aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/super.c
diff options
context:
space:
mode:
authorBryan Schumaker <bjschuma@netapp.com>2012-05-10 15:07:37 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2012-05-14 20:30:28 -0400
commit21e4b82e13c038457b4fa4d54d988c9f1865bcf6 (patch)
tree1154e3de3869bb480d556cce1de436d400360cda /fs/nfs/super.c
parent3d176e3fe4f6dc379b252bf43e2e146a8f7caf01 (diff)
NFS: Use nfs_fs_mount_common() for remote referral mounts
Signed-off-by: Bryan Schumaker <bjschuma@netapp.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/super.c')
-rw-r--r--fs/nfs/super.c89
1 files changed, 13 insertions, 76 deletions
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index e93a6e95c031..1157189b4d49 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -2920,95 +2920,32 @@ static struct dentry *
2920nfs4_remote_referral_mount(struct file_system_type *fs_type, int flags, 2920nfs4_remote_referral_mount(struct file_system_type *fs_type, int flags,
2921 const char *dev_name, void *raw_data) 2921 const char *dev_name, void *raw_data)
2922{ 2922{
2923 struct nfs_clone_mount *data = raw_data; 2923 struct nfs_mount_info mount_info = {
2924 struct super_block *s; 2924 .fill_super = nfs4_fill_super,
2925 .set_security = nfs_clone_sb_security,
2926 .cloned = raw_data,
2927 };
2925 struct nfs_server *server; 2928 struct nfs_server *server;
2926 struct dentry *mntroot; 2929 struct dentry *mntroot = ERR_PTR(-ENOMEM);
2927 struct nfs_fh *mntfh; 2930 struct nfs_fh *mntfh;
2928 int (*compare_super)(struct super_block *, void *) = nfs_compare_super;
2929 struct nfs_sb_mountdata sb_mntdata = {
2930 .mntflags = flags,
2931 };
2932 int error = -ENOMEM;
2933 2931
2934 dprintk("--> nfs4_referral_get_sb()\n"); 2932 dprintk("--> nfs4_referral_get_sb()\n");
2935 2933
2936 mntfh = nfs_alloc_fhandle(); 2934 mntfh = nfs_alloc_fhandle();
2937 if (mntfh == NULL) 2935 if (mount_info.cloned == NULL || mntfh == NULL)
2938 goto out_err_nofh; 2936 goto out;
2939 2937
2940 /* create a new volume representation */ 2938 /* create a new volume representation */
2941 server = nfs4_create_referral_server(data, mntfh); 2939 server = nfs4_create_referral_server(mount_info.cloned, mntfh);
2942 if (IS_ERR(server)) { 2940 if (IS_ERR(server)) {
2943 error = PTR_ERR(server); 2941 mntroot = ERR_CAST(server);
2944 goto out_err_noserver; 2942 goto out;
2945 }
2946 sb_mntdata.server = server;
2947
2948 if (server->flags & NFS_MOUNT_UNSHARED)
2949 compare_super = NULL;
2950
2951 /* -o noac implies -o sync */
2952 if (server->flags & NFS_MOUNT_NOAC)
2953 sb_mntdata.mntflags |= MS_SYNCHRONOUS;
2954
2955 /* Get a superblock - note that we may end up sharing one that already exists */
2956 s = sget(&nfs4_fs_type, compare_super, nfs_set_super, &sb_mntdata);
2957 if (IS_ERR(s)) {
2958 error = PTR_ERR(s);
2959 goto out_err_nosb;
2960 }
2961
2962 if (s->s_fs_info != server) {
2963 nfs_free_server(server);
2964 server = NULL;
2965 } else {
2966 error = nfs_bdi_register(server);
2967 if (error)
2968 goto error_splat_bdi;
2969 }
2970
2971 if (!s->s_root) {
2972 /* initial superblock/root creation */
2973 nfs4_fill_super(s, NULL);
2974 nfs_get_cache_cookie(s, NULL, data);
2975 }
2976
2977 mntroot = nfs_get_root(s, mntfh, dev_name);
2978 if (IS_ERR(mntroot)) {
2979 error = PTR_ERR(mntroot);
2980 goto error_splat_super;
2981 }
2982 if (mntroot->d_inode->i_op != NFS_SB(s)->nfs_client->rpc_ops->dir_inode_ops) {
2983 dput(mntroot);
2984 error = -ESTALE;
2985 goto error_splat_super;
2986 } 2943 }
2987 2944
2988 s->s_flags |= MS_ACTIVE; 2945 mntroot = nfs_fs_mount_common(&nfs4_fs_type, server, flags, dev_name, mntfh, &mount_info);
2989 2946out:
2990 security_sb_clone_mnt_opts(data->sb, s);
2991
2992 nfs_free_fhandle(mntfh); 2947 nfs_free_fhandle(mntfh);
2993 dprintk("<-- nfs4_referral_get_sb() = 0\n");
2994 return mntroot; 2948 return mntroot;
2995
2996out_err_nosb:
2997 nfs_free_server(server);
2998out_err_noserver:
2999 nfs_free_fhandle(mntfh);
3000out_err_nofh:
3001 dprintk("<-- nfs4_referral_get_sb() = %d [error]\n", error);
3002 return ERR_PTR(error);
3003
3004error_splat_super:
3005 if (server && !s->s_root)
3006 bdi_unregister(&server->backing_dev_info);
3007error_splat_bdi:
3008 deactivate_locked_super(s);
3009 nfs_free_fhandle(mntfh);
3010 dprintk("<-- nfs4_referral_get_sb() = %d [splat]\n", error);
3011 return ERR_PTR(error);
3012} 2949}
3013 2950
3014/* 2951/*