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.c60
1 files changed, 42 insertions, 18 deletions
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 73a8e5970f02..9c1a960f5b94 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -817,6 +817,43 @@ static void nfs_parse_ip_address(char *string, size_t str_len,
817} 817}
818 818
819/* 819/*
820 * Sanity check the NFS transport protocol.
821 *
822 */
823static void nfs_validate_transport_protocol(struct nfs_parsed_mount_data *mnt)
824{
825 switch (mnt->nfs_server.protocol) {
826 case XPRT_TRANSPORT_UDP:
827 case XPRT_TRANSPORT_TCP:
828 case XPRT_TRANSPORT_RDMA:
829 break;
830 default:
831 mnt->nfs_server.protocol = XPRT_TRANSPORT_TCP;
832 }
833}
834
835/*
836 * For text based NFSv2/v3 mounts, the mount protocol transport default
837 * settings should depend upon the specified NFS transport.
838 */
839static void nfs_set_mount_transport_protocol(struct nfs_parsed_mount_data *mnt)
840{
841 nfs_validate_transport_protocol(mnt);
842
843 if (mnt->mount_server.protocol == XPRT_TRANSPORT_UDP ||
844 mnt->mount_server.protocol == XPRT_TRANSPORT_TCP)
845 return;
846 switch (mnt->nfs_server.protocol) {
847 case XPRT_TRANSPORT_UDP:
848 mnt->mount_server.protocol = XPRT_TRANSPORT_UDP;
849 break;
850 case XPRT_TRANSPORT_TCP:
851 case XPRT_TRANSPORT_RDMA:
852 mnt->mount_server.protocol = XPRT_TRANSPORT_TCP;
853 }
854}
855
856/*
820 * Error-check and convert a string of mount options from user space into 857 * Error-check and convert a string of mount options from user space into
821 * a data structure 858 * a data structure
822 */ 859 */
@@ -896,20 +933,14 @@ static int nfs_parse_mount_options(char *raw,
896 case Opt_udp: 933 case Opt_udp:
897 mnt->flags &= ~NFS_MOUNT_TCP; 934 mnt->flags &= ~NFS_MOUNT_TCP;
898 mnt->nfs_server.protocol = XPRT_TRANSPORT_UDP; 935 mnt->nfs_server.protocol = XPRT_TRANSPORT_UDP;
899 mnt->timeo = 7;
900 mnt->retrans = 5;
901 break; 936 break;
902 case Opt_tcp: 937 case Opt_tcp:
903 mnt->flags |= NFS_MOUNT_TCP; 938 mnt->flags |= NFS_MOUNT_TCP;
904 mnt->nfs_server.protocol = XPRT_TRANSPORT_TCP; 939 mnt->nfs_server.protocol = XPRT_TRANSPORT_TCP;
905 mnt->timeo = 600;
906 mnt->retrans = 2;
907 break; 940 break;
908 case Opt_rdma: 941 case Opt_rdma:
909 mnt->flags |= NFS_MOUNT_TCP; /* for side protocols */ 942 mnt->flags |= NFS_MOUNT_TCP; /* for side protocols */
910 mnt->nfs_server.protocol = XPRT_TRANSPORT_RDMA; 943 mnt->nfs_server.protocol = XPRT_TRANSPORT_RDMA;
911 mnt->timeo = 600;
912 mnt->retrans = 2;
913 break; 944 break;
914 case Opt_acl: 945 case Opt_acl:
915 mnt->flags &= ~NFS_MOUNT_NOACL; 946 mnt->flags &= ~NFS_MOUNT_NOACL;
@@ -1103,21 +1134,15 @@ static int nfs_parse_mount_options(char *raw,
1103 case Opt_xprt_udp: 1134 case Opt_xprt_udp:
1104 mnt->flags &= ~NFS_MOUNT_TCP; 1135 mnt->flags &= ~NFS_MOUNT_TCP;
1105 mnt->nfs_server.protocol = XPRT_TRANSPORT_UDP; 1136 mnt->nfs_server.protocol = XPRT_TRANSPORT_UDP;
1106 mnt->timeo = 7;
1107 mnt->retrans = 5;
1108 break; 1137 break;
1109 case Opt_xprt_tcp: 1138 case Opt_xprt_tcp:
1110 mnt->flags |= NFS_MOUNT_TCP; 1139 mnt->flags |= NFS_MOUNT_TCP;
1111 mnt->nfs_server.protocol = XPRT_TRANSPORT_TCP; 1140 mnt->nfs_server.protocol = XPRT_TRANSPORT_TCP;
1112 mnt->timeo = 600;
1113 mnt->retrans = 2;
1114 break; 1141 break;
1115 case Opt_xprt_rdma: 1142 case Opt_xprt_rdma:
1116 /* vector side protocols to TCP */ 1143 /* vector side protocols to TCP */
1117 mnt->flags |= NFS_MOUNT_TCP; 1144 mnt->flags |= NFS_MOUNT_TCP;
1118 mnt->nfs_server.protocol = XPRT_TRANSPORT_RDMA; 1145 mnt->nfs_server.protocol = XPRT_TRANSPORT_RDMA;
1119 mnt->timeo = 600;
1120 mnt->retrans = 2;
1121 break; 1146 break;
1122 default: 1147 default:
1123 goto out_unrec_xprt; 1148 goto out_unrec_xprt;
@@ -1438,14 +1463,11 @@ static int nfs_validate_mount_data(void *options,
1438 args->flags = (NFS_MOUNT_VER3 | NFS_MOUNT_TCP); 1463 args->flags = (NFS_MOUNT_VER3 | NFS_MOUNT_TCP);
1439 args->rsize = NFS_MAX_FILE_IO_SIZE; 1464 args->rsize = NFS_MAX_FILE_IO_SIZE;
1440 args->wsize = NFS_MAX_FILE_IO_SIZE; 1465 args->wsize = NFS_MAX_FILE_IO_SIZE;
1441 args->timeo = 600;
1442 args->retrans = 2;
1443 args->acregmin = 3; 1466 args->acregmin = 3;
1444 args->acregmax = 60; 1467 args->acregmax = 60;
1445 args->acdirmin = 30; 1468 args->acdirmin = 30;
1446 args->acdirmax = 60; 1469 args->acdirmax = 60;
1447 args->mount_server.port = 0; /* autobind unless user sets port */ 1470 args->mount_server.port = 0; /* autobind unless user sets port */
1448 args->mount_server.protocol = XPRT_TRANSPORT_UDP;
1449 args->nfs_server.port = 0; /* autobind unless user sets port */ 1471 args->nfs_server.port = 0; /* autobind unless user sets port */
1450 args->nfs_server.protocol = XPRT_TRANSPORT_TCP; 1472 args->nfs_server.protocol = XPRT_TRANSPORT_TCP;
1451 1473
@@ -1546,6 +1568,8 @@ static int nfs_validate_mount_data(void *options,
1546 &args->nfs_server.address)) 1568 &args->nfs_server.address))
1547 goto out_no_address; 1569 goto out_no_address;
1548 1570
1571 nfs_set_mount_transport_protocol(args);
1572
1549 status = nfs_parse_devname(dev_name, 1573 status = nfs_parse_devname(dev_name,
1550 &args->nfs_server.hostname, 1574 &args->nfs_server.hostname,
1551 PAGE_SIZE, 1575 PAGE_SIZE,
@@ -2095,14 +2119,11 @@ static int nfs4_validate_mount_data(void *options,
2095 2119
2096 args->rsize = NFS_MAX_FILE_IO_SIZE; 2120 args->rsize = NFS_MAX_FILE_IO_SIZE;
2097 args->wsize = NFS_MAX_FILE_IO_SIZE; 2121 args->wsize = NFS_MAX_FILE_IO_SIZE;
2098 args->timeo = 600;
2099 args->retrans = 2;
2100 args->acregmin = 3; 2122 args->acregmin = 3;
2101 args->acregmax = 60; 2123 args->acregmax = 60;
2102 args->acdirmin = 30; 2124 args->acdirmin = 30;
2103 args->acdirmax = 60; 2125 args->acdirmax = 60;
2104 args->nfs_server.port = NFS_PORT; /* 2049 unless user set port= */ 2126 args->nfs_server.port = NFS_PORT; /* 2049 unless user set port= */
2105 args->nfs_server.protocol = XPRT_TRANSPORT_TCP;
2106 2127
2107 switch (data->version) { 2128 switch (data->version) {
2108 case 1: 2129 case 1:
@@ -2163,6 +2184,7 @@ static int nfs4_validate_mount_data(void *options,
2163 args->acdirmin = data->acdirmin; 2184 args->acdirmin = data->acdirmin;
2164 args->acdirmax = data->acdirmax; 2185 args->acdirmax = data->acdirmax;
2165 args->nfs_server.protocol = data->proto; 2186 args->nfs_server.protocol = data->proto;
2187 nfs_validate_transport_protocol(args);
2166 2188
2167 break; 2189 break;
2168 default: { 2190 default: {
@@ -2175,6 +2197,8 @@ static int nfs4_validate_mount_data(void *options,
2175 &args->nfs_server.address)) 2197 &args->nfs_server.address))
2176 return -EINVAL; 2198 return -EINVAL;
2177 2199
2200 nfs_validate_transport_protocol(args);
2201
2178 switch (args->auth_flavor_len) { 2202 switch (args->auth_flavor_len) {
2179 case 0: 2203 case 0:
2180 args->auth_flavors[0] = RPC_AUTH_UNIX; 2204 args->auth_flavors[0] = RPC_AUTH_UNIX;