Commit 7ae4b866f86f9ab7b99484b56dd303a860ad1cc9

Authored by Michael S. Tsirkin
Committed by Rusty Russell
1 parent dfd62d1d84

virtio: return correct capacity to users

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>

Showing 1 changed file with 0 additions and 3 deletions Side-by-side Diff

drivers/virtio/virtio_ring.c
... ... @@ -230,9 +230,6 @@
230 230 pr_debug("Added buffer head %i to %p\n", head, vq);
231 231 END_USE(vq);
232 232  
233   - /* If we're indirect, we can fit many (assuming not OOM). */
234   - if (vq->indirect)
235   - return vq->num_free ? vq->vring.num : 0;
236 233 return vq->num_free;
237 234 }
238 235 EXPORT_SYMBOL_GPL(virtqueue_add_buf_gfp);