virtio: fix full-virtqueue handling

Distinguish between "not enough descriptors available"
and "iovcnt > queue depth".

This patch brings back I/O re-queueing for virtio bdev
module. It was temporarily disabled by 451de7e1 [1].

[1] 451de7e1: "virtio: switch to the new virtqueue API"

Change-Id: I4c4f6a6d9d91373ee647ea7cafd53ad999aa6aa2
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
Signed-off-by: Dariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/393447
Tested-by: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Dariusz Stojaczyk 2018-01-03 12:16:04 +01:00 committed by Jim Harris
parent 48245f4bb8
commit 8b94174a4e
2 changed files with 5 additions and 4 deletions

View File

@ -209,9 +209,10 @@ uint16_t virtio_recv_pkts(struct virtqueue *vq, void **io, uint32_t *len, uint16
* is sent, processed and a response is received, the same object will be
* returned to the user calling the virtio poll API.
* \param iovcnt number of required iovectors for the request. This can be
* higher than than the actual number of descriptors to be added.
* \return 0 on success or negative errno otherwise. If not enough iovectors
* are available, -ENOSPC is returned.
* higher than than the actual number of iovectors to be added.
* \return 0 on success or negative errno otherwise. If the `iovcnt` is
* greater than virtqueue depth, -EINVAL is returned. If simply not enough
* iovectors are available, -ENOMEM is returned.
*/
int virtqueue_req_start(struct virtqueue *vq, void *cookie, int iovcnt);

View File

@ -448,7 +448,7 @@ virtqueue_req_start(struct virtqueue *vq, void *cookie, int iovcnt)
assert(virtio_dev_get_status(vq->vdev) & VIRTIO_CONFIG_S_DRIVER_OK);
if (iovcnt > vq->vq_free_cnt) {
return -ENOSPC;
return iovcnt > vq->vq_nentries ? -EINVAL : -ENOMEM;
}
if (vq->req_start != VQ_RING_DESC_CHAIN_END) {