Skip to content

Commit ba50a03

Browse files
isilenceaxboe
authored andcommitted
io_uring: run fallback on cancellation
io_uring_try_cancel_requests() matches not only current's requests, but also of other exiting tasks, so we need to actively cancel them and not just wait, especially since the function can be called on flush during do_exit() -> exit_files(). Even if it's not a problem for now, it's much nicer to know that the function tries to cancel everything it can. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent e54945a commit ba50a03

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

fs/io_uring.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8518,9 +8518,10 @@ static int io_remove_personalities(int id, void *p, void *data)
85188518
return 0;
85198519
}
85208520

8521-
static void io_run_ctx_fallback(struct io_ring_ctx *ctx)
8521+
static bool io_run_ctx_fallback(struct io_ring_ctx *ctx)
85228522
{
85238523
struct callback_head *work, *head, *next;
8524+
bool executed = false;
85248525

85258526
do {
85268527
do {
@@ -8537,7 +8538,10 @@ static void io_run_ctx_fallback(struct io_ring_ctx *ctx)
85378538
work = next;
85388539
cond_resched();
85398540
} while (work);
8541+
executed = true;
85408542
} while (1);
8543+
8544+
return executed;
85418545
}
85428546

85438547
static void io_ring_exit_work(struct work_struct *work)
@@ -8677,6 +8681,7 @@ static void io_uring_try_cancel_requests(struct io_ring_ctx *ctx,
86778681
ret |= io_poll_remove_all(ctx, task, files);
86788682
ret |= io_kill_timeouts(ctx, task, files);
86798683
ret |= io_run_task_work();
8684+
ret |= io_run_ctx_fallback(ctx);
86808685
io_cqring_overflow_flush(ctx, true, task, files);
86818686
if (!ret)
86828687
break;

0 commit comments

Comments
 (0)