diff options
author | Pavel Begunkov <asml.silence@gmail.com> | 2020-10-10 18:34:09 +0100 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2020-10-10 12:49:25 -0600 |
commit | 71b547c048eb10d54627932019411549b1e4cfb7 (patch) | |
tree | 641088f0845311cdbfc839982b6b0a55351ff63c | |
parent | 8371adf53c3c5ebfde1172608d3f4e126729cb10 (diff) | |
download | linux-71b547c048eb10d54627932019411549b1e4cfb7.tar.gz linux-71b547c048eb10d54627932019411549b1e4cfb7.tar.bz2 linux-71b547c048eb10d54627932019411549b1e4cfb7.zip |
io_uring: improve submit_state.ios_left accounting
state->ios_left isn't decremented for requests that don't need a file,
so it might be larger than number of SQEs left. That in some
circumstances makes us to grab more files that is needed so imposing
extra put.
Deaccount one ios_left for each request.
Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r-- | fs/io_uring.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c index ffdaea55e820..250eefbe13cb 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -2581,7 +2581,6 @@ static struct file *__io_file_get(struct io_submit_state *state, int fd) if (state->file) { if (state->fd == fd) { state->has_refs--; - state->ios_left--; return state->file; } __io_state_file_put(state); @@ -2591,8 +2590,7 @@ static struct file *__io_file_get(struct io_submit_state *state, int fd) return NULL; state->fd = fd; - state->ios_left--; - state->has_refs = state->ios_left; + state->has_refs = state->ios_left - 1; return state->file; } @@ -6386,7 +6384,7 @@ static int io_init_req(struct io_ring_ctx *ctx, struct io_kiocb *req, struct io_submit_state *state) { unsigned int sqe_flags; - int id; + int id, ret; req->opcode = READ_ONCE(sqe->opcode); req->user_data = READ_ONCE(sqe->user_data); @@ -6432,7 +6430,9 @@ static int io_init_req(struct io_ring_ctx *ctx, struct io_kiocb *req, if (!io_op_defs[req->opcode].needs_file) return 0; - return io_req_set_file(state, req, READ_ONCE(sqe->fd)); + ret = io_req_set_file(state, req, READ_ONCE(sqe->fd)); + state->ios_left--; + return ret; } static int io_submit_sqes(struct io_ring_ctx *ctx, unsigned int nr) |