There is no use of io_uring_try_task_cancel(), inline it, kill extra in_idle inc/dec as it's already done by __io_uring_task_cancel(), and do a bit of renaming. Signed-off-by: Pavel Begunkov <asml.silence@xxxxxxxxx> --- fs/io_uring.c | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index 4bf709d9db32..134ea0e3373d 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -8767,8 +8767,8 @@ static void __io_uring_cancel_task_requests(struct io_ring_ctx *ctx, * hard links. These persist even for failure of cancelations, hence keep * looping until none are found. */ -static void io_uring_cancel_task_requests(struct io_ring_ctx *ctx, - struct files_struct *files) +static void io_uring_try_task_cancel(struct io_ring_ctx *ctx, + struct files_struct *files) { struct task_struct *task = current; @@ -8862,19 +8862,6 @@ static void io_uring_attempt_task_drop(struct file *file) io_uring_del_task_file(current->io_uring, file); } -static void io_uring_try_task_cancel(struct files_struct *files) -{ - struct io_uring_task *tctx = current->io_uring; - struct file *file; - unsigned long index; - - /* make sure overflow events are dropped */ - atomic_inc(&tctx->in_idle); - xa_for_each(&tctx->xa, index, file) - io_uring_cancel_task_requests(file->private_data, files); - atomic_dec(&tctx->in_idle); -} - static s64 tctx_inflight(struct io_uring_task *tctx, bool files) { unsigned long index; @@ -8917,6 +8904,8 @@ static s64 tctx_inflight(struct io_uring_task *tctx, bool files) void __io_uring_task_cancel(struct files_struct *files) { struct io_uring_task *tctx = current->io_uring; + unsigned long index; + struct file *file; DEFINE_WAIT(wait); s64 inflight; @@ -8928,7 +8917,8 @@ void __io_uring_task_cancel(struct files_struct *files) inflight = tctx_inflight(tctx, !!files); if (!inflight) break; - io_uring_try_task_cancel(files); + xa_for_each(&tctx->xa, index, file) + io_uring_try_task_cancel(file->private_data, files); prepare_to_wait(&tctx->wait, &wait, TASK_UNINTERRUPTIBLE); @@ -8945,9 +8935,6 @@ void __io_uring_task_cancel(struct files_struct *files) atomic_dec(&tctx->in_idle); if (files) { - struct file *file; - unsigned long index; - xa_for_each(&tctx->xa, index, file) io_uring_del_task_file(tctx, file); } -- 2.24.0