Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 115399
b: refs/heads/master
c: 9a4bd29
h: refs/heads/master
i:
  115397: 45df14a
  115395: eea1f49
  115391: 118979d
v: v3
  • Loading branch information
Trond Myklebust authored and Trond Myklebust committed Oct 7, 2008
1 parent 4697dcc commit 4d58e71
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 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: d1ce02e1689dff9d413138f60a79b4e3affb4708
refs/heads/master: 9a4bd29fe8f6d3f015fe1c8e5450eb62cfebfcc9
36 changes: 29 additions & 7 deletions trunk/net/sunrpc/rpcb_clnt.c
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,28 @@ static struct rpc_task *rpcb_call_async(struct rpc_clnt *rpcb_clnt, struct rpcbi
return rpc_run_task(&task_setup_data);
}

/*
* In the case where rpc clients have been cloned, we want to make
* sure that we use the program number/version etc of the actual
* owner of the xprt. To do so, we walk back up the tree of parents
* to find whoever created the transport and/or whoever has the
* autobind flag set.
*/
static struct rpc_clnt *rpcb_find_transport_owner(struct rpc_clnt *clnt)
{
struct rpc_clnt *parent = clnt->cl_parent;

while (parent != clnt) {
if (parent->cl_xprt != clnt->cl_xprt)
break;
if (clnt->cl_autobind)
break;
clnt = parent;
parent = parent->cl_parent;
}
return clnt;
}

/**
* rpcb_getport_async - obtain the port for a given RPC service on a given host
* @task: task that is waiting for portmapper request
Expand All @@ -478,10 +500,10 @@ static struct rpc_task *rpcb_call_async(struct rpc_clnt *rpcb_clnt, struct rpcbi
*/
void rpcb_getport_async(struct rpc_task *task)
{
struct rpc_clnt *clnt = task->tk_client;
struct rpc_clnt *clnt;
struct rpc_procinfo *proc;
u32 bind_version;
struct rpc_xprt *xprt = task->tk_xprt;
struct rpc_xprt *xprt;
struct rpc_clnt *rpcb_clnt;
static struct rpcbind_args *map;
struct rpc_task *child;
Expand All @@ -490,13 +512,13 @@ void rpcb_getport_async(struct rpc_task *task)
size_t salen;
int status;

clnt = rpcb_find_transport_owner(task->tk_client);
xprt = clnt->cl_xprt;

dprintk("RPC: %5u %s(%s, %u, %u, %d)\n",
task->tk_pid, __func__,
clnt->cl_server, clnt->cl_prog, clnt->cl_vers, xprt->prot);

/* Autobind on cloned rpc clients is discouraged */
BUG_ON(clnt->cl_parent != clnt);

/* Put self on the wait queue to ensure we get notified if
* some other task is already attempting to bind the port */
rpc_sleep_on(&xprt->binding, task, NULL);
Expand Down Expand Up @@ -578,9 +600,9 @@ void rpcb_getport_async(struct rpc_task *task)
task->tk_pid, __func__);
return;
}
rpc_put_task(child);

task->tk_xprt->stat.bind_count++;
xprt->stat.bind_count++;
rpc_put_task(child);
return;

bailout_nofree:
Expand Down

0 comments on commit 4d58e71

Please sign in to comment.