Commit d18610b0 authored by David Howells's avatar David Howells Committed by Al Viro

AFS: Use d_automount() rather than abusing follow_link()

Make AFS use the new d_automount() dentry operation rather than abusing
follow_link() on directories.
Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent 6f45b656
...@@ -66,6 +66,7 @@ const struct dentry_operations afs_fs_dentry_operations = { ...@@ -66,6 +66,7 @@ const struct dentry_operations afs_fs_dentry_operations = {
.d_revalidate = afs_d_revalidate, .d_revalidate = afs_d_revalidate,
.d_delete = afs_d_delete, .d_delete = afs_d_delete,
.d_release = afs_d_release, .d_release = afs_d_release,
.d_automount = afs_d_automount,
}; };
#define AFS_DIR_HASHTBL_SIZE 128 #define AFS_DIR_HASHTBL_SIZE 128
......
...@@ -184,7 +184,8 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name, ...@@ -184,7 +184,8 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name,
inode->i_generation = 0; inode->i_generation = 0;
set_bit(AFS_VNODE_PSEUDODIR, &vnode->flags); set_bit(AFS_VNODE_PSEUDODIR, &vnode->flags);
inode->i_flags |= S_NOATIME; set_bit(AFS_VNODE_MOUNTPOINT, &vnode->flags);
inode->i_flags |= S_AUTOMOUNT | S_NOATIME;
unlock_new_inode(inode); unlock_new_inode(inode);
_leave(" = %p", inode); _leave(" = %p", inode);
return inode; return inode;
......
...@@ -592,6 +592,7 @@ extern const struct inode_operations afs_mntpt_inode_operations; ...@@ -592,6 +592,7 @@ extern const struct inode_operations afs_mntpt_inode_operations;
extern const struct inode_operations afs_autocell_inode_operations; extern const struct inode_operations afs_autocell_inode_operations;
extern const struct file_operations afs_mntpt_file_operations; extern const struct file_operations afs_mntpt_file_operations;
extern struct vfsmount *afs_d_automount(struct path *);
extern int afs_mntpt_check_symlink(struct afs_vnode *, struct key *); extern int afs_mntpt_check_symlink(struct afs_vnode *, struct key *);
extern void afs_mntpt_kill_timer(void); extern void afs_mntpt_kill_timer(void);
......
...@@ -24,7 +24,6 @@ static struct dentry *afs_mntpt_lookup(struct inode *dir, ...@@ -24,7 +24,6 @@ static struct dentry *afs_mntpt_lookup(struct inode *dir,
struct dentry *dentry, struct dentry *dentry,
struct nameidata *nd); struct nameidata *nd);
static int afs_mntpt_open(struct inode *inode, struct file *file); static int afs_mntpt_open(struct inode *inode, struct file *file);
static void *afs_mntpt_follow_link(struct dentry *dentry, struct nameidata *nd);
static void afs_mntpt_expiry_timed_out(struct work_struct *work); static void afs_mntpt_expiry_timed_out(struct work_struct *work);
const struct file_operations afs_mntpt_file_operations = { const struct file_operations afs_mntpt_file_operations = {
...@@ -34,13 +33,11 @@ const struct file_operations afs_mntpt_file_operations = { ...@@ -34,13 +33,11 @@ const struct file_operations afs_mntpt_file_operations = {
const struct inode_operations afs_mntpt_inode_operations = { const struct inode_operations afs_mntpt_inode_operations = {
.lookup = afs_mntpt_lookup, .lookup = afs_mntpt_lookup,
.follow_link = afs_mntpt_follow_link,
.readlink = page_readlink, .readlink = page_readlink,
.getattr = afs_getattr, .getattr = afs_getattr,
}; };
const struct inode_operations afs_autocell_inode_operations = { const struct inode_operations afs_autocell_inode_operations = {
.follow_link = afs_mntpt_follow_link,
.getattr = afs_getattr, .getattr = afs_getattr,
}; };
...@@ -88,6 +85,7 @@ int afs_mntpt_check_symlink(struct afs_vnode *vnode, struct key *key) ...@@ -88,6 +85,7 @@ int afs_mntpt_check_symlink(struct afs_vnode *vnode, struct key *key)
_debug("symlink is a mountpoint"); _debug("symlink is a mountpoint");
spin_lock(&vnode->lock); spin_lock(&vnode->lock);
set_bit(AFS_VNODE_MOUNTPOINT, &vnode->flags); set_bit(AFS_VNODE_MOUNTPOINT, &vnode->flags);
vnode->vfs_inode.i_flags |= S_AUTOMOUNT;
spin_unlock(&vnode->lock); spin_unlock(&vnode->lock);
} }
...@@ -238,49 +236,37 @@ static struct vfsmount *afs_mntpt_do_automount(struct dentry *mntpt) ...@@ -238,49 +236,37 @@ static struct vfsmount *afs_mntpt_do_automount(struct dentry *mntpt)
} }
/* /*
* follow a link from a mountpoint directory, thus causing it to be mounted * handle an automount point
*/ */
static void *afs_mntpt_follow_link(struct dentry *dentry, struct nameidata *nd) struct vfsmount *afs_d_automount(struct path *path)
{ {
struct vfsmount *newmnt; struct vfsmount *newmnt;
int err; int err;
_enter("%p{%s},{%s:%p{%s},}", _enter("{%s,%s}", path->mnt->mnt_devname, path->dentry->d_name.name);
dentry,
dentry->d_name.name,
nd->path.mnt->mnt_devname,
dentry,
nd->path.dentry->d_name.name);
dput(nd->path.dentry);
nd->path.dentry = dget(dentry);
newmnt = afs_mntpt_do_automount(nd->path.dentry); newmnt = afs_mntpt_do_automount(path->dentry);
if (IS_ERR(newmnt)) { if (IS_ERR(newmnt))
path_put(&nd->path); return newmnt;
return (void *)newmnt;
}
mntget(newmnt); mntget(newmnt);
err = do_add_mount(newmnt, &nd->path, MNT_SHRINKABLE, &afs_vfsmounts); err = do_add_mount(newmnt, path, MNT_SHRINKABLE, &afs_vfsmounts);
switch (err) { switch (err) {
case 0: case 0:
path_put(&nd->path);
nd->path.mnt = newmnt;
nd->path.dentry = dget(newmnt->mnt_root);
queue_delayed_work(afs_wq, &afs_mntpt_expiry_timer, queue_delayed_work(afs_wq, &afs_mntpt_expiry_timer,
afs_mntpt_expiry_timeout * HZ); afs_mntpt_expiry_timeout * HZ);
break; _leave(" = %p {%s}", newmnt, newmnt->mnt_devname);
return newmnt;
case -EBUSY: case -EBUSY:
/* someone else made a mount here whilst we were busy */ /* someone else made a mount here whilst we were busy */
err = follow_down(&nd->path, false); mntput(newmnt);
_leave(" = NULL [EBUSY]");
return NULL;
default: default:
mntput(newmnt); mntput(newmnt);
break; _leave(" = %d", err);
return ERR_PTR(err);
} }
_leave(" = %d", err);
return ERR_PTR(err);
} }
/* /*
......
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