X-Git-Url: https://git.kernel.dk/?a=blobdiff_plain;f=init.c;h=689c495b6ac648059a513c325d92620b7bd82beb;hb=75e6f36fae06978f29296fce76a7f00ca0df7b56;hp=e4f866a3bc883151372b9b9b3bfd528ee7477775;hpb=bb8895e07c6d6417410545f45d34b1b7916cd90a;p=fio.git diff --git a/init.c b/init.c index e4f866a3..689c495b 100644 --- a/init.c +++ b/init.c @@ -138,8 +138,18 @@ static struct fio_option options[] = { }, { .name = "bs", - .type = FIO_OPT_STR_VAL, - .off1 = td_var_offset(bs), + .type = FIO_OPT_STR_VAL_INT, + .off1 = td_var_offset(bs[DDIR_READ]), + }, + { + .name = "read_bs", + .type = FIO_OPT_STR_VAL_INT, + .off1 = td_var_offset(bs[DDIR_READ]), + }, + { + .name = "write_bs", + .type = FIO_OPT_STR_VAL_INT, + .off1 = td_var_offset(bs[DDIR_WRITE]), }, { .name = "offset", @@ -164,8 +174,20 @@ static struct fio_option options[] = { { .name = "bsrange", .type = FIO_OPT_RANGE, - .off1 = td_var_offset(min_bs), - .off2 = td_var_offset(max_bs), + .off1 = td_var_offset(min_bs[DDIR_READ]), + .off2 = td_var_offset(max_bs[DDIR_READ]), + }, + { + .name = "read_bsrange", + .type = FIO_OPT_RANGE, + .off1 = td_var_offset(min_bs[DDIR_READ]), + .off2 = td_var_offset(max_bs[DDIR_READ]), + }, + { + .name = "write_bsrange", + .type = FIO_OPT_RANGE, + .off1 = td_var_offset(min_bs[DDIR_WRITE]), + .off2 = td_var_offset(max_bs[DDIR_WRITE]), }, { .name = "nrfiles", @@ -348,6 +370,11 @@ static struct fio_option options[] = { .type = FIO_OPT_STR_SET, .off1 = td_var_offset(norandommap), }, + { + .name = "bs_unaligned", + .type = FIO_OPT_STR_SET, + .off1 = td_var_offset(bs_unaligned), + }, { .name = NULL, }, @@ -479,10 +506,19 @@ static void fixup_options(struct thread_data *td) if (td_read(td) || td_rw(td)) td->overwrite = 1; - if (!td->min_bs) - td->min_bs = td->bs; - if (!td->max_bs) - td->max_bs = td->bs; + if (td->bs[DDIR_READ] != DEF_BS) + td->bs[DDIR_WRITE] = td->bs[DDIR_READ]; + if (!td->min_bs[DDIR_READ]) + td->min_bs[DDIR_READ]= td->bs[DDIR_READ]; + if (!td->max_bs[DDIR_READ]) + td->max_bs[DDIR_READ] = td->bs[DDIR_READ]; + if (!td->min_bs[DDIR_WRITE]) + td->min_bs[DDIR_WRITE]= td->bs[DDIR_WRITE]; + if (!td->max_bs[DDIR_WRITE]) + td->max_bs[DDIR_WRITE] = td->bs[DDIR_WRITE]; + + td->rw_min_bs = min(td->min_bs[DDIR_READ], td->min_bs[DDIR_WRITE]); + if (td_read(td) && !td_rw(td)) td->verify = 0; @@ -490,6 +526,8 @@ static void fixup_options(struct thread_data *td) log_err("fio: norandommap given, verify disabled\n"); td->verify = VERIFY_NONE; } + if (td->bs_unaligned && (td->odirect || td->io_ops->flags & FIO_RAWIO)) + log_err("fio: bs_unaligned may not work with raw io\n"); } /* @@ -535,6 +573,9 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num) } } + if (td->odirect) + td->io_ops->flags |= FIO_RAWIO; + fixup_options(td); td->filetype = FIO_TYPE_FILE; @@ -545,9 +586,6 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num) td->filetype = FIO_TYPE_CHAR; } - if (td->odirect) - td->io_ops->flags |= FIO_RAWIO; - if (td->filename) td->nr_uniq_files = 1; else @@ -619,7 +657,7 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num) if (td->io_ops->flags & FIO_CPUIO) fprintf(f_out, "%s: ioengine=cpu, cpuload=%u, cpucycle=%u\n", td->name, td->cpuload, td->cpucycle); else - fprintf(f_out, "%s: (g=%d): rw=%s, odir=%d, bs=%d-%d, rate=%d, ioengine=%s, iodepth=%d\n", td->name, td->groupid, ddir_str[ddir], td->odirect, td->min_bs, td->max_bs, td->rate, td->io_ops->name, td->iodepth); + fprintf(f_out, "%s: (g=%d): rw=%s, odir=%d, bs=%d-%d/%d-%d, rate=%d, ioengine=%s, iodepth=%d\n", td->name, td->groupid, ddir_str[ddir], td->odirect, td->min_bs[DDIR_READ], td->max_bs[DDIR_READ], td->min_bs[DDIR_WRITE], td->max_bs[DDIR_WRITE], td->rate, td->io_ops->name, td->iodepth); } else if (job_add_num == 1) fprintf(f_out, "...\n"); } @@ -687,8 +725,8 @@ int init_random_state(struct thread_data *td) if (!td->norandommap) { for_each_file(td, f, i) { - blocks = (f->file_size + td->min_bs - 1) / td->min_bs; - num_maps = blocks / BLOCKS_PER_MAP; + blocks = (f->file_size + td->rw_min_bs - 1) / td->rw_min_bs; + num_maps = (blocks + BLOCKS_PER_MAP-1)/ BLOCKS_PER_MAP; f->file_map = malloc(num_maps * sizeof(long)); f->num_maps = num_maps; memset(f->file_map, 0, num_maps * sizeof(long)); @@ -925,6 +963,9 @@ int parse_jobs_ini(char *file, int stonewall_flag) if (!ret) { fsetpos(f, &off); ret = add_job(td, name, 0); + } else { + log_err("fio: job %s dropped\n", name); + put_job(td); } } while (!ret); @@ -948,9 +989,10 @@ static int fill_def_thread(void) */ def_thread.ddir = DDIR_READ; def_thread.iomix = 0; - def_thread.bs = DEF_BS; - def_thread.min_bs = 0; - def_thread.max_bs = 0; + def_thread.bs[DDIR_READ] = DEF_BS; + def_thread.bs[DDIR_WRITE] = DEF_BS; + def_thread.min_bs[DDIR_READ] = def_thread.min_bs[DDIR_WRITE] = 0; + def_thread.max_bs[DDIR_READ] = def_thread.max_bs[DDIR_WRITE] = 0; def_thread.odirect = DEF_ODIRECT; def_thread.ratecycle = DEF_RATE_CYCLE; def_thread.sequential = DEF_SEQUENTIAL; @@ -1047,7 +1089,12 @@ static int parse_cmd_line(int argc, char *argv[]) return 0; } - parse_cmd_option(opt, val, options, td); + ret = parse_cmd_option(opt, val, options, td); + if (ret) { + log_err("fio: job dropped\n"); + put_job(td); + td = NULL; + } break; } default: @@ -1177,7 +1224,6 @@ int parse_options(int argc, char *argv[]) if (!thread_number) { log_err("No jobs defined(s)\n"); - usage(); return 1; }