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.c37
1 files changed, 18 insertions, 19 deletions
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 29786d3b9326..90be551b80c1 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -728,22 +728,24 @@ 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) 731static struct nfs_parsed_mount_data *nfs_alloc_parsed_mount_data(unsigned int version)
732{ 732{
733 struct nfs_parsed_mount_data *data; 733 struct nfs_parsed_mount_data *data;
734 734
735 data = kzalloc(sizeof(*data), GFP_KERNEL); 735 data = kzalloc(sizeof(*data), GFP_KERNEL);
736 if (data) { 736 if (data) {
737 data->flags = flags;
738 data->rsize = NFS_MAX_FILE_IO_SIZE; 737 data->rsize = NFS_MAX_FILE_IO_SIZE;
739 data->wsize = NFS_MAX_FILE_IO_SIZE; 738 data->wsize = NFS_MAX_FILE_IO_SIZE;
740 data->acregmin = NFS_DEF_ACREGMIN; 739 data->acregmin = NFS_DEF_ACREGMIN;
741 data->acregmax = NFS_DEF_ACREGMAX; 740 data->acregmax = NFS_DEF_ACREGMAX;
742 data->acdirmin = NFS_DEF_ACDIRMIN; 741 data->acdirmin = NFS_DEF_ACDIRMIN;
743 data->acdirmax = NFS_DEF_ACDIRMAX; 742 data->acdirmax = NFS_DEF_ACDIRMAX;
743 data->mount_server.port = NFS_UNSPEC_PORT;
744 data->nfs_server.port = NFS_UNSPEC_PORT; 744 data->nfs_server.port = NFS_UNSPEC_PORT;
745 data->nfs_server.protocol = XPRT_TRANSPORT_TCP;
745 data->auth_flavors[0] = RPC_AUTH_UNIX; 746 data->auth_flavors[0] = RPC_AUTH_UNIX;
746 data->auth_flavor_len = 1; 747 data->auth_flavor_len = 1;
748 data->version = version;
747 data->minorversion = 0; 749 data->minorversion = 0;
748 } 750 }
749 return data; 751 return data;
@@ -776,15 +778,13 @@ static int nfs_verify_server_address(struct sockaddr *addr)
776 * Select between a default port value and a user-specified port value. 778 * Select between a default port value and a user-specified port value.
777 * If a zero value is set, then autobind will be used. 779 * If a zero value is set, then autobind will be used.
778 */ 780 */
779static void nfs_set_default_port(struct sockaddr *sap, const int parsed_port, 781static void nfs_set_port(struct sockaddr *sap, int *port,
780 const unsigned short default_port) 782 const unsigned short default_port)
781{ 783{
782 unsigned short port = default_port; 784 if (*port == NFS_UNSPEC_PORT)
785 *port = default_port;
783 786
784 if (parsed_port != NFS_UNSPEC_PORT) 787 rpc_set_port(sap, *port);
785 port = parsed_port;
786
787 rpc_set_port(sap, port);
788} 788}
789 789
790/* 790/*
@@ -1253,6 +1253,7 @@ static int nfs_parse_mount_options(char *raw,
1253 default: 1253 default:
1254 dfprintk(MOUNT, "NFS: unrecognized " 1254 dfprintk(MOUNT, "NFS: unrecognized "
1255 "transport protocol\n"); 1255 "transport protocol\n");
1256 kfree(string);
1256 return 0; 1257 return 0;
1257 } 1258 }
1258 break; 1259 break;
@@ -1475,7 +1476,7 @@ static int nfs_try_mount(struct nfs_parsed_mount_data *args,
1475 args->mount_server.addrlen = args->nfs_server.addrlen; 1476 args->mount_server.addrlen = args->nfs_server.addrlen;
1476 } 1477 }
1477 request.salen = args->mount_server.addrlen; 1478 request.salen = args->mount_server.addrlen;
1478 nfs_set_default_port(request.sap, args->mount_server.port, 0); 1479 nfs_set_port(request.sap, &args->mount_server.port, 0);
1479 1480
1480 /* 1481 /*
1481 * Now ask the mount server to map our export path 1482 * Now ask the mount server to map our export path
@@ -1711,8 +1712,6 @@ static int nfs_validate_mount_data(void *options,
1711 1712
1712 if (!(data->flags & NFS_MOUNT_TCP)) 1713 if (!(data->flags & NFS_MOUNT_TCP))
1713 args->nfs_server.protocol = XPRT_TRANSPORT_UDP; 1714 args->nfs_server.protocol = XPRT_TRANSPORT_UDP;
1714 else
1715 args->nfs_server.protocol = XPRT_TRANSPORT_TCP;
1716 /* N.B. caller will free nfs_server.hostname in all cases */ 1715 /* N.B. caller will free nfs_server.hostname in all cases */
1717 args->nfs_server.hostname = kstrdup(data->hostname, GFP_KERNEL); 1716 args->nfs_server.hostname = kstrdup(data->hostname, GFP_KERNEL);
1718 args->namlen = data->namlen; 1717 args->namlen = data->namlen;
@@ -1767,7 +1766,7 @@ static int nfs_validate_mount_data(void *options,
1767 goto out_v4_not_compiled; 1766 goto out_v4_not_compiled;
1768#endif 1767#endif
1769 1768
1770 nfs_set_default_port(sap, args->nfs_server.port, 0); 1769 nfs_set_port(sap, &args->nfs_server.port, 0);
1771 1770
1772 nfs_set_mount_transport_protocol(args); 1771 nfs_set_mount_transport_protocol(args);
1773 1772
@@ -1848,9 +1847,10 @@ nfs_compare_remount_data(struct nfs_server *nfss,
1848 data->acdirmin != nfss->acdirmin / HZ || 1847 data->acdirmin != nfss->acdirmin / HZ ||
1849 data->acdirmax != nfss->acdirmax / HZ || 1848 data->acdirmax != nfss->acdirmax / HZ ||
1850 data->timeo != (10U * nfss->client->cl_timeout->to_initval / HZ) || 1849 data->timeo != (10U * nfss->client->cl_timeout->to_initval / HZ) ||
1850 data->nfs_server.port != nfss->port ||
1851 data->nfs_server.addrlen != nfss->nfs_client->cl_addrlen || 1851 data->nfs_server.addrlen != nfss->nfs_client->cl_addrlen ||
1852 memcmp(&data->nfs_server.address, &nfss->nfs_client->cl_addr, 1852 !rpc_cmp_addr((struct sockaddr *)&data->nfs_server.address,
1853 data->nfs_server.addrlen) != 0) 1853 (struct sockaddr *)&nfss->nfs_client->cl_addr))
1854 return -EINVAL; 1854 return -EINVAL;
1855 1855
1856 return 0; 1856 return 0;
@@ -1893,6 +1893,7 @@ nfs_remount(struct super_block *sb, int *flags, char *raw_data)
1893 data->acdirmin = nfss->acdirmin / HZ; 1893 data->acdirmin = nfss->acdirmin / HZ;
1894 data->acdirmax = nfss->acdirmax / HZ; 1894 data->acdirmax = nfss->acdirmax / HZ;
1895 data->timeo = 10U * nfss->client->cl_timeout->to_initval / HZ; 1895 data->timeo = 10U * nfss->client->cl_timeout->to_initval / HZ;
1896 data->nfs_server.port = nfss->port;
1896 data->nfs_server.addrlen = nfss->nfs_client->cl_addrlen; 1897 data->nfs_server.addrlen = nfss->nfs_client->cl_addrlen;
1897 memcpy(&data->nfs_server.address, &nfss->nfs_client->cl_addr, 1898 memcpy(&data->nfs_server.address, &nfss->nfs_client->cl_addr,
1898 data->nfs_server.addrlen); 1899 data->nfs_server.addrlen);
@@ -2106,7 +2107,7 @@ static int nfs_get_sb(struct file_system_type *fs_type,
2106 }; 2107 };
2107 int error = -ENOMEM; 2108 int error = -ENOMEM;
2108 2109
2109 data = nfs_alloc_parsed_mount_data(NFS_MOUNT_VER3 | NFS_MOUNT_TCP); 2110 data = nfs_alloc_parsed_mount_data(3);
2110 mntfh = kzalloc(sizeof(*mntfh), GFP_KERNEL); 2111 mntfh = kzalloc(sizeof(*mntfh), GFP_KERNEL);
2111 if (data == NULL || mntfh == NULL) 2112 if (data == NULL || mntfh == NULL)
2112 goto out_free_fh; 2113 goto out_free_fh;
@@ -2331,7 +2332,7 @@ static int nfs4_validate_text_mount_data(void *options,
2331{ 2332{
2332 struct sockaddr *sap = (struct sockaddr *)&args->nfs_server.address; 2333 struct sockaddr *sap = (struct sockaddr *)&args->nfs_server.address;
2333 2334
2334 nfs_set_default_port(sap, args->nfs_server.port, NFS_PORT); 2335 nfs_set_port(sap, &args->nfs_server.port, NFS_PORT);
2335 2336
2336 nfs_validate_transport_protocol(args); 2337 nfs_validate_transport_protocol(args);
2337 2338
@@ -2376,7 +2377,6 @@ static int nfs4_validate_mount_data(void *options,
2376 if (data == NULL) 2377 if (data == NULL)
2377 goto out_no_data; 2378 goto out_no_data;
2378 2379
2379 args->version = 4;
2380 switch (data->version) { 2380 switch (data->version) {
2381 case 1: 2381 case 1:
2382 if (data->host_addrlen > sizeof(args->nfs_server.address)) 2382 if (data->host_addrlen > sizeof(args->nfs_server.address))
@@ -2660,7 +2660,7 @@ static int nfs4_get_sb(struct file_system_type *fs_type,
2660 struct nfs_parsed_mount_data *data; 2660 struct nfs_parsed_mount_data *data;
2661 int error = -ENOMEM; 2661 int error = -ENOMEM;
2662 2662
2663 data = nfs_alloc_parsed_mount_data(0); 2663 data = nfs_alloc_parsed_mount_data(4);
2664 if (data == NULL) 2664 if (data == NULL)
2665 goto out_free_data; 2665 goto out_free_data;
2666 2666
@@ -2690,7 +2690,6 @@ static void nfs4_kill_super(struct super_block *sb)
2690 dprintk("--> %s\n", __func__); 2690 dprintk("--> %s\n", __func__);
2691 nfs_super_return_all_delegations(sb); 2691 nfs_super_return_all_delegations(sb);
2692 kill_anon_super(sb); 2692 kill_anon_super(sb);
2693 nfs4_renewd_prepare_shutdown(server);
2694 nfs_fscache_release_super_cookie(sb); 2693 nfs_fscache_release_super_cookie(sb);
2695 nfs_free_server(server); 2694 nfs_free_server(server);
2696 dprintk("<-- %s\n", __func__); 2695 dprintk("<-- %s\n", __func__);