aboutsummaryrefslogtreecommitdiffstats
path: root/block/blk-timeout.c
diff options
context:
space:
mode:
Diffstat (limited to 'block/blk-timeout.c')
-rw-r--r--block/blk-timeout.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/block/blk-timeout.c b/block/blk-timeout.c
index 69185ea9fae2..a09535377a94 100644
--- a/block/blk-timeout.c
+++ b/block/blk-timeout.c
@@ -73,11 +73,7 @@ ssize_t part_timeout_store(struct device *dev, struct device_attribute *attr,
73 */ 73 */
74void blk_delete_timer(struct request *req) 74void blk_delete_timer(struct request *req)
75{ 75{
76 struct request_queue *q = req->q;
77
78 list_del_init(&req->timeout_list); 76 list_del_init(&req->timeout_list);
79 if (list_empty(&q->timeout_list))
80 del_timer(&q->timeout);
81} 77}
82 78
83static void blk_rq_timed_out(struct request *req) 79static void blk_rq_timed_out(struct request *req)
@@ -111,7 +107,7 @@ static void blk_rq_timed_out(struct request *req)
111void blk_rq_timed_out_timer(unsigned long data) 107void blk_rq_timed_out_timer(unsigned long data)
112{ 108{
113 struct request_queue *q = (struct request_queue *) data; 109 struct request_queue *q = (struct request_queue *) data;
114 unsigned long flags, uninitialized_var(next), next_set = 0; 110 unsigned long flags, next = 0;
115 struct request *rq, *tmp; 111 struct request *rq, *tmp;
116 112
117 spin_lock_irqsave(q->queue_lock, flags); 113 spin_lock_irqsave(q->queue_lock, flags);
@@ -126,15 +122,18 @@ void blk_rq_timed_out_timer(unsigned long data)
126 if (blk_mark_rq_complete(rq)) 122 if (blk_mark_rq_complete(rq))
127 continue; 123 continue;
128 blk_rq_timed_out(rq); 124 blk_rq_timed_out(rq);
125 } else {
126 if (!next || time_after(next, rq->deadline))
127 next = rq->deadline;
129 } 128 }
130 if (!next_set) {
131 next = rq->deadline;
132 next_set = 1;
133 } else if (time_after(next, rq->deadline))
134 next = rq->deadline;
135 } 129 }
136 130
137 if (next_set && !list_empty(&q->timeout_list)) 131 /*
132 * next can never be 0 here with the list non-empty, since we always
133 * bump ->deadline to 1 so we can detect if the timer was ever added
134 * or not. See comment in blk_add_timer()
135 */
136 if (next)
138 mod_timer(&q->timeout, round_jiffies_up(next)); 137 mod_timer(&q->timeout, round_jiffies_up(next));
139 138
140 spin_unlock_irqrestore(q->queue_lock, flags); 139 spin_unlock_irqrestore(q->queue_lock, flags);