Skip to content

Commit b82c386

Browse files
axboegregkh
authored andcommitted
io_uring: ensure deferred completions are posted for multishot
Commit 687b2bae0efff9b25e071737d6af5004e6e35af5 upstream. Multishot normally uses io_req_post_cqe() to post completions, but when stopping it, it may finish up with a deferred completion. This is fine, except if another multishot event triggers before the deferred completions get flushed. If this occurs, then CQEs may get reordered in the CQ ring, and cause confusion on the application side. When multishot posting via io_req_post_cqe(), flush any pending deferred completions first, if any. Cc: [email protected] # 6.1+ Reported-by: Norman Maurer <[email protected]> Reported-by: Christian Mazakas <[email protected]> Signed-off-by: Jens Axboe <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 95b9acb commit b82c386

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

io_uring/io_uring.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,14 @@ bool io_post_aux_cqe(struct io_ring_ctx *ctx,
819819
{
820820
bool filled;
821821

822+
/*
823+
* If multishot has already posted deferred completions, ensure that
824+
* those are flushed first before posting this one. If not, CQEs
825+
* could get reordered.
826+
*/
827+
if (!wq_list_empty(&ctx->submit_state.compl_reqs))
828+
__io_submit_flush_completions(ctx);
829+
822830
io_cq_lock(ctx);
823831
filled = io_fill_cqe_aux(ctx, user_data, res, cflags, allow_overflow);
824832
io_cq_unlock_post(ctx);

0 commit comments

Comments
 (0)