diff options
author | Jens Axboe <axboe@suse.de> | 2006-07-13 05:55:04 -0400 |
---|---|---|
committer | Jens Axboe <axboe@nelson.home.kernel.dk> | 2006-09-30 14:26:57 -0400 |
commit | 2e662b65f05d550b6799ed6bfa9963b82279e6b7 (patch) | |
tree | 82911ec73a52d149d74a3d13c3c5eedb269a19cb /include/linux | |
parent | 10fd48f2376db52f08bf0420d2c4f580e39269e1 (diff) |
[PATCH] elevator: abstract out the rbtree sort handling
The rbtree sort/lookup/reposition logic is mostly duplicated in
cfq/deadline/as, so move it to the elevator core. The io schedulers
still provide the actual rb root, as we don't want to impose any sort
of specific handling on the schedulers.
Introduce the helpers and rb_node in struct request to help migrate the
IO schedulers.
Signed-off-by: Jens Axboe <axboe@suse.de>
Diffstat (limited to 'include/linux')
-rw-r--r-- | include/linux/blkdev.h | 1 | ||||
-rw-r--r-- | include/linux/elevator.h | 18 |
2 files changed, 17 insertions, 2 deletions
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 8f5486964671..a905c4934a55 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h | |||
@@ -230,6 +230,7 @@ struct request { | |||
230 | struct bio *biotail; | 230 | struct bio *biotail; |
231 | 231 | ||
232 | struct hlist_node hash; /* merge hash */ | 232 | struct hlist_node hash; /* merge hash */ |
233 | struct rb_node rb_node; /* sort/lookup */ | ||
233 | 234 | ||
234 | void *elevator_private; | 235 | void *elevator_private; |
235 | void *completion_data; | 236 | void *completion_data; |
diff --git a/include/linux/elevator.h b/include/linux/elevator.h index 2c270e90b33e..95b2a04b969c 100644 --- a/include/linux/elevator.h +++ b/include/linux/elevator.h | |||
@@ -6,7 +6,7 @@ typedef int (elevator_merge_fn) (request_queue_t *, struct request **, | |||
6 | 6 | ||
7 | typedef void (elevator_merge_req_fn) (request_queue_t *, struct request *, struct request *); | 7 | typedef void (elevator_merge_req_fn) (request_queue_t *, struct request *, struct request *); |
8 | 8 | ||
9 | typedef void (elevator_merged_fn) (request_queue_t *, struct request *); | 9 | typedef void (elevator_merged_fn) (request_queue_t *, struct request *, int); |
10 | 10 | ||
11 | typedef int (elevator_dispatch_fn) (request_queue_t *, int); | 11 | typedef int (elevator_dispatch_fn) (request_queue_t *, int); |
12 | 12 | ||
@@ -96,7 +96,7 @@ extern void elv_insert(request_queue_t *, struct request *, int); | |||
96 | extern int elv_merge(request_queue_t *, struct request **, struct bio *); | 96 | extern int elv_merge(request_queue_t *, struct request **, struct bio *); |
97 | extern void elv_merge_requests(request_queue_t *, struct request *, | 97 | extern void elv_merge_requests(request_queue_t *, struct request *, |
98 | struct request *); | 98 | struct request *); |
99 | extern void elv_merged_request(request_queue_t *, struct request *); | 99 | extern void elv_merged_request(request_queue_t *, struct request *, int); |
100 | extern void elv_dequeue_request(request_queue_t *, struct request *); | 100 | extern void elv_dequeue_request(request_queue_t *, struct request *); |
101 | extern void elv_requeue_request(request_queue_t *, struct request *); | 101 | extern void elv_requeue_request(request_queue_t *, struct request *); |
102 | extern int elv_queue_empty(request_queue_t *); | 102 | extern int elv_queue_empty(request_queue_t *); |
@@ -127,6 +127,19 @@ extern void elevator_exit(elevator_t *); | |||
127 | extern int elv_rq_merge_ok(struct request *, struct bio *); | 127 | extern int elv_rq_merge_ok(struct request *, struct bio *); |
128 | 128 | ||
129 | /* | 129 | /* |
130 | * Helper functions. | ||
131 | */ | ||
132 | extern struct request *elv_rb_former_request(request_queue_t *, struct request *); | ||
133 | extern struct request *elv_rb_latter_request(request_queue_t *, struct request *); | ||
134 | |||
135 | /* | ||
136 | * rb support functions. | ||
137 | */ | ||
138 | extern struct request *elv_rb_add(struct rb_root *, struct request *); | ||
139 | extern void elv_rb_del(struct rb_root *, struct request *); | ||
140 | extern struct request *elv_rb_find(struct rb_root *, sector_t); | ||
141 | |||
142 | /* | ||
130 | * Return values from elevator merger | 143 | * Return values from elevator merger |
131 | */ | 144 | */ |
132 | #define ELEVATOR_NO_MERGE 0 | 145 | #define ELEVATOR_NO_MERGE 0 |
@@ -151,5 +164,6 @@ enum { | |||
151 | }; | 164 | }; |
152 | 165 | ||
153 | #define rq_end_sector(rq) ((rq)->sector + (rq)->nr_sectors) | 166 | #define rq_end_sector(rq) ((rq)->sector + (rq)->nr_sectors) |
167 | #define rb_entry_rq(node) rb_entry((node), struct request, rb_node) | ||
154 | 168 | ||
155 | #endif | 169 | #endif |