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",
965 { .ival = "readwrite",
967 .help = "Sequential read and write mix",
970 .oval = TD_DDIR_RANDRW,
971 .help = "Random read and write mix"
976 .name = "rw_sequencer",
977 .lname = "RW Sequencer",
979 .off1 = td_var_offset(rw_seq),
980 .help = "IO offset generator modifier",
982 .category = FIO_OPT_C_IO,
983 .group = FIO_OPT_G_IO_BASIC,
985 { .ival = "sequential",
987 .help = "Generate sequential offsets",
989 { .ival = "identical",
990 .oval = RW_SEQ_IDENT,
991 .help = "Generate identical offsets",
998 .lname = "IO Engine",
999 .type = FIO_OPT_STR_STORE,
1000 .off1 = td_var_offset(ioengine),
1001 .help = "IO engine to use",
1002 .def = FIO_PREFERRED_ENGINE,
1003 .category = FIO_OPT_C_IO,
1004 .group = FIO_OPT_G_IO_BASIC,
1007 .help = "Use read/write",
1010 .help = "Use pread/pwrite",
1013 .help = "Use readv/writev",
1015 #ifdef FIO_HAVE_LIBAIO
1017 .help = "Linux native asynchronous IO",
1020 #ifdef FIO_HAVE_POSIXAIO
1021 { .ival = "posixaio",
1022 .help = "POSIX asynchronous IO",
1025 #ifdef FIO_HAVE_SOLARISAIO
1026 { .ival = "solarisaio",
1027 .help = "Solaris native asynchronous IO",
1030 #ifdef FIO_HAVE_WINDOWSAIO
1031 { .ival = "windowsaio",
1032 .help = "Windows native asynchronous IO"
1036 .help = "Memory mapped IO"
1038 #ifdef FIO_HAVE_SPLICE
1040 .help = "splice/vmsplice based IO",
1042 { .ival = "netsplice",
1043 .help = "splice/vmsplice to/from the network",
1046 #ifdef FIO_HAVE_SGIO
1048 .help = "SCSI generic v3 IO",
1052 .help = "Testing engine (no data transfer)",
1055 .help = "Network IO",
1057 #ifdef FIO_HAVE_SYSLET
1058 { .ival = "syslet-rw",
1059 .help = "syslet enabled async pread/pwrite IO",
1063 .help = "CPU cycle burner engine",
1065 #ifdef FIO_HAVE_GUASI
1067 .help = "GUASI IO engine",
1070 #ifdef FIO_HAVE_BINJECT
1071 { .ival = "binject",
1072 .help = "binject direct inject block engine",
1075 #ifdef FIO_HAVE_RDMA
1077 .help = "RDMA IO engine",
1080 { .ival = "external",
1081 .help = "Load external engine (append name)",
1087 .lname = "IO Depth",
1088 .type = FIO_OPT_INT,
1089 .off1 = td_var_offset(iodepth),
1090 .help = "Number of IO buffers to keep in flight",
1094 .category = FIO_OPT_C_IO,
1095 .group = FIO_OPT_G_IO_BASIC,
1098 .name = "iodepth_batch",
1099 .lname = "IO Depth batch",
1100 .alias = "iodepth_batch_submit",
1101 .type = FIO_OPT_INT,
1102 .off1 = td_var_offset(iodepth_batch),
1103 .help = "Number of IO buffers to submit in one go",
1104 .parent = "iodepth",
1109 .category = FIO_OPT_C_IO,
1110 .group = FIO_OPT_G_IO_BASIC,
1113 .name = "iodepth_batch_complete",
1114 .lname = "IO Depth batch complete",
1115 .type = FIO_OPT_INT,
1116 .off1 = td_var_offset(iodepth_batch_complete),
1117 .help = "Number of IO buffers to retrieve in one go",
1118 .parent = "iodepth",
1123 .category = FIO_OPT_C_IO,
1124 .group = FIO_OPT_G_IO_BASIC,
1127 .name = "iodepth_low",
1128 .lname = "IO Depth batch low",
1129 .type = FIO_OPT_INT,
1130 .off1 = td_var_offset(iodepth_low),
1131 .help = "Low water mark for queuing depth",
1132 .parent = "iodepth",
1135 .category = FIO_OPT_C_IO,
1136 .group = FIO_OPT_G_IO_BASIC,
1141 .type = FIO_OPT_STR_VAL,
1143 .help = "Total size of device or files",
1144 .interval = 1024 * 1024,
1145 .category = FIO_OPT_C_IO,
1146 .group = FIO_OPT_G_INVALID,
1149 .name = "fill_device",
1150 .lname = "Fill device",
1152 .type = FIO_OPT_BOOL,
1153 .off1 = td_var_offset(fill_device),
1154 .help = "Write until an ENOSPC error occurs",
1156 .category = FIO_OPT_C_FILE,
1157 .group = FIO_OPT_G_INVALID,
1161 .lname = "File size",
1162 .type = FIO_OPT_STR_VAL,
1163 .off1 = td_var_offset(file_size_low),
1164 .off2 = td_var_offset(file_size_high),
1166 .help = "Size of individual files",
1167 .interval = 1024 * 1024,
1168 .category = FIO_OPT_C_FILE,
1169 .group = FIO_OPT_G_INVALID,
1173 .lname = "IO offset",
1174 .alias = "fileoffset",
1175 .type = FIO_OPT_STR_VAL,
1176 .off1 = td_var_offset(start_offset),
1177 .help = "Start IO from this offset",
1179 .interval = 1024 * 1024,
1180 .category = FIO_OPT_C_IO,
1181 .group = FIO_OPT_G_INVALID,
1184 .name = "offset_increment",
1185 .lname = "IO offset increment",
1186 .type = FIO_OPT_STR_VAL,
1187 .off1 = td_var_offset(offset_increment),
1188 .help = "What is the increment from one offset to the next",
1192 .interval = 1024 * 1024,
1193 .category = FIO_OPT_C_IO,
1194 .group = FIO_OPT_G_INVALID,
1198 .lname = "Block size",
1199 .alias = "blocksize",
1200 .type = FIO_OPT_INT,
1201 .off1 = td_var_offset(bs[DDIR_READ]),
1202 .off2 = td_var_offset(bs[DDIR_WRITE]),
1204 .help = "Block size unit",
1209 .category = FIO_OPT_C_IO,
1210 .group = FIO_OPT_G_INVALID,
1214 .lname = "Block size align",
1215 .alias = "blockalign",
1216 .type = FIO_OPT_INT,
1217 .off1 = td_var_offset(ba[DDIR_READ]),
1218 .off2 = td_var_offset(ba[DDIR_WRITE]),
1220 .help = "IO block offset alignment",
1224 .category = FIO_OPT_C_IO,
1225 .group = FIO_OPT_G_INVALID,
1229 .lname = "Block size range",
1230 .alias = "blocksize_range",
1231 .type = FIO_OPT_RANGE,
1232 .off1 = td_var_offset(min_bs[DDIR_READ]),
1233 .off2 = td_var_offset(max_bs[DDIR_READ]),
1234 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
1235 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
1237 .help = "Set block size range (in more detail than bs)",
1241 .category = FIO_OPT_C_IO,
1242 .group = FIO_OPT_G_INVALID,
1246 .lname = "Block size split",
1247 .type = FIO_OPT_STR,
1248 .cb = str_bssplit_cb,
1249 .help = "Set a specific mix of block sizes",
1252 .category = FIO_OPT_C_IO,
1253 .group = FIO_OPT_G_INVALID,
1256 .name = "bs_unaligned",
1257 .lname = "Block size unaligned",
1258 .alias = "blocksize_unaligned",
1259 .type = FIO_OPT_STR_SET,
1260 .off1 = td_var_offset(bs_unaligned),
1261 .help = "Don't sector align IO buffer sizes",
1264 .category = FIO_OPT_C_IO,
1265 .group = FIO_OPT_G_INVALID,
1268 .name = "randrepeat",
1269 .lname = "Random repeatable",
1270 .type = FIO_OPT_BOOL,
1271 .off1 = td_var_offset(rand_repeatable),
1272 .help = "Use repeatable random IO pattern",
1276 .category = FIO_OPT_C_IO,
1277 .group = FIO_OPT_G_RANDOM,
1280 .name = "use_os_rand",
1281 .lname = "Use OS random",
1282 .type = FIO_OPT_BOOL,
1283 .off1 = td_var_offset(use_os_rand),
1284 .help = "Set to use OS random generator",
1288 .category = FIO_OPT_C_IO,
1289 .group = FIO_OPT_G_RANDOM,
1292 .name = "norandommap",
1293 .lname = "No randommap",
1294 .type = FIO_OPT_STR_SET,
1295 .off1 = td_var_offset(norandommap),
1296 .help = "Accept potential duplicate random blocks",
1300 .category = FIO_OPT_C_IO,
1301 .group = FIO_OPT_G_RANDOM,
1304 .name = "softrandommap",
1305 .lname = "Soft randommap",
1306 .type = FIO_OPT_BOOL,
1307 .off1 = td_var_offset(softrandommap),
1308 .help = "Set norandommap if randommap allocation fails",
1309 .parent = "norandommap",
1312 .category = FIO_OPT_C_IO,
1313 .group = FIO_OPT_G_RANDOM,
1317 .lname = "Number of files",
1318 .alias = "nr_files",
1319 .type = FIO_OPT_INT,
1320 .off1 = td_var_offset(nr_files),
1321 .help = "Split job workload between this number of files",
1324 .category = FIO_OPT_C_FILE,
1325 .group = FIO_OPT_G_INVALID,
1328 .name = "openfiles",
1329 .lname = "Number of open files",
1330 .type = FIO_OPT_INT,
1331 .off1 = td_var_offset(open_files),
1332 .help = "Number of files to keep open at the same time",
1333 .category = FIO_OPT_C_FILE,
1334 .group = FIO_OPT_G_INVALID,
1337 .name = "file_service_type",
1338 .lname = "File service type",
1339 .type = FIO_OPT_STR,
1341 .off1 = td_var_offset(file_service_type),
1342 .help = "How to select which file to service next",
1343 .def = "roundrobin",
1344 .category = FIO_OPT_C_FILE,
1345 .group = FIO_OPT_G_INVALID,
1348 .oval = FIO_FSERVICE_RANDOM,
1349 .help = "Choose a file at random",
1351 { .ival = "roundrobin",
1352 .oval = FIO_FSERVICE_RR,
1353 .help = "Round robin select files",
1355 { .ival = "sequential",
1356 .oval = FIO_FSERVICE_SEQ,
1357 .help = "Finish one file before moving to the next",
1360 .parent = "nrfiles",
1363 #ifdef FIO_HAVE_FALLOCATE
1365 .name = "fallocate",
1366 .lname = "Fallocate",
1367 .type = FIO_OPT_STR,
1368 .off1 = td_var_offset(fallocate_mode),
1369 .help = "Whether pre-allocation is performed when laying out files",
1371 .category = FIO_OPT_C_FILE,
1372 .group = FIO_OPT_G_INVALID,
1375 .oval = FIO_FALLOCATE_NONE,
1376 .help = "Do not pre-allocate space",
1379 .oval = FIO_FALLOCATE_POSIX,
1380 .help = "Use posix_fallocate()",
1382 #ifdef FIO_HAVE_LINUX_FALLOCATE
1384 .oval = FIO_FALLOCATE_KEEP_SIZE,
1385 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
1388 /* Compatibility with former boolean values */
1390 .oval = FIO_FALLOCATE_NONE,
1391 .help = "Alias for 'none'",
1394 .oval = FIO_FALLOCATE_POSIX,
1395 .help = "Alias for 'posix'",
1399 #endif /* FIO_HAVE_FALLOCATE */
1401 .name = "fadvise_hint",
1402 .lname = "Fadvise hint",
1403 .type = FIO_OPT_BOOL,
1404 .off1 = td_var_offset(fadvise_hint),
1405 .help = "Use fadvise() to advise the kernel on IO pattern",
1407 .category = FIO_OPT_C_FILE,
1408 .group = FIO_OPT_G_INVALID,
1413 .type = FIO_OPT_INT,
1414 .off1 = td_var_offset(fsync_blocks),
1415 .help = "Issue fsync for writes every given number of blocks",
1418 .category = FIO_OPT_C_FILE,
1419 .group = FIO_OPT_G_INVALID,
1422 .name = "fdatasync",
1423 .lname = "Fdatasync",
1424 .type = FIO_OPT_INT,
1425 .off1 = td_var_offset(fdatasync_blocks),
1426 .help = "Issue fdatasync for writes every given number of blocks",
1429 .category = FIO_OPT_C_FILE,
1430 .group = FIO_OPT_G_INVALID,
1433 .name = "write_barrier",
1434 .lname = "Write barrier",
1435 .type = FIO_OPT_INT,
1436 .off1 = td_var_offset(barrier_blocks),
1437 .help = "Make every Nth write a barrier write",
1440 .category = FIO_OPT_C_IO,
1441 .group = FIO_OPT_G_INVALID,
1443 #ifdef FIO_HAVE_SYNC_FILE_RANGE
1445 .name = "sync_file_range",
1446 .lname = "Sync file range",
1448 { .ival = "wait_before",
1449 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
1450 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
1454 .oval = SYNC_FILE_RANGE_WRITE,
1455 .help = "SYNC_FILE_RANGE_WRITE",
1459 .ival = "wait_after",
1460 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
1461 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
1465 .type = FIO_OPT_STR_MULTI,
1467 .off1 = td_var_offset(sync_file_range),
1468 .help = "Use sync_file_range()",
1469 .category = FIO_OPT_C_FILE,
1470 .group = FIO_OPT_G_INVALID,
1475 .lname = "Direct I/O",
1476 .type = FIO_OPT_BOOL,
1477 .off1 = td_var_offset(odirect),
1478 .help = "Use O_DIRECT IO (negates buffered)",
1480 .inverse = "buffered",
1481 .category = FIO_OPT_C_IO,
1482 .group = FIO_OPT_G_IO_TYPE,
1486 .lname = "Buffered I/O",
1487 .type = FIO_OPT_BOOL,
1488 .off1 = td_var_offset(odirect),
1490 .help = "Use buffered IO (negates direct)",
1492 .inverse = "direct",
1493 .category = FIO_OPT_C_IO,
1494 .group = FIO_OPT_G_IO_TYPE,
1497 .name = "overwrite",
1498 .lname = "Overwrite",
1499 .type = FIO_OPT_BOOL,
1500 .off1 = td_var_offset(overwrite),
1501 .help = "When writing, set whether to overwrite current data",
1503 .category = FIO_OPT_C_FILE,
1504 .group = FIO_OPT_G_INVALID,
1509 .type = FIO_OPT_INT,
1510 .off1 = td_var_offset(loops),
1511 .help = "Number of times to run the job",
1514 .category = FIO_OPT_C_GENERAL,
1515 .group = FIO_OPT_G_RUNTIME,
1519 .lname = "Number of jobs",
1520 .type = FIO_OPT_INT,
1521 .off1 = td_var_offset(numjobs),
1522 .help = "Duplicate this job this many times",
1525 .category = FIO_OPT_C_GENERAL,
1526 .group = FIO_OPT_G_RUNTIME,
1529 .name = "startdelay",
1530 .lname = "Start delay",
1531 .type = FIO_OPT_STR_VAL_TIME,
1532 .off1 = td_var_offset(start_delay),
1533 .help = "Only start job when this period has passed",
1535 .category = FIO_OPT_C_GENERAL,
1536 .group = FIO_OPT_G_RUNTIME,
1542 .type = FIO_OPT_STR_VAL_TIME,
1543 .off1 = td_var_offset(timeout),
1544 .help = "Stop workload when this amount of time has passed",
1546 .category = FIO_OPT_C_GENERAL,
1547 .group = FIO_OPT_G_RUNTIME,
1550 .name = "time_based",
1551 .lname = "Time based",
1552 .type = FIO_OPT_STR_SET,
1553 .off1 = td_var_offset(time_based),
1554 .help = "Keep running until runtime/timeout is met",
1555 .category = FIO_OPT_C_GENERAL,
1556 .group = FIO_OPT_G_RUNTIME,
1559 .name = "ramp_time",
1560 .lname = "Ramp time",
1561 .type = FIO_OPT_STR_VAL_TIME,
1562 .off1 = td_var_offset(ramp_time),
1563 .help = "Ramp up time before measuring performance",
1564 .category = FIO_OPT_C_GENERAL,
1565 .group = FIO_OPT_G_RUNTIME,
1568 .name = "clocksource",
1569 .lname = "Clock source",
1570 .type = FIO_OPT_STR,
1571 .cb = fio_clock_source_cb,
1572 .off1 = td_var_offset(clocksource),
1573 .help = "What type of timing source to use",
1574 .category = FIO_OPT_C_GENERAL,
1575 .group = FIO_OPT_G_CLOCK,
1577 { .ival = "gettimeofday",
1579 .help = "Use gettimeofday(2) for timing",
1581 { .ival = "clock_gettime",
1582 .oval = CS_CGETTIME,
1583 .help = "Use clock_gettime(2) for timing",
1585 #ifdef ARCH_HAVE_CPU_CLOCK
1587 .oval = CS_CPUCLOCK,
1588 .help = "Use CPU private clock",
1596 .lname = "I/O Memory",
1597 .type = FIO_OPT_STR,
1599 .off1 = td_var_offset(mem_type),
1600 .help = "Backing type for IO buffers",
1602 .category = FIO_OPT_C_IO,
1603 .group = FIO_OPT_G_INVALID,
1607 .help = "Use malloc(3) for IO buffers",
1611 .help = "Use shared memory segments for IO buffers",
1613 #ifdef FIO_HAVE_HUGETLB
1614 { .ival = "shmhuge",
1615 .oval = MEM_SHMHUGE,
1616 .help = "Like shm, but use huge pages",
1621 .help = "Use mmap(2) (file or anon) for IO buffers",
1623 #ifdef FIO_HAVE_HUGETLB
1624 { .ival = "mmaphuge",
1625 .oval = MEM_MMAPHUGE,
1626 .help = "Like mmap, but use huge pages",
1632 .name = "iomem_align",
1633 .alias = "mem_align",
1634 .lname = "I/O memory alignment",
1635 .type = FIO_OPT_INT,
1636 .off1 = td_var_offset(mem_align),
1638 .help = "IO memory buffer offset alignment",
1642 .category = FIO_OPT_C_IO,
1643 .group = FIO_OPT_G_INVALID,
1648 .type = FIO_OPT_STR,
1649 .off1 = td_var_offset(verify),
1650 .help = "Verify data written",
1652 .category = FIO_OPT_C_IO,
1653 .group = FIO_OPT_G_VERIFY,
1656 .oval = VERIFY_NONE,
1657 .help = "Don't do IO verification",
1661 .help = "Use md5 checksums for verification",
1664 .oval = VERIFY_CRC64,
1665 .help = "Use crc64 checksums for verification",
1668 .oval = VERIFY_CRC32,
1669 .help = "Use crc32 checksums for verification",
1671 { .ival = "crc32c-intel",
1672 .oval = VERIFY_CRC32C,
1673 .help = "Use crc32c checksums for verification (hw assisted, if available)",
1676 .oval = VERIFY_CRC32C,
1677 .help = "Use crc32c checksums for verification (hw assisted, if available)",
1680 .oval = VERIFY_CRC16,
1681 .help = "Use crc16 checksums for verification",
1684 .oval = VERIFY_CRC7,
1685 .help = "Use crc7 checksums for verification",
1688 .oval = VERIFY_SHA1,
1689 .help = "Use sha1 checksums for verification",
1692 .oval = VERIFY_SHA256,
1693 .help = "Use sha256 checksums for verification",
1696 .oval = VERIFY_SHA512,
1697 .help = "Use sha512 checksums for verification",
1700 .oval = VERIFY_META,
1701 .help = "Use io information",
1705 .oval = VERIFY_NULL,
1706 .help = "Pretend to verify",
1711 .name = "do_verify",
1712 .lname = "Perform verify step",
1713 .type = FIO_OPT_BOOL,
1714 .off1 = td_var_offset(do_verify),
1715 .help = "Run verification stage after write",
1719 .category = FIO_OPT_C_IO,
1720 .group = FIO_OPT_G_VERIFY,
1723 .name = "verifysort",
1724 .lname = "Verify sort",
1725 .type = FIO_OPT_BOOL,
1726 .off1 = td_var_offset(verifysort),
1727 .help = "Sort written verify blocks for read back",
1731 .category = FIO_OPT_C_IO,
1732 .group = FIO_OPT_G_VERIFY,
1735 .name = "verify_interval",
1736 .lname = "Verify interval",
1737 .type = FIO_OPT_INT,
1738 .off1 = td_var_offset(verify_interval),
1739 .minval = 2 * sizeof(struct verify_header),
1740 .help = "Store verify buffer header every N bytes",
1743 .interval = 2 * sizeof(struct verify_header),
1744 .category = FIO_OPT_C_IO,
1745 .group = FIO_OPT_G_VERIFY,
1748 .name = "verify_offset",
1749 .lname = "Verify offset",
1750 .type = FIO_OPT_INT,
1751 .help = "Offset verify header location by N bytes",
1752 .off1 = td_var_offset(verify_offset),
1753 .minval = sizeof(struct verify_header),
1756 .category = FIO_OPT_C_IO,
1757 .group = FIO_OPT_G_VERIFY,
1760 .name = "verify_pattern",
1761 .lname = "Verify pattern",
1762 .type = FIO_OPT_STR,
1763 .cb = str_verify_pattern_cb,
1764 .help = "Fill pattern for IO buffers",
1767 .category = FIO_OPT_C_IO,
1768 .group = FIO_OPT_G_VERIFY,
1771 .name = "verify_fatal",
1772 .lname = "Verify fatal",
1773 .type = FIO_OPT_BOOL,
1774 .off1 = td_var_offset(verify_fatal),
1776 .help = "Exit on a single verify failure, don't continue",
1779 .category = FIO_OPT_C_IO,
1780 .group = FIO_OPT_G_VERIFY,
1783 .name = "verify_dump",
1784 .lname = "Verify dump",
1785 .type = FIO_OPT_BOOL,
1786 .off1 = td_var_offset(verify_dump),
1788 .help = "Dump contents of good and bad blocks on failure",
1791 .category = FIO_OPT_C_IO,
1792 .group = FIO_OPT_G_VERIFY,
1795 .name = "verify_async",
1796 .lname = "Verify asynchronously",
1797 .type = FIO_OPT_INT,
1798 .off1 = td_var_offset(verify_async),
1800 .help = "Number of async verifier threads to use",
1803 .category = FIO_OPT_C_IO,
1804 .group = FIO_OPT_G_VERIFY,
1807 .name = "verify_backlog",
1808 .lname = "Verify backlog",
1809 .type = FIO_OPT_STR_VAL,
1810 .off1 = td_var_offset(verify_backlog),
1811 .help = "Verify after this number of blocks are written",
1814 .category = FIO_OPT_C_IO,
1815 .group = FIO_OPT_G_VERIFY,
1818 .name = "verify_backlog_batch",
1819 .lname = "Verify backlog batch",
1820 .type = FIO_OPT_INT,
1821 .off1 = td_var_offset(verify_batch),
1822 .help = "Verify this number of IO blocks",
1825 .category = FIO_OPT_C_IO,
1826 .group = FIO_OPT_G_VERIFY,
1828 #ifdef FIO_HAVE_CPU_AFFINITY
1830 .name = "verify_async_cpus",
1831 .lname = "Async verify CPUs",
1832 .type = FIO_OPT_STR,
1833 .cb = str_verify_cpus_allowed_cb,
1834 .help = "Set CPUs allowed for async verify threads",
1835 .parent = "verify_async",
1837 .category = FIO_OPT_C_IO,
1838 .group = FIO_OPT_G_VERIFY,
1841 #ifdef FIO_HAVE_TRIM
1843 .name = "trim_percentage",
1844 .lname = "Trim percentage",
1845 .type = FIO_OPT_INT,
1846 .off1 = td_var_offset(trim_percentage),
1849 .help = "Number of verify blocks to discard/trim",
1854 .category = FIO_OPT_C_IO,
1855 .group = FIO_OPT_G_TRIM,
1858 .name = "trim_verify_zero",
1859 .lname = "Verify trim zero",
1860 .type = FIO_OPT_BOOL,
1861 .help = "Verify that trim/discarded blocks are returned as zeroes",
1862 .off1 = td_var_offset(trim_zero),
1863 .parent = "trim_percentage",
1866 .category = FIO_OPT_C_IO,
1867 .group = FIO_OPT_G_TRIM,
1870 .name = "trim_backlog",
1871 .lname = "Trim backlog",
1872 .type = FIO_OPT_STR_VAL,
1873 .off1 = td_var_offset(trim_backlog),
1874 .help = "Trim after this number of blocks are written",
1875 .parent = "trim_percentage",
1878 .category = FIO_OPT_C_IO,
1879 .group = FIO_OPT_G_TRIM,
1882 .name = "trim_backlog_batch",
1883 .lname = "Trim backlog batch",
1884 .type = FIO_OPT_INT,
1885 .off1 = td_var_offset(trim_batch),
1886 .help = "Trim this number of IO blocks",
1887 .parent = "trim_percentage",
1890 .category = FIO_OPT_C_IO,
1891 .group = FIO_OPT_G_TRIM,
1895 .name = "write_iolog",
1896 .lname = "Write I/O log",
1897 .type = FIO_OPT_STR_STORE,
1898 .off1 = td_var_offset(write_iolog_file),
1899 .help = "Store IO pattern to file",
1900 .category = FIO_OPT_C_IO,
1901 .group = FIO_OPT_G_IOLOG,
1904 .name = "read_iolog",
1905 .lname = "Read I/O log",
1906 .type = FIO_OPT_STR_STORE,
1907 .off1 = td_var_offset(read_iolog_file),
1908 .help = "Playback IO pattern from file",
1909 .category = FIO_OPT_C_IO,
1910 .group = FIO_OPT_G_IOLOG,
1913 .name = "replay_no_stall",
1914 .lname = "Don't stall on replay",
1915 .type = FIO_OPT_BOOL,
1916 .off1 = td_var_offset(no_stall),
1918 .parent = "read_iolog",
1920 .help = "Playback IO pattern file as fast as possible without stalls",
1921 .category = FIO_OPT_C_IO,
1922 .group = FIO_OPT_G_IOLOG,
1925 .name = "replay_redirect",
1926 .lname = "Redirect device for replay",
1927 .type = FIO_OPT_STR_STORE,
1928 .off1 = td_var_offset(replay_redirect),
1929 .parent = "read_iolog",
1931 .help = "Replay all I/O onto this device, regardless of trace device",
1932 .category = FIO_OPT_C_IO,
1933 .group = FIO_OPT_G_IOLOG,
1936 .name = "exec_prerun",
1937 .lname = "Pre-execute runnable",
1938 .type = FIO_OPT_STR_STORE,
1939 .off1 = td_var_offset(exec_prerun),
1940 .help = "Execute this file prior to running job",
1941 .category = FIO_OPT_C_GENERAL,
1942 .group = FIO_OPT_G_INVALID,
1945 .name = "exec_postrun",
1946 .lname = "Post-execute runnable",
1947 .type = FIO_OPT_STR_STORE,
1948 .off1 = td_var_offset(exec_postrun),
1949 .help = "Execute this file after running job",
1950 .category = FIO_OPT_C_GENERAL,
1951 .group = FIO_OPT_G_INVALID,
1953 #ifdef FIO_HAVE_IOSCHED_SWITCH
1955 .name = "ioscheduler",
1956 .lname = "I/O scheduler",
1957 .type = FIO_OPT_STR_STORE,
1958 .off1 = td_var_offset(ioscheduler),
1959 .help = "Use this IO scheduler on the backing device",
1960 .category = FIO_OPT_C_FILE,
1961 .group = FIO_OPT_G_INVALID,
1966 .lname = "Zone size",
1967 .type = FIO_OPT_STR_VAL,
1968 .off1 = td_var_offset(zone_size),
1969 .help = "Amount of data to read per zone",
1971 .interval = 1024 * 1024,
1972 .category = FIO_OPT_C_IO,
1973 .group = FIO_OPT_G_ZONE,
1976 .name = "zonerange",
1977 .lname = "Zone range",
1978 .type = FIO_OPT_STR_VAL,
1979 .off1 = td_var_offset(zone_range),
1980 .help = "Give size of an IO zone",
1982 .interval = 1024 * 1024,
1983 .category = FIO_OPT_C_IO,
1984 .group = FIO_OPT_G_ZONE,
1988 .lname = "Zone skip",
1989 .type = FIO_OPT_STR_VAL,
1990 .off1 = td_var_offset(zone_skip),
1991 .help = "Space between IO zones",
1993 .interval = 1024 * 1024,
1994 .category = FIO_OPT_C_IO,
1995 .group = FIO_OPT_G_ZONE,
1999 .lname = "Lock memory",
2000 .type = FIO_OPT_STR_VAL,
2001 .off1 = td_var_offset(lockmem),
2002 .help = "Lock down this amount of memory",
2004 .interval = 1024 * 1024,
2005 .category = FIO_OPT_C_GENERAL,
2006 .group = FIO_OPT_G_INVALID,
2009 .name = "rwmixread",
2010 .lname = "Read/write mix read",
2011 .type = FIO_OPT_INT,
2012 .cb = str_rwmix_read_cb,
2014 .help = "Percentage of mixed workload that is reads",
2017 .inverse = "rwmixwrite",
2018 .category = FIO_OPT_C_IO,
2019 .group = FIO_OPT_G_RWMIX,
2022 .name = "rwmixwrite",
2023 .lname = "Read/write mix write",
2024 .type = FIO_OPT_INT,
2025 .cb = str_rwmix_write_cb,
2027 .help = "Percentage of mixed workload that is writes",
2030 .inverse = "rwmixread",
2031 .category = FIO_OPT_C_IO,
2032 .group = FIO_OPT_G_RWMIX,
2035 .name = "rwmixcycle",
2036 .lname = "Read/write mix cycle",
2037 .type = FIO_OPT_DEPRECATED,
2038 .category = FIO_OPT_C_IO,
2039 .group = FIO_OPT_G_RWMIX,
2044 .type = FIO_OPT_INT,
2045 .off1 = td_var_offset(nice),
2046 .help = "Set job CPU nice value",
2051 .category = FIO_OPT_C_GENERAL,
2052 .group = FIO_OPT_G_CRED,
2054 #ifdef FIO_HAVE_IOPRIO
2057 .lname = "I/O nice priority",
2058 .type = FIO_OPT_INT,
2059 .off1 = td_var_offset(ioprio),
2060 .help = "Set job IO priority value",
2064 .category = FIO_OPT_C_GENERAL,
2065 .group = FIO_OPT_G_CRED,
2068 .name = "prioclass",
2069 .lname = "I/O nice priority class",
2070 .type = FIO_OPT_INT,
2071 .off1 = td_var_offset(ioprio_class),
2072 .help = "Set job IO priority class",
2076 .category = FIO_OPT_C_GENERAL,
2077 .group = FIO_OPT_G_CRED,
2081 .name = "thinktime",
2082 .lname = "Thinktime",
2083 .type = FIO_OPT_INT,
2084 .off1 = td_var_offset(thinktime),
2085 .help = "Idle time between IO buffers (usec)",
2087 .category = FIO_OPT_C_IO,
2088 .group = FIO_OPT_G_THINKTIME,
2091 .name = "thinktime_spin",
2092 .lname = "Thinktime spin",
2093 .type = FIO_OPT_INT,
2094 .off1 = td_var_offset(thinktime_spin),
2095 .help = "Start think time by spinning this amount (usec)",
2097 .parent = "thinktime",
2099 .category = FIO_OPT_C_IO,
2100 .group = FIO_OPT_G_THINKTIME,
2103 .name = "thinktime_blocks",
2104 .lname = "Thinktime blocks",
2105 .type = FIO_OPT_INT,
2106 .off1 = td_var_offset(thinktime_blocks),
2107 .help = "IO buffer period between 'thinktime'",
2109 .parent = "thinktime",
2111 .category = FIO_OPT_C_IO,
2112 .group = FIO_OPT_G_THINKTIME,
2116 .lname = "I/O rate",
2117 .type = FIO_OPT_INT,
2118 .off1 = td_var_offset(rate[0]),
2119 .off2 = td_var_offset(rate[1]),
2120 .help = "Set bandwidth rate",
2121 .category = FIO_OPT_C_IO,
2122 .group = FIO_OPT_G_RATE,
2126 .lname = "I/O min rate",
2127 .type = FIO_OPT_INT,
2128 .off1 = td_var_offset(ratemin[0]),
2129 .off2 = td_var_offset(ratemin[1]),
2130 .help = "Job must meet this rate or it will be shutdown",
2133 .category = FIO_OPT_C_IO,
2134 .group = FIO_OPT_G_RATE,
2137 .name = "rate_iops",
2138 .lname = "I/O rate IOPS",
2139 .type = FIO_OPT_INT,
2140 .off1 = td_var_offset(rate_iops[0]),
2141 .off2 = td_var_offset(rate_iops[1]),
2142 .help = "Limit IO used to this number of IO operations/sec",
2144 .category = FIO_OPT_C_IO,
2145 .group = FIO_OPT_G_RATE,
2148 .name = "rate_iops_min",
2149 .lname = "I/O min rate IOPS",
2150 .type = FIO_OPT_INT,
2151 .off1 = td_var_offset(rate_iops_min[0]),
2152 .off2 = td_var_offset(rate_iops_min[1]),
2153 .help = "Job must meet this rate or it will be shut down",
2154 .parent = "rate_iops",
2156 .category = FIO_OPT_C_IO,
2157 .group = FIO_OPT_G_RATE,
2160 .name = "ratecycle",
2161 .lname = "I/O rate cycle",
2162 .type = FIO_OPT_INT,
2163 .off1 = td_var_offset(ratecycle),
2164 .help = "Window average for rate limits (msec)",
2168 .category = FIO_OPT_C_IO,
2169 .group = FIO_OPT_G_RATE,
2172 .name = "invalidate",
2173 .lname = "Cache invalidate",
2174 .type = FIO_OPT_BOOL,
2175 .off1 = td_var_offset(invalidate_cache),
2176 .help = "Invalidate buffer/page cache prior to running job",
2178 .category = FIO_OPT_C_IO,
2179 .group = FIO_OPT_G_IO_TYPE,
2183 .lname = "Synchronous I/O",
2184 .type = FIO_OPT_BOOL,
2185 .off1 = td_var_offset(sync_io),
2186 .help = "Use O_SYNC for buffered writes",
2188 .parent = "buffered",
2190 .category = FIO_OPT_C_IO,
2191 .group = FIO_OPT_G_IO_TYPE,
2194 .name = "create_serialize",
2195 .lname = "Create serialize",
2196 .type = FIO_OPT_BOOL,
2197 .off1 = td_var_offset(create_serialize),
2198 .help = "Serialize creating of job files",
2200 .category = FIO_OPT_C_FILE,
2201 .group = FIO_OPT_G_INVALID,
2204 .name = "create_fsync",
2205 .lname = "Create fsync",
2206 .type = FIO_OPT_BOOL,
2207 .off1 = td_var_offset(create_fsync),
2208 .help = "fsync file after creation",
2210 .category = FIO_OPT_C_FILE,
2211 .group = FIO_OPT_G_INVALID,
2214 .name = "create_on_open",
2215 .lname = "Create on open",
2216 .type = FIO_OPT_BOOL,
2217 .off1 = td_var_offset(create_on_open),
2218 .help = "Create files when they are opened for IO",
2220 .category = FIO_OPT_C_FILE,
2221 .group = FIO_OPT_G_INVALID,
2225 .lname = "Pre-read files",
2226 .type = FIO_OPT_BOOL,
2227 .off1 = td_var_offset(pre_read),
2228 .help = "Pre-read files before starting official testing",
2230 .category = FIO_OPT_C_FILE,
2231 .group = FIO_OPT_G_INVALID,
2233 #ifdef FIO_HAVE_CPU_AFFINITY
2236 .lname = "CPU mask",
2237 .type = FIO_OPT_INT,
2238 .cb = str_cpumask_cb,
2239 .help = "CPU affinity mask",
2240 .category = FIO_OPT_C_GENERAL,
2241 .group = FIO_OPT_G_CRED,
2244 .name = "cpus_allowed",
2245 .lname = "CPUs allowed",
2246 .type = FIO_OPT_STR,
2247 .cb = str_cpus_allowed_cb,
2248 .help = "Set CPUs allowed",
2249 .category = FIO_OPT_C_GENERAL,
2250 .group = FIO_OPT_G_CRED,
2254 .name = "end_fsync",
2255 .lname = "End fsync",
2256 .type = FIO_OPT_BOOL,
2257 .off1 = td_var_offset(end_fsync),
2258 .help = "Include fsync at the end of job",
2260 .category = FIO_OPT_C_FILE,
2261 .group = FIO_OPT_G_INVALID,
2264 .name = "fsync_on_close",
2265 .lname = "Fsync on close",
2266 .type = FIO_OPT_BOOL,
2267 .off1 = td_var_offset(fsync_on_close),
2268 .help = "fsync files on close",
2270 .category = FIO_OPT_C_FILE,
2271 .group = FIO_OPT_G_INVALID,
2275 .lname = "Unlink file",
2276 .type = FIO_OPT_BOOL,
2277 .off1 = td_var_offset(unlink),
2278 .help = "Unlink created files after job has completed",
2280 .category = FIO_OPT_C_FILE,
2281 .group = FIO_OPT_G_INVALID,
2285 .lname = "Exit-all on terminate",
2286 .type = FIO_OPT_STR_SET,
2287 .cb = str_exitall_cb,
2288 .help = "Terminate all jobs when one exits",
2289 .category = FIO_OPT_C_GENERAL,
2290 .group = FIO_OPT_G_PROCESS,
2293 .name = "stonewall",
2294 .lname = "Wait for previous",
2295 .alias = "wait_for_previous",
2296 .type = FIO_OPT_STR_SET,
2297 .off1 = td_var_offset(stonewall),
2298 .help = "Insert a hard barrier between this job and previous",
2299 .category = FIO_OPT_C_GENERAL,
2300 .group = FIO_OPT_G_PROCESS,
2303 .name = "new_group",
2304 .lname = "New group",
2305 .type = FIO_OPT_STR_SET,
2306 .off1 = td_var_offset(new_group),
2307 .help = "Mark the start of a new group (for reporting)",
2308 .category = FIO_OPT_C_GENERAL,
2309 .group = FIO_OPT_G_PROCESS,
2314 .type = FIO_OPT_STR_SET,
2315 .off1 = td_var_offset(use_thread),
2316 .help = "Use threads instead of processes",
2317 .category = FIO_OPT_C_GENERAL,
2318 .group = FIO_OPT_G_PROCESS,
2321 .name = "write_bw_log",
2322 .lname = "Write bandwidth log",
2323 .type = FIO_OPT_STR_STORE,
2324 .off1 = td_var_offset(bw_log_file),
2325 .help = "Write log of bandwidth during run",
2326 .category = FIO_OPT_C_LOG,
2327 .group = FIO_OPT_G_INVALID,
2330 .name = "write_lat_log",
2331 .lname = "Write latency log",
2332 .type = FIO_OPT_STR_STORE,
2333 .off1 = td_var_offset(lat_log_file),
2334 .help = "Write log of latency during run",
2335 .category = FIO_OPT_C_LOG,
2336 .group = FIO_OPT_G_INVALID,
2339 .name = "write_iops_log",
2340 .lname = "Write IOPS log",
2341 .type = FIO_OPT_STR,
2342 .off1 = td_var_offset(iops_log_file),
2343 .help = "Write log of IOPS during run",
2344 .category = FIO_OPT_C_LOG,
2345 .group = FIO_OPT_G_INVALID,
2348 .name = "log_avg_msec",
2349 .lname = "Log averaging (msec)",
2350 .type = FIO_OPT_INT,
2351 .off1 = td_var_offset(log_avg_msec),
2352 .help = "Average bw/iops/lat logs over this period of time",
2354 .category = FIO_OPT_C_LOG,
2355 .group = FIO_OPT_G_INVALID,
2358 .name = "bwavgtime",
2359 .lname = "Bandwidth average time",
2360 .type = FIO_OPT_INT,
2361 .off1 = td_var_offset(bw_avg_time),
2362 .help = "Time window over which to calculate bandwidth"
2365 .parent = "write_bw_log",
2368 .category = FIO_OPT_C_LOG,
2369 .group = FIO_OPT_G_INVALID,
2372 .name = "iopsavgtime",
2373 .lname = "IOPS average time",
2374 .type = FIO_OPT_INT,
2375 .off1 = td_var_offset(iops_avg_time),
2376 .help = "Time window over which to calculate IOPS (msec)",
2378 .parent = "write_iops_log",
2381 .category = FIO_OPT_C_LOG,
2382 .group = FIO_OPT_G_INVALID,
2385 .name = "group_reporting",
2386 .lname = "Group reporting",
2387 .type = FIO_OPT_BOOL,
2388 .off1 = td_var_offset(group_reporting),
2389 .help = "Do reporting on a per-group basis",
2391 .category = FIO_OPT_C_STAT,
2392 .group = FIO_OPT_G_INVALID,
2395 .name = "zero_buffers",
2396 .lname = "Zero I/O buffers",
2397 .type = FIO_OPT_STR_SET,
2398 .off1 = td_var_offset(zero_buffers),
2399 .help = "Init IO buffers to all zeroes",
2400 .category = FIO_OPT_C_IO,
2401 .group = FIO_OPT_G_IO_BUF,
2404 .name = "refill_buffers",
2405 .lname = "Refill I/O buffers",
2406 .type = FIO_OPT_STR_SET,
2407 .off1 = td_var_offset(refill_buffers),
2408 .help = "Refill IO buffers on every IO submit",
2409 .category = FIO_OPT_C_IO,
2410 .group = FIO_OPT_G_IO_BUF,
2413 .name = "scramble_buffers",
2414 .lname = "Scramble I/O buffers",
2415 .type = FIO_OPT_BOOL,
2416 .off1 = td_var_offset(scramble_buffers),
2417 .help = "Slightly scramble buffers on every IO submit",
2419 .category = FIO_OPT_C_IO,
2420 .group = FIO_OPT_G_IO_BUF,
2423 .name = "buffer_compress_percentage",
2424 .lname = "Buffer compression percentage",
2425 .type = FIO_OPT_INT,
2426 .off1 = td_var_offset(compress_percentage),
2429 .help = "How compressible the buffer is (approximately)",
2431 .category = FIO_OPT_C_IO,
2432 .group = FIO_OPT_G_IO_BUF,
2435 .name = "buffer_compress_chunk",
2436 .lname = "Buffer compression chunk size",
2437 .type = FIO_OPT_INT,
2438 .off1 = td_var_offset(compress_chunk),
2439 .parent = "buffer_compress_percentage",
2441 .help = "Size of compressible region in buffer",
2443 .category = FIO_OPT_C_IO,
2444 .group = FIO_OPT_G_IO_BUF,
2447 .name = "clat_percentiles",
2448 .lname = "Completion latency percentiles",
2449 .type = FIO_OPT_BOOL,
2450 .off1 = td_var_offset(clat_percentiles),
2451 .help = "Enable the reporting of completion latency percentiles",
2453 .category = FIO_OPT_C_STAT,
2454 .group = FIO_OPT_G_INVALID,
2457 .name = "percentile_list",
2458 .lname = "Completion latency percentile list",
2459 .type = FIO_OPT_FLOAT_LIST,
2460 .off1 = td_var_offset(percentile_list),
2461 .off2 = td_var_offset(overwrite_plist),
2462 .help = "Specify a custom list of percentiles to report",
2463 .maxlen = FIO_IO_U_LIST_MAX_LEN,
2466 .category = FIO_OPT_C_STAT,
2467 .group = FIO_OPT_G_INVALID,
2470 #ifdef FIO_HAVE_DISK_UTIL
2472 .name = "disk_util",
2473 .lname = "Disk utilization",
2474 .type = FIO_OPT_BOOL,
2475 .off1 = td_var_offset(do_disk_util),
2476 .help = "Log disk utilization statistics",
2478 .category = FIO_OPT_C_STAT,
2479 .group = FIO_OPT_G_INVALID,
2483 .name = "gtod_reduce",
2484 .lname = "Reduce gettimeofday() calls",
2485 .type = FIO_OPT_BOOL,
2486 .help = "Greatly reduce number of gettimeofday() calls",
2487 .cb = str_gtod_reduce_cb,
2490 .category = FIO_OPT_C_STAT,
2491 .group = FIO_OPT_G_INVALID,
2494 .name = "disable_lat",
2495 .lname = "Disable all latency stats",
2496 .type = FIO_OPT_BOOL,
2497 .off1 = td_var_offset(disable_lat),
2498 .help = "Disable latency numbers",
2499 .parent = "gtod_reduce",
2502 .category = FIO_OPT_C_STAT,
2503 .group = FIO_OPT_G_INVALID,
2506 .name = "disable_clat",
2507 .lname = "Disable completion latency stats",
2508 .type = FIO_OPT_BOOL,
2509 .off1 = td_var_offset(disable_clat),
2510 .help = "Disable completion latency numbers",
2511 .parent = "gtod_reduce",
2514 .category = FIO_OPT_C_STAT,
2515 .group = FIO_OPT_G_INVALID,
2518 .name = "disable_slat",
2519 .lname = "Disable submission latency stats",
2520 .type = FIO_OPT_BOOL,
2521 .off1 = td_var_offset(disable_slat),
2522 .help = "Disable submission latency numbers",
2523 .parent = "gtod_reduce",
2526 .category = FIO_OPT_C_STAT,
2527 .group = FIO_OPT_G_INVALID,
2530 .name = "disable_bw_measurement",
2531 .lname = "Disable bandwidth stats",
2532 .type = FIO_OPT_BOOL,
2533 .off1 = td_var_offset(disable_bw),
2534 .help = "Disable bandwidth logging",
2535 .parent = "gtod_reduce",
2538 .category = FIO_OPT_C_STAT,
2539 .group = FIO_OPT_G_INVALID,
2543 .lname = "Dedicated gettimeofday() CPU",
2544 .type = FIO_OPT_INT,
2545 .cb = str_gtod_cpu_cb,
2546 .help = "Set up dedicated gettimeofday() thread on this CPU",
2547 .verify = gtod_cpu_verify,
2548 .category = FIO_OPT_C_GENERAL,
2549 .group = FIO_OPT_G_CLOCK,
2552 .name = "continue_on_error",
2553 .lname = "Continue on error",
2554 .type = FIO_OPT_STR,
2555 .off1 = td_var_offset(continue_on_error),
2556 .help = "Continue on non-fatal errors during IO",
2558 .category = FIO_OPT_C_GENERAL,
2559 .group = FIO_OPT_G_INVALID,
2562 .oval = ERROR_TYPE_NONE,
2563 .help = "Exit when an error is encountered",
2566 .oval = ERROR_TYPE_READ,
2567 .help = "Continue on read errors only",
2570 .oval = ERROR_TYPE_WRITE,
2571 .help = "Continue on write errors only",
2574 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
2575 .help = "Continue on any IO errors",
2578 .oval = ERROR_TYPE_VERIFY,
2579 .help = "Continue on verify errors only",
2582 .oval = ERROR_TYPE_ANY,
2583 .help = "Continue on all io and verify errors",
2586 .oval = ERROR_TYPE_NONE,
2587 .help = "Alias for 'none'",
2590 .oval = ERROR_TYPE_ANY,
2591 .help = "Alias for 'all'",
2598 .type = FIO_OPT_STR_STORE,
2599 .off1 = td_var_offset(profile),
2600 .help = "Select a specific builtin performance test",
2601 .category = FIO_OPT_C_PROFILE,
2602 .group = FIO_OPT_G_INVALID,
2607 .type = FIO_OPT_STR_STORE,
2608 .off1 = td_var_offset(cgroup),
2609 .help = "Add job to cgroup of this name",
2610 .category = FIO_OPT_C_GENERAL,
2611 .group = FIO_OPT_G_CGROUP,
2614 .name = "cgroup_nodelete",
2615 .lname = "Cgroup no-delete",
2616 .type = FIO_OPT_BOOL,
2617 .off1 = td_var_offset(cgroup_nodelete),
2618 .help = "Do not delete cgroups after job completion",
2621 .category = FIO_OPT_C_GENERAL,
2622 .group = FIO_OPT_G_CGROUP,
2625 .name = "cgroup_weight",
2626 .lname = "Cgroup weight",
2627 .type = FIO_OPT_INT,
2628 .off1 = td_var_offset(cgroup_weight),
2629 .help = "Use given weight for cgroup",
2633 .category = FIO_OPT_C_GENERAL,
2634 .group = FIO_OPT_G_CGROUP,
2639 .type = FIO_OPT_INT,
2640 .off1 = td_var_offset(uid),
2641 .help = "Run job with this user ID",
2642 .category = FIO_OPT_C_GENERAL,
2643 .group = FIO_OPT_G_CRED,
2647 .lname = "Group ID",
2648 .type = FIO_OPT_INT,
2649 .off1 = td_var_offset(gid),
2650 .help = "Run job with this group ID",
2651 .category = FIO_OPT_C_GENERAL,
2652 .group = FIO_OPT_G_CRED,
2657 .type = FIO_OPT_INT,
2658 .off1 = td_var_offset(kb_base),
2659 .verify = kb_base_verify,
2662 .help = "How many bytes per KB for reporting (1000 or 1024)",
2663 .category = FIO_OPT_C_GENERAL,
2664 .group = FIO_OPT_G_INVALID,
2667 .name = "hugepage-size",
2668 .lname = "Hugepage size",
2669 .type = FIO_OPT_INT,
2670 .off1 = td_var_offset(hugepage_size),
2671 .help = "When using hugepages, specify size of each page",
2672 .def = __fio_stringify(FIO_HUGE_PAGE),
2673 .interval = 1024 * 1024,
2674 .category = FIO_OPT_C_GENERAL,
2675 .group = FIO_OPT_G_INVALID,
2679 .lname = "I/O flow ID",
2680 .type = FIO_OPT_INT,
2681 .off1 = td_var_offset(flow_id),
2682 .help = "The flow index ID to use",
2684 .category = FIO_OPT_C_IO,
2685 .group = FIO_OPT_G_IO_FLOW,
2689 .lname = "I/O flow weight",
2690 .type = FIO_OPT_INT,
2691 .off1 = td_var_offset(flow),
2692 .help = "Weight for flow control of this job",
2693 .parent = "flow_id",
2696 .category = FIO_OPT_C_IO,
2697 .group = FIO_OPT_G_IO_FLOW,
2700 .name = "flow_watermark",
2701 .lname = "I/O flow watermark",
2702 .type = FIO_OPT_INT,
2703 .off1 = td_var_offset(flow_watermark),
2704 .help = "High watermark for flow control. This option"
2705 " should be set to the same value for all threads"
2706 " with non-zero flow.",
2707 .parent = "flow_id",
2710 .category = FIO_OPT_C_IO,
2711 .group = FIO_OPT_G_IO_FLOW,
2714 .name = "flow_sleep",
2715 .lname = "I/O flow sleep",
2716 .type = FIO_OPT_INT,
2717 .off1 = td_var_offset(flow_sleep),
2718 .help = "How many microseconds to sleep after being held"
2719 " back by the flow control mechanism",
2720 .parent = "flow_id",
2723 .category = FIO_OPT_C_IO,
2724 .group = FIO_OPT_G_IO_FLOW,
2731 static void add_to_lopt(struct option *lopt, struct fio_option *o,
2732 const char *name, int val)
2734 lopt->name = (char *) name;
2736 if (o->type == FIO_OPT_STR_SET)
2737 lopt->has_arg = no_argument;
2739 lopt->has_arg = required_argument;
2742 static void options_to_lopts(struct fio_option *opts,
2743 struct option *long_options,
2744 int i, int option_type)
2746 struct fio_option *o = &opts[0];
2748 add_to_lopt(&long_options[i], o, o->name, option_type);
2751 add_to_lopt(&long_options[i], o, o->alias, option_type);
2756 assert(i < FIO_NR_OPTIONS);
2760 void fio_options_set_ioengine_opts(struct option *long_options,
2761 struct thread_data *td)
2766 while (long_options[i].name) {
2767 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
2768 memset(&long_options[i], 0, sizeof(*long_options));
2775 * Just clear out the prior ioengine options.
2780 options_to_lopts(td->io_ops->options, long_options, i,
2781 FIO_GETOPT_IOENGINE);
2784 void fio_options_dup_and_init(struct option *long_options)
2788 options_init(fio_options);
2791 while (long_options[i].name)
2794 options_to_lopts(fio_options, long_options, i, FIO_GETOPT_JOB);
2797 struct fio_keyword {
2803 static struct fio_keyword fio_keywords[] = {
2805 .word = "$pagesize",
2806 .desc = "Page size in the system",
2809 .word = "$mb_memory",
2810 .desc = "Megabytes of memory online",
2814 .desc = "Number of CPUs online in the system",
2821 void fio_keywords_init(void)
2823 unsigned long long mb_memory;
2827 sprintf(buf, "%lu", page_size);
2828 fio_keywords[0].replace = strdup(buf);
2830 mb_memory = os_phys_mem() / (1024 * 1024);
2831 sprintf(buf, "%llu", mb_memory);
2832 fio_keywords[1].replace = strdup(buf);
2835 sprintf(buf, "%lu", l);
2836 fio_keywords[2].replace = strdup(buf);
2841 static char *bc_calc(char *str)
2843 char buf[128], *tmp;
2848 * No math, just return string
2850 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
2851 !strchr(str, '/')) || strchr(str, '\''))
2855 * Split option from value, we only need to calculate the value
2857 tmp = strchr(str, '=');
2864 * Prevent buffer overflows; such a case isn't reasonable anyway
2866 if (strlen(str) >= 128 || strlen(tmp) > 100)
2869 sprintf(buf, "which %s > /dev/null", BC_APP);
2871 log_err("fio: bc is needed for performing math\n");
2875 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
2876 f = popen(buf, "r");
2880 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
2885 buf[(tmp - str) + ret - 1] = '\0';
2886 memcpy(buf, str, tmp - str);
2892 * Return a copy of the input string with substrings of the form ${VARNAME}
2893 * substituted with the value of the environment variable VARNAME. The
2894 * substitution always occurs, even if VARNAME is empty or the corresponding
2895 * environment variable undefined.
2897 static char *option_dup_subs(const char *opt)
2899 char out[OPT_LEN_MAX+1];
2900 char in[OPT_LEN_MAX+1];
2903 char *ch1, *ch2, *env;
2904 ssize_t nchr = OPT_LEN_MAX;
2907 if (strlen(opt) + 1 > OPT_LEN_MAX) {
2908 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
2912 in[OPT_LEN_MAX] = '\0';
2913 strncpy(in, opt, OPT_LEN_MAX);
2915 while (*inptr && nchr > 0) {
2916 if (inptr[0] == '$' && inptr[1] == '{') {
2917 ch2 = strchr(inptr, '}');
2918 if (ch2 && inptr+1 < ch2) {
2925 envlen = strlen(env);
2926 if (envlen <= nchr) {
2927 memcpy(outptr, env, envlen);
2937 *outptr++ = *inptr++;
2946 * Look for reserved variable names and replace them with real values
2948 static char *fio_keyword_replace(char *opt)
2954 for (i = 0; fio_keywords[i].word != NULL; i++) {
2955 struct fio_keyword *kw = &fio_keywords[i];
2957 while ((s = strstr(opt, kw->word)) != NULL) {
2958 char *new = malloc(strlen(opt) + 1);
2964 * Copy part of the string before the keyword and
2965 * sprintf() the replacement after it.
2967 memcpy(new, opt, olen);
2968 len = sprintf(new + olen, "%s", kw->replace);
2971 * If there's more in the original string, copy that
2974 opt += strlen(kw->word) + olen;
2976 memcpy(new + olen + len, opt, opt - o_org - 1);
2979 * replace opt and free the old opt
2989 * Check for potential math and invoke bc, if possible
2997 static char **dup_and_sub_options(char **opts, int num_opts)
3000 char **opts_copy = malloc(num_opts * sizeof(*opts));
3001 for (i = 0; i < num_opts; i++) {
3002 opts_copy[i] = option_dup_subs(opts[i]);
3005 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
3010 int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
3012 int i, ret, unknown;
3015 sort_options(opts, fio_options, num_opts);
3016 opts_copy = dup_and_sub_options(opts, num_opts);
3018 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
3019 struct fio_option *o;
3020 int newret = parse_option(opts_copy[i], opts[i], fio_options,
3029 opts_copy[i] = NULL;
3036 ret |= ioengine_load(td);
3038 sort_options(opts_copy, td->io_ops->options, num_opts);
3041 for (i = 0; i < num_opts; i++) {
3042 struct fio_option *o = NULL;
3048 newret = parse_option(opts_copy[i], opts[i],
3049 td->io_ops->options, &o,
3054 log_err("Bad option <%s>\n", opts[i]);
3057 opts_copy[i] = NULL;
3065 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
3067 return parse_cmd_option(opt, val, fio_options, td);
3070 int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
3073 return parse_cmd_option(opt, val, td->io_ops->options, td);
3076 void fio_fill_default_options(struct thread_data *td)
3078 fill_default_options(td, fio_options);
3081 int fio_show_option_help(const char *opt)
3083 return show_cmd_help(fio_options, opt);
3086 void options_mem_dupe(void *data, struct fio_option *options)
3088 struct fio_option *o;
3091 for (o = &options[0]; o->name; o++) {
3092 if (o->type != FIO_OPT_STR_STORE)
3095 ptr = td_var(data, o->off1);
3097 *ptr = strdup(*ptr);
3102 * dupe FIO_OPT_STR_STORE options
3104 void fio_options_mem_dupe(struct thread_data *td)
3106 options_mem_dupe(&td->o, fio_options);
3108 if (td->eo && td->io_ops) {
3109 void *oldeo = td->eo;
3111 td->eo = malloc(td->io_ops->option_struct_size);
3112 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
3113 options_mem_dupe(td->eo, td->io_ops->options);
3117 unsigned int fio_get_kb_base(void *data)
3119 struct thread_options *o = data;
3120 unsigned int kb_base = 0;
3123 kb_base = o->kb_base;
3130 int add_option(struct fio_option *o)
3132 struct fio_option *__o;
3141 memcpy(&fio_options[opt_index], o, sizeof(*o));
3145 void invalidate_profile_options(const char *prof_name)
3147 struct fio_option *o;
3151 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
3152 o->type = FIO_OPT_INVALID;
3153 o->prof_name = NULL;
3159 void add_opt_posval(const char *optname, const char *ival, const char *help)
3161 struct fio_option *o;
3164 o = find_option(fio_options, optname);
3168 for (i = 0; i < PARSE_MAX_VP; i++) {
3169 if (o->posval[i].ival)
3172 o->posval[i].ival = ival;
3173 o->posval[i].help = help;
3178 void del_opt_posval(const char *optname, const char *ival)
3180 struct fio_option *o;
3183 o = find_option(fio_options, optname);
3187 for (i = 0; i < PARSE_MAX_VP; i++) {
3188 if (!o->posval[i].ival)
3190 if (strcmp(o->posval[i].ival, ival))
3193 o->posval[i].ival = NULL;
3194 o->posval[i].help = NULL;
3198 void fio_options_free(struct thread_data *td)
3200 options_free(fio_options, td);
3201 if (td->eo && td->io_ops && td->io_ops->options) {
3202 options_free(td->io_ops->options, td->eo);
3208 struct fio_option *fio_option_find(const char *name)
3210 return find_option(fio_options, name);