[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 17/19] block: Move bdrv_drain_all_begin() out of cor
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 17/19] block: Move bdrv_drain_all_begin() out of coroutine context |
Date: |
Wed, 11 Apr 2018 18:39:38 +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 fc26c1a2f8..db6810b35f 100644
--- a/block/io.c
+++ b/block/io.c
@@ -255,11 +255,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;
@@ -285,7 +290,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);
@@ -455,6 +462,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 02/19] block: Use bdrv_do_drain_begin/end in bdrv_drain_all(), (continued)
- [Qemu-devel] [PATCH 02/19] block: Use bdrv_do_drain_begin/end in bdrv_drain_all(), Kevin Wolf, 2018/04/11
- [Qemu-devel] [PATCH 01/19] test-bdrv-drain: bdrv_drain() works with cross-AioContext events, Kevin Wolf, 2018/04/11
- [Qemu-devel] [PATCH 11/19] test-bdrv-drain: Test node deletion in subtree recursion, Kevin Wolf, 2018/04/11
- [Qemu-devel] [PATCH 10/19] block: Drain recursively with a single BDRV_POLL_WHILE(), Kevin Wolf, 2018/04/11
- [Qemu-devel] [PATCH 15/19] test-bdrv-drain: Test that bdrv_drain_invoke() doesn't poll, Kevin Wolf, 2018/04/11
- [Qemu-devel] [PATCH 12/19] block: Don't poll in parent drain callbacks, Kevin Wolf, 2018/04/11
- [Qemu-devel] [PATCH 13/19] test-bdrv-drain: Graph change through parent callback, Kevin Wolf, 2018/04/11
- [Qemu-devel] [PATCH 14/19] block: Defer .bdrv_drain_begin callback to polling phase, Kevin Wolf, 2018/04/11
- [Qemu-devel] [PATCH 17/19] block: Move bdrv_drain_all_begin() out of coroutine context,
Kevin Wolf <=
- [Qemu-devel] [PATCH 19/19] test-bdrv-drain: Test graph changes in drain_all section, Kevin Wolf, 2018/04/11
- [Qemu-devel] [PATCH 18/19] block: Allow graph changes in bdrv_drain_all_begin/end sections, Kevin Wolf, 2018/04/11
- [Qemu-devel] [PATCH 16/19] block: Allow AIO_WAIT_WHILE with NULL ctx, Kevin Wolf, 2018/04/11
- Re: [Qemu-devel] [PATCH 00/19] Drain fixes and cleanups, part 3, no-reply, 2018/04/11
- Re: [Qemu-devel] [PATCH 00/19] Drain fixes and cleanups, part 3, Stefan Hajnoczi, 2018/04/20