]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
NFS: Fix directory delegation verifier checks
authorAnna Schumaker <anna.schumaker@oracle.com>
Fri, 19 Dec 2025 20:13:44 +0000 (15:13 -0500)
committerTrond Myklebust <trond.myklebust@hammerspace.com>
Mon, 5 Jan 2026 04:03:25 +0000 (23:03 -0500)
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: 156b09482933 ("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>
fs/nfs/dir.c

index 23a78a742b619dea8b76ddf28f4f59a1c8a015e2..c0e9d5a45cd0bef1e31241a2d818591ce2110684 100644 (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 @@ no_open:
 }
 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;