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[] = {
851 .mask = FIO_OPT_C_GENERAL,
855 .mask = FIO_OPT_C_IO,
859 .mask = FIO_OPT_C_FILE,
862 .name = "Statistics",
863 .mask = FIO_OPT_C_STAT,
867 .mask = FIO_OPT_C_LOG,
874 static struct opt_group *__opt_group_from_mask(struct opt_group *ogs, unsigned int *mask,
875 unsigned int inv_mask)
877 struct opt_group *og;
880 if (*mask == inv_mask || !*mask)
883 for (i = 0; ogs[i].name; i++) {
886 if (*mask & og->mask) {
887 *mask &= ~(og->mask);
895 struct opt_group *opt_group_from_mask(unsigned int *mask)
897 return __opt_group_from_mask(fio_opt_groups, mask, FIO_OPT_C_INVALID);
900 static struct opt_group fio_opt_cat_groups[] = {
903 .mask = FIO_OPT_G_RATE,
907 .mask = FIO_OPT_G_ZONE,
910 .name = "Read/write mix",
911 .mask = FIO_OPT_G_RWMIX,
915 .mask = FIO_OPT_G_VERIFY,
919 .mask = FIO_OPT_G_TRIM,
922 .name = "I/O Logging",
923 .mask = FIO_OPT_G_IOLOG,
927 .mask = FIO_OPT_G_IO_DEPTH,
931 .mask = FIO_OPT_G_IO_FLOW,
934 .name = "Description",
935 .mask = FIO_OPT_G_DESC,
939 .mask = FIO_OPT_G_FILENAME,
942 .name = "General I/O",
943 .mask = FIO_OPT_G_IO_BASIC,
947 .mask = FIO_OPT_G_CGROUP,
951 .mask = FIO_OPT_G_RUNTIME,
955 .mask = FIO_OPT_G_PROCESS,
958 .name = "Job credentials / priority",
959 .mask = FIO_OPT_G_CRED,
962 .name = "Clock settings",
963 .mask = FIO_OPT_G_CLOCK,
970 struct opt_group *opt_group_cat_from_mask(unsigned int *mask)
972 return __opt_group_from_mask(fio_opt_cat_groups, mask, FIO_OPT_G_INVALID);
976 * Map of job/command line options
978 struct fio_option fio_options[FIO_MAX_OPTS] = {
980 .name = "description",
981 .lname = "Description of job",
982 .type = FIO_OPT_STR_STORE,
983 .off1 = td_var_offset(description),
984 .help = "Text job description",
985 .category = FIO_OPT_C_GENERAL,
986 .group = FIO_OPT_G_DESC,
991 .type = FIO_OPT_STR_STORE,
992 .off1 = td_var_offset(name),
993 .help = "Name of this job",
994 .category = FIO_OPT_C_GENERAL,
995 .group = FIO_OPT_G_DESC,
999 .lname = "Filename(s)",
1000 .type = FIO_OPT_STR_STORE,
1001 .off1 = td_var_offset(filename),
1002 .cb = str_filename_cb,
1003 .prio = -1, /* must come after "directory" */
1004 .help = "File(s) to use for the workload",
1005 .category = FIO_OPT_C_FILE,
1006 .group = FIO_OPT_G_FILENAME,
1009 .name = "directory",
1010 .lname = "Directory",
1011 .type = FIO_OPT_STR_STORE,
1012 .off1 = td_var_offset(directory),
1013 .cb = str_directory_cb,
1014 .help = "Directory to store files in",
1015 .category = FIO_OPT_C_FILE,
1016 .group = FIO_OPT_G_FILENAME,
1020 .lname = "Lockfile",
1021 .type = FIO_OPT_STR,
1022 .cb = str_lockfile_cb,
1023 .off1 = td_var_offset(file_lock_mode),
1024 .help = "Lock file when doing IO to it",
1025 .parent = "filename",
1028 .category = FIO_OPT_C_FILE,
1029 .group = FIO_OPT_G_FILENAME,
1032 .oval = FILE_LOCK_NONE,
1033 .help = "No file locking",
1035 { .ival = "exclusive",
1036 .oval = FILE_LOCK_EXCLUSIVE,
1037 .help = "Exclusive file lock",
1040 .ival = "readwrite",
1041 .oval = FILE_LOCK_READWRITE,
1042 .help = "Read vs write lock",
1048 .lname = "Open directory",
1049 .type = FIO_OPT_STR_STORE,
1050 .off1 = td_var_offset(opendir),
1051 .cb = str_opendir_cb,
1052 .help = "Recursively add files from this directory and down",
1053 .category = FIO_OPT_C_FILE,
1054 .group = FIO_OPT_G_FILENAME,
1058 .lname = "Read/write",
1059 .alias = "readwrite",
1060 .type = FIO_OPT_STR,
1062 .off1 = td_var_offset(td_ddir),
1063 .help = "IO direction",
1065 .verify = rw_verify,
1066 .category = FIO_OPT_C_IO,
1067 .group = FIO_OPT_G_IO_BASIC,
1070 .oval = TD_DDIR_READ,
1071 .help = "Sequential read",
1074 .oval = TD_DDIR_WRITE,
1075 .help = "Sequential write",
1077 { .ival = "randread",
1078 .oval = TD_DDIR_RANDREAD,
1079 .help = "Random read",
1081 { .ival = "randwrite",
1082 .oval = TD_DDIR_RANDWRITE,
1083 .help = "Random write",
1087 .help = "Sequential read and write mix",
1090 .oval = TD_DDIR_RANDRW,
1091 .help = "Random read and write mix"
1096 .name = "rw_sequencer",
1097 .lname = "RW Sequencer",
1098 .type = FIO_OPT_STR,
1099 .off1 = td_var_offset(rw_seq),
1100 .help = "IO offset generator modifier",
1101 .def = "sequential",
1102 .category = FIO_OPT_C_IO,
1103 .group = FIO_OPT_G_IO_BASIC,
1105 { .ival = "sequential",
1107 .help = "Generate sequential offsets",
1109 { .ival = "identical",
1110 .oval = RW_SEQ_IDENT,
1111 .help = "Generate identical offsets",
1118 .lname = "IO Engine",
1119 .type = FIO_OPT_STR_STORE,
1120 .off1 = td_var_offset(ioengine),
1121 .help = "IO engine to use",
1122 .def = FIO_PREFERRED_ENGINE,
1123 .category = FIO_OPT_C_IO,
1124 .group = FIO_OPT_G_IO_BASIC,
1127 .help = "Use read/write",
1130 .help = "Use pread/pwrite",
1133 .help = "Use readv/writev",
1135 #ifdef FIO_HAVE_LIBAIO
1137 .help = "Linux native asynchronous IO",
1140 #ifdef FIO_HAVE_POSIXAIO
1141 { .ival = "posixaio",
1142 .help = "POSIX asynchronous IO",
1145 #ifdef FIO_HAVE_SOLARISAIO
1146 { .ival = "solarisaio",
1147 .help = "Solaris native asynchronous IO",
1150 #ifdef FIO_HAVE_WINDOWSAIO
1151 { .ival = "windowsaio",
1152 .help = "Windows native asynchronous IO"
1156 .help = "Memory mapped IO"
1158 #ifdef FIO_HAVE_SPLICE
1160 .help = "splice/vmsplice based IO",
1162 { .ival = "netsplice",
1163 .help = "splice/vmsplice to/from the network",
1166 #ifdef FIO_HAVE_SGIO
1168 .help = "SCSI generic v3 IO",
1172 .help = "Testing engine (no data transfer)",
1175 .help = "Network IO",
1177 #ifdef FIO_HAVE_SYSLET
1178 { .ival = "syslet-rw",
1179 .help = "syslet enabled async pread/pwrite IO",
1183 .help = "CPU cycle burner engine",
1185 #ifdef FIO_HAVE_GUASI
1187 .help = "GUASI IO engine",
1190 #ifdef FIO_HAVE_BINJECT
1191 { .ival = "binject",
1192 .help = "binject direct inject block engine",
1195 #ifdef FIO_HAVE_RDMA
1197 .help = "RDMA IO engine",
1200 { .ival = "external",
1201 .help = "Load external engine (append name)",
1207 .lname = "IO Depth",
1208 .type = FIO_OPT_INT,
1209 .off1 = td_var_offset(iodepth),
1210 .help = "Number of IO buffers to keep in flight",
1214 .category = FIO_OPT_C_IO,
1215 .group = FIO_OPT_G_IO_BASIC,
1218 .name = "iodepth_batch",
1219 .lname = "IO Depth batch",
1220 .alias = "iodepth_batch_submit",
1221 .type = FIO_OPT_INT,
1222 .off1 = td_var_offset(iodepth_batch),
1223 .help = "Number of IO buffers to submit in one go",
1224 .parent = "iodepth",
1229 .category = FIO_OPT_C_IO,
1230 .group = FIO_OPT_G_IO_BASIC,
1233 .name = "iodepth_batch_complete",
1234 .lname = "IO Depth batch complete",
1235 .type = FIO_OPT_INT,
1236 .off1 = td_var_offset(iodepth_batch_complete),
1237 .help = "Number of IO buffers to retrieve in one go",
1238 .parent = "iodepth",
1243 .category = FIO_OPT_C_IO,
1244 .group = FIO_OPT_G_IO_BASIC,
1247 .name = "iodepth_low",
1248 .lname = "IO Depth batch low",
1249 .type = FIO_OPT_INT,
1250 .off1 = td_var_offset(iodepth_low),
1251 .help = "Low water mark for queuing depth",
1252 .parent = "iodepth",
1255 .category = FIO_OPT_C_IO,
1256 .group = FIO_OPT_G_IO_BASIC,
1261 .type = FIO_OPT_STR_VAL,
1263 .help = "Total size of device or files",
1264 .interval = 1024 * 1024,
1265 .category = FIO_OPT_C_IO,
1266 .group = FIO_OPT_G_INVALID,
1269 .name = "fill_device",
1270 .lname = "Fill device",
1272 .type = FIO_OPT_BOOL,
1273 .off1 = td_var_offset(fill_device),
1274 .help = "Write until an ENOSPC error occurs",
1276 .category = FIO_OPT_C_FILE,
1277 .group = FIO_OPT_G_INVALID,
1281 .lname = "File size",
1282 .type = FIO_OPT_STR_VAL,
1283 .off1 = td_var_offset(file_size_low),
1284 .off2 = td_var_offset(file_size_high),
1286 .help = "Size of individual files",
1287 .interval = 1024 * 1024,
1288 .category = FIO_OPT_C_FILE,
1289 .group = FIO_OPT_G_INVALID,
1293 .lname = "IO offset",
1294 .alias = "fileoffset",
1295 .type = FIO_OPT_STR_VAL,
1296 .off1 = td_var_offset(start_offset),
1297 .help = "Start IO from this offset",
1299 .interval = 1024 * 1024,
1300 .category = FIO_OPT_C_IO,
1301 .group = FIO_OPT_G_INVALID,
1304 .name = "offset_increment",
1305 .lname = "IO offset increment",
1306 .type = FIO_OPT_STR_VAL,
1307 .off1 = td_var_offset(offset_increment),
1308 .help = "What is the increment from one offset to the next",
1312 .interval = 1024 * 1024,
1313 .category = FIO_OPT_C_IO,
1314 .group = FIO_OPT_G_INVALID,
1318 .lname = "Block size",
1319 .alias = "blocksize",
1320 .type = FIO_OPT_INT,
1321 .off1 = td_var_offset(bs[DDIR_READ]),
1322 .off2 = td_var_offset(bs[DDIR_WRITE]),
1324 .help = "Block size unit",
1329 .category = FIO_OPT_C_IO,
1330 .group = FIO_OPT_G_INVALID,
1334 .lname = "Block size align",
1335 .alias = "blockalign",
1336 .type = FIO_OPT_INT,
1337 .off1 = td_var_offset(ba[DDIR_READ]),
1338 .off2 = td_var_offset(ba[DDIR_WRITE]),
1340 .help = "IO block offset alignment",
1344 .category = FIO_OPT_C_IO,
1345 .group = FIO_OPT_G_INVALID,
1349 .lname = "Block size range",
1350 .alias = "blocksize_range",
1351 .type = FIO_OPT_RANGE,
1352 .off1 = td_var_offset(min_bs[DDIR_READ]),
1353 .off2 = td_var_offset(max_bs[DDIR_READ]),
1354 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
1355 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
1357 .help = "Set block size range (in more detail than bs)",
1361 .category = FIO_OPT_C_IO,
1362 .group = FIO_OPT_G_INVALID,
1366 .lname = "Block size split",
1367 .type = FIO_OPT_STR,
1368 .cb = str_bssplit_cb,
1369 .help = "Set a specific mix of block sizes",
1372 .category = FIO_OPT_C_IO,
1373 .group = FIO_OPT_G_INVALID,
1376 .name = "bs_unaligned",
1377 .lname = "Block size unaligned",
1378 .alias = "blocksize_unaligned",
1379 .type = FIO_OPT_STR_SET,
1380 .off1 = td_var_offset(bs_unaligned),
1381 .help = "Don't sector align IO buffer sizes",
1384 .category = FIO_OPT_C_IO,
1385 .group = FIO_OPT_G_INVALID,
1388 .name = "randrepeat",
1389 .lname = "Random repeatable",
1390 .type = FIO_OPT_BOOL,
1391 .off1 = td_var_offset(rand_repeatable),
1392 .help = "Use repeatable random IO pattern",
1396 .category = FIO_OPT_C_IO,
1397 .group = FIO_OPT_G_INVALID,
1400 .name = "use_os_rand",
1401 .lname = "Use OS random",
1402 .type = FIO_OPT_BOOL,
1403 .off1 = td_var_offset(use_os_rand),
1404 .help = "Set to use OS random generator",
1408 .category = FIO_OPT_C_IO,
1409 .group = FIO_OPT_G_INVALID,
1412 .name = "norandommap",
1413 .lname = "No randommap",
1414 .type = FIO_OPT_STR_SET,
1415 .off1 = td_var_offset(norandommap),
1416 .help = "Accept potential duplicate random blocks",
1419 .category = FIO_OPT_C_IO,
1420 .group = FIO_OPT_G_INVALID,
1423 .name = "softrandommap",
1424 .lname = "Soft randommap",
1425 .type = FIO_OPT_BOOL,
1426 .off1 = td_var_offset(softrandommap),
1427 .help = "Set norandommap if randommap allocation fails",
1428 .parent = "norandommap",
1431 .category = FIO_OPT_C_IO,
1432 .group = FIO_OPT_G_INVALID,
1436 .lname = "Number of files",
1437 .alias = "nr_files",
1438 .type = FIO_OPT_INT,
1439 .off1 = td_var_offset(nr_files),
1440 .help = "Split job workload between this number of files",
1443 .category = FIO_OPT_C_FILE,
1444 .group = FIO_OPT_G_INVALID,
1447 .name = "openfiles",
1448 .lname = "Number of open files",
1449 .type = FIO_OPT_INT,
1450 .off1 = td_var_offset(open_files),
1451 .help = "Number of files to keep open at the same time",
1452 .category = FIO_OPT_C_FILE,
1453 .group = FIO_OPT_G_INVALID,
1456 .name = "file_service_type",
1457 .lname = "File service type",
1458 .type = FIO_OPT_STR,
1460 .off1 = td_var_offset(file_service_type),
1461 .help = "How to select which file to service next",
1462 .def = "roundrobin",
1463 .category = FIO_OPT_C_FILE,
1464 .group = FIO_OPT_G_INVALID,
1467 .oval = FIO_FSERVICE_RANDOM,
1468 .help = "Choose a file at random",
1470 { .ival = "roundrobin",
1471 .oval = FIO_FSERVICE_RR,
1472 .help = "Round robin select files",
1474 { .ival = "sequential",
1475 .oval = FIO_FSERVICE_SEQ,
1476 .help = "Finish one file before moving to the next",
1479 .parent = "nrfiles",
1482 #ifdef FIO_HAVE_FALLOCATE
1484 .name = "fallocate",
1485 .lname = "Fallocate",
1486 .type = FIO_OPT_STR,
1487 .off1 = td_var_offset(fallocate_mode),
1488 .help = "Whether pre-allocation is performed when laying out files",
1490 .category = FIO_OPT_C_FILE,
1491 .group = FIO_OPT_G_INVALID,
1494 .oval = FIO_FALLOCATE_NONE,
1495 .help = "Do not pre-allocate space",
1498 .oval = FIO_FALLOCATE_POSIX,
1499 .help = "Use posix_fallocate()",
1501 #ifdef FIO_HAVE_LINUX_FALLOCATE
1503 .oval = FIO_FALLOCATE_KEEP_SIZE,
1504 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
1507 /* Compatibility with former boolean values */
1509 .oval = FIO_FALLOCATE_NONE,
1510 .help = "Alias for 'none'",
1513 .oval = FIO_FALLOCATE_POSIX,
1514 .help = "Alias for 'posix'",
1518 #endif /* FIO_HAVE_FALLOCATE */
1520 .name = "fadvise_hint",
1521 .lname = "Fadvise hint",
1522 .type = FIO_OPT_BOOL,
1523 .off1 = td_var_offset(fadvise_hint),
1524 .help = "Use fadvise() to advise the kernel on IO pattern",
1526 .category = FIO_OPT_C_FILE,
1527 .group = FIO_OPT_G_INVALID,
1532 .type = FIO_OPT_INT,
1533 .off1 = td_var_offset(fsync_blocks),
1534 .help = "Issue fsync for writes every given number of blocks",
1537 .category = FIO_OPT_C_FILE,
1538 .group = FIO_OPT_G_INVALID,
1541 .name = "fdatasync",
1542 .lname = "Fdatasync",
1543 .type = FIO_OPT_INT,
1544 .off1 = td_var_offset(fdatasync_blocks),
1545 .help = "Issue fdatasync for writes every given number of blocks",
1548 .category = FIO_OPT_C_FILE,
1549 .group = FIO_OPT_G_INVALID,
1552 .name = "write_barrier",
1553 .lname = "Write barrier",
1554 .type = FIO_OPT_INT,
1555 .off1 = td_var_offset(barrier_blocks),
1556 .help = "Make every Nth write a barrier write",
1559 .category = FIO_OPT_C_IO,
1560 .group = FIO_OPT_G_INVALID,
1562 #ifdef FIO_HAVE_SYNC_FILE_RANGE
1564 .name = "sync_file_range",
1565 .lname = "Sync file range",
1567 { .ival = "wait_before",
1568 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
1569 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
1573 .oval = SYNC_FILE_RANGE_WRITE,
1574 .help = "SYNC_FILE_RANGE_WRITE",
1578 .ival = "wait_after",
1579 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
1580 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
1584 .type = FIO_OPT_STR_MULTI,
1586 .off1 = td_var_offset(sync_file_range),
1587 .help = "Use sync_file_range()",
1588 .category = FIO_OPT_C_FILE,
1589 .group = FIO_OPT_G_INVALID,
1594 .lname = "Direct I/O",
1595 .type = FIO_OPT_BOOL,
1596 .off1 = td_var_offset(odirect),
1597 .help = "Use O_DIRECT IO (negates buffered)",
1599 .category = FIO_OPT_C_IO,
1600 .group = FIO_OPT_G_INVALID,
1604 .lname = "Buffered I/O",
1605 .type = FIO_OPT_BOOL,
1606 .off1 = td_var_offset(odirect),
1608 .help = "Use buffered IO (negates direct)",
1610 .category = FIO_OPT_C_IO,
1611 .group = FIO_OPT_G_INVALID,
1614 .name = "overwrite",
1615 .lname = "Overwrite",
1616 .type = FIO_OPT_BOOL,
1617 .off1 = td_var_offset(overwrite),
1618 .help = "When writing, set whether to overwrite current data",
1620 .category = FIO_OPT_C_FILE,
1621 .group = FIO_OPT_G_INVALID,
1626 .type = FIO_OPT_INT,
1627 .off1 = td_var_offset(loops),
1628 .help = "Number of times to run the job",
1631 .category = FIO_OPT_C_GENERAL,
1632 .group = FIO_OPT_G_RUNTIME,
1636 .lname = "Number of jobs",
1637 .type = FIO_OPT_INT,
1638 .off1 = td_var_offset(numjobs),
1639 .help = "Duplicate this job this many times",
1642 .category = FIO_OPT_C_GENERAL,
1643 .group = FIO_OPT_G_RUNTIME,
1646 .name = "startdelay",
1647 .lname = "Start delay",
1648 .type = FIO_OPT_STR_VAL_TIME,
1649 .off1 = td_var_offset(start_delay),
1650 .help = "Only start job when this period has passed",
1652 .category = FIO_OPT_C_GENERAL,
1653 .group = FIO_OPT_G_RUNTIME,
1659 .type = FIO_OPT_STR_VAL_TIME,
1660 .off1 = td_var_offset(timeout),
1661 .help = "Stop workload when this amount of time has passed",
1663 .category = FIO_OPT_C_GENERAL,
1664 .group = FIO_OPT_G_RUNTIME,
1667 .name = "time_based",
1668 .lname = "Time based",
1669 .type = FIO_OPT_STR_SET,
1670 .off1 = td_var_offset(time_based),
1671 .help = "Keep running until runtime/timeout is met",
1672 .category = FIO_OPT_C_GENERAL,
1673 .group = FIO_OPT_G_RUNTIME,
1676 .name = "ramp_time",
1677 .lname = "Ramp time",
1678 .type = FIO_OPT_STR_VAL_TIME,
1679 .off1 = td_var_offset(ramp_time),
1680 .help = "Ramp up time before measuring performance",
1681 .category = FIO_OPT_C_GENERAL,
1682 .group = FIO_OPT_G_RUNTIME,
1685 .name = "clocksource",
1686 .lname = "Clock source",
1687 .type = FIO_OPT_STR,
1688 .cb = fio_clock_source_cb,
1689 .off1 = td_var_offset(clocksource),
1690 .help = "What type of timing source to use",
1691 .category = FIO_OPT_C_GENERAL,
1692 .group = FIO_OPT_G_CLOCK,
1694 { .ival = "gettimeofday",
1696 .help = "Use gettimeofday(2) for timing",
1698 { .ival = "clock_gettime",
1699 .oval = CS_CGETTIME,
1700 .help = "Use clock_gettime(2) for timing",
1702 #ifdef ARCH_HAVE_CPU_CLOCK
1704 .oval = CS_CPUCLOCK,
1705 .help = "Use CPU private clock",
1713 .lname = "I/O Memory",
1714 .type = FIO_OPT_STR,
1716 .off1 = td_var_offset(mem_type),
1717 .help = "Backing type for IO buffers",
1719 .category = FIO_OPT_C_IO,
1720 .group = FIO_OPT_G_INVALID,
1724 .help = "Use malloc(3) for IO buffers",
1728 .help = "Use shared memory segments for IO buffers",
1730 #ifdef FIO_HAVE_HUGETLB
1731 { .ival = "shmhuge",
1732 .oval = MEM_SHMHUGE,
1733 .help = "Like shm, but use huge pages",
1738 .help = "Use mmap(2) (file or anon) for IO buffers",
1740 #ifdef FIO_HAVE_HUGETLB
1741 { .ival = "mmaphuge",
1742 .oval = MEM_MMAPHUGE,
1743 .help = "Like mmap, but use huge pages",
1749 .name = "iomem_align",
1750 .alias = "mem_align",
1751 .lname = "I/O memory alignment",
1752 .type = FIO_OPT_INT,
1753 .off1 = td_var_offset(mem_align),
1755 .help = "IO memory buffer offset alignment",
1759 .category = FIO_OPT_C_IO,
1760 .group = FIO_OPT_G_INVALID,
1765 .type = FIO_OPT_STR,
1766 .off1 = td_var_offset(verify),
1767 .help = "Verify data written",
1768 .cb = str_verify_cb,
1770 .category = FIO_OPT_C_IO,
1771 .group = FIO_OPT_G_INVALID,
1774 .oval = VERIFY_NONE,
1775 .help = "Don't do IO verification",
1779 .help = "Use md5 checksums for verification",
1782 .oval = VERIFY_CRC64,
1783 .help = "Use crc64 checksums for verification",
1786 .oval = VERIFY_CRC32,
1787 .help = "Use crc32 checksums for verification",
1789 { .ival = "crc32c-intel",
1790 .oval = VERIFY_CRC32C,
1791 .help = "Use crc32c checksums for verification (hw assisted, if available)",
1794 .oval = VERIFY_CRC32C,
1795 .help = "Use crc32c checksums for verification (hw assisted, if available)",
1798 .oval = VERIFY_CRC16,
1799 .help = "Use crc16 checksums for verification",
1802 .oval = VERIFY_CRC7,
1803 .help = "Use crc7 checksums for verification",
1806 .oval = VERIFY_SHA1,
1807 .help = "Use sha1 checksums for verification",
1810 .oval = VERIFY_SHA256,
1811 .help = "Use sha256 checksums for verification",
1814 .oval = VERIFY_SHA512,
1815 .help = "Use sha512 checksums for verification",
1818 .oval = VERIFY_META,
1819 .help = "Use io information",
1823 .oval = VERIFY_NULL,
1824 .help = "Pretend to verify",
1829 .name = "do_verify",
1830 .lname = "Perform verify step",
1831 .type = FIO_OPT_BOOL,
1832 .off1 = td_var_offset(do_verify),
1833 .help = "Run verification stage after write",
1837 .category = FIO_OPT_C_IO,
1838 .group = FIO_OPT_G_VERIFY,
1841 .name = "verifysort",
1842 .lname = "Verify sort",
1843 .type = FIO_OPT_BOOL,
1844 .off1 = td_var_offset(verifysort),
1845 .help = "Sort written verify blocks for read back",
1849 .category = FIO_OPT_C_IO,
1850 .group = FIO_OPT_G_VERIFY,
1853 .name = "verify_interval",
1854 .lname = "Verify interval",
1855 .type = FIO_OPT_INT,
1856 .off1 = td_var_offset(verify_interval),
1857 .minval = 2 * sizeof(struct verify_header),
1858 .help = "Store verify buffer header every N bytes",
1861 .interval = 2 * sizeof(struct verify_header),
1862 .category = FIO_OPT_C_IO,
1863 .group = FIO_OPT_G_VERIFY,
1866 .name = "verify_offset",
1867 .lname = "Verify offset",
1868 .type = FIO_OPT_INT,
1869 .help = "Offset verify header location by N bytes",
1871 .cb = str_verify_offset_cb,
1874 .category = FIO_OPT_C_IO,
1875 .group = FIO_OPT_G_VERIFY,
1878 .name = "verify_pattern",
1879 .lname = "Verify pattern",
1880 .type = FIO_OPT_STR,
1881 .cb = str_verify_pattern_cb,
1882 .help = "Fill pattern for IO buffers",
1885 .category = FIO_OPT_C_IO,
1886 .group = FIO_OPT_G_VERIFY,
1889 .name = "verify_fatal",
1890 .lname = "Verify fatal",
1891 .type = FIO_OPT_BOOL,
1892 .off1 = td_var_offset(verify_fatal),
1894 .help = "Exit on a single verify failure, don't continue",
1897 .category = FIO_OPT_C_IO,
1898 .group = FIO_OPT_G_VERIFY,
1901 .name = "verify_dump",
1902 .lname = "Verify dump",
1903 .type = FIO_OPT_BOOL,
1904 .off1 = td_var_offset(verify_dump),
1906 .help = "Dump contents of good and bad blocks on failure",
1909 .category = FIO_OPT_C_IO,
1910 .group = FIO_OPT_G_VERIFY,
1913 .name = "verify_async",
1914 .lname = "Verify asynchronously",
1915 .type = FIO_OPT_INT,
1916 .off1 = td_var_offset(verify_async),
1918 .help = "Number of async verifier threads to use",
1921 .category = FIO_OPT_C_IO,
1922 .group = FIO_OPT_G_VERIFY,
1925 .name = "verify_backlog",
1926 .lname = "Verify backlog",
1927 .type = FIO_OPT_STR_VAL,
1928 .off1 = td_var_offset(verify_backlog),
1929 .help = "Verify after this number of blocks are written",
1932 .category = FIO_OPT_C_IO,
1933 .group = FIO_OPT_G_VERIFY,
1936 .name = "verify_backlog_batch",
1937 .lname = "Verify backlog batch",
1938 .type = FIO_OPT_INT,
1939 .off1 = td_var_offset(verify_batch),
1940 .help = "Verify this number of IO blocks",
1943 .category = FIO_OPT_C_IO,
1944 .group = FIO_OPT_G_VERIFY,
1946 #ifdef FIO_HAVE_CPU_AFFINITY
1948 .name = "verify_async_cpus",
1949 .lname = "Async verify CPUs",
1950 .type = FIO_OPT_STR,
1951 .cb = str_verify_cpus_allowed_cb,
1952 .help = "Set CPUs allowed for async verify threads",
1953 .parent = "verify_async",
1955 .category = FIO_OPT_C_IO,
1956 .group = FIO_OPT_G_VERIFY,
1959 #ifdef FIO_HAVE_TRIM
1961 .name = "trim_percentage",
1962 .lname = "Trim percentage",
1963 .type = FIO_OPT_INT,
1964 .cb = str_verify_trim_cb,
1967 .help = "Number of verify blocks to discard/trim",
1972 .category = FIO_OPT_C_IO,
1973 .group = FIO_OPT_G_TRIM,
1976 .name = "trim_verify_zero",
1977 .lname = "Verify trim zero",
1978 .type = FIO_OPT_BOOL,
1979 .help = "Verify that trim/discarded blocks are returned as zeroes",
1980 .off1 = td_var_offset(trim_zero),
1981 .parent = "trim_percentage",
1984 .category = FIO_OPT_C_IO,
1985 .group = FIO_OPT_G_TRIM,
1988 .name = "trim_backlog",
1989 .lname = "Trim backlog",
1990 .type = FIO_OPT_STR_VAL,
1991 .off1 = td_var_offset(trim_backlog),
1992 .help = "Trim after this number of blocks are written",
1993 .parent = "trim_percentage",
1996 .category = FIO_OPT_C_IO,
1997 .group = FIO_OPT_G_TRIM,
2000 .name = "trim_backlog_batch",
2001 .lname = "Trim backlog batch",
2002 .type = FIO_OPT_INT,
2003 .off1 = td_var_offset(trim_batch),
2004 .help = "Trim this number of IO blocks",
2005 .parent = "trim_percentage",
2008 .category = FIO_OPT_C_IO,
2009 .group = FIO_OPT_G_TRIM,
2013 .name = "write_iolog",
2014 .lname = "Write I/O log",
2015 .type = FIO_OPT_STR_STORE,
2016 .off1 = td_var_offset(write_iolog_file),
2017 .help = "Store IO pattern to file",
2018 .category = FIO_OPT_C_IO,
2019 .group = FIO_OPT_G_IOLOG,
2022 .name = "read_iolog",
2023 .lname = "Read I/O log",
2024 .type = FIO_OPT_STR_STORE,
2025 .off1 = td_var_offset(read_iolog_file),
2026 .help = "Playback IO pattern from file",
2027 .category = FIO_OPT_C_IO,
2028 .group = FIO_OPT_G_IOLOG,
2031 .name = "replay_no_stall",
2032 .lname = "Don't stall on replay",
2033 .type = FIO_OPT_BOOL,
2034 .off1 = td_var_offset(no_stall),
2036 .parent = "read_iolog",
2038 .help = "Playback IO pattern file as fast as possible without stalls",
2039 .category = FIO_OPT_C_IO,
2040 .group = FIO_OPT_G_IOLOG,
2043 .name = "replay_redirect",
2044 .lname = "Redirect device for replay",
2045 .type = FIO_OPT_STR_STORE,
2046 .off1 = td_var_offset(replay_redirect),
2047 .parent = "read_iolog",
2049 .help = "Replay all I/O onto this device, regardless of trace device",
2050 .category = FIO_OPT_C_IO,
2051 .group = FIO_OPT_G_IOLOG,
2054 .name = "exec_prerun",
2055 .lname = "Pre-execute runnable",
2056 .type = FIO_OPT_STR_STORE,
2057 .off1 = td_var_offset(exec_prerun),
2058 .help = "Execute this file prior to running job",
2059 .category = FIO_OPT_C_GENERAL,
2060 .group = FIO_OPT_G_INVALID,
2063 .name = "exec_postrun",
2064 .lname = "Post-execute runnable",
2065 .type = FIO_OPT_STR_STORE,
2066 .off1 = td_var_offset(exec_postrun),
2067 .help = "Execute this file after running job",
2068 .category = FIO_OPT_C_GENERAL,
2069 .group = FIO_OPT_G_INVALID,
2071 #ifdef FIO_HAVE_IOSCHED_SWITCH
2073 .name = "ioscheduler",
2074 .lname = "I/O scheduler",
2075 .type = FIO_OPT_STR_STORE,
2076 .off1 = td_var_offset(ioscheduler),
2077 .help = "Use this IO scheduler on the backing device",
2078 .category = FIO_OPT_C_FILE,
2079 .group = FIO_OPT_G_INVALID,
2084 .lname = "Zone size",
2085 .type = FIO_OPT_STR_VAL,
2086 .off1 = td_var_offset(zone_size),
2087 .help = "Amount of data to read per zone",
2089 .interval = 1024 * 1024,
2090 .category = FIO_OPT_C_IO,
2091 .group = FIO_OPT_G_ZONE,
2094 .name = "zonerange",
2095 .lname = "Zone range",
2096 .type = FIO_OPT_STR_VAL,
2097 .off1 = td_var_offset(zone_range),
2098 .help = "Give size of an IO zone",
2100 .interval = 1024 * 1024,
2101 .category = FIO_OPT_C_IO,
2102 .group = FIO_OPT_G_ZONE,
2106 .lname = "Zone skip",
2107 .type = FIO_OPT_STR_VAL,
2108 .off1 = td_var_offset(zone_skip),
2109 .help = "Space between IO zones",
2111 .interval = 1024 * 1024,
2112 .category = FIO_OPT_C_IO,
2113 .group = FIO_OPT_G_ZONE,
2117 .lname = "Lock memory",
2118 .type = FIO_OPT_STR_VAL,
2119 .cb = str_lockmem_cb,
2120 .help = "Lock down this amount of memory",
2122 .interval = 1024 * 1024,
2123 .category = FIO_OPT_C_GENERAL,
2124 .group = FIO_OPT_G_INVALID,
2127 .name = "rwmixread",
2128 .lname = "Read/write mix read",
2129 .type = FIO_OPT_INT,
2130 .cb = str_rwmix_read_cb,
2132 .help = "Percentage of mixed workload that is reads",
2135 .inverse = "rwmixwrite",
2136 .category = FIO_OPT_C_IO,
2137 .group = FIO_OPT_G_RWMIX,
2140 .name = "rwmixwrite",
2141 .lname = "Read/write mix write",
2142 .type = FIO_OPT_INT,
2143 .cb = str_rwmix_write_cb,
2145 .help = "Percentage of mixed workload that is writes",
2148 .inverse = "rwmixread",
2149 .category = FIO_OPT_C_IO,
2150 .group = FIO_OPT_G_RWMIX,
2153 .name = "rwmixcycle",
2154 .lname = "Read/write mix cycle",
2155 .type = FIO_OPT_DEPRECATED,
2156 .category = FIO_OPT_C_IO,
2157 .group = FIO_OPT_G_RWMIX,
2162 .type = FIO_OPT_INT,
2163 .off1 = td_var_offset(nice),
2164 .help = "Set job CPU nice value",
2169 .category = FIO_OPT_C_GENERAL,
2170 .group = FIO_OPT_G_CRED,
2172 #ifdef FIO_HAVE_IOPRIO
2175 .lname = "I/O nice priority",
2176 .type = FIO_OPT_INT,
2178 .help = "Set job IO priority value",
2182 .category = FIO_OPT_C_GENERAL,
2183 .group = FIO_OPT_G_CRED,
2186 .name = "prioclass",
2187 .lname = "I/O nice priority class",
2188 .type = FIO_OPT_INT,
2189 .cb = str_prioclass_cb,
2190 .help = "Set job IO priority class",
2194 .category = FIO_OPT_C_GENERAL,
2195 .group = FIO_OPT_G_CRED,
2199 .name = "thinktime",
2200 .lname = "Thinktime",
2201 .type = FIO_OPT_INT,
2202 .off1 = td_var_offset(thinktime),
2203 .help = "Idle time between IO buffers (usec)",
2205 .category = FIO_OPT_C_IO,
2206 .group = FIO_OPT_G_INVALID,
2209 .name = "thinktime_spin",
2210 .lname = "Thinktime spin",
2211 .type = FIO_OPT_INT,
2212 .off1 = td_var_offset(thinktime_spin),
2213 .help = "Start think time by spinning this amount (usec)",
2215 .parent = "thinktime",
2217 .category = FIO_OPT_C_IO,
2218 .group = FIO_OPT_G_INVALID,
2221 .name = "thinktime_blocks",
2222 .lname = "Thinktime blocks",
2223 .type = FIO_OPT_INT,
2224 .off1 = td_var_offset(thinktime_blocks),
2225 .help = "IO buffer period between 'thinktime'",
2227 .parent = "thinktime",
2229 .category = FIO_OPT_C_IO,
2230 .group = FIO_OPT_G_INVALID,
2234 .lname = "I/O rate",
2235 .type = FIO_OPT_INT,
2236 .off1 = td_var_offset(rate[0]),
2237 .off2 = td_var_offset(rate[1]),
2238 .help = "Set bandwidth rate",
2239 .category = FIO_OPT_C_IO,
2240 .group = FIO_OPT_G_RATE,
2244 .lname = "I/O min rate",
2245 .type = FIO_OPT_INT,
2246 .off1 = td_var_offset(ratemin[0]),
2247 .off2 = td_var_offset(ratemin[1]),
2248 .help = "Job must meet this rate or it will be shutdown",
2251 .category = FIO_OPT_C_IO,
2252 .group = FIO_OPT_G_RATE,
2255 .name = "rate_iops",
2256 .lname = "I/O rate IOPS",
2257 .type = FIO_OPT_INT,
2258 .off1 = td_var_offset(rate_iops[0]),
2259 .off2 = td_var_offset(rate_iops[1]),
2260 .help = "Limit IO used to this number of IO operations/sec",
2262 .category = FIO_OPT_C_IO,
2263 .group = FIO_OPT_G_RATE,
2266 .name = "rate_iops_min",
2267 .lname = "I/O min rate IOPS",
2268 .type = FIO_OPT_INT,
2269 .off1 = td_var_offset(rate_iops_min[0]),
2270 .off2 = td_var_offset(rate_iops_min[1]),
2271 .help = "Job must meet this rate or it will be shut down",
2272 .parent = "rate_iops",
2274 .category = FIO_OPT_C_IO,
2275 .group = FIO_OPT_G_RATE,
2278 .name = "ratecycle",
2279 .lname = "I/O rate cycle",
2280 .type = FIO_OPT_INT,
2281 .off1 = td_var_offset(ratecycle),
2282 .help = "Window average for rate limits (msec)",
2286 .category = FIO_OPT_C_IO,
2287 .group = FIO_OPT_G_RATE,
2290 .name = "invalidate",
2291 .lname = "Cache invalidate",
2292 .type = FIO_OPT_BOOL,
2293 .off1 = td_var_offset(invalidate_cache),
2294 .help = "Invalidate buffer/page cache prior to running job",
2296 .category = FIO_OPT_C_IO,
2297 .group = FIO_OPT_G_INVALID,
2301 .lname = "Synchronous I/O",
2302 .type = FIO_OPT_BOOL,
2303 .off1 = td_var_offset(sync_io),
2304 .help = "Use O_SYNC for buffered writes",
2306 .parent = "buffered",
2308 .category = FIO_OPT_C_IO,
2309 .group = FIO_OPT_G_INVALID,
2312 .name = "bwavgtime",
2313 .lname = "Bandwidth average time",
2314 .type = FIO_OPT_INT,
2315 .off1 = td_var_offset(bw_avg_time),
2316 .help = "Time window over which to calculate bandwidth"
2319 .parent = "write_bw_log",
2322 .category = FIO_OPT_C_LOG,
2323 .group = FIO_OPT_G_INVALID,
2326 .name = "iopsavgtime",
2327 .lname = "IOPS average time",
2328 .type = FIO_OPT_INT,
2329 .off1 = td_var_offset(iops_avg_time),
2330 .help = "Time window over which to calculate IOPS (msec)",
2332 .parent = "write_iops_log",
2335 .category = FIO_OPT_C_LOG,
2336 .group = FIO_OPT_G_INVALID,
2339 .name = "create_serialize",
2340 .lname = "Create serialize",
2341 .type = FIO_OPT_BOOL,
2342 .off1 = td_var_offset(create_serialize),
2343 .help = "Serialize creating of job files",
2345 .category = FIO_OPT_C_FILE,
2346 .group = FIO_OPT_G_INVALID,
2349 .name = "create_fsync",
2350 .lname = "Create fsync",
2351 .type = FIO_OPT_BOOL,
2352 .off1 = td_var_offset(create_fsync),
2353 .help = "fsync file after creation",
2355 .category = FIO_OPT_C_FILE,
2356 .group = FIO_OPT_G_INVALID,
2359 .name = "create_on_open",
2360 .lname = "Create on open",
2361 .type = FIO_OPT_BOOL,
2362 .off1 = td_var_offset(create_on_open),
2363 .help = "Create files when they are opened for IO",
2365 .category = FIO_OPT_C_FILE,
2366 .group = FIO_OPT_G_INVALID,
2370 .lname = "Pre-read files",
2371 .type = FIO_OPT_BOOL,
2372 .off1 = td_var_offset(pre_read),
2373 .help = "Pre-read files before starting official testing",
2375 .category = FIO_OPT_C_FILE,
2376 .group = FIO_OPT_G_INVALID,
2380 .lname = "CPU load",
2381 .type = FIO_OPT_INT,
2382 .off1 = td_var_offset(cpuload),
2383 .help = "Use this percentage of CPU",
2384 .category = FIO_OPT_C_GENERAL,
2385 .group = FIO_OPT_G_INVALID,
2388 .name = "cpuchunks",
2389 .lname = "CPU chunk",
2390 .type = FIO_OPT_INT,
2391 .off1 = td_var_offset(cpucycle),
2392 .help = "Length of the CPU burn cycles (usecs)",
2394 .parent = "cpuload",
2396 .category = FIO_OPT_C_GENERAL,
2397 .group = FIO_OPT_G_INVALID,
2399 #ifdef FIO_HAVE_CPU_AFFINITY
2402 .lname = "CPU mask",
2403 .type = FIO_OPT_INT,
2404 .cb = str_cpumask_cb,
2405 .help = "CPU affinity mask",
2406 .category = FIO_OPT_C_GENERAL,
2407 .group = FIO_OPT_G_CRED,
2410 .name = "cpus_allowed",
2411 .lname = "CPUs allowed",
2412 .type = FIO_OPT_STR,
2413 .cb = str_cpus_allowed_cb,
2414 .help = "Set CPUs allowed",
2415 .category = FIO_OPT_C_GENERAL,
2416 .group = FIO_OPT_G_CRED,
2420 .name = "end_fsync",
2421 .lname = "End fsync",
2422 .type = FIO_OPT_BOOL,
2423 .off1 = td_var_offset(end_fsync),
2424 .help = "Include fsync at the end of job",
2426 .category = FIO_OPT_C_FILE,
2427 .group = FIO_OPT_G_INVALID,
2430 .name = "fsync_on_close",
2431 .lname = "Fsync on close",
2432 .type = FIO_OPT_BOOL,
2433 .off1 = td_var_offset(fsync_on_close),
2434 .help = "fsync files on close",
2436 .category = FIO_OPT_C_FILE,
2437 .group = FIO_OPT_G_INVALID,
2441 .lname = "Unlink file",
2442 .type = FIO_OPT_BOOL,
2443 .off1 = td_var_offset(unlink),
2444 .help = "Unlink created files after job has completed",
2446 .category = FIO_OPT_C_FILE,
2447 .group = FIO_OPT_G_INVALID,
2451 .lname = "Exit-all on terminate",
2452 .type = FIO_OPT_STR_SET,
2453 .cb = str_exitall_cb,
2454 .help = "Terminate all jobs when one exits",
2455 .category = FIO_OPT_C_GENERAL,
2456 .group = FIO_OPT_G_PROCESS,
2459 .name = "stonewall",
2460 .lname = "Wait for previous",
2461 .alias = "wait_for_previous",
2462 .type = FIO_OPT_STR_SET,
2463 .off1 = td_var_offset(stonewall),
2464 .help = "Insert a hard barrier between this job and previous",
2465 .category = FIO_OPT_C_GENERAL,
2466 .group = FIO_OPT_G_PROCESS,
2469 .name = "new_group",
2470 .lname = "New group",
2471 .type = FIO_OPT_STR_SET,
2472 .off1 = td_var_offset(new_group),
2473 .help = "Mark the start of a new group (for reporting)",
2474 .category = FIO_OPT_C_GENERAL,
2475 .group = FIO_OPT_G_PROCESS,
2480 .type = FIO_OPT_STR_SET,
2481 .off1 = td_var_offset(use_thread),
2482 .help = "Use threads instead of processes",
2483 .category = FIO_OPT_C_GENERAL,
2484 .group = FIO_OPT_G_PROCESS,
2487 .name = "write_bw_log",
2488 .lname = "Write bandwidth log",
2489 .type = FIO_OPT_STR,
2490 .off1 = td_var_offset(write_bw_log),
2491 .cb = str_write_bw_log_cb,
2492 .help = "Write log of bandwidth during run",
2493 .category = FIO_OPT_C_LOG,
2494 .group = FIO_OPT_G_INVALID,
2497 .name = "write_lat_log",
2498 .lname = "Write latency log",
2499 .type = FIO_OPT_STR,
2500 .off1 = td_var_offset(write_lat_log),
2501 .cb = str_write_lat_log_cb,
2502 .help = "Write log of latency during run",
2503 .category = FIO_OPT_C_LOG,
2504 .group = FIO_OPT_G_INVALID,
2507 .name = "write_iops_log",
2508 .lname = "Write IOPS log",
2509 .type = FIO_OPT_STR,
2510 .off1 = td_var_offset(write_iops_log),
2511 .cb = str_write_iops_log_cb,
2512 .help = "Write log of IOPS during run",
2513 .category = FIO_OPT_C_LOG,
2514 .group = FIO_OPT_G_INVALID,
2517 .name = "log_avg_msec",
2518 .lname = "Log averaging (msec)",
2519 .type = FIO_OPT_INT,
2520 .off1 = td_var_offset(log_avg_msec),
2521 .help = "Average bw/iops/lat logs over this period of time",
2523 .category = FIO_OPT_C_LOG,
2524 .group = FIO_OPT_G_INVALID,
2527 .name = "hugepage-size",
2528 .lname = "Hugepage size",
2529 .type = FIO_OPT_INT,
2530 .off1 = td_var_offset(hugepage_size),
2531 .help = "When using hugepages, specify size of each page",
2532 .def = __fio_stringify(FIO_HUGE_PAGE),
2533 .interval = 1024 * 1024,
2534 .category = FIO_OPT_C_GENERAL,
2535 .group = FIO_OPT_G_INVALID,
2538 .name = "group_reporting",
2539 .lname = "Group reporting",
2540 .type = FIO_OPT_BOOL,
2541 .off1 = td_var_offset(group_reporting),
2542 .help = "Do reporting on a per-group basis",
2544 .category = FIO_OPT_C_STAT,
2545 .group = FIO_OPT_G_INVALID,
2548 .name = "zero_buffers",
2549 .lname = "Zero I/O buffers",
2550 .type = FIO_OPT_STR_SET,
2551 .off1 = td_var_offset(zero_buffers),
2552 .help = "Init IO buffers to all zeroes",
2553 .category = FIO_OPT_C_IO,
2554 .group = FIO_OPT_G_INVALID,
2557 .name = "refill_buffers",
2558 .lname = "Refill I/O buffers",
2559 .type = FIO_OPT_STR_SET,
2560 .off1 = td_var_offset(refill_buffers),
2561 .help = "Refill IO buffers on every IO submit",
2562 .category = FIO_OPT_C_IO,
2563 .group = FIO_OPT_G_INVALID,
2566 .name = "scramble_buffers",
2567 .lname = "Scramble I/O buffers",
2568 .type = FIO_OPT_BOOL,
2569 .off1 = td_var_offset(scramble_buffers),
2570 .help = "Slightly scramble buffers on every IO submit",
2572 .category = FIO_OPT_C_IO,
2573 .group = FIO_OPT_G_INVALID,
2576 .name = "buffer_compress_percentage",
2577 .lname = "Buffer compression percentage",
2578 .type = FIO_OPT_INT,
2579 .off1 = td_var_offset(compress_percentage),
2582 .help = "How compressible the buffer is (approximately)",
2584 .category = FIO_OPT_C_IO,
2585 .group = FIO_OPT_G_INVALID,
2588 .name = "buffer_compress_chunk",
2589 .lname = "Buffer compression chunk size",
2590 .type = FIO_OPT_INT,
2591 .off1 = td_var_offset(compress_chunk),
2592 .parent = "buffer_compress_percentage",
2594 .help = "Size of compressible region in buffer",
2596 .category = FIO_OPT_C_IO,
2597 .group = FIO_OPT_G_INVALID,
2600 .name = "clat_percentiles",
2601 .lname = "Completion latency percentiles",
2602 .type = FIO_OPT_BOOL,
2603 .off1 = td_var_offset(clat_percentiles),
2604 .help = "Enable the reporting of completion latency percentiles",
2606 .category = FIO_OPT_C_STAT,
2607 .group = FIO_OPT_G_INVALID,
2610 .name = "percentile_list",
2611 .lname = "Completion latency percentile list",
2612 .type = FIO_OPT_FLOAT_LIST,
2613 .off1 = td_var_offset(percentile_list),
2614 .off2 = td_var_offset(overwrite_plist),
2615 .help = "Specify a custom list of percentiles to report",
2616 .maxlen = FIO_IO_U_LIST_MAX_LEN,
2619 .category = FIO_OPT_C_STAT,
2620 .group = FIO_OPT_G_INVALID,
2623 #ifdef FIO_HAVE_DISK_UTIL
2625 .name = "disk_util",
2626 .lname = "Disk utilization",
2627 .type = FIO_OPT_BOOL,
2628 .off1 = td_var_offset(do_disk_util),
2629 .help = "Log disk utilization statistics",
2631 .category = FIO_OPT_C_STAT,
2632 .group = FIO_OPT_G_INVALID,
2636 .name = "gtod_reduce",
2637 .lname = "Reduce gettimeofday() calls",
2638 .type = FIO_OPT_BOOL,
2639 .help = "Greatly reduce number of gettimeofday() calls",
2640 .cb = str_gtod_reduce_cb,
2642 .category = FIO_OPT_C_STAT,
2643 .group = FIO_OPT_G_INVALID,
2646 .name = "disable_lat",
2647 .lname = "Disable all latency stats",
2648 .type = FIO_OPT_BOOL,
2649 .off1 = td_var_offset(disable_lat),
2650 .help = "Disable latency numbers",
2651 .parent = "gtod_reduce",
2654 .category = FIO_OPT_C_STAT,
2655 .group = FIO_OPT_G_INVALID,
2658 .name = "disable_clat",
2659 .lname = "Disable completion latency stats",
2660 .type = FIO_OPT_BOOL,
2661 .off1 = td_var_offset(disable_clat),
2662 .help = "Disable completion latency numbers",
2663 .parent = "gtod_reduce",
2666 .category = FIO_OPT_C_STAT,
2667 .group = FIO_OPT_G_INVALID,
2670 .name = "disable_slat",
2671 .lname = "Disable submission latency stats",
2672 .type = FIO_OPT_BOOL,
2673 .off1 = td_var_offset(disable_slat),
2674 .help = "Disable submission latency numbers",
2675 .parent = "gtod_reduce",
2678 .category = FIO_OPT_C_STAT,
2679 .group = FIO_OPT_G_INVALID,
2682 .name = "disable_bw_measurement",
2683 .lname = "Disable bandwidth stats",
2684 .type = FIO_OPT_BOOL,
2685 .off1 = td_var_offset(disable_bw),
2686 .help = "Disable bandwidth logging",
2687 .parent = "gtod_reduce",
2690 .category = FIO_OPT_C_STAT,
2691 .group = FIO_OPT_G_INVALID,
2695 .lname = "Dedicated gettimeofday() CPU",
2696 .type = FIO_OPT_INT,
2697 .cb = str_gtod_cpu_cb,
2698 .help = "Set up dedicated gettimeofday() thread on this CPU",
2699 .verify = gtod_cpu_verify,
2700 .category = FIO_OPT_C_GENERAL,
2701 .group = FIO_OPT_G_CLOCK,
2704 .name = "continue_on_error",
2705 .lname = "Continue on error",
2706 .type = FIO_OPT_STR,
2707 .off1 = td_var_offset(continue_on_error),
2708 .help = "Continue on non-fatal errors during IO",
2710 .category = FIO_OPT_C_GENERAL,
2711 .group = FIO_OPT_G_INVALID,
2714 .oval = ERROR_TYPE_NONE,
2715 .help = "Exit when an error is encountered",
2718 .oval = ERROR_TYPE_READ,
2719 .help = "Continue on read errors only",
2722 .oval = ERROR_TYPE_WRITE,
2723 .help = "Continue on write errors only",
2726 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
2727 .help = "Continue on any IO errors",
2730 .oval = ERROR_TYPE_VERIFY,
2731 .help = "Continue on verify errors only",
2734 .oval = ERROR_TYPE_ANY,
2735 .help = "Continue on all io and verify errors",
2738 .oval = ERROR_TYPE_NONE,
2739 .help = "Alias for 'none'",
2742 .oval = ERROR_TYPE_ANY,
2743 .help = "Alias for 'all'",
2750 .type = FIO_OPT_STR_STORE,
2751 .off1 = td_var_offset(profile),
2752 .help = "Select a specific builtin performance test",
2753 .category = FIO_OPT_C_GENERAL,
2754 .group = FIO_OPT_G_INVALID,
2759 .type = FIO_OPT_STR_STORE,
2760 .off1 = td_var_offset(cgroup),
2761 .help = "Add job to cgroup of this name",
2762 .category = FIO_OPT_C_GENERAL,
2763 .group = FIO_OPT_G_CGROUP,
2766 .name = "cgroup_nodelete",
2767 .lname = "Cgroup no-delete",
2768 .type = FIO_OPT_BOOL,
2769 .off1 = td_var_offset(cgroup_nodelete),
2770 .help = "Do not delete cgroups after job completion",
2773 .category = FIO_OPT_C_GENERAL,
2774 .group = FIO_OPT_G_CGROUP,
2777 .name = "cgroup_weight",
2778 .lname = "Cgroup weight",
2779 .type = FIO_OPT_INT,
2780 .off1 = td_var_offset(cgroup_weight),
2781 .help = "Use given weight for cgroup",
2785 .category = FIO_OPT_C_GENERAL,
2786 .group = FIO_OPT_G_CGROUP,
2791 .type = FIO_OPT_INT,
2792 .off1 = td_var_offset(uid),
2793 .help = "Run job with this user ID",
2794 .category = FIO_OPT_C_GENERAL,
2795 .group = FIO_OPT_G_CRED,
2799 .lname = "Group ID",
2800 .type = FIO_OPT_INT,
2801 .off1 = td_var_offset(gid),
2802 .help = "Run job with this group ID",
2803 .category = FIO_OPT_C_GENERAL,
2804 .group = FIO_OPT_G_CRED,
2809 .type = FIO_OPT_INT,
2810 .off1 = td_var_offset(kb_base),
2811 .verify = kb_base_verify,
2814 .help = "How many bytes per KB for reporting (1000 or 1024)",
2815 .category = FIO_OPT_C_GENERAL,
2816 .group = FIO_OPT_G_INVALID,
2820 .lname = "I/O flow ID",
2821 .type = FIO_OPT_INT,
2822 .off1 = td_var_offset(flow_id),
2823 .help = "The flow index ID to use",
2825 .category = FIO_OPT_C_IO,
2826 .group = FIO_OPT_G_IO_FLOW,
2830 .lname = "I/O flow weight",
2831 .type = FIO_OPT_INT,
2832 .off1 = td_var_offset(flow),
2833 .help = "Weight for flow control of this job",
2834 .parent = "flow_id",
2837 .category = FIO_OPT_C_IO,
2838 .group = FIO_OPT_G_IO_FLOW,
2841 .name = "flow_watermark",
2842 .lname = "I/O flow watermark",
2843 .type = FIO_OPT_INT,
2844 .off1 = td_var_offset(flow_watermark),
2845 .help = "High watermark for flow control. This option"
2846 " should be set to the same value for all threads"
2847 " with non-zero flow.",
2848 .parent = "flow_id",
2851 .category = FIO_OPT_C_IO,
2852 .group = FIO_OPT_G_IO_FLOW,
2855 .name = "flow_sleep",
2856 .lname = "I/O flow sleep",
2857 .type = FIO_OPT_INT,
2858 .off1 = td_var_offset(flow_sleep),
2859 .help = "How many microseconds to sleep after being held"
2860 " back by the flow control mechanism",
2861 .parent = "flow_id",
2864 .category = FIO_OPT_C_IO,
2865 .group = FIO_OPT_G_IO_FLOW,
2872 static void add_to_lopt(struct option *lopt, struct fio_option *o,
2873 const char *name, int val)
2875 lopt->name = (char *) name;
2877 if (o->type == FIO_OPT_STR_SET)
2878 lopt->has_arg = no_argument;
2880 lopt->has_arg = required_argument;
2883 static void options_to_lopts(struct fio_option *opts,
2884 struct option *long_options,
2885 int i, int option_type)
2887 struct fio_option *o = &opts[0];
2889 add_to_lopt(&long_options[i], o, o->name, option_type);
2892 add_to_lopt(&long_options[i], o, o->alias, option_type);
2897 assert(i < FIO_NR_OPTIONS);
2901 void fio_options_set_ioengine_opts(struct option *long_options,
2902 struct thread_data *td)
2907 while (long_options[i].name) {
2908 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
2909 memset(&long_options[i], 0, sizeof(*long_options));
2916 * Just clear out the prior ioengine options.
2921 options_to_lopts(td->io_ops->options, long_options, i,
2922 FIO_GETOPT_IOENGINE);
2925 void fio_options_dup_and_init(struct option *long_options)
2929 options_init(fio_options);
2932 while (long_options[i].name)
2935 options_to_lopts(fio_options, long_options, i, FIO_GETOPT_JOB);
2938 struct fio_keyword {
2944 static struct fio_keyword fio_keywords[] = {
2946 .word = "$pagesize",
2947 .desc = "Page size in the system",
2950 .word = "$mb_memory",
2951 .desc = "Megabytes of memory online",
2955 .desc = "Number of CPUs online in the system",
2962 void fio_keywords_init(void)
2964 unsigned long long mb_memory;
2968 sprintf(buf, "%lu", page_size);
2969 fio_keywords[0].replace = strdup(buf);
2971 mb_memory = os_phys_mem() / (1024 * 1024);
2972 sprintf(buf, "%llu", mb_memory);
2973 fio_keywords[1].replace = strdup(buf);
2976 sprintf(buf, "%lu", l);
2977 fio_keywords[2].replace = strdup(buf);
2982 static char *bc_calc(char *str)
2984 char buf[128], *tmp;
2989 * No math, just return string
2991 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
2992 !strchr(str, '/')) || strchr(str, '\''))
2996 * Split option from value, we only need to calculate the value
2998 tmp = strchr(str, '=');
3005 * Prevent buffer overflows; such a case isn't reasonable anyway
3007 if (strlen(str) >= 128 || strlen(tmp) > 100)
3010 sprintf(buf, "which %s > /dev/null", BC_APP);
3012 log_err("fio: bc is needed for performing math\n");
3016 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
3017 f = popen(buf, "r");
3022 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
3028 buf[(tmp - str) + ret - 1] = '\0';
3029 memcpy(buf, str, tmp - str);
3035 * Return a copy of the input string with substrings of the form ${VARNAME}
3036 * substituted with the value of the environment variable VARNAME. The
3037 * substitution always occurs, even if VARNAME is empty or the corresponding
3038 * environment variable undefined.
3040 static char *option_dup_subs(const char *opt)
3042 char out[OPT_LEN_MAX+1];
3043 char in[OPT_LEN_MAX+1];
3046 char *ch1, *ch2, *env;
3047 ssize_t nchr = OPT_LEN_MAX;
3050 if (strlen(opt) + 1 > OPT_LEN_MAX) {
3051 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
3055 in[OPT_LEN_MAX] = '\0';
3056 strncpy(in, opt, OPT_LEN_MAX);
3058 while (*inptr && nchr > 0) {
3059 if (inptr[0] == '$' && inptr[1] == '{') {
3060 ch2 = strchr(inptr, '}');
3061 if (ch2 && inptr+1 < ch2) {
3068 envlen = strlen(env);
3069 if (envlen <= nchr) {
3070 memcpy(outptr, env, envlen);
3080 *outptr++ = *inptr++;
3089 * Look for reserved variable names and replace them with real values
3091 static char *fio_keyword_replace(char *opt)
3097 for (i = 0; fio_keywords[i].word != NULL; i++) {
3098 struct fio_keyword *kw = &fio_keywords[i];
3100 while ((s = strstr(opt, kw->word)) != NULL) {
3101 char *new = malloc(strlen(opt) + 1);
3107 * Copy part of the string before the keyword and
3108 * sprintf() the replacement after it.
3110 memcpy(new, opt, olen);
3111 len = sprintf(new + olen, "%s", kw->replace);
3114 * If there's more in the original string, copy that
3117 opt += strlen(kw->word) + olen;
3119 memcpy(new + olen + len, opt, opt - o_org - 1);
3122 * replace opt and free the old opt
3132 * Check for potential math and invoke bc, if possible
3140 static char **dup_and_sub_options(char **opts, int num_opts)
3143 char **opts_copy = malloc(num_opts * sizeof(*opts));
3144 for (i = 0; i < num_opts; i++) {
3145 opts_copy[i] = option_dup_subs(opts[i]);
3148 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
3153 int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
3155 int i, ret, unknown;
3158 sort_options(opts, fio_options, num_opts);
3159 opts_copy = dup_and_sub_options(opts, num_opts);
3161 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
3162 struct fio_option *o;
3163 int newret = parse_option(opts_copy[i], opts[i], fio_options,
3172 opts_copy[i] = NULL;
3179 ret |= ioengine_load(td);
3181 sort_options(opts_copy, td->io_ops->options, num_opts);
3184 for (i = 0; i < num_opts; i++) {
3185 struct fio_option *o = NULL;
3191 newret = parse_option(opts_copy[i], opts[i],
3192 td->io_ops->options, &o,
3197 log_err("Bad option <%s>\n", opts[i]);
3200 opts_copy[i] = NULL;
3208 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
3210 return parse_cmd_option(opt, val, fio_options, td);
3213 int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
3216 return parse_cmd_option(opt, val, td->io_ops->options, td);
3219 void fio_fill_default_options(struct thread_data *td)
3221 fill_default_options(td, fio_options);
3224 int fio_show_option_help(const char *opt)
3226 return show_cmd_help(fio_options, opt);
3229 void options_mem_dupe(void *data, struct fio_option *options)
3231 struct fio_option *o;
3234 for (o = &options[0]; o->name; o++) {
3235 if (o->type != FIO_OPT_STR_STORE)
3238 ptr = td_var(data, o->off1);
3240 *ptr = strdup(*ptr);
3245 * dupe FIO_OPT_STR_STORE options
3247 void fio_options_mem_dupe(struct thread_data *td)
3249 options_mem_dupe(&td->o, fio_options);
3251 if (td->eo && td->io_ops) {
3252 void *oldeo = td->eo;
3254 td->eo = malloc(td->io_ops->option_struct_size);
3255 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
3256 options_mem_dupe(td->eo, td->io_ops->options);
3260 unsigned int fio_get_kb_base(void *data)
3262 struct thread_data *td = data;
3263 unsigned int kb_base = 0;
3266 kb_base = td->o.kb_base;
3273 int add_option(struct fio_option *o)
3275 struct fio_option *__o;
3284 memcpy(&fio_options[opt_index], o, sizeof(*o));
3288 void invalidate_profile_options(const char *prof_name)
3290 struct fio_option *o;
3294 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
3295 o->type = FIO_OPT_INVALID;
3296 o->prof_name = NULL;
3302 void add_opt_posval(const char *optname, const char *ival, const char *help)
3304 struct fio_option *o;
3307 o = find_option(fio_options, optname);
3311 for (i = 0; i < PARSE_MAX_VP; i++) {
3312 if (o->posval[i].ival)
3315 o->posval[i].ival = ival;
3316 o->posval[i].help = help;
3321 void del_opt_posval(const char *optname, const char *ival)
3323 struct fio_option *o;
3326 o = find_option(fio_options, optname);
3330 for (i = 0; i < PARSE_MAX_VP; i++) {
3331 if (!o->posval[i].ival)
3333 if (strcmp(o->posval[i].ival, ival))
3336 o->posval[i].ival = NULL;
3337 o->posval[i].help = NULL;
3341 void fio_options_free(struct thread_data *td)
3343 options_free(fio_options, td);
3344 if (td->eo && td->io_ops && td->io_ops->options) {
3345 options_free(td->io_ops->options, td->eo);