iolog: fix --bandwidth-log segfaults
authorOmar Sandoval <osandov@fb.com>
Wed, 5 Oct 2016 22:15:27 +0000 (15:15 -0700)
committerJens Axboe <axboe@fb.com>
Tue, 11 Oct 2016 22:04:25 +0000 (16:04 -0600)
The global bandwidth log doesn't have thread data.

Fixes: 1e613c9c2393 ("This commit / feature adds completion latency histogram output to fio")
Fixes: 3aea75b14510 ("Option for changing log files to use Unix epoch")
Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
iolog.c
stat.c

diff --git a/iolog.c b/iolog.c
index 6576ca55237e58668bb892d1f4b1ec227eaef515..ab9c87881a0a98feb1fcd99faa4458e59ad711ec 100644 (file)
--- a/iolog.c
+++ b/iolog.c
@@ -1065,7 +1065,7 @@ void flush_log(struct io_log *log, bool do_append)
                cur_log = flist_first_entry(&log->io_logs, struct io_logs, list);
                flist_del_init(&cur_log->list);
                
                cur_log = flist_first_entry(&log->io_logs, struct io_logs, list);
                flist_del_init(&cur_log->list);
                
-               if (log == log->td->clat_hist_log)
+               if (log->td && log == log->td->clat_hist_log)
                        flush_hist_samples(f, log->hist_coarseness, cur_log->log,
                                           log_sample_sz(log, cur_log));
                else
                        flush_hist_samples(f, log->hist_coarseness, cur_log->log,
                                           log_sample_sz(log, cur_log));
                else
diff --git a/stat.c b/stat.c
index 3c72a6cd8a140b5fe0b81cb9d65d7dc1329a2dfb..1e889f537f24254cc9090a103a1993cf1a18e09d 100644 (file)
--- a/stat.c
+++ b/stat.c
@@ -2023,7 +2023,7 @@ static void __add_log_sample(struct io_log *iolog, unsigned long val,
                s = get_sample(iolog, cur_log, cur_log->nr_samples);
 
                s->val = val;
                s = get_sample(iolog, cur_log, cur_log->nr_samples);
 
                s->val = val;
-               s->time = t + iolog->td->unix_epoch;
+               s->time = t + (iolog->td ? iolog->td->unix_epoch : 0);
                io_sample_set_ddir(iolog, s, ddir);
                s->bs = bs;
 
                io_sample_set_ddir(iolog, s, ddir);
                s->bs = bs;