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 = malloc(4 * sizeof(struct bssplit));
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",
317 td->o.continue_on_error |= 1 << etype;
318 td->o.ignore_error_nr[etype] = i;
319 td->o.ignore_error[etype] = error;
327 static int str_ignore_error_cb(void *data, const char *input)
329 struct thread_data *td = cb_data_to_td(data);
331 int type = 0, ret = 1;
336 p = str = strdup(input);
338 strip_blank_front(&str);
339 strip_blank_end(str);
345 ret = ignore_error_type(td, type, p);
355 static int str_rw_cb(void *data, const char *str)
357 struct thread_data *td = cb_data_to_td(data);
358 struct thread_options *o = &td->o;
367 nr = get_opt_postfix(str);
372 o->ddir_seq_nr = atoi(nr);
376 if (str_to_decimal(nr, &val, 1, o, 0, 0)) {
377 log_err("fio: rw postfix parsing failed\n");
382 o->ddir_seq_add = val;
389 static int str_mem_cb(void *data, const char *mem)
391 struct thread_data *td = cb_data_to_td(data);
393 if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP ||
394 td->o.mem_type == MEM_MMAPSHARED)
395 td->o.mmapfile = get_opt_postfix(mem);
400 static int fio_clock_source_cb(void *data, const char *str)
402 struct thread_data *td = cb_data_to_td(data);
404 fio_clock_source = td->o.clocksource;
405 fio_clock_source_set = 1;
410 static int str_rwmix_read_cb(void *data, unsigned long long *val)
412 struct thread_data *td = cb_data_to_td(data);
414 td->o.rwmix[DDIR_READ] = *val;
415 td->o.rwmix[DDIR_WRITE] = 100 - *val;
419 static int str_rwmix_write_cb(void *data, unsigned long long *val)
421 struct thread_data *td = cb_data_to_td(data);
423 td->o.rwmix[DDIR_WRITE] = *val;
424 td->o.rwmix[DDIR_READ] = 100 - *val;
428 static int str_exitall_cb(void)
430 exitall_on_terminate = 1;
434 #ifdef FIO_HAVE_CPU_AFFINITY
435 int fio_cpus_split(os_cpu_mask_t *mask, unsigned int cpu_index)
437 unsigned int i, index, cpus_in_mask;
438 const long max_cpu = cpus_online();
440 cpus_in_mask = fio_cpu_count(mask);
441 cpu_index = cpu_index % cpus_in_mask;
444 for (i = 0; i < max_cpu; i++) {
445 if (!fio_cpu_isset(mask, i))
448 if (cpu_index != index)
449 fio_cpu_clear(mask, i);
454 return fio_cpu_count(mask);
457 static int str_cpumask_cb(void *data, unsigned long long *val)
459 struct thread_data *td = cb_data_to_td(data);
467 ret = fio_cpuset_init(&td->o.cpumask);
469 log_err("fio: cpuset_init failed\n");
470 td_verror(td, ret, "fio_cpuset_init");
474 max_cpu = cpus_online();
476 for (i = 0; i < sizeof(int) * 8; i++) {
477 if ((1 << i) & *val) {
479 log_err("fio: CPU %d too large (max=%ld)\n", i,
483 dprint(FD_PARSE, "set cpu allowed %d\n", i);
484 fio_cpu_set(&td->o.cpumask, i);
491 static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask,
498 ret = fio_cpuset_init(mask);
500 log_err("fio: cpuset_init failed\n");
501 td_verror(td, ret, "fio_cpuset_init");
505 p = str = strdup(input);
507 strip_blank_front(&str);
508 strip_blank_end(str);
510 max_cpu = cpus_online();
512 while ((cpu = strsep(&str, ",")) != NULL) {
521 while ((cpu2 = strsep(&str2, "-")) != NULL) {
531 while (icpu <= icpu2) {
532 if (icpu >= FIO_MAX_CPUS) {
533 log_err("fio: your OS only supports up to"
534 " %d CPUs\n", (int) FIO_MAX_CPUS);
538 if (icpu >= max_cpu) {
539 log_err("fio: CPU %d too large (max=%ld)\n",
545 dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
546 fio_cpu_set(mask, icpu);
557 static int str_cpus_allowed_cb(void *data, const char *input)
559 struct thread_data *td = cb_data_to_td(data);
564 return set_cpus_allowed(td, &td->o.cpumask, input);
567 static int str_verify_cpus_allowed_cb(void *data, const char *input)
569 struct thread_data *td = cb_data_to_td(data);
574 return set_cpus_allowed(td, &td->o.verify_cpumask, input);
578 static int str_log_cpus_allowed_cb(void *data, const char *input)
580 struct thread_data *td = cb_data_to_td(data);
585 return set_cpus_allowed(td, &td->o.log_gz_cpumask, input);
587 #endif /* CONFIG_ZLIB */
589 #endif /* FIO_HAVE_CPU_AFFINITY */
591 #ifdef CONFIG_LIBNUMA
592 static int str_numa_cpunodes_cb(void *data, char *input)
594 struct thread_data *td = cb_data_to_td(data);
595 struct bitmask *verify_bitmask;
600 /* numa_parse_nodestring() parses a character string list
601 * of nodes into a bit mask. The bit mask is allocated by
602 * numa_allocate_nodemask(), so it should be freed by
603 * numa_free_nodemask().
605 verify_bitmask = numa_parse_nodestring(input);
606 if (verify_bitmask == NULL) {
607 log_err("fio: numa_parse_nodestring failed\n");
608 td_verror(td, 1, "str_numa_cpunodes_cb");
611 numa_free_nodemask(verify_bitmask);
613 td->o.numa_cpunodes = strdup(input);
617 static int str_numa_mpol_cb(void *data, char *input)
619 struct thread_data *td = cb_data_to_td(data);
620 const char * const policy_types[] =
621 { "default", "prefer", "bind", "interleave", "local", NULL };
624 struct bitmask *verify_bitmask;
629 nodelist = strchr(input, ':');
631 /* NUL-terminate mode */
635 for (i = 0; i <= MPOL_LOCAL; i++) {
636 if (!strcmp(input, policy_types[i])) {
637 td->o.numa_mem_mode = i;
641 if (i > MPOL_LOCAL) {
642 log_err("fio: memory policy should be: default, prefer, bind, interleave, local\n");
646 switch (td->o.numa_mem_mode) {
649 * Insist on a nodelist of one node only
652 char *rest = nodelist;
653 while (isdigit(*rest))
656 log_err("fio: one node only for \'prefer\'\n");
660 log_err("fio: one node is needed for \'prefer\'\n");
664 case MPOL_INTERLEAVE:
666 * Default to online nodes with memory if no nodelist
669 nodelist = strdup("all");
674 * Don't allow a nodelist
677 log_err("fio: NO nodelist for \'local\'\n");
683 * Insist on a nodelist
686 log_err("fio: a nodelist is needed for \'bind\'\n");
693 /* numa_parse_nodestring() parses a character string list
694 * of nodes into a bit mask. The bit mask is allocated by
695 * numa_allocate_nodemask(), so it should be freed by
696 * numa_free_nodemask().
698 switch (td->o.numa_mem_mode) {
700 td->o.numa_mem_prefer_node = atoi(nodelist);
702 case MPOL_INTERLEAVE:
704 verify_bitmask = numa_parse_nodestring(nodelist);
705 if (verify_bitmask == NULL) {
706 log_err("fio: numa_parse_nodestring failed\n");
707 td_verror(td, 1, "str_numa_memnodes_cb");
710 td->o.numa_memnodes = strdup(nodelist);
711 numa_free_nodemask(verify_bitmask);
726 static int str_fst_cb(void *data, const char *str)
728 struct thread_data *td = cb_data_to_td(data);
733 td->file_service_nr = 1;
735 switch (td->o.file_service_type) {
736 case FIO_FSERVICE_RANDOM:
737 case FIO_FSERVICE_RR:
738 case FIO_FSERVICE_SEQ:
739 nr = get_opt_postfix(str);
741 td->file_service_nr = atoi(nr);
746 case FIO_FSERVICE_ZIPF:
749 case FIO_FSERVICE_PARETO:
750 val = FIO_DEF_PARETO;
752 case FIO_FSERVICE_GAUSS:
756 log_err("fio: bad file service type: %d\n", td->o.file_service_type);
763 nr = get_opt_postfix(str);
764 if (nr && !str_to_float(nr, &val, 0)) {
765 log_err("fio: file service type random postfix parsing failed\n");
772 switch (td->o.file_service_type) {
773 case FIO_FSERVICE_ZIPF:
775 log_err("fio: zipf theta must be different than 1.0\n");
780 td->zipf_theta = val;
782 case FIO_FSERVICE_PARETO:
783 if (val <= 0.00 || val >= 1.00) {
784 log_err("fio: pareto input out of range (0 < input < 1.0)\n");
791 case FIO_FSERVICE_GAUSS:
792 if (val < 0.00 || val >= 100.00) {
793 log_err("fio: normal deviation out of range (0 <= input < 100.0)\n");
805 #ifdef CONFIG_SYNC_FILE_RANGE
806 static int str_sfr_cb(void *data, const char *str)
808 struct thread_data *td = cb_data_to_td(data);
809 char *nr = get_opt_postfix(str);
811 td->sync_file_range_nr = 1;
813 td->sync_file_range_nr = atoi(nr);
821 static int zone_cmp(const void *p1, const void *p2)
823 const struct zone_split *zsp1 = p1;
824 const struct zone_split *zsp2 = p2;
826 return (int) zsp2->access_perc - (int) zsp1->access_perc;
829 static int zone_split_ddir(struct thread_options *o, enum fio_ddir ddir,
832 unsigned int i, perc, perc_missing, sperc, sperc_missing;
835 memset(&split, 0, sizeof(split));
837 if (split_parse_ddir(o, &split, ddir, str))
842 o->zone_split[ddir] = malloc(split.nr * sizeof(struct zone_split));
843 o->zone_split_nr[ddir] = split.nr;
844 for (i = 0; i < split.nr; i++) {
845 o->zone_split[ddir][i].access_perc = split.val1[i];
846 o->zone_split[ddir][i].size_perc = split.val2[i];
850 * Now check if the percentages add up, and how much is missing
852 perc = perc_missing = 0;
853 sperc = sperc_missing = 0;
854 for (i = 0; i < o->zone_split_nr[ddir]; i++) {
855 struct zone_split *zsp = &o->zone_split[ddir][i];
857 if (zsp->access_perc == (uint8_t) -1U)
860 perc += zsp->access_perc;
862 if (zsp->size_perc == (uint8_t) -1U)
865 sperc += zsp->size_perc;
869 if (perc > 100 || sperc > 100) {
870 log_err("fio: zone_split percentages add to more than 100%%\n");
871 free(o->zone_split[ddir]);
872 o->zone_split[ddir] = NULL;
876 log_err("fio: access percentage don't add up to 100 for zoned "
877 "random distribution (got=%u)\n", perc);
878 free(o->zone_split[ddir]);
879 o->zone_split[ddir] = NULL;
884 * If values didn't have a percentage set, divide the remains between
888 if (perc_missing == 1 && o->zone_split_nr[ddir] == 1)
890 for (i = 0; i < o->zone_split_nr[ddir]; i++) {
891 struct zone_split *zsp = &o->zone_split[ddir][i];
893 if (zsp->access_perc == (uint8_t) -1U)
894 zsp->access_perc = (100 - perc) / perc_missing;
898 if (sperc_missing == 1 && o->zone_split_nr[ddir] == 1)
900 for (i = 0; i < o->zone_split_nr[ddir]; i++) {
901 struct zone_split *zsp = &o->zone_split[ddir][i];
903 if (zsp->size_perc == (uint8_t) -1U)
904 zsp->size_perc = (100 - sperc) / sperc_missing;
909 * now sort based on percentages, for ease of lookup
911 qsort(o->zone_split[ddir], o->zone_split_nr[ddir], sizeof(struct zone_split), zone_cmp);
915 static void __td_zone_gen_index(struct thread_data *td, enum fio_ddir ddir)
917 unsigned int i, j, sprev, aprev;
919 td->zone_state_index[ddir] = malloc(sizeof(struct zone_split_index) * 100);
922 for (i = 0; i < td->o.zone_split_nr[ddir]; i++) {
923 struct zone_split *zsp = &td->o.zone_split[ddir][i];
925 for (j = aprev; j < aprev + zsp->access_perc; j++) {
926 struct zone_split_index *zsi = &td->zone_state_index[ddir][j];
928 zsi->size_perc = sprev + zsp->size_perc;
929 zsi->size_perc_prev = sprev;
932 aprev += zsp->access_perc;
933 sprev += zsp->size_perc;
938 * Generate state table for indexes, so we don't have to do it inline from
941 static void td_zone_gen_index(struct thread_data *td)
945 td->zone_state_index = malloc(DDIR_RWDIR_CNT *
946 sizeof(struct zone_split_index *));
948 for (i = 0; i < DDIR_RWDIR_CNT; i++)
949 __td_zone_gen_index(td, i);
952 static int parse_zoned_distribution(struct thread_data *td, const char *input)
957 p = str = strdup(input);
959 strip_blank_front(&str);
960 strip_blank_end(str);
962 /* We expect it to start like that, bail if not */
963 if (strncmp(str, "zoned:", 6)) {
964 log_err("fio: mismatch in zoned input <%s>\n", str);
968 str += strlen("zoned:");
970 ret = str_split_parse(td, str, zone_split_ddir);
974 for (i = 0; i < DDIR_RWDIR_CNT; i++) {
977 dprint(FD_PARSE, "zone ddir %d (nr=%u): \n", i, td->o.zone_split_nr[i]);
979 for (j = 0; j < td->o.zone_split_nr[i]; j++) {
980 struct zone_split *zsp = &td->o.zone_split[i][j];
982 dprint(FD_PARSE, "\t%d: %u/%u\n", j, zsp->access_perc,
987 if (parse_dryrun()) {
990 for (i = 0; i < DDIR_RWDIR_CNT; i++) {
991 free(td->o.zone_split[i]);
992 td->o.zone_split[i] = NULL;
993 td->o.zone_split_nr[i] = 0;
1000 td_zone_gen_index(td);
1002 for (i = 0; i < DDIR_RWDIR_CNT; i++)
1003 td->o.zone_split_nr[i] = 0;
1009 static int str_random_distribution_cb(void *data, const char *str)
1011 struct thread_data *td = cb_data_to_td(data);
1015 if (td->o.random_distribution == FIO_RAND_DIST_ZIPF)
1017 else if (td->o.random_distribution == FIO_RAND_DIST_PARETO)
1018 val = FIO_DEF_PARETO;
1019 else if (td->o.random_distribution == FIO_RAND_DIST_GAUSS)
1021 else if (td->o.random_distribution == FIO_RAND_DIST_ZONED)
1022 return parse_zoned_distribution(td, str);
1026 nr = get_opt_postfix(str);
1027 if (nr && !str_to_float(nr, &val, 0)) {
1028 log_err("fio: random postfix parsing failed\n");
1035 if (td->o.random_distribution == FIO_RAND_DIST_ZIPF) {
1037 log_err("fio: zipf theta must different than 1.0\n");
1042 td->o.zipf_theta.u.f = val;
1043 } else if (td->o.random_distribution == FIO_RAND_DIST_PARETO) {
1044 if (val <= 0.00 || val >= 1.00) {
1045 log_err("fio: pareto input out of range (0 < input < 1.0)\n");
1050 td->o.pareto_h.u.f = val;
1052 if (val < 0.00 || val >= 100.0) {
1053 log_err("fio: normal deviation out of range (0 <= input < 100.0)\n");
1058 td->o.gauss_dev.u.f = val;
1064 static int str_steadystate_cb(void *data, const char *str)
1066 struct thread_data *td = cb_data_to_td(data);
1072 if (td->o.ss_state != FIO_SS_IOPS && td->o.ss_state != FIO_SS_IOPS_SLOPE &&
1073 td->o.ss_state != FIO_SS_BW && td->o.ss_state != FIO_SS_BW_SLOPE) {
1074 /* should be impossible to get here */
1075 log_err("fio: unknown steady state criterion\n");
1079 nr = get_opt_postfix(str);
1081 log_err("fio: steadystate threshold must be specified in addition to criterion\n");
1086 /* ENHANCEMENT Allow fio to understand size=10.2% and use here */
1087 pct = strstr(nr, "%");
1090 strip_blank_end(nr);
1091 if (!str_to_float(nr, &val, 0)) {
1092 log_err("fio: could not parse steadystate threshold percentage\n");
1097 dprint(FD_PARSE, "set steady state threshold to %f%%\n", val);
1102 td->o.ss_state |= __FIO_SS_PCT;
1103 td->o.ss_limit.u.f = val;
1104 } else if (td->o.ss_state & __FIO_SS_IOPS) {
1105 if (!str_to_float(nr, &val, 0)) {
1106 log_err("fio: steadystate IOPS threshold postfix parsing failed\n");
1111 dprint(FD_PARSE, "set steady state IOPS threshold to %f\n", val);
1116 td->o.ss_limit.u.f = val;
1117 } else { /* bandwidth criterion */
1118 if (str_to_decimal(nr, &ll, 1, td, 0, 0)) {
1119 log_err("fio: steadystate BW threshold postfix parsing failed\n");
1124 dprint(FD_PARSE, "set steady state BW threshold to %lld\n", ll);
1129 td->o.ss_limit.u.f = (double) ll;
1132 td->ss.state = td->o.ss_state;
1137 * Return next name in the string. Files are separated with ':'. If the ':'
1138 * is escaped with a '\', then that ':' is part of the filename and does not
1139 * indicate a new file.
1141 static char *get_next_name(char **ptr)
1146 if (!str || !strlen(str))
1152 * No colon, we are done
1154 p = strchr(str, ':');
1161 * We got a colon, but it's the first character. Skip and
1169 if (*(p - 1) != '\\') {
1175 memmove(p - 1, p, strlen(p) + 1);
1183 static int get_max_name_idx(char *input)
1185 unsigned int cur_idx;
1188 p = str = strdup(input);
1189 for (cur_idx = 0; ; cur_idx++)
1190 if (get_next_name(&str) == NULL)
1198 * Returns the directory at the index, indexes > entires will be
1199 * assigned via modulo division of the index
1201 int set_name_idx(char *target, size_t tlen, char *input, int index,
1202 bool unique_filename)
1204 unsigned int cur_idx;
1206 char *fname, *str, *p;
1208 p = str = strdup(input);
1210 index %= get_max_name_idx(input);
1211 for (cur_idx = 0; cur_idx <= index; cur_idx++)
1212 fname = get_next_name(&str);
1214 if (client_sockaddr_str[0] && unique_filename) {
1215 len = snprintf(target, tlen, "%s/%s.", fname,
1216 client_sockaddr_str);
1218 len = snprintf(target, tlen, "%s/", fname);
1220 target[tlen - 1] = '\0';
1226 static int str_filename_cb(void *data, const char *input)
1228 struct thread_data *td = cb_data_to_td(data);
1229 char *fname, *str, *p;
1231 p = str = strdup(input);
1233 strip_blank_front(&str);
1234 strip_blank_end(str);
1236 if (!td->files_index)
1239 while ((fname = get_next_name(&str)) != NULL) {
1242 add_file(td, fname, 0, 1);
1249 static int str_directory_cb(void *data, const char fio_unused *unused)
1251 struct thread_data *td = cb_data_to_td(data);
1253 char *dirname, *str, *p;
1259 p = str = strdup(td->o.directory);
1260 while ((dirname = get_next_name(&str)) != NULL) {
1261 if (lstat(dirname, &sb) < 0) {
1264 log_err("fio: %s is not a directory\n", dirname);
1265 td_verror(td, ret, "lstat");
1268 if (!S_ISDIR(sb.st_mode)) {
1269 log_err("fio: %s is not a directory\n", dirname);
1280 static int str_opendir_cb(void *data, const char fio_unused *str)
1282 struct thread_data *td = cb_data_to_td(data);
1287 if (!td->files_index)
1290 return add_dir_files(td, td->o.opendir);
1293 static int str_buffer_pattern_cb(void *data, const char *input)
1295 struct thread_data *td = cb_data_to_td(data);
1298 /* FIXME: for now buffer pattern does not support formats */
1299 ret = parse_and_fill_pattern(input, strlen(input), td->o.buffer_pattern,
1300 MAX_PATTERN_SIZE, NULL, 0, NULL, NULL);
1305 td->o.buffer_pattern_bytes = ret;
1306 if (!td->o.compress_percentage)
1307 td->o.refill_buffers = 0;
1308 td->o.scramble_buffers = 0;
1309 td->o.zero_buffers = 0;
1314 static int str_buffer_compress_cb(void *data, unsigned long long *il)
1316 struct thread_data *td = cb_data_to_td(data);
1318 td->flags |= TD_F_COMPRESS;
1319 td->o.compress_percentage = *il;
1323 static int str_dedupe_cb(void *data, unsigned long long *il)
1325 struct thread_data *td = cb_data_to_td(data);
1327 td->flags |= TD_F_COMPRESS;
1328 td->o.dedupe_percentage = *il;
1329 td->o.refill_buffers = 1;
1333 static int str_verify_pattern_cb(void *data, const char *input)
1335 struct thread_data *td = cb_data_to_td(data);
1338 td->o.verify_fmt_sz = ARRAY_SIZE(td->o.verify_fmt);
1339 ret = parse_and_fill_pattern(input, strlen(input), td->o.verify_pattern,
1340 MAX_PATTERN_SIZE, fmt_desc, sizeof(fmt_desc),
1341 td->o.verify_fmt, &td->o.verify_fmt_sz);
1346 td->o.verify_pattern_bytes = ret;
1348 * VERIFY_* could already be set
1350 if (!fio_option_is_set(&td->o, verify))
1351 td->o.verify = VERIFY_PATTERN;
1356 static int str_gtod_reduce_cb(void *data, int *il)
1358 struct thread_data *td = cb_data_to_td(data);
1361 td->o.disable_lat = !!val;
1362 td->o.disable_clat = !!val;
1363 td->o.disable_slat = !!val;
1364 td->o.disable_bw = !!val;
1365 td->o.clat_percentiles = !val;
1367 td->tv_cache_mask = 63;
1372 static int str_size_cb(void *data, unsigned long long *__val)
1374 struct thread_data *td = cb_data_to_td(data);
1375 unsigned long long v = *__val;
1377 if (parse_is_percent(v)) {
1379 td->o.size_percent = -1ULL - v;
1386 static int str_write_bw_log_cb(void *data, const char *str)
1388 struct thread_data *td = cb_data_to_td(data);
1391 td->o.bw_log_file = strdup(str);
1393 td->o.write_bw_log = 1;
1397 static int str_write_lat_log_cb(void *data, const char *str)
1399 struct thread_data *td = cb_data_to_td(data);
1402 td->o.lat_log_file = strdup(str);
1404 td->o.write_lat_log = 1;
1408 static int str_write_iops_log_cb(void *data, const char *str)
1410 struct thread_data *td = cb_data_to_td(data);
1413 td->o.iops_log_file = strdup(str);
1415 td->o.write_iops_log = 1;
1419 static int str_write_hist_log_cb(void *data, const char *str)
1421 struct thread_data *td = cb_data_to_td(data);
1424 td->o.hist_log_file = strdup(str);
1426 td->o.write_hist_log = 1;
1430 static int rw_verify(struct fio_option *o, void *data)
1432 struct thread_data *td = cb_data_to_td(data);
1434 if (read_only && td_write(td)) {
1435 log_err("fio: job <%s> has write bit set, but fio is in"
1436 " read-only mode\n", td->o.name);
1443 static int gtod_cpu_verify(struct fio_option *o, void *data)
1445 #ifndef FIO_HAVE_CPU_AFFINITY
1446 struct thread_data *td = cb_data_to_td(data);
1448 if (td->o.gtod_cpu) {
1449 log_err("fio: platform must support CPU affinity for"
1450 "gettimeofday() offloading\n");
1459 * Map of job/command line options
1461 struct fio_option fio_options[FIO_MAX_OPTS] = {
1463 .name = "description",
1464 .lname = "Description of job",
1465 .type = FIO_OPT_STR_STORE,
1466 .off1 = offsetof(struct thread_options, description),
1467 .help = "Text job description",
1468 .category = FIO_OPT_C_GENERAL,
1469 .group = FIO_OPT_G_DESC,
1473 .lname = "Job name",
1474 .type = FIO_OPT_STR_STORE,
1475 .off1 = offsetof(struct thread_options, name),
1476 .help = "Name of this job",
1477 .category = FIO_OPT_C_GENERAL,
1478 .group = FIO_OPT_G_DESC,
1482 .lname = "Waitee name",
1483 .type = FIO_OPT_STR_STORE,
1484 .off1 = offsetof(struct thread_options, wait_for),
1485 .help = "Name of the job this one wants to wait for before starting",
1486 .category = FIO_OPT_C_GENERAL,
1487 .group = FIO_OPT_G_DESC,
1491 .lname = "Filename(s)",
1492 .type = FIO_OPT_STR_STORE,
1493 .off1 = offsetof(struct thread_options, filename),
1494 .cb = str_filename_cb,
1495 .prio = -1, /* must come after "directory" */
1496 .help = "File(s) to use for the workload",
1497 .category = FIO_OPT_C_FILE,
1498 .group = FIO_OPT_G_FILENAME,
1501 .name = "directory",
1502 .lname = "Directory",
1503 .type = FIO_OPT_STR_STORE,
1504 .off1 = offsetof(struct thread_options, directory),
1505 .cb = str_directory_cb,
1506 .help = "Directory to store files in",
1507 .category = FIO_OPT_C_FILE,
1508 .group = FIO_OPT_G_FILENAME,
1511 .name = "filename_format",
1512 .lname = "Filename Format",
1513 .type = FIO_OPT_STR_STORE,
1514 .off1 = offsetof(struct thread_options, filename_format),
1515 .prio = -1, /* must come after "directory" */
1516 .help = "Override default $jobname.$jobnum.$filenum naming",
1517 .def = "$jobname.$jobnum.$filenum",
1518 .category = FIO_OPT_C_FILE,
1519 .group = FIO_OPT_G_FILENAME,
1522 .name = "unique_filename",
1523 .lname = "Unique Filename",
1524 .type = FIO_OPT_BOOL,
1525 .off1 = offsetof(struct thread_options, unique_filename),
1526 .help = "For network clients, prefix file with source IP",
1528 .category = FIO_OPT_C_FILE,
1529 .group = FIO_OPT_G_FILENAME,
1533 .lname = "Lockfile",
1534 .type = FIO_OPT_STR,
1535 .off1 = offsetof(struct thread_options, file_lock_mode),
1536 .help = "Lock file when doing IO to it",
1538 .parent = "filename",
1541 .category = FIO_OPT_C_FILE,
1542 .group = FIO_OPT_G_FILENAME,
1545 .oval = FILE_LOCK_NONE,
1546 .help = "No file locking",
1548 { .ival = "exclusive",
1549 .oval = FILE_LOCK_EXCLUSIVE,
1550 .help = "Exclusive file lock",
1553 .ival = "readwrite",
1554 .oval = FILE_LOCK_READWRITE,
1555 .help = "Read vs write lock",
1561 .lname = "Open directory",
1562 .type = FIO_OPT_STR_STORE,
1563 .off1 = offsetof(struct thread_options, opendir),
1564 .cb = str_opendir_cb,
1565 .help = "Recursively add files from this directory and down",
1566 .category = FIO_OPT_C_FILE,
1567 .group = FIO_OPT_G_FILENAME,
1571 .lname = "Read/write",
1572 .alias = "readwrite",
1573 .type = FIO_OPT_STR,
1575 .off1 = offsetof(struct thread_options, td_ddir),
1576 .help = "IO direction",
1578 .verify = rw_verify,
1579 .category = FIO_OPT_C_IO,
1580 .group = FIO_OPT_G_IO_BASIC,
1583 .oval = TD_DDIR_READ,
1584 .help = "Sequential read",
1587 .oval = TD_DDIR_WRITE,
1588 .help = "Sequential write",
1591 .oval = TD_DDIR_TRIM,
1592 .help = "Sequential trim",
1594 { .ival = "randread",
1595 .oval = TD_DDIR_RANDREAD,
1596 .help = "Random read",
1598 { .ival = "randwrite",
1599 .oval = TD_DDIR_RANDWRITE,
1600 .help = "Random write",
1602 { .ival = "randtrim",
1603 .oval = TD_DDIR_RANDTRIM,
1604 .help = "Random trim",
1608 .help = "Sequential read and write mix",
1610 { .ival = "readwrite",
1612 .help = "Sequential read and write mix",
1615 .oval = TD_DDIR_RANDRW,
1616 .help = "Random read and write mix"
1618 { .ival = "trimwrite",
1619 .oval = TD_DDIR_TRIMWRITE,
1620 .help = "Trim and write mix, trims preceding writes"
1625 .name = "rw_sequencer",
1626 .lname = "RW Sequencer",
1627 .type = FIO_OPT_STR,
1628 .off1 = offsetof(struct thread_options, rw_seq),
1629 .help = "IO offset generator modifier",
1630 .def = "sequential",
1631 .category = FIO_OPT_C_IO,
1632 .group = FIO_OPT_G_IO_BASIC,
1634 { .ival = "sequential",
1636 .help = "Generate sequential offsets",
1638 { .ival = "identical",
1639 .oval = RW_SEQ_IDENT,
1640 .help = "Generate identical offsets",
1647 .lname = "IO Engine",
1648 .type = FIO_OPT_STR_STORE,
1649 .off1 = offsetof(struct thread_options, ioengine),
1650 .help = "IO engine to use",
1651 .def = FIO_PREFERRED_ENGINE,
1652 .category = FIO_OPT_C_IO,
1653 .group = FIO_OPT_G_IO_BASIC,
1656 .help = "Use read/write",
1659 .help = "Use pread/pwrite",
1662 .help = "Use readv/writev",
1664 #ifdef CONFIG_PWRITEV
1666 .help = "Use preadv/pwritev",
1669 #ifdef FIO_HAVE_PWRITEV2
1670 { .ival = "pvsync2",
1671 .help = "Use preadv2/pwritev2",
1674 #ifdef CONFIG_LIBAIO
1676 .help = "Linux native asynchronous IO",
1679 #ifdef CONFIG_POSIXAIO
1680 { .ival = "posixaio",
1681 .help = "POSIX asynchronous IO",
1684 #ifdef CONFIG_SOLARISAIO
1685 { .ival = "solarisaio",
1686 .help = "Solaris native asynchronous IO",
1689 #ifdef CONFIG_WINDOWSAIO
1690 { .ival = "windowsaio",
1691 .help = "Windows native asynchronous IO"
1696 .help = "Rados Block Device asynchronous IO"
1700 .help = "Memory mapped IO"
1702 #ifdef CONFIG_LINUX_SPLICE
1704 .help = "splice/vmsplice based IO",
1706 { .ival = "netsplice",
1707 .help = "splice/vmsplice to/from the network",
1710 #ifdef FIO_HAVE_SGIO
1712 .help = "SCSI generic v3 IO",
1716 .help = "Testing engine (no data transfer)",
1719 .help = "Network IO",
1722 .help = "CPU cycle burner engine",
1726 .help = "GUASI IO engine",
1729 #ifdef FIO_HAVE_BINJECT
1730 { .ival = "binject",
1731 .help = "binject direct inject block engine",
1736 .help = "RDMA IO engine",
1739 #ifdef CONFIG_FUSION_AW
1740 { .ival = "fusion-aw-sync",
1741 .help = "Fusion-io atomic write engine",
1744 #ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
1745 { .ival = "e4defrag",
1746 .help = "ext4 defrag engine",
1749 #ifdef CONFIG_LINUX_FALLOCATE
1751 .help = "fallocate() file based engine",
1756 .help = "Glusterfs libgfapi(sync) based engine"
1758 { .ival = "gfapi_async",
1759 .help = "Glusterfs libgfapi(async) based engine"
1762 #ifdef CONFIG_LIBHDFS
1763 { .ival = "libhdfs",
1764 .help = "Hadoop Distributed Filesystem (HDFS) engine"
1767 #ifdef CONFIG_PMEMBLK
1768 { .ival = "pmemblk",
1769 .help = "NVML libpmemblk based IO engine",
1773 #ifdef CONFIG_LINUX_DEVDAX
1774 { .ival = "dev-dax",
1775 .help = "DAX Device based IO engine",
1778 { .ival = "external",
1779 .help = "Load external engine (append name)",
1785 .lname = "IO Depth",
1786 .type = FIO_OPT_INT,
1787 .off1 = offsetof(struct thread_options, iodepth),
1788 .help = "Number of IO buffers to keep in flight",
1792 .category = FIO_OPT_C_IO,
1793 .group = FIO_OPT_G_IO_BASIC,
1796 .name = "iodepth_batch",
1797 .lname = "IO Depth batch",
1798 .alias = "iodepth_batch_submit",
1799 .type = FIO_OPT_INT,
1800 .off1 = offsetof(struct thread_options, iodepth_batch),
1801 .help = "Number of IO buffers to submit in one go",
1802 .parent = "iodepth",
1806 .category = FIO_OPT_C_IO,
1807 .group = FIO_OPT_G_IO_BASIC,
1810 .name = "iodepth_batch_complete_min",
1811 .lname = "Min IO depth batch complete",
1812 .alias = "iodepth_batch_complete",
1813 .type = FIO_OPT_INT,
1814 .off1 = offsetof(struct thread_options, iodepth_batch_complete_min),
1815 .help = "Min number of IO buffers to retrieve in one go",
1816 .parent = "iodepth",
1821 .category = FIO_OPT_C_IO,
1822 .group = FIO_OPT_G_IO_BASIC,
1825 .name = "iodepth_batch_complete_max",
1826 .lname = "Max IO depth batch complete",
1827 .type = FIO_OPT_INT,
1828 .off1 = offsetof(struct thread_options, iodepth_batch_complete_max),
1829 .help = "Max number of IO buffers to retrieve in one go",
1830 .parent = "iodepth",
1834 .category = FIO_OPT_C_IO,
1835 .group = FIO_OPT_G_IO_BASIC,
1838 .name = "iodepth_low",
1839 .lname = "IO Depth batch low",
1840 .type = FIO_OPT_INT,
1841 .off1 = offsetof(struct thread_options, iodepth_low),
1842 .help = "Low water mark for queuing depth",
1843 .parent = "iodepth",
1846 .category = FIO_OPT_C_IO,
1847 .group = FIO_OPT_G_IO_BASIC,
1850 .name = "io_submit_mode",
1851 .lname = "IO submit mode",
1852 .type = FIO_OPT_STR,
1853 .off1 = offsetof(struct thread_options, io_submit_mode),
1854 .help = "How IO submissions and completions are done",
1856 .category = FIO_OPT_C_IO,
1857 .group = FIO_OPT_G_IO_BASIC,
1860 .oval = IO_MODE_INLINE,
1861 .help = "Submit and complete IO inline",
1863 { .ival = "offload",
1864 .oval = IO_MODE_OFFLOAD,
1865 .help = "Offload submit and complete to threads",
1872 .type = FIO_OPT_STR_VAL,
1874 .off1 = offsetof(struct thread_options, size),
1875 .help = "Total size of device or files",
1876 .interval = 1024 * 1024,
1877 .category = FIO_OPT_C_IO,
1878 .group = FIO_OPT_G_INVALID,
1882 .alias = "io_limit",
1884 .type = FIO_OPT_STR_VAL,
1885 .off1 = offsetof(struct thread_options, io_limit),
1886 .help = "Total size of I/O to be performed",
1887 .interval = 1024 * 1024,
1888 .category = FIO_OPT_C_IO,
1889 .group = FIO_OPT_G_INVALID,
1892 .name = "fill_device",
1893 .lname = "Fill device",
1895 .type = FIO_OPT_BOOL,
1896 .off1 = offsetof(struct thread_options, fill_device),
1897 .help = "Write until an ENOSPC error occurs",
1899 .category = FIO_OPT_C_FILE,
1900 .group = FIO_OPT_G_INVALID,
1904 .lname = "File size",
1905 .type = FIO_OPT_STR_VAL,
1906 .off1 = offsetof(struct thread_options, file_size_low),
1907 .off2 = offsetof(struct thread_options, file_size_high),
1909 .help = "Size of individual files",
1910 .interval = 1024 * 1024,
1911 .category = FIO_OPT_C_FILE,
1912 .group = FIO_OPT_G_INVALID,
1915 .name = "file_append",
1916 .lname = "File append",
1917 .type = FIO_OPT_BOOL,
1918 .off1 = offsetof(struct thread_options, file_append),
1919 .help = "IO will start at the end of the file(s)",
1921 .category = FIO_OPT_C_FILE,
1922 .group = FIO_OPT_G_INVALID,
1926 .lname = "IO offset",
1927 .alias = "fileoffset",
1928 .type = FIO_OPT_STR_VAL,
1929 .off1 = offsetof(struct thread_options, start_offset),
1930 .help = "Start IO from this offset",
1932 .interval = 1024 * 1024,
1933 .category = FIO_OPT_C_IO,
1934 .group = FIO_OPT_G_INVALID,
1937 .name = "offset_increment",
1938 .lname = "IO offset increment",
1939 .type = FIO_OPT_STR_VAL,
1940 .off1 = offsetof(struct thread_options, offset_increment),
1941 .help = "What is the increment from one offset to the next",
1945 .interval = 1024 * 1024,
1946 .category = FIO_OPT_C_IO,
1947 .group = FIO_OPT_G_INVALID,
1950 .name = "number_ios",
1951 .lname = "Number of IOs to perform",
1952 .type = FIO_OPT_STR_VAL,
1953 .off1 = offsetof(struct thread_options, number_ios),
1954 .help = "Force job completion after this number of IOs",
1956 .category = FIO_OPT_C_IO,
1957 .group = FIO_OPT_G_INVALID,
1961 .lname = "Block size",
1962 .alias = "blocksize",
1963 .type = FIO_OPT_INT,
1964 .off1 = offsetof(struct thread_options, bs[DDIR_READ]),
1965 .off2 = offsetof(struct thread_options, bs[DDIR_WRITE]),
1966 .off3 = offsetof(struct thread_options, bs[DDIR_TRIM]),
1968 .help = "Block size unit",
1973 .category = FIO_OPT_C_IO,
1974 .group = FIO_OPT_G_INVALID,
1978 .lname = "Block size align",
1979 .alias = "blockalign",
1980 .type = FIO_OPT_INT,
1981 .off1 = offsetof(struct thread_options, ba[DDIR_READ]),
1982 .off2 = offsetof(struct thread_options, ba[DDIR_WRITE]),
1983 .off3 = offsetof(struct thread_options, ba[DDIR_TRIM]),
1985 .help = "IO block offset alignment",
1989 .category = FIO_OPT_C_IO,
1990 .group = FIO_OPT_G_INVALID,
1994 .lname = "Block size range",
1995 .alias = "blocksize_range",
1996 .type = FIO_OPT_RANGE,
1997 .off1 = offsetof(struct thread_options, min_bs[DDIR_READ]),
1998 .off2 = offsetof(struct thread_options, max_bs[DDIR_READ]),
1999 .off3 = offsetof(struct thread_options, min_bs[DDIR_WRITE]),
2000 .off4 = offsetof(struct thread_options, max_bs[DDIR_WRITE]),
2001 .off5 = offsetof(struct thread_options, min_bs[DDIR_TRIM]),
2002 .off6 = offsetof(struct thread_options, max_bs[DDIR_TRIM]),
2004 .help = "Set block size range (in more detail than bs)",
2008 .category = FIO_OPT_C_IO,
2009 .group = FIO_OPT_G_INVALID,
2013 .lname = "Block size split",
2014 .type = FIO_OPT_STR,
2015 .cb = str_bssplit_cb,
2016 .off1 = offsetof(struct thread_options, bssplit),
2017 .help = "Set a specific mix of block sizes",
2020 .category = FIO_OPT_C_IO,
2021 .group = FIO_OPT_G_INVALID,
2024 .name = "bs_unaligned",
2025 .lname = "Block size unaligned",
2026 .alias = "blocksize_unaligned",
2027 .type = FIO_OPT_STR_SET,
2028 .off1 = offsetof(struct thread_options, bs_unaligned),
2029 .help = "Don't sector align IO buffer sizes",
2032 .category = FIO_OPT_C_IO,
2033 .group = FIO_OPT_G_INVALID,
2036 .name = "bs_is_seq_rand",
2037 .lname = "Block size division is seq/random (not read/write)",
2038 .type = FIO_OPT_BOOL,
2039 .off1 = offsetof(struct thread_options, bs_is_seq_rand),
2040 .help = "Consider any blocksize setting to be sequential,random",
2042 .parent = "blocksize",
2043 .category = FIO_OPT_C_IO,
2044 .group = FIO_OPT_G_INVALID,
2047 .name = "randrepeat",
2048 .lname = "Random repeatable",
2049 .type = FIO_OPT_BOOL,
2050 .off1 = offsetof(struct thread_options, rand_repeatable),
2051 .help = "Use repeatable random IO pattern",
2055 .category = FIO_OPT_C_IO,
2056 .group = FIO_OPT_G_RANDOM,
2060 .lname = "The random generator seed",
2061 .type = FIO_OPT_STR_VAL,
2062 .off1 = offsetof(struct thread_options, rand_seed),
2063 .help = "Set the random generator seed value",
2066 .category = FIO_OPT_C_IO,
2067 .group = FIO_OPT_G_RANDOM,
2070 .name = "use_os_rand",
2071 .lname = "Use OS random",
2072 .type = FIO_OPT_DEPRECATED,
2073 .off1 = offsetof(struct thread_options, dep_use_os_rand),
2074 .category = FIO_OPT_C_IO,
2075 .group = FIO_OPT_G_RANDOM,
2078 .name = "norandommap",
2079 .lname = "No randommap",
2080 .type = FIO_OPT_STR_SET,
2081 .off1 = offsetof(struct thread_options, norandommap),
2082 .help = "Accept potential duplicate random blocks",
2086 .category = FIO_OPT_C_IO,
2087 .group = FIO_OPT_G_RANDOM,
2090 .name = "softrandommap",
2091 .lname = "Soft randommap",
2092 .type = FIO_OPT_BOOL,
2093 .off1 = offsetof(struct thread_options, softrandommap),
2094 .help = "Set norandommap if randommap allocation fails",
2095 .parent = "norandommap",
2098 .category = FIO_OPT_C_IO,
2099 .group = FIO_OPT_G_RANDOM,
2102 .name = "random_generator",
2103 .lname = "Random Generator",
2104 .type = FIO_OPT_STR,
2105 .off1 = offsetof(struct thread_options, random_generator),
2106 .help = "Type of random number generator to use",
2107 .def = "tausworthe",
2109 { .ival = "tausworthe",
2110 .oval = FIO_RAND_GEN_TAUSWORTHE,
2111 .help = "Strong Tausworthe generator",
2114 .oval = FIO_RAND_GEN_LFSR,
2115 .help = "Variable length LFSR",
2118 .ival = "tausworthe64",
2119 .oval = FIO_RAND_GEN_TAUSWORTHE64,
2120 .help = "64-bit Tausworthe variant",
2123 .category = FIO_OPT_C_IO,
2124 .group = FIO_OPT_G_RANDOM,
2127 .name = "random_distribution",
2128 .lname = "Random Distribution",
2129 .type = FIO_OPT_STR,
2130 .off1 = offsetof(struct thread_options, random_distribution),
2131 .cb = str_random_distribution_cb,
2132 .help = "Random offset distribution generator",
2136 .oval = FIO_RAND_DIST_RANDOM,
2137 .help = "Completely random",
2140 .oval = FIO_RAND_DIST_ZIPF,
2141 .help = "Zipf distribution",
2144 .oval = FIO_RAND_DIST_PARETO,
2145 .help = "Pareto distribution",
2148 .oval = FIO_RAND_DIST_GAUSS,
2149 .help = "Normal (Gaussian) distribution",
2152 .oval = FIO_RAND_DIST_ZONED,
2153 .help = "Zoned random distribution",
2157 .category = FIO_OPT_C_IO,
2158 .group = FIO_OPT_G_RANDOM,
2161 .name = "percentage_random",
2162 .lname = "Percentage Random",
2163 .type = FIO_OPT_INT,
2164 .off1 = offsetof(struct thread_options, perc_rand[DDIR_READ]),
2165 .off2 = offsetof(struct thread_options, perc_rand[DDIR_WRITE]),
2166 .off3 = offsetof(struct thread_options, perc_rand[DDIR_TRIM]),
2168 .help = "Percentage of seq/random mix that should be random",
2169 .def = "100,100,100",
2171 .inverse = "percentage_sequential",
2172 .category = FIO_OPT_C_IO,
2173 .group = FIO_OPT_G_RANDOM,
2176 .name = "percentage_sequential",
2177 .lname = "Percentage Sequential",
2178 .type = FIO_OPT_DEPRECATED,
2179 .category = FIO_OPT_C_IO,
2180 .group = FIO_OPT_G_RANDOM,
2183 .name = "allrandrepeat",
2184 .lname = "All Random Repeat",
2185 .type = FIO_OPT_BOOL,
2186 .off1 = offsetof(struct thread_options, allrand_repeatable),
2187 .help = "Use repeatable random numbers for everything",
2189 .category = FIO_OPT_C_IO,
2190 .group = FIO_OPT_G_RANDOM,
2194 .lname = "Number of files",
2195 .alias = "nr_files",
2196 .type = FIO_OPT_INT,
2197 .off1 = offsetof(struct thread_options, nr_files),
2198 .help = "Split job workload between this number of files",
2201 .category = FIO_OPT_C_FILE,
2202 .group = FIO_OPT_G_INVALID,
2205 .name = "openfiles",
2206 .lname = "Number of open files",
2207 .type = FIO_OPT_INT,
2208 .off1 = offsetof(struct thread_options, open_files),
2209 .help = "Number of files to keep open at the same time",
2210 .category = FIO_OPT_C_FILE,
2211 .group = FIO_OPT_G_INVALID,
2214 .name = "file_service_type",
2215 .lname = "File service type",
2216 .type = FIO_OPT_STR,
2218 .off1 = offsetof(struct thread_options, file_service_type),
2219 .help = "How to select which file to service next",
2220 .def = "roundrobin",
2221 .category = FIO_OPT_C_FILE,
2222 .group = FIO_OPT_G_INVALID,
2225 .oval = FIO_FSERVICE_RANDOM,
2226 .help = "Choose a file at random (uniform)",
2229 .oval = FIO_FSERVICE_ZIPF,
2230 .help = "Zipf randomized",
2233 .oval = FIO_FSERVICE_PARETO,
2234 .help = "Pareto randomized",
2237 .oval = FIO_FSERVICE_GAUSS,
2238 .help = "Normal (gaussian) distribution",
2240 { .ival = "roundrobin",
2241 .oval = FIO_FSERVICE_RR,
2242 .help = "Round robin select files",
2244 { .ival = "sequential",
2245 .oval = FIO_FSERVICE_SEQ,
2246 .help = "Finish one file before moving to the next",
2249 .parent = "nrfiles",
2252 #ifdef CONFIG_POSIX_FALLOCATE
2254 .name = "fallocate",
2255 .lname = "Fallocate",
2256 .type = FIO_OPT_STR,
2257 .off1 = offsetof(struct thread_options, fallocate_mode),
2258 .help = "Whether pre-allocation is performed when laying out files",
2260 .category = FIO_OPT_C_FILE,
2261 .group = FIO_OPT_G_INVALID,
2264 .oval = FIO_FALLOCATE_NONE,
2265 .help = "Do not pre-allocate space",
2268 .oval = FIO_FALLOCATE_POSIX,
2269 .help = "Use posix_fallocate()",
2271 #ifdef CONFIG_LINUX_FALLOCATE
2273 .oval = FIO_FALLOCATE_KEEP_SIZE,
2274 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
2277 /* Compatibility with former boolean values */
2279 .oval = FIO_FALLOCATE_NONE,
2280 .help = "Alias for 'none'",
2283 .oval = FIO_FALLOCATE_POSIX,
2284 .help = "Alias for 'posix'",
2288 #else /* CONFIG_POSIX_FALLOCATE */
2290 .name = "fallocate",
2291 .lname = "Fallocate",
2292 .type = FIO_OPT_UNSUPPORTED,
2293 .help = "Your platform does not support fallocate",
2295 #endif /* CONFIG_POSIX_FALLOCATE */
2297 .name = "fadvise_hint",
2298 .lname = "Fadvise hint",
2299 .type = FIO_OPT_STR,
2300 .off1 = offsetof(struct thread_options, fadvise_hint),
2304 .help = "Don't issue fadvise",
2308 .help = "Advise using fio IO pattern",
2311 .oval = F_ADV_RANDOM,
2312 .help = "Advise using FADV_RANDOM",
2314 { .ival = "sequential",
2315 .oval = F_ADV_SEQUENTIAL,
2316 .help = "Advise using FADV_SEQUENTIAL",
2319 .help = "Use fadvise() to advise the kernel on IO pattern",
2321 .category = FIO_OPT_C_FILE,
2322 .group = FIO_OPT_G_INVALID,
2324 #ifdef FIO_HAVE_STREAMID
2326 .name = "fadvise_stream",
2327 .lname = "Fadvise stream",
2328 .type = FIO_OPT_INT,
2329 .off1 = offsetof(struct thread_options, fadvise_stream),
2330 .help = "Use fadvise() to set stream ID",
2331 .category = FIO_OPT_C_FILE,
2332 .group = FIO_OPT_G_INVALID,
2336 .name = "fadvise_stream",
2337 .lname = "Fadvise stream",
2338 .type = FIO_OPT_UNSUPPORTED,
2339 .help = "Your platform does not support fadvise stream ID",
2345 .type = FIO_OPT_INT,
2346 .off1 = offsetof(struct thread_options, fsync_blocks),
2347 .help = "Issue fsync for writes every given number of blocks",
2350 .category = FIO_OPT_C_FILE,
2351 .group = FIO_OPT_G_INVALID,
2354 .name = "fdatasync",
2355 .lname = "Fdatasync",
2356 .type = FIO_OPT_INT,
2357 .off1 = offsetof(struct thread_options, fdatasync_blocks),
2358 .help = "Issue fdatasync for writes every given number of blocks",
2361 .category = FIO_OPT_C_FILE,
2362 .group = FIO_OPT_G_INVALID,
2365 .name = "write_barrier",
2366 .lname = "Write barrier",
2367 .type = FIO_OPT_INT,
2368 .off1 = offsetof(struct thread_options, barrier_blocks),
2369 .help = "Make every Nth write a barrier write",
2372 .category = FIO_OPT_C_IO,
2373 .group = FIO_OPT_G_INVALID,
2375 #ifdef CONFIG_SYNC_FILE_RANGE
2377 .name = "sync_file_range",
2378 .lname = "Sync file range",
2380 { .ival = "wait_before",
2381 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
2382 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
2386 .oval = SYNC_FILE_RANGE_WRITE,
2387 .help = "SYNC_FILE_RANGE_WRITE",
2391 .ival = "wait_after",
2392 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
2393 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
2397 .type = FIO_OPT_STR_MULTI,
2399 .off1 = offsetof(struct thread_options, sync_file_range),
2400 .help = "Use sync_file_range()",
2401 .category = FIO_OPT_C_FILE,
2402 .group = FIO_OPT_G_INVALID,
2406 .name = "sync_file_range",
2407 .lname = "Sync file range",
2408 .type = FIO_OPT_UNSUPPORTED,
2409 .help = "Your platform does not support sync_file_range",
2414 .lname = "Direct I/O",
2415 .type = FIO_OPT_BOOL,
2416 .off1 = offsetof(struct thread_options, odirect),
2417 .help = "Use O_DIRECT IO (negates buffered)",
2419 .inverse = "buffered",
2420 .category = FIO_OPT_C_IO,
2421 .group = FIO_OPT_G_IO_TYPE,
2425 .lname = "Atomic I/O",
2426 .type = FIO_OPT_BOOL,
2427 .off1 = offsetof(struct thread_options, oatomic),
2428 .help = "Use Atomic IO with O_DIRECT (implies O_DIRECT)",
2430 .category = FIO_OPT_C_IO,
2431 .group = FIO_OPT_G_IO_TYPE,
2435 .lname = "Buffered I/O",
2436 .type = FIO_OPT_BOOL,
2437 .off1 = offsetof(struct thread_options, odirect),
2439 .help = "Use buffered IO (negates direct)",
2441 .inverse = "direct",
2442 .category = FIO_OPT_C_IO,
2443 .group = FIO_OPT_G_IO_TYPE,
2446 .name = "overwrite",
2447 .lname = "Overwrite",
2448 .type = FIO_OPT_BOOL,
2449 .off1 = offsetof(struct thread_options, overwrite),
2450 .help = "When writing, set whether to overwrite current data",
2452 .category = FIO_OPT_C_FILE,
2453 .group = FIO_OPT_G_INVALID,
2458 .type = FIO_OPT_INT,
2459 .off1 = offsetof(struct thread_options, loops),
2460 .help = "Number of times to run the job",
2463 .category = FIO_OPT_C_GENERAL,
2464 .group = FIO_OPT_G_RUNTIME,
2468 .lname = "Number of jobs",
2469 .type = FIO_OPT_INT,
2470 .off1 = offsetof(struct thread_options, numjobs),
2471 .help = "Duplicate this job this many times",
2474 .category = FIO_OPT_C_GENERAL,
2475 .group = FIO_OPT_G_RUNTIME,
2478 .name = "startdelay",
2479 .lname = "Start delay",
2480 .type = FIO_OPT_STR_VAL_TIME,
2481 .off1 = offsetof(struct thread_options, start_delay),
2482 .off2 = offsetof(struct thread_options, start_delay_high),
2483 .help = "Only start job when this period has passed",
2487 .category = FIO_OPT_C_GENERAL,
2488 .group = FIO_OPT_G_RUNTIME,
2494 .type = FIO_OPT_STR_VAL_TIME,
2495 .off1 = offsetof(struct thread_options, timeout),
2496 .help = "Stop workload when this amount of time has passed",
2500 .category = FIO_OPT_C_GENERAL,
2501 .group = FIO_OPT_G_RUNTIME,
2504 .name = "time_based",
2505 .lname = "Time based",
2506 .type = FIO_OPT_STR_SET,
2507 .off1 = offsetof(struct thread_options, time_based),
2508 .help = "Keep running until runtime/timeout is met",
2509 .category = FIO_OPT_C_GENERAL,
2510 .group = FIO_OPT_G_RUNTIME,
2513 .name = "verify_only",
2514 .lname = "Verify only",
2515 .type = FIO_OPT_STR_SET,
2516 .off1 = offsetof(struct thread_options, verify_only),
2517 .help = "Verifies previously written data is still valid",
2518 .category = FIO_OPT_C_GENERAL,
2519 .group = FIO_OPT_G_RUNTIME,
2522 .name = "ramp_time",
2523 .lname = "Ramp time",
2524 .type = FIO_OPT_STR_VAL_TIME,
2525 .off1 = offsetof(struct thread_options, ramp_time),
2526 .help = "Ramp up time before measuring performance",
2529 .category = FIO_OPT_C_GENERAL,
2530 .group = FIO_OPT_G_RUNTIME,
2533 .name = "clocksource",
2534 .lname = "Clock source",
2535 .type = FIO_OPT_STR,
2536 .cb = fio_clock_source_cb,
2537 .off1 = offsetof(struct thread_options, clocksource),
2538 .help = "What type of timing source to use",
2539 .category = FIO_OPT_C_GENERAL,
2540 .group = FIO_OPT_G_CLOCK,
2542 #ifdef CONFIG_GETTIMEOFDAY
2543 { .ival = "gettimeofday",
2545 .help = "Use gettimeofday(2) for timing",
2548 #ifdef CONFIG_CLOCK_GETTIME
2549 { .ival = "clock_gettime",
2550 .oval = CS_CGETTIME,
2551 .help = "Use clock_gettime(2) for timing",
2554 #ifdef ARCH_HAVE_CPU_CLOCK
2556 .oval = CS_CPUCLOCK,
2557 .help = "Use CPU private clock",
2565 .lname = "I/O Memory",
2566 .type = FIO_OPT_STR,
2568 .off1 = offsetof(struct thread_options, mem_type),
2569 .help = "Backing type for IO buffers",
2571 .category = FIO_OPT_C_IO,
2572 .group = FIO_OPT_G_INVALID,
2576 .help = "Use malloc(3) for IO buffers",
2578 #ifndef CONFIG_NO_SHM
2581 .help = "Use shared memory segments for IO buffers",
2583 #ifdef FIO_HAVE_HUGETLB
2584 { .ival = "shmhuge",
2585 .oval = MEM_SHMHUGE,
2586 .help = "Like shm, but use huge pages",
2592 .help = "Use mmap(2) (file or anon) for IO buffers",
2594 { .ival = "mmapshared",
2595 .oval = MEM_MMAPSHARED,
2596 .help = "Like mmap, but use the shared flag",
2598 #ifdef FIO_HAVE_HUGETLB
2599 { .ival = "mmaphuge",
2600 .oval = MEM_MMAPHUGE,
2601 .help = "Like mmap, but use huge pages",
2607 .name = "iomem_align",
2608 .alias = "mem_align",
2609 .lname = "I/O memory alignment",
2610 .type = FIO_OPT_INT,
2611 .off1 = offsetof(struct thread_options, mem_align),
2613 .help = "IO memory buffer offset alignment",
2617 .category = FIO_OPT_C_IO,
2618 .group = FIO_OPT_G_INVALID,
2623 .type = FIO_OPT_STR,
2624 .off1 = offsetof(struct thread_options, verify),
2625 .help = "Verify data written",
2627 .category = FIO_OPT_C_IO,
2628 .group = FIO_OPT_G_VERIFY,
2631 .oval = VERIFY_NONE,
2632 .help = "Don't do IO verification",
2636 .help = "Use md5 checksums for verification",
2639 .oval = VERIFY_CRC64,
2640 .help = "Use crc64 checksums for verification",
2643 .oval = VERIFY_CRC32,
2644 .help = "Use crc32 checksums for verification",
2646 { .ival = "crc32c-intel",
2647 .oval = VERIFY_CRC32C,
2648 .help = "Use crc32c checksums for verification (hw assisted, if available)",
2650 { .ival = "crc32c-arm64",
2651 .oval = VERIFY_CRC32C,
2652 .help = "Use crc32c checksums for verification (hw assisted, if available)",
2655 .oval = VERIFY_CRC32C,
2656 .help = "Use crc32c checksums for verification (hw assisted, if available)",
2659 .oval = VERIFY_CRC16,
2660 .help = "Use crc16 checksums for verification",
2663 .oval = VERIFY_CRC7,
2664 .help = "Use crc7 checksums for verification",
2667 .oval = VERIFY_SHA1,
2668 .help = "Use sha1 checksums for verification",
2671 .oval = VERIFY_SHA256,
2672 .help = "Use sha256 checksums for verification",
2675 .oval = VERIFY_SHA512,
2676 .help = "Use sha512 checksums for verification",
2679 .oval = VERIFY_XXHASH,
2680 .help = "Use xxhash checksums for verification",
2682 /* Meta information was included into verify_header,
2683 * 'meta' verification is implied by default. */
2685 .oval = VERIFY_HDR_ONLY,
2686 .help = "Use io information for verification. "
2687 "Now is implied by default, thus option is obsolete, "
2690 { .ival = "pattern",
2691 .oval = VERIFY_PATTERN_NO_HDR,
2692 .help = "Verify strict pattern",
2696 .oval = VERIFY_NULL,
2697 .help = "Pretend to verify",
2702 .name = "do_verify",
2703 .lname = "Perform verify step",
2704 .type = FIO_OPT_BOOL,
2705 .off1 = offsetof(struct thread_options, do_verify),
2706 .help = "Run verification stage after write",
2710 .category = FIO_OPT_C_IO,
2711 .group = FIO_OPT_G_VERIFY,
2714 .name = "verifysort",
2715 .lname = "Verify sort",
2716 .type = FIO_OPT_BOOL,
2717 .off1 = offsetof(struct thread_options, verifysort),
2718 .help = "Sort written verify blocks for read back",
2722 .category = FIO_OPT_C_IO,
2723 .group = FIO_OPT_G_VERIFY,
2726 .name = "verifysort_nr",
2727 .lname = "Verify Sort Nr",
2728 .type = FIO_OPT_INT,
2729 .off1 = offsetof(struct thread_options, verifysort_nr),
2730 .help = "Pre-load and sort verify blocks for a read workload",
2735 .category = FIO_OPT_C_IO,
2736 .group = FIO_OPT_G_VERIFY,
2739 .name = "verify_interval",
2740 .lname = "Verify interval",
2741 .type = FIO_OPT_INT,
2742 .off1 = offsetof(struct thread_options, verify_interval),
2743 .minval = 2 * sizeof(struct verify_header),
2744 .help = "Store verify buffer header every N bytes",
2747 .interval = 2 * sizeof(struct verify_header),
2748 .category = FIO_OPT_C_IO,
2749 .group = FIO_OPT_G_VERIFY,
2752 .name = "verify_offset",
2753 .lname = "Verify offset",
2754 .type = FIO_OPT_INT,
2755 .help = "Offset verify header location by N bytes",
2756 .off1 = offsetof(struct thread_options, verify_offset),
2757 .minval = sizeof(struct verify_header),
2760 .category = FIO_OPT_C_IO,
2761 .group = FIO_OPT_G_VERIFY,
2764 .name = "verify_pattern",
2765 .lname = "Verify pattern",
2766 .type = FIO_OPT_STR,
2767 .cb = str_verify_pattern_cb,
2768 .off1 = offsetof(struct thread_options, verify_pattern),
2769 .help = "Fill pattern for IO buffers",
2772 .category = FIO_OPT_C_IO,
2773 .group = FIO_OPT_G_VERIFY,
2776 .name = "verify_fatal",
2777 .lname = "Verify fatal",
2778 .type = FIO_OPT_BOOL,
2779 .off1 = offsetof(struct thread_options, verify_fatal),
2781 .help = "Exit on a single verify failure, don't continue",
2784 .category = FIO_OPT_C_IO,
2785 .group = FIO_OPT_G_VERIFY,
2788 .name = "verify_dump",
2789 .lname = "Verify dump",
2790 .type = FIO_OPT_BOOL,
2791 .off1 = offsetof(struct thread_options, verify_dump),
2793 .help = "Dump contents of good and bad blocks on failure",
2796 .category = FIO_OPT_C_IO,
2797 .group = FIO_OPT_G_VERIFY,
2800 .name = "verify_async",
2801 .lname = "Verify asynchronously",
2802 .type = FIO_OPT_INT,
2803 .off1 = offsetof(struct thread_options, verify_async),
2805 .help = "Number of async verifier threads to use",
2808 .category = FIO_OPT_C_IO,
2809 .group = FIO_OPT_G_VERIFY,
2812 .name = "verify_backlog",
2813 .lname = "Verify backlog",
2814 .type = FIO_OPT_STR_VAL,
2815 .off1 = offsetof(struct thread_options, verify_backlog),
2816 .help = "Verify after this number of blocks are written",
2819 .category = FIO_OPT_C_IO,
2820 .group = FIO_OPT_G_VERIFY,
2823 .name = "verify_backlog_batch",
2824 .lname = "Verify backlog batch",
2825 .type = FIO_OPT_INT,
2826 .off1 = offsetof(struct thread_options, verify_batch),
2827 .help = "Verify this number of IO blocks",
2830 .category = FIO_OPT_C_IO,
2831 .group = FIO_OPT_G_VERIFY,
2833 #ifdef FIO_HAVE_CPU_AFFINITY
2835 .name = "verify_async_cpus",
2836 .lname = "Async verify CPUs",
2837 .type = FIO_OPT_STR,
2838 .cb = str_verify_cpus_allowed_cb,
2839 .off1 = offsetof(struct thread_options, verify_cpumask),
2840 .help = "Set CPUs allowed for async verify threads",
2841 .parent = "verify_async",
2843 .category = FIO_OPT_C_IO,
2844 .group = FIO_OPT_G_VERIFY,
2848 .name = "verify_async_cpus",
2849 .lname = "Async verify CPUs",
2850 .type = FIO_OPT_UNSUPPORTED,
2851 .help = "Your platform does not support CPU affinities",
2855 .name = "experimental_verify",
2856 .lname = "Experimental Verify",
2857 .off1 = offsetof(struct thread_options, experimental_verify),
2858 .type = FIO_OPT_BOOL,
2859 .help = "Enable experimental verification",
2861 .category = FIO_OPT_C_IO,
2862 .group = FIO_OPT_G_VERIFY,
2865 .name = "verify_state_load",
2866 .lname = "Load verify state",
2867 .off1 = offsetof(struct thread_options, verify_state),
2868 .type = FIO_OPT_BOOL,
2869 .help = "Load verify termination state",
2871 .category = FIO_OPT_C_IO,
2872 .group = FIO_OPT_G_VERIFY,
2875 .name = "verify_state_save",
2876 .lname = "Save verify state",
2877 .off1 = offsetof(struct thread_options, verify_state_save),
2878 .type = FIO_OPT_BOOL,
2880 .help = "Save verify state on termination",
2882 .category = FIO_OPT_C_IO,
2883 .group = FIO_OPT_G_VERIFY,
2885 #ifdef FIO_HAVE_TRIM
2887 .name = "trim_percentage",
2888 .lname = "Trim percentage",
2889 .type = FIO_OPT_INT,
2890 .off1 = offsetof(struct thread_options, trim_percentage),
2893 .help = "Number of verify blocks to trim (i.e., discard)",
2898 .category = FIO_OPT_C_IO,
2899 .group = FIO_OPT_G_TRIM,
2902 .name = "trim_verify_zero",
2903 .lname = "Verify trim zero",
2904 .type = FIO_OPT_BOOL,
2905 .help = "Verify that trimmed (i.e., discarded) blocks are returned as zeroes",
2906 .off1 = offsetof(struct thread_options, trim_zero),
2907 .parent = "trim_percentage",
2910 .category = FIO_OPT_C_IO,
2911 .group = FIO_OPT_G_TRIM,
2914 .name = "trim_backlog",
2915 .lname = "Trim backlog",
2916 .type = FIO_OPT_STR_VAL,
2917 .off1 = offsetof(struct thread_options, trim_backlog),
2918 .help = "Trim after this number of blocks are written",
2919 .parent = "trim_percentage",
2922 .category = FIO_OPT_C_IO,
2923 .group = FIO_OPT_G_TRIM,
2926 .name = "trim_backlog_batch",
2927 .lname = "Trim backlog batch",
2928 .type = FIO_OPT_INT,
2929 .off1 = offsetof(struct thread_options, trim_batch),
2930 .help = "Trim this number of IO blocks",
2931 .parent = "trim_percentage",
2934 .category = FIO_OPT_C_IO,
2935 .group = FIO_OPT_G_TRIM,
2939 .name = "trim_percentage",
2940 .lname = "Trim percentage",
2941 .type = FIO_OPT_UNSUPPORTED,
2942 .help = "Fio does not support TRIM on your platform",
2945 .name = "trim_verify_zero",
2946 .lname = "Verify trim zero",
2947 .type = FIO_OPT_UNSUPPORTED,
2948 .help = "Fio does not support TRIM on your platform",
2951 .name = "trim_backlog",
2952 .lname = "Trim backlog",
2953 .type = FIO_OPT_UNSUPPORTED,
2954 .help = "Fio does not support TRIM on your platform",
2957 .name = "trim_backlog_batch",
2958 .lname = "Trim backlog batch",
2959 .type = FIO_OPT_UNSUPPORTED,
2960 .help = "Fio does not support TRIM on your platform",
2964 .name = "write_iolog",
2965 .lname = "Write I/O log",
2966 .type = FIO_OPT_STR_STORE,
2967 .off1 = offsetof(struct thread_options, write_iolog_file),
2968 .help = "Store IO pattern to file",
2969 .category = FIO_OPT_C_IO,
2970 .group = FIO_OPT_G_IOLOG,
2973 .name = "read_iolog",
2974 .lname = "Read I/O log",
2975 .type = FIO_OPT_STR_STORE,
2976 .off1 = offsetof(struct thread_options, read_iolog_file),
2977 .help = "Playback IO pattern from file",
2978 .category = FIO_OPT_C_IO,
2979 .group = FIO_OPT_G_IOLOG,
2982 .name = "replay_no_stall",
2983 .lname = "Don't stall on replay",
2984 .type = FIO_OPT_BOOL,
2985 .off1 = offsetof(struct thread_options, no_stall),
2987 .parent = "read_iolog",
2989 .help = "Playback IO pattern file as fast as possible without stalls",
2990 .category = FIO_OPT_C_IO,
2991 .group = FIO_OPT_G_IOLOG,
2994 .name = "replay_redirect",
2995 .lname = "Redirect device for replay",
2996 .type = FIO_OPT_STR_STORE,
2997 .off1 = offsetof(struct thread_options, replay_redirect),
2998 .parent = "read_iolog",
3000 .help = "Replay all I/O onto this device, regardless of trace device",
3001 .category = FIO_OPT_C_IO,
3002 .group = FIO_OPT_G_IOLOG,
3005 .name = "replay_scale",
3006 .lname = "Replace offset scale factor",
3007 .type = FIO_OPT_INT,
3008 .off1 = offsetof(struct thread_options, replay_scale),
3009 .parent = "read_iolog",
3011 .help = "Align offsets to this blocksize",
3012 .category = FIO_OPT_C_IO,
3013 .group = FIO_OPT_G_IOLOG,
3016 .name = "replay_align",
3017 .lname = "Replace alignment",
3018 .type = FIO_OPT_INT,
3019 .off1 = offsetof(struct thread_options, replay_align),
3020 .parent = "read_iolog",
3021 .help = "Scale offset down by this factor",
3022 .category = FIO_OPT_C_IO,
3023 .group = FIO_OPT_G_IOLOG,
3027 .name = "exec_prerun",
3028 .lname = "Pre-execute runnable",
3029 .type = FIO_OPT_STR_STORE,
3030 .off1 = offsetof(struct thread_options, exec_prerun),
3031 .help = "Execute this file prior to running job",
3032 .category = FIO_OPT_C_GENERAL,
3033 .group = FIO_OPT_G_INVALID,
3036 .name = "exec_postrun",
3037 .lname = "Post-execute runnable",
3038 .type = FIO_OPT_STR_STORE,
3039 .off1 = offsetof(struct thread_options, exec_postrun),
3040 .help = "Execute this file after running job",
3041 .category = FIO_OPT_C_GENERAL,
3042 .group = FIO_OPT_G_INVALID,
3044 #ifdef FIO_HAVE_IOSCHED_SWITCH
3046 .name = "ioscheduler",
3047 .lname = "I/O scheduler",
3048 .type = FIO_OPT_STR_STORE,
3049 .off1 = offsetof(struct thread_options, ioscheduler),
3050 .help = "Use this IO scheduler on the backing device",
3051 .category = FIO_OPT_C_FILE,
3052 .group = FIO_OPT_G_INVALID,
3056 .name = "ioscheduler",
3057 .lname = "I/O scheduler",
3058 .type = FIO_OPT_UNSUPPORTED,
3059 .help = "Your platform does not support IO scheduler switching",
3064 .lname = "Zone size",
3065 .type = FIO_OPT_STR_VAL,
3066 .off1 = offsetof(struct thread_options, zone_size),
3067 .help = "Amount of data to read per zone",
3069 .interval = 1024 * 1024,
3070 .category = FIO_OPT_C_IO,
3071 .group = FIO_OPT_G_ZONE,
3074 .name = "zonerange",
3075 .lname = "Zone range",
3076 .type = FIO_OPT_STR_VAL,
3077 .off1 = offsetof(struct thread_options, zone_range),
3078 .help = "Give size of an IO zone",
3080 .interval = 1024 * 1024,
3081 .category = FIO_OPT_C_IO,
3082 .group = FIO_OPT_G_ZONE,
3086 .lname = "Zone skip",
3087 .type = FIO_OPT_STR_VAL,
3088 .off1 = offsetof(struct thread_options, zone_skip),
3089 .help = "Space between IO zones",
3091 .interval = 1024 * 1024,
3092 .category = FIO_OPT_C_IO,
3093 .group = FIO_OPT_G_ZONE,
3097 .lname = "Lock memory",
3098 .type = FIO_OPT_STR_VAL,
3099 .off1 = offsetof(struct thread_options, lockmem),
3100 .help = "Lock down this amount of memory (per worker)",
3102 .interval = 1024 * 1024,
3103 .category = FIO_OPT_C_GENERAL,
3104 .group = FIO_OPT_G_INVALID,
3107 .name = "rwmixread",
3108 .lname = "Read/write mix read",
3109 .type = FIO_OPT_INT,
3110 .cb = str_rwmix_read_cb,
3111 .off1 = offsetof(struct thread_options, rwmix[DDIR_READ]),
3113 .help = "Percentage of mixed workload that is reads",
3116 .inverse = "rwmixwrite",
3117 .category = FIO_OPT_C_IO,
3118 .group = FIO_OPT_G_RWMIX,
3121 .name = "rwmixwrite",
3122 .lname = "Read/write mix write",
3123 .type = FIO_OPT_INT,
3124 .cb = str_rwmix_write_cb,
3125 .off1 = offsetof(struct thread_options, rwmix[DDIR_WRITE]),
3127 .help = "Percentage of mixed workload that is writes",
3130 .inverse = "rwmixread",
3131 .category = FIO_OPT_C_IO,
3132 .group = FIO_OPT_G_RWMIX,
3135 .name = "rwmixcycle",
3136 .lname = "Read/write mix cycle",
3137 .type = FIO_OPT_DEPRECATED,
3138 .category = FIO_OPT_C_IO,
3139 .group = FIO_OPT_G_RWMIX,
3144 .type = FIO_OPT_INT,
3145 .off1 = offsetof(struct thread_options, nice),
3146 .help = "Set job CPU nice value",
3151 .category = FIO_OPT_C_GENERAL,
3152 .group = FIO_OPT_G_CRED,
3154 #ifdef FIO_HAVE_IOPRIO
3157 .lname = "I/O nice priority",
3158 .type = FIO_OPT_INT,
3159 .off1 = offsetof(struct thread_options, ioprio),
3160 .help = "Set job IO priority value",
3161 .minval = IOPRIO_MIN_PRIO,
3162 .maxval = IOPRIO_MAX_PRIO,
3164 .category = FIO_OPT_C_GENERAL,
3165 .group = FIO_OPT_G_CRED,
3170 .lname = "I/O nice priority",
3171 .type = FIO_OPT_UNSUPPORTED,
3172 .help = "Your platform does not support IO priorities",
3175 #ifdef FIO_HAVE_IOPRIO_CLASS
3176 #ifndef FIO_HAVE_IOPRIO
3177 #error "FIO_HAVE_IOPRIO_CLASS requires FIO_HAVE_IOPRIO"
3180 .name = "prioclass",
3181 .lname = "I/O nice priority class",
3182 .type = FIO_OPT_INT,
3183 .off1 = offsetof(struct thread_options, ioprio_class),
3184 .help = "Set job IO priority class",
3185 .minval = IOPRIO_MIN_PRIO_CLASS,
3186 .maxval = IOPRIO_MAX_PRIO_CLASS,
3188 .category = FIO_OPT_C_GENERAL,
3189 .group = FIO_OPT_G_CRED,
3193 .name = "prioclass",
3194 .lname = "I/O nice priority class",
3195 .type = FIO_OPT_UNSUPPORTED,
3196 .help = "Your platform does not support IO priority classes",
3200 .name = "thinktime",
3201 .lname = "Thinktime",
3202 .type = FIO_OPT_INT,
3203 .off1 = offsetof(struct thread_options, thinktime),
3204 .help = "Idle time between IO buffers (usec)",
3207 .category = FIO_OPT_C_IO,
3208 .group = FIO_OPT_G_THINKTIME,
3211 .name = "thinktime_spin",
3212 .lname = "Thinktime spin",
3213 .type = FIO_OPT_INT,
3214 .off1 = offsetof(struct thread_options, thinktime_spin),
3215 .help = "Start think time by spinning this amount (usec)",
3218 .parent = "thinktime",
3220 .category = FIO_OPT_C_IO,
3221 .group = FIO_OPT_G_THINKTIME,
3224 .name = "thinktime_blocks",
3225 .lname = "Thinktime blocks",
3226 .type = FIO_OPT_INT,
3227 .off1 = offsetof(struct thread_options, thinktime_blocks),
3228 .help = "IO buffer period between 'thinktime'",
3230 .parent = "thinktime",
3232 .category = FIO_OPT_C_IO,
3233 .group = FIO_OPT_G_THINKTIME,
3237 .lname = "I/O rate",
3238 .type = FIO_OPT_INT,
3239 .off1 = offsetof(struct thread_options, rate[DDIR_READ]),
3240 .off2 = offsetof(struct thread_options, rate[DDIR_WRITE]),
3241 .off3 = offsetof(struct thread_options, rate[DDIR_TRIM]),
3242 .help = "Set bandwidth rate",
3243 .category = FIO_OPT_C_IO,
3244 .group = FIO_OPT_G_RATE,
3249 .lname = "I/O min rate",
3250 .type = FIO_OPT_INT,
3251 .off1 = offsetof(struct thread_options, ratemin[DDIR_READ]),
3252 .off2 = offsetof(struct thread_options, ratemin[DDIR_WRITE]),
3253 .off3 = offsetof(struct thread_options, ratemin[DDIR_TRIM]),
3254 .help = "Job must meet this rate or it will be shutdown",
3257 .category = FIO_OPT_C_IO,
3258 .group = FIO_OPT_G_RATE,
3261 .name = "rate_iops",
3262 .lname = "I/O rate IOPS",
3263 .type = FIO_OPT_INT,
3264 .off1 = offsetof(struct thread_options, rate_iops[DDIR_READ]),
3265 .off2 = offsetof(struct thread_options, rate_iops[DDIR_WRITE]),
3266 .off3 = offsetof(struct thread_options, rate_iops[DDIR_TRIM]),
3267 .help = "Limit IO used to this number of IO operations/sec",
3269 .category = FIO_OPT_C_IO,
3270 .group = FIO_OPT_G_RATE,
3273 .name = "rate_iops_min",
3274 .lname = "I/O min rate IOPS",
3275 .type = FIO_OPT_INT,
3276 .off1 = offsetof(struct thread_options, rate_iops_min[DDIR_READ]),
3277 .off2 = offsetof(struct thread_options, rate_iops_min[DDIR_WRITE]),
3278 .off3 = offsetof(struct thread_options, rate_iops_min[DDIR_TRIM]),
3279 .help = "Job must meet this rate or it will be shut down",
3280 .parent = "rate_iops",
3282 .category = FIO_OPT_C_IO,
3283 .group = FIO_OPT_G_RATE,
3286 .name = "rate_process",
3287 .lname = "Rate Process",
3288 .type = FIO_OPT_STR,
3289 .off1 = offsetof(struct thread_options, rate_process),
3290 .help = "What process controls how rated IO is managed",
3292 .category = FIO_OPT_C_IO,
3293 .group = FIO_OPT_G_RATE,
3296 .oval = RATE_PROCESS_LINEAR,
3297 .help = "Linear rate of IO",
3301 .oval = RATE_PROCESS_POISSON,
3302 .help = "Rate follows Poisson process",
3308 .name = "rate_cycle",
3309 .alias = "ratecycle",
3310 .lname = "I/O rate cycle",
3311 .type = FIO_OPT_INT,
3312 .off1 = offsetof(struct thread_options, ratecycle),
3313 .help = "Window average for rate limits (msec)",
3317 .category = FIO_OPT_C_IO,
3318 .group = FIO_OPT_G_RATE,
3321 .name = "max_latency",
3322 .lname = "Max Latency",
3323 .type = FIO_OPT_INT,
3324 .off1 = offsetof(struct thread_options, max_latency),
3325 .help = "Maximum tolerated IO latency (usec)",
3327 .category = FIO_OPT_C_IO,
3328 .group = FIO_OPT_G_LATPROF,
3331 .name = "latency_target",
3332 .lname = "Latency Target (usec)",
3333 .type = FIO_OPT_STR_VAL_TIME,
3334 .off1 = offsetof(struct thread_options, latency_target),
3335 .help = "Ramp to max queue depth supporting this latency",
3337 .category = FIO_OPT_C_IO,
3338 .group = FIO_OPT_G_LATPROF,
3341 .name = "latency_window",
3342 .lname = "Latency Window (usec)",
3343 .type = FIO_OPT_STR_VAL_TIME,
3344 .off1 = offsetof(struct thread_options, latency_window),
3345 .help = "Time to sustain latency_target",
3347 .category = FIO_OPT_C_IO,
3348 .group = FIO_OPT_G_LATPROF,
3351 .name = "latency_percentile",
3352 .lname = "Latency Percentile",
3353 .type = FIO_OPT_FLOAT_LIST,
3354 .off1 = offsetof(struct thread_options, latency_percentile),
3355 .help = "Percentile of IOs must be below latency_target",
3360 .category = FIO_OPT_C_IO,
3361 .group = FIO_OPT_G_LATPROF,
3364 .name = "invalidate",
3365 .lname = "Cache invalidate",
3366 .type = FIO_OPT_BOOL,
3367 .off1 = offsetof(struct thread_options, invalidate_cache),
3368 .help = "Invalidate buffer/page cache prior to running job",
3370 .category = FIO_OPT_C_IO,
3371 .group = FIO_OPT_G_IO_TYPE,
3375 .lname = "Synchronous I/O",
3376 .type = FIO_OPT_BOOL,
3377 .off1 = offsetof(struct thread_options, sync_io),
3378 .help = "Use O_SYNC for buffered writes",
3380 .parent = "buffered",
3382 .category = FIO_OPT_C_IO,
3383 .group = FIO_OPT_G_IO_TYPE,
3386 .name = "create_serialize",
3387 .lname = "Create serialize",
3388 .type = FIO_OPT_BOOL,
3389 .off1 = offsetof(struct thread_options, create_serialize),
3390 .help = "Serialize creation of job files",
3392 .category = FIO_OPT_C_FILE,
3393 .group = FIO_OPT_G_INVALID,
3396 .name = "create_fsync",
3397 .lname = "Create fsync",
3398 .type = FIO_OPT_BOOL,
3399 .off1 = offsetof(struct thread_options, create_fsync),
3400 .help = "fsync file after creation",
3402 .category = FIO_OPT_C_FILE,
3403 .group = FIO_OPT_G_INVALID,
3406 .name = "create_on_open",
3407 .lname = "Create on open",
3408 .type = FIO_OPT_BOOL,
3409 .off1 = offsetof(struct thread_options, create_on_open),
3410 .help = "Create files when they are opened for IO",
3412 .category = FIO_OPT_C_FILE,
3413 .group = FIO_OPT_G_INVALID,
3416 .name = "create_only",
3417 .lname = "Create Only",
3418 .type = FIO_OPT_BOOL,
3419 .off1 = offsetof(struct thread_options, create_only),
3420 .help = "Only perform file creation phase",
3421 .category = FIO_OPT_C_FILE,
3425 .name = "allow_file_create",
3426 .lname = "Allow file create",
3427 .type = FIO_OPT_BOOL,
3428 .off1 = offsetof(struct thread_options, allow_create),
3429 .help = "Permit fio to create files, if they don't exist",
3431 .category = FIO_OPT_C_FILE,
3432 .group = FIO_OPT_G_FILENAME,
3435 .name = "allow_mounted_write",
3436 .lname = "Allow mounted write",
3437 .type = FIO_OPT_BOOL,
3438 .off1 = offsetof(struct thread_options, allow_mounted_write),
3439 .help = "Allow writes to a mounted partition",
3441 .category = FIO_OPT_C_FILE,
3442 .group = FIO_OPT_G_FILENAME,
3446 .lname = "Pre-read files",
3447 .type = FIO_OPT_BOOL,
3448 .off1 = offsetof(struct thread_options, pre_read),
3449 .help = "Pre-read files before starting official testing",
3451 .category = FIO_OPT_C_FILE,
3452 .group = FIO_OPT_G_INVALID,
3454 #ifdef FIO_HAVE_CPU_AFFINITY
3457 .lname = "CPU mask",
3458 .type = FIO_OPT_INT,
3459 .cb = str_cpumask_cb,
3460 .off1 = offsetof(struct thread_options, cpumask),
3461 .help = "CPU affinity mask",
3462 .category = FIO_OPT_C_GENERAL,
3463 .group = FIO_OPT_G_CRED,
3466 .name = "cpus_allowed",
3467 .lname = "CPUs allowed",
3468 .type = FIO_OPT_STR,
3469 .cb = str_cpus_allowed_cb,
3470 .off1 = offsetof(struct thread_options, cpumask),
3471 .help = "Set CPUs allowed",
3472 .category = FIO_OPT_C_GENERAL,
3473 .group = FIO_OPT_G_CRED,
3476 .name = "cpus_allowed_policy",
3477 .lname = "CPUs allowed distribution policy",
3478 .type = FIO_OPT_STR,
3479 .off1 = offsetof(struct thread_options, cpus_allowed_policy),
3480 .help = "Distribution policy for cpus_allowed",
3481 .parent = "cpus_allowed",
3485 .oval = FIO_CPUS_SHARED,
3486 .help = "Mask shared between threads",
3489 .oval = FIO_CPUS_SPLIT,
3490 .help = "Mask split between threads",
3493 .category = FIO_OPT_C_GENERAL,
3494 .group = FIO_OPT_G_CRED,
3499 .lname = "CPU mask",
3500 .type = FIO_OPT_UNSUPPORTED,
3501 .help = "Your platform does not support CPU affinities",
3504 .name = "cpus_allowed",
3505 .lname = "CPUs allowed",
3506 .type = FIO_OPT_UNSUPPORTED,
3507 .help = "Your platform does not support CPU affinities",
3510 .name = "cpus_allowed_policy",
3511 .lname = "CPUs allowed distribution policy",
3512 .type = FIO_OPT_UNSUPPORTED,
3513 .help = "Your platform does not support CPU affinities",
3516 #ifdef CONFIG_LIBNUMA
3518 .name = "numa_cpu_nodes",
3519 .lname = "NUMA CPU Nodes",
3520 .type = FIO_OPT_STR,
3521 .cb = str_numa_cpunodes_cb,
3522 .off1 = offsetof(struct thread_options, numa_cpunodes),
3523 .help = "NUMA CPU nodes bind",
3524 .category = FIO_OPT_C_GENERAL,
3525 .group = FIO_OPT_G_INVALID,
3528 .name = "numa_mem_policy",
3529 .lname = "NUMA Memory Policy",
3530 .type = FIO_OPT_STR,
3531 .cb = str_numa_mpol_cb,
3532 .off1 = offsetof(struct thread_options, numa_memnodes),
3533 .help = "NUMA memory policy setup",
3534 .category = FIO_OPT_C_GENERAL,
3535 .group = FIO_OPT_G_INVALID,
3539 .name = "numa_cpu_nodes",
3540 .lname = "NUMA CPU Nodes",
3541 .type = FIO_OPT_UNSUPPORTED,
3542 .help = "Build fio with libnuma-dev(el) to enable this option",
3545 .name = "numa_mem_policy",
3546 .lname = "NUMA Memory Policy",
3547 .type = FIO_OPT_UNSUPPORTED,
3548 .help = "Build fio with libnuma-dev(el) to enable this option",
3552 .name = "end_fsync",
3553 .lname = "End fsync",
3554 .type = FIO_OPT_BOOL,
3555 .off1 = offsetof(struct thread_options, end_fsync),
3556 .help = "Include fsync at the end of job",
3558 .category = FIO_OPT_C_FILE,
3559 .group = FIO_OPT_G_INVALID,
3562 .name = "fsync_on_close",
3563 .lname = "Fsync on close",
3564 .type = FIO_OPT_BOOL,
3565 .off1 = offsetof(struct thread_options, fsync_on_close),
3566 .help = "fsync files on close",
3568 .category = FIO_OPT_C_FILE,
3569 .group = FIO_OPT_G_INVALID,
3573 .lname = "Unlink file",
3574 .type = FIO_OPT_BOOL,
3575 .off1 = offsetof(struct thread_options, unlink),
3576 .help = "Unlink created files after job has completed",
3578 .category = FIO_OPT_C_FILE,
3579 .group = FIO_OPT_G_INVALID,
3582 .name = "unlink_each_loop",
3583 .lname = "Unlink file after each loop of a job",
3584 .type = FIO_OPT_BOOL,
3585 .off1 = offsetof(struct thread_options, unlink_each_loop),
3586 .help = "Unlink created files after each loop in a job has completed",
3588 .category = FIO_OPT_C_FILE,
3589 .group = FIO_OPT_G_INVALID,
3593 .lname = "Exit-all on terminate",
3594 .type = FIO_OPT_STR_SET,
3595 .cb = str_exitall_cb,
3596 .help = "Terminate all jobs when one exits",
3597 .category = FIO_OPT_C_GENERAL,
3598 .group = FIO_OPT_G_PROCESS,
3601 .name = "exitall_on_error",
3602 .lname = "Exit-all on terminate in error",
3603 .type = FIO_OPT_STR_SET,
3604 .off1 = offsetof(struct thread_options, exitall_error),
3605 .help = "Terminate all jobs when one exits in error",
3606 .category = FIO_OPT_C_GENERAL,
3607 .group = FIO_OPT_G_PROCESS,
3610 .name = "stonewall",
3611 .lname = "Wait for previous",
3612 .alias = "wait_for_previous",
3613 .type = FIO_OPT_STR_SET,
3614 .off1 = offsetof(struct thread_options, stonewall),
3615 .help = "Insert a hard barrier between this job and previous",
3616 .category = FIO_OPT_C_GENERAL,
3617 .group = FIO_OPT_G_PROCESS,
3620 .name = "new_group",
3621 .lname = "New group",
3622 .type = FIO_OPT_STR_SET,
3623 .off1 = offsetof(struct thread_options, new_group),
3624 .help = "Mark the start of a new group (for reporting)",
3625 .category = FIO_OPT_C_GENERAL,
3626 .group = FIO_OPT_G_PROCESS,
3631 .type = FIO_OPT_STR_SET,
3632 .off1 = offsetof(struct thread_options, use_thread),
3633 .help = "Use threads instead of processes",
3634 #ifdef CONFIG_NO_SHM
3638 .category = FIO_OPT_C_GENERAL,
3639 .group = FIO_OPT_G_PROCESS,
3642 .name = "per_job_logs",
3643 .lname = "Per Job Logs",
3644 .type = FIO_OPT_BOOL,
3645 .off1 = offsetof(struct thread_options, per_job_logs),
3646 .help = "Include job number in generated log files or not",
3648 .category = FIO_OPT_C_LOG,
3649 .group = FIO_OPT_G_INVALID,
3652 .name = "write_bw_log",
3653 .lname = "Write bandwidth log",
3654 .type = FIO_OPT_STR,
3655 .off1 = offsetof(struct thread_options, bw_log_file),
3656 .cb = str_write_bw_log_cb,
3657 .help = "Write log of bandwidth during run",
3658 .category = FIO_OPT_C_LOG,
3659 .group = FIO_OPT_G_INVALID,
3662 .name = "write_lat_log",
3663 .lname = "Write latency log",
3664 .type = FIO_OPT_STR,
3665 .off1 = offsetof(struct thread_options, lat_log_file),
3666 .cb = str_write_lat_log_cb,
3667 .help = "Write log of latency during run",
3668 .category = FIO_OPT_C_LOG,
3669 .group = FIO_OPT_G_INVALID,
3672 .name = "write_iops_log",
3673 .lname = "Write IOPS log",
3674 .type = FIO_OPT_STR,
3675 .off1 = offsetof(struct thread_options, iops_log_file),
3676 .cb = str_write_iops_log_cb,
3677 .help = "Write log of IOPS during run",
3678 .category = FIO_OPT_C_LOG,
3679 .group = FIO_OPT_G_INVALID,
3682 .name = "log_avg_msec",
3683 .lname = "Log averaging (msec)",
3684 .type = FIO_OPT_INT,
3685 .off1 = offsetof(struct thread_options, log_avg_msec),
3686 .help = "Average bw/iops/lat logs over this period of time",
3688 .category = FIO_OPT_C_LOG,
3689 .group = FIO_OPT_G_INVALID,
3692 .name = "log_hist_msec",
3693 .lname = "Log histograms (msec)",
3694 .type = FIO_OPT_INT,
3695 .off1 = offsetof(struct thread_options, log_hist_msec),
3696 .help = "Dump completion latency histograms at frequency of this time value",
3698 .category = FIO_OPT_C_LOG,
3699 .group = FIO_OPT_G_INVALID,
3702 .name = "log_hist_coarseness",
3703 .lname = "Histogram logs coarseness",
3704 .type = FIO_OPT_INT,
3705 .off1 = offsetof(struct thread_options, log_hist_coarseness),
3706 .help = "Integer in range [0,6]. Higher coarseness outputs"
3707 " fewer histogram bins per sample. The number of bins for"
3708 " these are [1216, 608, 304, 152, 76, 38, 19] respectively.",
3710 .category = FIO_OPT_C_LOG,
3711 .group = FIO_OPT_G_INVALID,
3714 .name = "write_hist_log",
3715 .lname = "Write latency histogram logs",
3716 .type = FIO_OPT_STR,
3717 .off1 = offsetof(struct thread_options, hist_log_file),
3718 .cb = str_write_hist_log_cb,
3719 .help = "Write log of latency histograms during run",
3720 .category = FIO_OPT_C_LOG,
3721 .group = FIO_OPT_G_INVALID,
3724 .name = "log_max_value",
3725 .lname = "Log maximum instead of average",
3726 .type = FIO_OPT_BOOL,
3727 .off1 = offsetof(struct thread_options, log_max),
3728 .help = "Log max sample in a window instead of average",
3730 .category = FIO_OPT_C_LOG,
3731 .group = FIO_OPT_G_INVALID,
3734 .name = "log_offset",
3735 .lname = "Log offset of IO",
3736 .type = FIO_OPT_BOOL,
3737 .off1 = offsetof(struct thread_options, log_offset),
3738 .help = "Include offset of IO for each log entry",
3740 .category = FIO_OPT_C_LOG,
3741 .group = FIO_OPT_G_INVALID,
3745 .name = "log_compression",
3746 .lname = "Log compression",
3747 .type = FIO_OPT_INT,
3748 .off1 = offsetof(struct thread_options, log_gz),
3749 .help = "Log in compressed chunks of this size",
3751 .maxval = 512 * 1024 * 1024ULL,
3752 .category = FIO_OPT_C_LOG,
3753 .group = FIO_OPT_G_INVALID,
3755 #ifdef FIO_HAVE_CPU_AFFINITY
3757 .name = "log_compression_cpus",
3758 .lname = "Log Compression CPUs",
3759 .type = FIO_OPT_STR,
3760 .cb = str_log_cpus_allowed_cb,
3761 .off1 = offsetof(struct thread_options, log_gz_cpumask),
3762 .parent = "log_compression",
3763 .help = "Limit log compression to these CPUs",
3764 .category = FIO_OPT_C_LOG,
3765 .group = FIO_OPT_G_INVALID,
3769 .name = "log_compression_cpus",
3770 .lname = "Log Compression CPUs",
3771 .type = FIO_OPT_UNSUPPORTED,
3772 .help = "Your platform does not support CPU affinities",
3776 .name = "log_store_compressed",
3777 .lname = "Log store compressed",
3778 .type = FIO_OPT_BOOL,
3779 .off1 = offsetof(struct thread_options, log_gz_store),
3780 .help = "Store logs in a compressed format",
3781 .category = FIO_OPT_C_LOG,
3782 .group = FIO_OPT_G_INVALID,
3786 .name = "log_compression",
3787 .lname = "Log compression",
3788 .type = FIO_OPT_UNSUPPORTED,
3789 .help = "Install libz-dev(el) to get compression support",
3792 .name = "log_store_compressed",
3793 .lname = "Log store compressed",
3794 .type = FIO_OPT_UNSUPPORTED,
3795 .help = "Install libz-dev(el) to get compression support",
3799 .name = "log_unix_epoch",
3800 .lname = "Log epoch unix",
3801 .type = FIO_OPT_BOOL,
3802 .off1 = offsetof(struct thread_options, log_unix_epoch),
3803 .help = "Use Unix time in log files",
3804 .category = FIO_OPT_C_LOG,
3805 .group = FIO_OPT_G_INVALID,
3808 .name = "block_error_percentiles",
3809 .lname = "Block error percentiles",
3810 .type = FIO_OPT_BOOL,
3811 .off1 = offsetof(struct thread_options, block_error_hist),
3812 .help = "Record trim block errors and make a histogram",
3814 .category = FIO_OPT_C_LOG,
3815 .group = FIO_OPT_G_INVALID,
3818 .name = "bwavgtime",
3819 .lname = "Bandwidth average time",
3820 .type = FIO_OPT_INT,
3821 .off1 = offsetof(struct thread_options, bw_avg_time),
3822 .help = "Time window over which to calculate bandwidth"
3825 .parent = "write_bw_log",
3828 .category = FIO_OPT_C_LOG,
3829 .group = FIO_OPT_G_INVALID,
3832 .name = "iopsavgtime",
3833 .lname = "IOPS average time",
3834 .type = FIO_OPT_INT,
3835 .off1 = offsetof(struct thread_options, iops_avg_time),
3836 .help = "Time window over which to calculate IOPS (msec)",
3838 .parent = "write_iops_log",
3841 .category = FIO_OPT_C_LOG,
3842 .group = FIO_OPT_G_INVALID,
3845 .name = "group_reporting",
3846 .lname = "Group reporting",
3847 .type = FIO_OPT_STR_SET,
3848 .off1 = offsetof(struct thread_options, group_reporting),
3849 .help = "Do reporting on a per-group basis",
3850 .category = FIO_OPT_C_STAT,
3851 .group = FIO_OPT_G_INVALID,
3854 .name = "zero_buffers",
3855 .lname = "Zero I/O buffers",
3856 .type = FIO_OPT_STR_SET,
3857 .off1 = offsetof(struct thread_options, zero_buffers),
3858 .help = "Init IO buffers to all zeroes",
3859 .category = FIO_OPT_C_IO,
3860 .group = FIO_OPT_G_IO_BUF,
3863 .name = "refill_buffers",
3864 .lname = "Refill I/O buffers",
3865 .type = FIO_OPT_STR_SET,
3866 .off1 = offsetof(struct thread_options, refill_buffers),
3867 .help = "Refill IO buffers on every IO submit",
3868 .category = FIO_OPT_C_IO,
3869 .group = FIO_OPT_G_IO_BUF,
3872 .name = "scramble_buffers",
3873 .lname = "Scramble I/O buffers",
3874 .type = FIO_OPT_BOOL,
3875 .off1 = offsetof(struct thread_options, scramble_buffers),
3876 .help = "Slightly scramble buffers on every IO submit",
3878 .category = FIO_OPT_C_IO,
3879 .group = FIO_OPT_G_IO_BUF,
3882 .name = "buffer_pattern",
3883 .lname = "Buffer pattern",
3884 .type = FIO_OPT_STR,
3885 .cb = str_buffer_pattern_cb,
3886 .off1 = offsetof(struct thread_options, buffer_pattern),
3887 .help = "Fill pattern for IO buffers",
3888 .category = FIO_OPT_C_IO,
3889 .group = FIO_OPT_G_IO_BUF,
3892 .name = "buffer_compress_percentage",
3893 .lname = "Buffer compression percentage",
3894 .type = FIO_OPT_INT,
3895 .cb = str_buffer_compress_cb,
3896 .off1 = offsetof(struct thread_options, compress_percentage),
3899 .help = "How compressible the buffer is (approximately)",
3901 .category = FIO_OPT_C_IO,
3902 .group = FIO_OPT_G_IO_BUF,
3905 .name = "buffer_compress_chunk",
3906 .lname = "Buffer compression chunk size",
3907 .type = FIO_OPT_INT,
3908 .off1 = offsetof(struct thread_options, compress_chunk),
3909 .parent = "buffer_compress_percentage",
3911 .help = "Size of compressible region in buffer",
3913 .category = FIO_OPT_C_IO,
3914 .group = FIO_OPT_G_IO_BUF,
3917 .name = "dedupe_percentage",
3918 .lname = "Dedupe percentage",
3919 .type = FIO_OPT_INT,
3920 .cb = str_dedupe_cb,
3921 .off1 = offsetof(struct thread_options, dedupe_percentage),
3924 .help = "Percentage of buffers that are dedupable",
3926 .category = FIO_OPT_C_IO,
3927 .group = FIO_OPT_G_IO_BUF,
3930 .name = "clat_percentiles",
3931 .lname = "Completion latency percentiles",
3932 .type = FIO_OPT_BOOL,
3933 .off1 = offsetof(struct thread_options, clat_percentiles),
3934 .help = "Enable the reporting of completion latency percentiles",
3936 .category = FIO_OPT_C_STAT,
3937 .group = FIO_OPT_G_INVALID,
3940 .name = "percentile_list",
3941 .lname = "Percentile list",
3942 .type = FIO_OPT_FLOAT_LIST,
3943 .off1 = offsetof(struct thread_options, percentile_list),
3944 .off2 = offsetof(struct thread_options, percentile_precision),
3945 .help = "Specify a custom list of percentiles to report for "
3946 "completion latency and block errors",
3947 .def = "1:5:10:20:30:40:50:60:70:80:90:95:99:99.5:99.9:99.95:99.99",
3948 .maxlen = FIO_IO_U_LIST_MAX_LEN,
3951 .category = FIO_OPT_C_STAT,
3952 .group = FIO_OPT_G_INVALID,
3955 #ifdef FIO_HAVE_DISK_UTIL
3957 .name = "disk_util",
3958 .lname = "Disk utilization",
3959 .type = FIO_OPT_BOOL,
3960 .off1 = offsetof(struct thread_options, do_disk_util),
3961 .help = "Log disk utilization statistics",
3963 .category = FIO_OPT_C_STAT,
3964 .group = FIO_OPT_G_INVALID,
3968 .name = "disk_util",
3969 .lname = "Disk utilization",
3970 .type = FIO_OPT_UNSUPPORTED,
3971 .help = "Your platform does not support disk utilization",
3975 .name = "gtod_reduce",
3976 .lname = "Reduce gettimeofday() calls",
3977 .type = FIO_OPT_BOOL,
3978 .help = "Greatly reduce number of gettimeofday() calls",
3979 .cb = str_gtod_reduce_cb,
3982 .category = FIO_OPT_C_STAT,
3983 .group = FIO_OPT_G_INVALID,
3986 .name = "disable_lat",
3987 .lname = "Disable all latency stats",
3988 .type = FIO_OPT_BOOL,
3989 .off1 = offsetof(struct thread_options, disable_lat),
3990 .help = "Disable latency numbers",
3991 .parent = "gtod_reduce",
3994 .category = FIO_OPT_C_STAT,
3995 .group = FIO_OPT_G_INVALID,
3998 .name = "disable_clat",
3999 .lname = "Disable completion latency stats",
4000 .type = FIO_OPT_BOOL,
4001 .off1 = offsetof(struct thread_options, disable_clat),
4002 .help = "Disable completion latency numbers",
4003 .parent = "gtod_reduce",
4006 .category = FIO_OPT_C_STAT,
4007 .group = FIO_OPT_G_INVALID,
4010 .name = "disable_slat",
4011 .lname = "Disable submission latency stats",
4012 .type = FIO_OPT_BOOL,
4013 .off1 = offsetof(struct thread_options, disable_slat),
4014 .help = "Disable submission latency numbers",
4015 .parent = "gtod_reduce",
4018 .category = FIO_OPT_C_STAT,
4019 .group = FIO_OPT_G_INVALID,
4022 .name = "disable_bw_measurement",
4023 .alias = "disable_bw",
4024 .lname = "Disable bandwidth stats",
4025 .type = FIO_OPT_BOOL,
4026 .off1 = offsetof(struct thread_options, disable_bw),
4027 .help = "Disable bandwidth logging",
4028 .parent = "gtod_reduce",
4031 .category = FIO_OPT_C_STAT,
4032 .group = FIO_OPT_G_INVALID,
4036 .lname = "Dedicated gettimeofday() CPU",
4037 .type = FIO_OPT_INT,
4038 .off1 = offsetof(struct thread_options, gtod_cpu),
4039 .help = "Set up dedicated gettimeofday() thread on this CPU",
4040 .verify = gtod_cpu_verify,
4041 .category = FIO_OPT_C_GENERAL,
4042 .group = FIO_OPT_G_CLOCK,
4045 .name = "unified_rw_reporting",
4046 .lname = "Unified RW Reporting",
4047 .type = FIO_OPT_BOOL,
4048 .off1 = offsetof(struct thread_options, unified_rw_rep),
4049 .help = "Unify reporting across data direction",
4051 .category = FIO_OPT_C_GENERAL,
4052 .group = FIO_OPT_G_INVALID,
4055 .name = "continue_on_error",
4056 .lname = "Continue on error",
4057 .type = FIO_OPT_STR,
4058 .off1 = offsetof(struct thread_options, continue_on_error),
4059 .help = "Continue on non-fatal errors during IO",
4061 .category = FIO_OPT_C_GENERAL,
4062 .group = FIO_OPT_G_ERR,
4065 .oval = ERROR_TYPE_NONE,
4066 .help = "Exit when an error is encountered",
4069 .oval = ERROR_TYPE_READ,
4070 .help = "Continue on read errors only",
4073 .oval = ERROR_TYPE_WRITE,
4074 .help = "Continue on write errors only",
4077 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
4078 .help = "Continue on any IO errors",
4081 .oval = ERROR_TYPE_VERIFY,
4082 .help = "Continue on verify errors only",
4085 .oval = ERROR_TYPE_ANY,
4086 .help = "Continue on all io and verify errors",
4089 .oval = ERROR_TYPE_NONE,
4090 .help = "Alias for 'none'",
4093 .oval = ERROR_TYPE_ANY,
4094 .help = "Alias for 'all'",
4099 .name = "ignore_error",
4100 .lname = "Ignore Error",
4101 .type = FIO_OPT_STR,
4102 .cb = str_ignore_error_cb,
4103 .off1 = offsetof(struct thread_options, ignore_error_nr),
4104 .help = "Set a specific list of errors to ignore",
4106 .category = FIO_OPT_C_GENERAL,
4107 .group = FIO_OPT_G_ERR,
4110 .name = "error_dump",
4111 .lname = "Error Dump",
4112 .type = FIO_OPT_BOOL,
4113 .off1 = offsetof(struct thread_options, error_dump),
4115 .help = "Dump info on each error",
4116 .category = FIO_OPT_C_GENERAL,
4117 .group = FIO_OPT_G_ERR,
4122 .type = FIO_OPT_STR_STORE,
4123 .off1 = offsetof(struct thread_options, profile),
4124 .help = "Select a specific builtin performance test",
4125 .category = FIO_OPT_C_PROFILE,
4126 .group = FIO_OPT_G_INVALID,
4131 .type = FIO_OPT_STR_STORE,
4132 .off1 = offsetof(struct thread_options, cgroup),
4133 .help = "Add job to cgroup of this name",
4134 .category = FIO_OPT_C_GENERAL,
4135 .group = FIO_OPT_G_CGROUP,
4138 .name = "cgroup_nodelete",
4139 .lname = "Cgroup no-delete",
4140 .type = FIO_OPT_BOOL,
4141 .off1 = offsetof(struct thread_options, cgroup_nodelete),
4142 .help = "Do not delete cgroups after job completion",
4145 .category = FIO_OPT_C_GENERAL,
4146 .group = FIO_OPT_G_CGROUP,
4149 .name = "cgroup_weight",
4150 .lname = "Cgroup weight",
4151 .type = FIO_OPT_INT,
4152 .off1 = offsetof(struct thread_options, cgroup_weight),
4153 .help = "Use given weight for cgroup",
4157 .category = FIO_OPT_C_GENERAL,
4158 .group = FIO_OPT_G_CGROUP,
4163 .type = FIO_OPT_INT,
4164 .off1 = offsetof(struct thread_options, uid),
4165 .help = "Run job with this user ID",
4166 .category = FIO_OPT_C_GENERAL,
4167 .group = FIO_OPT_G_CRED,
4171 .lname = "Group ID",
4172 .type = FIO_OPT_INT,
4173 .off1 = offsetof(struct thread_options, gid),
4174 .help = "Run job with this group ID",
4175 .category = FIO_OPT_C_GENERAL,
4176 .group = FIO_OPT_G_CRED,
4181 .type = FIO_OPT_INT,
4182 .off1 = offsetof(struct thread_options, kb_base),
4188 .help = "Inputs invert IEC and SI prefixes (for compatibility); outputs prefer binary",
4192 .help = "Inputs use IEC and SI prefixes; outputs prefer SI",
4195 .help = "Unit prefix interpretation for quantities of data (IEC and SI)",
4196 .category = FIO_OPT_C_GENERAL,
4197 .group = FIO_OPT_G_INVALID,
4200 .name = "unit_base",
4201 .lname = "Unit for quantities of data (Bits or Bytes)",
4202 .type = FIO_OPT_INT,
4203 .off1 = offsetof(struct thread_options, unit_base),
4208 .help = "Auto-detect",
4212 .help = "Normal (byte based)",
4216 .help = "Bit based",
4219 .help = "Bit multiple of result summary data (8 for byte, 1 for bit)",
4220 .category = FIO_OPT_C_GENERAL,
4221 .group = FIO_OPT_G_INVALID,
4224 .name = "hugepage-size",
4225 .lname = "Hugepage size",
4226 .type = FIO_OPT_INT,
4227 .off1 = offsetof(struct thread_options, hugepage_size),
4228 .help = "When using hugepages, specify size of each page",
4229 .def = __fio_stringify(FIO_HUGE_PAGE),
4230 .interval = 1024 * 1024,
4231 .category = FIO_OPT_C_GENERAL,
4232 .group = FIO_OPT_G_INVALID,
4236 .lname = "I/O flow ID",
4237 .type = FIO_OPT_INT,
4238 .off1 = offsetof(struct thread_options, flow_id),
4239 .help = "The flow index ID to use",
4241 .category = FIO_OPT_C_IO,
4242 .group = FIO_OPT_G_IO_FLOW,
4246 .lname = "I/O flow weight",
4247 .type = FIO_OPT_INT,
4248 .off1 = offsetof(struct thread_options, flow),
4249 .help = "Weight for flow control of this job",
4250 .parent = "flow_id",
4253 .category = FIO_OPT_C_IO,
4254 .group = FIO_OPT_G_IO_FLOW,
4257 .name = "flow_watermark",
4258 .lname = "I/O flow watermark",
4259 .type = FIO_OPT_INT,
4260 .off1 = offsetof(struct thread_options, flow_watermark),
4261 .help = "High watermark for flow control. This option"
4262 " should be set to the same value for all threads"
4263 " with non-zero flow.",
4264 .parent = "flow_id",
4267 .category = FIO_OPT_C_IO,
4268 .group = FIO_OPT_G_IO_FLOW,
4271 .name = "flow_sleep",
4272 .lname = "I/O flow sleep",
4273 .type = FIO_OPT_INT,
4274 .off1 = offsetof(struct thread_options, flow_sleep),
4275 .help = "How many microseconds to sleep after being held"
4276 " back by the flow control mechanism",
4277 .parent = "flow_id",
4280 .category = FIO_OPT_C_IO,
4281 .group = FIO_OPT_G_IO_FLOW,
4285 .lname = "Skip operations against bad blocks",
4286 .type = FIO_OPT_BOOL,
4287 .off1 = offsetof(struct thread_options, skip_bad),
4288 .help = "Skip operations against known bad blocks.",
4291 .category = FIO_OPT_C_IO,
4292 .group = FIO_OPT_G_MTD,
4295 .name = "steadystate",
4296 .lname = "Steady state threshold",
4298 .type = FIO_OPT_STR,
4299 .off1 = offsetof(struct thread_options, ss_state),
4300 .cb = str_steadystate_cb,
4301 .help = "Define the criterion and limit to judge when a job has reached steady state",
4302 .def = "iops_slope:0.01%",
4305 .oval = FIO_SS_IOPS,
4306 .help = "maximum mean deviation of IOPS measurements",
4308 { .ival = "iops_slope",
4309 .oval = FIO_SS_IOPS_SLOPE,
4310 .help = "slope calculated from IOPS measurements",
4314 .help = "maximum mean deviation of bandwidth measurements",
4318 .oval = FIO_SS_BW_SLOPE,
4319 .help = "slope calculated from bandwidth measurements",
4322 .category = FIO_OPT_C_GENERAL,
4323 .group = FIO_OPT_G_RUNTIME,
4326 .name = "steadystate_duration",
4327 .lname = "Steady state duration",
4329 .parent = "steadystate",
4330 .type = FIO_OPT_STR_VAL_TIME,
4331 .off1 = offsetof(struct thread_options, ss_dur),
4332 .help = "Stop workload upon attaining steady state for specified duration",
4336 .category = FIO_OPT_C_GENERAL,
4337 .group = FIO_OPT_G_RUNTIME,
4340 .name = "steadystate_ramp_time",
4341 .lname = "Steady state ramp time",
4343 .parent = "steadystate",
4344 .type = FIO_OPT_STR_VAL_TIME,
4345 .off1 = offsetof(struct thread_options, ss_ramp_time),
4346 .help = "Delay before initiation of data collection for steady state job termination testing",
4350 .category = FIO_OPT_C_GENERAL,
4351 .group = FIO_OPT_G_RUNTIME,
4358 static void add_to_lopt(struct option *lopt, struct fio_option *o,
4359 const char *name, int val)
4361 lopt->name = (char *) name;
4363 if (o->type == FIO_OPT_STR_SET)
4364 lopt->has_arg = optional_argument;
4366 lopt->has_arg = required_argument;
4369 static void options_to_lopts(struct fio_option *opts,
4370 struct option *long_options,
4371 int i, int option_type)
4373 struct fio_option *o = &opts[0];
4375 add_to_lopt(&long_options[i], o, o->name, option_type);
4378 add_to_lopt(&long_options[i], o, o->alias, option_type);
4383 assert(i < FIO_NR_OPTIONS);
4387 void fio_options_set_ioengine_opts(struct option *long_options,
4388 struct thread_data *td)
4393 while (long_options[i].name) {
4394 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
4395 memset(&long_options[i], 0, sizeof(*long_options));
4402 * Just clear out the prior ioengine options.
4407 options_to_lopts(td->io_ops->options, long_options, i,
4408 FIO_GETOPT_IOENGINE);
4411 void fio_options_dup_and_init(struct option *long_options)
4415 options_init(fio_options);
4418 while (long_options[i].name)
4421 options_to_lopts(fio_options, long_options, i, FIO_GETOPT_JOB);
4424 struct fio_keyword {
4430 static struct fio_keyword fio_keywords[] = {
4432 .word = "$pagesize",
4433 .desc = "Page size in the system",
4436 .word = "$mb_memory",
4437 .desc = "Megabytes of memory online",
4441 .desc = "Number of CPUs online in the system",
4448 void fio_keywords_exit(void)
4450 struct fio_keyword *kw;
4452 kw = &fio_keywords[0];
4460 void fio_keywords_init(void)
4462 unsigned long long mb_memory;
4466 sprintf(buf, "%lu", (unsigned long) page_size);
4467 fio_keywords[0].replace = strdup(buf);
4469 mb_memory = os_phys_mem() / (1024 * 1024);
4470 sprintf(buf, "%llu", mb_memory);
4471 fio_keywords[1].replace = strdup(buf);
4474 sprintf(buf, "%lu", l);
4475 fio_keywords[2].replace = strdup(buf);
4480 static char *bc_calc(char *str)
4482 char buf[128], *tmp;
4487 * No math, just return string
4489 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
4490 !strchr(str, '/')) || strchr(str, '\''))
4494 * Split option from value, we only need to calculate the value
4496 tmp = strchr(str, '=');
4503 * Prevent buffer overflows; such a case isn't reasonable anyway
4505 if (strlen(str) >= 128 || strlen(tmp) > 100)
4508 sprintf(buf, "which %s > /dev/null", BC_APP);
4510 log_err("fio: bc is needed for performing math\n");
4514 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
4515 f = popen(buf, "r");
4519 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
4526 buf[(tmp - str) + ret - 1] = '\0';
4527 memcpy(buf, str, tmp - str);
4533 * Return a copy of the input string with substrings of the form ${VARNAME}
4534 * substituted with the value of the environment variable VARNAME. The
4535 * substitution always occurs, even if VARNAME is empty or the corresponding
4536 * environment variable undefined.
4538 static char *option_dup_subs(const char *opt)
4540 char out[OPT_LEN_MAX+1];
4541 char in[OPT_LEN_MAX+1];
4544 char *ch1, *ch2, *env;
4545 ssize_t nchr = OPT_LEN_MAX;
4548 if (strlen(opt) + 1 > OPT_LEN_MAX) {
4549 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
4553 in[OPT_LEN_MAX] = '\0';
4554 strncpy(in, opt, OPT_LEN_MAX);
4556 while (*inptr && nchr > 0) {
4557 if (inptr[0] == '$' && inptr[1] == '{') {
4558 ch2 = strchr(inptr, '}');
4559 if (ch2 && inptr+1 < ch2) {
4566 envlen = strlen(env);
4567 if (envlen <= nchr) {
4568 memcpy(outptr, env, envlen);
4578 *outptr++ = *inptr++;
4587 * Look for reserved variable names and replace them with real values
4589 static char *fio_keyword_replace(char *opt)
4595 for (i = 0; fio_keywords[i].word != NULL; i++) {
4596 struct fio_keyword *kw = &fio_keywords[i];
4598 while ((s = strstr(opt, kw->word)) != NULL) {
4599 char *new = malloc(strlen(opt) + 1);
4605 * Copy part of the string before the keyword and
4606 * sprintf() the replacement after it.
4608 memcpy(new, opt, olen);
4609 len = sprintf(new + olen, "%s", kw->replace);
4612 * If there's more in the original string, copy that
4615 opt += strlen(kw->word) + olen;
4617 memcpy(new + olen + len, opt, opt - o_org - 1);
4620 * replace opt and free the old opt
4630 * Check for potential math and invoke bc, if possible
4638 static char **dup_and_sub_options(char **opts, int num_opts)
4641 char **opts_copy = malloc(num_opts * sizeof(*opts));
4642 for (i = 0; i < num_opts; i++) {
4643 opts_copy[i] = option_dup_subs(opts[i]);
4646 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
4651 static void show_closest_option(const char *opt)
4653 int best_option, best_distance;
4662 while (name[i] != '\0' && name[i] != '=')
4667 best_distance = INT_MAX;
4669 while (fio_options[i].name) {
4670 distance = string_distance(name, fio_options[i].name);
4671 if (distance < best_distance) {
4672 best_distance = distance;
4678 if (best_option != -1 && string_distance_ok(name, best_distance) &&
4679 fio_options[best_option].type != FIO_OPT_UNSUPPORTED)
4680 log_err("Did you mean %s?\n", fio_options[best_option].name);
4685 int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
4687 int i, ret, unknown;
4690 sort_options(opts, fio_options, num_opts);
4691 opts_copy = dup_and_sub_options(opts, num_opts);
4693 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
4694 struct fio_option *o;
4695 int newret = parse_option(opts_copy[i], opts[i], fio_options,
4696 &o, &td->o, &td->opt_list);
4699 fio_option_mark_set(&td->o, o);
4707 opts_copy[i] = NULL;
4714 ret |= ioengine_load(td);
4716 sort_options(opts_copy, td->io_ops->options, num_opts);
4719 for (i = 0; i < num_opts; i++) {
4720 struct fio_option *o = NULL;
4727 newret = parse_option(opts_copy[i], opts[i],
4728 td->io_ops->options, &o,
4729 td->eo, &td->opt_list);
4733 log_err("Bad option <%s>\n", opts[i]);
4734 show_closest_option(opts[i]);
4737 opts_copy[i] = NULL;
4745 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
4749 ret = parse_cmd_option(opt, val, fio_options, &td->o, &td->opt_list);
4751 struct fio_option *o;
4753 o = find_option(fio_options, opt);
4755 fio_option_mark_set(&td->o, o);
4761 int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
4764 return parse_cmd_option(opt, val, td->io_ops->options, td->eo,
4768 void fio_fill_default_options(struct thread_data *td)
4770 td->o.magic = OPT_MAGIC;
4771 fill_default_options(&td->o, fio_options);
4774 int fio_show_option_help(const char *opt)
4776 return show_cmd_help(fio_options, opt);
4779 void options_mem_dupe(void *data, struct fio_option *options)
4781 struct fio_option *o;
4784 for (o = &options[0]; o->name; o++) {
4785 if (o->type != FIO_OPT_STR_STORE)
4788 ptr = td_var(data, o, o->off1);
4790 *ptr = strdup(*ptr);
4795 * dupe FIO_OPT_STR_STORE options
4797 void fio_options_mem_dupe(struct thread_data *td)
4799 options_mem_dupe(&td->o, fio_options);
4801 if (td->eo && td->io_ops) {
4802 void *oldeo = td->eo;
4804 td->eo = malloc(td->io_ops->option_struct_size);
4805 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
4806 options_mem_dupe(td->eo, td->io_ops->options);
4810 unsigned int fio_get_kb_base(void *data)
4812 struct thread_data *td = cb_data_to_td(data);
4813 struct thread_options *o = &td->o;
4814 unsigned int kb_base = 0;
4817 * This is a hack... For private options, *data is not holding
4818 * a pointer to the thread_options, but to private data. This means
4819 * we can't safely dereference it, but magic is first so mem wise
4820 * it is valid. But this also means that if the job first sets
4821 * kb_base and expects that to be honored by private options,
4822 * it will be disappointed. We will return the global default
4825 if (o && o->magic == OPT_MAGIC)
4826 kb_base = o->kb_base;
4833 int add_option(struct fio_option *o)
4835 struct fio_option *__o;
4844 if (opt_index + 1 == FIO_MAX_OPTS) {
4845 log_err("fio: FIO_MAX_OPTS is too small\n");
4849 memcpy(&fio_options[opt_index], o, sizeof(*o));
4850 fio_options[opt_index + 1].name = NULL;
4854 void invalidate_profile_options(const char *prof_name)
4856 struct fio_option *o;
4860 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
4861 o->type = FIO_OPT_INVALID;
4862 o->prof_name = NULL;
4868 void add_opt_posval(const char *optname, const char *ival, const char *help)
4870 struct fio_option *o;
4873 o = find_option(fio_options, optname);
4877 for (i = 0; i < PARSE_MAX_VP; i++) {
4878 if (o->posval[i].ival)
4881 o->posval[i].ival = ival;
4882 o->posval[i].help = help;
4887 void del_opt_posval(const char *optname, const char *ival)
4889 struct fio_option *o;
4892 o = find_option(fio_options, optname);
4896 for (i = 0; i < PARSE_MAX_VP; i++) {
4897 if (!o->posval[i].ival)
4899 if (strcmp(o->posval[i].ival, ival))
4902 o->posval[i].ival = NULL;
4903 o->posval[i].help = NULL;
4907 void fio_options_free(struct thread_data *td)
4909 options_free(fio_options, &td->o);
4910 if (td->eo && td->io_ops && td->io_ops->options) {
4911 options_free(td->io_ops->options, td->eo);
4917 struct fio_option *fio_option_find(const char *name)
4919 return find_option(fio_options, name);
4922 static struct fio_option *find_next_opt(struct thread_options *o,
4923 struct fio_option *from,
4926 struct fio_option *opt;
4929 from = &fio_options[0];
4935 if (off1 == from->off1) {
4940 } while (from->name);
4945 static int opt_is_set(struct thread_options *o, struct fio_option *opt)
4947 unsigned int opt_off, index, offset;
4949 opt_off = opt - &fio_options[0];
4950 index = opt_off / (8 * sizeof(uint64_t));
4951 offset = opt_off & ((8 * sizeof(uint64_t)) - 1);
4952 return (o->set_options[index] & ((uint64_t)1 << offset)) != 0;
4955 bool __fio_option_is_set(struct thread_options *o, unsigned int off1)
4957 struct fio_option *opt, *next;
4960 while ((opt = find_next_opt(o, next, off1)) != NULL) {
4961 if (opt_is_set(o, opt))
4970 void fio_option_mark_set(struct thread_options *o, struct fio_option *opt)
4972 unsigned int opt_off, index, offset;
4974 opt_off = opt - &fio_options[0];
4975 index = opt_off / (8 * sizeof(uint64_t));
4976 offset = opt_off & ((8 * sizeof(uint64_t)) - 1);
4977 o->set_options[index] |= (uint64_t)1 << offset;