]> git.baikalelectronics.ru Git - kernel.git/commit
virtio: Honour 'may_reduce_num' in vring_create_virtqueue
authorCornelia Huck <cohuck@redhat.com>
Mon, 8 Apr 2019 12:33:22 +0000 (14:33 +0200)
committerMichael S. Tsirkin <mst@redhat.com>
Mon, 8 Apr 2019 21:05:52 +0000 (17:05 -0400)
commite6d6430e50138fea9d2aa9fe7b5a93e28a0992dc
treec03b1e320df04d9d5025e0e2ddcf80d002950d24
parentbf6fa2b53487e7b361fe641176f14fa888a55eec
virtio: Honour 'may_reduce_num' in vring_create_virtqueue

vring_create_virtqueue() allows the caller to specify via the
may_reduce_num parameter whether the vring code is allowed to
allocate a smaller ring than specified.

However, the split ring allocation code tries to allocate a
smaller ring on allocation failure regardless of what the
caller specified. This may cause trouble for e.g. virtio-pci
in legacy mode, which does not support ring resizing. (The
packed ring code does not resize in any case.)

Let's fix this by bailing out immediately in the split ring code
if the requested size cannot be allocated and may_reduce_num has
not been specified.

While at it, fix a typo in the usage instructions.

Fixes: c060f798dd3e ("virtio: Add improved queue allocation API")
Cc: stable@vger.kernel.org # v4.6+
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Halil Pasic <pasic@linux.ibm.com>
Reviewed-by: Jens Freimann <jfreimann@redhat.com>
drivers/virtio/virtio_ring.c
include/linux/virtio_ring.h