genfio: Splitting gen_template in 2 parts
[fio.git] / iolog.c
diff --git a/iolog.c b/iolog.c
index c1764bac76f8e56568d77af112353d31ccc3d12f..9bcf0d8e2982e37ce5d48fbd64e9653872e54ea0 100644 (file)
--- a/iolog.c
+++ b/iolog.c
@@ -110,7 +110,7 @@ int read_iolog_get(struct thread_data *td, struct io_u *io_u)
 {
        struct io_piece *ipo;
        unsigned long elapsed;
-       
+
        while (!flist_empty(&td->io_log_list)) {
                int ret;
 
@@ -141,11 +141,10 @@ int read_iolog_get(struct thread_data *td, struct io_u *io_u)
                        elapsed = mtime_since_genesis();
                        if (ipo->delay > elapsed)
                                usec_sleep(td, (ipo->delay - elapsed) * 1000);
-                               
                }
 
                free(ipo);
-               
+
                if (io_u->ddir != DDIR_WAIT)
                        return 0;
        }
@@ -176,12 +175,6 @@ void prune_io_piece_log(struct thread_data *td)
        }
 }
 
-static void dump_ipo(struct io_piece *ipo, const char *msg)
-{
-       printf("%s\n", msg);
-       printf("\toffset %llu, len %lu, fl %x, ddir %d\n", ipo->offset, ipo->len, ipo->flags, ipo->ddir);
-}
-
 /*
  * log a successful write, so we can unwind the log for verify
  */
@@ -245,12 +238,9 @@ restart:
                else if (ipo->offset > __ipo->offset)
                        p = &(*p)->rb_right;
                else {
-                       if (ipo->len != __ipo->len) {
-                               log_err("fio: unexpected ipo overlap!\n");
-                               log_err("fio: please report this issue.\n");
-                               dump_ipo(ipo, "ipo");
-                               dump_ipo(__ipo, "__ipo");
-                       }
+                       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);
@@ -325,6 +315,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")) {
@@ -381,7 +372,7 @@ static int read_iolog2(struct thread_data *td, FILE *f)
                        ipo->fileno = fileno;
                        ipo->file_action = file_action;
                }
-                       
+
                queue_io_piece(td, ipo);
        }
 
@@ -503,13 +494,14 @@ int init_iolog(struct thread_data *td)
        return ret;
 }
 
-void setup_log(struct io_log **log, unsigned long avg_msec)
+void setup_log(struct io_log **log, unsigned long avg_msec, int log_type)
 {
        struct io_log *l = malloc(sizeof(*l));
 
        memset(l, 0, sizeof(*l));
        l->nr_samples = 0;
        l->max_samples = 1024;
+       l->log_type = log_type;
        l->log = malloc(l->max_samples * sizeof(struct io_sample));
        l->avg_msec = avg_msec;
        *log = l;
@@ -527,10 +519,10 @@ void __finish_log(struct io_log *log, const char *name)
        }
 
        for (i = 0; i < log->nr_samples; i++) {
-               fprintf(f, "%lu, %lu, %u, %u\n", log->log[i].time,
-                                               log->log[i].val,
-                                               log->log[i].ddir,
-                                               log->log[i].bs);
+               fprintf(f, "%lu, %lu, %u, %u\n",
+                               (unsigned long) log->log[i].time,
+                               (unsigned long) log->log[i].val,
+                               log->log[i].ddir, log->log[i].bs);
        }
 
        fclose(f);
@@ -543,9 +535,15 @@ 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);
+
+       if (td->client_type == FIO_CLIENT_TYPE_GUI) {
+               fio_send_iolog(td, log, p);
+               free(log->log);
+               free(log);
+       } else
+               __finish_log(log, p);
 }
 
 void finish_log(struct thread_data *td, struct io_log *log, const char *name)