This reverts commit dcc5d4bc2abed4268bf31908193c4369e4c9d005. Signed-off-by: Paolo Bonzini <pbonz...@redhat.com> --- block.c | 4 ++-- block/io.c | 8 ++++++-- include/block/block-io.h | 5 +++-- 3 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/block.c b/block.c index 6191ac1f440c..87022f4cd971 100644 --- a/block.c +++ b/block.c @@ -2377,7 +2377,7 @@ static void bdrv_replace_child_abort(void *opaque) * new_bs drained when calling bdrv_replace_child_tran() is not a * requirement any more. */ - bdrv_parent_drained_begin_single(s->child); + bdrv_parent_drained_begin_single(s->child, false); assert(!bdrv_parent_drained_poll_single(s->child)); } assert(s->child->quiesced_parent); @@ -3050,7 +3050,7 @@ static BdrvChild *bdrv_attach_child_common(BlockDriverState *child_bs, * a problem, we already did this), but it will still poll until the parent * is fully quiesced, so it will not be negatively affected either. */ - bdrv_parent_drained_begin_single(new_child); + bdrv_parent_drained_begin_single(new_child, false); bdrv_replace_child_noperm(new_child, child_bs); BdrvAttachChildCommonState *s = g_new(BdrvAttachChildCommonState, 1); diff --git a/block/io.c b/block/io.c index f4444b7777d9..aee6e70c1496 100644 --- a/block/io.c +++ b/block/io.c @@ -53,7 +53,7 @@ static void bdrv_parent_drained_begin(BlockDriverState *bs, BdrvChild *ignore) if (c == ignore) { continue; } - bdrv_parent_drained_begin_single(c); + bdrv_parent_drained_begin_single(c, false); } } @@ -105,8 +105,9 @@ static bool bdrv_parent_drained_poll(BlockDriverState *bs, BdrvChild *ignore, return busy; } -void bdrv_parent_drained_begin_single(BdrvChild *c) +void bdrv_parent_drained_begin_single(BdrvChild *c, bool poll) { + AioContext *ctx = bdrv_child_get_parent_aio_context(c); IO_OR_GS_CODE(); assert(!c->quiesced_parent); @@ -115,6 +116,9 @@ void bdrv_parent_drained_begin_single(BdrvChild *c) if (c->klass->drained_begin) { c->klass->drained_begin(c); } + if (poll) { + AIO_WAIT_WHILE(ctx, bdrv_parent_drained_poll_single(c)); + } } static void bdrv_merge_limits(BlockLimits *dst, const BlockLimits *src) diff --git a/include/block/block-io.h b/include/block/block-io.h index 52869ea08eb5..75d043204355 100644 --- a/include/block/block-io.h +++ b/include/block/block-io.h @@ -308,9 +308,10 @@ bdrv_writev_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t pos); /** * bdrv_parent_drained_begin_single: * - * Begin a quiesced section for the parent of @c. + * Begin a quiesced section for the parent of @c. If @poll is true, wait for + * any pending activity to cease. */ -void bdrv_parent_drained_begin_single(BdrvChild *c); +void bdrv_parent_drained_begin_single(BdrvChild *c, bool poll); /** * bdrv_parent_drained_poll_single: -- 2.38.1