Add thread number to log filename
authorJens Axboe <axboe@fb.com>
Wed, 9 Jul 2014 08:31:34 +0000 (10:31 +0200)
committerJens Axboe <axboe@fb.com>
Wed, 9 Jul 2014 08:31:34 +0000 (10:31 +0200)
Since commit aee2ab6775d9, we open the log files for writing and
truncate the output. This breaks when you have multiple jobs with
the same name, as will happen with numjobs=x. Instead of reverting
this part of the commit, lets keep the truncate open and instead
store log files separately. This makes more sense anyway, since
otherwise the logs are all the entries from job X, then all the
entries from job Y, etc. It's easy enough to collate the logs,
should anyone want to do that.

Signed-off-by: Jens Axboe <axboe@fb.com>
HOWTO
fio.1
init.c

diff --git a/HOWTO b/HOWTO
index fbc455d44797dda6e779f561f1fe77178862583e..ac9606988b2c73b510823bf445300fcb92a67222 100644 (file)
--- a/HOWTO
+++ b/HOWTO
@@ -1307,7 +1307,9 @@ write_bw_log=str If given, write a bandwidth log of the jobs in this job
                jobs in their lifetime. The included fio_generate_plots
                script uses gnuplot to turn these text files into nice
                graphs. See write_lat_log for behaviour of given
-               filename. For this option, the suffix is _bw.log.
+               filename. For this option, the suffix is _bw.x.log, where
+               x is the index of the job (1..N, where N is the number of
+               jobs).
 
 write_lat_log=str Same as write_bw_log, except that this option stores io
                submission, completion, and total latencies instead. If no
@@ -1317,14 +1319,16 @@ write_lat_log=str Same as write_bw_log, except that this option stores io
 
                write_lat_log=foo
 
-               The actual log names will be foo_slat.log, foo_clat.log,
-               and foo_lat.log. This helps fio_generate_plot fine the logs
-               automatically.
+               The actual log names will be foo_slat.x.log, foo_clat.x.log,
+               and foo_lat.x.log, where x is the index of the job (1..N,
+               where N is the number of jobs). This helps fio_generate_plot
+               fine the logs automatically.
 
 write_iops_log=str Same as write_bw_log, but writes IOPS. If no filename is
                given with this option, the default filename of
-               "jobname_type.log" is used. Even if the filename is given,
-               fio will still append the type of log.
+               "jobname_type.x.log" is used,where x is the index of the job
+               (1..N, where N is the number of jobs). Even if the filename
+               is given, fio will still append the type of log.
 
 log_avg_msec=int By default, fio will log an entry in the iops, latency,
                or bw log for every IO that completes. When writing to the
diff --git a/fio.1 b/fio.1
index c58e81769d3585c09a808c057ed6a361ab034f3f..22d6b1e882d10b2a543fb88ddf657387b3b35d94 100644 (file)
--- a/fio.1
+++ b/fio.1
@@ -1191,17 +1191,21 @@ If given, write a bandwidth log of the jobs in this job file. Can be used to
 store data of the bandwidth of the jobs in their lifetime. The included
 fio_generate_plots script uses gnuplot to turn these text files into nice
 graphs. See \fBwrite_lat_log\fR for behaviour of given filename. For this
-option, the postfix is _bw.log.
+option, the postfix is _bw.x.log, where x is the index of the job (1..N,
+where N is the number of jobs)
 .TP
 .BI write_lat_log \fR=\fPstr
 Same as \fBwrite_bw_log\fR, but writes I/O completion latencies.  If no
-filename is given with this option, the default filename of "jobname_type.log"
-is used. Even if the filename is given, fio will still append the type of log.
+filename is given with this option, the default filename of
+"jobname_type.x.log" is used, where x is the index of the job (1..N, where
+N is the number of jobs). Even if the filename is given, fio will still
+append the type of log.
 .TP
 .BI write_iops_log \fR=\fPstr
 Same as \fBwrite_bw_log\fR, but writes IOPS. If no filename is given with this
-option, the default filename of "jobname_type.log" is used. Even if the
-filename is given, fio will still append the type of log.
+option, the default filename of "jobname_type.x.log" is used, where x is the
+index of the job (1..N, where N is the number of jobs). Even if the filename
+is given, fio will still append the type of log.
 .TP
 .BI log_avg_msec \fR=\fPint
 By default, fio will log an entry in the iops, latency, or bw log for every
diff --git a/init.c b/init.c
index 8268ed59e99668216fdee94a1a921ef0ae319bce..57aa702471acd65d9a12ec79064204fa1f87f40d 100644 (file)
--- a/init.c
+++ b/init.c
@@ -1167,14 +1167,14 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num,
                else
                        suf = "log";
 
-               snprintf(logname, sizeof(logname), "%s_lat.%s",
-                               o->lat_log_file, suf);
+               snprintf(logname, sizeof(logname), "%s_lat.%d.%s",
+                               o->lat_log_file, td->thread_number, suf);
                setup_log(&td->lat_log, &p, logname);
-               snprintf(logname, sizeof(logname), "%s_slat.%s",
-                               o->lat_log_file, suf);
+               snprintf(logname, sizeof(logname), "%s_slat.%d.%s",
+                               o->lat_log_file, td->thread_number, suf);
                setup_log(&td->slat_log, &p, logname);
-               snprintf(logname, sizeof(logname), "%s_clat.%s",
-                               o->lat_log_file, suf);
+               snprintf(logname, sizeof(logname), "%s_clat.%d.%s",
+                               o->lat_log_file, td->thread_number, suf);
                setup_log(&td->clat_log, &p, logname);
        }
        if (o->bw_log_file) {
@@ -1193,8 +1193,8 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num,
                else
                        suf = "log";
 
-               snprintf(logname, sizeof(logname), "%s_bw.%s",
-                               o->bw_log_file, suf);
+               snprintf(logname, sizeof(logname), "%s_bw.%d.%s",
+                               o->bw_log_file, td->thread_number, suf);
                setup_log(&td->bw_log, &p, logname);
        }
        if (o->iops_log_file) {
@@ -1213,8 +1213,8 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num,
                else
                        suf = "log";
 
-               snprintf(logname, sizeof(logname), "%s_iops.%s",
-                               o->iops_log_file, suf);
+               snprintf(logname, sizeof(logname), "%s_iops.%d.%s",
+                               o->iops_log_file, td->thread_number, suf);
                setup_log(&td->iops_log, &p, logname);
        }