Skip to content

Commit

Permalink
NFS: allow close-to-open cache semantics to apply to root of NFS file…
Browse files Browse the repository at this point in the history
…system

To obey NFS cache semantics, the client must verify the cached
attributes when a file is opened.  In most cases this is done by a call to
d_validate as one of the last steps in path_walk.

However for the root of a filesystem, d_validate is only ever called
on the mounted-on filesystem (except when the path ends '.' or '..').
So NFS has no chance to validate the attributes.

So, in nfs_opendir, we revalidate the attributes if the opened
directory is the mountpoint.  This may cause double-validation for "."
and ".." lookups, but that is better than missing regular /path/name
lookups completely.

Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
  • Loading branch information
Neil Brown authored and Trond Myklebust committed Aug 10, 2010
1 parent 669502f commit f5a7367
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions fs/nfs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@ nfs_opendir(struct inode *inode, struct file *filp)

/* Call generic open code in order to cache credentials */
res = nfs_open(inode, filp);
if (filp->f_path.dentry == filp->f_path.mnt->mnt_root) {
/* This is a mountpoint, so d_revalidate will never
* have been called, so we need to refresh the
* inode (for close-open consistency) ourselves.
*/
__nfs_revalidate_inode(NFS_SERVER(inode), inode);
}
return res;
}

Expand Down

0 comments on commit f5a7367

Please sign in to comment.