diff options
Diffstat (limited to 'net')
-rw-r--r-- | net/sunrpc/clnt.c | 51 | ||||
-rw-r--r-- | net/sunrpc/sched.c | 27 |
2 files changed, 50 insertions, 28 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) | |||
524 | EXPORT_SYMBOL_GPL(rpc_clnt_sigunmask); | 524 | EXPORT_SYMBOL_GPL(rpc_clnt_sigunmask); |
525 | 525 | ||
526 | static | 526 | static |
527 | struct rpc_task *rpc_do_run_task(struct rpc_clnt *clnt, | 527 | struct 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: | |||
566 | int rpc_call_sync(struct rpc_clnt *clnt, struct rpc_message *msg, int flags) | 563 | int 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 | } |
617 | EXPORT_SYMBOL_GPL(rpc_run_task); | 634 | EXPORT_SYMBOL_GPL(rpc_run_task); |
618 | 635 | ||
619 | void | 636 | void |
620 | rpc_call_setup(struct rpc_task *task, struct rpc_message *msg, int flags) | 637 | rpc_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 | } |
1532 | EXPORT_SYMBOL_GPL(rpc_call_null); | 1555 | EXPORT_SYMBOL_GPL(rpc_call_null); |
1533 | 1556 | ||
diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c index d0b4c7e11e06..10216989309c 100644 --- a/net/sunrpc/sched.c +++ b/net/sunrpc/sched.c | |||
@@ -815,18 +815,15 @@ EXPORT_SYMBOL_GPL(rpc_free); | |||
815 | /* | 815 | /* |
816 | * Creation and deletion of RPC task structures | 816 | * Creation and deletion of RPC task structures |
817 | */ | 817 | */ |
818 | void rpc_init_task(struct rpc_task *task, struct rpc_clnt *clnt, int flags, const struct rpc_call_ops *tk_ops, void *calldata) | 818 | void rpc_init_task(struct rpc_task *task, const struct rpc_task_setup *task_setup_data) |
819 | { | 819 | { |
820 | memset(task, 0, sizeof(*task)); | 820 | memset(task, 0, sizeof(*task)); |
821 | setup_timer(&task->tk_timer, (void (*)(unsigned long))rpc_run_timer, | 821 | setup_timer(&task->tk_timer, (void (*)(unsigned long))rpc_run_timer, |
822 | (unsigned long)task); | 822 | (unsigned long)task); |
823 | atomic_set(&task->tk_count, 1); | 823 | atomic_set(&task->tk_count, 1); |
824 | task->tk_client = clnt; | 824 | task->tk_flags = task_setup_data->flags; |
825 | task->tk_flags = flags; | 825 | task->tk_ops = task_setup_data->callback_ops; |
826 | task->tk_ops = tk_ops; | 826 | task->tk_calldata = task_setup_data->callback_data; |
827 | if (tk_ops->rpc_call_prepare != NULL) | ||
828 | task->tk_action = rpc_prepare_task; | ||
829 | task->tk_calldata = calldata; | ||
830 | INIT_LIST_HEAD(&task->tk_task); | 827 | INIT_LIST_HEAD(&task->tk_task); |
831 | 828 | ||
832 | /* Initialize retry counters */ | 829 | /* Initialize retry counters */ |
@@ -839,15 +836,17 @@ void rpc_init_task(struct rpc_task *task, struct rpc_clnt *clnt, int flags, cons | |||
839 | /* Initialize workqueue for async tasks */ | 836 | /* Initialize workqueue for async tasks */ |
840 | task->tk_workqueue = rpciod_workqueue; | 837 | task->tk_workqueue = rpciod_workqueue; |
841 | 838 | ||
842 | if (clnt) { | 839 | task->tk_client = task_setup_data->rpc_client; |
843 | kref_get(&clnt->cl_kref); | 840 | if (task->tk_client != NULL) { |
844 | if (clnt->cl_softrtry) | 841 | kref_get(&task->tk_client->cl_kref); |
842 | if (task->tk_client->cl_softrtry) | ||
845 | task->tk_flags |= RPC_TASK_SOFT; | 843 | task->tk_flags |= RPC_TASK_SOFT; |
846 | if (!clnt->cl_intr) | 844 | if (!task->tk_client->cl_intr) |
847 | task->tk_flags |= RPC_TASK_NOINTR; | 845 | task->tk_flags |= RPC_TASK_NOINTR; |
848 | } | 846 | } |
849 | 847 | ||
850 | BUG_ON(task->tk_ops == NULL); | 848 | if (task->tk_ops->rpc_call_prepare != NULL) |
849 | task->tk_action = rpc_prepare_task; | ||
851 | 850 | ||
852 | /* starting timestamp */ | 851 | /* starting timestamp */ |
853 | task->tk_start = jiffies; | 852 | task->tk_start = jiffies; |
@@ -873,7 +872,7 @@ static void rpc_free_task(struct rcu_head *rcu) | |||
873 | /* | 872 | /* |
874 | * Create a new task for the specified client. | 873 | * Create a new task for the specified client. |
875 | */ | 874 | */ |
876 | struct rpc_task *rpc_new_task(struct rpc_clnt *clnt, int flags, const struct rpc_call_ops *tk_ops, void *calldata) | 875 | struct rpc_task *rpc_new_task(const struct rpc_task_setup *setup_data) |
877 | { | 876 | { |
878 | struct rpc_task *task; | 877 | struct rpc_task *task; |
879 | 878 | ||
@@ -881,7 +880,7 @@ struct rpc_task *rpc_new_task(struct rpc_clnt *clnt, int flags, const struct rpc | |||
881 | if (!task) | 880 | if (!task) |
882 | goto out; | 881 | goto out; |
883 | 882 | ||
884 | rpc_init_task(task, clnt, flags, tk_ops, calldata); | 883 | rpc_init_task(task, setup_data); |
885 | 884 | ||
886 | dprintk("RPC: allocated task %p\n", task); | 885 | dprintk("RPC: allocated task %p\n", task); |
887 | task->tk_flags |= RPC_TASK_DYNAMIC; | 886 | task->tk_flags |= RPC_TASK_DYNAMIC; |