diff options
author | Jens Axboe <axboe@kernel.dk> | 2024-06-06 10:28:26 -0600 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2024-06-24 08:39:45 -0600 |
commit | f33096a3c99c0149be49fe1e107244a7ed860ecb (patch) | |
tree | a8a10d0f82bdfb182c3c4d959a953526da10cf0d /io_uring/io_uring.c | |
parent | c3ac76f9ca7a621428851149bc56bfca0aacaef4 (diff) | |
download | linux-stable-f33096a3c99c0149be49fe1e107244a7ed860ecb.tar.gz linux-stable-f33096a3c99c0149be49fe1e107244a7ed860ecb.tar.bz2 linux-stable-f33096a3c99c0149be49fe1e107244a7ed860ecb.zip |
io_uring: add io_add_aux_cqe() helper
This helper will post a CQE, and can be called from task_work where we
now that the ctx is already properly locked and that deferred
completions will get flushed later on.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'io_uring/io_uring.c')
-rw-r--r-- | io_uring/io_uring.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index 85b2ce54328c..cdeb94d2a26b 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -801,20 +801,39 @@ static bool io_fill_cqe_aux(struct io_ring_ctx *ctx, u64 user_data, s32 res, return false; } -bool io_post_aux_cqe(struct io_ring_ctx *ctx, u64 user_data, s32 res, u32 cflags) +static bool __io_post_aux_cqe(struct io_ring_ctx *ctx, u64 user_data, s32 res, + u32 cflags) { bool filled; - io_cq_lock(ctx); filled = io_fill_cqe_aux(ctx, user_data, res, cflags); if (!filled) filled = io_cqring_event_overflow(ctx, user_data, res, cflags, 0, 0); + return filled; +} + +bool io_post_aux_cqe(struct io_ring_ctx *ctx, u64 user_data, s32 res, u32 cflags) +{ + bool filled; + + io_cq_lock(ctx); + filled = __io_post_aux_cqe(ctx, user_data, res, cflags); io_cq_unlock_post(ctx); return filled; } /* + * 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). + */ +void io_add_aux_cqe(struct io_ring_ctx *ctx, u64 user_data, s32 res, u32 cflags) +{ + __io_post_aux_cqe(ctx, user_data, res, cflags); + ctx->submit_state.cq_flush = true; +} + +/* * A helper for multishot requests posting additional CQEs. * Should only be used from a task_work including IO_URING_F_MULTISHOT. */ |