io_uring: add io_add_aux_cqe32() helper
authorJens Axboe <axboe@kernel.dk>
Thu, 24 Jul 2025 21:03:27 +0000 (15:03 -0600)
committerJens Axboe <axboe@kernel.dk>
Sat, 9 Aug 2025 14:38:27 +0000 (08:38 -0600)
Add a helper like io_add_aux_cqe(), except it supports posting CQE32
CQEs. It returns true if the CQE was posted to the target ring, false
otherwise. Use case is otherwise the same, it can be used within
task_work like context where completions are posted when they have all
been posted.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/io_uring.c
io_uring/io_uring.h

index 4569bbee9e88b1f0f4569f7a87a18bb65d5dfce0..92279685533667a54d7d813383287804dd145a41 100644 (file)
@@ -897,6 +897,27 @@ bool io_post_aux_cqe(struct io_ring_ctx *ctx, u64 user_data, s32 res, u32 cflags
        return filled;
 }
 
+/*
+ * See io_add_aux_cqe() comment.
+ */
+bool io_add_aux_cqe32(struct io_ring_ctx *ctx, struct io_uring_cqe cqe[2])
+{
+       bool ret = true;
+
+       lockdep_assert_held(&ctx->uring_lock);
+       lockdep_assert(ctx->lockless_cq);
+
+       if (!io_fill_cqe_aux32(ctx, cqe)) {
+               struct io_cqe ocqe = io_init_cqe(cqe->user_data, cqe->res, cqe->flags);
+
+               io_cqe_overflow(ctx, &ocqe, (struct io_big_cqe *) &cqe[1]);
+               ret = false;
+       }
+
+       ctx->submit_state.cq_flush = true;
+       return ret;
+}
+
 /*
  * Must be called from inline task_work so we now a flush will happen later,
  * and obviously with ctx->uring_lock held (tw always has that).
index 2e4f7223a7679a039e6eb244cbdc8e5e24ff5562..c6e48e5adb01ed57593d65444355677824c17fcd 100644 (file)
@@ -80,6 +80,7 @@ int io_run_task_work_sig(struct io_ring_ctx *ctx);
 void io_req_defer_failed(struct io_kiocb *req, s32 res);
 bool io_post_aux_cqe(struct io_ring_ctx *ctx, u64 user_data, s32 res, u32 cflags);
 void io_add_aux_cqe(struct io_ring_ctx *ctx, u64 user_data, s32 res, u32 cflags);
+bool io_add_aux_cqe32(struct io_ring_ctx *ctx, struct io_uring_cqe src_cqe[2]);
 bool io_req_post_cqe(struct io_kiocb *req, s32 res, u32 cflags);
 bool io_req_post_cqe32(struct io_kiocb *req, struct io_uring_cqe src_cqe[2]);
 void __io_commit_cqring_flush(struct io_ring_ctx *ctx);