aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2012-01-20 13:53:37 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2012-01-31 19:28:19 -0500
commit6eac7d3f45a2519283d38bf670cb6968230124f8 (patch)
treeaf5542a51d63d971d2fe1af95e27617dc4947104 /net/sunrpc
parent4cb54ca2069903121e4c03ec427147c47bed5755 (diff)
SUNRPC: constify rpc_clnt fields cl_server and cl_protname
...and get rid of the superfluous cl_inline_name. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'net/sunrpc')
-rw-r--r--net/sunrpc/clnt.c29
-rw-r--r--net/sunrpc/rpcb_clnt.c2
2 files changed, 13 insertions, 18 deletions
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index 4c6848017168..e9b22e8e16c7 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -273,15 +273,9 @@ static struct rpc_clnt * rpc_new_client(const struct rpc_create_args *args, stru
273 goto out_err; 273 goto out_err;
274 clnt->cl_parent = clnt; 274 clnt->cl_parent = clnt;
275 275
276 clnt->cl_server = clnt->cl_inline_name; 276 clnt->cl_server = kstrdup(args->servername, GFP_KERNEL);
277 if (len > sizeof(clnt->cl_inline_name)) { 277 if (clnt->cl_server == NULL)
278 char *buf = kmalloc(len, GFP_KERNEL); 278 goto out_no_server;
279 if (buf != NULL)
280 clnt->cl_server = buf;
281 else
282 len = sizeof(clnt->cl_inline_name);
283 }
284 strlcpy(clnt->cl_server, args->servername, len);
285 279
286 clnt->cl_xprt = xprt; 280 clnt->cl_xprt = xprt;
287 clnt->cl_procinfo = version->procs; 281 clnt->cl_procinfo = version->procs;
@@ -346,8 +340,8 @@ out_no_path:
346out_no_principal: 340out_no_principal:
347 rpc_free_iostats(clnt->cl_metrics); 341 rpc_free_iostats(clnt->cl_metrics);
348out_no_stats: 342out_no_stats:
349 if (clnt->cl_server != clnt->cl_inline_name) 343 kfree(clnt->cl_server);
350 kfree(clnt->cl_server); 344out_no_server:
351 kfree(clnt); 345 kfree(clnt);
352out_err: 346out_err:
353 xprt_put(xprt); 347 xprt_put(xprt);
@@ -470,6 +464,9 @@ rpc_clone_client(struct rpc_clnt *clnt)
470 new = kmemdup(clnt, sizeof(*new), GFP_KERNEL); 464 new = kmemdup(clnt, sizeof(*new), GFP_KERNEL);
471 if (!new) 465 if (!new)
472 goto out_no_clnt; 466 goto out_no_clnt;
467 new->cl_server = kstrdup(clnt->cl_server, GFP_KERNEL);
468 if (new->cl_server == NULL)
469 goto out_no_server;
473 new->cl_parent = clnt; 470 new->cl_parent = clnt;
474 /* Turn off autobind on clones */ 471 /* Turn off autobind on clones */
475 new->cl_autobind = 0; 472 new->cl_autobind = 0;
@@ -500,6 +497,8 @@ out_no_path:
500out_no_principal: 497out_no_principal:
501 rpc_free_iostats(new->cl_metrics); 498 rpc_free_iostats(new->cl_metrics);
502out_no_stats: 499out_no_stats:
500 kfree(new->cl_server);
501out_no_server:
503 kfree(new); 502 kfree(new);
504out_no_clnt: 503out_no_clnt:
505 dprintk("RPC: %s: returned error %d\n", __func__, err); 504 dprintk("RPC: %s: returned error %d\n", __func__, err);
@@ -565,13 +564,9 @@ rpc_free_client(struct rpc_clnt *clnt)
565{ 564{
566 dprintk("RPC: destroying %s client for %s\n", 565 dprintk("RPC: destroying %s client for %s\n",
567 clnt->cl_protname, clnt->cl_server); 566 clnt->cl_protname, clnt->cl_server);
568 if (clnt->cl_parent != clnt) { 567 if (clnt->cl_parent != clnt)
569 rpc_release_client(clnt->cl_parent); 568 rpc_release_client(clnt->cl_parent);
570 goto out_free; 569 kfree(clnt->cl_server);
571 }
572 if (clnt->cl_server != clnt->cl_inline_name)
573 kfree(clnt->cl_server);
574out_free:
575 rpc_unregister_client(clnt); 570 rpc_unregister_client(clnt);
576 rpc_clnt_remove_pipedir(clnt); 571 rpc_clnt_remove_pipedir(clnt);
577 rpc_free_iostats(clnt->cl_metrics); 572 rpc_free_iostats(clnt->cl_metrics);
diff --git a/net/sunrpc/rpcb_clnt.c b/net/sunrpc/rpcb_clnt.c
index 4ce3a8e02953..d3978017b25d 100644
--- a/net/sunrpc/rpcb_clnt.c
+++ b/net/sunrpc/rpcb_clnt.c
@@ -343,7 +343,7 @@ out:
343 return result; 343 return result;
344} 344}
345 345
346static struct rpc_clnt *rpcb_create(struct net *net, char *hostname, 346static struct rpc_clnt *rpcb_create(struct net *net, const char *hostname,
347 struct sockaddr *srvaddr, size_t salen, 347 struct sockaddr *srvaddr, size_t salen,
348 int proto, u32 version) 348 int proto, u32 version)
349{ 349{