[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PATCH for-4.0? 0/2] Fix overflow bug in qcow2 discard
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[Qemu-block] [PATCH for-4.0? 0/2] Fix overflow bug in qcow2 discard |
Date: |
Wed, 17 Apr 2019 13:09:27 +0300 |
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.
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
--
2.18.0
- [Qemu-block] [PATCH for-4.0? 0/2] Fix overflow bug in qcow2 discard,
Vladimir Sementsov-Ogievskiy <=