[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v1 11/13] qcow2-cluster: make handle_dependencies()
From: |
Anton Nefedov |
Subject: |
[Qemu-devel] [PATCH v1 11/13] qcow2-cluster: make handle_dependencies() logic easier to follow |
Date: |
Fri, 19 May 2017 12:34:38 +0300 |
Avoid complicated nested conditions; return or continue asap instead.
The logic is not changed.
Signed-off-by: Anton Nefedov <address@hidden>
Signed-off-by: Denis V. Lunev <address@hidden>
---
block/qcow2-cluster.c | 45 ++++++++++++++++++++++-----------------------
1 file changed, 22 insertions(+), 23 deletions(-)
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
index 03d6f7e..c0974e8 100644
--- a/block/qcow2-cluster.c
+++ b/block/qcow2-cluster.c
@@ -926,32 +926,31 @@ 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) {
- /* start must be cluster aligned at this point */
- assert(start == start_of_cluster(s, start));
- *cur_bytes = 0;
- return 0;
- }
+ if (start < old_start) {
+ /* Stop at the start of a running allocation */
+ bytes = old_start - start;
+ /* ..if there is no other conflict, keep checking */
+ continue;
+ }
- 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;
- }
+ /* 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 (*m) {
+ /* start must be cluster aligned at this point */
+ assert(start == start_of_cluster(s, start));
+ *cur_bytes = 0;
+ return 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;
}
/* Make sure that existing clusters and new allocations are only used up to
--
2.7.4
- Re: [Qemu-devel] [PATCH v1 03/13] qcow2: do not COW the empty areas, (continued)
- [Qemu-devel] [PATCH v1 05/13] qcow2: set inactive flag, Anton Nefedov, 2017/05/19
- [Qemu-devel] [PATCH v1 04/13] qcow2: preallocation at image expand, Anton Nefedov, 2017/05/19
- [Qemu-devel] [PATCH v1 06/13] qcow2: truncate preallocated space, Anton Nefedov, 2017/05/19
- [Qemu-devel] [PATCH v1 08/13] qcow2: handle_prealloc(): find out if area zeroed by earlier preallocation, Anton Nefedov, 2017/05/19
- [Qemu-devel] [PATCH v1 09/13] qcow2: fix misleading comment about L2 linking, Anton Nefedov, 2017/05/19
- [Qemu-devel] [PATCH v1 07/13] qcow2: check space leak at the end of the image, Anton Nefedov, 2017/05/19
- [Qemu-devel] [PATCH v1 11/13] qcow2-cluster: make handle_dependencies() logic easier to follow,
Anton Nefedov <=
- [Qemu-devel] [PATCH v1 13/13] iotest 046: test simultaneous cluster write error case, Anton Nefedov, 2017/05/19
- [Qemu-devel] [PATCH v1 10/13] qcow2-cluster: slightly refactor handle_dependencies(), Anton Nefedov, 2017/05/19
- [Qemu-devel] [PATCH v1 12/13] qcow2: allow concurrent unaligned writes to the same clusters, Anton Nefedov, 2017/05/19
- Re: [Qemu-devel] [PATCH v1 00/13] qcow2: space preallocation and COW improvements, Eric Blake, 2017/05/23