[PATCH 4/9] io_uring: add one output argument to io_submit_sqe

Ming Lei
2024-04-08T01:04:13Z

Add one output argument to io_submit_sqe() for returning how many SQEs
handled in this function.

Prepare for supporting SQE group, which can include multiple member SQEs
to handle in io_submit_sqe().

No functional change.

Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
io_uring/io_uring.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c
index c73819c04c0b..4969d21ea2f8 100644
--- a/io_uring/io_uring.c
+++ b/io_uring/io_uring.c
@@ -2204,12 +2204,13 @@ static __cold int io_submit_fail_init(const struct io_uring_sqe *sqe,
}

static inline int io_submit_sqe(struct io_ring_ctx *ctx, struct io_kiocb *req,
- const struct io_uring_sqe *sqe)
+ const struct io_uring_sqe *sqe, unsigned int *nr)
__must_hold(&ctx->uring_lock)
{
struct io_submit_link *link = &ctx->submit_state.link;
int ret;

+ *nr = 1;
ret = io_init_req(ctx, req, sqe);
if (unlikely(ret))
return io_submit_fail_init(sqe, req, ret);
@@ -2351,6 +2352,7 @@ int io_submit_sqes(struct io_ring_ctx *ctx, unsigned int nr)
do {
const struct io_uring_sqe *sqe;
struct io_kiocb *req;
+ unsigned int done;

if (unlikely(!io_alloc_req(ctx, &req)))
break;
@@ -2363,12 +2365,13 @@ int io_submit_sqes(struct io_ring_ctx *ctx, unsigned int nr)
* Continue submitting even for sqe failure if the
* ring was setup with IORING_SETUP_SUBMIT_ALL
*/
- if (unlikely(io_submit_sqe(ctx, req, sqe)) &&
+ if (unlikely(io_submit_sqe(ctx, req, sqe, &done)) &&
!(ctx->flags & IORING_SETUP_SUBMIT_ALL)) {
- left--;
+ left -= done;
break;
}
- } while (--left);
+ left -= done;
+ } while (left);

if (unlikely(left)) {
ret -= left;
--
2.42.0