Fix a bug with multiple files in the same io_piece rbtree
authorJens Axboe <jaxboe@fusionio.com>
Mon, 21 Jun 2010 07:01:33 +0000 (09:01 +0200)
committerJens Axboe <jaxboe@fusionio.com>
Mon, 21 Jun 2010 07:01:33 +0000 (09:01 +0200)
Sort by file first, then sort by offset. This avoids false
positives on IO aliases, when it's really for a different file.

Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
log.c

diff --git a/log.c b/log.c
index 6a99c6611e3ad79aa2763ee44f4656863d1ba824..5fc8f64bef4fde855d9c11e471db35f0d94778f6 100644 (file)
--- a/log.c
+++ b/log.c
@@ -219,7 +219,11 @@ restart:
                parent = *p;
 
                __ipo = rb_entry(parent, struct io_piece, rb_node);
-               if (ipo->offset < __ipo->offset)
+               if (ipo->file < __ipo->file)
+                       p = &(*p)->rb_left;
+               else if (ipo->file > __ipo->file)
+                       p = &(*p)->rb_right;
+               else if (ipo->offset < __ipo->offset)
                        p = &(*p)->rb_left;
                else if (ipo->offset > __ipo->offset)
                        p = &(*p)->rb_right;