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);
871 static int parse_zoned_distribution(struct thread_data *td, const char *input)
873 char *str, *p, *odir, *ddir;
876 p = str = strdup(input);
878 strip_blank_front(&str);
879 strip_blank_end(str);
881 /* We expect it to start like that, bail if not */
882 if (strncmp(str, "zoned:", 6)) {
883 log_err("fio: mismatch in zoned input <%s>\n", str);
887 str += strlen("zoned:");
889 odir = strchr(str, ',');
891 ddir = strchr(odir + 1, ',');
893 ret = zone_split_ddir(&td->o, DDIR_TRIM, ddir + 1);
899 op = strdup(odir + 1);
900 ret = zone_split_ddir(&td->o, DDIR_TRIM, op);
905 ret = zone_split_ddir(&td->o, DDIR_WRITE, odir + 1);
908 ret = zone_split_ddir(&td->o, DDIR_READ, str);
914 ret = zone_split_ddir(&td->o, DDIR_WRITE, op);
919 ret = zone_split_ddir(&td->o, DDIR_TRIM, op);
923 ret = zone_split_ddir(&td->o, DDIR_READ, str);
928 for (i = 0; i < DDIR_RWDIR_CNT; i++) {
931 dprint(FD_PARSE, "zone ddir %d (nr=%u): \n", i, td->o.zone_split_nr[i]);
933 for (j = 0; j < td->o.zone_split_nr[i]; j++) {
934 struct zone_split *zsp = &td->o.zone_split[i][j];
936 dprint(FD_PARSE, "\t%d: %u/%u\n", j, zsp->access_perc,
942 td_zone_gen_index(td);
947 static int str_random_distribution_cb(void *data, const char *str)
949 struct thread_data *td = data;
956 if (td->o.random_distribution == FIO_RAND_DIST_ZIPF)
958 else if (td->o.random_distribution == FIO_RAND_DIST_PARETO)
959 val = FIO_DEF_PARETO;
960 else if (td->o.random_distribution == FIO_RAND_DIST_GAUSS)
962 else if (td->o.random_distribution == FIO_RAND_DIST_ZONED)
963 return parse_zoned_distribution(td, str);
967 nr = get_opt_postfix(str);
968 if (nr && !str_to_float(nr, &val, 0)) {
969 log_err("fio: random postfix parsing failed\n");
976 if (td->o.random_distribution == FIO_RAND_DIST_ZIPF) {
978 log_err("fio: zipf theta must different than 1.0\n");
981 td->o.zipf_theta.u.f = val;
982 } else if (td->o.random_distribution == FIO_RAND_DIST_PARETO) {
983 if (val <= 0.00 || val >= 1.00) {
984 log_err("fio: pareto input out of range (0 < input < 1.0)\n");
987 td->o.pareto_h.u.f = val;
989 if (val <= 0.00 || val >= 100.0) {
990 log_err("fio: normal deviation out of range (0 < input < 100.0)\n");
993 td->o.gauss_dev.u.f = val;
1000 * Return next name in the string. Files are separated with ':'. If the ':'
1001 * is escaped with a '\', then that ':' is part of the filename and does not
1002 * indicate a new file.
1004 static char *get_next_name(char **ptr)
1009 if (!str || !strlen(str))
1015 * No colon, we are done
1017 p = strchr(str, ':');
1024 * We got a colon, but it's the first character. Skip and
1032 if (*(p - 1) != '\\') {
1038 memmove(p - 1, p, strlen(p) + 1);
1046 static int get_max_name_idx(char *input)
1048 unsigned int cur_idx;
1051 p = str = strdup(input);
1052 for (cur_idx = 0; ; cur_idx++)
1053 if (get_next_name(&str) == NULL)
1061 * Returns the directory at the index, indexes > entires will be
1062 * assigned via modulo division of the index
1064 int set_name_idx(char *target, size_t tlen, char *input, int index)
1066 unsigned int cur_idx;
1068 char *fname, *str, *p;
1070 p = str = strdup(input);
1072 index %= get_max_name_idx(input);
1073 for (cur_idx = 0; cur_idx <= index; cur_idx++)
1074 fname = get_next_name(&str);
1076 if (client_sockaddr_str[0]) {
1077 len = snprintf(target, tlen, "%s/%s.", fname,
1078 client_sockaddr_str);
1080 len = snprintf(target, tlen, "%s/", fname);
1082 target[tlen - 1] = '\0';
1088 static int str_filename_cb(void *data, const char *input)
1090 struct thread_data *td = data;
1091 char *fname, *str, *p;
1093 p = str = strdup(input);
1095 strip_blank_front(&str);
1096 strip_blank_end(str);
1098 if (!td->files_index)
1101 while ((fname = get_next_name(&str)) != NULL) {
1104 add_file(td, fname, 0, 1);
1111 static int str_directory_cb(void *data, const char fio_unused *unused)
1113 struct thread_data *td = data;
1115 char *dirname, *str, *p;
1121 p = str = strdup(td->o.directory);
1122 while ((dirname = get_next_name(&str)) != NULL) {
1123 if (lstat(dirname, &sb) < 0) {
1126 log_err("fio: %s is not a directory\n", dirname);
1127 td_verror(td, ret, "lstat");
1130 if (!S_ISDIR(sb.st_mode)) {
1131 log_err("fio: %s is not a directory\n", dirname);
1142 static int str_opendir_cb(void *data, const char fio_unused *str)
1144 struct thread_data *td = data;
1149 if (!td->files_index)
1152 return add_dir_files(td, td->o.opendir);
1155 static int str_buffer_pattern_cb(void *data, const char *input)
1157 struct thread_data *td = data;
1160 /* FIXME: for now buffer pattern does not support formats */
1161 ret = parse_and_fill_pattern(input, strlen(input), td->o.buffer_pattern,
1162 MAX_PATTERN_SIZE, NULL, 0, NULL, NULL);
1167 td->o.buffer_pattern_bytes = ret;
1168 if (!td->o.compress_percentage)
1169 td->o.refill_buffers = 0;
1170 td->o.scramble_buffers = 0;
1171 td->o.zero_buffers = 0;
1176 static int str_buffer_compress_cb(void *data, unsigned long long *il)
1178 struct thread_data *td = data;
1180 td->flags |= TD_F_COMPRESS;
1181 td->o.compress_percentage = *il;
1185 static int str_dedupe_cb(void *data, unsigned long long *il)
1187 struct thread_data *td = data;
1189 td->flags |= TD_F_COMPRESS;
1190 td->o.dedupe_percentage = *il;
1191 td->o.refill_buffers = 1;
1195 static int str_verify_pattern_cb(void *data, const char *input)
1197 struct pattern_fmt_desc fmt_desc[] = {
1200 .len = FIELD_SIZE(struct io_u *, offset),
1201 .paste = paste_blockoff
1204 struct thread_data *td = data;
1207 td->o.verify_fmt_sz = ARRAY_SIZE(td->o.verify_fmt);
1208 ret = parse_and_fill_pattern(input, strlen(input), td->o.verify_pattern,
1209 MAX_PATTERN_SIZE, fmt_desc, sizeof(fmt_desc),
1210 td->o.verify_fmt, &td->o.verify_fmt_sz);
1215 td->o.verify_pattern_bytes = ret;
1217 * VERIFY_* could already be set
1219 if (!fio_option_is_set(&td->o, verify))
1220 td->o.verify = VERIFY_PATTERN;
1225 static int str_gtod_reduce_cb(void *data, int *il)
1227 struct thread_data *td = data;
1230 td->o.disable_lat = !!val;
1231 td->o.disable_clat = !!val;
1232 td->o.disable_slat = !!val;
1233 td->o.disable_bw = !!val;
1234 td->o.clat_percentiles = !val;
1236 td->tv_cache_mask = 63;
1241 static int str_size_cb(void *data, unsigned long long *__val)
1243 struct thread_data *td = data;
1244 unsigned long long v = *__val;
1246 if (parse_is_percent(v)) {
1248 td->o.size_percent = -1ULL - v;
1255 static int rw_verify(struct fio_option *o, void *data)
1257 struct thread_data *td = data;
1259 if (read_only && td_write(td)) {
1260 log_err("fio: job <%s> has write bit set, but fio is in"
1261 " read-only mode\n", td->o.name);
1268 static int gtod_cpu_verify(struct fio_option *o, void *data)
1270 #ifndef FIO_HAVE_CPU_AFFINITY
1271 struct thread_data *td = data;
1273 if (td->o.gtod_cpu) {
1274 log_err("fio: platform must support CPU affinity for"
1275 "gettimeofday() offloading\n");
1284 * Map of job/command line options
1286 struct fio_option fio_options[FIO_MAX_OPTS] = {
1288 .name = "description",
1289 .lname = "Description of job",
1290 .type = FIO_OPT_STR_STORE,
1291 .off1 = td_var_offset(description),
1292 .help = "Text job description",
1293 .category = FIO_OPT_C_GENERAL,
1294 .group = FIO_OPT_G_DESC,
1298 .lname = "Job name",
1299 .type = FIO_OPT_STR_STORE,
1300 .off1 = td_var_offset(name),
1301 .help = "Name of this job",
1302 .category = FIO_OPT_C_GENERAL,
1303 .group = FIO_OPT_G_DESC,
1307 .lname = "Waitee name",
1308 .type = FIO_OPT_STR_STORE,
1309 .off1 = td_var_offset(wait_for),
1310 .help = "Name of the job this one wants to wait for before starting",
1311 .category = FIO_OPT_C_GENERAL,
1312 .group = FIO_OPT_G_DESC,
1316 .lname = "Filename(s)",
1317 .type = FIO_OPT_STR_STORE,
1318 .off1 = td_var_offset(filename),
1319 .cb = str_filename_cb,
1320 .prio = -1, /* must come after "directory" */
1321 .help = "File(s) to use for the workload",
1322 .category = FIO_OPT_C_FILE,
1323 .group = FIO_OPT_G_FILENAME,
1326 .name = "directory",
1327 .lname = "Directory",
1328 .type = FIO_OPT_STR_STORE,
1329 .off1 = td_var_offset(directory),
1330 .cb = str_directory_cb,
1331 .help = "Directory to store files in",
1332 .category = FIO_OPT_C_FILE,
1333 .group = FIO_OPT_G_FILENAME,
1336 .name = "filename_format",
1337 .type = FIO_OPT_STR_STORE,
1338 .off1 = td_var_offset(filename_format),
1339 .prio = -1, /* must come after "directory" */
1340 .help = "Override default $jobname.$jobnum.$filenum naming",
1341 .def = "$jobname.$jobnum.$filenum",
1342 .category = FIO_OPT_C_FILE,
1343 .group = FIO_OPT_G_FILENAME,
1347 .lname = "Lockfile",
1348 .type = FIO_OPT_STR,
1349 .off1 = td_var_offset(file_lock_mode),
1350 .help = "Lock file when doing IO to it",
1352 .parent = "filename",
1355 .category = FIO_OPT_C_FILE,
1356 .group = FIO_OPT_G_FILENAME,
1359 .oval = FILE_LOCK_NONE,
1360 .help = "No file locking",
1362 { .ival = "exclusive",
1363 .oval = FILE_LOCK_EXCLUSIVE,
1364 .help = "Exclusive file lock",
1367 .ival = "readwrite",
1368 .oval = FILE_LOCK_READWRITE,
1369 .help = "Read vs write lock",
1375 .lname = "Open directory",
1376 .type = FIO_OPT_STR_STORE,
1377 .off1 = td_var_offset(opendir),
1378 .cb = str_opendir_cb,
1379 .help = "Recursively add files from this directory and down",
1380 .category = FIO_OPT_C_FILE,
1381 .group = FIO_OPT_G_FILENAME,
1385 .lname = "Read/write",
1386 .alias = "readwrite",
1387 .type = FIO_OPT_STR,
1389 .off1 = td_var_offset(td_ddir),
1390 .help = "IO direction",
1392 .verify = rw_verify,
1393 .category = FIO_OPT_C_IO,
1394 .group = FIO_OPT_G_IO_BASIC,
1397 .oval = TD_DDIR_READ,
1398 .help = "Sequential read",
1401 .oval = TD_DDIR_WRITE,
1402 .help = "Sequential write",
1405 .oval = TD_DDIR_TRIM,
1406 .help = "Sequential trim",
1408 { .ival = "randread",
1409 .oval = TD_DDIR_RANDREAD,
1410 .help = "Random read",
1412 { .ival = "randwrite",
1413 .oval = TD_DDIR_RANDWRITE,
1414 .help = "Random write",
1416 { .ival = "randtrim",
1417 .oval = TD_DDIR_RANDTRIM,
1418 .help = "Random trim",
1422 .help = "Sequential read and write mix",
1424 { .ival = "readwrite",
1426 .help = "Sequential read and write mix",
1429 .oval = TD_DDIR_RANDRW,
1430 .help = "Random read and write mix"
1432 { .ival = "trimwrite",
1433 .oval = TD_DDIR_TRIMWRITE,
1434 .help = "Trim and write mix, trims preceding writes"
1439 .name = "rw_sequencer",
1440 .lname = "RW Sequencer",
1441 .type = FIO_OPT_STR,
1442 .off1 = td_var_offset(rw_seq),
1443 .help = "IO offset generator modifier",
1444 .def = "sequential",
1445 .category = FIO_OPT_C_IO,
1446 .group = FIO_OPT_G_IO_BASIC,
1448 { .ival = "sequential",
1450 .help = "Generate sequential offsets",
1452 { .ival = "identical",
1453 .oval = RW_SEQ_IDENT,
1454 .help = "Generate identical offsets",
1461 .lname = "IO Engine",
1462 .type = FIO_OPT_STR_STORE,
1463 .off1 = td_var_offset(ioengine),
1464 .help = "IO engine to use",
1465 .def = FIO_PREFERRED_ENGINE,
1466 .category = FIO_OPT_C_IO,
1467 .group = FIO_OPT_G_IO_BASIC,
1470 .help = "Use read/write",
1473 .help = "Use pread/pwrite",
1476 .help = "Use readv/writev",
1478 #ifdef CONFIG_PWRITEV
1480 .help = "Use preadv/pwritev",
1483 #ifdef CONFIG_PWRITEV
1484 { .ival = "pvsync2",
1485 .help = "Use preadv2/pwritev2",
1488 #ifdef CONFIG_LIBAIO
1490 .help = "Linux native asynchronous IO",
1493 #ifdef CONFIG_POSIXAIO
1494 { .ival = "posixaio",
1495 .help = "POSIX asynchronous IO",
1498 #ifdef CONFIG_SOLARISAIO
1499 { .ival = "solarisaio",
1500 .help = "Solaris native asynchronous IO",
1503 #ifdef CONFIG_WINDOWSAIO
1504 { .ival = "windowsaio",
1505 .help = "Windows native asynchronous IO"
1510 .help = "Rados Block Device asynchronous IO"
1514 .help = "Memory mapped IO"
1516 #ifdef CONFIG_LINUX_SPLICE
1518 .help = "splice/vmsplice based IO",
1520 { .ival = "netsplice",
1521 .help = "splice/vmsplice to/from the network",
1524 #ifdef FIO_HAVE_SGIO
1526 .help = "SCSI generic v3 IO",
1530 .help = "Testing engine (no data transfer)",
1533 .help = "Network IO",
1536 .help = "CPU cycle burner engine",
1540 .help = "GUASI IO engine",
1543 #ifdef FIO_HAVE_BINJECT
1544 { .ival = "binject",
1545 .help = "binject direct inject block engine",
1550 .help = "RDMA IO engine",
1553 #ifdef CONFIG_FUSION_AW
1554 { .ival = "fusion-aw-sync",
1555 .help = "Fusion-io atomic write engine",
1558 #ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
1559 { .ival = "e4defrag",
1560 .help = "ext4 defrag engine",
1563 #ifdef CONFIG_LINUX_FALLOCATE
1565 .help = "fallocate() file based engine",
1570 .help = "Glusterfs libgfapi(sync) based engine"
1572 { .ival = "gfapi_async",
1573 .help = "Glusterfs libgfapi(async) based engine"
1576 #ifdef CONFIG_LIBHDFS
1577 { .ival = "libhdfs",
1578 .help = "Hadoop Distributed Filesystem (HDFS) engine"
1581 { .ival = "external",
1582 .help = "Load external engine (append name)",
1588 .lname = "IO Depth",
1589 .type = FIO_OPT_INT,
1590 .off1 = td_var_offset(iodepth),
1591 .help = "Number of IO buffers to keep in flight",
1595 .category = FIO_OPT_C_IO,
1596 .group = FIO_OPT_G_IO_BASIC,
1599 .name = "iodepth_batch",
1600 .lname = "IO Depth batch",
1601 .alias = "iodepth_batch_submit",
1602 .type = FIO_OPT_INT,
1603 .off1 = td_var_offset(iodepth_batch),
1604 .help = "Number of IO buffers to submit in one go",
1605 .parent = "iodepth",
1610 .category = FIO_OPT_C_IO,
1611 .group = FIO_OPT_G_IO_BASIC,
1614 .name = "iodepth_batch_complete_min",
1615 .lname = "Min IO depth batch complete",
1616 .alias = "iodepth_batch_complete",
1617 .type = FIO_OPT_INT,
1618 .off1 = td_var_offset(iodepth_batch_complete_min),
1619 .help = "Min number of IO buffers to retrieve in one go",
1620 .parent = "iodepth",
1625 .category = FIO_OPT_C_IO,
1626 .group = FIO_OPT_G_IO_BASIC,
1629 .name = "iodepth_batch_complete_max",
1630 .lname = "Max IO depth batch complete",
1631 .type = FIO_OPT_INT,
1632 .off1 = td_var_offset(iodepth_batch_complete_max),
1633 .help = "Max number of IO buffers to retrieve in one go",
1634 .parent = "iodepth",
1638 .category = FIO_OPT_C_IO,
1639 .group = FIO_OPT_G_IO_BASIC,
1642 .name = "iodepth_low",
1643 .lname = "IO Depth batch low",
1644 .type = FIO_OPT_INT,
1645 .off1 = td_var_offset(iodepth_low),
1646 .help = "Low water mark for queuing depth",
1647 .parent = "iodepth",
1650 .category = FIO_OPT_C_IO,
1651 .group = FIO_OPT_G_IO_BASIC,
1654 .name = "io_submit_mode",
1655 .lname = "IO submit mode",
1656 .type = FIO_OPT_STR,
1657 .off1 = td_var_offset(io_submit_mode),
1658 .help = "How IO submissions and completions are done",
1660 .category = FIO_OPT_C_IO,
1661 .group = FIO_OPT_G_IO_BASIC,
1664 .oval = IO_MODE_INLINE,
1665 .help = "Submit and complete IO inline",
1667 { .ival = "offload",
1668 .oval = IO_MODE_OFFLOAD,
1669 .help = "Offload submit and complete to threads",
1676 .type = FIO_OPT_STR_VAL,
1678 .off1 = td_var_offset(size),
1679 .help = "Total size of device or files",
1680 .interval = 1024 * 1024,
1681 .category = FIO_OPT_C_IO,
1682 .group = FIO_OPT_G_INVALID,
1686 .alias = "io_limit",
1688 .type = FIO_OPT_STR_VAL,
1689 .off1 = td_var_offset(io_limit),
1690 .interval = 1024 * 1024,
1691 .category = FIO_OPT_C_IO,
1692 .group = FIO_OPT_G_INVALID,
1695 .name = "fill_device",
1696 .lname = "Fill device",
1698 .type = FIO_OPT_BOOL,
1699 .off1 = td_var_offset(fill_device),
1700 .help = "Write until an ENOSPC error occurs",
1702 .category = FIO_OPT_C_FILE,
1703 .group = FIO_OPT_G_INVALID,
1707 .lname = "File size",
1708 .type = FIO_OPT_STR_VAL,
1709 .off1 = td_var_offset(file_size_low),
1710 .off2 = td_var_offset(file_size_high),
1712 .help = "Size of individual files",
1713 .interval = 1024 * 1024,
1714 .category = FIO_OPT_C_FILE,
1715 .group = FIO_OPT_G_INVALID,
1718 .name = "file_append",
1719 .lname = "File append",
1720 .type = FIO_OPT_BOOL,
1721 .off1 = td_var_offset(file_append),
1722 .help = "IO will start at the end of the file(s)",
1724 .category = FIO_OPT_C_FILE,
1725 .group = FIO_OPT_G_INVALID,
1729 .lname = "IO offset",
1730 .alias = "fileoffset",
1731 .type = FIO_OPT_STR_VAL,
1732 .off1 = td_var_offset(start_offset),
1733 .help = "Start IO from this offset",
1735 .interval = 1024 * 1024,
1736 .category = FIO_OPT_C_IO,
1737 .group = FIO_OPT_G_INVALID,
1740 .name = "offset_increment",
1741 .lname = "IO offset increment",
1742 .type = FIO_OPT_STR_VAL,
1743 .off1 = td_var_offset(offset_increment),
1744 .help = "What is the increment from one offset to the next",
1748 .interval = 1024 * 1024,
1749 .category = FIO_OPT_C_IO,
1750 .group = FIO_OPT_G_INVALID,
1753 .name = "number_ios",
1754 .lname = "Number of IOs to perform",
1755 .type = FIO_OPT_STR_VAL,
1756 .off1 = td_var_offset(number_ios),
1757 .help = "Force job completion after this number of IOs",
1759 .category = FIO_OPT_C_IO,
1760 .group = FIO_OPT_G_INVALID,
1764 .lname = "Block size",
1765 .alias = "blocksize",
1766 .type = FIO_OPT_INT,
1767 .off1 = td_var_offset(bs[DDIR_READ]),
1768 .off2 = td_var_offset(bs[DDIR_WRITE]),
1769 .off3 = td_var_offset(bs[DDIR_TRIM]),
1771 .help = "Block size unit",
1776 .category = FIO_OPT_C_IO,
1777 .group = FIO_OPT_G_INVALID,
1781 .lname = "Block size align",
1782 .alias = "blockalign",
1783 .type = FIO_OPT_INT,
1784 .off1 = td_var_offset(ba[DDIR_READ]),
1785 .off2 = td_var_offset(ba[DDIR_WRITE]),
1786 .off3 = td_var_offset(ba[DDIR_TRIM]),
1788 .help = "IO block offset alignment",
1792 .category = FIO_OPT_C_IO,
1793 .group = FIO_OPT_G_INVALID,
1797 .lname = "Block size range",
1798 .alias = "blocksize_range",
1799 .type = FIO_OPT_RANGE,
1800 .off1 = td_var_offset(min_bs[DDIR_READ]),
1801 .off2 = td_var_offset(max_bs[DDIR_READ]),
1802 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
1803 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
1804 .off5 = td_var_offset(min_bs[DDIR_TRIM]),
1805 .off6 = td_var_offset(max_bs[DDIR_TRIM]),
1807 .help = "Set block size range (in more detail than bs)",
1811 .category = FIO_OPT_C_IO,
1812 .group = FIO_OPT_G_INVALID,
1816 .lname = "Block size split",
1817 .type = FIO_OPT_STR,
1818 .cb = str_bssplit_cb,
1819 .off1 = td_var_offset(bssplit),
1820 .help = "Set a specific mix of block sizes",
1823 .category = FIO_OPT_C_IO,
1824 .group = FIO_OPT_G_INVALID,
1827 .name = "bs_unaligned",
1828 .lname = "Block size unaligned",
1829 .alias = "blocksize_unaligned",
1830 .type = FIO_OPT_STR_SET,
1831 .off1 = td_var_offset(bs_unaligned),
1832 .help = "Don't sector align IO buffer sizes",
1835 .category = FIO_OPT_C_IO,
1836 .group = FIO_OPT_G_INVALID,
1839 .name = "bs_is_seq_rand",
1840 .lname = "Block size division is seq/random (not read/write)",
1841 .type = FIO_OPT_BOOL,
1842 .off1 = td_var_offset(bs_is_seq_rand),
1843 .help = "Consider any blocksize setting to be sequential,random",
1845 .parent = "blocksize",
1846 .category = FIO_OPT_C_IO,
1847 .group = FIO_OPT_G_INVALID,
1850 .name = "randrepeat",
1851 .lname = "Random repeatable",
1852 .type = FIO_OPT_BOOL,
1853 .off1 = td_var_offset(rand_repeatable),
1854 .help = "Use repeatable random IO pattern",
1858 .category = FIO_OPT_C_IO,
1859 .group = FIO_OPT_G_RANDOM,
1863 .lname = "The random generator seed",
1864 .type = FIO_OPT_STR_VAL,
1865 .off1 = td_var_offset(rand_seed),
1866 .help = "Set the random generator seed value",
1869 .category = FIO_OPT_C_IO,
1870 .group = FIO_OPT_G_RANDOM,
1873 .name = "use_os_rand",
1874 .lname = "Use OS random",
1875 .type = FIO_OPT_DEPRECATED,
1876 .off1 = td_var_offset(dep_use_os_rand),
1877 .category = FIO_OPT_C_IO,
1878 .group = FIO_OPT_G_RANDOM,
1881 .name = "norandommap",
1882 .lname = "No randommap",
1883 .type = FIO_OPT_STR_SET,
1884 .off1 = td_var_offset(norandommap),
1885 .help = "Accept potential duplicate random blocks",
1889 .category = FIO_OPT_C_IO,
1890 .group = FIO_OPT_G_RANDOM,
1893 .name = "softrandommap",
1894 .lname = "Soft randommap",
1895 .type = FIO_OPT_BOOL,
1896 .off1 = td_var_offset(softrandommap),
1897 .help = "Set norandommap if randommap allocation fails",
1898 .parent = "norandommap",
1901 .category = FIO_OPT_C_IO,
1902 .group = FIO_OPT_G_RANDOM,
1905 .name = "random_generator",
1906 .type = FIO_OPT_STR,
1907 .off1 = td_var_offset(random_generator),
1908 .help = "Type of random number generator to use",
1909 .def = "tausworthe",
1911 { .ival = "tausworthe",
1912 .oval = FIO_RAND_GEN_TAUSWORTHE,
1913 .help = "Strong Tausworthe generator",
1916 .oval = FIO_RAND_GEN_LFSR,
1917 .help = "Variable length LFSR",
1920 .ival = "tausworthe64",
1921 .oval = FIO_RAND_GEN_TAUSWORTHE64,
1922 .help = "64-bit Tausworthe variant",
1925 .category = FIO_OPT_C_IO,
1926 .group = FIO_OPT_G_RANDOM,
1929 .name = "random_distribution",
1930 .type = FIO_OPT_STR,
1931 .off1 = td_var_offset(random_distribution),
1932 .cb = str_random_distribution_cb,
1933 .help = "Random offset distribution generator",
1937 .oval = FIO_RAND_DIST_RANDOM,
1938 .help = "Completely random",
1941 .oval = FIO_RAND_DIST_ZIPF,
1942 .help = "Zipf distribution",
1945 .oval = FIO_RAND_DIST_PARETO,
1946 .help = "Pareto distribution",
1949 .oval = FIO_RAND_DIST_GAUSS,
1950 .help = "Normal (gaussian) distribution",
1953 .oval = FIO_RAND_DIST_ZONED,
1954 .help = "Zoned random distribution",
1958 .category = FIO_OPT_C_IO,
1959 .group = FIO_OPT_G_RANDOM,
1962 .name = "percentage_random",
1963 .lname = "Percentage Random",
1964 .type = FIO_OPT_INT,
1965 .off1 = td_var_offset(perc_rand[DDIR_READ]),
1966 .off2 = td_var_offset(perc_rand[DDIR_WRITE]),
1967 .off3 = td_var_offset(perc_rand[DDIR_TRIM]),
1969 .help = "Percentage of seq/random mix that should be random",
1970 .def = "100,100,100",
1972 .inverse = "percentage_sequential",
1973 .category = FIO_OPT_C_IO,
1974 .group = FIO_OPT_G_RANDOM,
1977 .name = "percentage_sequential",
1978 .lname = "Percentage Sequential",
1979 .type = FIO_OPT_DEPRECATED,
1980 .category = FIO_OPT_C_IO,
1981 .group = FIO_OPT_G_RANDOM,
1984 .name = "allrandrepeat",
1985 .type = FIO_OPT_BOOL,
1986 .off1 = td_var_offset(allrand_repeatable),
1987 .help = "Use repeatable random numbers for everything",
1989 .category = FIO_OPT_C_IO,
1990 .group = FIO_OPT_G_RANDOM,
1994 .lname = "Number of files",
1995 .alias = "nr_files",
1996 .type = FIO_OPT_INT,
1997 .off1 = td_var_offset(nr_files),
1998 .help = "Split job workload between this number of files",
2001 .category = FIO_OPT_C_FILE,
2002 .group = FIO_OPT_G_INVALID,
2005 .name = "openfiles",
2006 .lname = "Number of open files",
2007 .type = FIO_OPT_INT,
2008 .off1 = td_var_offset(open_files),
2009 .help = "Number of files to keep open at the same time",
2010 .category = FIO_OPT_C_FILE,
2011 .group = FIO_OPT_G_INVALID,
2014 .name = "file_service_type",
2015 .lname = "File service type",
2016 .type = FIO_OPT_STR,
2018 .off1 = td_var_offset(file_service_type),
2019 .help = "How to select which file to service next",
2020 .def = "roundrobin",
2021 .category = FIO_OPT_C_FILE,
2022 .group = FIO_OPT_G_INVALID,
2025 .oval = FIO_FSERVICE_RANDOM,
2026 .help = "Choose a file at random",
2028 { .ival = "roundrobin",
2029 .oval = FIO_FSERVICE_RR,
2030 .help = "Round robin select files",
2032 { .ival = "sequential",
2033 .oval = FIO_FSERVICE_SEQ,
2034 .help = "Finish one file before moving to the next",
2037 .parent = "nrfiles",
2040 #ifdef CONFIG_POSIX_FALLOCATE
2042 .name = "fallocate",
2043 .lname = "Fallocate",
2044 .type = FIO_OPT_STR,
2045 .off1 = td_var_offset(fallocate_mode),
2046 .help = "Whether pre-allocation is performed when laying out files",
2048 .category = FIO_OPT_C_FILE,
2049 .group = FIO_OPT_G_INVALID,
2052 .oval = FIO_FALLOCATE_NONE,
2053 .help = "Do not pre-allocate space",
2056 .oval = FIO_FALLOCATE_POSIX,
2057 .help = "Use posix_fallocate()",
2059 #ifdef CONFIG_LINUX_FALLOCATE
2061 .oval = FIO_FALLOCATE_KEEP_SIZE,
2062 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
2065 /* Compatibility with former boolean values */
2067 .oval = FIO_FALLOCATE_NONE,
2068 .help = "Alias for 'none'",
2071 .oval = FIO_FALLOCATE_POSIX,
2072 .help = "Alias for 'posix'",
2076 #endif /* CONFIG_POSIX_FALLOCATE */
2078 .name = "fadvise_hint",
2079 .lname = "Fadvise hint",
2080 .type = FIO_OPT_BOOL,
2081 .off1 = td_var_offset(fadvise_hint),
2082 .help = "Use fadvise() to advise the kernel on IO pattern",
2084 .category = FIO_OPT_C_FILE,
2085 .group = FIO_OPT_G_INVALID,
2087 #ifdef FIO_HAVE_STREAMID
2089 .name = "fadvise_stream",
2090 .lname = "Fadvise stream",
2091 .type = FIO_OPT_INT,
2092 .off1 = td_var_offset(fadvise_stream),
2093 .help = "Use fadvise() to set stream ID",
2094 .category = FIO_OPT_C_FILE,
2095 .group = FIO_OPT_G_INVALID,
2101 .type = FIO_OPT_INT,
2102 .off1 = td_var_offset(fsync_blocks),
2103 .help = "Issue fsync for writes every given number of blocks",
2106 .category = FIO_OPT_C_FILE,
2107 .group = FIO_OPT_G_INVALID,
2110 .name = "fdatasync",
2111 .lname = "Fdatasync",
2112 .type = FIO_OPT_INT,
2113 .off1 = td_var_offset(fdatasync_blocks),
2114 .help = "Issue fdatasync for writes every given number of blocks",
2117 .category = FIO_OPT_C_FILE,
2118 .group = FIO_OPT_G_INVALID,
2121 .name = "write_barrier",
2122 .lname = "Write barrier",
2123 .type = FIO_OPT_INT,
2124 .off1 = td_var_offset(barrier_blocks),
2125 .help = "Make every Nth write a barrier write",
2128 .category = FIO_OPT_C_IO,
2129 .group = FIO_OPT_G_INVALID,
2131 #ifdef CONFIG_SYNC_FILE_RANGE
2133 .name = "sync_file_range",
2134 .lname = "Sync file range",
2136 { .ival = "wait_before",
2137 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
2138 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
2142 .oval = SYNC_FILE_RANGE_WRITE,
2143 .help = "SYNC_FILE_RANGE_WRITE",
2147 .ival = "wait_after",
2148 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
2149 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
2153 .type = FIO_OPT_STR_MULTI,
2155 .off1 = td_var_offset(sync_file_range),
2156 .help = "Use sync_file_range()",
2157 .category = FIO_OPT_C_FILE,
2158 .group = FIO_OPT_G_INVALID,
2163 .lname = "Direct I/O",
2164 .type = FIO_OPT_BOOL,
2165 .off1 = td_var_offset(odirect),
2166 .help = "Use O_DIRECT IO (negates buffered)",
2168 .inverse = "buffered",
2169 .category = FIO_OPT_C_IO,
2170 .group = FIO_OPT_G_IO_TYPE,
2174 .lname = "Atomic I/O",
2175 .type = FIO_OPT_BOOL,
2176 .off1 = td_var_offset(oatomic),
2177 .help = "Use Atomic IO with O_DIRECT (implies O_DIRECT)",
2179 .category = FIO_OPT_C_IO,
2180 .group = FIO_OPT_G_IO_TYPE,
2184 .lname = "Buffered I/O",
2185 .type = FIO_OPT_BOOL,
2186 .off1 = td_var_offset(odirect),
2188 .help = "Use buffered IO (negates direct)",
2190 .inverse = "direct",
2191 .category = FIO_OPT_C_IO,
2192 .group = FIO_OPT_G_IO_TYPE,
2195 .name = "overwrite",
2196 .lname = "Overwrite",
2197 .type = FIO_OPT_BOOL,
2198 .off1 = td_var_offset(overwrite),
2199 .help = "When writing, set whether to overwrite current data",
2201 .category = FIO_OPT_C_FILE,
2202 .group = FIO_OPT_G_INVALID,
2207 .type = FIO_OPT_INT,
2208 .off1 = td_var_offset(loops),
2209 .help = "Number of times to run the job",
2212 .category = FIO_OPT_C_GENERAL,
2213 .group = FIO_OPT_G_RUNTIME,
2217 .lname = "Number of jobs",
2218 .type = FIO_OPT_INT,
2219 .off1 = td_var_offset(numjobs),
2220 .help = "Duplicate this job this many times",
2223 .category = FIO_OPT_C_GENERAL,
2224 .group = FIO_OPT_G_RUNTIME,
2227 .name = "startdelay",
2228 .lname = "Start delay",
2229 .type = FIO_OPT_STR_VAL_TIME,
2230 .off1 = td_var_offset(start_delay),
2231 .off2 = td_var_offset(start_delay_high),
2232 .help = "Only start job when this period has passed",
2236 .category = FIO_OPT_C_GENERAL,
2237 .group = FIO_OPT_G_RUNTIME,
2243 .type = FIO_OPT_STR_VAL_TIME,
2244 .off1 = td_var_offset(timeout),
2245 .help = "Stop workload when this amount of time has passed",
2249 .category = FIO_OPT_C_GENERAL,
2250 .group = FIO_OPT_G_RUNTIME,
2253 .name = "time_based",
2254 .lname = "Time based",
2255 .type = FIO_OPT_STR_SET,
2256 .off1 = td_var_offset(time_based),
2257 .help = "Keep running until runtime/timeout is met",
2258 .category = FIO_OPT_C_GENERAL,
2259 .group = FIO_OPT_G_RUNTIME,
2262 .name = "verify_only",
2263 .lname = "Verify only",
2264 .type = FIO_OPT_STR_SET,
2265 .off1 = td_var_offset(verify_only),
2266 .help = "Verifies previously written data is still valid",
2267 .category = FIO_OPT_C_GENERAL,
2268 .group = FIO_OPT_G_RUNTIME,
2271 .name = "ramp_time",
2272 .lname = "Ramp time",
2273 .type = FIO_OPT_STR_VAL_TIME,
2274 .off1 = td_var_offset(ramp_time),
2275 .help = "Ramp up time before measuring performance",
2278 .category = FIO_OPT_C_GENERAL,
2279 .group = FIO_OPT_G_RUNTIME,
2282 .name = "clocksource",
2283 .lname = "Clock source",
2284 .type = FIO_OPT_STR,
2285 .cb = fio_clock_source_cb,
2286 .off1 = td_var_offset(clocksource),
2287 .help = "What type of timing source to use",
2288 .category = FIO_OPT_C_GENERAL,
2289 .group = FIO_OPT_G_CLOCK,
2291 #ifdef CONFIG_GETTIMEOFDAY
2292 { .ival = "gettimeofday",
2294 .help = "Use gettimeofday(2) for timing",
2297 #ifdef CONFIG_CLOCK_GETTIME
2298 { .ival = "clock_gettime",
2299 .oval = CS_CGETTIME,
2300 .help = "Use clock_gettime(2) for timing",
2303 #ifdef ARCH_HAVE_CPU_CLOCK
2305 .oval = CS_CPUCLOCK,
2306 .help = "Use CPU private clock",
2314 .lname = "I/O Memory",
2315 .type = FIO_OPT_STR,
2317 .off1 = td_var_offset(mem_type),
2318 .help = "Backing type for IO buffers",
2320 .category = FIO_OPT_C_IO,
2321 .group = FIO_OPT_G_INVALID,
2325 .help = "Use malloc(3) for IO buffers",
2327 #ifndef CONFIG_NO_SHM
2330 .help = "Use shared memory segments for IO buffers",
2332 #ifdef FIO_HAVE_HUGETLB
2333 { .ival = "shmhuge",
2334 .oval = MEM_SHMHUGE,
2335 .help = "Like shm, but use huge pages",
2341 .help = "Use mmap(2) (file or anon) for IO buffers",
2343 { .ival = "mmapshared",
2344 .oval = MEM_MMAPSHARED,
2345 .help = "Like mmap, but use the shared flag",
2347 #ifdef FIO_HAVE_HUGETLB
2348 { .ival = "mmaphuge",
2349 .oval = MEM_MMAPHUGE,
2350 .help = "Like mmap, but use huge pages",
2356 .name = "iomem_align",
2357 .alias = "mem_align",
2358 .lname = "I/O memory alignment",
2359 .type = FIO_OPT_INT,
2360 .off1 = td_var_offset(mem_align),
2362 .help = "IO memory buffer offset alignment",
2366 .category = FIO_OPT_C_IO,
2367 .group = FIO_OPT_G_INVALID,
2372 .type = FIO_OPT_STR,
2373 .off1 = td_var_offset(verify),
2374 .help = "Verify data written",
2376 .category = FIO_OPT_C_IO,
2377 .group = FIO_OPT_G_VERIFY,
2380 .oval = VERIFY_NONE,
2381 .help = "Don't do IO verification",
2385 .help = "Use md5 checksums for verification",
2388 .oval = VERIFY_CRC64,
2389 .help = "Use crc64 checksums for verification",
2392 .oval = VERIFY_CRC32,
2393 .help = "Use crc32 checksums for verification",
2395 { .ival = "crc32c-intel",
2396 .oval = VERIFY_CRC32C,
2397 .help = "Use crc32c checksums for verification (hw assisted, if available)",
2400 .oval = VERIFY_CRC32C,
2401 .help = "Use crc32c checksums for verification (hw assisted, if available)",
2404 .oval = VERIFY_CRC16,
2405 .help = "Use crc16 checksums for verification",
2408 .oval = VERIFY_CRC7,
2409 .help = "Use crc7 checksums for verification",
2412 .oval = VERIFY_SHA1,
2413 .help = "Use sha1 checksums for verification",
2416 .oval = VERIFY_SHA256,
2417 .help = "Use sha256 checksums for verification",
2420 .oval = VERIFY_SHA512,
2421 .help = "Use sha512 checksums for verification",
2424 .oval = VERIFY_XXHASH,
2425 .help = "Use xxhash checksums for verification",
2427 /* Meta information was included into verify_header,
2428 * 'meta' verification is implied by default. */
2430 .oval = VERIFY_HDR_ONLY,
2431 .help = "Use io information for verification. "
2432 "Now is implied by default, thus option is obsolete, "
2435 { .ival = "pattern",
2436 .oval = VERIFY_PATTERN_NO_HDR,
2437 .help = "Verify strict pattern",
2441 .oval = VERIFY_NULL,
2442 .help = "Pretend to verify",
2447 .name = "do_verify",
2448 .lname = "Perform verify step",
2449 .type = FIO_OPT_BOOL,
2450 .off1 = td_var_offset(do_verify),
2451 .help = "Run verification stage after write",
2455 .category = FIO_OPT_C_IO,
2456 .group = FIO_OPT_G_VERIFY,
2459 .name = "verifysort",
2460 .lname = "Verify sort",
2461 .type = FIO_OPT_BOOL,
2462 .off1 = td_var_offset(verifysort),
2463 .help = "Sort written verify blocks for read back",
2467 .category = FIO_OPT_C_IO,
2468 .group = FIO_OPT_G_VERIFY,
2471 .name = "verifysort_nr",
2472 .type = FIO_OPT_INT,
2473 .off1 = td_var_offset(verifysort_nr),
2474 .help = "Pre-load and sort verify blocks for a read workload",
2479 .category = FIO_OPT_C_IO,
2480 .group = FIO_OPT_G_VERIFY,
2483 .name = "verify_interval",
2484 .lname = "Verify interval",
2485 .type = FIO_OPT_INT,
2486 .off1 = td_var_offset(verify_interval),
2487 .minval = 2 * sizeof(struct verify_header),
2488 .help = "Store verify buffer header every N bytes",
2491 .interval = 2 * sizeof(struct verify_header),
2492 .category = FIO_OPT_C_IO,
2493 .group = FIO_OPT_G_VERIFY,
2496 .name = "verify_offset",
2497 .lname = "Verify offset",
2498 .type = FIO_OPT_INT,
2499 .help = "Offset verify header location by N bytes",
2500 .off1 = td_var_offset(verify_offset),
2501 .minval = sizeof(struct verify_header),
2504 .category = FIO_OPT_C_IO,
2505 .group = FIO_OPT_G_VERIFY,
2508 .name = "verify_pattern",
2509 .lname = "Verify pattern",
2510 .type = FIO_OPT_STR,
2511 .cb = str_verify_pattern_cb,
2512 .off1 = td_var_offset(verify_pattern),
2513 .help = "Fill pattern for IO buffers",
2516 .category = FIO_OPT_C_IO,
2517 .group = FIO_OPT_G_VERIFY,
2520 .name = "verify_fatal",
2521 .lname = "Verify fatal",
2522 .type = FIO_OPT_BOOL,
2523 .off1 = td_var_offset(verify_fatal),
2525 .help = "Exit on a single verify failure, don't continue",
2528 .category = FIO_OPT_C_IO,
2529 .group = FIO_OPT_G_VERIFY,
2532 .name = "verify_dump",
2533 .lname = "Verify dump",
2534 .type = FIO_OPT_BOOL,
2535 .off1 = td_var_offset(verify_dump),
2537 .help = "Dump contents of good and bad blocks on failure",
2540 .category = FIO_OPT_C_IO,
2541 .group = FIO_OPT_G_VERIFY,
2544 .name = "verify_async",
2545 .lname = "Verify asynchronously",
2546 .type = FIO_OPT_INT,
2547 .off1 = td_var_offset(verify_async),
2549 .help = "Number of async verifier threads to use",
2552 .category = FIO_OPT_C_IO,
2553 .group = FIO_OPT_G_VERIFY,
2556 .name = "verify_backlog",
2557 .lname = "Verify backlog",
2558 .type = FIO_OPT_STR_VAL,
2559 .off1 = td_var_offset(verify_backlog),
2560 .help = "Verify after this number of blocks are written",
2563 .category = FIO_OPT_C_IO,
2564 .group = FIO_OPT_G_VERIFY,
2567 .name = "verify_backlog_batch",
2568 .lname = "Verify backlog batch",
2569 .type = FIO_OPT_INT,
2570 .off1 = td_var_offset(verify_batch),
2571 .help = "Verify this number of IO blocks",
2574 .category = FIO_OPT_C_IO,
2575 .group = FIO_OPT_G_VERIFY,
2577 #ifdef FIO_HAVE_CPU_AFFINITY
2579 .name = "verify_async_cpus",
2580 .lname = "Async verify CPUs",
2581 .type = FIO_OPT_STR,
2582 .cb = str_verify_cpus_allowed_cb,
2583 .off1 = td_var_offset(verify_cpumask),
2584 .help = "Set CPUs allowed for async verify threads",
2585 .parent = "verify_async",
2587 .category = FIO_OPT_C_IO,
2588 .group = FIO_OPT_G_VERIFY,
2592 .name = "experimental_verify",
2593 .off1 = td_var_offset(experimental_verify),
2594 .type = FIO_OPT_BOOL,
2595 .help = "Enable experimental verification",
2597 .category = FIO_OPT_C_IO,
2598 .group = FIO_OPT_G_VERIFY,
2601 .name = "verify_state_load",
2602 .lname = "Load verify state",
2603 .off1 = td_var_offset(verify_state),
2604 .type = FIO_OPT_BOOL,
2605 .help = "Load verify termination state",
2607 .category = FIO_OPT_C_IO,
2608 .group = FIO_OPT_G_VERIFY,
2611 .name = "verify_state_save",
2612 .lname = "Save verify state",
2613 .off1 = td_var_offset(verify_state_save),
2614 .type = FIO_OPT_BOOL,
2616 .help = "Save verify state on termination",
2618 .category = FIO_OPT_C_IO,
2619 .group = FIO_OPT_G_VERIFY,
2621 #ifdef FIO_HAVE_TRIM
2623 .name = "trim_percentage",
2624 .lname = "Trim percentage",
2625 .type = FIO_OPT_INT,
2626 .off1 = td_var_offset(trim_percentage),
2629 .help = "Number of verify blocks to discard/trim",
2634 .category = FIO_OPT_C_IO,
2635 .group = FIO_OPT_G_TRIM,
2638 .name = "trim_verify_zero",
2639 .lname = "Verify trim zero",
2640 .type = FIO_OPT_BOOL,
2641 .help = "Verify that trim/discarded blocks are returned as zeroes",
2642 .off1 = td_var_offset(trim_zero),
2643 .parent = "trim_percentage",
2646 .category = FIO_OPT_C_IO,
2647 .group = FIO_OPT_G_TRIM,
2650 .name = "trim_backlog",
2651 .lname = "Trim backlog",
2652 .type = FIO_OPT_STR_VAL,
2653 .off1 = td_var_offset(trim_backlog),
2654 .help = "Trim after this number of blocks are written",
2655 .parent = "trim_percentage",
2658 .category = FIO_OPT_C_IO,
2659 .group = FIO_OPT_G_TRIM,
2662 .name = "trim_backlog_batch",
2663 .lname = "Trim backlog batch",
2664 .type = FIO_OPT_INT,
2665 .off1 = td_var_offset(trim_batch),
2666 .help = "Trim this number of IO blocks",
2667 .parent = "trim_percentage",
2670 .category = FIO_OPT_C_IO,
2671 .group = FIO_OPT_G_TRIM,
2675 .name = "write_iolog",
2676 .lname = "Write I/O log",
2677 .type = FIO_OPT_STR_STORE,
2678 .off1 = td_var_offset(write_iolog_file),
2679 .help = "Store IO pattern to file",
2680 .category = FIO_OPT_C_IO,
2681 .group = FIO_OPT_G_IOLOG,
2684 .name = "read_iolog",
2685 .lname = "Read I/O log",
2686 .type = FIO_OPT_STR_STORE,
2687 .off1 = td_var_offset(read_iolog_file),
2688 .help = "Playback IO pattern from file",
2689 .category = FIO_OPT_C_IO,
2690 .group = FIO_OPT_G_IOLOG,
2693 .name = "replay_no_stall",
2694 .lname = "Don't stall on replay",
2695 .type = FIO_OPT_BOOL,
2696 .off1 = td_var_offset(no_stall),
2698 .parent = "read_iolog",
2700 .help = "Playback IO pattern file as fast as possible without stalls",
2701 .category = FIO_OPT_C_IO,
2702 .group = FIO_OPT_G_IOLOG,
2705 .name = "replay_redirect",
2706 .lname = "Redirect device for replay",
2707 .type = FIO_OPT_STR_STORE,
2708 .off1 = td_var_offset(replay_redirect),
2709 .parent = "read_iolog",
2711 .help = "Replay all I/O onto this device, regardless of trace device",
2712 .category = FIO_OPT_C_IO,
2713 .group = FIO_OPT_G_IOLOG,
2716 .name = "replay_scale",
2717 .lname = "Replace offset scale factor",
2718 .type = FIO_OPT_INT,
2719 .off1 = td_var_offset(replay_scale),
2720 .parent = "read_iolog",
2722 .help = "Align offsets to this blocksize",
2723 .category = FIO_OPT_C_IO,
2724 .group = FIO_OPT_G_IOLOG,
2727 .name = "replay_align",
2728 .lname = "Replace alignment",
2729 .type = FIO_OPT_INT,
2730 .off1 = td_var_offset(replay_align),
2731 .parent = "read_iolog",
2732 .help = "Scale offset down by this factor",
2733 .category = FIO_OPT_C_IO,
2734 .group = FIO_OPT_G_IOLOG,
2738 .name = "exec_prerun",
2739 .lname = "Pre-execute runnable",
2740 .type = FIO_OPT_STR_STORE,
2741 .off1 = td_var_offset(exec_prerun),
2742 .help = "Execute this file prior to running job",
2743 .category = FIO_OPT_C_GENERAL,
2744 .group = FIO_OPT_G_INVALID,
2747 .name = "exec_postrun",
2748 .lname = "Post-execute runnable",
2749 .type = FIO_OPT_STR_STORE,
2750 .off1 = td_var_offset(exec_postrun),
2751 .help = "Execute this file after running job",
2752 .category = FIO_OPT_C_GENERAL,
2753 .group = FIO_OPT_G_INVALID,
2755 #ifdef FIO_HAVE_IOSCHED_SWITCH
2757 .name = "ioscheduler",
2758 .lname = "I/O scheduler",
2759 .type = FIO_OPT_STR_STORE,
2760 .off1 = td_var_offset(ioscheduler),
2761 .help = "Use this IO scheduler on the backing device",
2762 .category = FIO_OPT_C_FILE,
2763 .group = FIO_OPT_G_INVALID,
2768 .lname = "Zone size",
2769 .type = FIO_OPT_STR_VAL,
2770 .off1 = td_var_offset(zone_size),
2771 .help = "Amount of data to read per zone",
2773 .interval = 1024 * 1024,
2774 .category = FIO_OPT_C_IO,
2775 .group = FIO_OPT_G_ZONE,
2778 .name = "zonerange",
2779 .lname = "Zone range",
2780 .type = FIO_OPT_STR_VAL,
2781 .off1 = td_var_offset(zone_range),
2782 .help = "Give size of an IO zone",
2784 .interval = 1024 * 1024,
2785 .category = FIO_OPT_C_IO,
2786 .group = FIO_OPT_G_ZONE,
2790 .lname = "Zone skip",
2791 .type = FIO_OPT_STR_VAL,
2792 .off1 = td_var_offset(zone_skip),
2793 .help = "Space between IO zones",
2795 .interval = 1024 * 1024,
2796 .category = FIO_OPT_C_IO,
2797 .group = FIO_OPT_G_ZONE,
2801 .lname = "Lock memory",
2802 .type = FIO_OPT_STR_VAL,
2803 .off1 = td_var_offset(lockmem),
2804 .help = "Lock down this amount of memory (per worker)",
2806 .interval = 1024 * 1024,
2807 .category = FIO_OPT_C_GENERAL,
2808 .group = FIO_OPT_G_INVALID,
2811 .name = "rwmixread",
2812 .lname = "Read/write mix read",
2813 .type = FIO_OPT_INT,
2814 .cb = str_rwmix_read_cb,
2815 .off1 = td_var_offset(rwmix[DDIR_READ]),
2817 .help = "Percentage of mixed workload that is reads",
2820 .inverse = "rwmixwrite",
2821 .category = FIO_OPT_C_IO,
2822 .group = FIO_OPT_G_RWMIX,
2825 .name = "rwmixwrite",
2826 .lname = "Read/write mix write",
2827 .type = FIO_OPT_INT,
2828 .cb = str_rwmix_write_cb,
2829 .off1 = td_var_offset(rwmix[DDIR_WRITE]),
2831 .help = "Percentage of mixed workload that is writes",
2834 .inverse = "rwmixread",
2835 .category = FIO_OPT_C_IO,
2836 .group = FIO_OPT_G_RWMIX,
2839 .name = "rwmixcycle",
2840 .lname = "Read/write mix cycle",
2841 .type = FIO_OPT_DEPRECATED,
2842 .category = FIO_OPT_C_IO,
2843 .group = FIO_OPT_G_RWMIX,
2848 .type = FIO_OPT_INT,
2849 .off1 = td_var_offset(nice),
2850 .help = "Set job CPU nice value",
2855 .category = FIO_OPT_C_GENERAL,
2856 .group = FIO_OPT_G_CRED,
2858 #ifdef FIO_HAVE_IOPRIO
2861 .lname = "I/O nice priority",
2862 .type = FIO_OPT_INT,
2863 .off1 = td_var_offset(ioprio),
2864 .help = "Set job IO priority value",
2868 .category = FIO_OPT_C_GENERAL,
2869 .group = FIO_OPT_G_CRED,
2872 .name = "prioclass",
2873 .lname = "I/O nice priority class",
2874 .type = FIO_OPT_INT,
2875 .off1 = td_var_offset(ioprio_class),
2876 .help = "Set job IO priority class",
2880 .category = FIO_OPT_C_GENERAL,
2881 .group = FIO_OPT_G_CRED,
2885 .name = "thinktime",
2886 .lname = "Thinktime",
2887 .type = FIO_OPT_INT,
2888 .off1 = td_var_offset(thinktime),
2889 .help = "Idle time between IO buffers (usec)",
2892 .category = FIO_OPT_C_IO,
2893 .group = FIO_OPT_G_THINKTIME,
2896 .name = "thinktime_spin",
2897 .lname = "Thinktime spin",
2898 .type = FIO_OPT_INT,
2899 .off1 = td_var_offset(thinktime_spin),
2900 .help = "Start think time by spinning this amount (usec)",
2903 .parent = "thinktime",
2905 .category = FIO_OPT_C_IO,
2906 .group = FIO_OPT_G_THINKTIME,
2909 .name = "thinktime_blocks",
2910 .lname = "Thinktime blocks",
2911 .type = FIO_OPT_INT,
2912 .off1 = td_var_offset(thinktime_blocks),
2913 .help = "IO buffer period between 'thinktime'",
2915 .parent = "thinktime",
2917 .category = FIO_OPT_C_IO,
2918 .group = FIO_OPT_G_THINKTIME,
2922 .lname = "I/O rate",
2923 .type = FIO_OPT_INT,
2924 .off1 = td_var_offset(rate[DDIR_READ]),
2925 .off2 = td_var_offset(rate[DDIR_WRITE]),
2926 .off3 = td_var_offset(rate[DDIR_TRIM]),
2927 .help = "Set bandwidth rate",
2928 .category = FIO_OPT_C_IO,
2929 .group = FIO_OPT_G_RATE,
2934 .lname = "I/O min rate",
2935 .type = FIO_OPT_INT,
2936 .off1 = td_var_offset(ratemin[DDIR_READ]),
2937 .off2 = td_var_offset(ratemin[DDIR_WRITE]),
2938 .off3 = td_var_offset(ratemin[DDIR_TRIM]),
2939 .help = "Job must meet this rate or it will be shutdown",
2942 .category = FIO_OPT_C_IO,
2943 .group = FIO_OPT_G_RATE,
2946 .name = "rate_iops",
2947 .lname = "I/O rate IOPS",
2948 .type = FIO_OPT_INT,
2949 .off1 = td_var_offset(rate_iops[DDIR_READ]),
2950 .off2 = td_var_offset(rate_iops[DDIR_WRITE]),
2951 .off3 = td_var_offset(rate_iops[DDIR_TRIM]),
2952 .help = "Limit IO used to this number of IO operations/sec",
2954 .category = FIO_OPT_C_IO,
2955 .group = FIO_OPT_G_RATE,
2958 .name = "rate_iops_min",
2959 .lname = "I/O min rate IOPS",
2960 .type = FIO_OPT_INT,
2961 .off1 = td_var_offset(rate_iops_min[DDIR_READ]),
2962 .off2 = td_var_offset(rate_iops_min[DDIR_WRITE]),
2963 .off3 = td_var_offset(rate_iops_min[DDIR_TRIM]),
2964 .help = "Job must meet this rate or it will be shut down",
2965 .parent = "rate_iops",
2967 .category = FIO_OPT_C_IO,
2968 .group = FIO_OPT_G_RATE,
2971 .name = "rate_process",
2972 .lname = "Rate Process",
2973 .type = FIO_OPT_STR,
2974 .off1 = td_var_offset(rate_process),
2975 .help = "What process controls how rated IO is managed",
2977 .category = FIO_OPT_C_IO,
2978 .group = FIO_OPT_G_RATE,
2981 .oval = RATE_PROCESS_LINEAR,
2982 .help = "Linear rate of IO",
2986 .oval = RATE_PROCESS_POISSON,
2987 .help = "Rate follows Poisson process",
2993 .name = "rate_cycle",
2994 .alias = "ratecycle",
2995 .lname = "I/O rate cycle",
2996 .type = FIO_OPT_INT,
2997 .off1 = td_var_offset(ratecycle),
2998 .help = "Window average for rate limits (msec)",
3002 .category = FIO_OPT_C_IO,
3003 .group = FIO_OPT_G_RATE,
3006 .name = "max_latency",
3007 .type = FIO_OPT_INT,
3008 .off1 = td_var_offset(max_latency),
3009 .help = "Maximum tolerated IO latency (usec)",
3011 .category = FIO_OPT_C_IO,
3012 .group = FIO_OPT_G_LATPROF,
3015 .name = "latency_target",
3016 .lname = "Latency Target (usec)",
3017 .type = FIO_OPT_STR_VAL_TIME,
3018 .off1 = td_var_offset(latency_target),
3019 .help = "Ramp to max queue depth supporting this latency",
3021 .category = FIO_OPT_C_IO,
3022 .group = FIO_OPT_G_LATPROF,
3025 .name = "latency_window",
3026 .lname = "Latency Window (usec)",
3027 .type = FIO_OPT_STR_VAL_TIME,
3028 .off1 = td_var_offset(latency_window),
3029 .help = "Time to sustain latency_target",
3031 .category = FIO_OPT_C_IO,
3032 .group = FIO_OPT_G_LATPROF,
3035 .name = "latency_percentile",
3036 .lname = "Latency Percentile",
3037 .type = FIO_OPT_FLOAT_LIST,
3038 .off1 = td_var_offset(latency_percentile),
3039 .help = "Percentile of IOs must be below latency_target",
3044 .category = FIO_OPT_C_IO,
3045 .group = FIO_OPT_G_LATPROF,
3048 .name = "invalidate",
3049 .lname = "Cache invalidate",
3050 .type = FIO_OPT_BOOL,
3051 .off1 = td_var_offset(invalidate_cache),
3052 .help = "Invalidate buffer/page cache prior to running job",
3054 .category = FIO_OPT_C_IO,
3055 .group = FIO_OPT_G_IO_TYPE,
3059 .lname = "Synchronous I/O",
3060 .type = FIO_OPT_BOOL,
3061 .off1 = td_var_offset(sync_io),
3062 .help = "Use O_SYNC for buffered writes",
3064 .parent = "buffered",
3066 .category = FIO_OPT_C_IO,
3067 .group = FIO_OPT_G_IO_TYPE,
3070 .name = "create_serialize",
3071 .lname = "Create serialize",
3072 .type = FIO_OPT_BOOL,
3073 .off1 = td_var_offset(create_serialize),
3074 .help = "Serialize creating of job files",
3076 .category = FIO_OPT_C_FILE,
3077 .group = FIO_OPT_G_INVALID,
3080 .name = "create_fsync",
3081 .lname = "Create fsync",
3082 .type = FIO_OPT_BOOL,
3083 .off1 = td_var_offset(create_fsync),
3084 .help = "fsync file after creation",
3086 .category = FIO_OPT_C_FILE,
3087 .group = FIO_OPT_G_INVALID,
3090 .name = "create_on_open",
3091 .lname = "Create on open",
3092 .type = FIO_OPT_BOOL,
3093 .off1 = td_var_offset(create_on_open),
3094 .help = "Create files when they are opened for IO",
3096 .category = FIO_OPT_C_FILE,
3097 .group = FIO_OPT_G_INVALID,
3100 .name = "create_only",
3101 .type = FIO_OPT_BOOL,
3102 .off1 = td_var_offset(create_only),
3103 .help = "Only perform file creation phase",
3104 .category = FIO_OPT_C_FILE,
3108 .name = "allow_file_create",
3109 .lname = "Allow file create",
3110 .type = FIO_OPT_BOOL,
3111 .off1 = td_var_offset(allow_create),
3112 .help = "Permit fio to create files, if they don't exist",
3114 .category = FIO_OPT_C_FILE,
3115 .group = FIO_OPT_G_FILENAME,
3118 .name = "allow_mounted_write",
3119 .lname = "Allow mounted write",
3120 .type = FIO_OPT_BOOL,
3121 .off1 = td_var_offset(allow_mounted_write),
3122 .help = "Allow writes to a mounted partition",
3124 .category = FIO_OPT_C_FILE,
3125 .group = FIO_OPT_G_FILENAME,
3129 .lname = "Pre-read files",
3130 .type = FIO_OPT_BOOL,
3131 .off1 = td_var_offset(pre_read),
3132 .help = "Pre-read files before starting official testing",
3134 .category = FIO_OPT_C_FILE,
3135 .group = FIO_OPT_G_INVALID,
3137 #ifdef FIO_HAVE_CPU_AFFINITY
3140 .lname = "CPU mask",
3141 .type = FIO_OPT_INT,
3142 .cb = str_cpumask_cb,
3143 .off1 = td_var_offset(cpumask),
3144 .help = "CPU affinity mask",
3145 .category = FIO_OPT_C_GENERAL,
3146 .group = FIO_OPT_G_CRED,
3149 .name = "cpus_allowed",
3150 .lname = "CPUs allowed",
3151 .type = FIO_OPT_STR,
3152 .cb = str_cpus_allowed_cb,
3153 .off1 = td_var_offset(cpumask),
3154 .help = "Set CPUs allowed",
3155 .category = FIO_OPT_C_GENERAL,
3156 .group = FIO_OPT_G_CRED,
3159 .name = "cpus_allowed_policy",
3160 .lname = "CPUs allowed distribution policy",
3161 .type = FIO_OPT_STR,
3162 .off1 = td_var_offset(cpus_allowed_policy),
3163 .help = "Distribution policy for cpus_allowed",
3164 .parent = "cpus_allowed",
3168 .oval = FIO_CPUS_SHARED,
3169 .help = "Mask shared between threads",
3172 .oval = FIO_CPUS_SPLIT,
3173 .help = "Mask split between threads",
3176 .category = FIO_OPT_C_GENERAL,
3177 .group = FIO_OPT_G_CRED,
3180 #ifdef CONFIG_LIBNUMA
3182 .name = "numa_cpu_nodes",
3183 .type = FIO_OPT_STR,
3184 .cb = str_numa_cpunodes_cb,
3185 .off1 = td_var_offset(numa_cpunodes),
3186 .help = "NUMA CPU nodes bind",
3187 .category = FIO_OPT_C_GENERAL,
3188 .group = FIO_OPT_G_INVALID,
3191 .name = "numa_mem_policy",
3192 .type = FIO_OPT_STR,
3193 .cb = str_numa_mpol_cb,
3194 .off1 = td_var_offset(numa_memnodes),
3195 .help = "NUMA memory policy setup",
3196 .category = FIO_OPT_C_GENERAL,
3197 .group = FIO_OPT_G_INVALID,
3201 .name = "end_fsync",
3202 .lname = "End fsync",
3203 .type = FIO_OPT_BOOL,
3204 .off1 = td_var_offset(end_fsync),
3205 .help = "Include fsync at the end of job",
3207 .category = FIO_OPT_C_FILE,
3208 .group = FIO_OPT_G_INVALID,
3211 .name = "fsync_on_close",
3212 .lname = "Fsync on close",
3213 .type = FIO_OPT_BOOL,
3214 .off1 = td_var_offset(fsync_on_close),
3215 .help = "fsync files on close",
3217 .category = FIO_OPT_C_FILE,
3218 .group = FIO_OPT_G_INVALID,
3222 .lname = "Unlink file",
3223 .type = FIO_OPT_BOOL,
3224 .off1 = td_var_offset(unlink),
3225 .help = "Unlink created files after job has completed",
3227 .category = FIO_OPT_C_FILE,
3228 .group = FIO_OPT_G_INVALID,
3232 .lname = "Exit-all on terminate",
3233 .type = FIO_OPT_STR_SET,
3234 .cb = str_exitall_cb,
3235 .help = "Terminate all jobs when one exits",
3236 .category = FIO_OPT_C_GENERAL,
3237 .group = FIO_OPT_G_PROCESS,
3240 .name = "exitall_on_error",
3241 .lname = "Exit-all on terminate in error",
3242 .type = FIO_OPT_BOOL,
3243 .off1 = td_var_offset(unlink),
3244 .help = "Terminate all jobs when one exits in error",
3245 .category = FIO_OPT_C_GENERAL,
3246 .group = FIO_OPT_G_PROCESS,
3249 .name = "stonewall",
3250 .lname = "Wait for previous",
3251 .alias = "wait_for_previous",
3252 .type = FIO_OPT_STR_SET,
3253 .off1 = td_var_offset(stonewall),
3254 .help = "Insert a hard barrier between this job and previous",
3255 .category = FIO_OPT_C_GENERAL,
3256 .group = FIO_OPT_G_PROCESS,
3259 .name = "new_group",
3260 .lname = "New group",
3261 .type = FIO_OPT_STR_SET,
3262 .off1 = td_var_offset(new_group),
3263 .help = "Mark the start of a new group (for reporting)",
3264 .category = FIO_OPT_C_GENERAL,
3265 .group = FIO_OPT_G_PROCESS,
3270 .type = FIO_OPT_STR_SET,
3271 .off1 = td_var_offset(use_thread),
3272 .help = "Use threads instead of processes",
3273 #ifdef CONFIG_NO_SHM
3277 .category = FIO_OPT_C_GENERAL,
3278 .group = FIO_OPT_G_PROCESS,
3281 .name = "per_job_logs",
3282 .type = FIO_OPT_BOOL,
3283 .off1 = td_var_offset(per_job_logs),
3284 .help = "Include job number in generated log files or not",
3286 .category = FIO_OPT_C_LOG,
3287 .group = FIO_OPT_G_INVALID,
3290 .name = "write_bw_log",
3291 .lname = "Write bandwidth log",
3292 .type = FIO_OPT_STR_STORE,
3293 .off1 = td_var_offset(bw_log_file),
3294 .help = "Write log of bandwidth during run",
3295 .category = FIO_OPT_C_LOG,
3296 .group = FIO_OPT_G_INVALID,
3299 .name = "write_lat_log",
3300 .lname = "Write latency log",
3301 .type = FIO_OPT_STR_STORE,
3302 .off1 = td_var_offset(lat_log_file),
3303 .help = "Write log of latency during run",
3304 .category = FIO_OPT_C_LOG,
3305 .group = FIO_OPT_G_INVALID,
3308 .name = "write_iops_log",
3309 .lname = "Write IOPS log",
3310 .type = FIO_OPT_STR_STORE,
3311 .off1 = td_var_offset(iops_log_file),
3312 .help = "Write log of IOPS during run",
3313 .category = FIO_OPT_C_LOG,
3314 .group = FIO_OPT_G_INVALID,
3317 .name = "log_avg_msec",
3318 .lname = "Log averaging (msec)",
3319 .type = FIO_OPT_INT,
3320 .off1 = td_var_offset(log_avg_msec),
3321 .help = "Average bw/iops/lat logs over this period of time",
3323 .category = FIO_OPT_C_LOG,
3324 .group = FIO_OPT_G_INVALID,
3327 .name = "log_max_value",
3328 .lname = "Log maximum instead of average",
3329 .type = FIO_OPT_BOOL,
3330 .off1 = td_var_offset(log_max),
3331 .help = "Log max sample in a window instead of average",
3333 .category = FIO_OPT_C_LOG,
3334 .group = FIO_OPT_G_INVALID,
3337 .name = "log_offset",
3338 .lname = "Log offset of IO",
3339 .type = FIO_OPT_BOOL,
3340 .off1 = td_var_offset(log_offset),
3341 .help = "Include offset of IO for each log entry",
3343 .category = FIO_OPT_C_LOG,
3344 .group = FIO_OPT_G_INVALID,
3348 .name = "log_compression",
3349 .lname = "Log compression",
3350 .type = FIO_OPT_INT,
3351 .off1 = td_var_offset(log_gz),
3352 .help = "Log in compressed chunks of this size",
3354 .maxval = 512 * 1024 * 1024ULL,
3355 .category = FIO_OPT_C_LOG,
3356 .group = FIO_OPT_G_INVALID,
3358 #ifdef FIO_HAVE_CPU_AFFINITY
3360 .name = "log_compression_cpus",
3361 .lname = "Log Compression CPUs",
3362 .type = FIO_OPT_STR,
3363 .cb = str_log_cpus_allowed_cb,
3364 .off1 = td_var_offset(log_gz_cpumask),
3365 .parent = "log_compression",
3366 .help = "Limit log compression to these CPUs",
3367 .category = FIO_OPT_C_LOG,
3368 .group = FIO_OPT_G_INVALID,
3372 .name = "log_store_compressed",
3373 .lname = "Log store compressed",
3374 .type = FIO_OPT_BOOL,
3375 .off1 = td_var_offset(log_gz_store),
3376 .help = "Store logs in a compressed format",
3377 .category = FIO_OPT_C_LOG,
3378 .group = FIO_OPT_G_INVALID,
3382 .name = "block_error_percentiles",
3383 .lname = "Block error percentiles",
3384 .type = FIO_OPT_BOOL,
3385 .off1 = td_var_offset(block_error_hist),
3386 .help = "Record trim block errors and make a histogram",
3388 .category = FIO_OPT_C_LOG,
3389 .group = FIO_OPT_G_INVALID,
3392 .name = "bwavgtime",
3393 .lname = "Bandwidth average time",
3394 .type = FIO_OPT_INT,
3395 .off1 = td_var_offset(bw_avg_time),
3396 .help = "Time window over which to calculate bandwidth"
3399 .parent = "write_bw_log",
3402 .category = FIO_OPT_C_LOG,
3403 .group = FIO_OPT_G_INVALID,
3406 .name = "iopsavgtime",
3407 .lname = "IOPS average time",
3408 .type = FIO_OPT_INT,
3409 .off1 = td_var_offset(iops_avg_time),
3410 .help = "Time window over which to calculate IOPS (msec)",
3412 .parent = "write_iops_log",
3415 .category = FIO_OPT_C_LOG,
3416 .group = FIO_OPT_G_INVALID,
3419 .name = "group_reporting",
3420 .lname = "Group reporting",
3421 .type = FIO_OPT_STR_SET,
3422 .off1 = td_var_offset(group_reporting),
3423 .help = "Do reporting on a per-group basis",
3424 .category = FIO_OPT_C_STAT,
3425 .group = FIO_OPT_G_INVALID,
3428 .name = "zero_buffers",
3429 .lname = "Zero I/O buffers",
3430 .type = FIO_OPT_STR_SET,
3431 .off1 = td_var_offset(zero_buffers),
3432 .help = "Init IO buffers to all zeroes",
3433 .category = FIO_OPT_C_IO,
3434 .group = FIO_OPT_G_IO_BUF,
3437 .name = "refill_buffers",
3438 .lname = "Refill I/O buffers",
3439 .type = FIO_OPT_STR_SET,
3440 .off1 = td_var_offset(refill_buffers),
3441 .help = "Refill IO buffers on every IO submit",
3442 .category = FIO_OPT_C_IO,
3443 .group = FIO_OPT_G_IO_BUF,
3446 .name = "scramble_buffers",
3447 .lname = "Scramble I/O buffers",
3448 .type = FIO_OPT_BOOL,
3449 .off1 = td_var_offset(scramble_buffers),
3450 .help = "Slightly scramble buffers on every IO submit",
3452 .category = FIO_OPT_C_IO,
3453 .group = FIO_OPT_G_IO_BUF,
3456 .name = "buffer_pattern",
3457 .lname = "Buffer pattern",
3458 .type = FIO_OPT_STR,
3459 .cb = str_buffer_pattern_cb,
3460 .off1 = td_var_offset(buffer_pattern),
3461 .help = "Fill pattern for IO buffers",
3462 .category = FIO_OPT_C_IO,
3463 .group = FIO_OPT_G_IO_BUF,
3466 .name = "buffer_compress_percentage",
3467 .lname = "Buffer compression percentage",
3468 .type = FIO_OPT_INT,
3469 .cb = str_buffer_compress_cb,
3470 .off1 = td_var_offset(compress_percentage),
3473 .help = "How compressible the buffer is (approximately)",
3475 .category = FIO_OPT_C_IO,
3476 .group = FIO_OPT_G_IO_BUF,
3479 .name = "buffer_compress_chunk",
3480 .lname = "Buffer compression chunk size",
3481 .type = FIO_OPT_INT,
3482 .off1 = td_var_offset(compress_chunk),
3483 .parent = "buffer_compress_percentage",
3485 .help = "Size of compressible region in buffer",
3487 .category = FIO_OPT_C_IO,
3488 .group = FIO_OPT_G_IO_BUF,
3491 .name = "dedupe_percentage",
3492 .lname = "Dedupe percentage",
3493 .type = FIO_OPT_INT,
3494 .cb = str_dedupe_cb,
3495 .off1 = td_var_offset(dedupe_percentage),
3498 .help = "Percentage of buffers that are dedupable",
3500 .category = FIO_OPT_C_IO,
3501 .group = FIO_OPT_G_IO_BUF,
3504 .name = "clat_percentiles",
3505 .lname = "Completion latency percentiles",
3506 .type = FIO_OPT_BOOL,
3507 .off1 = td_var_offset(clat_percentiles),
3508 .help = "Enable the reporting of completion latency percentiles",
3510 .category = FIO_OPT_C_STAT,
3511 .group = FIO_OPT_G_INVALID,
3514 .name = "percentile_list",
3515 .lname = "Percentile list",
3516 .type = FIO_OPT_FLOAT_LIST,
3517 .off1 = td_var_offset(percentile_list),
3518 .off2 = td_var_offset(percentile_precision),
3519 .help = "Specify a custom list of percentiles to report for "
3520 "completion latency and block errors",
3521 .def = "1:5:10:20:30:40:50:60:70:80:90:95:99:99.5:99.9:99.95:99.99",
3522 .maxlen = FIO_IO_U_LIST_MAX_LEN,
3525 .category = FIO_OPT_C_STAT,
3526 .group = FIO_OPT_G_INVALID,
3529 #ifdef FIO_HAVE_DISK_UTIL
3531 .name = "disk_util",
3532 .lname = "Disk utilization",
3533 .type = FIO_OPT_BOOL,
3534 .off1 = td_var_offset(do_disk_util),
3535 .help = "Log disk utilization statistics",
3537 .category = FIO_OPT_C_STAT,
3538 .group = FIO_OPT_G_INVALID,
3542 .name = "gtod_reduce",
3543 .lname = "Reduce gettimeofday() calls",
3544 .type = FIO_OPT_BOOL,
3545 .help = "Greatly reduce number of gettimeofday() calls",
3546 .cb = str_gtod_reduce_cb,
3549 .category = FIO_OPT_C_STAT,
3550 .group = FIO_OPT_G_INVALID,
3553 .name = "disable_lat",
3554 .lname = "Disable all latency stats",
3555 .type = FIO_OPT_BOOL,
3556 .off1 = td_var_offset(disable_lat),
3557 .help = "Disable latency numbers",
3558 .parent = "gtod_reduce",
3561 .category = FIO_OPT_C_STAT,
3562 .group = FIO_OPT_G_INVALID,
3565 .name = "disable_clat",
3566 .lname = "Disable completion latency stats",
3567 .type = FIO_OPT_BOOL,
3568 .off1 = td_var_offset(disable_clat),
3569 .help = "Disable completion latency numbers",
3570 .parent = "gtod_reduce",
3573 .category = FIO_OPT_C_STAT,
3574 .group = FIO_OPT_G_INVALID,
3577 .name = "disable_slat",
3578 .lname = "Disable submission latency stats",
3579 .type = FIO_OPT_BOOL,
3580 .off1 = td_var_offset(disable_slat),
3581 .help = "Disable submission latency numbers",
3582 .parent = "gtod_reduce",
3585 .category = FIO_OPT_C_STAT,
3586 .group = FIO_OPT_G_INVALID,
3589 .name = "disable_bw_measurement",
3590 .lname = "Disable bandwidth stats",
3591 .type = FIO_OPT_BOOL,
3592 .off1 = td_var_offset(disable_bw),
3593 .help = "Disable bandwidth logging",
3594 .parent = "gtod_reduce",
3597 .category = FIO_OPT_C_STAT,
3598 .group = FIO_OPT_G_INVALID,
3602 .lname = "Dedicated gettimeofday() CPU",
3603 .type = FIO_OPT_INT,
3604 .off1 = td_var_offset(gtod_cpu),
3605 .help = "Set up dedicated gettimeofday() thread on this CPU",
3606 .verify = gtod_cpu_verify,
3607 .category = FIO_OPT_C_GENERAL,
3608 .group = FIO_OPT_G_CLOCK,
3611 .name = "unified_rw_reporting",
3612 .type = FIO_OPT_BOOL,
3613 .off1 = td_var_offset(unified_rw_rep),
3614 .help = "Unify reporting across data direction",
3616 .category = FIO_OPT_C_GENERAL,
3617 .group = FIO_OPT_G_INVALID,
3620 .name = "continue_on_error",
3621 .lname = "Continue on error",
3622 .type = FIO_OPT_STR,
3623 .off1 = td_var_offset(continue_on_error),
3624 .help = "Continue on non-fatal errors during IO",
3626 .category = FIO_OPT_C_GENERAL,
3627 .group = FIO_OPT_G_ERR,
3630 .oval = ERROR_TYPE_NONE,
3631 .help = "Exit when an error is encountered",
3634 .oval = ERROR_TYPE_READ,
3635 .help = "Continue on read errors only",
3638 .oval = ERROR_TYPE_WRITE,
3639 .help = "Continue on write errors only",
3642 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
3643 .help = "Continue on any IO errors",
3646 .oval = ERROR_TYPE_VERIFY,
3647 .help = "Continue on verify errors only",
3650 .oval = ERROR_TYPE_ANY,
3651 .help = "Continue on all io and verify errors",
3654 .oval = ERROR_TYPE_NONE,
3655 .help = "Alias for 'none'",
3658 .oval = ERROR_TYPE_ANY,
3659 .help = "Alias for 'all'",
3664 .name = "ignore_error",
3665 .type = FIO_OPT_STR,
3666 .cb = str_ignore_error_cb,
3667 .off1 = td_var_offset(ignore_error_nr),
3668 .help = "Set a specific list of errors to ignore",
3670 .category = FIO_OPT_C_GENERAL,
3671 .group = FIO_OPT_G_ERR,
3674 .name = "error_dump",
3675 .type = FIO_OPT_BOOL,
3676 .off1 = td_var_offset(error_dump),
3678 .help = "Dump info on each error",
3679 .category = FIO_OPT_C_GENERAL,
3680 .group = FIO_OPT_G_ERR,
3685 .type = FIO_OPT_STR_STORE,
3686 .off1 = td_var_offset(profile),
3687 .help = "Select a specific builtin performance test",
3688 .category = FIO_OPT_C_PROFILE,
3689 .group = FIO_OPT_G_INVALID,
3694 .type = FIO_OPT_STR_STORE,
3695 .off1 = td_var_offset(cgroup),
3696 .help = "Add job to cgroup of this name",
3697 .category = FIO_OPT_C_GENERAL,
3698 .group = FIO_OPT_G_CGROUP,
3701 .name = "cgroup_nodelete",
3702 .lname = "Cgroup no-delete",
3703 .type = FIO_OPT_BOOL,
3704 .off1 = td_var_offset(cgroup_nodelete),
3705 .help = "Do not delete cgroups after job completion",
3708 .category = FIO_OPT_C_GENERAL,
3709 .group = FIO_OPT_G_CGROUP,
3712 .name = "cgroup_weight",
3713 .lname = "Cgroup weight",
3714 .type = FIO_OPT_INT,
3715 .off1 = td_var_offset(cgroup_weight),
3716 .help = "Use given weight for cgroup",
3720 .category = FIO_OPT_C_GENERAL,
3721 .group = FIO_OPT_G_CGROUP,
3726 .type = FIO_OPT_INT,
3727 .off1 = td_var_offset(uid),
3728 .help = "Run job with this user ID",
3729 .category = FIO_OPT_C_GENERAL,
3730 .group = FIO_OPT_G_CRED,
3734 .lname = "Group ID",
3735 .type = FIO_OPT_INT,
3736 .off1 = td_var_offset(gid),
3737 .help = "Run job with this group ID",
3738 .category = FIO_OPT_C_GENERAL,
3739 .group = FIO_OPT_G_CRED,
3744 .type = FIO_OPT_INT,
3745 .off1 = td_var_offset(kb_base),
3751 .help = "Use 1024 as the K base",
3755 .help = "Use 1000 as the K base",
3758 .help = "How many bytes per KB for reporting (1000 or 1024)",
3759 .category = FIO_OPT_C_GENERAL,
3760 .group = FIO_OPT_G_INVALID,
3763 .name = "unit_base",
3764 .lname = "Base unit for reporting (Bits or Bytes)",
3765 .type = FIO_OPT_INT,
3766 .off1 = td_var_offset(unit_base),
3771 .help = "Auto-detect",
3775 .help = "Normal (byte based)",
3779 .help = "Bit based",
3782 .help = "Bit multiple of result summary data (8 for byte, 1 for bit)",
3783 .category = FIO_OPT_C_GENERAL,
3784 .group = FIO_OPT_G_INVALID,
3787 .name = "hugepage-size",
3788 .lname = "Hugepage size",
3789 .type = FIO_OPT_INT,
3790 .off1 = td_var_offset(hugepage_size),
3791 .help = "When using hugepages, specify size of each page",
3792 .def = __fio_stringify(FIO_HUGE_PAGE),
3793 .interval = 1024 * 1024,
3794 .category = FIO_OPT_C_GENERAL,
3795 .group = FIO_OPT_G_INVALID,
3799 .lname = "I/O flow ID",
3800 .type = FIO_OPT_INT,
3801 .off1 = td_var_offset(flow_id),
3802 .help = "The flow index ID to use",
3804 .category = FIO_OPT_C_IO,
3805 .group = FIO_OPT_G_IO_FLOW,
3809 .lname = "I/O flow weight",
3810 .type = FIO_OPT_INT,
3811 .off1 = td_var_offset(flow),
3812 .help = "Weight for flow control of this job",
3813 .parent = "flow_id",
3816 .category = FIO_OPT_C_IO,
3817 .group = FIO_OPT_G_IO_FLOW,
3820 .name = "flow_watermark",
3821 .lname = "I/O flow watermark",
3822 .type = FIO_OPT_INT,
3823 .off1 = td_var_offset(flow_watermark),
3824 .help = "High watermark for flow control. This option"
3825 " should be set to the same value for all threads"
3826 " with non-zero flow.",
3827 .parent = "flow_id",
3830 .category = FIO_OPT_C_IO,
3831 .group = FIO_OPT_G_IO_FLOW,
3834 .name = "flow_sleep",
3835 .lname = "I/O flow sleep",
3836 .type = FIO_OPT_INT,
3837 .off1 = td_var_offset(flow_sleep),
3838 .help = "How many microseconds to sleep after being held"
3839 " back by the flow control mechanism",
3840 .parent = "flow_id",
3843 .category = FIO_OPT_C_IO,
3844 .group = FIO_OPT_G_IO_FLOW,
3848 .lname = "Skip operations against bad blocks",
3849 .type = FIO_OPT_BOOL,
3850 .off1 = td_var_offset(skip_bad),
3851 .help = "Skip operations against known bad blocks.",
3854 .category = FIO_OPT_C_IO,
3855 .group = FIO_OPT_G_MTD,
3862 static void add_to_lopt(struct option *lopt, struct fio_option *o,
3863 const char *name, int val)
3865 lopt->name = (char *) name;
3867 if (o->type == FIO_OPT_STR_SET)
3868 lopt->has_arg = optional_argument;
3870 lopt->has_arg = required_argument;
3873 static void options_to_lopts(struct fio_option *opts,
3874 struct option *long_options,
3875 int i, int option_type)
3877 struct fio_option *o = &opts[0];
3879 add_to_lopt(&long_options[i], o, o->name, option_type);
3882 add_to_lopt(&long_options[i], o, o->alias, option_type);
3887 assert(i < FIO_NR_OPTIONS);
3891 void fio_options_set_ioengine_opts(struct option *long_options,
3892 struct thread_data *td)
3897 while (long_options[i].name) {
3898 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
3899 memset(&long_options[i], 0, sizeof(*long_options));
3906 * Just clear out the prior ioengine options.
3911 options_to_lopts(td->io_ops->options, long_options, i,
3912 FIO_GETOPT_IOENGINE);
3915 void fio_options_dup_and_init(struct option *long_options)
3919 options_init(fio_options);
3922 while (long_options[i].name)
3925 options_to_lopts(fio_options, long_options, i, FIO_GETOPT_JOB);
3928 struct fio_keyword {
3934 static struct fio_keyword fio_keywords[] = {
3936 .word = "$pagesize",
3937 .desc = "Page size in the system",
3940 .word = "$mb_memory",
3941 .desc = "Megabytes of memory online",
3945 .desc = "Number of CPUs online in the system",
3952 void fio_keywords_exit(void)
3954 struct fio_keyword *kw;
3956 kw = &fio_keywords[0];
3964 void fio_keywords_init(void)
3966 unsigned long long mb_memory;
3970 sprintf(buf, "%lu", (unsigned long) page_size);
3971 fio_keywords[0].replace = strdup(buf);
3973 mb_memory = os_phys_mem() / (1024 * 1024);
3974 sprintf(buf, "%llu", mb_memory);
3975 fio_keywords[1].replace = strdup(buf);
3978 sprintf(buf, "%lu", l);
3979 fio_keywords[2].replace = strdup(buf);
3984 static char *bc_calc(char *str)
3986 char buf[128], *tmp;
3991 * No math, just return string
3993 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
3994 !strchr(str, '/')) || strchr(str, '\''))
3998 * Split option from value, we only need to calculate the value
4000 tmp = strchr(str, '=');
4007 * Prevent buffer overflows; such a case isn't reasonable anyway
4009 if (strlen(str) >= 128 || strlen(tmp) > 100)
4012 sprintf(buf, "which %s > /dev/null", BC_APP);
4014 log_err("fio: bc is needed for performing math\n");
4018 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
4019 f = popen(buf, "r");
4023 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
4030 buf[(tmp - str) + ret - 1] = '\0';
4031 memcpy(buf, str, tmp - str);
4037 * Return a copy of the input string with substrings of the form ${VARNAME}
4038 * substituted with the value of the environment variable VARNAME. The
4039 * substitution always occurs, even if VARNAME is empty or the corresponding
4040 * environment variable undefined.
4042 static char *option_dup_subs(const char *opt)
4044 char out[OPT_LEN_MAX+1];
4045 char in[OPT_LEN_MAX+1];
4048 char *ch1, *ch2, *env;
4049 ssize_t nchr = OPT_LEN_MAX;
4052 if (strlen(opt) + 1 > OPT_LEN_MAX) {
4053 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
4057 in[OPT_LEN_MAX] = '\0';
4058 strncpy(in, opt, OPT_LEN_MAX);
4060 while (*inptr && nchr > 0) {
4061 if (inptr[0] == '$' && inptr[1] == '{') {
4062 ch2 = strchr(inptr, '}');
4063 if (ch2 && inptr+1 < ch2) {
4070 envlen = strlen(env);
4071 if (envlen <= nchr) {
4072 memcpy(outptr, env, envlen);
4082 *outptr++ = *inptr++;
4091 * Look for reserved variable names and replace them with real values
4093 static char *fio_keyword_replace(char *opt)
4099 for (i = 0; fio_keywords[i].word != NULL; i++) {
4100 struct fio_keyword *kw = &fio_keywords[i];
4102 while ((s = strstr(opt, kw->word)) != NULL) {
4103 char *new = malloc(strlen(opt) + 1);
4109 * Copy part of the string before the keyword and
4110 * sprintf() the replacement after it.
4112 memcpy(new, opt, olen);
4113 len = sprintf(new + olen, "%s", kw->replace);
4116 * If there's more in the original string, copy that
4119 opt += strlen(kw->word) + olen;
4121 memcpy(new + olen + len, opt, opt - o_org - 1);
4124 * replace opt and free the old opt
4134 * Check for potential math and invoke bc, if possible
4142 static char **dup_and_sub_options(char **opts, int num_opts)
4145 char **opts_copy = malloc(num_opts * sizeof(*opts));
4146 for (i = 0; i < num_opts; i++) {
4147 opts_copy[i] = option_dup_subs(opts[i]);
4150 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
4155 static void show_closest_option(const char *opt)
4157 int best_option, best_distance;
4166 while (name[i] != '\0' && name[i] != '=')
4171 best_distance = INT_MAX;
4173 while (fio_options[i].name) {
4174 distance = string_distance(name, fio_options[i].name);
4175 if (distance < best_distance) {
4176 best_distance = distance;
4182 if (best_option != -1 && string_distance_ok(name, best_distance))
4183 log_err("Did you mean %s?\n", fio_options[best_option].name);
4188 int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
4190 int i, ret, unknown;
4193 sort_options(opts, fio_options, num_opts);
4194 opts_copy = dup_and_sub_options(opts, num_opts);
4196 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
4197 struct fio_option *o;
4198 int newret = parse_option(opts_copy[i], opts[i], fio_options,
4199 &o, td, &td->opt_list);
4202 fio_option_mark_set(&td->o, o);
4210 opts_copy[i] = NULL;
4217 ret |= ioengine_load(td);
4219 sort_options(opts_copy, td->io_ops->options, num_opts);
4222 for (i = 0; i < num_opts; i++) {
4223 struct fio_option *o = NULL;
4230 newret = parse_option(opts_copy[i], opts[i],
4231 td->io_ops->options, &o,
4232 td->eo, &td->opt_list);
4236 log_err("Bad option <%s>\n", opts[i]);
4237 show_closest_option(opts[i]);
4240 opts_copy[i] = NULL;
4248 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
4252 ret = parse_cmd_option(opt, val, fio_options, td, &td->opt_list);
4254 struct fio_option *o;
4256 o = find_option(fio_options, opt);
4258 fio_option_mark_set(&td->o, o);
4264 int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
4267 return parse_cmd_option(opt, val, td->io_ops->options, td->eo,
4271 void fio_fill_default_options(struct thread_data *td)
4273 td->o.magic = OPT_MAGIC;
4274 fill_default_options(td, fio_options);
4277 int fio_show_option_help(const char *opt)
4279 return show_cmd_help(fio_options, opt);
4282 void options_mem_dupe(void *data, struct fio_option *options)
4284 struct fio_option *o;
4287 for (o = &options[0]; o->name; o++) {
4288 if (o->type != FIO_OPT_STR_STORE)
4291 ptr = td_var(data, o, o->off1);
4293 *ptr = strdup(*ptr);
4298 * dupe FIO_OPT_STR_STORE options
4300 void fio_options_mem_dupe(struct thread_data *td)
4302 options_mem_dupe(&td->o, fio_options);
4304 if (td->eo && td->io_ops) {
4305 void *oldeo = td->eo;
4307 td->eo = malloc(td->io_ops->option_struct_size);
4308 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
4309 options_mem_dupe(td->eo, td->io_ops->options);
4313 unsigned int fio_get_kb_base(void *data)
4315 struct thread_options *o = data;
4316 unsigned int kb_base = 0;
4319 * This is a hack... For private options, *data is not holding
4320 * a pointer to the thread_options, but to private data. This means
4321 * we can't safely dereference it, but magic is first so mem wise
4322 * it is valid. But this also means that if the job first sets
4323 * kb_base and expects that to be honored by private options,
4324 * it will be disappointed. We will return the global default
4327 if (o && o->magic == OPT_MAGIC)
4328 kb_base = o->kb_base;
4335 int add_option(struct fio_option *o)
4337 struct fio_option *__o;
4346 if (opt_index + 1 == FIO_MAX_OPTS) {
4347 log_err("fio: FIO_MAX_OPTS is too small\n");
4351 memcpy(&fio_options[opt_index], o, sizeof(*o));
4352 fio_options[opt_index + 1].name = NULL;
4356 void invalidate_profile_options(const char *prof_name)
4358 struct fio_option *o;
4362 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
4363 o->type = FIO_OPT_INVALID;
4364 o->prof_name = NULL;
4370 void add_opt_posval(const char *optname, const char *ival, const char *help)
4372 struct fio_option *o;
4375 o = find_option(fio_options, optname);
4379 for (i = 0; i < PARSE_MAX_VP; i++) {
4380 if (o->posval[i].ival)
4383 o->posval[i].ival = ival;
4384 o->posval[i].help = help;
4389 void del_opt_posval(const char *optname, const char *ival)
4391 struct fio_option *o;
4394 o = find_option(fio_options, optname);
4398 for (i = 0; i < PARSE_MAX_VP; i++) {
4399 if (!o->posval[i].ival)
4401 if (strcmp(o->posval[i].ival, ival))
4404 o->posval[i].ival = NULL;
4405 o->posval[i].help = NULL;
4409 void fio_options_free(struct thread_data *td)
4411 options_free(fio_options, td);
4412 if (td->eo && td->io_ops && td->io_ops->options) {
4413 options_free(td->io_ops->options, td->eo);
4417 if (td->zone_state_index) {
4420 for (i = 0; i < DDIR_RWDIR_CNT; i++)
4421 free(td->zone_state_index[i]);
4422 free(td->zone_state_index);
4423 td->zone_state_index = NULL;
4427 struct fio_option *fio_option_find(const char *name)
4429 return find_option(fio_options, name);
4432 static struct fio_option *find_next_opt(struct thread_options *o,
4433 struct fio_option *from,
4436 struct fio_option *opt;
4439 from = &fio_options[0];
4445 if (off1 == from->off1) {
4450 } while (from->name);
4455 static int opt_is_set(struct thread_options *o, struct fio_option *opt)
4457 unsigned int opt_off, index, offset;
4459 opt_off = opt - &fio_options[0];
4460 index = opt_off / (8 * sizeof(uint64_t));
4461 offset = opt_off & ((8 * sizeof(uint64_t)) - 1);
4462 return (o->set_options[index] & ((uint64_t)1 << offset)) != 0;
4465 bool __fio_option_is_set(struct thread_options *o, unsigned int off1)
4467 struct fio_option *opt, *next;
4470 while ((opt = find_next_opt(o, next, off1)) != NULL) {
4471 if (opt_is_set(o, opt))
4480 void fio_option_mark_set(struct thread_options *o, struct fio_option *opt)
4482 unsigned int opt_off, index, offset;
4484 opt_off = opt - &fio_options[0];
4485 index = opt_off / (8 * sizeof(uint64_t));
4486 offset = opt_off & ((8 * sizeof(uint64_t)) - 1);
4487 o->set_options[index] |= (uint64_t)1 << offset;