提交 59dca3b2 编写于 作者: T Trond Myklebust

NFS: Fix the 'proto=' mount option

Currently, if you have a server mounted using networking protocol, you
cannot specify a different value using the 'proto=' option on another
mountpoint.
Signed-off-by: NTrond Myklebust <Trond.Myklebust@netapp.com>
上级 33170233
...@@ -100,6 +100,7 @@ struct nfs_client_initdata { ...@@ -100,6 +100,7 @@ struct nfs_client_initdata {
const struct sockaddr *addr; const struct sockaddr *addr;
size_t addrlen; size_t addrlen;
const struct nfs_rpc_ops *rpc_ops; const struct nfs_rpc_ops *rpc_ops;
int proto;
}; };
/* /*
...@@ -138,6 +139,8 @@ static struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *cl_ ...@@ -138,6 +139,8 @@ static struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *cl_
INIT_LIST_HEAD(&clp->cl_superblocks); INIT_LIST_HEAD(&clp->cl_superblocks);
clp->cl_rpcclient = ERR_PTR(-EINVAL); clp->cl_rpcclient = ERR_PTR(-EINVAL);
clp->cl_proto = cl_init->proto;
#ifdef CONFIG_NFS_V4 #ifdef CONFIG_NFS_V4
init_rwsem(&clp->cl_sem); init_rwsem(&clp->cl_sem);
INIT_LIST_HEAD(&clp->cl_delegations); INIT_LIST_HEAD(&clp->cl_delegations);
...@@ -289,6 +292,9 @@ static struct nfs_client *nfs_match_client(const struct nfs_client_initdata *dat ...@@ -289,6 +292,9 @@ static struct nfs_client *nfs_match_client(const struct nfs_client_initdata *dat
if (clp->rpc_ops != data->rpc_ops) if (clp->rpc_ops != data->rpc_ops)
continue; continue;
if (clp->cl_proto != data->proto)
continue;
/* Match the full socket address */ /* Match the full socket address */
if (memcmp(&clp->cl_addr, data->addr, sizeof(clp->cl_addr)) != 0) if (memcmp(&clp->cl_addr, data->addr, sizeof(clp->cl_addr)) != 0)
continue; continue;
...@@ -414,14 +420,14 @@ static void nfs_init_timeout_values(struct rpc_timeout *to, int proto, ...@@ -414,14 +420,14 @@ static void nfs_init_timeout_values(struct rpc_timeout *to, int proto,
/* /*
* Create an RPC client handle * Create an RPC client handle
*/ */
static int nfs_create_rpc_client(struct nfs_client *clp, int proto, static int nfs_create_rpc_client(struct nfs_client *clp,
const struct rpc_timeout *timeparms, const struct rpc_timeout *timeparms,
rpc_authflavor_t flavor, rpc_authflavor_t flavor,
int flags) int flags)
{ {
struct rpc_clnt *clnt = NULL; struct rpc_clnt *clnt = NULL;
struct rpc_create_args args = { struct rpc_create_args args = {
.protocol = proto, .protocol = clp->cl_proto,
.address = (struct sockaddr *)&clp->cl_addr, .address = (struct sockaddr *)&clp->cl_addr,
.addrsize = clp->cl_addrlen, .addrsize = clp->cl_addrlen,
.timeout = timeparms, .timeout = timeparms,
...@@ -565,8 +571,7 @@ static int nfs_init_client(struct nfs_client *clp, ...@@ -565,8 +571,7 @@ static int nfs_init_client(struct nfs_client *clp,
* Create a client RPC handle for doing FSSTAT with UNIX auth only * Create a client RPC handle for doing FSSTAT with UNIX auth only
* - RFC 2623, sec 2.3.2 * - RFC 2623, sec 2.3.2
*/ */
error = nfs_create_rpc_client(clp, data->nfs_server.protocol, error = nfs_create_rpc_client(clp, timeparms, RPC_AUTH_UNIX, 0);
timeparms, RPC_AUTH_UNIX, 0);
if (error < 0) if (error < 0)
goto error; goto error;
nfs_mark_client_ready(clp, NFS_CS_READY); nfs_mark_client_ready(clp, NFS_CS_READY);
...@@ -589,6 +594,7 @@ static int nfs_init_server(struct nfs_server *server, ...@@ -589,6 +594,7 @@ static int nfs_init_server(struct nfs_server *server,
.addr = (const struct sockaddr *)&data->nfs_server.address, .addr = (const struct sockaddr *)&data->nfs_server.address,
.addrlen = data->nfs_server.addrlen, .addrlen = data->nfs_server.addrlen,
.rpc_ops = &nfs_v2_clientops, .rpc_ops = &nfs_v2_clientops,
.proto = data->nfs_server.protocol,
}; };
struct rpc_timeout timeparms; struct rpc_timeout timeparms;
struct nfs_client *clp; struct nfs_client *clp;
...@@ -894,7 +900,6 @@ struct nfs_server *nfs_create_server(const struct nfs_parsed_mount_data *data, ...@@ -894,7 +900,6 @@ struct nfs_server *nfs_create_server(const struct nfs_parsed_mount_data *data,
* Initialise an NFS4 client record * Initialise an NFS4 client record
*/ */
static int nfs4_init_client(struct nfs_client *clp, static int nfs4_init_client(struct nfs_client *clp,
int proto,
const struct rpc_timeout *timeparms, const struct rpc_timeout *timeparms,
const char *ip_addr, const char *ip_addr,
rpc_authflavor_t authflavour) rpc_authflavor_t authflavour)
...@@ -910,7 +915,7 @@ static int nfs4_init_client(struct nfs_client *clp, ...@@ -910,7 +915,7 @@ static int nfs4_init_client(struct nfs_client *clp,
/* Check NFS protocol revision and initialize RPC op vector */ /* Check NFS protocol revision and initialize RPC op vector */
clp->rpc_ops = &nfs_v4_clientops; clp->rpc_ops = &nfs_v4_clientops;
error = nfs_create_rpc_client(clp, proto, timeparms, authflavour, error = nfs_create_rpc_client(clp, timeparms, authflavour,
RPC_CLNT_CREATE_DISCRTRY); RPC_CLNT_CREATE_DISCRTRY);
if (error < 0) if (error < 0)
goto error; goto error;
...@@ -949,6 +954,7 @@ static int nfs4_set_client(struct nfs_server *server, ...@@ -949,6 +954,7 @@ static int nfs4_set_client(struct nfs_server *server,
.addr = addr, .addr = addr,
.addrlen = addrlen, .addrlen = addrlen,
.rpc_ops = &nfs_v4_clientops, .rpc_ops = &nfs_v4_clientops,
.proto = proto,
}; };
struct nfs_client *clp; struct nfs_client *clp;
int error; int error;
...@@ -961,7 +967,7 @@ static int nfs4_set_client(struct nfs_server *server, ...@@ -961,7 +967,7 @@ static int nfs4_set_client(struct nfs_server *server,
error = PTR_ERR(clp); error = PTR_ERR(clp);
goto error; goto error;
} }
error = nfs4_init_client(clp, proto, timeparms, ip_addr, authflavour); error = nfs4_init_client(clp, timeparms, ip_addr, authflavour);
if (error < 0) if (error < 0)
goto error_put; goto error_put;
......
...@@ -29,6 +29,7 @@ struct nfs_client { ...@@ -29,6 +29,7 @@ struct nfs_client {
struct rpc_clnt * cl_rpcclient; struct rpc_clnt * cl_rpcclient;
const struct nfs_rpc_ops *rpc_ops; /* NFS protocol vector */ const struct nfs_rpc_ops *rpc_ops; /* NFS protocol vector */
int cl_proto; /* Network transport protocol */
#ifdef CONFIG_NFS_V4 #ifdef CONFIG_NFS_V4
u64 cl_clientid; /* constant */ u64 cl_clientid; /* constant */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册