X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=init.c;h=5d185fe7e7dbbe90d82462d76072063d33205f17;hb=e76b1da43606f86fc23c8acb63114cba0d80a1c7;hp=19c6340e2fa7d4e9a5b1e224d5f03c6651473e01;hpb=d3e829b399a44b6d6ce9596a05f7a4bff5025573;p=fio.git diff --git a/init.c b/init.c index 19c6340e..5d185fe7 100644 --- a/init.c +++ b/init.c @@ -19,6 +19,7 @@ #include "smalloc.h" #include "filehash.h" #include "verify.h" +#include "profile.h" static char fio_version_string[] = "fio 1.37"; @@ -38,6 +39,7 @@ unsigned long long mlock_size = 0; FILE *f_out = NULL; FILE *f_err = NULL; char *job_section = NULL; +char *exec_profile = NULL; int write_bw_log = 0; int read_only = 0; @@ -136,26 +138,6 @@ static struct option l_opts[FIO_NR_OPTIONS] = { }, }; -static const char *tiobench_opts[] = { - "buffered=0", "size=4*1024*$mb_memory", "bs=4k", "timeout=600", - "numjobs=4", "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", - "name=seqread", "stonewall", "rw=read", - "name=randread", "stonewall", "rw=randread", NULL, -}; - -static const char **fio_prof_strings[PROFILE_END] = { - NULL, - tiobench_opts, -}; - -static const char *profiles[PROFILE_END] = { - "none", - "tiobench", -}; - FILE *get_f_out() { return f_out; @@ -186,6 +168,8 @@ static struct thread_data *get_new_job(int global, struct thread_data *parent) dup_files(td, parent); options_mem_dupe(td); + profile_add_hooks(td); + td->thread_number = thread_number; return td; } @@ -194,6 +178,8 @@ static void put_job(struct thread_data *td) { if (td == &def_thread) return; + + profile_td_exit(td); if (td->error) log_info("fio: %s\n", td->verror); @@ -518,6 +504,9 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num) return 0; } + if (profile_td_init(td)) + return 1; + engine = get_engine_name(td->o.ioengine); td->io_ops = load_ioengine(td, engine); if (!td->io_ops) { @@ -655,6 +644,43 @@ err: return -1; } +/* + * Parse as if 'o' was a command line + */ +void add_job_opts(const char **o) +{ + struct thread_data *td, *td_parent; + int i, in_global = 1; + char jobname[32]; + + i = 0; + td_parent = td = NULL; + while (o[i]) { + if (!strncmp(o[i], "name", 4)) { + in_global = 0; + if (td) + add_job(td, jobname, 0); + td = NULL; + sprintf(jobname, "%s", o[i] + 5); + } + if (in_global && !td_parent) + td_parent = get_new_job(1, &def_thread); + else if (!in_global && !td) { + if (!td_parent) + td_parent = &def_thread; + td = get_new_job(0, td_parent); + } + if (in_global) + fio_options_parse(td_parent, (char **) &o[i], 1); + else + fio_options_parse(td, (char **) &o[i], 1); + i++; + } + + if (td) + add_job(td, jobname, 0); +} + static int skip_this_section(const char *name) { if (!job_section) @@ -961,6 +987,7 @@ struct debug_level debug_levels[] = { { .name = "diskutil", .shift = FD_DISKUTIL }, { .name = "job", .shift = FD_JOB }, { .name = "mutex", .shift = FD_MUTEX }, + { .name = "profile", .shift = FD_PROFILE }, { .name = NULL, }, }; @@ -1028,57 +1055,6 @@ static int set_debug(const char *string) } #endif -static int load_profile(const char *profile) -{ - struct thread_data *td, *td_parent; - const char **o; - int i, in_global = 1; - char jobname[32]; - - dprint(FD_PARSE, "loading profile %s\n", profile); - - for (i = 0; i < PROFILE_END; i++) { - if (!strcmp(profile, profiles[i])) - break; - } - - if (i == PROFILE_END) { - log_err("fio: unknown profile %s\n", profile); - return 1; - } - - o = fio_prof_strings[i]; - if (!o) - return 0; - - i = 0; - td_parent = td = NULL; - while (o[i]) { - if (!strncmp(o[i], "name", 4)) { - in_global = 0; - if (td) - add_job(td, jobname, 0); - td = NULL; - sprintf(jobname, "%s", o[i] + 5); - } - if (in_global && !td_parent) - td_parent = get_new_job(1, &def_thread); - else if (!in_global && !td) { - if (!td_parent) - td_parent = &def_thread; - td = get_new_job(0, td_parent); - } - if (in_global) - fio_options_parse(td_parent, (char **) &o[i], 1); - else - fio_options_parse(td, (char **) &o[i], 1); - i++; - } - if (td) - add_job(td, jobname, 0); - return 0; -} - static int parse_cmd_line(int argc, char *argv[]) { struct thread_data *td = NULL; @@ -1146,8 +1122,7 @@ static int parse_cmd_line(int argc, char *argv[]) job_section = strdup(optarg); break; case 'p': - if (load_profile(optarg)) - do_exit++; + exec_profile = strdup(optarg); break; case FIO_GETOPT_JOB: { const char *opt = l_opts[lidx].name; @@ -1236,6 +1211,8 @@ int parse_options(int argc, char *argv[]) if (!thread_number) { if (dump_cmdline) return 0; + if (exec_profile) + return 0; log_err("No jobs defined(s)\n\n"); usage(argv[0]);