diff options
author | Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> | 2021-08-24 13:15:16 +0300 |
---|---|---|
committer | Hanna Reitz <hreitz@redhat.com> | 2021-09-15 15:54:07 +0200 |
commit | 6d207d3501b3e6c46c71d782df413d3f4cad2dd8 (patch) | |
tree | 00744ed189babee6c7d09378caffd0dc3e4d11a2 /block/qcow2-cluster.c | |
parent | 5b3f7daaec02704b340ebd8ec4011e19098a2b3c (diff) | |
download | qemu-6d207d3501b3e6c46c71d782df413d3f4cad2dd8.zip qemu-6d207d3501b3e6c46c71d782df413d3f4cad2dd8.tar.gz qemu-6d207d3501b3e6c46c71d782df413d3f4cad2dd8.tar.bz2 |
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>
Diffstat (limited to 'block/qcow2-cluster.c')
-rw-r--r-- | block/qcow2-cluster.c | 49 |
1 files changed, 28 insertions, 21 deletions
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index bd05978..9917e5c 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -1400,29 +1400,36 @@ static int handle_dependencies(BlockDriverState *bs, uint64_t guest_offset, if (end <= old_start || start >= old_end) { /* No intersection */ - } else { - if (start < old_start) { - /* Stop at the start of a running allocation */ - bytes = old_start - start; - } else { - bytes = 0; - } + continue; + } - /* Stop if already an l2meta exists. After yielding, it wouldn't - * be valid any more, so we'd have to clean up the old L2Metas - * and deal with requests depending on them before starting to - * gather new ones. Not worth the trouble. */ - if (bytes == 0 && *m) { - *cur_bytes = 0; - return 0; - } + /* Conflict */ - if (bytes == 0) { - /* 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); - return -EAGAIN; - } + if (start < old_start) { + /* Stop at the start of a running allocation */ + bytes = old_start - start; + } else { + bytes = 0; + } + + /* + * 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 + * and deal with requests depending on them before starting to + * gather new ones. Not worth the trouble. + */ + if (bytes == 0 && *m) { + *cur_bytes = 0; + return 0; + } + + if (bytes == 0) { + /* + * 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); + return -EAGAIN; } } |