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>
Sun, 4 Apr 2021 21:27:22 +0000 (15:27 -0600)
commit89a022d156fc5b967e0ac6b144ecc508bfc04030
tree3c89cd14d200289f8a41e01f309cc2922d672695
parentff2da7b795c04e3e755e6dd57172604c13712549
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