* [PATCHSET RFC v2 00/10] add support for name_to, open_by_handle_at() to io_uring @ 2025-09-10 21:49 Thomas Bertschinger 2025-09-10 21:49 ` [PATCH 10/10] xfs: add support for non-blocking fh_to_dentry() Thomas Bertschinger 0 siblings, 1 reply; 7+ messages in thread From: Thomas Bertschinger @ 2025-09-10 21:49 UTC (permalink / raw) To: io-uring, axboe, linux-fsdevel, viro, brauner, linux-nfs Cc: Thomas Bertschinger, linux-xfs, cem, chuck.lever, jlayton 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. The biggest change since [v1] is that this adds support for attempting non-blocking open_by_handle_at(). When io_uring calls handle_to_path(), it will set a flag to request that the call return -EAGAIN if it cannot complete using cached data. The same holds for the call to do_filp_path_open(). Supporting this for handle_to_path() requires a way to communicate to the filesystem that it should not block in its fh_to_dentry() implementation. This is done with a new flag FILEID_CACHED which is set in the file handle by the VFS. If a filesystem supports this new flag, it will indicate that with a new flag EXPORT_OP_NONBLOCK so that the VFS knows not to call into a filesystem with the FILEID_CACHED flag, when the FS does not know about that flag. Support for the new FILEID_CACHED flag is added for xfs. Thanks to Amir Goldstein for the review comments and suggesting this approach on v1. Testing ======= As in v1, a liburing branch with a test is available at https://github.com/bertschingert/liburing/tree/open_by_handle_at and is run with $ ./test/open_by_handle_at.t v1 -> v2: - rename some new helper functions: - do_name_to_handle_at() -> do_sys_name_to_handle_at() - __do_handle_open() -> do_filp_path_open() - create a union member name_to_handle_flags in struct io_uring_sqe - add new FILEID_CACHED and EXPORT_OP_NONBLOCK flags - attempt non-blocking open_by_handle_at() in io_uring first, rather than always giving up and running in async context - add support for FILEID_CACHED in xfs [v1] https://lore.kernel.org/linux-fsdevel/20250814235431.995876-1-tahbertschinger@gmail.com/ Thomas Bertschinger (10): fhandle: create helper for name_to_handle_at(2) io_uring: add support for IORING_OP_NAME_TO_HANDLE_AT fhandle: helper for allocating, reading struct file_handle fhandle: create do_filp_path_open() helper fhandle: make do_filp_path_open() take struct open_flags exportfs: allow VFS flags in struct file_handle exportfs: new FILEID_CACHED flag for non-blocking fh lookup io_uring: add __io_open_prep() helper io_uring: add support for IORING_OP_OPEN_BY_HANDLE_AT xfs: add support for non-blocking fh_to_dentry() fs/exportfs/expfs.c | 15 ++- fs/fhandle.c | 156 ++++++++++++++++----------- fs/internal.h | 13 +++ fs/xfs/xfs_export.c | 32 ++++-- fs/xfs/xfs_export.h | 3 +- fs/xfs/xfs_handle.c | 2 +- include/linux/exportfs.h | 34 +++++- include/uapi/linux/io_uring.h | 3 + io_uring/opdef.c | 26 +++++ io_uring/openclose.c | 191 ++++++++++++++++++++++++++++++++-- io_uring/openclose.h | 13 +++ 11 files changed, 405 insertions(+), 83 deletions(-) base-commit: 76eeb9b8de9880ca38696b2fb56ac45ac0a25c6c -- 2.51.0 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 10/10] xfs: add support for non-blocking fh_to_dentry() 2025-09-10 21:49 [PATCHSET RFC v2 00/10] add support for name_to, open_by_handle_at() to io_uring Thomas Bertschinger @ 2025-09-10 21:49 ` Thomas Bertschinger 2025-09-11 12:29 ` Christoph Hellwig 2025-09-11 12:38 ` Amir Goldstein 0 siblings, 2 replies; 7+ messages in thread From: Thomas Bertschinger @ 2025-09-10 21:49 UTC (permalink / raw) To: io-uring, axboe, linux-fsdevel, viro, brauner, linux-nfs Cc: Thomas Bertschinger, linux-xfs, cem This is to support using open_by_handle_at(2) via io_uring. It is useful for io_uring to request that opening a file via handle be completed using only cached data, or fail with -EAGAIN if that is not possible. The signature of xfs_nfs_get_inode() is extended with a new flags argument that allows callers to specify XFS_IGET_INCORE. That flag is set when the VFS passes the FILEID_CACHED flag via the fileid_type argument. Signed-off-by: Thomas Bertschinger <tahbertschinger@gmail.com> --- fs/xfs/xfs_export.c | 32 ++++++++++++++++++++++++++------ fs/xfs/xfs_export.h | 3 ++- fs/xfs/xfs_handle.c | 2 +- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/fs/xfs/xfs_export.c b/fs/xfs/xfs_export.c index 201489d3de08..ca2a9ed0eb16 100644 --- a/fs/xfs/xfs_export.c +++ b/fs/xfs/xfs_export.c @@ -106,7 +106,8 @@ struct inode * xfs_nfs_get_inode( struct super_block *sb, u64 ino, - u32 generation) + u32 generation, + uint flags) { xfs_mount_t *mp = XFS_M(sb); xfs_inode_t *ip; @@ -123,7 +124,9 @@ xfs_nfs_get_inode( * fine and not an indication of a corrupted filesystem as clients can * send invalid file handles and we have to handle it gracefully.. */ - error = xfs_iget(mp, NULL, ino, XFS_IGET_UNTRUSTED, 0, &ip); + flags |= XFS_IGET_UNTRUSTED; + + error = xfs_iget(mp, NULL, ino, flags, 0, &ip); if (error) { /* @@ -140,6 +143,10 @@ xfs_nfs_get_inode( case -EFSCORRUPTED: error = -ESTALE; break; + case -ENODATA: + if (flags & XFS_IGET_INCORE) + error = -EAGAIN; + break; default: break; } @@ -174,6 +181,12 @@ xfs_fs_fh_to_dentry(struct super_block *sb, struct fid *fid, { struct xfs_fid64 *fid64 = (struct xfs_fid64 *)fid; struct inode *inode = NULL; + uint flags = 0; + + if (fileid_type & FILEID_CACHED) + flags = XFS_IGET_INCORE; + + fileid_type = FILEID_TYPE(fileid_type); if (fh_len < xfs_fileid_length(fileid_type)) return NULL; @@ -181,11 +194,11 @@ xfs_fs_fh_to_dentry(struct super_block *sb, struct fid *fid, switch (fileid_type) { case FILEID_INO32_GEN_PARENT: case FILEID_INO32_GEN: - inode = xfs_nfs_get_inode(sb, fid->i32.ino, fid->i32.gen); + inode = xfs_nfs_get_inode(sb, fid->i32.ino, fid->i32.gen, flags); break; case FILEID_INO32_GEN_PARENT | XFS_FILEID_TYPE_64FLAG: case FILEID_INO32_GEN | XFS_FILEID_TYPE_64FLAG: - inode = xfs_nfs_get_inode(sb, fid64->ino, fid64->gen); + inode = xfs_nfs_get_inode(sb, fid64->ino, fid64->gen, flags); break; } @@ -198,6 +211,12 @@ xfs_fs_fh_to_parent(struct super_block *sb, struct fid *fid, { struct xfs_fid64 *fid64 = (struct xfs_fid64 *)fid; struct inode *inode = NULL; + uint flags = 0; + + if (fileid_type & FILEID_CACHED) + flags = XFS_IGET_INCORE; + + fileid_type = FILEID_TYPE(fileid_type); if (fh_len < xfs_fileid_length(fileid_type)) return NULL; @@ -205,11 +224,11 @@ xfs_fs_fh_to_parent(struct super_block *sb, struct fid *fid, switch (fileid_type) { case FILEID_INO32_GEN_PARENT: inode = xfs_nfs_get_inode(sb, fid->i32.parent_ino, - fid->i32.parent_gen); + fid->i32.parent_gen, flags); break; case FILEID_INO32_GEN_PARENT | XFS_FILEID_TYPE_64FLAG: inode = xfs_nfs_get_inode(sb, fid64->parent_ino, - fid64->parent_gen); + fid64->parent_gen, flags); break; } @@ -248,4 +267,5 @@ const struct export_operations xfs_export_operations = { .map_blocks = xfs_fs_map_blocks, .commit_blocks = xfs_fs_commit_blocks, #endif + .flags = EXPORT_OP_NONBLOCK, }; diff --git a/fs/xfs/xfs_export.h b/fs/xfs/xfs_export.h index 3cd85e8901a5..9addfcd5b1e1 100644 --- a/fs/xfs/xfs_export.h +++ b/fs/xfs/xfs_export.h @@ -57,6 +57,7 @@ struct xfs_fid64 { /* This flag goes on the wire. Don't play with it. */ #define XFS_FILEID_TYPE_64FLAG 0x80 /* NFS fileid has 64bit inodes */ -struct inode *xfs_nfs_get_inode(struct super_block *sb, u64 ino, u32 gen); +struct inode *xfs_nfs_get_inode(struct super_block *sb, u64 ino, u32 gen, + uint flags); #endif /* __XFS_EXPORT_H__ */ diff --git a/fs/xfs/xfs_handle.c b/fs/xfs/xfs_handle.c index f19fce557354..7d877ff504d6 100644 --- a/fs/xfs/xfs_handle.c +++ b/fs/xfs/xfs_handle.c @@ -193,7 +193,7 @@ xfs_khandle_to_inode( return ERR_PTR(-EINVAL); inode = xfs_nfs_get_inode(mp->m_super, handle->ha_fid.fid_ino, - handle->ha_fid.fid_gen); + handle->ha_fid.fid_gen, 0); if (IS_ERR(inode)) return ERR_CAST(inode); -- 2.51.0 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 10/10] xfs: add support for non-blocking fh_to_dentry() 2025-09-10 21:49 ` [PATCH 10/10] xfs: add support for non-blocking fh_to_dentry() Thomas Bertschinger @ 2025-09-11 12:29 ` Christoph Hellwig 2025-09-11 12:39 ` Amir Goldstein 2025-09-11 12:38 ` Amir Goldstein 1 sibling, 1 reply; 7+ messages in thread From: Christoph Hellwig @ 2025-09-11 12:29 UTC (permalink / raw) To: Thomas Bertschinger Cc: io-uring, axboe, linux-fsdevel, viro, brauner, linux-nfs, linux-xfs, cem On Wed, Sep 10, 2025 at 03:49:27PM -0600, Thomas Bertschinger wrote: > This is to support using open_by_handle_at(2) via io_uring. It is useful > for io_uring to request that opening a file via handle be completed > using only cached data, or fail with -EAGAIN if that is not possible. > > The signature of xfs_nfs_get_inode() is extended with a new flags > argument that allows callers to specify XFS_IGET_INCORE. > > That flag is set when the VFS passes the FILEID_CACHED flag via the > fileid_type argument. Please post the entire series to all list. No one has any idea what your magic new flag does without seeing all the patches. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 10/10] xfs: add support for non-blocking fh_to_dentry() 2025-09-11 12:29 ` Christoph Hellwig @ 2025-09-11 12:39 ` Amir Goldstein 2025-09-11 15:15 ` Thomas Bertschinger 0 siblings, 1 reply; 7+ messages in thread From: Amir Goldstein @ 2025-09-11 12:39 UTC (permalink / raw) To: Christoph Hellwig Cc: Thomas Bertschinger, io-uring, axboe, linux-fsdevel, viro, brauner, linux-nfs, linux-xfs, cem On Thu, Sep 11, 2025 at 2:29 PM Christoph Hellwig <hch@infradead.org> wrote: > > On Wed, Sep 10, 2025 at 03:49:27PM -0600, Thomas Bertschinger wrote: > > This is to support using open_by_handle_at(2) via io_uring. It is useful > > for io_uring to request that opening a file via handle be completed > > using only cached data, or fail with -EAGAIN if that is not possible. > > > > The signature of xfs_nfs_get_inode() is extended with a new flags > > argument that allows callers to specify XFS_IGET_INCORE. > > > > That flag is set when the VFS passes the FILEID_CACHED flag via the > > fileid_type argument. > > Please post the entire series to all list. No one has any idea what your > magic new flag does without seeing all the patches. > Might as well re-post your entire v2 patches with v2 subjects and cc xfs list. Thanks, Amir. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 10/10] xfs: add support for non-blocking fh_to_dentry() 2025-09-11 12:39 ` Amir Goldstein @ 2025-09-11 15:15 ` Thomas Bertschinger 2025-09-11 15:16 ` Amir Goldstein 0 siblings, 1 reply; 7+ messages in thread From: Thomas Bertschinger @ 2025-09-11 15:15 UTC (permalink / raw) To: Amir Goldstein, Christoph Hellwig Cc: Thomas Bertschinger, io-uring, axboe, linux-fsdevel, viro, brauner, linux-nfs, linux-xfs, cem On Thu Sep 11, 2025 at 6:39 AM MDT, Amir Goldstein wrote: > On Thu, Sep 11, 2025 at 2:29 PM Christoph Hellwig <hch@infradead.org> wrote: >> >> On Wed, Sep 10, 2025 at 03:49:27PM -0600, Thomas Bertschinger wrote: >> > This is to support using open_by_handle_at(2) via io_uring. It is useful >> > for io_uring to request that opening a file via handle be completed >> > using only cached data, or fail with -EAGAIN if that is not possible. >> > >> > The signature of xfs_nfs_get_inode() is extended with a new flags >> > argument that allows callers to specify XFS_IGET_INCORE. >> > >> > That flag is set when the VFS passes the FILEID_CACHED flag via the >> > fileid_type argument. >> >> Please post the entire series to all list. No one has any idea what your >> magic new flag does without seeing all the patches. >> > > Might as well re-post your entire v2 patches with v2 subjects and > cc xfs list. > > Thanks, > Amir. Thanks for the advice, sorry for messing up the procedure... Since there are a few quick fixups I can make, I may go straight to sending v3 with the correct subject and cc. Any reason for me to not do that -- is it preferable to resend v2 right away with no changes? ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 10/10] xfs: add support for non-blocking fh_to_dentry() 2025-09-11 15:15 ` Thomas Bertschinger @ 2025-09-11 15:16 ` Amir Goldstein 0 siblings, 0 replies; 7+ messages in thread From: Amir Goldstein @ 2025-09-11 15:16 UTC (permalink / raw) To: Thomas Bertschinger Cc: Christoph Hellwig, io-uring, axboe, linux-fsdevel, viro, brauner, linux-nfs, linux-xfs, cem On Thu, Sep 11, 2025 at 5:10 PM Thomas Bertschinger <tahbertschinger@gmail.com> wrote: > > On Thu Sep 11, 2025 at 6:39 AM MDT, Amir Goldstein wrote: > > On Thu, Sep 11, 2025 at 2:29 PM Christoph Hellwig <hch@infradead.org> wrote: > >> > >> On Wed, Sep 10, 2025 at 03:49:27PM -0600, Thomas Bertschinger wrote: > >> > This is to support using open_by_handle_at(2) via io_uring. It is useful > >> > for io_uring to request that opening a file via handle be completed > >> > using only cached data, or fail with -EAGAIN if that is not possible. > >> > > >> > The signature of xfs_nfs_get_inode() is extended with a new flags > >> > argument that allows callers to specify XFS_IGET_INCORE. > >> > > >> > That flag is set when the VFS passes the FILEID_CACHED flag via the > >> > fileid_type argument. > >> > >> Please post the entire series to all list. No one has any idea what your > >> magic new flag does without seeing all the patches. > >> > > > > Might as well re-post your entire v2 patches with v2 subjects and > > cc xfs list. > > > > Thanks, > > Amir. > > > Thanks for the advice, sorry for messing up the procedure... > > Since there are a few quick fixups I can make, I may go straight to > sending v3 with the correct subject and cc. Any reason for me to not do > that -- is it preferable to resend v2 right away with no changes? No worries. v3 is fine. But maybe give it a day or two for other people to comment on v2 before posting v3. Some people may even be mid review of v2 and that can be a bit annoying to get v3 while in the middle of review of v2. Thanks, Amir. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 10/10] xfs: add support for non-blocking fh_to_dentry() 2025-09-10 21:49 ` [PATCH 10/10] xfs: add support for non-blocking fh_to_dentry() Thomas Bertschinger 2025-09-11 12:29 ` Christoph Hellwig @ 2025-09-11 12:38 ` Amir Goldstein 1 sibling, 0 replies; 7+ messages in thread From: Amir Goldstein @ 2025-09-11 12:38 UTC (permalink / raw) To: Thomas Bertschinger Cc: io-uring, axboe, linux-fsdevel, viro, brauner, linux-nfs, linux-xfs, cem On Wed, Sep 10, 2025 at 11:48 PM Thomas Bertschinger <tahbertschinger@gmail.com> wrote: > > This is to support using open_by_handle_at(2) via io_uring. It is useful > for io_uring to request that opening a file via handle be completed > using only cached data, or fail with -EAGAIN if that is not possible. > > The signature of xfs_nfs_get_inode() is extended with a new flags > argument that allows callers to specify XFS_IGET_INCORE. > > That flag is set when the VFS passes the FILEID_CACHED flag via the > fileid_type argument. > > Signed-off-by: Thomas Bertschinger <tahbertschinger@gmail.com> I'll let xfs developers review this, but its looks pretty straightforward, so on my part you may add: Acked-by: Amir Goldstein <amir73il@gmail.com> One small nit below > --- > fs/xfs/xfs_export.c | 32 ++++++++++++++++++++++++++------ > fs/xfs/xfs_export.h | 3 ++- > fs/xfs/xfs_handle.c | 2 +- > 3 files changed, 29 insertions(+), 8 deletions(-) > > diff --git a/fs/xfs/xfs_export.c b/fs/xfs/xfs_export.c > index 201489d3de08..ca2a9ed0eb16 100644 > --- a/fs/xfs/xfs_export.c > +++ b/fs/xfs/xfs_export.c > @@ -106,7 +106,8 @@ struct inode * > xfs_nfs_get_inode( > struct super_block *sb, > u64 ino, > - u32 generation) > + u32 generation, > + uint flags) > { > xfs_mount_t *mp = XFS_M(sb); > xfs_inode_t *ip; > @@ -123,7 +124,9 @@ xfs_nfs_get_inode( > * fine and not an indication of a corrupted filesystem as clients can > * send invalid file handles and we have to handle it gracefully.. > */ > - error = xfs_iget(mp, NULL, ino, XFS_IGET_UNTRUSTED, 0, &ip); > + flags |= XFS_IGET_UNTRUSTED; > + > + error = xfs_iget(mp, NULL, ino, flags, 0, &ip); > if (error) { > > /* > @@ -140,6 +143,10 @@ xfs_nfs_get_inode( > case -EFSCORRUPTED: > error = -ESTALE; > break; > + case -ENODATA: > + if (flags & XFS_IGET_INCORE) > + error = -EAGAIN; > + break; > default: > break; > } > @@ -174,6 +181,12 @@ xfs_fs_fh_to_dentry(struct super_block *sb, struct fid *fid, > { > struct xfs_fid64 *fid64 = (struct xfs_fid64 *)fid; > struct inode *inode = NULL; > + uint flags = 0; > + > + if (fileid_type & FILEID_CACHED) > + flags = XFS_IGET_INCORE; > + > + fileid_type = FILEID_TYPE(fileid_type); That is a smelly practice. It's better to rename the function argument to fileid_flags or fileid_type_flags and use a local fileid_type var for fileid_type = FILEID_TYPE(fileid_flags) Thanks, Amir. > > if (fh_len < xfs_fileid_length(fileid_type)) > return NULL; > @@ -181,11 +194,11 @@ xfs_fs_fh_to_dentry(struct super_block *sb, struct fid *fid, > switch (fileid_type) { > case FILEID_INO32_GEN_PARENT: > case FILEID_INO32_GEN: > - inode = xfs_nfs_get_inode(sb, fid->i32.ino, fid->i32.gen); > + inode = xfs_nfs_get_inode(sb, fid->i32.ino, fid->i32.gen, flags); > break; > case FILEID_INO32_GEN_PARENT | XFS_FILEID_TYPE_64FLAG: > case FILEID_INO32_GEN | XFS_FILEID_TYPE_64FLAG: > - inode = xfs_nfs_get_inode(sb, fid64->ino, fid64->gen); > + inode = xfs_nfs_get_inode(sb, fid64->ino, fid64->gen, flags); > break; > } > > @@ -198,6 +211,12 @@ xfs_fs_fh_to_parent(struct super_block *sb, struct fid *fid, > { > struct xfs_fid64 *fid64 = (struct xfs_fid64 *)fid; > struct inode *inode = NULL; > + uint flags = 0; > + > + if (fileid_type & FILEID_CACHED) > + flags = XFS_IGET_INCORE; > + > + fileid_type = FILEID_TYPE(fileid_type); > > if (fh_len < xfs_fileid_length(fileid_type)) > return NULL; > @@ -205,11 +224,11 @@ xfs_fs_fh_to_parent(struct super_block *sb, struct fid *fid, > switch (fileid_type) { > case FILEID_INO32_GEN_PARENT: > inode = xfs_nfs_get_inode(sb, fid->i32.parent_ino, > - fid->i32.parent_gen); > + fid->i32.parent_gen, flags); > break; > case FILEID_INO32_GEN_PARENT | XFS_FILEID_TYPE_64FLAG: > inode = xfs_nfs_get_inode(sb, fid64->parent_ino, > - fid64->parent_gen); > + fid64->parent_gen, flags); > break; > } > > @@ -248,4 +267,5 @@ const struct export_operations xfs_export_operations = { > .map_blocks = xfs_fs_map_blocks, > .commit_blocks = xfs_fs_commit_blocks, > #endif > + .flags = EXPORT_OP_NONBLOCK, > }; > diff --git a/fs/xfs/xfs_export.h b/fs/xfs/xfs_export.h > index 3cd85e8901a5..9addfcd5b1e1 100644 > --- a/fs/xfs/xfs_export.h > +++ b/fs/xfs/xfs_export.h > @@ -57,6 +57,7 @@ struct xfs_fid64 { > /* This flag goes on the wire. Don't play with it. */ > #define XFS_FILEID_TYPE_64FLAG 0x80 /* NFS fileid has 64bit inodes */ > > -struct inode *xfs_nfs_get_inode(struct super_block *sb, u64 ino, u32 gen); > +struct inode *xfs_nfs_get_inode(struct super_block *sb, u64 ino, u32 gen, > + uint flags); > > #endif /* __XFS_EXPORT_H__ */ > diff --git a/fs/xfs/xfs_handle.c b/fs/xfs/xfs_handle.c > index f19fce557354..7d877ff504d6 100644 > --- a/fs/xfs/xfs_handle.c > +++ b/fs/xfs/xfs_handle.c > @@ -193,7 +193,7 @@ xfs_khandle_to_inode( > return ERR_PTR(-EINVAL); > > inode = xfs_nfs_get_inode(mp->m_super, handle->ha_fid.fid_ino, > - handle->ha_fid.fid_gen); > + handle->ha_fid.fid_gen, 0); > if (IS_ERR(inode)) > return ERR_CAST(inode); > > -- > 2.51.0 > > ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-09-11 15:16 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2025-09-10 21:49 [PATCHSET RFC v2 00/10] add support for name_to, open_by_handle_at() to io_uring Thomas Bertschinger 2025-09-10 21:49 ` [PATCH 10/10] xfs: add support for non-blocking fh_to_dentry() Thomas Bertschinger 2025-09-11 12:29 ` Christoph Hellwig 2025-09-11 12:39 ` Amir Goldstein 2025-09-11 15:15 ` Thomas Bertschinger 2025-09-11 15:16 ` Amir Goldstein 2025-09-11 12:38 ` Amir Goldstein
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox