aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Carroll <aaronc@gelato.unsw.edu.au>2007-10-30 05:40:12 -0400
committerJens Axboe <axboe@carl.home.kernel.dk>2007-11-02 03:47:25 -0400
commit5d1a536621403b442eef60ddd35e6b7a46fb04b7 (patch)
tree030f15afc505ce86653e338ce4f734a995dbb6b8
parent54866f032307063776b4eff7eadb131d47f9f9b4 (diff)
Deadline iosched: Factor out finding latter reques
Factor finding the next request in sector-sorted order into a function deadline_latter_request. Signed-off-by: Aaron Carroll <aaronc@gelato.unsw.edu.au> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
-rw-r--r--block/deadline-iosched.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/block/deadline-iosched.c b/block/deadline-iosched.c
index 1a511ffaf8a4..a44437e5a94b 100644
--- a/block/deadline-iosched.c
+++ b/block/deadline-iosched.c
@@ -55,6 +55,20 @@ static void deadline_move_request(struct deadline_data *, struct request *);
55 55
56#define RQ_RB_ROOT(dd, rq) (&(dd)->sort_list[rq_data_dir((rq))]) 56#define RQ_RB_ROOT(dd, rq) (&(dd)->sort_list[rq_data_dir((rq))])
57 57
58/*
59 * get the request after `rq' in sector-sorted order
60 */
61static inline struct request *
62deadline_latter_request(struct request *rq)
63{
64 struct rb_node *node = rb_next(&rq->rb_node);
65
66 if (node)
67 return rb_entry_rq(node);
68
69 return NULL;
70}
71
58static void 72static void
59deadline_add_rq_rb(struct deadline_data *dd, struct request *rq) 73deadline_add_rq_rb(struct deadline_data *dd, struct request *rq)
60{ 74{
@@ -74,13 +88,8 @@ deadline_del_rq_rb(struct deadline_data *dd, struct request *rq)
74{ 88{
75 const int data_dir = rq_data_dir(rq); 89 const int data_dir = rq_data_dir(rq);
76 90
77 if (dd->next_rq[data_dir] == rq) { 91 if (dd->next_rq[data_dir] == rq)
78 struct rb_node *rbnext = rb_next(&rq->rb_node); 92 dd->next_rq[data_dir] = deadline_latter_request(rq);
79
80 dd->next_rq[data_dir] = NULL;
81 if (rbnext)
82 dd->next_rq[data_dir] = rb_entry_rq(rbnext);
83 }
84 93
85 elv_rb_del(RQ_RB_ROOT(dd, rq), rq); 94 elv_rb_del(RQ_RB_ROOT(dd, rq), rq);
86} 95}
@@ -198,14 +207,11 @@ static void
198deadline_move_request(struct deadline_data *dd, struct request *rq) 207deadline_move_request(struct deadline_data *dd, struct request *rq)
199{ 208{
200 const int data_dir = rq_data_dir(rq); 209 const int data_dir = rq_data_dir(rq);
201 struct rb_node *rbnext = rb_next(&rq->rb_node);
202 210
203 dd->next_rq[READ] = NULL; 211 dd->next_rq[READ] = NULL;
204 dd->next_rq[WRITE] = NULL; 212 dd->next_rq[WRITE] = NULL;
213 dd->next_rq[data_dir] = deadline_latter_request(rq);
205 214
206 if (rbnext)
207 dd->next_rq[data_dir] = rb_entry_rq(rbnext);
208
209 dd->last_sector = rq->sector + rq->nr_sectors; 215 dd->last_sector = rq->sector + rq->nr_sectors;
210 216
211 /* 217 /*