[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH v5 08/11] block/io: refactor wait_serialising_reques
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[Qemu-block] [PATCH v5 08/11] block/io: refactor wait_serialising_requests |
Date: |
Sat, 29 Dec 2018 15:20:24 +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>
---
block/io.c | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/block/io.c b/block/io.c
index bd9d688f8b..b87c11a6ec 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 v5 10/11] block/backup: tiny refactor backup_job_create, (continued)
- [Qemu-block] [PATCH v5 10/11] block/backup: tiny refactor backup_job_create, Vladimir Sementsov-Ogievskiy, 2018/12/29
- [Qemu-block] [PATCH v5 11/11] block/backup: use backup-top instead of write notifiers, Vladimir Sementsov-Ogievskiy, 2018/12/29
- [Qemu-block] [PATCH v5 03/11] block: improve should_update_child, Vladimir Sementsov-Ogievskiy, 2018/12/29
- [Qemu-block] [PATCH v5 07/11] block: introduce backup-top filter driver, Vladimir Sementsov-Ogievskiy, 2018/12/29
- [Qemu-block] [PATCH v5 01/11] block/backup: simplify backup_incremental_init_copy_bitmap, Vladimir Sementsov-Ogievskiy, 2018/12/29
- [Qemu-block] [PATCH v5 06/11] iotests: prepare 055 to graph changes during backup job, Vladimir Sementsov-Ogievskiy, 2018/12/29
- [Qemu-block] [PATCH v5 05/11] iotests: allow resume_drive by node name, Vladimir Sementsov-Ogievskiy, 2018/12/29
- [Qemu-block] [PATCH v5 09/11] block: add lock/unlock range functions, Vladimir Sementsov-Ogievskiy, 2018/12/29
- [Qemu-block] [PATCH v5 04/11] iotests: handle -f argument correctly for qemu_io_silent, Vladimir Sementsov-Ogievskiy, 2018/12/29
- [Qemu-block] [PATCH v5 02/11] block/backup: move to copy_bitmap with granularity, Vladimir Sementsov-Ogievskiy, 2018/12/29
- [Qemu-block] [PATCH v5 08/11] block/io: refactor wait_serialising_requests,
Vladimir Sementsov-Ogievskiy <=