Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 294406
b: refs/heads/master
c: 2ea75a1
h: refs/heads/master
v: v3
  • Loading branch information
Stanislav Kinsbursky authored and Trond Myklebust committed Feb 1, 2012
1 parent 0f7838a commit 5a3c52b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: dff02d499c067bdde589b764321b35fe763569f6
refs/heads/master: 2ea75a10add779b722650aa10836247e7d609fd7
35 changes: 19 additions & 16 deletions trunk/net/sunrpc/rpcb_clnt.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,10 @@ static void rpcb_map_release(void *data)
kfree(map);
}

static int rpcb_get_local(void)
static int rpcb_get_local(struct net *net)
{
int cnt;
struct sunrpc_net *sn = net_generic(&init_net, sunrpc_net_id);
struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);

spin_lock(&sn->rpcb_clnt_lock);
if (sn->rpcb_users)
Expand Down Expand Up @@ -201,32 +201,34 @@ void rpcb_put_local(void)
}
}

static void rpcb_set_local(struct rpc_clnt *clnt, struct rpc_clnt *clnt4)
static void rpcb_set_local(struct net *net, struct rpc_clnt *clnt,
struct rpc_clnt *clnt4)
{
struct sunrpc_net *sn = net_generic(&init_net, sunrpc_net_id);
struct sunrpc_net *sn = net_generic(net, sunrpc_net_id);

/* Protected by rpcb_create_local_mutex */
sn->rpcb_local_clnt = clnt;
sn->rpcb_local_clnt4 = clnt4;
smp_wmb();
sn->rpcb_users = 1;
dprintk("RPC: created new rpcb local clients (rpcb_local_clnt: "
"%p, rpcb_local_clnt4: %p)\n", sn->rpcb_local_clnt,
sn->rpcb_local_clnt4);
"%p, rpcb_local_clnt4: %p) for net %p%s\n",
sn->rpcb_local_clnt, sn->rpcb_local_clnt4,
net, (net == &init_net) ? " (init_net)" : "");
}

/*
* Returns zero on success, otherwise a negative errno value
* is returned.
*/
static int rpcb_create_local_unix(void)
static int rpcb_create_local_unix(struct net *net)
{
static const struct sockaddr_un rpcb_localaddr_rpcbind = {
.sun_family = AF_LOCAL,
.sun_path = RPCBIND_SOCK_PATHNAME,
};
struct rpc_create_args args = {
.net = &init_net,
.net = net,
.protocol = XPRT_TRANSPORT_LOCAL,
.address = (struct sockaddr *)&rpcb_localaddr_rpcbind,
.addrsize = sizeof(rpcb_localaddr_rpcbind),
Expand Down Expand Up @@ -259,7 +261,7 @@ static int rpcb_create_local_unix(void)
clnt4 = NULL;
}

rpcb_set_local(clnt, clnt4);
rpcb_set_local(net, clnt, clnt4);

out:
return result;
Expand All @@ -269,15 +271,15 @@ static int rpcb_create_local_unix(void)
* Returns zero on success, otherwise a negative errno value
* is returned.
*/
static int rpcb_create_local_net(void)
static int rpcb_create_local_net(struct net *net)
{
static const struct sockaddr_in rpcb_inaddr_loopback = {
.sin_family = AF_INET,
.sin_addr.s_addr = htonl(INADDR_LOOPBACK),
.sin_port = htons(RPCBIND_PORT),
};
struct rpc_create_args args = {
.net = &init_net,
.net = net,
.protocol = XPRT_TRANSPORT_TCP,
.address = (struct sockaddr *)&rpcb_inaddr_loopback,
.addrsize = sizeof(rpcb_inaddr_loopback),
Expand Down Expand Up @@ -311,7 +313,7 @@ static int rpcb_create_local_net(void)
clnt4 = NULL;
}

rpcb_set_local(clnt, clnt4);
rpcb_set_local(net, clnt, clnt4);

out:
return result;
Expand All @@ -325,16 +327,17 @@ int rpcb_create_local(void)
{
static DEFINE_MUTEX(rpcb_create_local_mutex);
int result = 0;
struct net *net = &init_net;

if (rpcb_get_local())
if (rpcb_get_local(net))
return result;

mutex_lock(&rpcb_create_local_mutex);
if (rpcb_get_local())
if (rpcb_get_local(net))
goto out;

if (rpcb_create_local_unix() != 0)
result = rpcb_create_local_net();
if (rpcb_create_local_unix(net) != 0)
result = rpcb_create_local_net(net);

out:
mutex_unlock(&rpcb_create_local_mutex);
Expand Down

0 comments on commit 5a3c52b

Please sign in to comment.