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