[Devel] [PATCH VZ10 3/7] drivers/vhost/blk: improve request re-processing

Konstantin Khorenko khorenko at virtuozzo.com
Fri Jun 19 15:15:20 MSK 2026


On 6/15/26 16:55, Andrey Zhadchenko wrote:
> Handle failed request processing with extra care:
>  - If we got ENOMEM or EAGAIN, reverse vq head with
> vhost_discard_vq_desc() and try again
>  - 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>
> ---
>  drivers/vhost/blk.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/vhost/blk.c b/drivers/vhost/blk.c
> index 7e33a4f30165d..ef0f6f77bfada 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;
>  		}
>  

There is another place in this function which looks very similar

                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));
                        vhost_discard_vq_desc(vq, 1);
                        break;
                }

but here you still call vhost_discard_vq_desc() - why?

> @@ -553,8 +552,13 @@ static void vhost_blk_handle_guest_kick(struct vhost_work *work)
>  			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);
> +			continue;
> +		} 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