[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH v8 5/7] block/io: refactor wait_serialising_requests
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[Qemu-block] [PATCH v8 5/7] block/io: refactor wait_serialising_requests |
Date: |
Wed, 29 May 2019 18:46:52 +0300 |
Split out do_wait_serialising_requests with additional possibility to
not actually wait but just check, that there is something to wait for.
Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
---
block/io.c | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/block/io.c b/block/io.c
index 3134a60a48..c347f90722 100644
--- a/block/io.c
+++ b/block/io.c
@@ -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,
--
2.18.0
- [Qemu-block] [PATCH v8 0/7] backup-top filter driver for backup, Vladimir Sementsov-Ogievskiy, 2019/05/29
- [Qemu-block] [PATCH v8 2/7] block: swap operation order in bdrv_append, Vladimir Sementsov-Ogievskiy, 2019/05/29
- [Qemu-block] [PATCH v8 3/7] block: allow not one child for implicit node, Vladimir Sementsov-Ogievskiy, 2019/05/29
- [Qemu-block] [PATCH v8 5/7] block/io: refactor wait_serialising_requests,
Vladimir Sementsov-Ogievskiy <=
- [Qemu-block] [PATCH v8 1/7] block: teach bdrv_debug_breakpoint skip filters with backing, Vladimir Sementsov-Ogievskiy, 2019/05/29
- [Qemu-block] [PATCH v8 6/7] block: add lock/unlock range functions, Vladimir Sementsov-Ogievskiy, 2019/05/29
- [Qemu-block] [PATCH v8 4/7] block: introduce backup-top filter driver, Vladimir Sementsov-Ogievskiy, 2019/05/29
- [Qemu-block] [PATCH v8 7/7] block/backup: use backup-top instead of write notifiers, Vladimir Sementsov-Ogievskiy, 2019/05/29
- Re: [Qemu-block] [PATCH v8 0/7] backup-top filter driver for backup, Vladimir Sementsov-Ogievskiy, 2019/05/30