io_uring: only wait for in-flight requests if the closing task uses the ring

Since commit 13d3783a55 ("io_uring: wait for in-flight requests on
ring release"), the task dropping the last reference to a ring waits
for every request on it to complete. A process that only received the
ring fd, e.g. over a UNIX socket, can then block in close(2) on
requests owned by other tasks, such as a read from an unresponsive
FUSE server.

Skip the wait for tasks that never attached to the ring and leave those
requests to io_ring_exit_work(), as before.

Fixes: 13d3783a55 ("io_uring: wait for in-flight requests on ring release")
Signed-off-by: Orkun Emin Sarı <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Jens Axboe <[email protected]>
This commit is contained in:
Orkun Emin Sarı
2026-11-04 10:25:14 -07:00
committed by Jens Axboe
parent 21662435a5
commit cf6542493e
+4 -1
View File
@@ -2547,7 +2547,10 @@ static __cold void io_ring_ctx_wait_inflight(struct io_ring_ctx *ctx)
if (current->flags & (PF_KTHREAD | PF_EXITING))
return;
if (tctx && atomic_read(&tctx->in_cancel))
/* Only wait if this task has attached to the ring */
if (!tctx || !xa_load(&tctx->xa, (unsigned long)ctx))
return;
if (atomic_read(&tctx->in_cancel))
return;
while (io_ring_ctx_inflight(ctx) && !fatal_signal_pending(current)) {