aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2008-02-22 15:09:26 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2008-02-26 00:40:39 -0500
commitfde95c7554aa77f9a242f32b0b5f8f15395abf52 (patch)
tree293e0161eb30e1e87a305d07e57f54f483655b78 /net/sunrpc
parent101070ca2fe67186f5f5517b66cb4757b17f4e29 (diff)
SUNRPC: Clean up rpc_run_timer()
All RPC timeout callback functions are expected to wake the task up. We can enforce this by moving the wakeup back into rpc_run_timer. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'net/sunrpc')
-rw-r--r--net/sunrpc/sched.c67
-rw-r--r--net/sunrpc/xprt.c2
2 files changed, 35 insertions, 34 deletions
diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
index 3e0b22382a3b..9433a113862c 100644
--- a/net/sunrpc/sched.c
+++ b/net/sunrpc/sched.c
@@ -38,7 +38,6 @@ static struct kmem_cache *rpc_buffer_slabp __read_mostly;
38static mempool_t *rpc_task_mempool __read_mostly; 38static mempool_t *rpc_task_mempool __read_mostly;
39static mempool_t *rpc_buffer_mempool __read_mostly; 39static mempool_t *rpc_buffer_mempool __read_mostly;
40 40
41static void __rpc_default_timer(struct rpc_task *task);
42static void rpc_async_schedule(struct work_struct *); 41static void rpc_async_schedule(struct work_struct *);
43static void rpc_release_task(struct rpc_task *task); 42static void rpc_release_task(struct rpc_task *task);
44 43
@@ -66,25 +65,13 @@ __rpc_disable_timer(struct rpc_task *task)
66} 65}
67 66
68/* 67/*
69 * Run a timeout function. 68 * Default timeout handler if none specified by user
70 * We use the callback in order to allow __rpc_wake_up_task()
71 * and friends to disable the timer synchronously on SMP systems
72 * without calling del_timer_sync(). The latter could cause a
73 * deadlock if called while we're holding spinlocks...
74 */ 69 */
75static void rpc_run_timer(struct rpc_task *task) 70static void
71__rpc_default_timer(struct rpc_task *task)
76{ 72{
77 void (*callback)(struct rpc_task *); 73 dprintk("RPC: %5u timeout (default timer)\n", task->tk_pid);
78 74 task->tk_status = -ETIMEDOUT;
79 callback = task->tk_timeout_fn;
80 task->tk_timeout_fn = NULL;
81 if (callback && RPC_IS_QUEUED(task)) {
82 dprintk("RPC: %5u running timer\n", task->tk_pid);
83 callback(task);
84 }
85 smp_mb__before_clear_bit();
86 clear_bit(RPC_TASK_HAS_TIMER, &task->tk_runstate);
87 smp_mb__after_clear_bit();
88} 75}
89 76
90/* 77/*
@@ -416,17 +403,6 @@ static void __rpc_wake_up_task(struct rpc_task *task)
416} 403}
417 404
418/* 405/*
419 * Default timeout handler if none specified by user
420 */
421static void
422__rpc_default_timer(struct rpc_task *task)
423{
424 dprintk("RPC: %5u timeout (default timer)\n", task->tk_pid);
425 task->tk_status = -ETIMEDOUT;
426 rpc_wake_up_task(task);
427}
428
429/*
430 * Wake up the specified task 406 * Wake up the specified task
431 */ 407 */
432void rpc_wake_up_task(struct rpc_task *task) 408void rpc_wake_up_task(struct rpc_task *task)
@@ -578,9 +554,37 @@ void rpc_wake_up_status(struct rpc_wait_queue *queue, int status)
578} 554}
579EXPORT_SYMBOL_GPL(rpc_wake_up_status); 555EXPORT_SYMBOL_GPL(rpc_wake_up_status);
580 556
557/*
558 * Run a timeout function.
559 */
560static void rpc_run_timer(unsigned long ptr)
561{
562 struct rpc_task *task = (struct rpc_task *)ptr;
563 void (*callback)(struct rpc_task *);
564
565 if (!rpc_start_wakeup(task))
566 goto out;
567 if (RPC_IS_QUEUED(task)) {
568 struct rpc_wait_queue *queue = task->u.tk_wait.rpc_waitq;
569 callback = task->tk_timeout_fn;
570
571 dprintk("RPC: %5u running timer\n", task->tk_pid);
572 if (callback != NULL)
573 callback(task);
574 /* Note: we're already in a bh-safe context */
575 spin_lock(&queue->lock);
576 __rpc_do_wake_up_task(task);
577 spin_unlock(&queue->lock);
578 }
579 rpc_finish_wakeup(task);
580out:
581 smp_mb__before_clear_bit();
582 clear_bit(RPC_TASK_HAS_TIMER, &task->tk_runstate);
583 smp_mb__after_clear_bit();
584}
585
581static void __rpc_atrun(struct rpc_task *task) 586static void __rpc_atrun(struct rpc_task *task)
582{ 587{
583 rpc_wake_up_task(task);
584} 588}
585 589
586/* 590/*
@@ -816,8 +820,7 @@ EXPORT_SYMBOL_GPL(rpc_free);
816static void rpc_init_task(struct rpc_task *task, const struct rpc_task_setup *task_setup_data) 820static void rpc_init_task(struct rpc_task *task, const struct rpc_task_setup *task_setup_data)
817{ 821{
818 memset(task, 0, sizeof(*task)); 822 memset(task, 0, sizeof(*task));
819 setup_timer(&task->tk_timer, (void (*)(unsigned long))rpc_run_timer, 823 setup_timer(&task->tk_timer, rpc_run_timer, (unsigned long)task);
820 (unsigned long)task);
821 atomic_set(&task->tk_count, 1); 824 atomic_set(&task->tk_count, 1);
822 task->tk_flags = task_setup_data->flags; 825 task->tk_flags = task_setup_data->flags;
823 task->tk_ops = task_setup_data->callback_ops; 826 task->tk_ops = task_setup_data->callback_ops;
diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c
index d5553b8179f9..96c212ddc41a 100644
--- a/net/sunrpc/xprt.c
+++ b/net/sunrpc/xprt.c
@@ -777,8 +777,6 @@ static void xprt_timer(struct rpc_task *task)
777 xprt->ops->timer(task); 777 xprt->ops->timer(task);
778 task->tk_status = -ETIMEDOUT; 778 task->tk_status = -ETIMEDOUT;
779 } 779 }
780 task->tk_timeout = 0;
781 rpc_wake_up_task(task);
782 spin_unlock(&xprt->transport_lock); 780 spin_unlock(&xprt->transport_lock);
783} 781}
784 782