Fix replay of IO pattern with multiple open files
[fio.git] / iolog.c
diff --git a/iolog.c b/iolog.c
index f962864d912d9b5cdc3bfbc39286241fdd717665..b73c208e468e5e948c799d4a2d8d9beb72c60f49 100644 (file)
--- a/iolog.c
+++ b/iolog.c
@@ -239,7 +239,9 @@ restart:
                else if (ipo->offset > __ipo->offset)
                        p = &(*p)->rb_right;
                else {
-                       assert(ipo->len == __ipo->len);
+                       dprint(FD_IO, "iolog: overlap %llu/%lu, %llu/%lu",
+                               __ipo->offset, __ipo->len,
+                               ipo->offset, ipo->len);
                        td->io_hist_len--;
                        rb_erase(parent, &td->io_hist_tree);
                        remove_trim_entry(td, __ipo);
@@ -314,6 +316,7 @@ static int read_iolog2(struct thread_data *td, FILE *f)
                                                                        act);
                                continue;
                        }
+                       fileno = get_fileno(td, fname);
                } else if (r == 2) {
                        rw = DDIR_INVAL;
                        if (!strcmp(act, "add")) {
@@ -492,13 +495,15 @@ int init_iolog(struct thread_data *td)
        return ret;
 }
 
-void setup_log(struct io_log **log)
+void setup_log(struct io_log **log, unsigned long avg_msec)
 {
        struct io_log *l = malloc(sizeof(*l));
 
+       memset(l, 0, sizeof(*l));
        l->nr_samples = 0;
        l->max_samples = 1024;
        l->log = malloc(l->max_samples * sizeof(struct io_sample));
+       l->avg_msec = avg_msec;
        *log = l;
 }
 
@@ -530,7 +535,7 @@ void finish_log_named(struct thread_data *td, struct io_log *log,
 {
        char file_name[256], *p;
 
-       snprintf(file_name, 200, "%s_%s.log", prefix, postfix);
+       snprintf(file_name, sizeof(file_name), "%s_%s.log", prefix, postfix);
        p = basename(file_name);
        __finish_log(log, p);
 }