block: ensure jiffies wrap is handled correctly in blk_rq_timed_out_timer

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linux Kernel Mailing List
Date: Wednesday, April 28, 2010 - 1:59 pm

Gitweb:     http://git.kernel.org/linus/a534dbe96e9929c7245924d8252d89048c23d569
Commit:     a534dbe96e9929c7245924d8252d89048c23d569
Parent:     05ce7bfe547c9fa967d9cab6c37867a9cb6fb3fa
Author:     Richard Kennedy <richard@rsk.demon.co.uk>
AuthorDate: Wed Apr 14 20:54:03 2010 +0200
Committer:  Jens Axboe <jens.axboe@oracle.com>
CommitDate: Wed Apr 21 17:42:08 2010 +0200

    block: ensure jiffies wrap is handled correctly in blk_rq_timed_out_timer
    
    blk_rq_timed_out_timer() relied on blk_add_timer() never returning a
    timer value of zero, but commit 7838c15b8dd18e78a523513749e5b54bda07b0cb
    removed the code that bumped this value when it was zero.
    Therefore when jiffies is near wrap we could get unlucky & not set the
    timeout value correctly.
    
    This patch uses a flag to indicate that the timeout value was set and so
    handles jiffies wrap correctly, and it keeps all the logic in one
    function so should be easier to maintain in the future.
    
    Signed-off-by: Richard Kennedy <richard@rsk.demon.co.uk>
    Cc: stable@kernel.org
    Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
---
 block/blk-timeout.c |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/block/blk-timeout.c b/block/blk-timeout.c
index 1ba7e0a..4f0c06c 100644
--- a/block/blk-timeout.c
+++ b/block/blk-timeout.c
@@ -109,6 +109,7 @@ void blk_rq_timed_out_timer(unsigned long data)
 	struct request_queue *q = (struct request_queue *) data;
 	unsigned long flags, next = 0;
 	struct request *rq, *tmp;
+	int next_set = 0;
 
 	spin_lock_irqsave(q->queue_lock, flags);
 
@@ -122,16 +123,13 @@ void blk_rq_timed_out_timer(unsigned long data)
 			if (blk_mark_rq_complete(rq))
 				continue;
 			blk_rq_timed_out(rq);
-		} else if (!next || time_after(next, rq->deadline))
+		} else if (!next_set || time_after(next, rq->deadline)) {
 			next = rq->deadline;
+			next_set = 1;
+		}
 	}
 
-	/*
-	 * next can never be 0 here with the list non-empty, since we always
-	 * bump ->deadline to 1 so we can detect if the timer was ever added
-	 * or not. See comment in blk_add_timer()
-	 */
-	if (next)
+	if (next_set)
 		mod_timer(&q->timeout, round_jiffies_up(next));
 
 	spin_unlock_irqrestore(q->queue_lock, flags);
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
block: ensure jiffies wrap is handled correctly in blk_rq_ ..., Linux Kernel Mailing ..., (Wed Apr 28, 1:59 pm)