11 #include <netinet/in.h>
17 #include "lib/pattern.h"
21 char client_sockaddr_str[INET6_ADDRSTRLEN] = { 0 };
23 struct pattern_fmt_desc fmt_desc[] = {
26 .len = FIELD_SIZE(struct io_u *, offset),
27 .paste = paste_blockoff
32 * Check if mmap/mmaphuge has a :/foo/bar/file at the end. If so, return that.
34 static char *get_opt_postfix(const char *str)
36 char *p = strstr(str, ":");
42 strip_blank_front(&p);
47 static int bs_cmp(const void *p1, const void *p2)
49 const struct bssplit *bsp1 = p1;
50 const struct bssplit *bsp2 = p2;
52 return bsp1->perc < bsp2->perc;
55 static int bssplit_ddir(struct thread_options *o, int ddir, char *str)
57 struct bssplit *bssplit;
58 unsigned int i, perc, perc_missing;
59 unsigned int max_bs, min_bs;
63 o->bssplit_nr[ddir] = 4;
64 bssplit = malloc(4 * sizeof(struct bssplit));
69 while ((fname = strsep(&str, ":")) != NULL) {
76 * grow struct buffer, if needed
78 if (i == o->bssplit_nr[ddir]) {
79 o->bssplit_nr[ddir] <<= 1;
80 bssplit = realloc(bssplit, o->bssplit_nr[ddir]
81 * sizeof(struct bssplit));
84 perc_str = strstr(fname, "/");
88 perc = atoi(perc_str);
96 if (str_to_decimal(fname, &val, 1, o, 0, 0)) {
97 log_err("fio: bssplit conversion failed\n");
108 bssplit[i].perc = perc;
112 o->bssplit_nr[ddir] = i;
115 * Now check if the percentages add up, and how much is missing
117 perc = perc_missing = 0;
118 for (i = 0; i < o->bssplit_nr[ddir]; i++) {
119 struct bssplit *bsp = &bssplit[i];
121 if (bsp->perc == -1U)
127 if (perc > 100 && perc_missing > 1) {
128 log_err("fio: bssplit percentages add to more than 100%%\n");
134 * If values didn't have a percentage set, divide the remains between
138 if (perc_missing == 1 && o->bssplit_nr[ddir] == 1)
140 for (i = 0; i < o->bssplit_nr[ddir]; i++) {
141 struct bssplit *bsp = &bssplit[i];
143 if (bsp->perc == -1U)
144 bsp->perc = (100 - perc) / perc_missing;
148 o->min_bs[ddir] = min_bs;
149 o->max_bs[ddir] = max_bs;
152 * now sort based on percentages, for ease of lookup
154 qsort(bssplit, o->bssplit_nr[ddir], sizeof(struct bssplit), bs_cmp);
155 o->bssplit[ddir] = bssplit;
159 static int str_bssplit_cb(void *data, const char *input)
161 struct thread_data *td = data;
162 char *str, *p, *odir, *ddir;
168 p = str = strdup(input);
170 strip_blank_front(&str);
171 strip_blank_end(str);
173 odir = strchr(str, ',');
175 ddir = strchr(odir + 1, ',');
177 ret = bssplit_ddir(&td->o, DDIR_TRIM, ddir + 1);
183 op = strdup(odir + 1);
184 ret = bssplit_ddir(&td->o, DDIR_TRIM, op);
189 ret = bssplit_ddir(&td->o, DDIR_WRITE, odir + 1);
192 ret = bssplit_ddir(&td->o, DDIR_READ, str);
198 ret = bssplit_ddir(&td->o, DDIR_WRITE, op);
203 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.mem_type == MEM_MMAPSHARED)
356 td->o.mmapfile = get_opt_postfix(mem);
361 static int fio_clock_source_cb(void *data, const char *str)
363 struct thread_data *td = data;
365 fio_clock_source = td->o.clocksource;
366 fio_clock_source_set = 1;
371 static int str_rwmix_read_cb(void *data, unsigned long long *val)
373 struct thread_data *td = data;
375 td->o.rwmix[DDIR_READ] = *val;
376 td->o.rwmix[DDIR_WRITE] = 100 - *val;
380 static int str_rwmix_write_cb(void *data, unsigned long long *val)
382 struct thread_data *td = data;
384 td->o.rwmix[DDIR_WRITE] = *val;
385 td->o.rwmix[DDIR_READ] = 100 - *val;
389 static int str_exitall_cb(void)
391 exitall_on_terminate = 1;
395 #ifdef FIO_HAVE_CPU_AFFINITY
396 int fio_cpus_split(os_cpu_mask_t *mask, unsigned int cpu_index)
398 unsigned int i, index, cpus_in_mask;
399 const long max_cpu = cpus_online();
401 cpus_in_mask = fio_cpu_count(mask);
402 cpu_index = cpu_index % cpus_in_mask;
405 for (i = 0; i < max_cpu; i++) {
406 if (!fio_cpu_isset(mask, i))
409 if (cpu_index != index)
410 fio_cpu_clear(mask, i);
415 return fio_cpu_count(mask);
418 static int str_cpumask_cb(void *data, unsigned long long *val)
420 struct thread_data *td = data;
428 ret = fio_cpuset_init(&td->o.cpumask);
430 log_err("fio: cpuset_init failed\n");
431 td_verror(td, ret, "fio_cpuset_init");
435 max_cpu = cpus_online();
437 for (i = 0; i < sizeof(int) * 8; i++) {
438 if ((1 << i) & *val) {
440 log_err("fio: CPU %d too large (max=%ld)\n", i,
444 dprint(FD_PARSE, "set cpu allowed %d\n", i);
445 fio_cpu_set(&td->o.cpumask, i);
452 static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask,
459 ret = fio_cpuset_init(mask);
461 log_err("fio: cpuset_init failed\n");
462 td_verror(td, ret, "fio_cpuset_init");
466 p = str = strdup(input);
468 strip_blank_front(&str);
469 strip_blank_end(str);
471 max_cpu = cpus_online();
473 while ((cpu = strsep(&str, ",")) != NULL) {
482 while ((cpu2 = strsep(&str2, "-")) != NULL) {
492 while (icpu <= icpu2) {
493 if (icpu >= FIO_MAX_CPUS) {
494 log_err("fio: your OS only supports up to"
495 " %d CPUs\n", (int) FIO_MAX_CPUS);
499 if (icpu >= max_cpu) {
500 log_err("fio: CPU %d too large (max=%ld)\n",
506 dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
507 fio_cpu_set(mask, icpu);
518 static int str_cpus_allowed_cb(void *data, const char *input)
520 struct thread_data *td = data;
525 return set_cpus_allowed(td, &td->o.cpumask, input);
528 static int str_verify_cpus_allowed_cb(void *data, const char *input)
530 struct thread_data *td = data;
535 return set_cpus_allowed(td, &td->o.verify_cpumask, input);
539 static int str_log_cpus_allowed_cb(void *data, const char *input)
541 struct thread_data *td = data;
546 return set_cpus_allowed(td, &td->o.log_gz_cpumask, input);
548 #endif /* CONFIG_ZLIB */
550 #endif /* FIO_HAVE_CPU_AFFINITY */
552 #ifdef CONFIG_LIBNUMA
553 static int str_numa_cpunodes_cb(void *data, char *input)
555 struct thread_data *td = data;
556 struct bitmask *verify_bitmask;
561 /* numa_parse_nodestring() parses a character string list
562 * of nodes into a bit mask. The bit mask is allocated by
563 * numa_allocate_nodemask(), so it should be freed by
564 * numa_free_nodemask().
566 verify_bitmask = numa_parse_nodestring(input);
567 if (verify_bitmask == NULL) {
568 log_err("fio: numa_parse_nodestring failed\n");
569 td_verror(td, 1, "str_numa_cpunodes_cb");
572 numa_free_nodemask(verify_bitmask);
574 td->o.numa_cpunodes = strdup(input);
578 static int str_numa_mpol_cb(void *data, char *input)
580 struct thread_data *td = data;
581 const char * const policy_types[] =
582 { "default", "prefer", "bind", "interleave", "local", NULL };
585 struct bitmask *verify_bitmask;
590 nodelist = strchr(input, ':');
592 /* NUL-terminate mode */
596 for (i = 0; i <= MPOL_LOCAL; i++) {
597 if (!strcmp(input, policy_types[i])) {
598 td->o.numa_mem_mode = i;
602 if (i > MPOL_LOCAL) {
603 log_err("fio: memory policy should be: default, prefer, bind, interleave, local\n");
607 switch (td->o.numa_mem_mode) {
610 * Insist on a nodelist of one node only
613 char *rest = nodelist;
614 while (isdigit(*rest))
617 log_err("fio: one node only for \'prefer\'\n");
621 log_err("fio: one node is needed for \'prefer\'\n");
625 case MPOL_INTERLEAVE:
627 * Default to online nodes with memory if no nodelist
630 nodelist = strdup("all");
635 * Don't allow a nodelist
638 log_err("fio: NO nodelist for \'local\'\n");
644 * Insist on a nodelist
647 log_err("fio: a nodelist is needed for \'bind\'\n");
654 /* numa_parse_nodestring() parses a character string list
655 * of nodes into a bit mask. The bit mask is allocated by
656 * numa_allocate_nodemask(), so it should be freed by
657 * numa_free_nodemask().
659 switch (td->o.numa_mem_mode) {
661 td->o.numa_mem_prefer_node = atoi(nodelist);
663 case MPOL_INTERLEAVE:
665 verify_bitmask = numa_parse_nodestring(nodelist);
666 if (verify_bitmask == NULL) {
667 log_err("fio: numa_parse_nodestring failed\n");
668 td_verror(td, 1, "str_numa_memnodes_cb");
671 td->o.numa_memnodes = strdup(nodelist);
672 numa_free_nodemask(verify_bitmask);
687 static int str_fst_cb(void *data, const char *str)
689 struct thread_data *td = data;
690 char *nr = get_opt_postfix(str);
692 td->file_service_nr = 1;
694 td->file_service_nr = atoi(nr);
701 #ifdef CONFIG_SYNC_FILE_RANGE
702 static int str_sfr_cb(void *data, const char *str)
704 struct thread_data *td = data;
705 char *nr = get_opt_postfix(str);
707 td->sync_file_range_nr = 1;
709 td->sync_file_range_nr = atoi(nr);
717 static int str_random_distribution_cb(void *data, const char *str)
719 struct thread_data *td = data;
726 if (td->o.random_distribution == FIO_RAND_DIST_ZIPF)
728 else if (td->o.random_distribution == FIO_RAND_DIST_PARETO)
729 val = FIO_DEF_PARETO;
730 else if (td->o.random_distribution == FIO_RAND_DIST_GAUSS)
735 nr = get_opt_postfix(str);
736 if (nr && !str_to_float(nr, &val, 0)) {
737 log_err("fio: random postfix parsing failed\n");
744 if (td->o.random_distribution == FIO_RAND_DIST_ZIPF) {
746 log_err("fio: zipf theta must different than 1.0\n");
749 td->o.zipf_theta.u.f = val;
750 } else if (td->o.random_distribution == FIO_RAND_DIST_PARETO) {
751 if (val <= 0.00 || val >= 1.00) {
752 log_err("fio: pareto input out of range (0 < input < 1.0)\n");
755 td->o.pareto_h.u.f = val;
757 if (val <= 0.00 || val >= 100.0) {
758 log_err("fio: normal deviation out of range (0 < input < 100.0)\n");
761 td->o.gauss_dev.u.f = val;
768 * Return next name in the string. Files are separated with ':'. If the ':'
769 * is escaped with a '\', then that ':' is part of the filename and does not
770 * indicate a new file.
772 static char *get_next_name(char **ptr)
777 if (!str || !strlen(str))
783 * No colon, we are done
785 p = strchr(str, ':');
792 * We got a colon, but it's the first character. Skip and
800 if (*(p - 1) != '\\') {
806 memmove(p - 1, p, strlen(p) + 1);
814 static int get_max_name_idx(char *input)
816 unsigned int cur_idx;
819 p = str = strdup(input);
820 for (cur_idx = 0; ; cur_idx++)
821 if (get_next_name(&str) == NULL)
829 * Returns the directory at the index, indexes > entires will be
830 * assigned via modulo division of the index
832 int set_name_idx(char *target, size_t tlen, char *input, int index)
834 unsigned int cur_idx;
836 char *fname, *str, *p;
838 p = str = strdup(input);
840 index %= get_max_name_idx(input);
841 for (cur_idx = 0; cur_idx <= index; cur_idx++)
842 fname = get_next_name(&str);
844 if (client_sockaddr_str[0]) {
845 len = snprintf(target, tlen, "%s/%s.", fname,
846 client_sockaddr_str);
848 len = snprintf(target, tlen, "%s/", fname);
850 target[tlen - 1] = '\0';
856 static int str_filename_cb(void *data, const char *input)
858 struct thread_data *td = data;
859 char *fname, *str, *p;
861 p = str = strdup(input);
863 strip_blank_front(&str);
864 strip_blank_end(str);
866 if (!td->files_index)
869 while ((fname = get_next_name(&str)) != NULL) {
872 add_file(td, fname, 0, 1);
879 static int str_directory_cb(void *data, const char fio_unused *unused)
881 struct thread_data *td = data;
883 char *dirname, *str, *p;
889 p = str = strdup(td->o.directory);
890 while ((dirname = get_next_name(&str)) != NULL) {
891 if (lstat(dirname, &sb) < 0) {
894 log_err("fio: %s is not a directory\n", dirname);
895 td_verror(td, ret, "lstat");
898 if (!S_ISDIR(sb.st_mode)) {
899 log_err("fio: %s is not a directory\n", dirname);
910 static int str_opendir_cb(void *data, const char fio_unused *str)
912 struct thread_data *td = data;
917 if (!td->files_index)
920 return add_dir_files(td, td->o.opendir);
923 static int str_buffer_pattern_cb(void *data, const char *input)
925 struct thread_data *td = data;
928 /* FIXME: for now buffer pattern does not support formats */
929 ret = parse_and_fill_pattern(input, strlen(input), td->o.buffer_pattern,
930 MAX_PATTERN_SIZE, NULL, 0, NULL, NULL);
935 td->o.buffer_pattern_bytes = ret;
936 if (!td->o.compress_percentage)
937 td->o.refill_buffers = 0;
938 td->o.scramble_buffers = 0;
939 td->o.zero_buffers = 0;
944 static int str_buffer_compress_cb(void *data, unsigned long long *il)
946 struct thread_data *td = data;
948 td->flags |= TD_F_COMPRESS;
949 td->o.compress_percentage = *il;
953 static int str_dedupe_cb(void *data, unsigned long long *il)
955 struct thread_data *td = data;
957 td->flags |= TD_F_COMPRESS;
958 td->o.dedupe_percentage = *il;
959 td->o.refill_buffers = 1;
963 static int str_verify_pattern_cb(void *data, const char *input)
965 struct thread_data *td = data;
968 td->o.verify_fmt_sz = ARRAY_SIZE(td->o.verify_fmt);
969 ret = parse_and_fill_pattern(input, strlen(input), td->o.verify_pattern,
970 MAX_PATTERN_SIZE, fmt_desc, sizeof(fmt_desc),
971 td->o.verify_fmt, &td->o.verify_fmt_sz);
976 td->o.verify_pattern_bytes = ret;
978 * VERIFY_* could already be set
980 if (!fio_option_is_set(&td->o, verify))
981 td->o.verify = VERIFY_PATTERN;
986 static int str_gtod_reduce_cb(void *data, int *il)
988 struct thread_data *td = data;
991 td->o.disable_lat = !!val;
992 td->o.disable_clat = !!val;
993 td->o.disable_slat = !!val;
994 td->o.disable_bw = !!val;
995 td->o.clat_percentiles = !val;
997 td->tv_cache_mask = 63;
1002 static int str_size_cb(void *data, unsigned long long *__val)
1004 struct thread_data *td = data;
1005 unsigned long long v = *__val;
1007 if (parse_is_percent(v)) {
1009 td->o.size_percent = -1ULL - v;
1016 static int rw_verify(struct fio_option *o, void *data)
1018 struct thread_data *td = data;
1020 if (read_only && td_write(td)) {
1021 log_err("fio: job <%s> has write bit set, but fio is in"
1022 " read-only mode\n", td->o.name);
1029 static int gtod_cpu_verify(struct fio_option *o, void *data)
1031 #ifndef FIO_HAVE_CPU_AFFINITY
1032 struct thread_data *td = data;
1034 if (td->o.gtod_cpu) {
1035 log_err("fio: platform must support CPU affinity for"
1036 "gettimeofday() offloading\n");
1045 * Map of job/command line options
1047 struct fio_option fio_options[FIO_MAX_OPTS] = {
1049 .name = "description",
1050 .lname = "Description of job",
1051 .type = FIO_OPT_STR_STORE,
1052 .off1 = td_var_offset(description),
1053 .help = "Text job description",
1054 .category = FIO_OPT_C_GENERAL,
1055 .group = FIO_OPT_G_DESC,
1059 .lname = "Job name",
1060 .type = FIO_OPT_STR_STORE,
1061 .off1 = td_var_offset(name),
1062 .help = "Name of this job",
1063 .category = FIO_OPT_C_GENERAL,
1064 .group = FIO_OPT_G_DESC,
1068 .lname = "Waitee name",
1069 .type = FIO_OPT_STR_STORE,
1070 .off1 = td_var_offset(wait_for),
1071 .help = "Name of the job this one wants to wait for before starting",
1072 .category = FIO_OPT_C_GENERAL,
1073 .group = FIO_OPT_G_DESC,
1077 .lname = "Filename(s)",
1078 .type = FIO_OPT_STR_STORE,
1079 .off1 = td_var_offset(filename),
1080 .cb = str_filename_cb,
1081 .prio = -1, /* must come after "directory" */
1082 .help = "File(s) to use for the workload",
1083 .category = FIO_OPT_C_FILE,
1084 .group = FIO_OPT_G_FILENAME,
1087 .name = "directory",
1088 .lname = "Directory",
1089 .type = FIO_OPT_STR_STORE,
1090 .off1 = td_var_offset(directory),
1091 .cb = str_directory_cb,
1092 .help = "Directory to store files in",
1093 .category = FIO_OPT_C_FILE,
1094 .group = FIO_OPT_G_FILENAME,
1097 .name = "filename_format",
1098 .type = FIO_OPT_STR_STORE,
1099 .off1 = td_var_offset(filename_format),
1100 .prio = -1, /* must come after "directory" */
1101 .help = "Override default $jobname.$jobnum.$filenum naming",
1102 .def = "$jobname.$jobnum.$filenum",
1103 .category = FIO_OPT_C_FILE,
1104 .group = FIO_OPT_G_FILENAME,
1108 .lname = "Lockfile",
1109 .type = FIO_OPT_STR,
1110 .off1 = td_var_offset(file_lock_mode),
1111 .help = "Lock file when doing IO to it",
1113 .parent = "filename",
1116 .category = FIO_OPT_C_FILE,
1117 .group = FIO_OPT_G_FILENAME,
1120 .oval = FILE_LOCK_NONE,
1121 .help = "No file locking",
1123 { .ival = "exclusive",
1124 .oval = FILE_LOCK_EXCLUSIVE,
1125 .help = "Exclusive file lock",
1128 .ival = "readwrite",
1129 .oval = FILE_LOCK_READWRITE,
1130 .help = "Read vs write lock",
1136 .lname = "Open directory",
1137 .type = FIO_OPT_STR_STORE,
1138 .off1 = td_var_offset(opendir),
1139 .cb = str_opendir_cb,
1140 .help = "Recursively add files from this directory and down",
1141 .category = FIO_OPT_C_FILE,
1142 .group = FIO_OPT_G_FILENAME,
1146 .lname = "Read/write",
1147 .alias = "readwrite",
1148 .type = FIO_OPT_STR,
1150 .off1 = td_var_offset(td_ddir),
1151 .help = "IO direction",
1153 .verify = rw_verify,
1154 .category = FIO_OPT_C_IO,
1155 .group = FIO_OPT_G_IO_BASIC,
1158 .oval = TD_DDIR_READ,
1159 .help = "Sequential read",
1162 .oval = TD_DDIR_WRITE,
1163 .help = "Sequential write",
1166 .oval = TD_DDIR_TRIM,
1167 .help = "Sequential trim",
1169 { .ival = "randread",
1170 .oval = TD_DDIR_RANDREAD,
1171 .help = "Random read",
1173 { .ival = "randwrite",
1174 .oval = TD_DDIR_RANDWRITE,
1175 .help = "Random write",
1177 { .ival = "randtrim",
1178 .oval = TD_DDIR_RANDTRIM,
1179 .help = "Random trim",
1183 .help = "Sequential read and write mix",
1185 { .ival = "readwrite",
1187 .help = "Sequential read and write mix",
1190 .oval = TD_DDIR_RANDRW,
1191 .help = "Random read and write mix"
1193 { .ival = "trimwrite",
1194 .oval = TD_DDIR_TRIMWRITE,
1195 .help = "Trim and write mix, trims preceding writes"
1200 .name = "rw_sequencer",
1201 .lname = "RW Sequencer",
1202 .type = FIO_OPT_STR,
1203 .off1 = td_var_offset(rw_seq),
1204 .help = "IO offset generator modifier",
1205 .def = "sequential",
1206 .category = FIO_OPT_C_IO,
1207 .group = FIO_OPT_G_IO_BASIC,
1209 { .ival = "sequential",
1211 .help = "Generate sequential offsets",
1213 { .ival = "identical",
1214 .oval = RW_SEQ_IDENT,
1215 .help = "Generate identical offsets",
1222 .lname = "IO Engine",
1223 .type = FIO_OPT_STR_STORE,
1224 .off1 = td_var_offset(ioengine),
1225 .help = "IO engine to use",
1226 .def = FIO_PREFERRED_ENGINE,
1227 .category = FIO_OPT_C_IO,
1228 .group = FIO_OPT_G_IO_BASIC,
1231 .help = "Use read/write",
1234 .help = "Use pread/pwrite",
1237 .help = "Use readv/writev",
1239 #ifdef CONFIG_PWRITEV
1241 .help = "Use preadv/pwritev",
1244 #ifdef CONFIG_LIBAIO
1246 .help = "Linux native asynchronous IO",
1249 #ifdef CONFIG_POSIXAIO
1250 { .ival = "posixaio",
1251 .help = "POSIX asynchronous IO",
1254 #ifdef CONFIG_SOLARISAIO
1255 { .ival = "solarisaio",
1256 .help = "Solaris native asynchronous IO",
1259 #ifdef CONFIG_WINDOWSAIO
1260 { .ival = "windowsaio",
1261 .help = "Windows native asynchronous IO"
1266 .help = "Rados Block Device asynchronous IO"
1270 .help = "Memory mapped IO"
1272 #ifdef CONFIG_LINUX_SPLICE
1274 .help = "splice/vmsplice based IO",
1276 { .ival = "netsplice",
1277 .help = "splice/vmsplice to/from the network",
1280 #ifdef FIO_HAVE_SGIO
1282 .help = "SCSI generic v3 IO",
1286 .help = "Testing engine (no data transfer)",
1289 .help = "Network IO",
1292 .help = "CPU cycle burner engine",
1296 .help = "GUASI IO engine",
1299 #ifdef FIO_HAVE_BINJECT
1300 { .ival = "binject",
1301 .help = "binject direct inject block engine",
1306 .help = "RDMA IO engine",
1309 #ifdef CONFIG_FUSION_AW
1310 { .ival = "fusion-aw-sync",
1311 .help = "Fusion-io atomic write engine",
1314 #ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
1315 { .ival = "e4defrag",
1316 .help = "ext4 defrag engine",
1319 #ifdef CONFIG_LINUX_FALLOCATE
1321 .help = "fallocate() file based engine",
1326 .help = "Glusterfs libgfapi(sync) based engine"
1328 { .ival = "gfapi_async",
1329 .help = "Glusterfs libgfapi(async) based engine"
1332 #ifdef CONFIG_LIBHDFS
1333 { .ival = "libhdfs",
1334 .help = "Hadoop Distributed Filesystem (HDFS) engine"
1337 { .ival = "external",
1338 .help = "Load external engine (append name)",
1344 .lname = "IO Depth",
1345 .type = FIO_OPT_INT,
1346 .off1 = td_var_offset(iodepth),
1347 .help = "Number of IO buffers to keep in flight",
1351 .category = FIO_OPT_C_IO,
1352 .group = FIO_OPT_G_IO_BASIC,
1355 .name = "iodepth_batch",
1356 .lname = "IO Depth batch",
1357 .alias = "iodepth_batch_submit",
1358 .type = FIO_OPT_INT,
1359 .off1 = td_var_offset(iodepth_batch),
1360 .help = "Number of IO buffers to submit in one go",
1361 .parent = "iodepth",
1366 .category = FIO_OPT_C_IO,
1367 .group = FIO_OPT_G_IO_BASIC,
1370 .name = "iodepth_batch_complete_min",
1371 .lname = "Min IO depth batch complete",
1372 .alias = "iodepth_batch_complete",
1373 .type = FIO_OPT_INT,
1374 .off1 = td_var_offset(iodepth_batch_complete_min),
1375 .help = "Min number of IO buffers to retrieve in one go",
1376 .parent = "iodepth",
1381 .category = FIO_OPT_C_IO,
1382 .group = FIO_OPT_G_IO_BASIC,
1385 .name = "iodepth_batch_complete_max",
1386 .lname = "Max IO depth batch complete",
1387 .type = FIO_OPT_INT,
1388 .off1 = td_var_offset(iodepth_batch_complete_max),
1389 .help = "Max number of IO buffers to retrieve in one go",
1390 .parent = "iodepth",
1394 .category = FIO_OPT_C_IO,
1395 .group = FIO_OPT_G_IO_BASIC,
1398 .name = "iodepth_low",
1399 .lname = "IO Depth batch low",
1400 .type = FIO_OPT_INT,
1401 .off1 = td_var_offset(iodepth_low),
1402 .help = "Low water mark for queuing depth",
1403 .parent = "iodepth",
1406 .category = FIO_OPT_C_IO,
1407 .group = FIO_OPT_G_IO_BASIC,
1410 .name = "io_submit_mode",
1411 .lname = "IO submit mode",
1412 .type = FIO_OPT_STR,
1413 .off1 = td_var_offset(io_submit_mode),
1414 .help = "How IO submissions and completions are done",
1416 .category = FIO_OPT_C_IO,
1417 .group = FIO_OPT_G_IO_BASIC,
1420 .oval = IO_MODE_INLINE,
1421 .help = "Submit and complete IO inline",
1423 { .ival = "offload",
1424 .oval = IO_MODE_OFFLOAD,
1425 .help = "Offload submit and complete to threads",
1432 .type = FIO_OPT_STR_VAL,
1434 .off1 = td_var_offset(size),
1435 .help = "Total size of device or files",
1436 .interval = 1024 * 1024,
1437 .category = FIO_OPT_C_IO,
1438 .group = FIO_OPT_G_INVALID,
1442 .alias = "io_limit",
1444 .type = FIO_OPT_STR_VAL,
1445 .off1 = td_var_offset(io_limit),
1446 .interval = 1024 * 1024,
1447 .category = FIO_OPT_C_IO,
1448 .group = FIO_OPT_G_INVALID,
1451 .name = "fill_device",
1452 .lname = "Fill device",
1454 .type = FIO_OPT_BOOL,
1455 .off1 = td_var_offset(fill_device),
1456 .help = "Write until an ENOSPC error occurs",
1458 .category = FIO_OPT_C_FILE,
1459 .group = FIO_OPT_G_INVALID,
1463 .lname = "File size",
1464 .type = FIO_OPT_STR_VAL,
1465 .off1 = td_var_offset(file_size_low),
1466 .off2 = td_var_offset(file_size_high),
1468 .help = "Size of individual files",
1469 .interval = 1024 * 1024,
1470 .category = FIO_OPT_C_FILE,
1471 .group = FIO_OPT_G_INVALID,
1474 .name = "file_append",
1475 .lname = "File append",
1476 .type = FIO_OPT_BOOL,
1477 .off1 = td_var_offset(file_append),
1478 .help = "IO will start at the end of the file(s)",
1480 .category = FIO_OPT_C_FILE,
1481 .group = FIO_OPT_G_INVALID,
1485 .lname = "IO offset",
1486 .alias = "fileoffset",
1487 .type = FIO_OPT_STR_VAL,
1488 .off1 = td_var_offset(start_offset),
1489 .help = "Start IO from this offset",
1491 .interval = 1024 * 1024,
1492 .category = FIO_OPT_C_IO,
1493 .group = FIO_OPT_G_INVALID,
1496 .name = "offset_increment",
1497 .lname = "IO offset increment",
1498 .type = FIO_OPT_STR_VAL,
1499 .off1 = td_var_offset(offset_increment),
1500 .help = "What is the increment from one offset to the next",
1504 .interval = 1024 * 1024,
1505 .category = FIO_OPT_C_IO,
1506 .group = FIO_OPT_G_INVALID,
1509 .name = "number_ios",
1510 .lname = "Number of IOs to perform",
1511 .type = FIO_OPT_STR_VAL,
1512 .off1 = td_var_offset(number_ios),
1513 .help = "Force job completion after this number of IOs",
1515 .category = FIO_OPT_C_IO,
1516 .group = FIO_OPT_G_INVALID,
1520 .lname = "Block size",
1521 .alias = "blocksize",
1522 .type = FIO_OPT_INT,
1523 .off1 = td_var_offset(bs[DDIR_READ]),
1524 .off2 = td_var_offset(bs[DDIR_WRITE]),
1525 .off3 = td_var_offset(bs[DDIR_TRIM]),
1527 .help = "Block size unit",
1532 .category = FIO_OPT_C_IO,
1533 .group = FIO_OPT_G_INVALID,
1537 .lname = "Block size align",
1538 .alias = "blockalign",
1539 .type = FIO_OPT_INT,
1540 .off1 = td_var_offset(ba[DDIR_READ]),
1541 .off2 = td_var_offset(ba[DDIR_WRITE]),
1542 .off3 = td_var_offset(ba[DDIR_TRIM]),
1544 .help = "IO block offset alignment",
1548 .category = FIO_OPT_C_IO,
1549 .group = FIO_OPT_G_INVALID,
1553 .lname = "Block size range",
1554 .alias = "blocksize_range",
1555 .type = FIO_OPT_RANGE,
1556 .off1 = td_var_offset(min_bs[DDIR_READ]),
1557 .off2 = td_var_offset(max_bs[DDIR_READ]),
1558 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
1559 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
1560 .off5 = td_var_offset(min_bs[DDIR_TRIM]),
1561 .off6 = td_var_offset(max_bs[DDIR_TRIM]),
1563 .help = "Set block size range (in more detail than bs)",
1567 .category = FIO_OPT_C_IO,
1568 .group = FIO_OPT_G_INVALID,
1572 .lname = "Block size split",
1573 .type = FIO_OPT_STR,
1574 .cb = str_bssplit_cb,
1575 .off1 = td_var_offset(bssplit),
1576 .help = "Set a specific mix of block sizes",
1579 .category = FIO_OPT_C_IO,
1580 .group = FIO_OPT_G_INVALID,
1583 .name = "bs_unaligned",
1584 .lname = "Block size unaligned",
1585 .alias = "blocksize_unaligned",
1586 .type = FIO_OPT_STR_SET,
1587 .off1 = td_var_offset(bs_unaligned),
1588 .help = "Don't sector align IO buffer sizes",
1591 .category = FIO_OPT_C_IO,
1592 .group = FIO_OPT_G_INVALID,
1595 .name = "bs_is_seq_rand",
1596 .lname = "Block size division is seq/random (not read/write)",
1597 .type = FIO_OPT_BOOL,
1598 .off1 = td_var_offset(bs_is_seq_rand),
1599 .help = "Consider any blocksize setting to be sequential,random",
1601 .parent = "blocksize",
1602 .category = FIO_OPT_C_IO,
1603 .group = FIO_OPT_G_INVALID,
1606 .name = "randrepeat",
1607 .lname = "Random repeatable",
1608 .type = FIO_OPT_BOOL,
1609 .off1 = td_var_offset(rand_repeatable),
1610 .help = "Use repeatable random IO pattern",
1614 .category = FIO_OPT_C_IO,
1615 .group = FIO_OPT_G_RANDOM,
1619 .lname = "The random generator seed",
1620 .type = FIO_OPT_STR_VAL,
1621 .off1 = td_var_offset(rand_seed),
1622 .help = "Set the random generator seed value",
1625 .category = FIO_OPT_C_IO,
1626 .group = FIO_OPT_G_RANDOM,
1629 .name = "use_os_rand",
1630 .lname = "Use OS random",
1631 .type = FIO_OPT_DEPRECATED,
1632 .off1 = td_var_offset(dep_use_os_rand),
1633 .category = FIO_OPT_C_IO,
1634 .group = FIO_OPT_G_RANDOM,
1637 .name = "norandommap",
1638 .lname = "No randommap",
1639 .type = FIO_OPT_STR_SET,
1640 .off1 = td_var_offset(norandommap),
1641 .help = "Accept potential duplicate random blocks",
1645 .category = FIO_OPT_C_IO,
1646 .group = FIO_OPT_G_RANDOM,
1649 .name = "softrandommap",
1650 .lname = "Soft randommap",
1651 .type = FIO_OPT_BOOL,
1652 .off1 = td_var_offset(softrandommap),
1653 .help = "Set norandommap if randommap allocation fails",
1654 .parent = "norandommap",
1657 .category = FIO_OPT_C_IO,
1658 .group = FIO_OPT_G_RANDOM,
1661 .name = "random_generator",
1662 .type = FIO_OPT_STR,
1663 .off1 = td_var_offset(random_generator),
1664 .help = "Type of random number generator to use",
1665 .def = "tausworthe",
1667 { .ival = "tausworthe",
1668 .oval = FIO_RAND_GEN_TAUSWORTHE,
1669 .help = "Strong Tausworthe generator",
1672 .oval = FIO_RAND_GEN_LFSR,
1673 .help = "Variable length LFSR",
1676 .ival = "tausworthe64",
1677 .oval = FIO_RAND_GEN_TAUSWORTHE64,
1678 .help = "64-bit Tausworthe variant",
1681 .category = FIO_OPT_C_IO,
1682 .group = FIO_OPT_G_RANDOM,
1685 .name = "random_distribution",
1686 .type = FIO_OPT_STR,
1687 .off1 = td_var_offset(random_distribution),
1688 .cb = str_random_distribution_cb,
1689 .help = "Random offset distribution generator",
1693 .oval = FIO_RAND_DIST_RANDOM,
1694 .help = "Completely random",
1697 .oval = FIO_RAND_DIST_ZIPF,
1698 .help = "Zipf distribution",
1701 .oval = FIO_RAND_DIST_PARETO,
1702 .help = "Pareto distribution",
1705 .oval = FIO_RAND_DIST_GAUSS,
1706 .help = "Normal (gaussian) distribution",
1709 .category = FIO_OPT_C_IO,
1710 .group = FIO_OPT_G_RANDOM,
1713 .name = "percentage_random",
1714 .lname = "Percentage Random",
1715 .type = FIO_OPT_INT,
1716 .off1 = td_var_offset(perc_rand[DDIR_READ]),
1717 .off2 = td_var_offset(perc_rand[DDIR_WRITE]),
1718 .off3 = td_var_offset(perc_rand[DDIR_TRIM]),
1720 .help = "Percentage of seq/random mix that should be random",
1721 .def = "100,100,100",
1723 .inverse = "percentage_sequential",
1724 .category = FIO_OPT_C_IO,
1725 .group = FIO_OPT_G_RANDOM,
1728 .name = "percentage_sequential",
1729 .lname = "Percentage Sequential",
1730 .type = FIO_OPT_DEPRECATED,
1731 .category = FIO_OPT_C_IO,
1732 .group = FIO_OPT_G_RANDOM,
1735 .name = "allrandrepeat",
1736 .type = FIO_OPT_BOOL,
1737 .off1 = td_var_offset(allrand_repeatable),
1738 .help = "Use repeatable random numbers for everything",
1740 .category = FIO_OPT_C_IO,
1741 .group = FIO_OPT_G_RANDOM,
1745 .lname = "Number of files",
1746 .alias = "nr_files",
1747 .type = FIO_OPT_INT,
1748 .off1 = td_var_offset(nr_files),
1749 .help = "Split job workload between this number of files",
1752 .category = FIO_OPT_C_FILE,
1753 .group = FIO_OPT_G_INVALID,
1756 .name = "openfiles",
1757 .lname = "Number of open files",
1758 .type = FIO_OPT_INT,
1759 .off1 = td_var_offset(open_files),
1760 .help = "Number of files to keep open at the same time",
1761 .category = FIO_OPT_C_FILE,
1762 .group = FIO_OPT_G_INVALID,
1765 .name = "file_service_type",
1766 .lname = "File service type",
1767 .type = FIO_OPT_STR,
1769 .off1 = td_var_offset(file_service_type),
1770 .help = "How to select which file to service next",
1771 .def = "roundrobin",
1772 .category = FIO_OPT_C_FILE,
1773 .group = FIO_OPT_G_INVALID,
1776 .oval = FIO_FSERVICE_RANDOM,
1777 .help = "Choose a file at random",
1779 { .ival = "roundrobin",
1780 .oval = FIO_FSERVICE_RR,
1781 .help = "Round robin select files",
1783 { .ival = "sequential",
1784 .oval = FIO_FSERVICE_SEQ,
1785 .help = "Finish one file before moving to the next",
1788 .parent = "nrfiles",
1791 #ifdef CONFIG_POSIX_FALLOCATE
1793 .name = "fallocate",
1794 .lname = "Fallocate",
1795 .type = FIO_OPT_STR,
1796 .off1 = td_var_offset(fallocate_mode),
1797 .help = "Whether pre-allocation is performed when laying out files",
1799 .category = FIO_OPT_C_FILE,
1800 .group = FIO_OPT_G_INVALID,
1803 .oval = FIO_FALLOCATE_NONE,
1804 .help = "Do not pre-allocate space",
1807 .oval = FIO_FALLOCATE_POSIX,
1808 .help = "Use posix_fallocate()",
1810 #ifdef CONFIG_LINUX_FALLOCATE
1812 .oval = FIO_FALLOCATE_KEEP_SIZE,
1813 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
1816 /* Compatibility with former boolean values */
1818 .oval = FIO_FALLOCATE_NONE,
1819 .help = "Alias for 'none'",
1822 .oval = FIO_FALLOCATE_POSIX,
1823 .help = "Alias for 'posix'",
1827 #endif /* CONFIG_POSIX_FALLOCATE */
1829 .name = "fadvise_hint",
1830 .lname = "Fadvise hint",
1831 .type = FIO_OPT_BOOL,
1832 .off1 = td_var_offset(fadvise_hint),
1833 .help = "Use fadvise() to advise the kernel on IO pattern",
1835 .category = FIO_OPT_C_FILE,
1836 .group = FIO_OPT_G_INVALID,
1838 #ifdef FIO_HAVE_STREAMID
1840 .name = "fadvise_stream",
1841 .lname = "Fadvise stream",
1842 .type = FIO_OPT_INT,
1843 .off1 = td_var_offset(fadvise_stream),
1844 .help = "Use fadvise() to set stream ID",
1845 .category = FIO_OPT_C_FILE,
1846 .group = FIO_OPT_G_INVALID,
1852 .type = FIO_OPT_INT,
1853 .off1 = td_var_offset(fsync_blocks),
1854 .help = "Issue fsync for writes every given number of blocks",
1857 .category = FIO_OPT_C_FILE,
1858 .group = FIO_OPT_G_INVALID,
1861 .name = "fdatasync",
1862 .lname = "Fdatasync",
1863 .type = FIO_OPT_INT,
1864 .off1 = td_var_offset(fdatasync_blocks),
1865 .help = "Issue fdatasync for writes every given number of blocks",
1868 .category = FIO_OPT_C_FILE,
1869 .group = FIO_OPT_G_INVALID,
1872 .name = "write_barrier",
1873 .lname = "Write barrier",
1874 .type = FIO_OPT_INT,
1875 .off1 = td_var_offset(barrier_blocks),
1876 .help = "Make every Nth write a barrier write",
1879 .category = FIO_OPT_C_IO,
1880 .group = FIO_OPT_G_INVALID,
1882 #ifdef CONFIG_SYNC_FILE_RANGE
1884 .name = "sync_file_range",
1885 .lname = "Sync file range",
1887 { .ival = "wait_before",
1888 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
1889 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
1893 .oval = SYNC_FILE_RANGE_WRITE,
1894 .help = "SYNC_FILE_RANGE_WRITE",
1898 .ival = "wait_after",
1899 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
1900 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
1904 .type = FIO_OPT_STR_MULTI,
1906 .off1 = td_var_offset(sync_file_range),
1907 .help = "Use sync_file_range()",
1908 .category = FIO_OPT_C_FILE,
1909 .group = FIO_OPT_G_INVALID,
1914 .lname = "Direct I/O",
1915 .type = FIO_OPT_BOOL,
1916 .off1 = td_var_offset(odirect),
1917 .help = "Use O_DIRECT IO (negates buffered)",
1919 .inverse = "buffered",
1920 .category = FIO_OPT_C_IO,
1921 .group = FIO_OPT_G_IO_TYPE,
1925 .lname = "Atomic I/O",
1926 .type = FIO_OPT_BOOL,
1927 .off1 = td_var_offset(oatomic),
1928 .help = "Use Atomic IO with O_DIRECT (implies O_DIRECT)",
1930 .category = FIO_OPT_C_IO,
1931 .group = FIO_OPT_G_IO_TYPE,
1935 .lname = "Buffered I/O",
1936 .type = FIO_OPT_BOOL,
1937 .off1 = td_var_offset(odirect),
1939 .help = "Use buffered IO (negates direct)",
1941 .inverse = "direct",
1942 .category = FIO_OPT_C_IO,
1943 .group = FIO_OPT_G_IO_TYPE,
1946 .name = "overwrite",
1947 .lname = "Overwrite",
1948 .type = FIO_OPT_BOOL,
1949 .off1 = td_var_offset(overwrite),
1950 .help = "When writing, set whether to overwrite current data",
1952 .category = FIO_OPT_C_FILE,
1953 .group = FIO_OPT_G_INVALID,
1958 .type = FIO_OPT_INT,
1959 .off1 = td_var_offset(loops),
1960 .help = "Number of times to run the job",
1963 .category = FIO_OPT_C_GENERAL,
1964 .group = FIO_OPT_G_RUNTIME,
1968 .lname = "Number of jobs",
1969 .type = FIO_OPT_INT,
1970 .off1 = td_var_offset(numjobs),
1971 .help = "Duplicate this job this many times",
1974 .category = FIO_OPT_C_GENERAL,
1975 .group = FIO_OPT_G_RUNTIME,
1978 .name = "startdelay",
1979 .lname = "Start delay",
1980 .type = FIO_OPT_STR_VAL_TIME,
1981 .off1 = td_var_offset(start_delay),
1982 .off2 = td_var_offset(start_delay_high),
1983 .help = "Only start job when this period has passed",
1987 .category = FIO_OPT_C_GENERAL,
1988 .group = FIO_OPT_G_RUNTIME,
1994 .type = FIO_OPT_STR_VAL_TIME,
1995 .off1 = td_var_offset(timeout),
1996 .help = "Stop workload when this amount of time has passed",
2000 .category = FIO_OPT_C_GENERAL,
2001 .group = FIO_OPT_G_RUNTIME,
2004 .name = "time_based",
2005 .lname = "Time based",
2006 .type = FIO_OPT_STR_SET,
2007 .off1 = td_var_offset(time_based),
2008 .help = "Keep running until runtime/timeout is met",
2009 .category = FIO_OPT_C_GENERAL,
2010 .group = FIO_OPT_G_RUNTIME,
2013 .name = "verify_only",
2014 .lname = "Verify only",
2015 .type = FIO_OPT_STR_SET,
2016 .off1 = td_var_offset(verify_only),
2017 .help = "Verifies previously written data is still valid",
2018 .category = FIO_OPT_C_GENERAL,
2019 .group = FIO_OPT_G_RUNTIME,
2022 .name = "ramp_time",
2023 .lname = "Ramp time",
2024 .type = FIO_OPT_STR_VAL_TIME,
2025 .off1 = td_var_offset(ramp_time),
2026 .help = "Ramp up time before measuring performance",
2029 .category = FIO_OPT_C_GENERAL,
2030 .group = FIO_OPT_G_RUNTIME,
2033 .name = "clocksource",
2034 .lname = "Clock source",
2035 .type = FIO_OPT_STR,
2036 .cb = fio_clock_source_cb,
2037 .off1 = td_var_offset(clocksource),
2038 .help = "What type of timing source to use",
2039 .category = FIO_OPT_C_GENERAL,
2040 .group = FIO_OPT_G_CLOCK,
2042 #ifdef CONFIG_GETTIMEOFDAY
2043 { .ival = "gettimeofday",
2045 .help = "Use gettimeofday(2) for timing",
2048 #ifdef CONFIG_CLOCK_GETTIME
2049 { .ival = "clock_gettime",
2050 .oval = CS_CGETTIME,
2051 .help = "Use clock_gettime(2) for timing",
2054 #ifdef ARCH_HAVE_CPU_CLOCK
2056 .oval = CS_CPUCLOCK,
2057 .help = "Use CPU private clock",
2065 .lname = "I/O Memory",
2066 .type = FIO_OPT_STR,
2068 .off1 = td_var_offset(mem_type),
2069 .help = "Backing type for IO buffers",
2071 .category = FIO_OPT_C_IO,
2072 .group = FIO_OPT_G_INVALID,
2076 .help = "Use malloc(3) for IO buffers",
2078 #ifndef CONFIG_NO_SHM
2081 .help = "Use shared memory segments for IO buffers",
2083 #ifdef FIO_HAVE_HUGETLB
2084 { .ival = "shmhuge",
2085 .oval = MEM_SHMHUGE,
2086 .help = "Like shm, but use huge pages",
2092 .help = "Use mmap(2) (file or anon) for IO buffers",
2094 { .ival = "mmapshared",
2095 .oval = MEM_MMAPSHARED,
2096 .help = "Like mmap, but use the shared flag",
2098 #ifdef FIO_HAVE_HUGETLB
2099 { .ival = "mmaphuge",
2100 .oval = MEM_MMAPHUGE,
2101 .help = "Like mmap, but use huge pages",
2107 .name = "iomem_align",
2108 .alias = "mem_align",
2109 .lname = "I/O memory alignment",
2110 .type = FIO_OPT_INT,
2111 .off1 = td_var_offset(mem_align),
2113 .help = "IO memory buffer offset alignment",
2117 .category = FIO_OPT_C_IO,
2118 .group = FIO_OPT_G_INVALID,
2123 .type = FIO_OPT_STR,
2124 .off1 = td_var_offset(verify),
2125 .help = "Verify data written",
2127 .category = FIO_OPT_C_IO,
2128 .group = FIO_OPT_G_VERIFY,
2131 .oval = VERIFY_NONE,
2132 .help = "Don't do IO verification",
2136 .help = "Use md5 checksums for verification",
2139 .oval = VERIFY_CRC64,
2140 .help = "Use crc64 checksums for verification",
2143 .oval = VERIFY_CRC32,
2144 .help = "Use crc32 checksums for verification",
2146 { .ival = "crc32c-intel",
2147 .oval = VERIFY_CRC32C,
2148 .help = "Use crc32c checksums for verification (hw assisted, if available)",
2151 .oval = VERIFY_CRC32C,
2152 .help = "Use crc32c checksums for verification (hw assisted, if available)",
2155 .oval = VERIFY_CRC16,
2156 .help = "Use crc16 checksums for verification",
2159 .oval = VERIFY_CRC7,
2160 .help = "Use crc7 checksums for verification",
2163 .oval = VERIFY_SHA1,
2164 .help = "Use sha1 checksums for verification",
2167 .oval = VERIFY_SHA256,
2168 .help = "Use sha256 checksums for verification",
2171 .oval = VERIFY_SHA512,
2172 .help = "Use sha512 checksums for verification",
2175 .oval = VERIFY_XXHASH,
2176 .help = "Use xxhash checksums for verification",
2178 /* Meta information was included into verify_header,
2179 * 'meta' verification is implied by default. */
2181 .oval = VERIFY_HDR_ONLY,
2182 .help = "Use io information for verification. "
2183 "Now is implied by default, thus option is obsolete, "
2186 { .ival = "pattern",
2187 .oval = VERIFY_PATTERN_NO_HDR,
2188 .help = "Verify strict pattern",
2192 .oval = VERIFY_NULL,
2193 .help = "Pretend to verify",
2198 .name = "do_verify",
2199 .lname = "Perform verify step",
2200 .type = FIO_OPT_BOOL,
2201 .off1 = td_var_offset(do_verify),
2202 .help = "Run verification stage after write",
2206 .category = FIO_OPT_C_IO,
2207 .group = FIO_OPT_G_VERIFY,
2210 .name = "verifysort",
2211 .lname = "Verify sort",
2212 .type = FIO_OPT_BOOL,
2213 .off1 = td_var_offset(verifysort),
2214 .help = "Sort written verify blocks for read back",
2218 .category = FIO_OPT_C_IO,
2219 .group = FIO_OPT_G_VERIFY,
2222 .name = "verifysort_nr",
2223 .type = FIO_OPT_INT,
2224 .off1 = td_var_offset(verifysort_nr),
2225 .help = "Pre-load and sort verify blocks for a read workload",
2230 .category = FIO_OPT_C_IO,
2231 .group = FIO_OPT_G_VERIFY,
2234 .name = "verify_interval",
2235 .lname = "Verify interval",
2236 .type = FIO_OPT_INT,
2237 .off1 = td_var_offset(verify_interval),
2238 .minval = 2 * sizeof(struct verify_header),
2239 .help = "Store verify buffer header every N bytes",
2242 .interval = 2 * sizeof(struct verify_header),
2243 .category = FIO_OPT_C_IO,
2244 .group = FIO_OPT_G_VERIFY,
2247 .name = "verify_offset",
2248 .lname = "Verify offset",
2249 .type = FIO_OPT_INT,
2250 .help = "Offset verify header location by N bytes",
2251 .off1 = td_var_offset(verify_offset),
2252 .minval = sizeof(struct verify_header),
2255 .category = FIO_OPT_C_IO,
2256 .group = FIO_OPT_G_VERIFY,
2259 .name = "verify_pattern",
2260 .lname = "Verify pattern",
2261 .type = FIO_OPT_STR,
2262 .cb = str_verify_pattern_cb,
2263 .off1 = td_var_offset(verify_pattern),
2264 .help = "Fill pattern for IO buffers",
2267 .category = FIO_OPT_C_IO,
2268 .group = FIO_OPT_G_VERIFY,
2271 .name = "verify_fatal",
2272 .lname = "Verify fatal",
2273 .type = FIO_OPT_BOOL,
2274 .off1 = td_var_offset(verify_fatal),
2276 .help = "Exit on a single verify failure, don't continue",
2279 .category = FIO_OPT_C_IO,
2280 .group = FIO_OPT_G_VERIFY,
2283 .name = "verify_dump",
2284 .lname = "Verify dump",
2285 .type = FIO_OPT_BOOL,
2286 .off1 = td_var_offset(verify_dump),
2288 .help = "Dump contents of good and bad blocks on failure",
2291 .category = FIO_OPT_C_IO,
2292 .group = FIO_OPT_G_VERIFY,
2295 .name = "verify_async",
2296 .lname = "Verify asynchronously",
2297 .type = FIO_OPT_INT,
2298 .off1 = td_var_offset(verify_async),
2300 .help = "Number of async verifier threads to use",
2303 .category = FIO_OPT_C_IO,
2304 .group = FIO_OPT_G_VERIFY,
2307 .name = "verify_backlog",
2308 .lname = "Verify backlog",
2309 .type = FIO_OPT_STR_VAL,
2310 .off1 = td_var_offset(verify_backlog),
2311 .help = "Verify after this number of blocks are written",
2314 .category = FIO_OPT_C_IO,
2315 .group = FIO_OPT_G_VERIFY,
2318 .name = "verify_backlog_batch",
2319 .lname = "Verify backlog batch",
2320 .type = FIO_OPT_INT,
2321 .off1 = td_var_offset(verify_batch),
2322 .help = "Verify this number of IO blocks",
2325 .category = FIO_OPT_C_IO,
2326 .group = FIO_OPT_G_VERIFY,
2328 #ifdef FIO_HAVE_CPU_AFFINITY
2330 .name = "verify_async_cpus",
2331 .lname = "Async verify CPUs",
2332 .type = FIO_OPT_STR,
2333 .cb = str_verify_cpus_allowed_cb,
2334 .off1 = td_var_offset(verify_cpumask),
2335 .help = "Set CPUs allowed for async verify threads",
2336 .parent = "verify_async",
2338 .category = FIO_OPT_C_IO,
2339 .group = FIO_OPT_G_VERIFY,
2343 .name = "experimental_verify",
2344 .off1 = td_var_offset(experimental_verify),
2345 .type = FIO_OPT_BOOL,
2346 .help = "Enable experimental verification",
2348 .category = FIO_OPT_C_IO,
2349 .group = FIO_OPT_G_VERIFY,
2352 .name = "verify_state_load",
2353 .lname = "Load verify state",
2354 .off1 = td_var_offset(verify_state),
2355 .type = FIO_OPT_BOOL,
2356 .help = "Load verify termination state",
2358 .category = FIO_OPT_C_IO,
2359 .group = FIO_OPT_G_VERIFY,
2362 .name = "verify_state_save",
2363 .lname = "Save verify state",
2364 .off1 = td_var_offset(verify_state_save),
2365 .type = FIO_OPT_BOOL,
2367 .help = "Save verify state on termination",
2369 .category = FIO_OPT_C_IO,
2370 .group = FIO_OPT_G_VERIFY,
2372 #ifdef FIO_HAVE_TRIM
2374 .name = "trim_percentage",
2375 .lname = "Trim percentage",
2376 .type = FIO_OPT_INT,
2377 .off1 = td_var_offset(trim_percentage),
2380 .help = "Number of verify blocks to discard/trim",
2385 .category = FIO_OPT_C_IO,
2386 .group = FIO_OPT_G_TRIM,
2389 .name = "trim_verify_zero",
2390 .lname = "Verify trim zero",
2391 .type = FIO_OPT_BOOL,
2392 .help = "Verify that trim/discarded blocks are returned as zeroes",
2393 .off1 = td_var_offset(trim_zero),
2394 .parent = "trim_percentage",
2397 .category = FIO_OPT_C_IO,
2398 .group = FIO_OPT_G_TRIM,
2401 .name = "trim_backlog",
2402 .lname = "Trim backlog",
2403 .type = FIO_OPT_STR_VAL,
2404 .off1 = td_var_offset(trim_backlog),
2405 .help = "Trim after this number of blocks are written",
2406 .parent = "trim_percentage",
2409 .category = FIO_OPT_C_IO,
2410 .group = FIO_OPT_G_TRIM,
2413 .name = "trim_backlog_batch",
2414 .lname = "Trim backlog batch",
2415 .type = FIO_OPT_INT,
2416 .off1 = td_var_offset(trim_batch),
2417 .help = "Trim this number of IO blocks",
2418 .parent = "trim_percentage",
2421 .category = FIO_OPT_C_IO,
2422 .group = FIO_OPT_G_TRIM,
2426 .name = "write_iolog",
2427 .lname = "Write I/O log",
2428 .type = FIO_OPT_STR_STORE,
2429 .off1 = td_var_offset(write_iolog_file),
2430 .help = "Store IO pattern to file",
2431 .category = FIO_OPT_C_IO,
2432 .group = FIO_OPT_G_IOLOG,
2435 .name = "read_iolog",
2436 .lname = "Read I/O log",
2437 .type = FIO_OPT_STR_STORE,
2438 .off1 = td_var_offset(read_iolog_file),
2439 .help = "Playback IO pattern from file",
2440 .category = FIO_OPT_C_IO,
2441 .group = FIO_OPT_G_IOLOG,
2444 .name = "replay_no_stall",
2445 .lname = "Don't stall on replay",
2446 .type = FIO_OPT_BOOL,
2447 .off1 = td_var_offset(no_stall),
2449 .parent = "read_iolog",
2451 .help = "Playback IO pattern file as fast as possible without stalls",
2452 .category = FIO_OPT_C_IO,
2453 .group = FIO_OPT_G_IOLOG,
2456 .name = "replay_redirect",
2457 .lname = "Redirect device for replay",
2458 .type = FIO_OPT_STR_STORE,
2459 .off1 = td_var_offset(replay_redirect),
2460 .parent = "read_iolog",
2462 .help = "Replay all I/O onto this device, regardless of trace device",
2463 .category = FIO_OPT_C_IO,
2464 .group = FIO_OPT_G_IOLOG,
2467 .name = "replay_scale",
2468 .lname = "Replace offset scale factor",
2469 .type = FIO_OPT_INT,
2470 .off1 = td_var_offset(replay_scale),
2471 .parent = "read_iolog",
2473 .help = "Align offsets to this blocksize",
2474 .category = FIO_OPT_C_IO,
2475 .group = FIO_OPT_G_IOLOG,
2478 .name = "replay_align",
2479 .lname = "Replace alignment",
2480 .type = FIO_OPT_INT,
2481 .off1 = td_var_offset(replay_align),
2482 .parent = "read_iolog",
2483 .help = "Scale offset down by this factor",
2484 .category = FIO_OPT_C_IO,
2485 .group = FIO_OPT_G_IOLOG,
2489 .name = "exec_prerun",
2490 .lname = "Pre-execute runnable",
2491 .type = FIO_OPT_STR_STORE,
2492 .off1 = td_var_offset(exec_prerun),
2493 .help = "Execute this file prior to running job",
2494 .category = FIO_OPT_C_GENERAL,
2495 .group = FIO_OPT_G_INVALID,
2498 .name = "exec_postrun",
2499 .lname = "Post-execute runnable",
2500 .type = FIO_OPT_STR_STORE,
2501 .off1 = td_var_offset(exec_postrun),
2502 .help = "Execute this file after running job",
2503 .category = FIO_OPT_C_GENERAL,
2504 .group = FIO_OPT_G_INVALID,
2506 #ifdef FIO_HAVE_IOSCHED_SWITCH
2508 .name = "ioscheduler",
2509 .lname = "I/O scheduler",
2510 .type = FIO_OPT_STR_STORE,
2511 .off1 = td_var_offset(ioscheduler),
2512 .help = "Use this IO scheduler on the backing device",
2513 .category = FIO_OPT_C_FILE,
2514 .group = FIO_OPT_G_INVALID,
2519 .lname = "Zone size",
2520 .type = FIO_OPT_STR_VAL,
2521 .off1 = td_var_offset(zone_size),
2522 .help = "Amount of data to read per zone",
2524 .interval = 1024 * 1024,
2525 .category = FIO_OPT_C_IO,
2526 .group = FIO_OPT_G_ZONE,
2529 .name = "zonerange",
2530 .lname = "Zone range",
2531 .type = FIO_OPT_STR_VAL,
2532 .off1 = td_var_offset(zone_range),
2533 .help = "Give size of an IO zone",
2535 .interval = 1024 * 1024,
2536 .category = FIO_OPT_C_IO,
2537 .group = FIO_OPT_G_ZONE,
2541 .lname = "Zone skip",
2542 .type = FIO_OPT_STR_VAL,
2543 .off1 = td_var_offset(zone_skip),
2544 .help = "Space between IO zones",
2546 .interval = 1024 * 1024,
2547 .category = FIO_OPT_C_IO,
2548 .group = FIO_OPT_G_ZONE,
2552 .lname = "Lock memory",
2553 .type = FIO_OPT_STR_VAL,
2554 .off1 = td_var_offset(lockmem),
2555 .help = "Lock down this amount of memory (per worker)",
2557 .interval = 1024 * 1024,
2558 .category = FIO_OPT_C_GENERAL,
2559 .group = FIO_OPT_G_INVALID,
2562 .name = "rwmixread",
2563 .lname = "Read/write mix read",
2564 .type = FIO_OPT_INT,
2565 .cb = str_rwmix_read_cb,
2566 .off1 = td_var_offset(rwmix[DDIR_READ]),
2568 .help = "Percentage of mixed workload that is reads",
2571 .inverse = "rwmixwrite",
2572 .category = FIO_OPT_C_IO,
2573 .group = FIO_OPT_G_RWMIX,
2576 .name = "rwmixwrite",
2577 .lname = "Read/write mix write",
2578 .type = FIO_OPT_INT,
2579 .cb = str_rwmix_write_cb,
2580 .off1 = td_var_offset(rwmix[DDIR_WRITE]),
2582 .help = "Percentage of mixed workload that is writes",
2585 .inverse = "rwmixread",
2586 .category = FIO_OPT_C_IO,
2587 .group = FIO_OPT_G_RWMIX,
2590 .name = "rwmixcycle",
2591 .lname = "Read/write mix cycle",
2592 .type = FIO_OPT_DEPRECATED,
2593 .category = FIO_OPT_C_IO,
2594 .group = FIO_OPT_G_RWMIX,
2599 .type = FIO_OPT_INT,
2600 .off1 = td_var_offset(nice),
2601 .help = "Set job CPU nice value",
2606 .category = FIO_OPT_C_GENERAL,
2607 .group = FIO_OPT_G_CRED,
2609 #ifdef FIO_HAVE_IOPRIO
2612 .lname = "I/O nice priority",
2613 .type = FIO_OPT_INT,
2614 .off1 = td_var_offset(ioprio),
2615 .help = "Set job IO priority value",
2619 .category = FIO_OPT_C_GENERAL,
2620 .group = FIO_OPT_G_CRED,
2623 .name = "prioclass",
2624 .lname = "I/O nice priority class",
2625 .type = FIO_OPT_INT,
2626 .off1 = td_var_offset(ioprio_class),
2627 .help = "Set job IO priority class",
2631 .category = FIO_OPT_C_GENERAL,
2632 .group = FIO_OPT_G_CRED,
2636 .name = "thinktime",
2637 .lname = "Thinktime",
2638 .type = FIO_OPT_INT,
2639 .off1 = td_var_offset(thinktime),
2640 .help = "Idle time between IO buffers (usec)",
2643 .category = FIO_OPT_C_IO,
2644 .group = FIO_OPT_G_THINKTIME,
2647 .name = "thinktime_spin",
2648 .lname = "Thinktime spin",
2649 .type = FIO_OPT_INT,
2650 .off1 = td_var_offset(thinktime_spin),
2651 .help = "Start think time by spinning this amount (usec)",
2654 .parent = "thinktime",
2656 .category = FIO_OPT_C_IO,
2657 .group = FIO_OPT_G_THINKTIME,
2660 .name = "thinktime_blocks",
2661 .lname = "Thinktime blocks",
2662 .type = FIO_OPT_INT,
2663 .off1 = td_var_offset(thinktime_blocks),
2664 .help = "IO buffer period between 'thinktime'",
2666 .parent = "thinktime",
2668 .category = FIO_OPT_C_IO,
2669 .group = FIO_OPT_G_THINKTIME,
2673 .lname = "I/O rate",
2674 .type = FIO_OPT_INT,
2675 .off1 = td_var_offset(rate[DDIR_READ]),
2676 .off2 = td_var_offset(rate[DDIR_WRITE]),
2677 .off3 = td_var_offset(rate[DDIR_TRIM]),
2678 .help = "Set bandwidth rate",
2679 .category = FIO_OPT_C_IO,
2680 .group = FIO_OPT_G_RATE,
2685 .lname = "I/O min rate",
2686 .type = FIO_OPT_INT,
2687 .off1 = td_var_offset(ratemin[DDIR_READ]),
2688 .off2 = td_var_offset(ratemin[DDIR_WRITE]),
2689 .off3 = td_var_offset(ratemin[DDIR_TRIM]),
2690 .help = "Job must meet this rate or it will be shutdown",
2693 .category = FIO_OPT_C_IO,
2694 .group = FIO_OPT_G_RATE,
2697 .name = "rate_iops",
2698 .lname = "I/O rate IOPS",
2699 .type = FIO_OPT_INT,
2700 .off1 = td_var_offset(rate_iops[DDIR_READ]),
2701 .off2 = td_var_offset(rate_iops[DDIR_WRITE]),
2702 .off3 = td_var_offset(rate_iops[DDIR_TRIM]),
2703 .help = "Limit IO used to this number of IO operations/sec",
2705 .category = FIO_OPT_C_IO,
2706 .group = FIO_OPT_G_RATE,
2709 .name = "rate_iops_min",
2710 .lname = "I/O min rate IOPS",
2711 .type = FIO_OPT_INT,
2712 .off1 = td_var_offset(rate_iops_min[DDIR_READ]),
2713 .off2 = td_var_offset(rate_iops_min[DDIR_WRITE]),
2714 .off3 = td_var_offset(rate_iops_min[DDIR_TRIM]),
2715 .help = "Job must meet this rate or it will be shut down",
2716 .parent = "rate_iops",
2718 .category = FIO_OPT_C_IO,
2719 .group = FIO_OPT_G_RATE,
2722 .name = "rate_process",
2723 .lname = "Rate Process",
2724 .type = FIO_OPT_STR,
2725 .off1 = td_var_offset(rate_process),
2726 .help = "What process controls how rated IO is managed",
2728 .category = FIO_OPT_C_IO,
2729 .group = FIO_OPT_G_RATE,
2732 .oval = RATE_PROCESS_LINEAR,
2733 .help = "Linear rate of IO",
2737 .oval = RATE_PROCESS_POISSON,
2738 .help = "Rate follows Poisson process",
2744 .name = "rate_cycle",
2745 .alias = "ratecycle",
2746 .lname = "I/O rate cycle",
2747 .type = FIO_OPT_INT,
2748 .off1 = td_var_offset(ratecycle),
2749 .help = "Window average for rate limits (msec)",
2753 .category = FIO_OPT_C_IO,
2754 .group = FIO_OPT_G_RATE,
2757 .name = "max_latency",
2758 .type = FIO_OPT_INT,
2759 .off1 = td_var_offset(max_latency),
2760 .help = "Maximum tolerated IO latency (usec)",
2762 .category = FIO_OPT_C_IO,
2763 .group = FIO_OPT_G_LATPROF,
2766 .name = "latency_target",
2767 .lname = "Latency Target (usec)",
2768 .type = FIO_OPT_STR_VAL_TIME,
2769 .off1 = td_var_offset(latency_target),
2770 .help = "Ramp to max queue depth supporting this latency",
2772 .category = FIO_OPT_C_IO,
2773 .group = FIO_OPT_G_LATPROF,
2776 .name = "latency_window",
2777 .lname = "Latency Window (usec)",
2778 .type = FIO_OPT_STR_VAL_TIME,
2779 .off1 = td_var_offset(latency_window),
2780 .help = "Time to sustain latency_target",
2782 .category = FIO_OPT_C_IO,
2783 .group = FIO_OPT_G_LATPROF,
2786 .name = "latency_percentile",
2787 .lname = "Latency Percentile",
2788 .type = FIO_OPT_FLOAT_LIST,
2789 .off1 = td_var_offset(latency_percentile),
2790 .help = "Percentile of IOs must be below latency_target",
2795 .category = FIO_OPT_C_IO,
2796 .group = FIO_OPT_G_LATPROF,
2799 .name = "invalidate",
2800 .lname = "Cache invalidate",
2801 .type = FIO_OPT_BOOL,
2802 .off1 = td_var_offset(invalidate_cache),
2803 .help = "Invalidate buffer/page cache prior to running job",
2805 .category = FIO_OPT_C_IO,
2806 .group = FIO_OPT_G_IO_TYPE,
2810 .lname = "Synchronous I/O",
2811 .type = FIO_OPT_BOOL,
2812 .off1 = td_var_offset(sync_io),
2813 .help = "Use O_SYNC for buffered writes",
2815 .parent = "buffered",
2817 .category = FIO_OPT_C_IO,
2818 .group = FIO_OPT_G_IO_TYPE,
2821 .name = "create_serialize",
2822 .lname = "Create serialize",
2823 .type = FIO_OPT_BOOL,
2824 .off1 = td_var_offset(create_serialize),
2825 .help = "Serialize creating of job files",
2827 .category = FIO_OPT_C_FILE,
2828 .group = FIO_OPT_G_INVALID,
2831 .name = "create_fsync",
2832 .lname = "Create fsync",
2833 .type = FIO_OPT_BOOL,
2834 .off1 = td_var_offset(create_fsync),
2835 .help = "fsync file after creation",
2837 .category = FIO_OPT_C_FILE,
2838 .group = FIO_OPT_G_INVALID,
2841 .name = "create_on_open",
2842 .lname = "Create on open",
2843 .type = FIO_OPT_BOOL,
2844 .off1 = td_var_offset(create_on_open),
2845 .help = "Create files when they are opened for IO",
2847 .category = FIO_OPT_C_FILE,
2848 .group = FIO_OPT_G_INVALID,
2851 .name = "create_only",
2852 .type = FIO_OPT_BOOL,
2853 .off1 = td_var_offset(create_only),
2854 .help = "Only perform file creation phase",
2855 .category = FIO_OPT_C_FILE,
2859 .name = "allow_file_create",
2860 .lname = "Allow file create",
2861 .type = FIO_OPT_BOOL,
2862 .off1 = td_var_offset(allow_create),
2863 .help = "Permit fio to create files, if they don't exist",
2865 .category = FIO_OPT_C_FILE,
2866 .group = FIO_OPT_G_FILENAME,
2869 .name = "allow_mounted_write",
2870 .lname = "Allow mounted write",
2871 .type = FIO_OPT_BOOL,
2872 .off1 = td_var_offset(allow_mounted_write),
2873 .help = "Allow writes to a mounted partition",
2875 .category = FIO_OPT_C_FILE,
2876 .group = FIO_OPT_G_FILENAME,
2880 .lname = "Pre-read files",
2881 .type = FIO_OPT_BOOL,
2882 .off1 = td_var_offset(pre_read),
2883 .help = "Pre-read files before starting official testing",
2885 .category = FIO_OPT_C_FILE,
2886 .group = FIO_OPT_G_INVALID,
2888 #ifdef FIO_HAVE_CPU_AFFINITY
2891 .lname = "CPU mask",
2892 .type = FIO_OPT_INT,
2893 .cb = str_cpumask_cb,
2894 .off1 = td_var_offset(cpumask),
2895 .help = "CPU affinity mask",
2896 .category = FIO_OPT_C_GENERAL,
2897 .group = FIO_OPT_G_CRED,
2900 .name = "cpus_allowed",
2901 .lname = "CPUs allowed",
2902 .type = FIO_OPT_STR,
2903 .cb = str_cpus_allowed_cb,
2904 .off1 = td_var_offset(cpumask),
2905 .help = "Set CPUs allowed",
2906 .category = FIO_OPT_C_GENERAL,
2907 .group = FIO_OPT_G_CRED,
2910 .name = "cpus_allowed_policy",
2911 .lname = "CPUs allowed distribution policy",
2912 .type = FIO_OPT_STR,
2913 .off1 = td_var_offset(cpus_allowed_policy),
2914 .help = "Distribution policy for cpus_allowed",
2915 .parent = "cpus_allowed",
2919 .oval = FIO_CPUS_SHARED,
2920 .help = "Mask shared between threads",
2923 .oval = FIO_CPUS_SPLIT,
2924 .help = "Mask split between threads",
2927 .category = FIO_OPT_C_GENERAL,
2928 .group = FIO_OPT_G_CRED,
2931 #ifdef CONFIG_LIBNUMA
2933 .name = "numa_cpu_nodes",
2934 .type = FIO_OPT_STR,
2935 .cb = str_numa_cpunodes_cb,
2936 .off1 = td_var_offset(numa_cpunodes),
2937 .help = "NUMA CPU nodes bind",
2938 .category = FIO_OPT_C_GENERAL,
2939 .group = FIO_OPT_G_INVALID,
2942 .name = "numa_mem_policy",
2943 .type = FIO_OPT_STR,
2944 .cb = str_numa_mpol_cb,
2945 .off1 = td_var_offset(numa_memnodes),
2946 .help = "NUMA memory policy setup",
2947 .category = FIO_OPT_C_GENERAL,
2948 .group = FIO_OPT_G_INVALID,
2952 .name = "end_fsync",
2953 .lname = "End fsync",
2954 .type = FIO_OPT_BOOL,
2955 .off1 = td_var_offset(end_fsync),
2956 .help = "Include fsync at the end of job",
2958 .category = FIO_OPT_C_FILE,
2959 .group = FIO_OPT_G_INVALID,
2962 .name = "fsync_on_close",
2963 .lname = "Fsync on close",
2964 .type = FIO_OPT_BOOL,
2965 .off1 = td_var_offset(fsync_on_close),
2966 .help = "fsync files on close",
2968 .category = FIO_OPT_C_FILE,
2969 .group = FIO_OPT_G_INVALID,
2973 .lname = "Unlink file",
2974 .type = FIO_OPT_BOOL,
2975 .off1 = td_var_offset(unlink),
2976 .help = "Unlink created files after job has completed",
2978 .category = FIO_OPT_C_FILE,
2979 .group = FIO_OPT_G_INVALID,
2983 .lname = "Exit-all on terminate",
2984 .type = FIO_OPT_STR_SET,
2985 .cb = str_exitall_cb,
2986 .help = "Terminate all jobs when one exits",
2987 .category = FIO_OPT_C_GENERAL,
2988 .group = FIO_OPT_G_PROCESS,
2991 .name = "exitall_on_error",
2992 .lname = "Exit-all on terminate in error",
2993 .type = FIO_OPT_BOOL,
2994 .off1 = td_var_offset(unlink),
2995 .help = "Terminate all jobs when one exits in error",
2996 .category = FIO_OPT_C_GENERAL,
2997 .group = FIO_OPT_G_PROCESS,
3000 .name = "stonewall",
3001 .lname = "Wait for previous",
3002 .alias = "wait_for_previous",
3003 .type = FIO_OPT_STR_SET,
3004 .off1 = td_var_offset(stonewall),
3005 .help = "Insert a hard barrier between this job and previous",
3006 .category = FIO_OPT_C_GENERAL,
3007 .group = FIO_OPT_G_PROCESS,
3010 .name = "new_group",
3011 .lname = "New group",
3012 .type = FIO_OPT_STR_SET,
3013 .off1 = td_var_offset(new_group),
3014 .help = "Mark the start of a new group (for reporting)",
3015 .category = FIO_OPT_C_GENERAL,
3016 .group = FIO_OPT_G_PROCESS,
3021 .type = FIO_OPT_STR_SET,
3022 .off1 = td_var_offset(use_thread),
3023 .help = "Use threads instead of processes",
3024 #ifdef CONFIG_NO_SHM
3028 .category = FIO_OPT_C_GENERAL,
3029 .group = FIO_OPT_G_PROCESS,
3032 .name = "per_job_logs",
3033 .type = FIO_OPT_BOOL,
3034 .off1 = td_var_offset(per_job_logs),
3035 .help = "Include job number in generated log files or not",
3037 .category = FIO_OPT_C_LOG,
3038 .group = FIO_OPT_G_INVALID,
3041 .name = "write_bw_log",
3042 .lname = "Write bandwidth log",
3043 .type = FIO_OPT_STR_STORE,
3044 .off1 = td_var_offset(bw_log_file),
3045 .help = "Write log of bandwidth during run",
3046 .category = FIO_OPT_C_LOG,
3047 .group = FIO_OPT_G_INVALID,
3050 .name = "write_lat_log",
3051 .lname = "Write latency log",
3052 .type = FIO_OPT_STR_STORE,
3053 .off1 = td_var_offset(lat_log_file),
3054 .help = "Write log of latency during run",
3055 .category = FIO_OPT_C_LOG,
3056 .group = FIO_OPT_G_INVALID,
3059 .name = "write_iops_log",
3060 .lname = "Write IOPS log",
3061 .type = FIO_OPT_STR_STORE,
3062 .off1 = td_var_offset(iops_log_file),
3063 .help = "Write log of IOPS during run",
3064 .category = FIO_OPT_C_LOG,
3065 .group = FIO_OPT_G_INVALID,
3068 .name = "log_avg_msec",
3069 .lname = "Log averaging (msec)",
3070 .type = FIO_OPT_INT,
3071 .off1 = td_var_offset(log_avg_msec),
3072 .help = "Average bw/iops/lat logs over this period of time",
3074 .category = FIO_OPT_C_LOG,
3075 .group = FIO_OPT_G_INVALID,
3078 .name = "log_offset",
3079 .lname = "Log offset of IO",
3080 .type = FIO_OPT_BOOL,
3081 .off1 = td_var_offset(log_offset),
3082 .help = "Include offset of IO for each log entry",
3084 .category = FIO_OPT_C_LOG,
3085 .group = FIO_OPT_G_INVALID,
3089 .name = "log_compression",
3090 .lname = "Log compression",
3091 .type = FIO_OPT_INT,
3092 .off1 = td_var_offset(log_gz),
3093 .help = "Log in compressed chunks of this size",
3095 .maxval = 512 * 1024 * 1024ULL,
3096 .category = FIO_OPT_C_LOG,
3097 .group = FIO_OPT_G_INVALID,
3099 #ifdef FIO_HAVE_CPU_AFFINITY
3101 .name = "log_compression_cpus",
3102 .lname = "Log Compression CPUs",
3103 .type = FIO_OPT_STR,
3104 .cb = str_log_cpus_allowed_cb,
3105 .off1 = td_var_offset(log_gz_cpumask),
3106 .parent = "log_compression",
3107 .help = "Limit log compression to these CPUs",
3108 .category = FIO_OPT_C_LOG,
3109 .group = FIO_OPT_G_INVALID,
3113 .name = "log_store_compressed",
3114 .lname = "Log store compressed",
3115 .type = FIO_OPT_BOOL,
3116 .off1 = td_var_offset(log_gz_store),
3117 .help = "Store logs in a compressed format",
3118 .category = FIO_OPT_C_LOG,
3119 .group = FIO_OPT_G_INVALID,
3123 .name = "block_error_percentiles",
3124 .lname = "Block error percentiles",
3125 .type = FIO_OPT_BOOL,
3126 .off1 = td_var_offset(block_error_hist),
3127 .help = "Record trim block errors and make a histogram",
3129 .category = FIO_OPT_C_LOG,
3130 .group = FIO_OPT_G_INVALID,
3133 .name = "bwavgtime",
3134 .lname = "Bandwidth average time",
3135 .type = FIO_OPT_INT,
3136 .off1 = td_var_offset(bw_avg_time),
3137 .help = "Time window over which to calculate bandwidth"
3140 .parent = "write_bw_log",
3143 .category = FIO_OPT_C_LOG,
3144 .group = FIO_OPT_G_INVALID,
3147 .name = "iopsavgtime",
3148 .lname = "IOPS average time",
3149 .type = FIO_OPT_INT,
3150 .off1 = td_var_offset(iops_avg_time),
3151 .help = "Time window over which to calculate IOPS (msec)",
3153 .parent = "write_iops_log",
3156 .category = FIO_OPT_C_LOG,
3157 .group = FIO_OPT_G_INVALID,
3160 .name = "group_reporting",
3161 .lname = "Group reporting",
3162 .type = FIO_OPT_STR_SET,
3163 .off1 = td_var_offset(group_reporting),
3164 .help = "Do reporting on a per-group basis",
3165 .category = FIO_OPT_C_STAT,
3166 .group = FIO_OPT_G_INVALID,
3169 .name = "zero_buffers",
3170 .lname = "Zero I/O buffers",
3171 .type = FIO_OPT_STR_SET,
3172 .off1 = td_var_offset(zero_buffers),
3173 .help = "Init IO buffers to all zeroes",
3174 .category = FIO_OPT_C_IO,
3175 .group = FIO_OPT_G_IO_BUF,
3178 .name = "refill_buffers",
3179 .lname = "Refill I/O buffers",
3180 .type = FIO_OPT_STR_SET,
3181 .off1 = td_var_offset(refill_buffers),
3182 .help = "Refill IO buffers on every IO submit",
3183 .category = FIO_OPT_C_IO,
3184 .group = FIO_OPT_G_IO_BUF,
3187 .name = "scramble_buffers",
3188 .lname = "Scramble I/O buffers",
3189 .type = FIO_OPT_BOOL,
3190 .off1 = td_var_offset(scramble_buffers),
3191 .help = "Slightly scramble buffers on every IO submit",
3193 .category = FIO_OPT_C_IO,
3194 .group = FIO_OPT_G_IO_BUF,
3197 .name = "buffer_pattern",
3198 .lname = "Buffer pattern",
3199 .type = FIO_OPT_STR,
3200 .cb = str_buffer_pattern_cb,
3201 .off1 = td_var_offset(buffer_pattern),
3202 .help = "Fill pattern for IO buffers",
3203 .category = FIO_OPT_C_IO,
3204 .group = FIO_OPT_G_IO_BUF,
3207 .name = "buffer_compress_percentage",
3208 .lname = "Buffer compression percentage",
3209 .type = FIO_OPT_INT,
3210 .cb = str_buffer_compress_cb,
3211 .off1 = td_var_offset(compress_percentage),
3214 .help = "How compressible the buffer is (approximately)",
3216 .category = FIO_OPT_C_IO,
3217 .group = FIO_OPT_G_IO_BUF,
3220 .name = "buffer_compress_chunk",
3221 .lname = "Buffer compression chunk size",
3222 .type = FIO_OPT_INT,
3223 .off1 = td_var_offset(compress_chunk),
3224 .parent = "buffer_compress_percentage",
3226 .help = "Size of compressible region in buffer",
3228 .category = FIO_OPT_C_IO,
3229 .group = FIO_OPT_G_IO_BUF,
3232 .name = "dedupe_percentage",
3233 .lname = "Dedupe percentage",
3234 .type = FIO_OPT_INT,
3235 .cb = str_dedupe_cb,
3236 .off1 = td_var_offset(dedupe_percentage),
3239 .help = "Percentage of buffers that are dedupable",
3241 .category = FIO_OPT_C_IO,
3242 .group = FIO_OPT_G_IO_BUF,
3245 .name = "clat_percentiles",
3246 .lname = "Completion latency percentiles",
3247 .type = FIO_OPT_BOOL,
3248 .off1 = td_var_offset(clat_percentiles),
3249 .help = "Enable the reporting of completion latency percentiles",
3251 .category = FIO_OPT_C_STAT,
3252 .group = FIO_OPT_G_INVALID,
3255 .name = "percentile_list",
3256 .lname = "Percentile list",
3257 .type = FIO_OPT_FLOAT_LIST,
3258 .off1 = td_var_offset(percentile_list),
3259 .off2 = td_var_offset(percentile_precision),
3260 .help = "Specify a custom list of percentiles to report for "
3261 "completion latency and block errors",
3262 .def = "1:5:10:20:30:40:50:60:70:80:90:95:99:99.5:99.9:99.95:99.99",
3263 .maxlen = FIO_IO_U_LIST_MAX_LEN,
3266 .category = FIO_OPT_C_STAT,
3267 .group = FIO_OPT_G_INVALID,
3270 #ifdef FIO_HAVE_DISK_UTIL
3272 .name = "disk_util",
3273 .lname = "Disk utilization",
3274 .type = FIO_OPT_BOOL,
3275 .off1 = td_var_offset(do_disk_util),
3276 .help = "Log disk utilization statistics",
3278 .category = FIO_OPT_C_STAT,
3279 .group = FIO_OPT_G_INVALID,
3283 .name = "gtod_reduce",
3284 .lname = "Reduce gettimeofday() calls",
3285 .type = FIO_OPT_BOOL,
3286 .help = "Greatly reduce number of gettimeofday() calls",
3287 .cb = str_gtod_reduce_cb,
3290 .category = FIO_OPT_C_STAT,
3291 .group = FIO_OPT_G_INVALID,
3294 .name = "disable_lat",
3295 .lname = "Disable all latency stats",
3296 .type = FIO_OPT_BOOL,
3297 .off1 = td_var_offset(disable_lat),
3298 .help = "Disable latency numbers",
3299 .parent = "gtod_reduce",
3302 .category = FIO_OPT_C_STAT,
3303 .group = FIO_OPT_G_INVALID,
3306 .name = "disable_clat",
3307 .lname = "Disable completion latency stats",
3308 .type = FIO_OPT_BOOL,
3309 .off1 = td_var_offset(disable_clat),
3310 .help = "Disable completion latency numbers",
3311 .parent = "gtod_reduce",
3314 .category = FIO_OPT_C_STAT,
3315 .group = FIO_OPT_G_INVALID,
3318 .name = "disable_slat",
3319 .lname = "Disable submission latency stats",
3320 .type = FIO_OPT_BOOL,
3321 .off1 = td_var_offset(disable_slat),
3322 .help = "Disable submission latency numbers",
3323 .parent = "gtod_reduce",
3326 .category = FIO_OPT_C_STAT,
3327 .group = FIO_OPT_G_INVALID,
3330 .name = "disable_bw_measurement",
3331 .lname = "Disable bandwidth stats",
3332 .type = FIO_OPT_BOOL,
3333 .off1 = td_var_offset(disable_bw),
3334 .help = "Disable bandwidth logging",
3335 .parent = "gtod_reduce",
3338 .category = FIO_OPT_C_STAT,
3339 .group = FIO_OPT_G_INVALID,
3343 .lname = "Dedicated gettimeofday() CPU",
3344 .type = FIO_OPT_INT,
3345 .off1 = td_var_offset(gtod_cpu),
3346 .help = "Set up dedicated gettimeofday() thread on this CPU",
3347 .verify = gtod_cpu_verify,
3348 .category = FIO_OPT_C_GENERAL,
3349 .group = FIO_OPT_G_CLOCK,
3352 .name = "unified_rw_reporting",
3353 .type = FIO_OPT_BOOL,
3354 .off1 = td_var_offset(unified_rw_rep),
3355 .help = "Unify reporting across data direction",
3357 .category = FIO_OPT_C_GENERAL,
3358 .group = FIO_OPT_G_INVALID,
3361 .name = "continue_on_error",
3362 .lname = "Continue on error",
3363 .type = FIO_OPT_STR,
3364 .off1 = td_var_offset(continue_on_error),
3365 .help = "Continue on non-fatal errors during IO",
3367 .category = FIO_OPT_C_GENERAL,
3368 .group = FIO_OPT_G_ERR,
3371 .oval = ERROR_TYPE_NONE,
3372 .help = "Exit when an error is encountered",
3375 .oval = ERROR_TYPE_READ,
3376 .help = "Continue on read errors only",
3379 .oval = ERROR_TYPE_WRITE,
3380 .help = "Continue on write errors only",
3383 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
3384 .help = "Continue on any IO errors",
3387 .oval = ERROR_TYPE_VERIFY,
3388 .help = "Continue on verify errors only",
3391 .oval = ERROR_TYPE_ANY,
3392 .help = "Continue on all io and verify errors",
3395 .oval = ERROR_TYPE_NONE,
3396 .help = "Alias for 'none'",
3399 .oval = ERROR_TYPE_ANY,
3400 .help = "Alias for 'all'",
3405 .name = "ignore_error",
3406 .type = FIO_OPT_STR,
3407 .cb = str_ignore_error_cb,
3408 .off1 = td_var_offset(ignore_error_nr),
3409 .help = "Set a specific list of errors to ignore",
3411 .category = FIO_OPT_C_GENERAL,
3412 .group = FIO_OPT_G_ERR,
3415 .name = "error_dump",
3416 .type = FIO_OPT_BOOL,
3417 .off1 = td_var_offset(error_dump),
3419 .help = "Dump info on each error",
3420 .category = FIO_OPT_C_GENERAL,
3421 .group = FIO_OPT_G_ERR,
3426 .type = FIO_OPT_STR_STORE,
3427 .off1 = td_var_offset(profile),
3428 .help = "Select a specific builtin performance test",
3429 .category = FIO_OPT_C_PROFILE,
3430 .group = FIO_OPT_G_INVALID,
3435 .type = FIO_OPT_STR_STORE,
3436 .off1 = td_var_offset(cgroup),
3437 .help = "Add job to cgroup of this name",
3438 .category = FIO_OPT_C_GENERAL,
3439 .group = FIO_OPT_G_CGROUP,
3442 .name = "cgroup_nodelete",
3443 .lname = "Cgroup no-delete",
3444 .type = FIO_OPT_BOOL,
3445 .off1 = td_var_offset(cgroup_nodelete),
3446 .help = "Do not delete cgroups after job completion",
3449 .category = FIO_OPT_C_GENERAL,
3450 .group = FIO_OPT_G_CGROUP,
3453 .name = "cgroup_weight",
3454 .lname = "Cgroup weight",
3455 .type = FIO_OPT_INT,
3456 .off1 = td_var_offset(cgroup_weight),
3457 .help = "Use given weight for cgroup",
3461 .category = FIO_OPT_C_GENERAL,
3462 .group = FIO_OPT_G_CGROUP,
3467 .type = FIO_OPT_INT,
3468 .off1 = td_var_offset(uid),
3469 .help = "Run job with this user ID",
3470 .category = FIO_OPT_C_GENERAL,
3471 .group = FIO_OPT_G_CRED,
3475 .lname = "Group ID",
3476 .type = FIO_OPT_INT,
3477 .off1 = td_var_offset(gid),
3478 .help = "Run job with this group ID",
3479 .category = FIO_OPT_C_GENERAL,
3480 .group = FIO_OPT_G_CRED,
3485 .type = FIO_OPT_INT,
3486 .off1 = td_var_offset(kb_base),
3492 .help = "Use 1024 as the K base",
3496 .help = "Use 1000 as the K base",
3499 .help = "How many bytes per KB for reporting (1000 or 1024)",
3500 .category = FIO_OPT_C_GENERAL,
3501 .group = FIO_OPT_G_INVALID,
3504 .name = "unit_base",
3505 .lname = "Base unit for reporting (Bits or Bytes)",
3506 .type = FIO_OPT_INT,
3507 .off1 = td_var_offset(unit_base),
3512 .help = "Auto-detect",
3516 .help = "Normal (byte based)",
3520 .help = "Bit based",
3523 .help = "Bit multiple of result summary data (8 for byte, 1 for bit)",
3524 .category = FIO_OPT_C_GENERAL,
3525 .group = FIO_OPT_G_INVALID,
3528 .name = "hugepage-size",
3529 .lname = "Hugepage size",
3530 .type = FIO_OPT_INT,
3531 .off1 = td_var_offset(hugepage_size),
3532 .help = "When using hugepages, specify size of each page",
3533 .def = __fio_stringify(FIO_HUGE_PAGE),
3534 .interval = 1024 * 1024,
3535 .category = FIO_OPT_C_GENERAL,
3536 .group = FIO_OPT_G_INVALID,
3540 .lname = "I/O flow ID",
3541 .type = FIO_OPT_INT,
3542 .off1 = td_var_offset(flow_id),
3543 .help = "The flow index ID to use",
3545 .category = FIO_OPT_C_IO,
3546 .group = FIO_OPT_G_IO_FLOW,
3550 .lname = "I/O flow weight",
3551 .type = FIO_OPT_INT,
3552 .off1 = td_var_offset(flow),
3553 .help = "Weight for flow control of this job",
3554 .parent = "flow_id",
3557 .category = FIO_OPT_C_IO,
3558 .group = FIO_OPT_G_IO_FLOW,
3561 .name = "flow_watermark",
3562 .lname = "I/O flow watermark",
3563 .type = FIO_OPT_INT,
3564 .off1 = td_var_offset(flow_watermark),
3565 .help = "High watermark for flow control. This option"
3566 " should be set to the same value for all threads"
3567 " with non-zero flow.",
3568 .parent = "flow_id",
3571 .category = FIO_OPT_C_IO,
3572 .group = FIO_OPT_G_IO_FLOW,
3575 .name = "flow_sleep",
3576 .lname = "I/O flow sleep",
3577 .type = FIO_OPT_INT,
3578 .off1 = td_var_offset(flow_sleep),
3579 .help = "How many microseconds to sleep after being held"
3580 " back by the flow control mechanism",
3581 .parent = "flow_id",
3584 .category = FIO_OPT_C_IO,
3585 .group = FIO_OPT_G_IO_FLOW,
3589 .lname = "Skip operations against bad blocks",
3590 .type = FIO_OPT_BOOL,
3591 .off1 = td_var_offset(skip_bad),
3592 .help = "Skip operations against known bad blocks.",
3595 .category = FIO_OPT_C_IO,
3596 .group = FIO_OPT_G_MTD,
3603 static void add_to_lopt(struct option *lopt, struct fio_option *o,
3604 const char *name, int val)
3606 lopt->name = (char *) name;
3608 if (o->type == FIO_OPT_STR_SET)
3609 lopt->has_arg = optional_argument;
3611 lopt->has_arg = required_argument;
3614 static void options_to_lopts(struct fio_option *opts,
3615 struct option *long_options,
3616 int i, int option_type)
3618 struct fio_option *o = &opts[0];
3620 add_to_lopt(&long_options[i], o, o->name, option_type);
3623 add_to_lopt(&long_options[i], o, o->alias, option_type);
3628 assert(i < FIO_NR_OPTIONS);
3632 void fio_options_set_ioengine_opts(struct option *long_options,
3633 struct thread_data *td)
3638 while (long_options[i].name) {
3639 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
3640 memset(&long_options[i], 0, sizeof(*long_options));
3647 * Just clear out the prior ioengine options.
3652 options_to_lopts(td->io_ops->options, long_options, i,
3653 FIO_GETOPT_IOENGINE);
3656 void fio_options_dup_and_init(struct option *long_options)
3660 options_init(fio_options);
3663 while (long_options[i].name)
3666 options_to_lopts(fio_options, long_options, i, FIO_GETOPT_JOB);
3669 struct fio_keyword {
3675 static struct fio_keyword fio_keywords[] = {
3677 .word = "$pagesize",
3678 .desc = "Page size in the system",
3681 .word = "$mb_memory",
3682 .desc = "Megabytes of memory online",
3686 .desc = "Number of CPUs online in the system",
3693 void fio_keywords_exit(void)
3695 struct fio_keyword *kw;
3697 kw = &fio_keywords[0];
3705 void fio_keywords_init(void)
3707 unsigned long long mb_memory;
3711 sprintf(buf, "%lu", (unsigned long) page_size);
3712 fio_keywords[0].replace = strdup(buf);
3714 mb_memory = os_phys_mem() / (1024 * 1024);
3715 sprintf(buf, "%llu", mb_memory);
3716 fio_keywords[1].replace = strdup(buf);
3719 sprintf(buf, "%lu", l);
3720 fio_keywords[2].replace = strdup(buf);
3725 static char *bc_calc(char *str)
3727 char buf[128], *tmp;
3732 * No math, just return string
3734 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
3735 !strchr(str, '/')) || strchr(str, '\''))
3739 * Split option from value, we only need to calculate the value
3741 tmp = strchr(str, '=');
3748 * Prevent buffer overflows; such a case isn't reasonable anyway
3750 if (strlen(str) >= 128 || strlen(tmp) > 100)
3753 sprintf(buf, "which %s > /dev/null", BC_APP);
3755 log_err("fio: bc is needed for performing math\n");
3759 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
3760 f = popen(buf, "r");
3764 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
3771 buf[(tmp - str) + ret - 1] = '\0';
3772 memcpy(buf, str, tmp - str);
3778 * Return a copy of the input string with substrings of the form ${VARNAME}
3779 * substituted with the value of the environment variable VARNAME. The
3780 * substitution always occurs, even if VARNAME is empty or the corresponding
3781 * environment variable undefined.
3783 static char *option_dup_subs(const char *opt)
3785 char out[OPT_LEN_MAX+1];
3786 char in[OPT_LEN_MAX+1];
3789 char *ch1, *ch2, *env;
3790 ssize_t nchr = OPT_LEN_MAX;
3793 if (strlen(opt) + 1 > OPT_LEN_MAX) {
3794 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
3798 in[OPT_LEN_MAX] = '\0';
3799 strncpy(in, opt, OPT_LEN_MAX);
3801 while (*inptr && nchr > 0) {
3802 if (inptr[0] == '$' && inptr[1] == '{') {
3803 ch2 = strchr(inptr, '}');
3804 if (ch2 && inptr+1 < ch2) {
3811 envlen = strlen(env);
3812 if (envlen <= nchr) {
3813 memcpy(outptr, env, envlen);
3823 *outptr++ = *inptr++;
3832 * Look for reserved variable names and replace them with real values
3834 static char *fio_keyword_replace(char *opt)
3840 for (i = 0; fio_keywords[i].word != NULL; i++) {
3841 struct fio_keyword *kw = &fio_keywords[i];
3843 while ((s = strstr(opt, kw->word)) != NULL) {
3844 char *new = malloc(strlen(opt) + 1);
3850 * Copy part of the string before the keyword and
3851 * sprintf() the replacement after it.
3853 memcpy(new, opt, olen);
3854 len = sprintf(new + olen, "%s", kw->replace);
3857 * If there's more in the original string, copy that
3860 opt += strlen(kw->word) + olen;
3862 memcpy(new + olen + len, opt, opt - o_org - 1);
3865 * replace opt and free the old opt
3875 * Check for potential math and invoke bc, if possible
3883 static char **dup_and_sub_options(char **opts, int num_opts)
3886 char **opts_copy = malloc(num_opts * sizeof(*opts));
3887 for (i = 0; i < num_opts; i++) {
3888 opts_copy[i] = option_dup_subs(opts[i]);
3891 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
3896 static void show_closest_option(const char *opt)
3898 int best_option, best_distance;
3907 while (name[i] != '\0' && name[i] != '=')
3912 best_distance = INT_MAX;
3914 while (fio_options[i].name) {
3915 distance = string_distance(name, fio_options[i].name);
3916 if (distance < best_distance) {
3917 best_distance = distance;
3923 if (best_option != -1 && string_distance_ok(name, best_distance))
3924 log_err("Did you mean %s?\n", fio_options[best_option].name);
3929 int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
3931 int i, ret, unknown;
3934 sort_options(opts, fio_options, num_opts);
3935 opts_copy = dup_and_sub_options(opts, num_opts);
3937 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
3938 struct fio_option *o;
3939 int newret = parse_option(opts_copy[i], opts[i], fio_options,
3940 &o, td, &td->opt_list);
3943 fio_option_mark_set(&td->o, o);
3951 opts_copy[i] = NULL;
3958 ret |= ioengine_load(td);
3960 sort_options(opts_copy, td->io_ops->options, num_opts);
3963 for (i = 0; i < num_opts; i++) {
3964 struct fio_option *o = NULL;
3971 newret = parse_option(opts_copy[i], opts[i],
3972 td->io_ops->options, &o,
3973 td->eo, &td->opt_list);
3977 log_err("Bad option <%s>\n", opts[i]);
3978 show_closest_option(opts[i]);
3981 opts_copy[i] = NULL;
3989 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
3993 ret = parse_cmd_option(opt, val, fio_options, td, &td->opt_list);
3995 struct fio_option *o;
3997 o = find_option(fio_options, opt);
3999 fio_option_mark_set(&td->o, o);
4005 int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
4008 return parse_cmd_option(opt, val, td->io_ops->options, td->eo,
4012 void fio_fill_default_options(struct thread_data *td)
4014 td->o.magic = OPT_MAGIC;
4015 fill_default_options(td, fio_options);
4018 int fio_show_option_help(const char *opt)
4020 return show_cmd_help(fio_options, opt);
4023 void options_mem_dupe(void *data, struct fio_option *options)
4025 struct fio_option *o;
4028 for (o = &options[0]; o->name; o++) {
4029 if (o->type != FIO_OPT_STR_STORE)
4032 ptr = td_var(data, o, o->off1);
4034 *ptr = strdup(*ptr);
4039 * dupe FIO_OPT_STR_STORE options
4041 void fio_options_mem_dupe(struct thread_data *td)
4043 options_mem_dupe(&td->o, fio_options);
4045 if (td->eo && td->io_ops) {
4046 void *oldeo = td->eo;
4048 td->eo = malloc(td->io_ops->option_struct_size);
4049 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
4050 options_mem_dupe(td->eo, td->io_ops->options);
4054 unsigned int fio_get_kb_base(void *data)
4056 struct thread_options *o = data;
4057 unsigned int kb_base = 0;
4060 * This is a hack... For private options, *data is not holding
4061 * a pointer to the thread_options, but to private data. This means
4062 * we can't safely dereference it, but magic is first so mem wise
4063 * it is valid. But this also means that if the job first sets
4064 * kb_base and expects that to be honored by private options,
4065 * it will be disappointed. We will return the global default
4068 if (o && o->magic == OPT_MAGIC)
4069 kb_base = o->kb_base;
4076 int add_option(struct fio_option *o)
4078 struct fio_option *__o;
4087 if (opt_index + 1 == FIO_MAX_OPTS) {
4088 log_err("fio: FIO_MAX_OPTS is too small\n");
4092 memcpy(&fio_options[opt_index], o, sizeof(*o));
4093 fio_options[opt_index + 1].name = NULL;
4097 void invalidate_profile_options(const char *prof_name)
4099 struct fio_option *o;
4103 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
4104 o->type = FIO_OPT_INVALID;
4105 o->prof_name = NULL;
4111 void add_opt_posval(const char *optname, const char *ival, const char *help)
4113 struct fio_option *o;
4116 o = find_option(fio_options, optname);
4120 for (i = 0; i < PARSE_MAX_VP; i++) {
4121 if (o->posval[i].ival)
4124 o->posval[i].ival = ival;
4125 o->posval[i].help = help;
4130 void del_opt_posval(const char *optname, const char *ival)
4132 struct fio_option *o;
4135 o = find_option(fio_options, optname);
4139 for (i = 0; i < PARSE_MAX_VP; i++) {
4140 if (!o->posval[i].ival)
4142 if (strcmp(o->posval[i].ival, ival))
4145 o->posval[i].ival = NULL;
4146 o->posval[i].help = NULL;
4150 void fio_options_free(struct thread_data *td)
4152 options_free(fio_options, td);
4153 if (td->eo && td->io_ops && td->io_ops->options) {
4154 options_free(td->io_ops->options, td->eo);
4160 struct fio_option *fio_option_find(const char *name)
4162 return find_option(fio_options, name);
4165 static struct fio_option *find_next_opt(struct thread_options *o,
4166 struct fio_option *from,
4169 struct fio_option *opt;
4172 from = &fio_options[0];
4178 if (off1 == from->off1) {
4183 } while (from->name);
4188 static int opt_is_set(struct thread_options *o, struct fio_option *opt)
4190 unsigned int opt_off, index, offset;
4192 opt_off = opt - &fio_options[0];
4193 index = opt_off / (8 * sizeof(uint64_t));
4194 offset = opt_off & ((8 * sizeof(uint64_t)) - 1);
4195 return (o->set_options[index] & ((uint64_t)1 << offset)) != 0;
4198 bool __fio_option_is_set(struct thread_options *o, unsigned int off1)
4200 struct fio_option *opt, *next;
4203 while ((opt = find_next_opt(o, next, off1)) != NULL) {
4204 if (opt_is_set(o, opt))
4213 void fio_option_mark_set(struct thread_options *o, struct fio_option *opt)
4215 unsigned int opt_off, index, offset;
4217 opt_off = opt - &fio_options[0];
4218 index = opt_off / (8 * sizeof(uint64_t));
4219 offset = opt_off & ((8 * sizeof(uint64_t)) - 1);
4220 o->set_options[index] |= (uint64_t)1 << offset;