qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [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

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).