mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-19 08:02:15 -06:00
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>
This commit is contained in:
parent
2d57511a88
commit
17187cb646
1 changed files with 18 additions and 11 deletions
|
@ -24,24 +24,31 @@
|
||||||
#define BLOCK_COPY_MAX_BUFFER (1 * MiB)
|
#define BLOCK_COPY_MAX_BUFFER (1 * MiB)
|
||||||
#define BLOCK_COPY_MAX_MEM (128 * 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,
|
static void coroutine_fn block_copy_wait_inflight_reqs(BlockCopyState *s,
|
||||||
int64_t start,
|
int64_t start,
|
||||||
int64_t end)
|
int64_t end)
|
||||||
{
|
{
|
||||||
BlockCopyInFlightReq *req;
|
BlockCopyInFlightReq *req;
|
||||||
bool waited;
|
|
||||||
|
|
||||||
do {
|
while ((req = find_conflicting_inflight_req(s, start, end))) {
|
||||||
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);
|
qemu_co_queue_wait(&req->wait_queue, NULL);
|
||||||
waited = true;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while (waited);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void block_copy_inflight_req_begin(BlockCopyState *s,
|
static void block_copy_inflight_req_begin(BlockCopyState *s,
|
||||||
BlockCopyInFlightReq *req,
|
BlockCopyInFlightReq *req,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue