提交 259875ef 编写于 作者: T Trond Myklebust

NFS: set transport defaults after mount option parsing is finished

Move the UDP/TCP default timeo/retrans settings for text mounts to
nfs_init_timeout_values(), which was were they were always being
initialised (and sanity checked) for binary mounts.
Document the default timeout values using appropriate #defines.

Ensure that we initialise and sanity check the transport protocols that
may have been specified by the user.
Signed-off-by: NTrond Myklebust <Trond.Myklebust@netapp.com>
上级 40fef8a6
...@@ -431,14 +431,14 @@ static void nfs_init_timeout_values(struct rpc_timeout *to, int proto, ...@@ -431,14 +431,14 @@ static void nfs_init_timeout_values(struct rpc_timeout *to, int proto,
{ {
to->to_initval = timeo * HZ / 10; to->to_initval = timeo * HZ / 10;
to->to_retries = retrans; to->to_retries = retrans;
if (!to->to_retries)
to->to_retries = 2;
switch (proto) { switch (proto) {
case XPRT_TRANSPORT_TCP: case XPRT_TRANSPORT_TCP:
case XPRT_TRANSPORT_RDMA: case XPRT_TRANSPORT_RDMA:
if (to->to_retries == 0)
to->to_retries = NFS_DEF_TCP_RETRANS;
if (to->to_initval == 0) if (to->to_initval == 0)
to->to_initval = 60 * HZ; to->to_initval = NFS_DEF_TCP_TIMEO * HZ / 10;
if (to->to_initval > NFS_MAX_TCP_TIMEOUT) if (to->to_initval > NFS_MAX_TCP_TIMEOUT)
to->to_initval = NFS_MAX_TCP_TIMEOUT; to->to_initval = NFS_MAX_TCP_TIMEOUT;
to->to_increment = to->to_initval; to->to_increment = to->to_initval;
...@@ -450,14 +450,17 @@ static void nfs_init_timeout_values(struct rpc_timeout *to, int proto, ...@@ -450,14 +450,17 @@ static void nfs_init_timeout_values(struct rpc_timeout *to, int proto,
to->to_exponential = 0; to->to_exponential = 0;
break; break;
case XPRT_TRANSPORT_UDP: case XPRT_TRANSPORT_UDP:
default: if (to->to_retries == 0)
to->to_retries = NFS_DEF_UDP_RETRANS;
if (!to->to_initval) if (!to->to_initval)
to->to_initval = 11 * HZ / 10; to->to_initval = NFS_DEF_UDP_TIMEO * HZ / 10;
if (to->to_initval > NFS_MAX_UDP_TIMEOUT) if (to->to_initval > NFS_MAX_UDP_TIMEOUT)
to->to_initval = NFS_MAX_UDP_TIMEOUT; to->to_initval = NFS_MAX_UDP_TIMEOUT;
to->to_maxval = NFS_MAX_UDP_TIMEOUT; to->to_maxval = NFS_MAX_UDP_TIMEOUT;
to->to_exponential = 1; to->to_exponential = 1;
break; break;
default:
BUG();
} }
} }
......
...@@ -816,6 +816,43 @@ static void nfs_parse_ip_address(char *string, size_t str_len, ...@@ -816,6 +816,43 @@ static void nfs_parse_ip_address(char *string, size_t str_len,
nfs_parse_ipv4_address(string, str_len, sap, addr_len); nfs_parse_ipv4_address(string, str_len, sap, addr_len);
} }
/*
* Sanity check the NFS transport protocol.
*
*/
static void nfs_validate_transport_protocol(struct nfs_parsed_mount_data *mnt)
{
switch (mnt->nfs_server.protocol) {
case XPRT_TRANSPORT_UDP:
case XPRT_TRANSPORT_TCP:
case XPRT_TRANSPORT_RDMA:
break;
default:
mnt->nfs_server.protocol = XPRT_TRANSPORT_TCP;
}
}
/*
* For text based NFSv2/v3 mounts, the mount protocol transport default
* settings should depend upon the specified NFS transport.
*/
static void nfs_set_mount_transport_protocol(struct nfs_parsed_mount_data *mnt)
{
nfs_validate_transport_protocol(mnt);
if (mnt->mount_server.protocol == XPRT_TRANSPORT_UDP ||
mnt->mount_server.protocol == XPRT_TRANSPORT_TCP)
return;
switch (mnt->nfs_server.protocol) {
case XPRT_TRANSPORT_UDP:
mnt->mount_server.protocol = XPRT_TRANSPORT_UDP;
break;
case XPRT_TRANSPORT_TCP:
case XPRT_TRANSPORT_RDMA:
mnt->mount_server.protocol = XPRT_TRANSPORT_TCP;
}
}
/* /*
* Error-check and convert a string of mount options from user space into * Error-check and convert a string of mount options from user space into
* a data structure * a data structure
...@@ -896,20 +933,14 @@ static int nfs_parse_mount_options(char *raw, ...@@ -896,20 +933,14 @@ static int nfs_parse_mount_options(char *raw,
case Opt_udp: case Opt_udp:
mnt->flags &= ~NFS_MOUNT_TCP; mnt->flags &= ~NFS_MOUNT_TCP;
mnt->nfs_server.protocol = XPRT_TRANSPORT_UDP; mnt->nfs_server.protocol = XPRT_TRANSPORT_UDP;
mnt->timeo = 7;
mnt->retrans = 5;
break; break;
case Opt_tcp: case Opt_tcp:
mnt->flags |= NFS_MOUNT_TCP; mnt->flags |= NFS_MOUNT_TCP;
mnt->nfs_server.protocol = XPRT_TRANSPORT_TCP; mnt->nfs_server.protocol = XPRT_TRANSPORT_TCP;
mnt->timeo = 600;
mnt->retrans = 2;
break; break;
case Opt_rdma: case Opt_rdma:
mnt->flags |= NFS_MOUNT_TCP; /* for side protocols */ mnt->flags |= NFS_MOUNT_TCP; /* for side protocols */
mnt->nfs_server.protocol = XPRT_TRANSPORT_RDMA; mnt->nfs_server.protocol = XPRT_TRANSPORT_RDMA;
mnt->timeo = 600;
mnt->retrans = 2;
break; break;
case Opt_acl: case Opt_acl:
mnt->flags &= ~NFS_MOUNT_NOACL; mnt->flags &= ~NFS_MOUNT_NOACL;
...@@ -1103,21 +1134,15 @@ static int nfs_parse_mount_options(char *raw, ...@@ -1103,21 +1134,15 @@ static int nfs_parse_mount_options(char *raw,
case Opt_xprt_udp: case Opt_xprt_udp:
mnt->flags &= ~NFS_MOUNT_TCP; mnt->flags &= ~NFS_MOUNT_TCP;
mnt->nfs_server.protocol = XPRT_TRANSPORT_UDP; mnt->nfs_server.protocol = XPRT_TRANSPORT_UDP;
mnt->timeo = 7;
mnt->retrans = 5;
break; break;
case Opt_xprt_tcp: case Opt_xprt_tcp:
mnt->flags |= NFS_MOUNT_TCP; mnt->flags |= NFS_MOUNT_TCP;
mnt->nfs_server.protocol = XPRT_TRANSPORT_TCP; mnt->nfs_server.protocol = XPRT_TRANSPORT_TCP;
mnt->timeo = 600;
mnt->retrans = 2;
break; break;
case Opt_xprt_rdma: case Opt_xprt_rdma:
/* vector side protocols to TCP */ /* vector side protocols to TCP */
mnt->flags |= NFS_MOUNT_TCP; mnt->flags |= NFS_MOUNT_TCP;
mnt->nfs_server.protocol = XPRT_TRANSPORT_RDMA; mnt->nfs_server.protocol = XPRT_TRANSPORT_RDMA;
mnt->timeo = 600;
mnt->retrans = 2;
break; break;
default: default:
goto out_unrec_xprt; goto out_unrec_xprt;
...@@ -1438,14 +1463,11 @@ static int nfs_validate_mount_data(void *options, ...@@ -1438,14 +1463,11 @@ static int nfs_validate_mount_data(void *options,
args->flags = (NFS_MOUNT_VER3 | NFS_MOUNT_TCP); args->flags = (NFS_MOUNT_VER3 | NFS_MOUNT_TCP);
args->rsize = NFS_MAX_FILE_IO_SIZE; args->rsize = NFS_MAX_FILE_IO_SIZE;
args->wsize = NFS_MAX_FILE_IO_SIZE; args->wsize = NFS_MAX_FILE_IO_SIZE;
args->timeo = 600;
args->retrans = 2;
args->acregmin = 3; args->acregmin = 3;
args->acregmax = 60; args->acregmax = 60;
args->acdirmin = 30; args->acdirmin = 30;
args->acdirmax = 60; args->acdirmax = 60;
args->mount_server.port = 0; /* autobind unless user sets port */ args->mount_server.port = 0; /* autobind unless user sets port */
args->mount_server.protocol = XPRT_TRANSPORT_UDP;
args->nfs_server.port = 0; /* autobind unless user sets port */ args->nfs_server.port = 0; /* autobind unless user sets port */
args->nfs_server.protocol = XPRT_TRANSPORT_TCP; args->nfs_server.protocol = XPRT_TRANSPORT_TCP;
...@@ -1546,6 +1568,8 @@ static int nfs_validate_mount_data(void *options, ...@@ -1546,6 +1568,8 @@ static int nfs_validate_mount_data(void *options,
&args->nfs_server.address)) &args->nfs_server.address))
goto out_no_address; goto out_no_address;
nfs_set_mount_transport_protocol(args);
status = nfs_parse_devname(dev_name, status = nfs_parse_devname(dev_name,
&args->nfs_server.hostname, &args->nfs_server.hostname,
PAGE_SIZE, PAGE_SIZE,
...@@ -2095,14 +2119,11 @@ static int nfs4_validate_mount_data(void *options, ...@@ -2095,14 +2119,11 @@ static int nfs4_validate_mount_data(void *options,
args->rsize = NFS_MAX_FILE_IO_SIZE; args->rsize = NFS_MAX_FILE_IO_SIZE;
args->wsize = NFS_MAX_FILE_IO_SIZE; args->wsize = NFS_MAX_FILE_IO_SIZE;
args->timeo = 600;
args->retrans = 2;
args->acregmin = 3; args->acregmin = 3;
args->acregmax = 60; args->acregmax = 60;
args->acdirmin = 30; args->acdirmin = 30;
args->acdirmax = 60; args->acdirmax = 60;
args->nfs_server.port = NFS_PORT; /* 2049 unless user set port= */ args->nfs_server.port = NFS_PORT; /* 2049 unless user set port= */
args->nfs_server.protocol = XPRT_TRANSPORT_TCP;
switch (data->version) { switch (data->version) {
case 1: case 1:
...@@ -2163,6 +2184,7 @@ static int nfs4_validate_mount_data(void *options, ...@@ -2163,6 +2184,7 @@ static int nfs4_validate_mount_data(void *options,
args->acdirmin = data->acdirmin; args->acdirmin = data->acdirmin;
args->acdirmax = data->acdirmax; args->acdirmax = data->acdirmax;
args->nfs_server.protocol = data->proto; args->nfs_server.protocol = data->proto;
nfs_validate_transport_protocol(args);
break; break;
default: { default: {
...@@ -2175,6 +2197,8 @@ static int nfs4_validate_mount_data(void *options, ...@@ -2175,6 +2197,8 @@ static int nfs4_validate_mount_data(void *options,
&args->nfs_server.address)) &args->nfs_server.address))
return -EINVAL; return -EINVAL;
nfs_validate_transport_protocol(args);
switch (args->auth_flavor_len) { switch (args->auth_flavor_len) {
case 0: case 0:
args->auth_flavors[0] = RPC_AUTH_UNIX; args->auth_flavors[0] = RPC_AUTH_UNIX;
......
...@@ -12,6 +12,11 @@ ...@@ -12,6 +12,11 @@
#include <linux/magic.h> #include <linux/magic.h>
/* Default timeout values */ /* Default timeout values */
#define NFS_DEF_UDP_TIMEO (11)
#define NFS_DEF_UDP_RETRANS (3)
#define NFS_DEF_TCP_TIMEO (600)
#define NFS_DEF_TCP_RETRANS (2)
#define NFS_MAX_UDP_TIMEOUT (60*HZ) #define NFS_MAX_UDP_TIMEOUT (60*HZ)
#define NFS_MAX_TCP_TIMEOUT (600*HZ) #define NFS_MAX_TCP_TIMEOUT (600*HZ)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册