]> git.ipfire.org Git - thirdparty/qemu.git/commit
qcow2: Forward ZERO_WRITE flag for full preallocation
authorKevin Wolf <kwolf@redhat.com>
Fri, 24 Apr 2020 14:27:01 +0000 (16:27 +0200)
committerKevin Wolf <kwolf@redhat.com>
Thu, 30 Apr 2020 15:51:07 +0000 (17:51 +0200)
commiteb8a0cf3ba26611f3981f8f45ac6a868975a68cc
tree4b8711b089ae88ba8166f9881f83ac3ffb1092b5
parentbf03dede475e29a16f9188ea85a4d77cd3dcf2b7
qcow2: Forward ZERO_WRITE flag for full preallocation

The BDRV_REQ_ZERO_WRITE is currently implemented in a way that first the
image is possibly preallocated and then the zero flag is added to all
clusters. This means that a copy-on-write operation may be needed when
writing to these clusters, despite having used preallocation, negating
one of the major benefits of preallocation.

Instead, try to forward the BDRV_REQ_ZERO_WRITE to the protocol driver,
and if the protocol driver can ensure that the new area reads as zeros,
we can skip setting the zero flag in the qcow2 layer.

Unfortunately, the same approach doesn't work for metadata
preallocation, so we'll still set the zero flag there.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
Message-Id: <20200424142701.67053-1-kwolf@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/qcow2.c
tests/qemu-iotests/274.out