diff options
author | Denis V. Lunev <den@openvz.org> | 2016-05-11 10:00:14 +0300 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2016-05-12 15:22:09 +0200 |
commit | 2928abce6d1d426d37c0a9bd5f85fb95cf33f709 (patch) | |
tree | bb03ee7f76509b42bab3ece5ac8eece43b710a39 /block/nbd-client.c | |
parent | 7b1deac84e2a06530b3a5855ff46a27e87a74820 (diff) | |
download | qemu-2928abce6d1d426d37c0a9bd5f85fb95cf33f709.zip qemu-2928abce6d1d426d37c0a9bd5f85fb95cf33f709.tar.gz qemu-2928abce6d1d426d37c0a9bd5f85fb95cf33f709.tar.bz2 |
qcow2: improve qcow2_co_write_zeroes()
There is a possibility that qcow2_co_write_zeroes() will be called
with the partial block. This could be synthetically triggered with
qemu-io -c "write -z 32k 4k"
and can happen in the real life in qemu-nbd. The latter happens under
the following conditions:
(1) qemu-nbd is started with --detect-zeroes=on and is connected to the
kernel NBD client
(2) third party program opens kernel NBD device with O_DIRECT
(3) third party program performs write operation with memory buffer
not aligned to the page
In this case qcow2_co_write_zeroes() is unable to perform the operation
and mark entire cluster as zeroed and returns ENOTSUP. Thus the caller
switches to non-optimized version and writes real zeroes to the disk.
The patch creates a shortcut. If the block is read as zeroes, f.e. if
it is unallocated, the request is extended to cover full block.
User-visible situation with this block is not changed. Before the patch
the block is filled in the image with real zeroes. After that patch the
block is marked as zeroed in metadata. Thus any subsequent changes in
backing store chain are not affected.
Kevin, thank you for a cool suggestion.
Signed-off-by: Denis V. Lunev <den@openvz.org>
Reviewed-by: Roman Kagan <rkagan@virtuozzo.com>
CC: Kevin Wolf <kwolf@redhat.com>
CC: Max Reitz <mreitz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block/nbd-client.c')
0 files changed, 0 insertions, 0 deletions