From e3cedca76d9fc104eb4f6f869606fb5bf4c0d59c Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 19 Nov 2008 19:57:52 +0100 Subject: [PATCH] Add support for giving bw/clat/slat log prefixes Signed-off-by: Jens Axboe --- HOWTO | 17 +++++++++++++---- fio.c | 24 ++++++++++++++++++------ fio.h | 3 +++ log.c | 10 ++++++++-- options.c | 28 ++++++++++++++++++++++++++-- parse.c | 2 +- 6 files changed, 69 insertions(+), 15 deletions(-) diff --git a/HOWTO b/HOWTO index f4efd281..4298f324 100644 --- a/HOWTO +++ b/HOWTO @@ -804,14 +804,23 @@ read_iolog=str Open an iolog with the specified file name and replay the the file needs to be turned into a blkparse binary data file first (blktrace -d file_for_fio.bin). -write_bw_log If given, write a bandwidth log of the jobs in this job +write_bw_log=str 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. + graphs. See write_log_log for behaviour of given + filename. For this option, the postfix is _bw.log. -write_lat_log Same as write_bw_log, except that this option stores io - completion latencies instead. +write_lat_log=str Same as write_bw_log, except that this option stores io + completion latencies instead. 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. So if one specifies + + write_lat_log=foo + + The actual log names will be foo_clat.log and foo_slat.log. + This helps fio_generate_plot fine the logs automatically. lockmem=siint Pin down the specified amount of memory with mlock(2). Can potentially be used instead of removing memory or booting diff --git a/fio.c b/fio.c index 2aa8b401..5a87ae4b 100644 --- a/fio.c +++ b/fio.c @@ -1066,12 +1066,24 @@ static void *thread_main(void *data) td->ts.io_bytes[0] = td->io_bytes[0]; td->ts.io_bytes[1] = td->io_bytes[1]; - if (td->ts.bw_log) - finish_log(td, td->ts.bw_log, "bw"); - if (td->ts.slat_log) - finish_log(td, td->ts.slat_log, "slat"); - if (td->ts.clat_log) - finish_log(td, td->ts.clat_log, "clat"); + if (td->ts.bw_log) { + if (td->o.bw_log_file) + finish_log_named(td, td->ts.bw_log, td->o.bw_log_file, "bw"); + else + finish_log(td, td->ts.bw_log, "bw"); + } + if (td->ts.slat_log) { + if (td->o.lat_log_file) + finish_log_named(td, td->ts.slat_log, td->o.lat_log_file, "clat"); + else + finish_log(td, td->ts.slat_log, "slat"); + } + if (td->ts.clat_log) { + if (td->o.lat_log_file) + finish_log_named(td, td->ts.clat_log, td->o.lat_log_file, "clat"); + else + finish_log(td, td->ts.clat_log, "clat"); + } if (td->o.exec_postrun) { if (system(td->o.exec_postrun) < 0) log_err("fio: postrun %s failed\n", td->o.exec_postrun); diff --git a/fio.h b/fio.h index 3e39aeae..f8e6a4a0 100644 --- a/fio.h +++ b/fio.h @@ -503,6 +503,8 @@ struct thread_options { char *read_iolog_file; char *write_iolog_file; + char *bw_log_file; + char *lat_log_file; /* * Pre-run and post-run shell @@ -806,6 +808,7 @@ extern void update_rusage_stat(struct thread_data *); extern void update_io_ticks(void); extern void setup_log(struct io_log **); extern void finish_log(struct thread_data *, struct io_log *, const char *); +extern void finish_log_named(struct thread_data *, struct io_log *, const char *, const char *); extern void __finish_log(struct io_log *, const char *); extern struct io_log *agg_io_log[2]; extern int write_bw_log; diff --git a/log.c b/log.c index 5c468ad9..611aa9f9 100644 --- a/log.c +++ b/log.c @@ -471,11 +471,17 @@ void __finish_log(struct io_log *log, const char *name) free(log); } -void finish_log(struct thread_data *td, struct io_log *log, const char *name) +void finish_log_named(struct thread_data *td, struct io_log *log, + const char *prefix, const char *postfix) { char file_name[256], *p; - snprintf(file_name, 200, "%s_%s.log", td->o.name, name); + snprintf(file_name, 200, "%s_%s.log", prefix, postfix); p = basename(file_name); __finish_log(log, p); } + +void finish_log(struct thread_data *td, struct io_log *log, const char *name) +{ + finish_log_named(td, log, td->o.name, name); +} diff --git a/options.c b/options.c index 3d27f255..b890420f 100644 --- a/options.c +++ b/options.c @@ -438,6 +438,28 @@ static int str_lockfile_cb(void *data, const char *str) return 0; } +static int str_write_bw_log_cb(void *data, const char *str) +{ + struct thread_data *td = data; + + if (str) + td->o.bw_log_file = strdup(str); + + td->o.write_bw_log = 1; + return 0; +} + +static int str_write_lat_log_cb(void *data, const char *str) +{ + struct thread_data *td = data; + + if (str) + td->o.lat_log_file = strdup(str); + + td->o.write_lat_log = 1; + return 0; +} + static int str_gtod_reduce_cb(void *data, int *il) { struct thread_data *td = data; @@ -1266,14 +1288,16 @@ static struct fio_option options[] = { }, { .name = "write_bw_log", - .type = FIO_OPT_STR_SET, + .type = FIO_OPT_STR, .off1 = td_var_offset(write_bw_log), + .cb = str_write_bw_log_cb, .help = "Write log of bandwidth during run", }, { .name = "write_lat_log", - .type = FIO_OPT_STR_SET, + .type = FIO_OPT_STR, .off1 = td_var_offset(write_lat_log), + .cb = str_write_lat_log_cb, .help = "Write log of latency during run", }, { diff --git a/parse.c b/parse.c index 8a2e6f21..44c02f60 100644 --- a/parse.c +++ b/parse.c @@ -236,7 +236,7 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data, dprint(FD_PARSE, "__handle_option=%s, type=%d, ptr=%s\n", o->name, o->type, ptr); - if (!ptr && o->type != FIO_OPT_STR_SET) { + if (!ptr && o->type != FIO_OPT_STR_SET && o->type != FIO_OPT_STR) { fprintf(stderr, "Option %s requires an argument\n", o->name); return 1; } -- 2.25.1