prune_io_piece_log() also needs to take list into account
[fio.git] / log.c
diff --git a/log.c b/log.c
index 66b8f5babfe106ba3d7d1a68ab02d393d3467c22..8754eb051a1ecfb3ba38290b8d88d5a6bb547c8a 100644 (file)
--- a/log.c
+++ b/log.c
@@ -84,6 +84,9 @@ int read_iolog_get(struct thread_data *td, struct io_u *io_u)
                io_u->file = &td->files[ipo->fileno];
                get_file(io_u->file);
 
+               dprint(FD_IO, "iolog: get %llu/%lu/%s\n", io_u->offset,
+                                       io_u->buflen, io_u->file->file_name);
+
                if (ipo->delay)
                        iolog_delay(td, ipo->delay);
 
@@ -105,6 +108,12 @@ void prune_io_piece_log(struct thread_data *td)
                rb_erase(n, &td->io_hist_tree);
                free(ipo);
        }
+
+       while (!list_empty(&td->io_hist_list)) {
+               ipo = list_entry(td->io_hist_list.next, struct io_piece, list);
+               list_del(&ipo->list);
+               free(ipo);
+       }
 }
 
 /*
@@ -129,8 +138,7 @@ void log_io_piece(struct thread_data *td, struct io_u *io_u)
         * For both these cases, just reading back data in the order we
         * wrote it out is the fastest.
         */
-       if (!td_random(td) || !td->o.overwrite ||
-            (io_u->file->flags & FIO_FILE_NOSORT)) {
+       if (!td_random(td) || !td->o.overwrite) {
                INIT_LIST_HEAD(&ipo->list);
                list_add_tail(&ipo->list, &td->io_hist_list);
                return;
@@ -294,7 +302,7 @@ static int read_iolog(struct thread_data *td, FILE *f)
        unsigned int bytes;
        char *str, *p;
        int reads, writes;
-       enum fio_ddir rw;
+       int rw;
 
        /*
         * Read in the read iolog and store it, reuse the infrastructure
@@ -328,7 +336,7 @@ static int read_iolog(struct thread_data *td, FILE *f)
                INIT_LIST_HEAD(&ipo->list);
                ipo->offset = offset;
                ipo->len = bytes;
-               ipo->ddir = rw;
+               ipo->ddir = (enum fio_ddir) rw;
                if (bytes > td->o.max_bs[rw])
                        td->o.max_bs[rw] = bytes;
                list_add_tail(&ipo->list, &td->io_log_list);