fio: flush log files on test end
authorPeter Oberparleiter <oberpar@linux.vnet.ibm.com>
Thu, 20 Feb 2014 13:20:05 +0000 (14:20 +0100)
committerJens Axboe <axboe@fb.com>
Thu, 20 Feb 2014 17:14:21 +0000 (09:14 -0800)
Ensure proper flushing of all logs at the end of tests.

Signed-off-by: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
backend.c
iolog.h
stat.c

index b92877efd1ca8a167555cd753387df6eaf39fbc5..87aec87b37ac6df9b975f274f6200f344bae5dd4 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -1461,6 +1461,7 @@ static void *thread_main(void *data)
        fio_unpin_memory(td);
 
        fio_mutex_down(writeout_mutex);
        fio_unpin_memory(td);
 
        fio_mutex_down(writeout_mutex);
+       finalize_logs(td);
        if (td->bw_log) {
                if (o->bw_log_file) {
                        finish_log_named(td, td->bw_log,
        if (td->bw_log) {
                if (o->bw_log_file) {
                        finish_log_named(td, td->bw_log,
diff --git a/iolog.h b/iolog.h
index 3ec48f2100fe04f1cc8981a81d61e0d60fb3f9ea..07163916585baea680eb14604b3020c2d300e20b 100644 (file)
--- a/iolog.h
+++ b/iolog.h
@@ -117,6 +117,7 @@ extern void write_iolog_close(struct thread_data *);
 /*
  * Logging
  */
 /*
  * Logging
  */
+extern void finalize_logs(struct thread_data *td);
 extern void add_lat_sample(struct thread_data *, enum fio_ddir, unsigned long,
                                unsigned int);
 extern void add_clat_sample(struct thread_data *, enum fio_ddir, unsigned long,
 extern void add_lat_sample(struct thread_data *, enum fio_ddir, unsigned long,
                                unsigned int);
 extern void add_clat_sample(struct thread_data *, enum fio_ddir, unsigned long,
diff --git a/stat.c b/stat.c
index 77275d94efe4de77f3fb3bc6a39fa6b70121c07a..bc01b5192f31a25299591b5a66dd4c0a6d3ce242 100644 (file)
--- a/stat.c
+++ b/stat.c
@@ -1579,6 +1579,37 @@ static inline void reset_io_stat(struct io_stat *ios)
        ios->mean.u.f = ios->S.u.f = 0;
 }
 
        ios->mean.u.f = ios->S.u.f = 0;
 }
 
+static void _add_stat_to_log(struct io_log *iolog, unsigned long elapsed)
+{
+       /*
+        * Note an entry in the log. Use the mean from the logged samples,
+        * making sure to properly round up. Only write a log entry if we
+        * had actual samples done.
+        */
+       if (iolog->avg_window[DDIR_READ].samples) {
+               unsigned long mr;
+
+               mr = iolog->avg_window[DDIR_READ].mean.u.f + 0.50;
+               __add_log_sample(iolog, mr, DDIR_READ, 0, elapsed);
+       }
+       if (iolog->avg_window[DDIR_WRITE].samples) {
+               unsigned long mw;
+
+               mw = iolog->avg_window[DDIR_WRITE].mean.u.f + 0.50;
+               __add_log_sample(iolog, mw, DDIR_WRITE, 0, elapsed);
+       }
+       if (iolog->avg_window[DDIR_TRIM].samples) {
+               unsigned long mw;
+
+               mw = iolog->avg_window[DDIR_TRIM].mean.u.f + 0.50;
+               __add_log_sample(iolog, mw, DDIR_TRIM, 0, elapsed);
+       }
+
+       reset_io_stat(&iolog->avg_window[DDIR_READ]);
+       reset_io_stat(&iolog->avg_window[DDIR_WRITE]);
+       reset_io_stat(&iolog->avg_window[DDIR_TRIM]);
+}
+
 static void add_log_sample(struct thread_data *td, struct io_log *iolog,
                           unsigned long val, enum fio_ddir ddir,
                           unsigned int bs)
 static void add_log_sample(struct thread_data *td, struct io_log *iolog,
                           unsigned long val, enum fio_ddir ddir,
                           unsigned int bs)
@@ -1612,35 +1643,27 @@ static void add_log_sample(struct thread_data *td, struct io_log *iolog,
        if (this_window < iolog->avg_msec)
                return;
 
        if (this_window < iolog->avg_msec)
                return;
 
-       /*
-        * Note an entry in the log. Use the mean from the logged samples,
-        * making sure to properly round up. Only write a log entry if we
-        * had actual samples done.
-        */
-       if (iolog->avg_window[DDIR_READ].samples) {
-               unsigned long mr;
-
-               mr = iolog->avg_window[DDIR_READ].mean.u.f + 0.50;
-               __add_log_sample(iolog, mr, DDIR_READ, 0, elapsed);
-       }
-       if (iolog->avg_window[DDIR_WRITE].samples) {
-               unsigned long mw;
+       _add_stat_to_log(iolog, elapsed);
 
 
-               mw = iolog->avg_window[DDIR_WRITE].mean.u.f + 0.50;
-               __add_log_sample(iolog, mw, DDIR_WRITE, 0, elapsed);
-       }
-       if (iolog->avg_window[DDIR_TRIM].samples) {
-               unsigned long mw;
+       iolog->avg_last = elapsed;
+}
 
 
-               mw = iolog->avg_window[DDIR_TRIM].mean.u.f + 0.50;
-               __add_log_sample(iolog, mw, DDIR_TRIM, 0, elapsed);
-       }
+void finalize_logs(struct thread_data *td)
+{
+       unsigned long elapsed;
 
 
+       elapsed = mtime_since_now(&td->epoch);
 
 
-       reset_io_stat(&iolog->avg_window[DDIR_READ]);
-       reset_io_stat(&iolog->avg_window[DDIR_WRITE]);
-       reset_io_stat(&iolog->avg_window[DDIR_TRIM]);
-       iolog->avg_last = elapsed;
+       if (td->clat_log)
+               _add_stat_to_log(td->clat_log, elapsed);
+       if (td->slat_log)
+               _add_stat_to_log(td->slat_log, elapsed);
+       if (td->lat_log)
+               _add_stat_to_log(td->lat_log, elapsed);
+       if (td->bw_log)
+               _add_stat_to_log(td->bw_log, elapsed);
+       if (td->iops_log)
+               _add_stat_to_log(td->iops_log, elapsed);
 }
 
 void add_agg_sample(unsigned long val, enum fio_ddir ddir, unsigned int bs)
 }
 
 void add_agg_sample(unsigned long val, enum fio_ddir ddir, unsigned int bs)