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