qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: qemu-block@nongnu.org, 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: Tue, 7 Jun 2016 11:12:47 +0200	[thread overview]
Message-ID: <20160607091247.GA4684@noname.str.redhat.com> (raw)
In-Reply-To: <575643D7.3090807@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1920 bytes --]

Am 07.06.2016 um 05:47 hat Eric Blake geschrieben:
> 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...

Yes, thanks for catching that.

> >          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?

You mean I should actually test encrypted images? *cough* (I know I did
test something with encryption, but maybe that was only after converting
reads.)

Anyway, missing ~ indeed.

> > +        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.

Kevin

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

  reply	other threads:[~2016-06-07  9:13 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
2016-06-07  9:12     ` Kevin Wolf [this message]
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=20160607091247.GA4684@noname.str.redhat.com \
    --to=kwolf@redhat.com \
    --cc=eblake@redhat.com \
    --cc=jsnow@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 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).