@@ -720,12 +720,13 @@ void bdrv_dec_in_flight(BlockDriverState *bs)
bdrv_wakeup(bs);
}
-static bool coroutine_fn wait_serialising_requests(BdrvTrackedRequest *self)
+static bool coroutine_fn do_wait_serialising_requests(BdrvTrackedRequest *self,
+ bool wait)
{
BlockDriverState *bs = self->bs;
BdrvTrackedRequest *req;
bool retry;
- bool waited = false;
+ bool found = false;
if (!atomic_read(&bs->serialising_in_flight)) {
return false;
@@ -751,11 +752,13 @@ static bool coroutine_fn wait_serialising_requests(BdrvTrackedRequest *self)
* will wait for us as soon as it wakes up, then just go on
* (instead of producing a deadlock in the former case). */
if (!req->waiting_for) {
- self->waiting_for = req;
- qemu_co_queue_wait(&req->wait_queue, &bs->reqs_lock);
- self->waiting_for = NULL;
- retry = true;
- waited = true;
+ found = true;
+ if (wait) {
+ self->waiting_for = req;
+ qemu_co_queue_wait(&req->wait_queue, &bs->reqs_lock);
+ self->waiting_for = NULL;
+ retry = true;
+ }
break;
}
}
@@ -763,7 +766,12 @@ static bool coroutine_fn wait_serialising_requests(BdrvTrackedRequest *self)
qemu_co_mutex_unlock(&bs->reqs_lock);
} while (retry);
- return waited;
+ return found;
+}
+
+static bool coroutine_fn wait_serialising_requests(BdrvTrackedRequest *self)
+{
+ return do_wait_serialising_requests(self, true);
}
static int bdrv_check_byte_request(BlockDriverState *bs, int64_t offset,