diff options
author | Stefan Hajnoczi <stefanha@redhat.com> | 2023-08-08 11:58:51 -0400 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2023-09-08 17:03:09 +0200 |
commit | 3480ce69a9c7ee956323c45269d21b6905488904 (patch) | |
tree | 9e34ffb82f35de40fd6306937688345d4ec3b402 /block/io.c | |
parent | 65c23ef1e4197c53d3836906895062307e48a6c5 (diff) |
block: minimize bs->reqs_lock section in tracked_request_end()
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-ID: <20230808155852.2745350-2-stefanha@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block/io.c')
-rw-r--r-- | block/io.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/block/io.c b/block/io.c index 76e7df18d8..4f32d6aa6e 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); } /** |