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.1] drivers/vhost/blk: support VIRTIO_BLK_F_WRITE_ZEROES
Date: Thu, 12 Nov 2026 14:48:36 +0100	[thread overview]
Message-ID: <179449131676.4060562.10013879144026497589.b4-review@b4> (raw)
In-Reply-To: <20261102113051.4190522-1-alexander.ivanov@virtuozzo.com>

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

On Mon, 02 Nov 2026 12:30:51 +0100, Alexander Ivanov <alexander.ivanov@virtuozzo.com> wrote:
> QEMU virtio-blk advertises WRITE_ZEROES, so a guest switched to
> vhost-blk may issue such requests and gets VIRTIO_BLK_S_UNSUPP.

- Reword this paragraph: no guest of our vhost-blk device can get
  WRITE_ZEROES today, and a QEMU change has to follow this patch.
- Say in the message what the VMM must advertise: the backend logical
  block size, max_write_zeroes_sectors aligned to it, and
  max_write_zeroes_seg = 1. Drop "as QEMU does" for the alignment
  check.
- Use a much smaller chunk when the range is written with zero pages.
- Make the commit message much shorter: what the patch does, what the
  VMM must advertise and the errors the guest gets, in a few lines.
  Move the rest to the cover text: the comparisons with QEMU, the
  BLKROSET race, why a submit error would hang the guest, the wait in
  vhost_blk_flush(), the WRITE SAME retry. For a single patch b4 puts
  the cover text below the "---" line, so it stays in the mail and
  the list archive but not in git.

The scenario cannot happen with our QEMU. The "write-zeroes" property
of vhost-blk is off by default ("not yet implemented in kernel
module"). Even when it is on, vhost_get_features() clears the bit,
because the kernel did not report it. A guest moved from virtio-blk
to vhost-blk renegotiates features on the new device. The real reason
is parity with virtio-blk.

> 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

bs_mask comes from the backend, but our QEMU always tells the guest
blk_size 512 and leaves max_write_zeroes_sectors at 0. A Linux guest
reads 0 as no limit and splits a large zeroout at 8388607 sectors. On a
4Kn backend, e.g. dm-qcow2 on a 4K disk, such a request is not aligned
and gets IOERR. The guest does not fall back to zero pages, so
blkdiscard -z or BLKZEROOUT of 4 GiB or more fails with -EIO, where
before the patch the guest wrote the zeroes itself. QEMU checks
alignment against the block size it advertised, so it never hits this.

> +#define VHOST_BLK_MAX_WRITE_ZEROES_SECTORS	(SZ_1G >> SECTOR_SHIFT)

dm-ploop, dm-qcow2 and most SATA disks have no WRITE ZEROES, so on them
every chunk goes through the zero-page fallback: about a thousand 1 MiB
bios, all submitted from the vhost worker with vq->mutex held. On a disk
with a shallow queue submit_bio() sleeps on tags until most of that GiB
is written, and with the default single worker the completions of all
queues of the device wait behind it. A Linux guest never sends a data
request that large, and a guest zeroing on its own sends 1 MiB requests
that do not block the worker. 1 GiB is fine for real WRITE ZEROES bios;
for the zero-page case a chunk of a few MiB keeps the worker responsive.

-- 
Konstantin Khorenko,
Virtuozzo Linux Kernel Team

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

      parent reply	other threads:[~2026-11-12 13:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-02 11:30 Alexander Ivanov
2026-11-02 11:38 ` no-reply
2026-11-12 13:48 ` Konstantin Khorenko [this message]

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=179449131676.4060562.10013879144026497589.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