io_uring: refactor rsrc refnode allocation
authorPavel Begunkov <asml.silence@gmail.com>
Fri, 19 Mar 2021 17:22:36 +0000 (17:22 +0000)
committerJens Axboe <axboe@kernel.dk>
Mon, 22 Mar 2021 13:42:50 +0000 (07:42 -0600)
commit8179a85ebf5ccc415b221faaa71a79bb2ec5a7f6
tree4d470e4ca75865a1c857fb23920a0f28b0685670
parent2b3cde03e323a729db1bf79dc12ec69a16331ec3
io_uring: refactor rsrc refnode allocation

There are two problems:
1) we always allocate refnodes in advance and free them if those
haven't been used. It's expensive, takes two allocations, where one of
them is percpu. And it may be pretty common not actually using them.

2) Current API with allocating a refnode and setting some of the fields
is error prone, we don't ever want to have a file node runninng fixed
buffer callback...

Solve both with pre-init/get API. Pre-init just leaves the node for
later if not used, and for get (i.e. io_rsrc_refnode_get()), you need to
explicitly pass all arguments setting callbacks/etc., so it's more
resilient.

Signed-off-by: Pavel Begunkov <asml.silence@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io_uring.c