Skip to content

Commit c8fb20b

Browse files
isilenceaxboe
authored andcommitted
io_uring: remove req cancel in ->flush()
Every close(io_uring) causes cancellation of all inflight requests carrying ->files. That's not nice but was neccessary up until recently. Now task->files removal is handled in the core code, so that part of flush can be removed. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 43c01fb commit c8fb20b

1 file changed

Lines changed: 5 additions & 23 deletions

File tree

fs/io_uring.c

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8684,30 +8684,21 @@ static void io_uring_del_task_file(struct file *file)
86848684
fput(file);
86858685
}
86868686

8687-
static void __io_uring_attempt_task_drop(struct file *file)
8688-
{
8689-
struct file *old = xa_load(&current->io_uring->xa, (unsigned long)file);
8690-
8691-
if (old == file)
8692-
io_uring_del_task_file(file);
8693-
}
8694-
86958687
/*
86968688
* Drop task note for this file if we're the only ones that hold it after
86978689
* pending fput()
86988690
*/
8699-
static void io_uring_attempt_task_drop(struct file *file, bool exiting)
8691+
static void io_uring_attempt_task_drop(struct file *file)
87008692
{
87018693
if (!current->io_uring)
87028694
return;
87038695
/*
87048696
* fput() is pending, will be 2 if the only other ref is our potential
87058697
* task file note. If the task is exiting, drop regardless of count.
87068698
*/
8707-
if (!exiting && atomic_long_read(&file->f_count) != 2)
8708-
return;
8709-
8710-
__io_uring_attempt_task_drop(file);
8699+
if (fatal_signal_pending(current) || (current->flags & PF_EXITING) ||
8700+
atomic_long_read(&file->f_count) == 2)
8701+
io_uring_del_task_file(file);
87118702
}
87128703

87138704
void __io_uring_files_cancel(struct files_struct *files)
@@ -8765,16 +8756,7 @@ void __io_uring_task_cancel(void)
87658756

87668757
static int io_uring_flush(struct file *file, void *data)
87678758
{
8768-
struct io_ring_ctx *ctx = file->private_data;
8769-
8770-
/*
8771-
* If the task is going away, cancel work it may have pending
8772-
*/
8773-
if (fatal_signal_pending(current) || (current->flags & PF_EXITING))
8774-
data = NULL;
8775-
8776-
io_uring_cancel_task_requests(ctx, data);
8777-
io_uring_attempt_task_drop(file, !data);
8759+
io_uring_attempt_task_drop(file);
87788760
return 0;
87798761
}
87808762

0 commit comments

Comments
 (0)