mirror of https://github.com/xemu-project/xemu.git
qcow2: refactor handle_dependencies() loop body
No logic change, just prepare for the following commit. While being here do also small grammar fix in a comment. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Hanna Reitz <hreitz@redhat.com> Message-Id: <20210824101517.59802-3-vsementsov@virtuozzo.com> Signed-off-by: Hanna Reitz <hreitz@redhat.com>
This commit is contained in:
parent
5b3f7daaec
commit
6d207d3501
|
@ -1400,7 +1400,11 @@ static int handle_dependencies(BlockDriverState *bs, uint64_t guest_offset,
|
||||||
|
|
||||||
if (end <= old_start || start >= old_end) {
|
if (end <= old_start || start >= old_end) {
|
||||||
/* No intersection */
|
/* No intersection */
|
||||||
} else {
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Conflict */
|
||||||
|
|
||||||
if (start < old_start) {
|
if (start < old_start) {
|
||||||
/* Stop at the start of a running allocation */
|
/* Stop at the start of a running allocation */
|
||||||
bytes = old_start - start;
|
bytes = old_start - start;
|
||||||
|
@ -1408,23 +1412,26 @@ static int handle_dependencies(BlockDriverState *bs, uint64_t guest_offset,
|
||||||
bytes = 0;
|
bytes = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Stop if already an l2meta exists. After yielding, it wouldn't
|
/*
|
||||||
|
* Stop if an l2meta already exists. After yielding, it wouldn't
|
||||||
* be valid any more, so we'd have to clean up the old L2Metas
|
* be valid any more, so we'd have to clean up the old L2Metas
|
||||||
* and deal with requests depending on them before starting to
|
* and deal with requests depending on them before starting to
|
||||||
* gather new ones. Not worth the trouble. */
|
* gather new ones. Not worth the trouble.
|
||||||
|
*/
|
||||||
if (bytes == 0 && *m) {
|
if (bytes == 0 && *m) {
|
||||||
*cur_bytes = 0;
|
*cur_bytes = 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bytes == 0) {
|
if (bytes == 0) {
|
||||||
/* Wait for the dependency to complete. We need to recheck
|
/*
|
||||||
* the free/allocated clusters when we continue. */
|
* Wait for the dependency to complete. We need to recheck
|
||||||
|
* the free/allocated clusters when we continue.
|
||||||
|
*/
|
||||||
qemu_co_queue_wait(&old_alloc->dependent_requests, &s->lock);
|
qemu_co_queue_wait(&old_alloc->dependent_requests, &s->lock);
|
||||||
return -EAGAIN;
|
return -EAGAIN;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* Make sure that existing clusters and new allocations are only used up to
|
/* Make sure that existing clusters and new allocations are only used up to
|
||||||
* the next dependency if we shortened the request above */
|
* the next dependency if we shortened the request above */
|
||||||
|
|
Loading…
Reference in New Issue