• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-WNDR4500v2-V1.0.0.60_1.0.38/src/linux/linux-2.6/net/sunrpc/

Lines Matching refs:task

42 static void			__rpc_default_timer(struct rpc_task *task);
45 static void rpc_release_task(struct rpc_task *task);
70 * Disable the timer for a given RPC task. Should be called with
75 __rpc_disable_timer(struct rpc_task *task)
77 dprintk("RPC: %5u disabling timer\n", task->tk_pid);
78 task->tk_timeout_fn = NULL;
79 task->tk_timeout = 0;
89 static void rpc_run_timer(struct rpc_task *task)
93 callback = task->tk_timeout_fn;
94 task->tk_timeout_fn = NULL;
95 if (callback && RPC_IS_QUEUED(task)) {
96 dprintk("RPC: %5u running timer\n", task->tk_pid);
97 callback(task);
100 clear_bit(RPC_TASK_HAS_TIMER, &task->tk_runstate);
105 * Set up a timer for the current task.
108 __rpc_add_timer(struct rpc_task *task, rpc_action timer)
110 if (!task->tk_timeout)
114 task->tk_pid, task->tk_timeout * 1000 / HZ);
117 task->tk_timeout_fn = timer;
119 task->tk_timeout_fn = __rpc_default_timer;
120 set_bit(RPC_TASK_HAS_TIMER, &task->tk_runstate);
121 mod_timer(&task->tk_timer, jiffies + task->tk_timeout);
125 * Delete any timer for the current task. Because we use del_timer_sync(),
129 rpc_delete_timer(struct rpc_task *task)
131 if (RPC_IS_QUEUED(task))
133 if (test_and_clear_bit(RPC_TASK_HAS_TIMER, &task->tk_runstate)) {
134 del_singleshot_timer_sync(&task->tk_timer);
135 dprintk("RPC: %5u deleting timer\n", task->tk_pid);
142 static void __rpc_add_wait_queue_priority(struct rpc_wait_queue *queue, struct rpc_task *task)
147 INIT_LIST_HEAD(&task->u.tk_wait.links);
148 q = &queue->tasks[task->tk_priority];
149 if (unlikely(task->tk_priority > queue->maxpriority))
152 if (t->tk_cookie == task->tk_cookie) {
153 list_add_tail(&task->u.tk_wait.list, &t->u.tk_wait.links);
157 list_add_tail(&task->u.tk_wait.list, q);
168 static void __rpc_add_wait_queue(struct rpc_wait_queue *queue, struct rpc_task *task)
170 BUG_ON (RPC_IS_QUEUED(task));
173 __rpc_add_wait_queue_priority(queue, task);
174 else if (RPC_IS_SWAPPER(task))
175 list_add(&task->u.tk_wait.list, &queue->tasks[0]);
177 list_add_tail(&task->u.tk_wait.list, &queue->tasks[0]);
178 task->u.tk_wait.rpc_waitq = queue;
180 rpc_set_queued(task);
183 task->tk_pid, queue, rpc_qname(queue));
189 static void __rpc_remove_wait_queue_priority(struct rpc_task *task)
193 if (!list_empty(&task->u.tk_wait.links)) {
194 t = list_entry(task->u.tk_wait.links.next, struct rpc_task, u.tk_wait.list);
195 list_move(&t->u.tk_wait.list, &task->u.tk_wait.list);
196 list_splice_init(&task->u.tk_wait.links, &t->u.tk_wait.links);
198 list_del(&task->u.tk_wait.list);
205 static void __rpc_remove_wait_queue(struct rpc_task *task)
208 queue = task->u.tk_wait.rpc_waitq;
211 __rpc_remove_wait_queue_priority(task);
213 list_del(&task->u.tk_wait.list);
216 task->tk_pid, queue, rpc_qname(queue));
270 static void rpc_set_active(struct rpc_task *task)
272 if (test_and_set_bit(RPC_TASK_ACTIVE, &task->tk_runstate) != 0)
276 task->tk_magic = RPC_TASK_MAGIC_ID;
277 task->tk_pid = rpc_task_id++;
280 list_add_tail(&task->tk_task, &all_tasks);
287 static void rpc_mark_complete_task(struct rpc_task *task)
290 clear_bit(RPC_TASK_ACTIVE, &task->tk_runstate);
292 wake_up_bit(&task->tk_runstate, RPC_TASK_ACTIVE);
298 int __rpc_wait_for_completion_task(struct rpc_task *task, int (*action)(void *))
302 return wait_on_bit(&task->tk_runstate, RPC_TASK_ACTIVE,
308 * Make an RPC task runnable.
310 * Note: If the task is ASYNC, this must be called with
313 static void rpc_make_runnable(struct rpc_task *task)
315 BUG_ON(task->tk_timeout_fn);
316 rpc_clear_queued(task);
317 if (rpc_test_and_set_running(task))
320 if (RPC_IS_QUEUED(task)) {
321 rpc_clear_running(task);
324 if (RPC_IS_ASYNC(task)) {
327 INIT_WORK(&task->u.tk_work, rpc_async_schedule);
328 status = queue_work(task->tk_workqueue, &task->u.tk_work);
330 printk(KERN_WARNING "RPC: failed to add task to queue: error: %d!\n", status);
331 task->tk_status = status;
335 wake_up_bit(&task->tk_runstate, RPC_TASK_QUEUED);
341 * NB: An RPC task will only receive interrupt-driven events as long
344 static void __rpc_sleep_on(struct rpc_wait_queue *q, struct rpc_task *task,
348 task->tk_pid, rpc_qname(q), jiffies);
350 if (!RPC_IS_ASYNC(task) && !RPC_IS_ACTIVATED(task)) {
351 printk(KERN_ERR "RPC: Inactive synchronous task put to sleep!\n");
355 __rpc_add_wait_queue(q, task);
357 BUG_ON(task->tk_callback != NULL);
358 task->tk_callback = action;
359 __rpc_add_timer(task, timer);
362 void rpc_sleep_on(struct rpc_wait_queue *q, struct rpc_task *task,
365 /* Mark the task as being activated if so needed */
366 rpc_set_active(task);
372 __rpc_sleep_on(q, task, action, timer);
378 * @task: task to be woken up
380 * Caller must hold queue->lock, and have cleared the task queued flag.
382 static void __rpc_do_wake_up_task(struct rpc_task *task)
385 task->tk_pid, jiffies);
388 BUG_ON(task->tk_magic != RPC_TASK_MAGIC_ID);
390 /* Has the task been executed yet? If not, we cannot wake it up! */
391 if (!RPC_IS_ACTIVATED(task)) {
392 printk(KERN_ERR "RPC: Inactive task (%p) being woken up!\n", task);
396 __rpc_disable_timer(task);
397 __rpc_remove_wait_queue(task);
399 rpc_make_runnable(task);
405 * Wake up the specified task
407 static void __rpc_wake_up_task(struct rpc_task *task)
409 if (rpc_start_wakeup(task)) {
410 if (RPC_IS_QUEUED(task))
411 __rpc_do_wake_up_task(task);
412 rpc_finish_wakeup(task);
420 __rpc_default_timer(struct rpc_task *task)
422 dprintk("RPC: %5u timeout (default timer)\n", task->tk_pid);
423 task->tk_status = -ETIMEDOUT;
424 rpc_wake_up_task(task);
428 * Wake up the specified task
430 void rpc_wake_up_task(struct rpc_task *task)
433 if (rpc_start_wakeup(task)) {
434 if (RPC_IS_QUEUED(task)) {
435 struct rpc_wait_queue *queue = task->u.tk_wait.rpc_waitq;
439 __rpc_do_wake_up_task(task);
442 rpc_finish_wakeup(task);
448 * Wake up the next task on a priority queue.
453 struct rpc_task *task;
460 task = list_entry(q->next, struct rpc_task, u.tk_wait.list);
461 if (queue->cookie == task->tk_cookie) {
464 list_move_tail(&task->u.tk_wait.list, q);
482 task = list_entry(q->next, struct rpc_task, u.tk_wait.list);
493 rpc_set_waitqueue_cookie(queue, task->tk_cookie);
495 __rpc_wake_up_task(task);
496 return task;
500 * Wake up the next task on the wait queue.
504 struct rpc_task *task = NULL;
511 task = __rpc_wake_up_next_priority(queue);
513 task_for_first(task, &queue->tasks[0])
514 __rpc_wake_up_task(task);
519 return task;
530 struct rpc_task *task, *next;
537 list_for_each_entry_safe(task, next, head, u.tk_wait.list)
538 __rpc_wake_up_task(task);
556 struct rpc_task *task, *next;
563 list_for_each_entry_safe(task, next, head, u.tk_wait.list) {
564 task->tk_status = status;
565 __rpc_wake_up_task(task);
575 static void __rpc_atrun(struct rpc_task *task)
577 rpc_wake_up_task(task);
581 * Run a task at a later time
583 void rpc_delay(struct rpc_task *task, unsigned long delay)
585 task->tk_timeout = delay;
586 rpc_sleep_on(&delay_queue, task, NULL, __rpc_atrun);
590 * Helper to call task->tk_ops->rpc_call_prepare
592 static void rpc_prepare_task(struct rpc_task *task)
595 task->tk_ops->rpc_call_prepare(task, task->tk_calldata);
600 * Helper that calls task->tk_ops->rpc_call_done if it exists
602 void rpc_exit_task(struct rpc_task *task)
604 task->tk_action = NULL;
605 if (task->tk_ops->rpc_call_done != NULL) {
607 task->tk_ops->rpc_call_done(task, task->tk_calldata);
609 if (task->tk_action != NULL) {
610 WARN_ON(RPC_ASSASSINATED(task));
612 xprt_release(task);
630 static void __rpc_execute(struct rpc_task *task)
635 task->tk_pid, task->tk_flags);
637 BUG_ON(RPC_IS_QUEUED(task));
643 rpc_delete_timer(task);
648 if (RPC_DO_CALLBACK(task)) {
659 save_callback=task->tk_callback;
660 task->tk_callback=NULL;
661 save_callback(task);
666 * tk_action may be NULL when the task has been killed
669 if (!RPC_IS_QUEUED(task)) {
670 if (task->tk_action == NULL)
672 task->tk_action(task);
676 * Lockless check for whether task is sleeping or not.
678 if (!RPC_IS_QUEUED(task))
680 rpc_clear_running(task);
681 if (RPC_IS_ASYNC(task)) {
683 if (RPC_IS_QUEUED(task))
685 if (rpc_test_and_set_running(task))
690 /* sync task: sleep here */
691 dprintk("RPC: %5u sync task going to sleep\n", task->tk_pid);
693 status = out_of_line_wait_on_bit(&task->tk_runstate,
698 * When a sync task receives a signal, it exits with
703 dprintk("RPC: %5u got signal\n", task->tk_pid);
704 task->tk_flags |= RPC_TASK_KILLED;
705 rpc_exit(task, -ERESTARTSYS);
706 rpc_wake_up_task(task);
708 rpc_set_running(task);
709 dprintk("RPC: %5u sync task resuming\n", task->tk_pid);
712 dprintk("RPC: %5u return %d, status %d\n", task->tk_pid, status,
713 task->tk_status);
714 /* Release all resources associated with the task */
715 rpc_release_task(task);
721 * This may be called recursively if e.g. an async NFS task updates
723 * NOTE: Upon exit of this function the task is guaranteed to be
725 * been called, so your task memory may have been freed.
727 void rpc_execute(struct rpc_task *task)
729 rpc_set_active(task);
730 rpc_set_running(task);
731 __rpc_execute(task);
746 * @task: RPC task that will use this buffer
760 void *rpc_malloc(struct rpc_task *task, size_t size)
763 gfp_t gfp = RPC_IS_SWAPPER(task) ? GFP_ATOMIC : GFP_NOWAIT;
776 task->tk_pid, size, buf);
806 * Creation and deletion of RPC task structures
808 void rpc_init_task(struct rpc_task *task, struct rpc_clnt *clnt, int flags, const struct rpc_call_ops *tk_ops, void *calldata)
810 memset(task, 0, sizeof(*task));
811 init_timer(&task->tk_timer);
812 task->tk_timer.data = (unsigned long) task;
813 task->tk_timer.function = (void (*)(unsigned long)) rpc_run_timer;
814 atomic_set(&task->tk_count, 1);
815 task->tk_client = clnt;
816 task->tk_flags = flags;
817 task->tk_ops = tk_ops;
819 task->tk_action = rpc_prepare_task;
820 task->tk_calldata = calldata;
823 task->tk_garb_retry = 2;
824 task->tk_cred_retry = 2;
826 task->tk_priority = RPC_PRIORITY_NORMAL;
827 task->tk_cookie = (unsigned long)current;
830 task->tk_workqueue = rpciod_workqueue;
835 task->tk_flags |= RPC_TASK_SOFT;
837 task->tk_flags |= RPC_TASK_NOINTR;
840 BUG_ON(task->tk_ops == NULL);
843 task->tk_start = jiffies;
845 dprintk("RPC: new task initialized, procpid %u\n",
857 struct rpc_task *task = container_of(rcu, struct rpc_task, u.tk_rcu);
858 dprintk("RPC: %5u freeing task\n", task->tk_pid);
859 mempool_free(task, rpc_task_mempool);
863 * Create a new task for the specified client. We have to
869 struct rpc_task *task;
871 task = rpc_alloc_task();
872 if (!task)
875 rpc_init_task(task, clnt, flags, tk_ops, calldata);
877 dprintk("RPC: allocated task %p\n", task);
878 task->tk_flags |= RPC_TASK_DYNAMIC;
880 return task;
894 void rpc_put_task(struct rpc_task *task)
896 const struct rpc_call_ops *tk_ops = task->tk_ops;
897 void *calldata = task->tk_calldata;
899 if (!atomic_dec_and_test(&task->tk_count))
902 if (task->tk_rqstp)
903 xprt_release(task);
904 if (task->tk_msg.rpc_cred)
905 rpcauth_unbindcred(task);
906 if (task->tk_client) {
907 rpc_release_client(task->tk_client);
908 task->tk_client = NULL;
910 if (task->tk_flags & RPC_TASK_DYNAMIC)
911 call_rcu_bh(&task->u.tk_rcu, rpc_free_task);
916 static void rpc_release_task(struct rpc_task *task)
919 BUG_ON(task->tk_magic != RPC_TASK_MAGIC_ID);
921 dprintk("RPC: %5u release task\n", task->tk_pid);
923 /* Remove from global task list */
925 list_del(&task->tk_task);
928 BUG_ON (RPC_IS_QUEUED(task));
931 rpc_delete_timer(task);
934 task->tk_magic = 0;
936 /* Wake up anyone who is waiting for task completion */
937 rpc_mark_complete_task(task);
939 rpc_put_task(task);
943 * rpc_run_task - Allocate a new RPC task, then run rpc_execute against it
953 struct rpc_task *task;
954 task = rpc_new_task(clnt, flags, ops, data);
955 if (task == NULL) {
959 atomic_inc(&task->tk_count);
960 rpc_execute(task);
961 return task;