aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/super.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/nfs/super.c')
-rw-r--r--fs/nfs/super.c76
1 files changed, 40 insertions, 36 deletions
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index f1cc0587cfef..810770f96816 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 *
@@ -1430,10 +1451,13 @@ static int nfs_try_mount(struct nfs_parsed_mount_data *args,
1430 int status; 1451 int status;
1431 1452
1432 if (args->mount_server.version == 0) { 1453 if (args->mount_server.version == 0) {
1433 if (args->flags & NFS_MOUNT_VER3) 1454 switch (args->version) {
1434 args->mount_server.version = NFS_MNT3_VERSION; 1455 default:
1435 else 1456 args->mount_server.version = NFS_MNT3_VERSION;
1436 args->mount_server.version = NFS_MNT_VERSION; 1457 break;
1458 case 2:
1459 args->mount_server.version = NFS_MNT_VERSION;
1460 }
1437 } 1461 }
1438 request.version = args->mount_server.version; 1462 request.version = args->mount_server.version;
1439 1463
@@ -1634,20 +1658,6 @@ static int nfs_validate_mount_data(void *options,
1634 if (data == NULL) 1658 if (data == NULL)
1635 goto out_no_data; 1659 goto out_no_data;
1636 1660
1637 args->flags = (NFS_MOUNT_VER3 | NFS_MOUNT_TCP);
1638 args->rsize = NFS_MAX_FILE_IO_SIZE;
1639 args->wsize = NFS_MAX_FILE_IO_SIZE;
1640 args->acregmin = NFS_DEF_ACREGMIN;
1641 args->acregmax = NFS_DEF_ACREGMAX;
1642 args->acdirmin = NFS_DEF_ACDIRMIN;
1643 args->acdirmax = NFS_DEF_ACDIRMAX;
1644 args->mount_server.port = NFS_UNSPEC_PORT;
1645 args->nfs_server.port = NFS_UNSPEC_PORT;
1646 args->nfs_server.protocol = XPRT_TRANSPORT_TCP;
1647 args->auth_flavors[0] = RPC_AUTH_UNIX;
1648 args->auth_flavor_len = 1;
1649 args->minorversion = 0;
1650
1651 switch (data->version) { 1661 switch (data->version) {
1652 case 1: 1662 case 1:
1653 data->namlen = 0; 1663 data->namlen = 0;
@@ -1778,7 +1788,7 @@ static int nfs_validate_mount_data(void *options,
1778 } 1788 }
1779 1789
1780#ifndef CONFIG_NFS_V3 1790#ifndef CONFIG_NFS_V3
1781 if (args->flags & NFS_MOUNT_VER3) 1791 if (args->version == 3)
1782 goto out_v3_not_compiled; 1792 goto out_v3_not_compiled;
1783#endif /* !CONFIG_NFS_V3 */ 1793#endif /* !CONFIG_NFS_V3 */
1784 1794
@@ -1936,7 +1946,7 @@ static void nfs_fill_super(struct super_block *sb,
1936 if (data->bsize) 1946 if (data->bsize)
1937 sb->s_blocksize = nfs_block_size(data->bsize, &sb->s_blocksize_bits); 1947 sb->s_blocksize = nfs_block_size(data->bsize, &sb->s_blocksize_bits);
1938 1948
1939 if (server->flags & NFS_MOUNT_VER3) { 1949 if (server->nfs_client->rpc_ops->version == 3) {
1940 /* The VFS shouldn't apply the umask to mode bits. We will do 1950 /* The VFS shouldn't apply the umask to mode bits. We will do
1941 * so ourselves when necessary. 1951 * so ourselves when necessary.
1942 */ 1952 */
@@ -1960,7 +1970,7 @@ static void nfs_clone_super(struct super_block *sb,
1960 sb->s_blocksize = old_sb->s_blocksize; 1970 sb->s_blocksize = old_sb->s_blocksize;
1961 sb->s_maxbytes = old_sb->s_maxbytes; 1971 sb->s_maxbytes = old_sb->s_maxbytes;
1962 1972
1963 if (server->flags & NFS_MOUNT_VER3) { 1973 if (server->nfs_client->rpc_ops->version == 3) {
1964 /* The VFS shouldn't apply the umask to mode bits. We will do 1974 /* The VFS shouldn't apply the umask to mode bits. We will do
1965 * so ourselves when necessary. 1975 * so ourselves when necessary.
1966 */ 1976 */
@@ -2094,7 +2104,7 @@ static int nfs_get_sb(struct file_system_type *fs_type,
2094 }; 2104 };
2095 int error = -ENOMEM; 2105 int error = -ENOMEM;
2096 2106
2097 data = kzalloc(sizeof(*data), GFP_KERNEL); 2107 data = nfs_alloc_parsed_mount_data(NFS_MOUNT_VER3 | NFS_MOUNT_TCP);
2098 mntfh = kzalloc(sizeof(*mntfh), GFP_KERNEL); 2108 mntfh = kzalloc(sizeof(*mntfh), GFP_KERNEL);
2099 if (data == NULL || mntfh == NULL) 2109 if (data == NULL || mntfh == NULL)
2100 goto out_free_fh; 2110 goto out_free_fh;
@@ -2144,7 +2154,8 @@ static int nfs_get_sb(struct file_system_type *fs_type,
2144 if (!s->s_root) { 2154 if (!s->s_root) {
2145 /* initial superblock/root creation */ 2155 /* initial superblock/root creation */
2146 nfs_fill_super(s, data); 2156 nfs_fill_super(s, data);
2147 nfs_fscache_get_super_cookie(s, data); 2157 nfs_fscache_get_super_cookie(
2158 s, data ? data->fscache_uniq : NULL, NULL);
2148 } 2159 }
2149 2160
2150 mntroot = nfs_get_root(s, mntfh); 2161 mntroot = nfs_get_root(s, mntfh);
@@ -2245,6 +2256,7 @@ static int nfs_xdev_get_sb(struct file_system_type *fs_type, int flags,
2245 if (!s->s_root) { 2256 if (!s->s_root) {
2246 /* initial superblock/root creation */ 2257 /* initial superblock/root creation */
2247 nfs_clone_super(s, data->sb); 2258 nfs_clone_super(s, data->sb);
2259 nfs_fscache_get_super_cookie(s, NULL, data);
2248 } 2260 }
2249 2261
2250 mntroot = nfs_get_root(s, data->fh); 2262 mntroot = nfs_get_root(s, data->fh);
@@ -2362,18 +2374,7 @@ static int nfs4_validate_mount_data(void *options,
2362 if (data == NULL) 2374 if (data == NULL)
2363 goto out_no_data; 2375 goto out_no_data;
2364 2376
2365 args->rsize = NFS_MAX_FILE_IO_SIZE;
2366 args->wsize = NFS_MAX_FILE_IO_SIZE;
2367 args->acregmin = NFS_DEF_ACREGMIN;
2368 args->acregmax = NFS_DEF_ACREGMAX;
2369 args->acdirmin = NFS_DEF_ACDIRMIN;
2370 args->acdirmax = NFS_DEF_ACDIRMAX;
2371 args->nfs_server.port = NFS_UNSPEC_PORT;
2372 args->auth_flavors[0] = RPC_AUTH_UNIX;
2373 args->auth_flavor_len = 1;
2374 args->version = 4; 2377 args->version = 4;
2375 args->minorversion = 0;
2376
2377 switch (data->version) { 2378 switch (data->version) {
2378 case 1: 2379 case 1:
2379 if (data->host_addrlen > sizeof(args->nfs_server.address)) 2380 if (data->host_addrlen > sizeof(args->nfs_server.address))
@@ -2508,7 +2509,8 @@ static int nfs4_remote_get_sb(struct file_system_type *fs_type,
2508 if (!s->s_root) { 2509 if (!s->s_root) {
2509 /* initial superblock/root creation */ 2510 /* initial superblock/root creation */
2510 nfs4_fill_super(s); 2511 nfs4_fill_super(s);
2511 nfs_fscache_get_super_cookie(s, data); 2512 nfs_fscache_get_super_cookie(
2513 s, data ? data->fscache_uniq : NULL, NULL);
2512 } 2514 }
2513 2515
2514 mntroot = nfs4_get_root(s, mntfh); 2516 mntroot = nfs4_get_root(s, mntfh);
@@ -2656,7 +2658,7 @@ static int nfs4_get_sb(struct file_system_type *fs_type,
2656 struct nfs_parsed_mount_data *data; 2658 struct nfs_parsed_mount_data *data;
2657 int error = -ENOMEM; 2659 int error = -ENOMEM;
2658 2660
2659 data = kzalloc(sizeof(*data), GFP_KERNEL); 2661 data = nfs_alloc_parsed_mount_data(0);
2660 if (data == NULL) 2662 if (data == NULL)
2661 goto out_free_data; 2663 goto out_free_data;
2662 2664
@@ -2741,6 +2743,7 @@ static int nfs4_xdev_get_sb(struct file_system_type *fs_type, int flags,
2741 if (!s->s_root) { 2743 if (!s->s_root) {
2742 /* initial superblock/root creation */ 2744 /* initial superblock/root creation */
2743 nfs4_clone_super(s, data->sb); 2745 nfs4_clone_super(s, data->sb);
2746 nfs_fscache_get_super_cookie(s, NULL, data);
2744 } 2747 }
2745 2748
2746 mntroot = nfs4_get_root(s, data->fh); 2749 mntroot = nfs4_get_root(s, data->fh);
@@ -2822,6 +2825,7 @@ static int nfs4_remote_referral_get_sb(struct file_system_type *fs_type,
2822 if (!s->s_root) { 2825 if (!s->s_root) {
2823 /* initial superblock/root creation */ 2826 /* initial superblock/root creation */
2824 nfs4_fill_super(s); 2827 nfs4_fill_super(s);
2828 nfs_fscache_get_super_cookie(s, NULL, data);
2825 } 2829 }
2826 2830
2827 mntroot = nfs4_get_root(s, &mntfh); 2831 mntroot = nfs4_get_root(s, &mntfh);