]> git.hungrycats.org Git - linux/commit
io_uring: end the drain when the drain request completes
authorJens Axboe <axboe@kernel.dk>
Mon, 19 Oct 2026 19:30:51 +0000 (13:30 -0600)
committerJens Axboe <axboe@kernel.dk>
Tue, 20 Oct 2026 14:35:27 +0000 (08:35 -0600)
commitecb6817b769fd7d71af2c9f446188649020b2e53
treef1ae8f57c64ace4d50682d9f555b8d5dfd0ebd7b
parent02caa5922184e99da04b37fd3336066625ea8e2e
io_uring: end the drain when the drain request completes

Since requests are drained based on allocated requests, the drain stays
active after the drain request has posted its CQE, until it is freed and
a new request finds the defer list empty. A drain request run by io-wq
is freed only after the worker drops its reference, so a request
submitted after the drain completed can still be deferred behind it,
and get issued much later than the application expects.

A drain request dispatched from the defer list runs alone. Track it,
and end the drain when its CQE is flushed and nothing else is deferred.
Have io-wq complete drain requests through task_work, so that this
happens under ->uring_lock before the CQE is visible. Linked drain
requests keep waiting until the link is freed.

Reported-by: Wei Gao <wegao@suse.com>
Link: https://lore.kernel.org/io-uring/20261018070154.16944-1-wegao@suse.com/
Fixes: 8fb7aee05591 ("io_uring: drain based on allocates reqs")
Cc: stable@vger.kernel.org
Tested-by: Wei Gao <wegao@suse.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
include/linux/io_uring_types.h
io_uring/io_uring.c