This is a note to let you know that I've just added the patch titled io_uring: move dropping of files into separate helper to the 5.8-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: io_uring-move-dropping-of-files-into-separate-helper.patch and it can be found in the queue-5.8 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From foo@baz Thu Oct 29 01:16:54 PM CET 2020 From: Jens Axboe <axboe@xxxxxxxxx> Date: Mon, 12 Oct 2020 11:03:18 -0600 Subject: io_uring: move dropping of files into separate helper From: Jens Axboe <axboe@xxxxxxxxx> commit f573d384456b3025d3f8e58b3eafaeeb0f510784 upstream. No functional changes in this patch, prep patch for grabbing references to the files_struct. Reviewed-by: Pavel Begunkov <asml.silence@xxxxxxxxx> Signed-off-by: Jens Axboe <axboe@xxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- fs/io_uring.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -1424,6 +1424,20 @@ static inline void io_put_file(struct io fput(file); } +static void io_req_drop_files(struct io_kiocb *req) +{ + struct io_ring_ctx *ctx = req->ctx; + unsigned long flags; + + spin_lock_irqsave(&ctx->inflight_lock, flags); + list_del(&req->inflight_entry); + if (waitqueue_active(&ctx->inflight_wait)) + wake_up(&ctx->inflight_wait); + spin_unlock_irqrestore(&ctx->inflight_lock, flags); + req->flags &= ~REQ_F_INFLIGHT; + req->work.files = NULL; +} + static void __io_req_aux_free(struct io_kiocb *req) { if (req->flags & REQ_F_NEED_CLEANUP) @@ -1440,16 +1454,8 @@ static void __io_free_req(struct io_kioc { __io_req_aux_free(req); - if (req->flags & REQ_F_INFLIGHT) { - struct io_ring_ctx *ctx = req->ctx; - unsigned long flags; - - spin_lock_irqsave(&ctx->inflight_lock, flags); - list_del(&req->inflight_entry); - if (waitqueue_active(&ctx->inflight_wait)) - wake_up(&ctx->inflight_wait); - spin_unlock_irqrestore(&ctx->inflight_lock, flags); - } + if (req->flags & REQ_F_INFLIGHT) + io_req_drop_files(req); percpu_ref_put(&req->ctx->refs); if (likely(!io_is_fallback_req(req))) Patches currently in stable-queue which might be from axboe@xxxxxxxxx are queue-5.8/io_uring-convert-advanced-xarray-uses-to-the-normal-api.patch queue-5.8/io_uring-don-t-run-task-work-on-an-exiting-task.patch queue-5.8/io_uring-reference-nsproxy-for-file-table-commands.patch queue-5.8/io_uring-stash-ctx-task-reference-for-sqpoll.patch queue-5.8/io_uring-return-cancelation-status-from-poll-timeout-files-handlers.patch queue-5.8/io_uring-fix-xarray-usage-in-io_uring_add_task_file.patch queue-5.8/io_uring-fix-use-of-xarray-in-__io_uring_files_cancel.patch queue-5.8/io-wq-fix-use-after-free-in-io_wq_worker_running.patch queue-5.8/io_uring-don-t-rely-on-weak-files-references.patch queue-5.8/io_uring-allow-timeout-poll-files-killing-to-take-task-into-account.patch queue-5.8/io_uring-move-dropping-of-files-into-separate-helper.patch queue-5.8/io_uring-unconditionally-grab-req-task.patch queue-5.8/io_uring-enable-task-files-specific-overflow-flushing.patch queue-5.8/io_wq-make-io_wqe-lock-a-raw_spinlock_t.patch queue-5.8/io_uring-no-need-to-call-xa_destroy-on-empty-xarray.patch