From: Thomas Bertschinger <tahbertschinger@gmail.com>
To: io-uring@vger.kernel.org, axboe@kernel.dk,
linux-fsdevel@vger.kernel.org, viro@zeniv.linux.org.uk,
brauner@kernel.org, linux-nfs@vger.kernel.org
Cc: Thomas Bertschinger <tahbertschinger@gmail.com>
Subject: [PATCHSET RFC 0/6] add support for name_to, open_by_handle_at(2) to io_uring
Date: Thu, 14 Aug 2025 17:54:25 -0600 [thread overview]
Message-ID: <20250814235431.995876-1-tahbertschinger@gmail.com> (raw)
This series adds support for name_to_handle_at() and open_by_handle_at()
to io_uring. The idea is for these opcodes to be useful for userspace
NFS servers that want to use io_uring.
name_to_handle_at()
===================
Support for name_to_handle_at() is added in patches 1 and 2.
In order to do a non-blocking name_to_handle_at(), a new helper
do_name_to_handle_at() is created that takes a lookup_flags argument.
This is to support non-blocking lookup when called with
IO_URING_F_NONBLOCK--user_path_at() will be called with LOOKUP_CACHED
in that case.
Aside from the lookup, I don't think there is anything else that
do_name_to_handle_at() does that would be a problem in the non-blocking
case. There is a GFP_KERNEL allocation:
do_name_to_handle_at()
-> do_path_to_handle()
-> kzalloc(..., GFP_KERNEL)
But I think that's OK? Let me know if there's anything else I'm
missing...
open_by_handle_at()
===================
Patch 3 is a fixup to fhandle.c:do_handle_open() that (I believe) fixes
a bug and can exist independently of this series, but it fits in with
these changes so I'm including it here.
Support for open_by_handle_at() is added in patches 4 - 6.
A helper __do_handle_open() is created that does the file open without
installing a file descriptor for it. This is needed because io_uring
needs to decide between using a file descriptor or a fixed file.
No attempt is made to support a non-blocking open_by_handle_at()--the
attempt is always immediately returned with -EAGAIN if
IO_URING_F_NONBLOCK is set.
This isn't ideal and it would be nice to add support for non-blocking
open by handle in the future. This would presumably require updates to
the ->encode_fh() implementation for filesystems that want to
support this.
I see that lack of support for non-blocking operation was a dealbreaker
for adding getdents to io_uring previously:
https://lore.kernel.org/io-uring/20230428050640.GA1969623@dread.disaster.area/
On the other hand, AFAICT, support for openat() was originally added in
15b71abe7b52 (io_uring: add support for IORING_OP_OPENAT) without a non-
blocking lookup, and the possibility of non-blocking lookup later added
in 3a81fd02045c (io_uring: enable LOOKUP_CACHED path resolution for
filename lookups).
(To be honest I'm a little confused by the history here. The commit
message of 15b71abe7b52 says
> For the normal case of a non-blocking path lookup this will complete
> inline. If we have to do IO to perform the open, it'll be done from
> async context.
but from the commit contents this would NOT appear to be the case:
> + if (force_nonblock) {
> + req->work.flags |= IO_WQ_WORK_NEEDS_FILES;
> + return -EAGAIN;
> + }
until the support is really added in the later commit. Am I confused or
is the commit message wrong?)
In any event, based on my reading of the history, it would appear to be
OK to add open_by_handle_at() initially without support for inline
completion, and then later add that when the filesystem implementations
can be updated to support this.
Please let me know if I am wrong on my interpretation of the history or
if anyone disagrees with the conclusion.
Testing
=======
A liburing branch that includes support for the new opcodes, as well as
a test, is available at:
https://github.com/bertschingert/liburing/tree/open_by_handle_at
To run the test:
$ ./test/open_by_handle_at.t
Thomas Bertschinger (6):
fhandle: create helper for name_to_handle_at(2)
io_uring: add support for IORING_OP_NAME_TO_HANDLE_AT
fhandle: do_handle_open() should get FD with user flags
fhandle: create __do_handle_open() helper
io_uring: add __io_open_prep() helper
io_uring: add support for IORING_OP_OPEN_BY_HANDLE_AT
fs/fhandle.c | 85 ++++++++++++---------
fs/internal.h | 9 +++
include/uapi/linux/io_uring.h | 2 +
io_uring/opdef.c | 14 ++++
io_uring/openclose.c | 137 +++++++++++++++++++++++++++++++---
io_uring/openclose.h | 5 ++
6 files changed, 209 insertions(+), 43 deletions(-)
--
2.50.1
next reply other threads:[~2025-08-14 23:50 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-14 23:54 Thomas Bertschinger [this message]
2025-08-14 23:54 ` [PATCH 1/6] fhandle: create helper for name_to_handle_at(2) Thomas Bertschinger
2025-08-15 10:21 ` Amir Goldstein
2025-08-15 18:17 ` Thomas Bertschinger
2025-08-14 23:54 ` [PATCH 2/6] io_uring: add support for IORING_OP_NAME_TO_HANDLE_AT Thomas Bertschinger
2025-08-15 10:40 ` Amir Goldstein
2025-08-16 7:43 ` kernel test robot
2025-08-14 23:54 ` [PATCH 3/6] fhandle: do_handle_open() should get FD with user flags Thomas Bertschinger
2025-08-15 9:17 ` Amir Goldstein
2025-08-15 13:46 ` Christian Brauner
2025-08-15 13:51 ` Amir Goldstein
2025-08-19 9:43 ` Christian Brauner
2025-08-15 13:47 ` (subset) " Christian Brauner
2025-08-14 23:54 ` [PATCH 4/6] fhandle: create __do_handle_open() helper Thomas Bertschinger
2025-08-15 10:33 ` Amir Goldstein
2025-08-14 23:54 ` [PATCH 5/6] io_uring: add __io_open_prep() helper Thomas Bertschinger
2025-08-14 23:54 ` [PATCH 6/6] io_uring: add support for IORING_OP_OPEN_BY_HANDLE_AT Thomas Bertschinger
2025-08-16 10:10 ` kernel test robot
2025-08-15 9:52 ` [PATCHSET RFC 0/6] add support for name_to, open_by_handle_at(2) to io_uring Amir Goldstein
2025-08-15 18:24 ` Thomas Bertschinger
2025-08-19 15:11 ` Jens Axboe
2025-08-20 3:01 ` Thomas Bertschinger
2025-08-20 8:34 ` Amir Goldstein
2025-08-20 15:05 ` Thomas Bertschinger
2025-08-20 19:58 ` Amir Goldstein
2025-08-21 7:47 ` Christian Brauner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250814235431.995876-1-tahbertschinger@gmail.com \
--to=tahbertschinger@gmail.com \
--cc=axboe@kernel.dk \
--cc=brauner@kernel.org \
--cc=io-uring@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox