From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org
Subject: [PULL 10/11] block: Start/end drain on correct AioContext
Date: Fri, 11 Nov 2022 16:27:43 +0100 [thread overview]
Message-ID: <20221111152744.261358-11-kwolf@redhat.com> (raw)
In-Reply-To: <20221111152744.261358-1-kwolf@redhat.com>
From: Hanna Reitz <hreitz@redhat.com>
bdrv_parent_drained_{begin,end}_single() are supposed to operate on the
parent, not on the child, so they should not attempt to get the context
to poll from the child but the parent instead. BDRV_POLL_WHILE(c->bs)
does get the context from the child, so we should replace it with
AIO_WAIT_WHILE() on the parent's context instead.
This problem becomes apparent when bdrv_replace_child_noperm() invokes
bdrv_parent_drained_end_single() after removing a child from a subgraph
that is in an I/O thread. By the time bdrv_parent_drained_end_single()
is called, child->bs is NULL, and so BDRV_POLL_WHILE(c->bs, ...) will
poll the main loop instead of the I/O thread; but anything that
bdrv_parent_drained_end_single_no_poll() may have scheduled is going to
want to run in the I/O thread, but because we poll the main loop, the
I/O thread is never unpaused, and nothing is run, resulting in a
deadlock.
Closes: https://gitlab.com/qemu-project/qemu/-/issues/1215
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
Message-Id: <20221107151321.211175-4-hreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block/io.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/block/io.c b/block/io.c
index 34b30e304e..b9424024f9 100644
--- a/block/io.c
+++ b/block/io.c
@@ -71,9 +71,10 @@ static void bdrv_parent_drained_end_single_no_poll(BdrvChild *c,
void bdrv_parent_drained_end_single(BdrvChild *c)
{
int drained_end_counter = 0;
+ AioContext *ctx = bdrv_child_get_parent_aio_context(c);
IO_OR_GS_CODE();
bdrv_parent_drained_end_single_no_poll(c, &drained_end_counter);
- BDRV_POLL_WHILE(c->bs, qatomic_read(&drained_end_counter) > 0);
+ AIO_WAIT_WHILE(ctx, qatomic_read(&drained_end_counter) > 0);
}
static void bdrv_parent_drained_end(BlockDriverState *bs, BdrvChild *ignore,
@@ -116,13 +117,14 @@ static bool bdrv_parent_drained_poll(BlockDriverState *bs, BdrvChild *ignore,
void bdrv_parent_drained_begin_single(BdrvChild *c, bool poll)
{
+ AioContext *ctx = bdrv_child_get_parent_aio_context(c);
IO_OR_GS_CODE();
c->parent_quiesce_counter++;
if (c->klass->drained_begin) {
c->klass->drained_begin(c);
}
if (poll) {
- BDRV_POLL_WHILE(c->bs, bdrv_parent_drained_poll_single(c));
+ AIO_WAIT_WHILE(ctx, bdrv_parent_drained_poll_single(c));
}
}
--
2.38.1
next prev parent reply other threads:[~2022-11-11 15:32 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-11 15:27 [PULL 00/11] Block layer patches Kevin Wolf
2022-11-11 15:27 ` [PULL 01/11] block/mirror: Do not wait for active writes Kevin Wolf
2022-11-11 15:27 ` [PULL 02/11] block/mirror: Drop mirror_wait_for_any_operation() Kevin Wolf
2022-11-11 15:27 ` [PULL 03/11] block/mirror: Fix NULL s->job in active writes Kevin Wolf
2022-11-11 15:27 ` [PULL 04/11] iotests/151: Test that active mirror progresses Kevin Wolf
2022-11-11 15:27 ` [PULL 05/11] iotests/151: Test active requests on mirror start Kevin Wolf
2022-11-11 15:27 ` [PULL 06/11] qapi/block-core: Fix BlockdevOptionsNvmeIoUring @path description Kevin Wolf
2022-11-11 15:27 ` [PULL 07/11] block/blkio: Set BlockDriver::has_variable_length to false Kevin Wolf
2022-11-11 15:27 ` [PULL 08/11] block: Make bdrv_child_get_parent_aio_context I/O Kevin Wolf
2022-11-11 15:27 ` [PULL 09/11] block-backend: Update ctx immediately after root Kevin Wolf
2022-11-11 15:27 ` Kevin Wolf [this message]
2022-11-11 15:27 ` [PULL 11/11] tests/stream-under-throttle: New test Kevin Wolf
2022-11-11 19:20 ` [PULL 00/11] Block layer patches Stefan Hajnoczi
2022-11-14 10:12 ` Hanna Reitz
2022-11-14 10:56 ` Kevin Wolf
2022-11-14 23:58 ` John Snow
2022-11-15 10:14 ` Kevin Wolf
2022-11-15 10:21 ` Hanna Reitz
2022-11-15 15:32 ` Kevin Wolf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221111152744.261358-11-kwolf@redhat.com \
--to=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).