aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/super.c
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2009-09-23 14:36:38 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2009-09-23 14:36:38 -0400
commit9423a08ad5773d0a7612d434700561dc8346b6d6 (patch)
tree3d43b5d0bd90526f64d5f3950f25e539fa14ed63 /fs/nfs/super.c
parent61d0a8e6a8049cea246ee7ec19b042d4ff1f6ef6 (diff)
NFS: Add nfs_alloc_parsed_mount_data
Allocating nfs_parsed_mount_data and setting up the defaults is nearly the same for both nfs and nfs4 mounts. Both paths seem to use nfs_validate_transport_protocol(), so setting a default value for nfs_server.protocol ought to be unnecessary. Signed-off-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/nfs/super.c')
-rw-r--r--fs/nfs/super.c50
1 files changed, 23 insertions, 27 deletions
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index ca278b3ff64f..92bbe1de4fcf 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -728,6 +728,27 @@ static void nfs_umount_begin(struct super_block *sb)
728 unlock_kernel(); 728 unlock_kernel();
729} 729}
730 730
731static struct nfs_parsed_mount_data *nfs_alloc_parsed_mount_data(int flags)
732{
733 struct nfs_parsed_mount_data *data;
734
735 data = kzalloc(sizeof(*data), GFP_KERNEL);
736 if (data) {
737 data->flags = flags;
738 data->rsize = NFS_MAX_FILE_IO_SIZE;
739 data->wsize = NFS_MAX_FILE_IO_SIZE;
740 data->acregmin = NFS_DEF_ACREGMIN;
741 data->acregmax = NFS_DEF_ACREGMAX;
742 data->acdirmin = NFS_DEF_ACDIRMIN;
743 data->acdirmax = NFS_DEF_ACDIRMAX;
744 data->nfs_server.port = NFS_UNSPEC_PORT;
745 data->auth_flavors[0] = RPC_AUTH_UNIX;
746 data->auth_flavor_len = 1;
747 data->minorversion = 0;
748 }
749 return data;
750}
751
731/* 752/*
732 * Sanity-check a server address provided by the mount command. 753 * Sanity-check a server address provided by the mount command.
733 * 754 *
@@ -1637,20 +1658,6 @@ static int nfs_validate_mount_data(void *options,
1637 if (data == NULL) 1658 if (data == NULL)
1638 goto out_no_data; 1659 goto out_no_data;
1639 1660
1640 args->flags = (NFS_MOUNT_VER3 | NFS_MOUNT_TCP);
1641 args->rsize = NFS_MAX_FILE_IO_SIZE;
1642 args->wsize = NFS_MAX_FILE_IO_SIZE;
1643 args->acregmin = NFS_DEF_ACREGMIN;
1644 args->acregmax = NFS_DEF_ACREGMAX;
1645 args->acdirmin = NFS_DEF_ACDIRMIN;
1646 args->acdirmax = NFS_DEF_ACDIRMAX;
1647 args->mount_server.port = NFS_UNSPEC_PORT;
1648 args->nfs_server.port = NFS_UNSPEC_PORT;
1649 args->nfs_server.protocol = XPRT_TRANSPORT_TCP;
1650 args->auth_flavors[0] = RPC_AUTH_UNIX;
1651 args->auth_flavor_len = 1;
1652 args->minorversion = 0;
1653
1654 switch (data->version) { 1661 switch (data->version) {
1655 case 1: 1662 case 1:
1656 data->namlen = 0; 1663 data->namlen = 0;
@@ -2097,7 +2104,7 @@ static int nfs_get_sb(struct file_system_type *fs_type,
2097 }; 2104 };
2098 int error = -ENOMEM; 2105 int error = -ENOMEM;
2099 2106
2100 data = kzalloc(sizeof(*data), GFP_KERNEL); 2107 data = nfs_alloc_parsed_mount_data(NFS_MOUNT_VER3 | NFS_MOUNT_TCP);
2101 mntfh = kzalloc(sizeof(*mntfh), GFP_KERNEL); 2108 mntfh = kzalloc(sizeof(*mntfh), GFP_KERNEL);
2102 if (data == NULL || mntfh == NULL) 2109 if (data == NULL || mntfh == NULL)
2103 goto out_free_fh; 2110 goto out_free_fh;
@@ -2365,18 +2372,7 @@ static int nfs4_validate_mount_data(void *options,
2365 if (data == NULL) 2372 if (data == NULL)
2366 goto out_no_data; 2373 goto out_no_data;
2367 2374
2368 args->rsize = NFS_MAX_FILE_IO_SIZE;
2369 args->wsize = NFS_MAX_FILE_IO_SIZE;
2370 args->acregmin = NFS_DEF_ACREGMIN;
2371 args->acregmax = NFS_DEF_ACREGMAX;
2372 args->acdirmin = NFS_DEF_ACDIRMIN;
2373 args->acdirmax = NFS_DEF_ACDIRMAX;
2374 args->nfs_server.port = NFS_UNSPEC_PORT;
2375 args->auth_flavors[0] = RPC_AUTH_UNIX;
2376 args->auth_flavor_len = 1;
2377 args->version = 4; 2375 args->version = 4;
2378 args->minorversion = 0;
2379
2380 switch (data->version) { 2376 switch (data->version) {
2381 case 1: 2377 case 1:
2382 if (data->host_addrlen > sizeof(args->nfs_server.address)) 2378 if (data->host_addrlen > sizeof(args->nfs_server.address))
@@ -2659,7 +2655,7 @@ static int nfs4_get_sb(struct file_system_type *fs_type,
2659 struct nfs_parsed_mount_data *data; 2655 struct nfs_parsed_mount_data *data;
2660 int error = -ENOMEM; 2656 int error = -ENOMEM;
2661 2657
2662 data = kzalloc(sizeof(*data), GFP_KERNEL); 2658 data = nfs_alloc_parsed_mount_data(0);
2663 if (data == NULL) 2659 if (data == NULL)
2664 goto out_free_data; 2660 goto out_free_data;
2665 2661