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,
950 struct opt_group *opt_group_cat_from_mask(unsigned int *mask)
952 return __opt_group_from_mask(fio_opt_cat_groups, mask, FIO_OPT_G_INVALID);
956 * Map of job/command line options
958 struct fio_option fio_options[FIO_MAX_OPTS] = {
960 .name = "description",
961 .lname = "Description of job",
962 .type = FIO_OPT_STR_STORE,
963 .off1 = td_var_offset(description),
964 .help = "Text job description",
965 .category = FIO_OPT_C_GENERAL,
966 .group = FIO_OPT_G_DESC,
971 .type = FIO_OPT_STR_STORE,
972 .off1 = td_var_offset(name),
973 .help = "Name of this job",
974 .category = FIO_OPT_C_GENERAL,
975 .group = FIO_OPT_G_DESC,
981 .off1 = td_var_offset(kb_base),
982 .verify = kb_base_verify,
985 .help = "How many bytes per KB for reporting (1000 or 1024)",
986 .category = FIO_OPT_C_GENERAL,
987 .group = FIO_OPT_G_INVALID,
991 .lname = "Filename(s)",
992 .type = FIO_OPT_STR_STORE,
993 .off1 = td_var_offset(filename),
994 .cb = str_filename_cb,
995 .prio = -1, /* must come after "directory" */
996 .help = "File(s) to use for the workload",
997 .category = FIO_OPT_C_FILE,
998 .group = FIO_OPT_G_FILENAME,
1001 .name = "directory",
1002 .lname = "Directory",
1003 .type = FIO_OPT_STR_STORE,
1004 .off1 = td_var_offset(directory),
1005 .cb = str_directory_cb,
1006 .help = "Directory to store files in",
1007 .category = FIO_OPT_C_FILE,
1008 .group = FIO_OPT_G_FILENAME,
1012 .lname = "Lockfile",
1013 .type = FIO_OPT_STR,
1014 .cb = str_lockfile_cb,
1015 .off1 = td_var_offset(file_lock_mode),
1016 .help = "Lock file when doing IO to it",
1017 .parent = "filename",
1020 .category = FIO_OPT_C_FILE,
1021 .group = FIO_OPT_G_FILENAME,
1024 .oval = FILE_LOCK_NONE,
1025 .help = "No file locking",
1027 { .ival = "exclusive",
1028 .oval = FILE_LOCK_EXCLUSIVE,
1029 .help = "Exclusive file lock",
1032 .ival = "readwrite",
1033 .oval = FILE_LOCK_READWRITE,
1034 .help = "Read vs write lock",
1040 .lname = "Open directory",
1041 .type = FIO_OPT_STR_STORE,
1042 .off1 = td_var_offset(opendir),
1043 .cb = str_opendir_cb,
1044 .help = "Recursively add files from this directory and down",
1045 .category = FIO_OPT_C_FILE,
1046 .group = FIO_OPT_G_FILENAME,
1050 .lname = "Read/write",
1051 .alias = "readwrite",
1052 .type = FIO_OPT_STR,
1054 .off1 = td_var_offset(td_ddir),
1055 .help = "IO direction",
1057 .verify = rw_verify,
1058 .category = FIO_OPT_C_IO,
1059 .group = FIO_OPT_G_IO_BASIC,
1062 .oval = TD_DDIR_READ,
1063 .help = "Sequential read",
1066 .oval = TD_DDIR_WRITE,
1067 .help = "Sequential write",
1069 { .ival = "randread",
1070 .oval = TD_DDIR_RANDREAD,
1071 .help = "Random read",
1073 { .ival = "randwrite",
1074 .oval = TD_DDIR_RANDWRITE,
1075 .help = "Random write",
1079 .help = "Sequential read and write mix",
1082 .oval = TD_DDIR_RANDRW,
1083 .help = "Random read and write mix"
1088 .name = "rw_sequencer",
1089 .lname = "RW Sequencer",
1090 .type = FIO_OPT_STR,
1091 .off1 = td_var_offset(rw_seq),
1092 .help = "IO offset generator modifier",
1093 .def = "sequential",
1094 .category = FIO_OPT_C_IO,
1095 .group = FIO_OPT_G_IO_BASIC,
1097 { .ival = "sequential",
1099 .help = "Generate sequential offsets",
1101 { .ival = "identical",
1102 .oval = RW_SEQ_IDENT,
1103 .help = "Generate identical offsets",
1110 .lname = "IO Engine",
1111 .type = FIO_OPT_STR_STORE,
1112 .off1 = td_var_offset(ioengine),
1113 .help = "IO engine to use",
1114 .def = FIO_PREFERRED_ENGINE,
1115 .category = FIO_OPT_C_IO,
1116 .group = FIO_OPT_G_IO_BASIC,
1119 .help = "Use read/write",
1122 .help = "Use pread/pwrite",
1125 .help = "Use readv/writev",
1127 #ifdef FIO_HAVE_LIBAIO
1129 .help = "Linux native asynchronous IO",
1132 #ifdef FIO_HAVE_POSIXAIO
1133 { .ival = "posixaio",
1134 .help = "POSIX asynchronous IO",
1137 #ifdef FIO_HAVE_SOLARISAIO
1138 { .ival = "solarisaio",
1139 .help = "Solaris native asynchronous IO",
1142 #ifdef FIO_HAVE_WINDOWSAIO
1143 { .ival = "windowsaio",
1144 .help = "Windows native asynchronous IO"
1148 .help = "Memory mapped IO"
1150 #ifdef FIO_HAVE_SPLICE
1152 .help = "splice/vmsplice based IO",
1154 { .ival = "netsplice",
1155 .help = "splice/vmsplice to/from the network",
1158 #ifdef FIO_HAVE_SGIO
1160 .help = "SCSI generic v3 IO",
1164 .help = "Testing engine (no data transfer)",
1167 .help = "Network IO",
1169 #ifdef FIO_HAVE_SYSLET
1170 { .ival = "syslet-rw",
1171 .help = "syslet enabled async pread/pwrite IO",
1175 .help = "CPU cycle burner engine",
1177 #ifdef FIO_HAVE_GUASI
1179 .help = "GUASI IO engine",
1182 #ifdef FIO_HAVE_BINJECT
1183 { .ival = "binject",
1184 .help = "binject direct inject block engine",
1187 #ifdef FIO_HAVE_RDMA
1189 .help = "RDMA IO engine",
1192 { .ival = "external",
1193 .help = "Load external engine (append name)",
1199 .lname = "IO Depth",
1200 .type = FIO_OPT_INT,
1201 .off1 = td_var_offset(iodepth),
1202 .help = "Number of IO buffers to keep in flight",
1206 .category = FIO_OPT_C_IO,
1207 .group = FIO_OPT_G_IO_BASIC,
1210 .name = "iodepth_batch",
1211 .lname = "IO Depth batch",
1212 .alias = "iodepth_batch_submit",
1213 .type = FIO_OPT_INT,
1214 .off1 = td_var_offset(iodepth_batch),
1215 .help = "Number of IO buffers to submit in one go",
1216 .parent = "iodepth",
1221 .category = FIO_OPT_C_IO,
1222 .group = FIO_OPT_G_IO_BASIC,
1225 .name = "iodepth_batch_complete",
1226 .lname = "IO Depth batch complete",
1227 .type = FIO_OPT_INT,
1228 .off1 = td_var_offset(iodepth_batch_complete),
1229 .help = "Number of IO buffers to retrieve in one go",
1230 .parent = "iodepth",
1235 .category = FIO_OPT_C_IO,
1236 .group = FIO_OPT_G_IO_BASIC,
1239 .name = "iodepth_low",
1240 .lname = "IO Depth batch low",
1241 .type = FIO_OPT_INT,
1242 .off1 = td_var_offset(iodepth_low),
1243 .help = "Low water mark for queuing depth",
1244 .parent = "iodepth",
1247 .category = FIO_OPT_C_IO,
1248 .group = FIO_OPT_G_IO_BASIC,
1253 .type = FIO_OPT_STR_VAL,
1255 .help = "Total size of device or files",
1256 .interval = 1024 * 1024,
1257 .category = FIO_OPT_C_IO,
1258 .group = FIO_OPT_G_INVALID,
1261 .name = "fill_device",
1262 .lname = "Fill device",
1264 .type = FIO_OPT_BOOL,
1265 .off1 = td_var_offset(fill_device),
1266 .help = "Write until an ENOSPC error occurs",
1268 .category = FIO_OPT_C_FILE,
1269 .group = FIO_OPT_G_INVALID,
1273 .lname = "File size",
1274 .type = FIO_OPT_STR_VAL,
1275 .off1 = td_var_offset(file_size_low),
1276 .off2 = td_var_offset(file_size_high),
1278 .help = "Size of individual files",
1279 .interval = 1024 * 1024,
1280 .category = FIO_OPT_C_FILE,
1281 .group = FIO_OPT_G_INVALID,
1285 .lname = "IO offset",
1286 .alias = "fileoffset",
1287 .type = FIO_OPT_STR_VAL,
1288 .off1 = td_var_offset(start_offset),
1289 .help = "Start IO from this offset",
1291 .interval = 1024 * 1024,
1292 .category = FIO_OPT_C_IO,
1293 .group = FIO_OPT_G_INVALID,
1296 .name = "offset_increment",
1297 .lname = "IO offset increment",
1298 .type = FIO_OPT_STR_VAL,
1299 .off1 = td_var_offset(offset_increment),
1300 .help = "What is the increment from one offset to the next",
1304 .interval = 1024 * 1024,
1305 .category = FIO_OPT_C_IO,
1306 .group = FIO_OPT_G_INVALID,
1310 .lname = "Block size",
1311 .alias = "blocksize",
1312 .type = FIO_OPT_INT,
1313 .off1 = td_var_offset(bs[DDIR_READ]),
1314 .off2 = td_var_offset(bs[DDIR_WRITE]),
1316 .help = "Block size unit",
1321 .category = FIO_OPT_C_IO,
1322 .group = FIO_OPT_G_INVALID,
1326 .lname = "Block size align",
1327 .alias = "blockalign",
1328 .type = FIO_OPT_INT,
1329 .off1 = td_var_offset(ba[DDIR_READ]),
1330 .off2 = td_var_offset(ba[DDIR_WRITE]),
1332 .help = "IO block offset alignment",
1336 .category = FIO_OPT_C_IO,
1337 .group = FIO_OPT_G_INVALID,
1341 .lname = "Block size range",
1342 .alias = "blocksize_range",
1343 .type = FIO_OPT_RANGE,
1344 .off1 = td_var_offset(min_bs[DDIR_READ]),
1345 .off2 = td_var_offset(max_bs[DDIR_READ]),
1346 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
1347 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
1349 .help = "Set block size range (in more detail than bs)",
1353 .category = FIO_OPT_C_IO,
1354 .group = FIO_OPT_G_INVALID,
1358 .lname = "Block size split",
1359 .type = FIO_OPT_STR,
1360 .cb = str_bssplit_cb,
1361 .help = "Set a specific mix of block sizes",
1364 .category = FIO_OPT_C_IO,
1365 .group = FIO_OPT_G_INVALID,
1368 .name = "bs_unaligned",
1369 .lname = "Block size unaligned",
1370 .alias = "blocksize_unaligned",
1371 .type = FIO_OPT_STR_SET,
1372 .off1 = td_var_offset(bs_unaligned),
1373 .help = "Don't sector align IO buffer sizes",
1376 .category = FIO_OPT_C_IO,
1377 .group = FIO_OPT_G_INVALID,
1380 .name = "randrepeat",
1381 .lname = "Random repeatable",
1382 .type = FIO_OPT_BOOL,
1383 .off1 = td_var_offset(rand_repeatable),
1384 .help = "Use repeatable random IO pattern",
1388 .category = FIO_OPT_C_IO,
1389 .group = FIO_OPT_G_INVALID,
1392 .name = "use_os_rand",
1393 .lname = "Use OS random",
1394 .type = FIO_OPT_BOOL,
1395 .off1 = td_var_offset(use_os_rand),
1396 .help = "Set to use OS random generator",
1400 .category = FIO_OPT_C_IO,
1401 .group = FIO_OPT_G_INVALID,
1404 .name = "norandommap",
1405 .lname = "No randommap",
1406 .type = FIO_OPT_STR_SET,
1407 .off1 = td_var_offset(norandommap),
1408 .help = "Accept potential duplicate random blocks",
1411 .category = FIO_OPT_C_IO,
1412 .group = FIO_OPT_G_INVALID,
1415 .name = "softrandommap",
1416 .lname = "Soft randommap",
1417 .type = FIO_OPT_BOOL,
1418 .off1 = td_var_offset(softrandommap),
1419 .help = "Set norandommap if randommap allocation fails",
1420 .parent = "norandommap",
1423 .category = FIO_OPT_C_IO,
1424 .group = FIO_OPT_G_INVALID,
1428 .lname = "Number of files",
1429 .alias = "nr_files",
1430 .type = FIO_OPT_INT,
1431 .off1 = td_var_offset(nr_files),
1432 .help = "Split job workload between this number of files",
1435 .category = FIO_OPT_C_FILE,
1436 .group = FIO_OPT_G_INVALID,
1439 .name = "openfiles",
1440 .lname = "Number of open files",
1441 .type = FIO_OPT_INT,
1442 .off1 = td_var_offset(open_files),
1443 .help = "Number of files to keep open at the same time",
1444 .category = FIO_OPT_C_FILE,
1445 .group = FIO_OPT_G_INVALID,
1448 .name = "file_service_type",
1449 .lname = "File service type",
1450 .type = FIO_OPT_STR,
1452 .off1 = td_var_offset(file_service_type),
1453 .help = "How to select which file to service next",
1454 .def = "roundrobin",
1455 .category = FIO_OPT_C_FILE,
1456 .group = FIO_OPT_G_INVALID,
1459 .oval = FIO_FSERVICE_RANDOM,
1460 .help = "Choose a file at random",
1462 { .ival = "roundrobin",
1463 .oval = FIO_FSERVICE_RR,
1464 .help = "Round robin select files",
1466 { .ival = "sequential",
1467 .oval = FIO_FSERVICE_SEQ,
1468 .help = "Finish one file before moving to the next",
1471 .parent = "nrfiles",
1474 #ifdef FIO_HAVE_FALLOCATE
1476 .name = "fallocate",
1477 .lname = "Fallocate",
1478 .type = FIO_OPT_STR,
1479 .off1 = td_var_offset(fallocate_mode),
1480 .help = "Whether pre-allocation is performed when laying out files",
1482 .category = FIO_OPT_C_FILE,
1483 .group = FIO_OPT_G_INVALID,
1486 .oval = FIO_FALLOCATE_NONE,
1487 .help = "Do not pre-allocate space",
1490 .oval = FIO_FALLOCATE_POSIX,
1491 .help = "Use posix_fallocate()",
1493 #ifdef FIO_HAVE_LINUX_FALLOCATE
1495 .oval = FIO_FALLOCATE_KEEP_SIZE,
1496 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
1499 /* Compatibility with former boolean values */
1501 .oval = FIO_FALLOCATE_NONE,
1502 .help = "Alias for 'none'",
1505 .oval = FIO_FALLOCATE_POSIX,
1506 .help = "Alias for 'posix'",
1510 #endif /* FIO_HAVE_FALLOCATE */
1512 .name = "fadvise_hint",
1513 .lname = "Fadvise hint",
1514 .type = FIO_OPT_BOOL,
1515 .off1 = td_var_offset(fadvise_hint),
1516 .help = "Use fadvise() to advise the kernel on IO pattern",
1518 .category = FIO_OPT_C_FILE,
1519 .group = FIO_OPT_G_INVALID,
1524 .type = FIO_OPT_INT,
1525 .off1 = td_var_offset(fsync_blocks),
1526 .help = "Issue fsync for writes every given number of blocks",
1529 .category = FIO_OPT_C_FILE,
1530 .group = FIO_OPT_G_INVALID,
1533 .name = "fdatasync",
1534 .lname = "Fdatasync",
1535 .type = FIO_OPT_INT,
1536 .off1 = td_var_offset(fdatasync_blocks),
1537 .help = "Issue fdatasync for writes every given number of blocks",
1540 .category = FIO_OPT_C_FILE,
1541 .group = FIO_OPT_G_INVALID,
1544 .name = "write_barrier",
1545 .lname = "Write barrier",
1546 .type = FIO_OPT_INT,
1547 .off1 = td_var_offset(barrier_blocks),
1548 .help = "Make every Nth write a barrier write",
1551 .category = FIO_OPT_C_IO,
1552 .group = FIO_OPT_G_INVALID,
1554 #ifdef FIO_HAVE_SYNC_FILE_RANGE
1556 .name = "sync_file_range",
1557 .lname = "Sync file range",
1559 { .ival = "wait_before",
1560 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
1561 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
1565 .oval = SYNC_FILE_RANGE_WRITE,
1566 .help = "SYNC_FILE_RANGE_WRITE",
1570 .ival = "wait_after",
1571 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
1572 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
1576 .type = FIO_OPT_STR_MULTI,
1578 .off1 = td_var_offset(sync_file_range),
1579 .help = "Use sync_file_range()",
1580 .category = FIO_OPT_C_FILE,
1581 .group = FIO_OPT_G_INVALID,
1586 .lname = "Direct I/O",
1587 .type = FIO_OPT_BOOL,
1588 .off1 = td_var_offset(odirect),
1589 .help = "Use O_DIRECT IO (negates buffered)",
1591 .category = FIO_OPT_C_IO,
1592 .group = FIO_OPT_G_INVALID,
1596 .lname = "Buffered I/O",
1597 .type = FIO_OPT_BOOL,
1598 .off1 = td_var_offset(odirect),
1600 .help = "Use buffered IO (negates direct)",
1602 .category = FIO_OPT_C_IO,
1603 .group = FIO_OPT_G_INVALID,
1606 .name = "overwrite",
1607 .lname = "Overwrite",
1608 .type = FIO_OPT_BOOL,
1609 .off1 = td_var_offset(overwrite),
1610 .help = "When writing, set whether to overwrite current data",
1612 .category = FIO_OPT_C_FILE,
1613 .group = FIO_OPT_G_INVALID,
1618 .type = FIO_OPT_INT,
1619 .off1 = td_var_offset(loops),
1620 .help = "Number of times to run the job",
1623 .category = FIO_OPT_C_GENERAL,
1624 .group = FIO_OPT_G_INVALID,
1628 .lname = "Number of jobs",
1629 .type = FIO_OPT_INT,
1630 .off1 = td_var_offset(numjobs),
1631 .help = "Duplicate this job this many times",
1634 .category = FIO_OPT_C_GENERAL,
1635 .group = FIO_OPT_G_INVALID,
1638 .name = "startdelay",
1639 .lname = "Start delay",
1640 .type = FIO_OPT_STR_VAL_TIME,
1641 .off1 = td_var_offset(start_delay),
1642 .help = "Only start job when this period has passed",
1644 .category = FIO_OPT_C_GENERAL,
1645 .group = FIO_OPT_G_INVALID,
1651 .type = FIO_OPT_STR_VAL_TIME,
1652 .off1 = td_var_offset(timeout),
1653 .help = "Stop workload when this amount of time has passed",
1655 .category = FIO_OPT_C_GENERAL,
1656 .group = FIO_OPT_G_INVALID,
1659 .name = "time_based",
1660 .lname = "Time based",
1661 .type = FIO_OPT_STR_SET,
1662 .off1 = td_var_offset(time_based),
1663 .help = "Keep running until runtime/timeout is met",
1664 .category = FIO_OPT_C_GENERAL,
1665 .group = FIO_OPT_G_INVALID,
1668 .name = "ramp_time",
1669 .lname = "Ramp time",
1670 .type = FIO_OPT_STR_VAL_TIME,
1671 .off1 = td_var_offset(ramp_time),
1672 .help = "Ramp up time before measuring performance",
1673 .category = FIO_OPT_C_GENERAL,
1674 .group = FIO_OPT_G_INVALID,
1677 .name = "clocksource",
1678 .lname = "Clock source",
1679 .type = FIO_OPT_STR,
1680 .cb = fio_clock_source_cb,
1681 .off1 = td_var_offset(clocksource),
1682 .help = "What type of timing source to use",
1683 .category = FIO_OPT_C_GENERAL,
1684 .group = FIO_OPT_G_INVALID,
1686 { .ival = "gettimeofday",
1688 .help = "Use gettimeofday(2) for timing",
1690 { .ival = "clock_gettime",
1691 .oval = CS_CGETTIME,
1692 .help = "Use clock_gettime(2) for timing",
1694 #ifdef ARCH_HAVE_CPU_CLOCK
1696 .oval = CS_CPUCLOCK,
1697 .help = "Use CPU private clock",
1705 .lname = "I/O Memory",
1706 .type = FIO_OPT_STR,
1708 .off1 = td_var_offset(mem_type),
1709 .help = "Backing type for IO buffers",
1711 .category = FIO_OPT_C_IO,
1712 .group = FIO_OPT_G_INVALID,
1716 .help = "Use malloc(3) for IO buffers",
1720 .help = "Use shared memory segments for IO buffers",
1722 #ifdef FIO_HAVE_HUGETLB
1723 { .ival = "shmhuge",
1724 .oval = MEM_SHMHUGE,
1725 .help = "Like shm, but use huge pages",
1730 .help = "Use mmap(2) (file or anon) for IO buffers",
1732 #ifdef FIO_HAVE_HUGETLB
1733 { .ival = "mmaphuge",
1734 .oval = MEM_MMAPHUGE,
1735 .help = "Like mmap, but use huge pages",
1741 .name = "iomem_align",
1742 .alias = "mem_align",
1743 .lname = "I/O memory alignment",
1744 .type = FIO_OPT_INT,
1745 .off1 = td_var_offset(mem_align),
1747 .help = "IO memory buffer offset alignment",
1751 .category = FIO_OPT_C_IO,
1752 .group = FIO_OPT_G_INVALID,
1757 .type = FIO_OPT_STR,
1758 .off1 = td_var_offset(verify),
1759 .help = "Verify data written",
1760 .cb = str_verify_cb,
1762 .category = FIO_OPT_C_IO,
1763 .group = FIO_OPT_G_INVALID,
1766 .oval = VERIFY_NONE,
1767 .help = "Don't do IO verification",
1771 .help = "Use md5 checksums for verification",
1774 .oval = VERIFY_CRC64,
1775 .help = "Use crc64 checksums for verification",
1778 .oval = VERIFY_CRC32,
1779 .help = "Use crc32 checksums for verification",
1781 { .ival = "crc32c-intel",
1782 .oval = VERIFY_CRC32C,
1783 .help = "Use crc32c checksums for verification (hw assisted, if available)",
1786 .oval = VERIFY_CRC32C,
1787 .help = "Use crc32c checksums for verification (hw assisted, if available)",
1790 .oval = VERIFY_CRC16,
1791 .help = "Use crc16 checksums for verification",
1794 .oval = VERIFY_CRC7,
1795 .help = "Use crc7 checksums for verification",
1798 .oval = VERIFY_SHA1,
1799 .help = "Use sha1 checksums for verification",
1802 .oval = VERIFY_SHA256,
1803 .help = "Use sha256 checksums for verification",
1806 .oval = VERIFY_SHA512,
1807 .help = "Use sha512 checksums for verification",
1810 .oval = VERIFY_META,
1811 .help = "Use io information",
1815 .oval = VERIFY_NULL,
1816 .help = "Pretend to verify",
1821 .name = "do_verify",
1822 .lname = "Perform verify step",
1823 .type = FIO_OPT_BOOL,
1824 .off1 = td_var_offset(do_verify),
1825 .help = "Run verification stage after write",
1829 .category = FIO_OPT_C_IO,
1830 .group = FIO_OPT_G_VERIFY,
1833 .name = "verifysort",
1834 .lname = "Verify sort",
1835 .type = FIO_OPT_BOOL,
1836 .off1 = td_var_offset(verifysort),
1837 .help = "Sort written verify blocks for read back",
1841 .category = FIO_OPT_C_IO,
1842 .group = FIO_OPT_G_VERIFY,
1845 .name = "verify_interval",
1846 .lname = "Verify interval",
1847 .type = FIO_OPT_INT,
1848 .off1 = td_var_offset(verify_interval),
1849 .minval = 2 * sizeof(struct verify_header),
1850 .help = "Store verify buffer header every N bytes",
1853 .interval = 2 * sizeof(struct verify_header),
1854 .category = FIO_OPT_C_IO,
1855 .group = FIO_OPT_G_VERIFY,
1858 .name = "verify_offset",
1859 .lname = "Verify offset",
1860 .type = FIO_OPT_INT,
1861 .help = "Offset verify header location by N bytes",
1863 .cb = str_verify_offset_cb,
1866 .category = FIO_OPT_C_IO,
1867 .group = FIO_OPT_G_VERIFY,
1870 .name = "verify_pattern",
1871 .lname = "Verify pattern",
1872 .type = FIO_OPT_STR,
1873 .cb = str_verify_pattern_cb,
1874 .help = "Fill pattern for IO buffers",
1877 .category = FIO_OPT_C_IO,
1878 .group = FIO_OPT_G_VERIFY,
1881 .name = "verify_fatal",
1882 .lname = "Verify fatal",
1883 .type = FIO_OPT_BOOL,
1884 .off1 = td_var_offset(verify_fatal),
1886 .help = "Exit on a single verify failure, don't continue",
1889 .category = FIO_OPT_C_IO,
1890 .group = FIO_OPT_G_VERIFY,
1893 .name = "verify_dump",
1894 .lname = "Verify dump",
1895 .type = FIO_OPT_BOOL,
1896 .off1 = td_var_offset(verify_dump),
1898 .help = "Dump contents of good and bad blocks on failure",
1901 .category = FIO_OPT_C_IO,
1902 .group = FIO_OPT_G_VERIFY,
1905 .name = "verify_async",
1906 .lname = "Verify asynchronously",
1907 .type = FIO_OPT_INT,
1908 .off1 = td_var_offset(verify_async),
1910 .help = "Number of async verifier threads to use",
1913 .category = FIO_OPT_C_IO,
1914 .group = FIO_OPT_G_VERIFY,
1917 .name = "verify_backlog",
1918 .lname = "Verify backlog",
1919 .type = FIO_OPT_STR_VAL,
1920 .off1 = td_var_offset(verify_backlog),
1921 .help = "Verify after this number of blocks are written",
1924 .category = FIO_OPT_C_IO,
1925 .group = FIO_OPT_G_VERIFY,
1928 .name = "verify_backlog_batch",
1929 .lname = "Verify backlog batch",
1930 .type = FIO_OPT_INT,
1931 .off1 = td_var_offset(verify_batch),
1932 .help = "Verify this number of IO blocks",
1935 .category = FIO_OPT_C_IO,
1936 .group = FIO_OPT_G_VERIFY,
1938 #ifdef FIO_HAVE_CPU_AFFINITY
1940 .name = "verify_async_cpus",
1941 .lname = "Async verify CPUs",
1942 .type = FIO_OPT_STR,
1943 .cb = str_verify_cpus_allowed_cb,
1944 .help = "Set CPUs allowed for async verify threads",
1945 .parent = "verify_async",
1947 .category = FIO_OPT_C_IO,
1948 .group = FIO_OPT_G_VERIFY,
1951 #ifdef FIO_HAVE_TRIM
1953 .name = "trim_percentage",
1954 .lname = "Trim percentage",
1955 .type = FIO_OPT_INT,
1956 .cb = str_verify_trim_cb,
1959 .help = "Number of verify blocks to discard/trim",
1964 .category = FIO_OPT_C_IO,
1965 .group = FIO_OPT_G_TRIM,
1968 .name = "trim_verify_zero",
1969 .lname = "Verify trim zero",
1970 .type = FIO_OPT_BOOL,
1971 .help = "Verify that trim/discarded blocks are returned as zeroes",
1972 .off1 = td_var_offset(trim_zero),
1973 .parent = "trim_percentage",
1976 .category = FIO_OPT_C_IO,
1977 .group = FIO_OPT_G_TRIM,
1980 .name = "trim_backlog",
1981 .lname = "Trim backlog",
1982 .type = FIO_OPT_STR_VAL,
1983 .off1 = td_var_offset(trim_backlog),
1984 .help = "Trim after this number of blocks are written",
1985 .parent = "trim_percentage",
1988 .category = FIO_OPT_C_IO,
1989 .group = FIO_OPT_G_TRIM,
1992 .name = "trim_backlog_batch",
1993 .lname = "Trim backlog batch",
1994 .type = FIO_OPT_INT,
1995 .off1 = td_var_offset(trim_batch),
1996 .help = "Trim this number of IO blocks",
1997 .parent = "trim_percentage",
2000 .category = FIO_OPT_C_IO,
2001 .group = FIO_OPT_G_TRIM,
2005 .name = "write_iolog",
2006 .lname = "Write I/O log",
2007 .type = FIO_OPT_STR_STORE,
2008 .off1 = td_var_offset(write_iolog_file),
2009 .help = "Store IO pattern to file",
2010 .category = FIO_OPT_C_IO,
2011 .group = FIO_OPT_G_IOLOG,
2014 .name = "read_iolog",
2015 .lname = "Read I/O log",
2016 .type = FIO_OPT_STR_STORE,
2017 .off1 = td_var_offset(read_iolog_file),
2018 .help = "Playback IO pattern from file",
2019 .category = FIO_OPT_C_IO,
2020 .group = FIO_OPT_G_IOLOG,
2023 .name = "replay_no_stall",
2024 .lname = "Don't stall on replay",
2025 .type = FIO_OPT_BOOL,
2026 .off1 = td_var_offset(no_stall),
2028 .parent = "read_iolog",
2030 .help = "Playback IO pattern file as fast as possible without stalls",
2031 .category = FIO_OPT_C_IO,
2032 .group = FIO_OPT_G_IOLOG,
2035 .name = "replay_redirect",
2036 .lname = "Redirect device for replay",
2037 .type = FIO_OPT_STR_STORE,
2038 .off1 = td_var_offset(replay_redirect),
2039 .parent = "read_iolog",
2041 .help = "Replay all I/O onto this device, regardless of trace device",
2042 .category = FIO_OPT_C_IO,
2043 .group = FIO_OPT_G_IOLOG,
2046 .name = "exec_prerun",
2047 .lname = "Pre-execute runnable",
2048 .type = FIO_OPT_STR_STORE,
2049 .off1 = td_var_offset(exec_prerun),
2050 .help = "Execute this file prior to running job",
2051 .category = FIO_OPT_C_GENERAL,
2052 .group = FIO_OPT_G_INVALID,
2055 .name = "exec_postrun",
2056 .lname = "Post-execute runnable",
2057 .type = FIO_OPT_STR_STORE,
2058 .off1 = td_var_offset(exec_postrun),
2059 .help = "Execute this file after running job",
2060 .category = FIO_OPT_C_GENERAL,
2061 .group = FIO_OPT_G_INVALID,
2063 #ifdef FIO_HAVE_IOSCHED_SWITCH
2065 .name = "ioscheduler",
2066 .lname = "I/O scheduler",
2067 .type = FIO_OPT_STR_STORE,
2068 .off1 = td_var_offset(ioscheduler),
2069 .help = "Use this IO scheduler on the backing device",
2070 .category = FIO_OPT_C_FILE,
2071 .group = FIO_OPT_G_INVALID,
2076 .lname = "Zone size",
2077 .type = FIO_OPT_STR_VAL,
2078 .off1 = td_var_offset(zone_size),
2079 .help = "Amount of data to read per zone",
2081 .interval = 1024 * 1024,
2082 .category = FIO_OPT_C_IO,
2083 .group = FIO_OPT_G_ZONE,
2086 .name = "zonerange",
2087 .lname = "Zone range",
2088 .type = FIO_OPT_STR_VAL,
2089 .off1 = td_var_offset(zone_range),
2090 .help = "Give size of an IO zone",
2092 .interval = 1024 * 1024,
2093 .category = FIO_OPT_C_IO,
2094 .group = FIO_OPT_G_ZONE,
2098 .lname = "Zone skip",
2099 .type = FIO_OPT_STR_VAL,
2100 .off1 = td_var_offset(zone_skip),
2101 .help = "Space between IO zones",
2103 .interval = 1024 * 1024,
2104 .category = FIO_OPT_C_IO,
2105 .group = FIO_OPT_G_ZONE,
2109 .lname = "Lock memory",
2110 .type = FIO_OPT_STR_VAL,
2111 .cb = str_lockmem_cb,
2112 .help = "Lock down this amount of memory",
2114 .interval = 1024 * 1024,
2115 .category = FIO_OPT_C_GENERAL,
2116 .group = FIO_OPT_G_INVALID,
2119 .name = "rwmixread",
2120 .lname = "Read/write mix read",
2121 .type = FIO_OPT_INT,
2122 .cb = str_rwmix_read_cb,
2124 .help = "Percentage of mixed workload that is reads",
2127 .inverse = "rwmixwrite",
2128 .category = FIO_OPT_C_IO,
2129 .group = FIO_OPT_G_RWMIX,
2132 .name = "rwmixwrite",
2133 .lname = "Read/write mix write",
2134 .type = FIO_OPT_INT,
2135 .cb = str_rwmix_write_cb,
2137 .help = "Percentage of mixed workload that is writes",
2140 .inverse = "rwmixread",
2141 .category = FIO_OPT_C_IO,
2142 .group = FIO_OPT_G_RWMIX,
2145 .name = "rwmixcycle",
2146 .lname = "Read/write mix cycle",
2147 .type = FIO_OPT_DEPRECATED,
2148 .category = FIO_OPT_C_IO,
2149 .group = FIO_OPT_G_RWMIX,
2154 .type = FIO_OPT_INT,
2155 .off1 = td_var_offset(nice),
2156 .help = "Set job CPU nice value",
2161 .category = FIO_OPT_C_GENERAL,
2162 .group = FIO_OPT_G_INVALID,
2164 #ifdef FIO_HAVE_IOPRIO
2167 .lname = "I/O nice priority",
2168 .type = FIO_OPT_INT,
2170 .help = "Set job IO priority value",
2174 .category = FIO_OPT_C_GENERAL,
2175 .group = FIO_OPT_G_INVALID,
2178 .name = "prioclass",
2179 .lname = "I/O nice priority class",
2180 .type = FIO_OPT_INT,
2181 .cb = str_prioclass_cb,
2182 .help = "Set job IO priority class",
2186 .category = FIO_OPT_C_GENERAL,
2187 .group = FIO_OPT_G_INVALID,
2191 .name = "thinktime",
2192 .lname = "Thinktime",
2193 .type = FIO_OPT_INT,
2194 .off1 = td_var_offset(thinktime),
2195 .help = "Idle time between IO buffers (usec)",
2197 .category = FIO_OPT_C_IO,
2198 .group = FIO_OPT_G_INVALID,
2201 .name = "thinktime_spin",
2202 .lname = "Thinktime spin",
2203 .type = FIO_OPT_INT,
2204 .off1 = td_var_offset(thinktime_spin),
2205 .help = "Start think time by spinning this amount (usec)",
2207 .parent = "thinktime",
2209 .category = FIO_OPT_C_IO,
2210 .group = FIO_OPT_G_INVALID,
2213 .name = "thinktime_blocks",
2214 .lname = "Thinktime blocks",
2215 .type = FIO_OPT_INT,
2216 .off1 = td_var_offset(thinktime_blocks),
2217 .help = "IO buffer period between 'thinktime'",
2219 .parent = "thinktime",
2221 .category = FIO_OPT_C_IO,
2222 .group = FIO_OPT_G_INVALID,
2226 .lname = "I/O rate",
2227 .type = FIO_OPT_INT,
2228 .off1 = td_var_offset(rate[0]),
2229 .off2 = td_var_offset(rate[1]),
2230 .help = "Set bandwidth rate",
2231 .category = FIO_OPT_C_IO,
2232 .group = FIO_OPT_G_RATE,
2236 .lname = "I/O min rate",
2237 .type = FIO_OPT_INT,
2238 .off1 = td_var_offset(ratemin[0]),
2239 .off2 = td_var_offset(ratemin[1]),
2240 .help = "Job must meet this rate or it will be shutdown",
2243 .category = FIO_OPT_C_IO,
2244 .group = FIO_OPT_G_RATE,
2247 .name = "rate_iops",
2248 .lname = "I/O rate IOPS",
2249 .type = FIO_OPT_INT,
2250 .off1 = td_var_offset(rate_iops[0]),
2251 .off2 = td_var_offset(rate_iops[1]),
2252 .help = "Limit IO used to this number of IO operations/sec",
2254 .category = FIO_OPT_C_IO,
2255 .group = FIO_OPT_G_RATE,
2258 .name = "rate_iops_min",
2259 .lname = "I/O min rate IOPS",
2260 .type = FIO_OPT_INT,
2261 .off1 = td_var_offset(rate_iops_min[0]),
2262 .off2 = td_var_offset(rate_iops_min[1]),
2263 .help = "Job must meet this rate or it will be shut down",
2264 .parent = "rate_iops",
2266 .category = FIO_OPT_C_IO,
2267 .group = FIO_OPT_G_RATE,
2270 .name = "ratecycle",
2271 .lname = "I/O rate cycle",
2272 .type = FIO_OPT_INT,
2273 .off1 = td_var_offset(ratecycle),
2274 .help = "Window average for rate limits (msec)",
2278 .category = FIO_OPT_C_IO,
2279 .group = FIO_OPT_G_RATE,
2282 .name = "invalidate",
2283 .lname = "Cache invalidate",
2284 .type = FIO_OPT_BOOL,
2285 .off1 = td_var_offset(invalidate_cache),
2286 .help = "Invalidate buffer/page cache prior to running job",
2288 .category = FIO_OPT_C_IO,
2289 .group = FIO_OPT_G_INVALID,
2293 .lname = "Synchronous I/O",
2294 .type = FIO_OPT_BOOL,
2295 .off1 = td_var_offset(sync_io),
2296 .help = "Use O_SYNC for buffered writes",
2298 .parent = "buffered",
2300 .category = FIO_OPT_C_IO,
2301 .group = FIO_OPT_G_INVALID,
2304 .name = "bwavgtime",
2305 .lname = "Bandwidth average time",
2306 .type = FIO_OPT_INT,
2307 .off1 = td_var_offset(bw_avg_time),
2308 .help = "Time window over which to calculate bandwidth"
2311 .parent = "write_bw_log",
2314 .category = FIO_OPT_C_LOG,
2315 .group = FIO_OPT_G_INVALID,
2318 .name = "iopsavgtime",
2319 .lname = "IOPS average time",
2320 .type = FIO_OPT_INT,
2321 .off1 = td_var_offset(iops_avg_time),
2322 .help = "Time window over which to calculate IOPS (msec)",
2324 .parent = "write_iops_log",
2327 .category = FIO_OPT_C_LOG,
2328 .group = FIO_OPT_G_INVALID,
2331 .name = "create_serialize",
2332 .lname = "Create serialize",
2333 .type = FIO_OPT_BOOL,
2334 .off1 = td_var_offset(create_serialize),
2335 .help = "Serialize creating of job files",
2337 .category = FIO_OPT_C_FILE,
2338 .group = FIO_OPT_G_INVALID,
2341 .name = "create_fsync",
2342 .lname = "Create fsync",
2343 .type = FIO_OPT_BOOL,
2344 .off1 = td_var_offset(create_fsync),
2345 .help = "fsync file after creation",
2347 .category = FIO_OPT_C_FILE,
2348 .group = FIO_OPT_G_INVALID,
2351 .name = "create_on_open",
2352 .lname = "Create on open",
2353 .type = FIO_OPT_BOOL,
2354 .off1 = td_var_offset(create_on_open),
2355 .help = "Create files when they are opened for IO",
2357 .category = FIO_OPT_C_FILE,
2358 .group = FIO_OPT_G_INVALID,
2362 .lname = "Pre-read files",
2363 .type = FIO_OPT_BOOL,
2364 .off1 = td_var_offset(pre_read),
2365 .help = "Pre-read files before starting official testing",
2367 .category = FIO_OPT_C_FILE,
2368 .group = FIO_OPT_G_INVALID,
2372 .lname = "CPU load",
2373 .type = FIO_OPT_INT,
2374 .off1 = td_var_offset(cpuload),
2375 .help = "Use this percentage of CPU",
2376 .category = FIO_OPT_C_GENERAL,
2377 .group = FIO_OPT_G_INVALID,
2380 .name = "cpuchunks",
2381 .lname = "CPU chunk",
2382 .type = FIO_OPT_INT,
2383 .off1 = td_var_offset(cpucycle),
2384 .help = "Length of the CPU burn cycles (usecs)",
2386 .parent = "cpuload",
2388 .category = FIO_OPT_C_GENERAL,
2389 .group = FIO_OPT_G_INVALID,
2391 #ifdef FIO_HAVE_CPU_AFFINITY
2394 .lname = "CPU mask",
2395 .type = FIO_OPT_INT,
2396 .cb = str_cpumask_cb,
2397 .help = "CPU affinity mask",
2398 .category = FIO_OPT_C_GENERAL,
2399 .group = FIO_OPT_G_INVALID,
2402 .name = "cpus_allowed",
2403 .lname = "CPUs allowed",
2404 .type = FIO_OPT_STR,
2405 .cb = str_cpus_allowed_cb,
2406 .help = "Set CPUs allowed",
2407 .category = FIO_OPT_C_GENERAL,
2408 .group = FIO_OPT_G_INVALID,
2412 .name = "end_fsync",
2413 .lname = "End fsync",
2414 .type = FIO_OPT_BOOL,
2415 .off1 = td_var_offset(end_fsync),
2416 .help = "Include fsync at the end of job",
2418 .category = FIO_OPT_C_FILE,
2419 .group = FIO_OPT_G_INVALID,
2422 .name = "fsync_on_close",
2423 .lname = "Fsync on close",
2424 .type = FIO_OPT_BOOL,
2425 .off1 = td_var_offset(fsync_on_close),
2426 .help = "fsync files on close",
2428 .category = FIO_OPT_C_FILE,
2429 .group = FIO_OPT_G_INVALID,
2433 .lname = "Unlink file",
2434 .type = FIO_OPT_BOOL,
2435 .off1 = td_var_offset(unlink),
2436 .help = "Unlink created files after job has completed",
2438 .category = FIO_OPT_C_FILE,
2439 .group = FIO_OPT_G_INVALID,
2443 .lname = "Exit-all on terminate",
2444 .type = FIO_OPT_STR_SET,
2445 .cb = str_exitall_cb,
2446 .help = "Terminate all jobs when one exits",
2447 .category = FIO_OPT_C_GENERAL,
2448 .group = FIO_OPT_G_INVALID,
2451 .name = "stonewall",
2452 .lname = "Wait for previous",
2453 .alias = "wait_for_previous",
2454 .type = FIO_OPT_STR_SET,
2455 .off1 = td_var_offset(stonewall),
2456 .help = "Insert a hard barrier between this job and previous",
2457 .category = FIO_OPT_C_GENERAL,
2458 .group = FIO_OPT_G_INVALID,
2461 .name = "new_group",
2462 .lname = "New group",
2463 .type = FIO_OPT_STR_SET,
2464 .off1 = td_var_offset(new_group),
2465 .help = "Mark the start of a new group (for reporting)",
2466 .category = FIO_OPT_C_GENERAL,
2467 .group = FIO_OPT_G_INVALID,
2472 .type = FIO_OPT_STR_SET,
2473 .off1 = td_var_offset(use_thread),
2474 .help = "Use threads instead of processes",
2475 .category = FIO_OPT_C_GENERAL,
2476 .group = FIO_OPT_G_INVALID,
2479 .name = "write_bw_log",
2480 .lname = "Write bandwidth log",
2481 .type = FIO_OPT_STR,
2482 .off1 = td_var_offset(write_bw_log),
2483 .cb = str_write_bw_log_cb,
2484 .help = "Write log of bandwidth during run",
2485 .category = FIO_OPT_C_LOG,
2486 .group = FIO_OPT_G_INVALID,
2489 .name = "write_lat_log",
2490 .lname = "Write latency log",
2491 .type = FIO_OPT_STR,
2492 .off1 = td_var_offset(write_lat_log),
2493 .cb = str_write_lat_log_cb,
2494 .help = "Write log of latency during run",
2495 .category = FIO_OPT_C_LOG,
2496 .group = FIO_OPT_G_INVALID,
2499 .name = "write_iops_log",
2500 .lname = "Write IOPS log",
2501 .type = FIO_OPT_STR,
2502 .off1 = td_var_offset(write_iops_log),
2503 .cb = str_write_iops_log_cb,
2504 .help = "Write log of IOPS during run",
2505 .category = FIO_OPT_C_LOG,
2506 .group = FIO_OPT_G_INVALID,
2509 .name = "log_avg_msec",
2510 .lname = "Log averaging (msec)",
2511 .type = FIO_OPT_INT,
2512 .off1 = td_var_offset(log_avg_msec),
2513 .help = "Average bw/iops/lat logs over this period of time",
2515 .category = FIO_OPT_C_LOG,
2516 .group = FIO_OPT_G_INVALID,
2519 .name = "hugepage-size",
2520 .lname = "Hugepage size",
2521 .type = FIO_OPT_INT,
2522 .off1 = td_var_offset(hugepage_size),
2523 .help = "When using hugepages, specify size of each page",
2524 .def = __fio_stringify(FIO_HUGE_PAGE),
2525 .interval = 1024 * 1024,
2526 .category = FIO_OPT_C_GENERAL,
2527 .group = FIO_OPT_G_INVALID,
2530 .name = "group_reporting",
2531 .lname = "Group reporting",
2532 .type = FIO_OPT_BOOL,
2533 .off1 = td_var_offset(group_reporting),
2534 .help = "Do reporting on a per-group basis",
2536 .category = FIO_OPT_C_GENERAL,
2537 .group = FIO_OPT_G_INVALID,
2540 .name = "zero_buffers",
2541 .lname = "Zero I/O buffers",
2542 .type = FIO_OPT_STR_SET,
2543 .off1 = td_var_offset(zero_buffers),
2544 .help = "Init IO buffers to all zeroes",
2545 .category = FIO_OPT_C_IO,
2546 .group = FIO_OPT_G_INVALID,
2549 .name = "refill_buffers",
2550 .lname = "Refill I/O buffers",
2551 .type = FIO_OPT_STR_SET,
2552 .off1 = td_var_offset(refill_buffers),
2553 .help = "Refill IO buffers on every IO submit",
2554 .category = FIO_OPT_C_IO,
2555 .group = FIO_OPT_G_INVALID,
2558 .name = "scramble_buffers",
2559 .lname = "Scramble I/O buffers",
2560 .type = FIO_OPT_BOOL,
2561 .off1 = td_var_offset(scramble_buffers),
2562 .help = "Slightly scramble buffers on every IO submit",
2564 .category = FIO_OPT_C_IO,
2565 .group = FIO_OPT_G_INVALID,
2568 .name = "buffer_compress_percentage",
2569 .lname = "Buffer compression percentage",
2570 .type = FIO_OPT_INT,
2571 .off1 = td_var_offset(compress_percentage),
2574 .help = "How compressible the buffer is (approximately)",
2576 .category = FIO_OPT_C_IO,
2577 .group = FIO_OPT_G_INVALID,
2580 .name = "buffer_compress_chunk",
2581 .lname = "Buffer compression chunk size",
2582 .type = FIO_OPT_INT,
2583 .off1 = td_var_offset(compress_chunk),
2584 .parent = "buffer_compress_percentage",
2586 .help = "Size of compressible region in buffer",
2588 .category = FIO_OPT_C_IO,
2589 .group = FIO_OPT_G_INVALID,
2592 .name = "clat_percentiles",
2593 .lname = "Completion latency percentiles",
2594 .type = FIO_OPT_BOOL,
2595 .off1 = td_var_offset(clat_percentiles),
2596 .help = "Enable the reporting of completion latency percentiles",
2598 .category = FIO_OPT_C_STAT,
2599 .group = FIO_OPT_G_INVALID,
2602 .name = "percentile_list",
2603 .lname = "Completion latency percentile list",
2604 .type = FIO_OPT_FLOAT_LIST,
2605 .off1 = td_var_offset(percentile_list),
2606 .off2 = td_var_offset(overwrite_plist),
2607 .help = "Specify a custom list of percentiles to report",
2608 .maxlen = FIO_IO_U_LIST_MAX_LEN,
2611 .category = FIO_OPT_C_STAT,
2612 .group = FIO_OPT_G_INVALID,
2615 #ifdef FIO_HAVE_DISK_UTIL
2617 .name = "disk_util",
2618 .lname = "Disk utilization",
2619 .type = FIO_OPT_BOOL,
2620 .off1 = td_var_offset(do_disk_util),
2621 .help = "Log disk utilization statistics",
2623 .category = FIO_OPT_C_STAT,
2624 .group = FIO_OPT_G_INVALID,
2628 .name = "gtod_reduce",
2629 .lname = "Reduce gettimeofday() calls",
2630 .type = FIO_OPT_BOOL,
2631 .help = "Greatly reduce number of gettimeofday() calls",
2632 .cb = str_gtod_reduce_cb,
2634 .category = FIO_OPT_C_STAT,
2635 .group = FIO_OPT_G_INVALID,
2638 .name = "disable_lat",
2639 .lname = "Disable all latency stats",
2640 .type = FIO_OPT_BOOL,
2641 .off1 = td_var_offset(disable_lat),
2642 .help = "Disable latency numbers",
2643 .parent = "gtod_reduce",
2646 .category = FIO_OPT_C_STAT,
2647 .group = FIO_OPT_G_INVALID,
2650 .name = "disable_clat",
2651 .lname = "Disable completion latency stats",
2652 .type = FIO_OPT_BOOL,
2653 .off1 = td_var_offset(disable_clat),
2654 .help = "Disable completion latency numbers",
2655 .parent = "gtod_reduce",
2658 .category = FIO_OPT_C_STAT,
2659 .group = FIO_OPT_G_INVALID,
2662 .name = "disable_slat",
2663 .lname = "Disable submission latency stats",
2664 .type = FIO_OPT_BOOL,
2665 .off1 = td_var_offset(disable_slat),
2666 .help = "Disable submission latency numbers",
2667 .parent = "gtod_reduce",
2670 .category = FIO_OPT_C_STAT,
2671 .group = FIO_OPT_G_INVALID,
2674 .name = "disable_bw_measurement",
2675 .lname = "Disable bandwidth stats",
2676 .type = FIO_OPT_BOOL,
2677 .off1 = td_var_offset(disable_bw),
2678 .help = "Disable bandwidth logging",
2679 .parent = "gtod_reduce",
2682 .category = FIO_OPT_C_STAT,
2683 .group = FIO_OPT_G_INVALID,
2687 .lname = "Dedicated gettimeofday() CPU",
2688 .type = FIO_OPT_INT,
2689 .cb = str_gtod_cpu_cb,
2690 .help = "Set up dedicated gettimeofday() thread on this CPU",
2691 .verify = gtod_cpu_verify,
2692 .category = FIO_OPT_C_GENERAL,
2693 .group = FIO_OPT_G_INVALID,
2696 .name = "continue_on_error",
2697 .lname = "Continue on error",
2698 .type = FIO_OPT_STR,
2699 .off1 = td_var_offset(continue_on_error),
2700 .help = "Continue on non-fatal errors during IO",
2702 .category = FIO_OPT_C_GENERAL,
2703 .group = FIO_OPT_G_INVALID,
2706 .oval = ERROR_TYPE_NONE,
2707 .help = "Exit when an error is encountered",
2710 .oval = ERROR_TYPE_READ,
2711 .help = "Continue on read errors only",
2714 .oval = ERROR_TYPE_WRITE,
2715 .help = "Continue on write errors only",
2718 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
2719 .help = "Continue on any IO errors",
2722 .oval = ERROR_TYPE_VERIFY,
2723 .help = "Continue on verify errors only",
2726 .oval = ERROR_TYPE_ANY,
2727 .help = "Continue on all io and verify errors",
2730 .oval = ERROR_TYPE_NONE,
2731 .help = "Alias for 'none'",
2734 .oval = ERROR_TYPE_ANY,
2735 .help = "Alias for 'all'",
2742 .type = FIO_OPT_STR_STORE,
2743 .off1 = td_var_offset(profile),
2744 .help = "Select a specific builtin performance test",
2745 .category = FIO_OPT_C_GENERAL,
2746 .group = FIO_OPT_G_INVALID,
2751 .type = FIO_OPT_STR_STORE,
2752 .off1 = td_var_offset(cgroup),
2753 .help = "Add job to cgroup of this name",
2754 .category = FIO_OPT_C_GENERAL,
2755 .group = FIO_OPT_G_INVALID,
2758 .name = "cgroup_weight",
2759 .lname = "Cgroup weight",
2760 .type = FIO_OPT_INT,
2761 .off1 = td_var_offset(cgroup_weight),
2762 .help = "Use given weight for cgroup",
2765 .category = FIO_OPT_C_GENERAL,
2766 .group = FIO_OPT_G_INVALID,
2769 .name = "cgroup_nodelete",
2770 .lname = "Cgroup no-delete",
2771 .type = FIO_OPT_BOOL,
2772 .off1 = td_var_offset(cgroup_nodelete),
2773 .help = "Do not delete cgroups after job completion",
2775 .category = FIO_OPT_C_GENERAL,
2776 .group = FIO_OPT_G_INVALID,
2781 .type = FIO_OPT_INT,
2782 .off1 = td_var_offset(uid),
2783 .help = "Run job with this user ID",
2784 .category = FIO_OPT_C_GENERAL,
2785 .group = FIO_OPT_G_INVALID,
2789 .lname = "Group ID",
2790 .type = FIO_OPT_INT,
2791 .off1 = td_var_offset(gid),
2792 .help = "Run job with this group ID",
2793 .category = FIO_OPT_C_GENERAL,
2794 .group = FIO_OPT_G_INVALID,
2798 .lname = "I/O flow ID",
2799 .type = FIO_OPT_INT,
2800 .off1 = td_var_offset(flow_id),
2801 .help = "The flow index ID to use",
2803 .category = FIO_OPT_C_IO,
2804 .group = FIO_OPT_G_IO_FLOW,
2808 .lname = "I/O flow weight",
2809 .type = FIO_OPT_INT,
2810 .off1 = td_var_offset(flow),
2811 .help = "Weight for flow control of this job",
2812 .parent = "flow_id",
2815 .category = FIO_OPT_C_IO,
2816 .group = FIO_OPT_G_IO_FLOW,
2819 .name = "flow_watermark",
2820 .lname = "I/O flow watermark",
2821 .type = FIO_OPT_INT,
2822 .off1 = td_var_offset(flow_watermark),
2823 .help = "High watermark for flow control. This option"
2824 " should be set to the same value for all threads"
2825 " with non-zero flow.",
2826 .parent = "flow_id",
2829 .category = FIO_OPT_C_IO,
2830 .group = FIO_OPT_G_IO_FLOW,
2833 .name = "flow_sleep",
2834 .lname = "I/O flow sleep",
2835 .type = FIO_OPT_INT,
2836 .off1 = td_var_offset(flow_sleep),
2837 .help = "How many microseconds to sleep after being held"
2838 " back by the flow control mechanism",
2839 .parent = "flow_id",
2842 .category = FIO_OPT_C_IO,
2843 .group = FIO_OPT_G_IO_FLOW,
2850 static void add_to_lopt(struct option *lopt, struct fio_option *o,
2851 const char *name, int val)
2853 lopt->name = (char *) name;
2855 if (o->type == FIO_OPT_STR_SET)
2856 lopt->has_arg = no_argument;
2858 lopt->has_arg = required_argument;
2861 static void options_to_lopts(struct fio_option *opts,
2862 struct option *long_options,
2863 int i, int option_type)
2865 struct fio_option *o = &opts[0];
2867 add_to_lopt(&long_options[i], o, o->name, option_type);
2870 add_to_lopt(&long_options[i], o, o->alias, option_type);
2875 assert(i < FIO_NR_OPTIONS);
2879 void fio_options_set_ioengine_opts(struct option *long_options,
2880 struct thread_data *td)
2885 while (long_options[i].name) {
2886 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
2887 memset(&long_options[i], 0, sizeof(*long_options));
2894 * Just clear out the prior ioengine options.
2899 options_to_lopts(td->io_ops->options, long_options, i,
2900 FIO_GETOPT_IOENGINE);
2903 void fio_options_dup_and_init(struct option *long_options)
2907 options_init(fio_options);
2910 while (long_options[i].name)
2913 options_to_lopts(fio_options, long_options, i, FIO_GETOPT_JOB);
2916 struct fio_keyword {
2922 static struct fio_keyword fio_keywords[] = {
2924 .word = "$pagesize",
2925 .desc = "Page size in the system",
2928 .word = "$mb_memory",
2929 .desc = "Megabytes of memory online",
2933 .desc = "Number of CPUs online in the system",
2940 void fio_keywords_init(void)
2942 unsigned long long mb_memory;
2946 sprintf(buf, "%lu", page_size);
2947 fio_keywords[0].replace = strdup(buf);
2949 mb_memory = os_phys_mem() / (1024 * 1024);
2950 sprintf(buf, "%llu", mb_memory);
2951 fio_keywords[1].replace = strdup(buf);
2954 sprintf(buf, "%lu", l);
2955 fio_keywords[2].replace = strdup(buf);
2960 static char *bc_calc(char *str)
2962 char buf[128], *tmp;
2967 * No math, just return string
2969 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
2970 !strchr(str, '/')) || strchr(str, '\''))
2974 * Split option from value, we only need to calculate the value
2976 tmp = strchr(str, '=');
2983 * Prevent buffer overflows; such a case isn't reasonable anyway
2985 if (strlen(str) >= 128 || strlen(tmp) > 100)
2988 sprintf(buf, "which %s > /dev/null", BC_APP);
2990 log_err("fio: bc is needed for performing math\n");
2994 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
2995 f = popen(buf, "r");
3000 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
3006 buf[(tmp - str) + ret - 1] = '\0';
3007 memcpy(buf, str, tmp - str);
3013 * Return a copy of the input string with substrings of the form ${VARNAME}
3014 * substituted with the value of the environment variable VARNAME. The
3015 * substitution always occurs, even if VARNAME is empty or the corresponding
3016 * environment variable undefined.
3018 static char *option_dup_subs(const char *opt)
3020 char out[OPT_LEN_MAX+1];
3021 char in[OPT_LEN_MAX+1];
3024 char *ch1, *ch2, *env;
3025 ssize_t nchr = OPT_LEN_MAX;
3028 if (strlen(opt) + 1 > OPT_LEN_MAX) {
3029 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
3033 in[OPT_LEN_MAX] = '\0';
3034 strncpy(in, opt, OPT_LEN_MAX);
3036 while (*inptr && nchr > 0) {
3037 if (inptr[0] == '$' && inptr[1] == '{') {
3038 ch2 = strchr(inptr, '}');
3039 if (ch2 && inptr+1 < ch2) {
3046 envlen = strlen(env);
3047 if (envlen <= nchr) {
3048 memcpy(outptr, env, envlen);
3058 *outptr++ = *inptr++;
3067 * Look for reserved variable names and replace them with real values
3069 static char *fio_keyword_replace(char *opt)
3075 for (i = 0; fio_keywords[i].word != NULL; i++) {
3076 struct fio_keyword *kw = &fio_keywords[i];
3078 while ((s = strstr(opt, kw->word)) != NULL) {
3079 char *new = malloc(strlen(opt) + 1);
3085 * Copy part of the string before the keyword and
3086 * sprintf() the replacement after it.
3088 memcpy(new, opt, olen);
3089 len = sprintf(new + olen, "%s", kw->replace);
3092 * If there's more in the original string, copy that
3095 opt += strlen(kw->word) + olen;
3097 memcpy(new + olen + len, opt, opt - o_org - 1);
3100 * replace opt and free the old opt
3110 * Check for potential math and invoke bc, if possible
3118 static char **dup_and_sub_options(char **opts, int num_opts)
3121 char **opts_copy = malloc(num_opts * sizeof(*opts));
3122 for (i = 0; i < num_opts; i++) {
3123 opts_copy[i] = option_dup_subs(opts[i]);
3126 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
3131 int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
3133 int i, ret, unknown;
3136 sort_options(opts, fio_options, num_opts);
3137 opts_copy = dup_and_sub_options(opts, num_opts);
3139 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
3140 struct fio_option *o;
3141 int newret = parse_option(opts_copy[i], opts[i], fio_options,
3150 opts_copy[i] = NULL;
3157 ret |= ioengine_load(td);
3159 sort_options(opts_copy, td->io_ops->options, num_opts);
3162 for (i = 0; i < num_opts; i++) {
3163 struct fio_option *o = NULL;
3169 newret = parse_option(opts_copy[i], opts[i],
3170 td->io_ops->options, &o,
3175 log_err("Bad option <%s>\n", opts[i]);
3178 opts_copy[i] = NULL;
3186 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
3188 return parse_cmd_option(opt, val, fio_options, td);
3191 int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
3194 return parse_cmd_option(opt, val, td->io_ops->options, td);
3197 void fio_fill_default_options(struct thread_data *td)
3199 fill_default_options(td, fio_options);
3202 int fio_show_option_help(const char *opt)
3204 return show_cmd_help(fio_options, opt);
3207 void options_mem_dupe(void *data, struct fio_option *options)
3209 struct fio_option *o;
3212 for (o = &options[0]; o->name; o++) {
3213 if (o->type != FIO_OPT_STR_STORE)
3216 ptr = td_var(data, o->off1);
3218 *ptr = strdup(*ptr);
3223 * dupe FIO_OPT_STR_STORE options
3225 void fio_options_mem_dupe(struct thread_data *td)
3227 options_mem_dupe(&td->o, fio_options);
3229 if (td->eo && td->io_ops) {
3230 void *oldeo = td->eo;
3232 td->eo = malloc(td->io_ops->option_struct_size);
3233 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
3234 options_mem_dupe(td->eo, td->io_ops->options);
3238 unsigned int fio_get_kb_base(void *data)
3240 struct thread_data *td = data;
3241 unsigned int kb_base = 0;
3244 kb_base = td->o.kb_base;
3251 int add_option(struct fio_option *o)
3253 struct fio_option *__o;
3262 memcpy(&fio_options[opt_index], o, sizeof(*o));
3266 void invalidate_profile_options(const char *prof_name)
3268 struct fio_option *o;
3272 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
3273 o->type = FIO_OPT_INVALID;
3274 o->prof_name = NULL;
3280 void add_opt_posval(const char *optname, const char *ival, const char *help)
3282 struct fio_option *o;
3285 o = find_option(fio_options, optname);
3289 for (i = 0; i < PARSE_MAX_VP; i++) {
3290 if (o->posval[i].ival)
3293 o->posval[i].ival = ival;
3294 o->posval[i].help = help;
3299 void del_opt_posval(const char *optname, const char *ival)
3301 struct fio_option *o;
3304 o = find_option(fio_options, optname);
3308 for (i = 0; i < PARSE_MAX_VP; i++) {
3309 if (!o->posval[i].ival)
3311 if (strcmp(o->posval[i].ival, ival))
3314 o->posval[i].ival = NULL;
3315 o->posval[i].help = NULL;
3319 void fio_options_free(struct thread_data *td)
3321 options_free(fio_options, td);
3322 if (td->eo && td->io_ops && td->io_ops->options) {
3323 options_free(td->io_ops->options, td->eo);