This series adds an interface for optimized writes when data contains all zeros. If zero detection is enabled a block driver can take extra steps to represent zero regions efficiently.
The details of optimized zero representations depend on the image format but the main block layer change is a field to indicate that zero detection should be performed. (This can be CPU intensive since buffers are scanned for all zeros and the feature is disabled by default.) This series includes a patch for the QED image format that writes special "zero clusters" and keeps the image file compact. In the future qcow2v3 could also support an efficient zero representation. My motivation for this feature is efficient image streaming. The destination file must stay compact and not be bloated with clusters containing only zeroes from the source file. Kevin Wolf <kw...@redhat.com> has suggested zero detection in the source image to avoid scanning for zeroes when the source image has an efficient zero representation. This is a complementary feature which can be introduced in the future but does not work for raw files over NFS, for example. I see the current series as the minimum support we need with extensions possible in the future. Here is a qemu-iotest to verify that zero write detection is working: http://repo.or.cz/w/qemu-iotests/stefanha.git/commitdiff/226949695eef51bdcdea3e6ce3d7e5a863427f37 Stefan Hajnoczi (3): block: add zero write detection interface qed: add zero write detection support qemu-io: add zero write detection option block.c | 16 ++++++++++++ block.h | 3 ++ block/qed.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++------ block_int.h | 9 ++++++ qemu-io.c | 29 ++++++++++++++++----- 5 files changed, 122 insertions(+), 15 deletions(-) -- 1.7.7.3