mirror of https://gitee.com/openkylin/qemu.git
block: Make bdrv_drain() driver callbacks non-recursive
bdrv_drained_begin() doesn't increase bs->quiesce_counter recursively and also doesn't notify other parent nodes of children, which both means that the child nodes are not actually drained, and bdrv_drained_begin() is providing useful functionality only on a single node. To keep things consistent, we also shouldn't call the block driver callbacks recursively. A proper recursive drain version that provides an actually working drained section for child nodes will be introduced later. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Fam Zheng <famz@redhat.com>
This commit is contained in:
parent
9a7e86c804
commit
7b6a3d3553
16
block/io.c
16
block/io.c
|
@ -158,7 +158,7 @@ static void coroutine_fn bdrv_drain_invoke_entry(void *opaque)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Recursively call BlockDriver.bdrv_co_drain_begin/end callbacks */
|
/* Recursively call BlockDriver.bdrv_co_drain_begin/end callbacks */
|
||||||
static void bdrv_drain_invoke(BlockDriverState *bs, bool begin)
|
static void bdrv_drain_invoke(BlockDriverState *bs, bool begin, bool recursive)
|
||||||
{
|
{
|
||||||
BdrvChild *child, *tmp;
|
BdrvChild *child, *tmp;
|
||||||
BdrvCoDrainData data = { .bs = bs, .done = false, .begin = begin};
|
BdrvCoDrainData data = { .bs = bs, .done = false, .begin = begin};
|
||||||
|
@ -172,8 +172,10 @@ static void bdrv_drain_invoke(BlockDriverState *bs, bool begin)
|
||||||
bdrv_coroutine_enter(bs, data.co);
|
bdrv_coroutine_enter(bs, data.co);
|
||||||
BDRV_POLL_WHILE(bs, !data.done);
|
BDRV_POLL_WHILE(bs, !data.done);
|
||||||
|
|
||||||
QLIST_FOREACH_SAFE(child, &bs->children, next, tmp) {
|
if (recursive) {
|
||||||
bdrv_drain_invoke(child->bs, begin);
|
QLIST_FOREACH_SAFE(child, &bs->children, next, tmp) {
|
||||||
|
bdrv_drain_invoke(child->bs, begin, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -265,7 +267,7 @@ void bdrv_drained_begin(BlockDriverState *bs)
|
||||||
bdrv_parent_drained_begin(bs);
|
bdrv_parent_drained_begin(bs);
|
||||||
}
|
}
|
||||||
|
|
||||||
bdrv_drain_invoke(bs, true);
|
bdrv_drain_invoke(bs, true, false);
|
||||||
bdrv_drain_recurse(bs);
|
bdrv_drain_recurse(bs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -281,7 +283,7 @@ void bdrv_drained_end(BlockDriverState *bs)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Re-enable things in child-to-parent order */
|
/* Re-enable things in child-to-parent order */
|
||||||
bdrv_drain_invoke(bs, false);
|
bdrv_drain_invoke(bs, false, false);
|
||||||
bdrv_parent_drained_end(bs);
|
bdrv_parent_drained_end(bs);
|
||||||
aio_enable_external(bdrv_get_aio_context(bs));
|
aio_enable_external(bdrv_get_aio_context(bs));
|
||||||
}
|
}
|
||||||
|
@ -345,7 +347,7 @@ void bdrv_drain_all_begin(void)
|
||||||
aio_context_acquire(aio_context);
|
aio_context_acquire(aio_context);
|
||||||
aio_disable_external(aio_context);
|
aio_disable_external(aio_context);
|
||||||
bdrv_parent_drained_begin(bs);
|
bdrv_parent_drained_begin(bs);
|
||||||
bdrv_drain_invoke(bs, true);
|
bdrv_drain_invoke(bs, true, true);
|
||||||
aio_context_release(aio_context);
|
aio_context_release(aio_context);
|
||||||
|
|
||||||
if (!g_slist_find(aio_ctxs, aio_context)) {
|
if (!g_slist_find(aio_ctxs, aio_context)) {
|
||||||
|
@ -388,7 +390,7 @@ void bdrv_drain_all_end(void)
|
||||||
|
|
||||||
/* Re-enable things in child-to-parent order */
|
/* Re-enable things in child-to-parent order */
|
||||||
aio_context_acquire(aio_context);
|
aio_context_acquire(aio_context);
|
||||||
bdrv_drain_invoke(bs, false);
|
bdrv_drain_invoke(bs, false, true);
|
||||||
bdrv_parent_drained_end(bs);
|
bdrv_parent_drained_end(bs);
|
||||||
aio_enable_external(aio_context);
|
aio_enable_external(aio_context);
|
||||||
aio_context_release(aio_context);
|
aio_context_release(aio_context);
|
||||||
|
|
Loading…
Reference in New Issue