Skip to content

Commit

Permalink
autofs4: Add d_automount() dentry operation
Browse files Browse the repository at this point in the history
Add a function to use the newly defined ->d_automount() dentry operation
for triggering mounts instead of doing the user space callback in ->lookup()
and ->d_revalidate().

Note, to be useful the subsequent patch to add the ->d_manage() dentry
operation is also needed so the discussion of functionality is deferred to
that patch.

Signed-off-by: Ian Kent <raven@themaw.net>
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
  • Loading branch information
Ian Kent authored and Al Viro committed Jan 16, 2011
1 parent db37291 commit 1058421
Show file tree
Hide file tree
Showing 4 changed files with 189 additions and 112 deletions.
30 changes: 30 additions & 0 deletions fs/autofs4/autofs_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,36 @@ extern const struct inode_operations autofs4_direct_root_inode_operations;
extern const struct file_operations autofs4_dir_operations;
extern const struct file_operations autofs4_root_operations;

/* Operations methods */

struct vfsmount *autofs4_d_automount(struct path *);

/* VFS automount flags management functions */

static inline void __managed_dentry_set_automount(struct dentry *dentry)
{
dentry->d_flags |= DCACHE_NEED_AUTOMOUNT;
}

static inline void managed_dentry_set_automount(struct dentry *dentry)
{
spin_lock(&dentry->d_lock);
__managed_dentry_set_automount(dentry);
spin_unlock(&dentry->d_lock);
}

static inline void __managed_dentry_clear_automount(struct dentry *dentry)
{
dentry->d_flags &= ~DCACHE_NEED_AUTOMOUNT;
}

static inline void managed_dentry_clear_automount(struct dentry *dentry)
{
spin_lock(&dentry->d_lock);
__managed_dentry_clear_automount(dentry);
spin_unlock(&dentry->d_lock);
}

/* Initializing function */

int autofs4_fill_super(struct super_block *, void *, int);
Expand Down
6 changes: 6 additions & 0 deletions fs/autofs4/expire.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ struct dentry *autofs4_expire_direct(struct super_block *sb,
spin_unlock(&root->d_lock);
}
ino->flags |= AUTOFS_INF_EXPIRING;
managed_dentry_set_automount(root);
init_completion(&ino->expire_complete);
spin_unlock(&sbi->fs_lock);
return root;
Expand Down Expand Up @@ -408,6 +409,7 @@ struct dentry *autofs4_expire_indirect(struct super_block *sb,
expired, (int)expired->d_name.len, expired->d_name.name);
ino = autofs4_dentry_ino(expired);
ino->flags |= AUTOFS_INF_EXPIRING;
managed_dentry_set_automount(expired);
init_completion(&ino->expire_complete);
spin_unlock(&sbi->fs_lock);
spin_lock(&autofs4_lock);
Expand Down Expand Up @@ -479,6 +481,8 @@ 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_automount(dentry);
complete_all(&ino->expire_complete);
spin_unlock(&sbi->fs_lock);

Expand Down Expand Up @@ -516,6 +520,8 @@ int autofs4_do_expire_multi(struct super_block *sb, struct vfsmount *mnt,
ino->flags &= ~AUTOFS_INF_MOUNTPOINT;
}
ino->flags &= ~AUTOFS_INF_EXPIRING;
if (ret)
managed_dentry_clear_automount(dentry);
complete_all(&ino->expire_complete);
spin_unlock(&sbi->fs_lock);
dput(dentry);
Expand Down
4 changes: 4 additions & 0 deletions fs/autofs4/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ static struct autofs_info *autofs4_mkroot(struct autofs_sb_info *sbi)
}

static const struct dentry_operations autofs4_sb_dentry_operations = {
.d_automount = autofs4_d_automount,
.d_release = autofs4_dentry_release,
};

Expand Down Expand Up @@ -320,6 +321,9 @@ int autofs4_fill_super(struct super_block *s, void *data, int silent)
goto fail_dput;
}

if (autofs_type_trigger(sbi->type))
__managed_dentry_set_automount(root);

root_inode->i_fop = &autofs4_root_operations;
root_inode->i_op = autofs_type_trigger(sbi->type) ?
&autofs4_direct_root_inode_operations :
Expand Down
Loading

0 comments on commit 1058421

Please sign in to comment.