Commit 4b34e048 authored by Ed Reed's avatar Ed Reed Committed by Jim Harris
Browse files

bdev/uring: handle async out of resource from uring



If there are sufficient resources to submit the I/O but resources
are exhausted during processing, the result in the completion queue
entry will be -EAGAIN. Complete the I/O in this case with NOMEM to
allow it to be retried.

This change also fixes the return value from bdev_uring_reap on
error return from io_uring_peek_cqe so it doesn't lose the count
of cqes already processed. The sole caller isn't expecting an error
return and the value only used to determine whether work was done
or not.

Change-Id: I49d83873dde895ec9056c13e91af616985fea97c
Signed-off-by: default avatarEd Reed <edreed@microsoft.com>
Reviewed-on: https://review.spdk.io/c/spdk/spdk/+/25453


Reviewed-by: default avatarJim Harris <jim.harris@nvidia.com>
Reviewed-by: default avatarChangpeng Liu <changpeliu@tencent.com>
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK Automated Test System <spdkbot@gmail.com>
parent b480cc2b
Loading
Loading
Loading
Loading
+10 −6
Original line number Diff line number Diff line
@@ -254,16 +254,20 @@ bdev_uring_reap(struct io_uring *ring, int max)
	for (i = 0; i < max; i++) {
		ret = io_uring_peek_cqe(ring, &cqe);
		if (ret != 0) {
			return ret;
		}

		if (cqe == NULL) {
			assert(ret == -EAGAIN || ret == -EWOULDBLOCK);
			return count;
		}

		assert(cqe != NULL);

		uring_task = (struct bdev_uring_task *)cqe->user_data;
		if (cqe->res != (signed)uring_task->len) {
		if (spdk_unlikely(cqe->res != (signed)uring_task->len)) {
			if (cqe->res == -EAGAIN || cqe->res == -EWOULDBLOCK) {
				status = SPDK_BDEV_IO_STATUS_NOMEM;
			} else {
				SPDK_ERRLOG("I/O failed with error %d\n", cqe->res);
				status = SPDK_BDEV_IO_STATUS_FAILED;
			}
		} else {
			status = SPDK_BDEV_IO_STATUS_SUCCESS;
		}