aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Axboe <axboe@suse.de>2006-07-11 15:15:52 -0400
committerJens Axboe <axboe@nelson.home.kernel.dk>2006-09-30 14:26:56 -0400
commit10fd48f2376db52f08bf0420d2c4f580e39269e1 (patch)
tree89de18dcda9c8a09937187a0e8d138cfe3cb4089
parent9817064b68fef7e4580c6df1ea597e106b9ff88b (diff)
[PATCH] rbtree: fixed reversed RB_EMPTY_NODE and rb_next/prev
The conditions got reserved. Also make rb_next() and rb_prev() check for the empty condition. Signed-off-by: Jens Axboe <axboe@suse.de>
-rw-r--r--block/as-iosched.c4
-rw-r--r--include/linux/rbtree.h2
-rw-r--r--lib/rbtree.c6
3 files changed, 9 insertions, 3 deletions
diff --git a/block/as-iosched.c b/block/as-iosched.c
index 6db494333c3..9d0f15a54c6 100644
--- a/block/as-iosched.c
+++ b/block/as-iosched.c
@@ -336,7 +336,7 @@ static void as_add_arq_rb(struct as_data *ad, struct as_rq *arq)
336 336
337static inline void as_del_arq_rb(struct as_data *ad, struct as_rq *arq) 337static inline void as_del_arq_rb(struct as_data *ad, struct as_rq *arq)
338{ 338{
339 if (!RB_EMPTY_NODE(&arq->rb_node)) { 339 if (RB_EMPTY_NODE(&arq->rb_node)) {
340 WARN_ON(1); 340 WARN_ON(1);
341 return; 341 return;
342 } 342 }
@@ -1039,7 +1039,7 @@ static void as_move_to_dispatch(struct as_data *ad, struct as_rq *arq)
1039 struct request *rq = arq->request; 1039 struct request *rq = arq->request;
1040 const int data_dir = arq->is_sync; 1040 const int data_dir = arq->is_sync;
1041 1041
1042 BUG_ON(!RB_EMPTY_NODE(&arq->rb_node)); 1042 BUG_ON(RB_EMPTY_NODE(&arq->rb_node));
1043 1043
1044 as_antic_stop(ad); 1044 as_antic_stop(ad);
1045 ad->antic_status = ANTIC_OFF; 1045 ad->antic_status = ANTIC_OFF;
diff --git a/include/linux/rbtree.h b/include/linux/rbtree.h
index 8d5382e62c0..344bc3495dd 100644
--- a/include/linux/rbtree.h
+++ b/include/linux/rbtree.h
@@ -133,7 +133,7 @@ static inline void rb_set_color(struct rb_node *rb, int color)
133#define rb_entry(ptr, type, member) container_of(ptr, type, member) 133#define rb_entry(ptr, type, member) container_of(ptr, type, member)
134 134
135#define RB_EMPTY_ROOT(root) ((root)->rb_node == NULL) 135#define RB_EMPTY_ROOT(root) ((root)->rb_node == NULL)
136#define RB_EMPTY_NODE(node) (rb_parent(node) != node) 136#define RB_EMPTY_NODE(node) (rb_parent(node) == node)
137#define RB_CLEAR_NODE(node) (rb_set_parent(node, node)) 137#define RB_CLEAR_NODE(node) (rb_set_parent(node, node))
138 138
139extern void rb_insert_color(struct rb_node *, struct rb_root *); 139extern void rb_insert_color(struct rb_node *, struct rb_root *);
diff --git a/lib/rbtree.c b/lib/rbtree.c
index 1e55ba1c2ed..48499c2d88c 100644
--- a/lib/rbtree.c
+++ b/lib/rbtree.c
@@ -322,6 +322,9 @@ struct rb_node *rb_next(struct rb_node *node)
322{ 322{
323 struct rb_node *parent; 323 struct rb_node *parent;
324 324
325 if (rb_parent(node) == node)
326 return NULL;
327
325 /* If we have a right-hand child, go down and then left as far 328 /* If we have a right-hand child, go down and then left as far
326 as we can. */ 329 as we can. */
327 if (node->rb_right) { 330 if (node->rb_right) {
@@ -348,6 +351,9 @@ struct rb_node *rb_prev(struct rb_node *node)
348{ 351{
349 struct rb_node *parent; 352 struct rb_node *parent;
350 353
354 if (rb_parent(node) == node)
355 return NULL;
356
351 /* If we have a left-hand child, go down and then right as far 357 /* If we have a left-hand child, go down and then right as far
352 as we can. */ 358 as we can. */
353 if (node->rb_left) { 359 if (node->rb_left) {