[Devel] [PATCH RHEL7 COMMIT] ms/scsi: virtio: Reduce BUG if total_sg > virtqueue size to WARN.

Konstantin Khorenko khorenko at virtuozzo.com
Wed Dec 20 11:32:33 MSK 2017


The commit is pushed to "branch-rh7-3.10.0-693.11.1.vz7.39.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-693.11.1.vz7.39.7
------>
commit ae3eaef2b71b98e77123572f69c170ec6bf2c646
Author: Richard W.M. Jones <rjones at redhat.com>
Date:   Wed Dec 20 11:32:33 2017 +0300

    ms/scsi: virtio: Reduce BUG if total_sg > virtqueue size to WARN.
    
    If using indirect descriptors, you can make the total_sg as large as you
    want.  If not, BUG is too serious because the function later returns
    -ENOSPC.
    
    Signed-off-by: Richard W.M. Jones <rjones at redhat.com>
    Reviewed-by: Paolo Bonzini <pbonzini at redhat.com>
    Signed-off-by: Martin K. Petersen <martin.petersen at oracle.com>
    
    (cherry picked from commit 44ed8089e991a60d614abe0ee4b9057a28b364e4)
    Signed-off-by: Roman Kagan <rkagan at virtuozzo.com>
    VZ-Bug: PSBM-79523
    https://jira.sw.ru/browse/PSBM-78839
    
    Signed-off-by: Roman Kagan <rkagan at virtuozzo.com>
---
 drivers/virtio/virtio_ring.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
index d77a91f39d55..5903139aede2 100644
--- a/drivers/virtio/virtio_ring.c
+++ b/drivers/virtio/virtio_ring.c
@@ -275,7 +275,6 @@ static inline int virtqueue_add(struct virtqueue *_vq,
 	}
 #endif
 
-	BUG_ON(total_sg > vq->vring.num);
 	BUG_ON(total_sg == 0);
 
 	head = vq->free_head;
@@ -284,8 +283,10 @@ static inline int virtqueue_add(struct virtqueue *_vq,
 	 * buffers, then go indirect. FIXME: tune this threshold */
 	if (vq->indirect && total_sg > 1 && vq->vq.num_free)
 		desc = alloc_indirect(_vq, total_sg, gfp);
-	else
+	else {
 		desc = NULL;
+		WARN_ON_ONCE(total_sg > vq->vring.num && !vq->indirect);
+	}
 
 	if (desc) {
 		/* Use a single buffer which doesn't continue */


More information about the Devel mailing list