Commit 2d753e62 authored by Ian Kent's avatar Ian Kent Committed by Linus Torvalds

[PATCH] autofs4: can't mount due to mount point dir not empty

Addresse a problem where stale dentrys stop mounts from happening.

When a mount point directory is pre-created and a non-existent entry within it
is requested a dentry ends up being created within the mount point directory
which stops future mounts.  The problem is solved by ignoring negative,
unhashed dentrys in the mount point d_subdirs list.

Additionally the apparent cacheing of -ENOENT returns from requests is
removed.  The test on d_time is a tautology and d_time is not initialised and
has an unexpected value.  In short it doesn't do what it's meant to.

The cacheing of failed requests to the daemon is important and will be
followed up later.
Signed-off-by: default avatarIan Kent <raven@themaw.net>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent f360ce3b
...@@ -41,14 +41,6 @@ ...@@ -41,14 +41,6 @@
#define AUTOFS_SUPER_MAGIC 0x0187 #define AUTOFS_SUPER_MAGIC 0x0187
/*
* If the daemon returns a negative response (AUTOFS_IOC_FAIL) then the
* kernel will keep the negative response cached for up to the time given
* here, although the time can be shorter if the kernel throws the dcache
* entry away. This probably should be settable from user space.
*/
#define AUTOFS_NEGATIVE_TIMEOUT (60*HZ) /* 1 minute */
/* Unified info structure. This is pointed to by both the dentry and /* Unified info structure. This is pointed to by both the dentry and
inode structures. Each file in the filesystem has an instance of this inode structures. Each file in the filesystem has an instance of this
structure. It holds a reference to the dentry, so dentries are never structure. It holds a reference to the dentry, so dentries are never
......
...@@ -294,14 +294,13 @@ static int try_to_fill_dentry(struct vfsmount *mnt, struct dentry *dentry, int f ...@@ -294,14 +294,13 @@ static int try_to_fill_dentry(struct vfsmount *mnt, struct dentry *dentry, int f
/* Turn this into a real negative dentry? */ /* Turn this into a real negative dentry? */
if (status == -ENOENT) { if (status == -ENOENT) {
dentry->d_time = jiffies + AUTOFS_NEGATIVE_TIMEOUT;
spin_lock(&dentry->d_lock); spin_lock(&dentry->d_lock);
dentry->d_flags &= ~DCACHE_AUTOFS_PENDING; dentry->d_flags &= ~DCACHE_AUTOFS_PENDING;
spin_unlock(&dentry->d_lock); spin_unlock(&dentry->d_lock);
return 1; return 0;
} else if (status) { } else if (status) {
/* Return a negative dentry, but leave it "pending" */ /* Return a negative dentry, but leave it "pending" */
return 1; return 0;
} }
/* Trigger mount for path component or follow link */ /* Trigger mount for path component or follow link */
} else if (flags & (LOOKUP_CONTINUE | LOOKUP_DIRECTORY) || } else if (flags & (LOOKUP_CONTINUE | LOOKUP_DIRECTORY) ||
...@@ -360,13 +359,13 @@ static int autofs4_revalidate(struct dentry *dentry, struct nameidata *nd) ...@@ -360,13 +359,13 @@ static int autofs4_revalidate(struct dentry *dentry, struct nameidata *nd)
/* Negative dentry.. invalidate if "old" */ /* Negative dentry.. invalidate if "old" */
if (dentry->d_inode == NULL) if (dentry->d_inode == NULL)
return (dentry->d_time - jiffies <= AUTOFS_NEGATIVE_TIMEOUT); return 0;
/* Check for a non-mountpoint directory with no contents */ /* Check for a non-mountpoint directory with no contents */
spin_lock(&dcache_lock); spin_lock(&dcache_lock);
if (S_ISDIR(dentry->d_inode->i_mode) && if (S_ISDIR(dentry->d_inode->i_mode) &&
!d_mountpoint(dentry) && !d_mountpoint(dentry) &&
list_empty(&dentry->d_subdirs)) { simple_empty_nolock(dentry)) {
DPRINTK("dentry=%p %.*s, emptydir", DPRINTK("dentry=%p %.*s, emptydir",
dentry, dentry->d_name.len, dentry->d_name.name); dentry, dentry->d_name.len, dentry->d_name.name);
spin_unlock(&dcache_lock); spin_unlock(&dcache_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment