block: split write_zeroes always
commit443668ca408cdb7f01e1a70a58518bb100c3e9d1
authorDenis V. Lunev <den@openvz.org>
Thu, 26 May 2016 03:48:45 +0000 (25 21:48 -0600)
committerKevin Wolf <kwolf@redhat.com>
Wed, 8 Jun 2016 08:21:08 +0000 (8 10:21 +0200)
tree668a5dad129a866dcba61c066a193f42e5bdabd9
parent6ed5546fa7bf12c5b87ef76bafb86e1d77ed6e85
block: split write_zeroes always

We should split requests even if they are less than write_zeroes_alignment.
For example we can have the following request:
  offset 62k
  size   4k
  write_zeroes_alignment 64k
The original code sent 1 request covering 2 qcow2 clusters, and resulted
in both clusters being allocated. But by splitting the request, we can
cater to the case where one of the two clusters can be zeroed as a
whole, for only 1 cluster allocated after the operation.

Signed-off-by: Denis V. Lunev <den@openvz.org>
CC: Eric Blake <eblake@redhat.com>
CC: Kevin Wolf <kwolf@redhat.com>
Message-Id: <1463476543-3087-2-git-send-email-den@openvz.org>

[eblake: Avoid exceeding nb_sectors, hoist alignment checks out of
loop, and update testsuite to show that patch works]

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/io.c
tests/qemu-iotests/154.out