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);
207 ret = bssplit_ddir(&td->o, DDIR_READ, str);
214 static int str2error(char *str)
216 const char *err[] = { "EPERM", "ENOENT", "ESRCH", "EINTR", "EIO",
217 "ENXIO", "E2BIG", "ENOEXEC", "EBADF",
218 "ECHILD", "EAGAIN", "ENOMEM", "EACCES",
219 "EFAULT", "ENOTBLK", "EBUSY", "EEXIST",
220 "EXDEV", "ENODEV", "ENOTDIR", "EISDIR",
221 "EINVAL", "ENFILE", "EMFILE", "ENOTTY",
222 "ETXTBSY","EFBIG", "ENOSPC", "ESPIPE",
223 "EROFS","EMLINK", "EPIPE", "EDOM", "ERANGE" };
224 int i = 0, num = sizeof(err) / sizeof(void *);
227 if (!strcmp(err[i], str))
234 static int ignore_error_type(struct thread_data *td, int etype, char *str)
240 if (etype >= ERROR_TYPE_CNT) {
241 log_err("Illegal error type\n");
245 td->o.ignore_error_nr[etype] = 4;
246 error = malloc(4 * sizeof(struct bssplit));
249 while ((fname = strsep(&str, ":")) != NULL) {
255 * grow struct buffer, if needed
257 if (i == td->o.ignore_error_nr[etype]) {
258 td->o.ignore_error_nr[etype] <<= 1;
259 error = realloc(error, td->o.ignore_error_nr[etype]
262 if (fname[0] == 'E') {
263 error[i] = str2error(fname);
265 error[i] = atoi(fname);
267 error[i] = -error[i];
270 log_err("Unknown error %s, please use number value \n",
278 td->o.continue_on_error |= 1 << etype;
279 td->o.ignore_error_nr[etype] = i;
280 td->o.ignore_error[etype] = error;
288 static int str_ignore_error_cb(void *data, const char *input)
290 struct thread_data *td = data;
292 int type = 0, ret = 1;
297 p = str = strdup(input);
299 strip_blank_front(&str);
300 strip_blank_end(str);
306 ret = ignore_error_type(td, type, p);
316 static int str_rw_cb(void *data, const char *str)
318 struct thread_data *td = data;
319 struct thread_options *o = &td->o;
328 nr = get_opt_postfix(str);
333 o->ddir_seq_nr = atoi(nr);
337 if (str_to_decimal(nr, &val, 1, o, 0, 0)) {
338 log_err("fio: rw postfix parsing failed\n");
343 o->ddir_seq_add = val;
350 static int str_mem_cb(void *data, const char *mem)
352 struct thread_data *td = data;
354 if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP)
355 td->o.mmapfile = get_opt_postfix(mem);
360 static int fio_clock_source_cb(void *data, const char *str)
362 struct thread_data *td = data;
364 fio_clock_source = td->o.clocksource;
365 fio_clock_source_set = 1;
370 static int str_rwmix_read_cb(void *data, unsigned long long *val)
372 struct thread_data *td = data;
374 td->o.rwmix[DDIR_READ] = *val;
375 td->o.rwmix[DDIR_WRITE] = 100 - *val;
379 static int str_rwmix_write_cb(void *data, unsigned long long *val)
381 struct thread_data *td = data;
383 td->o.rwmix[DDIR_WRITE] = *val;
384 td->o.rwmix[DDIR_READ] = 100 - *val;
388 static int str_exitall_cb(void)
390 exitall_on_terminate = 1;
394 #ifdef FIO_HAVE_CPU_AFFINITY
395 int fio_cpus_split(os_cpu_mask_t *mask, unsigned int cpu_index)
397 unsigned int i, index, cpus_in_mask;
398 const long max_cpu = cpus_online();
400 cpus_in_mask = fio_cpu_count(mask);
401 cpu_index = cpu_index % cpus_in_mask;
404 for (i = 0; i < max_cpu; i++) {
405 if (!fio_cpu_isset(mask, i))
408 if (cpu_index != index)
409 fio_cpu_clear(mask, i);
414 return fio_cpu_count(mask);
417 static int str_cpumask_cb(void *data, unsigned long long *val)
419 struct thread_data *td = data;
427 ret = fio_cpuset_init(&td->o.cpumask);
429 log_err("fio: cpuset_init failed\n");
430 td_verror(td, ret, "fio_cpuset_init");
434 max_cpu = cpus_online();
436 for (i = 0; i < sizeof(int) * 8; i++) {
437 if ((1 << i) & *val) {
439 log_err("fio: CPU %d too large (max=%ld)\n", i,
443 dprint(FD_PARSE, "set cpu allowed %d\n", i);
444 fio_cpu_set(&td->o.cpumask, i);
451 static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask,
458 ret = fio_cpuset_init(mask);
460 log_err("fio: cpuset_init failed\n");
461 td_verror(td, ret, "fio_cpuset_init");
465 p = str = strdup(input);
467 strip_blank_front(&str);
468 strip_blank_end(str);
470 max_cpu = cpus_online();
472 while ((cpu = strsep(&str, ",")) != NULL) {
481 while ((cpu2 = strsep(&str2, "-")) != NULL) {
491 while (icpu <= icpu2) {
492 if (icpu >= FIO_MAX_CPUS) {
493 log_err("fio: your OS only supports up to"
494 " %d CPUs\n", (int) FIO_MAX_CPUS);
498 if (icpu >= max_cpu) {
499 log_err("fio: CPU %d too large (max=%ld)\n",
505 dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
506 fio_cpu_set(mask, icpu);
517 static int str_cpus_allowed_cb(void *data, const char *input)
519 struct thread_data *td = data;
524 return set_cpus_allowed(td, &td->o.cpumask, input);
527 static int str_verify_cpus_allowed_cb(void *data, const char *input)
529 struct thread_data *td = data;
531 return set_cpus_allowed(td, &td->o.verify_cpumask, input);
535 #ifdef CONFIG_LIBNUMA
536 static int str_numa_cpunodes_cb(void *data, char *input)
538 struct thread_data *td = data;
539 struct bitmask *verify_bitmask;
544 /* numa_parse_nodestring() parses a character string list
545 * of nodes into a bit mask. The bit mask is allocated by
546 * numa_allocate_nodemask(), so it should be freed by
547 * numa_free_nodemask().
549 verify_bitmask = numa_parse_nodestring(input);
550 if (verify_bitmask == NULL) {
551 log_err("fio: numa_parse_nodestring failed\n");
552 td_verror(td, 1, "str_numa_cpunodes_cb");
555 numa_free_nodemask(verify_bitmask);
557 td->o.numa_cpunodes = strdup(input);
561 static int str_numa_mpol_cb(void *data, char *input)
563 struct thread_data *td = data;
564 const char * const policy_types[] =
565 { "default", "prefer", "bind", "interleave", "local", NULL };
568 struct bitmask *verify_bitmask;
573 nodelist = strchr(input, ':');
575 /* NUL-terminate mode */
579 for (i = 0; i <= MPOL_LOCAL; i++) {
580 if (!strcmp(input, policy_types[i])) {
581 td->o.numa_mem_mode = i;
585 if (i > MPOL_LOCAL) {
586 log_err("fio: memory policy should be: default, prefer, bind, interleave, local\n");
590 switch (td->o.numa_mem_mode) {
593 * Insist on a nodelist of one node only
596 char *rest = nodelist;
597 while (isdigit(*rest))
600 log_err("fio: one node only for \'prefer\'\n");
604 log_err("fio: one node is needed for \'prefer\'\n");
608 case MPOL_INTERLEAVE:
610 * Default to online nodes with memory if no nodelist
613 nodelist = strdup("all");
618 * Don't allow a nodelist
621 log_err("fio: NO nodelist for \'local\'\n");
627 * Insist on a nodelist
630 log_err("fio: a nodelist is needed for \'bind\'\n");
637 /* numa_parse_nodestring() parses a character string list
638 * of nodes into a bit mask. The bit mask is allocated by
639 * numa_allocate_nodemask(), so it should be freed by
640 * numa_free_nodemask().
642 switch (td->o.numa_mem_mode) {
644 td->o.numa_mem_prefer_node = atoi(nodelist);
646 case MPOL_INTERLEAVE:
648 verify_bitmask = numa_parse_nodestring(nodelist);
649 if (verify_bitmask == NULL) {
650 log_err("fio: numa_parse_nodestring failed\n");
651 td_verror(td, 1, "str_numa_memnodes_cb");
654 td->o.numa_memnodes = strdup(nodelist);
655 numa_free_nodemask(verify_bitmask);
670 static int str_fst_cb(void *data, const char *str)
672 struct thread_data *td = data;
673 char *nr = get_opt_postfix(str);
675 td->file_service_nr = 1;
677 td->file_service_nr = atoi(nr);
684 #ifdef CONFIG_SYNC_FILE_RANGE
685 static int str_sfr_cb(void *data, const char *str)
687 struct thread_data *td = data;
688 char *nr = get_opt_postfix(str);
690 td->sync_file_range_nr = 1;
692 td->sync_file_range_nr = atoi(nr);
700 static int str_random_distribution_cb(void *data, const char *str)
702 struct thread_data *td = data;
709 if (td->o.random_distribution == FIO_RAND_DIST_ZIPF)
711 else if (td->o.random_distribution == FIO_RAND_DIST_PARETO)
712 val = FIO_DEF_PARETO;
713 else if (td->o.random_distribution == FIO_RAND_DIST_GAUSS)
718 nr = get_opt_postfix(str);
719 if (nr && !str_to_float(nr, &val, 0)) {
720 log_err("fio: random postfix parsing failed\n");
727 if (td->o.random_distribution == FIO_RAND_DIST_ZIPF) {
729 log_err("fio: zipf theta must different than 1.0\n");
732 td->o.zipf_theta.u.f = val;
733 } else if (td->o.random_distribution == FIO_RAND_DIST_PARETO) {
734 if (val <= 0.00 || val >= 1.00) {
735 log_err("fio: pareto input out of range (0 < input < 1.0)\n");
738 td->o.pareto_h.u.f = val;
740 if (val <= 0.00 || val >= 100.0) {
741 log_err("fio: normal deviation out of range (0 < input < 100.0)\n");
744 td->o.gauss_dev.u.f = val;
751 * Return next name in the string. Files are separated with ':'. If the ':'
752 * is escaped with a '\', then that ':' is part of the filename and does not
753 * indicate a new file.
755 static char *get_next_name(char **ptr)
760 if (!str || !strlen(str))
766 * No colon, we are done
768 p = strchr(str, ':');
775 * We got a colon, but it's the first character. Skip and
783 if (*(p - 1) != '\\') {
789 memmove(p - 1, p, strlen(p) + 1);
797 static int get_max_name_idx(char *input)
799 unsigned int cur_idx;
802 p = str = strdup(input);
803 for (cur_idx = 0; ; cur_idx++)
804 if (get_next_name(&str) == NULL)
812 * Returns the directory at the index, indexes > entires will be
813 * assigned via modulo division of the index
815 int set_name_idx(char *target, size_t tlen, char *input, int index)
817 unsigned int cur_idx;
819 char *fname, *str, *p;
821 p = str = strdup(input);
823 index %= get_max_name_idx(input);
824 for (cur_idx = 0; cur_idx <= index; cur_idx++)
825 fname = get_next_name(&str);
827 if (client_sockaddr_str[0]) {
828 len = snprintf(target, tlen, "%s/%s.", fname,
829 client_sockaddr_str);
831 len = snprintf(target, tlen, "%s/", fname);
833 target[tlen - 1] = '\0';
839 static int str_filename_cb(void *data, const char *input)
841 struct thread_data *td = data;
842 char *fname, *str, *p;
844 p = str = strdup(input);
846 strip_blank_front(&str);
847 strip_blank_end(str);
849 if (!td->files_index)
852 while ((fname = get_next_name(&str)) != NULL) {
855 add_file(td, fname, 0, 1);
862 static int str_directory_cb(void *data, const char fio_unused *unused)
864 struct thread_data *td = data;
866 char *dirname, *str, *p;
872 p = str = strdup(td->o.directory);
873 while ((dirname = get_next_name(&str)) != NULL) {
874 if (lstat(dirname, &sb) < 0) {
877 log_err("fio: %s is not a directory\n", dirname);
878 td_verror(td, ret, "lstat");
881 if (!S_ISDIR(sb.st_mode)) {
882 log_err("fio: %s is not a directory\n", dirname);
893 static int str_opendir_cb(void *data, const char fio_unused *str)
895 struct thread_data *td = data;
900 if (!td->files_index)
903 return add_dir_files(td, td->o.opendir);
906 static int str_buffer_pattern_cb(void *data, const char *input)
908 struct thread_data *td = data;
911 /* FIXME: for now buffer pattern does not support formats */
912 ret = parse_and_fill_pattern(input, strlen(input), td->o.buffer_pattern,
913 MAX_PATTERN_SIZE, NULL, 0, NULL, NULL);
918 td->o.buffer_pattern_bytes = ret;
919 if (!td->o.compress_percentage)
920 td->o.refill_buffers = 0;
921 td->o.scramble_buffers = 0;
922 td->o.zero_buffers = 0;
927 static int str_buffer_compress_cb(void *data, unsigned long long *il)
929 struct thread_data *td = data;
931 td->flags |= TD_F_COMPRESS;
932 td->o.compress_percentage = *il;
936 static int str_dedupe_cb(void *data, unsigned long long *il)
938 struct thread_data *td = data;
940 td->flags |= TD_F_COMPRESS;
941 td->o.dedupe_percentage = *il;
942 td->o.refill_buffers = 1;
946 static int str_verify_pattern_cb(void *data, const char *input)
948 struct thread_data *td = data;
951 td->o.verify_fmt_sz = ARRAY_SIZE(td->o.verify_fmt);
952 ret = parse_and_fill_pattern(input, strlen(input), td->o.verify_pattern,
953 MAX_PATTERN_SIZE, fmt_desc, sizeof(fmt_desc),
954 td->o.verify_fmt, &td->o.verify_fmt_sz);
959 td->o.verify_pattern_bytes = ret;
961 * VERIFY_* could already be set
963 if (!fio_option_is_set(&td->o, verify))
964 td->o.verify = VERIFY_PATTERN;
969 static int str_gtod_reduce_cb(void *data, int *il)
971 struct thread_data *td = data;
974 td->o.disable_lat = !!val;
975 td->o.disable_clat = !!val;
976 td->o.disable_slat = !!val;
977 td->o.disable_bw = !!val;
978 td->o.clat_percentiles = !val;
980 td->tv_cache_mask = 63;
985 static int str_size_cb(void *data, unsigned long long *__val)
987 struct thread_data *td = data;
988 unsigned long long v = *__val;
990 if (parse_is_percent(v)) {
992 td->o.size_percent = -1ULL - v;
999 static int rw_verify(struct fio_option *o, void *data)
1001 struct thread_data *td = data;
1003 if (read_only && td_write(td)) {
1004 log_err("fio: job <%s> has write bit set, but fio is in"
1005 " read-only mode\n", td->o.name);
1012 static int gtod_cpu_verify(struct fio_option *o, void *data)
1014 #ifndef FIO_HAVE_CPU_AFFINITY
1015 struct thread_data *td = data;
1017 if (td->o.gtod_cpu) {
1018 log_err("fio: platform must support CPU affinity for"
1019 "gettimeofday() offloading\n");
1030 static struct opt_group fio_opt_groups[] = {
1033 .mask = FIO_OPT_C_GENERAL,
1037 .mask = FIO_OPT_C_IO,
1041 .mask = FIO_OPT_C_FILE,
1044 .name = "Statistics",
1045 .mask = FIO_OPT_C_STAT,
1049 .mask = FIO_OPT_C_LOG,
1053 .mask = FIO_OPT_C_PROFILE,
1060 static struct opt_group *__opt_group_from_mask(struct opt_group *ogs, unsigned int *mask,
1061 unsigned int inv_mask)
1063 struct opt_group *og;
1066 if (*mask == inv_mask || !*mask)
1069 for (i = 0; ogs[i].name; i++) {
1072 if (*mask & og->mask) {
1073 *mask &= ~(og->mask);
1081 struct opt_group *opt_group_from_mask(unsigned int *mask)
1083 return __opt_group_from_mask(fio_opt_groups, mask, FIO_OPT_C_INVALID);
1086 static struct opt_group fio_opt_cat_groups[] = {
1088 .name = "Latency profiling",
1089 .mask = FIO_OPT_G_LATPROF,
1093 .mask = FIO_OPT_G_RATE,
1097 .mask = FIO_OPT_G_ZONE,
1100 .name = "Read/write mix",
1101 .mask = FIO_OPT_G_RWMIX,
1105 .mask = FIO_OPT_G_VERIFY,
1109 .mask = FIO_OPT_G_TRIM,
1112 .name = "I/O Logging",
1113 .mask = FIO_OPT_G_IOLOG,
1116 .name = "I/O Depth",
1117 .mask = FIO_OPT_G_IO_DEPTH,
1121 .mask = FIO_OPT_G_IO_FLOW,
1124 .name = "Description",
1125 .mask = FIO_OPT_G_DESC,
1129 .mask = FIO_OPT_G_FILENAME,
1132 .name = "General I/O",
1133 .mask = FIO_OPT_G_IO_BASIC,
1137 .mask = FIO_OPT_G_CGROUP,
1141 .mask = FIO_OPT_G_RUNTIME,
1145 .mask = FIO_OPT_G_PROCESS,
1148 .name = "Job credentials / priority",
1149 .mask = FIO_OPT_G_CRED,
1152 .name = "Clock settings",
1153 .mask = FIO_OPT_G_CLOCK,
1157 .mask = FIO_OPT_G_IO_TYPE,
1160 .name = "I/O Thinktime",
1161 .mask = FIO_OPT_G_THINKTIME,
1164 .name = "Randomizations",
1165 .mask = FIO_OPT_G_RANDOM,
1168 .name = "I/O buffers",
1169 .mask = FIO_OPT_G_IO_BUF,
1172 .name = "Tiobench profile",
1173 .mask = FIO_OPT_G_TIOBENCH,
1177 .mask = FIO_OPT_G_MTD,
1185 struct opt_group *opt_group_cat_from_mask(unsigned int *mask)
1187 return __opt_group_from_mask(fio_opt_cat_groups, mask, FIO_OPT_G_INVALID);
1191 * Map of job/command line options
1193 struct fio_option fio_options[FIO_MAX_OPTS] = {
1195 .name = "description",
1196 .lname = "Description of job",
1197 .type = FIO_OPT_STR_STORE,
1198 .off1 = td_var_offset(description),
1199 .help = "Text job description",
1200 .category = FIO_OPT_C_GENERAL,
1201 .group = FIO_OPT_G_DESC,
1205 .lname = "Job name",
1206 .type = FIO_OPT_STR_STORE,
1207 .off1 = td_var_offset(name),
1208 .help = "Name of this job",
1209 .category = FIO_OPT_C_GENERAL,
1210 .group = FIO_OPT_G_DESC,
1214 .lname = "Filename(s)",
1215 .type = FIO_OPT_STR_STORE,
1216 .off1 = td_var_offset(filename),
1217 .cb = str_filename_cb,
1218 .prio = -1, /* must come after "directory" */
1219 .help = "File(s) to use for the workload",
1220 .category = FIO_OPT_C_FILE,
1221 .group = FIO_OPT_G_FILENAME,
1224 .name = "directory",
1225 .lname = "Directory",
1226 .type = FIO_OPT_STR_STORE,
1227 .off1 = td_var_offset(directory),
1228 .cb = str_directory_cb,
1229 .help = "Directory to store files in",
1230 .category = FIO_OPT_C_FILE,
1231 .group = FIO_OPT_G_FILENAME,
1234 .name = "filename_format",
1235 .type = FIO_OPT_STR_STORE,
1236 .off1 = td_var_offset(filename_format),
1237 .prio = -1, /* must come after "directory" */
1238 .help = "Override default $jobname.$jobnum.$filenum naming",
1239 .def = "$jobname.$jobnum.$filenum",
1240 .category = FIO_OPT_C_FILE,
1241 .group = FIO_OPT_G_FILENAME,
1245 .lname = "Lockfile",
1246 .type = FIO_OPT_STR,
1247 .off1 = td_var_offset(file_lock_mode),
1248 .help = "Lock file when doing IO to it",
1250 .parent = "filename",
1253 .category = FIO_OPT_C_FILE,
1254 .group = FIO_OPT_G_FILENAME,
1257 .oval = FILE_LOCK_NONE,
1258 .help = "No file locking",
1260 { .ival = "exclusive",
1261 .oval = FILE_LOCK_EXCLUSIVE,
1262 .help = "Exclusive file lock",
1265 .ival = "readwrite",
1266 .oval = FILE_LOCK_READWRITE,
1267 .help = "Read vs write lock",
1273 .lname = "Open directory",
1274 .type = FIO_OPT_STR_STORE,
1275 .off1 = td_var_offset(opendir),
1276 .cb = str_opendir_cb,
1277 .help = "Recursively add files from this directory and down",
1278 .category = FIO_OPT_C_FILE,
1279 .group = FIO_OPT_G_FILENAME,
1283 .lname = "Read/write",
1284 .alias = "readwrite",
1285 .type = FIO_OPT_STR,
1287 .off1 = td_var_offset(td_ddir),
1288 .help = "IO direction",
1290 .verify = rw_verify,
1291 .category = FIO_OPT_C_IO,
1292 .group = FIO_OPT_G_IO_BASIC,
1295 .oval = TD_DDIR_READ,
1296 .help = "Sequential read",
1299 .oval = TD_DDIR_WRITE,
1300 .help = "Sequential write",
1303 .oval = TD_DDIR_TRIM,
1304 .help = "Sequential trim",
1306 { .ival = "randread",
1307 .oval = TD_DDIR_RANDREAD,
1308 .help = "Random read",
1310 { .ival = "randwrite",
1311 .oval = TD_DDIR_RANDWRITE,
1312 .help = "Random write",
1314 { .ival = "randtrim",
1315 .oval = TD_DDIR_RANDTRIM,
1316 .help = "Random trim",
1320 .help = "Sequential read and write mix",
1322 { .ival = "readwrite",
1324 .help = "Sequential read and write mix",
1327 .oval = TD_DDIR_RANDRW,
1328 .help = "Random read and write mix"
1330 { .ival = "trimwrite",
1331 .oval = TD_DDIR_TRIMWRITE,
1332 .help = "Trim and write mix, trims preceding writes"
1337 .name = "rw_sequencer",
1338 .lname = "RW Sequencer",
1339 .type = FIO_OPT_STR,
1340 .off1 = td_var_offset(rw_seq),
1341 .help = "IO offset generator modifier",
1342 .def = "sequential",
1343 .category = FIO_OPT_C_IO,
1344 .group = FIO_OPT_G_IO_BASIC,
1346 { .ival = "sequential",
1348 .help = "Generate sequential offsets",
1350 { .ival = "identical",
1351 .oval = RW_SEQ_IDENT,
1352 .help = "Generate identical offsets",
1359 .lname = "IO Engine",
1360 .type = FIO_OPT_STR_STORE,
1361 .off1 = td_var_offset(ioengine),
1362 .help = "IO engine to use",
1363 .def = FIO_PREFERRED_ENGINE,
1364 .category = FIO_OPT_C_IO,
1365 .group = FIO_OPT_G_IO_BASIC,
1368 .help = "Use read/write",
1371 .help = "Use pread/pwrite",
1374 .help = "Use readv/writev",
1376 #ifdef CONFIG_PWRITEV
1378 .help = "Use preadv/pwritev",
1381 #ifdef CONFIG_LIBAIO
1383 .help = "Linux native asynchronous IO",
1386 #ifdef CONFIG_POSIXAIO
1387 { .ival = "posixaio",
1388 .help = "POSIX asynchronous IO",
1391 #ifdef CONFIG_SOLARISAIO
1392 { .ival = "solarisaio",
1393 .help = "Solaris native asynchronous IO",
1396 #ifdef CONFIG_WINDOWSAIO
1397 { .ival = "windowsaio",
1398 .help = "Windows native asynchronous IO"
1403 .help = "Rados Block Device asynchronous IO"
1407 .help = "Memory mapped IO"
1409 #ifdef CONFIG_LINUX_SPLICE
1411 .help = "splice/vmsplice based IO",
1413 { .ival = "netsplice",
1414 .help = "splice/vmsplice to/from the network",
1417 #ifdef FIO_HAVE_SGIO
1419 .help = "SCSI generic v3 IO",
1423 .help = "Testing engine (no data transfer)",
1426 .help = "Network IO",
1429 .help = "CPU cycle burner engine",
1433 .help = "GUASI IO engine",
1436 #ifdef FIO_HAVE_BINJECT
1437 { .ival = "binject",
1438 .help = "binject direct inject block engine",
1443 .help = "RDMA IO engine",
1446 #ifdef CONFIG_FUSION_AW
1447 { .ival = "fusion-aw-sync",
1448 .help = "Fusion-io atomic write engine",
1451 #ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
1452 { .ival = "e4defrag",
1453 .help = "ext4 defrag engine",
1456 #ifdef CONFIG_LINUX_FALLOCATE
1458 .help = "fallocate() file based engine",
1463 .help = "Glusterfs libgfapi(sync) based engine"
1465 { .ival = "gfapi_async",
1466 .help = "Glusterfs libgfapi(async) based engine"
1469 #ifdef CONFIG_LIBHDFS
1470 { .ival = "libhdfs",
1471 .help = "Hadoop Distributed Filesystem (HDFS) engine"
1474 { .ival = "external",
1475 .help = "Load external engine (append name)",
1481 .lname = "IO Depth",
1482 .type = FIO_OPT_INT,
1483 .off1 = td_var_offset(iodepth),
1484 .help = "Number of IO buffers to keep in flight",
1488 .category = FIO_OPT_C_IO,
1489 .group = FIO_OPT_G_IO_BASIC,
1492 .name = "iodepth_batch",
1493 .lname = "IO Depth batch",
1494 .alias = "iodepth_batch_submit",
1495 .type = FIO_OPT_INT,
1496 .off1 = td_var_offset(iodepth_batch),
1497 .help = "Number of IO buffers to submit in one go",
1498 .parent = "iodepth",
1503 .category = FIO_OPT_C_IO,
1504 .group = FIO_OPT_G_IO_BASIC,
1507 .name = "iodepth_batch_complete",
1508 .lname = "IO Depth batch complete",
1509 .type = FIO_OPT_INT,
1510 .off1 = td_var_offset(iodepth_batch_complete),
1511 .help = "Number of IO buffers to retrieve in one go",
1512 .parent = "iodepth",
1517 .category = FIO_OPT_C_IO,
1518 .group = FIO_OPT_G_IO_BASIC,
1521 .name = "iodepth_low",
1522 .lname = "IO Depth batch low",
1523 .type = FIO_OPT_INT,
1524 .off1 = td_var_offset(iodepth_low),
1525 .help = "Low water mark for queuing depth",
1526 .parent = "iodepth",
1529 .category = FIO_OPT_C_IO,
1530 .group = FIO_OPT_G_IO_BASIC,
1533 .name = "io_submit_mode",
1534 .lname = "IO submit mode",
1535 .type = FIO_OPT_STR,
1536 .off1 = td_var_offset(io_submit_mode),
1537 .help = "How IO submissions and completions are done",
1539 .category = FIO_OPT_C_IO,
1540 .group = FIO_OPT_G_IO_BASIC,
1543 .oval = IO_MODE_INLINE,
1544 .help = "Submit and complete IO inline",
1546 { .ival = "offload",
1547 .oval = IO_MODE_OFFLOAD,
1548 .help = "Offload submit and complete to threads",
1555 .type = FIO_OPT_STR_VAL,
1557 .off1 = td_var_offset(size),
1558 .help = "Total size of device or files",
1559 .interval = 1024 * 1024,
1560 .category = FIO_OPT_C_IO,
1561 .group = FIO_OPT_G_INVALID,
1565 .alias = "io_limit",
1567 .type = FIO_OPT_STR_VAL,
1568 .off1 = td_var_offset(io_limit),
1569 .interval = 1024 * 1024,
1570 .category = FIO_OPT_C_IO,
1571 .group = FIO_OPT_G_INVALID,
1574 .name = "fill_device",
1575 .lname = "Fill device",
1577 .type = FIO_OPT_BOOL,
1578 .off1 = td_var_offset(fill_device),
1579 .help = "Write until an ENOSPC error occurs",
1581 .category = FIO_OPT_C_FILE,
1582 .group = FIO_OPT_G_INVALID,
1586 .lname = "File size",
1587 .type = FIO_OPT_STR_VAL,
1588 .off1 = td_var_offset(file_size_low),
1589 .off2 = td_var_offset(file_size_high),
1591 .help = "Size of individual files",
1592 .interval = 1024 * 1024,
1593 .category = FIO_OPT_C_FILE,
1594 .group = FIO_OPT_G_INVALID,
1597 .name = "file_append",
1598 .lname = "File append",
1599 .type = FIO_OPT_BOOL,
1600 .off1 = td_var_offset(file_append),
1601 .help = "IO will start at the end of the file(s)",
1603 .category = FIO_OPT_C_FILE,
1604 .group = FIO_OPT_G_INVALID,
1608 .lname = "IO offset",
1609 .alias = "fileoffset",
1610 .type = FIO_OPT_STR_VAL,
1611 .off1 = td_var_offset(start_offset),
1612 .help = "Start IO from this offset",
1614 .interval = 1024 * 1024,
1615 .category = FIO_OPT_C_IO,
1616 .group = FIO_OPT_G_INVALID,
1619 .name = "offset_increment",
1620 .lname = "IO offset increment",
1621 .type = FIO_OPT_STR_VAL,
1622 .off1 = td_var_offset(offset_increment),
1623 .help = "What is the increment from one offset to the next",
1627 .interval = 1024 * 1024,
1628 .category = FIO_OPT_C_IO,
1629 .group = FIO_OPT_G_INVALID,
1632 .name = "number_ios",
1633 .lname = "Number of IOs to perform",
1634 .type = FIO_OPT_STR_VAL,
1635 .off1 = td_var_offset(number_ios),
1636 .help = "Force job completion after this number of IOs",
1638 .category = FIO_OPT_C_IO,
1639 .group = FIO_OPT_G_INVALID,
1643 .lname = "Block size",
1644 .alias = "blocksize",
1645 .type = FIO_OPT_INT,
1646 .off1 = td_var_offset(bs[DDIR_READ]),
1647 .off2 = td_var_offset(bs[DDIR_WRITE]),
1648 .off3 = td_var_offset(bs[DDIR_TRIM]),
1650 .help = "Block size unit",
1655 .category = FIO_OPT_C_IO,
1656 .group = FIO_OPT_G_INVALID,
1660 .lname = "Block size align",
1661 .alias = "blockalign",
1662 .type = FIO_OPT_INT,
1663 .off1 = td_var_offset(ba[DDIR_READ]),
1664 .off2 = td_var_offset(ba[DDIR_WRITE]),
1665 .off3 = td_var_offset(ba[DDIR_TRIM]),
1667 .help = "IO block offset alignment",
1671 .category = FIO_OPT_C_IO,
1672 .group = FIO_OPT_G_INVALID,
1676 .lname = "Block size range",
1677 .alias = "blocksize_range",
1678 .type = FIO_OPT_RANGE,
1679 .off1 = td_var_offset(min_bs[DDIR_READ]),
1680 .off2 = td_var_offset(max_bs[DDIR_READ]),
1681 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
1682 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
1683 .off5 = td_var_offset(min_bs[DDIR_TRIM]),
1684 .off6 = td_var_offset(max_bs[DDIR_TRIM]),
1686 .help = "Set block size range (in more detail than bs)",
1690 .category = FIO_OPT_C_IO,
1691 .group = FIO_OPT_G_INVALID,
1695 .lname = "Block size split",
1696 .type = FIO_OPT_STR,
1697 .cb = str_bssplit_cb,
1698 .off1 = td_var_offset(bssplit),
1699 .help = "Set a specific mix of block sizes",
1702 .category = FIO_OPT_C_IO,
1703 .group = FIO_OPT_G_INVALID,
1706 .name = "bs_unaligned",
1707 .lname = "Block size unaligned",
1708 .alias = "blocksize_unaligned",
1709 .type = FIO_OPT_STR_SET,
1710 .off1 = td_var_offset(bs_unaligned),
1711 .help = "Don't sector align IO buffer sizes",
1714 .category = FIO_OPT_C_IO,
1715 .group = FIO_OPT_G_INVALID,
1718 .name = "bs_is_seq_rand",
1719 .lname = "Block size division is seq/random (not read/write)",
1720 .type = FIO_OPT_BOOL,
1721 .off1 = td_var_offset(bs_is_seq_rand),
1722 .help = "Consider any blocksize setting to be sequential,random",
1724 .parent = "blocksize",
1725 .category = FIO_OPT_C_IO,
1726 .group = FIO_OPT_G_INVALID,
1729 .name = "randrepeat",
1730 .lname = "Random repeatable",
1731 .type = FIO_OPT_BOOL,
1732 .off1 = td_var_offset(rand_repeatable),
1733 .help = "Use repeatable random IO pattern",
1737 .category = FIO_OPT_C_IO,
1738 .group = FIO_OPT_G_RANDOM,
1742 .lname = "The random generator seed",
1743 .type = FIO_OPT_STR_VAL,
1744 .off1 = td_var_offset(rand_seed),
1745 .help = "Set the random generator seed value",
1748 .category = FIO_OPT_C_IO,
1749 .group = FIO_OPT_G_RANDOM,
1752 .name = "use_os_rand",
1753 .lname = "Use OS random",
1754 .type = FIO_OPT_DEPRECATED,
1755 .off1 = td_var_offset(dep_use_os_rand),
1756 .category = FIO_OPT_C_IO,
1757 .group = FIO_OPT_G_RANDOM,
1760 .name = "norandommap",
1761 .lname = "No randommap",
1762 .type = FIO_OPT_STR_SET,
1763 .off1 = td_var_offset(norandommap),
1764 .help = "Accept potential duplicate random blocks",
1768 .category = FIO_OPT_C_IO,
1769 .group = FIO_OPT_G_RANDOM,
1772 .name = "softrandommap",
1773 .lname = "Soft randommap",
1774 .type = FIO_OPT_BOOL,
1775 .off1 = td_var_offset(softrandommap),
1776 .help = "Set norandommap if randommap allocation fails",
1777 .parent = "norandommap",
1780 .category = FIO_OPT_C_IO,
1781 .group = FIO_OPT_G_RANDOM,
1784 .name = "random_generator",
1785 .type = FIO_OPT_STR,
1786 .off1 = td_var_offset(random_generator),
1787 .help = "Type of random number generator to use",
1788 .def = "tausworthe",
1790 { .ival = "tausworthe",
1791 .oval = FIO_RAND_GEN_TAUSWORTHE,
1792 .help = "Strong Tausworthe generator",
1795 .oval = FIO_RAND_GEN_LFSR,
1796 .help = "Variable length LFSR",
1799 .ival = "tausworthe64",
1800 .oval = FIO_RAND_GEN_TAUSWORTHE64,
1801 .help = "64-bit Tausworthe variant",
1804 .category = FIO_OPT_C_IO,
1805 .group = FIO_OPT_G_RANDOM,
1808 .name = "random_distribution",
1809 .type = FIO_OPT_STR,
1810 .off1 = td_var_offset(random_distribution),
1811 .cb = str_random_distribution_cb,
1812 .help = "Random offset distribution generator",
1816 .oval = FIO_RAND_DIST_RANDOM,
1817 .help = "Completely random",
1820 .oval = FIO_RAND_DIST_ZIPF,
1821 .help = "Zipf distribution",
1824 .oval = FIO_RAND_DIST_PARETO,
1825 .help = "Pareto distribution",
1828 .oval = FIO_RAND_DIST_GAUSS,
1829 .help = "Normal (gaussian) distribution",
1832 .category = FIO_OPT_C_IO,
1833 .group = FIO_OPT_G_RANDOM,
1836 .name = "percentage_random",
1837 .lname = "Percentage Random",
1838 .type = FIO_OPT_INT,
1839 .off1 = td_var_offset(perc_rand[DDIR_READ]),
1840 .off2 = td_var_offset(perc_rand[DDIR_WRITE]),
1841 .off3 = td_var_offset(perc_rand[DDIR_TRIM]),
1843 .help = "Percentage of seq/random mix that should be random",
1844 .def = "100,100,100",
1846 .inverse = "percentage_sequential",
1847 .category = FIO_OPT_C_IO,
1848 .group = FIO_OPT_G_RANDOM,
1851 .name = "percentage_sequential",
1852 .lname = "Percentage Sequential",
1853 .type = FIO_OPT_DEPRECATED,
1854 .category = FIO_OPT_C_IO,
1855 .group = FIO_OPT_G_RANDOM,
1858 .name = "allrandrepeat",
1859 .type = FIO_OPT_BOOL,
1860 .off1 = td_var_offset(allrand_repeatable),
1861 .help = "Use repeatable random numbers for everything",
1863 .category = FIO_OPT_C_IO,
1864 .group = FIO_OPT_G_RANDOM,
1868 .lname = "Number of files",
1869 .alias = "nr_files",
1870 .type = FIO_OPT_INT,
1871 .off1 = td_var_offset(nr_files),
1872 .help = "Split job workload between this number of files",
1875 .category = FIO_OPT_C_FILE,
1876 .group = FIO_OPT_G_INVALID,
1879 .name = "openfiles",
1880 .lname = "Number of open files",
1881 .type = FIO_OPT_INT,
1882 .off1 = td_var_offset(open_files),
1883 .help = "Number of files to keep open at the same time",
1884 .category = FIO_OPT_C_FILE,
1885 .group = FIO_OPT_G_INVALID,
1888 .name = "file_service_type",
1889 .lname = "File service type",
1890 .type = FIO_OPT_STR,
1892 .off1 = td_var_offset(file_service_type),
1893 .help = "How to select which file to service next",
1894 .def = "roundrobin",
1895 .category = FIO_OPT_C_FILE,
1896 .group = FIO_OPT_G_INVALID,
1899 .oval = FIO_FSERVICE_RANDOM,
1900 .help = "Choose a file at random",
1902 { .ival = "roundrobin",
1903 .oval = FIO_FSERVICE_RR,
1904 .help = "Round robin select files",
1906 { .ival = "sequential",
1907 .oval = FIO_FSERVICE_SEQ,
1908 .help = "Finish one file before moving to the next",
1911 .parent = "nrfiles",
1914 #ifdef CONFIG_POSIX_FALLOCATE
1916 .name = "fallocate",
1917 .lname = "Fallocate",
1918 .type = FIO_OPT_STR,
1919 .off1 = td_var_offset(fallocate_mode),
1920 .help = "Whether pre-allocation is performed when laying out files",
1922 .category = FIO_OPT_C_FILE,
1923 .group = FIO_OPT_G_INVALID,
1926 .oval = FIO_FALLOCATE_NONE,
1927 .help = "Do not pre-allocate space",
1930 .oval = FIO_FALLOCATE_POSIX,
1931 .help = "Use posix_fallocate()",
1933 #ifdef CONFIG_LINUX_FALLOCATE
1935 .oval = FIO_FALLOCATE_KEEP_SIZE,
1936 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
1939 /* Compatibility with former boolean values */
1941 .oval = FIO_FALLOCATE_NONE,
1942 .help = "Alias for 'none'",
1945 .oval = FIO_FALLOCATE_POSIX,
1946 .help = "Alias for 'posix'",
1950 #endif /* CONFIG_POSIX_FALLOCATE */
1952 .name = "fadvise_hint",
1953 .lname = "Fadvise hint",
1954 .type = FIO_OPT_BOOL,
1955 .off1 = td_var_offset(fadvise_hint),
1956 .help = "Use fadvise() to advise the kernel on IO pattern",
1958 .category = FIO_OPT_C_FILE,
1959 .group = FIO_OPT_G_INVALID,
1961 #ifdef FIO_HAVE_STREAMID
1963 .name = "fadvise_stream",
1964 .lname = "Fadvise stream",
1965 .type = FIO_OPT_INT,
1966 .off1 = td_var_offset(fadvise_stream),
1967 .help = "Use fadvise() to set stream ID",
1968 .category = FIO_OPT_C_FILE,
1969 .group = FIO_OPT_G_INVALID,
1975 .type = FIO_OPT_INT,
1976 .off1 = td_var_offset(fsync_blocks),
1977 .help = "Issue fsync for writes every given number of blocks",
1980 .category = FIO_OPT_C_FILE,
1981 .group = FIO_OPT_G_INVALID,
1984 .name = "fdatasync",
1985 .lname = "Fdatasync",
1986 .type = FIO_OPT_INT,
1987 .off1 = td_var_offset(fdatasync_blocks),
1988 .help = "Issue fdatasync for writes every given number of blocks",
1991 .category = FIO_OPT_C_FILE,
1992 .group = FIO_OPT_G_INVALID,
1995 .name = "write_barrier",
1996 .lname = "Write barrier",
1997 .type = FIO_OPT_INT,
1998 .off1 = td_var_offset(barrier_blocks),
1999 .help = "Make every Nth write a barrier write",
2002 .category = FIO_OPT_C_IO,
2003 .group = FIO_OPT_G_INVALID,
2005 #ifdef CONFIG_SYNC_FILE_RANGE
2007 .name = "sync_file_range",
2008 .lname = "Sync file range",
2010 { .ival = "wait_before",
2011 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
2012 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
2016 .oval = SYNC_FILE_RANGE_WRITE,
2017 .help = "SYNC_FILE_RANGE_WRITE",
2021 .ival = "wait_after",
2022 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
2023 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
2027 .type = FIO_OPT_STR_MULTI,
2029 .off1 = td_var_offset(sync_file_range),
2030 .help = "Use sync_file_range()",
2031 .category = FIO_OPT_C_FILE,
2032 .group = FIO_OPT_G_INVALID,
2037 .lname = "Direct I/O",
2038 .type = FIO_OPT_BOOL,
2039 .off1 = td_var_offset(odirect),
2040 .help = "Use O_DIRECT IO (negates buffered)",
2042 .inverse = "buffered",
2043 .category = FIO_OPT_C_IO,
2044 .group = FIO_OPT_G_IO_TYPE,
2048 .lname = "Atomic I/O",
2049 .type = FIO_OPT_BOOL,
2050 .off1 = td_var_offset(oatomic),
2051 .help = "Use Atomic IO with O_DIRECT (implies O_DIRECT)",
2053 .category = FIO_OPT_C_IO,
2054 .group = FIO_OPT_G_IO_TYPE,
2058 .lname = "Buffered I/O",
2059 .type = FIO_OPT_BOOL,
2060 .off1 = td_var_offset(odirect),
2062 .help = "Use buffered IO (negates direct)",
2064 .inverse = "direct",
2065 .category = FIO_OPT_C_IO,
2066 .group = FIO_OPT_G_IO_TYPE,
2069 .name = "overwrite",
2070 .lname = "Overwrite",
2071 .type = FIO_OPT_BOOL,
2072 .off1 = td_var_offset(overwrite),
2073 .help = "When writing, set whether to overwrite current data",
2075 .category = FIO_OPT_C_FILE,
2076 .group = FIO_OPT_G_INVALID,
2081 .type = FIO_OPT_INT,
2082 .off1 = td_var_offset(loops),
2083 .help = "Number of times to run the job",
2086 .category = FIO_OPT_C_GENERAL,
2087 .group = FIO_OPT_G_RUNTIME,
2091 .lname = "Number of jobs",
2092 .type = FIO_OPT_INT,
2093 .off1 = td_var_offset(numjobs),
2094 .help = "Duplicate this job this many times",
2097 .category = FIO_OPT_C_GENERAL,
2098 .group = FIO_OPT_G_RUNTIME,
2101 .name = "startdelay",
2102 .lname = "Start delay",
2103 .type = FIO_OPT_STR_VAL_TIME,
2104 .off1 = td_var_offset(start_delay),
2105 .off2 = td_var_offset(start_delay_high),
2106 .help = "Only start job when this period has passed",
2110 .category = FIO_OPT_C_GENERAL,
2111 .group = FIO_OPT_G_RUNTIME,
2117 .type = FIO_OPT_STR_VAL_TIME,
2118 .off1 = td_var_offset(timeout),
2119 .help = "Stop workload when this amount of time has passed",
2123 .category = FIO_OPT_C_GENERAL,
2124 .group = FIO_OPT_G_RUNTIME,
2127 .name = "time_based",
2128 .lname = "Time based",
2129 .type = FIO_OPT_STR_SET,
2130 .off1 = td_var_offset(time_based),
2131 .help = "Keep running until runtime/timeout is met",
2132 .category = FIO_OPT_C_GENERAL,
2133 .group = FIO_OPT_G_RUNTIME,
2136 .name = "verify_only",
2137 .lname = "Verify only",
2138 .type = FIO_OPT_STR_SET,
2139 .off1 = td_var_offset(verify_only),
2140 .help = "Verifies previously written data is still valid",
2141 .category = FIO_OPT_C_GENERAL,
2142 .group = FIO_OPT_G_RUNTIME,
2145 .name = "ramp_time",
2146 .lname = "Ramp time",
2147 .type = FIO_OPT_STR_VAL_TIME,
2148 .off1 = td_var_offset(ramp_time),
2149 .help = "Ramp up time before measuring performance",
2152 .category = FIO_OPT_C_GENERAL,
2153 .group = FIO_OPT_G_RUNTIME,
2156 .name = "clocksource",
2157 .lname = "Clock source",
2158 .type = FIO_OPT_STR,
2159 .cb = fio_clock_source_cb,
2160 .off1 = td_var_offset(clocksource),
2161 .help = "What type of timing source to use",
2162 .category = FIO_OPT_C_GENERAL,
2163 .group = FIO_OPT_G_CLOCK,
2165 #ifdef CONFIG_GETTIMEOFDAY
2166 { .ival = "gettimeofday",
2168 .help = "Use gettimeofday(2) for timing",
2171 #ifdef CONFIG_CLOCK_GETTIME
2172 { .ival = "clock_gettime",
2173 .oval = CS_CGETTIME,
2174 .help = "Use clock_gettime(2) for timing",
2177 #ifdef ARCH_HAVE_CPU_CLOCK
2179 .oval = CS_CPUCLOCK,
2180 .help = "Use CPU private clock",
2188 .lname = "I/O Memory",
2189 .type = FIO_OPT_STR,
2191 .off1 = td_var_offset(mem_type),
2192 .help = "Backing type for IO buffers",
2194 .category = FIO_OPT_C_IO,
2195 .group = FIO_OPT_G_INVALID,
2199 .help = "Use malloc(3) for IO buffers",
2201 #ifndef CONFIG_NO_SHM
2204 .help = "Use shared memory segments for IO buffers",
2206 #ifdef FIO_HAVE_HUGETLB
2207 { .ival = "shmhuge",
2208 .oval = MEM_SHMHUGE,
2209 .help = "Like shm, but use huge pages",
2215 .help = "Use mmap(2) (file or anon) for IO buffers",
2217 #ifdef FIO_HAVE_HUGETLB
2218 { .ival = "mmaphuge",
2219 .oval = MEM_MMAPHUGE,
2220 .help = "Like mmap, but use huge pages",
2226 .name = "iomem_align",
2227 .alias = "mem_align",
2228 .lname = "I/O memory alignment",
2229 .type = FIO_OPT_INT,
2230 .off1 = td_var_offset(mem_align),
2232 .help = "IO memory buffer offset alignment",
2236 .category = FIO_OPT_C_IO,
2237 .group = FIO_OPT_G_INVALID,
2242 .type = FIO_OPT_STR,
2243 .off1 = td_var_offset(verify),
2244 .help = "Verify data written",
2246 .category = FIO_OPT_C_IO,
2247 .group = FIO_OPT_G_VERIFY,
2250 .oval = VERIFY_NONE,
2251 .help = "Don't do IO verification",
2255 .help = "Use md5 checksums for verification",
2258 .oval = VERIFY_CRC64,
2259 .help = "Use crc64 checksums for verification",
2262 .oval = VERIFY_CRC32,
2263 .help = "Use crc32 checksums for verification",
2265 { .ival = "crc32c-intel",
2266 .oval = VERIFY_CRC32C,
2267 .help = "Use crc32c checksums for verification (hw assisted, if available)",
2270 .oval = VERIFY_CRC32C,
2271 .help = "Use crc32c checksums for verification (hw assisted, if available)",
2274 .oval = VERIFY_CRC16,
2275 .help = "Use crc16 checksums for verification",
2278 .oval = VERIFY_CRC7,
2279 .help = "Use crc7 checksums for verification",
2282 .oval = VERIFY_SHA1,
2283 .help = "Use sha1 checksums for verification",
2286 .oval = VERIFY_SHA256,
2287 .help = "Use sha256 checksums for verification",
2290 .oval = VERIFY_SHA512,
2291 .help = "Use sha512 checksums for verification",
2294 .oval = VERIFY_XXHASH,
2295 .help = "Use xxhash checksums for verification",
2297 /* Meta information was included into verify_header,
2298 * 'meta' verification is implied by default. */
2300 .oval = VERIFY_HDR_ONLY,
2301 .help = "Use io information for verification. "
2302 "Now is implied by default, thus option is obsolete, "
2305 { .ival = "pattern",
2306 .oval = VERIFY_PATTERN_NO_HDR,
2307 .help = "Verify strict pattern",
2311 .oval = VERIFY_NULL,
2312 .help = "Pretend to verify",
2317 .name = "do_verify",
2318 .lname = "Perform verify step",
2319 .type = FIO_OPT_BOOL,
2320 .off1 = td_var_offset(do_verify),
2321 .help = "Run verification stage after write",
2325 .category = FIO_OPT_C_IO,
2326 .group = FIO_OPT_G_VERIFY,
2329 .name = "verifysort",
2330 .lname = "Verify sort",
2331 .type = FIO_OPT_BOOL,
2332 .off1 = td_var_offset(verifysort),
2333 .help = "Sort written verify blocks for read back",
2337 .category = FIO_OPT_C_IO,
2338 .group = FIO_OPT_G_VERIFY,
2341 .name = "verifysort_nr",
2342 .type = FIO_OPT_INT,
2343 .off1 = td_var_offset(verifysort_nr),
2344 .help = "Pre-load and sort verify blocks for a read workload",
2349 .category = FIO_OPT_C_IO,
2350 .group = FIO_OPT_G_VERIFY,
2353 .name = "verify_interval",
2354 .lname = "Verify interval",
2355 .type = FIO_OPT_INT,
2356 .off1 = td_var_offset(verify_interval),
2357 .minval = 2 * sizeof(struct verify_header),
2358 .help = "Store verify buffer header every N bytes",
2361 .interval = 2 * sizeof(struct verify_header),
2362 .category = FIO_OPT_C_IO,
2363 .group = FIO_OPT_G_VERIFY,
2366 .name = "verify_offset",
2367 .lname = "Verify offset",
2368 .type = FIO_OPT_INT,
2369 .help = "Offset verify header location by N bytes",
2370 .off1 = td_var_offset(verify_offset),
2371 .minval = sizeof(struct verify_header),
2374 .category = FIO_OPT_C_IO,
2375 .group = FIO_OPT_G_VERIFY,
2378 .name = "verify_pattern",
2379 .lname = "Verify pattern",
2380 .type = FIO_OPT_STR,
2381 .cb = str_verify_pattern_cb,
2382 .off1 = td_var_offset(verify_pattern),
2383 .help = "Fill pattern for IO buffers",
2386 .category = FIO_OPT_C_IO,
2387 .group = FIO_OPT_G_VERIFY,
2390 .name = "verify_fatal",
2391 .lname = "Verify fatal",
2392 .type = FIO_OPT_BOOL,
2393 .off1 = td_var_offset(verify_fatal),
2395 .help = "Exit on a single verify failure, don't continue",
2398 .category = FIO_OPT_C_IO,
2399 .group = FIO_OPT_G_VERIFY,
2402 .name = "verify_dump",
2403 .lname = "Verify dump",
2404 .type = FIO_OPT_BOOL,
2405 .off1 = td_var_offset(verify_dump),
2407 .help = "Dump contents of good and bad blocks on failure",
2410 .category = FIO_OPT_C_IO,
2411 .group = FIO_OPT_G_VERIFY,
2414 .name = "verify_async",
2415 .lname = "Verify asynchronously",
2416 .type = FIO_OPT_INT,
2417 .off1 = td_var_offset(verify_async),
2419 .help = "Number of async verifier threads to use",
2422 .category = FIO_OPT_C_IO,
2423 .group = FIO_OPT_G_VERIFY,
2426 .name = "verify_backlog",
2427 .lname = "Verify backlog",
2428 .type = FIO_OPT_STR_VAL,
2429 .off1 = td_var_offset(verify_backlog),
2430 .help = "Verify after this number of blocks are written",
2433 .category = FIO_OPT_C_IO,
2434 .group = FIO_OPT_G_VERIFY,
2437 .name = "verify_backlog_batch",
2438 .lname = "Verify backlog batch",
2439 .type = FIO_OPT_INT,
2440 .off1 = td_var_offset(verify_batch),
2441 .help = "Verify this number of IO blocks",
2444 .category = FIO_OPT_C_IO,
2445 .group = FIO_OPT_G_VERIFY,
2447 #ifdef FIO_HAVE_CPU_AFFINITY
2449 .name = "verify_async_cpus",
2450 .lname = "Async verify CPUs",
2451 .type = FIO_OPT_STR,
2452 .cb = str_verify_cpus_allowed_cb,
2453 .off1 = td_var_offset(verify_cpumask),
2454 .help = "Set CPUs allowed for async verify threads",
2455 .parent = "verify_async",
2457 .category = FIO_OPT_C_IO,
2458 .group = FIO_OPT_G_VERIFY,
2462 .name = "experimental_verify",
2463 .off1 = td_var_offset(experimental_verify),
2464 .type = FIO_OPT_BOOL,
2465 .help = "Enable experimental verification",
2467 .category = FIO_OPT_C_IO,
2468 .group = FIO_OPT_G_VERIFY,
2471 .name = "verify_state_load",
2472 .lname = "Load verify state",
2473 .off1 = td_var_offset(verify_state),
2474 .type = FIO_OPT_BOOL,
2475 .help = "Load verify termination state",
2477 .category = FIO_OPT_C_IO,
2478 .group = FIO_OPT_G_VERIFY,
2481 .name = "verify_state_save",
2482 .lname = "Save verify state",
2483 .off1 = td_var_offset(verify_state_save),
2484 .type = FIO_OPT_BOOL,
2486 .help = "Save verify state on termination",
2488 .category = FIO_OPT_C_IO,
2489 .group = FIO_OPT_G_VERIFY,
2491 #ifdef FIO_HAVE_TRIM
2493 .name = "trim_percentage",
2494 .lname = "Trim percentage",
2495 .type = FIO_OPT_INT,
2496 .off1 = td_var_offset(trim_percentage),
2499 .help = "Number of verify blocks to discard/trim",
2504 .category = FIO_OPT_C_IO,
2505 .group = FIO_OPT_G_TRIM,
2508 .name = "trim_verify_zero",
2509 .lname = "Verify trim zero",
2510 .type = FIO_OPT_BOOL,
2511 .help = "Verify that trim/discarded blocks are returned as zeroes",
2512 .off1 = td_var_offset(trim_zero),
2513 .parent = "trim_percentage",
2516 .category = FIO_OPT_C_IO,
2517 .group = FIO_OPT_G_TRIM,
2520 .name = "trim_backlog",
2521 .lname = "Trim backlog",
2522 .type = FIO_OPT_STR_VAL,
2523 .off1 = td_var_offset(trim_backlog),
2524 .help = "Trim after this number of blocks are written",
2525 .parent = "trim_percentage",
2528 .category = FIO_OPT_C_IO,
2529 .group = FIO_OPT_G_TRIM,
2532 .name = "trim_backlog_batch",
2533 .lname = "Trim backlog batch",
2534 .type = FIO_OPT_INT,
2535 .off1 = td_var_offset(trim_batch),
2536 .help = "Trim this number of IO blocks",
2537 .parent = "trim_percentage",
2540 .category = FIO_OPT_C_IO,
2541 .group = FIO_OPT_G_TRIM,
2545 .name = "write_iolog",
2546 .lname = "Write I/O log",
2547 .type = FIO_OPT_STR_STORE,
2548 .off1 = td_var_offset(write_iolog_file),
2549 .help = "Store IO pattern to file",
2550 .category = FIO_OPT_C_IO,
2551 .group = FIO_OPT_G_IOLOG,
2554 .name = "read_iolog",
2555 .lname = "Read I/O log",
2556 .type = FIO_OPT_STR_STORE,
2557 .off1 = td_var_offset(read_iolog_file),
2558 .help = "Playback IO pattern from file",
2559 .category = FIO_OPT_C_IO,
2560 .group = FIO_OPT_G_IOLOG,
2563 .name = "replay_no_stall",
2564 .lname = "Don't stall on replay",
2565 .type = FIO_OPT_BOOL,
2566 .off1 = td_var_offset(no_stall),
2568 .parent = "read_iolog",
2570 .help = "Playback IO pattern file as fast as possible without stalls",
2571 .category = FIO_OPT_C_IO,
2572 .group = FIO_OPT_G_IOLOG,
2575 .name = "replay_redirect",
2576 .lname = "Redirect device for replay",
2577 .type = FIO_OPT_STR_STORE,
2578 .off1 = td_var_offset(replay_redirect),
2579 .parent = "read_iolog",
2581 .help = "Replay all I/O onto this device, regardless of trace device",
2582 .category = FIO_OPT_C_IO,
2583 .group = FIO_OPT_G_IOLOG,
2586 .name = "replay_scale",
2587 .lname = "Replace offset scale factor",
2588 .type = FIO_OPT_INT,
2589 .off1 = td_var_offset(replay_scale),
2590 .parent = "read_iolog",
2592 .help = "Align offsets to this blocksize",
2593 .category = FIO_OPT_C_IO,
2594 .group = FIO_OPT_G_IOLOG,
2597 .name = "replay_align",
2598 .lname = "Replace alignment",
2599 .type = FIO_OPT_INT,
2600 .off1 = td_var_offset(replay_align),
2601 .parent = "read_iolog",
2602 .help = "Scale offset down by this factor",
2603 .category = FIO_OPT_C_IO,
2604 .group = FIO_OPT_G_IOLOG,
2608 .name = "exec_prerun",
2609 .lname = "Pre-execute runnable",
2610 .type = FIO_OPT_STR_STORE,
2611 .off1 = td_var_offset(exec_prerun),
2612 .help = "Execute this file prior to running job",
2613 .category = FIO_OPT_C_GENERAL,
2614 .group = FIO_OPT_G_INVALID,
2617 .name = "exec_postrun",
2618 .lname = "Post-execute runnable",
2619 .type = FIO_OPT_STR_STORE,
2620 .off1 = td_var_offset(exec_postrun),
2621 .help = "Execute this file after running job",
2622 .category = FIO_OPT_C_GENERAL,
2623 .group = FIO_OPT_G_INVALID,
2625 #ifdef FIO_HAVE_IOSCHED_SWITCH
2627 .name = "ioscheduler",
2628 .lname = "I/O scheduler",
2629 .type = FIO_OPT_STR_STORE,
2630 .off1 = td_var_offset(ioscheduler),
2631 .help = "Use this IO scheduler on the backing device",
2632 .category = FIO_OPT_C_FILE,
2633 .group = FIO_OPT_G_INVALID,
2638 .lname = "Zone size",
2639 .type = FIO_OPT_STR_VAL,
2640 .off1 = td_var_offset(zone_size),
2641 .help = "Amount of data to read per zone",
2643 .interval = 1024 * 1024,
2644 .category = FIO_OPT_C_IO,
2645 .group = FIO_OPT_G_ZONE,
2648 .name = "zonerange",
2649 .lname = "Zone range",
2650 .type = FIO_OPT_STR_VAL,
2651 .off1 = td_var_offset(zone_range),
2652 .help = "Give size of an IO zone",
2654 .interval = 1024 * 1024,
2655 .category = FIO_OPT_C_IO,
2656 .group = FIO_OPT_G_ZONE,
2660 .lname = "Zone skip",
2661 .type = FIO_OPT_STR_VAL,
2662 .off1 = td_var_offset(zone_skip),
2663 .help = "Space between IO zones",
2665 .interval = 1024 * 1024,
2666 .category = FIO_OPT_C_IO,
2667 .group = FIO_OPT_G_ZONE,
2671 .lname = "Lock memory",
2672 .type = FIO_OPT_STR_VAL,
2673 .off1 = td_var_offset(lockmem),
2674 .help = "Lock down this amount of memory (per worker)",
2676 .interval = 1024 * 1024,
2677 .category = FIO_OPT_C_GENERAL,
2678 .group = FIO_OPT_G_INVALID,
2681 .name = "rwmixread",
2682 .lname = "Read/write mix read",
2683 .type = FIO_OPT_INT,
2684 .cb = str_rwmix_read_cb,
2685 .off1 = td_var_offset(rwmix[DDIR_READ]),
2687 .help = "Percentage of mixed workload that is reads",
2690 .inverse = "rwmixwrite",
2691 .category = FIO_OPT_C_IO,
2692 .group = FIO_OPT_G_RWMIX,
2695 .name = "rwmixwrite",
2696 .lname = "Read/write mix write",
2697 .type = FIO_OPT_INT,
2698 .cb = str_rwmix_write_cb,
2699 .off1 = td_var_offset(rwmix[DDIR_WRITE]),
2701 .help = "Percentage of mixed workload that is writes",
2704 .inverse = "rwmixread",
2705 .category = FIO_OPT_C_IO,
2706 .group = FIO_OPT_G_RWMIX,
2709 .name = "rwmixcycle",
2710 .lname = "Read/write mix cycle",
2711 .type = FIO_OPT_DEPRECATED,
2712 .category = FIO_OPT_C_IO,
2713 .group = FIO_OPT_G_RWMIX,
2718 .type = FIO_OPT_INT,
2719 .off1 = td_var_offset(nice),
2720 .help = "Set job CPU nice value",
2725 .category = FIO_OPT_C_GENERAL,
2726 .group = FIO_OPT_G_CRED,
2728 #ifdef FIO_HAVE_IOPRIO
2731 .lname = "I/O nice priority",
2732 .type = FIO_OPT_INT,
2733 .off1 = td_var_offset(ioprio),
2734 .help = "Set job IO priority value",
2738 .category = FIO_OPT_C_GENERAL,
2739 .group = FIO_OPT_G_CRED,
2742 .name = "prioclass",
2743 .lname = "I/O nice priority class",
2744 .type = FIO_OPT_INT,
2745 .off1 = td_var_offset(ioprio_class),
2746 .help = "Set job IO priority class",
2750 .category = FIO_OPT_C_GENERAL,
2751 .group = FIO_OPT_G_CRED,
2755 .name = "thinktime",
2756 .lname = "Thinktime",
2757 .type = FIO_OPT_INT,
2758 .off1 = td_var_offset(thinktime),
2759 .help = "Idle time between IO buffers (usec)",
2762 .category = FIO_OPT_C_IO,
2763 .group = FIO_OPT_G_THINKTIME,
2766 .name = "thinktime_spin",
2767 .lname = "Thinktime spin",
2768 .type = FIO_OPT_INT,
2769 .off1 = td_var_offset(thinktime_spin),
2770 .help = "Start think time by spinning this amount (usec)",
2773 .parent = "thinktime",
2775 .category = FIO_OPT_C_IO,
2776 .group = FIO_OPT_G_THINKTIME,
2779 .name = "thinktime_blocks",
2780 .lname = "Thinktime blocks",
2781 .type = FIO_OPT_INT,
2782 .off1 = td_var_offset(thinktime_blocks),
2783 .help = "IO buffer period between 'thinktime'",
2785 .parent = "thinktime",
2787 .category = FIO_OPT_C_IO,
2788 .group = FIO_OPT_G_THINKTIME,
2792 .lname = "I/O rate",
2793 .type = FIO_OPT_INT,
2794 .off1 = td_var_offset(rate[DDIR_READ]),
2795 .off2 = td_var_offset(rate[DDIR_WRITE]),
2796 .off3 = td_var_offset(rate[DDIR_TRIM]),
2797 .help = "Set bandwidth rate",
2798 .category = FIO_OPT_C_IO,
2799 .group = FIO_OPT_G_RATE,
2803 .lname = "I/O min rate",
2804 .type = FIO_OPT_INT,
2805 .off1 = td_var_offset(ratemin[DDIR_READ]),
2806 .off2 = td_var_offset(ratemin[DDIR_WRITE]),
2807 .off3 = td_var_offset(ratemin[DDIR_TRIM]),
2808 .help = "Job must meet this rate or it will be shutdown",
2811 .category = FIO_OPT_C_IO,
2812 .group = FIO_OPT_G_RATE,
2815 .name = "rate_iops",
2816 .lname = "I/O rate IOPS",
2817 .type = FIO_OPT_INT,
2818 .off1 = td_var_offset(rate_iops[DDIR_READ]),
2819 .off2 = td_var_offset(rate_iops[DDIR_WRITE]),
2820 .off3 = td_var_offset(rate_iops[DDIR_TRIM]),
2821 .help = "Limit IO used to this number of IO operations/sec",
2823 .category = FIO_OPT_C_IO,
2824 .group = FIO_OPT_G_RATE,
2827 .name = "rate_iops_min",
2828 .lname = "I/O min rate IOPS",
2829 .type = FIO_OPT_INT,
2830 .off1 = td_var_offset(rate_iops_min[DDIR_READ]),
2831 .off2 = td_var_offset(rate_iops_min[DDIR_WRITE]),
2832 .off3 = td_var_offset(rate_iops_min[DDIR_TRIM]),
2833 .help = "Job must meet this rate or it will be shut down",
2834 .parent = "rate_iops",
2836 .category = FIO_OPT_C_IO,
2837 .group = FIO_OPT_G_RATE,
2840 .name = "ratecycle",
2841 .lname = "I/O rate cycle",
2842 .type = FIO_OPT_INT,
2843 .off1 = td_var_offset(ratecycle),
2844 .help = "Window average for rate limits (msec)",
2848 .category = FIO_OPT_C_IO,
2849 .group = FIO_OPT_G_RATE,
2852 .name = "max_latency",
2853 .type = FIO_OPT_INT,
2854 .off1 = td_var_offset(max_latency),
2855 .help = "Maximum tolerated IO latency (usec)",
2857 .category = FIO_OPT_C_IO,
2858 .group = FIO_OPT_G_LATPROF,
2861 .name = "latency_target",
2862 .lname = "Latency Target (usec)",
2863 .type = FIO_OPT_STR_VAL_TIME,
2864 .off1 = td_var_offset(latency_target),
2865 .help = "Ramp to max queue depth supporting this latency",
2867 .category = FIO_OPT_C_IO,
2868 .group = FIO_OPT_G_LATPROF,
2871 .name = "latency_window",
2872 .lname = "Latency Window (usec)",
2873 .type = FIO_OPT_STR_VAL_TIME,
2874 .off1 = td_var_offset(latency_window),
2875 .help = "Time to sustain latency_target",
2877 .category = FIO_OPT_C_IO,
2878 .group = FIO_OPT_G_LATPROF,
2881 .name = "latency_percentile",
2882 .lname = "Latency Percentile",
2883 .type = FIO_OPT_FLOAT_LIST,
2884 .off1 = td_var_offset(latency_percentile),
2885 .help = "Percentile of IOs must be below latency_target",
2890 .category = FIO_OPT_C_IO,
2891 .group = FIO_OPT_G_LATPROF,
2894 .name = "invalidate",
2895 .lname = "Cache invalidate",
2896 .type = FIO_OPT_BOOL,
2897 .off1 = td_var_offset(invalidate_cache),
2898 .help = "Invalidate buffer/page cache prior to running job",
2900 .category = FIO_OPT_C_IO,
2901 .group = FIO_OPT_G_IO_TYPE,
2905 .lname = "Synchronous I/O",
2906 .type = FIO_OPT_BOOL,
2907 .off1 = td_var_offset(sync_io),
2908 .help = "Use O_SYNC for buffered writes",
2910 .parent = "buffered",
2912 .category = FIO_OPT_C_IO,
2913 .group = FIO_OPT_G_IO_TYPE,
2916 .name = "create_serialize",
2917 .lname = "Create serialize",
2918 .type = FIO_OPT_BOOL,
2919 .off1 = td_var_offset(create_serialize),
2920 .help = "Serialize creating of job files",
2922 .category = FIO_OPT_C_FILE,
2923 .group = FIO_OPT_G_INVALID,
2926 .name = "create_fsync",
2927 .lname = "Create fsync",
2928 .type = FIO_OPT_BOOL,
2929 .off1 = td_var_offset(create_fsync),
2930 .help = "fsync file after creation",
2932 .category = FIO_OPT_C_FILE,
2933 .group = FIO_OPT_G_INVALID,
2936 .name = "create_on_open",
2937 .lname = "Create on open",
2938 .type = FIO_OPT_BOOL,
2939 .off1 = td_var_offset(create_on_open),
2940 .help = "Create files when they are opened for IO",
2942 .category = FIO_OPT_C_FILE,
2943 .group = FIO_OPT_G_INVALID,
2946 .name = "create_only",
2947 .type = FIO_OPT_BOOL,
2948 .off1 = td_var_offset(create_only),
2949 .help = "Only perform file creation phase",
2950 .category = FIO_OPT_C_FILE,
2954 .name = "allow_file_create",
2955 .lname = "Allow file create",
2956 .type = FIO_OPT_BOOL,
2957 .off1 = td_var_offset(allow_create),
2958 .help = "Permit fio to create files, if they don't exist",
2960 .category = FIO_OPT_C_FILE,
2961 .group = FIO_OPT_G_FILENAME,
2964 .name = "allow_mounted_write",
2965 .lname = "Allow mounted write",
2966 .type = FIO_OPT_BOOL,
2967 .off1 = td_var_offset(allow_mounted_write),
2968 .help = "Allow writes to a mounted partition",
2970 .category = FIO_OPT_C_FILE,
2971 .group = FIO_OPT_G_FILENAME,
2975 .lname = "Pre-read files",
2976 .type = FIO_OPT_BOOL,
2977 .off1 = td_var_offset(pre_read),
2978 .help = "Pre-read files before starting official testing",
2980 .category = FIO_OPT_C_FILE,
2981 .group = FIO_OPT_G_INVALID,
2983 #ifdef FIO_HAVE_CPU_AFFINITY
2986 .lname = "CPU mask",
2987 .type = FIO_OPT_INT,
2988 .cb = str_cpumask_cb,
2989 .off1 = td_var_offset(cpumask),
2990 .help = "CPU affinity mask",
2991 .category = FIO_OPT_C_GENERAL,
2992 .group = FIO_OPT_G_CRED,
2995 .name = "cpus_allowed",
2996 .lname = "CPUs allowed",
2997 .type = FIO_OPT_STR,
2998 .cb = str_cpus_allowed_cb,
2999 .off1 = td_var_offset(cpumask),
3000 .help = "Set CPUs allowed",
3001 .category = FIO_OPT_C_GENERAL,
3002 .group = FIO_OPT_G_CRED,
3005 .name = "cpus_allowed_policy",
3006 .lname = "CPUs allowed distribution policy",
3007 .type = FIO_OPT_STR,
3008 .off1 = td_var_offset(cpus_allowed_policy),
3009 .help = "Distribution policy for cpus_allowed",
3010 .parent = "cpus_allowed",
3014 .oval = FIO_CPUS_SHARED,
3015 .help = "Mask shared between threads",
3018 .oval = FIO_CPUS_SPLIT,
3019 .help = "Mask split between threads",
3022 .category = FIO_OPT_C_GENERAL,
3023 .group = FIO_OPT_G_CRED,
3026 #ifdef CONFIG_LIBNUMA
3028 .name = "numa_cpu_nodes",
3029 .type = FIO_OPT_STR,
3030 .cb = str_numa_cpunodes_cb,
3031 .off1 = td_var_offset(numa_cpunodes),
3032 .help = "NUMA CPU nodes bind",
3033 .category = FIO_OPT_C_GENERAL,
3034 .group = FIO_OPT_G_INVALID,
3037 .name = "numa_mem_policy",
3038 .type = FIO_OPT_STR,
3039 .cb = str_numa_mpol_cb,
3040 .off1 = td_var_offset(numa_memnodes),
3041 .help = "NUMA memory policy setup",
3042 .category = FIO_OPT_C_GENERAL,
3043 .group = FIO_OPT_G_INVALID,
3047 .name = "end_fsync",
3048 .lname = "End fsync",
3049 .type = FIO_OPT_BOOL,
3050 .off1 = td_var_offset(end_fsync),
3051 .help = "Include fsync at the end of job",
3053 .category = FIO_OPT_C_FILE,
3054 .group = FIO_OPT_G_INVALID,
3057 .name = "fsync_on_close",
3058 .lname = "Fsync on close",
3059 .type = FIO_OPT_BOOL,
3060 .off1 = td_var_offset(fsync_on_close),
3061 .help = "fsync files on close",
3063 .category = FIO_OPT_C_FILE,
3064 .group = FIO_OPT_G_INVALID,
3068 .lname = "Unlink file",
3069 .type = FIO_OPT_BOOL,
3070 .off1 = td_var_offset(unlink),
3071 .help = "Unlink created files after job has completed",
3073 .category = FIO_OPT_C_FILE,
3074 .group = FIO_OPT_G_INVALID,
3078 .lname = "Exit-all on terminate",
3079 .type = FIO_OPT_STR_SET,
3080 .cb = str_exitall_cb,
3081 .help = "Terminate all jobs when one exits",
3082 .category = FIO_OPT_C_GENERAL,
3083 .group = FIO_OPT_G_PROCESS,
3086 .name = "stonewall",
3087 .lname = "Wait for previous",
3088 .alias = "wait_for_previous",
3089 .type = FIO_OPT_STR_SET,
3090 .off1 = td_var_offset(stonewall),
3091 .help = "Insert a hard barrier between this job and previous",
3092 .category = FIO_OPT_C_GENERAL,
3093 .group = FIO_OPT_G_PROCESS,
3096 .name = "new_group",
3097 .lname = "New group",
3098 .type = FIO_OPT_STR_SET,
3099 .off1 = td_var_offset(new_group),
3100 .help = "Mark the start of a new group (for reporting)",
3101 .category = FIO_OPT_C_GENERAL,
3102 .group = FIO_OPT_G_PROCESS,
3107 .type = FIO_OPT_STR_SET,
3108 .off1 = td_var_offset(use_thread),
3109 .help = "Use threads instead of processes",
3110 #ifdef CONFIG_NO_SHM
3114 .category = FIO_OPT_C_GENERAL,
3115 .group = FIO_OPT_G_PROCESS,
3118 .name = "per_job_logs",
3119 .type = FIO_OPT_BOOL,
3120 .off1 = td_var_offset(per_job_logs),
3121 .help = "Include job number in generated log files or not",
3123 .category = FIO_OPT_C_LOG,
3124 .group = FIO_OPT_G_INVALID,
3127 .name = "write_bw_log",
3128 .lname = "Write bandwidth log",
3129 .type = FIO_OPT_STR_STORE,
3130 .off1 = td_var_offset(bw_log_file),
3131 .help = "Write log of bandwidth during run",
3132 .category = FIO_OPT_C_LOG,
3133 .group = FIO_OPT_G_INVALID,
3136 .name = "write_lat_log",
3137 .lname = "Write latency log",
3138 .type = FIO_OPT_STR_STORE,
3139 .off1 = td_var_offset(lat_log_file),
3140 .help = "Write log of latency during run",
3141 .category = FIO_OPT_C_LOG,
3142 .group = FIO_OPT_G_INVALID,
3145 .name = "write_iops_log",
3146 .lname = "Write IOPS log",
3147 .type = FIO_OPT_STR_STORE,
3148 .off1 = td_var_offset(iops_log_file),
3149 .help = "Write log of IOPS during run",
3150 .category = FIO_OPT_C_LOG,
3151 .group = FIO_OPT_G_INVALID,
3154 .name = "log_avg_msec",
3155 .lname = "Log averaging (msec)",
3156 .type = FIO_OPT_INT,
3157 .off1 = td_var_offset(log_avg_msec),
3158 .help = "Average bw/iops/lat logs over this period of time",
3160 .category = FIO_OPT_C_LOG,
3161 .group = FIO_OPT_G_INVALID,
3164 .name = "log_offset",
3165 .lname = "Log offset of IO",
3166 .type = FIO_OPT_BOOL,
3167 .off1 = td_var_offset(log_offset),
3168 .help = "Include offset of IO for each log entry",
3170 .category = FIO_OPT_C_LOG,
3171 .group = FIO_OPT_G_INVALID,
3175 .name = "log_compression",
3176 .lname = "Log compression",
3177 .type = FIO_OPT_INT,
3178 .off1 = td_var_offset(log_gz),
3179 .help = "Log in compressed chunks of this size",
3181 .maxval = 512 * 1024 * 1024ULL,
3182 .category = FIO_OPT_C_LOG,
3183 .group = FIO_OPT_G_INVALID,
3186 .name = "log_store_compressed",
3187 .lname = "Log store compressed",
3188 .type = FIO_OPT_BOOL,
3189 .off1 = td_var_offset(log_gz_store),
3190 .help = "Store logs in a compressed format",
3191 .category = FIO_OPT_C_LOG,
3192 .group = FIO_OPT_G_INVALID,
3196 .name = "block_error_percentiles",
3197 .lname = "Block error percentiles",
3198 .type = FIO_OPT_BOOL,
3199 .off1 = td_var_offset(block_error_hist),
3200 .help = "Record trim block errors and make a histogram",
3202 .category = FIO_OPT_C_LOG,
3203 .group = FIO_OPT_G_INVALID,
3206 .name = "bwavgtime",
3207 .lname = "Bandwidth average time",
3208 .type = FIO_OPT_INT,
3209 .off1 = td_var_offset(bw_avg_time),
3210 .help = "Time window over which to calculate bandwidth"
3213 .parent = "write_bw_log",
3216 .category = FIO_OPT_C_LOG,
3217 .group = FIO_OPT_G_INVALID,
3220 .name = "iopsavgtime",
3221 .lname = "IOPS average time",
3222 .type = FIO_OPT_INT,
3223 .off1 = td_var_offset(iops_avg_time),
3224 .help = "Time window over which to calculate IOPS (msec)",
3226 .parent = "write_iops_log",
3229 .category = FIO_OPT_C_LOG,
3230 .group = FIO_OPT_G_INVALID,
3233 .name = "group_reporting",
3234 .lname = "Group reporting",
3235 .type = FIO_OPT_STR_SET,
3236 .off1 = td_var_offset(group_reporting),
3237 .help = "Do reporting on a per-group basis",
3238 .category = FIO_OPT_C_STAT,
3239 .group = FIO_OPT_G_INVALID,
3242 .name = "zero_buffers",
3243 .lname = "Zero I/O buffers",
3244 .type = FIO_OPT_STR_SET,
3245 .off1 = td_var_offset(zero_buffers),
3246 .help = "Init IO buffers to all zeroes",
3247 .category = FIO_OPT_C_IO,
3248 .group = FIO_OPT_G_IO_BUF,
3251 .name = "refill_buffers",
3252 .lname = "Refill I/O buffers",
3253 .type = FIO_OPT_STR_SET,
3254 .off1 = td_var_offset(refill_buffers),
3255 .help = "Refill IO buffers on every IO submit",
3256 .category = FIO_OPT_C_IO,
3257 .group = FIO_OPT_G_IO_BUF,
3260 .name = "scramble_buffers",
3261 .lname = "Scramble I/O buffers",
3262 .type = FIO_OPT_BOOL,
3263 .off1 = td_var_offset(scramble_buffers),
3264 .help = "Slightly scramble buffers on every IO submit",
3266 .category = FIO_OPT_C_IO,
3267 .group = FIO_OPT_G_IO_BUF,
3270 .name = "buffer_pattern",
3271 .lname = "Buffer pattern",
3272 .type = FIO_OPT_STR,
3273 .cb = str_buffer_pattern_cb,
3274 .off1 = td_var_offset(buffer_pattern),
3275 .help = "Fill pattern for IO buffers",
3276 .category = FIO_OPT_C_IO,
3277 .group = FIO_OPT_G_IO_BUF,
3280 .name = "buffer_compress_percentage",
3281 .lname = "Buffer compression percentage",
3282 .type = FIO_OPT_INT,
3283 .cb = str_buffer_compress_cb,
3284 .off1 = td_var_offset(compress_percentage),
3287 .help = "How compressible the buffer is (approximately)",
3289 .category = FIO_OPT_C_IO,
3290 .group = FIO_OPT_G_IO_BUF,
3293 .name = "buffer_compress_chunk",
3294 .lname = "Buffer compression chunk size",
3295 .type = FIO_OPT_INT,
3296 .off1 = td_var_offset(compress_chunk),
3297 .parent = "buffer_compress_percentage",
3299 .help = "Size of compressible region in buffer",
3301 .category = FIO_OPT_C_IO,
3302 .group = FIO_OPT_G_IO_BUF,
3305 .name = "dedupe_percentage",
3306 .lname = "Dedupe percentage",
3307 .type = FIO_OPT_INT,
3308 .cb = str_dedupe_cb,
3309 .off1 = td_var_offset(dedupe_percentage),
3312 .help = "Percentage of buffers that are dedupable",
3314 .category = FIO_OPT_C_IO,
3315 .group = FIO_OPT_G_IO_BUF,
3318 .name = "clat_percentiles",
3319 .lname = "Completion latency percentiles",
3320 .type = FIO_OPT_BOOL,
3321 .off1 = td_var_offset(clat_percentiles),
3322 .help = "Enable the reporting of completion latency percentiles",
3324 .category = FIO_OPT_C_STAT,
3325 .group = FIO_OPT_G_INVALID,
3328 .name = "percentile_list",
3329 .lname = "Percentile list",
3330 .type = FIO_OPT_FLOAT_LIST,
3331 .off1 = td_var_offset(percentile_list),
3332 .off2 = td_var_offset(percentile_precision),
3333 .help = "Specify a custom list of percentiles to report for "
3334 "completion latency and block errors",
3335 .def = "1:5:10:20:30:40:50:60:70:80:90:95:99:99.5:99.9:99.95:99.99",
3336 .maxlen = FIO_IO_U_LIST_MAX_LEN,
3339 .category = FIO_OPT_C_STAT,
3340 .group = FIO_OPT_G_INVALID,
3343 #ifdef FIO_HAVE_DISK_UTIL
3345 .name = "disk_util",
3346 .lname = "Disk utilization",
3347 .type = FIO_OPT_BOOL,
3348 .off1 = td_var_offset(do_disk_util),
3349 .help = "Log disk utilization statistics",
3351 .category = FIO_OPT_C_STAT,
3352 .group = FIO_OPT_G_INVALID,
3356 .name = "gtod_reduce",
3357 .lname = "Reduce gettimeofday() calls",
3358 .type = FIO_OPT_BOOL,
3359 .help = "Greatly reduce number of gettimeofday() calls",
3360 .cb = str_gtod_reduce_cb,
3363 .category = FIO_OPT_C_STAT,
3364 .group = FIO_OPT_G_INVALID,
3367 .name = "disable_lat",
3368 .lname = "Disable all latency stats",
3369 .type = FIO_OPT_BOOL,
3370 .off1 = td_var_offset(disable_lat),
3371 .help = "Disable latency numbers",
3372 .parent = "gtod_reduce",
3375 .category = FIO_OPT_C_STAT,
3376 .group = FIO_OPT_G_INVALID,
3379 .name = "disable_clat",
3380 .lname = "Disable completion latency stats",
3381 .type = FIO_OPT_BOOL,
3382 .off1 = td_var_offset(disable_clat),
3383 .help = "Disable completion latency numbers",
3384 .parent = "gtod_reduce",
3387 .category = FIO_OPT_C_STAT,
3388 .group = FIO_OPT_G_INVALID,
3391 .name = "disable_slat",
3392 .lname = "Disable submission latency stats",
3393 .type = FIO_OPT_BOOL,
3394 .off1 = td_var_offset(disable_slat),
3395 .help = "Disable submission latency numbers",
3396 .parent = "gtod_reduce",
3399 .category = FIO_OPT_C_STAT,
3400 .group = FIO_OPT_G_INVALID,
3403 .name = "disable_bw_measurement",
3404 .lname = "Disable bandwidth stats",
3405 .type = FIO_OPT_BOOL,
3406 .off1 = td_var_offset(disable_bw),
3407 .help = "Disable bandwidth logging",
3408 .parent = "gtod_reduce",
3411 .category = FIO_OPT_C_STAT,
3412 .group = FIO_OPT_G_INVALID,
3416 .lname = "Dedicated gettimeofday() CPU",
3417 .type = FIO_OPT_INT,
3418 .off1 = td_var_offset(gtod_cpu),
3419 .help = "Set up dedicated gettimeofday() thread on this CPU",
3420 .verify = gtod_cpu_verify,
3421 .category = FIO_OPT_C_GENERAL,
3422 .group = FIO_OPT_G_CLOCK,
3425 .name = "unified_rw_reporting",
3426 .type = FIO_OPT_BOOL,
3427 .off1 = td_var_offset(unified_rw_rep),
3428 .help = "Unify reporting across data direction",
3430 .category = FIO_OPT_C_GENERAL,
3431 .group = FIO_OPT_G_INVALID,
3434 .name = "continue_on_error",
3435 .lname = "Continue on error",
3436 .type = FIO_OPT_STR,
3437 .off1 = td_var_offset(continue_on_error),
3438 .help = "Continue on non-fatal errors during IO",
3440 .category = FIO_OPT_C_GENERAL,
3441 .group = FIO_OPT_G_ERR,
3444 .oval = ERROR_TYPE_NONE,
3445 .help = "Exit when an error is encountered",
3448 .oval = ERROR_TYPE_READ,
3449 .help = "Continue on read errors only",
3452 .oval = ERROR_TYPE_WRITE,
3453 .help = "Continue on write errors only",
3456 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
3457 .help = "Continue on any IO errors",
3460 .oval = ERROR_TYPE_VERIFY,
3461 .help = "Continue on verify errors only",
3464 .oval = ERROR_TYPE_ANY,
3465 .help = "Continue on all io and verify errors",
3468 .oval = ERROR_TYPE_NONE,
3469 .help = "Alias for 'none'",
3472 .oval = ERROR_TYPE_ANY,
3473 .help = "Alias for 'all'",
3478 .name = "ignore_error",
3479 .type = FIO_OPT_STR,
3480 .cb = str_ignore_error_cb,
3481 .off1 = td_var_offset(ignore_error_nr),
3482 .help = "Set a specific list of errors to ignore",
3484 .category = FIO_OPT_C_GENERAL,
3485 .group = FIO_OPT_G_ERR,
3488 .name = "error_dump",
3489 .type = FIO_OPT_BOOL,
3490 .off1 = td_var_offset(error_dump),
3492 .help = "Dump info on each error",
3493 .category = FIO_OPT_C_GENERAL,
3494 .group = FIO_OPT_G_ERR,
3499 .type = FIO_OPT_STR_STORE,
3500 .off1 = td_var_offset(profile),
3501 .help = "Select a specific builtin performance test",
3502 .category = FIO_OPT_C_PROFILE,
3503 .group = FIO_OPT_G_INVALID,
3508 .type = FIO_OPT_STR_STORE,
3509 .off1 = td_var_offset(cgroup),
3510 .help = "Add job to cgroup of this name",
3511 .category = FIO_OPT_C_GENERAL,
3512 .group = FIO_OPT_G_CGROUP,
3515 .name = "cgroup_nodelete",
3516 .lname = "Cgroup no-delete",
3517 .type = FIO_OPT_BOOL,
3518 .off1 = td_var_offset(cgroup_nodelete),
3519 .help = "Do not delete cgroups after job completion",
3522 .category = FIO_OPT_C_GENERAL,
3523 .group = FIO_OPT_G_CGROUP,
3526 .name = "cgroup_weight",
3527 .lname = "Cgroup weight",
3528 .type = FIO_OPT_INT,
3529 .off1 = td_var_offset(cgroup_weight),
3530 .help = "Use given weight for cgroup",
3534 .category = FIO_OPT_C_GENERAL,
3535 .group = FIO_OPT_G_CGROUP,
3540 .type = FIO_OPT_INT,
3541 .off1 = td_var_offset(uid),
3542 .help = "Run job with this user ID",
3543 .category = FIO_OPT_C_GENERAL,
3544 .group = FIO_OPT_G_CRED,
3548 .lname = "Group ID",
3549 .type = FIO_OPT_INT,
3550 .off1 = td_var_offset(gid),
3551 .help = "Run job with this group ID",
3552 .category = FIO_OPT_C_GENERAL,
3553 .group = FIO_OPT_G_CRED,
3558 .type = FIO_OPT_INT,
3559 .off1 = td_var_offset(kb_base),
3565 .help = "Use 1024 as the K base",
3569 .help = "Use 1000 as the K base",
3572 .help = "How many bytes per KB for reporting (1000 or 1024)",
3573 .category = FIO_OPT_C_GENERAL,
3574 .group = FIO_OPT_G_INVALID,
3577 .name = "unit_base",
3578 .lname = "Base unit for reporting (Bits or Bytes)",
3579 .type = FIO_OPT_INT,
3580 .off1 = td_var_offset(unit_base),
3585 .help = "Auto-detect",
3589 .help = "Normal (byte based)",
3593 .help = "Bit based",
3596 .help = "Bit multiple of result summary data (8 for byte, 1 for bit)",
3597 .category = FIO_OPT_C_GENERAL,
3598 .group = FIO_OPT_G_INVALID,
3601 .name = "hugepage-size",
3602 .lname = "Hugepage size",
3603 .type = FIO_OPT_INT,
3604 .off1 = td_var_offset(hugepage_size),
3605 .help = "When using hugepages, specify size of each page",
3606 .def = __fio_stringify(FIO_HUGE_PAGE),
3607 .interval = 1024 * 1024,
3608 .category = FIO_OPT_C_GENERAL,
3609 .group = FIO_OPT_G_INVALID,
3613 .lname = "I/O flow ID",
3614 .type = FIO_OPT_INT,
3615 .off1 = td_var_offset(flow_id),
3616 .help = "The flow index ID to use",
3618 .category = FIO_OPT_C_IO,
3619 .group = FIO_OPT_G_IO_FLOW,
3623 .lname = "I/O flow weight",
3624 .type = FIO_OPT_INT,
3625 .off1 = td_var_offset(flow),
3626 .help = "Weight for flow control of this job",
3627 .parent = "flow_id",
3630 .category = FIO_OPT_C_IO,
3631 .group = FIO_OPT_G_IO_FLOW,
3634 .name = "flow_watermark",
3635 .lname = "I/O flow watermark",
3636 .type = FIO_OPT_INT,
3637 .off1 = td_var_offset(flow_watermark),
3638 .help = "High watermark for flow control. This option"
3639 " should be set to the same value for all threads"
3640 " with non-zero flow.",
3641 .parent = "flow_id",
3644 .category = FIO_OPT_C_IO,
3645 .group = FIO_OPT_G_IO_FLOW,
3648 .name = "flow_sleep",
3649 .lname = "I/O flow sleep",
3650 .type = FIO_OPT_INT,
3651 .off1 = td_var_offset(flow_sleep),
3652 .help = "How many microseconds to sleep after being held"
3653 " back by the flow control mechanism",
3654 .parent = "flow_id",
3657 .category = FIO_OPT_C_IO,
3658 .group = FIO_OPT_G_IO_FLOW,
3662 .lname = "Skip operations against bad blocks",
3663 .type = FIO_OPT_BOOL,
3664 .off1 = td_var_offset(skip_bad),
3665 .help = "Skip operations against known bad blocks.",
3668 .category = FIO_OPT_C_IO,
3669 .group = FIO_OPT_G_MTD,
3676 static void add_to_lopt(struct option *lopt, struct fio_option *o,
3677 const char *name, int val)
3679 lopt->name = (char *) name;
3681 if (o->type == FIO_OPT_STR_SET)
3682 lopt->has_arg = optional_argument;
3684 lopt->has_arg = required_argument;
3687 static void options_to_lopts(struct fio_option *opts,
3688 struct option *long_options,
3689 int i, int option_type)
3691 struct fio_option *o = &opts[0];
3693 add_to_lopt(&long_options[i], o, o->name, option_type);
3696 add_to_lopt(&long_options[i], o, o->alias, option_type);
3701 assert(i < FIO_NR_OPTIONS);
3705 void fio_options_set_ioengine_opts(struct option *long_options,
3706 struct thread_data *td)
3711 while (long_options[i].name) {
3712 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
3713 memset(&long_options[i], 0, sizeof(*long_options));
3720 * Just clear out the prior ioengine options.
3725 options_to_lopts(td->io_ops->options, long_options, i,
3726 FIO_GETOPT_IOENGINE);
3729 void fio_options_dup_and_init(struct option *long_options)
3733 options_init(fio_options);
3736 while (long_options[i].name)
3739 options_to_lopts(fio_options, long_options, i, FIO_GETOPT_JOB);
3742 struct fio_keyword {
3748 static struct fio_keyword fio_keywords[] = {
3750 .word = "$pagesize",
3751 .desc = "Page size in the system",
3754 .word = "$mb_memory",
3755 .desc = "Megabytes of memory online",
3759 .desc = "Number of CPUs online in the system",
3766 void fio_keywords_exit(void)
3768 struct fio_keyword *kw;
3770 kw = &fio_keywords[0];
3778 void fio_keywords_init(void)
3780 unsigned long long mb_memory;
3784 sprintf(buf, "%lu", (unsigned long) page_size);
3785 fio_keywords[0].replace = strdup(buf);
3787 mb_memory = os_phys_mem() / (1024 * 1024);
3788 sprintf(buf, "%llu", mb_memory);
3789 fio_keywords[1].replace = strdup(buf);
3792 sprintf(buf, "%lu", l);
3793 fio_keywords[2].replace = strdup(buf);
3798 static char *bc_calc(char *str)
3800 char buf[128], *tmp;
3805 * No math, just return string
3807 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
3808 !strchr(str, '/')) || strchr(str, '\''))
3812 * Split option from value, we only need to calculate the value
3814 tmp = strchr(str, '=');
3821 * Prevent buffer overflows; such a case isn't reasonable anyway
3823 if (strlen(str) >= 128 || strlen(tmp) > 100)
3826 sprintf(buf, "which %s > /dev/null", BC_APP);
3828 log_err("fio: bc is needed for performing math\n");
3832 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
3833 f = popen(buf, "r");
3837 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
3844 buf[(tmp - str) + ret - 1] = '\0';
3845 memcpy(buf, str, tmp - str);
3851 * Return a copy of the input string with substrings of the form ${VARNAME}
3852 * substituted with the value of the environment variable VARNAME. The
3853 * substitution always occurs, even if VARNAME is empty or the corresponding
3854 * environment variable undefined.
3856 static char *option_dup_subs(const char *opt)
3858 char out[OPT_LEN_MAX+1];
3859 char in[OPT_LEN_MAX+1];
3862 char *ch1, *ch2, *env;
3863 ssize_t nchr = OPT_LEN_MAX;
3866 if (strlen(opt) + 1 > OPT_LEN_MAX) {
3867 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
3871 in[OPT_LEN_MAX] = '\0';
3872 strncpy(in, opt, OPT_LEN_MAX);
3874 while (*inptr && nchr > 0) {
3875 if (inptr[0] == '$' && inptr[1] == '{') {
3876 ch2 = strchr(inptr, '}');
3877 if (ch2 && inptr+1 < ch2) {
3884 envlen = strlen(env);
3885 if (envlen <= nchr) {
3886 memcpy(outptr, env, envlen);
3896 *outptr++ = *inptr++;
3905 * Look for reserved variable names and replace them with real values
3907 static char *fio_keyword_replace(char *opt)
3913 for (i = 0; fio_keywords[i].word != NULL; i++) {
3914 struct fio_keyword *kw = &fio_keywords[i];
3916 while ((s = strstr(opt, kw->word)) != NULL) {
3917 char *new = malloc(strlen(opt) + 1);
3923 * Copy part of the string before the keyword and
3924 * sprintf() the replacement after it.
3926 memcpy(new, opt, olen);
3927 len = sprintf(new + olen, "%s", kw->replace);
3930 * If there's more in the original string, copy that
3933 opt += strlen(kw->word) + olen;
3935 memcpy(new + olen + len, opt, opt - o_org - 1);
3938 * replace opt and free the old opt
3948 * Check for potential math and invoke bc, if possible
3956 static char **dup_and_sub_options(char **opts, int num_opts)
3959 char **opts_copy = malloc(num_opts * sizeof(*opts));
3960 for (i = 0; i < num_opts; i++) {
3961 opts_copy[i] = option_dup_subs(opts[i]);
3964 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
3969 static void show_closest_option(const char *opt)
3971 int best_option, best_distance;
3980 while (name[i] != '\0' && name[i] != '=')
3985 best_distance = INT_MAX;
3987 while (fio_options[i].name) {
3988 distance = string_distance(name, fio_options[i].name);
3989 if (distance < best_distance) {
3990 best_distance = distance;
3996 if (best_option != -1 && string_distance_ok(name, best_distance))
3997 log_err("Did you mean %s?\n", fio_options[best_option].name);
4002 int fio_options_parse(struct thread_data *td, char **opts, int num_opts,
4005 int i, ret, unknown;
4008 sort_options(opts, fio_options, num_opts);
4009 opts_copy = dup_and_sub_options(opts, num_opts);
4011 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
4012 struct fio_option *o;
4013 int newret = parse_option(opts_copy[i], opts[i], fio_options,
4014 &o, td, dump_cmdline);
4017 fio_option_mark_set(&td->o, o);
4025 opts_copy[i] = NULL;
4032 ret |= ioengine_load(td);
4034 sort_options(opts_copy, td->io_ops->options, num_opts);
4037 for (i = 0; i < num_opts; i++) {
4038 struct fio_option *o = NULL;
4045 newret = parse_option(opts_copy[i], opts[i],
4046 td->io_ops->options, &o,
4047 td->eo, dump_cmdline);
4051 log_err("Bad option <%s>\n", opts[i]);
4052 show_closest_option(opts[i]);
4055 opts_copy[i] = NULL;
4063 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
4067 ret = parse_cmd_option(opt, val, fio_options, td);
4069 struct fio_option *o;
4071 o = find_option(fio_options, opt);
4073 fio_option_mark_set(&td->o, o);
4079 int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
4082 return parse_cmd_option(opt, val, td->io_ops->options, td->eo);
4085 void fio_fill_default_options(struct thread_data *td)
4087 td->o.magic = OPT_MAGIC;
4088 fill_default_options(td, fio_options);
4091 int fio_show_option_help(const char *opt)
4093 return show_cmd_help(fio_options, opt);
4096 void options_mem_dupe(void *data, struct fio_option *options)
4098 struct fio_option *o;
4101 for (o = &options[0]; o->name; o++) {
4102 if (o->type != FIO_OPT_STR_STORE)
4105 ptr = td_var(data, o, o->off1);
4107 *ptr = strdup(*ptr);
4112 * dupe FIO_OPT_STR_STORE options
4114 void fio_options_mem_dupe(struct thread_data *td)
4116 options_mem_dupe(&td->o, fio_options);
4118 if (td->eo && td->io_ops) {
4119 void *oldeo = td->eo;
4121 td->eo = malloc(td->io_ops->option_struct_size);
4122 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
4123 options_mem_dupe(td->eo, td->io_ops->options);
4127 unsigned int fio_get_kb_base(void *data)
4129 struct thread_options *o = data;
4130 unsigned int kb_base = 0;
4133 * This is a hack... For private options, *data is not holding
4134 * a pointer to the thread_options, but to private data. This means
4135 * we can't safely dereference it, but magic is first so mem wise
4136 * it is valid. But this also means that if the job first sets
4137 * kb_base and expects that to be honored by private options,
4138 * it will be disappointed. We will return the global default
4141 if (o && o->magic == OPT_MAGIC)
4142 kb_base = o->kb_base;
4149 int add_option(struct fio_option *o)
4151 struct fio_option *__o;
4160 if (opt_index + 1 == FIO_MAX_OPTS) {
4161 log_err("fio: FIO_MAX_OPTS is too small\n");
4165 memcpy(&fio_options[opt_index], o, sizeof(*o));
4166 fio_options[opt_index + 1].name = NULL;
4170 void invalidate_profile_options(const char *prof_name)
4172 struct fio_option *o;
4176 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
4177 o->type = FIO_OPT_INVALID;
4178 o->prof_name = NULL;
4184 void add_opt_posval(const char *optname, const char *ival, const char *help)
4186 struct fio_option *o;
4189 o = find_option(fio_options, optname);
4193 for (i = 0; i < PARSE_MAX_VP; i++) {
4194 if (o->posval[i].ival)
4197 o->posval[i].ival = ival;
4198 o->posval[i].help = help;
4203 void del_opt_posval(const char *optname, const char *ival)
4205 struct fio_option *o;
4208 o = find_option(fio_options, optname);
4212 for (i = 0; i < PARSE_MAX_VP; i++) {
4213 if (!o->posval[i].ival)
4215 if (strcmp(o->posval[i].ival, ival))
4218 o->posval[i].ival = NULL;
4219 o->posval[i].help = NULL;
4223 void fio_options_free(struct thread_data *td)
4225 options_free(fio_options, td);
4226 if (td->eo && td->io_ops && td->io_ops->options) {
4227 options_free(td->io_ops->options, td->eo);
4233 struct fio_option *fio_option_find(const char *name)
4235 return find_option(fio_options, name);
4238 static struct fio_option *find_next_opt(struct thread_options *o,
4239 struct fio_option *from,
4242 struct fio_option *opt;
4245 from = &fio_options[0];
4251 if (off1 == from->off1) {
4256 } while (from->name);
4261 static int opt_is_set(struct thread_options *o, struct fio_option *opt)
4263 unsigned int opt_off, index, offset;
4265 opt_off = opt - &fio_options[0];
4266 index = opt_off / (8 * sizeof(uint64_t));
4267 offset = opt_off & ((8 * sizeof(uint64_t)) - 1);
4268 return (o->set_options[index] & ((uint64_t)1 << offset)) != 0;
4271 int __fio_option_is_set(struct thread_options *o, unsigned int off1)
4273 struct fio_option *opt, *next;
4276 while ((opt = find_next_opt(o, next, off1)) != NULL) {
4277 if (opt_is_set(o, opt))
4286 void fio_option_mark_set(struct thread_options *o, struct fio_option *opt)
4288 unsigned int opt_off, index, offset;
4290 opt_off = opt - &fio_options[0];
4291 index = opt_off / (8 * sizeof(uint64_t));
4292 offset = opt_off & ((8 * sizeof(uint64_t)) - 1);
4293 o->set_options[index] |= (uint64_t)1 << offset;