11 #include <netinet/in.h>
17 #include "lib/pattern.h"
21 char client_sockaddr_str[INET6_ADDRSTRLEN] = { 0 };
24 * Check if mmap/mmaphuge has a :/foo/bar/file at the end. If so, return that.
26 static char *get_opt_postfix(const char *str)
28 char *p = strstr(str, ":");
34 strip_blank_front(&p);
39 static int bs_cmp(const void *p1, const void *p2)
41 const struct bssplit *bsp1 = p1;
42 const struct bssplit *bsp2 = p2;
44 return (int) bsp1->perc - (int) bsp2->perc;
47 static int bssplit_ddir(struct thread_options *o, int ddir, char *str)
49 struct bssplit *bssplit;
50 unsigned int i, perc, perc_missing;
51 unsigned int max_bs, min_bs;
55 o->bssplit_nr[ddir] = 4;
56 bssplit = malloc(4 * sizeof(struct bssplit));
61 while ((fname = strsep(&str, ":")) != NULL) {
68 * grow struct buffer, if needed
70 if (i == o->bssplit_nr[ddir]) {
71 o->bssplit_nr[ddir] <<= 1;
72 bssplit = realloc(bssplit, o->bssplit_nr[ddir]
73 * sizeof(struct bssplit));
76 perc_str = strstr(fname, "/");
80 perc = atoi(perc_str);
88 if (str_to_decimal(fname, &val, 1, o, 0, 0)) {
89 log_err("fio: bssplit conversion failed\n");
100 bssplit[i].perc = perc;
104 o->bssplit_nr[ddir] = i;
107 * Now check if the percentages add up, and how much is missing
109 perc = perc_missing = 0;
110 for (i = 0; i < o->bssplit_nr[ddir]; i++) {
111 struct bssplit *bsp = &bssplit[i];
113 if (bsp->perc == -1U)
119 if (perc > 100 && perc_missing > 1) {
120 log_err("fio: bssplit percentages add to more than 100%%\n");
126 * If values didn't have a percentage set, divide the remains between
130 if (perc_missing == 1 && o->bssplit_nr[ddir] == 1)
132 for (i = 0; i < o->bssplit_nr[ddir]; i++) {
133 struct bssplit *bsp = &bssplit[i];
135 if (bsp->perc == -1U)
136 bsp->perc = (100 - perc) / perc_missing;
140 o->min_bs[ddir] = min_bs;
141 o->max_bs[ddir] = max_bs;
144 * now sort based on percentages, for ease of lookup
146 qsort(bssplit, o->bssplit_nr[ddir], sizeof(struct bssplit), bs_cmp);
147 o->bssplit[ddir] = bssplit;
151 static int str_bssplit_cb(void *data, const char *input)
153 struct thread_data *td = data;
154 char *str, *p, *odir, *ddir;
160 p = str = strdup(input);
162 strip_blank_front(&str);
163 strip_blank_end(str);
165 odir = strchr(str, ',');
167 ddir = strchr(odir + 1, ',');
169 ret = bssplit_ddir(&td->o, DDIR_TRIM, ddir + 1);
175 op = strdup(odir + 1);
176 ret = bssplit_ddir(&td->o, DDIR_TRIM, op);
181 ret = bssplit_ddir(&td->o, DDIR_WRITE, odir + 1);
184 ret = bssplit_ddir(&td->o, DDIR_READ, str);
190 ret = bssplit_ddir(&td->o, DDIR_WRITE, op);
195 ret = bssplit_ddir(&td->o, DDIR_TRIM, op);
199 ret = bssplit_ddir(&td->o, DDIR_READ, str);
206 static int str2error(char *str)
208 const char *err[] = { "EPERM", "ENOENT", "ESRCH", "EINTR", "EIO",
209 "ENXIO", "E2BIG", "ENOEXEC", "EBADF",
210 "ECHILD", "EAGAIN", "ENOMEM", "EACCES",
211 "EFAULT", "ENOTBLK", "EBUSY", "EEXIST",
212 "EXDEV", "ENODEV", "ENOTDIR", "EISDIR",
213 "EINVAL", "ENFILE", "EMFILE", "ENOTTY",
214 "ETXTBSY","EFBIG", "ENOSPC", "ESPIPE",
215 "EROFS","EMLINK", "EPIPE", "EDOM", "ERANGE" };
216 int i = 0, num = sizeof(err) / sizeof(void *);
219 if (!strcmp(err[i], str))
226 static int ignore_error_type(struct thread_data *td, int etype, char *str)
232 if (etype >= ERROR_TYPE_CNT) {
233 log_err("Illegal error type\n");
237 td->o.ignore_error_nr[etype] = 4;
238 error = malloc(4 * sizeof(struct bssplit));
241 while ((fname = strsep(&str, ":")) != NULL) {
247 * grow struct buffer, if needed
249 if (i == td->o.ignore_error_nr[etype]) {
250 td->o.ignore_error_nr[etype] <<= 1;
251 error = realloc(error, td->o.ignore_error_nr[etype]
254 if (fname[0] == 'E') {
255 error[i] = str2error(fname);
257 error[i] = atoi(fname);
259 error[i] = -error[i];
262 log_err("Unknown error %s, please use number value \n",
270 td->o.continue_on_error |= 1 << etype;
271 td->o.ignore_error_nr[etype] = i;
272 td->o.ignore_error[etype] = error;
280 static int str_ignore_error_cb(void *data, const char *input)
282 struct thread_data *td = data;
284 int type = 0, ret = 1;
289 p = str = strdup(input);
291 strip_blank_front(&str);
292 strip_blank_end(str);
298 ret = ignore_error_type(td, type, p);
308 static int str_rw_cb(void *data, const char *str)
310 struct thread_data *td = data;
311 struct thread_options *o = &td->o;
320 nr = get_opt_postfix(str);
325 o->ddir_seq_nr = atoi(nr);
329 if (str_to_decimal(nr, &val, 1, o, 0, 0)) {
330 log_err("fio: rw postfix parsing failed\n");
335 o->ddir_seq_add = val;
342 static int str_mem_cb(void *data, const char *mem)
344 struct thread_data *td = data;
346 if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP ||
347 td->o.mem_type == MEM_MMAPSHARED)
348 td->o.mmapfile = get_opt_postfix(mem);
353 static int fio_clock_source_cb(void *data, const char *str)
355 struct thread_data *td = data;
357 fio_clock_source = td->o.clocksource;
358 fio_clock_source_set = 1;
363 static int str_rwmix_read_cb(void *data, unsigned long long *val)
365 struct thread_data *td = data;
367 td->o.rwmix[DDIR_READ] = *val;
368 td->o.rwmix[DDIR_WRITE] = 100 - *val;
372 static int str_rwmix_write_cb(void *data, unsigned long long *val)
374 struct thread_data *td = data;
376 td->o.rwmix[DDIR_WRITE] = *val;
377 td->o.rwmix[DDIR_READ] = 100 - *val;
381 static int str_exitall_cb(void)
383 exitall_on_terminate = 1;
387 #ifdef FIO_HAVE_CPU_AFFINITY
388 int fio_cpus_split(os_cpu_mask_t *mask, unsigned int cpu_index)
390 unsigned int i, index, cpus_in_mask;
391 const long max_cpu = cpus_online();
393 cpus_in_mask = fio_cpu_count(mask);
394 cpu_index = cpu_index % cpus_in_mask;
397 for (i = 0; i < max_cpu; i++) {
398 if (!fio_cpu_isset(mask, i))
401 if (cpu_index != index)
402 fio_cpu_clear(mask, i);
407 return fio_cpu_count(mask);
410 static int str_cpumask_cb(void *data, unsigned long long *val)
412 struct thread_data *td = data;
420 ret = fio_cpuset_init(&td->o.cpumask);
422 log_err("fio: cpuset_init failed\n");
423 td_verror(td, ret, "fio_cpuset_init");
427 max_cpu = cpus_online();
429 for (i = 0; i < sizeof(int) * 8; i++) {
430 if ((1 << i) & *val) {
432 log_err("fio: CPU %d too large (max=%ld)\n", i,
436 dprint(FD_PARSE, "set cpu allowed %d\n", i);
437 fio_cpu_set(&td->o.cpumask, i);
444 static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask,
451 ret = fio_cpuset_init(mask);
453 log_err("fio: cpuset_init failed\n");
454 td_verror(td, ret, "fio_cpuset_init");
458 p = str = strdup(input);
460 strip_blank_front(&str);
461 strip_blank_end(str);
463 max_cpu = cpus_online();
465 while ((cpu = strsep(&str, ",")) != NULL) {
474 while ((cpu2 = strsep(&str2, "-")) != NULL) {
484 while (icpu <= icpu2) {
485 if (icpu >= FIO_MAX_CPUS) {
486 log_err("fio: your OS only supports up to"
487 " %d CPUs\n", (int) FIO_MAX_CPUS);
491 if (icpu >= max_cpu) {
492 log_err("fio: CPU %d too large (max=%ld)\n",
498 dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
499 fio_cpu_set(mask, icpu);
510 static int str_cpus_allowed_cb(void *data, const char *input)
512 struct thread_data *td = data;
517 return set_cpus_allowed(td, &td->o.cpumask, input);
520 static int str_verify_cpus_allowed_cb(void *data, const char *input)
522 struct thread_data *td = data;
527 return set_cpus_allowed(td, &td->o.verify_cpumask, input);
531 static int str_log_cpus_allowed_cb(void *data, const char *input)
533 struct thread_data *td = data;
538 return set_cpus_allowed(td, &td->o.log_gz_cpumask, input);
540 #endif /* CONFIG_ZLIB */
542 #endif /* FIO_HAVE_CPU_AFFINITY */
544 #ifdef CONFIG_LIBNUMA
545 static int str_numa_cpunodes_cb(void *data, char *input)
547 struct thread_data *td = data;
548 struct bitmask *verify_bitmask;
553 /* numa_parse_nodestring() parses a character string list
554 * of nodes into a bit mask. The bit mask is allocated by
555 * numa_allocate_nodemask(), so it should be freed by
556 * numa_free_nodemask().
558 verify_bitmask = numa_parse_nodestring(input);
559 if (verify_bitmask == NULL) {
560 log_err("fio: numa_parse_nodestring failed\n");
561 td_verror(td, 1, "str_numa_cpunodes_cb");
564 numa_free_nodemask(verify_bitmask);
566 td->o.numa_cpunodes = strdup(input);
570 static int str_numa_mpol_cb(void *data, char *input)
572 struct thread_data *td = data;
573 const char * const policy_types[] =
574 { "default", "prefer", "bind", "interleave", "local", NULL };
577 struct bitmask *verify_bitmask;
582 nodelist = strchr(input, ':');
584 /* NUL-terminate mode */
588 for (i = 0; i <= MPOL_LOCAL; i++) {
589 if (!strcmp(input, policy_types[i])) {
590 td->o.numa_mem_mode = i;
594 if (i > MPOL_LOCAL) {
595 log_err("fio: memory policy should be: default, prefer, bind, interleave, local\n");
599 switch (td->o.numa_mem_mode) {
602 * Insist on a nodelist of one node only
605 char *rest = nodelist;
606 while (isdigit(*rest))
609 log_err("fio: one node only for \'prefer\'\n");
613 log_err("fio: one node is needed for \'prefer\'\n");
617 case MPOL_INTERLEAVE:
619 * Default to online nodes with memory if no nodelist
622 nodelist = strdup("all");
627 * Don't allow a nodelist
630 log_err("fio: NO nodelist for \'local\'\n");
636 * Insist on a nodelist
639 log_err("fio: a nodelist is needed for \'bind\'\n");
646 /* numa_parse_nodestring() parses a character string list
647 * of nodes into a bit mask. The bit mask is allocated by
648 * numa_allocate_nodemask(), so it should be freed by
649 * numa_free_nodemask().
651 switch (td->o.numa_mem_mode) {
653 td->o.numa_mem_prefer_node = atoi(nodelist);
655 case MPOL_INTERLEAVE:
657 verify_bitmask = numa_parse_nodestring(nodelist);
658 if (verify_bitmask == NULL) {
659 log_err("fio: numa_parse_nodestring failed\n");
660 td_verror(td, 1, "str_numa_memnodes_cb");
663 td->o.numa_memnodes = strdup(nodelist);
664 numa_free_nodemask(verify_bitmask);
679 static int str_fst_cb(void *data, const char *str)
681 struct thread_data *td = data;
682 char *nr = get_opt_postfix(str);
684 td->file_service_nr = 1;
686 td->file_service_nr = atoi(nr);
693 #ifdef CONFIG_SYNC_FILE_RANGE
694 static int str_sfr_cb(void *data, const char *str)
696 struct thread_data *td = data;
697 char *nr = get_opt_postfix(str);
699 td->sync_file_range_nr = 1;
701 td->sync_file_range_nr = atoi(nr);
709 static int str_random_distribution_cb(void *data, const char *str)
711 struct thread_data *td = data;
718 if (td->o.random_distribution == FIO_RAND_DIST_ZIPF)
720 else if (td->o.random_distribution == FIO_RAND_DIST_PARETO)
721 val = FIO_DEF_PARETO;
722 else if (td->o.random_distribution == FIO_RAND_DIST_GAUSS)
727 nr = get_opt_postfix(str);
728 if (nr && !str_to_float(nr, &val, 0)) {
729 log_err("fio: random postfix parsing failed\n");
736 if (td->o.random_distribution == FIO_RAND_DIST_ZIPF) {
738 log_err("fio: zipf theta must different than 1.0\n");
741 td->o.zipf_theta.u.f = val;
742 } else if (td->o.random_distribution == FIO_RAND_DIST_PARETO) {
743 if (val <= 0.00 || val >= 1.00) {
744 log_err("fio: pareto input out of range (0 < input < 1.0)\n");
747 td->o.pareto_h.u.f = val;
749 if (val <= 0.00 || val >= 100.0) {
750 log_err("fio: normal deviation out of range (0 < input < 100.0)\n");
753 td->o.gauss_dev.u.f = val;
760 * Return next name in the string. Files are separated with ':'. If the ':'
761 * is escaped with a '\', then that ':' is part of the filename and does not
762 * indicate a new file.
764 static char *get_next_name(char **ptr)
769 if (!str || !strlen(str))
775 * No colon, we are done
777 p = strchr(str, ':');
784 * We got a colon, but it's the first character. Skip and
792 if (*(p - 1) != '\\') {
798 memmove(p - 1, p, strlen(p) + 1);
806 static int get_max_name_idx(char *input)
808 unsigned int cur_idx;
811 p = str = strdup(input);
812 for (cur_idx = 0; ; cur_idx++)
813 if (get_next_name(&str) == NULL)
821 * Returns the directory at the index, indexes > entires will be
822 * assigned via modulo division of the index
824 int set_name_idx(char *target, size_t tlen, char *input, int index)
826 unsigned int cur_idx;
828 char *fname, *str, *p;
830 p = str = strdup(input);
832 index %= get_max_name_idx(input);
833 for (cur_idx = 0; cur_idx <= index; cur_idx++)
834 fname = get_next_name(&str);
836 if (client_sockaddr_str[0]) {
837 len = snprintf(target, tlen, "%s/%s.", fname,
838 client_sockaddr_str);
840 len = snprintf(target, tlen, "%s/", fname);
842 target[tlen - 1] = '\0';
848 static int str_filename_cb(void *data, const char *input)
850 struct thread_data *td = data;
851 char *fname, *str, *p;
853 p = str = strdup(input);
855 strip_blank_front(&str);
856 strip_blank_end(str);
858 if (!td->files_index)
861 while ((fname = get_next_name(&str)) != NULL) {
864 add_file(td, fname, 0, 1);
871 static int str_directory_cb(void *data, const char fio_unused *unused)
873 struct thread_data *td = data;
875 char *dirname, *str, *p;
881 p = str = strdup(td->o.directory);
882 while ((dirname = get_next_name(&str)) != NULL) {
883 if (lstat(dirname, &sb) < 0) {
886 log_err("fio: %s is not a directory\n", dirname);
887 td_verror(td, ret, "lstat");
890 if (!S_ISDIR(sb.st_mode)) {
891 log_err("fio: %s is not a directory\n", dirname);
902 static int str_opendir_cb(void *data, const char fio_unused *str)
904 struct thread_data *td = data;
909 if (!td->files_index)
912 return add_dir_files(td, td->o.opendir);
915 static int str_buffer_pattern_cb(void *data, const char *input)
917 struct thread_data *td = data;
920 /* FIXME: for now buffer pattern does not support formats */
921 ret = parse_and_fill_pattern(input, strlen(input), td->o.buffer_pattern,
922 MAX_PATTERN_SIZE, NULL, 0, NULL, NULL);
927 td->o.buffer_pattern_bytes = ret;
928 if (!td->o.compress_percentage)
929 td->o.refill_buffers = 0;
930 td->o.scramble_buffers = 0;
931 td->o.zero_buffers = 0;
936 static int str_buffer_compress_cb(void *data, unsigned long long *il)
938 struct thread_data *td = data;
940 td->flags |= TD_F_COMPRESS;
941 td->o.compress_percentage = *il;
945 static int str_dedupe_cb(void *data, unsigned long long *il)
947 struct thread_data *td = data;
949 td->flags |= TD_F_COMPRESS;
950 td->o.dedupe_percentage = *il;
951 td->o.refill_buffers = 1;
955 static int str_verify_pattern_cb(void *data, const char *input)
957 struct pattern_fmt_desc fmt_desc[] = {
960 .len = FIELD_SIZE(struct io_u *, offset),
961 .paste = paste_blockoff
964 struct thread_data *td = data;
967 td->o.verify_fmt_sz = ARRAY_SIZE(td->o.verify_fmt);
968 ret = parse_and_fill_pattern(input, strlen(input), td->o.verify_pattern,
969 MAX_PATTERN_SIZE, fmt_desc, sizeof(fmt_desc),
970 td->o.verify_fmt, &td->o.verify_fmt_sz);
975 td->o.verify_pattern_bytes = ret;
977 * VERIFY_* could already be set
979 if (!fio_option_is_set(&td->o, verify))
980 td->o.verify = VERIFY_PATTERN;
985 static int str_gtod_reduce_cb(void *data, int *il)
987 struct thread_data *td = data;
990 td->o.disable_lat = !!val;
991 td->o.disable_clat = !!val;
992 td->o.disable_slat = !!val;
993 td->o.disable_bw = !!val;
994 td->o.clat_percentiles = !val;
996 td->tv_cache_mask = 63;
1001 static int str_size_cb(void *data, unsigned long long *__val)
1003 struct thread_data *td = data;
1004 unsigned long long v = *__val;
1006 if (parse_is_percent(v)) {
1008 td->o.size_percent = -1ULL - v;
1015 static int rw_verify(struct fio_option *o, void *data)
1017 struct thread_data *td = data;
1019 if (read_only && td_write(td)) {
1020 log_err("fio: job <%s> has write bit set, but fio is in"
1021 " read-only mode\n", td->o.name);
1028 static int gtod_cpu_verify(struct fio_option *o, void *data)
1030 #ifndef FIO_HAVE_CPU_AFFINITY
1031 struct thread_data *td = data;
1033 if (td->o.gtod_cpu) {
1034 log_err("fio: platform must support CPU affinity for"
1035 "gettimeofday() offloading\n");
1044 * Map of job/command line options
1046 struct fio_option fio_options[FIO_MAX_OPTS] = {
1048 .name = "description",
1049 .lname = "Description of job",
1050 .type = FIO_OPT_STR_STORE,
1051 .off1 = td_var_offset(description),
1052 .help = "Text job description",
1053 .category = FIO_OPT_C_GENERAL,
1054 .group = FIO_OPT_G_DESC,
1058 .lname = "Job name",
1059 .type = FIO_OPT_STR_STORE,
1060 .off1 = td_var_offset(name),
1061 .help = "Name of this job",
1062 .category = FIO_OPT_C_GENERAL,
1063 .group = FIO_OPT_G_DESC,
1067 .lname = "Waitee name",
1068 .type = FIO_OPT_STR_STORE,
1069 .off1 = td_var_offset(wait_for),
1070 .help = "Name of the job this one wants to wait for before starting",
1071 .category = FIO_OPT_C_GENERAL,
1072 .group = FIO_OPT_G_DESC,
1076 .lname = "Filename(s)",
1077 .type = FIO_OPT_STR_STORE,
1078 .off1 = td_var_offset(filename),
1079 .cb = str_filename_cb,
1080 .prio = -1, /* must come after "directory" */
1081 .help = "File(s) to use for the workload",
1082 .category = FIO_OPT_C_FILE,
1083 .group = FIO_OPT_G_FILENAME,
1086 .name = "directory",
1087 .lname = "Directory",
1088 .type = FIO_OPT_STR_STORE,
1089 .off1 = td_var_offset(directory),
1090 .cb = str_directory_cb,
1091 .help = "Directory to store files in",
1092 .category = FIO_OPT_C_FILE,
1093 .group = FIO_OPT_G_FILENAME,
1096 .name = "filename_format",
1097 .type = FIO_OPT_STR_STORE,
1098 .off1 = td_var_offset(filename_format),
1099 .prio = -1, /* must come after "directory" */
1100 .help = "Override default $jobname.$jobnum.$filenum naming",
1101 .def = "$jobname.$jobnum.$filenum",
1102 .category = FIO_OPT_C_FILE,
1103 .group = FIO_OPT_G_FILENAME,
1107 .lname = "Lockfile",
1108 .type = FIO_OPT_STR,
1109 .off1 = td_var_offset(file_lock_mode),
1110 .help = "Lock file when doing IO to it",
1112 .parent = "filename",
1115 .category = FIO_OPT_C_FILE,
1116 .group = FIO_OPT_G_FILENAME,
1119 .oval = FILE_LOCK_NONE,
1120 .help = "No file locking",
1122 { .ival = "exclusive",
1123 .oval = FILE_LOCK_EXCLUSIVE,
1124 .help = "Exclusive file lock",
1127 .ival = "readwrite",
1128 .oval = FILE_LOCK_READWRITE,
1129 .help = "Read vs write lock",
1135 .lname = "Open directory",
1136 .type = FIO_OPT_STR_STORE,
1137 .off1 = td_var_offset(opendir),
1138 .cb = str_opendir_cb,
1139 .help = "Recursively add files from this directory and down",
1140 .category = FIO_OPT_C_FILE,
1141 .group = FIO_OPT_G_FILENAME,
1145 .lname = "Read/write",
1146 .alias = "readwrite",
1147 .type = FIO_OPT_STR,
1149 .off1 = td_var_offset(td_ddir),
1150 .help = "IO direction",
1152 .verify = rw_verify,
1153 .category = FIO_OPT_C_IO,
1154 .group = FIO_OPT_G_IO_BASIC,
1157 .oval = TD_DDIR_READ,
1158 .help = "Sequential read",
1161 .oval = TD_DDIR_WRITE,
1162 .help = "Sequential write",
1165 .oval = TD_DDIR_TRIM,
1166 .help = "Sequential trim",
1168 { .ival = "randread",
1169 .oval = TD_DDIR_RANDREAD,
1170 .help = "Random read",
1172 { .ival = "randwrite",
1173 .oval = TD_DDIR_RANDWRITE,
1174 .help = "Random write",
1176 { .ival = "randtrim",
1177 .oval = TD_DDIR_RANDTRIM,
1178 .help = "Random trim",
1182 .help = "Sequential read and write mix",
1184 { .ival = "readwrite",
1186 .help = "Sequential read and write mix",
1189 .oval = TD_DDIR_RANDRW,
1190 .help = "Random read and write mix"
1192 { .ival = "trimwrite",
1193 .oval = TD_DDIR_TRIMWRITE,
1194 .help = "Trim and write mix, trims preceding writes"
1199 .name = "rw_sequencer",
1200 .lname = "RW Sequencer",
1201 .type = FIO_OPT_STR,
1202 .off1 = td_var_offset(rw_seq),
1203 .help = "IO offset generator modifier",
1204 .def = "sequential",
1205 .category = FIO_OPT_C_IO,
1206 .group = FIO_OPT_G_IO_BASIC,
1208 { .ival = "sequential",
1210 .help = "Generate sequential offsets",
1212 { .ival = "identical",
1213 .oval = RW_SEQ_IDENT,
1214 .help = "Generate identical offsets",
1221 .lname = "IO Engine",
1222 .type = FIO_OPT_STR_STORE,
1223 .off1 = td_var_offset(ioengine),
1224 .help = "IO engine to use",
1225 .def = FIO_PREFERRED_ENGINE,
1226 .category = FIO_OPT_C_IO,
1227 .group = FIO_OPT_G_IO_BASIC,
1230 .help = "Use read/write",
1233 .help = "Use pread/pwrite",
1236 .help = "Use readv/writev",
1238 #ifdef CONFIG_PWRITEV
1240 .help = "Use preadv/pwritev",
1243 #ifdef CONFIG_LIBAIO
1245 .help = "Linux native asynchronous IO",
1248 #ifdef CONFIG_POSIXAIO
1249 { .ival = "posixaio",
1250 .help = "POSIX asynchronous IO",
1253 #ifdef CONFIG_SOLARISAIO
1254 { .ival = "solarisaio",
1255 .help = "Solaris native asynchronous IO",
1258 #ifdef CONFIG_WINDOWSAIO
1259 { .ival = "windowsaio",
1260 .help = "Windows native asynchronous IO"
1265 .help = "Rados Block Device asynchronous IO"
1269 .help = "Memory mapped IO"
1271 #ifdef CONFIG_LINUX_SPLICE
1273 .help = "splice/vmsplice based IO",
1275 { .ival = "netsplice",
1276 .help = "splice/vmsplice to/from the network",
1279 #ifdef FIO_HAVE_SGIO
1281 .help = "SCSI generic v3 IO",
1285 .help = "Testing engine (no data transfer)",
1288 .help = "Network IO",
1291 .help = "CPU cycle burner engine",
1295 .help = "GUASI IO engine",
1298 #ifdef FIO_HAVE_BINJECT
1299 { .ival = "binject",
1300 .help = "binject direct inject block engine",
1305 .help = "RDMA IO engine",
1308 #ifdef CONFIG_FUSION_AW
1309 { .ival = "fusion-aw-sync",
1310 .help = "Fusion-io atomic write engine",
1313 #ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
1314 { .ival = "e4defrag",
1315 .help = "ext4 defrag engine",
1318 #ifdef CONFIG_LINUX_FALLOCATE
1320 .help = "fallocate() file based engine",
1325 .help = "Glusterfs libgfapi(sync) based engine"
1327 { .ival = "gfapi_async",
1328 .help = "Glusterfs libgfapi(async) based engine"
1331 #ifdef CONFIG_LIBHDFS
1332 { .ival = "libhdfs",
1333 .help = "Hadoop Distributed Filesystem (HDFS) engine"
1336 { .ival = "external",
1337 .help = "Load external engine (append name)",
1343 .lname = "IO Depth",
1344 .type = FIO_OPT_INT,
1345 .off1 = td_var_offset(iodepth),
1346 .help = "Number of IO buffers to keep in flight",
1350 .category = FIO_OPT_C_IO,
1351 .group = FIO_OPT_G_IO_BASIC,
1354 .name = "iodepth_batch",
1355 .lname = "IO Depth batch",
1356 .alias = "iodepth_batch_submit",
1357 .type = FIO_OPT_INT,
1358 .off1 = td_var_offset(iodepth_batch),
1359 .help = "Number of IO buffers to submit in one go",
1360 .parent = "iodepth",
1365 .category = FIO_OPT_C_IO,
1366 .group = FIO_OPT_G_IO_BASIC,
1369 .name = "iodepth_batch_complete_min",
1370 .lname = "Min IO depth batch complete",
1371 .alias = "iodepth_batch_complete",
1372 .type = FIO_OPT_INT,
1373 .off1 = td_var_offset(iodepth_batch_complete_min),
1374 .help = "Min number of IO buffers to retrieve in one go",
1375 .parent = "iodepth",
1380 .category = FIO_OPT_C_IO,
1381 .group = FIO_OPT_G_IO_BASIC,
1384 .name = "iodepth_batch_complete_max",
1385 .lname = "Max IO depth batch complete",
1386 .type = FIO_OPT_INT,
1387 .off1 = td_var_offset(iodepth_batch_complete_max),
1388 .help = "Max number of IO buffers to retrieve in one go",
1389 .parent = "iodepth",
1393 .category = FIO_OPT_C_IO,
1394 .group = FIO_OPT_G_IO_BASIC,
1397 .name = "iodepth_low",
1398 .lname = "IO Depth batch low",
1399 .type = FIO_OPT_INT,
1400 .off1 = td_var_offset(iodepth_low),
1401 .help = "Low water mark for queuing depth",
1402 .parent = "iodepth",
1405 .category = FIO_OPT_C_IO,
1406 .group = FIO_OPT_G_IO_BASIC,
1409 .name = "io_submit_mode",
1410 .lname = "IO submit mode",
1411 .type = FIO_OPT_STR,
1412 .off1 = td_var_offset(io_submit_mode),
1413 .help = "How IO submissions and completions are done",
1415 .category = FIO_OPT_C_IO,
1416 .group = FIO_OPT_G_IO_BASIC,
1419 .oval = IO_MODE_INLINE,
1420 .help = "Submit and complete IO inline",
1422 { .ival = "offload",
1423 .oval = IO_MODE_OFFLOAD,
1424 .help = "Offload submit and complete to threads",
1431 .type = FIO_OPT_STR_VAL,
1433 .off1 = td_var_offset(size),
1434 .help = "Total size of device or files",
1435 .interval = 1024 * 1024,
1436 .category = FIO_OPT_C_IO,
1437 .group = FIO_OPT_G_INVALID,
1441 .alias = "io_limit",
1443 .type = FIO_OPT_STR_VAL,
1444 .off1 = td_var_offset(io_limit),
1445 .interval = 1024 * 1024,
1446 .category = FIO_OPT_C_IO,
1447 .group = FIO_OPT_G_INVALID,
1450 .name = "fill_device",
1451 .lname = "Fill device",
1453 .type = FIO_OPT_BOOL,
1454 .off1 = td_var_offset(fill_device),
1455 .help = "Write until an ENOSPC error occurs",
1457 .category = FIO_OPT_C_FILE,
1458 .group = FIO_OPT_G_INVALID,
1462 .lname = "File size",
1463 .type = FIO_OPT_STR_VAL,
1464 .off1 = td_var_offset(file_size_low),
1465 .off2 = td_var_offset(file_size_high),
1467 .help = "Size of individual files",
1468 .interval = 1024 * 1024,
1469 .category = FIO_OPT_C_FILE,
1470 .group = FIO_OPT_G_INVALID,
1473 .name = "file_append",
1474 .lname = "File append",
1475 .type = FIO_OPT_BOOL,
1476 .off1 = td_var_offset(file_append),
1477 .help = "IO will start at the end of the file(s)",
1479 .category = FIO_OPT_C_FILE,
1480 .group = FIO_OPT_G_INVALID,
1484 .lname = "IO offset",
1485 .alias = "fileoffset",
1486 .type = FIO_OPT_STR_VAL,
1487 .off1 = td_var_offset(start_offset),
1488 .help = "Start IO from this offset",
1490 .interval = 1024 * 1024,
1491 .category = FIO_OPT_C_IO,
1492 .group = FIO_OPT_G_INVALID,
1495 .name = "offset_increment",
1496 .lname = "IO offset increment",
1497 .type = FIO_OPT_STR_VAL,
1498 .off1 = td_var_offset(offset_increment),
1499 .help = "What is the increment from one offset to the next",
1503 .interval = 1024 * 1024,
1504 .category = FIO_OPT_C_IO,
1505 .group = FIO_OPT_G_INVALID,
1508 .name = "number_ios",
1509 .lname = "Number of IOs to perform",
1510 .type = FIO_OPT_STR_VAL,
1511 .off1 = td_var_offset(number_ios),
1512 .help = "Force job completion after this number of IOs",
1514 .category = FIO_OPT_C_IO,
1515 .group = FIO_OPT_G_INVALID,
1519 .lname = "Block size",
1520 .alias = "blocksize",
1521 .type = FIO_OPT_INT,
1522 .off1 = td_var_offset(bs[DDIR_READ]),
1523 .off2 = td_var_offset(bs[DDIR_WRITE]),
1524 .off3 = td_var_offset(bs[DDIR_TRIM]),
1526 .help = "Block size unit",
1531 .category = FIO_OPT_C_IO,
1532 .group = FIO_OPT_G_INVALID,
1536 .lname = "Block size align",
1537 .alias = "blockalign",
1538 .type = FIO_OPT_INT,
1539 .off1 = td_var_offset(ba[DDIR_READ]),
1540 .off2 = td_var_offset(ba[DDIR_WRITE]),
1541 .off3 = td_var_offset(ba[DDIR_TRIM]),
1543 .help = "IO block offset alignment",
1547 .category = FIO_OPT_C_IO,
1548 .group = FIO_OPT_G_INVALID,
1552 .lname = "Block size range",
1553 .alias = "blocksize_range",
1554 .type = FIO_OPT_RANGE,
1555 .off1 = td_var_offset(min_bs[DDIR_READ]),
1556 .off2 = td_var_offset(max_bs[DDIR_READ]),
1557 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
1558 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
1559 .off5 = td_var_offset(min_bs[DDIR_TRIM]),
1560 .off6 = td_var_offset(max_bs[DDIR_TRIM]),
1562 .help = "Set block size range (in more detail than bs)",
1566 .category = FIO_OPT_C_IO,
1567 .group = FIO_OPT_G_INVALID,
1571 .lname = "Block size split",
1572 .type = FIO_OPT_STR,
1573 .cb = str_bssplit_cb,
1574 .off1 = td_var_offset(bssplit),
1575 .help = "Set a specific mix of block sizes",
1578 .category = FIO_OPT_C_IO,
1579 .group = FIO_OPT_G_INVALID,
1582 .name = "bs_unaligned",
1583 .lname = "Block size unaligned",
1584 .alias = "blocksize_unaligned",
1585 .type = FIO_OPT_STR_SET,
1586 .off1 = td_var_offset(bs_unaligned),
1587 .help = "Don't sector align IO buffer sizes",
1590 .category = FIO_OPT_C_IO,
1591 .group = FIO_OPT_G_INVALID,
1594 .name = "bs_is_seq_rand",
1595 .lname = "Block size division is seq/random (not read/write)",
1596 .type = FIO_OPT_BOOL,
1597 .off1 = td_var_offset(bs_is_seq_rand),
1598 .help = "Consider any blocksize setting to be sequential,random",
1600 .parent = "blocksize",
1601 .category = FIO_OPT_C_IO,
1602 .group = FIO_OPT_G_INVALID,
1605 .name = "randrepeat",
1606 .lname = "Random repeatable",
1607 .type = FIO_OPT_BOOL,
1608 .off1 = td_var_offset(rand_repeatable),
1609 .help = "Use repeatable random IO pattern",
1613 .category = FIO_OPT_C_IO,
1614 .group = FIO_OPT_G_RANDOM,
1618 .lname = "The random generator seed",
1619 .type = FIO_OPT_STR_VAL,
1620 .off1 = td_var_offset(rand_seed),
1621 .help = "Set the random generator seed value",
1624 .category = FIO_OPT_C_IO,
1625 .group = FIO_OPT_G_RANDOM,
1628 .name = "use_os_rand",
1629 .lname = "Use OS random",
1630 .type = FIO_OPT_DEPRECATED,
1631 .off1 = td_var_offset(dep_use_os_rand),
1632 .category = FIO_OPT_C_IO,
1633 .group = FIO_OPT_G_RANDOM,
1636 .name = "norandommap",
1637 .lname = "No randommap",
1638 .type = FIO_OPT_STR_SET,
1639 .off1 = td_var_offset(norandommap),
1640 .help = "Accept potential duplicate random blocks",
1644 .category = FIO_OPT_C_IO,
1645 .group = FIO_OPT_G_RANDOM,
1648 .name = "softrandommap",
1649 .lname = "Soft randommap",
1650 .type = FIO_OPT_BOOL,
1651 .off1 = td_var_offset(softrandommap),
1652 .help = "Set norandommap if randommap allocation fails",
1653 .parent = "norandommap",
1656 .category = FIO_OPT_C_IO,
1657 .group = FIO_OPT_G_RANDOM,
1660 .name = "random_generator",
1661 .type = FIO_OPT_STR,
1662 .off1 = td_var_offset(random_generator),
1663 .help = "Type of random number generator to use",
1664 .def = "tausworthe",
1666 { .ival = "tausworthe",
1667 .oval = FIO_RAND_GEN_TAUSWORTHE,
1668 .help = "Strong Tausworthe generator",
1671 .oval = FIO_RAND_GEN_LFSR,
1672 .help = "Variable length LFSR",
1675 .ival = "tausworthe64",
1676 .oval = FIO_RAND_GEN_TAUSWORTHE64,
1677 .help = "64-bit Tausworthe variant",
1680 .category = FIO_OPT_C_IO,
1681 .group = FIO_OPT_G_RANDOM,
1684 .name = "random_distribution",
1685 .type = FIO_OPT_STR,
1686 .off1 = td_var_offset(random_distribution),
1687 .cb = str_random_distribution_cb,
1688 .help = "Random offset distribution generator",
1692 .oval = FIO_RAND_DIST_RANDOM,
1693 .help = "Completely random",
1696 .oval = FIO_RAND_DIST_ZIPF,
1697 .help = "Zipf distribution",
1700 .oval = FIO_RAND_DIST_PARETO,
1701 .help = "Pareto distribution",
1704 .oval = FIO_RAND_DIST_GAUSS,
1705 .help = "Normal (gaussian) distribution",
1708 .category = FIO_OPT_C_IO,
1709 .group = FIO_OPT_G_RANDOM,
1712 .name = "percentage_random",
1713 .lname = "Percentage Random",
1714 .type = FIO_OPT_INT,
1715 .off1 = td_var_offset(perc_rand[DDIR_READ]),
1716 .off2 = td_var_offset(perc_rand[DDIR_WRITE]),
1717 .off3 = td_var_offset(perc_rand[DDIR_TRIM]),
1719 .help = "Percentage of seq/random mix that should be random",
1720 .def = "100,100,100",
1722 .inverse = "percentage_sequential",
1723 .category = FIO_OPT_C_IO,
1724 .group = FIO_OPT_G_RANDOM,
1727 .name = "percentage_sequential",
1728 .lname = "Percentage Sequential",
1729 .type = FIO_OPT_DEPRECATED,
1730 .category = FIO_OPT_C_IO,
1731 .group = FIO_OPT_G_RANDOM,
1734 .name = "allrandrepeat",
1735 .type = FIO_OPT_BOOL,
1736 .off1 = td_var_offset(allrand_repeatable),
1737 .help = "Use repeatable random numbers for everything",
1739 .category = FIO_OPT_C_IO,
1740 .group = FIO_OPT_G_RANDOM,
1744 .lname = "Number of files",
1745 .alias = "nr_files",
1746 .type = FIO_OPT_INT,
1747 .off1 = td_var_offset(nr_files),
1748 .help = "Split job workload between this number of files",
1751 .category = FIO_OPT_C_FILE,
1752 .group = FIO_OPT_G_INVALID,
1755 .name = "openfiles",
1756 .lname = "Number of open files",
1757 .type = FIO_OPT_INT,
1758 .off1 = td_var_offset(open_files),
1759 .help = "Number of files to keep open at the same time",
1760 .category = FIO_OPT_C_FILE,
1761 .group = FIO_OPT_G_INVALID,
1764 .name = "file_service_type",
1765 .lname = "File service type",
1766 .type = FIO_OPT_STR,
1768 .off1 = td_var_offset(file_service_type),
1769 .help = "How to select which file to service next",
1770 .def = "roundrobin",
1771 .category = FIO_OPT_C_FILE,
1772 .group = FIO_OPT_G_INVALID,
1775 .oval = FIO_FSERVICE_RANDOM,
1776 .help = "Choose a file at random",
1778 { .ival = "roundrobin",
1779 .oval = FIO_FSERVICE_RR,
1780 .help = "Round robin select files",
1782 { .ival = "sequential",
1783 .oval = FIO_FSERVICE_SEQ,
1784 .help = "Finish one file before moving to the next",
1787 .parent = "nrfiles",
1790 #ifdef CONFIG_POSIX_FALLOCATE
1792 .name = "fallocate",
1793 .lname = "Fallocate",
1794 .type = FIO_OPT_STR,
1795 .off1 = td_var_offset(fallocate_mode),
1796 .help = "Whether pre-allocation is performed when laying out files",
1798 .category = FIO_OPT_C_FILE,
1799 .group = FIO_OPT_G_INVALID,
1802 .oval = FIO_FALLOCATE_NONE,
1803 .help = "Do not pre-allocate space",
1806 .oval = FIO_FALLOCATE_POSIX,
1807 .help = "Use posix_fallocate()",
1809 #ifdef CONFIG_LINUX_FALLOCATE
1811 .oval = FIO_FALLOCATE_KEEP_SIZE,
1812 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
1815 /* Compatibility with former boolean values */
1817 .oval = FIO_FALLOCATE_NONE,
1818 .help = "Alias for 'none'",
1821 .oval = FIO_FALLOCATE_POSIX,
1822 .help = "Alias for 'posix'",
1826 #endif /* CONFIG_POSIX_FALLOCATE */
1828 .name = "fadvise_hint",
1829 .lname = "Fadvise hint",
1830 .type = FIO_OPT_BOOL,
1831 .off1 = td_var_offset(fadvise_hint),
1832 .help = "Use fadvise() to advise the kernel on IO pattern",
1834 .category = FIO_OPT_C_FILE,
1835 .group = FIO_OPT_G_INVALID,
1837 #ifdef FIO_HAVE_STREAMID
1839 .name = "fadvise_stream",
1840 .lname = "Fadvise stream",
1841 .type = FIO_OPT_INT,
1842 .off1 = td_var_offset(fadvise_stream),
1843 .help = "Use fadvise() to set stream ID",
1844 .category = FIO_OPT_C_FILE,
1845 .group = FIO_OPT_G_INVALID,
1851 .type = FIO_OPT_INT,
1852 .off1 = td_var_offset(fsync_blocks),
1853 .help = "Issue fsync for writes every given number of blocks",
1856 .category = FIO_OPT_C_FILE,
1857 .group = FIO_OPT_G_INVALID,
1860 .name = "fdatasync",
1861 .lname = "Fdatasync",
1862 .type = FIO_OPT_INT,
1863 .off1 = td_var_offset(fdatasync_blocks),
1864 .help = "Issue fdatasync for writes every given number of blocks",
1867 .category = FIO_OPT_C_FILE,
1868 .group = FIO_OPT_G_INVALID,
1871 .name = "write_barrier",
1872 .lname = "Write barrier",
1873 .type = FIO_OPT_INT,
1874 .off1 = td_var_offset(barrier_blocks),
1875 .help = "Make every Nth write a barrier write",
1878 .category = FIO_OPT_C_IO,
1879 .group = FIO_OPT_G_INVALID,
1881 #ifdef CONFIG_SYNC_FILE_RANGE
1883 .name = "sync_file_range",
1884 .lname = "Sync file range",
1886 { .ival = "wait_before",
1887 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
1888 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
1892 .oval = SYNC_FILE_RANGE_WRITE,
1893 .help = "SYNC_FILE_RANGE_WRITE",
1897 .ival = "wait_after",
1898 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
1899 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
1903 .type = FIO_OPT_STR_MULTI,
1905 .off1 = td_var_offset(sync_file_range),
1906 .help = "Use sync_file_range()",
1907 .category = FIO_OPT_C_FILE,
1908 .group = FIO_OPT_G_INVALID,
1913 .lname = "Direct I/O",
1914 .type = FIO_OPT_BOOL,
1915 .off1 = td_var_offset(odirect),
1916 .help = "Use O_DIRECT IO (negates buffered)",
1918 .inverse = "buffered",
1919 .category = FIO_OPT_C_IO,
1920 .group = FIO_OPT_G_IO_TYPE,
1924 .lname = "Atomic I/O",
1925 .type = FIO_OPT_BOOL,
1926 .off1 = td_var_offset(oatomic),
1927 .help = "Use Atomic IO with O_DIRECT (implies O_DIRECT)",
1929 .category = FIO_OPT_C_IO,
1930 .group = FIO_OPT_G_IO_TYPE,
1934 .lname = "Buffered I/O",
1935 .type = FIO_OPT_BOOL,
1936 .off1 = td_var_offset(odirect),
1938 .help = "Use buffered IO (negates direct)",
1940 .inverse = "direct",
1941 .category = FIO_OPT_C_IO,
1942 .group = FIO_OPT_G_IO_TYPE,
1945 .name = "overwrite",
1946 .lname = "Overwrite",
1947 .type = FIO_OPT_BOOL,
1948 .off1 = td_var_offset(overwrite),
1949 .help = "When writing, set whether to overwrite current data",
1951 .category = FIO_OPT_C_FILE,
1952 .group = FIO_OPT_G_INVALID,
1957 .type = FIO_OPT_INT,
1958 .off1 = td_var_offset(loops),
1959 .help = "Number of times to run the job",
1962 .category = FIO_OPT_C_GENERAL,
1963 .group = FIO_OPT_G_RUNTIME,
1967 .lname = "Number of jobs",
1968 .type = FIO_OPT_INT,
1969 .off1 = td_var_offset(numjobs),
1970 .help = "Duplicate this job this many times",
1973 .category = FIO_OPT_C_GENERAL,
1974 .group = FIO_OPT_G_RUNTIME,
1977 .name = "startdelay",
1978 .lname = "Start delay",
1979 .type = FIO_OPT_STR_VAL_TIME,
1980 .off1 = td_var_offset(start_delay),
1981 .off2 = td_var_offset(start_delay_high),
1982 .help = "Only start job when this period has passed",
1986 .category = FIO_OPT_C_GENERAL,
1987 .group = FIO_OPT_G_RUNTIME,
1993 .type = FIO_OPT_STR_VAL_TIME,
1994 .off1 = td_var_offset(timeout),
1995 .help = "Stop workload when this amount of time has passed",
1999 .category = FIO_OPT_C_GENERAL,
2000 .group = FIO_OPT_G_RUNTIME,
2003 .name = "time_based",
2004 .lname = "Time based",
2005 .type = FIO_OPT_STR_SET,
2006 .off1 = td_var_offset(time_based),
2007 .help = "Keep running until runtime/timeout is met",
2008 .category = FIO_OPT_C_GENERAL,
2009 .group = FIO_OPT_G_RUNTIME,
2012 .name = "verify_only",
2013 .lname = "Verify only",
2014 .type = FIO_OPT_STR_SET,
2015 .off1 = td_var_offset(verify_only),
2016 .help = "Verifies previously written data is still valid",
2017 .category = FIO_OPT_C_GENERAL,
2018 .group = FIO_OPT_G_RUNTIME,
2021 .name = "ramp_time",
2022 .lname = "Ramp time",
2023 .type = FIO_OPT_STR_VAL_TIME,
2024 .off1 = td_var_offset(ramp_time),
2025 .help = "Ramp up time before measuring performance",
2028 .category = FIO_OPT_C_GENERAL,
2029 .group = FIO_OPT_G_RUNTIME,
2032 .name = "clocksource",
2033 .lname = "Clock source",
2034 .type = FIO_OPT_STR,
2035 .cb = fio_clock_source_cb,
2036 .off1 = td_var_offset(clocksource),
2037 .help = "What type of timing source to use",
2038 .category = FIO_OPT_C_GENERAL,
2039 .group = FIO_OPT_G_CLOCK,
2041 #ifdef CONFIG_GETTIMEOFDAY
2042 { .ival = "gettimeofday",
2044 .help = "Use gettimeofday(2) for timing",
2047 #ifdef CONFIG_CLOCK_GETTIME
2048 { .ival = "clock_gettime",
2049 .oval = CS_CGETTIME,
2050 .help = "Use clock_gettime(2) for timing",
2053 #ifdef ARCH_HAVE_CPU_CLOCK
2055 .oval = CS_CPUCLOCK,
2056 .help = "Use CPU private clock",
2064 .lname = "I/O Memory",
2065 .type = FIO_OPT_STR,
2067 .off1 = td_var_offset(mem_type),
2068 .help = "Backing type for IO buffers",
2070 .category = FIO_OPT_C_IO,
2071 .group = FIO_OPT_G_INVALID,
2075 .help = "Use malloc(3) for IO buffers",
2077 #ifndef CONFIG_NO_SHM
2080 .help = "Use shared memory segments for IO buffers",
2082 #ifdef FIO_HAVE_HUGETLB
2083 { .ival = "shmhuge",
2084 .oval = MEM_SHMHUGE,
2085 .help = "Like shm, but use huge pages",
2091 .help = "Use mmap(2) (file or anon) for IO buffers",
2093 { .ival = "mmapshared",
2094 .oval = MEM_MMAPSHARED,
2095 .help = "Like mmap, but use the shared flag",
2097 #ifdef FIO_HAVE_HUGETLB
2098 { .ival = "mmaphuge",
2099 .oval = MEM_MMAPHUGE,
2100 .help = "Like mmap, but use huge pages",
2106 .name = "iomem_align",
2107 .alias = "mem_align",
2108 .lname = "I/O memory alignment",
2109 .type = FIO_OPT_INT,
2110 .off1 = td_var_offset(mem_align),
2112 .help = "IO memory buffer offset alignment",
2116 .category = FIO_OPT_C_IO,
2117 .group = FIO_OPT_G_INVALID,
2122 .type = FIO_OPT_STR,
2123 .off1 = td_var_offset(verify),
2124 .help = "Verify data written",
2126 .category = FIO_OPT_C_IO,
2127 .group = FIO_OPT_G_VERIFY,
2130 .oval = VERIFY_NONE,
2131 .help = "Don't do IO verification",
2135 .help = "Use md5 checksums for verification",
2138 .oval = VERIFY_CRC64,
2139 .help = "Use crc64 checksums for verification",
2142 .oval = VERIFY_CRC32,
2143 .help = "Use crc32 checksums for verification",
2145 { .ival = "crc32c-intel",
2146 .oval = VERIFY_CRC32C,
2147 .help = "Use crc32c checksums for verification (hw assisted, if available)",
2150 .oval = VERIFY_CRC32C,
2151 .help = "Use crc32c checksums for verification (hw assisted, if available)",
2154 .oval = VERIFY_CRC16,
2155 .help = "Use crc16 checksums for verification",
2158 .oval = VERIFY_CRC7,
2159 .help = "Use crc7 checksums for verification",
2162 .oval = VERIFY_SHA1,
2163 .help = "Use sha1 checksums for verification",
2166 .oval = VERIFY_SHA256,
2167 .help = "Use sha256 checksums for verification",
2170 .oval = VERIFY_SHA512,
2171 .help = "Use sha512 checksums for verification",
2174 .oval = VERIFY_XXHASH,
2175 .help = "Use xxhash checksums for verification",
2177 /* Meta information was included into verify_header,
2178 * 'meta' verification is implied by default. */
2180 .oval = VERIFY_HDR_ONLY,
2181 .help = "Use io information for verification. "
2182 "Now is implied by default, thus option is obsolete, "
2185 { .ival = "pattern",
2186 .oval = VERIFY_PATTERN_NO_HDR,
2187 .help = "Verify strict pattern",
2191 .oval = VERIFY_NULL,
2192 .help = "Pretend to verify",
2197 .name = "do_verify",
2198 .lname = "Perform verify step",
2199 .type = FIO_OPT_BOOL,
2200 .off1 = td_var_offset(do_verify),
2201 .help = "Run verification stage after write",
2205 .category = FIO_OPT_C_IO,
2206 .group = FIO_OPT_G_VERIFY,
2209 .name = "verifysort",
2210 .lname = "Verify sort",
2211 .type = FIO_OPT_BOOL,
2212 .off1 = td_var_offset(verifysort),
2213 .help = "Sort written verify blocks for read back",
2217 .category = FIO_OPT_C_IO,
2218 .group = FIO_OPT_G_VERIFY,
2221 .name = "verifysort_nr",
2222 .type = FIO_OPT_INT,
2223 .off1 = td_var_offset(verifysort_nr),
2224 .help = "Pre-load and sort verify blocks for a read workload",
2229 .category = FIO_OPT_C_IO,
2230 .group = FIO_OPT_G_VERIFY,
2233 .name = "verify_interval",
2234 .lname = "Verify interval",
2235 .type = FIO_OPT_INT,
2236 .off1 = td_var_offset(verify_interval),
2237 .minval = 2 * sizeof(struct verify_header),
2238 .help = "Store verify buffer header every N bytes",
2241 .interval = 2 * sizeof(struct verify_header),
2242 .category = FIO_OPT_C_IO,
2243 .group = FIO_OPT_G_VERIFY,
2246 .name = "verify_offset",
2247 .lname = "Verify offset",
2248 .type = FIO_OPT_INT,
2249 .help = "Offset verify header location by N bytes",
2250 .off1 = td_var_offset(verify_offset),
2251 .minval = sizeof(struct verify_header),
2254 .category = FIO_OPT_C_IO,
2255 .group = FIO_OPT_G_VERIFY,
2258 .name = "verify_pattern",
2259 .lname = "Verify pattern",
2260 .type = FIO_OPT_STR,
2261 .cb = str_verify_pattern_cb,
2262 .off1 = td_var_offset(verify_pattern),
2263 .help = "Fill pattern for IO buffers",
2266 .category = FIO_OPT_C_IO,
2267 .group = FIO_OPT_G_VERIFY,
2270 .name = "verify_fatal",
2271 .lname = "Verify fatal",
2272 .type = FIO_OPT_BOOL,
2273 .off1 = td_var_offset(verify_fatal),
2275 .help = "Exit on a single verify failure, don't continue",
2278 .category = FIO_OPT_C_IO,
2279 .group = FIO_OPT_G_VERIFY,
2282 .name = "verify_dump",
2283 .lname = "Verify dump",
2284 .type = FIO_OPT_BOOL,
2285 .off1 = td_var_offset(verify_dump),
2287 .help = "Dump contents of good and bad blocks on failure",
2290 .category = FIO_OPT_C_IO,
2291 .group = FIO_OPT_G_VERIFY,
2294 .name = "verify_async",
2295 .lname = "Verify asynchronously",
2296 .type = FIO_OPT_INT,
2297 .off1 = td_var_offset(verify_async),
2299 .help = "Number of async verifier threads to use",
2302 .category = FIO_OPT_C_IO,
2303 .group = FIO_OPT_G_VERIFY,
2306 .name = "verify_backlog",
2307 .lname = "Verify backlog",
2308 .type = FIO_OPT_STR_VAL,
2309 .off1 = td_var_offset(verify_backlog),
2310 .help = "Verify after this number of blocks are written",
2313 .category = FIO_OPT_C_IO,
2314 .group = FIO_OPT_G_VERIFY,
2317 .name = "verify_backlog_batch",
2318 .lname = "Verify backlog batch",
2319 .type = FIO_OPT_INT,
2320 .off1 = td_var_offset(verify_batch),
2321 .help = "Verify this number of IO blocks",
2324 .category = FIO_OPT_C_IO,
2325 .group = FIO_OPT_G_VERIFY,
2327 #ifdef FIO_HAVE_CPU_AFFINITY
2329 .name = "verify_async_cpus",
2330 .lname = "Async verify CPUs",
2331 .type = FIO_OPT_STR,
2332 .cb = str_verify_cpus_allowed_cb,
2333 .off1 = td_var_offset(verify_cpumask),
2334 .help = "Set CPUs allowed for async verify threads",
2335 .parent = "verify_async",
2337 .category = FIO_OPT_C_IO,
2338 .group = FIO_OPT_G_VERIFY,
2342 .name = "experimental_verify",
2343 .off1 = td_var_offset(experimental_verify),
2344 .type = FIO_OPT_BOOL,
2345 .help = "Enable experimental verification",
2347 .category = FIO_OPT_C_IO,
2348 .group = FIO_OPT_G_VERIFY,
2351 .name = "verify_state_load",
2352 .lname = "Load verify state",
2353 .off1 = td_var_offset(verify_state),
2354 .type = FIO_OPT_BOOL,
2355 .help = "Load verify termination state",
2357 .category = FIO_OPT_C_IO,
2358 .group = FIO_OPT_G_VERIFY,
2361 .name = "verify_state_save",
2362 .lname = "Save verify state",
2363 .off1 = td_var_offset(verify_state_save),
2364 .type = FIO_OPT_BOOL,
2366 .help = "Save verify state on termination",
2368 .category = FIO_OPT_C_IO,
2369 .group = FIO_OPT_G_VERIFY,
2371 #ifdef FIO_HAVE_TRIM
2373 .name = "trim_percentage",
2374 .lname = "Trim percentage",
2375 .type = FIO_OPT_INT,
2376 .off1 = td_var_offset(trim_percentage),
2379 .help = "Number of verify blocks to discard/trim",
2384 .category = FIO_OPT_C_IO,
2385 .group = FIO_OPT_G_TRIM,
2388 .name = "trim_verify_zero",
2389 .lname = "Verify trim zero",
2390 .type = FIO_OPT_BOOL,
2391 .help = "Verify that trim/discarded blocks are returned as zeroes",
2392 .off1 = td_var_offset(trim_zero),
2393 .parent = "trim_percentage",
2396 .category = FIO_OPT_C_IO,
2397 .group = FIO_OPT_G_TRIM,
2400 .name = "trim_backlog",
2401 .lname = "Trim backlog",
2402 .type = FIO_OPT_STR_VAL,
2403 .off1 = td_var_offset(trim_backlog),
2404 .help = "Trim after this number of blocks are written",
2405 .parent = "trim_percentage",
2408 .category = FIO_OPT_C_IO,
2409 .group = FIO_OPT_G_TRIM,
2412 .name = "trim_backlog_batch",
2413 .lname = "Trim backlog batch",
2414 .type = FIO_OPT_INT,
2415 .off1 = td_var_offset(trim_batch),
2416 .help = "Trim this number of IO blocks",
2417 .parent = "trim_percentage",
2420 .category = FIO_OPT_C_IO,
2421 .group = FIO_OPT_G_TRIM,
2425 .name = "write_iolog",
2426 .lname = "Write I/O log",
2427 .type = FIO_OPT_STR_STORE,
2428 .off1 = td_var_offset(write_iolog_file),
2429 .help = "Store IO pattern to file",
2430 .category = FIO_OPT_C_IO,
2431 .group = FIO_OPT_G_IOLOG,
2434 .name = "read_iolog",
2435 .lname = "Read I/O log",
2436 .type = FIO_OPT_STR_STORE,
2437 .off1 = td_var_offset(read_iolog_file),
2438 .help = "Playback IO pattern from file",
2439 .category = FIO_OPT_C_IO,
2440 .group = FIO_OPT_G_IOLOG,
2443 .name = "replay_no_stall",
2444 .lname = "Don't stall on replay",
2445 .type = FIO_OPT_BOOL,
2446 .off1 = td_var_offset(no_stall),
2448 .parent = "read_iolog",
2450 .help = "Playback IO pattern file as fast as possible without stalls",
2451 .category = FIO_OPT_C_IO,
2452 .group = FIO_OPT_G_IOLOG,
2455 .name = "replay_redirect",
2456 .lname = "Redirect device for replay",
2457 .type = FIO_OPT_STR_STORE,
2458 .off1 = td_var_offset(replay_redirect),
2459 .parent = "read_iolog",
2461 .help = "Replay all I/O onto this device, regardless of trace device",
2462 .category = FIO_OPT_C_IO,
2463 .group = FIO_OPT_G_IOLOG,
2466 .name = "replay_scale",
2467 .lname = "Replace offset scale factor",
2468 .type = FIO_OPT_INT,
2469 .off1 = td_var_offset(replay_scale),
2470 .parent = "read_iolog",
2472 .help = "Align offsets to this blocksize",
2473 .category = FIO_OPT_C_IO,
2474 .group = FIO_OPT_G_IOLOG,
2477 .name = "replay_align",
2478 .lname = "Replace alignment",
2479 .type = FIO_OPT_INT,
2480 .off1 = td_var_offset(replay_align),
2481 .parent = "read_iolog",
2482 .help = "Scale offset down by this factor",
2483 .category = FIO_OPT_C_IO,
2484 .group = FIO_OPT_G_IOLOG,
2488 .name = "exec_prerun",
2489 .lname = "Pre-execute runnable",
2490 .type = FIO_OPT_STR_STORE,
2491 .off1 = td_var_offset(exec_prerun),
2492 .help = "Execute this file prior to running job",
2493 .category = FIO_OPT_C_GENERAL,
2494 .group = FIO_OPT_G_INVALID,
2497 .name = "exec_postrun",
2498 .lname = "Post-execute runnable",
2499 .type = FIO_OPT_STR_STORE,
2500 .off1 = td_var_offset(exec_postrun),
2501 .help = "Execute this file after running job",
2502 .category = FIO_OPT_C_GENERAL,
2503 .group = FIO_OPT_G_INVALID,
2505 #ifdef FIO_HAVE_IOSCHED_SWITCH
2507 .name = "ioscheduler",
2508 .lname = "I/O scheduler",
2509 .type = FIO_OPT_STR_STORE,
2510 .off1 = td_var_offset(ioscheduler),
2511 .help = "Use this IO scheduler on the backing device",
2512 .category = FIO_OPT_C_FILE,
2513 .group = FIO_OPT_G_INVALID,
2518 .lname = "Zone size",
2519 .type = FIO_OPT_STR_VAL,
2520 .off1 = td_var_offset(zone_size),
2521 .help = "Amount of data to read per zone",
2523 .interval = 1024 * 1024,
2524 .category = FIO_OPT_C_IO,
2525 .group = FIO_OPT_G_ZONE,
2528 .name = "zonerange",
2529 .lname = "Zone range",
2530 .type = FIO_OPT_STR_VAL,
2531 .off1 = td_var_offset(zone_range),
2532 .help = "Give size of an IO zone",
2534 .interval = 1024 * 1024,
2535 .category = FIO_OPT_C_IO,
2536 .group = FIO_OPT_G_ZONE,
2540 .lname = "Zone skip",
2541 .type = FIO_OPT_STR_VAL,
2542 .off1 = td_var_offset(zone_skip),
2543 .help = "Space between IO zones",
2545 .interval = 1024 * 1024,
2546 .category = FIO_OPT_C_IO,
2547 .group = FIO_OPT_G_ZONE,
2551 .lname = "Lock memory",
2552 .type = FIO_OPT_STR_VAL,
2553 .off1 = td_var_offset(lockmem),
2554 .help = "Lock down this amount of memory (per worker)",
2556 .interval = 1024 * 1024,
2557 .category = FIO_OPT_C_GENERAL,
2558 .group = FIO_OPT_G_INVALID,
2561 .name = "rwmixread",
2562 .lname = "Read/write mix read",
2563 .type = FIO_OPT_INT,
2564 .cb = str_rwmix_read_cb,
2565 .off1 = td_var_offset(rwmix[DDIR_READ]),
2567 .help = "Percentage of mixed workload that is reads",
2570 .inverse = "rwmixwrite",
2571 .category = FIO_OPT_C_IO,
2572 .group = FIO_OPT_G_RWMIX,
2575 .name = "rwmixwrite",
2576 .lname = "Read/write mix write",
2577 .type = FIO_OPT_INT,
2578 .cb = str_rwmix_write_cb,
2579 .off1 = td_var_offset(rwmix[DDIR_WRITE]),
2581 .help = "Percentage of mixed workload that is writes",
2584 .inverse = "rwmixread",
2585 .category = FIO_OPT_C_IO,
2586 .group = FIO_OPT_G_RWMIX,
2589 .name = "rwmixcycle",
2590 .lname = "Read/write mix cycle",
2591 .type = FIO_OPT_DEPRECATED,
2592 .category = FIO_OPT_C_IO,
2593 .group = FIO_OPT_G_RWMIX,
2598 .type = FIO_OPT_INT,
2599 .off1 = td_var_offset(nice),
2600 .help = "Set job CPU nice value",
2605 .category = FIO_OPT_C_GENERAL,
2606 .group = FIO_OPT_G_CRED,
2608 #ifdef FIO_HAVE_IOPRIO
2611 .lname = "I/O nice priority",
2612 .type = FIO_OPT_INT,
2613 .off1 = td_var_offset(ioprio),
2614 .help = "Set job IO priority value",
2618 .category = FIO_OPT_C_GENERAL,
2619 .group = FIO_OPT_G_CRED,
2622 .name = "prioclass",
2623 .lname = "I/O nice priority class",
2624 .type = FIO_OPT_INT,
2625 .off1 = td_var_offset(ioprio_class),
2626 .help = "Set job IO priority class",
2630 .category = FIO_OPT_C_GENERAL,
2631 .group = FIO_OPT_G_CRED,
2635 .name = "thinktime",
2636 .lname = "Thinktime",
2637 .type = FIO_OPT_INT,
2638 .off1 = td_var_offset(thinktime),
2639 .help = "Idle time between IO buffers (usec)",
2642 .category = FIO_OPT_C_IO,
2643 .group = FIO_OPT_G_THINKTIME,
2646 .name = "thinktime_spin",
2647 .lname = "Thinktime spin",
2648 .type = FIO_OPT_INT,
2649 .off1 = td_var_offset(thinktime_spin),
2650 .help = "Start think time by spinning this amount (usec)",
2653 .parent = "thinktime",
2655 .category = FIO_OPT_C_IO,
2656 .group = FIO_OPT_G_THINKTIME,
2659 .name = "thinktime_blocks",
2660 .lname = "Thinktime blocks",
2661 .type = FIO_OPT_INT,
2662 .off1 = td_var_offset(thinktime_blocks),
2663 .help = "IO buffer period between 'thinktime'",
2665 .parent = "thinktime",
2667 .category = FIO_OPT_C_IO,
2668 .group = FIO_OPT_G_THINKTIME,
2672 .lname = "I/O rate",
2673 .type = FIO_OPT_INT,
2674 .off1 = td_var_offset(rate[DDIR_READ]),
2675 .off2 = td_var_offset(rate[DDIR_WRITE]),
2676 .off3 = td_var_offset(rate[DDIR_TRIM]),
2677 .help = "Set bandwidth rate",
2678 .category = FIO_OPT_C_IO,
2679 .group = FIO_OPT_G_RATE,
2684 .lname = "I/O min rate",
2685 .type = FIO_OPT_INT,
2686 .off1 = td_var_offset(ratemin[DDIR_READ]),
2687 .off2 = td_var_offset(ratemin[DDIR_WRITE]),
2688 .off3 = td_var_offset(ratemin[DDIR_TRIM]),
2689 .help = "Job must meet this rate or it will be shutdown",
2692 .category = FIO_OPT_C_IO,
2693 .group = FIO_OPT_G_RATE,
2696 .name = "rate_iops",
2697 .lname = "I/O rate IOPS",
2698 .type = FIO_OPT_INT,
2699 .off1 = td_var_offset(rate_iops[DDIR_READ]),
2700 .off2 = td_var_offset(rate_iops[DDIR_WRITE]),
2701 .off3 = td_var_offset(rate_iops[DDIR_TRIM]),
2702 .help = "Limit IO used to this number of IO operations/sec",
2704 .category = FIO_OPT_C_IO,
2705 .group = FIO_OPT_G_RATE,
2708 .name = "rate_iops_min",
2709 .lname = "I/O min rate IOPS",
2710 .type = FIO_OPT_INT,
2711 .off1 = td_var_offset(rate_iops_min[DDIR_READ]),
2712 .off2 = td_var_offset(rate_iops_min[DDIR_WRITE]),
2713 .off3 = td_var_offset(rate_iops_min[DDIR_TRIM]),
2714 .help = "Job must meet this rate or it will be shut down",
2715 .parent = "rate_iops",
2717 .category = FIO_OPT_C_IO,
2718 .group = FIO_OPT_G_RATE,
2721 .name = "rate_process",
2722 .lname = "Rate Process",
2723 .type = FIO_OPT_STR,
2724 .off1 = td_var_offset(rate_process),
2725 .help = "What process controls how rated IO is managed",
2727 .category = FIO_OPT_C_IO,
2728 .group = FIO_OPT_G_RATE,
2731 .oval = RATE_PROCESS_LINEAR,
2732 .help = "Linear rate of IO",
2736 .oval = RATE_PROCESS_POISSON,
2737 .help = "Rate follows Poisson process",
2743 .name = "rate_cycle",
2744 .alias = "ratecycle",
2745 .lname = "I/O rate cycle",
2746 .type = FIO_OPT_INT,
2747 .off1 = td_var_offset(ratecycle),
2748 .help = "Window average for rate limits (msec)",
2752 .category = FIO_OPT_C_IO,
2753 .group = FIO_OPT_G_RATE,
2756 .name = "max_latency",
2757 .type = FIO_OPT_INT,
2758 .off1 = td_var_offset(max_latency),
2759 .help = "Maximum tolerated IO latency (usec)",
2761 .category = FIO_OPT_C_IO,
2762 .group = FIO_OPT_G_LATPROF,
2765 .name = "latency_target",
2766 .lname = "Latency Target (usec)",
2767 .type = FIO_OPT_STR_VAL_TIME,
2768 .off1 = td_var_offset(latency_target),
2769 .help = "Ramp to max queue depth supporting this latency",
2771 .category = FIO_OPT_C_IO,
2772 .group = FIO_OPT_G_LATPROF,
2775 .name = "latency_window",
2776 .lname = "Latency Window (usec)",
2777 .type = FIO_OPT_STR_VAL_TIME,
2778 .off1 = td_var_offset(latency_window),
2779 .help = "Time to sustain latency_target",
2781 .category = FIO_OPT_C_IO,
2782 .group = FIO_OPT_G_LATPROF,
2785 .name = "latency_percentile",
2786 .lname = "Latency Percentile",
2787 .type = FIO_OPT_FLOAT_LIST,
2788 .off1 = td_var_offset(latency_percentile),
2789 .help = "Percentile of IOs must be below latency_target",
2794 .category = FIO_OPT_C_IO,
2795 .group = FIO_OPT_G_LATPROF,
2798 .name = "invalidate",
2799 .lname = "Cache invalidate",
2800 .type = FIO_OPT_BOOL,
2801 .off1 = td_var_offset(invalidate_cache),
2802 .help = "Invalidate buffer/page cache prior to running job",
2804 .category = FIO_OPT_C_IO,
2805 .group = FIO_OPT_G_IO_TYPE,
2809 .lname = "Synchronous I/O",
2810 .type = FIO_OPT_BOOL,
2811 .off1 = td_var_offset(sync_io),
2812 .help = "Use O_SYNC for buffered writes",
2814 .parent = "buffered",
2816 .category = FIO_OPT_C_IO,
2817 .group = FIO_OPT_G_IO_TYPE,
2820 .name = "create_serialize",
2821 .lname = "Create serialize",
2822 .type = FIO_OPT_BOOL,
2823 .off1 = td_var_offset(create_serialize),
2824 .help = "Serialize creating of job files",
2826 .category = FIO_OPT_C_FILE,
2827 .group = FIO_OPT_G_INVALID,
2830 .name = "create_fsync",
2831 .lname = "Create fsync",
2832 .type = FIO_OPT_BOOL,
2833 .off1 = td_var_offset(create_fsync),
2834 .help = "fsync file after creation",
2836 .category = FIO_OPT_C_FILE,
2837 .group = FIO_OPT_G_INVALID,
2840 .name = "create_on_open",
2841 .lname = "Create on open",
2842 .type = FIO_OPT_BOOL,
2843 .off1 = td_var_offset(create_on_open),
2844 .help = "Create files when they are opened for IO",
2846 .category = FIO_OPT_C_FILE,
2847 .group = FIO_OPT_G_INVALID,
2850 .name = "create_only",
2851 .type = FIO_OPT_BOOL,
2852 .off1 = td_var_offset(create_only),
2853 .help = "Only perform file creation phase",
2854 .category = FIO_OPT_C_FILE,
2858 .name = "allow_file_create",
2859 .lname = "Allow file create",
2860 .type = FIO_OPT_BOOL,
2861 .off1 = td_var_offset(allow_create),
2862 .help = "Permit fio to create files, if they don't exist",
2864 .category = FIO_OPT_C_FILE,
2865 .group = FIO_OPT_G_FILENAME,
2868 .name = "allow_mounted_write",
2869 .lname = "Allow mounted write",
2870 .type = FIO_OPT_BOOL,
2871 .off1 = td_var_offset(allow_mounted_write),
2872 .help = "Allow writes to a mounted partition",
2874 .category = FIO_OPT_C_FILE,
2875 .group = FIO_OPT_G_FILENAME,
2879 .lname = "Pre-read files",
2880 .type = FIO_OPT_BOOL,
2881 .off1 = td_var_offset(pre_read),
2882 .help = "Pre-read files before starting official testing",
2884 .category = FIO_OPT_C_FILE,
2885 .group = FIO_OPT_G_INVALID,
2887 #ifdef FIO_HAVE_CPU_AFFINITY
2890 .lname = "CPU mask",
2891 .type = FIO_OPT_INT,
2892 .cb = str_cpumask_cb,
2893 .off1 = td_var_offset(cpumask),
2894 .help = "CPU affinity mask",
2895 .category = FIO_OPT_C_GENERAL,
2896 .group = FIO_OPT_G_CRED,
2899 .name = "cpus_allowed",
2900 .lname = "CPUs allowed",
2901 .type = FIO_OPT_STR,
2902 .cb = str_cpus_allowed_cb,
2903 .off1 = td_var_offset(cpumask),
2904 .help = "Set CPUs allowed",
2905 .category = FIO_OPT_C_GENERAL,
2906 .group = FIO_OPT_G_CRED,
2909 .name = "cpus_allowed_policy",
2910 .lname = "CPUs allowed distribution policy",
2911 .type = FIO_OPT_STR,
2912 .off1 = td_var_offset(cpus_allowed_policy),
2913 .help = "Distribution policy for cpus_allowed",
2914 .parent = "cpus_allowed",
2918 .oval = FIO_CPUS_SHARED,
2919 .help = "Mask shared between threads",
2922 .oval = FIO_CPUS_SPLIT,
2923 .help = "Mask split between threads",
2926 .category = FIO_OPT_C_GENERAL,
2927 .group = FIO_OPT_G_CRED,
2930 #ifdef CONFIG_LIBNUMA
2932 .name = "numa_cpu_nodes",
2933 .type = FIO_OPT_STR,
2934 .cb = str_numa_cpunodes_cb,
2935 .off1 = td_var_offset(numa_cpunodes),
2936 .help = "NUMA CPU nodes bind",
2937 .category = FIO_OPT_C_GENERAL,
2938 .group = FIO_OPT_G_INVALID,
2941 .name = "numa_mem_policy",
2942 .type = FIO_OPT_STR,
2943 .cb = str_numa_mpol_cb,
2944 .off1 = td_var_offset(numa_memnodes),
2945 .help = "NUMA memory policy setup",
2946 .category = FIO_OPT_C_GENERAL,
2947 .group = FIO_OPT_G_INVALID,
2951 .name = "end_fsync",
2952 .lname = "End fsync",
2953 .type = FIO_OPT_BOOL,
2954 .off1 = td_var_offset(end_fsync),
2955 .help = "Include fsync at the end of job",
2957 .category = FIO_OPT_C_FILE,
2958 .group = FIO_OPT_G_INVALID,
2961 .name = "fsync_on_close",
2962 .lname = "Fsync on close",
2963 .type = FIO_OPT_BOOL,
2964 .off1 = td_var_offset(fsync_on_close),
2965 .help = "fsync files on close",
2967 .category = FIO_OPT_C_FILE,
2968 .group = FIO_OPT_G_INVALID,
2972 .lname = "Unlink file",
2973 .type = FIO_OPT_BOOL,
2974 .off1 = td_var_offset(unlink),
2975 .help = "Unlink created files after job has completed",
2977 .category = FIO_OPT_C_FILE,
2978 .group = FIO_OPT_G_INVALID,
2982 .lname = "Exit-all on terminate",
2983 .type = FIO_OPT_STR_SET,
2984 .cb = str_exitall_cb,
2985 .help = "Terminate all jobs when one exits",
2986 .category = FIO_OPT_C_GENERAL,
2987 .group = FIO_OPT_G_PROCESS,
2990 .name = "exitall_on_error",
2991 .lname = "Exit-all on terminate in error",
2992 .type = FIO_OPT_BOOL,
2993 .off1 = td_var_offset(unlink),
2994 .help = "Terminate all jobs when one exits in error",
2995 .category = FIO_OPT_C_GENERAL,
2996 .group = FIO_OPT_G_PROCESS,
2999 .name = "stonewall",
3000 .lname = "Wait for previous",
3001 .alias = "wait_for_previous",
3002 .type = FIO_OPT_STR_SET,
3003 .off1 = td_var_offset(stonewall),
3004 .help = "Insert a hard barrier between this job and previous",
3005 .category = FIO_OPT_C_GENERAL,
3006 .group = FIO_OPT_G_PROCESS,
3009 .name = "new_group",
3010 .lname = "New group",
3011 .type = FIO_OPT_STR_SET,
3012 .off1 = td_var_offset(new_group),
3013 .help = "Mark the start of a new group (for reporting)",
3014 .category = FIO_OPT_C_GENERAL,
3015 .group = FIO_OPT_G_PROCESS,
3020 .type = FIO_OPT_STR_SET,
3021 .off1 = td_var_offset(use_thread),
3022 .help = "Use threads instead of processes",
3023 #ifdef CONFIG_NO_SHM
3027 .category = FIO_OPT_C_GENERAL,
3028 .group = FIO_OPT_G_PROCESS,
3031 .name = "per_job_logs",
3032 .type = FIO_OPT_BOOL,
3033 .off1 = td_var_offset(per_job_logs),
3034 .help = "Include job number in generated log files or not",
3036 .category = FIO_OPT_C_LOG,
3037 .group = FIO_OPT_G_INVALID,
3040 .name = "write_bw_log",
3041 .lname = "Write bandwidth log",
3042 .type = FIO_OPT_STR_STORE,
3043 .off1 = td_var_offset(bw_log_file),
3044 .help = "Write log of bandwidth during run",
3045 .category = FIO_OPT_C_LOG,
3046 .group = FIO_OPT_G_INVALID,
3049 .name = "write_lat_log",
3050 .lname = "Write latency log",
3051 .type = FIO_OPT_STR_STORE,
3052 .off1 = td_var_offset(lat_log_file),
3053 .help = "Write log of latency during run",
3054 .category = FIO_OPT_C_LOG,
3055 .group = FIO_OPT_G_INVALID,
3058 .name = "write_iops_log",
3059 .lname = "Write IOPS log",
3060 .type = FIO_OPT_STR_STORE,
3061 .off1 = td_var_offset(iops_log_file),
3062 .help = "Write log of IOPS during run",
3063 .category = FIO_OPT_C_LOG,
3064 .group = FIO_OPT_G_INVALID,
3067 .name = "log_avg_msec",
3068 .lname = "Log averaging (msec)",
3069 .type = FIO_OPT_INT,
3070 .off1 = td_var_offset(log_avg_msec),
3071 .help = "Average bw/iops/lat logs over this period of time",
3073 .category = FIO_OPT_C_LOG,
3074 .group = FIO_OPT_G_INVALID,
3077 .name = "log_offset",
3078 .lname = "Log offset of IO",
3079 .type = FIO_OPT_BOOL,
3080 .off1 = td_var_offset(log_offset),
3081 .help = "Include offset of IO for each log entry",
3083 .category = FIO_OPT_C_LOG,
3084 .group = FIO_OPT_G_INVALID,
3088 .name = "log_compression",
3089 .lname = "Log compression",
3090 .type = FIO_OPT_INT,
3091 .off1 = td_var_offset(log_gz),
3092 .help = "Log in compressed chunks of this size",
3094 .maxval = 512 * 1024 * 1024ULL,
3095 .category = FIO_OPT_C_LOG,
3096 .group = FIO_OPT_G_INVALID,
3098 #ifdef FIO_HAVE_CPU_AFFINITY
3100 .name = "log_compression_cpus",
3101 .lname = "Log Compression CPUs",
3102 .type = FIO_OPT_STR,
3103 .cb = str_log_cpus_allowed_cb,
3104 .off1 = td_var_offset(log_gz_cpumask),
3105 .parent = "log_compression",
3106 .help = "Limit log compression to these CPUs",
3107 .category = FIO_OPT_C_LOG,
3108 .group = FIO_OPT_G_INVALID,
3112 .name = "log_store_compressed",
3113 .lname = "Log store compressed",
3114 .type = FIO_OPT_BOOL,
3115 .off1 = td_var_offset(log_gz_store),
3116 .help = "Store logs in a compressed format",
3117 .category = FIO_OPT_C_LOG,
3118 .group = FIO_OPT_G_INVALID,
3122 .name = "block_error_percentiles",
3123 .lname = "Block error percentiles",
3124 .type = FIO_OPT_BOOL,
3125 .off1 = td_var_offset(block_error_hist),
3126 .help = "Record trim block errors and make a histogram",
3128 .category = FIO_OPT_C_LOG,
3129 .group = FIO_OPT_G_INVALID,
3132 .name = "bwavgtime",
3133 .lname = "Bandwidth average time",
3134 .type = FIO_OPT_INT,
3135 .off1 = td_var_offset(bw_avg_time),
3136 .help = "Time window over which to calculate bandwidth"
3139 .parent = "write_bw_log",
3142 .category = FIO_OPT_C_LOG,
3143 .group = FIO_OPT_G_INVALID,
3146 .name = "iopsavgtime",
3147 .lname = "IOPS average time",
3148 .type = FIO_OPT_INT,
3149 .off1 = td_var_offset(iops_avg_time),
3150 .help = "Time window over which to calculate IOPS (msec)",
3152 .parent = "write_iops_log",
3155 .category = FIO_OPT_C_LOG,
3156 .group = FIO_OPT_G_INVALID,
3159 .name = "group_reporting",
3160 .lname = "Group reporting",
3161 .type = FIO_OPT_STR_SET,
3162 .off1 = td_var_offset(group_reporting),
3163 .help = "Do reporting on a per-group basis",
3164 .category = FIO_OPT_C_STAT,
3165 .group = FIO_OPT_G_INVALID,
3168 .name = "zero_buffers",
3169 .lname = "Zero I/O buffers",
3170 .type = FIO_OPT_STR_SET,
3171 .off1 = td_var_offset(zero_buffers),
3172 .help = "Init IO buffers to all zeroes",
3173 .category = FIO_OPT_C_IO,
3174 .group = FIO_OPT_G_IO_BUF,
3177 .name = "refill_buffers",
3178 .lname = "Refill I/O buffers",
3179 .type = FIO_OPT_STR_SET,
3180 .off1 = td_var_offset(refill_buffers),
3181 .help = "Refill IO buffers on every IO submit",
3182 .category = FIO_OPT_C_IO,
3183 .group = FIO_OPT_G_IO_BUF,
3186 .name = "scramble_buffers",
3187 .lname = "Scramble I/O buffers",
3188 .type = FIO_OPT_BOOL,
3189 .off1 = td_var_offset(scramble_buffers),
3190 .help = "Slightly scramble buffers on every IO submit",
3192 .category = FIO_OPT_C_IO,
3193 .group = FIO_OPT_G_IO_BUF,
3196 .name = "buffer_pattern",
3197 .lname = "Buffer pattern",
3198 .type = FIO_OPT_STR,
3199 .cb = str_buffer_pattern_cb,
3200 .off1 = td_var_offset(buffer_pattern),
3201 .help = "Fill pattern for IO buffers",
3202 .category = FIO_OPT_C_IO,
3203 .group = FIO_OPT_G_IO_BUF,
3206 .name = "buffer_compress_percentage",
3207 .lname = "Buffer compression percentage",
3208 .type = FIO_OPT_INT,
3209 .cb = str_buffer_compress_cb,
3210 .off1 = td_var_offset(compress_percentage),
3213 .help = "How compressible the buffer is (approximately)",
3215 .category = FIO_OPT_C_IO,
3216 .group = FIO_OPT_G_IO_BUF,
3219 .name = "buffer_compress_chunk",
3220 .lname = "Buffer compression chunk size",
3221 .type = FIO_OPT_INT,
3222 .off1 = td_var_offset(compress_chunk),
3223 .parent = "buffer_compress_percentage",
3225 .help = "Size of compressible region in buffer",
3227 .category = FIO_OPT_C_IO,
3228 .group = FIO_OPT_G_IO_BUF,
3231 .name = "dedupe_percentage",
3232 .lname = "Dedupe percentage",
3233 .type = FIO_OPT_INT,
3234 .cb = str_dedupe_cb,
3235 .off1 = td_var_offset(dedupe_percentage),
3238 .help = "Percentage of buffers that are dedupable",
3240 .category = FIO_OPT_C_IO,
3241 .group = FIO_OPT_G_IO_BUF,
3244 .name = "clat_percentiles",
3245 .lname = "Completion latency percentiles",
3246 .type = FIO_OPT_BOOL,
3247 .off1 = td_var_offset(clat_percentiles),
3248 .help = "Enable the reporting of completion latency percentiles",
3250 .category = FIO_OPT_C_STAT,
3251 .group = FIO_OPT_G_INVALID,
3254 .name = "percentile_list",
3255 .lname = "Percentile list",
3256 .type = FIO_OPT_FLOAT_LIST,
3257 .off1 = td_var_offset(percentile_list),
3258 .off2 = td_var_offset(percentile_precision),
3259 .help = "Specify a custom list of percentiles to report for "
3260 "completion latency and block errors",
3261 .def = "1:5:10:20:30:40:50:60:70:80:90:95:99:99.5:99.9:99.95:99.99",
3262 .maxlen = FIO_IO_U_LIST_MAX_LEN,
3265 .category = FIO_OPT_C_STAT,
3266 .group = FIO_OPT_G_INVALID,
3269 #ifdef FIO_HAVE_DISK_UTIL
3271 .name = "disk_util",
3272 .lname = "Disk utilization",
3273 .type = FIO_OPT_BOOL,
3274 .off1 = td_var_offset(do_disk_util),
3275 .help = "Log disk utilization statistics",
3277 .category = FIO_OPT_C_STAT,
3278 .group = FIO_OPT_G_INVALID,
3282 .name = "gtod_reduce",
3283 .lname = "Reduce gettimeofday() calls",
3284 .type = FIO_OPT_BOOL,
3285 .help = "Greatly reduce number of gettimeofday() calls",
3286 .cb = str_gtod_reduce_cb,
3289 .category = FIO_OPT_C_STAT,
3290 .group = FIO_OPT_G_INVALID,
3293 .name = "disable_lat",
3294 .lname = "Disable all latency stats",
3295 .type = FIO_OPT_BOOL,
3296 .off1 = td_var_offset(disable_lat),
3297 .help = "Disable latency numbers",
3298 .parent = "gtod_reduce",
3301 .category = FIO_OPT_C_STAT,
3302 .group = FIO_OPT_G_INVALID,
3305 .name = "disable_clat",
3306 .lname = "Disable completion latency stats",
3307 .type = FIO_OPT_BOOL,
3308 .off1 = td_var_offset(disable_clat),
3309 .help = "Disable completion latency numbers",
3310 .parent = "gtod_reduce",
3313 .category = FIO_OPT_C_STAT,
3314 .group = FIO_OPT_G_INVALID,
3317 .name = "disable_slat",
3318 .lname = "Disable submission latency stats",
3319 .type = FIO_OPT_BOOL,
3320 .off1 = td_var_offset(disable_slat),
3321 .help = "Disable submission latency numbers",
3322 .parent = "gtod_reduce",
3325 .category = FIO_OPT_C_STAT,
3326 .group = FIO_OPT_G_INVALID,
3329 .name = "disable_bw_measurement",
3330 .lname = "Disable bandwidth stats",
3331 .type = FIO_OPT_BOOL,
3332 .off1 = td_var_offset(disable_bw),
3333 .help = "Disable bandwidth logging",
3334 .parent = "gtod_reduce",
3337 .category = FIO_OPT_C_STAT,
3338 .group = FIO_OPT_G_INVALID,
3342 .lname = "Dedicated gettimeofday() CPU",
3343 .type = FIO_OPT_INT,
3344 .off1 = td_var_offset(gtod_cpu),
3345 .help = "Set up dedicated gettimeofday() thread on this CPU",
3346 .verify = gtod_cpu_verify,
3347 .category = FIO_OPT_C_GENERAL,
3348 .group = FIO_OPT_G_CLOCK,
3351 .name = "unified_rw_reporting",
3352 .type = FIO_OPT_BOOL,
3353 .off1 = td_var_offset(unified_rw_rep),
3354 .help = "Unify reporting across data direction",
3356 .category = FIO_OPT_C_GENERAL,
3357 .group = FIO_OPT_G_INVALID,
3360 .name = "continue_on_error",
3361 .lname = "Continue on error",
3362 .type = FIO_OPT_STR,
3363 .off1 = td_var_offset(continue_on_error),
3364 .help = "Continue on non-fatal errors during IO",
3366 .category = FIO_OPT_C_GENERAL,
3367 .group = FIO_OPT_G_ERR,
3370 .oval = ERROR_TYPE_NONE,
3371 .help = "Exit when an error is encountered",
3374 .oval = ERROR_TYPE_READ,
3375 .help = "Continue on read errors only",
3378 .oval = ERROR_TYPE_WRITE,
3379 .help = "Continue on write errors only",
3382 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
3383 .help = "Continue on any IO errors",
3386 .oval = ERROR_TYPE_VERIFY,
3387 .help = "Continue on verify errors only",
3390 .oval = ERROR_TYPE_ANY,
3391 .help = "Continue on all io and verify errors",
3394 .oval = ERROR_TYPE_NONE,
3395 .help = "Alias for 'none'",
3398 .oval = ERROR_TYPE_ANY,
3399 .help = "Alias for 'all'",
3404 .name = "ignore_error",
3405 .type = FIO_OPT_STR,
3406 .cb = str_ignore_error_cb,
3407 .off1 = td_var_offset(ignore_error_nr),
3408 .help = "Set a specific list of errors to ignore",
3410 .category = FIO_OPT_C_GENERAL,
3411 .group = FIO_OPT_G_ERR,
3414 .name = "error_dump",
3415 .type = FIO_OPT_BOOL,
3416 .off1 = td_var_offset(error_dump),
3418 .help = "Dump info on each error",
3419 .category = FIO_OPT_C_GENERAL,
3420 .group = FIO_OPT_G_ERR,
3425 .type = FIO_OPT_STR_STORE,
3426 .off1 = td_var_offset(profile),
3427 .help = "Select a specific builtin performance test",
3428 .category = FIO_OPT_C_PROFILE,
3429 .group = FIO_OPT_G_INVALID,
3434 .type = FIO_OPT_STR_STORE,
3435 .off1 = td_var_offset(cgroup),
3436 .help = "Add job to cgroup of this name",
3437 .category = FIO_OPT_C_GENERAL,
3438 .group = FIO_OPT_G_CGROUP,
3441 .name = "cgroup_nodelete",
3442 .lname = "Cgroup no-delete",
3443 .type = FIO_OPT_BOOL,
3444 .off1 = td_var_offset(cgroup_nodelete),
3445 .help = "Do not delete cgroups after job completion",
3448 .category = FIO_OPT_C_GENERAL,
3449 .group = FIO_OPT_G_CGROUP,
3452 .name = "cgroup_weight",
3453 .lname = "Cgroup weight",
3454 .type = FIO_OPT_INT,
3455 .off1 = td_var_offset(cgroup_weight),
3456 .help = "Use given weight for cgroup",
3460 .category = FIO_OPT_C_GENERAL,
3461 .group = FIO_OPT_G_CGROUP,
3466 .type = FIO_OPT_INT,
3467 .off1 = td_var_offset(uid),
3468 .help = "Run job with this user ID",
3469 .category = FIO_OPT_C_GENERAL,
3470 .group = FIO_OPT_G_CRED,
3474 .lname = "Group ID",
3475 .type = FIO_OPT_INT,
3476 .off1 = td_var_offset(gid),
3477 .help = "Run job with this group ID",
3478 .category = FIO_OPT_C_GENERAL,
3479 .group = FIO_OPT_G_CRED,
3484 .type = FIO_OPT_INT,
3485 .off1 = td_var_offset(kb_base),
3491 .help = "Use 1024 as the K base",
3495 .help = "Use 1000 as the K base",
3498 .help = "How many bytes per KB for reporting (1000 or 1024)",
3499 .category = FIO_OPT_C_GENERAL,
3500 .group = FIO_OPT_G_INVALID,
3503 .name = "unit_base",
3504 .lname = "Base unit for reporting (Bits or Bytes)",
3505 .type = FIO_OPT_INT,
3506 .off1 = td_var_offset(unit_base),
3511 .help = "Auto-detect",
3515 .help = "Normal (byte based)",
3519 .help = "Bit based",
3522 .help = "Bit multiple of result summary data (8 for byte, 1 for bit)",
3523 .category = FIO_OPT_C_GENERAL,
3524 .group = FIO_OPT_G_INVALID,
3527 .name = "hugepage-size",
3528 .lname = "Hugepage size",
3529 .type = FIO_OPT_INT,
3530 .off1 = td_var_offset(hugepage_size),
3531 .help = "When using hugepages, specify size of each page",
3532 .def = __fio_stringify(FIO_HUGE_PAGE),
3533 .interval = 1024 * 1024,
3534 .category = FIO_OPT_C_GENERAL,
3535 .group = FIO_OPT_G_INVALID,
3539 .lname = "I/O flow ID",
3540 .type = FIO_OPT_INT,
3541 .off1 = td_var_offset(flow_id),
3542 .help = "The flow index ID to use",
3544 .category = FIO_OPT_C_IO,
3545 .group = FIO_OPT_G_IO_FLOW,
3549 .lname = "I/O flow weight",
3550 .type = FIO_OPT_INT,
3551 .off1 = td_var_offset(flow),
3552 .help = "Weight for flow control of this job",
3553 .parent = "flow_id",
3556 .category = FIO_OPT_C_IO,
3557 .group = FIO_OPT_G_IO_FLOW,
3560 .name = "flow_watermark",
3561 .lname = "I/O flow watermark",
3562 .type = FIO_OPT_INT,
3563 .off1 = td_var_offset(flow_watermark),
3564 .help = "High watermark for flow control. This option"
3565 " should be set to the same value for all threads"
3566 " with non-zero flow.",
3567 .parent = "flow_id",
3570 .category = FIO_OPT_C_IO,
3571 .group = FIO_OPT_G_IO_FLOW,
3574 .name = "flow_sleep",
3575 .lname = "I/O flow sleep",
3576 .type = FIO_OPT_INT,
3577 .off1 = td_var_offset(flow_sleep),
3578 .help = "How many microseconds to sleep after being held"
3579 " back by the flow control mechanism",
3580 .parent = "flow_id",
3583 .category = FIO_OPT_C_IO,
3584 .group = FIO_OPT_G_IO_FLOW,
3588 .lname = "Skip operations against bad blocks",
3589 .type = FIO_OPT_BOOL,
3590 .off1 = td_var_offset(skip_bad),
3591 .help = "Skip operations against known bad blocks.",
3594 .category = FIO_OPT_C_IO,
3595 .group = FIO_OPT_G_MTD,
3602 static void add_to_lopt(struct option *lopt, struct fio_option *o,
3603 const char *name, int val)
3605 lopt->name = (char *) name;
3607 if (o->type == FIO_OPT_STR_SET)
3608 lopt->has_arg = optional_argument;
3610 lopt->has_arg = required_argument;
3613 static void options_to_lopts(struct fio_option *opts,
3614 struct option *long_options,
3615 int i, int option_type)
3617 struct fio_option *o = &opts[0];
3619 add_to_lopt(&long_options[i], o, o->name, option_type);
3622 add_to_lopt(&long_options[i], o, o->alias, option_type);
3627 assert(i < FIO_NR_OPTIONS);
3631 void fio_options_set_ioengine_opts(struct option *long_options,
3632 struct thread_data *td)
3637 while (long_options[i].name) {
3638 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
3639 memset(&long_options[i], 0, sizeof(*long_options));
3646 * Just clear out the prior ioengine options.
3651 options_to_lopts(td->io_ops->options, long_options, i,
3652 FIO_GETOPT_IOENGINE);
3655 void fio_options_dup_and_init(struct option *long_options)
3659 options_init(fio_options);
3662 while (long_options[i].name)
3665 options_to_lopts(fio_options, long_options, i, FIO_GETOPT_JOB);
3668 struct fio_keyword {
3674 static struct fio_keyword fio_keywords[] = {
3676 .word = "$pagesize",
3677 .desc = "Page size in the system",
3680 .word = "$mb_memory",
3681 .desc = "Megabytes of memory online",
3685 .desc = "Number of CPUs online in the system",
3692 void fio_keywords_exit(void)
3694 struct fio_keyword *kw;
3696 kw = &fio_keywords[0];
3704 void fio_keywords_init(void)
3706 unsigned long long mb_memory;
3710 sprintf(buf, "%lu", (unsigned long) page_size);
3711 fio_keywords[0].replace = strdup(buf);
3713 mb_memory = os_phys_mem() / (1024 * 1024);
3714 sprintf(buf, "%llu", mb_memory);
3715 fio_keywords[1].replace = strdup(buf);
3718 sprintf(buf, "%lu", l);
3719 fio_keywords[2].replace = strdup(buf);
3724 static char *bc_calc(char *str)
3726 char buf[128], *tmp;
3731 * No math, just return string
3733 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
3734 !strchr(str, '/')) || strchr(str, '\''))
3738 * Split option from value, we only need to calculate the value
3740 tmp = strchr(str, '=');
3747 * Prevent buffer overflows; such a case isn't reasonable anyway
3749 if (strlen(str) >= 128 || strlen(tmp) > 100)
3752 sprintf(buf, "which %s > /dev/null", BC_APP);
3754 log_err("fio: bc is needed for performing math\n");
3758 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
3759 f = popen(buf, "r");
3763 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
3770 buf[(tmp - str) + ret - 1] = '\0';
3771 memcpy(buf, str, tmp - str);
3777 * Return a copy of the input string with substrings of the form ${VARNAME}
3778 * substituted with the value of the environment variable VARNAME. The
3779 * substitution always occurs, even if VARNAME is empty or the corresponding
3780 * environment variable undefined.
3782 static char *option_dup_subs(const char *opt)
3784 char out[OPT_LEN_MAX+1];
3785 char in[OPT_LEN_MAX+1];
3788 char *ch1, *ch2, *env;
3789 ssize_t nchr = OPT_LEN_MAX;
3792 if (strlen(opt) + 1 > OPT_LEN_MAX) {
3793 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
3797 in[OPT_LEN_MAX] = '\0';
3798 strncpy(in, opt, OPT_LEN_MAX);
3800 while (*inptr && nchr > 0) {
3801 if (inptr[0] == '$' && inptr[1] == '{') {
3802 ch2 = strchr(inptr, '}');
3803 if (ch2 && inptr+1 < ch2) {
3810 envlen = strlen(env);
3811 if (envlen <= nchr) {
3812 memcpy(outptr, env, envlen);
3822 *outptr++ = *inptr++;
3831 * Look for reserved variable names and replace them with real values
3833 static char *fio_keyword_replace(char *opt)
3839 for (i = 0; fio_keywords[i].word != NULL; i++) {
3840 struct fio_keyword *kw = &fio_keywords[i];
3842 while ((s = strstr(opt, kw->word)) != NULL) {
3843 char *new = malloc(strlen(opt) + 1);
3849 * Copy part of the string before the keyword and
3850 * sprintf() the replacement after it.
3852 memcpy(new, opt, olen);
3853 len = sprintf(new + olen, "%s", kw->replace);
3856 * If there's more in the original string, copy that
3859 opt += strlen(kw->word) + olen;
3861 memcpy(new + olen + len, opt, opt - o_org - 1);
3864 * replace opt and free the old opt
3874 * Check for potential math and invoke bc, if possible
3882 static char **dup_and_sub_options(char **opts, int num_opts)
3885 char **opts_copy = malloc(num_opts * sizeof(*opts));
3886 for (i = 0; i < num_opts; i++) {
3887 opts_copy[i] = option_dup_subs(opts[i]);
3890 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
3895 static void show_closest_option(const char *opt)
3897 int best_option, best_distance;
3906 while (name[i] != '\0' && name[i] != '=')
3911 best_distance = INT_MAX;
3913 while (fio_options[i].name) {
3914 distance = string_distance(name, fio_options[i].name);
3915 if (distance < best_distance) {
3916 best_distance = distance;
3922 if (best_option != -1 && string_distance_ok(name, best_distance))
3923 log_err("Did you mean %s?\n", fio_options[best_option].name);
3928 int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
3930 int i, ret, unknown;
3933 sort_options(opts, fio_options, num_opts);
3934 opts_copy = dup_and_sub_options(opts, num_opts);
3936 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
3937 struct fio_option *o;
3938 int newret = parse_option(opts_copy[i], opts[i], fio_options,
3939 &o, td, &td->opt_list);
3942 fio_option_mark_set(&td->o, o);
3950 opts_copy[i] = NULL;
3957 ret |= ioengine_load(td);
3959 sort_options(opts_copy, td->io_ops->options, num_opts);
3962 for (i = 0; i < num_opts; i++) {
3963 struct fio_option *o = NULL;
3970 newret = parse_option(opts_copy[i], opts[i],
3971 td->io_ops->options, &o,
3972 td->eo, &td->opt_list);
3976 log_err("Bad option <%s>\n", opts[i]);
3977 show_closest_option(opts[i]);
3980 opts_copy[i] = NULL;
3988 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
3992 ret = parse_cmd_option(opt, val, fio_options, td, &td->opt_list);
3994 struct fio_option *o;
3996 o = find_option(fio_options, opt);
3998 fio_option_mark_set(&td->o, o);
4004 int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
4007 return parse_cmd_option(opt, val, td->io_ops->options, td->eo,
4011 void fio_fill_default_options(struct thread_data *td)
4013 td->o.magic = OPT_MAGIC;
4014 fill_default_options(td, fio_options);
4017 int fio_show_option_help(const char *opt)
4019 return show_cmd_help(fio_options, opt);
4022 void options_mem_dupe(void *data, struct fio_option *options)
4024 struct fio_option *o;
4027 for (o = &options[0]; o->name; o++) {
4028 if (o->type != FIO_OPT_STR_STORE)
4031 ptr = td_var(data, o, o->off1);
4033 *ptr = strdup(*ptr);
4038 * dupe FIO_OPT_STR_STORE options
4040 void fio_options_mem_dupe(struct thread_data *td)
4042 options_mem_dupe(&td->o, fio_options);
4044 if (td->eo && td->io_ops) {
4045 void *oldeo = td->eo;
4047 td->eo = malloc(td->io_ops->option_struct_size);
4048 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
4049 options_mem_dupe(td->eo, td->io_ops->options);
4053 unsigned int fio_get_kb_base(void *data)
4055 struct thread_options *o = data;
4056 unsigned int kb_base = 0;
4059 * This is a hack... For private options, *data is not holding
4060 * a pointer to the thread_options, but to private data. This means
4061 * we can't safely dereference it, but magic is first so mem wise
4062 * it is valid. But this also means that if the job first sets
4063 * kb_base and expects that to be honored by private options,
4064 * it will be disappointed. We will return the global default
4067 if (o && o->magic == OPT_MAGIC)
4068 kb_base = o->kb_base;
4075 int add_option(struct fio_option *o)
4077 struct fio_option *__o;
4086 if (opt_index + 1 == FIO_MAX_OPTS) {
4087 log_err("fio: FIO_MAX_OPTS is too small\n");
4091 memcpy(&fio_options[opt_index], o, sizeof(*o));
4092 fio_options[opt_index + 1].name = NULL;
4096 void invalidate_profile_options(const char *prof_name)
4098 struct fio_option *o;
4102 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
4103 o->type = FIO_OPT_INVALID;
4104 o->prof_name = NULL;
4110 void add_opt_posval(const char *optname, const char *ival, const char *help)
4112 struct fio_option *o;
4115 o = find_option(fio_options, optname);
4119 for (i = 0; i < PARSE_MAX_VP; i++) {
4120 if (o->posval[i].ival)
4123 o->posval[i].ival = ival;
4124 o->posval[i].help = help;
4129 void del_opt_posval(const char *optname, const char *ival)
4131 struct fio_option *o;
4134 o = find_option(fio_options, optname);
4138 for (i = 0; i < PARSE_MAX_VP; i++) {
4139 if (!o->posval[i].ival)
4141 if (strcmp(o->posval[i].ival, ival))
4144 o->posval[i].ival = NULL;
4145 o->posval[i].help = NULL;
4149 void fio_options_free(struct thread_data *td)
4151 options_free(fio_options, td);
4152 if (td->eo && td->io_ops && td->io_ops->options) {
4153 options_free(td->io_ops->options, td->eo);
4159 struct fio_option *fio_option_find(const char *name)
4161 return find_option(fio_options, name);
4164 static struct fio_option *find_next_opt(struct thread_options *o,
4165 struct fio_option *from,
4168 struct fio_option *opt;
4171 from = &fio_options[0];
4177 if (off1 == from->off1) {
4182 } while (from->name);
4187 static int opt_is_set(struct thread_options *o, struct fio_option *opt)
4189 unsigned int opt_off, index, offset;
4191 opt_off = opt - &fio_options[0];
4192 index = opt_off / (8 * sizeof(uint64_t));
4193 offset = opt_off & ((8 * sizeof(uint64_t)) - 1);
4194 return (o->set_options[index] & ((uint64_t)1 << offset)) != 0;
4197 bool __fio_option_is_set(struct thread_options *o, unsigned int off1)
4199 struct fio_option *opt, *next;
4202 while ((opt = find_next_opt(o, next, off1)) != NULL) {
4203 if (opt_is_set(o, opt))
4212 void fio_option_mark_set(struct thread_options *o, struct fio_option *opt)
4214 unsigned int opt_off, index, offset;
4216 opt_off = opt - &fio_options[0];
4217 index = opt_off / (8 * sizeof(uint64_t));
4218 offset = opt_off & ((8 * sizeof(uint64_t)) - 1);
4219 o->set_options[index] |= (uint64_t)1 << offset;