[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v10 11/14] block/io: refactor wait_serialising_reque
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[Qemu-devel] [PATCH v10 11/14] block/io: refactor wait_serialising_requests |
Date: |
Fri, 30 Aug 2019 19:12:25 +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 56bbf195bb..378180b274 100644
--- a/block/io.c
+++ b/block/io.c
@@ -785,12 +785,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;
@@ -816,11 +817,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;
}
}
@@ -828,7 +831,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-devel] [PATCH v10 00/14] backup-top filter driver for backup, Vladimir Sementsov-Ogievskiy, 2019/08/30
- [Qemu-devel] [PATCH v10 07/14] block: teach bdrv_debug_breakpoint skip filters with backing, Vladimir Sementsov-Ogievskiy, 2019/08/30
- [Qemu-devel] [PATCH v10 03/14] block/backup: improve comment about image fleecing, Vladimir Sementsov-Ogievskiy, 2019/08/30
- [Qemu-devel] [PATCH v10 12/14] block: add lock/unlock range functions, Vladimir Sementsov-Ogievskiy, 2019/08/30
- [Qemu-devel] [PATCH v10 01/14] block/backup: fix backup_cow_with_offload for last cluster, Vladimir Sementsov-Ogievskiy, 2019/08/30
- [Qemu-devel] [PATCH v10 06/14] block: move block_copy from block/backup.c to separate file, Vladimir Sementsov-Ogievskiy, 2019/08/30
- [Qemu-devel] [PATCH v10 02/14] block/backup: split shareable copying part from backup_do_cow, Vladimir Sementsov-Ogievskiy, 2019/08/30
- [Qemu-devel] [PATCH v10 09/14] iotests: 257: drop unused Drive.device field, Vladimir Sementsov-Ogievskiy, 2019/08/30
- [Qemu-devel] [PATCH v10 10/14] iotests: 257: drop device_add, Vladimir Sementsov-Ogievskiy, 2019/08/30
- [Qemu-devel] [PATCH v10 11/14] block/io: refactor wait_serialising_requests,
Vladimir Sementsov-Ogievskiy <=
- [Qemu-devel] [PATCH v10 04/14] block/backup: introduce BlockCopyState, Vladimir Sementsov-Ogievskiy, 2019/08/30
- [Qemu-devel] [PATCH v10 05/14] block/backup: fix block-comment style, Vladimir Sementsov-Ogievskiy, 2019/08/30
- [Qemu-devel] [PATCH v10 14/14] block/backup: use backup-top instead of write notifiers, Vladimir Sementsov-Ogievskiy, 2019/08/30
- [Qemu-devel] [PATCH v10 13/14] block: introduce backup-top filter driver, Vladimir Sementsov-Ogievskiy, 2019/08/30
- [Qemu-devel] [PATCH v10 08/14] iotests: prepare 124 and 257 bitmap querying for backup-top filter, Vladimir Sementsov-Ogievskiy, 2019/08/30