aboutsummaryrefslogtreecommitdiffstats
path: root/block/cfq-iosched.c
diff options
context:
space:
mode:
authorCorrado Zoccolo <czoccolo@gmail.com>2009-10-05 02:49:23 -0400
committerJens Axboe <jens.axboe@oracle.com>2009-10-05 05:03:55 -0400
commit48e025e63ac908ed6ec5394a294f4ecd510a7476 (patch)
tree49828c00687c810627f00430dd56ce9901537fc9 /block/cfq-iosched.c
parent30996f40bffe73f05abb92a4cec254befa8cecf7 (diff)
cfq-iosched: fix possible problem with jiffies wraparound
The RR service tree is indexed by a key that is relative to current jiffies. This can cause problems on jiffies wraparound. The patch fixes it using time_before comparison, and changing the add_front path to use a relative number, too. Signed-off-by: Corrado Zoccolo <czoccolo@gmail.com> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'block/cfq-iosched.c')
-rw-r--r--block/cfq-iosched.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index e7f9e4e3a270..ae14cbaf9d0e 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -512,8 +512,11 @@ static void cfq_service_tree_add(struct cfq_data *cfqd, struct cfq_queue *cfqq,
512 rb_key = cfq_slice_offset(cfqd, cfqq) + jiffies; 512 rb_key = cfq_slice_offset(cfqd, cfqq) + jiffies;
513 rb_key += cfqq->slice_resid; 513 rb_key += cfqq->slice_resid;
514 cfqq->slice_resid = 0; 514 cfqq->slice_resid = 0;
515 } else 515 } else {
516 rb_key = 0; 516 rb_key = -HZ;
517 __cfqq = cfq_rb_first(&cfqd->service_tree);
518 rb_key += __cfqq ? __cfqq->rb_key : jiffies;
519 }
517 520
518 if (!RB_EMPTY_NODE(&cfqq->rb_node)) { 521 if (!RB_EMPTY_NODE(&cfqq->rb_node)) {
519 /* 522 /*
@@ -547,7 +550,7 @@ static void cfq_service_tree_add(struct cfq_data *cfqd, struct cfq_queue *cfqq,
547 n = &(*p)->rb_left; 550 n = &(*p)->rb_left;
548 else if (cfq_class_idle(cfqq) > cfq_class_idle(__cfqq)) 551 else if (cfq_class_idle(cfqq) > cfq_class_idle(__cfqq))
549 n = &(*p)->rb_right; 552 n = &(*p)->rb_right;
550 else if (rb_key < __cfqq->rb_key) 553 else if (time_before(rb_key, __cfqq->rb_key))
551 n = &(*p)->rb_left; 554 n = &(*p)->rb_left;
552 else 555 else
553 n = &(*p)->rb_right; 556 n = &(*p)->rb_right;