diff options
author | Jens Axboe <axboe@kernel.dk> | 2022-05-07 10:08:31 -0600 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2022-05-09 06:29:53 -0600 |
commit | e721cdc172fd3aa845e4a0850cb5f9aefd8f3591 (patch) | |
tree | d86a2e4f2bb9176b2d1b276af3785e89c158d487 | |
parent | 0db0570a9f51b75693b0e9c7553be004521abceb (diff) |
io_uring: allow allocated fixed files for acceptfastpoll-mshot
If the applications passes in UINT_MAX as the file_slot, then that's a
hint to allocate a fixed file descriptor rather than have one be passed
in directly.
This can be useful for having io_uring manage the direct descriptor space,
and also allows multi-shot support to work with fixed files.
Normal accept direct requests will complete with 0 for success, and < 0
in case of error. If io_uring is asked to allocated the direct descriptor,
then the direct descriptor is returned in case of success.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r-- | fs/io_uring.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c index 5faff07a109b..a0ad67bcfe98 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -5772,9 +5772,13 @@ static int io_accept_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) return -EINVAL; accept->file_slot = READ_ONCE(sqe->file_index); - if (accept->file_slot && ((accept->flags & SOCK_CLOEXEC) || - flags & IORING_ACCEPT_MULTISHOT)) - return -EINVAL; + if (accept->file_slot) { + if (accept->flags & SOCK_CLOEXEC) + return -EINVAL; + if (accept->file_slot != UINT_MAX && + req->flags & IORING_ACCEPT_MULTISHOT) + return -EINVAL; + } if (accept->flags & ~(SOCK_CLOEXEC | SOCK_NONBLOCK)) return -EINVAL; if (SOCK_NONBLOCK != O_NONBLOCK && (accept->flags & SOCK_NONBLOCK)) @@ -5838,8 +5842,8 @@ retry: fd_install(fd, file); ret = fd; } else { - ret = io_install_fixed_file(req, file, issue_flags, - accept->file_slot - 1); + ret = io_fixed_file_install(req, issue_flags, file, + accept->file_slot); } if (!(req->flags & REQ_F_APOLL_MULTISHOT)) { |