From: Eric Blake <eblake@redhat.com>
To: Alberto Garcia <berto@igalia.com>, qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org, Kevin Wolf <kwolf@redhat.com>,
Max Reitz <mreitz@redhat.com>, "Denis V . Lunev" <den@openvz.org>,
Stefan Hajnoczi <stefanha@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v2 2/7] qcow2: Use unsigned int for both members of Qcow2COWRegion
Date: Wed, 7 Jun 2017 11:02:06 -0500 [thread overview]
Message-ID: <5be69f00-7630-bdb1-70a8-02a078798f15@redhat.com> (raw)
In-Reply-To: <2ddc2703be89a250994478c92ca7695b4b88791b.1496844254.git.berto@igalia.com>
[-- Attachment #1: Type: text/plain, Size: 2511 bytes --]
On 06/07/2017 09:08 AM, Alberto Garcia wrote:
> Qcow2COWRegion has two attributes:
>
> - The offset of the COW region from the start of the first cluster
> touched by the I/O request. Since it's always going to be positive
> and the maximum request size is at most INT_MAX, we can use a
> regular unsigned int to store this offset.
I don't know if we will ever get to the point that we allow a 64-bit
request at the block layer (and then the block layer guarantees it is
split down to the driver's limits, which works when a driver is still
bound by 32-bit limits). But we ALSO know that a cluster is at most 2M
(in our current implementation of qcow2), so the offset of where the COW
region starts in relation to the start of a cluster is < 2M.
>
> - The size of the COW region in bytes. This is guaranteed to be >= 0,
> so we should use an unsigned type instead.
And likewise, since a COW region is a sub-cluster, and clusters are
bounded at 2M, we also have a sub-int upper bound on the size of the region.
>
> In x86_64 this reduces the size of Qcow2COWRegion from 16 to 8 bytes.
> It will also help keep some assertions simpler now that we know that
> there are no negative numbers.
>
> The prototype of do_perform_cow() is also updated to reflect these
> changes.
>
> Signed-off-by: Alberto Garcia <berto@igalia.com>
> ---
> block/qcow2-cluster.c | 4 ++--
> block/qcow2.h | 4 ++--
> 2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
> index d1c419f52b..a86c5a75a9 100644
> --- a/block/qcow2-cluster.c
> +++ b/block/qcow2-cluster.c
> @@ -406,8 +406,8 @@ int qcow2_encrypt_sectors(BDRVQcow2State *s, int64_t sector_num,
> static int coroutine_fn do_perform_cow(BlockDriverState *bs,
> uint64_t src_cluster_offset,
> uint64_t cluster_offset,
> - int offset_in_cluster,
> - int bytes)
> + unsigned offset_in_cluster,
> + unsigned bytes)
I don't know if the code base has a strong preference for 'unsigned int'
over 'unsigned', but it doesn't bother me.
Reviewed-by: Eric Blake <eblake@redhat.com>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
next prev parent reply other threads:[~2017-06-07 16:02 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-07 14:08 [Qemu-devel] [PATCH v2 0/7] qcow2: Reduce the number of I/O ops when doing COW Alberto Garcia
2017-06-07 14:08 ` [Qemu-devel] [PATCH v2 1/7] qcow2: Remove unused Error variable in do_perform_cow() Alberto Garcia
2017-06-07 15:44 ` Eric Blake
2017-06-07 14:08 ` [Qemu-devel] [PATCH v2 2/7] qcow2: Use unsigned int for both members of Qcow2COWRegion Alberto Garcia
2017-06-07 16:02 ` Eric Blake [this message]
2017-06-08 13:06 ` Alberto Garcia
2017-06-08 13:38 ` Eric Blake
2017-06-07 14:08 ` [Qemu-devel] [PATCH v2 3/7] qcow2: Make perform_cow() call do_perform_cow() twice Alberto Garcia
2017-06-07 21:43 ` Eric Blake
2017-06-08 7:09 ` Alberto Garcia
2017-06-07 14:08 ` [Qemu-devel] [PATCH v2 4/7] qcow2: Split do_perform_cow() into _read(), _encrypt() and _write() Alberto Garcia
2017-06-09 14:53 ` Eric Blake
2017-06-12 13:00 ` Alberto Garcia
2017-06-07 14:08 ` [Qemu-devel] [PATCH v2 5/7] qcow2: Allow reading both COW regions with only one request Alberto Garcia
2017-06-07 14:08 ` [Qemu-devel] [PATCH v2 6/7] qcow2: Pass a QEMUIOVector to do_perform_cow_{read, write}() Alberto Garcia
2017-06-07 16:20 ` Manos Pitsidianakis
2017-06-16 15:31 ` Kevin Wolf
2017-06-07 14:08 ` [Qemu-devel] [PATCH v2 7/7] qcow2: Merge the writing of the COW regions with the guest data Alberto Garcia
2017-06-16 15:31 ` Kevin Wolf
2017-06-19 11:50 ` Alberto Garcia
2017-06-16 15:31 ` [Qemu-devel] [PATCH v2 0/7] qcow2: Reduce the number of I/O ops when doing COW Kevin Wolf
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=5be69f00-7630-bdb1-70a8-02a078798f15@redhat.com \
--to=eblake@redhat.com \
--cc=berto@igalia.com \
--cc=den@openvz.org \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/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).