[PATCH] NFS: revalidate on open if dcache is negative.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




NFS CTO semantics require that (absent a delegation) the server
must be contacted at each open.

nfs_lookup_verify_inode() implements this when the dcache contains
a positive cached entry.  However it is not called when the dcache
contains a negative cached entry.  That path uses nfs_neg_need_reval()
which doesn't impose CTO semantics.

So a sequence like:

   rm -f testfile
   ls -l testfile
   ssh $server touch testfile
   cat testfile

will fail:

  cat: testfile: No such file or directory

an 'strace' will confirm that this resulted from an 'open' system
call.

So add code to nfs_neg_need_reval implement CTO semantics much like
that in nfs_lookup_verify_inode().

Signed-off-by: NeilBrown <neilb@xxxxxxx>

diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index d9f3d067cd15..f8022da72460 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -1062,6 +1062,8 @@ int nfs_neg_need_reval(struct inode *dir, struct dentry *dentry,
 	/* Don't revalidate a negative dentry if we're creating a new file */
 	if (flags & LOOKUP_CREATE)
 		return 0;
+	if ((flags & LOOKUP_OPEN) && !(NFS_SERVER(dir)->flags & NFS_MOUNT_NOCTO))
+		return 1;
 	if (NFS_SERVER(dir)->flags & NFS_MOUNT_LOOKUP_CACHE_NONEG)
 		return 1;
 	return !nfs_check_verifier(dir, dentry);

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux Filesystem Development]     [Linux USB Development]     [Linux Media Development]     [Video for Linux]     [Linux NILFS]     [Linux Audio Users]     [Yosemite Info]     [Linux SCSI]

  Powered by Linux