diff options
author | Jens Axboe <[email protected]> | 2024-10-26 14:50:13 -0600 |
---|---|---|
committer | Jens Axboe <[email protected]> | 2024-11-02 15:45:23 -0600 |
commit | 3597f2786b687a7f26361ce00a805ea0af41b65f (patch) | |
tree | 7b15bfaff8816407ffd8936e12ef1eb0fcc458bd /io_uring/io_uring.c | |
parent | f38f2847646f8be29a8fcb722e8b1dc8c8cb3924 (diff) |
io_uring/rsrc: unify file and buffer resource tables
For files, there's nr_user_files/file_table/file_data, and buffers have
nr_user_bufs/user_bufs/buf_data. There's no reason why file_table and
file_data can't be the same thing, and ditto for the buffer side. That
gets rid of more io_ring_ctx state that's in two spots rather than just
being in one spot, as it should be. Put all the registered file data in
one locations, and ditto on the buffer front.
This also avoids having both io_rsrc_data->nodes being an allocated
array, and ->user_bufs[] or ->file_table.nodes. There's no reason to
have this information duplicated. Keep it in one spot, io_rsrc_data,
along with how many resources are available.
Signed-off-by: Jens Axboe <[email protected]>
Diffstat (limited to 'io_uring/io_uring.c')
-rw-r--r-- | io_uring/io_uring.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index 60c947114fa3..78df515fb3a7 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -1879,11 +1879,10 @@ inline struct file *io_file_get_fixed(struct io_kiocb *req, int fd, struct file *file = NULL; io_ring_submit_lock(ctx, issue_flags); - - if (unlikely((unsigned int)fd >= ctx->nr_user_files)) + if (unlikely((unsigned int)fd >= ctx->file_table.data.nr)) goto out; - fd = array_index_nospec(fd, ctx->nr_user_files); - node = ctx->file_table.nodes[fd]; + fd = array_index_nospec(fd, ctx->file_table.data.nr); + node = ctx->file_table.data.nodes[fd]; if (node) { io_req_assign_rsrc_node(req, node); req->flags |= io_slot_flags(node); |