From: Anton Nefedov <anton.nefedov@virtuozzo.com>
To: qemu-devel@nongnu.org
Cc: den@virtuozzo.com, kwolf@redhat.com, mreitz@redhat.com,
eblake@redhat.com, Anton Nefedov <anton.nefedov@virtuozzo.com>,
"Denis V . Lunev" <den@openvz.org>
Subject: [Qemu-devel] [PATCH v2 12/15] qcow2-cluster: slightly refactor handle_dependencies()
Date: Thu, 1 Jun 2017 18:14:30 +0300 [thread overview]
Message-ID: <1496330073-51338-13-git-send-email-anton.nefedov@virtuozzo.com> (raw)
In-Reply-To: <1496330073-51338-1-git-send-email-anton.nefedov@virtuozzo.com>
- assert the alignment on return if the allocation has to stop
(at the start of a running allocation)
- make use of const specifiers for local variables
Signed-off-by: Anton Nefedov <anton.nefedov@virtuozzo.com>
Signed-off-by: Denis V. Lunev <den@openvz.org>
---
block/qcow2-cluster.c | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
index 3dafd19..95e8862 100644
--- a/block/qcow2-cluster.c
+++ b/block/qcow2-cluster.c
@@ -900,15 +900,15 @@ out:
* Check if there already is an AIO write request in flight which allocates
* the same cluster. In this case we need to wait until the previous
* request has completed and updated the L2 table accordingly.
- *
* Returns:
* 0 if there was no dependency. *cur_bytes indicates the number of
* bytes from guest_offset that can be read before the next
- * dependency must be processed (or the request is complete)
+ * dependency must be processed (or the request is complete).
+ * *m is not modified
*
- * -EAGAIN if we had to wait for another request, previously gathered
- * information on cluster allocation may be invalid now. The caller
- * must start over anyway, so consider *cur_bytes undefined.
+ * -EAGAIN if we had to wait for another request. The caller
+ * must start over, so consider *cur_bytes undefined.
+ * *m is not modified
*/
static int handle_dependencies(BlockDriverState *bs, uint64_t guest_offset,
uint64_t *cur_bytes, QCowL2Meta **m)
@@ -919,10 +919,10 @@ static int handle_dependencies(BlockDriverState *bs, uint64_t guest_offset,
QLIST_FOREACH(old_alloc, &s->cluster_allocs, next_in_flight) {
- uint64_t start = guest_offset;
- uint64_t end = start + bytes;
- uint64_t old_start = l2meta_cow_start(old_alloc);
- uint64_t old_end = l2meta_cow_end(old_alloc);
+ const uint64_t start = guest_offset;
+ const uint64_t end = start + bytes;
+ const uint64_t old_start = l2meta_cow_start(old_alloc);
+ const uint64_t old_end = l2meta_cow_end(old_alloc);
if (end <= old_start || start >= old_end) {
/* No intersection */
@@ -939,6 +939,8 @@ static int handle_dependencies(BlockDriverState *bs, uint64_t guest_offset,
* 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;
}
--
2.7.4
next prev parent reply other threads:[~2017-06-01 15:15 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-01 15:14 [Qemu-devel] [PATCH v2 00/15] qcow2: space preallocation and COW improvements Anton Nefedov
2017-06-01 15:14 ` [Qemu-devel] [PATCH v2 01/15] block: introduce BDRV_REQ_ALLOCATE flag Anton Nefedov
2017-06-01 19:07 ` Eric Blake
2017-06-02 13:08 ` Anton Nefedov
2017-06-01 15:14 ` [Qemu-devel] [PATCH v2 02/15] file-posix: support BDRV_REQ_ALLOCATE Anton Nefedov
2017-06-01 19:49 ` Eric Blake
2017-06-01 19:54 ` Eric Blake
2017-06-02 14:34 ` Anton Nefedov
2017-06-01 15:14 ` [Qemu-devel] [PATCH v2 03/15] blkdebug: " Anton Nefedov
2017-06-01 19:50 ` Eric Blake
2017-06-02 13:13 ` Anton Nefedov
2017-06-01 15:14 ` [Qemu-devel] [PATCH v2 04/15] qcow2: alloc space for COW in one chunk Anton Nefedov
2017-06-05 14:28 ` Eric Blake
2017-06-01 15:14 ` [Qemu-devel] [PATCH v2 05/15] qcow2: do not COW the empty areas Anton Nefedov
2017-06-05 14:40 ` Eric Blake
2017-06-01 15:14 ` [Qemu-devel] [PATCH v2 06/15] qcow2: preallocation at image expand Anton Nefedov
2017-06-01 15:14 ` [Qemu-devel] [PATCH v2 07/15] qcow2: set inactive flag Anton Nefedov
2017-06-01 15:14 ` [Qemu-devel] [PATCH v2 08/15] qcow2: truncate preallocated space Anton Nefedov
2017-06-01 15:14 ` [Qemu-devel] [PATCH v2 09/15] qcow2: check space leak at the end of the image Anton Nefedov
2017-06-01 15:14 ` [Qemu-devel] [PATCH v2 10/15] qcow2: handle_prealloc(): find out if area zeroed by earlier preallocation Anton Nefedov
2017-06-01 15:14 ` [Qemu-devel] [PATCH v2 11/15] qcow2: fix misleading comment about L2 linking Anton Nefedov
2017-06-01 15:14 ` Anton Nefedov [this message]
2017-06-01 15:14 ` [Qemu-devel] [PATCH v2 13/15] qcow2-cluster: make handle_dependencies() logic easier to follow Anton Nefedov
2017-06-01 15:14 ` [Qemu-devel] [PATCH v2 14/15] qcow2: allow concurrent unaligned writes to the same clusters Anton Nefedov
2017-06-01 15:14 ` [Qemu-devel] [PATCH v2 15/15] iotest 046: test simultaneous cluster write error case Anton Nefedov
2017-06-01 18:41 ` [Qemu-devel] [PATCH v2 00/15] qcow2: space preallocation and COW improvements John Snow
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1496330073-51338-13-git-send-email-anton.nefedov@virtuozzo.com \
--to=anton.nefedov@virtuozzo.com \
--cc=den@openvz.org \
--cc=den@virtuozzo.com \
--cc=eblake@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).