aboutsummaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--include/linux/sunrpc/clnt.h9
-rw-r--r--net/sunrpc/clnt.c29
-rw-r--r--net/sunrpc/rpcb_clnt.c2
3 files changed, 17 insertions, 23 deletions
diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
index 9e754e3458fc..db6970ced9bc 100644
--- a/include/linux/sunrpc/clnt.h
+++ b/include/linux/sunrpc/clnt.h
@@ -41,8 +41,8 @@ struct rpc_clnt {
41 cl_vers, /* RPC version number */ 41 cl_vers, /* RPC version number */
42 cl_maxproc; /* max procedure number */ 42 cl_maxproc; /* max procedure number */
43 43
44 char * cl_server; /* server machine name */ 44 const char * cl_server; /* server machine name */
45 char * cl_protname; /* protocol name */ 45 const char * cl_protname; /* protocol name */
46 struct rpc_auth * cl_auth; /* authenticator */ 46 struct rpc_auth * cl_auth; /* authenticator */
47 struct rpc_stat * cl_stats; /* per-program statistics */ 47 struct rpc_stat * cl_stats; /* per-program statistics */
48 struct rpc_iostats * cl_metrics; /* per-client statistics */ 48 struct rpc_iostats * cl_metrics; /* per-client statistics */
@@ -62,7 +62,6 @@ struct rpc_clnt {
62 struct rpc_rtt cl_rtt_default; 62 struct rpc_rtt cl_rtt_default;
63 struct rpc_timeout cl_timeout_default; 63 struct rpc_timeout cl_timeout_default;
64 struct rpc_program * cl_program; 64 struct rpc_program * cl_program;
65 char cl_inline_name[32];
66 char *cl_principal; /* target to authenticate to */ 65 char *cl_principal; /* target to authenticate to */
67}; 66};
68 67
@@ -97,7 +96,7 @@ struct rpc_procinfo {
97 unsigned int p_count; /* call count */ 96 unsigned int p_count; /* call count */
98 unsigned int p_timer; /* Which RTT timer to use */ 97 unsigned int p_timer; /* Which RTT timer to use */
99 u32 p_statidx; /* Which procedure to account */ 98 u32 p_statidx; /* Which procedure to account */
100 char * p_name; /* name of procedure */ 99 const char * p_name; /* name of procedure */
101}; 100};
102 101
103#ifdef __KERNEL__ 102#ifdef __KERNEL__
@@ -109,7 +108,7 @@ struct rpc_create_args {
109 size_t addrsize; 108 size_t addrsize;
110 struct sockaddr *saddress; 109 struct sockaddr *saddress;
111 const struct rpc_timeout *timeout; 110 const struct rpc_timeout *timeout;
112 char *servername; 111 const char *servername;
113 struct rpc_program *program; 112 struct rpc_program *program;
114 u32 prognumber; /* overrides program->number */ 113 u32 prognumber; /* overrides program->number */
115 u32 version; 114 u32 version;
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{