From 5961d92c4ac567103d5942e5a376047a85212b35 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 3 Nov 2005 15:56:17 +0100 Subject: [PATCH] [PATCH] fio: Remove jobs on command line It's a hassle to keep them in sync and the file version is a lot more flexible. --- README.fio | 17 ---- fio.c | 236 ++--------------------------------------------------- 2 files changed, 7 insertions(+), 246 deletions(-) diff --git a/README.fio b/README.fio index a284b0b..2b0f56b 100644 --- a/README.fio +++ b/README.fio @@ -20,8 +20,6 @@ $ fio -w Generate per-job bandwidth logs -f Read for job descriptions - - The format is as follows: rw=0/1 0 is read, 1 is write @@ -56,21 +54,6 @@ The format is as follows: loops=x Run the job 'x' number of times. -Examples using cmd line jobs ----------------------------- - -Spawn 2 threads, one read and one writer. Both threads want direct and -sequential io, set these as global options. The reader wants a 4kb block -size and the writer a 16kb block size, set those as thread options. - -$ fio -o1 -s "{rw=0,file=read_file,bs=4096}" "{rw=1,file=write_file,bs=16384}" - -Spawn 3 reader threads doing io at priorities 0, 3, and 6. The highest -prio thread wants direct io, the others buffered. All want a 4kb block -size. - -$ fio -o0 -s -b4096 "{rw=0,file=rf1,prio=6}" "{rw=0,file=rf2,prio=3}" "{rw=0,file=rf3,prio=0,direct=1}" - Examples using a job file ------------------------- diff --git a/fio.c b/fio.c index b7bdd18..8c94a54 100644 --- a/fio.c +++ b/fio.c @@ -1342,19 +1342,6 @@ static void fill_cpu_mask(cpu_set_t cpumask, int cpu) } } -static void fill_option(const char *input, char *output) -{ - int i; - - i = 0; - while (input[i] != ',' && input[i] != '}' && input[i] != '\0') { - output[i] = input[i]; - i++; - } - - output[i] = '\0'; -} - unsigned long get_mult(char c) { switch (c) { @@ -1395,217 +1382,6 @@ static int str_cnv(char *p, unsigned long long *val) return 0; } -/* - * job key words: - * - * file= - * bs= - * rw= - * direct= - */ -static void parse_jobs_cmd(int argc, char *argv[], int index) -{ - struct thread_data *td; - unsigned int prio, prioclass, cpu; - char *string, *filename, *p, *c; - int i; - - string = malloc(256); - filename = malloc(256); - - for (i = index; i < argc; i++) { - p = argv[i]; - - c = strpbrk(p, "{"); - if (!c) - break; - - filename[0] = 0; - - td = get_new_job(0); - if (!td) - break; - - prioclass = 2; - prio = 4; - - c = strstr(p, "rw="); - if (c) { - c += 3; - if (*c == '0') - td->ddir = DDIR_READ; - else - td->ddir = DDIR_WRITE; - } - - c = strstr(p, "prio="); - if (c) { - c += 5; - prio = *c - '0'; - } - - c = strstr(p, "prioclass="); - if (c) { - c += 10; - prioclass = *c - '0'; - } - - c = strstr(p, "file="); - if (c) { - c += 5; - fill_option(c, filename); - } - - c = strstr(p, "direct="); - if (c) { - c += 7; - if (*c != '0') - td->odirect = 1; - else - td->odirect = 0; - } - - c = strstr(p, "sync="); - if (c) { - c += 5; - if (*c != '0') - td->sync_io = 1; - else - td->sync_io = 0; - } - - c = strstr(p, "thinktime="); - if (c) { - c += 10; - fill_option(c, string); - td->thinktime = strtoul(string, NULL, 10); - } - - c = strstr(p, "rate="); - if (c) { - c += 5; - fill_option(c, string); - td->rate = strtoul(string, NULL, 10); - } - - c = strstr(p, "ratemin="); - if (c) { - c += 8; - fill_option(c, string); - td->ratemin = strtoul(string, NULL, 10); - } - - c = strstr(p, "ratecycle="); - if (c) { - c += 10; - fill_option(c, string); - td->ratecycle = strtoul(string, NULL, 10); - } - - c = strstr(p, "cpumask="); - if (c) { - c += 8; - fill_option(c, string); - cpu = strtoul(string, NULL, 10); - fill_cpu_mask(td->cpumask, cpu); - } - - c = strstr(p, "fsync="); - if (c) { - c += 6; - fill_option(c, string); - td->fsync_blocks = strtoul(string, NULL, 10); - } - - c = strstr(p, "startdelay="); - if (c) { - c += 11; - fill_option(c, string); - td->start_delay = strtoul(string, NULL, 10); - } - - c = strstr(p, "timeout="); - if (c) { - c += 8; - fill_option(c, string); - td->timeout = strtoul(string, NULL, 10); - } - - c = strstr(p, "invalidate="); - if (c) { - c += 11; - if (*c != '0') - td->invalidate_cache = 1; - else - td->invalidate_cache = 0; - } - - c = strstr(p, "bs="); - if (c) { - unsigned long long bs; - - c += 3; - str_cnv(c, &bs); - td->bs = bs; - } - - c = strstr(p, "size="); - if (c) { - c += 5; - str_cnv(c, &td->file_size); - } - - c = strstr(p, "offset="); - if (c) { - c += 7; - str_cnv(c, &td->file_offset); - } - - c = strstr(p, "aio_depth="); - if (c) { - c += 10; - fill_option(c, string); - td->aio_depth = strtoul(string, NULL, 10); - } - - c = strstr(p, "mem="); - if (c) { - c += 4; - if (!strncmp(c, "malloc", 6)) - td->mem_type = MEM_MALLOC; - else if (!strncmp(c, "shm", 3)) - td->mem_type = MEM_SHM; - else - printf("bad mem type %s\n", c); - } - - c = strstr(p, "aio"); - if (c) - td->use_aio = 1; - - c = strstr(p, "create"); - if (c) - td->create_file = 1; - - c = strstr(p, "overwrite"); - if (c) - td->overwrite = 1; - - c = strstr(p, "random"); - if (c) - td->sequential = 0; - c = strstr(p, "sequential"); - if (c) - td->sequential = 1; - - if (add_job(td, filename, prioclass, prio)) - put_job(td); - } - - free(string); - free(filename); -} - static int check_strcnv(char *p, char *name, unsigned long long *val) { if (!strstr(p, name)) @@ -2158,11 +1934,13 @@ int main(int argc, char *argv[]) i = parse_options(argc, argv); - if (ini_file) { - if (parse_jobs_ini(ini_file)) - return 1; - } else - parse_jobs_cmd(argc, argv, i); + if (!ini_file) { + printf("Need job file\n"); + return 1; + } + + if (parse_jobs_ini(ini_file)) + return 1; if (!thread_number) { printf("Nothing to do\n"); -- 2.25.1