From: Pavel Begunkov Date: Sun, 28 Feb 2021 22:35:11 +0000 (+0000) Subject: io_uring: further deduplicate file slot selection X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=dafecf19e25f9b864ce0f3b8bb12de2e3d5f6da6;p=linux.git 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 Signed-off-by: Jens Axboe --- diff --git a/fs/io_uring.c b/fs/io_uring.c index 49cdeaf710ee3..a5eee7514a038 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;