aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc
diff options
context:
space:
mode:
authorStanislav Kinsbursky <skinsbursky@parallels.com>2013-06-24 03:52:52 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2013-06-28 15:42:16 -0400
commite73f4cc051199799aee4320f300f28ffb82f3eb1 (patch)
treefebba6f33716b75986666e2efc7a47b42882b16a /net/sunrpc
parentadb6fa7ffe9031857ec14b8aab75c9ab65556cbc (diff)
SUNRPC: split client creation routine into setup and registration
This helper moves all "registration" code to the new rpc_client_register() helper. This helper will be used later in the series to synchronize against PipeFS MOUNT/UMOUNT events. Signed-off-by: Stanislav Kinsbursky <skinsbursky@parallels.com> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'net/sunrpc')
-rw-r--r--net/sunrpc/clnt.c64
1 files changed, 39 insertions, 25 deletions
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index 41f180c5a498..b4f17117b779 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -281,14 +281,47 @@ static void rpc_clnt_set_nodename(struct rpc_clnt *clnt, const char *nodename)
281 memcpy(clnt->cl_nodename, nodename, clnt->cl_nodelen); 281 memcpy(clnt->cl_nodename, nodename, clnt->cl_nodelen);
282} 282}
283 283
284static int rpc_client_register(const struct rpc_create_args *args,
285 struct rpc_clnt *clnt)
286{
287 const struct rpc_program *program = args->program;
288 struct rpc_auth *auth;
289 struct net *net = rpc_net_ns(clnt);
290 struct super_block *pipefs_sb;
291 int err = 0;
292
293 pipefs_sb = rpc_get_sb_net(net);
294 if (pipefs_sb) {
295 err = rpc_setup_pipedir(clnt, program->pipe_dir_name, pipefs_sb);
296 if (err)
297 goto out;
298 }
299
300 auth = rpcauth_create(args->authflavor, clnt);
301 if (IS_ERR(auth)) {
302 dprintk("RPC: Couldn't create auth handle (flavor %u)\n",
303 args->authflavor);
304 err = PTR_ERR(auth);
305 goto err_auth;
306 }
307
308 rpc_register_client(clnt);
309out:
310 if (pipefs_sb)
311 rpc_put_sb_net(net);
312 return err;
313
314err_auth:
315 __rpc_clnt_remove_pipedir(clnt);
316 goto out;
317}
318
284static struct rpc_clnt * rpc_new_client(const struct rpc_create_args *args, struct rpc_xprt *xprt) 319static struct rpc_clnt * rpc_new_client(const struct rpc_create_args *args, struct rpc_xprt *xprt)
285{ 320{
286 const struct rpc_program *program = args->program; 321 const struct rpc_program *program = args->program;
287 const struct rpc_version *version; 322 const struct rpc_version *version;
288 struct rpc_clnt *clnt = NULL; 323 struct rpc_clnt *clnt = NULL;
289 struct rpc_auth *auth;
290 int err; 324 int err;
291 struct super_block *pipefs_sb;
292 325
293 /* sanity check the name before trying to print it */ 326 /* sanity check the name before trying to print it */
294 dprintk("RPC: creating %s client for %s (xprt %p)\n", 327 dprintk("RPC: creating %s client for %s (xprt %p)\n",
@@ -347,34 +380,15 @@ static struct rpc_clnt * rpc_new_client(const struct rpc_create_args *args, stru
347 380
348 atomic_set(&clnt->cl_count, 1); 381 atomic_set(&clnt->cl_count, 1);
349 382
350 pipefs_sb = rpc_get_sb_net(rpc_net_ns(clnt));
351 if (pipefs_sb) {
352 err = rpc_setup_pipedir(clnt, program->pipe_dir_name, pipefs_sb);
353 if (err)
354 goto out_no_path;
355 }
356
357 auth = rpcauth_create(args->authflavor, clnt);
358 if (IS_ERR(auth)) {
359 dprintk("RPC: Couldn't create auth handle (flavor %u)\n",
360 args->authflavor);
361 err = PTR_ERR(auth);
362 goto out_no_auth;
363 }
364
365 /* save the nodename */ 383 /* save the nodename */
366 rpc_clnt_set_nodename(clnt, utsname()->nodename); 384 rpc_clnt_set_nodename(clnt, utsname()->nodename);
367 rpc_register_client(clnt); 385
368 if (pipefs_sb) 386 err = rpc_client_register(args, clnt);
369 rpc_put_sb_net(rpc_net_ns(clnt)); 387 if (err)
388 goto out_no_path;
370 return clnt; 389 return clnt;
371 390
372out_no_auth:
373 if (pipefs_sb)
374 __rpc_clnt_remove_pipedir(clnt);
375out_no_path: 391out_no_path:
376 if (pipefs_sb)
377 rpc_put_sb_net(rpc_net_ns(clnt));
378 kfree(clnt->cl_principal); 392 kfree(clnt->cl_principal);
379out_no_principal: 393out_no_principal:
380 rpc_free_iostats(clnt->cl_metrics); 394 rpc_free_iostats(clnt->cl_metrics);