diff options
| author | Kinglong Mee <kinglongmee@gmail.com> | 2014-03-23 23:58:59 -0400 |
|---|---|---|
| committer | J. Bruce Fields <bfields@redhat.com> | 2014-03-30 10:47:36 -0400 |
| commit | 83ddfebdd21da669918d7f9854fd592858625f4b (patch) | |
| tree | 12af99c421f207cfa20f443ade38c1fd1a62f7b5 | |
| parent | 47f72efa8f32e8182cd4a70d5a9a6d07651093fc (diff) | |
SUNRPC: New helper for creating client with rpc_xprt
Signed-off-by: Kinglong Mee <kinglongmee@gmail.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
| -rw-r--r-- | include/linux/sunrpc/clnt.h | 2 | ||||
| -rw-r--r-- | net/sunrpc/clnt.c | 58 |
2 files changed, 35 insertions, 25 deletions
diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h index 8af2804bab16..70736b98c721 100644 --- a/include/linux/sunrpc/clnt.h +++ b/include/linux/sunrpc/clnt.h | |||
| @@ -130,6 +130,8 @@ struct rpc_create_args { | |||
| 130 | #define RPC_CLNT_CREATE_NO_RETRANS_TIMEOUT (1UL << 9) | 130 | #define RPC_CLNT_CREATE_NO_RETRANS_TIMEOUT (1UL << 9) |
| 131 | 131 | ||
| 132 | struct rpc_clnt *rpc_create(struct rpc_create_args *args); | 132 | struct rpc_clnt *rpc_create(struct rpc_create_args *args); |
| 133 | struct rpc_clnt *rpc_create_xprt(struct rpc_create_args *args, | ||
| 134 | struct rpc_xprt *xprt); | ||
| 133 | struct rpc_clnt *rpc_bind_new_program(struct rpc_clnt *, | 135 | struct rpc_clnt *rpc_bind_new_program(struct rpc_clnt *, |
| 134 | const struct rpc_program *, u32); | 136 | const struct rpc_program *, u32); |
| 135 | void rpc_task_reset_client(struct rpc_task *task, struct rpc_clnt *clnt); | 137 | void rpc_task_reset_client(struct rpc_task *task, struct rpc_clnt *clnt); |
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index 0edada973434..3c9a0f02374d 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c | |||
| @@ -438,6 +438,38 @@ out_no_rpciod: | |||
| 438 | return ERR_PTR(err); | 438 | return ERR_PTR(err); |
| 439 | } | 439 | } |
| 440 | 440 | ||
| 441 | struct rpc_clnt *rpc_create_xprt(struct rpc_create_args *args, | ||
| 442 | struct rpc_xprt *xprt) | ||
| 443 | { | ||
| 444 | struct rpc_clnt *clnt = NULL; | ||
| 445 | |||
| 446 | clnt = rpc_new_client(args, xprt, NULL); | ||
| 447 | if (IS_ERR(clnt)) | ||
| 448 | return clnt; | ||
| 449 | |||
| 450 | if (!(args->flags & RPC_CLNT_CREATE_NOPING)) { | ||
| 451 | int err = rpc_ping(clnt); | ||
| 452 | if (err != 0) { | ||
| 453 | rpc_shutdown_client(clnt); | ||
| 454 | return ERR_PTR(err); | ||
| 455 | } | ||
| 456 | } | ||
| 457 | |||
| 458 | clnt->cl_softrtry = 1; | ||
| 459 | if (args->flags & RPC_CLNT_CREATE_HARDRTRY) | ||
| 460 | clnt->cl_softrtry = 0; | ||
| 461 | |||
| 462 | if (args->flags & RPC_CLNT_CREATE_AUTOBIND) | ||
| 463 | clnt->cl_autobind = 1; | ||
| 464 | if (args->flags & RPC_CLNT_CREATE_DISCRTRY) | ||
| 465 | clnt->cl_discrtry = 1; | ||
| 466 | if (!(args->flags & RPC_CLNT_CREATE_QUIET)) | ||
| 467 | clnt->cl_chatty = 1; | ||
| 468 | |||
| 469 | return clnt; | ||
| 470 | } | ||
| 471 | EXPORT_SYMBOL_GPL(rpc_create_xprt); | ||
| 472 | |||
| 441 | /** | 473 | /** |
| 442 | * rpc_create - create an RPC client and transport with one call | 474 | * rpc_create - create an RPC client and transport with one call |
| 443 | * @args: rpc_clnt create argument structure | 475 | * @args: rpc_clnt create argument structure |
| @@ -451,7 +483,6 @@ out_no_rpciod: | |||
| 451 | struct rpc_clnt *rpc_create(struct rpc_create_args *args) | 483 | struct rpc_clnt *rpc_create(struct rpc_create_args *args) |
| 452 | { | 484 | { |
| 453 | struct rpc_xprt *xprt; | 485 | struct rpc_xprt *xprt; |
| 454 | struct rpc_clnt *clnt; | ||
| 455 | struct xprt_create xprtargs = { | 486 | struct xprt_create xprtargs = { |
| 456 | .net = args->net, | 487 | .net = args->net, |
| 457 | .ident = args->protocol, | 488 | .ident = args->protocol, |
| @@ -515,30 +546,7 @@ struct rpc_clnt *rpc_create(struct rpc_create_args *args) | |||
| 515 | if (args->flags & RPC_CLNT_CREATE_NONPRIVPORT) | 546 | if (args->flags & RPC_CLNT_CREATE_NONPRIVPORT) |
| 516 | xprt->resvport = 0; | 547 | xprt->resvport = 0; |
| 517 | 548 | ||
| 518 | clnt = rpc_new_client(args, xprt, NULL); | 549 | return rpc_create_xprt(args, xprt); |
| 519 | if (IS_ERR(clnt)) | ||
| 520 | return clnt; | ||
| 521 | |||
| 522 | if (!(args->flags & RPC_CLNT_CREATE_NOPING)) { | ||
| 523 | int err = rpc_ping(clnt); | ||
| 524 | if (err != 0) { | ||
| 525 | rpc_shutdown_client(clnt); | ||
| 526 | return ERR_PTR(err); | ||
| 527 | } | ||
| 528 | } | ||
| 529 | |||
| 530 | clnt->cl_softrtry = 1; | ||
| 531 | if (args->flags & RPC_CLNT_CREATE_HARDRTRY) | ||
| 532 | clnt->cl_softrtry = 0; | ||
| 533 | |||
| 534 | if (args->flags & RPC_CLNT_CREATE_AUTOBIND) | ||
| 535 | clnt->cl_autobind = 1; | ||
| 536 | if (args->flags & RPC_CLNT_CREATE_DISCRTRY) | ||
| 537 | clnt->cl_discrtry = 1; | ||
| 538 | if (!(args->flags & RPC_CLNT_CREATE_QUIET)) | ||
| 539 | clnt->cl_chatty = 1; | ||
| 540 | |||
| 541 | return clnt; | ||
| 542 | } | 550 | } |
| 543 | EXPORT_SYMBOL_GPL(rpc_create); | 551 | EXPORT_SYMBOL_GPL(rpc_create); |
| 544 | 552 | ||
