}
/* 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;
BdrvCoDrainData data = { .bs = bs, .done = false, .begin = begin};
bdrv_coroutine_enter(bs, data.co);
BDRV_POLL_WHILE(bs, !data.done);
- QLIST_FOREACH_SAFE(child, &bs->children, next, tmp) {
- bdrv_drain_invoke(child->bs, begin);
+ if (recursive) {
+ QLIST_FOREACH_SAFE(child, &bs->children, next, tmp) {
+ bdrv_drain_invoke(child->bs, begin, true);
+ }
}
}
bdrv_parent_drained_begin(bs);
}
- bdrv_drain_invoke(bs, true);
+ bdrv_drain_invoke(bs, true, false);
bdrv_drain_recurse(bs);
}
}
/* Re-enable things in child-to-parent order */
- bdrv_drain_invoke(bs, false);
+ bdrv_drain_invoke(bs, false, false);
bdrv_parent_drained_end(bs);
aio_enable_external(bdrv_get_aio_context(bs));
}
aio_context_acquire(aio_context);
aio_disable_external(aio_context);
bdrv_parent_drained_begin(bs);
- bdrv_drain_invoke(bs, true);
+ bdrv_drain_invoke(bs, true, true);
aio_context_release(aio_context);
if (!g_slist_find(aio_ctxs, aio_context)) {
/* Re-enable things in child-to-parent order */
aio_context_acquire(aio_context);
- bdrv_drain_invoke(bs, false);
+ bdrv_drain_invoke(bs, false, true);
bdrv_parent_drained_end(bs);
aio_enable_external(aio_context);
aio_context_release(aio_context);