From c2b1e753ca7abaca7f177cb1ca5087ca3971542b Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Mon, 30 Oct 2006 09:03:13 +0100 Subject: [PATCH] [PATCH] Add support for multiple jobs on the command line Give --name the special meaning of starting a new job (and adding the previous). Now the command line is just as powerful as the job files. Signed-off-by: Jens Axboe --- HOWTO | 18 +++++++++++++++--- init.c | 22 +++++++++++++--------- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/HOWTO b/HOWTO index 3f4a6675..ae19834f 100644 --- a/HOWTO +++ b/HOWTO @@ -86,7 +86,13 @@ If the job file contains only one job, you may as well just give the parameters on the command line. The command line parameters are identical to the job parameters, with a few extra that control global parameters (see README). For example, for the job file parameter iodepth=2, the -mirror command line option would be --iodepth 2 or --iodepth=2. +mirror command line option would be --iodepth 2 or --iodepth=2. You can +also use the command line for giving more than one job entry. For each +--name option that fio sees, it will start a new job with that name. +Command line entries following a --name entry will apply to that job, +until there are no more entries or a new --name entry is seen. This is +similar to the job file options, where each option applies to the current +job until a new [] job entry is seen. fio does not need to run as root, except if the files or devices specified in the job section requires that. Some other options may also be restricted, @@ -121,7 +127,11 @@ size=128m As you can see, the job file sections themselves are empty as all the described parameters are shared. As no filename= option is given, fio -makes up a filename for each of the jobs as it sees fit. +makes up a filename for each of the jobs as it sees fit. On the command +line, this job would look as follows: + +$ fio --name=global --rw=randread --size=128m --name=job1 --name=job2 + Lets look at an example that have a number of processes writing randomly to files. @@ -176,7 +186,9 @@ parameters. name=str ASCII name of the job. This may be used to override the name printed by fio for this job. Otherwise the job - name is used. + name is used. On the command line this parameter has the + special purpose of also signalling the start of a new + job. directory=str Prefix filenames with this directory. Used to places files in a different location than "./". diff --git a/init.c b/init.c index c799bf5f..20ea2676 100644 --- a/init.c +++ b/init.c @@ -985,7 +985,7 @@ static void usage(void) static int parse_cmd_line(int argc, char *argv[]) { struct thread_data *td = NULL; - int c, ini_idx = 0, lidx; + int c, ini_idx = 0, lidx, ret; while ((c = getopt_long(argc, argv, "", long_options, &lidx)) != -1) { switch (c) { @@ -1019,8 +1019,18 @@ static int parse_cmd_line(int argc, char *argv[]) const char *opt = long_options[lidx].name; char *val = optarg; + if (!strncmp(opt, "name", 4) && td) { + ret = add_job(td, td->name ?: "fio", 0); + if (ret) { + put_job(td); + return 0; + } + td = NULL; + } if (!td) { - td = get_new_job(0, &def_thread); + int global = !strncmp(opt, "global", 6); + + td = get_new_job(global, &def_thread); if (!td) return 0; } @@ -1035,13 +1045,7 @@ static int parse_cmd_line(int argc, char *argv[]) } if (td) { - const char *name = td->name; - int ret; - - if (!name) - name = "fio"; - - ret = add_job(td, name, 0); + ret = add_job(td, td->name ?: "fio", 0); if (ret) put_job(td); } -- 2.25.1