Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

NFS: Add options for finer control of the lookup cache

Add the flag NFS_MOUNT_LOOKUP_CACHE_NONEG to turn off the caching of
negative dentries. In reality what we do is to force
nfs_lookup_revalidate() to always discard negative dentries.

Add the flag NFS_MOUNT_LOOKUP_CACHE_NONE for enforcing stricter
revalidation of dentries. It forces the revalidate code to always do a
lookup instead of just checking the cached mtime of the parent directory.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>

+8
+4
fs/nfs/dir.c
··· 667 667 { 668 668 if (IS_ROOT(dentry)) 669 669 return 1; 670 + if (NFS_SERVER(dir)->flags & NFS_MOUNT_LOOKUP_CACHE_NONE) 671 + return 0; 670 672 if (!nfs_verify_change_attribute(dir, dentry->d_time)) 671 673 return 0; 672 674 /* Revalidate nfsi->cache_change_attribute before we declare a match */ ··· 752 750 /* Don't revalidate a negative dentry if we're creating a new file */ 753 751 if (nd != NULL && nfs_lookup_check_intent(nd, LOOKUP_CREATE) != 0) 754 752 return 0; 753 + if (NFS_SERVER(dir)->flags & NFS_MOUNT_LOOKUP_CACHE_NONEG) 754 + return 1; 755 755 return !nfs_check_verifier(dir, dentry); 756 756 } 757 757
+4
include/linux/nfs_mount.h
··· 65 65 #define NFS_MOUNT_UNSHARED 0x8000 /* 5 */ 66 66 #define NFS_MOUNT_FLAGMASK 0xFFFF 67 67 68 + /* The following are for internal use only */ 69 + #define NFS_MOUNT_LOOKUP_CACHE_NONEG 0x10000 70 + #define NFS_MOUNT_LOOKUP_CACHE_NONE 0x20000 71 + 68 72 #endif