* [PATCH for-8.2] block: Fix AioContext locking in qmp_block_resize()
@ 2023-12-08 12:43 Kevin Wolf
2023-12-11 14:48 ` Stefan Hajnoczi
2023-12-13 17:22 ` Stefan Hajnoczi
0 siblings, 2 replies; 3+ messages in thread
From: Kevin Wolf @ 2023-12-08 12:43 UTC (permalink / raw)
To: qemu-block; +Cc: kwolf, stefanha, qemu-devel, qemu-stable
The AioContext must be unlocked before calling blk_co_unref(), because
it takes the AioContext lock internally in blk_unref_bh(), which is
scheduled in the main thread. If we don't unlock, the AioContext is
locked twice and nested event loops such as in bdrv_graph_wrlock() will
deadlock.
Cc: qemu-stable@nongnu.org
Fixes: https://issues.redhat.com/browse/RHEL-15965
Fixes: 0c7d204f50c382c6baac8c94bd57af4a022b3888
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
blockdev.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/blockdev.c b/blockdev.c
index 4c1177e8db..c91f49e7b6 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -2400,8 +2400,9 @@ void coroutine_fn qmp_block_resize(const char *device, const char *node_name,
bdrv_co_lock(bs);
bdrv_drained_end(bs);
- blk_co_unref(blk);
bdrv_co_unlock(bs);
+
+ blk_co_unref(blk);
}
void qmp_block_stream(const char *job_id, const char *device,
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH for-8.2] block: Fix AioContext locking in qmp_block_resize()
2023-12-08 12:43 [PATCH for-8.2] block: Fix AioContext locking in qmp_block_resize() Kevin Wolf
@ 2023-12-11 14:48 ` Stefan Hajnoczi
2023-12-13 17:22 ` Stefan Hajnoczi
1 sibling, 0 replies; 3+ messages in thread
From: Stefan Hajnoczi @ 2023-12-11 14:48 UTC (permalink / raw)
To: Kevin Wolf; +Cc: qemu-block, stefanha, qemu-devel, qemu-stable
On Fri, 8 Dec 2023 at 07:44, Kevin Wolf <kwolf@redhat.com> wrote:
>
> The AioContext must be unlocked before calling blk_co_unref(), because
> it takes the AioContext lock internally in blk_unref_bh(), which is
> scheduled in the main thread. If we don't unlock, the AioContext is
> locked twice and nested event loops such as in bdrv_graph_wrlock() will
> deadlock.
>
> Cc: qemu-stable@nongnu.org
> Fixes: https://issues.redhat.com/browse/RHEL-15965
> Fixes: 0c7d204f50c382c6baac8c94bd57af4a022b3888
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
> blockdev.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
From IRC:
09:40 < stefanha> kwolf: "[PATCH for-8.2] block: Fix AioContext
locking in qmp_block_resize()" fixes QEMU 8.1 bug and is not a
regression?
09:41 < stefanha> I'm trying to understand the nature of the issue and
whether to roll an -rc4 tomorrow and delay the QEMU 8.2 release by a
week.
09:41 < kwolf> stefanha: Looks like it, yes
09:41 < kwolf> stefanha: Probably not worth an -rc4 on its own if
there are no other fixes
09:42 < stefanha> Okay, thanks. If nothing else comes up by tomorrow I
will tag v8.2.0 (final) and we can merge this immediately when the
development window and -stable tree opens.
>
> diff --git a/blockdev.c b/blockdev.c
> index 4c1177e8db..c91f49e7b6 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -2400,8 +2400,9 @@ void coroutine_fn qmp_block_resize(const char *device, const char *node_name,
>
> bdrv_co_lock(bs);
> bdrv_drained_end(bs);
> - blk_co_unref(blk);
> bdrv_co_unlock(bs);
> +
> + blk_co_unref(blk);
> }
>
> void qmp_block_stream(const char *job_id, const char *device,
> --
> 2.43.0
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH for-8.2] block: Fix AioContext locking in qmp_block_resize()
2023-12-08 12:43 [PATCH for-8.2] block: Fix AioContext locking in qmp_block_resize() Kevin Wolf
2023-12-11 14:48 ` Stefan Hajnoczi
@ 2023-12-13 17:22 ` Stefan Hajnoczi
1 sibling, 0 replies; 3+ messages in thread
From: Stefan Hajnoczi @ 2023-12-13 17:22 UTC (permalink / raw)
To: Kevin Wolf; +Cc: qemu-block, kwolf, stefanha, qemu-devel, qemu-stable
[-- Attachment #1: Type: text/plain, Size: 115 bytes --]
Applied, thanks.
Please update the changelog at https://wiki.qemu.org/ChangeLog/8.2 for any user-visible changes.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-12-13 17:23 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-08 12:43 [PATCH for-8.2] block: Fix AioContext locking in qmp_block_resize() Kevin Wolf
2023-12-11 14:48 ` Stefan Hajnoczi
2023-12-13 17:22 ` Stefan Hajnoczi
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).