This series reworks write_zeroes and discard support in QEMU, with the aim of enabling discard support in guests. The problem here is that so far the semantics of discard were left to the block drivers. Discard could only be enabled as long as all storage had the same characteristics, including all of them supporting it and all of them having the same discard granularity. Hence, nobody really bothered to enable it. (This is good, because we have fewer backwards-compatibility issues).
This series fixes this by specifying the semantics of discard at the block layer level: from now on, discard will always have sector granularity and write zeroes to the devices. Given this choice, the equivalent of Linux discard_zeroes_data can also be easily implemented. Patches 1-4 add information on discard to bdrv_get_info, and implement discard for QED. Patches 5-8 replace the write_zeroes operation with discard. Patches 9-12 turn discard on in the device models. Patches 13-15 add discard support for files and enable hole-punching in other filesystems than XFS. To complete thin provisioning support, patches 16 and 17 implement is_allocated for raw using the brand new SEEK_HOLE/SEEK_DATA interface. With these patches and with the kernel patch at http://patchwork.xfs.org/patch/3264/ it should be possible to do efficient streaming with raw on XFS. Various bits could be separated and committed in parts; comments are welcome. Paolo Bonzini (17): qemu-iotests: add a simple test for write_zeroes qed: make write-zeroes bounce buffer smaller than a single cluster block: add discard properties to BlockDriverInfo qed: implement bdrv_aio_discard block: pass around qiov for write_zeroes operation block: use bdrv_{co,aio}_discard for write_zeroes operations block: make high level discard operation always zero block: kill the write zeroes operation ide: issue discard asynchronously but serialize the pieces ide/scsi: add discard_zeroes_data property ide/scsi: prepare for flipping the discard defaults ide/scsi: turn on discard block: fallback from discard to writes block: support FALLOC_FL_PUNCH_HOLE trimming raw: add get_info qemu-io: fix the alloc command raw: implement is_allocated block.c | 62 +++++++------ block.h | 30 ++++--- block/qcow2.c | 2 + block/qed.c | 126 ++++++++++++------------- block/raw-posix.c | 100 +++++++++++++++++++- block/raw.c | 14 +++ block_int.h | 8 -- hw/ide/core.c | 81 +++++++++++----- hw/ide/qdev.c | 6 +- hw/pc_piix.c | 224 ++++++++++++++++++++++++++++++++++++++++++++ hw/scsi-disk.c | 17 +++- qemu-io.c | 61 ++---------- tests/qemu-iotests/031 | 73 ++++++++++++++ tests/qemu-iotests/031.out | 29 ++++++ tests/qemu-iotests/group | 1 + 15 files changed, 635 insertions(+), 199 deletions(-) create mode 100755 tests/qemu-iotests/031 create mode 100644 tests/qemu-iotests/031.out -- 1.7.7.6