[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 15/19] block/block-copy: factor out find_conflicting_inflight_req
From: |
Max Reitz |
Subject: |
[PULL 15/19] block/block-copy: factor out find_conflicting_inflight_req |
Date: |
Wed, 11 Mar 2020 14:52:09 +0100 |
From: Vladimir Sementsov-Ogievskiy <address@hidden>
Split find_conflicting_inflight_req to be used separately.
Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
Reviewed-by: Andrey Shinkevich <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Max Reitz <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 b075dba206..251d415a2c 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 *find_conflicting_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 = find_conflicting_inflight_req(s, start, end))) {
+ qemu_co_queue_wait(&req->wait_queue, NULL);
+ }
}
static void block_copy_inflight_req_begin(BlockCopyState *s,
--
2.24.1
- [PULL 06/19] block/curl: HTTP header field names are case insensitive, (continued)
- [PULL 06/19] block/curl: HTTP header field names are case insensitive, Max Reitz, 2020/03/11
- [PULL 09/19] qemu-img: free memory before re-assign, Max Reitz, 2020/03/11
- [PULL 08/19] block/qcow2: do free crypto_opts in qcow2_close(), Max Reitz, 2020/03/11
- [PULL 03/19] qemu-img: allow qemu-img measure --object without a filename, Max Reitz, 2020/03/11
- [PULL 10/19] block/qcow2-threads: fix qcow2_decompress, Max Reitz, 2020/03/11
- [PULL 07/19] iotests: Fix nonportable use of od --endian, Max Reitz, 2020/03/11
- [PULL 11/19] job: refactor progress to separate object, Max Reitz, 2020/03/11
- [PULL 12/19] block/block-copy: fix progress calculation, Max Reitz, 2020/03/11
- [PULL 13/19] block/block-copy: specialcase first copy_range request, Max Reitz, 2020/03/11
- [PULL 14/19] block/block-copy: use block_status, Max Reitz, 2020/03/11
- [PULL 15/19] block/block-copy: factor out find_conflicting_inflight_req,
Max Reitz <=
- [PULL 16/19] block/block-copy: refactor interfaces to use bytes instead of end, Max Reitz, 2020/03/11
- [PULL 17/19] block/block-copy: rename start to offset in interfaces, Max Reitz, 2020/03/11
- [PULL 18/19] block/block-copy: reduce intersecting request lock, Max Reitz, 2020/03/11
- [PULL 19/19] block/block-copy: hide structure definitions, Max Reitz, 2020/03/11
- Re: [PULL 00/19] Block patches, Peter Maydell, 2020/03/12