Skip to content

Commit

Permalink
io_uring: move dropping of files into separate helper
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jens Axboe committed Oct 1, 2020
1 parent f3606e3 commit f573d38
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions fs/io_uring.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit f573d38

Please sign in to comment.