summaryrefslogtreecommitdiffstats
path: root/fs/nfs
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2011-11-16 21:43:59 -0500
committerAl Viro <viro@zeniv.linux.org.uk>2011-11-16 22:00:34 -0500
commitea441d1104cf1efb471fa81bc91e9fd1e6ae29fd (patch)
tree32b7c4f7c78af47936a604e3f4e13e8e61f834a0 /fs/nfs
parentc13344958780b4046305ee6235d686c846535529 (diff)
downloadlinux-ea441d1104cf1efb471fa81bc91e9fd1e6ae29fd.tar.gz
linux-ea441d1104cf1efb471fa81bc91e9fd1e6ae29fd.tar.bz2
linux-ea441d1104cf1efb471fa81bc91e9fd1e6ae29fd.zip
new helper: mount_subtree()
takes vfsmount and relative path, does lookup within that vfsmount (possibly triggering automounts) and returns the result as root of subtree suitable for return by ->mount() (i.e. a reference to dentry and an active reference to its superblock grabbed, superblock locked exclusive). btrfs and nfs switched to it instead of open-coding the sucker. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/nfs')
-rw-r--r--fs/nfs/super.c30
1 files changed, 6 insertions, 24 deletions
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 46d69f38fd55..134777406ee3 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -2787,35 +2787,17 @@ static void nfs_referral_loop_unprotect(void)
static struct dentry *nfs_follow_remote_path(struct vfsmount *root_mnt,
const char *export_path)
{
- struct mnt_namespace *ns_private;
- struct super_block *s;
struct dentry *dentry;
- struct path path;
- int ret;
+ int ret = nfs_referral_loop_protect();
- ns_private = create_mnt_ns(root_mnt);
- if (IS_ERR(ns_private))
- return ERR_CAST(ns_private);
-
- ret = nfs_referral_loop_protect();
- if (ret == 0) {
- ret = vfs_path_lookup(root_mnt->mnt_root, root_mnt,
- export_path, LOOKUP_FOLLOW|LOOKUP_AUTOMOUNT,
- &path);
- nfs_referral_loop_unprotect();
- }
-
- put_mnt_ns(ns_private);
-
- if (ret != 0)
+ if (ret) {
+ mntput(root_mnt);
return ERR_PTR(ret);
+ }
- s = path.mnt->mnt_sb;
- atomic_inc(&s->s_active);
- dentry = dget(path.dentry);
+ dentry = mount_subtree(root_mnt, export_path);
+ nfs_referral_loop_unprotect();
- path_put(&path);
- down_write(&s->s_umount);
return dentry;
}