OpenVZ / Virtuozzo kernel development (devel@openvz.org)
 help / color / mirror / Atom feed
From: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
To: andrey.zhadchenko@virtuozzo.com
Cc: devel@openvz.org
Subject: [Devel] [PATCH hci-8.2 v4 0/4] drivers/vhost/blk: hold requests failed with ENOSPC until QEMU resubmits them
Date: Tue,  1 Dec 2026 13:49:27 +0100	[thread overview]
Message-ID: <20261201124931.1969095-1-alexander.ivanov@virtuozzo.com> (raw)

With report_enospc, dm-qcow2 and dm-ploop fail a request with ENOSPC
at once, and vhost-blk passes it to the guest as VIRTIO_BLK_S_IOERR.
The guest gets a write error, where QEMU with werror=enospc would
pause the VM until space is freed.

This series lets QEMU hold such requests in vhost-blk:
- VHOST_BLK_SET_ERROR_POLICY selects the requests to hold on ENOSPC:
  writes (with flushes, write zeroes and discards) and reads
- VHOST_BLK_SET_ERROR_FD sets the eventfd signalled when a request is
  held
- VHOST_BLK_GET_HELD_REQS returns the vq and head of each held request
- VHOST_BLK_RESUBMIT submits held requests again by vq and head, on
  resume or on the destination of a migration

A held request stays out of the used ring and is not counted as
inflight, so stopping vhost-blk to pause the VM does not wait for it.

QEMU uses them as follows:
- when it starts vhost-blk: VHOST_BLK_SET_ERROR_POLICY and
  VHOST_BLK_SET_ERROR_FD, before the backend is set
- on the eventfd: stops the VM and vhost-blk
- after every stop of vhost-blk, not only one caused by the eventfd:
  reads the list with VHOST_BLK_GET_HELD_REQS, as a request in flight
  can be held while the stop waits for it
- on the next start, or on the destination of a migration:
  VHOST_BLK_RESUBMIT with the saved vq and head pairs, after
  VHOST_BLK_SET_BACKEND, which empties the list

Patches 1-2 move the descriptor chain walk and the request parsing out
of the avail ring path, so that a head taken earlier can be parsed
again. Patch 3 holds the requests and reports them, patch 4 resubmits
them.

The series goes on top of "dm-qcow2, dm-ploop: report ENOSPC at once
for vhost-blk disks" v3, which lets the ENOSPC reach vhost-blk. The
other parts:
- QEMU: "[PATCH hci-8.2 v4 0/5] vhost-blk: support the werror/rerror
  policies"
- libvirt: https://bitbucket.org/openvz/libvirt.ovz/pull-requests/403
- ploop.ovz: https://bitbucket.org/openvz/ploop.ovz/pull-requests/530

v4:
- patch 3: keep the held list across a failing VHOST_BLK_SET_BACKEND,
  adding the requests held by the vqs it had started, so that the saved
  heads are not lost (item 2 of the v1 review, missed in v2 and v3)
- patch 4: return -EIO instead of -EFAULT for a fault on the guest
  memory of one entry, so that -EFAULT, which ends the call, means only
  a fault on the array of the caller
- cover letter: say that QEMU reads the list after every stop
- cover letter: name the QEMU series v4

v3:
- patch 3: copy the held list to userspace in VHOST_BLK_GET_HELD_REQS
  without held_mutex, so that a faulting user buffer does not stall
  the completion path
- patch 4: say in the uapi which VHOST_BLK_RESUBMIT errors fail the
  rest of the entries and which concern only the failed one
- rebase on top of rh10-6.12.0-211.75.1.26.6.vz10 and the dm-qcow2,
  dm-ploop series v3

v2:
- cover letter: say how QEMU uses the ioctls and name the QEMU,
  libvirt and ploop.ovz series
- patch 3: hold a request split into several bios only if none of
  them failed with an error other than ENOSPC
- patch 3: say that a guest reusing a held head after a backend
  restart gets it accepted
- patch 4: fail a head out of range with -EINVAL and a head in flight
  with -EBUSY before the descriptor chain is walked
- patch 4: on error, set nr to the index of the entry that failed
- rebase on top of the dm-qcow2, dm-ploop series v2 and the
  VIRTIO_BLK_F_DISCARD series v4
- patch 3: say that a discard is held as a write, as werror covers it
  in QEMU
- patch 4: say in the uapi that VHOST_BLK_RESUBMIT needs the backend
  set

https://virtuozzo.atlassian.net/browse/VSTOR-152175
Assisted-by: LLM

Alexander Ivanov (4):
  drivers/vhost: split the descriptor chain walk out of
    vhost_get_vq_desc()
  drivers/vhost/blk: split request parsing out of the guest kick handler
  drivers/vhost/blk: hold requests failed with ENOSPC
  drivers/vhost/blk: add the VHOST_BLK_RESUBMIT ioctl

 drivers/vhost/blk.c              | 313 ++++++++++++++++++++++++++++---
 drivers/vhost/vhost.c            |  91 +++++----
 drivers/vhost/vhost.h            |   4 +
 include/uapi/linux/vhost.h       |  39 ++++
 include/uapi/linux/vhost_types.h |  21 +++
 5 files changed, 405 insertions(+), 63 deletions(-)

-- 
2.53.0

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

             reply	other threads:[~2026-12-01 12:50 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 12:49 Alexander Ivanov [this message]
2026-12-01 12:49 ` [Devel] [PATCH hci-8.2 v4 1/4] drivers/vhost: split the descriptor chain walk out of vhost_get_vq_desc() Alexander Ivanov
2026-12-01 12:49 ` [Devel] [PATCH hci-8.2 v4 2/4] drivers/vhost/blk: split request parsing out of the guest kick handler Alexander Ivanov
2026-12-01 12:49 ` [Devel] [PATCH hci-8.2 v4 3/4] drivers/vhost/blk: hold requests failed with ENOSPC Alexander Ivanov
2026-12-01 12:49 ` [Devel] [PATCH hci-8.2 v4 4/4] drivers/vhost/blk: add the VHOST_BLK_RESUBMIT ioctl Alexander Ivanov
2026-12-01 12:57   ` no-reply
2026-12-01 15:32 ` [Devel] [PATCH hci-8.2 v4 0/4] drivers/vhost/blk: hold requests failed with ENOSPC until QEMU resubmits them Konstantin Khorenko
2026-12-01 15:32 ` Konstantin Khorenko

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=20261201124931.1969095-1-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