11 #include <netinet/in.h>
17 #include "lib/pattern.h"
21 char client_sockaddr_str[INET6_ADDRSTRLEN] = { 0 };
23 #define cb_data_to_td(data) container_of(data, struct thread_data, o)
25 static struct pattern_fmt_desc fmt_desc[] = {
28 .len = FIELD_SIZE(struct io_u *, offset),
29 .paste = paste_blockoff
34 * Check if mmap/mmaphuge has a :/foo/bar/file at the end. If so, return that.
36 static char *get_opt_postfix(const char *str)
38 char *p = strstr(str, ":");
44 strip_blank_front(&p);
49 static int bs_cmp(const void *p1, const void *p2)
51 const struct bssplit *bsp1 = p1;
52 const struct bssplit *bsp2 = p2;
54 return (int) bsp1->perc - (int) bsp2->perc;
59 unsigned int val1[100];
60 unsigned int val2[100];
63 static int split_parse_ddir(struct thread_options *o, struct split *split,
64 enum fio_ddir ddir, char *str)
73 while ((fname = strsep(&str, ":")) != NULL) {
79 perc_str = strstr(fname, "/");
83 perc = atoi(perc_str);
91 if (str_to_decimal(fname, &val, 1, o, 0, 0)) {
92 log_err("fio: bssplit conversion failed\n");
97 split->val2[i] = perc;
107 static int bssplit_ddir(struct thread_options *o, enum fio_ddir ddir, char *str)
109 unsigned int i, perc, perc_missing;
110 unsigned int max_bs, min_bs;
113 memset(&split, 0, sizeof(split));
115 if (split_parse_ddir(o, &split, ddir, str))
122 o->bssplit[ddir] = malloc(split.nr * sizeof(struct bssplit));
123 o->bssplit_nr[ddir] = split.nr;
124 for (i = 0; i < split.nr; i++) {
125 if (split.val1[i] > max_bs)
126 max_bs = split.val1[i];
127 if (split.val1[i] < min_bs)
128 min_bs = split.val1[i];
130 o->bssplit[ddir][i].bs = split.val1[i];
131 o->bssplit[ddir][i].perc =split.val2[i];
135 * Now check if the percentages add up, and how much is missing
137 perc = perc_missing = 0;
138 for (i = 0; i < o->bssplit_nr[ddir]; i++) {
139 struct bssplit *bsp = &o->bssplit[ddir][i];
141 if (bsp->perc == -1U)
147 if (perc > 100 && perc_missing > 1) {
148 log_err("fio: bssplit percentages add to more than 100%%\n");
149 free(o->bssplit[ddir]);
150 o->bssplit[ddir] = NULL;
155 * If values didn't have a percentage set, divide the remains between
159 if (perc_missing == 1 && o->bssplit_nr[ddir] == 1)
161 for (i = 0; i < o->bssplit_nr[ddir]; i++) {
162 struct bssplit *bsp = &o->bssplit[ddir][i];
164 if (bsp->perc == -1U)
165 bsp->perc = (100 - perc) / perc_missing;
169 o->min_bs[ddir] = min_bs;
170 o->max_bs[ddir] = max_bs;
173 * now sort based on percentages, for ease of lookup
175 qsort(o->bssplit[ddir], o->bssplit_nr[ddir], sizeof(struct bssplit), bs_cmp);
179 typedef int (split_parse_fn)(struct thread_options *, enum fio_ddir, char *);
181 static int str_split_parse(struct thread_data *td, char *str, split_parse_fn *fn)
186 odir = strchr(str, ',');
188 ddir = strchr(odir + 1, ',');
190 ret = fn(&td->o, DDIR_TRIM, ddir + 1);
196 op = strdup(odir + 1);
197 ret = fn(&td->o, DDIR_TRIM, op);
202 ret = fn(&td->o, DDIR_WRITE, odir + 1);
205 ret = fn(&td->o, DDIR_READ, str);
211 ret = fn(&td->o, DDIR_WRITE, op);
216 ret = fn(&td->o, DDIR_TRIM, op);
220 ret = fn(&td->o, DDIR_READ, str);
226 static int str_bssplit_cb(void *data, const char *input)
228 struct thread_data *td = cb_data_to_td(data);
232 p = str = strdup(input);
234 strip_blank_front(&str);
235 strip_blank_end(str);
237 ret = str_split_parse(td, str, bssplit_ddir);
239 if (parse_dryrun()) {
242 for (i = 0; i < DDIR_RWDIR_CNT; i++) {
243 free(td->o.bssplit[i]);
244 td->o.bssplit[i] = NULL;
245 td->o.bssplit_nr[i] = 0;
253 static int str2error(char *str)
255 const char *err[] = { "EPERM", "ENOENT", "ESRCH", "EINTR", "EIO",
256 "ENXIO", "E2BIG", "ENOEXEC", "EBADF",
257 "ECHILD", "EAGAIN", "ENOMEM", "EACCES",
258 "EFAULT", "ENOTBLK", "EBUSY", "EEXIST",
259 "EXDEV", "ENODEV", "ENOTDIR", "EISDIR",
260 "EINVAL", "ENFILE", "EMFILE", "ENOTTY",
261 "ETXTBSY","EFBIG", "ENOSPC", "ESPIPE",
262 "EROFS","EMLINK", "EPIPE", "EDOM", "ERANGE" };
263 int i = 0, num = sizeof(err) / sizeof(char *);
266 if (!strcmp(err[i], str))
273 static int ignore_error_type(struct thread_data *td, int etype, char *str)
279 if (etype >= ERROR_TYPE_CNT) {
280 log_err("Illegal error type\n");
284 td->o.ignore_error_nr[etype] = 4;
285 error = malloc(4 * sizeof(struct bssplit));
288 while ((fname = strsep(&str, ":")) != NULL) {
294 * grow struct buffer, if needed
296 if (i == td->o.ignore_error_nr[etype]) {
297 td->o.ignore_error_nr[etype] <<= 1;
298 error = realloc(error, td->o.ignore_error_nr[etype]
301 if (fname[0] == 'E') {
302 error[i] = str2error(fname);
304 error[i] = atoi(fname);
306 error[i] = -error[i];
309 log_err("Unknown error %s, please use number value \n",
317 td->o.continue_on_error |= 1 << etype;
318 td->o.ignore_error_nr[etype] = i;
319 td->o.ignore_error[etype] = error;
327 static int str_ignore_error_cb(void *data, const char *input)
329 struct thread_data *td = cb_data_to_td(data);
331 int type = 0, ret = 1;
336 p = str = strdup(input);
338 strip_blank_front(&str);
339 strip_blank_end(str);
345 ret = ignore_error_type(td, type, p);
355 static int str_rw_cb(void *data, const char *str)
357 struct thread_data *td = cb_data_to_td(data);
358 struct thread_options *o = &td->o;
367 nr = get_opt_postfix(str);
372 o->ddir_seq_nr = atoi(nr);
376 if (str_to_decimal(nr, &val, 1, o, 0, 0)) {
377 log_err("fio: rw postfix parsing failed\n");
382 o->ddir_seq_add = val;
389 static int str_mem_cb(void *data, const char *mem)
391 struct thread_data *td = cb_data_to_td(data);
393 if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP ||
394 td->o.mem_type == MEM_MMAPSHARED)
395 td->o.mmapfile = get_opt_postfix(mem);
400 static int fio_clock_source_cb(void *data, const char *str)
402 struct thread_data *td = cb_data_to_td(data);
404 fio_clock_source = td->o.clocksource;
405 fio_clock_source_set = 1;
410 static int str_rwmix_read_cb(void *data, unsigned long long *val)
412 struct thread_data *td = cb_data_to_td(data);
414 td->o.rwmix[DDIR_READ] = *val;
415 td->o.rwmix[DDIR_WRITE] = 100 - *val;
419 static int str_rwmix_write_cb(void *data, unsigned long long *val)
421 struct thread_data *td = cb_data_to_td(data);
423 td->o.rwmix[DDIR_WRITE] = *val;
424 td->o.rwmix[DDIR_READ] = 100 - *val;
428 static int str_exitall_cb(void)
430 exitall_on_terminate = 1;
434 #ifdef FIO_HAVE_CPU_AFFINITY
435 int fio_cpus_split(os_cpu_mask_t *mask, unsigned int cpu_index)
437 unsigned int i, index, cpus_in_mask;
438 const long max_cpu = cpus_online();
440 cpus_in_mask = fio_cpu_count(mask);
441 cpu_index = cpu_index % cpus_in_mask;
444 for (i = 0; i < max_cpu; i++) {
445 if (!fio_cpu_isset(mask, i))
448 if (cpu_index != index)
449 fio_cpu_clear(mask, i);
454 return fio_cpu_count(mask);
457 static int str_cpumask_cb(void *data, unsigned long long *val)
459 struct thread_data *td = cb_data_to_td(data);
467 ret = fio_cpuset_init(&td->o.cpumask);
469 log_err("fio: cpuset_init failed\n");
470 td_verror(td, ret, "fio_cpuset_init");
474 max_cpu = cpus_online();
476 for (i = 0; i < sizeof(int) * 8; i++) {
477 if ((1 << i) & *val) {
479 log_err("fio: CPU %d too large (max=%ld)\n", i,
483 dprint(FD_PARSE, "set cpu allowed %d\n", i);
484 fio_cpu_set(&td->o.cpumask, i);
491 static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask,
498 ret = fio_cpuset_init(mask);
500 log_err("fio: cpuset_init failed\n");
501 td_verror(td, ret, "fio_cpuset_init");
505 p = str = strdup(input);
507 strip_blank_front(&str);
508 strip_blank_end(str);
510 max_cpu = cpus_online();
512 while ((cpu = strsep(&str, ",")) != NULL) {
521 while ((cpu2 = strsep(&str2, "-")) != NULL) {
531 while (icpu <= icpu2) {
532 if (icpu >= FIO_MAX_CPUS) {
533 log_err("fio: your OS only supports up to"
534 " %d CPUs\n", (int) FIO_MAX_CPUS);
538 if (icpu >= max_cpu) {
539 log_err("fio: CPU %d too large (max=%ld)\n",
545 dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
546 fio_cpu_set(mask, icpu);
557 static int str_cpus_allowed_cb(void *data, const char *input)
559 struct thread_data *td = cb_data_to_td(data);
564 return set_cpus_allowed(td, &td->o.cpumask, input);
567 static int str_verify_cpus_allowed_cb(void *data, const char *input)
569 struct thread_data *td = cb_data_to_td(data);
574 return set_cpus_allowed(td, &td->o.verify_cpumask, input);
578 static int str_log_cpus_allowed_cb(void *data, const char *input)
580 struct thread_data *td = cb_data_to_td(data);
585 return set_cpus_allowed(td, &td->o.log_gz_cpumask, input);
587 #endif /* CONFIG_ZLIB */
589 #endif /* FIO_HAVE_CPU_AFFINITY */
591 #ifdef CONFIG_LIBNUMA
592 static int str_numa_cpunodes_cb(void *data, char *input)
594 struct thread_data *td = cb_data_to_td(data);
595 struct bitmask *verify_bitmask;
600 /* numa_parse_nodestring() parses a character string list
601 * of nodes into a bit mask. The bit mask is allocated by
602 * numa_allocate_nodemask(), so it should be freed by
603 * numa_free_nodemask().
605 verify_bitmask = numa_parse_nodestring(input);
606 if (verify_bitmask == NULL) {
607 log_err("fio: numa_parse_nodestring failed\n");
608 td_verror(td, 1, "str_numa_cpunodes_cb");
611 numa_free_nodemask(verify_bitmask);
613 td->o.numa_cpunodes = strdup(input);
617 static int str_numa_mpol_cb(void *data, char *input)
619 struct thread_data *td = cb_data_to_td(data);
620 const char * const policy_types[] =
621 { "default", "prefer", "bind", "interleave", "local", NULL };
624 struct bitmask *verify_bitmask;
629 nodelist = strchr(input, ':');
631 /* NUL-terminate mode */
635 for (i = 0; i <= MPOL_LOCAL; i++) {
636 if (!strcmp(input, policy_types[i])) {
637 td->o.numa_mem_mode = i;
641 if (i > MPOL_LOCAL) {
642 log_err("fio: memory policy should be: default, prefer, bind, interleave, local\n");
646 switch (td->o.numa_mem_mode) {
649 * Insist on a nodelist of one node only
652 char *rest = nodelist;
653 while (isdigit(*rest))
656 log_err("fio: one node only for \'prefer\'\n");
660 log_err("fio: one node is needed for \'prefer\'\n");
664 case MPOL_INTERLEAVE:
666 * Default to online nodes with memory if no nodelist
669 nodelist = strdup("all");
674 * Don't allow a nodelist
677 log_err("fio: NO nodelist for \'local\'\n");
683 * Insist on a nodelist
686 log_err("fio: a nodelist is needed for \'bind\'\n");
693 /* numa_parse_nodestring() parses a character string list
694 * of nodes into a bit mask. The bit mask is allocated by
695 * numa_allocate_nodemask(), so it should be freed by
696 * numa_free_nodemask().
698 switch (td->o.numa_mem_mode) {
700 td->o.numa_mem_prefer_node = atoi(nodelist);
702 case MPOL_INTERLEAVE:
704 verify_bitmask = numa_parse_nodestring(nodelist);
705 if (verify_bitmask == NULL) {
706 log_err("fio: numa_parse_nodestring failed\n");
707 td_verror(td, 1, "str_numa_memnodes_cb");
710 td->o.numa_memnodes = strdup(nodelist);
711 numa_free_nodemask(verify_bitmask);
726 static int str_fst_cb(void *data, const char *str)
728 struct thread_data *td = cb_data_to_td(data);
733 td->file_service_nr = 1;
735 switch (td->o.file_service_type) {
736 case FIO_FSERVICE_RANDOM:
737 case FIO_FSERVICE_RR:
738 case FIO_FSERVICE_SEQ:
739 nr = get_opt_postfix(str);
741 td->file_service_nr = atoi(nr);
746 case FIO_FSERVICE_ZIPF:
749 case FIO_FSERVICE_PARETO:
750 val = FIO_DEF_PARETO;
752 case FIO_FSERVICE_GAUSS:
756 log_err("fio: bad file service type: %d\n", td->o.file_service_type);
763 nr = get_opt_postfix(str);
764 if (nr && !str_to_float(nr, &val, 0)) {
765 log_err("fio: file service type random postfix parsing failed\n");
772 switch (td->o.file_service_type) {
773 case FIO_FSERVICE_ZIPF:
775 log_err("fio: zipf theta must be different than 1.0\n");
780 td->zipf_theta = val;
782 case FIO_FSERVICE_PARETO:
783 if (val <= 0.00 || val >= 1.00) {
784 log_err("fio: pareto input out of range (0 < input < 1.0)\n");
791 case FIO_FSERVICE_GAUSS:
792 if (val < 0.00 || val >= 100.00) {
793 log_err("fio: normal deviation out of range (0 <= input < 100.0)\n");
805 #ifdef CONFIG_SYNC_FILE_RANGE
806 static int str_sfr_cb(void *data, const char *str)
808 struct thread_data *td = cb_data_to_td(data);
809 char *nr = get_opt_postfix(str);
811 td->sync_file_range_nr = 1;
813 td->sync_file_range_nr = atoi(nr);
821 static int zone_cmp(const void *p1, const void *p2)
823 const struct zone_split *zsp1 = p1;
824 const struct zone_split *zsp2 = p2;
826 return (int) zsp2->access_perc - (int) zsp1->access_perc;
829 static int zone_split_ddir(struct thread_options *o, enum fio_ddir ddir,
832 unsigned int i, perc, perc_missing, sperc, sperc_missing;
835 memset(&split, 0, sizeof(split));
837 if (split_parse_ddir(o, &split, ddir, str))
842 o->zone_split[ddir] = malloc(split.nr * sizeof(struct zone_split));
843 o->zone_split_nr[ddir] = split.nr;
844 for (i = 0; i < split.nr; i++) {
845 o->zone_split[ddir][i].access_perc = split.val1[i];
846 o->zone_split[ddir][i].size_perc = split.val2[i];
850 * Now check if the percentages add up, and how much is missing
852 perc = perc_missing = 0;
853 sperc = sperc_missing = 0;
854 for (i = 0; i < o->zone_split_nr[ddir]; i++) {
855 struct zone_split *zsp = &o->zone_split[ddir][i];
857 if (zsp->access_perc == (uint8_t) -1U)
860 perc += zsp->access_perc;
862 if (zsp->size_perc == (uint8_t) -1U)
865 sperc += zsp->size_perc;
869 if (perc > 100 || sperc > 100) {
870 log_err("fio: zone_split percentages add to more than 100%%\n");
871 free(o->zone_split[ddir]);
872 o->zone_split[ddir] = NULL;
876 log_err("fio: access percentage don't add up to 100 for zoned "
877 "random distribution (got=%u)\n", perc);
878 free(o->zone_split[ddir]);
879 o->zone_split[ddir] = NULL;
884 * If values didn't have a percentage set, divide the remains between
888 if (perc_missing == 1 && o->zone_split_nr[ddir] == 1)
890 for (i = 0; i < o->zone_split_nr[ddir]; i++) {
891 struct zone_split *zsp = &o->zone_split[ddir][i];
893 if (zsp->access_perc == (uint8_t) -1U)
894 zsp->access_perc = (100 - perc) / perc_missing;
898 if (sperc_missing == 1 && o->zone_split_nr[ddir] == 1)
900 for (i = 0; i < o->zone_split_nr[ddir]; i++) {
901 struct zone_split *zsp = &o->zone_split[ddir][i];
903 if (zsp->size_perc == (uint8_t) -1U)
904 zsp->size_perc = (100 - sperc) / sperc_missing;
909 * now sort based on percentages, for ease of lookup
911 qsort(o->zone_split[ddir], o->zone_split_nr[ddir], sizeof(struct zone_split), zone_cmp);
915 static void __td_zone_gen_index(struct thread_data *td, enum fio_ddir ddir)
917 unsigned int i, j, sprev, aprev;
919 td->zone_state_index[ddir] = malloc(sizeof(struct zone_split_index) * 100);
922 for (i = 0; i < td->o.zone_split_nr[ddir]; i++) {
923 struct zone_split *zsp = &td->o.zone_split[ddir][i];
925 for (j = aprev; j < aprev + zsp->access_perc; j++) {
926 struct zone_split_index *zsi = &td->zone_state_index[ddir][j];
928 zsi->size_perc = sprev + zsp->size_perc;
929 zsi->size_perc_prev = sprev;
932 aprev += zsp->access_perc;
933 sprev += zsp->size_perc;
938 * Generate state table for indexes, so we don't have to do it inline from
941 static void td_zone_gen_index(struct thread_data *td)
945 td->zone_state_index = malloc(DDIR_RWDIR_CNT *
946 sizeof(struct zone_split_index *));
948 for (i = 0; i < DDIR_RWDIR_CNT; i++)
949 __td_zone_gen_index(td, i);
952 static int parse_zoned_distribution(struct thread_data *td, const char *input)
957 p = str = strdup(input);
959 strip_blank_front(&str);
960 strip_blank_end(str);
962 /* We expect it to start like that, bail if not */
963 if (strncmp(str, "zoned:", 6)) {
964 log_err("fio: mismatch in zoned input <%s>\n", str);
968 str += strlen("zoned:");
970 ret = str_split_parse(td, str, zone_split_ddir);
974 for (i = 0; i < DDIR_RWDIR_CNT; i++) {
977 dprint(FD_PARSE, "zone ddir %d (nr=%u): \n", i, td->o.zone_split_nr[i]);
979 for (j = 0; j < td->o.zone_split_nr[i]; j++) {
980 struct zone_split *zsp = &td->o.zone_split[i][j];
982 dprint(FD_PARSE, "\t%d: %u/%u\n", j, zsp->access_perc,
987 if (parse_dryrun()) {
990 for (i = 0; i < DDIR_RWDIR_CNT; i++) {
991 free(td->o.zone_split[i]);
992 td->o.zone_split[i] = NULL;
993 td->o.zone_split_nr[i] = 0;
1000 td_zone_gen_index(td);
1002 for (i = 0; i < DDIR_RWDIR_CNT; i++)
1003 td->o.zone_split_nr[i] = 0;
1009 static int str_random_distribution_cb(void *data, const char *str)
1011 struct thread_data *td = cb_data_to_td(data);
1015 if (td->o.random_distribution == FIO_RAND_DIST_ZIPF)
1017 else if (td->o.random_distribution == FIO_RAND_DIST_PARETO)
1018 val = FIO_DEF_PARETO;
1019 else if (td->o.random_distribution == FIO_RAND_DIST_GAUSS)
1021 else if (td->o.random_distribution == FIO_RAND_DIST_ZONED)
1022 return parse_zoned_distribution(td, str);
1026 nr = get_opt_postfix(str);
1027 if (nr && !str_to_float(nr, &val, 0)) {
1028 log_err("fio: random postfix parsing failed\n");
1035 if (td->o.random_distribution == FIO_RAND_DIST_ZIPF) {
1037 log_err("fio: zipf theta must different than 1.0\n");
1042 td->o.zipf_theta.u.f = val;
1043 } else if (td->o.random_distribution == FIO_RAND_DIST_PARETO) {
1044 if (val <= 0.00 || val >= 1.00) {
1045 log_err("fio: pareto input out of range (0 < input < 1.0)\n");
1050 td->o.pareto_h.u.f = val;
1052 if (val < 0.00 || val >= 100.0) {
1053 log_err("fio: normal deviation out of range (0 <= input < 100.0)\n");
1058 td->o.gauss_dev.u.f = val;
1065 * Return next name in the string. Files are separated with ':'. If the ':'
1066 * is escaped with a '\', then that ':' is part of the filename and does not
1067 * indicate a new file.
1069 static char *get_next_name(char **ptr)
1074 if (!str || !strlen(str))
1080 * No colon, we are done
1082 p = strchr(str, ':');
1089 * We got a colon, but it's the first character. Skip and
1097 if (*(p - 1) != '\\') {
1103 memmove(p - 1, p, strlen(p) + 1);
1111 static int get_max_name_idx(char *input)
1113 unsigned int cur_idx;
1116 p = str = strdup(input);
1117 for (cur_idx = 0; ; cur_idx++)
1118 if (get_next_name(&str) == NULL)
1126 * Returns the directory at the index, indexes > entires will be
1127 * assigned via modulo division of the index
1129 int set_name_idx(char *target, size_t tlen, char *input, int index,
1130 bool unique_filename)
1132 unsigned int cur_idx;
1134 char *fname, *str, *p;
1136 p = str = strdup(input);
1138 index %= get_max_name_idx(input);
1139 for (cur_idx = 0; cur_idx <= index; cur_idx++)
1140 fname = get_next_name(&str);
1142 if (client_sockaddr_str[0] && unique_filename) {
1143 len = snprintf(target, tlen, "%s/%s.", fname,
1144 client_sockaddr_str);
1146 len = snprintf(target, tlen, "%s/", fname);
1148 target[tlen - 1] = '\0';
1154 static int str_filename_cb(void *data, const char *input)
1156 struct thread_data *td = cb_data_to_td(data);
1157 char *fname, *str, *p;
1159 p = str = strdup(input);
1161 strip_blank_front(&str);
1162 strip_blank_end(str);
1164 if (!td->files_index)
1167 while ((fname = get_next_name(&str)) != NULL) {
1170 add_file(td, fname, 0, 1);
1177 static int str_directory_cb(void *data, const char fio_unused *unused)
1179 struct thread_data *td = cb_data_to_td(data);
1181 char *dirname, *str, *p;
1187 p = str = strdup(td->o.directory);
1188 while ((dirname = get_next_name(&str)) != NULL) {
1189 if (lstat(dirname, &sb) < 0) {
1192 log_err("fio: %s is not a directory\n", dirname);
1193 td_verror(td, ret, "lstat");
1196 if (!S_ISDIR(sb.st_mode)) {
1197 log_err("fio: %s is not a directory\n", dirname);
1208 static int str_opendir_cb(void *data, const char fio_unused *str)
1210 struct thread_data *td = cb_data_to_td(data);
1215 if (!td->files_index)
1218 return add_dir_files(td, td->o.opendir);
1221 static int str_buffer_pattern_cb(void *data, const char *input)
1223 struct thread_data *td = cb_data_to_td(data);
1226 /* FIXME: for now buffer pattern does not support formats */
1227 ret = parse_and_fill_pattern(input, strlen(input), td->o.buffer_pattern,
1228 MAX_PATTERN_SIZE, NULL, 0, NULL, NULL);
1233 td->o.buffer_pattern_bytes = ret;
1234 if (!td->o.compress_percentage)
1235 td->o.refill_buffers = 0;
1236 td->o.scramble_buffers = 0;
1237 td->o.zero_buffers = 0;
1242 static int str_buffer_compress_cb(void *data, unsigned long long *il)
1244 struct thread_data *td = cb_data_to_td(data);
1246 td->flags |= TD_F_COMPRESS;
1247 td->o.compress_percentage = *il;
1251 static int str_dedupe_cb(void *data, unsigned long long *il)
1253 struct thread_data *td = cb_data_to_td(data);
1255 td->flags |= TD_F_COMPRESS;
1256 td->o.dedupe_percentage = *il;
1257 td->o.refill_buffers = 1;
1261 static int str_verify_pattern_cb(void *data, const char *input)
1263 struct thread_data *td = cb_data_to_td(data);
1266 td->o.verify_fmt_sz = ARRAY_SIZE(td->o.verify_fmt);
1267 ret = parse_and_fill_pattern(input, strlen(input), td->o.verify_pattern,
1268 MAX_PATTERN_SIZE, fmt_desc, sizeof(fmt_desc),
1269 td->o.verify_fmt, &td->o.verify_fmt_sz);
1274 td->o.verify_pattern_bytes = ret;
1276 * VERIFY_* could already be set
1278 if (!fio_option_is_set(&td->o, verify))
1279 td->o.verify = VERIFY_PATTERN;
1284 static int str_gtod_reduce_cb(void *data, int *il)
1286 struct thread_data *td = cb_data_to_td(data);
1289 td->o.disable_lat = !!val;
1290 td->o.disable_clat = !!val;
1291 td->o.disable_slat = !!val;
1292 td->o.disable_bw = !!val;
1293 td->o.clat_percentiles = !val;
1295 td->tv_cache_mask = 63;
1300 static int str_size_cb(void *data, unsigned long long *__val)
1302 struct thread_data *td = cb_data_to_td(data);
1303 unsigned long long v = *__val;
1305 if (parse_is_percent(v)) {
1307 td->o.size_percent = -1ULL - v;
1314 static int str_write_bw_log_cb(void *data, const char *str)
1316 struct thread_data *td = cb_data_to_td(data);
1319 td->o.bw_log_file = strdup(str);
1321 td->o.write_bw_log = 1;
1325 static int str_write_lat_log_cb(void *data, const char *str)
1327 struct thread_data *td = cb_data_to_td(data);
1330 td->o.lat_log_file = strdup(str);
1332 td->o.write_lat_log = 1;
1336 static int str_write_iops_log_cb(void *data, const char *str)
1338 struct thread_data *td = cb_data_to_td(data);
1341 td->o.iops_log_file = strdup(str);
1343 td->o.write_iops_log = 1;
1347 static int str_write_hist_log_cb(void *data, const char *str)
1349 struct thread_data *td = cb_data_to_td(data);
1352 td->o.hist_log_file = strdup(str);
1354 td->o.write_hist_log = 1;
1358 static int rw_verify(struct fio_option *o, void *data)
1360 struct thread_data *td = cb_data_to_td(data);
1362 if (read_only && td_write(td)) {
1363 log_err("fio: job <%s> has write bit set, but fio is in"
1364 " read-only mode\n", td->o.name);
1371 static int gtod_cpu_verify(struct fio_option *o, void *data)
1373 #ifndef FIO_HAVE_CPU_AFFINITY
1374 struct thread_data *td = cb_data_to_td(data);
1376 if (td->o.gtod_cpu) {
1377 log_err("fio: platform must support CPU affinity for"
1378 "gettimeofday() offloading\n");
1387 * Map of job/command line options
1389 struct fio_option fio_options[FIO_MAX_OPTS] = {
1391 .name = "description",
1392 .lname = "Description of job",
1393 .type = FIO_OPT_STR_STORE,
1394 .off1 = offsetof(struct thread_options, description),
1395 .help = "Text job description",
1396 .category = FIO_OPT_C_GENERAL,
1397 .group = FIO_OPT_G_DESC,
1401 .lname = "Job name",
1402 .type = FIO_OPT_STR_STORE,
1403 .off1 = offsetof(struct thread_options, name),
1404 .help = "Name of this job",
1405 .category = FIO_OPT_C_GENERAL,
1406 .group = FIO_OPT_G_DESC,
1410 .lname = "Waitee name",
1411 .type = FIO_OPT_STR_STORE,
1412 .off1 = offsetof(struct thread_options, wait_for),
1413 .help = "Name of the job this one wants to wait for before starting",
1414 .category = FIO_OPT_C_GENERAL,
1415 .group = FIO_OPT_G_DESC,
1419 .lname = "Filename(s)",
1420 .type = FIO_OPT_STR_STORE,
1421 .off1 = offsetof(struct thread_options, filename),
1422 .cb = str_filename_cb,
1423 .prio = -1, /* must come after "directory" */
1424 .help = "File(s) to use for the workload",
1425 .category = FIO_OPT_C_FILE,
1426 .group = FIO_OPT_G_FILENAME,
1429 .name = "directory",
1430 .lname = "Directory",
1431 .type = FIO_OPT_STR_STORE,
1432 .off1 = offsetof(struct thread_options, directory),
1433 .cb = str_directory_cb,
1434 .help = "Directory to store files in",
1435 .category = FIO_OPT_C_FILE,
1436 .group = FIO_OPT_G_FILENAME,
1439 .name = "filename_format",
1440 .lname = "Filename Format",
1441 .type = FIO_OPT_STR_STORE,
1442 .off1 = offsetof(struct thread_options, filename_format),
1443 .prio = -1, /* must come after "directory" */
1444 .help = "Override default $jobname.$jobnum.$filenum naming",
1445 .def = "$jobname.$jobnum.$filenum",
1446 .category = FIO_OPT_C_FILE,
1447 .group = FIO_OPT_G_FILENAME,
1450 .name = "unique_filename",
1451 .lname = "Unique Filename",
1452 .type = FIO_OPT_BOOL,
1453 .off1 = offsetof(struct thread_options, unique_filename),
1454 .help = "For network clients, prefix file with source IP",
1456 .category = FIO_OPT_C_FILE,
1457 .group = FIO_OPT_G_FILENAME,
1461 .lname = "Lockfile",
1462 .type = FIO_OPT_STR,
1463 .off1 = offsetof(struct thread_options, file_lock_mode),
1464 .help = "Lock file when doing IO to it",
1466 .parent = "filename",
1469 .category = FIO_OPT_C_FILE,
1470 .group = FIO_OPT_G_FILENAME,
1473 .oval = FILE_LOCK_NONE,
1474 .help = "No file locking",
1476 { .ival = "exclusive",
1477 .oval = FILE_LOCK_EXCLUSIVE,
1478 .help = "Exclusive file lock",
1481 .ival = "readwrite",
1482 .oval = FILE_LOCK_READWRITE,
1483 .help = "Read vs write lock",
1489 .lname = "Open directory",
1490 .type = FIO_OPT_STR_STORE,
1491 .off1 = offsetof(struct thread_options, opendir),
1492 .cb = str_opendir_cb,
1493 .help = "Recursively add files from this directory and down",
1494 .category = FIO_OPT_C_FILE,
1495 .group = FIO_OPT_G_FILENAME,
1499 .lname = "Read/write",
1500 .alias = "readwrite",
1501 .type = FIO_OPT_STR,
1503 .off1 = offsetof(struct thread_options, td_ddir),
1504 .help = "IO direction",
1506 .verify = rw_verify,
1507 .category = FIO_OPT_C_IO,
1508 .group = FIO_OPT_G_IO_BASIC,
1511 .oval = TD_DDIR_READ,
1512 .help = "Sequential read",
1515 .oval = TD_DDIR_WRITE,
1516 .help = "Sequential write",
1519 .oval = TD_DDIR_TRIM,
1520 .help = "Sequential trim",
1522 { .ival = "randread",
1523 .oval = TD_DDIR_RANDREAD,
1524 .help = "Random read",
1526 { .ival = "randwrite",
1527 .oval = TD_DDIR_RANDWRITE,
1528 .help = "Random write",
1530 { .ival = "randtrim",
1531 .oval = TD_DDIR_RANDTRIM,
1532 .help = "Random trim",
1536 .help = "Sequential read and write mix",
1538 { .ival = "readwrite",
1540 .help = "Sequential read and write mix",
1543 .oval = TD_DDIR_RANDRW,
1544 .help = "Random read and write mix"
1546 { .ival = "trimwrite",
1547 .oval = TD_DDIR_TRIMWRITE,
1548 .help = "Trim and write mix, trims preceding writes"
1553 .name = "rw_sequencer",
1554 .lname = "RW Sequencer",
1555 .type = FIO_OPT_STR,
1556 .off1 = offsetof(struct thread_options, rw_seq),
1557 .help = "IO offset generator modifier",
1558 .def = "sequential",
1559 .category = FIO_OPT_C_IO,
1560 .group = FIO_OPT_G_IO_BASIC,
1562 { .ival = "sequential",
1564 .help = "Generate sequential offsets",
1566 { .ival = "identical",
1567 .oval = RW_SEQ_IDENT,
1568 .help = "Generate identical offsets",
1575 .lname = "IO Engine",
1576 .type = FIO_OPT_STR_STORE,
1577 .off1 = offsetof(struct thread_options, ioengine),
1578 .help = "IO engine to use",
1579 .def = FIO_PREFERRED_ENGINE,
1580 .category = FIO_OPT_C_IO,
1581 .group = FIO_OPT_G_IO_BASIC,
1584 .help = "Use read/write",
1587 .help = "Use pread/pwrite",
1590 .help = "Use readv/writev",
1592 #ifdef CONFIG_PWRITEV
1594 .help = "Use preadv/pwritev",
1597 #ifdef FIO_HAVE_PWRITEV2
1598 { .ival = "pvsync2",
1599 .help = "Use preadv2/pwritev2",
1602 #ifdef CONFIG_LIBAIO
1604 .help = "Linux native asynchronous IO",
1607 #ifdef CONFIG_POSIXAIO
1608 { .ival = "posixaio",
1609 .help = "POSIX asynchronous IO",
1612 #ifdef CONFIG_SOLARISAIO
1613 { .ival = "solarisaio",
1614 .help = "Solaris native asynchronous IO",
1617 #ifdef CONFIG_WINDOWSAIO
1618 { .ival = "windowsaio",
1619 .help = "Windows native asynchronous IO"
1624 .help = "Rados Block Device asynchronous IO"
1628 .help = "Memory mapped IO"
1630 #ifdef CONFIG_LINUX_SPLICE
1632 .help = "splice/vmsplice based IO",
1634 { .ival = "netsplice",
1635 .help = "splice/vmsplice to/from the network",
1638 #ifdef FIO_HAVE_SGIO
1640 .help = "SCSI generic v3 IO",
1644 .help = "Testing engine (no data transfer)",
1647 .help = "Network IO",
1650 .help = "CPU cycle burner engine",
1654 .help = "GUASI IO engine",
1657 #ifdef FIO_HAVE_BINJECT
1658 { .ival = "binject",
1659 .help = "binject direct inject block engine",
1664 .help = "RDMA IO engine",
1667 #ifdef CONFIG_FUSION_AW
1668 { .ival = "fusion-aw-sync",
1669 .help = "Fusion-io atomic write engine",
1672 #ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
1673 { .ival = "e4defrag",
1674 .help = "ext4 defrag engine",
1677 #ifdef CONFIG_LINUX_FALLOCATE
1679 .help = "fallocate() file based engine",
1684 .help = "Glusterfs libgfapi(sync) based engine"
1686 { .ival = "gfapi_async",
1687 .help = "Glusterfs libgfapi(async) based engine"
1690 #ifdef CONFIG_LIBHDFS
1691 { .ival = "libhdfs",
1692 .help = "Hadoop Distributed Filesystem (HDFS) engine"
1695 #ifdef CONFIG_PMEMBLK
1696 { .ival = "pmemblk",
1697 .help = "NVML libpmemblk based IO engine",
1701 { .ival = "external",
1702 .help = "Load external engine (append name)",
1708 .lname = "IO Depth",
1709 .type = FIO_OPT_INT,
1710 .off1 = offsetof(struct thread_options, iodepth),
1711 .help = "Number of IO buffers to keep in flight",
1715 .category = FIO_OPT_C_IO,
1716 .group = FIO_OPT_G_IO_BASIC,
1719 .name = "iodepth_batch",
1720 .lname = "IO Depth batch",
1721 .alias = "iodepth_batch_submit",
1722 .type = FIO_OPT_INT,
1723 .off1 = offsetof(struct thread_options, iodepth_batch),
1724 .help = "Number of IO buffers to submit in one go",
1725 .parent = "iodepth",
1729 .category = FIO_OPT_C_IO,
1730 .group = FIO_OPT_G_IO_BASIC,
1733 .name = "iodepth_batch_complete_min",
1734 .lname = "Min IO depth batch complete",
1735 .alias = "iodepth_batch_complete",
1736 .type = FIO_OPT_INT,
1737 .off1 = offsetof(struct thread_options, iodepth_batch_complete_min),
1738 .help = "Min number of IO buffers to retrieve in one go",
1739 .parent = "iodepth",
1744 .category = FIO_OPT_C_IO,
1745 .group = FIO_OPT_G_IO_BASIC,
1748 .name = "iodepth_batch_complete_max",
1749 .lname = "Max IO depth batch complete",
1750 .type = FIO_OPT_INT,
1751 .off1 = offsetof(struct thread_options, iodepth_batch_complete_max),
1752 .help = "Max number of IO buffers to retrieve in one go",
1753 .parent = "iodepth",
1757 .category = FIO_OPT_C_IO,
1758 .group = FIO_OPT_G_IO_BASIC,
1761 .name = "iodepth_low",
1762 .lname = "IO Depth batch low",
1763 .type = FIO_OPT_INT,
1764 .off1 = offsetof(struct thread_options, iodepth_low),
1765 .help = "Low water mark for queuing depth",
1766 .parent = "iodepth",
1769 .category = FIO_OPT_C_IO,
1770 .group = FIO_OPT_G_IO_BASIC,
1773 .name = "io_submit_mode",
1774 .lname = "IO submit mode",
1775 .type = FIO_OPT_STR,
1776 .off1 = offsetof(struct thread_options, io_submit_mode),
1777 .help = "How IO submissions and completions are done",
1779 .category = FIO_OPT_C_IO,
1780 .group = FIO_OPT_G_IO_BASIC,
1783 .oval = IO_MODE_INLINE,
1784 .help = "Submit and complete IO inline",
1786 { .ival = "offload",
1787 .oval = IO_MODE_OFFLOAD,
1788 .help = "Offload submit and complete to threads",
1795 .type = FIO_OPT_STR_VAL,
1797 .off1 = offsetof(struct thread_options, size),
1798 .help = "Total size of device or files",
1799 .interval = 1024 * 1024,
1800 .category = FIO_OPT_C_IO,
1801 .group = FIO_OPT_G_INVALID,
1805 .alias = "io_limit",
1807 .type = FIO_OPT_STR_VAL,
1808 .off1 = offsetof(struct thread_options, io_limit),
1809 .interval = 1024 * 1024,
1810 .category = FIO_OPT_C_IO,
1811 .group = FIO_OPT_G_INVALID,
1814 .name = "fill_device",
1815 .lname = "Fill device",
1817 .type = FIO_OPT_BOOL,
1818 .off1 = offsetof(struct thread_options, fill_device),
1819 .help = "Write until an ENOSPC error occurs",
1821 .category = FIO_OPT_C_FILE,
1822 .group = FIO_OPT_G_INVALID,
1826 .lname = "File size",
1827 .type = FIO_OPT_STR_VAL,
1828 .off1 = offsetof(struct thread_options, file_size_low),
1829 .off2 = offsetof(struct thread_options, file_size_high),
1831 .help = "Size of individual files",
1832 .interval = 1024 * 1024,
1833 .category = FIO_OPT_C_FILE,
1834 .group = FIO_OPT_G_INVALID,
1837 .name = "file_append",
1838 .lname = "File append",
1839 .type = FIO_OPT_BOOL,
1840 .off1 = offsetof(struct thread_options, file_append),
1841 .help = "IO will start at the end of the file(s)",
1843 .category = FIO_OPT_C_FILE,
1844 .group = FIO_OPT_G_INVALID,
1848 .lname = "IO offset",
1849 .alias = "fileoffset",
1850 .type = FIO_OPT_STR_VAL,
1851 .off1 = offsetof(struct thread_options, start_offset),
1852 .help = "Start IO from this offset",
1854 .interval = 1024 * 1024,
1855 .category = FIO_OPT_C_IO,
1856 .group = FIO_OPT_G_INVALID,
1859 .name = "offset_increment",
1860 .lname = "IO offset increment",
1861 .type = FIO_OPT_STR_VAL,
1862 .off1 = offsetof(struct thread_options, offset_increment),
1863 .help = "What is the increment from one offset to the next",
1867 .interval = 1024 * 1024,
1868 .category = FIO_OPT_C_IO,
1869 .group = FIO_OPT_G_INVALID,
1872 .name = "number_ios",
1873 .lname = "Number of IOs to perform",
1874 .type = FIO_OPT_STR_VAL,
1875 .off1 = offsetof(struct thread_options, number_ios),
1876 .help = "Force job completion after this number of IOs",
1878 .category = FIO_OPT_C_IO,
1879 .group = FIO_OPT_G_INVALID,
1883 .lname = "Block size",
1884 .alias = "blocksize",
1885 .type = FIO_OPT_INT,
1886 .off1 = offsetof(struct thread_options, bs[DDIR_READ]),
1887 .off2 = offsetof(struct thread_options, bs[DDIR_WRITE]),
1888 .off3 = offsetof(struct thread_options, bs[DDIR_TRIM]),
1890 .help = "Block size unit",
1895 .category = FIO_OPT_C_IO,
1896 .group = FIO_OPT_G_INVALID,
1900 .lname = "Block size align",
1901 .alias = "blockalign",
1902 .type = FIO_OPT_INT,
1903 .off1 = offsetof(struct thread_options, ba[DDIR_READ]),
1904 .off2 = offsetof(struct thread_options, ba[DDIR_WRITE]),
1905 .off3 = offsetof(struct thread_options, ba[DDIR_TRIM]),
1907 .help = "IO block offset alignment",
1911 .category = FIO_OPT_C_IO,
1912 .group = FIO_OPT_G_INVALID,
1916 .lname = "Block size range",
1917 .alias = "blocksize_range",
1918 .type = FIO_OPT_RANGE,
1919 .off1 = offsetof(struct thread_options, min_bs[DDIR_READ]),
1920 .off2 = offsetof(struct thread_options, max_bs[DDIR_READ]),
1921 .off3 = offsetof(struct thread_options, min_bs[DDIR_WRITE]),
1922 .off4 = offsetof(struct thread_options, max_bs[DDIR_WRITE]),
1923 .off5 = offsetof(struct thread_options, min_bs[DDIR_TRIM]),
1924 .off6 = offsetof(struct thread_options, max_bs[DDIR_TRIM]),
1926 .help = "Set block size range (in more detail than bs)",
1930 .category = FIO_OPT_C_IO,
1931 .group = FIO_OPT_G_INVALID,
1935 .lname = "Block size split",
1936 .type = FIO_OPT_STR,
1937 .cb = str_bssplit_cb,
1938 .off1 = offsetof(struct thread_options, bssplit),
1939 .help = "Set a specific mix of block sizes",
1942 .category = FIO_OPT_C_IO,
1943 .group = FIO_OPT_G_INVALID,
1946 .name = "bs_unaligned",
1947 .lname = "Block size unaligned",
1948 .alias = "blocksize_unaligned",
1949 .type = FIO_OPT_STR_SET,
1950 .off1 = offsetof(struct thread_options, bs_unaligned),
1951 .help = "Don't sector align IO buffer sizes",
1954 .category = FIO_OPT_C_IO,
1955 .group = FIO_OPT_G_INVALID,
1958 .name = "bs_is_seq_rand",
1959 .lname = "Block size division is seq/random (not read/write)",
1960 .type = FIO_OPT_BOOL,
1961 .off1 = offsetof(struct thread_options, bs_is_seq_rand),
1962 .help = "Consider any blocksize setting to be sequential,random",
1964 .parent = "blocksize",
1965 .category = FIO_OPT_C_IO,
1966 .group = FIO_OPT_G_INVALID,
1969 .name = "randrepeat",
1970 .lname = "Random repeatable",
1971 .type = FIO_OPT_BOOL,
1972 .off1 = offsetof(struct thread_options, rand_repeatable),
1973 .help = "Use repeatable random IO pattern",
1977 .category = FIO_OPT_C_IO,
1978 .group = FIO_OPT_G_RANDOM,
1982 .lname = "The random generator seed",
1983 .type = FIO_OPT_STR_VAL,
1984 .off1 = offsetof(struct thread_options, rand_seed),
1985 .help = "Set the random generator seed value",
1988 .category = FIO_OPT_C_IO,
1989 .group = FIO_OPT_G_RANDOM,
1992 .name = "use_os_rand",
1993 .lname = "Use OS random",
1994 .type = FIO_OPT_DEPRECATED,
1995 .off1 = offsetof(struct thread_options, dep_use_os_rand),
1996 .category = FIO_OPT_C_IO,
1997 .group = FIO_OPT_G_RANDOM,
2000 .name = "norandommap",
2001 .lname = "No randommap",
2002 .type = FIO_OPT_STR_SET,
2003 .off1 = offsetof(struct thread_options, norandommap),
2004 .help = "Accept potential duplicate random blocks",
2008 .category = FIO_OPT_C_IO,
2009 .group = FIO_OPT_G_RANDOM,
2012 .name = "softrandommap",
2013 .lname = "Soft randommap",
2014 .type = FIO_OPT_BOOL,
2015 .off1 = offsetof(struct thread_options, softrandommap),
2016 .help = "Set norandommap if randommap allocation fails",
2017 .parent = "norandommap",
2020 .category = FIO_OPT_C_IO,
2021 .group = FIO_OPT_G_RANDOM,
2024 .name = "random_generator",
2025 .lname = "Random Generator",
2026 .type = FIO_OPT_STR,
2027 .off1 = offsetof(struct thread_options, random_generator),
2028 .help = "Type of random number generator to use",
2029 .def = "tausworthe",
2031 { .ival = "tausworthe",
2032 .oval = FIO_RAND_GEN_TAUSWORTHE,
2033 .help = "Strong Tausworthe generator",
2036 .oval = FIO_RAND_GEN_LFSR,
2037 .help = "Variable length LFSR",
2040 .ival = "tausworthe64",
2041 .oval = FIO_RAND_GEN_TAUSWORTHE64,
2042 .help = "64-bit Tausworthe variant",
2045 .category = FIO_OPT_C_IO,
2046 .group = FIO_OPT_G_RANDOM,
2049 .name = "random_distribution",
2050 .lname = "Random Distribution",
2051 .type = FIO_OPT_STR,
2052 .off1 = offsetof(struct thread_options, random_distribution),
2053 .cb = str_random_distribution_cb,
2054 .help = "Random offset distribution generator",
2058 .oval = FIO_RAND_DIST_RANDOM,
2059 .help = "Completely random",
2062 .oval = FIO_RAND_DIST_ZIPF,
2063 .help = "Zipf distribution",
2066 .oval = FIO_RAND_DIST_PARETO,
2067 .help = "Pareto distribution",
2070 .oval = FIO_RAND_DIST_GAUSS,
2071 .help = "Normal (Gaussian) distribution",
2074 .oval = FIO_RAND_DIST_ZONED,
2075 .help = "Zoned random distribution",
2079 .category = FIO_OPT_C_IO,
2080 .group = FIO_OPT_G_RANDOM,
2083 .name = "percentage_random",
2084 .lname = "Percentage Random",
2085 .type = FIO_OPT_INT,
2086 .off1 = offsetof(struct thread_options, perc_rand[DDIR_READ]),
2087 .off2 = offsetof(struct thread_options, perc_rand[DDIR_WRITE]),
2088 .off3 = offsetof(struct thread_options, perc_rand[DDIR_TRIM]),
2090 .help = "Percentage of seq/random mix that should be random",
2091 .def = "100,100,100",
2093 .inverse = "percentage_sequential",
2094 .category = FIO_OPT_C_IO,
2095 .group = FIO_OPT_G_RANDOM,
2098 .name = "percentage_sequential",
2099 .lname = "Percentage Sequential",
2100 .type = FIO_OPT_DEPRECATED,
2101 .category = FIO_OPT_C_IO,
2102 .group = FIO_OPT_G_RANDOM,
2105 .name = "allrandrepeat",
2106 .lname = "All Random Repeat",
2107 .type = FIO_OPT_BOOL,
2108 .off1 = offsetof(struct thread_options, allrand_repeatable),
2109 .help = "Use repeatable random numbers for everything",
2111 .category = FIO_OPT_C_IO,
2112 .group = FIO_OPT_G_RANDOM,
2116 .lname = "Number of files",
2117 .alias = "nr_files",
2118 .type = FIO_OPT_INT,
2119 .off1 = offsetof(struct thread_options, nr_files),
2120 .help = "Split job workload between this number of files",
2123 .category = FIO_OPT_C_FILE,
2124 .group = FIO_OPT_G_INVALID,
2127 .name = "openfiles",
2128 .lname = "Number of open files",
2129 .type = FIO_OPT_INT,
2130 .off1 = offsetof(struct thread_options, open_files),
2131 .help = "Number of files to keep open at the same time",
2132 .category = FIO_OPT_C_FILE,
2133 .group = FIO_OPT_G_INVALID,
2136 .name = "file_service_type",
2137 .lname = "File service type",
2138 .type = FIO_OPT_STR,
2140 .off1 = offsetof(struct thread_options, file_service_type),
2141 .help = "How to select which file to service next",
2142 .def = "roundrobin",
2143 .category = FIO_OPT_C_FILE,
2144 .group = FIO_OPT_G_INVALID,
2147 .oval = FIO_FSERVICE_RANDOM,
2148 .help = "Choose a file at random (uniform)",
2151 .oval = FIO_FSERVICE_ZIPF,
2152 .help = "Zipf randomized",
2155 .oval = FIO_FSERVICE_PARETO,
2156 .help = "Pareto randomized",
2159 .oval = FIO_FSERVICE_GAUSS,
2160 .help = "Normal (gaussian) distribution",
2162 { .ival = "roundrobin",
2163 .oval = FIO_FSERVICE_RR,
2164 .help = "Round robin select files",
2166 { .ival = "sequential",
2167 .oval = FIO_FSERVICE_SEQ,
2168 .help = "Finish one file before moving to the next",
2171 .parent = "nrfiles",
2174 #ifdef CONFIG_POSIX_FALLOCATE
2176 .name = "fallocate",
2177 .lname = "Fallocate",
2178 .type = FIO_OPT_STR,
2179 .off1 = offsetof(struct thread_options, fallocate_mode),
2180 .help = "Whether pre-allocation is performed when laying out files",
2182 .category = FIO_OPT_C_FILE,
2183 .group = FIO_OPT_G_INVALID,
2186 .oval = FIO_FALLOCATE_NONE,
2187 .help = "Do not pre-allocate space",
2190 .oval = FIO_FALLOCATE_POSIX,
2191 .help = "Use posix_fallocate()",
2193 #ifdef CONFIG_LINUX_FALLOCATE
2195 .oval = FIO_FALLOCATE_KEEP_SIZE,
2196 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
2199 /* Compatibility with former boolean values */
2201 .oval = FIO_FALLOCATE_NONE,
2202 .help = "Alias for 'none'",
2205 .oval = FIO_FALLOCATE_POSIX,
2206 .help = "Alias for 'posix'",
2210 #else /* CONFIG_POSIX_FALLOCATE */
2212 .name = "fallocate",
2213 .lname = "Fallocate",
2214 .type = FIO_OPT_UNSUPPORTED,
2215 .help = "Your platform does not support fallocate",
2217 #endif /* CONFIG_POSIX_FALLOCATE */
2219 .name = "fadvise_hint",
2220 .lname = "Fadvise hint",
2221 .type = FIO_OPT_BOOL,
2222 .off1 = offsetof(struct thread_options, fadvise_hint),
2223 .help = "Use fadvise() to advise the kernel on IO pattern",
2225 .category = FIO_OPT_C_FILE,
2226 .group = FIO_OPT_G_INVALID,
2228 #ifdef FIO_HAVE_STREAMID
2230 .name = "fadvise_stream",
2231 .lname = "Fadvise stream",
2232 .type = FIO_OPT_INT,
2233 .off1 = offsetof(struct thread_options, fadvise_stream),
2234 .help = "Use fadvise() to set stream ID",
2235 .category = FIO_OPT_C_FILE,
2236 .group = FIO_OPT_G_INVALID,
2240 .name = "fadvise_stream",
2241 .lname = "Fadvise stream",
2242 .type = FIO_OPT_UNSUPPORTED,
2243 .help = "Your platform does not support fadvise stream ID",
2249 .type = FIO_OPT_INT,
2250 .off1 = offsetof(struct thread_options, fsync_blocks),
2251 .help = "Issue fsync for writes every given number of blocks",
2254 .category = FIO_OPT_C_FILE,
2255 .group = FIO_OPT_G_INVALID,
2258 .name = "fdatasync",
2259 .lname = "Fdatasync",
2260 .type = FIO_OPT_INT,
2261 .off1 = offsetof(struct thread_options, fdatasync_blocks),
2262 .help = "Issue fdatasync for writes every given number of blocks",
2265 .category = FIO_OPT_C_FILE,
2266 .group = FIO_OPT_G_INVALID,
2269 .name = "write_barrier",
2270 .lname = "Write barrier",
2271 .type = FIO_OPT_INT,
2272 .off1 = offsetof(struct thread_options, barrier_blocks),
2273 .help = "Make every Nth write a barrier write",
2276 .category = FIO_OPT_C_IO,
2277 .group = FIO_OPT_G_INVALID,
2279 #ifdef CONFIG_SYNC_FILE_RANGE
2281 .name = "sync_file_range",
2282 .lname = "Sync file range",
2284 { .ival = "wait_before",
2285 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
2286 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
2290 .oval = SYNC_FILE_RANGE_WRITE,
2291 .help = "SYNC_FILE_RANGE_WRITE",
2295 .ival = "wait_after",
2296 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
2297 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
2301 .type = FIO_OPT_STR_MULTI,
2303 .off1 = offsetof(struct thread_options, sync_file_range),
2304 .help = "Use sync_file_range()",
2305 .category = FIO_OPT_C_FILE,
2306 .group = FIO_OPT_G_INVALID,
2310 .name = "sync_file_range",
2311 .lname = "Sync file range",
2312 .type = FIO_OPT_UNSUPPORTED,
2313 .help = "Your platform does not support sync_file_range",
2318 .lname = "Direct I/O",
2319 .type = FIO_OPT_BOOL,
2320 .off1 = offsetof(struct thread_options, odirect),
2321 .help = "Use O_DIRECT IO (negates buffered)",
2323 .inverse = "buffered",
2324 .category = FIO_OPT_C_IO,
2325 .group = FIO_OPT_G_IO_TYPE,
2329 .lname = "Atomic I/O",
2330 .type = FIO_OPT_BOOL,
2331 .off1 = offsetof(struct thread_options, oatomic),
2332 .help = "Use Atomic IO with O_DIRECT (implies O_DIRECT)",
2334 .category = FIO_OPT_C_IO,
2335 .group = FIO_OPT_G_IO_TYPE,
2339 .lname = "Buffered I/O",
2340 .type = FIO_OPT_BOOL,
2341 .off1 = offsetof(struct thread_options, odirect),
2343 .help = "Use buffered IO (negates direct)",
2345 .inverse = "direct",
2346 .category = FIO_OPT_C_IO,
2347 .group = FIO_OPT_G_IO_TYPE,
2350 .name = "overwrite",
2351 .lname = "Overwrite",
2352 .type = FIO_OPT_BOOL,
2353 .off1 = offsetof(struct thread_options, overwrite),
2354 .help = "When writing, set whether to overwrite current data",
2356 .category = FIO_OPT_C_FILE,
2357 .group = FIO_OPT_G_INVALID,
2362 .type = FIO_OPT_INT,
2363 .off1 = offsetof(struct thread_options, loops),
2364 .help = "Number of times to run the job",
2367 .category = FIO_OPT_C_GENERAL,
2368 .group = FIO_OPT_G_RUNTIME,
2372 .lname = "Number of jobs",
2373 .type = FIO_OPT_INT,
2374 .off1 = offsetof(struct thread_options, numjobs),
2375 .help = "Duplicate this job this many times",
2378 .category = FIO_OPT_C_GENERAL,
2379 .group = FIO_OPT_G_RUNTIME,
2382 .name = "startdelay",
2383 .lname = "Start delay",
2384 .type = FIO_OPT_STR_VAL_TIME,
2385 .off1 = offsetof(struct thread_options, start_delay),
2386 .off2 = offsetof(struct thread_options, start_delay_high),
2387 .help = "Only start job when this period has passed",
2391 .category = FIO_OPT_C_GENERAL,
2392 .group = FIO_OPT_G_RUNTIME,
2398 .type = FIO_OPT_STR_VAL_TIME,
2399 .off1 = offsetof(struct thread_options, timeout),
2400 .help = "Stop workload when this amount of time has passed",
2404 .category = FIO_OPT_C_GENERAL,
2405 .group = FIO_OPT_G_RUNTIME,
2408 .name = "time_based",
2409 .lname = "Time based",
2410 .type = FIO_OPT_STR_SET,
2411 .off1 = offsetof(struct thread_options, time_based),
2412 .help = "Keep running until runtime/timeout is met",
2413 .category = FIO_OPT_C_GENERAL,
2414 .group = FIO_OPT_G_RUNTIME,
2417 .name = "verify_only",
2418 .lname = "Verify only",
2419 .type = FIO_OPT_STR_SET,
2420 .off1 = offsetof(struct thread_options, verify_only),
2421 .help = "Verifies previously written data is still valid",
2422 .category = FIO_OPT_C_GENERAL,
2423 .group = FIO_OPT_G_RUNTIME,
2426 .name = "ramp_time",
2427 .lname = "Ramp time",
2428 .type = FIO_OPT_STR_VAL_TIME,
2429 .off1 = offsetof(struct thread_options, ramp_time),
2430 .help = "Ramp up time before measuring performance",
2433 .category = FIO_OPT_C_GENERAL,
2434 .group = FIO_OPT_G_RUNTIME,
2437 .name = "clocksource",
2438 .lname = "Clock source",
2439 .type = FIO_OPT_STR,
2440 .cb = fio_clock_source_cb,
2441 .off1 = offsetof(struct thread_options, clocksource),
2442 .help = "What type of timing source to use",
2443 .category = FIO_OPT_C_GENERAL,
2444 .group = FIO_OPT_G_CLOCK,
2446 #ifdef CONFIG_GETTIMEOFDAY
2447 { .ival = "gettimeofday",
2449 .help = "Use gettimeofday(2) for timing",
2452 #ifdef CONFIG_CLOCK_GETTIME
2453 { .ival = "clock_gettime",
2454 .oval = CS_CGETTIME,
2455 .help = "Use clock_gettime(2) for timing",
2458 #ifdef ARCH_HAVE_CPU_CLOCK
2460 .oval = CS_CPUCLOCK,
2461 .help = "Use CPU private clock",
2469 .lname = "I/O Memory",
2470 .type = FIO_OPT_STR,
2472 .off1 = offsetof(struct thread_options, mem_type),
2473 .help = "Backing type for IO buffers",
2475 .category = FIO_OPT_C_IO,
2476 .group = FIO_OPT_G_INVALID,
2480 .help = "Use malloc(3) for IO buffers",
2482 #ifndef CONFIG_NO_SHM
2485 .help = "Use shared memory segments for IO buffers",
2487 #ifdef FIO_HAVE_HUGETLB
2488 { .ival = "shmhuge",
2489 .oval = MEM_SHMHUGE,
2490 .help = "Like shm, but use huge pages",
2496 .help = "Use mmap(2) (file or anon) for IO buffers",
2498 { .ival = "mmapshared",
2499 .oval = MEM_MMAPSHARED,
2500 .help = "Like mmap, but use the shared flag",
2502 #ifdef FIO_HAVE_HUGETLB
2503 { .ival = "mmaphuge",
2504 .oval = MEM_MMAPHUGE,
2505 .help = "Like mmap, but use huge pages",
2511 .name = "iomem_align",
2512 .alias = "mem_align",
2513 .lname = "I/O memory alignment",
2514 .type = FIO_OPT_INT,
2515 .off1 = offsetof(struct thread_options, mem_align),
2517 .help = "IO memory buffer offset alignment",
2521 .category = FIO_OPT_C_IO,
2522 .group = FIO_OPT_G_INVALID,
2527 .type = FIO_OPT_STR,
2528 .off1 = offsetof(struct thread_options, verify),
2529 .help = "Verify data written",
2531 .category = FIO_OPT_C_IO,
2532 .group = FIO_OPT_G_VERIFY,
2535 .oval = VERIFY_NONE,
2536 .help = "Don't do IO verification",
2540 .help = "Use md5 checksums for verification",
2543 .oval = VERIFY_CRC64,
2544 .help = "Use crc64 checksums for verification",
2547 .oval = VERIFY_CRC32,
2548 .help = "Use crc32 checksums for verification",
2550 { .ival = "crc32c-intel",
2551 .oval = VERIFY_CRC32C,
2552 .help = "Use crc32c checksums for verification (hw assisted, if available)",
2555 .oval = VERIFY_CRC32C,
2556 .help = "Use crc32c checksums for verification (hw assisted, if available)",
2559 .oval = VERIFY_CRC16,
2560 .help = "Use crc16 checksums for verification",
2563 .oval = VERIFY_CRC7,
2564 .help = "Use crc7 checksums for verification",
2567 .oval = VERIFY_SHA1,
2568 .help = "Use sha1 checksums for verification",
2571 .oval = VERIFY_SHA256,
2572 .help = "Use sha256 checksums for verification",
2575 .oval = VERIFY_SHA512,
2576 .help = "Use sha512 checksums for verification",
2579 .oval = VERIFY_XXHASH,
2580 .help = "Use xxhash checksums for verification",
2582 /* Meta information was included into verify_header,
2583 * 'meta' verification is implied by default. */
2585 .oval = VERIFY_HDR_ONLY,
2586 .help = "Use io information for verification. "
2587 "Now is implied by default, thus option is obsolete, "
2590 { .ival = "pattern",
2591 .oval = VERIFY_PATTERN_NO_HDR,
2592 .help = "Verify strict pattern",
2596 .oval = VERIFY_NULL,
2597 .help = "Pretend to verify",
2602 .name = "do_verify",
2603 .lname = "Perform verify step",
2604 .type = FIO_OPT_BOOL,
2605 .off1 = offsetof(struct thread_options, do_verify),
2606 .help = "Run verification stage after write",
2610 .category = FIO_OPT_C_IO,
2611 .group = FIO_OPT_G_VERIFY,
2614 .name = "verifysort",
2615 .lname = "Verify sort",
2616 .type = FIO_OPT_BOOL,
2617 .off1 = offsetof(struct thread_options, verifysort),
2618 .help = "Sort written verify blocks for read back",
2622 .category = FIO_OPT_C_IO,
2623 .group = FIO_OPT_G_VERIFY,
2626 .name = "verifysort_nr",
2627 .lname = "Verify Sort Nr",
2628 .type = FIO_OPT_INT,
2629 .off1 = offsetof(struct thread_options, verifysort_nr),
2630 .help = "Pre-load and sort verify blocks for a read workload",
2635 .category = FIO_OPT_C_IO,
2636 .group = FIO_OPT_G_VERIFY,
2639 .name = "verify_interval",
2640 .lname = "Verify interval",
2641 .type = FIO_OPT_INT,
2642 .off1 = offsetof(struct thread_options, verify_interval),
2643 .minval = 2 * sizeof(struct verify_header),
2644 .help = "Store verify buffer header every N bytes",
2647 .interval = 2 * sizeof(struct verify_header),
2648 .category = FIO_OPT_C_IO,
2649 .group = FIO_OPT_G_VERIFY,
2652 .name = "verify_offset",
2653 .lname = "Verify offset",
2654 .type = FIO_OPT_INT,
2655 .help = "Offset verify header location by N bytes",
2656 .off1 = offsetof(struct thread_options, verify_offset),
2657 .minval = sizeof(struct verify_header),
2660 .category = FIO_OPT_C_IO,
2661 .group = FIO_OPT_G_VERIFY,
2664 .name = "verify_pattern",
2665 .lname = "Verify pattern",
2666 .type = FIO_OPT_STR,
2667 .cb = str_verify_pattern_cb,
2668 .off1 = offsetof(struct thread_options, verify_pattern),
2669 .help = "Fill pattern for IO buffers",
2672 .category = FIO_OPT_C_IO,
2673 .group = FIO_OPT_G_VERIFY,
2676 .name = "verify_fatal",
2677 .lname = "Verify fatal",
2678 .type = FIO_OPT_BOOL,
2679 .off1 = offsetof(struct thread_options, verify_fatal),
2681 .help = "Exit on a single verify failure, don't continue",
2684 .category = FIO_OPT_C_IO,
2685 .group = FIO_OPT_G_VERIFY,
2688 .name = "verify_dump",
2689 .lname = "Verify dump",
2690 .type = FIO_OPT_BOOL,
2691 .off1 = offsetof(struct thread_options, verify_dump),
2693 .help = "Dump contents of good and bad blocks on failure",
2696 .category = FIO_OPT_C_IO,
2697 .group = FIO_OPT_G_VERIFY,
2700 .name = "verify_async",
2701 .lname = "Verify asynchronously",
2702 .type = FIO_OPT_INT,
2703 .off1 = offsetof(struct thread_options, verify_async),
2705 .help = "Number of async verifier threads to use",
2708 .category = FIO_OPT_C_IO,
2709 .group = FIO_OPT_G_VERIFY,
2712 .name = "verify_backlog",
2713 .lname = "Verify backlog",
2714 .type = FIO_OPT_STR_VAL,
2715 .off1 = offsetof(struct thread_options, verify_backlog),
2716 .help = "Verify after this number of blocks are written",
2719 .category = FIO_OPT_C_IO,
2720 .group = FIO_OPT_G_VERIFY,
2723 .name = "verify_backlog_batch",
2724 .lname = "Verify backlog batch",
2725 .type = FIO_OPT_INT,
2726 .off1 = offsetof(struct thread_options, verify_batch),
2727 .help = "Verify this number of IO blocks",
2730 .category = FIO_OPT_C_IO,
2731 .group = FIO_OPT_G_VERIFY,
2733 #ifdef FIO_HAVE_CPU_AFFINITY
2735 .name = "verify_async_cpus",
2736 .lname = "Async verify CPUs",
2737 .type = FIO_OPT_STR,
2738 .cb = str_verify_cpus_allowed_cb,
2739 .off1 = offsetof(struct thread_options, verify_cpumask),
2740 .help = "Set CPUs allowed for async verify threads",
2741 .parent = "verify_async",
2743 .category = FIO_OPT_C_IO,
2744 .group = FIO_OPT_G_VERIFY,
2748 .name = "verify_async_cpus",
2749 .lname = "Async verify CPUs",
2750 .type = FIO_OPT_UNSUPPORTED,
2751 .help = "Your platform does not support CPU affinities",
2755 .name = "experimental_verify",
2756 .lname = "Experimental Verify",
2757 .off1 = offsetof(struct thread_options, experimental_verify),
2758 .type = FIO_OPT_BOOL,
2759 .help = "Enable experimental verification",
2761 .category = FIO_OPT_C_IO,
2762 .group = FIO_OPT_G_VERIFY,
2765 .name = "verify_state_load",
2766 .lname = "Load verify state",
2767 .off1 = offsetof(struct thread_options, verify_state),
2768 .type = FIO_OPT_BOOL,
2769 .help = "Load verify termination state",
2771 .category = FIO_OPT_C_IO,
2772 .group = FIO_OPT_G_VERIFY,
2775 .name = "verify_state_save",
2776 .lname = "Save verify state",
2777 .off1 = offsetof(struct thread_options, verify_state_save),
2778 .type = FIO_OPT_BOOL,
2780 .help = "Save verify state on termination",
2782 .category = FIO_OPT_C_IO,
2783 .group = FIO_OPT_G_VERIFY,
2785 #ifdef FIO_HAVE_TRIM
2787 .name = "trim_percentage",
2788 .lname = "Trim percentage",
2789 .type = FIO_OPT_INT,
2790 .off1 = offsetof(struct thread_options, trim_percentage),
2793 .help = "Number of verify blocks to discard/trim",
2798 .category = FIO_OPT_C_IO,
2799 .group = FIO_OPT_G_TRIM,
2802 .name = "trim_verify_zero",
2803 .lname = "Verify trim zero",
2804 .type = FIO_OPT_BOOL,
2805 .help = "Verify that trim/discarded blocks are returned as zeroes",
2806 .off1 = offsetof(struct thread_options, trim_zero),
2807 .parent = "trim_percentage",
2810 .category = FIO_OPT_C_IO,
2811 .group = FIO_OPT_G_TRIM,
2814 .name = "trim_backlog",
2815 .lname = "Trim backlog",
2816 .type = FIO_OPT_STR_VAL,
2817 .off1 = offsetof(struct thread_options, trim_backlog),
2818 .help = "Trim after this number of blocks are written",
2819 .parent = "trim_percentage",
2822 .category = FIO_OPT_C_IO,
2823 .group = FIO_OPT_G_TRIM,
2826 .name = "trim_backlog_batch",
2827 .lname = "Trim backlog batch",
2828 .type = FIO_OPT_INT,
2829 .off1 = offsetof(struct thread_options, trim_batch),
2830 .help = "Trim this number of IO blocks",
2831 .parent = "trim_percentage",
2834 .category = FIO_OPT_C_IO,
2835 .group = FIO_OPT_G_TRIM,
2839 .name = "trim_percentage",
2840 .lname = "Trim percentage",
2841 .type = FIO_OPT_UNSUPPORTED,
2842 .help = "Fio does not support TRIM on your platform",
2845 .name = "trim_verify_zero",
2846 .lname = "Verify trim zero",
2847 .type = FIO_OPT_UNSUPPORTED,
2848 .help = "Fio does not support TRIM on your platform",
2851 .name = "trim_backlog",
2852 .lname = "Trim backlog",
2853 .type = FIO_OPT_UNSUPPORTED,
2854 .help = "Fio does not support TRIM on your platform",
2857 .name = "trim_backlog_batch",
2858 .lname = "Trim backlog batch",
2859 .type = FIO_OPT_UNSUPPORTED,
2860 .help = "Fio does not support TRIM on your platform",
2864 .name = "write_iolog",
2865 .lname = "Write I/O log",
2866 .type = FIO_OPT_STR_STORE,
2867 .off1 = offsetof(struct thread_options, write_iolog_file),
2868 .help = "Store IO pattern to file",
2869 .category = FIO_OPT_C_IO,
2870 .group = FIO_OPT_G_IOLOG,
2873 .name = "read_iolog",
2874 .lname = "Read I/O log",
2875 .type = FIO_OPT_STR_STORE,
2876 .off1 = offsetof(struct thread_options, read_iolog_file),
2877 .help = "Playback IO pattern from file",
2878 .category = FIO_OPT_C_IO,
2879 .group = FIO_OPT_G_IOLOG,
2882 .name = "replay_no_stall",
2883 .lname = "Don't stall on replay",
2884 .type = FIO_OPT_BOOL,
2885 .off1 = offsetof(struct thread_options, no_stall),
2887 .parent = "read_iolog",
2889 .help = "Playback IO pattern file as fast as possible without stalls",
2890 .category = FIO_OPT_C_IO,
2891 .group = FIO_OPT_G_IOLOG,
2894 .name = "replay_redirect",
2895 .lname = "Redirect device for replay",
2896 .type = FIO_OPT_STR_STORE,
2897 .off1 = offsetof(struct thread_options, replay_redirect),
2898 .parent = "read_iolog",
2900 .help = "Replay all I/O onto this device, regardless of trace device",
2901 .category = FIO_OPT_C_IO,
2902 .group = FIO_OPT_G_IOLOG,
2905 .name = "replay_scale",
2906 .lname = "Replace offset scale factor",
2907 .type = FIO_OPT_INT,
2908 .off1 = offsetof(struct thread_options, replay_scale),
2909 .parent = "read_iolog",
2911 .help = "Align offsets to this blocksize",
2912 .category = FIO_OPT_C_IO,
2913 .group = FIO_OPT_G_IOLOG,
2916 .name = "replay_align",
2917 .lname = "Replace alignment",
2918 .type = FIO_OPT_INT,
2919 .off1 = offsetof(struct thread_options, replay_align),
2920 .parent = "read_iolog",
2921 .help = "Scale offset down by this factor",
2922 .category = FIO_OPT_C_IO,
2923 .group = FIO_OPT_G_IOLOG,
2927 .name = "exec_prerun",
2928 .lname = "Pre-execute runnable",
2929 .type = FIO_OPT_STR_STORE,
2930 .off1 = offsetof(struct thread_options, exec_prerun),
2931 .help = "Execute this file prior to running job",
2932 .category = FIO_OPT_C_GENERAL,
2933 .group = FIO_OPT_G_INVALID,
2936 .name = "exec_postrun",
2937 .lname = "Post-execute runnable",
2938 .type = FIO_OPT_STR_STORE,
2939 .off1 = offsetof(struct thread_options, exec_postrun),
2940 .help = "Execute this file after running job",
2941 .category = FIO_OPT_C_GENERAL,
2942 .group = FIO_OPT_G_INVALID,
2944 #ifdef FIO_HAVE_IOSCHED_SWITCH
2946 .name = "ioscheduler",
2947 .lname = "I/O scheduler",
2948 .type = FIO_OPT_STR_STORE,
2949 .off1 = offsetof(struct thread_options, ioscheduler),
2950 .help = "Use this IO scheduler on the backing device",
2951 .category = FIO_OPT_C_FILE,
2952 .group = FIO_OPT_G_INVALID,
2956 .name = "ioscheduler",
2957 .lname = "I/O scheduler",
2958 .type = FIO_OPT_UNSUPPORTED,
2959 .help = "Your platform does not support IO scheduler switching",
2964 .lname = "Zone size",
2965 .type = FIO_OPT_STR_VAL,
2966 .off1 = offsetof(struct thread_options, zone_size),
2967 .help = "Amount of data to read per zone",
2969 .interval = 1024 * 1024,
2970 .category = FIO_OPT_C_IO,
2971 .group = FIO_OPT_G_ZONE,
2974 .name = "zonerange",
2975 .lname = "Zone range",
2976 .type = FIO_OPT_STR_VAL,
2977 .off1 = offsetof(struct thread_options, zone_range),
2978 .help = "Give size of an IO zone",
2980 .interval = 1024 * 1024,
2981 .category = FIO_OPT_C_IO,
2982 .group = FIO_OPT_G_ZONE,
2986 .lname = "Zone skip",
2987 .type = FIO_OPT_STR_VAL,
2988 .off1 = offsetof(struct thread_options, zone_skip),
2989 .help = "Space between IO zones",
2991 .interval = 1024 * 1024,
2992 .category = FIO_OPT_C_IO,
2993 .group = FIO_OPT_G_ZONE,
2997 .lname = "Lock memory",
2998 .type = FIO_OPT_STR_VAL,
2999 .off1 = offsetof(struct thread_options, lockmem),
3000 .help = "Lock down this amount of memory (per worker)",
3002 .interval = 1024 * 1024,
3003 .category = FIO_OPT_C_GENERAL,
3004 .group = FIO_OPT_G_INVALID,
3007 .name = "rwmixread",
3008 .lname = "Read/write mix read",
3009 .type = FIO_OPT_INT,
3010 .cb = str_rwmix_read_cb,
3011 .off1 = offsetof(struct thread_options, rwmix[DDIR_READ]),
3013 .help = "Percentage of mixed workload that is reads",
3016 .inverse = "rwmixwrite",
3017 .category = FIO_OPT_C_IO,
3018 .group = FIO_OPT_G_RWMIX,
3021 .name = "rwmixwrite",
3022 .lname = "Read/write mix write",
3023 .type = FIO_OPT_INT,
3024 .cb = str_rwmix_write_cb,
3025 .off1 = offsetof(struct thread_options, rwmix[DDIR_WRITE]),
3027 .help = "Percentage of mixed workload that is writes",
3030 .inverse = "rwmixread",
3031 .category = FIO_OPT_C_IO,
3032 .group = FIO_OPT_G_RWMIX,
3035 .name = "rwmixcycle",
3036 .lname = "Read/write mix cycle",
3037 .type = FIO_OPT_DEPRECATED,
3038 .category = FIO_OPT_C_IO,
3039 .group = FIO_OPT_G_RWMIX,
3044 .type = FIO_OPT_INT,
3045 .off1 = offsetof(struct thread_options, nice),
3046 .help = "Set job CPU nice value",
3051 .category = FIO_OPT_C_GENERAL,
3052 .group = FIO_OPT_G_CRED,
3054 #ifdef FIO_HAVE_IOPRIO
3057 .lname = "I/O nice priority",
3058 .type = FIO_OPT_INT,
3059 .off1 = offsetof(struct thread_options, ioprio),
3060 .help = "Set job IO priority value",
3061 .minval = IOPRIO_MIN_PRIO,
3062 .maxval = IOPRIO_MAX_PRIO,
3064 .category = FIO_OPT_C_GENERAL,
3065 .group = FIO_OPT_G_CRED,
3070 .lname = "I/O nice priority",
3071 .type = FIO_OPT_UNSUPPORTED,
3072 .help = "Your platform does not support IO priorities",
3075 #ifdef FIO_HAVE_IOPRIO_CLASS
3076 #ifndef FIO_HAVE_IOPRIO
3077 #error "FIO_HAVE_IOPRIO_CLASS requires FIO_HAVE_IOPRIO"
3080 .name = "prioclass",
3081 .lname = "I/O nice priority class",
3082 .type = FIO_OPT_INT,
3083 .off1 = offsetof(struct thread_options, ioprio_class),
3084 .help = "Set job IO priority class",
3085 .minval = IOPRIO_MIN_PRIO_CLASS,
3086 .maxval = IOPRIO_MAX_PRIO_CLASS,
3088 .category = FIO_OPT_C_GENERAL,
3089 .group = FIO_OPT_G_CRED,
3093 .name = "prioclass",
3094 .lname = "I/O nice priority class",
3095 .type = FIO_OPT_UNSUPPORTED,
3096 .help = "Your platform does not support IO priority classes",
3100 .name = "thinktime",
3101 .lname = "Thinktime",
3102 .type = FIO_OPT_INT,
3103 .off1 = offsetof(struct thread_options, thinktime),
3104 .help = "Idle time between IO buffers (usec)",
3107 .category = FIO_OPT_C_IO,
3108 .group = FIO_OPT_G_THINKTIME,
3111 .name = "thinktime_spin",
3112 .lname = "Thinktime spin",
3113 .type = FIO_OPT_INT,
3114 .off1 = offsetof(struct thread_options, thinktime_spin),
3115 .help = "Start think time by spinning this amount (usec)",
3118 .parent = "thinktime",
3120 .category = FIO_OPT_C_IO,
3121 .group = FIO_OPT_G_THINKTIME,
3124 .name = "thinktime_blocks",
3125 .lname = "Thinktime blocks",
3126 .type = FIO_OPT_INT,
3127 .off1 = offsetof(struct thread_options, thinktime_blocks),
3128 .help = "IO buffer period between 'thinktime'",
3130 .parent = "thinktime",
3132 .category = FIO_OPT_C_IO,
3133 .group = FIO_OPT_G_THINKTIME,
3137 .lname = "I/O rate",
3138 .type = FIO_OPT_INT,
3139 .off1 = offsetof(struct thread_options, rate[DDIR_READ]),
3140 .off2 = offsetof(struct thread_options, rate[DDIR_WRITE]),
3141 .off3 = offsetof(struct thread_options, rate[DDIR_TRIM]),
3142 .help = "Set bandwidth rate",
3143 .category = FIO_OPT_C_IO,
3144 .group = FIO_OPT_G_RATE,
3149 .lname = "I/O min rate",
3150 .type = FIO_OPT_INT,
3151 .off1 = offsetof(struct thread_options, ratemin[DDIR_READ]),
3152 .off2 = offsetof(struct thread_options, ratemin[DDIR_WRITE]),
3153 .off3 = offsetof(struct thread_options, ratemin[DDIR_TRIM]),
3154 .help = "Job must meet this rate or it will be shutdown",
3157 .category = FIO_OPT_C_IO,
3158 .group = FIO_OPT_G_RATE,
3161 .name = "rate_iops",
3162 .lname = "I/O rate IOPS",
3163 .type = FIO_OPT_INT,
3164 .off1 = offsetof(struct thread_options, rate_iops[DDIR_READ]),
3165 .off2 = offsetof(struct thread_options, rate_iops[DDIR_WRITE]),
3166 .off3 = offsetof(struct thread_options, rate_iops[DDIR_TRIM]),
3167 .help = "Limit IO used to this number of IO operations/sec",
3169 .category = FIO_OPT_C_IO,
3170 .group = FIO_OPT_G_RATE,
3173 .name = "rate_iops_min",
3174 .lname = "I/O min rate IOPS",
3175 .type = FIO_OPT_INT,
3176 .off1 = offsetof(struct thread_options, rate_iops_min[DDIR_READ]),
3177 .off2 = offsetof(struct thread_options, rate_iops_min[DDIR_WRITE]),
3178 .off3 = offsetof(struct thread_options, rate_iops_min[DDIR_TRIM]),
3179 .help = "Job must meet this rate or it will be shut down",
3180 .parent = "rate_iops",
3182 .category = FIO_OPT_C_IO,
3183 .group = FIO_OPT_G_RATE,
3186 .name = "rate_process",
3187 .lname = "Rate Process",
3188 .type = FIO_OPT_STR,
3189 .off1 = offsetof(struct thread_options, rate_process),
3190 .help = "What process controls how rated IO is managed",
3192 .category = FIO_OPT_C_IO,
3193 .group = FIO_OPT_G_RATE,
3196 .oval = RATE_PROCESS_LINEAR,
3197 .help = "Linear rate of IO",
3201 .oval = RATE_PROCESS_POISSON,
3202 .help = "Rate follows Poisson process",
3208 .name = "rate_cycle",
3209 .alias = "ratecycle",
3210 .lname = "I/O rate cycle",
3211 .type = FIO_OPT_INT,
3212 .off1 = offsetof(struct thread_options, ratecycle),
3213 .help = "Window average for rate limits (msec)",
3217 .category = FIO_OPT_C_IO,
3218 .group = FIO_OPT_G_RATE,
3221 .name = "max_latency",
3222 .lname = "Max Latency",
3223 .type = FIO_OPT_INT,
3224 .off1 = offsetof(struct thread_options, max_latency),
3225 .help = "Maximum tolerated IO latency (usec)",
3227 .category = FIO_OPT_C_IO,
3228 .group = FIO_OPT_G_LATPROF,
3231 .name = "latency_target",
3232 .lname = "Latency Target (usec)",
3233 .type = FIO_OPT_STR_VAL_TIME,
3234 .off1 = offsetof(struct thread_options, latency_target),
3235 .help = "Ramp to max queue depth supporting this latency",
3237 .category = FIO_OPT_C_IO,
3238 .group = FIO_OPT_G_LATPROF,
3241 .name = "latency_window",
3242 .lname = "Latency Window (usec)",
3243 .type = FIO_OPT_STR_VAL_TIME,
3244 .off1 = offsetof(struct thread_options, latency_window),
3245 .help = "Time to sustain latency_target",
3247 .category = FIO_OPT_C_IO,
3248 .group = FIO_OPT_G_LATPROF,
3251 .name = "latency_percentile",
3252 .lname = "Latency Percentile",
3253 .type = FIO_OPT_FLOAT_LIST,
3254 .off1 = offsetof(struct thread_options, latency_percentile),
3255 .help = "Percentile of IOs must be below latency_target",
3260 .category = FIO_OPT_C_IO,
3261 .group = FIO_OPT_G_LATPROF,
3264 .name = "invalidate",
3265 .lname = "Cache invalidate",
3266 .type = FIO_OPT_BOOL,
3267 .off1 = offsetof(struct thread_options, invalidate_cache),
3268 .help = "Invalidate buffer/page cache prior to running job",
3270 .category = FIO_OPT_C_IO,
3271 .group = FIO_OPT_G_IO_TYPE,
3275 .lname = "Synchronous I/O",
3276 .type = FIO_OPT_BOOL,
3277 .off1 = offsetof(struct thread_options, sync_io),
3278 .help = "Use O_SYNC for buffered writes",
3280 .parent = "buffered",
3282 .category = FIO_OPT_C_IO,
3283 .group = FIO_OPT_G_IO_TYPE,
3286 .name = "create_serialize",
3287 .lname = "Create serialize",
3288 .type = FIO_OPT_BOOL,
3289 .off1 = offsetof(struct thread_options, create_serialize),
3290 .help = "Serialize creation of job files",
3292 .category = FIO_OPT_C_FILE,
3293 .group = FIO_OPT_G_INVALID,
3296 .name = "create_fsync",
3297 .lname = "Create fsync",
3298 .type = FIO_OPT_BOOL,
3299 .off1 = offsetof(struct thread_options, create_fsync),
3300 .help = "fsync file after creation",
3302 .category = FIO_OPT_C_FILE,
3303 .group = FIO_OPT_G_INVALID,
3306 .name = "create_on_open",
3307 .lname = "Create on open",
3308 .type = FIO_OPT_BOOL,
3309 .off1 = offsetof(struct thread_options, create_on_open),
3310 .help = "Create files when they are opened for IO",
3312 .category = FIO_OPT_C_FILE,
3313 .group = FIO_OPT_G_INVALID,
3316 .name = "create_only",
3317 .lname = "Create Only",
3318 .type = FIO_OPT_BOOL,
3319 .off1 = offsetof(struct thread_options, create_only),
3320 .help = "Only perform file creation phase",
3321 .category = FIO_OPT_C_FILE,
3325 .name = "allow_file_create",
3326 .lname = "Allow file create",
3327 .type = FIO_OPT_BOOL,
3328 .off1 = offsetof(struct thread_options, allow_create),
3329 .help = "Permit fio to create files, if they don't exist",
3331 .category = FIO_OPT_C_FILE,
3332 .group = FIO_OPT_G_FILENAME,
3335 .name = "allow_mounted_write",
3336 .lname = "Allow mounted write",
3337 .type = FIO_OPT_BOOL,
3338 .off1 = offsetof(struct thread_options, allow_mounted_write),
3339 .help = "Allow writes to a mounted partition",
3341 .category = FIO_OPT_C_FILE,
3342 .group = FIO_OPT_G_FILENAME,
3346 .lname = "Pre-read files",
3347 .type = FIO_OPT_BOOL,
3348 .off1 = offsetof(struct thread_options, pre_read),
3349 .help = "Pre-read files before starting official testing",
3351 .category = FIO_OPT_C_FILE,
3352 .group = FIO_OPT_G_INVALID,
3354 #ifdef FIO_HAVE_CPU_AFFINITY
3357 .lname = "CPU mask",
3358 .type = FIO_OPT_INT,
3359 .cb = str_cpumask_cb,
3360 .off1 = offsetof(struct thread_options, cpumask),
3361 .help = "CPU affinity mask",
3362 .category = FIO_OPT_C_GENERAL,
3363 .group = FIO_OPT_G_CRED,
3366 .name = "cpus_allowed",
3367 .lname = "CPUs allowed",
3368 .type = FIO_OPT_STR,
3369 .cb = str_cpus_allowed_cb,
3370 .off1 = offsetof(struct thread_options, cpumask),
3371 .help = "Set CPUs allowed",
3372 .category = FIO_OPT_C_GENERAL,
3373 .group = FIO_OPT_G_CRED,
3376 .name = "cpus_allowed_policy",
3377 .lname = "CPUs allowed distribution policy",
3378 .type = FIO_OPT_STR,
3379 .off1 = offsetof(struct thread_options, cpus_allowed_policy),
3380 .help = "Distribution policy for cpus_allowed",
3381 .parent = "cpus_allowed",
3385 .oval = FIO_CPUS_SHARED,
3386 .help = "Mask shared between threads",
3389 .oval = FIO_CPUS_SPLIT,
3390 .help = "Mask split between threads",
3393 .category = FIO_OPT_C_GENERAL,
3394 .group = FIO_OPT_G_CRED,
3399 .lname = "CPU mask",
3400 .type = FIO_OPT_UNSUPPORTED,
3401 .help = "Your platform does not support CPU affinities",
3404 .name = "cpus_allowed",
3405 .lname = "CPUs allowed",
3406 .type = FIO_OPT_UNSUPPORTED,
3407 .help = "Your platform does not support CPU affinities",
3410 .name = "cpus_allowed_policy",
3411 .lname = "CPUs allowed distribution policy",
3412 .type = FIO_OPT_UNSUPPORTED,
3413 .help = "Your platform does not support CPU affinities",
3416 #ifdef CONFIG_LIBNUMA
3418 .name = "numa_cpu_nodes",
3419 .lname = "NUMA CPU Nodes",
3420 .type = FIO_OPT_STR,
3421 .cb = str_numa_cpunodes_cb,
3422 .off1 = offsetof(struct thread_options, numa_cpunodes),
3423 .help = "NUMA CPU nodes bind",
3424 .category = FIO_OPT_C_GENERAL,
3425 .group = FIO_OPT_G_INVALID,
3428 .name = "numa_mem_policy",
3429 .lname = "NUMA Memory Policy",
3430 .type = FIO_OPT_STR,
3431 .cb = str_numa_mpol_cb,
3432 .off1 = offsetof(struct thread_options, numa_memnodes),
3433 .help = "NUMA memory policy setup",
3434 .category = FIO_OPT_C_GENERAL,
3435 .group = FIO_OPT_G_INVALID,
3439 .name = "numa_cpu_nodes",
3440 .lname = "NUMA CPU Nodes",
3441 .type = FIO_OPT_UNSUPPORTED,
3442 .help = "Build fio with libnuma-dev(el) to enable this option",
3445 .name = "numa_mem_policy",
3446 .lname = "NUMA Memory Policy",
3447 .type = FIO_OPT_UNSUPPORTED,
3448 .help = "Build fio with libnuma-dev(el) to enable this option",
3452 .name = "end_fsync",
3453 .lname = "End fsync",
3454 .type = FIO_OPT_BOOL,
3455 .off1 = offsetof(struct thread_options, end_fsync),
3456 .help = "Include fsync at the end of job",
3458 .category = FIO_OPT_C_FILE,
3459 .group = FIO_OPT_G_INVALID,
3462 .name = "fsync_on_close",
3463 .lname = "Fsync on close",
3464 .type = FIO_OPT_BOOL,
3465 .off1 = offsetof(struct thread_options, fsync_on_close),
3466 .help = "fsync files on close",
3468 .category = FIO_OPT_C_FILE,
3469 .group = FIO_OPT_G_INVALID,
3473 .lname = "Unlink file",
3474 .type = FIO_OPT_BOOL,
3475 .off1 = offsetof(struct thread_options, unlink),
3476 .help = "Unlink created files after job has completed",
3478 .category = FIO_OPT_C_FILE,
3479 .group = FIO_OPT_G_INVALID,
3482 .name = "unlink_each_loop",
3483 .lname = "Unlink file after each loop of a job",
3484 .type = FIO_OPT_BOOL,
3485 .off1 = offsetof(struct thread_options, unlink_each_loop),
3486 .help = "Unlink created files after each loop in a job has completed",
3488 .category = FIO_OPT_C_FILE,
3489 .group = FIO_OPT_G_INVALID,
3493 .lname = "Exit-all on terminate",
3494 .type = FIO_OPT_STR_SET,
3495 .cb = str_exitall_cb,
3496 .help = "Terminate all jobs when one exits",
3497 .category = FIO_OPT_C_GENERAL,
3498 .group = FIO_OPT_G_PROCESS,
3501 .name = "exitall_on_error",
3502 .lname = "Exit-all on terminate in error",
3503 .type = FIO_OPT_STR_SET,
3504 .off1 = offsetof(struct thread_options, exitall_error),
3505 .help = "Terminate all jobs when one exits in error",
3506 .category = FIO_OPT_C_GENERAL,
3507 .group = FIO_OPT_G_PROCESS,
3510 .name = "stonewall",
3511 .lname = "Wait for previous",
3512 .alias = "wait_for_previous",
3513 .type = FIO_OPT_STR_SET,
3514 .off1 = offsetof(struct thread_options, stonewall),
3515 .help = "Insert a hard barrier between this job and previous",
3516 .category = FIO_OPT_C_GENERAL,
3517 .group = FIO_OPT_G_PROCESS,
3520 .name = "new_group",
3521 .lname = "New group",
3522 .type = FIO_OPT_STR_SET,
3523 .off1 = offsetof(struct thread_options, new_group),
3524 .help = "Mark the start of a new group (for reporting)",
3525 .category = FIO_OPT_C_GENERAL,
3526 .group = FIO_OPT_G_PROCESS,
3531 .type = FIO_OPT_STR_SET,
3532 .off1 = offsetof(struct thread_options, use_thread),
3533 .help = "Use threads instead of processes",
3534 #ifdef CONFIG_NO_SHM
3538 .category = FIO_OPT_C_GENERAL,
3539 .group = FIO_OPT_G_PROCESS,
3542 .name = "per_job_logs",
3543 .lname = "Per Job Logs",
3544 .type = FIO_OPT_BOOL,
3545 .off1 = offsetof(struct thread_options, per_job_logs),
3546 .help = "Include job number in generated log files or not",
3548 .category = FIO_OPT_C_LOG,
3549 .group = FIO_OPT_G_INVALID,
3552 .name = "write_bw_log",
3553 .lname = "Write bandwidth log",
3554 .type = FIO_OPT_STR,
3555 .off1 = offsetof(struct thread_options, bw_log_file),
3556 .cb = str_write_bw_log_cb,
3557 .help = "Write log of bandwidth during run",
3558 .category = FIO_OPT_C_LOG,
3559 .group = FIO_OPT_G_INVALID,
3562 .name = "write_lat_log",
3563 .lname = "Write latency log",
3564 .type = FIO_OPT_STR,
3565 .off1 = offsetof(struct thread_options, lat_log_file),
3566 .cb = str_write_lat_log_cb,
3567 .help = "Write log of latency during run",
3568 .category = FIO_OPT_C_LOG,
3569 .group = FIO_OPT_G_INVALID,
3572 .name = "write_iops_log",
3573 .lname = "Write IOPS log",
3574 .type = FIO_OPT_STR,
3575 .off1 = offsetof(struct thread_options, iops_log_file),
3576 .cb = str_write_iops_log_cb,
3577 .help = "Write log of IOPS during run",
3578 .category = FIO_OPT_C_LOG,
3579 .group = FIO_OPT_G_INVALID,
3582 .name = "log_avg_msec",
3583 .lname = "Log averaging (msec)",
3584 .type = FIO_OPT_INT,
3585 .off1 = offsetof(struct thread_options, log_avg_msec),
3586 .help = "Average bw/iops/lat logs over this period of time",
3588 .category = FIO_OPT_C_LOG,
3589 .group = FIO_OPT_G_INVALID,
3592 .name = "log_hist_msec",
3593 .lname = "Log histograms (msec)",
3594 .type = FIO_OPT_INT,
3595 .off1 = offsetof(struct thread_options, log_hist_msec),
3596 .help = "Dump completion latency histograms at frequency of this time value",
3598 .category = FIO_OPT_C_LOG,
3599 .group = FIO_OPT_G_INVALID,
3602 .name = "log_hist_coarseness",
3603 .lname = "Histogram logs coarseness",
3604 .type = FIO_OPT_INT,
3605 .off1 = offsetof(struct thread_options, log_hist_coarseness),
3606 .help = "Integer in range [0,6]. Higher coarseness outputs"
3607 " fewer histogram bins per sample. The number of bins for"
3608 " these are [1216, 608, 304, 152, 76, 38, 19] respectively.",
3610 .category = FIO_OPT_C_LOG,
3611 .group = FIO_OPT_G_INVALID,
3614 .name = "write_hist_log",
3615 .lname = "Write latency histogram logs",
3616 .type = FIO_OPT_STR,
3617 .off1 = offsetof(struct thread_options, hist_log_file),
3618 .cb = str_write_hist_log_cb,
3619 .help = "Write log of latency histograms during run",
3620 .category = FIO_OPT_C_LOG,
3621 .group = FIO_OPT_G_INVALID,
3624 .name = "log_max_value",
3625 .lname = "Log maximum instead of average",
3626 .type = FIO_OPT_BOOL,
3627 .off1 = offsetof(struct thread_options, log_max),
3628 .help = "Log max sample in a window instead of average",
3630 .category = FIO_OPT_C_LOG,
3631 .group = FIO_OPT_G_INVALID,
3634 .name = "log_offset",
3635 .lname = "Log offset of IO",
3636 .type = FIO_OPT_BOOL,
3637 .off1 = offsetof(struct thread_options, log_offset),
3638 .help = "Include offset of IO for each log entry",
3640 .category = FIO_OPT_C_LOG,
3641 .group = FIO_OPT_G_INVALID,
3645 .name = "log_compression",
3646 .lname = "Log compression",
3647 .type = FIO_OPT_INT,
3648 .off1 = offsetof(struct thread_options, log_gz),
3649 .help = "Log in compressed chunks of this size",
3651 .maxval = 512 * 1024 * 1024ULL,
3652 .category = FIO_OPT_C_LOG,
3653 .group = FIO_OPT_G_INVALID,
3655 #ifdef FIO_HAVE_CPU_AFFINITY
3657 .name = "log_compression_cpus",
3658 .lname = "Log Compression CPUs",
3659 .type = FIO_OPT_STR,
3660 .cb = str_log_cpus_allowed_cb,
3661 .off1 = offsetof(struct thread_options, log_gz_cpumask),
3662 .parent = "log_compression",
3663 .help = "Limit log compression to these CPUs",
3664 .category = FIO_OPT_C_LOG,
3665 .group = FIO_OPT_G_INVALID,
3669 .name = "log_compression_cpus",
3670 .lname = "Log Compression CPUs",
3671 .type = FIO_OPT_UNSUPPORTED,
3672 .help = "Your platform does not support CPU affinities",
3676 .name = "log_store_compressed",
3677 .lname = "Log store compressed",
3678 .type = FIO_OPT_BOOL,
3679 .off1 = offsetof(struct thread_options, log_gz_store),
3680 .help = "Store logs in a compressed format",
3681 .category = FIO_OPT_C_LOG,
3682 .group = FIO_OPT_G_INVALID,
3686 .name = "log_compression",
3687 .lname = "Log compression",
3688 .type = FIO_OPT_UNSUPPORTED,
3689 .help = "Install libz-dev(el) to get compression support",
3692 .name = "log_store_compressed",
3693 .lname = "Log store compressed",
3694 .type = FIO_OPT_UNSUPPORTED,
3695 .help = "Install libz-dev(el) to get compression support",
3699 .name = "log_unix_epoch",
3700 .lname = "Log epoch unix",
3701 .type = FIO_OPT_BOOL,
3702 .off1 = offsetof(struct thread_options, log_unix_epoch),
3703 .help = "Use Unix time in log files",
3704 .category = FIO_OPT_C_LOG,
3705 .group = FIO_OPT_G_INVALID,
3708 .name = "block_error_percentiles",
3709 .lname = "Block error percentiles",
3710 .type = FIO_OPT_BOOL,
3711 .off1 = offsetof(struct thread_options, block_error_hist),
3712 .help = "Record trim block errors and make a histogram",
3714 .category = FIO_OPT_C_LOG,
3715 .group = FIO_OPT_G_INVALID,
3718 .name = "bwavgtime",
3719 .lname = "Bandwidth average time",
3720 .type = FIO_OPT_INT,
3721 .off1 = offsetof(struct thread_options, bw_avg_time),
3722 .help = "Time window over which to calculate bandwidth"
3725 .parent = "write_bw_log",
3728 .category = FIO_OPT_C_LOG,
3729 .group = FIO_OPT_G_INVALID,
3732 .name = "iopsavgtime",
3733 .lname = "IOPS average time",
3734 .type = FIO_OPT_INT,
3735 .off1 = offsetof(struct thread_options, iops_avg_time),
3736 .help = "Time window over which to calculate IOPS (msec)",
3738 .parent = "write_iops_log",
3741 .category = FIO_OPT_C_LOG,
3742 .group = FIO_OPT_G_INVALID,
3745 .name = "group_reporting",
3746 .lname = "Group reporting",
3747 .type = FIO_OPT_STR_SET,
3748 .off1 = offsetof(struct thread_options, group_reporting),
3749 .help = "Do reporting on a per-group basis",
3750 .category = FIO_OPT_C_STAT,
3751 .group = FIO_OPT_G_INVALID,
3754 .name = "zero_buffers",
3755 .lname = "Zero I/O buffers",
3756 .type = FIO_OPT_STR_SET,
3757 .off1 = offsetof(struct thread_options, zero_buffers),
3758 .help = "Init IO buffers to all zeroes",
3759 .category = FIO_OPT_C_IO,
3760 .group = FIO_OPT_G_IO_BUF,
3763 .name = "refill_buffers",
3764 .lname = "Refill I/O buffers",
3765 .type = FIO_OPT_STR_SET,
3766 .off1 = offsetof(struct thread_options, refill_buffers),
3767 .help = "Refill IO buffers on every IO submit",
3768 .category = FIO_OPT_C_IO,
3769 .group = FIO_OPT_G_IO_BUF,
3772 .name = "scramble_buffers",
3773 .lname = "Scramble I/O buffers",
3774 .type = FIO_OPT_BOOL,
3775 .off1 = offsetof(struct thread_options, scramble_buffers),
3776 .help = "Slightly scramble buffers on every IO submit",
3778 .category = FIO_OPT_C_IO,
3779 .group = FIO_OPT_G_IO_BUF,
3782 .name = "buffer_pattern",
3783 .lname = "Buffer pattern",
3784 .type = FIO_OPT_STR,
3785 .cb = str_buffer_pattern_cb,
3786 .off1 = offsetof(struct thread_options, buffer_pattern),
3787 .help = "Fill pattern for IO buffers",
3788 .category = FIO_OPT_C_IO,
3789 .group = FIO_OPT_G_IO_BUF,
3792 .name = "buffer_compress_percentage",
3793 .lname = "Buffer compression percentage",
3794 .type = FIO_OPT_INT,
3795 .cb = str_buffer_compress_cb,
3796 .off1 = offsetof(struct thread_options, compress_percentage),
3799 .help = "How compressible the buffer is (approximately)",
3801 .category = FIO_OPT_C_IO,
3802 .group = FIO_OPT_G_IO_BUF,
3805 .name = "buffer_compress_chunk",
3806 .lname = "Buffer compression chunk size",
3807 .type = FIO_OPT_INT,
3808 .off1 = offsetof(struct thread_options, compress_chunk),
3809 .parent = "buffer_compress_percentage",
3811 .help = "Size of compressible region in buffer",
3813 .category = FIO_OPT_C_IO,
3814 .group = FIO_OPT_G_IO_BUF,
3817 .name = "dedupe_percentage",
3818 .lname = "Dedupe percentage",
3819 .type = FIO_OPT_INT,
3820 .cb = str_dedupe_cb,
3821 .off1 = offsetof(struct thread_options, dedupe_percentage),
3824 .help = "Percentage of buffers that are dedupable",
3826 .category = FIO_OPT_C_IO,
3827 .group = FIO_OPT_G_IO_BUF,
3830 .name = "clat_percentiles",
3831 .lname = "Completion latency percentiles",
3832 .type = FIO_OPT_BOOL,
3833 .off1 = offsetof(struct thread_options, clat_percentiles),
3834 .help = "Enable the reporting of completion latency percentiles",
3836 .category = FIO_OPT_C_STAT,
3837 .group = FIO_OPT_G_INVALID,
3840 .name = "percentile_list",
3841 .lname = "Percentile list",
3842 .type = FIO_OPT_FLOAT_LIST,
3843 .off1 = offsetof(struct thread_options, percentile_list),
3844 .off2 = offsetof(struct thread_options, percentile_precision),
3845 .help = "Specify a custom list of percentiles to report for "
3846 "completion latency and block errors",
3847 .def = "1:5:10:20:30:40:50:60:70:80:90:95:99:99.5:99.9:99.95:99.99",
3848 .maxlen = FIO_IO_U_LIST_MAX_LEN,
3851 .category = FIO_OPT_C_STAT,
3852 .group = FIO_OPT_G_INVALID,
3855 #ifdef FIO_HAVE_DISK_UTIL
3857 .name = "disk_util",
3858 .lname = "Disk utilization",
3859 .type = FIO_OPT_BOOL,
3860 .off1 = offsetof(struct thread_options, do_disk_util),
3861 .help = "Log disk utilization statistics",
3863 .category = FIO_OPT_C_STAT,
3864 .group = FIO_OPT_G_INVALID,
3868 .name = "disk_util",
3869 .lname = "Disk utilization",
3870 .type = FIO_OPT_UNSUPPORTED,
3871 .help = "Your platform does not support disk utilization",
3875 .name = "gtod_reduce",
3876 .lname = "Reduce gettimeofday() calls",
3877 .type = FIO_OPT_BOOL,
3878 .help = "Greatly reduce number of gettimeofday() calls",
3879 .cb = str_gtod_reduce_cb,
3882 .category = FIO_OPT_C_STAT,
3883 .group = FIO_OPT_G_INVALID,
3886 .name = "disable_lat",
3887 .lname = "Disable all latency stats",
3888 .type = FIO_OPT_BOOL,
3889 .off1 = offsetof(struct thread_options, disable_lat),
3890 .help = "Disable latency numbers",
3891 .parent = "gtod_reduce",
3894 .category = FIO_OPT_C_STAT,
3895 .group = FIO_OPT_G_INVALID,
3898 .name = "disable_clat",
3899 .lname = "Disable completion latency stats",
3900 .type = FIO_OPT_BOOL,
3901 .off1 = offsetof(struct thread_options, disable_clat),
3902 .help = "Disable completion latency numbers",
3903 .parent = "gtod_reduce",
3906 .category = FIO_OPT_C_STAT,
3907 .group = FIO_OPT_G_INVALID,
3910 .name = "disable_slat",
3911 .lname = "Disable submission latency stats",
3912 .type = FIO_OPT_BOOL,
3913 .off1 = offsetof(struct thread_options, disable_slat),
3914 .help = "Disable submission latency numbers",
3915 .parent = "gtod_reduce",
3918 .category = FIO_OPT_C_STAT,
3919 .group = FIO_OPT_G_INVALID,
3922 .name = "disable_bw_measurement",
3923 .alias = "disable_bw",
3924 .lname = "Disable bandwidth stats",
3925 .type = FIO_OPT_BOOL,
3926 .off1 = offsetof(struct thread_options, disable_bw),
3927 .help = "Disable bandwidth logging",
3928 .parent = "gtod_reduce",
3931 .category = FIO_OPT_C_STAT,
3932 .group = FIO_OPT_G_INVALID,
3936 .lname = "Dedicated gettimeofday() CPU",
3937 .type = FIO_OPT_INT,
3938 .off1 = offsetof(struct thread_options, gtod_cpu),
3939 .help = "Set up dedicated gettimeofday() thread on this CPU",
3940 .verify = gtod_cpu_verify,
3941 .category = FIO_OPT_C_GENERAL,
3942 .group = FIO_OPT_G_CLOCK,
3945 .name = "unified_rw_reporting",
3946 .lname = "Unified RW Reporting",
3947 .type = FIO_OPT_BOOL,
3948 .off1 = offsetof(struct thread_options, unified_rw_rep),
3949 .help = "Unify reporting across data direction",
3951 .category = FIO_OPT_C_GENERAL,
3952 .group = FIO_OPT_G_INVALID,
3955 .name = "continue_on_error",
3956 .lname = "Continue on error",
3957 .type = FIO_OPT_STR,
3958 .off1 = offsetof(struct thread_options, continue_on_error),
3959 .help = "Continue on non-fatal errors during IO",
3961 .category = FIO_OPT_C_GENERAL,
3962 .group = FIO_OPT_G_ERR,
3965 .oval = ERROR_TYPE_NONE,
3966 .help = "Exit when an error is encountered",
3969 .oval = ERROR_TYPE_READ,
3970 .help = "Continue on read errors only",
3973 .oval = ERROR_TYPE_WRITE,
3974 .help = "Continue on write errors only",
3977 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
3978 .help = "Continue on any IO errors",
3981 .oval = ERROR_TYPE_VERIFY,
3982 .help = "Continue on verify errors only",
3985 .oval = ERROR_TYPE_ANY,
3986 .help = "Continue on all io and verify errors",
3989 .oval = ERROR_TYPE_NONE,
3990 .help = "Alias for 'none'",
3993 .oval = ERROR_TYPE_ANY,
3994 .help = "Alias for 'all'",
3999 .name = "ignore_error",
4000 .lname = "Ignore Error",
4001 .type = FIO_OPT_STR,
4002 .cb = str_ignore_error_cb,
4003 .off1 = offsetof(struct thread_options, ignore_error_nr),
4004 .help = "Set a specific list of errors to ignore",
4006 .category = FIO_OPT_C_GENERAL,
4007 .group = FIO_OPT_G_ERR,
4010 .name = "error_dump",
4011 .lname = "Error Dump",
4012 .type = FIO_OPT_BOOL,
4013 .off1 = offsetof(struct thread_options, error_dump),
4015 .help = "Dump info on each error",
4016 .category = FIO_OPT_C_GENERAL,
4017 .group = FIO_OPT_G_ERR,
4022 .type = FIO_OPT_STR_STORE,
4023 .off1 = offsetof(struct thread_options, profile),
4024 .help = "Select a specific builtin performance test",
4025 .category = FIO_OPT_C_PROFILE,
4026 .group = FIO_OPT_G_INVALID,
4031 .type = FIO_OPT_STR_STORE,
4032 .off1 = offsetof(struct thread_options, cgroup),
4033 .help = "Add job to cgroup of this name",
4034 .category = FIO_OPT_C_GENERAL,
4035 .group = FIO_OPT_G_CGROUP,
4038 .name = "cgroup_nodelete",
4039 .lname = "Cgroup no-delete",
4040 .type = FIO_OPT_BOOL,
4041 .off1 = offsetof(struct thread_options, cgroup_nodelete),
4042 .help = "Do not delete cgroups after job completion",
4045 .category = FIO_OPT_C_GENERAL,
4046 .group = FIO_OPT_G_CGROUP,
4049 .name = "cgroup_weight",
4050 .lname = "Cgroup weight",
4051 .type = FIO_OPT_INT,
4052 .off1 = offsetof(struct thread_options, cgroup_weight),
4053 .help = "Use given weight for cgroup",
4057 .category = FIO_OPT_C_GENERAL,
4058 .group = FIO_OPT_G_CGROUP,
4063 .type = FIO_OPT_INT,
4064 .off1 = offsetof(struct thread_options, uid),
4065 .help = "Run job with this user ID",
4066 .category = FIO_OPT_C_GENERAL,
4067 .group = FIO_OPT_G_CRED,
4071 .lname = "Group ID",
4072 .type = FIO_OPT_INT,
4073 .off1 = offsetof(struct thread_options, gid),
4074 .help = "Run job with this group ID",
4075 .category = FIO_OPT_C_GENERAL,
4076 .group = FIO_OPT_G_CRED,
4081 .type = FIO_OPT_INT,
4082 .off1 = offsetof(struct thread_options, kb_base),
4088 .help = "Use 1024 as the K base",
4092 .help = "Use 1000 as the K base",
4095 .help = "How many bytes per KB for reporting (1000 or 1024)",
4096 .category = FIO_OPT_C_GENERAL,
4097 .group = FIO_OPT_G_INVALID,
4100 .name = "unit_base",
4101 .lname = "Base unit for reporting (Bits or Bytes)",
4102 .type = FIO_OPT_INT,
4103 .off1 = offsetof(struct thread_options, unit_base),
4108 .help = "Auto-detect",
4112 .help = "Normal (byte based)",
4116 .help = "Bit based",
4119 .help = "Bit multiple of result summary data (8 for byte, 1 for bit)",
4120 .category = FIO_OPT_C_GENERAL,
4121 .group = FIO_OPT_G_INVALID,
4124 .name = "hugepage-size",
4125 .lname = "Hugepage size",
4126 .type = FIO_OPT_INT,
4127 .off1 = offsetof(struct thread_options, hugepage_size),
4128 .help = "When using hugepages, specify size of each page",
4129 .def = __fio_stringify(FIO_HUGE_PAGE),
4130 .interval = 1024 * 1024,
4131 .category = FIO_OPT_C_GENERAL,
4132 .group = FIO_OPT_G_INVALID,
4136 .lname = "I/O flow ID",
4137 .type = FIO_OPT_INT,
4138 .off1 = offsetof(struct thread_options, flow_id),
4139 .help = "The flow index ID to use",
4141 .category = FIO_OPT_C_IO,
4142 .group = FIO_OPT_G_IO_FLOW,
4146 .lname = "I/O flow weight",
4147 .type = FIO_OPT_INT,
4148 .off1 = offsetof(struct thread_options, flow),
4149 .help = "Weight for flow control of this job",
4150 .parent = "flow_id",
4153 .category = FIO_OPT_C_IO,
4154 .group = FIO_OPT_G_IO_FLOW,
4157 .name = "flow_watermark",
4158 .lname = "I/O flow watermark",
4159 .type = FIO_OPT_INT,
4160 .off1 = offsetof(struct thread_options, flow_watermark),
4161 .help = "High watermark for flow control. This option"
4162 " should be set to the same value for all threads"
4163 " with non-zero flow.",
4164 .parent = "flow_id",
4167 .category = FIO_OPT_C_IO,
4168 .group = FIO_OPT_G_IO_FLOW,
4171 .name = "flow_sleep",
4172 .lname = "I/O flow sleep",
4173 .type = FIO_OPT_INT,
4174 .off1 = offsetof(struct thread_options, flow_sleep),
4175 .help = "How many microseconds to sleep after being held"
4176 " back by the flow control mechanism",
4177 .parent = "flow_id",
4180 .category = FIO_OPT_C_IO,
4181 .group = FIO_OPT_G_IO_FLOW,
4185 .lname = "Skip operations against bad blocks",
4186 .type = FIO_OPT_BOOL,
4187 .off1 = offsetof(struct thread_options, skip_bad),
4188 .help = "Skip operations against known bad blocks.",
4191 .category = FIO_OPT_C_IO,
4192 .group = FIO_OPT_G_MTD,
4199 static void add_to_lopt(struct option *lopt, struct fio_option *o,
4200 const char *name, int val)
4202 lopt->name = (char *) name;
4204 if (o->type == FIO_OPT_STR_SET)
4205 lopt->has_arg = optional_argument;
4207 lopt->has_arg = required_argument;
4210 static void options_to_lopts(struct fio_option *opts,
4211 struct option *long_options,
4212 int i, int option_type)
4214 struct fio_option *o = &opts[0];
4216 add_to_lopt(&long_options[i], o, o->name, option_type);
4219 add_to_lopt(&long_options[i], o, o->alias, option_type);
4224 assert(i < FIO_NR_OPTIONS);
4228 void fio_options_set_ioengine_opts(struct option *long_options,
4229 struct thread_data *td)
4234 while (long_options[i].name) {
4235 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
4236 memset(&long_options[i], 0, sizeof(*long_options));
4243 * Just clear out the prior ioengine options.
4248 options_to_lopts(td->io_ops->options, long_options, i,
4249 FIO_GETOPT_IOENGINE);
4252 void fio_options_dup_and_init(struct option *long_options)
4256 options_init(fio_options);
4259 while (long_options[i].name)
4262 options_to_lopts(fio_options, long_options, i, FIO_GETOPT_JOB);
4265 struct fio_keyword {
4271 static struct fio_keyword fio_keywords[] = {
4273 .word = "$pagesize",
4274 .desc = "Page size in the system",
4277 .word = "$mb_memory",
4278 .desc = "Megabytes of memory online",
4282 .desc = "Number of CPUs online in the system",
4289 void fio_keywords_exit(void)
4291 struct fio_keyword *kw;
4293 kw = &fio_keywords[0];
4301 void fio_keywords_init(void)
4303 unsigned long long mb_memory;
4307 sprintf(buf, "%lu", (unsigned long) page_size);
4308 fio_keywords[0].replace = strdup(buf);
4310 mb_memory = os_phys_mem() / (1024 * 1024);
4311 sprintf(buf, "%llu", mb_memory);
4312 fio_keywords[1].replace = strdup(buf);
4315 sprintf(buf, "%lu", l);
4316 fio_keywords[2].replace = strdup(buf);
4321 static char *bc_calc(char *str)
4323 char buf[128], *tmp;
4328 * No math, just return string
4330 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
4331 !strchr(str, '/')) || strchr(str, '\''))
4335 * Split option from value, we only need to calculate the value
4337 tmp = strchr(str, '=');
4344 * Prevent buffer overflows; such a case isn't reasonable anyway
4346 if (strlen(str) >= 128 || strlen(tmp) > 100)
4349 sprintf(buf, "which %s > /dev/null", BC_APP);
4351 log_err("fio: bc is needed for performing math\n");
4355 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
4356 f = popen(buf, "r");
4360 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
4367 buf[(tmp - str) + ret - 1] = '\0';
4368 memcpy(buf, str, tmp - str);
4374 * Return a copy of the input string with substrings of the form ${VARNAME}
4375 * substituted with the value of the environment variable VARNAME. The
4376 * substitution always occurs, even if VARNAME is empty or the corresponding
4377 * environment variable undefined.
4379 static char *option_dup_subs(const char *opt)
4381 char out[OPT_LEN_MAX+1];
4382 char in[OPT_LEN_MAX+1];
4385 char *ch1, *ch2, *env;
4386 ssize_t nchr = OPT_LEN_MAX;
4389 if (strlen(opt) + 1 > OPT_LEN_MAX) {
4390 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
4394 in[OPT_LEN_MAX] = '\0';
4395 strncpy(in, opt, OPT_LEN_MAX);
4397 while (*inptr && nchr > 0) {
4398 if (inptr[0] == '$' && inptr[1] == '{') {
4399 ch2 = strchr(inptr, '}');
4400 if (ch2 && inptr+1 < ch2) {
4407 envlen = strlen(env);
4408 if (envlen <= nchr) {
4409 memcpy(outptr, env, envlen);
4419 *outptr++ = *inptr++;
4428 * Look for reserved variable names and replace them with real values
4430 static char *fio_keyword_replace(char *opt)
4436 for (i = 0; fio_keywords[i].word != NULL; i++) {
4437 struct fio_keyword *kw = &fio_keywords[i];
4439 while ((s = strstr(opt, kw->word)) != NULL) {
4440 char *new = malloc(strlen(opt) + 1);
4446 * Copy part of the string before the keyword and
4447 * sprintf() the replacement after it.
4449 memcpy(new, opt, olen);
4450 len = sprintf(new + olen, "%s", kw->replace);
4453 * If there's more in the original string, copy that
4456 opt += strlen(kw->word) + olen;
4458 memcpy(new + olen + len, opt, opt - o_org - 1);
4461 * replace opt and free the old opt
4471 * Check for potential math and invoke bc, if possible
4479 static char **dup_and_sub_options(char **opts, int num_opts)
4482 char **opts_copy = malloc(num_opts * sizeof(*opts));
4483 for (i = 0; i < num_opts; i++) {
4484 opts_copy[i] = option_dup_subs(opts[i]);
4487 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
4492 static void show_closest_option(const char *opt)
4494 int best_option, best_distance;
4503 while (name[i] != '\0' && name[i] != '=')
4508 best_distance = INT_MAX;
4510 while (fio_options[i].name) {
4511 distance = string_distance(name, fio_options[i].name);
4512 if (distance < best_distance) {
4513 best_distance = distance;
4519 if (best_option != -1 && string_distance_ok(name, best_distance) &&
4520 fio_options[best_option].type != FIO_OPT_UNSUPPORTED)
4521 log_err("Did you mean %s?\n", fio_options[best_option].name);
4526 int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
4528 int i, ret, unknown;
4531 sort_options(opts, fio_options, num_opts);
4532 opts_copy = dup_and_sub_options(opts, num_opts);
4534 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
4535 struct fio_option *o;
4536 int newret = parse_option(opts_copy[i], opts[i], fio_options,
4537 &o, &td->o, &td->opt_list);
4540 fio_option_mark_set(&td->o, o);
4548 opts_copy[i] = NULL;
4555 ret |= ioengine_load(td);
4557 sort_options(opts_copy, td->io_ops->options, num_opts);
4560 for (i = 0; i < num_opts; i++) {
4561 struct fio_option *o = NULL;
4568 newret = parse_option(opts_copy[i], opts[i],
4569 td->io_ops->options, &o,
4570 td->eo, &td->opt_list);
4574 log_err("Bad option <%s>\n", opts[i]);
4575 show_closest_option(opts[i]);
4578 opts_copy[i] = NULL;
4586 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
4590 ret = parse_cmd_option(opt, val, fio_options, &td->o, &td->opt_list);
4592 struct fio_option *o;
4594 o = find_option(fio_options, opt);
4596 fio_option_mark_set(&td->o, o);
4602 int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
4605 return parse_cmd_option(opt, val, td->io_ops->options, td->eo,
4609 void fio_fill_default_options(struct thread_data *td)
4611 td->o.magic = OPT_MAGIC;
4612 fill_default_options(&td->o, fio_options);
4615 int fio_show_option_help(const char *opt)
4617 return show_cmd_help(fio_options, opt);
4620 void options_mem_dupe(void *data, struct fio_option *options)
4622 struct fio_option *o;
4625 for (o = &options[0]; o->name; o++) {
4626 if (o->type != FIO_OPT_STR_STORE)
4629 ptr = td_var(data, o, o->off1);
4631 *ptr = strdup(*ptr);
4636 * dupe FIO_OPT_STR_STORE options
4638 void fio_options_mem_dupe(struct thread_data *td)
4640 options_mem_dupe(&td->o, fio_options);
4642 if (td->eo && td->io_ops) {
4643 void *oldeo = td->eo;
4645 td->eo = malloc(td->io_ops->option_struct_size);
4646 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
4647 options_mem_dupe(td->eo, td->io_ops->options);
4651 unsigned int fio_get_kb_base(void *data)
4653 struct thread_data *td = cb_data_to_td(data);
4654 struct thread_options *o = &td->o;
4655 unsigned int kb_base = 0;
4658 * This is a hack... For private options, *data is not holding
4659 * a pointer to the thread_options, but to private data. This means
4660 * we can't safely dereference it, but magic is first so mem wise
4661 * it is valid. But this also means that if the job first sets
4662 * kb_base and expects that to be honored by private options,
4663 * it will be disappointed. We will return the global default
4666 if (o && o->magic == OPT_MAGIC)
4667 kb_base = o->kb_base;
4674 int add_option(struct fio_option *o)
4676 struct fio_option *__o;
4685 if (opt_index + 1 == FIO_MAX_OPTS) {
4686 log_err("fio: FIO_MAX_OPTS is too small\n");
4690 memcpy(&fio_options[opt_index], o, sizeof(*o));
4691 fio_options[opt_index + 1].name = NULL;
4695 void invalidate_profile_options(const char *prof_name)
4697 struct fio_option *o;
4701 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
4702 o->type = FIO_OPT_INVALID;
4703 o->prof_name = NULL;
4709 void add_opt_posval(const char *optname, const char *ival, const char *help)
4711 struct fio_option *o;
4714 o = find_option(fio_options, optname);
4718 for (i = 0; i < PARSE_MAX_VP; i++) {
4719 if (o->posval[i].ival)
4722 o->posval[i].ival = ival;
4723 o->posval[i].help = help;
4728 void del_opt_posval(const char *optname, const char *ival)
4730 struct fio_option *o;
4733 o = find_option(fio_options, optname);
4737 for (i = 0; i < PARSE_MAX_VP; i++) {
4738 if (!o->posval[i].ival)
4740 if (strcmp(o->posval[i].ival, ival))
4743 o->posval[i].ival = NULL;
4744 o->posval[i].help = NULL;
4748 void fio_options_free(struct thread_data *td)
4750 options_free(fio_options, &td->o);
4751 if (td->eo && td->io_ops && td->io_ops->options) {
4752 options_free(td->io_ops->options, td->eo);
4758 struct fio_option *fio_option_find(const char *name)
4760 return find_option(fio_options, name);
4763 static struct fio_option *find_next_opt(struct thread_options *o,
4764 struct fio_option *from,
4767 struct fio_option *opt;
4770 from = &fio_options[0];
4776 if (off1 == from->off1) {
4781 } while (from->name);
4786 static int opt_is_set(struct thread_options *o, struct fio_option *opt)
4788 unsigned int opt_off, index, offset;
4790 opt_off = opt - &fio_options[0];
4791 index = opt_off / (8 * sizeof(uint64_t));
4792 offset = opt_off & ((8 * sizeof(uint64_t)) - 1);
4793 return (o->set_options[index] & ((uint64_t)1 << offset)) != 0;
4796 bool __fio_option_is_set(struct thread_options *o, unsigned int off1)
4798 struct fio_option *opt, *next;
4801 while ((opt = find_next_opt(o, next, off1)) != NULL) {
4802 if (opt_is_set(o, opt))
4811 void fio_option_mark_set(struct thread_options *o, struct fio_option *opt)
4813 unsigned int opt_off, index, offset;
4815 opt_off = opt - &fio_options[0];
4816 index = opt_off / (8 * sizeof(uint64_t));
4817 offset = opt_off & ((8 * sizeof(uint64_t)) - 1);
4818 o->set_options[index] |= (uint64_t)1 << offset;