Skip to content

Commit ef75c79

Browse files
Trond MyklebustTrond Myklebust
authored andcommitted
NFS: Also use readdir info to revalidate positive dentries
If the fileid of the cached dentry fails to match that returned by the readdir call, then we should also d_drop. Try to take into account the fact that on NFSv4, readdir may return the "mounted_on_fileid" by looking for submounts. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
1 parent df1d5d2 commit ef75c79

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

‎fs/nfs/dir.c‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,9 +1124,16 @@ static struct dentry *nfs_readdir_lookup(nfs_readdir_descriptor_t *desc)
11241124
name.hash = full_name_hash(name.name, name.len);
11251125
dentry = d_lookup(parent, &name);
11261126
if (dentry != NULL) {
1127-
/* Is this a positive dentry? */
1128-
if (dentry->d_inode != NULL)
1129-
return dentry;
1127+
/* Is this a positive dentry that matches the readdir info? */
1128+
if (dentry->d_inode != NULL &&
1129+
(NFS_FILEID(dentry->d_inode) == entry->ino ||
1130+
d_mountpoint(dentry))) {
1131+
if (!desc->plus || entry->fh->size == 0)
1132+
return dentry;
1133+
if (nfs_compare_fh(NFS_FH(dentry->d_inode),
1134+
entry->fh) == 0)
1135+
goto out_renew;
1136+
}
11301137
/* No, so d_drop to allow one to be created */
11311138
d_drop(dentry);
11321139
dput(dentry);
@@ -1152,6 +1159,7 @@ static struct dentry *nfs_readdir_lookup(nfs_readdir_descriptor_t *desc)
11521159
dentry = alias;
11531160
}
11541161

1162+
out_renew:
11551163
nfs_renew_times(dentry);
11561164
nfs_set_verifier(dentry, nfs_save_change_attribute(dir));
11571165
return dentry;

0 commit comments

Comments
 (0)