On 4/17/19 5:09 AM, Vladimir Sementsov-Ogievskiy wrote: > Hi all. We faced an interesting bug, which may be simply reproduced: > > prepare image: > ./qemu-img create -f qcow2 -o cluster_size=1M /ssd/test 2300M > ./qemu-io -c 'write 100M 2000M' -c 'write 2100M 200M' -c 'write 0 100M' > /ssd/test > > shrink: > ./qemu-img resize --shrink /ssd/test 50M > > bug: > ./qemu-img info /ssd/test > image: /ssd/test > file format: qcow2 > virtual size: 50M (52428800 bytes) > disk size: 2.2G > cluster_size: 1048576 > Format specific information: > compat: 1.1 > lazy refcounts: false > refcount bits: 16 > corrupt: false > > Virtual size is shrunk, but file - not. It is due to the fact, > that merged qcow2 discard may exceed 2G, and then converting from > uint64_t to int in qcow2_process_discards when we call bdrv_pdiscard > make wrong thing.
Too late for 4.0, but also not a regression new to this release, since the problem appears to have been present since its introduction in commit 0b919fae (1.6.0) (that is, even back then, Qcow2DiscardRegion was introduced with a 64-bit discard length, but qcow2_process_discards blindly passed that through bdrv_discard() at the time, which took 'int nb_sectors'). > > So, here are proposal of fix and new iotest for it. > > Vladimir Sementsov-Ogievskiy (2): > block/io: bdrv_pdiscard: support int64_t bytes parameter > iotests: test big qcow2 shrink > > include/block/block.h | 4 +-- > block/io.c | 19 ++++++----- > tests/qemu-iotests/249 | 69 ++++++++++++++++++++++++++++++++++++++ > tests/qemu-iotests/249.out | 30 +++++++++++++++++ > tests/qemu-iotests/group | 1 + > 5 files changed, 112 insertions(+), 11 deletions(-) > create mode 100755 tests/qemu-iotests/249 > create mode 100644 tests/qemu-iotests/249.out > -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature