X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=init.c;h=ae960302f70a5695b08854198776a6553f1a609b;hp=7b2b5121f193bf17bacc228fddaeb6953ec8b364;hb=178d11f29ffc50c46d907129ee81c3b41f48c926;hpb=c06aa240c904becbafb8457ed3b828cf0d38a180 diff --git a/init.c b/init.c index 7b2b5121..ae960302 100644 --- a/init.c +++ b/init.c @@ -29,7 +29,7 @@ #define DEF_IO_ENGINE_NAME "sync" #define DEF_SEQUENTIAL (1) #define DEF_RAND_REPEAT (1) -#define DEF_OVERWRITE (1) +#define DEF_OVERWRITE (0) #define DEF_INVALIDATE (1) #define DEF_SYNCIO (0) #define DEF_RANDSEED (0xb1899bedUL) @@ -48,7 +48,7 @@ #define DEF_RWMIX_READ (50) #define DEF_NICE (0) #define DEF_NR_FILES (1) -#define DEF_UNLINK (0) +#define DEF_UNLINK (1) #define DEF_WRITE_BW_LOG (0) #define DEF_WRITE_LAT_LOG (0) #define DEF_NO_RAND_MAP (0) @@ -60,8 +60,10 @@ static int str_ioengine_cb(void *, const char *); static int str_mem_cb(void *, const char *); static int str_verify_cb(void *, const char *); static int str_lockmem_cb(void *, unsigned long *); +#ifdef FIO_HAVE_IOPRIO static int str_prio_cb(void *, unsigned int *); static int str_prioclass_cb(void *, unsigned int *); +#endif static int str_exitall_cb(void); static int str_cpumask_cb(void *, unsigned int *); @@ -140,16 +142,7 @@ static struct fio_option options[] = { .name = "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]), + .off2 = td_var_offset(bs[DDIR_WRITE]), }, { .name = "offset", @@ -176,18 +169,8 @@ static struct fio_option options[] = { .type = FIO_OPT_RANGE, .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]), + .off3 = td_var_offset(min_bs[DDIR_WRITE]), + .off4 = td_var_offset(max_bs[DDIR_WRITE]), }, { .name = "nrfiles", @@ -426,7 +409,7 @@ static struct option long_options[FIO_JOB_OPTS + FIO_CMD_OPTS] = { static int def_timeout = DEF_TIMEOUT; -static char fio_version_string[] = "fio 1.7"; +static char fio_version_string[] = "fio 1.9"; static char **ini_file; static int max_jobs = MAX_JOBS; @@ -434,7 +417,6 @@ static int max_jobs = MAX_JOBS; struct thread_data def_thread; struct thread_data *threads = NULL; -int rate_quit = 0; int exitall_on_terminate = 0; int terse_output = 0; unsigned long long mlock_size = 0; @@ -506,8 +488,6 @@ static void fixup_options(struct thread_data *td) if (td_read(td) || td_rw(td)) td->overwrite = 1; - 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]) @@ -530,6 +510,27 @@ static void fixup_options(struct thread_data *td) log_err("fio: bs_unaligned may not work with raw io\n"); } +/* + * This function leaks the buffer + */ +static char *to_kmg(unsigned int val) +{ + char *buf = malloc(32); + char post[] = { 0, 'K', 'M', 'G', 'P', 0 }; + char *p = post; + + do { + if (val & 1023) + break; + + val >>= 10; + p++; + } while (*p); + + snprintf(buf, 31, "%u%c", val, *p); + return buf; +} + /* * Adds a job to the list of things todo. Sanitizes the various options * to make sure we don't have conflicts, and initializes various @@ -537,8 +538,8 @@ static void fixup_options(struct thread_data *td) */ static int add_job(struct thread_data *td, const char *jobname, int job_add_num) { - char *ddir_str[] = { "read", "write", "randread", "randwrite", - "rw", NULL, "randrw" }; + const char *ddir_str[] = { "read", "write", "randread", "randwrite", + "rw", NULL, "randrw" }; struct stat sb; int numjobs, ddir, i; struct fio_file *f; @@ -581,7 +582,6 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num) if (td->filetype == FIO_TYPE_FILE || td->filename) { char tmp[PATH_MAX]; int len = 0; - int i; if (td->directory && td->directory[0] != '\0') sprintf(tmp, "%s/", td->directory); @@ -643,8 +643,21 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num) if (!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/%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 { + char *c1, *c2, *c3, *c4; + + c1 = to_kmg(td->min_bs[DDIR_READ]); + c2 = to_kmg(td->max_bs[DDIR_READ]); + c3 = to_kmg(td->min_bs[DDIR_WRITE]); + c4 = to_kmg(td->max_bs[DDIR_WRITE]); + + fprintf(f_out, "%s: (g=%d): rw=%s, odir=%u, bs=%s-%s/%s-%s, rate=%u, ioengine=%s, iodepth=%u\n", td->name, td->groupid, ddir_str[ddir], td->odirect, c1, c2, c3, c4, td->rate, td->io_ops->name, td->iodepth); + + free(c1); + free(c2); + free(c3); + free(c4); + } } else if (job_add_num == 1) fprintf(f_out, "...\n"); } @@ -773,12 +786,12 @@ static int str_rw_cb(void *data, const char *mem) td->sequential = 0; return 0; } else if (!strncmp(mem, "rw", 2)) { - td->ddir = 0; + td->ddir = DDIR_READ; td->iomix = 1; td->sequential = 1; return 0; } else if (!strncmp(mem, "randrw", 6)) { - td->ddir = 0; + td->ddir = DDIR_READ; td->iomix = 1; td->sequential = 0; return 0; @@ -834,7 +847,8 @@ static int str_ioengine_cb(void *data, const char *str) if (td->io_ops) return 0; - log_err("fio: ioengine: { linuxaio, aio, libaio }, posixaio, sync, mmap, sgio, splice, cpu\n"); + log_err("fio: ioengine= libaio, posixaio, sync, mmap, sgio, splice, cpu, null\n"); + log_err("fio: or specify path to dynamic ioengine module\n"); return 1; } @@ -844,6 +858,7 @@ static int str_lockmem_cb(void fio_unused *data, unsigned long *val) return 0; } +#ifdef FIO_HAVE_IOPRIO static int str_prioclass_cb(void *data, unsigned int *val) { struct thread_data *td = data; @@ -859,6 +874,7 @@ static int str_prio_cb(void *data, unsigned int *val) td->ioprio |= *val; return 0; } +#endif static int str_exitall_cb(void) { @@ -877,7 +893,7 @@ static int str_cpumask_cb(void *data, unsigned int *val) /* * This is our [ini] type file parser. */ -int parse_jobs_ini(char *file, int stonewall_flag) +static int parse_jobs_ini(char *file, int stonewall_flag) { unsigned int global; struct thread_data *td;