Commit e1d767f0 authored by Pavel Begunkov's avatar Pavel Begunkov Committed by Jens Axboe

io_uring: abolish old io_put_file()

io_put_file() doesn't do a good job at generating a good code. Inline
it, so we can check REQ_F_FIXED_FILE first, prioritising FIXED_FILE case
over requests without files, and saving a memory load in that case.
Signed-off-by: default avatarPavel Begunkov <asml.silence@gmail.com>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 094bae49
...@@ -1696,10 +1696,9 @@ static struct io_kiocb *io_alloc_req(struct io_ring_ctx *ctx) ...@@ -1696,10 +1696,9 @@ static struct io_kiocb *io_alloc_req(struct io_ring_ctx *ctx)
return state->reqs[state->free_reqs]; return state->reqs[state->free_reqs];
} }
static inline void io_put_file(struct io_kiocb *req, struct file *file, static inline void io_put_file(struct file *file)
bool fixed)
{ {
if (!fixed) if (file)
fput(file); fput(file);
} }
...@@ -1707,8 +1706,8 @@ static void io_dismantle_req(struct io_kiocb *req) ...@@ -1707,8 +1706,8 @@ static void io_dismantle_req(struct io_kiocb *req)
{ {
unsigned int flags = req->flags; unsigned int flags = req->flags;
if (req->file) if (!(flags & REQ_F_FIXED_FILE))
io_put_file(req, req->file, (flags & REQ_F_FIXED_FILE)); io_put_file(req->file);
if (flags & (REQ_F_NEED_CLEANUP | REQ_F_BUFFER_SELECTED | if (flags & (REQ_F_NEED_CLEANUP | REQ_F_BUFFER_SELECTED |
REQ_F_INFLIGHT)) { REQ_F_INFLIGHT)) {
io_clean_op(req); io_clean_op(req);
...@@ -3648,7 +3647,8 @@ static int io_tee(struct io_kiocb *req, unsigned int issue_flags) ...@@ -3648,7 +3647,8 @@ static int io_tee(struct io_kiocb *req, unsigned int issue_flags)
if (sp->len) if (sp->len)
ret = do_tee(in, out, sp->len, flags); ret = do_tee(in, out, sp->len, flags);
io_put_file(req, in, (sp->flags & SPLICE_F_FD_IN_FIXED)); if (!(sp->flags & SPLICE_F_FD_IN_FIXED))
io_put_file(in);
req->flags &= ~REQ_F_NEED_CLEANUP; req->flags &= ~REQ_F_NEED_CLEANUP;
if (ret != sp->len) if (ret != sp->len)
...@@ -3684,7 +3684,8 @@ static int io_splice(struct io_kiocb *req, unsigned int issue_flags) ...@@ -3684,7 +3684,8 @@ static int io_splice(struct io_kiocb *req, unsigned int issue_flags)
if (sp->len) if (sp->len)
ret = do_splice(in, poff_in, out, poff_out, sp->len, flags); ret = do_splice(in, poff_in, out, poff_out, sp->len, flags);
io_put_file(req, in, (sp->flags & SPLICE_F_FD_IN_FIXED)); if (!(sp->flags & SPLICE_F_FD_IN_FIXED))
io_put_file(in);
req->flags &= ~REQ_F_NEED_CLEANUP; req->flags &= ~REQ_F_NEED_CLEANUP;
if (ret != sp->len) if (ret != sp->len)
...@@ -5989,8 +5990,8 @@ static void io_clean_op(struct io_kiocb *req) ...@@ -5989,8 +5990,8 @@ static void io_clean_op(struct io_kiocb *req)
} }
case IORING_OP_SPLICE: case IORING_OP_SPLICE:
case IORING_OP_TEE: case IORING_OP_TEE:
io_put_file(req, req->splice.file_in, if (!(req->splice.flags & SPLICE_F_FD_IN_FIXED))
(req->splice.flags & SPLICE_F_FD_IN_FIXED)); io_put_file(req->splice.file_in);
break; break;
case IORING_OP_OPENAT: case IORING_OP_OPENAT:
case IORING_OP_OPENAT2: case IORING_OP_OPENAT2:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment