Skip to content

Commit

Permalink
autofs4 - reinstate last used update on access
Browse files Browse the repository at this point in the history
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: Ian Kent <[email protected]>
Signed-off-by: Al Viro <[email protected]>
  • Loading branch information
raven-au authored and Al Viro committed Mar 24, 2011
1 parent 62a7375 commit 3c31998
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 34 deletions.
13 changes: 2 additions & 11 deletions fs/autofs4/expire.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,15 +294,13 @@ struct dentry *autofs4_expire_direct(struct super_block *sb,
spin_unlock(&sbi->fs_lock);
return NULL;
}
managed_dentry_set_transit(root);
if (!autofs4_direct_busy(mnt, root, timeout, do_now)) {
struct autofs_info *ino = autofs4_dentry_ino(root);
ino->flags |= AUTOFS_INF_EXPIRING;
init_completion(&ino->expire_complete);
spin_unlock(&sbi->fs_lock);
return root;
}
managed_dentry_clear_transit(root);
spin_unlock(&sbi->fs_lock);
dput(root);

Expand Down Expand Up @@ -341,8 +339,7 @@ struct dentry *autofs4_expire_indirect(struct super_block *sb,
ino = autofs4_dentry_ino(dentry);
/* No point expiring a pending mount */
if (ino->flags & AUTOFS_INF_PENDING)
goto cont;
managed_dentry_set_transit(dentry);
goto next;

/*
* Case 1: (i) indirect mount or top level pseudo direct mount
Expand Down Expand Up @@ -402,8 +399,6 @@ struct dentry *autofs4_expire_indirect(struct super_block *sb,
}
}
next:
managed_dentry_clear_transit(dentry);
cont:
spin_unlock(&sbi->fs_lock);
}
return NULL;
Expand Down Expand Up @@ -484,8 +479,6 @@ int autofs4_expire_run(struct super_block *sb,
spin_lock(&sbi->fs_lock);
ino = autofs4_dentry_ino(dentry);
ino->flags &= ~AUTOFS_INF_EXPIRING;
if (!d_unhashed(dentry))
managed_dentry_clear_transit(dentry);
complete_all(&ino->expire_complete);
spin_unlock(&sbi->fs_lock);

Expand Down Expand Up @@ -513,9 +506,7 @@ int autofs4_do_expire_multi(struct super_block *sb, struct vfsmount *mnt,
spin_lock(&sbi->fs_lock);
ino->flags &= ~AUTOFS_INF_EXPIRING;
spin_lock(&dentry->d_lock);
if (ret)
__managed_dentry_clear_transit(dentry);
else {
if (!ret) {
if ((IS_ROOT(dentry) ||
(autofs_type_indirect(sbi->type) &&
IS_ROOT(dentry->d_parent))) &&
Expand Down
35 changes: 12 additions & 23 deletions fs/autofs4/root.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,17 +275,16 @@ static int autofs4_mount_wait(struct dentry *dentry)
{
struct autofs_sb_info *sbi = autofs4_sbi(dentry->d_sb);
struct autofs_info *ino = autofs4_dentry_ino(dentry);
int status;
int status = 0;

if (ino->flags & AUTOFS_INF_PENDING) {
DPRINTK("waiting for mount name=%.*s",
dentry->d_name.len, dentry->d_name.name);
status = autofs4_wait(sbi, dentry, NFY_MOUNT);
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)
Expand Down Expand Up @@ -319,9 +318,12 @@ static struct dentry *autofs4_mountpoint_changed(struct path *path)
*/
if (autofs_type_indirect(sbi->type) && d_unhashed(dentry)) {
struct dentry *parent = dentry->d_parent;
struct autofs_info *ino;
struct dentry *new = d_lookup(parent, &dentry->d_name);
if (!new)
return NULL;
ino = autofs4_dentry_ino(new);
ino->last_used = jiffies;
dput(path->dentry);
path->dentry = new;
}
Expand All @@ -338,18 +340,6 @@ static struct vfsmount *autofs4_d_automount(struct path *path)
DPRINTK("dentry=%p %.*s",
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. */
if (autofs4_oz_mode(sbi))
return NULL;
Expand Down Expand Up @@ -418,18 +408,17 @@ static struct vfsmount *autofs4_d_automount(struct path *path)
done:
if (!(ino->flags & AUTOFS_INF_EXPIRING)) {
/*
* Any needed mounting has been completed and the path updated
* so turn this into a normal dentry so we don't continually
* call ->d_automount() and ->d_manage().
*/
spin_lock(&dentry->d_lock);
__managed_dentry_clear_transit(dentry);
/*
* Any needed mounting has been completed and the path
* updated so clear DCACHE_NEED_AUTOMOUNT so we don't
* call ->d_automount() on rootless multi-mounts since
* it can lead to an incorrect ELOOP error return.
*
* Only clear DMANAGED_AUTOMOUNT for rootless multi-mounts and
* symlinks as in all other cases the dentry will be covered by
* an actual mount so ->d_automount() won't be called during
* the follow.
*/
spin_lock(&dentry->d_lock);
if ((!d_mountpoint(dentry) &&
!list_empty(&dentry->d_subdirs)) ||
(dentry->d_inode && S_ISLNK(dentry->d_inode->i_mode)))
Expand Down

0 comments on commit 3c31998

Please sign in to comment.