Blame SOURCES/kvm-virtio-blk-Release-s-rq-queue-at-system_reset.patch

619821
From 200748826a6069c31f5004dde00614675bac659b Mon Sep 17 00:00:00 2001
4f5da8
From: Fam Zheng <famz@redhat.com>
619821
Date: Tue, 7 Feb 2017 09:21:53 +0100
619821
Subject: [PATCH 02/11] virtio-blk: Release s->rq queue at system_reset
4f5da8
4f5da8
RH-Author: Fam Zheng <famz@redhat.com>
619821
Message-id: <20170207092153.8331-1-famz@redhat.com>
619821
Patchwork-id: 73553
619821
O-Subject: [RHEL-7.4 qemu-kvm PATCH] virtio-blk: Release s->rq queue at system_reset
619821
Bugzilla: 1361488
4f5da8
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
619821
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
619821
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
4f5da8
4f5da8
At system_reset, there is no point in retrying the queued request,
4f5da8
because the driver that issued the request won't be around any more.
4f5da8
4f5da8
Analyzed-by: Laszlo Ersek <lersek@redhat.com>
4f5da8
Reported-by: Laszlo Ersek <lersek@redhat.com>
4f5da8
Signed-off-by: Fam Zheng <famz@redhat.com>
4f5da8
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
4f5da8
Message-id: 1470278654-13525-2-git-send-email-famz@redhat.com
4f5da8
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
4f5da8
(cherry picked from commit 26307f6aa451708b8c60a49d605a78bbd29f70ef)
4f5da8
4f5da8
 Conflicts:
4f5da8
	hw/block/virtio-blk.c
4f5da8
4f5da8
The context is different. The hunk is placed below bdrv_drain_all() with
4f5da8
the comment updated to match downstream.
4f5da8
4f5da8
There is no virtio_blk_free_request in qemu-kvm in RHEL 7, use g_free().
4f5da8
4f5da8
Signed-off-by: Fam Zheng <famz@redhat.com>
4f5da8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
4f5da8
---
4f5da8
 hw/block/virtio-blk.c | 8 ++++++++
4f5da8
 1 file changed, 8 insertions(+)
4f5da8
4f5da8
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
4f5da8
index 4f6aa22..462ac81 100644
4f5da8
--- a/hw/block/virtio-blk.c
4f5da8
+++ b/hw/block/virtio-blk.c
4f5da8
@@ -474,6 +474,7 @@ static void virtio_blk_dma_restart_cb(void *opaque, int running,
4f5da8
 static void virtio_blk_reset(VirtIODevice *vdev)
4f5da8
 {
4f5da8
     VirtIOBlock *s = VIRTIO_BLK(vdev);
4f5da8
+    VirtIOBlockReq *req;
4f5da8
 
4f5da8
 #ifdef CONFIG_VIRTIO_BLK_DATA_PLANE
4f5da8
     if (s->dataplane) {
4f5da8
@@ -487,6 +488,13 @@ static void virtio_blk_reset(VirtIODevice *vdev)
4f5da8
      */
4f5da8
     bdrv_drain_all();
4f5da8
     bdrv_set_enable_write_cache(s->bs, s->original_wce);
4f5da8
+    /* We drop queued requests after bdrv_drain_all() because bdrv_drain_all()
4f5da8
+     * itself can produce them. */
4f5da8
+    while (s->rq) {
4f5da8
+        req = s->rq;
4f5da8
+        s->rq = req->next;
4f5da8
+        g_free(req);
4f5da8
+    }
4f5da8
 }
4f5da8
 
4f5da8
 /* coalesce internal state, copy to pci i/o region 0
4f5da8
-- 
4f5da8
1.8.3.1
4f5da8