]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
virtio: return correct capacity to users
authorMichael S. Tsirkin <mst@redhat.com>
Thu, 4 Nov 2010 12:24:24 +0000 (14:24 +0200)
committerRusty Russell <rusty@rustcorp.com.au>
Wed, 24 Nov 2010 04:51:11 +0000 (15:21 +1030)
We can't rely on indirect buffers for capacity
calculations because they need a memory allocation
which might fail.  In particular, virtio_net can get
into this situation under stress, and it drops packets
and performs badly.

So return the number of buffers we can guarantee users.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Reported-By: Krishna Kumar2 <krkumar2@in.ibm.com>
drivers/virtio/virtio_ring.c

index 1475ed6b575fd7a9984380b9e0841ac5f019a306..cc2f73e03475b620053765b373c8b1a39fc08762 100644 (file)
@@ -230,9 +230,6 @@ add_head:
        pr_debug("Added buffer head %i to %p\n", head, vq);
        END_USE(vq);
 
-       /* If we're indirect, we can fit many (assuming not OOM). */
-       if (vq->indirect)
-               return vq->num_free ? vq->vring.num : 0;
        return vq->num_free;
 }
 EXPORT_SYMBOL_GPL(virtqueue_add_buf_gfp);