]> www.infradead.org Git - users/hch/misc.git/commitdiff
io_uring: add helper of io_req_commit_cqe()
authorMing Lei <ming.lei@redhat.com>
Fri, 25 Oct 2024 12:22:40 +0000 (20:22 +0800)
committerJens Axboe <axboe@kernel.dk>
Thu, 7 Nov 2024 22:24:33 +0000 (15:24 -0700)
Add helper of io_req_commit_cqe() for simplifying
__io_submit_flush_completions() a bit.

No functional change, and the added helper will be reused in sqe group
code with same lock rule.

Signed-off-by: Ming Lei <ming.lei@redhat.com>
Link: https://lore.kernel.org/r/20241025122247.3709133-4-ming.lei@redhat.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/io_uring.c

index 3d19023e5d9d8c7c02a7cbbb5f418d6c459a3b9a..fbe1d68ba15a068fcb6792e0767c1648849cb759 100644 (file)
@@ -878,6 +878,20 @@ bool io_req_post_cqe(struct io_kiocb *req, s32 res, u32 cflags)
        return posted;
 }
 
+static __always_inline void io_req_commit_cqe(struct io_ring_ctx *ctx,
+               struct io_kiocb *req)
+{
+       if (unlikely(!io_fill_cqe_req(ctx, req))) {
+               if (ctx->lockless_cq) {
+                       spin_lock(&ctx->completion_lock);
+                       io_req_cqe_overflow(req);
+                       spin_unlock(&ctx->completion_lock);
+               } else {
+                       io_req_cqe_overflow(req);
+               }
+       }
+}
+
 static void io_req_complete_post(struct io_kiocb *req, unsigned issue_flags)
 {
        struct io_ring_ctx *ctx = req->ctx;
@@ -1416,16 +1430,8 @@ void __io_submit_flush_completions(struct io_ring_ctx *ctx)
                struct io_kiocb *req = container_of(node, struct io_kiocb,
                                            comp_list);
 
-               if (!(req->flags & REQ_F_CQE_SKIP) &&
-                   unlikely(!io_fill_cqe_req(ctx, req))) {
-                       if (ctx->lockless_cq) {
-                               spin_lock(&ctx->completion_lock);
-                               io_req_cqe_overflow(req);
-                               spin_unlock(&ctx->completion_lock);
-                       } else {
-                               io_req_cqe_overflow(req);
-                       }
-               }
+               if (!(req->flags & REQ_F_CQE_SKIP))
+                       io_req_commit_cqe(ctx, req);
        }
        __io_cq_unlock_post(ctx);