block: relax when to modify the timeout timer
[linux-2.6-block.git] / block / blk-timeout.c
index d96f7061c6fd8727de9eb9fc02fae7b07dd357c1..a09e8af8186c8cb671ef29cbcbcfa41ab00c23f4 100644 (file)
@@ -199,8 +199,19 @@ void __blk_add_timer(struct request *req, struct list_head *timeout_list)
        expiry = round_jiffies_up(req->deadline);
 
        if (!timer_pending(&q->timeout) ||
-           time_before(expiry, q->timeout.expires))
-               mod_timer(&q->timeout, expiry);
+           time_before(expiry, q->timeout.expires)) {
+               unsigned long diff = q->timeout.expires - expiry;
+
+               /*
+                * Due to added timer slack to group timers, the timer
+                * will often be a little in front of what we asked for.
+                * So apply some tolerance here too, otherwise we keep
+                * modifying the timer because expires for value X
+                * will be X + something.
+                */
+               if (diff >= HZ / 2)
+                       mod_timer(&q->timeout, expiry);
+       }
 
 }