From 3480ce69a9c7ee956323c45269d21b6905488904 Mon Sep 17 00:00:00 2001 From: Stefan Hajnoczi Date: Tue, 8 Aug 2023 11:58:51 -0400 Subject: block: minimize bs->reqs_lock section in tracked_request_end() Signed-off-by: Stefan Hajnoczi Message-ID: <20230808155852.2745350-2-stefanha@redhat.com> Reviewed-by: Eric Blake Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- block/io.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'block') diff --git a/block/io.c b/block/io.c index 76e7df1..4f32d6a 100644 --- a/block/io.c +++ b/block/io.c @@ -593,8 +593,14 @@ static void coroutine_fn tracked_request_end(BdrvTrackedRequest *req) qemu_co_mutex_lock(&req->bs->reqs_lock); QLIST_REMOVE(req, list); - qemu_co_queue_restart_all(&req->wait_queue); qemu_co_mutex_unlock(&req->bs->reqs_lock); + + /* + * At this point qemu_co_queue_wait(&req->wait_queue, ...) won't be called + * anymore because the request has been removed from the list, so it's safe + * to restart the queue outside reqs_lock to minimize the critical section. + */ + qemu_co_queue_restart_all(&req->wait_queue); } /** -- cgit v1.1