diff options
author | Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 2020-03-11 13:30:00 +0300 |
---|---|---|
committer | Max Reitz <mreitz@redhat.com> | 2020-03-11 12:42:30 +0100 |
commit | 17187cb646913356bbd434bebdcddf43f92ce31a (patch) | |
tree | dc6e6b67fe7f7c5a6baf17b612e931c7847e2438 | |
parent | 2d57511a88e71485f745ad3dc0afe03b87a8ad5e (diff) | |
download | qemu-17187cb646913356bbd434bebdcddf43f92ce31a.zip qemu-17187cb646913356bbd434bebdcddf43f92ce31a.tar.gz qemu-17187cb646913356bbd434bebdcddf43f92ce31a.tar.bz2 |
block/block-copy: factor out find_conflicting_inflight_req
Split find_conflicting_inflight_req to be used separately.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Reviewed-by: Andrey Shinkevich <andrey.shinkevich@virtuozzo.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-Id: <20200311103004.7649-6-vsementsov@virtuozzo.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
-rw-r--r-- | block/block-copy.c | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/block/block-copy.c b/block/block-copy.c index b075dba..251d415 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, |