18 #include "crc/crc32c.h"
20 char client_sockaddr_str[INET6_ADDRSTRLEN] = {0};
23 * Check if mmap/mmaphuge has a :/foo/bar/file at the end. If so, return that.
25 static char *get_opt_postfix(const char *str)
27 char *p = strstr(str, ":");
33 strip_blank_front(&p);
38 static int converthexchartoint(char a)
58 static int bs_cmp(const void *p1, const void *p2)
60 const struct bssplit *bsp1 = p1;
61 const struct bssplit *bsp2 = p2;
63 return bsp1->perc < bsp2->perc;
66 static int bssplit_ddir(struct thread_options *o, int ddir, char *str)
68 struct bssplit *bssplit;
69 unsigned int i, perc, perc_missing;
70 unsigned int max_bs, min_bs;
74 o->bssplit_nr[ddir] = 4;
75 bssplit = malloc(4 * sizeof(struct bssplit));
80 while ((fname = strsep(&str, ":")) != NULL) {
87 * grow struct buffer, if needed
89 if (i == o->bssplit_nr[ddir]) {
90 o->bssplit_nr[ddir] <<= 1;
91 bssplit = realloc(bssplit, o->bssplit_nr[ddir]
92 * sizeof(struct bssplit));
95 perc_str = strstr(fname, "/");
99 perc = atoi(perc_str);
107 if (str_to_decimal(fname, &val, 1, o, 0, 0)) {
108 log_err("fio: bssplit conversion failed\n");
119 bssplit[i].perc = perc;
123 o->bssplit_nr[ddir] = i;
126 * Now check if the percentages add up, and how much is missing
128 perc = perc_missing = 0;
129 for (i = 0; i < o->bssplit_nr[ddir]; i++) {
130 struct bssplit *bsp = &bssplit[i];
132 if (bsp->perc == -1U)
138 if (perc > 100 && perc_missing > 1) {
139 log_err("fio: bssplit percentages add to more than 100%%\n");
145 * If values didn't have a percentage set, divide the remains between
149 if (perc_missing == 1 && o->bssplit_nr[ddir] == 1)
151 for (i = 0; i < o->bssplit_nr[ddir]; i++) {
152 struct bssplit *bsp = &bssplit[i];
154 if (bsp->perc == -1U)
155 bsp->perc = (100 - perc) / perc_missing;
159 o->min_bs[ddir] = min_bs;
160 o->max_bs[ddir] = max_bs;
163 * now sort based on percentages, for ease of lookup
165 qsort(bssplit, o->bssplit_nr[ddir], sizeof(struct bssplit), bs_cmp);
166 o->bssplit[ddir] = bssplit;
170 static int str_bssplit_cb(void *data, const char *input)
172 struct thread_data *td = data;
173 char *str, *p, *odir, *ddir;
179 p = str = strdup(input);
181 strip_blank_front(&str);
182 strip_blank_end(str);
184 odir = strchr(str, ',');
186 ddir = strchr(odir + 1, ',');
188 ret = bssplit_ddir(&td->o, DDIR_TRIM, ddir + 1);
194 op = strdup(odir + 1);
195 ret = bssplit_ddir(&td->o, DDIR_TRIM, op);
200 ret = bssplit_ddir(&td->o, DDIR_WRITE, odir + 1);
203 ret = bssplit_ddir(&td->o, DDIR_READ, str);
209 ret = bssplit_ddir(&td->o, DDIR_WRITE, op);
214 ret = bssplit_ddir(&td->o, DDIR_TRIM, op);
217 ret = bssplit_ddir(&td->o, DDIR_READ, str);
224 static int str2error(char *str)
226 const char *err[] = { "EPERM", "ENOENT", "ESRCH", "EINTR", "EIO",
227 "ENXIO", "E2BIG", "ENOEXEC", "EBADF",
228 "ECHILD", "EAGAIN", "ENOMEM", "EACCES",
229 "EFAULT", "ENOTBLK", "EBUSY", "EEXIST",
230 "EXDEV", "ENODEV", "ENOTDIR", "EISDIR",
231 "EINVAL", "ENFILE", "EMFILE", "ENOTTY",
232 "ETXTBSY","EFBIG", "ENOSPC", "ESPIPE",
233 "EROFS","EMLINK", "EPIPE", "EDOM", "ERANGE" };
234 int i = 0, num = sizeof(err) / sizeof(void *);
237 if (!strcmp(err[i], str))
244 static int ignore_error_type(struct thread_data *td, int etype, char *str)
250 if (etype >= ERROR_TYPE_CNT) {
251 log_err("Illegal error type\n");
255 td->o.ignore_error_nr[etype] = 4;
256 error = malloc(4 * sizeof(struct bssplit));
259 while ((fname = strsep(&str, ":")) != NULL) {
265 * grow struct buffer, if needed
267 if (i == td->o.ignore_error_nr[etype]) {
268 td->o.ignore_error_nr[etype] <<= 1;
269 error = realloc(error, td->o.ignore_error_nr[etype]
272 if (fname[0] == 'E') {
273 error[i] = str2error(fname);
275 error[i] = atoi(fname);
277 error[i] = -error[i];
280 log_err("Unknown error %s, please use number value \n",
288 td->o.continue_on_error |= 1 << etype;
289 td->o.ignore_error_nr[etype] = i;
290 td->o.ignore_error[etype] = error;
298 static int str_ignore_error_cb(void *data, const char *input)
300 struct thread_data *td = data;
302 int type = 0, ret = 1;
307 p = str = strdup(input);
309 strip_blank_front(&str);
310 strip_blank_end(str);
316 ret = ignore_error_type(td, type, p);
326 static int str_rw_cb(void *data, const char *str)
328 struct thread_data *td = data;
329 struct thread_options *o = &td->o;
338 nr = get_opt_postfix(str);
343 o->ddir_seq_nr = atoi(nr);
347 if (str_to_decimal(nr, &val, 1, o, 0, 0)) {
348 log_err("fio: rw postfix parsing failed\n");
353 o->ddir_seq_add = val;
360 static int str_mem_cb(void *data, const char *mem)
362 struct thread_data *td = data;
364 if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP)
365 td->o.mmapfile = get_opt_postfix(mem);
370 static int fio_clock_source_cb(void *data, const char *str)
372 struct thread_data *td = data;
374 fio_clock_source = td->o.clocksource;
375 fio_clock_source_set = 1;
380 static int str_rwmix_read_cb(void *data, unsigned long long *val)
382 struct thread_data *td = data;
384 td->o.rwmix[DDIR_READ] = *val;
385 td->o.rwmix[DDIR_WRITE] = 100 - *val;
389 static int str_rwmix_write_cb(void *data, unsigned long long *val)
391 struct thread_data *td = data;
393 td->o.rwmix[DDIR_WRITE] = *val;
394 td->o.rwmix[DDIR_READ] = 100 - *val;
398 static int str_exitall_cb(void)
400 exitall_on_terminate = 1;
404 #ifdef FIO_HAVE_CPU_AFFINITY
405 int fio_cpus_split(os_cpu_mask_t *mask, unsigned int cpu_index)
407 unsigned int i, index, cpus_in_mask;
408 const long max_cpu = cpus_online();
410 cpus_in_mask = fio_cpu_count(mask);
411 cpu_index = cpu_index % cpus_in_mask;
414 for (i = 0; i < max_cpu; i++) {
415 if (!fio_cpu_isset(mask, i))
418 if (cpu_index != index)
419 fio_cpu_clear(mask, i);
424 return fio_cpu_count(mask);
427 static int str_cpumask_cb(void *data, unsigned long long *val)
429 struct thread_data *td = data;
437 ret = fio_cpuset_init(&td->o.cpumask);
439 log_err("fio: cpuset_init failed\n");
440 td_verror(td, ret, "fio_cpuset_init");
444 max_cpu = cpus_online();
446 for (i = 0; i < sizeof(int) * 8; i++) {
447 if ((1 << i) & *val) {
449 log_err("fio: CPU %d too large (max=%ld)\n", i,
453 dprint(FD_PARSE, "set cpu allowed %d\n", i);
454 fio_cpu_set(&td->o.cpumask, i);
461 static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask,
468 ret = fio_cpuset_init(mask);
470 log_err("fio: cpuset_init failed\n");
471 td_verror(td, ret, "fio_cpuset_init");
475 p = str = strdup(input);
477 strip_blank_front(&str);
478 strip_blank_end(str);
480 max_cpu = cpus_online();
482 while ((cpu = strsep(&str, ",")) != NULL) {
491 while ((cpu2 = strsep(&str2, "-")) != NULL) {
501 while (icpu <= icpu2) {
502 if (icpu >= FIO_MAX_CPUS) {
503 log_err("fio: your OS only supports up to"
504 " %d CPUs\n", (int) FIO_MAX_CPUS);
508 if (icpu >= max_cpu) {
509 log_err("fio: CPU %d too large (max=%ld)\n",
515 dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
516 fio_cpu_set(mask, icpu);
527 static int str_cpus_allowed_cb(void *data, const char *input)
529 struct thread_data *td = data;
534 return set_cpus_allowed(td, &td->o.cpumask, input);
537 static int str_verify_cpus_allowed_cb(void *data, const char *input)
539 struct thread_data *td = data;
541 return set_cpus_allowed(td, &td->o.verify_cpumask, input);
545 #ifdef CONFIG_LIBNUMA
546 static int str_numa_cpunodes_cb(void *data, char *input)
548 struct thread_data *td = data;
549 struct bitmask *verify_bitmask;
554 /* numa_parse_nodestring() parses a character string list
555 * of nodes into a bit mask. The bit mask is allocated by
556 * numa_allocate_nodemask(), so it should be freed by
557 * numa_free_nodemask().
559 verify_bitmask = numa_parse_nodestring(input);
560 if (verify_bitmask == NULL) {
561 log_err("fio: numa_parse_nodestring failed\n");
562 td_verror(td, 1, "str_numa_cpunodes_cb");
565 numa_free_nodemask(verify_bitmask);
567 td->o.numa_cpunodes = strdup(input);
571 static int str_numa_mpol_cb(void *data, char *input)
573 struct thread_data *td = data;
574 const char * const policy_types[] =
575 { "default", "prefer", "bind", "interleave", "local", NULL };
578 struct bitmask *verify_bitmask;
583 nodelist = strchr(input, ':');
585 /* NUL-terminate mode */
589 for (i = 0; i <= MPOL_LOCAL; i++) {
590 if (!strcmp(input, policy_types[i])) {
591 td->o.numa_mem_mode = i;
595 if (i > MPOL_LOCAL) {
596 log_err("fio: memory policy should be: default, prefer, bind, interleave, local\n");
600 switch (td->o.numa_mem_mode) {
603 * Insist on a nodelist of one node only
606 char *rest = nodelist;
607 while (isdigit(*rest))
610 log_err("fio: one node only for \'prefer\'\n");
614 log_err("fio: one node is needed for \'prefer\'\n");
618 case MPOL_INTERLEAVE:
620 * Default to online nodes with memory if no nodelist
623 nodelist = strdup("all");
628 * Don't allow a nodelist
631 log_err("fio: NO nodelist for \'local\'\n");
637 * Insist on a nodelist
640 log_err("fio: a nodelist is needed for \'bind\'\n");
647 /* numa_parse_nodestring() parses a character string list
648 * of nodes into a bit mask. The bit mask is allocated by
649 * numa_allocate_nodemask(), so it should be freed by
650 * numa_free_nodemask().
652 switch (td->o.numa_mem_mode) {
654 td->o.numa_mem_prefer_node = atoi(nodelist);
656 case MPOL_INTERLEAVE:
658 verify_bitmask = numa_parse_nodestring(nodelist);
659 if (verify_bitmask == NULL) {
660 log_err("fio: numa_parse_nodestring failed\n");
661 td_verror(td, 1, "str_numa_memnodes_cb");
664 td->o.numa_memnodes = strdup(nodelist);
665 numa_free_nodemask(verify_bitmask);
680 static int str_fst_cb(void *data, const char *str)
682 struct thread_data *td = data;
683 char *nr = get_opt_postfix(str);
685 td->file_service_nr = 1;
687 td->file_service_nr = atoi(nr);
694 #ifdef CONFIG_SYNC_FILE_RANGE
695 static int str_sfr_cb(void *data, const char *str)
697 struct thread_data *td = data;
698 char *nr = get_opt_postfix(str);
700 td->sync_file_range_nr = 1;
702 td->sync_file_range_nr = atoi(nr);
710 static int str_random_distribution_cb(void *data, const char *str)
712 struct thread_data *td = data;
719 if (td->o.random_distribution == FIO_RAND_DIST_ZIPF)
721 else if (td->o.random_distribution == FIO_RAND_DIST_PARETO)
722 val = FIO_DEF_PARETO;
723 else if (td->o.random_distribution == FIO_RAND_DIST_GAUSS)
728 nr = get_opt_postfix(str);
729 if (nr && !str_to_float(nr, &val, 0)) {
730 log_err("fio: random postfix parsing failed\n");
737 if (td->o.random_distribution == FIO_RAND_DIST_ZIPF) {
739 log_err("fio: zipf theta must different than 1.0\n");
742 td->o.zipf_theta.u.f = val;
743 } else if (td->o.random_distribution == FIO_RAND_DIST_PARETO) {
744 if (val <= 0.00 || val >= 1.00) {
745 log_err("fio: pareto input out of range (0 < input < 1.0)\n");
748 td->o.pareto_h.u.f = val;
750 if (val <= 0.00 || val >= 100.0) {
751 log_err("fio: normal deviation out of range (0 < input < 100.0)\n");
754 td->o.gauss_dev.u.f = val;
761 * Return next name in the string. Files are separated with ':'. If the ':'
762 * is escaped with a '\', then that ':' is part of the filename and does not
763 * indicate a new file.
765 static char *get_next_name(char **ptr)
770 if (!str || !strlen(str))
776 * No colon, we are done
778 p = strchr(str, ':');
785 * We got a colon, but it's the first character. Skip and
793 if (*(p - 1) != '\\') {
799 memmove(p - 1, p, strlen(p) + 1);
807 static int get_max_name_idx(char *input)
809 unsigned int cur_idx;
812 p = str = strdup(input);
813 for (cur_idx = 0; ; cur_idx++)
814 if (get_next_name(&str) == NULL)
822 * Returns the directory at the index, indexes > entires will be
823 * assigned via modulo division of the index
825 int set_name_idx(char *target, char *input, int index)
827 unsigned int cur_idx;
829 char *fname, *str, *p;
831 p = str = strdup(input);
833 index %= get_max_name_idx(input);
834 for (cur_idx = 0; cur_idx <= index; cur_idx++)
835 fname = get_next_name(&str);
837 if (client_sockaddr_str[0]) {
838 len = sprintf(target, "%s/%s.", fname, client_sockaddr_str);
840 len = sprintf(target, "%s/", fname);
848 static int str_filename_cb(void *data, const char *input)
850 struct thread_data *td = data;
851 char *fname, *str, *p;
853 p = str = strdup(input);
855 strip_blank_front(&str);
856 strip_blank_end(str);
858 if (!td->files_index)
861 while ((fname = get_next_name(&str)) != NULL) {
864 add_file(td, fname, 0, 1);
871 static int str_directory_cb(void *data, const char fio_unused *unused)
873 struct thread_data *td = data;
875 char *dirname, *str, *p;
881 p = str = strdup(td->o.directory);
882 while ((dirname = get_next_name(&str)) != NULL) {
883 if (lstat(dirname, &sb) < 0) {
886 log_err("fio: %s is not a directory\n", dirname);
887 td_verror(td, ret, "lstat");
890 if (!S_ISDIR(sb.st_mode)) {
891 log_err("fio: %s is not a directory\n", dirname);
902 static int str_opendir_cb(void *data, const char fio_unused *str)
904 struct thread_data *td = data;
909 if (!td->files_index)
912 return add_dir_files(td, td->o.opendir);
915 static int pattern_cb(char *pattern, unsigned int max_size,
916 const char *input, unsigned int *pattern_bytes)
919 int i = 0, j = 0, len, k, base = 10;
920 uint32_t pattern_length;
924 * Check if it's a string input
926 loc1 = strchr(input, '\"');
930 if (*loc1 == '\0' || *loc1 == '\"')
935 } while (i < max_size);
944 * No string, find out if it's decimal or hexidecimal
946 loc1 = strstr(input, "0x");
947 loc2 = strstr(input, "0X");
950 off = strtol(input, NULL, base);
951 if (off != LONG_MAX || errno != ERANGE) {
953 pattern[i] = off & 0xff;
962 j = loc1 - input + 2;
964 j = loc2 - input + 2;
967 if (len - j < max_size * 2) {
969 off = converthexchartoint(input[k--]);
971 off += (converthexchartoint(input[k--])
973 pattern[i++] = (char) off;
979 * Fill the pattern all the way to the end. This greatly reduces
980 * the number of memcpy's we have to do when verifying the IO.
984 while (i > 1 && i * 2 <= max_size) {
985 memcpy(&pattern[i], &pattern[0], i);
990 * Fill remainder, if the pattern multiple ends up not being
993 while (i > 1 && i < max_size) {
994 unsigned int b = min(pattern_length, max_size - i);
996 memcpy(&pattern[i], &pattern[0], b);
1002 * The code in verify_io_u_pattern assumes a single byte
1003 * pattern fills the whole verify pattern buffer.
1005 memset(pattern, pattern[0], max_size);
1012 static int str_buffer_pattern_cb(void *data, const char *input)
1014 struct thread_data *td = data;
1017 ret = pattern_cb(td->o.buffer_pattern, MAX_PATTERN_SIZE, input,
1018 &td->o.buffer_pattern_bytes);
1020 if (!ret && td->o.buffer_pattern_bytes) {
1021 if (!td->o.compress_percentage)
1022 td->o.refill_buffers = 0;
1023 td->o.scramble_buffers = 0;
1024 td->o.zero_buffers = 0;
1026 log_err("fio: failed parsing pattern `%s`\n", input);
1033 static int str_buffer_compress_cb(void *data, unsigned long long *il)
1035 struct thread_data *td = data;
1037 td->flags |= TD_F_COMPRESS;
1038 td->o.compress_percentage = *il;
1042 static int str_dedupe_cb(void *data, unsigned long long *il)
1044 struct thread_data *td = data;
1046 td->flags |= TD_F_COMPRESS;
1047 td->o.dedupe_percentage = *il;
1048 td->o.refill_buffers = 1;
1052 static int str_verify_pattern_cb(void *data, const char *input)
1054 struct thread_data *td = data;
1057 ret = pattern_cb(td->o.verify_pattern, MAX_PATTERN_SIZE, input,
1058 &td->o.verify_pattern_bytes);
1061 * VERIFY_META could already be set
1063 if (!ret && td->o.verify == VERIFY_NONE)
1064 td->o.verify = VERIFY_PATTERN;
1069 static int str_gtod_reduce_cb(void *data, int *il)
1071 struct thread_data *td = data;
1074 td->o.disable_lat = !!val;
1075 td->o.disable_clat = !!val;
1076 td->o.disable_slat = !!val;
1077 td->o.disable_bw = !!val;
1078 td->o.clat_percentiles = !val;
1080 td->tv_cache_mask = 63;
1085 static int str_size_cb(void *data, unsigned long long *__val)
1087 struct thread_data *td = data;
1088 unsigned long long v = *__val;
1090 if (parse_is_percent(v)) {
1092 td->o.size_percent = -1ULL - v;
1099 static int rw_verify(struct fio_option *o, void *data)
1101 struct thread_data *td = data;
1103 if (read_only && td_write(td)) {
1104 log_err("fio: job <%s> has write bit set, but fio is in"
1105 " read-only mode\n", td->o.name);
1112 static int gtod_cpu_verify(struct fio_option *o, void *data)
1114 #ifndef FIO_HAVE_CPU_AFFINITY
1115 struct thread_data *td = data;
1117 if (td->o.gtod_cpu) {
1118 log_err("fio: platform must support CPU affinity for"
1119 "gettimeofday() offloading\n");
1130 static struct opt_group fio_opt_groups[] = {
1133 .mask = FIO_OPT_C_GENERAL,
1137 .mask = FIO_OPT_C_IO,
1141 .mask = FIO_OPT_C_FILE,
1144 .name = "Statistics",
1145 .mask = FIO_OPT_C_STAT,
1149 .mask = FIO_OPT_C_LOG,
1153 .mask = FIO_OPT_C_PROFILE,
1160 static struct opt_group *__opt_group_from_mask(struct opt_group *ogs, unsigned int *mask,
1161 unsigned int inv_mask)
1163 struct opt_group *og;
1166 if (*mask == inv_mask || !*mask)
1169 for (i = 0; ogs[i].name; i++) {
1172 if (*mask & og->mask) {
1173 *mask &= ~(og->mask);
1181 struct opt_group *opt_group_from_mask(unsigned int *mask)
1183 return __opt_group_from_mask(fio_opt_groups, mask, FIO_OPT_C_INVALID);
1186 static struct opt_group fio_opt_cat_groups[] = {
1188 .name = "Latency profiling",
1189 .mask = FIO_OPT_G_LATPROF,
1193 .mask = FIO_OPT_G_RATE,
1197 .mask = FIO_OPT_G_ZONE,
1200 .name = "Read/write mix",
1201 .mask = FIO_OPT_G_RWMIX,
1205 .mask = FIO_OPT_G_VERIFY,
1209 .mask = FIO_OPT_G_TRIM,
1212 .name = "I/O Logging",
1213 .mask = FIO_OPT_G_IOLOG,
1216 .name = "I/O Depth",
1217 .mask = FIO_OPT_G_IO_DEPTH,
1221 .mask = FIO_OPT_G_IO_FLOW,
1224 .name = "Description",
1225 .mask = FIO_OPT_G_DESC,
1229 .mask = FIO_OPT_G_FILENAME,
1232 .name = "General I/O",
1233 .mask = FIO_OPT_G_IO_BASIC,
1237 .mask = FIO_OPT_G_CGROUP,
1241 .mask = FIO_OPT_G_RUNTIME,
1245 .mask = FIO_OPT_G_PROCESS,
1248 .name = "Job credentials / priority",
1249 .mask = FIO_OPT_G_CRED,
1252 .name = "Clock settings",
1253 .mask = FIO_OPT_G_CLOCK,
1257 .mask = FIO_OPT_G_IO_TYPE,
1260 .name = "I/O Thinktime",
1261 .mask = FIO_OPT_G_THINKTIME,
1264 .name = "Randomizations",
1265 .mask = FIO_OPT_G_RANDOM,
1268 .name = "I/O buffers",
1269 .mask = FIO_OPT_G_IO_BUF,
1272 .name = "Tiobench profile",
1273 .mask = FIO_OPT_G_TIOBENCH,
1277 .mask = FIO_OPT_G_MTD,
1285 struct opt_group *opt_group_cat_from_mask(unsigned int *mask)
1287 return __opt_group_from_mask(fio_opt_cat_groups, mask, FIO_OPT_G_INVALID);
1291 * Map of job/command line options
1293 struct fio_option fio_options[FIO_MAX_OPTS] = {
1295 .name = "description",
1296 .lname = "Description of job",
1297 .type = FIO_OPT_STR_STORE,
1298 .off1 = td_var_offset(description),
1299 .help = "Text job description",
1300 .category = FIO_OPT_C_GENERAL,
1301 .group = FIO_OPT_G_DESC,
1305 .lname = "Job name",
1306 .type = FIO_OPT_STR_STORE,
1307 .off1 = td_var_offset(name),
1308 .help = "Name of this job",
1309 .category = FIO_OPT_C_GENERAL,
1310 .group = FIO_OPT_G_DESC,
1314 .lname = "Filename(s)",
1315 .type = FIO_OPT_STR_STORE,
1316 .off1 = td_var_offset(filename),
1317 .cb = str_filename_cb,
1318 .prio = -1, /* must come after "directory" */
1319 .help = "File(s) to use for the workload",
1320 .category = FIO_OPT_C_FILE,
1321 .group = FIO_OPT_G_FILENAME,
1324 .name = "directory",
1325 .lname = "Directory",
1326 .type = FIO_OPT_STR_STORE,
1327 .off1 = td_var_offset(directory),
1328 .cb = str_directory_cb,
1329 .help = "Directory to store files in",
1330 .category = FIO_OPT_C_FILE,
1331 .group = FIO_OPT_G_FILENAME,
1334 .name = "filename_format",
1335 .type = FIO_OPT_STR_STORE,
1336 .off1 = td_var_offset(filename_format),
1337 .prio = -1, /* must come after "directory" */
1338 .help = "Override default $jobname.$jobnum.$filenum naming",
1339 .def = "$jobname.$jobnum.$filenum",
1340 .category = FIO_OPT_C_FILE,
1341 .group = FIO_OPT_G_FILENAME,
1345 .lname = "Lockfile",
1346 .type = FIO_OPT_STR,
1347 .off1 = td_var_offset(file_lock_mode),
1348 .help = "Lock file when doing IO to it",
1350 .parent = "filename",
1353 .category = FIO_OPT_C_FILE,
1354 .group = FIO_OPT_G_FILENAME,
1357 .oval = FILE_LOCK_NONE,
1358 .help = "No file locking",
1360 { .ival = "exclusive",
1361 .oval = FILE_LOCK_EXCLUSIVE,
1362 .help = "Exclusive file lock",
1365 .ival = "readwrite",
1366 .oval = FILE_LOCK_READWRITE,
1367 .help = "Read vs write lock",
1373 .lname = "Open directory",
1374 .type = FIO_OPT_STR_STORE,
1375 .off1 = td_var_offset(opendir),
1376 .cb = str_opendir_cb,
1377 .help = "Recursively add files from this directory and down",
1378 .category = FIO_OPT_C_FILE,
1379 .group = FIO_OPT_G_FILENAME,
1383 .lname = "Read/write",
1384 .alias = "readwrite",
1385 .type = FIO_OPT_STR,
1387 .off1 = td_var_offset(td_ddir),
1388 .help = "IO direction",
1390 .verify = rw_verify,
1391 .category = FIO_OPT_C_IO,
1392 .group = FIO_OPT_G_IO_BASIC,
1395 .oval = TD_DDIR_READ,
1396 .help = "Sequential read",
1399 .oval = TD_DDIR_WRITE,
1400 .help = "Sequential write",
1403 .oval = TD_DDIR_TRIM,
1404 .help = "Sequential trim",
1406 { .ival = "randread",
1407 .oval = TD_DDIR_RANDREAD,
1408 .help = "Random read",
1410 { .ival = "randwrite",
1411 .oval = TD_DDIR_RANDWRITE,
1412 .help = "Random write",
1414 { .ival = "randtrim",
1415 .oval = TD_DDIR_RANDTRIM,
1416 .help = "Random trim",
1420 .help = "Sequential read and write mix",
1422 { .ival = "readwrite",
1424 .help = "Sequential read and write mix",
1427 .oval = TD_DDIR_RANDRW,
1428 .help = "Random read and write mix"
1430 { .ival = "trimwrite",
1431 .oval = TD_DDIR_TRIMWRITE,
1432 .help = "Trim and write mix, trims preceding writes"
1437 .name = "rw_sequencer",
1438 .lname = "RW Sequencer",
1439 .type = FIO_OPT_STR,
1440 .off1 = td_var_offset(rw_seq),
1441 .help = "IO offset generator modifier",
1442 .def = "sequential",
1443 .category = FIO_OPT_C_IO,
1444 .group = FIO_OPT_G_IO_BASIC,
1446 { .ival = "sequential",
1448 .help = "Generate sequential offsets",
1450 { .ival = "identical",
1451 .oval = RW_SEQ_IDENT,
1452 .help = "Generate identical offsets",
1459 .lname = "IO Engine",
1460 .type = FIO_OPT_STR_STORE,
1461 .off1 = td_var_offset(ioengine),
1462 .help = "IO engine to use",
1463 .def = FIO_PREFERRED_ENGINE,
1464 .category = FIO_OPT_C_IO,
1465 .group = FIO_OPT_G_IO_BASIC,
1468 .help = "Use read/write",
1471 .help = "Use pread/pwrite",
1474 .help = "Use readv/writev",
1476 #ifdef CONFIG_PWRITEV
1478 .help = "Use preadv/pwritev",
1481 #ifdef CONFIG_LIBAIO
1483 .help = "Linux native asynchronous IO",
1486 #ifdef CONFIG_POSIXAIO
1487 { .ival = "posixaio",
1488 .help = "POSIX asynchronous IO",
1491 #ifdef CONFIG_SOLARISAIO
1492 { .ival = "solarisaio",
1493 .help = "Solaris native asynchronous IO",
1496 #ifdef CONFIG_WINDOWSAIO
1497 { .ival = "windowsaio",
1498 .help = "Windows native asynchronous IO"
1503 .help = "Rados Block Device asynchronous IO"
1507 .help = "Memory mapped IO"
1509 #ifdef CONFIG_LINUX_SPLICE
1511 .help = "splice/vmsplice based IO",
1513 { .ival = "netsplice",
1514 .help = "splice/vmsplice to/from the network",
1517 #ifdef FIO_HAVE_SGIO
1519 .help = "SCSI generic v3 IO",
1523 .help = "Testing engine (no data transfer)",
1526 .help = "Network IO",
1529 .help = "CPU cycle burner engine",
1533 .help = "GUASI IO engine",
1536 #ifdef FIO_HAVE_BINJECT
1537 { .ival = "binject",
1538 .help = "binject direct inject block engine",
1543 .help = "RDMA IO engine",
1546 #ifdef CONFIG_FUSION_AW
1547 { .ival = "fusion-aw-sync",
1548 .help = "Fusion-io atomic write engine",
1551 #ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
1552 { .ival = "e4defrag",
1553 .help = "ext4 defrag engine",
1556 #ifdef CONFIG_LINUX_FALLOCATE
1558 .help = "fallocate() file based engine",
1563 .help = "Glusterfs libgfapi(sync) based engine"
1565 { .ival = "gfapi_async",
1566 .help = "Glusterfs libgfapi(async) based engine"
1569 #ifdef CONFIG_LIBHDFS
1570 { .ival = "libhdfs",
1571 .help = "Hadoop Distributed Filesystem (HDFS) engine"
1574 { .ival = "external",
1575 .help = "Load external engine (append name)",
1581 .lname = "IO Depth",
1582 .type = FIO_OPT_INT,
1583 .off1 = td_var_offset(iodepth),
1584 .help = "Number of IO buffers to keep in flight",
1588 .category = FIO_OPT_C_IO,
1589 .group = FIO_OPT_G_IO_BASIC,
1592 .name = "iodepth_batch",
1593 .lname = "IO Depth batch",
1594 .alias = "iodepth_batch_submit",
1595 .type = FIO_OPT_INT,
1596 .off1 = td_var_offset(iodepth_batch),
1597 .help = "Number of IO buffers to submit in one go",
1598 .parent = "iodepth",
1603 .category = FIO_OPT_C_IO,
1604 .group = FIO_OPT_G_IO_BASIC,
1607 .name = "iodepth_batch_complete",
1608 .lname = "IO Depth batch complete",
1609 .type = FIO_OPT_INT,
1610 .off1 = td_var_offset(iodepth_batch_complete),
1611 .help = "Number of IO buffers to retrieve in one go",
1612 .parent = "iodepth",
1617 .category = FIO_OPT_C_IO,
1618 .group = FIO_OPT_G_IO_BASIC,
1621 .name = "iodepth_low",
1622 .lname = "IO Depth batch low",
1623 .type = FIO_OPT_INT,
1624 .off1 = td_var_offset(iodepth_low),
1625 .help = "Low water mark for queuing depth",
1626 .parent = "iodepth",
1629 .category = FIO_OPT_C_IO,
1630 .group = FIO_OPT_G_IO_BASIC,
1633 .name = "io_submit_mode",
1634 .lname = "IO submit mode",
1635 .type = FIO_OPT_STR,
1636 .off1 = td_var_offset(io_submit_mode),
1637 .help = "How IO submissions and completions are done",
1639 .category = FIO_OPT_C_IO,
1640 .group = FIO_OPT_G_IO_BASIC,
1643 .oval = IO_MODE_INLINE,
1644 .help = "Submit and complete IO inline",
1646 { .ival = "offload",
1647 .oval = IO_MODE_OFFLOAD,
1648 .help = "Offload submit and complete to threads",
1655 .type = FIO_OPT_STR_VAL,
1657 .off1 = td_var_offset(size),
1658 .help = "Total size of device or files",
1659 .interval = 1024 * 1024,
1660 .category = FIO_OPT_C_IO,
1661 .group = FIO_OPT_G_INVALID,
1665 .alias = "io_limit",
1667 .type = FIO_OPT_STR_VAL,
1668 .off1 = td_var_offset(io_limit),
1669 .interval = 1024 * 1024,
1670 .category = FIO_OPT_C_IO,
1671 .group = FIO_OPT_G_INVALID,
1674 .name = "fill_device",
1675 .lname = "Fill device",
1677 .type = FIO_OPT_BOOL,
1678 .off1 = td_var_offset(fill_device),
1679 .help = "Write until an ENOSPC error occurs",
1681 .category = FIO_OPT_C_FILE,
1682 .group = FIO_OPT_G_INVALID,
1686 .lname = "File size",
1687 .type = FIO_OPT_STR_VAL,
1688 .off1 = td_var_offset(file_size_low),
1689 .off2 = td_var_offset(file_size_high),
1691 .help = "Size of individual files",
1692 .interval = 1024 * 1024,
1693 .category = FIO_OPT_C_FILE,
1694 .group = FIO_OPT_G_INVALID,
1697 .name = "file_append",
1698 .lname = "File append",
1699 .type = FIO_OPT_BOOL,
1700 .off1 = td_var_offset(file_append),
1701 .help = "IO will start at the end of the file(s)",
1703 .category = FIO_OPT_C_FILE,
1704 .group = FIO_OPT_G_INVALID,
1708 .lname = "IO offset",
1709 .alias = "fileoffset",
1710 .type = FIO_OPT_STR_VAL,
1711 .off1 = td_var_offset(start_offset),
1712 .help = "Start IO from this offset",
1714 .interval = 1024 * 1024,
1715 .category = FIO_OPT_C_IO,
1716 .group = FIO_OPT_G_INVALID,
1719 .name = "offset_increment",
1720 .lname = "IO offset increment",
1721 .type = FIO_OPT_STR_VAL,
1722 .off1 = td_var_offset(offset_increment),
1723 .help = "What is the increment from one offset to the next",
1727 .interval = 1024 * 1024,
1728 .category = FIO_OPT_C_IO,
1729 .group = FIO_OPT_G_INVALID,
1732 .name = "number_ios",
1733 .lname = "Number of IOs to perform",
1734 .type = FIO_OPT_STR_VAL,
1735 .off1 = td_var_offset(number_ios),
1736 .help = "Force job completion after this number of IOs",
1738 .category = FIO_OPT_C_IO,
1739 .group = FIO_OPT_G_INVALID,
1743 .lname = "Block size",
1744 .alias = "blocksize",
1745 .type = FIO_OPT_INT,
1746 .off1 = td_var_offset(bs[DDIR_READ]),
1747 .off2 = td_var_offset(bs[DDIR_WRITE]),
1748 .off3 = td_var_offset(bs[DDIR_TRIM]),
1750 .help = "Block size unit",
1755 .category = FIO_OPT_C_IO,
1756 .group = FIO_OPT_G_INVALID,
1760 .lname = "Block size align",
1761 .alias = "blockalign",
1762 .type = FIO_OPT_INT,
1763 .off1 = td_var_offset(ba[DDIR_READ]),
1764 .off2 = td_var_offset(ba[DDIR_WRITE]),
1765 .off3 = td_var_offset(ba[DDIR_TRIM]),
1767 .help = "IO block offset alignment",
1771 .category = FIO_OPT_C_IO,
1772 .group = FIO_OPT_G_INVALID,
1776 .lname = "Block size range",
1777 .alias = "blocksize_range",
1778 .type = FIO_OPT_RANGE,
1779 .off1 = td_var_offset(min_bs[DDIR_READ]),
1780 .off2 = td_var_offset(max_bs[DDIR_READ]),
1781 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
1782 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
1783 .off5 = td_var_offset(min_bs[DDIR_TRIM]),
1784 .off6 = td_var_offset(max_bs[DDIR_TRIM]),
1786 .help = "Set block size range (in more detail than bs)",
1790 .category = FIO_OPT_C_IO,
1791 .group = FIO_OPT_G_INVALID,
1795 .lname = "Block size split",
1796 .type = FIO_OPT_STR,
1797 .cb = str_bssplit_cb,
1798 .off1 = td_var_offset(bssplit),
1799 .help = "Set a specific mix of block sizes",
1802 .category = FIO_OPT_C_IO,
1803 .group = FIO_OPT_G_INVALID,
1806 .name = "bs_unaligned",
1807 .lname = "Block size unaligned",
1808 .alias = "blocksize_unaligned",
1809 .type = FIO_OPT_STR_SET,
1810 .off1 = td_var_offset(bs_unaligned),
1811 .help = "Don't sector align IO buffer sizes",
1814 .category = FIO_OPT_C_IO,
1815 .group = FIO_OPT_G_INVALID,
1818 .name = "bs_is_seq_rand",
1819 .lname = "Block size division is seq/random (not read/write)",
1820 .type = FIO_OPT_BOOL,
1821 .off1 = td_var_offset(bs_is_seq_rand),
1822 .help = "Consider any blocksize setting to be sequential,random",
1824 .parent = "blocksize",
1825 .category = FIO_OPT_C_IO,
1826 .group = FIO_OPT_G_INVALID,
1829 .name = "randrepeat",
1830 .lname = "Random repeatable",
1831 .type = FIO_OPT_BOOL,
1832 .off1 = td_var_offset(rand_repeatable),
1833 .help = "Use repeatable random IO pattern",
1837 .category = FIO_OPT_C_IO,
1838 .group = FIO_OPT_G_RANDOM,
1842 .lname = "The random generator seed",
1843 .type = FIO_OPT_STR_VAL,
1844 .off1 = td_var_offset(rand_seed),
1845 .help = "Set the random generator seed value",
1847 .category = FIO_OPT_C_IO,
1848 .group = FIO_OPT_G_RANDOM,
1851 .name = "use_os_rand",
1852 .lname = "Use OS random",
1853 .type = FIO_OPT_DEPRECATED,
1854 .off1 = td_var_offset(dep_use_os_rand),
1855 .category = FIO_OPT_C_IO,
1856 .group = FIO_OPT_G_RANDOM,
1859 .name = "norandommap",
1860 .lname = "No randommap",
1861 .type = FIO_OPT_STR_SET,
1862 .off1 = td_var_offset(norandommap),
1863 .help = "Accept potential duplicate random blocks",
1867 .category = FIO_OPT_C_IO,
1868 .group = FIO_OPT_G_RANDOM,
1871 .name = "softrandommap",
1872 .lname = "Soft randommap",
1873 .type = FIO_OPT_BOOL,
1874 .off1 = td_var_offset(softrandommap),
1875 .help = "Set norandommap if randommap allocation fails",
1876 .parent = "norandommap",
1879 .category = FIO_OPT_C_IO,
1880 .group = FIO_OPT_G_RANDOM,
1883 .name = "random_generator",
1884 .type = FIO_OPT_STR,
1885 .off1 = td_var_offset(random_generator),
1886 .help = "Type of random number generator to use",
1887 .def = "tausworthe",
1889 { .ival = "tausworthe",
1890 .oval = FIO_RAND_GEN_TAUSWORTHE,
1891 .help = "Strong Tausworthe generator",
1894 .oval = FIO_RAND_GEN_LFSR,
1895 .help = "Variable length LFSR",
1898 .category = FIO_OPT_C_IO,
1899 .group = FIO_OPT_G_RANDOM,
1902 .name = "random_distribution",
1903 .type = FIO_OPT_STR,
1904 .off1 = td_var_offset(random_distribution),
1905 .cb = str_random_distribution_cb,
1906 .help = "Random offset distribution generator",
1910 .oval = FIO_RAND_DIST_RANDOM,
1911 .help = "Completely random",
1914 .oval = FIO_RAND_DIST_ZIPF,
1915 .help = "Zipf distribution",
1918 .oval = FIO_RAND_DIST_PARETO,
1919 .help = "Pareto distribution",
1922 .oval = FIO_RAND_DIST_GAUSS,
1923 .help = "Normal (gaussian) distribution",
1926 .category = FIO_OPT_C_IO,
1927 .group = FIO_OPT_G_RANDOM,
1930 .name = "percentage_random",
1931 .lname = "Percentage Random",
1932 .type = FIO_OPT_INT,
1933 .off1 = td_var_offset(perc_rand[DDIR_READ]),
1934 .off2 = td_var_offset(perc_rand[DDIR_WRITE]),
1935 .off3 = td_var_offset(perc_rand[DDIR_TRIM]),
1937 .help = "Percentage of seq/random mix that should be random",
1938 .def = "100,100,100",
1940 .inverse = "percentage_sequential",
1941 .category = FIO_OPT_C_IO,
1942 .group = FIO_OPT_G_RANDOM,
1945 .name = "percentage_sequential",
1946 .lname = "Percentage Sequential",
1947 .type = FIO_OPT_DEPRECATED,
1948 .category = FIO_OPT_C_IO,
1949 .group = FIO_OPT_G_RANDOM,
1952 .name = "allrandrepeat",
1953 .type = FIO_OPT_BOOL,
1954 .off1 = td_var_offset(allrand_repeatable),
1955 .help = "Use repeatable random numbers for everything",
1957 .category = FIO_OPT_C_IO,
1958 .group = FIO_OPT_G_RANDOM,
1962 .lname = "Number of files",
1963 .alias = "nr_files",
1964 .type = FIO_OPT_INT,
1965 .off1 = td_var_offset(nr_files),
1966 .help = "Split job workload between this number of files",
1969 .category = FIO_OPT_C_FILE,
1970 .group = FIO_OPT_G_INVALID,
1973 .name = "openfiles",
1974 .lname = "Number of open files",
1975 .type = FIO_OPT_INT,
1976 .off1 = td_var_offset(open_files),
1977 .help = "Number of files to keep open at the same time",
1978 .category = FIO_OPT_C_FILE,
1979 .group = FIO_OPT_G_INVALID,
1982 .name = "file_service_type",
1983 .lname = "File service type",
1984 .type = FIO_OPT_STR,
1986 .off1 = td_var_offset(file_service_type),
1987 .help = "How to select which file to service next",
1988 .def = "roundrobin",
1989 .category = FIO_OPT_C_FILE,
1990 .group = FIO_OPT_G_INVALID,
1993 .oval = FIO_FSERVICE_RANDOM,
1994 .help = "Choose a file at random",
1996 { .ival = "roundrobin",
1997 .oval = FIO_FSERVICE_RR,
1998 .help = "Round robin select files",
2000 { .ival = "sequential",
2001 .oval = FIO_FSERVICE_SEQ,
2002 .help = "Finish one file before moving to the next",
2005 .parent = "nrfiles",
2008 #ifdef CONFIG_POSIX_FALLOCATE
2010 .name = "fallocate",
2011 .lname = "Fallocate",
2012 .type = FIO_OPT_STR,
2013 .off1 = td_var_offset(fallocate_mode),
2014 .help = "Whether pre-allocation is performed when laying out files",
2016 .category = FIO_OPT_C_FILE,
2017 .group = FIO_OPT_G_INVALID,
2020 .oval = FIO_FALLOCATE_NONE,
2021 .help = "Do not pre-allocate space",
2024 .oval = FIO_FALLOCATE_POSIX,
2025 .help = "Use posix_fallocate()",
2027 #ifdef CONFIG_LINUX_FALLOCATE
2029 .oval = FIO_FALLOCATE_KEEP_SIZE,
2030 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
2033 /* Compatibility with former boolean values */
2035 .oval = FIO_FALLOCATE_NONE,
2036 .help = "Alias for 'none'",
2039 .oval = FIO_FALLOCATE_POSIX,
2040 .help = "Alias for 'posix'",
2044 #endif /* CONFIG_POSIX_FALLOCATE */
2046 .name = "fadvise_hint",
2047 .lname = "Fadvise hint",
2048 .type = FIO_OPT_BOOL,
2049 .off1 = td_var_offset(fadvise_hint),
2050 .help = "Use fadvise() to advise the kernel on IO pattern",
2052 .category = FIO_OPT_C_FILE,
2053 .group = FIO_OPT_G_INVALID,
2055 #ifdef FIO_HAVE_STREAMID
2057 .name = "fadvise_stream",
2058 .lname = "Fadvise stream",
2059 .type = FIO_OPT_INT,
2060 .off1 = td_var_offset(fadvise_stream),
2061 .help = "Use fadvise() to set stream ID",
2062 .category = FIO_OPT_C_FILE,
2063 .group = FIO_OPT_G_INVALID,
2069 .type = FIO_OPT_INT,
2070 .off1 = td_var_offset(fsync_blocks),
2071 .help = "Issue fsync for writes every given number of blocks",
2074 .category = FIO_OPT_C_FILE,
2075 .group = FIO_OPT_G_INVALID,
2078 .name = "fdatasync",
2079 .lname = "Fdatasync",
2080 .type = FIO_OPT_INT,
2081 .off1 = td_var_offset(fdatasync_blocks),
2082 .help = "Issue fdatasync for writes every given number of blocks",
2085 .category = FIO_OPT_C_FILE,
2086 .group = FIO_OPT_G_INVALID,
2089 .name = "write_barrier",
2090 .lname = "Write barrier",
2091 .type = FIO_OPT_INT,
2092 .off1 = td_var_offset(barrier_blocks),
2093 .help = "Make every Nth write a barrier write",
2096 .category = FIO_OPT_C_IO,
2097 .group = FIO_OPT_G_INVALID,
2099 #ifdef CONFIG_SYNC_FILE_RANGE
2101 .name = "sync_file_range",
2102 .lname = "Sync file range",
2104 { .ival = "wait_before",
2105 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
2106 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
2110 .oval = SYNC_FILE_RANGE_WRITE,
2111 .help = "SYNC_FILE_RANGE_WRITE",
2115 .ival = "wait_after",
2116 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
2117 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
2121 .type = FIO_OPT_STR_MULTI,
2123 .off1 = td_var_offset(sync_file_range),
2124 .help = "Use sync_file_range()",
2125 .category = FIO_OPT_C_FILE,
2126 .group = FIO_OPT_G_INVALID,
2131 .lname = "Direct I/O",
2132 .type = FIO_OPT_BOOL,
2133 .off1 = td_var_offset(odirect),
2134 .help = "Use O_DIRECT IO (negates buffered)",
2136 .inverse = "buffered",
2137 .category = FIO_OPT_C_IO,
2138 .group = FIO_OPT_G_IO_TYPE,
2142 .lname = "Atomic I/O",
2143 .type = FIO_OPT_BOOL,
2144 .off1 = td_var_offset(oatomic),
2145 .help = "Use Atomic IO with O_DIRECT (implies O_DIRECT)",
2147 .category = FIO_OPT_C_IO,
2148 .group = FIO_OPT_G_IO_TYPE,
2152 .lname = "Buffered I/O",
2153 .type = FIO_OPT_BOOL,
2154 .off1 = td_var_offset(odirect),
2156 .help = "Use buffered IO (negates direct)",
2158 .inverse = "direct",
2159 .category = FIO_OPT_C_IO,
2160 .group = FIO_OPT_G_IO_TYPE,
2163 .name = "overwrite",
2164 .lname = "Overwrite",
2165 .type = FIO_OPT_BOOL,
2166 .off1 = td_var_offset(overwrite),
2167 .help = "When writing, set whether to overwrite current data",
2169 .category = FIO_OPT_C_FILE,
2170 .group = FIO_OPT_G_INVALID,
2175 .type = FIO_OPT_INT,
2176 .off1 = td_var_offset(loops),
2177 .help = "Number of times to run the job",
2180 .category = FIO_OPT_C_GENERAL,
2181 .group = FIO_OPT_G_RUNTIME,
2185 .lname = "Number of jobs",
2186 .type = FIO_OPT_INT,
2187 .off1 = td_var_offset(numjobs),
2188 .help = "Duplicate this job this many times",
2191 .category = FIO_OPT_C_GENERAL,
2192 .group = FIO_OPT_G_RUNTIME,
2195 .name = "startdelay",
2196 .lname = "Start delay",
2197 .type = FIO_OPT_STR_VAL_TIME,
2198 .off1 = td_var_offset(start_delay),
2199 .off2 = td_var_offset(start_delay_high),
2200 .help = "Only start job when this period has passed",
2204 .category = FIO_OPT_C_GENERAL,
2205 .group = FIO_OPT_G_RUNTIME,
2211 .type = FIO_OPT_STR_VAL_TIME,
2212 .off1 = td_var_offset(timeout),
2213 .help = "Stop workload when this amount of time has passed",
2217 .category = FIO_OPT_C_GENERAL,
2218 .group = FIO_OPT_G_RUNTIME,
2221 .name = "time_based",
2222 .lname = "Time based",
2223 .type = FIO_OPT_STR_SET,
2224 .off1 = td_var_offset(time_based),
2225 .help = "Keep running until runtime/timeout is met",
2226 .category = FIO_OPT_C_GENERAL,
2227 .group = FIO_OPT_G_RUNTIME,
2230 .name = "verify_only",
2231 .lname = "Verify only",
2232 .type = FIO_OPT_STR_SET,
2233 .off1 = td_var_offset(verify_only),
2234 .help = "Verifies previously written data is still valid",
2235 .category = FIO_OPT_C_GENERAL,
2236 .group = FIO_OPT_G_RUNTIME,
2239 .name = "ramp_time",
2240 .lname = "Ramp time",
2241 .type = FIO_OPT_STR_VAL_TIME,
2242 .off1 = td_var_offset(ramp_time),
2243 .help = "Ramp up time before measuring performance",
2246 .category = FIO_OPT_C_GENERAL,
2247 .group = FIO_OPT_G_RUNTIME,
2250 .name = "clocksource",
2251 .lname = "Clock source",
2252 .type = FIO_OPT_STR,
2253 .cb = fio_clock_source_cb,
2254 .off1 = td_var_offset(clocksource),
2255 .help = "What type of timing source to use",
2256 .category = FIO_OPT_C_GENERAL,
2257 .group = FIO_OPT_G_CLOCK,
2259 #ifdef CONFIG_GETTIMEOFDAY
2260 { .ival = "gettimeofday",
2262 .help = "Use gettimeofday(2) for timing",
2265 #ifdef CONFIG_CLOCK_GETTIME
2266 { .ival = "clock_gettime",
2267 .oval = CS_CGETTIME,
2268 .help = "Use clock_gettime(2) for timing",
2271 #ifdef ARCH_HAVE_CPU_CLOCK
2273 .oval = CS_CPUCLOCK,
2274 .help = "Use CPU private clock",
2282 .lname = "I/O Memory",
2283 .type = FIO_OPT_STR,
2285 .off1 = td_var_offset(mem_type),
2286 .help = "Backing type for IO buffers",
2288 .category = FIO_OPT_C_IO,
2289 .group = FIO_OPT_G_INVALID,
2293 .help = "Use malloc(3) for IO buffers",
2295 #ifndef CONFIG_NO_SHM
2298 .help = "Use shared memory segments for IO buffers",
2300 #ifdef FIO_HAVE_HUGETLB
2301 { .ival = "shmhuge",
2302 .oval = MEM_SHMHUGE,
2303 .help = "Like shm, but use huge pages",
2309 .help = "Use mmap(2) (file or anon) for IO buffers",
2311 #ifdef FIO_HAVE_HUGETLB
2312 { .ival = "mmaphuge",
2313 .oval = MEM_MMAPHUGE,
2314 .help = "Like mmap, but use huge pages",
2320 .name = "iomem_align",
2321 .alias = "mem_align",
2322 .lname = "I/O memory alignment",
2323 .type = FIO_OPT_INT,
2324 .off1 = td_var_offset(mem_align),
2326 .help = "IO memory buffer offset alignment",
2330 .category = FIO_OPT_C_IO,
2331 .group = FIO_OPT_G_INVALID,
2336 .type = FIO_OPT_STR,
2337 .off1 = td_var_offset(verify),
2338 .help = "Verify data written",
2340 .category = FIO_OPT_C_IO,
2341 .group = FIO_OPT_G_VERIFY,
2344 .oval = VERIFY_NONE,
2345 .help = "Don't do IO verification",
2349 .help = "Use md5 checksums for verification",
2352 .oval = VERIFY_CRC64,
2353 .help = "Use crc64 checksums for verification",
2356 .oval = VERIFY_CRC32,
2357 .help = "Use crc32 checksums for verification",
2359 { .ival = "crc32c-intel",
2360 .oval = VERIFY_CRC32C,
2361 .help = "Use crc32c checksums for verification (hw assisted, if available)",
2364 .oval = VERIFY_CRC32C,
2365 .help = "Use crc32c checksums for verification (hw assisted, if available)",
2368 .oval = VERIFY_CRC16,
2369 .help = "Use crc16 checksums for verification",
2372 .oval = VERIFY_CRC7,
2373 .help = "Use crc7 checksums for verification",
2376 .oval = VERIFY_SHA1,
2377 .help = "Use sha1 checksums for verification",
2380 .oval = VERIFY_SHA256,
2381 .help = "Use sha256 checksums for verification",
2384 .oval = VERIFY_SHA512,
2385 .help = "Use sha512 checksums for verification",
2388 .oval = VERIFY_XXHASH,
2389 .help = "Use xxhash checksums for verification",
2392 .oval = VERIFY_META,
2393 .help = "Use io information",
2397 .oval = VERIFY_NULL,
2398 .help = "Pretend to verify",
2403 .name = "do_verify",
2404 .lname = "Perform verify step",
2405 .type = FIO_OPT_BOOL,
2406 .off1 = td_var_offset(do_verify),
2407 .help = "Run verification stage after write",
2411 .category = FIO_OPT_C_IO,
2412 .group = FIO_OPT_G_VERIFY,
2415 .name = "verifysort",
2416 .lname = "Verify sort",
2417 .type = FIO_OPT_BOOL,
2418 .off1 = td_var_offset(verifysort),
2419 .help = "Sort written verify blocks for read back",
2423 .category = FIO_OPT_C_IO,
2424 .group = FIO_OPT_G_VERIFY,
2427 .name = "verifysort_nr",
2428 .type = FIO_OPT_INT,
2429 .off1 = td_var_offset(verifysort_nr),
2430 .help = "Pre-load and sort verify blocks for a read workload",
2435 .category = FIO_OPT_C_IO,
2436 .group = FIO_OPT_G_VERIFY,
2439 .name = "verify_interval",
2440 .lname = "Verify interval",
2441 .type = FIO_OPT_INT,
2442 .off1 = td_var_offset(verify_interval),
2443 .minval = 2 * sizeof(struct verify_header),
2444 .help = "Store verify buffer header every N bytes",
2447 .interval = 2 * sizeof(struct verify_header),
2448 .category = FIO_OPT_C_IO,
2449 .group = FIO_OPT_G_VERIFY,
2452 .name = "verify_offset",
2453 .lname = "Verify offset",
2454 .type = FIO_OPT_INT,
2455 .help = "Offset verify header location by N bytes",
2456 .off1 = td_var_offset(verify_offset),
2457 .minval = sizeof(struct verify_header),
2460 .category = FIO_OPT_C_IO,
2461 .group = FIO_OPT_G_VERIFY,
2464 .name = "verify_pattern",
2465 .lname = "Verify pattern",
2466 .type = FIO_OPT_STR,
2467 .cb = str_verify_pattern_cb,
2468 .off1 = td_var_offset(verify_pattern),
2469 .help = "Fill pattern for IO buffers",
2472 .category = FIO_OPT_C_IO,
2473 .group = FIO_OPT_G_VERIFY,
2476 .name = "verify_fatal",
2477 .lname = "Verify fatal",
2478 .type = FIO_OPT_BOOL,
2479 .off1 = td_var_offset(verify_fatal),
2481 .help = "Exit on a single verify failure, don't continue",
2484 .category = FIO_OPT_C_IO,
2485 .group = FIO_OPT_G_VERIFY,
2488 .name = "verify_dump",
2489 .lname = "Verify dump",
2490 .type = FIO_OPT_BOOL,
2491 .off1 = td_var_offset(verify_dump),
2493 .help = "Dump contents of good and bad blocks on failure",
2496 .category = FIO_OPT_C_IO,
2497 .group = FIO_OPT_G_VERIFY,
2500 .name = "verify_async",
2501 .lname = "Verify asynchronously",
2502 .type = FIO_OPT_INT,
2503 .off1 = td_var_offset(verify_async),
2505 .help = "Number of async verifier threads to use",
2508 .category = FIO_OPT_C_IO,
2509 .group = FIO_OPT_G_VERIFY,
2512 .name = "verify_backlog",
2513 .lname = "Verify backlog",
2514 .type = FIO_OPT_STR_VAL,
2515 .off1 = td_var_offset(verify_backlog),
2516 .help = "Verify after this number of blocks are written",
2519 .category = FIO_OPT_C_IO,
2520 .group = FIO_OPT_G_VERIFY,
2523 .name = "verify_backlog_batch",
2524 .lname = "Verify backlog batch",
2525 .type = FIO_OPT_INT,
2526 .off1 = td_var_offset(verify_batch),
2527 .help = "Verify this number of IO blocks",
2530 .category = FIO_OPT_C_IO,
2531 .group = FIO_OPT_G_VERIFY,
2533 #ifdef FIO_HAVE_CPU_AFFINITY
2535 .name = "verify_async_cpus",
2536 .lname = "Async verify CPUs",
2537 .type = FIO_OPT_STR,
2538 .cb = str_verify_cpus_allowed_cb,
2539 .off1 = td_var_offset(verify_cpumask),
2540 .help = "Set CPUs allowed for async verify threads",
2541 .parent = "verify_async",
2543 .category = FIO_OPT_C_IO,
2544 .group = FIO_OPT_G_VERIFY,
2548 .name = "experimental_verify",
2549 .off1 = td_var_offset(experimental_verify),
2550 .type = FIO_OPT_BOOL,
2551 .help = "Enable experimental verification",
2553 .category = FIO_OPT_C_IO,
2554 .group = FIO_OPT_G_VERIFY,
2557 .name = "verify_state_load",
2558 .lname = "Load verify state",
2559 .off1 = td_var_offset(verify_state),
2560 .type = FIO_OPT_BOOL,
2561 .help = "Load verify termination state",
2563 .category = FIO_OPT_C_IO,
2564 .group = FIO_OPT_G_VERIFY,
2567 .name = "verify_state_save",
2568 .lname = "Save verify state",
2569 .off1 = td_var_offset(verify_state_save),
2570 .type = FIO_OPT_BOOL,
2572 .help = "Save verify state on termination",
2574 .category = FIO_OPT_C_IO,
2575 .group = FIO_OPT_G_VERIFY,
2577 #ifdef FIO_HAVE_TRIM
2579 .name = "trim_percentage",
2580 .lname = "Trim percentage",
2581 .type = FIO_OPT_INT,
2582 .off1 = td_var_offset(trim_percentage),
2585 .help = "Number of verify blocks to discard/trim",
2590 .category = FIO_OPT_C_IO,
2591 .group = FIO_OPT_G_TRIM,
2594 .name = "trim_verify_zero",
2595 .lname = "Verify trim zero",
2596 .type = FIO_OPT_BOOL,
2597 .help = "Verify that trim/discarded blocks are returned as zeroes",
2598 .off1 = td_var_offset(trim_zero),
2599 .parent = "trim_percentage",
2602 .category = FIO_OPT_C_IO,
2603 .group = FIO_OPT_G_TRIM,
2606 .name = "trim_backlog",
2607 .lname = "Trim backlog",
2608 .type = FIO_OPT_STR_VAL,
2609 .off1 = td_var_offset(trim_backlog),
2610 .help = "Trim after this number of blocks are written",
2611 .parent = "trim_percentage",
2614 .category = FIO_OPT_C_IO,
2615 .group = FIO_OPT_G_TRIM,
2618 .name = "trim_backlog_batch",
2619 .lname = "Trim backlog batch",
2620 .type = FIO_OPT_INT,
2621 .off1 = td_var_offset(trim_batch),
2622 .help = "Trim this number of IO blocks",
2623 .parent = "trim_percentage",
2626 .category = FIO_OPT_C_IO,
2627 .group = FIO_OPT_G_TRIM,
2631 .name = "write_iolog",
2632 .lname = "Write I/O log",
2633 .type = FIO_OPT_STR_STORE,
2634 .off1 = td_var_offset(write_iolog_file),
2635 .help = "Store IO pattern to file",
2636 .category = FIO_OPT_C_IO,
2637 .group = FIO_OPT_G_IOLOG,
2640 .name = "read_iolog",
2641 .lname = "Read I/O log",
2642 .type = FIO_OPT_STR_STORE,
2643 .off1 = td_var_offset(read_iolog_file),
2644 .help = "Playback IO pattern from file",
2645 .category = FIO_OPT_C_IO,
2646 .group = FIO_OPT_G_IOLOG,
2649 .name = "replay_no_stall",
2650 .lname = "Don't stall on replay",
2651 .type = FIO_OPT_BOOL,
2652 .off1 = td_var_offset(no_stall),
2654 .parent = "read_iolog",
2656 .help = "Playback IO pattern file as fast as possible without stalls",
2657 .category = FIO_OPT_C_IO,
2658 .group = FIO_OPT_G_IOLOG,
2661 .name = "replay_redirect",
2662 .lname = "Redirect device for replay",
2663 .type = FIO_OPT_STR_STORE,
2664 .off1 = td_var_offset(replay_redirect),
2665 .parent = "read_iolog",
2667 .help = "Replay all I/O onto this device, regardless of trace device",
2668 .category = FIO_OPT_C_IO,
2669 .group = FIO_OPT_G_IOLOG,
2672 .name = "replay_scale",
2673 .lname = "Replace offset scale factor",
2674 .type = FIO_OPT_INT,
2675 .off1 = td_var_offset(replay_scale),
2676 .parent = "read_iolog",
2678 .help = "Align offsets to this blocksize",
2679 .category = FIO_OPT_C_IO,
2680 .group = FIO_OPT_G_IOLOG,
2683 .name = "replay_align",
2684 .lname = "Replace alignment",
2685 .type = FIO_OPT_INT,
2686 .off1 = td_var_offset(replay_align),
2687 .parent = "read_iolog",
2688 .help = "Scale offset down by this factor",
2689 .category = FIO_OPT_C_IO,
2690 .group = FIO_OPT_G_IOLOG,
2694 .name = "exec_prerun",
2695 .lname = "Pre-execute runnable",
2696 .type = FIO_OPT_STR_STORE,
2697 .off1 = td_var_offset(exec_prerun),
2698 .help = "Execute this file prior to running job",
2699 .category = FIO_OPT_C_GENERAL,
2700 .group = FIO_OPT_G_INVALID,
2703 .name = "exec_postrun",
2704 .lname = "Post-execute runnable",
2705 .type = FIO_OPT_STR_STORE,
2706 .off1 = td_var_offset(exec_postrun),
2707 .help = "Execute this file after running job",
2708 .category = FIO_OPT_C_GENERAL,
2709 .group = FIO_OPT_G_INVALID,
2711 #ifdef FIO_HAVE_IOSCHED_SWITCH
2713 .name = "ioscheduler",
2714 .lname = "I/O scheduler",
2715 .type = FIO_OPT_STR_STORE,
2716 .off1 = td_var_offset(ioscheduler),
2717 .help = "Use this IO scheduler on the backing device",
2718 .category = FIO_OPT_C_FILE,
2719 .group = FIO_OPT_G_INVALID,
2724 .lname = "Zone size",
2725 .type = FIO_OPT_STR_VAL,
2726 .off1 = td_var_offset(zone_size),
2727 .help = "Amount of data to read per zone",
2729 .interval = 1024 * 1024,
2730 .category = FIO_OPT_C_IO,
2731 .group = FIO_OPT_G_ZONE,
2734 .name = "zonerange",
2735 .lname = "Zone range",
2736 .type = FIO_OPT_STR_VAL,
2737 .off1 = td_var_offset(zone_range),
2738 .help = "Give size of an IO zone",
2740 .interval = 1024 * 1024,
2741 .category = FIO_OPT_C_IO,
2742 .group = FIO_OPT_G_ZONE,
2746 .lname = "Zone skip",
2747 .type = FIO_OPT_STR_VAL,
2748 .off1 = td_var_offset(zone_skip),
2749 .help = "Space between IO zones",
2751 .interval = 1024 * 1024,
2752 .category = FIO_OPT_C_IO,
2753 .group = FIO_OPT_G_ZONE,
2757 .lname = "Lock memory",
2758 .type = FIO_OPT_STR_VAL,
2759 .off1 = td_var_offset(lockmem),
2760 .help = "Lock down this amount of memory (per worker)",
2762 .interval = 1024 * 1024,
2763 .category = FIO_OPT_C_GENERAL,
2764 .group = FIO_OPT_G_INVALID,
2767 .name = "rwmixread",
2768 .lname = "Read/write mix read",
2769 .type = FIO_OPT_INT,
2770 .cb = str_rwmix_read_cb,
2771 .off1 = td_var_offset(rwmix[DDIR_READ]),
2773 .help = "Percentage of mixed workload that is reads",
2776 .inverse = "rwmixwrite",
2777 .category = FIO_OPT_C_IO,
2778 .group = FIO_OPT_G_RWMIX,
2781 .name = "rwmixwrite",
2782 .lname = "Read/write mix write",
2783 .type = FIO_OPT_INT,
2784 .cb = str_rwmix_write_cb,
2785 .off1 = td_var_offset(rwmix[DDIR_WRITE]),
2787 .help = "Percentage of mixed workload that is writes",
2790 .inverse = "rwmixread",
2791 .category = FIO_OPT_C_IO,
2792 .group = FIO_OPT_G_RWMIX,
2795 .name = "rwmixcycle",
2796 .lname = "Read/write mix cycle",
2797 .type = FIO_OPT_DEPRECATED,
2798 .category = FIO_OPT_C_IO,
2799 .group = FIO_OPT_G_RWMIX,
2804 .type = FIO_OPT_INT,
2805 .off1 = td_var_offset(nice),
2806 .help = "Set job CPU nice value",
2811 .category = FIO_OPT_C_GENERAL,
2812 .group = FIO_OPT_G_CRED,
2814 #ifdef FIO_HAVE_IOPRIO
2817 .lname = "I/O nice priority",
2818 .type = FIO_OPT_INT,
2819 .off1 = td_var_offset(ioprio),
2820 .help = "Set job IO priority value",
2824 .category = FIO_OPT_C_GENERAL,
2825 .group = FIO_OPT_G_CRED,
2828 .name = "prioclass",
2829 .lname = "I/O nice priority class",
2830 .type = FIO_OPT_INT,
2831 .off1 = td_var_offset(ioprio_class),
2832 .help = "Set job IO priority class",
2836 .category = FIO_OPT_C_GENERAL,
2837 .group = FIO_OPT_G_CRED,
2841 .name = "thinktime",
2842 .lname = "Thinktime",
2843 .type = FIO_OPT_INT,
2844 .off1 = td_var_offset(thinktime),
2845 .help = "Idle time between IO buffers (usec)",
2848 .category = FIO_OPT_C_IO,
2849 .group = FIO_OPT_G_THINKTIME,
2852 .name = "thinktime_spin",
2853 .lname = "Thinktime spin",
2854 .type = FIO_OPT_INT,
2855 .off1 = td_var_offset(thinktime_spin),
2856 .help = "Start think time by spinning this amount (usec)",
2859 .parent = "thinktime",
2861 .category = FIO_OPT_C_IO,
2862 .group = FIO_OPT_G_THINKTIME,
2865 .name = "thinktime_blocks",
2866 .lname = "Thinktime blocks",
2867 .type = FIO_OPT_INT,
2868 .off1 = td_var_offset(thinktime_blocks),
2869 .help = "IO buffer period between 'thinktime'",
2871 .parent = "thinktime",
2873 .category = FIO_OPT_C_IO,
2874 .group = FIO_OPT_G_THINKTIME,
2878 .lname = "I/O rate",
2879 .type = FIO_OPT_INT,
2880 .off1 = td_var_offset(rate[DDIR_READ]),
2881 .off2 = td_var_offset(rate[DDIR_WRITE]),
2882 .off3 = td_var_offset(rate[DDIR_TRIM]),
2883 .help = "Set bandwidth rate",
2884 .category = FIO_OPT_C_IO,
2885 .group = FIO_OPT_G_RATE,
2889 .lname = "I/O min rate",
2890 .type = FIO_OPT_INT,
2891 .off1 = td_var_offset(ratemin[DDIR_READ]),
2892 .off2 = td_var_offset(ratemin[DDIR_WRITE]),
2893 .off3 = td_var_offset(ratemin[DDIR_TRIM]),
2894 .help = "Job must meet this rate or it will be shutdown",
2897 .category = FIO_OPT_C_IO,
2898 .group = FIO_OPT_G_RATE,
2901 .name = "rate_iops",
2902 .lname = "I/O rate IOPS",
2903 .type = FIO_OPT_INT,
2904 .off1 = td_var_offset(rate_iops[DDIR_READ]),
2905 .off2 = td_var_offset(rate_iops[DDIR_WRITE]),
2906 .off3 = td_var_offset(rate_iops[DDIR_TRIM]),
2907 .help = "Limit IO used to this number of IO operations/sec",
2909 .category = FIO_OPT_C_IO,
2910 .group = FIO_OPT_G_RATE,
2913 .name = "rate_iops_min",
2914 .lname = "I/O min rate IOPS",
2915 .type = FIO_OPT_INT,
2916 .off1 = td_var_offset(rate_iops_min[DDIR_READ]),
2917 .off2 = td_var_offset(rate_iops_min[DDIR_WRITE]),
2918 .off3 = td_var_offset(rate_iops_min[DDIR_TRIM]),
2919 .help = "Job must meet this rate or it will be shut down",
2920 .parent = "rate_iops",
2922 .category = FIO_OPT_C_IO,
2923 .group = FIO_OPT_G_RATE,
2926 .name = "ratecycle",
2927 .lname = "I/O rate cycle",
2928 .type = FIO_OPT_INT,
2929 .off1 = td_var_offset(ratecycle),
2930 .help = "Window average for rate limits (msec)",
2934 .category = FIO_OPT_C_IO,
2935 .group = FIO_OPT_G_RATE,
2938 .name = "max_latency",
2939 .type = FIO_OPT_INT,
2940 .off1 = td_var_offset(max_latency),
2941 .help = "Maximum tolerated IO latency (usec)",
2943 .category = FIO_OPT_C_IO,
2944 .group = FIO_OPT_G_LATPROF,
2947 .name = "latency_target",
2948 .lname = "Latency Target (usec)",
2949 .type = FIO_OPT_STR_VAL_TIME,
2950 .off1 = td_var_offset(latency_target),
2951 .help = "Ramp to max queue depth supporting this latency",
2953 .category = FIO_OPT_C_IO,
2954 .group = FIO_OPT_G_LATPROF,
2957 .name = "latency_window",
2958 .lname = "Latency Window (usec)",
2959 .type = FIO_OPT_STR_VAL_TIME,
2960 .off1 = td_var_offset(latency_window),
2961 .help = "Time to sustain latency_target",
2963 .category = FIO_OPT_C_IO,
2964 .group = FIO_OPT_G_LATPROF,
2967 .name = "latency_percentile",
2968 .lname = "Latency Percentile",
2969 .type = FIO_OPT_FLOAT_LIST,
2970 .off1 = td_var_offset(latency_percentile),
2971 .help = "Percentile of IOs must be below latency_target",
2976 .category = FIO_OPT_C_IO,
2977 .group = FIO_OPT_G_LATPROF,
2980 .name = "invalidate",
2981 .lname = "Cache invalidate",
2982 .type = FIO_OPT_BOOL,
2983 .off1 = td_var_offset(invalidate_cache),
2984 .help = "Invalidate buffer/page cache prior to running job",
2986 .category = FIO_OPT_C_IO,
2987 .group = FIO_OPT_G_IO_TYPE,
2991 .lname = "Synchronous I/O",
2992 .type = FIO_OPT_BOOL,
2993 .off1 = td_var_offset(sync_io),
2994 .help = "Use O_SYNC for buffered writes",
2996 .parent = "buffered",
2998 .category = FIO_OPT_C_IO,
2999 .group = FIO_OPT_G_IO_TYPE,
3002 .name = "create_serialize",
3003 .lname = "Create serialize",
3004 .type = FIO_OPT_BOOL,
3005 .off1 = td_var_offset(create_serialize),
3006 .help = "Serialize creating of job files",
3008 .category = FIO_OPT_C_FILE,
3009 .group = FIO_OPT_G_INVALID,
3012 .name = "create_fsync",
3013 .lname = "Create fsync",
3014 .type = FIO_OPT_BOOL,
3015 .off1 = td_var_offset(create_fsync),
3016 .help = "fsync file after creation",
3018 .category = FIO_OPT_C_FILE,
3019 .group = FIO_OPT_G_INVALID,
3022 .name = "create_on_open",
3023 .lname = "Create on open",
3024 .type = FIO_OPT_BOOL,
3025 .off1 = td_var_offset(create_on_open),
3026 .help = "Create files when they are opened for IO",
3028 .category = FIO_OPT_C_FILE,
3029 .group = FIO_OPT_G_INVALID,
3032 .name = "create_only",
3033 .type = FIO_OPT_BOOL,
3034 .off1 = td_var_offset(create_only),
3035 .help = "Only perform file creation phase",
3036 .category = FIO_OPT_C_FILE,
3041 .lname = "Pre-read files",
3042 .type = FIO_OPT_BOOL,
3043 .off1 = td_var_offset(pre_read),
3044 .help = "Pre-read files before starting official testing",
3046 .category = FIO_OPT_C_FILE,
3047 .group = FIO_OPT_G_INVALID,
3049 #ifdef FIO_HAVE_CPU_AFFINITY
3052 .lname = "CPU mask",
3053 .type = FIO_OPT_INT,
3054 .cb = str_cpumask_cb,
3055 .off1 = td_var_offset(cpumask),
3056 .help = "CPU affinity mask",
3057 .category = FIO_OPT_C_GENERAL,
3058 .group = FIO_OPT_G_CRED,
3061 .name = "cpus_allowed",
3062 .lname = "CPUs allowed",
3063 .type = FIO_OPT_STR,
3064 .cb = str_cpus_allowed_cb,
3065 .off1 = td_var_offset(cpumask),
3066 .help = "Set CPUs allowed",
3067 .category = FIO_OPT_C_GENERAL,
3068 .group = FIO_OPT_G_CRED,
3071 .name = "cpus_allowed_policy",
3072 .lname = "CPUs allowed distribution policy",
3073 .type = FIO_OPT_STR,
3074 .off1 = td_var_offset(cpus_allowed_policy),
3075 .help = "Distribution policy for cpus_allowed",
3076 .parent = "cpus_allowed",
3080 .oval = FIO_CPUS_SHARED,
3081 .help = "Mask shared between threads",
3084 .oval = FIO_CPUS_SPLIT,
3085 .help = "Mask split between threads",
3088 .category = FIO_OPT_C_GENERAL,
3089 .group = FIO_OPT_G_CRED,
3092 #ifdef CONFIG_LIBNUMA
3094 .name = "numa_cpu_nodes",
3095 .type = FIO_OPT_STR,
3096 .cb = str_numa_cpunodes_cb,
3097 .off1 = td_var_offset(numa_cpunodes),
3098 .help = "NUMA CPU nodes bind",
3099 .category = FIO_OPT_C_GENERAL,
3100 .group = FIO_OPT_G_INVALID,
3103 .name = "numa_mem_policy",
3104 .type = FIO_OPT_STR,
3105 .cb = str_numa_mpol_cb,
3106 .off1 = td_var_offset(numa_memnodes),
3107 .help = "NUMA memory policy setup",
3108 .category = FIO_OPT_C_GENERAL,
3109 .group = FIO_OPT_G_INVALID,
3113 .name = "end_fsync",
3114 .lname = "End fsync",
3115 .type = FIO_OPT_BOOL,
3116 .off1 = td_var_offset(end_fsync),
3117 .help = "Include fsync at the end of job",
3119 .category = FIO_OPT_C_FILE,
3120 .group = FIO_OPT_G_INVALID,
3123 .name = "fsync_on_close",
3124 .lname = "Fsync on close",
3125 .type = FIO_OPT_BOOL,
3126 .off1 = td_var_offset(fsync_on_close),
3127 .help = "fsync files on close",
3129 .category = FIO_OPT_C_FILE,
3130 .group = FIO_OPT_G_INVALID,
3134 .lname = "Unlink file",
3135 .type = FIO_OPT_BOOL,
3136 .off1 = td_var_offset(unlink),
3137 .help = "Unlink created files after job has completed",
3139 .category = FIO_OPT_C_FILE,
3140 .group = FIO_OPT_G_INVALID,
3144 .lname = "Exit-all on terminate",
3145 .type = FIO_OPT_STR_SET,
3146 .cb = str_exitall_cb,
3147 .help = "Terminate all jobs when one exits",
3148 .category = FIO_OPT_C_GENERAL,
3149 .group = FIO_OPT_G_PROCESS,
3152 .name = "stonewall",
3153 .lname = "Wait for previous",
3154 .alias = "wait_for_previous",
3155 .type = FIO_OPT_STR_SET,
3156 .off1 = td_var_offset(stonewall),
3157 .help = "Insert a hard barrier between this job and previous",
3158 .category = FIO_OPT_C_GENERAL,
3159 .group = FIO_OPT_G_PROCESS,
3162 .name = "new_group",
3163 .lname = "New group",
3164 .type = FIO_OPT_STR_SET,
3165 .off1 = td_var_offset(new_group),
3166 .help = "Mark the start of a new group (for reporting)",
3167 .category = FIO_OPT_C_GENERAL,
3168 .group = FIO_OPT_G_PROCESS,
3173 .type = FIO_OPT_STR_SET,
3174 .off1 = td_var_offset(use_thread),
3175 .help = "Use threads instead of processes",
3176 #ifdef CONFIG_NO_SHM
3180 .category = FIO_OPT_C_GENERAL,
3181 .group = FIO_OPT_G_PROCESS,
3184 .name = "write_bw_log",
3185 .lname = "Write bandwidth log",
3186 .type = FIO_OPT_STR_STORE,
3187 .off1 = td_var_offset(bw_log_file),
3188 .help = "Write log of bandwidth during run",
3189 .category = FIO_OPT_C_LOG,
3190 .group = FIO_OPT_G_INVALID,
3193 .name = "write_lat_log",
3194 .lname = "Write latency log",
3195 .type = FIO_OPT_STR_STORE,
3196 .off1 = td_var_offset(lat_log_file),
3197 .help = "Write log of latency during run",
3198 .category = FIO_OPT_C_LOG,
3199 .group = FIO_OPT_G_INVALID,
3202 .name = "write_iops_log",
3203 .lname = "Write IOPS log",
3204 .type = FIO_OPT_STR_STORE,
3205 .off1 = td_var_offset(iops_log_file),
3206 .help = "Write log of IOPS during run",
3207 .category = FIO_OPT_C_LOG,
3208 .group = FIO_OPT_G_INVALID,
3211 .name = "log_avg_msec",
3212 .lname = "Log averaging (msec)",
3213 .type = FIO_OPT_INT,
3214 .off1 = td_var_offset(log_avg_msec),
3215 .help = "Average bw/iops/lat logs over this period of time",
3217 .category = FIO_OPT_C_LOG,
3218 .group = FIO_OPT_G_INVALID,
3221 .name = "log_offset",
3222 .lname = "Log offset of IO",
3223 .type = FIO_OPT_BOOL,
3224 .off1 = td_var_offset(log_offset),
3225 .help = "Include offset of IO for each log entry",
3227 .category = FIO_OPT_C_LOG,
3228 .group = FIO_OPT_G_INVALID,
3232 .name = "log_compression",
3233 .lname = "Log compression",
3234 .type = FIO_OPT_INT,
3235 .off1 = td_var_offset(log_gz),
3236 .help = "Log in compressed chunks of this size",
3237 .minval = 32 * 1024 * 1024ULL,
3238 .maxval = 512 * 1024 * 1024ULL,
3239 .category = FIO_OPT_C_LOG,
3240 .group = FIO_OPT_G_INVALID,
3243 .name = "log_store_compressed",
3244 .lname = "Log store compressed",
3245 .type = FIO_OPT_BOOL,
3246 .off1 = td_var_offset(log_gz_store),
3247 .help = "Store logs in a compressed format",
3248 .category = FIO_OPT_C_LOG,
3249 .group = FIO_OPT_G_INVALID,
3253 .name = "block_error_percentiles",
3254 .lname = "Block error percentiles",
3255 .type = FIO_OPT_BOOL,
3256 .off1 = td_var_offset(block_error_hist),
3257 .help = "Record trim block errors and make a histogram",
3259 .category = FIO_OPT_C_LOG,
3260 .group = FIO_OPT_G_INVALID,
3263 .name = "bwavgtime",
3264 .lname = "Bandwidth average time",
3265 .type = FIO_OPT_INT,
3266 .off1 = td_var_offset(bw_avg_time),
3267 .help = "Time window over which to calculate bandwidth"
3270 .parent = "write_bw_log",
3273 .category = FIO_OPT_C_LOG,
3274 .group = FIO_OPT_G_INVALID,
3277 .name = "iopsavgtime",
3278 .lname = "IOPS average time",
3279 .type = FIO_OPT_INT,
3280 .off1 = td_var_offset(iops_avg_time),
3281 .help = "Time window over which to calculate IOPS (msec)",
3283 .parent = "write_iops_log",
3286 .category = FIO_OPT_C_LOG,
3287 .group = FIO_OPT_G_INVALID,
3290 .name = "group_reporting",
3291 .lname = "Group reporting",
3292 .type = FIO_OPT_STR_SET,
3293 .off1 = td_var_offset(group_reporting),
3294 .help = "Do reporting on a per-group basis",
3295 .category = FIO_OPT_C_STAT,
3296 .group = FIO_OPT_G_INVALID,
3299 .name = "zero_buffers",
3300 .lname = "Zero I/O buffers",
3301 .type = FIO_OPT_STR_SET,
3302 .off1 = td_var_offset(zero_buffers),
3303 .help = "Init IO buffers to all zeroes",
3304 .category = FIO_OPT_C_IO,
3305 .group = FIO_OPT_G_IO_BUF,
3308 .name = "refill_buffers",
3309 .lname = "Refill I/O buffers",
3310 .type = FIO_OPT_STR_SET,
3311 .off1 = td_var_offset(refill_buffers),
3312 .help = "Refill IO buffers on every IO submit",
3313 .category = FIO_OPT_C_IO,
3314 .group = FIO_OPT_G_IO_BUF,
3317 .name = "scramble_buffers",
3318 .lname = "Scramble I/O buffers",
3319 .type = FIO_OPT_BOOL,
3320 .off1 = td_var_offset(scramble_buffers),
3321 .help = "Slightly scramble buffers on every IO submit",
3323 .category = FIO_OPT_C_IO,
3324 .group = FIO_OPT_G_IO_BUF,
3327 .name = "buffer_pattern",
3328 .lname = "Buffer pattern",
3329 .type = FIO_OPT_STR,
3330 .cb = str_buffer_pattern_cb,
3331 .off1 = td_var_offset(buffer_pattern),
3332 .help = "Fill pattern for IO buffers",
3333 .category = FIO_OPT_C_IO,
3334 .group = FIO_OPT_G_IO_BUF,
3337 .name = "buffer_compress_percentage",
3338 .lname = "Buffer compression percentage",
3339 .type = FIO_OPT_INT,
3340 .cb = str_buffer_compress_cb,
3341 .off1 = td_var_offset(compress_percentage),
3344 .help = "How compressible the buffer is (approximately)",
3346 .category = FIO_OPT_C_IO,
3347 .group = FIO_OPT_G_IO_BUF,
3350 .name = "buffer_compress_chunk",
3351 .lname = "Buffer compression chunk size",
3352 .type = FIO_OPT_INT,
3353 .off1 = td_var_offset(compress_chunk),
3354 .parent = "buffer_compress_percentage",
3356 .help = "Size of compressible region in buffer",
3358 .category = FIO_OPT_C_IO,
3359 .group = FIO_OPT_G_IO_BUF,
3362 .name = "dedupe_percentage",
3363 .lname = "Dedupe percentage",
3364 .type = FIO_OPT_INT,
3365 .cb = str_dedupe_cb,
3366 .off1 = td_var_offset(dedupe_percentage),
3369 .help = "Percentage of buffers that are dedupable",
3371 .category = FIO_OPT_C_IO,
3372 .group = FIO_OPT_G_IO_BUF,
3375 .name = "clat_percentiles",
3376 .lname = "Completion latency percentiles",
3377 .type = FIO_OPT_BOOL,
3378 .off1 = td_var_offset(clat_percentiles),
3379 .help = "Enable the reporting of completion latency percentiles",
3381 .category = FIO_OPT_C_STAT,
3382 .group = FIO_OPT_G_INVALID,
3385 .name = "percentile_list",
3386 .lname = "Percentile list",
3387 .type = FIO_OPT_FLOAT_LIST,
3388 .off1 = td_var_offset(percentile_list),
3389 .off2 = td_var_offset(percentile_precision),
3390 .help = "Specify a custom list of percentiles to report for "
3391 "completion latency and block errors",
3392 .def = "1:5:10:20:30:40:50:60:70:80:90:95:99:99.5:99.9:99.95:99.99",
3393 .maxlen = FIO_IO_U_LIST_MAX_LEN,
3396 .category = FIO_OPT_C_STAT,
3397 .group = FIO_OPT_G_INVALID,
3400 #ifdef FIO_HAVE_DISK_UTIL
3402 .name = "disk_util",
3403 .lname = "Disk utilization",
3404 .type = FIO_OPT_BOOL,
3405 .off1 = td_var_offset(do_disk_util),
3406 .help = "Log disk utilization statistics",
3408 .category = FIO_OPT_C_STAT,
3409 .group = FIO_OPT_G_INVALID,
3413 .name = "gtod_reduce",
3414 .lname = "Reduce gettimeofday() calls",
3415 .type = FIO_OPT_BOOL,
3416 .help = "Greatly reduce number of gettimeofday() calls",
3417 .cb = str_gtod_reduce_cb,
3420 .category = FIO_OPT_C_STAT,
3421 .group = FIO_OPT_G_INVALID,
3424 .name = "disable_lat",
3425 .lname = "Disable all latency stats",
3426 .type = FIO_OPT_BOOL,
3427 .off1 = td_var_offset(disable_lat),
3428 .help = "Disable latency numbers",
3429 .parent = "gtod_reduce",
3432 .category = FIO_OPT_C_STAT,
3433 .group = FIO_OPT_G_INVALID,
3436 .name = "disable_clat",
3437 .lname = "Disable completion latency stats",
3438 .type = FIO_OPT_BOOL,
3439 .off1 = td_var_offset(disable_clat),
3440 .help = "Disable completion latency numbers",
3441 .parent = "gtod_reduce",
3444 .category = FIO_OPT_C_STAT,
3445 .group = FIO_OPT_G_INVALID,
3448 .name = "disable_slat",
3449 .lname = "Disable submission latency stats",
3450 .type = FIO_OPT_BOOL,
3451 .off1 = td_var_offset(disable_slat),
3452 .help = "Disable submission latency numbers",
3453 .parent = "gtod_reduce",
3456 .category = FIO_OPT_C_STAT,
3457 .group = FIO_OPT_G_INVALID,
3460 .name = "disable_bw_measurement",
3461 .lname = "Disable bandwidth stats",
3462 .type = FIO_OPT_BOOL,
3463 .off1 = td_var_offset(disable_bw),
3464 .help = "Disable bandwidth logging",
3465 .parent = "gtod_reduce",
3468 .category = FIO_OPT_C_STAT,
3469 .group = FIO_OPT_G_INVALID,
3473 .lname = "Dedicated gettimeofday() CPU",
3474 .type = FIO_OPT_INT,
3475 .off1 = td_var_offset(gtod_cpu),
3476 .help = "Set up dedicated gettimeofday() thread on this CPU",
3477 .verify = gtod_cpu_verify,
3478 .category = FIO_OPT_C_GENERAL,
3479 .group = FIO_OPT_G_CLOCK,
3482 .name = "unified_rw_reporting",
3483 .type = FIO_OPT_BOOL,
3484 .off1 = td_var_offset(unified_rw_rep),
3485 .help = "Unify reporting across data direction",
3487 .category = FIO_OPT_C_GENERAL,
3488 .group = FIO_OPT_G_INVALID,
3491 .name = "continue_on_error",
3492 .lname = "Continue on error",
3493 .type = FIO_OPT_STR,
3494 .off1 = td_var_offset(continue_on_error),
3495 .help = "Continue on non-fatal errors during IO",
3497 .category = FIO_OPT_C_GENERAL,
3498 .group = FIO_OPT_G_ERR,
3501 .oval = ERROR_TYPE_NONE,
3502 .help = "Exit when an error is encountered",
3505 .oval = ERROR_TYPE_READ,
3506 .help = "Continue on read errors only",
3509 .oval = ERROR_TYPE_WRITE,
3510 .help = "Continue on write errors only",
3513 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
3514 .help = "Continue on any IO errors",
3517 .oval = ERROR_TYPE_VERIFY,
3518 .help = "Continue on verify errors only",
3521 .oval = ERROR_TYPE_ANY,
3522 .help = "Continue on all io and verify errors",
3525 .oval = ERROR_TYPE_NONE,
3526 .help = "Alias for 'none'",
3529 .oval = ERROR_TYPE_ANY,
3530 .help = "Alias for 'all'",
3535 .name = "ignore_error",
3536 .type = FIO_OPT_STR,
3537 .cb = str_ignore_error_cb,
3538 .off1 = td_var_offset(ignore_error_nr),
3539 .help = "Set a specific list of errors to ignore",
3541 .category = FIO_OPT_C_GENERAL,
3542 .group = FIO_OPT_G_ERR,
3545 .name = "error_dump",
3546 .type = FIO_OPT_BOOL,
3547 .off1 = td_var_offset(error_dump),
3549 .help = "Dump info on each error",
3550 .category = FIO_OPT_C_GENERAL,
3551 .group = FIO_OPT_G_ERR,
3556 .type = FIO_OPT_STR_STORE,
3557 .off1 = td_var_offset(profile),
3558 .help = "Select a specific builtin performance test",
3559 .category = FIO_OPT_C_PROFILE,
3560 .group = FIO_OPT_G_INVALID,
3565 .type = FIO_OPT_STR_STORE,
3566 .off1 = td_var_offset(cgroup),
3567 .help = "Add job to cgroup of this name",
3568 .category = FIO_OPT_C_GENERAL,
3569 .group = FIO_OPT_G_CGROUP,
3572 .name = "cgroup_nodelete",
3573 .lname = "Cgroup no-delete",
3574 .type = FIO_OPT_BOOL,
3575 .off1 = td_var_offset(cgroup_nodelete),
3576 .help = "Do not delete cgroups after job completion",
3579 .category = FIO_OPT_C_GENERAL,
3580 .group = FIO_OPT_G_CGROUP,
3583 .name = "cgroup_weight",
3584 .lname = "Cgroup weight",
3585 .type = FIO_OPT_INT,
3586 .off1 = td_var_offset(cgroup_weight),
3587 .help = "Use given weight for cgroup",
3591 .category = FIO_OPT_C_GENERAL,
3592 .group = FIO_OPT_G_CGROUP,
3597 .type = FIO_OPT_INT,
3598 .off1 = td_var_offset(uid),
3599 .help = "Run job with this user ID",
3600 .category = FIO_OPT_C_GENERAL,
3601 .group = FIO_OPT_G_CRED,
3605 .lname = "Group ID",
3606 .type = FIO_OPT_INT,
3607 .off1 = td_var_offset(gid),
3608 .help = "Run job with this group ID",
3609 .category = FIO_OPT_C_GENERAL,
3610 .group = FIO_OPT_G_CRED,
3615 .type = FIO_OPT_INT,
3616 .off1 = td_var_offset(kb_base),
3622 .help = "Use 1024 as the K base",
3626 .help = "Use 1000 as the K base",
3629 .help = "How many bytes per KB for reporting (1000 or 1024)",
3630 .category = FIO_OPT_C_GENERAL,
3631 .group = FIO_OPT_G_INVALID,
3634 .name = "unit_base",
3635 .lname = "Base unit for reporting (Bits or Bytes)",
3636 .type = FIO_OPT_INT,
3637 .off1 = td_var_offset(unit_base),
3642 .help = "Auto-detect",
3646 .help = "Normal (byte based)",
3650 .help = "Bit based",
3653 .help = "Bit multiple of result summary data (8 for byte, 1 for bit)",
3654 .category = FIO_OPT_C_GENERAL,
3655 .group = FIO_OPT_G_INVALID,
3658 .name = "hugepage-size",
3659 .lname = "Hugepage size",
3660 .type = FIO_OPT_INT,
3661 .off1 = td_var_offset(hugepage_size),
3662 .help = "When using hugepages, specify size of each page",
3663 .def = __fio_stringify(FIO_HUGE_PAGE),
3664 .interval = 1024 * 1024,
3665 .category = FIO_OPT_C_GENERAL,
3666 .group = FIO_OPT_G_INVALID,
3670 .lname = "I/O flow ID",
3671 .type = FIO_OPT_INT,
3672 .off1 = td_var_offset(flow_id),
3673 .help = "The flow index ID to use",
3675 .category = FIO_OPT_C_IO,
3676 .group = FIO_OPT_G_IO_FLOW,
3680 .lname = "I/O flow weight",
3681 .type = FIO_OPT_INT,
3682 .off1 = td_var_offset(flow),
3683 .help = "Weight for flow control of this job",
3684 .parent = "flow_id",
3687 .category = FIO_OPT_C_IO,
3688 .group = FIO_OPT_G_IO_FLOW,
3691 .name = "flow_watermark",
3692 .lname = "I/O flow watermark",
3693 .type = FIO_OPT_INT,
3694 .off1 = td_var_offset(flow_watermark),
3695 .help = "High watermark for flow control. This option"
3696 " should be set to the same value for all threads"
3697 " with non-zero flow.",
3698 .parent = "flow_id",
3701 .category = FIO_OPT_C_IO,
3702 .group = FIO_OPT_G_IO_FLOW,
3705 .name = "flow_sleep",
3706 .lname = "I/O flow sleep",
3707 .type = FIO_OPT_INT,
3708 .off1 = td_var_offset(flow_sleep),
3709 .help = "How many microseconds to sleep after being held"
3710 " back by the flow control mechanism",
3711 .parent = "flow_id",
3714 .category = FIO_OPT_C_IO,
3715 .group = FIO_OPT_G_IO_FLOW,
3719 .lname = "Skip operations against bad blocks",
3720 .type = FIO_OPT_BOOL,
3721 .off1 = td_var_offset(skip_bad),
3722 .help = "Skip operations against known bad blocks.",
3725 .category = FIO_OPT_C_IO,
3726 .group = FIO_OPT_G_MTD,
3733 static void add_to_lopt(struct option *lopt, struct fio_option *o,
3734 const char *name, int val)
3736 lopt->name = (char *) name;
3738 if (o->type == FIO_OPT_STR_SET)
3739 lopt->has_arg = optional_argument;
3741 lopt->has_arg = required_argument;
3744 static void options_to_lopts(struct fio_option *opts,
3745 struct option *long_options,
3746 int i, int option_type)
3748 struct fio_option *o = &opts[0];
3750 add_to_lopt(&long_options[i], o, o->name, option_type);
3753 add_to_lopt(&long_options[i], o, o->alias, option_type);
3758 assert(i < FIO_NR_OPTIONS);
3762 void fio_options_set_ioengine_opts(struct option *long_options,
3763 struct thread_data *td)
3768 while (long_options[i].name) {
3769 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
3770 memset(&long_options[i], 0, sizeof(*long_options));
3777 * Just clear out the prior ioengine options.
3782 options_to_lopts(td->io_ops->options, long_options, i,
3783 FIO_GETOPT_IOENGINE);
3786 void fio_options_dup_and_init(struct option *long_options)
3790 options_init(fio_options);
3793 while (long_options[i].name)
3796 options_to_lopts(fio_options, long_options, i, FIO_GETOPT_JOB);
3799 struct fio_keyword {
3805 static struct fio_keyword fio_keywords[] = {
3807 .word = "$pagesize",
3808 .desc = "Page size in the system",
3811 .word = "$mb_memory",
3812 .desc = "Megabytes of memory online",
3816 .desc = "Number of CPUs online in the system",
3823 void fio_keywords_init(void)
3825 unsigned long long mb_memory;
3829 sprintf(buf, "%lu", (unsigned long) page_size);
3830 fio_keywords[0].replace = strdup(buf);
3832 mb_memory = os_phys_mem() / (1024 * 1024);
3833 sprintf(buf, "%llu", mb_memory);
3834 fio_keywords[1].replace = strdup(buf);
3837 sprintf(buf, "%lu", l);
3838 fio_keywords[2].replace = strdup(buf);
3843 static char *bc_calc(char *str)
3845 char buf[128], *tmp;
3850 * No math, just return string
3852 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
3853 !strchr(str, '/')) || strchr(str, '\''))
3857 * Split option from value, we only need to calculate the value
3859 tmp = strchr(str, '=');
3866 * Prevent buffer overflows; such a case isn't reasonable anyway
3868 if (strlen(str) >= 128 || strlen(tmp) > 100)
3871 sprintf(buf, "which %s > /dev/null", BC_APP);
3873 log_err("fio: bc is needed for performing math\n");
3877 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
3878 f = popen(buf, "r");
3882 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
3889 buf[(tmp - str) + ret - 1] = '\0';
3890 memcpy(buf, str, tmp - str);
3896 * Return a copy of the input string with substrings of the form ${VARNAME}
3897 * substituted with the value of the environment variable VARNAME. The
3898 * substitution always occurs, even if VARNAME is empty or the corresponding
3899 * environment variable undefined.
3901 static char *option_dup_subs(const char *opt)
3903 char out[OPT_LEN_MAX+1];
3904 char in[OPT_LEN_MAX+1];
3907 char *ch1, *ch2, *env;
3908 ssize_t nchr = OPT_LEN_MAX;
3911 if (strlen(opt) + 1 > OPT_LEN_MAX) {
3912 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
3916 in[OPT_LEN_MAX] = '\0';
3917 strncpy(in, opt, OPT_LEN_MAX);
3919 while (*inptr && nchr > 0) {
3920 if (inptr[0] == '$' && inptr[1] == '{') {
3921 ch2 = strchr(inptr, '}');
3922 if (ch2 && inptr+1 < ch2) {
3929 envlen = strlen(env);
3930 if (envlen <= nchr) {
3931 memcpy(outptr, env, envlen);
3941 *outptr++ = *inptr++;
3950 * Look for reserved variable names and replace them with real values
3952 static char *fio_keyword_replace(char *opt)
3958 for (i = 0; fio_keywords[i].word != NULL; i++) {
3959 struct fio_keyword *kw = &fio_keywords[i];
3961 while ((s = strstr(opt, kw->word)) != NULL) {
3962 char *new = malloc(strlen(opt) + 1);
3968 * Copy part of the string before the keyword and
3969 * sprintf() the replacement after it.
3971 memcpy(new, opt, olen);
3972 len = sprintf(new + olen, "%s", kw->replace);
3975 * If there's more in the original string, copy that
3978 opt += strlen(kw->word) + olen;
3980 memcpy(new + olen + len, opt, opt - o_org - 1);
3983 * replace opt and free the old opt
3993 * Check for potential math and invoke bc, if possible
4001 static char **dup_and_sub_options(char **opts, int num_opts)
4004 char **opts_copy = malloc(num_opts * sizeof(*opts));
4005 for (i = 0; i < num_opts; i++) {
4006 opts_copy[i] = option_dup_subs(opts[i]);
4009 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
4014 static void show_closest_option(const char *opt)
4016 int best_option, best_distance;
4025 while (name[i] != '\0' && name[i] != '=')
4030 best_distance = INT_MAX;
4032 while (fio_options[i].name) {
4033 distance = string_distance(name, fio_options[i].name);
4034 if (distance < best_distance) {
4035 best_distance = distance;
4041 if (best_option != -1)
4042 log_err("Did you mean %s?\n", fio_options[best_option].name);
4047 int fio_options_parse(struct thread_data *td, char **opts, int num_opts,
4050 int i, ret, unknown;
4053 sort_options(opts, fio_options, num_opts);
4054 opts_copy = dup_and_sub_options(opts, num_opts);
4056 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
4057 struct fio_option *o;
4058 int newret = parse_option(opts_copy[i], opts[i], fio_options,
4059 &o, td, dump_cmdline);
4062 fio_option_mark_set(&td->o, o);
4070 opts_copy[i] = NULL;
4077 ret |= ioengine_load(td);
4079 sort_options(opts_copy, td->io_ops->options, num_opts);
4082 for (i = 0; i < num_opts; i++) {
4083 struct fio_option *o = NULL;
4090 newret = parse_option(opts_copy[i], opts[i],
4091 td->io_ops->options, &o,
4092 td->eo, dump_cmdline);
4096 log_err("Bad option <%s>\n", opts[i]);
4097 show_closest_option(opts[i]);
4100 opts_copy[i] = NULL;
4108 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
4112 ret = parse_cmd_option(opt, val, fio_options, td);
4114 struct fio_option *o;
4116 o = find_option(fio_options, opt);
4118 fio_option_mark_set(&td->o, o);
4124 int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
4127 return parse_cmd_option(opt, val, td->io_ops->options, td->eo);
4130 void fio_fill_default_options(struct thread_data *td)
4132 td->o.magic = OPT_MAGIC;
4133 fill_default_options(td, fio_options);
4136 int fio_show_option_help(const char *opt)
4138 return show_cmd_help(fio_options, opt);
4141 void options_mem_dupe(void *data, struct fio_option *options)
4143 struct fio_option *o;
4146 for (o = &options[0]; o->name; o++) {
4147 if (o->type != FIO_OPT_STR_STORE)
4150 ptr = td_var(data, o, o->off1);
4152 *ptr = strdup(*ptr);
4157 * dupe FIO_OPT_STR_STORE options
4159 void fio_options_mem_dupe(struct thread_data *td)
4161 options_mem_dupe(&td->o, fio_options);
4163 if (td->eo && td->io_ops) {
4164 void *oldeo = td->eo;
4166 td->eo = malloc(td->io_ops->option_struct_size);
4167 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
4168 options_mem_dupe(td->eo, td->io_ops->options);
4172 unsigned int fio_get_kb_base(void *data)
4174 struct thread_options *o = data;
4175 unsigned int kb_base = 0;
4178 * This is a hack... For private options, *data is not holding
4179 * a pointer to the thread_options, but to private data. This means
4180 * we can't safely dereference it, but magic is first so mem wise
4181 * it is valid. But this also means that if the job first sets
4182 * kb_base and expects that to be honored by private options,
4183 * it will be disappointed. We will return the global default
4186 if (o && o->magic == OPT_MAGIC)
4187 kb_base = o->kb_base;
4194 int add_option(struct fio_option *o)
4196 struct fio_option *__o;
4205 if (opt_index + 1 == FIO_MAX_OPTS) {
4206 log_err("fio: FIO_MAX_OPTS is too small\n");
4210 memcpy(&fio_options[opt_index], o, sizeof(*o));
4211 fio_options[opt_index + 1].name = NULL;
4215 void invalidate_profile_options(const char *prof_name)
4217 struct fio_option *o;
4221 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
4222 o->type = FIO_OPT_INVALID;
4223 o->prof_name = NULL;
4229 void add_opt_posval(const char *optname, const char *ival, const char *help)
4231 struct fio_option *o;
4234 o = find_option(fio_options, optname);
4238 for (i = 0; i < PARSE_MAX_VP; i++) {
4239 if (o->posval[i].ival)
4242 o->posval[i].ival = ival;
4243 o->posval[i].help = help;
4248 void del_opt_posval(const char *optname, const char *ival)
4250 struct fio_option *o;
4253 o = find_option(fio_options, optname);
4257 for (i = 0; i < PARSE_MAX_VP; i++) {
4258 if (!o->posval[i].ival)
4260 if (strcmp(o->posval[i].ival, ival))
4263 o->posval[i].ival = NULL;
4264 o->posval[i].help = NULL;
4268 void fio_options_free(struct thread_data *td)
4270 options_free(fio_options, td);
4271 if (td->eo && td->io_ops && td->io_ops->options) {
4272 options_free(td->io_ops->options, td->eo);
4278 struct fio_option *fio_option_find(const char *name)
4280 return find_option(fio_options, name);
4283 static struct fio_option *find_next_opt(struct thread_options *o,
4284 struct fio_option *from,
4287 struct fio_option *opt;
4290 from = &fio_options[0];
4296 if (off1 == from->off1) {
4301 } while (from->name);
4306 static int opt_is_set(struct thread_options *o, struct fio_option *opt)
4308 unsigned int opt_off, index, offset;
4310 opt_off = opt - &fio_options[0];
4311 index = opt_off / (8 * sizeof(uint64_t));
4312 offset = opt_off & ((8 * sizeof(uint64_t)) - 1);
4313 return (o->set_options[index] & (1UL << offset)) != 0;
4316 int __fio_option_is_set(struct thread_options *o, unsigned int off1)
4318 struct fio_option *opt, *next;
4321 while ((opt = find_next_opt(o, next, off1)) != NULL) {
4322 if (opt_is_set(o, opt))
4331 void fio_option_mark_set(struct thread_options *o, struct fio_option *opt)
4333 unsigned int opt_off, index, offset;
4335 opt_off = opt - &fio_options[0];
4336 index = opt_off / (8 * sizeof(uint64_t));
4337 offset = opt_off & ((8 * sizeof(uint64_t)) - 1);
4338 o->set_options[index] |= 1UL << offset;