18 #include "crc/crc32c.h"
21 * Check if mmap/mmaphuge has a :/foo/bar/file at the end. If so, return that.
23 static char *get_opt_postfix(const char *str)
25 char *p = strstr(str, ":");
31 strip_blank_front(&p);
36 static int converthexchartoint(char a)
56 static int bs_cmp(const void *p1, const void *p2)
58 const struct bssplit *bsp1 = p1;
59 const struct bssplit *bsp2 = p2;
61 return bsp1->perc < bsp2->perc;
64 static int bssplit_ddir(struct thread_data *td, int ddir, char *str)
66 struct bssplit *bssplit;
67 unsigned int i, perc, perc_missing;
68 unsigned int max_bs, min_bs;
72 td->o.bssplit_nr[ddir] = 4;
73 bssplit = malloc(4 * sizeof(struct bssplit));
78 while ((fname = strsep(&str, ":")) != NULL) {
85 * grow struct buffer, if needed
87 if (i == td->o.bssplit_nr[ddir]) {
88 td->o.bssplit_nr[ddir] <<= 1;
89 bssplit = realloc(bssplit, td->o.bssplit_nr[ddir]
90 * sizeof(struct bssplit));
93 perc_str = strstr(fname, "/");
97 perc = atoi(perc_str);
105 if (str_to_decimal(fname, &val, 1, td)) {
106 log_err("fio: bssplit conversion failed\n");
117 bssplit[i].perc = perc;
121 td->o.bssplit_nr[ddir] = i;
124 * Now check if the percentages add up, and how much is missing
126 perc = perc_missing = 0;
127 for (i = 0; i < td->o.bssplit_nr[ddir]; i++) {
128 struct bssplit *bsp = &bssplit[i];
130 if (bsp->perc == (unsigned char) -1)
137 log_err("fio: bssplit percentages add to more than 100%%\n");
142 * If values didn't have a percentage set, divide the remains between
146 for (i = 0; i < td->o.bssplit_nr[ddir]; i++) {
147 struct bssplit *bsp = &bssplit[i];
149 if (bsp->perc == (unsigned char) -1)
150 bsp->perc = (100 - perc) / perc_missing;
154 td->o.min_bs[ddir] = min_bs;
155 td->o.max_bs[ddir] = max_bs;
158 * now sort based on percentages, for ease of lookup
160 qsort(bssplit, td->o.bssplit_nr[ddir], sizeof(struct bssplit), bs_cmp);
161 td->o.bssplit[ddir] = bssplit;
166 static int str_bssplit_cb(void *data, const char *input)
168 struct thread_data *td = data;
169 char *str, *p, *odir, *ddir;
172 p = str = strdup(input);
174 strip_blank_front(&str);
175 strip_blank_end(str);
177 odir = strchr(str, ',');
179 ddir = strchr(odir + 1, ',');
181 ret = bssplit_ddir(td, DDIR_TRIM, ddir + 1);
187 op = strdup(odir + 1);
188 ret = bssplit_ddir(td, DDIR_TRIM, op);
193 ret = bssplit_ddir(td, DDIR_WRITE, odir + 1);
196 ret = bssplit_ddir(td, DDIR_READ, str);
202 ret = bssplit_ddir(td, DDIR_WRITE, op);
207 ret = bssplit_ddir(td, DDIR_TRIM, op);
210 ret = bssplit_ddir(td, DDIR_READ, str);
217 static int str2error(char *str)
219 const char * err[] = {"EPERM", "ENOENT", "ESRCH", "EINTR", "EIO",
220 "ENXIO", "E2BIG", "ENOEXEC", "EBADF",
221 "ECHILD", "EAGAIN", "ENOMEM", "EACCES",
222 "EFAULT", "ENOTBLK", "EBUSY", "EEXIST",
223 "EXDEV", "ENODEV", "ENOTDIR", "EISDIR",
224 "EINVAL", "ENFILE", "EMFILE", "ENOTTY",
225 "ETXTBSY","EFBIG", "ENOSPC", "ESPIPE",
226 "EROFS","EMLINK", "EPIPE", "EDOM", "ERANGE"};
227 int i = 0, num = sizeof(err) / sizeof(void *);
230 if (!strcmp(err[i], str))
237 static int ignore_error_type(struct thread_data *td, int etype, char *str)
243 if (etype >= ERROR_TYPE_CNT) {
244 log_err("Illegal error type\n");
248 td->o.ignore_error_nr[etype] = 4;
249 error = malloc(4 * sizeof(struct bssplit));
252 while ((fname = strsep(&str, ":")) != NULL) {
258 * grow struct buffer, if needed
260 if (i == td->o.ignore_error_nr[etype]) {
261 td->o.ignore_error_nr[etype] <<= 1;
262 error = realloc(error, td->o.ignore_error_nr[etype]
265 if (fname[0] == 'E') {
266 error[i] = str2error(fname);
268 error[i] = atoi(fname);
273 log_err("Unknown error %s, please use number value \n",
280 td->o.continue_on_error |= 1 << etype;
281 td->o.ignore_error_nr[etype] = i;
282 td->o.ignore_error[etype] = error;
288 static int str_ignore_error_cb(void *data, const char *input)
290 struct thread_data *td = data;
292 int type = 0, ret = 1;
293 p = str = strdup(input);
295 strip_blank_front(&str);
296 strip_blank_end(str);
302 ret = ignore_error_type(td, type, p);
312 static int str_rw_cb(void *data, const char *str)
314 struct thread_data *td = data;
315 char *nr = get_opt_postfix(str);
317 td->o.ddir_seq_nr = 1;
318 td->o.ddir_seq_add = 0;
324 td->o.ddir_seq_nr = atoi(nr);
328 if (str_to_decimal(nr, &val, 1, td)) {
329 log_err("fio: rw postfix parsing failed\n");
334 td->o.ddir_seq_add = val;
341 static int str_mem_cb(void *data, const char *mem)
343 struct thread_data *td = data;
345 if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP) {
346 td->mmapfile = get_opt_postfix(mem);
347 if (td->o.mem_type == MEM_MMAPHUGE && !td->mmapfile) {
348 log_err("fio: mmaphuge:/path/to/file\n");
356 static int str_verify_cb(void *data, const char *mem)
358 struct thread_data *td = data;
360 if (td->o.verify == VERIFY_CRC32C_INTEL ||
361 td->o.verify == VERIFY_CRC32C) {
362 crc32c_intel_probe();
368 static int fio_clock_source_cb(void *data, const char *str)
370 struct thread_data *td = data;
372 fio_clock_source = td->o.clocksource;
377 static int str_lockmem_cb(void fio_unused *data, unsigned long long *val)
383 static int str_rwmix_read_cb(void *data, unsigned long long *val)
385 struct thread_data *td = data;
387 td->o.rwmix[DDIR_READ] = *val;
388 td->o.rwmix[DDIR_WRITE] = 100 - *val;
392 static int str_rwmix_write_cb(void *data, unsigned long long *val)
394 struct thread_data *td = data;
396 td->o.rwmix[DDIR_WRITE] = *val;
397 td->o.rwmix[DDIR_READ] = 100 - *val;
401 #ifdef FIO_HAVE_IOPRIO
402 static int str_prioclass_cb(void *data, unsigned long long *val)
404 struct thread_data *td = data;
408 * mask off old class bits, str_prio_cb() may have set a default class
410 mask = (1 << IOPRIO_CLASS_SHIFT) - 1;
413 td->ioprio |= *val << IOPRIO_CLASS_SHIFT;
418 static int str_prio_cb(void *data, unsigned long long *val)
420 struct thread_data *td = data;
425 * If no class is set, assume BE
427 if ((td->ioprio >> IOPRIO_CLASS_SHIFT) == 0)
428 td->ioprio |= IOPRIO_CLASS_BE << IOPRIO_CLASS_SHIFT;
435 static int str_exitall_cb(void)
437 exitall_on_terminate = 1;
441 #ifdef FIO_HAVE_CPU_AFFINITY
442 static int str_cpumask_cb(void *data, unsigned long long *val)
444 struct thread_data *td = data;
449 ret = fio_cpuset_init(&td->o.cpumask);
451 log_err("fio: cpuset_init failed\n");
452 td_verror(td, ret, "fio_cpuset_init");
456 max_cpu = cpus_online();
458 for (i = 0; i < sizeof(int) * 8; i++) {
459 if ((1 << i) & *val) {
461 log_err("fio: CPU %d too large (max=%ld)\n", i,
465 dprint(FD_PARSE, "set cpu allowed %d\n", i);
466 fio_cpu_set(&td->o.cpumask, i);
470 td->o.cpumask_set = 1;
474 static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask,
481 ret = fio_cpuset_init(mask);
483 log_err("fio: cpuset_init failed\n");
484 td_verror(td, ret, "fio_cpuset_init");
488 p = str = strdup(input);
490 strip_blank_front(&str);
491 strip_blank_end(str);
493 max_cpu = cpus_online();
495 while ((cpu = strsep(&str, ",")) != NULL) {
504 while ((cpu2 = strsep(&str2, "-")) != NULL) {
514 while (icpu <= icpu2) {
515 if (icpu >= FIO_MAX_CPUS) {
516 log_err("fio: your OS only supports up to"
517 " %d CPUs\n", (int) FIO_MAX_CPUS);
521 if (icpu > max_cpu) {
522 log_err("fio: CPU %d too large (max=%ld)\n",
528 dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
529 fio_cpu_set(mask, icpu);
538 td->o.cpumask_set = 1;
542 static int str_cpus_allowed_cb(void *data, const char *input)
544 struct thread_data *td = data;
547 ret = set_cpus_allowed(td, &td->o.cpumask, input);
549 td->o.cpumask_set = 1;
554 static int str_verify_cpus_allowed_cb(void *data, const char *input)
556 struct thread_data *td = data;
559 ret = set_cpus_allowed(td, &td->o.verify_cpumask, input);
561 td->o.verify_cpumask_set = 1;
567 #ifdef FIO_HAVE_LIBNUMA
568 static int str_numa_cpunodes_cb(void *data, char *input)
570 struct thread_data *td = data;
572 /* numa_parse_nodestring() parses a character string list
573 * of nodes into a bit mask. The bit mask is allocated by
574 * numa_allocate_nodemask(), so it should be freed by
575 * numa_free_nodemask().
577 td->o.numa_cpunodesmask = numa_parse_nodestring(input);
578 if (td->o.numa_cpunodesmask == NULL) {
579 log_err("fio: numa_parse_nodestring failed\n");
580 td_verror(td, 1, "str_numa_cpunodes_cb");
584 td->o.numa_cpumask_set = 1;
588 static int str_numa_mpol_cb(void *data, char *input)
590 struct thread_data *td = data;
591 const char * const policy_types[] =
592 { "default", "prefer", "bind", "interleave", "local" };
595 char *nodelist = strchr(input, ':');
597 /* NUL-terminate mode */
601 for (i = 0; i <= MPOL_LOCAL; i++) {
602 if (!strcmp(input, policy_types[i])) {
603 td->o.numa_mem_mode = i;
607 if (i > MPOL_LOCAL) {
608 log_err("fio: memory policy should be: default, prefer, bind, interleave, local\n");
612 switch (td->o.numa_mem_mode) {
615 * Insist on a nodelist of one node only
618 char *rest = nodelist;
619 while (isdigit(*rest))
622 log_err("fio: one node only for \'prefer\'\n");
626 log_err("fio: one node is needed for \'prefer\'\n");
630 case MPOL_INTERLEAVE:
632 * Default to online nodes with memory if no nodelist
635 nodelist = strdup("all");
640 * Don't allow a nodelist
643 log_err("fio: NO nodelist for \'local\'\n");
649 * Insist on a nodelist
652 log_err("fio: a nodelist is needed for \'bind\'\n");
659 /* numa_parse_nodestring() parses a character string list
660 * of nodes into a bit mask. The bit mask is allocated by
661 * numa_allocate_nodemask(), so it should be freed by
662 * numa_free_nodemask().
664 switch (td->o.numa_mem_mode) {
666 td->o.numa_mem_prefer_node = atoi(nodelist);
668 case MPOL_INTERLEAVE:
670 td->o.numa_memnodesmask = numa_parse_nodestring(nodelist);
671 if (td->o.numa_memnodesmask == NULL) {
672 log_err("fio: numa_parse_nodestring failed\n");
673 td_verror(td, 1, "str_numa_memnodes_cb");
683 td->o.numa_memmask_set = 1;
692 static int str_verify_trim_cb(void *data, unsigned long long *val)
694 struct thread_data *td = data;
696 td->o.trim_percentage = *val;
701 static int str_fst_cb(void *data, const char *str)
703 struct thread_data *td = data;
704 char *nr = get_opt_postfix(str);
706 td->file_service_nr = 1;
708 td->file_service_nr = atoi(nr);
715 #ifdef FIO_HAVE_SYNC_FILE_RANGE
716 static int str_sfr_cb(void *data, const char *str)
718 struct thread_data *td = data;
719 char *nr = get_opt_postfix(str);
721 td->sync_file_range_nr = 1;
723 td->sync_file_range_nr = atoi(nr);
731 static int check_dir(struct thread_data *td, char *fname)
734 char file[PATH_MAX], *dir;
737 if (td->o.directory) {
738 strcpy(file, td->o.directory);
743 sprintf(file + elen, "%s", fname);
749 * We can't do this on FIO_DISKLESSIO engines. The engine isn't loaded
750 * yet, so we can't do this check right here...
752 if (lstat(dir, &sb) < 0) {
755 log_err("fio: %s is not a directory\n", dir);
756 td_verror(td, ret, "lstat");
760 if (!S_ISDIR(sb.st_mode)) {
761 log_err("fio: %s is not a directory\n", dir);
771 * Return next file in the string. Files are separated with ':'. If the ':'
772 * is escaped with a '\', then that ':' is part of the filename and does not
773 * indicate a new file.
775 static char *get_next_file_name(char **ptr)
780 if (!str || !strlen(str))
786 * No colon, we are done
788 p = strchr(str, ':');
795 * We got a colon, but it's the first character. Skip and
803 if (*(p - 1) != '\\') {
809 memmove(p - 1, p, strlen(p) + 1);
816 static int str_filename_cb(void *data, const char *input)
818 struct thread_data *td = data;
819 char *fname, *str, *p;
821 p = str = strdup(input);
823 strip_blank_front(&str);
824 strip_blank_end(str);
826 if (!td->files_index)
829 while ((fname = get_next_file_name(&str)) != NULL) {
832 if (check_dir(td, fname)) {
844 static int str_directory_cb(void *data, const char fio_unused *str)
846 struct thread_data *td = data;
849 if (lstat(td->o.directory, &sb) < 0) {
852 log_err("fio: %s is not a directory\n", td->o.directory);
853 td_verror(td, ret, "lstat");
856 if (!S_ISDIR(sb.st_mode)) {
857 log_err("fio: %s is not a directory\n", td->o.directory);
864 static int str_opendir_cb(void *data, const char fio_unused *str)
866 struct thread_data *td = data;
868 if (!td->files_index)
871 return add_dir_files(td, td->o.opendir);
874 static int str_verify_offset_cb(void *data, unsigned long long *off)
876 struct thread_data *td = data;
878 if (*off && *off < sizeof(struct verify_header)) {
879 log_err("fio: verify_offset too small\n");
883 td->o.verify_offset = *off;
887 static int str_verify_pattern_cb(void *data, const char *input)
889 struct thread_data *td = data;
891 int i = 0, j = 0, len, k, base = 10;
894 loc1 = strstr(input, "0x");
895 loc2 = strstr(input, "0X");
898 off = strtol(input, NULL, base);
899 if (off != LONG_MAX || errno != ERANGE) {
901 td->o.verify_pattern[i] = off & 0xff;
910 j = loc1 - input + 2;
912 j = loc2 - input + 2;
915 if (len - j < MAX_PATTERN_SIZE * 2) {
917 off = converthexchartoint(input[k--]);
919 off += (converthexchartoint(input[k--])
921 td->o.verify_pattern[i++] = (char) off;
927 * Fill the pattern all the way to the end. This greatly reduces
928 * the number of memcpy's we have to do when verifying the IO.
930 while (i > 1 && i * 2 <= MAX_PATTERN_SIZE) {
931 memcpy(&td->o.verify_pattern[i], &td->o.verify_pattern[0], i);
936 * The code in verify_io_u_pattern assumes a single byte pattern
937 * fills the whole verify pattern buffer.
939 memset(td->o.verify_pattern, td->o.verify_pattern[0],
943 td->o.verify_pattern_bytes = i;
946 * VERIFY_META could already be set
948 if (td->o.verify == VERIFY_NONE)
949 td->o.verify = VERIFY_PATTERN;
954 static int str_lockfile_cb(void *data, const char *str)
956 struct thread_data *td = data;
957 char *nr = get_opt_postfix(str);
959 td->o.lockfile_batch = 1;
961 td->o.lockfile_batch = atoi(nr);
968 static int str_write_bw_log_cb(void *data, const char *str)
970 struct thread_data *td = data;
973 td->o.bw_log_file = strdup(str);
975 td->o.write_bw_log = 1;
979 static int str_write_lat_log_cb(void *data, const char *str)
981 struct thread_data *td = data;
984 td->o.lat_log_file = strdup(str);
986 td->o.write_lat_log = 1;
990 static int str_write_iops_log_cb(void *data, const char *str)
992 struct thread_data *td = data;
995 td->o.iops_log_file = strdup(str);
997 td->o.write_iops_log = 1;
1001 static int str_gtod_reduce_cb(void *data, int *il)
1003 struct thread_data *td = data;
1006 td->o.disable_lat = !!val;
1007 td->o.disable_clat = !!val;
1008 td->o.disable_slat = !!val;
1009 td->o.disable_bw = !!val;
1010 td->o.clat_percentiles = !val;
1012 td->tv_cache_mask = 63;
1017 static int str_gtod_cpu_cb(void *data, long long *il)
1019 struct thread_data *td = data;
1022 td->o.gtod_cpu = val;
1023 td->o.gtod_offload = 1;
1027 static int str_size_cb(void *data, unsigned long long *__val)
1029 struct thread_data *td = data;
1030 unsigned long long v = *__val;
1032 if (parse_is_percent(v)) {
1034 td->o.size_percent = -1ULL - v;
1041 static int rw_verify(struct fio_option *o, void *data)
1043 struct thread_data *td = data;
1045 if (read_only && td_write(td)) {
1046 log_err("fio: job <%s> has write bit set, but fio is in"
1047 " read-only mode\n", td->o.name);
1054 static int gtod_cpu_verify(struct fio_option *o, void *data)
1056 #ifndef FIO_HAVE_CPU_AFFINITY
1057 struct thread_data *td = data;
1059 if (td->o.gtod_cpu) {
1060 log_err("fio: platform must support CPU affinity for"
1061 "gettimeofday() offloading\n");
1069 static int kb_base_verify(struct fio_option *o, void *data)
1071 struct thread_data *td = data;
1073 if (td->o.kb_base != 1024 && td->o.kb_base != 1000) {
1074 log_err("fio: kb_base set to nonsensical value: %u\n",
1083 * Map of job/command line options
1085 static struct fio_option options[FIO_MAX_OPTS] = {
1087 .name = "description",
1088 .type = FIO_OPT_STR_STORE,
1089 .off1 = td_var_offset(description),
1090 .help = "Text job description",
1094 .type = FIO_OPT_STR_STORE,
1095 .off1 = td_var_offset(name),
1096 .help = "Name of this job",
1099 .name = "directory",
1100 .type = FIO_OPT_STR_STORE,
1101 .off1 = td_var_offset(directory),
1102 .cb = str_directory_cb,
1103 .help = "Directory to store files in",
1107 .type = FIO_OPT_STR_STORE,
1108 .off1 = td_var_offset(filename),
1109 .cb = str_filename_cb,
1110 .prio = -1, /* must come after "directory" */
1111 .help = "File(s) to use for the workload",
1115 .type = FIO_OPT_INT,
1116 .off1 = td_var_offset(kb_base),
1117 .verify = kb_base_verify,
1120 .help = "How many bytes per KB for reporting (1000 or 1024)",
1124 .type = FIO_OPT_STR,
1125 .cb = str_lockfile_cb,
1126 .off1 = td_var_offset(file_lock_mode),
1127 .help = "Lock file when doing IO to it",
1128 .parent = "filename",
1132 .oval = FILE_LOCK_NONE,
1133 .help = "No file locking",
1135 { .ival = "exclusive",
1136 .oval = FILE_LOCK_EXCLUSIVE,
1137 .help = "Exclusive file lock",
1140 .ival = "readwrite",
1141 .oval = FILE_LOCK_READWRITE,
1142 .help = "Read vs write lock",
1148 .type = FIO_OPT_STR_STORE,
1149 .off1 = td_var_offset(opendir),
1150 .cb = str_opendir_cb,
1151 .help = "Recursively add files from this directory and down",
1155 .alias = "readwrite",
1156 .type = FIO_OPT_STR,
1158 .off1 = td_var_offset(td_ddir),
1159 .help = "IO direction",
1161 .verify = rw_verify,
1164 .oval = TD_DDIR_READ,
1165 .help = "Sequential read",
1168 .oval = TD_DDIR_WRITE,
1169 .help = "Sequential write",
1172 .oval = TD_DDIR_TRIM,
1173 .help = "Sequential trim",
1175 { .ival = "randread",
1176 .oval = TD_DDIR_RANDREAD,
1177 .help = "Random read",
1179 { .ival = "randwrite",
1180 .oval = TD_DDIR_RANDWRITE,
1181 .help = "Random write",
1183 { .ival = "randtrim",
1184 .oval = TD_DDIR_RANDTRIM,
1185 .help = "Random trim",
1189 .help = "Sequential read and write mix",
1191 { .ival = "readwrite",
1193 .help = "Sequential read and write mix",
1196 .oval = TD_DDIR_RANDRW,
1197 .help = "Random read and write mix"
1202 .name = "rw_sequencer",
1203 .type = FIO_OPT_STR,
1204 .off1 = td_var_offset(rw_seq),
1205 .help = "IO offset generator modifier",
1206 .def = "sequential",
1208 { .ival = "sequential",
1210 .help = "Generate sequential offsets",
1212 { .ival = "identical",
1213 .oval = RW_SEQ_IDENT,
1214 .help = "Generate identical offsets",
1221 .type = FIO_OPT_STR_STORE,
1222 .off1 = td_var_offset(ioengine),
1223 .help = "IO engine to use",
1224 .def = FIO_PREFERRED_ENGINE,
1227 .help = "Use read/write",
1230 .help = "Use pread/pwrite",
1233 .help = "Use readv/writev",
1235 #ifdef FIO_HAVE_LIBAIO
1237 .help = "Linux native asynchronous IO",
1240 #ifdef FIO_HAVE_POSIXAIO
1241 { .ival = "posixaio",
1242 .help = "POSIX asynchronous IO",
1245 #ifdef FIO_HAVE_SOLARISAIO
1246 { .ival = "solarisaio",
1247 .help = "Solaris native asynchronous IO",
1250 #ifdef FIO_HAVE_WINDOWSAIO
1251 { .ival = "windowsaio",
1252 .help = "Windows native asynchronous IO"
1256 .help = "Memory mapped IO"
1258 #ifdef FIO_HAVE_SPLICE
1260 .help = "splice/vmsplice based IO",
1262 { .ival = "netsplice",
1263 .help = "splice/vmsplice to/from the network",
1266 #ifdef FIO_HAVE_SGIO
1268 .help = "SCSI generic v3 IO",
1272 .help = "Testing engine (no data transfer)",
1275 .help = "Network IO",
1277 #ifdef FIO_HAVE_SYSLET
1278 { .ival = "syslet-rw",
1279 .help = "syslet enabled async pread/pwrite IO",
1283 .help = "CPU cycle burner engine",
1285 #ifdef FIO_HAVE_GUASI
1287 .help = "GUASI IO engine",
1290 #ifdef FIO_HAVE_BINJECT
1291 { .ival = "binject",
1292 .help = "binject direct inject block engine",
1295 #ifdef FIO_HAVE_RDMA
1297 .help = "RDMA IO engine",
1300 #ifdef FIO_HAVE_FUSION_AW
1301 { .ival = "fusion-aw-sync",
1302 .help = "Fusion-io atomic write engine",
1305 #ifdef FIO_HAVE_E4_ENG
1306 { .ival = "e4defrag",
1307 .help = "ext4 defrag engine",
1310 #ifdef FIO_HAVE_FALLOC_ENG
1312 .help = "fallocate() file based engine",
1315 { .ival = "external",
1316 .help = "Load external engine (append name)",
1322 .type = FIO_OPT_INT,
1323 .off1 = td_var_offset(iodepth),
1324 .help = "Number of IO buffers to keep in flight",
1329 .name = "iodepth_batch",
1330 .alias = "iodepth_batch_submit",
1331 .type = FIO_OPT_INT,
1332 .off1 = td_var_offset(iodepth_batch),
1333 .help = "Number of IO buffers to submit in one go",
1334 .parent = "iodepth",
1339 .name = "iodepth_batch_complete",
1340 .type = FIO_OPT_INT,
1341 .off1 = td_var_offset(iodepth_batch_complete),
1342 .help = "Number of IO buffers to retrieve in one go",
1343 .parent = "iodepth",
1348 .name = "iodepth_low",
1349 .type = FIO_OPT_INT,
1350 .off1 = td_var_offset(iodepth_low),
1351 .help = "Low water mark for queuing depth",
1352 .parent = "iodepth",
1356 .type = FIO_OPT_STR_VAL,
1358 .help = "Total size of device or files",
1361 .name = "fill_device",
1363 .type = FIO_OPT_BOOL,
1364 .off1 = td_var_offset(fill_device),
1365 .help = "Write until an ENOSPC error occurs",
1370 .type = FIO_OPT_STR_VAL,
1371 .off1 = td_var_offset(file_size_low),
1372 .off2 = td_var_offset(file_size_high),
1374 .help = "Size of individual files",
1378 .alias = "fileoffset",
1379 .type = FIO_OPT_STR_VAL,
1380 .off1 = td_var_offset(start_offset),
1381 .help = "Start IO from this offset",
1385 .name = "offset_increment",
1386 .type = FIO_OPT_STR_VAL,
1387 .off1 = td_var_offset(offset_increment),
1388 .help = "What is the increment from one offset to the next",
1394 .alias = "blocksize",
1395 .type = FIO_OPT_INT,
1396 .off1 = td_var_offset(bs[DDIR_READ]),
1397 .off2 = td_var_offset(bs[DDIR_WRITE]),
1398 .off3 = td_var_offset(bs[DDIR_TRIM]),
1400 .help = "Block size unit",
1406 .alias = "blockalign",
1407 .type = FIO_OPT_INT,
1408 .off1 = td_var_offset(ba[DDIR_READ]),
1409 .off2 = td_var_offset(ba[DDIR_WRITE]),
1410 .off3 = td_var_offset(ba[DDIR_TRIM]),
1412 .help = "IO block offset alignment",
1417 .alias = "blocksize_range",
1418 .type = FIO_OPT_RANGE,
1419 .off1 = td_var_offset(min_bs[DDIR_READ]),
1420 .off2 = td_var_offset(max_bs[DDIR_READ]),
1421 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
1422 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
1423 .off5 = td_var_offset(min_bs[DDIR_TRIM]),
1424 .off6 = td_var_offset(max_bs[DDIR_TRIM]),
1426 .help = "Set block size range (in more detail than bs)",
1431 .type = FIO_OPT_STR,
1432 .cb = str_bssplit_cb,
1433 .help = "Set a specific mix of block sizes",
1437 .name = "bs_unaligned",
1438 .alias = "blocksize_unaligned",
1439 .type = FIO_OPT_STR_SET,
1440 .off1 = td_var_offset(bs_unaligned),
1441 .help = "Don't sector align IO buffer sizes",
1445 .name = "randrepeat",
1446 .type = FIO_OPT_BOOL,
1447 .off1 = td_var_offset(rand_repeatable),
1448 .help = "Use repeatable random IO pattern",
1453 .name = "use_os_rand",
1454 .type = FIO_OPT_BOOL,
1455 .off1 = td_var_offset(use_os_rand),
1456 .help = "Set to use OS random generator",
1461 .name = "norandommap",
1462 .type = FIO_OPT_STR_SET,
1463 .off1 = td_var_offset(norandommap),
1464 .help = "Accept potential duplicate random blocks",
1468 .name = "softrandommap",
1469 .type = FIO_OPT_BOOL,
1470 .off1 = td_var_offset(softrandommap),
1471 .help = "Set norandommap if randommap allocation fails",
1472 .parent = "norandommap",
1477 .alias = "nr_files",
1478 .type = FIO_OPT_INT,
1479 .off1 = td_var_offset(nr_files),
1480 .help = "Split job workload between this number of files",
1484 .name = "openfiles",
1485 .type = FIO_OPT_INT,
1486 .off1 = td_var_offset(open_files),
1487 .help = "Number of files to keep open at the same time",
1490 .name = "file_service_type",
1491 .type = FIO_OPT_STR,
1493 .off1 = td_var_offset(file_service_type),
1494 .help = "How to select which file to service next",
1495 .def = "roundrobin",
1498 .oval = FIO_FSERVICE_RANDOM,
1499 .help = "Choose a file at random",
1501 { .ival = "roundrobin",
1502 .oval = FIO_FSERVICE_RR,
1503 .help = "Round robin select files",
1505 { .ival = "sequential",
1506 .oval = FIO_FSERVICE_SEQ,
1507 .help = "Finish one file before moving to the next",
1510 .parent = "nrfiles",
1512 #ifdef FIO_HAVE_FALLOCATE
1514 .name = "fallocate",
1515 .type = FIO_OPT_STR,
1516 .off1 = td_var_offset(fallocate_mode),
1517 .help = "Whether pre-allocation is performed when laying out files",
1521 .oval = FIO_FALLOCATE_NONE,
1522 .help = "Do not pre-allocate space",
1525 .oval = FIO_FALLOCATE_POSIX,
1526 .help = "Use posix_fallocate()",
1528 #ifdef FIO_HAVE_LINUX_FALLOCATE
1530 .oval = FIO_FALLOCATE_KEEP_SIZE,
1531 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
1534 /* Compatibility with former boolean values */
1536 .oval = FIO_FALLOCATE_NONE,
1537 .help = "Alias for 'none'",
1540 .oval = FIO_FALLOCATE_POSIX,
1541 .help = "Alias for 'posix'",
1545 #endif /* FIO_HAVE_FALLOCATE */
1547 .name = "fadvise_hint",
1548 .type = FIO_OPT_BOOL,
1549 .off1 = td_var_offset(fadvise_hint),
1550 .help = "Use fadvise() to advise the kernel on IO pattern",
1555 .type = FIO_OPT_INT,
1556 .off1 = td_var_offset(fsync_blocks),
1557 .help = "Issue fsync for writes every given number of blocks",
1561 .name = "fdatasync",
1562 .type = FIO_OPT_INT,
1563 .off1 = td_var_offset(fdatasync_blocks),
1564 .help = "Issue fdatasync for writes every given number of blocks",
1568 .name = "write_barrier",
1569 .type = FIO_OPT_INT,
1570 .off1 = td_var_offset(barrier_blocks),
1571 .help = "Make every Nth write a barrier write",
1574 #ifdef FIO_HAVE_SYNC_FILE_RANGE
1576 .name = "sync_file_range",
1578 { .ival = "wait_before",
1579 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
1580 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
1584 .oval = SYNC_FILE_RANGE_WRITE,
1585 .help = "SYNC_FILE_RANGE_WRITE",
1589 .ival = "wait_after",
1590 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
1591 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
1595 .type = FIO_OPT_STR_MULTI,
1597 .off1 = td_var_offset(sync_file_range),
1598 .help = "Use sync_file_range()",
1603 .type = FIO_OPT_BOOL,
1604 .off1 = td_var_offset(odirect),
1605 .help = "Use O_DIRECT IO (negates buffered)",
1610 .type = FIO_OPT_BOOL,
1611 .off1 = td_var_offset(odirect),
1613 .help = "Use buffered IO (negates direct)",
1617 .name = "overwrite",
1618 .type = FIO_OPT_BOOL,
1619 .off1 = td_var_offset(overwrite),
1620 .help = "When writing, set whether to overwrite current data",
1625 .type = FIO_OPT_INT,
1626 .off1 = td_var_offset(loops),
1627 .help = "Number of times to run the job",
1632 .type = FIO_OPT_INT,
1633 .off1 = td_var_offset(numjobs),
1634 .help = "Duplicate this job this many times",
1638 .name = "startdelay",
1639 .type = FIO_OPT_STR_VAL_TIME,
1640 .off1 = td_var_offset(start_delay),
1641 .help = "Only start job when this period has passed",
1647 .type = FIO_OPT_STR_VAL_TIME,
1648 .off1 = td_var_offset(timeout),
1649 .help = "Stop workload when this amount of time has passed",
1653 .name = "time_based",
1654 .type = FIO_OPT_STR_SET,
1655 .off1 = td_var_offset(time_based),
1656 .help = "Keep running until runtime/timeout is met",
1659 .name = "ramp_time",
1660 .type = FIO_OPT_STR_VAL_TIME,
1661 .off1 = td_var_offset(ramp_time),
1662 .help = "Ramp up time before measuring performance",
1665 .name = "clocksource",
1666 .type = FIO_OPT_STR,
1667 .cb = fio_clock_source_cb,
1668 .off1 = td_var_offset(clocksource),
1669 .help = "What type of timing source to use",
1671 { .ival = "gettimeofday",
1673 .help = "Use gettimeofday(2) for timing",
1675 { .ival = "clock_gettime",
1676 .oval = CS_CGETTIME,
1677 .help = "Use clock_gettime(2) for timing",
1679 #ifdef ARCH_HAVE_CPU_CLOCK
1681 .oval = CS_CPUCLOCK,
1682 .help = "Use CPU private clock",
1690 .type = FIO_OPT_STR,
1692 .off1 = td_var_offset(mem_type),
1693 .help = "Backing type for IO buffers",
1698 .help = "Use malloc(3) for IO buffers",
1702 .help = "Use shared memory segments for IO buffers",
1704 #ifdef FIO_HAVE_HUGETLB
1705 { .ival = "shmhuge",
1706 .oval = MEM_SHMHUGE,
1707 .help = "Like shm, but use huge pages",
1712 .help = "Use mmap(2) (file or anon) for IO buffers",
1714 #ifdef FIO_HAVE_HUGETLB
1715 { .ival = "mmaphuge",
1716 .oval = MEM_MMAPHUGE,
1717 .help = "Like mmap, but use huge pages",
1723 .name = "iomem_align",
1724 .alias = "mem_align",
1725 .type = FIO_OPT_INT,
1726 .off1 = td_var_offset(mem_align),
1728 .help = "IO memory buffer offset alignment",
1734 .type = FIO_OPT_STR,
1735 .off1 = td_var_offset(verify),
1736 .help = "Verify data written",
1737 .cb = str_verify_cb,
1741 .oval = VERIFY_NONE,
1742 .help = "Don't do IO verification",
1746 .help = "Use md5 checksums for verification",
1749 .oval = VERIFY_CRC64,
1750 .help = "Use crc64 checksums for verification",
1753 .oval = VERIFY_CRC32,
1754 .help = "Use crc32 checksums for verification",
1756 { .ival = "crc32c-intel",
1757 .oval = VERIFY_CRC32C,
1758 .help = "Use crc32c checksums for verification (hw assisted, if available)",
1761 .oval = VERIFY_CRC32C,
1762 .help = "Use crc32c checksums for verification (hw assisted, if available)",
1765 .oval = VERIFY_CRC16,
1766 .help = "Use crc16 checksums for verification",
1769 .oval = VERIFY_CRC7,
1770 .help = "Use crc7 checksums for verification",
1773 .oval = VERIFY_SHA1,
1774 .help = "Use sha1 checksums for verification",
1777 .oval = VERIFY_SHA256,
1778 .help = "Use sha256 checksums for verification",
1781 .oval = VERIFY_SHA512,
1782 .help = "Use sha512 checksums for verification",
1785 .oval = VERIFY_META,
1786 .help = "Use io information",
1790 .oval = VERIFY_NULL,
1791 .help = "Pretend to verify",
1796 .name = "do_verify",
1797 .type = FIO_OPT_BOOL,
1798 .off1 = td_var_offset(do_verify),
1799 .help = "Run verification stage after write",
1804 .name = "verifysort",
1805 .type = FIO_OPT_BOOL,
1806 .off1 = td_var_offset(verifysort),
1807 .help = "Sort written verify blocks for read back",
1812 .name = "verify_interval",
1813 .type = FIO_OPT_INT,
1814 .off1 = td_var_offset(verify_interval),
1815 .minval = 2 * sizeof(struct verify_header),
1816 .help = "Store verify buffer header every N bytes",
1820 .name = "verify_offset",
1821 .type = FIO_OPT_INT,
1822 .help = "Offset verify header location by N bytes",
1824 .cb = str_verify_offset_cb,
1828 .name = "verify_pattern",
1829 .type = FIO_OPT_STR,
1830 .cb = str_verify_pattern_cb,
1831 .help = "Fill pattern for IO buffers",
1835 .name = "verify_fatal",
1836 .type = FIO_OPT_BOOL,
1837 .off1 = td_var_offset(verify_fatal),
1839 .help = "Exit on a single verify failure, don't continue",
1843 .name = "verify_dump",
1844 .type = FIO_OPT_BOOL,
1845 .off1 = td_var_offset(verify_dump),
1847 .help = "Dump contents of good and bad blocks on failure",
1851 .name = "verify_async",
1852 .type = FIO_OPT_INT,
1853 .off1 = td_var_offset(verify_async),
1855 .help = "Number of async verifier threads to use",
1859 .name = "verify_backlog",
1860 .type = FIO_OPT_STR_VAL,
1861 .off1 = td_var_offset(verify_backlog),
1862 .help = "Verify after this number of blocks are written",
1866 .name = "verify_backlog_batch",
1867 .type = FIO_OPT_INT,
1868 .off1 = td_var_offset(verify_batch),
1869 .help = "Verify this number of IO blocks",
1872 #ifdef FIO_HAVE_CPU_AFFINITY
1874 .name = "verify_async_cpus",
1875 .type = FIO_OPT_STR,
1876 .cb = str_verify_cpus_allowed_cb,
1877 .help = "Set CPUs allowed for async verify threads",
1878 .parent = "verify_async",
1881 #ifdef FIO_HAVE_TRIM
1883 .name = "trim_percentage",
1884 .type = FIO_OPT_INT,
1885 .cb = str_verify_trim_cb,
1887 .help = "Number of verify blocks to discard/trim",
1892 .name = "trim_verify_zero",
1893 .type = FIO_OPT_INT,
1894 .help = "Verify that trim/discarded blocks are returned as zeroes",
1895 .off1 = td_var_offset(trim_zero),
1896 .parent = "trim_percentage",
1900 .name = "trim_backlog",
1901 .type = FIO_OPT_STR_VAL,
1902 .off1 = td_var_offset(trim_backlog),
1903 .help = "Trim after this number of blocks are written",
1904 .parent = "trim_percentage",
1907 .name = "trim_backlog_batch",
1908 .type = FIO_OPT_INT,
1909 .off1 = td_var_offset(trim_batch),
1910 .help = "Trim this number of IO blocks",
1911 .parent = "trim_percentage",
1915 .name = "write_iolog",
1916 .type = FIO_OPT_STR_STORE,
1917 .off1 = td_var_offset(write_iolog_file),
1918 .help = "Store IO pattern to file",
1921 .name = "read_iolog",
1922 .type = FIO_OPT_STR_STORE,
1923 .off1 = td_var_offset(read_iolog_file),
1924 .help = "Playback IO pattern from file",
1927 .name = "replay_no_stall",
1928 .type = FIO_OPT_INT,
1929 .off1 = td_var_offset(no_stall),
1931 .parent = "read_iolog",
1932 .help = "Playback IO pattern file as fast as possible without stalls",
1935 .name = "replay_redirect",
1936 .type = FIO_OPT_STR_STORE,
1937 .off1 = td_var_offset(replay_redirect),
1938 .parent = "read_iolog",
1939 .help = "Replay all I/O onto this device, regardless of trace device",
1942 .name = "exec_prerun",
1943 .type = FIO_OPT_STR_STORE,
1944 .off1 = td_var_offset(exec_prerun),
1945 .help = "Execute this file prior to running job",
1948 .name = "exec_postrun",
1949 .type = FIO_OPT_STR_STORE,
1950 .off1 = td_var_offset(exec_postrun),
1951 .help = "Execute this file after running job",
1953 #ifdef FIO_HAVE_IOSCHED_SWITCH
1955 .name = "ioscheduler",
1956 .type = FIO_OPT_STR_STORE,
1957 .off1 = td_var_offset(ioscheduler),
1958 .help = "Use this IO scheduler on the backing device",
1963 .type = FIO_OPT_STR_VAL,
1964 .off1 = td_var_offset(zone_size),
1965 .help = "Amount of data to read per zone",
1969 .name = "zonerange",
1970 .type = FIO_OPT_STR_VAL,
1971 .off1 = td_var_offset(zone_range),
1972 .help = "Give size of an IO zone",
1977 .type = FIO_OPT_STR_VAL,
1978 .off1 = td_var_offset(zone_skip),
1979 .help = "Space between IO zones",
1984 .type = FIO_OPT_STR_VAL,
1985 .cb = str_lockmem_cb,
1986 .help = "Lock down this amount of memory",
1990 .name = "rwmixread",
1991 .type = FIO_OPT_INT,
1992 .cb = str_rwmix_read_cb,
1994 .help = "Percentage of mixed workload that is reads",
1998 .name = "rwmixwrite",
1999 .type = FIO_OPT_INT,
2000 .cb = str_rwmix_write_cb,
2002 .help = "Percentage of mixed workload that is writes",
2006 .name = "rwmixcycle",
2007 .type = FIO_OPT_DEPRECATED,
2011 .type = FIO_OPT_INT,
2012 .off1 = td_var_offset(nice),
2013 .help = "Set job CPU nice value",
2018 #ifdef FIO_HAVE_IOPRIO
2021 .type = FIO_OPT_INT,
2023 .help = "Set job IO priority value",
2028 .name = "prioclass",
2029 .type = FIO_OPT_INT,
2030 .cb = str_prioclass_cb,
2031 .help = "Set job IO priority class",
2037 .name = "thinktime",
2038 .type = FIO_OPT_INT,
2039 .off1 = td_var_offset(thinktime),
2040 .help = "Idle time between IO buffers (usec)",
2044 .name = "thinktime_spin",
2045 .type = FIO_OPT_INT,
2046 .off1 = td_var_offset(thinktime_spin),
2047 .help = "Start think time by spinning this amount (usec)",
2049 .parent = "thinktime",
2052 .name = "thinktime_blocks",
2053 .type = FIO_OPT_INT,
2054 .off1 = td_var_offset(thinktime_blocks),
2055 .help = "IO buffer period between 'thinktime'",
2057 .parent = "thinktime",
2061 .type = FIO_OPT_INT,
2062 .off1 = td_var_offset(rate[DDIR_READ]),
2063 .off2 = td_var_offset(rate[DDIR_WRITE]),
2064 .off3 = td_var_offset(rate[DDIR_TRIM]),
2065 .help = "Set bandwidth rate",
2069 .type = FIO_OPT_INT,
2070 .off1 = td_var_offset(ratemin[DDIR_READ]),
2071 .off2 = td_var_offset(ratemin[DDIR_WRITE]),
2072 .off3 = td_var_offset(ratemin[DDIR_TRIM]),
2073 .help = "Job must meet this rate or it will be shutdown",
2077 .name = "rate_iops",
2078 .type = FIO_OPT_INT,
2079 .off1 = td_var_offset(rate_iops[DDIR_READ]),
2080 .off2 = td_var_offset(rate_iops[DDIR_WRITE]),
2081 .off3 = td_var_offset(rate_iops[DDIR_TRIM]),
2082 .help = "Limit IO used to this number of IO operations/sec",
2085 .name = "rate_iops_min",
2086 .type = FIO_OPT_INT,
2087 .off1 = td_var_offset(rate_iops_min[DDIR_READ]),
2088 .off2 = td_var_offset(rate_iops_min[DDIR_WRITE]),
2089 .off3 = td_var_offset(rate_iops_min[DDIR_TRIM]),
2090 .help = "Job must meet this rate or it will be shut down",
2091 .parent = "rate_iops",
2094 .name = "ratecycle",
2095 .type = FIO_OPT_INT,
2096 .off1 = td_var_offset(ratecycle),
2097 .help = "Window average for rate limits (msec)",
2102 .name = "invalidate",
2103 .type = FIO_OPT_BOOL,
2104 .off1 = td_var_offset(invalidate_cache),
2105 .help = "Invalidate buffer/page cache prior to running job",
2110 .type = FIO_OPT_BOOL,
2111 .off1 = td_var_offset(sync_io),
2112 .help = "Use O_SYNC for buffered writes",
2114 .parent = "buffered",
2117 .name = "bwavgtime",
2118 .type = FIO_OPT_INT,
2119 .off1 = td_var_offset(bw_avg_time),
2120 .help = "Time window over which to calculate bandwidth"
2123 .parent = "write_bw_log",
2126 .name = "iopsavgtime",
2127 .type = FIO_OPT_INT,
2128 .off1 = td_var_offset(iops_avg_time),
2129 .help = "Time window over which to calculate IOPS (msec)",
2131 .parent = "write_iops_log",
2134 .name = "create_serialize",
2135 .type = FIO_OPT_BOOL,
2136 .off1 = td_var_offset(create_serialize),
2137 .help = "Serialize creating of job files",
2141 .name = "create_fsync",
2142 .type = FIO_OPT_BOOL,
2143 .off1 = td_var_offset(create_fsync),
2144 .help = "fsync file after creation",
2148 .name = "create_on_open",
2149 .type = FIO_OPT_BOOL,
2150 .off1 = td_var_offset(create_on_open),
2151 .help = "Create files when they are opened for IO",
2155 .name = "create_only",
2156 .type = FIO_OPT_BOOL,
2157 .off1 = td_var_offset(create_only),
2158 .help = "Only perform file creation phase",
2163 .type = FIO_OPT_BOOL,
2164 .off1 = td_var_offset(pre_read),
2165 .help = "Pre-read files before starting official testing",
2170 .type = FIO_OPT_INT,
2171 .off1 = td_var_offset(cpuload),
2172 .help = "Use this percentage of CPU",
2175 .name = "cpuchunks",
2176 .type = FIO_OPT_INT,
2177 .off1 = td_var_offset(cpucycle),
2178 .help = "Length of the CPU burn cycles (usecs)",
2180 .parent = "cpuload",
2182 #ifdef FIO_HAVE_CPU_AFFINITY
2185 .type = FIO_OPT_INT,
2186 .cb = str_cpumask_cb,
2187 .help = "CPU affinity mask",
2190 .name = "cpus_allowed",
2191 .type = FIO_OPT_STR,
2192 .cb = str_cpus_allowed_cb,
2193 .help = "Set CPUs allowed",
2196 #ifdef FIO_HAVE_LIBNUMA
2198 .name = "numa_cpu_nodes",
2199 .type = FIO_OPT_STR,
2200 .cb = str_numa_cpunodes_cb,
2201 .help = "NUMA CPU nodes bind",
2204 .name = "numa_mem_policy",
2205 .type = FIO_OPT_STR,
2206 .cb = str_numa_mpol_cb,
2207 .help = "NUMA memory policy setup",
2211 .name = "end_fsync",
2212 .type = FIO_OPT_BOOL,
2213 .off1 = td_var_offset(end_fsync),
2214 .help = "Include fsync at the end of job",
2218 .name = "fsync_on_close",
2219 .type = FIO_OPT_BOOL,
2220 .off1 = td_var_offset(fsync_on_close),
2221 .help = "fsync files on close",
2226 .type = FIO_OPT_BOOL,
2227 .off1 = td_var_offset(unlink),
2228 .help = "Unlink created files after job has completed",
2233 .type = FIO_OPT_STR_SET,
2234 .cb = str_exitall_cb,
2235 .help = "Terminate all jobs when one exits",
2238 .name = "stonewall",
2239 .alias = "wait_for_previous",
2240 .type = FIO_OPT_STR_SET,
2241 .off1 = td_var_offset(stonewall),
2242 .help = "Insert a hard barrier between this job and previous",
2245 .name = "new_group",
2246 .type = FIO_OPT_STR_SET,
2247 .off1 = td_var_offset(new_group),
2248 .help = "Mark the start of a new group (for reporting)",
2252 .type = FIO_OPT_STR_SET,
2253 .off1 = td_var_offset(use_thread),
2254 .help = "Use threads instead of forks",
2257 .name = "write_bw_log",
2258 .type = FIO_OPT_STR,
2259 .off1 = td_var_offset(write_bw_log),
2260 .cb = str_write_bw_log_cb,
2261 .help = "Write log of bandwidth during run",
2264 .name = "write_lat_log",
2265 .type = FIO_OPT_STR,
2266 .off1 = td_var_offset(write_lat_log),
2267 .cb = str_write_lat_log_cb,
2268 .help = "Write log of latency during run",
2271 .name = "write_iops_log",
2272 .type = FIO_OPT_STR,
2273 .off1 = td_var_offset(write_iops_log),
2274 .cb = str_write_iops_log_cb,
2275 .help = "Write log of IOPS during run",
2278 .name = "log_avg_msec",
2279 .type = FIO_OPT_INT,
2280 .off1 = td_var_offset(log_avg_msec),
2281 .help = "Average bw/iops/lat logs over this period of time",
2285 .name = "hugepage-size",
2286 .type = FIO_OPT_INT,
2287 .off1 = td_var_offset(hugepage_size),
2288 .help = "When using hugepages, specify size of each page",
2289 .def = __fio_stringify(FIO_HUGE_PAGE),
2292 .name = "group_reporting",
2293 .type = FIO_OPT_STR_SET,
2294 .off1 = td_var_offset(group_reporting),
2295 .help = "Do reporting on a per-group basis",
2298 .name = "zero_buffers",
2299 .type = FIO_OPT_STR_SET,
2300 .off1 = td_var_offset(zero_buffers),
2301 .help = "Init IO buffers to all zeroes",
2304 .name = "refill_buffers",
2305 .type = FIO_OPT_STR_SET,
2306 .off1 = td_var_offset(refill_buffers),
2307 .help = "Refill IO buffers on every IO submit",
2310 .name = "scramble_buffers",
2311 .type = FIO_OPT_BOOL,
2312 .off1 = td_var_offset(scramble_buffers),
2313 .help = "Slightly scramble buffers on every IO submit",
2317 .name = "buffer_compress_percentage",
2318 .type = FIO_OPT_INT,
2319 .off1 = td_var_offset(compress_percentage),
2322 .help = "How compressible the buffer is (approximately)",
2325 .name = "buffer_compress_chunk",
2326 .type = FIO_OPT_INT,
2327 .off1 = td_var_offset(compress_chunk),
2328 .parent = "buffer_compress_percentage",
2329 .help = "Size of compressible region in buffer",
2332 .name = "clat_percentiles",
2333 .type = FIO_OPT_BOOL,
2334 .off1 = td_var_offset(clat_percentiles),
2335 .help = "Enable the reporting of completion latency percentiles",
2339 .name = "percentile_list",
2340 .type = FIO_OPT_FLOAT_LIST,
2341 .off1 = td_var_offset(percentile_list),
2342 .off2 = td_var_offset(overwrite_plist),
2343 .help = "Specify a custom list of percentiles to report",
2344 .maxlen = FIO_IO_U_LIST_MAX_LEN,
2349 #ifdef FIO_HAVE_DISK_UTIL
2351 .name = "disk_util",
2352 .type = FIO_OPT_BOOL,
2353 .off1 = td_var_offset(do_disk_util),
2354 .help = "Log disk utilization statistics",
2359 .name = "gtod_reduce",
2360 .type = FIO_OPT_BOOL,
2361 .help = "Greatly reduce number of gettimeofday() calls",
2362 .cb = str_gtod_reduce_cb,
2366 .name = "disable_lat",
2367 .type = FIO_OPT_BOOL,
2368 .off1 = td_var_offset(disable_lat),
2369 .help = "Disable latency numbers",
2370 .parent = "gtod_reduce",
2374 .name = "disable_clat",
2375 .type = FIO_OPT_BOOL,
2376 .off1 = td_var_offset(disable_clat),
2377 .help = "Disable completion latency numbers",
2378 .parent = "gtod_reduce",
2382 .name = "disable_slat",
2383 .type = FIO_OPT_BOOL,
2384 .off1 = td_var_offset(disable_slat),
2385 .help = "Disable submission latency numbers",
2386 .parent = "gtod_reduce",
2390 .name = "disable_bw_measurement",
2391 .type = FIO_OPT_BOOL,
2392 .off1 = td_var_offset(disable_bw),
2393 .help = "Disable bandwidth logging",
2394 .parent = "gtod_reduce",
2399 .type = FIO_OPT_INT,
2400 .cb = str_gtod_cpu_cb,
2401 .help = "Set up dedicated gettimeofday() thread on this CPU",
2402 .verify = gtod_cpu_verify,
2405 .name = "continue_on_error",
2406 .type = FIO_OPT_STR,
2407 .off1 = td_var_offset(continue_on_error),
2408 .help = "Continue on non-fatal errors during IO",
2412 .oval = ERROR_TYPE_NONE,
2413 .help = "Exit when an error is encountered",
2416 .oval = ERROR_TYPE_READ,
2417 .help = "Continue on read errors only",
2420 .oval = ERROR_TYPE_WRITE,
2421 .help = "Continue on write errors only",
2424 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
2425 .help = "Continue on any IO errors",
2428 .oval = ERROR_TYPE_VERIFY,
2429 .help = "Continue on verify errors only",
2432 .oval = ERROR_TYPE_ANY,
2433 .help = "Continue on all io and verify errors",
2436 .oval = ERROR_TYPE_NONE,
2437 .help = "Alias for 'none'",
2440 .oval = ERROR_TYPE_ANY,
2441 .help = "Alias for 'all'",
2446 .name = "ignore_error",
2447 .type = FIO_OPT_STR,
2448 .cb = str_ignore_error_cb,
2449 .help = "Set a specific list of errors to ignore",
2453 .name = "error_dump",
2454 .type = FIO_OPT_BOOL,
2455 .off1 = td_var_offset(error_dump),
2457 .help = "Dump info on each error",
2462 .type = FIO_OPT_STR_STORE,
2463 .off1 = td_var_offset(profile),
2464 .help = "Select a specific builtin performance test",
2468 .type = FIO_OPT_STR_STORE,
2469 .off1 = td_var_offset(cgroup),
2470 .help = "Add job to cgroup of this name",
2473 .name = "cgroup_weight",
2474 .type = FIO_OPT_INT,
2475 .off1 = td_var_offset(cgroup_weight),
2476 .help = "Use given weight for cgroup",
2481 .name = "cgroup_nodelete",
2482 .type = FIO_OPT_BOOL,
2483 .off1 = td_var_offset(cgroup_nodelete),
2484 .help = "Do not delete cgroups after job completion",
2489 .type = FIO_OPT_INT,
2490 .off1 = td_var_offset(uid),
2491 .help = "Run job with this user ID",
2495 .type = FIO_OPT_INT,
2496 .off1 = td_var_offset(gid),
2497 .help = "Run job with this group ID",
2501 .type = FIO_OPT_INT,
2502 .off1 = td_var_offset(flow_id),
2503 .help = "The flow index ID to use",
2508 .type = FIO_OPT_INT,
2509 .off1 = td_var_offset(flow),
2510 .help = "Weight for flow control of this job",
2511 .parent = "flow_id",
2515 .name = "flow_watermark",
2516 .type = FIO_OPT_INT,
2517 .off1 = td_var_offset(flow_watermark),
2518 .help = "High watermark for flow control. This option"
2519 " should be set to the same value for all threads"
2520 " with non-zero flow.",
2521 .parent = "flow_id",
2525 .name = "flow_sleep",
2526 .type = FIO_OPT_INT,
2527 .off1 = td_var_offset(flow_sleep),
2528 .help = "How many microseconds to sleep after being held"
2529 " back by the flow control mechanism",
2530 .parent = "flow_id",
2538 static void add_to_lopt(struct option *lopt, struct fio_option *o,
2539 const char *name, int val)
2541 lopt->name = (char *) name;
2543 if (o->type == FIO_OPT_STR_SET)
2544 lopt->has_arg = no_argument;
2546 lopt->has_arg = required_argument;
2549 static void options_to_lopts(struct fio_option *opts,
2550 struct option *long_options,
2551 int i, int option_type)
2553 struct fio_option *o = &opts[0];
2555 add_to_lopt(&long_options[i], o, o->name, option_type);
2558 add_to_lopt(&long_options[i], o, o->alias, option_type);
2563 assert(i < FIO_NR_OPTIONS);
2567 void fio_options_set_ioengine_opts(struct option *long_options,
2568 struct thread_data *td)
2573 while (long_options[i].name) {
2574 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
2575 memset(&long_options[i], 0, sizeof(*long_options));
2582 * Just clear out the prior ioengine options.
2587 options_to_lopts(td->io_ops->options, long_options, i,
2588 FIO_GETOPT_IOENGINE);
2591 void fio_options_dup_and_init(struct option *long_options)
2595 options_init(options);
2598 while (long_options[i].name)
2601 options_to_lopts(options, long_options, i, FIO_GETOPT_JOB);
2604 struct fio_keyword {
2610 static struct fio_keyword fio_keywords[] = {
2612 .word = "$pagesize",
2613 .desc = "Page size in the system",
2616 .word = "$mb_memory",
2617 .desc = "Megabytes of memory online",
2621 .desc = "Number of CPUs online in the system",
2628 void fio_keywords_init(void)
2630 unsigned long long mb_memory;
2634 sprintf(buf, "%lu", (unsigned long) page_size);
2635 fio_keywords[0].replace = strdup(buf);
2637 mb_memory = os_phys_mem() / (1024 * 1024);
2638 sprintf(buf, "%llu", mb_memory);
2639 fio_keywords[1].replace = strdup(buf);
2642 sprintf(buf, "%lu", l);
2643 fio_keywords[2].replace = strdup(buf);
2648 static char *bc_calc(char *str)
2650 char buf[128], *tmp;
2655 * No math, just return string
2657 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
2658 !strchr(str, '/')) || strchr(str, '\''))
2662 * Split option from value, we only need to calculate the value
2664 tmp = strchr(str, '=');
2671 * Prevent buffer overflows; such a case isn't reasonable anyway
2673 if (strlen(str) >= 128 || strlen(tmp) > 100)
2676 sprintf(buf, "which %s > /dev/null", BC_APP);
2678 log_err("fio: bc is needed for performing math\n");
2682 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
2683 f = popen(buf, "r");
2688 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
2694 buf[(tmp - str) + ret - 1] = '\0';
2695 memcpy(buf, str, tmp - str);
2701 * Return a copy of the input string with substrings of the form ${VARNAME}
2702 * substituted with the value of the environment variable VARNAME. The
2703 * substitution always occurs, even if VARNAME is empty or the corresponding
2704 * environment variable undefined.
2706 static char *option_dup_subs(const char *opt)
2708 char out[OPT_LEN_MAX+1];
2709 char in[OPT_LEN_MAX+1];
2712 char *ch1, *ch2, *env;
2713 ssize_t nchr = OPT_LEN_MAX;
2716 if (strlen(opt) + 1 > OPT_LEN_MAX) {
2717 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
2721 in[OPT_LEN_MAX] = '\0';
2722 strncpy(in, opt, OPT_LEN_MAX);
2724 while (*inptr && nchr > 0) {
2725 if (inptr[0] == '$' && inptr[1] == '{') {
2726 ch2 = strchr(inptr, '}');
2727 if (ch2 && inptr+1 < ch2) {
2734 envlen = strlen(env);
2735 if (envlen <= nchr) {
2736 memcpy(outptr, env, envlen);
2746 *outptr++ = *inptr++;
2755 * Look for reserved variable names and replace them with real values
2757 static char *fio_keyword_replace(char *opt)
2763 for (i = 0; fio_keywords[i].word != NULL; i++) {
2764 struct fio_keyword *kw = &fio_keywords[i];
2766 while ((s = strstr(opt, kw->word)) != NULL) {
2767 char *new = malloc(strlen(opt) + 1);
2773 * Copy part of the string before the keyword and
2774 * sprintf() the replacement after it.
2776 memcpy(new, opt, olen);
2777 len = sprintf(new + olen, "%s", kw->replace);
2780 * If there's more in the original string, copy that
2783 opt += strlen(kw->word) + olen;
2785 memcpy(new + olen + len, opt, opt - o_org - 1);
2788 * replace opt and free the old opt
2798 * Check for potential math and invoke bc, if possible
2806 static char **dup_and_sub_options(char **opts, int num_opts)
2809 char **opts_copy = malloc(num_opts * sizeof(*opts));
2810 for (i = 0; i < num_opts; i++) {
2811 opts_copy[i] = option_dup_subs(opts[i]);
2814 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
2819 int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
2821 int i, ret, unknown;
2824 sort_options(opts, options, num_opts);
2825 opts_copy = dup_and_sub_options(opts, num_opts);
2827 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
2828 struct fio_option *o;
2829 int newret = parse_option(opts_copy[i], opts[i], options, &o,
2838 opts_copy[i] = NULL;
2845 ret |= ioengine_load(td);
2847 sort_options(opts_copy, td->io_ops->options, num_opts);
2850 for (i = 0; i < num_opts; i++) {
2851 struct fio_option *o = NULL;
2857 newret = parse_option(opts_copy[i], opts[i],
2858 td->io_ops->options, &o,
2863 log_err("Bad option <%s>\n", opts[i]);
2866 opts_copy[i] = NULL;
2874 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
2876 return parse_cmd_option(opt, val, options, td);
2879 int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
2882 return parse_cmd_option(opt, val, td->io_ops->options, td);
2885 void fio_fill_default_options(struct thread_data *td)
2887 fill_default_options(td, options);
2890 int fio_show_option_help(const char *opt)
2892 return show_cmd_help(options, opt);
2895 void options_mem_dupe(void *data, struct fio_option *options)
2897 struct fio_option *o;
2900 for (o = &options[0]; o->name; o++) {
2901 if (o->type != FIO_OPT_STR_STORE)
2904 ptr = td_var(data, o->off1);
2906 *ptr = strdup(*ptr);
2911 * dupe FIO_OPT_STR_STORE options
2913 void fio_options_mem_dupe(struct thread_data *td)
2915 options_mem_dupe(&td->o, options);
2917 if (td->eo && td->io_ops) {
2918 void *oldeo = td->eo;
2920 td->eo = malloc(td->io_ops->option_struct_size);
2921 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
2922 options_mem_dupe(td->eo, td->io_ops->options);
2926 unsigned int fio_get_kb_base(void *data)
2928 struct thread_data *td = data;
2929 unsigned int kb_base = 0;
2932 kb_base = td->o.kb_base;
2939 int add_option(struct fio_option *o)
2941 struct fio_option *__o;
2950 memcpy(&options[opt_index], o, sizeof(*o));
2954 void invalidate_profile_options(const char *prof_name)
2956 struct fio_option *o;
2960 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
2961 o->type = FIO_OPT_INVALID;
2962 o->prof_name = NULL;
2968 void add_opt_posval(const char *optname, const char *ival, const char *help)
2970 struct fio_option *o;
2973 o = find_option(options, optname);
2977 for (i = 0; i < PARSE_MAX_VP; i++) {
2978 if (o->posval[i].ival)
2981 o->posval[i].ival = ival;
2982 o->posval[i].help = help;
2987 void del_opt_posval(const char *optname, const char *ival)
2989 struct fio_option *o;
2992 o = find_option(options, optname);
2996 for (i = 0; i < PARSE_MAX_VP; i++) {
2997 if (!o->posval[i].ival)
2999 if (strcmp(o->posval[i].ival, ival))
3002 o->posval[i].ival = NULL;
3003 o->posval[i].help = NULL;
3007 void fio_options_free(struct thread_data *td)
3009 options_free(options, td);
3010 if (td->eo && td->io_ops && td->io_ops->options) {
3011 options_free(td->io_ops->options, td->eo);