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,
725 static struct opt_group *__opt_group_from_mask(struct opt_group *ogs, unsigned int *mask,
726 unsigned int inv_mask)
728 struct opt_group *og;
731 if (*mask == inv_mask || !*mask)
734 for (i = 0; ogs[i].name; i++) {
737 if (*mask & og->mask) {
738 *mask &= ~(og->mask);
746 struct opt_group *opt_group_from_mask(unsigned int *mask)
748 return __opt_group_from_mask(fio_opt_groups, mask, FIO_OPT_C_INVALID);
751 static struct opt_group fio_opt_cat_groups[] = {
754 .mask = FIO_OPT_G_RATE,
758 .mask = FIO_OPT_G_ZONE,
761 .name = "Read/write mix",
762 .mask = FIO_OPT_G_RWMIX,
766 .mask = FIO_OPT_G_VERIFY,
770 .mask = FIO_OPT_G_TRIM,
773 .name = "I/O Logging",
774 .mask = FIO_OPT_G_IOLOG,
778 .mask = FIO_OPT_G_IO_DEPTH,
782 .mask = FIO_OPT_G_IO_FLOW,
785 .name = "Description",
786 .mask = FIO_OPT_G_DESC,
790 .mask = FIO_OPT_G_FILENAME,
793 .name = "General I/O",
794 .mask = FIO_OPT_G_IO_BASIC,
798 .mask = FIO_OPT_G_CGROUP,
802 .mask = FIO_OPT_G_RUNTIME,
806 .mask = FIO_OPT_G_PROCESS,
809 .name = "Job credentials / priority",
810 .mask = FIO_OPT_G_CRED,
813 .name = "Clock settings",
814 .mask = FIO_OPT_G_CLOCK,
818 .mask = FIO_OPT_G_IO_TYPE,
821 .name = "I/O Thinktime",
822 .mask = FIO_OPT_G_THINKTIME,
825 .name = "Randomizations",
826 .mask = FIO_OPT_G_RANDOM,
829 .name = "I/O buffers",
830 .mask = FIO_OPT_G_IO_BUF,
837 struct opt_group *opt_group_cat_from_mask(unsigned int *mask)
839 return __opt_group_from_mask(fio_opt_cat_groups, mask, FIO_OPT_G_INVALID);
843 * Map of job/command line options
845 struct fio_option fio_options[FIO_MAX_OPTS] = {
847 .name = "description",
848 .lname = "Description of job",
849 .type = FIO_OPT_STR_STORE,
850 .off1 = td_var_offset(description),
851 .help = "Text job description",
852 .category = FIO_OPT_C_GENERAL,
853 .group = FIO_OPT_G_DESC,
858 .type = FIO_OPT_STR_STORE,
859 .off1 = td_var_offset(name),
860 .help = "Name of this job",
861 .category = FIO_OPT_C_GENERAL,
862 .group = FIO_OPT_G_DESC,
866 .lname = "Filename(s)",
867 .type = FIO_OPT_STR_STORE,
868 .off1 = td_var_offset(filename),
869 .cb = str_filename_cb,
870 .prio = -1, /* must come after "directory" */
871 .help = "File(s) to use for the workload",
872 .category = FIO_OPT_C_FILE,
873 .group = FIO_OPT_G_FILENAME,
877 .lname = "Directory",
878 .type = FIO_OPT_STR_STORE,
879 .off1 = td_var_offset(directory),
880 .cb = str_directory_cb,
881 .help = "Directory to store files in",
882 .category = FIO_OPT_C_FILE,
883 .group = FIO_OPT_G_FILENAME,
889 .cb = str_lockfile_cb,
890 .off1 = td_var_offset(file_lock_mode),
891 .help = "Lock file when doing IO to it",
892 .parent = "filename",
895 .category = FIO_OPT_C_FILE,
896 .group = FIO_OPT_G_FILENAME,
899 .oval = FILE_LOCK_NONE,
900 .help = "No file locking",
902 { .ival = "exclusive",
903 .oval = FILE_LOCK_EXCLUSIVE,
904 .help = "Exclusive file lock",
908 .oval = FILE_LOCK_READWRITE,
909 .help = "Read vs write lock",
915 .lname = "Open directory",
916 .type = FIO_OPT_STR_STORE,
917 .off1 = td_var_offset(opendir),
918 .cb = str_opendir_cb,
919 .help = "Recursively add files from this directory and down",
920 .category = FIO_OPT_C_FILE,
921 .group = FIO_OPT_G_FILENAME,
925 .lname = "Read/write",
926 .alias = "readwrite",
929 .off1 = td_var_offset(td_ddir),
930 .help = "IO direction",
933 .category = FIO_OPT_C_IO,
934 .group = FIO_OPT_G_IO_BASIC,
937 .oval = TD_DDIR_READ,
938 .help = "Sequential read",
941 .oval = TD_DDIR_WRITE,
942 .help = "Sequential write",
944 { .ival = "randread",
945 .oval = TD_DDIR_RANDREAD,
946 .help = "Random read",
948 { .ival = "randwrite",
949 .oval = TD_DDIR_RANDWRITE,
950 .help = "Random write",
954 .help = "Sequential read and write mix",
957 .oval = TD_DDIR_RANDRW,
958 .help = "Random read and write mix"
963 .name = "rw_sequencer",
964 .lname = "RW Sequencer",
966 .off1 = td_var_offset(rw_seq),
967 .help = "IO offset generator modifier",
969 .category = FIO_OPT_C_IO,
970 .group = FIO_OPT_G_IO_BASIC,
972 { .ival = "sequential",
974 .help = "Generate sequential offsets",
976 { .ival = "identical",
977 .oval = RW_SEQ_IDENT,
978 .help = "Generate identical offsets",
985 .lname = "IO Engine",
986 .type = FIO_OPT_STR_STORE,
987 .off1 = td_var_offset(ioengine),
988 .help = "IO engine to use",
989 .def = FIO_PREFERRED_ENGINE,
990 .category = FIO_OPT_C_IO,
991 .group = FIO_OPT_G_IO_BASIC,
994 .help = "Use read/write",
997 .help = "Use pread/pwrite",
1000 .help = "Use readv/writev",
1002 #ifdef FIO_HAVE_LIBAIO
1004 .help = "Linux native asynchronous IO",
1007 #ifdef FIO_HAVE_POSIXAIO
1008 { .ival = "posixaio",
1009 .help = "POSIX asynchronous IO",
1012 #ifdef FIO_HAVE_SOLARISAIO
1013 { .ival = "solarisaio",
1014 .help = "Solaris native asynchronous IO",
1017 #ifdef FIO_HAVE_WINDOWSAIO
1018 { .ival = "windowsaio",
1019 .help = "Windows native asynchronous IO"
1023 .help = "Memory mapped IO"
1025 #ifdef FIO_HAVE_SPLICE
1027 .help = "splice/vmsplice based IO",
1029 { .ival = "netsplice",
1030 .help = "splice/vmsplice to/from the network",
1033 #ifdef FIO_HAVE_SGIO
1035 .help = "SCSI generic v3 IO",
1039 .help = "Testing engine (no data transfer)",
1042 .help = "Network IO",
1044 #ifdef FIO_HAVE_SYSLET
1045 { .ival = "syslet-rw",
1046 .help = "syslet enabled async pread/pwrite IO",
1050 .help = "CPU cycle burner engine",
1052 #ifdef FIO_HAVE_GUASI
1054 .help = "GUASI IO engine",
1057 #ifdef FIO_HAVE_BINJECT
1058 { .ival = "binject",
1059 .help = "binject direct inject block engine",
1062 #ifdef FIO_HAVE_RDMA
1064 .help = "RDMA IO engine",
1067 { .ival = "external",
1068 .help = "Load external engine (append name)",
1074 .lname = "IO Depth",
1075 .type = FIO_OPT_INT,
1076 .off1 = td_var_offset(iodepth),
1077 .help = "Number of IO buffers to keep in flight",
1081 .category = FIO_OPT_C_IO,
1082 .group = FIO_OPT_G_IO_BASIC,
1085 .name = "iodepth_batch",
1086 .lname = "IO Depth batch",
1087 .alias = "iodepth_batch_submit",
1088 .type = FIO_OPT_INT,
1089 .off1 = td_var_offset(iodepth_batch),
1090 .help = "Number of IO buffers to submit in one go",
1091 .parent = "iodepth",
1096 .category = FIO_OPT_C_IO,
1097 .group = FIO_OPT_G_IO_BASIC,
1100 .name = "iodepth_batch_complete",
1101 .lname = "IO Depth batch complete",
1102 .type = FIO_OPT_INT,
1103 .off1 = td_var_offset(iodepth_batch_complete),
1104 .help = "Number of IO buffers to retrieve in one go",
1105 .parent = "iodepth",
1110 .category = FIO_OPT_C_IO,
1111 .group = FIO_OPT_G_IO_BASIC,
1114 .name = "iodepth_low",
1115 .lname = "IO Depth batch low",
1116 .type = FIO_OPT_INT,
1117 .off1 = td_var_offset(iodepth_low),
1118 .help = "Low water mark for queuing depth",
1119 .parent = "iodepth",
1122 .category = FIO_OPT_C_IO,
1123 .group = FIO_OPT_G_IO_BASIC,
1128 .type = FIO_OPT_STR_VAL,
1130 .help = "Total size of device or files",
1131 .interval = 1024 * 1024,
1132 .category = FIO_OPT_C_IO,
1133 .group = FIO_OPT_G_INVALID,
1136 .name = "fill_device",
1137 .lname = "Fill device",
1139 .type = FIO_OPT_BOOL,
1140 .off1 = td_var_offset(fill_device),
1141 .help = "Write until an ENOSPC error occurs",
1143 .category = FIO_OPT_C_FILE,
1144 .group = FIO_OPT_G_INVALID,
1148 .lname = "File size",
1149 .type = FIO_OPT_STR_VAL,
1150 .off1 = td_var_offset(file_size_low),
1151 .off2 = td_var_offset(file_size_high),
1153 .help = "Size of individual files",
1154 .interval = 1024 * 1024,
1155 .category = FIO_OPT_C_FILE,
1156 .group = FIO_OPT_G_INVALID,
1160 .lname = "IO offset",
1161 .alias = "fileoffset",
1162 .type = FIO_OPT_STR_VAL,
1163 .off1 = td_var_offset(start_offset),
1164 .help = "Start IO from this offset",
1166 .interval = 1024 * 1024,
1167 .category = FIO_OPT_C_IO,
1168 .group = FIO_OPT_G_INVALID,
1171 .name = "offset_increment",
1172 .lname = "IO offset increment",
1173 .type = FIO_OPT_STR_VAL,
1174 .off1 = td_var_offset(offset_increment),
1175 .help = "What is the increment from one offset to the next",
1179 .interval = 1024 * 1024,
1180 .category = FIO_OPT_C_IO,
1181 .group = FIO_OPT_G_INVALID,
1185 .lname = "Block size",
1186 .alias = "blocksize",
1187 .type = FIO_OPT_INT,
1188 .off1 = td_var_offset(bs[DDIR_READ]),
1189 .off2 = td_var_offset(bs[DDIR_WRITE]),
1191 .help = "Block size unit",
1196 .category = FIO_OPT_C_IO,
1197 .group = FIO_OPT_G_INVALID,
1201 .lname = "Block size align",
1202 .alias = "blockalign",
1203 .type = FIO_OPT_INT,
1204 .off1 = td_var_offset(ba[DDIR_READ]),
1205 .off2 = td_var_offset(ba[DDIR_WRITE]),
1207 .help = "IO block offset alignment",
1211 .category = FIO_OPT_C_IO,
1212 .group = FIO_OPT_G_INVALID,
1216 .lname = "Block size range",
1217 .alias = "blocksize_range",
1218 .type = FIO_OPT_RANGE,
1219 .off1 = td_var_offset(min_bs[DDIR_READ]),
1220 .off2 = td_var_offset(max_bs[DDIR_READ]),
1221 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
1222 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
1224 .help = "Set block size range (in more detail than bs)",
1228 .category = FIO_OPT_C_IO,
1229 .group = FIO_OPT_G_INVALID,
1233 .lname = "Block size split",
1234 .type = FIO_OPT_STR,
1235 .cb = str_bssplit_cb,
1236 .help = "Set a specific mix of block sizes",
1239 .category = FIO_OPT_C_IO,
1240 .group = FIO_OPT_G_INVALID,
1243 .name = "bs_unaligned",
1244 .lname = "Block size unaligned",
1245 .alias = "blocksize_unaligned",
1246 .type = FIO_OPT_STR_SET,
1247 .off1 = td_var_offset(bs_unaligned),
1248 .help = "Don't sector align IO buffer sizes",
1251 .category = FIO_OPT_C_IO,
1252 .group = FIO_OPT_G_INVALID,
1255 .name = "randrepeat",
1256 .lname = "Random repeatable",
1257 .type = FIO_OPT_BOOL,
1258 .off1 = td_var_offset(rand_repeatable),
1259 .help = "Use repeatable random IO pattern",
1263 .category = FIO_OPT_C_IO,
1264 .group = FIO_OPT_G_RANDOM,
1267 .name = "use_os_rand",
1268 .lname = "Use OS random",
1269 .type = FIO_OPT_BOOL,
1270 .off1 = td_var_offset(use_os_rand),
1271 .help = "Set to use OS random generator",
1275 .category = FIO_OPT_C_IO,
1276 .group = FIO_OPT_G_RANDOM,
1279 .name = "norandommap",
1280 .lname = "No randommap",
1281 .type = FIO_OPT_STR_SET,
1282 .off1 = td_var_offset(norandommap),
1283 .help = "Accept potential duplicate random blocks",
1287 .category = FIO_OPT_C_IO,
1288 .group = FIO_OPT_G_RANDOM,
1291 .name = "softrandommap",
1292 .lname = "Soft randommap",
1293 .type = FIO_OPT_BOOL,
1294 .off1 = td_var_offset(softrandommap),
1295 .help = "Set norandommap if randommap allocation fails",
1296 .parent = "norandommap",
1299 .category = FIO_OPT_C_IO,
1300 .group = FIO_OPT_G_RANDOM,
1304 .lname = "Number of files",
1305 .alias = "nr_files",
1306 .type = FIO_OPT_INT,
1307 .off1 = td_var_offset(nr_files),
1308 .help = "Split job workload between this number of files",
1311 .category = FIO_OPT_C_FILE,
1312 .group = FIO_OPT_G_INVALID,
1315 .name = "openfiles",
1316 .lname = "Number of open files",
1317 .type = FIO_OPT_INT,
1318 .off1 = td_var_offset(open_files),
1319 .help = "Number of files to keep open at the same time",
1320 .category = FIO_OPT_C_FILE,
1321 .group = FIO_OPT_G_INVALID,
1324 .name = "file_service_type",
1325 .lname = "File service type",
1326 .type = FIO_OPT_STR,
1328 .off1 = td_var_offset(file_service_type),
1329 .help = "How to select which file to service next",
1330 .def = "roundrobin",
1331 .category = FIO_OPT_C_FILE,
1332 .group = FIO_OPT_G_INVALID,
1335 .oval = FIO_FSERVICE_RANDOM,
1336 .help = "Choose a file at random",
1338 { .ival = "roundrobin",
1339 .oval = FIO_FSERVICE_RR,
1340 .help = "Round robin select files",
1342 { .ival = "sequential",
1343 .oval = FIO_FSERVICE_SEQ,
1344 .help = "Finish one file before moving to the next",
1347 .parent = "nrfiles",
1350 #ifdef FIO_HAVE_FALLOCATE
1352 .name = "fallocate",
1353 .lname = "Fallocate",
1354 .type = FIO_OPT_STR,
1355 .off1 = td_var_offset(fallocate_mode),
1356 .help = "Whether pre-allocation is performed when laying out files",
1358 .category = FIO_OPT_C_FILE,
1359 .group = FIO_OPT_G_INVALID,
1362 .oval = FIO_FALLOCATE_NONE,
1363 .help = "Do not pre-allocate space",
1366 .oval = FIO_FALLOCATE_POSIX,
1367 .help = "Use posix_fallocate()",
1369 #ifdef FIO_HAVE_LINUX_FALLOCATE
1371 .oval = FIO_FALLOCATE_KEEP_SIZE,
1372 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
1375 /* Compatibility with former boolean values */
1377 .oval = FIO_FALLOCATE_NONE,
1378 .help = "Alias for 'none'",
1381 .oval = FIO_FALLOCATE_POSIX,
1382 .help = "Alias for 'posix'",
1386 #endif /* FIO_HAVE_FALLOCATE */
1388 .name = "fadvise_hint",
1389 .lname = "Fadvise hint",
1390 .type = FIO_OPT_BOOL,
1391 .off1 = td_var_offset(fadvise_hint),
1392 .help = "Use fadvise() to advise the kernel on IO pattern",
1394 .category = FIO_OPT_C_FILE,
1395 .group = FIO_OPT_G_INVALID,
1400 .type = FIO_OPT_INT,
1401 .off1 = td_var_offset(fsync_blocks),
1402 .help = "Issue fsync for writes every given number of blocks",
1405 .category = FIO_OPT_C_FILE,
1406 .group = FIO_OPT_G_INVALID,
1409 .name = "fdatasync",
1410 .lname = "Fdatasync",
1411 .type = FIO_OPT_INT,
1412 .off1 = td_var_offset(fdatasync_blocks),
1413 .help = "Issue fdatasync for writes every given number of blocks",
1416 .category = FIO_OPT_C_FILE,
1417 .group = FIO_OPT_G_INVALID,
1420 .name = "write_barrier",
1421 .lname = "Write barrier",
1422 .type = FIO_OPT_INT,
1423 .off1 = td_var_offset(barrier_blocks),
1424 .help = "Make every Nth write a barrier write",
1427 .category = FIO_OPT_C_IO,
1428 .group = FIO_OPT_G_INVALID,
1430 #ifdef FIO_HAVE_SYNC_FILE_RANGE
1432 .name = "sync_file_range",
1433 .lname = "Sync file range",
1435 { .ival = "wait_before",
1436 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
1437 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
1441 .oval = SYNC_FILE_RANGE_WRITE,
1442 .help = "SYNC_FILE_RANGE_WRITE",
1446 .ival = "wait_after",
1447 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
1448 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
1452 .type = FIO_OPT_STR_MULTI,
1454 .off1 = td_var_offset(sync_file_range),
1455 .help = "Use sync_file_range()",
1456 .category = FIO_OPT_C_FILE,
1457 .group = FIO_OPT_G_INVALID,
1462 .lname = "Direct I/O",
1463 .type = FIO_OPT_BOOL,
1464 .off1 = td_var_offset(odirect),
1465 .help = "Use O_DIRECT IO (negates buffered)",
1467 .inverse = "buffered",
1468 .category = FIO_OPT_C_IO,
1469 .group = FIO_OPT_G_IO_TYPE,
1473 .lname = "Buffered I/O",
1474 .type = FIO_OPT_BOOL,
1475 .off1 = td_var_offset(odirect),
1477 .help = "Use buffered IO (negates direct)",
1479 .inverse = "direct",
1480 .category = FIO_OPT_C_IO,
1481 .group = FIO_OPT_G_IO_TYPE,
1484 .name = "overwrite",
1485 .lname = "Overwrite",
1486 .type = FIO_OPT_BOOL,
1487 .off1 = td_var_offset(overwrite),
1488 .help = "When writing, set whether to overwrite current data",
1490 .category = FIO_OPT_C_FILE,
1491 .group = FIO_OPT_G_INVALID,
1496 .type = FIO_OPT_INT,
1497 .off1 = td_var_offset(loops),
1498 .help = "Number of times to run the job",
1501 .category = FIO_OPT_C_GENERAL,
1502 .group = FIO_OPT_G_RUNTIME,
1506 .lname = "Number of jobs",
1507 .type = FIO_OPT_INT,
1508 .off1 = td_var_offset(numjobs),
1509 .help = "Duplicate this job this many times",
1512 .category = FIO_OPT_C_GENERAL,
1513 .group = FIO_OPT_G_RUNTIME,
1516 .name = "startdelay",
1517 .lname = "Start delay",
1518 .type = FIO_OPT_STR_VAL_TIME,
1519 .off1 = td_var_offset(start_delay),
1520 .help = "Only start job when this period has passed",
1522 .category = FIO_OPT_C_GENERAL,
1523 .group = FIO_OPT_G_RUNTIME,
1529 .type = FIO_OPT_STR_VAL_TIME,
1530 .off1 = td_var_offset(timeout),
1531 .help = "Stop workload when this amount of time has passed",
1533 .category = FIO_OPT_C_GENERAL,
1534 .group = FIO_OPT_G_RUNTIME,
1537 .name = "time_based",
1538 .lname = "Time based",
1539 .type = FIO_OPT_STR_SET,
1540 .off1 = td_var_offset(time_based),
1541 .help = "Keep running until runtime/timeout is met",
1542 .category = FIO_OPT_C_GENERAL,
1543 .group = FIO_OPT_G_RUNTIME,
1546 .name = "ramp_time",
1547 .lname = "Ramp time",
1548 .type = FIO_OPT_STR_VAL_TIME,
1549 .off1 = td_var_offset(ramp_time),
1550 .help = "Ramp up time before measuring performance",
1551 .category = FIO_OPT_C_GENERAL,
1552 .group = FIO_OPT_G_RUNTIME,
1555 .name = "clocksource",
1556 .lname = "Clock source",
1557 .type = FIO_OPT_STR,
1558 .cb = fio_clock_source_cb,
1559 .off1 = td_var_offset(clocksource),
1560 .help = "What type of timing source to use",
1561 .category = FIO_OPT_C_GENERAL,
1562 .group = FIO_OPT_G_CLOCK,
1564 { .ival = "gettimeofday",
1566 .help = "Use gettimeofday(2) for timing",
1568 { .ival = "clock_gettime",
1569 .oval = CS_CGETTIME,
1570 .help = "Use clock_gettime(2) for timing",
1572 #ifdef ARCH_HAVE_CPU_CLOCK
1574 .oval = CS_CPUCLOCK,
1575 .help = "Use CPU private clock",
1583 .lname = "I/O Memory",
1584 .type = FIO_OPT_STR,
1586 .off1 = td_var_offset(mem_type),
1587 .help = "Backing type for IO buffers",
1589 .category = FIO_OPT_C_IO,
1590 .group = FIO_OPT_G_INVALID,
1594 .help = "Use malloc(3) for IO buffers",
1598 .help = "Use shared memory segments for IO buffers",
1600 #ifdef FIO_HAVE_HUGETLB
1601 { .ival = "shmhuge",
1602 .oval = MEM_SHMHUGE,
1603 .help = "Like shm, but use huge pages",
1608 .help = "Use mmap(2) (file or anon) for IO buffers",
1610 #ifdef FIO_HAVE_HUGETLB
1611 { .ival = "mmaphuge",
1612 .oval = MEM_MMAPHUGE,
1613 .help = "Like mmap, but use huge pages",
1619 .name = "iomem_align",
1620 .alias = "mem_align",
1621 .lname = "I/O memory alignment",
1622 .type = FIO_OPT_INT,
1623 .off1 = td_var_offset(mem_align),
1625 .help = "IO memory buffer offset alignment",
1629 .category = FIO_OPT_C_IO,
1630 .group = FIO_OPT_G_INVALID,
1635 .type = FIO_OPT_STR,
1636 .off1 = td_var_offset(verify),
1637 .help = "Verify data written",
1639 .category = FIO_OPT_C_IO,
1640 .group = FIO_OPT_G_VERIFY,
1643 .oval = VERIFY_NONE,
1644 .help = "Don't do IO verification",
1648 .help = "Use md5 checksums for verification",
1651 .oval = VERIFY_CRC64,
1652 .help = "Use crc64 checksums for verification",
1655 .oval = VERIFY_CRC32,
1656 .help = "Use crc32 checksums for verification",
1658 { .ival = "crc32c-intel",
1659 .oval = VERIFY_CRC32C,
1660 .help = "Use crc32c checksums for verification (hw assisted, if available)",
1663 .oval = VERIFY_CRC32C,
1664 .help = "Use crc32c checksums for verification (hw assisted, if available)",
1667 .oval = VERIFY_CRC16,
1668 .help = "Use crc16 checksums for verification",
1671 .oval = VERIFY_CRC7,
1672 .help = "Use crc7 checksums for verification",
1675 .oval = VERIFY_SHA1,
1676 .help = "Use sha1 checksums for verification",
1679 .oval = VERIFY_SHA256,
1680 .help = "Use sha256 checksums for verification",
1683 .oval = VERIFY_SHA512,
1684 .help = "Use sha512 checksums for verification",
1687 .oval = VERIFY_META,
1688 .help = "Use io information",
1692 .oval = VERIFY_NULL,
1693 .help = "Pretend to verify",
1698 .name = "do_verify",
1699 .lname = "Perform verify step",
1700 .type = FIO_OPT_BOOL,
1701 .off1 = td_var_offset(do_verify),
1702 .help = "Run verification stage after write",
1706 .category = FIO_OPT_C_IO,
1707 .group = FIO_OPT_G_VERIFY,
1710 .name = "verifysort",
1711 .lname = "Verify sort",
1712 .type = FIO_OPT_BOOL,
1713 .off1 = td_var_offset(verifysort),
1714 .help = "Sort written verify blocks for read back",
1718 .category = FIO_OPT_C_IO,
1719 .group = FIO_OPT_G_VERIFY,
1722 .name = "verify_interval",
1723 .lname = "Verify interval",
1724 .type = FIO_OPT_INT,
1725 .off1 = td_var_offset(verify_interval),
1726 .minval = 2 * sizeof(struct verify_header),
1727 .help = "Store verify buffer header every N bytes",
1730 .interval = 2 * sizeof(struct verify_header),
1731 .category = FIO_OPT_C_IO,
1732 .group = FIO_OPT_G_VERIFY,
1735 .name = "verify_offset",
1736 .lname = "Verify offset",
1737 .type = FIO_OPT_INT,
1738 .help = "Offset verify header location by N bytes",
1739 .off1 = td_var_offset(verify_offset),
1740 .minval = sizeof(struct verify_header),
1743 .category = FIO_OPT_C_IO,
1744 .group = FIO_OPT_G_VERIFY,
1747 .name = "verify_pattern",
1748 .lname = "Verify pattern",
1749 .type = FIO_OPT_STR,
1750 .cb = str_verify_pattern_cb,
1751 .help = "Fill pattern for IO buffers",
1754 .category = FIO_OPT_C_IO,
1755 .group = FIO_OPT_G_VERIFY,
1758 .name = "verify_fatal",
1759 .lname = "Verify fatal",
1760 .type = FIO_OPT_BOOL,
1761 .off1 = td_var_offset(verify_fatal),
1763 .help = "Exit on a single verify failure, don't continue",
1766 .category = FIO_OPT_C_IO,
1767 .group = FIO_OPT_G_VERIFY,
1770 .name = "verify_dump",
1771 .lname = "Verify dump",
1772 .type = FIO_OPT_BOOL,
1773 .off1 = td_var_offset(verify_dump),
1775 .help = "Dump contents of good and bad blocks on failure",
1778 .category = FIO_OPT_C_IO,
1779 .group = FIO_OPT_G_VERIFY,
1782 .name = "verify_async",
1783 .lname = "Verify asynchronously",
1784 .type = FIO_OPT_INT,
1785 .off1 = td_var_offset(verify_async),
1787 .help = "Number of async verifier threads to use",
1790 .category = FIO_OPT_C_IO,
1791 .group = FIO_OPT_G_VERIFY,
1794 .name = "verify_backlog",
1795 .lname = "Verify backlog",
1796 .type = FIO_OPT_STR_VAL,
1797 .off1 = td_var_offset(verify_backlog),
1798 .help = "Verify after this number of blocks are written",
1801 .category = FIO_OPT_C_IO,
1802 .group = FIO_OPT_G_VERIFY,
1805 .name = "verify_backlog_batch",
1806 .lname = "Verify backlog batch",
1807 .type = FIO_OPT_INT,
1808 .off1 = td_var_offset(verify_batch),
1809 .help = "Verify this number of IO blocks",
1812 .category = FIO_OPT_C_IO,
1813 .group = FIO_OPT_G_VERIFY,
1815 #ifdef FIO_HAVE_CPU_AFFINITY
1817 .name = "verify_async_cpus",
1818 .lname = "Async verify CPUs",
1819 .type = FIO_OPT_STR,
1820 .cb = str_verify_cpus_allowed_cb,
1821 .help = "Set CPUs allowed for async verify threads",
1822 .parent = "verify_async",
1824 .category = FIO_OPT_C_IO,
1825 .group = FIO_OPT_G_VERIFY,
1828 #ifdef FIO_HAVE_TRIM
1830 .name = "trim_percentage",
1831 .lname = "Trim percentage",
1832 .type = FIO_OPT_INT,
1833 .off1 = td_var_offset(trim_percentage),
1836 .help = "Number of verify blocks to discard/trim",
1841 .category = FIO_OPT_C_IO,
1842 .group = FIO_OPT_G_TRIM,
1845 .name = "trim_verify_zero",
1846 .lname = "Verify trim zero",
1847 .type = FIO_OPT_BOOL,
1848 .help = "Verify that trim/discarded blocks are returned as zeroes",
1849 .off1 = td_var_offset(trim_zero),
1850 .parent = "trim_percentage",
1853 .category = FIO_OPT_C_IO,
1854 .group = FIO_OPT_G_TRIM,
1857 .name = "trim_backlog",
1858 .lname = "Trim backlog",
1859 .type = FIO_OPT_STR_VAL,
1860 .off1 = td_var_offset(trim_backlog),
1861 .help = "Trim after this number of blocks are written",
1862 .parent = "trim_percentage",
1865 .category = FIO_OPT_C_IO,
1866 .group = FIO_OPT_G_TRIM,
1869 .name = "trim_backlog_batch",
1870 .lname = "Trim backlog batch",
1871 .type = FIO_OPT_INT,
1872 .off1 = td_var_offset(trim_batch),
1873 .help = "Trim this number of IO blocks",
1874 .parent = "trim_percentage",
1877 .category = FIO_OPT_C_IO,
1878 .group = FIO_OPT_G_TRIM,
1882 .name = "write_iolog",
1883 .lname = "Write I/O log",
1884 .type = FIO_OPT_STR_STORE,
1885 .off1 = td_var_offset(write_iolog_file),
1886 .help = "Store IO pattern to file",
1887 .category = FIO_OPT_C_IO,
1888 .group = FIO_OPT_G_IOLOG,
1891 .name = "read_iolog",
1892 .lname = "Read I/O log",
1893 .type = FIO_OPT_STR_STORE,
1894 .off1 = td_var_offset(read_iolog_file),
1895 .help = "Playback IO pattern from file",
1896 .category = FIO_OPT_C_IO,
1897 .group = FIO_OPT_G_IOLOG,
1900 .name = "replay_no_stall",
1901 .lname = "Don't stall on replay",
1902 .type = FIO_OPT_BOOL,
1903 .off1 = td_var_offset(no_stall),
1905 .parent = "read_iolog",
1907 .help = "Playback IO pattern file as fast as possible without stalls",
1908 .category = FIO_OPT_C_IO,
1909 .group = FIO_OPT_G_IOLOG,
1912 .name = "replay_redirect",
1913 .lname = "Redirect device for replay",
1914 .type = FIO_OPT_STR_STORE,
1915 .off1 = td_var_offset(replay_redirect),
1916 .parent = "read_iolog",
1918 .help = "Replay all I/O onto this device, regardless of trace device",
1919 .category = FIO_OPT_C_IO,
1920 .group = FIO_OPT_G_IOLOG,
1923 .name = "exec_prerun",
1924 .lname = "Pre-execute runnable",
1925 .type = FIO_OPT_STR_STORE,
1926 .off1 = td_var_offset(exec_prerun),
1927 .help = "Execute this file prior to running job",
1928 .category = FIO_OPT_C_GENERAL,
1929 .group = FIO_OPT_G_INVALID,
1932 .name = "exec_postrun",
1933 .lname = "Post-execute runnable",
1934 .type = FIO_OPT_STR_STORE,
1935 .off1 = td_var_offset(exec_postrun),
1936 .help = "Execute this file after running job",
1937 .category = FIO_OPT_C_GENERAL,
1938 .group = FIO_OPT_G_INVALID,
1940 #ifdef FIO_HAVE_IOSCHED_SWITCH
1942 .name = "ioscheduler",
1943 .lname = "I/O scheduler",
1944 .type = FIO_OPT_STR_STORE,
1945 .off1 = td_var_offset(ioscheduler),
1946 .help = "Use this IO scheduler on the backing device",
1947 .category = FIO_OPT_C_FILE,
1948 .group = FIO_OPT_G_INVALID,
1953 .lname = "Zone size",
1954 .type = FIO_OPT_STR_VAL,
1955 .off1 = td_var_offset(zone_size),
1956 .help = "Amount of data to read per zone",
1958 .interval = 1024 * 1024,
1959 .category = FIO_OPT_C_IO,
1960 .group = FIO_OPT_G_ZONE,
1963 .name = "zonerange",
1964 .lname = "Zone range",
1965 .type = FIO_OPT_STR_VAL,
1966 .off1 = td_var_offset(zone_range),
1967 .help = "Give size of an IO zone",
1969 .interval = 1024 * 1024,
1970 .category = FIO_OPT_C_IO,
1971 .group = FIO_OPT_G_ZONE,
1975 .lname = "Zone skip",
1976 .type = FIO_OPT_STR_VAL,
1977 .off1 = td_var_offset(zone_skip),
1978 .help = "Space between IO zones",
1980 .interval = 1024 * 1024,
1981 .category = FIO_OPT_C_IO,
1982 .group = FIO_OPT_G_ZONE,
1986 .lname = "Lock memory",
1987 .type = FIO_OPT_STR_VAL,
1988 .off1 = td_var_offset(lockmem),
1989 .help = "Lock down this amount of memory",
1991 .interval = 1024 * 1024,
1992 .category = FIO_OPT_C_GENERAL,
1993 .group = FIO_OPT_G_INVALID,
1996 .name = "rwmixread",
1997 .lname = "Read/write mix read",
1998 .type = FIO_OPT_INT,
1999 .cb = str_rwmix_read_cb,
2001 .help = "Percentage of mixed workload that is reads",
2004 .inverse = "rwmixwrite",
2005 .category = FIO_OPT_C_IO,
2006 .group = FIO_OPT_G_RWMIX,
2009 .name = "rwmixwrite",
2010 .lname = "Read/write mix write",
2011 .type = FIO_OPT_INT,
2012 .cb = str_rwmix_write_cb,
2014 .help = "Percentage of mixed workload that is writes",
2017 .inverse = "rwmixread",
2018 .category = FIO_OPT_C_IO,
2019 .group = FIO_OPT_G_RWMIX,
2022 .name = "rwmixcycle",
2023 .lname = "Read/write mix cycle",
2024 .type = FIO_OPT_DEPRECATED,
2025 .category = FIO_OPT_C_IO,
2026 .group = FIO_OPT_G_RWMIX,
2031 .type = FIO_OPT_INT,
2032 .off1 = td_var_offset(nice),
2033 .help = "Set job CPU nice value",
2038 .category = FIO_OPT_C_GENERAL,
2039 .group = FIO_OPT_G_CRED,
2041 #ifdef FIO_HAVE_IOPRIO
2044 .lname = "I/O nice priority",
2045 .type = FIO_OPT_INT,
2046 .off1 = td_var_offset(ioprio),
2047 .help = "Set job IO priority value",
2051 .category = FIO_OPT_C_GENERAL,
2052 .group = FIO_OPT_G_CRED,
2055 .name = "prioclass",
2056 .lname = "I/O nice priority class",
2057 .type = FIO_OPT_INT,
2058 .off1 = td_var_offset(ioprio_class),
2059 .help = "Set job IO priority class",
2063 .category = FIO_OPT_C_GENERAL,
2064 .group = FIO_OPT_G_CRED,
2068 .name = "thinktime",
2069 .lname = "Thinktime",
2070 .type = FIO_OPT_INT,
2071 .off1 = td_var_offset(thinktime),
2072 .help = "Idle time between IO buffers (usec)",
2074 .category = FIO_OPT_C_IO,
2075 .group = FIO_OPT_G_THINKTIME,
2078 .name = "thinktime_spin",
2079 .lname = "Thinktime spin",
2080 .type = FIO_OPT_INT,
2081 .off1 = td_var_offset(thinktime_spin),
2082 .help = "Start think time by spinning this amount (usec)",
2084 .parent = "thinktime",
2086 .category = FIO_OPT_C_IO,
2087 .group = FIO_OPT_G_THINKTIME,
2090 .name = "thinktime_blocks",
2091 .lname = "Thinktime blocks",
2092 .type = FIO_OPT_INT,
2093 .off1 = td_var_offset(thinktime_blocks),
2094 .help = "IO buffer period between 'thinktime'",
2096 .parent = "thinktime",
2098 .category = FIO_OPT_C_IO,
2099 .group = FIO_OPT_G_THINKTIME,
2103 .lname = "I/O rate",
2104 .type = FIO_OPT_INT,
2105 .off1 = td_var_offset(rate[0]),
2106 .off2 = td_var_offset(rate[1]),
2107 .help = "Set bandwidth rate",
2108 .category = FIO_OPT_C_IO,
2109 .group = FIO_OPT_G_RATE,
2113 .lname = "I/O min rate",
2114 .type = FIO_OPT_INT,
2115 .off1 = td_var_offset(ratemin[0]),
2116 .off2 = td_var_offset(ratemin[1]),
2117 .help = "Job must meet this rate or it will be shutdown",
2120 .category = FIO_OPT_C_IO,
2121 .group = FIO_OPT_G_RATE,
2124 .name = "rate_iops",
2125 .lname = "I/O rate IOPS",
2126 .type = FIO_OPT_INT,
2127 .off1 = td_var_offset(rate_iops[0]),
2128 .off2 = td_var_offset(rate_iops[1]),
2129 .help = "Limit IO used to this number of IO operations/sec",
2131 .category = FIO_OPT_C_IO,
2132 .group = FIO_OPT_G_RATE,
2135 .name = "rate_iops_min",
2136 .lname = "I/O min rate IOPS",
2137 .type = FIO_OPT_INT,
2138 .off1 = td_var_offset(rate_iops_min[0]),
2139 .off2 = td_var_offset(rate_iops_min[1]),
2140 .help = "Job must meet this rate or it will be shut down",
2141 .parent = "rate_iops",
2143 .category = FIO_OPT_C_IO,
2144 .group = FIO_OPT_G_RATE,
2147 .name = "ratecycle",
2148 .lname = "I/O rate cycle",
2149 .type = FIO_OPT_INT,
2150 .off1 = td_var_offset(ratecycle),
2151 .help = "Window average for rate limits (msec)",
2155 .category = FIO_OPT_C_IO,
2156 .group = FIO_OPT_G_RATE,
2159 .name = "invalidate",
2160 .lname = "Cache invalidate",
2161 .type = FIO_OPT_BOOL,
2162 .off1 = td_var_offset(invalidate_cache),
2163 .help = "Invalidate buffer/page cache prior to running job",
2165 .category = FIO_OPT_C_IO,
2166 .group = FIO_OPT_G_IO_TYPE,
2170 .lname = "Synchronous I/O",
2171 .type = FIO_OPT_BOOL,
2172 .off1 = td_var_offset(sync_io),
2173 .help = "Use O_SYNC for buffered writes",
2175 .parent = "buffered",
2177 .category = FIO_OPT_C_IO,
2178 .group = FIO_OPT_G_IO_TYPE,
2181 .name = "create_serialize",
2182 .lname = "Create serialize",
2183 .type = FIO_OPT_BOOL,
2184 .off1 = td_var_offset(create_serialize),
2185 .help = "Serialize creating of job files",
2187 .category = FIO_OPT_C_FILE,
2188 .group = FIO_OPT_G_INVALID,
2191 .name = "create_fsync",
2192 .lname = "Create fsync",
2193 .type = FIO_OPT_BOOL,
2194 .off1 = td_var_offset(create_fsync),
2195 .help = "fsync file after creation",
2197 .category = FIO_OPT_C_FILE,
2198 .group = FIO_OPT_G_INVALID,
2201 .name = "create_on_open",
2202 .lname = "Create on open",
2203 .type = FIO_OPT_BOOL,
2204 .off1 = td_var_offset(create_on_open),
2205 .help = "Create files when they are opened for IO",
2207 .category = FIO_OPT_C_FILE,
2208 .group = FIO_OPT_G_INVALID,
2212 .lname = "Pre-read files",
2213 .type = FIO_OPT_BOOL,
2214 .off1 = td_var_offset(pre_read),
2215 .help = "Pre-read files before starting official testing",
2217 .category = FIO_OPT_C_FILE,
2218 .group = FIO_OPT_G_INVALID,
2220 #ifdef FIO_HAVE_CPU_AFFINITY
2223 .lname = "CPU mask",
2224 .type = FIO_OPT_INT,
2225 .cb = str_cpumask_cb,
2226 .help = "CPU affinity mask",
2227 .category = FIO_OPT_C_GENERAL,
2228 .group = FIO_OPT_G_CRED,
2231 .name = "cpus_allowed",
2232 .lname = "CPUs allowed",
2233 .type = FIO_OPT_STR,
2234 .cb = str_cpus_allowed_cb,
2235 .help = "Set CPUs allowed",
2236 .category = FIO_OPT_C_GENERAL,
2237 .group = FIO_OPT_G_CRED,
2241 .name = "end_fsync",
2242 .lname = "End fsync",
2243 .type = FIO_OPT_BOOL,
2244 .off1 = td_var_offset(end_fsync),
2245 .help = "Include fsync at the end of job",
2247 .category = FIO_OPT_C_FILE,
2248 .group = FIO_OPT_G_INVALID,
2251 .name = "fsync_on_close",
2252 .lname = "Fsync on close",
2253 .type = FIO_OPT_BOOL,
2254 .off1 = td_var_offset(fsync_on_close),
2255 .help = "fsync files on close",
2257 .category = FIO_OPT_C_FILE,
2258 .group = FIO_OPT_G_INVALID,
2262 .lname = "Unlink file",
2263 .type = FIO_OPT_BOOL,
2264 .off1 = td_var_offset(unlink),
2265 .help = "Unlink created files after job has completed",
2267 .category = FIO_OPT_C_FILE,
2268 .group = FIO_OPT_G_INVALID,
2272 .lname = "Exit-all on terminate",
2273 .type = FIO_OPT_STR_SET,
2274 .cb = str_exitall_cb,
2275 .help = "Terminate all jobs when one exits",
2276 .category = FIO_OPT_C_GENERAL,
2277 .group = FIO_OPT_G_PROCESS,
2280 .name = "stonewall",
2281 .lname = "Wait for previous",
2282 .alias = "wait_for_previous",
2283 .type = FIO_OPT_STR_SET,
2284 .off1 = td_var_offset(stonewall),
2285 .help = "Insert a hard barrier between this job and previous",
2286 .category = FIO_OPT_C_GENERAL,
2287 .group = FIO_OPT_G_PROCESS,
2290 .name = "new_group",
2291 .lname = "New group",
2292 .type = FIO_OPT_STR_SET,
2293 .off1 = td_var_offset(new_group),
2294 .help = "Mark the start of a new group (for reporting)",
2295 .category = FIO_OPT_C_GENERAL,
2296 .group = FIO_OPT_G_PROCESS,
2301 .type = FIO_OPT_STR_SET,
2302 .off1 = td_var_offset(use_thread),
2303 .help = "Use threads instead of processes",
2304 .category = FIO_OPT_C_GENERAL,
2305 .group = FIO_OPT_G_PROCESS,
2308 .name = "write_bw_log",
2309 .lname = "Write bandwidth log",
2310 .type = FIO_OPT_STR_STORE,
2311 .off1 = td_var_offset(bw_log_file),
2312 .help = "Write log of bandwidth during run",
2313 .category = FIO_OPT_C_LOG,
2314 .group = FIO_OPT_G_INVALID,
2317 .name = "write_lat_log",
2318 .lname = "Write latency log",
2319 .type = FIO_OPT_STR_STORE,
2320 .off1 = td_var_offset(lat_log_file),
2321 .help = "Write log of latency during run",
2322 .category = FIO_OPT_C_LOG,
2323 .group = FIO_OPT_G_INVALID,
2326 .name = "write_iops_log",
2327 .lname = "Write IOPS log",
2328 .type = FIO_OPT_STR,
2329 .off1 = td_var_offset(iops_log_file),
2330 .help = "Write log of IOPS during run",
2331 .category = FIO_OPT_C_LOG,
2332 .group = FIO_OPT_G_INVALID,
2335 .name = "log_avg_msec",
2336 .lname = "Log averaging (msec)",
2337 .type = FIO_OPT_INT,
2338 .off1 = td_var_offset(log_avg_msec),
2339 .help = "Average bw/iops/lat logs over this period of time",
2341 .category = FIO_OPT_C_LOG,
2342 .group = FIO_OPT_G_INVALID,
2345 .name = "bwavgtime",
2346 .lname = "Bandwidth average time",
2347 .type = FIO_OPT_INT,
2348 .off1 = td_var_offset(bw_avg_time),
2349 .help = "Time window over which to calculate bandwidth"
2352 .parent = "write_bw_log",
2355 .category = FIO_OPT_C_LOG,
2356 .group = FIO_OPT_G_INVALID,
2359 .name = "iopsavgtime",
2360 .lname = "IOPS average time",
2361 .type = FIO_OPT_INT,
2362 .off1 = td_var_offset(iops_avg_time),
2363 .help = "Time window over which to calculate IOPS (msec)",
2365 .parent = "write_iops_log",
2368 .category = FIO_OPT_C_LOG,
2369 .group = FIO_OPT_G_INVALID,
2372 .name = "group_reporting",
2373 .lname = "Group reporting",
2374 .type = FIO_OPT_BOOL,
2375 .off1 = td_var_offset(group_reporting),
2376 .help = "Do reporting on a per-group basis",
2378 .category = FIO_OPT_C_STAT,
2379 .group = FIO_OPT_G_INVALID,
2382 .name = "zero_buffers",
2383 .lname = "Zero I/O buffers",
2384 .type = FIO_OPT_STR_SET,
2385 .off1 = td_var_offset(zero_buffers),
2386 .help = "Init IO buffers to all zeroes",
2387 .category = FIO_OPT_C_IO,
2388 .group = FIO_OPT_G_IO_BUF,
2391 .name = "refill_buffers",
2392 .lname = "Refill I/O buffers",
2393 .type = FIO_OPT_STR_SET,
2394 .off1 = td_var_offset(refill_buffers),
2395 .help = "Refill IO buffers on every IO submit",
2396 .category = FIO_OPT_C_IO,
2397 .group = FIO_OPT_G_IO_BUF,
2400 .name = "scramble_buffers",
2401 .lname = "Scramble I/O buffers",
2402 .type = FIO_OPT_BOOL,
2403 .off1 = td_var_offset(scramble_buffers),
2404 .help = "Slightly scramble buffers on every IO submit",
2406 .category = FIO_OPT_C_IO,
2407 .group = FIO_OPT_G_IO_BUF,
2410 .name = "buffer_compress_percentage",
2411 .lname = "Buffer compression percentage",
2412 .type = FIO_OPT_INT,
2413 .off1 = td_var_offset(compress_percentage),
2416 .help = "How compressible the buffer is (approximately)",
2418 .category = FIO_OPT_C_IO,
2419 .group = FIO_OPT_G_IO_BUF,
2422 .name = "buffer_compress_chunk",
2423 .lname = "Buffer compression chunk size",
2424 .type = FIO_OPT_INT,
2425 .off1 = td_var_offset(compress_chunk),
2426 .parent = "buffer_compress_percentage",
2428 .help = "Size of compressible region in buffer",
2430 .category = FIO_OPT_C_IO,
2431 .group = FIO_OPT_G_IO_BUF,
2434 .name = "clat_percentiles",
2435 .lname = "Completion latency percentiles",
2436 .type = FIO_OPT_BOOL,
2437 .off1 = td_var_offset(clat_percentiles),
2438 .help = "Enable the reporting of completion latency percentiles",
2440 .category = FIO_OPT_C_STAT,
2441 .group = FIO_OPT_G_INVALID,
2444 .name = "percentile_list",
2445 .lname = "Completion latency percentile list",
2446 .type = FIO_OPT_FLOAT_LIST,
2447 .off1 = td_var_offset(percentile_list),
2448 .off2 = td_var_offset(overwrite_plist),
2449 .help = "Specify a custom list of percentiles to report",
2450 .maxlen = FIO_IO_U_LIST_MAX_LEN,
2453 .category = FIO_OPT_C_STAT,
2454 .group = FIO_OPT_G_INVALID,
2457 #ifdef FIO_HAVE_DISK_UTIL
2459 .name = "disk_util",
2460 .lname = "Disk utilization",
2461 .type = FIO_OPT_BOOL,
2462 .off1 = td_var_offset(do_disk_util),
2463 .help = "Log disk utilization statistics",
2465 .category = FIO_OPT_C_STAT,
2466 .group = FIO_OPT_G_INVALID,
2470 .name = "gtod_reduce",
2471 .lname = "Reduce gettimeofday() calls",
2472 .type = FIO_OPT_BOOL,
2473 .help = "Greatly reduce number of gettimeofday() calls",
2474 .cb = str_gtod_reduce_cb,
2477 .category = FIO_OPT_C_STAT,
2478 .group = FIO_OPT_G_INVALID,
2481 .name = "disable_lat",
2482 .lname = "Disable all latency stats",
2483 .type = FIO_OPT_BOOL,
2484 .off1 = td_var_offset(disable_lat),
2485 .help = "Disable latency numbers",
2486 .parent = "gtod_reduce",
2489 .category = FIO_OPT_C_STAT,
2490 .group = FIO_OPT_G_INVALID,
2493 .name = "disable_clat",
2494 .lname = "Disable completion latency stats",
2495 .type = FIO_OPT_BOOL,
2496 .off1 = td_var_offset(disable_clat),
2497 .help = "Disable completion latency numbers",
2498 .parent = "gtod_reduce",
2501 .category = FIO_OPT_C_STAT,
2502 .group = FIO_OPT_G_INVALID,
2505 .name = "disable_slat",
2506 .lname = "Disable submission latency stats",
2507 .type = FIO_OPT_BOOL,
2508 .off1 = td_var_offset(disable_slat),
2509 .help = "Disable submission latency numbers",
2510 .parent = "gtod_reduce",
2513 .category = FIO_OPT_C_STAT,
2514 .group = FIO_OPT_G_INVALID,
2517 .name = "disable_bw_measurement",
2518 .lname = "Disable bandwidth stats",
2519 .type = FIO_OPT_BOOL,
2520 .off1 = td_var_offset(disable_bw),
2521 .help = "Disable bandwidth logging",
2522 .parent = "gtod_reduce",
2525 .category = FIO_OPT_C_STAT,
2526 .group = FIO_OPT_G_INVALID,
2530 .lname = "Dedicated gettimeofday() CPU",
2531 .type = FIO_OPT_INT,
2532 .cb = str_gtod_cpu_cb,
2533 .help = "Set up dedicated gettimeofday() thread on this CPU",
2534 .verify = gtod_cpu_verify,
2535 .category = FIO_OPT_C_GENERAL,
2536 .group = FIO_OPT_G_CLOCK,
2539 .name = "continue_on_error",
2540 .lname = "Continue on error",
2541 .type = FIO_OPT_STR,
2542 .off1 = td_var_offset(continue_on_error),
2543 .help = "Continue on non-fatal errors during IO",
2545 .category = FIO_OPT_C_GENERAL,
2546 .group = FIO_OPT_G_INVALID,
2549 .oval = ERROR_TYPE_NONE,
2550 .help = "Exit when an error is encountered",
2553 .oval = ERROR_TYPE_READ,
2554 .help = "Continue on read errors only",
2557 .oval = ERROR_TYPE_WRITE,
2558 .help = "Continue on write errors only",
2561 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
2562 .help = "Continue on any IO errors",
2565 .oval = ERROR_TYPE_VERIFY,
2566 .help = "Continue on verify errors only",
2569 .oval = ERROR_TYPE_ANY,
2570 .help = "Continue on all io and verify errors",
2573 .oval = ERROR_TYPE_NONE,
2574 .help = "Alias for 'none'",
2577 .oval = ERROR_TYPE_ANY,
2578 .help = "Alias for 'all'",
2585 .type = FIO_OPT_STR_STORE,
2586 .off1 = td_var_offset(profile),
2587 .help = "Select a specific builtin performance test",
2588 .category = FIO_OPT_C_GENERAL,
2589 .group = FIO_OPT_G_INVALID,
2594 .type = FIO_OPT_STR_STORE,
2595 .off1 = td_var_offset(cgroup),
2596 .help = "Add job to cgroup of this name",
2597 .category = FIO_OPT_C_GENERAL,
2598 .group = FIO_OPT_G_CGROUP,
2601 .name = "cgroup_nodelete",
2602 .lname = "Cgroup no-delete",
2603 .type = FIO_OPT_BOOL,
2604 .off1 = td_var_offset(cgroup_nodelete),
2605 .help = "Do not delete cgroups after job completion",
2608 .category = FIO_OPT_C_GENERAL,
2609 .group = FIO_OPT_G_CGROUP,
2612 .name = "cgroup_weight",
2613 .lname = "Cgroup weight",
2614 .type = FIO_OPT_INT,
2615 .off1 = td_var_offset(cgroup_weight),
2616 .help = "Use given weight for cgroup",
2620 .category = FIO_OPT_C_GENERAL,
2621 .group = FIO_OPT_G_CGROUP,
2626 .type = FIO_OPT_INT,
2627 .off1 = td_var_offset(uid),
2628 .help = "Run job with this user ID",
2629 .category = FIO_OPT_C_GENERAL,
2630 .group = FIO_OPT_G_CRED,
2634 .lname = "Group ID",
2635 .type = FIO_OPT_INT,
2636 .off1 = td_var_offset(gid),
2637 .help = "Run job with this group ID",
2638 .category = FIO_OPT_C_GENERAL,
2639 .group = FIO_OPT_G_CRED,
2644 .type = FIO_OPT_INT,
2645 .off1 = td_var_offset(kb_base),
2646 .verify = kb_base_verify,
2649 .help = "How many bytes per KB for reporting (1000 or 1024)",
2650 .category = FIO_OPT_C_GENERAL,
2651 .group = FIO_OPT_G_INVALID,
2654 .name = "hugepage-size",
2655 .lname = "Hugepage size",
2656 .type = FIO_OPT_INT,
2657 .off1 = td_var_offset(hugepage_size),
2658 .help = "When using hugepages, specify size of each page",
2659 .def = __fio_stringify(FIO_HUGE_PAGE),
2660 .interval = 1024 * 1024,
2661 .category = FIO_OPT_C_GENERAL,
2662 .group = FIO_OPT_G_INVALID,
2666 .lname = "I/O flow ID",
2667 .type = FIO_OPT_INT,
2668 .off1 = td_var_offset(flow_id),
2669 .help = "The flow index ID to use",
2671 .category = FIO_OPT_C_IO,
2672 .group = FIO_OPT_G_IO_FLOW,
2676 .lname = "I/O flow weight",
2677 .type = FIO_OPT_INT,
2678 .off1 = td_var_offset(flow),
2679 .help = "Weight for flow control of this job",
2680 .parent = "flow_id",
2683 .category = FIO_OPT_C_IO,
2684 .group = FIO_OPT_G_IO_FLOW,
2687 .name = "flow_watermark",
2688 .lname = "I/O flow watermark",
2689 .type = FIO_OPT_INT,
2690 .off1 = td_var_offset(flow_watermark),
2691 .help = "High watermark for flow control. This option"
2692 " should be set to the same value for all threads"
2693 " with non-zero flow.",
2694 .parent = "flow_id",
2697 .category = FIO_OPT_C_IO,
2698 .group = FIO_OPT_G_IO_FLOW,
2701 .name = "flow_sleep",
2702 .lname = "I/O flow sleep",
2703 .type = FIO_OPT_INT,
2704 .off1 = td_var_offset(flow_sleep),
2705 .help = "How many microseconds to sleep after being held"
2706 " back by the flow control mechanism",
2707 .parent = "flow_id",
2710 .category = FIO_OPT_C_IO,
2711 .group = FIO_OPT_G_IO_FLOW,
2718 static void add_to_lopt(struct option *lopt, struct fio_option *o,
2719 const char *name, int val)
2721 lopt->name = (char *) name;
2723 if (o->type == FIO_OPT_STR_SET)
2724 lopt->has_arg = no_argument;
2726 lopt->has_arg = required_argument;
2729 static void options_to_lopts(struct fio_option *opts,
2730 struct option *long_options,
2731 int i, int option_type)
2733 struct fio_option *o = &opts[0];
2735 add_to_lopt(&long_options[i], o, o->name, option_type);
2738 add_to_lopt(&long_options[i], o, o->alias, option_type);
2743 assert(i < FIO_NR_OPTIONS);
2747 void fio_options_set_ioengine_opts(struct option *long_options,
2748 struct thread_data *td)
2753 while (long_options[i].name) {
2754 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
2755 memset(&long_options[i], 0, sizeof(*long_options));
2762 * Just clear out the prior ioengine options.
2767 options_to_lopts(td->io_ops->options, long_options, i,
2768 FIO_GETOPT_IOENGINE);
2771 void fio_options_dup_and_init(struct option *long_options)
2775 options_init(fio_options);
2778 while (long_options[i].name)
2781 options_to_lopts(fio_options, long_options, i, FIO_GETOPT_JOB);
2784 struct fio_keyword {
2790 static struct fio_keyword fio_keywords[] = {
2792 .word = "$pagesize",
2793 .desc = "Page size in the system",
2796 .word = "$mb_memory",
2797 .desc = "Megabytes of memory online",
2801 .desc = "Number of CPUs online in the system",
2808 void fio_keywords_init(void)
2810 unsigned long long mb_memory;
2814 sprintf(buf, "%lu", page_size);
2815 fio_keywords[0].replace = strdup(buf);
2817 mb_memory = os_phys_mem() / (1024 * 1024);
2818 sprintf(buf, "%llu", mb_memory);
2819 fio_keywords[1].replace = strdup(buf);
2822 sprintf(buf, "%lu", l);
2823 fio_keywords[2].replace = strdup(buf);
2828 static char *bc_calc(char *str)
2830 char buf[128], *tmp;
2835 * No math, just return string
2837 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
2838 !strchr(str, '/')) || strchr(str, '\''))
2842 * Split option from value, we only need to calculate the value
2844 tmp = strchr(str, '=');
2851 * Prevent buffer overflows; such a case isn't reasonable anyway
2853 if (strlen(str) >= 128 || strlen(tmp) > 100)
2856 sprintf(buf, "which %s > /dev/null", BC_APP);
2858 log_err("fio: bc is needed for performing math\n");
2862 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
2863 f = popen(buf, "r");
2867 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
2872 buf[(tmp - str) + ret - 1] = '\0';
2873 memcpy(buf, str, tmp - str);
2879 * Return a copy of the input string with substrings of the form ${VARNAME}
2880 * substituted with the value of the environment variable VARNAME. The
2881 * substitution always occurs, even if VARNAME is empty or the corresponding
2882 * environment variable undefined.
2884 static char *option_dup_subs(const char *opt)
2886 char out[OPT_LEN_MAX+1];
2887 char in[OPT_LEN_MAX+1];
2890 char *ch1, *ch2, *env;
2891 ssize_t nchr = OPT_LEN_MAX;
2894 if (strlen(opt) + 1 > OPT_LEN_MAX) {
2895 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
2899 in[OPT_LEN_MAX] = '\0';
2900 strncpy(in, opt, OPT_LEN_MAX);
2902 while (*inptr && nchr > 0) {
2903 if (inptr[0] == '$' && inptr[1] == '{') {
2904 ch2 = strchr(inptr, '}');
2905 if (ch2 && inptr+1 < ch2) {
2912 envlen = strlen(env);
2913 if (envlen <= nchr) {
2914 memcpy(outptr, env, envlen);
2924 *outptr++ = *inptr++;
2933 * Look for reserved variable names and replace them with real values
2935 static char *fio_keyword_replace(char *opt)
2941 for (i = 0; fio_keywords[i].word != NULL; i++) {
2942 struct fio_keyword *kw = &fio_keywords[i];
2944 while ((s = strstr(opt, kw->word)) != NULL) {
2945 char *new = malloc(strlen(opt) + 1);
2951 * Copy part of the string before the keyword and
2952 * sprintf() the replacement after it.
2954 memcpy(new, opt, olen);
2955 len = sprintf(new + olen, "%s", kw->replace);
2958 * If there's more in the original string, copy that
2961 opt += strlen(kw->word) + olen;
2963 memcpy(new + olen + len, opt, opt - o_org - 1);
2966 * replace opt and free the old opt
2976 * Check for potential math and invoke bc, if possible
2984 static char **dup_and_sub_options(char **opts, int num_opts)
2987 char **opts_copy = malloc(num_opts * sizeof(*opts));
2988 for (i = 0; i < num_opts; i++) {
2989 opts_copy[i] = option_dup_subs(opts[i]);
2992 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
2997 int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
2999 int i, ret, unknown;
3002 sort_options(opts, fio_options, num_opts);
3003 opts_copy = dup_and_sub_options(opts, num_opts);
3005 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
3006 struct fio_option *o;
3007 int newret = parse_option(opts_copy[i], opts[i], fio_options,
3016 opts_copy[i] = NULL;
3023 ret |= ioengine_load(td);
3025 sort_options(opts_copy, td->io_ops->options, num_opts);
3028 for (i = 0; i < num_opts; i++) {
3029 struct fio_option *o = NULL;
3035 newret = parse_option(opts_copy[i], opts[i],
3036 td->io_ops->options, &o,
3041 log_err("Bad option <%s>\n", opts[i]);
3044 opts_copy[i] = NULL;
3052 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
3054 return parse_cmd_option(opt, val, fio_options, td);
3057 int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
3060 return parse_cmd_option(opt, val, td->io_ops->options, td);
3063 void fio_fill_default_options(struct thread_data *td)
3065 fill_default_options(td, fio_options);
3068 int fio_show_option_help(const char *opt)
3070 return show_cmd_help(fio_options, opt);
3073 void options_mem_dupe(void *data, struct fio_option *options)
3075 struct fio_option *o;
3078 for (o = &options[0]; o->name; o++) {
3079 if (o->type != FIO_OPT_STR_STORE)
3082 ptr = td_var(data, o->off1);
3084 *ptr = strdup(*ptr);
3089 * dupe FIO_OPT_STR_STORE options
3091 void fio_options_mem_dupe(struct thread_data *td)
3093 options_mem_dupe(&td->o, fio_options);
3095 if (td->eo && td->io_ops) {
3096 void *oldeo = td->eo;
3098 td->eo = malloc(td->io_ops->option_struct_size);
3099 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
3100 options_mem_dupe(td->eo, td->io_ops->options);
3104 unsigned int fio_get_kb_base(void *data)
3106 struct thread_options *o = data;
3107 unsigned int kb_base = 0;
3110 kb_base = o->kb_base;
3117 int add_option(struct fio_option *o)
3119 struct fio_option *__o;
3128 memcpy(&fio_options[opt_index], o, sizeof(*o));
3132 void invalidate_profile_options(const char *prof_name)
3134 struct fio_option *o;
3138 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
3139 o->type = FIO_OPT_INVALID;
3140 o->prof_name = NULL;
3146 void add_opt_posval(const char *optname, const char *ival, const char *help)
3148 struct fio_option *o;
3151 o = find_option(fio_options, optname);
3155 for (i = 0; i < PARSE_MAX_VP; i++) {
3156 if (o->posval[i].ival)
3159 o->posval[i].ival = ival;
3160 o->posval[i].help = help;
3165 void del_opt_posval(const char *optname, const char *ival)
3167 struct fio_option *o;
3170 o = find_option(fio_options, optname);
3174 for (i = 0; i < PARSE_MAX_VP; i++) {
3175 if (!o->posval[i].ival)
3177 if (strcmp(o->posval[i].ival, ival))
3180 o->posval[i].ival = NULL;
3181 o->posval[i].help = NULL;
3185 void fio_options_free(struct thread_data *td)
3187 options_free(fio_options, td);
3188 if (td->eo && td->io_ops && td->io_ops->options) {
3189 options_free(td->io_ops->options, td->eo);
3195 struct fio_option *fio_option_find(const char *name)
3197 return find_option(fio_options, name);