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.9-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.9 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:19:08 PM CET 2020 From: Jens Axboe <axboe@xxxxxxxxx> Date: Tue, 22 Sep 2020 10:19:24 -0600 Subject: io_uring: move dropping of files into separate helper From: Jens Axboe <axboe@xxxxxxxxx> commit 0444ce1e0b5967393447dcd5adbf2bb023a50aab 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 | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -5648,6 +5648,20 @@ static int io_req_defer(struct io_kiocb return -EIOCBQUEUED; } +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_clean_op(struct io_kiocb *req) { struct io_async_ctx *io = req->io; @@ -5697,17 +5711,8 @@ static void __io_clean_op(struct io_kioc req->flags &= ~REQ_F_NEED_CLEANUP; } - 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); - req->flags &= ~REQ_F_INFLIGHT; - } + if (req->flags & REQ_F_INFLIGHT) + io_req_drop_files(req); } static int io_issue_sqe(struct io_kiocb *req, const struct io_uring_sqe *sqe, Patches currently in stable-queue which might be from axboe@xxxxxxxxx are queue-5.9/io_uring-convert-advanced-xarray-uses-to-the-normal-api.patch queue-5.9/io_uring-reference-nsproxy-for-file-table-commands.patch queue-5.9/io_uring-stash-ctx-task-reference-for-sqpoll.patch queue-5.9/io_uring-return-cancelation-status-from-poll-timeout-files-handlers.patch queue-5.9/io_uring-fix-xarray-usage-in-io_uring_add_task_file.patch queue-5.9/io_uring-fix-use-of-xarray-in-__io_uring_files_cancel.patch queue-5.9/io-wq-fix-use-after-free-in-io_wq_worker_running.patch queue-5.9/io_uring-don-t-rely-on-weak-files-references.patch queue-5.9/io_uring-allow-timeout-poll-files-killing-to-take-task-into-account.patch queue-5.9/io_uring-move-dropping-of-files-into-separate-helper.patch queue-5.9/io_uring-unconditionally-grab-req-task.patch queue-5.9/io_uring-enable-task-files-specific-overflow-flushing.patch queue-5.9/io_wq-make-io_wqe-lock-a-raw_spinlock_t.patch queue-5.9/io_uring-no-need-to-call-xa_destroy-on-empty-xarray.patch