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 <axboe@kernel.dk>
This commit is contained in:
Jens Axboe
2024-10-26 14:50:13 -06:00
parent f38f284764
commit 3597f2786b
15 changed files with 123 additions and 212 deletions

View File

@@ -212,15 +212,15 @@ int io_uring_cmd_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
u16 index;
index = READ_ONCE(sqe->buf_index);
if (unlikely(index >= ctx->nr_user_bufs))
if (unlikely(index >= ctx->buf_table.nr))
return -EFAULT;
req->buf_index = array_index_nospec(index, ctx->nr_user_bufs);
req->buf_index = array_index_nospec(index, ctx->buf_table.nr);
/*
* Pi node upfront, prior to io_uring_cmd_import_fixed()
* being called. This prevents destruction of the mapped buffer
* we'll need at actual import time.
*/
io_req_assign_rsrc_node(req, ctx->user_bufs[req->buf_index]);
io_req_assign_rsrc_node(req, ctx->buf_table.nodes[req->buf_index]);
}
ioucmd->cmd_op = READ_ONCE(sqe->cmd_op);