block: relax jiffies rounding for timeouts
[linux-2.6-microblaze.git] / block / blk-timeout.c
index 3a1ac64..8ab8a82 100644 (file)
@@ -88,11 +88,29 @@ void blk_abort_request(struct request *req)
 }
 EXPORT_SYMBOL_GPL(blk_abort_request);
 
+static unsigned long blk_timeout_mask __read_mostly;
+
+int __init blk_timeout_init(void)
+{
+       blk_timeout_mask = roundup_pow_of_two(HZ) - 1;
+       return 0;
+}
+
+late_initcall(blk_timeout_init);
+
+/*
+ * Just a rough estimate, we don't care about specific values for timeouts.
+ */
+static inline unsigned long blk_round_jiffies(unsigned long j)
+{
+       return (j + blk_timeout_mask) + 1;
+}
+
 unsigned long blk_rq_timeout(unsigned long timeout)
 {
        unsigned long maxt;
 
-       maxt = round_jiffies_up(jiffies + BLK_MAX_TIMEOUT);
+       maxt = blk_round_jiffies(jiffies + BLK_MAX_TIMEOUT);
        if (time_after(timeout, maxt))
                timeout = maxt;
 
@@ -129,7 +147,7 @@ void blk_add_timer(struct request *req)
         * than an existing one, modify the timer. Round up to next nearest
         * second.
         */
-       expiry = blk_rq_timeout(round_jiffies_up(expiry));
+       expiry = blk_rq_timeout(blk_round_jiffies(expiry));
 
        if (!timer_pending(&q->timeout) ||
            time_before(expiry, q->timeout.expires)) {