aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2011-03-16 07:25:36 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2011-03-16 16:48:06 -0400
commit011949811b946bd3b72fca71200f197c6168a5f8 (patch)
tree21e9fc3727de86bda7dc41cc90c331c6240239fc
parentfd462fb51db46c84bea0fc377c11b9a7e16bc1a0 (diff)
nfs: switch NFS from ->get_sb() to ->mount()
The last remaining instances of ->get_sb() can be converted ->mount() now - nothing in them uses new vfsmount anymore. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r--fs/nfs/super.c132
1 files changed, 66 insertions, 66 deletions
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 3f967cee4072..d3286583009a 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -266,7 +266,8 @@ static int nfs_show_options(struct seq_file *, struct vfsmount *);
266static int nfs_show_devname(struct seq_file *, struct vfsmount *); 266static int nfs_show_devname(struct seq_file *, struct vfsmount *);
267static int nfs_show_path(struct seq_file *, struct vfsmount *); 267static int nfs_show_path(struct seq_file *, struct vfsmount *);
268static int nfs_show_stats(struct seq_file *, struct vfsmount *); 268static int nfs_show_stats(struct seq_file *, struct vfsmount *);
269static int nfs_get_sb(struct file_system_type *, int, const char *, void *, struct vfsmount *); 269static struct dentry *nfs_fs_mount(struct file_system_type *,
270 int, const char *, void *);
270static struct dentry *nfs_xdev_mount(struct file_system_type *fs_type, 271static struct dentry *nfs_xdev_mount(struct file_system_type *fs_type,
271 int flags, const char *dev_name, void *raw_data); 272 int flags, const char *dev_name, void *raw_data);
272static void nfs_put_super(struct super_block *); 273static void nfs_put_super(struct super_block *);
@@ -276,7 +277,7 @@ static int nfs_remount(struct super_block *sb, int *flags, char *raw_data);
276static struct file_system_type nfs_fs_type = { 277static struct file_system_type nfs_fs_type = {
277 .owner = THIS_MODULE, 278 .owner = THIS_MODULE,
278 .name = "nfs", 279 .name = "nfs",
279 .get_sb = nfs_get_sb, 280 .mount = nfs_fs_mount,
280 .kill_sb = nfs_kill_super, 281 .kill_sb = nfs_kill_super,
281 .fs_flags = FS_RENAME_DOES_D_MOVE|FS_REVAL_DOT|FS_BINARY_MOUNTDATA, 282 .fs_flags = FS_RENAME_DOES_D_MOVE|FS_REVAL_DOT|FS_BINARY_MOUNTDATA,
282}; 283};
@@ -307,16 +308,16 @@ static const struct super_operations nfs_sops = {
307#ifdef CONFIG_NFS_V4 308#ifdef CONFIG_NFS_V4
308static int nfs4_validate_text_mount_data(void *options, 309static int nfs4_validate_text_mount_data(void *options,
309 struct nfs_parsed_mount_data *args, const char *dev_name); 310 struct nfs_parsed_mount_data *args, const char *dev_name);
310static int nfs4_try_mount(int flags, const char *dev_name, 311static struct dentry *nfs4_try_mount(int flags, const char *dev_name,
311 struct nfs_parsed_mount_data *data, struct vfsmount *mnt); 312 struct nfs_parsed_mount_data *data);
312static int nfs4_get_sb(struct file_system_type *fs_type, 313static struct dentry *nfs4_mount(struct file_system_type *fs_type,
313 int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt); 314 int flags, const char *dev_name, void *raw_data);
314static struct dentry *nfs4_remote_mount(struct file_system_type *fs_type, 315static struct dentry *nfs4_remote_mount(struct file_system_type *fs_type,
315 int flags, const char *dev_name, void *raw_data); 316 int flags, const char *dev_name, void *raw_data);
316static struct dentry *nfs4_xdev_mount(struct file_system_type *fs_type, 317static struct dentry *nfs4_xdev_mount(struct file_system_type *fs_type,
317 int flags, const char *dev_name, void *raw_data); 318 int flags, const char *dev_name, void *raw_data);
318static int nfs4_referral_get_sb(struct file_system_type *fs_type, 319static struct dentry *nfs4_referral_mount(struct file_system_type *fs_type,
319 int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt); 320 int flags, const char *dev_name, void *raw_data);
320static struct dentry *nfs4_remote_referral_mount(struct file_system_type *fs_type, 321static struct dentry *nfs4_remote_referral_mount(struct file_system_type *fs_type,
321 int flags, const char *dev_name, void *raw_data); 322 int flags, const char *dev_name, void *raw_data);
322static void nfs4_kill_super(struct super_block *sb); 323static void nfs4_kill_super(struct super_block *sb);
@@ -324,7 +325,7 @@ static void nfs4_kill_super(struct super_block *sb);
324static struct file_system_type nfs4_fs_type = { 325static struct file_system_type nfs4_fs_type = {
325 .owner = THIS_MODULE, 326 .owner = THIS_MODULE,
326 .name = "nfs4", 327 .name = "nfs4",
327 .get_sb = nfs4_get_sb, 328 .mount = nfs4_mount,
328 .kill_sb = nfs4_kill_super, 329 .kill_sb = nfs4_kill_super,
329 .fs_flags = FS_RENAME_DOES_D_MOVE|FS_REVAL_DOT|FS_BINARY_MOUNTDATA, 330 .fs_flags = FS_RENAME_DOES_D_MOVE|FS_REVAL_DOT|FS_BINARY_MOUNTDATA,
330}; 331};
@@ -356,7 +357,7 @@ static struct file_system_type nfs4_remote_referral_fs_type = {
356struct file_system_type nfs4_referral_fs_type = { 357struct file_system_type nfs4_referral_fs_type = {
357 .owner = THIS_MODULE, 358 .owner = THIS_MODULE,
358 .name = "nfs4", 359 .name = "nfs4",
359 .get_sb = nfs4_referral_get_sb, 360 .mount = nfs4_referral_mount,
360 .kill_sb = nfs4_kill_super, 361 .kill_sb = nfs4_kill_super,
361 .fs_flags = FS_RENAME_DOES_D_MOVE|FS_REVAL_DOT|FS_BINARY_MOUNTDATA, 362 .fs_flags = FS_RENAME_DOES_D_MOVE|FS_REVAL_DOT|FS_BINARY_MOUNTDATA,
362}; 363};
@@ -2295,19 +2296,19 @@ static int nfs_bdi_register(struct nfs_server *server)
2295 return bdi_register_dev(&server->backing_dev_info, server->s_dev); 2296 return bdi_register_dev(&server->backing_dev_info, server->s_dev);
2296} 2297}
2297 2298
2298static int nfs_get_sb(struct file_system_type *fs_type, 2299static struct dentry *nfs_fs_mount(struct file_system_type *fs_type,
2299 int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt) 2300 int flags, const char *dev_name, void *raw_data)
2300{ 2301{
2301 struct nfs_server *server = NULL; 2302 struct nfs_server *server = NULL;
2302 struct super_block *s; 2303 struct super_block *s;
2303 struct nfs_parsed_mount_data *data; 2304 struct nfs_parsed_mount_data *data;
2304 struct nfs_fh *mntfh; 2305 struct nfs_fh *mntfh;
2305 struct dentry *mntroot; 2306 struct dentry *mntroot = ERR_PTR(-ENOMEM);
2306 int (*compare_super)(struct super_block *, void *) = nfs_compare_super; 2307 int (*compare_super)(struct super_block *, void *) = nfs_compare_super;
2307 struct nfs_sb_mountdata sb_mntdata = { 2308 struct nfs_sb_mountdata sb_mntdata = {
2308 .mntflags = flags, 2309 .mntflags = flags,
2309 }; 2310 };
2310 int error = -ENOMEM; 2311 int error;
2311 2312
2312 data = nfs_alloc_parsed_mount_data(NFS_DEFAULT_VERSION); 2313 data = nfs_alloc_parsed_mount_data(NFS_DEFAULT_VERSION);
2313 mntfh = nfs_alloc_fhandle(); 2314 mntfh = nfs_alloc_fhandle();
@@ -2318,12 +2319,14 @@ static int nfs_get_sb(struct file_system_type *fs_type,
2318 2319
2319 /* Validate the mount data */ 2320 /* Validate the mount data */
2320 error = nfs_validate_mount_data(raw_data, data, mntfh, dev_name); 2321 error = nfs_validate_mount_data(raw_data, data, mntfh, dev_name);
2321 if (error < 0) 2322 if (error < 0) {
2323 mntroot = ERR_PTR(error);
2322 goto out; 2324 goto out;
2325 }
2323 2326
2324#ifdef CONFIG_NFS_V4 2327#ifdef CONFIG_NFS_V4
2325 if (data->version == 4) { 2328 if (data->version == 4) {
2326 error = nfs4_try_mount(flags, dev_name, data, mnt); 2329 mntroot = nfs4_try_mount(flags, dev_name, data);
2327 kfree(data->client_address); 2330 kfree(data->client_address);
2328 kfree(data->nfs_server.export_path); 2331 kfree(data->nfs_server.export_path);
2329 goto out; 2332 goto out;
@@ -2333,7 +2336,7 @@ static int nfs_get_sb(struct file_system_type *fs_type,
2333 /* Get a volume representation */ 2336 /* Get a volume representation */
2334 server = nfs_create_server(data, mntfh); 2337 server = nfs_create_server(data, mntfh);
2335 if (IS_ERR(server)) { 2338 if (IS_ERR(server)) {
2336 error = PTR_ERR(server); 2339 mntroot = ERR_CAST(server);
2337 goto out; 2340 goto out;
2338 } 2341 }
2339 sb_mntdata.server = server; 2342 sb_mntdata.server = server;
@@ -2344,7 +2347,7 @@ static int nfs_get_sb(struct file_system_type *fs_type,
2344 /* Get a superblock - note that we may end up sharing one that already exists */ 2347 /* Get a superblock - note that we may end up sharing one that already exists */
2345 s = sget(fs_type, compare_super, nfs_set_super, &sb_mntdata); 2348 s = sget(fs_type, compare_super, nfs_set_super, &sb_mntdata);
2346 if (IS_ERR(s)) { 2349 if (IS_ERR(s)) {
2347 error = PTR_ERR(s); 2350 mntroot = ERR_CAST(s);
2348 goto out_err_nosb; 2351 goto out_err_nosb;
2349 } 2352 }
2350 2353
@@ -2353,8 +2356,10 @@ static int nfs_get_sb(struct file_system_type *fs_type,
2353 server = NULL; 2356 server = NULL;
2354 } else { 2357 } else {
2355 error = nfs_bdi_register(server); 2358 error = nfs_bdi_register(server);
2356 if (error) 2359 if (error) {
2360 mntroot = ERR_PTR(error);
2357 goto error_splat_bdi; 2361 goto error_splat_bdi;
2362 }
2358 } 2363 }
2359 2364
2360 if (!s->s_root) { 2365 if (!s->s_root) {
@@ -2365,19 +2370,14 @@ static int nfs_get_sb(struct file_system_type *fs_type,
2365 } 2370 }
2366 2371
2367 mntroot = nfs_get_root(s, mntfh, dev_name); 2372 mntroot = nfs_get_root(s, mntfh, dev_name);
2368 if (IS_ERR(mntroot)) { 2373 if (IS_ERR(mntroot))
2369 error = PTR_ERR(mntroot);
2370 goto error_splat_super; 2374 goto error_splat_super;
2371 }
2372 2375
2373 error = security_sb_set_mnt_opts(s, &data->lsm_opts); 2376 error = security_sb_set_mnt_opts(s, &data->lsm_opts);
2374 if (error) 2377 if (error)
2375 goto error_splat_root; 2378 goto error_splat_root;
2376 2379
2377 s->s_flags |= MS_ACTIVE; 2380 s->s_flags |= MS_ACTIVE;
2378 mnt->mnt_sb = s;
2379 mnt->mnt_root = mntroot;
2380 error = 0;
2381 2381
2382out: 2382out:
2383 kfree(data->nfs_server.hostname); 2383 kfree(data->nfs_server.hostname);
@@ -2387,7 +2387,7 @@ out:
2387out_free_fh: 2387out_free_fh:
2388 nfs_free_fhandle(mntfh); 2388 nfs_free_fhandle(mntfh);
2389 kfree(data); 2389 kfree(data);
2390 return error; 2390 return mntroot;
2391 2391
2392out_err_nosb: 2392out_err_nosb:
2393 nfs_free_server(server); 2393 nfs_free_server(server);
@@ -2395,6 +2395,7 @@ out_err_nosb:
2395 2395
2396error_splat_root: 2396error_splat_root:
2397 dput(mntroot); 2397 dput(mntroot);
2398 mntroot = ERR_PTR(error);
2398error_splat_super: 2399error_splat_super:
2399 if (server && !s->s_root) 2400 if (server && !s->s_root)
2400 bdi_unregister(&server->backing_dev_info); 2401 bdi_unregister(&server->backing_dev_info);
@@ -2865,17 +2866,18 @@ static void nfs_referral_loop_unprotect(void)
2865 kfree(p); 2866 kfree(p);
2866} 2867}
2867 2868
2868static int nfs_follow_remote_path(struct vfsmount *root_mnt, 2869static struct dentry *nfs_follow_remote_path(struct vfsmount *root_mnt,
2869 const char *export_path, struct vfsmount *mnt_target) 2870 const char *export_path)
2870{ 2871{
2871 struct nameidata *nd = NULL; 2872 struct nameidata *nd = NULL;
2872 struct mnt_namespace *ns_private; 2873 struct mnt_namespace *ns_private;
2873 struct super_block *s; 2874 struct super_block *s;
2875 struct dentry *dentry;
2874 int ret; 2876 int ret;
2875 2877
2876 nd = kmalloc(sizeof(*nd), GFP_KERNEL); 2878 nd = kmalloc(sizeof(*nd), GFP_KERNEL);
2877 if (nd == NULL) 2879 if (nd == NULL)
2878 return -ENOMEM; 2880 return ERR_PTR(-ENOMEM);
2879 2881
2880 ns_private = create_mnt_ns(root_mnt); 2882 ns_private = create_mnt_ns(root_mnt);
2881 ret = PTR_ERR(ns_private); 2883 ret = PTR_ERR(ns_private);
@@ -2897,29 +2899,27 @@ static int nfs_follow_remote_path(struct vfsmount *root_mnt,
2897 2899
2898 s = nd->path.mnt->mnt_sb; 2900 s = nd->path.mnt->mnt_sb;
2899 atomic_inc(&s->s_active); 2901 atomic_inc(&s->s_active);
2900 mnt_target->mnt_sb = s; 2902 dentry = dget(nd->path.dentry);
2901 mnt_target->mnt_root = dget(nd->path.dentry);
2902 2903
2903 path_put(&nd->path); 2904 path_put(&nd->path);
2904 kfree(nd); 2905 kfree(nd);
2905 down_write(&s->s_umount); 2906 down_write(&s->s_umount);
2906 return 0; 2907 return dentry;
2907out_put_mnt_ns: 2908out_put_mnt_ns:
2908 put_mnt_ns(ns_private); 2909 put_mnt_ns(ns_private);
2909out_mntput: 2910out_mntput:
2910 mntput(root_mnt); 2911 mntput(root_mnt);
2911out_err: 2912out_err:
2912 kfree(nd); 2913 kfree(nd);
2913 return ret; 2914 return ERR_PTR(ret);
2914} 2915}
2915 2916
2916static int nfs4_try_mount(int flags, const char *dev_name, 2917static struct dentry *nfs4_try_mount(int flags, const char *dev_name,
2917 struct nfs_parsed_mount_data *data, 2918 struct nfs_parsed_mount_data *data)
2918 struct vfsmount *mnt)
2919{ 2919{
2920 char *export_path; 2920 char *export_path;
2921 struct vfsmount *root_mnt; 2921 struct vfsmount *root_mnt;
2922 int error; 2922 struct dentry *res;
2923 2923
2924 dfprintk(MOUNT, "--> nfs4_try_mount()\n"); 2924 dfprintk(MOUNT, "--> nfs4_try_mount()\n");
2925 2925
@@ -2929,26 +2929,25 @@ static int nfs4_try_mount(int flags, const char *dev_name,
2929 data->nfs_server.hostname); 2929 data->nfs_server.hostname);
2930 data->nfs_server.export_path = export_path; 2930 data->nfs_server.export_path = export_path;
2931 2931
2932 error = PTR_ERR(root_mnt); 2932 res = ERR_CAST(root_mnt);
2933 if (IS_ERR(root_mnt)) 2933 if (!IS_ERR(root_mnt))
2934 goto out; 2934 res = nfs_follow_remote_path(root_mnt, export_path);
2935
2936 error = nfs_follow_remote_path(root_mnt, export_path, mnt);
2937 2935
2938out: 2936 dfprintk(MOUNT, "<-- nfs4_try_mount() = %ld%s\n",
2939 dfprintk(MOUNT, "<-- nfs4_try_mount() = %d%s\n", error, 2937 IS_ERR(res) ? PTR_ERR(res) : 0,
2940 error != 0 ? " [error]" : ""); 2938 IS_ERR(res) ? " [error]" : "");
2941 return error; 2939 return res;
2942} 2940}
2943 2941
2944/* 2942/*
2945 * Get the superblock for an NFS4 mountpoint 2943 * Get the superblock for an NFS4 mountpoint
2946 */ 2944 */
2947static int nfs4_get_sb(struct file_system_type *fs_type, 2945static struct dentry *nfs4_mount(struct file_system_type *fs_type,
2948 int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt) 2946 int flags, const char *dev_name, void *raw_data)
2949{ 2947{
2950 struct nfs_parsed_mount_data *data; 2948 struct nfs_parsed_mount_data *data;
2951 int error = -ENOMEM; 2949 int error = -ENOMEM;
2950 struct dentry *res = ERR_PTR(-ENOMEM);
2952 2951
2953 data = nfs_alloc_parsed_mount_data(4); 2952 data = nfs_alloc_parsed_mount_data(4);
2954 if (data == NULL) 2953 if (data == NULL)
@@ -2956,10 +2955,14 @@ static int nfs4_get_sb(struct file_system_type *fs_type,
2956 2955
2957 /* Validate the mount data */ 2956 /* Validate the mount data */
2958 error = nfs4_validate_mount_data(raw_data, data, dev_name); 2957 error = nfs4_validate_mount_data(raw_data, data, dev_name);
2959 if (error < 0) 2958 if (error < 0) {
2959 res = ERR_PTR(error);
2960 goto out; 2960 goto out;
2961 }
2961 2962
2962 error = nfs4_try_mount(flags, dev_name, data, mnt); 2963 res = nfs4_try_mount(flags, dev_name, data);
2964 if (IS_ERR(res))
2965 error = PTR_ERR(res);
2963 2966
2964out: 2967out:
2965 kfree(data->client_address); 2968 kfree(data->client_address);
@@ -2968,9 +2971,9 @@ out:
2968 kfree(data->fscache_uniq); 2971 kfree(data->fscache_uniq);
2969out_free_data: 2972out_free_data:
2970 kfree(data); 2973 kfree(data);
2971 dprintk("<-- nfs4_get_sb() = %d%s\n", error, 2974 dprintk("<-- nfs4_mount() = %d%s\n", error,
2972 error != 0 ? " [error]" : ""); 2975 error != 0 ? " [error]" : "");
2973 return error; 2976 return res;
2974} 2977}
2975 2978
2976static void nfs4_kill_super(struct super_block *sb) 2979static void nfs4_kill_super(struct super_block *sb)
@@ -3164,16 +3167,15 @@ error_splat_bdi:
3164/* 3167/*
3165 * Create an NFS4 server record on referral traversal 3168 * Create an NFS4 server record on referral traversal
3166 */ 3169 */
3167static int nfs4_referral_get_sb(struct file_system_type *fs_type, 3170static struct dentry *nfs4_referral_mount(struct file_system_type *fs_type,
3168 int flags, const char *dev_name, void *raw_data, 3171 int flags, const char *dev_name, void *raw_data)
3169 struct vfsmount *mnt)
3170{ 3172{
3171 struct nfs_clone_mount *data = raw_data; 3173 struct nfs_clone_mount *data = raw_data;
3172 char *export_path; 3174 char *export_path;
3173 struct vfsmount *root_mnt; 3175 struct vfsmount *root_mnt;
3174 int error; 3176 struct dentry *res;
3175 3177
3176 dprintk("--> nfs4_referral_get_sb()\n"); 3178 dprintk("--> nfs4_referral_mount()\n");
3177 3179
3178 export_path = data->mnt_path; 3180 export_path = data->mnt_path;
3179 data->mnt_path = "/"; 3181 data->mnt_path = "/";
@@ -3182,15 +3184,13 @@ static int nfs4_referral_get_sb(struct file_system_type *fs_type,
3182 flags, data, data->hostname); 3184 flags, data, data->hostname);
3183 data->mnt_path = export_path; 3185 data->mnt_path = export_path;
3184 3186
3185 error = PTR_ERR(root_mnt); 3187 res = ERR_CAST(root_mnt);
3186 if (IS_ERR(root_mnt)) 3188 if (!IS_ERR(root_mnt))
3187 goto out; 3189 res = nfs_follow_remote_path(root_mnt, export_path);
3188 3190 dprintk("<-- nfs4_referral_mount() = %ld%s\n",
3189 error = nfs_follow_remote_path(root_mnt, export_path, mnt); 3191 IS_ERR(res) ? PTR_ERR(res) : 0,
3190out: 3192 IS_ERR(res) ? " [error]" : "");
3191 dprintk("<-- nfs4_referral_get_sb() = %d%s\n", error, 3193 return res;
3192 error != 0 ? " [error]" : "");
3193 return error;
3194} 3194}
3195 3195
3196#endif /* CONFIG_NFS_V4 */ 3196#endif /* CONFIG_NFS_V4 */