Blame SOURCES/kvm-virtio-blk-Increase-in_flight-for-request-restart-BH.patch

383d26
From 399ed639cc85835eb7a4a7241df6c1741c0578ba Mon Sep 17 00:00:00 2001
383d26
From: Kevin Wolf <kwolf@redhat.com>
383d26
Date: Fri, 1 Mar 2019 14:27:44 +0100
383d26
Subject: [PATCH 2/9] virtio-blk: Increase in_flight for request restart BH
383d26
383d26
RH-Author: Kevin Wolf <kwolf@redhat.com>
383d26
Message-id: <20190301142747.12251-3-kwolf@redhat.com>
383d26
Patchwork-id: 84762
383d26
O-Subject: [RHEL-7.7 qemu-kvm-rhev PATCH 2/5] virtio-blk: Increase in_flight for request restart BH
383d26
Bugzilla: 1671173
383d26
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
383d26
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
383d26
RH-Acked-by: John Snow <jsnow@redhat.com>
383d26
383d26
virtio_blk_dma_restart_bh() submits new requests, so in order to make
383d26
sure that these requests are not started inside a drained section of the
383d26
attached BlockBackend, we need to make sure that draining the
383d26
BlockBackend waits for the BH to be executed.
383d26
383d26
This BH is still questionable because its scheduled in the main thread
383d26
instead of the configured iothread. Leave a FIXME comment for this.
383d26
383d26
But with this fix, enabling the data plane at least waits for these
383d26
requests (in bdrv_set_aio_context()) instead of changing the AioContext
383d26
under their feet and making them run in the wrong thread, causing
383d26
crashes and failures (e.g. due to missing locking).
383d26
383d26
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
383d26
(cherry picked from commit 680f200217748e0920b79ec1d524717c2f50935b)
383d26
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
383d26
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
383d26
---
383d26
 hw/block/virtio-blk.c | 4 ++++
383d26
 1 file changed, 4 insertions(+)
383d26
383d26
diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c
383d26
index b1532e4..691ade4 100644
383d26
--- a/hw/block/virtio-blk.c
383d26
+++ b/hw/block/virtio-blk.c
383d26
@@ -678,6 +678,7 @@ static void virtio_blk_dma_restart_bh(void *opaque)
383d26
     if (mrb.num_reqs) {
383d26
         virtio_blk_submit_multireq(s->blk, &mrb);
383d26
     }
383d26
+    blk_dec_in_flight(s->conf.conf.blk);
383d26
     aio_context_release(blk_get_aio_context(s->conf.conf.blk));
383d26
 }
383d26
 
383d26
@@ -691,8 +692,11 @@ static void virtio_blk_dma_restart_cb(void *opaque, int running,
383d26
     }
383d26
 
383d26
     if (!s->bh) {
383d26
+        /* FIXME The data plane is not started yet, so these requests are
383d26
+         * processed in the main thread. */
383d26
         s->bh = aio_bh_new(blk_get_aio_context(s->conf.conf.blk),
383d26
                            virtio_blk_dma_restart_bh, s);
383d26
+        blk_inc_in_flight(s->conf.conf.blk);
383d26
         qemu_bh_schedule(s->bh);
383d26
     }
383d26
 }
383d26
-- 
383d26
1.8.3.1
383d26