11 #include <netinet/in.h>
17 #include "lib/pattern.h"
20 #include "crc/crc32c.h"
22 char client_sockaddr_str[INET6_ADDRSTRLEN] = { 0 };
24 struct pattern_fmt_desc fmt_desc[] = {
27 .len = FIELD_SIZE(struct io_u *, offset),
28 .paste = paste_blockoff
33 * Check if mmap/mmaphuge has a :/foo/bar/file at the end. If so, return that.
35 static char *get_opt_postfix(const char *str)
37 char *p = strstr(str, ":");
43 strip_blank_front(&p);
48 static int bs_cmp(const void *p1, const void *p2)
50 const struct bssplit *bsp1 = p1;
51 const struct bssplit *bsp2 = p2;
53 return bsp1->perc < bsp2->perc;
56 static int bssplit_ddir(struct thread_options *o, int ddir, char *str)
58 struct bssplit *bssplit;
59 unsigned int i, perc, perc_missing;
60 unsigned int max_bs, min_bs;
64 o->bssplit_nr[ddir] = 4;
65 bssplit = malloc(4 * sizeof(struct bssplit));
70 while ((fname = strsep(&str, ":")) != NULL) {
77 * grow struct buffer, if needed
79 if (i == o->bssplit_nr[ddir]) {
80 o->bssplit_nr[ddir] <<= 1;
81 bssplit = realloc(bssplit, o->bssplit_nr[ddir]
82 * sizeof(struct bssplit));
85 perc_str = strstr(fname, "/");
89 perc = atoi(perc_str);
97 if (str_to_decimal(fname, &val, 1, o, 0, 0)) {
98 log_err("fio: bssplit conversion failed\n");
109 bssplit[i].perc = perc;
113 o->bssplit_nr[ddir] = i;
116 * Now check if the percentages add up, and how much is missing
118 perc = perc_missing = 0;
119 for (i = 0; i < o->bssplit_nr[ddir]; i++) {
120 struct bssplit *bsp = &bssplit[i];
122 if (bsp->perc == -1U)
128 if (perc > 100 && perc_missing > 1) {
129 log_err("fio: bssplit percentages add to more than 100%%\n");
135 * If values didn't have a percentage set, divide the remains between
139 if (perc_missing == 1 && o->bssplit_nr[ddir] == 1)
141 for (i = 0; i < o->bssplit_nr[ddir]; i++) {
142 struct bssplit *bsp = &bssplit[i];
144 if (bsp->perc == -1U)
145 bsp->perc = (100 - perc) / perc_missing;
149 o->min_bs[ddir] = min_bs;
150 o->max_bs[ddir] = max_bs;
153 * now sort based on percentages, for ease of lookup
155 qsort(bssplit, o->bssplit_nr[ddir], sizeof(struct bssplit), bs_cmp);
156 o->bssplit[ddir] = bssplit;
160 static int str_bssplit_cb(void *data, const char *input)
162 struct thread_data *td = data;
163 char *str, *p, *odir, *ddir;
169 p = str = strdup(input);
171 strip_blank_front(&str);
172 strip_blank_end(str);
174 odir = strchr(str, ',');
176 ddir = strchr(odir + 1, ',');
178 ret = bssplit_ddir(&td->o, DDIR_TRIM, ddir + 1);
184 op = strdup(odir + 1);
185 ret = bssplit_ddir(&td->o, DDIR_TRIM, op);
190 ret = bssplit_ddir(&td->o, DDIR_WRITE, odir + 1);
193 ret = bssplit_ddir(&td->o, DDIR_READ, str);
199 ret = bssplit_ddir(&td->o, DDIR_WRITE, op);
204 ret = bssplit_ddir(&td->o, DDIR_TRIM, op);
208 ret = bssplit_ddir(&td->o, DDIR_READ, str);
215 static int str2error(char *str)
217 const char *err[] = { "EPERM", "ENOENT", "ESRCH", "EINTR", "EIO",
218 "ENXIO", "E2BIG", "ENOEXEC", "EBADF",
219 "ECHILD", "EAGAIN", "ENOMEM", "EACCES",
220 "EFAULT", "ENOTBLK", "EBUSY", "EEXIST",
221 "EXDEV", "ENODEV", "ENOTDIR", "EISDIR",
222 "EINVAL", "ENFILE", "EMFILE", "ENOTTY",
223 "ETXTBSY","EFBIG", "ENOSPC", "ESPIPE",
224 "EROFS","EMLINK", "EPIPE", "EDOM", "ERANGE" };
225 int i = 0, num = sizeof(err) / sizeof(void *);
228 if (!strcmp(err[i], str))
235 static int ignore_error_type(struct thread_data *td, int etype, char *str)
241 if (etype >= ERROR_TYPE_CNT) {
242 log_err("Illegal error type\n");
246 td->o.ignore_error_nr[etype] = 4;
247 error = malloc(4 * sizeof(struct bssplit));
250 while ((fname = strsep(&str, ":")) != NULL) {
256 * grow struct buffer, if needed
258 if (i == td->o.ignore_error_nr[etype]) {
259 td->o.ignore_error_nr[etype] <<= 1;
260 error = realloc(error, td->o.ignore_error_nr[etype]
263 if (fname[0] == 'E') {
264 error[i] = str2error(fname);
266 error[i] = atoi(fname);
268 error[i] = -error[i];
271 log_err("Unknown error %s, please use number value \n",
279 td->o.continue_on_error |= 1 << etype;
280 td->o.ignore_error_nr[etype] = i;
281 td->o.ignore_error[etype] = error;
289 static int str_ignore_error_cb(void *data, const char *input)
291 struct thread_data *td = data;
293 int type = 0, ret = 1;
298 p = str = strdup(input);
300 strip_blank_front(&str);
301 strip_blank_end(str);
307 ret = ignore_error_type(td, type, p);
317 static int str_rw_cb(void *data, const char *str)
319 struct thread_data *td = data;
320 struct thread_options *o = &td->o;
329 nr = get_opt_postfix(str);
334 o->ddir_seq_nr = atoi(nr);
338 if (str_to_decimal(nr, &val, 1, o, 0, 0)) {
339 log_err("fio: rw postfix parsing failed\n");
344 o->ddir_seq_add = val;
351 static int str_mem_cb(void *data, const char *mem)
353 struct thread_data *td = data;
355 if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP ||
356 td->o.mem_type == MEM_MMAPSHARED)
357 td->o.mmapfile = get_opt_postfix(mem);
362 static int fio_clock_source_cb(void *data, const char *str)
364 struct thread_data *td = data;
366 fio_clock_source = td->o.clocksource;
367 fio_clock_source_set = 1;
372 static int str_rwmix_read_cb(void *data, unsigned long long *val)
374 struct thread_data *td = data;
376 td->o.rwmix[DDIR_READ] = *val;
377 td->o.rwmix[DDIR_WRITE] = 100 - *val;
381 static int str_rwmix_write_cb(void *data, unsigned long long *val)
383 struct thread_data *td = data;
385 td->o.rwmix[DDIR_WRITE] = *val;
386 td->o.rwmix[DDIR_READ] = 100 - *val;
390 static int str_exitall_cb(void)
392 exitall_on_terminate = 1;
396 #ifdef FIO_HAVE_CPU_AFFINITY
397 int fio_cpus_split(os_cpu_mask_t *mask, unsigned int cpu_index)
399 unsigned int i, index, cpus_in_mask;
400 const long max_cpu = cpus_online();
402 cpus_in_mask = fio_cpu_count(mask);
403 cpu_index = cpu_index % cpus_in_mask;
406 for (i = 0; i < max_cpu; i++) {
407 if (!fio_cpu_isset(mask, i))
410 if (cpu_index != index)
411 fio_cpu_clear(mask, i);
416 return fio_cpu_count(mask);
419 static int str_cpumask_cb(void *data, unsigned long long *val)
421 struct thread_data *td = data;
429 ret = fio_cpuset_init(&td->o.cpumask);
431 log_err("fio: cpuset_init failed\n");
432 td_verror(td, ret, "fio_cpuset_init");
436 max_cpu = cpus_online();
438 for (i = 0; i < sizeof(int) * 8; i++) {
439 if ((1 << i) & *val) {
441 log_err("fio: CPU %d too large (max=%ld)\n", i,
445 dprint(FD_PARSE, "set cpu allowed %d\n", i);
446 fio_cpu_set(&td->o.cpumask, i);
453 static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask,
460 ret = fio_cpuset_init(mask);
462 log_err("fio: cpuset_init failed\n");
463 td_verror(td, ret, "fio_cpuset_init");
467 p = str = strdup(input);
469 strip_blank_front(&str);
470 strip_blank_end(str);
472 max_cpu = cpus_online();
474 while ((cpu = strsep(&str, ",")) != NULL) {
483 while ((cpu2 = strsep(&str2, "-")) != NULL) {
493 while (icpu <= icpu2) {
494 if (icpu >= FIO_MAX_CPUS) {
495 log_err("fio: your OS only supports up to"
496 " %d CPUs\n", (int) FIO_MAX_CPUS);
500 if (icpu >= max_cpu) {
501 log_err("fio: CPU %d too large (max=%ld)\n",
507 dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
508 fio_cpu_set(mask, icpu);
519 static int str_cpus_allowed_cb(void *data, const char *input)
521 struct thread_data *td = data;
526 return set_cpus_allowed(td, &td->o.cpumask, input);
529 static int str_verify_cpus_allowed_cb(void *data, const char *input)
531 struct thread_data *td = data;
536 return set_cpus_allowed(td, &td->o.verify_cpumask, input);
540 static int str_log_cpus_allowed_cb(void *data, const char *input)
542 struct thread_data *td = data;
547 return set_cpus_allowed(td, &td->o.log_gz_cpumask, input);
549 #endif /* CONFIG_ZLIB */
551 #endif /* FIO_HAVE_CPU_AFFINITY */
553 #ifdef CONFIG_LIBNUMA
554 static int str_numa_cpunodes_cb(void *data, char *input)
556 struct thread_data *td = data;
557 struct bitmask *verify_bitmask;
562 /* numa_parse_nodestring() parses a character string list
563 * of nodes into a bit mask. The bit mask is allocated by
564 * numa_allocate_nodemask(), so it should be freed by
565 * numa_free_nodemask().
567 verify_bitmask = numa_parse_nodestring(input);
568 if (verify_bitmask == NULL) {
569 log_err("fio: numa_parse_nodestring failed\n");
570 td_verror(td, 1, "str_numa_cpunodes_cb");
573 numa_free_nodemask(verify_bitmask);
575 td->o.numa_cpunodes = strdup(input);
579 static int str_numa_mpol_cb(void *data, char *input)
581 struct thread_data *td = data;
582 const char * const policy_types[] =
583 { "default", "prefer", "bind", "interleave", "local", NULL };
586 struct bitmask *verify_bitmask;
591 nodelist = strchr(input, ':');
593 /* NUL-terminate mode */
597 for (i = 0; i <= MPOL_LOCAL; i++) {
598 if (!strcmp(input, policy_types[i])) {
599 td->o.numa_mem_mode = i;
603 if (i > MPOL_LOCAL) {
604 log_err("fio: memory policy should be: default, prefer, bind, interleave, local\n");
608 switch (td->o.numa_mem_mode) {
611 * Insist on a nodelist of one node only
614 char *rest = nodelist;
615 while (isdigit(*rest))
618 log_err("fio: one node only for \'prefer\'\n");
622 log_err("fio: one node is needed for \'prefer\'\n");
626 case MPOL_INTERLEAVE:
628 * Default to online nodes with memory if no nodelist
631 nodelist = strdup("all");
636 * Don't allow a nodelist
639 log_err("fio: NO nodelist for \'local\'\n");
645 * Insist on a nodelist
648 log_err("fio: a nodelist is needed for \'bind\'\n");
655 /* numa_parse_nodestring() parses a character string list
656 * of nodes into a bit mask. The bit mask is allocated by
657 * numa_allocate_nodemask(), so it should be freed by
658 * numa_free_nodemask().
660 switch (td->o.numa_mem_mode) {
662 td->o.numa_mem_prefer_node = atoi(nodelist);
664 case MPOL_INTERLEAVE:
666 verify_bitmask = numa_parse_nodestring(nodelist);
667 if (verify_bitmask == NULL) {
668 log_err("fio: numa_parse_nodestring failed\n");
669 td_verror(td, 1, "str_numa_memnodes_cb");
672 td->o.numa_memnodes = strdup(nodelist);
673 numa_free_nodemask(verify_bitmask);
688 static int str_fst_cb(void *data, const char *str)
690 struct thread_data *td = data;
691 char *nr = get_opt_postfix(str);
693 td->file_service_nr = 1;
695 td->file_service_nr = atoi(nr);
702 #ifdef CONFIG_SYNC_FILE_RANGE
703 static int str_sfr_cb(void *data, const char *str)
705 struct thread_data *td = data;
706 char *nr = get_opt_postfix(str);
708 td->sync_file_range_nr = 1;
710 td->sync_file_range_nr = atoi(nr);
718 static int str_random_distribution_cb(void *data, const char *str)
720 struct thread_data *td = data;
727 if (td->o.random_distribution == FIO_RAND_DIST_ZIPF)
729 else if (td->o.random_distribution == FIO_RAND_DIST_PARETO)
730 val = FIO_DEF_PARETO;
731 else if (td->o.random_distribution == FIO_RAND_DIST_GAUSS)
736 nr = get_opt_postfix(str);
737 if (nr && !str_to_float(nr, &val, 0)) {
738 log_err("fio: random postfix parsing failed\n");
745 if (td->o.random_distribution == FIO_RAND_DIST_ZIPF) {
747 log_err("fio: zipf theta must different than 1.0\n");
750 td->o.zipf_theta.u.f = val;
751 } else if (td->o.random_distribution == FIO_RAND_DIST_PARETO) {
752 if (val <= 0.00 || val >= 1.00) {
753 log_err("fio: pareto input out of range (0 < input < 1.0)\n");
756 td->o.pareto_h.u.f = val;
758 if (val <= 0.00 || val >= 100.0) {
759 log_err("fio: normal deviation out of range (0 < input < 100.0)\n");
762 td->o.gauss_dev.u.f = val;
769 * Return next name in the string. Files are separated with ':'. If the ':'
770 * is escaped with a '\', then that ':' is part of the filename and does not
771 * indicate a new file.
773 static char *get_next_name(char **ptr)
778 if (!str || !strlen(str))
784 * No colon, we are done
786 p = strchr(str, ':');
793 * We got a colon, but it's the first character. Skip and
801 if (*(p - 1) != '\\') {
807 memmove(p - 1, p, strlen(p) + 1);
815 static int get_max_name_idx(char *input)
817 unsigned int cur_idx;
820 p = str = strdup(input);
821 for (cur_idx = 0; ; cur_idx++)
822 if (get_next_name(&str) == NULL)
830 * Returns the directory at the index, indexes > entires will be
831 * assigned via modulo division of the index
833 int set_name_idx(char *target, size_t tlen, char *input, int index)
835 unsigned int cur_idx;
837 char *fname, *str, *p;
839 p = str = strdup(input);
841 index %= get_max_name_idx(input);
842 for (cur_idx = 0; cur_idx <= index; cur_idx++)
843 fname = get_next_name(&str);
845 if (client_sockaddr_str[0]) {
846 len = snprintf(target, tlen, "%s/%s.", fname,
847 client_sockaddr_str);
849 len = snprintf(target, tlen, "%s/", fname);
851 target[tlen - 1] = '\0';
857 static int str_filename_cb(void *data, const char *input)
859 struct thread_data *td = data;
860 char *fname, *str, *p;
862 p = str = strdup(input);
864 strip_blank_front(&str);
865 strip_blank_end(str);
867 if (!td->files_index)
870 while ((fname = get_next_name(&str)) != NULL) {
873 add_file(td, fname, 0, 1);
880 static int str_directory_cb(void *data, const char fio_unused *unused)
882 struct thread_data *td = data;
884 char *dirname, *str, *p;
890 p = str = strdup(td->o.directory);
891 while ((dirname = get_next_name(&str)) != NULL) {
892 if (lstat(dirname, &sb) < 0) {
895 log_err("fio: %s is not a directory\n", dirname);
896 td_verror(td, ret, "lstat");
899 if (!S_ISDIR(sb.st_mode)) {
900 log_err("fio: %s is not a directory\n", dirname);
911 static int str_opendir_cb(void *data, const char fio_unused *str)
913 struct thread_data *td = data;
918 if (!td->files_index)
921 return add_dir_files(td, td->o.opendir);
924 static int str_buffer_pattern_cb(void *data, const char *input)
926 struct thread_data *td = data;
929 /* FIXME: for now buffer pattern does not support formats */
930 ret = parse_and_fill_pattern(input, strlen(input), td->o.buffer_pattern,
931 MAX_PATTERN_SIZE, NULL, 0, NULL, NULL);
936 td->o.buffer_pattern_bytes = ret;
937 if (!td->o.compress_percentage)
938 td->o.refill_buffers = 0;
939 td->o.scramble_buffers = 0;
940 td->o.zero_buffers = 0;
945 static int str_buffer_compress_cb(void *data, unsigned long long *il)
947 struct thread_data *td = data;
949 td->flags |= TD_F_COMPRESS;
950 td->o.compress_percentage = *il;
954 static int str_dedupe_cb(void *data, unsigned long long *il)
956 struct thread_data *td = data;
958 td->flags |= TD_F_COMPRESS;
959 td->o.dedupe_percentage = *il;
960 td->o.refill_buffers = 1;
964 static int str_verify_pattern_cb(void *data, const char *input)
966 struct thread_data *td = data;
969 td->o.verify_fmt_sz = ARRAY_SIZE(td->o.verify_fmt);
970 ret = parse_and_fill_pattern(input, strlen(input), td->o.verify_pattern,
971 MAX_PATTERN_SIZE, fmt_desc, sizeof(fmt_desc),
972 td->o.verify_fmt, &td->o.verify_fmt_sz);
977 td->o.verify_pattern_bytes = ret;
979 * VERIFY_* could already be set
981 if (!fio_option_is_set(&td->o, verify))
982 td->o.verify = VERIFY_PATTERN;
987 static int str_gtod_reduce_cb(void *data, int *il)
989 struct thread_data *td = data;
992 td->o.disable_lat = !!val;
993 td->o.disable_clat = !!val;
994 td->o.disable_slat = !!val;
995 td->o.disable_bw = !!val;
996 td->o.clat_percentiles = !val;
998 td->tv_cache_mask = 63;
1003 static int str_size_cb(void *data, unsigned long long *__val)
1005 struct thread_data *td = data;
1006 unsigned long long v = *__val;
1008 if (parse_is_percent(v)) {
1010 td->o.size_percent = -1ULL - v;
1017 static int rw_verify(struct fio_option *o, void *data)
1019 struct thread_data *td = data;
1021 if (read_only && td_write(td)) {
1022 log_err("fio: job <%s> has write bit set, but fio is in"
1023 " read-only mode\n", td->o.name);
1030 static int gtod_cpu_verify(struct fio_option *o, void *data)
1032 #ifndef FIO_HAVE_CPU_AFFINITY
1033 struct thread_data *td = data;
1035 if (td->o.gtod_cpu) {
1036 log_err("fio: platform must support CPU affinity for"
1037 "gettimeofday() offloading\n");
1048 static struct opt_group fio_opt_groups[] = {
1051 .mask = FIO_OPT_C_GENERAL,
1055 .mask = FIO_OPT_C_IO,
1059 .mask = FIO_OPT_C_FILE,
1062 .name = "Statistics",
1063 .mask = FIO_OPT_C_STAT,
1067 .mask = FIO_OPT_C_LOG,
1071 .mask = FIO_OPT_C_PROFILE,
1078 static struct opt_group *__opt_group_from_mask(struct opt_group *ogs,
1082 struct opt_group *og;
1085 if (*mask == inv_mask || !*mask)
1088 for (i = 0; ogs[i].name; i++) {
1091 if (*mask & og->mask) {
1092 *mask &= ~(og->mask);
1100 struct opt_group *opt_group_from_mask(uint64_t *mask)
1102 return __opt_group_from_mask(fio_opt_groups, mask, FIO_OPT_C_INVALID);
1105 static struct opt_group fio_opt_cat_groups[] = {
1107 .name = "Latency profiling",
1108 .mask = FIO_OPT_G_LATPROF,
1112 .mask = FIO_OPT_G_RATE,
1116 .mask = FIO_OPT_G_ZONE,
1119 .name = "Read/write mix",
1120 .mask = FIO_OPT_G_RWMIX,
1124 .mask = FIO_OPT_G_VERIFY,
1128 .mask = FIO_OPT_G_TRIM,
1131 .name = "I/O Logging",
1132 .mask = FIO_OPT_G_IOLOG,
1135 .name = "I/O Depth",
1136 .mask = FIO_OPT_G_IO_DEPTH,
1140 .mask = FIO_OPT_G_IO_FLOW,
1143 .name = "Description",
1144 .mask = FIO_OPT_G_DESC,
1148 .mask = FIO_OPT_G_FILENAME,
1151 .name = "General I/O",
1152 .mask = FIO_OPT_G_IO_BASIC,
1156 .mask = FIO_OPT_G_CGROUP,
1160 .mask = FIO_OPT_G_RUNTIME,
1164 .mask = FIO_OPT_G_PROCESS,
1167 .name = "Job credentials / priority",
1168 .mask = FIO_OPT_G_CRED,
1171 .name = "Clock settings",
1172 .mask = FIO_OPT_G_CLOCK,
1176 .mask = FIO_OPT_G_IO_TYPE,
1179 .name = "I/O Thinktime",
1180 .mask = FIO_OPT_G_THINKTIME,
1183 .name = "Randomizations",
1184 .mask = FIO_OPT_G_RANDOM,
1187 .name = "I/O buffers",
1188 .mask = FIO_OPT_G_IO_BUF,
1191 .name = "Tiobench profile",
1192 .mask = FIO_OPT_G_TIOBENCH,
1196 .mask = FIO_OPT_G_MTD,
1204 struct opt_group *opt_group_cat_from_mask(uint64_t *mask)
1206 return __opt_group_from_mask(fio_opt_cat_groups, mask, FIO_OPT_G_INVALID);
1210 * Map of job/command line options
1212 struct fio_option fio_options[FIO_MAX_OPTS] = {
1214 .name = "description",
1215 .lname = "Description of job",
1216 .type = FIO_OPT_STR_STORE,
1217 .off1 = td_var_offset(description),
1218 .help = "Text job description",
1219 .category = FIO_OPT_C_GENERAL,
1220 .group = FIO_OPT_G_DESC,
1224 .lname = "Job name",
1225 .type = FIO_OPT_STR_STORE,
1226 .off1 = td_var_offset(name),
1227 .help = "Name of this job",
1228 .category = FIO_OPT_C_GENERAL,
1229 .group = FIO_OPT_G_DESC,
1233 .lname = "Filename(s)",
1234 .type = FIO_OPT_STR_STORE,
1235 .off1 = td_var_offset(filename),
1236 .cb = str_filename_cb,
1237 .prio = -1, /* must come after "directory" */
1238 .help = "File(s) to use for the workload",
1239 .category = FIO_OPT_C_FILE,
1240 .group = FIO_OPT_G_FILENAME,
1243 .name = "directory",
1244 .lname = "Directory",
1245 .type = FIO_OPT_STR_STORE,
1246 .off1 = td_var_offset(directory),
1247 .cb = str_directory_cb,
1248 .help = "Directory to store files in",
1249 .category = FIO_OPT_C_FILE,
1250 .group = FIO_OPT_G_FILENAME,
1253 .name = "filename_format",
1254 .type = FIO_OPT_STR_STORE,
1255 .off1 = td_var_offset(filename_format),
1256 .prio = -1, /* must come after "directory" */
1257 .help = "Override default $jobname.$jobnum.$filenum naming",
1258 .def = "$jobname.$jobnum.$filenum",
1259 .category = FIO_OPT_C_FILE,
1260 .group = FIO_OPT_G_FILENAME,
1264 .lname = "Lockfile",
1265 .type = FIO_OPT_STR,
1266 .off1 = td_var_offset(file_lock_mode),
1267 .help = "Lock file when doing IO to it",
1269 .parent = "filename",
1272 .category = FIO_OPT_C_FILE,
1273 .group = FIO_OPT_G_FILENAME,
1276 .oval = FILE_LOCK_NONE,
1277 .help = "No file locking",
1279 { .ival = "exclusive",
1280 .oval = FILE_LOCK_EXCLUSIVE,
1281 .help = "Exclusive file lock",
1284 .ival = "readwrite",
1285 .oval = FILE_LOCK_READWRITE,
1286 .help = "Read vs write lock",
1292 .lname = "Open directory",
1293 .type = FIO_OPT_STR_STORE,
1294 .off1 = td_var_offset(opendir),
1295 .cb = str_opendir_cb,
1296 .help = "Recursively add files from this directory and down",
1297 .category = FIO_OPT_C_FILE,
1298 .group = FIO_OPT_G_FILENAME,
1302 .lname = "Read/write",
1303 .alias = "readwrite",
1304 .type = FIO_OPT_STR,
1306 .off1 = td_var_offset(td_ddir),
1307 .help = "IO direction",
1309 .verify = rw_verify,
1310 .category = FIO_OPT_C_IO,
1311 .group = FIO_OPT_G_IO_BASIC,
1314 .oval = TD_DDIR_READ,
1315 .help = "Sequential read",
1318 .oval = TD_DDIR_WRITE,
1319 .help = "Sequential write",
1322 .oval = TD_DDIR_TRIM,
1323 .help = "Sequential trim",
1325 { .ival = "randread",
1326 .oval = TD_DDIR_RANDREAD,
1327 .help = "Random read",
1329 { .ival = "randwrite",
1330 .oval = TD_DDIR_RANDWRITE,
1331 .help = "Random write",
1333 { .ival = "randtrim",
1334 .oval = TD_DDIR_RANDTRIM,
1335 .help = "Random trim",
1339 .help = "Sequential read and write mix",
1341 { .ival = "readwrite",
1343 .help = "Sequential read and write mix",
1346 .oval = TD_DDIR_RANDRW,
1347 .help = "Random read and write mix"
1349 { .ival = "trimwrite",
1350 .oval = TD_DDIR_TRIMWRITE,
1351 .help = "Trim and write mix, trims preceding writes"
1356 .name = "rw_sequencer",
1357 .lname = "RW Sequencer",
1358 .type = FIO_OPT_STR,
1359 .off1 = td_var_offset(rw_seq),
1360 .help = "IO offset generator modifier",
1361 .def = "sequential",
1362 .category = FIO_OPT_C_IO,
1363 .group = FIO_OPT_G_IO_BASIC,
1365 { .ival = "sequential",
1367 .help = "Generate sequential offsets",
1369 { .ival = "identical",
1370 .oval = RW_SEQ_IDENT,
1371 .help = "Generate identical offsets",
1378 .lname = "IO Engine",
1379 .type = FIO_OPT_STR_STORE,
1380 .off1 = td_var_offset(ioengine),
1381 .help = "IO engine to use",
1382 .def = FIO_PREFERRED_ENGINE,
1383 .category = FIO_OPT_C_IO,
1384 .group = FIO_OPT_G_IO_BASIC,
1387 .help = "Use read/write",
1390 .help = "Use pread/pwrite",
1393 .help = "Use readv/writev",
1395 #ifdef CONFIG_PWRITEV
1397 .help = "Use preadv/pwritev",
1400 #ifdef CONFIG_LIBAIO
1402 .help = "Linux native asynchronous IO",
1405 #ifdef CONFIG_POSIXAIO
1406 { .ival = "posixaio",
1407 .help = "POSIX asynchronous IO",
1410 #ifdef CONFIG_SOLARISAIO
1411 { .ival = "solarisaio",
1412 .help = "Solaris native asynchronous IO",
1415 #ifdef CONFIG_WINDOWSAIO
1416 { .ival = "windowsaio",
1417 .help = "Windows native asynchronous IO"
1422 .help = "Rados Block Device asynchronous IO"
1426 .help = "Memory mapped IO"
1428 #ifdef CONFIG_LINUX_SPLICE
1430 .help = "splice/vmsplice based IO",
1432 { .ival = "netsplice",
1433 .help = "splice/vmsplice to/from the network",
1436 #ifdef FIO_HAVE_SGIO
1438 .help = "SCSI generic v3 IO",
1442 .help = "Testing engine (no data transfer)",
1445 .help = "Network IO",
1448 .help = "CPU cycle burner engine",
1452 .help = "GUASI IO engine",
1455 #ifdef FIO_HAVE_BINJECT
1456 { .ival = "binject",
1457 .help = "binject direct inject block engine",
1462 .help = "RDMA IO engine",
1465 #ifdef CONFIG_FUSION_AW
1466 { .ival = "fusion-aw-sync",
1467 .help = "Fusion-io atomic write engine",
1470 #ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
1471 { .ival = "e4defrag",
1472 .help = "ext4 defrag engine",
1475 #ifdef CONFIG_LINUX_FALLOCATE
1477 .help = "fallocate() file based engine",
1482 .help = "Glusterfs libgfapi(sync) based engine"
1484 { .ival = "gfapi_async",
1485 .help = "Glusterfs libgfapi(async) based engine"
1488 #ifdef CONFIG_LIBHDFS
1489 { .ival = "libhdfs",
1490 .help = "Hadoop Distributed Filesystem (HDFS) engine"
1493 { .ival = "external",
1494 .help = "Load external engine (append name)",
1500 .lname = "IO Depth",
1501 .type = FIO_OPT_INT,
1502 .off1 = td_var_offset(iodepth),
1503 .help = "Number of IO buffers to keep in flight",
1507 .category = FIO_OPT_C_IO,
1508 .group = FIO_OPT_G_IO_BASIC,
1511 .name = "iodepth_batch",
1512 .lname = "IO Depth batch",
1513 .alias = "iodepth_batch_submit",
1514 .type = FIO_OPT_INT,
1515 .off1 = td_var_offset(iodepth_batch),
1516 .help = "Number of IO buffers to submit in one go",
1517 .parent = "iodepth",
1522 .category = FIO_OPT_C_IO,
1523 .group = FIO_OPT_G_IO_BASIC,
1526 .name = "iodepth_batch_complete_min",
1527 .lname = "Min IO depth batch complete",
1528 .alias = "iodepth_batch_complete",
1529 .type = FIO_OPT_INT,
1530 .off1 = td_var_offset(iodepth_batch_complete_min),
1531 .help = "Min number of IO buffers to retrieve in one go",
1532 .parent = "iodepth",
1537 .category = FIO_OPT_C_IO,
1538 .group = FIO_OPT_G_IO_BASIC,
1541 .name = "iodepth_batch_complete_max",
1542 .lname = "Max IO depth batch complete",
1543 .type = FIO_OPT_INT,
1544 .off1 = td_var_offset(iodepth_batch_complete_max),
1545 .help = "Max number of IO buffers to retrieve in one go",
1546 .parent = "iodepth",
1550 .category = FIO_OPT_C_IO,
1551 .group = FIO_OPT_G_IO_BASIC,
1554 .name = "iodepth_low",
1555 .lname = "IO Depth batch low",
1556 .type = FIO_OPT_INT,
1557 .off1 = td_var_offset(iodepth_low),
1558 .help = "Low water mark for queuing depth",
1559 .parent = "iodepth",
1562 .category = FIO_OPT_C_IO,
1563 .group = FIO_OPT_G_IO_BASIC,
1566 .name = "io_submit_mode",
1567 .lname = "IO submit mode",
1568 .type = FIO_OPT_STR,
1569 .off1 = td_var_offset(io_submit_mode),
1570 .help = "How IO submissions and completions are done",
1572 .category = FIO_OPT_C_IO,
1573 .group = FIO_OPT_G_IO_BASIC,
1576 .oval = IO_MODE_INLINE,
1577 .help = "Submit and complete IO inline",
1579 { .ival = "offload",
1580 .oval = IO_MODE_OFFLOAD,
1581 .help = "Offload submit and complete to threads",
1588 .type = FIO_OPT_STR_VAL,
1590 .off1 = td_var_offset(size),
1591 .help = "Total size of device or files",
1592 .interval = 1024 * 1024,
1593 .category = FIO_OPT_C_IO,
1594 .group = FIO_OPT_G_INVALID,
1598 .alias = "io_limit",
1600 .type = FIO_OPT_STR_VAL,
1601 .off1 = td_var_offset(io_limit),
1602 .interval = 1024 * 1024,
1603 .category = FIO_OPT_C_IO,
1604 .group = FIO_OPT_G_INVALID,
1607 .name = "fill_device",
1608 .lname = "Fill device",
1610 .type = FIO_OPT_BOOL,
1611 .off1 = td_var_offset(fill_device),
1612 .help = "Write until an ENOSPC error occurs",
1614 .category = FIO_OPT_C_FILE,
1615 .group = FIO_OPT_G_INVALID,
1619 .lname = "File size",
1620 .type = FIO_OPT_STR_VAL,
1621 .off1 = td_var_offset(file_size_low),
1622 .off2 = td_var_offset(file_size_high),
1624 .help = "Size of individual files",
1625 .interval = 1024 * 1024,
1626 .category = FIO_OPT_C_FILE,
1627 .group = FIO_OPT_G_INVALID,
1630 .name = "file_append",
1631 .lname = "File append",
1632 .type = FIO_OPT_BOOL,
1633 .off1 = td_var_offset(file_append),
1634 .help = "IO will start at the end of the file(s)",
1636 .category = FIO_OPT_C_FILE,
1637 .group = FIO_OPT_G_INVALID,
1641 .lname = "IO offset",
1642 .alias = "fileoffset",
1643 .type = FIO_OPT_STR_VAL,
1644 .off1 = td_var_offset(start_offset),
1645 .help = "Start IO from this offset",
1647 .interval = 1024 * 1024,
1648 .category = FIO_OPT_C_IO,
1649 .group = FIO_OPT_G_INVALID,
1652 .name = "offset_increment",
1653 .lname = "IO offset increment",
1654 .type = FIO_OPT_STR_VAL,
1655 .off1 = td_var_offset(offset_increment),
1656 .help = "What is the increment from one offset to the next",
1660 .interval = 1024 * 1024,
1661 .category = FIO_OPT_C_IO,
1662 .group = FIO_OPT_G_INVALID,
1665 .name = "number_ios",
1666 .lname = "Number of IOs to perform",
1667 .type = FIO_OPT_STR_VAL,
1668 .off1 = td_var_offset(number_ios),
1669 .help = "Force job completion after this number of IOs",
1671 .category = FIO_OPT_C_IO,
1672 .group = FIO_OPT_G_INVALID,
1676 .lname = "Block size",
1677 .alias = "blocksize",
1678 .type = FIO_OPT_INT,
1679 .off1 = td_var_offset(bs[DDIR_READ]),
1680 .off2 = td_var_offset(bs[DDIR_WRITE]),
1681 .off3 = td_var_offset(bs[DDIR_TRIM]),
1683 .help = "Block size unit",
1688 .category = FIO_OPT_C_IO,
1689 .group = FIO_OPT_G_INVALID,
1693 .lname = "Block size align",
1694 .alias = "blockalign",
1695 .type = FIO_OPT_INT,
1696 .off1 = td_var_offset(ba[DDIR_READ]),
1697 .off2 = td_var_offset(ba[DDIR_WRITE]),
1698 .off3 = td_var_offset(ba[DDIR_TRIM]),
1700 .help = "IO block offset alignment",
1704 .category = FIO_OPT_C_IO,
1705 .group = FIO_OPT_G_INVALID,
1709 .lname = "Block size range",
1710 .alias = "blocksize_range",
1711 .type = FIO_OPT_RANGE,
1712 .off1 = td_var_offset(min_bs[DDIR_READ]),
1713 .off2 = td_var_offset(max_bs[DDIR_READ]),
1714 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
1715 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
1716 .off5 = td_var_offset(min_bs[DDIR_TRIM]),
1717 .off6 = td_var_offset(max_bs[DDIR_TRIM]),
1719 .help = "Set block size range (in more detail than bs)",
1723 .category = FIO_OPT_C_IO,
1724 .group = FIO_OPT_G_INVALID,
1728 .lname = "Block size split",
1729 .type = FIO_OPT_STR,
1730 .cb = str_bssplit_cb,
1731 .off1 = td_var_offset(bssplit),
1732 .help = "Set a specific mix of block sizes",
1735 .category = FIO_OPT_C_IO,
1736 .group = FIO_OPT_G_INVALID,
1739 .name = "bs_unaligned",
1740 .lname = "Block size unaligned",
1741 .alias = "blocksize_unaligned",
1742 .type = FIO_OPT_STR_SET,
1743 .off1 = td_var_offset(bs_unaligned),
1744 .help = "Don't sector align IO buffer sizes",
1747 .category = FIO_OPT_C_IO,
1748 .group = FIO_OPT_G_INVALID,
1751 .name = "bs_is_seq_rand",
1752 .lname = "Block size division is seq/random (not read/write)",
1753 .type = FIO_OPT_BOOL,
1754 .off1 = td_var_offset(bs_is_seq_rand),
1755 .help = "Consider any blocksize setting to be sequential,random",
1757 .parent = "blocksize",
1758 .category = FIO_OPT_C_IO,
1759 .group = FIO_OPT_G_INVALID,
1762 .name = "randrepeat",
1763 .lname = "Random repeatable",
1764 .type = FIO_OPT_BOOL,
1765 .off1 = td_var_offset(rand_repeatable),
1766 .help = "Use repeatable random IO pattern",
1770 .category = FIO_OPT_C_IO,
1771 .group = FIO_OPT_G_RANDOM,
1775 .lname = "The random generator seed",
1776 .type = FIO_OPT_STR_VAL,
1777 .off1 = td_var_offset(rand_seed),
1778 .help = "Set the random generator seed value",
1781 .category = FIO_OPT_C_IO,
1782 .group = FIO_OPT_G_RANDOM,
1785 .name = "use_os_rand",
1786 .lname = "Use OS random",
1787 .type = FIO_OPT_DEPRECATED,
1788 .off1 = td_var_offset(dep_use_os_rand),
1789 .category = FIO_OPT_C_IO,
1790 .group = FIO_OPT_G_RANDOM,
1793 .name = "norandommap",
1794 .lname = "No randommap",
1795 .type = FIO_OPT_STR_SET,
1796 .off1 = td_var_offset(norandommap),
1797 .help = "Accept potential duplicate random blocks",
1801 .category = FIO_OPT_C_IO,
1802 .group = FIO_OPT_G_RANDOM,
1805 .name = "softrandommap",
1806 .lname = "Soft randommap",
1807 .type = FIO_OPT_BOOL,
1808 .off1 = td_var_offset(softrandommap),
1809 .help = "Set norandommap if randommap allocation fails",
1810 .parent = "norandommap",
1813 .category = FIO_OPT_C_IO,
1814 .group = FIO_OPT_G_RANDOM,
1817 .name = "random_generator",
1818 .type = FIO_OPT_STR,
1819 .off1 = td_var_offset(random_generator),
1820 .help = "Type of random number generator to use",
1821 .def = "tausworthe",
1823 { .ival = "tausworthe",
1824 .oval = FIO_RAND_GEN_TAUSWORTHE,
1825 .help = "Strong Tausworthe generator",
1828 .oval = FIO_RAND_GEN_LFSR,
1829 .help = "Variable length LFSR",
1832 .ival = "tausworthe64",
1833 .oval = FIO_RAND_GEN_TAUSWORTHE64,
1834 .help = "64-bit Tausworthe variant",
1837 .category = FIO_OPT_C_IO,
1838 .group = FIO_OPT_G_RANDOM,
1841 .name = "random_distribution",
1842 .type = FIO_OPT_STR,
1843 .off1 = td_var_offset(random_distribution),
1844 .cb = str_random_distribution_cb,
1845 .help = "Random offset distribution generator",
1849 .oval = FIO_RAND_DIST_RANDOM,
1850 .help = "Completely random",
1853 .oval = FIO_RAND_DIST_ZIPF,
1854 .help = "Zipf distribution",
1857 .oval = FIO_RAND_DIST_PARETO,
1858 .help = "Pareto distribution",
1861 .oval = FIO_RAND_DIST_GAUSS,
1862 .help = "Normal (gaussian) distribution",
1865 .category = FIO_OPT_C_IO,
1866 .group = FIO_OPT_G_RANDOM,
1869 .name = "percentage_random",
1870 .lname = "Percentage Random",
1871 .type = FIO_OPT_INT,
1872 .off1 = td_var_offset(perc_rand[DDIR_READ]),
1873 .off2 = td_var_offset(perc_rand[DDIR_WRITE]),
1874 .off3 = td_var_offset(perc_rand[DDIR_TRIM]),
1876 .help = "Percentage of seq/random mix that should be random",
1877 .def = "100,100,100",
1879 .inverse = "percentage_sequential",
1880 .category = FIO_OPT_C_IO,
1881 .group = FIO_OPT_G_RANDOM,
1884 .name = "percentage_sequential",
1885 .lname = "Percentage Sequential",
1886 .type = FIO_OPT_DEPRECATED,
1887 .category = FIO_OPT_C_IO,
1888 .group = FIO_OPT_G_RANDOM,
1891 .name = "allrandrepeat",
1892 .type = FIO_OPT_BOOL,
1893 .off1 = td_var_offset(allrand_repeatable),
1894 .help = "Use repeatable random numbers for everything",
1896 .category = FIO_OPT_C_IO,
1897 .group = FIO_OPT_G_RANDOM,
1901 .lname = "Number of files",
1902 .alias = "nr_files",
1903 .type = FIO_OPT_INT,
1904 .off1 = td_var_offset(nr_files),
1905 .help = "Split job workload between this number of files",
1908 .category = FIO_OPT_C_FILE,
1909 .group = FIO_OPT_G_INVALID,
1912 .name = "openfiles",
1913 .lname = "Number of open files",
1914 .type = FIO_OPT_INT,
1915 .off1 = td_var_offset(open_files),
1916 .help = "Number of files to keep open at the same time",
1917 .category = FIO_OPT_C_FILE,
1918 .group = FIO_OPT_G_INVALID,
1921 .name = "file_service_type",
1922 .lname = "File service type",
1923 .type = FIO_OPT_STR,
1925 .off1 = td_var_offset(file_service_type),
1926 .help = "How to select which file to service next",
1927 .def = "roundrobin",
1928 .category = FIO_OPT_C_FILE,
1929 .group = FIO_OPT_G_INVALID,
1932 .oval = FIO_FSERVICE_RANDOM,
1933 .help = "Choose a file at random",
1935 { .ival = "roundrobin",
1936 .oval = FIO_FSERVICE_RR,
1937 .help = "Round robin select files",
1939 { .ival = "sequential",
1940 .oval = FIO_FSERVICE_SEQ,
1941 .help = "Finish one file before moving to the next",
1944 .parent = "nrfiles",
1947 #ifdef CONFIG_POSIX_FALLOCATE
1949 .name = "fallocate",
1950 .lname = "Fallocate",
1951 .type = FIO_OPT_STR,
1952 .off1 = td_var_offset(fallocate_mode),
1953 .help = "Whether pre-allocation is performed when laying out files",
1955 .category = FIO_OPT_C_FILE,
1956 .group = FIO_OPT_G_INVALID,
1959 .oval = FIO_FALLOCATE_NONE,
1960 .help = "Do not pre-allocate space",
1963 .oval = FIO_FALLOCATE_POSIX,
1964 .help = "Use posix_fallocate()",
1966 #ifdef CONFIG_LINUX_FALLOCATE
1968 .oval = FIO_FALLOCATE_KEEP_SIZE,
1969 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
1972 /* Compatibility with former boolean values */
1974 .oval = FIO_FALLOCATE_NONE,
1975 .help = "Alias for 'none'",
1978 .oval = FIO_FALLOCATE_POSIX,
1979 .help = "Alias for 'posix'",
1983 #endif /* CONFIG_POSIX_FALLOCATE */
1985 .name = "fadvise_hint",
1986 .lname = "Fadvise hint",
1987 .type = FIO_OPT_BOOL,
1988 .off1 = td_var_offset(fadvise_hint),
1989 .help = "Use fadvise() to advise the kernel on IO pattern",
1991 .category = FIO_OPT_C_FILE,
1992 .group = FIO_OPT_G_INVALID,
1994 #ifdef FIO_HAVE_STREAMID
1996 .name = "fadvise_stream",
1997 .lname = "Fadvise stream",
1998 .type = FIO_OPT_INT,
1999 .off1 = td_var_offset(fadvise_stream),
2000 .help = "Use fadvise() to set stream ID",
2001 .category = FIO_OPT_C_FILE,
2002 .group = FIO_OPT_G_INVALID,
2008 .type = FIO_OPT_INT,
2009 .off1 = td_var_offset(fsync_blocks),
2010 .help = "Issue fsync for writes every given number of blocks",
2013 .category = FIO_OPT_C_FILE,
2014 .group = FIO_OPT_G_INVALID,
2017 .name = "fdatasync",
2018 .lname = "Fdatasync",
2019 .type = FIO_OPT_INT,
2020 .off1 = td_var_offset(fdatasync_blocks),
2021 .help = "Issue fdatasync for writes every given number of blocks",
2024 .category = FIO_OPT_C_FILE,
2025 .group = FIO_OPT_G_INVALID,
2028 .name = "write_barrier",
2029 .lname = "Write barrier",
2030 .type = FIO_OPT_INT,
2031 .off1 = td_var_offset(barrier_blocks),
2032 .help = "Make every Nth write a barrier write",
2035 .category = FIO_OPT_C_IO,
2036 .group = FIO_OPT_G_INVALID,
2038 #ifdef CONFIG_SYNC_FILE_RANGE
2040 .name = "sync_file_range",
2041 .lname = "Sync file range",
2043 { .ival = "wait_before",
2044 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
2045 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
2049 .oval = SYNC_FILE_RANGE_WRITE,
2050 .help = "SYNC_FILE_RANGE_WRITE",
2054 .ival = "wait_after",
2055 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
2056 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
2060 .type = FIO_OPT_STR_MULTI,
2062 .off1 = td_var_offset(sync_file_range),
2063 .help = "Use sync_file_range()",
2064 .category = FIO_OPT_C_FILE,
2065 .group = FIO_OPT_G_INVALID,
2070 .lname = "Direct I/O",
2071 .type = FIO_OPT_BOOL,
2072 .off1 = td_var_offset(odirect),
2073 .help = "Use O_DIRECT IO (negates buffered)",
2075 .inverse = "buffered",
2076 .category = FIO_OPT_C_IO,
2077 .group = FIO_OPT_G_IO_TYPE,
2081 .lname = "Atomic I/O",
2082 .type = FIO_OPT_BOOL,
2083 .off1 = td_var_offset(oatomic),
2084 .help = "Use Atomic IO with O_DIRECT (implies O_DIRECT)",
2086 .category = FIO_OPT_C_IO,
2087 .group = FIO_OPT_G_IO_TYPE,
2091 .lname = "Buffered I/O",
2092 .type = FIO_OPT_BOOL,
2093 .off1 = td_var_offset(odirect),
2095 .help = "Use buffered IO (negates direct)",
2097 .inverse = "direct",
2098 .category = FIO_OPT_C_IO,
2099 .group = FIO_OPT_G_IO_TYPE,
2102 .name = "overwrite",
2103 .lname = "Overwrite",
2104 .type = FIO_OPT_BOOL,
2105 .off1 = td_var_offset(overwrite),
2106 .help = "When writing, set whether to overwrite current data",
2108 .category = FIO_OPT_C_FILE,
2109 .group = FIO_OPT_G_INVALID,
2114 .type = FIO_OPT_INT,
2115 .off1 = td_var_offset(loops),
2116 .help = "Number of times to run the job",
2119 .category = FIO_OPT_C_GENERAL,
2120 .group = FIO_OPT_G_RUNTIME,
2124 .lname = "Number of jobs",
2125 .type = FIO_OPT_INT,
2126 .off1 = td_var_offset(numjobs),
2127 .help = "Duplicate this job this many times",
2130 .category = FIO_OPT_C_GENERAL,
2131 .group = FIO_OPT_G_RUNTIME,
2134 .name = "startdelay",
2135 .lname = "Start delay",
2136 .type = FIO_OPT_STR_VAL_TIME,
2137 .off1 = td_var_offset(start_delay),
2138 .off2 = td_var_offset(start_delay_high),
2139 .help = "Only start job when this period has passed",
2143 .category = FIO_OPT_C_GENERAL,
2144 .group = FIO_OPT_G_RUNTIME,
2150 .type = FIO_OPT_STR_VAL_TIME,
2151 .off1 = td_var_offset(timeout),
2152 .help = "Stop workload when this amount of time has passed",
2156 .category = FIO_OPT_C_GENERAL,
2157 .group = FIO_OPT_G_RUNTIME,
2160 .name = "time_based",
2161 .lname = "Time based",
2162 .type = FIO_OPT_STR_SET,
2163 .off1 = td_var_offset(time_based),
2164 .help = "Keep running until runtime/timeout is met",
2165 .category = FIO_OPT_C_GENERAL,
2166 .group = FIO_OPT_G_RUNTIME,
2169 .name = "verify_only",
2170 .lname = "Verify only",
2171 .type = FIO_OPT_STR_SET,
2172 .off1 = td_var_offset(verify_only),
2173 .help = "Verifies previously written data is still valid",
2174 .category = FIO_OPT_C_GENERAL,
2175 .group = FIO_OPT_G_RUNTIME,
2178 .name = "ramp_time",
2179 .lname = "Ramp time",
2180 .type = FIO_OPT_STR_VAL_TIME,
2181 .off1 = td_var_offset(ramp_time),
2182 .help = "Ramp up time before measuring performance",
2185 .category = FIO_OPT_C_GENERAL,
2186 .group = FIO_OPT_G_RUNTIME,
2189 .name = "clocksource",
2190 .lname = "Clock source",
2191 .type = FIO_OPT_STR,
2192 .cb = fio_clock_source_cb,
2193 .off1 = td_var_offset(clocksource),
2194 .help = "What type of timing source to use",
2195 .category = FIO_OPT_C_GENERAL,
2196 .group = FIO_OPT_G_CLOCK,
2198 #ifdef CONFIG_GETTIMEOFDAY
2199 { .ival = "gettimeofday",
2201 .help = "Use gettimeofday(2) for timing",
2204 #ifdef CONFIG_CLOCK_GETTIME
2205 { .ival = "clock_gettime",
2206 .oval = CS_CGETTIME,
2207 .help = "Use clock_gettime(2) for timing",
2210 #ifdef ARCH_HAVE_CPU_CLOCK
2212 .oval = CS_CPUCLOCK,
2213 .help = "Use CPU private clock",
2221 .lname = "I/O Memory",
2222 .type = FIO_OPT_STR,
2224 .off1 = td_var_offset(mem_type),
2225 .help = "Backing type for IO buffers",
2227 .category = FIO_OPT_C_IO,
2228 .group = FIO_OPT_G_INVALID,
2232 .help = "Use malloc(3) for IO buffers",
2234 #ifndef CONFIG_NO_SHM
2237 .help = "Use shared memory segments for IO buffers",
2239 #ifdef FIO_HAVE_HUGETLB
2240 { .ival = "shmhuge",
2241 .oval = MEM_SHMHUGE,
2242 .help = "Like shm, but use huge pages",
2248 .help = "Use mmap(2) (file or anon) for IO buffers",
2250 { .ival = "mmapshared",
2251 .oval = MEM_MMAPSHARED,
2252 .help = "Like mmap, but use the shared flag",
2254 #ifdef FIO_HAVE_HUGETLB
2255 { .ival = "mmaphuge",
2256 .oval = MEM_MMAPHUGE,
2257 .help = "Like mmap, but use huge pages",
2263 .name = "iomem_align",
2264 .alias = "mem_align",
2265 .lname = "I/O memory alignment",
2266 .type = FIO_OPT_INT,
2267 .off1 = td_var_offset(mem_align),
2269 .help = "IO memory buffer offset alignment",
2273 .category = FIO_OPT_C_IO,
2274 .group = FIO_OPT_G_INVALID,
2279 .type = FIO_OPT_STR,
2280 .off1 = td_var_offset(verify),
2281 .help = "Verify data written",
2283 .category = FIO_OPT_C_IO,
2284 .group = FIO_OPT_G_VERIFY,
2287 .oval = VERIFY_NONE,
2288 .help = "Don't do IO verification",
2292 .help = "Use md5 checksums for verification",
2295 .oval = VERIFY_CRC64,
2296 .help = "Use crc64 checksums for verification",
2299 .oval = VERIFY_CRC32,
2300 .help = "Use crc32 checksums for verification",
2302 { .ival = "crc32c-intel",
2303 .oval = VERIFY_CRC32C,
2304 .help = "Use crc32c checksums for verification (hw assisted, if available)",
2307 .oval = VERIFY_CRC32C,
2308 .help = "Use crc32c checksums for verification (hw assisted, if available)",
2311 .oval = VERIFY_CRC16,
2312 .help = "Use crc16 checksums for verification",
2315 .oval = VERIFY_CRC7,
2316 .help = "Use crc7 checksums for verification",
2319 .oval = VERIFY_SHA1,
2320 .help = "Use sha1 checksums for verification",
2323 .oval = VERIFY_SHA256,
2324 .help = "Use sha256 checksums for verification",
2327 .oval = VERIFY_SHA512,
2328 .help = "Use sha512 checksums for verification",
2331 .oval = VERIFY_XXHASH,
2332 .help = "Use xxhash checksums for verification",
2334 /* Meta information was included into verify_header,
2335 * 'meta' verification is implied by default. */
2337 .oval = VERIFY_HDR_ONLY,
2338 .help = "Use io information for verification. "
2339 "Now is implied by default, thus option is obsolete, "
2342 { .ival = "pattern",
2343 .oval = VERIFY_PATTERN_NO_HDR,
2344 .help = "Verify strict pattern",
2348 .oval = VERIFY_NULL,
2349 .help = "Pretend to verify",
2354 .name = "do_verify",
2355 .lname = "Perform verify step",
2356 .type = FIO_OPT_BOOL,
2357 .off1 = td_var_offset(do_verify),
2358 .help = "Run verification stage after write",
2362 .category = FIO_OPT_C_IO,
2363 .group = FIO_OPT_G_VERIFY,
2366 .name = "verifysort",
2367 .lname = "Verify sort",
2368 .type = FIO_OPT_BOOL,
2369 .off1 = td_var_offset(verifysort),
2370 .help = "Sort written verify blocks for read back",
2374 .category = FIO_OPT_C_IO,
2375 .group = FIO_OPT_G_VERIFY,
2378 .name = "verifysort_nr",
2379 .type = FIO_OPT_INT,
2380 .off1 = td_var_offset(verifysort_nr),
2381 .help = "Pre-load and sort verify blocks for a read workload",
2386 .category = FIO_OPT_C_IO,
2387 .group = FIO_OPT_G_VERIFY,
2390 .name = "verify_interval",
2391 .lname = "Verify interval",
2392 .type = FIO_OPT_INT,
2393 .off1 = td_var_offset(verify_interval),
2394 .minval = 2 * sizeof(struct verify_header),
2395 .help = "Store verify buffer header every N bytes",
2398 .interval = 2 * sizeof(struct verify_header),
2399 .category = FIO_OPT_C_IO,
2400 .group = FIO_OPT_G_VERIFY,
2403 .name = "verify_offset",
2404 .lname = "Verify offset",
2405 .type = FIO_OPT_INT,
2406 .help = "Offset verify header location by N bytes",
2407 .off1 = td_var_offset(verify_offset),
2408 .minval = sizeof(struct verify_header),
2411 .category = FIO_OPT_C_IO,
2412 .group = FIO_OPT_G_VERIFY,
2415 .name = "verify_pattern",
2416 .lname = "Verify pattern",
2417 .type = FIO_OPT_STR,
2418 .cb = str_verify_pattern_cb,
2419 .off1 = td_var_offset(verify_pattern),
2420 .help = "Fill pattern for IO buffers",
2423 .category = FIO_OPT_C_IO,
2424 .group = FIO_OPT_G_VERIFY,
2427 .name = "verify_fatal",
2428 .lname = "Verify fatal",
2429 .type = FIO_OPT_BOOL,
2430 .off1 = td_var_offset(verify_fatal),
2432 .help = "Exit on a single verify failure, don't continue",
2435 .category = FIO_OPT_C_IO,
2436 .group = FIO_OPT_G_VERIFY,
2439 .name = "verify_dump",
2440 .lname = "Verify dump",
2441 .type = FIO_OPT_BOOL,
2442 .off1 = td_var_offset(verify_dump),
2444 .help = "Dump contents of good and bad blocks on failure",
2447 .category = FIO_OPT_C_IO,
2448 .group = FIO_OPT_G_VERIFY,
2451 .name = "verify_async",
2452 .lname = "Verify asynchronously",
2453 .type = FIO_OPT_INT,
2454 .off1 = td_var_offset(verify_async),
2456 .help = "Number of async verifier threads to use",
2459 .category = FIO_OPT_C_IO,
2460 .group = FIO_OPT_G_VERIFY,
2463 .name = "verify_backlog",
2464 .lname = "Verify backlog",
2465 .type = FIO_OPT_STR_VAL,
2466 .off1 = td_var_offset(verify_backlog),
2467 .help = "Verify after this number of blocks are written",
2470 .category = FIO_OPT_C_IO,
2471 .group = FIO_OPT_G_VERIFY,
2474 .name = "verify_backlog_batch",
2475 .lname = "Verify backlog batch",
2476 .type = FIO_OPT_INT,
2477 .off1 = td_var_offset(verify_batch),
2478 .help = "Verify this number of IO blocks",
2481 .category = FIO_OPT_C_IO,
2482 .group = FIO_OPT_G_VERIFY,
2484 #ifdef FIO_HAVE_CPU_AFFINITY
2486 .name = "verify_async_cpus",
2487 .lname = "Async verify CPUs",
2488 .type = FIO_OPT_STR,
2489 .cb = str_verify_cpus_allowed_cb,
2490 .off1 = td_var_offset(verify_cpumask),
2491 .help = "Set CPUs allowed for async verify threads",
2492 .parent = "verify_async",
2494 .category = FIO_OPT_C_IO,
2495 .group = FIO_OPT_G_VERIFY,
2499 .name = "experimental_verify",
2500 .off1 = td_var_offset(experimental_verify),
2501 .type = FIO_OPT_BOOL,
2502 .help = "Enable experimental verification",
2504 .category = FIO_OPT_C_IO,
2505 .group = FIO_OPT_G_VERIFY,
2508 .name = "verify_state_load",
2509 .lname = "Load verify state",
2510 .off1 = td_var_offset(verify_state),
2511 .type = FIO_OPT_BOOL,
2512 .help = "Load verify termination state",
2514 .category = FIO_OPT_C_IO,
2515 .group = FIO_OPT_G_VERIFY,
2518 .name = "verify_state_save",
2519 .lname = "Save verify state",
2520 .off1 = td_var_offset(verify_state_save),
2521 .type = FIO_OPT_BOOL,
2523 .help = "Save verify state on termination",
2525 .category = FIO_OPT_C_IO,
2526 .group = FIO_OPT_G_VERIFY,
2528 #ifdef FIO_HAVE_TRIM
2530 .name = "trim_percentage",
2531 .lname = "Trim percentage",
2532 .type = FIO_OPT_INT,
2533 .off1 = td_var_offset(trim_percentage),
2536 .help = "Number of verify blocks to discard/trim",
2541 .category = FIO_OPT_C_IO,
2542 .group = FIO_OPT_G_TRIM,
2545 .name = "trim_verify_zero",
2546 .lname = "Verify trim zero",
2547 .type = FIO_OPT_BOOL,
2548 .help = "Verify that trim/discarded blocks are returned as zeroes",
2549 .off1 = td_var_offset(trim_zero),
2550 .parent = "trim_percentage",
2553 .category = FIO_OPT_C_IO,
2554 .group = FIO_OPT_G_TRIM,
2557 .name = "trim_backlog",
2558 .lname = "Trim backlog",
2559 .type = FIO_OPT_STR_VAL,
2560 .off1 = td_var_offset(trim_backlog),
2561 .help = "Trim after this number of blocks are written",
2562 .parent = "trim_percentage",
2565 .category = FIO_OPT_C_IO,
2566 .group = FIO_OPT_G_TRIM,
2569 .name = "trim_backlog_batch",
2570 .lname = "Trim backlog batch",
2571 .type = FIO_OPT_INT,
2572 .off1 = td_var_offset(trim_batch),
2573 .help = "Trim this number of IO blocks",
2574 .parent = "trim_percentage",
2577 .category = FIO_OPT_C_IO,
2578 .group = FIO_OPT_G_TRIM,
2582 .name = "write_iolog",
2583 .lname = "Write I/O log",
2584 .type = FIO_OPT_STR_STORE,
2585 .off1 = td_var_offset(write_iolog_file),
2586 .help = "Store IO pattern to file",
2587 .category = FIO_OPT_C_IO,
2588 .group = FIO_OPT_G_IOLOG,
2591 .name = "read_iolog",
2592 .lname = "Read I/O log",
2593 .type = FIO_OPT_STR_STORE,
2594 .off1 = td_var_offset(read_iolog_file),
2595 .help = "Playback IO pattern from file",
2596 .category = FIO_OPT_C_IO,
2597 .group = FIO_OPT_G_IOLOG,
2600 .name = "replay_no_stall",
2601 .lname = "Don't stall on replay",
2602 .type = FIO_OPT_BOOL,
2603 .off1 = td_var_offset(no_stall),
2605 .parent = "read_iolog",
2607 .help = "Playback IO pattern file as fast as possible without stalls",
2608 .category = FIO_OPT_C_IO,
2609 .group = FIO_OPT_G_IOLOG,
2612 .name = "replay_redirect",
2613 .lname = "Redirect device for replay",
2614 .type = FIO_OPT_STR_STORE,
2615 .off1 = td_var_offset(replay_redirect),
2616 .parent = "read_iolog",
2618 .help = "Replay all I/O onto this device, regardless of trace device",
2619 .category = FIO_OPT_C_IO,
2620 .group = FIO_OPT_G_IOLOG,
2623 .name = "replay_scale",
2624 .lname = "Replace offset scale factor",
2625 .type = FIO_OPT_INT,
2626 .off1 = td_var_offset(replay_scale),
2627 .parent = "read_iolog",
2629 .help = "Align offsets to this blocksize",
2630 .category = FIO_OPT_C_IO,
2631 .group = FIO_OPT_G_IOLOG,
2634 .name = "replay_align",
2635 .lname = "Replace alignment",
2636 .type = FIO_OPT_INT,
2637 .off1 = td_var_offset(replay_align),
2638 .parent = "read_iolog",
2639 .help = "Scale offset down by this factor",
2640 .category = FIO_OPT_C_IO,
2641 .group = FIO_OPT_G_IOLOG,
2645 .name = "exec_prerun",
2646 .lname = "Pre-execute runnable",
2647 .type = FIO_OPT_STR_STORE,
2648 .off1 = td_var_offset(exec_prerun),
2649 .help = "Execute this file prior to running job",
2650 .category = FIO_OPT_C_GENERAL,
2651 .group = FIO_OPT_G_INVALID,
2654 .name = "exec_postrun",
2655 .lname = "Post-execute runnable",
2656 .type = FIO_OPT_STR_STORE,
2657 .off1 = td_var_offset(exec_postrun),
2658 .help = "Execute this file after running job",
2659 .category = FIO_OPT_C_GENERAL,
2660 .group = FIO_OPT_G_INVALID,
2662 #ifdef FIO_HAVE_IOSCHED_SWITCH
2664 .name = "ioscheduler",
2665 .lname = "I/O scheduler",
2666 .type = FIO_OPT_STR_STORE,
2667 .off1 = td_var_offset(ioscheduler),
2668 .help = "Use this IO scheduler on the backing device",
2669 .category = FIO_OPT_C_FILE,
2670 .group = FIO_OPT_G_INVALID,
2675 .lname = "Zone size",
2676 .type = FIO_OPT_STR_VAL,
2677 .off1 = td_var_offset(zone_size),
2678 .help = "Amount of data to read per zone",
2680 .interval = 1024 * 1024,
2681 .category = FIO_OPT_C_IO,
2682 .group = FIO_OPT_G_ZONE,
2685 .name = "zonerange",
2686 .lname = "Zone range",
2687 .type = FIO_OPT_STR_VAL,
2688 .off1 = td_var_offset(zone_range),
2689 .help = "Give size of an IO zone",
2691 .interval = 1024 * 1024,
2692 .category = FIO_OPT_C_IO,
2693 .group = FIO_OPT_G_ZONE,
2697 .lname = "Zone skip",
2698 .type = FIO_OPT_STR_VAL,
2699 .off1 = td_var_offset(zone_skip),
2700 .help = "Space between IO zones",
2702 .interval = 1024 * 1024,
2703 .category = FIO_OPT_C_IO,
2704 .group = FIO_OPT_G_ZONE,
2708 .lname = "Lock memory",
2709 .type = FIO_OPT_STR_VAL,
2710 .off1 = td_var_offset(lockmem),
2711 .help = "Lock down this amount of memory (per worker)",
2713 .interval = 1024 * 1024,
2714 .category = FIO_OPT_C_GENERAL,
2715 .group = FIO_OPT_G_INVALID,
2718 .name = "rwmixread",
2719 .lname = "Read/write mix read",
2720 .type = FIO_OPT_INT,
2721 .cb = str_rwmix_read_cb,
2722 .off1 = td_var_offset(rwmix[DDIR_READ]),
2724 .help = "Percentage of mixed workload that is reads",
2727 .inverse = "rwmixwrite",
2728 .category = FIO_OPT_C_IO,
2729 .group = FIO_OPT_G_RWMIX,
2732 .name = "rwmixwrite",
2733 .lname = "Read/write mix write",
2734 .type = FIO_OPT_INT,
2735 .cb = str_rwmix_write_cb,
2736 .off1 = td_var_offset(rwmix[DDIR_WRITE]),
2738 .help = "Percentage of mixed workload that is writes",
2741 .inverse = "rwmixread",
2742 .category = FIO_OPT_C_IO,
2743 .group = FIO_OPT_G_RWMIX,
2746 .name = "rwmixcycle",
2747 .lname = "Read/write mix cycle",
2748 .type = FIO_OPT_DEPRECATED,
2749 .category = FIO_OPT_C_IO,
2750 .group = FIO_OPT_G_RWMIX,
2755 .type = FIO_OPT_INT,
2756 .off1 = td_var_offset(nice),
2757 .help = "Set job CPU nice value",
2762 .category = FIO_OPT_C_GENERAL,
2763 .group = FIO_OPT_G_CRED,
2765 #ifdef FIO_HAVE_IOPRIO
2768 .lname = "I/O nice priority",
2769 .type = FIO_OPT_INT,
2770 .off1 = td_var_offset(ioprio),
2771 .help = "Set job IO priority value",
2775 .category = FIO_OPT_C_GENERAL,
2776 .group = FIO_OPT_G_CRED,
2779 .name = "prioclass",
2780 .lname = "I/O nice priority class",
2781 .type = FIO_OPT_INT,
2782 .off1 = td_var_offset(ioprio_class),
2783 .help = "Set job IO priority class",
2787 .category = FIO_OPT_C_GENERAL,
2788 .group = FIO_OPT_G_CRED,
2792 .name = "thinktime",
2793 .lname = "Thinktime",
2794 .type = FIO_OPT_INT,
2795 .off1 = td_var_offset(thinktime),
2796 .help = "Idle time between IO buffers (usec)",
2799 .category = FIO_OPT_C_IO,
2800 .group = FIO_OPT_G_THINKTIME,
2803 .name = "thinktime_spin",
2804 .lname = "Thinktime spin",
2805 .type = FIO_OPT_INT,
2806 .off1 = td_var_offset(thinktime_spin),
2807 .help = "Start think time by spinning this amount (usec)",
2810 .parent = "thinktime",
2812 .category = FIO_OPT_C_IO,
2813 .group = FIO_OPT_G_THINKTIME,
2816 .name = "thinktime_blocks",
2817 .lname = "Thinktime blocks",
2818 .type = FIO_OPT_INT,
2819 .off1 = td_var_offset(thinktime_blocks),
2820 .help = "IO buffer period between 'thinktime'",
2822 .parent = "thinktime",
2824 .category = FIO_OPT_C_IO,
2825 .group = FIO_OPT_G_THINKTIME,
2829 .lname = "I/O rate",
2830 .type = FIO_OPT_INT,
2831 .off1 = td_var_offset(rate[DDIR_READ]),
2832 .off2 = td_var_offset(rate[DDIR_WRITE]),
2833 .off3 = td_var_offset(rate[DDIR_TRIM]),
2834 .help = "Set bandwidth rate",
2835 .category = FIO_OPT_C_IO,
2836 .group = FIO_OPT_G_RATE,
2841 .lname = "I/O min rate",
2842 .type = FIO_OPT_INT,
2843 .off1 = td_var_offset(ratemin[DDIR_READ]),
2844 .off2 = td_var_offset(ratemin[DDIR_WRITE]),
2845 .off3 = td_var_offset(ratemin[DDIR_TRIM]),
2846 .help = "Job must meet this rate or it will be shutdown",
2849 .category = FIO_OPT_C_IO,
2850 .group = FIO_OPT_G_RATE,
2853 .name = "rate_iops",
2854 .lname = "I/O rate IOPS",
2855 .type = FIO_OPT_INT,
2856 .off1 = td_var_offset(rate_iops[DDIR_READ]),
2857 .off2 = td_var_offset(rate_iops[DDIR_WRITE]),
2858 .off3 = td_var_offset(rate_iops[DDIR_TRIM]),
2859 .help = "Limit IO used to this number of IO operations/sec",
2861 .category = FIO_OPT_C_IO,
2862 .group = FIO_OPT_G_RATE,
2865 .name = "rate_iops_min",
2866 .lname = "I/O min rate IOPS",
2867 .type = FIO_OPT_INT,
2868 .off1 = td_var_offset(rate_iops_min[DDIR_READ]),
2869 .off2 = td_var_offset(rate_iops_min[DDIR_WRITE]),
2870 .off3 = td_var_offset(rate_iops_min[DDIR_TRIM]),
2871 .help = "Job must meet this rate or it will be shut down",
2872 .parent = "rate_iops",
2874 .category = FIO_OPT_C_IO,
2875 .group = FIO_OPT_G_RATE,
2878 .name = "rate_process",
2879 .lname = "Rate Process",
2880 .type = FIO_OPT_STR,
2881 .off1 = td_var_offset(rate_process),
2882 .help = "What process controls how rated IO is managed",
2884 .category = FIO_OPT_C_IO,
2885 .group = FIO_OPT_G_RATE,
2888 .oval = RATE_PROCESS_LINEAR,
2889 .help = "Linear rate of IO",
2893 .oval = RATE_PROCESS_POISSON,
2894 .help = "Rate follows Poisson process",
2900 .name = "rate_cycle",
2901 .alias = "ratecycle",
2902 .lname = "I/O rate cycle",
2903 .type = FIO_OPT_INT,
2904 .off1 = td_var_offset(ratecycle),
2905 .help = "Window average for rate limits (msec)",
2909 .category = FIO_OPT_C_IO,
2910 .group = FIO_OPT_G_RATE,
2913 .name = "max_latency",
2914 .type = FIO_OPT_INT,
2915 .off1 = td_var_offset(max_latency),
2916 .help = "Maximum tolerated IO latency (usec)",
2918 .category = FIO_OPT_C_IO,
2919 .group = FIO_OPT_G_LATPROF,
2922 .name = "latency_target",
2923 .lname = "Latency Target (usec)",
2924 .type = FIO_OPT_STR_VAL_TIME,
2925 .off1 = td_var_offset(latency_target),
2926 .help = "Ramp to max queue depth supporting this latency",
2928 .category = FIO_OPT_C_IO,
2929 .group = FIO_OPT_G_LATPROF,
2932 .name = "latency_window",
2933 .lname = "Latency Window (usec)",
2934 .type = FIO_OPT_STR_VAL_TIME,
2935 .off1 = td_var_offset(latency_window),
2936 .help = "Time to sustain latency_target",
2938 .category = FIO_OPT_C_IO,
2939 .group = FIO_OPT_G_LATPROF,
2942 .name = "latency_percentile",
2943 .lname = "Latency Percentile",
2944 .type = FIO_OPT_FLOAT_LIST,
2945 .off1 = td_var_offset(latency_percentile),
2946 .help = "Percentile of IOs must be below latency_target",
2951 .category = FIO_OPT_C_IO,
2952 .group = FIO_OPT_G_LATPROF,
2955 .name = "invalidate",
2956 .lname = "Cache invalidate",
2957 .type = FIO_OPT_BOOL,
2958 .off1 = td_var_offset(invalidate_cache),
2959 .help = "Invalidate buffer/page cache prior to running job",
2961 .category = FIO_OPT_C_IO,
2962 .group = FIO_OPT_G_IO_TYPE,
2966 .lname = "Synchronous I/O",
2967 .type = FIO_OPT_BOOL,
2968 .off1 = td_var_offset(sync_io),
2969 .help = "Use O_SYNC for buffered writes",
2971 .parent = "buffered",
2973 .category = FIO_OPT_C_IO,
2974 .group = FIO_OPT_G_IO_TYPE,
2977 .name = "create_serialize",
2978 .lname = "Create serialize",
2979 .type = FIO_OPT_BOOL,
2980 .off1 = td_var_offset(create_serialize),
2981 .help = "Serialize creating of job files",
2983 .category = FIO_OPT_C_FILE,
2984 .group = FIO_OPT_G_INVALID,
2987 .name = "create_fsync",
2988 .lname = "Create fsync",
2989 .type = FIO_OPT_BOOL,
2990 .off1 = td_var_offset(create_fsync),
2991 .help = "fsync file after creation",
2993 .category = FIO_OPT_C_FILE,
2994 .group = FIO_OPT_G_INVALID,
2997 .name = "create_on_open",
2998 .lname = "Create on open",
2999 .type = FIO_OPT_BOOL,
3000 .off1 = td_var_offset(create_on_open),
3001 .help = "Create files when they are opened for IO",
3003 .category = FIO_OPT_C_FILE,
3004 .group = FIO_OPT_G_INVALID,
3007 .name = "create_only",
3008 .type = FIO_OPT_BOOL,
3009 .off1 = td_var_offset(create_only),
3010 .help = "Only perform file creation phase",
3011 .category = FIO_OPT_C_FILE,
3015 .name = "allow_file_create",
3016 .lname = "Allow file create",
3017 .type = FIO_OPT_BOOL,
3018 .off1 = td_var_offset(allow_create),
3019 .help = "Permit fio to create files, if they don't exist",
3021 .category = FIO_OPT_C_FILE,
3022 .group = FIO_OPT_G_FILENAME,
3025 .name = "allow_mounted_write",
3026 .lname = "Allow mounted write",
3027 .type = FIO_OPT_BOOL,
3028 .off1 = td_var_offset(allow_mounted_write),
3029 .help = "Allow writes to a mounted partition",
3031 .category = FIO_OPT_C_FILE,
3032 .group = FIO_OPT_G_FILENAME,
3036 .lname = "Pre-read files",
3037 .type = FIO_OPT_BOOL,
3038 .off1 = td_var_offset(pre_read),
3039 .help = "Pre-read files before starting official testing",
3041 .category = FIO_OPT_C_FILE,
3042 .group = FIO_OPT_G_INVALID,
3044 #ifdef FIO_HAVE_CPU_AFFINITY
3047 .lname = "CPU mask",
3048 .type = FIO_OPT_INT,
3049 .cb = str_cpumask_cb,
3050 .off1 = td_var_offset(cpumask),
3051 .help = "CPU affinity mask",
3052 .category = FIO_OPT_C_GENERAL,
3053 .group = FIO_OPT_G_CRED,
3056 .name = "cpus_allowed",
3057 .lname = "CPUs allowed",
3058 .type = FIO_OPT_STR,
3059 .cb = str_cpus_allowed_cb,
3060 .off1 = td_var_offset(cpumask),
3061 .help = "Set CPUs allowed",
3062 .category = FIO_OPT_C_GENERAL,
3063 .group = FIO_OPT_G_CRED,
3066 .name = "cpus_allowed_policy",
3067 .lname = "CPUs allowed distribution policy",
3068 .type = FIO_OPT_STR,
3069 .off1 = td_var_offset(cpus_allowed_policy),
3070 .help = "Distribution policy for cpus_allowed",
3071 .parent = "cpus_allowed",
3075 .oval = FIO_CPUS_SHARED,
3076 .help = "Mask shared between threads",
3079 .oval = FIO_CPUS_SPLIT,
3080 .help = "Mask split between threads",
3083 .category = FIO_OPT_C_GENERAL,
3084 .group = FIO_OPT_G_CRED,
3087 #ifdef CONFIG_LIBNUMA
3089 .name = "numa_cpu_nodes",
3090 .type = FIO_OPT_STR,
3091 .cb = str_numa_cpunodes_cb,
3092 .off1 = td_var_offset(numa_cpunodes),
3093 .help = "NUMA CPU nodes bind",
3094 .category = FIO_OPT_C_GENERAL,
3095 .group = FIO_OPT_G_INVALID,
3098 .name = "numa_mem_policy",
3099 .type = FIO_OPT_STR,
3100 .cb = str_numa_mpol_cb,
3101 .off1 = td_var_offset(numa_memnodes),
3102 .help = "NUMA memory policy setup",
3103 .category = FIO_OPT_C_GENERAL,
3104 .group = FIO_OPT_G_INVALID,
3108 .name = "end_fsync",
3109 .lname = "End fsync",
3110 .type = FIO_OPT_BOOL,
3111 .off1 = td_var_offset(end_fsync),
3112 .help = "Include fsync at the end of job",
3114 .category = FIO_OPT_C_FILE,
3115 .group = FIO_OPT_G_INVALID,
3118 .name = "fsync_on_close",
3119 .lname = "Fsync on close",
3120 .type = FIO_OPT_BOOL,
3121 .off1 = td_var_offset(fsync_on_close),
3122 .help = "fsync files on close",
3124 .category = FIO_OPT_C_FILE,
3125 .group = FIO_OPT_G_INVALID,
3129 .lname = "Unlink file",
3130 .type = FIO_OPT_BOOL,
3131 .off1 = td_var_offset(unlink),
3132 .help = "Unlink created files after job has completed",
3134 .category = FIO_OPT_C_FILE,
3135 .group = FIO_OPT_G_INVALID,
3139 .lname = "Exit-all on terminate",
3140 .type = FIO_OPT_STR_SET,
3141 .cb = str_exitall_cb,
3142 .help = "Terminate all jobs when one exits",
3143 .category = FIO_OPT_C_GENERAL,
3144 .group = FIO_OPT_G_PROCESS,
3147 .name = "exitall_on_error",
3148 .lname = "Exit-all on terminate in error",
3149 .type = FIO_OPT_BOOL,
3150 .off1 = td_var_offset(unlink),
3151 .help = "Terminate all jobs when one exits in error",
3152 .category = FIO_OPT_C_GENERAL,
3153 .group = FIO_OPT_G_PROCESS,
3156 .name = "stonewall",
3157 .lname = "Wait for previous",
3158 .alias = "wait_for_previous",
3159 .type = FIO_OPT_STR_SET,
3160 .off1 = td_var_offset(stonewall),
3161 .help = "Insert a hard barrier between this job and previous",
3162 .category = FIO_OPT_C_GENERAL,
3163 .group = FIO_OPT_G_PROCESS,
3166 .name = "new_group",
3167 .lname = "New group",
3168 .type = FIO_OPT_STR_SET,
3169 .off1 = td_var_offset(new_group),
3170 .help = "Mark the start of a new group (for reporting)",
3171 .category = FIO_OPT_C_GENERAL,
3172 .group = FIO_OPT_G_PROCESS,
3177 .type = FIO_OPT_STR_SET,
3178 .off1 = td_var_offset(use_thread),
3179 .help = "Use threads instead of processes",
3180 #ifdef CONFIG_NO_SHM
3184 .category = FIO_OPT_C_GENERAL,
3185 .group = FIO_OPT_G_PROCESS,
3188 .name = "per_job_logs",
3189 .type = FIO_OPT_BOOL,
3190 .off1 = td_var_offset(per_job_logs),
3191 .help = "Include job number in generated log files or not",
3193 .category = FIO_OPT_C_LOG,
3194 .group = FIO_OPT_G_INVALID,
3197 .name = "write_bw_log",
3198 .lname = "Write bandwidth log",
3199 .type = FIO_OPT_STR_STORE,
3200 .off1 = td_var_offset(bw_log_file),
3201 .help = "Write log of bandwidth during run",
3202 .category = FIO_OPT_C_LOG,
3203 .group = FIO_OPT_G_INVALID,
3206 .name = "write_lat_log",
3207 .lname = "Write latency log",
3208 .type = FIO_OPT_STR_STORE,
3209 .off1 = td_var_offset(lat_log_file),
3210 .help = "Write log of latency during run",
3211 .category = FIO_OPT_C_LOG,
3212 .group = FIO_OPT_G_INVALID,
3215 .name = "write_iops_log",
3216 .lname = "Write IOPS log",
3217 .type = FIO_OPT_STR_STORE,
3218 .off1 = td_var_offset(iops_log_file),
3219 .help = "Write log of IOPS during run",
3220 .category = FIO_OPT_C_LOG,
3221 .group = FIO_OPT_G_INVALID,
3224 .name = "log_avg_msec",
3225 .lname = "Log averaging (msec)",
3226 .type = FIO_OPT_INT,
3227 .off1 = td_var_offset(log_avg_msec),
3228 .help = "Average bw/iops/lat logs over this period of time",
3230 .category = FIO_OPT_C_LOG,
3231 .group = FIO_OPT_G_INVALID,
3234 .name = "log_offset",
3235 .lname = "Log offset of IO",
3236 .type = FIO_OPT_BOOL,
3237 .off1 = td_var_offset(log_offset),
3238 .help = "Include offset of IO for each log entry",
3240 .category = FIO_OPT_C_LOG,
3241 .group = FIO_OPT_G_INVALID,
3245 .name = "log_compression",
3246 .lname = "Log compression",
3247 .type = FIO_OPT_INT,
3248 .off1 = td_var_offset(log_gz),
3249 .help = "Log in compressed chunks of this size",
3251 .maxval = 512 * 1024 * 1024ULL,
3252 .category = FIO_OPT_C_LOG,
3253 .group = FIO_OPT_G_INVALID,
3255 #ifdef FIO_HAVE_CPU_AFFINITY
3257 .name = "log_compression_cpus",
3258 .lname = "Log Compression CPUs",
3259 .type = FIO_OPT_STR,
3260 .cb = str_log_cpus_allowed_cb,
3261 .off1 = td_var_offset(log_gz_cpumask),
3262 .parent = "log_compression",
3263 .help = "Limit log compression to these CPUs",
3264 .category = FIO_OPT_C_LOG,
3265 .group = FIO_OPT_G_INVALID,
3269 .name = "log_store_compressed",
3270 .lname = "Log store compressed",
3271 .type = FIO_OPT_BOOL,
3272 .off1 = td_var_offset(log_gz_store),
3273 .help = "Store logs in a compressed format",
3274 .category = FIO_OPT_C_LOG,
3275 .group = FIO_OPT_G_INVALID,
3279 .name = "block_error_percentiles",
3280 .lname = "Block error percentiles",
3281 .type = FIO_OPT_BOOL,
3282 .off1 = td_var_offset(block_error_hist),
3283 .help = "Record trim block errors and make a histogram",
3285 .category = FIO_OPT_C_LOG,
3286 .group = FIO_OPT_G_INVALID,
3289 .name = "bwavgtime",
3290 .lname = "Bandwidth average time",
3291 .type = FIO_OPT_INT,
3292 .off1 = td_var_offset(bw_avg_time),
3293 .help = "Time window over which to calculate bandwidth"
3296 .parent = "write_bw_log",
3299 .category = FIO_OPT_C_LOG,
3300 .group = FIO_OPT_G_INVALID,
3303 .name = "iopsavgtime",
3304 .lname = "IOPS average time",
3305 .type = FIO_OPT_INT,
3306 .off1 = td_var_offset(iops_avg_time),
3307 .help = "Time window over which to calculate IOPS (msec)",
3309 .parent = "write_iops_log",
3312 .category = FIO_OPT_C_LOG,
3313 .group = FIO_OPT_G_INVALID,
3316 .name = "group_reporting",
3317 .lname = "Group reporting",
3318 .type = FIO_OPT_STR_SET,
3319 .off1 = td_var_offset(group_reporting),
3320 .help = "Do reporting on a per-group basis",
3321 .category = FIO_OPT_C_STAT,
3322 .group = FIO_OPT_G_INVALID,
3325 .name = "zero_buffers",
3326 .lname = "Zero I/O buffers",
3327 .type = FIO_OPT_STR_SET,
3328 .off1 = td_var_offset(zero_buffers),
3329 .help = "Init IO buffers to all zeroes",
3330 .category = FIO_OPT_C_IO,
3331 .group = FIO_OPT_G_IO_BUF,
3334 .name = "refill_buffers",
3335 .lname = "Refill I/O buffers",
3336 .type = FIO_OPT_STR_SET,
3337 .off1 = td_var_offset(refill_buffers),
3338 .help = "Refill IO buffers on every IO submit",
3339 .category = FIO_OPT_C_IO,
3340 .group = FIO_OPT_G_IO_BUF,
3343 .name = "scramble_buffers",
3344 .lname = "Scramble I/O buffers",
3345 .type = FIO_OPT_BOOL,
3346 .off1 = td_var_offset(scramble_buffers),
3347 .help = "Slightly scramble buffers on every IO submit",
3349 .category = FIO_OPT_C_IO,
3350 .group = FIO_OPT_G_IO_BUF,
3353 .name = "buffer_pattern",
3354 .lname = "Buffer pattern",
3355 .type = FIO_OPT_STR,
3356 .cb = str_buffer_pattern_cb,
3357 .off1 = td_var_offset(buffer_pattern),
3358 .help = "Fill pattern for IO buffers",
3359 .category = FIO_OPT_C_IO,
3360 .group = FIO_OPT_G_IO_BUF,
3363 .name = "buffer_compress_percentage",
3364 .lname = "Buffer compression percentage",
3365 .type = FIO_OPT_INT,
3366 .cb = str_buffer_compress_cb,
3367 .off1 = td_var_offset(compress_percentage),
3370 .help = "How compressible the buffer is (approximately)",
3372 .category = FIO_OPT_C_IO,
3373 .group = FIO_OPT_G_IO_BUF,
3376 .name = "buffer_compress_chunk",
3377 .lname = "Buffer compression chunk size",
3378 .type = FIO_OPT_INT,
3379 .off1 = td_var_offset(compress_chunk),
3380 .parent = "buffer_compress_percentage",
3382 .help = "Size of compressible region in buffer",
3384 .category = FIO_OPT_C_IO,
3385 .group = FIO_OPT_G_IO_BUF,
3388 .name = "dedupe_percentage",
3389 .lname = "Dedupe percentage",
3390 .type = FIO_OPT_INT,
3391 .cb = str_dedupe_cb,
3392 .off1 = td_var_offset(dedupe_percentage),
3395 .help = "Percentage of buffers that are dedupable",
3397 .category = FIO_OPT_C_IO,
3398 .group = FIO_OPT_G_IO_BUF,
3401 .name = "clat_percentiles",
3402 .lname = "Completion latency percentiles",
3403 .type = FIO_OPT_BOOL,
3404 .off1 = td_var_offset(clat_percentiles),
3405 .help = "Enable the reporting of completion latency percentiles",
3407 .category = FIO_OPT_C_STAT,
3408 .group = FIO_OPT_G_INVALID,
3411 .name = "percentile_list",
3412 .lname = "Percentile list",
3413 .type = FIO_OPT_FLOAT_LIST,
3414 .off1 = td_var_offset(percentile_list),
3415 .off2 = td_var_offset(percentile_precision),
3416 .help = "Specify a custom list of percentiles to report for "
3417 "completion latency and block errors",
3418 .def = "1:5:10:20:30:40:50:60:70:80:90:95:99:99.5:99.9:99.95:99.99",
3419 .maxlen = FIO_IO_U_LIST_MAX_LEN,
3422 .category = FIO_OPT_C_STAT,
3423 .group = FIO_OPT_G_INVALID,
3426 #ifdef FIO_HAVE_DISK_UTIL
3428 .name = "disk_util",
3429 .lname = "Disk utilization",
3430 .type = FIO_OPT_BOOL,
3431 .off1 = td_var_offset(do_disk_util),
3432 .help = "Log disk utilization statistics",
3434 .category = FIO_OPT_C_STAT,
3435 .group = FIO_OPT_G_INVALID,
3439 .name = "gtod_reduce",
3440 .lname = "Reduce gettimeofday() calls",
3441 .type = FIO_OPT_BOOL,
3442 .help = "Greatly reduce number of gettimeofday() calls",
3443 .cb = str_gtod_reduce_cb,
3446 .category = FIO_OPT_C_STAT,
3447 .group = FIO_OPT_G_INVALID,
3450 .name = "disable_lat",
3451 .lname = "Disable all latency stats",
3452 .type = FIO_OPT_BOOL,
3453 .off1 = td_var_offset(disable_lat),
3454 .help = "Disable latency numbers",
3455 .parent = "gtod_reduce",
3458 .category = FIO_OPT_C_STAT,
3459 .group = FIO_OPT_G_INVALID,
3462 .name = "disable_clat",
3463 .lname = "Disable completion latency stats",
3464 .type = FIO_OPT_BOOL,
3465 .off1 = td_var_offset(disable_clat),
3466 .help = "Disable completion latency numbers",
3467 .parent = "gtod_reduce",
3470 .category = FIO_OPT_C_STAT,
3471 .group = FIO_OPT_G_INVALID,
3474 .name = "disable_slat",
3475 .lname = "Disable submission latency stats",
3476 .type = FIO_OPT_BOOL,
3477 .off1 = td_var_offset(disable_slat),
3478 .help = "Disable submission latency numbers",
3479 .parent = "gtod_reduce",
3482 .category = FIO_OPT_C_STAT,
3483 .group = FIO_OPT_G_INVALID,
3486 .name = "disable_bw_measurement",
3487 .lname = "Disable bandwidth stats",
3488 .type = FIO_OPT_BOOL,
3489 .off1 = td_var_offset(disable_bw),
3490 .help = "Disable bandwidth logging",
3491 .parent = "gtod_reduce",
3494 .category = FIO_OPT_C_STAT,
3495 .group = FIO_OPT_G_INVALID,
3499 .lname = "Dedicated gettimeofday() CPU",
3500 .type = FIO_OPT_INT,
3501 .off1 = td_var_offset(gtod_cpu),
3502 .help = "Set up dedicated gettimeofday() thread on this CPU",
3503 .verify = gtod_cpu_verify,
3504 .category = FIO_OPT_C_GENERAL,
3505 .group = FIO_OPT_G_CLOCK,
3508 .name = "unified_rw_reporting",
3509 .type = FIO_OPT_BOOL,
3510 .off1 = td_var_offset(unified_rw_rep),
3511 .help = "Unify reporting across data direction",
3513 .category = FIO_OPT_C_GENERAL,
3514 .group = FIO_OPT_G_INVALID,
3517 .name = "continue_on_error",
3518 .lname = "Continue on error",
3519 .type = FIO_OPT_STR,
3520 .off1 = td_var_offset(continue_on_error),
3521 .help = "Continue on non-fatal errors during IO",
3523 .category = FIO_OPT_C_GENERAL,
3524 .group = FIO_OPT_G_ERR,
3527 .oval = ERROR_TYPE_NONE,
3528 .help = "Exit when an error is encountered",
3531 .oval = ERROR_TYPE_READ,
3532 .help = "Continue on read errors only",
3535 .oval = ERROR_TYPE_WRITE,
3536 .help = "Continue on write errors only",
3539 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
3540 .help = "Continue on any IO errors",
3543 .oval = ERROR_TYPE_VERIFY,
3544 .help = "Continue on verify errors only",
3547 .oval = ERROR_TYPE_ANY,
3548 .help = "Continue on all io and verify errors",
3551 .oval = ERROR_TYPE_NONE,
3552 .help = "Alias for 'none'",
3555 .oval = ERROR_TYPE_ANY,
3556 .help = "Alias for 'all'",
3561 .name = "ignore_error",
3562 .type = FIO_OPT_STR,
3563 .cb = str_ignore_error_cb,
3564 .off1 = td_var_offset(ignore_error_nr),
3565 .help = "Set a specific list of errors to ignore",
3567 .category = FIO_OPT_C_GENERAL,
3568 .group = FIO_OPT_G_ERR,
3571 .name = "error_dump",
3572 .type = FIO_OPT_BOOL,
3573 .off1 = td_var_offset(error_dump),
3575 .help = "Dump info on each error",
3576 .category = FIO_OPT_C_GENERAL,
3577 .group = FIO_OPT_G_ERR,
3582 .type = FIO_OPT_STR_STORE,
3583 .off1 = td_var_offset(profile),
3584 .help = "Select a specific builtin performance test",
3585 .category = FIO_OPT_C_PROFILE,
3586 .group = FIO_OPT_G_INVALID,
3591 .type = FIO_OPT_STR_STORE,
3592 .off1 = td_var_offset(cgroup),
3593 .help = "Add job to cgroup of this name",
3594 .category = FIO_OPT_C_GENERAL,
3595 .group = FIO_OPT_G_CGROUP,
3598 .name = "cgroup_nodelete",
3599 .lname = "Cgroup no-delete",
3600 .type = FIO_OPT_BOOL,
3601 .off1 = td_var_offset(cgroup_nodelete),
3602 .help = "Do not delete cgroups after job completion",
3605 .category = FIO_OPT_C_GENERAL,
3606 .group = FIO_OPT_G_CGROUP,
3609 .name = "cgroup_weight",
3610 .lname = "Cgroup weight",
3611 .type = FIO_OPT_INT,
3612 .off1 = td_var_offset(cgroup_weight),
3613 .help = "Use given weight for cgroup",
3617 .category = FIO_OPT_C_GENERAL,
3618 .group = FIO_OPT_G_CGROUP,
3623 .type = FIO_OPT_INT,
3624 .off1 = td_var_offset(uid),
3625 .help = "Run job with this user ID",
3626 .category = FIO_OPT_C_GENERAL,
3627 .group = FIO_OPT_G_CRED,
3631 .lname = "Group ID",
3632 .type = FIO_OPT_INT,
3633 .off1 = td_var_offset(gid),
3634 .help = "Run job with this group ID",
3635 .category = FIO_OPT_C_GENERAL,
3636 .group = FIO_OPT_G_CRED,
3641 .type = FIO_OPT_INT,
3642 .off1 = td_var_offset(kb_base),
3648 .help = "Use 1024 as the K base",
3652 .help = "Use 1000 as the K base",
3655 .help = "How many bytes per KB for reporting (1000 or 1024)",
3656 .category = FIO_OPT_C_GENERAL,
3657 .group = FIO_OPT_G_INVALID,
3660 .name = "unit_base",
3661 .lname = "Base unit for reporting (Bits or Bytes)",
3662 .type = FIO_OPT_INT,
3663 .off1 = td_var_offset(unit_base),
3668 .help = "Auto-detect",
3672 .help = "Normal (byte based)",
3676 .help = "Bit based",
3679 .help = "Bit multiple of result summary data (8 for byte, 1 for bit)",
3680 .category = FIO_OPT_C_GENERAL,
3681 .group = FIO_OPT_G_INVALID,
3684 .name = "hugepage-size",
3685 .lname = "Hugepage size",
3686 .type = FIO_OPT_INT,
3687 .off1 = td_var_offset(hugepage_size),
3688 .help = "When using hugepages, specify size of each page",
3689 .def = __fio_stringify(FIO_HUGE_PAGE),
3690 .interval = 1024 * 1024,
3691 .category = FIO_OPT_C_GENERAL,
3692 .group = FIO_OPT_G_INVALID,
3696 .lname = "I/O flow ID",
3697 .type = FIO_OPT_INT,
3698 .off1 = td_var_offset(flow_id),
3699 .help = "The flow index ID to use",
3701 .category = FIO_OPT_C_IO,
3702 .group = FIO_OPT_G_IO_FLOW,
3706 .lname = "I/O flow weight",
3707 .type = FIO_OPT_INT,
3708 .off1 = td_var_offset(flow),
3709 .help = "Weight for flow control of this job",
3710 .parent = "flow_id",
3713 .category = FIO_OPT_C_IO,
3714 .group = FIO_OPT_G_IO_FLOW,
3717 .name = "flow_watermark",
3718 .lname = "I/O flow watermark",
3719 .type = FIO_OPT_INT,
3720 .off1 = td_var_offset(flow_watermark),
3721 .help = "High watermark for flow control. This option"
3722 " should be set to the same value for all threads"
3723 " with non-zero flow.",
3724 .parent = "flow_id",
3727 .category = FIO_OPT_C_IO,
3728 .group = FIO_OPT_G_IO_FLOW,
3731 .name = "flow_sleep",
3732 .lname = "I/O flow sleep",
3733 .type = FIO_OPT_INT,
3734 .off1 = td_var_offset(flow_sleep),
3735 .help = "How many microseconds to sleep after being held"
3736 " back by the flow control mechanism",
3737 .parent = "flow_id",
3740 .category = FIO_OPT_C_IO,
3741 .group = FIO_OPT_G_IO_FLOW,
3745 .lname = "Skip operations against bad blocks",
3746 .type = FIO_OPT_BOOL,
3747 .off1 = td_var_offset(skip_bad),
3748 .help = "Skip operations against known bad blocks.",
3751 .category = FIO_OPT_C_IO,
3752 .group = FIO_OPT_G_MTD,
3759 static void add_to_lopt(struct option *lopt, struct fio_option *o,
3760 const char *name, int val)
3762 lopt->name = (char *) name;
3764 if (o->type == FIO_OPT_STR_SET)
3765 lopt->has_arg = optional_argument;
3767 lopt->has_arg = required_argument;
3770 static void options_to_lopts(struct fio_option *opts,
3771 struct option *long_options,
3772 int i, int option_type)
3774 struct fio_option *o = &opts[0];
3776 add_to_lopt(&long_options[i], o, o->name, option_type);
3779 add_to_lopt(&long_options[i], o, o->alias, option_type);
3784 assert(i < FIO_NR_OPTIONS);
3788 void fio_options_set_ioengine_opts(struct option *long_options,
3789 struct thread_data *td)
3794 while (long_options[i].name) {
3795 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
3796 memset(&long_options[i], 0, sizeof(*long_options));
3803 * Just clear out the prior ioengine options.
3808 options_to_lopts(td->io_ops->options, long_options, i,
3809 FIO_GETOPT_IOENGINE);
3812 void fio_options_dup_and_init(struct option *long_options)
3816 options_init(fio_options);
3819 while (long_options[i].name)
3822 options_to_lopts(fio_options, long_options, i, FIO_GETOPT_JOB);
3825 struct fio_keyword {
3831 static struct fio_keyword fio_keywords[] = {
3833 .word = "$pagesize",
3834 .desc = "Page size in the system",
3837 .word = "$mb_memory",
3838 .desc = "Megabytes of memory online",
3842 .desc = "Number of CPUs online in the system",
3849 void fio_keywords_exit(void)
3851 struct fio_keyword *kw;
3853 kw = &fio_keywords[0];
3861 void fio_keywords_init(void)
3863 unsigned long long mb_memory;
3867 sprintf(buf, "%lu", (unsigned long) page_size);
3868 fio_keywords[0].replace = strdup(buf);
3870 mb_memory = os_phys_mem() / (1024 * 1024);
3871 sprintf(buf, "%llu", mb_memory);
3872 fio_keywords[1].replace = strdup(buf);
3875 sprintf(buf, "%lu", l);
3876 fio_keywords[2].replace = strdup(buf);
3881 static char *bc_calc(char *str)
3883 char buf[128], *tmp;
3888 * No math, just return string
3890 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
3891 !strchr(str, '/')) || strchr(str, '\''))
3895 * Split option from value, we only need to calculate the value
3897 tmp = strchr(str, '=');
3904 * Prevent buffer overflows; such a case isn't reasonable anyway
3906 if (strlen(str) >= 128 || strlen(tmp) > 100)
3909 sprintf(buf, "which %s > /dev/null", BC_APP);
3911 log_err("fio: bc is needed for performing math\n");
3915 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
3916 f = popen(buf, "r");
3920 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
3927 buf[(tmp - str) + ret - 1] = '\0';
3928 memcpy(buf, str, tmp - str);
3934 * Return a copy of the input string with substrings of the form ${VARNAME}
3935 * substituted with the value of the environment variable VARNAME. The
3936 * substitution always occurs, even if VARNAME is empty or the corresponding
3937 * environment variable undefined.
3939 static char *option_dup_subs(const char *opt)
3941 char out[OPT_LEN_MAX+1];
3942 char in[OPT_LEN_MAX+1];
3945 char *ch1, *ch2, *env;
3946 ssize_t nchr = OPT_LEN_MAX;
3949 if (strlen(opt) + 1 > OPT_LEN_MAX) {
3950 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
3954 in[OPT_LEN_MAX] = '\0';
3955 strncpy(in, opt, OPT_LEN_MAX);
3957 while (*inptr && nchr > 0) {
3958 if (inptr[0] == '$' && inptr[1] == '{') {
3959 ch2 = strchr(inptr, '}');
3960 if (ch2 && inptr+1 < ch2) {
3967 envlen = strlen(env);
3968 if (envlen <= nchr) {
3969 memcpy(outptr, env, envlen);
3979 *outptr++ = *inptr++;
3988 * Look for reserved variable names and replace them with real values
3990 static char *fio_keyword_replace(char *opt)
3996 for (i = 0; fio_keywords[i].word != NULL; i++) {
3997 struct fio_keyword *kw = &fio_keywords[i];
3999 while ((s = strstr(opt, kw->word)) != NULL) {
4000 char *new = malloc(strlen(opt) + 1);
4006 * Copy part of the string before the keyword and
4007 * sprintf() the replacement after it.
4009 memcpy(new, opt, olen);
4010 len = sprintf(new + olen, "%s", kw->replace);
4013 * If there's more in the original string, copy that
4016 opt += strlen(kw->word) + olen;
4018 memcpy(new + olen + len, opt, opt - o_org - 1);
4021 * replace opt and free the old opt
4031 * Check for potential math and invoke bc, if possible
4039 static char **dup_and_sub_options(char **opts, int num_opts)
4042 char **opts_copy = malloc(num_opts * sizeof(*opts));
4043 for (i = 0; i < num_opts; i++) {
4044 opts_copy[i] = option_dup_subs(opts[i]);
4047 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
4052 static void show_closest_option(const char *opt)
4054 int best_option, best_distance;
4063 while (name[i] != '\0' && name[i] != '=')
4068 best_distance = INT_MAX;
4070 while (fio_options[i].name) {
4071 distance = string_distance(name, fio_options[i].name);
4072 if (distance < best_distance) {
4073 best_distance = distance;
4079 if (best_option != -1 && string_distance_ok(name, best_distance))
4080 log_err("Did you mean %s?\n", fio_options[best_option].name);
4085 int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
4087 int i, ret, unknown;
4090 sort_options(opts, fio_options, num_opts);
4091 opts_copy = dup_and_sub_options(opts, num_opts);
4093 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
4094 struct fio_option *o;
4095 int newret = parse_option(opts_copy[i], opts[i], fio_options,
4096 &o, td, &td->opt_list);
4099 fio_option_mark_set(&td->o, o);
4107 opts_copy[i] = NULL;
4114 ret |= ioengine_load(td);
4116 sort_options(opts_copy, td->io_ops->options, num_opts);
4119 for (i = 0; i < num_opts; i++) {
4120 struct fio_option *o = NULL;
4127 newret = parse_option(opts_copy[i], opts[i],
4128 td->io_ops->options, &o,
4129 td->eo, &td->opt_list);
4133 log_err("Bad option <%s>\n", opts[i]);
4134 show_closest_option(opts[i]);
4137 opts_copy[i] = NULL;
4145 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
4149 ret = parse_cmd_option(opt, val, fio_options, td, &td->opt_list);
4151 struct fio_option *o;
4153 o = find_option(fio_options, opt);
4155 fio_option_mark_set(&td->o, o);
4161 int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
4164 return parse_cmd_option(opt, val, td->io_ops->options, td->eo,
4168 void fio_fill_default_options(struct thread_data *td)
4170 td->o.magic = OPT_MAGIC;
4171 fill_default_options(td, fio_options);
4174 int fio_show_option_help(const char *opt)
4176 return show_cmd_help(fio_options, opt);
4179 void options_mem_dupe(void *data, struct fio_option *options)
4181 struct fio_option *o;
4184 for (o = &options[0]; o->name; o++) {
4185 if (o->type != FIO_OPT_STR_STORE)
4188 ptr = td_var(data, o, o->off1);
4190 *ptr = strdup(*ptr);
4195 * dupe FIO_OPT_STR_STORE options
4197 void fio_options_mem_dupe(struct thread_data *td)
4199 options_mem_dupe(&td->o, fio_options);
4201 if (td->eo && td->io_ops) {
4202 void *oldeo = td->eo;
4204 td->eo = malloc(td->io_ops->option_struct_size);
4205 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
4206 options_mem_dupe(td->eo, td->io_ops->options);
4210 unsigned int fio_get_kb_base(void *data)
4212 struct thread_options *o = data;
4213 unsigned int kb_base = 0;
4216 * This is a hack... For private options, *data is not holding
4217 * a pointer to the thread_options, but to private data. This means
4218 * we can't safely dereference it, but magic is first so mem wise
4219 * it is valid. But this also means that if the job first sets
4220 * kb_base and expects that to be honored by private options,
4221 * it will be disappointed. We will return the global default
4224 if (o && o->magic == OPT_MAGIC)
4225 kb_base = o->kb_base;
4232 int add_option(struct fio_option *o)
4234 struct fio_option *__o;
4243 if (opt_index + 1 == FIO_MAX_OPTS) {
4244 log_err("fio: FIO_MAX_OPTS is too small\n");
4248 memcpy(&fio_options[opt_index], o, sizeof(*o));
4249 fio_options[opt_index + 1].name = NULL;
4253 void invalidate_profile_options(const char *prof_name)
4255 struct fio_option *o;
4259 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
4260 o->type = FIO_OPT_INVALID;
4261 o->prof_name = NULL;
4267 void add_opt_posval(const char *optname, const char *ival, const char *help)
4269 struct fio_option *o;
4272 o = find_option(fio_options, optname);
4276 for (i = 0; i < PARSE_MAX_VP; i++) {
4277 if (o->posval[i].ival)
4280 o->posval[i].ival = ival;
4281 o->posval[i].help = help;
4286 void del_opt_posval(const char *optname, const char *ival)
4288 struct fio_option *o;
4291 o = find_option(fio_options, optname);
4295 for (i = 0; i < PARSE_MAX_VP; i++) {
4296 if (!o->posval[i].ival)
4298 if (strcmp(o->posval[i].ival, ival))
4301 o->posval[i].ival = NULL;
4302 o->posval[i].help = NULL;
4306 void fio_options_free(struct thread_data *td)
4308 options_free(fio_options, td);
4309 if (td->eo && td->io_ops && td->io_ops->options) {
4310 options_free(td->io_ops->options, td->eo);
4316 struct fio_option *fio_option_find(const char *name)
4318 return find_option(fio_options, name);
4321 static struct fio_option *find_next_opt(struct thread_options *o,
4322 struct fio_option *from,
4325 struct fio_option *opt;
4328 from = &fio_options[0];
4334 if (off1 == from->off1) {
4339 } while (from->name);
4344 static int opt_is_set(struct thread_options *o, struct fio_option *opt)
4346 unsigned int opt_off, index, offset;
4348 opt_off = opt - &fio_options[0];
4349 index = opt_off / (8 * sizeof(uint64_t));
4350 offset = opt_off & ((8 * sizeof(uint64_t)) - 1);
4351 return (o->set_options[index] & ((uint64_t)1 << offset)) != 0;
4354 bool __fio_option_is_set(struct thread_options *o, unsigned int off1)
4356 struct fio_option *opt, *next;
4359 while ((opt = find_next_opt(o, next, off1)) != NULL) {
4360 if (opt_is_set(o, opt))
4369 void fio_option_mark_set(struct thread_options *o, struct fio_option *opt)
4371 unsigned int opt_off, index, offset;
4373 opt_off = opt - &fio_options[0];
4374 index = opt_off / (8 * sizeof(uint64_t));
4375 offset = opt_off & ((8 * sizeof(uint64_t)) - 1);
4376 o->set_options[index] |= (uint64_t)1 << offset;