Fix io piece logging to not have O(n) runtime
[fio.git] / verify.c
index f748065d7fc031b66098334aef419654b5ff25c9..7fbb2e6cd9ee9132e9eecb2eaddf27f71b163913 100644 (file)
--- a/verify.c
+++ b/verify.c
@@ -145,6 +145,7 @@ void populate_verify_io_u(struct thread_data *td, struct io_u *io_u)
 int get_next_verify(struct thread_data *td, struct io_u *io_u)
 {
        struct io_piece *ipo;
+       struct rb_node *n;
 
        /*
         * this io_u is from a requeue, we already filled the offsets
@@ -152,10 +153,11 @@ int get_next_verify(struct thread_data *td, struct io_u *io_u)
        if (io_u->file)
                return 0;
 
-       if (!list_empty(&td->io_hist_list)) {
-               ipo = list_entry(td->io_hist_list.next, struct io_piece, list);
+       n = rb_first(&td->io_hist_tree);
+       if (n) {
+               ipo = rb_entry(n, struct io_piece, rb_node);
 
-               list_del(&ipo->list);
+               rb_erase(n, &td->io_hist_tree);
 
                io_u->offset = ipo->offset;
                io_u->buflen = ipo->len;