From: Jens Axboe Date: Thu, 4 Mar 2010 13:30:02 +0000 (+0100) Subject: More progress on per-profile options support X-Git-Tag: fio-1.38~37 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=2363d8df7c0c6fe0613dc8e7ae2fa6f098cbc0d8 More progress on per-profile options support Signed-off-by: Jens Axboe --- diff --git a/profile.c b/profile.c index 9f588a17..44e62699 100644 --- a/profile.c +++ b/profile.c @@ -22,7 +22,8 @@ int load_profile(const char *profile) } if (ops) { - add_job_opts(ops->def_ops); + ops->prep_cmd(); + add_job_opts(ops->cmdline); return 0; } diff --git a/profile.h b/profile.h index 5268d4ae..8ea77d9b 100644 --- a/profile.h +++ b/profile.h @@ -3,16 +3,25 @@ #include "flist.h" -#define FIO_PROFILE_VERSION 1 - struct profile_ops { struct flist_head list; char name[32]; - int version; int flags; - const char **def_ops; + /* + * Profile specific options + */ struct fio_option *options; + + /* + * Called after parsing options, to prepare 'cmdline' + */ + void (*prep_cmd)(void); + + /* + * The complete command line + */ + const char **cmdline; }; void register_profile(struct profile_ops *); diff --git a/profiles/tiobench.c b/profiles/tiobench.c index 873be994..4bdcfa24 100644 --- a/profiles/tiobench.c +++ b/profiles/tiobench.c @@ -2,14 +2,17 @@ #include "../profile.h" #include "../parse.h" -static unsigned long size; -static unsigned long loops; -static unsigned long bs; +static unsigned long long size; +static unsigned int loops = 1; +static unsigned int bs = 4096; +static unsigned int nthreads = 1; static char *dir; +char sz_idx[80], bs_idx[80], loop_idx[80], dir_idx[80], t_idx[80]; + static const char *tb_opts[] = { - "buffered=0", "size=4*1024*$mb_memory", "bs=4k", "timeout=600", - "numjobs=4", "group_reporting", "thread", "overwrite=1", + "buffered=0", sz_idx, bs_idx, loop_idx, dir_idx, t_idx, + "timeout=600", "group_reporting", "thread", "overwrite=1", "filename=.fio.tio.1:.fio.tio.2:.fio.tio.3:.fio.tio.4", "name=seqwrite", "rw=write", "end_fsync=1", "name=randwrite", "stonewall", "rw=randwrite", "end_fsync=1", @@ -20,7 +23,7 @@ static const char *tb_opts[] = { static struct fio_option options[] = { { .name = "size", - .type = FIO_OPT_INT, + .type = FIO_OPT_STR_VAL, .roff1 = &size, .help = "Size in MB", }, @@ -43,16 +46,48 @@ static struct fio_option options[] = { .roff1 = &dir, .help = "Test directory", }, + { + .name = "threads", + .type = FIO_OPT_INT, + .roff1 = &nthreads, + .help = "Number of Threads", + }, { .name = NULL, }, }; +/* + * Fill our private options into the command line + */ +static void tb_prep_cmdline(void) +{ + + /* + * tiobench uses size as MB, so multiply up + */ + size *= 1024 * 1024ULL; + if (size) + sprintf(sz_idx, "size=%llu", size); + else + strcpy(sz_idx, "size=4*1024*$mb_memory"); + + sprintf(bs_idx, "bs=%u", bs); + sprintf(loop_idx, "loops=%u", loops); + + if (dir) + sprintf(dir_idx, "directory=%s", dir); + else + sprintf(dir_idx, "directory=./"); + + sprintf(t_idx, "numjobs=%u", nthreads); +} + static struct profile_ops tiobench_profile = { .name = "tiobench", - .version = FIO_PROFILE_VERSION, - .def_ops = tb_opts, .options = options, + .prep_cmd = tb_prep_cmdline, + .cmdline = tb_opts, }; static void fio_init tiobench_register(void)