NFS: Fix directory delegation verifier checks

Doing this check in nfs_check_verifier() resulted in many, many more
lookups on the wire when running Christoph's delegation benchmarking
script. After some experimentation, I found that we can treat directory
delegations exactly the same as having a delegated verifier when we
reach nfs4_lookup_revalidate() for the best performance.

Reported-by: Christoph Hellwig <hch@lst.de>
Fixes: 156b094829 ("NFS: Request a directory delegation on ACCESS, CREATE, and UNLINK")
Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
This commit is contained in:
Anna Schumaker
2025-12-19 15:13:44 -05:00
committed by Trond Myklebust
parent 5a74af51c3
commit 6f9bda2337

View File

@@ -1516,14 +1516,6 @@ static int nfs_check_verifier(struct inode *dir, struct dentry *dentry,
if (!nfs_dentry_verify_change(dir, dentry))
return 0;
/*
* If we have a directory delegation then we don't need to revalidate
* the directory. The delegation will either get recalled or we will
* receive a notification when it changes.
*/
if (nfs_have_directory_delegation(dir))
return 0;
/* Revalidate nfsi->cache_change_attribute before we declare a match */
if (nfs_mapping_need_revalidate_inode(dir)) {
if (rcu_walk)
@@ -2216,13 +2208,6 @@ 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, 1);
}
static int
nfs4_lookup_revalidate(struct inode *dir, const struct qstr *name,
struct dentry *dentry, unsigned int flags)
@@ -2247,12 +2232,10 @@ nfs4_lookup_revalidate(struct inode *dir, const struct qstr *name,
if (inode == NULL)
goto full_reval;
if (nfs_verifier_is_delegated(dentry))
if (nfs_verifier_is_delegated(dentry) ||
nfs_have_directory_delegation(inode))
return nfs_lookup_revalidate_delegated(dir, dentry, inode);
if (nfs_have_directory_delegation(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;