11 #include <netinet/in.h>
17 #include "lib/pattern.h"
21 char client_sockaddr_str[INET6_ADDRSTRLEN] = { 0 };
24 * Check if mmap/mmaphuge has a :/foo/bar/file at the end. If so, return that.
26 static char *get_opt_postfix(const char *str)
28 char *p = strstr(str, ":");
34 strip_blank_front(&p);
39 static int bs_cmp(const void *p1, const void *p2)
41 const struct bssplit *bsp1 = p1;
42 const struct bssplit *bsp2 = p2;
44 return (int) bsp1->perc - (int) bsp2->perc;
47 static int bssplit_ddir(struct thread_options *o, int ddir, char *str)
49 struct bssplit *bssplit;
50 unsigned int i, perc, perc_missing;
51 unsigned int max_bs, min_bs;
55 o->bssplit_nr[ddir] = 4;
56 bssplit = malloc(4 * sizeof(struct bssplit));
61 while ((fname = strsep(&str, ":")) != NULL) {
68 * grow struct buffer, if needed
70 if (i == o->bssplit_nr[ddir]) {
71 o->bssplit_nr[ddir] <<= 1;
72 bssplit = realloc(bssplit, o->bssplit_nr[ddir]
73 * sizeof(struct bssplit));
76 perc_str = strstr(fname, "/");
80 perc = atoi(perc_str);
88 if (str_to_decimal(fname, &val, 1, o, 0, 0)) {
89 log_err("fio: bssplit conversion failed\n");
100 bssplit[i].perc = perc;
104 o->bssplit_nr[ddir] = i;
107 * Now check if the percentages add up, and how much is missing
109 perc = perc_missing = 0;
110 for (i = 0; i < o->bssplit_nr[ddir]; i++) {
111 struct bssplit *bsp = &bssplit[i];
113 if (bsp->perc == -1U)
119 if (perc > 100 && perc_missing > 1) {
120 log_err("fio: bssplit percentages add to more than 100%%\n");
126 * If values didn't have a percentage set, divide the remains between
130 if (perc_missing == 1 && o->bssplit_nr[ddir] == 1)
132 for (i = 0; i < o->bssplit_nr[ddir]; i++) {
133 struct bssplit *bsp = &bssplit[i];
135 if (bsp->perc == -1U)
136 bsp->perc = (100 - perc) / perc_missing;
140 o->min_bs[ddir] = min_bs;
141 o->max_bs[ddir] = max_bs;
144 * now sort based on percentages, for ease of lookup
146 qsort(bssplit, o->bssplit_nr[ddir], sizeof(struct bssplit), bs_cmp);
147 o->bssplit[ddir] = bssplit;
151 static int str_bssplit_cb(void *data, const char *input)
153 struct thread_data *td = data;
154 char *str, *p, *odir, *ddir;
160 p = str = strdup(input);
162 strip_blank_front(&str);
163 strip_blank_end(str);
165 odir = strchr(str, ',');
167 ddir = strchr(odir + 1, ',');
169 ret = bssplit_ddir(&td->o, DDIR_TRIM, ddir + 1);
175 op = strdup(odir + 1);
176 ret = bssplit_ddir(&td->o, DDIR_TRIM, op);
181 ret = bssplit_ddir(&td->o, DDIR_WRITE, odir + 1);
184 ret = bssplit_ddir(&td->o, DDIR_READ, str);
190 ret = bssplit_ddir(&td->o, DDIR_WRITE, op);
195 ret = bssplit_ddir(&td->o, DDIR_TRIM, op);
199 ret = bssplit_ddir(&td->o, DDIR_READ, str);
206 static int str2error(char *str)
208 const char *err[] = { "EPERM", "ENOENT", "ESRCH", "EINTR", "EIO",
209 "ENXIO", "E2BIG", "ENOEXEC", "EBADF",
210 "ECHILD", "EAGAIN", "ENOMEM", "EACCES",
211 "EFAULT", "ENOTBLK", "EBUSY", "EEXIST",
212 "EXDEV", "ENODEV", "ENOTDIR", "EISDIR",
213 "EINVAL", "ENFILE", "EMFILE", "ENOTTY",
214 "ETXTBSY","EFBIG", "ENOSPC", "ESPIPE",
215 "EROFS","EMLINK", "EPIPE", "EDOM", "ERANGE" };
216 int i = 0, num = sizeof(err) / sizeof(void *);
219 if (!strcmp(err[i], str))
226 static int ignore_error_type(struct thread_data *td, int etype, char *str)
232 if (etype >= ERROR_TYPE_CNT) {
233 log_err("Illegal error type\n");
237 td->o.ignore_error_nr[etype] = 4;
238 error = malloc(4 * sizeof(struct bssplit));
241 while ((fname = strsep(&str, ":")) != NULL) {
247 * grow struct buffer, if needed
249 if (i == td->o.ignore_error_nr[etype]) {
250 td->o.ignore_error_nr[etype] <<= 1;
251 error = realloc(error, td->o.ignore_error_nr[etype]
254 if (fname[0] == 'E') {
255 error[i] = str2error(fname);
257 error[i] = atoi(fname);
259 error[i] = -error[i];
262 log_err("Unknown error %s, please use number value \n",
270 td->o.continue_on_error |= 1 << etype;
271 td->o.ignore_error_nr[etype] = i;
272 td->o.ignore_error[etype] = error;
280 static int str_ignore_error_cb(void *data, const char *input)
282 struct thread_data *td = data;
284 int type = 0, ret = 1;
289 p = str = strdup(input);
291 strip_blank_front(&str);
292 strip_blank_end(str);
298 ret = ignore_error_type(td, type, p);
308 static int str_rw_cb(void *data, const char *str)
310 struct thread_data *td = data;
311 struct thread_options *o = &td->o;
320 nr = get_opt_postfix(str);
325 o->ddir_seq_nr = atoi(nr);
329 if (str_to_decimal(nr, &val, 1, o, 0, 0)) {
330 log_err("fio: rw postfix parsing failed\n");
335 o->ddir_seq_add = val;
342 static int str_mem_cb(void *data, const char *mem)
344 struct thread_data *td = data;
346 if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP ||
347 td->o.mem_type == MEM_MMAPSHARED)
348 td->o.mmapfile = get_opt_postfix(mem);
353 static int fio_clock_source_cb(void *data, const char *str)
355 struct thread_data *td = data;
357 fio_clock_source = td->o.clocksource;
358 fio_clock_source_set = 1;
363 static int str_rwmix_read_cb(void *data, unsigned long long *val)
365 struct thread_data *td = data;
367 td->o.rwmix[DDIR_READ] = *val;
368 td->o.rwmix[DDIR_WRITE] = 100 - *val;
372 static int str_rwmix_write_cb(void *data, unsigned long long *val)
374 struct thread_data *td = data;
376 td->o.rwmix[DDIR_WRITE] = *val;
377 td->o.rwmix[DDIR_READ] = 100 - *val;
381 static int str_exitall_cb(void)
383 exitall_on_terminate = 1;
387 #ifdef FIO_HAVE_CPU_AFFINITY
388 int fio_cpus_split(os_cpu_mask_t *mask, unsigned int cpu_index)
390 unsigned int i, index, cpus_in_mask;
391 const long max_cpu = cpus_online();
393 cpus_in_mask = fio_cpu_count(mask);
394 cpu_index = cpu_index % cpus_in_mask;
397 for (i = 0; i < max_cpu; i++) {
398 if (!fio_cpu_isset(mask, i))
401 if (cpu_index != index)
402 fio_cpu_clear(mask, i);
407 return fio_cpu_count(mask);
410 static int str_cpumask_cb(void *data, unsigned long long *val)
412 struct thread_data *td = data;
420 ret = fio_cpuset_init(&td->o.cpumask);
422 log_err("fio: cpuset_init failed\n");
423 td_verror(td, ret, "fio_cpuset_init");
427 max_cpu = cpus_online();
429 for (i = 0; i < sizeof(int) * 8; i++) {
430 if ((1 << i) & *val) {
432 log_err("fio: CPU %d too large (max=%ld)\n", i,
436 dprint(FD_PARSE, "set cpu allowed %d\n", i);
437 fio_cpu_set(&td->o.cpumask, i);
444 static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask,
451 ret = fio_cpuset_init(mask);
453 log_err("fio: cpuset_init failed\n");
454 td_verror(td, ret, "fio_cpuset_init");
458 p = str = strdup(input);
460 strip_blank_front(&str);
461 strip_blank_end(str);
463 max_cpu = cpus_online();
465 while ((cpu = strsep(&str, ",")) != NULL) {
474 while ((cpu2 = strsep(&str2, "-")) != NULL) {
484 while (icpu <= icpu2) {
485 if (icpu >= FIO_MAX_CPUS) {
486 log_err("fio: your OS only supports up to"
487 " %d CPUs\n", (int) FIO_MAX_CPUS);
491 if (icpu >= max_cpu) {
492 log_err("fio: CPU %d too large (max=%ld)\n",
498 dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
499 fio_cpu_set(mask, icpu);
510 static int str_cpus_allowed_cb(void *data, const char *input)
512 struct thread_data *td = data;
517 return set_cpus_allowed(td, &td->o.cpumask, input);
520 static int str_verify_cpus_allowed_cb(void *data, const char *input)
522 struct thread_data *td = data;
527 return set_cpus_allowed(td, &td->o.verify_cpumask, input);
531 static int str_log_cpus_allowed_cb(void *data, const char *input)
533 struct thread_data *td = data;
538 return set_cpus_allowed(td, &td->o.log_gz_cpumask, input);
540 #endif /* CONFIG_ZLIB */
542 #endif /* FIO_HAVE_CPU_AFFINITY */
544 #ifdef CONFIG_LIBNUMA
545 static int str_numa_cpunodes_cb(void *data, char *input)
547 struct thread_data *td = data;
548 struct bitmask *verify_bitmask;
553 /* numa_parse_nodestring() parses a character string list
554 * of nodes into a bit mask. The bit mask is allocated by
555 * numa_allocate_nodemask(), so it should be freed by
556 * numa_free_nodemask().
558 verify_bitmask = numa_parse_nodestring(input);
559 if (verify_bitmask == NULL) {
560 log_err("fio: numa_parse_nodestring failed\n");
561 td_verror(td, 1, "str_numa_cpunodes_cb");
564 numa_free_nodemask(verify_bitmask);
566 td->o.numa_cpunodes = strdup(input);
570 static int str_numa_mpol_cb(void *data, char *input)
572 struct thread_data *td = data;
573 const char * const policy_types[] =
574 { "default", "prefer", "bind", "interleave", "local", NULL };
577 struct bitmask *verify_bitmask;
582 nodelist = strchr(input, ':');
584 /* NUL-terminate mode */
588 for (i = 0; i <= MPOL_LOCAL; i++) {
589 if (!strcmp(input, policy_types[i])) {
590 td->o.numa_mem_mode = i;
594 if (i > MPOL_LOCAL) {
595 log_err("fio: memory policy should be: default, prefer, bind, interleave, local\n");
599 switch (td->o.numa_mem_mode) {
602 * Insist on a nodelist of one node only
605 char *rest = nodelist;
606 while (isdigit(*rest))
609 log_err("fio: one node only for \'prefer\'\n");
613 log_err("fio: one node is needed for \'prefer\'\n");
617 case MPOL_INTERLEAVE:
619 * Default to online nodes with memory if no nodelist
622 nodelist = strdup("all");
627 * Don't allow a nodelist
630 log_err("fio: NO nodelist for \'local\'\n");
636 * Insist on a nodelist
639 log_err("fio: a nodelist is needed for \'bind\'\n");
646 /* numa_parse_nodestring() parses a character string list
647 * of nodes into a bit mask. The bit mask is allocated by
648 * numa_allocate_nodemask(), so it should be freed by
649 * numa_free_nodemask().
651 switch (td->o.numa_mem_mode) {
653 td->o.numa_mem_prefer_node = atoi(nodelist);
655 case MPOL_INTERLEAVE:
657 verify_bitmask = numa_parse_nodestring(nodelist);
658 if (verify_bitmask == NULL) {
659 log_err("fio: numa_parse_nodestring failed\n");
660 td_verror(td, 1, "str_numa_memnodes_cb");
663 td->o.numa_memnodes = strdup(nodelist);
664 numa_free_nodemask(verify_bitmask);
679 static int str_fst_cb(void *data, const char *str)
681 struct thread_data *td = data;
682 char *nr = get_opt_postfix(str);
684 td->file_service_nr = 1;
686 td->file_service_nr = atoi(nr);
693 #ifdef CONFIG_SYNC_FILE_RANGE
694 static int str_sfr_cb(void *data, const char *str)
696 struct thread_data *td = data;
697 char *nr = get_opt_postfix(str);
699 td->sync_file_range_nr = 1;
701 td->sync_file_range_nr = atoi(nr);
709 static int zone_cmp(const void *p1, const void *p2)
711 const struct zone_split *zsp1 = p1;
712 const struct zone_split *zsp2 = p2;
714 return (int) zsp2->access_perc - (int) zsp1->access_perc;
717 static int zone_split_ddir(struct thread_options *o, int ddir, char *str)
719 struct zone_split *zsplit;
720 unsigned int i, perc, perc_missing, sperc, sperc_missing;
724 o->zone_split_nr[ddir] = 4;
725 zsplit = malloc(4 * sizeof(struct zone_split));
728 while ((fname = strsep(&str, ":")) != NULL) {
735 * grow struct buffer, if needed
737 if (i == o->zone_split_nr[ddir]) {
738 o->zone_split_nr[ddir] <<= 1;
739 zsplit = realloc(zsplit, o->zone_split_nr[ddir]
740 * sizeof(struct zone_split));
743 perc_str = strstr(fname, "/");
747 perc = atoi(perc_str);
755 if (str_to_decimal(fname, &val, 1, o, 0, 0)) {
756 log_err("fio: zone_split conversion failed\n");
761 zsplit[i].access_perc = val;
762 zsplit[i].size_perc = perc;
766 o->zone_split_nr[ddir] = i;
769 * Now check if the percentages add up, and how much is missing
771 perc = perc_missing = 0;
772 sperc = sperc_missing = 0;
773 for (i = 0; i < o->zone_split_nr[ddir]; i++) {
774 struct zone_split *zsp = &zsplit[i];
776 if (zsp->access_perc == (uint8_t) -1U)
779 perc += zsp->access_perc;
781 if (zsp->size_perc == (uint8_t) -1U)
784 sperc += zsp->size_perc;
788 if (perc > 100 || sperc > 100) {
789 log_err("fio: zone_split percentages add to more than 100%%\n");
794 log_err("fio: access percentage don't add up to 100 for zoned "
795 "random distribution (got=%u)\n", perc);
801 * If values didn't have a percentage set, divide the remains between
805 if (perc_missing == 1 && o->zone_split_nr[ddir] == 1)
807 for (i = 0; i < o->zone_split_nr[ddir]; i++) {
808 struct zone_split *zsp = &zsplit[i];
810 if (zsp->access_perc == (uint8_t) -1U)
811 zsp->access_perc = (100 - perc) / perc_missing;
815 if (sperc_missing == 1 && o->zone_split_nr[ddir] == 1)
817 for (i = 0; i < o->zone_split_nr[ddir]; i++) {
818 struct zone_split *zsp = &zsplit[i];
820 if (zsp->size_perc == (uint8_t) -1U)
821 zsp->size_perc = (100 - sperc) / sperc_missing;
826 * now sort based on percentages, for ease of lookup
828 qsort(zsplit, o->zone_split_nr[ddir], sizeof(struct zone_split), zone_cmp);
829 o->zone_split[ddir] = zsplit;
833 static void __td_zone_gen_index(struct thread_data *td, enum fio_ddir ddir)
835 unsigned int i, j, sprev, aprev;
837 td->zone_state_index[ddir] = malloc(sizeof(struct zone_split_index) * 100);
840 for (i = 0; i < td->o.zone_split_nr[ddir]; i++) {
841 struct zone_split *zsp = &td->o.zone_split[ddir][i];
843 for (j = aprev; j < aprev + zsp->access_perc; j++) {
844 struct zone_split_index *zsi = &td->zone_state_index[ddir][j];
846 zsi->size_perc = sprev + zsp->size_perc;
847 zsi->size_perc_prev = sprev;
850 aprev += zsp->access_perc;
851 sprev += zsp->size_perc;
856 * Generate state table for indexes, so we don't have to do it inline from
859 static void td_zone_gen_index(struct thread_data *td)
863 td->zone_state_index = malloc(DDIR_RWDIR_CNT *
864 sizeof(struct zone_split_index *));
866 for (i = 0; i < DDIR_RWDIR_CNT; i++)
867 __td_zone_gen_index(td, i);
870 static int parse_zoned_distribution(struct thread_data *td, const char *input)
872 char *str, *p, *odir, *ddir;
875 p = str = strdup(input);
877 strip_blank_front(&str);
878 strip_blank_end(str);
880 /* We expect it to start like that, bail if not */
881 if (strncmp(str, "zoned:", 6)) {
882 log_err("fio: mismatch in zoned input <%s>\n", str);
886 str += strlen("zoned:");
888 odir = strchr(str, ',');
890 ddir = strchr(odir + 1, ',');
892 ret = zone_split_ddir(&td->o, DDIR_TRIM, ddir + 1);
898 op = strdup(odir + 1);
899 ret = zone_split_ddir(&td->o, DDIR_TRIM, op);
904 ret = zone_split_ddir(&td->o, DDIR_WRITE, odir + 1);
907 ret = zone_split_ddir(&td->o, DDIR_READ, str);
913 ret = zone_split_ddir(&td->o, DDIR_WRITE, op);
918 ret = zone_split_ddir(&td->o, DDIR_TRIM, op);
922 ret = zone_split_ddir(&td->o, DDIR_READ, str);
927 for (i = 0; i < DDIR_RWDIR_CNT; i++) {
930 dprint(FD_PARSE, "zone ddir %d (nr=%u): \n", i, td->o.zone_split_nr[i]);
932 for (j = 0; j < td->o.zone_split_nr[i]; j++) {
933 struct zone_split *zsp = &td->o.zone_split[i][j];
935 dprint(FD_PARSE, "\t%d: %u/%u\n", j, zsp->access_perc,
941 td_zone_gen_index(td);
943 for (i = 0; i < DDIR_RWDIR_CNT; i++)
944 td->o.zone_split_nr[i] = 0;
950 static int str_random_distribution_cb(void *data, const char *str)
952 struct thread_data *td = data;
959 if (td->o.random_distribution == FIO_RAND_DIST_ZIPF)
961 else if (td->o.random_distribution == FIO_RAND_DIST_PARETO)
962 val = FIO_DEF_PARETO;
963 else if (td->o.random_distribution == FIO_RAND_DIST_GAUSS)
965 else if (td->o.random_distribution == FIO_RAND_DIST_ZONED)
966 return parse_zoned_distribution(td, str);
970 nr = get_opt_postfix(str);
971 if (nr && !str_to_float(nr, &val, 0)) {
972 log_err("fio: random postfix parsing failed\n");
979 if (td->o.random_distribution == FIO_RAND_DIST_ZIPF) {
981 log_err("fio: zipf theta must different than 1.0\n");
984 td->o.zipf_theta.u.f = val;
985 } else if (td->o.random_distribution == FIO_RAND_DIST_PARETO) {
986 if (val <= 0.00 || val >= 1.00) {
987 log_err("fio: pareto input out of range (0 < input < 1.0)\n");
990 td->o.pareto_h.u.f = val;
992 if (val <= 0.00 || val >= 100.0) {
993 log_err("fio: normal deviation out of range (0 < input < 100.0)\n");
996 td->o.gauss_dev.u.f = val;
1003 * Return next name in the string. Files are separated with ':'. If the ':'
1004 * is escaped with a '\', then that ':' is part of the filename and does not
1005 * indicate a new file.
1007 static char *get_next_name(char **ptr)
1012 if (!str || !strlen(str))
1018 * No colon, we are done
1020 p = strchr(str, ':');
1027 * We got a colon, but it's the first character. Skip and
1035 if (*(p - 1) != '\\') {
1041 memmove(p - 1, p, strlen(p) + 1);
1049 static int get_max_name_idx(char *input)
1051 unsigned int cur_idx;
1054 p = str = strdup(input);
1055 for (cur_idx = 0; ; cur_idx++)
1056 if (get_next_name(&str) == NULL)
1064 * Returns the directory at the index, indexes > entires will be
1065 * assigned via modulo division of the index
1067 int set_name_idx(char *target, size_t tlen, char *input, int index)
1069 unsigned int cur_idx;
1071 char *fname, *str, *p;
1073 p = str = strdup(input);
1075 index %= get_max_name_idx(input);
1076 for (cur_idx = 0; cur_idx <= index; cur_idx++)
1077 fname = get_next_name(&str);
1079 if (client_sockaddr_str[0]) {
1080 len = snprintf(target, tlen, "%s/%s.", fname,
1081 client_sockaddr_str);
1083 len = snprintf(target, tlen, "%s/", fname);
1085 target[tlen - 1] = '\0';
1091 static int str_filename_cb(void *data, const char *input)
1093 struct thread_data *td = data;
1094 char *fname, *str, *p;
1096 p = str = strdup(input);
1098 strip_blank_front(&str);
1099 strip_blank_end(str);
1101 if (!td->files_index)
1104 while ((fname = get_next_name(&str)) != NULL) {
1107 add_file(td, fname, 0, 1);
1114 static int str_directory_cb(void *data, const char fio_unused *unused)
1116 struct thread_data *td = data;
1118 char *dirname, *str, *p;
1124 p = str = strdup(td->o.directory);
1125 while ((dirname = get_next_name(&str)) != NULL) {
1126 if (lstat(dirname, &sb) < 0) {
1129 log_err("fio: %s is not a directory\n", dirname);
1130 td_verror(td, ret, "lstat");
1133 if (!S_ISDIR(sb.st_mode)) {
1134 log_err("fio: %s is not a directory\n", dirname);
1145 static int str_opendir_cb(void *data, const char fio_unused *str)
1147 struct thread_data *td = data;
1152 if (!td->files_index)
1155 return add_dir_files(td, td->o.opendir);
1158 static int str_buffer_pattern_cb(void *data, const char *input)
1160 struct thread_data *td = data;
1163 /* FIXME: for now buffer pattern does not support formats */
1164 ret = parse_and_fill_pattern(input, strlen(input), td->o.buffer_pattern,
1165 MAX_PATTERN_SIZE, NULL, 0, NULL, NULL);
1170 td->o.buffer_pattern_bytes = ret;
1171 if (!td->o.compress_percentage)
1172 td->o.refill_buffers = 0;
1173 td->o.scramble_buffers = 0;
1174 td->o.zero_buffers = 0;
1179 static int str_buffer_compress_cb(void *data, unsigned long long *il)
1181 struct thread_data *td = data;
1183 td->flags |= TD_F_COMPRESS;
1184 td->o.compress_percentage = *il;
1188 static int str_dedupe_cb(void *data, unsigned long long *il)
1190 struct thread_data *td = data;
1192 td->flags |= TD_F_COMPRESS;
1193 td->o.dedupe_percentage = *il;
1194 td->o.refill_buffers = 1;
1198 static int str_verify_pattern_cb(void *data, const char *input)
1200 struct pattern_fmt_desc fmt_desc[] = {
1203 .len = FIELD_SIZE(struct io_u *, offset),
1204 .paste = paste_blockoff
1207 struct thread_data *td = data;
1210 td->o.verify_fmt_sz = ARRAY_SIZE(td->o.verify_fmt);
1211 ret = parse_and_fill_pattern(input, strlen(input), td->o.verify_pattern,
1212 MAX_PATTERN_SIZE, fmt_desc, sizeof(fmt_desc),
1213 td->o.verify_fmt, &td->o.verify_fmt_sz);
1218 td->o.verify_pattern_bytes = ret;
1220 * VERIFY_* could already be set
1222 if (!fio_option_is_set(&td->o, verify))
1223 td->o.verify = VERIFY_PATTERN;
1228 static int str_gtod_reduce_cb(void *data, int *il)
1230 struct thread_data *td = data;
1233 td->o.disable_lat = !!val;
1234 td->o.disable_clat = !!val;
1235 td->o.disable_slat = !!val;
1236 td->o.disable_bw = !!val;
1237 td->o.clat_percentiles = !val;
1239 td->tv_cache_mask = 63;
1244 static int str_size_cb(void *data, unsigned long long *__val)
1246 struct thread_data *td = data;
1247 unsigned long long v = *__val;
1249 if (parse_is_percent(v)) {
1251 td->o.size_percent = -1ULL - v;
1258 static int rw_verify(struct fio_option *o, void *data)
1260 struct thread_data *td = data;
1262 if (read_only && td_write(td)) {
1263 log_err("fio: job <%s> has write bit set, but fio is in"
1264 " read-only mode\n", td->o.name);
1271 static int gtod_cpu_verify(struct fio_option *o, void *data)
1273 #ifndef FIO_HAVE_CPU_AFFINITY
1274 struct thread_data *td = data;
1276 if (td->o.gtod_cpu) {
1277 log_err("fio: platform must support CPU affinity for"
1278 "gettimeofday() offloading\n");
1287 * Map of job/command line options
1289 struct fio_option fio_options[FIO_MAX_OPTS] = {
1291 .name = "description",
1292 .lname = "Description of job",
1293 .type = FIO_OPT_STR_STORE,
1294 .off1 = td_var_offset(description),
1295 .help = "Text job description",
1296 .category = FIO_OPT_C_GENERAL,
1297 .group = FIO_OPT_G_DESC,
1301 .lname = "Job name",
1302 .type = FIO_OPT_STR_STORE,
1303 .off1 = td_var_offset(name),
1304 .help = "Name of this job",
1305 .category = FIO_OPT_C_GENERAL,
1306 .group = FIO_OPT_G_DESC,
1310 .lname = "Waitee name",
1311 .type = FIO_OPT_STR_STORE,
1312 .off1 = td_var_offset(wait_for),
1313 .help = "Name of the job this one wants to wait for before starting",
1314 .category = FIO_OPT_C_GENERAL,
1315 .group = FIO_OPT_G_DESC,
1319 .lname = "Filename(s)",
1320 .type = FIO_OPT_STR_STORE,
1321 .off1 = td_var_offset(filename),
1322 .cb = str_filename_cb,
1323 .prio = -1, /* must come after "directory" */
1324 .help = "File(s) to use for the workload",
1325 .category = FIO_OPT_C_FILE,
1326 .group = FIO_OPT_G_FILENAME,
1329 .name = "directory",
1330 .lname = "Directory",
1331 .type = FIO_OPT_STR_STORE,
1332 .off1 = td_var_offset(directory),
1333 .cb = str_directory_cb,
1334 .help = "Directory to store files in",
1335 .category = FIO_OPT_C_FILE,
1336 .group = FIO_OPT_G_FILENAME,
1339 .name = "filename_format",
1340 .type = FIO_OPT_STR_STORE,
1341 .off1 = td_var_offset(filename_format),
1342 .prio = -1, /* must come after "directory" */
1343 .help = "Override default $jobname.$jobnum.$filenum naming",
1344 .def = "$jobname.$jobnum.$filenum",
1345 .category = FIO_OPT_C_FILE,
1346 .group = FIO_OPT_G_FILENAME,
1350 .lname = "Lockfile",
1351 .type = FIO_OPT_STR,
1352 .off1 = td_var_offset(file_lock_mode),
1353 .help = "Lock file when doing IO to it",
1355 .parent = "filename",
1358 .category = FIO_OPT_C_FILE,
1359 .group = FIO_OPT_G_FILENAME,
1362 .oval = FILE_LOCK_NONE,
1363 .help = "No file locking",
1365 { .ival = "exclusive",
1366 .oval = FILE_LOCK_EXCLUSIVE,
1367 .help = "Exclusive file lock",
1370 .ival = "readwrite",
1371 .oval = FILE_LOCK_READWRITE,
1372 .help = "Read vs write lock",
1378 .lname = "Open directory",
1379 .type = FIO_OPT_STR_STORE,
1380 .off1 = td_var_offset(opendir),
1381 .cb = str_opendir_cb,
1382 .help = "Recursively add files from this directory and down",
1383 .category = FIO_OPT_C_FILE,
1384 .group = FIO_OPT_G_FILENAME,
1388 .lname = "Read/write",
1389 .alias = "readwrite",
1390 .type = FIO_OPT_STR,
1392 .off1 = td_var_offset(td_ddir),
1393 .help = "IO direction",
1395 .verify = rw_verify,
1396 .category = FIO_OPT_C_IO,
1397 .group = FIO_OPT_G_IO_BASIC,
1400 .oval = TD_DDIR_READ,
1401 .help = "Sequential read",
1404 .oval = TD_DDIR_WRITE,
1405 .help = "Sequential write",
1408 .oval = TD_DDIR_TRIM,
1409 .help = "Sequential trim",
1411 { .ival = "randread",
1412 .oval = TD_DDIR_RANDREAD,
1413 .help = "Random read",
1415 { .ival = "randwrite",
1416 .oval = TD_DDIR_RANDWRITE,
1417 .help = "Random write",
1419 { .ival = "randtrim",
1420 .oval = TD_DDIR_RANDTRIM,
1421 .help = "Random trim",
1425 .help = "Sequential read and write mix",
1427 { .ival = "readwrite",
1429 .help = "Sequential read and write mix",
1432 .oval = TD_DDIR_RANDRW,
1433 .help = "Random read and write mix"
1435 { .ival = "trimwrite",
1436 .oval = TD_DDIR_TRIMWRITE,
1437 .help = "Trim and write mix, trims preceding writes"
1442 .name = "rw_sequencer",
1443 .lname = "RW Sequencer",
1444 .type = FIO_OPT_STR,
1445 .off1 = td_var_offset(rw_seq),
1446 .help = "IO offset generator modifier",
1447 .def = "sequential",
1448 .category = FIO_OPT_C_IO,
1449 .group = FIO_OPT_G_IO_BASIC,
1451 { .ival = "sequential",
1453 .help = "Generate sequential offsets",
1455 { .ival = "identical",
1456 .oval = RW_SEQ_IDENT,
1457 .help = "Generate identical offsets",
1464 .lname = "IO Engine",
1465 .type = FIO_OPT_STR_STORE,
1466 .off1 = td_var_offset(ioengine),
1467 .help = "IO engine to use",
1468 .def = FIO_PREFERRED_ENGINE,
1469 .category = FIO_OPT_C_IO,
1470 .group = FIO_OPT_G_IO_BASIC,
1473 .help = "Use read/write",
1476 .help = "Use pread/pwrite",
1479 .help = "Use readv/writev",
1481 #ifdef CONFIG_PWRITEV
1483 .help = "Use preadv/pwritev",
1486 #ifdef CONFIG_PWRITEV
1487 { .ival = "pvsync2",
1488 .help = "Use preadv2/pwritev2",
1491 #ifdef CONFIG_LIBAIO
1493 .help = "Linux native asynchronous IO",
1496 #ifdef CONFIG_POSIXAIO
1497 { .ival = "posixaio",
1498 .help = "POSIX asynchronous IO",
1501 #ifdef CONFIG_SOLARISAIO
1502 { .ival = "solarisaio",
1503 .help = "Solaris native asynchronous IO",
1506 #ifdef CONFIG_WINDOWSAIO
1507 { .ival = "windowsaio",
1508 .help = "Windows native asynchronous IO"
1513 .help = "Rados Block Device asynchronous IO"
1517 .help = "Memory mapped IO"
1519 #ifdef CONFIG_LINUX_SPLICE
1521 .help = "splice/vmsplice based IO",
1523 { .ival = "netsplice",
1524 .help = "splice/vmsplice to/from the network",
1527 #ifdef FIO_HAVE_SGIO
1529 .help = "SCSI generic v3 IO",
1533 .help = "Testing engine (no data transfer)",
1536 .help = "Network IO",
1539 .help = "CPU cycle burner engine",
1543 .help = "GUASI IO engine",
1546 #ifdef FIO_HAVE_BINJECT
1547 { .ival = "binject",
1548 .help = "binject direct inject block engine",
1553 .help = "RDMA IO engine",
1556 #ifdef CONFIG_FUSION_AW
1557 { .ival = "fusion-aw-sync",
1558 .help = "Fusion-io atomic write engine",
1561 #ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
1562 { .ival = "e4defrag",
1563 .help = "ext4 defrag engine",
1566 #ifdef CONFIG_LINUX_FALLOCATE
1568 .help = "fallocate() file based engine",
1573 .help = "Glusterfs libgfapi(sync) based engine"
1575 { .ival = "gfapi_async",
1576 .help = "Glusterfs libgfapi(async) based engine"
1579 #ifdef CONFIG_LIBHDFS
1580 { .ival = "libhdfs",
1581 .help = "Hadoop Distributed Filesystem (HDFS) engine"
1584 { .ival = "external",
1585 .help = "Load external engine (append name)",
1591 .lname = "IO Depth",
1592 .type = FIO_OPT_INT,
1593 .off1 = td_var_offset(iodepth),
1594 .help = "Number of IO buffers to keep in flight",
1598 .category = FIO_OPT_C_IO,
1599 .group = FIO_OPT_G_IO_BASIC,
1602 .name = "iodepth_batch",
1603 .lname = "IO Depth batch",
1604 .alias = "iodepth_batch_submit",
1605 .type = FIO_OPT_INT,
1606 .off1 = td_var_offset(iodepth_batch),
1607 .help = "Number of IO buffers to submit in one go",
1608 .parent = "iodepth",
1613 .category = FIO_OPT_C_IO,
1614 .group = FIO_OPT_G_IO_BASIC,
1617 .name = "iodepth_batch_complete_min",
1618 .lname = "Min IO depth batch complete",
1619 .alias = "iodepth_batch_complete",
1620 .type = FIO_OPT_INT,
1621 .off1 = td_var_offset(iodepth_batch_complete_min),
1622 .help = "Min number of IO buffers to retrieve in one go",
1623 .parent = "iodepth",
1628 .category = FIO_OPT_C_IO,
1629 .group = FIO_OPT_G_IO_BASIC,
1632 .name = "iodepth_batch_complete_max",
1633 .lname = "Max IO depth batch complete",
1634 .type = FIO_OPT_INT,
1635 .off1 = td_var_offset(iodepth_batch_complete_max),
1636 .help = "Max number of IO buffers to retrieve in one go",
1637 .parent = "iodepth",
1641 .category = FIO_OPT_C_IO,
1642 .group = FIO_OPT_G_IO_BASIC,
1645 .name = "iodepth_low",
1646 .lname = "IO Depth batch low",
1647 .type = FIO_OPT_INT,
1648 .off1 = td_var_offset(iodepth_low),
1649 .help = "Low water mark for queuing depth",
1650 .parent = "iodepth",
1653 .category = FIO_OPT_C_IO,
1654 .group = FIO_OPT_G_IO_BASIC,
1657 .name = "io_submit_mode",
1658 .lname = "IO submit mode",
1659 .type = FIO_OPT_STR,
1660 .off1 = td_var_offset(io_submit_mode),
1661 .help = "How IO submissions and completions are done",
1663 .category = FIO_OPT_C_IO,
1664 .group = FIO_OPT_G_IO_BASIC,
1667 .oval = IO_MODE_INLINE,
1668 .help = "Submit and complete IO inline",
1670 { .ival = "offload",
1671 .oval = IO_MODE_OFFLOAD,
1672 .help = "Offload submit and complete to threads",
1679 .type = FIO_OPT_STR_VAL,
1681 .off1 = td_var_offset(size),
1682 .help = "Total size of device or files",
1683 .interval = 1024 * 1024,
1684 .category = FIO_OPT_C_IO,
1685 .group = FIO_OPT_G_INVALID,
1689 .alias = "io_limit",
1691 .type = FIO_OPT_STR_VAL,
1692 .off1 = td_var_offset(io_limit),
1693 .interval = 1024 * 1024,
1694 .category = FIO_OPT_C_IO,
1695 .group = FIO_OPT_G_INVALID,
1698 .name = "fill_device",
1699 .lname = "Fill device",
1701 .type = FIO_OPT_BOOL,
1702 .off1 = td_var_offset(fill_device),
1703 .help = "Write until an ENOSPC error occurs",
1705 .category = FIO_OPT_C_FILE,
1706 .group = FIO_OPT_G_INVALID,
1710 .lname = "File size",
1711 .type = FIO_OPT_STR_VAL,
1712 .off1 = td_var_offset(file_size_low),
1713 .off2 = td_var_offset(file_size_high),
1715 .help = "Size of individual files",
1716 .interval = 1024 * 1024,
1717 .category = FIO_OPT_C_FILE,
1718 .group = FIO_OPT_G_INVALID,
1721 .name = "file_append",
1722 .lname = "File append",
1723 .type = FIO_OPT_BOOL,
1724 .off1 = td_var_offset(file_append),
1725 .help = "IO will start at the end of the file(s)",
1727 .category = FIO_OPT_C_FILE,
1728 .group = FIO_OPT_G_INVALID,
1732 .lname = "IO offset",
1733 .alias = "fileoffset",
1734 .type = FIO_OPT_STR_VAL,
1735 .off1 = td_var_offset(start_offset),
1736 .help = "Start IO from this offset",
1738 .interval = 1024 * 1024,
1739 .category = FIO_OPT_C_IO,
1740 .group = FIO_OPT_G_INVALID,
1743 .name = "offset_increment",
1744 .lname = "IO offset increment",
1745 .type = FIO_OPT_STR_VAL,
1746 .off1 = td_var_offset(offset_increment),
1747 .help = "What is the increment from one offset to the next",
1751 .interval = 1024 * 1024,
1752 .category = FIO_OPT_C_IO,
1753 .group = FIO_OPT_G_INVALID,
1756 .name = "number_ios",
1757 .lname = "Number of IOs to perform",
1758 .type = FIO_OPT_STR_VAL,
1759 .off1 = td_var_offset(number_ios),
1760 .help = "Force job completion after this number of IOs",
1762 .category = FIO_OPT_C_IO,
1763 .group = FIO_OPT_G_INVALID,
1767 .lname = "Block size",
1768 .alias = "blocksize",
1769 .type = FIO_OPT_INT,
1770 .off1 = td_var_offset(bs[DDIR_READ]),
1771 .off2 = td_var_offset(bs[DDIR_WRITE]),
1772 .off3 = td_var_offset(bs[DDIR_TRIM]),
1774 .help = "Block size unit",
1779 .category = FIO_OPT_C_IO,
1780 .group = FIO_OPT_G_INVALID,
1784 .lname = "Block size align",
1785 .alias = "blockalign",
1786 .type = FIO_OPT_INT,
1787 .off1 = td_var_offset(ba[DDIR_READ]),
1788 .off2 = td_var_offset(ba[DDIR_WRITE]),
1789 .off3 = td_var_offset(ba[DDIR_TRIM]),
1791 .help = "IO block offset alignment",
1795 .category = FIO_OPT_C_IO,
1796 .group = FIO_OPT_G_INVALID,
1800 .lname = "Block size range",
1801 .alias = "blocksize_range",
1802 .type = FIO_OPT_RANGE,
1803 .off1 = td_var_offset(min_bs[DDIR_READ]),
1804 .off2 = td_var_offset(max_bs[DDIR_READ]),
1805 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
1806 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
1807 .off5 = td_var_offset(min_bs[DDIR_TRIM]),
1808 .off6 = td_var_offset(max_bs[DDIR_TRIM]),
1810 .help = "Set block size range (in more detail than bs)",
1814 .category = FIO_OPT_C_IO,
1815 .group = FIO_OPT_G_INVALID,
1819 .lname = "Block size split",
1820 .type = FIO_OPT_STR,
1821 .cb = str_bssplit_cb,
1822 .off1 = td_var_offset(bssplit),
1823 .help = "Set a specific mix of block sizes",
1826 .category = FIO_OPT_C_IO,
1827 .group = FIO_OPT_G_INVALID,
1830 .name = "bs_unaligned",
1831 .lname = "Block size unaligned",
1832 .alias = "blocksize_unaligned",
1833 .type = FIO_OPT_STR_SET,
1834 .off1 = td_var_offset(bs_unaligned),
1835 .help = "Don't sector align IO buffer sizes",
1838 .category = FIO_OPT_C_IO,
1839 .group = FIO_OPT_G_INVALID,
1842 .name = "bs_is_seq_rand",
1843 .lname = "Block size division is seq/random (not read/write)",
1844 .type = FIO_OPT_BOOL,
1845 .off1 = td_var_offset(bs_is_seq_rand),
1846 .help = "Consider any blocksize setting to be sequential,random",
1848 .parent = "blocksize",
1849 .category = FIO_OPT_C_IO,
1850 .group = FIO_OPT_G_INVALID,
1853 .name = "randrepeat",
1854 .lname = "Random repeatable",
1855 .type = FIO_OPT_BOOL,
1856 .off1 = td_var_offset(rand_repeatable),
1857 .help = "Use repeatable random IO pattern",
1861 .category = FIO_OPT_C_IO,
1862 .group = FIO_OPT_G_RANDOM,
1866 .lname = "The random generator seed",
1867 .type = FIO_OPT_STR_VAL,
1868 .off1 = td_var_offset(rand_seed),
1869 .help = "Set the random generator seed value",
1872 .category = FIO_OPT_C_IO,
1873 .group = FIO_OPT_G_RANDOM,
1876 .name = "use_os_rand",
1877 .lname = "Use OS random",
1878 .type = FIO_OPT_DEPRECATED,
1879 .off1 = td_var_offset(dep_use_os_rand),
1880 .category = FIO_OPT_C_IO,
1881 .group = FIO_OPT_G_RANDOM,
1884 .name = "norandommap",
1885 .lname = "No randommap",
1886 .type = FIO_OPT_STR_SET,
1887 .off1 = td_var_offset(norandommap),
1888 .help = "Accept potential duplicate random blocks",
1892 .category = FIO_OPT_C_IO,
1893 .group = FIO_OPT_G_RANDOM,
1896 .name = "softrandommap",
1897 .lname = "Soft randommap",
1898 .type = FIO_OPT_BOOL,
1899 .off1 = td_var_offset(softrandommap),
1900 .help = "Set norandommap if randommap allocation fails",
1901 .parent = "norandommap",
1904 .category = FIO_OPT_C_IO,
1905 .group = FIO_OPT_G_RANDOM,
1908 .name = "random_generator",
1909 .type = FIO_OPT_STR,
1910 .off1 = td_var_offset(random_generator),
1911 .help = "Type of random number generator to use",
1912 .def = "tausworthe",
1914 { .ival = "tausworthe",
1915 .oval = FIO_RAND_GEN_TAUSWORTHE,
1916 .help = "Strong Tausworthe generator",
1919 .oval = FIO_RAND_GEN_LFSR,
1920 .help = "Variable length LFSR",
1923 .ival = "tausworthe64",
1924 .oval = FIO_RAND_GEN_TAUSWORTHE64,
1925 .help = "64-bit Tausworthe variant",
1928 .category = FIO_OPT_C_IO,
1929 .group = FIO_OPT_G_RANDOM,
1932 .name = "random_distribution",
1933 .type = FIO_OPT_STR,
1934 .off1 = td_var_offset(random_distribution),
1935 .cb = str_random_distribution_cb,
1936 .help = "Random offset distribution generator",
1940 .oval = FIO_RAND_DIST_RANDOM,
1941 .help = "Completely random",
1944 .oval = FIO_RAND_DIST_ZIPF,
1945 .help = "Zipf distribution",
1948 .oval = FIO_RAND_DIST_PARETO,
1949 .help = "Pareto distribution",
1952 .oval = FIO_RAND_DIST_GAUSS,
1953 .help = "Normal (gaussian) distribution",
1956 .oval = FIO_RAND_DIST_ZONED,
1957 .help = "Zoned random distribution",
1961 .category = FIO_OPT_C_IO,
1962 .group = FIO_OPT_G_RANDOM,
1965 .name = "percentage_random",
1966 .lname = "Percentage Random",
1967 .type = FIO_OPT_INT,
1968 .off1 = td_var_offset(perc_rand[DDIR_READ]),
1969 .off2 = td_var_offset(perc_rand[DDIR_WRITE]),
1970 .off3 = td_var_offset(perc_rand[DDIR_TRIM]),
1972 .help = "Percentage of seq/random mix that should be random",
1973 .def = "100,100,100",
1975 .inverse = "percentage_sequential",
1976 .category = FIO_OPT_C_IO,
1977 .group = FIO_OPT_G_RANDOM,
1980 .name = "percentage_sequential",
1981 .lname = "Percentage Sequential",
1982 .type = FIO_OPT_DEPRECATED,
1983 .category = FIO_OPT_C_IO,
1984 .group = FIO_OPT_G_RANDOM,
1987 .name = "allrandrepeat",
1988 .type = FIO_OPT_BOOL,
1989 .off1 = td_var_offset(allrand_repeatable),
1990 .help = "Use repeatable random numbers for everything",
1992 .category = FIO_OPT_C_IO,
1993 .group = FIO_OPT_G_RANDOM,
1997 .lname = "Number of files",
1998 .alias = "nr_files",
1999 .type = FIO_OPT_INT,
2000 .off1 = td_var_offset(nr_files),
2001 .help = "Split job workload between this number of files",
2004 .category = FIO_OPT_C_FILE,
2005 .group = FIO_OPT_G_INVALID,
2008 .name = "openfiles",
2009 .lname = "Number of open files",
2010 .type = FIO_OPT_INT,
2011 .off1 = td_var_offset(open_files),
2012 .help = "Number of files to keep open at the same time",
2013 .category = FIO_OPT_C_FILE,
2014 .group = FIO_OPT_G_INVALID,
2017 .name = "file_service_type",
2018 .lname = "File service type",
2019 .type = FIO_OPT_STR,
2021 .off1 = td_var_offset(file_service_type),
2022 .help = "How to select which file to service next",
2023 .def = "roundrobin",
2024 .category = FIO_OPT_C_FILE,
2025 .group = FIO_OPT_G_INVALID,
2028 .oval = FIO_FSERVICE_RANDOM,
2029 .help = "Choose a file at random",
2031 { .ival = "roundrobin",
2032 .oval = FIO_FSERVICE_RR,
2033 .help = "Round robin select files",
2035 { .ival = "sequential",
2036 .oval = FIO_FSERVICE_SEQ,
2037 .help = "Finish one file before moving to the next",
2040 .parent = "nrfiles",
2043 #ifdef CONFIG_POSIX_FALLOCATE
2045 .name = "fallocate",
2046 .lname = "Fallocate",
2047 .type = FIO_OPT_STR,
2048 .off1 = td_var_offset(fallocate_mode),
2049 .help = "Whether pre-allocation is performed when laying out files",
2051 .category = FIO_OPT_C_FILE,
2052 .group = FIO_OPT_G_INVALID,
2055 .oval = FIO_FALLOCATE_NONE,
2056 .help = "Do not pre-allocate space",
2059 .oval = FIO_FALLOCATE_POSIX,
2060 .help = "Use posix_fallocate()",
2062 #ifdef CONFIG_LINUX_FALLOCATE
2064 .oval = FIO_FALLOCATE_KEEP_SIZE,
2065 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
2068 /* Compatibility with former boolean values */
2070 .oval = FIO_FALLOCATE_NONE,
2071 .help = "Alias for 'none'",
2074 .oval = FIO_FALLOCATE_POSIX,
2075 .help = "Alias for 'posix'",
2079 #endif /* CONFIG_POSIX_FALLOCATE */
2081 .name = "fadvise_hint",
2082 .lname = "Fadvise hint",
2083 .type = FIO_OPT_BOOL,
2084 .off1 = td_var_offset(fadvise_hint),
2085 .help = "Use fadvise() to advise the kernel on IO pattern",
2087 .category = FIO_OPT_C_FILE,
2088 .group = FIO_OPT_G_INVALID,
2090 #ifdef FIO_HAVE_STREAMID
2092 .name = "fadvise_stream",
2093 .lname = "Fadvise stream",
2094 .type = FIO_OPT_INT,
2095 .off1 = td_var_offset(fadvise_stream),
2096 .help = "Use fadvise() to set stream ID",
2097 .category = FIO_OPT_C_FILE,
2098 .group = FIO_OPT_G_INVALID,
2104 .type = FIO_OPT_INT,
2105 .off1 = td_var_offset(fsync_blocks),
2106 .help = "Issue fsync for writes every given number of blocks",
2109 .category = FIO_OPT_C_FILE,
2110 .group = FIO_OPT_G_INVALID,
2113 .name = "fdatasync",
2114 .lname = "Fdatasync",
2115 .type = FIO_OPT_INT,
2116 .off1 = td_var_offset(fdatasync_blocks),
2117 .help = "Issue fdatasync for writes every given number of blocks",
2120 .category = FIO_OPT_C_FILE,
2121 .group = FIO_OPT_G_INVALID,
2124 .name = "write_barrier",
2125 .lname = "Write barrier",
2126 .type = FIO_OPT_INT,
2127 .off1 = td_var_offset(barrier_blocks),
2128 .help = "Make every Nth write a barrier write",
2131 .category = FIO_OPT_C_IO,
2132 .group = FIO_OPT_G_INVALID,
2134 #ifdef CONFIG_SYNC_FILE_RANGE
2136 .name = "sync_file_range",
2137 .lname = "Sync file range",
2139 { .ival = "wait_before",
2140 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
2141 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
2145 .oval = SYNC_FILE_RANGE_WRITE,
2146 .help = "SYNC_FILE_RANGE_WRITE",
2150 .ival = "wait_after",
2151 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
2152 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
2156 .type = FIO_OPT_STR_MULTI,
2158 .off1 = td_var_offset(sync_file_range),
2159 .help = "Use sync_file_range()",
2160 .category = FIO_OPT_C_FILE,
2161 .group = FIO_OPT_G_INVALID,
2166 .lname = "Direct I/O",
2167 .type = FIO_OPT_BOOL,
2168 .off1 = td_var_offset(odirect),
2169 .help = "Use O_DIRECT IO (negates buffered)",
2171 .inverse = "buffered",
2172 .category = FIO_OPT_C_IO,
2173 .group = FIO_OPT_G_IO_TYPE,
2177 .lname = "Atomic I/O",
2178 .type = FIO_OPT_BOOL,
2179 .off1 = td_var_offset(oatomic),
2180 .help = "Use Atomic IO with O_DIRECT (implies O_DIRECT)",
2182 .category = FIO_OPT_C_IO,
2183 .group = FIO_OPT_G_IO_TYPE,
2187 .lname = "Buffered I/O",
2188 .type = FIO_OPT_BOOL,
2189 .off1 = td_var_offset(odirect),
2191 .help = "Use buffered IO (negates direct)",
2193 .inverse = "direct",
2194 .category = FIO_OPT_C_IO,
2195 .group = FIO_OPT_G_IO_TYPE,
2198 .name = "overwrite",
2199 .lname = "Overwrite",
2200 .type = FIO_OPT_BOOL,
2201 .off1 = td_var_offset(overwrite),
2202 .help = "When writing, set whether to overwrite current data",
2204 .category = FIO_OPT_C_FILE,
2205 .group = FIO_OPT_G_INVALID,
2210 .type = FIO_OPT_INT,
2211 .off1 = td_var_offset(loops),
2212 .help = "Number of times to run the job",
2215 .category = FIO_OPT_C_GENERAL,
2216 .group = FIO_OPT_G_RUNTIME,
2220 .lname = "Number of jobs",
2221 .type = FIO_OPT_INT,
2222 .off1 = td_var_offset(numjobs),
2223 .help = "Duplicate this job this many times",
2226 .category = FIO_OPT_C_GENERAL,
2227 .group = FIO_OPT_G_RUNTIME,
2230 .name = "startdelay",
2231 .lname = "Start delay",
2232 .type = FIO_OPT_STR_VAL_TIME,
2233 .off1 = td_var_offset(start_delay),
2234 .off2 = td_var_offset(start_delay_high),
2235 .help = "Only start job when this period has passed",
2239 .category = FIO_OPT_C_GENERAL,
2240 .group = FIO_OPT_G_RUNTIME,
2246 .type = FIO_OPT_STR_VAL_TIME,
2247 .off1 = td_var_offset(timeout),
2248 .help = "Stop workload when this amount of time has passed",
2252 .category = FIO_OPT_C_GENERAL,
2253 .group = FIO_OPT_G_RUNTIME,
2256 .name = "time_based",
2257 .lname = "Time based",
2258 .type = FIO_OPT_STR_SET,
2259 .off1 = td_var_offset(time_based),
2260 .help = "Keep running until runtime/timeout is met",
2261 .category = FIO_OPT_C_GENERAL,
2262 .group = FIO_OPT_G_RUNTIME,
2265 .name = "verify_only",
2266 .lname = "Verify only",
2267 .type = FIO_OPT_STR_SET,
2268 .off1 = td_var_offset(verify_only),
2269 .help = "Verifies previously written data is still valid",
2270 .category = FIO_OPT_C_GENERAL,
2271 .group = FIO_OPT_G_RUNTIME,
2274 .name = "ramp_time",
2275 .lname = "Ramp time",
2276 .type = FIO_OPT_STR_VAL_TIME,
2277 .off1 = td_var_offset(ramp_time),
2278 .help = "Ramp up time before measuring performance",
2281 .category = FIO_OPT_C_GENERAL,
2282 .group = FIO_OPT_G_RUNTIME,
2285 .name = "clocksource",
2286 .lname = "Clock source",
2287 .type = FIO_OPT_STR,
2288 .cb = fio_clock_source_cb,
2289 .off1 = td_var_offset(clocksource),
2290 .help = "What type of timing source to use",
2291 .category = FIO_OPT_C_GENERAL,
2292 .group = FIO_OPT_G_CLOCK,
2294 #ifdef CONFIG_GETTIMEOFDAY
2295 { .ival = "gettimeofday",
2297 .help = "Use gettimeofday(2) for timing",
2300 #ifdef CONFIG_CLOCK_GETTIME
2301 { .ival = "clock_gettime",
2302 .oval = CS_CGETTIME,
2303 .help = "Use clock_gettime(2) for timing",
2306 #ifdef ARCH_HAVE_CPU_CLOCK
2308 .oval = CS_CPUCLOCK,
2309 .help = "Use CPU private clock",
2317 .lname = "I/O Memory",
2318 .type = FIO_OPT_STR,
2320 .off1 = td_var_offset(mem_type),
2321 .help = "Backing type for IO buffers",
2323 .category = FIO_OPT_C_IO,
2324 .group = FIO_OPT_G_INVALID,
2328 .help = "Use malloc(3) for IO buffers",
2330 #ifndef CONFIG_NO_SHM
2333 .help = "Use shared memory segments for IO buffers",
2335 #ifdef FIO_HAVE_HUGETLB
2336 { .ival = "shmhuge",
2337 .oval = MEM_SHMHUGE,
2338 .help = "Like shm, but use huge pages",
2344 .help = "Use mmap(2) (file or anon) for IO buffers",
2346 { .ival = "mmapshared",
2347 .oval = MEM_MMAPSHARED,
2348 .help = "Like mmap, but use the shared flag",
2350 #ifdef FIO_HAVE_HUGETLB
2351 { .ival = "mmaphuge",
2352 .oval = MEM_MMAPHUGE,
2353 .help = "Like mmap, but use huge pages",
2359 .name = "iomem_align",
2360 .alias = "mem_align",
2361 .lname = "I/O memory alignment",
2362 .type = FIO_OPT_INT,
2363 .off1 = td_var_offset(mem_align),
2365 .help = "IO memory buffer offset alignment",
2369 .category = FIO_OPT_C_IO,
2370 .group = FIO_OPT_G_INVALID,
2375 .type = FIO_OPT_STR,
2376 .off1 = td_var_offset(verify),
2377 .help = "Verify data written",
2379 .category = FIO_OPT_C_IO,
2380 .group = FIO_OPT_G_VERIFY,
2383 .oval = VERIFY_NONE,
2384 .help = "Don't do IO verification",
2388 .help = "Use md5 checksums for verification",
2391 .oval = VERIFY_CRC64,
2392 .help = "Use crc64 checksums for verification",
2395 .oval = VERIFY_CRC32,
2396 .help = "Use crc32 checksums for verification",
2398 { .ival = "crc32c-intel",
2399 .oval = VERIFY_CRC32C,
2400 .help = "Use crc32c checksums for verification (hw assisted, if available)",
2403 .oval = VERIFY_CRC32C,
2404 .help = "Use crc32c checksums for verification (hw assisted, if available)",
2407 .oval = VERIFY_CRC16,
2408 .help = "Use crc16 checksums for verification",
2411 .oval = VERIFY_CRC7,
2412 .help = "Use crc7 checksums for verification",
2415 .oval = VERIFY_SHA1,
2416 .help = "Use sha1 checksums for verification",
2419 .oval = VERIFY_SHA256,
2420 .help = "Use sha256 checksums for verification",
2423 .oval = VERIFY_SHA512,
2424 .help = "Use sha512 checksums for verification",
2427 .oval = VERIFY_XXHASH,
2428 .help = "Use xxhash checksums for verification",
2430 /* Meta information was included into verify_header,
2431 * 'meta' verification is implied by default. */
2433 .oval = VERIFY_HDR_ONLY,
2434 .help = "Use io information for verification. "
2435 "Now is implied by default, thus option is obsolete, "
2438 { .ival = "pattern",
2439 .oval = VERIFY_PATTERN_NO_HDR,
2440 .help = "Verify strict pattern",
2444 .oval = VERIFY_NULL,
2445 .help = "Pretend to verify",
2450 .name = "do_verify",
2451 .lname = "Perform verify step",
2452 .type = FIO_OPT_BOOL,
2453 .off1 = td_var_offset(do_verify),
2454 .help = "Run verification stage after write",
2458 .category = FIO_OPT_C_IO,
2459 .group = FIO_OPT_G_VERIFY,
2462 .name = "verifysort",
2463 .lname = "Verify sort",
2464 .type = FIO_OPT_BOOL,
2465 .off1 = td_var_offset(verifysort),
2466 .help = "Sort written verify blocks for read back",
2470 .category = FIO_OPT_C_IO,
2471 .group = FIO_OPT_G_VERIFY,
2474 .name = "verifysort_nr",
2475 .type = FIO_OPT_INT,
2476 .off1 = td_var_offset(verifysort_nr),
2477 .help = "Pre-load and sort verify blocks for a read workload",
2482 .category = FIO_OPT_C_IO,
2483 .group = FIO_OPT_G_VERIFY,
2486 .name = "verify_interval",
2487 .lname = "Verify interval",
2488 .type = FIO_OPT_INT,
2489 .off1 = td_var_offset(verify_interval),
2490 .minval = 2 * sizeof(struct verify_header),
2491 .help = "Store verify buffer header every N bytes",
2494 .interval = 2 * sizeof(struct verify_header),
2495 .category = FIO_OPT_C_IO,
2496 .group = FIO_OPT_G_VERIFY,
2499 .name = "verify_offset",
2500 .lname = "Verify offset",
2501 .type = FIO_OPT_INT,
2502 .help = "Offset verify header location by N bytes",
2503 .off1 = td_var_offset(verify_offset),
2504 .minval = sizeof(struct verify_header),
2507 .category = FIO_OPT_C_IO,
2508 .group = FIO_OPT_G_VERIFY,
2511 .name = "verify_pattern",
2512 .lname = "Verify pattern",
2513 .type = FIO_OPT_STR,
2514 .cb = str_verify_pattern_cb,
2515 .off1 = td_var_offset(verify_pattern),
2516 .help = "Fill pattern for IO buffers",
2519 .category = FIO_OPT_C_IO,
2520 .group = FIO_OPT_G_VERIFY,
2523 .name = "verify_fatal",
2524 .lname = "Verify fatal",
2525 .type = FIO_OPT_BOOL,
2526 .off1 = td_var_offset(verify_fatal),
2528 .help = "Exit on a single verify failure, don't continue",
2531 .category = FIO_OPT_C_IO,
2532 .group = FIO_OPT_G_VERIFY,
2535 .name = "verify_dump",
2536 .lname = "Verify dump",
2537 .type = FIO_OPT_BOOL,
2538 .off1 = td_var_offset(verify_dump),
2540 .help = "Dump contents of good and bad blocks on failure",
2543 .category = FIO_OPT_C_IO,
2544 .group = FIO_OPT_G_VERIFY,
2547 .name = "verify_async",
2548 .lname = "Verify asynchronously",
2549 .type = FIO_OPT_INT,
2550 .off1 = td_var_offset(verify_async),
2552 .help = "Number of async verifier threads to use",
2555 .category = FIO_OPT_C_IO,
2556 .group = FIO_OPT_G_VERIFY,
2559 .name = "verify_backlog",
2560 .lname = "Verify backlog",
2561 .type = FIO_OPT_STR_VAL,
2562 .off1 = td_var_offset(verify_backlog),
2563 .help = "Verify after this number of blocks are written",
2566 .category = FIO_OPT_C_IO,
2567 .group = FIO_OPT_G_VERIFY,
2570 .name = "verify_backlog_batch",
2571 .lname = "Verify backlog batch",
2572 .type = FIO_OPT_INT,
2573 .off1 = td_var_offset(verify_batch),
2574 .help = "Verify this number of IO blocks",
2577 .category = FIO_OPT_C_IO,
2578 .group = FIO_OPT_G_VERIFY,
2580 #ifdef FIO_HAVE_CPU_AFFINITY
2582 .name = "verify_async_cpus",
2583 .lname = "Async verify CPUs",
2584 .type = FIO_OPT_STR,
2585 .cb = str_verify_cpus_allowed_cb,
2586 .off1 = td_var_offset(verify_cpumask),
2587 .help = "Set CPUs allowed for async verify threads",
2588 .parent = "verify_async",
2590 .category = FIO_OPT_C_IO,
2591 .group = FIO_OPT_G_VERIFY,
2595 .name = "experimental_verify",
2596 .off1 = td_var_offset(experimental_verify),
2597 .type = FIO_OPT_BOOL,
2598 .help = "Enable experimental verification",
2600 .category = FIO_OPT_C_IO,
2601 .group = FIO_OPT_G_VERIFY,
2604 .name = "verify_state_load",
2605 .lname = "Load verify state",
2606 .off1 = td_var_offset(verify_state),
2607 .type = FIO_OPT_BOOL,
2608 .help = "Load verify termination state",
2610 .category = FIO_OPT_C_IO,
2611 .group = FIO_OPT_G_VERIFY,
2614 .name = "verify_state_save",
2615 .lname = "Save verify state",
2616 .off1 = td_var_offset(verify_state_save),
2617 .type = FIO_OPT_BOOL,
2619 .help = "Save verify state on termination",
2621 .category = FIO_OPT_C_IO,
2622 .group = FIO_OPT_G_VERIFY,
2624 #ifdef FIO_HAVE_TRIM
2626 .name = "trim_percentage",
2627 .lname = "Trim percentage",
2628 .type = FIO_OPT_INT,
2629 .off1 = td_var_offset(trim_percentage),
2632 .help = "Number of verify blocks to discard/trim",
2637 .category = FIO_OPT_C_IO,
2638 .group = FIO_OPT_G_TRIM,
2641 .name = "trim_verify_zero",
2642 .lname = "Verify trim zero",
2643 .type = FIO_OPT_BOOL,
2644 .help = "Verify that trim/discarded blocks are returned as zeroes",
2645 .off1 = td_var_offset(trim_zero),
2646 .parent = "trim_percentage",
2649 .category = FIO_OPT_C_IO,
2650 .group = FIO_OPT_G_TRIM,
2653 .name = "trim_backlog",
2654 .lname = "Trim backlog",
2655 .type = FIO_OPT_STR_VAL,
2656 .off1 = td_var_offset(trim_backlog),
2657 .help = "Trim after this number of blocks are written",
2658 .parent = "trim_percentage",
2661 .category = FIO_OPT_C_IO,
2662 .group = FIO_OPT_G_TRIM,
2665 .name = "trim_backlog_batch",
2666 .lname = "Trim backlog batch",
2667 .type = FIO_OPT_INT,
2668 .off1 = td_var_offset(trim_batch),
2669 .help = "Trim this number of IO blocks",
2670 .parent = "trim_percentage",
2673 .category = FIO_OPT_C_IO,
2674 .group = FIO_OPT_G_TRIM,
2678 .name = "write_iolog",
2679 .lname = "Write I/O log",
2680 .type = FIO_OPT_STR_STORE,
2681 .off1 = td_var_offset(write_iolog_file),
2682 .help = "Store IO pattern to file",
2683 .category = FIO_OPT_C_IO,
2684 .group = FIO_OPT_G_IOLOG,
2687 .name = "read_iolog",
2688 .lname = "Read I/O log",
2689 .type = FIO_OPT_STR_STORE,
2690 .off1 = td_var_offset(read_iolog_file),
2691 .help = "Playback IO pattern from file",
2692 .category = FIO_OPT_C_IO,
2693 .group = FIO_OPT_G_IOLOG,
2696 .name = "replay_no_stall",
2697 .lname = "Don't stall on replay",
2698 .type = FIO_OPT_BOOL,
2699 .off1 = td_var_offset(no_stall),
2701 .parent = "read_iolog",
2703 .help = "Playback IO pattern file as fast as possible without stalls",
2704 .category = FIO_OPT_C_IO,
2705 .group = FIO_OPT_G_IOLOG,
2708 .name = "replay_redirect",
2709 .lname = "Redirect device for replay",
2710 .type = FIO_OPT_STR_STORE,
2711 .off1 = td_var_offset(replay_redirect),
2712 .parent = "read_iolog",
2714 .help = "Replay all I/O onto this device, regardless of trace device",
2715 .category = FIO_OPT_C_IO,
2716 .group = FIO_OPT_G_IOLOG,
2719 .name = "replay_scale",
2720 .lname = "Replace offset scale factor",
2721 .type = FIO_OPT_INT,
2722 .off1 = td_var_offset(replay_scale),
2723 .parent = "read_iolog",
2725 .help = "Align offsets to this blocksize",
2726 .category = FIO_OPT_C_IO,
2727 .group = FIO_OPT_G_IOLOG,
2730 .name = "replay_align",
2731 .lname = "Replace alignment",
2732 .type = FIO_OPT_INT,
2733 .off1 = td_var_offset(replay_align),
2734 .parent = "read_iolog",
2735 .help = "Scale offset down by this factor",
2736 .category = FIO_OPT_C_IO,
2737 .group = FIO_OPT_G_IOLOG,
2741 .name = "exec_prerun",
2742 .lname = "Pre-execute runnable",
2743 .type = FIO_OPT_STR_STORE,
2744 .off1 = td_var_offset(exec_prerun),
2745 .help = "Execute this file prior to running job",
2746 .category = FIO_OPT_C_GENERAL,
2747 .group = FIO_OPT_G_INVALID,
2750 .name = "exec_postrun",
2751 .lname = "Post-execute runnable",
2752 .type = FIO_OPT_STR_STORE,
2753 .off1 = td_var_offset(exec_postrun),
2754 .help = "Execute this file after running job",
2755 .category = FIO_OPT_C_GENERAL,
2756 .group = FIO_OPT_G_INVALID,
2758 #ifdef FIO_HAVE_IOSCHED_SWITCH
2760 .name = "ioscheduler",
2761 .lname = "I/O scheduler",
2762 .type = FIO_OPT_STR_STORE,
2763 .off1 = td_var_offset(ioscheduler),
2764 .help = "Use this IO scheduler on the backing device",
2765 .category = FIO_OPT_C_FILE,
2766 .group = FIO_OPT_G_INVALID,
2771 .lname = "Zone size",
2772 .type = FIO_OPT_STR_VAL,
2773 .off1 = td_var_offset(zone_size),
2774 .help = "Amount of data to read per zone",
2776 .interval = 1024 * 1024,
2777 .category = FIO_OPT_C_IO,
2778 .group = FIO_OPT_G_ZONE,
2781 .name = "zonerange",
2782 .lname = "Zone range",
2783 .type = FIO_OPT_STR_VAL,
2784 .off1 = td_var_offset(zone_range),
2785 .help = "Give size of an IO zone",
2787 .interval = 1024 * 1024,
2788 .category = FIO_OPT_C_IO,
2789 .group = FIO_OPT_G_ZONE,
2793 .lname = "Zone skip",
2794 .type = FIO_OPT_STR_VAL,
2795 .off1 = td_var_offset(zone_skip),
2796 .help = "Space between IO zones",
2798 .interval = 1024 * 1024,
2799 .category = FIO_OPT_C_IO,
2800 .group = FIO_OPT_G_ZONE,
2804 .lname = "Lock memory",
2805 .type = FIO_OPT_STR_VAL,
2806 .off1 = td_var_offset(lockmem),
2807 .help = "Lock down this amount of memory (per worker)",
2809 .interval = 1024 * 1024,
2810 .category = FIO_OPT_C_GENERAL,
2811 .group = FIO_OPT_G_INVALID,
2814 .name = "rwmixread",
2815 .lname = "Read/write mix read",
2816 .type = FIO_OPT_INT,
2817 .cb = str_rwmix_read_cb,
2818 .off1 = td_var_offset(rwmix[DDIR_READ]),
2820 .help = "Percentage of mixed workload that is reads",
2823 .inverse = "rwmixwrite",
2824 .category = FIO_OPT_C_IO,
2825 .group = FIO_OPT_G_RWMIX,
2828 .name = "rwmixwrite",
2829 .lname = "Read/write mix write",
2830 .type = FIO_OPT_INT,
2831 .cb = str_rwmix_write_cb,
2832 .off1 = td_var_offset(rwmix[DDIR_WRITE]),
2834 .help = "Percentage of mixed workload that is writes",
2837 .inverse = "rwmixread",
2838 .category = FIO_OPT_C_IO,
2839 .group = FIO_OPT_G_RWMIX,
2842 .name = "rwmixcycle",
2843 .lname = "Read/write mix cycle",
2844 .type = FIO_OPT_DEPRECATED,
2845 .category = FIO_OPT_C_IO,
2846 .group = FIO_OPT_G_RWMIX,
2851 .type = FIO_OPT_INT,
2852 .off1 = td_var_offset(nice),
2853 .help = "Set job CPU nice value",
2858 .category = FIO_OPT_C_GENERAL,
2859 .group = FIO_OPT_G_CRED,
2861 #ifdef FIO_HAVE_IOPRIO
2864 .lname = "I/O nice priority",
2865 .type = FIO_OPT_INT,
2866 .off1 = td_var_offset(ioprio),
2867 .help = "Set job IO priority value",
2871 .category = FIO_OPT_C_GENERAL,
2872 .group = FIO_OPT_G_CRED,
2875 .name = "prioclass",
2876 .lname = "I/O nice priority class",
2877 .type = FIO_OPT_INT,
2878 .off1 = td_var_offset(ioprio_class),
2879 .help = "Set job IO priority class",
2883 .category = FIO_OPT_C_GENERAL,
2884 .group = FIO_OPT_G_CRED,
2888 .name = "thinktime",
2889 .lname = "Thinktime",
2890 .type = FIO_OPT_INT,
2891 .off1 = td_var_offset(thinktime),
2892 .help = "Idle time between IO buffers (usec)",
2895 .category = FIO_OPT_C_IO,
2896 .group = FIO_OPT_G_THINKTIME,
2899 .name = "thinktime_spin",
2900 .lname = "Thinktime spin",
2901 .type = FIO_OPT_INT,
2902 .off1 = td_var_offset(thinktime_spin),
2903 .help = "Start think time by spinning this amount (usec)",
2906 .parent = "thinktime",
2908 .category = FIO_OPT_C_IO,
2909 .group = FIO_OPT_G_THINKTIME,
2912 .name = "thinktime_blocks",
2913 .lname = "Thinktime blocks",
2914 .type = FIO_OPT_INT,
2915 .off1 = td_var_offset(thinktime_blocks),
2916 .help = "IO buffer period between 'thinktime'",
2918 .parent = "thinktime",
2920 .category = FIO_OPT_C_IO,
2921 .group = FIO_OPT_G_THINKTIME,
2925 .lname = "I/O rate",
2926 .type = FIO_OPT_INT,
2927 .off1 = td_var_offset(rate[DDIR_READ]),
2928 .off2 = td_var_offset(rate[DDIR_WRITE]),
2929 .off3 = td_var_offset(rate[DDIR_TRIM]),
2930 .help = "Set bandwidth rate",
2931 .category = FIO_OPT_C_IO,
2932 .group = FIO_OPT_G_RATE,
2937 .lname = "I/O min rate",
2938 .type = FIO_OPT_INT,
2939 .off1 = td_var_offset(ratemin[DDIR_READ]),
2940 .off2 = td_var_offset(ratemin[DDIR_WRITE]),
2941 .off3 = td_var_offset(ratemin[DDIR_TRIM]),
2942 .help = "Job must meet this rate or it will be shutdown",
2945 .category = FIO_OPT_C_IO,
2946 .group = FIO_OPT_G_RATE,
2949 .name = "rate_iops",
2950 .lname = "I/O rate IOPS",
2951 .type = FIO_OPT_INT,
2952 .off1 = td_var_offset(rate_iops[DDIR_READ]),
2953 .off2 = td_var_offset(rate_iops[DDIR_WRITE]),
2954 .off3 = td_var_offset(rate_iops[DDIR_TRIM]),
2955 .help = "Limit IO used to this number of IO operations/sec",
2957 .category = FIO_OPT_C_IO,
2958 .group = FIO_OPT_G_RATE,
2961 .name = "rate_iops_min",
2962 .lname = "I/O min rate IOPS",
2963 .type = FIO_OPT_INT,
2964 .off1 = td_var_offset(rate_iops_min[DDIR_READ]),
2965 .off2 = td_var_offset(rate_iops_min[DDIR_WRITE]),
2966 .off3 = td_var_offset(rate_iops_min[DDIR_TRIM]),
2967 .help = "Job must meet this rate or it will be shut down",
2968 .parent = "rate_iops",
2970 .category = FIO_OPT_C_IO,
2971 .group = FIO_OPT_G_RATE,
2974 .name = "rate_process",
2975 .lname = "Rate Process",
2976 .type = FIO_OPT_STR,
2977 .off1 = td_var_offset(rate_process),
2978 .help = "What process controls how rated IO is managed",
2980 .category = FIO_OPT_C_IO,
2981 .group = FIO_OPT_G_RATE,
2984 .oval = RATE_PROCESS_LINEAR,
2985 .help = "Linear rate of IO",
2989 .oval = RATE_PROCESS_POISSON,
2990 .help = "Rate follows Poisson process",
2996 .name = "rate_cycle",
2997 .alias = "ratecycle",
2998 .lname = "I/O rate cycle",
2999 .type = FIO_OPT_INT,
3000 .off1 = td_var_offset(ratecycle),
3001 .help = "Window average for rate limits (msec)",
3005 .category = FIO_OPT_C_IO,
3006 .group = FIO_OPT_G_RATE,
3009 .name = "max_latency",
3010 .type = FIO_OPT_INT,
3011 .off1 = td_var_offset(max_latency),
3012 .help = "Maximum tolerated IO latency (usec)",
3014 .category = FIO_OPT_C_IO,
3015 .group = FIO_OPT_G_LATPROF,
3018 .name = "latency_target",
3019 .lname = "Latency Target (usec)",
3020 .type = FIO_OPT_STR_VAL_TIME,
3021 .off1 = td_var_offset(latency_target),
3022 .help = "Ramp to max queue depth supporting this latency",
3024 .category = FIO_OPT_C_IO,
3025 .group = FIO_OPT_G_LATPROF,
3028 .name = "latency_window",
3029 .lname = "Latency Window (usec)",
3030 .type = FIO_OPT_STR_VAL_TIME,
3031 .off1 = td_var_offset(latency_window),
3032 .help = "Time to sustain latency_target",
3034 .category = FIO_OPT_C_IO,
3035 .group = FIO_OPT_G_LATPROF,
3038 .name = "latency_percentile",
3039 .lname = "Latency Percentile",
3040 .type = FIO_OPT_FLOAT_LIST,
3041 .off1 = td_var_offset(latency_percentile),
3042 .help = "Percentile of IOs must be below latency_target",
3047 .category = FIO_OPT_C_IO,
3048 .group = FIO_OPT_G_LATPROF,
3051 .name = "invalidate",
3052 .lname = "Cache invalidate",
3053 .type = FIO_OPT_BOOL,
3054 .off1 = td_var_offset(invalidate_cache),
3055 .help = "Invalidate buffer/page cache prior to running job",
3057 .category = FIO_OPT_C_IO,
3058 .group = FIO_OPT_G_IO_TYPE,
3062 .lname = "Synchronous I/O",
3063 .type = FIO_OPT_BOOL,
3064 .off1 = td_var_offset(sync_io),
3065 .help = "Use O_SYNC for buffered writes",
3067 .parent = "buffered",
3069 .category = FIO_OPT_C_IO,
3070 .group = FIO_OPT_G_IO_TYPE,
3073 .name = "create_serialize",
3074 .lname = "Create serialize",
3075 .type = FIO_OPT_BOOL,
3076 .off1 = td_var_offset(create_serialize),
3077 .help = "Serialize creating of job files",
3079 .category = FIO_OPT_C_FILE,
3080 .group = FIO_OPT_G_INVALID,
3083 .name = "create_fsync",
3084 .lname = "Create fsync",
3085 .type = FIO_OPT_BOOL,
3086 .off1 = td_var_offset(create_fsync),
3087 .help = "fsync file after creation",
3089 .category = FIO_OPT_C_FILE,
3090 .group = FIO_OPT_G_INVALID,
3093 .name = "create_on_open",
3094 .lname = "Create on open",
3095 .type = FIO_OPT_BOOL,
3096 .off1 = td_var_offset(create_on_open),
3097 .help = "Create files when they are opened for IO",
3099 .category = FIO_OPT_C_FILE,
3100 .group = FIO_OPT_G_INVALID,
3103 .name = "create_only",
3104 .type = FIO_OPT_BOOL,
3105 .off1 = td_var_offset(create_only),
3106 .help = "Only perform file creation phase",
3107 .category = FIO_OPT_C_FILE,
3111 .name = "allow_file_create",
3112 .lname = "Allow file create",
3113 .type = FIO_OPT_BOOL,
3114 .off1 = td_var_offset(allow_create),
3115 .help = "Permit fio to create files, if they don't exist",
3117 .category = FIO_OPT_C_FILE,
3118 .group = FIO_OPT_G_FILENAME,
3121 .name = "allow_mounted_write",
3122 .lname = "Allow mounted write",
3123 .type = FIO_OPT_BOOL,
3124 .off1 = td_var_offset(allow_mounted_write),
3125 .help = "Allow writes to a mounted partition",
3127 .category = FIO_OPT_C_FILE,
3128 .group = FIO_OPT_G_FILENAME,
3132 .lname = "Pre-read files",
3133 .type = FIO_OPT_BOOL,
3134 .off1 = td_var_offset(pre_read),
3135 .help = "Pre-read files before starting official testing",
3137 .category = FIO_OPT_C_FILE,
3138 .group = FIO_OPT_G_INVALID,
3140 #ifdef FIO_HAVE_CPU_AFFINITY
3143 .lname = "CPU mask",
3144 .type = FIO_OPT_INT,
3145 .cb = str_cpumask_cb,
3146 .off1 = td_var_offset(cpumask),
3147 .help = "CPU affinity mask",
3148 .category = FIO_OPT_C_GENERAL,
3149 .group = FIO_OPT_G_CRED,
3152 .name = "cpus_allowed",
3153 .lname = "CPUs allowed",
3154 .type = FIO_OPT_STR,
3155 .cb = str_cpus_allowed_cb,
3156 .off1 = td_var_offset(cpumask),
3157 .help = "Set CPUs allowed",
3158 .category = FIO_OPT_C_GENERAL,
3159 .group = FIO_OPT_G_CRED,
3162 .name = "cpus_allowed_policy",
3163 .lname = "CPUs allowed distribution policy",
3164 .type = FIO_OPT_STR,
3165 .off1 = td_var_offset(cpus_allowed_policy),
3166 .help = "Distribution policy for cpus_allowed",
3167 .parent = "cpus_allowed",
3171 .oval = FIO_CPUS_SHARED,
3172 .help = "Mask shared between threads",
3175 .oval = FIO_CPUS_SPLIT,
3176 .help = "Mask split between threads",
3179 .category = FIO_OPT_C_GENERAL,
3180 .group = FIO_OPT_G_CRED,
3183 #ifdef CONFIG_LIBNUMA
3185 .name = "numa_cpu_nodes",
3186 .type = FIO_OPT_STR,
3187 .cb = str_numa_cpunodes_cb,
3188 .off1 = td_var_offset(numa_cpunodes),
3189 .help = "NUMA CPU nodes bind",
3190 .category = FIO_OPT_C_GENERAL,
3191 .group = FIO_OPT_G_INVALID,
3194 .name = "numa_mem_policy",
3195 .type = FIO_OPT_STR,
3196 .cb = str_numa_mpol_cb,
3197 .off1 = td_var_offset(numa_memnodes),
3198 .help = "NUMA memory policy setup",
3199 .category = FIO_OPT_C_GENERAL,
3200 .group = FIO_OPT_G_INVALID,
3204 .name = "end_fsync",
3205 .lname = "End fsync",
3206 .type = FIO_OPT_BOOL,
3207 .off1 = td_var_offset(end_fsync),
3208 .help = "Include fsync at the end of job",
3210 .category = FIO_OPT_C_FILE,
3211 .group = FIO_OPT_G_INVALID,
3214 .name = "fsync_on_close",
3215 .lname = "Fsync on close",
3216 .type = FIO_OPT_BOOL,
3217 .off1 = td_var_offset(fsync_on_close),
3218 .help = "fsync files on close",
3220 .category = FIO_OPT_C_FILE,
3221 .group = FIO_OPT_G_INVALID,
3225 .lname = "Unlink file",
3226 .type = FIO_OPT_BOOL,
3227 .off1 = td_var_offset(unlink),
3228 .help = "Unlink created files after job has completed",
3230 .category = FIO_OPT_C_FILE,
3231 .group = FIO_OPT_G_INVALID,
3235 .lname = "Exit-all on terminate",
3236 .type = FIO_OPT_STR_SET,
3237 .cb = str_exitall_cb,
3238 .help = "Terminate all jobs when one exits",
3239 .category = FIO_OPT_C_GENERAL,
3240 .group = FIO_OPT_G_PROCESS,
3243 .name = "exitall_on_error",
3244 .lname = "Exit-all on terminate in error",
3245 .type = FIO_OPT_BOOL,
3246 .off1 = td_var_offset(unlink),
3247 .help = "Terminate all jobs when one exits in error",
3248 .category = FIO_OPT_C_GENERAL,
3249 .group = FIO_OPT_G_PROCESS,
3252 .name = "stonewall",
3253 .lname = "Wait for previous",
3254 .alias = "wait_for_previous",
3255 .type = FIO_OPT_STR_SET,
3256 .off1 = td_var_offset(stonewall),
3257 .help = "Insert a hard barrier between this job and previous",
3258 .category = FIO_OPT_C_GENERAL,
3259 .group = FIO_OPT_G_PROCESS,
3262 .name = "new_group",
3263 .lname = "New group",
3264 .type = FIO_OPT_STR_SET,
3265 .off1 = td_var_offset(new_group),
3266 .help = "Mark the start of a new group (for reporting)",
3267 .category = FIO_OPT_C_GENERAL,
3268 .group = FIO_OPT_G_PROCESS,
3273 .type = FIO_OPT_STR_SET,
3274 .off1 = td_var_offset(use_thread),
3275 .help = "Use threads instead of processes",
3276 #ifdef CONFIG_NO_SHM
3280 .category = FIO_OPT_C_GENERAL,
3281 .group = FIO_OPT_G_PROCESS,
3284 .name = "per_job_logs",
3285 .type = FIO_OPT_BOOL,
3286 .off1 = td_var_offset(per_job_logs),
3287 .help = "Include job number in generated log files or not",
3289 .category = FIO_OPT_C_LOG,
3290 .group = FIO_OPT_G_INVALID,
3293 .name = "write_bw_log",
3294 .lname = "Write bandwidth log",
3295 .type = FIO_OPT_STR_STORE,
3296 .off1 = td_var_offset(bw_log_file),
3297 .help = "Write log of bandwidth during run",
3298 .category = FIO_OPT_C_LOG,
3299 .group = FIO_OPT_G_INVALID,
3302 .name = "write_lat_log",
3303 .lname = "Write latency log",
3304 .type = FIO_OPT_STR_STORE,
3305 .off1 = td_var_offset(lat_log_file),
3306 .help = "Write log of latency during run",
3307 .category = FIO_OPT_C_LOG,
3308 .group = FIO_OPT_G_INVALID,
3311 .name = "write_iops_log",
3312 .lname = "Write IOPS log",
3313 .type = FIO_OPT_STR_STORE,
3314 .off1 = td_var_offset(iops_log_file),
3315 .help = "Write log of IOPS during run",
3316 .category = FIO_OPT_C_LOG,
3317 .group = FIO_OPT_G_INVALID,
3320 .name = "log_avg_msec",
3321 .lname = "Log averaging (msec)",
3322 .type = FIO_OPT_INT,
3323 .off1 = td_var_offset(log_avg_msec),
3324 .help = "Average bw/iops/lat logs over this period of time",
3326 .category = FIO_OPT_C_LOG,
3327 .group = FIO_OPT_G_INVALID,
3330 .name = "log_max_value",
3331 .lname = "Log maximum instead of average",
3332 .type = FIO_OPT_BOOL,
3333 .off1 = td_var_offset(log_max),
3334 .help = "Log max sample in a window instead of average",
3336 .category = FIO_OPT_C_LOG,
3337 .group = FIO_OPT_G_INVALID,
3340 .name = "log_offset",
3341 .lname = "Log offset of IO",
3342 .type = FIO_OPT_BOOL,
3343 .off1 = td_var_offset(log_offset),
3344 .help = "Include offset of IO for each log entry",
3346 .category = FIO_OPT_C_LOG,
3347 .group = FIO_OPT_G_INVALID,
3351 .name = "log_compression",
3352 .lname = "Log compression",
3353 .type = FIO_OPT_INT,
3354 .off1 = td_var_offset(log_gz),
3355 .help = "Log in compressed chunks of this size",
3357 .maxval = 512 * 1024 * 1024ULL,
3358 .category = FIO_OPT_C_LOG,
3359 .group = FIO_OPT_G_INVALID,
3361 #ifdef FIO_HAVE_CPU_AFFINITY
3363 .name = "log_compression_cpus",
3364 .lname = "Log Compression CPUs",
3365 .type = FIO_OPT_STR,
3366 .cb = str_log_cpus_allowed_cb,
3367 .off1 = td_var_offset(log_gz_cpumask),
3368 .parent = "log_compression",
3369 .help = "Limit log compression to these CPUs",
3370 .category = FIO_OPT_C_LOG,
3371 .group = FIO_OPT_G_INVALID,
3375 .name = "log_store_compressed",
3376 .lname = "Log store compressed",
3377 .type = FIO_OPT_BOOL,
3378 .off1 = td_var_offset(log_gz_store),
3379 .help = "Store logs in a compressed format",
3380 .category = FIO_OPT_C_LOG,
3381 .group = FIO_OPT_G_INVALID,
3385 .name = "block_error_percentiles",
3386 .lname = "Block error percentiles",
3387 .type = FIO_OPT_BOOL,
3388 .off1 = td_var_offset(block_error_hist),
3389 .help = "Record trim block errors and make a histogram",
3391 .category = FIO_OPT_C_LOG,
3392 .group = FIO_OPT_G_INVALID,
3395 .name = "bwavgtime",
3396 .lname = "Bandwidth average time",
3397 .type = FIO_OPT_INT,
3398 .off1 = td_var_offset(bw_avg_time),
3399 .help = "Time window over which to calculate bandwidth"
3402 .parent = "write_bw_log",
3405 .category = FIO_OPT_C_LOG,
3406 .group = FIO_OPT_G_INVALID,
3409 .name = "iopsavgtime",
3410 .lname = "IOPS average time",
3411 .type = FIO_OPT_INT,
3412 .off1 = td_var_offset(iops_avg_time),
3413 .help = "Time window over which to calculate IOPS (msec)",
3415 .parent = "write_iops_log",
3418 .category = FIO_OPT_C_LOG,
3419 .group = FIO_OPT_G_INVALID,
3422 .name = "group_reporting",
3423 .lname = "Group reporting",
3424 .type = FIO_OPT_STR_SET,
3425 .off1 = td_var_offset(group_reporting),
3426 .help = "Do reporting on a per-group basis",
3427 .category = FIO_OPT_C_STAT,
3428 .group = FIO_OPT_G_INVALID,
3431 .name = "zero_buffers",
3432 .lname = "Zero I/O buffers",
3433 .type = FIO_OPT_STR_SET,
3434 .off1 = td_var_offset(zero_buffers),
3435 .help = "Init IO buffers to all zeroes",
3436 .category = FIO_OPT_C_IO,
3437 .group = FIO_OPT_G_IO_BUF,
3440 .name = "refill_buffers",
3441 .lname = "Refill I/O buffers",
3442 .type = FIO_OPT_STR_SET,
3443 .off1 = td_var_offset(refill_buffers),
3444 .help = "Refill IO buffers on every IO submit",
3445 .category = FIO_OPT_C_IO,
3446 .group = FIO_OPT_G_IO_BUF,
3449 .name = "scramble_buffers",
3450 .lname = "Scramble I/O buffers",
3451 .type = FIO_OPT_BOOL,
3452 .off1 = td_var_offset(scramble_buffers),
3453 .help = "Slightly scramble buffers on every IO submit",
3455 .category = FIO_OPT_C_IO,
3456 .group = FIO_OPT_G_IO_BUF,
3459 .name = "buffer_pattern",
3460 .lname = "Buffer pattern",
3461 .type = FIO_OPT_STR,
3462 .cb = str_buffer_pattern_cb,
3463 .off1 = td_var_offset(buffer_pattern),
3464 .help = "Fill pattern for IO buffers",
3465 .category = FIO_OPT_C_IO,
3466 .group = FIO_OPT_G_IO_BUF,
3469 .name = "buffer_compress_percentage",
3470 .lname = "Buffer compression percentage",
3471 .type = FIO_OPT_INT,
3472 .cb = str_buffer_compress_cb,
3473 .off1 = td_var_offset(compress_percentage),
3476 .help = "How compressible the buffer is (approximately)",
3478 .category = FIO_OPT_C_IO,
3479 .group = FIO_OPT_G_IO_BUF,
3482 .name = "buffer_compress_chunk",
3483 .lname = "Buffer compression chunk size",
3484 .type = FIO_OPT_INT,
3485 .off1 = td_var_offset(compress_chunk),
3486 .parent = "buffer_compress_percentage",
3488 .help = "Size of compressible region in buffer",
3490 .category = FIO_OPT_C_IO,
3491 .group = FIO_OPT_G_IO_BUF,
3494 .name = "dedupe_percentage",
3495 .lname = "Dedupe percentage",
3496 .type = FIO_OPT_INT,
3497 .cb = str_dedupe_cb,
3498 .off1 = td_var_offset(dedupe_percentage),
3501 .help = "Percentage of buffers that are dedupable",
3503 .category = FIO_OPT_C_IO,
3504 .group = FIO_OPT_G_IO_BUF,
3507 .name = "clat_percentiles",
3508 .lname = "Completion latency percentiles",
3509 .type = FIO_OPT_BOOL,
3510 .off1 = td_var_offset(clat_percentiles),
3511 .help = "Enable the reporting of completion latency percentiles",
3513 .category = FIO_OPT_C_STAT,
3514 .group = FIO_OPT_G_INVALID,
3517 .name = "percentile_list",
3518 .lname = "Percentile list",
3519 .type = FIO_OPT_FLOAT_LIST,
3520 .off1 = td_var_offset(percentile_list),
3521 .off2 = td_var_offset(percentile_precision),
3522 .help = "Specify a custom list of percentiles to report for "
3523 "completion latency and block errors",
3524 .def = "1:5:10:20:30:40:50:60:70:80:90:95:99:99.5:99.9:99.95:99.99",
3525 .maxlen = FIO_IO_U_LIST_MAX_LEN,
3528 .category = FIO_OPT_C_STAT,
3529 .group = FIO_OPT_G_INVALID,
3532 #ifdef FIO_HAVE_DISK_UTIL
3534 .name = "disk_util",
3535 .lname = "Disk utilization",
3536 .type = FIO_OPT_BOOL,
3537 .off1 = td_var_offset(do_disk_util),
3538 .help = "Log disk utilization statistics",
3540 .category = FIO_OPT_C_STAT,
3541 .group = FIO_OPT_G_INVALID,
3545 .name = "gtod_reduce",
3546 .lname = "Reduce gettimeofday() calls",
3547 .type = FIO_OPT_BOOL,
3548 .help = "Greatly reduce number of gettimeofday() calls",
3549 .cb = str_gtod_reduce_cb,
3552 .category = FIO_OPT_C_STAT,
3553 .group = FIO_OPT_G_INVALID,
3556 .name = "disable_lat",
3557 .lname = "Disable all latency stats",
3558 .type = FIO_OPT_BOOL,
3559 .off1 = td_var_offset(disable_lat),
3560 .help = "Disable latency numbers",
3561 .parent = "gtod_reduce",
3564 .category = FIO_OPT_C_STAT,
3565 .group = FIO_OPT_G_INVALID,
3568 .name = "disable_clat",
3569 .lname = "Disable completion latency stats",
3570 .type = FIO_OPT_BOOL,
3571 .off1 = td_var_offset(disable_clat),
3572 .help = "Disable completion latency numbers",
3573 .parent = "gtod_reduce",
3576 .category = FIO_OPT_C_STAT,
3577 .group = FIO_OPT_G_INVALID,
3580 .name = "disable_slat",
3581 .lname = "Disable submission latency stats",
3582 .type = FIO_OPT_BOOL,
3583 .off1 = td_var_offset(disable_slat),
3584 .help = "Disable submission latency numbers",
3585 .parent = "gtod_reduce",
3588 .category = FIO_OPT_C_STAT,
3589 .group = FIO_OPT_G_INVALID,
3592 .name = "disable_bw_measurement",
3593 .lname = "Disable bandwidth stats",
3594 .type = FIO_OPT_BOOL,
3595 .off1 = td_var_offset(disable_bw),
3596 .help = "Disable bandwidth logging",
3597 .parent = "gtod_reduce",
3600 .category = FIO_OPT_C_STAT,
3601 .group = FIO_OPT_G_INVALID,
3605 .lname = "Dedicated gettimeofday() CPU",
3606 .type = FIO_OPT_INT,
3607 .off1 = td_var_offset(gtod_cpu),
3608 .help = "Set up dedicated gettimeofday() thread on this CPU",
3609 .verify = gtod_cpu_verify,
3610 .category = FIO_OPT_C_GENERAL,
3611 .group = FIO_OPT_G_CLOCK,
3614 .name = "unified_rw_reporting",
3615 .type = FIO_OPT_BOOL,
3616 .off1 = td_var_offset(unified_rw_rep),
3617 .help = "Unify reporting across data direction",
3619 .category = FIO_OPT_C_GENERAL,
3620 .group = FIO_OPT_G_INVALID,
3623 .name = "continue_on_error",
3624 .lname = "Continue on error",
3625 .type = FIO_OPT_STR,
3626 .off1 = td_var_offset(continue_on_error),
3627 .help = "Continue on non-fatal errors during IO",
3629 .category = FIO_OPT_C_GENERAL,
3630 .group = FIO_OPT_G_ERR,
3633 .oval = ERROR_TYPE_NONE,
3634 .help = "Exit when an error is encountered",
3637 .oval = ERROR_TYPE_READ,
3638 .help = "Continue on read errors only",
3641 .oval = ERROR_TYPE_WRITE,
3642 .help = "Continue on write errors only",
3645 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
3646 .help = "Continue on any IO errors",
3649 .oval = ERROR_TYPE_VERIFY,
3650 .help = "Continue on verify errors only",
3653 .oval = ERROR_TYPE_ANY,
3654 .help = "Continue on all io and verify errors",
3657 .oval = ERROR_TYPE_NONE,
3658 .help = "Alias for 'none'",
3661 .oval = ERROR_TYPE_ANY,
3662 .help = "Alias for 'all'",
3667 .name = "ignore_error",
3668 .type = FIO_OPT_STR,
3669 .cb = str_ignore_error_cb,
3670 .off1 = td_var_offset(ignore_error_nr),
3671 .help = "Set a specific list of errors to ignore",
3673 .category = FIO_OPT_C_GENERAL,
3674 .group = FIO_OPT_G_ERR,
3677 .name = "error_dump",
3678 .type = FIO_OPT_BOOL,
3679 .off1 = td_var_offset(error_dump),
3681 .help = "Dump info on each error",
3682 .category = FIO_OPT_C_GENERAL,
3683 .group = FIO_OPT_G_ERR,
3688 .type = FIO_OPT_STR_STORE,
3689 .off1 = td_var_offset(profile),
3690 .help = "Select a specific builtin performance test",
3691 .category = FIO_OPT_C_PROFILE,
3692 .group = FIO_OPT_G_INVALID,
3697 .type = FIO_OPT_STR_STORE,
3698 .off1 = td_var_offset(cgroup),
3699 .help = "Add job to cgroup of this name",
3700 .category = FIO_OPT_C_GENERAL,
3701 .group = FIO_OPT_G_CGROUP,
3704 .name = "cgroup_nodelete",
3705 .lname = "Cgroup no-delete",
3706 .type = FIO_OPT_BOOL,
3707 .off1 = td_var_offset(cgroup_nodelete),
3708 .help = "Do not delete cgroups after job completion",
3711 .category = FIO_OPT_C_GENERAL,
3712 .group = FIO_OPT_G_CGROUP,
3715 .name = "cgroup_weight",
3716 .lname = "Cgroup weight",
3717 .type = FIO_OPT_INT,
3718 .off1 = td_var_offset(cgroup_weight),
3719 .help = "Use given weight for cgroup",
3723 .category = FIO_OPT_C_GENERAL,
3724 .group = FIO_OPT_G_CGROUP,
3729 .type = FIO_OPT_INT,
3730 .off1 = td_var_offset(uid),
3731 .help = "Run job with this user ID",
3732 .category = FIO_OPT_C_GENERAL,
3733 .group = FIO_OPT_G_CRED,
3737 .lname = "Group ID",
3738 .type = FIO_OPT_INT,
3739 .off1 = td_var_offset(gid),
3740 .help = "Run job with this group ID",
3741 .category = FIO_OPT_C_GENERAL,
3742 .group = FIO_OPT_G_CRED,
3747 .type = FIO_OPT_INT,
3748 .off1 = td_var_offset(kb_base),
3754 .help = "Use 1024 as the K base",
3758 .help = "Use 1000 as the K base",
3761 .help = "How many bytes per KB for reporting (1000 or 1024)",
3762 .category = FIO_OPT_C_GENERAL,
3763 .group = FIO_OPT_G_INVALID,
3766 .name = "unit_base",
3767 .lname = "Base unit for reporting (Bits or Bytes)",
3768 .type = FIO_OPT_INT,
3769 .off1 = td_var_offset(unit_base),
3774 .help = "Auto-detect",
3778 .help = "Normal (byte based)",
3782 .help = "Bit based",
3785 .help = "Bit multiple of result summary data (8 for byte, 1 for bit)",
3786 .category = FIO_OPT_C_GENERAL,
3787 .group = FIO_OPT_G_INVALID,
3790 .name = "hugepage-size",
3791 .lname = "Hugepage size",
3792 .type = FIO_OPT_INT,
3793 .off1 = td_var_offset(hugepage_size),
3794 .help = "When using hugepages, specify size of each page",
3795 .def = __fio_stringify(FIO_HUGE_PAGE),
3796 .interval = 1024 * 1024,
3797 .category = FIO_OPT_C_GENERAL,
3798 .group = FIO_OPT_G_INVALID,
3802 .lname = "I/O flow ID",
3803 .type = FIO_OPT_INT,
3804 .off1 = td_var_offset(flow_id),
3805 .help = "The flow index ID to use",
3807 .category = FIO_OPT_C_IO,
3808 .group = FIO_OPT_G_IO_FLOW,
3812 .lname = "I/O flow weight",
3813 .type = FIO_OPT_INT,
3814 .off1 = td_var_offset(flow),
3815 .help = "Weight for flow control of this job",
3816 .parent = "flow_id",
3819 .category = FIO_OPT_C_IO,
3820 .group = FIO_OPT_G_IO_FLOW,
3823 .name = "flow_watermark",
3824 .lname = "I/O flow watermark",
3825 .type = FIO_OPT_INT,
3826 .off1 = td_var_offset(flow_watermark),
3827 .help = "High watermark for flow control. This option"
3828 " should be set to the same value for all threads"
3829 " with non-zero flow.",
3830 .parent = "flow_id",
3833 .category = FIO_OPT_C_IO,
3834 .group = FIO_OPT_G_IO_FLOW,
3837 .name = "flow_sleep",
3838 .lname = "I/O flow sleep",
3839 .type = FIO_OPT_INT,
3840 .off1 = td_var_offset(flow_sleep),
3841 .help = "How many microseconds to sleep after being held"
3842 " back by the flow control mechanism",
3843 .parent = "flow_id",
3846 .category = FIO_OPT_C_IO,
3847 .group = FIO_OPT_G_IO_FLOW,
3851 .lname = "Skip operations against bad blocks",
3852 .type = FIO_OPT_BOOL,
3853 .off1 = td_var_offset(skip_bad),
3854 .help = "Skip operations against known bad blocks.",
3857 .category = FIO_OPT_C_IO,
3858 .group = FIO_OPT_G_MTD,
3865 static void add_to_lopt(struct option *lopt, struct fio_option *o,
3866 const char *name, int val)
3868 lopt->name = (char *) name;
3870 if (o->type == FIO_OPT_STR_SET)
3871 lopt->has_arg = optional_argument;
3873 lopt->has_arg = required_argument;
3876 static void options_to_lopts(struct fio_option *opts,
3877 struct option *long_options,
3878 int i, int option_type)
3880 struct fio_option *o = &opts[0];
3882 add_to_lopt(&long_options[i], o, o->name, option_type);
3885 add_to_lopt(&long_options[i], o, o->alias, option_type);
3890 assert(i < FIO_NR_OPTIONS);
3894 void fio_options_set_ioengine_opts(struct option *long_options,
3895 struct thread_data *td)
3900 while (long_options[i].name) {
3901 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
3902 memset(&long_options[i], 0, sizeof(*long_options));
3909 * Just clear out the prior ioengine options.
3914 options_to_lopts(td->io_ops->options, long_options, i,
3915 FIO_GETOPT_IOENGINE);
3918 void fio_options_dup_and_init(struct option *long_options)
3922 options_init(fio_options);
3925 while (long_options[i].name)
3928 options_to_lopts(fio_options, long_options, i, FIO_GETOPT_JOB);
3931 struct fio_keyword {
3937 static struct fio_keyword fio_keywords[] = {
3939 .word = "$pagesize",
3940 .desc = "Page size in the system",
3943 .word = "$mb_memory",
3944 .desc = "Megabytes of memory online",
3948 .desc = "Number of CPUs online in the system",
3955 void fio_keywords_exit(void)
3957 struct fio_keyword *kw;
3959 kw = &fio_keywords[0];
3967 void fio_keywords_init(void)
3969 unsigned long long mb_memory;
3973 sprintf(buf, "%lu", (unsigned long) page_size);
3974 fio_keywords[0].replace = strdup(buf);
3976 mb_memory = os_phys_mem() / (1024 * 1024);
3977 sprintf(buf, "%llu", mb_memory);
3978 fio_keywords[1].replace = strdup(buf);
3981 sprintf(buf, "%lu", l);
3982 fio_keywords[2].replace = strdup(buf);
3987 static char *bc_calc(char *str)
3989 char buf[128], *tmp;
3994 * No math, just return string
3996 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
3997 !strchr(str, '/')) || strchr(str, '\''))
4001 * Split option from value, we only need to calculate the value
4003 tmp = strchr(str, '=');
4010 * Prevent buffer overflows; such a case isn't reasonable anyway
4012 if (strlen(str) >= 128 || strlen(tmp) > 100)
4015 sprintf(buf, "which %s > /dev/null", BC_APP);
4017 log_err("fio: bc is needed for performing math\n");
4021 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
4022 f = popen(buf, "r");
4026 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
4033 buf[(tmp - str) + ret - 1] = '\0';
4034 memcpy(buf, str, tmp - str);
4040 * Return a copy of the input string with substrings of the form ${VARNAME}
4041 * substituted with the value of the environment variable VARNAME. The
4042 * substitution always occurs, even if VARNAME is empty or the corresponding
4043 * environment variable undefined.
4045 static char *option_dup_subs(const char *opt)
4047 char out[OPT_LEN_MAX+1];
4048 char in[OPT_LEN_MAX+1];
4051 char *ch1, *ch2, *env;
4052 ssize_t nchr = OPT_LEN_MAX;
4055 if (strlen(opt) + 1 > OPT_LEN_MAX) {
4056 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
4060 in[OPT_LEN_MAX] = '\0';
4061 strncpy(in, opt, OPT_LEN_MAX);
4063 while (*inptr && nchr > 0) {
4064 if (inptr[0] == '$' && inptr[1] == '{') {
4065 ch2 = strchr(inptr, '}');
4066 if (ch2 && inptr+1 < ch2) {
4073 envlen = strlen(env);
4074 if (envlen <= nchr) {
4075 memcpy(outptr, env, envlen);
4085 *outptr++ = *inptr++;
4094 * Look for reserved variable names and replace them with real values
4096 static char *fio_keyword_replace(char *opt)
4102 for (i = 0; fio_keywords[i].word != NULL; i++) {
4103 struct fio_keyword *kw = &fio_keywords[i];
4105 while ((s = strstr(opt, kw->word)) != NULL) {
4106 char *new = malloc(strlen(opt) + 1);
4112 * Copy part of the string before the keyword and
4113 * sprintf() the replacement after it.
4115 memcpy(new, opt, olen);
4116 len = sprintf(new + olen, "%s", kw->replace);
4119 * If there's more in the original string, copy that
4122 opt += strlen(kw->word) + olen;
4124 memcpy(new + olen + len, opt, opt - o_org - 1);
4127 * replace opt and free the old opt
4137 * Check for potential math and invoke bc, if possible
4145 static char **dup_and_sub_options(char **opts, int num_opts)
4148 char **opts_copy = malloc(num_opts * sizeof(*opts));
4149 for (i = 0; i < num_opts; i++) {
4150 opts_copy[i] = option_dup_subs(opts[i]);
4153 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
4158 static void show_closest_option(const char *opt)
4160 int best_option, best_distance;
4169 while (name[i] != '\0' && name[i] != '=')
4174 best_distance = INT_MAX;
4176 while (fio_options[i].name) {
4177 distance = string_distance(name, fio_options[i].name);
4178 if (distance < best_distance) {
4179 best_distance = distance;
4185 if (best_option != -1 && string_distance_ok(name, best_distance))
4186 log_err("Did you mean %s?\n", fio_options[best_option].name);
4191 int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
4193 int i, ret, unknown;
4196 sort_options(opts, fio_options, num_opts);
4197 opts_copy = dup_and_sub_options(opts, num_opts);
4199 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
4200 struct fio_option *o;
4201 int newret = parse_option(opts_copy[i], opts[i], fio_options,
4202 &o, td, &td->opt_list);
4205 fio_option_mark_set(&td->o, o);
4213 opts_copy[i] = NULL;
4220 ret |= ioengine_load(td);
4222 sort_options(opts_copy, td->io_ops->options, num_opts);
4225 for (i = 0; i < num_opts; i++) {
4226 struct fio_option *o = NULL;
4233 newret = parse_option(opts_copy[i], opts[i],
4234 td->io_ops->options, &o,
4235 td->eo, &td->opt_list);
4239 log_err("Bad option <%s>\n", opts[i]);
4240 show_closest_option(opts[i]);
4243 opts_copy[i] = NULL;
4251 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
4255 ret = parse_cmd_option(opt, val, fio_options, td, &td->opt_list);
4257 struct fio_option *o;
4259 o = find_option(fio_options, opt);
4261 fio_option_mark_set(&td->o, o);
4267 int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
4270 return parse_cmd_option(opt, val, td->io_ops->options, td->eo,
4274 void fio_fill_default_options(struct thread_data *td)
4276 td->o.magic = OPT_MAGIC;
4277 fill_default_options(td, fio_options);
4280 int fio_show_option_help(const char *opt)
4282 return show_cmd_help(fio_options, opt);
4285 void options_mem_dupe(void *data, struct fio_option *options)
4287 struct fio_option *o;
4290 for (o = &options[0]; o->name; o++) {
4291 if (o->type != FIO_OPT_STR_STORE)
4294 ptr = td_var(data, o, o->off1);
4296 *ptr = strdup(*ptr);
4301 * dupe FIO_OPT_STR_STORE options
4303 void fio_options_mem_dupe(struct thread_data *td)
4305 options_mem_dupe(&td->o, fio_options);
4307 if (td->eo && td->io_ops) {
4308 void *oldeo = td->eo;
4310 td->eo = malloc(td->io_ops->option_struct_size);
4311 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
4312 options_mem_dupe(td->eo, td->io_ops->options);
4316 unsigned int fio_get_kb_base(void *data)
4318 struct thread_options *o = data;
4319 unsigned int kb_base = 0;
4322 * This is a hack... For private options, *data is not holding
4323 * a pointer to the thread_options, but to private data. This means
4324 * we can't safely dereference it, but magic is first so mem wise
4325 * it is valid. But this also means that if the job first sets
4326 * kb_base and expects that to be honored by private options,
4327 * it will be disappointed. We will return the global default
4330 if (o && o->magic == OPT_MAGIC)
4331 kb_base = o->kb_base;
4338 int add_option(struct fio_option *o)
4340 struct fio_option *__o;
4349 if (opt_index + 1 == FIO_MAX_OPTS) {
4350 log_err("fio: FIO_MAX_OPTS is too small\n");
4354 memcpy(&fio_options[opt_index], o, sizeof(*o));
4355 fio_options[opt_index + 1].name = NULL;
4359 void invalidate_profile_options(const char *prof_name)
4361 struct fio_option *o;
4365 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
4366 o->type = FIO_OPT_INVALID;
4367 o->prof_name = NULL;
4373 void add_opt_posval(const char *optname, const char *ival, const char *help)
4375 struct fio_option *o;
4378 o = find_option(fio_options, optname);
4382 for (i = 0; i < PARSE_MAX_VP; i++) {
4383 if (o->posval[i].ival)
4386 o->posval[i].ival = ival;
4387 o->posval[i].help = help;
4392 void del_opt_posval(const char *optname, const char *ival)
4394 struct fio_option *o;
4397 o = find_option(fio_options, optname);
4401 for (i = 0; i < PARSE_MAX_VP; i++) {
4402 if (!o->posval[i].ival)
4404 if (strcmp(o->posval[i].ival, ival))
4407 o->posval[i].ival = NULL;
4408 o->posval[i].help = NULL;
4412 void fio_options_free(struct thread_data *td)
4414 options_free(fio_options, td);
4415 if (td->eo && td->io_ops && td->io_ops->options) {
4416 options_free(td->io_ops->options, td->eo);
4422 struct fio_option *fio_option_find(const char *name)
4424 return find_option(fio_options, name);
4427 static struct fio_option *find_next_opt(struct thread_options *o,
4428 struct fio_option *from,
4431 struct fio_option *opt;
4434 from = &fio_options[0];
4440 if (off1 == from->off1) {
4445 } while (from->name);
4450 static int opt_is_set(struct thread_options *o, struct fio_option *opt)
4452 unsigned int opt_off, index, offset;
4454 opt_off = opt - &fio_options[0];
4455 index = opt_off / (8 * sizeof(uint64_t));
4456 offset = opt_off & ((8 * sizeof(uint64_t)) - 1);
4457 return (o->set_options[index] & ((uint64_t)1 << offset)) != 0;
4460 bool __fio_option_is_set(struct thread_options *o, unsigned int off1)
4462 struct fio_option *opt, *next;
4465 while ((opt = find_next_opt(o, next, off1)) != NULL) {
4466 if (opt_is_set(o, opt))
4475 void fio_option_mark_set(struct thread_options *o, struct fio_option *opt)
4477 unsigned int opt_off, index, offset;
4479 opt_off = opt - &fio_options[0];
4480 index = opt_off / (8 * sizeof(uint64_t));
4481 offset = opt_off & ((8 * sizeof(uint64_t)) - 1);
4482 o->set_options[index] |= (uint64_t)1 << offset;