diff options
author | Bryan Schumaker <bjschuma@netapp.com> | 2012-05-10 15:07:36 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2012-05-14 20:30:28 -0400 |
commit | 3d176e3fe4f6dc379b252bf43e2e146a8f7caf01 (patch) | |
tree | c1d776845621fd53a73f60de14768cafabcb8db3 /fs/nfs | |
parent | 8c958e0c4c52d600bd2ea677eb920fceda8aee49 (diff) |
NFS: Use nfs_fs_mount_common() for xdev mounts
At this point, there are only a few small differences between these two
functions. I can set a few function pointers in the nfs_mount_info
struct to get around these differences.
Signed-off-by: Bryan Schumaker <bjschuma@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs')
-rw-r--r-- | fs/nfs/super.c | 96 |
1 files changed, 29 insertions, 67 deletions
diff --git a/fs/nfs/super.c b/fs/nfs/super.c index 707d1f67fb32..e93a6e95c031 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c | |||
@@ -279,6 +279,7 @@ static match_table_t nfs_vers_tokens = { | |||
279 | 279 | ||
280 | struct nfs_mount_info { | 280 | struct nfs_mount_info { |
281 | void (*fill_super)(struct super_block *, struct nfs_mount_info *); | 281 | void (*fill_super)(struct super_block *, struct nfs_mount_info *); |
282 | int (*set_security)(struct super_block *, struct dentry *, struct nfs_mount_info *); | ||
282 | struct nfs_parsed_mount_data *parsed; | 283 | struct nfs_parsed_mount_data *parsed; |
283 | struct nfs_clone_mount *cloned; | 284 | struct nfs_clone_mount *cloned; |
284 | }; | 285 | }; |
@@ -2312,6 +2313,22 @@ static int nfs_bdi_register(struct nfs_server *server) | |||
2312 | return bdi_register_dev(&server->backing_dev_info, server->s_dev); | 2313 | return bdi_register_dev(&server->backing_dev_info, server->s_dev); |
2313 | } | 2314 | } |
2314 | 2315 | ||
2316 | static int nfs_set_sb_security(struct super_block *s, struct dentry *mntroot, | ||
2317 | struct nfs_mount_info *mount_info) | ||
2318 | { | ||
2319 | return security_sb_set_mnt_opts(s, &mount_info->parsed->lsm_opts); | ||
2320 | } | ||
2321 | |||
2322 | static int nfs_clone_sb_security(struct super_block *s, struct dentry *mntroot, | ||
2323 | struct nfs_mount_info *mount_info) | ||
2324 | { | ||
2325 | /* clone any lsm security options from the parent to the new sb */ | ||
2326 | security_sb_clone_mnt_opts(mount_info->cloned->sb, s); | ||
2327 | if (mntroot->d_inode->i_op != NFS_SB(s)->nfs_client->rpc_ops->dir_inode_ops) | ||
2328 | return -ESTALE; | ||
2329 | return 0; | ||
2330 | } | ||
2331 | |||
2315 | static struct dentry *nfs_fs_mount_common(struct file_system_type *fs_type, | 2332 | static struct dentry *nfs_fs_mount_common(struct file_system_type *fs_type, |
2316 | struct nfs_server *server, | 2333 | struct nfs_server *server, |
2317 | int flags, const char *dev_name, | 2334 | int flags, const char *dev_name, |
@@ -2355,14 +2372,14 @@ static struct dentry *nfs_fs_mount_common(struct file_system_type *fs_type, | |||
2355 | if (!s->s_root) { | 2372 | if (!s->s_root) { |
2356 | /* initial superblock/root creation */ | 2373 | /* initial superblock/root creation */ |
2357 | mount_info->fill_super(s, mount_info); | 2374 | mount_info->fill_super(s, mount_info); |
2358 | nfs_get_cache_cookie(s, mount_info->parsed, NULL); | 2375 | nfs_get_cache_cookie(s, mount_info->parsed, mount_info->cloned); |
2359 | } | 2376 | } |
2360 | 2377 | ||
2361 | mntroot = nfs_get_root(s, mntfh, dev_name); | 2378 | mntroot = nfs_get_root(s, mntfh, dev_name); |
2362 | if (IS_ERR(mntroot)) | 2379 | if (IS_ERR(mntroot)) |
2363 | goto error_splat_super; | 2380 | goto error_splat_super; |
2364 | 2381 | ||
2365 | error = security_sb_set_mnt_opts(s, &mount_info->parsed->lsm_opts); | 2382 | error = mount_info->set_security(s, mntroot, mount_info); |
2366 | if (error) | 2383 | if (error) |
2367 | goto error_splat_root; | 2384 | goto error_splat_root; |
2368 | 2385 | ||
@@ -2393,6 +2410,7 @@ static struct dentry *nfs_fs_mount(struct file_system_type *fs_type, | |||
2393 | struct nfs_parsed_mount_data *data = NULL; | 2410 | struct nfs_parsed_mount_data *data = NULL; |
2394 | struct nfs_mount_info mount_info = { | 2411 | struct nfs_mount_info mount_info = { |
2395 | .fill_super = nfs_fill_super, | 2412 | .fill_super = nfs_fill_super, |
2413 | .set_security = nfs_set_sb_security, | ||
2396 | }; | 2414 | }; |
2397 | struct nfs_fh *mntfh; | 2415 | struct nfs_fh *mntfh; |
2398 | struct dentry *mntroot = ERR_PTR(-ENOMEM); | 2416 | struct dentry *mntroot = ERR_PTR(-ENOMEM); |
@@ -2463,13 +2481,8 @@ nfs_xdev_mount_common(struct file_system_type *fs_type, int flags, | |||
2463 | const char *dev_name, struct nfs_mount_info *mount_info) | 2481 | const char *dev_name, struct nfs_mount_info *mount_info) |
2464 | { | 2482 | { |
2465 | struct nfs_clone_mount *data = mount_info->cloned; | 2483 | struct nfs_clone_mount *data = mount_info->cloned; |
2466 | struct super_block *s; | ||
2467 | struct nfs_server *server; | 2484 | struct nfs_server *server; |
2468 | struct dentry *mntroot; | 2485 | struct dentry *mntroot = ERR_PTR(-ENOMEM); |
2469 | int (*compare_super)(struct super_block *, void *) = nfs_compare_super; | ||
2470 | struct nfs_sb_mountdata sb_mntdata = { | ||
2471 | .mntflags = flags, | ||
2472 | }; | ||
2473 | int error; | 2486 | int error; |
2474 | 2487 | ||
2475 | dprintk("--> nfs_xdev_mount_common()\n"); | 2488 | dprintk("--> nfs_xdev_mount_common()\n"); |
@@ -2478,71 +2491,17 @@ nfs_xdev_mount_common(struct file_system_type *fs_type, int flags, | |||
2478 | server = nfs_clone_server(NFS_SB(data->sb), data->fh, data->fattr, data->authflavor); | 2491 | server = nfs_clone_server(NFS_SB(data->sb), data->fh, data->fattr, data->authflavor); |
2479 | if (IS_ERR(server)) { | 2492 | if (IS_ERR(server)) { |
2480 | error = PTR_ERR(server); | 2493 | error = PTR_ERR(server); |
2481 | goto out_err_noserver; | 2494 | goto out_err; |
2482 | } | ||
2483 | sb_mntdata.server = server; | ||
2484 | |||
2485 | if (server->flags & NFS_MOUNT_UNSHARED) | ||
2486 | compare_super = NULL; | ||
2487 | |||
2488 | /* -o noac implies -o sync */ | ||
2489 | if (server->flags & NFS_MOUNT_NOAC) | ||
2490 | sb_mntdata.mntflags |= MS_SYNCHRONOUS; | ||
2491 | |||
2492 | /* Get a superblock - note that we may end up sharing one that already exists */ | ||
2493 | s = sget(&nfs_fs_type, compare_super, nfs_set_super, &sb_mntdata); | ||
2494 | if (IS_ERR(s)) { | ||
2495 | error = PTR_ERR(s); | ||
2496 | goto out_err_nosb; | ||
2497 | } | ||
2498 | |||
2499 | if (s->s_fs_info != server) { | ||
2500 | nfs_free_server(server); | ||
2501 | server = NULL; | ||
2502 | } else { | ||
2503 | error = nfs_bdi_register(server); | ||
2504 | if (error) | ||
2505 | goto error_splat_bdi; | ||
2506 | } | ||
2507 | |||
2508 | if (!s->s_root) { | ||
2509 | /* initial superblock/root creation */ | ||
2510 | mount_info->fill_super(s, mount_info); | ||
2511 | nfs_get_cache_cookie(s, NULL, data); | ||
2512 | } | ||
2513 | |||
2514 | mntroot = nfs_get_root(s, data->fh, dev_name); | ||
2515 | if (IS_ERR(mntroot)) { | ||
2516 | error = PTR_ERR(mntroot); | ||
2517 | goto error_splat_super; | ||
2518 | } | ||
2519 | if (mntroot->d_inode->i_op != NFS_SB(s)->nfs_client->rpc_ops->dir_inode_ops) { | ||
2520 | dput(mntroot); | ||
2521 | error = -ESTALE; | ||
2522 | goto error_splat_super; | ||
2523 | } | 2495 | } |
2524 | 2496 | ||
2525 | s->s_flags |= MS_ACTIVE; | 2497 | mntroot = nfs_fs_mount_common(fs_type, server, flags, dev_name, data->fh, mount_info); |
2526 | |||
2527 | /* clone any lsm security options from the parent to the new sb */ | ||
2528 | security_sb_clone_mnt_opts(data->sb, s); | ||
2529 | |||
2530 | dprintk("<-- nfs_xdev_mount_common() = 0\n"); | 2498 | dprintk("<-- nfs_xdev_mount_common() = 0\n"); |
2499 | out: | ||
2531 | return mntroot; | 2500 | return mntroot; |
2532 | 2501 | ||
2533 | out_err_nosb: | 2502 | out_err: |
2534 | nfs_free_server(server); | ||
2535 | out_err_noserver: | ||
2536 | dprintk("<-- nfs_xdev_mount_common() = %d [error]\n", error); | 2503 | dprintk("<-- nfs_xdev_mount_common() = %d [error]\n", error); |
2537 | return ERR_PTR(error); | 2504 | goto out; |
2538 | |||
2539 | error_splat_super: | ||
2540 | if (server && !s->s_root) | ||
2541 | bdi_unregister(&server->backing_dev_info); | ||
2542 | error_splat_bdi: | ||
2543 | deactivate_locked_super(s); | ||
2544 | dprintk("<-- nfs_xdev_mount_common() = %d [splat]\n", error); | ||
2545 | return ERR_PTR(error); | ||
2546 | } | 2505 | } |
2547 | 2506 | ||
2548 | /* | 2507 | /* |
@@ -2554,6 +2513,7 @@ nfs_xdev_mount(struct file_system_type *fs_type, int flags, | |||
2554 | { | 2513 | { |
2555 | struct nfs_mount_info mount_info = { | 2514 | struct nfs_mount_info mount_info = { |
2556 | .fill_super = nfs_clone_super, | 2515 | .fill_super = nfs_clone_super, |
2516 | .set_security = nfs_clone_sb_security, | ||
2557 | .cloned = raw_data, | 2517 | .cloned = raw_data, |
2558 | }; | 2518 | }; |
2559 | return nfs_xdev_mount_common(&nfs_fs_type, flags, dev_name, &mount_info); | 2519 | return nfs_xdev_mount_common(&nfs_fs_type, flags, dev_name, &mount_info); |
@@ -2740,6 +2700,7 @@ nfs4_remote_mount(struct file_system_type *fs_type, int flags, | |||
2740 | { | 2700 | { |
2741 | struct nfs_mount_info mount_info = { | 2701 | struct nfs_mount_info mount_info = { |
2742 | .fill_super = nfs4_fill_super, | 2702 | .fill_super = nfs4_fill_super, |
2703 | .set_security = nfs_set_sb_security, | ||
2743 | .parsed = raw_data, | 2704 | .parsed = raw_data, |
2744 | }; | 2705 | }; |
2745 | struct nfs_server *server; | 2706 | struct nfs_server *server; |
@@ -2949,6 +2910,7 @@ nfs4_xdev_mount(struct file_system_type *fs_type, int flags, | |||
2949 | { | 2910 | { |
2950 | struct nfs_mount_info mount_info = { | 2911 | struct nfs_mount_info mount_info = { |
2951 | .fill_super = nfs4_clone_super, | 2912 | .fill_super = nfs4_clone_super, |
2913 | .set_security = nfs_clone_sb_security, | ||
2952 | .cloned = raw_data, | 2914 | .cloned = raw_data, |
2953 | }; | 2915 | }; |
2954 | return nfs_xdev_mount_common(&nfs4_fs_type, flags, dev_name, &mount_info); | 2916 | return nfs_xdev_mount_common(&nfs4_fs_type, flags, dev_name, &mount_info); |