diff --git a/fs/io_uring.c b/fs/io_uring.c index 3250ea7261fb5fc2047df071edad50b474152777..2e7d2885f0407b22ee8d9ea14abcdbfe28346046 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -7342,9 +7342,22 @@ static int io_uring_release(struct inode *inode, struct file *file) return 0; } +static bool io_wq_files_match(struct io_wq_work *work, void *data) +{ + struct files_struct *files = data; + + return work->files == files; +} + static void io_uring_cancel_files(struct io_ring_ctx *ctx, struct files_struct *files) { + if (list_empty_careful(&ctx->inflight_list)) + return; + + /* cancel all at once, should be faster than doing it one by one*/ + io_wq_cancel_cb(ctx->io_wq, io_wq_files_match, files, true); + while (!list_empty_careful(&ctx->inflight_list)) { struct io_kiocb *cancel_req = NULL, *req; DEFINE_WAIT(wait);