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

4f5da8
From cc9a8ce29ba364abcf019f6fe44b218255b9e4d7 Mon Sep 17 00:00:00 2001
4f5da8
From: Fam Zheng <famz@redhat.com>
4f5da8
Date: Wed, 8 Feb 2017 07:05:34 +0100
4f5da8
Subject: [PATCH 1/8] virtio-blk: Release s->rq queue at system_reset
4f5da8
4f5da8
RH-Author: Fam Zheng <famz@redhat.com>
4f5da8
Message-id: <20170208070534.10571-1-famz@redhat.com>
4f5da8
Patchwork-id: 73642
4f5da8
O-Subject: [RHEL-7.3.z qemu-kvm PATCH] virtio-blk: Release s->rq queue at system_reset
4f5da8
Bugzilla: 1420049
4f5da8
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
4f5da8
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
4f5da8
RH-Acked-by: Laurent Vivier <lvivier@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