diff options
author | Pavel Begunkov <asml.silence@gmail.com> | 2021-02-28 22:35:11 +0000 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2021-04-11 17:41:58 -0600 |
commit | dafecf19e25f9b864ce0f3b8bb12de2e3d5f6da6 (patch) | |
tree | d58679038235e33e39d69fc7041442d1ac873533 /fs/io_uring.c | |
parent | 2c4b8eb6435e615544b92acdcd4b25a85e83f300 (diff) | |
download | lwn-dafecf19e25f9b864ce0f3b8bb12de2e3d5f6da6.tar.gz lwn-dafecf19e25f9b864ce0f3b8bb12de2e3d5f6da6.zip |
io_uring: further deduplicate file slot selection
io_fixed_file_slot() and io_file_from_index() behave pretty similarly,
DRY and call one from another.
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.c | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c index 49cdeaf710ee..a5eee7514a03 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -6204,13 +6204,19 @@ static void io_wq_submit_work(struct io_wq_work *work) } } -static inline struct file *io_file_from_index(struct io_ring_ctx *ctx, - int index) +static inline struct file **io_fixed_file_slot(struct fixed_rsrc_data *file_data, + unsigned i) { struct fixed_rsrc_table *table; - table = &ctx->file_data->table[index >> IORING_FILE_TABLE_SHIFT]; - return table->files[index & IORING_FILE_TABLE_MASK]; + table = &file_data->table[i >> IORING_FILE_TABLE_SHIFT]; + return &table->files[i & IORING_FILE_TABLE_MASK]; +} + +static inline struct file *io_file_from_index(struct io_ring_ctx *ctx, + int index) +{ + return *io_fixed_file_slot(ctx->file_data, index); } static struct file *io_file_get(struct io_submit_state *state, @@ -7478,15 +7484,6 @@ static void io_rsrc_put_work(struct work_struct *work) } } -static struct file **io_fixed_file_slot(struct fixed_rsrc_data *file_data, - unsigned i) -{ - struct fixed_rsrc_table *table; - - table = &file_data->table[i >> IORING_FILE_TABLE_SHIFT]; - return &table->files[i & IORING_FILE_TABLE_MASK]; -} - static void io_rsrc_node_ref_zero(struct percpu_ref *ref) { struct fixed_rsrc_ref_node *ref_node; |