[Devel] [PATCH RHEL10 COMMIT] drivers/vhost/blk: improve request re-processing

Konstantin Khorenko khorenko at virtuozzo.com
Fri Jun 19 19:36:04 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 0854fe8b689b1808078382ba3929f990e4f2aa31
Author: Andrey Zhadchenko <andrey.zhadchenko at virtuozzo.com>
Date:   Fri Jun 19 16:33:09 2026 +0300

    drivers/vhost/blk: improve request re-processing
    
    Handle failed request processing with extra care:
     - If we got ENOMEM or EAGAIN, reverse vq head with
    vhost_discard_vq_desc() and re-queue this callback. ENOMEM isn't
    that critical, as we always allocate the memory with GFP_KERNEL
    so it can reclaim or sleep anyway. But with EAGAIN we should
    re-enter the function to properly check vq->backend.
     - On any other error, signal error and wait for next kick just
    like vhost-net or vhost-scsi. After all, we can't do anything with
    faulty guest request anyway.
    
    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 | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/drivers/vhost/blk.c b/drivers/vhost/blk.c
index 7e33a4f30165d..6a1a2bab3bed8 100644
--- a/drivers/vhost/blk.c
+++ b/drivers/vhost/blk.c
@@ -540,7 +540,6 @@ 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) {
 			vhostblk_vq_err(blk, vq, "virtio_blk_hdr (head %d) is too split!", head);
-			vhost_discard_vq_desc(vq, 1);
 			break;
 		}
 
@@ -549,12 +548,17 @@ static void vhost_blk_handle_guest_kick(struct vhost_work *work)
 		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));
-			vhost_discard_vq_desc(vq, 1);
 			break;
 		}
 
-		if (vhost_blk_req_handle(vq, &hdr, head, out + in) < 0) {
+		ret = vhost_blk_req_handle(vq, &hdr, 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;
 		}
 


More information about the Devel mailing list