[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL v3 19/35] block: Make bdrv_drain() driver callbacks n
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL v3 19/35] block: Make bdrv_drain() driver callbacks non-recursive |
Date: |
Fri, 22 Dec 2017 16:18:30 +0100 |
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 <address@hidden>
Reviewed-by: Fam Zheng <address@hidden>
---
block/io.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/block/io.c b/block/io.c
index b94740b8ff..91a52e2d82 100644
--- a/block/io.c
+++ b/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 */
-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};
@@ -172,8 +172,10 @@ static void bdrv_drain_invoke(BlockDriverState *bs, bool
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);
+ }
}
}
@@ -265,7 +267,7 @@ void bdrv_drained_begin(BlockDriverState *bs)
bdrv_parent_drained_begin(bs);
}
- bdrv_drain_invoke(bs, true);
+ bdrv_drain_invoke(bs, true, false);
bdrv_drain_recurse(bs);
}
@@ -281,7 +283,7 @@ void bdrv_drained_end(BlockDriverState *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));
}
@@ -345,7 +347,7 @@ void bdrv_drain_all_begin(void)
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)) {
@@ -388,7 +390,7 @@ void bdrv_drain_all_end(void)
/* 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);
--
2.13.6
- [Qemu-devel] [PULL v3 05/35] test-bdrv-drain: Test BlockDriver callbacks for drain, (continued)
- [Qemu-devel] [PULL v3 05/35] test-bdrv-drain: Test BlockDriver callbacks for drain, Kevin Wolf, 2017/12/22
- [Qemu-devel] [PULL v3 07/35] block: Don't wait for requests in bdrv_drain*_end(), Kevin Wolf, 2017/12/22
- [Qemu-devel] [PULL v3 06/35] block: bdrv_drain_recurse(): Remove unused begin parameter, Kevin Wolf, 2017/12/22
- [Qemu-devel] [PULL v3 10/35] qcow2: get rid of qcow2_backing_read1 routine, Kevin Wolf, 2017/12/22
- [Qemu-devel] [PULL v3 09/35] block: Don't acquire AioContext in hmp_qemu_io(), Kevin Wolf, 2017/12/22
- [Qemu-devel] [PULL v3 13/35] block: Open backing image in force share mode for size probe, Kevin Wolf, 2017/12/22
- [Qemu-devel] [PULL v3 11/35] block: Document that x-blockdev-change breaks quorum children list, Kevin Wolf, 2017/12/22
- [Qemu-devel] [PULL v3 14/35] block: Remove the obsolete -drive boot=on|off parameter, Kevin Wolf, 2017/12/22
- [Qemu-devel] [PULL v3 15/35] block: Remove the deprecated -hdachs option, Kevin Wolf, 2017/12/22
- [Qemu-devel] [PULL v3 12/35] nvme: Add tracing, Kevin Wolf, 2017/12/22
- [Qemu-devel] [PULL v3 19/35] block: Make bdrv_drain() driver callbacks non-recursive,
Kevin Wolf <=
- [Qemu-devel] [PULL v3 16/35] block: Mention -drive cyls/heads/secs/trans/serial/addr in deprecation chapter, Kevin Wolf, 2017/12/22
- [Qemu-devel] [PULL v3 17/35] block: Remove unused bdrv_requests_pending, Kevin Wolf, 2017/12/22
- [Qemu-devel] [PULL v3 24/35] block: Don't block_job_pause_all() in bdrv_drain_all(), Kevin Wolf, 2017/12/22
- [Qemu-devel] [PULL v3 25/35] block: Nested drain_end must still call callbacks, Kevin Wolf, 2017/12/22
- [Qemu-devel] [PULL v3 22/35] blockjob: Pause job on draining any job BDS, Kevin Wolf, 2017/12/22
- [Qemu-devel] [PULL v3 23/35] test-bdrv-drain: Test drain vs. block jobs, Kevin Wolf, 2017/12/22
- [Qemu-devel] [PULL v3 21/35] test-bdrv-drain: Test bs->quiesce_counter, Kevin Wolf, 2017/12/22
- [Qemu-devel] [PULL v3 20/35] test-bdrv-drain: Test callback for bdrv_drain, Kevin Wolf, 2017/12/22
- [Qemu-devel] [PULL v3 18/35] block: Assert drain_all is only called from main AioContext, Kevin Wolf, 2017/12/22
- [Qemu-devel] [PULL v3 26/35] test-bdrv-drain: Test nested drain sections, Kevin Wolf, 2017/12/22