Skip to content

Commit

Permalink
block: minimize bs->reqs_lock section in tracked_request_end()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
stefanhaRH authored and kevmw committed Sep 8, 2023
1 parent 65c23ef commit 3480ce6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion block/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down

0 comments on commit 3480ce6

Please sign in to comment.