Linux NFS development
 help / color / mirror / Atom feed
* [PATCH 0/2] Resolve d_weak_revalidate issues in NFS
@ 2017-08-25  7:34 NeilBrown
  2017-08-25  7:34 ` [PATCH 2/2] NFS: remove special-case revalidate in nfs_opendir() NeilBrown
  2017-08-25  7:34 ` [PATCH 1/2] NFS: revalidate "." etc correctly on "open" NeilBrown
  0 siblings, 2 replies; 3+ messages in thread
From: NeilBrown @ 2017-08-25  7:34 UTC (permalink / raw)
  To: Trond Myklebust, Anna Schumaker; +Cc: linux-nfs, Jeff Layton

Following my recent investigations into d_weak_revalidate
I offer these two patches.  The first fixes two closely
related bugs caused by the introduction of d_weak_revalidate.
The second provides a minor code cleanup.

It seems we really do need d_weak_revalidate, but we might
need better documentation describing its purpose.

Thanks,
NeilBrown


---

NeilBrown (2):
      NFS: revalidate "." etc correctly on "open".
      NFS: remove special-case revalidate in nfs_opendir()


 fs/nfs/dir.c |   11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

--
Signature


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] NFS: revalidate "." etc correctly on "open".
  2017-08-25  7:34 [PATCH 0/2] Resolve d_weak_revalidate issues in NFS NeilBrown
  2017-08-25  7:34 ` [PATCH 2/2] NFS: remove special-case revalidate in nfs_opendir() NeilBrown
@ 2017-08-25  7:34 ` NeilBrown
  1 sibling, 0 replies; 3+ messages in thread
From: NeilBrown @ 2017-08-25  7:34 UTC (permalink / raw)
  To: Trond Myklebust, Anna Schumaker; +Cc: linux-nfs, Jeff Layton

For correct close-to-open semantics, NFS must validate
the change attribute of a directory (or file) on open.

Since commit ecf3d1f1aa74 ("vfs: kill FS_REVAL_DOT by adding a
d_weak_revalidate dentry op"), open() of "." or a path ending ".." is
not revalidated reliably (except when that direct is a mount point).

Prior to that commit, "." was revalidated using nfs_lookup_revalidate()
which checks the LOOKUP_OPEN flag and forces revalidation if the flag is
set.
Since that commit, nfs_weak_revalidate() is used for NFSv3 (which
ignores the flags) and nothing is used for NFSv4.

This is fixed by using nfs_lookup_verify_inode() in
nfs_weak_revalidate().  This does the revalidation exactly when needed.
Also, add a definition of .d_weak_revalidate for NFSv4.

The incorrect behavior is easily demonstrated by running "echo *" in
some non-mountpoint NFS directory while watching network traffic.
Without this patch, "echo *" sometimes doesn't produce any traffic.
With the patch it always does.

Fixes: ecf3d1f1aa74 ("vfs: kill FS_REVAL_DOT by adding a d_weak_revalidate dentry op")
cc: stable@vger.kernel.org (3.9+)
Signed-off-by: NeilBrown <neilb@suse.com>
---
 fs/nfs/dir.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 3522b1249019..1458e0a8969d 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -1241,8 +1241,7 @@ static int nfs_weak_revalidate(struct dentry *dentry, unsigned int flags)
 		return 0;
 	}
 
-	if (nfs_mapping_need_revalidate_inode(inode))
-		error = __nfs_revalidate_inode(NFS_SERVER(inode), inode);
+	error = nfs_lookup_verify_inode(inode, flags);
 	dfprintk(LOOKUPCACHE, "NFS: %s: inode %lu is %s\n",
 			__func__, inode->i_ino, error ? "invalid" : "valid");
 	return !error;
@@ -1393,6 +1392,7 @@ static int nfs4_lookup_revalidate(struct dentry *, unsigned int);
 
 const struct dentry_operations nfs4_dentry_operations = {
 	.d_revalidate	= nfs4_lookup_revalidate,
+	.d_weak_revalidate	= nfs_weak_revalidate,
 	.d_delete	= nfs_dentry_delete,
 	.d_iput		= nfs_dentry_iput,
 	.d_automount	= nfs_d_automount,



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] NFS: remove special-case revalidate in nfs_opendir()
  2017-08-25  7:34 [PATCH 0/2] Resolve d_weak_revalidate issues in NFS NeilBrown
@ 2017-08-25  7:34 ` NeilBrown
  2017-08-25  7:34 ` [PATCH 1/2] NFS: revalidate "." etc correctly on "open" NeilBrown
  1 sibling, 0 replies; 3+ messages in thread
From: NeilBrown @ 2017-08-25  7:34 UTC (permalink / raw)
  To: Trond Myklebust, Anna Schumaker; +Cc: linux-nfs, Jeff Layton

Commit f5a73672d181 ("NFS: allow close-to-open cache semantics to
apply to root of NFS filesystem") added a call to
__nfs_revalidate_inode() to nfs_opendir to as the lookup
process wouldn't reliable do this.

Subsequent commit a3fbbde70a0c ("VFS: we need to set LOOKUP_JUMPED
on mountpoint crossing") make this unnecessary.  So remove the
unnecessary code.

Signed-off-by: NeilBrown <neilb@suse.com>
---
 fs/nfs/dir.c |    7 -------
 1 file changed, 7 deletions(-)

diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 1458e0a8969d..ca3c6c5d6256 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -118,13 +118,6 @@ nfs_opendir(struct inode *inode, struct file *filp)
 		goto out;
 	}
 	filp->private_data = ctx;
-	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);
-	}
 out:
 	put_rpccred(cred);
 	return res;



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-08-25  7:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-25  7:34 [PATCH 0/2] Resolve d_weak_revalidate issues in NFS NeilBrown
2017-08-25  7:34 ` [PATCH 2/2] NFS: remove special-case revalidate in nfs_opendir() NeilBrown
2017-08-25  7:34 ` [PATCH 1/2] NFS: revalidate "." etc correctly on "open" NeilBrown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox