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>,
Amir Goldstein <amir73il@gmail.com>,
chuck.lever@oracle.com, jlayton@kernel.org
Subject: [PATCH 07/10] exportfs: new FILEID_CACHED flag for non-blocking fh lookup
Date: Wed, 10 Sep 2025 15:49:24 -0600 [thread overview]
Message-ID: <20250910214927.480316-8-tahbertschinger@gmail.com> (raw)
In-Reply-To: <20250910214927.480316-1-tahbertschinger@gmail.com>
This defines a new flag FILEID_CACHED that the VFS can set in the
handle_type field of struct file_handle to request that the FS
implementations of fh_to_{dentry,parent}() only complete if they can
satisfy the request with cached data.
Because not every FS implementation will recognize this new flag, those
that do recognize the flag can indicate their support using a new
export flag, EXPORT_OP_NONBLOCK.
If FILEID_CACHED is set in a file handle, but the filesystem does not
set EXPORT_OP_NONBLOCK, then the VFS will return -EAGAIN without
attempting to call into the filesystem code.
exportfs_decode_fh_raw() is updated to respect the new flag by returning
-EAGAIN when it would need to do an operation that may not be possible
with only cached data.
Suggested-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Thomas Bertschinger <tahbertschinger@gmail.com>
---
fs/exportfs/expfs.c | 13 +++++++++++++
fs/fhandle.c | 2 ++
include/linux/exportfs.h | 5 +++++
3 files changed, 20 insertions(+)
diff --git a/fs/exportfs/expfs.c b/fs/exportfs/expfs.c
index 949ce6ef6c4e..88418b93abbf 100644
--- a/fs/exportfs/expfs.c
+++ b/fs/exportfs/expfs.c
@@ -441,6 +441,7 @@ exportfs_decode_fh_raw(struct vfsmount *mnt, struct fid *fid, int fh_len,
void *context)
{
const struct export_operations *nop = mnt->mnt_sb->s_export_op;
+ bool decode_cached = fileid_type & FILEID_CACHED;
struct dentry *result, *alias;
char nbuf[NAME_MAX+1];
int err;
@@ -453,6 +454,10 @@ exportfs_decode_fh_raw(struct vfsmount *mnt, struct fid *fid, int fh_len,
*/
if (!exportfs_can_decode_fh(nop))
return ERR_PTR(-ESTALE);
+
+ if (decode_cached && !(nop->flags & EXPORT_OP_NONBLOCK))
+ return ERR_PTR(-EAGAIN);
+
result = nop->fh_to_dentry(mnt->mnt_sb, fid, fh_len, fileid_type);
if (IS_ERR_OR_NULL(result))
return result;
@@ -481,6 +486,10 @@ exportfs_decode_fh_raw(struct vfsmount *mnt, struct fid *fid, int fh_len,
* filesystem root.
*/
if (result->d_flags & DCACHE_DISCONNECTED) {
+ err = -EAGAIN;
+ if (decode_cached)
+ goto err_result;
+
err = reconnect_path(mnt, result, nbuf);
if (err)
goto err_result;
@@ -526,6 +535,10 @@ exportfs_decode_fh_raw(struct vfsmount *mnt, struct fid *fid, int fh_len,
err = PTR_ERR(target_dir);
if (IS_ERR(target_dir))
goto err_result;
+ err = -EAGAIN;
+ if (decode_cached & (target_dir->d_flags & DCACHE_DISCONNECTED)) {
+ goto err_result;
+ }
/*
* And as usual we need to make sure the parent directory is
diff --git a/fs/fhandle.c b/fs/fhandle.c
index 276c16454eb7..70e265f6a3ab 100644
--- a/fs/fhandle.c
+++ b/fs/fhandle.c
@@ -273,6 +273,8 @@ static int do_handle_to_path(struct file_handle *handle, struct path *path,
if (IS_ERR_OR_NULL(dentry)) {
if (dentry == ERR_PTR(-ENOMEM))
return -ENOMEM;
+ if (dentry == ERR_PTR(-EAGAIN))
+ return -EAGAIN;
return -ESTALE;
}
path->dentry = dentry;
diff --git a/include/linux/exportfs.h b/include/linux/exportfs.h
index 30a9791d88e0..8238b6f67956 100644
--- a/include/linux/exportfs.h
+++ b/include/linux/exportfs.h
@@ -199,6 +199,8 @@ struct handle_to_path_ctx {
#define FILEID_FS_FLAGS_MASK 0xff00
#define FILEID_FS_FLAGS(flags) ((flags) & FILEID_FS_FLAGS_MASK)
+#define FILEID_CACHED 0x100 /* Use only cached data when decoding handle */
+
/* User flags: */
#define FILEID_USER_FLAGS_MASK 0xffff0000
#define FILEID_USER_FLAGS(type) ((type) & FILEID_USER_FLAGS_MASK)
@@ -303,6 +305,9 @@ struct export_operations {
*/
#define EXPORT_OP_FLUSH_ON_CLOSE (0x20) /* fs flushes file data on close */
#define EXPORT_OP_NOLOCKS (0x40) /* no file locking support */
+#define EXPORT_OP_NONBLOCK (0x80) /* Filesystem supports non-
+ blocking fh_to_dentry()
+ */
unsigned long flags;
};
--
2.51.0
next prev parent reply other threads:[~2025-09-10 21:47 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
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 01/10] fhandle: create helper for name_to_handle_at(2) Thomas Bertschinger
2025-09-11 12:06 ` Amir Goldstein
2025-09-10 21:49 ` [PATCH 02/10] io_uring: add support for IORING_OP_NAME_TO_HANDLE_AT Thomas Bertschinger
2025-09-10 21:49 ` [PATCH 03/10] fhandle: helper for allocating, reading struct file_handle Thomas Bertschinger
2025-09-11 12:15 ` Amir Goldstein
2025-09-11 15:31 ` Thomas Bertschinger
2025-09-11 15:54 ` Amir Goldstein
2025-09-10 21:49 ` [PATCH 04/10] fhandle: create do_filp_path_open() helper Thomas Bertschinger
2025-09-11 0:53 ` Al Viro
2025-09-11 12:21 ` Amir Goldstein
2025-09-10 21:49 ` [PATCH 05/10] fhandle: make do_filp_path_open() take struct open_flags Thomas Bertschinger
2025-09-10 21:49 ` [PATCH 06/10] exportfs: allow VFS flags in struct file_handle Thomas Bertschinger
2025-09-11 12:24 ` Amir Goldstein
2025-09-10 21:49 ` Thomas Bertschinger [this message]
2025-09-11 12:31 ` [PATCH 07/10] exportfs: new FILEID_CACHED flag for non-blocking fh lookup Amir Goldstein
2025-09-12 8:21 ` Dan Carpenter
2025-09-10 21:49 ` [PATCH 08/10] io_uring: add __io_open_prep() helper Thomas Bertschinger
2025-09-10 21:49 ` [PATCH 09/10] io_uring: add support for IORING_OP_OPEN_BY_HANDLE_AT 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
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=20250910214927.480316-8-tahbertschinger@gmail.com \
--to=tahbertschinger@gmail.com \
--cc=amir73il@gmail.com \
--cc=axboe@kernel.dk \
--cc=brauner@kernel.org \
--cc=chuck.lever@oracle.com \
--cc=io-uring@vger.kernel.org \
--cc=jlayton@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