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

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