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

no-reply at sashiko.virtuozzo.com no-reply at sashiko.virtuozzo.com
Mon Nov 2 14:38:35 MSK 2026


> QEMU virtio-blk advertises WRITE_ZEROES, so a guest switched to
> vhost-blk may issue such requests and gets VIRTIO_BLK_S_UNSUPP.
> 
> Handle VIRTIO_BLK_T_WRITE_ZEROES with __blkdev_issue_zeroout(), which
> splits the range by the device limit and falls back to writing zero
> pages when the backend has no WRITE ZEROES support. The UNMAP flag
> maps to the absence of BLKDEV_ZERO_NOUNMAP. Only a single segment per
> request is accepted, as in QEMU, so the device config must report
> max_write_zeroes_seg = 1. The segment is taken from the device-readable
> part of the chain, where the virtio spec places it.
> 
> Complete a range not aligned to the logical block size and a request
> to a read-only backend with VIRTIO_BLK_S_IOERR, as QEMU does. The
> backend is read-only as for VIRTIO_BLK_T_OUT: the fd lacks FMODE_WRITE
> or the bdev is read-only. BLKROSET or set_disk_ro() may switch the bdev
> [ ... ]
> the limit has become zero instead of reporting VIRTIO_BLK_S_IOERR.
> 
> https://virtuozzo.atlassian.net/browse/VSTOR-141684
> Feature: vhost-blk: in-kernel accelerator for virtio-blk guests
> Signed-off-by: Alexander Ivanov <alexander.ivanov at virtuozzo.com>

Sashiko has reviewed this patch and found no issues. It looks great!

-- 
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261102113051.4190522-1-alexander.ivanov@virtuozzo.com?part=1




More information about the Devel mailing list