11 #include <netinet/in.h>
17 #include "lib/pattern.h"
21 char client_sockaddr_str[INET6_ADDRSTRLEN] = { 0 };
23 #define cb_data_to_td(data) container_of(data, struct thread_data, o)
25 static struct pattern_fmt_desc fmt_desc[] = {
28 .len = FIELD_SIZE(struct io_u *, offset),
29 .paste = paste_blockoff
34 * Check if mmap/mmaphuge has a :/foo/bar/file at the end. If so, return that.
36 static char *get_opt_postfix(const char *str)
38 char *p = strstr(str, ":");
44 strip_blank_front(&p);
49 static int bs_cmp(const void *p1, const void *p2)
51 const struct bssplit *bsp1 = p1;
52 const struct bssplit *bsp2 = p2;
54 return (int) bsp1->perc - (int) bsp2->perc;
59 unsigned int val1[100];
60 unsigned int val2[100];
63 static int split_parse_ddir(struct thread_options *o, struct split *split,
64 enum fio_ddir ddir, char *str)
73 while ((fname = strsep(&str, ":")) != NULL) {
79 perc_str = strstr(fname, "/");
83 perc = atoi(perc_str);
91 if (str_to_decimal(fname, &val, 1, o, 0, 0)) {
92 log_err("fio: bssplit conversion failed\n");
97 split->val2[i] = perc;
107 static int bssplit_ddir(struct thread_options *o, enum fio_ddir ddir, char *str)
109 unsigned int i, perc, perc_missing;
110 unsigned int max_bs, min_bs;
113 memset(&split, 0, sizeof(split));
115 if (split_parse_ddir(o, &split, ddir, str))
122 o->bssplit[ddir] = malloc(split.nr * sizeof(struct bssplit));
123 o->bssplit_nr[ddir] = split.nr;
124 for (i = 0; i < split.nr; i++) {
125 if (split.val1[i] > max_bs)
126 max_bs = split.val1[i];
127 if (split.val1[i] < min_bs)
128 min_bs = split.val1[i];
130 o->bssplit[ddir][i].bs = split.val1[i];
131 o->bssplit[ddir][i].perc =split.val2[i];
135 * Now check if the percentages add up, and how much is missing
137 perc = perc_missing = 0;
138 for (i = 0; i < o->bssplit_nr[ddir]; i++) {
139 struct bssplit *bsp = &o->bssplit[ddir][i];
141 if (bsp->perc == -1U)
147 if (perc > 100 && perc_missing > 1) {
148 log_err("fio: bssplit percentages add to more than 100%%\n");
149 free(o->bssplit[ddir]);
150 o->bssplit[ddir] = NULL;
155 * If values didn't have a percentage set, divide the remains between
159 if (perc_missing == 1 && o->bssplit_nr[ddir] == 1)
161 for (i = 0; i < o->bssplit_nr[ddir]; i++) {
162 struct bssplit *bsp = &o->bssplit[ddir][i];
164 if (bsp->perc == -1U)
165 bsp->perc = (100 - perc) / perc_missing;
169 o->min_bs[ddir] = min_bs;
170 o->max_bs[ddir] = max_bs;
173 * now sort based on percentages, for ease of lookup
175 qsort(o->bssplit[ddir], o->bssplit_nr[ddir], sizeof(struct bssplit), bs_cmp);
179 typedef int (split_parse_fn)(struct thread_options *, enum fio_ddir, char *);
181 static int str_split_parse(struct thread_data *td, char *str, split_parse_fn *fn)
186 odir = strchr(str, ',');
188 ddir = strchr(odir + 1, ',');
190 ret = fn(&td->o, DDIR_TRIM, ddir + 1);
196 op = strdup(odir + 1);
197 ret = fn(&td->o, DDIR_TRIM, op);
202 ret = fn(&td->o, DDIR_WRITE, odir + 1);
205 ret = fn(&td->o, DDIR_READ, str);
211 ret = fn(&td->o, DDIR_WRITE, op);
216 ret = fn(&td->o, DDIR_TRIM, op);
220 ret = fn(&td->o, DDIR_READ, str);
226 static int str_bssplit_cb(void *data, const char *input)
228 struct thread_data *td = cb_data_to_td(data);
232 p = str = strdup(input);
234 strip_blank_front(&str);
235 strip_blank_end(str);
237 ret = str_split_parse(td, str, bssplit_ddir);
239 if (parse_dryrun()) {
242 for (i = 0; i < DDIR_RWDIR_CNT; i++) {
243 free(td->o.bssplit[i]);
244 td->o.bssplit[i] = NULL;
245 td->o.bssplit_nr[i] = 0;
253 static int str2error(char *str)
255 const char *err[] = { "EPERM", "ENOENT", "ESRCH", "EINTR", "EIO",
256 "ENXIO", "E2BIG", "ENOEXEC", "EBADF",
257 "ECHILD", "EAGAIN", "ENOMEM", "EACCES",
258 "EFAULT", "ENOTBLK", "EBUSY", "EEXIST",
259 "EXDEV", "ENODEV", "ENOTDIR", "EISDIR",
260 "EINVAL", "ENFILE", "EMFILE", "ENOTTY",
261 "ETXTBSY","EFBIG", "ENOSPC", "ESPIPE",
262 "EROFS","EMLINK", "EPIPE", "EDOM", "ERANGE" };
263 int i = 0, num = sizeof(err) / sizeof(char *);
266 if (!strcmp(err[i], str))
273 static int ignore_error_type(struct thread_data *td, int etype, char *str)
279 if (etype >= ERROR_TYPE_CNT) {
280 log_err("Illegal error type\n");
284 td->o.ignore_error_nr[etype] = 4;
285 error = calloc(4, sizeof(int));
288 while ((fname = strsep(&str, ":")) != NULL) {
294 * grow struct buffer, if needed
296 if (i == td->o.ignore_error_nr[etype]) {
297 td->o.ignore_error_nr[etype] <<= 1;
298 error = realloc(error, td->o.ignore_error_nr[etype]
301 if (fname[0] == 'E') {
302 error[i] = str2error(fname);
304 error[i] = atoi(fname);
306 error[i] = -error[i];
309 log_err("Unknown error %s, please use number value\n",
311 td->o.ignore_error_nr[etype] = 0;
318 td->o.continue_on_error |= 1 << etype;
319 td->o.ignore_error_nr[etype] = i;
320 td->o.ignore_error[etype] = error;
322 td->o.ignore_error_nr[etype] = 0;
330 static int str_ignore_error_cb(void *data, const char *input)
332 struct thread_data *td = cb_data_to_td(data);
334 int type = 0, ret = 1;
339 p = str = strdup(input);
341 strip_blank_front(&str);
342 strip_blank_end(str);
348 ret = ignore_error_type(td, type, p);
358 static int str_rw_cb(void *data, const char *str)
360 struct thread_data *td = cb_data_to_td(data);
361 struct thread_options *o = &td->o;
370 nr = get_opt_postfix(str);
375 o->ddir_seq_nr = atoi(nr);
379 if (str_to_decimal(nr, &val, 1, o, 0, 0)) {
380 log_err("fio: rw postfix parsing failed\n");
385 o->ddir_seq_add = val;
392 static int str_mem_cb(void *data, const char *mem)
394 struct thread_data *td = cb_data_to_td(data);
396 if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP ||
397 td->o.mem_type == MEM_MMAPSHARED)
398 td->o.mmapfile = get_opt_postfix(mem);
403 static int fio_clock_source_cb(void *data, const char *str)
405 struct thread_data *td = cb_data_to_td(data);
407 fio_clock_source = td->o.clocksource;
408 fio_clock_source_set = 1;
413 static int str_rwmix_read_cb(void *data, unsigned long long *val)
415 struct thread_data *td = cb_data_to_td(data);
417 td->o.rwmix[DDIR_READ] = *val;
418 td->o.rwmix[DDIR_WRITE] = 100 - *val;
422 static int str_rwmix_write_cb(void *data, unsigned long long *val)
424 struct thread_data *td = cb_data_to_td(data);
426 td->o.rwmix[DDIR_WRITE] = *val;
427 td->o.rwmix[DDIR_READ] = 100 - *val;
431 static int str_exitall_cb(void)
433 exitall_on_terminate = 1;
437 #ifdef FIO_HAVE_CPU_AFFINITY
438 int fio_cpus_split(os_cpu_mask_t *mask, unsigned int cpu_index)
440 unsigned int i, index, cpus_in_mask;
441 const long max_cpu = cpus_online();
443 cpus_in_mask = fio_cpu_count(mask);
444 cpu_index = cpu_index % cpus_in_mask;
447 for (i = 0; i < max_cpu; i++) {
448 if (!fio_cpu_isset(mask, i))
451 if (cpu_index != index)
452 fio_cpu_clear(mask, i);
457 return fio_cpu_count(mask);
460 static int str_cpumask_cb(void *data, unsigned long long *val)
462 struct thread_data *td = cb_data_to_td(data);
470 ret = fio_cpuset_init(&td->o.cpumask);
472 log_err("fio: cpuset_init failed\n");
473 td_verror(td, ret, "fio_cpuset_init");
477 max_cpu = cpus_online();
479 for (i = 0; i < sizeof(int) * 8; i++) {
480 if ((1 << i) & *val) {
482 log_err("fio: CPU %d too large (max=%ld)\n", i,
486 dprint(FD_PARSE, "set cpu allowed %d\n", i);
487 fio_cpu_set(&td->o.cpumask, i);
494 static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask,
501 ret = fio_cpuset_init(mask);
503 log_err("fio: cpuset_init failed\n");
504 td_verror(td, ret, "fio_cpuset_init");
508 p = str = strdup(input);
510 strip_blank_front(&str);
511 strip_blank_end(str);
513 max_cpu = cpus_online();
515 while ((cpu = strsep(&str, ",")) != NULL) {
524 while ((cpu2 = strsep(&str2, "-")) != NULL) {
534 while (icpu <= icpu2) {
535 if (icpu >= FIO_MAX_CPUS) {
536 log_err("fio: your OS only supports up to"
537 " %d CPUs\n", (int) FIO_MAX_CPUS);
541 if (icpu >= max_cpu) {
542 log_err("fio: CPU %d too large (max=%ld)\n",
548 dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
549 fio_cpu_set(mask, icpu);
560 static int str_cpus_allowed_cb(void *data, const char *input)
562 struct thread_data *td = cb_data_to_td(data);
567 return set_cpus_allowed(td, &td->o.cpumask, input);
570 static int str_verify_cpus_allowed_cb(void *data, const char *input)
572 struct thread_data *td = cb_data_to_td(data);
577 return set_cpus_allowed(td, &td->o.verify_cpumask, input);
581 static int str_log_cpus_allowed_cb(void *data, const char *input)
583 struct thread_data *td = cb_data_to_td(data);
588 return set_cpus_allowed(td, &td->o.log_gz_cpumask, input);
590 #endif /* CONFIG_ZLIB */
592 #endif /* FIO_HAVE_CPU_AFFINITY */
594 #ifdef CONFIG_LIBNUMA
595 static int str_numa_cpunodes_cb(void *data, char *input)
597 struct thread_data *td = cb_data_to_td(data);
598 struct bitmask *verify_bitmask;
603 /* numa_parse_nodestring() parses a character string list
604 * of nodes into a bit mask. The bit mask is allocated by
605 * numa_allocate_nodemask(), so it should be freed by
606 * numa_free_nodemask().
608 verify_bitmask = numa_parse_nodestring(input);
609 if (verify_bitmask == NULL) {
610 log_err("fio: numa_parse_nodestring failed\n");
611 td_verror(td, 1, "str_numa_cpunodes_cb");
614 numa_free_nodemask(verify_bitmask);
616 td->o.numa_cpunodes = strdup(input);
620 static int str_numa_mpol_cb(void *data, char *input)
622 struct thread_data *td = cb_data_to_td(data);
623 const char * const policy_types[] =
624 { "default", "prefer", "bind", "interleave", "local", NULL };
627 struct bitmask *verify_bitmask;
632 nodelist = strchr(input, ':');
634 /* NUL-terminate mode */
638 for (i = 0; i <= MPOL_LOCAL; i++) {
639 if (!strcmp(input, policy_types[i])) {
640 td->o.numa_mem_mode = i;
644 if (i > MPOL_LOCAL) {
645 log_err("fio: memory policy should be: default, prefer, bind, interleave, local\n");
649 switch (td->o.numa_mem_mode) {
652 * Insist on a nodelist of one node only
655 char *rest = nodelist;
656 while (isdigit(*rest))
659 log_err("fio: one node only for \'prefer\'\n");
663 log_err("fio: one node is needed for \'prefer\'\n");
667 case MPOL_INTERLEAVE:
669 * Default to online nodes with memory if no nodelist
672 nodelist = strdup("all");
677 * Don't allow a nodelist
680 log_err("fio: NO nodelist for \'local\'\n");
686 * Insist on a nodelist
689 log_err("fio: a nodelist is needed for \'bind\'\n");
696 /* numa_parse_nodestring() parses a character string list
697 * of nodes into a bit mask. The bit mask is allocated by
698 * numa_allocate_nodemask(), so it should be freed by
699 * numa_free_nodemask().
701 switch (td->o.numa_mem_mode) {
703 td->o.numa_mem_prefer_node = atoi(nodelist);
705 case MPOL_INTERLEAVE:
707 verify_bitmask = numa_parse_nodestring(nodelist);
708 if (verify_bitmask == NULL) {
709 log_err("fio: numa_parse_nodestring failed\n");
710 td_verror(td, 1, "str_numa_memnodes_cb");
713 td->o.numa_memnodes = strdup(nodelist);
714 numa_free_nodemask(verify_bitmask);
729 static int str_fst_cb(void *data, const char *str)
731 struct thread_data *td = cb_data_to_td(data);
736 td->file_service_nr = 1;
738 switch (td->o.file_service_type) {
739 case FIO_FSERVICE_RANDOM:
740 case FIO_FSERVICE_RR:
741 case FIO_FSERVICE_SEQ:
742 nr = get_opt_postfix(str);
744 td->file_service_nr = atoi(nr);
749 case FIO_FSERVICE_ZIPF:
752 case FIO_FSERVICE_PARETO:
753 val = FIO_DEF_PARETO;
755 case FIO_FSERVICE_GAUSS:
759 log_err("fio: bad file service type: %d\n", td->o.file_service_type);
766 nr = get_opt_postfix(str);
767 if (nr && !str_to_float(nr, &val, 0)) {
768 log_err("fio: file service type random postfix parsing failed\n");
775 switch (td->o.file_service_type) {
776 case FIO_FSERVICE_ZIPF:
778 log_err("fio: zipf theta must be different than 1.0\n");
783 td->zipf_theta = val;
785 case FIO_FSERVICE_PARETO:
786 if (val <= 0.00 || val >= 1.00) {
787 log_err("fio: pareto input out of range (0 < input < 1.0)\n");
794 case FIO_FSERVICE_GAUSS:
795 if (val < 0.00 || val >= 100.00) {
796 log_err("fio: normal deviation out of range (0 <= input < 100.0)\n");
808 #ifdef CONFIG_SYNC_FILE_RANGE
809 static int str_sfr_cb(void *data, const char *str)
811 struct thread_data *td = cb_data_to_td(data);
812 char *nr = get_opt_postfix(str);
814 td->sync_file_range_nr = 1;
816 td->sync_file_range_nr = atoi(nr);
824 static int zone_cmp(const void *p1, const void *p2)
826 const struct zone_split *zsp1 = p1;
827 const struct zone_split *zsp2 = p2;
829 return (int) zsp2->access_perc - (int) zsp1->access_perc;
832 static int zone_split_ddir(struct thread_options *o, enum fio_ddir ddir,
835 unsigned int i, perc, perc_missing, sperc, sperc_missing;
838 memset(&split, 0, sizeof(split));
840 if (split_parse_ddir(o, &split, ddir, str))
845 o->zone_split[ddir] = malloc(split.nr * sizeof(struct zone_split));
846 o->zone_split_nr[ddir] = split.nr;
847 for (i = 0; i < split.nr; i++) {
848 o->zone_split[ddir][i].access_perc = split.val1[i];
849 o->zone_split[ddir][i].size_perc = split.val2[i];
853 * Now check if the percentages add up, and how much is missing
855 perc = perc_missing = 0;
856 sperc = sperc_missing = 0;
857 for (i = 0; i < o->zone_split_nr[ddir]; i++) {
858 struct zone_split *zsp = &o->zone_split[ddir][i];
860 if (zsp->access_perc == (uint8_t) -1U)
863 perc += zsp->access_perc;
865 if (zsp->size_perc == (uint8_t) -1U)
868 sperc += zsp->size_perc;
872 if (perc > 100 || sperc > 100) {
873 log_err("fio: zone_split percentages add to more than 100%%\n");
874 free(o->zone_split[ddir]);
875 o->zone_split[ddir] = NULL;
879 log_err("fio: access percentage don't add up to 100 for zoned "
880 "random distribution (got=%u)\n", perc);
881 free(o->zone_split[ddir]);
882 o->zone_split[ddir] = NULL;
887 * If values didn't have a percentage set, divide the remains between
891 if (perc_missing == 1 && o->zone_split_nr[ddir] == 1)
893 for (i = 0; i < o->zone_split_nr[ddir]; i++) {
894 struct zone_split *zsp = &o->zone_split[ddir][i];
896 if (zsp->access_perc == (uint8_t) -1U)
897 zsp->access_perc = (100 - perc) / perc_missing;
901 if (sperc_missing == 1 && o->zone_split_nr[ddir] == 1)
903 for (i = 0; i < o->zone_split_nr[ddir]; i++) {
904 struct zone_split *zsp = &o->zone_split[ddir][i];
906 if (zsp->size_perc == (uint8_t) -1U)
907 zsp->size_perc = (100 - sperc) / sperc_missing;
912 * now sort based on percentages, for ease of lookup
914 qsort(o->zone_split[ddir], o->zone_split_nr[ddir], sizeof(struct zone_split), zone_cmp);
918 static void __td_zone_gen_index(struct thread_data *td, enum fio_ddir ddir)
920 unsigned int i, j, sprev, aprev;
922 td->zone_state_index[ddir] = malloc(sizeof(struct zone_split_index) * 100);
925 for (i = 0; i < td->o.zone_split_nr[ddir]; i++) {
926 struct zone_split *zsp = &td->o.zone_split[ddir][i];
928 for (j = aprev; j < aprev + zsp->access_perc; j++) {
929 struct zone_split_index *zsi = &td->zone_state_index[ddir][j];
931 zsi->size_perc = sprev + zsp->size_perc;
932 zsi->size_perc_prev = sprev;
935 aprev += zsp->access_perc;
936 sprev += zsp->size_perc;
941 * Generate state table for indexes, so we don't have to do it inline from
944 static void td_zone_gen_index(struct thread_data *td)
948 td->zone_state_index = malloc(DDIR_RWDIR_CNT *
949 sizeof(struct zone_split_index *));
951 for (i = 0; i < DDIR_RWDIR_CNT; i++)
952 __td_zone_gen_index(td, i);
955 static int parse_zoned_distribution(struct thread_data *td, const char *input)
960 p = str = strdup(input);
962 strip_blank_front(&str);
963 strip_blank_end(str);
965 /* We expect it to start like that, bail if not */
966 if (strncmp(str, "zoned:", 6)) {
967 log_err("fio: mismatch in zoned input <%s>\n", str);
971 str += strlen("zoned:");
973 ret = str_split_parse(td, str, zone_split_ddir);
977 for (i = 0; i < DDIR_RWDIR_CNT; i++) {
980 dprint(FD_PARSE, "zone ddir %d (nr=%u): \n", i, td->o.zone_split_nr[i]);
982 for (j = 0; j < td->o.zone_split_nr[i]; j++) {
983 struct zone_split *zsp = &td->o.zone_split[i][j];
985 dprint(FD_PARSE, "\t%d: %u/%u\n", j, zsp->access_perc,
990 if (parse_dryrun()) {
993 for (i = 0; i < DDIR_RWDIR_CNT; i++) {
994 free(td->o.zone_split[i]);
995 td->o.zone_split[i] = NULL;
996 td->o.zone_split_nr[i] = 0;
1003 td_zone_gen_index(td);
1005 for (i = 0; i < DDIR_RWDIR_CNT; i++)
1006 td->o.zone_split_nr[i] = 0;
1012 static int str_random_distribution_cb(void *data, const char *str)
1014 struct thread_data *td = cb_data_to_td(data);
1018 if (td->o.random_distribution == FIO_RAND_DIST_ZIPF)
1020 else if (td->o.random_distribution == FIO_RAND_DIST_PARETO)
1021 val = FIO_DEF_PARETO;
1022 else if (td->o.random_distribution == FIO_RAND_DIST_GAUSS)
1024 else if (td->o.random_distribution == FIO_RAND_DIST_ZONED)
1025 return parse_zoned_distribution(td, str);
1029 nr = get_opt_postfix(str);
1030 if (nr && !str_to_float(nr, &val, 0)) {
1031 log_err("fio: random postfix parsing failed\n");
1038 if (td->o.random_distribution == FIO_RAND_DIST_ZIPF) {
1040 log_err("fio: zipf theta must different than 1.0\n");
1045 td->o.zipf_theta.u.f = val;
1046 } else if (td->o.random_distribution == FIO_RAND_DIST_PARETO) {
1047 if (val <= 0.00 || val >= 1.00) {
1048 log_err("fio: pareto input out of range (0 < input < 1.0)\n");
1053 td->o.pareto_h.u.f = val;
1055 if (val < 0.00 || val >= 100.0) {
1056 log_err("fio: normal deviation out of range (0 <= input < 100.0)\n");
1061 td->o.gauss_dev.u.f = val;
1067 static int str_steadystate_cb(void *data, const char *str)
1069 struct thread_data *td = cb_data_to_td(data);
1075 if (td->o.ss_state != FIO_SS_IOPS && td->o.ss_state != FIO_SS_IOPS_SLOPE &&
1076 td->o.ss_state != FIO_SS_BW && td->o.ss_state != FIO_SS_BW_SLOPE) {
1077 /* should be impossible to get here */
1078 log_err("fio: unknown steady state criterion\n");
1082 nr = get_opt_postfix(str);
1084 log_err("fio: steadystate threshold must be specified in addition to criterion\n");
1089 /* ENHANCEMENT Allow fio to understand size=10.2% and use here */
1090 pct = strstr(nr, "%");
1093 strip_blank_end(nr);
1094 if (!str_to_float(nr, &val, 0)) {
1095 log_err("fio: could not parse steadystate threshold percentage\n");
1100 dprint(FD_PARSE, "set steady state threshold to %f%%\n", val);
1105 td->o.ss_state |= __FIO_SS_PCT;
1106 td->o.ss_limit.u.f = val;
1107 } else if (td->o.ss_state & __FIO_SS_IOPS) {
1108 if (!str_to_float(nr, &val, 0)) {
1109 log_err("fio: steadystate IOPS threshold postfix parsing failed\n");
1114 dprint(FD_PARSE, "set steady state IOPS threshold to %f\n", val);
1119 td->o.ss_limit.u.f = val;
1120 } else { /* bandwidth criterion */
1121 if (str_to_decimal(nr, &ll, 1, td, 0, 0)) {
1122 log_err("fio: steadystate BW threshold postfix parsing failed\n");
1127 dprint(FD_PARSE, "set steady state BW threshold to %lld\n", ll);
1132 td->o.ss_limit.u.f = (double) ll;
1135 td->ss.state = td->o.ss_state;
1140 * Return next name in the string. Files are separated with ':'. If the ':'
1141 * is escaped with a '\', then that ':' is part of the filename and does not
1142 * indicate a new file.
1144 static char *get_next_name(char **ptr)
1149 if (!str || !strlen(str))
1155 * No colon, we are done
1157 p = strchr(str, ':');
1164 * We got a colon, but it's the first character. Skip and
1172 if (*(p - 1) != '\\') {
1178 memmove(p - 1, p, strlen(p) + 1);
1186 static int get_max_name_idx(char *input)
1188 unsigned int cur_idx;
1191 p = str = strdup(input);
1192 for (cur_idx = 0; ; cur_idx++)
1193 if (get_next_name(&str) == NULL)
1201 * Returns the directory at the index, indexes > entires will be
1202 * assigned via modulo division of the index
1204 int set_name_idx(char *target, size_t tlen, char *input, int index,
1205 bool unique_filename)
1207 unsigned int cur_idx;
1209 char *fname, *str, *p;
1211 p = str = strdup(input);
1213 index %= get_max_name_idx(input);
1214 for (cur_idx = 0; cur_idx <= index; cur_idx++)
1215 fname = get_next_name(&str);
1217 if (client_sockaddr_str[0] && unique_filename) {
1218 len = snprintf(target, tlen, "%s/%s.", fname,
1219 client_sockaddr_str);
1221 len = snprintf(target, tlen, "%s/", fname);
1223 target[tlen - 1] = '\0';
1229 static int str_filename_cb(void *data, const char *input)
1231 struct thread_data *td = cb_data_to_td(data);
1232 char *fname, *str, *p;
1234 p = str = strdup(input);
1236 strip_blank_front(&str);
1237 strip_blank_end(str);
1240 * Ignore what we may already have from nrfiles option.
1242 if (!td->files_index)
1245 while ((fname = get_next_name(&str)) != NULL) {
1248 add_file(td, fname, 0, 1);
1255 static int str_directory_cb(void *data, const char fio_unused *unused)
1257 struct thread_data *td = cb_data_to_td(data);
1259 char *dirname, *str, *p;
1265 p = str = strdup(td->o.directory);
1266 while ((dirname = get_next_name(&str)) != NULL) {
1267 if (lstat(dirname, &sb) < 0) {
1270 log_err("fio: %s is not a directory\n", dirname);
1271 td_verror(td, ret, "lstat");
1274 if (!S_ISDIR(sb.st_mode)) {
1275 log_err("fio: %s is not a directory\n", dirname);
1286 static int str_opendir_cb(void *data, const char fio_unused *str)
1288 struct thread_data *td = cb_data_to_td(data);
1293 if (!td->files_index)
1296 return add_dir_files(td, td->o.opendir);
1299 static int str_buffer_pattern_cb(void *data, const char *input)
1301 struct thread_data *td = cb_data_to_td(data);
1304 /* FIXME: for now buffer pattern does not support formats */
1305 ret = parse_and_fill_pattern(input, strlen(input), td->o.buffer_pattern,
1306 MAX_PATTERN_SIZE, NULL, 0, NULL, NULL);
1311 td->o.buffer_pattern_bytes = ret;
1314 * If this job is doing any reading or has compression set,
1315 * ensure that we refill buffers for writes or we could be
1316 * invalidating the pattern through reads.
1318 if (!td->o.compress_percentage && !td_read(td))
1319 td->o.refill_buffers = 0;
1321 td->o.refill_buffers = 1;
1323 td->o.scramble_buffers = 0;
1324 td->o.zero_buffers = 0;
1329 static int str_buffer_compress_cb(void *data, unsigned long long *il)
1331 struct thread_data *td = cb_data_to_td(data);
1333 td->flags |= TD_F_COMPRESS;
1334 td->o.compress_percentage = *il;
1338 static int str_dedupe_cb(void *data, unsigned long long *il)
1340 struct thread_data *td = cb_data_to_td(data);
1342 td->flags |= TD_F_COMPRESS;
1343 td->o.dedupe_percentage = *il;
1344 td->o.refill_buffers = 1;
1348 static int str_verify_pattern_cb(void *data, const char *input)
1350 struct thread_data *td = cb_data_to_td(data);
1353 td->o.verify_fmt_sz = ARRAY_SIZE(td->o.verify_fmt);
1354 ret = parse_and_fill_pattern(input, strlen(input), td->o.verify_pattern,
1355 MAX_PATTERN_SIZE, fmt_desc, sizeof(fmt_desc),
1356 td->o.verify_fmt, &td->o.verify_fmt_sz);
1361 td->o.verify_pattern_bytes = ret;
1363 * VERIFY_* could already be set
1365 if (!fio_option_is_set(&td->o, verify))
1366 td->o.verify = VERIFY_PATTERN;
1371 static int str_gtod_reduce_cb(void *data, int *il)
1373 struct thread_data *td = cb_data_to_td(data);
1376 td->o.disable_lat = !!val;
1377 td->o.disable_clat = !!val;
1378 td->o.disable_slat = !!val;
1379 td->o.disable_bw = !!val;
1380 td->o.clat_percentiles = !val;
1382 td->tv_cache_mask = 63;
1387 static int str_offset_cb(void *data, unsigned long long *__val)
1389 struct thread_data *td = cb_data_to_td(data);
1390 unsigned long long v = *__val;
1392 if (parse_is_percent(v)) {
1393 td->o.start_offset = 0;
1394 td->o.start_offset_percent = -1ULL - v;
1395 dprint(FD_PARSE, "SET start_offset_percent %d\n",
1396 td->o.start_offset_percent);
1398 td->o.start_offset = v;
1403 static int str_size_cb(void *data, unsigned long long *__val)
1405 struct thread_data *td = cb_data_to_td(data);
1406 unsigned long long v = *__val;
1408 if (parse_is_percent(v)) {
1410 td->o.size_percent = -1ULL - v;
1417 static int str_write_bw_log_cb(void *data, const char *str)
1419 struct thread_data *td = cb_data_to_td(data);
1422 td->o.bw_log_file = strdup(str);
1424 td->o.write_bw_log = 1;
1428 static int str_write_lat_log_cb(void *data, const char *str)
1430 struct thread_data *td = cb_data_to_td(data);
1433 td->o.lat_log_file = strdup(str);
1435 td->o.write_lat_log = 1;
1439 static int str_write_iops_log_cb(void *data, const char *str)
1441 struct thread_data *td = cb_data_to_td(data);
1444 td->o.iops_log_file = strdup(str);
1446 td->o.write_iops_log = 1;
1450 static int str_write_hist_log_cb(void *data, const char *str)
1452 struct thread_data *td = cb_data_to_td(data);
1455 td->o.hist_log_file = strdup(str);
1457 td->o.write_hist_log = 1;
1461 static int rw_verify(struct fio_option *o, void *data)
1463 struct thread_data *td = cb_data_to_td(data);
1465 if (read_only && td_write(td)) {
1466 log_err("fio: job <%s> has write bit set, but fio is in"
1467 " read-only mode\n", td->o.name);
1474 static int gtod_cpu_verify(struct fio_option *o, void *data)
1476 #ifndef FIO_HAVE_CPU_AFFINITY
1477 struct thread_data *td = cb_data_to_td(data);
1479 if (td->o.gtod_cpu) {
1480 log_err("fio: platform must support CPU affinity for"
1481 "gettimeofday() offloading\n");
1490 * Map of job/command line options
1492 struct fio_option fio_options[FIO_MAX_OPTS] = {
1494 .name = "description",
1495 .lname = "Description of job",
1496 .type = FIO_OPT_STR_STORE,
1497 .off1 = offsetof(struct thread_options, description),
1498 .help = "Text job description",
1499 .category = FIO_OPT_C_GENERAL,
1500 .group = FIO_OPT_G_DESC,
1504 .lname = "Job name",
1505 .type = FIO_OPT_STR_STORE,
1506 .off1 = offsetof(struct thread_options, name),
1507 .help = "Name of this job",
1508 .category = FIO_OPT_C_GENERAL,
1509 .group = FIO_OPT_G_DESC,
1513 .lname = "Waitee name",
1514 .type = FIO_OPT_STR_STORE,
1515 .off1 = offsetof(struct thread_options, wait_for),
1516 .help = "Name of the job this one wants to wait for before starting",
1517 .category = FIO_OPT_C_GENERAL,
1518 .group = FIO_OPT_G_DESC,
1522 .lname = "Filename(s)",
1523 .type = FIO_OPT_STR_STORE,
1524 .off1 = offsetof(struct thread_options, filename),
1525 .cb = str_filename_cb,
1526 .prio = -1, /* must come after "directory" */
1527 .help = "File(s) to use for the workload",
1528 .category = FIO_OPT_C_FILE,
1529 .group = FIO_OPT_G_FILENAME,
1532 .name = "directory",
1533 .lname = "Directory",
1534 .type = FIO_OPT_STR_STORE,
1535 .off1 = offsetof(struct thread_options, directory),
1536 .cb = str_directory_cb,
1537 .help = "Directory to store files in",
1538 .category = FIO_OPT_C_FILE,
1539 .group = FIO_OPT_G_FILENAME,
1542 .name = "filename_format",
1543 .lname = "Filename Format",
1544 .type = FIO_OPT_STR_STORE,
1545 .off1 = offsetof(struct thread_options, filename_format),
1546 .prio = -1, /* must come after "directory" */
1547 .help = "Override default $jobname.$jobnum.$filenum naming",
1548 .def = "$jobname.$jobnum.$filenum",
1549 .category = FIO_OPT_C_FILE,
1550 .group = FIO_OPT_G_FILENAME,
1553 .name = "unique_filename",
1554 .lname = "Unique Filename",
1555 .type = FIO_OPT_BOOL,
1556 .off1 = offsetof(struct thread_options, unique_filename),
1557 .help = "For network clients, prefix file with source IP",
1559 .category = FIO_OPT_C_FILE,
1560 .group = FIO_OPT_G_FILENAME,
1564 .lname = "Lockfile",
1565 .type = FIO_OPT_STR,
1566 .off1 = offsetof(struct thread_options, file_lock_mode),
1567 .help = "Lock file when doing IO to it",
1569 .parent = "filename",
1572 .category = FIO_OPT_C_FILE,
1573 .group = FIO_OPT_G_FILENAME,
1576 .oval = FILE_LOCK_NONE,
1577 .help = "No file locking",
1579 { .ival = "exclusive",
1580 .oval = FILE_LOCK_EXCLUSIVE,
1581 .help = "Exclusive file lock",
1584 .ival = "readwrite",
1585 .oval = FILE_LOCK_READWRITE,
1586 .help = "Read vs write lock",
1592 .lname = "Open directory",
1593 .type = FIO_OPT_STR_STORE,
1594 .off1 = offsetof(struct thread_options, opendir),
1595 .cb = str_opendir_cb,
1596 .help = "Recursively add files from this directory and down",
1597 .category = FIO_OPT_C_FILE,
1598 .group = FIO_OPT_G_FILENAME,
1602 .lname = "Read/write",
1603 .alias = "readwrite",
1604 .type = FIO_OPT_STR,
1606 .off1 = offsetof(struct thread_options, td_ddir),
1607 .help = "IO direction",
1609 .verify = rw_verify,
1610 .category = FIO_OPT_C_IO,
1611 .group = FIO_OPT_G_IO_BASIC,
1614 .oval = TD_DDIR_READ,
1615 .help = "Sequential read",
1618 .oval = TD_DDIR_WRITE,
1619 .help = "Sequential write",
1622 .oval = TD_DDIR_TRIM,
1623 .help = "Sequential trim",
1625 { .ival = "randread",
1626 .oval = TD_DDIR_RANDREAD,
1627 .help = "Random read",
1629 { .ival = "randwrite",
1630 .oval = TD_DDIR_RANDWRITE,
1631 .help = "Random write",
1633 { .ival = "randtrim",
1634 .oval = TD_DDIR_RANDTRIM,
1635 .help = "Random trim",
1639 .help = "Sequential read and write mix",
1641 { .ival = "readwrite",
1643 .help = "Sequential read and write mix",
1646 .oval = TD_DDIR_RANDRW,
1647 .help = "Random read and write mix"
1649 { .ival = "trimwrite",
1650 .oval = TD_DDIR_TRIMWRITE,
1651 .help = "Trim and write mix, trims preceding writes"
1656 .name = "rw_sequencer",
1657 .lname = "RW Sequencer",
1658 .type = FIO_OPT_STR,
1659 .off1 = offsetof(struct thread_options, rw_seq),
1660 .help = "IO offset generator modifier",
1661 .def = "sequential",
1662 .category = FIO_OPT_C_IO,
1663 .group = FIO_OPT_G_IO_BASIC,
1665 { .ival = "sequential",
1667 .help = "Generate sequential offsets",
1669 { .ival = "identical",
1670 .oval = RW_SEQ_IDENT,
1671 .help = "Generate identical offsets",
1678 .lname = "IO Engine",
1679 .type = FIO_OPT_STR_STORE,
1680 .off1 = offsetof(struct thread_options, ioengine),
1681 .help = "IO engine to use",
1682 .def = FIO_PREFERRED_ENGINE,
1683 .category = FIO_OPT_C_IO,
1684 .group = FIO_OPT_G_IO_BASIC,
1687 .help = "Use read/write",
1690 .help = "Use pread/pwrite",
1693 .help = "Use readv/writev",
1695 #ifdef CONFIG_PWRITEV
1697 .help = "Use preadv/pwritev",
1700 #ifdef FIO_HAVE_PWRITEV2
1701 { .ival = "pvsync2",
1702 .help = "Use preadv2/pwritev2",
1705 #ifdef CONFIG_LIBAIO
1707 .help = "Linux native asynchronous IO",
1710 #ifdef CONFIG_POSIXAIO
1711 { .ival = "posixaio",
1712 .help = "POSIX asynchronous IO",
1715 #ifdef CONFIG_SOLARISAIO
1716 { .ival = "solarisaio",
1717 .help = "Solaris native asynchronous IO",
1720 #ifdef CONFIG_WINDOWSAIO
1721 { .ival = "windowsaio",
1722 .help = "Windows native asynchronous IO"
1727 .help = "Rados Block Device asynchronous IO"
1731 .help = "Memory mapped IO"
1733 #ifdef CONFIG_LINUX_SPLICE
1735 .help = "splice/vmsplice based IO",
1737 { .ival = "netsplice",
1738 .help = "splice/vmsplice to/from the network",
1741 #ifdef FIO_HAVE_SGIO
1743 .help = "SCSI generic v3 IO",
1747 .help = "Testing engine (no data transfer)",
1750 .help = "Network IO",
1753 .help = "CPU cycle burner engine",
1757 .help = "GUASI IO engine",
1760 #ifdef FIO_HAVE_BINJECT
1761 { .ival = "binject",
1762 .help = "binject direct inject block engine",
1767 .help = "RDMA IO engine",
1770 #ifdef CONFIG_FUSION_AW
1771 { .ival = "fusion-aw-sync",
1772 .help = "Fusion-io atomic write engine",
1775 #ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
1776 { .ival = "e4defrag",
1777 .help = "ext4 defrag engine",
1780 #ifdef CONFIG_LINUX_FALLOCATE
1782 .help = "fallocate() file based engine",
1787 .help = "Glusterfs libgfapi(sync) based engine"
1789 { .ival = "gfapi_async",
1790 .help = "Glusterfs libgfapi(async) based engine"
1793 #ifdef CONFIG_LIBHDFS
1794 { .ival = "libhdfs",
1795 .help = "Hadoop Distributed Filesystem (HDFS) engine"
1798 #ifdef CONFIG_PMEMBLK
1799 { .ival = "pmemblk",
1800 .help = "NVML libpmemblk based IO engine",
1804 #ifdef CONFIG_LINUX_DEVDAX
1805 { .ival = "dev-dax",
1806 .help = "DAX Device based IO engine",
1809 { .ival = "external",
1810 .help = "Load external engine (append name)",
1816 .lname = "IO Depth",
1817 .type = FIO_OPT_INT,
1818 .off1 = offsetof(struct thread_options, iodepth),
1819 .help = "Number of IO buffers to keep in flight",
1823 .category = FIO_OPT_C_IO,
1824 .group = FIO_OPT_G_IO_BASIC,
1827 .name = "iodepth_batch",
1828 .lname = "IO Depth batch",
1829 .alias = "iodepth_batch_submit",
1830 .type = FIO_OPT_INT,
1831 .off1 = offsetof(struct thread_options, iodepth_batch),
1832 .help = "Number of IO buffers to submit in one go",
1833 .parent = "iodepth",
1837 .category = FIO_OPT_C_IO,
1838 .group = FIO_OPT_G_IO_BASIC,
1841 .name = "iodepth_batch_complete_min",
1842 .lname = "Min IO depth batch complete",
1843 .alias = "iodepth_batch_complete",
1844 .type = FIO_OPT_INT,
1845 .off1 = offsetof(struct thread_options, iodepth_batch_complete_min),
1846 .help = "Min number of IO buffers to retrieve in one go",
1847 .parent = "iodepth",
1852 .category = FIO_OPT_C_IO,
1853 .group = FIO_OPT_G_IO_BASIC,
1856 .name = "iodepth_batch_complete_max",
1857 .lname = "Max IO depth batch complete",
1858 .type = FIO_OPT_INT,
1859 .off1 = offsetof(struct thread_options, iodepth_batch_complete_max),
1860 .help = "Max number of IO buffers to retrieve in one go",
1861 .parent = "iodepth",
1865 .category = FIO_OPT_C_IO,
1866 .group = FIO_OPT_G_IO_BASIC,
1869 .name = "iodepth_low",
1870 .lname = "IO Depth batch low",
1871 .type = FIO_OPT_INT,
1872 .off1 = offsetof(struct thread_options, iodepth_low),
1873 .help = "Low water mark for queuing depth",
1874 .parent = "iodepth",
1877 .category = FIO_OPT_C_IO,
1878 .group = FIO_OPT_G_IO_BASIC,
1881 .name = "io_submit_mode",
1882 .lname = "IO submit mode",
1883 .type = FIO_OPT_STR,
1884 .off1 = offsetof(struct thread_options, io_submit_mode),
1885 .help = "How IO submissions and completions are done",
1887 .category = FIO_OPT_C_IO,
1888 .group = FIO_OPT_G_IO_BASIC,
1891 .oval = IO_MODE_INLINE,
1892 .help = "Submit and complete IO inline",
1894 { .ival = "offload",
1895 .oval = IO_MODE_OFFLOAD,
1896 .help = "Offload submit and complete to threads",
1903 .type = FIO_OPT_STR_VAL,
1905 .off1 = offsetof(struct thread_options, size),
1906 .help = "Total size of device or files",
1907 .interval = 1024 * 1024,
1908 .category = FIO_OPT_C_IO,
1909 .group = FIO_OPT_G_INVALID,
1913 .alias = "io_limit",
1915 .type = FIO_OPT_STR_VAL,
1916 .off1 = offsetof(struct thread_options, io_size),
1917 .help = "Total size of I/O to be performed",
1918 .interval = 1024 * 1024,
1919 .category = FIO_OPT_C_IO,
1920 .group = FIO_OPT_G_INVALID,
1923 .name = "fill_device",
1924 .lname = "Fill device",
1926 .type = FIO_OPT_BOOL,
1927 .off1 = offsetof(struct thread_options, fill_device),
1928 .help = "Write until an ENOSPC error occurs",
1930 .category = FIO_OPT_C_FILE,
1931 .group = FIO_OPT_G_INVALID,
1935 .lname = "File size",
1936 .type = FIO_OPT_STR_VAL,
1937 .off1 = offsetof(struct thread_options, file_size_low),
1938 .off2 = offsetof(struct thread_options, file_size_high),
1940 .help = "Size of individual files",
1941 .interval = 1024 * 1024,
1942 .category = FIO_OPT_C_FILE,
1943 .group = FIO_OPT_G_INVALID,
1946 .name = "file_append",
1947 .lname = "File append",
1948 .type = FIO_OPT_BOOL,
1949 .off1 = offsetof(struct thread_options, file_append),
1950 .help = "IO will start at the end of the file(s)",
1952 .category = FIO_OPT_C_FILE,
1953 .group = FIO_OPT_G_INVALID,
1957 .lname = "IO offset",
1958 .alias = "fileoffset",
1959 .type = FIO_OPT_STR_VAL,
1960 .cb = str_offset_cb,
1961 .off1 = offsetof(struct thread_options, start_offset),
1962 .help = "Start IO from this offset",
1964 .interval = 1024 * 1024,
1965 .category = FIO_OPT_C_IO,
1966 .group = FIO_OPT_G_INVALID,
1969 .name = "offset_increment",
1970 .lname = "IO offset increment",
1971 .type = FIO_OPT_STR_VAL,
1972 .off1 = offsetof(struct thread_options, offset_increment),
1973 .help = "What is the increment from one offset to the next",
1977 .interval = 1024 * 1024,
1978 .category = FIO_OPT_C_IO,
1979 .group = FIO_OPT_G_INVALID,
1982 .name = "number_ios",
1983 .lname = "Number of IOs to perform",
1984 .type = FIO_OPT_STR_VAL,
1985 .off1 = offsetof(struct thread_options, number_ios),
1986 .help = "Force job completion after this number of IOs",
1988 .category = FIO_OPT_C_IO,
1989 .group = FIO_OPT_G_INVALID,
1993 .lname = "Block size",
1994 .alias = "blocksize",
1995 .type = FIO_OPT_INT,
1996 .off1 = offsetof(struct thread_options, bs[DDIR_READ]),
1997 .off2 = offsetof(struct thread_options, bs[DDIR_WRITE]),
1998 .off3 = offsetof(struct thread_options, bs[DDIR_TRIM]),
2000 .help = "Block size unit",
2005 .category = FIO_OPT_C_IO,
2006 .group = FIO_OPT_G_INVALID,
2010 .lname = "Block size align",
2011 .alias = "blockalign",
2012 .type = FIO_OPT_INT,
2013 .off1 = offsetof(struct thread_options, ba[DDIR_READ]),
2014 .off2 = offsetof(struct thread_options, ba[DDIR_WRITE]),
2015 .off3 = offsetof(struct thread_options, ba[DDIR_TRIM]),
2017 .help = "IO block offset alignment",
2021 .category = FIO_OPT_C_IO,
2022 .group = FIO_OPT_G_INVALID,
2026 .lname = "Block size range",
2027 .alias = "blocksize_range",
2028 .type = FIO_OPT_RANGE,
2029 .off1 = offsetof(struct thread_options, min_bs[DDIR_READ]),
2030 .off2 = offsetof(struct thread_options, max_bs[DDIR_READ]),
2031 .off3 = offsetof(struct thread_options, min_bs[DDIR_WRITE]),
2032 .off4 = offsetof(struct thread_options, max_bs[DDIR_WRITE]),
2033 .off5 = offsetof(struct thread_options, min_bs[DDIR_TRIM]),
2034 .off6 = offsetof(struct thread_options, max_bs[DDIR_TRIM]),
2036 .help = "Set block size range (in more detail than bs)",
2040 .category = FIO_OPT_C_IO,
2041 .group = FIO_OPT_G_INVALID,
2045 .lname = "Block size split",
2046 .type = FIO_OPT_STR,
2047 .cb = str_bssplit_cb,
2048 .off1 = offsetof(struct thread_options, bssplit),
2049 .help = "Set a specific mix of block sizes",
2052 .category = FIO_OPT_C_IO,
2053 .group = FIO_OPT_G_INVALID,
2056 .name = "bs_unaligned",
2057 .lname = "Block size unaligned",
2058 .alias = "blocksize_unaligned",
2059 .type = FIO_OPT_STR_SET,
2060 .off1 = offsetof(struct thread_options, bs_unaligned),
2061 .help = "Don't sector align IO buffer sizes",
2064 .category = FIO_OPT_C_IO,
2065 .group = FIO_OPT_G_INVALID,
2068 .name = "bs_is_seq_rand",
2069 .lname = "Block size division is seq/random (not read/write)",
2070 .type = FIO_OPT_BOOL,
2071 .off1 = offsetof(struct thread_options, bs_is_seq_rand),
2072 .help = "Consider any blocksize setting to be sequential,random",
2074 .parent = "blocksize",
2075 .category = FIO_OPT_C_IO,
2076 .group = FIO_OPT_G_INVALID,
2079 .name = "randrepeat",
2080 .lname = "Random repeatable",
2081 .type = FIO_OPT_BOOL,
2082 .off1 = offsetof(struct thread_options, rand_repeatable),
2083 .help = "Use repeatable random IO pattern",
2087 .category = FIO_OPT_C_IO,
2088 .group = FIO_OPT_G_RANDOM,
2092 .lname = "The random generator seed",
2093 .type = FIO_OPT_STR_VAL,
2094 .off1 = offsetof(struct thread_options, rand_seed),
2095 .help = "Set the random generator seed value",
2098 .category = FIO_OPT_C_IO,
2099 .group = FIO_OPT_G_RANDOM,
2102 .name = "use_os_rand",
2103 .lname = "Use OS random",
2104 .type = FIO_OPT_DEPRECATED,
2105 .off1 = offsetof(struct thread_options, dep_use_os_rand),
2106 .category = FIO_OPT_C_IO,
2107 .group = FIO_OPT_G_RANDOM,
2110 .name = "norandommap",
2111 .lname = "No randommap",
2112 .type = FIO_OPT_STR_SET,
2113 .off1 = offsetof(struct thread_options, norandommap),
2114 .help = "Accept potential duplicate random blocks",
2118 .category = FIO_OPT_C_IO,
2119 .group = FIO_OPT_G_RANDOM,
2122 .name = "softrandommap",
2123 .lname = "Soft randommap",
2124 .type = FIO_OPT_BOOL,
2125 .off1 = offsetof(struct thread_options, softrandommap),
2126 .help = "Set norandommap if randommap allocation fails",
2127 .parent = "norandommap",
2130 .category = FIO_OPT_C_IO,
2131 .group = FIO_OPT_G_RANDOM,
2134 .name = "random_generator",
2135 .lname = "Random Generator",
2136 .type = FIO_OPT_STR,
2137 .off1 = offsetof(struct thread_options, random_generator),
2138 .help = "Type of random number generator to use",
2139 .def = "tausworthe",
2141 { .ival = "tausworthe",
2142 .oval = FIO_RAND_GEN_TAUSWORTHE,
2143 .help = "Strong Tausworthe generator",
2146 .oval = FIO_RAND_GEN_LFSR,
2147 .help = "Variable length LFSR",
2150 .ival = "tausworthe64",
2151 .oval = FIO_RAND_GEN_TAUSWORTHE64,
2152 .help = "64-bit Tausworthe variant",
2155 .category = FIO_OPT_C_IO,
2156 .group = FIO_OPT_G_RANDOM,
2159 .name = "random_distribution",
2160 .lname = "Random Distribution",
2161 .type = FIO_OPT_STR,
2162 .off1 = offsetof(struct thread_options, random_distribution),
2163 .cb = str_random_distribution_cb,
2164 .help = "Random offset distribution generator",
2168 .oval = FIO_RAND_DIST_RANDOM,
2169 .help = "Completely random",
2172 .oval = FIO_RAND_DIST_ZIPF,
2173 .help = "Zipf distribution",
2176 .oval = FIO_RAND_DIST_PARETO,
2177 .help = "Pareto distribution",
2180 .oval = FIO_RAND_DIST_GAUSS,
2181 .help = "Normal (Gaussian) distribution",
2184 .oval = FIO_RAND_DIST_ZONED,
2185 .help = "Zoned random distribution",
2189 .category = FIO_OPT_C_IO,
2190 .group = FIO_OPT_G_RANDOM,
2193 .name = "percentage_random",
2194 .lname = "Percentage Random",
2195 .type = FIO_OPT_INT,
2196 .off1 = offsetof(struct thread_options, perc_rand[DDIR_READ]),
2197 .off2 = offsetof(struct thread_options, perc_rand[DDIR_WRITE]),
2198 .off3 = offsetof(struct thread_options, perc_rand[DDIR_TRIM]),
2200 .help = "Percentage of seq/random mix that should be random",
2201 .def = "100,100,100",
2203 .inverse = "percentage_sequential",
2204 .category = FIO_OPT_C_IO,
2205 .group = FIO_OPT_G_RANDOM,
2208 .name = "percentage_sequential",
2209 .lname = "Percentage Sequential",
2210 .type = FIO_OPT_DEPRECATED,
2211 .category = FIO_OPT_C_IO,
2212 .group = FIO_OPT_G_RANDOM,
2215 .name = "allrandrepeat",
2216 .lname = "All Random Repeat",
2217 .type = FIO_OPT_BOOL,
2218 .off1 = offsetof(struct thread_options, allrand_repeatable),
2219 .help = "Use repeatable random numbers for everything",
2221 .category = FIO_OPT_C_IO,
2222 .group = FIO_OPT_G_RANDOM,
2226 .lname = "Number of files",
2227 .alias = "nr_files",
2228 .type = FIO_OPT_INT,
2229 .off1 = offsetof(struct thread_options, nr_files),
2230 .help = "Split job workload between this number of files",
2233 .category = FIO_OPT_C_FILE,
2234 .group = FIO_OPT_G_INVALID,
2237 .name = "openfiles",
2238 .lname = "Number of open files",
2239 .type = FIO_OPT_INT,
2240 .off1 = offsetof(struct thread_options, open_files),
2241 .help = "Number of files to keep open at the same time",
2242 .category = FIO_OPT_C_FILE,
2243 .group = FIO_OPT_G_INVALID,
2246 .name = "file_service_type",
2247 .lname = "File service type",
2248 .type = FIO_OPT_STR,
2250 .off1 = offsetof(struct thread_options, file_service_type),
2251 .help = "How to select which file to service next",
2252 .def = "roundrobin",
2253 .category = FIO_OPT_C_FILE,
2254 .group = FIO_OPT_G_INVALID,
2257 .oval = FIO_FSERVICE_RANDOM,
2258 .help = "Choose a file at random (uniform)",
2261 .oval = FIO_FSERVICE_ZIPF,
2262 .help = "Zipf randomized",
2265 .oval = FIO_FSERVICE_PARETO,
2266 .help = "Pareto randomized",
2269 .oval = FIO_FSERVICE_GAUSS,
2270 .help = "Normal (Gaussian) distribution",
2272 { .ival = "roundrobin",
2273 .oval = FIO_FSERVICE_RR,
2274 .help = "Round robin select files",
2276 { .ival = "sequential",
2277 .oval = FIO_FSERVICE_SEQ,
2278 .help = "Finish one file before moving to the next",
2281 .parent = "nrfiles",
2284 #ifdef CONFIG_POSIX_FALLOCATE
2286 .name = "fallocate",
2287 .lname = "Fallocate",
2288 .type = FIO_OPT_STR,
2289 .off1 = offsetof(struct thread_options, fallocate_mode),
2290 .help = "Whether pre-allocation is performed when laying out files",
2292 .category = FIO_OPT_C_FILE,
2293 .group = FIO_OPT_G_INVALID,
2296 .oval = FIO_FALLOCATE_NONE,
2297 .help = "Do not pre-allocate space",
2300 .oval = FIO_FALLOCATE_POSIX,
2301 .help = "Use posix_fallocate()",
2303 #ifdef CONFIG_LINUX_FALLOCATE
2305 .oval = FIO_FALLOCATE_KEEP_SIZE,
2306 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
2309 /* Compatibility with former boolean values */
2311 .oval = FIO_FALLOCATE_NONE,
2312 .help = "Alias for 'none'",
2315 .oval = FIO_FALLOCATE_POSIX,
2316 .help = "Alias for 'posix'",
2320 #else /* CONFIG_POSIX_FALLOCATE */
2322 .name = "fallocate",
2323 .lname = "Fallocate",
2324 .type = FIO_OPT_UNSUPPORTED,
2325 .help = "Your platform does not support fallocate",
2327 #endif /* CONFIG_POSIX_FALLOCATE */
2329 .name = "fadvise_hint",
2330 .lname = "Fadvise hint",
2331 .type = FIO_OPT_STR,
2332 .off1 = offsetof(struct thread_options, fadvise_hint),
2336 .help = "Don't issue fadvise",
2340 .help = "Advise using fio IO pattern",
2343 .oval = F_ADV_RANDOM,
2344 .help = "Advise using FADV_RANDOM",
2346 { .ival = "sequential",
2347 .oval = F_ADV_SEQUENTIAL,
2348 .help = "Advise using FADV_SEQUENTIAL",
2351 .help = "Use fadvise() to advise the kernel on IO pattern",
2353 .category = FIO_OPT_C_FILE,
2354 .group = FIO_OPT_G_INVALID,
2356 #ifdef FIO_HAVE_STREAMID
2358 .name = "fadvise_stream",
2359 .lname = "Fadvise stream",
2360 .type = FIO_OPT_INT,
2361 .off1 = offsetof(struct thread_options, fadvise_stream),
2362 .help = "Use fadvise() to set stream ID",
2363 .category = FIO_OPT_C_FILE,
2364 .group = FIO_OPT_G_INVALID,
2368 .name = "fadvise_stream",
2369 .lname = "Fadvise stream",
2370 .type = FIO_OPT_UNSUPPORTED,
2371 .help = "Your platform does not support fadvise stream ID",
2377 .type = FIO_OPT_INT,
2378 .off1 = offsetof(struct thread_options, fsync_blocks),
2379 .help = "Issue fsync for writes every given number of blocks",
2382 .category = FIO_OPT_C_FILE,
2383 .group = FIO_OPT_G_INVALID,
2386 .name = "fdatasync",
2387 .lname = "Fdatasync",
2388 .type = FIO_OPT_INT,
2389 .off1 = offsetof(struct thread_options, fdatasync_blocks),
2390 .help = "Issue fdatasync for writes every given number of blocks",
2393 .category = FIO_OPT_C_FILE,
2394 .group = FIO_OPT_G_INVALID,
2397 .name = "write_barrier",
2398 .lname = "Write barrier",
2399 .type = FIO_OPT_INT,
2400 .off1 = offsetof(struct thread_options, barrier_blocks),
2401 .help = "Make every Nth write a barrier write",
2404 .category = FIO_OPT_C_IO,
2405 .group = FIO_OPT_G_INVALID,
2407 #ifdef CONFIG_SYNC_FILE_RANGE
2409 .name = "sync_file_range",
2410 .lname = "Sync file range",
2412 { .ival = "wait_before",
2413 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
2414 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
2418 .oval = SYNC_FILE_RANGE_WRITE,
2419 .help = "SYNC_FILE_RANGE_WRITE",
2423 .ival = "wait_after",
2424 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
2425 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
2429 .type = FIO_OPT_STR_MULTI,
2431 .off1 = offsetof(struct thread_options, sync_file_range),
2432 .help = "Use sync_file_range()",
2433 .category = FIO_OPT_C_FILE,
2434 .group = FIO_OPT_G_INVALID,
2438 .name = "sync_file_range",
2439 .lname = "Sync file range",
2440 .type = FIO_OPT_UNSUPPORTED,
2441 .help = "Your platform does not support sync_file_range",
2446 .lname = "Direct I/O",
2447 .type = FIO_OPT_BOOL,
2448 .off1 = offsetof(struct thread_options, odirect),
2449 .help = "Use O_DIRECT IO (negates buffered)",
2451 .inverse = "buffered",
2452 .category = FIO_OPT_C_IO,
2453 .group = FIO_OPT_G_IO_TYPE,
2457 .lname = "Atomic I/O",
2458 .type = FIO_OPT_BOOL,
2459 .off1 = offsetof(struct thread_options, oatomic),
2460 .help = "Use Atomic IO with O_DIRECT (implies O_DIRECT)",
2462 .category = FIO_OPT_C_IO,
2463 .group = FIO_OPT_G_IO_TYPE,
2467 .lname = "Buffered I/O",
2468 .type = FIO_OPT_BOOL,
2469 .off1 = offsetof(struct thread_options, odirect),
2471 .help = "Use buffered IO (negates direct)",
2473 .inverse = "direct",
2474 .category = FIO_OPT_C_IO,
2475 .group = FIO_OPT_G_IO_TYPE,
2478 .name = "overwrite",
2479 .lname = "Overwrite",
2480 .type = FIO_OPT_BOOL,
2481 .off1 = offsetof(struct thread_options, overwrite),
2482 .help = "When writing, set whether to overwrite current data",
2484 .category = FIO_OPT_C_FILE,
2485 .group = FIO_OPT_G_INVALID,
2490 .type = FIO_OPT_INT,
2491 .off1 = offsetof(struct thread_options, loops),
2492 .help = "Number of times to run the job",
2495 .category = FIO_OPT_C_GENERAL,
2496 .group = FIO_OPT_G_RUNTIME,
2500 .lname = "Number of jobs",
2501 .type = FIO_OPT_INT,
2502 .off1 = offsetof(struct thread_options, numjobs),
2503 .help = "Duplicate this job this many times",
2506 .category = FIO_OPT_C_GENERAL,
2507 .group = FIO_OPT_G_RUNTIME,
2510 .name = "startdelay",
2511 .lname = "Start delay",
2512 .type = FIO_OPT_STR_VAL_TIME,
2513 .off1 = offsetof(struct thread_options, start_delay),
2514 .off2 = offsetof(struct thread_options, start_delay_high),
2515 .help = "Only start job when this period has passed",
2519 .category = FIO_OPT_C_GENERAL,
2520 .group = FIO_OPT_G_RUNTIME,
2526 .type = FIO_OPT_STR_VAL_TIME,
2527 .off1 = offsetof(struct thread_options, timeout),
2528 .help = "Stop workload when this amount of time has passed",
2532 .category = FIO_OPT_C_GENERAL,
2533 .group = FIO_OPT_G_RUNTIME,
2536 .name = "time_based",
2537 .lname = "Time based",
2538 .type = FIO_OPT_STR_SET,
2539 .off1 = offsetof(struct thread_options, time_based),
2540 .help = "Keep running until runtime/timeout is met",
2541 .category = FIO_OPT_C_GENERAL,
2542 .group = FIO_OPT_G_RUNTIME,
2545 .name = "verify_only",
2546 .lname = "Verify only",
2547 .type = FIO_OPT_STR_SET,
2548 .off1 = offsetof(struct thread_options, verify_only),
2549 .help = "Verifies previously written data is still valid",
2550 .category = FIO_OPT_C_GENERAL,
2551 .group = FIO_OPT_G_RUNTIME,
2554 .name = "ramp_time",
2555 .lname = "Ramp time",
2556 .type = FIO_OPT_STR_VAL_TIME,
2557 .off1 = offsetof(struct thread_options, ramp_time),
2558 .help = "Ramp up time before measuring performance",
2561 .category = FIO_OPT_C_GENERAL,
2562 .group = FIO_OPT_G_RUNTIME,
2565 .name = "clocksource",
2566 .lname = "Clock source",
2567 .type = FIO_OPT_STR,
2568 .cb = fio_clock_source_cb,
2569 .off1 = offsetof(struct thread_options, clocksource),
2570 .help = "What type of timing source to use",
2571 .category = FIO_OPT_C_GENERAL,
2572 .group = FIO_OPT_G_CLOCK,
2574 #ifdef CONFIG_GETTIMEOFDAY
2575 { .ival = "gettimeofday",
2577 .help = "Use gettimeofday(2) for timing",
2580 #ifdef CONFIG_CLOCK_GETTIME
2581 { .ival = "clock_gettime",
2582 .oval = CS_CGETTIME,
2583 .help = "Use clock_gettime(2) for timing",
2586 #ifdef ARCH_HAVE_CPU_CLOCK
2588 .oval = CS_CPUCLOCK,
2589 .help = "Use CPU private clock",
2597 .lname = "I/O Memory",
2598 .type = FIO_OPT_STR,
2600 .off1 = offsetof(struct thread_options, mem_type),
2601 .help = "Backing type for IO buffers",
2603 .category = FIO_OPT_C_IO,
2604 .group = FIO_OPT_G_INVALID,
2608 .help = "Use malloc(3) for IO buffers",
2610 #ifndef CONFIG_NO_SHM
2613 .help = "Use shared memory segments for IO buffers",
2615 #ifdef FIO_HAVE_HUGETLB
2616 { .ival = "shmhuge",
2617 .oval = MEM_SHMHUGE,
2618 .help = "Like shm, but use huge pages",
2624 .help = "Use mmap(2) (file or anon) for IO buffers",
2626 { .ival = "mmapshared",
2627 .oval = MEM_MMAPSHARED,
2628 .help = "Like mmap, but use the shared flag",
2630 #ifdef FIO_HAVE_HUGETLB
2631 { .ival = "mmaphuge",
2632 .oval = MEM_MMAPHUGE,
2633 .help = "Like mmap, but use huge pages",
2637 { .ival = "cudamalloc",
2638 .oval = MEM_CUDA_MALLOC,
2639 .help = "Allocate GPU device memory for GPUDirect RDMA",
2645 .name = "iomem_align",
2646 .alias = "mem_align",
2647 .lname = "I/O memory alignment",
2648 .type = FIO_OPT_INT,
2649 .off1 = offsetof(struct thread_options, mem_align),
2651 .help = "IO memory buffer offset alignment",
2655 .category = FIO_OPT_C_IO,
2656 .group = FIO_OPT_G_INVALID,
2661 .type = FIO_OPT_STR,
2662 .off1 = offsetof(struct thread_options, verify),
2663 .help = "Verify data written",
2665 .category = FIO_OPT_C_IO,
2666 .group = FIO_OPT_G_VERIFY,
2669 .oval = VERIFY_NONE,
2670 .help = "Don't do IO verification",
2674 .help = "Use md5 checksums for verification",
2677 .oval = VERIFY_CRC64,
2678 .help = "Use crc64 checksums for verification",
2681 .oval = VERIFY_CRC32,
2682 .help = "Use crc32 checksums for verification",
2684 { .ival = "crc32c-intel",
2685 .oval = VERIFY_CRC32C,
2686 .help = "Use crc32c checksums for verification (hw assisted, if available)",
2689 .oval = VERIFY_CRC32C,
2690 .help = "Use crc32c checksums for verification (hw assisted, if available)",
2693 .oval = VERIFY_CRC16,
2694 .help = "Use crc16 checksums for verification",
2697 .oval = VERIFY_CRC7,
2698 .help = "Use crc7 checksums for verification",
2701 .oval = VERIFY_SHA1,
2702 .help = "Use sha1 checksums for verification",
2705 .oval = VERIFY_SHA256,
2706 .help = "Use sha256 checksums for verification",
2709 .oval = VERIFY_SHA512,
2710 .help = "Use sha512 checksums for verification",
2712 { .ival = "sha3-224",
2713 .oval = VERIFY_SHA3_224,
2714 .help = "Use sha3-224 checksums for verification",
2716 { .ival = "sha3-256",
2717 .oval = VERIFY_SHA3_256,
2718 .help = "Use sha3-256 checksums for verification",
2720 { .ival = "sha3-384",
2721 .oval = VERIFY_SHA3_384,
2722 .help = "Use sha3-384 checksums for verification",
2724 { .ival = "sha3-512",
2725 .oval = VERIFY_SHA3_512,
2726 .help = "Use sha3-512 checksums for verification",
2729 .oval = VERIFY_XXHASH,
2730 .help = "Use xxhash checksums for verification",
2732 /* Meta information was included into verify_header,
2733 * 'meta' verification is implied by default. */
2735 .oval = VERIFY_HDR_ONLY,
2736 .help = "Use io information for verification. "
2737 "Now is implied by default, thus option is obsolete, "
2740 { .ival = "pattern",
2741 .oval = VERIFY_PATTERN_NO_HDR,
2742 .help = "Verify strict pattern",
2746 .oval = VERIFY_NULL,
2747 .help = "Pretend to verify",
2752 .name = "do_verify",
2753 .lname = "Perform verify step",
2754 .type = FIO_OPT_BOOL,
2755 .off1 = offsetof(struct thread_options, do_verify),
2756 .help = "Run verification stage after write",
2760 .category = FIO_OPT_C_IO,
2761 .group = FIO_OPT_G_VERIFY,
2764 .name = "verifysort",
2765 .lname = "Verify sort",
2766 .type = FIO_OPT_BOOL,
2767 .off1 = offsetof(struct thread_options, verifysort),
2768 .help = "Sort written verify blocks for read back",
2772 .category = FIO_OPT_C_IO,
2773 .group = FIO_OPT_G_VERIFY,
2776 .name = "verifysort_nr",
2777 .lname = "Verify Sort Nr",
2778 .type = FIO_OPT_INT,
2779 .off1 = offsetof(struct thread_options, verifysort_nr),
2780 .help = "Pre-load and sort verify blocks for a read workload",
2785 .category = FIO_OPT_C_IO,
2786 .group = FIO_OPT_G_VERIFY,
2789 .name = "verify_interval",
2790 .lname = "Verify interval",
2791 .type = FIO_OPT_INT,
2792 .off1 = offsetof(struct thread_options, verify_interval),
2793 .minval = 2 * sizeof(struct verify_header),
2794 .help = "Store verify buffer header every N bytes",
2797 .interval = 2 * sizeof(struct verify_header),
2798 .category = FIO_OPT_C_IO,
2799 .group = FIO_OPT_G_VERIFY,
2802 .name = "verify_offset",
2803 .lname = "Verify offset",
2804 .type = FIO_OPT_INT,
2805 .help = "Offset verify header location by N bytes",
2806 .off1 = offsetof(struct thread_options, verify_offset),
2807 .minval = sizeof(struct verify_header),
2810 .category = FIO_OPT_C_IO,
2811 .group = FIO_OPT_G_VERIFY,
2814 .name = "verify_pattern",
2815 .lname = "Verify pattern",
2816 .type = FIO_OPT_STR,
2817 .cb = str_verify_pattern_cb,
2818 .off1 = offsetof(struct thread_options, verify_pattern),
2819 .help = "Fill pattern for IO buffers",
2822 .category = FIO_OPT_C_IO,
2823 .group = FIO_OPT_G_VERIFY,
2826 .name = "verify_fatal",
2827 .lname = "Verify fatal",
2828 .type = FIO_OPT_BOOL,
2829 .off1 = offsetof(struct thread_options, verify_fatal),
2831 .help = "Exit on a single verify failure, don't continue",
2834 .category = FIO_OPT_C_IO,
2835 .group = FIO_OPT_G_VERIFY,
2838 .name = "verify_dump",
2839 .lname = "Verify dump",
2840 .type = FIO_OPT_BOOL,
2841 .off1 = offsetof(struct thread_options, verify_dump),
2843 .help = "Dump contents of good and bad blocks on failure",
2846 .category = FIO_OPT_C_IO,
2847 .group = FIO_OPT_G_VERIFY,
2850 .name = "verify_async",
2851 .lname = "Verify asynchronously",
2852 .type = FIO_OPT_INT,
2853 .off1 = offsetof(struct thread_options, verify_async),
2855 .help = "Number of async verifier threads to use",
2858 .category = FIO_OPT_C_IO,
2859 .group = FIO_OPT_G_VERIFY,
2862 .name = "verify_backlog",
2863 .lname = "Verify backlog",
2864 .type = FIO_OPT_STR_VAL,
2865 .off1 = offsetof(struct thread_options, verify_backlog),
2866 .help = "Verify after this number of blocks are written",
2869 .category = FIO_OPT_C_IO,
2870 .group = FIO_OPT_G_VERIFY,
2873 .name = "verify_backlog_batch",
2874 .lname = "Verify backlog batch",
2875 .type = FIO_OPT_INT,
2876 .off1 = offsetof(struct thread_options, verify_batch),
2877 .help = "Verify this number of IO blocks",
2880 .category = FIO_OPT_C_IO,
2881 .group = FIO_OPT_G_VERIFY,
2883 #ifdef FIO_HAVE_CPU_AFFINITY
2885 .name = "verify_async_cpus",
2886 .lname = "Async verify CPUs",
2887 .type = FIO_OPT_STR,
2888 .cb = str_verify_cpus_allowed_cb,
2889 .off1 = offsetof(struct thread_options, verify_cpumask),
2890 .help = "Set CPUs allowed for async verify threads",
2891 .parent = "verify_async",
2893 .category = FIO_OPT_C_IO,
2894 .group = FIO_OPT_G_VERIFY,
2898 .name = "verify_async_cpus",
2899 .lname = "Async verify CPUs",
2900 .type = FIO_OPT_UNSUPPORTED,
2901 .help = "Your platform does not support CPU affinities",
2905 .name = "experimental_verify",
2906 .lname = "Experimental Verify",
2907 .off1 = offsetof(struct thread_options, experimental_verify),
2908 .type = FIO_OPT_BOOL,
2909 .help = "Enable experimental verification",
2911 .category = FIO_OPT_C_IO,
2912 .group = FIO_OPT_G_VERIFY,
2915 .name = "verify_state_load",
2916 .lname = "Load verify state",
2917 .off1 = offsetof(struct thread_options, verify_state),
2918 .type = FIO_OPT_BOOL,
2919 .help = "Load verify termination state",
2921 .category = FIO_OPT_C_IO,
2922 .group = FIO_OPT_G_VERIFY,
2925 .name = "verify_state_save",
2926 .lname = "Save verify state",
2927 .off1 = offsetof(struct thread_options, verify_state_save),
2928 .type = FIO_OPT_BOOL,
2930 .help = "Save verify state on termination",
2932 .category = FIO_OPT_C_IO,
2933 .group = FIO_OPT_G_VERIFY,
2935 #ifdef FIO_HAVE_TRIM
2937 .name = "trim_percentage",
2938 .lname = "Trim percentage",
2939 .type = FIO_OPT_INT,
2940 .off1 = offsetof(struct thread_options, trim_percentage),
2943 .help = "Number of verify blocks to trim (i.e., discard)",
2948 .category = FIO_OPT_C_IO,
2949 .group = FIO_OPT_G_TRIM,
2952 .name = "trim_verify_zero",
2953 .lname = "Verify trim zero",
2954 .type = FIO_OPT_BOOL,
2955 .help = "Verify that trimmed (i.e., discarded) blocks are returned as zeroes",
2956 .off1 = offsetof(struct thread_options, trim_zero),
2957 .parent = "trim_percentage",
2960 .category = FIO_OPT_C_IO,
2961 .group = FIO_OPT_G_TRIM,
2964 .name = "trim_backlog",
2965 .lname = "Trim backlog",
2966 .type = FIO_OPT_STR_VAL,
2967 .off1 = offsetof(struct thread_options, trim_backlog),
2968 .help = "Trim after this number of blocks are written",
2969 .parent = "trim_percentage",
2972 .category = FIO_OPT_C_IO,
2973 .group = FIO_OPT_G_TRIM,
2976 .name = "trim_backlog_batch",
2977 .lname = "Trim backlog batch",
2978 .type = FIO_OPT_INT,
2979 .off1 = offsetof(struct thread_options, trim_batch),
2980 .help = "Trim this number of IO blocks",
2981 .parent = "trim_percentage",
2984 .category = FIO_OPT_C_IO,
2985 .group = FIO_OPT_G_TRIM,
2989 .name = "trim_percentage",
2990 .lname = "Trim percentage",
2991 .type = FIO_OPT_UNSUPPORTED,
2992 .help = "Fio does not support TRIM on your platform",
2995 .name = "trim_verify_zero",
2996 .lname = "Verify trim zero",
2997 .type = FIO_OPT_UNSUPPORTED,
2998 .help = "Fio does not support TRIM on your platform",
3001 .name = "trim_backlog",
3002 .lname = "Trim backlog",
3003 .type = FIO_OPT_UNSUPPORTED,
3004 .help = "Fio does not support TRIM on your platform",
3007 .name = "trim_backlog_batch",
3008 .lname = "Trim backlog batch",
3009 .type = FIO_OPT_UNSUPPORTED,
3010 .help = "Fio does not support TRIM on your platform",
3014 .name = "write_iolog",
3015 .lname = "Write I/O log",
3016 .type = FIO_OPT_STR_STORE,
3017 .off1 = offsetof(struct thread_options, write_iolog_file),
3018 .help = "Store IO pattern to file",
3019 .category = FIO_OPT_C_IO,
3020 .group = FIO_OPT_G_IOLOG,
3023 .name = "read_iolog",
3024 .lname = "Read I/O log",
3025 .type = FIO_OPT_STR_STORE,
3026 .off1 = offsetof(struct thread_options, read_iolog_file),
3027 .help = "Playback IO pattern from file",
3028 .category = FIO_OPT_C_IO,
3029 .group = FIO_OPT_G_IOLOG,
3032 .name = "replay_no_stall",
3033 .lname = "Don't stall on replay",
3034 .type = FIO_OPT_BOOL,
3035 .off1 = offsetof(struct thread_options, no_stall),
3037 .parent = "read_iolog",
3039 .help = "Playback IO pattern file as fast as possible without stalls",
3040 .category = FIO_OPT_C_IO,
3041 .group = FIO_OPT_G_IOLOG,
3044 .name = "replay_redirect",
3045 .lname = "Redirect device for replay",
3046 .type = FIO_OPT_STR_STORE,
3047 .off1 = offsetof(struct thread_options, replay_redirect),
3048 .parent = "read_iolog",
3050 .help = "Replay all I/O onto this device, regardless of trace device",
3051 .category = FIO_OPT_C_IO,
3052 .group = FIO_OPT_G_IOLOG,
3055 .name = "replay_scale",
3056 .lname = "Replace offset scale factor",
3057 .type = FIO_OPT_INT,
3058 .off1 = offsetof(struct thread_options, replay_scale),
3059 .parent = "read_iolog",
3061 .help = "Align offsets to this blocksize",
3062 .category = FIO_OPT_C_IO,
3063 .group = FIO_OPT_G_IOLOG,
3066 .name = "replay_align",
3067 .lname = "Replace alignment",
3068 .type = FIO_OPT_INT,
3069 .off1 = offsetof(struct thread_options, replay_align),
3070 .parent = "read_iolog",
3071 .help = "Scale offset down by this factor",
3072 .category = FIO_OPT_C_IO,
3073 .group = FIO_OPT_G_IOLOG,
3077 .name = "exec_prerun",
3078 .lname = "Pre-execute runnable",
3079 .type = FIO_OPT_STR_STORE,
3080 .off1 = offsetof(struct thread_options, exec_prerun),
3081 .help = "Execute this file prior to running job",
3082 .category = FIO_OPT_C_GENERAL,
3083 .group = FIO_OPT_G_INVALID,
3086 .name = "exec_postrun",
3087 .lname = "Post-execute runnable",
3088 .type = FIO_OPT_STR_STORE,
3089 .off1 = offsetof(struct thread_options, exec_postrun),
3090 .help = "Execute this file after running job",
3091 .category = FIO_OPT_C_GENERAL,
3092 .group = FIO_OPT_G_INVALID,
3094 #ifdef FIO_HAVE_IOSCHED_SWITCH
3096 .name = "ioscheduler",
3097 .lname = "I/O scheduler",
3098 .type = FIO_OPT_STR_STORE,
3099 .off1 = offsetof(struct thread_options, ioscheduler),
3100 .help = "Use this IO scheduler on the backing device",
3101 .category = FIO_OPT_C_FILE,
3102 .group = FIO_OPT_G_INVALID,
3106 .name = "ioscheduler",
3107 .lname = "I/O scheduler",
3108 .type = FIO_OPT_UNSUPPORTED,
3109 .help = "Your platform does not support IO scheduler switching",
3114 .lname = "Zone size",
3115 .type = FIO_OPT_STR_VAL,
3116 .off1 = offsetof(struct thread_options, zone_size),
3117 .help = "Amount of data to read per zone",
3119 .interval = 1024 * 1024,
3120 .category = FIO_OPT_C_IO,
3121 .group = FIO_OPT_G_ZONE,
3124 .name = "zonerange",
3125 .lname = "Zone range",
3126 .type = FIO_OPT_STR_VAL,
3127 .off1 = offsetof(struct thread_options, zone_range),
3128 .help = "Give size of an IO zone",
3130 .interval = 1024 * 1024,
3131 .category = FIO_OPT_C_IO,
3132 .group = FIO_OPT_G_ZONE,
3136 .lname = "Zone skip",
3137 .type = FIO_OPT_STR_VAL,
3138 .off1 = offsetof(struct thread_options, zone_skip),
3139 .help = "Space between IO zones",
3141 .interval = 1024 * 1024,
3142 .category = FIO_OPT_C_IO,
3143 .group = FIO_OPT_G_ZONE,
3147 .lname = "Lock memory",
3148 .type = FIO_OPT_STR_VAL,
3149 .off1 = offsetof(struct thread_options, lockmem),
3150 .help = "Lock down this amount of memory (per worker)",
3152 .interval = 1024 * 1024,
3153 .category = FIO_OPT_C_GENERAL,
3154 .group = FIO_OPT_G_INVALID,
3157 .name = "rwmixread",
3158 .lname = "Read/write mix read",
3159 .type = FIO_OPT_INT,
3160 .cb = str_rwmix_read_cb,
3161 .off1 = offsetof(struct thread_options, rwmix[DDIR_READ]),
3163 .help = "Percentage of mixed workload that is reads",
3166 .inverse = "rwmixwrite",
3167 .category = FIO_OPT_C_IO,
3168 .group = FIO_OPT_G_RWMIX,
3171 .name = "rwmixwrite",
3172 .lname = "Read/write mix write",
3173 .type = FIO_OPT_INT,
3174 .cb = str_rwmix_write_cb,
3175 .off1 = offsetof(struct thread_options, rwmix[DDIR_WRITE]),
3177 .help = "Percentage of mixed workload that is writes",
3180 .inverse = "rwmixread",
3181 .category = FIO_OPT_C_IO,
3182 .group = FIO_OPT_G_RWMIX,
3185 .name = "rwmixcycle",
3186 .lname = "Read/write mix cycle",
3187 .type = FIO_OPT_DEPRECATED,
3188 .category = FIO_OPT_C_IO,
3189 .group = FIO_OPT_G_RWMIX,
3194 .type = FIO_OPT_INT,
3195 .off1 = offsetof(struct thread_options, nice),
3196 .help = "Set job CPU nice value",
3201 .category = FIO_OPT_C_GENERAL,
3202 .group = FIO_OPT_G_CRED,
3204 #ifdef FIO_HAVE_IOPRIO
3207 .lname = "I/O nice priority",
3208 .type = FIO_OPT_INT,
3209 .off1 = offsetof(struct thread_options, ioprio),
3210 .help = "Set job IO priority value",
3211 .minval = IOPRIO_MIN_PRIO,
3212 .maxval = IOPRIO_MAX_PRIO,
3214 .category = FIO_OPT_C_GENERAL,
3215 .group = FIO_OPT_G_CRED,
3220 .lname = "I/O nice priority",
3221 .type = FIO_OPT_UNSUPPORTED,
3222 .help = "Your platform does not support IO priorities",
3225 #ifdef FIO_HAVE_IOPRIO_CLASS
3226 #ifndef FIO_HAVE_IOPRIO
3227 #error "FIO_HAVE_IOPRIO_CLASS requires FIO_HAVE_IOPRIO"
3230 .name = "prioclass",
3231 .lname = "I/O nice priority class",
3232 .type = FIO_OPT_INT,
3233 .off1 = offsetof(struct thread_options, ioprio_class),
3234 .help = "Set job IO priority class",
3235 .minval = IOPRIO_MIN_PRIO_CLASS,
3236 .maxval = IOPRIO_MAX_PRIO_CLASS,
3238 .category = FIO_OPT_C_GENERAL,
3239 .group = FIO_OPT_G_CRED,
3243 .name = "prioclass",
3244 .lname = "I/O nice priority class",
3245 .type = FIO_OPT_UNSUPPORTED,
3246 .help = "Your platform does not support IO priority classes",
3250 .name = "thinktime",
3251 .lname = "Thinktime",
3252 .type = FIO_OPT_INT,
3253 .off1 = offsetof(struct thread_options, thinktime),
3254 .help = "Idle time between IO buffers (usec)",
3257 .category = FIO_OPT_C_IO,
3258 .group = FIO_OPT_G_THINKTIME,
3261 .name = "thinktime_spin",
3262 .lname = "Thinktime spin",
3263 .type = FIO_OPT_INT,
3264 .off1 = offsetof(struct thread_options, thinktime_spin),
3265 .help = "Start think time by spinning this amount (usec)",
3268 .parent = "thinktime",
3270 .category = FIO_OPT_C_IO,
3271 .group = FIO_OPT_G_THINKTIME,
3274 .name = "thinktime_blocks",
3275 .lname = "Thinktime blocks",
3276 .type = FIO_OPT_INT,
3277 .off1 = offsetof(struct thread_options, thinktime_blocks),
3278 .help = "IO buffer period between 'thinktime'",
3280 .parent = "thinktime",
3282 .category = FIO_OPT_C_IO,
3283 .group = FIO_OPT_G_THINKTIME,
3287 .lname = "I/O rate",
3288 .type = FIO_OPT_INT,
3289 .off1 = offsetof(struct thread_options, rate[DDIR_READ]),
3290 .off2 = offsetof(struct thread_options, rate[DDIR_WRITE]),
3291 .off3 = offsetof(struct thread_options, rate[DDIR_TRIM]),
3292 .help = "Set bandwidth rate",
3293 .category = FIO_OPT_C_IO,
3294 .group = FIO_OPT_G_RATE,
3299 .lname = "I/O min rate",
3300 .type = FIO_OPT_INT,
3301 .off1 = offsetof(struct thread_options, ratemin[DDIR_READ]),
3302 .off2 = offsetof(struct thread_options, ratemin[DDIR_WRITE]),
3303 .off3 = offsetof(struct thread_options, ratemin[DDIR_TRIM]),
3304 .help = "Job must meet this rate or it will be shutdown",
3307 .category = FIO_OPT_C_IO,
3308 .group = FIO_OPT_G_RATE,
3311 .name = "rate_iops",
3312 .lname = "I/O rate IOPS",
3313 .type = FIO_OPT_INT,
3314 .off1 = offsetof(struct thread_options, rate_iops[DDIR_READ]),
3315 .off2 = offsetof(struct thread_options, rate_iops[DDIR_WRITE]),
3316 .off3 = offsetof(struct thread_options, rate_iops[DDIR_TRIM]),
3317 .help = "Limit IO used to this number of IO operations/sec",
3319 .category = FIO_OPT_C_IO,
3320 .group = FIO_OPT_G_RATE,
3323 .name = "rate_iops_min",
3324 .lname = "I/O min rate IOPS",
3325 .type = FIO_OPT_INT,
3326 .off1 = offsetof(struct thread_options, rate_iops_min[DDIR_READ]),
3327 .off2 = offsetof(struct thread_options, rate_iops_min[DDIR_WRITE]),
3328 .off3 = offsetof(struct thread_options, rate_iops_min[DDIR_TRIM]),
3329 .help = "Job must meet this rate or it will be shut down",
3330 .parent = "rate_iops",
3332 .category = FIO_OPT_C_IO,
3333 .group = FIO_OPT_G_RATE,
3336 .name = "rate_process",
3337 .lname = "Rate Process",
3338 .type = FIO_OPT_STR,
3339 .off1 = offsetof(struct thread_options, rate_process),
3340 .help = "What process controls how rated IO is managed",
3342 .category = FIO_OPT_C_IO,
3343 .group = FIO_OPT_G_RATE,
3346 .oval = RATE_PROCESS_LINEAR,
3347 .help = "Linear rate of IO",
3351 .oval = RATE_PROCESS_POISSON,
3352 .help = "Rate follows Poisson process",
3358 .name = "rate_cycle",
3359 .alias = "ratecycle",
3360 .lname = "I/O rate cycle",
3361 .type = FIO_OPT_INT,
3362 .off1 = offsetof(struct thread_options, ratecycle),
3363 .help = "Window average for rate limits (msec)",
3367 .category = FIO_OPT_C_IO,
3368 .group = FIO_OPT_G_RATE,
3371 .name = "max_latency",
3372 .lname = "Max Latency",
3373 .type = FIO_OPT_INT,
3374 .off1 = offsetof(struct thread_options, max_latency),
3375 .help = "Maximum tolerated IO latency (usec)",
3377 .category = FIO_OPT_C_IO,
3378 .group = FIO_OPT_G_LATPROF,
3381 .name = "latency_target",
3382 .lname = "Latency Target (usec)",
3383 .type = FIO_OPT_STR_VAL_TIME,
3384 .off1 = offsetof(struct thread_options, latency_target),
3385 .help = "Ramp to max queue depth supporting this latency",
3387 .category = FIO_OPT_C_IO,
3388 .group = FIO_OPT_G_LATPROF,
3391 .name = "latency_window",
3392 .lname = "Latency Window (usec)",
3393 .type = FIO_OPT_STR_VAL_TIME,
3394 .off1 = offsetof(struct thread_options, latency_window),
3395 .help = "Time to sustain latency_target",
3397 .category = FIO_OPT_C_IO,
3398 .group = FIO_OPT_G_LATPROF,
3401 .name = "latency_percentile",
3402 .lname = "Latency Percentile",
3403 .type = FIO_OPT_FLOAT_LIST,
3404 .off1 = offsetof(struct thread_options, latency_percentile),
3405 .help = "Percentile of IOs must be below latency_target",
3410 .category = FIO_OPT_C_IO,
3411 .group = FIO_OPT_G_LATPROF,
3414 .name = "invalidate",
3415 .lname = "Cache invalidate",
3416 .type = FIO_OPT_BOOL,
3417 .off1 = offsetof(struct thread_options, invalidate_cache),
3418 .help = "Invalidate buffer/page cache prior to running job",
3420 .category = FIO_OPT_C_IO,
3421 .group = FIO_OPT_G_IO_TYPE,
3425 .lname = "Synchronous I/O",
3426 .type = FIO_OPT_BOOL,
3427 .off1 = offsetof(struct thread_options, sync_io),
3428 .help = "Use O_SYNC for buffered writes",
3430 .parent = "buffered",
3432 .category = FIO_OPT_C_IO,
3433 .group = FIO_OPT_G_IO_TYPE,
3436 .name = "create_serialize",
3437 .lname = "Create serialize",
3438 .type = FIO_OPT_BOOL,
3439 .off1 = offsetof(struct thread_options, create_serialize),
3440 .help = "Serialize creation of job files",
3442 .category = FIO_OPT_C_FILE,
3443 .group = FIO_OPT_G_INVALID,
3446 .name = "create_fsync",
3447 .lname = "Create fsync",
3448 .type = FIO_OPT_BOOL,
3449 .off1 = offsetof(struct thread_options, create_fsync),
3450 .help = "fsync file after creation",
3452 .category = FIO_OPT_C_FILE,
3453 .group = FIO_OPT_G_INVALID,
3456 .name = "create_on_open",
3457 .lname = "Create on open",
3458 .type = FIO_OPT_BOOL,
3459 .off1 = offsetof(struct thread_options, create_on_open),
3460 .help = "Create files when they are opened for IO",
3462 .category = FIO_OPT_C_FILE,
3463 .group = FIO_OPT_G_INVALID,
3466 .name = "create_only",
3467 .lname = "Create Only",
3468 .type = FIO_OPT_BOOL,
3469 .off1 = offsetof(struct thread_options, create_only),
3470 .help = "Only perform file creation phase",
3471 .category = FIO_OPT_C_FILE,
3475 .name = "allow_file_create",
3476 .lname = "Allow file create",
3477 .type = FIO_OPT_BOOL,
3478 .off1 = offsetof(struct thread_options, allow_create),
3479 .help = "Permit fio to create files, if they don't exist",
3481 .category = FIO_OPT_C_FILE,
3482 .group = FIO_OPT_G_FILENAME,
3485 .name = "allow_mounted_write",
3486 .lname = "Allow mounted write",
3487 .type = FIO_OPT_BOOL,
3488 .off1 = offsetof(struct thread_options, allow_mounted_write),
3489 .help = "Allow writes to a mounted partition",
3491 .category = FIO_OPT_C_FILE,
3492 .group = FIO_OPT_G_FILENAME,
3496 .lname = "Pre-read files",
3497 .type = FIO_OPT_BOOL,
3498 .off1 = offsetof(struct thread_options, pre_read),
3499 .help = "Pre-read files before starting official testing",
3501 .category = FIO_OPT_C_FILE,
3502 .group = FIO_OPT_G_INVALID,
3504 #ifdef FIO_HAVE_CPU_AFFINITY
3507 .lname = "CPU mask",
3508 .type = FIO_OPT_INT,
3509 .cb = str_cpumask_cb,
3510 .off1 = offsetof(struct thread_options, cpumask),
3511 .help = "CPU affinity mask",
3512 .category = FIO_OPT_C_GENERAL,
3513 .group = FIO_OPT_G_CRED,
3516 .name = "cpus_allowed",
3517 .lname = "CPUs allowed",
3518 .type = FIO_OPT_STR,
3519 .cb = str_cpus_allowed_cb,
3520 .off1 = offsetof(struct thread_options, cpumask),
3521 .help = "Set CPUs allowed",
3522 .category = FIO_OPT_C_GENERAL,
3523 .group = FIO_OPT_G_CRED,
3526 .name = "cpus_allowed_policy",
3527 .lname = "CPUs allowed distribution policy",
3528 .type = FIO_OPT_STR,
3529 .off1 = offsetof(struct thread_options, cpus_allowed_policy),
3530 .help = "Distribution policy for cpus_allowed",
3531 .parent = "cpus_allowed",
3535 .oval = FIO_CPUS_SHARED,
3536 .help = "Mask shared between threads",
3539 .oval = FIO_CPUS_SPLIT,
3540 .help = "Mask split between threads",
3543 .category = FIO_OPT_C_GENERAL,
3544 .group = FIO_OPT_G_CRED,
3549 .lname = "CPU mask",
3550 .type = FIO_OPT_UNSUPPORTED,
3551 .help = "Your platform does not support CPU affinities",
3554 .name = "cpus_allowed",
3555 .lname = "CPUs allowed",
3556 .type = FIO_OPT_UNSUPPORTED,
3557 .help = "Your platform does not support CPU affinities",
3560 .name = "cpus_allowed_policy",
3561 .lname = "CPUs allowed distribution policy",
3562 .type = FIO_OPT_UNSUPPORTED,
3563 .help = "Your platform does not support CPU affinities",
3566 #ifdef CONFIG_LIBNUMA
3568 .name = "numa_cpu_nodes",
3569 .lname = "NUMA CPU Nodes",
3570 .type = FIO_OPT_STR,
3571 .cb = str_numa_cpunodes_cb,
3572 .off1 = offsetof(struct thread_options, numa_cpunodes),
3573 .help = "NUMA CPU nodes bind",
3574 .category = FIO_OPT_C_GENERAL,
3575 .group = FIO_OPT_G_INVALID,
3578 .name = "numa_mem_policy",
3579 .lname = "NUMA Memory Policy",
3580 .type = FIO_OPT_STR,
3581 .cb = str_numa_mpol_cb,
3582 .off1 = offsetof(struct thread_options, numa_memnodes),
3583 .help = "NUMA memory policy setup",
3584 .category = FIO_OPT_C_GENERAL,
3585 .group = FIO_OPT_G_INVALID,
3589 .name = "numa_cpu_nodes",
3590 .lname = "NUMA CPU Nodes",
3591 .type = FIO_OPT_UNSUPPORTED,
3592 .help = "Build fio with libnuma-dev(el) to enable this option",
3595 .name = "numa_mem_policy",
3596 .lname = "NUMA Memory Policy",
3597 .type = FIO_OPT_UNSUPPORTED,
3598 .help = "Build fio with libnuma-dev(el) to enable this option",
3603 .name = "gpu_dev_id",
3604 .lname = "GPU device ID",
3605 .type = FIO_OPT_INT,
3606 .off1 = offsetof(struct thread_options, gpu_dev_id),
3607 .help = "Set GPU device ID for GPUDirect RDMA",
3609 .category = FIO_OPT_C_GENERAL,
3610 .group = FIO_OPT_G_INVALID,
3614 .name = "end_fsync",
3615 .lname = "End fsync",
3616 .type = FIO_OPT_BOOL,
3617 .off1 = offsetof(struct thread_options, end_fsync),
3618 .help = "Include fsync at the end of job",
3620 .category = FIO_OPT_C_FILE,
3621 .group = FIO_OPT_G_INVALID,
3624 .name = "fsync_on_close",
3625 .lname = "Fsync on close",
3626 .type = FIO_OPT_BOOL,
3627 .off1 = offsetof(struct thread_options, fsync_on_close),
3628 .help = "fsync files on close",
3630 .category = FIO_OPT_C_FILE,
3631 .group = FIO_OPT_G_INVALID,
3635 .lname = "Unlink file",
3636 .type = FIO_OPT_BOOL,
3637 .off1 = offsetof(struct thread_options, unlink),
3638 .help = "Unlink created files after job has completed",
3640 .category = FIO_OPT_C_FILE,
3641 .group = FIO_OPT_G_INVALID,
3644 .name = "unlink_each_loop",
3645 .lname = "Unlink file after each loop of a job",
3646 .type = FIO_OPT_BOOL,
3647 .off1 = offsetof(struct thread_options, unlink_each_loop),
3648 .help = "Unlink created files after each loop in a job has completed",
3650 .category = FIO_OPT_C_FILE,
3651 .group = FIO_OPT_G_INVALID,
3655 .lname = "Exit-all on terminate",
3656 .type = FIO_OPT_STR_SET,
3657 .cb = str_exitall_cb,
3658 .help = "Terminate all jobs when one exits",
3659 .category = FIO_OPT_C_GENERAL,
3660 .group = FIO_OPT_G_PROCESS,
3663 .name = "exitall_on_error",
3664 .lname = "Exit-all on terminate in error",
3665 .type = FIO_OPT_STR_SET,
3666 .off1 = offsetof(struct thread_options, exitall_error),
3667 .help = "Terminate all jobs when one exits in error",
3668 .category = FIO_OPT_C_GENERAL,
3669 .group = FIO_OPT_G_PROCESS,
3672 .name = "stonewall",
3673 .lname = "Wait for previous",
3674 .alias = "wait_for_previous",
3675 .type = FIO_OPT_STR_SET,
3676 .off1 = offsetof(struct thread_options, stonewall),
3677 .help = "Insert a hard barrier between this job and previous",
3678 .category = FIO_OPT_C_GENERAL,
3679 .group = FIO_OPT_G_PROCESS,
3682 .name = "new_group",
3683 .lname = "New group",
3684 .type = FIO_OPT_STR_SET,
3685 .off1 = offsetof(struct thread_options, new_group),
3686 .help = "Mark the start of a new group (for reporting)",
3687 .category = FIO_OPT_C_GENERAL,
3688 .group = FIO_OPT_G_PROCESS,
3693 .type = FIO_OPT_STR_SET,
3694 .off1 = offsetof(struct thread_options, use_thread),
3695 .help = "Use threads instead of processes",
3696 #ifdef CONFIG_NO_SHM
3700 .category = FIO_OPT_C_GENERAL,
3701 .group = FIO_OPT_G_PROCESS,
3704 .name = "per_job_logs",
3705 .lname = "Per Job Logs",
3706 .type = FIO_OPT_BOOL,
3707 .off1 = offsetof(struct thread_options, per_job_logs),
3708 .help = "Include job number in generated log files or not",
3710 .category = FIO_OPT_C_LOG,
3711 .group = FIO_OPT_G_INVALID,
3714 .name = "write_bw_log",
3715 .lname = "Write bandwidth log",
3716 .type = FIO_OPT_STR,
3717 .off1 = offsetof(struct thread_options, bw_log_file),
3718 .cb = str_write_bw_log_cb,
3719 .help = "Write log of bandwidth during run",
3720 .category = FIO_OPT_C_LOG,
3721 .group = FIO_OPT_G_INVALID,
3724 .name = "write_lat_log",
3725 .lname = "Write latency log",
3726 .type = FIO_OPT_STR,
3727 .off1 = offsetof(struct thread_options, lat_log_file),
3728 .cb = str_write_lat_log_cb,
3729 .help = "Write log of latency during run",
3730 .category = FIO_OPT_C_LOG,
3731 .group = FIO_OPT_G_INVALID,
3734 .name = "write_iops_log",
3735 .lname = "Write IOPS log",
3736 .type = FIO_OPT_STR,
3737 .off1 = offsetof(struct thread_options, iops_log_file),
3738 .cb = str_write_iops_log_cb,
3739 .help = "Write log of IOPS during run",
3740 .category = FIO_OPT_C_LOG,
3741 .group = FIO_OPT_G_INVALID,
3744 .name = "log_avg_msec",
3745 .lname = "Log averaging (msec)",
3746 .type = FIO_OPT_INT,
3747 .off1 = offsetof(struct thread_options, log_avg_msec),
3748 .help = "Average bw/iops/lat logs over this period of time",
3750 .category = FIO_OPT_C_LOG,
3751 .group = FIO_OPT_G_INVALID,
3754 .name = "log_hist_msec",
3755 .lname = "Log histograms (msec)",
3756 .type = FIO_OPT_INT,
3757 .off1 = offsetof(struct thread_options, log_hist_msec),
3758 .help = "Dump completion latency histograms at frequency of this time value",
3760 .category = FIO_OPT_C_LOG,
3761 .group = FIO_OPT_G_INVALID,
3764 .name = "log_hist_coarseness",
3765 .lname = "Histogram logs coarseness",
3766 .type = FIO_OPT_INT,
3767 .off1 = offsetof(struct thread_options, log_hist_coarseness),
3768 .help = "Integer in range [0,6]. Higher coarseness outputs"
3769 " fewer histogram bins per sample. The number of bins for"
3770 " these are [1216, 608, 304, 152, 76, 38, 19] respectively.",
3772 .category = FIO_OPT_C_LOG,
3773 .group = FIO_OPT_G_INVALID,
3776 .name = "write_hist_log",
3777 .lname = "Write latency histogram logs",
3778 .type = FIO_OPT_STR,
3779 .off1 = offsetof(struct thread_options, hist_log_file),
3780 .cb = str_write_hist_log_cb,
3781 .help = "Write log of latency histograms during run",
3782 .category = FIO_OPT_C_LOG,
3783 .group = FIO_OPT_G_INVALID,
3786 .name = "log_max_value",
3787 .lname = "Log maximum instead of average",
3788 .type = FIO_OPT_BOOL,
3789 .off1 = offsetof(struct thread_options, log_max),
3790 .help = "Log max sample in a window instead of average",
3792 .category = FIO_OPT_C_LOG,
3793 .group = FIO_OPT_G_INVALID,
3796 .name = "log_offset",
3797 .lname = "Log offset of IO",
3798 .type = FIO_OPT_BOOL,
3799 .off1 = offsetof(struct thread_options, log_offset),
3800 .help = "Include offset of IO for each log entry",
3802 .category = FIO_OPT_C_LOG,
3803 .group = FIO_OPT_G_INVALID,
3807 .name = "log_compression",
3808 .lname = "Log compression",
3809 .type = FIO_OPT_INT,
3810 .off1 = offsetof(struct thread_options, log_gz),
3811 .help = "Log in compressed chunks of this size",
3813 .maxval = 512 * 1024 * 1024ULL,
3814 .category = FIO_OPT_C_LOG,
3815 .group = FIO_OPT_G_INVALID,
3817 #ifdef FIO_HAVE_CPU_AFFINITY
3819 .name = "log_compression_cpus",
3820 .lname = "Log Compression CPUs",
3821 .type = FIO_OPT_STR,
3822 .cb = str_log_cpus_allowed_cb,
3823 .off1 = offsetof(struct thread_options, log_gz_cpumask),
3824 .parent = "log_compression",
3825 .help = "Limit log compression to these CPUs",
3826 .category = FIO_OPT_C_LOG,
3827 .group = FIO_OPT_G_INVALID,
3831 .name = "log_compression_cpus",
3832 .lname = "Log Compression CPUs",
3833 .type = FIO_OPT_UNSUPPORTED,
3834 .help = "Your platform does not support CPU affinities",
3838 .name = "log_store_compressed",
3839 .lname = "Log store compressed",
3840 .type = FIO_OPT_BOOL,
3841 .off1 = offsetof(struct thread_options, log_gz_store),
3842 .help = "Store logs in a compressed format",
3843 .category = FIO_OPT_C_LOG,
3844 .group = FIO_OPT_G_INVALID,
3848 .name = "log_compression",
3849 .lname = "Log compression",
3850 .type = FIO_OPT_UNSUPPORTED,
3851 .help = "Install libz-dev(el) to get compression support",
3854 .name = "log_store_compressed",
3855 .lname = "Log store compressed",
3856 .type = FIO_OPT_UNSUPPORTED,
3857 .help = "Install libz-dev(el) to get compression support",
3861 .name = "log_unix_epoch",
3862 .lname = "Log epoch unix",
3863 .type = FIO_OPT_BOOL,
3864 .off1 = offsetof(struct thread_options, log_unix_epoch),
3865 .help = "Use Unix time in log files",
3866 .category = FIO_OPT_C_LOG,
3867 .group = FIO_OPT_G_INVALID,
3870 .name = "block_error_percentiles",
3871 .lname = "Block error percentiles",
3872 .type = FIO_OPT_BOOL,
3873 .off1 = offsetof(struct thread_options, block_error_hist),
3874 .help = "Record trim block errors and make a histogram",
3876 .category = FIO_OPT_C_LOG,
3877 .group = FIO_OPT_G_INVALID,
3880 .name = "bwavgtime",
3881 .lname = "Bandwidth average time",
3882 .type = FIO_OPT_INT,
3883 .off1 = offsetof(struct thread_options, bw_avg_time),
3884 .help = "Time window over which to calculate bandwidth"
3887 .parent = "write_bw_log",
3890 .category = FIO_OPT_C_LOG,
3891 .group = FIO_OPT_G_INVALID,
3894 .name = "iopsavgtime",
3895 .lname = "IOPS average time",
3896 .type = FIO_OPT_INT,
3897 .off1 = offsetof(struct thread_options, iops_avg_time),
3898 .help = "Time window over which to calculate IOPS (msec)",
3900 .parent = "write_iops_log",
3903 .category = FIO_OPT_C_LOG,
3904 .group = FIO_OPT_G_INVALID,
3907 .name = "group_reporting",
3908 .lname = "Group reporting",
3909 .type = FIO_OPT_STR_SET,
3910 .off1 = offsetof(struct thread_options, group_reporting),
3911 .help = "Do reporting on a per-group basis",
3912 .category = FIO_OPT_C_STAT,
3913 .group = FIO_OPT_G_INVALID,
3918 .type = FIO_OPT_BOOL,
3919 .off1 = offsetof(struct thread_options, stats),
3920 .help = "Enable collection of stats",
3922 .category = FIO_OPT_C_STAT,
3923 .group = FIO_OPT_G_INVALID,
3926 .name = "zero_buffers",
3927 .lname = "Zero I/O buffers",
3928 .type = FIO_OPT_STR_SET,
3929 .off1 = offsetof(struct thread_options, zero_buffers),
3930 .help = "Init IO buffers to all zeroes",
3931 .category = FIO_OPT_C_IO,
3932 .group = FIO_OPT_G_IO_BUF,
3935 .name = "refill_buffers",
3936 .lname = "Refill I/O buffers",
3937 .type = FIO_OPT_STR_SET,
3938 .off1 = offsetof(struct thread_options, refill_buffers),
3939 .help = "Refill IO buffers on every IO submit",
3940 .category = FIO_OPT_C_IO,
3941 .group = FIO_OPT_G_IO_BUF,
3944 .name = "scramble_buffers",
3945 .lname = "Scramble I/O buffers",
3946 .type = FIO_OPT_BOOL,
3947 .off1 = offsetof(struct thread_options, scramble_buffers),
3948 .help = "Slightly scramble buffers on every IO submit",
3950 .category = FIO_OPT_C_IO,
3951 .group = FIO_OPT_G_IO_BUF,
3954 .name = "buffer_pattern",
3955 .lname = "Buffer pattern",
3956 .type = FIO_OPT_STR,
3957 .cb = str_buffer_pattern_cb,
3958 .off1 = offsetof(struct thread_options, buffer_pattern),
3959 .help = "Fill pattern for IO buffers",
3960 .category = FIO_OPT_C_IO,
3961 .group = FIO_OPT_G_IO_BUF,
3964 .name = "buffer_compress_percentage",
3965 .lname = "Buffer compression percentage",
3966 .type = FIO_OPT_INT,
3967 .cb = str_buffer_compress_cb,
3968 .off1 = offsetof(struct thread_options, compress_percentage),
3971 .help = "How compressible the buffer is (approximately)",
3973 .category = FIO_OPT_C_IO,
3974 .group = FIO_OPT_G_IO_BUF,
3977 .name = "buffer_compress_chunk",
3978 .lname = "Buffer compression chunk size",
3979 .type = FIO_OPT_INT,
3980 .off1 = offsetof(struct thread_options, compress_chunk),
3981 .parent = "buffer_compress_percentage",
3983 .help = "Size of compressible region in buffer",
3985 .category = FIO_OPT_C_IO,
3986 .group = FIO_OPT_G_IO_BUF,
3989 .name = "dedupe_percentage",
3990 .lname = "Dedupe percentage",
3991 .type = FIO_OPT_INT,
3992 .cb = str_dedupe_cb,
3993 .off1 = offsetof(struct thread_options, dedupe_percentage),
3996 .help = "Percentage of buffers that are dedupable",
3998 .category = FIO_OPT_C_IO,
3999 .group = FIO_OPT_G_IO_BUF,
4002 .name = "clat_percentiles",
4003 .lname = "Completion latency percentiles",
4004 .type = FIO_OPT_BOOL,
4005 .off1 = offsetof(struct thread_options, clat_percentiles),
4006 .help = "Enable the reporting of completion latency percentiles",
4008 .category = FIO_OPT_C_STAT,
4009 .group = FIO_OPT_G_INVALID,
4012 .name = "percentile_list",
4013 .lname = "Percentile list",
4014 .type = FIO_OPT_FLOAT_LIST,
4015 .off1 = offsetof(struct thread_options, percentile_list),
4016 .off2 = offsetof(struct thread_options, percentile_precision),
4017 .help = "Specify a custom list of percentiles to report for "
4018 "completion latency and block errors",
4019 .def = "1:5:10:20:30:40:50:60:70:80:90:95:99:99.5:99.9:99.95:99.99",
4020 .maxlen = FIO_IO_U_LIST_MAX_LEN,
4023 .category = FIO_OPT_C_STAT,
4024 .group = FIO_OPT_G_INVALID,
4027 #ifdef FIO_HAVE_DISK_UTIL
4029 .name = "disk_util",
4030 .lname = "Disk utilization",
4031 .type = FIO_OPT_BOOL,
4032 .off1 = offsetof(struct thread_options, do_disk_util),
4033 .help = "Log disk utilization statistics",
4035 .category = FIO_OPT_C_STAT,
4036 .group = FIO_OPT_G_INVALID,
4040 .name = "disk_util",
4041 .lname = "Disk utilization",
4042 .type = FIO_OPT_UNSUPPORTED,
4043 .help = "Your platform does not support disk utilization",
4047 .name = "gtod_reduce",
4048 .lname = "Reduce gettimeofday() calls",
4049 .type = FIO_OPT_BOOL,
4050 .help = "Greatly reduce number of gettimeofday() calls",
4051 .cb = str_gtod_reduce_cb,
4054 .category = FIO_OPT_C_STAT,
4055 .group = FIO_OPT_G_INVALID,
4058 .name = "disable_lat",
4059 .lname = "Disable all latency stats",
4060 .type = FIO_OPT_BOOL,
4061 .off1 = offsetof(struct thread_options, disable_lat),
4062 .help = "Disable latency numbers",
4063 .parent = "gtod_reduce",
4066 .category = FIO_OPT_C_STAT,
4067 .group = FIO_OPT_G_INVALID,
4070 .name = "disable_clat",
4071 .lname = "Disable completion latency stats",
4072 .type = FIO_OPT_BOOL,
4073 .off1 = offsetof(struct thread_options, disable_clat),
4074 .help = "Disable completion latency numbers",
4075 .parent = "gtod_reduce",
4078 .category = FIO_OPT_C_STAT,
4079 .group = FIO_OPT_G_INVALID,
4082 .name = "disable_slat",
4083 .lname = "Disable submission latency stats",
4084 .type = FIO_OPT_BOOL,
4085 .off1 = offsetof(struct thread_options, disable_slat),
4086 .help = "Disable submission latency numbers",
4087 .parent = "gtod_reduce",
4090 .category = FIO_OPT_C_STAT,
4091 .group = FIO_OPT_G_INVALID,
4094 .name = "disable_bw_measurement",
4095 .alias = "disable_bw",
4096 .lname = "Disable bandwidth stats",
4097 .type = FIO_OPT_BOOL,
4098 .off1 = offsetof(struct thread_options, disable_bw),
4099 .help = "Disable bandwidth logging",
4100 .parent = "gtod_reduce",
4103 .category = FIO_OPT_C_STAT,
4104 .group = FIO_OPT_G_INVALID,
4108 .lname = "Dedicated gettimeofday() CPU",
4109 .type = FIO_OPT_INT,
4110 .off1 = offsetof(struct thread_options, gtod_cpu),
4111 .help = "Set up dedicated gettimeofday() thread on this CPU",
4112 .verify = gtod_cpu_verify,
4113 .category = FIO_OPT_C_GENERAL,
4114 .group = FIO_OPT_G_CLOCK,
4117 .name = "unified_rw_reporting",
4118 .lname = "Unified RW Reporting",
4119 .type = FIO_OPT_BOOL,
4120 .off1 = offsetof(struct thread_options, unified_rw_rep),
4121 .help = "Unify reporting across data direction",
4123 .category = FIO_OPT_C_GENERAL,
4124 .group = FIO_OPT_G_INVALID,
4127 .name = "continue_on_error",
4128 .lname = "Continue on error",
4129 .type = FIO_OPT_STR,
4130 .off1 = offsetof(struct thread_options, continue_on_error),
4131 .help = "Continue on non-fatal errors during IO",
4133 .category = FIO_OPT_C_GENERAL,
4134 .group = FIO_OPT_G_ERR,
4137 .oval = ERROR_TYPE_NONE,
4138 .help = "Exit when an error is encountered",
4141 .oval = ERROR_TYPE_READ,
4142 .help = "Continue on read errors only",
4145 .oval = ERROR_TYPE_WRITE,
4146 .help = "Continue on write errors only",
4149 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
4150 .help = "Continue on any IO errors",
4153 .oval = ERROR_TYPE_VERIFY,
4154 .help = "Continue on verify errors only",
4157 .oval = ERROR_TYPE_ANY,
4158 .help = "Continue on all io and verify errors",
4161 .oval = ERROR_TYPE_NONE,
4162 .help = "Alias for 'none'",
4165 .oval = ERROR_TYPE_ANY,
4166 .help = "Alias for 'all'",
4171 .name = "ignore_error",
4172 .lname = "Ignore Error",
4173 .type = FIO_OPT_STR,
4174 .cb = str_ignore_error_cb,
4175 .off1 = offsetof(struct thread_options, ignore_error_nr),
4176 .help = "Set a specific list of errors to ignore",
4178 .category = FIO_OPT_C_GENERAL,
4179 .group = FIO_OPT_G_ERR,
4182 .name = "error_dump",
4183 .lname = "Error Dump",
4184 .type = FIO_OPT_BOOL,
4185 .off1 = offsetof(struct thread_options, error_dump),
4187 .help = "Dump info on each error",
4188 .category = FIO_OPT_C_GENERAL,
4189 .group = FIO_OPT_G_ERR,
4194 .type = FIO_OPT_STR_STORE,
4195 .off1 = offsetof(struct thread_options, profile),
4196 .help = "Select a specific builtin performance test",
4197 .category = FIO_OPT_C_PROFILE,
4198 .group = FIO_OPT_G_INVALID,
4203 .type = FIO_OPT_STR_STORE,
4204 .off1 = offsetof(struct thread_options, cgroup),
4205 .help = "Add job to cgroup of this name",
4206 .category = FIO_OPT_C_GENERAL,
4207 .group = FIO_OPT_G_CGROUP,
4210 .name = "cgroup_nodelete",
4211 .lname = "Cgroup no-delete",
4212 .type = FIO_OPT_BOOL,
4213 .off1 = offsetof(struct thread_options, cgroup_nodelete),
4214 .help = "Do not delete cgroups after job completion",
4217 .category = FIO_OPT_C_GENERAL,
4218 .group = FIO_OPT_G_CGROUP,
4221 .name = "cgroup_weight",
4222 .lname = "Cgroup weight",
4223 .type = FIO_OPT_INT,
4224 .off1 = offsetof(struct thread_options, cgroup_weight),
4225 .help = "Use given weight for cgroup",
4229 .category = FIO_OPT_C_GENERAL,
4230 .group = FIO_OPT_G_CGROUP,
4235 .type = FIO_OPT_INT,
4236 .off1 = offsetof(struct thread_options, uid),
4237 .help = "Run job with this user ID",
4238 .category = FIO_OPT_C_GENERAL,
4239 .group = FIO_OPT_G_CRED,
4243 .lname = "Group ID",
4244 .type = FIO_OPT_INT,
4245 .off1 = offsetof(struct thread_options, gid),
4246 .help = "Run job with this group ID",
4247 .category = FIO_OPT_C_GENERAL,
4248 .group = FIO_OPT_G_CRED,
4253 .type = FIO_OPT_INT,
4254 .off1 = offsetof(struct thread_options, kb_base),
4260 .help = "Inputs invert IEC and SI prefixes (for compatibility); outputs prefer binary",
4264 .help = "Inputs use IEC and SI prefixes; outputs prefer SI",
4267 .help = "Unit prefix interpretation for quantities of data (IEC and SI)",
4268 .category = FIO_OPT_C_GENERAL,
4269 .group = FIO_OPT_G_INVALID,
4272 .name = "unit_base",
4273 .lname = "Unit for quantities of data (Bits or Bytes)",
4274 .type = FIO_OPT_INT,
4275 .off1 = offsetof(struct thread_options, unit_base),
4280 .help = "Auto-detect",
4284 .help = "Normal (byte based)",
4288 .help = "Bit based",
4291 .help = "Bit multiple of result summary data (8 for byte, 1 for bit)",
4292 .category = FIO_OPT_C_GENERAL,
4293 .group = FIO_OPT_G_INVALID,
4296 .name = "hugepage-size",
4297 .lname = "Hugepage size",
4298 .type = FIO_OPT_INT,
4299 .off1 = offsetof(struct thread_options, hugepage_size),
4300 .help = "When using hugepages, specify size of each page",
4301 .def = __fio_stringify(FIO_HUGE_PAGE),
4302 .interval = 1024 * 1024,
4303 .category = FIO_OPT_C_GENERAL,
4304 .group = FIO_OPT_G_INVALID,
4308 .lname = "I/O flow ID",
4309 .type = FIO_OPT_INT,
4310 .off1 = offsetof(struct thread_options, flow_id),
4311 .help = "The flow index ID to use",
4313 .category = FIO_OPT_C_IO,
4314 .group = FIO_OPT_G_IO_FLOW,
4318 .lname = "I/O flow weight",
4319 .type = FIO_OPT_INT,
4320 .off1 = offsetof(struct thread_options, flow),
4321 .help = "Weight for flow control of this job",
4322 .parent = "flow_id",
4325 .category = FIO_OPT_C_IO,
4326 .group = FIO_OPT_G_IO_FLOW,
4329 .name = "flow_watermark",
4330 .lname = "I/O flow watermark",
4331 .type = FIO_OPT_INT,
4332 .off1 = offsetof(struct thread_options, flow_watermark),
4333 .help = "High watermark for flow control. This option"
4334 " should be set to the same value for all threads"
4335 " with non-zero flow.",
4336 .parent = "flow_id",
4339 .category = FIO_OPT_C_IO,
4340 .group = FIO_OPT_G_IO_FLOW,
4343 .name = "flow_sleep",
4344 .lname = "I/O flow sleep",
4345 .type = FIO_OPT_INT,
4346 .off1 = offsetof(struct thread_options, flow_sleep),
4347 .help = "How many microseconds to sleep after being held"
4348 " back by the flow control mechanism",
4349 .parent = "flow_id",
4352 .category = FIO_OPT_C_IO,
4353 .group = FIO_OPT_G_IO_FLOW,
4357 .lname = "Skip operations against bad blocks",
4358 .type = FIO_OPT_BOOL,
4359 .off1 = offsetof(struct thread_options, skip_bad),
4360 .help = "Skip operations against known bad blocks.",
4363 .category = FIO_OPT_C_IO,
4364 .group = FIO_OPT_G_MTD,
4367 .name = "steadystate",
4368 .lname = "Steady state threshold",
4370 .type = FIO_OPT_STR,
4371 .off1 = offsetof(struct thread_options, ss_state),
4372 .cb = str_steadystate_cb,
4373 .help = "Define the criterion and limit to judge when a job has reached steady state",
4374 .def = "iops_slope:0.01%",
4377 .oval = FIO_SS_IOPS,
4378 .help = "maximum mean deviation of IOPS measurements",
4380 { .ival = "iops_slope",
4381 .oval = FIO_SS_IOPS_SLOPE,
4382 .help = "slope calculated from IOPS measurements",
4386 .help = "maximum mean deviation of bandwidth measurements",
4390 .oval = FIO_SS_BW_SLOPE,
4391 .help = "slope calculated from bandwidth measurements",
4394 .category = FIO_OPT_C_GENERAL,
4395 .group = FIO_OPT_G_RUNTIME,
4398 .name = "steadystate_duration",
4399 .lname = "Steady state duration",
4401 .parent = "steadystate",
4402 .type = FIO_OPT_STR_VAL_TIME,
4403 .off1 = offsetof(struct thread_options, ss_dur),
4404 .help = "Stop workload upon attaining steady state for specified duration",
4408 .category = FIO_OPT_C_GENERAL,
4409 .group = FIO_OPT_G_RUNTIME,
4412 .name = "steadystate_ramp_time",
4413 .lname = "Steady state ramp time",
4415 .parent = "steadystate",
4416 .type = FIO_OPT_STR_VAL_TIME,
4417 .off1 = offsetof(struct thread_options, ss_ramp_time),
4418 .help = "Delay before initiation of data collection for steady state job termination testing",
4422 .category = FIO_OPT_C_GENERAL,
4423 .group = FIO_OPT_G_RUNTIME,
4430 static void add_to_lopt(struct option *lopt, struct fio_option *o,
4431 const char *name, int val)
4433 lopt->name = (char *) name;
4435 if (o->type == FIO_OPT_STR_SET)
4436 lopt->has_arg = optional_argument;
4438 lopt->has_arg = required_argument;
4441 static void options_to_lopts(struct fio_option *opts,
4442 struct option *long_options,
4443 int i, int option_type)
4445 struct fio_option *o = &opts[0];
4447 add_to_lopt(&long_options[i], o, o->name, option_type);
4450 add_to_lopt(&long_options[i], o, o->alias, option_type);
4455 assert(i < FIO_NR_OPTIONS);
4459 void fio_options_set_ioengine_opts(struct option *long_options,
4460 struct thread_data *td)
4465 while (long_options[i].name) {
4466 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
4467 memset(&long_options[i], 0, sizeof(*long_options));
4474 * Just clear out the prior ioengine options.
4479 options_to_lopts(td->io_ops->options, long_options, i,
4480 FIO_GETOPT_IOENGINE);
4483 void fio_options_dup_and_init(struct option *long_options)
4487 options_init(fio_options);
4490 while (long_options[i].name)
4493 options_to_lopts(fio_options, long_options, i, FIO_GETOPT_JOB);
4496 struct fio_keyword {
4502 static struct fio_keyword fio_keywords[] = {
4504 .word = "$pagesize",
4505 .desc = "Page size in the system",
4508 .word = "$mb_memory",
4509 .desc = "Megabytes of memory online",
4513 .desc = "Number of CPUs online in the system",
4520 void fio_keywords_exit(void)
4522 struct fio_keyword *kw;
4524 kw = &fio_keywords[0];
4532 void fio_keywords_init(void)
4534 unsigned long long mb_memory;
4538 sprintf(buf, "%lu", (unsigned long) page_size);
4539 fio_keywords[0].replace = strdup(buf);
4541 mb_memory = os_phys_mem() / (1024 * 1024);
4542 sprintf(buf, "%llu", mb_memory);
4543 fio_keywords[1].replace = strdup(buf);
4546 sprintf(buf, "%lu", l);
4547 fio_keywords[2].replace = strdup(buf);
4552 static char *bc_calc(char *str)
4554 char buf[128], *tmp;
4559 * No math, just return string
4561 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
4562 !strchr(str, '/')) || strchr(str, '\''))
4566 * Split option from value, we only need to calculate the value
4568 tmp = strchr(str, '=');
4575 * Prevent buffer overflows; such a case isn't reasonable anyway
4577 if (strlen(str) >= 128 || strlen(tmp) > 100)
4580 sprintf(buf, "which %s > /dev/null", BC_APP);
4582 log_err("fio: bc is needed for performing math\n");
4586 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
4587 f = popen(buf, "r");
4591 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
4598 buf[(tmp - str) + ret - 1] = '\0';
4599 memcpy(buf, str, tmp - str);
4605 * Return a copy of the input string with substrings of the form ${VARNAME}
4606 * substituted with the value of the environment variable VARNAME. The
4607 * substitution always occurs, even if VARNAME is empty or the corresponding
4608 * environment variable undefined.
4610 static char *option_dup_subs(const char *opt)
4612 char out[OPT_LEN_MAX+1];
4613 char in[OPT_LEN_MAX+1];
4616 char *ch1, *ch2, *env;
4617 ssize_t nchr = OPT_LEN_MAX;
4620 if (strlen(opt) + 1 > OPT_LEN_MAX) {
4621 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
4625 in[OPT_LEN_MAX] = '\0';
4626 strncpy(in, opt, OPT_LEN_MAX);
4628 while (*inptr && nchr > 0) {
4629 if (inptr[0] == '$' && inptr[1] == '{') {
4630 ch2 = strchr(inptr, '}');
4631 if (ch2 && inptr+1 < ch2) {
4638 envlen = strlen(env);
4639 if (envlen <= nchr) {
4640 memcpy(outptr, env, envlen);
4650 *outptr++ = *inptr++;
4659 * Look for reserved variable names and replace them with real values
4661 static char *fio_keyword_replace(char *opt)
4667 for (i = 0; fio_keywords[i].word != NULL; i++) {
4668 struct fio_keyword *kw = &fio_keywords[i];
4670 while ((s = strstr(opt, kw->word)) != NULL) {
4671 char *new = malloc(strlen(opt) + 1);
4677 * Copy part of the string before the keyword and
4678 * sprintf() the replacement after it.
4680 memcpy(new, opt, olen);
4681 len = sprintf(new + olen, "%s", kw->replace);
4684 * If there's more in the original string, copy that
4687 opt += strlen(kw->word) + olen;
4689 memcpy(new + olen + len, opt, opt - o_org - 1);
4692 * replace opt and free the old opt
4702 * Check for potential math and invoke bc, if possible
4710 static char **dup_and_sub_options(char **opts, int num_opts)
4713 char **opts_copy = malloc(num_opts * sizeof(*opts));
4714 for (i = 0; i < num_opts; i++) {
4715 opts_copy[i] = option_dup_subs(opts[i]);
4718 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
4723 static void show_closest_option(const char *opt)
4725 int best_option, best_distance;
4734 while (name[i] != '\0' && name[i] != '=')
4739 best_distance = INT_MAX;
4741 while (fio_options[i].name) {
4742 distance = string_distance(name, fio_options[i].name);
4743 if (distance < best_distance) {
4744 best_distance = distance;
4750 if (best_option != -1 && string_distance_ok(name, best_distance) &&
4751 fio_options[best_option].type != FIO_OPT_UNSUPPORTED)
4752 log_err("Did you mean %s?\n", fio_options[best_option].name);
4757 int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
4759 int i, ret, unknown;
4762 sort_options(opts, fio_options, num_opts);
4763 opts_copy = dup_and_sub_options(opts, num_opts);
4765 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
4766 struct fio_option *o;
4767 int newret = parse_option(opts_copy[i], opts[i], fio_options,
4768 &o, &td->o, &td->opt_list);
4771 fio_option_mark_set(&td->o, o);
4779 opts_copy[i] = NULL;
4786 ret |= ioengine_load(td);
4788 sort_options(opts_copy, td->io_ops->options, num_opts);
4791 for (i = 0; i < num_opts; i++) {
4792 struct fio_option *o = NULL;
4799 newret = parse_option(opts_copy[i], opts[i],
4800 td->io_ops->options, &o,
4801 td->eo, &td->opt_list);
4805 log_err("Bad option <%s>\n", opts[i]);
4806 show_closest_option(opts[i]);
4809 opts_copy[i] = NULL;
4817 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
4821 ret = parse_cmd_option(opt, val, fio_options, &td->o, &td->opt_list);
4823 struct fio_option *o;
4825 o = find_option(fio_options, opt);
4827 fio_option_mark_set(&td->o, o);
4833 int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
4836 return parse_cmd_option(opt, val, td->io_ops->options, td->eo,
4840 void fio_fill_default_options(struct thread_data *td)
4842 td->o.magic = OPT_MAGIC;
4843 fill_default_options(&td->o, fio_options);
4846 int fio_show_option_help(const char *opt)
4848 return show_cmd_help(fio_options, opt);
4852 * dupe FIO_OPT_STR_STORE options
4854 void fio_options_mem_dupe(struct thread_data *td)
4856 options_mem_dupe(fio_options, &td->o);
4858 if (td->eo && td->io_ops) {
4859 void *oldeo = td->eo;
4861 td->eo = malloc(td->io_ops->option_struct_size);
4862 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
4863 options_mem_dupe(td->io_ops->options, td->eo);
4867 unsigned int fio_get_kb_base(void *data)
4869 struct thread_data *td = cb_data_to_td(data);
4870 struct thread_options *o = &td->o;
4871 unsigned int kb_base = 0;
4874 * This is a hack... For private options, *data is not holding
4875 * a pointer to the thread_options, but to private data. This means
4876 * we can't safely dereference it, but magic is first so mem wise
4877 * it is valid. But this also means that if the job first sets
4878 * kb_base and expects that to be honored by private options,
4879 * it will be disappointed. We will return the global default
4882 if (o && o->magic == OPT_MAGIC)
4883 kb_base = o->kb_base;
4890 int add_option(struct fio_option *o)
4892 struct fio_option *__o;
4901 if (opt_index + 1 == FIO_MAX_OPTS) {
4902 log_err("fio: FIO_MAX_OPTS is too small\n");
4906 memcpy(&fio_options[opt_index], o, sizeof(*o));
4907 fio_options[opt_index + 1].name = NULL;
4911 void invalidate_profile_options(const char *prof_name)
4913 struct fio_option *o;
4917 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
4918 o->type = FIO_OPT_INVALID;
4919 o->prof_name = NULL;
4925 void add_opt_posval(const char *optname, const char *ival, const char *help)
4927 struct fio_option *o;
4930 o = find_option(fio_options, optname);
4934 for (i = 0; i < PARSE_MAX_VP; i++) {
4935 if (o->posval[i].ival)
4938 o->posval[i].ival = ival;
4939 o->posval[i].help = help;
4944 void del_opt_posval(const char *optname, const char *ival)
4946 struct fio_option *o;
4949 o = find_option(fio_options, optname);
4953 for (i = 0; i < PARSE_MAX_VP; i++) {
4954 if (!o->posval[i].ival)
4956 if (strcmp(o->posval[i].ival, ival))
4959 o->posval[i].ival = NULL;
4960 o->posval[i].help = NULL;
4964 void fio_options_free(struct thread_data *td)
4966 options_free(fio_options, &td->o);
4967 if (td->eo && td->io_ops && td->io_ops->options) {
4968 options_free(td->io_ops->options, td->eo);
4974 struct fio_option *fio_option_find(const char *name)
4976 return find_option(fio_options, name);
4979 static struct fio_option *find_next_opt(struct thread_options *o,
4980 struct fio_option *from,
4983 struct fio_option *opt;
4986 from = &fio_options[0];
4992 if (off1 == from->off1) {
4997 } while (from->name);
5002 static int opt_is_set(struct thread_options *o, struct fio_option *opt)
5004 unsigned int opt_off, index, offset;
5006 opt_off = opt - &fio_options[0];
5007 index = opt_off / (8 * sizeof(uint64_t));
5008 offset = opt_off & ((8 * sizeof(uint64_t)) - 1);
5009 return (o->set_options[index] & ((uint64_t)1 << offset)) != 0;
5012 bool __fio_option_is_set(struct thread_options *o, unsigned int off1)
5014 struct fio_option *opt, *next;
5017 while ((opt = find_next_opt(o, next, off1)) != NULL) {
5018 if (opt_is_set(o, opt))
5027 void fio_option_mark_set(struct thread_options *o, struct fio_option *opt)
5029 unsigned int opt_off, index, offset;
5031 opt_off = opt - &fio_options[0];
5032 index = opt_off / (8 * sizeof(uint64_t));
5033 offset = opt_off & ((8 * sizeof(uint64_t)) - 1);
5034 o->set_options[index] |= (uint64_t)1 << offset;