11 #include <netinet/in.h>
17 #include "lib/pattern.h"
21 #include "crc/crc32c.h"
23 char client_sockaddr_str[INET6_ADDRSTRLEN] = { 0 };
25 struct pattern_fmt_desc fmt_desc[] = {
28 .len = FIELD_SIZE(struct io_u *, offset),
29 .paste = paste_blockoff
34 * Check if mmap/mmaphuge has a :/foo/bar/file at the end. If so, return that.
36 static char *get_opt_postfix(const char *str)
38 char *p = strstr(str, ":");
44 strip_blank_front(&p);
49 static int bs_cmp(const void *p1, const void *p2)
51 const struct bssplit *bsp1 = p1;
52 const struct bssplit *bsp2 = p2;
54 return bsp1->perc < bsp2->perc;
57 static int bssplit_ddir(struct thread_options *o, int ddir, char *str)
59 struct bssplit *bssplit;
60 unsigned int i, perc, perc_missing;
61 unsigned int max_bs, min_bs;
65 o->bssplit_nr[ddir] = 4;
66 bssplit = malloc(4 * sizeof(struct bssplit));
71 while ((fname = strsep(&str, ":")) != NULL) {
78 * grow struct buffer, if needed
80 if (i == o->bssplit_nr[ddir]) {
81 o->bssplit_nr[ddir] <<= 1;
82 bssplit = realloc(bssplit, o->bssplit_nr[ddir]
83 * sizeof(struct bssplit));
86 perc_str = strstr(fname, "/");
90 perc = atoi(perc_str);
98 if (str_to_decimal(fname, &val, 1, o, 0, 0)) {
99 log_err("fio: bssplit conversion failed\n");
110 bssplit[i].perc = perc;
114 o->bssplit_nr[ddir] = i;
117 * Now check if the percentages add up, and how much is missing
119 perc = perc_missing = 0;
120 for (i = 0; i < o->bssplit_nr[ddir]; i++) {
121 struct bssplit *bsp = &bssplit[i];
123 if (bsp->perc == -1U)
129 if (perc > 100 && perc_missing > 1) {
130 log_err("fio: bssplit percentages add to more than 100%%\n");
136 * If values didn't have a percentage set, divide the remains between
140 if (perc_missing == 1 && o->bssplit_nr[ddir] == 1)
142 for (i = 0; i < o->bssplit_nr[ddir]; i++) {
143 struct bssplit *bsp = &bssplit[i];
145 if (bsp->perc == -1U)
146 bsp->perc = (100 - perc) / perc_missing;
150 o->min_bs[ddir] = min_bs;
151 o->max_bs[ddir] = max_bs;
154 * now sort based on percentages, for ease of lookup
156 qsort(bssplit, o->bssplit_nr[ddir], sizeof(struct bssplit), bs_cmp);
157 o->bssplit[ddir] = bssplit;
161 static int str_bssplit_cb(void *data, const char *input)
163 struct thread_data *td = data;
164 char *str, *p, *odir, *ddir;
170 p = str = strdup(input);
172 strip_blank_front(&str);
173 strip_blank_end(str);
175 odir = strchr(str, ',');
177 ddir = strchr(odir + 1, ',');
179 ret = bssplit_ddir(&td->o, DDIR_TRIM, ddir + 1);
185 op = strdup(odir + 1);
186 ret = bssplit_ddir(&td->o, DDIR_TRIM, op);
191 ret = bssplit_ddir(&td->o, DDIR_WRITE, odir + 1);
194 ret = bssplit_ddir(&td->o, DDIR_READ, str);
200 ret = bssplit_ddir(&td->o, DDIR_WRITE, op);
205 ret = bssplit_ddir(&td->o, DDIR_TRIM, op);
209 ret = bssplit_ddir(&td->o, DDIR_READ, str);
216 static int str2error(char *str)
218 const char *err[] = { "EPERM", "ENOENT", "ESRCH", "EINTR", "EIO",
219 "ENXIO", "E2BIG", "ENOEXEC", "EBADF",
220 "ECHILD", "EAGAIN", "ENOMEM", "EACCES",
221 "EFAULT", "ENOTBLK", "EBUSY", "EEXIST",
222 "EXDEV", "ENODEV", "ENOTDIR", "EISDIR",
223 "EINVAL", "ENFILE", "EMFILE", "ENOTTY",
224 "ETXTBSY","EFBIG", "ENOSPC", "ESPIPE",
225 "EROFS","EMLINK", "EPIPE", "EDOM", "ERANGE" };
226 int i = 0, num = sizeof(err) / sizeof(void *);
229 if (!strcmp(err[i], str))
236 static int ignore_error_type(struct thread_data *td, int etype, char *str)
242 if (etype >= ERROR_TYPE_CNT) {
243 log_err("Illegal error type\n");
247 td->o.ignore_error_nr[etype] = 4;
248 error = malloc(4 * sizeof(struct bssplit));
251 while ((fname = strsep(&str, ":")) != NULL) {
257 * grow struct buffer, if needed
259 if (i == td->o.ignore_error_nr[etype]) {
260 td->o.ignore_error_nr[etype] <<= 1;
261 error = realloc(error, td->o.ignore_error_nr[etype]
264 if (fname[0] == 'E') {
265 error[i] = str2error(fname);
267 error[i] = atoi(fname);
269 error[i] = -error[i];
272 log_err("Unknown error %s, please use number value \n",
280 td->o.continue_on_error |= 1 << etype;
281 td->o.ignore_error_nr[etype] = i;
282 td->o.ignore_error[etype] = error;
290 static int str_ignore_error_cb(void *data, const char *input)
292 struct thread_data *td = data;
294 int type = 0, ret = 1;
299 p = str = strdup(input);
301 strip_blank_front(&str);
302 strip_blank_end(str);
308 ret = ignore_error_type(td, type, p);
318 static int str_rw_cb(void *data, const char *str)
320 struct thread_data *td = data;
321 struct thread_options *o = &td->o;
330 nr = get_opt_postfix(str);
335 o->ddir_seq_nr = atoi(nr);
339 if (str_to_decimal(nr, &val, 1, o, 0, 0)) {
340 log_err("fio: rw postfix parsing failed\n");
345 o->ddir_seq_add = val;
352 static int str_mem_cb(void *data, const char *mem)
354 struct thread_data *td = data;
356 if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP ||
357 td->o.mem_type == MEM_MMAPSHARED)
358 td->o.mmapfile = get_opt_postfix(mem);
363 static int fio_clock_source_cb(void *data, const char *str)
365 struct thread_data *td = data;
367 fio_clock_source = td->o.clocksource;
368 fio_clock_source_set = 1;
373 static int str_rwmix_read_cb(void *data, unsigned long long *val)
375 struct thread_data *td = data;
377 td->o.rwmix[DDIR_READ] = *val;
378 td->o.rwmix[DDIR_WRITE] = 100 - *val;
382 static int str_rwmix_write_cb(void *data, unsigned long long *val)
384 struct thread_data *td = data;
386 td->o.rwmix[DDIR_WRITE] = *val;
387 td->o.rwmix[DDIR_READ] = 100 - *val;
391 static int str_exitall_cb(void)
393 exitall_on_terminate = 1;
397 #ifdef FIO_HAVE_CPU_AFFINITY
398 int fio_cpus_split(os_cpu_mask_t *mask, unsigned int cpu_index)
400 unsigned int i, index, cpus_in_mask;
401 const long max_cpu = cpus_online();
403 cpus_in_mask = fio_cpu_count(mask);
404 cpu_index = cpu_index % cpus_in_mask;
407 for (i = 0; i < max_cpu; i++) {
408 if (!fio_cpu_isset(mask, i))
411 if (cpu_index != index)
412 fio_cpu_clear(mask, i);
417 return fio_cpu_count(mask);
420 static int str_cpumask_cb(void *data, unsigned long long *val)
422 struct thread_data *td = data;
430 ret = fio_cpuset_init(&td->o.cpumask);
432 log_err("fio: cpuset_init failed\n");
433 td_verror(td, ret, "fio_cpuset_init");
437 max_cpu = cpus_online();
439 for (i = 0; i < sizeof(int) * 8; i++) {
440 if ((1 << i) & *val) {
442 log_err("fio: CPU %d too large (max=%ld)\n", i,
446 dprint(FD_PARSE, "set cpu allowed %d\n", i);
447 fio_cpu_set(&td->o.cpumask, i);
454 static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask,
461 ret = fio_cpuset_init(mask);
463 log_err("fio: cpuset_init failed\n");
464 td_verror(td, ret, "fio_cpuset_init");
468 p = str = strdup(input);
470 strip_blank_front(&str);
471 strip_blank_end(str);
473 max_cpu = cpus_online();
475 while ((cpu = strsep(&str, ",")) != NULL) {
484 while ((cpu2 = strsep(&str2, "-")) != NULL) {
494 while (icpu <= icpu2) {
495 if (icpu >= FIO_MAX_CPUS) {
496 log_err("fio: your OS only supports up to"
497 " %d CPUs\n", (int) FIO_MAX_CPUS);
501 if (icpu >= max_cpu) {
502 log_err("fio: CPU %d too large (max=%ld)\n",
508 dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
509 fio_cpu_set(mask, icpu);
520 static int str_cpus_allowed_cb(void *data, const char *input)
522 struct thread_data *td = data;
527 return set_cpus_allowed(td, &td->o.cpumask, input);
530 static int str_verify_cpus_allowed_cb(void *data, const char *input)
532 struct thread_data *td = data;
537 return set_cpus_allowed(td, &td->o.verify_cpumask, input);
541 static int str_log_cpus_allowed_cb(void *data, const char *input)
543 struct thread_data *td = data;
548 return set_cpus_allowed(td, &td->o.log_gz_cpumask, input);
550 #endif /* CONFIG_ZLIB */
552 #endif /* FIO_HAVE_CPU_AFFINITY */
554 #ifdef CONFIG_LIBNUMA
555 static int str_numa_cpunodes_cb(void *data, char *input)
557 struct thread_data *td = data;
558 struct bitmask *verify_bitmask;
563 /* numa_parse_nodestring() parses a character string list
564 * of nodes into a bit mask. The bit mask is allocated by
565 * numa_allocate_nodemask(), so it should be freed by
566 * numa_free_nodemask().
568 verify_bitmask = numa_parse_nodestring(input);
569 if (verify_bitmask == NULL) {
570 log_err("fio: numa_parse_nodestring failed\n");
571 td_verror(td, 1, "str_numa_cpunodes_cb");
574 numa_free_nodemask(verify_bitmask);
576 td->o.numa_cpunodes = strdup(input);
580 static int str_numa_mpol_cb(void *data, char *input)
582 struct thread_data *td = data;
583 const char * const policy_types[] =
584 { "default", "prefer", "bind", "interleave", "local", NULL };
587 struct bitmask *verify_bitmask;
592 nodelist = strchr(input, ':');
594 /* NUL-terminate mode */
598 for (i = 0; i <= MPOL_LOCAL; i++) {
599 if (!strcmp(input, policy_types[i])) {
600 td->o.numa_mem_mode = i;
604 if (i > MPOL_LOCAL) {
605 log_err("fio: memory policy should be: default, prefer, bind, interleave, local\n");
609 switch (td->o.numa_mem_mode) {
612 * Insist on a nodelist of one node only
615 char *rest = nodelist;
616 while (isdigit(*rest))
619 log_err("fio: one node only for \'prefer\'\n");
623 log_err("fio: one node is needed for \'prefer\'\n");
627 case MPOL_INTERLEAVE:
629 * Default to online nodes with memory if no nodelist
632 nodelist = strdup("all");
637 * Don't allow a nodelist
640 log_err("fio: NO nodelist for \'local\'\n");
646 * Insist on a nodelist
649 log_err("fio: a nodelist is needed for \'bind\'\n");
656 /* numa_parse_nodestring() parses a character string list
657 * of nodes into a bit mask. The bit mask is allocated by
658 * numa_allocate_nodemask(), so it should be freed by
659 * numa_free_nodemask().
661 switch (td->o.numa_mem_mode) {
663 td->o.numa_mem_prefer_node = atoi(nodelist);
665 case MPOL_INTERLEAVE:
667 verify_bitmask = numa_parse_nodestring(nodelist);
668 if (verify_bitmask == NULL) {
669 log_err("fio: numa_parse_nodestring failed\n");
670 td_verror(td, 1, "str_numa_memnodes_cb");
673 td->o.numa_memnodes = strdup(nodelist);
674 numa_free_nodemask(verify_bitmask);
689 static int str_fst_cb(void *data, const char *str)
691 struct thread_data *td = data;
692 char *nr = get_opt_postfix(str);
694 td->file_service_nr = 1;
696 td->file_service_nr = atoi(nr);
703 #ifdef CONFIG_SYNC_FILE_RANGE
704 static int str_sfr_cb(void *data, const char *str)
706 struct thread_data *td = data;
707 char *nr = get_opt_postfix(str);
709 td->sync_file_range_nr = 1;
711 td->sync_file_range_nr = atoi(nr);
719 static int str_random_distribution_cb(void *data, const char *str)
721 struct thread_data *td = data;
728 if (td->o.random_distribution == FIO_RAND_DIST_ZIPF)
730 else if (td->o.random_distribution == FIO_RAND_DIST_PARETO)
731 val = FIO_DEF_PARETO;
732 else if (td->o.random_distribution == FIO_RAND_DIST_GAUSS)
737 nr = get_opt_postfix(str);
738 if (nr && !str_to_float(nr, &val, 0)) {
739 log_err("fio: random postfix parsing failed\n");
746 if (td->o.random_distribution == FIO_RAND_DIST_ZIPF) {
748 log_err("fio: zipf theta must different than 1.0\n");
751 td->o.zipf_theta.u.f = val;
752 } else if (td->o.random_distribution == FIO_RAND_DIST_PARETO) {
753 if (val <= 0.00 || val >= 1.00) {
754 log_err("fio: pareto input out of range (0 < input < 1.0)\n");
757 td->o.pareto_h.u.f = val;
759 if (val <= 0.00 || val >= 100.0) {
760 log_err("fio: normal deviation out of range (0 < input < 100.0)\n");
763 td->o.gauss_dev.u.f = val;
770 * Return next name in the string. Files are separated with ':'. If the ':'
771 * is escaped with a '\', then that ':' is part of the filename and does not
772 * indicate a new file.
774 static char *get_next_name(char **ptr)
779 if (!str || !strlen(str))
785 * No colon, we are done
787 p = strchr(str, ':');
794 * We got a colon, but it's the first character. Skip and
802 if (*(p - 1) != '\\') {
808 memmove(p - 1, p, strlen(p) + 1);
816 static int get_max_name_idx(char *input)
818 unsigned int cur_idx;
821 p = str = strdup(input);
822 for (cur_idx = 0; ; cur_idx++)
823 if (get_next_name(&str) == NULL)
831 * Returns the directory at the index, indexes > entires will be
832 * assigned via modulo division of the index
834 int set_name_idx(char *target, size_t tlen, char *input, int index)
836 unsigned int cur_idx;
838 char *fname, *str, *p;
840 p = str = strdup(input);
842 index %= get_max_name_idx(input);
843 for (cur_idx = 0; cur_idx <= index; cur_idx++)
844 fname = get_next_name(&str);
846 if (client_sockaddr_str[0]) {
847 len = snprintf(target, tlen, "%s/%s.", fname,
848 client_sockaddr_str);
850 len = snprintf(target, tlen, "%s/", fname);
852 target[tlen - 1] = '\0';
858 static int str_filename_cb(void *data, const char *input)
860 struct thread_data *td = data;
861 char *fname, *str, *p;
863 p = str = strdup(input);
865 strip_blank_front(&str);
866 strip_blank_end(str);
868 if (!td->files_index)
871 while ((fname = get_next_name(&str)) != NULL) {
874 add_file(td, fname, 0, 1);
881 static int str_directory_cb(void *data, const char fio_unused *unused)
883 struct thread_data *td = data;
885 char *dirname, *str, *p;
891 p = str = strdup(td->o.directory);
892 while ((dirname = get_next_name(&str)) != NULL) {
893 if (lstat(dirname, &sb) < 0) {
896 log_err("fio: %s is not a directory\n", dirname);
897 td_verror(td, ret, "lstat");
900 if (!S_ISDIR(sb.st_mode)) {
901 log_err("fio: %s is not a directory\n", dirname);
912 static int str_opendir_cb(void *data, const char fio_unused *str)
914 struct thread_data *td = data;
919 if (!td->files_index)
922 return add_dir_files(td, td->o.opendir);
925 static int str_buffer_pattern_cb(void *data, const char *input)
927 struct thread_data *td = data;
930 /* FIXME: for now buffer pattern does not support formats */
931 ret = parse_and_fill_pattern(input, strlen(input), td->o.buffer_pattern,
932 MAX_PATTERN_SIZE, NULL, 0, NULL, NULL);
937 td->o.buffer_pattern_bytes = ret;
938 if (!td->o.compress_percentage)
939 td->o.refill_buffers = 0;
940 td->o.scramble_buffers = 0;
941 td->o.zero_buffers = 0;
946 static int str_buffer_compress_cb(void *data, unsigned long long *il)
948 struct thread_data *td = data;
950 td->flags |= TD_F_COMPRESS;
951 td->o.compress_percentage = *il;
955 static int str_dedupe_cb(void *data, unsigned long long *il)
957 struct thread_data *td = data;
959 td->flags |= TD_F_COMPRESS;
960 td->o.dedupe_percentage = *il;
961 td->o.refill_buffers = 1;
965 static int str_verify_pattern_cb(void *data, const char *input)
967 struct thread_data *td = data;
970 td->o.verify_fmt_sz = ARRAY_SIZE(td->o.verify_fmt);
971 ret = parse_and_fill_pattern(input, strlen(input), td->o.verify_pattern,
972 MAX_PATTERN_SIZE, fmt_desc, sizeof(fmt_desc),
973 td->o.verify_fmt, &td->o.verify_fmt_sz);
978 td->o.verify_pattern_bytes = ret;
980 * VERIFY_* could already be set
982 if (!fio_option_is_set(&td->o, verify))
983 td->o.verify = VERIFY_PATTERN;
988 static int str_gtod_reduce_cb(void *data, int *il)
990 struct thread_data *td = data;
993 td->o.disable_lat = !!val;
994 td->o.disable_clat = !!val;
995 td->o.disable_slat = !!val;
996 td->o.disable_bw = !!val;
997 td->o.clat_percentiles = !val;
999 td->tv_cache_mask = 63;
1004 static int str_size_cb(void *data, unsigned long long *__val)
1006 struct thread_data *td = data;
1007 unsigned long long v = *__val;
1009 if (parse_is_percent(v)) {
1011 td->o.size_percent = -1ULL - v;
1018 static int rw_verify(struct fio_option *o, void *data)
1020 struct thread_data *td = data;
1022 if (read_only && td_write(td)) {
1023 log_err("fio: job <%s> has write bit set, but fio is in"
1024 " read-only mode\n", td->o.name);
1031 static int gtod_cpu_verify(struct fio_option *o, void *data)
1033 #ifndef FIO_HAVE_CPU_AFFINITY
1034 struct thread_data *td = data;
1036 if (td->o.gtod_cpu) {
1037 log_err("fio: platform must support CPU affinity for"
1038 "gettimeofday() offloading\n");
1047 * Map of job/command line options
1049 struct fio_option fio_options[FIO_MAX_OPTS] = {
1051 .name = "description",
1052 .lname = "Description of job",
1053 .type = FIO_OPT_STR_STORE,
1054 .off1 = td_var_offset(description),
1055 .help = "Text job description",
1056 .category = FIO_OPT_C_GENERAL,
1057 .group = FIO_OPT_G_DESC,
1061 .lname = "Job name",
1062 .type = FIO_OPT_STR_STORE,
1063 .off1 = td_var_offset(name),
1064 .help = "Name of this job",
1065 .category = FIO_OPT_C_GENERAL,
1066 .group = FIO_OPT_G_DESC,
1070 .lname = "Waitee name",
1071 .type = FIO_OPT_STR_STORE,
1072 .off1 = td_var_offset(wait_for),
1073 .help = "Name of the job this one wants to wait for before starting",
1074 .category = FIO_OPT_C_GENERAL,
1075 .group = FIO_OPT_G_DESC,
1079 .lname = "Filename(s)",
1080 .type = FIO_OPT_STR_STORE,
1081 .off1 = td_var_offset(filename),
1082 .cb = str_filename_cb,
1083 .prio = -1, /* must come after "directory" */
1084 .help = "File(s) to use for the workload",
1085 .category = FIO_OPT_C_FILE,
1086 .group = FIO_OPT_G_FILENAME,
1089 .name = "directory",
1090 .lname = "Directory",
1091 .type = FIO_OPT_STR_STORE,
1092 .off1 = td_var_offset(directory),
1093 .cb = str_directory_cb,
1094 .help = "Directory to store files in",
1095 .category = FIO_OPT_C_FILE,
1096 .group = FIO_OPT_G_FILENAME,
1099 .name = "filename_format",
1100 .type = FIO_OPT_STR_STORE,
1101 .off1 = td_var_offset(filename_format),
1102 .prio = -1, /* must come after "directory" */
1103 .help = "Override default $jobname.$jobnum.$filenum naming",
1104 .def = "$jobname.$jobnum.$filenum",
1105 .category = FIO_OPT_C_FILE,
1106 .group = FIO_OPT_G_FILENAME,
1110 .lname = "Lockfile",
1111 .type = FIO_OPT_STR,
1112 .off1 = td_var_offset(file_lock_mode),
1113 .help = "Lock file when doing IO to it",
1115 .parent = "filename",
1118 .category = FIO_OPT_C_FILE,
1119 .group = FIO_OPT_G_FILENAME,
1122 .oval = FILE_LOCK_NONE,
1123 .help = "No file locking",
1125 { .ival = "exclusive",
1126 .oval = FILE_LOCK_EXCLUSIVE,
1127 .help = "Exclusive file lock",
1130 .ival = "readwrite",
1131 .oval = FILE_LOCK_READWRITE,
1132 .help = "Read vs write lock",
1138 .lname = "Open directory",
1139 .type = FIO_OPT_STR_STORE,
1140 .off1 = td_var_offset(opendir),
1141 .cb = str_opendir_cb,
1142 .help = "Recursively add files from this directory and down",
1143 .category = FIO_OPT_C_FILE,
1144 .group = FIO_OPT_G_FILENAME,
1148 .lname = "Read/write",
1149 .alias = "readwrite",
1150 .type = FIO_OPT_STR,
1152 .off1 = td_var_offset(td_ddir),
1153 .help = "IO direction",
1155 .verify = rw_verify,
1156 .category = FIO_OPT_C_IO,
1157 .group = FIO_OPT_G_IO_BASIC,
1160 .oval = TD_DDIR_READ,
1161 .help = "Sequential read",
1164 .oval = TD_DDIR_WRITE,
1165 .help = "Sequential write",
1168 .oval = TD_DDIR_TRIM,
1169 .help = "Sequential trim",
1171 { .ival = "randread",
1172 .oval = TD_DDIR_RANDREAD,
1173 .help = "Random read",
1175 { .ival = "randwrite",
1176 .oval = TD_DDIR_RANDWRITE,
1177 .help = "Random write",
1179 { .ival = "randtrim",
1180 .oval = TD_DDIR_RANDTRIM,
1181 .help = "Random trim",
1185 .help = "Sequential read and write mix",
1187 { .ival = "readwrite",
1189 .help = "Sequential read and write mix",
1192 .oval = TD_DDIR_RANDRW,
1193 .help = "Random read and write mix"
1195 { .ival = "trimwrite",
1196 .oval = TD_DDIR_TRIMWRITE,
1197 .help = "Trim and write mix, trims preceding writes"
1202 .name = "rw_sequencer",
1203 .lname = "RW Sequencer",
1204 .type = FIO_OPT_STR,
1205 .off1 = td_var_offset(rw_seq),
1206 .help = "IO offset generator modifier",
1207 .def = "sequential",
1208 .category = FIO_OPT_C_IO,
1209 .group = FIO_OPT_G_IO_BASIC,
1211 { .ival = "sequential",
1213 .help = "Generate sequential offsets",
1215 { .ival = "identical",
1216 .oval = RW_SEQ_IDENT,
1217 .help = "Generate identical offsets",
1224 .lname = "IO Engine",
1225 .type = FIO_OPT_STR_STORE,
1226 .off1 = td_var_offset(ioengine),
1227 .help = "IO engine to use",
1228 .def = FIO_PREFERRED_ENGINE,
1229 .category = FIO_OPT_C_IO,
1230 .group = FIO_OPT_G_IO_BASIC,
1233 .help = "Use read/write",
1236 .help = "Use pread/pwrite",
1239 .help = "Use readv/writev",
1241 #ifdef CONFIG_PWRITEV
1243 .help = "Use preadv/pwritev",
1246 #ifdef CONFIG_LIBAIO
1248 .help = "Linux native asynchronous IO",
1251 #ifdef CONFIG_POSIXAIO
1252 { .ival = "posixaio",
1253 .help = "POSIX asynchronous IO",
1256 #ifdef CONFIG_SOLARISAIO
1257 { .ival = "solarisaio",
1258 .help = "Solaris native asynchronous IO",
1261 #ifdef CONFIG_WINDOWSAIO
1262 { .ival = "windowsaio",
1263 .help = "Windows native asynchronous IO"
1268 .help = "Rados Block Device asynchronous IO"
1272 .help = "Memory mapped IO"
1274 #ifdef CONFIG_LINUX_SPLICE
1276 .help = "splice/vmsplice based IO",
1278 { .ival = "netsplice",
1279 .help = "splice/vmsplice to/from the network",
1282 #ifdef FIO_HAVE_SGIO
1284 .help = "SCSI generic v3 IO",
1288 .help = "Testing engine (no data transfer)",
1291 .help = "Network IO",
1294 .help = "CPU cycle burner engine",
1298 .help = "GUASI IO engine",
1301 #ifdef FIO_HAVE_BINJECT
1302 { .ival = "binject",
1303 .help = "binject direct inject block engine",
1308 .help = "RDMA IO engine",
1311 #ifdef CONFIG_FUSION_AW
1312 { .ival = "fusion-aw-sync",
1313 .help = "Fusion-io atomic write engine",
1316 #ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
1317 { .ival = "e4defrag",
1318 .help = "ext4 defrag engine",
1321 #ifdef CONFIG_LINUX_FALLOCATE
1323 .help = "fallocate() file based engine",
1328 .help = "Glusterfs libgfapi(sync) based engine"
1330 { .ival = "gfapi_async",
1331 .help = "Glusterfs libgfapi(async) based engine"
1334 #ifdef CONFIG_LIBHDFS
1335 { .ival = "libhdfs",
1336 .help = "Hadoop Distributed Filesystem (HDFS) engine"
1339 { .ival = "external",
1340 .help = "Load external engine (append name)",
1346 .lname = "IO Depth",
1347 .type = FIO_OPT_INT,
1348 .off1 = td_var_offset(iodepth),
1349 .help = "Number of IO buffers to keep in flight",
1353 .category = FIO_OPT_C_IO,
1354 .group = FIO_OPT_G_IO_BASIC,
1357 .name = "iodepth_batch",
1358 .lname = "IO Depth batch",
1359 .alias = "iodepth_batch_submit",
1360 .type = FIO_OPT_INT,
1361 .off1 = td_var_offset(iodepth_batch),
1362 .help = "Number of IO buffers to submit in one go",
1363 .parent = "iodepth",
1368 .category = FIO_OPT_C_IO,
1369 .group = FIO_OPT_G_IO_BASIC,
1372 .name = "iodepth_batch_complete_min",
1373 .lname = "Min IO depth batch complete",
1374 .alias = "iodepth_batch_complete",
1375 .type = FIO_OPT_INT,
1376 .off1 = td_var_offset(iodepth_batch_complete_min),
1377 .help = "Min number of IO buffers to retrieve in one go",
1378 .parent = "iodepth",
1383 .category = FIO_OPT_C_IO,
1384 .group = FIO_OPT_G_IO_BASIC,
1387 .name = "iodepth_batch_complete_max",
1388 .lname = "Max IO depth batch complete",
1389 .type = FIO_OPT_INT,
1390 .off1 = td_var_offset(iodepth_batch_complete_max),
1391 .help = "Max number of IO buffers to retrieve in one go",
1392 .parent = "iodepth",
1396 .category = FIO_OPT_C_IO,
1397 .group = FIO_OPT_G_IO_BASIC,
1400 .name = "iodepth_low",
1401 .lname = "IO Depth batch low",
1402 .type = FIO_OPT_INT,
1403 .off1 = td_var_offset(iodepth_low),
1404 .help = "Low water mark for queuing depth",
1405 .parent = "iodepth",
1408 .category = FIO_OPT_C_IO,
1409 .group = FIO_OPT_G_IO_BASIC,
1412 .name = "io_submit_mode",
1413 .lname = "IO submit mode",
1414 .type = FIO_OPT_STR,
1415 .off1 = td_var_offset(io_submit_mode),
1416 .help = "How IO submissions and completions are done",
1418 .category = FIO_OPT_C_IO,
1419 .group = FIO_OPT_G_IO_BASIC,
1422 .oval = IO_MODE_INLINE,
1423 .help = "Submit and complete IO inline",
1425 { .ival = "offload",
1426 .oval = IO_MODE_OFFLOAD,
1427 .help = "Offload submit and complete to threads",
1434 .type = FIO_OPT_STR_VAL,
1436 .off1 = td_var_offset(size),
1437 .help = "Total size of device or files",
1438 .interval = 1024 * 1024,
1439 .category = FIO_OPT_C_IO,
1440 .group = FIO_OPT_G_INVALID,
1444 .alias = "io_limit",
1446 .type = FIO_OPT_STR_VAL,
1447 .off1 = td_var_offset(io_limit),
1448 .interval = 1024 * 1024,
1449 .category = FIO_OPT_C_IO,
1450 .group = FIO_OPT_G_INVALID,
1453 .name = "fill_device",
1454 .lname = "Fill device",
1456 .type = FIO_OPT_BOOL,
1457 .off1 = td_var_offset(fill_device),
1458 .help = "Write until an ENOSPC error occurs",
1460 .category = FIO_OPT_C_FILE,
1461 .group = FIO_OPT_G_INVALID,
1465 .lname = "File size",
1466 .type = FIO_OPT_STR_VAL,
1467 .off1 = td_var_offset(file_size_low),
1468 .off2 = td_var_offset(file_size_high),
1470 .help = "Size of individual files",
1471 .interval = 1024 * 1024,
1472 .category = FIO_OPT_C_FILE,
1473 .group = FIO_OPT_G_INVALID,
1476 .name = "file_append",
1477 .lname = "File append",
1478 .type = FIO_OPT_BOOL,
1479 .off1 = td_var_offset(file_append),
1480 .help = "IO will start at the end of the file(s)",
1482 .category = FIO_OPT_C_FILE,
1483 .group = FIO_OPT_G_INVALID,
1487 .lname = "IO offset",
1488 .alias = "fileoffset",
1489 .type = FIO_OPT_STR_VAL,
1490 .off1 = td_var_offset(start_offset),
1491 .help = "Start IO from this offset",
1493 .interval = 1024 * 1024,
1494 .category = FIO_OPT_C_IO,
1495 .group = FIO_OPT_G_INVALID,
1498 .name = "offset_increment",
1499 .lname = "IO offset increment",
1500 .type = FIO_OPT_STR_VAL,
1501 .off1 = td_var_offset(offset_increment),
1502 .help = "What is the increment from one offset to the next",
1506 .interval = 1024 * 1024,
1507 .category = FIO_OPT_C_IO,
1508 .group = FIO_OPT_G_INVALID,
1511 .name = "number_ios",
1512 .lname = "Number of IOs to perform",
1513 .type = FIO_OPT_STR_VAL,
1514 .off1 = td_var_offset(number_ios),
1515 .help = "Force job completion after this number of IOs",
1517 .category = FIO_OPT_C_IO,
1518 .group = FIO_OPT_G_INVALID,
1522 .lname = "Block size",
1523 .alias = "blocksize",
1524 .type = FIO_OPT_INT,
1525 .off1 = td_var_offset(bs[DDIR_READ]),
1526 .off2 = td_var_offset(bs[DDIR_WRITE]),
1527 .off3 = td_var_offset(bs[DDIR_TRIM]),
1529 .help = "Block size unit",
1534 .category = FIO_OPT_C_IO,
1535 .group = FIO_OPT_G_INVALID,
1539 .lname = "Block size align",
1540 .alias = "blockalign",
1541 .type = FIO_OPT_INT,
1542 .off1 = td_var_offset(ba[DDIR_READ]),
1543 .off2 = td_var_offset(ba[DDIR_WRITE]),
1544 .off3 = td_var_offset(ba[DDIR_TRIM]),
1546 .help = "IO block offset alignment",
1550 .category = FIO_OPT_C_IO,
1551 .group = FIO_OPT_G_INVALID,
1555 .lname = "Block size range",
1556 .alias = "blocksize_range",
1557 .type = FIO_OPT_RANGE,
1558 .off1 = td_var_offset(min_bs[DDIR_READ]),
1559 .off2 = td_var_offset(max_bs[DDIR_READ]),
1560 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
1561 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
1562 .off5 = td_var_offset(min_bs[DDIR_TRIM]),
1563 .off6 = td_var_offset(max_bs[DDIR_TRIM]),
1565 .help = "Set block size range (in more detail than bs)",
1569 .category = FIO_OPT_C_IO,
1570 .group = FIO_OPT_G_INVALID,
1574 .lname = "Block size split",
1575 .type = FIO_OPT_STR,
1576 .cb = str_bssplit_cb,
1577 .off1 = td_var_offset(bssplit),
1578 .help = "Set a specific mix of block sizes",
1581 .category = FIO_OPT_C_IO,
1582 .group = FIO_OPT_G_INVALID,
1585 .name = "bs_unaligned",
1586 .lname = "Block size unaligned",
1587 .alias = "blocksize_unaligned",
1588 .type = FIO_OPT_STR_SET,
1589 .off1 = td_var_offset(bs_unaligned),
1590 .help = "Don't sector align IO buffer sizes",
1593 .category = FIO_OPT_C_IO,
1594 .group = FIO_OPT_G_INVALID,
1597 .name = "bs_is_seq_rand",
1598 .lname = "Block size division is seq/random (not read/write)",
1599 .type = FIO_OPT_BOOL,
1600 .off1 = td_var_offset(bs_is_seq_rand),
1601 .help = "Consider any blocksize setting to be sequential,random",
1603 .parent = "blocksize",
1604 .category = FIO_OPT_C_IO,
1605 .group = FIO_OPT_G_INVALID,
1608 .name = "randrepeat",
1609 .lname = "Random repeatable",
1610 .type = FIO_OPT_BOOL,
1611 .off1 = td_var_offset(rand_repeatable),
1612 .help = "Use repeatable random IO pattern",
1616 .category = FIO_OPT_C_IO,
1617 .group = FIO_OPT_G_RANDOM,
1621 .lname = "The random generator seed",
1622 .type = FIO_OPT_STR_VAL,
1623 .off1 = td_var_offset(rand_seed),
1624 .help = "Set the random generator seed value",
1627 .category = FIO_OPT_C_IO,
1628 .group = FIO_OPT_G_RANDOM,
1631 .name = "use_os_rand",
1632 .lname = "Use OS random",
1633 .type = FIO_OPT_DEPRECATED,
1634 .off1 = td_var_offset(dep_use_os_rand),
1635 .category = FIO_OPT_C_IO,
1636 .group = FIO_OPT_G_RANDOM,
1639 .name = "norandommap",
1640 .lname = "No randommap",
1641 .type = FIO_OPT_STR_SET,
1642 .off1 = td_var_offset(norandommap),
1643 .help = "Accept potential duplicate random blocks",
1647 .category = FIO_OPT_C_IO,
1648 .group = FIO_OPT_G_RANDOM,
1651 .name = "softrandommap",
1652 .lname = "Soft randommap",
1653 .type = FIO_OPT_BOOL,
1654 .off1 = td_var_offset(softrandommap),
1655 .help = "Set norandommap if randommap allocation fails",
1656 .parent = "norandommap",
1659 .category = FIO_OPT_C_IO,
1660 .group = FIO_OPT_G_RANDOM,
1663 .name = "random_generator",
1664 .type = FIO_OPT_STR,
1665 .off1 = td_var_offset(random_generator),
1666 .help = "Type of random number generator to use",
1667 .def = "tausworthe",
1669 { .ival = "tausworthe",
1670 .oval = FIO_RAND_GEN_TAUSWORTHE,
1671 .help = "Strong Tausworthe generator",
1674 .oval = FIO_RAND_GEN_LFSR,
1675 .help = "Variable length LFSR",
1678 .ival = "tausworthe64",
1679 .oval = FIO_RAND_GEN_TAUSWORTHE64,
1680 .help = "64-bit Tausworthe variant",
1683 .category = FIO_OPT_C_IO,
1684 .group = FIO_OPT_G_RANDOM,
1687 .name = "random_distribution",
1688 .type = FIO_OPT_STR,
1689 .off1 = td_var_offset(random_distribution),
1690 .cb = str_random_distribution_cb,
1691 .help = "Random offset distribution generator",
1695 .oval = FIO_RAND_DIST_RANDOM,
1696 .help = "Completely random",
1699 .oval = FIO_RAND_DIST_ZIPF,
1700 .help = "Zipf distribution",
1703 .oval = FIO_RAND_DIST_PARETO,
1704 .help = "Pareto distribution",
1707 .oval = FIO_RAND_DIST_GAUSS,
1708 .help = "Normal (gaussian) distribution",
1711 .category = FIO_OPT_C_IO,
1712 .group = FIO_OPT_G_RANDOM,
1715 .name = "percentage_random",
1716 .lname = "Percentage Random",
1717 .type = FIO_OPT_INT,
1718 .off1 = td_var_offset(perc_rand[DDIR_READ]),
1719 .off2 = td_var_offset(perc_rand[DDIR_WRITE]),
1720 .off3 = td_var_offset(perc_rand[DDIR_TRIM]),
1722 .help = "Percentage of seq/random mix that should be random",
1723 .def = "100,100,100",
1725 .inverse = "percentage_sequential",
1726 .category = FIO_OPT_C_IO,
1727 .group = FIO_OPT_G_RANDOM,
1730 .name = "percentage_sequential",
1731 .lname = "Percentage Sequential",
1732 .type = FIO_OPT_DEPRECATED,
1733 .category = FIO_OPT_C_IO,
1734 .group = FIO_OPT_G_RANDOM,
1737 .name = "allrandrepeat",
1738 .type = FIO_OPT_BOOL,
1739 .off1 = td_var_offset(allrand_repeatable),
1740 .help = "Use repeatable random numbers for everything",
1742 .category = FIO_OPT_C_IO,
1743 .group = FIO_OPT_G_RANDOM,
1747 .lname = "Number of files",
1748 .alias = "nr_files",
1749 .type = FIO_OPT_INT,
1750 .off1 = td_var_offset(nr_files),
1751 .help = "Split job workload between this number of files",
1754 .category = FIO_OPT_C_FILE,
1755 .group = FIO_OPT_G_INVALID,
1758 .name = "openfiles",
1759 .lname = "Number of open files",
1760 .type = FIO_OPT_INT,
1761 .off1 = td_var_offset(open_files),
1762 .help = "Number of files to keep open at the same time",
1763 .category = FIO_OPT_C_FILE,
1764 .group = FIO_OPT_G_INVALID,
1767 .name = "file_service_type",
1768 .lname = "File service type",
1769 .type = FIO_OPT_STR,
1771 .off1 = td_var_offset(file_service_type),
1772 .help = "How to select which file to service next",
1773 .def = "roundrobin",
1774 .category = FIO_OPT_C_FILE,
1775 .group = FIO_OPT_G_INVALID,
1778 .oval = FIO_FSERVICE_RANDOM,
1779 .help = "Choose a file at random",
1781 { .ival = "roundrobin",
1782 .oval = FIO_FSERVICE_RR,
1783 .help = "Round robin select files",
1785 { .ival = "sequential",
1786 .oval = FIO_FSERVICE_SEQ,
1787 .help = "Finish one file before moving to the next",
1790 .parent = "nrfiles",
1793 #ifdef CONFIG_POSIX_FALLOCATE
1795 .name = "fallocate",
1796 .lname = "Fallocate",
1797 .type = FIO_OPT_STR,
1798 .off1 = td_var_offset(fallocate_mode),
1799 .help = "Whether pre-allocation is performed when laying out files",
1801 .category = FIO_OPT_C_FILE,
1802 .group = FIO_OPT_G_INVALID,
1805 .oval = FIO_FALLOCATE_NONE,
1806 .help = "Do not pre-allocate space",
1809 .oval = FIO_FALLOCATE_POSIX,
1810 .help = "Use posix_fallocate()",
1812 #ifdef CONFIG_LINUX_FALLOCATE
1814 .oval = FIO_FALLOCATE_KEEP_SIZE,
1815 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
1818 /* Compatibility with former boolean values */
1820 .oval = FIO_FALLOCATE_NONE,
1821 .help = "Alias for 'none'",
1824 .oval = FIO_FALLOCATE_POSIX,
1825 .help = "Alias for 'posix'",
1829 #endif /* CONFIG_POSIX_FALLOCATE */
1831 .name = "fadvise_hint",
1832 .lname = "Fadvise hint",
1833 .type = FIO_OPT_BOOL,
1834 .off1 = td_var_offset(fadvise_hint),
1835 .help = "Use fadvise() to advise the kernel on IO pattern",
1837 .category = FIO_OPT_C_FILE,
1838 .group = FIO_OPT_G_INVALID,
1840 #ifdef FIO_HAVE_STREAMID
1842 .name = "fadvise_stream",
1843 .lname = "Fadvise stream",
1844 .type = FIO_OPT_INT,
1845 .off1 = td_var_offset(fadvise_stream),
1846 .help = "Use fadvise() to set stream ID",
1847 .category = FIO_OPT_C_FILE,
1848 .group = FIO_OPT_G_INVALID,
1854 .type = FIO_OPT_INT,
1855 .off1 = td_var_offset(fsync_blocks),
1856 .help = "Issue fsync for writes every given number of blocks",
1859 .category = FIO_OPT_C_FILE,
1860 .group = FIO_OPT_G_INVALID,
1863 .name = "fdatasync",
1864 .lname = "Fdatasync",
1865 .type = FIO_OPT_INT,
1866 .off1 = td_var_offset(fdatasync_blocks),
1867 .help = "Issue fdatasync for writes every given number of blocks",
1870 .category = FIO_OPT_C_FILE,
1871 .group = FIO_OPT_G_INVALID,
1874 .name = "write_barrier",
1875 .lname = "Write barrier",
1876 .type = FIO_OPT_INT,
1877 .off1 = td_var_offset(barrier_blocks),
1878 .help = "Make every Nth write a barrier write",
1881 .category = FIO_OPT_C_IO,
1882 .group = FIO_OPT_G_INVALID,
1884 #ifdef CONFIG_SYNC_FILE_RANGE
1886 .name = "sync_file_range",
1887 .lname = "Sync file range",
1889 { .ival = "wait_before",
1890 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
1891 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
1895 .oval = SYNC_FILE_RANGE_WRITE,
1896 .help = "SYNC_FILE_RANGE_WRITE",
1900 .ival = "wait_after",
1901 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
1902 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
1906 .type = FIO_OPT_STR_MULTI,
1908 .off1 = td_var_offset(sync_file_range),
1909 .help = "Use sync_file_range()",
1910 .category = FIO_OPT_C_FILE,
1911 .group = FIO_OPT_G_INVALID,
1916 .lname = "Direct I/O",
1917 .type = FIO_OPT_BOOL,
1918 .off1 = td_var_offset(odirect),
1919 .help = "Use O_DIRECT IO (negates buffered)",
1921 .inverse = "buffered",
1922 .category = FIO_OPT_C_IO,
1923 .group = FIO_OPT_G_IO_TYPE,
1927 .lname = "Atomic I/O",
1928 .type = FIO_OPT_BOOL,
1929 .off1 = td_var_offset(oatomic),
1930 .help = "Use Atomic IO with O_DIRECT (implies O_DIRECT)",
1932 .category = FIO_OPT_C_IO,
1933 .group = FIO_OPT_G_IO_TYPE,
1937 .lname = "Buffered I/O",
1938 .type = FIO_OPT_BOOL,
1939 .off1 = td_var_offset(odirect),
1941 .help = "Use buffered IO (negates direct)",
1943 .inverse = "direct",
1944 .category = FIO_OPT_C_IO,
1945 .group = FIO_OPT_G_IO_TYPE,
1948 .name = "overwrite",
1949 .lname = "Overwrite",
1950 .type = FIO_OPT_BOOL,
1951 .off1 = td_var_offset(overwrite),
1952 .help = "When writing, set whether to overwrite current data",
1954 .category = FIO_OPT_C_FILE,
1955 .group = FIO_OPT_G_INVALID,
1960 .type = FIO_OPT_INT,
1961 .off1 = td_var_offset(loops),
1962 .help = "Number of times to run the job",
1965 .category = FIO_OPT_C_GENERAL,
1966 .group = FIO_OPT_G_RUNTIME,
1970 .lname = "Number of jobs",
1971 .type = FIO_OPT_INT,
1972 .off1 = td_var_offset(numjobs),
1973 .help = "Duplicate this job this many times",
1976 .category = FIO_OPT_C_GENERAL,
1977 .group = FIO_OPT_G_RUNTIME,
1980 .name = "startdelay",
1981 .lname = "Start delay",
1982 .type = FIO_OPT_STR_VAL_TIME,
1983 .off1 = td_var_offset(start_delay),
1984 .off2 = td_var_offset(start_delay_high),
1985 .help = "Only start job when this period has passed",
1989 .category = FIO_OPT_C_GENERAL,
1990 .group = FIO_OPT_G_RUNTIME,
1996 .type = FIO_OPT_STR_VAL_TIME,
1997 .off1 = td_var_offset(timeout),
1998 .help = "Stop workload when this amount of time has passed",
2002 .category = FIO_OPT_C_GENERAL,
2003 .group = FIO_OPT_G_RUNTIME,
2006 .name = "time_based",
2007 .lname = "Time based",
2008 .type = FIO_OPT_STR_SET,
2009 .off1 = td_var_offset(time_based),
2010 .help = "Keep running until runtime/timeout is met",
2011 .category = FIO_OPT_C_GENERAL,
2012 .group = FIO_OPT_G_RUNTIME,
2015 .name = "verify_only",
2016 .lname = "Verify only",
2017 .type = FIO_OPT_STR_SET,
2018 .off1 = td_var_offset(verify_only),
2019 .help = "Verifies previously written data is still valid",
2020 .category = FIO_OPT_C_GENERAL,
2021 .group = FIO_OPT_G_RUNTIME,
2024 .name = "ramp_time",
2025 .lname = "Ramp time",
2026 .type = FIO_OPT_STR_VAL_TIME,
2027 .off1 = td_var_offset(ramp_time),
2028 .help = "Ramp up time before measuring performance",
2031 .category = FIO_OPT_C_GENERAL,
2032 .group = FIO_OPT_G_RUNTIME,
2035 .name = "clocksource",
2036 .lname = "Clock source",
2037 .type = FIO_OPT_STR,
2038 .cb = fio_clock_source_cb,
2039 .off1 = td_var_offset(clocksource),
2040 .help = "What type of timing source to use",
2041 .category = FIO_OPT_C_GENERAL,
2042 .group = FIO_OPT_G_CLOCK,
2044 #ifdef CONFIG_GETTIMEOFDAY
2045 { .ival = "gettimeofday",
2047 .help = "Use gettimeofday(2) for timing",
2050 #ifdef CONFIG_CLOCK_GETTIME
2051 { .ival = "clock_gettime",
2052 .oval = CS_CGETTIME,
2053 .help = "Use clock_gettime(2) for timing",
2056 #ifdef ARCH_HAVE_CPU_CLOCK
2058 .oval = CS_CPUCLOCK,
2059 .help = "Use CPU private clock",
2067 .lname = "I/O Memory",
2068 .type = FIO_OPT_STR,
2070 .off1 = td_var_offset(mem_type),
2071 .help = "Backing type for IO buffers",
2073 .category = FIO_OPT_C_IO,
2074 .group = FIO_OPT_G_INVALID,
2078 .help = "Use malloc(3) for IO buffers",
2080 #ifndef CONFIG_NO_SHM
2083 .help = "Use shared memory segments for IO buffers",
2085 #ifdef FIO_HAVE_HUGETLB
2086 { .ival = "shmhuge",
2087 .oval = MEM_SHMHUGE,
2088 .help = "Like shm, but use huge pages",
2094 .help = "Use mmap(2) (file or anon) for IO buffers",
2096 { .ival = "mmapshared",
2097 .oval = MEM_MMAPSHARED,
2098 .help = "Like mmap, but use the shared flag",
2100 #ifdef FIO_HAVE_HUGETLB
2101 { .ival = "mmaphuge",
2102 .oval = MEM_MMAPHUGE,
2103 .help = "Like mmap, but use huge pages",
2109 .name = "iomem_align",
2110 .alias = "mem_align",
2111 .lname = "I/O memory alignment",
2112 .type = FIO_OPT_INT,
2113 .off1 = td_var_offset(mem_align),
2115 .help = "IO memory buffer offset alignment",
2119 .category = FIO_OPT_C_IO,
2120 .group = FIO_OPT_G_INVALID,
2125 .type = FIO_OPT_STR,
2126 .off1 = td_var_offset(verify),
2127 .help = "Verify data written",
2129 .category = FIO_OPT_C_IO,
2130 .group = FIO_OPT_G_VERIFY,
2133 .oval = VERIFY_NONE,
2134 .help = "Don't do IO verification",
2138 .help = "Use md5 checksums for verification",
2141 .oval = VERIFY_CRC64,
2142 .help = "Use crc64 checksums for verification",
2145 .oval = VERIFY_CRC32,
2146 .help = "Use crc32 checksums for verification",
2148 { .ival = "crc32c-intel",
2149 .oval = VERIFY_CRC32C,
2150 .help = "Use crc32c checksums for verification (hw assisted, if available)",
2153 .oval = VERIFY_CRC32C,
2154 .help = "Use crc32c checksums for verification (hw assisted, if available)",
2157 .oval = VERIFY_CRC16,
2158 .help = "Use crc16 checksums for verification",
2161 .oval = VERIFY_CRC7,
2162 .help = "Use crc7 checksums for verification",
2165 .oval = VERIFY_SHA1,
2166 .help = "Use sha1 checksums for verification",
2169 .oval = VERIFY_SHA256,
2170 .help = "Use sha256 checksums for verification",
2173 .oval = VERIFY_SHA512,
2174 .help = "Use sha512 checksums for verification",
2177 .oval = VERIFY_XXHASH,
2178 .help = "Use xxhash checksums for verification",
2180 /* Meta information was included into verify_header,
2181 * 'meta' verification is implied by default. */
2183 .oval = VERIFY_HDR_ONLY,
2184 .help = "Use io information for verification. "
2185 "Now is implied by default, thus option is obsolete, "
2188 { .ival = "pattern",
2189 .oval = VERIFY_PATTERN_NO_HDR,
2190 .help = "Verify strict pattern",
2194 .oval = VERIFY_NULL,
2195 .help = "Pretend to verify",
2200 .name = "do_verify",
2201 .lname = "Perform verify step",
2202 .type = FIO_OPT_BOOL,
2203 .off1 = td_var_offset(do_verify),
2204 .help = "Run verification stage after write",
2208 .category = FIO_OPT_C_IO,
2209 .group = FIO_OPT_G_VERIFY,
2212 .name = "verifysort",
2213 .lname = "Verify sort",
2214 .type = FIO_OPT_BOOL,
2215 .off1 = td_var_offset(verifysort),
2216 .help = "Sort written verify blocks for read back",
2220 .category = FIO_OPT_C_IO,
2221 .group = FIO_OPT_G_VERIFY,
2224 .name = "verifysort_nr",
2225 .type = FIO_OPT_INT,
2226 .off1 = td_var_offset(verifysort_nr),
2227 .help = "Pre-load and sort verify blocks for a read workload",
2232 .category = FIO_OPT_C_IO,
2233 .group = FIO_OPT_G_VERIFY,
2236 .name = "verify_interval",
2237 .lname = "Verify interval",
2238 .type = FIO_OPT_INT,
2239 .off1 = td_var_offset(verify_interval),
2240 .minval = 2 * sizeof(struct verify_header),
2241 .help = "Store verify buffer header every N bytes",
2244 .interval = 2 * sizeof(struct verify_header),
2245 .category = FIO_OPT_C_IO,
2246 .group = FIO_OPT_G_VERIFY,
2249 .name = "verify_offset",
2250 .lname = "Verify offset",
2251 .type = FIO_OPT_INT,
2252 .help = "Offset verify header location by N bytes",
2253 .off1 = td_var_offset(verify_offset),
2254 .minval = sizeof(struct verify_header),
2257 .category = FIO_OPT_C_IO,
2258 .group = FIO_OPT_G_VERIFY,
2261 .name = "verify_pattern",
2262 .lname = "Verify pattern",
2263 .type = FIO_OPT_STR,
2264 .cb = str_verify_pattern_cb,
2265 .off1 = td_var_offset(verify_pattern),
2266 .help = "Fill pattern for IO buffers",
2269 .category = FIO_OPT_C_IO,
2270 .group = FIO_OPT_G_VERIFY,
2273 .name = "verify_fatal",
2274 .lname = "Verify fatal",
2275 .type = FIO_OPT_BOOL,
2276 .off1 = td_var_offset(verify_fatal),
2278 .help = "Exit on a single verify failure, don't continue",
2281 .category = FIO_OPT_C_IO,
2282 .group = FIO_OPT_G_VERIFY,
2285 .name = "verify_dump",
2286 .lname = "Verify dump",
2287 .type = FIO_OPT_BOOL,
2288 .off1 = td_var_offset(verify_dump),
2290 .help = "Dump contents of good and bad blocks on failure",
2293 .category = FIO_OPT_C_IO,
2294 .group = FIO_OPT_G_VERIFY,
2297 .name = "verify_async",
2298 .lname = "Verify asynchronously",
2299 .type = FIO_OPT_INT,
2300 .off1 = td_var_offset(verify_async),
2302 .help = "Number of async verifier threads to use",
2305 .category = FIO_OPT_C_IO,
2306 .group = FIO_OPT_G_VERIFY,
2309 .name = "verify_backlog",
2310 .lname = "Verify backlog",
2311 .type = FIO_OPT_STR_VAL,
2312 .off1 = td_var_offset(verify_backlog),
2313 .help = "Verify after this number of blocks are written",
2316 .category = FIO_OPT_C_IO,
2317 .group = FIO_OPT_G_VERIFY,
2320 .name = "verify_backlog_batch",
2321 .lname = "Verify backlog batch",
2322 .type = FIO_OPT_INT,
2323 .off1 = td_var_offset(verify_batch),
2324 .help = "Verify this number of IO blocks",
2327 .category = FIO_OPT_C_IO,
2328 .group = FIO_OPT_G_VERIFY,
2330 #ifdef FIO_HAVE_CPU_AFFINITY
2332 .name = "verify_async_cpus",
2333 .lname = "Async verify CPUs",
2334 .type = FIO_OPT_STR,
2335 .cb = str_verify_cpus_allowed_cb,
2336 .off1 = td_var_offset(verify_cpumask),
2337 .help = "Set CPUs allowed for async verify threads",
2338 .parent = "verify_async",
2340 .category = FIO_OPT_C_IO,
2341 .group = FIO_OPT_G_VERIFY,
2345 .name = "experimental_verify",
2346 .off1 = td_var_offset(experimental_verify),
2347 .type = FIO_OPT_BOOL,
2348 .help = "Enable experimental verification",
2350 .category = FIO_OPT_C_IO,
2351 .group = FIO_OPT_G_VERIFY,
2354 .name = "verify_state_load",
2355 .lname = "Load verify state",
2356 .off1 = td_var_offset(verify_state),
2357 .type = FIO_OPT_BOOL,
2358 .help = "Load verify termination state",
2360 .category = FIO_OPT_C_IO,
2361 .group = FIO_OPT_G_VERIFY,
2364 .name = "verify_state_save",
2365 .lname = "Save verify state",
2366 .off1 = td_var_offset(verify_state_save),
2367 .type = FIO_OPT_BOOL,
2369 .help = "Save verify state on termination",
2371 .category = FIO_OPT_C_IO,
2372 .group = FIO_OPT_G_VERIFY,
2374 #ifdef FIO_HAVE_TRIM
2376 .name = "trim_percentage",
2377 .lname = "Trim percentage",
2378 .type = FIO_OPT_INT,
2379 .off1 = td_var_offset(trim_percentage),
2382 .help = "Number of verify blocks to discard/trim",
2387 .category = FIO_OPT_C_IO,
2388 .group = FIO_OPT_G_TRIM,
2391 .name = "trim_verify_zero",
2392 .lname = "Verify trim zero",
2393 .type = FIO_OPT_BOOL,
2394 .help = "Verify that trim/discarded blocks are returned as zeroes",
2395 .off1 = td_var_offset(trim_zero),
2396 .parent = "trim_percentage",
2399 .category = FIO_OPT_C_IO,
2400 .group = FIO_OPT_G_TRIM,
2403 .name = "trim_backlog",
2404 .lname = "Trim backlog",
2405 .type = FIO_OPT_STR_VAL,
2406 .off1 = td_var_offset(trim_backlog),
2407 .help = "Trim after this number of blocks are written",
2408 .parent = "trim_percentage",
2411 .category = FIO_OPT_C_IO,
2412 .group = FIO_OPT_G_TRIM,
2415 .name = "trim_backlog_batch",
2416 .lname = "Trim backlog batch",
2417 .type = FIO_OPT_INT,
2418 .off1 = td_var_offset(trim_batch),
2419 .help = "Trim this number of IO blocks",
2420 .parent = "trim_percentage",
2423 .category = FIO_OPT_C_IO,
2424 .group = FIO_OPT_G_TRIM,
2428 .name = "write_iolog",
2429 .lname = "Write I/O log",
2430 .type = FIO_OPT_STR_STORE,
2431 .off1 = td_var_offset(write_iolog_file),
2432 .help = "Store IO pattern to file",
2433 .category = FIO_OPT_C_IO,
2434 .group = FIO_OPT_G_IOLOG,
2437 .name = "read_iolog",
2438 .lname = "Read I/O log",
2439 .type = FIO_OPT_STR_STORE,
2440 .off1 = td_var_offset(read_iolog_file),
2441 .help = "Playback IO pattern from file",
2442 .category = FIO_OPT_C_IO,
2443 .group = FIO_OPT_G_IOLOG,
2446 .name = "replay_no_stall",
2447 .lname = "Don't stall on replay",
2448 .type = FIO_OPT_BOOL,
2449 .off1 = td_var_offset(no_stall),
2451 .parent = "read_iolog",
2453 .help = "Playback IO pattern file as fast as possible without stalls",
2454 .category = FIO_OPT_C_IO,
2455 .group = FIO_OPT_G_IOLOG,
2458 .name = "replay_redirect",
2459 .lname = "Redirect device for replay",
2460 .type = FIO_OPT_STR_STORE,
2461 .off1 = td_var_offset(replay_redirect),
2462 .parent = "read_iolog",
2464 .help = "Replay all I/O onto this device, regardless of trace device",
2465 .category = FIO_OPT_C_IO,
2466 .group = FIO_OPT_G_IOLOG,
2469 .name = "replay_scale",
2470 .lname = "Replace offset scale factor",
2471 .type = FIO_OPT_INT,
2472 .off1 = td_var_offset(replay_scale),
2473 .parent = "read_iolog",
2475 .help = "Align offsets to this blocksize",
2476 .category = FIO_OPT_C_IO,
2477 .group = FIO_OPT_G_IOLOG,
2480 .name = "replay_align",
2481 .lname = "Replace alignment",
2482 .type = FIO_OPT_INT,
2483 .off1 = td_var_offset(replay_align),
2484 .parent = "read_iolog",
2485 .help = "Scale offset down by this factor",
2486 .category = FIO_OPT_C_IO,
2487 .group = FIO_OPT_G_IOLOG,
2491 .name = "exec_prerun",
2492 .lname = "Pre-execute runnable",
2493 .type = FIO_OPT_STR_STORE,
2494 .off1 = td_var_offset(exec_prerun),
2495 .help = "Execute this file prior to running job",
2496 .category = FIO_OPT_C_GENERAL,
2497 .group = FIO_OPT_G_INVALID,
2500 .name = "exec_postrun",
2501 .lname = "Post-execute runnable",
2502 .type = FIO_OPT_STR_STORE,
2503 .off1 = td_var_offset(exec_postrun),
2504 .help = "Execute this file after running job",
2505 .category = FIO_OPT_C_GENERAL,
2506 .group = FIO_OPT_G_INVALID,
2508 #ifdef FIO_HAVE_IOSCHED_SWITCH
2510 .name = "ioscheduler",
2511 .lname = "I/O scheduler",
2512 .type = FIO_OPT_STR_STORE,
2513 .off1 = td_var_offset(ioscheduler),
2514 .help = "Use this IO scheduler on the backing device",
2515 .category = FIO_OPT_C_FILE,
2516 .group = FIO_OPT_G_INVALID,
2521 .lname = "Zone size",
2522 .type = FIO_OPT_STR_VAL,
2523 .off1 = td_var_offset(zone_size),
2524 .help = "Amount of data to read per zone",
2526 .interval = 1024 * 1024,
2527 .category = FIO_OPT_C_IO,
2528 .group = FIO_OPT_G_ZONE,
2531 .name = "zonerange",
2532 .lname = "Zone range",
2533 .type = FIO_OPT_STR_VAL,
2534 .off1 = td_var_offset(zone_range),
2535 .help = "Give size of an IO zone",
2537 .interval = 1024 * 1024,
2538 .category = FIO_OPT_C_IO,
2539 .group = FIO_OPT_G_ZONE,
2543 .lname = "Zone skip",
2544 .type = FIO_OPT_STR_VAL,
2545 .off1 = td_var_offset(zone_skip),
2546 .help = "Space between IO zones",
2548 .interval = 1024 * 1024,
2549 .category = FIO_OPT_C_IO,
2550 .group = FIO_OPT_G_ZONE,
2554 .lname = "Lock memory",
2555 .type = FIO_OPT_STR_VAL,
2556 .off1 = td_var_offset(lockmem),
2557 .help = "Lock down this amount of memory (per worker)",
2559 .interval = 1024 * 1024,
2560 .category = FIO_OPT_C_GENERAL,
2561 .group = FIO_OPT_G_INVALID,
2564 .name = "rwmixread",
2565 .lname = "Read/write mix read",
2566 .type = FIO_OPT_INT,
2567 .cb = str_rwmix_read_cb,
2568 .off1 = td_var_offset(rwmix[DDIR_READ]),
2570 .help = "Percentage of mixed workload that is reads",
2573 .inverse = "rwmixwrite",
2574 .category = FIO_OPT_C_IO,
2575 .group = FIO_OPT_G_RWMIX,
2578 .name = "rwmixwrite",
2579 .lname = "Read/write mix write",
2580 .type = FIO_OPT_INT,
2581 .cb = str_rwmix_write_cb,
2582 .off1 = td_var_offset(rwmix[DDIR_WRITE]),
2584 .help = "Percentage of mixed workload that is writes",
2587 .inverse = "rwmixread",
2588 .category = FIO_OPT_C_IO,
2589 .group = FIO_OPT_G_RWMIX,
2592 .name = "rwmixcycle",
2593 .lname = "Read/write mix cycle",
2594 .type = FIO_OPT_DEPRECATED,
2595 .category = FIO_OPT_C_IO,
2596 .group = FIO_OPT_G_RWMIX,
2601 .type = FIO_OPT_INT,
2602 .off1 = td_var_offset(nice),
2603 .help = "Set job CPU nice value",
2608 .category = FIO_OPT_C_GENERAL,
2609 .group = FIO_OPT_G_CRED,
2611 #ifdef FIO_HAVE_IOPRIO
2614 .lname = "I/O nice priority",
2615 .type = FIO_OPT_INT,
2616 .off1 = td_var_offset(ioprio),
2617 .help = "Set job IO priority value",
2621 .category = FIO_OPT_C_GENERAL,
2622 .group = FIO_OPT_G_CRED,
2625 .name = "prioclass",
2626 .lname = "I/O nice priority class",
2627 .type = FIO_OPT_INT,
2628 .off1 = td_var_offset(ioprio_class),
2629 .help = "Set job IO priority class",
2633 .category = FIO_OPT_C_GENERAL,
2634 .group = FIO_OPT_G_CRED,
2638 .name = "thinktime",
2639 .lname = "Thinktime",
2640 .type = FIO_OPT_INT,
2641 .off1 = td_var_offset(thinktime),
2642 .help = "Idle time between IO buffers (usec)",
2645 .category = FIO_OPT_C_IO,
2646 .group = FIO_OPT_G_THINKTIME,
2649 .name = "thinktime_spin",
2650 .lname = "Thinktime spin",
2651 .type = FIO_OPT_INT,
2652 .off1 = td_var_offset(thinktime_spin),
2653 .help = "Start think time by spinning this amount (usec)",
2656 .parent = "thinktime",
2658 .category = FIO_OPT_C_IO,
2659 .group = FIO_OPT_G_THINKTIME,
2662 .name = "thinktime_blocks",
2663 .lname = "Thinktime blocks",
2664 .type = FIO_OPT_INT,
2665 .off1 = td_var_offset(thinktime_blocks),
2666 .help = "IO buffer period between 'thinktime'",
2668 .parent = "thinktime",
2670 .category = FIO_OPT_C_IO,
2671 .group = FIO_OPT_G_THINKTIME,
2675 .lname = "I/O rate",
2676 .type = FIO_OPT_INT,
2677 .off1 = td_var_offset(rate[DDIR_READ]),
2678 .off2 = td_var_offset(rate[DDIR_WRITE]),
2679 .off3 = td_var_offset(rate[DDIR_TRIM]),
2680 .help = "Set bandwidth rate",
2681 .category = FIO_OPT_C_IO,
2682 .group = FIO_OPT_G_RATE,
2687 .lname = "I/O min rate",
2688 .type = FIO_OPT_INT,
2689 .off1 = td_var_offset(ratemin[DDIR_READ]),
2690 .off2 = td_var_offset(ratemin[DDIR_WRITE]),
2691 .off3 = td_var_offset(ratemin[DDIR_TRIM]),
2692 .help = "Job must meet this rate or it will be shutdown",
2695 .category = FIO_OPT_C_IO,
2696 .group = FIO_OPT_G_RATE,
2699 .name = "rate_iops",
2700 .lname = "I/O rate IOPS",
2701 .type = FIO_OPT_INT,
2702 .off1 = td_var_offset(rate_iops[DDIR_READ]),
2703 .off2 = td_var_offset(rate_iops[DDIR_WRITE]),
2704 .off3 = td_var_offset(rate_iops[DDIR_TRIM]),
2705 .help = "Limit IO used to this number of IO operations/sec",
2707 .category = FIO_OPT_C_IO,
2708 .group = FIO_OPT_G_RATE,
2711 .name = "rate_iops_min",
2712 .lname = "I/O min rate IOPS",
2713 .type = FIO_OPT_INT,
2714 .off1 = td_var_offset(rate_iops_min[DDIR_READ]),
2715 .off2 = td_var_offset(rate_iops_min[DDIR_WRITE]),
2716 .off3 = td_var_offset(rate_iops_min[DDIR_TRIM]),
2717 .help = "Job must meet this rate or it will be shut down",
2718 .parent = "rate_iops",
2720 .category = FIO_OPT_C_IO,
2721 .group = FIO_OPT_G_RATE,
2724 .name = "rate_process",
2725 .lname = "Rate Process",
2726 .type = FIO_OPT_STR,
2727 .off1 = td_var_offset(rate_process),
2728 .help = "What process controls how rated IO is managed",
2730 .category = FIO_OPT_C_IO,
2731 .group = FIO_OPT_G_RATE,
2734 .oval = RATE_PROCESS_LINEAR,
2735 .help = "Linear rate of IO",
2739 .oval = RATE_PROCESS_POISSON,
2740 .help = "Rate follows Poisson process",
2746 .name = "rate_cycle",
2747 .alias = "ratecycle",
2748 .lname = "I/O rate cycle",
2749 .type = FIO_OPT_INT,
2750 .off1 = td_var_offset(ratecycle),
2751 .help = "Window average for rate limits (msec)",
2755 .category = FIO_OPT_C_IO,
2756 .group = FIO_OPT_G_RATE,
2759 .name = "max_latency",
2760 .type = FIO_OPT_INT,
2761 .off1 = td_var_offset(max_latency),
2762 .help = "Maximum tolerated IO latency (usec)",
2764 .category = FIO_OPT_C_IO,
2765 .group = FIO_OPT_G_LATPROF,
2768 .name = "latency_target",
2769 .lname = "Latency Target (usec)",
2770 .type = FIO_OPT_STR_VAL_TIME,
2771 .off1 = td_var_offset(latency_target),
2772 .help = "Ramp to max queue depth supporting this latency",
2774 .category = FIO_OPT_C_IO,
2775 .group = FIO_OPT_G_LATPROF,
2778 .name = "latency_window",
2779 .lname = "Latency Window (usec)",
2780 .type = FIO_OPT_STR_VAL_TIME,
2781 .off1 = td_var_offset(latency_window),
2782 .help = "Time to sustain latency_target",
2784 .category = FIO_OPT_C_IO,
2785 .group = FIO_OPT_G_LATPROF,
2788 .name = "latency_percentile",
2789 .lname = "Latency Percentile",
2790 .type = FIO_OPT_FLOAT_LIST,
2791 .off1 = td_var_offset(latency_percentile),
2792 .help = "Percentile of IOs must be below latency_target",
2797 .category = FIO_OPT_C_IO,
2798 .group = FIO_OPT_G_LATPROF,
2801 .name = "invalidate",
2802 .lname = "Cache invalidate",
2803 .type = FIO_OPT_BOOL,
2804 .off1 = td_var_offset(invalidate_cache),
2805 .help = "Invalidate buffer/page cache prior to running job",
2807 .category = FIO_OPT_C_IO,
2808 .group = FIO_OPT_G_IO_TYPE,
2812 .lname = "Synchronous I/O",
2813 .type = FIO_OPT_BOOL,
2814 .off1 = td_var_offset(sync_io),
2815 .help = "Use O_SYNC for buffered writes",
2817 .parent = "buffered",
2819 .category = FIO_OPT_C_IO,
2820 .group = FIO_OPT_G_IO_TYPE,
2823 .name = "create_serialize",
2824 .lname = "Create serialize",
2825 .type = FIO_OPT_BOOL,
2826 .off1 = td_var_offset(create_serialize),
2827 .help = "Serialize creating of job files",
2829 .category = FIO_OPT_C_FILE,
2830 .group = FIO_OPT_G_INVALID,
2833 .name = "create_fsync",
2834 .lname = "Create fsync",
2835 .type = FIO_OPT_BOOL,
2836 .off1 = td_var_offset(create_fsync),
2837 .help = "fsync file after creation",
2839 .category = FIO_OPT_C_FILE,
2840 .group = FIO_OPT_G_INVALID,
2843 .name = "create_on_open",
2844 .lname = "Create on open",
2845 .type = FIO_OPT_BOOL,
2846 .off1 = td_var_offset(create_on_open),
2847 .help = "Create files when they are opened for IO",
2849 .category = FIO_OPT_C_FILE,
2850 .group = FIO_OPT_G_INVALID,
2853 .name = "create_only",
2854 .type = FIO_OPT_BOOL,
2855 .off1 = td_var_offset(create_only),
2856 .help = "Only perform file creation phase",
2857 .category = FIO_OPT_C_FILE,
2861 .name = "allow_file_create",
2862 .lname = "Allow file create",
2863 .type = FIO_OPT_BOOL,
2864 .off1 = td_var_offset(allow_create),
2865 .help = "Permit fio to create files, if they don't exist",
2867 .category = FIO_OPT_C_FILE,
2868 .group = FIO_OPT_G_FILENAME,
2871 .name = "allow_mounted_write",
2872 .lname = "Allow mounted write",
2873 .type = FIO_OPT_BOOL,
2874 .off1 = td_var_offset(allow_mounted_write),
2875 .help = "Allow writes to a mounted partition",
2877 .category = FIO_OPT_C_FILE,
2878 .group = FIO_OPT_G_FILENAME,
2882 .lname = "Pre-read files",
2883 .type = FIO_OPT_BOOL,
2884 .off1 = td_var_offset(pre_read),
2885 .help = "Pre-read files before starting official testing",
2887 .category = FIO_OPT_C_FILE,
2888 .group = FIO_OPT_G_INVALID,
2890 #ifdef FIO_HAVE_CPU_AFFINITY
2893 .lname = "CPU mask",
2894 .type = FIO_OPT_INT,
2895 .cb = str_cpumask_cb,
2896 .off1 = td_var_offset(cpumask),
2897 .help = "CPU affinity mask",
2898 .category = FIO_OPT_C_GENERAL,
2899 .group = FIO_OPT_G_CRED,
2902 .name = "cpus_allowed",
2903 .lname = "CPUs allowed",
2904 .type = FIO_OPT_STR,
2905 .cb = str_cpus_allowed_cb,
2906 .off1 = td_var_offset(cpumask),
2907 .help = "Set CPUs allowed",
2908 .category = FIO_OPT_C_GENERAL,
2909 .group = FIO_OPT_G_CRED,
2912 .name = "cpus_allowed_policy",
2913 .lname = "CPUs allowed distribution policy",
2914 .type = FIO_OPT_STR,
2915 .off1 = td_var_offset(cpus_allowed_policy),
2916 .help = "Distribution policy for cpus_allowed",
2917 .parent = "cpus_allowed",
2921 .oval = FIO_CPUS_SHARED,
2922 .help = "Mask shared between threads",
2925 .oval = FIO_CPUS_SPLIT,
2926 .help = "Mask split between threads",
2929 .category = FIO_OPT_C_GENERAL,
2930 .group = FIO_OPT_G_CRED,
2933 #ifdef CONFIG_LIBNUMA
2935 .name = "numa_cpu_nodes",
2936 .type = FIO_OPT_STR,
2937 .cb = str_numa_cpunodes_cb,
2938 .off1 = td_var_offset(numa_cpunodes),
2939 .help = "NUMA CPU nodes bind",
2940 .category = FIO_OPT_C_GENERAL,
2941 .group = FIO_OPT_G_INVALID,
2944 .name = "numa_mem_policy",
2945 .type = FIO_OPT_STR,
2946 .cb = str_numa_mpol_cb,
2947 .off1 = td_var_offset(numa_memnodes),
2948 .help = "NUMA memory policy setup",
2949 .category = FIO_OPT_C_GENERAL,
2950 .group = FIO_OPT_G_INVALID,
2954 .name = "end_fsync",
2955 .lname = "End fsync",
2956 .type = FIO_OPT_BOOL,
2957 .off1 = td_var_offset(end_fsync),
2958 .help = "Include fsync at the end of job",
2960 .category = FIO_OPT_C_FILE,
2961 .group = FIO_OPT_G_INVALID,
2964 .name = "fsync_on_close",
2965 .lname = "Fsync on close",
2966 .type = FIO_OPT_BOOL,
2967 .off1 = td_var_offset(fsync_on_close),
2968 .help = "fsync files on close",
2970 .category = FIO_OPT_C_FILE,
2971 .group = FIO_OPT_G_INVALID,
2975 .lname = "Unlink file",
2976 .type = FIO_OPT_BOOL,
2977 .off1 = td_var_offset(unlink),
2978 .help = "Unlink created files after job has completed",
2980 .category = FIO_OPT_C_FILE,
2981 .group = FIO_OPT_G_INVALID,
2985 .lname = "Exit-all on terminate",
2986 .type = FIO_OPT_STR_SET,
2987 .cb = str_exitall_cb,
2988 .help = "Terminate all jobs when one exits",
2989 .category = FIO_OPT_C_GENERAL,
2990 .group = FIO_OPT_G_PROCESS,
2993 .name = "exitall_on_error",
2994 .lname = "Exit-all on terminate in error",
2995 .type = FIO_OPT_BOOL,
2996 .off1 = td_var_offset(unlink),
2997 .help = "Terminate all jobs when one exits in error",
2998 .category = FIO_OPT_C_GENERAL,
2999 .group = FIO_OPT_G_PROCESS,
3002 .name = "stonewall",
3003 .lname = "Wait for previous",
3004 .alias = "wait_for_previous",
3005 .type = FIO_OPT_STR_SET,
3006 .off1 = td_var_offset(stonewall),
3007 .help = "Insert a hard barrier between this job and previous",
3008 .category = FIO_OPT_C_GENERAL,
3009 .group = FIO_OPT_G_PROCESS,
3012 .name = "new_group",
3013 .lname = "New group",
3014 .type = FIO_OPT_STR_SET,
3015 .off1 = td_var_offset(new_group),
3016 .help = "Mark the start of a new group (for reporting)",
3017 .category = FIO_OPT_C_GENERAL,
3018 .group = FIO_OPT_G_PROCESS,
3023 .type = FIO_OPT_STR_SET,
3024 .off1 = td_var_offset(use_thread),
3025 .help = "Use threads instead of processes",
3026 #ifdef CONFIG_NO_SHM
3030 .category = FIO_OPT_C_GENERAL,
3031 .group = FIO_OPT_G_PROCESS,
3034 .name = "per_job_logs",
3035 .type = FIO_OPT_BOOL,
3036 .off1 = td_var_offset(per_job_logs),
3037 .help = "Include job number in generated log files or not",
3039 .category = FIO_OPT_C_LOG,
3040 .group = FIO_OPT_G_INVALID,
3043 .name = "write_bw_log",
3044 .lname = "Write bandwidth log",
3045 .type = FIO_OPT_STR_STORE,
3046 .off1 = td_var_offset(bw_log_file),
3047 .help = "Write log of bandwidth during run",
3048 .category = FIO_OPT_C_LOG,
3049 .group = FIO_OPT_G_INVALID,
3052 .name = "write_lat_log",
3053 .lname = "Write latency log",
3054 .type = FIO_OPT_STR_STORE,
3055 .off1 = td_var_offset(lat_log_file),
3056 .help = "Write log of latency during run",
3057 .category = FIO_OPT_C_LOG,
3058 .group = FIO_OPT_G_INVALID,
3061 .name = "write_iops_log",
3062 .lname = "Write IOPS log",
3063 .type = FIO_OPT_STR_STORE,
3064 .off1 = td_var_offset(iops_log_file),
3065 .help = "Write log of IOPS during run",
3066 .category = FIO_OPT_C_LOG,
3067 .group = FIO_OPT_G_INVALID,
3070 .name = "log_avg_msec",
3071 .lname = "Log averaging (msec)",
3072 .type = FIO_OPT_INT,
3073 .off1 = td_var_offset(log_avg_msec),
3074 .help = "Average bw/iops/lat logs over this period of time",
3076 .category = FIO_OPT_C_LOG,
3077 .group = FIO_OPT_G_INVALID,
3080 .name = "log_offset",
3081 .lname = "Log offset of IO",
3082 .type = FIO_OPT_BOOL,
3083 .off1 = td_var_offset(log_offset),
3084 .help = "Include offset of IO for each log entry",
3086 .category = FIO_OPT_C_LOG,
3087 .group = FIO_OPT_G_INVALID,
3091 .name = "log_compression",
3092 .lname = "Log compression",
3093 .type = FIO_OPT_INT,
3094 .off1 = td_var_offset(log_gz),
3095 .help = "Log in compressed chunks of this size",
3097 .maxval = 512 * 1024 * 1024ULL,
3098 .category = FIO_OPT_C_LOG,
3099 .group = FIO_OPT_G_INVALID,
3101 #ifdef FIO_HAVE_CPU_AFFINITY
3103 .name = "log_compression_cpus",
3104 .lname = "Log Compression CPUs",
3105 .type = FIO_OPT_STR,
3106 .cb = str_log_cpus_allowed_cb,
3107 .off1 = td_var_offset(log_gz_cpumask),
3108 .parent = "log_compression",
3109 .help = "Limit log compression to these CPUs",
3110 .category = FIO_OPT_C_LOG,
3111 .group = FIO_OPT_G_INVALID,
3115 .name = "log_store_compressed",
3116 .lname = "Log store compressed",
3117 .type = FIO_OPT_BOOL,
3118 .off1 = td_var_offset(log_gz_store),
3119 .help = "Store logs in a compressed format",
3120 .category = FIO_OPT_C_LOG,
3121 .group = FIO_OPT_G_INVALID,
3125 .name = "block_error_percentiles",
3126 .lname = "Block error percentiles",
3127 .type = FIO_OPT_BOOL,
3128 .off1 = td_var_offset(block_error_hist),
3129 .help = "Record trim block errors and make a histogram",
3131 .category = FIO_OPT_C_LOG,
3132 .group = FIO_OPT_G_INVALID,
3135 .name = "bwavgtime",
3136 .lname = "Bandwidth average time",
3137 .type = FIO_OPT_INT,
3138 .off1 = td_var_offset(bw_avg_time),
3139 .help = "Time window over which to calculate bandwidth"
3142 .parent = "write_bw_log",
3145 .category = FIO_OPT_C_LOG,
3146 .group = FIO_OPT_G_INVALID,
3149 .name = "iopsavgtime",
3150 .lname = "IOPS average time",
3151 .type = FIO_OPT_INT,
3152 .off1 = td_var_offset(iops_avg_time),
3153 .help = "Time window over which to calculate IOPS (msec)",
3155 .parent = "write_iops_log",
3158 .category = FIO_OPT_C_LOG,
3159 .group = FIO_OPT_G_INVALID,
3162 .name = "group_reporting",
3163 .lname = "Group reporting",
3164 .type = FIO_OPT_STR_SET,
3165 .off1 = td_var_offset(group_reporting),
3166 .help = "Do reporting on a per-group basis",
3167 .category = FIO_OPT_C_STAT,
3168 .group = FIO_OPT_G_INVALID,
3171 .name = "zero_buffers",
3172 .lname = "Zero I/O buffers",
3173 .type = FIO_OPT_STR_SET,
3174 .off1 = td_var_offset(zero_buffers),
3175 .help = "Init IO buffers to all zeroes",
3176 .category = FIO_OPT_C_IO,
3177 .group = FIO_OPT_G_IO_BUF,
3180 .name = "refill_buffers",
3181 .lname = "Refill I/O buffers",
3182 .type = FIO_OPT_STR_SET,
3183 .off1 = td_var_offset(refill_buffers),
3184 .help = "Refill IO buffers on every IO submit",
3185 .category = FIO_OPT_C_IO,
3186 .group = FIO_OPT_G_IO_BUF,
3189 .name = "scramble_buffers",
3190 .lname = "Scramble I/O buffers",
3191 .type = FIO_OPT_BOOL,
3192 .off1 = td_var_offset(scramble_buffers),
3193 .help = "Slightly scramble buffers on every IO submit",
3195 .category = FIO_OPT_C_IO,
3196 .group = FIO_OPT_G_IO_BUF,
3199 .name = "buffer_pattern",
3200 .lname = "Buffer pattern",
3201 .type = FIO_OPT_STR,
3202 .cb = str_buffer_pattern_cb,
3203 .off1 = td_var_offset(buffer_pattern),
3204 .help = "Fill pattern for IO buffers",
3205 .category = FIO_OPT_C_IO,
3206 .group = FIO_OPT_G_IO_BUF,
3209 .name = "buffer_compress_percentage",
3210 .lname = "Buffer compression percentage",
3211 .type = FIO_OPT_INT,
3212 .cb = str_buffer_compress_cb,
3213 .off1 = td_var_offset(compress_percentage),
3216 .help = "How compressible the buffer is (approximately)",
3218 .category = FIO_OPT_C_IO,
3219 .group = FIO_OPT_G_IO_BUF,
3222 .name = "buffer_compress_chunk",
3223 .lname = "Buffer compression chunk size",
3224 .type = FIO_OPT_INT,
3225 .off1 = td_var_offset(compress_chunk),
3226 .parent = "buffer_compress_percentage",
3228 .help = "Size of compressible region in buffer",
3230 .category = FIO_OPT_C_IO,
3231 .group = FIO_OPT_G_IO_BUF,
3234 .name = "dedupe_percentage",
3235 .lname = "Dedupe percentage",
3236 .type = FIO_OPT_INT,
3237 .cb = str_dedupe_cb,
3238 .off1 = td_var_offset(dedupe_percentage),
3241 .help = "Percentage of buffers that are dedupable",
3243 .category = FIO_OPT_C_IO,
3244 .group = FIO_OPT_G_IO_BUF,
3247 .name = "clat_percentiles",
3248 .lname = "Completion latency percentiles",
3249 .type = FIO_OPT_BOOL,
3250 .off1 = td_var_offset(clat_percentiles),
3251 .help = "Enable the reporting of completion latency percentiles",
3253 .category = FIO_OPT_C_STAT,
3254 .group = FIO_OPT_G_INVALID,
3257 .name = "percentile_list",
3258 .lname = "Percentile list",
3259 .type = FIO_OPT_FLOAT_LIST,
3260 .off1 = td_var_offset(percentile_list),
3261 .off2 = td_var_offset(percentile_precision),
3262 .help = "Specify a custom list of percentiles to report for "
3263 "completion latency and block errors",
3264 .def = "1:5:10:20:30:40:50:60:70:80:90:95:99:99.5:99.9:99.95:99.99",
3265 .maxlen = FIO_IO_U_LIST_MAX_LEN,
3268 .category = FIO_OPT_C_STAT,
3269 .group = FIO_OPT_G_INVALID,
3272 #ifdef FIO_HAVE_DISK_UTIL
3274 .name = "disk_util",
3275 .lname = "Disk utilization",
3276 .type = FIO_OPT_BOOL,
3277 .off1 = td_var_offset(do_disk_util),
3278 .help = "Log disk utilization statistics",
3280 .category = FIO_OPT_C_STAT,
3281 .group = FIO_OPT_G_INVALID,
3285 .name = "gtod_reduce",
3286 .lname = "Reduce gettimeofday() calls",
3287 .type = FIO_OPT_BOOL,
3288 .help = "Greatly reduce number of gettimeofday() calls",
3289 .cb = str_gtod_reduce_cb,
3292 .category = FIO_OPT_C_STAT,
3293 .group = FIO_OPT_G_INVALID,
3296 .name = "disable_lat",
3297 .lname = "Disable all latency stats",
3298 .type = FIO_OPT_BOOL,
3299 .off1 = td_var_offset(disable_lat),
3300 .help = "Disable latency numbers",
3301 .parent = "gtod_reduce",
3304 .category = FIO_OPT_C_STAT,
3305 .group = FIO_OPT_G_INVALID,
3308 .name = "disable_clat",
3309 .lname = "Disable completion latency stats",
3310 .type = FIO_OPT_BOOL,
3311 .off1 = td_var_offset(disable_clat),
3312 .help = "Disable completion latency numbers",
3313 .parent = "gtod_reduce",
3316 .category = FIO_OPT_C_STAT,
3317 .group = FIO_OPT_G_INVALID,
3320 .name = "disable_slat",
3321 .lname = "Disable submission latency stats",
3322 .type = FIO_OPT_BOOL,
3323 .off1 = td_var_offset(disable_slat),
3324 .help = "Disable submission latency numbers",
3325 .parent = "gtod_reduce",
3328 .category = FIO_OPT_C_STAT,
3329 .group = FIO_OPT_G_INVALID,
3332 .name = "disable_bw_measurement",
3333 .lname = "Disable bandwidth stats",
3334 .type = FIO_OPT_BOOL,
3335 .off1 = td_var_offset(disable_bw),
3336 .help = "Disable bandwidth logging",
3337 .parent = "gtod_reduce",
3340 .category = FIO_OPT_C_STAT,
3341 .group = FIO_OPT_G_INVALID,
3345 .lname = "Dedicated gettimeofday() CPU",
3346 .type = FIO_OPT_INT,
3347 .off1 = td_var_offset(gtod_cpu),
3348 .help = "Set up dedicated gettimeofday() thread on this CPU",
3349 .verify = gtod_cpu_verify,
3350 .category = FIO_OPT_C_GENERAL,
3351 .group = FIO_OPT_G_CLOCK,
3354 .name = "unified_rw_reporting",
3355 .type = FIO_OPT_BOOL,
3356 .off1 = td_var_offset(unified_rw_rep),
3357 .help = "Unify reporting across data direction",
3359 .category = FIO_OPT_C_GENERAL,
3360 .group = FIO_OPT_G_INVALID,
3363 .name = "continue_on_error",
3364 .lname = "Continue on error",
3365 .type = FIO_OPT_STR,
3366 .off1 = td_var_offset(continue_on_error),
3367 .help = "Continue on non-fatal errors during IO",
3369 .category = FIO_OPT_C_GENERAL,
3370 .group = FIO_OPT_G_ERR,
3373 .oval = ERROR_TYPE_NONE,
3374 .help = "Exit when an error is encountered",
3377 .oval = ERROR_TYPE_READ,
3378 .help = "Continue on read errors only",
3381 .oval = ERROR_TYPE_WRITE,
3382 .help = "Continue on write errors only",
3385 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
3386 .help = "Continue on any IO errors",
3389 .oval = ERROR_TYPE_VERIFY,
3390 .help = "Continue on verify errors only",
3393 .oval = ERROR_TYPE_ANY,
3394 .help = "Continue on all io and verify errors",
3397 .oval = ERROR_TYPE_NONE,
3398 .help = "Alias for 'none'",
3401 .oval = ERROR_TYPE_ANY,
3402 .help = "Alias for 'all'",
3407 .name = "ignore_error",
3408 .type = FIO_OPT_STR,
3409 .cb = str_ignore_error_cb,
3410 .off1 = td_var_offset(ignore_error_nr),
3411 .help = "Set a specific list of errors to ignore",
3413 .category = FIO_OPT_C_GENERAL,
3414 .group = FIO_OPT_G_ERR,
3417 .name = "error_dump",
3418 .type = FIO_OPT_BOOL,
3419 .off1 = td_var_offset(error_dump),
3421 .help = "Dump info on each error",
3422 .category = FIO_OPT_C_GENERAL,
3423 .group = FIO_OPT_G_ERR,
3428 .type = FIO_OPT_STR_STORE,
3429 .off1 = td_var_offset(profile),
3430 .help = "Select a specific builtin performance test",
3431 .category = FIO_OPT_C_PROFILE,
3432 .group = FIO_OPT_G_INVALID,
3437 .type = FIO_OPT_STR_STORE,
3438 .off1 = td_var_offset(cgroup),
3439 .help = "Add job to cgroup of this name",
3440 .category = FIO_OPT_C_GENERAL,
3441 .group = FIO_OPT_G_CGROUP,
3444 .name = "cgroup_nodelete",
3445 .lname = "Cgroup no-delete",
3446 .type = FIO_OPT_BOOL,
3447 .off1 = td_var_offset(cgroup_nodelete),
3448 .help = "Do not delete cgroups after job completion",
3451 .category = FIO_OPT_C_GENERAL,
3452 .group = FIO_OPT_G_CGROUP,
3455 .name = "cgroup_weight",
3456 .lname = "Cgroup weight",
3457 .type = FIO_OPT_INT,
3458 .off1 = td_var_offset(cgroup_weight),
3459 .help = "Use given weight for cgroup",
3463 .category = FIO_OPT_C_GENERAL,
3464 .group = FIO_OPT_G_CGROUP,
3469 .type = FIO_OPT_INT,
3470 .off1 = td_var_offset(uid),
3471 .help = "Run job with this user ID",
3472 .category = FIO_OPT_C_GENERAL,
3473 .group = FIO_OPT_G_CRED,
3477 .lname = "Group ID",
3478 .type = FIO_OPT_INT,
3479 .off1 = td_var_offset(gid),
3480 .help = "Run job with this group ID",
3481 .category = FIO_OPT_C_GENERAL,
3482 .group = FIO_OPT_G_CRED,
3487 .type = FIO_OPT_INT,
3488 .off1 = td_var_offset(kb_base),
3494 .help = "Use 1024 as the K base",
3498 .help = "Use 1000 as the K base",
3501 .help = "How many bytes per KB for reporting (1000 or 1024)",
3502 .category = FIO_OPT_C_GENERAL,
3503 .group = FIO_OPT_G_INVALID,
3506 .name = "unit_base",
3507 .lname = "Base unit for reporting (Bits or Bytes)",
3508 .type = FIO_OPT_INT,
3509 .off1 = td_var_offset(unit_base),
3514 .help = "Auto-detect",
3518 .help = "Normal (byte based)",
3522 .help = "Bit based",
3525 .help = "Bit multiple of result summary data (8 for byte, 1 for bit)",
3526 .category = FIO_OPT_C_GENERAL,
3527 .group = FIO_OPT_G_INVALID,
3530 .name = "hugepage-size",
3531 .lname = "Hugepage size",
3532 .type = FIO_OPT_INT,
3533 .off1 = td_var_offset(hugepage_size),
3534 .help = "When using hugepages, specify size of each page",
3535 .def = __fio_stringify(FIO_HUGE_PAGE),
3536 .interval = 1024 * 1024,
3537 .category = FIO_OPT_C_GENERAL,
3538 .group = FIO_OPT_G_INVALID,
3542 .lname = "I/O flow ID",
3543 .type = FIO_OPT_INT,
3544 .off1 = td_var_offset(flow_id),
3545 .help = "The flow index ID to use",
3547 .category = FIO_OPT_C_IO,
3548 .group = FIO_OPT_G_IO_FLOW,
3552 .lname = "I/O flow weight",
3553 .type = FIO_OPT_INT,
3554 .off1 = td_var_offset(flow),
3555 .help = "Weight for flow control of this job",
3556 .parent = "flow_id",
3559 .category = FIO_OPT_C_IO,
3560 .group = FIO_OPT_G_IO_FLOW,
3563 .name = "flow_watermark",
3564 .lname = "I/O flow watermark",
3565 .type = FIO_OPT_INT,
3566 .off1 = td_var_offset(flow_watermark),
3567 .help = "High watermark for flow control. This option"
3568 " should be set to the same value for all threads"
3569 " with non-zero flow.",
3570 .parent = "flow_id",
3573 .category = FIO_OPT_C_IO,
3574 .group = FIO_OPT_G_IO_FLOW,
3577 .name = "flow_sleep",
3578 .lname = "I/O flow sleep",
3579 .type = FIO_OPT_INT,
3580 .off1 = td_var_offset(flow_sleep),
3581 .help = "How many microseconds to sleep after being held"
3582 " back by the flow control mechanism",
3583 .parent = "flow_id",
3586 .category = FIO_OPT_C_IO,
3587 .group = FIO_OPT_G_IO_FLOW,
3591 .lname = "Skip operations against bad blocks",
3592 .type = FIO_OPT_BOOL,
3593 .off1 = td_var_offset(skip_bad),
3594 .help = "Skip operations against known bad blocks.",
3597 .category = FIO_OPT_C_IO,
3598 .group = FIO_OPT_G_MTD,
3605 static void add_to_lopt(struct option *lopt, struct fio_option *o,
3606 const char *name, int val)
3608 lopt->name = (char *) name;
3610 if (o->type == FIO_OPT_STR_SET)
3611 lopt->has_arg = optional_argument;
3613 lopt->has_arg = required_argument;
3616 static void options_to_lopts(struct fio_option *opts,
3617 struct option *long_options,
3618 int i, int option_type)
3620 struct fio_option *o = &opts[0];
3622 add_to_lopt(&long_options[i], o, o->name, option_type);
3625 add_to_lopt(&long_options[i], o, o->alias, option_type);
3630 assert(i < FIO_NR_OPTIONS);
3634 void fio_options_set_ioengine_opts(struct option *long_options,
3635 struct thread_data *td)
3640 while (long_options[i].name) {
3641 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
3642 memset(&long_options[i], 0, sizeof(*long_options));
3649 * Just clear out the prior ioengine options.
3654 options_to_lopts(td->io_ops->options, long_options, i,
3655 FIO_GETOPT_IOENGINE);
3658 void fio_options_dup_and_init(struct option *long_options)
3662 options_init(fio_options);
3665 while (long_options[i].name)
3668 options_to_lopts(fio_options, long_options, i, FIO_GETOPT_JOB);
3671 struct fio_keyword {
3677 static struct fio_keyword fio_keywords[] = {
3679 .word = "$pagesize",
3680 .desc = "Page size in the system",
3683 .word = "$mb_memory",
3684 .desc = "Megabytes of memory online",
3688 .desc = "Number of CPUs online in the system",
3695 void fio_keywords_exit(void)
3697 struct fio_keyword *kw;
3699 kw = &fio_keywords[0];
3707 void fio_keywords_init(void)
3709 unsigned long long mb_memory;
3713 sprintf(buf, "%lu", (unsigned long) page_size);
3714 fio_keywords[0].replace = strdup(buf);
3716 mb_memory = os_phys_mem() / (1024 * 1024);
3717 sprintf(buf, "%llu", mb_memory);
3718 fio_keywords[1].replace = strdup(buf);
3721 sprintf(buf, "%lu", l);
3722 fio_keywords[2].replace = strdup(buf);
3727 static char *bc_calc(char *str)
3729 char buf[128], *tmp;
3734 * No math, just return string
3736 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
3737 !strchr(str, '/')) || strchr(str, '\''))
3741 * Split option from value, we only need to calculate the value
3743 tmp = strchr(str, '=');
3750 * Prevent buffer overflows; such a case isn't reasonable anyway
3752 if (strlen(str) >= 128 || strlen(tmp) > 100)
3755 sprintf(buf, "which %s > /dev/null", BC_APP);
3757 log_err("fio: bc is needed for performing math\n");
3761 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
3762 f = popen(buf, "r");
3766 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
3773 buf[(tmp - str) + ret - 1] = '\0';
3774 memcpy(buf, str, tmp - str);
3780 * Return a copy of the input string with substrings of the form ${VARNAME}
3781 * substituted with the value of the environment variable VARNAME. The
3782 * substitution always occurs, even if VARNAME is empty or the corresponding
3783 * environment variable undefined.
3785 static char *option_dup_subs(const char *opt)
3787 char out[OPT_LEN_MAX+1];
3788 char in[OPT_LEN_MAX+1];
3791 char *ch1, *ch2, *env;
3792 ssize_t nchr = OPT_LEN_MAX;
3795 if (strlen(opt) + 1 > OPT_LEN_MAX) {
3796 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
3800 in[OPT_LEN_MAX] = '\0';
3801 strncpy(in, opt, OPT_LEN_MAX);
3803 while (*inptr && nchr > 0) {
3804 if (inptr[0] == '$' && inptr[1] == '{') {
3805 ch2 = strchr(inptr, '}');
3806 if (ch2 && inptr+1 < ch2) {
3813 envlen = strlen(env);
3814 if (envlen <= nchr) {
3815 memcpy(outptr, env, envlen);
3825 *outptr++ = *inptr++;
3834 * Look for reserved variable names and replace them with real values
3836 static char *fio_keyword_replace(char *opt)
3842 for (i = 0; fio_keywords[i].word != NULL; i++) {
3843 struct fio_keyword *kw = &fio_keywords[i];
3845 while ((s = strstr(opt, kw->word)) != NULL) {
3846 char *new = malloc(strlen(opt) + 1);
3852 * Copy part of the string before the keyword and
3853 * sprintf() the replacement after it.
3855 memcpy(new, opt, olen);
3856 len = sprintf(new + olen, "%s", kw->replace);
3859 * If there's more in the original string, copy that
3862 opt += strlen(kw->word) + olen;
3864 memcpy(new + olen + len, opt, opt - o_org - 1);
3867 * replace opt and free the old opt
3877 * Check for potential math and invoke bc, if possible
3885 static char **dup_and_sub_options(char **opts, int num_opts)
3888 char **opts_copy = malloc(num_opts * sizeof(*opts));
3889 for (i = 0; i < num_opts; i++) {
3890 opts_copy[i] = option_dup_subs(opts[i]);
3893 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
3898 static void show_closest_option(const char *opt)
3900 int best_option, best_distance;
3909 while (name[i] != '\0' && name[i] != '=')
3914 best_distance = INT_MAX;
3916 while (fio_options[i].name) {
3917 distance = string_distance(name, fio_options[i].name);
3918 if (distance < best_distance) {
3919 best_distance = distance;
3925 if (best_option != -1 && string_distance_ok(name, best_distance))
3926 log_err("Did you mean %s?\n", fio_options[best_option].name);
3931 int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
3933 int i, ret, unknown;
3936 sort_options(opts, fio_options, num_opts);
3937 opts_copy = dup_and_sub_options(opts, num_opts);
3939 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
3940 struct fio_option *o;
3941 int newret = parse_option(opts_copy[i], opts[i], fio_options,
3942 &o, td, &td->opt_list);
3945 fio_option_mark_set(&td->o, o);
3953 opts_copy[i] = NULL;
3960 ret |= ioengine_load(td);
3962 sort_options(opts_copy, td->io_ops->options, num_opts);
3965 for (i = 0; i < num_opts; i++) {
3966 struct fio_option *o = NULL;
3973 newret = parse_option(opts_copy[i], opts[i],
3974 td->io_ops->options, &o,
3975 td->eo, &td->opt_list);
3979 log_err("Bad option <%s>\n", opts[i]);
3980 show_closest_option(opts[i]);
3983 opts_copy[i] = NULL;
3991 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
3995 ret = parse_cmd_option(opt, val, fio_options, td, &td->opt_list);
3997 struct fio_option *o;
3999 o = find_option(fio_options, opt);
4001 fio_option_mark_set(&td->o, o);
4007 int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
4010 return parse_cmd_option(opt, val, td->io_ops->options, td->eo,
4014 void fio_fill_default_options(struct thread_data *td)
4016 td->o.magic = OPT_MAGIC;
4017 fill_default_options(td, fio_options);
4020 int fio_show_option_help(const char *opt)
4022 return show_cmd_help(fio_options, opt);
4025 void options_mem_dupe(void *data, struct fio_option *options)
4027 struct fio_option *o;
4030 for (o = &options[0]; o->name; o++) {
4031 if (o->type != FIO_OPT_STR_STORE)
4034 ptr = td_var(data, o, o->off1);
4036 *ptr = strdup(*ptr);
4041 * dupe FIO_OPT_STR_STORE options
4043 void fio_options_mem_dupe(struct thread_data *td)
4045 options_mem_dupe(&td->o, fio_options);
4047 if (td->eo && td->io_ops) {
4048 void *oldeo = td->eo;
4050 td->eo = malloc(td->io_ops->option_struct_size);
4051 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
4052 options_mem_dupe(td->eo, td->io_ops->options);
4056 unsigned int fio_get_kb_base(void *data)
4058 struct thread_options *o = data;
4059 unsigned int kb_base = 0;
4062 * This is a hack... For private options, *data is not holding
4063 * a pointer to the thread_options, but to private data. This means
4064 * we can't safely dereference it, but magic is first so mem wise
4065 * it is valid. But this also means that if the job first sets
4066 * kb_base and expects that to be honored by private options,
4067 * it will be disappointed. We will return the global default
4070 if (o && o->magic == OPT_MAGIC)
4071 kb_base = o->kb_base;
4078 int add_option(struct fio_option *o)
4080 struct fio_option *__o;
4089 if (opt_index + 1 == FIO_MAX_OPTS) {
4090 log_err("fio: FIO_MAX_OPTS is too small\n");
4094 memcpy(&fio_options[opt_index], o, sizeof(*o));
4095 fio_options[opt_index + 1].name = NULL;
4099 void invalidate_profile_options(const char *prof_name)
4101 struct fio_option *o;
4105 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
4106 o->type = FIO_OPT_INVALID;
4107 o->prof_name = NULL;
4113 void add_opt_posval(const char *optname, const char *ival, const char *help)
4115 struct fio_option *o;
4118 o = find_option(fio_options, optname);
4122 for (i = 0; i < PARSE_MAX_VP; i++) {
4123 if (o->posval[i].ival)
4126 o->posval[i].ival = ival;
4127 o->posval[i].help = help;
4132 void del_opt_posval(const char *optname, const char *ival)
4134 struct fio_option *o;
4137 o = find_option(fio_options, optname);
4141 for (i = 0; i < PARSE_MAX_VP; i++) {
4142 if (!o->posval[i].ival)
4144 if (strcmp(o->posval[i].ival, ival))
4147 o->posval[i].ival = NULL;
4148 o->posval[i].help = NULL;
4152 void fio_options_free(struct thread_data *td)
4154 options_free(fio_options, td);
4155 if (td->eo && td->io_ops && td->io_ops->options) {
4156 options_free(td->io_ops->options, td->eo);
4162 struct fio_option *fio_option_find(const char *name)
4164 return find_option(fio_options, name);
4167 static struct fio_option *find_next_opt(struct thread_options *o,
4168 struct fio_option *from,
4171 struct fio_option *opt;
4174 from = &fio_options[0];
4180 if (off1 == from->off1) {
4185 } while (from->name);
4190 static int opt_is_set(struct thread_options *o, struct fio_option *opt)
4192 unsigned int opt_off, index, offset;
4194 opt_off = opt - &fio_options[0];
4195 index = opt_off / (8 * sizeof(uint64_t));
4196 offset = opt_off & ((8 * sizeof(uint64_t)) - 1);
4197 return (o->set_options[index] & ((uint64_t)1 << offset)) != 0;
4200 bool __fio_option_is_set(struct thread_options *o, unsigned int off1)
4202 struct fio_option *opt, *next;
4205 while ((opt = find_next_opt(o, next, off1)) != NULL) {
4206 if (opt_is_set(o, opt))
4215 void fio_option_mark_set(struct thread_options *o, struct fio_option *opt)
4217 unsigned int opt_off, index, offset;
4219 opt_off = opt - &fio_options[0];
4220 index = opt_off / (8 * sizeof(uint64_t));
4221 offset = opt_off & ((8 * sizeof(uint64_t)) - 1);
4222 o->set_options[index] |= (uint64_t)1 << offset;