From: Eric Blake <eblake@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>, qemu-block@nongnu.org
Cc: mreitz@redhat.com, jsnow@redhat.com, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2 3/5] qcow2: Make copy_sectors() byte based
Date: Mon, 6 Jun 2016 21:47:35 -0600 [thread overview]
Message-ID: <575643D7.3090807@redhat.com> (raw)
In-Reply-To: <1465225155-18661-4-git-send-email-kwolf@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1671 bytes --]
On 06/06/2016 08:59 AM, Kevin Wolf wrote:
> This will allow copy on write operations where the overwritten part of
> the cluster is not aligned to sector boundaries.
>
> Also rename the function because it has nothing to do with sectors any
> more.
>
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
> block/qcow2-cluster.c | 54 +++++++++++++++++++++++++--------------------------
> 1 file changed, 26 insertions(+), 28 deletions(-)
>
>
> if (bs->encrypted) {
> Error *err = NULL;
> + int sector = (cluster_offset + offset_in_cluster) >> BDRV_SECTOR_BITS;
Potentially the wrong type...
> assert(s->cipher);
> - if (qcow2_encrypt_sectors(s, start_sect + n_start,
> - iov.iov_base, iov.iov_base, n,
> - true, &err) < 0) {
> + assert((offset_in_cluster & BDRV_SECTOR_MASK) == 0);
Why is this one true? If I have a cluster of 4 sectors, why must
offset_in_cluster fall within only the first of those sectors? Are you
missing a ~, to instead be asserting that offset_in_cluster is
sector-aligned?
> + assert((bytes & ~BDRV_SECTOR_MASK) == 0);
This one looks correct, stating that the number of bytes to copy is a
sector multiple.
> + if (qcow2_encrypt_sectors(s, sector, iov.iov_base, iov.iov_base,
> + bytes >> BDRV_SECTOR_BITS, true, &err) < 0) {
...since encryption allows a 64-bit sector number for the case where the
image is larger than 2T.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
next prev parent reply other threads:[~2016-06-07 3:47 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-06 14:59 [Qemu-devel] [PATCH v2 0/5] qcow2: Implement .bdrv_co_preadv/pwritev Kevin Wolf
2016-06-06 14:59 ` [Qemu-devel] [PATCH v2 1/5] qcow2: Work with bytes in qcow2_get_cluster_offset() Kevin Wolf
2016-06-06 17:11 ` Eric Blake
2016-06-06 14:59 ` [Qemu-devel] [PATCH v2 2/5] qcow2: Implement .bdrv_co_preadv() Kevin Wolf
2016-06-06 21:32 ` Eric Blake
2016-06-06 14:59 ` [Qemu-devel] [PATCH v2 3/5] qcow2: Make copy_sectors() byte based Kevin Wolf
2016-06-07 3:47 ` Eric Blake [this message]
2016-06-07 9:12 ` Kevin Wolf
2016-06-07 9:20 ` [Qemu-devel] [PATCH v3 " Kevin Wolf
2016-06-07 11:57 ` Eric Blake
2016-06-06 14:59 ` [Qemu-devel] [PATCH v2 4/5] qcow2: Use bytes instead of sectors for QCowL2Meta Kevin Wolf
2016-06-07 3:50 ` Eric Blake
2016-06-06 14:59 ` [Qemu-devel] [PATCH v2 5/5] qcow2: Implement .bdrv_co_pwritev() Kevin Wolf
2016-06-07 4:02 ` Eric Blake
2016-06-09 13:27 ` [Qemu-devel] [PATCH v2 0/5] qcow2: Implement .bdrv_co_preadv/pwritev 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=575643D7.3090807@redhat.com \
--to=eblake@redhat.com \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.