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;
165 static int str_bssplit_cb(void *data, const char *input)
167 struct thread_data *td = data;
168 char *str, *p, *odir;
171 p = str = strdup(input);
173 strip_blank_front(&str);
174 strip_blank_end(str);
176 odir = strchr(str, ',');
178 ret = bssplit_ddir(td, DDIR_WRITE, odir + 1);
181 ret = bssplit_ddir(td, DDIR_READ, str);
188 ret = bssplit_ddir(td, DDIR_READ, str);
190 ret = bssplit_ddir(td, DDIR_WRITE, op);
199 static int str_rw_cb(void *data, const char *str)
201 struct thread_data *td = data;
202 char *nr = get_opt_postfix(str);
204 td->o.ddir_seq_nr = 1;
205 td->o.ddir_seq_add = 0;
211 td->o.ddir_seq_nr = atoi(nr);
215 if (str_to_decimal(nr, &val, 1, td)) {
216 log_err("fio: rw postfix parsing failed\n");
221 td->o.ddir_seq_add = val;
228 static int str_mem_cb(void *data, const char *mem)
230 struct thread_data *td = data;
232 if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP) {
233 td->mmapfile = get_opt_postfix(mem);
234 if (td->o.mem_type == MEM_MMAPHUGE && !td->mmapfile) {
235 log_err("fio: mmaphuge:/path/to/file\n");
243 static int str_verify_cb(void *data, const char *mem)
245 struct thread_data *td = data;
247 if (td->o.verify == VERIFY_CRC32C_INTEL ||
248 td->o.verify == VERIFY_CRC32C) {
249 crc32c_intel_probe();
255 static int fio_clock_source_cb(void *data, const char *str)
257 struct thread_data *td = data;
259 fio_clock_source = td->o.clocksource;
264 static int str_lockmem_cb(void fio_unused *data, unsigned long long *val)
270 static int str_rwmix_read_cb(void *data, unsigned long long *val)
272 struct thread_data *td = data;
274 td->o.rwmix[DDIR_READ] = *val;
275 td->o.rwmix[DDIR_WRITE] = 100 - *val;
279 static int str_rwmix_write_cb(void *data, unsigned long long *val)
281 struct thread_data *td = data;
283 td->o.rwmix[DDIR_WRITE] = *val;
284 td->o.rwmix[DDIR_READ] = 100 - *val;
288 #ifdef FIO_HAVE_IOPRIO
289 static int str_prioclass_cb(void *data, unsigned long long *val)
291 struct thread_data *td = data;
295 * mask off old class bits, str_prio_cb() may have set a default class
297 mask = (1 << IOPRIO_CLASS_SHIFT) - 1;
300 td->ioprio |= *val << IOPRIO_CLASS_SHIFT;
305 static int str_prio_cb(void *data, unsigned long long *val)
307 struct thread_data *td = data;
312 * If no class is set, assume BE
314 if ((td->ioprio >> IOPRIO_CLASS_SHIFT) == 0)
315 td->ioprio |= IOPRIO_CLASS_BE << IOPRIO_CLASS_SHIFT;
322 static int str_exitall_cb(void)
324 exitall_on_terminate = 1;
328 #ifdef FIO_HAVE_CPU_AFFINITY
329 static int str_cpumask_cb(void *data, unsigned long long *val)
331 struct thread_data *td = data;
336 ret = fio_cpuset_init(&td->o.cpumask);
338 log_err("fio: cpuset_init failed\n");
339 td_verror(td, ret, "fio_cpuset_init");
343 max_cpu = cpus_online();
345 for (i = 0; i < sizeof(int) * 8; i++) {
346 if ((1 << i) & *val) {
348 log_err("fio: CPU %d too large (max=%ld)\n", i,
352 dprint(FD_PARSE, "set cpu allowed %d\n", i);
353 fio_cpu_set(&td->o.cpumask, i);
357 td->o.cpumask_set = 1;
361 static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask,
368 ret = fio_cpuset_init(mask);
370 log_err("fio: cpuset_init failed\n");
371 td_verror(td, ret, "fio_cpuset_init");
375 p = str = strdup(input);
377 strip_blank_front(&str);
378 strip_blank_end(str);
380 max_cpu = cpus_online();
382 while ((cpu = strsep(&str, ",")) != NULL) {
391 while ((cpu2 = strsep(&str2, "-")) != NULL) {
401 while (icpu <= icpu2) {
402 if (icpu >= FIO_MAX_CPUS) {
403 log_err("fio: your OS only supports up to"
404 " %d CPUs\n", (int) FIO_MAX_CPUS);
408 if (icpu > max_cpu) {
409 log_err("fio: CPU %d too large (max=%ld)\n",
415 dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
416 fio_cpu_set(mask, icpu);
425 td->o.cpumask_set = 1;
429 static int str_cpus_allowed_cb(void *data, const char *input)
431 struct thread_data *td = data;
434 ret = set_cpus_allowed(td, &td->o.cpumask, input);
436 td->o.cpumask_set = 1;
441 static int str_verify_cpus_allowed_cb(void *data, const char *input)
443 struct thread_data *td = data;
446 ret = set_cpus_allowed(td, &td->o.verify_cpumask, input);
448 td->o.verify_cpumask_set = 1;
455 static int str_verify_trim_cb(void *data, unsigned long long *val)
457 struct thread_data *td = data;
459 td->o.trim_percentage = *val;
464 static int str_fst_cb(void *data, const char *str)
466 struct thread_data *td = data;
467 char *nr = get_opt_postfix(str);
469 td->file_service_nr = 1;
471 td->file_service_nr = atoi(nr);
478 #ifdef FIO_HAVE_SYNC_FILE_RANGE
479 static int str_sfr_cb(void *data, const char *str)
481 struct thread_data *td = data;
482 char *nr = get_opt_postfix(str);
484 td->sync_file_range_nr = 1;
486 td->sync_file_range_nr = atoi(nr);
494 static int check_dir(struct thread_data *td, char *fname)
497 char file[PATH_MAX], *dir;
500 if (td->o.directory) {
501 strcpy(file, td->o.directory);
506 sprintf(file + elen, "%s", fname);
512 * We can't do this on FIO_DISKLESSIO engines. The engine isn't loaded
513 * yet, so we can't do this check right here...
515 if (lstat(dir, &sb) < 0) {
518 log_err("fio: %s is not a directory\n", dir);
519 td_verror(td, ret, "lstat");
523 if (!S_ISDIR(sb.st_mode)) {
524 log_err("fio: %s is not a directory\n", dir);
534 * Return next file in the string. Files are separated with ':'. If the ':'
535 * is escaped with a '\', then that ':' is part of the filename and does not
536 * indicate a new file.
538 static char *get_next_file_name(char **ptr)
543 if (!str || !strlen(str))
549 * No colon, we are done
551 p = strchr(str, ':');
558 * We got a colon, but it's the first character. Skip and
566 if (*(p - 1) != '\\') {
572 memmove(p - 1, p, strlen(p) + 1);
579 static int str_filename_cb(void *data, const char *input)
581 struct thread_data *td = data;
582 char *fname, *str, *p;
584 p = str = strdup(input);
586 strip_blank_front(&str);
587 strip_blank_end(str);
589 if (!td->files_index)
592 while ((fname = get_next_file_name(&str)) != NULL) {
595 if (check_dir(td, fname)) {
607 static int str_directory_cb(void *data, const char fio_unused *str)
609 struct thread_data *td = data;
612 if (lstat(td->o.directory, &sb) < 0) {
615 log_err("fio: %s is not a directory\n", td->o.directory);
616 td_verror(td, ret, "lstat");
619 if (!S_ISDIR(sb.st_mode)) {
620 log_err("fio: %s is not a directory\n", td->o.directory);
627 static int str_opendir_cb(void *data, const char fio_unused *str)
629 struct thread_data *td = data;
631 if (!td->files_index)
634 return add_dir_files(td, td->o.opendir);
637 static int str_verify_offset_cb(void *data, unsigned long long *off)
639 struct thread_data *td = data;
641 if (*off && *off < sizeof(struct verify_header)) {
642 log_err("fio: verify_offset too small\n");
646 td->o.verify_offset = *off;
650 static int str_verify_pattern_cb(void *data, const char *input)
652 struct thread_data *td = data;
654 int i = 0, j = 0, len, k, base = 10;
657 loc1 = strstr(input, "0x");
658 loc2 = strstr(input, "0X");
661 off = strtol(input, NULL, base);
662 if (off != LONG_MAX || errno != ERANGE) {
664 td->o.verify_pattern[i] = off & 0xff;
673 j = loc1 - input + 2;
675 j = loc2 - input + 2;
678 if (len - j < MAX_PATTERN_SIZE * 2) {
680 off = converthexchartoint(input[k--]);
682 off += (converthexchartoint(input[k--])
684 td->o.verify_pattern[i++] = (char) off;
690 * Fill the pattern all the way to the end. This greatly reduces
691 * the number of memcpy's we have to do when verifying the IO.
693 while (i > 1 && i * 2 <= MAX_PATTERN_SIZE) {
694 memcpy(&td->o.verify_pattern[i], &td->o.verify_pattern[0], i);
699 * The code in verify_io_u_pattern assumes a single byte pattern
700 * fills the whole verify pattern buffer.
702 memset(td->o.verify_pattern, td->o.verify_pattern[0],
706 td->o.verify_pattern_bytes = i;
709 * VERIFY_META could already be set
711 if (td->o.verify == VERIFY_NONE)
712 td->o.verify = VERIFY_PATTERN;
717 static int str_lockfile_cb(void *data, const char *str)
719 struct thread_data *td = data;
720 char *nr = get_opt_postfix(str);
722 td->o.lockfile_batch = 1;
724 td->o.lockfile_batch = atoi(nr);
731 static int str_write_bw_log_cb(void *data, const char *str)
733 struct thread_data *td = data;
736 td->o.bw_log_file = strdup(str);
738 td->o.write_bw_log = 1;
742 static int str_write_lat_log_cb(void *data, const char *str)
744 struct thread_data *td = data;
747 td->o.lat_log_file = strdup(str);
749 td->o.write_lat_log = 1;
753 static int str_write_iops_log_cb(void *data, const char *str)
755 struct thread_data *td = data;
758 td->o.iops_log_file = strdup(str);
760 td->o.write_iops_log = 1;
764 static int str_gtod_reduce_cb(void *data, int *il)
766 struct thread_data *td = data;
769 td->o.disable_lat = !!val;
770 td->o.disable_clat = !!val;
771 td->o.disable_slat = !!val;
772 td->o.disable_bw = !!val;
773 td->o.clat_percentiles = !val;
775 td->tv_cache_mask = 63;
780 static int str_gtod_cpu_cb(void *data, long long *il)
782 struct thread_data *td = data;
785 td->o.gtod_cpu = val;
786 td->o.gtod_offload = 1;
790 static int str_size_cb(void *data, unsigned long long *__val)
792 struct thread_data *td = data;
793 unsigned long long v = *__val;
795 if (parse_is_percent(v)) {
797 td->o.size_percent = -1ULL - v;
804 static int rw_verify(struct fio_option *o, void *data)
806 struct thread_data *td = data;
808 if (read_only && td_write(td)) {
809 log_err("fio: job <%s> has write bit set, but fio is in"
810 " read-only mode\n", td->o.name);
817 static int gtod_cpu_verify(struct fio_option *o, void *data)
819 #ifndef FIO_HAVE_CPU_AFFINITY
820 struct thread_data *td = data;
822 if (td->o.gtod_cpu) {
823 log_err("fio: platform must support CPU affinity for"
824 "gettimeofday() offloading\n");
832 static int kb_base_verify(struct fio_option *o, void *data)
834 struct thread_data *td = data;
836 if (td->o.kb_base != 1024 && td->o.kb_base != 1000) {
837 log_err("fio: kb_base set to nonsensical value: %u\n",
848 static struct opt_group fio_opt_groups[] = {
850 .name = "Description",
851 .mask = FIO_OPT_G_DESC,
855 .mask = FIO_OPT_G_FILE,
859 .mask = FIO_OPT_G_MISC,
863 .mask = FIO_OPT_G_IO,
866 .name = "IO direction",
867 .mask = FIO_OPT_G_IO_DDIR,
871 .mask = FIO_OPT_G_IO_BUF,
875 .mask = FIO_OPT_G_RAND,
879 .mask = FIO_OPT_G_OS,
883 .mask = FIO_OPT_G_MEM,
887 .mask = FIO_OPT_G_VERIFY,
891 .mask = FIO_OPT_G_CPU,
895 .mask = FIO_OPT_G_LOG,
899 .mask = FIO_OPT_G_ZONE,
903 .mask = FIO_OPT_G_CACHE,
907 .mask = FIO_OPT_G_STAT,
911 .mask = FIO_OPT_G_ERR,
915 .mask = FIO_OPT_G_JOB,
922 struct opt_group *opt_group_from_mask(unsigned int *mask)
924 struct opt_group *og;
927 if (*mask == FIO_OPT_G_INVALID)
930 for (i = 0; fio_opt_groups[i].name; i++) {
931 og = &fio_opt_groups[i];
933 if (*mask & og->mask) {
934 *mask &= ~(og->mask);
943 * Map of job/command line options
945 struct fio_option fio_options[FIO_MAX_OPTS] = {
947 .name = "description",
948 .type = FIO_OPT_STR_STORE,
949 .off1 = td_var_offset(description),
950 .help = "Text job description",
951 .category = FIO_OPT_G_DESC,
955 .type = FIO_OPT_STR_STORE,
956 .off1 = td_var_offset(name),
957 .help = "Name of this job",
958 .category = FIO_OPT_G_DESC,
962 .type = FIO_OPT_STR_STORE,
963 .off1 = td_var_offset(directory),
964 .cb = str_directory_cb,
965 .help = "Directory to store files in",
966 .category = FIO_OPT_G_FILE,
970 .type = FIO_OPT_STR_STORE,
971 .off1 = td_var_offset(filename),
972 .cb = str_filename_cb,
973 .prio = -1, /* must come after "directory" */
974 .help = "File(s) to use for the workload",
975 .category = FIO_OPT_G_FILE,
980 .off1 = td_var_offset(kb_base),
981 .verify = kb_base_verify,
984 .help = "How many bytes per KB for reporting (1000 or 1024)",
985 .category = FIO_OPT_G_MISC,
990 .cb = str_lockfile_cb,
991 .off1 = td_var_offset(file_lock_mode),
992 .help = "Lock file when doing IO to it",
993 .parent = "filename",
995 .category = FIO_OPT_G_FILE,
998 .oval = FILE_LOCK_NONE,
999 .help = "No file locking",
1001 { .ival = "exclusive",
1002 .oval = FILE_LOCK_EXCLUSIVE,
1003 .help = "Exclusive file lock",
1006 .ival = "readwrite",
1007 .oval = FILE_LOCK_READWRITE,
1008 .help = "Read vs write lock",
1014 .type = FIO_OPT_STR_STORE,
1015 .off1 = td_var_offset(opendir),
1016 .cb = str_opendir_cb,
1017 .help = "Recursively add files from this directory and down",
1018 .category = FIO_OPT_G_FILE,
1022 .alias = "readwrite",
1023 .type = FIO_OPT_STR,
1025 .off1 = td_var_offset(td_ddir),
1026 .help = "IO direction",
1028 .verify = rw_verify,
1029 .category = FIO_OPT_G_IO_DDIR,
1032 .oval = TD_DDIR_READ,
1033 .help = "Sequential read",
1036 .oval = TD_DDIR_WRITE,
1037 .help = "Sequential write",
1039 { .ival = "randread",
1040 .oval = TD_DDIR_RANDREAD,
1041 .help = "Random read",
1043 { .ival = "randwrite",
1044 .oval = TD_DDIR_RANDWRITE,
1045 .help = "Random write",
1049 .help = "Sequential read and write mix",
1052 .oval = TD_DDIR_RANDRW,
1053 .help = "Random read and write mix"
1058 .name = "rw_sequencer",
1059 .type = FIO_OPT_STR,
1060 .off1 = td_var_offset(rw_seq),
1061 .help = "IO offset generator modifier",
1062 .def = "sequential",
1063 .category = FIO_OPT_G_IO_DDIR,
1065 { .ival = "sequential",
1067 .help = "Generate sequential offsets",
1069 { .ival = "identical",
1070 .oval = RW_SEQ_IDENT,
1071 .help = "Generate identical offsets",
1078 .type = FIO_OPT_STR_STORE,
1079 .off1 = td_var_offset(ioengine),
1080 .help = "IO engine to use",
1081 .def = FIO_PREFERRED_ENGINE,
1082 .category = FIO_OPT_G_IO,
1085 .help = "Use read/write",
1088 .help = "Use pread/pwrite",
1091 .help = "Use readv/writev",
1093 #ifdef FIO_HAVE_LIBAIO
1095 .help = "Linux native asynchronous IO",
1098 #ifdef FIO_HAVE_POSIXAIO
1099 { .ival = "posixaio",
1100 .help = "POSIX asynchronous IO",
1103 #ifdef FIO_HAVE_SOLARISAIO
1104 { .ival = "solarisaio",
1105 .help = "Solaris native asynchronous IO",
1108 #ifdef FIO_HAVE_WINDOWSAIO
1109 { .ival = "windowsaio",
1110 .help = "Windows native asynchronous IO"
1114 .help = "Memory mapped IO"
1116 #ifdef FIO_HAVE_SPLICE
1118 .help = "splice/vmsplice based IO",
1120 { .ival = "netsplice",
1121 .help = "splice/vmsplice to/from the network",
1124 #ifdef FIO_HAVE_SGIO
1126 .help = "SCSI generic v3 IO",
1130 .help = "Testing engine (no data transfer)",
1133 .help = "Network IO",
1135 #ifdef FIO_HAVE_SYSLET
1136 { .ival = "syslet-rw",
1137 .help = "syslet enabled async pread/pwrite IO",
1141 .help = "CPU cycle burner engine",
1143 #ifdef FIO_HAVE_GUASI
1145 .help = "GUASI IO engine",
1148 #ifdef FIO_HAVE_BINJECT
1149 { .ival = "binject",
1150 .help = "binject direct inject block engine",
1153 #ifdef FIO_HAVE_RDMA
1155 .help = "RDMA IO engine",
1158 { .ival = "external",
1159 .help = "Load external engine (append name)",
1165 .type = FIO_OPT_INT,
1166 .off1 = td_var_offset(iodepth),
1167 .help = "Number of IO buffers to keep in flight",
1170 .category = FIO_OPT_G_IO,
1173 .name = "iodepth_batch",
1174 .alias = "iodepth_batch_submit",
1175 .type = FIO_OPT_INT,
1176 .off1 = td_var_offset(iodepth_batch),
1177 .help = "Number of IO buffers to submit in one go",
1178 .parent = "iodepth",
1181 .category = FIO_OPT_G_IO,
1184 .name = "iodepth_batch_complete",
1185 .type = FIO_OPT_INT,
1186 .off1 = td_var_offset(iodepth_batch_complete),
1187 .help = "Number of IO buffers to retrieve in one go",
1188 .parent = "iodepth",
1191 .category = FIO_OPT_G_IO,
1194 .name = "iodepth_low",
1195 .type = FIO_OPT_INT,
1196 .off1 = td_var_offset(iodepth_low),
1197 .help = "Low water mark for queuing depth",
1198 .parent = "iodepth",
1199 .category = FIO_OPT_G_IO,
1203 .type = FIO_OPT_STR_VAL,
1205 .help = "Total size of device or files",
1206 .category = FIO_OPT_G_IO,
1209 .name = "fill_device",
1211 .type = FIO_OPT_BOOL,
1212 .off1 = td_var_offset(fill_device),
1213 .help = "Write until an ENOSPC error occurs",
1215 .category = FIO_OPT_G_IO,
1219 .type = FIO_OPT_STR_VAL,
1220 .off1 = td_var_offset(file_size_low),
1221 .off2 = td_var_offset(file_size_high),
1223 .help = "Size of individual files",
1224 .category = FIO_OPT_G_IO | FIO_OPT_G_FILE,
1228 .alias = "fileoffset",
1229 .type = FIO_OPT_STR_VAL,
1230 .off1 = td_var_offset(start_offset),
1231 .help = "Start IO from this offset",
1233 .category = FIO_OPT_G_IO,
1237 .alias = "blocksize",
1238 .type = FIO_OPT_INT,
1239 .off1 = td_var_offset(bs[DDIR_READ]),
1240 .off2 = td_var_offset(bs[DDIR_WRITE]),
1242 .help = "Block size unit",
1245 .category = FIO_OPT_G_IO,
1249 .alias = "blockalign",
1250 .type = FIO_OPT_INT,
1251 .off1 = td_var_offset(ba[DDIR_READ]),
1252 .off2 = td_var_offset(ba[DDIR_WRITE]),
1254 .help = "IO block offset alignment",
1256 .category = FIO_OPT_G_IO | FIO_OPT_G_IO_BUF,
1260 .alias = "blocksize_range",
1261 .type = FIO_OPT_RANGE,
1262 .off1 = td_var_offset(min_bs[DDIR_READ]),
1263 .off2 = td_var_offset(max_bs[DDIR_READ]),
1264 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
1265 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
1267 .help = "Set block size range (in more detail than bs)",
1269 .category = FIO_OPT_G_IO,
1273 .type = FIO_OPT_STR,
1274 .cb = str_bssplit_cb,
1275 .help = "Set a specific mix of block sizes",
1277 .category = FIO_OPT_G_IO,
1280 .name = "bs_unaligned",
1281 .alias = "blocksize_unaligned",
1282 .type = FIO_OPT_STR_SET,
1283 .off1 = td_var_offset(bs_unaligned),
1284 .help = "Don't sector align IO buffer sizes",
1286 .category = FIO_OPT_G_IO,
1289 .name = "randrepeat",
1290 .type = FIO_OPT_BOOL,
1291 .off1 = td_var_offset(rand_repeatable),
1292 .help = "Use repeatable random IO pattern",
1295 .category = FIO_OPT_G_IO | FIO_OPT_G_RAND,
1298 .name = "use_os_rand",
1299 .type = FIO_OPT_BOOL,
1300 .off1 = td_var_offset(use_os_rand),
1301 .help = "Set to use OS random generator",
1304 .category = FIO_OPT_G_RAND,
1307 .name = "norandommap",
1308 .type = FIO_OPT_STR_SET,
1309 .off1 = td_var_offset(norandommap),
1310 .help = "Accept potential duplicate random blocks",
1312 .category = FIO_OPT_G_RAND,
1315 .name = "softrandommap",
1316 .type = FIO_OPT_BOOL,
1317 .off1 = td_var_offset(softrandommap),
1318 .help = "Set norandommap if randommap allocation fails",
1319 .parent = "norandommap",
1321 .category = FIO_OPT_G_RAND,
1325 .alias = "nr_files",
1326 .type = FIO_OPT_INT,
1327 .off1 = td_var_offset(nr_files),
1328 .help = "Split job workload between this number of files",
1330 .category = FIO_OPT_G_FILE,
1333 .name = "openfiles",
1334 .type = FIO_OPT_INT,
1335 .off1 = td_var_offset(open_files),
1336 .help = "Number of files to keep open at the same time",
1337 .category = FIO_OPT_G_FILE,
1340 .name = "file_service_type",
1341 .type = FIO_OPT_STR,
1343 .off1 = td_var_offset(file_service_type),
1344 .help = "How to select which file to service next",
1345 .def = "roundrobin",
1346 .category = FIO_OPT_G_FILE,
1349 .oval = FIO_FSERVICE_RANDOM,
1350 .help = "Choose a file at random",
1352 { .ival = "roundrobin",
1353 .oval = FIO_FSERVICE_RR,
1354 .help = "Round robin select files",
1356 { .ival = "sequential",
1357 .oval = FIO_FSERVICE_SEQ,
1358 .help = "Finish one file before moving to the next",
1361 .parent = "nrfiles",
1363 #ifdef FIO_HAVE_FALLOCATE
1365 .name = "fallocate",
1366 .type = FIO_OPT_STR,
1367 .off1 = td_var_offset(fallocate_mode),
1368 .help = "Whether pre-allocation is performed when laying out files",
1370 .category = FIO_OPT_G_FILE,
1373 .oval = FIO_FALLOCATE_NONE,
1374 .help = "Do not pre-allocate space",
1377 .oval = FIO_FALLOCATE_POSIX,
1378 .help = "Use posix_fallocate()",
1380 #ifdef FIO_HAVE_LINUX_FALLOCATE
1382 .oval = FIO_FALLOCATE_KEEP_SIZE,
1383 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
1386 /* Compatibility with former boolean values */
1388 .oval = FIO_FALLOCATE_NONE,
1389 .help = "Alias for 'none'",
1392 .oval = FIO_FALLOCATE_POSIX,
1393 .help = "Alias for 'posix'",
1397 #endif /* FIO_HAVE_FALLOCATE */
1399 .name = "fadvise_hint",
1400 .type = FIO_OPT_BOOL,
1401 .off1 = td_var_offset(fadvise_hint),
1402 .help = "Use fadvise() to advise the kernel on IO pattern",
1404 .category = FIO_OPT_G_FILE,
1408 .type = FIO_OPT_INT,
1409 .off1 = td_var_offset(fsync_blocks),
1410 .help = "Issue fsync for writes every given number of blocks",
1412 .category = FIO_OPT_G_FILE,
1415 .name = "fdatasync",
1416 .type = FIO_OPT_INT,
1417 .off1 = td_var_offset(fdatasync_blocks),
1418 .help = "Issue fdatasync for writes every given number of blocks",
1420 .category = FIO_OPT_G_FILE,
1423 .name = "write_barrier",
1424 .type = FIO_OPT_INT,
1425 .off1 = td_var_offset(barrier_blocks),
1426 .help = "Make every Nth write a barrier write",
1428 .category = FIO_OPT_G_IO,
1430 #ifdef FIO_HAVE_SYNC_FILE_RANGE
1432 .name = "sync_file_range",
1434 { .ival = "wait_before",
1435 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
1436 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
1440 .oval = SYNC_FILE_RANGE_WRITE,
1441 .help = "SYNC_FILE_RANGE_WRITE",
1445 .ival = "wait_after",
1446 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
1447 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
1451 .type = FIO_OPT_STR_MULTI,
1453 .off1 = td_var_offset(sync_file_range),
1454 .help = "Use sync_file_range()",
1455 .category = FIO_OPT_G_FILE,
1460 .type = FIO_OPT_BOOL,
1461 .off1 = td_var_offset(odirect),
1462 .help = "Use O_DIRECT IO (negates buffered)",
1464 .category = FIO_OPT_G_IO,
1468 .type = FIO_OPT_BOOL,
1469 .off1 = td_var_offset(odirect),
1471 .help = "Use buffered IO (negates direct)",
1473 .category = FIO_OPT_G_IO,
1476 .name = "overwrite",
1477 .type = FIO_OPT_BOOL,
1478 .off1 = td_var_offset(overwrite),
1479 .help = "When writing, set whether to overwrite current data",
1481 .category = FIO_OPT_G_IO | FIO_OPT_G_FILE,
1485 .type = FIO_OPT_INT,
1486 .off1 = td_var_offset(loops),
1487 .help = "Number of times to run the job",
1489 .category = FIO_OPT_G_MISC,
1493 .type = FIO_OPT_INT,
1494 .off1 = td_var_offset(numjobs),
1495 .help = "Duplicate this job this many times",
1497 .category = FIO_OPT_G_MISC,
1500 .name = "startdelay",
1501 .type = FIO_OPT_STR_VAL_TIME,
1502 .off1 = td_var_offset(start_delay),
1503 .help = "Only start job when this period has passed",
1505 .category = FIO_OPT_G_MISC,
1510 .type = FIO_OPT_STR_VAL_TIME,
1511 .off1 = td_var_offset(timeout),
1512 .help = "Stop workload when this amount of time has passed",
1514 .category = FIO_OPT_G_MISC,
1517 .name = "time_based",
1518 .type = FIO_OPT_STR_SET,
1519 .off1 = td_var_offset(time_based),
1520 .help = "Keep running until runtime/timeout is met",
1521 .category = FIO_OPT_G_MISC,
1524 .name = "ramp_time",
1525 .type = FIO_OPT_STR_VAL_TIME,
1526 .off1 = td_var_offset(ramp_time),
1527 .help = "Ramp up time before measuring performance",
1528 .category = FIO_OPT_G_MISC,
1531 .name = "clocksource",
1532 .type = FIO_OPT_STR,
1533 .cb = fio_clock_source_cb,
1534 .off1 = td_var_offset(clocksource),
1535 .help = "What type of timing source to use",
1536 .category = FIO_OPT_G_OS,
1538 { .ival = "gettimeofday",
1540 .help = "Use gettimeofday(2) for timing",
1542 { .ival = "clock_gettime",
1543 .oval = CS_CGETTIME,
1544 .help = "Use clock_gettime(2) for timing",
1546 #ifdef ARCH_HAVE_CPU_CLOCK
1548 .oval = CS_CPUCLOCK,
1549 .help = "Use CPU private clock",
1557 .type = FIO_OPT_STR,
1559 .off1 = td_var_offset(mem_type),
1560 .help = "Backing type for IO buffers",
1562 .category = FIO_OPT_G_IO_BUF | FIO_OPT_G_MEM,
1566 .help = "Use malloc(3) for IO buffers",
1570 .help = "Use shared memory segments for IO buffers",
1572 #ifdef FIO_HAVE_HUGETLB
1573 { .ival = "shmhuge",
1574 .oval = MEM_SHMHUGE,
1575 .help = "Like shm, but use huge pages",
1580 .help = "Use mmap(2) (file or anon) for IO buffers",
1582 #ifdef FIO_HAVE_HUGETLB
1583 { .ival = "mmaphuge",
1584 .oval = MEM_MMAPHUGE,
1585 .help = "Like mmap, but use huge pages",
1591 .name = "iomem_align",
1592 .alias = "mem_align",
1593 .type = FIO_OPT_INT,
1594 .off1 = td_var_offset(mem_align),
1596 .help = "IO memory buffer offset alignment",
1599 .category = FIO_OPT_G_IO_BUF | FIO_OPT_G_MEM,
1603 .type = FIO_OPT_STR,
1604 .off1 = td_var_offset(verify),
1605 .help = "Verify data written",
1606 .cb = str_verify_cb,
1608 .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY,
1611 .oval = VERIFY_NONE,
1612 .help = "Don't do IO verification",
1616 .help = "Use md5 checksums for verification",
1619 .oval = VERIFY_CRC64,
1620 .help = "Use crc64 checksums for verification",
1623 .oval = VERIFY_CRC32,
1624 .help = "Use crc32 checksums for verification",
1626 { .ival = "crc32c-intel",
1627 .oval = VERIFY_CRC32C,
1628 .help = "Use crc32c checksums for verification (hw assisted, if available)",
1631 .oval = VERIFY_CRC32C,
1632 .help = "Use crc32c checksums for verification (hw assisted, if available)",
1635 .oval = VERIFY_CRC16,
1636 .help = "Use crc16 checksums for verification",
1639 .oval = VERIFY_CRC7,
1640 .help = "Use crc7 checksums for verification",
1643 .oval = VERIFY_SHA1,
1644 .help = "Use sha1 checksums for verification",
1647 .oval = VERIFY_SHA256,
1648 .help = "Use sha256 checksums for verification",
1651 .oval = VERIFY_SHA512,
1652 .help = "Use sha512 checksums for verification",
1655 .oval = VERIFY_META,
1656 .help = "Use io information",
1660 .oval = VERIFY_NULL,
1661 .help = "Pretend to verify",
1666 .name = "do_verify",
1667 .type = FIO_OPT_BOOL,
1668 .off1 = td_var_offset(do_verify),
1669 .help = "Run verification stage after write",
1672 .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY,
1675 .name = "verifysort",
1676 .type = FIO_OPT_BOOL,
1677 .off1 = td_var_offset(verifysort),
1678 .help = "Sort written verify blocks for read back",
1681 .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY,
1684 .name = "verify_interval",
1685 .type = FIO_OPT_INT,
1686 .off1 = td_var_offset(verify_interval),
1687 .minval = 2 * sizeof(struct verify_header),
1688 .help = "Store verify buffer header every N bytes",
1690 .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY,
1693 .name = "verify_offset",
1694 .type = FIO_OPT_INT,
1695 .help = "Offset verify header location by N bytes",
1697 .cb = str_verify_offset_cb,
1699 .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY,
1702 .name = "verify_pattern",
1703 .type = FIO_OPT_STR,
1704 .cb = str_verify_pattern_cb,
1705 .help = "Fill pattern for IO buffers",
1707 .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY,
1710 .name = "verify_fatal",
1711 .type = FIO_OPT_BOOL,
1712 .off1 = td_var_offset(verify_fatal),
1714 .help = "Exit on a single verify failure, don't continue",
1716 .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY | FIO_OPT_G_ERR,
1719 .name = "verify_dump",
1720 .type = FIO_OPT_BOOL,
1721 .off1 = td_var_offset(verify_dump),
1723 .help = "Dump contents of good and bad blocks on failure",
1725 .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY | FIO_OPT_G_ERR,
1728 .name = "verify_async",
1729 .type = FIO_OPT_INT,
1730 .off1 = td_var_offset(verify_async),
1732 .help = "Number of async verifier threads to use",
1734 .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY,
1737 .name = "verify_backlog",
1738 .type = FIO_OPT_STR_VAL,
1739 .off1 = td_var_offset(verify_backlog),
1740 .help = "Verify after this number of blocks are written",
1742 .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY,
1745 .name = "verify_backlog_batch",
1746 .type = FIO_OPT_INT,
1747 .off1 = td_var_offset(verify_batch),
1748 .help = "Verify this number of IO blocks",
1750 .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY,
1752 #ifdef FIO_HAVE_CPU_AFFINITY
1754 .name = "verify_async_cpus",
1755 .type = FIO_OPT_STR,
1756 .cb = str_verify_cpus_allowed_cb,
1757 .help = "Set CPUs allowed for async verify threads",
1758 .parent = "verify_async",
1759 .category = FIO_OPT_G_OS | FIO_OPT_G_CPU | FIO_OPT_G_VERIFY,
1762 #ifdef FIO_HAVE_TRIM
1764 .name = "trim_percentage",
1765 .type = FIO_OPT_INT,
1766 .cb = str_verify_trim_cb,
1768 .help = "Number of verify blocks to discard/trim",
1771 .category = FIO_OPT_G_IO,
1774 .name = "trim_verify_zero",
1775 .type = FIO_OPT_INT,
1776 .help = "Verify that trim/discarded blocks are returned as zeroes",
1777 .off1 = td_var_offset(trim_zero),
1778 .parent = "trim_percentage",
1780 .category = FIO_OPT_G_IO,
1783 .name = "trim_backlog",
1784 .type = FIO_OPT_STR_VAL,
1785 .off1 = td_var_offset(trim_backlog),
1786 .help = "Trim after this number of blocks are written",
1787 .parent = "trim_percentage",
1788 .category = FIO_OPT_G_IO,
1791 .name = "trim_backlog_batch",
1792 .type = FIO_OPT_INT,
1793 .off1 = td_var_offset(trim_batch),
1794 .help = "Trim this number of IO blocks",
1795 .parent = "trim_percentage",
1796 .category = FIO_OPT_G_IO,
1800 .name = "write_iolog",
1801 .type = FIO_OPT_STR_STORE,
1802 .off1 = td_var_offset(write_iolog_file),
1803 .help = "Store IO pattern to file",
1804 .category = FIO_OPT_G_IO | FIO_OPT_G_LOG,
1807 .name = "read_iolog",
1808 .type = FIO_OPT_STR_STORE,
1809 .off1 = td_var_offset(read_iolog_file),
1810 .help = "Playback IO pattern from file",
1811 .category = FIO_OPT_G_IO | FIO_OPT_G_LOG,
1814 .name = "replay_no_stall",
1815 .type = FIO_OPT_INT,
1816 .off1 = td_var_offset(no_stall),
1818 .parent = "read_iolog",
1819 .help = "Playback IO pattern file as fast as possible without stalls",
1820 .category = FIO_OPT_G_IO | FIO_OPT_G_LOG,
1823 .name = "replay_redirect",
1824 .type = FIO_OPT_STR_STORE,
1825 .off1 = td_var_offset(replay_redirect),
1826 .parent = "read_iolog",
1827 .help = "Replay all I/O onto this device, regardless of trace device",
1828 .category = FIO_OPT_G_IO | FIO_OPT_G_LOG,
1831 .name = "exec_prerun",
1832 .type = FIO_OPT_STR_STORE,
1833 .off1 = td_var_offset(exec_prerun),
1834 .help = "Execute this file prior to running job",
1835 .category = FIO_OPT_G_MISC | FIO_OPT_G_OS,
1838 .name = "exec_postrun",
1839 .type = FIO_OPT_STR_STORE,
1840 .off1 = td_var_offset(exec_postrun),
1841 .help = "Execute this file after running job",
1842 .category = FIO_OPT_G_MISC | FIO_OPT_G_OS,
1844 #ifdef FIO_HAVE_IOSCHED_SWITCH
1846 .name = "ioscheduler",
1847 .type = FIO_OPT_STR_STORE,
1848 .off1 = td_var_offset(ioscheduler),
1849 .help = "Use this IO scheduler on the backing device",
1850 .category = FIO_OPT_G_OS | FIO_OPT_G_IO,
1855 .type = FIO_OPT_STR_VAL,
1856 .off1 = td_var_offset(zone_size),
1857 .help = "Amount of data to read per zone",
1859 .category = FIO_OPT_G_IO | FIO_OPT_G_ZONE,
1862 .name = "zonerange",
1863 .type = FIO_OPT_STR_VAL,
1864 .off1 = td_var_offset(zone_range),
1865 .help = "Give size of an IO zone",
1867 .category = FIO_OPT_G_IO | FIO_OPT_G_ZONE,
1871 .type = FIO_OPT_STR_VAL,
1872 .off1 = td_var_offset(zone_skip),
1873 .help = "Space between IO zones",
1875 .category = FIO_OPT_G_IO | FIO_OPT_G_ZONE,
1879 .type = FIO_OPT_STR_VAL,
1880 .cb = str_lockmem_cb,
1881 .help = "Lock down this amount of memory",
1883 .category = FIO_OPT_G_OS | FIO_OPT_G_MEM,
1886 .name = "rwmixread",
1887 .type = FIO_OPT_INT,
1888 .cb = str_rwmix_read_cb,
1890 .help = "Percentage of mixed workload that is reads",
1892 .category = FIO_OPT_G_IO,
1895 .name = "rwmixwrite",
1896 .type = FIO_OPT_INT,
1897 .cb = str_rwmix_write_cb,
1899 .help = "Percentage of mixed workload that is writes",
1901 .category = FIO_OPT_G_IO,
1904 .name = "rwmixcycle",
1905 .type = FIO_OPT_DEPRECATED,
1906 .category = FIO_OPT_G_IO,
1910 .type = FIO_OPT_INT,
1911 .off1 = td_var_offset(nice),
1912 .help = "Set job CPU nice value",
1916 .category = FIO_OPT_G_OS | FIO_OPT_G_CPU,
1918 #ifdef FIO_HAVE_IOPRIO
1921 .type = FIO_OPT_INT,
1923 .help = "Set job IO priority value",
1926 .category = FIO_OPT_G_OS | FIO_OPT_G_CPU,
1929 .name = "prioclass",
1930 .type = FIO_OPT_INT,
1931 .cb = str_prioclass_cb,
1932 .help = "Set job IO priority class",
1935 .category = FIO_OPT_G_OS | FIO_OPT_G_CPU,
1939 .name = "thinktime",
1940 .type = FIO_OPT_INT,
1941 .off1 = td_var_offset(thinktime),
1942 .help = "Idle time between IO buffers (usec)",
1944 .category = FIO_OPT_G_MISC,
1947 .name = "thinktime_spin",
1948 .type = FIO_OPT_INT,
1949 .off1 = td_var_offset(thinktime_spin),
1950 .help = "Start think time by spinning this amount (usec)",
1952 .parent = "thinktime",
1953 .category = FIO_OPT_G_MISC,
1956 .name = "thinktime_blocks",
1957 .type = FIO_OPT_INT,
1958 .off1 = td_var_offset(thinktime_blocks),
1959 .help = "IO buffer period between 'thinktime'",
1961 .parent = "thinktime",
1962 .category = FIO_OPT_G_MISC,
1966 .type = FIO_OPT_INT,
1967 .off1 = td_var_offset(rate[0]),
1968 .off2 = td_var_offset(rate[1]),
1969 .help = "Set bandwidth rate",
1970 .category = FIO_OPT_G_IO,
1974 .type = FIO_OPT_INT,
1975 .off1 = td_var_offset(ratemin[0]),
1976 .off2 = td_var_offset(ratemin[1]),
1977 .help = "Job must meet this rate or it will be shutdown",
1979 .category = FIO_OPT_G_IO,
1982 .name = "rate_iops",
1983 .type = FIO_OPT_INT,
1984 .off1 = td_var_offset(rate_iops[0]),
1985 .off2 = td_var_offset(rate_iops[1]),
1986 .help = "Limit IO used to this number of IO operations/sec",
1987 .category = FIO_OPT_G_IO,
1990 .name = "rate_iops_min",
1991 .type = FIO_OPT_INT,
1992 .off1 = td_var_offset(rate_iops_min[0]),
1993 .off2 = td_var_offset(rate_iops_min[1]),
1994 .help = "Job must meet this rate or it will be shut down",
1995 .parent = "rate_iops",
1996 .category = FIO_OPT_G_IO,
1999 .name = "ratecycle",
2000 .type = FIO_OPT_INT,
2001 .off1 = td_var_offset(ratecycle),
2002 .help = "Window average for rate limits (msec)",
2005 .category = FIO_OPT_G_IO,
2008 .name = "invalidate",
2009 .type = FIO_OPT_BOOL,
2010 .off1 = td_var_offset(invalidate_cache),
2011 .help = "Invalidate buffer/page cache prior to running job",
2013 .category = FIO_OPT_G_IO | FIO_OPT_G_CACHE,
2017 .type = FIO_OPT_BOOL,
2018 .off1 = td_var_offset(sync_io),
2019 .help = "Use O_SYNC for buffered writes",
2021 .parent = "buffered",
2022 .category = FIO_OPT_G_IO | FIO_OPT_G_FILE,
2025 .name = "bwavgtime",
2026 .type = FIO_OPT_INT,
2027 .off1 = td_var_offset(bw_avg_time),
2028 .help = "Time window over which to calculate bandwidth"
2031 .parent = "write_bw_log",
2032 .category = FIO_OPT_G_LOG | FIO_OPT_G_STAT,
2035 .name = "iopsavgtime",
2036 .type = FIO_OPT_INT,
2037 .off1 = td_var_offset(iops_avg_time),
2038 .help = "Time window over which to calculate IOPS (msec)",
2040 .parent = "write_iops_log",
2041 .category = FIO_OPT_G_LOG | FIO_OPT_G_STAT,
2044 .name = "create_serialize",
2045 .type = FIO_OPT_BOOL,
2046 .off1 = td_var_offset(create_serialize),
2047 .help = "Serialize creating of job files",
2049 .category = FIO_OPT_G_FILE,
2052 .name = "create_fsync",
2053 .type = FIO_OPT_BOOL,
2054 .off1 = td_var_offset(create_fsync),
2055 .help = "fsync file after creation",
2057 .category = FIO_OPT_G_FILE,
2060 .name = "create_on_open",
2061 .type = FIO_OPT_BOOL,
2062 .off1 = td_var_offset(create_on_open),
2063 .help = "Create files when they are opened for IO",
2065 .category = FIO_OPT_G_FILE,
2069 .type = FIO_OPT_BOOL,
2070 .off1 = td_var_offset(pre_read),
2071 .help = "Pre-read files before starting official testing",
2073 .category = FIO_OPT_G_FILE | FIO_OPT_G_CACHE,
2077 .type = FIO_OPT_INT,
2078 .off1 = td_var_offset(cpuload),
2079 .help = "Use this percentage of CPU",
2080 .category = FIO_OPT_G_CPU,
2083 .name = "cpuchunks",
2084 .type = FIO_OPT_INT,
2085 .off1 = td_var_offset(cpucycle),
2086 .help = "Length of the CPU burn cycles (usecs)",
2088 .parent = "cpuload",
2089 .category = FIO_OPT_G_CPU,
2091 #ifdef FIO_HAVE_CPU_AFFINITY
2094 .type = FIO_OPT_INT,
2095 .cb = str_cpumask_cb,
2096 .help = "CPU affinity mask",
2097 .category = FIO_OPT_G_CPU | FIO_OPT_G_OS,
2100 .name = "cpus_allowed",
2101 .type = FIO_OPT_STR,
2102 .cb = str_cpus_allowed_cb,
2103 .help = "Set CPUs allowed",
2104 .category = FIO_OPT_G_CPU | FIO_OPT_G_OS,
2108 .name = "end_fsync",
2109 .type = FIO_OPT_BOOL,
2110 .off1 = td_var_offset(end_fsync),
2111 .help = "Include fsync at the end of job",
2113 .category = FIO_OPT_G_FILE,
2116 .name = "fsync_on_close",
2117 .type = FIO_OPT_BOOL,
2118 .off1 = td_var_offset(fsync_on_close),
2119 .help = "fsync files on close",
2121 .category = FIO_OPT_G_FILE,
2125 .type = FIO_OPT_BOOL,
2126 .off1 = td_var_offset(unlink),
2127 .help = "Unlink created files after job has completed",
2129 .category = FIO_OPT_G_FILE,
2133 .type = FIO_OPT_STR_SET,
2134 .cb = str_exitall_cb,
2135 .help = "Terminate all jobs when one exits",
2136 .category = FIO_OPT_G_MISC | FIO_OPT_G_JOB,
2139 .name = "stonewall",
2140 .alias = "wait_for_previous",
2141 .type = FIO_OPT_STR_SET,
2142 .off1 = td_var_offset(stonewall),
2143 .help = "Insert a hard barrier between this job and previous",
2144 .category = FIO_OPT_G_MISC | FIO_OPT_G_JOB,
2147 .name = "new_group",
2148 .type = FIO_OPT_STR_SET,
2149 .off1 = td_var_offset(new_group),
2150 .help = "Mark the start of a new group (for reporting)",
2151 .category = FIO_OPT_G_MISC | FIO_OPT_G_JOB,
2155 .type = FIO_OPT_STR_SET,
2156 .off1 = td_var_offset(use_thread),
2157 .help = "Use threads instead of forks",
2158 .category = FIO_OPT_G_MISC | FIO_OPT_G_OS | FIO_OPT_G_JOB,
2161 .name = "write_bw_log",
2162 .type = FIO_OPT_STR,
2163 .off1 = td_var_offset(write_bw_log),
2164 .cb = str_write_bw_log_cb,
2165 .help = "Write log of bandwidth during run",
2166 .category = FIO_OPT_G_LOG,
2169 .name = "write_lat_log",
2170 .type = FIO_OPT_STR,
2171 .off1 = td_var_offset(write_lat_log),
2172 .cb = str_write_lat_log_cb,
2173 .help = "Write log of latency during run",
2174 .category = FIO_OPT_G_LOG,
2177 .name = "write_iops_log",
2178 .type = FIO_OPT_STR,
2179 .off1 = td_var_offset(write_iops_log),
2180 .cb = str_write_iops_log_cb,
2181 .help = "Write log of IOPS during run",
2182 .category = FIO_OPT_G_LOG,
2185 .name = "log_avg_msec",
2186 .type = FIO_OPT_INT,
2187 .off1 = td_var_offset(log_avg_msec),
2188 .help = "Average bw/iops/lat logs over this period of time",
2190 .category = FIO_OPT_G_LOG,
2193 .name = "hugepage-size",
2194 .type = FIO_OPT_INT,
2195 .off1 = td_var_offset(hugepage_size),
2196 .help = "When using hugepages, specify size of each page",
2197 .def = __fio_stringify(FIO_HUGE_PAGE),
2198 .category = FIO_OPT_G_OS | FIO_OPT_G_MEM,
2201 .name = "group_reporting",
2202 .type = FIO_OPT_STR_SET,
2203 .off1 = td_var_offset(group_reporting),
2204 .help = "Do reporting on a per-group basis",
2205 .category = FIO_OPT_G_MISC,
2208 .name = "zero_buffers",
2209 .type = FIO_OPT_STR_SET,
2210 .off1 = td_var_offset(zero_buffers),
2211 .help = "Init IO buffers to all zeroes",
2212 .category = FIO_OPT_G_IO_BUF,
2215 .name = "refill_buffers",
2216 .type = FIO_OPT_STR_SET,
2217 .off1 = td_var_offset(refill_buffers),
2218 .help = "Refill IO buffers on every IO submit",
2219 .category = FIO_OPT_G_IO_BUF,
2222 .name = "scramble_buffers",
2223 .type = FIO_OPT_BOOL,
2224 .off1 = td_var_offset(scramble_buffers),
2225 .help = "Slightly scramble buffers on every IO submit",
2227 .category = FIO_OPT_G_IO_BUF,
2230 .name = "buffer_compress_percentage",
2231 .type = FIO_OPT_INT,
2232 .off1 = td_var_offset(compress_percentage),
2235 .help = "How compressible the buffer is (approximately)",
2238 .name = "buffer_compress_chunk",
2239 .type = FIO_OPT_INT,
2240 .off1 = td_var_offset(compress_chunk),
2241 .parent = "buffer_compress_percentage",
2242 .help = "Size of compressible region in buffer",
2245 .name = "clat_percentiles",
2246 .type = FIO_OPT_BOOL,
2247 .off1 = td_var_offset(clat_percentiles),
2248 .help = "Enable the reporting of completion latency percentiles",
2250 .category = FIO_OPT_G_STAT,
2253 .name = "percentile_list",
2254 .type = FIO_OPT_FLOAT_LIST,
2255 .off1 = td_var_offset(percentile_list),
2256 .off2 = td_var_offset(overwrite_plist),
2257 .help = "Specify a custom list of percentiles to report",
2258 .maxlen = FIO_IO_U_LIST_MAX_LEN,
2261 .category = FIO_OPT_G_STAT,
2264 #ifdef FIO_HAVE_DISK_UTIL
2266 .name = "disk_util",
2267 .type = FIO_OPT_BOOL,
2268 .off1 = td_var_offset(do_disk_util),
2269 .help = "Log disk utilization statistics",
2271 .category = FIO_OPT_G_OS | FIO_OPT_G_STAT,
2275 .name = "gtod_reduce",
2276 .type = FIO_OPT_BOOL,
2277 .help = "Greatly reduce number of gettimeofday() calls",
2278 .cb = str_gtod_reduce_cb,
2280 .category = FIO_OPT_G_OS | FIO_OPT_G_MISC | FIO_OPT_G_STAT,
2283 .name = "disable_lat",
2284 .type = FIO_OPT_BOOL,
2285 .off1 = td_var_offset(disable_lat),
2286 .help = "Disable latency numbers",
2287 .parent = "gtod_reduce",
2289 .category = FIO_OPT_G_OS | FIO_OPT_G_MISC | FIO_OPT_G_STAT,
2292 .name = "disable_clat",
2293 .type = FIO_OPT_BOOL,
2294 .off1 = td_var_offset(disable_clat),
2295 .help = "Disable completion latency numbers",
2296 .parent = "gtod_reduce",
2298 .category = FIO_OPT_G_OS | FIO_OPT_G_MISC | FIO_OPT_G_STAT,
2301 .name = "disable_slat",
2302 .type = FIO_OPT_BOOL,
2303 .off1 = td_var_offset(disable_slat),
2304 .help = "Disable submission latency numbers",
2305 .parent = "gtod_reduce",
2307 .category = FIO_OPT_G_OS | FIO_OPT_G_MISC | FIO_OPT_G_STAT,
2310 .name = "disable_bw_measurement",
2311 .type = FIO_OPT_BOOL,
2312 .off1 = td_var_offset(disable_bw),
2313 .help = "Disable bandwidth logging",
2314 .parent = "gtod_reduce",
2316 .category = FIO_OPT_G_OS | FIO_OPT_G_MISC | FIO_OPT_G_STAT,
2320 .type = FIO_OPT_INT,
2321 .cb = str_gtod_cpu_cb,
2322 .help = "Set up dedicated gettimeofday() thread on this CPU",
2323 .verify = gtod_cpu_verify,
2324 .category = FIO_OPT_G_OS | FIO_OPT_G_MISC | FIO_OPT_G_STAT,
2327 .name = "continue_on_error",
2328 .type = FIO_OPT_STR,
2329 .off1 = td_var_offset(continue_on_error),
2330 .help = "Continue on non-fatal errors during IO",
2332 .category = FIO_OPT_G_MISC | FIO_OPT_G_ERR,
2335 .oval = ERROR_TYPE_NONE,
2336 .help = "Exit when an error is encountered",
2339 .oval = ERROR_TYPE_READ,
2340 .help = "Continue on read errors only",
2343 .oval = ERROR_TYPE_WRITE,
2344 .help = "Continue on write errors only",
2347 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
2348 .help = "Continue on any IO errors",
2351 .oval = ERROR_TYPE_VERIFY,
2352 .help = "Continue on verify errors only",
2355 .oval = ERROR_TYPE_ANY,
2356 .help = "Continue on all io and verify errors",
2359 .oval = ERROR_TYPE_NONE,
2360 .help = "Alias for 'none'",
2363 .oval = ERROR_TYPE_ANY,
2364 .help = "Alias for 'all'",
2370 .type = FIO_OPT_STR_STORE,
2371 .off1 = td_var_offset(profile),
2372 .help = "Select a specific builtin performance test",
2373 .category = FIO_OPT_G_MISC | FIO_OPT_G_JOB,
2377 .type = FIO_OPT_STR_STORE,
2378 .off1 = td_var_offset(cgroup),
2379 .help = "Add job to cgroup of this name",
2380 .category = FIO_OPT_G_MISC | FIO_OPT_G_OS,
2383 .name = "cgroup_weight",
2384 .type = FIO_OPT_INT,
2385 .off1 = td_var_offset(cgroup_weight),
2386 .help = "Use given weight for cgroup",
2389 .category = FIO_OPT_G_MISC | FIO_OPT_G_OS,
2392 .name = "cgroup_nodelete",
2393 .type = FIO_OPT_BOOL,
2394 .off1 = td_var_offset(cgroup_nodelete),
2395 .help = "Do not delete cgroups after job completion",
2397 .category = FIO_OPT_G_MISC | FIO_OPT_G_OS,
2401 .type = FIO_OPT_INT,
2402 .off1 = td_var_offset(uid),
2403 .help = "Run job with this user ID",
2404 .category = FIO_OPT_G_OS | FIO_OPT_G_JOB,
2408 .type = FIO_OPT_INT,
2409 .off1 = td_var_offset(gid),
2410 .help = "Run job with this group ID",
2411 .category = FIO_OPT_G_OS | FIO_OPT_G_JOB,
2415 .type = FIO_OPT_INT,
2416 .off1 = td_var_offset(flow_id),
2417 .help = "The flow index ID to use",
2419 .category = FIO_OPT_G_IO,
2423 .type = FIO_OPT_INT,
2424 .off1 = td_var_offset(flow),
2425 .help = "Weight for flow control of this job",
2426 .parent = "flow_id",
2428 .category = FIO_OPT_G_IO,
2431 .name = "flow_watermark",
2432 .type = FIO_OPT_INT,
2433 .off1 = td_var_offset(flow_watermark),
2434 .help = "High watermark for flow control. This option"
2435 " should be set to the same value for all threads"
2436 " with non-zero flow.",
2437 .parent = "flow_id",
2439 .category = FIO_OPT_G_IO,
2442 .name = "flow_sleep",
2443 .type = FIO_OPT_INT,
2444 .off1 = td_var_offset(flow_sleep),
2445 .help = "How many microseconds to sleep after being held"
2446 " back by the flow control mechanism",
2447 .parent = "flow_id",
2449 .category = FIO_OPT_G_IO,
2456 static void add_to_lopt(struct option *lopt, struct fio_option *o,
2457 const char *name, int val)
2459 lopt->name = (char *) name;
2461 if (o->type == FIO_OPT_STR_SET)
2462 lopt->has_arg = no_argument;
2464 lopt->has_arg = required_argument;
2467 static void options_to_lopts(struct fio_option *opts,
2468 struct option *long_options,
2469 int i, int option_type)
2471 struct fio_option *o = &opts[0];
2473 add_to_lopt(&long_options[i], o, o->name, option_type);
2476 add_to_lopt(&long_options[i], o, o->alias, option_type);
2481 assert(i < FIO_NR_OPTIONS);
2485 void fio_options_set_ioengine_opts(struct option *long_options,
2486 struct thread_data *td)
2491 while (long_options[i].name) {
2492 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
2493 memset(&long_options[i], 0, sizeof(*long_options));
2500 * Just clear out the prior ioengine options.
2505 options_to_lopts(td->io_ops->options, long_options, i,
2506 FIO_GETOPT_IOENGINE);
2509 void fio_options_dup_and_init(struct option *long_options)
2513 options_init(fio_options);
2516 while (long_options[i].name)
2519 options_to_lopts(fio_options, long_options, i, FIO_GETOPT_JOB);
2522 struct fio_keyword {
2528 static struct fio_keyword fio_keywords[] = {
2530 .word = "$pagesize",
2531 .desc = "Page size in the system",
2534 .word = "$mb_memory",
2535 .desc = "Megabytes of memory online",
2539 .desc = "Number of CPUs online in the system",
2546 void fio_keywords_init(void)
2548 unsigned long long mb_memory;
2552 sprintf(buf, "%lu", page_size);
2553 fio_keywords[0].replace = strdup(buf);
2555 mb_memory = os_phys_mem() / (1024 * 1024);
2556 sprintf(buf, "%llu", mb_memory);
2557 fio_keywords[1].replace = strdup(buf);
2560 sprintf(buf, "%lu", l);
2561 fio_keywords[2].replace = strdup(buf);
2566 static char *bc_calc(char *str)
2568 char buf[128], *tmp;
2573 * No math, just return string
2575 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
2576 !strchr(str, '/')) || strchr(str, '\''))
2580 * Split option from value, we only need to calculate the value
2582 tmp = strchr(str, '=');
2589 * Prevent buffer overflows; such a case isn't reasonable anyway
2591 if (strlen(str) >= 128 || strlen(tmp) > 100)
2594 sprintf(buf, "which %s > /dev/null", BC_APP);
2596 log_err("fio: bc is needed for performing math\n");
2600 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
2601 f = popen(buf, "r");
2606 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
2612 buf[(tmp - str) + ret - 1] = '\0';
2613 memcpy(buf, str, tmp - str);
2619 * Return a copy of the input string with substrings of the form ${VARNAME}
2620 * substituted with the value of the environment variable VARNAME. The
2621 * substitution always occurs, even if VARNAME is empty or the corresponding
2622 * environment variable undefined.
2624 static char *option_dup_subs(const char *opt)
2626 char out[OPT_LEN_MAX+1];
2627 char in[OPT_LEN_MAX+1];
2630 char *ch1, *ch2, *env;
2631 ssize_t nchr = OPT_LEN_MAX;
2634 if (strlen(opt) + 1 > OPT_LEN_MAX) {
2635 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
2639 in[OPT_LEN_MAX] = '\0';
2640 strncpy(in, opt, OPT_LEN_MAX);
2642 while (*inptr && nchr > 0) {
2643 if (inptr[0] == '$' && inptr[1] == '{') {
2644 ch2 = strchr(inptr, '}');
2645 if (ch2 && inptr+1 < ch2) {
2652 envlen = strlen(env);
2653 if (envlen <= nchr) {
2654 memcpy(outptr, env, envlen);
2664 *outptr++ = *inptr++;
2673 * Look for reserved variable names and replace them with real values
2675 static char *fio_keyword_replace(char *opt)
2681 for (i = 0; fio_keywords[i].word != NULL; i++) {
2682 struct fio_keyword *kw = &fio_keywords[i];
2684 while ((s = strstr(opt, kw->word)) != NULL) {
2685 char *new = malloc(strlen(opt) + 1);
2691 * Copy part of the string before the keyword and
2692 * sprintf() the replacement after it.
2694 memcpy(new, opt, olen);
2695 len = sprintf(new + olen, "%s", kw->replace);
2698 * If there's more in the original string, copy that
2701 opt += strlen(kw->word) + olen;
2703 memcpy(new + olen + len, opt, opt - o_org - 1);
2706 * replace opt and free the old opt
2716 * Check for potential math and invoke bc, if possible
2724 static char **dup_and_sub_options(char **opts, int num_opts)
2727 char **opts_copy = malloc(num_opts * sizeof(*opts));
2728 for (i = 0; i < num_opts; i++) {
2729 opts_copy[i] = option_dup_subs(opts[i]);
2732 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
2737 int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
2739 int i, ret, unknown;
2742 sort_options(opts, fio_options, num_opts);
2743 opts_copy = dup_and_sub_options(opts, num_opts);
2745 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
2746 struct fio_option *o;
2747 int newret = parse_option(opts_copy[i], opts[i], fio_options,
2756 opts_copy[i] = NULL;
2763 ret |= ioengine_load(td);
2765 sort_options(opts_copy, td->io_ops->options, num_opts);
2768 for (i = 0; i < num_opts; i++) {
2769 struct fio_option *o = NULL;
2775 newret = parse_option(opts_copy[i], opts[i],
2776 td->io_ops->options, &o,
2781 log_err("Bad option <%s>\n", opts[i]);
2784 opts_copy[i] = NULL;
2792 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
2794 return parse_cmd_option(opt, val, fio_options, td);
2797 int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
2800 return parse_cmd_option(opt, val, td->io_ops->options, td);
2803 void fio_fill_default_options(struct thread_data *td)
2805 fill_default_options(td, fio_options);
2808 int fio_show_option_help(const char *opt)
2810 return show_cmd_help(fio_options, opt);
2813 void options_mem_dupe(void *data, struct fio_option *options)
2815 struct fio_option *o;
2818 for (o = &options[0]; o->name; o++) {
2819 if (o->type != FIO_OPT_STR_STORE)
2822 ptr = td_var(data, o->off1);
2824 *ptr = strdup(*ptr);
2829 * dupe FIO_OPT_STR_STORE options
2831 void fio_options_mem_dupe(struct thread_data *td)
2833 options_mem_dupe(&td->o, fio_options);
2835 if (td->eo && td->io_ops) {
2836 void *oldeo = td->eo;
2838 td->eo = malloc(td->io_ops->option_struct_size);
2839 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
2840 options_mem_dupe(td->eo, td->io_ops->options);
2844 unsigned int fio_get_kb_base(void *data)
2846 struct thread_data *td = data;
2847 unsigned int kb_base = 0;
2850 kb_base = td->o.kb_base;
2857 int add_option(struct fio_option *o)
2859 struct fio_option *__o;
2868 memcpy(&fio_options[opt_index], o, sizeof(*o));
2872 void invalidate_profile_options(const char *prof_name)
2874 struct fio_option *o;
2878 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
2879 o->type = FIO_OPT_INVALID;
2880 o->prof_name = NULL;
2886 void add_opt_posval(const char *optname, const char *ival, const char *help)
2888 struct fio_option *o;
2891 o = find_option(fio_options, optname);
2895 for (i = 0; i < PARSE_MAX_VP; i++) {
2896 if (o->posval[i].ival)
2899 o->posval[i].ival = ival;
2900 o->posval[i].help = help;
2905 void del_opt_posval(const char *optname, const char *ival)
2907 struct fio_option *o;
2910 o = find_option(fio_options, optname);
2914 for (i = 0; i < PARSE_MAX_VP; i++) {
2915 if (!o->posval[i].ival)
2917 if (strcmp(o->posval[i].ival, ival))
2920 o->posval[i].ival = NULL;
2921 o->posval[i].help = NULL;
2925 void fio_options_free(struct thread_data *td)
2927 options_free(fio_options, td);
2928 if (td->eo && td->io_ops && td->io_ops->options) {
2929 options_free(td->io_ops->options, td->eo);