aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc/clnt.c
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2007-07-14 15:39:59 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2008-01-30 02:05:30 -0500
commit84115e1cd4a3614c4e566d4cce31381dce3dbef9 (patch)
tree01b2de7163deb6b3a789811183d8b8c1329b900c /net/sunrpc/clnt.c
parente8914c65f7f8d4e8701b8e78a12b714872ea0402 (diff)
SUNRPC: Cleanup of rpc_task initialisation
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'net/sunrpc/clnt.c')
-rw-r--r--net/sunrpc/clnt.c51
1 files changed, 37 insertions, 14 deletions
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index 22092b91dd85..7c80abd9263f 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -524,25 +524,22 @@ void rpc_clnt_sigunmask(struct rpc_clnt *clnt, sigset_t *oldset)
524EXPORT_SYMBOL_GPL(rpc_clnt_sigunmask); 524EXPORT_SYMBOL_GPL(rpc_clnt_sigunmask);
525 525
526static 526static
527struct rpc_task *rpc_do_run_task(struct rpc_clnt *clnt, 527struct rpc_task *rpc_do_run_task(const struct rpc_task_setup *task_setup_data)
528 struct rpc_message *msg,
529 int flags,
530 const struct rpc_call_ops *ops,
531 void *data)
532{ 528{
533 struct rpc_task *task, *ret; 529 struct rpc_task *task, *ret;
534 sigset_t oldset; 530 sigset_t oldset;
535 531
536 task = rpc_new_task(clnt, flags, ops, data); 532 task = rpc_new_task(task_setup_data);
537 if (task == NULL) { 533 if (task == NULL) {
538 rpc_release_calldata(ops, data); 534 rpc_release_calldata(task_setup_data->callback_ops,
535 task_setup_data->callback_data);
539 return ERR_PTR(-ENOMEM); 536 return ERR_PTR(-ENOMEM);
540 } 537 }
541 538
542 /* Mask signals on synchronous RPC calls and RPCSEC_GSS upcalls */ 539 /* Mask signals on synchronous RPC calls and RPCSEC_GSS upcalls */
543 rpc_task_sigmask(task, &oldset); 540 rpc_task_sigmask(task, &oldset);
544 if (msg != NULL) { 541 if (task_setup_data->rpc_message != NULL) {
545 rpc_call_setup(task, msg, 0); 542 rpc_call_setup(task, task_setup_data->rpc_message, 0);
546 if (task->tk_status != 0) { 543 if (task->tk_status != 0) {
547 ret = ERR_PTR(task->tk_status); 544 ret = ERR_PTR(task->tk_status);
548 rpc_put_task(task); 545 rpc_put_task(task);
@@ -566,11 +563,17 @@ out:
566int rpc_call_sync(struct rpc_clnt *clnt, struct rpc_message *msg, int flags) 563int rpc_call_sync(struct rpc_clnt *clnt, struct rpc_message *msg, int flags)
567{ 564{
568 struct rpc_task *task; 565 struct rpc_task *task;
566 struct rpc_task_setup task_setup_data = {
567 .rpc_client = clnt,
568 .rpc_message = msg,
569 .callback_ops = &rpc_default_ops,
570 .flags = flags,
571 };
569 int status; 572 int status;
570 573
571 BUG_ON(flags & RPC_TASK_ASYNC); 574 BUG_ON(flags & RPC_TASK_ASYNC);
572 575
573 task = rpc_do_run_task(clnt, msg, flags, &rpc_default_ops, NULL); 576 task = rpc_do_run_task(&task_setup_data);
574 if (IS_ERR(task)) 577 if (IS_ERR(task))
575 return PTR_ERR(task); 578 return PTR_ERR(task);
576 status = task->tk_status; 579 status = task->tk_status;
@@ -592,8 +595,15 @@ rpc_call_async(struct rpc_clnt *clnt, struct rpc_message *msg, int flags,
592 const struct rpc_call_ops *tk_ops, void *data) 595 const struct rpc_call_ops *tk_ops, void *data)
593{ 596{
594 struct rpc_task *task; 597 struct rpc_task *task;
598 struct rpc_task_setup task_setup_data = {
599 .rpc_client = clnt,
600 .rpc_message = msg,
601 .callback_ops = tk_ops,
602 .callback_data = data,
603 .flags = flags|RPC_TASK_ASYNC,
604 };
595 605
596 task = rpc_do_run_task(clnt, msg, flags|RPC_TASK_ASYNC, tk_ops, data); 606 task = rpc_do_run_task(&task_setup_data);
597 if (IS_ERR(task)) 607 if (IS_ERR(task))
598 return PTR_ERR(task); 608 return PTR_ERR(task);
599 rpc_put_task(task); 609 rpc_put_task(task);
@@ -612,12 +622,19 @@ struct rpc_task *rpc_run_task(struct rpc_clnt *clnt, int flags,
612 const struct rpc_call_ops *tk_ops, 622 const struct rpc_call_ops *tk_ops,
613 void *data) 623 void *data)
614{ 624{
615 return rpc_do_run_task(clnt, NULL, flags, tk_ops, data); 625 struct rpc_task_setup task_setup_data = {
626 .rpc_client = clnt,
627 .callback_ops = tk_ops,
628 .callback_data = data,
629 .flags = flags,
630 };
631
632 return rpc_do_run_task(&task_setup_data);
616} 633}
617EXPORT_SYMBOL_GPL(rpc_run_task); 634EXPORT_SYMBOL_GPL(rpc_run_task);
618 635
619void 636void
620rpc_call_setup(struct rpc_task *task, struct rpc_message *msg, int flags) 637rpc_call_setup(struct rpc_task *task, const struct rpc_message *msg, int flags)
621{ 638{
622 task->tk_msg = *msg; 639 task->tk_msg = *msg;
623 task->tk_flags |= flags; 640 task->tk_flags |= flags;
@@ -1527,7 +1544,13 @@ struct rpc_task *rpc_call_null(struct rpc_clnt *clnt, struct rpc_cred *cred, int
1527 .rpc_proc = &rpcproc_null, 1544 .rpc_proc = &rpcproc_null,
1528 .rpc_cred = cred, 1545 .rpc_cred = cred,
1529 }; 1546 };
1530 return rpc_do_run_task(clnt, &msg, flags, &rpc_default_ops, NULL); 1547 struct rpc_task_setup task_setup_data = {
1548 .rpc_client = clnt,
1549 .rpc_message = &msg,
1550 .callback_ops = &rpc_default_ops,
1551 .flags = flags,
1552 };
1553 return rpc_do_run_task(&task_setup_data);
1531} 1554}
1532EXPORT_SYMBOL_GPL(rpc_call_null); 1555EXPORT_SYMBOL_GPL(rpc_call_null);
1533 1556