From: Jens Axboe Date: Thu, 24 Jul 2025 21:03:27 +0000 (-0600) Subject: io_uring: add io_add_aux_cqe32() helper X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=7e7c53453070fee71cd56b6e73038ebe6422fc5b;p=linux-block.git io_uring: add io_add_aux_cqe32() helper 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 --- diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index 4569bbee9e88..922796855336 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -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). diff --git a/io_uring/io_uring.h b/io_uring/io_uring.h index 2e4f7223a767..c6e48e5adb01 100644 --- a/io_uring/io_uring.h +++ b/io_uring/io_uring.h @@ -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);