Skip to content

Commit 87148dd

Browse files
committed
liburing, man: make io_uring_sqring_wait() more consistent with API
Make io_uring_sqring_wait() return an amount of free SQ ring entries or -EINVAL if the ring was not setup with IORING_SETUP_SQPOLL, adjust manual page accordingly. Signed-off-by: Dmitry Antipov <[email protected]>
1 parent 5772879 commit 87148dd

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

man/io_uring_sqring_wait.3

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ This feature can only be used when the ring has been setup with
2626
and hence is using an offloaded approach to request submissions.
2727

2828
.SH RETURN VALUE
29-
On success it returns the free space. If the kernel does not support the
30-
feature, -EINVAL is returned.
29+
On success it returns an amount of free entries in the SQ ring. If the kernel
30+
does not support the feature, or the ring was not setup with
31+
.B IORING_SETUP_SQPOLL,
32+
-EINVAL is returned.
3133
.SH SEE ALSO
3234
.BR io_uring_submit (3),
3335
.BR io_uring_wait_cqe (3),

src/include/liburing.h

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,20 +1093,21 @@ static inline unsigned io_uring_sq_space_left(const struct io_uring *ring)
10931093
}
10941094

10951095
/*
1096-
* Only applicable when using SQPOLL - allows the caller to wait for space
1097-
* to free up in the SQ ring, which happens when the kernel side thread has
1098-
* consumed one or more entries. If the SQ ring is currently non-full, no
1099-
* action is taken. Note: may return -EINVAL if the kernel doesn't support
1096+
* Only applicable when using SQPOLL - allows the caller to wait for an at
1097+
* least one free entry in the SQ ring, which happens when the kernel side
1098+
* thread has consumed one or more entries. If the SQ ring is currently
1099+
* non-full, no waiting occured and an amout of free entries is returned
1100+
* immediately. Note: may also return -EINVAL if the kernel doesn't support
11001101
* this feature.
11011102
*/
11021103
static inline int io_uring_sqring_wait(struct io_uring *ring)
11031104
{
1104-
if (!(ring->flags & IORING_SETUP_SQPOLL))
1105-
return 0;
1106-
if (io_uring_sq_space_left(ring))
1107-
return 0;
1105+
int ret;
11081106

1109-
return __io_uring_sqring_wait(ring);
1107+
if (!(ring->flags & IORING_SETUP_SQPOLL))
1108+
return -EINVAL;
1109+
return (ret = io_uring_sq_space_left(ring))
1110+
? ret : __io_uring_sqring_wait(ring);
11101111
}
11111112

11121113
/*

0 commit comments

Comments
 (0)