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, unsigned int *mask,
1079 unsigned int inv_mask)
1081 struct opt_group *og;
1084 if (*mask == inv_mask || !*mask)
1087 for (i = 0; ogs[i].name; i++) {
1090 if (*mask & og->mask) {
1091 *mask &= ~(og->mask);
1099 struct opt_group *opt_group_from_mask(unsigned int *mask)
1101 return __opt_group_from_mask(fio_opt_groups, mask, FIO_OPT_C_INVALID);
1104 static struct opt_group fio_opt_cat_groups[] = {
1106 .name = "Latency profiling",
1107 .mask = FIO_OPT_G_LATPROF,
1111 .mask = FIO_OPT_G_RATE,
1115 .mask = FIO_OPT_G_ZONE,
1118 .name = "Read/write mix",
1119 .mask = FIO_OPT_G_RWMIX,
1123 .mask = FIO_OPT_G_VERIFY,
1127 .mask = FIO_OPT_G_TRIM,
1130 .name = "I/O Logging",
1131 .mask = FIO_OPT_G_IOLOG,
1134 .name = "I/O Depth",
1135 .mask = FIO_OPT_G_IO_DEPTH,
1139 .mask = FIO_OPT_G_IO_FLOW,
1142 .name = "Description",
1143 .mask = FIO_OPT_G_DESC,
1147 .mask = FIO_OPT_G_FILENAME,
1150 .name = "General I/O",
1151 .mask = FIO_OPT_G_IO_BASIC,
1155 .mask = FIO_OPT_G_CGROUP,
1159 .mask = FIO_OPT_G_RUNTIME,
1163 .mask = FIO_OPT_G_PROCESS,
1166 .name = "Job credentials / priority",
1167 .mask = FIO_OPT_G_CRED,
1170 .name = "Clock settings",
1171 .mask = FIO_OPT_G_CLOCK,
1175 .mask = FIO_OPT_G_IO_TYPE,
1178 .name = "I/O Thinktime",
1179 .mask = FIO_OPT_G_THINKTIME,
1182 .name = "Randomizations",
1183 .mask = FIO_OPT_G_RANDOM,
1186 .name = "I/O buffers",
1187 .mask = FIO_OPT_G_IO_BUF,
1190 .name = "Tiobench profile",
1191 .mask = FIO_OPT_G_TIOBENCH,
1195 .mask = FIO_OPT_G_MTD,
1203 struct opt_group *opt_group_cat_from_mask(unsigned int *mask)
1205 return __opt_group_from_mask(fio_opt_cat_groups, mask, FIO_OPT_G_INVALID);
1209 * Map of job/command line options
1211 struct fio_option fio_options[FIO_MAX_OPTS] = {
1213 .name = "description",
1214 .lname = "Description of job",
1215 .type = FIO_OPT_STR_STORE,
1216 .off1 = td_var_offset(description),
1217 .help = "Text job description",
1218 .category = FIO_OPT_C_GENERAL,
1219 .group = FIO_OPT_G_DESC,
1223 .lname = "Job name",
1224 .type = FIO_OPT_STR_STORE,
1225 .off1 = td_var_offset(name),
1226 .help = "Name of this job",
1227 .category = FIO_OPT_C_GENERAL,
1228 .group = FIO_OPT_G_DESC,
1232 .lname = "Filename(s)",
1233 .type = FIO_OPT_STR_STORE,
1234 .off1 = td_var_offset(filename),
1235 .cb = str_filename_cb,
1236 .prio = -1, /* must come after "directory" */
1237 .help = "File(s) to use for the workload",
1238 .category = FIO_OPT_C_FILE,
1239 .group = FIO_OPT_G_FILENAME,
1242 .name = "directory",
1243 .lname = "Directory",
1244 .type = FIO_OPT_STR_STORE,
1245 .off1 = td_var_offset(directory),
1246 .cb = str_directory_cb,
1247 .help = "Directory to store files in",
1248 .category = FIO_OPT_C_FILE,
1249 .group = FIO_OPT_G_FILENAME,
1252 .name = "filename_format",
1253 .type = FIO_OPT_STR_STORE,
1254 .off1 = td_var_offset(filename_format),
1255 .prio = -1, /* must come after "directory" */
1256 .help = "Override default $jobname.$jobnum.$filenum naming",
1257 .def = "$jobname.$jobnum.$filenum",
1258 .category = FIO_OPT_C_FILE,
1259 .group = FIO_OPT_G_FILENAME,
1263 .lname = "Lockfile",
1264 .type = FIO_OPT_STR,
1265 .off1 = td_var_offset(file_lock_mode),
1266 .help = "Lock file when doing IO to it",
1268 .parent = "filename",
1271 .category = FIO_OPT_C_FILE,
1272 .group = FIO_OPT_G_FILENAME,
1275 .oval = FILE_LOCK_NONE,
1276 .help = "No file locking",
1278 { .ival = "exclusive",
1279 .oval = FILE_LOCK_EXCLUSIVE,
1280 .help = "Exclusive file lock",
1283 .ival = "readwrite",
1284 .oval = FILE_LOCK_READWRITE,
1285 .help = "Read vs write lock",
1291 .lname = "Open directory",
1292 .type = FIO_OPT_STR_STORE,
1293 .off1 = td_var_offset(opendir),
1294 .cb = str_opendir_cb,
1295 .help = "Recursively add files from this directory and down",
1296 .category = FIO_OPT_C_FILE,
1297 .group = FIO_OPT_G_FILENAME,
1301 .lname = "Read/write",
1302 .alias = "readwrite",
1303 .type = FIO_OPT_STR,
1305 .off1 = td_var_offset(td_ddir),
1306 .help = "IO direction",
1308 .verify = rw_verify,
1309 .category = FIO_OPT_C_IO,
1310 .group = FIO_OPT_G_IO_BASIC,
1313 .oval = TD_DDIR_READ,
1314 .help = "Sequential read",
1317 .oval = TD_DDIR_WRITE,
1318 .help = "Sequential write",
1321 .oval = TD_DDIR_TRIM,
1322 .help = "Sequential trim",
1324 { .ival = "randread",
1325 .oval = TD_DDIR_RANDREAD,
1326 .help = "Random read",
1328 { .ival = "randwrite",
1329 .oval = TD_DDIR_RANDWRITE,
1330 .help = "Random write",
1332 { .ival = "randtrim",
1333 .oval = TD_DDIR_RANDTRIM,
1334 .help = "Random trim",
1338 .help = "Sequential read and write mix",
1340 { .ival = "readwrite",
1342 .help = "Sequential read and write mix",
1345 .oval = TD_DDIR_RANDRW,
1346 .help = "Random read and write mix"
1348 { .ival = "trimwrite",
1349 .oval = TD_DDIR_TRIMWRITE,
1350 .help = "Trim and write mix, trims preceding writes"
1355 .name = "rw_sequencer",
1356 .lname = "RW Sequencer",
1357 .type = FIO_OPT_STR,
1358 .off1 = td_var_offset(rw_seq),
1359 .help = "IO offset generator modifier",
1360 .def = "sequential",
1361 .category = FIO_OPT_C_IO,
1362 .group = FIO_OPT_G_IO_BASIC,
1364 { .ival = "sequential",
1366 .help = "Generate sequential offsets",
1368 { .ival = "identical",
1369 .oval = RW_SEQ_IDENT,
1370 .help = "Generate identical offsets",
1377 .lname = "IO Engine",
1378 .type = FIO_OPT_STR_STORE,
1379 .off1 = td_var_offset(ioengine),
1380 .help = "IO engine to use",
1381 .def = FIO_PREFERRED_ENGINE,
1382 .category = FIO_OPT_C_IO,
1383 .group = FIO_OPT_G_IO_BASIC,
1386 .help = "Use read/write",
1389 .help = "Use pread/pwrite",
1392 .help = "Use readv/writev",
1394 #ifdef CONFIG_PWRITEV
1396 .help = "Use preadv/pwritev",
1399 #ifdef CONFIG_LIBAIO
1401 .help = "Linux native asynchronous IO",
1404 #ifdef CONFIG_POSIXAIO
1405 { .ival = "posixaio",
1406 .help = "POSIX asynchronous IO",
1409 #ifdef CONFIG_SOLARISAIO
1410 { .ival = "solarisaio",
1411 .help = "Solaris native asynchronous IO",
1414 #ifdef CONFIG_WINDOWSAIO
1415 { .ival = "windowsaio",
1416 .help = "Windows native asynchronous IO"
1421 .help = "Rados Block Device asynchronous IO"
1425 .help = "Memory mapped IO"
1427 #ifdef CONFIG_LINUX_SPLICE
1429 .help = "splice/vmsplice based IO",
1431 { .ival = "netsplice",
1432 .help = "splice/vmsplice to/from the network",
1435 #ifdef FIO_HAVE_SGIO
1437 .help = "SCSI generic v3 IO",
1441 .help = "Testing engine (no data transfer)",
1444 .help = "Network IO",
1447 .help = "CPU cycle burner engine",
1451 .help = "GUASI IO engine",
1454 #ifdef FIO_HAVE_BINJECT
1455 { .ival = "binject",
1456 .help = "binject direct inject block engine",
1461 .help = "RDMA IO engine",
1464 #ifdef CONFIG_FUSION_AW
1465 { .ival = "fusion-aw-sync",
1466 .help = "Fusion-io atomic write engine",
1469 #ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
1470 { .ival = "e4defrag",
1471 .help = "ext4 defrag engine",
1474 #ifdef CONFIG_LINUX_FALLOCATE
1476 .help = "fallocate() file based engine",
1481 .help = "Glusterfs libgfapi(sync) based engine"
1483 { .ival = "gfapi_async",
1484 .help = "Glusterfs libgfapi(async) based engine"
1487 #ifdef CONFIG_LIBHDFS
1488 { .ival = "libhdfs",
1489 .help = "Hadoop Distributed Filesystem (HDFS) engine"
1492 { .ival = "external",
1493 .help = "Load external engine (append name)",
1499 .lname = "IO Depth",
1500 .type = FIO_OPT_INT,
1501 .off1 = td_var_offset(iodepth),
1502 .help = "Number of IO buffers to keep in flight",
1506 .category = FIO_OPT_C_IO,
1507 .group = FIO_OPT_G_IO_BASIC,
1510 .name = "iodepth_batch",
1511 .lname = "IO Depth batch",
1512 .alias = "iodepth_batch_submit",
1513 .type = FIO_OPT_INT,
1514 .off1 = td_var_offset(iodepth_batch),
1515 .help = "Number of IO buffers to submit in one go",
1516 .parent = "iodepth",
1521 .category = FIO_OPT_C_IO,
1522 .group = FIO_OPT_G_IO_BASIC,
1525 .name = "iodepth_batch_complete_min",
1526 .lname = "Min IO depth batch complete",
1527 .alias = "iodepth_batch_complete",
1528 .type = FIO_OPT_INT,
1529 .off1 = td_var_offset(iodepth_batch_complete_min),
1530 .help = "Min number of IO buffers to retrieve in one go",
1531 .parent = "iodepth",
1536 .category = FIO_OPT_C_IO,
1537 .group = FIO_OPT_G_IO_BASIC,
1540 .name = "iodepth_batch_complete_max",
1541 .lname = "Max IO depth batch complete",
1542 .type = FIO_OPT_INT,
1543 .off1 = td_var_offset(iodepth_batch_complete_max),
1544 .help = "Max number of IO buffers to retrieve in one go",
1545 .parent = "iodepth",
1549 .category = FIO_OPT_C_IO,
1550 .group = FIO_OPT_G_IO_BASIC,
1553 .name = "iodepth_low",
1554 .lname = "IO Depth batch low",
1555 .type = FIO_OPT_INT,
1556 .off1 = td_var_offset(iodepth_low),
1557 .help = "Low water mark for queuing depth",
1558 .parent = "iodepth",
1561 .category = FIO_OPT_C_IO,
1562 .group = FIO_OPT_G_IO_BASIC,
1565 .name = "io_submit_mode",
1566 .lname = "IO submit mode",
1567 .type = FIO_OPT_STR,
1568 .off1 = td_var_offset(io_submit_mode),
1569 .help = "How IO submissions and completions are done",
1571 .category = FIO_OPT_C_IO,
1572 .group = FIO_OPT_G_IO_BASIC,
1575 .oval = IO_MODE_INLINE,
1576 .help = "Submit and complete IO inline",
1578 { .ival = "offload",
1579 .oval = IO_MODE_OFFLOAD,
1580 .help = "Offload submit and complete to threads",
1587 .type = FIO_OPT_STR_VAL,
1589 .off1 = td_var_offset(size),
1590 .help = "Total size of device or files",
1591 .interval = 1024 * 1024,
1592 .category = FIO_OPT_C_IO,
1593 .group = FIO_OPT_G_INVALID,
1597 .alias = "io_limit",
1599 .type = FIO_OPT_STR_VAL,
1600 .off1 = td_var_offset(io_limit),
1601 .interval = 1024 * 1024,
1602 .category = FIO_OPT_C_IO,
1603 .group = FIO_OPT_G_INVALID,
1606 .name = "fill_device",
1607 .lname = "Fill device",
1609 .type = FIO_OPT_BOOL,
1610 .off1 = td_var_offset(fill_device),
1611 .help = "Write until an ENOSPC error occurs",
1613 .category = FIO_OPT_C_FILE,
1614 .group = FIO_OPT_G_INVALID,
1618 .lname = "File size",
1619 .type = FIO_OPT_STR_VAL,
1620 .off1 = td_var_offset(file_size_low),
1621 .off2 = td_var_offset(file_size_high),
1623 .help = "Size of individual files",
1624 .interval = 1024 * 1024,
1625 .category = FIO_OPT_C_FILE,
1626 .group = FIO_OPT_G_INVALID,
1629 .name = "file_append",
1630 .lname = "File append",
1631 .type = FIO_OPT_BOOL,
1632 .off1 = td_var_offset(file_append),
1633 .help = "IO will start at the end of the file(s)",
1635 .category = FIO_OPT_C_FILE,
1636 .group = FIO_OPT_G_INVALID,
1640 .lname = "IO offset",
1641 .alias = "fileoffset",
1642 .type = FIO_OPT_STR_VAL,
1643 .off1 = td_var_offset(start_offset),
1644 .help = "Start IO from this offset",
1646 .interval = 1024 * 1024,
1647 .category = FIO_OPT_C_IO,
1648 .group = FIO_OPT_G_INVALID,
1651 .name = "offset_increment",
1652 .lname = "IO offset increment",
1653 .type = FIO_OPT_STR_VAL,
1654 .off1 = td_var_offset(offset_increment),
1655 .help = "What is the increment from one offset to the next",
1659 .interval = 1024 * 1024,
1660 .category = FIO_OPT_C_IO,
1661 .group = FIO_OPT_G_INVALID,
1664 .name = "number_ios",
1665 .lname = "Number of IOs to perform",
1666 .type = FIO_OPT_STR_VAL,
1667 .off1 = td_var_offset(number_ios),
1668 .help = "Force job completion after this number of IOs",
1670 .category = FIO_OPT_C_IO,
1671 .group = FIO_OPT_G_INVALID,
1675 .lname = "Block size",
1676 .alias = "blocksize",
1677 .type = FIO_OPT_INT,
1678 .off1 = td_var_offset(bs[DDIR_READ]),
1679 .off2 = td_var_offset(bs[DDIR_WRITE]),
1680 .off3 = td_var_offset(bs[DDIR_TRIM]),
1682 .help = "Block size unit",
1687 .category = FIO_OPT_C_IO,
1688 .group = FIO_OPT_G_INVALID,
1692 .lname = "Block size align",
1693 .alias = "blockalign",
1694 .type = FIO_OPT_INT,
1695 .off1 = td_var_offset(ba[DDIR_READ]),
1696 .off2 = td_var_offset(ba[DDIR_WRITE]),
1697 .off3 = td_var_offset(ba[DDIR_TRIM]),
1699 .help = "IO block offset alignment",
1703 .category = FIO_OPT_C_IO,
1704 .group = FIO_OPT_G_INVALID,
1708 .lname = "Block size range",
1709 .alias = "blocksize_range",
1710 .type = FIO_OPT_RANGE,
1711 .off1 = td_var_offset(min_bs[DDIR_READ]),
1712 .off2 = td_var_offset(max_bs[DDIR_READ]),
1713 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
1714 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
1715 .off5 = td_var_offset(min_bs[DDIR_TRIM]),
1716 .off6 = td_var_offset(max_bs[DDIR_TRIM]),
1718 .help = "Set block size range (in more detail than bs)",
1722 .category = FIO_OPT_C_IO,
1723 .group = FIO_OPT_G_INVALID,
1727 .lname = "Block size split",
1728 .type = FIO_OPT_STR,
1729 .cb = str_bssplit_cb,
1730 .off1 = td_var_offset(bssplit),
1731 .help = "Set a specific mix of block sizes",
1734 .category = FIO_OPT_C_IO,
1735 .group = FIO_OPT_G_INVALID,
1738 .name = "bs_unaligned",
1739 .lname = "Block size unaligned",
1740 .alias = "blocksize_unaligned",
1741 .type = FIO_OPT_STR_SET,
1742 .off1 = td_var_offset(bs_unaligned),
1743 .help = "Don't sector align IO buffer sizes",
1746 .category = FIO_OPT_C_IO,
1747 .group = FIO_OPT_G_INVALID,
1750 .name = "bs_is_seq_rand",
1751 .lname = "Block size division is seq/random (not read/write)",
1752 .type = FIO_OPT_BOOL,
1753 .off1 = td_var_offset(bs_is_seq_rand),
1754 .help = "Consider any blocksize setting to be sequential,random",
1756 .parent = "blocksize",
1757 .category = FIO_OPT_C_IO,
1758 .group = FIO_OPT_G_INVALID,
1761 .name = "randrepeat",
1762 .lname = "Random repeatable",
1763 .type = FIO_OPT_BOOL,
1764 .off1 = td_var_offset(rand_repeatable),
1765 .help = "Use repeatable random IO pattern",
1769 .category = FIO_OPT_C_IO,
1770 .group = FIO_OPT_G_RANDOM,
1774 .lname = "The random generator seed",
1775 .type = FIO_OPT_STR_VAL,
1776 .off1 = td_var_offset(rand_seed),
1777 .help = "Set the random generator seed value",
1780 .category = FIO_OPT_C_IO,
1781 .group = FIO_OPT_G_RANDOM,
1784 .name = "use_os_rand",
1785 .lname = "Use OS random",
1786 .type = FIO_OPT_DEPRECATED,
1787 .off1 = td_var_offset(dep_use_os_rand),
1788 .category = FIO_OPT_C_IO,
1789 .group = FIO_OPT_G_RANDOM,
1792 .name = "norandommap",
1793 .lname = "No randommap",
1794 .type = FIO_OPT_STR_SET,
1795 .off1 = td_var_offset(norandommap),
1796 .help = "Accept potential duplicate random blocks",
1800 .category = FIO_OPT_C_IO,
1801 .group = FIO_OPT_G_RANDOM,
1804 .name = "softrandommap",
1805 .lname = "Soft randommap",
1806 .type = FIO_OPT_BOOL,
1807 .off1 = td_var_offset(softrandommap),
1808 .help = "Set norandommap if randommap allocation fails",
1809 .parent = "norandommap",
1812 .category = FIO_OPT_C_IO,
1813 .group = FIO_OPT_G_RANDOM,
1816 .name = "random_generator",
1817 .type = FIO_OPT_STR,
1818 .off1 = td_var_offset(random_generator),
1819 .help = "Type of random number generator to use",
1820 .def = "tausworthe",
1822 { .ival = "tausworthe",
1823 .oval = FIO_RAND_GEN_TAUSWORTHE,
1824 .help = "Strong Tausworthe generator",
1827 .oval = FIO_RAND_GEN_LFSR,
1828 .help = "Variable length LFSR",
1831 .ival = "tausworthe64",
1832 .oval = FIO_RAND_GEN_TAUSWORTHE64,
1833 .help = "64-bit Tausworthe variant",
1836 .category = FIO_OPT_C_IO,
1837 .group = FIO_OPT_G_RANDOM,
1840 .name = "random_distribution",
1841 .type = FIO_OPT_STR,
1842 .off1 = td_var_offset(random_distribution),
1843 .cb = str_random_distribution_cb,
1844 .help = "Random offset distribution generator",
1848 .oval = FIO_RAND_DIST_RANDOM,
1849 .help = "Completely random",
1852 .oval = FIO_RAND_DIST_ZIPF,
1853 .help = "Zipf distribution",
1856 .oval = FIO_RAND_DIST_PARETO,
1857 .help = "Pareto distribution",
1860 .oval = FIO_RAND_DIST_GAUSS,
1861 .help = "Normal (gaussian) distribution",
1864 .category = FIO_OPT_C_IO,
1865 .group = FIO_OPT_G_RANDOM,
1868 .name = "percentage_random",
1869 .lname = "Percentage Random",
1870 .type = FIO_OPT_INT,
1871 .off1 = td_var_offset(perc_rand[DDIR_READ]),
1872 .off2 = td_var_offset(perc_rand[DDIR_WRITE]),
1873 .off3 = td_var_offset(perc_rand[DDIR_TRIM]),
1875 .help = "Percentage of seq/random mix that should be random",
1876 .def = "100,100,100",
1878 .inverse = "percentage_sequential",
1879 .category = FIO_OPT_C_IO,
1880 .group = FIO_OPT_G_RANDOM,
1883 .name = "percentage_sequential",
1884 .lname = "Percentage Sequential",
1885 .type = FIO_OPT_DEPRECATED,
1886 .category = FIO_OPT_C_IO,
1887 .group = FIO_OPT_G_RANDOM,
1890 .name = "allrandrepeat",
1891 .type = FIO_OPT_BOOL,
1892 .off1 = td_var_offset(allrand_repeatable),
1893 .help = "Use repeatable random numbers for everything",
1895 .category = FIO_OPT_C_IO,
1896 .group = FIO_OPT_G_RANDOM,
1900 .lname = "Number of files",
1901 .alias = "nr_files",
1902 .type = FIO_OPT_INT,
1903 .off1 = td_var_offset(nr_files),
1904 .help = "Split job workload between this number of files",
1907 .category = FIO_OPT_C_FILE,
1908 .group = FIO_OPT_G_INVALID,
1911 .name = "openfiles",
1912 .lname = "Number of open files",
1913 .type = FIO_OPT_INT,
1914 .off1 = td_var_offset(open_files),
1915 .help = "Number of files to keep open at the same time",
1916 .category = FIO_OPT_C_FILE,
1917 .group = FIO_OPT_G_INVALID,
1920 .name = "file_service_type",
1921 .lname = "File service type",
1922 .type = FIO_OPT_STR,
1924 .off1 = td_var_offset(file_service_type),
1925 .help = "How to select which file to service next",
1926 .def = "roundrobin",
1927 .category = FIO_OPT_C_FILE,
1928 .group = FIO_OPT_G_INVALID,
1931 .oval = FIO_FSERVICE_RANDOM,
1932 .help = "Choose a file at random",
1934 { .ival = "roundrobin",
1935 .oval = FIO_FSERVICE_RR,
1936 .help = "Round robin select files",
1938 { .ival = "sequential",
1939 .oval = FIO_FSERVICE_SEQ,
1940 .help = "Finish one file before moving to the next",
1943 .parent = "nrfiles",
1946 #ifdef CONFIG_POSIX_FALLOCATE
1948 .name = "fallocate",
1949 .lname = "Fallocate",
1950 .type = FIO_OPT_STR,
1951 .off1 = td_var_offset(fallocate_mode),
1952 .help = "Whether pre-allocation is performed when laying out files",
1954 .category = FIO_OPT_C_FILE,
1955 .group = FIO_OPT_G_INVALID,
1958 .oval = FIO_FALLOCATE_NONE,
1959 .help = "Do not pre-allocate space",
1962 .oval = FIO_FALLOCATE_POSIX,
1963 .help = "Use posix_fallocate()",
1965 #ifdef CONFIG_LINUX_FALLOCATE
1967 .oval = FIO_FALLOCATE_KEEP_SIZE,
1968 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
1971 /* Compatibility with former boolean values */
1973 .oval = FIO_FALLOCATE_NONE,
1974 .help = "Alias for 'none'",
1977 .oval = FIO_FALLOCATE_POSIX,
1978 .help = "Alias for 'posix'",
1982 #endif /* CONFIG_POSIX_FALLOCATE */
1984 .name = "fadvise_hint",
1985 .lname = "Fadvise hint",
1986 .type = FIO_OPT_BOOL,
1987 .off1 = td_var_offset(fadvise_hint),
1988 .help = "Use fadvise() to advise the kernel on IO pattern",
1990 .category = FIO_OPT_C_FILE,
1991 .group = FIO_OPT_G_INVALID,
1993 #ifdef FIO_HAVE_STREAMID
1995 .name = "fadvise_stream",
1996 .lname = "Fadvise stream",
1997 .type = FIO_OPT_INT,
1998 .off1 = td_var_offset(fadvise_stream),
1999 .help = "Use fadvise() to set stream ID",
2000 .category = FIO_OPT_C_FILE,
2001 .group = FIO_OPT_G_INVALID,
2007 .type = FIO_OPT_INT,
2008 .off1 = td_var_offset(fsync_blocks),
2009 .help = "Issue fsync for writes every given number of blocks",
2012 .category = FIO_OPT_C_FILE,
2013 .group = FIO_OPT_G_INVALID,
2016 .name = "fdatasync",
2017 .lname = "Fdatasync",
2018 .type = FIO_OPT_INT,
2019 .off1 = td_var_offset(fdatasync_blocks),
2020 .help = "Issue fdatasync for writes every given number of blocks",
2023 .category = FIO_OPT_C_FILE,
2024 .group = FIO_OPT_G_INVALID,
2027 .name = "write_barrier",
2028 .lname = "Write barrier",
2029 .type = FIO_OPT_INT,
2030 .off1 = td_var_offset(barrier_blocks),
2031 .help = "Make every Nth write a barrier write",
2034 .category = FIO_OPT_C_IO,
2035 .group = FIO_OPT_G_INVALID,
2037 #ifdef CONFIG_SYNC_FILE_RANGE
2039 .name = "sync_file_range",
2040 .lname = "Sync file range",
2042 { .ival = "wait_before",
2043 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
2044 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
2048 .oval = SYNC_FILE_RANGE_WRITE,
2049 .help = "SYNC_FILE_RANGE_WRITE",
2053 .ival = "wait_after",
2054 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
2055 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
2059 .type = FIO_OPT_STR_MULTI,
2061 .off1 = td_var_offset(sync_file_range),
2062 .help = "Use sync_file_range()",
2063 .category = FIO_OPT_C_FILE,
2064 .group = FIO_OPT_G_INVALID,
2069 .lname = "Direct I/O",
2070 .type = FIO_OPT_BOOL,
2071 .off1 = td_var_offset(odirect),
2072 .help = "Use O_DIRECT IO (negates buffered)",
2074 .inverse = "buffered",
2075 .category = FIO_OPT_C_IO,
2076 .group = FIO_OPT_G_IO_TYPE,
2080 .lname = "Atomic I/O",
2081 .type = FIO_OPT_BOOL,
2082 .off1 = td_var_offset(oatomic),
2083 .help = "Use Atomic IO with O_DIRECT (implies O_DIRECT)",
2085 .category = FIO_OPT_C_IO,
2086 .group = FIO_OPT_G_IO_TYPE,
2090 .lname = "Buffered I/O",
2091 .type = FIO_OPT_BOOL,
2092 .off1 = td_var_offset(odirect),
2094 .help = "Use buffered IO (negates direct)",
2096 .inverse = "direct",
2097 .category = FIO_OPT_C_IO,
2098 .group = FIO_OPT_G_IO_TYPE,
2101 .name = "overwrite",
2102 .lname = "Overwrite",
2103 .type = FIO_OPT_BOOL,
2104 .off1 = td_var_offset(overwrite),
2105 .help = "When writing, set whether to overwrite current data",
2107 .category = FIO_OPT_C_FILE,
2108 .group = FIO_OPT_G_INVALID,
2113 .type = FIO_OPT_INT,
2114 .off1 = td_var_offset(loops),
2115 .help = "Number of times to run the job",
2118 .category = FIO_OPT_C_GENERAL,
2119 .group = FIO_OPT_G_RUNTIME,
2123 .lname = "Number of jobs",
2124 .type = FIO_OPT_INT,
2125 .off1 = td_var_offset(numjobs),
2126 .help = "Duplicate this job this many times",
2129 .category = FIO_OPT_C_GENERAL,
2130 .group = FIO_OPT_G_RUNTIME,
2133 .name = "startdelay",
2134 .lname = "Start delay",
2135 .type = FIO_OPT_STR_VAL_TIME,
2136 .off1 = td_var_offset(start_delay),
2137 .off2 = td_var_offset(start_delay_high),
2138 .help = "Only start job when this period has passed",
2142 .category = FIO_OPT_C_GENERAL,
2143 .group = FIO_OPT_G_RUNTIME,
2149 .type = FIO_OPT_STR_VAL_TIME,
2150 .off1 = td_var_offset(timeout),
2151 .help = "Stop workload when this amount of time has passed",
2155 .category = FIO_OPT_C_GENERAL,
2156 .group = FIO_OPT_G_RUNTIME,
2159 .name = "time_based",
2160 .lname = "Time based",
2161 .type = FIO_OPT_STR_SET,
2162 .off1 = td_var_offset(time_based),
2163 .help = "Keep running until runtime/timeout is met",
2164 .category = FIO_OPT_C_GENERAL,
2165 .group = FIO_OPT_G_RUNTIME,
2168 .name = "verify_only",
2169 .lname = "Verify only",
2170 .type = FIO_OPT_STR_SET,
2171 .off1 = td_var_offset(verify_only),
2172 .help = "Verifies previously written data is still valid",
2173 .category = FIO_OPT_C_GENERAL,
2174 .group = FIO_OPT_G_RUNTIME,
2177 .name = "ramp_time",
2178 .lname = "Ramp time",
2179 .type = FIO_OPT_STR_VAL_TIME,
2180 .off1 = td_var_offset(ramp_time),
2181 .help = "Ramp up time before measuring performance",
2184 .category = FIO_OPT_C_GENERAL,
2185 .group = FIO_OPT_G_RUNTIME,
2188 .name = "clocksource",
2189 .lname = "Clock source",
2190 .type = FIO_OPT_STR,
2191 .cb = fio_clock_source_cb,
2192 .off1 = td_var_offset(clocksource),
2193 .help = "What type of timing source to use",
2194 .category = FIO_OPT_C_GENERAL,
2195 .group = FIO_OPT_G_CLOCK,
2197 #ifdef CONFIG_GETTIMEOFDAY
2198 { .ival = "gettimeofday",
2200 .help = "Use gettimeofday(2) for timing",
2203 #ifdef CONFIG_CLOCK_GETTIME
2204 { .ival = "clock_gettime",
2205 .oval = CS_CGETTIME,
2206 .help = "Use clock_gettime(2) for timing",
2209 #ifdef ARCH_HAVE_CPU_CLOCK
2211 .oval = CS_CPUCLOCK,
2212 .help = "Use CPU private clock",
2220 .lname = "I/O Memory",
2221 .type = FIO_OPT_STR,
2223 .off1 = td_var_offset(mem_type),
2224 .help = "Backing type for IO buffers",
2226 .category = FIO_OPT_C_IO,
2227 .group = FIO_OPT_G_INVALID,
2231 .help = "Use malloc(3) for IO buffers",
2233 #ifndef CONFIG_NO_SHM
2236 .help = "Use shared memory segments for IO buffers",
2238 #ifdef FIO_HAVE_HUGETLB
2239 { .ival = "shmhuge",
2240 .oval = MEM_SHMHUGE,
2241 .help = "Like shm, but use huge pages",
2247 .help = "Use mmap(2) (file or anon) for IO buffers",
2249 { .ival = "mmapshared",
2250 .oval = MEM_MMAPSHARED,
2251 .help = "Like mmap, but use the shared flag",
2253 #ifdef FIO_HAVE_HUGETLB
2254 { .ival = "mmaphuge",
2255 .oval = MEM_MMAPHUGE,
2256 .help = "Like mmap, but use huge pages",
2262 .name = "iomem_align",
2263 .alias = "mem_align",
2264 .lname = "I/O memory alignment",
2265 .type = FIO_OPT_INT,
2266 .off1 = td_var_offset(mem_align),
2268 .help = "IO memory buffer offset alignment",
2272 .category = FIO_OPT_C_IO,
2273 .group = FIO_OPT_G_INVALID,
2278 .type = FIO_OPT_STR,
2279 .off1 = td_var_offset(verify),
2280 .help = "Verify data written",
2282 .category = FIO_OPT_C_IO,
2283 .group = FIO_OPT_G_VERIFY,
2286 .oval = VERIFY_NONE,
2287 .help = "Don't do IO verification",
2291 .help = "Use md5 checksums for verification",
2294 .oval = VERIFY_CRC64,
2295 .help = "Use crc64 checksums for verification",
2298 .oval = VERIFY_CRC32,
2299 .help = "Use crc32 checksums for verification",
2301 { .ival = "crc32c-intel",
2302 .oval = VERIFY_CRC32C,
2303 .help = "Use crc32c checksums for verification (hw assisted, if available)",
2306 .oval = VERIFY_CRC32C,
2307 .help = "Use crc32c checksums for verification (hw assisted, if available)",
2310 .oval = VERIFY_CRC16,
2311 .help = "Use crc16 checksums for verification",
2314 .oval = VERIFY_CRC7,
2315 .help = "Use crc7 checksums for verification",
2318 .oval = VERIFY_SHA1,
2319 .help = "Use sha1 checksums for verification",
2322 .oval = VERIFY_SHA256,
2323 .help = "Use sha256 checksums for verification",
2326 .oval = VERIFY_SHA512,
2327 .help = "Use sha512 checksums for verification",
2330 .oval = VERIFY_XXHASH,
2331 .help = "Use xxhash checksums for verification",
2333 /* Meta information was included into verify_header,
2334 * 'meta' verification is implied by default. */
2336 .oval = VERIFY_HDR_ONLY,
2337 .help = "Use io information for verification. "
2338 "Now is implied by default, thus option is obsolete, "
2341 { .ival = "pattern",
2342 .oval = VERIFY_PATTERN_NO_HDR,
2343 .help = "Verify strict pattern",
2347 .oval = VERIFY_NULL,
2348 .help = "Pretend to verify",
2353 .name = "do_verify",
2354 .lname = "Perform verify step",
2355 .type = FIO_OPT_BOOL,
2356 .off1 = td_var_offset(do_verify),
2357 .help = "Run verification stage after write",
2361 .category = FIO_OPT_C_IO,
2362 .group = FIO_OPT_G_VERIFY,
2365 .name = "verifysort",
2366 .lname = "Verify sort",
2367 .type = FIO_OPT_BOOL,
2368 .off1 = td_var_offset(verifysort),
2369 .help = "Sort written verify blocks for read back",
2373 .category = FIO_OPT_C_IO,
2374 .group = FIO_OPT_G_VERIFY,
2377 .name = "verifysort_nr",
2378 .type = FIO_OPT_INT,
2379 .off1 = td_var_offset(verifysort_nr),
2380 .help = "Pre-load and sort verify blocks for a read workload",
2385 .category = FIO_OPT_C_IO,
2386 .group = FIO_OPT_G_VERIFY,
2389 .name = "verify_interval",
2390 .lname = "Verify interval",
2391 .type = FIO_OPT_INT,
2392 .off1 = td_var_offset(verify_interval),
2393 .minval = 2 * sizeof(struct verify_header),
2394 .help = "Store verify buffer header every N bytes",
2397 .interval = 2 * sizeof(struct verify_header),
2398 .category = FIO_OPT_C_IO,
2399 .group = FIO_OPT_G_VERIFY,
2402 .name = "verify_offset",
2403 .lname = "Verify offset",
2404 .type = FIO_OPT_INT,
2405 .help = "Offset verify header location by N bytes",
2406 .off1 = td_var_offset(verify_offset),
2407 .minval = sizeof(struct verify_header),
2410 .category = FIO_OPT_C_IO,
2411 .group = FIO_OPT_G_VERIFY,
2414 .name = "verify_pattern",
2415 .lname = "Verify pattern",
2416 .type = FIO_OPT_STR,
2417 .cb = str_verify_pattern_cb,
2418 .off1 = td_var_offset(verify_pattern),
2419 .help = "Fill pattern for IO buffers",
2422 .category = FIO_OPT_C_IO,
2423 .group = FIO_OPT_G_VERIFY,
2426 .name = "verify_fatal",
2427 .lname = "Verify fatal",
2428 .type = FIO_OPT_BOOL,
2429 .off1 = td_var_offset(verify_fatal),
2431 .help = "Exit on a single verify failure, don't continue",
2434 .category = FIO_OPT_C_IO,
2435 .group = FIO_OPT_G_VERIFY,
2438 .name = "verify_dump",
2439 .lname = "Verify dump",
2440 .type = FIO_OPT_BOOL,
2441 .off1 = td_var_offset(verify_dump),
2443 .help = "Dump contents of good and bad blocks on failure",
2446 .category = FIO_OPT_C_IO,
2447 .group = FIO_OPT_G_VERIFY,
2450 .name = "verify_async",
2451 .lname = "Verify asynchronously",
2452 .type = FIO_OPT_INT,
2453 .off1 = td_var_offset(verify_async),
2455 .help = "Number of async verifier threads to use",
2458 .category = FIO_OPT_C_IO,
2459 .group = FIO_OPT_G_VERIFY,
2462 .name = "verify_backlog",
2463 .lname = "Verify backlog",
2464 .type = FIO_OPT_STR_VAL,
2465 .off1 = td_var_offset(verify_backlog),
2466 .help = "Verify after this number of blocks are written",
2469 .category = FIO_OPT_C_IO,
2470 .group = FIO_OPT_G_VERIFY,
2473 .name = "verify_backlog_batch",
2474 .lname = "Verify backlog batch",
2475 .type = FIO_OPT_INT,
2476 .off1 = td_var_offset(verify_batch),
2477 .help = "Verify this number of IO blocks",
2480 .category = FIO_OPT_C_IO,
2481 .group = FIO_OPT_G_VERIFY,
2483 #ifdef FIO_HAVE_CPU_AFFINITY
2485 .name = "verify_async_cpus",
2486 .lname = "Async verify CPUs",
2487 .type = FIO_OPT_STR,
2488 .cb = str_verify_cpus_allowed_cb,
2489 .off1 = td_var_offset(verify_cpumask),
2490 .help = "Set CPUs allowed for async verify threads",
2491 .parent = "verify_async",
2493 .category = FIO_OPT_C_IO,
2494 .group = FIO_OPT_G_VERIFY,
2498 .name = "experimental_verify",
2499 .off1 = td_var_offset(experimental_verify),
2500 .type = FIO_OPT_BOOL,
2501 .help = "Enable experimental verification",
2503 .category = FIO_OPT_C_IO,
2504 .group = FIO_OPT_G_VERIFY,
2507 .name = "verify_state_load",
2508 .lname = "Load verify state",
2509 .off1 = td_var_offset(verify_state),
2510 .type = FIO_OPT_BOOL,
2511 .help = "Load verify termination state",
2513 .category = FIO_OPT_C_IO,
2514 .group = FIO_OPT_G_VERIFY,
2517 .name = "verify_state_save",
2518 .lname = "Save verify state",
2519 .off1 = td_var_offset(verify_state_save),
2520 .type = FIO_OPT_BOOL,
2522 .help = "Save verify state on termination",
2524 .category = FIO_OPT_C_IO,
2525 .group = FIO_OPT_G_VERIFY,
2527 #ifdef FIO_HAVE_TRIM
2529 .name = "trim_percentage",
2530 .lname = "Trim percentage",
2531 .type = FIO_OPT_INT,
2532 .off1 = td_var_offset(trim_percentage),
2535 .help = "Number of verify blocks to discard/trim",
2540 .category = FIO_OPT_C_IO,
2541 .group = FIO_OPT_G_TRIM,
2544 .name = "trim_verify_zero",
2545 .lname = "Verify trim zero",
2546 .type = FIO_OPT_BOOL,
2547 .help = "Verify that trim/discarded blocks are returned as zeroes",
2548 .off1 = td_var_offset(trim_zero),
2549 .parent = "trim_percentage",
2552 .category = FIO_OPT_C_IO,
2553 .group = FIO_OPT_G_TRIM,
2556 .name = "trim_backlog",
2557 .lname = "Trim backlog",
2558 .type = FIO_OPT_STR_VAL,
2559 .off1 = td_var_offset(trim_backlog),
2560 .help = "Trim after this number of blocks are written",
2561 .parent = "trim_percentage",
2564 .category = FIO_OPT_C_IO,
2565 .group = FIO_OPT_G_TRIM,
2568 .name = "trim_backlog_batch",
2569 .lname = "Trim backlog batch",
2570 .type = FIO_OPT_INT,
2571 .off1 = td_var_offset(trim_batch),
2572 .help = "Trim this number of IO blocks",
2573 .parent = "trim_percentage",
2576 .category = FIO_OPT_C_IO,
2577 .group = FIO_OPT_G_TRIM,
2581 .name = "write_iolog",
2582 .lname = "Write I/O log",
2583 .type = FIO_OPT_STR_STORE,
2584 .off1 = td_var_offset(write_iolog_file),
2585 .help = "Store IO pattern to file",
2586 .category = FIO_OPT_C_IO,
2587 .group = FIO_OPT_G_IOLOG,
2590 .name = "read_iolog",
2591 .lname = "Read I/O log",
2592 .type = FIO_OPT_STR_STORE,
2593 .off1 = td_var_offset(read_iolog_file),
2594 .help = "Playback IO pattern from file",
2595 .category = FIO_OPT_C_IO,
2596 .group = FIO_OPT_G_IOLOG,
2599 .name = "replay_no_stall",
2600 .lname = "Don't stall on replay",
2601 .type = FIO_OPT_BOOL,
2602 .off1 = td_var_offset(no_stall),
2604 .parent = "read_iolog",
2606 .help = "Playback IO pattern file as fast as possible without stalls",
2607 .category = FIO_OPT_C_IO,
2608 .group = FIO_OPT_G_IOLOG,
2611 .name = "replay_redirect",
2612 .lname = "Redirect device for replay",
2613 .type = FIO_OPT_STR_STORE,
2614 .off1 = td_var_offset(replay_redirect),
2615 .parent = "read_iolog",
2617 .help = "Replay all I/O onto this device, regardless of trace device",
2618 .category = FIO_OPT_C_IO,
2619 .group = FIO_OPT_G_IOLOG,
2622 .name = "replay_scale",
2623 .lname = "Replace offset scale factor",
2624 .type = FIO_OPT_INT,
2625 .off1 = td_var_offset(replay_scale),
2626 .parent = "read_iolog",
2628 .help = "Align offsets to this blocksize",
2629 .category = FIO_OPT_C_IO,
2630 .group = FIO_OPT_G_IOLOG,
2633 .name = "replay_align",
2634 .lname = "Replace alignment",
2635 .type = FIO_OPT_INT,
2636 .off1 = td_var_offset(replay_align),
2637 .parent = "read_iolog",
2638 .help = "Scale offset down by this factor",
2639 .category = FIO_OPT_C_IO,
2640 .group = FIO_OPT_G_IOLOG,
2644 .name = "exec_prerun",
2645 .lname = "Pre-execute runnable",
2646 .type = FIO_OPT_STR_STORE,
2647 .off1 = td_var_offset(exec_prerun),
2648 .help = "Execute this file prior to running job",
2649 .category = FIO_OPT_C_GENERAL,
2650 .group = FIO_OPT_G_INVALID,
2653 .name = "exec_postrun",
2654 .lname = "Post-execute runnable",
2655 .type = FIO_OPT_STR_STORE,
2656 .off1 = td_var_offset(exec_postrun),
2657 .help = "Execute this file after running job",
2658 .category = FIO_OPT_C_GENERAL,
2659 .group = FIO_OPT_G_INVALID,
2661 #ifdef FIO_HAVE_IOSCHED_SWITCH
2663 .name = "ioscheduler",
2664 .lname = "I/O scheduler",
2665 .type = FIO_OPT_STR_STORE,
2666 .off1 = td_var_offset(ioscheduler),
2667 .help = "Use this IO scheduler on the backing device",
2668 .category = FIO_OPT_C_FILE,
2669 .group = FIO_OPT_G_INVALID,
2674 .lname = "Zone size",
2675 .type = FIO_OPT_STR_VAL,
2676 .off1 = td_var_offset(zone_size),
2677 .help = "Amount of data to read per zone",
2679 .interval = 1024 * 1024,
2680 .category = FIO_OPT_C_IO,
2681 .group = FIO_OPT_G_ZONE,
2684 .name = "zonerange",
2685 .lname = "Zone range",
2686 .type = FIO_OPT_STR_VAL,
2687 .off1 = td_var_offset(zone_range),
2688 .help = "Give size of an IO zone",
2690 .interval = 1024 * 1024,
2691 .category = FIO_OPT_C_IO,
2692 .group = FIO_OPT_G_ZONE,
2696 .lname = "Zone skip",
2697 .type = FIO_OPT_STR_VAL,
2698 .off1 = td_var_offset(zone_skip),
2699 .help = "Space between IO zones",
2701 .interval = 1024 * 1024,
2702 .category = FIO_OPT_C_IO,
2703 .group = FIO_OPT_G_ZONE,
2707 .lname = "Lock memory",
2708 .type = FIO_OPT_STR_VAL,
2709 .off1 = td_var_offset(lockmem),
2710 .help = "Lock down this amount of memory (per worker)",
2712 .interval = 1024 * 1024,
2713 .category = FIO_OPT_C_GENERAL,
2714 .group = FIO_OPT_G_INVALID,
2717 .name = "rwmixread",
2718 .lname = "Read/write mix read",
2719 .type = FIO_OPT_INT,
2720 .cb = str_rwmix_read_cb,
2721 .off1 = td_var_offset(rwmix[DDIR_READ]),
2723 .help = "Percentage of mixed workload that is reads",
2726 .inverse = "rwmixwrite",
2727 .category = FIO_OPT_C_IO,
2728 .group = FIO_OPT_G_RWMIX,
2731 .name = "rwmixwrite",
2732 .lname = "Read/write mix write",
2733 .type = FIO_OPT_INT,
2734 .cb = str_rwmix_write_cb,
2735 .off1 = td_var_offset(rwmix[DDIR_WRITE]),
2737 .help = "Percentage of mixed workload that is writes",
2740 .inverse = "rwmixread",
2741 .category = FIO_OPT_C_IO,
2742 .group = FIO_OPT_G_RWMIX,
2745 .name = "rwmixcycle",
2746 .lname = "Read/write mix cycle",
2747 .type = FIO_OPT_DEPRECATED,
2748 .category = FIO_OPT_C_IO,
2749 .group = FIO_OPT_G_RWMIX,
2754 .type = FIO_OPT_INT,
2755 .off1 = td_var_offset(nice),
2756 .help = "Set job CPU nice value",
2761 .category = FIO_OPT_C_GENERAL,
2762 .group = FIO_OPT_G_CRED,
2764 #ifdef FIO_HAVE_IOPRIO
2767 .lname = "I/O nice priority",
2768 .type = FIO_OPT_INT,
2769 .off1 = td_var_offset(ioprio),
2770 .help = "Set job IO priority value",
2774 .category = FIO_OPT_C_GENERAL,
2775 .group = FIO_OPT_G_CRED,
2778 .name = "prioclass",
2779 .lname = "I/O nice priority class",
2780 .type = FIO_OPT_INT,
2781 .off1 = td_var_offset(ioprio_class),
2782 .help = "Set job IO priority class",
2786 .category = FIO_OPT_C_GENERAL,
2787 .group = FIO_OPT_G_CRED,
2791 .name = "thinktime",
2792 .lname = "Thinktime",
2793 .type = FIO_OPT_INT,
2794 .off1 = td_var_offset(thinktime),
2795 .help = "Idle time between IO buffers (usec)",
2798 .category = FIO_OPT_C_IO,
2799 .group = FIO_OPT_G_THINKTIME,
2802 .name = "thinktime_spin",
2803 .lname = "Thinktime spin",
2804 .type = FIO_OPT_INT,
2805 .off1 = td_var_offset(thinktime_spin),
2806 .help = "Start think time by spinning this amount (usec)",
2809 .parent = "thinktime",
2811 .category = FIO_OPT_C_IO,
2812 .group = FIO_OPT_G_THINKTIME,
2815 .name = "thinktime_blocks",
2816 .lname = "Thinktime blocks",
2817 .type = FIO_OPT_INT,
2818 .off1 = td_var_offset(thinktime_blocks),
2819 .help = "IO buffer period between 'thinktime'",
2821 .parent = "thinktime",
2823 .category = FIO_OPT_C_IO,
2824 .group = FIO_OPT_G_THINKTIME,
2828 .lname = "I/O rate",
2829 .type = FIO_OPT_INT,
2830 .off1 = td_var_offset(rate[DDIR_READ]),
2831 .off2 = td_var_offset(rate[DDIR_WRITE]),
2832 .off3 = td_var_offset(rate[DDIR_TRIM]),
2833 .help = "Set bandwidth rate",
2834 .category = FIO_OPT_C_IO,
2835 .group = FIO_OPT_G_RATE,
2840 .lname = "I/O min rate",
2841 .type = FIO_OPT_INT,
2842 .off1 = td_var_offset(ratemin[DDIR_READ]),
2843 .off2 = td_var_offset(ratemin[DDIR_WRITE]),
2844 .off3 = td_var_offset(ratemin[DDIR_TRIM]),
2845 .help = "Job must meet this rate or it will be shutdown",
2848 .category = FIO_OPT_C_IO,
2849 .group = FIO_OPT_G_RATE,
2852 .name = "rate_iops",
2853 .lname = "I/O rate IOPS",
2854 .type = FIO_OPT_INT,
2855 .off1 = td_var_offset(rate_iops[DDIR_READ]),
2856 .off2 = td_var_offset(rate_iops[DDIR_WRITE]),
2857 .off3 = td_var_offset(rate_iops[DDIR_TRIM]),
2858 .help = "Limit IO used to this number of IO operations/sec",
2860 .category = FIO_OPT_C_IO,
2861 .group = FIO_OPT_G_RATE,
2864 .name = "rate_iops_min",
2865 .lname = "I/O min rate IOPS",
2866 .type = FIO_OPT_INT,
2867 .off1 = td_var_offset(rate_iops_min[DDIR_READ]),
2868 .off2 = td_var_offset(rate_iops_min[DDIR_WRITE]),
2869 .off3 = td_var_offset(rate_iops_min[DDIR_TRIM]),
2870 .help = "Job must meet this rate or it will be shut down",
2871 .parent = "rate_iops",
2873 .category = FIO_OPT_C_IO,
2874 .group = FIO_OPT_G_RATE,
2877 .name = "rate_process",
2878 .lname = "Rate Process",
2879 .type = FIO_OPT_STR,
2880 .off1 = td_var_offset(rate_process),
2881 .help = "What process controls how rated IO is managed",
2883 .category = FIO_OPT_C_IO,
2884 .group = FIO_OPT_G_RATE,
2887 .oval = RATE_PROCESS_LINEAR,
2888 .help = "Linear rate of IO",
2892 .oval = RATE_PROCESS_POISSON,
2893 .help = "Rate follows Poisson process",
2899 .name = "rate_cycle",
2900 .alias = "ratecycle",
2901 .lname = "I/O rate cycle",
2902 .type = FIO_OPT_INT,
2903 .off1 = td_var_offset(ratecycle),
2904 .help = "Window average for rate limits (msec)",
2908 .category = FIO_OPT_C_IO,
2909 .group = FIO_OPT_G_RATE,
2912 .name = "max_latency",
2913 .type = FIO_OPT_INT,
2914 .off1 = td_var_offset(max_latency),
2915 .help = "Maximum tolerated IO latency (usec)",
2917 .category = FIO_OPT_C_IO,
2918 .group = FIO_OPT_G_LATPROF,
2921 .name = "latency_target",
2922 .lname = "Latency Target (usec)",
2923 .type = FIO_OPT_STR_VAL_TIME,
2924 .off1 = td_var_offset(latency_target),
2925 .help = "Ramp to max queue depth supporting this latency",
2927 .category = FIO_OPT_C_IO,
2928 .group = FIO_OPT_G_LATPROF,
2931 .name = "latency_window",
2932 .lname = "Latency Window (usec)",
2933 .type = FIO_OPT_STR_VAL_TIME,
2934 .off1 = td_var_offset(latency_window),
2935 .help = "Time to sustain latency_target",
2937 .category = FIO_OPT_C_IO,
2938 .group = FIO_OPT_G_LATPROF,
2941 .name = "latency_percentile",
2942 .lname = "Latency Percentile",
2943 .type = FIO_OPT_FLOAT_LIST,
2944 .off1 = td_var_offset(latency_percentile),
2945 .help = "Percentile of IOs must be below latency_target",
2950 .category = FIO_OPT_C_IO,
2951 .group = FIO_OPT_G_LATPROF,
2954 .name = "invalidate",
2955 .lname = "Cache invalidate",
2956 .type = FIO_OPT_BOOL,
2957 .off1 = td_var_offset(invalidate_cache),
2958 .help = "Invalidate buffer/page cache prior to running job",
2960 .category = FIO_OPT_C_IO,
2961 .group = FIO_OPT_G_IO_TYPE,
2965 .lname = "Synchronous I/O",
2966 .type = FIO_OPT_BOOL,
2967 .off1 = td_var_offset(sync_io),
2968 .help = "Use O_SYNC for buffered writes",
2970 .parent = "buffered",
2972 .category = FIO_OPT_C_IO,
2973 .group = FIO_OPT_G_IO_TYPE,
2976 .name = "create_serialize",
2977 .lname = "Create serialize",
2978 .type = FIO_OPT_BOOL,
2979 .off1 = td_var_offset(create_serialize),
2980 .help = "Serialize creating of job files",
2982 .category = FIO_OPT_C_FILE,
2983 .group = FIO_OPT_G_INVALID,
2986 .name = "create_fsync",
2987 .lname = "Create fsync",
2988 .type = FIO_OPT_BOOL,
2989 .off1 = td_var_offset(create_fsync),
2990 .help = "fsync file after creation",
2992 .category = FIO_OPT_C_FILE,
2993 .group = FIO_OPT_G_INVALID,
2996 .name = "create_on_open",
2997 .lname = "Create on open",
2998 .type = FIO_OPT_BOOL,
2999 .off1 = td_var_offset(create_on_open),
3000 .help = "Create files when they are opened for IO",
3002 .category = FIO_OPT_C_FILE,
3003 .group = FIO_OPT_G_INVALID,
3006 .name = "create_only",
3007 .type = FIO_OPT_BOOL,
3008 .off1 = td_var_offset(create_only),
3009 .help = "Only perform file creation phase",
3010 .category = FIO_OPT_C_FILE,
3014 .name = "allow_file_create",
3015 .lname = "Allow file create",
3016 .type = FIO_OPT_BOOL,
3017 .off1 = td_var_offset(allow_create),
3018 .help = "Permit fio to create files, if they don't exist",
3020 .category = FIO_OPT_C_FILE,
3021 .group = FIO_OPT_G_FILENAME,
3024 .name = "allow_mounted_write",
3025 .lname = "Allow mounted write",
3026 .type = FIO_OPT_BOOL,
3027 .off1 = td_var_offset(allow_mounted_write),
3028 .help = "Allow writes to a mounted partition",
3030 .category = FIO_OPT_C_FILE,
3031 .group = FIO_OPT_G_FILENAME,
3035 .lname = "Pre-read files",
3036 .type = FIO_OPT_BOOL,
3037 .off1 = td_var_offset(pre_read),
3038 .help = "Pre-read files before starting official testing",
3040 .category = FIO_OPT_C_FILE,
3041 .group = FIO_OPT_G_INVALID,
3043 #ifdef FIO_HAVE_CPU_AFFINITY
3046 .lname = "CPU mask",
3047 .type = FIO_OPT_INT,
3048 .cb = str_cpumask_cb,
3049 .off1 = td_var_offset(cpumask),
3050 .help = "CPU affinity mask",
3051 .category = FIO_OPT_C_GENERAL,
3052 .group = FIO_OPT_G_CRED,
3055 .name = "cpus_allowed",
3056 .lname = "CPUs allowed",
3057 .type = FIO_OPT_STR,
3058 .cb = str_cpus_allowed_cb,
3059 .off1 = td_var_offset(cpumask),
3060 .help = "Set CPUs allowed",
3061 .category = FIO_OPT_C_GENERAL,
3062 .group = FIO_OPT_G_CRED,
3065 .name = "cpus_allowed_policy",
3066 .lname = "CPUs allowed distribution policy",
3067 .type = FIO_OPT_STR,
3068 .off1 = td_var_offset(cpus_allowed_policy),
3069 .help = "Distribution policy for cpus_allowed",
3070 .parent = "cpus_allowed",
3074 .oval = FIO_CPUS_SHARED,
3075 .help = "Mask shared between threads",
3078 .oval = FIO_CPUS_SPLIT,
3079 .help = "Mask split between threads",
3082 .category = FIO_OPT_C_GENERAL,
3083 .group = FIO_OPT_G_CRED,
3086 #ifdef CONFIG_LIBNUMA
3088 .name = "numa_cpu_nodes",
3089 .type = FIO_OPT_STR,
3090 .cb = str_numa_cpunodes_cb,
3091 .off1 = td_var_offset(numa_cpunodes),
3092 .help = "NUMA CPU nodes bind",
3093 .category = FIO_OPT_C_GENERAL,
3094 .group = FIO_OPT_G_INVALID,
3097 .name = "numa_mem_policy",
3098 .type = FIO_OPT_STR,
3099 .cb = str_numa_mpol_cb,
3100 .off1 = td_var_offset(numa_memnodes),
3101 .help = "NUMA memory policy setup",
3102 .category = FIO_OPT_C_GENERAL,
3103 .group = FIO_OPT_G_INVALID,
3107 .name = "end_fsync",
3108 .lname = "End fsync",
3109 .type = FIO_OPT_BOOL,
3110 .off1 = td_var_offset(end_fsync),
3111 .help = "Include fsync at the end of job",
3113 .category = FIO_OPT_C_FILE,
3114 .group = FIO_OPT_G_INVALID,
3117 .name = "fsync_on_close",
3118 .lname = "Fsync on close",
3119 .type = FIO_OPT_BOOL,
3120 .off1 = td_var_offset(fsync_on_close),
3121 .help = "fsync files on close",
3123 .category = FIO_OPT_C_FILE,
3124 .group = FIO_OPT_G_INVALID,
3128 .lname = "Unlink file",
3129 .type = FIO_OPT_BOOL,
3130 .off1 = td_var_offset(unlink),
3131 .help = "Unlink created files after job has completed",
3133 .category = FIO_OPT_C_FILE,
3134 .group = FIO_OPT_G_INVALID,
3138 .lname = "Exit-all on terminate",
3139 .type = FIO_OPT_STR_SET,
3140 .cb = str_exitall_cb,
3141 .help = "Terminate all jobs when one exits",
3142 .category = FIO_OPT_C_GENERAL,
3143 .group = FIO_OPT_G_PROCESS,
3146 .name = "exitall_on_error",
3147 .lname = "Exit-all on terminate in error",
3148 .type = FIO_OPT_BOOL,
3149 .off1 = td_var_offset(unlink),
3150 .help = "Terminate all jobs when one exits in error",
3151 .category = FIO_OPT_C_GENERAL,
3152 .group = FIO_OPT_G_PROCESS,
3155 .name = "stonewall",
3156 .lname = "Wait for previous",
3157 .alias = "wait_for_previous",
3158 .type = FIO_OPT_STR_SET,
3159 .off1 = td_var_offset(stonewall),
3160 .help = "Insert a hard barrier between this job and previous",
3161 .category = FIO_OPT_C_GENERAL,
3162 .group = FIO_OPT_G_PROCESS,
3165 .name = "new_group",
3166 .lname = "New group",
3167 .type = FIO_OPT_STR_SET,
3168 .off1 = td_var_offset(new_group),
3169 .help = "Mark the start of a new group (for reporting)",
3170 .category = FIO_OPT_C_GENERAL,
3171 .group = FIO_OPT_G_PROCESS,
3176 .type = FIO_OPT_STR_SET,
3177 .off1 = td_var_offset(use_thread),
3178 .help = "Use threads instead of processes",
3179 #ifdef CONFIG_NO_SHM
3183 .category = FIO_OPT_C_GENERAL,
3184 .group = FIO_OPT_G_PROCESS,
3187 .name = "per_job_logs",
3188 .type = FIO_OPT_BOOL,
3189 .off1 = td_var_offset(per_job_logs),
3190 .help = "Include job number in generated log files or not",
3192 .category = FIO_OPT_C_LOG,
3193 .group = FIO_OPT_G_INVALID,
3196 .name = "write_bw_log",
3197 .lname = "Write bandwidth log",
3198 .type = FIO_OPT_STR_STORE,
3199 .off1 = td_var_offset(bw_log_file),
3200 .help = "Write log of bandwidth during run",
3201 .category = FIO_OPT_C_LOG,
3202 .group = FIO_OPT_G_INVALID,
3205 .name = "write_lat_log",
3206 .lname = "Write latency log",
3207 .type = FIO_OPT_STR_STORE,
3208 .off1 = td_var_offset(lat_log_file),
3209 .help = "Write log of latency during run",
3210 .category = FIO_OPT_C_LOG,
3211 .group = FIO_OPT_G_INVALID,
3214 .name = "write_iops_log",
3215 .lname = "Write IOPS log",
3216 .type = FIO_OPT_STR_STORE,
3217 .off1 = td_var_offset(iops_log_file),
3218 .help = "Write log of IOPS during run",
3219 .category = FIO_OPT_C_LOG,
3220 .group = FIO_OPT_G_INVALID,
3223 .name = "log_avg_msec",
3224 .lname = "Log averaging (msec)",
3225 .type = FIO_OPT_INT,
3226 .off1 = td_var_offset(log_avg_msec),
3227 .help = "Average bw/iops/lat logs over this period of time",
3229 .category = FIO_OPT_C_LOG,
3230 .group = FIO_OPT_G_INVALID,
3233 .name = "log_offset",
3234 .lname = "Log offset of IO",
3235 .type = FIO_OPT_BOOL,
3236 .off1 = td_var_offset(log_offset),
3237 .help = "Include offset of IO for each log entry",
3239 .category = FIO_OPT_C_LOG,
3240 .group = FIO_OPT_G_INVALID,
3244 .name = "log_compression",
3245 .lname = "Log compression",
3246 .type = FIO_OPT_INT,
3247 .off1 = td_var_offset(log_gz),
3248 .help = "Log in compressed chunks of this size",
3250 .maxval = 512 * 1024 * 1024ULL,
3251 .category = FIO_OPT_C_LOG,
3252 .group = FIO_OPT_G_INVALID,
3254 #ifdef FIO_HAVE_CPU_AFFINITY
3256 .name = "log_compression_cpus",
3257 .lname = "Log Compression CPUs",
3258 .type = FIO_OPT_STR,
3259 .cb = str_log_cpus_allowed_cb,
3260 .off1 = td_var_offset(log_gz_cpumask),
3261 .parent = "log_compression",
3262 .help = "Limit log compression to these CPUs",
3263 .category = FIO_OPT_C_LOG,
3264 .group = FIO_OPT_G_INVALID,
3268 .name = "log_store_compressed",
3269 .lname = "Log store compressed",
3270 .type = FIO_OPT_BOOL,
3271 .off1 = td_var_offset(log_gz_store),
3272 .help = "Store logs in a compressed format",
3273 .category = FIO_OPT_C_LOG,
3274 .group = FIO_OPT_G_INVALID,
3278 .name = "block_error_percentiles",
3279 .lname = "Block error percentiles",
3280 .type = FIO_OPT_BOOL,
3281 .off1 = td_var_offset(block_error_hist),
3282 .help = "Record trim block errors and make a histogram",
3284 .category = FIO_OPT_C_LOG,
3285 .group = FIO_OPT_G_INVALID,
3288 .name = "bwavgtime",
3289 .lname = "Bandwidth average time",
3290 .type = FIO_OPT_INT,
3291 .off1 = td_var_offset(bw_avg_time),
3292 .help = "Time window over which to calculate bandwidth"
3295 .parent = "write_bw_log",
3298 .category = FIO_OPT_C_LOG,
3299 .group = FIO_OPT_G_INVALID,
3302 .name = "iopsavgtime",
3303 .lname = "IOPS average time",
3304 .type = FIO_OPT_INT,
3305 .off1 = td_var_offset(iops_avg_time),
3306 .help = "Time window over which to calculate IOPS (msec)",
3308 .parent = "write_iops_log",
3311 .category = FIO_OPT_C_LOG,
3312 .group = FIO_OPT_G_INVALID,
3315 .name = "group_reporting",
3316 .lname = "Group reporting",
3317 .type = FIO_OPT_STR_SET,
3318 .off1 = td_var_offset(group_reporting),
3319 .help = "Do reporting on a per-group basis",
3320 .category = FIO_OPT_C_STAT,
3321 .group = FIO_OPT_G_INVALID,
3324 .name = "zero_buffers",
3325 .lname = "Zero I/O buffers",
3326 .type = FIO_OPT_STR_SET,
3327 .off1 = td_var_offset(zero_buffers),
3328 .help = "Init IO buffers to all zeroes",
3329 .category = FIO_OPT_C_IO,
3330 .group = FIO_OPT_G_IO_BUF,
3333 .name = "refill_buffers",
3334 .lname = "Refill I/O buffers",
3335 .type = FIO_OPT_STR_SET,
3336 .off1 = td_var_offset(refill_buffers),
3337 .help = "Refill IO buffers on every IO submit",
3338 .category = FIO_OPT_C_IO,
3339 .group = FIO_OPT_G_IO_BUF,
3342 .name = "scramble_buffers",
3343 .lname = "Scramble I/O buffers",
3344 .type = FIO_OPT_BOOL,
3345 .off1 = td_var_offset(scramble_buffers),
3346 .help = "Slightly scramble buffers on every IO submit",
3348 .category = FIO_OPT_C_IO,
3349 .group = FIO_OPT_G_IO_BUF,
3352 .name = "buffer_pattern",
3353 .lname = "Buffer pattern",
3354 .type = FIO_OPT_STR,
3355 .cb = str_buffer_pattern_cb,
3356 .off1 = td_var_offset(buffer_pattern),
3357 .help = "Fill pattern for IO buffers",
3358 .category = FIO_OPT_C_IO,
3359 .group = FIO_OPT_G_IO_BUF,
3362 .name = "buffer_compress_percentage",
3363 .lname = "Buffer compression percentage",
3364 .type = FIO_OPT_INT,
3365 .cb = str_buffer_compress_cb,
3366 .off1 = td_var_offset(compress_percentage),
3369 .help = "How compressible the buffer is (approximately)",
3371 .category = FIO_OPT_C_IO,
3372 .group = FIO_OPT_G_IO_BUF,
3375 .name = "buffer_compress_chunk",
3376 .lname = "Buffer compression chunk size",
3377 .type = FIO_OPT_INT,
3378 .off1 = td_var_offset(compress_chunk),
3379 .parent = "buffer_compress_percentage",
3381 .help = "Size of compressible region in buffer",
3383 .category = FIO_OPT_C_IO,
3384 .group = FIO_OPT_G_IO_BUF,
3387 .name = "dedupe_percentage",
3388 .lname = "Dedupe percentage",
3389 .type = FIO_OPT_INT,
3390 .cb = str_dedupe_cb,
3391 .off1 = td_var_offset(dedupe_percentage),
3394 .help = "Percentage of buffers that are dedupable",
3396 .category = FIO_OPT_C_IO,
3397 .group = FIO_OPT_G_IO_BUF,
3400 .name = "clat_percentiles",
3401 .lname = "Completion latency percentiles",
3402 .type = FIO_OPT_BOOL,
3403 .off1 = td_var_offset(clat_percentiles),
3404 .help = "Enable the reporting of completion latency percentiles",
3406 .category = FIO_OPT_C_STAT,
3407 .group = FIO_OPT_G_INVALID,
3410 .name = "percentile_list",
3411 .lname = "Percentile list",
3412 .type = FIO_OPT_FLOAT_LIST,
3413 .off1 = td_var_offset(percentile_list),
3414 .off2 = td_var_offset(percentile_precision),
3415 .help = "Specify a custom list of percentiles to report for "
3416 "completion latency and block errors",
3417 .def = "1:5:10:20:30:40:50:60:70:80:90:95:99:99.5:99.9:99.95:99.99",
3418 .maxlen = FIO_IO_U_LIST_MAX_LEN,
3421 .category = FIO_OPT_C_STAT,
3422 .group = FIO_OPT_G_INVALID,
3425 #ifdef FIO_HAVE_DISK_UTIL
3427 .name = "disk_util",
3428 .lname = "Disk utilization",
3429 .type = FIO_OPT_BOOL,
3430 .off1 = td_var_offset(do_disk_util),
3431 .help = "Log disk utilization statistics",
3433 .category = FIO_OPT_C_STAT,
3434 .group = FIO_OPT_G_INVALID,
3438 .name = "gtod_reduce",
3439 .lname = "Reduce gettimeofday() calls",
3440 .type = FIO_OPT_BOOL,
3441 .help = "Greatly reduce number of gettimeofday() calls",
3442 .cb = str_gtod_reduce_cb,
3445 .category = FIO_OPT_C_STAT,
3446 .group = FIO_OPT_G_INVALID,
3449 .name = "disable_lat",
3450 .lname = "Disable all latency stats",
3451 .type = FIO_OPT_BOOL,
3452 .off1 = td_var_offset(disable_lat),
3453 .help = "Disable latency numbers",
3454 .parent = "gtod_reduce",
3457 .category = FIO_OPT_C_STAT,
3458 .group = FIO_OPT_G_INVALID,
3461 .name = "disable_clat",
3462 .lname = "Disable completion latency stats",
3463 .type = FIO_OPT_BOOL,
3464 .off1 = td_var_offset(disable_clat),
3465 .help = "Disable completion latency numbers",
3466 .parent = "gtod_reduce",
3469 .category = FIO_OPT_C_STAT,
3470 .group = FIO_OPT_G_INVALID,
3473 .name = "disable_slat",
3474 .lname = "Disable submission latency stats",
3475 .type = FIO_OPT_BOOL,
3476 .off1 = td_var_offset(disable_slat),
3477 .help = "Disable submission latency numbers",
3478 .parent = "gtod_reduce",
3481 .category = FIO_OPT_C_STAT,
3482 .group = FIO_OPT_G_INVALID,
3485 .name = "disable_bw_measurement",
3486 .lname = "Disable bandwidth stats",
3487 .type = FIO_OPT_BOOL,
3488 .off1 = td_var_offset(disable_bw),
3489 .help = "Disable bandwidth logging",
3490 .parent = "gtod_reduce",
3493 .category = FIO_OPT_C_STAT,
3494 .group = FIO_OPT_G_INVALID,
3498 .lname = "Dedicated gettimeofday() CPU",
3499 .type = FIO_OPT_INT,
3500 .off1 = td_var_offset(gtod_cpu),
3501 .help = "Set up dedicated gettimeofday() thread on this CPU",
3502 .verify = gtod_cpu_verify,
3503 .category = FIO_OPT_C_GENERAL,
3504 .group = FIO_OPT_G_CLOCK,
3507 .name = "unified_rw_reporting",
3508 .type = FIO_OPT_BOOL,
3509 .off1 = td_var_offset(unified_rw_rep),
3510 .help = "Unify reporting across data direction",
3512 .category = FIO_OPT_C_GENERAL,
3513 .group = FIO_OPT_G_INVALID,
3516 .name = "continue_on_error",
3517 .lname = "Continue on error",
3518 .type = FIO_OPT_STR,
3519 .off1 = td_var_offset(continue_on_error),
3520 .help = "Continue on non-fatal errors during IO",
3522 .category = FIO_OPT_C_GENERAL,
3523 .group = FIO_OPT_G_ERR,
3526 .oval = ERROR_TYPE_NONE,
3527 .help = "Exit when an error is encountered",
3530 .oval = ERROR_TYPE_READ,
3531 .help = "Continue on read errors only",
3534 .oval = ERROR_TYPE_WRITE,
3535 .help = "Continue on write errors only",
3538 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
3539 .help = "Continue on any IO errors",
3542 .oval = ERROR_TYPE_VERIFY,
3543 .help = "Continue on verify errors only",
3546 .oval = ERROR_TYPE_ANY,
3547 .help = "Continue on all io and verify errors",
3550 .oval = ERROR_TYPE_NONE,
3551 .help = "Alias for 'none'",
3554 .oval = ERROR_TYPE_ANY,
3555 .help = "Alias for 'all'",
3560 .name = "ignore_error",
3561 .type = FIO_OPT_STR,
3562 .cb = str_ignore_error_cb,
3563 .off1 = td_var_offset(ignore_error_nr),
3564 .help = "Set a specific list of errors to ignore",
3566 .category = FIO_OPT_C_GENERAL,
3567 .group = FIO_OPT_G_ERR,
3570 .name = "error_dump",
3571 .type = FIO_OPT_BOOL,
3572 .off1 = td_var_offset(error_dump),
3574 .help = "Dump info on each error",
3575 .category = FIO_OPT_C_GENERAL,
3576 .group = FIO_OPT_G_ERR,
3581 .type = FIO_OPT_STR_STORE,
3582 .off1 = td_var_offset(profile),
3583 .help = "Select a specific builtin performance test",
3584 .category = FIO_OPT_C_PROFILE,
3585 .group = FIO_OPT_G_INVALID,
3590 .type = FIO_OPT_STR_STORE,
3591 .off1 = td_var_offset(cgroup),
3592 .help = "Add job to cgroup of this name",
3593 .category = FIO_OPT_C_GENERAL,
3594 .group = FIO_OPT_G_CGROUP,
3597 .name = "cgroup_nodelete",
3598 .lname = "Cgroup no-delete",
3599 .type = FIO_OPT_BOOL,
3600 .off1 = td_var_offset(cgroup_nodelete),
3601 .help = "Do not delete cgroups after job completion",
3604 .category = FIO_OPT_C_GENERAL,
3605 .group = FIO_OPT_G_CGROUP,
3608 .name = "cgroup_weight",
3609 .lname = "Cgroup weight",
3610 .type = FIO_OPT_INT,
3611 .off1 = td_var_offset(cgroup_weight),
3612 .help = "Use given weight for cgroup",
3616 .category = FIO_OPT_C_GENERAL,
3617 .group = FIO_OPT_G_CGROUP,
3622 .type = FIO_OPT_INT,
3623 .off1 = td_var_offset(uid),
3624 .help = "Run job with this user ID",
3625 .category = FIO_OPT_C_GENERAL,
3626 .group = FIO_OPT_G_CRED,
3630 .lname = "Group ID",
3631 .type = FIO_OPT_INT,
3632 .off1 = td_var_offset(gid),
3633 .help = "Run job with this group ID",
3634 .category = FIO_OPT_C_GENERAL,
3635 .group = FIO_OPT_G_CRED,
3640 .type = FIO_OPT_INT,
3641 .off1 = td_var_offset(kb_base),
3647 .help = "Use 1024 as the K base",
3651 .help = "Use 1000 as the K base",
3654 .help = "How many bytes per KB for reporting (1000 or 1024)",
3655 .category = FIO_OPT_C_GENERAL,
3656 .group = FIO_OPT_G_INVALID,
3659 .name = "unit_base",
3660 .lname = "Base unit for reporting (Bits or Bytes)",
3661 .type = FIO_OPT_INT,
3662 .off1 = td_var_offset(unit_base),
3667 .help = "Auto-detect",
3671 .help = "Normal (byte based)",
3675 .help = "Bit based",
3678 .help = "Bit multiple of result summary data (8 for byte, 1 for bit)",
3679 .category = FIO_OPT_C_GENERAL,
3680 .group = FIO_OPT_G_INVALID,
3683 .name = "hugepage-size",
3684 .lname = "Hugepage size",
3685 .type = FIO_OPT_INT,
3686 .off1 = td_var_offset(hugepage_size),
3687 .help = "When using hugepages, specify size of each page",
3688 .def = __fio_stringify(FIO_HUGE_PAGE),
3689 .interval = 1024 * 1024,
3690 .category = FIO_OPT_C_GENERAL,
3691 .group = FIO_OPT_G_INVALID,
3695 .lname = "I/O flow ID",
3696 .type = FIO_OPT_INT,
3697 .off1 = td_var_offset(flow_id),
3698 .help = "The flow index ID to use",
3700 .category = FIO_OPT_C_IO,
3701 .group = FIO_OPT_G_IO_FLOW,
3705 .lname = "I/O flow weight",
3706 .type = FIO_OPT_INT,
3707 .off1 = td_var_offset(flow),
3708 .help = "Weight for flow control of this job",
3709 .parent = "flow_id",
3712 .category = FIO_OPT_C_IO,
3713 .group = FIO_OPT_G_IO_FLOW,
3716 .name = "flow_watermark",
3717 .lname = "I/O flow watermark",
3718 .type = FIO_OPT_INT,
3719 .off1 = td_var_offset(flow_watermark),
3720 .help = "High watermark for flow control. This option"
3721 " should be set to the same value for all threads"
3722 " with non-zero flow.",
3723 .parent = "flow_id",
3726 .category = FIO_OPT_C_IO,
3727 .group = FIO_OPT_G_IO_FLOW,
3730 .name = "flow_sleep",
3731 .lname = "I/O flow sleep",
3732 .type = FIO_OPT_INT,
3733 .off1 = td_var_offset(flow_sleep),
3734 .help = "How many microseconds to sleep after being held"
3735 " back by the flow control mechanism",
3736 .parent = "flow_id",
3739 .category = FIO_OPT_C_IO,
3740 .group = FIO_OPT_G_IO_FLOW,
3744 .lname = "Skip operations against bad blocks",
3745 .type = FIO_OPT_BOOL,
3746 .off1 = td_var_offset(skip_bad),
3747 .help = "Skip operations against known bad blocks.",
3750 .category = FIO_OPT_C_IO,
3751 .group = FIO_OPT_G_MTD,
3758 static void add_to_lopt(struct option *lopt, struct fio_option *o,
3759 const char *name, int val)
3761 lopt->name = (char *) name;
3763 if (o->type == FIO_OPT_STR_SET)
3764 lopt->has_arg = optional_argument;
3766 lopt->has_arg = required_argument;
3769 static void options_to_lopts(struct fio_option *opts,
3770 struct option *long_options,
3771 int i, int option_type)
3773 struct fio_option *o = &opts[0];
3775 add_to_lopt(&long_options[i], o, o->name, option_type);
3778 add_to_lopt(&long_options[i], o, o->alias, option_type);
3783 assert(i < FIO_NR_OPTIONS);
3787 void fio_options_set_ioengine_opts(struct option *long_options,
3788 struct thread_data *td)
3793 while (long_options[i].name) {
3794 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
3795 memset(&long_options[i], 0, sizeof(*long_options));
3802 * Just clear out the prior ioengine options.
3807 options_to_lopts(td->io_ops->options, long_options, i,
3808 FIO_GETOPT_IOENGINE);
3811 void fio_options_dup_and_init(struct option *long_options)
3815 options_init(fio_options);
3818 while (long_options[i].name)
3821 options_to_lopts(fio_options, long_options, i, FIO_GETOPT_JOB);
3824 struct fio_keyword {
3830 static struct fio_keyword fio_keywords[] = {
3832 .word = "$pagesize",
3833 .desc = "Page size in the system",
3836 .word = "$mb_memory",
3837 .desc = "Megabytes of memory online",
3841 .desc = "Number of CPUs online in the system",
3848 void fio_keywords_exit(void)
3850 struct fio_keyword *kw;
3852 kw = &fio_keywords[0];
3860 void fio_keywords_init(void)
3862 unsigned long long mb_memory;
3866 sprintf(buf, "%lu", (unsigned long) page_size);
3867 fio_keywords[0].replace = strdup(buf);
3869 mb_memory = os_phys_mem() / (1024 * 1024);
3870 sprintf(buf, "%llu", mb_memory);
3871 fio_keywords[1].replace = strdup(buf);
3874 sprintf(buf, "%lu", l);
3875 fio_keywords[2].replace = strdup(buf);
3880 static char *bc_calc(char *str)
3882 char buf[128], *tmp;
3887 * No math, just return string
3889 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
3890 !strchr(str, '/')) || strchr(str, '\''))
3894 * Split option from value, we only need to calculate the value
3896 tmp = strchr(str, '=');
3903 * Prevent buffer overflows; such a case isn't reasonable anyway
3905 if (strlen(str) >= 128 || strlen(tmp) > 100)
3908 sprintf(buf, "which %s > /dev/null", BC_APP);
3910 log_err("fio: bc is needed for performing math\n");
3914 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
3915 f = popen(buf, "r");
3919 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
3926 buf[(tmp - str) + ret - 1] = '\0';
3927 memcpy(buf, str, tmp - str);
3933 * Return a copy of the input string with substrings of the form ${VARNAME}
3934 * substituted with the value of the environment variable VARNAME. The
3935 * substitution always occurs, even if VARNAME is empty or the corresponding
3936 * environment variable undefined.
3938 static char *option_dup_subs(const char *opt)
3940 char out[OPT_LEN_MAX+1];
3941 char in[OPT_LEN_MAX+1];
3944 char *ch1, *ch2, *env;
3945 ssize_t nchr = OPT_LEN_MAX;
3948 if (strlen(opt) + 1 > OPT_LEN_MAX) {
3949 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
3953 in[OPT_LEN_MAX] = '\0';
3954 strncpy(in, opt, OPT_LEN_MAX);
3956 while (*inptr && nchr > 0) {
3957 if (inptr[0] == '$' && inptr[1] == '{') {
3958 ch2 = strchr(inptr, '}');
3959 if (ch2 && inptr+1 < ch2) {
3966 envlen = strlen(env);
3967 if (envlen <= nchr) {
3968 memcpy(outptr, env, envlen);
3978 *outptr++ = *inptr++;
3987 * Look for reserved variable names and replace them with real values
3989 static char *fio_keyword_replace(char *opt)
3995 for (i = 0; fio_keywords[i].word != NULL; i++) {
3996 struct fio_keyword *kw = &fio_keywords[i];
3998 while ((s = strstr(opt, kw->word)) != NULL) {
3999 char *new = malloc(strlen(opt) + 1);
4005 * Copy part of the string before the keyword and
4006 * sprintf() the replacement after it.
4008 memcpy(new, opt, olen);
4009 len = sprintf(new + olen, "%s", kw->replace);
4012 * If there's more in the original string, copy that
4015 opt += strlen(kw->word) + olen;
4017 memcpy(new + olen + len, opt, opt - o_org - 1);
4020 * replace opt and free the old opt
4030 * Check for potential math and invoke bc, if possible
4038 static char **dup_and_sub_options(char **opts, int num_opts)
4041 char **opts_copy = malloc(num_opts * sizeof(*opts));
4042 for (i = 0; i < num_opts; i++) {
4043 opts_copy[i] = option_dup_subs(opts[i]);
4046 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
4051 static void show_closest_option(const char *opt)
4053 int best_option, best_distance;
4062 while (name[i] != '\0' && name[i] != '=')
4067 best_distance = INT_MAX;
4069 while (fio_options[i].name) {
4070 distance = string_distance(name, fio_options[i].name);
4071 if (distance < best_distance) {
4072 best_distance = distance;
4078 if (best_option != -1 && string_distance_ok(name, best_distance))
4079 log_err("Did you mean %s?\n", fio_options[best_option].name);
4084 int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
4086 int i, ret, unknown;
4089 sort_options(opts, fio_options, num_opts);
4090 opts_copy = dup_and_sub_options(opts, num_opts);
4092 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
4093 struct fio_option *o;
4094 int newret = parse_option(opts_copy[i], opts[i], fio_options,
4095 &o, td, &td->opt_list);
4098 fio_option_mark_set(&td->o, o);
4106 opts_copy[i] = NULL;
4113 ret |= ioengine_load(td);
4115 sort_options(opts_copy, td->io_ops->options, num_opts);
4118 for (i = 0; i < num_opts; i++) {
4119 struct fio_option *o = NULL;
4126 newret = parse_option(opts_copy[i], opts[i],
4127 td->io_ops->options, &o,
4128 td->eo, &td->opt_list);
4132 log_err("Bad option <%s>\n", opts[i]);
4133 show_closest_option(opts[i]);
4136 opts_copy[i] = NULL;
4144 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
4148 ret = parse_cmd_option(opt, val, fio_options, td, &td->opt_list);
4150 struct fio_option *o;
4152 o = find_option(fio_options, opt);
4154 fio_option_mark_set(&td->o, o);
4160 int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
4163 return parse_cmd_option(opt, val, td->io_ops->options, td->eo,
4167 void fio_fill_default_options(struct thread_data *td)
4169 td->o.magic = OPT_MAGIC;
4170 fill_default_options(td, fio_options);
4173 int fio_show_option_help(const char *opt)
4175 return show_cmd_help(fio_options, opt);
4178 void options_mem_dupe(void *data, struct fio_option *options)
4180 struct fio_option *o;
4183 for (o = &options[0]; o->name; o++) {
4184 if (o->type != FIO_OPT_STR_STORE)
4187 ptr = td_var(data, o, o->off1);
4189 *ptr = strdup(*ptr);
4194 * dupe FIO_OPT_STR_STORE options
4196 void fio_options_mem_dupe(struct thread_data *td)
4198 options_mem_dupe(&td->o, fio_options);
4200 if (td->eo && td->io_ops) {
4201 void *oldeo = td->eo;
4203 td->eo = malloc(td->io_ops->option_struct_size);
4204 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
4205 options_mem_dupe(td->eo, td->io_ops->options);
4209 unsigned int fio_get_kb_base(void *data)
4211 struct thread_options *o = data;
4212 unsigned int kb_base = 0;
4215 * This is a hack... For private options, *data is not holding
4216 * a pointer to the thread_options, but to private data. This means
4217 * we can't safely dereference it, but magic is first so mem wise
4218 * it is valid. But this also means that if the job first sets
4219 * kb_base and expects that to be honored by private options,
4220 * it will be disappointed. We will return the global default
4223 if (o && o->magic == OPT_MAGIC)
4224 kb_base = o->kb_base;
4231 int add_option(struct fio_option *o)
4233 struct fio_option *__o;
4242 if (opt_index + 1 == FIO_MAX_OPTS) {
4243 log_err("fio: FIO_MAX_OPTS is too small\n");
4247 memcpy(&fio_options[opt_index], o, sizeof(*o));
4248 fio_options[opt_index + 1].name = NULL;
4252 void invalidate_profile_options(const char *prof_name)
4254 struct fio_option *o;
4258 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
4259 o->type = FIO_OPT_INVALID;
4260 o->prof_name = NULL;
4266 void add_opt_posval(const char *optname, const char *ival, const char *help)
4268 struct fio_option *o;
4271 o = find_option(fio_options, optname);
4275 for (i = 0; i < PARSE_MAX_VP; i++) {
4276 if (o->posval[i].ival)
4279 o->posval[i].ival = ival;
4280 o->posval[i].help = help;
4285 void del_opt_posval(const char *optname, const char *ival)
4287 struct fio_option *o;
4290 o = find_option(fio_options, optname);
4294 for (i = 0; i < PARSE_MAX_VP; i++) {
4295 if (!o->posval[i].ival)
4297 if (strcmp(o->posval[i].ival, ival))
4300 o->posval[i].ival = NULL;
4301 o->posval[i].help = NULL;
4305 void fio_options_free(struct thread_data *td)
4307 options_free(fio_options, td);
4308 if (td->eo && td->io_ops && td->io_ops->options) {
4309 options_free(td->io_ops->options, td->eo);
4315 struct fio_option *fio_option_find(const char *name)
4317 return find_option(fio_options, name);
4320 static struct fio_option *find_next_opt(struct thread_options *o,
4321 struct fio_option *from,
4324 struct fio_option *opt;
4327 from = &fio_options[0];
4333 if (off1 == from->off1) {
4338 } while (from->name);
4343 static int opt_is_set(struct thread_options *o, struct fio_option *opt)
4345 unsigned int opt_off, index, offset;
4347 opt_off = opt - &fio_options[0];
4348 index = opt_off / (8 * sizeof(uint64_t));
4349 offset = opt_off & ((8 * sizeof(uint64_t)) - 1);
4350 return (o->set_options[index] & ((uint64_t)1 << offset)) != 0;
4353 int __fio_option_is_set(struct thread_options *o, unsigned int off1)
4355 struct fio_option *opt, *next;
4358 while ((opt = find_next_opt(o, next, off1)) != NULL) {
4359 if (opt_is_set(o, opt))
4368 void fio_option_mark_set(struct thread_options *o, struct fio_option *opt)
4370 unsigned int opt_off, index, offset;
4372 opt_off = opt - &fio_options[0];
4373 index = opt_off / (8 * sizeof(uint64_t));
4374 offset = opt_off & ((8 * sizeof(uint64_t)) - 1);
4375 o->set_options[index] |= (uint64_t)1 << offset;