11 #include <netinet/in.h>
17 #include "lib/pattern.h"
20 #include "crc/crc32c.h"
22 char client_sockaddr_str[INET6_ADDRSTRLEN] = { 0 };
24 struct pattern_fmt_desc fmt_desc[] = {
27 .len = FIELD_SIZE(struct io_u *, offset),
28 .paste = paste_blockoff
33 * Check if mmap/mmaphuge has a :/foo/bar/file at the end. If so, return that.
35 static char *get_opt_postfix(const char *str)
37 char *p = strstr(str, ":");
43 strip_blank_front(&p);
48 static int bs_cmp(const void *p1, const void *p2)
50 const struct bssplit *bsp1 = p1;
51 const struct bssplit *bsp2 = p2;
53 return bsp1->perc < bsp2->perc;
56 static int bssplit_ddir(struct thread_options *o, int ddir, char *str)
58 struct bssplit *bssplit;
59 unsigned int i, perc, perc_missing;
60 unsigned int max_bs, min_bs;
64 o->bssplit_nr[ddir] = 4;
65 bssplit = malloc(4 * sizeof(struct bssplit));
70 while ((fname = strsep(&str, ":")) != NULL) {
77 * grow struct buffer, if needed
79 if (i == o->bssplit_nr[ddir]) {
80 o->bssplit_nr[ddir] <<= 1;
81 bssplit = realloc(bssplit, o->bssplit_nr[ddir]
82 * sizeof(struct bssplit));
85 perc_str = strstr(fname, "/");
89 perc = atoi(perc_str);
97 if (str_to_decimal(fname, &val, 1, o, 0, 0)) {
98 log_err("fio: bssplit conversion failed\n");
109 bssplit[i].perc = perc;
113 o->bssplit_nr[ddir] = i;
116 * Now check if the percentages add up, and how much is missing
118 perc = perc_missing = 0;
119 for (i = 0; i < o->bssplit_nr[ddir]; i++) {
120 struct bssplit *bsp = &bssplit[i];
122 if (bsp->perc == -1U)
128 if (perc > 100 && perc_missing > 1) {
129 log_err("fio: bssplit percentages add to more than 100%%\n");
135 * If values didn't have a percentage set, divide the remains between
139 if (perc_missing == 1 && o->bssplit_nr[ddir] == 1)
141 for (i = 0; i < o->bssplit_nr[ddir]; i++) {
142 struct bssplit *bsp = &bssplit[i];
144 if (bsp->perc == -1U)
145 bsp->perc = (100 - perc) / perc_missing;
149 o->min_bs[ddir] = min_bs;
150 o->max_bs[ddir] = max_bs;
153 * now sort based on percentages, for ease of lookup
155 qsort(bssplit, o->bssplit_nr[ddir], sizeof(struct bssplit), bs_cmp);
156 o->bssplit[ddir] = bssplit;
160 static int str_bssplit_cb(void *data, const char *input)
162 struct thread_data *td = data;
163 char *str, *p, *odir, *ddir;
169 p = str = strdup(input);
171 strip_blank_front(&str);
172 strip_blank_end(str);
174 odir = strchr(str, ',');
176 ddir = strchr(odir + 1, ',');
178 ret = bssplit_ddir(&td->o, DDIR_TRIM, ddir + 1);
184 op = strdup(odir + 1);
185 ret = bssplit_ddir(&td->o, DDIR_TRIM, op);
190 ret = bssplit_ddir(&td->o, DDIR_WRITE, odir + 1);
193 ret = bssplit_ddir(&td->o, DDIR_READ, str);
199 ret = bssplit_ddir(&td->o, DDIR_WRITE, op);
204 ret = bssplit_ddir(&td->o, DDIR_TRIM, op);
207 ret = bssplit_ddir(&td->o, DDIR_READ, str);
214 static int str2error(char *str)
216 const char *err[] = { "EPERM", "ENOENT", "ESRCH", "EINTR", "EIO",
217 "ENXIO", "E2BIG", "ENOEXEC", "EBADF",
218 "ECHILD", "EAGAIN", "ENOMEM", "EACCES",
219 "EFAULT", "ENOTBLK", "EBUSY", "EEXIST",
220 "EXDEV", "ENODEV", "ENOTDIR", "EISDIR",
221 "EINVAL", "ENFILE", "EMFILE", "ENOTTY",
222 "ETXTBSY","EFBIG", "ENOSPC", "ESPIPE",
223 "EROFS","EMLINK", "EPIPE", "EDOM", "ERANGE" };
224 int i = 0, num = sizeof(err) / sizeof(void *);
227 if (!strcmp(err[i], str))
234 static int ignore_error_type(struct thread_data *td, int etype, char *str)
240 if (etype >= ERROR_TYPE_CNT) {
241 log_err("Illegal error type\n");
245 td->o.ignore_error_nr[etype] = 4;
246 error = malloc(4 * sizeof(struct bssplit));
249 while ((fname = strsep(&str, ":")) != NULL) {
255 * grow struct buffer, if needed
257 if (i == td->o.ignore_error_nr[etype]) {
258 td->o.ignore_error_nr[etype] <<= 1;
259 error = realloc(error, td->o.ignore_error_nr[etype]
262 if (fname[0] == 'E') {
263 error[i] = str2error(fname);
265 error[i] = atoi(fname);
267 error[i] = -error[i];
270 log_err("Unknown error %s, please use number value \n",
278 td->o.continue_on_error |= 1 << etype;
279 td->o.ignore_error_nr[etype] = i;
280 td->o.ignore_error[etype] = error;
288 static int str_ignore_error_cb(void *data, const char *input)
290 struct thread_data *td = data;
292 int type = 0, ret = 1;
297 p = str = strdup(input);
299 strip_blank_front(&str);
300 strip_blank_end(str);
306 ret = ignore_error_type(td, type, p);
316 static int str_rw_cb(void *data, const char *str)
318 struct thread_data *td = data;
319 struct thread_options *o = &td->o;
328 nr = get_opt_postfix(str);
333 o->ddir_seq_nr = atoi(nr);
337 if (str_to_decimal(nr, &val, 1, o, 0, 0)) {
338 log_err("fio: rw postfix parsing failed\n");
343 o->ddir_seq_add = val;
350 static int str_mem_cb(void *data, const char *mem)
352 struct thread_data *td = data;
354 if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP ||
355 td->o.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;
532 return set_cpus_allowed(td, &td->o.verify_cpumask, input);
536 #ifdef CONFIG_LIBNUMA
537 static int str_numa_cpunodes_cb(void *data, char *input)
539 struct thread_data *td = data;
540 struct bitmask *verify_bitmask;
545 /* numa_parse_nodestring() parses a character string list
546 * of nodes into a bit mask. The bit mask is allocated by
547 * numa_allocate_nodemask(), so it should be freed by
548 * numa_free_nodemask().
550 verify_bitmask = numa_parse_nodestring(input);
551 if (verify_bitmask == NULL) {
552 log_err("fio: numa_parse_nodestring failed\n");
553 td_verror(td, 1, "str_numa_cpunodes_cb");
556 numa_free_nodemask(verify_bitmask);
558 td->o.numa_cpunodes = strdup(input);
562 static int str_numa_mpol_cb(void *data, char *input)
564 struct thread_data *td = data;
565 const char * const policy_types[] =
566 { "default", "prefer", "bind", "interleave", "local", NULL };
569 struct bitmask *verify_bitmask;
574 nodelist = strchr(input, ':');
576 /* NUL-terminate mode */
580 for (i = 0; i <= MPOL_LOCAL; i++) {
581 if (!strcmp(input, policy_types[i])) {
582 td->o.numa_mem_mode = i;
586 if (i > MPOL_LOCAL) {
587 log_err("fio: memory policy should be: default, prefer, bind, interleave, local\n");
591 switch (td->o.numa_mem_mode) {
594 * Insist on a nodelist of one node only
597 char *rest = nodelist;
598 while (isdigit(*rest))
601 log_err("fio: one node only for \'prefer\'\n");
605 log_err("fio: one node is needed for \'prefer\'\n");
609 case MPOL_INTERLEAVE:
611 * Default to online nodes with memory if no nodelist
614 nodelist = strdup("all");
619 * Don't allow a nodelist
622 log_err("fio: NO nodelist for \'local\'\n");
628 * Insist on a nodelist
631 log_err("fio: a nodelist is needed for \'bind\'\n");
638 /* numa_parse_nodestring() parses a character string list
639 * of nodes into a bit mask. The bit mask is allocated by
640 * numa_allocate_nodemask(), so it should be freed by
641 * numa_free_nodemask().
643 switch (td->o.numa_mem_mode) {
645 td->o.numa_mem_prefer_node = atoi(nodelist);
647 case MPOL_INTERLEAVE:
649 verify_bitmask = numa_parse_nodestring(nodelist);
650 if (verify_bitmask == NULL) {
651 log_err("fio: numa_parse_nodestring failed\n");
652 td_verror(td, 1, "str_numa_memnodes_cb");
655 td->o.numa_memnodes = strdup(nodelist);
656 numa_free_nodemask(verify_bitmask);
671 static int str_fst_cb(void *data, const char *str)
673 struct thread_data *td = data;
674 char *nr = get_opt_postfix(str);
676 td->file_service_nr = 1;
678 td->file_service_nr = atoi(nr);
685 #ifdef CONFIG_SYNC_FILE_RANGE
686 static int str_sfr_cb(void *data, const char *str)
688 struct thread_data *td = data;
689 char *nr = get_opt_postfix(str);
691 td->sync_file_range_nr = 1;
693 td->sync_file_range_nr = atoi(nr);
701 static int str_random_distribution_cb(void *data, const char *str)
703 struct thread_data *td = data;
710 if (td->o.random_distribution == FIO_RAND_DIST_ZIPF)
712 else if (td->o.random_distribution == FIO_RAND_DIST_PARETO)
713 val = FIO_DEF_PARETO;
714 else if (td->o.random_distribution == FIO_RAND_DIST_GAUSS)
719 nr = get_opt_postfix(str);
720 if (nr && !str_to_float(nr, &val, 0)) {
721 log_err("fio: random postfix parsing failed\n");
728 if (td->o.random_distribution == FIO_RAND_DIST_ZIPF) {
730 log_err("fio: zipf theta must different than 1.0\n");
733 td->o.zipf_theta.u.f = val;
734 } else if (td->o.random_distribution == FIO_RAND_DIST_PARETO) {
735 if (val <= 0.00 || val >= 1.00) {
736 log_err("fio: pareto input out of range (0 < input < 1.0)\n");
739 td->o.pareto_h.u.f = val;
741 if (val <= 0.00 || val >= 100.0) {
742 log_err("fio: normal deviation out of range (0 < input < 100.0)\n");
745 td->o.gauss_dev.u.f = val;
752 * Return next name in the string. Files are separated with ':'. If the ':'
753 * is escaped with a '\', then that ':' is part of the filename and does not
754 * indicate a new file.
756 static char *get_next_name(char **ptr)
761 if (!str || !strlen(str))
767 * No colon, we are done
769 p = strchr(str, ':');
776 * We got a colon, but it's the first character. Skip and
784 if (*(p - 1) != '\\') {
790 memmove(p - 1, p, strlen(p) + 1);
798 static int get_max_name_idx(char *input)
800 unsigned int cur_idx;
803 p = str = strdup(input);
804 for (cur_idx = 0; ; cur_idx++)
805 if (get_next_name(&str) == NULL)
813 * Returns the directory at the index, indexes > entires will be
814 * assigned via modulo division of the index
816 int set_name_idx(char *target, size_t tlen, char *input, int index)
818 unsigned int cur_idx;
820 char *fname, *str, *p;
822 p = str = strdup(input);
824 index %= get_max_name_idx(input);
825 for (cur_idx = 0; cur_idx <= index; cur_idx++)
826 fname = get_next_name(&str);
828 if (client_sockaddr_str[0]) {
829 len = snprintf(target, tlen, "%s/%s.", fname,
830 client_sockaddr_str);
832 len = snprintf(target, tlen, "%s/", fname);
834 target[tlen - 1] = '\0';
840 static int str_filename_cb(void *data, const char *input)
842 struct thread_data *td = data;
843 char *fname, *str, *p;
845 p = str = strdup(input);
847 strip_blank_front(&str);
848 strip_blank_end(str);
850 if (!td->files_index)
853 while ((fname = get_next_name(&str)) != NULL) {
856 add_file(td, fname, 0, 1);
863 static int str_directory_cb(void *data, const char fio_unused *unused)
865 struct thread_data *td = data;
867 char *dirname, *str, *p;
873 p = str = strdup(td->o.directory);
874 while ((dirname = get_next_name(&str)) != NULL) {
875 if (lstat(dirname, &sb) < 0) {
878 log_err("fio: %s is not a directory\n", dirname);
879 td_verror(td, ret, "lstat");
882 if (!S_ISDIR(sb.st_mode)) {
883 log_err("fio: %s is not a directory\n", dirname);
894 static int str_opendir_cb(void *data, const char fio_unused *str)
896 struct thread_data *td = data;
901 if (!td->files_index)
904 return add_dir_files(td, td->o.opendir);
907 static int str_buffer_pattern_cb(void *data, const char *input)
909 struct thread_data *td = data;
912 /* FIXME: for now buffer pattern does not support formats */
913 ret = parse_and_fill_pattern(input, strlen(input), td->o.buffer_pattern,
914 MAX_PATTERN_SIZE, NULL, 0, NULL, NULL);
919 td->o.buffer_pattern_bytes = ret;
920 if (!td->o.compress_percentage)
921 td->o.refill_buffers = 0;
922 td->o.scramble_buffers = 0;
923 td->o.zero_buffers = 0;
928 static int str_buffer_compress_cb(void *data, unsigned long long *il)
930 struct thread_data *td = data;
932 td->flags |= TD_F_COMPRESS;
933 td->o.compress_percentage = *il;
937 static int str_dedupe_cb(void *data, unsigned long long *il)
939 struct thread_data *td = data;
941 td->flags |= TD_F_COMPRESS;
942 td->o.dedupe_percentage = *il;
943 td->o.refill_buffers = 1;
947 static int str_verify_pattern_cb(void *data, const char *input)
949 struct thread_data *td = data;
952 td->o.verify_fmt_sz = ARRAY_SIZE(td->o.verify_fmt);
953 ret = parse_and_fill_pattern(input, strlen(input), td->o.verify_pattern,
954 MAX_PATTERN_SIZE, fmt_desc, sizeof(fmt_desc),
955 td->o.verify_fmt, &td->o.verify_fmt_sz);
960 td->o.verify_pattern_bytes = ret;
962 * VERIFY_* could already be set
964 if (!fio_option_is_set(&td->o, verify))
965 td->o.verify = VERIFY_PATTERN;
970 static int str_gtod_reduce_cb(void *data, int *il)
972 struct thread_data *td = data;
975 td->o.disable_lat = !!val;
976 td->o.disable_clat = !!val;
977 td->o.disable_slat = !!val;
978 td->o.disable_bw = !!val;
979 td->o.clat_percentiles = !val;
981 td->tv_cache_mask = 63;
986 static int str_size_cb(void *data, unsigned long long *__val)
988 struct thread_data *td = data;
989 unsigned long long v = *__val;
991 if (parse_is_percent(v)) {
993 td->o.size_percent = -1ULL - v;
1000 static int rw_verify(struct fio_option *o, void *data)
1002 struct thread_data *td = data;
1004 if (read_only && td_write(td)) {
1005 log_err("fio: job <%s> has write bit set, but fio is in"
1006 " read-only mode\n", td->o.name);
1013 static int gtod_cpu_verify(struct fio_option *o, void *data)
1015 #ifndef FIO_HAVE_CPU_AFFINITY
1016 struct thread_data *td = data;
1018 if (td->o.gtod_cpu) {
1019 log_err("fio: platform must support CPU affinity for"
1020 "gettimeofday() offloading\n");
1031 static struct opt_group fio_opt_groups[] = {
1034 .mask = FIO_OPT_C_GENERAL,
1038 .mask = FIO_OPT_C_IO,
1042 .mask = FIO_OPT_C_FILE,
1045 .name = "Statistics",
1046 .mask = FIO_OPT_C_STAT,
1050 .mask = FIO_OPT_C_LOG,
1054 .mask = FIO_OPT_C_PROFILE,
1061 static struct opt_group *__opt_group_from_mask(struct opt_group *ogs, unsigned int *mask,
1062 unsigned int inv_mask)
1064 struct opt_group *og;
1067 if (*mask == inv_mask || !*mask)
1070 for (i = 0; ogs[i].name; i++) {
1073 if (*mask & og->mask) {
1074 *mask &= ~(og->mask);
1082 struct opt_group *opt_group_from_mask(unsigned int *mask)
1084 return __opt_group_from_mask(fio_opt_groups, mask, FIO_OPT_C_INVALID);
1087 static struct opt_group fio_opt_cat_groups[] = {
1089 .name = "Latency profiling",
1090 .mask = FIO_OPT_G_LATPROF,
1094 .mask = FIO_OPT_G_RATE,
1098 .mask = FIO_OPT_G_ZONE,
1101 .name = "Read/write mix",
1102 .mask = FIO_OPT_G_RWMIX,
1106 .mask = FIO_OPT_G_VERIFY,
1110 .mask = FIO_OPT_G_TRIM,
1113 .name = "I/O Logging",
1114 .mask = FIO_OPT_G_IOLOG,
1117 .name = "I/O Depth",
1118 .mask = FIO_OPT_G_IO_DEPTH,
1122 .mask = FIO_OPT_G_IO_FLOW,
1125 .name = "Description",
1126 .mask = FIO_OPT_G_DESC,
1130 .mask = FIO_OPT_G_FILENAME,
1133 .name = "General I/O",
1134 .mask = FIO_OPT_G_IO_BASIC,
1138 .mask = FIO_OPT_G_CGROUP,
1142 .mask = FIO_OPT_G_RUNTIME,
1146 .mask = FIO_OPT_G_PROCESS,
1149 .name = "Job credentials / priority",
1150 .mask = FIO_OPT_G_CRED,
1153 .name = "Clock settings",
1154 .mask = FIO_OPT_G_CLOCK,
1158 .mask = FIO_OPT_G_IO_TYPE,
1161 .name = "I/O Thinktime",
1162 .mask = FIO_OPT_G_THINKTIME,
1165 .name = "Randomizations",
1166 .mask = FIO_OPT_G_RANDOM,
1169 .name = "I/O buffers",
1170 .mask = FIO_OPT_G_IO_BUF,
1173 .name = "Tiobench profile",
1174 .mask = FIO_OPT_G_TIOBENCH,
1178 .mask = FIO_OPT_G_MTD,
1186 struct opt_group *opt_group_cat_from_mask(unsigned int *mask)
1188 return __opt_group_from_mask(fio_opt_cat_groups, mask, FIO_OPT_G_INVALID);
1192 * Map of job/command line options
1194 struct fio_option fio_options[FIO_MAX_OPTS] = {
1196 .name = "description",
1197 .lname = "Description of job",
1198 .type = FIO_OPT_STR_STORE,
1199 .off1 = td_var_offset(description),
1200 .help = "Text job description",
1201 .category = FIO_OPT_C_GENERAL,
1202 .group = FIO_OPT_G_DESC,
1206 .lname = "Job name",
1207 .type = FIO_OPT_STR_STORE,
1208 .off1 = td_var_offset(name),
1209 .help = "Name of this job",
1210 .category = FIO_OPT_C_GENERAL,
1211 .group = FIO_OPT_G_DESC,
1215 .lname = "Filename(s)",
1216 .type = FIO_OPT_STR_STORE,
1217 .off1 = td_var_offset(filename),
1218 .cb = str_filename_cb,
1219 .prio = -1, /* must come after "directory" */
1220 .help = "File(s) to use for the workload",
1221 .category = FIO_OPT_C_FILE,
1222 .group = FIO_OPT_G_FILENAME,
1225 .name = "directory",
1226 .lname = "Directory",
1227 .type = FIO_OPT_STR_STORE,
1228 .off1 = td_var_offset(directory),
1229 .cb = str_directory_cb,
1230 .help = "Directory to store files in",
1231 .category = FIO_OPT_C_FILE,
1232 .group = FIO_OPT_G_FILENAME,
1235 .name = "filename_format",
1236 .type = FIO_OPT_STR_STORE,
1237 .off1 = td_var_offset(filename_format),
1238 .prio = -1, /* must come after "directory" */
1239 .help = "Override default $jobname.$jobnum.$filenum naming",
1240 .def = "$jobname.$jobnum.$filenum",
1241 .category = FIO_OPT_C_FILE,
1242 .group = FIO_OPT_G_FILENAME,
1246 .lname = "Lockfile",
1247 .type = FIO_OPT_STR,
1248 .off1 = td_var_offset(file_lock_mode),
1249 .help = "Lock file when doing IO to it",
1251 .parent = "filename",
1254 .category = FIO_OPT_C_FILE,
1255 .group = FIO_OPT_G_FILENAME,
1258 .oval = FILE_LOCK_NONE,
1259 .help = "No file locking",
1261 { .ival = "exclusive",
1262 .oval = FILE_LOCK_EXCLUSIVE,
1263 .help = "Exclusive file lock",
1266 .ival = "readwrite",
1267 .oval = FILE_LOCK_READWRITE,
1268 .help = "Read vs write lock",
1274 .lname = "Open directory",
1275 .type = FIO_OPT_STR_STORE,
1276 .off1 = td_var_offset(opendir),
1277 .cb = str_opendir_cb,
1278 .help = "Recursively add files from this directory and down",
1279 .category = FIO_OPT_C_FILE,
1280 .group = FIO_OPT_G_FILENAME,
1284 .lname = "Read/write",
1285 .alias = "readwrite",
1286 .type = FIO_OPT_STR,
1288 .off1 = td_var_offset(td_ddir),
1289 .help = "IO direction",
1291 .verify = rw_verify,
1292 .category = FIO_OPT_C_IO,
1293 .group = FIO_OPT_G_IO_BASIC,
1296 .oval = TD_DDIR_READ,
1297 .help = "Sequential read",
1300 .oval = TD_DDIR_WRITE,
1301 .help = "Sequential write",
1304 .oval = TD_DDIR_TRIM,
1305 .help = "Sequential trim",
1307 { .ival = "randread",
1308 .oval = TD_DDIR_RANDREAD,
1309 .help = "Random read",
1311 { .ival = "randwrite",
1312 .oval = TD_DDIR_RANDWRITE,
1313 .help = "Random write",
1315 { .ival = "randtrim",
1316 .oval = TD_DDIR_RANDTRIM,
1317 .help = "Random trim",
1321 .help = "Sequential read and write mix",
1323 { .ival = "readwrite",
1325 .help = "Sequential read and write mix",
1328 .oval = TD_DDIR_RANDRW,
1329 .help = "Random read and write mix"
1331 { .ival = "trimwrite",
1332 .oval = TD_DDIR_TRIMWRITE,
1333 .help = "Trim and write mix, trims preceding writes"
1338 .name = "rw_sequencer",
1339 .lname = "RW Sequencer",
1340 .type = FIO_OPT_STR,
1341 .off1 = td_var_offset(rw_seq),
1342 .help = "IO offset generator modifier",
1343 .def = "sequential",
1344 .category = FIO_OPT_C_IO,
1345 .group = FIO_OPT_G_IO_BASIC,
1347 { .ival = "sequential",
1349 .help = "Generate sequential offsets",
1351 { .ival = "identical",
1352 .oval = RW_SEQ_IDENT,
1353 .help = "Generate identical offsets",
1360 .lname = "IO Engine",
1361 .type = FIO_OPT_STR_STORE,
1362 .off1 = td_var_offset(ioengine),
1363 .help = "IO engine to use",
1364 .def = FIO_PREFERRED_ENGINE,
1365 .category = FIO_OPT_C_IO,
1366 .group = FIO_OPT_G_IO_BASIC,
1369 .help = "Use read/write",
1372 .help = "Use pread/pwrite",
1375 .help = "Use readv/writev",
1377 #ifdef CONFIG_PWRITEV
1379 .help = "Use preadv/pwritev",
1382 #ifdef CONFIG_LIBAIO
1384 .help = "Linux native asynchronous IO",
1387 #ifdef CONFIG_POSIXAIO
1388 { .ival = "posixaio",
1389 .help = "POSIX asynchronous IO",
1392 #ifdef CONFIG_SOLARISAIO
1393 { .ival = "solarisaio",
1394 .help = "Solaris native asynchronous IO",
1397 #ifdef CONFIG_WINDOWSAIO
1398 { .ival = "windowsaio",
1399 .help = "Windows native asynchronous IO"
1404 .help = "Rados Block Device asynchronous IO"
1408 .help = "Memory mapped IO"
1410 #ifdef CONFIG_LINUX_SPLICE
1412 .help = "splice/vmsplice based IO",
1414 { .ival = "netsplice",
1415 .help = "splice/vmsplice to/from the network",
1418 #ifdef FIO_HAVE_SGIO
1420 .help = "SCSI generic v3 IO",
1424 .help = "Testing engine (no data transfer)",
1427 .help = "Network IO",
1430 .help = "CPU cycle burner engine",
1434 .help = "GUASI IO engine",
1437 #ifdef FIO_HAVE_BINJECT
1438 { .ival = "binject",
1439 .help = "binject direct inject block engine",
1444 .help = "RDMA IO engine",
1447 #ifdef CONFIG_FUSION_AW
1448 { .ival = "fusion-aw-sync",
1449 .help = "Fusion-io atomic write engine",
1452 #ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
1453 { .ival = "e4defrag",
1454 .help = "ext4 defrag engine",
1457 #ifdef CONFIG_LINUX_FALLOCATE
1459 .help = "fallocate() file based engine",
1464 .help = "Glusterfs libgfapi(sync) based engine"
1466 { .ival = "gfapi_async",
1467 .help = "Glusterfs libgfapi(async) based engine"
1470 #ifdef CONFIG_LIBHDFS
1471 { .ival = "libhdfs",
1472 .help = "Hadoop Distributed Filesystem (HDFS) engine"
1475 { .ival = "external",
1476 .help = "Load external engine (append name)",
1482 .lname = "IO Depth",
1483 .type = FIO_OPT_INT,
1484 .off1 = td_var_offset(iodepth),
1485 .help = "Number of IO buffers to keep in flight",
1489 .category = FIO_OPT_C_IO,
1490 .group = FIO_OPT_G_IO_BASIC,
1493 .name = "iodepth_batch",
1494 .lname = "IO Depth batch",
1495 .alias = "iodepth_batch_submit",
1496 .type = FIO_OPT_INT,
1497 .off1 = td_var_offset(iodepth_batch),
1498 .help = "Number of IO buffers to submit in one go",
1499 .parent = "iodepth",
1504 .category = FIO_OPT_C_IO,
1505 .group = FIO_OPT_G_IO_BASIC,
1508 .name = "iodepth_batch_complete_min",
1509 .lname = "Min IO depth batch complete",
1510 .alias = "iodepth_batch_complete",
1511 .type = FIO_OPT_INT,
1512 .off1 = td_var_offset(iodepth_batch_complete_min),
1513 .help = "Min number of IO buffers to retrieve in one go",
1514 .parent = "iodepth",
1519 .category = FIO_OPT_C_IO,
1520 .group = FIO_OPT_G_IO_BASIC,
1523 .name = "iodepth_batch_complete_max",
1524 .lname = "Max IO depth batch complete",
1525 .type = FIO_OPT_INT,
1526 .off1 = td_var_offset(iodepth_batch_complete_max),
1527 .help = "Max number of IO buffers to retrieve in one go",
1528 .parent = "iodepth",
1532 .category = FIO_OPT_C_IO,
1533 .group = FIO_OPT_G_IO_BASIC,
1536 .name = "iodepth_low",
1537 .lname = "IO Depth batch low",
1538 .type = FIO_OPT_INT,
1539 .off1 = td_var_offset(iodepth_low),
1540 .help = "Low water mark for queuing depth",
1541 .parent = "iodepth",
1544 .category = FIO_OPT_C_IO,
1545 .group = FIO_OPT_G_IO_BASIC,
1548 .name = "io_submit_mode",
1549 .lname = "IO submit mode",
1550 .type = FIO_OPT_STR,
1551 .off1 = td_var_offset(io_submit_mode),
1552 .help = "How IO submissions and completions are done",
1554 .category = FIO_OPT_C_IO,
1555 .group = FIO_OPT_G_IO_BASIC,
1558 .oval = IO_MODE_INLINE,
1559 .help = "Submit and complete IO inline",
1561 { .ival = "offload",
1562 .oval = IO_MODE_OFFLOAD,
1563 .help = "Offload submit and complete to threads",
1570 .type = FIO_OPT_STR_VAL,
1572 .off1 = td_var_offset(size),
1573 .help = "Total size of device or files",
1574 .interval = 1024 * 1024,
1575 .category = FIO_OPT_C_IO,
1576 .group = FIO_OPT_G_INVALID,
1580 .alias = "io_limit",
1582 .type = FIO_OPT_STR_VAL,
1583 .off1 = td_var_offset(io_limit),
1584 .interval = 1024 * 1024,
1585 .category = FIO_OPT_C_IO,
1586 .group = FIO_OPT_G_INVALID,
1589 .name = "fill_device",
1590 .lname = "Fill device",
1592 .type = FIO_OPT_BOOL,
1593 .off1 = td_var_offset(fill_device),
1594 .help = "Write until an ENOSPC error occurs",
1596 .category = FIO_OPT_C_FILE,
1597 .group = FIO_OPT_G_INVALID,
1601 .lname = "File size",
1602 .type = FIO_OPT_STR_VAL,
1603 .off1 = td_var_offset(file_size_low),
1604 .off2 = td_var_offset(file_size_high),
1606 .help = "Size of individual files",
1607 .interval = 1024 * 1024,
1608 .category = FIO_OPT_C_FILE,
1609 .group = FIO_OPT_G_INVALID,
1612 .name = "file_append",
1613 .lname = "File append",
1614 .type = FIO_OPT_BOOL,
1615 .off1 = td_var_offset(file_append),
1616 .help = "IO will start at the end of the file(s)",
1618 .category = FIO_OPT_C_FILE,
1619 .group = FIO_OPT_G_INVALID,
1623 .lname = "IO offset",
1624 .alias = "fileoffset",
1625 .type = FIO_OPT_STR_VAL,
1626 .off1 = td_var_offset(start_offset),
1627 .help = "Start IO from this offset",
1629 .interval = 1024 * 1024,
1630 .category = FIO_OPT_C_IO,
1631 .group = FIO_OPT_G_INVALID,
1634 .name = "offset_increment",
1635 .lname = "IO offset increment",
1636 .type = FIO_OPT_STR_VAL,
1637 .off1 = td_var_offset(offset_increment),
1638 .help = "What is the increment from one offset to the next",
1642 .interval = 1024 * 1024,
1643 .category = FIO_OPT_C_IO,
1644 .group = FIO_OPT_G_INVALID,
1647 .name = "number_ios",
1648 .lname = "Number of IOs to perform",
1649 .type = FIO_OPT_STR_VAL,
1650 .off1 = td_var_offset(number_ios),
1651 .help = "Force job completion after this number of IOs",
1653 .category = FIO_OPT_C_IO,
1654 .group = FIO_OPT_G_INVALID,
1658 .lname = "Block size",
1659 .alias = "blocksize",
1660 .type = FIO_OPT_INT,
1661 .off1 = td_var_offset(bs[DDIR_READ]),
1662 .off2 = td_var_offset(bs[DDIR_WRITE]),
1663 .off3 = td_var_offset(bs[DDIR_TRIM]),
1665 .help = "Block size unit",
1670 .category = FIO_OPT_C_IO,
1671 .group = FIO_OPT_G_INVALID,
1675 .lname = "Block size align",
1676 .alias = "blockalign",
1677 .type = FIO_OPT_INT,
1678 .off1 = td_var_offset(ba[DDIR_READ]),
1679 .off2 = td_var_offset(ba[DDIR_WRITE]),
1680 .off3 = td_var_offset(ba[DDIR_TRIM]),
1682 .help = "IO block offset alignment",
1686 .category = FIO_OPT_C_IO,
1687 .group = FIO_OPT_G_INVALID,
1691 .lname = "Block size range",
1692 .alias = "blocksize_range",
1693 .type = FIO_OPT_RANGE,
1694 .off1 = td_var_offset(min_bs[DDIR_READ]),
1695 .off2 = td_var_offset(max_bs[DDIR_READ]),
1696 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
1697 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
1698 .off5 = td_var_offset(min_bs[DDIR_TRIM]),
1699 .off6 = td_var_offset(max_bs[DDIR_TRIM]),
1701 .help = "Set block size range (in more detail than bs)",
1705 .category = FIO_OPT_C_IO,
1706 .group = FIO_OPT_G_INVALID,
1710 .lname = "Block size split",
1711 .type = FIO_OPT_STR,
1712 .cb = str_bssplit_cb,
1713 .off1 = td_var_offset(bssplit),
1714 .help = "Set a specific mix of block sizes",
1717 .category = FIO_OPT_C_IO,
1718 .group = FIO_OPT_G_INVALID,
1721 .name = "bs_unaligned",
1722 .lname = "Block size unaligned",
1723 .alias = "blocksize_unaligned",
1724 .type = FIO_OPT_STR_SET,
1725 .off1 = td_var_offset(bs_unaligned),
1726 .help = "Don't sector align IO buffer sizes",
1729 .category = FIO_OPT_C_IO,
1730 .group = FIO_OPT_G_INVALID,
1733 .name = "bs_is_seq_rand",
1734 .lname = "Block size division is seq/random (not read/write)",
1735 .type = FIO_OPT_BOOL,
1736 .off1 = td_var_offset(bs_is_seq_rand),
1737 .help = "Consider any blocksize setting to be sequential,random",
1739 .parent = "blocksize",
1740 .category = FIO_OPT_C_IO,
1741 .group = FIO_OPT_G_INVALID,
1744 .name = "randrepeat",
1745 .lname = "Random repeatable",
1746 .type = FIO_OPT_BOOL,
1747 .off1 = td_var_offset(rand_repeatable),
1748 .help = "Use repeatable random IO pattern",
1752 .category = FIO_OPT_C_IO,
1753 .group = FIO_OPT_G_RANDOM,
1757 .lname = "The random generator seed",
1758 .type = FIO_OPT_STR_VAL,
1759 .off1 = td_var_offset(rand_seed),
1760 .help = "Set the random generator seed value",
1763 .category = FIO_OPT_C_IO,
1764 .group = FIO_OPT_G_RANDOM,
1767 .name = "use_os_rand",
1768 .lname = "Use OS random",
1769 .type = FIO_OPT_DEPRECATED,
1770 .off1 = td_var_offset(dep_use_os_rand),
1771 .category = FIO_OPT_C_IO,
1772 .group = FIO_OPT_G_RANDOM,
1775 .name = "norandommap",
1776 .lname = "No randommap",
1777 .type = FIO_OPT_STR_SET,
1778 .off1 = td_var_offset(norandommap),
1779 .help = "Accept potential duplicate random blocks",
1783 .category = FIO_OPT_C_IO,
1784 .group = FIO_OPT_G_RANDOM,
1787 .name = "softrandommap",
1788 .lname = "Soft randommap",
1789 .type = FIO_OPT_BOOL,
1790 .off1 = td_var_offset(softrandommap),
1791 .help = "Set norandommap if randommap allocation fails",
1792 .parent = "norandommap",
1795 .category = FIO_OPT_C_IO,
1796 .group = FIO_OPT_G_RANDOM,
1799 .name = "random_generator",
1800 .type = FIO_OPT_STR,
1801 .off1 = td_var_offset(random_generator),
1802 .help = "Type of random number generator to use",
1803 .def = "tausworthe",
1805 { .ival = "tausworthe",
1806 .oval = FIO_RAND_GEN_TAUSWORTHE,
1807 .help = "Strong Tausworthe generator",
1810 .oval = FIO_RAND_GEN_LFSR,
1811 .help = "Variable length LFSR",
1814 .ival = "tausworthe64",
1815 .oval = FIO_RAND_GEN_TAUSWORTHE64,
1816 .help = "64-bit Tausworthe variant",
1819 .category = FIO_OPT_C_IO,
1820 .group = FIO_OPT_G_RANDOM,
1823 .name = "random_distribution",
1824 .type = FIO_OPT_STR,
1825 .off1 = td_var_offset(random_distribution),
1826 .cb = str_random_distribution_cb,
1827 .help = "Random offset distribution generator",
1831 .oval = FIO_RAND_DIST_RANDOM,
1832 .help = "Completely random",
1835 .oval = FIO_RAND_DIST_ZIPF,
1836 .help = "Zipf distribution",
1839 .oval = FIO_RAND_DIST_PARETO,
1840 .help = "Pareto distribution",
1843 .oval = FIO_RAND_DIST_GAUSS,
1844 .help = "Normal (gaussian) distribution",
1847 .category = FIO_OPT_C_IO,
1848 .group = FIO_OPT_G_RANDOM,
1851 .name = "percentage_random",
1852 .lname = "Percentage Random",
1853 .type = FIO_OPT_INT,
1854 .off1 = td_var_offset(perc_rand[DDIR_READ]),
1855 .off2 = td_var_offset(perc_rand[DDIR_WRITE]),
1856 .off3 = td_var_offset(perc_rand[DDIR_TRIM]),
1858 .help = "Percentage of seq/random mix that should be random",
1859 .def = "100,100,100",
1861 .inverse = "percentage_sequential",
1862 .category = FIO_OPT_C_IO,
1863 .group = FIO_OPT_G_RANDOM,
1866 .name = "percentage_sequential",
1867 .lname = "Percentage Sequential",
1868 .type = FIO_OPT_DEPRECATED,
1869 .category = FIO_OPT_C_IO,
1870 .group = FIO_OPT_G_RANDOM,
1873 .name = "allrandrepeat",
1874 .type = FIO_OPT_BOOL,
1875 .off1 = td_var_offset(allrand_repeatable),
1876 .help = "Use repeatable random numbers for everything",
1878 .category = FIO_OPT_C_IO,
1879 .group = FIO_OPT_G_RANDOM,
1883 .lname = "Number of files",
1884 .alias = "nr_files",
1885 .type = FIO_OPT_INT,
1886 .off1 = td_var_offset(nr_files),
1887 .help = "Split job workload between this number of files",
1890 .category = FIO_OPT_C_FILE,
1891 .group = FIO_OPT_G_INVALID,
1894 .name = "openfiles",
1895 .lname = "Number of open files",
1896 .type = FIO_OPT_INT,
1897 .off1 = td_var_offset(open_files),
1898 .help = "Number of files to keep open at the same time",
1899 .category = FIO_OPT_C_FILE,
1900 .group = FIO_OPT_G_INVALID,
1903 .name = "file_service_type",
1904 .lname = "File service type",
1905 .type = FIO_OPT_STR,
1907 .off1 = td_var_offset(file_service_type),
1908 .help = "How to select which file to service next",
1909 .def = "roundrobin",
1910 .category = FIO_OPT_C_FILE,
1911 .group = FIO_OPT_G_INVALID,
1914 .oval = FIO_FSERVICE_RANDOM,
1915 .help = "Choose a file at random",
1917 { .ival = "roundrobin",
1918 .oval = FIO_FSERVICE_RR,
1919 .help = "Round robin select files",
1921 { .ival = "sequential",
1922 .oval = FIO_FSERVICE_SEQ,
1923 .help = "Finish one file before moving to the next",
1926 .parent = "nrfiles",
1929 #ifdef CONFIG_POSIX_FALLOCATE
1931 .name = "fallocate",
1932 .lname = "Fallocate",
1933 .type = FIO_OPT_STR,
1934 .off1 = td_var_offset(fallocate_mode),
1935 .help = "Whether pre-allocation is performed when laying out files",
1937 .category = FIO_OPT_C_FILE,
1938 .group = FIO_OPT_G_INVALID,
1941 .oval = FIO_FALLOCATE_NONE,
1942 .help = "Do not pre-allocate space",
1945 .oval = FIO_FALLOCATE_POSIX,
1946 .help = "Use posix_fallocate()",
1948 #ifdef CONFIG_LINUX_FALLOCATE
1950 .oval = FIO_FALLOCATE_KEEP_SIZE,
1951 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
1954 /* Compatibility with former boolean values */
1956 .oval = FIO_FALLOCATE_NONE,
1957 .help = "Alias for 'none'",
1960 .oval = FIO_FALLOCATE_POSIX,
1961 .help = "Alias for 'posix'",
1965 #endif /* CONFIG_POSIX_FALLOCATE */
1967 .name = "fadvise_hint",
1968 .lname = "Fadvise hint",
1969 .type = FIO_OPT_BOOL,
1970 .off1 = td_var_offset(fadvise_hint),
1971 .help = "Use fadvise() to advise the kernel on IO pattern",
1973 .category = FIO_OPT_C_FILE,
1974 .group = FIO_OPT_G_INVALID,
1976 #ifdef FIO_HAVE_STREAMID
1978 .name = "fadvise_stream",
1979 .lname = "Fadvise stream",
1980 .type = FIO_OPT_INT,
1981 .off1 = td_var_offset(fadvise_stream),
1982 .help = "Use fadvise() to set stream ID",
1983 .category = FIO_OPT_C_FILE,
1984 .group = FIO_OPT_G_INVALID,
1990 .type = FIO_OPT_INT,
1991 .off1 = td_var_offset(fsync_blocks),
1992 .help = "Issue fsync for writes every given number of blocks",
1995 .category = FIO_OPT_C_FILE,
1996 .group = FIO_OPT_G_INVALID,
1999 .name = "fdatasync",
2000 .lname = "Fdatasync",
2001 .type = FIO_OPT_INT,
2002 .off1 = td_var_offset(fdatasync_blocks),
2003 .help = "Issue fdatasync for writes every given number of blocks",
2006 .category = FIO_OPT_C_FILE,
2007 .group = FIO_OPT_G_INVALID,
2010 .name = "write_barrier",
2011 .lname = "Write barrier",
2012 .type = FIO_OPT_INT,
2013 .off1 = td_var_offset(barrier_blocks),
2014 .help = "Make every Nth write a barrier write",
2017 .category = FIO_OPT_C_IO,
2018 .group = FIO_OPT_G_INVALID,
2020 #ifdef CONFIG_SYNC_FILE_RANGE
2022 .name = "sync_file_range",
2023 .lname = "Sync file range",
2025 { .ival = "wait_before",
2026 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
2027 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
2031 .oval = SYNC_FILE_RANGE_WRITE,
2032 .help = "SYNC_FILE_RANGE_WRITE",
2036 .ival = "wait_after",
2037 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
2038 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
2042 .type = FIO_OPT_STR_MULTI,
2044 .off1 = td_var_offset(sync_file_range),
2045 .help = "Use sync_file_range()",
2046 .category = FIO_OPT_C_FILE,
2047 .group = FIO_OPT_G_INVALID,
2052 .lname = "Direct I/O",
2053 .type = FIO_OPT_BOOL,
2054 .off1 = td_var_offset(odirect),
2055 .help = "Use O_DIRECT IO (negates buffered)",
2057 .inverse = "buffered",
2058 .category = FIO_OPT_C_IO,
2059 .group = FIO_OPT_G_IO_TYPE,
2063 .lname = "Atomic I/O",
2064 .type = FIO_OPT_BOOL,
2065 .off1 = td_var_offset(oatomic),
2066 .help = "Use Atomic IO with O_DIRECT (implies O_DIRECT)",
2068 .category = FIO_OPT_C_IO,
2069 .group = FIO_OPT_G_IO_TYPE,
2073 .lname = "Buffered I/O",
2074 .type = FIO_OPT_BOOL,
2075 .off1 = td_var_offset(odirect),
2077 .help = "Use buffered IO (negates direct)",
2079 .inverse = "direct",
2080 .category = FIO_OPT_C_IO,
2081 .group = FIO_OPT_G_IO_TYPE,
2084 .name = "overwrite",
2085 .lname = "Overwrite",
2086 .type = FIO_OPT_BOOL,
2087 .off1 = td_var_offset(overwrite),
2088 .help = "When writing, set whether to overwrite current data",
2090 .category = FIO_OPT_C_FILE,
2091 .group = FIO_OPT_G_INVALID,
2096 .type = FIO_OPT_INT,
2097 .off1 = td_var_offset(loops),
2098 .help = "Number of times to run the job",
2101 .category = FIO_OPT_C_GENERAL,
2102 .group = FIO_OPT_G_RUNTIME,
2106 .lname = "Number of jobs",
2107 .type = FIO_OPT_INT,
2108 .off1 = td_var_offset(numjobs),
2109 .help = "Duplicate this job this many times",
2112 .category = FIO_OPT_C_GENERAL,
2113 .group = FIO_OPT_G_RUNTIME,
2116 .name = "startdelay",
2117 .lname = "Start delay",
2118 .type = FIO_OPT_STR_VAL_TIME,
2119 .off1 = td_var_offset(start_delay),
2120 .off2 = td_var_offset(start_delay_high),
2121 .help = "Only start job when this period has passed",
2125 .category = FIO_OPT_C_GENERAL,
2126 .group = FIO_OPT_G_RUNTIME,
2132 .type = FIO_OPT_STR_VAL_TIME,
2133 .off1 = td_var_offset(timeout),
2134 .help = "Stop workload when this amount of time has passed",
2138 .category = FIO_OPT_C_GENERAL,
2139 .group = FIO_OPT_G_RUNTIME,
2142 .name = "time_based",
2143 .lname = "Time based",
2144 .type = FIO_OPT_STR_SET,
2145 .off1 = td_var_offset(time_based),
2146 .help = "Keep running until runtime/timeout is met",
2147 .category = FIO_OPT_C_GENERAL,
2148 .group = FIO_OPT_G_RUNTIME,
2151 .name = "verify_only",
2152 .lname = "Verify only",
2153 .type = FIO_OPT_STR_SET,
2154 .off1 = td_var_offset(verify_only),
2155 .help = "Verifies previously written data is still valid",
2156 .category = FIO_OPT_C_GENERAL,
2157 .group = FIO_OPT_G_RUNTIME,
2160 .name = "ramp_time",
2161 .lname = "Ramp time",
2162 .type = FIO_OPT_STR_VAL_TIME,
2163 .off1 = td_var_offset(ramp_time),
2164 .help = "Ramp up time before measuring performance",
2167 .category = FIO_OPT_C_GENERAL,
2168 .group = FIO_OPT_G_RUNTIME,
2171 .name = "clocksource",
2172 .lname = "Clock source",
2173 .type = FIO_OPT_STR,
2174 .cb = fio_clock_source_cb,
2175 .off1 = td_var_offset(clocksource),
2176 .help = "What type of timing source to use",
2177 .category = FIO_OPT_C_GENERAL,
2178 .group = FIO_OPT_G_CLOCK,
2180 #ifdef CONFIG_GETTIMEOFDAY
2181 { .ival = "gettimeofday",
2183 .help = "Use gettimeofday(2) for timing",
2186 #ifdef CONFIG_CLOCK_GETTIME
2187 { .ival = "clock_gettime",
2188 .oval = CS_CGETTIME,
2189 .help = "Use clock_gettime(2) for timing",
2192 #ifdef ARCH_HAVE_CPU_CLOCK
2194 .oval = CS_CPUCLOCK,
2195 .help = "Use CPU private clock",
2203 .lname = "I/O Memory",
2204 .type = FIO_OPT_STR,
2206 .off1 = td_var_offset(mem_type),
2207 .help = "Backing type for IO buffers",
2209 .category = FIO_OPT_C_IO,
2210 .group = FIO_OPT_G_INVALID,
2214 .help = "Use malloc(3) for IO buffers",
2216 #ifndef CONFIG_NO_SHM
2219 .help = "Use shared memory segments for IO buffers",
2221 #ifdef FIO_HAVE_HUGETLB
2222 { .ival = "shmhuge",
2223 .oval = MEM_SHMHUGE,
2224 .help = "Like shm, but use huge pages",
2230 .help = "Use mmap(2) (file or anon) for IO buffers",
2232 { .ival = "mmapshared",
2233 .oval = MEM_MMAPSHARED,
2234 .help = "Like mmap, but use the shared flag",
2236 #ifdef FIO_HAVE_HUGETLB
2237 { .ival = "mmaphuge",
2238 .oval = MEM_MMAPHUGE,
2239 .help = "Like mmap, but use huge pages",
2245 .name = "iomem_align",
2246 .alias = "mem_align",
2247 .lname = "I/O memory alignment",
2248 .type = FIO_OPT_INT,
2249 .off1 = td_var_offset(mem_align),
2251 .help = "IO memory buffer offset alignment",
2255 .category = FIO_OPT_C_IO,
2256 .group = FIO_OPT_G_INVALID,
2261 .type = FIO_OPT_STR,
2262 .off1 = td_var_offset(verify),
2263 .help = "Verify data written",
2265 .category = FIO_OPT_C_IO,
2266 .group = FIO_OPT_G_VERIFY,
2269 .oval = VERIFY_NONE,
2270 .help = "Don't do IO verification",
2274 .help = "Use md5 checksums for verification",
2277 .oval = VERIFY_CRC64,
2278 .help = "Use crc64 checksums for verification",
2281 .oval = VERIFY_CRC32,
2282 .help = "Use crc32 checksums for verification",
2284 { .ival = "crc32c-intel",
2285 .oval = VERIFY_CRC32C,
2286 .help = "Use crc32c checksums for verification (hw assisted, if available)",
2289 .oval = VERIFY_CRC32C,
2290 .help = "Use crc32c checksums for verification (hw assisted, if available)",
2293 .oval = VERIFY_CRC16,
2294 .help = "Use crc16 checksums for verification",
2297 .oval = VERIFY_CRC7,
2298 .help = "Use crc7 checksums for verification",
2301 .oval = VERIFY_SHA1,
2302 .help = "Use sha1 checksums for verification",
2305 .oval = VERIFY_SHA256,
2306 .help = "Use sha256 checksums for verification",
2309 .oval = VERIFY_SHA512,
2310 .help = "Use sha512 checksums for verification",
2313 .oval = VERIFY_XXHASH,
2314 .help = "Use xxhash checksums for verification",
2316 /* Meta information was included into verify_header,
2317 * 'meta' verification is implied by default. */
2319 .oval = VERIFY_HDR_ONLY,
2320 .help = "Use io information for verification. "
2321 "Now is implied by default, thus option is obsolete, "
2324 { .ival = "pattern",
2325 .oval = VERIFY_PATTERN_NO_HDR,
2326 .help = "Verify strict pattern",
2330 .oval = VERIFY_NULL,
2331 .help = "Pretend to verify",
2336 .name = "do_verify",
2337 .lname = "Perform verify step",
2338 .type = FIO_OPT_BOOL,
2339 .off1 = td_var_offset(do_verify),
2340 .help = "Run verification stage after write",
2344 .category = FIO_OPT_C_IO,
2345 .group = FIO_OPT_G_VERIFY,
2348 .name = "verifysort",
2349 .lname = "Verify sort",
2350 .type = FIO_OPT_BOOL,
2351 .off1 = td_var_offset(verifysort),
2352 .help = "Sort written verify blocks for read back",
2356 .category = FIO_OPT_C_IO,
2357 .group = FIO_OPT_G_VERIFY,
2360 .name = "verifysort_nr",
2361 .type = FIO_OPT_INT,
2362 .off1 = td_var_offset(verifysort_nr),
2363 .help = "Pre-load and sort verify blocks for a read workload",
2368 .category = FIO_OPT_C_IO,
2369 .group = FIO_OPT_G_VERIFY,
2372 .name = "verify_interval",
2373 .lname = "Verify interval",
2374 .type = FIO_OPT_INT,
2375 .off1 = td_var_offset(verify_interval),
2376 .minval = 2 * sizeof(struct verify_header),
2377 .help = "Store verify buffer header every N bytes",
2380 .interval = 2 * sizeof(struct verify_header),
2381 .category = FIO_OPT_C_IO,
2382 .group = FIO_OPT_G_VERIFY,
2385 .name = "verify_offset",
2386 .lname = "Verify offset",
2387 .type = FIO_OPT_INT,
2388 .help = "Offset verify header location by N bytes",
2389 .off1 = td_var_offset(verify_offset),
2390 .minval = sizeof(struct verify_header),
2393 .category = FIO_OPT_C_IO,
2394 .group = FIO_OPT_G_VERIFY,
2397 .name = "verify_pattern",
2398 .lname = "Verify pattern",
2399 .type = FIO_OPT_STR,
2400 .cb = str_verify_pattern_cb,
2401 .off1 = td_var_offset(verify_pattern),
2402 .help = "Fill pattern for IO buffers",
2405 .category = FIO_OPT_C_IO,
2406 .group = FIO_OPT_G_VERIFY,
2409 .name = "verify_fatal",
2410 .lname = "Verify fatal",
2411 .type = FIO_OPT_BOOL,
2412 .off1 = td_var_offset(verify_fatal),
2414 .help = "Exit on a single verify failure, don't continue",
2417 .category = FIO_OPT_C_IO,
2418 .group = FIO_OPT_G_VERIFY,
2421 .name = "verify_dump",
2422 .lname = "Verify dump",
2423 .type = FIO_OPT_BOOL,
2424 .off1 = td_var_offset(verify_dump),
2426 .help = "Dump contents of good and bad blocks on failure",
2429 .category = FIO_OPT_C_IO,
2430 .group = FIO_OPT_G_VERIFY,
2433 .name = "verify_async",
2434 .lname = "Verify asynchronously",
2435 .type = FIO_OPT_INT,
2436 .off1 = td_var_offset(verify_async),
2438 .help = "Number of async verifier threads to use",
2441 .category = FIO_OPT_C_IO,
2442 .group = FIO_OPT_G_VERIFY,
2445 .name = "verify_backlog",
2446 .lname = "Verify backlog",
2447 .type = FIO_OPT_STR_VAL,
2448 .off1 = td_var_offset(verify_backlog),
2449 .help = "Verify after this number of blocks are written",
2452 .category = FIO_OPT_C_IO,
2453 .group = FIO_OPT_G_VERIFY,
2456 .name = "verify_backlog_batch",
2457 .lname = "Verify backlog batch",
2458 .type = FIO_OPT_INT,
2459 .off1 = td_var_offset(verify_batch),
2460 .help = "Verify this number of IO blocks",
2463 .category = FIO_OPT_C_IO,
2464 .group = FIO_OPT_G_VERIFY,
2466 #ifdef FIO_HAVE_CPU_AFFINITY
2468 .name = "verify_async_cpus",
2469 .lname = "Async verify CPUs",
2470 .type = FIO_OPT_STR,
2471 .cb = str_verify_cpus_allowed_cb,
2472 .off1 = td_var_offset(verify_cpumask),
2473 .help = "Set CPUs allowed for async verify threads",
2474 .parent = "verify_async",
2476 .category = FIO_OPT_C_IO,
2477 .group = FIO_OPT_G_VERIFY,
2481 .name = "experimental_verify",
2482 .off1 = td_var_offset(experimental_verify),
2483 .type = FIO_OPT_BOOL,
2484 .help = "Enable experimental verification",
2486 .category = FIO_OPT_C_IO,
2487 .group = FIO_OPT_G_VERIFY,
2490 .name = "verify_state_load",
2491 .lname = "Load verify state",
2492 .off1 = td_var_offset(verify_state),
2493 .type = FIO_OPT_BOOL,
2494 .help = "Load verify termination state",
2496 .category = FIO_OPT_C_IO,
2497 .group = FIO_OPT_G_VERIFY,
2500 .name = "verify_state_save",
2501 .lname = "Save verify state",
2502 .off1 = td_var_offset(verify_state_save),
2503 .type = FIO_OPT_BOOL,
2505 .help = "Save verify state on termination",
2507 .category = FIO_OPT_C_IO,
2508 .group = FIO_OPT_G_VERIFY,
2510 #ifdef FIO_HAVE_TRIM
2512 .name = "trim_percentage",
2513 .lname = "Trim percentage",
2514 .type = FIO_OPT_INT,
2515 .off1 = td_var_offset(trim_percentage),
2518 .help = "Number of verify blocks to discard/trim",
2523 .category = FIO_OPT_C_IO,
2524 .group = FIO_OPT_G_TRIM,
2527 .name = "trim_verify_zero",
2528 .lname = "Verify trim zero",
2529 .type = FIO_OPT_BOOL,
2530 .help = "Verify that trim/discarded blocks are returned as zeroes",
2531 .off1 = td_var_offset(trim_zero),
2532 .parent = "trim_percentage",
2535 .category = FIO_OPT_C_IO,
2536 .group = FIO_OPT_G_TRIM,
2539 .name = "trim_backlog",
2540 .lname = "Trim backlog",
2541 .type = FIO_OPT_STR_VAL,
2542 .off1 = td_var_offset(trim_backlog),
2543 .help = "Trim after this number of blocks are written",
2544 .parent = "trim_percentage",
2547 .category = FIO_OPT_C_IO,
2548 .group = FIO_OPT_G_TRIM,
2551 .name = "trim_backlog_batch",
2552 .lname = "Trim backlog batch",
2553 .type = FIO_OPT_INT,
2554 .off1 = td_var_offset(trim_batch),
2555 .help = "Trim this number of IO blocks",
2556 .parent = "trim_percentage",
2559 .category = FIO_OPT_C_IO,
2560 .group = FIO_OPT_G_TRIM,
2564 .name = "write_iolog",
2565 .lname = "Write I/O log",
2566 .type = FIO_OPT_STR_STORE,
2567 .off1 = td_var_offset(write_iolog_file),
2568 .help = "Store IO pattern to file",
2569 .category = FIO_OPT_C_IO,
2570 .group = FIO_OPT_G_IOLOG,
2573 .name = "read_iolog",
2574 .lname = "Read I/O log",
2575 .type = FIO_OPT_STR_STORE,
2576 .off1 = td_var_offset(read_iolog_file),
2577 .help = "Playback IO pattern from file",
2578 .category = FIO_OPT_C_IO,
2579 .group = FIO_OPT_G_IOLOG,
2582 .name = "replay_no_stall",
2583 .lname = "Don't stall on replay",
2584 .type = FIO_OPT_BOOL,
2585 .off1 = td_var_offset(no_stall),
2587 .parent = "read_iolog",
2589 .help = "Playback IO pattern file as fast as possible without stalls",
2590 .category = FIO_OPT_C_IO,
2591 .group = FIO_OPT_G_IOLOG,
2594 .name = "replay_redirect",
2595 .lname = "Redirect device for replay",
2596 .type = FIO_OPT_STR_STORE,
2597 .off1 = td_var_offset(replay_redirect),
2598 .parent = "read_iolog",
2600 .help = "Replay all I/O onto this device, regardless of trace device",
2601 .category = FIO_OPT_C_IO,
2602 .group = FIO_OPT_G_IOLOG,
2605 .name = "replay_scale",
2606 .lname = "Replace offset scale factor",
2607 .type = FIO_OPT_INT,
2608 .off1 = td_var_offset(replay_scale),
2609 .parent = "read_iolog",
2611 .help = "Align offsets to this blocksize",
2612 .category = FIO_OPT_C_IO,
2613 .group = FIO_OPT_G_IOLOG,
2616 .name = "replay_align",
2617 .lname = "Replace alignment",
2618 .type = FIO_OPT_INT,
2619 .off1 = td_var_offset(replay_align),
2620 .parent = "read_iolog",
2621 .help = "Scale offset down by this factor",
2622 .category = FIO_OPT_C_IO,
2623 .group = FIO_OPT_G_IOLOG,
2627 .name = "exec_prerun",
2628 .lname = "Pre-execute runnable",
2629 .type = FIO_OPT_STR_STORE,
2630 .off1 = td_var_offset(exec_prerun),
2631 .help = "Execute this file prior to running job",
2632 .category = FIO_OPT_C_GENERAL,
2633 .group = FIO_OPT_G_INVALID,
2636 .name = "exec_postrun",
2637 .lname = "Post-execute runnable",
2638 .type = FIO_OPT_STR_STORE,
2639 .off1 = td_var_offset(exec_postrun),
2640 .help = "Execute this file after running job",
2641 .category = FIO_OPT_C_GENERAL,
2642 .group = FIO_OPT_G_INVALID,
2644 #ifdef FIO_HAVE_IOSCHED_SWITCH
2646 .name = "ioscheduler",
2647 .lname = "I/O scheduler",
2648 .type = FIO_OPT_STR_STORE,
2649 .off1 = td_var_offset(ioscheduler),
2650 .help = "Use this IO scheduler on the backing device",
2651 .category = FIO_OPT_C_FILE,
2652 .group = FIO_OPT_G_INVALID,
2657 .lname = "Zone size",
2658 .type = FIO_OPT_STR_VAL,
2659 .off1 = td_var_offset(zone_size),
2660 .help = "Amount of data to read per zone",
2662 .interval = 1024 * 1024,
2663 .category = FIO_OPT_C_IO,
2664 .group = FIO_OPT_G_ZONE,
2667 .name = "zonerange",
2668 .lname = "Zone range",
2669 .type = FIO_OPT_STR_VAL,
2670 .off1 = td_var_offset(zone_range),
2671 .help = "Give size of an IO zone",
2673 .interval = 1024 * 1024,
2674 .category = FIO_OPT_C_IO,
2675 .group = FIO_OPT_G_ZONE,
2679 .lname = "Zone skip",
2680 .type = FIO_OPT_STR_VAL,
2681 .off1 = td_var_offset(zone_skip),
2682 .help = "Space between IO zones",
2684 .interval = 1024 * 1024,
2685 .category = FIO_OPT_C_IO,
2686 .group = FIO_OPT_G_ZONE,
2690 .lname = "Lock memory",
2691 .type = FIO_OPT_STR_VAL,
2692 .off1 = td_var_offset(lockmem),
2693 .help = "Lock down this amount of memory (per worker)",
2695 .interval = 1024 * 1024,
2696 .category = FIO_OPT_C_GENERAL,
2697 .group = FIO_OPT_G_INVALID,
2700 .name = "rwmixread",
2701 .lname = "Read/write mix read",
2702 .type = FIO_OPT_INT,
2703 .cb = str_rwmix_read_cb,
2704 .off1 = td_var_offset(rwmix[DDIR_READ]),
2706 .help = "Percentage of mixed workload that is reads",
2709 .inverse = "rwmixwrite",
2710 .category = FIO_OPT_C_IO,
2711 .group = FIO_OPT_G_RWMIX,
2714 .name = "rwmixwrite",
2715 .lname = "Read/write mix write",
2716 .type = FIO_OPT_INT,
2717 .cb = str_rwmix_write_cb,
2718 .off1 = td_var_offset(rwmix[DDIR_WRITE]),
2720 .help = "Percentage of mixed workload that is writes",
2723 .inverse = "rwmixread",
2724 .category = FIO_OPT_C_IO,
2725 .group = FIO_OPT_G_RWMIX,
2728 .name = "rwmixcycle",
2729 .lname = "Read/write mix cycle",
2730 .type = FIO_OPT_DEPRECATED,
2731 .category = FIO_OPT_C_IO,
2732 .group = FIO_OPT_G_RWMIX,
2737 .type = FIO_OPT_INT,
2738 .off1 = td_var_offset(nice),
2739 .help = "Set job CPU nice value",
2744 .category = FIO_OPT_C_GENERAL,
2745 .group = FIO_OPT_G_CRED,
2747 #ifdef FIO_HAVE_IOPRIO
2750 .lname = "I/O nice priority",
2751 .type = FIO_OPT_INT,
2752 .off1 = td_var_offset(ioprio),
2753 .help = "Set job IO priority value",
2757 .category = FIO_OPT_C_GENERAL,
2758 .group = FIO_OPT_G_CRED,
2761 .name = "prioclass",
2762 .lname = "I/O nice priority class",
2763 .type = FIO_OPT_INT,
2764 .off1 = td_var_offset(ioprio_class),
2765 .help = "Set job IO priority class",
2769 .category = FIO_OPT_C_GENERAL,
2770 .group = FIO_OPT_G_CRED,
2774 .name = "thinktime",
2775 .lname = "Thinktime",
2776 .type = FIO_OPT_INT,
2777 .off1 = td_var_offset(thinktime),
2778 .help = "Idle time between IO buffers (usec)",
2781 .category = FIO_OPT_C_IO,
2782 .group = FIO_OPT_G_THINKTIME,
2785 .name = "thinktime_spin",
2786 .lname = "Thinktime spin",
2787 .type = FIO_OPT_INT,
2788 .off1 = td_var_offset(thinktime_spin),
2789 .help = "Start think time by spinning this amount (usec)",
2792 .parent = "thinktime",
2794 .category = FIO_OPT_C_IO,
2795 .group = FIO_OPT_G_THINKTIME,
2798 .name = "thinktime_blocks",
2799 .lname = "Thinktime blocks",
2800 .type = FIO_OPT_INT,
2801 .off1 = td_var_offset(thinktime_blocks),
2802 .help = "IO buffer period between 'thinktime'",
2804 .parent = "thinktime",
2806 .category = FIO_OPT_C_IO,
2807 .group = FIO_OPT_G_THINKTIME,
2811 .lname = "I/O rate",
2812 .type = FIO_OPT_INT,
2813 .off1 = td_var_offset(rate[DDIR_READ]),
2814 .off2 = td_var_offset(rate[DDIR_WRITE]),
2815 .off3 = td_var_offset(rate[DDIR_TRIM]),
2816 .help = "Set bandwidth rate",
2817 .category = FIO_OPT_C_IO,
2818 .group = FIO_OPT_G_RATE,
2822 .lname = "I/O min rate",
2823 .type = FIO_OPT_INT,
2824 .off1 = td_var_offset(ratemin[DDIR_READ]),
2825 .off2 = td_var_offset(ratemin[DDIR_WRITE]),
2826 .off3 = td_var_offset(ratemin[DDIR_TRIM]),
2827 .help = "Job must meet this rate or it will be shutdown",
2830 .category = FIO_OPT_C_IO,
2831 .group = FIO_OPT_G_RATE,
2834 .name = "rate_iops",
2835 .lname = "I/O rate IOPS",
2836 .type = FIO_OPT_INT,
2837 .off1 = td_var_offset(rate_iops[DDIR_READ]),
2838 .off2 = td_var_offset(rate_iops[DDIR_WRITE]),
2839 .off3 = td_var_offset(rate_iops[DDIR_TRIM]),
2840 .help = "Limit IO used to this number of IO operations/sec",
2842 .category = FIO_OPT_C_IO,
2843 .group = FIO_OPT_G_RATE,
2846 .name = "rate_iops_min",
2847 .lname = "I/O min rate IOPS",
2848 .type = FIO_OPT_INT,
2849 .off1 = td_var_offset(rate_iops_min[DDIR_READ]),
2850 .off2 = td_var_offset(rate_iops_min[DDIR_WRITE]),
2851 .off3 = td_var_offset(rate_iops_min[DDIR_TRIM]),
2852 .help = "Job must meet this rate or it will be shut down",
2853 .parent = "rate_iops",
2855 .category = FIO_OPT_C_IO,
2856 .group = FIO_OPT_G_RATE,
2860 .lname = "simulate requests under Poisson process",
2861 .type = FIO_OPT_BOOL,
2862 .off1 = td_var_offset(poisson_request),
2863 .help = "with rate limit, try simulate requests that follow Poisson process",
2866 .category = FIO_OPT_C_IO,
2867 .group = FIO_OPT_G_RATE,
2870 .name = "ratecycle",
2871 .lname = "I/O rate cycle",
2872 .type = FIO_OPT_INT,
2873 .off1 = td_var_offset(ratecycle),
2874 .help = "Window average for rate limits (msec)",
2878 .category = FIO_OPT_C_IO,
2879 .group = FIO_OPT_G_RATE,
2882 .name = "max_latency",
2883 .type = FIO_OPT_INT,
2884 .off1 = td_var_offset(max_latency),
2885 .help = "Maximum tolerated IO latency (usec)",
2887 .category = FIO_OPT_C_IO,
2888 .group = FIO_OPT_G_LATPROF,
2891 .name = "latency_target",
2892 .lname = "Latency Target (usec)",
2893 .type = FIO_OPT_STR_VAL_TIME,
2894 .off1 = td_var_offset(latency_target),
2895 .help = "Ramp to max queue depth supporting this latency",
2897 .category = FIO_OPT_C_IO,
2898 .group = FIO_OPT_G_LATPROF,
2901 .name = "latency_window",
2902 .lname = "Latency Window (usec)",
2903 .type = FIO_OPT_STR_VAL_TIME,
2904 .off1 = td_var_offset(latency_window),
2905 .help = "Time to sustain latency_target",
2907 .category = FIO_OPT_C_IO,
2908 .group = FIO_OPT_G_LATPROF,
2911 .name = "latency_percentile",
2912 .lname = "Latency Percentile",
2913 .type = FIO_OPT_FLOAT_LIST,
2914 .off1 = td_var_offset(latency_percentile),
2915 .help = "Percentile of IOs must be below latency_target",
2920 .category = FIO_OPT_C_IO,
2921 .group = FIO_OPT_G_LATPROF,
2924 .name = "invalidate",
2925 .lname = "Cache invalidate",
2926 .type = FIO_OPT_BOOL,
2927 .off1 = td_var_offset(invalidate_cache),
2928 .help = "Invalidate buffer/page cache prior to running job",
2930 .category = FIO_OPT_C_IO,
2931 .group = FIO_OPT_G_IO_TYPE,
2935 .lname = "Synchronous I/O",
2936 .type = FIO_OPT_BOOL,
2937 .off1 = td_var_offset(sync_io),
2938 .help = "Use O_SYNC for buffered writes",
2940 .parent = "buffered",
2942 .category = FIO_OPT_C_IO,
2943 .group = FIO_OPT_G_IO_TYPE,
2946 .name = "create_serialize",
2947 .lname = "Create serialize",
2948 .type = FIO_OPT_BOOL,
2949 .off1 = td_var_offset(create_serialize),
2950 .help = "Serialize creating of job files",
2952 .category = FIO_OPT_C_FILE,
2953 .group = FIO_OPT_G_INVALID,
2956 .name = "create_fsync",
2957 .lname = "Create fsync",
2958 .type = FIO_OPT_BOOL,
2959 .off1 = td_var_offset(create_fsync),
2960 .help = "fsync file after creation",
2962 .category = FIO_OPT_C_FILE,
2963 .group = FIO_OPT_G_INVALID,
2966 .name = "create_on_open",
2967 .lname = "Create on open",
2968 .type = FIO_OPT_BOOL,
2969 .off1 = td_var_offset(create_on_open),
2970 .help = "Create files when they are opened for IO",
2972 .category = FIO_OPT_C_FILE,
2973 .group = FIO_OPT_G_INVALID,
2976 .name = "create_only",
2977 .type = FIO_OPT_BOOL,
2978 .off1 = td_var_offset(create_only),
2979 .help = "Only perform file creation phase",
2980 .category = FIO_OPT_C_FILE,
2984 .name = "allow_file_create",
2985 .lname = "Allow file create",
2986 .type = FIO_OPT_BOOL,
2987 .off1 = td_var_offset(allow_create),
2988 .help = "Permit fio to create files, if they don't exist",
2990 .category = FIO_OPT_C_FILE,
2991 .group = FIO_OPT_G_FILENAME,
2994 .name = "allow_mounted_write",
2995 .lname = "Allow mounted write",
2996 .type = FIO_OPT_BOOL,
2997 .off1 = td_var_offset(allow_mounted_write),
2998 .help = "Allow writes to a mounted partition",
3000 .category = FIO_OPT_C_FILE,
3001 .group = FIO_OPT_G_FILENAME,
3005 .lname = "Pre-read files",
3006 .type = FIO_OPT_BOOL,
3007 .off1 = td_var_offset(pre_read),
3008 .help = "Pre-read files before starting official testing",
3010 .category = FIO_OPT_C_FILE,
3011 .group = FIO_OPT_G_INVALID,
3013 #ifdef FIO_HAVE_CPU_AFFINITY
3016 .lname = "CPU mask",
3017 .type = FIO_OPT_INT,
3018 .cb = str_cpumask_cb,
3019 .off1 = td_var_offset(cpumask),
3020 .help = "CPU affinity mask",
3021 .category = FIO_OPT_C_GENERAL,
3022 .group = FIO_OPT_G_CRED,
3025 .name = "cpus_allowed",
3026 .lname = "CPUs allowed",
3027 .type = FIO_OPT_STR,
3028 .cb = str_cpus_allowed_cb,
3029 .off1 = td_var_offset(cpumask),
3030 .help = "Set CPUs allowed",
3031 .category = FIO_OPT_C_GENERAL,
3032 .group = FIO_OPT_G_CRED,
3035 .name = "cpus_allowed_policy",
3036 .lname = "CPUs allowed distribution policy",
3037 .type = FIO_OPT_STR,
3038 .off1 = td_var_offset(cpus_allowed_policy),
3039 .help = "Distribution policy for cpus_allowed",
3040 .parent = "cpus_allowed",
3044 .oval = FIO_CPUS_SHARED,
3045 .help = "Mask shared between threads",
3048 .oval = FIO_CPUS_SPLIT,
3049 .help = "Mask split between threads",
3052 .category = FIO_OPT_C_GENERAL,
3053 .group = FIO_OPT_G_CRED,
3056 #ifdef CONFIG_LIBNUMA
3058 .name = "numa_cpu_nodes",
3059 .type = FIO_OPT_STR,
3060 .cb = str_numa_cpunodes_cb,
3061 .off1 = td_var_offset(numa_cpunodes),
3062 .help = "NUMA CPU nodes bind",
3063 .category = FIO_OPT_C_GENERAL,
3064 .group = FIO_OPT_G_INVALID,
3067 .name = "numa_mem_policy",
3068 .type = FIO_OPT_STR,
3069 .cb = str_numa_mpol_cb,
3070 .off1 = td_var_offset(numa_memnodes),
3071 .help = "NUMA memory policy setup",
3072 .category = FIO_OPT_C_GENERAL,
3073 .group = FIO_OPT_G_INVALID,
3077 .name = "end_fsync",
3078 .lname = "End fsync",
3079 .type = FIO_OPT_BOOL,
3080 .off1 = td_var_offset(end_fsync),
3081 .help = "Include fsync at the end of job",
3083 .category = FIO_OPT_C_FILE,
3084 .group = FIO_OPT_G_INVALID,
3087 .name = "fsync_on_close",
3088 .lname = "Fsync on close",
3089 .type = FIO_OPT_BOOL,
3090 .off1 = td_var_offset(fsync_on_close),
3091 .help = "fsync files on close",
3093 .category = FIO_OPT_C_FILE,
3094 .group = FIO_OPT_G_INVALID,
3098 .lname = "Unlink file",
3099 .type = FIO_OPT_BOOL,
3100 .off1 = td_var_offset(unlink),
3101 .help = "Unlink created files after job has completed",
3103 .category = FIO_OPT_C_FILE,
3104 .group = FIO_OPT_G_INVALID,
3108 .lname = "Exit-all on terminate",
3109 .type = FIO_OPT_STR_SET,
3110 .cb = str_exitall_cb,
3111 .help = "Terminate all jobs when one exits",
3112 .category = FIO_OPT_C_GENERAL,
3113 .group = FIO_OPT_G_PROCESS,
3116 .name = "stonewall",
3117 .lname = "Wait for previous",
3118 .alias = "wait_for_previous",
3119 .type = FIO_OPT_STR_SET,
3120 .off1 = td_var_offset(stonewall),
3121 .help = "Insert a hard barrier between this job and previous",
3122 .category = FIO_OPT_C_GENERAL,
3123 .group = FIO_OPT_G_PROCESS,
3126 .name = "new_group",
3127 .lname = "New group",
3128 .type = FIO_OPT_STR_SET,
3129 .off1 = td_var_offset(new_group),
3130 .help = "Mark the start of a new group (for reporting)",
3131 .category = FIO_OPT_C_GENERAL,
3132 .group = FIO_OPT_G_PROCESS,
3137 .type = FIO_OPT_STR_SET,
3138 .off1 = td_var_offset(use_thread),
3139 .help = "Use threads instead of processes",
3140 #ifdef CONFIG_NO_SHM
3144 .category = FIO_OPT_C_GENERAL,
3145 .group = FIO_OPT_G_PROCESS,
3148 .name = "per_job_logs",
3149 .type = FIO_OPT_BOOL,
3150 .off1 = td_var_offset(per_job_logs),
3151 .help = "Include job number in generated log files or not",
3153 .category = FIO_OPT_C_LOG,
3154 .group = FIO_OPT_G_INVALID,
3157 .name = "write_bw_log",
3158 .lname = "Write bandwidth log",
3159 .type = FIO_OPT_STR_STORE,
3160 .off1 = td_var_offset(bw_log_file),
3161 .help = "Write log of bandwidth during run",
3162 .category = FIO_OPT_C_LOG,
3163 .group = FIO_OPT_G_INVALID,
3166 .name = "write_lat_log",
3167 .lname = "Write latency log",
3168 .type = FIO_OPT_STR_STORE,
3169 .off1 = td_var_offset(lat_log_file),
3170 .help = "Write log of latency during run",
3171 .category = FIO_OPT_C_LOG,
3172 .group = FIO_OPT_G_INVALID,
3175 .name = "write_iops_log",
3176 .lname = "Write IOPS log",
3177 .type = FIO_OPT_STR_STORE,
3178 .off1 = td_var_offset(iops_log_file),
3179 .help = "Write log of IOPS during run",
3180 .category = FIO_OPT_C_LOG,
3181 .group = FIO_OPT_G_INVALID,
3184 .name = "log_avg_msec",
3185 .lname = "Log averaging (msec)",
3186 .type = FIO_OPT_INT,
3187 .off1 = td_var_offset(log_avg_msec),
3188 .help = "Average bw/iops/lat logs over this period of time",
3190 .category = FIO_OPT_C_LOG,
3191 .group = FIO_OPT_G_INVALID,
3194 .name = "log_offset",
3195 .lname = "Log offset of IO",
3196 .type = FIO_OPT_BOOL,
3197 .off1 = td_var_offset(log_offset),
3198 .help = "Include offset of IO for each log entry",
3200 .category = FIO_OPT_C_LOG,
3201 .group = FIO_OPT_G_INVALID,
3205 .name = "log_compression",
3206 .lname = "Log compression",
3207 .type = FIO_OPT_INT,
3208 .off1 = td_var_offset(log_gz),
3209 .help = "Log in compressed chunks of this size",
3211 .maxval = 512 * 1024 * 1024ULL,
3212 .category = FIO_OPT_C_LOG,
3213 .group = FIO_OPT_G_INVALID,
3216 .name = "log_store_compressed",
3217 .lname = "Log store compressed",
3218 .type = FIO_OPT_BOOL,
3219 .off1 = td_var_offset(log_gz_store),
3220 .help = "Store logs in a compressed format",
3221 .category = FIO_OPT_C_LOG,
3222 .group = FIO_OPT_G_INVALID,
3226 .name = "block_error_percentiles",
3227 .lname = "Block error percentiles",
3228 .type = FIO_OPT_BOOL,
3229 .off1 = td_var_offset(block_error_hist),
3230 .help = "Record trim block errors and make a histogram",
3232 .category = FIO_OPT_C_LOG,
3233 .group = FIO_OPT_G_INVALID,
3236 .name = "bwavgtime",
3237 .lname = "Bandwidth average time",
3238 .type = FIO_OPT_INT,
3239 .off1 = td_var_offset(bw_avg_time),
3240 .help = "Time window over which to calculate bandwidth"
3243 .parent = "write_bw_log",
3246 .category = FIO_OPT_C_LOG,
3247 .group = FIO_OPT_G_INVALID,
3250 .name = "iopsavgtime",
3251 .lname = "IOPS average time",
3252 .type = FIO_OPT_INT,
3253 .off1 = td_var_offset(iops_avg_time),
3254 .help = "Time window over which to calculate IOPS (msec)",
3256 .parent = "write_iops_log",
3259 .category = FIO_OPT_C_LOG,
3260 .group = FIO_OPT_G_INVALID,
3263 .name = "group_reporting",
3264 .lname = "Group reporting",
3265 .type = FIO_OPT_STR_SET,
3266 .off1 = td_var_offset(group_reporting),
3267 .help = "Do reporting on a per-group basis",
3268 .category = FIO_OPT_C_STAT,
3269 .group = FIO_OPT_G_INVALID,
3272 .name = "zero_buffers",
3273 .lname = "Zero I/O buffers",
3274 .type = FIO_OPT_STR_SET,
3275 .off1 = td_var_offset(zero_buffers),
3276 .help = "Init IO buffers to all zeroes",
3277 .category = FIO_OPT_C_IO,
3278 .group = FIO_OPT_G_IO_BUF,
3281 .name = "refill_buffers",
3282 .lname = "Refill I/O buffers",
3283 .type = FIO_OPT_STR_SET,
3284 .off1 = td_var_offset(refill_buffers),
3285 .help = "Refill IO buffers on every IO submit",
3286 .category = FIO_OPT_C_IO,
3287 .group = FIO_OPT_G_IO_BUF,
3290 .name = "scramble_buffers",
3291 .lname = "Scramble I/O buffers",
3292 .type = FIO_OPT_BOOL,
3293 .off1 = td_var_offset(scramble_buffers),
3294 .help = "Slightly scramble buffers on every IO submit",
3296 .category = FIO_OPT_C_IO,
3297 .group = FIO_OPT_G_IO_BUF,
3300 .name = "buffer_pattern",
3301 .lname = "Buffer pattern",
3302 .type = FIO_OPT_STR,
3303 .cb = str_buffer_pattern_cb,
3304 .off1 = td_var_offset(buffer_pattern),
3305 .help = "Fill pattern for IO buffers",
3306 .category = FIO_OPT_C_IO,
3307 .group = FIO_OPT_G_IO_BUF,
3310 .name = "buffer_compress_percentage",
3311 .lname = "Buffer compression percentage",
3312 .type = FIO_OPT_INT,
3313 .cb = str_buffer_compress_cb,
3314 .off1 = td_var_offset(compress_percentage),
3317 .help = "How compressible the buffer is (approximately)",
3319 .category = FIO_OPT_C_IO,
3320 .group = FIO_OPT_G_IO_BUF,
3323 .name = "buffer_compress_chunk",
3324 .lname = "Buffer compression chunk size",
3325 .type = FIO_OPT_INT,
3326 .off1 = td_var_offset(compress_chunk),
3327 .parent = "buffer_compress_percentage",
3329 .help = "Size of compressible region in buffer",
3331 .category = FIO_OPT_C_IO,
3332 .group = FIO_OPT_G_IO_BUF,
3335 .name = "dedupe_percentage",
3336 .lname = "Dedupe percentage",
3337 .type = FIO_OPT_INT,
3338 .cb = str_dedupe_cb,
3339 .off1 = td_var_offset(dedupe_percentage),
3342 .help = "Percentage of buffers that are dedupable",
3344 .category = FIO_OPT_C_IO,
3345 .group = FIO_OPT_G_IO_BUF,
3348 .name = "clat_percentiles",
3349 .lname = "Completion latency percentiles",
3350 .type = FIO_OPT_BOOL,
3351 .off1 = td_var_offset(clat_percentiles),
3352 .help = "Enable the reporting of completion latency percentiles",
3354 .category = FIO_OPT_C_STAT,
3355 .group = FIO_OPT_G_INVALID,
3358 .name = "percentile_list",
3359 .lname = "Percentile list",
3360 .type = FIO_OPT_FLOAT_LIST,
3361 .off1 = td_var_offset(percentile_list),
3362 .off2 = td_var_offset(percentile_precision),
3363 .help = "Specify a custom list of percentiles to report for "
3364 "completion latency and block errors",
3365 .def = "1:5:10:20:30:40:50:60:70:80:90:95:99:99.5:99.9:99.95:99.99",
3366 .maxlen = FIO_IO_U_LIST_MAX_LEN,
3369 .category = FIO_OPT_C_STAT,
3370 .group = FIO_OPT_G_INVALID,
3373 #ifdef FIO_HAVE_DISK_UTIL
3375 .name = "disk_util",
3376 .lname = "Disk utilization",
3377 .type = FIO_OPT_BOOL,
3378 .off1 = td_var_offset(do_disk_util),
3379 .help = "Log disk utilization statistics",
3381 .category = FIO_OPT_C_STAT,
3382 .group = FIO_OPT_G_INVALID,
3386 .name = "gtod_reduce",
3387 .lname = "Reduce gettimeofday() calls",
3388 .type = FIO_OPT_BOOL,
3389 .help = "Greatly reduce number of gettimeofday() calls",
3390 .cb = str_gtod_reduce_cb,
3393 .category = FIO_OPT_C_STAT,
3394 .group = FIO_OPT_G_INVALID,
3397 .name = "disable_lat",
3398 .lname = "Disable all latency stats",
3399 .type = FIO_OPT_BOOL,
3400 .off1 = td_var_offset(disable_lat),
3401 .help = "Disable latency numbers",
3402 .parent = "gtod_reduce",
3405 .category = FIO_OPT_C_STAT,
3406 .group = FIO_OPT_G_INVALID,
3409 .name = "disable_clat",
3410 .lname = "Disable completion latency stats",
3411 .type = FIO_OPT_BOOL,
3412 .off1 = td_var_offset(disable_clat),
3413 .help = "Disable completion latency numbers",
3414 .parent = "gtod_reduce",
3417 .category = FIO_OPT_C_STAT,
3418 .group = FIO_OPT_G_INVALID,
3421 .name = "disable_slat",
3422 .lname = "Disable submission latency stats",
3423 .type = FIO_OPT_BOOL,
3424 .off1 = td_var_offset(disable_slat),
3425 .help = "Disable submission latency numbers",
3426 .parent = "gtod_reduce",
3429 .category = FIO_OPT_C_STAT,
3430 .group = FIO_OPT_G_INVALID,
3433 .name = "disable_bw_measurement",
3434 .lname = "Disable bandwidth stats",
3435 .type = FIO_OPT_BOOL,
3436 .off1 = td_var_offset(disable_bw),
3437 .help = "Disable bandwidth logging",
3438 .parent = "gtod_reduce",
3441 .category = FIO_OPT_C_STAT,
3442 .group = FIO_OPT_G_INVALID,
3446 .lname = "Dedicated gettimeofday() CPU",
3447 .type = FIO_OPT_INT,
3448 .off1 = td_var_offset(gtod_cpu),
3449 .help = "Set up dedicated gettimeofday() thread on this CPU",
3450 .verify = gtod_cpu_verify,
3451 .category = FIO_OPT_C_GENERAL,
3452 .group = FIO_OPT_G_CLOCK,
3455 .name = "unified_rw_reporting",
3456 .type = FIO_OPT_BOOL,
3457 .off1 = td_var_offset(unified_rw_rep),
3458 .help = "Unify reporting across data direction",
3460 .category = FIO_OPT_C_GENERAL,
3461 .group = FIO_OPT_G_INVALID,
3464 .name = "continue_on_error",
3465 .lname = "Continue on error",
3466 .type = FIO_OPT_STR,
3467 .off1 = td_var_offset(continue_on_error),
3468 .help = "Continue on non-fatal errors during IO",
3470 .category = FIO_OPT_C_GENERAL,
3471 .group = FIO_OPT_G_ERR,
3474 .oval = ERROR_TYPE_NONE,
3475 .help = "Exit when an error is encountered",
3478 .oval = ERROR_TYPE_READ,
3479 .help = "Continue on read errors only",
3482 .oval = ERROR_TYPE_WRITE,
3483 .help = "Continue on write errors only",
3486 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
3487 .help = "Continue on any IO errors",
3490 .oval = ERROR_TYPE_VERIFY,
3491 .help = "Continue on verify errors only",
3494 .oval = ERROR_TYPE_ANY,
3495 .help = "Continue on all io and verify errors",
3498 .oval = ERROR_TYPE_NONE,
3499 .help = "Alias for 'none'",
3502 .oval = ERROR_TYPE_ANY,
3503 .help = "Alias for 'all'",
3508 .name = "ignore_error",
3509 .type = FIO_OPT_STR,
3510 .cb = str_ignore_error_cb,
3511 .off1 = td_var_offset(ignore_error_nr),
3512 .help = "Set a specific list of errors to ignore",
3514 .category = FIO_OPT_C_GENERAL,
3515 .group = FIO_OPT_G_ERR,
3518 .name = "error_dump",
3519 .type = FIO_OPT_BOOL,
3520 .off1 = td_var_offset(error_dump),
3522 .help = "Dump info on each error",
3523 .category = FIO_OPT_C_GENERAL,
3524 .group = FIO_OPT_G_ERR,
3529 .type = FIO_OPT_STR_STORE,
3530 .off1 = td_var_offset(profile),
3531 .help = "Select a specific builtin performance test",
3532 .category = FIO_OPT_C_PROFILE,
3533 .group = FIO_OPT_G_INVALID,
3538 .type = FIO_OPT_STR_STORE,
3539 .off1 = td_var_offset(cgroup),
3540 .help = "Add job to cgroup of this name",
3541 .category = FIO_OPT_C_GENERAL,
3542 .group = FIO_OPT_G_CGROUP,
3545 .name = "cgroup_nodelete",
3546 .lname = "Cgroup no-delete",
3547 .type = FIO_OPT_BOOL,
3548 .off1 = td_var_offset(cgroup_nodelete),
3549 .help = "Do not delete cgroups after job completion",
3552 .category = FIO_OPT_C_GENERAL,
3553 .group = FIO_OPT_G_CGROUP,
3556 .name = "cgroup_weight",
3557 .lname = "Cgroup weight",
3558 .type = FIO_OPT_INT,
3559 .off1 = td_var_offset(cgroup_weight),
3560 .help = "Use given weight for cgroup",
3564 .category = FIO_OPT_C_GENERAL,
3565 .group = FIO_OPT_G_CGROUP,
3570 .type = FIO_OPT_INT,
3571 .off1 = td_var_offset(uid),
3572 .help = "Run job with this user ID",
3573 .category = FIO_OPT_C_GENERAL,
3574 .group = FIO_OPT_G_CRED,
3578 .lname = "Group ID",
3579 .type = FIO_OPT_INT,
3580 .off1 = td_var_offset(gid),
3581 .help = "Run job with this group ID",
3582 .category = FIO_OPT_C_GENERAL,
3583 .group = FIO_OPT_G_CRED,
3588 .type = FIO_OPT_INT,
3589 .off1 = td_var_offset(kb_base),
3595 .help = "Use 1024 as the K base",
3599 .help = "Use 1000 as the K base",
3602 .help = "How many bytes per KB for reporting (1000 or 1024)",
3603 .category = FIO_OPT_C_GENERAL,
3604 .group = FIO_OPT_G_INVALID,
3607 .name = "unit_base",
3608 .lname = "Base unit for reporting (Bits or Bytes)",
3609 .type = FIO_OPT_INT,
3610 .off1 = td_var_offset(unit_base),
3615 .help = "Auto-detect",
3619 .help = "Normal (byte based)",
3623 .help = "Bit based",
3626 .help = "Bit multiple of result summary data (8 for byte, 1 for bit)",
3627 .category = FIO_OPT_C_GENERAL,
3628 .group = FIO_OPT_G_INVALID,
3631 .name = "hugepage-size",
3632 .lname = "Hugepage size",
3633 .type = FIO_OPT_INT,
3634 .off1 = td_var_offset(hugepage_size),
3635 .help = "When using hugepages, specify size of each page",
3636 .def = __fio_stringify(FIO_HUGE_PAGE),
3637 .interval = 1024 * 1024,
3638 .category = FIO_OPT_C_GENERAL,
3639 .group = FIO_OPT_G_INVALID,
3643 .lname = "I/O flow ID",
3644 .type = FIO_OPT_INT,
3645 .off1 = td_var_offset(flow_id),
3646 .help = "The flow index ID to use",
3648 .category = FIO_OPT_C_IO,
3649 .group = FIO_OPT_G_IO_FLOW,
3653 .lname = "I/O flow weight",
3654 .type = FIO_OPT_INT,
3655 .off1 = td_var_offset(flow),
3656 .help = "Weight for flow control of this job",
3657 .parent = "flow_id",
3660 .category = FIO_OPT_C_IO,
3661 .group = FIO_OPT_G_IO_FLOW,
3664 .name = "flow_watermark",
3665 .lname = "I/O flow watermark",
3666 .type = FIO_OPT_INT,
3667 .off1 = td_var_offset(flow_watermark),
3668 .help = "High watermark for flow control. This option"
3669 " should be set to the same value for all threads"
3670 " with non-zero flow.",
3671 .parent = "flow_id",
3674 .category = FIO_OPT_C_IO,
3675 .group = FIO_OPT_G_IO_FLOW,
3678 .name = "flow_sleep",
3679 .lname = "I/O flow sleep",
3680 .type = FIO_OPT_INT,
3681 .off1 = td_var_offset(flow_sleep),
3682 .help = "How many microseconds to sleep after being held"
3683 " back by the flow control mechanism",
3684 .parent = "flow_id",
3687 .category = FIO_OPT_C_IO,
3688 .group = FIO_OPT_G_IO_FLOW,
3692 .lname = "Skip operations against bad blocks",
3693 .type = FIO_OPT_BOOL,
3694 .off1 = td_var_offset(skip_bad),
3695 .help = "Skip operations against known bad blocks.",
3698 .category = FIO_OPT_C_IO,
3699 .group = FIO_OPT_G_MTD,
3706 static void add_to_lopt(struct option *lopt, struct fio_option *o,
3707 const char *name, int val)
3709 lopt->name = (char *) name;
3711 if (o->type == FIO_OPT_STR_SET)
3712 lopt->has_arg = optional_argument;
3714 lopt->has_arg = required_argument;
3717 static void options_to_lopts(struct fio_option *opts,
3718 struct option *long_options,
3719 int i, int option_type)
3721 struct fio_option *o = &opts[0];
3723 add_to_lopt(&long_options[i], o, o->name, option_type);
3726 add_to_lopt(&long_options[i], o, o->alias, option_type);
3731 assert(i < FIO_NR_OPTIONS);
3735 void fio_options_set_ioengine_opts(struct option *long_options,
3736 struct thread_data *td)
3741 while (long_options[i].name) {
3742 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
3743 memset(&long_options[i], 0, sizeof(*long_options));
3750 * Just clear out the prior ioengine options.
3755 options_to_lopts(td->io_ops->options, long_options, i,
3756 FIO_GETOPT_IOENGINE);
3759 void fio_options_dup_and_init(struct option *long_options)
3763 options_init(fio_options);
3766 while (long_options[i].name)
3769 options_to_lopts(fio_options, long_options, i, FIO_GETOPT_JOB);
3772 struct fio_keyword {
3778 static struct fio_keyword fio_keywords[] = {
3780 .word = "$pagesize",
3781 .desc = "Page size in the system",
3784 .word = "$mb_memory",
3785 .desc = "Megabytes of memory online",
3789 .desc = "Number of CPUs online in the system",
3796 void fio_keywords_exit(void)
3798 struct fio_keyword *kw;
3800 kw = &fio_keywords[0];
3808 void fio_keywords_init(void)
3810 unsigned long long mb_memory;
3814 sprintf(buf, "%lu", (unsigned long) page_size);
3815 fio_keywords[0].replace = strdup(buf);
3817 mb_memory = os_phys_mem() / (1024 * 1024);
3818 sprintf(buf, "%llu", mb_memory);
3819 fio_keywords[1].replace = strdup(buf);
3822 sprintf(buf, "%lu", l);
3823 fio_keywords[2].replace = strdup(buf);
3828 static char *bc_calc(char *str)
3830 char buf[128], *tmp;
3835 * No math, just return string
3837 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
3838 !strchr(str, '/')) || strchr(str, '\''))
3842 * Split option from value, we only need to calculate the value
3844 tmp = strchr(str, '=');
3851 * Prevent buffer overflows; such a case isn't reasonable anyway
3853 if (strlen(str) >= 128 || strlen(tmp) > 100)
3856 sprintf(buf, "which %s > /dev/null", BC_APP);
3858 log_err("fio: bc is needed for performing math\n");
3862 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
3863 f = popen(buf, "r");
3867 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
3874 buf[(tmp - str) + ret - 1] = '\0';
3875 memcpy(buf, str, tmp - str);
3881 * Return a copy of the input string with substrings of the form ${VARNAME}
3882 * substituted with the value of the environment variable VARNAME. The
3883 * substitution always occurs, even if VARNAME is empty or the corresponding
3884 * environment variable undefined.
3886 static char *option_dup_subs(const char *opt)
3888 char out[OPT_LEN_MAX+1];
3889 char in[OPT_LEN_MAX+1];
3892 char *ch1, *ch2, *env;
3893 ssize_t nchr = OPT_LEN_MAX;
3896 if (strlen(opt) + 1 > OPT_LEN_MAX) {
3897 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
3901 in[OPT_LEN_MAX] = '\0';
3902 strncpy(in, opt, OPT_LEN_MAX);
3904 while (*inptr && nchr > 0) {
3905 if (inptr[0] == '$' && inptr[1] == '{') {
3906 ch2 = strchr(inptr, '}');
3907 if (ch2 && inptr+1 < ch2) {
3914 envlen = strlen(env);
3915 if (envlen <= nchr) {
3916 memcpy(outptr, env, envlen);
3926 *outptr++ = *inptr++;
3935 * Look for reserved variable names and replace them with real values
3937 static char *fio_keyword_replace(char *opt)
3943 for (i = 0; fio_keywords[i].word != NULL; i++) {
3944 struct fio_keyword *kw = &fio_keywords[i];
3946 while ((s = strstr(opt, kw->word)) != NULL) {
3947 char *new = malloc(strlen(opt) + 1);
3953 * Copy part of the string before the keyword and
3954 * sprintf() the replacement after it.
3956 memcpy(new, opt, olen);
3957 len = sprintf(new + olen, "%s", kw->replace);
3960 * If there's more in the original string, copy that
3963 opt += strlen(kw->word) + olen;
3965 memcpy(new + olen + len, opt, opt - o_org - 1);
3968 * replace opt and free the old opt
3978 * Check for potential math and invoke bc, if possible
3986 static char **dup_and_sub_options(char **opts, int num_opts)
3989 char **opts_copy = malloc(num_opts * sizeof(*opts));
3990 for (i = 0; i < num_opts; i++) {
3991 opts_copy[i] = option_dup_subs(opts[i]);
3994 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
3999 static void show_closest_option(const char *opt)
4001 int best_option, best_distance;
4010 while (name[i] != '\0' && name[i] != '=')
4015 best_distance = INT_MAX;
4017 while (fio_options[i].name) {
4018 distance = string_distance(name, fio_options[i].name);
4019 if (distance < best_distance) {
4020 best_distance = distance;
4026 if (best_option != -1 && string_distance_ok(name, best_distance))
4027 log_err("Did you mean %s?\n", fio_options[best_option].name);
4032 int fio_options_parse(struct thread_data *td, char **opts, int num_opts,
4035 int i, ret, unknown;
4038 sort_options(opts, fio_options, num_opts);
4039 opts_copy = dup_and_sub_options(opts, num_opts);
4041 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
4042 struct fio_option *o;
4043 int newret = parse_option(opts_copy[i], opts[i], fio_options,
4044 &o, td, dump_cmdline);
4047 fio_option_mark_set(&td->o, o);
4055 opts_copy[i] = NULL;
4062 ret |= ioengine_load(td);
4064 sort_options(opts_copy, td->io_ops->options, num_opts);
4067 for (i = 0; i < num_opts; i++) {
4068 struct fio_option *o = NULL;
4075 newret = parse_option(opts_copy[i], opts[i],
4076 td->io_ops->options, &o,
4077 td->eo, dump_cmdline);
4081 log_err("Bad option <%s>\n", opts[i]);
4082 show_closest_option(opts[i]);
4085 opts_copy[i] = NULL;
4093 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
4097 ret = parse_cmd_option(opt, val, fio_options, td);
4099 struct fio_option *o;
4101 o = find_option(fio_options, opt);
4103 fio_option_mark_set(&td->o, o);
4109 int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
4112 return parse_cmd_option(opt, val, td->io_ops->options, td->eo);
4115 void fio_fill_default_options(struct thread_data *td)
4117 td->o.magic = OPT_MAGIC;
4118 fill_default_options(td, fio_options);
4121 int fio_show_option_help(const char *opt)
4123 return show_cmd_help(fio_options, opt);
4126 void options_mem_dupe(void *data, struct fio_option *options)
4128 struct fio_option *o;
4131 for (o = &options[0]; o->name; o++) {
4132 if (o->type != FIO_OPT_STR_STORE)
4135 ptr = td_var(data, o, o->off1);
4137 *ptr = strdup(*ptr);
4142 * dupe FIO_OPT_STR_STORE options
4144 void fio_options_mem_dupe(struct thread_data *td)
4146 options_mem_dupe(&td->o, fio_options);
4148 if (td->eo && td->io_ops) {
4149 void *oldeo = td->eo;
4151 td->eo = malloc(td->io_ops->option_struct_size);
4152 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
4153 options_mem_dupe(td->eo, td->io_ops->options);
4157 unsigned int fio_get_kb_base(void *data)
4159 struct thread_options *o = data;
4160 unsigned int kb_base = 0;
4163 * This is a hack... For private options, *data is not holding
4164 * a pointer to the thread_options, but to private data. This means
4165 * we can't safely dereference it, but magic is first so mem wise
4166 * it is valid. But this also means that if the job first sets
4167 * kb_base and expects that to be honored by private options,
4168 * it will be disappointed. We will return the global default
4171 if (o && o->magic == OPT_MAGIC)
4172 kb_base = o->kb_base;
4179 int add_option(struct fio_option *o)
4181 struct fio_option *__o;
4190 if (opt_index + 1 == FIO_MAX_OPTS) {
4191 log_err("fio: FIO_MAX_OPTS is too small\n");
4195 memcpy(&fio_options[opt_index], o, sizeof(*o));
4196 fio_options[opt_index + 1].name = NULL;
4200 void invalidate_profile_options(const char *prof_name)
4202 struct fio_option *o;
4206 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
4207 o->type = FIO_OPT_INVALID;
4208 o->prof_name = NULL;
4214 void add_opt_posval(const char *optname, const char *ival, const char *help)
4216 struct fio_option *o;
4219 o = find_option(fio_options, optname);
4223 for (i = 0; i < PARSE_MAX_VP; i++) {
4224 if (o->posval[i].ival)
4227 o->posval[i].ival = ival;
4228 o->posval[i].help = help;
4233 void del_opt_posval(const char *optname, const char *ival)
4235 struct fio_option *o;
4238 o = find_option(fio_options, optname);
4242 for (i = 0; i < PARSE_MAX_VP; i++) {
4243 if (!o->posval[i].ival)
4245 if (strcmp(o->posval[i].ival, ival))
4248 o->posval[i].ival = NULL;
4249 o->posval[i].help = NULL;
4253 void fio_options_free(struct thread_data *td)
4255 options_free(fio_options, td);
4256 if (td->eo && td->io_ops && td->io_ops->options) {
4257 options_free(td->io_ops->options, td->eo);
4263 struct fio_option *fio_option_find(const char *name)
4265 return find_option(fio_options, name);
4268 static struct fio_option *find_next_opt(struct thread_options *o,
4269 struct fio_option *from,
4272 struct fio_option *opt;
4275 from = &fio_options[0];
4281 if (off1 == from->off1) {
4286 } while (from->name);
4291 static int opt_is_set(struct thread_options *o, struct fio_option *opt)
4293 unsigned int opt_off, index, offset;
4295 opt_off = opt - &fio_options[0];
4296 index = opt_off / (8 * sizeof(uint64_t));
4297 offset = opt_off & ((8 * sizeof(uint64_t)) - 1);
4298 return (o->set_options[index] & ((uint64_t)1 << offset)) != 0;
4301 int __fio_option_is_set(struct thread_options *o, unsigned int off1)
4303 struct fio_option *opt, *next;
4306 while ((opt = find_next_opt(o, next, off1)) != NULL) {
4307 if (opt_is_set(o, opt))
4316 void fio_option_mark_set(struct thread_options *o, struct fio_option *opt)
4318 unsigned int opt_off, index, offset;
4320 opt_off = opt - &fio_options[0];
4321 index = opt_off / (8 * sizeof(uint64_t));
4322 offset = opt_off & ((8 * sizeof(uint64_t)) - 1);
4323 o->set_options[index] |= (uint64_t)1 << offset;