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 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 = data;
1072 if (td->o.ss != FIO_STEADYSTATE_IOPS &&
1073 td->o.ss != FIO_STEADYSTATE_IOPS_SLOPE &&
1074 td->o.ss != FIO_STEADYSTATE_BW &&
1075 td->o.ss != FIO_STEADYSTATE_BW_SLOPE) {
1076 /* should be impossible to get here */
1077 log_err("fio: unknown steady state criterion\n");
1081 nr = get_opt_postfix(str);
1083 log_err("fio: steadystate threshold must be specified in addition to criterion\n");
1088 /* ENHANCEMENT Allow fio to understand size=10.2% and use here */
1089 pct = strstr(nr, "%");
1092 strip_blank_end(nr);
1093 if (!str_to_float(nr, &val, 0)) {
1094 log_err("fio: could not parse steadystate threshold percentage\n");
1099 dprint(FD_PARSE, "set steady state threshold to %f%%\n", val);
1104 td->o.ss_pct = true;
1105 td->o.ss_limit.u.f = val;
1108 } else if (td->o.ss == FIO_STEADYSTATE_IOPS ||
1109 td->o.ss == FIO_STEADYSTATE_IOPS_SLOPE) {
1110 if (!str_to_float(nr, &val, 0)) {
1111 log_err("fio: steadystate IOPS threshold postfix parsing failed\n");
1116 dprint(FD_PARSE, "set steady state IOPS threshold to %f\n", val);
1121 td->o.ss_pct = false;
1122 td->o.ss_limit.u.f = val;
1124 } else { /* bandwidth criterion */
1125 if (str_to_decimal(nr, &ll, 1, td, 0, 0)) {
1126 log_err("fio: steadystate BW threshold postfix parsing failed\n");
1131 dprint(FD_PARSE, "set steady state BW threshold to %lld\n", ll);
1136 td->o.ss_pct = false;
1137 td->o.ss_limit.u.f = (double) ll;
1145 * Return next name in the string. Files are separated with ':'. If the ':'
1146 * is escaped with a '\', then that ':' is part of the filename and does not
1147 * indicate a new file.
1149 static char *get_next_name(char **ptr)
1154 if (!str || !strlen(str))
1160 * No colon, we are done
1162 p = strchr(str, ':');
1169 * We got a colon, but it's the first character. Skip and
1177 if (*(p - 1) != '\\') {
1183 memmove(p - 1, p, strlen(p) + 1);
1191 static int get_max_name_idx(char *input)
1193 unsigned int cur_idx;
1196 p = str = strdup(input);
1197 for (cur_idx = 0; ; cur_idx++)
1198 if (get_next_name(&str) == NULL)
1206 * Returns the directory at the index, indexes > entires will be
1207 * assigned via modulo division of the index
1209 int set_name_idx(char *target, size_t tlen, char *input, int index,
1210 bool unique_filename)
1212 unsigned int cur_idx;
1214 char *fname, *str, *p;
1216 p = str = strdup(input);
1218 index %= get_max_name_idx(input);
1219 for (cur_idx = 0; cur_idx <= index; cur_idx++)
1220 fname = get_next_name(&str);
1222 if (client_sockaddr_str[0] && unique_filename) {
1223 len = snprintf(target, tlen, "%s/%s.", fname,
1224 client_sockaddr_str);
1226 len = snprintf(target, tlen, "%s/", fname);
1228 target[tlen - 1] = '\0';
1234 static int str_filename_cb(void *data, const char *input)
1236 struct thread_data *td = cb_data_to_td(data);
1237 char *fname, *str, *p;
1239 p = str = strdup(input);
1241 strip_blank_front(&str);
1242 strip_blank_end(str);
1244 if (!td->files_index)
1247 while ((fname = get_next_name(&str)) != NULL) {
1250 add_file(td, fname, 0, 1);
1257 static int str_directory_cb(void *data, const char fio_unused *unused)
1259 struct thread_data *td = cb_data_to_td(data);
1261 char *dirname, *str, *p;
1267 p = str = strdup(td->o.directory);
1268 while ((dirname = get_next_name(&str)) != NULL) {
1269 if (lstat(dirname, &sb) < 0) {
1272 log_err("fio: %s is not a directory\n", dirname);
1273 td_verror(td, ret, "lstat");
1276 if (!S_ISDIR(sb.st_mode)) {
1277 log_err("fio: %s is not a directory\n", dirname);
1288 static int str_opendir_cb(void *data, const char fio_unused *str)
1290 struct thread_data *td = cb_data_to_td(data);
1295 if (!td->files_index)
1298 return add_dir_files(td, td->o.opendir);
1301 static int str_buffer_pattern_cb(void *data, const char *input)
1303 struct thread_data *td = cb_data_to_td(data);
1306 /* FIXME: for now buffer pattern does not support formats */
1307 ret = parse_and_fill_pattern(input, strlen(input), td->o.buffer_pattern,
1308 MAX_PATTERN_SIZE, NULL, 0, NULL, NULL);
1313 td->o.buffer_pattern_bytes = ret;
1314 if (!td->o.compress_percentage)
1315 td->o.refill_buffers = 0;
1316 td->o.scramble_buffers = 0;
1317 td->o.zero_buffers = 0;
1322 static int str_buffer_compress_cb(void *data, unsigned long long *il)
1324 struct thread_data *td = cb_data_to_td(data);
1326 td->flags |= TD_F_COMPRESS;
1327 td->o.compress_percentage = *il;
1331 static int str_dedupe_cb(void *data, unsigned long long *il)
1333 struct thread_data *td = cb_data_to_td(data);
1335 td->flags |= TD_F_COMPRESS;
1336 td->o.dedupe_percentage = *il;
1337 td->o.refill_buffers = 1;
1341 static int str_verify_pattern_cb(void *data, const char *input)
1343 struct thread_data *td = cb_data_to_td(data);
1346 td->o.verify_fmt_sz = ARRAY_SIZE(td->o.verify_fmt);
1347 ret = parse_and_fill_pattern(input, strlen(input), td->o.verify_pattern,
1348 MAX_PATTERN_SIZE, fmt_desc, sizeof(fmt_desc),
1349 td->o.verify_fmt, &td->o.verify_fmt_sz);
1354 td->o.verify_pattern_bytes = ret;
1356 * VERIFY_* could already be set
1358 if (!fio_option_is_set(&td->o, verify))
1359 td->o.verify = VERIFY_PATTERN;
1364 static int str_gtod_reduce_cb(void *data, int *il)
1366 struct thread_data *td = cb_data_to_td(data);
1369 td->o.disable_lat = !!val;
1370 td->o.disable_clat = !!val;
1371 td->o.disable_slat = !!val;
1372 td->o.disable_bw = !!val;
1373 td->o.clat_percentiles = !val;
1375 td->tv_cache_mask = 63;
1380 static int str_size_cb(void *data, unsigned long long *__val)
1382 struct thread_data *td = cb_data_to_td(data);
1383 unsigned long long v = *__val;
1385 if (parse_is_percent(v)) {
1387 td->o.size_percent = -1ULL - v;
1394 static int rw_verify(struct fio_option *o, void *data)
1396 struct thread_data *td = cb_data_to_td(data);
1398 if (read_only && td_write(td)) {
1399 log_err("fio: job <%s> has write bit set, but fio is in"
1400 " read-only mode\n", td->o.name);
1407 static int gtod_cpu_verify(struct fio_option *o, void *data)
1409 #ifndef FIO_HAVE_CPU_AFFINITY
1410 struct thread_data *td = cb_data_to_td(data);
1412 if (td->o.gtod_cpu) {
1413 log_err("fio: platform must support CPU affinity for"
1414 "gettimeofday() offloading\n");
1423 * Map of job/command line options
1425 struct fio_option fio_options[FIO_MAX_OPTS] = {
1427 .name = "description",
1428 .lname = "Description of job",
1429 .type = FIO_OPT_STR_STORE,
1430 .off1 = offsetof(struct thread_options, description),
1431 .help = "Text job description",
1432 .category = FIO_OPT_C_GENERAL,
1433 .group = FIO_OPT_G_DESC,
1437 .lname = "Job name",
1438 .type = FIO_OPT_STR_STORE,
1439 .off1 = offsetof(struct thread_options, name),
1440 .help = "Name of this job",
1441 .category = FIO_OPT_C_GENERAL,
1442 .group = FIO_OPT_G_DESC,
1446 .lname = "Waitee name",
1447 .type = FIO_OPT_STR_STORE,
1448 .off1 = offsetof(struct thread_options, wait_for),
1449 .help = "Name of the job this one wants to wait for before starting",
1450 .category = FIO_OPT_C_GENERAL,
1451 .group = FIO_OPT_G_DESC,
1455 .lname = "Filename(s)",
1456 .type = FIO_OPT_STR_STORE,
1457 .off1 = offsetof(struct thread_options, filename),
1458 .cb = str_filename_cb,
1459 .prio = -1, /* must come after "directory" */
1460 .help = "File(s) to use for the workload",
1461 .category = FIO_OPT_C_FILE,
1462 .group = FIO_OPT_G_FILENAME,
1465 .name = "directory",
1466 .lname = "Directory",
1467 .type = FIO_OPT_STR_STORE,
1468 .off1 = offsetof(struct thread_options, directory),
1469 .cb = str_directory_cb,
1470 .help = "Directory to store files in",
1471 .category = FIO_OPT_C_FILE,
1472 .group = FIO_OPT_G_FILENAME,
1475 .name = "filename_format",
1476 .lname = "Filename Format",
1477 .type = FIO_OPT_STR_STORE,
1478 .off1 = offsetof(struct thread_options, filename_format),
1479 .prio = -1, /* must come after "directory" */
1480 .help = "Override default $jobname.$jobnum.$filenum naming",
1481 .def = "$jobname.$jobnum.$filenum",
1482 .category = FIO_OPT_C_FILE,
1483 .group = FIO_OPT_G_FILENAME,
1486 .name = "unique_filename",
1487 .lname = "Unique Filename",
1488 .type = FIO_OPT_BOOL,
1489 .off1 = offsetof(struct thread_options, unique_filename),
1490 .help = "For network clients, prefix file with source IP",
1492 .category = FIO_OPT_C_FILE,
1493 .group = FIO_OPT_G_FILENAME,
1497 .lname = "Lockfile",
1498 .type = FIO_OPT_STR,
1499 .off1 = offsetof(struct thread_options, file_lock_mode),
1500 .help = "Lock file when doing IO to it",
1502 .parent = "filename",
1505 .category = FIO_OPT_C_FILE,
1506 .group = FIO_OPT_G_FILENAME,
1509 .oval = FILE_LOCK_NONE,
1510 .help = "No file locking",
1512 { .ival = "exclusive",
1513 .oval = FILE_LOCK_EXCLUSIVE,
1514 .help = "Exclusive file lock",
1517 .ival = "readwrite",
1518 .oval = FILE_LOCK_READWRITE,
1519 .help = "Read vs write lock",
1525 .lname = "Open directory",
1526 .type = FIO_OPT_STR_STORE,
1527 .off1 = offsetof(struct thread_options, opendir),
1528 .cb = str_opendir_cb,
1529 .help = "Recursively add files from this directory and down",
1530 .category = FIO_OPT_C_FILE,
1531 .group = FIO_OPT_G_FILENAME,
1535 .lname = "Read/write",
1536 .alias = "readwrite",
1537 .type = FIO_OPT_STR,
1539 .off1 = offsetof(struct thread_options, td_ddir),
1540 .help = "IO direction",
1542 .verify = rw_verify,
1543 .category = FIO_OPT_C_IO,
1544 .group = FIO_OPT_G_IO_BASIC,
1547 .oval = TD_DDIR_READ,
1548 .help = "Sequential read",
1551 .oval = TD_DDIR_WRITE,
1552 .help = "Sequential write",
1555 .oval = TD_DDIR_TRIM,
1556 .help = "Sequential trim",
1558 { .ival = "randread",
1559 .oval = TD_DDIR_RANDREAD,
1560 .help = "Random read",
1562 { .ival = "randwrite",
1563 .oval = TD_DDIR_RANDWRITE,
1564 .help = "Random write",
1566 { .ival = "randtrim",
1567 .oval = TD_DDIR_RANDTRIM,
1568 .help = "Random trim",
1572 .help = "Sequential read and write mix",
1574 { .ival = "readwrite",
1576 .help = "Sequential read and write mix",
1579 .oval = TD_DDIR_RANDRW,
1580 .help = "Random read and write mix"
1582 { .ival = "trimwrite",
1583 .oval = TD_DDIR_TRIMWRITE,
1584 .help = "Trim and write mix, trims preceding writes"
1589 .name = "rw_sequencer",
1590 .lname = "RW Sequencer",
1591 .type = FIO_OPT_STR,
1592 .off1 = offsetof(struct thread_options, rw_seq),
1593 .help = "IO offset generator modifier",
1594 .def = "sequential",
1595 .category = FIO_OPT_C_IO,
1596 .group = FIO_OPT_G_IO_BASIC,
1598 { .ival = "sequential",
1600 .help = "Generate sequential offsets",
1602 { .ival = "identical",
1603 .oval = RW_SEQ_IDENT,
1604 .help = "Generate identical offsets",
1611 .lname = "IO Engine",
1612 .type = FIO_OPT_STR_STORE,
1613 .off1 = offsetof(struct thread_options, ioengine),
1614 .help = "IO engine to use",
1615 .def = FIO_PREFERRED_ENGINE,
1616 .category = FIO_OPT_C_IO,
1617 .group = FIO_OPT_G_IO_BASIC,
1620 .help = "Use read/write",
1623 .help = "Use pread/pwrite",
1626 .help = "Use readv/writev",
1628 #ifdef CONFIG_PWRITEV
1630 .help = "Use preadv/pwritev",
1633 #ifdef FIO_HAVE_PWRITEV2
1634 { .ival = "pvsync2",
1635 .help = "Use preadv2/pwritev2",
1638 #ifdef CONFIG_LIBAIO
1640 .help = "Linux native asynchronous IO",
1643 #ifdef CONFIG_POSIXAIO
1644 { .ival = "posixaio",
1645 .help = "POSIX asynchronous IO",
1648 #ifdef CONFIG_SOLARISAIO
1649 { .ival = "solarisaio",
1650 .help = "Solaris native asynchronous IO",
1653 #ifdef CONFIG_WINDOWSAIO
1654 { .ival = "windowsaio",
1655 .help = "Windows native asynchronous IO"
1660 .help = "Rados Block Device asynchronous IO"
1664 .help = "Memory mapped IO"
1666 #ifdef CONFIG_LINUX_SPLICE
1668 .help = "splice/vmsplice based IO",
1670 { .ival = "netsplice",
1671 .help = "splice/vmsplice to/from the network",
1674 #ifdef FIO_HAVE_SGIO
1676 .help = "SCSI generic v3 IO",
1680 .help = "Testing engine (no data transfer)",
1683 .help = "Network IO",
1686 .help = "CPU cycle burner engine",
1690 .help = "GUASI IO engine",
1693 #ifdef FIO_HAVE_BINJECT
1694 { .ival = "binject",
1695 .help = "binject direct inject block engine",
1700 .help = "RDMA IO engine",
1703 #ifdef CONFIG_FUSION_AW
1704 { .ival = "fusion-aw-sync",
1705 .help = "Fusion-io atomic write engine",
1708 #ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
1709 { .ival = "e4defrag",
1710 .help = "ext4 defrag engine",
1713 #ifdef CONFIG_LINUX_FALLOCATE
1715 .help = "fallocate() file based engine",
1720 .help = "Glusterfs libgfapi(sync) based engine"
1722 { .ival = "gfapi_async",
1723 .help = "Glusterfs libgfapi(async) based engine"
1726 #ifdef CONFIG_LIBHDFS
1727 { .ival = "libhdfs",
1728 .help = "Hadoop Distributed Filesystem (HDFS) engine"
1731 #ifdef CONFIG_PMEMBLK
1732 { .ival = "pmemblk",
1733 .help = "NVML libpmemblk based IO engine",
1737 { .ival = "external",
1738 .help = "Load external engine (append name)",
1744 .lname = "IO Depth",
1745 .type = FIO_OPT_INT,
1746 .off1 = offsetof(struct thread_options, iodepth),
1747 .help = "Number of IO buffers to keep in flight",
1751 .category = FIO_OPT_C_IO,
1752 .group = FIO_OPT_G_IO_BASIC,
1755 .name = "iodepth_batch",
1756 .lname = "IO Depth batch",
1757 .alias = "iodepth_batch_submit",
1758 .type = FIO_OPT_INT,
1759 .off1 = offsetof(struct thread_options, iodepth_batch),
1760 .help = "Number of IO buffers to submit in one go",
1761 .parent = "iodepth",
1765 .category = FIO_OPT_C_IO,
1766 .group = FIO_OPT_G_IO_BASIC,
1769 .name = "iodepth_batch_complete_min",
1770 .lname = "Min IO depth batch complete",
1771 .alias = "iodepth_batch_complete",
1772 .type = FIO_OPT_INT,
1773 .off1 = offsetof(struct thread_options, iodepth_batch_complete_min),
1774 .help = "Min number of IO buffers to retrieve in one go",
1775 .parent = "iodepth",
1780 .category = FIO_OPT_C_IO,
1781 .group = FIO_OPT_G_IO_BASIC,
1784 .name = "iodepth_batch_complete_max",
1785 .lname = "Max IO depth batch complete",
1786 .type = FIO_OPT_INT,
1787 .off1 = offsetof(struct thread_options, iodepth_batch_complete_max),
1788 .help = "Max number of IO buffers to retrieve in one go",
1789 .parent = "iodepth",
1793 .category = FIO_OPT_C_IO,
1794 .group = FIO_OPT_G_IO_BASIC,
1797 .name = "iodepth_low",
1798 .lname = "IO Depth batch low",
1799 .type = FIO_OPT_INT,
1800 .off1 = offsetof(struct thread_options, iodepth_low),
1801 .help = "Low water mark for queuing depth",
1802 .parent = "iodepth",
1805 .category = FIO_OPT_C_IO,
1806 .group = FIO_OPT_G_IO_BASIC,
1809 .name = "io_submit_mode",
1810 .lname = "IO submit mode",
1811 .type = FIO_OPT_STR,
1812 .off1 = offsetof(struct thread_options, io_submit_mode),
1813 .help = "How IO submissions and completions are done",
1815 .category = FIO_OPT_C_IO,
1816 .group = FIO_OPT_G_IO_BASIC,
1819 .oval = IO_MODE_INLINE,
1820 .help = "Submit and complete IO inline",
1822 { .ival = "offload",
1823 .oval = IO_MODE_OFFLOAD,
1824 .help = "Offload submit and complete to threads",
1831 .type = FIO_OPT_STR_VAL,
1833 .off1 = offsetof(struct thread_options, size),
1834 .help = "Total size of device or files",
1835 .interval = 1024 * 1024,
1836 .category = FIO_OPT_C_IO,
1837 .group = FIO_OPT_G_INVALID,
1841 .alias = "io_limit",
1843 .type = FIO_OPT_STR_VAL,
1844 .off1 = offsetof(struct thread_options, io_limit),
1845 .interval = 1024 * 1024,
1846 .category = FIO_OPT_C_IO,
1847 .group = FIO_OPT_G_INVALID,
1850 .name = "fill_device",
1851 .lname = "Fill device",
1853 .type = FIO_OPT_BOOL,
1854 .off1 = offsetof(struct thread_options, fill_device),
1855 .help = "Write until an ENOSPC error occurs",
1857 .category = FIO_OPT_C_FILE,
1858 .group = FIO_OPT_G_INVALID,
1862 .lname = "File size",
1863 .type = FIO_OPT_STR_VAL,
1864 .off1 = offsetof(struct thread_options, file_size_low),
1865 .off2 = offsetof(struct thread_options, file_size_high),
1867 .help = "Size of individual files",
1868 .interval = 1024 * 1024,
1869 .category = FIO_OPT_C_FILE,
1870 .group = FIO_OPT_G_INVALID,
1873 .name = "file_append",
1874 .lname = "File append",
1875 .type = FIO_OPT_BOOL,
1876 .off1 = offsetof(struct thread_options, file_append),
1877 .help = "IO will start at the end of the file(s)",
1879 .category = FIO_OPT_C_FILE,
1880 .group = FIO_OPT_G_INVALID,
1884 .lname = "IO offset",
1885 .alias = "fileoffset",
1886 .type = FIO_OPT_STR_VAL,
1887 .off1 = offsetof(struct thread_options, start_offset),
1888 .help = "Start IO from this offset",
1890 .interval = 1024 * 1024,
1891 .category = FIO_OPT_C_IO,
1892 .group = FIO_OPT_G_INVALID,
1895 .name = "offset_increment",
1896 .lname = "IO offset increment",
1897 .type = FIO_OPT_STR_VAL,
1898 .off1 = offsetof(struct thread_options, offset_increment),
1899 .help = "What is the increment from one offset to the next",
1903 .interval = 1024 * 1024,
1904 .category = FIO_OPT_C_IO,
1905 .group = FIO_OPT_G_INVALID,
1908 .name = "number_ios",
1909 .lname = "Number of IOs to perform",
1910 .type = FIO_OPT_STR_VAL,
1911 .off1 = offsetof(struct thread_options, number_ios),
1912 .help = "Force job completion after this number of IOs",
1914 .category = FIO_OPT_C_IO,
1915 .group = FIO_OPT_G_INVALID,
1919 .lname = "Block size",
1920 .alias = "blocksize",
1921 .type = FIO_OPT_INT,
1922 .off1 = offsetof(struct thread_options, bs[DDIR_READ]),
1923 .off2 = offsetof(struct thread_options, bs[DDIR_WRITE]),
1924 .off3 = offsetof(struct thread_options, bs[DDIR_TRIM]),
1926 .help = "Block size unit",
1931 .category = FIO_OPT_C_IO,
1932 .group = FIO_OPT_G_INVALID,
1936 .lname = "Block size align",
1937 .alias = "blockalign",
1938 .type = FIO_OPT_INT,
1939 .off1 = offsetof(struct thread_options, ba[DDIR_READ]),
1940 .off2 = offsetof(struct thread_options, ba[DDIR_WRITE]),
1941 .off3 = offsetof(struct thread_options, ba[DDIR_TRIM]),
1943 .help = "IO block offset alignment",
1947 .category = FIO_OPT_C_IO,
1948 .group = FIO_OPT_G_INVALID,
1952 .lname = "Block size range",
1953 .alias = "blocksize_range",
1954 .type = FIO_OPT_RANGE,
1955 .off1 = offsetof(struct thread_options, min_bs[DDIR_READ]),
1956 .off2 = offsetof(struct thread_options, max_bs[DDIR_READ]),
1957 .off3 = offsetof(struct thread_options, min_bs[DDIR_WRITE]),
1958 .off4 = offsetof(struct thread_options, max_bs[DDIR_WRITE]),
1959 .off5 = offsetof(struct thread_options, min_bs[DDIR_TRIM]),
1960 .off6 = offsetof(struct thread_options, max_bs[DDIR_TRIM]),
1962 .help = "Set block size range (in more detail than bs)",
1966 .category = FIO_OPT_C_IO,
1967 .group = FIO_OPT_G_INVALID,
1971 .lname = "Block size split",
1972 .type = FIO_OPT_STR,
1973 .cb = str_bssplit_cb,
1974 .off1 = offsetof(struct thread_options, bssplit),
1975 .help = "Set a specific mix of block sizes",
1978 .category = FIO_OPT_C_IO,
1979 .group = FIO_OPT_G_INVALID,
1982 .name = "bs_unaligned",
1983 .lname = "Block size unaligned",
1984 .alias = "blocksize_unaligned",
1985 .type = FIO_OPT_STR_SET,
1986 .off1 = offsetof(struct thread_options, bs_unaligned),
1987 .help = "Don't sector align IO buffer sizes",
1990 .category = FIO_OPT_C_IO,
1991 .group = FIO_OPT_G_INVALID,
1994 .name = "bs_is_seq_rand",
1995 .lname = "Block size division is seq/random (not read/write)",
1996 .type = FIO_OPT_BOOL,
1997 .off1 = offsetof(struct thread_options, bs_is_seq_rand),
1998 .help = "Consider any blocksize setting to be sequential,random",
2000 .parent = "blocksize",
2001 .category = FIO_OPT_C_IO,
2002 .group = FIO_OPT_G_INVALID,
2005 .name = "randrepeat",
2006 .lname = "Random repeatable",
2007 .type = FIO_OPT_BOOL,
2008 .off1 = offsetof(struct thread_options, rand_repeatable),
2009 .help = "Use repeatable random IO pattern",
2013 .category = FIO_OPT_C_IO,
2014 .group = FIO_OPT_G_RANDOM,
2018 .lname = "The random generator seed",
2019 .type = FIO_OPT_STR_VAL,
2020 .off1 = offsetof(struct thread_options, rand_seed),
2021 .help = "Set the random generator seed value",
2024 .category = FIO_OPT_C_IO,
2025 .group = FIO_OPT_G_RANDOM,
2028 .name = "use_os_rand",
2029 .lname = "Use OS random",
2030 .type = FIO_OPT_DEPRECATED,
2031 .off1 = offsetof(struct thread_options, dep_use_os_rand),
2032 .category = FIO_OPT_C_IO,
2033 .group = FIO_OPT_G_RANDOM,
2036 .name = "norandommap",
2037 .lname = "No randommap",
2038 .type = FIO_OPT_STR_SET,
2039 .off1 = offsetof(struct thread_options, norandommap),
2040 .help = "Accept potential duplicate random blocks",
2044 .category = FIO_OPT_C_IO,
2045 .group = FIO_OPT_G_RANDOM,
2048 .name = "softrandommap",
2049 .lname = "Soft randommap",
2050 .type = FIO_OPT_BOOL,
2051 .off1 = offsetof(struct thread_options, softrandommap),
2052 .help = "Set norandommap if randommap allocation fails",
2053 .parent = "norandommap",
2056 .category = FIO_OPT_C_IO,
2057 .group = FIO_OPT_G_RANDOM,
2060 .name = "random_generator",
2061 .lname = "Random Generator",
2062 .type = FIO_OPT_STR,
2063 .off1 = offsetof(struct thread_options, random_generator),
2064 .help = "Type of random number generator to use",
2065 .def = "tausworthe",
2067 { .ival = "tausworthe",
2068 .oval = FIO_RAND_GEN_TAUSWORTHE,
2069 .help = "Strong Tausworthe generator",
2072 .oval = FIO_RAND_GEN_LFSR,
2073 .help = "Variable length LFSR",
2076 .ival = "tausworthe64",
2077 .oval = FIO_RAND_GEN_TAUSWORTHE64,
2078 .help = "64-bit Tausworthe variant",
2081 .category = FIO_OPT_C_IO,
2082 .group = FIO_OPT_G_RANDOM,
2085 .name = "random_distribution",
2086 .lname = "Random Distribution",
2087 .type = FIO_OPT_STR,
2088 .off1 = offsetof(struct thread_options, random_distribution),
2089 .cb = str_random_distribution_cb,
2090 .help = "Random offset distribution generator",
2094 .oval = FIO_RAND_DIST_RANDOM,
2095 .help = "Completely random",
2098 .oval = FIO_RAND_DIST_ZIPF,
2099 .help = "Zipf distribution",
2102 .oval = FIO_RAND_DIST_PARETO,
2103 .help = "Pareto distribution",
2106 .oval = FIO_RAND_DIST_GAUSS,
2107 .help = "Normal (Gaussian) distribution",
2110 .oval = FIO_RAND_DIST_ZONED,
2111 .help = "Zoned random distribution",
2115 .category = FIO_OPT_C_IO,
2116 .group = FIO_OPT_G_RANDOM,
2119 .name = "percentage_random",
2120 .lname = "Percentage Random",
2121 .type = FIO_OPT_INT,
2122 .off1 = offsetof(struct thread_options, perc_rand[DDIR_READ]),
2123 .off2 = offsetof(struct thread_options, perc_rand[DDIR_WRITE]),
2124 .off3 = offsetof(struct thread_options, perc_rand[DDIR_TRIM]),
2126 .help = "Percentage of seq/random mix that should be random",
2127 .def = "100,100,100",
2129 .inverse = "percentage_sequential",
2130 .category = FIO_OPT_C_IO,
2131 .group = FIO_OPT_G_RANDOM,
2134 .name = "percentage_sequential",
2135 .lname = "Percentage Sequential",
2136 .type = FIO_OPT_DEPRECATED,
2137 .category = FIO_OPT_C_IO,
2138 .group = FIO_OPT_G_RANDOM,
2141 .name = "allrandrepeat",
2142 .lname = "All Random Repeat",
2143 .type = FIO_OPT_BOOL,
2144 .off1 = offsetof(struct thread_options, allrand_repeatable),
2145 .help = "Use repeatable random numbers for everything",
2147 .category = FIO_OPT_C_IO,
2148 .group = FIO_OPT_G_RANDOM,
2152 .lname = "Number of files",
2153 .alias = "nr_files",
2154 .type = FIO_OPT_INT,
2155 .off1 = offsetof(struct thread_options, nr_files),
2156 .help = "Split job workload between this number of files",
2159 .category = FIO_OPT_C_FILE,
2160 .group = FIO_OPT_G_INVALID,
2163 .name = "openfiles",
2164 .lname = "Number of open files",
2165 .type = FIO_OPT_INT,
2166 .off1 = offsetof(struct thread_options, open_files),
2167 .help = "Number of files to keep open at the same time",
2168 .category = FIO_OPT_C_FILE,
2169 .group = FIO_OPT_G_INVALID,
2172 .name = "file_service_type",
2173 .lname = "File service type",
2174 .type = FIO_OPT_STR,
2176 .off1 = offsetof(struct thread_options, file_service_type),
2177 .help = "How to select which file to service next",
2178 .def = "roundrobin",
2179 .category = FIO_OPT_C_FILE,
2180 .group = FIO_OPT_G_INVALID,
2183 .oval = FIO_FSERVICE_RANDOM,
2184 .help = "Choose a file at random (uniform)",
2187 .oval = FIO_FSERVICE_ZIPF,
2188 .help = "Zipf randomized",
2191 .oval = FIO_FSERVICE_PARETO,
2192 .help = "Pareto randomized",
2195 .oval = FIO_FSERVICE_GAUSS,
2196 .help = "Normal (guassian) distribution",
2198 { .ival = "roundrobin",
2199 .oval = FIO_FSERVICE_RR,
2200 .help = "Round robin select files",
2202 { .ival = "sequential",
2203 .oval = FIO_FSERVICE_SEQ,
2204 .help = "Finish one file before moving to the next",
2207 .parent = "nrfiles",
2210 #ifdef CONFIG_POSIX_FALLOCATE
2212 .name = "fallocate",
2213 .lname = "Fallocate",
2214 .type = FIO_OPT_STR,
2215 .off1 = offsetof(struct thread_options, fallocate_mode),
2216 .help = "Whether pre-allocation is performed when laying out files",
2218 .category = FIO_OPT_C_FILE,
2219 .group = FIO_OPT_G_INVALID,
2222 .oval = FIO_FALLOCATE_NONE,
2223 .help = "Do not pre-allocate space",
2226 .oval = FIO_FALLOCATE_POSIX,
2227 .help = "Use posix_fallocate()",
2229 #ifdef CONFIG_LINUX_FALLOCATE
2231 .oval = FIO_FALLOCATE_KEEP_SIZE,
2232 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
2235 /* Compatibility with former boolean values */
2237 .oval = FIO_FALLOCATE_NONE,
2238 .help = "Alias for 'none'",
2241 .oval = FIO_FALLOCATE_POSIX,
2242 .help = "Alias for 'posix'",
2246 #else /* CONFIG_POSIX_FALLOCATE */
2248 .name = "fallocate",
2249 .lname = "Fallocate",
2250 .type = FIO_OPT_UNSUPPORTED,
2251 .help = "Your platform does not support fallocate",
2253 #endif /* CONFIG_POSIX_FALLOCATE */
2255 .name = "fadvise_hint",
2256 .lname = "Fadvise hint",
2257 .type = FIO_OPT_BOOL,
2258 .off1 = offsetof(struct thread_options, fadvise_hint),
2259 .help = "Use fadvise() to advise the kernel on IO pattern",
2261 .category = FIO_OPT_C_FILE,
2262 .group = FIO_OPT_G_INVALID,
2264 #ifdef FIO_HAVE_STREAMID
2266 .name = "fadvise_stream",
2267 .lname = "Fadvise stream",
2268 .type = FIO_OPT_INT,
2269 .off1 = offsetof(struct thread_options, fadvise_stream),
2270 .help = "Use fadvise() to set stream ID",
2271 .category = FIO_OPT_C_FILE,
2272 .group = FIO_OPT_G_INVALID,
2276 .name = "fadvise_stream",
2277 .lname = "Fadvise stream",
2278 .type = FIO_OPT_UNSUPPORTED,
2279 .help = "Your platform does not support fadvise stream ID",
2285 .type = FIO_OPT_INT,
2286 .off1 = offsetof(struct thread_options, fsync_blocks),
2287 .help = "Issue fsync for writes every given number of blocks",
2290 .category = FIO_OPT_C_FILE,
2291 .group = FIO_OPT_G_INVALID,
2294 .name = "fdatasync",
2295 .lname = "Fdatasync",
2296 .type = FIO_OPT_INT,
2297 .off1 = offsetof(struct thread_options, fdatasync_blocks),
2298 .help = "Issue fdatasync for writes every given number of blocks",
2301 .category = FIO_OPT_C_FILE,
2302 .group = FIO_OPT_G_INVALID,
2305 .name = "write_barrier",
2306 .lname = "Write barrier",
2307 .type = FIO_OPT_INT,
2308 .off1 = offsetof(struct thread_options, barrier_blocks),
2309 .help = "Make every Nth write a barrier write",
2312 .category = FIO_OPT_C_IO,
2313 .group = FIO_OPT_G_INVALID,
2315 #ifdef CONFIG_SYNC_FILE_RANGE
2317 .name = "sync_file_range",
2318 .lname = "Sync file range",
2320 { .ival = "wait_before",
2321 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
2322 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
2326 .oval = SYNC_FILE_RANGE_WRITE,
2327 .help = "SYNC_FILE_RANGE_WRITE",
2331 .ival = "wait_after",
2332 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
2333 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
2337 .type = FIO_OPT_STR_MULTI,
2339 .off1 = offsetof(struct thread_options, sync_file_range),
2340 .help = "Use sync_file_range()",
2341 .category = FIO_OPT_C_FILE,
2342 .group = FIO_OPT_G_INVALID,
2346 .name = "sync_file_range",
2347 .lname = "Sync file range",
2348 .type = FIO_OPT_UNSUPPORTED,
2349 .help = "Your platform does not support sync_file_range",
2354 .lname = "Direct I/O",
2355 .type = FIO_OPT_BOOL,
2356 .off1 = offsetof(struct thread_options, odirect),
2357 .help = "Use O_DIRECT IO (negates buffered)",
2359 .inverse = "buffered",
2360 .category = FIO_OPT_C_IO,
2361 .group = FIO_OPT_G_IO_TYPE,
2365 .lname = "Atomic I/O",
2366 .type = FIO_OPT_BOOL,
2367 .off1 = offsetof(struct thread_options, oatomic),
2368 .help = "Use Atomic IO with O_DIRECT (implies O_DIRECT)",
2370 .category = FIO_OPT_C_IO,
2371 .group = FIO_OPT_G_IO_TYPE,
2375 .lname = "Buffered I/O",
2376 .type = FIO_OPT_BOOL,
2377 .off1 = offsetof(struct thread_options, odirect),
2379 .help = "Use buffered IO (negates direct)",
2381 .inverse = "direct",
2382 .category = FIO_OPT_C_IO,
2383 .group = FIO_OPT_G_IO_TYPE,
2386 .name = "overwrite",
2387 .lname = "Overwrite",
2388 .type = FIO_OPT_BOOL,
2389 .off1 = offsetof(struct thread_options, overwrite),
2390 .help = "When writing, set whether to overwrite current data",
2392 .category = FIO_OPT_C_FILE,
2393 .group = FIO_OPT_G_INVALID,
2398 .type = FIO_OPT_INT,
2399 .off1 = offsetof(struct thread_options, loops),
2400 .help = "Number of times to run the job",
2403 .category = FIO_OPT_C_GENERAL,
2404 .group = FIO_OPT_G_RUNTIME,
2408 .lname = "Number of jobs",
2409 .type = FIO_OPT_INT,
2410 .off1 = offsetof(struct thread_options, numjobs),
2411 .help = "Duplicate this job this many times",
2414 .category = FIO_OPT_C_GENERAL,
2415 .group = FIO_OPT_G_RUNTIME,
2418 .name = "startdelay",
2419 .lname = "Start delay",
2420 .type = FIO_OPT_STR_VAL_TIME,
2421 .off1 = offsetof(struct thread_options, start_delay),
2422 .off2 = offsetof(struct thread_options, start_delay_high),
2423 .help = "Only start job when this period has passed",
2427 .category = FIO_OPT_C_GENERAL,
2428 .group = FIO_OPT_G_RUNTIME,
2434 .type = FIO_OPT_STR_VAL_TIME,
2435 .off1 = offsetof(struct thread_options, timeout),
2436 .help = "Stop workload when this amount of time has passed",
2440 .category = FIO_OPT_C_GENERAL,
2441 .group = FIO_OPT_G_RUNTIME,
2444 .name = "time_based",
2445 .lname = "Time based",
2446 .type = FIO_OPT_STR_SET,
2447 .off1 = offsetof(struct thread_options, time_based),
2448 .help = "Keep running until runtime/timeout is met",
2449 .category = FIO_OPT_C_GENERAL,
2450 .group = FIO_OPT_G_RUNTIME,
2453 .name = "verify_only",
2454 .lname = "Verify only",
2455 .type = FIO_OPT_STR_SET,
2456 .off1 = offsetof(struct thread_options, verify_only),
2457 .help = "Verifies previously written data is still valid",
2458 .category = FIO_OPT_C_GENERAL,
2459 .group = FIO_OPT_G_RUNTIME,
2462 .name = "ramp_time",
2463 .lname = "Ramp time",
2464 .type = FIO_OPT_STR_VAL_TIME,
2465 .off1 = offsetof(struct thread_options, ramp_time),
2466 .help = "Ramp up time before measuring performance",
2469 .category = FIO_OPT_C_GENERAL,
2470 .group = FIO_OPT_G_RUNTIME,
2473 .name = "clocksource",
2474 .lname = "Clock source",
2475 .type = FIO_OPT_STR,
2476 .cb = fio_clock_source_cb,
2477 .off1 = offsetof(struct thread_options, clocksource),
2478 .help = "What type of timing source to use",
2479 .category = FIO_OPT_C_GENERAL,
2480 .group = FIO_OPT_G_CLOCK,
2482 #ifdef CONFIG_GETTIMEOFDAY
2483 { .ival = "gettimeofday",
2485 .help = "Use gettimeofday(2) for timing",
2488 #ifdef CONFIG_CLOCK_GETTIME
2489 { .ival = "clock_gettime",
2490 .oval = CS_CGETTIME,
2491 .help = "Use clock_gettime(2) for timing",
2494 #ifdef ARCH_HAVE_CPU_CLOCK
2496 .oval = CS_CPUCLOCK,
2497 .help = "Use CPU private clock",
2505 .lname = "I/O Memory",
2506 .type = FIO_OPT_STR,
2508 .off1 = offsetof(struct thread_options, mem_type),
2509 .help = "Backing type for IO buffers",
2511 .category = FIO_OPT_C_IO,
2512 .group = FIO_OPT_G_INVALID,
2516 .help = "Use malloc(3) for IO buffers",
2518 #ifndef CONFIG_NO_SHM
2521 .help = "Use shared memory segments for IO buffers",
2523 #ifdef FIO_HAVE_HUGETLB
2524 { .ival = "shmhuge",
2525 .oval = MEM_SHMHUGE,
2526 .help = "Like shm, but use huge pages",
2532 .help = "Use mmap(2) (file or anon) for IO buffers",
2534 { .ival = "mmapshared",
2535 .oval = MEM_MMAPSHARED,
2536 .help = "Like mmap, but use the shared flag",
2538 #ifdef FIO_HAVE_HUGETLB
2539 { .ival = "mmaphuge",
2540 .oval = MEM_MMAPHUGE,
2541 .help = "Like mmap, but use huge pages",
2547 .name = "iomem_align",
2548 .alias = "mem_align",
2549 .lname = "I/O memory alignment",
2550 .type = FIO_OPT_INT,
2551 .off1 = offsetof(struct thread_options, mem_align),
2553 .help = "IO memory buffer offset alignment",
2557 .category = FIO_OPT_C_IO,
2558 .group = FIO_OPT_G_INVALID,
2563 .type = FIO_OPT_STR,
2564 .off1 = offsetof(struct thread_options, verify),
2565 .help = "Verify data written",
2567 .category = FIO_OPT_C_IO,
2568 .group = FIO_OPT_G_VERIFY,
2571 .oval = VERIFY_NONE,
2572 .help = "Don't do IO verification",
2576 .help = "Use md5 checksums for verification",
2579 .oval = VERIFY_CRC64,
2580 .help = "Use crc64 checksums for verification",
2583 .oval = VERIFY_CRC32,
2584 .help = "Use crc32 checksums for verification",
2586 { .ival = "crc32c-intel",
2587 .oval = VERIFY_CRC32C,
2588 .help = "Use crc32c checksums for verification (hw assisted, if available)",
2591 .oval = VERIFY_CRC32C,
2592 .help = "Use crc32c checksums for verification (hw assisted, if available)",
2595 .oval = VERIFY_CRC16,
2596 .help = "Use crc16 checksums for verification",
2599 .oval = VERIFY_CRC7,
2600 .help = "Use crc7 checksums for verification",
2603 .oval = VERIFY_SHA1,
2604 .help = "Use sha1 checksums for verification",
2607 .oval = VERIFY_SHA256,
2608 .help = "Use sha256 checksums for verification",
2611 .oval = VERIFY_SHA512,
2612 .help = "Use sha512 checksums for verification",
2615 .oval = VERIFY_XXHASH,
2616 .help = "Use xxhash checksums for verification",
2618 /* Meta information was included into verify_header,
2619 * 'meta' verification is implied by default. */
2621 .oval = VERIFY_HDR_ONLY,
2622 .help = "Use io information for verification. "
2623 "Now is implied by default, thus option is obsolete, "
2626 { .ival = "pattern",
2627 .oval = VERIFY_PATTERN_NO_HDR,
2628 .help = "Verify strict pattern",
2632 .oval = VERIFY_NULL,
2633 .help = "Pretend to verify",
2638 .name = "do_verify",
2639 .lname = "Perform verify step",
2640 .type = FIO_OPT_BOOL,
2641 .off1 = offsetof(struct thread_options, do_verify),
2642 .help = "Run verification stage after write",
2646 .category = FIO_OPT_C_IO,
2647 .group = FIO_OPT_G_VERIFY,
2650 .name = "verifysort",
2651 .lname = "Verify sort",
2652 .type = FIO_OPT_BOOL,
2653 .off1 = offsetof(struct thread_options, verifysort),
2654 .help = "Sort written verify blocks for read back",
2658 .category = FIO_OPT_C_IO,
2659 .group = FIO_OPT_G_VERIFY,
2662 .name = "verifysort_nr",
2663 .lname = "Verify Sort Nr",
2664 .type = FIO_OPT_INT,
2665 .off1 = offsetof(struct thread_options, verifysort_nr),
2666 .help = "Pre-load and sort verify blocks for a read workload",
2671 .category = FIO_OPT_C_IO,
2672 .group = FIO_OPT_G_VERIFY,
2675 .name = "verify_interval",
2676 .lname = "Verify interval",
2677 .type = FIO_OPT_INT,
2678 .off1 = offsetof(struct thread_options, verify_interval),
2679 .minval = 2 * sizeof(struct verify_header),
2680 .help = "Store verify buffer header every N bytes",
2683 .interval = 2 * sizeof(struct verify_header),
2684 .category = FIO_OPT_C_IO,
2685 .group = FIO_OPT_G_VERIFY,
2688 .name = "verify_offset",
2689 .lname = "Verify offset",
2690 .type = FIO_OPT_INT,
2691 .help = "Offset verify header location by N bytes",
2692 .off1 = offsetof(struct thread_options, verify_offset),
2693 .minval = sizeof(struct verify_header),
2696 .category = FIO_OPT_C_IO,
2697 .group = FIO_OPT_G_VERIFY,
2700 .name = "verify_pattern",
2701 .lname = "Verify pattern",
2702 .type = FIO_OPT_STR,
2703 .cb = str_verify_pattern_cb,
2704 .off1 = offsetof(struct thread_options, verify_pattern),
2705 .help = "Fill pattern for IO buffers",
2708 .category = FIO_OPT_C_IO,
2709 .group = FIO_OPT_G_VERIFY,
2712 .name = "verify_fatal",
2713 .lname = "Verify fatal",
2714 .type = FIO_OPT_BOOL,
2715 .off1 = offsetof(struct thread_options, verify_fatal),
2717 .help = "Exit on a single verify failure, don't continue",
2720 .category = FIO_OPT_C_IO,
2721 .group = FIO_OPT_G_VERIFY,
2724 .name = "verify_dump",
2725 .lname = "Verify dump",
2726 .type = FIO_OPT_BOOL,
2727 .off1 = offsetof(struct thread_options, verify_dump),
2729 .help = "Dump contents of good and bad blocks on failure",
2732 .category = FIO_OPT_C_IO,
2733 .group = FIO_OPT_G_VERIFY,
2736 .name = "verify_async",
2737 .lname = "Verify asynchronously",
2738 .type = FIO_OPT_INT,
2739 .off1 = offsetof(struct thread_options, verify_async),
2741 .help = "Number of async verifier threads to use",
2744 .category = FIO_OPT_C_IO,
2745 .group = FIO_OPT_G_VERIFY,
2748 .name = "verify_backlog",
2749 .lname = "Verify backlog",
2750 .type = FIO_OPT_STR_VAL,
2751 .off1 = offsetof(struct thread_options, verify_backlog),
2752 .help = "Verify after this number of blocks are written",
2755 .category = FIO_OPT_C_IO,
2756 .group = FIO_OPT_G_VERIFY,
2759 .name = "verify_backlog_batch",
2760 .lname = "Verify backlog batch",
2761 .type = FIO_OPT_INT,
2762 .off1 = offsetof(struct thread_options, verify_batch),
2763 .help = "Verify this number of IO blocks",
2766 .category = FIO_OPT_C_IO,
2767 .group = FIO_OPT_G_VERIFY,
2769 #ifdef FIO_HAVE_CPU_AFFINITY
2771 .name = "verify_async_cpus",
2772 .lname = "Async verify CPUs",
2773 .type = FIO_OPT_STR,
2774 .cb = str_verify_cpus_allowed_cb,
2775 .off1 = offsetof(struct thread_options, verify_cpumask),
2776 .help = "Set CPUs allowed for async verify threads",
2777 .parent = "verify_async",
2779 .category = FIO_OPT_C_IO,
2780 .group = FIO_OPT_G_VERIFY,
2784 .name = "verify_async_cpus",
2785 .lname = "Async verify CPUs",
2786 .type = FIO_OPT_UNSUPPORTED,
2787 .help = "Your platform does not support CPU affinities",
2791 .name = "experimental_verify",
2792 .lname = "Experimental Verify",
2793 .off1 = offsetof(struct thread_options, experimental_verify),
2794 .type = FIO_OPT_BOOL,
2795 .help = "Enable experimental verification",
2797 .category = FIO_OPT_C_IO,
2798 .group = FIO_OPT_G_VERIFY,
2801 .name = "verify_state_load",
2802 .lname = "Load verify state",
2803 .off1 = offsetof(struct thread_options, verify_state),
2804 .type = FIO_OPT_BOOL,
2805 .help = "Load verify termination state",
2807 .category = FIO_OPT_C_IO,
2808 .group = FIO_OPT_G_VERIFY,
2811 .name = "verify_state_save",
2812 .lname = "Save verify state",
2813 .off1 = offsetof(struct thread_options, verify_state_save),
2814 .type = FIO_OPT_BOOL,
2816 .help = "Save verify state on termination",
2818 .category = FIO_OPT_C_IO,
2819 .group = FIO_OPT_G_VERIFY,
2821 #ifdef FIO_HAVE_TRIM
2823 .name = "trim_percentage",
2824 .lname = "Trim percentage",
2825 .type = FIO_OPT_INT,
2826 .off1 = offsetof(struct thread_options, trim_percentage),
2829 .help = "Number of verify blocks to discard/trim",
2834 .category = FIO_OPT_C_IO,
2835 .group = FIO_OPT_G_TRIM,
2838 .name = "trim_verify_zero",
2839 .lname = "Verify trim zero",
2840 .type = FIO_OPT_BOOL,
2841 .help = "Verify that trim/discarded blocks are returned as zeroes",
2842 .off1 = offsetof(struct thread_options, trim_zero),
2843 .parent = "trim_percentage",
2846 .category = FIO_OPT_C_IO,
2847 .group = FIO_OPT_G_TRIM,
2850 .name = "trim_backlog",
2851 .lname = "Trim backlog",
2852 .type = FIO_OPT_STR_VAL,
2853 .off1 = offsetof(struct thread_options, trim_backlog),
2854 .help = "Trim after this number of blocks are written",
2855 .parent = "trim_percentage",
2858 .category = FIO_OPT_C_IO,
2859 .group = FIO_OPT_G_TRIM,
2862 .name = "trim_backlog_batch",
2863 .lname = "Trim backlog batch",
2864 .type = FIO_OPT_INT,
2865 .off1 = offsetof(struct thread_options, trim_batch),
2866 .help = "Trim this number of IO blocks",
2867 .parent = "trim_percentage",
2870 .category = FIO_OPT_C_IO,
2871 .group = FIO_OPT_G_TRIM,
2875 .name = "trim_percentage",
2876 .lname = "Trim percentage",
2877 .type = FIO_OPT_UNSUPPORTED,
2878 .help = "Fio does not support TRIM on your platform",
2881 .name = "trim_verify_zero",
2882 .lname = "Verify trim zero",
2883 .type = FIO_OPT_UNSUPPORTED,
2884 .help = "Fio does not support TRIM on your platform",
2887 .name = "trim_backlog",
2888 .lname = "Trim backlog",
2889 .type = FIO_OPT_UNSUPPORTED,
2890 .help = "Fio does not support TRIM on your platform",
2893 .name = "trim_backlog_batch",
2894 .lname = "Trim backlog batch",
2895 .type = FIO_OPT_UNSUPPORTED,
2896 .help = "Fio does not support TRIM on your platform",
2900 .name = "write_iolog",
2901 .lname = "Write I/O log",
2902 .type = FIO_OPT_STR_STORE,
2903 .off1 = offsetof(struct thread_options, write_iolog_file),
2904 .help = "Store IO pattern to file",
2905 .category = FIO_OPT_C_IO,
2906 .group = FIO_OPT_G_IOLOG,
2909 .name = "read_iolog",
2910 .lname = "Read I/O log",
2911 .type = FIO_OPT_STR_STORE,
2912 .off1 = offsetof(struct thread_options, read_iolog_file),
2913 .help = "Playback IO pattern from file",
2914 .category = FIO_OPT_C_IO,
2915 .group = FIO_OPT_G_IOLOG,
2918 .name = "replay_no_stall",
2919 .lname = "Don't stall on replay",
2920 .type = FIO_OPT_BOOL,
2921 .off1 = offsetof(struct thread_options, no_stall),
2923 .parent = "read_iolog",
2925 .help = "Playback IO pattern file as fast as possible without stalls",
2926 .category = FIO_OPT_C_IO,
2927 .group = FIO_OPT_G_IOLOG,
2930 .name = "replay_redirect",
2931 .lname = "Redirect device for replay",
2932 .type = FIO_OPT_STR_STORE,
2933 .off1 = offsetof(struct thread_options, replay_redirect),
2934 .parent = "read_iolog",
2936 .help = "Replay all I/O onto this device, regardless of trace device",
2937 .category = FIO_OPT_C_IO,
2938 .group = FIO_OPT_G_IOLOG,
2941 .name = "replay_scale",
2942 .lname = "Replace offset scale factor",
2943 .type = FIO_OPT_INT,
2944 .off1 = offsetof(struct thread_options, replay_scale),
2945 .parent = "read_iolog",
2947 .help = "Align offsets to this blocksize",
2948 .category = FIO_OPT_C_IO,
2949 .group = FIO_OPT_G_IOLOG,
2952 .name = "replay_align",
2953 .lname = "Replace alignment",
2954 .type = FIO_OPT_INT,
2955 .off1 = offsetof(struct thread_options, replay_align),
2956 .parent = "read_iolog",
2957 .help = "Scale offset down by this factor",
2958 .category = FIO_OPT_C_IO,
2959 .group = FIO_OPT_G_IOLOG,
2963 .name = "exec_prerun",
2964 .lname = "Pre-execute runnable",
2965 .type = FIO_OPT_STR_STORE,
2966 .off1 = offsetof(struct thread_options, exec_prerun),
2967 .help = "Execute this file prior to running job",
2968 .category = FIO_OPT_C_GENERAL,
2969 .group = FIO_OPT_G_INVALID,
2972 .name = "exec_postrun",
2973 .lname = "Post-execute runnable",
2974 .type = FIO_OPT_STR_STORE,
2975 .off1 = offsetof(struct thread_options, exec_postrun),
2976 .help = "Execute this file after running job",
2977 .category = FIO_OPT_C_GENERAL,
2978 .group = FIO_OPT_G_INVALID,
2980 #ifdef FIO_HAVE_IOSCHED_SWITCH
2982 .name = "ioscheduler",
2983 .lname = "I/O scheduler",
2984 .type = FIO_OPT_STR_STORE,
2985 .off1 = offsetof(struct thread_options, ioscheduler),
2986 .help = "Use this IO scheduler on the backing device",
2987 .category = FIO_OPT_C_FILE,
2988 .group = FIO_OPT_G_INVALID,
2992 .name = "ioscheduler",
2993 .lname = "I/O scheduler",
2994 .type = FIO_OPT_UNSUPPORTED,
2995 .help = "Your platform does not support IO scheduler switching",
3000 .lname = "Zone size",
3001 .type = FIO_OPT_STR_VAL,
3002 .off1 = offsetof(struct thread_options, zone_size),
3003 .help = "Amount of data to read per zone",
3005 .interval = 1024 * 1024,
3006 .category = FIO_OPT_C_IO,
3007 .group = FIO_OPT_G_ZONE,
3010 .name = "zonerange",
3011 .lname = "Zone range",
3012 .type = FIO_OPT_STR_VAL,
3013 .off1 = offsetof(struct thread_options, zone_range),
3014 .help = "Give size of an IO zone",
3016 .interval = 1024 * 1024,
3017 .category = FIO_OPT_C_IO,
3018 .group = FIO_OPT_G_ZONE,
3022 .lname = "Zone skip",
3023 .type = FIO_OPT_STR_VAL,
3024 .off1 = offsetof(struct thread_options, zone_skip),
3025 .help = "Space between IO zones",
3027 .interval = 1024 * 1024,
3028 .category = FIO_OPT_C_IO,
3029 .group = FIO_OPT_G_ZONE,
3033 .lname = "Lock memory",
3034 .type = FIO_OPT_STR_VAL,
3035 .off1 = offsetof(struct thread_options, lockmem),
3036 .help = "Lock down this amount of memory (per worker)",
3038 .interval = 1024 * 1024,
3039 .category = FIO_OPT_C_GENERAL,
3040 .group = FIO_OPT_G_INVALID,
3043 .name = "rwmixread",
3044 .lname = "Read/write mix read",
3045 .type = FIO_OPT_INT,
3046 .cb = str_rwmix_read_cb,
3047 .off1 = offsetof(struct thread_options, rwmix[DDIR_READ]),
3049 .help = "Percentage of mixed workload that is reads",
3052 .inverse = "rwmixwrite",
3053 .category = FIO_OPT_C_IO,
3054 .group = FIO_OPT_G_RWMIX,
3057 .name = "rwmixwrite",
3058 .lname = "Read/write mix write",
3059 .type = FIO_OPT_INT,
3060 .cb = str_rwmix_write_cb,
3061 .off1 = offsetof(struct thread_options, rwmix[DDIR_WRITE]),
3063 .help = "Percentage of mixed workload that is writes",
3066 .inverse = "rwmixread",
3067 .category = FIO_OPT_C_IO,
3068 .group = FIO_OPT_G_RWMIX,
3071 .name = "rwmixcycle",
3072 .lname = "Read/write mix cycle",
3073 .type = FIO_OPT_DEPRECATED,
3074 .category = FIO_OPT_C_IO,
3075 .group = FIO_OPT_G_RWMIX,
3080 .type = FIO_OPT_INT,
3081 .off1 = offsetof(struct thread_options, nice),
3082 .help = "Set job CPU nice value",
3087 .category = FIO_OPT_C_GENERAL,
3088 .group = FIO_OPT_G_CRED,
3090 #ifdef FIO_HAVE_IOPRIO
3093 .lname = "I/O nice priority",
3094 .type = FIO_OPT_INT,
3095 .off1 = offsetof(struct thread_options, ioprio),
3096 .help = "Set job IO priority value",
3097 .minval = IOPRIO_MIN_PRIO,
3098 .maxval = IOPRIO_MAX_PRIO,
3100 .category = FIO_OPT_C_GENERAL,
3101 .group = FIO_OPT_G_CRED,
3106 .lname = "I/O nice priority",
3107 .type = FIO_OPT_UNSUPPORTED,
3108 .help = "Your platform does not support IO priorities",
3111 #ifdef FIO_HAVE_IOPRIO_CLASS
3112 #ifndef FIO_HAVE_IOPRIO
3113 #error "FIO_HAVE_IOPRIO_CLASS requires FIO_HAVE_IOPRIO"
3116 .name = "prioclass",
3117 .lname = "I/O nice priority class",
3118 .type = FIO_OPT_INT,
3119 .off1 = offsetof(struct thread_options, ioprio_class),
3120 .help = "Set job IO priority class",
3121 .minval = IOPRIO_MIN_PRIO_CLASS,
3122 .maxval = IOPRIO_MAX_PRIO_CLASS,
3124 .category = FIO_OPT_C_GENERAL,
3125 .group = FIO_OPT_G_CRED,
3129 .name = "prioclass",
3130 .lname = "I/O nice priority class",
3131 .type = FIO_OPT_UNSUPPORTED,
3132 .help = "Your platform does not support IO priority classes",
3136 .name = "thinktime",
3137 .lname = "Thinktime",
3138 .type = FIO_OPT_INT,
3139 .off1 = offsetof(struct thread_options, thinktime),
3140 .help = "Idle time between IO buffers (usec)",
3143 .category = FIO_OPT_C_IO,
3144 .group = FIO_OPT_G_THINKTIME,
3147 .name = "thinktime_spin",
3148 .lname = "Thinktime spin",
3149 .type = FIO_OPT_INT,
3150 .off1 = offsetof(struct thread_options, thinktime_spin),
3151 .help = "Start think time by spinning this amount (usec)",
3154 .parent = "thinktime",
3156 .category = FIO_OPT_C_IO,
3157 .group = FIO_OPT_G_THINKTIME,
3160 .name = "thinktime_blocks",
3161 .lname = "Thinktime blocks",
3162 .type = FIO_OPT_INT,
3163 .off1 = offsetof(struct thread_options, thinktime_blocks),
3164 .help = "IO buffer period between 'thinktime'",
3166 .parent = "thinktime",
3168 .category = FIO_OPT_C_IO,
3169 .group = FIO_OPT_G_THINKTIME,
3173 .lname = "I/O rate",
3174 .type = FIO_OPT_INT,
3175 .off1 = offsetof(struct thread_options, rate[DDIR_READ]),
3176 .off2 = offsetof(struct thread_options, rate[DDIR_WRITE]),
3177 .off3 = offsetof(struct thread_options, rate[DDIR_TRIM]),
3178 .help = "Set bandwidth rate",
3179 .category = FIO_OPT_C_IO,
3180 .group = FIO_OPT_G_RATE,
3185 .lname = "I/O min rate",
3186 .type = FIO_OPT_INT,
3187 .off1 = offsetof(struct thread_options, ratemin[DDIR_READ]),
3188 .off2 = offsetof(struct thread_options, ratemin[DDIR_WRITE]),
3189 .off3 = offsetof(struct thread_options, ratemin[DDIR_TRIM]),
3190 .help = "Job must meet this rate or it will be shutdown",
3193 .category = FIO_OPT_C_IO,
3194 .group = FIO_OPT_G_RATE,
3197 .name = "rate_iops",
3198 .lname = "I/O rate IOPS",
3199 .type = FIO_OPT_INT,
3200 .off1 = offsetof(struct thread_options, rate_iops[DDIR_READ]),
3201 .off2 = offsetof(struct thread_options, rate_iops[DDIR_WRITE]),
3202 .off3 = offsetof(struct thread_options, rate_iops[DDIR_TRIM]),
3203 .help = "Limit IO used to this number of IO operations/sec",
3205 .category = FIO_OPT_C_IO,
3206 .group = FIO_OPT_G_RATE,
3209 .name = "rate_iops_min",
3210 .lname = "I/O min rate IOPS",
3211 .type = FIO_OPT_INT,
3212 .off1 = offsetof(struct thread_options, rate_iops_min[DDIR_READ]),
3213 .off2 = offsetof(struct thread_options, rate_iops_min[DDIR_WRITE]),
3214 .off3 = offsetof(struct thread_options, rate_iops_min[DDIR_TRIM]),
3215 .help = "Job must meet this rate or it will be shut down",
3216 .parent = "rate_iops",
3218 .category = FIO_OPT_C_IO,
3219 .group = FIO_OPT_G_RATE,
3222 .name = "rate_process",
3223 .lname = "Rate Process",
3224 .type = FIO_OPT_STR,
3225 .off1 = offsetof(struct thread_options, rate_process),
3226 .help = "What process controls how rated IO is managed",
3228 .category = FIO_OPT_C_IO,
3229 .group = FIO_OPT_G_RATE,
3232 .oval = RATE_PROCESS_LINEAR,
3233 .help = "Linear rate of IO",
3237 .oval = RATE_PROCESS_POISSON,
3238 .help = "Rate follows Poisson process",
3244 .name = "rate_cycle",
3245 .alias = "ratecycle",
3246 .lname = "I/O rate cycle",
3247 .type = FIO_OPT_INT,
3248 .off1 = offsetof(struct thread_options, ratecycle),
3249 .help = "Window average for rate limits (msec)",
3253 .category = FIO_OPT_C_IO,
3254 .group = FIO_OPT_G_RATE,
3257 .name = "max_latency",
3258 .lname = "Max Latency",
3259 .type = FIO_OPT_INT,
3260 .off1 = offsetof(struct thread_options, max_latency),
3261 .help = "Maximum tolerated IO latency (usec)",
3263 .category = FIO_OPT_C_IO,
3264 .group = FIO_OPT_G_LATPROF,
3267 .name = "latency_target",
3268 .lname = "Latency Target (usec)",
3269 .type = FIO_OPT_STR_VAL_TIME,
3270 .off1 = offsetof(struct thread_options, latency_target),
3271 .help = "Ramp to max queue depth supporting this latency",
3273 .category = FIO_OPT_C_IO,
3274 .group = FIO_OPT_G_LATPROF,
3277 .name = "latency_window",
3278 .lname = "Latency Window (usec)",
3279 .type = FIO_OPT_STR_VAL_TIME,
3280 .off1 = offsetof(struct thread_options, latency_window),
3281 .help = "Time to sustain latency_target",
3283 .category = FIO_OPT_C_IO,
3284 .group = FIO_OPT_G_LATPROF,
3287 .name = "latency_percentile",
3288 .lname = "Latency Percentile",
3289 .type = FIO_OPT_FLOAT_LIST,
3290 .off1 = offsetof(struct thread_options, latency_percentile),
3291 .help = "Percentile of IOs must be below latency_target",
3296 .category = FIO_OPT_C_IO,
3297 .group = FIO_OPT_G_LATPROF,
3300 .name = "invalidate",
3301 .lname = "Cache invalidate",
3302 .type = FIO_OPT_BOOL,
3303 .off1 = offsetof(struct thread_options, invalidate_cache),
3304 .help = "Invalidate buffer/page cache prior to running job",
3306 .category = FIO_OPT_C_IO,
3307 .group = FIO_OPT_G_IO_TYPE,
3311 .lname = "Synchronous I/O",
3312 .type = FIO_OPT_BOOL,
3313 .off1 = offsetof(struct thread_options, sync_io),
3314 .help = "Use O_SYNC for buffered writes",
3316 .parent = "buffered",
3318 .category = FIO_OPT_C_IO,
3319 .group = FIO_OPT_G_IO_TYPE,
3322 .name = "create_serialize",
3323 .lname = "Create serialize",
3324 .type = FIO_OPT_BOOL,
3325 .off1 = offsetof(struct thread_options, create_serialize),
3326 .help = "Serialize creation of job files",
3328 .category = FIO_OPT_C_FILE,
3329 .group = FIO_OPT_G_INVALID,
3332 .name = "create_fsync",
3333 .lname = "Create fsync",
3334 .type = FIO_OPT_BOOL,
3335 .off1 = offsetof(struct thread_options, create_fsync),
3336 .help = "fsync file after creation",
3338 .category = FIO_OPT_C_FILE,
3339 .group = FIO_OPT_G_INVALID,
3342 .name = "create_on_open",
3343 .lname = "Create on open",
3344 .type = FIO_OPT_BOOL,
3345 .off1 = offsetof(struct thread_options, create_on_open),
3346 .help = "Create files when they are opened for IO",
3348 .category = FIO_OPT_C_FILE,
3349 .group = FIO_OPT_G_INVALID,
3352 .name = "create_only",
3353 .lname = "Create Only",
3354 .type = FIO_OPT_BOOL,
3355 .off1 = offsetof(struct thread_options, create_only),
3356 .help = "Only perform file creation phase",
3357 .category = FIO_OPT_C_FILE,
3361 .name = "allow_file_create",
3362 .lname = "Allow file create",
3363 .type = FIO_OPT_BOOL,
3364 .off1 = offsetof(struct thread_options, allow_create),
3365 .help = "Permit fio to create files, if they don't exist",
3367 .category = FIO_OPT_C_FILE,
3368 .group = FIO_OPT_G_FILENAME,
3371 .name = "allow_mounted_write",
3372 .lname = "Allow mounted write",
3373 .type = FIO_OPT_BOOL,
3374 .off1 = offsetof(struct thread_options, allow_mounted_write),
3375 .help = "Allow writes to a mounted partition",
3377 .category = FIO_OPT_C_FILE,
3378 .group = FIO_OPT_G_FILENAME,
3382 .lname = "Pre-read files",
3383 .type = FIO_OPT_BOOL,
3384 .off1 = offsetof(struct thread_options, pre_read),
3385 .help = "Pre-read files before starting official testing",
3387 .category = FIO_OPT_C_FILE,
3388 .group = FIO_OPT_G_INVALID,
3390 #ifdef FIO_HAVE_CPU_AFFINITY
3393 .lname = "CPU mask",
3394 .type = FIO_OPT_INT,
3395 .cb = str_cpumask_cb,
3396 .off1 = offsetof(struct thread_options, cpumask),
3397 .help = "CPU affinity mask",
3398 .category = FIO_OPT_C_GENERAL,
3399 .group = FIO_OPT_G_CRED,
3402 .name = "cpus_allowed",
3403 .lname = "CPUs allowed",
3404 .type = FIO_OPT_STR,
3405 .cb = str_cpus_allowed_cb,
3406 .off1 = offsetof(struct thread_options, cpumask),
3407 .help = "Set CPUs allowed",
3408 .category = FIO_OPT_C_GENERAL,
3409 .group = FIO_OPT_G_CRED,
3412 .name = "cpus_allowed_policy",
3413 .lname = "CPUs allowed distribution policy",
3414 .type = FIO_OPT_STR,
3415 .off1 = offsetof(struct thread_options, cpus_allowed_policy),
3416 .help = "Distribution policy for cpus_allowed",
3417 .parent = "cpus_allowed",
3421 .oval = FIO_CPUS_SHARED,
3422 .help = "Mask shared between threads",
3425 .oval = FIO_CPUS_SPLIT,
3426 .help = "Mask split between threads",
3429 .category = FIO_OPT_C_GENERAL,
3430 .group = FIO_OPT_G_CRED,
3435 .lname = "CPU mask",
3436 .type = FIO_OPT_UNSUPPORTED,
3437 .help = "Your platform does not support CPU affinities",
3440 .name = "cpus_allowed",
3441 .lname = "CPUs allowed",
3442 .type = FIO_OPT_UNSUPPORTED,
3443 .help = "Your platform does not support CPU affinities",
3446 .name = "cpus_allowed_policy",
3447 .lname = "CPUs allowed distribution policy",
3448 .type = FIO_OPT_UNSUPPORTED,
3449 .help = "Your platform does not support CPU affinities",
3452 #ifdef CONFIG_LIBNUMA
3454 .name = "numa_cpu_nodes",
3455 .lname = "NUMA CPU Nodes",
3456 .type = FIO_OPT_STR,
3457 .cb = str_numa_cpunodes_cb,
3458 .off1 = offsetof(struct thread_options, numa_cpunodes),
3459 .help = "NUMA CPU nodes bind",
3460 .category = FIO_OPT_C_GENERAL,
3461 .group = FIO_OPT_G_INVALID,
3464 .name = "numa_mem_policy",
3465 .lname = "NUMA Memory Policy",
3466 .type = FIO_OPT_STR,
3467 .cb = str_numa_mpol_cb,
3468 .off1 = offsetof(struct thread_options, numa_memnodes),
3469 .help = "NUMA memory policy setup",
3470 .category = FIO_OPT_C_GENERAL,
3471 .group = FIO_OPT_G_INVALID,
3475 .name = "numa_cpu_nodes",
3476 .lname = "NUMA CPU Nodes",
3477 .type = FIO_OPT_UNSUPPORTED,
3478 .help = "Build fio with libnuma-dev(el) to enable this option",
3481 .name = "numa_mem_policy",
3482 .lname = "NUMA Memory Policy",
3483 .type = FIO_OPT_UNSUPPORTED,
3484 .help = "Build fio with libnuma-dev(el) to enable this option",
3488 .name = "end_fsync",
3489 .lname = "End fsync",
3490 .type = FIO_OPT_BOOL,
3491 .off1 = offsetof(struct thread_options, end_fsync),
3492 .help = "Include fsync at the end of job",
3494 .category = FIO_OPT_C_FILE,
3495 .group = FIO_OPT_G_INVALID,
3498 .name = "fsync_on_close",
3499 .lname = "Fsync on close",
3500 .type = FIO_OPT_BOOL,
3501 .off1 = offsetof(struct thread_options, fsync_on_close),
3502 .help = "fsync files on close",
3504 .category = FIO_OPT_C_FILE,
3505 .group = FIO_OPT_G_INVALID,
3509 .lname = "Unlink file",
3510 .type = FIO_OPT_BOOL,
3511 .off1 = offsetof(struct thread_options, unlink),
3512 .help = "Unlink created files after job has completed",
3514 .category = FIO_OPT_C_FILE,
3515 .group = FIO_OPT_G_INVALID,
3518 .name = "unlink_each_loop",
3519 .lname = "Unlink file after each loop of a job",
3520 .type = FIO_OPT_BOOL,
3521 .off1 = offsetof(struct thread_options, unlink_each_loop),
3522 .help = "Unlink created files after each loop in a job has completed",
3524 .category = FIO_OPT_C_FILE,
3525 .group = FIO_OPT_G_INVALID,
3529 .lname = "Exit-all on terminate",
3530 .type = FIO_OPT_STR_SET,
3531 .cb = str_exitall_cb,
3532 .help = "Terminate all jobs when one exits",
3533 .category = FIO_OPT_C_GENERAL,
3534 .group = FIO_OPT_G_PROCESS,
3537 .name = "exitall_on_error",
3538 .lname = "Exit-all on terminate in error",
3539 .type = FIO_OPT_STR_SET,
3540 .off1 = offsetof(struct thread_options, exitall_error),
3541 .help = "Terminate all jobs when one exits in error",
3542 .category = FIO_OPT_C_GENERAL,
3543 .group = FIO_OPT_G_PROCESS,
3546 .name = "stonewall",
3547 .lname = "Wait for previous",
3548 .alias = "wait_for_previous",
3549 .type = FIO_OPT_STR_SET,
3550 .off1 = offsetof(struct thread_options, stonewall),
3551 .help = "Insert a hard barrier between this job and previous",
3552 .category = FIO_OPT_C_GENERAL,
3553 .group = FIO_OPT_G_PROCESS,
3556 .name = "new_group",
3557 .lname = "New group",
3558 .type = FIO_OPT_STR_SET,
3559 .off1 = offsetof(struct thread_options, new_group),
3560 .help = "Mark the start of a new group (for reporting)",
3561 .category = FIO_OPT_C_GENERAL,
3562 .group = FIO_OPT_G_PROCESS,
3567 .type = FIO_OPT_STR_SET,
3568 .off1 = offsetof(struct thread_options, use_thread),
3569 .help = "Use threads instead of processes",
3570 #ifdef CONFIG_NO_SHM
3574 .category = FIO_OPT_C_GENERAL,
3575 .group = FIO_OPT_G_PROCESS,
3578 .name = "per_job_logs",
3579 .lname = "Per Job Logs",
3580 .type = FIO_OPT_BOOL,
3581 .off1 = offsetof(struct thread_options, per_job_logs),
3582 .help = "Include job number in generated log files or not",
3584 .category = FIO_OPT_C_LOG,
3585 .group = FIO_OPT_G_INVALID,
3588 .name = "write_bw_log",
3589 .lname = "Write bandwidth log",
3590 .type = FIO_OPT_STR_STORE,
3591 .off1 = offsetof(struct thread_options, bw_log_file),
3592 .help = "Write log of bandwidth during run",
3593 .category = FIO_OPT_C_LOG,
3594 .group = FIO_OPT_G_INVALID,
3597 .name = "write_lat_log",
3598 .lname = "Write latency log",
3599 .type = FIO_OPT_STR_STORE,
3600 .off1 = offsetof(struct thread_options, lat_log_file),
3601 .help = "Write log of latency during run",
3602 .category = FIO_OPT_C_LOG,
3603 .group = FIO_OPT_G_INVALID,
3606 .name = "write_iops_log",
3607 .lname = "Write IOPS log",
3608 .type = FIO_OPT_STR_STORE,
3609 .off1 = offsetof(struct thread_options, iops_log_file),
3610 .help = "Write log of IOPS during run",
3611 .category = FIO_OPT_C_LOG,
3612 .group = FIO_OPT_G_INVALID,
3615 .name = "log_avg_msec",
3616 .lname = "Log averaging (msec)",
3617 .type = FIO_OPT_INT,
3618 .off1 = offsetof(struct thread_options, log_avg_msec),
3619 .help = "Average bw/iops/lat logs over this period of time",
3621 .category = FIO_OPT_C_LOG,
3622 .group = FIO_OPT_G_INVALID,
3625 .name = "log_hist_msec",
3626 .lname = "Log histograms (msec)",
3627 .type = FIO_OPT_INT,
3628 .off1 = offsetof(struct thread_options, log_hist_msec),
3629 .help = "Dump completion latency histograms at frequency of this time value",
3631 .category = FIO_OPT_C_LOG,
3632 .group = FIO_OPT_G_INVALID,
3635 .name = "log_hist_coarseness",
3636 .lname = "Histogram logs coarseness",
3637 .type = FIO_OPT_INT,
3638 .off1 = offsetof(struct thread_options, log_hist_coarseness),
3639 .help = "Integer in range [0,6]. Higher coarseness outputs"
3640 " fewer histogram bins per sample. The number of bins for"
3641 " these are [1216, 608, 304, 152, 76, 38, 19] respectively.",
3643 .category = FIO_OPT_C_LOG,
3644 .group = FIO_OPT_G_INVALID,
3647 .name = "write_hist_log",
3648 .lname = "Write latency histogram logs",
3649 .type = FIO_OPT_STR_STORE,
3650 .off1 = offsetof(struct thread_options, hist_log_file),
3651 .help = "Write log of latency histograms during run",
3652 .category = FIO_OPT_C_LOG,
3653 .group = FIO_OPT_G_INVALID,
3656 .name = "log_max_value",
3657 .lname = "Log maximum instead of average",
3658 .type = FIO_OPT_BOOL,
3659 .off1 = offsetof(struct thread_options, log_max),
3660 .help = "Log max sample in a window instead of average",
3662 .category = FIO_OPT_C_LOG,
3663 .group = FIO_OPT_G_INVALID,
3666 .name = "log_offset",
3667 .lname = "Log offset of IO",
3668 .type = FIO_OPT_BOOL,
3669 .off1 = offsetof(struct thread_options, log_offset),
3670 .help = "Include offset of IO for each log entry",
3672 .category = FIO_OPT_C_LOG,
3673 .group = FIO_OPT_G_INVALID,
3677 .name = "log_compression",
3678 .lname = "Log compression",
3679 .type = FIO_OPT_INT,
3680 .off1 = offsetof(struct thread_options, log_gz),
3681 .help = "Log in compressed chunks of this size",
3683 .maxval = 512 * 1024 * 1024ULL,
3684 .category = FIO_OPT_C_LOG,
3685 .group = FIO_OPT_G_INVALID,
3687 #ifdef FIO_HAVE_CPU_AFFINITY
3689 .name = "log_compression_cpus",
3690 .lname = "Log Compression CPUs",
3691 .type = FIO_OPT_STR,
3692 .cb = str_log_cpus_allowed_cb,
3693 .off1 = offsetof(struct thread_options, log_gz_cpumask),
3694 .parent = "log_compression",
3695 .help = "Limit log compression to these CPUs",
3696 .category = FIO_OPT_C_LOG,
3697 .group = FIO_OPT_G_INVALID,
3701 .name = "log_compression_cpus",
3702 .lname = "Log Compression CPUs",
3703 .type = FIO_OPT_UNSUPPORTED,
3704 .help = "Your platform does not support CPU affinities",
3708 .name = "log_store_compressed",
3709 .lname = "Log store compressed",
3710 .type = FIO_OPT_BOOL,
3711 .off1 = offsetof(struct thread_options, log_gz_store),
3712 .help = "Store logs in a compressed format",
3713 .category = FIO_OPT_C_LOG,
3714 .group = FIO_OPT_G_INVALID,
3718 .name = "log_compression",
3719 .lname = "Log compression",
3720 .type = FIO_OPT_UNSUPPORTED,
3721 .help = "Install libz-dev(el) to get compression support",
3724 .name = "log_store_compressed",
3725 .lname = "Log store compressed",
3726 .type = FIO_OPT_UNSUPPORTED,
3727 .help = "Install libz-dev(el) to get compression support",
3731 .name = "block_error_percentiles",
3732 .lname = "Block error percentiles",
3733 .type = FIO_OPT_BOOL,
3734 .off1 = offsetof(struct thread_options, block_error_hist),
3735 .help = "Record trim block errors and make a histogram",
3737 .category = FIO_OPT_C_LOG,
3738 .group = FIO_OPT_G_INVALID,
3741 .name = "bwavgtime",
3742 .lname = "Bandwidth average time",
3743 .type = FIO_OPT_INT,
3744 .off1 = offsetof(struct thread_options, bw_avg_time),
3745 .help = "Time window over which to calculate bandwidth"
3748 .parent = "write_bw_log",
3751 .category = FIO_OPT_C_LOG,
3752 .group = FIO_OPT_G_INVALID,
3755 .name = "iopsavgtime",
3756 .lname = "IOPS average time",
3757 .type = FIO_OPT_INT,
3758 .off1 = offsetof(struct thread_options, iops_avg_time),
3759 .help = "Time window over which to calculate IOPS (msec)",
3761 .parent = "write_iops_log",
3764 .category = FIO_OPT_C_LOG,
3765 .group = FIO_OPT_G_INVALID,
3768 .name = "group_reporting",
3769 .lname = "Group reporting",
3770 .type = FIO_OPT_STR_SET,
3771 .off1 = offsetof(struct thread_options, group_reporting),
3772 .help = "Do reporting on a per-group basis",
3773 .category = FIO_OPT_C_STAT,
3774 .group = FIO_OPT_G_INVALID,
3777 .name = "zero_buffers",
3778 .lname = "Zero I/O buffers",
3779 .type = FIO_OPT_STR_SET,
3780 .off1 = offsetof(struct thread_options, zero_buffers),
3781 .help = "Init IO buffers to all zeroes",
3782 .category = FIO_OPT_C_IO,
3783 .group = FIO_OPT_G_IO_BUF,
3786 .name = "refill_buffers",
3787 .lname = "Refill I/O buffers",
3788 .type = FIO_OPT_STR_SET,
3789 .off1 = offsetof(struct thread_options, refill_buffers),
3790 .help = "Refill IO buffers on every IO submit",
3791 .category = FIO_OPT_C_IO,
3792 .group = FIO_OPT_G_IO_BUF,
3795 .name = "scramble_buffers",
3796 .lname = "Scramble I/O buffers",
3797 .type = FIO_OPT_BOOL,
3798 .off1 = offsetof(struct thread_options, scramble_buffers),
3799 .help = "Slightly scramble buffers on every IO submit",
3801 .category = FIO_OPT_C_IO,
3802 .group = FIO_OPT_G_IO_BUF,
3805 .name = "buffer_pattern",
3806 .lname = "Buffer pattern",
3807 .type = FIO_OPT_STR,
3808 .cb = str_buffer_pattern_cb,
3809 .off1 = offsetof(struct thread_options, buffer_pattern),
3810 .help = "Fill pattern for IO buffers",
3811 .category = FIO_OPT_C_IO,
3812 .group = FIO_OPT_G_IO_BUF,
3815 .name = "buffer_compress_percentage",
3816 .lname = "Buffer compression percentage",
3817 .type = FIO_OPT_INT,
3818 .cb = str_buffer_compress_cb,
3819 .off1 = offsetof(struct thread_options, compress_percentage),
3822 .help = "How compressible the buffer is (approximately)",
3824 .category = FIO_OPT_C_IO,
3825 .group = FIO_OPT_G_IO_BUF,
3828 .name = "buffer_compress_chunk",
3829 .lname = "Buffer compression chunk size",
3830 .type = FIO_OPT_INT,
3831 .off1 = offsetof(struct thread_options, compress_chunk),
3832 .parent = "buffer_compress_percentage",
3834 .help = "Size of compressible region in buffer",
3836 .category = FIO_OPT_C_IO,
3837 .group = FIO_OPT_G_IO_BUF,
3840 .name = "dedupe_percentage",
3841 .lname = "Dedupe percentage",
3842 .type = FIO_OPT_INT,
3843 .cb = str_dedupe_cb,
3844 .off1 = offsetof(struct thread_options, dedupe_percentage),
3847 .help = "Percentage of buffers that are dedupable",
3849 .category = FIO_OPT_C_IO,
3850 .group = FIO_OPT_G_IO_BUF,
3853 .name = "clat_percentiles",
3854 .lname = "Completion latency percentiles",
3855 .type = FIO_OPT_BOOL,
3856 .off1 = offsetof(struct thread_options, clat_percentiles),
3857 .help = "Enable the reporting of completion latency percentiles",
3859 .category = FIO_OPT_C_STAT,
3860 .group = FIO_OPT_G_INVALID,
3863 .name = "percentile_list",
3864 .lname = "Percentile list",
3865 .type = FIO_OPT_FLOAT_LIST,
3866 .off1 = offsetof(struct thread_options, percentile_list),
3867 .off2 = offsetof(struct thread_options, percentile_precision),
3868 .help = "Specify a custom list of percentiles to report for "
3869 "completion latency and block errors",
3870 .def = "1:5:10:20:30:40:50:60:70:80:90:95:99:99.5:99.9:99.95:99.99",
3871 .maxlen = FIO_IO_U_LIST_MAX_LEN,
3874 .category = FIO_OPT_C_STAT,
3875 .group = FIO_OPT_G_INVALID,
3878 #ifdef FIO_HAVE_DISK_UTIL
3880 .name = "disk_util",
3881 .lname = "Disk utilization",
3882 .type = FIO_OPT_BOOL,
3883 .off1 = offsetof(struct thread_options, do_disk_util),
3884 .help = "Log disk utilization statistics",
3886 .category = FIO_OPT_C_STAT,
3887 .group = FIO_OPT_G_INVALID,
3891 .name = "disk_util",
3892 .lname = "Disk utilization",
3893 .type = FIO_OPT_UNSUPPORTED,
3894 .help = "Your platform does not support disk utilization",
3898 .name = "gtod_reduce",
3899 .lname = "Reduce gettimeofday() calls",
3900 .type = FIO_OPT_BOOL,
3901 .help = "Greatly reduce number of gettimeofday() calls",
3902 .cb = str_gtod_reduce_cb,
3905 .category = FIO_OPT_C_STAT,
3906 .group = FIO_OPT_G_INVALID,
3909 .name = "disable_lat",
3910 .lname = "Disable all latency stats",
3911 .type = FIO_OPT_BOOL,
3912 .off1 = offsetof(struct thread_options, disable_lat),
3913 .help = "Disable latency numbers",
3914 .parent = "gtod_reduce",
3917 .category = FIO_OPT_C_STAT,
3918 .group = FIO_OPT_G_INVALID,
3921 .name = "disable_clat",
3922 .lname = "Disable completion latency stats",
3923 .type = FIO_OPT_BOOL,
3924 .off1 = offsetof(struct thread_options, disable_clat),
3925 .help = "Disable completion latency numbers",
3926 .parent = "gtod_reduce",
3929 .category = FIO_OPT_C_STAT,
3930 .group = FIO_OPT_G_INVALID,
3933 .name = "disable_slat",
3934 .lname = "Disable submission latency stats",
3935 .type = FIO_OPT_BOOL,
3936 .off1 = offsetof(struct thread_options, disable_slat),
3937 .help = "Disable submission latency numbers",
3938 .parent = "gtod_reduce",
3941 .category = FIO_OPT_C_STAT,
3942 .group = FIO_OPT_G_INVALID,
3945 .name = "disable_bw_measurement",
3946 .lname = "Disable bandwidth stats",
3947 .type = FIO_OPT_BOOL,
3948 .off1 = offsetof(struct thread_options, disable_bw),
3949 .help = "Disable bandwidth logging",
3950 .parent = "gtod_reduce",
3953 .category = FIO_OPT_C_STAT,
3954 .group = FIO_OPT_G_INVALID,
3958 .lname = "Dedicated gettimeofday() CPU",
3959 .type = FIO_OPT_INT,
3960 .off1 = offsetof(struct thread_options, gtod_cpu),
3961 .help = "Set up dedicated gettimeofday() thread on this CPU",
3962 .verify = gtod_cpu_verify,
3963 .category = FIO_OPT_C_GENERAL,
3964 .group = FIO_OPT_G_CLOCK,
3967 .name = "unified_rw_reporting",
3968 .lname = "Unified RW Reporting",
3969 .type = FIO_OPT_BOOL,
3970 .off1 = offsetof(struct thread_options, unified_rw_rep),
3971 .help = "Unify reporting across data direction",
3973 .category = FIO_OPT_C_GENERAL,
3974 .group = FIO_OPT_G_INVALID,
3977 .name = "continue_on_error",
3978 .lname = "Continue on error",
3979 .type = FIO_OPT_STR,
3980 .off1 = offsetof(struct thread_options, continue_on_error),
3981 .help = "Continue on non-fatal errors during IO",
3983 .category = FIO_OPT_C_GENERAL,
3984 .group = FIO_OPT_G_ERR,
3987 .oval = ERROR_TYPE_NONE,
3988 .help = "Exit when an error is encountered",
3991 .oval = ERROR_TYPE_READ,
3992 .help = "Continue on read errors only",
3995 .oval = ERROR_TYPE_WRITE,
3996 .help = "Continue on write errors only",
3999 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
4000 .help = "Continue on any IO errors",
4003 .oval = ERROR_TYPE_VERIFY,
4004 .help = "Continue on verify errors only",
4007 .oval = ERROR_TYPE_ANY,
4008 .help = "Continue on all io and verify errors",
4011 .oval = ERROR_TYPE_NONE,
4012 .help = "Alias for 'none'",
4015 .oval = ERROR_TYPE_ANY,
4016 .help = "Alias for 'all'",
4021 .name = "ignore_error",
4022 .lname = "Ignore Error",
4023 .type = FIO_OPT_STR,
4024 .cb = str_ignore_error_cb,
4025 .off1 = offsetof(struct thread_options, ignore_error_nr),
4026 .help = "Set a specific list of errors to ignore",
4028 .category = FIO_OPT_C_GENERAL,
4029 .group = FIO_OPT_G_ERR,
4032 .name = "error_dump",
4033 .lname = "Error Dump",
4034 .type = FIO_OPT_BOOL,
4035 .off1 = offsetof(struct thread_options, error_dump),
4037 .help = "Dump info on each error",
4038 .category = FIO_OPT_C_GENERAL,
4039 .group = FIO_OPT_G_ERR,
4044 .type = FIO_OPT_STR_STORE,
4045 .off1 = offsetof(struct thread_options, profile),
4046 .help = "Select a specific builtin performance test",
4047 .category = FIO_OPT_C_PROFILE,
4048 .group = FIO_OPT_G_INVALID,
4053 .type = FIO_OPT_STR_STORE,
4054 .off1 = offsetof(struct thread_options, cgroup),
4055 .help = "Add job to cgroup of this name",
4056 .category = FIO_OPT_C_GENERAL,
4057 .group = FIO_OPT_G_CGROUP,
4060 .name = "cgroup_nodelete",
4061 .lname = "Cgroup no-delete",
4062 .type = FIO_OPT_BOOL,
4063 .off1 = offsetof(struct thread_options, cgroup_nodelete),
4064 .help = "Do not delete cgroups after job completion",
4067 .category = FIO_OPT_C_GENERAL,
4068 .group = FIO_OPT_G_CGROUP,
4071 .name = "cgroup_weight",
4072 .lname = "Cgroup weight",
4073 .type = FIO_OPT_INT,
4074 .off1 = offsetof(struct thread_options, cgroup_weight),
4075 .help = "Use given weight for cgroup",
4079 .category = FIO_OPT_C_GENERAL,
4080 .group = FIO_OPT_G_CGROUP,
4085 .type = FIO_OPT_INT,
4086 .off1 = offsetof(struct thread_options, uid),
4087 .help = "Run job with this user ID",
4088 .category = FIO_OPT_C_GENERAL,
4089 .group = FIO_OPT_G_CRED,
4093 .lname = "Group ID",
4094 .type = FIO_OPT_INT,
4095 .off1 = offsetof(struct thread_options, gid),
4096 .help = "Run job with this group ID",
4097 .category = FIO_OPT_C_GENERAL,
4098 .group = FIO_OPT_G_CRED,
4103 .type = FIO_OPT_INT,
4104 .off1 = offsetof(struct thread_options, kb_base),
4110 .help = "Use 1024 as the K base",
4114 .help = "Use 1000 as the K base",
4117 .help = "How many bytes per KB for reporting (1000 or 1024)",
4118 .category = FIO_OPT_C_GENERAL,
4119 .group = FIO_OPT_G_INVALID,
4122 .name = "unit_base",
4123 .lname = "Base unit for reporting (Bits or Bytes)",
4124 .type = FIO_OPT_INT,
4125 .off1 = offsetof(struct thread_options, unit_base),
4130 .help = "Auto-detect",
4134 .help = "Normal (byte based)",
4138 .help = "Bit based",
4141 .help = "Bit multiple of result summary data (8 for byte, 1 for bit)",
4142 .category = FIO_OPT_C_GENERAL,
4143 .group = FIO_OPT_G_INVALID,
4146 .name = "hugepage-size",
4147 .lname = "Hugepage size",
4148 .type = FIO_OPT_INT,
4149 .off1 = offsetof(struct thread_options, hugepage_size),
4150 .help = "When using hugepages, specify size of each page",
4151 .def = __fio_stringify(FIO_HUGE_PAGE),
4152 .interval = 1024 * 1024,
4153 .category = FIO_OPT_C_GENERAL,
4154 .group = FIO_OPT_G_INVALID,
4158 .lname = "I/O flow ID",
4159 .type = FIO_OPT_INT,
4160 .off1 = offsetof(struct thread_options, flow_id),
4161 .help = "The flow index ID to use",
4163 .category = FIO_OPT_C_IO,
4164 .group = FIO_OPT_G_IO_FLOW,
4168 .lname = "I/O flow weight",
4169 .type = FIO_OPT_INT,
4170 .off1 = offsetof(struct thread_options, flow),
4171 .help = "Weight for flow control of this job",
4172 .parent = "flow_id",
4175 .category = FIO_OPT_C_IO,
4176 .group = FIO_OPT_G_IO_FLOW,
4179 .name = "flow_watermark",
4180 .lname = "I/O flow watermark",
4181 .type = FIO_OPT_INT,
4182 .off1 = offsetof(struct thread_options, flow_watermark),
4183 .help = "High watermark for flow control. This option"
4184 " should be set to the same value for all threads"
4185 " with non-zero flow.",
4186 .parent = "flow_id",
4189 .category = FIO_OPT_C_IO,
4190 .group = FIO_OPT_G_IO_FLOW,
4193 .name = "flow_sleep",
4194 .lname = "I/O flow sleep",
4195 .type = FIO_OPT_INT,
4196 .off1 = offsetof(struct thread_options, flow_sleep),
4197 .help = "How many microseconds to sleep after being held"
4198 " back by the flow control mechanism",
4199 .parent = "flow_id",
4202 .category = FIO_OPT_C_IO,
4203 .group = FIO_OPT_G_IO_FLOW,
4207 .lname = "Skip operations against bad blocks",
4208 .type = FIO_OPT_BOOL,
4209 .off1 = offsetof(struct thread_options, skip_bad),
4210 .help = "Skip operations against known bad blocks.",
4213 .category = FIO_OPT_C_IO,
4214 .group = FIO_OPT_G_MTD,
4217 .name = "steadystate",
4218 .lname = "Steady state threshold",
4220 .type = FIO_OPT_STR,
4221 .off1 = offsetof(struct thread_options, ss),
4222 .cb = str_steadystate_cb,
4223 .help = "Define the criterion and limit to judge when a job has reached steady state",
4224 .def = "iops_slope:0.01%",
4227 .oval = FIO_STEADYSTATE_IOPS,
4228 .help = "maximum mean deviation of IOPS measurements",
4230 { .ival = "iops_slope",
4231 .oval = FIO_STEADYSTATE_IOPS_SLOPE,
4232 .help = "slope calculated from IOPS measurements",
4235 .oval = FIO_STEADYSTATE_BW,
4236 .help = "maximum mean deviation of bandwidth measurements",
4240 .oval = FIO_STEADYSTATE_BW_SLOPE,
4241 .help = "slope calculated from bandwidth measurements",
4244 .category = FIO_OPT_C_GENERAL,
4245 .group = FIO_OPT_G_RUNTIME,
4248 .name = "steadystate_duration",
4249 .lname = "Steady state duration",
4251 .type = FIO_OPT_STR_VAL_TIME,
4252 .off1 = offsetof(struct thread_options, ss_dur),
4253 .help = "Stop workload upon attaining steady state for specified duration",
4257 .category = FIO_OPT_C_GENERAL,
4258 .group = FIO_OPT_G_RUNTIME,
4261 .name = "steadystate_ramp_time",
4262 .lname = "Steady state ramp time",
4264 .type = FIO_OPT_STR_VAL_TIME,
4265 .off1 = offsetof(struct thread_options, ss_ramp_time),
4266 .help = "Delay before initiation of data collection for steady state job termination testing",
4270 .category = FIO_OPT_C_GENERAL,
4271 .group = FIO_OPT_G_RUNTIME,
4278 static void add_to_lopt(struct option *lopt, struct fio_option *o,
4279 const char *name, int val)
4281 lopt->name = (char *) name;
4283 if (o->type == FIO_OPT_STR_SET)
4284 lopt->has_arg = optional_argument;
4286 lopt->has_arg = required_argument;
4289 static void options_to_lopts(struct fio_option *opts,
4290 struct option *long_options,
4291 int i, int option_type)
4293 struct fio_option *o = &opts[0];
4295 add_to_lopt(&long_options[i], o, o->name, option_type);
4298 add_to_lopt(&long_options[i], o, o->alias, option_type);
4303 assert(i < FIO_NR_OPTIONS);
4307 void fio_options_set_ioengine_opts(struct option *long_options,
4308 struct thread_data *td)
4313 while (long_options[i].name) {
4314 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
4315 memset(&long_options[i], 0, sizeof(*long_options));
4322 * Just clear out the prior ioengine options.
4327 options_to_lopts(td->io_ops->options, long_options, i,
4328 FIO_GETOPT_IOENGINE);
4331 void fio_options_dup_and_init(struct option *long_options)
4335 options_init(fio_options);
4338 while (long_options[i].name)
4341 options_to_lopts(fio_options, long_options, i, FIO_GETOPT_JOB);
4344 struct fio_keyword {
4350 static struct fio_keyword fio_keywords[] = {
4352 .word = "$pagesize",
4353 .desc = "Page size in the system",
4356 .word = "$mb_memory",
4357 .desc = "Megabytes of memory online",
4361 .desc = "Number of CPUs online in the system",
4368 void fio_keywords_exit(void)
4370 struct fio_keyword *kw;
4372 kw = &fio_keywords[0];
4380 void fio_keywords_init(void)
4382 unsigned long long mb_memory;
4386 sprintf(buf, "%lu", (unsigned long) page_size);
4387 fio_keywords[0].replace = strdup(buf);
4389 mb_memory = os_phys_mem() / (1024 * 1024);
4390 sprintf(buf, "%llu", mb_memory);
4391 fio_keywords[1].replace = strdup(buf);
4394 sprintf(buf, "%lu", l);
4395 fio_keywords[2].replace = strdup(buf);
4400 static char *bc_calc(char *str)
4402 char buf[128], *tmp;
4407 * No math, just return string
4409 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
4410 !strchr(str, '/')) || strchr(str, '\''))
4414 * Split option from value, we only need to calculate the value
4416 tmp = strchr(str, '=');
4423 * Prevent buffer overflows; such a case isn't reasonable anyway
4425 if (strlen(str) >= 128 || strlen(tmp) > 100)
4428 sprintf(buf, "which %s > /dev/null", BC_APP);
4430 log_err("fio: bc is needed for performing math\n");
4434 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
4435 f = popen(buf, "r");
4439 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
4446 buf[(tmp - str) + ret - 1] = '\0';
4447 memcpy(buf, str, tmp - str);
4453 * Return a copy of the input string with substrings of the form ${VARNAME}
4454 * substituted with the value of the environment variable VARNAME. The
4455 * substitution always occurs, even if VARNAME is empty or the corresponding
4456 * environment variable undefined.
4458 static char *option_dup_subs(const char *opt)
4460 char out[OPT_LEN_MAX+1];
4461 char in[OPT_LEN_MAX+1];
4464 char *ch1, *ch2, *env;
4465 ssize_t nchr = OPT_LEN_MAX;
4468 if (strlen(opt) + 1 > OPT_LEN_MAX) {
4469 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
4473 in[OPT_LEN_MAX] = '\0';
4474 strncpy(in, opt, OPT_LEN_MAX);
4476 while (*inptr && nchr > 0) {
4477 if (inptr[0] == '$' && inptr[1] == '{') {
4478 ch2 = strchr(inptr, '}');
4479 if (ch2 && inptr+1 < ch2) {
4486 envlen = strlen(env);
4487 if (envlen <= nchr) {
4488 memcpy(outptr, env, envlen);
4498 *outptr++ = *inptr++;
4507 * Look for reserved variable names and replace them with real values
4509 static char *fio_keyword_replace(char *opt)
4515 for (i = 0; fio_keywords[i].word != NULL; i++) {
4516 struct fio_keyword *kw = &fio_keywords[i];
4518 while ((s = strstr(opt, kw->word)) != NULL) {
4519 char *new = malloc(strlen(opt) + 1);
4525 * Copy part of the string before the keyword and
4526 * sprintf() the replacement after it.
4528 memcpy(new, opt, olen);
4529 len = sprintf(new + olen, "%s", kw->replace);
4532 * If there's more in the original string, copy that
4535 opt += strlen(kw->word) + olen;
4537 memcpy(new + olen + len, opt, opt - o_org - 1);
4540 * replace opt and free the old opt
4550 * Check for potential math and invoke bc, if possible
4558 static char **dup_and_sub_options(char **opts, int num_opts)
4561 char **opts_copy = malloc(num_opts * sizeof(*opts));
4562 for (i = 0; i < num_opts; i++) {
4563 opts_copy[i] = option_dup_subs(opts[i]);
4566 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
4571 static void show_closest_option(const char *opt)
4573 int best_option, best_distance;
4582 while (name[i] != '\0' && name[i] != '=')
4587 best_distance = INT_MAX;
4589 while (fio_options[i].name) {
4590 distance = string_distance(name, fio_options[i].name);
4591 if (distance < best_distance) {
4592 best_distance = distance;
4598 if (best_option != -1 && string_distance_ok(name, best_distance) &&
4599 fio_options[best_option].type != FIO_OPT_UNSUPPORTED)
4600 log_err("Did you mean %s?\n", fio_options[best_option].name);
4605 int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
4607 int i, ret, unknown;
4610 sort_options(opts, fio_options, num_opts);
4611 opts_copy = dup_and_sub_options(opts, num_opts);
4613 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
4614 struct fio_option *o;
4615 int newret = parse_option(opts_copy[i], opts[i], fio_options,
4616 &o, &td->o, &td->opt_list);
4619 fio_option_mark_set(&td->o, o);
4627 opts_copy[i] = NULL;
4634 ret |= ioengine_load(td);
4636 sort_options(opts_copy, td->io_ops->options, num_opts);
4639 for (i = 0; i < num_opts; i++) {
4640 struct fio_option *o = NULL;
4647 newret = parse_option(opts_copy[i], opts[i],
4648 td->io_ops->options, &o,
4649 td->eo, &td->opt_list);
4653 log_err("Bad option <%s>\n", opts[i]);
4654 show_closest_option(opts[i]);
4657 opts_copy[i] = NULL;
4665 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
4669 ret = parse_cmd_option(opt, val, fio_options, &td->o, &td->opt_list);
4671 struct fio_option *o;
4673 o = find_option(fio_options, opt);
4675 fio_option_mark_set(&td->o, o);
4681 int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
4684 return parse_cmd_option(opt, val, td->io_ops->options, td->eo,
4688 void fio_fill_default_options(struct thread_data *td)
4690 td->o.magic = OPT_MAGIC;
4691 fill_default_options(&td->o, fio_options);
4694 int fio_show_option_help(const char *opt)
4696 return show_cmd_help(fio_options, opt);
4699 void options_mem_dupe(void *data, struct fio_option *options)
4701 struct fio_option *o;
4704 for (o = &options[0]; o->name; o++) {
4705 if (o->type != FIO_OPT_STR_STORE)
4708 ptr = td_var(data, o, o->off1);
4710 *ptr = strdup(*ptr);
4715 * dupe FIO_OPT_STR_STORE options
4717 void fio_options_mem_dupe(struct thread_data *td)
4719 options_mem_dupe(&td->o, fio_options);
4721 if (td->eo && td->io_ops) {
4722 void *oldeo = td->eo;
4724 td->eo = malloc(td->io_ops->option_struct_size);
4725 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
4726 options_mem_dupe(td->eo, td->io_ops->options);
4730 unsigned int fio_get_kb_base(void *data)
4732 struct thread_data *td = cb_data_to_td(data);
4733 struct thread_options *o = &td->o;
4734 unsigned int kb_base = 0;
4737 * This is a hack... For private options, *data is not holding
4738 * a pointer to the thread_options, but to private data. This means
4739 * we can't safely dereference it, but magic is first so mem wise
4740 * it is valid. But this also means that if the job first sets
4741 * kb_base and expects that to be honored by private options,
4742 * it will be disappointed. We will return the global default
4745 if (o && o->magic == OPT_MAGIC)
4746 kb_base = o->kb_base;
4753 int add_option(struct fio_option *o)
4755 struct fio_option *__o;
4764 if (opt_index + 1 == FIO_MAX_OPTS) {
4765 log_err("fio: FIO_MAX_OPTS is too small\n");
4769 memcpy(&fio_options[opt_index], o, sizeof(*o));
4770 fio_options[opt_index + 1].name = NULL;
4774 void invalidate_profile_options(const char *prof_name)
4776 struct fio_option *o;
4780 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
4781 o->type = FIO_OPT_INVALID;
4782 o->prof_name = NULL;
4788 void add_opt_posval(const char *optname, const char *ival, const char *help)
4790 struct fio_option *o;
4793 o = find_option(fio_options, optname);
4797 for (i = 0; i < PARSE_MAX_VP; i++) {
4798 if (o->posval[i].ival)
4801 o->posval[i].ival = ival;
4802 o->posval[i].help = help;
4807 void del_opt_posval(const char *optname, const char *ival)
4809 struct fio_option *o;
4812 o = find_option(fio_options, optname);
4816 for (i = 0; i < PARSE_MAX_VP; i++) {
4817 if (!o->posval[i].ival)
4819 if (strcmp(o->posval[i].ival, ival))
4822 o->posval[i].ival = NULL;
4823 o->posval[i].help = NULL;
4827 void fio_options_free(struct thread_data *td)
4829 options_free(fio_options, td);
4830 if (td->eo && td->io_ops && td->io_ops->options) {
4831 options_free(td->io_ops->options, td->eo);
4837 struct fio_option *fio_option_find(const char *name)
4839 return find_option(fio_options, name);
4842 static struct fio_option *find_next_opt(struct thread_options *o,
4843 struct fio_option *from,
4846 struct fio_option *opt;
4849 from = &fio_options[0];
4855 if (off1 == from->off1) {
4860 } while (from->name);
4865 static int opt_is_set(struct thread_options *o, struct fio_option *opt)
4867 unsigned int opt_off, index, offset;
4869 opt_off = opt - &fio_options[0];
4870 index = opt_off / (8 * sizeof(uint64_t));
4871 offset = opt_off & ((8 * sizeof(uint64_t)) - 1);
4872 return (o->set_options[index] & ((uint64_t)1 << offset)) != 0;
4875 bool __fio_option_is_set(struct thread_options *o, unsigned int off1)
4877 struct fio_option *opt, *next;
4880 while ((opt = find_next_opt(o, next, off1)) != NULL) {
4881 if (opt_is_set(o, opt))
4890 void fio_option_mark_set(struct thread_options *o, struct fio_option *opt)
4892 unsigned int opt_off, index, offset;
4894 opt_off = opt - &fio_options[0];
4895 index = opt_off / (8 * sizeof(uint64_t));
4896 offset = opt_off & ((8 * sizeof(uint64_t)) - 1);
4897 o->set_options[index] |= (uint64_t)1 << offset;