io_uring_load_sq_head() shouldn't need a IORING_SETUP_SQ_REWIND check as the SQ head should already be zero. Also, add a couple of words about the tail resetting logic. Signed-off-by: Pavel Begunkov --- src/include/liburing.h | 3 --- src/queue.c | 7 +++++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/include/liburing.h b/src/include/liburing.h index b41958ce..8d45d400 100644 --- a/src/include/liburing.h +++ b/src/include/liburing.h @@ -1684,9 +1684,6 @@ IOURINGINLINE void io_uring_prep_pipe_direct(struct io_uring_sqe *sqe, int *fds, IOURINGINLINE unsigned io_uring_load_sq_head(const struct io_uring *ring) LIBURING_NOEXCEPT { - if (ring->flags & IORING_SETUP_SQ_REWIND) - return 0; - /* * Without acquire ordering, we could overwrite a SQE before the kernel * finished reading it. We don't need the acquire ordering for diff --git a/src/queue.c b/src/queue.c index 00995ace..87b4dbbe 100644 --- a/src/queue.c +++ b/src/queue.c @@ -205,6 +205,13 @@ static unsigned __io_uring_flush_sq(struct io_uring *ring) struct io_uring_sq *sq = &ring->sq; unsigned tail = sq->sqe_tail; + /* + * With IORING_SETUP_SQ_REWIND, the kernel ignores the SQ head / tail + * and submits entries from the beginning of the queue. Continue using + * the indices as before but reset the tail on submission. With the + * head kept to be zero, io_uring_get_sqe() / etc. will work without + * any extra changes. + */ if (ring->flags & IORING_SETUP_SQ_REWIND) { sq->sqe_tail = 0; return tail; -- 2.52.0