[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 17/20] block: Move bdrv_drain_all_begin() out of
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH v2 17/20] block: Move bdrv_drain_all_begin() out of coroutine context |
Date: |
Tue, 29 May 2018 19:21:53 +0200 |
Before we can introduce a single polling loop for all nodes in
bdrv_drain_all_begin(), we must make sure to run it outside of coroutine
context like we already do for bdrv_do_drained_begin().
Signed-off-by: Kevin Wolf <address@hidden>
---
block/io.c | 22 +++++++++++++++++-----
1 file changed, 17 insertions(+), 5 deletions(-)
diff --git a/block/io.c b/block/io.c
index a5b899723a..2c06aaf6d8 100644
--- a/block/io.c
+++ b/block/io.c
@@ -264,11 +264,16 @@ static void bdrv_co_drain_bh_cb(void *opaque)
Coroutine *co = data->co;
BlockDriverState *bs = data->bs;
- bdrv_dec_in_flight(bs);
- if (data->begin) {
- bdrv_do_drained_begin(bs, data->recursive, data->parent, data->poll);
+ if (bs) {
+ bdrv_dec_in_flight(bs);
+ if (data->begin) {
+ bdrv_do_drained_begin(bs, data->recursive, data->parent,
data->poll);
+ } else {
+ bdrv_do_drained_end(bs, data->recursive, data->parent);
+ }
} else {
- bdrv_do_drained_end(bs, data->recursive, data->parent);
+ assert(data->begin);
+ bdrv_drain_all_begin();
}
data->done = true;
@@ -294,7 +299,9 @@ static void coroutine_fn
bdrv_co_yield_to_drain(BlockDriverState *bs,
.parent = parent,
.poll = poll,
};
- bdrv_inc_in_flight(bs);
+ if (bs) {
+ bdrv_inc_in_flight(bs);
+ }
aio_bh_schedule_oneshot(bdrv_get_aio_context(bs),
bdrv_co_drain_bh_cb, &data);
@@ -464,6 +471,11 @@ void bdrv_drain_all_begin(void)
BlockDriverState *bs;
BdrvNextIterator it;
+ if (qemu_in_coroutine()) {
+ bdrv_co_yield_to_drain(NULL, true, false, NULL, true);
+ return;
+ }
+
/* BDRV_POLL_WHILE() for a node can only be called from its own I/O thread
* or the main loop AioContext. We potentially use BDRV_POLL_WHILE() on
* nodes in several different AioContexts, so make sure we're in the main
--
2.13.6
- [Qemu-devel] [PATCH v2 08/20] block: Remove bdrv_drain_recurse(), (continued)
- [Qemu-devel] [PATCH v2 08/20] block: Remove bdrv_drain_recurse(), Kevin Wolf, 2018/05/29
- [Qemu-devel] [PATCH v2 07/20] block: Really pause block jobs on drain, Kevin Wolf, 2018/05/29
- [Qemu-devel] [PATCH v2 09/20] test-bdrv-drain: Add test for node deletion, Kevin Wolf, 2018/05/29
- [Qemu-devel] [PATCH v2 11/20] test-bdrv-drain: Test node deletion in subtree recursion, Kevin Wolf, 2018/05/29
- [Qemu-devel] [PATCH v2 10/20] block: Drain recursively with a single BDRV_POLL_WHILE(), Kevin Wolf, 2018/05/29
- [Qemu-devel] [PATCH v2 12/20] block: Don't poll in parent drain callbacks, Kevin Wolf, 2018/05/29
- [Qemu-devel] [PATCH v2 13/20] test-bdrv-drain: Graph change through parent callback, Kevin Wolf, 2018/05/29
- [Qemu-devel] [PATCH v2 14/20] block: Defer .bdrv_drain_begin callback to polling phase, Kevin Wolf, 2018/05/29
- [Qemu-devel] [PATCH v2 16/20] block: Allow AIO_WAIT_WHILE with NULL ctx, Kevin Wolf, 2018/05/29
- [Qemu-devel] [PATCH v2 15/20] test-bdrv-drain: Test that bdrv_drain_invoke() doesn't poll, Kevin Wolf, 2018/05/29
- [Qemu-devel] [PATCH v2 17/20] block: Move bdrv_drain_all_begin() out of coroutine context,
Kevin Wolf <=
- [Qemu-devel] [PATCH v2 19/20] block: Allow graph changes in bdrv_drain_all_begin/end sections, Kevin Wolf, 2018/05/29
- [Qemu-devel] [PATCH v2 20/20] test-bdrv-drain: Test graph changes in drain_all section, Kevin Wolf, 2018/05/29
- [Qemu-devel] [PATCH v2 18/20] block: ignore_bds_parents parameter for drain functions, Kevin Wolf, 2018/05/29
- Re: [Qemu-devel] [PATCH v2 00/20] Drain fixes and cleanups, part 3, no-reply, 2018/05/29