io_uring: ensure deferred completions are flushed for multishot
authorJens Axboe <axboe@kernel.dk>
Wed, 7 May 2025 13:34:24 +0000 (07:34 -0600)
committerJens Axboe <axboe@kernel.dk>
Wed, 7 May 2025 13:55:15 +0000 (07:55 -0600)
commit687b2bae0efff9b25e071737d6af5004e6e35af5
treeed667929806efd8b50851810e52b713dc0ec6fc7
parentb53e523261bf058ea4a518b482222e7a277b186b
io_uring: ensure deferred completions are flushed for multishot

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,
as new multishot completions get posted before the deferred ones are
flushed. This can cause confusion on the application side, if strict
ordering is required for the use case.

When multishot posting via io_req_post_cqe(), flush any pending deferred
completions first, if any.

Cc: stable@vger.kernel.org # 6.1+
Reported-by: Norman Maurer <norman_maurer@apple.com>
Reported-by: Christian Mazakas <christian.mazakas@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/io_uring.c