在 2022/5/9 上午7:49, Jens Axboe 写道:
Hi, Currently using direct descriptors with open or accept requires the application to manage the descriptor space, picking which slot to use for any given file. However, there are cases where it's useful to just get a direct descriptor and not care about which value it is, instead just return it like a normal open or accept would. This will also be useful for multishot accept support, where allocated direct descriptors are a requirement to make that feature work with these kinds of files. This adds support for allocating a new fixed descriptor. This is chosen by passing in UINT_MAX as the fixed slot, which otherwise has a limit of INT_MAX like any file descriptor does. fs/io_uring.c | 100 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 94 insertions(+), 6 deletions(-)
Hi Jens, I've read this idea of leveraging bitmap, it looks great. a small flaw of it is that when the file_table is very long, the bitmap searching seems to be O({length of table}/BITS_PER_LONG), to make the time complexity stable, I did a linked list version, could you have a look when you're avalible. totally untested, just to show my idea. Basically I use a list to link all the free slots, when we need a slot, just get the head of it. https://github.com/HowHsu/linux/commits/for-5.19/io_uring_multishot_accept_v5 (borrowed some commit message from your patches) Thanks, Hao