Commit 3c319985 authored by Ian Kent's avatar Ian Kent Committed by Al Viro

autofs4 - reinstate last used update on access

When direct (and offset) mounts were introduced the the last used
timeout could no longer be updated in ->d_revalidate(). This is
because covered direct mounts would be followed over without calling
the autofs file system. As a result the definition of the busyness
check for all entries was changed to be "actually busy" being an open
file or working directory within the automount. But now we have a call
back in the follow so the last used update on any access can be
re-instated. This requires DCACHE_MANAGE_TRANSIT to always be set.
Signed-off-by: default avatarIan Kent <raven@themaw.net>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 62a7375e
...@@ -294,7 +294,6 @@ struct dentry *autofs4_expire_direct(struct super_block *sb, ...@@ -294,7 +294,6 @@ struct dentry *autofs4_expire_direct(struct super_block *sb,
spin_unlock(&sbi->fs_lock); spin_unlock(&sbi->fs_lock);
return NULL; return NULL;
} }
managed_dentry_set_transit(root);
if (!autofs4_direct_busy(mnt, root, timeout, do_now)) { if (!autofs4_direct_busy(mnt, root, timeout, do_now)) {
struct autofs_info *ino = autofs4_dentry_ino(root); struct autofs_info *ino = autofs4_dentry_ino(root);
ino->flags |= AUTOFS_INF_EXPIRING; ino->flags |= AUTOFS_INF_EXPIRING;
...@@ -302,7 +301,6 @@ struct dentry *autofs4_expire_direct(struct super_block *sb, ...@@ -302,7 +301,6 @@ struct dentry *autofs4_expire_direct(struct super_block *sb,
spin_unlock(&sbi->fs_lock); spin_unlock(&sbi->fs_lock);
return root; return root;
} }
managed_dentry_clear_transit(root);
spin_unlock(&sbi->fs_lock); spin_unlock(&sbi->fs_lock);
dput(root); dput(root);
...@@ -341,8 +339,7 @@ struct dentry *autofs4_expire_indirect(struct super_block *sb, ...@@ -341,8 +339,7 @@ struct dentry *autofs4_expire_indirect(struct super_block *sb,
ino = autofs4_dentry_ino(dentry); ino = autofs4_dentry_ino(dentry);
/* No point expiring a pending mount */ /* No point expiring a pending mount */
if (ino->flags & AUTOFS_INF_PENDING) if (ino->flags & AUTOFS_INF_PENDING)
goto cont; goto next;
managed_dentry_set_transit(dentry);
/* /*
* Case 1: (i) indirect mount or top level pseudo direct mount * Case 1: (i) indirect mount or top level pseudo direct mount
...@@ -402,8 +399,6 @@ struct dentry *autofs4_expire_indirect(struct super_block *sb, ...@@ -402,8 +399,6 @@ struct dentry *autofs4_expire_indirect(struct super_block *sb,
} }
} }
next: next:
managed_dentry_clear_transit(dentry);
cont:
spin_unlock(&sbi->fs_lock); spin_unlock(&sbi->fs_lock);
} }
return NULL; return NULL;
...@@ -484,8 +479,6 @@ int autofs4_expire_run(struct super_block *sb, ...@@ -484,8 +479,6 @@ int autofs4_expire_run(struct super_block *sb,
spin_lock(&sbi->fs_lock); spin_lock(&sbi->fs_lock);
ino = autofs4_dentry_ino(dentry); ino = autofs4_dentry_ino(dentry);
ino->flags &= ~AUTOFS_INF_EXPIRING; ino->flags &= ~AUTOFS_INF_EXPIRING;
if (!d_unhashed(dentry))
managed_dentry_clear_transit(dentry);
complete_all(&ino->expire_complete); complete_all(&ino->expire_complete);
spin_unlock(&sbi->fs_lock); spin_unlock(&sbi->fs_lock);
...@@ -513,9 +506,7 @@ int autofs4_do_expire_multi(struct super_block *sb, struct vfsmount *mnt, ...@@ -513,9 +506,7 @@ int autofs4_do_expire_multi(struct super_block *sb, struct vfsmount *mnt,
spin_lock(&sbi->fs_lock); spin_lock(&sbi->fs_lock);
ino->flags &= ~AUTOFS_INF_EXPIRING; ino->flags &= ~AUTOFS_INF_EXPIRING;
spin_lock(&dentry->d_lock); spin_lock(&dentry->d_lock);
if (ret) if (!ret) {
__managed_dentry_clear_transit(dentry);
else {
if ((IS_ROOT(dentry) || if ((IS_ROOT(dentry) ||
(autofs_type_indirect(sbi->type) && (autofs_type_indirect(sbi->type) &&
IS_ROOT(dentry->d_parent))) && IS_ROOT(dentry->d_parent))) &&
......
...@@ -275,17 +275,16 @@ static int autofs4_mount_wait(struct dentry *dentry) ...@@ -275,17 +275,16 @@ static int autofs4_mount_wait(struct dentry *dentry)
{ {
struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb); struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
struct autofs_info *ino = autofs4_dentry_ino(dentry); struct autofs_info *ino = autofs4_dentry_ino(dentry);
int status; int status = 0;
if (ino->flags & AUTOFS_INF_PENDING) { if (ino->flags & AUTOFS_INF_PENDING) {
DPRINTK("waiting for mount name=%.*s", DPRINTK("waiting for mount name=%.*s",
dentry->d_name.len, dentry->d_name.name); dentry->d_name.len, dentry->d_name.name);
status = autofs4_wait(sbi, dentry, NFY_MOUNT); status = autofs4_wait(sbi, dentry, NFY_MOUNT);
DPRINTK("mount wait done status=%d", status); DPRINTK("mount wait done status=%d", status);
ino->last_used = jiffies;
return status;
} }
return 0; ino->last_used = jiffies;
return status;
} }
static int do_expire_wait(struct dentry *dentry) static int do_expire_wait(struct dentry *dentry)
...@@ -319,9 +318,12 @@ static struct dentry *autofs4_mountpoint_changed(struct path *path) ...@@ -319,9 +318,12 @@ static struct dentry *autofs4_mountpoint_changed(struct path *path)
*/ */
if (autofs_type_indirect(sbi->type) && d_unhashed(dentry)) { if (autofs_type_indirect(sbi->type) && d_unhashed(dentry)) {
struct dentry *parent = dentry->d_parent; struct dentry *parent = dentry->d_parent;
struct autofs_info *ino;
struct dentry *new = d_lookup(parent, &dentry->d_name); struct dentry *new = d_lookup(parent, &dentry->d_name);
if (!new) if (!new)
return NULL; return NULL;
ino = autofs4_dentry_ino(new);
ino->last_used = jiffies;
dput(path->dentry); dput(path->dentry);
path->dentry = new; path->dentry = new;
} }
...@@ -338,18 +340,6 @@ static struct vfsmount *autofs4_d_automount(struct path *path) ...@@ -338,18 +340,6 @@ static struct vfsmount *autofs4_d_automount(struct path *path)
DPRINTK("dentry=%p %.*s", DPRINTK("dentry=%p %.*s",
dentry, dentry->d_name.len, dentry->d_name.name); dentry, dentry->d_name.len, dentry->d_name.name);
/*
* Someone may have manually umounted this or it was a submount
* that has gone away.
*/
spin_lock(&dentry->d_lock);
if (!d_mountpoint(dentry) && list_empty(&dentry->d_subdirs)) {
if (!(dentry->d_flags & DCACHE_MANAGE_TRANSIT) &&
(dentry->d_flags & DCACHE_NEED_AUTOMOUNT))
__managed_dentry_set_transit(path->dentry);
}
spin_unlock(&dentry->d_lock);
/* The daemon never triggers a mount. */ /* The daemon never triggers a mount. */
if (autofs4_oz_mode(sbi)) if (autofs4_oz_mode(sbi))
return NULL; return NULL;
...@@ -418,18 +408,17 @@ static struct vfsmount *autofs4_d_automount(struct path *path) ...@@ -418,18 +408,17 @@ static struct vfsmount *autofs4_d_automount(struct path *path)
done: done:
if (!(ino->flags & AUTOFS_INF_EXPIRING)) { if (!(ino->flags & AUTOFS_INF_EXPIRING)) {
/* /*
* Any needed mounting has been completed and the path updated * Any needed mounting has been completed and the path
* so turn this into a normal dentry so we don't continually * updated so clear DCACHE_NEED_AUTOMOUNT so we don't
* call ->d_automount() and ->d_manage(). * call ->d_automount() on rootless multi-mounts since
*/ * it can lead to an incorrect ELOOP error return.
spin_lock(&dentry->d_lock); *
__managed_dentry_clear_transit(dentry);
/*
* Only clear DMANAGED_AUTOMOUNT for rootless multi-mounts and * Only clear DMANAGED_AUTOMOUNT for rootless multi-mounts and
* symlinks as in all other cases the dentry will be covered by * symlinks as in all other cases the dentry will be covered by
* an actual mount so ->d_automount() won't be called during * an actual mount so ->d_automount() won't be called during
* the follow. * the follow.
*/ */
spin_lock(&dentry->d_lock);
if ((!d_mountpoint(dentry) && if ((!d_mountpoint(dentry) &&
!list_empty(&dentry->d_subdirs)) || !list_empty(&dentry->d_subdirs)) ||
(dentry->d_inode && S_ISLNK(dentry->d_inode->i_mode))) (dentry->d_inode && S_ISLNK(dentry->d_inode->i_mode)))
......
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