Skip to contentSkip to conversation

io_uring: pass ctx instead of req to io_init_req_drain()

PATCH Applied Caleb Sander Mateos 2 participants 2 messages Feb 12, 2025 io_uring

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 io_uring: pass ctx instead of req to io_init_req_drain()

io_init_req_drain() takes a struct io_kiocb *req argument but only uses it to get struct io_ring_ctx *ctx. The caller already knows the ctx, so pass it instead.

Drop "req" from the function name since it operates on the ctx rather than a specific req.

---
 io_uring/io_uring.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
io_uring/io_uring.c +2 -3
index 8bb8c099c3e1..4a0944a57d96 100644
@@ -1995,13 +1995,12 @@ static inline bool io_check_restriction(struct io_ring_ctx *ctx,
 		return false;
 
 	return true;
 }
 
-static void io_init_req_drain(struct io_kiocb *req)
+static void io_init_drain(struct io_ring_ctx *ctx)
 {
-	struct io_ring_ctx *ctx = req->ctx;
 	struct io_kiocb *head = ctx->submit_state.link.head;
 
 	ctx->drain_active = true;
 	if (head) {
 		/*
@@ -2059,11 +2058,11 @@ static int io_init_req(struct io_ring_ctx *ctx, struct io_kiocb *req,
 		if (sqe_flags & IOSQE_CQE_SKIP_SUCCESS)
 			ctx->drain_disabled = true;
 		if (sqe_flags & IOSQE_IO_DRAIN) {
 			if (ctx->drain_disabled)
 				return io_init_fail_req(req, -EOPNOTSUPP);
-			io_init_req_drain(req);
+			io_init_drain(ctx);
 		}
 	}
 	if (unlikely(ctx->restricted || ctx->drain_active || ctx->drain_next)) {
 		if (ctx->restricted && !io_check_restriction(ctx, req, sqe_flags))
 			return io_init_fail_req(req, -EACCES);
Signature · 1 line
2.45.2
maintainer Applied
#1 lore raw
Quoted 8 lines · Caleb Sander Mateos

io_init_req_drain() takes a struct io_kiocb *req argument but only uses it to get struct io_ring_ctx *ctx. The caller already knows the ctx, so pass it instead.

Drop "req" from the function name since it operates on the ctx rather than a specific req.

[...]

Applied, thanks!

[1/1] io_uring: pass ctx instead of req to io_init_req_drain()

      commit: 5fa0beffc75910a694a90ed0425bb13674b10256

Best regards,

Signature · 1 line
Jens Axboe