From: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
To: andrey.zhadchenko@virtuozzo.com
Cc: devel@openvz.org
Subject: [Devel] [PATCH hci-8.2 v3 2/4] drivers/vhost/blk: stop failing write zeroes above the backend limit
Date: Wed, 25 Nov 2026 12:57:01 +0100 [thread overview]
Message-ID: <20261125115703.741517-3-alexander.ivanov@virtuozzo.com> (raw)
In-Reply-To: <20261125115703.741517-1-alexander.ivanov@virtuozzo.com>
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@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
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
next prev parent reply other threads:[~2026-11-25 11:58 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 11:56 [Devel] [PATCH hci-8.2 v3 0/4] drivers/vhost/blk: fix write zeroes errors, support VIRTIO_BLK_F_DISCARD Alexander Ivanov
2026-11-25 11:57 ` [Devel] [PATCH hci-8.2 v3 1/4] drivers/vhost/blk: drop ring features already in VHOST_FEATURES Alexander Ivanov
2026-11-25 11:57 ` Alexander Ivanov [this message]
2026-11-25 12:32 ` [Devel] [PATCH hci-8.2 v3 2/4] drivers/vhost/blk: stop failing write zeroes above the backend limit Konstantin Khorenko
2026-11-25 11:57 ` [Devel] [PATCH hci-8.2 v3 3/4] drivers/vhost/blk: return UNSUPP for write zeroes on a backend without it Alexander Ivanov
2026-11-25 12:32 ` Konstantin Khorenko
2026-11-25 11:57 ` [Devel] [PATCH hci-8.2 v3 4/4] drivers/vhost/blk: support VIRTIO_BLK_F_DISCARD Alexander Ivanov
2026-11-25 12:32 ` Konstantin Khorenko
2026-11-25 12:32 ` [Devel] [PATCH hci-8.2 v3 0/4] drivers/vhost/blk: fix write zeroes errors, " Konstantin Khorenko
2026-11-25 14:07 ` Alexander Ivanov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261125115703.741517-3-alexander.ivanov@virtuozzo.com \
--to=alexander.ivanov@virtuozzo.com \
--cc=andrey.zhadchenko@virtuozzo.com \
--cc=devel@openvz.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox