提交 292f503c 编写于 作者: T Trond Myklebust

NFSv4: Use the correct net namespace in nfs4_update_server

We need to use the same net namespace that was used to resolve
the hostname and sockaddr arguments.

Fixes: 32e62b7c (NFS: Add nfs4_update_server)
Cc: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: NTrond Myklebust <trond.myklebust@primarydata.com>
上级 e9776d0f
...@@ -176,7 +176,8 @@ extern struct nfs_server *nfs4_create_server( ...@@ -176,7 +176,8 @@ extern struct nfs_server *nfs4_create_server(
extern struct nfs_server *nfs4_create_referral_server(struct nfs_clone_mount *, extern struct nfs_server *nfs4_create_referral_server(struct nfs_clone_mount *,
struct nfs_fh *); struct nfs_fh *);
extern int nfs4_update_server(struct nfs_server *server, const char *hostname, extern int nfs4_update_server(struct nfs_server *server, const char *hostname,
struct sockaddr *sap, size_t salen); struct sockaddr *sap, size_t salen,
struct net *net);
extern void nfs_free_server(struct nfs_server *server); extern void nfs_free_server(struct nfs_server *server);
extern struct nfs_server *nfs_clone_server(struct nfs_server *, extern struct nfs_server *nfs_clone_server(struct nfs_server *,
struct nfs_fh *, struct nfs_fh *,
......
...@@ -1135,6 +1135,7 @@ static int nfs_probe_destination(struct nfs_server *server) ...@@ -1135,6 +1135,7 @@ static int nfs_probe_destination(struct nfs_server *server)
* @hostname: new end-point's hostname * @hostname: new end-point's hostname
* @sap: new end-point's socket address * @sap: new end-point's socket address
* @salen: size of "sap" * @salen: size of "sap"
* @net: net namespace
* *
* The nfs_server must be quiescent before this function is invoked. * The nfs_server must be quiescent before this function is invoked.
* Either its session is drained (NFSv4.1+), or its transport is * Either its session is drained (NFSv4.1+), or its transport is
...@@ -1143,13 +1144,13 @@ static int nfs_probe_destination(struct nfs_server *server) ...@@ -1143,13 +1144,13 @@ static int nfs_probe_destination(struct nfs_server *server)
* Returns zero on success, or a negative errno value. * Returns zero on success, or a negative errno value.
*/ */
int nfs4_update_server(struct nfs_server *server, const char *hostname, int nfs4_update_server(struct nfs_server *server, const char *hostname,
struct sockaddr *sap, size_t salen) struct sockaddr *sap, size_t salen, struct net *net)
{ {
struct nfs_client *clp = server->nfs_client; struct nfs_client *clp = server->nfs_client;
struct rpc_clnt *clnt = server->client; struct rpc_clnt *clnt = server->client;
struct xprt_create xargs = { struct xprt_create xargs = {
.ident = clp->cl_proto, .ident = clp->cl_proto,
.net = &init_net, .net = net,
.dstaddr = sap, .dstaddr = sap,
.addrlen = salen, .addrlen = salen,
.servername = hostname, .servername = hostname,
...@@ -1189,7 +1190,7 @@ int nfs4_update_server(struct nfs_server *server, const char *hostname, ...@@ -1189,7 +1190,7 @@ int nfs4_update_server(struct nfs_server *server, const char *hostname,
error = nfs4_set_client(server, hostname, sap, salen, buf, error = nfs4_set_client(server, hostname, sap, salen, buf,
clp->cl_rpcclient->cl_auth->au_flavor, clp->cl_rpcclient->cl_auth->au_flavor,
clp->cl_proto, clnt->cl_timeout, clp->cl_proto, clnt->cl_timeout,
clp->cl_minorversion, clp->cl_net); clp->cl_minorversion, net);
nfs_put_client(clp); nfs_put_client(clp);
if (error != 0) { if (error != 0) {
nfs_server_insert_lists(server); nfs_server_insert_lists(server);
......
...@@ -121,9 +121,8 @@ static int nfs4_validate_fspath(struct dentry *dentry, ...@@ -121,9 +121,8 @@ static int nfs4_validate_fspath(struct dentry *dentry,
} }
static size_t nfs_parse_server_name(char *string, size_t len, static size_t nfs_parse_server_name(char *string, size_t len,
struct sockaddr *sa, size_t salen, struct nfs_server *server) struct sockaddr *sa, size_t salen, struct net *net)
{ {
struct net *net = rpc_net_ns(server->client);
ssize_t ret; ssize_t ret;
ret = rpc_pton(net, string, len, sa, salen); ret = rpc_pton(net, string, len, sa, salen);
...@@ -223,6 +222,7 @@ static struct vfsmount *try_location(struct nfs_clone_mount *mountdata, ...@@ -223,6 +222,7 @@ static struct vfsmount *try_location(struct nfs_clone_mount *mountdata,
const struct nfs4_fs_location *location) const struct nfs4_fs_location *location)
{ {
const size_t addr_bufsize = sizeof(struct sockaddr_storage); const size_t addr_bufsize = sizeof(struct sockaddr_storage);
struct net *net = rpc_net_ns(NFS_SB(mountdata->sb)->client);
struct vfsmount *mnt = ERR_PTR(-ENOENT); struct vfsmount *mnt = ERR_PTR(-ENOENT);
char *mnt_path; char *mnt_path;
unsigned int maxbuflen; unsigned int maxbuflen;
...@@ -248,8 +248,7 @@ static struct vfsmount *try_location(struct nfs_clone_mount *mountdata, ...@@ -248,8 +248,7 @@ static struct vfsmount *try_location(struct nfs_clone_mount *mountdata,
continue; continue;
mountdata->addrlen = nfs_parse_server_name(buf->data, buf->len, mountdata->addrlen = nfs_parse_server_name(buf->data, buf->len,
mountdata->addr, addr_bufsize, mountdata->addr, addr_bufsize, net);
NFS_SB(mountdata->sb));
if (mountdata->addrlen == 0) if (mountdata->addrlen == 0)
continue; continue;
...@@ -419,6 +418,7 @@ static int nfs4_try_replacing_one_location(struct nfs_server *server, ...@@ -419,6 +418,7 @@ static int nfs4_try_replacing_one_location(struct nfs_server *server,
const struct nfs4_fs_location *location) const struct nfs4_fs_location *location)
{ {
const size_t addr_bufsize = sizeof(struct sockaddr_storage); const size_t addr_bufsize = sizeof(struct sockaddr_storage);
struct net *net = rpc_net_ns(server->client);
struct sockaddr *sap; struct sockaddr *sap;
unsigned int s; unsigned int s;
size_t salen; size_t salen;
...@@ -440,7 +440,7 @@ static int nfs4_try_replacing_one_location(struct nfs_server *server, ...@@ -440,7 +440,7 @@ static int nfs4_try_replacing_one_location(struct nfs_server *server,
continue; continue;
salen = nfs_parse_server_name(buf->data, buf->len, salen = nfs_parse_server_name(buf->data, buf->len,
sap, addr_bufsize, server); sap, addr_bufsize, net);
if (salen == 0) if (salen == 0)
continue; continue;
rpc_set_port(sap, NFS_PORT); rpc_set_port(sap, NFS_PORT);
...@@ -450,7 +450,7 @@ static int nfs4_try_replacing_one_location(struct nfs_server *server, ...@@ -450,7 +450,7 @@ static int nfs4_try_replacing_one_location(struct nfs_server *server,
if (hostname == NULL) if (hostname == NULL)
break; break;
error = nfs4_update_server(server, hostname, sap, salen); error = nfs4_update_server(server, hostname, sap, salen, net);
kfree(hostname); kfree(hostname);
if (error == 0) if (error == 0)
break; break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册