qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
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 2/5] qcow2: Implement .bdrv_co_preadv()
Date: Mon, 6 Jun 2016 15:32:29 -0600	[thread overview]
Message-ID: <5755EBED.2070400@redhat.com> (raw)
In-Reply-To: <1465225155-18661-3-git-send-email-kwolf@redhat.com>

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

On 06/06/2016 08:59 AM, Kevin Wolf wrote:
> Reading from qcow2 images is now byte granularity.
> 
> Most of the affected code in qcow2 actually gets simpler with this
> change. The only exception is encryption, which is fixed on 512 bytes
> blocks; in order to keep this working, bs->request_alignment is set for
> encrypted images.
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  block/qcow2-cluster.c |  27 ++++++-------
>  block/qcow2.c         | 108 +++++++++++++++++++++++++++-----------------------
>  block/qcow2.h         |   2 +-
>  3 files changed, 72 insertions(+), 65 deletions(-)
> 

> - * on exit, *num is the number of contiguous sectors we can read.
> + * On exit, *bytes is the number of bytes staring at offset that have the same

s/staring/starting/

(although "staring" does make for a rather interesting thought :)

> @@ -1389,26 +1402,24 @@ static coroutine_fn int qcow2_co_readv(BlockDriverState *bs, int64_t sector_num,
>  
>      qemu_co_mutex_lock(&s->lock);
>  
> -    while (remaining_sectors != 0) {
> +    while (bytes != 0) {
>  
>          /* prepare next request */
> -        cur_nr_sectors = remaining_sectors;
> +        cur_bytes = MIN(bytes, INT_MAX);
>          if (s->cipher) {
> -            cur_nr_sectors = MIN(cur_nr_sectors,
> -                QCOW_MAX_CRYPT_CLUSTERS * s->cluster_sectors);
> +            cur_bytes = MIN(cur_bytes,
> +                            QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size);
>          }

Can this ever result in cur_bytes that is not aligned, even though
encryption requires aligned reads?  Do you need to round anything to a
sector boundary in this case?

>              qemu_co_mutex_unlock(&s->lock);
> -            ret = bdrv_co_readv(bs->file->bs,
> -                                (cluster_offset >> 9) + index_in_cluster,
> -                                cur_nr_sectors, &hd_qiov);
> +            ret = bdrv_co_preadv(bs->file->bs,
> +                                 cluster_offset + offset_in_cluster,
> +                                 cur_bytes, &hd_qiov, 0);
>              qemu_co_mutex_lock(&s->lock);
>              if (ret < 0) {
>                  goto fail;
>              }
>              if (bs->encrypted) {
>                  assert(s->cipher);
> +                assert((offset & (BDRV_SECTOR_SIZE - 1)) == 0);
> +                assert((cur_bytes & (BDRV_SECTOR_SIZE - 1)) == 0);

Hmm, you do check that later on.

So, other than the typo (easy to fix on commit),
Reviewed-by: Eric Blake <eblake@redhat.com>

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

  reply	other threads:[~2016-06-06 21:32 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 [this message]
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
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=5755EBED.2070400@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 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).