]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
[PATCH] rbtree: fixed reversed RB_EMPTY_NODE and rb_next/prev
authorJens Axboe <axboe@suse.de>
Tue, 11 Jul 2006 19:15:52 +0000 (21:15 +0200)
committerJens Axboe <axboe@nelson.home.kernel.dk>
Sat, 30 Sep 2006 18:26:56 +0000 (20:26 +0200)
The conditions got reserved. Also make rb_next() and rb_prev() check
for the empty condition.

Signed-off-by: Jens Axboe <axboe@suse.de>
block/as-iosched.c
include/linux/rbtree.h
lib/rbtree.c

index 6db494333c3a554000baf1e3281aa755b9765255..9d0f15a54c64f9fd05bbe936ec646845c2ecfe65 100644 (file)
@@ -336,7 +336,7 @@ static void as_add_arq_rb(struct as_data *ad, struct as_rq *arq)
 
 static inline void as_del_arq_rb(struct as_data *ad, struct as_rq *arq)
 {
-       if (!RB_EMPTY_NODE(&arq->rb_node)) {
+       if (RB_EMPTY_NODE(&arq->rb_node)) {
                WARN_ON(1);
                return;
        }
@@ -1039,7 +1039,7 @@ static void as_move_to_dispatch(struct as_data *ad, struct as_rq *arq)
        struct request *rq = arq->request;
        const int data_dir = arq->is_sync;
 
-       BUG_ON(!RB_EMPTY_NODE(&arq->rb_node));
+       BUG_ON(RB_EMPTY_NODE(&arq->rb_node));
 
        as_antic_stop(ad);
        ad->antic_status = ANTIC_OFF;
index 8d5382e62c08e8503f5e43e2e62b7215df2dd26b..344bc3495ddbd12548c32ebaf57cd3c6ee7e8be9 100644 (file)
@@ -133,7 +133,7 @@ static inline void rb_set_color(struct rb_node *rb, int color)
 #define        rb_entry(ptr, type, member) container_of(ptr, type, member)
 
 #define RB_EMPTY_ROOT(root)    ((root)->rb_node == NULL)
-#define RB_EMPTY_NODE(node)    (rb_parent(node) != node)
+#define RB_EMPTY_NODE(node)    (rb_parent(node) == node)
 #define RB_CLEAR_NODE(node)    (rb_set_parent(node, node))
 
 extern void rb_insert_color(struct rb_node *, struct rb_root *);
index 1e55ba1c2edfac510c41c87e47e7849f99a5f3b3..48499c2d88ccf16d65c8891e3fc5a23e8cdf283a 100644 (file)
@@ -322,6 +322,9 @@ struct rb_node *rb_next(struct rb_node *node)
 {
        struct rb_node *parent;
 
+       if (rb_parent(node) == node)
+               return NULL;
+
        /* If we have a right-hand child, go down and then left as far
           as we can. */
        if (node->rb_right) {
@@ -348,6 +351,9 @@ struct rb_node *rb_prev(struct rb_node *node)
 {
        struct rb_node *parent;
 
+       if (rb_parent(node) == node)
+               return NULL;
+
        /* If we have a left-hand child, go down and then right as far
           as we can. */
        if (node->rb_left) {