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_options *o, int ddir, char *str)
66 struct bssplit *bssplit;
67 unsigned int i, perc, perc_missing;
68 unsigned int max_bs, min_bs;
72 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 == o->bssplit_nr[ddir]) {
88 o->bssplit_nr[ddir] <<= 1;
89 bssplit = realloc(bssplit, 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, o)) {
106 log_err("fio: bssplit conversion failed\n");
117 bssplit[i].perc = perc;
121 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 < 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 < 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 o->min_bs[ddir] = min_bs;
155 o->max_bs[ddir] = max_bs;
158 * now sort based on percentages, for ease of lookup
160 qsort(bssplit, o->bssplit_nr[ddir], sizeof(struct bssplit), bs_cmp);
161 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->o, DDIR_WRITE, odir + 1);
181 ret = bssplit_ddir(&td->o, DDIR_READ, str);
188 ret = bssplit_ddir(&td->o, DDIR_READ, str);
190 ret = bssplit_ddir(&td->o, DDIR_WRITE, op);
199 static int str_rw_cb(void *data, const char *str)
201 struct thread_data *td = data;
202 struct thread_options *o = &td->o;
203 char *nr = get_opt_postfix(str);
212 o->ddir_seq_nr = atoi(nr);
216 if (str_to_decimal(nr, &val, 1, o)) {
217 log_err("fio: rw postfix parsing failed\n");
222 o->ddir_seq_add = val;
229 static int str_mem_cb(void *data, const char *mem)
231 struct thread_data *td = data;
232 struct thread_options *o = &td->o;
234 if (o->mem_type == MEM_MMAPHUGE || o->mem_type == MEM_MMAP) {
235 o->mmapfile = get_opt_postfix(mem);
236 if (o->mem_type == MEM_MMAPHUGE && !o->mmapfile) {
237 log_err("fio: mmaphuge:/path/to/file\n");
245 static int fio_clock_source_cb(void *data, const char *str)
247 struct thread_data *td = data;
249 fio_clock_source = td->o.clocksource;
254 static int str_rwmix_read_cb(void *data, unsigned long long *val)
256 struct thread_data *td = data;
258 td->o.rwmix[DDIR_READ] = *val;
259 td->o.rwmix[DDIR_WRITE] = 100 - *val;
263 static int str_rwmix_write_cb(void *data, unsigned long long *val)
265 struct thread_data *td = data;
267 td->o.rwmix[DDIR_WRITE] = *val;
268 td->o.rwmix[DDIR_READ] = 100 - *val;
272 static int str_exitall_cb(void)
274 exitall_on_terminate = 1;
278 #ifdef FIO_HAVE_CPU_AFFINITY
279 static int str_cpumask_cb(void *data, unsigned long long *val)
281 struct thread_data *td = data;
286 ret = fio_cpuset_init(&td->o.cpumask);
288 log_err("fio: cpuset_init failed\n");
289 td_verror(td, ret, "fio_cpuset_init");
293 max_cpu = cpus_online();
295 for (i = 0; i < sizeof(int) * 8; i++) {
296 if ((1 << i) & *val) {
298 log_err("fio: CPU %d too large (max=%ld)\n", i,
302 dprint(FD_PARSE, "set cpu allowed %d\n", i);
303 fio_cpu_set(&td->o.cpumask, i);
307 td->o.cpumask_set = 1;
311 static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask,
318 ret = fio_cpuset_init(mask);
320 log_err("fio: cpuset_init failed\n");
321 td_verror(td, ret, "fio_cpuset_init");
325 p = str = strdup(input);
327 strip_blank_front(&str);
328 strip_blank_end(str);
330 max_cpu = cpus_online();
332 while ((cpu = strsep(&str, ",")) != NULL) {
341 while ((cpu2 = strsep(&str2, "-")) != NULL) {
351 while (icpu <= icpu2) {
352 if (icpu >= FIO_MAX_CPUS) {
353 log_err("fio: your OS only supports up to"
354 " %d CPUs\n", (int) FIO_MAX_CPUS);
358 if (icpu > max_cpu) {
359 log_err("fio: CPU %d too large (max=%ld)\n",
365 dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
366 fio_cpu_set(mask, icpu);
375 td->o.cpumask_set = 1;
379 static int str_cpus_allowed_cb(void *data, const char *input)
381 struct thread_data *td = data;
384 ret = set_cpus_allowed(td, &td->o.cpumask, input);
386 td->o.cpumask_set = 1;
391 static int str_verify_cpus_allowed_cb(void *data, const char *input)
393 struct thread_data *td = data;
396 ret = set_cpus_allowed(td, &td->o.verify_cpumask, input);
398 td->o.verify_cpumask_set = 1;
404 static int str_fst_cb(void *data, const char *str)
406 struct thread_data *td = data;
407 char *nr = get_opt_postfix(str);
409 td->file_service_nr = 1;
411 td->file_service_nr = atoi(nr);
418 #ifdef FIO_HAVE_SYNC_FILE_RANGE
419 static int str_sfr_cb(void *data, const char *str)
421 struct thread_data *td = data;
422 char *nr = get_opt_postfix(str);
424 td->sync_file_range_nr = 1;
426 td->sync_file_range_nr = atoi(nr);
435 * Return next file in the string. Files are separated with ':'. If the ':'
436 * is escaped with a '\', then that ':' is part of the filename and does not
437 * indicate a new file.
439 static char *get_next_file_name(char **ptr)
444 if (!str || !strlen(str))
450 * No colon, we are done
452 p = strchr(str, ':');
459 * We got a colon, but it's the first character. Skip and
467 if (*(p - 1) != '\\') {
473 memmove(p - 1, p, strlen(p) + 1);
480 static int str_filename_cb(void *data, const char *input)
482 struct thread_data *td = data;
483 char *fname, *str, *p;
485 p = str = strdup(input);
487 strip_blank_front(&str);
488 strip_blank_end(str);
490 if (!td->files_index)
493 while ((fname = get_next_file_name(&str)) != NULL) {
504 static int str_directory_cb(void *data, const char fio_unused *str)
506 struct thread_data *td = data;
509 if (lstat(td->o.directory, &sb) < 0) {
512 log_err("fio: %s is not a directory\n", td->o.directory);
513 td_verror(td, ret, "lstat");
516 if (!S_ISDIR(sb.st_mode)) {
517 log_err("fio: %s is not a directory\n", td->o.directory);
524 static int str_opendir_cb(void *data, const char fio_unused *str)
526 struct thread_data *td = data;
528 if (!td->files_index)
531 return add_dir_files(td, td->o.opendir);
534 static int str_verify_pattern_cb(void *data, const char *input)
536 struct thread_data *td = data;
538 int i = 0, j = 0, len, k, base = 10;
541 loc1 = strstr(input, "0x");
542 loc2 = strstr(input, "0X");
545 off = strtol(input, NULL, base);
546 if (off != LONG_MAX || errno != ERANGE) {
548 td->o.verify_pattern[i] = off & 0xff;
557 j = loc1 - input + 2;
559 j = loc2 - input + 2;
562 if (len - j < MAX_PATTERN_SIZE * 2) {
564 off = converthexchartoint(input[k--]);
566 off += (converthexchartoint(input[k--])
568 td->o.verify_pattern[i++] = (char) off;
574 * Fill the pattern all the way to the end. This greatly reduces
575 * the number of memcpy's we have to do when verifying the IO.
577 while (i > 1 && i * 2 <= MAX_PATTERN_SIZE) {
578 memcpy(&td->o.verify_pattern[i], &td->o.verify_pattern[0], i);
583 * The code in verify_io_u_pattern assumes a single byte pattern
584 * fills the whole verify pattern buffer.
586 memset(td->o.verify_pattern, td->o.verify_pattern[0],
590 td->o.verify_pattern_bytes = i;
593 * VERIFY_META could already be set
595 if (td->o.verify == VERIFY_NONE)
596 td->o.verify = VERIFY_PATTERN;
601 static int str_lockfile_cb(void *data, const char *str)
603 struct thread_data *td = data;
604 char *nr = get_opt_postfix(str);
606 td->o.lockfile_batch = 1;
608 td->o.lockfile_batch = atoi(nr);
615 static int str_gtod_reduce_cb(void *data, int *il)
617 struct thread_data *td = data;
620 td->o.disable_lat = !!val;
621 td->o.disable_clat = !!val;
622 td->o.disable_slat = !!val;
623 td->o.disable_bw = !!val;
624 td->o.clat_percentiles = !val;
626 td->tv_cache_mask = 63;
631 static int str_gtod_cpu_cb(void *data, long long *il)
633 struct thread_data *td = data;
636 td->o.gtod_cpu = val;
637 td->o.gtod_offload = 1;
641 static int str_size_cb(void *data, unsigned long long *__val)
643 struct thread_data *td = data;
644 unsigned long long v = *__val;
646 if (parse_is_percent(v)) {
648 td->o.size_percent = -1ULL - v;
655 static int rw_verify(struct fio_option *o, void *data)
657 struct thread_data *td = data;
659 if (read_only && td_write(td)) {
660 log_err("fio: job <%s> has write bit set, but fio is in"
661 " read-only mode\n", td->o.name);
668 static int gtod_cpu_verify(struct fio_option *o, void *data)
670 #ifndef FIO_HAVE_CPU_AFFINITY
671 struct thread_data *td = data;
673 if (td->o.gtod_cpu) {
674 log_err("fio: platform must support CPU affinity for"
675 "gettimeofday() offloading\n");
683 static int kb_base_verify(struct fio_option *o, void *data)
685 struct thread_data *td = data;
687 if (td->o.kb_base != 1024 && td->o.kb_base != 1000) {
688 log_err("fio: kb_base set to nonsensical value: %u\n",
699 static struct opt_group fio_opt_groups[] = {
702 .mask = FIO_OPT_C_GENERAL,
706 .mask = FIO_OPT_C_IO,
710 .mask = FIO_OPT_C_FILE,
713 .name = "Statistics",
714 .mask = FIO_OPT_C_STAT,
718 .mask = FIO_OPT_C_LOG,
722 .mask = FIO_OPT_C_PROFILE,
729 static struct opt_group *__opt_group_from_mask(struct opt_group *ogs, unsigned int *mask,
730 unsigned int inv_mask)
732 struct opt_group *og;
735 if (*mask == inv_mask || !*mask)
738 for (i = 0; ogs[i].name; i++) {
741 if (*mask & og->mask) {
742 *mask &= ~(og->mask);
750 struct opt_group *opt_group_from_mask(unsigned int *mask)
752 return __opt_group_from_mask(fio_opt_groups, mask, FIO_OPT_C_INVALID);
755 static struct opt_group fio_opt_cat_groups[] = {
758 .mask = FIO_OPT_G_RATE,
762 .mask = FIO_OPT_G_ZONE,
765 .name = "Read/write mix",
766 .mask = FIO_OPT_G_RWMIX,
770 .mask = FIO_OPT_G_VERIFY,
774 .mask = FIO_OPT_G_TRIM,
777 .name = "I/O Logging",
778 .mask = FIO_OPT_G_IOLOG,
782 .mask = FIO_OPT_G_IO_DEPTH,
786 .mask = FIO_OPT_G_IO_FLOW,
789 .name = "Description",
790 .mask = FIO_OPT_G_DESC,
794 .mask = FIO_OPT_G_FILENAME,
797 .name = "General I/O",
798 .mask = FIO_OPT_G_IO_BASIC,
802 .mask = FIO_OPT_G_CGROUP,
806 .mask = FIO_OPT_G_RUNTIME,
810 .mask = FIO_OPT_G_PROCESS,
813 .name = "Job credentials / priority",
814 .mask = FIO_OPT_G_CRED,
817 .name = "Clock settings",
818 .mask = FIO_OPT_G_CLOCK,
822 .mask = FIO_OPT_G_IO_TYPE,
825 .name = "I/O Thinktime",
826 .mask = FIO_OPT_G_THINKTIME,
829 .name = "Randomizations",
830 .mask = FIO_OPT_G_RANDOM,
833 .name = "I/O buffers",
834 .mask = FIO_OPT_G_IO_BUF,
837 .name = "Tiobench profile",
838 .mask = FIO_OPT_G_TIOBENCH,
846 struct opt_group *opt_group_cat_from_mask(unsigned int *mask)
848 return __opt_group_from_mask(fio_opt_cat_groups, mask, FIO_OPT_G_INVALID);
852 * Map of job/command line options
854 struct fio_option fio_options[FIO_MAX_OPTS] = {
856 .name = "description",
857 .lname = "Description of job",
858 .type = FIO_OPT_STR_STORE,
859 .off1 = td_var_offset(description),
860 .help = "Text job description",
861 .category = FIO_OPT_C_GENERAL,
862 .group = FIO_OPT_G_DESC,
867 .type = FIO_OPT_STR_STORE,
868 .off1 = td_var_offset(name),
869 .help = "Name of this job",
870 .category = FIO_OPT_C_GENERAL,
871 .group = FIO_OPT_G_DESC,
875 .lname = "Filename(s)",
876 .type = FIO_OPT_STR_STORE,
877 .off1 = td_var_offset(filename),
878 .cb = str_filename_cb,
879 .prio = -1, /* must come after "directory" */
880 .help = "File(s) to use for the workload",
881 .category = FIO_OPT_C_FILE,
882 .group = FIO_OPT_G_FILENAME,
886 .lname = "Directory",
887 .type = FIO_OPT_STR_STORE,
888 .off1 = td_var_offset(directory),
889 .cb = str_directory_cb,
890 .help = "Directory to store files in",
891 .category = FIO_OPT_C_FILE,
892 .group = FIO_OPT_G_FILENAME,
898 .cb = str_lockfile_cb,
899 .off1 = td_var_offset(file_lock_mode),
900 .help = "Lock file when doing IO to it",
901 .parent = "filename",
904 .category = FIO_OPT_C_FILE,
905 .group = FIO_OPT_G_FILENAME,
908 .oval = FILE_LOCK_NONE,
909 .help = "No file locking",
911 { .ival = "exclusive",
912 .oval = FILE_LOCK_EXCLUSIVE,
913 .help = "Exclusive file lock",
917 .oval = FILE_LOCK_READWRITE,
918 .help = "Read vs write lock",
924 .lname = "Open directory",
925 .type = FIO_OPT_STR_STORE,
926 .off1 = td_var_offset(opendir),
927 .cb = str_opendir_cb,
928 .help = "Recursively add files from this directory and down",
929 .category = FIO_OPT_C_FILE,
930 .group = FIO_OPT_G_FILENAME,
934 .lname = "Read/write",
935 .alias = "readwrite",
938 .off1 = td_var_offset(td_ddir),
939 .help = "IO direction",
942 .category = FIO_OPT_C_IO,
943 .group = FIO_OPT_G_IO_BASIC,
946 .oval = TD_DDIR_READ,
947 .help = "Sequential read",
950 .oval = TD_DDIR_WRITE,
951 .help = "Sequential write",
953 { .ival = "randread",
954 .oval = TD_DDIR_RANDREAD,
955 .help = "Random read",
957 { .ival = "randwrite",
958 .oval = TD_DDIR_RANDWRITE,
959 .help = "Random write",
963 .help = "Sequential read and write mix",
966 .oval = TD_DDIR_RANDRW,
967 .help = "Random read and write mix"
972 .name = "rw_sequencer",
973 .lname = "RW Sequencer",
975 .off1 = td_var_offset(rw_seq),
976 .help = "IO offset generator modifier",
978 .category = FIO_OPT_C_IO,
979 .group = FIO_OPT_G_IO_BASIC,
981 { .ival = "sequential",
983 .help = "Generate sequential offsets",
985 { .ival = "identical",
986 .oval = RW_SEQ_IDENT,
987 .help = "Generate identical offsets",
994 .lname = "IO Engine",
995 .type = FIO_OPT_STR_STORE,
996 .off1 = td_var_offset(ioengine),
997 .help = "IO engine to use",
998 .def = FIO_PREFERRED_ENGINE,
999 .category = FIO_OPT_C_IO,
1000 .group = FIO_OPT_G_IO_BASIC,
1003 .help = "Use read/write",
1006 .help = "Use pread/pwrite",
1009 .help = "Use readv/writev",
1011 #ifdef FIO_HAVE_LIBAIO
1013 .help = "Linux native asynchronous IO",
1016 #ifdef FIO_HAVE_POSIXAIO
1017 { .ival = "posixaio",
1018 .help = "POSIX asynchronous IO",
1021 #ifdef FIO_HAVE_SOLARISAIO
1022 { .ival = "solarisaio",
1023 .help = "Solaris native asynchronous IO",
1026 #ifdef FIO_HAVE_WINDOWSAIO
1027 { .ival = "windowsaio",
1028 .help = "Windows native asynchronous IO"
1032 .help = "Memory mapped IO"
1034 #ifdef FIO_HAVE_SPLICE
1036 .help = "splice/vmsplice based IO",
1038 { .ival = "netsplice",
1039 .help = "splice/vmsplice to/from the network",
1042 #ifdef FIO_HAVE_SGIO
1044 .help = "SCSI generic v3 IO",
1048 .help = "Testing engine (no data transfer)",
1051 .help = "Network IO",
1053 #ifdef FIO_HAVE_SYSLET
1054 { .ival = "syslet-rw",
1055 .help = "syslet enabled async pread/pwrite IO",
1059 .help = "CPU cycle burner engine",
1061 #ifdef FIO_HAVE_GUASI
1063 .help = "GUASI IO engine",
1066 #ifdef FIO_HAVE_BINJECT
1067 { .ival = "binject",
1068 .help = "binject direct inject block engine",
1071 #ifdef FIO_HAVE_RDMA
1073 .help = "RDMA IO engine",
1076 { .ival = "external",
1077 .help = "Load external engine (append name)",
1083 .lname = "IO Depth",
1084 .type = FIO_OPT_INT,
1085 .off1 = td_var_offset(iodepth),
1086 .help = "Number of IO buffers to keep in flight",
1090 .category = FIO_OPT_C_IO,
1091 .group = FIO_OPT_G_IO_BASIC,
1094 .name = "iodepth_batch",
1095 .lname = "IO Depth batch",
1096 .alias = "iodepth_batch_submit",
1097 .type = FIO_OPT_INT,
1098 .off1 = td_var_offset(iodepth_batch),
1099 .help = "Number of IO buffers to submit in one go",
1100 .parent = "iodepth",
1105 .category = FIO_OPT_C_IO,
1106 .group = FIO_OPT_G_IO_BASIC,
1109 .name = "iodepth_batch_complete",
1110 .lname = "IO Depth batch complete",
1111 .type = FIO_OPT_INT,
1112 .off1 = td_var_offset(iodepth_batch_complete),
1113 .help = "Number of IO buffers to retrieve in one go",
1114 .parent = "iodepth",
1119 .category = FIO_OPT_C_IO,
1120 .group = FIO_OPT_G_IO_BASIC,
1123 .name = "iodepth_low",
1124 .lname = "IO Depth batch low",
1125 .type = FIO_OPT_INT,
1126 .off1 = td_var_offset(iodepth_low),
1127 .help = "Low water mark for queuing depth",
1128 .parent = "iodepth",
1131 .category = FIO_OPT_C_IO,
1132 .group = FIO_OPT_G_IO_BASIC,
1137 .type = FIO_OPT_STR_VAL,
1139 .help = "Total size of device or files",
1140 .interval = 1024 * 1024,
1141 .category = FIO_OPT_C_IO,
1142 .group = FIO_OPT_G_INVALID,
1145 .name = "fill_device",
1146 .lname = "Fill device",
1148 .type = FIO_OPT_BOOL,
1149 .off1 = td_var_offset(fill_device),
1150 .help = "Write until an ENOSPC error occurs",
1152 .category = FIO_OPT_C_FILE,
1153 .group = FIO_OPT_G_INVALID,
1157 .lname = "File size",
1158 .type = FIO_OPT_STR_VAL,
1159 .off1 = td_var_offset(file_size_low),
1160 .off2 = td_var_offset(file_size_high),
1162 .help = "Size of individual files",
1163 .interval = 1024 * 1024,
1164 .category = FIO_OPT_C_FILE,
1165 .group = FIO_OPT_G_INVALID,
1169 .lname = "IO offset",
1170 .alias = "fileoffset",
1171 .type = FIO_OPT_STR_VAL,
1172 .off1 = td_var_offset(start_offset),
1173 .help = "Start IO from this offset",
1175 .interval = 1024 * 1024,
1176 .category = FIO_OPT_C_IO,
1177 .group = FIO_OPT_G_INVALID,
1180 .name = "offset_increment",
1181 .lname = "IO offset increment",
1182 .type = FIO_OPT_STR_VAL,
1183 .off1 = td_var_offset(offset_increment),
1184 .help = "What is the increment from one offset to the next",
1188 .interval = 1024 * 1024,
1189 .category = FIO_OPT_C_IO,
1190 .group = FIO_OPT_G_INVALID,
1194 .lname = "Block size",
1195 .alias = "blocksize",
1196 .type = FIO_OPT_INT,
1197 .off1 = td_var_offset(bs[DDIR_READ]),
1198 .off2 = td_var_offset(bs[DDIR_WRITE]),
1200 .help = "Block size unit",
1205 .category = FIO_OPT_C_IO,
1206 .group = FIO_OPT_G_INVALID,
1210 .lname = "Block size align",
1211 .alias = "blockalign",
1212 .type = FIO_OPT_INT,
1213 .off1 = td_var_offset(ba[DDIR_READ]),
1214 .off2 = td_var_offset(ba[DDIR_WRITE]),
1216 .help = "IO block offset alignment",
1220 .category = FIO_OPT_C_IO,
1221 .group = FIO_OPT_G_INVALID,
1225 .lname = "Block size range",
1226 .alias = "blocksize_range",
1227 .type = FIO_OPT_RANGE,
1228 .off1 = td_var_offset(min_bs[DDIR_READ]),
1229 .off2 = td_var_offset(max_bs[DDIR_READ]),
1230 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
1231 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
1233 .help = "Set block size range (in more detail than bs)",
1237 .category = FIO_OPT_C_IO,
1238 .group = FIO_OPT_G_INVALID,
1242 .lname = "Block size split",
1243 .type = FIO_OPT_STR,
1244 .cb = str_bssplit_cb,
1245 .help = "Set a specific mix of block sizes",
1248 .category = FIO_OPT_C_IO,
1249 .group = FIO_OPT_G_INVALID,
1252 .name = "bs_unaligned",
1253 .lname = "Block size unaligned",
1254 .alias = "blocksize_unaligned",
1255 .type = FIO_OPT_STR_SET,
1256 .off1 = td_var_offset(bs_unaligned),
1257 .help = "Don't sector align IO buffer sizes",
1260 .category = FIO_OPT_C_IO,
1261 .group = FIO_OPT_G_INVALID,
1264 .name = "randrepeat",
1265 .lname = "Random repeatable",
1266 .type = FIO_OPT_BOOL,
1267 .off1 = td_var_offset(rand_repeatable),
1268 .help = "Use repeatable random IO pattern",
1272 .category = FIO_OPT_C_IO,
1273 .group = FIO_OPT_G_RANDOM,
1276 .name = "use_os_rand",
1277 .lname = "Use OS random",
1278 .type = FIO_OPT_BOOL,
1279 .off1 = td_var_offset(use_os_rand),
1280 .help = "Set to use OS random generator",
1284 .category = FIO_OPT_C_IO,
1285 .group = FIO_OPT_G_RANDOM,
1288 .name = "norandommap",
1289 .lname = "No randommap",
1290 .type = FIO_OPT_STR_SET,
1291 .off1 = td_var_offset(norandommap),
1292 .help = "Accept potential duplicate random blocks",
1296 .category = FIO_OPT_C_IO,
1297 .group = FIO_OPT_G_RANDOM,
1300 .name = "softrandommap",
1301 .lname = "Soft randommap",
1302 .type = FIO_OPT_BOOL,
1303 .off1 = td_var_offset(softrandommap),
1304 .help = "Set norandommap if randommap allocation fails",
1305 .parent = "norandommap",
1308 .category = FIO_OPT_C_IO,
1309 .group = FIO_OPT_G_RANDOM,
1313 .lname = "Number of files",
1314 .alias = "nr_files",
1315 .type = FIO_OPT_INT,
1316 .off1 = td_var_offset(nr_files),
1317 .help = "Split job workload between this number of files",
1320 .category = FIO_OPT_C_FILE,
1321 .group = FIO_OPT_G_INVALID,
1324 .name = "openfiles",
1325 .lname = "Number of open files",
1326 .type = FIO_OPT_INT,
1327 .off1 = td_var_offset(open_files),
1328 .help = "Number of files to keep open at the same time",
1329 .category = FIO_OPT_C_FILE,
1330 .group = FIO_OPT_G_INVALID,
1333 .name = "file_service_type",
1334 .lname = "File service type",
1335 .type = FIO_OPT_STR,
1337 .off1 = td_var_offset(file_service_type),
1338 .help = "How to select which file to service next",
1339 .def = "roundrobin",
1340 .category = FIO_OPT_C_FILE,
1341 .group = FIO_OPT_G_INVALID,
1344 .oval = FIO_FSERVICE_RANDOM,
1345 .help = "Choose a file at random",
1347 { .ival = "roundrobin",
1348 .oval = FIO_FSERVICE_RR,
1349 .help = "Round robin select files",
1351 { .ival = "sequential",
1352 .oval = FIO_FSERVICE_SEQ,
1353 .help = "Finish one file before moving to the next",
1356 .parent = "nrfiles",
1359 #ifdef FIO_HAVE_FALLOCATE
1361 .name = "fallocate",
1362 .lname = "Fallocate",
1363 .type = FIO_OPT_STR,
1364 .off1 = td_var_offset(fallocate_mode),
1365 .help = "Whether pre-allocation is performed when laying out files",
1367 .category = FIO_OPT_C_FILE,
1368 .group = FIO_OPT_G_INVALID,
1371 .oval = FIO_FALLOCATE_NONE,
1372 .help = "Do not pre-allocate space",
1375 .oval = FIO_FALLOCATE_POSIX,
1376 .help = "Use posix_fallocate()",
1378 #ifdef FIO_HAVE_LINUX_FALLOCATE
1380 .oval = FIO_FALLOCATE_KEEP_SIZE,
1381 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
1384 /* Compatibility with former boolean values */
1386 .oval = FIO_FALLOCATE_NONE,
1387 .help = "Alias for 'none'",
1390 .oval = FIO_FALLOCATE_POSIX,
1391 .help = "Alias for 'posix'",
1395 #endif /* FIO_HAVE_FALLOCATE */
1397 .name = "fadvise_hint",
1398 .lname = "Fadvise hint",
1399 .type = FIO_OPT_BOOL,
1400 .off1 = td_var_offset(fadvise_hint),
1401 .help = "Use fadvise() to advise the kernel on IO pattern",
1403 .category = FIO_OPT_C_FILE,
1404 .group = FIO_OPT_G_INVALID,
1409 .type = FIO_OPT_INT,
1410 .off1 = td_var_offset(fsync_blocks),
1411 .help = "Issue fsync for writes every given number of blocks",
1414 .category = FIO_OPT_C_FILE,
1415 .group = FIO_OPT_G_INVALID,
1418 .name = "fdatasync",
1419 .lname = "Fdatasync",
1420 .type = FIO_OPT_INT,
1421 .off1 = td_var_offset(fdatasync_blocks),
1422 .help = "Issue fdatasync for writes every given number of blocks",
1425 .category = FIO_OPT_C_FILE,
1426 .group = FIO_OPT_G_INVALID,
1429 .name = "write_barrier",
1430 .lname = "Write barrier",
1431 .type = FIO_OPT_INT,
1432 .off1 = td_var_offset(barrier_blocks),
1433 .help = "Make every Nth write a barrier write",
1436 .category = FIO_OPT_C_IO,
1437 .group = FIO_OPT_G_INVALID,
1439 #ifdef FIO_HAVE_SYNC_FILE_RANGE
1441 .name = "sync_file_range",
1442 .lname = "Sync file range",
1444 { .ival = "wait_before",
1445 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
1446 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
1450 .oval = SYNC_FILE_RANGE_WRITE,
1451 .help = "SYNC_FILE_RANGE_WRITE",
1455 .ival = "wait_after",
1456 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
1457 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
1461 .type = FIO_OPT_STR_MULTI,
1463 .off1 = td_var_offset(sync_file_range),
1464 .help = "Use sync_file_range()",
1465 .category = FIO_OPT_C_FILE,
1466 .group = FIO_OPT_G_INVALID,
1471 .lname = "Direct I/O",
1472 .type = FIO_OPT_BOOL,
1473 .off1 = td_var_offset(odirect),
1474 .help = "Use O_DIRECT IO (negates buffered)",
1476 .inverse = "buffered",
1477 .category = FIO_OPT_C_IO,
1478 .group = FIO_OPT_G_IO_TYPE,
1482 .lname = "Buffered I/O",
1483 .type = FIO_OPT_BOOL,
1484 .off1 = td_var_offset(odirect),
1486 .help = "Use buffered IO (negates direct)",
1488 .inverse = "direct",
1489 .category = FIO_OPT_C_IO,
1490 .group = FIO_OPT_G_IO_TYPE,
1493 .name = "overwrite",
1494 .lname = "Overwrite",
1495 .type = FIO_OPT_BOOL,
1496 .off1 = td_var_offset(overwrite),
1497 .help = "When writing, set whether to overwrite current data",
1499 .category = FIO_OPT_C_FILE,
1500 .group = FIO_OPT_G_INVALID,
1505 .type = FIO_OPT_INT,
1506 .off1 = td_var_offset(loops),
1507 .help = "Number of times to run the job",
1510 .category = FIO_OPT_C_GENERAL,
1511 .group = FIO_OPT_G_RUNTIME,
1515 .lname = "Number of jobs",
1516 .type = FIO_OPT_INT,
1517 .off1 = td_var_offset(numjobs),
1518 .help = "Duplicate this job this many times",
1521 .category = FIO_OPT_C_GENERAL,
1522 .group = FIO_OPT_G_RUNTIME,
1525 .name = "startdelay",
1526 .lname = "Start delay",
1527 .type = FIO_OPT_STR_VAL_TIME,
1528 .off1 = td_var_offset(start_delay),
1529 .help = "Only start job when this period has passed",
1531 .category = FIO_OPT_C_GENERAL,
1532 .group = FIO_OPT_G_RUNTIME,
1538 .type = FIO_OPT_STR_VAL_TIME,
1539 .off1 = td_var_offset(timeout),
1540 .help = "Stop workload when this amount of time has passed",
1542 .category = FIO_OPT_C_GENERAL,
1543 .group = FIO_OPT_G_RUNTIME,
1546 .name = "time_based",
1547 .lname = "Time based",
1548 .type = FIO_OPT_STR_SET,
1549 .off1 = td_var_offset(time_based),
1550 .help = "Keep running until runtime/timeout is met",
1551 .category = FIO_OPT_C_GENERAL,
1552 .group = FIO_OPT_G_RUNTIME,
1555 .name = "ramp_time",
1556 .lname = "Ramp time",
1557 .type = FIO_OPT_STR_VAL_TIME,
1558 .off1 = td_var_offset(ramp_time),
1559 .help = "Ramp up time before measuring performance",
1560 .category = FIO_OPT_C_GENERAL,
1561 .group = FIO_OPT_G_RUNTIME,
1564 .name = "clocksource",
1565 .lname = "Clock source",
1566 .type = FIO_OPT_STR,
1567 .cb = fio_clock_source_cb,
1568 .off1 = td_var_offset(clocksource),
1569 .help = "What type of timing source to use",
1570 .category = FIO_OPT_C_GENERAL,
1571 .group = FIO_OPT_G_CLOCK,
1573 { .ival = "gettimeofday",
1575 .help = "Use gettimeofday(2) for timing",
1577 { .ival = "clock_gettime",
1578 .oval = CS_CGETTIME,
1579 .help = "Use clock_gettime(2) for timing",
1581 #ifdef ARCH_HAVE_CPU_CLOCK
1583 .oval = CS_CPUCLOCK,
1584 .help = "Use CPU private clock",
1592 .lname = "I/O Memory",
1593 .type = FIO_OPT_STR,
1595 .off1 = td_var_offset(mem_type),
1596 .help = "Backing type for IO buffers",
1598 .category = FIO_OPT_C_IO,
1599 .group = FIO_OPT_G_INVALID,
1603 .help = "Use malloc(3) for IO buffers",
1607 .help = "Use shared memory segments for IO buffers",
1609 #ifdef FIO_HAVE_HUGETLB
1610 { .ival = "shmhuge",
1611 .oval = MEM_SHMHUGE,
1612 .help = "Like shm, but use huge pages",
1617 .help = "Use mmap(2) (file or anon) for IO buffers",
1619 #ifdef FIO_HAVE_HUGETLB
1620 { .ival = "mmaphuge",
1621 .oval = MEM_MMAPHUGE,
1622 .help = "Like mmap, but use huge pages",
1628 .name = "iomem_align",
1629 .alias = "mem_align",
1630 .lname = "I/O memory alignment",
1631 .type = FIO_OPT_INT,
1632 .off1 = td_var_offset(mem_align),
1634 .help = "IO memory buffer offset alignment",
1638 .category = FIO_OPT_C_IO,
1639 .group = FIO_OPT_G_INVALID,
1644 .type = FIO_OPT_STR,
1645 .off1 = td_var_offset(verify),
1646 .help = "Verify data written",
1648 .category = FIO_OPT_C_IO,
1649 .group = FIO_OPT_G_VERIFY,
1652 .oval = VERIFY_NONE,
1653 .help = "Don't do IO verification",
1657 .help = "Use md5 checksums for verification",
1660 .oval = VERIFY_CRC64,
1661 .help = "Use crc64 checksums for verification",
1664 .oval = VERIFY_CRC32,
1665 .help = "Use crc32 checksums for verification",
1667 { .ival = "crc32c-intel",
1668 .oval = VERIFY_CRC32C,
1669 .help = "Use crc32c checksums for verification (hw assisted, if available)",
1672 .oval = VERIFY_CRC32C,
1673 .help = "Use crc32c checksums for verification (hw assisted, if available)",
1676 .oval = VERIFY_CRC16,
1677 .help = "Use crc16 checksums for verification",
1680 .oval = VERIFY_CRC7,
1681 .help = "Use crc7 checksums for verification",
1684 .oval = VERIFY_SHA1,
1685 .help = "Use sha1 checksums for verification",
1688 .oval = VERIFY_SHA256,
1689 .help = "Use sha256 checksums for verification",
1692 .oval = VERIFY_SHA512,
1693 .help = "Use sha512 checksums for verification",
1696 .oval = VERIFY_META,
1697 .help = "Use io information",
1701 .oval = VERIFY_NULL,
1702 .help = "Pretend to verify",
1707 .name = "do_verify",
1708 .lname = "Perform verify step",
1709 .type = FIO_OPT_BOOL,
1710 .off1 = td_var_offset(do_verify),
1711 .help = "Run verification stage after write",
1715 .category = FIO_OPT_C_IO,
1716 .group = FIO_OPT_G_VERIFY,
1719 .name = "verifysort",
1720 .lname = "Verify sort",
1721 .type = FIO_OPT_BOOL,
1722 .off1 = td_var_offset(verifysort),
1723 .help = "Sort written verify blocks for read back",
1727 .category = FIO_OPT_C_IO,
1728 .group = FIO_OPT_G_VERIFY,
1731 .name = "verify_interval",
1732 .lname = "Verify interval",
1733 .type = FIO_OPT_INT,
1734 .off1 = td_var_offset(verify_interval),
1735 .minval = 2 * sizeof(struct verify_header),
1736 .help = "Store verify buffer header every N bytes",
1739 .interval = 2 * sizeof(struct verify_header),
1740 .category = FIO_OPT_C_IO,
1741 .group = FIO_OPT_G_VERIFY,
1744 .name = "verify_offset",
1745 .lname = "Verify offset",
1746 .type = FIO_OPT_INT,
1747 .help = "Offset verify header location by N bytes",
1748 .off1 = td_var_offset(verify_offset),
1749 .minval = sizeof(struct verify_header),
1752 .category = FIO_OPT_C_IO,
1753 .group = FIO_OPT_G_VERIFY,
1756 .name = "verify_pattern",
1757 .lname = "Verify pattern",
1758 .type = FIO_OPT_STR,
1759 .cb = str_verify_pattern_cb,
1760 .help = "Fill pattern for IO buffers",
1763 .category = FIO_OPT_C_IO,
1764 .group = FIO_OPT_G_VERIFY,
1767 .name = "verify_fatal",
1768 .lname = "Verify fatal",
1769 .type = FIO_OPT_BOOL,
1770 .off1 = td_var_offset(verify_fatal),
1772 .help = "Exit on a single verify failure, don't continue",
1775 .category = FIO_OPT_C_IO,
1776 .group = FIO_OPT_G_VERIFY,
1779 .name = "verify_dump",
1780 .lname = "Verify dump",
1781 .type = FIO_OPT_BOOL,
1782 .off1 = td_var_offset(verify_dump),
1784 .help = "Dump contents of good and bad blocks on failure",
1787 .category = FIO_OPT_C_IO,
1788 .group = FIO_OPT_G_VERIFY,
1791 .name = "verify_async",
1792 .lname = "Verify asynchronously",
1793 .type = FIO_OPT_INT,
1794 .off1 = td_var_offset(verify_async),
1796 .help = "Number of async verifier threads to use",
1799 .category = FIO_OPT_C_IO,
1800 .group = FIO_OPT_G_VERIFY,
1803 .name = "verify_backlog",
1804 .lname = "Verify backlog",
1805 .type = FIO_OPT_STR_VAL,
1806 .off1 = td_var_offset(verify_backlog),
1807 .help = "Verify after this number of blocks are written",
1810 .category = FIO_OPT_C_IO,
1811 .group = FIO_OPT_G_VERIFY,
1814 .name = "verify_backlog_batch",
1815 .lname = "Verify backlog batch",
1816 .type = FIO_OPT_INT,
1817 .off1 = td_var_offset(verify_batch),
1818 .help = "Verify this number of IO blocks",
1821 .category = FIO_OPT_C_IO,
1822 .group = FIO_OPT_G_VERIFY,
1824 #ifdef FIO_HAVE_CPU_AFFINITY
1826 .name = "verify_async_cpus",
1827 .lname = "Async verify CPUs",
1828 .type = FIO_OPT_STR,
1829 .cb = str_verify_cpus_allowed_cb,
1830 .help = "Set CPUs allowed for async verify threads",
1831 .parent = "verify_async",
1833 .category = FIO_OPT_C_IO,
1834 .group = FIO_OPT_G_VERIFY,
1837 #ifdef FIO_HAVE_TRIM
1839 .name = "trim_percentage",
1840 .lname = "Trim percentage",
1841 .type = FIO_OPT_INT,
1842 .off1 = td_var_offset(trim_percentage),
1845 .help = "Number of verify blocks to discard/trim",
1850 .category = FIO_OPT_C_IO,
1851 .group = FIO_OPT_G_TRIM,
1854 .name = "trim_verify_zero",
1855 .lname = "Verify trim zero",
1856 .type = FIO_OPT_BOOL,
1857 .help = "Verify that trim/discarded blocks are returned as zeroes",
1858 .off1 = td_var_offset(trim_zero),
1859 .parent = "trim_percentage",
1862 .category = FIO_OPT_C_IO,
1863 .group = FIO_OPT_G_TRIM,
1866 .name = "trim_backlog",
1867 .lname = "Trim backlog",
1868 .type = FIO_OPT_STR_VAL,
1869 .off1 = td_var_offset(trim_backlog),
1870 .help = "Trim after this number of blocks are written",
1871 .parent = "trim_percentage",
1874 .category = FIO_OPT_C_IO,
1875 .group = FIO_OPT_G_TRIM,
1878 .name = "trim_backlog_batch",
1879 .lname = "Trim backlog batch",
1880 .type = FIO_OPT_INT,
1881 .off1 = td_var_offset(trim_batch),
1882 .help = "Trim this number of IO blocks",
1883 .parent = "trim_percentage",
1886 .category = FIO_OPT_C_IO,
1887 .group = FIO_OPT_G_TRIM,
1891 .name = "write_iolog",
1892 .lname = "Write I/O log",
1893 .type = FIO_OPT_STR_STORE,
1894 .off1 = td_var_offset(write_iolog_file),
1895 .help = "Store IO pattern to file",
1896 .category = FIO_OPT_C_IO,
1897 .group = FIO_OPT_G_IOLOG,
1900 .name = "read_iolog",
1901 .lname = "Read I/O log",
1902 .type = FIO_OPT_STR_STORE,
1903 .off1 = td_var_offset(read_iolog_file),
1904 .help = "Playback IO pattern from file",
1905 .category = FIO_OPT_C_IO,
1906 .group = FIO_OPT_G_IOLOG,
1909 .name = "replay_no_stall",
1910 .lname = "Don't stall on replay",
1911 .type = FIO_OPT_BOOL,
1912 .off1 = td_var_offset(no_stall),
1914 .parent = "read_iolog",
1916 .help = "Playback IO pattern file as fast as possible without stalls",
1917 .category = FIO_OPT_C_IO,
1918 .group = FIO_OPT_G_IOLOG,
1921 .name = "replay_redirect",
1922 .lname = "Redirect device for replay",
1923 .type = FIO_OPT_STR_STORE,
1924 .off1 = td_var_offset(replay_redirect),
1925 .parent = "read_iolog",
1927 .help = "Replay all I/O onto this device, regardless of trace device",
1928 .category = FIO_OPT_C_IO,
1929 .group = FIO_OPT_G_IOLOG,
1932 .name = "exec_prerun",
1933 .lname = "Pre-execute runnable",
1934 .type = FIO_OPT_STR_STORE,
1935 .off1 = td_var_offset(exec_prerun),
1936 .help = "Execute this file prior to running job",
1937 .category = FIO_OPT_C_GENERAL,
1938 .group = FIO_OPT_G_INVALID,
1941 .name = "exec_postrun",
1942 .lname = "Post-execute runnable",
1943 .type = FIO_OPT_STR_STORE,
1944 .off1 = td_var_offset(exec_postrun),
1945 .help = "Execute this file after running job",
1946 .category = FIO_OPT_C_GENERAL,
1947 .group = FIO_OPT_G_INVALID,
1949 #ifdef FIO_HAVE_IOSCHED_SWITCH
1951 .name = "ioscheduler",
1952 .lname = "I/O scheduler",
1953 .type = FIO_OPT_STR_STORE,
1954 .off1 = td_var_offset(ioscheduler),
1955 .help = "Use this IO scheduler on the backing device",
1956 .category = FIO_OPT_C_FILE,
1957 .group = FIO_OPT_G_INVALID,
1962 .lname = "Zone size",
1963 .type = FIO_OPT_STR_VAL,
1964 .off1 = td_var_offset(zone_size),
1965 .help = "Amount of data to read per zone",
1967 .interval = 1024 * 1024,
1968 .category = FIO_OPT_C_IO,
1969 .group = FIO_OPT_G_ZONE,
1972 .name = "zonerange",
1973 .lname = "Zone range",
1974 .type = FIO_OPT_STR_VAL,
1975 .off1 = td_var_offset(zone_range),
1976 .help = "Give size of an IO zone",
1978 .interval = 1024 * 1024,
1979 .category = FIO_OPT_C_IO,
1980 .group = FIO_OPT_G_ZONE,
1984 .lname = "Zone skip",
1985 .type = FIO_OPT_STR_VAL,
1986 .off1 = td_var_offset(zone_skip),
1987 .help = "Space between IO zones",
1989 .interval = 1024 * 1024,
1990 .category = FIO_OPT_C_IO,
1991 .group = FIO_OPT_G_ZONE,
1995 .lname = "Lock memory",
1996 .type = FIO_OPT_STR_VAL,
1997 .off1 = td_var_offset(lockmem),
1998 .help = "Lock down this amount of memory",
2000 .interval = 1024 * 1024,
2001 .category = FIO_OPT_C_GENERAL,
2002 .group = FIO_OPT_G_INVALID,
2005 .name = "rwmixread",
2006 .lname = "Read/write mix read",
2007 .type = FIO_OPT_INT,
2008 .cb = str_rwmix_read_cb,
2010 .help = "Percentage of mixed workload that is reads",
2013 .inverse = "rwmixwrite",
2014 .category = FIO_OPT_C_IO,
2015 .group = FIO_OPT_G_RWMIX,
2018 .name = "rwmixwrite",
2019 .lname = "Read/write mix write",
2020 .type = FIO_OPT_INT,
2021 .cb = str_rwmix_write_cb,
2023 .help = "Percentage of mixed workload that is writes",
2026 .inverse = "rwmixread",
2027 .category = FIO_OPT_C_IO,
2028 .group = FIO_OPT_G_RWMIX,
2031 .name = "rwmixcycle",
2032 .lname = "Read/write mix cycle",
2033 .type = FIO_OPT_DEPRECATED,
2034 .category = FIO_OPT_C_IO,
2035 .group = FIO_OPT_G_RWMIX,
2040 .type = FIO_OPT_INT,
2041 .off1 = td_var_offset(nice),
2042 .help = "Set job CPU nice value",
2047 .category = FIO_OPT_C_GENERAL,
2048 .group = FIO_OPT_G_CRED,
2050 #ifdef FIO_HAVE_IOPRIO
2053 .lname = "I/O nice priority",
2054 .type = FIO_OPT_INT,
2055 .off1 = td_var_offset(ioprio),
2056 .help = "Set job IO priority value",
2060 .category = FIO_OPT_C_GENERAL,
2061 .group = FIO_OPT_G_CRED,
2064 .name = "prioclass",
2065 .lname = "I/O nice priority class",
2066 .type = FIO_OPT_INT,
2067 .off1 = td_var_offset(ioprio_class),
2068 .help = "Set job IO priority class",
2072 .category = FIO_OPT_C_GENERAL,
2073 .group = FIO_OPT_G_CRED,
2077 .name = "thinktime",
2078 .lname = "Thinktime",
2079 .type = FIO_OPT_INT,
2080 .off1 = td_var_offset(thinktime),
2081 .help = "Idle time between IO buffers (usec)",
2083 .category = FIO_OPT_C_IO,
2084 .group = FIO_OPT_G_THINKTIME,
2087 .name = "thinktime_spin",
2088 .lname = "Thinktime spin",
2089 .type = FIO_OPT_INT,
2090 .off1 = td_var_offset(thinktime_spin),
2091 .help = "Start think time by spinning this amount (usec)",
2093 .parent = "thinktime",
2095 .category = FIO_OPT_C_IO,
2096 .group = FIO_OPT_G_THINKTIME,
2099 .name = "thinktime_blocks",
2100 .lname = "Thinktime blocks",
2101 .type = FIO_OPT_INT,
2102 .off1 = td_var_offset(thinktime_blocks),
2103 .help = "IO buffer period between 'thinktime'",
2105 .parent = "thinktime",
2107 .category = FIO_OPT_C_IO,
2108 .group = FIO_OPT_G_THINKTIME,
2112 .lname = "I/O rate",
2113 .type = FIO_OPT_INT,
2114 .off1 = td_var_offset(rate[0]),
2115 .off2 = td_var_offset(rate[1]),
2116 .help = "Set bandwidth rate",
2117 .category = FIO_OPT_C_IO,
2118 .group = FIO_OPT_G_RATE,
2122 .lname = "I/O min rate",
2123 .type = FIO_OPT_INT,
2124 .off1 = td_var_offset(ratemin[0]),
2125 .off2 = td_var_offset(ratemin[1]),
2126 .help = "Job must meet this rate or it will be shutdown",
2129 .category = FIO_OPT_C_IO,
2130 .group = FIO_OPT_G_RATE,
2133 .name = "rate_iops",
2134 .lname = "I/O rate IOPS",
2135 .type = FIO_OPT_INT,
2136 .off1 = td_var_offset(rate_iops[0]),
2137 .off2 = td_var_offset(rate_iops[1]),
2138 .help = "Limit IO used to this number of IO operations/sec",
2140 .category = FIO_OPT_C_IO,
2141 .group = FIO_OPT_G_RATE,
2144 .name = "rate_iops_min",
2145 .lname = "I/O min rate IOPS",
2146 .type = FIO_OPT_INT,
2147 .off1 = td_var_offset(rate_iops_min[0]),
2148 .off2 = td_var_offset(rate_iops_min[1]),
2149 .help = "Job must meet this rate or it will be shut down",
2150 .parent = "rate_iops",
2152 .category = FIO_OPT_C_IO,
2153 .group = FIO_OPT_G_RATE,
2156 .name = "ratecycle",
2157 .lname = "I/O rate cycle",
2158 .type = FIO_OPT_INT,
2159 .off1 = td_var_offset(ratecycle),
2160 .help = "Window average for rate limits (msec)",
2164 .category = FIO_OPT_C_IO,
2165 .group = FIO_OPT_G_RATE,
2168 .name = "invalidate",
2169 .lname = "Cache invalidate",
2170 .type = FIO_OPT_BOOL,
2171 .off1 = td_var_offset(invalidate_cache),
2172 .help = "Invalidate buffer/page cache prior to running job",
2174 .category = FIO_OPT_C_IO,
2175 .group = FIO_OPT_G_IO_TYPE,
2179 .lname = "Synchronous I/O",
2180 .type = FIO_OPT_BOOL,
2181 .off1 = td_var_offset(sync_io),
2182 .help = "Use O_SYNC for buffered writes",
2184 .parent = "buffered",
2186 .category = FIO_OPT_C_IO,
2187 .group = FIO_OPT_G_IO_TYPE,
2190 .name = "create_serialize",
2191 .lname = "Create serialize",
2192 .type = FIO_OPT_BOOL,
2193 .off1 = td_var_offset(create_serialize),
2194 .help = "Serialize creating of job files",
2196 .category = FIO_OPT_C_FILE,
2197 .group = FIO_OPT_G_INVALID,
2200 .name = "create_fsync",
2201 .lname = "Create fsync",
2202 .type = FIO_OPT_BOOL,
2203 .off1 = td_var_offset(create_fsync),
2204 .help = "fsync file after creation",
2206 .category = FIO_OPT_C_FILE,
2207 .group = FIO_OPT_G_INVALID,
2210 .name = "create_on_open",
2211 .lname = "Create on open",
2212 .type = FIO_OPT_BOOL,
2213 .off1 = td_var_offset(create_on_open),
2214 .help = "Create files when they are opened for IO",
2216 .category = FIO_OPT_C_FILE,
2217 .group = FIO_OPT_G_INVALID,
2221 .lname = "Pre-read files",
2222 .type = FIO_OPT_BOOL,
2223 .off1 = td_var_offset(pre_read),
2224 .help = "Pre-read files before starting official testing",
2226 .category = FIO_OPT_C_FILE,
2227 .group = FIO_OPT_G_INVALID,
2229 #ifdef FIO_HAVE_CPU_AFFINITY
2232 .lname = "CPU mask",
2233 .type = FIO_OPT_INT,
2234 .cb = str_cpumask_cb,
2235 .help = "CPU affinity mask",
2236 .category = FIO_OPT_C_GENERAL,
2237 .group = FIO_OPT_G_CRED,
2240 .name = "cpus_allowed",
2241 .lname = "CPUs allowed",
2242 .type = FIO_OPT_STR,
2243 .cb = str_cpus_allowed_cb,
2244 .help = "Set CPUs allowed",
2245 .category = FIO_OPT_C_GENERAL,
2246 .group = FIO_OPT_G_CRED,
2250 .name = "end_fsync",
2251 .lname = "End fsync",
2252 .type = FIO_OPT_BOOL,
2253 .off1 = td_var_offset(end_fsync),
2254 .help = "Include fsync at the end of job",
2256 .category = FIO_OPT_C_FILE,
2257 .group = FIO_OPT_G_INVALID,
2260 .name = "fsync_on_close",
2261 .lname = "Fsync on close",
2262 .type = FIO_OPT_BOOL,
2263 .off1 = td_var_offset(fsync_on_close),
2264 .help = "fsync files on close",
2266 .category = FIO_OPT_C_FILE,
2267 .group = FIO_OPT_G_INVALID,
2271 .lname = "Unlink file",
2272 .type = FIO_OPT_BOOL,
2273 .off1 = td_var_offset(unlink),
2274 .help = "Unlink created files after job has completed",
2276 .category = FIO_OPT_C_FILE,
2277 .group = FIO_OPT_G_INVALID,
2281 .lname = "Exit-all on terminate",
2282 .type = FIO_OPT_STR_SET,
2283 .cb = str_exitall_cb,
2284 .help = "Terminate all jobs when one exits",
2285 .category = FIO_OPT_C_GENERAL,
2286 .group = FIO_OPT_G_PROCESS,
2289 .name = "stonewall",
2290 .lname = "Wait for previous",
2291 .alias = "wait_for_previous",
2292 .type = FIO_OPT_STR_SET,
2293 .off1 = td_var_offset(stonewall),
2294 .help = "Insert a hard barrier between this job and previous",
2295 .category = FIO_OPT_C_GENERAL,
2296 .group = FIO_OPT_G_PROCESS,
2299 .name = "new_group",
2300 .lname = "New group",
2301 .type = FIO_OPT_STR_SET,
2302 .off1 = td_var_offset(new_group),
2303 .help = "Mark the start of a new group (for reporting)",
2304 .category = FIO_OPT_C_GENERAL,
2305 .group = FIO_OPT_G_PROCESS,
2310 .type = FIO_OPT_STR_SET,
2311 .off1 = td_var_offset(use_thread),
2312 .help = "Use threads instead of processes",
2313 .category = FIO_OPT_C_GENERAL,
2314 .group = FIO_OPT_G_PROCESS,
2317 .name = "write_bw_log",
2318 .lname = "Write bandwidth log",
2319 .type = FIO_OPT_STR_STORE,
2320 .off1 = td_var_offset(bw_log_file),
2321 .help = "Write log of bandwidth during run",
2322 .category = FIO_OPT_C_LOG,
2323 .group = FIO_OPT_G_INVALID,
2326 .name = "write_lat_log",
2327 .lname = "Write latency log",
2328 .type = FIO_OPT_STR_STORE,
2329 .off1 = td_var_offset(lat_log_file),
2330 .help = "Write log of latency during run",
2331 .category = FIO_OPT_C_LOG,
2332 .group = FIO_OPT_G_INVALID,
2335 .name = "write_iops_log",
2336 .lname = "Write IOPS log",
2337 .type = FIO_OPT_STR,
2338 .off1 = td_var_offset(iops_log_file),
2339 .help = "Write log of IOPS during run",
2340 .category = FIO_OPT_C_LOG,
2341 .group = FIO_OPT_G_INVALID,
2344 .name = "log_avg_msec",
2345 .lname = "Log averaging (msec)",
2346 .type = FIO_OPT_INT,
2347 .off1 = td_var_offset(log_avg_msec),
2348 .help = "Average bw/iops/lat logs over this period of time",
2350 .category = FIO_OPT_C_LOG,
2351 .group = FIO_OPT_G_INVALID,
2354 .name = "bwavgtime",
2355 .lname = "Bandwidth average time",
2356 .type = FIO_OPT_INT,
2357 .off1 = td_var_offset(bw_avg_time),
2358 .help = "Time window over which to calculate bandwidth"
2361 .parent = "write_bw_log",
2364 .category = FIO_OPT_C_LOG,
2365 .group = FIO_OPT_G_INVALID,
2368 .name = "iopsavgtime",
2369 .lname = "IOPS average time",
2370 .type = FIO_OPT_INT,
2371 .off1 = td_var_offset(iops_avg_time),
2372 .help = "Time window over which to calculate IOPS (msec)",
2374 .parent = "write_iops_log",
2377 .category = FIO_OPT_C_LOG,
2378 .group = FIO_OPT_G_INVALID,
2381 .name = "group_reporting",
2382 .lname = "Group reporting",
2383 .type = FIO_OPT_BOOL,
2384 .off1 = td_var_offset(group_reporting),
2385 .help = "Do reporting on a per-group basis",
2387 .category = FIO_OPT_C_STAT,
2388 .group = FIO_OPT_G_INVALID,
2391 .name = "zero_buffers",
2392 .lname = "Zero I/O buffers",
2393 .type = FIO_OPT_STR_SET,
2394 .off1 = td_var_offset(zero_buffers),
2395 .help = "Init IO buffers to all zeroes",
2396 .category = FIO_OPT_C_IO,
2397 .group = FIO_OPT_G_IO_BUF,
2400 .name = "refill_buffers",
2401 .lname = "Refill I/O buffers",
2402 .type = FIO_OPT_STR_SET,
2403 .off1 = td_var_offset(refill_buffers),
2404 .help = "Refill IO buffers on every IO submit",
2405 .category = FIO_OPT_C_IO,
2406 .group = FIO_OPT_G_IO_BUF,
2409 .name = "scramble_buffers",
2410 .lname = "Scramble I/O buffers",
2411 .type = FIO_OPT_BOOL,
2412 .off1 = td_var_offset(scramble_buffers),
2413 .help = "Slightly scramble buffers on every IO submit",
2415 .category = FIO_OPT_C_IO,
2416 .group = FIO_OPT_G_IO_BUF,
2419 .name = "buffer_compress_percentage",
2420 .lname = "Buffer compression percentage",
2421 .type = FIO_OPT_INT,
2422 .off1 = td_var_offset(compress_percentage),
2425 .help = "How compressible the buffer is (approximately)",
2427 .category = FIO_OPT_C_IO,
2428 .group = FIO_OPT_G_IO_BUF,
2431 .name = "buffer_compress_chunk",
2432 .lname = "Buffer compression chunk size",
2433 .type = FIO_OPT_INT,
2434 .off1 = td_var_offset(compress_chunk),
2435 .parent = "buffer_compress_percentage",
2437 .help = "Size of compressible region in buffer",
2439 .category = FIO_OPT_C_IO,
2440 .group = FIO_OPT_G_IO_BUF,
2443 .name = "clat_percentiles",
2444 .lname = "Completion latency percentiles",
2445 .type = FIO_OPT_BOOL,
2446 .off1 = td_var_offset(clat_percentiles),
2447 .help = "Enable the reporting of completion latency percentiles",
2449 .category = FIO_OPT_C_STAT,
2450 .group = FIO_OPT_G_INVALID,
2453 .name = "percentile_list",
2454 .lname = "Completion latency percentile list",
2455 .type = FIO_OPT_FLOAT_LIST,
2456 .off1 = td_var_offset(percentile_list),
2457 .off2 = td_var_offset(overwrite_plist),
2458 .help = "Specify a custom list of percentiles to report",
2459 .maxlen = FIO_IO_U_LIST_MAX_LEN,
2462 .category = FIO_OPT_C_STAT,
2463 .group = FIO_OPT_G_INVALID,
2466 #ifdef FIO_HAVE_DISK_UTIL
2468 .name = "disk_util",
2469 .lname = "Disk utilization",
2470 .type = FIO_OPT_BOOL,
2471 .off1 = td_var_offset(do_disk_util),
2472 .help = "Log disk utilization statistics",
2474 .category = FIO_OPT_C_STAT,
2475 .group = FIO_OPT_G_INVALID,
2479 .name = "gtod_reduce",
2480 .lname = "Reduce gettimeofday() calls",
2481 .type = FIO_OPT_BOOL,
2482 .help = "Greatly reduce number of gettimeofday() calls",
2483 .cb = str_gtod_reduce_cb,
2486 .category = FIO_OPT_C_STAT,
2487 .group = FIO_OPT_G_INVALID,
2490 .name = "disable_lat",
2491 .lname = "Disable all latency stats",
2492 .type = FIO_OPT_BOOL,
2493 .off1 = td_var_offset(disable_lat),
2494 .help = "Disable latency numbers",
2495 .parent = "gtod_reduce",
2498 .category = FIO_OPT_C_STAT,
2499 .group = FIO_OPT_G_INVALID,
2502 .name = "disable_clat",
2503 .lname = "Disable completion latency stats",
2504 .type = FIO_OPT_BOOL,
2505 .off1 = td_var_offset(disable_clat),
2506 .help = "Disable completion latency numbers",
2507 .parent = "gtod_reduce",
2510 .category = FIO_OPT_C_STAT,
2511 .group = FIO_OPT_G_INVALID,
2514 .name = "disable_slat",
2515 .lname = "Disable submission latency stats",
2516 .type = FIO_OPT_BOOL,
2517 .off1 = td_var_offset(disable_slat),
2518 .help = "Disable submission latency numbers",
2519 .parent = "gtod_reduce",
2522 .category = FIO_OPT_C_STAT,
2523 .group = FIO_OPT_G_INVALID,
2526 .name = "disable_bw_measurement",
2527 .lname = "Disable bandwidth stats",
2528 .type = FIO_OPT_BOOL,
2529 .off1 = td_var_offset(disable_bw),
2530 .help = "Disable bandwidth logging",
2531 .parent = "gtod_reduce",
2534 .category = FIO_OPT_C_STAT,
2535 .group = FIO_OPT_G_INVALID,
2539 .lname = "Dedicated gettimeofday() CPU",
2540 .type = FIO_OPT_INT,
2541 .cb = str_gtod_cpu_cb,
2542 .help = "Set up dedicated gettimeofday() thread on this CPU",
2543 .verify = gtod_cpu_verify,
2544 .category = FIO_OPT_C_GENERAL,
2545 .group = FIO_OPT_G_CLOCK,
2548 .name = "continue_on_error",
2549 .lname = "Continue on error",
2550 .type = FIO_OPT_STR,
2551 .off1 = td_var_offset(continue_on_error),
2552 .help = "Continue on non-fatal errors during IO",
2554 .category = FIO_OPT_C_GENERAL,
2555 .group = FIO_OPT_G_INVALID,
2558 .oval = ERROR_TYPE_NONE,
2559 .help = "Exit when an error is encountered",
2562 .oval = ERROR_TYPE_READ,
2563 .help = "Continue on read errors only",
2566 .oval = ERROR_TYPE_WRITE,
2567 .help = "Continue on write errors only",
2570 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
2571 .help = "Continue on any IO errors",
2574 .oval = ERROR_TYPE_VERIFY,
2575 .help = "Continue on verify errors only",
2578 .oval = ERROR_TYPE_ANY,
2579 .help = "Continue on all io and verify errors",
2582 .oval = ERROR_TYPE_NONE,
2583 .help = "Alias for 'none'",
2586 .oval = ERROR_TYPE_ANY,
2587 .help = "Alias for 'all'",
2594 .type = FIO_OPT_STR_STORE,
2595 .off1 = td_var_offset(profile),
2596 .help = "Select a specific builtin performance test",
2597 .category = FIO_OPT_C_PROFILE,
2598 .group = FIO_OPT_G_INVALID,
2603 .type = FIO_OPT_STR_STORE,
2604 .off1 = td_var_offset(cgroup),
2605 .help = "Add job to cgroup of this name",
2606 .category = FIO_OPT_C_GENERAL,
2607 .group = FIO_OPT_G_CGROUP,
2610 .name = "cgroup_nodelete",
2611 .lname = "Cgroup no-delete",
2612 .type = FIO_OPT_BOOL,
2613 .off1 = td_var_offset(cgroup_nodelete),
2614 .help = "Do not delete cgroups after job completion",
2617 .category = FIO_OPT_C_GENERAL,
2618 .group = FIO_OPT_G_CGROUP,
2621 .name = "cgroup_weight",
2622 .lname = "Cgroup weight",
2623 .type = FIO_OPT_INT,
2624 .off1 = td_var_offset(cgroup_weight),
2625 .help = "Use given weight for cgroup",
2629 .category = FIO_OPT_C_GENERAL,
2630 .group = FIO_OPT_G_CGROUP,
2635 .type = FIO_OPT_INT,
2636 .off1 = td_var_offset(uid),
2637 .help = "Run job with this user ID",
2638 .category = FIO_OPT_C_GENERAL,
2639 .group = FIO_OPT_G_CRED,
2643 .lname = "Group ID",
2644 .type = FIO_OPT_INT,
2645 .off1 = td_var_offset(gid),
2646 .help = "Run job with this group ID",
2647 .category = FIO_OPT_C_GENERAL,
2648 .group = FIO_OPT_G_CRED,
2653 .type = FIO_OPT_INT,
2654 .off1 = td_var_offset(kb_base),
2655 .verify = kb_base_verify,
2658 .help = "How many bytes per KB for reporting (1000 or 1024)",
2659 .category = FIO_OPT_C_GENERAL,
2660 .group = FIO_OPT_G_INVALID,
2663 .name = "hugepage-size",
2664 .lname = "Hugepage size",
2665 .type = FIO_OPT_INT,
2666 .off1 = td_var_offset(hugepage_size),
2667 .help = "When using hugepages, specify size of each page",
2668 .def = __fio_stringify(FIO_HUGE_PAGE),
2669 .interval = 1024 * 1024,
2670 .category = FIO_OPT_C_GENERAL,
2671 .group = FIO_OPT_G_INVALID,
2675 .lname = "I/O flow ID",
2676 .type = FIO_OPT_INT,
2677 .off1 = td_var_offset(flow_id),
2678 .help = "The flow index ID to use",
2680 .category = FIO_OPT_C_IO,
2681 .group = FIO_OPT_G_IO_FLOW,
2685 .lname = "I/O flow weight",
2686 .type = FIO_OPT_INT,
2687 .off1 = td_var_offset(flow),
2688 .help = "Weight for flow control of this job",
2689 .parent = "flow_id",
2692 .category = FIO_OPT_C_IO,
2693 .group = FIO_OPT_G_IO_FLOW,
2696 .name = "flow_watermark",
2697 .lname = "I/O flow watermark",
2698 .type = FIO_OPT_INT,
2699 .off1 = td_var_offset(flow_watermark),
2700 .help = "High watermark for flow control. This option"
2701 " should be set to the same value for all threads"
2702 " with non-zero flow.",
2703 .parent = "flow_id",
2706 .category = FIO_OPT_C_IO,
2707 .group = FIO_OPT_G_IO_FLOW,
2710 .name = "flow_sleep",
2711 .lname = "I/O flow sleep",
2712 .type = FIO_OPT_INT,
2713 .off1 = td_var_offset(flow_sleep),
2714 .help = "How many microseconds to sleep after being held"
2715 " back by the flow control mechanism",
2716 .parent = "flow_id",
2719 .category = FIO_OPT_C_IO,
2720 .group = FIO_OPT_G_IO_FLOW,
2727 static void add_to_lopt(struct option *lopt, struct fio_option *o,
2728 const char *name, int val)
2730 lopt->name = (char *) name;
2732 if (o->type == FIO_OPT_STR_SET)
2733 lopt->has_arg = no_argument;
2735 lopt->has_arg = required_argument;
2738 static void options_to_lopts(struct fio_option *opts,
2739 struct option *long_options,
2740 int i, int option_type)
2742 struct fio_option *o = &opts[0];
2744 add_to_lopt(&long_options[i], o, o->name, option_type);
2747 add_to_lopt(&long_options[i], o, o->alias, option_type);
2752 assert(i < FIO_NR_OPTIONS);
2756 void fio_options_set_ioengine_opts(struct option *long_options,
2757 struct thread_data *td)
2762 while (long_options[i].name) {
2763 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
2764 memset(&long_options[i], 0, sizeof(*long_options));
2771 * Just clear out the prior ioengine options.
2776 options_to_lopts(td->io_ops->options, long_options, i,
2777 FIO_GETOPT_IOENGINE);
2780 void fio_options_dup_and_init(struct option *long_options)
2784 options_init(fio_options);
2787 while (long_options[i].name)
2790 options_to_lopts(fio_options, long_options, i, FIO_GETOPT_JOB);
2793 struct fio_keyword {
2799 static struct fio_keyword fio_keywords[] = {
2801 .word = "$pagesize",
2802 .desc = "Page size in the system",
2805 .word = "$mb_memory",
2806 .desc = "Megabytes of memory online",
2810 .desc = "Number of CPUs online in the system",
2817 void fio_keywords_init(void)
2819 unsigned long long mb_memory;
2823 sprintf(buf, "%lu", page_size);
2824 fio_keywords[0].replace = strdup(buf);
2826 mb_memory = os_phys_mem() / (1024 * 1024);
2827 sprintf(buf, "%llu", mb_memory);
2828 fio_keywords[1].replace = strdup(buf);
2831 sprintf(buf, "%lu", l);
2832 fio_keywords[2].replace = strdup(buf);
2837 static char *bc_calc(char *str)
2839 char buf[128], *tmp;
2844 * No math, just return string
2846 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
2847 !strchr(str, '/')) || strchr(str, '\''))
2851 * Split option from value, we only need to calculate the value
2853 tmp = strchr(str, '=');
2860 * Prevent buffer overflows; such a case isn't reasonable anyway
2862 if (strlen(str) >= 128 || strlen(tmp) > 100)
2865 sprintf(buf, "which %s > /dev/null", BC_APP);
2867 log_err("fio: bc is needed for performing math\n");
2871 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
2872 f = popen(buf, "r");
2876 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
2881 buf[(tmp - str) + ret - 1] = '\0';
2882 memcpy(buf, str, tmp - str);
2888 * Return a copy of the input string with substrings of the form ${VARNAME}
2889 * substituted with the value of the environment variable VARNAME. The
2890 * substitution always occurs, even if VARNAME is empty or the corresponding
2891 * environment variable undefined.
2893 static char *option_dup_subs(const char *opt)
2895 char out[OPT_LEN_MAX+1];
2896 char in[OPT_LEN_MAX+1];
2899 char *ch1, *ch2, *env;
2900 ssize_t nchr = OPT_LEN_MAX;
2903 if (strlen(opt) + 1 > OPT_LEN_MAX) {
2904 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
2908 in[OPT_LEN_MAX] = '\0';
2909 strncpy(in, opt, OPT_LEN_MAX);
2911 while (*inptr && nchr > 0) {
2912 if (inptr[0] == '$' && inptr[1] == '{') {
2913 ch2 = strchr(inptr, '}');
2914 if (ch2 && inptr+1 < ch2) {
2921 envlen = strlen(env);
2922 if (envlen <= nchr) {
2923 memcpy(outptr, env, envlen);
2933 *outptr++ = *inptr++;
2942 * Look for reserved variable names and replace them with real values
2944 static char *fio_keyword_replace(char *opt)
2950 for (i = 0; fio_keywords[i].word != NULL; i++) {
2951 struct fio_keyword *kw = &fio_keywords[i];
2953 while ((s = strstr(opt, kw->word)) != NULL) {
2954 char *new = malloc(strlen(opt) + 1);
2960 * Copy part of the string before the keyword and
2961 * sprintf() the replacement after it.
2963 memcpy(new, opt, olen);
2964 len = sprintf(new + olen, "%s", kw->replace);
2967 * If there's more in the original string, copy that
2970 opt += strlen(kw->word) + olen;
2972 memcpy(new + olen + len, opt, opt - o_org - 1);
2975 * replace opt and free the old opt
2985 * Check for potential math and invoke bc, if possible
2993 static char **dup_and_sub_options(char **opts, int num_opts)
2996 char **opts_copy = malloc(num_opts * sizeof(*opts));
2997 for (i = 0; i < num_opts; i++) {
2998 opts_copy[i] = option_dup_subs(opts[i]);
3001 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
3006 int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
3008 int i, ret, unknown;
3011 sort_options(opts, fio_options, num_opts);
3012 opts_copy = dup_and_sub_options(opts, num_opts);
3014 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
3015 struct fio_option *o;
3016 int newret = parse_option(opts_copy[i], opts[i], fio_options,
3025 opts_copy[i] = NULL;
3032 ret |= ioengine_load(td);
3034 sort_options(opts_copy, td->io_ops->options, num_opts);
3037 for (i = 0; i < num_opts; i++) {
3038 struct fio_option *o = NULL;
3044 newret = parse_option(opts_copy[i], opts[i],
3045 td->io_ops->options, &o,
3050 log_err("Bad option <%s>\n", opts[i]);
3053 opts_copy[i] = NULL;
3061 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
3063 return parse_cmd_option(opt, val, fio_options, td);
3066 int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
3069 return parse_cmd_option(opt, val, td->io_ops->options, td);
3072 void fio_fill_default_options(struct thread_data *td)
3074 fill_default_options(td, fio_options);
3077 int fio_show_option_help(const char *opt)
3079 return show_cmd_help(fio_options, opt);
3082 void options_mem_dupe(void *data, struct fio_option *options)
3084 struct fio_option *o;
3087 for (o = &options[0]; o->name; o++) {
3088 if (o->type != FIO_OPT_STR_STORE)
3091 ptr = td_var(data, o->off1);
3093 *ptr = strdup(*ptr);
3098 * dupe FIO_OPT_STR_STORE options
3100 void fio_options_mem_dupe(struct thread_data *td)
3102 options_mem_dupe(&td->o, fio_options);
3104 if (td->eo && td->io_ops) {
3105 void *oldeo = td->eo;
3107 td->eo = malloc(td->io_ops->option_struct_size);
3108 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
3109 options_mem_dupe(td->eo, td->io_ops->options);
3113 unsigned int fio_get_kb_base(void *data)
3115 struct thread_options *o = data;
3116 unsigned int kb_base = 0;
3119 kb_base = o->kb_base;
3126 int add_option(struct fio_option *o)
3128 struct fio_option *__o;
3137 memcpy(&fio_options[opt_index], o, sizeof(*o));
3141 void invalidate_profile_options(const char *prof_name)
3143 struct fio_option *o;
3147 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
3148 o->type = FIO_OPT_INVALID;
3149 o->prof_name = NULL;
3155 void add_opt_posval(const char *optname, const char *ival, const char *help)
3157 struct fio_option *o;
3160 o = find_option(fio_options, optname);
3164 for (i = 0; i < PARSE_MAX_VP; i++) {
3165 if (o->posval[i].ival)
3168 o->posval[i].ival = ival;
3169 o->posval[i].help = help;
3174 void del_opt_posval(const char *optname, const char *ival)
3176 struct fio_option *o;
3179 o = find_option(fio_options, optname);
3183 for (i = 0; i < PARSE_MAX_VP; i++) {
3184 if (!o->posval[i].ival)
3186 if (strcmp(o->posval[i].ival, ival))
3189 o->posval[i].ival = NULL;
3190 o->posval[i].help = NULL;
3194 void fio_options_free(struct thread_data *td)
3196 options_free(fio_options, td);
3197 if (td->eo && td->io_ops && td->io_ops->options) {
3198 options_free(td->io_ops->options, td->eo);
3204 struct fio_option *fio_option_find(const char *name)
3206 return find_option(fio_options, name);