OpenVZ / Virtuozzo kernel development (devel@openvz.org)
 help / color / mirror / Atom feed
From: Konstantin Khorenko <khorenko@virtuozzo.com>
To: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
Cc: devel@openvz.org
Subject: Re: [Devel] [PATCH hci-8.2 v3 4/4] drivers/vhost/blk: support VIRTIO_BLK_F_DISCARD
Date: Wed, 25 Nov 2026 13:32:09 +0100	[thread overview]
Message-ID: <179560992945.33784.13470699889344933010.b4-review@b4> (raw)
In-Reply-To: <20261125115703.741517-5-alexander.ivanov@virtuozzo.com>

I won't apply this version, please send v4 with the changes below.

- One form of the op test: item 3.
- Pass the backend to vhost_blk_parse_segment() once: item 4.
- Message fixes: item 5 of the cover letter reply.

On Wed, 25 Nov 2026 12:57:03 +0100, Alexander Ivanov wrote:
> +	if (err && op_is_discard(req->bi_opf) &&
> +	    (err == -EOPNOTSUPP || !bdev_max_discard_sectors(bdev)))
> +		err = 0;
>  	if (err && (req->bi_opf & REQ_OP_MASK) == REQ_OP_WRITE_ZEROES &&

Item 3: two forms of the same test side by side, here and in
vhost_blk_bio_make(). v1 asked for one; use
(req->bi_opf & REQ_OP_MASK) == REQ_OP_DISCARD next to the
WRITE_ZEROES test.

> +static int vhost_blk_parse_segment(struct vhost_blk_req *req,
> +				   struct block_device *bdev,

Item 4: the function still looks up f itself, and both callers take f
and bdev only to pass bdev down. Get bdev from f here and drop the
parameter and the callers' locals.

> A discard is a hint, and the guest takes the limits from the VMM, not
> from the backend. So the range is not checked against the backend
> discard limit: the bio gets split by it. As QEMU does, complete the

Item 5: the block layer splitting the bio is why the limit is not
checked; the hint is why the request completes with VIRTIO_BLK_S_OK
without a backend discard. Keep the two reasons apart.

> max_discard_sectors at 8388607 so that the range fits in one bio. QEMU

Item 5: 8388607 is not a multiple of 8, so on a 4K backend a range of
exactly that size fails the alignment check with IOERR: say "rounded
down to the logical block size". Also say that the VMM must not offer
VIRTIO_BLK_F_DISCARD for a drive whose discards are to be ignored
(QEMU discard=ignore): vhost-blk sends every discard to the backend.

-- 
Konstantin Khorenko,
Virtuozzo Linux Kernel Team

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

  reply	other threads:[~2026-11-25 12:33 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, " 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 ` [Devel] [PATCH hci-8.2 v3 2/4] drivers/vhost/blk: stop failing write zeroes above the backend limit Alexander Ivanov
2026-11-25 12:32   ` 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 [this message]
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=179560992945.33784.13470699889344933010.b4-review@b4 \
    --to=khorenko@virtuozzo.com \
    --cc=alexander.ivanov@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