Blame SOURCES/kvm-block-Drain-source-node-in-bdrv_replace_node.patch

8b1478
From b8a78d2f99bb481e78686ef2e0beb369b5563d87 Mon Sep 17 00:00:00 2001
8b1478
From: Kevin Wolf <kwolf@redhat.com>
8b1478
Date: Tue, 3 Sep 2019 15:28:28 +0200
8b1478
Subject: [PATCH 23/23] block: Drain source node in bdrv_replace_node()
8b1478
8b1478
RH-Author: Kevin Wolf <kwolf@redhat.com>
8b1478
Message-id: <20190903152828.15668-2-kwolf@redhat.com>
8b1478
Patchwork-id: 90257
8b1478
O-Subject: [RHEL-7.7.z qemu-kvm PATCH 1/1] block: Drain source node in bdrv_replace_node()
8b1478
Bugzilla: 1711643
8b1478
RH-Acked-by: John Snow <jsnow@redhat.com>
8b1478
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
8b1478
RH-Acked-by: Pankaj Gupta <pagupta@redhat.com>
8b1478
8b1478
Instead of just asserting that no requests are in flight in
8b1478
bdrv_replace_node(), which is a requirement that most callers ignore, we
8b1478
can just drain the source node right there. This fixes at least starting
8b1478
a commit job while I/O is active on the backing chain, but probably
8b1478
other callers, too.
8b1478
8b1478
Having requests in flight on the target node isn't a problem because the
8b1478
target just gets new parents, but the call path of running requests
8b1478
isn't modified. So we can just drop this assertion without a replacement.
8b1478
8b1478
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1711643
8b1478
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8b1478
Reviewed-by: Max Reitz <mreitz@redhat.com>
8b1478
(cherry picked from commit f871abd60f4b67547e62c57c9bec19420052be39)
8b1478
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
8b1478
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
8b1478
---
8b1478
 block.c | 7 ++++---
8b1478
 1 file changed, 4 insertions(+), 3 deletions(-)
8b1478
8b1478
diff --git a/block.c b/block.c
8b1478
index 7061f9b..4986516 100644
8b1478
--- a/block.c
8b1478
+++ b/block.c
8b1478
@@ -3505,13 +3505,13 @@ void bdrv_replace_node(BlockDriverState *from, BlockDriverState *to,
8b1478
     uint64_t perm = 0, shared = BLK_PERM_ALL;
8b1478
     int ret;
8b1478
 
8b1478
-    assert(!atomic_read(&from->in_flight));
8b1478
-    assert(!atomic_read(&to->in_flight));
8b1478
-
8b1478
     /* Make sure that @from doesn't go away until we have successfully attached
8b1478
      * all of its parents to @to. */
8b1478
     bdrv_ref(from);
8b1478
 
8b1478
+    assert(qemu_get_current_aio_context() == qemu_get_aio_context());
8b1478
+    bdrv_drained_begin(from);
8b1478
+
8b1478
     /* Put all parents into @list and calculate their cumulative permissions */
8b1478
     QLIST_FOREACH_SAFE(c, &from->parents, next_parent, next) {
8b1478
         if (!should_update_child(c, to)) {
8b1478
@@ -3546,6 +3546,7 @@ void bdrv_replace_node(BlockDriverState *from, BlockDriverState *to,
8b1478
 
8b1478
 out:
8b1478
     g_slist_free(list);
8b1478
+    bdrv_drained_end(from);
8b1478
     bdrv_unref(from);
8b1478
 }
8b1478
 
8b1478
-- 
8b1478
1.8.3.1
8b1478