[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 12/19] block: Don't poll in parent drain callbacks
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 12/19] block: Don't poll in parent drain callbacks |
Date: |
Wed, 11 Apr 2018 18:39:33 +0200 |
bdrv_do_drained_begin() is only safe if we have a single
BDRV_POLL_WHILE() after quiescing all affected nodes. We cannot allow
that parent callbacks introduce a nested polling loop that could cause
graph changes while we're traversing the graph.
Split off bdrv_do_drained_begin_quiesce(), which only quiesces a single
node without waiting for its requests to complete. These requests will
be waited for in the BDRV_POLL_WHILE() call down the call chain.
Signed-off-by: Kevin Wolf <address@hidden>
---
include/block/block.h | 9 +++++++++
block.c | 2 +-
block/io.c | 24 ++++++++++++++++--------
3 files changed, 26 insertions(+), 9 deletions(-)
diff --git a/include/block/block.h b/include/block/block.h
index 91bf3b4e36..de2cba2c74 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -578,6 +578,15 @@ bool bdrv_drain_poll(BlockDriverState *bs, bool top_level,
bool recursive);
void bdrv_drained_begin(BlockDriverState *bs);
/**
+ * bdrv_do_drained_begin_quiesce:
+ *
+ * Quiesces a BDS like bdrv_drained_begin(), but does not wait for already
+ * running requests to complete.
+ */
+void bdrv_do_drained_begin_quiesce(BlockDriverState *bs,
+ BdrvChild *parent);
+
+/**
* Like bdrv_drained_begin, but recursively begins a quiesced section for
* exclusive access to all child nodes as well.
*/
diff --git a/block.c b/block.c
index 9fe39ac8c1..330238de19 100644
--- a/block.c
+++ b/block.c
@@ -817,7 +817,7 @@ static char *bdrv_child_get_parent_desc(BdrvChild *c)
static void bdrv_child_cb_drained_begin(BdrvChild *child)
{
BlockDriverState *bs = child->opaque;
- bdrv_drained_begin(bs);
+ bdrv_do_drained_begin_quiesce(bs, NULL);
}
static bool bdrv_child_cb_drained_poll(BdrvChild *child)
diff --git a/block/io.c b/block/io.c
index 1287630c58..f372b9ffb0 100644
--- a/block/io.c
+++ b/block/io.c
@@ -277,15 +277,10 @@ static void coroutine_fn
bdrv_co_yield_to_drain(BlockDriverState *bs,
assert(data.done);
}
-void bdrv_do_drained_begin(BlockDriverState *bs, bool recursive,
- BdrvChild *parent, bool poll)
+void bdrv_do_drained_begin_quiesce(BlockDriverState *bs,
+ BdrvChild *parent)
{
- BdrvChild *child, *next;
-
- if (qemu_in_coroutine()) {
- bdrv_co_yield_to_drain(bs, true, recursive, parent, poll);
- return;
- }
+ assert(!qemu_in_coroutine());
/* Stop things in parent-to-child order */
if (atomic_fetch_inc(&bs->quiesce_counter) == 0) {
@@ -294,6 +289,19 @@ void bdrv_do_drained_begin(BlockDriverState *bs, bool
recursive,
bdrv_parent_drained_begin(bs, parent);
bdrv_drain_invoke(bs, true);
+}
+
+static void bdrv_do_drained_begin(BlockDriverState *bs, bool recursive,
+ BdrvChild *parent, bool poll)
+{
+ BdrvChild *child, *next;
+
+ if (qemu_in_coroutine()) {
+ bdrv_co_yield_to_drain(bs, true, recursive, parent, poll);
+ return;
+ }
+
+ bdrv_do_drained_begin_quiesce(bs, parent);
if (recursive) {
bs->recursive_quiesce_counter++;
--
2.13.6
- Re: [Qemu-devel] [PATCH 07/19] block: Really pause block jobs on drain, (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 <=
[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, 2018/04/11
[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