aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/nfs/client.c10
-rw-r--r--fs/nfs/internal.h5
-rw-r--r--fs/nfs/super.c19
3 files changed, 26 insertions, 8 deletions
diff --git a/fs/nfs/client.c b/fs/nfs/client.c
index 003ebce4bbc4..1e106780a237 100644
--- a/fs/nfs/client.c
+++ b/fs/nfs/client.c
@@ -426,7 +426,7 @@ EXPORT_SYMBOL_GPL(nfs_mark_client_ready);
426 * Initialise the timeout values for a connection 426 * Initialise the timeout values for a connection
427 */ 427 */
428void nfs_init_timeout_values(struct rpc_timeout *to, int proto, 428void nfs_init_timeout_values(struct rpc_timeout *to, int proto,
429 unsigned int timeo, unsigned int retrans) 429 int timeo, int retrans)
430{ 430{
431 to->to_initval = timeo * HZ / 10; 431 to->to_initval = timeo * HZ / 10;
432 to->to_retries = retrans; 432 to->to_retries = retrans;
@@ -434,9 +434,9 @@ void nfs_init_timeout_values(struct rpc_timeout *to, int proto,
434 switch (proto) { 434 switch (proto) {
435 case XPRT_TRANSPORT_TCP: 435 case XPRT_TRANSPORT_TCP:
436 case XPRT_TRANSPORT_RDMA: 436 case XPRT_TRANSPORT_RDMA:
437 if (to->to_retries == 0) 437 if (retrans == NFS_UNSPEC_RETRANS)
438 to->to_retries = NFS_DEF_TCP_RETRANS; 438 to->to_retries = NFS_DEF_TCP_RETRANS;
439 if (to->to_initval == 0) 439 if (timeo == NFS_UNSPEC_TIMEO || to->to_retries == 0)
440 to->to_initval = NFS_DEF_TCP_TIMEO * HZ / 10; 440 to->to_initval = NFS_DEF_TCP_TIMEO * HZ / 10;
441 if (to->to_initval > NFS_MAX_TCP_TIMEOUT) 441 if (to->to_initval > NFS_MAX_TCP_TIMEOUT)
442 to->to_initval = NFS_MAX_TCP_TIMEOUT; 442 to->to_initval = NFS_MAX_TCP_TIMEOUT;
@@ -449,9 +449,9 @@ void nfs_init_timeout_values(struct rpc_timeout *to, int proto,
449 to->to_exponential = 0; 449 to->to_exponential = 0;
450 break; 450 break;
451 case XPRT_TRANSPORT_UDP: 451 case XPRT_TRANSPORT_UDP:
452 if (to->to_retries == 0) 452 if (retrans == NFS_UNSPEC_RETRANS)
453 to->to_retries = NFS_DEF_UDP_RETRANS; 453 to->to_retries = NFS_DEF_UDP_RETRANS;
454 if (!to->to_initval) 454 if (timeo == NFS_UNSPEC_TIMEO || to->to_initval == 0)
455 to->to_initval = NFS_DEF_UDP_TIMEO * HZ / 10; 455 to->to_initval = NFS_DEF_UDP_TIMEO * HZ / 10;
456 if (to->to_initval > NFS_MAX_UDP_TIMEOUT) 456 if (to->to_initval > NFS_MAX_UDP_TIMEOUT)
457 to->to_initval = NFS_MAX_UDP_TIMEOUT; 457 to->to_initval = NFS_MAX_UDP_TIMEOUT;
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index 7ce5e023c3c3..74935a19e4bf 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -58,6 +58,9 @@ struct nfs_clone_mount {
58 */ 58 */
59#define NFS_UNSPEC_PORT (-1) 59#define NFS_UNSPEC_PORT (-1)
60 60
61#define NFS_UNSPEC_RETRANS (UINT_MAX)
62#define NFS_UNSPEC_TIMEO (UINT_MAX)
63
61/* 64/*
62 * Maximum number of pages that readdir can use for creating 65 * Maximum number of pages that readdir can use for creating
63 * a vmapped array of pages. 66 * a vmapped array of pages.
@@ -156,7 +159,7 @@ struct nfs_client *nfs_get_client(const struct nfs_client_initdata *,
156int nfs_probe_fsinfo(struct nfs_server *server, struct nfs_fh *, struct nfs_fattr *); 159int nfs_probe_fsinfo(struct nfs_server *server, struct nfs_fh *, struct nfs_fattr *);
157void nfs_server_insert_lists(struct nfs_server *); 160void nfs_server_insert_lists(struct nfs_server *);
158void nfs_server_remove_lists(struct nfs_server *); 161void nfs_server_remove_lists(struct nfs_server *);
159void nfs_init_timeout_values(struct rpc_timeout *, int, unsigned int, unsigned int); 162void nfs_init_timeout_values(struct rpc_timeout *to, int proto, int timeo, int retrans);
160int nfs_init_server_rpcclient(struct nfs_server *, const struct rpc_timeout *t, 163int nfs_init_server_rpcclient(struct nfs_server *, const struct rpc_timeout *t,
161 rpc_authflavor_t); 164 rpc_authflavor_t);
162struct nfs_server *nfs_alloc_server(void); 165struct nfs_server *nfs_alloc_server(void);
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index 18d446e1a82b..d39601381adf 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -923,6 +923,8 @@ static struct nfs_parsed_mount_data *nfs_alloc_parsed_mount_data(void)
923 923
924 data = kzalloc(sizeof(*data), GFP_KERNEL); 924 data = kzalloc(sizeof(*data), GFP_KERNEL);
925 if (data) { 925 if (data) {
926 data->timeo = NFS_UNSPEC_TIMEO;
927 data->retrans = NFS_UNSPEC_RETRANS;
926 data->acregmin = NFS_DEF_ACREGMIN; 928 data->acregmin = NFS_DEF_ACREGMIN;
927 data->acregmax = NFS_DEF_ACREGMAX; 929 data->acregmax = NFS_DEF_ACREGMAX;
928 data->acdirmin = NFS_DEF_ACDIRMIN; 930 data->acdirmin = NFS_DEF_ACDIRMIN;
@@ -1189,6 +1191,19 @@ static int nfs_get_option_ul(substring_t args[], unsigned long *option)
1189 return rc; 1191 return rc;
1190} 1192}
1191 1193
1194static int nfs_get_option_ul_bound(substring_t args[], unsigned long *option,
1195 unsigned long l_bound, unsigned long u_bound)
1196{
1197 int ret;
1198
1199 ret = nfs_get_option_ul(args, option);
1200 if (ret != 0)
1201 return ret;
1202 if (*option < l_bound || *option > u_bound)
1203 return -ERANGE;
1204 return 0;
1205}
1206
1192/* 1207/*
1193 * Error-check and convert a string of mount options from user space into 1208 * Error-check and convert a string of mount options from user space into
1194 * a data structure. The whole mount string is processed; bad options are 1209 * a data structure. The whole mount string is processed; bad options are
@@ -1352,12 +1367,12 @@ static int nfs_parse_mount_options(char *raw,
1352 mnt->bsize = option; 1367 mnt->bsize = option;
1353 break; 1368 break;
1354 case Opt_timeo: 1369 case Opt_timeo:
1355 if (nfs_get_option_ul(args, &option) || option == 0) 1370 if (nfs_get_option_ul_bound(args, &option, 1, INT_MAX))
1356 goto out_invalid_value; 1371 goto out_invalid_value;
1357 mnt->timeo = option; 1372 mnt->timeo = option;
1358 break; 1373 break;
1359 case Opt_retrans: 1374 case Opt_retrans:
1360 if (nfs_get_option_ul(args, &option) || option == 0) 1375 if (nfs_get_option_ul_bound(args, &option, 0, INT_MAX))
1361 goto out_invalid_value; 1376 goto out_invalid_value;
1362 mnt->retrans = option; 1377 mnt->retrans = option;
1363 break; 1378 break;