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;
405 static int str_verify_trim_cb(void *data, unsigned long long *val)
407 struct thread_data *td = data;
409 td->o.trim_percentage = *val;
414 static int str_fst_cb(void *data, const char *str)
416 struct thread_data *td = data;
417 char *nr = get_opt_postfix(str);
419 td->file_service_nr = 1;
421 td->file_service_nr = atoi(nr);
428 #ifdef FIO_HAVE_SYNC_FILE_RANGE
429 static int str_sfr_cb(void *data, const char *str)
431 struct thread_data *td = data;
432 char *nr = get_opt_postfix(str);
434 td->sync_file_range_nr = 1;
436 td->sync_file_range_nr = atoi(nr);
444 static int check_dir(struct thread_data *td, char *fname)
447 char file[PATH_MAX], *dir;
450 if (td->o.directory) {
451 strcpy(file, td->o.directory);
456 sprintf(file + elen, "%s", fname);
462 * We can't do this on FIO_DISKLESSIO engines. The engine isn't loaded
463 * yet, so we can't do this check right here...
465 if (lstat(dir, &sb) < 0) {
468 log_err("fio: %s is not a directory\n", dir);
469 td_verror(td, ret, "lstat");
473 if (!S_ISDIR(sb.st_mode)) {
474 log_err("fio: %s is not a directory\n", dir);
484 * Return next file in the string. Files are separated with ':'. If the ':'
485 * is escaped with a '\', then that ':' is part of the filename and does not
486 * indicate a new file.
488 static char *get_next_file_name(char **ptr)
493 if (!str || !strlen(str))
499 * No colon, we are done
501 p = strchr(str, ':');
508 * We got a colon, but it's the first character. Skip and
516 if (*(p - 1) != '\\') {
522 memmove(p - 1, p, strlen(p) + 1);
529 static int str_filename_cb(void *data, const char *input)
531 struct thread_data *td = data;
532 char *fname, *str, *p;
534 p = str = strdup(input);
536 strip_blank_front(&str);
537 strip_blank_end(str);
539 if (!td->files_index)
542 while ((fname = get_next_file_name(&str)) != NULL) {
545 if (check_dir(td, fname)) {
557 static int str_directory_cb(void *data, const char fio_unused *str)
559 struct thread_data *td = data;
562 if (lstat(td->o.directory, &sb) < 0) {
565 log_err("fio: %s is not a directory\n", td->o.directory);
566 td_verror(td, ret, "lstat");
569 if (!S_ISDIR(sb.st_mode)) {
570 log_err("fio: %s is not a directory\n", td->o.directory);
577 static int str_opendir_cb(void *data, const char fio_unused *str)
579 struct thread_data *td = data;
581 if (!td->files_index)
584 return add_dir_files(td, td->o.opendir);
587 static int str_verify_offset_cb(void *data, unsigned long long *off)
589 struct thread_data *td = data;
591 if (*off && *off < sizeof(struct verify_header)) {
592 log_err("fio: verify_offset too small\n");
596 td->o.verify_offset = *off;
600 static int str_verify_pattern_cb(void *data, const char *input)
602 struct thread_data *td = data;
604 int i = 0, j = 0, len, k, base = 10;
607 loc1 = strstr(input, "0x");
608 loc2 = strstr(input, "0X");
611 off = strtol(input, NULL, base);
612 if (off != LONG_MAX || errno != ERANGE) {
614 td->o.verify_pattern[i] = off & 0xff;
623 j = loc1 - input + 2;
625 j = loc2 - input + 2;
628 if (len - j < MAX_PATTERN_SIZE * 2) {
630 off = converthexchartoint(input[k--]);
632 off += (converthexchartoint(input[k--])
634 td->o.verify_pattern[i++] = (char) off;
640 * Fill the pattern all the way to the end. This greatly reduces
641 * the number of memcpy's we have to do when verifying the IO.
643 while (i > 1 && i * 2 <= MAX_PATTERN_SIZE) {
644 memcpy(&td->o.verify_pattern[i], &td->o.verify_pattern[0], i);
649 * The code in verify_io_u_pattern assumes a single byte pattern
650 * fills the whole verify pattern buffer.
652 memset(td->o.verify_pattern, td->o.verify_pattern[0],
656 td->o.verify_pattern_bytes = i;
659 * VERIFY_META could already be set
661 if (td->o.verify == VERIFY_NONE)
662 td->o.verify = VERIFY_PATTERN;
667 static int str_lockfile_cb(void *data, const char *str)
669 struct thread_data *td = data;
670 char *nr = get_opt_postfix(str);
672 td->o.lockfile_batch = 1;
674 td->o.lockfile_batch = atoi(nr);
681 static int str_write_bw_log_cb(void *data, const char *str)
683 struct thread_data *td = data;
686 td->o.bw_log_file = strdup(str);
688 td->o.write_bw_log = 1;
692 static int str_write_lat_log_cb(void *data, const char *str)
694 struct thread_data *td = data;
697 td->o.lat_log_file = strdup(str);
699 td->o.write_lat_log = 1;
703 static int str_write_iops_log_cb(void *data, const char *str)
705 struct thread_data *td = data;
708 td->o.iops_log_file = strdup(str);
710 td->o.write_iops_log = 1;
714 static int str_gtod_reduce_cb(void *data, int *il)
716 struct thread_data *td = data;
719 td->o.disable_lat = !!val;
720 td->o.disable_clat = !!val;
721 td->o.disable_slat = !!val;
722 td->o.disable_bw = !!val;
723 td->o.clat_percentiles = !val;
725 td->tv_cache_mask = 63;
730 static int str_gtod_cpu_cb(void *data, long long *il)
732 struct thread_data *td = data;
735 td->o.gtod_cpu = val;
736 td->o.gtod_offload = 1;
740 static int str_size_cb(void *data, unsigned long long *__val)
742 struct thread_data *td = data;
743 unsigned long long v = *__val;
745 if (parse_is_percent(v)) {
747 td->o.size_percent = -1ULL - v;
754 static int rw_verify(struct fio_option *o, void *data)
756 struct thread_data *td = data;
758 if (read_only && td_write(td)) {
759 log_err("fio: job <%s> has write bit set, but fio is in"
760 " read-only mode\n", td->o.name);
767 static int gtod_cpu_verify(struct fio_option *o, void *data)
769 #ifndef FIO_HAVE_CPU_AFFINITY
770 struct thread_data *td = data;
772 if (td->o.gtod_cpu) {
773 log_err("fio: platform must support CPU affinity for"
774 "gettimeofday() offloading\n");
782 static int kb_base_verify(struct fio_option *o, void *data)
784 struct thread_data *td = data;
786 if (td->o.kb_base != 1024 && td->o.kb_base != 1000) {
787 log_err("fio: kb_base set to nonsensical value: %u\n",
798 static struct opt_group fio_opt_groups[] = {
801 .mask = FIO_OPT_C_GENERAL,
805 .mask = FIO_OPT_C_IO,
809 .mask = FIO_OPT_C_FILE,
812 .name = "Statistics",
813 .mask = FIO_OPT_C_STAT,
817 .mask = FIO_OPT_C_LOG,
824 static struct opt_group *__opt_group_from_mask(struct opt_group *ogs, unsigned int *mask,
825 unsigned int inv_mask)
827 struct opt_group *og;
830 if (*mask == inv_mask || !*mask)
833 for (i = 0; ogs[i].name; i++) {
836 if (*mask & og->mask) {
837 *mask &= ~(og->mask);
845 struct opt_group *opt_group_from_mask(unsigned int *mask)
847 return __opt_group_from_mask(fio_opt_groups, mask, FIO_OPT_C_INVALID);
850 static struct opt_group fio_opt_cat_groups[] = {
853 .mask = FIO_OPT_G_RATE,
857 .mask = FIO_OPT_G_ZONE,
860 .name = "Read/write mix",
861 .mask = FIO_OPT_G_RWMIX,
865 .mask = FIO_OPT_G_VERIFY,
869 .mask = FIO_OPT_G_TRIM,
872 .name = "I/O Logging",
873 .mask = FIO_OPT_G_IOLOG,
877 .mask = FIO_OPT_G_IO_DEPTH,
881 .mask = FIO_OPT_G_IO_FLOW,
884 .name = "Description",
885 .mask = FIO_OPT_G_DESC,
889 .mask = FIO_OPT_G_FILENAME,
892 .name = "General I/O",
893 .mask = FIO_OPT_G_IO_BASIC,
897 .mask = FIO_OPT_G_CGROUP,
901 .mask = FIO_OPT_G_RUNTIME,
905 .mask = FIO_OPT_G_PROCESS,
908 .name = "Job credentials / priority",
909 .mask = FIO_OPT_G_CRED,
912 .name = "Clock settings",
913 .mask = FIO_OPT_G_CLOCK,
917 .mask = FIO_OPT_G_IO_TYPE,
920 .name = "I/O Thinktime",
921 .mask = FIO_OPT_G_THINKTIME,
924 .name = "Randomizations",
925 .mask = FIO_OPT_G_RANDOM,
928 .name = "I/O buffers",
929 .mask = FIO_OPT_G_IO_BUF,
936 struct opt_group *opt_group_cat_from_mask(unsigned int *mask)
938 return __opt_group_from_mask(fio_opt_cat_groups, mask, FIO_OPT_G_INVALID);
942 * Map of job/command line options
944 struct fio_option fio_options[FIO_MAX_OPTS] = {
946 .name = "description",
947 .lname = "Description of job",
948 .type = FIO_OPT_STR_STORE,
949 .off1 = td_var_offset(description),
950 .help = "Text job description",
951 .category = FIO_OPT_C_GENERAL,
952 .group = FIO_OPT_G_DESC,
957 .type = FIO_OPT_STR_STORE,
958 .off1 = td_var_offset(name),
959 .help = "Name of this job",
960 .category = FIO_OPT_C_GENERAL,
961 .group = FIO_OPT_G_DESC,
965 .lname = "Filename(s)",
966 .type = FIO_OPT_STR_STORE,
967 .off1 = td_var_offset(filename),
968 .cb = str_filename_cb,
969 .prio = -1, /* must come after "directory" */
970 .help = "File(s) to use for the workload",
971 .category = FIO_OPT_C_FILE,
972 .group = FIO_OPT_G_FILENAME,
976 .lname = "Directory",
977 .type = FIO_OPT_STR_STORE,
978 .off1 = td_var_offset(directory),
979 .cb = str_directory_cb,
980 .help = "Directory to store files in",
981 .category = FIO_OPT_C_FILE,
982 .group = FIO_OPT_G_FILENAME,
988 .cb = str_lockfile_cb,
989 .off1 = td_var_offset(file_lock_mode),
990 .help = "Lock file when doing IO to it",
991 .parent = "filename",
994 .category = FIO_OPT_C_FILE,
995 .group = FIO_OPT_G_FILENAME,
998 .oval = FILE_LOCK_NONE,
999 .help = "No file locking",
1001 { .ival = "exclusive",
1002 .oval = FILE_LOCK_EXCLUSIVE,
1003 .help = "Exclusive file lock",
1006 .ival = "readwrite",
1007 .oval = FILE_LOCK_READWRITE,
1008 .help = "Read vs write lock",
1014 .lname = "Open directory",
1015 .type = FIO_OPT_STR_STORE,
1016 .off1 = td_var_offset(opendir),
1017 .cb = str_opendir_cb,
1018 .help = "Recursively add files from this directory and down",
1019 .category = FIO_OPT_C_FILE,
1020 .group = FIO_OPT_G_FILENAME,
1024 .lname = "Read/write",
1025 .alias = "readwrite",
1026 .type = FIO_OPT_STR,
1028 .off1 = td_var_offset(td_ddir),
1029 .help = "IO direction",
1031 .verify = rw_verify,
1032 .category = FIO_OPT_C_IO,
1033 .group = FIO_OPT_G_IO_BASIC,
1036 .oval = TD_DDIR_READ,
1037 .help = "Sequential read",
1040 .oval = TD_DDIR_WRITE,
1041 .help = "Sequential write",
1043 { .ival = "randread",
1044 .oval = TD_DDIR_RANDREAD,
1045 .help = "Random read",
1047 { .ival = "randwrite",
1048 .oval = TD_DDIR_RANDWRITE,
1049 .help = "Random write",
1053 .help = "Sequential read and write mix",
1056 .oval = TD_DDIR_RANDRW,
1057 .help = "Random read and write mix"
1062 .name = "rw_sequencer",
1063 .lname = "RW Sequencer",
1064 .type = FIO_OPT_STR,
1065 .off1 = td_var_offset(rw_seq),
1066 .help = "IO offset generator modifier",
1067 .def = "sequential",
1068 .category = FIO_OPT_C_IO,
1069 .group = FIO_OPT_G_IO_BASIC,
1071 { .ival = "sequential",
1073 .help = "Generate sequential offsets",
1075 { .ival = "identical",
1076 .oval = RW_SEQ_IDENT,
1077 .help = "Generate identical offsets",
1084 .lname = "IO Engine",
1085 .type = FIO_OPT_STR_STORE,
1086 .off1 = td_var_offset(ioengine),
1087 .help = "IO engine to use",
1088 .def = FIO_PREFERRED_ENGINE,
1089 .category = FIO_OPT_C_IO,
1090 .group = FIO_OPT_G_IO_BASIC,
1093 .help = "Use read/write",
1096 .help = "Use pread/pwrite",
1099 .help = "Use readv/writev",
1101 #ifdef FIO_HAVE_LIBAIO
1103 .help = "Linux native asynchronous IO",
1106 #ifdef FIO_HAVE_POSIXAIO
1107 { .ival = "posixaio",
1108 .help = "POSIX asynchronous IO",
1111 #ifdef FIO_HAVE_SOLARISAIO
1112 { .ival = "solarisaio",
1113 .help = "Solaris native asynchronous IO",
1116 #ifdef FIO_HAVE_WINDOWSAIO
1117 { .ival = "windowsaio",
1118 .help = "Windows native asynchronous IO"
1122 .help = "Memory mapped IO"
1124 #ifdef FIO_HAVE_SPLICE
1126 .help = "splice/vmsplice based IO",
1128 { .ival = "netsplice",
1129 .help = "splice/vmsplice to/from the network",
1132 #ifdef FIO_HAVE_SGIO
1134 .help = "SCSI generic v3 IO",
1138 .help = "Testing engine (no data transfer)",
1141 .help = "Network IO",
1143 #ifdef FIO_HAVE_SYSLET
1144 { .ival = "syslet-rw",
1145 .help = "syslet enabled async pread/pwrite IO",
1149 .help = "CPU cycle burner engine",
1151 #ifdef FIO_HAVE_GUASI
1153 .help = "GUASI IO engine",
1156 #ifdef FIO_HAVE_BINJECT
1157 { .ival = "binject",
1158 .help = "binject direct inject block engine",
1161 #ifdef FIO_HAVE_RDMA
1163 .help = "RDMA IO engine",
1166 { .ival = "external",
1167 .help = "Load external engine (append name)",
1173 .lname = "IO Depth",
1174 .type = FIO_OPT_INT,
1175 .off1 = td_var_offset(iodepth),
1176 .help = "Number of IO buffers to keep in flight",
1180 .category = FIO_OPT_C_IO,
1181 .group = FIO_OPT_G_IO_BASIC,
1184 .name = "iodepth_batch",
1185 .lname = "IO Depth batch",
1186 .alias = "iodepth_batch_submit",
1187 .type = FIO_OPT_INT,
1188 .off1 = td_var_offset(iodepth_batch),
1189 .help = "Number of IO buffers to submit in one go",
1190 .parent = "iodepth",
1195 .category = FIO_OPT_C_IO,
1196 .group = FIO_OPT_G_IO_BASIC,
1199 .name = "iodepth_batch_complete",
1200 .lname = "IO Depth batch complete",
1201 .type = FIO_OPT_INT,
1202 .off1 = td_var_offset(iodepth_batch_complete),
1203 .help = "Number of IO buffers to retrieve in one go",
1204 .parent = "iodepth",
1209 .category = FIO_OPT_C_IO,
1210 .group = FIO_OPT_G_IO_BASIC,
1213 .name = "iodepth_low",
1214 .lname = "IO Depth batch low",
1215 .type = FIO_OPT_INT,
1216 .off1 = td_var_offset(iodepth_low),
1217 .help = "Low water mark for queuing depth",
1218 .parent = "iodepth",
1221 .category = FIO_OPT_C_IO,
1222 .group = FIO_OPT_G_IO_BASIC,
1227 .type = FIO_OPT_STR_VAL,
1229 .help = "Total size of device or files",
1230 .interval = 1024 * 1024,
1231 .category = FIO_OPT_C_IO,
1232 .group = FIO_OPT_G_INVALID,
1235 .name = "fill_device",
1236 .lname = "Fill device",
1238 .type = FIO_OPT_BOOL,
1239 .off1 = td_var_offset(fill_device),
1240 .help = "Write until an ENOSPC error occurs",
1242 .category = FIO_OPT_C_FILE,
1243 .group = FIO_OPT_G_INVALID,
1247 .lname = "File size",
1248 .type = FIO_OPT_STR_VAL,
1249 .off1 = td_var_offset(file_size_low),
1250 .off2 = td_var_offset(file_size_high),
1252 .help = "Size of individual files",
1253 .interval = 1024 * 1024,
1254 .category = FIO_OPT_C_FILE,
1255 .group = FIO_OPT_G_INVALID,
1259 .lname = "IO offset",
1260 .alias = "fileoffset",
1261 .type = FIO_OPT_STR_VAL,
1262 .off1 = td_var_offset(start_offset),
1263 .help = "Start IO from this offset",
1265 .interval = 1024 * 1024,
1266 .category = FIO_OPT_C_IO,
1267 .group = FIO_OPT_G_INVALID,
1270 .name = "offset_increment",
1271 .lname = "IO offset increment",
1272 .type = FIO_OPT_STR_VAL,
1273 .off1 = td_var_offset(offset_increment),
1274 .help = "What is the increment from one offset to the next",
1278 .interval = 1024 * 1024,
1279 .category = FIO_OPT_C_IO,
1280 .group = FIO_OPT_G_INVALID,
1284 .lname = "Block size",
1285 .alias = "blocksize",
1286 .type = FIO_OPT_INT,
1287 .off1 = td_var_offset(bs[DDIR_READ]),
1288 .off2 = td_var_offset(bs[DDIR_WRITE]),
1290 .help = "Block size unit",
1295 .category = FIO_OPT_C_IO,
1296 .group = FIO_OPT_G_INVALID,
1300 .lname = "Block size align",
1301 .alias = "blockalign",
1302 .type = FIO_OPT_INT,
1303 .off1 = td_var_offset(ba[DDIR_READ]),
1304 .off2 = td_var_offset(ba[DDIR_WRITE]),
1306 .help = "IO block offset alignment",
1310 .category = FIO_OPT_C_IO,
1311 .group = FIO_OPT_G_INVALID,
1315 .lname = "Block size range",
1316 .alias = "blocksize_range",
1317 .type = FIO_OPT_RANGE,
1318 .off1 = td_var_offset(min_bs[DDIR_READ]),
1319 .off2 = td_var_offset(max_bs[DDIR_READ]),
1320 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
1321 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
1323 .help = "Set block size range (in more detail than bs)",
1327 .category = FIO_OPT_C_IO,
1328 .group = FIO_OPT_G_INVALID,
1332 .lname = "Block size split",
1333 .type = FIO_OPT_STR,
1334 .cb = str_bssplit_cb,
1335 .help = "Set a specific mix of block sizes",
1338 .category = FIO_OPT_C_IO,
1339 .group = FIO_OPT_G_INVALID,
1342 .name = "bs_unaligned",
1343 .lname = "Block size unaligned",
1344 .alias = "blocksize_unaligned",
1345 .type = FIO_OPT_STR_SET,
1346 .off1 = td_var_offset(bs_unaligned),
1347 .help = "Don't sector align IO buffer sizes",
1350 .category = FIO_OPT_C_IO,
1351 .group = FIO_OPT_G_INVALID,
1354 .name = "randrepeat",
1355 .lname = "Random repeatable",
1356 .type = FIO_OPT_BOOL,
1357 .off1 = td_var_offset(rand_repeatable),
1358 .help = "Use repeatable random IO pattern",
1362 .category = FIO_OPT_C_IO,
1363 .group = FIO_OPT_G_RANDOM,
1366 .name = "use_os_rand",
1367 .lname = "Use OS random",
1368 .type = FIO_OPT_BOOL,
1369 .off1 = td_var_offset(use_os_rand),
1370 .help = "Set to use OS random generator",
1374 .category = FIO_OPT_C_IO,
1375 .group = FIO_OPT_G_RANDOM,
1378 .name = "norandommap",
1379 .lname = "No randommap",
1380 .type = FIO_OPT_STR_SET,
1381 .off1 = td_var_offset(norandommap),
1382 .help = "Accept potential duplicate random blocks",
1386 .category = FIO_OPT_C_IO,
1387 .group = FIO_OPT_G_RANDOM,
1390 .name = "softrandommap",
1391 .lname = "Soft randommap",
1392 .type = FIO_OPT_BOOL,
1393 .off1 = td_var_offset(softrandommap),
1394 .help = "Set norandommap if randommap allocation fails",
1395 .parent = "norandommap",
1398 .category = FIO_OPT_C_IO,
1399 .group = FIO_OPT_G_RANDOM,
1403 .lname = "Number of files",
1404 .alias = "nr_files",
1405 .type = FIO_OPT_INT,
1406 .off1 = td_var_offset(nr_files),
1407 .help = "Split job workload between this number of files",
1410 .category = FIO_OPT_C_FILE,
1411 .group = FIO_OPT_G_INVALID,
1414 .name = "openfiles",
1415 .lname = "Number of open files",
1416 .type = FIO_OPT_INT,
1417 .off1 = td_var_offset(open_files),
1418 .help = "Number of files to keep open at the same time",
1419 .category = FIO_OPT_C_FILE,
1420 .group = FIO_OPT_G_INVALID,
1423 .name = "file_service_type",
1424 .lname = "File service type",
1425 .type = FIO_OPT_STR,
1427 .off1 = td_var_offset(file_service_type),
1428 .help = "How to select which file to service next",
1429 .def = "roundrobin",
1430 .category = FIO_OPT_C_FILE,
1431 .group = FIO_OPT_G_INVALID,
1434 .oval = FIO_FSERVICE_RANDOM,
1435 .help = "Choose a file at random",
1437 { .ival = "roundrobin",
1438 .oval = FIO_FSERVICE_RR,
1439 .help = "Round robin select files",
1441 { .ival = "sequential",
1442 .oval = FIO_FSERVICE_SEQ,
1443 .help = "Finish one file before moving to the next",
1446 .parent = "nrfiles",
1449 #ifdef FIO_HAVE_FALLOCATE
1451 .name = "fallocate",
1452 .lname = "Fallocate",
1453 .type = FIO_OPT_STR,
1454 .off1 = td_var_offset(fallocate_mode),
1455 .help = "Whether pre-allocation is performed when laying out files",
1457 .category = FIO_OPT_C_FILE,
1458 .group = FIO_OPT_G_INVALID,
1461 .oval = FIO_FALLOCATE_NONE,
1462 .help = "Do not pre-allocate space",
1465 .oval = FIO_FALLOCATE_POSIX,
1466 .help = "Use posix_fallocate()",
1468 #ifdef FIO_HAVE_LINUX_FALLOCATE
1470 .oval = FIO_FALLOCATE_KEEP_SIZE,
1471 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
1474 /* Compatibility with former boolean values */
1476 .oval = FIO_FALLOCATE_NONE,
1477 .help = "Alias for 'none'",
1480 .oval = FIO_FALLOCATE_POSIX,
1481 .help = "Alias for 'posix'",
1485 #endif /* FIO_HAVE_FALLOCATE */
1487 .name = "fadvise_hint",
1488 .lname = "Fadvise hint",
1489 .type = FIO_OPT_BOOL,
1490 .off1 = td_var_offset(fadvise_hint),
1491 .help = "Use fadvise() to advise the kernel on IO pattern",
1493 .category = FIO_OPT_C_FILE,
1494 .group = FIO_OPT_G_INVALID,
1499 .type = FIO_OPT_INT,
1500 .off1 = td_var_offset(fsync_blocks),
1501 .help = "Issue fsync for writes every given number of blocks",
1504 .category = FIO_OPT_C_FILE,
1505 .group = FIO_OPT_G_INVALID,
1508 .name = "fdatasync",
1509 .lname = "Fdatasync",
1510 .type = FIO_OPT_INT,
1511 .off1 = td_var_offset(fdatasync_blocks),
1512 .help = "Issue fdatasync for writes every given number of blocks",
1515 .category = FIO_OPT_C_FILE,
1516 .group = FIO_OPT_G_INVALID,
1519 .name = "write_barrier",
1520 .lname = "Write barrier",
1521 .type = FIO_OPT_INT,
1522 .off1 = td_var_offset(barrier_blocks),
1523 .help = "Make every Nth write a barrier write",
1526 .category = FIO_OPT_C_IO,
1527 .group = FIO_OPT_G_INVALID,
1529 #ifdef FIO_HAVE_SYNC_FILE_RANGE
1531 .name = "sync_file_range",
1532 .lname = "Sync file range",
1534 { .ival = "wait_before",
1535 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
1536 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
1540 .oval = SYNC_FILE_RANGE_WRITE,
1541 .help = "SYNC_FILE_RANGE_WRITE",
1545 .ival = "wait_after",
1546 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
1547 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
1551 .type = FIO_OPT_STR_MULTI,
1553 .off1 = td_var_offset(sync_file_range),
1554 .help = "Use sync_file_range()",
1555 .category = FIO_OPT_C_FILE,
1556 .group = FIO_OPT_G_INVALID,
1561 .lname = "Direct I/O",
1562 .type = FIO_OPT_BOOL,
1563 .off1 = td_var_offset(odirect),
1564 .help = "Use O_DIRECT IO (negates buffered)",
1566 .inverse = "buffered",
1567 .category = FIO_OPT_C_IO,
1568 .group = FIO_OPT_G_IO_TYPE,
1572 .lname = "Buffered I/O",
1573 .type = FIO_OPT_BOOL,
1574 .off1 = td_var_offset(odirect),
1576 .help = "Use buffered IO (negates direct)",
1578 .inverse = "direct",
1579 .category = FIO_OPT_C_IO,
1580 .group = FIO_OPT_G_IO_TYPE,
1583 .name = "overwrite",
1584 .lname = "Overwrite",
1585 .type = FIO_OPT_BOOL,
1586 .off1 = td_var_offset(overwrite),
1587 .help = "When writing, set whether to overwrite current data",
1589 .category = FIO_OPT_C_FILE,
1590 .group = FIO_OPT_G_INVALID,
1595 .type = FIO_OPT_INT,
1596 .off1 = td_var_offset(loops),
1597 .help = "Number of times to run the job",
1600 .category = FIO_OPT_C_GENERAL,
1601 .group = FIO_OPT_G_RUNTIME,
1605 .lname = "Number of jobs",
1606 .type = FIO_OPT_INT,
1607 .off1 = td_var_offset(numjobs),
1608 .help = "Duplicate this job this many times",
1611 .category = FIO_OPT_C_GENERAL,
1612 .group = FIO_OPT_G_RUNTIME,
1615 .name = "startdelay",
1616 .lname = "Start delay",
1617 .type = FIO_OPT_STR_VAL_TIME,
1618 .off1 = td_var_offset(start_delay),
1619 .help = "Only start job when this period has passed",
1621 .category = FIO_OPT_C_GENERAL,
1622 .group = FIO_OPT_G_RUNTIME,
1628 .type = FIO_OPT_STR_VAL_TIME,
1629 .off1 = td_var_offset(timeout),
1630 .help = "Stop workload when this amount of time has passed",
1632 .category = FIO_OPT_C_GENERAL,
1633 .group = FIO_OPT_G_RUNTIME,
1636 .name = "time_based",
1637 .lname = "Time based",
1638 .type = FIO_OPT_STR_SET,
1639 .off1 = td_var_offset(time_based),
1640 .help = "Keep running until runtime/timeout is met",
1641 .category = FIO_OPT_C_GENERAL,
1642 .group = FIO_OPT_G_RUNTIME,
1645 .name = "ramp_time",
1646 .lname = "Ramp time",
1647 .type = FIO_OPT_STR_VAL_TIME,
1648 .off1 = td_var_offset(ramp_time),
1649 .help = "Ramp up time before measuring performance",
1650 .category = FIO_OPT_C_GENERAL,
1651 .group = FIO_OPT_G_RUNTIME,
1654 .name = "clocksource",
1655 .lname = "Clock source",
1656 .type = FIO_OPT_STR,
1657 .cb = fio_clock_source_cb,
1658 .off1 = td_var_offset(clocksource),
1659 .help = "What type of timing source to use",
1660 .category = FIO_OPT_C_GENERAL,
1661 .group = FIO_OPT_G_CLOCK,
1663 { .ival = "gettimeofday",
1665 .help = "Use gettimeofday(2) for timing",
1667 { .ival = "clock_gettime",
1668 .oval = CS_CGETTIME,
1669 .help = "Use clock_gettime(2) for timing",
1671 #ifdef ARCH_HAVE_CPU_CLOCK
1673 .oval = CS_CPUCLOCK,
1674 .help = "Use CPU private clock",
1682 .lname = "I/O Memory",
1683 .type = FIO_OPT_STR,
1685 .off1 = td_var_offset(mem_type),
1686 .help = "Backing type for IO buffers",
1688 .category = FIO_OPT_C_IO,
1689 .group = FIO_OPT_G_INVALID,
1693 .help = "Use malloc(3) for IO buffers",
1697 .help = "Use shared memory segments for IO buffers",
1699 #ifdef FIO_HAVE_HUGETLB
1700 { .ival = "shmhuge",
1701 .oval = MEM_SHMHUGE,
1702 .help = "Like shm, but use huge pages",
1707 .help = "Use mmap(2) (file or anon) for IO buffers",
1709 #ifdef FIO_HAVE_HUGETLB
1710 { .ival = "mmaphuge",
1711 .oval = MEM_MMAPHUGE,
1712 .help = "Like mmap, but use huge pages",
1718 .name = "iomem_align",
1719 .alias = "mem_align",
1720 .lname = "I/O memory alignment",
1721 .type = FIO_OPT_INT,
1722 .off1 = td_var_offset(mem_align),
1724 .help = "IO memory buffer offset alignment",
1728 .category = FIO_OPT_C_IO,
1729 .group = FIO_OPT_G_INVALID,
1734 .type = FIO_OPT_STR,
1735 .off1 = td_var_offset(verify),
1736 .help = "Verify data written",
1738 .category = FIO_OPT_C_IO,
1739 .group = FIO_OPT_G_VERIFY,
1742 .oval = VERIFY_NONE,
1743 .help = "Don't do IO verification",
1747 .help = "Use md5 checksums for verification",
1750 .oval = VERIFY_CRC64,
1751 .help = "Use crc64 checksums for verification",
1754 .oval = VERIFY_CRC32,
1755 .help = "Use crc32 checksums for verification",
1757 { .ival = "crc32c-intel",
1758 .oval = VERIFY_CRC32C,
1759 .help = "Use crc32c checksums for verification (hw assisted, if available)",
1762 .oval = VERIFY_CRC32C,
1763 .help = "Use crc32c checksums for verification (hw assisted, if available)",
1766 .oval = VERIFY_CRC16,
1767 .help = "Use crc16 checksums for verification",
1770 .oval = VERIFY_CRC7,
1771 .help = "Use crc7 checksums for verification",
1774 .oval = VERIFY_SHA1,
1775 .help = "Use sha1 checksums for verification",
1778 .oval = VERIFY_SHA256,
1779 .help = "Use sha256 checksums for verification",
1782 .oval = VERIFY_SHA512,
1783 .help = "Use sha512 checksums for verification",
1786 .oval = VERIFY_META,
1787 .help = "Use io information",
1791 .oval = VERIFY_NULL,
1792 .help = "Pretend to verify",
1797 .name = "do_verify",
1798 .lname = "Perform verify step",
1799 .type = FIO_OPT_BOOL,
1800 .off1 = td_var_offset(do_verify),
1801 .help = "Run verification stage after write",
1805 .category = FIO_OPT_C_IO,
1806 .group = FIO_OPT_G_VERIFY,
1809 .name = "verifysort",
1810 .lname = "Verify sort",
1811 .type = FIO_OPT_BOOL,
1812 .off1 = td_var_offset(verifysort),
1813 .help = "Sort written verify blocks for read back",
1817 .category = FIO_OPT_C_IO,
1818 .group = FIO_OPT_G_VERIFY,
1821 .name = "verify_interval",
1822 .lname = "Verify interval",
1823 .type = FIO_OPT_INT,
1824 .off1 = td_var_offset(verify_interval),
1825 .minval = 2 * sizeof(struct verify_header),
1826 .help = "Store verify buffer header every N bytes",
1829 .interval = 2 * sizeof(struct verify_header),
1830 .category = FIO_OPT_C_IO,
1831 .group = FIO_OPT_G_VERIFY,
1834 .name = "verify_offset",
1835 .lname = "Verify offset",
1836 .type = FIO_OPT_INT,
1837 .help = "Offset verify header location by N bytes",
1839 .cb = str_verify_offset_cb,
1842 .category = FIO_OPT_C_IO,
1843 .group = FIO_OPT_G_VERIFY,
1846 .name = "verify_pattern",
1847 .lname = "Verify pattern",
1848 .type = FIO_OPT_STR,
1849 .cb = str_verify_pattern_cb,
1850 .help = "Fill pattern for IO buffers",
1853 .category = FIO_OPT_C_IO,
1854 .group = FIO_OPT_G_VERIFY,
1857 .name = "verify_fatal",
1858 .lname = "Verify fatal",
1859 .type = FIO_OPT_BOOL,
1860 .off1 = td_var_offset(verify_fatal),
1862 .help = "Exit on a single verify failure, don't continue",
1865 .category = FIO_OPT_C_IO,
1866 .group = FIO_OPT_G_VERIFY,
1869 .name = "verify_dump",
1870 .lname = "Verify dump",
1871 .type = FIO_OPT_BOOL,
1872 .off1 = td_var_offset(verify_dump),
1874 .help = "Dump contents of good and bad blocks on failure",
1877 .category = FIO_OPT_C_IO,
1878 .group = FIO_OPT_G_VERIFY,
1881 .name = "verify_async",
1882 .lname = "Verify asynchronously",
1883 .type = FIO_OPT_INT,
1884 .off1 = td_var_offset(verify_async),
1886 .help = "Number of async verifier threads to use",
1889 .category = FIO_OPT_C_IO,
1890 .group = FIO_OPT_G_VERIFY,
1893 .name = "verify_backlog",
1894 .lname = "Verify backlog",
1895 .type = FIO_OPT_STR_VAL,
1896 .off1 = td_var_offset(verify_backlog),
1897 .help = "Verify after this number of blocks are written",
1900 .category = FIO_OPT_C_IO,
1901 .group = FIO_OPT_G_VERIFY,
1904 .name = "verify_backlog_batch",
1905 .lname = "Verify backlog batch",
1906 .type = FIO_OPT_INT,
1907 .off1 = td_var_offset(verify_batch),
1908 .help = "Verify this number of IO blocks",
1911 .category = FIO_OPT_C_IO,
1912 .group = FIO_OPT_G_VERIFY,
1914 #ifdef FIO_HAVE_CPU_AFFINITY
1916 .name = "verify_async_cpus",
1917 .lname = "Async verify CPUs",
1918 .type = FIO_OPT_STR,
1919 .cb = str_verify_cpus_allowed_cb,
1920 .help = "Set CPUs allowed for async verify threads",
1921 .parent = "verify_async",
1923 .category = FIO_OPT_C_IO,
1924 .group = FIO_OPT_G_VERIFY,
1927 #ifdef FIO_HAVE_TRIM
1929 .name = "trim_percentage",
1930 .lname = "Trim percentage",
1931 .type = FIO_OPT_INT,
1932 .cb = str_verify_trim_cb,
1935 .help = "Number of verify blocks to discard/trim",
1940 .category = FIO_OPT_C_IO,
1941 .group = FIO_OPT_G_TRIM,
1944 .name = "trim_verify_zero",
1945 .lname = "Verify trim zero",
1946 .type = FIO_OPT_BOOL,
1947 .help = "Verify that trim/discarded blocks are returned as zeroes",
1948 .off1 = td_var_offset(trim_zero),
1949 .parent = "trim_percentage",
1952 .category = FIO_OPT_C_IO,
1953 .group = FIO_OPT_G_TRIM,
1956 .name = "trim_backlog",
1957 .lname = "Trim backlog",
1958 .type = FIO_OPT_STR_VAL,
1959 .off1 = td_var_offset(trim_backlog),
1960 .help = "Trim after this number of blocks are written",
1961 .parent = "trim_percentage",
1964 .category = FIO_OPT_C_IO,
1965 .group = FIO_OPT_G_TRIM,
1968 .name = "trim_backlog_batch",
1969 .lname = "Trim backlog batch",
1970 .type = FIO_OPT_INT,
1971 .off1 = td_var_offset(trim_batch),
1972 .help = "Trim this number of IO blocks",
1973 .parent = "trim_percentage",
1976 .category = FIO_OPT_C_IO,
1977 .group = FIO_OPT_G_TRIM,
1981 .name = "write_iolog",
1982 .lname = "Write I/O log",
1983 .type = FIO_OPT_STR_STORE,
1984 .off1 = td_var_offset(write_iolog_file),
1985 .help = "Store IO pattern to file",
1986 .category = FIO_OPT_C_IO,
1987 .group = FIO_OPT_G_IOLOG,
1990 .name = "read_iolog",
1991 .lname = "Read I/O log",
1992 .type = FIO_OPT_STR_STORE,
1993 .off1 = td_var_offset(read_iolog_file),
1994 .help = "Playback IO pattern from file",
1995 .category = FIO_OPT_C_IO,
1996 .group = FIO_OPT_G_IOLOG,
1999 .name = "replay_no_stall",
2000 .lname = "Don't stall on replay",
2001 .type = FIO_OPT_BOOL,
2002 .off1 = td_var_offset(no_stall),
2004 .parent = "read_iolog",
2006 .help = "Playback IO pattern file as fast as possible without stalls",
2007 .category = FIO_OPT_C_IO,
2008 .group = FIO_OPT_G_IOLOG,
2011 .name = "replay_redirect",
2012 .lname = "Redirect device for replay",
2013 .type = FIO_OPT_STR_STORE,
2014 .off1 = td_var_offset(replay_redirect),
2015 .parent = "read_iolog",
2017 .help = "Replay all I/O onto this device, regardless of trace device",
2018 .category = FIO_OPT_C_IO,
2019 .group = FIO_OPT_G_IOLOG,
2022 .name = "exec_prerun",
2023 .lname = "Pre-execute runnable",
2024 .type = FIO_OPT_STR_STORE,
2025 .off1 = td_var_offset(exec_prerun),
2026 .help = "Execute this file prior to running job",
2027 .category = FIO_OPT_C_GENERAL,
2028 .group = FIO_OPT_G_INVALID,
2031 .name = "exec_postrun",
2032 .lname = "Post-execute runnable",
2033 .type = FIO_OPT_STR_STORE,
2034 .off1 = td_var_offset(exec_postrun),
2035 .help = "Execute this file after running job",
2036 .category = FIO_OPT_C_GENERAL,
2037 .group = FIO_OPT_G_INVALID,
2039 #ifdef FIO_HAVE_IOSCHED_SWITCH
2041 .name = "ioscheduler",
2042 .lname = "I/O scheduler",
2043 .type = FIO_OPT_STR_STORE,
2044 .off1 = td_var_offset(ioscheduler),
2045 .help = "Use this IO scheduler on the backing device",
2046 .category = FIO_OPT_C_FILE,
2047 .group = FIO_OPT_G_INVALID,
2052 .lname = "Zone size",
2053 .type = FIO_OPT_STR_VAL,
2054 .off1 = td_var_offset(zone_size),
2055 .help = "Amount of data to read per zone",
2057 .interval = 1024 * 1024,
2058 .category = FIO_OPT_C_IO,
2059 .group = FIO_OPT_G_ZONE,
2062 .name = "zonerange",
2063 .lname = "Zone range",
2064 .type = FIO_OPT_STR_VAL,
2065 .off1 = td_var_offset(zone_range),
2066 .help = "Give size of an IO zone",
2068 .interval = 1024 * 1024,
2069 .category = FIO_OPT_C_IO,
2070 .group = FIO_OPT_G_ZONE,
2074 .lname = "Zone skip",
2075 .type = FIO_OPT_STR_VAL,
2076 .off1 = td_var_offset(zone_skip),
2077 .help = "Space between IO zones",
2079 .interval = 1024 * 1024,
2080 .category = FIO_OPT_C_IO,
2081 .group = FIO_OPT_G_ZONE,
2085 .lname = "Lock memory",
2086 .type = FIO_OPT_STR_VAL,
2087 .off1 = td_var_offset(lockmem),
2088 .help = "Lock down this amount of memory",
2090 .interval = 1024 * 1024,
2091 .category = FIO_OPT_C_GENERAL,
2092 .group = FIO_OPT_G_INVALID,
2095 .name = "rwmixread",
2096 .lname = "Read/write mix read",
2097 .type = FIO_OPT_INT,
2098 .cb = str_rwmix_read_cb,
2100 .help = "Percentage of mixed workload that is reads",
2103 .inverse = "rwmixwrite",
2104 .category = FIO_OPT_C_IO,
2105 .group = FIO_OPT_G_RWMIX,
2108 .name = "rwmixwrite",
2109 .lname = "Read/write mix write",
2110 .type = FIO_OPT_INT,
2111 .cb = str_rwmix_write_cb,
2113 .help = "Percentage of mixed workload that is writes",
2116 .inverse = "rwmixread",
2117 .category = FIO_OPT_C_IO,
2118 .group = FIO_OPT_G_RWMIX,
2121 .name = "rwmixcycle",
2122 .lname = "Read/write mix cycle",
2123 .type = FIO_OPT_DEPRECATED,
2124 .category = FIO_OPT_C_IO,
2125 .group = FIO_OPT_G_RWMIX,
2130 .type = FIO_OPT_INT,
2131 .off1 = td_var_offset(nice),
2132 .help = "Set job CPU nice value",
2137 .category = FIO_OPT_C_GENERAL,
2138 .group = FIO_OPT_G_CRED,
2140 #ifdef FIO_HAVE_IOPRIO
2143 .lname = "I/O nice priority",
2144 .type = FIO_OPT_INT,
2145 .off1 = td_var_offset(ioprio),
2146 .help = "Set job IO priority value",
2150 .category = FIO_OPT_C_GENERAL,
2151 .group = FIO_OPT_G_CRED,
2154 .name = "prioclass",
2155 .lname = "I/O nice priority class",
2156 .type = FIO_OPT_INT,
2157 .off1 = td_var_offset(ioprio_class),
2158 .help = "Set job IO priority class",
2162 .category = FIO_OPT_C_GENERAL,
2163 .group = FIO_OPT_G_CRED,
2167 .name = "thinktime",
2168 .lname = "Thinktime",
2169 .type = FIO_OPT_INT,
2170 .off1 = td_var_offset(thinktime),
2171 .help = "Idle time between IO buffers (usec)",
2173 .category = FIO_OPT_C_IO,
2174 .group = FIO_OPT_G_THINKTIME,
2177 .name = "thinktime_spin",
2178 .lname = "Thinktime spin",
2179 .type = FIO_OPT_INT,
2180 .off1 = td_var_offset(thinktime_spin),
2181 .help = "Start think time by spinning this amount (usec)",
2183 .parent = "thinktime",
2185 .category = FIO_OPT_C_IO,
2186 .group = FIO_OPT_G_THINKTIME,
2189 .name = "thinktime_blocks",
2190 .lname = "Thinktime blocks",
2191 .type = FIO_OPT_INT,
2192 .off1 = td_var_offset(thinktime_blocks),
2193 .help = "IO buffer period between 'thinktime'",
2195 .parent = "thinktime",
2197 .category = FIO_OPT_C_IO,
2198 .group = FIO_OPT_G_THINKTIME,
2202 .lname = "I/O rate",
2203 .type = FIO_OPT_INT,
2204 .off1 = td_var_offset(rate[0]),
2205 .off2 = td_var_offset(rate[1]),
2206 .help = "Set bandwidth rate",
2207 .category = FIO_OPT_C_IO,
2208 .group = FIO_OPT_G_RATE,
2212 .lname = "I/O min rate",
2213 .type = FIO_OPT_INT,
2214 .off1 = td_var_offset(ratemin[0]),
2215 .off2 = td_var_offset(ratemin[1]),
2216 .help = "Job must meet this rate or it will be shutdown",
2219 .category = FIO_OPT_C_IO,
2220 .group = FIO_OPT_G_RATE,
2223 .name = "rate_iops",
2224 .lname = "I/O rate IOPS",
2225 .type = FIO_OPT_INT,
2226 .off1 = td_var_offset(rate_iops[0]),
2227 .off2 = td_var_offset(rate_iops[1]),
2228 .help = "Limit IO used to this number of IO operations/sec",
2230 .category = FIO_OPT_C_IO,
2231 .group = FIO_OPT_G_RATE,
2234 .name = "rate_iops_min",
2235 .lname = "I/O min rate IOPS",
2236 .type = FIO_OPT_INT,
2237 .off1 = td_var_offset(rate_iops_min[0]),
2238 .off2 = td_var_offset(rate_iops_min[1]),
2239 .help = "Job must meet this rate or it will be shut down",
2240 .parent = "rate_iops",
2242 .category = FIO_OPT_C_IO,
2243 .group = FIO_OPT_G_RATE,
2246 .name = "ratecycle",
2247 .lname = "I/O rate cycle",
2248 .type = FIO_OPT_INT,
2249 .off1 = td_var_offset(ratecycle),
2250 .help = "Window average for rate limits (msec)",
2254 .category = FIO_OPT_C_IO,
2255 .group = FIO_OPT_G_RATE,
2258 .name = "invalidate",
2259 .lname = "Cache invalidate",
2260 .type = FIO_OPT_BOOL,
2261 .off1 = td_var_offset(invalidate_cache),
2262 .help = "Invalidate buffer/page cache prior to running job",
2264 .category = FIO_OPT_C_IO,
2265 .group = FIO_OPT_G_IO_TYPE,
2269 .lname = "Synchronous I/O",
2270 .type = FIO_OPT_BOOL,
2271 .off1 = td_var_offset(sync_io),
2272 .help = "Use O_SYNC for buffered writes",
2274 .parent = "buffered",
2276 .category = FIO_OPT_C_IO,
2277 .group = FIO_OPT_G_IO_TYPE,
2280 .name = "create_serialize",
2281 .lname = "Create serialize",
2282 .type = FIO_OPT_BOOL,
2283 .off1 = td_var_offset(create_serialize),
2284 .help = "Serialize creating of job files",
2286 .category = FIO_OPT_C_FILE,
2287 .group = FIO_OPT_G_INVALID,
2290 .name = "create_fsync",
2291 .lname = "Create fsync",
2292 .type = FIO_OPT_BOOL,
2293 .off1 = td_var_offset(create_fsync),
2294 .help = "fsync file after creation",
2296 .category = FIO_OPT_C_FILE,
2297 .group = FIO_OPT_G_INVALID,
2300 .name = "create_on_open",
2301 .lname = "Create on open",
2302 .type = FIO_OPT_BOOL,
2303 .off1 = td_var_offset(create_on_open),
2304 .help = "Create files when they are opened for IO",
2306 .category = FIO_OPT_C_FILE,
2307 .group = FIO_OPT_G_INVALID,
2311 .lname = "Pre-read files",
2312 .type = FIO_OPT_BOOL,
2313 .off1 = td_var_offset(pre_read),
2314 .help = "Pre-read files before starting official testing",
2316 .category = FIO_OPT_C_FILE,
2317 .group = FIO_OPT_G_INVALID,
2319 #ifdef FIO_HAVE_CPU_AFFINITY
2322 .lname = "CPU mask",
2323 .type = FIO_OPT_INT,
2324 .cb = str_cpumask_cb,
2325 .help = "CPU affinity mask",
2326 .category = FIO_OPT_C_GENERAL,
2327 .group = FIO_OPT_G_CRED,
2330 .name = "cpus_allowed",
2331 .lname = "CPUs allowed",
2332 .type = FIO_OPT_STR,
2333 .cb = str_cpus_allowed_cb,
2334 .help = "Set CPUs allowed",
2335 .category = FIO_OPT_C_GENERAL,
2336 .group = FIO_OPT_G_CRED,
2340 .name = "end_fsync",
2341 .lname = "End fsync",
2342 .type = FIO_OPT_BOOL,
2343 .off1 = td_var_offset(end_fsync),
2344 .help = "Include fsync at the end of job",
2346 .category = FIO_OPT_C_FILE,
2347 .group = FIO_OPT_G_INVALID,
2350 .name = "fsync_on_close",
2351 .lname = "Fsync on close",
2352 .type = FIO_OPT_BOOL,
2353 .off1 = td_var_offset(fsync_on_close),
2354 .help = "fsync files on close",
2356 .category = FIO_OPT_C_FILE,
2357 .group = FIO_OPT_G_INVALID,
2361 .lname = "Unlink file",
2362 .type = FIO_OPT_BOOL,
2363 .off1 = td_var_offset(unlink),
2364 .help = "Unlink created files after job has completed",
2366 .category = FIO_OPT_C_FILE,
2367 .group = FIO_OPT_G_INVALID,
2371 .lname = "Exit-all on terminate",
2372 .type = FIO_OPT_STR_SET,
2373 .cb = str_exitall_cb,
2374 .help = "Terminate all jobs when one exits",
2375 .category = FIO_OPT_C_GENERAL,
2376 .group = FIO_OPT_G_PROCESS,
2379 .name = "stonewall",
2380 .lname = "Wait for previous",
2381 .alias = "wait_for_previous",
2382 .type = FIO_OPT_STR_SET,
2383 .off1 = td_var_offset(stonewall),
2384 .help = "Insert a hard barrier between this job and previous",
2385 .category = FIO_OPT_C_GENERAL,
2386 .group = FIO_OPT_G_PROCESS,
2389 .name = "new_group",
2390 .lname = "New group",
2391 .type = FIO_OPT_STR_SET,
2392 .off1 = td_var_offset(new_group),
2393 .help = "Mark the start of a new group (for reporting)",
2394 .category = FIO_OPT_C_GENERAL,
2395 .group = FIO_OPT_G_PROCESS,
2400 .type = FIO_OPT_STR_SET,
2401 .off1 = td_var_offset(use_thread),
2402 .help = "Use threads instead of processes",
2403 .category = FIO_OPT_C_GENERAL,
2404 .group = FIO_OPT_G_PROCESS,
2407 .name = "write_bw_log",
2408 .lname = "Write bandwidth log",
2409 .type = FIO_OPT_STR,
2410 .off1 = td_var_offset(write_bw_log),
2411 .cb = str_write_bw_log_cb,
2412 .help = "Write log of bandwidth during run",
2413 .category = FIO_OPT_C_LOG,
2414 .group = FIO_OPT_G_INVALID,
2417 .name = "write_lat_log",
2418 .lname = "Write latency log",
2419 .type = FIO_OPT_STR,
2420 .off1 = td_var_offset(write_lat_log),
2421 .cb = str_write_lat_log_cb,
2422 .help = "Write log of latency during run",
2423 .category = FIO_OPT_C_LOG,
2424 .group = FIO_OPT_G_INVALID,
2427 .name = "write_iops_log",
2428 .lname = "Write IOPS log",
2429 .type = FIO_OPT_STR,
2430 .off1 = td_var_offset(write_iops_log),
2431 .cb = str_write_iops_log_cb,
2432 .help = "Write log of IOPS during run",
2433 .category = FIO_OPT_C_LOG,
2434 .group = FIO_OPT_G_INVALID,
2437 .name = "log_avg_msec",
2438 .lname = "Log averaging (msec)",
2439 .type = FIO_OPT_INT,
2440 .off1 = td_var_offset(log_avg_msec),
2441 .help = "Average bw/iops/lat logs over this period of time",
2443 .category = FIO_OPT_C_LOG,
2444 .group = FIO_OPT_G_INVALID,
2447 .name = "bwavgtime",
2448 .lname = "Bandwidth average time",
2449 .type = FIO_OPT_INT,
2450 .off1 = td_var_offset(bw_avg_time),
2451 .help = "Time window over which to calculate bandwidth"
2454 .parent = "write_bw_log",
2457 .category = FIO_OPT_C_LOG,
2458 .group = FIO_OPT_G_INVALID,
2461 .name = "iopsavgtime",
2462 .lname = "IOPS average time",
2463 .type = FIO_OPT_INT,
2464 .off1 = td_var_offset(iops_avg_time),
2465 .help = "Time window over which to calculate IOPS (msec)",
2467 .parent = "write_iops_log",
2470 .category = FIO_OPT_C_LOG,
2471 .group = FIO_OPT_G_INVALID,
2474 .name = "group_reporting",
2475 .lname = "Group reporting",
2476 .type = FIO_OPT_BOOL,
2477 .off1 = td_var_offset(group_reporting),
2478 .help = "Do reporting on a per-group basis",
2480 .category = FIO_OPT_C_STAT,
2481 .group = FIO_OPT_G_INVALID,
2484 .name = "zero_buffers",
2485 .lname = "Zero I/O buffers",
2486 .type = FIO_OPT_STR_SET,
2487 .off1 = td_var_offset(zero_buffers),
2488 .help = "Init IO buffers to all zeroes",
2489 .category = FIO_OPT_C_IO,
2490 .group = FIO_OPT_G_IO_BUF,
2493 .name = "refill_buffers",
2494 .lname = "Refill I/O buffers",
2495 .type = FIO_OPT_STR_SET,
2496 .off1 = td_var_offset(refill_buffers),
2497 .help = "Refill IO buffers on every IO submit",
2498 .category = FIO_OPT_C_IO,
2499 .group = FIO_OPT_G_IO_BUF,
2502 .name = "scramble_buffers",
2503 .lname = "Scramble I/O buffers",
2504 .type = FIO_OPT_BOOL,
2505 .off1 = td_var_offset(scramble_buffers),
2506 .help = "Slightly scramble buffers on every IO submit",
2508 .category = FIO_OPT_C_IO,
2509 .group = FIO_OPT_G_IO_BUF,
2512 .name = "buffer_compress_percentage",
2513 .lname = "Buffer compression percentage",
2514 .type = FIO_OPT_INT,
2515 .off1 = td_var_offset(compress_percentage),
2518 .help = "How compressible the buffer is (approximately)",
2520 .category = FIO_OPT_C_IO,
2521 .group = FIO_OPT_G_IO_BUF,
2524 .name = "buffer_compress_chunk",
2525 .lname = "Buffer compression chunk size",
2526 .type = FIO_OPT_INT,
2527 .off1 = td_var_offset(compress_chunk),
2528 .parent = "buffer_compress_percentage",
2530 .help = "Size of compressible region in buffer",
2532 .category = FIO_OPT_C_IO,
2533 .group = FIO_OPT_G_IO_BUF,
2536 .name = "clat_percentiles",
2537 .lname = "Completion latency percentiles",
2538 .type = FIO_OPT_BOOL,
2539 .off1 = td_var_offset(clat_percentiles),
2540 .help = "Enable the reporting of completion latency percentiles",
2542 .category = FIO_OPT_C_STAT,
2543 .group = FIO_OPT_G_INVALID,
2546 .name = "percentile_list",
2547 .lname = "Completion latency percentile list",
2548 .type = FIO_OPT_FLOAT_LIST,
2549 .off1 = td_var_offset(percentile_list),
2550 .off2 = td_var_offset(overwrite_plist),
2551 .help = "Specify a custom list of percentiles to report",
2552 .maxlen = FIO_IO_U_LIST_MAX_LEN,
2555 .category = FIO_OPT_C_STAT,
2556 .group = FIO_OPT_G_INVALID,
2559 #ifdef FIO_HAVE_DISK_UTIL
2561 .name = "disk_util",
2562 .lname = "Disk utilization",
2563 .type = FIO_OPT_BOOL,
2564 .off1 = td_var_offset(do_disk_util),
2565 .help = "Log disk utilization statistics",
2567 .category = FIO_OPT_C_STAT,
2568 .group = FIO_OPT_G_INVALID,
2572 .name = "gtod_reduce",
2573 .lname = "Reduce gettimeofday() calls",
2574 .type = FIO_OPT_BOOL,
2575 .help = "Greatly reduce number of gettimeofday() calls",
2576 .cb = str_gtod_reduce_cb,
2579 .category = FIO_OPT_C_STAT,
2580 .group = FIO_OPT_G_INVALID,
2583 .name = "disable_lat",
2584 .lname = "Disable all latency stats",
2585 .type = FIO_OPT_BOOL,
2586 .off1 = td_var_offset(disable_lat),
2587 .help = "Disable latency numbers",
2588 .parent = "gtod_reduce",
2591 .category = FIO_OPT_C_STAT,
2592 .group = FIO_OPT_G_INVALID,
2595 .name = "disable_clat",
2596 .lname = "Disable completion latency stats",
2597 .type = FIO_OPT_BOOL,
2598 .off1 = td_var_offset(disable_clat),
2599 .help = "Disable completion latency numbers",
2600 .parent = "gtod_reduce",
2603 .category = FIO_OPT_C_STAT,
2604 .group = FIO_OPT_G_INVALID,
2607 .name = "disable_slat",
2608 .lname = "Disable submission latency stats",
2609 .type = FIO_OPT_BOOL,
2610 .off1 = td_var_offset(disable_slat),
2611 .help = "Disable submission latency numbers",
2612 .parent = "gtod_reduce",
2615 .category = FIO_OPT_C_STAT,
2616 .group = FIO_OPT_G_INVALID,
2619 .name = "disable_bw_measurement",
2620 .lname = "Disable bandwidth stats",
2621 .type = FIO_OPT_BOOL,
2622 .off1 = td_var_offset(disable_bw),
2623 .help = "Disable bandwidth logging",
2624 .parent = "gtod_reduce",
2627 .category = FIO_OPT_C_STAT,
2628 .group = FIO_OPT_G_INVALID,
2632 .lname = "Dedicated gettimeofday() CPU",
2633 .type = FIO_OPT_INT,
2634 .cb = str_gtod_cpu_cb,
2635 .help = "Set up dedicated gettimeofday() thread on this CPU",
2636 .verify = gtod_cpu_verify,
2637 .category = FIO_OPT_C_GENERAL,
2638 .group = FIO_OPT_G_CLOCK,
2641 .name = "continue_on_error",
2642 .lname = "Continue on error",
2643 .type = FIO_OPT_STR,
2644 .off1 = td_var_offset(continue_on_error),
2645 .help = "Continue on non-fatal errors during IO",
2647 .category = FIO_OPT_C_GENERAL,
2648 .group = FIO_OPT_G_INVALID,
2651 .oval = ERROR_TYPE_NONE,
2652 .help = "Exit when an error is encountered",
2655 .oval = ERROR_TYPE_READ,
2656 .help = "Continue on read errors only",
2659 .oval = ERROR_TYPE_WRITE,
2660 .help = "Continue on write errors only",
2663 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
2664 .help = "Continue on any IO errors",
2667 .oval = ERROR_TYPE_VERIFY,
2668 .help = "Continue on verify errors only",
2671 .oval = ERROR_TYPE_ANY,
2672 .help = "Continue on all io and verify errors",
2675 .oval = ERROR_TYPE_NONE,
2676 .help = "Alias for 'none'",
2679 .oval = ERROR_TYPE_ANY,
2680 .help = "Alias for 'all'",
2687 .type = FIO_OPT_STR_STORE,
2688 .off1 = td_var_offset(profile),
2689 .help = "Select a specific builtin performance test",
2690 .category = FIO_OPT_C_GENERAL,
2691 .group = FIO_OPT_G_INVALID,
2696 .type = FIO_OPT_STR_STORE,
2697 .off1 = td_var_offset(cgroup),
2698 .help = "Add job to cgroup of this name",
2699 .category = FIO_OPT_C_GENERAL,
2700 .group = FIO_OPT_G_CGROUP,
2703 .name = "cgroup_nodelete",
2704 .lname = "Cgroup no-delete",
2705 .type = FIO_OPT_BOOL,
2706 .off1 = td_var_offset(cgroup_nodelete),
2707 .help = "Do not delete cgroups after job completion",
2710 .category = FIO_OPT_C_GENERAL,
2711 .group = FIO_OPT_G_CGROUP,
2714 .name = "cgroup_weight",
2715 .lname = "Cgroup weight",
2716 .type = FIO_OPT_INT,
2717 .off1 = td_var_offset(cgroup_weight),
2718 .help = "Use given weight for cgroup",
2722 .category = FIO_OPT_C_GENERAL,
2723 .group = FIO_OPT_G_CGROUP,
2728 .type = FIO_OPT_INT,
2729 .off1 = td_var_offset(uid),
2730 .help = "Run job with this user ID",
2731 .category = FIO_OPT_C_GENERAL,
2732 .group = FIO_OPT_G_CRED,
2736 .lname = "Group ID",
2737 .type = FIO_OPT_INT,
2738 .off1 = td_var_offset(gid),
2739 .help = "Run job with this group ID",
2740 .category = FIO_OPT_C_GENERAL,
2741 .group = FIO_OPT_G_CRED,
2746 .type = FIO_OPT_INT,
2747 .off1 = td_var_offset(kb_base),
2748 .verify = kb_base_verify,
2751 .help = "How many bytes per KB for reporting (1000 or 1024)",
2752 .category = FIO_OPT_C_GENERAL,
2753 .group = FIO_OPT_G_INVALID,
2756 .name = "hugepage-size",
2757 .lname = "Hugepage size",
2758 .type = FIO_OPT_INT,
2759 .off1 = td_var_offset(hugepage_size),
2760 .help = "When using hugepages, specify size of each page",
2761 .def = __fio_stringify(FIO_HUGE_PAGE),
2762 .interval = 1024 * 1024,
2763 .category = FIO_OPT_C_GENERAL,
2764 .group = FIO_OPT_G_INVALID,
2768 .lname = "I/O flow ID",
2769 .type = FIO_OPT_INT,
2770 .off1 = td_var_offset(flow_id),
2771 .help = "The flow index ID to use",
2773 .category = FIO_OPT_C_IO,
2774 .group = FIO_OPT_G_IO_FLOW,
2778 .lname = "I/O flow weight",
2779 .type = FIO_OPT_INT,
2780 .off1 = td_var_offset(flow),
2781 .help = "Weight for flow control of this job",
2782 .parent = "flow_id",
2785 .category = FIO_OPT_C_IO,
2786 .group = FIO_OPT_G_IO_FLOW,
2789 .name = "flow_watermark",
2790 .lname = "I/O flow watermark",
2791 .type = FIO_OPT_INT,
2792 .off1 = td_var_offset(flow_watermark),
2793 .help = "High watermark for flow control. This option"
2794 " should be set to the same value for all threads"
2795 " with non-zero flow.",
2796 .parent = "flow_id",
2799 .category = FIO_OPT_C_IO,
2800 .group = FIO_OPT_G_IO_FLOW,
2803 .name = "flow_sleep",
2804 .lname = "I/O flow sleep",
2805 .type = FIO_OPT_INT,
2806 .off1 = td_var_offset(flow_sleep),
2807 .help = "How many microseconds to sleep after being held"
2808 " back by the flow control mechanism",
2809 .parent = "flow_id",
2812 .category = FIO_OPT_C_IO,
2813 .group = FIO_OPT_G_IO_FLOW,
2820 static void add_to_lopt(struct option *lopt, struct fio_option *o,
2821 const char *name, int val)
2823 lopt->name = (char *) name;
2825 if (o->type == FIO_OPT_STR_SET)
2826 lopt->has_arg = no_argument;
2828 lopt->has_arg = required_argument;
2831 static void options_to_lopts(struct fio_option *opts,
2832 struct option *long_options,
2833 int i, int option_type)
2835 struct fio_option *o = &opts[0];
2837 add_to_lopt(&long_options[i], o, o->name, option_type);
2840 add_to_lopt(&long_options[i], o, o->alias, option_type);
2845 assert(i < FIO_NR_OPTIONS);
2849 void fio_options_set_ioengine_opts(struct option *long_options,
2850 struct thread_data *td)
2855 while (long_options[i].name) {
2856 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
2857 memset(&long_options[i], 0, sizeof(*long_options));
2864 * Just clear out the prior ioengine options.
2869 options_to_lopts(td->io_ops->options, long_options, i,
2870 FIO_GETOPT_IOENGINE);
2873 void fio_options_dup_and_init(struct option *long_options)
2877 options_init(fio_options);
2880 while (long_options[i].name)
2883 options_to_lopts(fio_options, long_options, i, FIO_GETOPT_JOB);
2886 struct fio_keyword {
2892 static struct fio_keyword fio_keywords[] = {
2894 .word = "$pagesize",
2895 .desc = "Page size in the system",
2898 .word = "$mb_memory",
2899 .desc = "Megabytes of memory online",
2903 .desc = "Number of CPUs online in the system",
2910 void fio_keywords_init(void)
2912 unsigned long long mb_memory;
2916 sprintf(buf, "%lu", page_size);
2917 fio_keywords[0].replace = strdup(buf);
2919 mb_memory = os_phys_mem() / (1024 * 1024);
2920 sprintf(buf, "%llu", mb_memory);
2921 fio_keywords[1].replace = strdup(buf);
2924 sprintf(buf, "%lu", l);
2925 fio_keywords[2].replace = strdup(buf);
2930 static char *bc_calc(char *str)
2932 char buf[128], *tmp;
2937 * No math, just return string
2939 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
2940 !strchr(str, '/')) || strchr(str, '\''))
2944 * Split option from value, we only need to calculate the value
2946 tmp = strchr(str, '=');
2953 * Prevent buffer overflows; such a case isn't reasonable anyway
2955 if (strlen(str) >= 128 || strlen(tmp) > 100)
2958 sprintf(buf, "which %s > /dev/null", BC_APP);
2960 log_err("fio: bc is needed for performing math\n");
2964 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
2965 f = popen(buf, "r");
2969 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
2974 buf[(tmp - str) + ret - 1] = '\0';
2975 memcpy(buf, str, tmp - str);
2981 * Return a copy of the input string with substrings of the form ${VARNAME}
2982 * substituted with the value of the environment variable VARNAME. The
2983 * substitution always occurs, even if VARNAME is empty or the corresponding
2984 * environment variable undefined.
2986 static char *option_dup_subs(const char *opt)
2988 char out[OPT_LEN_MAX+1];
2989 char in[OPT_LEN_MAX+1];
2992 char *ch1, *ch2, *env;
2993 ssize_t nchr = OPT_LEN_MAX;
2996 if (strlen(opt) + 1 > OPT_LEN_MAX) {
2997 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
3001 in[OPT_LEN_MAX] = '\0';
3002 strncpy(in, opt, OPT_LEN_MAX);
3004 while (*inptr && nchr > 0) {
3005 if (inptr[0] == '$' && inptr[1] == '{') {
3006 ch2 = strchr(inptr, '}');
3007 if (ch2 && inptr+1 < ch2) {
3014 envlen = strlen(env);
3015 if (envlen <= nchr) {
3016 memcpy(outptr, env, envlen);
3026 *outptr++ = *inptr++;
3035 * Look for reserved variable names and replace them with real values
3037 static char *fio_keyword_replace(char *opt)
3043 for (i = 0; fio_keywords[i].word != NULL; i++) {
3044 struct fio_keyword *kw = &fio_keywords[i];
3046 while ((s = strstr(opt, kw->word)) != NULL) {
3047 char *new = malloc(strlen(opt) + 1);
3053 * Copy part of the string before the keyword and
3054 * sprintf() the replacement after it.
3056 memcpy(new, opt, olen);
3057 len = sprintf(new + olen, "%s", kw->replace);
3060 * If there's more in the original string, copy that
3063 opt += strlen(kw->word) + olen;
3065 memcpy(new + olen + len, opt, opt - o_org - 1);
3068 * replace opt and free the old opt
3078 * Check for potential math and invoke bc, if possible
3086 static char **dup_and_sub_options(char **opts, int num_opts)
3089 char **opts_copy = malloc(num_opts * sizeof(*opts));
3090 for (i = 0; i < num_opts; i++) {
3091 opts_copy[i] = option_dup_subs(opts[i]);
3094 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
3099 int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
3101 int i, ret, unknown;
3104 sort_options(opts, fio_options, num_opts);
3105 opts_copy = dup_and_sub_options(opts, num_opts);
3107 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
3108 struct fio_option *o;
3109 int newret = parse_option(opts_copy[i], opts[i], fio_options,
3118 opts_copy[i] = NULL;
3125 ret |= ioengine_load(td);
3127 sort_options(opts_copy, td->io_ops->options, num_opts);
3130 for (i = 0; i < num_opts; i++) {
3131 struct fio_option *o = NULL;
3137 newret = parse_option(opts_copy[i], opts[i],
3138 td->io_ops->options, &o,
3143 log_err("Bad option <%s>\n", opts[i]);
3146 opts_copy[i] = NULL;
3154 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
3156 return parse_cmd_option(opt, val, fio_options, td);
3159 int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
3162 return parse_cmd_option(opt, val, td->io_ops->options, td);
3165 void fio_fill_default_options(struct thread_data *td)
3167 fill_default_options(td, fio_options);
3170 int fio_show_option_help(const char *opt)
3172 return show_cmd_help(fio_options, opt);
3175 void options_mem_dupe(void *data, struct fio_option *options)
3177 struct fio_option *o;
3180 for (o = &options[0]; o->name; o++) {
3181 if (o->type != FIO_OPT_STR_STORE)
3184 ptr = td_var(data, o->off1);
3186 *ptr = strdup(*ptr);
3191 * dupe FIO_OPT_STR_STORE options
3193 void fio_options_mem_dupe(struct thread_data *td)
3195 options_mem_dupe(&td->o, fio_options);
3197 if (td->eo && td->io_ops) {
3198 void *oldeo = td->eo;
3200 td->eo = malloc(td->io_ops->option_struct_size);
3201 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
3202 options_mem_dupe(td->eo, td->io_ops->options);
3206 unsigned int fio_get_kb_base(void *data)
3208 struct thread_options *o = data;
3209 unsigned int kb_base = 0;
3212 kb_base = o->kb_base;
3219 int add_option(struct fio_option *o)
3221 struct fio_option *__o;
3230 memcpy(&fio_options[opt_index], o, sizeof(*o));
3234 void invalidate_profile_options(const char *prof_name)
3236 struct fio_option *o;
3240 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
3241 o->type = FIO_OPT_INVALID;
3242 o->prof_name = NULL;
3248 void add_opt_posval(const char *optname, const char *ival, const char *help)
3250 struct fio_option *o;
3253 o = find_option(fio_options, optname);
3257 for (i = 0; i < PARSE_MAX_VP; i++) {
3258 if (o->posval[i].ival)
3261 o->posval[i].ival = ival;
3262 o->posval[i].help = help;
3267 void del_opt_posval(const char *optname, const char *ival)
3269 struct fio_option *o;
3272 o = find_option(fio_options, optname);
3276 for (i = 0; i < PARSE_MAX_VP; i++) {
3277 if (!o->posval[i].ival)
3279 if (strcmp(o->posval[i].ival, ival))
3282 o->posval[i].ival = NULL;
3283 o->posval[i].help = NULL;
3287 void fio_options_free(struct thread_data *td)
3289 options_free(fio_options, td);
3290 if (td->eo && td->io_ops && td->io_ops->options) {
3291 options_free(td->io_ops->options, td->eo);
3297 struct fio_option *fio_option_find(const char *name)
3299 return find_option(fio_options, name);