Fix problems with rb code
authorJens Axboe <jens.axboe@oracle.com>
Tue, 27 Mar 2007 08:21:25 +0000 (10:21 +0200)
committerJens Axboe <jens.axboe@oracle.com>
Tue, 27 Mar 2007 08:21:25 +0000 (10:21 +0200)
If the offset match, we must not break. Instead follow the left branch
and things will work as expected.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
fio.c
log.c

diff --git a/fio.c b/fio.c
index 504b78db0b0cd6dc1390435f56fd89d6bf19345c..6a3a87b0feb9257c5e38b3f7826fc2ba96d08d31 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -736,6 +736,7 @@ static void *thread_main(void *data)
        INIT_LIST_HEAD(&td->io_u_busylist);
        INIT_LIST_HEAD(&td->io_u_requeues);
        INIT_LIST_HEAD(&td->io_log_list);
+       td->io_hist_tree = RB_ROOT;
 
        if (init_io_u(td))
                goto err_sem;
diff --git a/log.c b/log.c
index d59c38fd4e7cee46aa8f199b7f570e8c93b23501..0614b277c1e9de3752b977c284aa2531f9581049 100644 (file)
--- a/log.c
+++ b/log.c
@@ -48,7 +48,7 @@ void log_io_piece(struct thread_data *td, struct io_u *io_u)
        struct io_piece *ipo, *__ipo;
 
        ipo = malloc(sizeof(struct io_piece));
-       memset(&ipo->rb_node, 0, sizeof(ipo->rb_node));
+       RB_CLEAR_NODE(&ipo->rb_node);
        ipo->file = io_u->file;
        ipo->offset = io_u->offset;
        ipo->len = io_u->buflen;
@@ -60,12 +60,10 @@ void log_io_piece(struct thread_data *td, struct io_u *io_u)
                parent = *p;
 
                __ipo = rb_entry(parent, struct io_piece, rb_node);
-               if (ipo->offset < __ipo->offset)
+               if (ipo->offset <= __ipo->offset)
                        p = &(*p)->rb_left;
-               else if (ipo->offset > __ipo->offset)
-                       p = &(*p)->rb_right;
                else
-                       break;
+                       p = &(*p)->rb_right;
        }
 
        rb_link_node(&ipo->rb_node, parent, p);