[Devel] [PATCH hci-8.2 v4] drivers/vhost/blk: support VIRTIO_BLK_F_WRITE_ZEROES

Konstantin Khorenko khorenko at virtuozzo.com
Wed Nov 18 18:26:32 MSK 2026


Applying with these fixes on my side:
- "The VMM advertises ... and sets" -> "The VMM must advertise ... and
  set": our QEMU does not do it yet, the QEMU patch is not in hci-dev
- the cap: "and rounded down to the logical block size", as 8388607
  sectors is not a multiple of a 4K block

On Wed, 18 Nov 2026 12:08:13 +0100, Alexander Ivanov wrote:
> The VMM advertises the feature only for a backend with WRITE ZEROES
> support and sets max_write_zeroes_sectors from its limit, capped at
> 8388607 so that the range fits in one bio, and max_write_zeroes_seg
> to 1.

All v3 items are done and the code is fine.

A possible follow-up, not needed for this patch: answer
VIRTIO_BLK_S_UNSUPP instead of VIRTIO_BLK_S_IOERR when the backend has
no WRITE ZEROES (and for a bio that fails with BLK_STS_NOTSUPP). I
asked for IOERR in v3, but a Linux guest since 39722a2f2bcd8 ("block:
limit the Write Zeroes to manually writing zeroes fallback") writes
zeroes itself only on -EOPNOTSUPP, which UNSUPP maps to. With IOERR,
BLKZEROOUT in the guest fails with -EIO once a host disk drops its
limit (sd and dm can do that at runtime).

Thanks.

-- 
Konstantin Khorenko,
Virtuozzo Linux Kernel Team



More information about the Devel mailing list