From: no-reply@sashiko.virtuozzo.com
To: Alexander Ivanov <alexander.ivanov@virtuozzo.com>,
andrey.zhadchenko@virtuozzo.com
Cc: devel@openvz.org
Subject: Re: [Devel] [PATCH hci-8.2 2/2] drivers/vhost/blk: support VIRTIO_BLK_F_DISCARD
Date: Mon, 23 Nov 2026 08:45:50 +0000 [thread overview]
Message-ID: <010701a207953b9f-3e153367-d6dd-495b-a422-9b5c2e47e6eb-000000@eu-central-1.amazonses.com> (raw)
In-Reply-To: <20261123084014.176824-3-alexander.ivanov@virtuozzo.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] vhost-blk: discard of 4 GiB or more fails with IOERR, unlike
QEMU
--
commit 585dad915e7dad27e7f9cee3c2459ab7642245e2
Author: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
drivers/vhost/blk: support VIRTIO_BLK_F_DISCARD
This commit makes vhost-blk offer VIRTIO_BLK_F_DISCARD. A discard request is handled like write-zeroes: it takes a single segment, passes the same checks, and goes to the backend as one REQ_OP_DISCARD bio. A backend with no discard support, or an -EOPNOTSUPP from the bio, completes with VIRTIO_BLK_S_OK.
> diff --git a/drivers/vhost/blk.c b/drivers/vhost/blk.c
> index 816ce4cb77a2..811349b19500 100644
> --- a/drivers/vhost/blk.c
> +++ b/drivers/vhost/blk.c
[ ... ]
> @@ -478,13 +485,14 @@ static int vhost_blk_parse_write_zeroes(struct vhost_blk_req *req, u8 *status)
> - if (vhost_blk_backend_ro(f) || !max_sects ||
> - nr_sects > UINT_MAX >> SECTOR_SHIFT || nr_sects > max_sects ||
> + if (vhost_blk_backend_ro(f) ||
> + (!discard && (!max_sects || nr_sects > max_sects)) ||
> + nr_sects > UINT_MAX >> SECTOR_SHIFT ||
> (sector | nr_sects) & bs_mask ||
> sector > bdev_nr_sectors(bdev) ||
> nr_sects > bdev_nr_sectors(bdev) - sector) {
> *status = VIRTIO_BLK_S_IOERR;
[Severity: Low]
Can a valid discard of 4 GiB or more fail with VIRTIO_BLK_S_IOERR here? The commit message treats discard as a hint that is not checked against backend limits. For discard, though, the nr_sects > UINT_MAX >> SECTOR_SHIFT check still returns IOERR.
If the VMM leaves max_discard_sectors at 0, drivers/block/virtio_blk.c sets max_hw_discard_sectors to UINT_MAX. The guest can then merge discards well past this cap. With max_discard_seg = 1, the merged range goes out as a single segment. fstrim or blkdiscard on a large range would then report errors. QEMU does not fail these requests.
Should vhost_blk_bio_make() split a large discard across several bios? Alternatively, the commit message could tell the VMM to cap max_discard_sectors, as the write-zeroes commit did for its limit.
Carry the trailer below into the next revision and Sashiko will not review this patch again.
Reviewed-by: Sashiko <no-reply@sashiko.virtuozzo.com>
--
Sashiko AI review · https://sashiko.vzint.dev/#/patchset/20261123084014.176824-1-alexander.ivanov@virtuozzo.com?part=2
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
next prev parent reply other threads:[~2026-11-23 8:47 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 8:40 [Devel] [PATCH hci-8.2 0/2] " Alexander Ivanov
2026-11-23 8:40 ` [Devel] [PATCH hci-8.2 1/2] drivers/vhost/blk: drop ring features already in VHOST_FEATURES Alexander Ivanov
2026-11-23 8:43 ` no-reply
2026-11-23 8:40 ` [Devel] [PATCH hci-8.2 2/2] drivers/vhost/blk: support VIRTIO_BLK_F_DISCARD Alexander Ivanov
2026-11-23 8:45 ` no-reply [this message]
2026-11-23 8:57 ` Alexander Ivanov
2026-11-23 13:36 ` Andrey Zhadchenko
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=010701a207953b9f-3e153367-d6dd-495b-a422-9b5c2e47e6eb-000000@eu-central-1.amazonses.com \
--to=no-reply@sashiko.virtuozzo.com \
--cc=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