[Devel] [PATCH hci-8.2 v3 2/4] drivers/vhost/blk: stop failing write zeroes above the backend limit
Alexander Ivanov
alexander.ivanov at virtuozzo.com
Wed Nov 25 14:57:01 MSK 2026
vhost_blk_parse_write_zeroes() answers VIRTIO_BLK_S_IOERR to a range
above the WRITE ZEROES limit of the backend. The guest does not know
that limit: it sees UINT_MAX when the VMM leaves
max_write_zeroes_sectors 0, and a dm table reload can lower the limit of
the backend below the one the VMM sampled.
Every request above the limit of the backend then fails, while the block
layer splits a WRITE ZEROES bio by that limit anyway.
Drop the check. The VMM then need not set max_write_zeroes_sectors from
the limit of the backend.
Fixes: 3b2e28a4f6b7 ("drivers/vhost/blk: support VIRTIO_BLK_F_WRITE_ZEROES")
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>
---
drivers/vhost/blk.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/vhost/blk.c b/drivers/vhost/blk.c
index 816ce4cb77a2..86b526c3f571 100644
--- a/drivers/vhost/blk.c
+++ b/drivers/vhost/blk.c
@@ -462,7 +462,6 @@ static int vhost_blk_parse_write_zeroes(struct vhost_blk_req *req, u8 *status)
struct file *f = vhost_vq_get_backend(&req->blk_vq->vq);
struct block_device *bdev = I_BDEV(f->f_mapping->host);
sector_t bs_mask = (bdev_logical_block_size(bdev) >> SECTOR_SHIFT) - 1;
- unsigned int max_sects = bdev_write_zeroes_sectors(bdev);
struct virtio_blk_discard_write_zeroes seg;
struct iov_iter iter;
u32 flags, nr_sects;
@@ -483,8 +482,8 @@ static int vhost_blk_parse_write_zeroes(struct vhost_blk_req *req, u8 *status)
sector = le64_to_cpu(seg.sector);
nr_sects = le32_to_cpu(seg.num_sectors);
- if (vhost_blk_backend_ro(f) || !max_sects ||
- nr_sects > UINT_MAX >> SECTOR_SHIFT || nr_sects > max_sects ||
+ if (vhost_blk_backend_ro(f) ||
+ nr_sects > UINT_MAX >> SECTOR_SHIFT ||
(sector | nr_sects) & bs_mask ||
sector > bdev_nr_sectors(bdev) ||
nr_sects > bdev_nr_sectors(bdev) - sector) {
--
2.53.0
More information about the Devel
mailing list