7f1c5b
From 79063522861cb2baf921b204bcdf4c3bfb5697f4 Mon Sep 17 00:00:00 2001
7f1c5b
From: Kevin Wolf <kwolf@redhat.com>
7f1c5b
Date: Fri, 18 Nov 2022 18:41:05 +0100
7f1c5b
Subject: [PATCH 23/31] block: Remove subtree drains
7f1c5b
7f1c5b
RH-Author: Stefano Garzarella <sgarzare@redhat.com>
7f1c5b
RH-MergeRequest: 135: block: Simplify drain to prevent QEMU from crashing during snapshot
7f1c5b
RH-Bugzilla: 2155112
7f1c5b
RH-Acked-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
7f1c5b
RH-Acked-by: Hanna Czenczek <hreitz@redhat.com>
7f1c5b
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
7f1c5b
RH-Commit: [11/16] d92f5041cceeeec49a65441b22d20f692c0f1c77 (sgarzarella/qemu-kvm-c-9-s)
7f1c5b
7f1c5b
Subtree drains are not used any more. Remove them.
7f1c5b
7f1c5b
After this, BdrvChildClass.attach/detach() don't poll any more.
7f1c5b
7f1c5b
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7f1c5b
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
7f1c5b
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
7f1c5b
Message-Id: <20221118174110.55183-11-kwolf@redhat.com>
7f1c5b
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7f1c5b
(cherry picked from commit 299403aedaeb7f08d8e98aa8614b29d4e5546066)
7f1c5b
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
7f1c5b
---
7f1c5b
 block.c                          |  20 +--
7f1c5b
 block/io.c                       | 121 +++-----------
7f1c5b
 include/block/block-io.h         |  18 +--
7f1c5b
 include/block/block_int-common.h |   1 -
7f1c5b
 include/block/block_int-io.h     |  12 --
7f1c5b
 tests/unit/test-bdrv-drain.c     | 261 ++-----------------------------
7f1c5b
 6 files changed, 44 insertions(+), 389 deletions(-)
7f1c5b
7f1c5b
diff --git a/block.c b/block.c
7f1c5b
index 5330e89903..e0e3b21790 100644
7f1c5b
--- a/block.c
7f1c5b
+++ b/block.c
7f1c5b
@@ -1232,7 +1232,7 @@ static void bdrv_child_cb_drained_begin(BdrvChild *child)
7f1c5b
 static bool bdrv_child_cb_drained_poll(BdrvChild *child)
7f1c5b
 {
7f1c5b
     BlockDriverState *bs = child->opaque;
7f1c5b
-    return bdrv_drain_poll(bs, false, NULL, false);
7f1c5b
+    return bdrv_drain_poll(bs, NULL, false);
7f1c5b
 }
7f1c5b
 
7f1c5b
 static void bdrv_child_cb_drained_end(BdrvChild *child)
7f1c5b
@@ -1482,8 +1482,6 @@ static void bdrv_child_cb_attach(BdrvChild *child)
7f1c5b
         assert(!bs->file);
7f1c5b
         bs->file = child;
7f1c5b
     }
7f1c5b
-
7f1c5b
-    bdrv_apply_subtree_drain(child, bs);
7f1c5b
 }
7f1c5b
 
7f1c5b
 static void bdrv_child_cb_detach(BdrvChild *child)
7f1c5b
@@ -1494,8 +1492,6 @@ static void bdrv_child_cb_detach(BdrvChild *child)
7f1c5b
         bdrv_backing_detach(child);
7f1c5b
     }
7f1c5b
 
7f1c5b
-    bdrv_unapply_subtree_drain(child, bs);
7f1c5b
-
7f1c5b
     assert_bdrv_graph_writable(bs);
7f1c5b
     QLIST_REMOVE(child, next);
