From d805d8a2c70d73fc5a1f29b70296e74a012e865b Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Thu, 9 Mar 2023 14:08:52 -0500 Subject: [PATCH] block: convert bdrv_graph_wrlock() to AIO_WAIT_WHILE_UNLOCKED() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The following conversion is safe and does not change behavior: GLOBAL_STATE_CODE(); ... - AIO_WAIT_WHILE(qemu_get_aio_context(), ...); + AIO_WAIT_WHILE_UNLOCKED(NULL, ...); Since we're in GLOBAL_STATE_CODE(), qemu_get_aio_context() is our home thread's AioContext. Thus AIO_WAIT_WHILE() does not unlock the AioContext: if (ctx_ && in_aio_context_home_thread(ctx_)) { \ while ((cond)) { \ aio_poll(ctx_, true); \ waited_ = true; \ } \ And that means AIO_WAIT_WHILE_UNLOCKED(NULL, ...) can be substituted. Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé Reviewed-by: Kevin Wolf Signed-off-by: Stefan Hajnoczi Message-Id: <20230309190855.414275-4-stefanha@redhat.com> Reviewed-by: Wilfred Mallawa Signed-off-by: Kevin Wolf --- block/graph-lock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/graph-lock.c b/block/graph-lock.c index 454c31e691..639526608f 100644 --- a/block/graph-lock.c +++ b/block/graph-lock.c @@ -127,7 +127,7 @@ void bdrv_graph_wrlock(void) * reader lock. */ qatomic_set(&has_writer, 0); - AIO_WAIT_WHILE(qemu_get_aio_context(), reader_count() >= 1); + AIO_WAIT_WHILE_UNLOCKED(NULL, reader_count() >= 1); qatomic_set(&has_writer, 1); /*