io_uring: let IORING_OP_FILES_UPDATE support choosing fixed file slots
authorXiaoguang Wang <xiaoguang.wang@linux.alibaba.com>
Mon, 30 May 2022 13:15:20 +0000 (21:15 +0800)
committerJens Axboe <axboe@kernel.dk>
Tue, 31 May 2022 08:50:06 +0000 (02:50 -0600)
commita7c41b4687f5902af70cd559806990930c8a307b
treed0fc3d8c3d4ac2bcccdf6065f770be66b71653b5
parent4278a0deb1f6cac40ded3362fe2a9827d7efee3d
io_uring: let IORING_OP_FILES_UPDATE support choosing fixed file slots

One big issue with the file registration feature is that it needs user
space apps to maintain free slot info about io_uring's fixed file table,
which really is a burden for development. io_uring now supports choosing
free file slot for user space apps by using IORING_FILE_INDEX_ALLOC flag
in accept, open, and socket operations, but they need the app to use
direct accept or direct open, which not all apps are prepared to use yet.

To support apps that still need real fds, make use of the registration
feature easier. Let IORING_OP_FILES_UPDATE support choosing fixed file
slots, which will store picked fixed files slots in fd array and let cqe
return the number of slots allocated.

Suggested-by: Hao Xu <howeyxu@tencent.com>
Signed-off-by: Xiaoguang Wang <xiaoguang.wang@linux.alibaba.com>
[axboe: move flag to uapi io_uring header, change goto to break, init]
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io_uring.c
include/uapi/linux/io_uring.h