diff mbox series

[RFC,v7,02/14] fixup! vhost: option to fetch descriptors through an independent struct

Message ID 20200610113515.1497099-3-mst@redhat.com (mailing list archive)
State New, archived
Headers show
Series vhost: ring format independence | expand

Commit Message

Michael S. Tsirkin June 10, 2020, 11:35 a.m. UTC
---
 drivers/vhost/vhost.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Eugenio Perez Martin June 10, 2020, 2 p.m. UTC | #1
On Wed, 2020-06-10 at 07:35 -0400, Michael S. Tsirkin wrote:
> ---
>  drivers/vhost/vhost.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
> index 180b7b58c76b..11433d709651 100644
> --- a/drivers/vhost/vhost.c
> +++ b/drivers/vhost/vhost.c
> @@ -2614,7 +2614,7 @@ int vhost_get_vq_desc_batch(struct vhost_virtqueue *vq,
>  err_fetch:
>  	vq->ndescs = 0;
>  
> -	return ret;
> +	return ret ? ret : vq->num;
>  }
>  EXPORT_SYMBOL_GPL(vhost_get_vq_desc_batch);
>  

I'm able to lock the vhost_get_vq_desc running virtio_test with no arguments against this patch. It does not happen if
it returns vq->num early, appended below.

Let me know if you prefer your conditional at the end of the function and I will investigate the cause.

Thanks!

diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index 28f324fd77df..4d198994e7be 100644
@@ -2350,7 +2345,9 @@ int vhost_get_vq_desc(struct vhost_virtqueue *vq,
 	int ret = fetch_descs(vq);
 	int i;
 
-	if (ret <= 0)
+	if (ret == 0)
+		return vq->num;
+	else if (ret < 0)
 		goto err;
 
 	/* Now convert to IOV */
diff mbox series

Patch

diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index 180b7b58c76b..11433d709651 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -2614,7 +2614,7 @@  int vhost_get_vq_desc_batch(struct vhost_virtqueue *vq,
 err_fetch:
 	vq->ndescs = 0;
 
-	return ret;
+	return ret ? ret : vq->num;
 }
 EXPORT_SYMBOL_GPL(vhost_get_vq_desc_batch);