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",
846 * Map of job/command line options
848 static struct fio_option options[FIO_MAX_OPTS] = {
850 .name = "description",
851 .type = FIO_OPT_STR_STORE,
852 .off1 = td_var_offset(description),
853 .help = "Text job description",
854 .category = FIO_OPT_G_DESC,
858 .type = FIO_OPT_STR_STORE,
859 .off1 = td_var_offset(name),
860 .help = "Name of this job",
861 .category = FIO_OPT_G_DESC,
865 .type = FIO_OPT_STR_STORE,
866 .off1 = td_var_offset(directory),
867 .cb = str_directory_cb,
868 .help = "Directory to store files in",
869 .category = FIO_OPT_G_FILE,
873 .type = FIO_OPT_STR_STORE,
874 .off1 = td_var_offset(filename),
875 .cb = str_filename_cb,
876 .prio = -1, /* must come after "directory" */
877 .help = "File(s) to use for the workload",
878 .category = FIO_OPT_G_FILE,
883 .off1 = td_var_offset(kb_base),
884 .verify = kb_base_verify,
887 .help = "How many bytes per KB for reporting (1000 or 1024)",
888 .category = FIO_OPT_G_MISC,
893 .cb = str_lockfile_cb,
894 .off1 = td_var_offset(file_lock_mode),
895 .help = "Lock file when doing IO to it",
896 .parent = "filename",
898 .category = FIO_OPT_G_FILE,
901 .oval = FILE_LOCK_NONE,
902 .help = "No file locking",
904 { .ival = "exclusive",
905 .oval = FILE_LOCK_EXCLUSIVE,
906 .help = "Exclusive file lock",
910 .oval = FILE_LOCK_READWRITE,
911 .help = "Read vs write lock",
917 .type = FIO_OPT_STR_STORE,
918 .off1 = td_var_offset(opendir),
919 .cb = str_opendir_cb,
920 .help = "Recursively add files from this directory and down",
921 .category = FIO_OPT_G_FILE,
925 .alias = "readwrite",
928 .off1 = td_var_offset(td_ddir),
929 .help = "IO direction",
932 .category = FIO_OPT_G_IO_DDIR,
935 .oval = TD_DDIR_READ,
936 .help = "Sequential read",
939 .oval = TD_DDIR_WRITE,
940 .help = "Sequential write",
942 { .ival = "randread",
943 .oval = TD_DDIR_RANDREAD,
944 .help = "Random read",
946 { .ival = "randwrite",
947 .oval = TD_DDIR_RANDWRITE,
948 .help = "Random write",
952 .help = "Sequential read and write mix",
955 .oval = TD_DDIR_RANDRW,
956 .help = "Random read and write mix"
961 .name = "rw_sequencer",
963 .off1 = td_var_offset(rw_seq),
964 .help = "IO offset generator modifier",
966 .category = FIO_OPT_G_IO_DDIR,
968 { .ival = "sequential",
970 .help = "Generate sequential offsets",
972 { .ival = "identical",
973 .oval = RW_SEQ_IDENT,
974 .help = "Generate identical offsets",
981 .type = FIO_OPT_STR_STORE,
982 .off1 = td_var_offset(ioengine),
983 .help = "IO engine to use",
984 .def = FIO_PREFERRED_ENGINE,
985 .category = FIO_OPT_G_IO,
988 .help = "Use read/write",
991 .help = "Use pread/pwrite",
994 .help = "Use readv/writev",
996 #ifdef FIO_HAVE_LIBAIO
998 .help = "Linux native asynchronous IO",
1001 #ifdef FIO_HAVE_POSIXAIO
1002 { .ival = "posixaio",
1003 .help = "POSIX asynchronous IO",
1006 #ifdef FIO_HAVE_SOLARISAIO
1007 { .ival = "solarisaio",
1008 .help = "Solaris native asynchronous IO",
1011 #ifdef FIO_HAVE_WINDOWSAIO
1012 { .ival = "windowsaio",
1013 .help = "Windows native asynchronous IO"
1017 .help = "Memory mapped IO"
1019 #ifdef FIO_HAVE_SPLICE
1021 .help = "splice/vmsplice based IO",
1023 { .ival = "netsplice",
1024 .help = "splice/vmsplice to/from the network",
1027 #ifdef FIO_HAVE_SGIO
1029 .help = "SCSI generic v3 IO",
1033 .help = "Testing engine (no data transfer)",
1036 .help = "Network IO",
1038 #ifdef FIO_HAVE_SYSLET
1039 { .ival = "syslet-rw",
1040 .help = "syslet enabled async pread/pwrite IO",
1044 .help = "CPU cycle burner engine",
1046 #ifdef FIO_HAVE_GUASI
1048 .help = "GUASI IO engine",
1051 #ifdef FIO_HAVE_BINJECT
1052 { .ival = "binject",
1053 .help = "binject direct inject block engine",
1056 #ifdef FIO_HAVE_RDMA
1058 .help = "RDMA IO engine",
1061 { .ival = "external",
1062 .help = "Load external engine (append name)",
1068 .type = FIO_OPT_INT,
1069 .off1 = td_var_offset(iodepth),
1070 .help = "Number of IO buffers to keep in flight",
1073 .category = FIO_OPT_G_IO,
1076 .name = "iodepth_batch",
1077 .alias = "iodepth_batch_submit",
1078 .type = FIO_OPT_INT,
1079 .off1 = td_var_offset(iodepth_batch),
1080 .help = "Number of IO buffers to submit in one go",
1081 .parent = "iodepth",
1084 .category = FIO_OPT_G_IO,
1087 .name = "iodepth_batch_complete",
1088 .type = FIO_OPT_INT,
1089 .off1 = td_var_offset(iodepth_batch_complete),
1090 .help = "Number of IO buffers to retrieve in one go",
1091 .parent = "iodepth",
1094 .category = FIO_OPT_G_IO,
1097 .name = "iodepth_low",
1098 .type = FIO_OPT_INT,
1099 .off1 = td_var_offset(iodepth_low),
1100 .help = "Low water mark for queuing depth",
1101 .parent = "iodepth",
1102 .category = FIO_OPT_G_IO,
1106 .type = FIO_OPT_STR_VAL,
1108 .help = "Total size of device or files",
1109 .category = FIO_OPT_G_IO,
1112 .name = "fill_device",
1114 .type = FIO_OPT_BOOL,
1115 .off1 = td_var_offset(fill_device),
1116 .help = "Write until an ENOSPC error occurs",
1118 .category = FIO_OPT_G_IO,
1122 .type = FIO_OPT_STR_VAL,
1123 .off1 = td_var_offset(file_size_low),
1124 .off2 = td_var_offset(file_size_high),
1126 .help = "Size of individual files",
1127 .category = FIO_OPT_G_IO | FIO_OPT_G_FILE,
1131 .alias = "fileoffset",
1132 .type = FIO_OPT_STR_VAL,
1133 .off1 = td_var_offset(start_offset),
1134 .help = "Start IO from this offset",
1136 .category = FIO_OPT_G_IO,
1140 .alias = "blocksize",
1141 .type = FIO_OPT_INT,
1142 .off1 = td_var_offset(bs[DDIR_READ]),
1143 .off2 = td_var_offset(bs[DDIR_WRITE]),
1145 .help = "Block size unit",
1148 .category = FIO_OPT_G_IO,
1152 .alias = "blockalign",
1153 .type = FIO_OPT_INT,
1154 .off1 = td_var_offset(ba[DDIR_READ]),
1155 .off2 = td_var_offset(ba[DDIR_WRITE]),
1157 .help = "IO block offset alignment",
1159 .category = FIO_OPT_G_IO | FIO_OPT_G_IO_BUF,
1163 .alias = "blocksize_range",
1164 .type = FIO_OPT_RANGE,
1165 .off1 = td_var_offset(min_bs[DDIR_READ]),
1166 .off2 = td_var_offset(max_bs[DDIR_READ]),
1167 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
1168 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
1170 .help = "Set block size range (in more detail than bs)",
1172 .category = FIO_OPT_G_IO,
1176 .type = FIO_OPT_STR,
1177 .cb = str_bssplit_cb,
1178 .help = "Set a specific mix of block sizes",
1180 .category = FIO_OPT_G_IO,
1183 .name = "bs_unaligned",
1184 .alias = "blocksize_unaligned",
1185 .type = FIO_OPT_STR_SET,
1186 .off1 = td_var_offset(bs_unaligned),
1187 .help = "Don't sector align IO buffer sizes",
1189 .category = FIO_OPT_G_IO,
1192 .name = "randrepeat",
1193 .type = FIO_OPT_BOOL,
1194 .off1 = td_var_offset(rand_repeatable),
1195 .help = "Use repeatable random IO pattern",
1198 .category = FIO_OPT_G_IO | FIO_OPT_G_RAND,
1201 .name = "use_os_rand",
1202 .type = FIO_OPT_BOOL,
1203 .off1 = td_var_offset(use_os_rand),
1204 .help = "Set to use OS random generator",
1207 .category = FIO_OPT_G_RAND,
1210 .name = "norandommap",
1211 .type = FIO_OPT_STR_SET,
1212 .off1 = td_var_offset(norandommap),
1213 .help = "Accept potential duplicate random blocks",
1215 .category = FIO_OPT_G_RAND,
1218 .name = "softrandommap",
1219 .type = FIO_OPT_BOOL,
1220 .off1 = td_var_offset(softrandommap),
1221 .help = "Set norandommap if randommap allocation fails",
1222 .parent = "norandommap",
1224 .category = FIO_OPT_G_RAND,
1228 .alias = "nr_files",
1229 .type = FIO_OPT_INT,
1230 .off1 = td_var_offset(nr_files),
1231 .help = "Split job workload between this number of files",
1233 .category = FIO_OPT_G_FILE,
1236 .name = "openfiles",
1237 .type = FIO_OPT_INT,
1238 .off1 = td_var_offset(open_files),
1239 .help = "Number of files to keep open at the same time",
1240 .category = FIO_OPT_G_FILE,
1243 .name = "file_service_type",
1244 .type = FIO_OPT_STR,
1246 .off1 = td_var_offset(file_service_type),
1247 .help = "How to select which file to service next",
1248 .def = "roundrobin",
1249 .category = FIO_OPT_G_FILE,
1252 .oval = FIO_FSERVICE_RANDOM,
1253 .help = "Choose a file at random",
1255 { .ival = "roundrobin",
1256 .oval = FIO_FSERVICE_RR,
1257 .help = "Round robin select files",
1259 { .ival = "sequential",
1260 .oval = FIO_FSERVICE_SEQ,
1261 .help = "Finish one file before moving to the next",
1264 .parent = "nrfiles",
1266 #ifdef FIO_HAVE_FALLOCATE
1268 .name = "fallocate",
1269 .type = FIO_OPT_STR,
1270 .off1 = td_var_offset(fallocate_mode),
1271 .help = "Whether pre-allocation is performed when laying out files",
1273 .category = FIO_OPT_G_FILE,
1276 .oval = FIO_FALLOCATE_NONE,
1277 .help = "Do not pre-allocate space",
1280 .oval = FIO_FALLOCATE_POSIX,
1281 .help = "Use posix_fallocate()",
1283 #ifdef FIO_HAVE_LINUX_FALLOCATE
1285 .oval = FIO_FALLOCATE_KEEP_SIZE,
1286 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
1289 /* Compatibility with former boolean values */
1291 .oval = FIO_FALLOCATE_NONE,
1292 .help = "Alias for 'none'",
1295 .oval = FIO_FALLOCATE_POSIX,
1296 .help = "Alias for 'posix'",
1300 #endif /* FIO_HAVE_FALLOCATE */
1302 .name = "fadvise_hint",
1303 .type = FIO_OPT_BOOL,
1304 .off1 = td_var_offset(fadvise_hint),
1305 .help = "Use fadvise() to advise the kernel on IO pattern",
1307 .category = FIO_OPT_G_FILE,
1311 .type = FIO_OPT_INT,
1312 .off1 = td_var_offset(fsync_blocks),
1313 .help = "Issue fsync for writes every given number of blocks",
1315 .category = FIO_OPT_G_FILE,
1318 .name = "fdatasync",
1319 .type = FIO_OPT_INT,
1320 .off1 = td_var_offset(fdatasync_blocks),
1321 .help = "Issue fdatasync for writes every given number of blocks",
1323 .category = FIO_OPT_G_FILE,
1326 .name = "write_barrier",
1327 .type = FIO_OPT_INT,
1328 .off1 = td_var_offset(barrier_blocks),
1329 .help = "Make every Nth write a barrier write",
1331 .category = FIO_OPT_G_IO,
1333 #ifdef FIO_HAVE_SYNC_FILE_RANGE
1335 .name = "sync_file_range",
1337 { .ival = "wait_before",
1338 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
1339 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
1343 .oval = SYNC_FILE_RANGE_WRITE,
1344 .help = "SYNC_FILE_RANGE_WRITE",
1348 .ival = "wait_after",
1349 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
1350 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
1354 .type = FIO_OPT_STR_MULTI,
1356 .off1 = td_var_offset(sync_file_range),
1357 .help = "Use sync_file_range()",
1358 .category = FIO_OPT_G_FILE,
1363 .type = FIO_OPT_BOOL,
1364 .off1 = td_var_offset(odirect),
1365 .help = "Use O_DIRECT IO (negates buffered)",
1367 .category = FIO_OPT_G_IO,
1371 .type = FIO_OPT_BOOL,
1372 .off1 = td_var_offset(odirect),
1374 .help = "Use buffered IO (negates direct)",
1376 .category = FIO_OPT_G_IO,
1379 .name = "overwrite",
1380 .type = FIO_OPT_BOOL,
1381 .off1 = td_var_offset(overwrite),
1382 .help = "When writing, set whether to overwrite current data",
1384 .category = FIO_OPT_G_IO | FIO_OPT_G_FILE,
1388 .type = FIO_OPT_INT,
1389 .off1 = td_var_offset(loops),
1390 .help = "Number of times to run the job",
1392 .category = FIO_OPT_G_MISC,
1396 .type = FIO_OPT_INT,
1397 .off1 = td_var_offset(numjobs),
1398 .help = "Duplicate this job this many times",
1400 .category = FIO_OPT_G_MISC,
1403 .name = "startdelay",
1404 .type = FIO_OPT_STR_VAL_TIME,
1405 .off1 = td_var_offset(start_delay),
1406 .help = "Only start job when this period has passed",
1408 .category = FIO_OPT_G_MISC,
1413 .type = FIO_OPT_STR_VAL_TIME,
1414 .off1 = td_var_offset(timeout),
1415 .help = "Stop workload when this amount of time has passed",
1417 .category = FIO_OPT_G_MISC,
1420 .name = "time_based",
1421 .type = FIO_OPT_STR_SET,
1422 .off1 = td_var_offset(time_based),
1423 .help = "Keep running until runtime/timeout is met",
1424 .category = FIO_OPT_G_MISC,
1427 .name = "ramp_time",
1428 .type = FIO_OPT_STR_VAL_TIME,
1429 .off1 = td_var_offset(ramp_time),
1430 .help = "Ramp up time before measuring performance",
1431 .category = FIO_OPT_G_MISC,
1434 .name = "clocksource",
1435 .type = FIO_OPT_STR,
1436 .cb = fio_clock_source_cb,
1437 .off1 = td_var_offset(clocksource),
1438 .help = "What type of timing source to use",
1439 .category = FIO_OPT_G_OS,
1441 { .ival = "gettimeofday",
1443 .help = "Use gettimeofday(2) for timing",
1445 { .ival = "clock_gettime",
1446 .oval = CS_CGETTIME,
1447 .help = "Use clock_gettime(2) for timing",
1449 #ifdef ARCH_HAVE_CPU_CLOCK
1451 .oval = CS_CPUCLOCK,
1452 .help = "Use CPU private clock",
1460 .type = FIO_OPT_STR,
1462 .off1 = td_var_offset(mem_type),
1463 .help = "Backing type for IO buffers",
1465 .category = FIO_OPT_G_IO_BUF | FIO_OPT_G_MEM,
1469 .help = "Use malloc(3) for IO buffers",
1473 .help = "Use shared memory segments for IO buffers",
1475 #ifdef FIO_HAVE_HUGETLB
1476 { .ival = "shmhuge",
1477 .oval = MEM_SHMHUGE,
1478 .help = "Like shm, but use huge pages",
1483 .help = "Use mmap(2) (file or anon) for IO buffers",
1485 #ifdef FIO_HAVE_HUGETLB
1486 { .ival = "mmaphuge",
1487 .oval = MEM_MMAPHUGE,
1488 .help = "Like mmap, but use huge pages",
1494 .name = "iomem_align",
1495 .alias = "mem_align",
1496 .type = FIO_OPT_INT,
1497 .off1 = td_var_offset(mem_align),
1499 .help = "IO memory buffer offset alignment",
1502 .category = FIO_OPT_G_IO_BUF | FIO_OPT_G_MEM,
1506 .type = FIO_OPT_STR,
1507 .off1 = td_var_offset(verify),
1508 .help = "Verify data written",
1509 .cb = str_verify_cb,
1511 .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY,
1514 .oval = VERIFY_NONE,
1515 .help = "Don't do IO verification",
1519 .help = "Use md5 checksums for verification",
1522 .oval = VERIFY_CRC64,
1523 .help = "Use crc64 checksums for verification",
1526 .oval = VERIFY_CRC32,
1527 .help = "Use crc32 checksums for verification",
1529 { .ival = "crc32c-intel",
1530 .oval = VERIFY_CRC32C,
1531 .help = "Use crc32c checksums for verification (hw assisted, if available)",
1534 .oval = VERIFY_CRC32C,
1535 .help = "Use crc32c checksums for verification (hw assisted, if available)",
1538 .oval = VERIFY_CRC16,
1539 .help = "Use crc16 checksums for verification",
1542 .oval = VERIFY_CRC7,
1543 .help = "Use crc7 checksums for verification",
1546 .oval = VERIFY_SHA1,
1547 .help = "Use sha1 checksums for verification",
1550 .oval = VERIFY_SHA256,
1551 .help = "Use sha256 checksums for verification",
1554 .oval = VERIFY_SHA512,
1555 .help = "Use sha512 checksums for verification",
1558 .oval = VERIFY_META,
1559 .help = "Use io information",
1563 .oval = VERIFY_NULL,
1564 .help = "Pretend to verify",
1569 .name = "do_verify",
1570 .type = FIO_OPT_BOOL,
1571 .off1 = td_var_offset(do_verify),
1572 .help = "Run verification stage after write",
1575 .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY,
1578 .name = "verifysort",
1579 .type = FIO_OPT_BOOL,
1580 .off1 = td_var_offset(verifysort),
1581 .help = "Sort written verify blocks for read back",
1584 .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY,
1587 .name = "verify_interval",
1588 .type = FIO_OPT_INT,
1589 .off1 = td_var_offset(verify_interval),
1590 .minval = 2 * sizeof(struct verify_header),
1591 .help = "Store verify buffer header every N bytes",
1593 .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY,
1596 .name = "verify_offset",
1597 .type = FIO_OPT_INT,
1598 .help = "Offset verify header location by N bytes",
1600 .cb = str_verify_offset_cb,
1602 .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY,
1605 .name = "verify_pattern",
1606 .type = FIO_OPT_STR,
1607 .cb = str_verify_pattern_cb,
1608 .help = "Fill pattern for IO buffers",
1610 .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY,
1613 .name = "verify_fatal",
1614 .type = FIO_OPT_BOOL,
1615 .off1 = td_var_offset(verify_fatal),
1617 .help = "Exit on a single verify failure, don't continue",
1619 .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY | FIO_OPT_G_ERR,
1622 .name = "verify_dump",
1623 .type = FIO_OPT_BOOL,
1624 .off1 = td_var_offset(verify_dump),
1626 .help = "Dump contents of good and bad blocks on failure",
1628 .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY | FIO_OPT_G_ERR,
1631 .name = "verify_async",
1632 .type = FIO_OPT_INT,
1633 .off1 = td_var_offset(verify_async),
1635 .help = "Number of async verifier threads to use",
1637 .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY,
1640 .name = "verify_backlog",
1641 .type = FIO_OPT_STR_VAL,
1642 .off1 = td_var_offset(verify_backlog),
1643 .help = "Verify after this number of blocks are written",
1645 .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY,
1648 .name = "verify_backlog_batch",
1649 .type = FIO_OPT_INT,
1650 .off1 = td_var_offset(verify_batch),
1651 .help = "Verify this number of IO blocks",
1653 .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY,
1655 #ifdef FIO_HAVE_CPU_AFFINITY
1657 .name = "verify_async_cpus",
1658 .type = FIO_OPT_STR,
1659 .cb = str_verify_cpus_allowed_cb,
1660 .help = "Set CPUs allowed for async verify threads",
1661 .parent = "verify_async",
1662 .category = FIO_OPT_G_OS | FIO_OPT_G_CPU | FIO_OPT_G_VERIFY,
1665 #ifdef FIO_HAVE_TRIM
1667 .name = "trim_percentage",
1668 .type = FIO_OPT_INT,
1669 .cb = str_verify_trim_cb,
1671 .help = "Number of verify blocks to discard/trim",
1674 .category = FIO_OPT_G_IO,
1677 .name = "trim_verify_zero",
1678 .type = FIO_OPT_INT,
1679 .help = "Verify that trim/discarded blocks are returned as zeroes",
1680 .off1 = td_var_offset(trim_zero),
1681 .parent = "trim_percentage",
1683 .category = FIO_OPT_G_IO,
1686 .name = "trim_backlog",
1687 .type = FIO_OPT_STR_VAL,
1688 .off1 = td_var_offset(trim_backlog),
1689 .help = "Trim after this number of blocks are written",
1690 .parent = "trim_percentage",
1691 .category = FIO_OPT_G_IO,
1694 .name = "trim_backlog_batch",
1695 .type = FIO_OPT_INT,
1696 .off1 = td_var_offset(trim_batch),
1697 .help = "Trim this number of IO blocks",
1698 .parent = "trim_percentage",
1699 .category = FIO_OPT_G_IO,
1703 .name = "write_iolog",
1704 .type = FIO_OPT_STR_STORE,
1705 .off1 = td_var_offset(write_iolog_file),
1706 .help = "Store IO pattern to file",
1707 .category = FIO_OPT_G_IO | FIO_OPT_G_LOG,
1710 .name = "read_iolog",
1711 .type = FIO_OPT_STR_STORE,
1712 .off1 = td_var_offset(read_iolog_file),
1713 .help = "Playback IO pattern from file",
1714 .category = FIO_OPT_G_IO | FIO_OPT_G_LOG,
1717 .name = "replay_no_stall",
1718 .type = FIO_OPT_INT,
1719 .off1 = td_var_offset(no_stall),
1721 .parent = "read_iolog",
1722 .help = "Playback IO pattern file as fast as possible without stalls",
1723 .category = FIO_OPT_G_IO | FIO_OPT_G_LOG,
1726 .name = "replay_redirect",
1727 .type = FIO_OPT_STR_STORE,
1728 .off1 = td_var_offset(replay_redirect),
1729 .parent = "read_iolog",
1730 .help = "Replay all I/O onto this device, regardless of trace device",
1731 .category = FIO_OPT_G_IO | FIO_OPT_G_LOG,
1734 .name = "exec_prerun",
1735 .type = FIO_OPT_STR_STORE,
1736 .off1 = td_var_offset(exec_prerun),
1737 .help = "Execute this file prior to running job",
1738 .category = FIO_OPT_G_MISC | FIO_OPT_G_OS,
1741 .name = "exec_postrun",
1742 .type = FIO_OPT_STR_STORE,
1743 .off1 = td_var_offset(exec_postrun),
1744 .help = "Execute this file after running job",
1745 .category = FIO_OPT_G_MISC | FIO_OPT_G_OS,
1747 #ifdef FIO_HAVE_IOSCHED_SWITCH
1749 .name = "ioscheduler",
1750 .type = FIO_OPT_STR_STORE,
1751 .off1 = td_var_offset(ioscheduler),
1752 .help = "Use this IO scheduler on the backing device",
1753 .category = FIO_OPT_G_OS | FIO_OPT_G_IO,
1758 .type = FIO_OPT_STR_VAL,
1759 .off1 = td_var_offset(zone_size),
1760 .help = "Amount of data to read per zone",
1762 .category = FIO_OPT_G_IO | FIO_OPT_G_ZONE,
1765 .name = "zonerange",
1766 .type = FIO_OPT_STR_VAL,
1767 .off1 = td_var_offset(zone_range),
1768 .help = "Give size of an IO zone",
1770 .category = FIO_OPT_G_IO | FIO_OPT_G_ZONE,
1774 .type = FIO_OPT_STR_VAL,
1775 .off1 = td_var_offset(zone_skip),
1776 .help = "Space between IO zones",
1778 .category = FIO_OPT_G_IO | FIO_OPT_G_ZONE,
1782 .type = FIO_OPT_STR_VAL,
1783 .cb = str_lockmem_cb,
1784 .help = "Lock down this amount of memory",
1786 .category = FIO_OPT_G_OS | FIO_OPT_G_MEM,
1789 .name = "rwmixread",
1790 .type = FIO_OPT_INT,
1791 .cb = str_rwmix_read_cb,
1793 .help = "Percentage of mixed workload that is reads",
1795 .category = FIO_OPT_G_IO,
1798 .name = "rwmixwrite",
1799 .type = FIO_OPT_INT,
1800 .cb = str_rwmix_write_cb,
1802 .help = "Percentage of mixed workload that is writes",
1804 .category = FIO_OPT_G_IO,
1807 .name = "rwmixcycle",
1808 .type = FIO_OPT_DEPRECATED,
1809 .category = FIO_OPT_G_IO,
1813 .type = FIO_OPT_INT,
1814 .off1 = td_var_offset(nice),
1815 .help = "Set job CPU nice value",
1819 .category = FIO_OPT_G_OS | FIO_OPT_G_CPU,
1821 #ifdef FIO_HAVE_IOPRIO
1824 .type = FIO_OPT_INT,
1826 .help = "Set job IO priority value",
1829 .category = FIO_OPT_G_OS | FIO_OPT_G_CPU,
1832 .name = "prioclass",
1833 .type = FIO_OPT_INT,
1834 .cb = str_prioclass_cb,
1835 .help = "Set job IO priority class",
1838 .category = FIO_OPT_G_OS | FIO_OPT_G_CPU,
1842 .name = "thinktime",
1843 .type = FIO_OPT_INT,
1844 .off1 = td_var_offset(thinktime),
1845 .help = "Idle time between IO buffers (usec)",
1847 .category = FIO_OPT_G_MISC,
1850 .name = "thinktime_spin",
1851 .type = FIO_OPT_INT,
1852 .off1 = td_var_offset(thinktime_spin),
1853 .help = "Start think time by spinning this amount (usec)",
1855 .parent = "thinktime",
1856 .category = FIO_OPT_G_MISC,
1859 .name = "thinktime_blocks",
1860 .type = FIO_OPT_INT,
1861 .off1 = td_var_offset(thinktime_blocks),
1862 .help = "IO buffer period between 'thinktime'",
1864 .parent = "thinktime",
1865 .category = FIO_OPT_G_MISC,
1869 .type = FIO_OPT_INT,
1870 .off1 = td_var_offset(rate[0]),
1871 .off2 = td_var_offset(rate[1]),
1872 .help = "Set bandwidth rate",
1873 .category = FIO_OPT_G_IO,
1877 .type = FIO_OPT_INT,
1878 .off1 = td_var_offset(ratemin[0]),
1879 .off2 = td_var_offset(ratemin[1]),
1880 .help = "Job must meet this rate or it will be shutdown",
1882 .category = FIO_OPT_G_IO,
1885 .name = "rate_iops",
1886 .type = FIO_OPT_INT,
1887 .off1 = td_var_offset(rate_iops[0]),
1888 .off2 = td_var_offset(rate_iops[1]),
1889 .help = "Limit IO used to this number of IO operations/sec",
1890 .category = FIO_OPT_G_IO,
1893 .name = "rate_iops_min",
1894 .type = FIO_OPT_INT,
1895 .off1 = td_var_offset(rate_iops_min[0]),
1896 .off2 = td_var_offset(rate_iops_min[1]),
1897 .help = "Job must meet this rate or it will be shut down",
1898 .parent = "rate_iops",
1899 .category = FIO_OPT_G_IO,
1902 .name = "ratecycle",
1903 .type = FIO_OPT_INT,
1904 .off1 = td_var_offset(ratecycle),
1905 .help = "Window average for rate limits (msec)",
1908 .category = FIO_OPT_G_IO,
1911 .name = "invalidate",
1912 .type = FIO_OPT_BOOL,
1913 .off1 = td_var_offset(invalidate_cache),
1914 .help = "Invalidate buffer/page cache prior to running job",
1916 .category = FIO_OPT_G_IO | FIO_OPT_G_CACHE,
1920 .type = FIO_OPT_BOOL,
1921 .off1 = td_var_offset(sync_io),
1922 .help = "Use O_SYNC for buffered writes",
1924 .parent = "buffered",
1925 .category = FIO_OPT_G_IO | FIO_OPT_G_FILE,
1928 .name = "bwavgtime",
1929 .type = FIO_OPT_INT,
1930 .off1 = td_var_offset(bw_avg_time),
1931 .help = "Time window over which to calculate bandwidth"
1934 .parent = "write_bw_log",
1935 .category = FIO_OPT_G_LOG | FIO_OPT_G_STAT,
1938 .name = "iopsavgtime",
1939 .type = FIO_OPT_INT,
1940 .off1 = td_var_offset(iops_avg_time),
1941 .help = "Time window over which to calculate IOPS (msec)",
1943 .parent = "write_iops_log",
1944 .category = FIO_OPT_G_LOG | FIO_OPT_G_STAT,
1947 .name = "create_serialize",
1948 .type = FIO_OPT_BOOL,
1949 .off1 = td_var_offset(create_serialize),
1950 .help = "Serialize creating of job files",
1952 .category = FIO_OPT_G_FILE,
1955 .name = "create_fsync",
1956 .type = FIO_OPT_BOOL,
1957 .off1 = td_var_offset(create_fsync),
1958 .help = "fsync file after creation",
1960 .category = FIO_OPT_G_FILE,
1963 .name = "create_on_open",
1964 .type = FIO_OPT_BOOL,
1965 .off1 = td_var_offset(create_on_open),
1966 .help = "Create files when they are opened for IO",
1968 .category = FIO_OPT_G_FILE,
1972 .type = FIO_OPT_BOOL,
1973 .off1 = td_var_offset(pre_read),
1974 .help = "Pre-read files before starting official testing",
1976 .category = FIO_OPT_G_FILE | FIO_OPT_G_CACHE,
1980 .type = FIO_OPT_INT,
1981 .off1 = td_var_offset(cpuload),
1982 .help = "Use this percentage of CPU",
1983 .category = FIO_OPT_G_CPU,
1986 .name = "cpuchunks",
1987 .type = FIO_OPT_INT,
1988 .off1 = td_var_offset(cpucycle),
1989 .help = "Length of the CPU burn cycles (usecs)",
1991 .parent = "cpuload",
1992 .category = FIO_OPT_G_CPU,
1994 #ifdef FIO_HAVE_CPU_AFFINITY
1997 .type = FIO_OPT_INT,
1998 .cb = str_cpumask_cb,
1999 .help = "CPU affinity mask",
2000 .category = FIO_OPT_G_CPU | FIO_OPT_G_OS,
2003 .name = "cpus_allowed",
2004 .type = FIO_OPT_STR,
2005 .cb = str_cpus_allowed_cb,
2006 .help = "Set CPUs allowed",
2007 .category = FIO_OPT_G_CPU | FIO_OPT_G_OS,
2011 .name = "end_fsync",
2012 .type = FIO_OPT_BOOL,
2013 .off1 = td_var_offset(end_fsync),
2014 .help = "Include fsync at the end of job",
2016 .category = FIO_OPT_G_FILE,
2019 .name = "fsync_on_close",
2020 .type = FIO_OPT_BOOL,
2021 .off1 = td_var_offset(fsync_on_close),
2022 .help = "fsync files on close",
2024 .category = FIO_OPT_G_FILE,
2028 .type = FIO_OPT_BOOL,
2029 .off1 = td_var_offset(unlink),
2030 .help = "Unlink created files after job has completed",
2032 .category = FIO_OPT_G_FILE,
2036 .type = FIO_OPT_STR_SET,
2037 .cb = str_exitall_cb,
2038 .help = "Terminate all jobs when one exits",
2039 .category = FIO_OPT_G_MISC | FIO_OPT_G_JOB,
2042 .name = "stonewall",
2043 .alias = "wait_for_previous",
2044 .type = FIO_OPT_STR_SET,
2045 .off1 = td_var_offset(stonewall),
2046 .help = "Insert a hard barrier between this job and previous",
2047 .category = FIO_OPT_G_MISC | FIO_OPT_G_JOB,
2050 .name = "new_group",
2051 .type = FIO_OPT_STR_SET,
2052 .off1 = td_var_offset(new_group),
2053 .help = "Mark the start of a new group (for reporting)",
2054 .category = FIO_OPT_G_MISC | FIO_OPT_G_JOB,
2058 .type = FIO_OPT_STR_SET,
2059 .off1 = td_var_offset(use_thread),
2060 .help = "Use threads instead of forks",
2061 .category = FIO_OPT_G_MISC | FIO_OPT_G_OS | FIO_OPT_G_JOB,
2064 .name = "write_bw_log",
2065 .type = FIO_OPT_STR,
2066 .off1 = td_var_offset(write_bw_log),
2067 .cb = str_write_bw_log_cb,
2068 .help = "Write log of bandwidth during run",
2069 .category = FIO_OPT_G_LOG,
2072 .name = "write_lat_log",
2073 .type = FIO_OPT_STR,
2074 .off1 = td_var_offset(write_lat_log),
2075 .cb = str_write_lat_log_cb,
2076 .help = "Write log of latency during run",
2077 .category = FIO_OPT_G_LOG,
2080 .name = "write_iops_log",
2081 .type = FIO_OPT_STR,
2082 .off1 = td_var_offset(write_iops_log),
2083 .cb = str_write_iops_log_cb,
2084 .help = "Write log of IOPS during run",
2085 .category = FIO_OPT_G_LOG,
2088 .name = "log_avg_msec",
2089 .type = FIO_OPT_INT,
2090 .off1 = td_var_offset(log_avg_msec),
2091 .help = "Average bw/iops/lat logs over this period of time",
2093 .category = FIO_OPT_G_LOG,
2096 .name = "hugepage-size",
2097 .type = FIO_OPT_INT,
2098 .off1 = td_var_offset(hugepage_size),
2099 .help = "When using hugepages, specify size of each page",
2100 .def = __fio_stringify(FIO_HUGE_PAGE),
2101 .category = FIO_OPT_G_OS | FIO_OPT_G_MEM,
2104 .name = "group_reporting",
2105 .type = FIO_OPT_STR_SET,
2106 .off1 = td_var_offset(group_reporting),
2107 .help = "Do reporting on a per-group basis",
2108 .category = FIO_OPT_G_MISC,
2111 .name = "zero_buffers",
2112 .type = FIO_OPT_STR_SET,
2113 .off1 = td_var_offset(zero_buffers),
2114 .help = "Init IO buffers to all zeroes",
2115 .category = FIO_OPT_G_IO_BUF,
2118 .name = "refill_buffers",
2119 .type = FIO_OPT_STR_SET,
2120 .off1 = td_var_offset(refill_buffers),
2121 .help = "Refill IO buffers on every IO submit",
2122 .category = FIO_OPT_G_IO_BUF,
2125 .name = "scramble_buffers",
2126 .type = FIO_OPT_BOOL,
2127 .off1 = td_var_offset(scramble_buffers),
2128 .help = "Slightly scramble buffers on every IO submit",
2130 .category = FIO_OPT_G_IO_BUF,
2133 .name = "buffer_compress_percentage",
2134 .type = FIO_OPT_INT,
2135 .off1 = td_var_offset(compress_percentage),
2138 .help = "How compressible the buffer is (approximately)",
2141 .name = "buffer_compress_chunk",
2142 .type = FIO_OPT_INT,
2143 .off1 = td_var_offset(compress_chunk),
2144 .parent = "buffer_compress_percentage",
2145 .help = "Size of compressible region in buffer",
2148 .name = "clat_percentiles",
2149 .type = FIO_OPT_BOOL,
2150 .off1 = td_var_offset(clat_percentiles),
2151 .help = "Enable the reporting of completion latency percentiles",
2153 .category = FIO_OPT_G_STAT,
2156 .name = "percentile_list",
2157 .type = FIO_OPT_FLOAT_LIST,
2158 .off1 = td_var_offset(percentile_list),
2159 .off2 = td_var_offset(overwrite_plist),
2160 .help = "Specify a custom list of percentiles to report",
2161 .maxlen = FIO_IO_U_LIST_MAX_LEN,
2164 .category = FIO_OPT_G_STAT,
2167 #ifdef FIO_HAVE_DISK_UTIL
2169 .name = "disk_util",
2170 .type = FIO_OPT_BOOL,
2171 .off1 = td_var_offset(do_disk_util),
2172 .help = "Log disk utilization statistics",
2174 .category = FIO_OPT_G_OS | FIO_OPT_G_STAT,
2178 .name = "gtod_reduce",
2179 .type = FIO_OPT_BOOL,
2180 .help = "Greatly reduce number of gettimeofday() calls",
2181 .cb = str_gtod_reduce_cb,
2183 .category = FIO_OPT_G_OS | FIO_OPT_G_MISC | FIO_OPT_G_STAT,
2186 .name = "disable_lat",
2187 .type = FIO_OPT_BOOL,
2188 .off1 = td_var_offset(disable_lat),
2189 .help = "Disable latency numbers",
2190 .parent = "gtod_reduce",
2192 .category = FIO_OPT_G_OS | FIO_OPT_G_MISC | FIO_OPT_G_STAT,
2195 .name = "disable_clat",
2196 .type = FIO_OPT_BOOL,
2197 .off1 = td_var_offset(disable_clat),
2198 .help = "Disable completion latency numbers",
2199 .parent = "gtod_reduce",
2201 .category = FIO_OPT_G_OS | FIO_OPT_G_MISC | FIO_OPT_G_STAT,
2204 .name = "disable_slat",
2205 .type = FIO_OPT_BOOL,
2206 .off1 = td_var_offset(disable_slat),
2207 .help = "Disable submission latency numbers",
2208 .parent = "gtod_reduce",
2210 .category = FIO_OPT_G_OS | FIO_OPT_G_MISC | FIO_OPT_G_STAT,
2213 .name = "disable_bw_measurement",
2214 .type = FIO_OPT_BOOL,
2215 .off1 = td_var_offset(disable_bw),
2216 .help = "Disable bandwidth logging",
2217 .parent = "gtod_reduce",
2219 .category = FIO_OPT_G_OS | FIO_OPT_G_MISC | FIO_OPT_G_STAT,
2223 .type = FIO_OPT_INT,
2224 .cb = str_gtod_cpu_cb,
2225 .help = "Set up dedicated gettimeofday() thread on this CPU",
2226 .verify = gtod_cpu_verify,
2227 .category = FIO_OPT_G_OS | FIO_OPT_G_MISC | FIO_OPT_G_STAT,
2230 .name = "continue_on_error",
2231 .type = FIO_OPT_STR,
2232 .off1 = td_var_offset(continue_on_error),
2233 .help = "Continue on non-fatal errors during IO",
2235 .category = FIO_OPT_G_MISC | FIO_OPT_G_ERR,
2238 .oval = ERROR_TYPE_NONE,
2239 .help = "Exit when an error is encountered",
2242 .oval = ERROR_TYPE_READ,
2243 .help = "Continue on read errors only",
2246 .oval = ERROR_TYPE_WRITE,
2247 .help = "Continue on write errors only",
2250 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
2251 .help = "Continue on any IO errors",
2254 .oval = ERROR_TYPE_VERIFY,
2255 .help = "Continue on verify errors only",
2258 .oval = ERROR_TYPE_ANY,
2259 .help = "Continue on all io and verify errors",
2262 .oval = ERROR_TYPE_NONE,
2263 .help = "Alias for 'none'",
2266 .oval = ERROR_TYPE_ANY,
2267 .help = "Alias for 'all'",
2273 .type = FIO_OPT_STR_STORE,
2274 .off1 = td_var_offset(profile),
2275 .help = "Select a specific builtin performance test",
2276 .category = FIO_OPT_G_MISC | FIO_OPT_G_JOB,
2280 .type = FIO_OPT_STR_STORE,
2281 .off1 = td_var_offset(cgroup),
2282 .help = "Add job to cgroup of this name",
2283 .category = FIO_OPT_G_MISC | FIO_OPT_G_OS,
2286 .name = "cgroup_weight",
2287 .type = FIO_OPT_INT,
2288 .off1 = td_var_offset(cgroup_weight),
2289 .help = "Use given weight for cgroup",
2292 .category = FIO_OPT_G_MISC | FIO_OPT_G_OS,
2295 .name = "cgroup_nodelete",
2296 .type = FIO_OPT_BOOL,
2297 .off1 = td_var_offset(cgroup_nodelete),
2298 .help = "Do not delete cgroups after job completion",
2300 .category = FIO_OPT_G_MISC | FIO_OPT_G_OS,
2304 .type = FIO_OPT_INT,
2305 .off1 = td_var_offset(uid),
2306 .help = "Run job with this user ID",
2307 .category = FIO_OPT_G_OS | FIO_OPT_G_JOB,
2311 .type = FIO_OPT_INT,
2312 .off1 = td_var_offset(gid),
2313 .help = "Run job with this group ID",
2314 .category = FIO_OPT_G_OS | FIO_OPT_G_JOB,
2318 .type = FIO_OPT_INT,
2319 .off1 = td_var_offset(flow_id),
2320 .help = "The flow index ID to use",
2322 .category = FIO_OPT_G_IO,
2326 .type = FIO_OPT_INT,
2327 .off1 = td_var_offset(flow),
2328 .help = "Weight for flow control of this job",
2329 .parent = "flow_id",
2331 .category = FIO_OPT_G_IO,
2334 .name = "flow_watermark",
2335 .type = FIO_OPT_INT,
2336 .off1 = td_var_offset(flow_watermark),
2337 .help = "High watermark for flow control. This option"
2338 " should be set to the same value for all threads"
2339 " with non-zero flow.",
2340 .parent = "flow_id",
2342 .category = FIO_OPT_G_IO,
2345 .name = "flow_sleep",
2346 .type = FIO_OPT_INT,
2347 .off1 = td_var_offset(flow_sleep),
2348 .help = "How many microseconds to sleep after being held"
2349 " back by the flow control mechanism",
2350 .parent = "flow_id",
2352 .category = FIO_OPT_G_IO,
2359 static void add_to_lopt(struct option *lopt, struct fio_option *o,
2360 const char *name, int val)
2362 lopt->name = (char *) name;
2364 if (o->type == FIO_OPT_STR_SET)
2365 lopt->has_arg = no_argument;
2367 lopt->has_arg = required_argument;
2370 static void options_to_lopts(struct fio_option *opts,
2371 struct option *long_options,
2372 int i, int option_type)
2374 struct fio_option *o = &opts[0];
2376 add_to_lopt(&long_options[i], o, o->name, option_type);
2379 add_to_lopt(&long_options[i], o, o->alias, option_type);
2384 assert(i < FIO_NR_OPTIONS);
2388 void fio_options_set_ioengine_opts(struct option *long_options,
2389 struct thread_data *td)
2394 while (long_options[i].name) {
2395 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
2396 memset(&long_options[i], 0, sizeof(*long_options));
2403 * Just clear out the prior ioengine options.
2408 options_to_lopts(td->io_ops->options, long_options, i,
2409 FIO_GETOPT_IOENGINE);
2412 void fio_options_dup_and_init(struct option *long_options)
2416 options_init(options);
2419 while (long_options[i].name)
2422 options_to_lopts(options, long_options, i, FIO_GETOPT_JOB);
2425 struct fio_keyword {
2431 static struct fio_keyword fio_keywords[] = {
2433 .word = "$pagesize",
2434 .desc = "Page size in the system",
2437 .word = "$mb_memory",
2438 .desc = "Megabytes of memory online",
2442 .desc = "Number of CPUs online in the system",
2449 void fio_keywords_init(void)
2451 unsigned long long mb_memory;
2455 sprintf(buf, "%lu", page_size);
2456 fio_keywords[0].replace = strdup(buf);
2458 mb_memory = os_phys_mem() / (1024 * 1024);
2459 sprintf(buf, "%llu", mb_memory);
2460 fio_keywords[1].replace = strdup(buf);
2463 sprintf(buf, "%lu", l);
2464 fio_keywords[2].replace = strdup(buf);
2469 static char *bc_calc(char *str)
2471 char buf[128], *tmp;
2476 * No math, just return string
2478 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
2479 !strchr(str, '/')) || strchr(str, '\''))
2483 * Split option from value, we only need to calculate the value
2485 tmp = strchr(str, '=');
2492 * Prevent buffer overflows; such a case isn't reasonable anyway
2494 if (strlen(str) >= 128 || strlen(tmp) > 100)
2497 sprintf(buf, "which %s > /dev/null", BC_APP);
2499 log_err("fio: bc is needed for performing math\n");
2503 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
2504 f = popen(buf, "r");
2509 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
2515 buf[(tmp - str) + ret - 1] = '\0';
2516 memcpy(buf, str, tmp - str);
2522 * Return a copy of the input string with substrings of the form ${VARNAME}
2523 * substituted with the value of the environment variable VARNAME. The
2524 * substitution always occurs, even if VARNAME is empty or the corresponding
2525 * environment variable undefined.
2527 static char *option_dup_subs(const char *opt)
2529 char out[OPT_LEN_MAX+1];
2530 char in[OPT_LEN_MAX+1];
2533 char *ch1, *ch2, *env;
2534 ssize_t nchr = OPT_LEN_MAX;
2537 if (strlen(opt) + 1 > OPT_LEN_MAX) {
2538 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
2542 in[OPT_LEN_MAX] = '\0';
2543 strncpy(in, opt, OPT_LEN_MAX);
2545 while (*inptr && nchr > 0) {
2546 if (inptr[0] == '$' && inptr[1] == '{') {
2547 ch2 = strchr(inptr, '}');
2548 if (ch2 && inptr+1 < ch2) {
2555 envlen = strlen(env);
2556 if (envlen <= nchr) {
2557 memcpy(outptr, env, envlen);
2567 *outptr++ = *inptr++;
2576 * Look for reserved variable names and replace them with real values
2578 static char *fio_keyword_replace(char *opt)
2584 for (i = 0; fio_keywords[i].word != NULL; i++) {
2585 struct fio_keyword *kw = &fio_keywords[i];
2587 while ((s = strstr(opt, kw->word)) != NULL) {
2588 char *new = malloc(strlen(opt) + 1);
2594 * Copy part of the string before the keyword and
2595 * sprintf() the replacement after it.
2597 memcpy(new, opt, olen);
2598 len = sprintf(new + olen, "%s", kw->replace);
2601 * If there's more in the original string, copy that
2604 opt += strlen(kw->word) + olen;
2606 memcpy(new + olen + len, opt, opt - o_org - 1);
2609 * replace opt and free the old opt
2619 * Check for potential math and invoke bc, if possible
2627 static char **dup_and_sub_options(char **opts, int num_opts)
2630 char **opts_copy = malloc(num_opts * sizeof(*opts));
2631 for (i = 0; i < num_opts; i++) {
2632 opts_copy[i] = option_dup_subs(opts[i]);
2635 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
2640 int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
2642 int i, ret, unknown;
2645 sort_options(opts, options, num_opts);
2646 opts_copy = dup_and_sub_options(opts, num_opts);
2648 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
2649 struct fio_option *o;
2650 int newret = parse_option(opts_copy[i], opts[i], options, &o,
2659 opts_copy[i] = NULL;
2666 ret |= ioengine_load(td);
2668 sort_options(opts_copy, td->io_ops->options, num_opts);
2671 for (i = 0; i < num_opts; i++) {
2672 struct fio_option *o = NULL;
2678 newret = parse_option(opts_copy[i], opts[i],
2679 td->io_ops->options, &o,
2684 log_err("Bad option <%s>\n", opts[i]);
2687 opts_copy[i] = NULL;
2695 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
2697 return parse_cmd_option(opt, val, options, td);
2700 int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
2703 return parse_cmd_option(opt, val, td->io_ops->options, td);
2706 void fio_fill_default_options(struct thread_data *td)
2708 fill_default_options(td, options);
2711 int fio_show_option_help(const char *opt)
2713 return show_cmd_help(options, opt);
2716 void options_mem_dupe(void *data, struct fio_option *options)
2718 struct fio_option *o;
2721 for (o = &options[0]; o->name; o++) {
2722 if (o->type != FIO_OPT_STR_STORE)
2725 ptr = td_var(data, o->off1);
2727 *ptr = strdup(*ptr);
2732 * dupe FIO_OPT_STR_STORE options
2734 void fio_options_mem_dupe(struct thread_data *td)
2736 options_mem_dupe(&td->o, options);
2738 if (td->eo && td->io_ops) {
2739 void *oldeo = td->eo;
2741 td->eo = malloc(td->io_ops->option_struct_size);
2742 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
2743 options_mem_dupe(td->eo, td->io_ops->options);
2747 unsigned int fio_get_kb_base(void *data)
2749 struct thread_data *td = data;
2750 unsigned int kb_base = 0;
2753 kb_base = td->o.kb_base;
2760 int add_option(struct fio_option *o)
2762 struct fio_option *__o;
2771 memcpy(&options[opt_index], o, sizeof(*o));
2775 void invalidate_profile_options(const char *prof_name)
2777 struct fio_option *o;
2781 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
2782 o->type = FIO_OPT_INVALID;
2783 o->prof_name = NULL;
2789 void add_opt_posval(const char *optname, const char *ival, const char *help)
2791 struct fio_option *o;
2794 o = find_option(options, optname);
2798 for (i = 0; i < PARSE_MAX_VP; i++) {
2799 if (o->posval[i].ival)
2802 o->posval[i].ival = ival;
2803 o->posval[i].help = help;
2808 void del_opt_posval(const char *optname, const char *ival)
2810 struct fio_option *o;
2813 o = find_option(options, optname);
2817 for (i = 0; i < PARSE_MAX_VP; i++) {
2818 if (!o->posval[i].ival)
2820 if (strcmp(o->posval[i].ival, ival))
2823 o->posval[i].ival = NULL;
2824 o->posval[i].help = NULL;
2828 void fio_options_free(struct thread_data *td)
2830 options_free(options, td);
2831 if (td->eo && td->io_ops && td->io_ops->options) {
2832 options_free(td->io_ops->options, td->eo);