[Devel] [PATCH RHEL10 COMMIT] drivers/vhost/blk: better log errors in vhost-blk

Konstantin Khorenko khorenko at virtuozzo.com
Fri Jun 19 19:36:03 MSK 2026


The commit is pushed to "branch-rh10-6.12.0-211.16.1.12.x.vz10-ovz" and will appear at git at bitbucket.org:openvz/vzkernel.git
after rh10-6.12.0-211.16.1.12.4.vz10
------>
commit fd40c3bc7531eddad70af968c6c356df7804e0b9
Author: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>
Date:   Fri Jun 19 16:33:08 2026 +0300

    drivers/vhost/blk: better log errors in vhost-blk
    
    pr_debug() is too specific. Let's use pr_warn_ratelimited() so we
    get better exposure
    
    https://virtuozzo.atlassian.net/browse/VSTOR-134034
    Signed-off-by: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>
    
    ======
    Patchset description:
    vhost-blk: handling of failing requests
    
    This series mainly addresses the handling of failing requests.
    Previously the driver will always retry all requests failed at
    processing and will always complete the requests if they are
    past bio submission point.
    
    Using vhost-net and vhost-scsi as a model, we adopt the following
    approach:
     - requests failed at processing phase with ENOMEM/EAGAIN are re-tried
     - requests failed at processing phase with other errors are not
    reported completed and are not processed further. It is higly likely
    they are just incorrect
     - requests failed at status write after the completion are not
    reported completed
    
    This may sometime lead to guests stalling, but the alternatives are
    always worse.
    
    Also the patchset improves logging and adds a few sanity checks.
    
    Feature: vhost-blk: in-kernel accelerator for virtio-blk guests
    Reviewed-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
 drivers/vhost/blk.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/drivers/vhost/blk.c b/drivers/vhost/blk.c
index e4236df2f2161..7e33a4f30165d 100644
--- a/drivers/vhost/blk.c
+++ b/drivers/vhost/blk.c
@@ -51,6 +51,14 @@ enum {
 
 #define NR_INLINE 16
 
+#define vhostblk_vq_err(blk, vq, fmt, ...) do {				\
+		pr_warn_ratelimited(KBUILD_MODNAME "(%d) : " fmt,	\
+				    blk->owner_pid, ##__VA_ARGS__);	\
+		if ((vq)->error_ctx)					\
+			eventfd_signal((vq)->error_ctx);		\
+	} while (0)
+
+
 struct vhost_blk_req {
 	struct bio *inline_bio[NR_INLINE];
 	int req_bin;
@@ -94,6 +102,7 @@ struct vhost_blk {
 	int new_req_bin;
 	struct file *backend;
 	char serial[VIRTIO_BLK_ID_BYTES];
+	pid_t owner_pid;
 };
 
 static int gen;
@@ -133,7 +142,7 @@ static inline int vhost_blk_set_status(struct vhost_blk_req *req, u8 status)
 	iov_iter_init(&iter, ITER_DEST, req->status, ARRAY_SIZE(req->status), sizeof(status));
 	ret = copy_to_iter(&status, sizeof(status), &iter);
 	if (ret != sizeof(status)) {
-		vq_err(&req->blk_vq->vq, "Failed to write status\n");
+		vhostblk_vq_err(req->blk, &req->blk_vq->vq, "Failed to write status\n");
 		return -EFAULT;
 	}
 
@@ -481,7 +490,7 @@ static int vhost_blk_req_handle(struct vhost_virtqueue *vq,
 		vhost_add_used_and_signal(&blk->dev, vq, head, len);
 		break;
 	default:
-		vq_err(vq, "Unsupported request type %d\n", hdr->type);
+		vhostblk_vq_err(blk, vq, "Unsupported request type %d\n", hdr->type);
 		status = VIRTIO_BLK_S_UNSUPP;
 		ret = vhost_blk_set_status(req, status);
 		if (ret)
@@ -530,7 +539,7 @@ static void vhost_blk_handle_guest_kick(struct vhost_work *work)
 
 		ret = move_iovec(vq->iov, hdr_iovec, sizeof(hdr), in + out, ARRAY_SIZE(hdr_iovec));
 		if (ret < 0) {
-			vq_err(vq, "virtio_blk_hdr is too split!");
+			vhostblk_vq_err(blk, vq, "virtio_blk_hdr (head %d) is too split!", head);
 			vhost_discard_vq_desc(vq, 1);
 			break;
 		}
@@ -538,8 +547,8 @@ static void vhost_blk_handle_guest_kick(struct vhost_work *work)
 		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)) {
-			vq_err(vq, "Failed to get block header: read %d bytes instead of %ld!\n",
-			       ret, sizeof(hdr));
+			vhostblk_vq_err(blk, vq, "Failed to get read header (head %d): got %d, expected %ld!\n",
+					head, ret, sizeof(hdr));
 			vhost_discard_vq_desc(vq, 1);
 			break;
 		}
@@ -671,6 +680,7 @@ static int vhost_blk_open(struct inode *inode, struct file *file)
 	blk->new_req_bin = 0;
 	spin_lock_init(&blk->flush_lock);
 	init_waitqueue_head(&blk->flush_wait);
+	blk->owner_pid = current->pid;
 
 	vhost_dev_init(&blk->dev, vqs, VHOST_BLK_VQ_MAX, UIO_MAXIOV,
 		       VHOST_DEV_WEIGHT, VHOST_DEV_PKT_WEIGHT, true, NULL);


More information about the Devel mailing list