summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2020-09-22 10:19:24 -0600
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-11-01 12:47:01 +0100
commitcf383607a5826f2a124540ef5cf3a25ff658bf9c (patch)
tree83bdeb3f2fd012ceada6ca191e17cbf3f9d654b7
parent2c5401763d967390d7285abdb8f00e8a8d80959f (diff)
downloadlinux-stable-cf383607a5826f2a124540ef5cf3a25ff658bf9c.tar.gz
linux-stable-cf383607a5826f2a124540ef5cf3a25ff658bf9c.tar.bz2
linux-stable-cf383607a5826f2a124540ef5cf3a25ff658bf9c.zip
io_uring: move dropping of files into separate helper
commit 0444ce1e0b5967393447dcd5adbf2bb023a50aab upstream. No functional changes in this patch, prep patch for grabbing references to the files_struct. Reviewed-by: Pavel Begunkov <asml.silence@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--fs/io_uring.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 867145fb149c..73c5dbb1591d 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -5648,6 +5648,20 @@ static int io_req_defer(struct io_kiocb *req, const struct io_uring_sqe *sqe)
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_kiocb *req)
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,