Skip to content

Commit 17bc283

Browse files
committed
io_uring: have io_file_put() take an io_kiocb rather than the file
No functional changes in this patch, just a prep patch for needing the request in io_file_put(). Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 9f69a25 commit 17bc283

2 files changed

Lines changed: 5 additions & 7 deletions

File tree

io_uring/io_uring.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -998,8 +998,7 @@ static void __io_req_complete_post(struct io_kiocb *req, unsigned issue_flags)
998998
io_put_kbuf_comp(req);
999999
if (unlikely(req->flags & IO_REQ_CLEAN_FLAGS))
10001000
io_clean_op(req);
1001-
if (!(req->flags & REQ_F_FIXED_FILE))
1002-
io_put_file(req->file);
1001+
io_put_file(req);
10031002

10041003
rsrc_node = req->rsrc_node;
10051004
/*
@@ -1533,8 +1532,7 @@ void io_free_batch_list(struct io_ring_ctx *ctx, struct io_wq_work_node *node)
15331532
if (unlikely(req->flags & IO_REQ_CLEAN_FLAGS))
15341533
io_clean_op(req);
15351534
}
1536-
if (!(req->flags & REQ_F_FIXED_FILE))
1537-
io_put_file(req->file);
1535+
io_put_file(req);
15381536

15391537
io_req_put_rsrc_locked(req, ctx);
15401538

io_uring/io_uring.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,10 @@ static inline bool req_has_async_data(struct io_kiocb *req)
196196
return req->flags & REQ_F_ASYNC_DATA;
197197
}
198198

199-
static inline void io_put_file(struct file *file)
199+
static inline void io_put_file(struct io_kiocb *req)
200200
{
201-
if (file)
202-
fput(file);
201+
if (!(req->flags & REQ_F_FIXED_FILE) && req->file)
202+
fput(req->file);
203203
}
204204

205205
static inline void io_ring_submit_unlock(struct io_ring_ctx *ctx,

0 commit comments

Comments
 (0)