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/as-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/as-iosched.c')
-rw-r--r-- | block/as-iosched.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/block/as-iosched.c b/block/as-iosched.c index 56c99fa037df..1ec5df466708 100644 --- a/block/as-iosched.c +++ b/block/as-iosched.c | |||
@@ -347,9 +347,6 @@ static struct request *as_find_arq_hash(struct as_data *ad, sector_t offset) | |||
347 | /* | 347 | /* |
348 | * rb tree support functions | 348 | * rb tree support functions |
349 | */ | 349 | */ |
350 | #define RB_EMPTY(root) ((root)->rb_node == NULL) | ||
351 | #define ON_RB(node) (rb_parent(node) != node) | ||
352 | #define RB_CLEAR(node) (rb_set_parent(node, node)) | ||
353 | #define rb_entry_arq(node) rb_entry((node), struct as_rq, rb_node) | 350 | #define rb_entry_arq(node) rb_entry((node), struct as_rq, rb_node) |
354 | #define ARQ_RB_ROOT(ad, arq) (&(ad)->sort_list[(arq)->is_sync]) | 351 | #define ARQ_RB_ROOT(ad, arq) (&(ad)->sort_list[(arq)->is_sync]) |
355 | #define rq_rb_key(rq) (rq)->sector | 352 | #define rq_rb_key(rq) (rq)->sector |
@@ -418,13 +415,13 @@ static void as_add_arq_rb(struct as_data *ad, struct as_rq *arq) | |||
418 | 415 | ||
419 | static inline void as_del_arq_rb(struct as_data *ad, struct as_rq *arq) | 416 | static inline void as_del_arq_rb(struct as_data *ad, struct as_rq *arq) |
420 | { | 417 | { |
421 | if (!ON_RB(&arq->rb_node)) { | 418 | if (!RB_EMPTY_NODE(&arq->rb_node)) { |
422 | WARN_ON(1); | 419 | WARN_ON(1); |
423 | return; | 420 | return; |
424 | } | 421 | } |
425 | 422 | ||
426 | rb_erase(&arq->rb_node, ARQ_RB_ROOT(ad, arq)); | 423 | rb_erase(&arq->rb_node, ARQ_RB_ROOT(ad, arq)); |
427 | RB_CLEAR(&arq->rb_node); | 424 | RB_CLEAR_NODE(&arq->rb_node); |
428 | } | 425 | } |
429 | 426 | ||
430 | static struct request * | 427 | static struct request * |
@@ -545,7 +542,7 @@ static struct as_rq *as_find_next_arq(struct as_data *ad, struct as_rq *last) | |||
545 | struct rb_node *rbprev = rb_prev(&last->rb_node); | 542 | struct rb_node *rbprev = rb_prev(&last->rb_node); |
546 | struct as_rq *arq_next, *arq_prev; | 543 | struct as_rq *arq_next, *arq_prev; |
547 | 544 | ||
548 | BUG_ON(!ON_RB(&last->rb_node)); | 545 | BUG_ON(!RB_EMPTY_NODE(&last->rb_node)); |
549 | 546 | ||
550 | if (rbprev) | 547 | if (rbprev) |
551 | arq_prev = rb_entry_arq(rbprev); | 548 | arq_prev = rb_entry_arq(rbprev); |
@@ -1122,7 +1119,7 @@ static void as_move_to_dispatch(struct as_data *ad, struct as_rq *arq) | |||
1122 | struct request *rq = arq->request; | 1119 | struct request *rq = arq->request; |
1123 | const int data_dir = arq->is_sync; | 1120 | const int data_dir = arq->is_sync; |
1124 | 1121 | ||
1125 | BUG_ON(!ON_RB(&arq->rb_node)); | 1122 | BUG_ON(!RB_EMPTY_NODE(&arq->rb_node)); |
1126 | 1123 | ||
1127 | as_antic_stop(ad); | 1124 | as_antic_stop(ad); |
1128 | ad->antic_status = ANTIC_OFF; | 1125 | ad->antic_status = ANTIC_OFF; |
@@ -1247,7 +1244,7 @@ static int as_dispatch_request(request_queue_t *q, int force) | |||
1247 | */ | 1244 | */ |
1248 | 1245 | ||
1249 | if (reads) { | 1246 | if (reads) { |
1250 | BUG_ON(RB_EMPTY(&ad->sort_list[REQ_SYNC])); | 1247 | BUG_ON(RB_EMPTY_ROOT(&ad->sort_list[REQ_SYNC])); |
1251 | 1248 | ||
1252 | if (writes && ad->batch_data_dir == REQ_SYNC) | 1249 | if (writes && ad->batch_data_dir == REQ_SYNC) |
1253 | /* | 1250 | /* |
@@ -1271,7 +1268,7 @@ static int as_dispatch_request(request_queue_t *q, int force) | |||
1271 | 1268 | ||
1272 | if (writes) { | 1269 | if (writes) { |
1273 | dispatch_writes: | 1270 | dispatch_writes: |
1274 | BUG_ON(RB_EMPTY(&ad->sort_list[REQ_ASYNC])); | 1271 | BUG_ON(RB_EMPTY_ROOT(&ad->sort_list[REQ_ASYNC])); |
1275 | 1272 | ||
1276 | if (ad->batch_data_dir == REQ_SYNC) { | 1273 | if (ad->batch_data_dir == REQ_SYNC) { |
1277 | ad->changed_batch = 1; | 1274 | ad->changed_batch = 1; |
@@ -1591,7 +1588,7 @@ static int as_set_request(request_queue_t *q, struct request *rq, | |||
1591 | 1588 | ||
1592 | if (arq) { | 1589 | if (arq) { |
1593 | memset(arq, 0, sizeof(*arq)); | 1590 | memset(arq, 0, sizeof(*arq)); |
1594 | RB_CLEAR(&arq->rb_node); | 1591 | RB_CLEAR_NODE(&arq->rb_node); |
1595 | arq->request = rq; | 1592 | arq->request = rq; |
1596 | arq->state = AS_RQ_PRESCHED; | 1593 | arq->state = AS_RQ_PRESCHED; |
1597 | arq->io_context = NULL; | 1594 | arq->io_context = NULL; |