[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 3/7] block/block-copy: factor out block_copy_find_inflight_req
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[PATCH v2 3/7] block/block-copy: factor out block_copy_find_inflight_req |
Date: |
Wed, 27 Nov 2019 21:08:36 +0300 |
Split block_copy_find_inflight_req to be used in seprate.
Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
---
block/block-copy.c | 31 +++++++++++++++++++------------
1 file changed, 19 insertions(+), 12 deletions(-)
diff --git a/block/block-copy.c b/block/block-copy.c
index 74295d93d5..94e7e855ef 100644
--- a/block/block-copy.c
+++ b/block/block-copy.c
@@ -24,23 +24,30 @@
#define BLOCK_COPY_MAX_BUFFER (1 * MiB)
#define BLOCK_COPY_MAX_MEM (128 * MiB)
+static BlockCopyInFlightReq *block_copy_find_inflight_req(BlockCopyState *s,
+ int64_t start,
+ int64_t end)
+{
+ BlockCopyInFlightReq *req;
+
+ QLIST_FOREACH(req, &s->inflight_reqs, list) {
+ if (end > req->start_byte && start < req->end_byte) {
+ return req;
+ }
+ }
+
+ return NULL;
+}
+
static void coroutine_fn block_copy_wait_inflight_reqs(BlockCopyState *s,
int64_t start,
int64_t end)
{
BlockCopyInFlightReq *req;
- bool waited;
-
- do {
- waited = false;
- QLIST_FOREACH(req, &s->inflight_reqs, list) {
- if (end > req->start_byte && start < req->end_byte) {
- qemu_co_queue_wait(&req->wait_queue, NULL);
- waited = true;
- break;
- }
- }
- } while (waited);
+
+ while ((req = block_copy_find_inflight_req(s, start, end))) {
+ qemu_co_queue_wait(&req->wait_queue, NULL);
+ }
}
static void block_copy_inflight_req_begin(BlockCopyState *s,
--
2.21.0
- [PATCH v2 for-5.0 0/7] block-copy improvements: part I, Vladimir Sementsov-Ogievskiy, 2019/11/27
- [PATCH v2 1/7] block/block-copy: specialcase first copy_range request, Vladimir Sementsov-Ogievskiy, 2019/11/27
- [PATCH v2 4/7] block/block-copy: refactor interfaces to use bytes instead of end, Vladimir Sementsov-Ogievskiy, 2019/11/27
- [PATCH v2 6/7] block/block-copy: reduce intersecting request lock, Vladimir Sementsov-Ogievskiy, 2019/11/27
- [PATCH v2 7/7] block/block-copy: hide structure definitions, Vladimir Sementsov-Ogievskiy, 2019/11/27
- [PATCH v2 3/7] block/block-copy: factor out block_copy_find_inflight_req,
Vladimir Sementsov-Ogievskiy <=
- [PATCH v2 2/7] block/block-copy: use block_status, Vladimir Sementsov-Ogievskiy, 2019/11/27
- [PATCH v2 5/7] block/block-copy: rename start to offset in interfaces, Vladimir Sementsov-Ogievskiy, 2019/11/27