thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone

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

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