Files
cloud-hypervisor/block
Anatol Belski 3e2e453d89 block: Honor unmap flag in write zeroes requests
The write zeroes segment descriptor (struct
virtio_blk_discard_write_zeroes, virtio spec v1.2 section 5.2.6)
includes a flags field with an unmap bit. Per section 5.2.6.2, if
unmap is set, the device MAY deallocate the specified range of
sectors in the device backend storage, as if the discard command
had been sent.

Read the flags field and when the unmap bit is set, use punch_hole
to deallocate the range. Otherwise continue using write_zeroes via
ZERO_RANGE which preserves allocation.

This allows the guest to reclaim host disk space through write
zeroes requests on thin provisioned images.

Signed-off-by: Anatol Belski <anbelski@linux.microsoft.com>
2026-03-18 09:40:19 +00:00
..