Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ecf3d1f1 authored by Jeff Layton's avatar Jeff Layton Committed by Al Viro
Browse files

vfs: kill FS_REVAL_DOT by adding a d_weak_revalidate dentry op



The following set of operations on a NFS client and server will cause

    server# mkdir a
    client# cd a
    server# mv a a.bak
    client# sleep 30  # (or whatever the dir attrcache timeout is)
    client# stat .
    stat: cannot stat `.': Stale NFS file handle

Obviously, we should not be getting an ESTALE error back there since the
inode still exists on the server. The problem is that the lookup code
will call d_revalidate on the dentry that "." refers to, because NFS has
FS_REVAL_DOT set.

nfs_lookup_revalidate will see that the parent directory has changed and
will try to reverify the dentry by redoing a LOOKUP. That of course
fails, so the lookup code returns ESTALE.

The problem here is that d_revalidate is really a bad fit for this case.
What we really want to know at this point is whether the inode is still
good or not, but we don't really care what name it goes by or whether
the dcache is still valid.

Add a new d_op->d_weak_revalidate operation and have complete_walk call
that instead of d_revalidate. The intent there is to allow for a
"weaker" d_revalidate that just checks to see whether the inode is still
good. This is also gives us an opportunity to kill off the FS_REVAL_DOT
special casing.

[AV: changed method name, added note in porting, fixed confusion re
having it possibly called from RCU mode (it won't be)]

Cc: NeilBrown <neilb@suse.de>
Signed-off-by: default avatarJeff Layton <jlayton@redhat.com>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 4f4a4fad
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ be able to use diff(1).
--------------------------- dentry_operations --------------------------
prototypes:
	int (*d_revalidate)(struct dentry *, unsigned int);
	int (*d_weak_revalidate)(struct dentry *, unsigned int);
	int (*d_hash)(const struct dentry *, const struct inode *,
			struct qstr *);
	int (*d_compare)(const struct dentry *, const struct inode *,
@@ -25,6 +26,7 @@ prototypes:
locking rules:
		rename_lock	->d_lock	may block	rcu-walk
d_revalidate:	no		no		yes (ref-walk)	maybe
d_weak_revalidate:no		no		yes	 	no
d_hash		no		no		no		maybe
d_compare:	yes		no		no		maybe
d_delete:	no		yes		no		no
+4 −0
Original line number Diff line number Diff line
@@ -441,3 +441,7 @@ d_make_root() drops the reference to inode if dentry allocation fails.
two, it gets "is it an O_EXCL or equivalent?" boolean argument.  Note that
local filesystems can ignore tha argument - they are guaranteed that the
object doesn't exist.  It's remote/distributed ones that might care...
--
[mandatory]
	FS_REVAL_DOT is gone; if you used to have it, add ->d_weak_revalidate()
in your dentry operations instead.
+22 −2
Original line number Diff line number Diff line
@@ -900,6 +900,7 @@ defined:

struct dentry_operations {
	int (*d_revalidate)(struct dentry *, unsigned int);
	int (*d_weak_revalidate)(struct dentry *, unsigned int);
	int (*d_hash)(const struct dentry *, const struct inode *,
			struct qstr *);
	int (*d_compare)(const struct dentry *, const struct inode *,
@@ -915,8 +916,13 @@ struct dentry_operations {

  d_revalidate: called when the VFS needs to revalidate a dentry. This
	is called whenever a name look-up finds a dentry in the
	dcache. Most filesystems leave this as NULL, because all their
	dentries in the dcache are valid
	dcache. Most local filesystems leave this as NULL, because all their
	dentries in the dcache are valid. Network filesystems are different
	since things can change on the server without the client necessarily
	being aware of it.

	This function should return a positive value if the dentry is still
	valid, and zero or a negative error code if it isn't.

	d_revalidate may be called in rcu-walk mode (flags & LOOKUP_RCU).
	If in rcu-walk mode, the filesystem must revalidate the dentry without
@@ -927,6 +933,20 @@ struct dentry_operations {
	If a situation is encountered that rcu-walk cannot handle, return
	-ECHILD and it will be called again in ref-walk mode.

 d_weak_revalidate: called when the VFS needs to revalidate a "jumped" dentry.
	This is called when a path-walk ends at dentry that was not acquired by
	doing a lookup in the parent directory. This includes "/", "." and "..",
	as well as procfs-style symlinks and mountpoint traversal.

	In this case, we are less concerned with whether the dentry is still
	fully correct, but rather that the inode is still valid. As with
	d_revalidate, most local filesystems will set this to NULL since their
	dcache entries are always valid.

	This function has the same return code semantics as d_revalidate.

	d_weak_revalidate is only called after leaving rcu-walk mode.

  d_hash: called when the VFS adds a dentry to the hash table. The first
	dentry passed to d_hash is the parent directory that the name is
	to be hashed into. The inode is the dentry's inode.
+1 −0
Original line number Diff line number Diff line
@@ -137,6 +137,7 @@ static int v9fs_lookup_revalidate(struct dentry *dentry, unsigned int flags)

const struct dentry_operations v9fs_cached_dentry_operations = {
	.d_revalidate = v9fs_lookup_revalidate,
	.d_weak_revalidate = v9fs_lookup_revalidate,
	.d_delete = v9fs_cached_dentry_delete,
	.d_release = v9fs_dentry_release,
};
+1 −1
Original line number Diff line number Diff line
@@ -363,5 +363,5 @@ struct file_system_type v9fs_fs_type = {
	.mount = v9fs_mount,
	.kill_sb = v9fs_kill_super,
	.owner = THIS_MODULE,
	.fs_flags = FS_RENAME_DOES_D_MOVE|FS_REVAL_DOT,
	.fs_flags = FS_RENAME_DOES_D_MOVE,
};
Loading