7f1c5b
     if (child == bs->backing) {
7f1c5b
@@ -2851,9 +2847,6 @@ static void bdrv_replace_child_noperm(BdrvChild *child,
7f1c5b
     }
7f1c5b
 
7f1c5b
     if (old_bs) {
7f1c5b
-        /* Detach first so that the recursive drain sections coming from @child
7f1c5b
-         * are already gone and we only end the drain sections that came from
7f1c5b
-         * elsewhere. */
7f1c5b
         if (child->klass->detach) {
7f1c5b
             child->klass->detach(child);
7f1c5b
         }
7f1c5b
@@ -2868,17 +2861,14 @@ static void bdrv_replace_child_noperm(BdrvChild *child,
7f1c5b
         QLIST_INSERT_HEAD(&new_bs->parents, child, next_parent);
7f1c5b
 
7f1c5b
         /*
7f1c5b
-         * Detaching the old node may have led to the new node's
7f1c5b
-         * quiesce_counter having been decreased.  Not a problem, we
7f1c5b
-         * just need to recognize this here and then invoke
7f1c5b
-         * drained_end appropriately more often.
7f1c5b
+         * Polling in bdrv_parent_drained_begin_single() may have led to the new
7f1c5b
+         * node's quiesce_counter having been decreased.  Not a problem, we just
7f1c5b
+         * need to recognize this here and then invoke drained_end appropriately
7f1c5b
+         * more often.
7f1c5b
          */
7f1c5b
         assert(new_bs->quiesce_counter <= new_bs_quiesce_counter);
7f1c5b
         drain_saldo += new_bs->quiesce_counter - new_bs_quiesce_counter;
7f1c5b
 
7f1c5b
-        /* Attach only after starting new drained sections, so that recursive
7f1c5b
-         * drain sections coming from @child don't get an extra .drained_begin
7f1c5b
-         * callback. */
7f1c5b
         if (child->klass->attach) {
7f1c5b
             child->klass->attach(child);
7f1c5b
         }
7f1c5b
diff --git a/block/io.c b/block/io.c
7f1c5b
index a25103be6f..75224480d0 100644
7f1c5b
--- a/block/io.c
7f1c5b
+++ b/block/io.c
7f1c5b
@@ -236,17 +236,15 @@ typedef struct {
7f1c5b
     BlockDriverState *bs;
7f1c5b
     bool done;
7f1c5b
     bool begin;
7f1c5b
-    bool recursive;
7f1c5b
     bool poll;
7f1c5b
     BdrvChild *parent;
7f1c5b
     bool ignore_bds_parents;
7f1c5b
 } BdrvCoDrainData;
7f1c5b
 
7f1c5b
 /* Returns true if BDRV_POLL_WHILE() should go into a blocking aio_poll() */
7f1c5b
-bool bdrv_drain_poll(BlockDriverState *bs, bool recursive,
7f1c5b
-                     BdrvChild *ignore_parent, bool ignore_bds_parents)
7f1c5b
+bool bdrv_drain_poll(BlockDriverState *bs, BdrvChild *ignore_parent,
7f1c5b
+                     bool ignore_bds_parents)
7f1c5b
 {
7f1c5b
-    BdrvChild *child, *next;
7f1c5b
     IO_OR_GS_CODE();
7f1c5b
 
7f1c5b
     if (bdrv_parent_drained_poll(bs, ignore_parent, ignore_bds_parents)) {
7f1c5b
@@ -257,29 +255,19 @@ bool bdrv_drain_poll(BlockDriverState *bs, bool recursive,
7f1c5b
         return true;
7f1c5b
     }
7f1c5b
 
7f1c5b
-    if (recursive) {
7f1c5b
-        assert(!ignore_bds_parents);
7f1c5b
-        QLIST_FOREACH_SAFE(child, &bs->children, next, next) {
7f1c5b
-            if (bdrv_drain_poll(child->bs, recursive, child, false)) {
7f1c5b
-                return true;
7f1c5b
-            }
7f1c5b
-        }
7f1c5b
-    }
7f1c5b
-
7f1c5b
     return false;
7f1c5b
 }
7f1c5b
 
7f1c5b
-static bool bdrv_drain_poll_top_level(BlockDriverState *bs, bool recursive,
7f1c5b
+static bool bdrv_drain_poll_top_level(BlockDriverState *bs,
7f1c5b
                                       BdrvChild *ignore_parent)
7f1c5b
 {
7f1c5b
-    return bdrv_drain_poll(bs, recursive, ignore_parent, false);
7f1c5b
+    return bdrv_drain_poll(bs, ignore_parent, false);
7f1c5b
 }
7f1c5b
 
7f1c5b
-static void bdrv_do_drained_begin(BlockDriverState *bs, bool recursive,
7f1c5b
-                                  BdrvChild *parent, bool ignore_bds_parents,
7f1c5b
-                                  bool poll);
7f1c5b
-static void bdrv_do_drained_end(BlockDriverState *bs, bool recursive,
7f1c5b
-                                BdrvChild *parent, bool ignore_bds_parents);
7f1c5b
+static void bdrv_do_drained_begin(BlockDriverState *bs, BdrvChild *parent,
7f1c5b
+                                  bool ignore_bds_parents, bool poll);
7f1c5b
+static void bdrv_do_drained_end(BlockDriverState *bs, BdrvChild *parent,
7f1c5b
+                                bool ignore_bds_parents);
7f1c5b
 
7f1c5b
 static void bdrv_co_drain_bh_cb(void *opaque)
7f1c5b
 {
7f1c5b
@@ -292,12 +280,11 @@ static void bdrv_co_drain_bh_cb(void *opaque)
7f1c5b
         aio_context_acquire(ctx);
7f1c5b
         bdrv_dec_in_flight(bs);
7f1c5b
         if (data->begin) {
7f1c5b
-            bdrv_do_drained_begin(bs, data->recursive, data->parent,
7f1c5b
-                                  data->ignore_bds_parents, data->poll);
7f1c5b
+            bdrv_do_drained_begin(bs, data->parent, data->ignore_bds_parents,
7f1c5b
+                                  data->poll);
7f1c5b
         } else {
7f1c5b
             assert(!data->poll);
7f1c5b
-            bdrv_do_drained_end(bs, data->recursive, data->parent,
7f1c5b
-                                data->ignore_bds_parents);
7f1c5b
+            bdrv_do_drained_end(bs, data->parent, data->ignore_bds_parents);
7f1c5b
         }
7f1c5b
         aio_context_release(ctx);
7f1c5b
     } else {
7f1c5b
@@ -310,7 +297,7 @@ static void bdrv_co_drain_bh_cb(void *opaque)
7f1c5b
 }
7f1c5b
 
7f1c5b
 static void coroutine_fn bdrv_co_yield_to_drain(BlockDriverState *bs,
7f1c5b
-                                                bool begin, bool recursive,
7f1c5b
+                                                bool begin,
7f1c5b
                                                 BdrvChild *parent,
7f1c5b
                                                 bool ignore_bds_parents,
7f1c5b
                                                 bool poll)
7f1c5b
@@ -329,7 +316,6 @@ static void coroutine_fn bdrv_co_yield_to_drain(BlockDriverState *bs,
7f1c5b
         .bs = bs,
7f1c5b
         .done = false,
7f1c5b
         .begin = begin,
7f1c5b
-        .recursive = recursive,
7f1c5b
         .parent = parent,
7f1c5b
         .ignore_bds_parents = ignore_bds_parents,
7f1c5b
         .poll = poll,
7f1c5b
@@ -380,29 +366,16 @@ void bdrv_do_drained_begin_quiesce(BlockDriverState *bs,
7f1c5b
     }
7f1c5b
 }
7f1c5b
 
7f1c5b
-static void bdrv_do_drained_begin(BlockDriverState *bs, bool recursive,
7f1c5b
-                                  BdrvChild *parent, bool ignore_bds_parents,
7f1c5b
-                                  bool poll)
7f1c5b
+static void bdrv_do_drained_begin(BlockDriverState *bs, BdrvChild *parent,
7f1c5b
+                                  bool ignore_bds_parents, bool poll)
7f1c5b
 {
7f1c5b
-    BdrvChild *child, *next;
7f1c5b
-
7f1c5b
     if (qemu_in_coroutine()) {
7f1c5b
-        bdrv_co_yield_to_drain(bs, true, recursive, parent, ignore_bds_parents,
7f1c5b
-                               poll);
7f1c5b
+        bdrv_co_yield_to_drain(bs, true, parent, ignore_bds_parents, poll);
7f1c5b
         return;
7f1c5b
     }
7f1c5b
 
7f1c5b
     bdrv_do_drained_begin_quiesce(bs, parent, ignore_bds_parents);
7f1c5b
 
7f1c5b
-    if (recursive) {
7f1c5b
-        assert(!ignore_bds_parents);
7f1c5b
-        bs->recursive_quiesce_counter++;
7f1c5b
-        QLIST_FOREACH_SAFE(child, &bs->children, next, next) {
7f1c5b
-            bdrv_do_drained_begin(child->bs, true, child, ignore_bds_parents,
7f1c5b
-                                  false);
7f1c5b
-        }
7f1c5b
-    }
7f1c5b
-
7f1c5b
     /*
7f1c5b
      * Wait for drained requests to finish.
7f1c5b
      *
7f1c5b
@@ -414,35 +387,27 @@ static void bdrv_do_drained_begin(BlockDriverState *bs, bool recursive,
7f1c5b
      */
7f1c5b
     if (poll) {
7f1c5b
         assert(!ignore_bds_parents);
7f1c5b
-        BDRV_POLL_WHILE(bs, bdrv_drain_poll_top_level(bs, recursive, parent));
7f1c5b
+        BDRV_POLL_WHILE(bs, bdrv_drain_poll_top_level(bs, parent));
7f1c5b
     }
7f1c5b
 }
7f1c5b
 
7f1c5b
 void bdrv_drained_begin(BlockDriverState *bs)
7f1c5b
 {
7f1c5b
     IO_OR_GS_CODE();
7f1c5b
-    bdrv_do_drained_begin(bs, false, NULL, false, true);
7f1c5b
-}
7f1c5b
-
7f1c5b
-void bdrv_subtree_drained_begin(BlockDriverState *bs)
7f1c5b
-{
7f1c5b
-    IO_OR_GS_CODE();
7f1c5b
-    bdrv_do_drained_begin(bs, true, NULL, false, true);
7f1c5b
+    bdrv_do_drained_begin(bs, NULL, false, true);
7f1c5b
 }
7f1c5b
 
7f1c5b
 /**
7f1c5b
  * This function does not poll, nor must any of its recursively called
7f1c5b
  * functions.
7f1c5b
  */
7f1c5b
-static void bdrv_do_drained_end(BlockDriverState *bs, bool recursive,
7f1c5b
-                                BdrvChild *parent, bool ignore_bds_parents)
7f1c5b
+static void bdrv_do_drained_end(BlockDriverState *bs, BdrvChild *parent,
7f1c5b
+                                bool ignore_bds_parents)
7f1c5b
 {
7f1c5b
-    BdrvChild *child;
7f1c5b
     int old_quiesce_counter;
7f1c5b
 
7f1c5b
     if (qemu_in_coroutine()) {
7f1c5b
-        bdrv_co_yield_to_drain(bs, false, recursive, parent, ignore_bds_parents,
7f1c5b
-                               false);
7f1c5b
+        bdrv_co_yield_to_drain(bs, false, parent, ignore_bds_parents, false);
7f1c5b
         return;
7f1c5b
     }
7f1c5b
     assert(bs->quiesce_counter > 0);
7f1c5b
@@ -457,46 +422,12 @@ static void bdrv_do_drained_end(BlockDriverState *bs, bool recursive,
7f1c5b
     if (old_quiesce_counter == 1) {
7f1c5b
         aio_enable_external(bdrv_get_aio_context(bs));
7f1c5b
     }
7f1c5b
-
7f1c5b
-    if (recursive) {
7f1c5b
-        assert(!ignore_bds_parents);
7f1c5b
-        bs->recursive_quiesce_counter--;
7f1c5b
-        QLIST_FOREACH(child, &bs->children, next) {
7f1c5b
-            bdrv_do_drained_end(child->bs, true, child, ignore_bds_parents);
7f1c5b
-        }
7f1c5b
-    }
7f1c5b
 }
7f1c5b
 
7f1c5b
 void bdrv_drained_end(BlockDriverState *bs)
7f1c5b
 {
7f1c5b
     IO_OR_GS_CODE();
7f1c5b
-    bdrv_do_drained_end(bs, false, NULL, false);
7f1c5b
-}
7f1c5b
-
7f1c5b
-void bdrv_subtree_drained_end(BlockDriverState *bs)
7f1c5b
-{
7f1c5b
-    IO_OR_GS_CODE();
7f1c5b
-    bdrv_do_drained_end(bs, true, NULL, false);
7f1c5b
-}
7f1c5b
-
7f1c5b
-void bdrv_apply_subtree_drain(BdrvChild *child, BlockDriverState *new_parent)
7f1c5b
-{
7f1c5b
-    int i;
7f1c5b
-    IO_OR_GS_CODE();
7f1c5b
-
7f1c5b
-    for (i = 0; i < new_parent->recursive_quiesce_counter; i++) {
7f1c5b
-        bdrv_do_drained_begin(child->bs, true, child, false, true);
7f1c5b
-    }
7f1c5b
-}
7f1c5b
-
7f1c5b
-void bdrv_unapply_subtree_drain(BdrvChild *child, BlockDriverState *old_parent)
7f1c5b
-{
7f1c5b
-    int i;
7f1c5b
-    IO_OR_GS_CODE();
7f1c5b
-
7f1c5b
-    for (i = 0; i < old_parent->recursive_quiesce_counter; i++) {
7f1c5b
-        bdrv_do_drained_end(child->bs, true, child, false);
7f1c5b
-    }
7f1c5b
+    bdrv_do_drained_end(bs, NULL, false);
7f1c5b
 }
7f1c5b
 
7f1c5b
 void bdrv_drain(BlockDriverState *bs)
7f1c5b
@@ -529,7 +460,7 @@ static bool bdrv_drain_all_poll(void)
7f1c5b
     while ((bs = bdrv_next_all_states(bs))) {
7f1c5b
         AioContext *aio_context = bdrv_get_aio_context(bs);
7f1c5b
         aio_context_acquire(aio_context);
7f1c5b
-        result |= bdrv_drain_poll(bs, false, NULL, true);
7f1c5b
+        result |= bdrv_drain_poll(bs, NULL, true);
7f1c5b
         aio_context_release(aio_context);
7f1c5b
     }
7f1c5b
 
7f1c5b
@@ -554,7 +485,7 @@ void bdrv_drain_all_begin(void)
7f1c5b
     GLOBAL_STATE_CODE();
7f1c5b
 
7f1c5b
     if (qemu_in_coroutine()) {
7f1c5b
-        bdrv_co_yield_to_drain(NULL, true, false, NULL, true, true);
7f1c5b
+        bdrv_co_yield_to_drain(NULL, true, NULL, true, true);
7f1c5b
         return;
7f1c5b
     }
7f1c5b
 
7f1c5b
@@ -579,7 +510,7 @@ void bdrv_drain_all_begin(void)
7f1c5b
         AioContext *aio_context = bdrv_get_aio_context(bs);
7f1c5b
 
7f1c5b
         aio_context_acquire(aio_context);
7f1c5b
-        bdrv_do_drained_begin(bs, false, NULL, true, false);
7f1c5b
+        bdrv_do_drained_begin(bs, NULL, true, false);
7f1c5b
         aio_context_release(aio_context);
7f1c5b
     }
7f1c5b
 
7f1c5b
@@ -599,7 +530,7 @@ void bdrv_drain_all_end_quiesce(BlockDriverState *bs)
7f1c5b
     g_assert(!bs->refcnt);
7f1c5b
 
7f1c5b
     while (bs->quiesce_counter) {
7f1c5b
-        bdrv_do_drained_end(bs, false, NULL, true);
7f1c5b
+        bdrv_do_drained_end(bs, NULL, true);
7f1c5b
     }
7f1c5b
 }
7f1c5b
 
7f1c5b
@@ -621,7 +552,7 @@ void bdrv_drain_all_end(void)
7f1c5b
         AioContext *aio_context = bdrv_get_aio_context(bs);
7f1c5b
 
7f1c5b
         aio_context_acquire(aio_context);
7f1c5b
-        bdrv_do_drained_end(bs, false, NULL, true);
7f1c5b
+        bdrv_do_drained_end(bs, NULL, true);
7f1c5b
         aio_context_release(aio_context);
7f1c5b
     }
7f1c5b
 
7f1c5b
diff --git a/include/block/block-io.h b/include/block/block-io.h
7f1c5b
index 054e964c9b..9c36a16a1f 100644
7f1c5b
--- a/include/block/block-io.h
7f1c5b
+++ b/include/block/block-io.h
7f1c5b
@@ -302,8 +302,7 @@ void bdrv_parent_drained_end_single(BdrvChild *c);
7f1c5b
 /**
7f1c5b
  * bdrv_drain_poll:
7f1c5b
  *
7f1c5b
- * Poll for pending requests in @bs, its parents (except for @ignore_parent),
7f1c5b
- * and if @recursive is true its children as well (used for subtree drain).
7f1c5b
+ * Poll for pending requests in @bs and its parents (except for @ignore_parent).
7f1c5b
  *
7f1c5b
  * If @ignore_bds_parents is true, parents that are BlockDriverStates must
7f1c5b
  * ignore the drain request because they will be drained separately (used for
7f1c5b
@@ -311,8 +310,8 @@ void bdrv_parent_drained_end_single(BdrvChild *c);
7f1c5b
  *
7f1c5b
  * This is part of bdrv_drained_begin.
7f1c5b
  */
7f1c5b
-bool bdrv_drain_poll(BlockDriverState *bs, bool recursive,
7f1c5b
-                     BdrvChild *ignore_parent, bool ignore_bds_parents);
7f1c5b
+bool bdrv_drain_poll(BlockDriverState *bs, BdrvChild *ignore_parent,
7f1c5b
+                     bool ignore_bds_parents);
7f1c5b
 
7f1c5b
 /**
7f1c5b
  * bdrv_drained_begin:
7f1c5b
@@ -333,12 +332,6 @@ void bdrv_drained_begin(BlockDriverState *bs);
7f1c5b
 void bdrv_do_drained_begin_quiesce(BlockDriverState *bs,
7f1c5b
                                    BdrvChild *parent, bool ignore_bds_parents);
7f1c5b
 
7f1c5b
-/**
7f1c5b
- * Like bdrv_drained_begin, but recursively begins a quiesced section for
7f1c5b
- * exclusive access to all child nodes as well.
7f1c5b
- */
7f1c5b
-void bdrv_subtree_drained_begin(BlockDriverState *bs);
7f1c5b
-
7f1c5b
 /**
7f1c5b
  * bdrv_drained_end:
7f1c5b
  *
7f1c5b
@@ -346,9 +339,4 @@ void bdrv_subtree_drained_begin(BlockDriverState *bs);
7f1c5b
  */
7f1c5b
 void bdrv_drained_end(BlockDriverState *bs);
7f1c5b
 
7f1c5b
-/**
7f1c5b
- * End a quiescent section started by bdrv_subtree_drained_begin().
7f1c5b
- */
7f1c5b
-void bdrv_subtree_drained_end(BlockDriverState *bs);
7f1c5b
-
7f1c5b
 #endif /* BLOCK_IO_H */
7f1c5b
diff --git a/include/block/block_int-common.h b/include/block/block_int-common.h
7f1c5b
index 2b97576f6d..791dddfd7d 100644
7f1c5b
--- a/include/block/block_int-common.h
7f1c5b
+++ b/include/block/block_int-common.h
7f1c5b
@@ -1184,7 +1184,6 @@ struct BlockDriverState {
7f1c5b
 
7f1c5b
     /* Accessed with atomic ops.  */
7f1c5b
     int quiesce_counter;
7f1c5b
-    int recursive_quiesce_counter;
7f1c5b
 
7f1c5b
     unsigned int write_gen;               /* Current data generation */
7f1c5b
 
7f1c5b
diff --git a/include/block/block_int-io.h b/include/block/block_int-io.h
7f1c5b
index 4b0b3e17ef..8bc061ebb8 100644
7f1c5b
--- a/include/block/block_int-io.h
7f1c5b
+++ b/include/block/block_int-io.h
7f1c5b
@@ -179,16 +179,4 @@ void bdrv_bsc_invalidate_range(BlockDriverState *bs,
7f1c5b
  */
7f1c5b
 void bdrv_bsc_fill(BlockDriverState *bs, int64_t offset, int64_t bytes);
7f1c5b
 
7f1c5b
-
7f1c5b
-/*
7f1c5b
- * "I/O or GS" API functions. These functions can run without
7f1c5b
- * the BQL, but only in one specific iothread/main loop.
7f1c5b
- *
7f1c5b
- * See include/block/block-io.h for more information about
7f1c5b
- * the "I/O or GS" API.
7f1c5b
- */
7f1c5b
-
7f1c5b
-void bdrv_apply_subtree_drain(BdrvChild *child, BlockDriverState *new_parent);
7f1c5b
-void bdrv_unapply_subtree_drain(BdrvChild *child, BlockDriverState *old_parent);
7f1c5b
-
7f1c5b
 #endif /* BLOCK_INT_IO_H */
7f1c5b
diff --git a/tests/unit/test-bdrv-drain.c b/tests/unit/test-bdrv-drain.c
7f1c5b
index 695519ee02..dda08de8db 100644
7f1c5b
--- a/tests/unit/test-bdrv-drain.c
7f1c5b
+++ b/tests/unit/test-bdrv-drain.c
7f1c5b
@@ -156,7 +156,6 @@ static void call_in_coroutine(void (*entry)(void))
7f1c5b
 enum drain_type {
7f1c5b
     BDRV_DRAIN_ALL,
7f1c5b
     BDRV_DRAIN,
7f1c5b
-    BDRV_SUBTREE_DRAIN,
7f1c5b
     DRAIN_TYPE_MAX,
7f1c5b
 };
7f1c5b
 
7f1c5b
@@ -165,7 +164,6 @@ static void do_drain_begin(enum drain_type drain_type, BlockDriverState *bs)
7f1c5b
     switch (drain_type) {
7f1c5b
     case BDRV_DRAIN_ALL:        bdrv_drain_all_begin(); break;
7f1c5b
     case BDRV_DRAIN:            bdrv_drained_begin(bs); break;
7f1c5b
-    case BDRV_SUBTREE_DRAIN:    bdrv_subtree_drained_begin(bs); break;
7f1c5b
     default:                    g_assert_not_reached();
7f1c5b
     }
7f1c5b
 }
7f1c5b
@@ -175,7 +173,6 @@ static void do_drain_end(enum drain_type drain_type, BlockDriverState *bs)
7f1c5b
     switch (drain_type) {
7f1c5b
     case BDRV_DRAIN_ALL:        bdrv_drain_all_end(); break;
7f1c5b
     case BDRV_DRAIN:            bdrv_drained_end(bs); break;
7f1c5b
-    case BDRV_SUBTREE_DRAIN:    bdrv_subtree_drained_end(bs); break;
7f1c5b
     default:                    g_assert_not_reached();
7f1c5b
     }
7f1c5b
 }
7f1c5b
@@ -271,11 +268,6 @@ static void test_drv_cb_drain(void)
7f1c5b
     test_drv_cb_common(BDRV_DRAIN, false);
7f1c5b
 }
7f1c5b
 
7f1c5b
-static void test_drv_cb_drain_subtree(void)
7f1c5b
-{
7f1c5b
-    test_drv_cb_common(BDRV_SUBTREE_DRAIN, true);
7f1c5b
-}
7f1c5b
-
7f1c5b
 static void test_drv_cb_co_drain_all(void)
7f1c5b
 {
7f1c5b
     call_in_coroutine(test_drv_cb_drain_all);
7f1c5b
@@ -286,11 +278,6 @@ static void test_drv_cb_co_drain(void)
7f1c5b
     call_in_coroutine(test_drv_cb_drain);
7f1c5b
 }
7f1c5b
 
7f1c5b
-static void test_drv_cb_co_drain_subtree(void)
7f1c5b
-{
7f1c5b
-    call_in_coroutine(test_drv_cb_drain_subtree);
7f1c5b
-}
7f1c5b
-
7f1c5b
 static void test_quiesce_common(enum drain_type drain_type, bool recursive)
7f1c5b
 {
7f1c5b
     BlockBackend *blk;
7f1c5b
@@ -332,11 +319,6 @@ static void test_quiesce_drain(void)
7f1c5b
     test_quiesce_common(BDRV_DRAIN, false);
7f1c5b
 }
7f1c5b
 
7f1c5b
-static void test_quiesce_drain_subtree(void)
7f1c5b
-{
7f1c5b
-    test_quiesce_common(BDRV_SUBTREE_DRAIN, true);
7f1c5b
-}
7f1c5b
-
7f1c5b
 static void test_quiesce_co_drain_all(void)
7f1c5b
 {
7f1c5b
     call_in_coroutine(test_quiesce_drain_all);
7f1c5b
@@ -347,11 +329,6 @@ static void test_quiesce_co_drain(void)
7f1c5b
     call_in_coroutine(test_quiesce_drain);
7f1c5b
 }
7f1c5b
 
7f1c5b
-static void test_quiesce_co_drain_subtree(void)
7f1c5b
-{
7f1c5b
-    call_in_coroutine(test_quiesce_drain_subtree);
7f1c5b
-}
7f1c5b
-
7f1c5b
 static void test_nested(void)
7f1c5b
 {
7f1c5b
     BlockBackend *blk;
7f1c5b
@@ -402,158 +379,6 @@ static void test_nested(void)
7f1c5b
     blk_unref(blk);
7f1c5b
 }
7f1c5b
 
7f1c5b
-static void test_multiparent(void)
7f1c5b
-{
7f1c5b
-    BlockBackend *blk_a, *blk_b;
7f1c5b
-    BlockDriverState *bs_a, *bs_b, *backing;
7f1c5b
-    BDRVTestState *a_s, *b_s, *backing_s;
7f1c5b
-
7f1c5b
-    blk_a = blk_new(qemu_get_aio_context(), BLK_PERM_ALL, BLK_PERM_ALL);
7f1c5b
-    bs_a = bdrv_new_open_driver(&bdrv_test, "test-node-a", BDRV_O_RDWR,
7f1c5b
-                                &error_abort);
7f1c5b
-    a_s = bs_a->opaque;
7f1c5b
-    blk_insert_bs(blk_a, bs_a, &error_abort);
7f1c5b
-
7f1c5b
-    blk_b = blk_new(qemu_get_aio_context(), BLK_PERM_ALL, BLK_PERM_ALL);
7f1c5b
-    bs_b = bdrv_new_open_driver(&bdrv_test, "test-node-b", BDRV_O_RDWR,
7f1c5b
-                                &error_abort);
7f1c5b
-    b_s = bs_b->opaque;
7f1c5b
-    blk_insert_bs(blk_b, bs_b, &error_abort);
7f1c5b
-
7f1c5b
-    backing = bdrv_new_open_driver(&bdrv_test, "backing", 0, &error_abort);
7f1c5b
-    backing_s = backing->opaque;
7f1c5b
-    bdrv_set_backing_hd(bs_a, backing, &error_abort);
7f1c5b
-    bdrv_set_backing_hd(bs_b, backing, &error_abort);
7f1c5b
-
7f1c5b
-    g_assert_cmpint(bs_a->quiesce_counter, ==, 0);
7f1c5b
-    g_assert_cmpint(bs_b->quiesce_counter, ==, 0);
7f1c5b
-    g_assert_cmpint(backing->quiesce_counter, ==, 0);
7f1c5b
-    g_assert_cmpint(a_s->drain_count, ==, 0);
7f1c5b
-    g_assert_cmpint(b_s->drain_count, ==, 0);
7f1c5b
-    g_assert_cmpint(backing_s->drain_count, ==, 0);
7f1c5b
-
7f1c5b
-    do_drain_begin(BDRV_SUBTREE_DRAIN, bs_a);
7f1c5b
-
7f1c5b
-    g_assert_cmpint(bs_a->quiesce_counter, ==, 1);
7f1c5b
-    g_assert_cmpint(bs_b->quiesce_counter, ==, 1);
7f1c5b
-    g_assert_cmpint(backing->quiesce_counter, ==, 1);
7f1c5b
-    g_assert_cmpint(a_s->drain_count, ==, 1);
7f1c5b
-    g_assert_cmpint(b_s->drain_count, ==, 1);
7f1c5b
-    g_assert_cmpint(backing_s->drain_count, ==, 1);
7f1c5b
-
7f1c5b
-    do_drain_begin(BDRV_SUBTREE_DRAIN, bs_b);
7f1c5b
-
7f1c5b
-    g_assert_cmpint(bs_a->quiesce_counter, ==, 2);
7f1c5b
-    g_assert_cmpint(bs_b->quiesce_counter, ==, 2);
7f1c5b
-    g_assert_cmpint(backing->quiesce_counter, ==, 2);
7f1c5b
-    g_assert_cmpint(a_s->drain_count, ==, 2);
7f1c5b
-    g_assert_cmpint(b_s->drain_count, ==, 2);
7f1c5b
-    g_assert_cmpint(backing_s->drain_count, ==, 2);
7f1c5b
-
7f1c5b
-    do_drain_end(BDRV_SUBTREE_DRAIN, bs_b);
7f1c5b
-
7f1c5b
-    g_assert_cmpint(bs_a->quiesce_counter, ==, 1);
7f1c5b
-    g_assert_cmpint(bs_b->quiesce_counter, ==, 1);
7f1c5b
-    g_assert_cmpint(backing->quiesce_counter, ==, 1);
7f1c5b
-    g_assert_cmpint(a_s->drain_count, ==, 1);
7f1c5b
-    g_assert_cmpint(b_s->drain_count, ==, 1);
7f1c5b
-    g_assert_cmpint(backing_s->drain_count, ==, 1);
7f1c5b
-
7f1c5b
-    do_drain_end(BDRV_SUBTREE_DRAIN, bs_a);
7f1c5b
-
7f1c5b
-    g_assert_cmpint(bs_a->quiesce_counter, ==, 0);
7f1c5b
-    g_assert_cmpint(bs_b->quiesce_counter, ==, 0);
7f1c5b
-    g_assert_cmpint(backing->quiesce_counter, ==, 0);
7f1c5b
-    g_assert_cmpint(a_s->drain_count, ==, 0);
7f1c5b
-    g_assert_cmpint(b_s->drain_count, ==, 0);
7f1c5b
-    g_assert_cmpint(backing_s->drain_count, ==, 0);
7f1c5b
-
7f1c5b
-    bdrv_unref(backing);
7f1c5b
-    bdrv_unref(bs_a);
7f1c5b
-    bdrv_unref(bs_b);
7f1c5b
-    blk_unref(blk_a);
7f1c5b
-    blk_unref(blk_b);
7f1c5b
-}
7f1c5b
-
7f1c5b
-static void test_graph_change_drain_subtree(void)
7f1c5b
-{
7f1c5b
-    BlockBackend *blk_a, *blk_b;
7f1c5b
-    BlockDriverState *bs_a, *bs_b, *backing;
7f1c5b
-    BDRVTestState *a_s, *b_s, *backing_s;
7f1c5b
-
7f1c5b
-    blk_a = blk_new(qemu_get_aio_context(), BLK_PERM_ALL, BLK_PERM_ALL);
7f1c5b
-    bs_a = bdrv_new_open_driver(&bdrv_test, "test-node-a", BDRV_O_RDWR,
7f1c5b
-                                &error_abort);
7f1c5b
-    a_s = bs_a->opaque;
7f1c5b
-    blk_insert_bs(blk_a, bs_a, &error_abort);
7f1c5b
-
7f1c5b
-    blk_b = blk_new(qemu_get_aio_context(), BLK_PERM_ALL, BLK_PERM_ALL);
7f1c5b
-    bs_b = bdrv_new_open_driver(&bdrv_test, "test-node-b", BDRV_O_RDWR,
7f1c5b
-                                &error_abort);
7f1c5b
-    b_s = bs_b->opaque;
7f1c5b
-    blk_insert_bs(blk_b, bs_b, &error_abort);
7f1c5b
-
7f1c5b
-    backing = bdrv_new_open_driver(&bdrv_test, "backing", 0, &error_abort);
7f1c5b
-    backing_s = backing->opaque;
7f1c5b
-    bdrv_set_backing_hd(bs_a, backing, &error_abort);
7f1c5b
-
7f1c5b
-    g_assert_cmpint(bs_a->quiesce_counter, ==, 0);
7f1c5b
-    g_assert_cmpint(bs_b->quiesce_counter, ==, 0);
7f1c5b
-    g_assert_cmpint(backing->quiesce_counter, ==, 0);
7f1c5b
-    g_assert_cmpint(a_s->drain_count, ==, 0);
7f1c5b
-    g_assert_cmpint(b_s->drain_count, ==, 0);
7f1c5b
-    g_assert_cmpint(backing_s->drain_count, ==, 0);
7f1c5b
-
7f1c5b
-    do_drain_begin(BDRV_SUBTREE_DRAIN, bs_a);
7f1c5b
-    do_drain_begin(BDRV_SUBTREE_DRAIN, bs_a);
7f1c5b
-    do_drain_begin(BDRV_SUBTREE_DRAIN, bs_a);
7f1c5b
-    do_drain_begin(BDRV_SUBTREE_DRAIN, bs_b);
7f1c5b
-    do_drain_begin(BDRV_SUBTREE_DRAIN, bs_b);
7f1c5b
-
7f1c5b
-    bdrv_set_backing_hd(bs_b, backing, &error_abort);
7f1c5b
-    g_assert_cmpint(bs_a->quiesce_counter, ==, 5);
7f1c5b
-    g_assert_cmpint(bs_b->quiesce_counter, ==, 5);
7f1c5b
-    g_assert_cmpint(backing->quiesce_counter, ==, 5);
7f1c5b
-    g_assert_cmpint(a_s->drain_count, ==, 5);
7f1c5b
-    g_assert_cmpint(b_s->drain_count, ==, 5);
7f1c5b
-    g_assert_cmpint(backing_s->drain_count, ==, 5);
7f1c5b
-
7f1c5b
-    bdrv_set_backing_hd(bs_b, NULL, &error_abort);
7f1c5b
-    g_assert_cmpint(bs_a->quiesce_counter, ==, 3);
7f1c5b
-    g_assert_cmpint(bs_b->quiesce_counter, ==, 2);
7f1c5b
-    g_assert_cmpint(backing->quiesce_counter, ==, 3);
7f1c5b
-    g_assert_cmpint(a_s->drain_count, ==, 3);
7f1c5b
-    g_assert_cmpint(b_s->drain_count, ==, 2);
7f1c5b
-    g_assert_cmpint(backing_s->drain_count, ==, 3);
7f1c5b
-
7f1c5b
-    bdrv_set_backing_hd(bs_b, backing, &error_abort);
7f1c5b
-    g_assert_cmpint(bs_a->quiesce_counter, ==, 5);
7f1c5b
-    g_assert_cmpint(bs_b->quiesce_counter, ==, 5);
7f1c5b
-    g_assert_cmpint(backing->quiesce_counter, ==, 5);
7f1c5b
-    g_assert_cmpint(a_s->drain_count, ==, 5);
7f1c5b
-    g_assert_cmpint(b_s->drain_count, ==, 5);
7f1c5b
-    g_assert_cmpint(backing_s->drain_count, ==, 5);
7f1c5b
-
7f1c5b
-    do_drain_end(BDRV_SUBTREE_DRAIN, bs_b);
7f1c5b
-    do_drain_end(BDRV_SUBTREE_DRAIN, bs_b);
7f1c5b
-    do_drain_end(BDRV_SUBTREE_DRAIN, bs_a);
7f1c5b
-    do_drain_end(BDRV_SUBTREE_DRAIN, bs_a);
7f1c5b
-    do_drain_end(BDRV_SUBTREE_DRAIN, bs_a);
7f1c5b
-
7f1c5b
-    g_assert_cmpint(bs_a->quiesce_counter, ==, 0);
7f1c5b
-    g_assert_cmpint(bs_b->quiesce_counter, ==, 0);
7f1c5b
-    g_assert_cmpint(backing->quiesce_counter, ==, 0);
7f1c5b
-    g_assert_cmpint(a_s->drain_count, ==, 0);
7f1c5b
-    g_assert_cmpint(b_s->drain_count, ==, 0);
7f1c5b
-    g_assert_cmpint(backing_s->drain_count, ==, 0);
7f1c5b
-
7f1c5b
-    bdrv_unref(backing);
7f1c5b
-    bdrv_unref(bs_a);
7f1c5b
-    bdrv_unref(bs_b);
7f1c5b
-    blk_unref(blk_a);
7f1c5b
-    blk_unref(blk_b);
7f1c5b
-}
7f1c5b
-
7f1c5b
 static void test_graph_change_drain_all(void)
7f1c5b
 {
7f1c5b
     BlockBackend *blk_a, *blk_b;
7f1c5b
@@ -773,12 +598,6 @@ static void test_iothread_drain(void)
7f1c5b
     test_iothread_common(BDRV_DRAIN, 1);
7f1c5b
 }
7f1c5b
 
7f1c5b
-static void test_iothread_drain_subtree(void)
7f1c5b
-{
7f1c5b
-    test_iothread_common(BDRV_SUBTREE_DRAIN, 0);
7f1c5b
-    test_iothread_common(BDRV_SUBTREE_DRAIN, 1);
7f1c5b
-}
7f1c5b
-
7f1c5b
 
7f1c5b
 typedef struct TestBlockJob {
7f1c5b
     BlockJob common;
7f1c5b
@@ -863,7 +682,6 @@ enum test_job_result {
7f1c5b
 enum test_job_drain_node {
7f1c5b
     TEST_JOB_DRAIN_SRC,
7f1c5b
     TEST_JOB_DRAIN_SRC_CHILD,
7f1c5b
-    TEST_JOB_DRAIN_SRC_PARENT,
7f1c5b
 };
7f1c5b
 
7f1c5b
 static void test_blockjob_common_drain_node(enum drain_type drain_type,
7f1c5b
@@ -901,9 +719,6 @@ static void test_blockjob_common_drain_node(enum drain_type drain_type,
7f1c5b
     case TEST_JOB_DRAIN_SRC_CHILD:
7f1c5b
         drain_bs = src_backing;
7f1c5b
         break;
7f1c5b
-    case TEST_JOB_DRAIN_SRC_PARENT:
7f1c5b
-        drain_bs = src_overlay;
7f1c5b
-        break;
7f1c5b
     default:
7f1c5b
         g_assert_not_reached();
7f1c5b
     }
7f1c5b
@@ -1055,10 +870,6 @@ static void test_blockjob_common(enum drain_type drain_type, bool use_iothread,
7f1c5b
                                     TEST_JOB_DRAIN_SRC);
7f1c5b
     test_blockjob_common_drain_node(drain_type, use_iothread, result,
7f1c5b
                                     TEST_JOB_DRAIN_SRC_CHILD);
7f1c5b
-    if (drain_type == BDRV_SUBTREE_DRAIN) {
7f1c5b
-        test_blockjob_common_drain_node(drain_type, use_iothread, result,
7f1c5b
-                                        TEST_JOB_DRAIN_SRC_PARENT);
7f1c5b
-    }
7f1c5b
 }
7f1c5b
 
7f1c5b
 static void test_blockjob_drain_all(void)
7f1c5b
@@ -1071,11 +882,6 @@ static void test_blockjob_drain(void)
7f1c5b
     test_blockjob_common(BDRV_DRAIN, false, TEST_JOB_SUCCESS);
7f1c5b
 }
7f1c5b
 
7f1c5b
-static void test_blockjob_drain_subtree(void)
7f1c5b
-{
7f1c5b
-    test_blockjob_common(BDRV_SUBTREE_DRAIN, false, TEST_JOB_SUCCESS);
7f1c5b
-}
7f1c5b
-
7f1c5b
 static void test_blockjob_error_drain_all(void)
7f1c5b
 {
7f1c5b
     test_blockjob_common(BDRV_DRAIN_ALL, false, TEST_JOB_FAIL_RUN);
7f1c5b
@@ -1088,12 +894,6 @@ static void test_blockjob_error_drain(void)
7f1c5b
     test_blockjob_common(BDRV_DRAIN, false, TEST_JOB_FAIL_PREPARE);
7f1c5b
 }
7f1c5b
 
7f1c5b
-static void test_blockjob_error_drain_subtree(void)
7f1c5b
-{
7f1c5b
-    test_blockjob_common(BDRV_SUBTREE_DRAIN, false, TEST_JOB_FAIL_RUN);
7f1c5b
-    test_blockjob_common(BDRV_SUBTREE_DRAIN, false, TEST_JOB_FAIL_PREPARE);
7f1c5b
-}
7f1c5b
-
7f1c5b
 static void test_blockjob_iothread_drain_all(void)
7f1c5b
 {
7f1c5b
     test_blockjob_common(BDRV_DRAIN_ALL, true, TEST_JOB_SUCCESS);
7f1c5b
@@ -1104,11 +904,6 @@ static void test_blockjob_iothread_drain(void)
7f1c5b
     test_blockjob_common(BDRV_DRAIN, true, TEST_JOB_SUCCESS);
7f1c5b
 }
7f1c5b
 
7f1c5b
-static void test_blockjob_iothread_drain_subtree(void)
7f1c5b
-{
7f1c5b
-    test_blockjob_common(BDRV_SUBTREE_DRAIN, true, TEST_JOB_SUCCESS);
7f1c5b
-}
7f1c5b
-
7f1c5b
 static void test_blockjob_iothread_error_drain_all(void)
7f1c5b
 {
7f1c5b
     test_blockjob_common(BDRV_DRAIN_ALL, true, TEST_JOB_FAIL_RUN);
7f1c5b
@@ -1121,12 +916,6 @@ static void test_blockjob_iothread_error_drain(void)
7f1c5b
     test_blockjob_common(BDRV_DRAIN, true, TEST_JOB_FAIL_PREPARE);
7f1c5b
 }
7f1c5b
 
7f1c5b
-static void test_blockjob_iothread_error_drain_subtree(void)
7f1c5b
-{
7f1c5b
-    test_blockjob_common(BDRV_SUBTREE_DRAIN, true, TEST_JOB_FAIL_RUN);
7f1c5b
-    test_blockjob_common(BDRV_SUBTREE_DRAIN, true, TEST_JOB_FAIL_PREPARE);
7f1c5b
-}
7f1c5b
-
7f1c5b
 
7f1c5b
 typedef struct BDRVTestTopState {
7f1c5b
     BdrvChild *wait_child;
7f1c5b
@@ -1273,14 +1062,6 @@ static void do_test_delete_by_drain(bool detach_instead_of_delete,
7f1c5b
         bdrv_drain(child_bs);
7f1c5b
         bdrv_unref(child_bs);
7f1c5b
         break;
7f1c5b
-    case BDRV_SUBTREE_DRAIN:
7f1c5b
-        /* Would have to ref/unref bs here for !detach_instead_of_delete, but
7f1c5b
-         * then the whole test becomes pointless because the graph changes
7f1c5b
-         * don't occur during the drain any more. */
7f1c5b
-        assert(detach_instead_of_delete);
7f1c5b
-        bdrv_subtree_drained_begin(bs);
7f1c5b
-        bdrv_subtree_drained_end(bs);
7f1c5b
-        break;
7f1c5b
     case BDRV_DRAIN_ALL:
7f1c5b
         bdrv_drain_all_begin();
7f1c5b
         bdrv_drain_all_end();
7f1c5b
@@ -1315,11 +1096,6 @@ static void test_detach_by_drain(void)
7f1c5b
     do_test_delete_by_drain(true, BDRV_DRAIN);
7f1c5b
 }
7f1c5b
 
7f1c5b
-static void test_detach_by_drain_subtree(void)
7f1c5b
-{
7f1c5b
-    do_test_delete_by_drain(true, BDRV_SUBTREE_DRAIN);
7f1c5b
-}
7f1c5b
-
7f1c5b
 
7f1c5b
 struct detach_by_parent_data {
7f1c5b
     BlockDriverState *parent_b;
7f1c5b
@@ -1452,7 +1228,10 @@ static void test_detach_indirect(bool by_parent_cb)
7f1c5b
     g_assert(acb != NULL);
7f1c5b
 
7f1c5b
     /* Drain and check the expected result */
7f1c5b
-    bdrv_subtree_drained_begin(parent_b);
7f1c5b
+    bdrv_drained_begin(parent_b);
7f1c5b
+    bdrv_drained_begin(a);
7f1c5b
+    bdrv_drained_begin(b);
7f1c5b
+    bdrv_drained_begin(c);
7f1c5b
 
7f1c5b
     g_assert(detach_by_parent_data.child_c != NULL);
7f1c5b
 
7f1c5b
@@ -1467,12 +1246,15 @@ static void test_detach_indirect(bool by_parent_cb)
7f1c5b
     g_assert(QLIST_NEXT(child_a, next) == NULL);
7f1c5b
 
7f1c5b
     g_assert_cmpint(parent_a->quiesce_counter, ==, 1);
7f1c5b
-    g_assert_cmpint(parent_b->quiesce_counter, ==, 1);
7f1c5b
+    g_assert_cmpint(parent_b->quiesce_counter, ==, 3);
7f1c5b
     g_assert_cmpint(a->quiesce_counter, ==, 1);
7f1c5b
-    g_assert_cmpint(b->quiesce_counter, ==, 0);
7f1c5b
+    g_assert_cmpint(b->quiesce_counter, ==, 1);
7f1c5b
     g_assert_cmpint(c->quiesce_counter, ==, 1);
7f1c5b
 
7f1c5b
-    bdrv_subtree_drained_end(parent_b);
7f1c5b
+    bdrv_drained_end(parent_b);
7f1c5b
+    bdrv_drained_end(a);
7f1c5b
+    bdrv_drained_end(b);
7f1c5b
+    bdrv_drained_end(c);
7f1c5b
 
7f1c5b
     bdrv_unref(parent_b);
7f1c5b
     blk_unref(blk);
7f1c5b
@@ -2202,70 +1984,47 @@ int main(int argc, char **argv)
7f1c5b
 
7f1c5b
     g_test_add_func("/bdrv-drain/driver-cb/drain_all", test_drv_cb_drain_all);
7f1c5b
     g_test_add_func("/bdrv-drain/driver-cb/drain", test_drv_cb_drain);
7f1c5b
-    g_test_add_func("/bdrv-drain/driver-cb/drain_subtree",
7f1c5b
-                    test_drv_cb_drain_subtree);
7f1c5b
 
7f1c5b
     g_test_add_func("/bdrv-drain/driver-cb/co/drain_all",
7f1c5b
                     test_drv_cb_co_drain_all);
7f1c5b
     g_test_add_func("/bdrv-drain/driver-cb/co/drain", test_drv_cb_co_drain);
7f1c5b
-    g_test_add_func("/bdrv-drain/driver-cb/co/drain_subtree",
7f1c5b
-                    test_drv_cb_co_drain_subtree);
7f1c5b
-
7f1c5b
 
7f1c5b
     g_test_add_func("/bdrv-drain/quiesce/drain_all", test_quiesce_drain_all);
7f1c5b
     g_test_add_func("/bdrv-drain/quiesce/drain", test_quiesce_drain);
7f1c5b
-    g_test_add_func("/bdrv-drain/quiesce/drain_subtree",
7f1c5b
-                    test_quiesce_drain_subtree);
7f1c5b
 
7f1c5b
     g_test_add_func("/bdrv-drain/quiesce/co/drain_all",
7f1c5b
                     test_quiesce_co_drain_all);
7f1c5b
     g_test_add_func("/bdrv-drain/quiesce/co/drain", test_quiesce_co_drain);
7f1c5b
-    g_test_add_func("/bdrv-drain/quiesce/co/drain_subtree",
7f1c5b
-                    test_quiesce_co_drain_subtree);
7f1c5b
 
7f1c5b
     g_test_add_func("/bdrv-drain/nested", test_nested);
7f1c5b
-    g_test_add_func("/bdrv-drain/multiparent", test_multiparent);
7f1c5b
 
7f1c5b
-    g_test_add_func("/bdrv-drain/graph-change/drain_subtree",
7f1c5b
-                    test_graph_change_drain_subtree);
7f1c5b
     g_test_add_func("/bdrv-drain/graph-change/drain_all",
7f1c5b
                     test_graph_change_drain_all);
7f1c5b
 
7f1c5b
     g_test_add_func("/bdrv-drain/iothread/drain_all", test_iothread_drain_all);
7f1c5b
     g_test_add_func("/bdrv-drain/iothread/drain", test_iothread_drain);
7f1c5b
-    g_test_add_func("/bdrv-drain/iothread/drain_subtree",
7f1c5b
-                    test_iothread_drain_subtree);
7f1c5b
 
7f1c5b
     g_test_add_func("/bdrv-drain/blockjob/drain_all", test_blockjob_drain_all);
7f1c5b
     g_test_add_func("/bdrv-drain/blockjob/drain", test_blockjob_drain);
7f1c5b
-    g_test_add_func("/bdrv-drain/blockjob/drain_subtree",
7f1c5b
-                    test_blockjob_drain_subtree);
7f1c5b
 
7f1c5b
     g_test_add_func("/bdrv-drain/blockjob/error/drain_all",
7f1c5b
                     test_blockjob_error_drain_all);
7f1c5b
     g_test_add_func("/bdrv-drain/blockjob/error/drain",
7f1c5b
                     test_blockjob_error_drain);
7f1c5b
-    g_test_add_func("/bdrv-drain/blockjob/error/drain_subtree",
7f1c5b
-                    test_blockjob_error_drain_subtree);
7f1c5b
 
7f1c5b
     g_test_add_func("/bdrv-drain/blockjob/iothread/drain_all",
7f1c5b
                     test_blockjob_iothread_drain_all);
7f1c5b
     g_test_add_func("/bdrv-drain/blockjob/iothread/drain",
7f1c5b
                     test_blockjob_iothread_drain);
7f1c5b
-    g_test_add_func("/bdrv-drain/blockjob/iothread/drain_subtree",
7f1c5b
-                    test_blockjob_iothread_drain_subtree);
7f1c5b
 
7f1c5b
     g_test_add_func("/bdrv-drain/blockjob/iothread/error/drain_all",
7f1c5b
                     test_blockjob_iothread_error_drain_all);
7f1c5b
     g_test_add_func("/bdrv-drain/blockjob/iothread/error/drain",
7f1c5b
                     test_blockjob_iothread_error_drain);
7f1c5b
-    g_test_add_func("/bdrv-drain/blockjob/iothread/error/drain_subtree",
7f1c5b
-                    test_blockjob_iothread_error_drain_subtree);
7f1c5b
 
7f1c5b
     g_test_add_func("/bdrv-drain/deletion/drain", test_delete_by_drain);
7f1c5b
     g_test_add_func("/bdrv-drain/detach/drain_all", test_detach_by_drain_all);
7f1c5b
     g_test_add_func("/bdrv-drain/detach/drain", test_detach_by_drain);
7f1c5b
-    g_test_add_func("/bdrv-drain/detach/drain_subtree", test_detach_by_drain_subtree);
7f1c5b
     g_test_add_func("/bdrv-drain/detach/parent_cb", test_detach_by_parent_cb);
7f1c5b
     g_test_add_func("/bdrv-drain/detach/driver_cb", test_detach_by_driver_cb);
7f1c5b
 
7f1c5b
-- 
7f1c5b
2.31.1
7f1c5b