2024-03-15 17:04:25

by Jeffrey Layton

[permalink] [raw]
Subject: [PATCH RFC 22/24] nfs: skip dentry revalidation when parent dir has a delegation

If the parent has a valid delegation, then test whether the
dentry->d_time matches the current change attr on the directory. If it
does, then we can declare the dentry valid with no further checks.

Signed-off-by: Jeff Layton <[email protected]>
---
fs/nfs/dir.c | 12 ++++++++++++
1 file changed, 12 insertions(+)

diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index ac505671efbd..061648c73116 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -2188,6 +2188,15 @@ int nfs_atomic_open(struct inode *dir, struct dentry *dentry,
}
EXPORT_SYMBOL_GPL(nfs_atomic_open);

+static int
+nfs_lookup_revalidate_delegated_parent(struct inode *dir, struct dentry *dentry,
+ struct inode *inode)
+{
+ return nfs_lookup_revalidate_done(dir, dentry, inode,
+ nfs_verify_change_attribute(dir, dentry->d_time) ?
+ 1 : 0);
+}
+
static int
nfs4_do_lookup_revalidate(struct inode *dir, struct dentry *dentry,
unsigned int flags)
@@ -2212,6 +2221,9 @@ nfs4_do_lookup_revalidate(struct inode *dir, struct dentry *dentry,
if (nfs_verifier_is_delegated(dentry))
return nfs_lookup_revalidate_delegated(dir, dentry, inode);

+ if (nfs_have_delegated_attributes(dir))
+ return nfs_lookup_revalidate_delegated_parent(dir, dentry, inode);
+
/* NFS only supports OPEN on regular files */
if (!S_ISREG(inode->i_mode))
goto full_reval;

--
2.44.0