]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
NFS: Fix case insensitive renames
authorTrond Myklebust <trond.myklebust@hammerspace.com>
Mon, 27 Jun 2022 20:04:02 +0000 (16:04 -0400)
committerTrond Myklebust <trond.myklebust@hammerspace.com>
Sun, 10 Jul 2022 23:00:53 +0000 (19:00 -0400)
For filesystems that are case insensitive and case preserving, we need
to be able to rename from one case folded variant of the filename to
another.
Currently, if we have looked up the target filename before the call to
rename, then we may have a hashed dentry with that target name in the
dcache, causing the vfs to optimise away the rename.
To avoid that, let's drop the target dentry, and leave it to the server
to optimise away the rename if that is the correct thing to do.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
fs/nfs/dir.c

index 0c4e8dd6aa968717d68a829540c14ac1b3972b51..d9d277d7fa8460f0999fa66c1e25728344e5f78f 100644 (file)
@@ -1739,6 +1739,10 @@ nfs_do_lookup_revalidate(struct inode *dir, struct dentry *dentry,
                goto out_bad;
        }
 
+       if ((flags & LOOKUP_RENAME_TARGET) && d_count(dentry) < 2 &&
+           nfs_server_capable(dir, NFS_CAP_CASE_INSENSITIVE))
+               goto out_bad;
+
        if (nfs_verifier_is_delegated(dentry))
                return nfs_lookup_revalidate_delegated(dir, dentry, inode);