From bb5d7d0b5bde867690590aaa61d77307d773107f Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Tue, 27 Mar 2007 10:21:25 +0200 Subject: [PATCH] Fix problems with rb code If the offset match, we must not break. Instead follow the left branch and things will work as expected. Signed-off-by: Jens Axboe --- fio.c | 1 + log.c | 8 +++----- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/fio.c b/fio.c index 504b78db..6a3a87b0 100644 --- 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 d59c38fd..0614b277 100644 --- 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); -- 2.25.1