]> git.proxmox.com Git - mirror_qemu.git/commit - qemu-img.c
qemu-img: make is_allocated_sectors() more efficient
authorVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Fri, 17 Dec 2021 16:46:54 +0000 (17:46 +0100)
committerKevin Wolf <kwolf@redhat.com>
Fri, 14 Jan 2022 11:03:16 +0000 (12:03 +0100)
commit96054c76ff2db74165385a69f234c57a6bbc941e
tree7426f47bd77a9a4153f2c88fd043947daf5580e8
parent51cd8bddd63540514d44808f7920811439baa253
qemu-img: make is_allocated_sectors() more efficient

Consider the case when the whole buffer is zero and end is unaligned.

If i <= tail, we return 1 and do one unaligned WRITE, RMW happens.

If i > tail, we do on aligned WRITE_ZERO (or skip if target is zeroed)
and again one unaligned WRITE, RMW happens.

Let's do better: don't fragment the whole-zero buffer and report it as
ZERO: in case of zeroed target we just do nothing and avoid RMW. If
target is not zeroes, one unaligned WRITE_ZERO should not be much worse
than one unaligned WRITE.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <20211217164654.1184218-3-vsementsov@virtuozzo.com>
Tested-by: Peter Lieven <pl@kamp.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
qemu-img.c
tests/qemu-iotests/122.out