Commit ba50a036 authored by Pavel Begunkov's avatar Pavel Begunkov Committed by Jens Axboe

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: default avatarPavel Begunkov <asml.silence@gmail.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent e54945ae
...@@ -8518,9 +8518,10 @@ static int io_remove_personalities(int id, void *p, void *data) ...@@ -8518,9 +8518,10 @@ static int io_remove_personalities(int id, void *p, void *data)
return 0; return 0;
} }
static void io_run_ctx_fallback(struct io_ring_ctx *ctx) static bool io_run_ctx_fallback(struct io_ring_ctx *ctx)
{ {
struct callback_head *work, *head, *next; struct callback_head *work, *head, *next;
bool executed = false;
do { do {
do { do {
...@@ -8537,7 +8538,10 @@ static void io_run_ctx_fallback(struct io_ring_ctx *ctx) ...@@ -8537,7 +8538,10 @@ static void io_run_ctx_fallback(struct io_ring_ctx *ctx)
work = next; work = next;
cond_resched(); cond_resched();
} while (work); } while (work);
executed = true;
} while (1); } while (1);
return executed;
} }
static void io_ring_exit_work(struct work_struct *work) 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, ...@@ -8677,6 +8681,7 @@ static void io_uring_try_cancel_requests(struct io_ring_ctx *ctx,
ret |= io_poll_remove_all(ctx, task, files); ret |= io_poll_remove_all(ctx, task, files);
ret |= io_kill_timeouts(ctx, task, files); ret |= io_kill_timeouts(ctx, task, files);
ret |= io_run_task_work(); ret |= io_run_task_work();
ret |= io_run_ctx_fallback(ctx);
io_cqring_overflow_flush(ctx, true, task, files); io_cqring_overflow_flush(ctx, true, task, files);
if (!ret) if (!ret)
break; break;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment