Skip to content

Commit

Permalink
io_uring: put flag checking for needing req cleanup in one spot
Browse files Browse the repository at this point in the history
We have this in two spots right now, which is a bit fragile. In
preparation for moving REQ_F_POLLED cleanup into the same spot, move
the check into a separate helper so we only have it once.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Jens Axboe committed Apr 16, 2021
1 parent ea6a693 commit 4e3d9ff
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions fs/io_uring.c
Original file line number Diff line number Diff line change
Expand Up @@ -1598,10 +1598,15 @@ static void io_req_complete_post(struct io_kiocb *req, long res,
}
}

static inline bool io_req_needs_clean(struct io_kiocb *req)
{
return req->flags & (REQ_F_BUFFER_SELECTED | REQ_F_NEED_CLEANUP);
}

static void io_req_complete_state(struct io_kiocb *req, long res,
unsigned int cflags)
{
if (req->flags & (REQ_F_NEED_CLEANUP | REQ_F_BUFFER_SELECTED))
if (io_req_needs_clean(req))
io_clean_op(req);
req->result = res;
req->compl.cflags = cflags;
Expand Down Expand Up @@ -1713,10 +1718,8 @@ static void io_dismantle_req(struct io_kiocb *req)

if (!(flags & REQ_F_FIXED_FILE))
io_put_file(req->file);
if (flags & (REQ_F_NEED_CLEANUP | REQ_F_BUFFER_SELECTED |
REQ_F_INFLIGHT)) {
if (io_req_needs_clean(req) || (req->flags & REQ_F_INFLIGHT)) {
io_clean_op(req);

if (req->flags & REQ_F_INFLIGHT) {
struct io_uring_task *tctx = req->task->io_uring;

Expand Down

0 comments on commit 4e3d9ff

Please sign in to comment.