Better handling of file creation vs existing files
[fio.git] / stat.c
diff --git a/stat.c b/stat.c
index 8d391a35d4dec7058e0670bde73685d3fa176937..815e3ae54fd42f01200614db771c5768cf004147 100644 (file)
--- a/stat.c
+++ b/stat.c
@@ -241,21 +241,13 @@ static int find_block_dir(dev_t dev, char *path)
        return found;
 }
 
-void init_disk_util(struct thread_data *td)
+static void __init_disk_util(struct thread_data *td, struct fio_file *f)
 {
-       struct fio_file *f;
        struct stat st;
        char foo[PATH_MAX], tmp[PATH_MAX];
        dev_t dev;
        char *p;
 
-       if (!td->do_disk_util || (td->io_ops->flags & FIO_DISKLESSIO))
-               return;
-
-       /*
-        * Just use the same file, they are on the same device.
-        */
-       f = &td->files[0];
        if (!stat(f->file_name, &st)) {
                if (S_ISBLK(st.st_mode))
                        dev = st.st_rdev;
@@ -310,12 +302,25 @@ void init_disk_util(struct thread_data *td)
                sprintf(foo, "%s", tmp);
        }
 
-       if (td->ioscheduler)
+       if (td->ioscheduler && !td->sysfs_root)
                td->sysfs_root = strdup(foo);
 
        disk_util_add(dev, foo);
 }
 
+void init_disk_util(struct thread_data *td)
+{
+       struct fio_file *f;
+       unsigned int i;
+
+       if (!td->do_disk_util ||
+           (td->io_ops->flags & (FIO_DISKLESSIO | FIO_NODISKUTIL)))
+               return;
+
+       for_each_file(td, f, i)
+               __init_disk_util(td, f);
+}
+
 void disk_util_timer_arm(void)
 {
        itimer.it_value.tv_sec = 0;
@@ -669,18 +674,27 @@ void show_run_stats(void)
                        ts->slat_stat[j].min_val = -1UL;
                        ts->bw_stat[j].min_val = -1UL;
                }
+               ts->groupid = -1;
        }
 
        j = 0;
        last_ts = -1;
        idx = 0;
        for_each_td(td, i) {
+               if (idx && (!td->group_reporting ||
+                   (td->group_reporting && last_ts != td->groupid))) {
+                       idx = 0;
+                       j++;
+               }
+
+               last_ts = td->groupid;
+
                ts = &threadstats[j];
 
                idx++;
                ts->members++;
 
-               if (!ts->groupid) {
+               if (ts->groupid == -1) {
                        /*
                         * These are per-group shared already
                         */
@@ -724,21 +738,6 @@ void show_run_stats(void)
                        ts->total_io_u[k] += td->ts.total_io_u[k];
 
                ts->total_run_time += td->ts.total_run_time;
-
-               if (!td->group_reporting) {
-                       idx = 0;
-                       j++;
-                       continue;
-               }
-               if (last_ts == td->groupid)
-                       continue;
-
-               if (last_ts != -1) {
-                       idx = 0;
-                       j++;
-               }
-
-               last_ts = td->groupid;
        }
 
        for (i = 0; i < nr_ts; i++) {