qemu-block
[Top][All Lists]
Advanced

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

Re: [Qemu-block] [Qemu-devel] [PATCH v5 14/23] qemu-img: Speed up compar


From: Eric Blake
Subject: Re: [Qemu-block] [Qemu-devel] [PATCH v5 14/23] qemu-img: Speed up compare on pre-allocated larger file
Date: Wed, 11 Oct 2017 13:33:49 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0

On 10/03/2017 09:00 PM, Eric Blake wrote:
> Compare the following images with all-zero contents:
> $ truncate --size 1M A
> $ qemu-img create -f qcow2 -o preallocation=off B 1G
> $ qemu-img create -f qcow2 -o preallocation=metadata C 1G
> 

> Signed-off-by: Eric Blake <address@hidden>
> Reviewed-by: John Snow <address@hidden>
> Reviewed-by: Vladimir Sementsov-Ogievskiy <address@hidden>
> 

> +++ b/qemu-img.c
> @@ -1481,11 +1481,11 @@ static int img_compare(int argc, char **argv)
>          while (sector_num < progress_base) {
>              int64_t count;
> 
> -            ret = bdrv_is_allocated_above(blk_bs(blk_over), NULL,
> +            ret = bdrv_block_status_above(blk_bs(blk_over), NULL,

Just now noticing: in this function, ret is 32-bit, but
bdrv_block_status_above() returns 64-bit values...

>                                            sector_num * BDRV_SECTOR_SIZE,
>                                            (progress_base - sector_num) *
>                                            BDRV_SECTOR_SIZE,
> -                                          &count);
> +                                          &count, NULL);
>              if (ret < 0) {

...which could make for a false positive in a static checker (none of
our implementations return a negative value beyond INT_MIN for wrapping
to be a serious concern).  So that's yet another reason why I am liking
Kevin's proposal to split the returned offset to be a by-reference
parameter rather than squashed into the return type, as it will let me
use a 32-bit return type and avoid worrying about this corner case.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

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