summaryrefslogtreecommitdiff
path: root/io_uring/filetable.c
diff options
context:
space:
mode:
authorMing Lei <ming.lei@redhat.com>2024-11-07 19:01:34 +0800
committerJens Axboe <axboe@kernel.dk>2024-11-07 15:24:33 -0700
commit0d98c509086837a8cf5a32f82f2a58f39a539192 (patch)
treeea2fcd6c406d92ff8479964fc3b29c399e32f006 /io_uring/filetable.c
parentaf0a2ffef0e6d23412dd55df29f5caef8f3583f2 (diff)
io_uring/rsrc: pass 'struct io_ring_ctx' reference to rsrc helpers
`io_rsrc_node` instance won't be shared among different io_uring ctxs, and its allocation 'ctx' is always same with the user's 'ctx', so it is safe to pass user 'ctx' reference to rsrc helpers. Even in io_clone_buffers(), `io_rsrc_node` instance is allocated actually for destination io_uring_ctx. Then io_rsrc_node_ctx() can be removed, and the 8 bytes `ctx` pointer will be removed from `io_rsrc_node` in the following patch. Signed-off-by: Ming Lei <ming.lei@redhat.com> Link: https://lore.kernel.org/r/20241107110149.890530-2-ming.lei@redhat.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'io_uring/filetable.c')
-rw-r--r--io_uring/filetable.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/io_uring/filetable.c b/io_uring/filetable.c
index 45f005f5db42..a21660e3145a 100644
--- a/io_uring/filetable.c
+++ b/io_uring/filetable.c
@@ -36,20 +36,21 @@ static int io_file_bitmap_get(struct io_ring_ctx *ctx)
return -ENFILE;
}
-bool io_alloc_file_tables(struct io_file_table *table, unsigned nr_files)
+bool io_alloc_file_tables(struct io_ring_ctx *ctx, struct io_file_table *table,
+ unsigned nr_files)
{
if (io_rsrc_data_alloc(&table->data, nr_files))
return false;
table->bitmap = bitmap_zalloc(nr_files, GFP_KERNEL_ACCOUNT);
if (table->bitmap)
return true;
- io_rsrc_data_free(&table->data);
+ io_rsrc_data_free(ctx, &table->data);
return false;
}
-void io_free_file_tables(struct io_file_table *table)
+void io_free_file_tables(struct io_ring_ctx *ctx, struct io_file_table *table)
{
- io_rsrc_data_free(&table->data);
+ io_rsrc_data_free(ctx, &table->data);
bitmap_free(table->bitmap);
table->bitmap = NULL;
}
@@ -71,7 +72,7 @@ static int io_install_fixed_file(struct io_ring_ctx *ctx, struct file *file,
if (!node)
return -ENOMEM;
- if (!io_reset_rsrc_node(&ctx->file_table.data, slot_index))
+ if (!io_reset_rsrc_node(ctx, &ctx->file_table.data, slot_index))
io_file_bitmap_set(&ctx->file_table, slot_index);
ctx->file_table.data.nodes[slot_index] = node;
@@ -130,7 +131,7 @@ int io_fixed_fd_remove(struct io_ring_ctx *ctx, unsigned int offset)
node = io_rsrc_node_lookup(&ctx->file_table.data, offset);
if (!node)
return -EBADF;
- io_reset_rsrc_node(&ctx->file_table.data, offset);
+ io_reset_rsrc_node(ctx, &ctx->file_table.data, offset);
io_file_bitmap_clear(&ctx->file_table, offset);
return 0;
}