summaryrefslogtreecommitdiff
path: root/fs/io_uring.c
diff options
context:
space:
mode:
authorPavel Begunkov <asml.silence@gmail.com>2020-07-16 23:28:33 +0300
committerJens Axboe <axboe@kernel.dk>2020-07-24 13:00:44 -0600
commit06ef3608b0eed673fcbc62cf74c8d3ad0007a337 (patch)
tree39ced7885ecf8b833c3cbe5572203f96e04c44e5 /fs/io_uring.c
parent57f1a64958543fe18a7fe0addbfb31bb2ceeaea2 (diff)
downloadlwn-06ef3608b0eed673fcbc62cf74c8d3ad0007a337.tar.gz
lwn-06ef3608b0eed673fcbc62cf74c8d3ad0007a337.zip
io_uring: simplify file ref tracking in submission state
Currently, file refs in struct io_submit_state are tracked with 2 vars: @has_refs -- how many refs were initially taken @used_refs -- number of refs used Replace it with a single variable counting how many refs left at the current moment. Signed-off-by: Pavel Begunkov <asml.silence@gmail.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'fs/io_uring.c')
-rw-r--r--fs/io_uring.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 8b2f7a1bbd06..28b47533454a 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -707,7 +707,6 @@ struct io_submit_state {
struct file *file;
unsigned int fd;
unsigned int has_refs;
- unsigned int used_refs;
unsigned int ios_left;
};
@@ -2327,10 +2326,8 @@ static void io_iopoll_req_issued(struct io_kiocb *req)
static void __io_state_file_put(struct io_submit_state *state)
{
- int diff = state->has_refs - state->used_refs;
-
- if (diff)
- fput_many(state->file, diff);
+ if (state->has_refs)
+ fput_many(state->file, state->has_refs);
state->file = NULL;
}
@@ -2352,7 +2349,7 @@ static struct file *__io_file_get(struct io_submit_state *state, int fd)
if (state->file) {
if (state->fd == fd) {
- state->used_refs++;
+ state->has_refs--;
state->ios_left--;
return state->file;
}
@@ -2363,9 +2360,8 @@ static struct file *__io_file_get(struct io_submit_state *state, int fd)
return NULL;
state->fd = fd;
- state->has_refs = state->ios_left;
- state->used_refs = 1;
state->ios_left--;
+ state->has_refs = state->ios_left;
return state->file;
}