Commit 462cfd7b76 for qemu.org
commit 462cfd7b76590043d79f1fa220424fbab67902f3
Author: Kevin Wolf <kwolf@redhat.com>
Date: Mon Nov 30 11:35:01 2026 +0100
block: Restore fast path for non-serialising requests
Commit 0bd5a1b3d60c added a bdrv_wait_serialising_requests_locked() call
without the fast path for bs->serialising_in_flight == 0, which was
present in the bdrv_wait_serialising_requests() it replaced (removed in
cf4f672c11d6). This causes performance regressions when there are no
serialising requests in flight: Instead of just comparing the counter,
this now has to iterate through the whole list of tracked requests.
Add the fast path back in bdrv_wait_serialising_requests_locked().
Now that all users of bs->serialising_in_flight hold the mutex, more
changes could be made (e.g. it doesn't have to be atomic any more, or it
could be changed to keep a separate list of serialising requests), but
given how late we're in the release cycle, this is left for another day.
Cc: qemu-stable@nongnu.org
Fixes: 0bd5a1b3d60c ('block: Fix corruption from broken RMW atomicity')
Reported-by: Christian Borntraeger <borntraeger@linux.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-ID: <20261130103501.38910-1-kwolf@redhat.com>
Tested-by: Christian Borntraeger <borntraeger@linux.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
diff --git a/block/io.c b/block/io.c
index e4568d4d24..5e2734e540 100644
--- a/block/io.c
+++ b/block/io.c
@@ -703,6 +703,10 @@ bdrv_wait_serialising_requests_locked(BdrvTrackedRequest *self)
{
BdrvTrackedRequest *req;
+ if (!qatomic_read(&self->bs->serialising_in_flight)) {
+ return;
+ }
+
while ((req = bdrv_find_conflicting_request(self))) {
/*
* If this request is the active owner of the data blocks it accesses,