26ba25
From e6d8bc54a031c61c1fce2c9e1ccdb821b5991c1a Mon Sep 17 00:00:00 2001
26ba25
From: Kevin Wolf <kwolf@redhat.com>
26ba25
Date: Wed, 10 Oct 2018 20:08:42 +0100
26ba25
Subject: [PATCH 11/49] block: Remove bdrv_drain_recurse()
26ba25
26ba25
RH-Author: Kevin Wolf <kwolf@redhat.com>
26ba25
Message-id: <20181010200843.6710-9-kwolf@redhat.com>
26ba25
Patchwork-id: 82588
26ba25
O-Subject: [RHEL-8 qemu-kvm PATCH 08/44] block: Remove bdrv_drain_recurse()
26ba25
Bugzilla: 1637976
26ba25
RH-Acked-by: Max Reitz <mreitz@redhat.com>
26ba25
RH-Acked-by: John Snow <jsnow@redhat.com>
26ba25
RH-Acked-by: Thomas Huth <thuth@redhat.com>
26ba25
26ba25
For bdrv_drain(), recursively waiting for child node requests is
26ba25
pointless because we didn't quiesce their parents, so new requests could
26ba25
come in anyway. Letting the function work only on a single node makes it
26ba25
more consistent.
26ba25
26ba25
For subtree drains and drain_all, we already have the recursion in
26ba25
bdrv_do_drained_begin(), so the extra recursion doesn't add anything
26ba25
either.
26ba25
26ba25
Remove the useless code.
26ba25
26ba25
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
26ba25
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
26ba25
(cherry picked from commit d30b8e64b7b282da785307504ada59efa8096fb1)
26ba25
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
26ba25
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
26ba25
---
26ba25
 block/io.c | 36 +++---------------------------------
26ba25
 1 file changed, 3 insertions(+), 33 deletions(-)
26ba25
26ba25
diff --git a/block/io.c b/block/io.c
26ba25
index e260394..a0e3461 100644
26ba25
--- a/block/io.c
26ba25
+++ b/block/io.c
26ba25
@@ -218,38 +218,6 @@ static bool bdrv_drain_poll_top_level(BlockDriverState *bs,
26ba25
     return bdrv_drain_poll(bs, ignore_parent);
26ba25
 }
26ba25
 
26ba25
-static bool bdrv_drain_recurse(BlockDriverState *bs, BdrvChild *parent)
26ba25
-{
26ba25
-    BdrvChild *child, *tmp;
26ba25
-    bool waited;
26ba25
-
26ba25
-    /* Wait for drained requests to finish */
26ba25
-    waited = BDRV_POLL_WHILE(bs, bdrv_drain_poll_top_level(bs, parent));
26ba25
-
26ba25
-    QLIST_FOREACH_SAFE(child, &bs->children, next, tmp) {
26ba25
-        BlockDriverState *bs = child->bs;
26ba25
-        bool in_main_loop =
26ba25
-            qemu_get_current_aio_context() == qemu_get_aio_context();
26ba25
-        assert(bs->refcnt > 0);
26ba25
-        if (in_main_loop) {
26ba25
-            /* In case the recursive bdrv_drain_recurse processes a
26ba25
-             * block_job_defer_to_main_loop BH and modifies the graph,
26ba25
-             * let's hold a reference to bs until we are done.
26ba25
-             *
26ba25
-             * IOThread doesn't have such a BH, and it is not safe to call
26ba25
-             * bdrv_unref without BQL, so skip doing it there.
26ba25
-             */
26ba25
-            bdrv_ref(bs);
26ba25
-        }
26ba25
-        waited |= bdrv_drain_recurse(bs, child);
26ba25
-        if (in_main_loop) {
26ba25
-            bdrv_unref(bs);
26ba25
-        }
26ba25
-    }
26ba25
-
26ba25
-    return waited;
26ba25
-}
26ba25
-
26ba25
 static void bdrv_do_drained_begin(BlockDriverState *bs, bool recursive,
26ba25
                                   BdrvChild *parent);
26ba25
 static void bdrv_do_drained_end(BlockDriverState *bs, bool recursive,
26ba25
@@ -317,7 +285,9 @@ void bdrv_do_drained_begin(BlockDriverState *bs, bool recursive,
26ba25
 
26ba25
     bdrv_parent_drained_begin(bs, parent);
26ba25
     bdrv_drain_invoke(bs, true);
26ba25
-    bdrv_drain_recurse(bs, parent);
26ba25
+
26ba25
+    /* Wait for drained requests to finish */
26ba25
+    BDRV_POLL_WHILE(bs, bdrv_drain_poll_top_level(bs, parent));
26ba25
 
26ba25
     if (recursive) {
26ba25
         bs->recursive_quiesce_counter++;
26ba25
-- 
26ba25
1.8.3.1
26ba25