[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v5 14/23] qemu-img: Speed up compare on pre-allo
From: |
Eric Blake |
Subject: |
Re: [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
signature.asc
Description: OpenPGP digital signature
- [Qemu-devel] [PATCH v5 10/23] block: Switch bdrv_common_block_status_above() to byte-based, (continued)
- [Qemu-devel] [PATCH v5 10/23] block: Switch bdrv_common_block_status_above() to byte-based, Eric Blake, 2017/10/03
- [Qemu-devel] [PATCH v5 11/23] block: Switch bdrv_co_get_block_status_above() to byte-based, Eric Blake, 2017/10/03
- [Qemu-devel] [PATCH v5 09/23] block: Switch BdrvCoGetBlockStatusData to byte-based, Eric Blake, 2017/10/03
- [Qemu-devel] [PATCH v5 13/23] qemu-img: Simplify logic in img_compare(), Eric Blake, 2017/10/03
- [Qemu-devel] [PATCH v5 15/23] qemu-img: Add find_nonzero(), Eric Blake, 2017/10/03
- [Qemu-devel] [PATCH v5 12/23] block: Convert bdrv_get_block_status_above() to bytes, Eric Blake, 2017/10/03
- [Qemu-devel] [PATCH v5 17/23] qemu-img: Change check_empty_sectors() to byte-based, Eric Blake, 2017/10/03
- [Qemu-devel] [PATCH v5 14/23] qemu-img: Speed up compare on pre-allocated larger file, Eric Blake, 2017/10/03
- Re: [Qemu-devel] [PATCH v5 14/23] qemu-img: Speed up compare on pre-allocated larger file,
Eric Blake <=
- [Qemu-devel] [PATCH v5 16/23] qemu-img: Drop redundant error message in compare, Eric Blake, 2017/10/03
- [Qemu-devel] [PATCH v5 18/23] qemu-img: Change compare_sectors() to be byte-based, Eric Blake, 2017/10/03
- [Qemu-devel] [PATCH v5 19/23] qemu-img: Change img_rebase() to be byte-based, Eric Blake, 2017/10/03
- [Qemu-devel] [PATCH v5 20/23] qemu-img: Change img_compare() to be byte-based, Eric Blake, 2017/10/03
- [Qemu-devel] [PATCH v5 22/23] block: Relax bdrv_aligned_preadv() assertion, Eric Blake, 2017/10/03
- [Qemu-devel] [PATCH v5 23/23] qemu-io: Relax 'alloc' now that block-status doesn't assert, Eric Blake, 2017/10/03
- [Qemu-devel] [PATCH v5 21/23] block: Align block status requests, Eric Blake, 2017/10/03
- Re: [Qemu-devel] [PATCH v5 00/23] make bdrv_get_block_status byte-based, Kevin Wolf, 2017/10/10