qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-block] [Qemu-devel] [PATCH 4/5] qcow2: Use bytes instead of se


From: Eric Blake
Subject: Re: [Qemu-block] [Qemu-devel] [PATCH 4/5] qcow2: Use bytes instead of sectors for QCowL2Meta
Date: Fri, 3 Jun 2016 13:44:27 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0

On 06/03/2016 11:21 AM, Kevin Wolf wrote:
> In preparation for implementing .bdrv_co_pwritev in qcow2.
> 
> Signed-off-by: Kevin Wolf <address@hidden>
> ---
>  block/qcow2-cluster.c | 32 ++++++++++++--------------------
>  block/qcow2.h         | 13 +++----------
>  2 files changed, 15 insertions(+), 30 deletions(-)
> 

> @@ -1192,25 +1191,20 @@ static int handle_alloc(BlockDriverState *bs, 
> uint64_t guest_offset,
>      /*
>       * Save info needed for meta data update.
>       *
> -     * requested_sectors: Number of sectors from the start of the first
> +     * requested_sectors: Number of bytes from the start of the first

This comment seems like an incomplete conversion. Is it sectors or bytes?


> -    int requested_sectors =
> -        (*bytes + offset_into_cluster(s, guest_offset))
> -        >> BDRV_SECTOR_BITS;
> -    int avail_sectors = nb_clusters
> -                        << (s->cluster_bits - BDRV_SECTOR_BITS);
> -    int alloc_n_start = offset_into_cluster(s, guest_offset)
> -                        >> BDRV_SECTOR_BITS;
> -    int nb_sectors = MIN(requested_sectors, avail_sectors);
> +    int requested_bytes = *bytes + offset_into_cluster(s, guest_offset);
> +    int avail_bytes = nb_clusters << s->cluster_bits;

Can this ever overflow?

Otherwise looks correct.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]