X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=init.c;h=5630c9fb3e821708b6bb8552cd5a3111834c82fb;hp=c2725261ad8481ee923de2fb5b6e3ac524868e03;hb=e916b390684ec1ca6247f98138fa9c1682701d29;hpb=03b74b3ec5268e731ed7fcaef31c8c0655acd530 diff --git a/init.c b/init.c index c2725261..5630c9fb 100644 --- a/init.c +++ b/init.c @@ -41,6 +41,12 @@ static int str_cpumask_cb(void *, unsigned int *); * Map of job/command line options */ static struct fio_option options[] = { + { + .name = "description", + .type = FIO_OPT_STR_STORE, + .off1 = td_var_offset(description), + .help = "Text job description", + }, { .name = "name", .type = FIO_OPT_STR_STORE, @@ -75,7 +81,7 @@ static struct fio_option options[] = { .help = "IO engine to use", .def = "sync", .posval = { "sync", "libaio", "posixaio", "mmap", "splice", - "sg", "null", }, + "sg", "null", "net", "syslet-rw" }, }, { .name = "iodepth", @@ -84,6 +90,12 @@ static struct fio_option options[] = { .help = "Amount of IO buffers to keep in flight", .def = "1", }, + { + .name = "iodepth_low", + .type = FIO_OPT_INT, + .off1 = td_var_offset(iodepth_low), + .help = "Low water mark for queuing depth", + }, { .name = "size", .type = FIO_OPT_STR_VAL, @@ -151,7 +163,15 @@ static struct fio_option options[] = { .name = "direct", .type = FIO_OPT_BOOL, .off1 = td_var_offset(odirect), - .help = "Use O_DIRECT IO", + .help = "Use O_DIRECT IO (negates buffered)", + .def = "0", + }, + { + .name = "buffered", + .type = FIO_OPT_BOOL, + .off1 = td_var_offset(odirect), + .neg = 1, + .help = "Use buffered IO (negates direct)", .def = "1", }, { @@ -313,7 +333,14 @@ static struct fio_option options[] = { .name = "thinktime", .type = FIO_OPT_INT, .off1 = td_var_offset(thinktime), - .help = "Idle time between IO buffers", + .help = "Idle time between IO buffers (usec)", + .def = "0", + }, + { + .name = "thinktime_spin", + .type = FIO_OPT_INT, + .off1 = td_var_offset(thinktime_spin), + .help = "Start thinktime by spinning this amount (usec)", .def = "0", }, { @@ -409,7 +436,7 @@ static struct fio_option options[] = { .type = FIO_OPT_BOOL, .off1 = td_var_offset(unlink), .help = "Unlink created files after job has completed", - .def = "1", + .def = "0", }, { .name = "exitall", @@ -524,7 +551,7 @@ FILE *f_out = NULL; FILE *f_err = NULL; static int write_lat_log = 0; -static int write_bw_log = 0; +int write_bw_log = 0; /* * Return a free job structure. @@ -550,6 +577,9 @@ static void put_job(struct thread_data *td) if (td == &def_thread) return; + if (td->error) + fprintf(f_out, "fio: %s\n", td->verror); + memset(&threads[td->thread_number - 1], 0, sizeof(*td)); thread_number--; } @@ -614,6 +644,20 @@ static void fixup_options(struct thread_data *td) */ if (td->filetype == FIO_TYPE_CHAR && td->odirect) td->odirect = 0; + + /* + * thinktime_spin must be less than thinktime + */ + if (td->thinktime_spin > td->thinktime) + td->thinktime_spin = td->thinktime; + + /* + * The low water mark cannot be bigger than the iodepth + */ + if (td->iodepth_low > td->iodepth || !td->iodepth_low) + td->iodepth_low = td->iodepth; + + printf("io depth %d/%d\n", td->iodepth_low, td->iodepth); } /* @@ -622,7 +666,7 @@ static void fixup_options(struct thread_data *td) static char *to_kmg(unsigned int val) { char *buf = malloc(32); - char post[] = { 0, 'K', 'M', 'G', 'P', 0 }; + char post[] = { 0, 'K', 'M', 'G', 'P', 'E', 0 }; char *p = post; do { @@ -662,7 +706,7 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num) td->io_ops->flags |= FIO_RAWIO; td->filetype = FIO_TYPE_FILE; - if (!stat(jobname, &sb)) { + if (td->filename && !lstat(td->filename, &sb)) { if (S_ISBLK(sb.st_mode)) td->filetype = FIO_TYPE_BD; else if (S_ISCHR(sb.st_mode)) @@ -680,8 +724,18 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num) char tmp[PATH_MAX]; int len = 0; - if (td->directory && td->directory[0] != '\0') + if (td->directory && td->directory[0] != '\0') { + if (lstat(td->directory, &sb) < 0) { + log_err("fio: %s is not a directory\n", td->directory); + td_verror(td, errno); + return 1; + } + if (!S_ISDIR(sb.st_mode)) { + log_err("fio: %s is not a directory\n", td->directory); + return 1; + } len = sprintf(tmp, "%s/", td->directory); + } td->files = malloc(sizeof(struct fio_file) * td->nr_files); @@ -712,9 +766,9 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num) fio_sem_init(&td->mutex, 0); - td->clat_stat[0].min_val = td->clat_stat[1].min_val = ULONG_MAX; - td->slat_stat[0].min_val = td->slat_stat[1].min_val = ULONG_MAX; - td->bw_stat[0].min_val = td->bw_stat[1].min_val = ULONG_MAX; + td->ts.clat_stat[0].min_val = td->ts.clat_stat[1].min_val = ULONG_MAX; + td->ts.slat_stat[0].min_val = td->ts.slat_stat[1].min_val = ULONG_MAX; + td->ts.bw_stat[0].min_val = td->ts.bw_stat[1].min_val = ULONG_MAX; if (td->stonewall && td->thread_number > 1) groupid++; @@ -725,11 +779,11 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num) goto err; if (td->write_lat_log) { - setup_log(&td->slat_log); - setup_log(&td->clat_log); + setup_log(&td->ts.slat_log); + setup_log(&td->ts.clat_log); } if (td->write_bw_log) - setup_log(&td->bw_log); + setup_log(&td->ts.bw_log); if (!td->name) td->name = strdup(jobname); @@ -748,7 +802,7 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num) 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); + fprintf(f_out, "%s: (g=%d): rw=%s, bs=%s-%s/%s-%s, ioengine=%s, iodepth=%u\n", td->name, td->groupid, ddir_str[ddir], c1, c2, c3, c4, td->io_ops->name, td->iodepth); free(c1); free(c2); @@ -818,11 +872,11 @@ int init_random_state(struct thread_data *td) return 0; if (td->rand_repeatable) - seeds[3] = FIO_RANDSEED; + seeds[3] = FIO_RANDSEED * td->thread_number; if (!td->norandommap) { for_each_file(td, f, i) { - blocks = (f->file_size + td->rw_min_bs - 1) / td->rw_min_bs; + blocks = (f->real_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; @@ -855,6 +909,8 @@ static int is_empty_or_comment(char *line) for (i = 0; i < strlen(line); i++) { if (line[i] == ';') return 1; + if (line[i] == '#') + return 1; if (!isspace(line[i]) && !iscntrl(line[i])) return 0; }