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: split request parsing out of the guest kick handler
Date: Tue, 1 Dec 2026 09:50:18 +0100 [thread overview]
Message-ID: <20261201085020.1884923-3-alexander.ivanov@virtuozzo.com> (raw)
In-Reply-To: <20261201085020.1884923-1-alexander.ivanov@virtuozzo.com>
A request resubmitted by QEMU is to go through the same header checks
and vhost_blk_req_handle() as one taken from the avail ring. Move them
into vhost_blk_handle_desc().
https://virtuozzo.atlassian.net/browse/VSTOR-152175
Feature: vhost-blk: in-kernel accelerator for virtio-blk guests
Signed-off-by: Alexander Ivanov <alexander.ivanov@virtuozzo.com>
Reviewed-by: Sashiko <no-reply@sashiko.virtuozzo.com>
---
drivers/vhost/blk.c | 61 ++++++++++++++++++++++++++-------------------
1 file changed, 36 insertions(+), 25 deletions(-)
diff --git a/drivers/vhost/blk.c b/drivers/vhost/blk.c
index bfd4bde0bcff..d8ea714f71ae 100644
--- a/drivers/vhost/blk.c
+++ b/drivers/vhost/blk.c
@@ -682,14 +682,46 @@ static int vhost_blk_req_handle(struct vhost_virtqueue *vq,
return ret;
}
-static void vhost_blk_handle_guest_kick(struct vhost_work *work)
+static int vhost_blk_handle_desc(struct vhost_virtqueue *vq, u16 head,
+ unsigned int out, unsigned int in)
{
+ struct vhost_blk *blk = container_of(vq->dev, struct vhost_blk, dev);
+ struct iovec hdr_iovec[VHOST_MAX_METADATA_IOV];
struct virtio_blk_outhdr hdr;
+ struct iov_iter iter;
+ int ret;
+
+ if (iov_length(vq->iov, out) < sizeof(hdr)) {
+ vhostblk_vq_err(blk, vq, "virtio_blk_hdr (head %d) is missing!", head);
+ return -EINVAL;
+ }
+
+ ret = move_iovec(vq->iov, hdr_iovec, sizeof(hdr), out, ARRAY_SIZE(hdr_iovec));
+ if (ret < 0) {
+ vhostblk_vq_err(blk, vq, "virtio_blk_hdr (head %d) is too split!", head);
+ return -EINVAL;
+ }
+
+ iov_iter_init(&iter, ITER_SOURCE, hdr_iovec, ARRAY_SIZE(hdr_iovec), sizeof(hdr));
+ ret = copy_from_iter(&hdr, sizeof(hdr), &iter);
+ if (ret != sizeof(hdr)) {
+ vhostblk_vq_err(blk, vq, "Failed to get read header (head %d): got %d, expected %ld!\n",
+ head, ret, sizeof(hdr));
+ return -EFAULT;
+ }
+
+ ret = vhost_blk_req_handle(vq, &hdr, head, out, in);
+ if (ret < 0 && ret != -EAGAIN && ret != -ENOMEM)
+ vhostblk_vq_err(blk, vq, "Failed to process guest request (head %d) with %d",
+ head, ret);
+ return ret;
+}
+
+static void vhost_blk_handle_guest_kick(struct vhost_work *work)
+{
struct vhost_blk_vq *blk_vq;
struct vhost_virtqueue *vq;
- struct iovec hdr_iovec[VHOST_MAX_METADATA_IOV];
struct vhost_blk *blk;
- struct iov_iter iter;
int in, out, ret;
struct file *f;
int head;
@@ -720,33 +752,12 @@ static void vhost_blk_handle_guest_kick(struct vhost_work *work)
break;
}
- if (iov_length(vq->iov, out) < sizeof(hdr)) {
- vhostblk_vq_err(blk, vq, "virtio_blk_hdr (head %d) is missing!", head);
- break;
- }
-
- ret = move_iovec(vq->iov, hdr_iovec, sizeof(hdr), out, ARRAY_SIZE(hdr_iovec));
- if (ret < 0) {
- vhostblk_vq_err(blk, vq, "virtio_blk_hdr (head %d) is too split!", head);
- break;
- }
-
- iov_iter_init(&iter, ITER_SOURCE, hdr_iovec, ARRAY_SIZE(hdr_iovec), sizeof(hdr));
- ret = copy_from_iter(&hdr, sizeof(hdr), &iter);
- if (ret != sizeof(hdr)) {
- vhostblk_vq_err(blk, vq, "Failed to get read header (head %d): got %d, expected %ld!\n",
- head, ret, sizeof(hdr));
- break;
- }
-
- ret = vhost_blk_req_handle(vq, &hdr, head, out, in);
+ ret = vhost_blk_handle_desc(vq, head, out, in);
if (ret == -EAGAIN || ret == -ENOMEM) {
vhost_discard_vq_desc(vq, 1);
vhost_poll_queue(&vq->poll);
break;
} else if (ret < 0) {
- vhostblk_vq_err(blk, vq, "Failed to process guest request (head %d) with %d",
- head, ret);
break;
}
--
2.53.0
_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel
next prev parent reply other threads:[~2026-12-01 8:52 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 8:50 [Devel] [PATCH hci-8.2 v3 0/4] drivers/vhost/blk: hold requests failed with ENOSPC until QEMU resubmits them Alexander Ivanov
2026-12-01 8:50 ` [Devel] [PATCH hci-8.2 v3 1/4] drivers/vhost: split the descriptor chain walk out of vhost_get_vq_desc() Alexander Ivanov
2026-12-01 8:50 ` Alexander Ivanov [this message]
2026-12-01 8:50 ` [Devel] [PATCH hci-8.2 v3 3/4] drivers/vhost/blk: hold requests failed with ENOSPC Alexander Ivanov
2026-12-01 8:56 ` no-reply
2026-12-01 9:19 ` Konstantin Khorenko
2026-12-01 11:25 ` Alexander Ivanov
2026-12-01 8:50 ` [Devel] [PATCH hci-8.2 v3 4/4] drivers/vhost/blk: add the VHOST_BLK_RESUBMIT ioctl Alexander Ivanov
2026-12-01 9:01 ` no-reply
2026-12-01 11:14 ` Alexander Ivanov
2026-12-01 9:19 ` Konstantin Khorenko
2026-12-01 11:16 ` Alexander Ivanov
2026-12-01 9:19 ` [Devel] [PATCH hci-8.2 v3 0/4] drivers/vhost/blk: hold requests failed with ENOSPC until QEMU resubmits them 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=20261201085020.1884923-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