Skip to content

Commit b1b6b5a

Browse files
isilenceaxboe
authored andcommitted
kernel/io_uring: cancel io_uring before task works
For cancelling io_uring requests it needs either to be able to run currently enqueued task_works or having it shut down by that moment. Otherwise io_uring_cancel_files() may be waiting for requests that won't ever complete. Go with the first way and do cancellations before setting PF_EXITING and so before putting the task_work infrastructure into a transition state where task_work_run() would better not be called. Cc: [email protected] # 5.5+ Signed-off-by: Pavel Begunkov <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 1ffc542 commit b1b6b5a

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

fs/file.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
#include <linux/rcupdate.h>
2222
#include <linux/close_range.h>
2323
#include <net/sock.h>
24-
#include <linux/io_uring.h>
2524

2625
unsigned int sysctl_nr_open __read_mostly = 1024*1024;
2726
unsigned int sysctl_nr_open_min = BITS_PER_LONG;
@@ -428,7 +427,6 @@ void exit_files(struct task_struct *tsk)
428427
struct files_struct * files = tsk->files;
429428

430429
if (files) {
431-
io_uring_files_cancel(files);
432430
task_lock(tsk);
433431
tsk->files = NULL;
434432
task_unlock(tsk);

kernel/exit.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
#include <linux/random.h>
6464
#include <linux/rcuwait.h>
6565
#include <linux/compat.h>
66+
#include <linux/io_uring.h>
6667

6768
#include <linux/uaccess.h>
6869
#include <asm/unistd.h>
@@ -776,6 +777,7 @@ void __noreturn do_exit(long code)
776777
schedule();
777778
}
778779

780+
io_uring_files_cancel(tsk->files);
779781
exit_signals(tsk); /* sets PF_EXITING */
780782

781783
/* sync mm's RSS info before statistics gathering */

0 commit comments

Comments
 (0)