X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=init.c;h=6c48d3ad8a9cd278b9dbf911a2436192f28a61aa;hp=7246bd83c268dacac75c6de94027227bb1e7fb72;hb=d10983d7;hpb=211c9b8948b43ed47aedf1227e0444a58db015e4 diff --git a/init.c b/init.c index 7246bd83..6c48d3ad 100644 --- a/init.c +++ b/init.c @@ -100,7 +100,7 @@ static struct option l_opts[FIO_NR_OPTIONS] = { }, { .name = (char *) "minimal", - .has_arg = optional_argument, + .has_arg = no_argument, .val = 'm' | FIO_CLIENT_FLAG, }, { @@ -629,6 +629,18 @@ static int fixup_options(struct thread_data *td) ret = 1; } + /* + * O_ATOMIC implies O_DIRECT + */ + if (td->o.oatomic) + td->o.odirect = 1; + + /* + * If randseed is set, that overrides randrepeat + */ + if (td->o.rand_seed) + td->o.rand_repeatable = 0; + return ret; } @@ -701,7 +713,10 @@ static void td_fill_rand_seeds_os(struct thread_data *td) td->rand_seeds[FIO_RAND_BLOCK_OFF] = FIO_RANDSEED * td->thread_number; os_random_seed(td->rand_seeds[FIO_RAND_BLOCK_OFF], &td->random_state); - os_random_seed(td->rand_seeds[FIO_RAND_SEQ_RAND_OFF], &td->seq_rand_state); + + os_random_seed(td->rand_seeds[FIO_RAND_SEQ_RAND_READ_OFF], &td->seq_rand_state[DDIR_READ]); + os_random_seed(td->rand_seeds[FIO_RAND_SEQ_RAND_WRITE_OFF], &td->seq_rand_state[DDIR_WRITE]); + os_random_seed(td->rand_seeds[FIO_RAND_SEQ_RAND_TRIM_OFF], &td->seq_rand_state[DDIR_TRIM]); } static void td_fill_rand_seeds_internal(struct thread_data *td) @@ -723,7 +738,9 @@ static void td_fill_rand_seeds_internal(struct thread_data *td) td->rand_seeds[FIO_RAND_BLOCK_OFF] = FIO_RANDSEED * td->thread_number; init_rand_seed(&td->__random_state, td->rand_seeds[FIO_RAND_BLOCK_OFF]); - init_rand_seed(&td->__seq_rand_state, td->rand_seeds[FIO_RAND_SEQ_RAND_OFF]); + init_rand_seed(&td->__seq_rand_state[DDIR_READ], td->rand_seeds[FIO_RAND_SEQ_RAND_READ_OFF]); + init_rand_seed(&td->__seq_rand_state[DDIR_WRITE], td->rand_seeds[FIO_RAND_SEQ_RAND_WRITE_OFF]); + init_rand_seed(&td->__seq_rand_state[DDIR_TRIM], td->rand_seeds[FIO_RAND_SEQ_RAND_TRIM_OFF]); } void td_fill_rand_seeds(struct thread_data *td) @@ -749,6 +766,10 @@ int ioengine_load(struct thread_data *td) */ if (td->io_ops) return 0; + if (!td->o.ioengine) { + log_err("fio: internal fault, no IO engine specified\n"); + return 1; + } engine = get_engine_name(td->o.ioengine); td->io_ops = load_ioengine(td, engine); @@ -815,10 +836,15 @@ static int setup_random_seeds(struct thread_data *td) unsigned long seed; unsigned int i; - if (!td->o.rand_repeatable) + if (!td->o.rand_repeatable && !td->o.rand_seed) return init_random_state(td, td->rand_seeds, sizeof(td->rand_seeds)); - for (seed = 0x89, i = 0; i < 4; i++) + if (!td->o.rand_seed) + seed = 0x89; + else + seed = td->o.rand_seed; + + for (i = 0; i < 4; i++) seed *= 0x9e370001UL; for (i = 0; i < FIO_RAND_NR_OFFS; i++) { @@ -906,6 +932,12 @@ static char *make_filename(char *buf, struct thread_options *o, return buf; } + +int parse_dryrun(void) +{ + return dump_cmdline || parse_only; +} + /* * Adds a job to the list of things todo. Sanitizes the various options * to make sure we don't have conflicts, and initializes various @@ -930,7 +962,7 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num, /* * if we are just dumping the output command line, don't add the job */ - if (dump_cmdline || parse_only) { + if (parse_dryrun()) { put_job(td); return 0; } @@ -1026,20 +1058,31 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num, fio_server_send_add_job(td); if (!(td->io_ops->flags & FIO_NOIO)) { - char *c1, *c2, *c3, *c4, *c5, *c6; + char *c1, *c2, *c3, *c4; + char *c5 = NULL, *c6 = NULL; c1 = fio_uint_to_kmg(o->min_bs[DDIR_READ]); c2 = fio_uint_to_kmg(o->max_bs[DDIR_READ]); c3 = fio_uint_to_kmg(o->min_bs[DDIR_WRITE]); c4 = fio_uint_to_kmg(o->max_bs[DDIR_WRITE]); - c5 = fio_uint_to_kmg(o->min_bs[DDIR_TRIM]); - c6 = fio_uint_to_kmg(o->max_bs[DDIR_TRIM]); - - log_info("%s: (g=%d): rw=%s, bs=%s-%s/%s-%s/%s-%s," - " ioengine=%s, iodepth=%u\n", - td->o.name, td->groupid, - ddir_str(o->td_ddir), - c1, c2, c3, c4, c5, c6, + + if (!o->bs_is_seq_rand) { + c5 = fio_uint_to_kmg(o->min_bs[DDIR_TRIM]); + c6 = fio_uint_to_kmg(o->max_bs[DDIR_TRIM]); + } + + log_info("%s: (g=%d): rw=%s, ", td->o.name, + td->groupid, + ddir_str(o->td_ddir)); + + if (o->bs_is_seq_rand) + log_info("bs(seq/rand)=%s-%s/%s-%s, ", + c1, c2, c3, c4); + else + log_info("bs=%s-%s/%s-%s/%s-%s, ", + c1, c2, c3, c4, c5, c6); + + log_info("ioengine=%s, iodepth=%u\n", td->io_ops->name, o->iodepth); free(c1); @@ -1114,9 +1157,9 @@ void add_job_opts(const char **o, int client_type) td = get_new_job(0, td_parent, 0); } if (in_global) - fio_options_parse(td_parent, (char **) &o[i], 1); + fio_options_parse(td_parent, (char **) &o[i], 1, 0); else - fio_options_parse(td, (char **) &o[i], 1); + fio_options_parse(td, (char **) &o[i], 1, 0); i++; } @@ -1253,7 +1296,7 @@ int parse_jobs_ini(char *file, int is_buf, int stonewall_flag, int type) } /* - * Seperate multiple job files by a stonewall + * Separate multiple job files by a stonewall */ if (!global && stonewall) { td->o.stonewall = stonewall; @@ -1297,14 +1340,10 @@ int parse_jobs_ini(char *file, int is_buf, int stonewall_flag, int type) num_opts++; } - ret = fio_options_parse(td, opts, num_opts); - if (!ret) { - if (dump_cmdline) - for (i = 0; i < num_opts; i++) - log_info("--%s ", opts[i]); - + ret = fio_options_parse(td, opts, num_opts, dump_cmdline); + if (!ret) ret = add_job(td, name, 0, 0, type); - } else { + else { log_err("fio: job %s dropped\n", name); put_job(td); } @@ -1354,7 +1393,7 @@ static void usage(const char *name) printf("%s [options] [job options] \n", name); printf(" --debug=options\tEnable debug logging. May be one/more of:\n" "\t\t\tprocess,file,io,mem,blktrace,verify,random,parse,\n" - "\t\t\tdiskutil,job,mutex,profile,time,net\n"); + "\t\t\tdiskutil,job,mutex,profile,time,net,rate\n"); printf(" --parse-only\t\tParse options only, don't start any IO\n"); printf(" --output\t\tWrite output to file\n"); printf(" --runtime\t\tRuntime in seconds\n"); @@ -1393,7 +1432,8 @@ static void usage(const char *name) "\t\t\t(option=system,percpu) or run unit work\n" "\t\t\tcalibration only (option=calibrate)\n"); printf("\nFio was written by Jens Axboe "); - printf("\n Jens Axboe \n"); + printf("\n Jens Axboe "); + printf("\n Jens Axboe \n"); } #ifdef FIO_INC_DEBUG @@ -1454,6 +1494,10 @@ struct debug_level debug_levels[] = { .help = "Network logging", .shift = FD_NET, }, + { .name = "rate", + .help = "Rate logging", + .shift = FD_RATE, + }, { .name = NULL, }, }; @@ -1608,6 +1652,12 @@ int parse_cmd_line(int argc, char *argv[], int client_type) output_format = FIO_OUTPUT_TERSE; break; case 'F': + if (!optarg) { + log_err("fio: missing --output-format argument\n"); + exit_val = 1; + do_exit++; + break; + } if (!strcmp(optarg, "minimal") || !strcmp(optarg, "terse") || !strcmp(optarg, "csv")) @@ -1725,9 +1775,20 @@ int parse_cmd_line(int argc, char *argv[], int client_type) fio_options_set_ioengine_opts(l_opts, td); } - ret = fio_cmd_option_parse(td, opt, val); - if (ret) + if ((!val || !strlen(val)) && + l_opts[lidx].has_arg == required_argument) { + log_err("fio: option %s requires an argument\n", opt); + ret = 1; + } else + ret = fio_cmd_option_parse(td, opt, val); + + if (ret) { + if (td) { + put_job(td); + td = NULL; + } do_exit++; + } if (!ret && !strcmp(opt, "ioengine")) { free_ioengine(td); @@ -1740,8 +1801,6 @@ int parse_cmd_line(int argc, char *argv[], int client_type) case FIO_GETOPT_IOENGINE: { const char *opt = l_opts[lidx].name; char *val = optarg; - opt = l_opts[lidx].name; - val = optarg; ret = fio_cmd_ioengine_option_parse(td, opt, val); break; } @@ -1833,10 +1892,8 @@ int parse_cmd_line(int argc, char *argv[], int client_type) break; } - if (do_exit) { - if (exit_val && !(is_backend || nr_clients)) - exit(exit_val); - } + if (do_exit && !(is_backend || nr_clients)) + exit(exit_val); if (nr_clients && fio_clients_connect()) { do_exit++; @@ -1917,7 +1974,7 @@ int parse_options(int argc, char *argv[]) fio_options_free(&def_thread); if (!thread_number) { - if (dump_cmdline || parse_only) + if (parse_dryrun()) return 0; if (exec_profile) return 0;