diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2009-09-08 19:50:00 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2009-09-08 19:50:00 -0400 |
commit | a6fe23be90aa78783523a25330e09bfaa43a1581 (patch) | |
tree | f77656861a6464f114e2e4bf5b9f5016bf18c0c5 /fs | |
parent | 7630c852e19c7fffb85b50d98eeb5516fec7c088 (diff) |
NFS: Move details of nfs4_get_sb() to a helper
Clean up: Refactor nfs4_get_sb() to allow its guts to be invoked by
nfs_get_sb().
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/nfs/super.c | 44 |
1 files changed, 31 insertions, 13 deletions
diff --git a/fs/nfs/super.c b/fs/nfs/super.c index 599e8c5fe6ce..c105e12197c2 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c | |||
@@ -274,6 +274,8 @@ static const struct super_operations nfs_sops = { | |||
274 | #ifdef CONFIG_NFS_V4 | 274 | #ifdef CONFIG_NFS_V4 |
275 | static int nfs4_validate_text_mount_data(void *options, | 275 | static int nfs4_validate_text_mount_data(void *options, |
276 | struct nfs_parsed_mount_data *args, const char *dev_name); | 276 | struct nfs_parsed_mount_data *args, const char *dev_name); |
277 | static int nfs4_try_mount(int flags, const char *dev_name, | ||
278 | struct nfs_parsed_mount_data *data, struct vfsmount *mnt); | ||
277 | static int nfs4_get_sb(struct file_system_type *fs_type, | 279 | static int nfs4_get_sb(struct file_system_type *fs_type, |
278 | int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt); | 280 | int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt); |
279 | static int nfs4_remote_get_sb(struct file_system_type *fs_type, | 281 | static int nfs4_remote_get_sb(struct file_system_type *fs_type, |
@@ -2565,6 +2567,34 @@ out_err: | |||
2565 | return ret; | 2567 | return ret; |
2566 | } | 2568 | } |
2567 | 2569 | ||
2570 | static int nfs4_try_mount(int flags, const char *dev_name, | ||
2571 | struct nfs_parsed_mount_data *data, | ||
2572 | struct vfsmount *mnt) | ||
2573 | { | ||
2574 | char *export_path; | ||
2575 | struct vfsmount *root_mnt; | ||
2576 | int error; | ||
2577 | |||
2578 | dfprintk(MOUNT, "--> nfs4_try_mount()\n"); | ||
2579 | |||
2580 | export_path = data->nfs_server.export_path; | ||
2581 | data->nfs_server.export_path = "/"; | ||
2582 | root_mnt = nfs_do_root_mount(&nfs4_remote_fs_type, flags, data, | ||
2583 | data->nfs_server.hostname); | ||
2584 | data->nfs_server.export_path = export_path; | ||
2585 | |||
2586 | error = PTR_ERR(root_mnt); | ||
2587 | if (IS_ERR(root_mnt)) | ||
2588 | goto out; | ||
2589 | |||
2590 | error = nfs_follow_remote_path(root_mnt, export_path, mnt); | ||
2591 | |||
2592 | out: | ||
2593 | dfprintk(MOUNT, "<-- nfs4_try_mount() = %d%s\n", error, | ||
2594 | error != 0 ? " [error]" : ""); | ||
2595 | return error; | ||
2596 | } | ||
2597 | |||
2568 | /* | 2598 | /* |
2569 | * Get the superblock for an NFS4 mountpoint | 2599 | * Get the superblock for an NFS4 mountpoint |
2570 | */ | 2600 | */ |
@@ -2572,8 +2602,6 @@ static int nfs4_get_sb(struct file_system_type *fs_type, | |||
2572 | int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt) | 2602 | int flags, const char *dev_name, void *raw_data, struct vfsmount *mnt) |
2573 | { | 2603 | { |
2574 | struct nfs_parsed_mount_data *data; | 2604 | struct nfs_parsed_mount_data *data; |
2575 | char *export_path; | ||
2576 | struct vfsmount *root_mnt; | ||
2577 | int error = -ENOMEM; | 2605 | int error = -ENOMEM; |
2578 | 2606 | ||
2579 | data = kzalloc(sizeof(*data), GFP_KERNEL); | 2607 | data = kzalloc(sizeof(*data), GFP_KERNEL); |
@@ -2585,17 +2613,7 @@ static int nfs4_get_sb(struct file_system_type *fs_type, | |||
2585 | if (error < 0) | 2613 | if (error < 0) |
2586 | goto out; | 2614 | goto out; |
2587 | 2615 | ||
2588 | export_path = data->nfs_server.export_path; | 2616 | error = nfs4_try_mount(flags, dev_name, data, mnt); |
2589 | data->nfs_server.export_path = "/"; | ||
2590 | root_mnt = nfs_do_root_mount(&nfs4_remote_fs_type, flags, data, | ||
2591 | data->nfs_server.hostname); | ||
2592 | data->nfs_server.export_path = export_path; | ||
2593 | |||
2594 | error = PTR_ERR(root_mnt); | ||
2595 | if (IS_ERR(root_mnt)) | ||
2596 | goto out; | ||
2597 | |||
2598 | error = nfs_follow_remote_path(root_mnt, export_path, mnt); | ||
2599 | 2617 | ||
2600 | out: | 2618 | out: |
2601 | kfree(data->client_address); | 2619 | kfree(data->client_address); |