diff options
author | Jens Axboe <axboe@suse.de> | 2006-06-21 03:36:18 -0400 |
---|---|---|
committer | Jens Axboe <axboe@nelson.home.kernel.dk> | 2006-06-23 11:10:39 -0400 |
commit | dd67d051529387f6e44d22d1d5540ef281965fdd (patch) | |
tree | 80457f9a2ad3e562b179e40f5c8d51b4f24d6d9e /block/deadline-iosched.c | |
parent | 9e94cd4fd1812bab45237f998b3c6fa1b24023fd (diff) |
[PATCH] rbtree: support functions used by the io schedulers
They all duplicate macros to check for empty root and/or node, and
clearing a node. So put those in rbtree.h.
Signed-off-by: Jens Axboe <axboe@suse.de>
Diffstat (limited to 'block/deadline-iosched.c')
-rw-r--r-- | block/deadline-iosched.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/block/deadline-iosched.c b/block/deadline-iosched.c index e5bccaaed563..4469dd84623c 100644 --- a/block/deadline-iosched.c +++ b/block/deadline-iosched.c | |||
@@ -159,9 +159,6 @@ deadline_find_drq_hash(struct deadline_data *dd, sector_t offset) | |||
159 | /* | 159 | /* |
160 | * rb tree support functions | 160 | * rb tree support functions |
161 | */ | 161 | */ |
162 | #define RB_EMPTY(root) ((root)->rb_node == NULL) | ||
163 | #define ON_RB(node) (rb_parent(node) != node) | ||
164 | #define RB_CLEAR(node) (rb_set_parent(node, node)) | ||
165 | #define rb_entry_drq(node) rb_entry((node), struct deadline_rq, rb_node) | 162 | #define rb_entry_drq(node) rb_entry((node), struct deadline_rq, rb_node) |
166 | #define DRQ_RB_ROOT(dd, drq) (&(dd)->sort_list[rq_data_dir((drq)->request)]) | 163 | #define DRQ_RB_ROOT(dd, drq) (&(dd)->sort_list[rq_data_dir((drq)->request)]) |
167 | #define rq_rb_key(rq) (rq)->sector | 164 | #define rq_rb_key(rq) (rq)->sector |
@@ -220,9 +217,9 @@ deadline_del_drq_rb(struct deadline_data *dd, struct deadline_rq *drq) | |||
220 | dd->next_drq[data_dir] = rb_entry_drq(rbnext); | 217 | dd->next_drq[data_dir] = rb_entry_drq(rbnext); |
221 | } | 218 | } |
222 | 219 | ||
223 | BUG_ON(!ON_RB(&drq->rb_node)); | 220 | BUG_ON(!RB_EMPTY_NODE(&drq->rb_node)); |
224 | rb_erase(&drq->rb_node, DRQ_RB_ROOT(dd, drq)); | 221 | rb_erase(&drq->rb_node, DRQ_RB_ROOT(dd, drq)); |
225 | RB_CLEAR(&drq->rb_node); | 222 | RB_CLEAR_NODE(&drq->rb_node); |
226 | } | 223 | } |
227 | 224 | ||
228 | static struct request * | 225 | static struct request * |
@@ -496,7 +493,7 @@ static int deadline_dispatch_requests(request_queue_t *q, int force) | |||
496 | */ | 493 | */ |
497 | 494 | ||
498 | if (reads) { | 495 | if (reads) { |
499 | BUG_ON(RB_EMPTY(&dd->sort_list[READ])); | 496 | BUG_ON(RB_EMPTY_ROOT(&dd->sort_list[READ])); |
500 | 497 | ||
501 | if (writes && (dd->starved++ >= dd->writes_starved)) | 498 | if (writes && (dd->starved++ >= dd->writes_starved)) |
502 | goto dispatch_writes; | 499 | goto dispatch_writes; |
@@ -512,7 +509,7 @@ static int deadline_dispatch_requests(request_queue_t *q, int force) | |||
512 | 509 | ||
513 | if (writes) { | 510 | if (writes) { |
514 | dispatch_writes: | 511 | dispatch_writes: |
515 | BUG_ON(RB_EMPTY(&dd->sort_list[WRITE])); | 512 | BUG_ON(RB_EMPTY_ROOT(&dd->sort_list[WRITE])); |
516 | 513 | ||
517 | dd->starved = 0; | 514 | dd->starved = 0; |
518 | 515 | ||
@@ -668,7 +665,7 @@ deadline_set_request(request_queue_t *q, struct request *rq, struct bio *bio, | |||
668 | drq = mempool_alloc(dd->drq_pool, gfp_mask); | 665 | drq = mempool_alloc(dd->drq_pool, gfp_mask); |
669 | if (drq) { | 666 | if (drq) { |
670 | memset(drq, 0, sizeof(*drq)); | 667 | memset(drq, 0, sizeof(*drq)); |
671 | RB_CLEAR(&drq->rb_node); | 668 | RB_CLEAR_NODE(&drq->rb_node); |
672 | drq->request = rq; | 669 | drq->request = rq; |
673 | 670 | ||
674 | INIT_HLIST_NODE(&drq->hash); | 671 | INIT_HLIST_NODE(&drq->hash); |