11 #include <netinet/in.h>
17 #include "lib/pattern.h"
20 #include "crc/crc32c.h"
22 char client_sockaddr_str[INET6_ADDRSTRLEN] = { 0 };
24 struct pattern_fmt_desc fmt_desc[] = {
27 .len = FIELD_SIZE(struct io_u *, offset),
28 .paste = paste_blockoff
33 * Check if mmap/mmaphuge has a :/foo/bar/file at the end. If so, return that.
35 static char *get_opt_postfix(const char *str)
37 char *p = strstr(str, ":");
43 strip_blank_front(&p);
48 static int bs_cmp(const void *p1, const void *p2)
50 const struct bssplit *bsp1 = p1;
51 const struct bssplit *bsp2 = p2;
53 return bsp1->perc < bsp2->perc;
56 static int bssplit_ddir(struct thread_options *o, int ddir, char *str)
58 struct bssplit *bssplit;
59 unsigned int i, perc, perc_missing;
60 unsigned int max_bs, min_bs;
64 o->bssplit_nr[ddir] = 4;
65 bssplit = malloc(4 * sizeof(struct bssplit));
70 while ((fname = strsep(&str, ":")) != NULL) {
77 * grow struct buffer, if needed
79 if (i == o->bssplit_nr[ddir]) {
80 o->bssplit_nr[ddir] <<= 1;
81 bssplit = realloc(bssplit, o->bssplit_nr[ddir]
82 * sizeof(struct bssplit));
85 perc_str = strstr(fname, "/");
89 perc = atoi(perc_str);
97 if (str_to_decimal(fname, &val, 1, o, 0, 0)) {
98 log_err("fio: bssplit conversion failed\n");
109 bssplit[i].perc = perc;
113 o->bssplit_nr[ddir] = i;
116 * Now check if the percentages add up, and how much is missing
118 perc = perc_missing = 0;
119 for (i = 0; i < o->bssplit_nr[ddir]; i++) {
120 struct bssplit *bsp = &bssplit[i];
122 if (bsp->perc == -1U)
128 if (perc > 100 && perc_missing > 1) {
129 log_err("fio: bssplit percentages add to more than 100%%\n");
135 * If values didn't have a percentage set, divide the remains between
139 if (perc_missing == 1 && o->bssplit_nr[ddir] == 1)
141 for (i = 0; i < o->bssplit_nr[ddir]; i++) {
142 struct bssplit *bsp = &bssplit[i];
144 if (bsp->perc == -1U)
145 bsp->perc = (100 - perc) / perc_missing;
149 o->min_bs[ddir] = min_bs;
150 o->max_bs[ddir] = max_bs;
153 * now sort based on percentages, for ease of lookup
155 qsort(bssplit, o->bssplit_nr[ddir], sizeof(struct bssplit), bs_cmp);
156 o->bssplit[ddir] = bssplit;
160 static int str_bssplit_cb(void *data, const char *input)
162 struct thread_data *td = data;
163 char *str, *p, *odir, *ddir;
169 p = str = strdup(input);
171 strip_blank_front(&str);
172 strip_blank_end(str);
174 odir = strchr(str, ',');
176 ddir = strchr(odir + 1, ',');
178 ret = bssplit_ddir(&td->o, DDIR_TRIM, ddir + 1);
184 op = strdup(odir + 1);
185 ret = bssplit_ddir(&td->o, DDIR_TRIM, op);
190 ret = bssplit_ddir(&td->o, DDIR_WRITE, odir + 1);
193 ret = bssplit_ddir(&td->o, DDIR_READ, str);
199 ret = bssplit_ddir(&td->o, DDIR_WRITE, op);
204 ret = bssplit_ddir(&td->o, DDIR_TRIM, op);
208 ret = bssplit_ddir(&td->o, DDIR_READ, str);
215 static int str2error(char *str)
217 const char *err[] = { "EPERM", "ENOENT", "ESRCH", "EINTR", "EIO",
218 "ENXIO", "E2BIG", "ENOEXEC", "EBADF",
219 "ECHILD", "EAGAIN", "ENOMEM", "EACCES",
220 "EFAULT", "ENOTBLK", "EBUSY", "EEXIST",
221 "EXDEV", "ENODEV", "ENOTDIR", "EISDIR",
222 "EINVAL", "ENFILE", "EMFILE", "ENOTTY",
223 "ETXTBSY","EFBIG", "ENOSPC", "ESPIPE",
224 "EROFS","EMLINK", "EPIPE", "EDOM", "ERANGE" };
225 int i = 0, num = sizeof(err) / sizeof(void *);
228 if (!strcmp(err[i], str))
235 static int ignore_error_type(struct thread_data *td, int etype, char *str)
241 if (etype >= ERROR_TYPE_CNT) {
242 log_err("Illegal error type\n");
246 td->o.ignore_error_nr[etype] = 4;
247 error = malloc(4 * sizeof(struct bssplit));
250 while ((fname = strsep(&str, ":")) != NULL) {
256 * grow struct buffer, if needed
258 if (i == td->o.ignore_error_nr[etype]) {
259 td->o.ignore_error_nr[etype] <<= 1;
260 error = realloc(error, td->o.ignore_error_nr[etype]
263 if (fname[0] == 'E') {
264 error[i] = str2error(fname);
266 error[i] = atoi(fname);
268 error[i] = -error[i];
271 log_err("Unknown error %s, please use number value \n",
279 td->o.continue_on_error |= 1 << etype;
280 td->o.ignore_error_nr[etype] = i;
281 td->o.ignore_error[etype] = error;
289 static int str_ignore_error_cb(void *data, const char *input)
291 struct thread_data *td = data;
293 int type = 0, ret = 1;
298 p = str = strdup(input);
300 strip_blank_front(&str);
301 strip_blank_end(str);
307 ret = ignore_error_type(td, type, p);
317 static int str_rw_cb(void *data, const char *str)
319 struct thread_data *td = data;
320 struct thread_options *o = &td->o;
329 nr = get_opt_postfix(str);
334 o->ddir_seq_nr = atoi(nr);
338 if (str_to_decimal(nr, &val, 1, o, 0, 0)) {
339 log_err("fio: rw postfix parsing failed\n");
344 o->ddir_seq_add = val;
351 static int str_mem_cb(void *data, const char *mem)
353 struct thread_data *td = data;
355 if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP ||
356 td->o.mem_type == MEM_MMAPSHARED)
357 td->o.mmapfile = get_opt_postfix(mem);
362 static int fio_clock_source_cb(void *data, const char *str)
364 struct thread_data *td = data;
366 fio_clock_source = td->o.clocksource;
367 fio_clock_source_set = 1;
372 static int str_rwmix_read_cb(void *data, unsigned long long *val)
374 struct thread_data *td = data;
376 td->o.rwmix[DDIR_READ] = *val;
377 td->o.rwmix[DDIR_WRITE] = 100 - *val;
381 static int str_rwmix_write_cb(void *data, unsigned long long *val)
383 struct thread_data *td = data;
385 td->o.rwmix[DDIR_WRITE] = *val;
386 td->o.rwmix[DDIR_READ] = 100 - *val;
390 static int str_exitall_cb(void)
392 exitall_on_terminate = 1;
396 #ifdef FIO_HAVE_CPU_AFFINITY
397 int fio_cpus_split(os_cpu_mask_t *mask, unsigned int cpu_index)
399 unsigned int i, index, cpus_in_mask;
400 const long max_cpu = cpus_online();
402 cpus_in_mask = fio_cpu_count(mask);
403 cpu_index = cpu_index % cpus_in_mask;
406 for (i = 0; i < max_cpu; i++) {
407 if (!fio_cpu_isset(mask, i))
410 if (cpu_index != index)
411 fio_cpu_clear(mask, i);
416 return fio_cpu_count(mask);
419 static int str_cpumask_cb(void *data, unsigned long long *val)
421 struct thread_data *td = data;
429 ret = fio_cpuset_init(&td->o.cpumask);
431 log_err("fio: cpuset_init failed\n");
432 td_verror(td, ret, "fio_cpuset_init");
436 max_cpu = cpus_online();
438 for (i = 0; i < sizeof(int) * 8; i++) {
439 if ((1 << i) & *val) {
441 log_err("fio: CPU %d too large (max=%ld)\n", i,
445 dprint(FD_PARSE, "set cpu allowed %d\n", i);
446 fio_cpu_set(&td->o.cpumask, i);
453 static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask,
460 ret = fio_cpuset_init(mask);
462 log_err("fio: cpuset_init failed\n");
463 td_verror(td, ret, "fio_cpuset_init");
467 p = str = strdup(input);
469 strip_blank_front(&str);
470 strip_blank_end(str);
472 max_cpu = cpus_online();
474 while ((cpu = strsep(&str, ",")) != NULL) {
483 while ((cpu2 = strsep(&str2, "-")) != NULL) {
493 while (icpu <= icpu2) {
494 if (icpu >= FIO_MAX_CPUS) {
495 log_err("fio: your OS only supports up to"
496 " %d CPUs\n", (int) FIO_MAX_CPUS);
500 if (icpu >= max_cpu) {
501 log_err("fio: CPU %d too large (max=%ld)\n",
507 dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
508 fio_cpu_set(mask, icpu);
519 static int str_cpus_allowed_cb(void *data, const char *input)
521 struct thread_data *td = data;
526 return set_cpus_allowed(td, &td->o.cpumask, input);
529 static int str_verify_cpus_allowed_cb(void *data, const char *input)
531 struct thread_data *td = data;
533 return set_cpus_allowed(td, &td->o.verify_cpumask, input);
537 #ifdef CONFIG_LIBNUMA
538 static int str_numa_cpunodes_cb(void *data, char *input)
540 struct thread_data *td = data;
541 struct bitmask *verify_bitmask;
546 /* numa_parse_nodestring() parses a character string list
547 * of nodes into a bit mask. The bit mask is allocated by
548 * numa_allocate_nodemask(), so it should be freed by
549 * numa_free_nodemask().
551 verify_bitmask = numa_parse_nodestring(input);
552 if (verify_bitmask == NULL) {
553 log_err("fio: numa_parse_nodestring failed\n");
554 td_verror(td, 1, "str_numa_cpunodes_cb");
557 numa_free_nodemask(verify_bitmask);
559 td->o.numa_cpunodes = strdup(input);
563 static int str_numa_mpol_cb(void *data, char *input)
565 struct thread_data *td = data;
566 const char * const policy_types[] =
567 { "default", "prefer", "bind", "interleave", "local", NULL };
570 struct bitmask *verify_bitmask;
575 nodelist = strchr(input, ':');
577 /* NUL-terminate mode */
581 for (i = 0; i <= MPOL_LOCAL; i++) {
582 if (!strcmp(input, policy_types[i])) {
583 td->o.numa_mem_mode = i;
587 if (i > MPOL_LOCAL) {
588 log_err("fio: memory policy should be: default, prefer, bind, interleave, local\n");
592 switch (td->o.numa_mem_mode) {
595 * Insist on a nodelist of one node only
598 char *rest = nodelist;
599 while (isdigit(*rest))
602 log_err("fio: one node only for \'prefer\'\n");
606 log_err("fio: one node is needed for \'prefer\'\n");
610 case MPOL_INTERLEAVE:
612 * Default to online nodes with memory if no nodelist
615 nodelist = strdup("all");
620 * Don't allow a nodelist
623 log_err("fio: NO nodelist for \'local\'\n");
629 * Insist on a nodelist
632 log_err("fio: a nodelist is needed for \'bind\'\n");
639 /* numa_parse_nodestring() parses a character string list
640 * of nodes into a bit mask. The bit mask is allocated by
641 * numa_allocate_nodemask(), so it should be freed by
642 * numa_free_nodemask().
644 switch (td->o.numa_mem_mode) {
646 td->o.numa_mem_prefer_node = atoi(nodelist);
648 case MPOL_INTERLEAVE:
650 verify_bitmask = numa_parse_nodestring(nodelist);
651 if (verify_bitmask == NULL) {
652 log_err("fio: numa_parse_nodestring failed\n");
653 td_verror(td, 1, "str_numa_memnodes_cb");
656 td->o.numa_memnodes = strdup(nodelist);
657 numa_free_nodemask(verify_bitmask);
672 static int str_fst_cb(void *data, const char *str)
674 struct thread_data *td = data;
675 char *nr = get_opt_postfix(str);
677 td->file_service_nr = 1;
679 td->file_service_nr = atoi(nr);
686 #ifdef CONFIG_SYNC_FILE_RANGE
687 static int str_sfr_cb(void *data, const char *str)
689 struct thread_data *td = data;
690 char *nr = get_opt_postfix(str);
692 td->sync_file_range_nr = 1;
694 td->sync_file_range_nr = atoi(nr);
702 static int str_random_distribution_cb(void *data, const char *str)
704 struct thread_data *td = data;
711 if (td->o.random_distribution == FIO_RAND_DIST_ZIPF)
713 else if (td->o.random_distribution == FIO_RAND_DIST_PARETO)
714 val = FIO_DEF_PARETO;
715 else if (td->o.random_distribution == FIO_RAND_DIST_GAUSS)
720 nr = get_opt_postfix(str);
721 if (nr && !str_to_float(nr, &val, 0)) {
722 log_err("fio: random postfix parsing failed\n");
729 if (td->o.random_distribution == FIO_RAND_DIST_ZIPF) {
731 log_err("fio: zipf theta must different than 1.0\n");
734 td->o.zipf_theta.u.f = val;
735 } else if (td->o.random_distribution == FIO_RAND_DIST_PARETO) {
736 if (val <= 0.00 || val >= 1.00) {
737 log_err("fio: pareto input out of range (0 < input < 1.0)\n");
740 td->o.pareto_h.u.f = val;
742 if (val <= 0.00 || val >= 100.0) {
743 log_err("fio: normal deviation out of range (0 < input < 100.0)\n");
746 td->o.gauss_dev.u.f = val;
753 * Return next name in the string. Files are separated with ':'. If the ':'
754 * is escaped with a '\', then that ':' is part of the filename and does not
755 * indicate a new file.
757 static char *get_next_name(char **ptr)
762 if (!str || !strlen(str))
768 * No colon, we are done
770 p = strchr(str, ':');
777 * We got a colon, but it's the first character. Skip and
785 if (*(p - 1) != '\\') {
791 memmove(p - 1, p, strlen(p) + 1);
799 static int get_max_name_idx(char *input)
801 unsigned int cur_idx;
804 p = str = strdup(input);
805 for (cur_idx = 0; ; cur_idx++)
806 if (get_next_name(&str) == NULL)
814 * Returns the directory at the index, indexes > entires will be
815 * assigned via modulo division of the index
817 int set_name_idx(char *target, size_t tlen, char *input, int index)
819 unsigned int cur_idx;
821 char *fname, *str, *p;
823 p = str = strdup(input);
825 index %= get_max_name_idx(input);
826 for (cur_idx = 0; cur_idx <= index; cur_idx++)
827 fname = get_next_name(&str);
829 if (client_sockaddr_str[0]) {
830 len = snprintf(target, tlen, "%s/%s.", fname,
831 client_sockaddr_str);
833 len = snprintf(target, tlen, "%s/", fname);
835 target[tlen - 1] = '\0';
841 static int str_filename_cb(void *data, const char *input)
843 struct thread_data *td = data;
844 char *fname, *str, *p;
846 p = str = strdup(input);
848 strip_blank_front(&str);
849 strip_blank_end(str);
851 if (!td->files_index)
854 while ((fname = get_next_name(&str)) != NULL) {
857 add_file(td, fname, 0, 1);
864 static int str_directory_cb(void *data, const char fio_unused *unused)
866 struct thread_data *td = data;
868 char *dirname, *str, *p;
874 p = str = strdup(td->o.directory);
875 while ((dirname = get_next_name(&str)) != NULL) {
876 if (lstat(dirname, &sb) < 0) {
879 log_err("fio: %s is not a directory\n", dirname);
880 td_verror(td, ret, "lstat");
883 if (!S_ISDIR(sb.st_mode)) {
884 log_err("fio: %s is not a directory\n", dirname);
895 static int str_opendir_cb(void *data, const char fio_unused *str)
897 struct thread_data *td = data;
902 if (!td->files_index)
905 return add_dir_files(td, td->o.opendir);
908 static int str_buffer_pattern_cb(void *data, const char *input)
910 struct thread_data *td = data;
913 /* FIXME: for now buffer pattern does not support formats */
914 ret = parse_and_fill_pattern(input, strlen(input), td->o.buffer_pattern,
915 MAX_PATTERN_SIZE, NULL, 0, NULL, NULL);
920 td->o.buffer_pattern_bytes = ret;
921 if (!td->o.compress_percentage)
922 td->o.refill_buffers = 0;
923 td->o.scramble_buffers = 0;
924 td->o.zero_buffers = 0;
929 static int str_buffer_compress_cb(void *data, unsigned long long *il)
931 struct thread_data *td = data;
933 td->flags |= TD_F_COMPRESS;
934 td->o.compress_percentage = *il;
938 static int str_dedupe_cb(void *data, unsigned long long *il)
940 struct thread_data *td = data;
942 td->flags |= TD_F_COMPRESS;
943 td->o.dedupe_percentage = *il;
944 td->o.refill_buffers = 1;
948 static int str_verify_pattern_cb(void *data, const char *input)
950 struct thread_data *td = data;
953 td->o.verify_fmt_sz = ARRAY_SIZE(td->o.verify_fmt);
954 ret = parse_and_fill_pattern(input, strlen(input), td->o.verify_pattern,
955 MAX_PATTERN_SIZE, fmt_desc, sizeof(fmt_desc),
956 td->o.verify_fmt, &td->o.verify_fmt_sz);
961 td->o.verify_pattern_bytes = ret;
963 * VERIFY_* could already be set
965 if (!fio_option_is_set(&td->o, verify))
966 td->o.verify = VERIFY_PATTERN;
971 static int str_gtod_reduce_cb(void *data, int *il)
973 struct thread_data *td = data;
976 td->o.disable_lat = !!val;
977 td->o.disable_clat = !!val;
978 td->o.disable_slat = !!val;
979 td->o.disable_bw = !!val;
980 td->o.clat_percentiles = !val;
982 td->tv_cache_mask = 63;
987 static int str_size_cb(void *data, unsigned long long *__val)
989 struct thread_data *td = data;
990 unsigned long long v = *__val;
992 if (parse_is_percent(v)) {
994 td->o.size_percent = -1ULL - v;
1001 static int rw_verify(struct fio_option *o, void *data)
1003 struct thread_data *td = data;
1005 if (read_only && td_write(td)) {
1006 log_err("fio: job <%s> has write bit set, but fio is in"
1007 " read-only mode\n", td->o.name);
1014 static int gtod_cpu_verify(struct fio_option *o, void *data)
1016 #ifndef FIO_HAVE_CPU_AFFINITY
1017 struct thread_data *td = data;
1019 if (td->o.gtod_cpu) {
1020 log_err("fio: platform must support CPU affinity for"
1021 "gettimeofday() offloading\n");
1032 static struct opt_group fio_opt_groups[] = {
1035 .mask = FIO_OPT_C_GENERAL,
1039 .mask = FIO_OPT_C_IO,
1043 .mask = FIO_OPT_C_FILE,
1046 .name = "Statistics",
1047 .mask = FIO_OPT_C_STAT,
1051 .mask = FIO_OPT_C_LOG,
1055 .mask = FIO_OPT_C_PROFILE,
1062 static struct opt_group *__opt_group_from_mask(struct opt_group *ogs, unsigned int *mask,
1063 unsigned int inv_mask)
1065 struct opt_group *og;
1068 if (*mask == inv_mask || !*mask)
1071 for (i = 0; ogs[i].name; i++) {
1074 if (*mask & og->mask) {
1075 *mask &= ~(og->mask);
1083 struct opt_group *opt_group_from_mask(unsigned int *mask)
1085 return __opt_group_from_mask(fio_opt_groups, mask, FIO_OPT_C_INVALID);
1088 static struct opt_group fio_opt_cat_groups[] = {
1090 .name = "Latency profiling",
1091 .mask = FIO_OPT_G_LATPROF,
1095 .mask = FIO_OPT_G_RATE,
1099 .mask = FIO_OPT_G_ZONE,
1102 .name = "Read/write mix",
1103 .mask = FIO_OPT_G_RWMIX,
1107 .mask = FIO_OPT_G_VERIFY,
1111 .mask = FIO_OPT_G_TRIM,
1114 .name = "I/O Logging",
1115 .mask = FIO_OPT_G_IOLOG,
1118 .name = "I/O Depth",
1119 .mask = FIO_OPT_G_IO_DEPTH,
1123 .mask = FIO_OPT_G_IO_FLOW,
1126 .name = "Description",
1127 .mask = FIO_OPT_G_DESC,
1131 .mask = FIO_OPT_G_FILENAME,
1134 .name = "General I/O",
1135 .mask = FIO_OPT_G_IO_BASIC,
1139 .mask = FIO_OPT_G_CGROUP,
1143 .mask = FIO_OPT_G_RUNTIME,
1147 .mask = FIO_OPT_G_PROCESS,
1150 .name = "Job credentials / priority",
1151 .mask = FIO_OPT_G_CRED,
1154 .name = "Clock settings",
1155 .mask = FIO_OPT_G_CLOCK,
1159 .mask = FIO_OPT_G_IO_TYPE,
1162 .name = "I/O Thinktime",
1163 .mask = FIO_OPT_G_THINKTIME,
1166 .name = "Randomizations",
1167 .mask = FIO_OPT_G_RANDOM,
1170 .name = "I/O buffers",
1171 .mask = FIO_OPT_G_IO_BUF,
1174 .name = "Tiobench profile",
1175 .mask = FIO_OPT_G_TIOBENCH,
1179 .mask = FIO_OPT_G_MTD,
1187 struct opt_group *opt_group_cat_from_mask(unsigned int *mask)
1189 return __opt_group_from_mask(fio_opt_cat_groups, mask, FIO_OPT_G_INVALID);
1193 * Map of job/command line options
1195 struct fio_option fio_options[FIO_MAX_OPTS] = {
1197 .name = "description",
1198 .lname = "Description of job",
1199 .type = FIO_OPT_STR_STORE,
1200 .off1 = td_var_offset(description),
1201 .help = "Text job description",
1202 .category = FIO_OPT_C_GENERAL,
1203 .group = FIO_OPT_G_DESC,
1207 .lname = "Job name",
1208 .type = FIO_OPT_STR_STORE,
1209 .off1 = td_var_offset(name),
1210 .help = "Name of this job",
1211 .category = FIO_OPT_C_GENERAL,
1212 .group = FIO_OPT_G_DESC,
1216 .lname = "Filename(s)",
1217 .type = FIO_OPT_STR_STORE,
1218 .off1 = td_var_offset(filename),
1219 .cb = str_filename_cb,
1220 .prio = -1, /* must come after "directory" */
1221 .help = "File(s) to use for the workload",
1222 .category = FIO_OPT_C_FILE,
1223 .group = FIO_OPT_G_FILENAME,
1226 .name = "directory",
1227 .lname = "Directory",
1228 .type = FIO_OPT_STR_STORE,
1229 .off1 = td_var_offset(directory),
1230 .cb = str_directory_cb,
1231 .help = "Directory to store files in",
1232 .category = FIO_OPT_C_FILE,
1233 .group = FIO_OPT_G_FILENAME,
1236 .name = "filename_format",
1237 .type = FIO_OPT_STR_STORE,
1238 .off1 = td_var_offset(filename_format),
1239 .prio = -1, /* must come after "directory" */
1240 .help = "Override default $jobname.$jobnum.$filenum naming",
1241 .def = "$jobname.$jobnum.$filenum",
1242 .category = FIO_OPT_C_FILE,
1243 .group = FIO_OPT_G_FILENAME,
1247 .lname = "Lockfile",
1248 .type = FIO_OPT_STR,
1249 .off1 = td_var_offset(file_lock_mode),
1250 .help = "Lock file when doing IO to it",
1252 .parent = "filename",
1255 .category = FIO_OPT_C_FILE,
1256 .group = FIO_OPT_G_FILENAME,
1259 .oval = FILE_LOCK_NONE,
1260 .help = "No file locking",
1262 { .ival = "exclusive",
1263 .oval = FILE_LOCK_EXCLUSIVE,
1264 .help = "Exclusive file lock",
1267 .ival = "readwrite",
1268 .oval = FILE_LOCK_READWRITE,
1269 .help = "Read vs write lock",
1275 .lname = "Open directory",
1276 .type = FIO_OPT_STR_STORE,
1277 .off1 = td_var_offset(opendir),
1278 .cb = str_opendir_cb,
1279 .help = "Recursively add files from this directory and down",
1280 .category = FIO_OPT_C_FILE,
1281 .group = FIO_OPT_G_FILENAME,
1285 .lname = "Read/write",
1286 .alias = "readwrite",
1287 .type = FIO_OPT_STR,
1289 .off1 = td_var_offset(td_ddir),
1290 .help = "IO direction",
1292 .verify = rw_verify,
1293 .category = FIO_OPT_C_IO,
1294 .group = FIO_OPT_G_IO_BASIC,
1297 .oval = TD_DDIR_READ,
1298 .help = "Sequential read",
1301 .oval = TD_DDIR_WRITE,
1302 .help = "Sequential write",
1305 .oval = TD_DDIR_TRIM,
1306 .help = "Sequential trim",
1308 { .ival = "randread",
1309 .oval = TD_DDIR_RANDREAD,
1310 .help = "Random read",
1312 { .ival = "randwrite",
1313 .oval = TD_DDIR_RANDWRITE,
1314 .help = "Random write",
1316 { .ival = "randtrim",
1317 .oval = TD_DDIR_RANDTRIM,
1318 .help = "Random trim",
1322 .help = "Sequential read and write mix",
1324 { .ival = "readwrite",
1326 .help = "Sequential read and write mix",
1329 .oval = TD_DDIR_RANDRW,
1330 .help = "Random read and write mix"
1332 { .ival = "trimwrite",
1333 .oval = TD_DDIR_TRIMWRITE,
1334 .help = "Trim and write mix, trims preceding writes"
1339 .name = "rw_sequencer",
1340 .lname = "RW Sequencer",
1341 .type = FIO_OPT_STR,
1342 .off1 = td_var_offset(rw_seq),
1343 .help = "IO offset generator modifier",
1344 .def = "sequential",
1345 .category = FIO_OPT_C_IO,
1346 .group = FIO_OPT_G_IO_BASIC,
1348 { .ival = "sequential",
1350 .help = "Generate sequential offsets",
1352 { .ival = "identical",
1353 .oval = RW_SEQ_IDENT,
1354 .help = "Generate identical offsets",
1361 .lname = "IO Engine",
1362 .type = FIO_OPT_STR_STORE,
1363 .off1 = td_var_offset(ioengine),
1364 .help = "IO engine to use",
1365 .def = FIO_PREFERRED_ENGINE,
1366 .category = FIO_OPT_C_IO,
1367 .group = FIO_OPT_G_IO_BASIC,
1370 .help = "Use read/write",
1373 .help = "Use pread/pwrite",
1376 .help = "Use readv/writev",
1378 #ifdef CONFIG_PWRITEV
1380 .help = "Use preadv/pwritev",
1383 #ifdef CONFIG_LIBAIO
1385 .help = "Linux native asynchronous IO",
1388 #ifdef CONFIG_POSIXAIO
1389 { .ival = "posixaio",
1390 .help = "POSIX asynchronous IO",
1393 #ifdef CONFIG_SOLARISAIO
1394 { .ival = "solarisaio",
1395 .help = "Solaris native asynchronous IO",
1398 #ifdef CONFIG_WINDOWSAIO
1399 { .ival = "windowsaio",
1400 .help = "Windows native asynchronous IO"
1405 .help = "Rados Block Device asynchronous IO"
1409 .help = "Memory mapped IO"
1411 #ifdef CONFIG_LINUX_SPLICE
1413 .help = "splice/vmsplice based IO",
1415 { .ival = "netsplice",
1416 .help = "splice/vmsplice to/from the network",
1419 #ifdef FIO_HAVE_SGIO
1421 .help = "SCSI generic v3 IO",
1425 .help = "Testing engine (no data transfer)",
1428 .help = "Network IO",
1431 .help = "CPU cycle burner engine",
1435 .help = "GUASI IO engine",
1438 #ifdef FIO_HAVE_BINJECT
1439 { .ival = "binject",
1440 .help = "binject direct inject block engine",
1445 .help = "RDMA IO engine",
1448 #ifdef CONFIG_FUSION_AW
1449 { .ival = "fusion-aw-sync",
1450 .help = "Fusion-io atomic write engine",
1453 #ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
1454 { .ival = "e4defrag",
1455 .help = "ext4 defrag engine",
1458 #ifdef CONFIG_LINUX_FALLOCATE
1460 .help = "fallocate() file based engine",
1465 .help = "Glusterfs libgfapi(sync) based engine"
1467 { .ival = "gfapi_async",
1468 .help = "Glusterfs libgfapi(async) based engine"
1471 #ifdef CONFIG_LIBHDFS
1472 { .ival = "libhdfs",
1473 .help = "Hadoop Distributed Filesystem (HDFS) engine"
1476 { .ival = "external",
1477 .help = "Load external engine (append name)",
1483 .lname = "IO Depth",
1484 .type = FIO_OPT_INT,
1485 .off1 = td_var_offset(iodepth),
1486 .help = "Number of IO buffers to keep in flight",
1490 .category = FIO_OPT_C_IO,
1491 .group = FIO_OPT_G_IO_BASIC,
1494 .name = "iodepth_batch",
1495 .lname = "IO Depth batch",
1496 .alias = "iodepth_batch_submit",
1497 .type = FIO_OPT_INT,
1498 .off1 = td_var_offset(iodepth_batch),
1499 .help = "Number of IO buffers to submit in one go",
1500 .parent = "iodepth",
1505 .category = FIO_OPT_C_IO,
1506 .group = FIO_OPT_G_IO_BASIC,
1509 .name = "iodepth_batch_complete_min",
1510 .lname = "Min IO depth batch complete",
1511 .alias = "iodepth_batch_complete",
1512 .type = FIO_OPT_INT,
1513 .off1 = td_var_offset(iodepth_batch_complete_min),
1514 .help = "Min number of IO buffers to retrieve in one go",
1515 .parent = "iodepth",
1520 .category = FIO_OPT_C_IO,
1521 .group = FIO_OPT_G_IO_BASIC,
1524 .name = "iodepth_batch_complete_max",
1525 .lname = "Max IO depth batch complete",
1526 .type = FIO_OPT_INT,
1527 .off1 = td_var_offset(iodepth_batch_complete_max),
1528 .help = "Max number of IO buffers to retrieve in one go",
1529 .parent = "iodepth",
1533 .category = FIO_OPT_C_IO,
1534 .group = FIO_OPT_G_IO_BASIC,
1537 .name = "iodepth_low",
1538 .lname = "IO Depth batch low",
1539 .type = FIO_OPT_INT,
1540 .off1 = td_var_offset(iodepth_low),
1541 .help = "Low water mark for queuing depth",
1542 .parent = "iodepth",
1545 .category = FIO_OPT_C_IO,
1546 .group = FIO_OPT_G_IO_BASIC,
1549 .name = "io_submit_mode",
1550 .lname = "IO submit mode",
1551 .type = FIO_OPT_STR,
1552 .off1 = td_var_offset(io_submit_mode),
1553 .help = "How IO submissions and completions are done",
1555 .category = FIO_OPT_C_IO,
1556 .group = FIO_OPT_G_IO_BASIC,
1559 .oval = IO_MODE_INLINE,
1560 .help = "Submit and complete IO inline",
1562 { .ival = "offload",
1563 .oval = IO_MODE_OFFLOAD,
1564 .help = "Offload submit and complete to threads",
1571 .type = FIO_OPT_STR_VAL,
1573 .off1 = td_var_offset(size),
1574 .help = "Total size of device or files",
1575 .interval = 1024 * 1024,
1576 .category = FIO_OPT_C_IO,
1577 .group = FIO_OPT_G_INVALID,
1581 .alias = "io_limit",
1583 .type = FIO_OPT_STR_VAL,
1584 .off1 = td_var_offset(io_limit),
1585 .interval = 1024 * 1024,
1586 .category = FIO_OPT_C_IO,
1587 .group = FIO_OPT_G_INVALID,
1590 .name = "fill_device",
1591 .lname = "Fill device",
1593 .type = FIO_OPT_BOOL,
1594 .off1 = td_var_offset(fill_device),
1595 .help = "Write until an ENOSPC error occurs",
1597 .category = FIO_OPT_C_FILE,
1598 .group = FIO_OPT_G_INVALID,
1602 .lname = "File size",
1603 .type = FIO_OPT_STR_VAL,
1604 .off1 = td_var_offset(file_size_low),
1605 .off2 = td_var_offset(file_size_high),
1607 .help = "Size of individual files",
1608 .interval = 1024 * 1024,
1609 .category = FIO_OPT_C_FILE,
1610 .group = FIO_OPT_G_INVALID,
1613 .name = "file_append",
1614 .lname = "File append",
1615 .type = FIO_OPT_BOOL,
1616 .off1 = td_var_offset(file_append),
1617 .help = "IO will start at the end of the file(s)",
1619 .category = FIO_OPT_C_FILE,
1620 .group = FIO_OPT_G_INVALID,
1624 .lname = "IO offset",
1625 .alias = "fileoffset",
1626 .type = FIO_OPT_STR_VAL,
1627 .off1 = td_var_offset(start_offset),
1628 .help = "Start IO from this offset",
1630 .interval = 1024 * 1024,
1631 .category = FIO_OPT_C_IO,
1632 .group = FIO_OPT_G_INVALID,
1635 .name = "offset_increment",
1636 .lname = "IO offset increment",
1637 .type = FIO_OPT_STR_VAL,
1638 .off1 = td_var_offset(offset_increment),
1639 .help = "What is the increment from one offset to the next",
1643 .interval = 1024 * 1024,
1644 .category = FIO_OPT_C_IO,
1645 .group = FIO_OPT_G_INVALID,
1648 .name = "number_ios",
1649 .lname = "Number of IOs to perform",
1650 .type = FIO_OPT_STR_VAL,
1651 .off1 = td_var_offset(number_ios),
1652 .help = "Force job completion after this number of IOs",
1654 .category = FIO_OPT_C_IO,
1655 .group = FIO_OPT_G_INVALID,
1659 .lname = "Block size",
1660 .alias = "blocksize",
1661 .type = FIO_OPT_INT,
1662 .off1 = td_var_offset(bs[DDIR_READ]),
1663 .off2 = td_var_offset(bs[DDIR_WRITE]),
1664 .off3 = td_var_offset(bs[DDIR_TRIM]),
1666 .help = "Block size unit",
1671 .category = FIO_OPT_C_IO,
1672 .group = FIO_OPT_G_INVALID,
1676 .lname = "Block size align",
1677 .alias = "blockalign",
1678 .type = FIO_OPT_INT,
1679 .off1 = td_var_offset(ba[DDIR_READ]),
1680 .off2 = td_var_offset(ba[DDIR_WRITE]),
1681 .off3 = td_var_offset(ba[DDIR_TRIM]),
1683 .help = "IO block offset alignment",
1687 .category = FIO_OPT_C_IO,
1688 .group = FIO_OPT_G_INVALID,
1692 .lname = "Block size range",
1693 .alias = "blocksize_range",
1694 .type = FIO_OPT_RANGE,
1695 .off1 = td_var_offset(min_bs[DDIR_READ]),
1696 .off2 = td_var_offset(max_bs[DDIR_READ]),
1697 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
1698 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
1699 .off5 = td_var_offset(min_bs[DDIR_TRIM]),
1700 .off6 = td_var_offset(max_bs[DDIR_TRIM]),
1702 .help = "Set block size range (in more detail than bs)",
1706 .category = FIO_OPT_C_IO,
1707 .group = FIO_OPT_G_INVALID,
1711 .lname = "Block size split",
1712 .type = FIO_OPT_STR,
1713 .cb = str_bssplit_cb,
1714 .off1 = td_var_offset(bssplit),
1715 .help = "Set a specific mix of block sizes",
1718 .category = FIO_OPT_C_IO,
1719 .group = FIO_OPT_G_INVALID,
1722 .name = "bs_unaligned",
1723 .lname = "Block size unaligned",
1724 .alias = "blocksize_unaligned",
1725 .type = FIO_OPT_STR_SET,
1726 .off1 = td_var_offset(bs_unaligned),
1727 .help = "Don't sector align IO buffer sizes",
1730 .category = FIO_OPT_C_IO,
1731 .group = FIO_OPT_G_INVALID,
1734 .name = "bs_is_seq_rand",
1735 .lname = "Block size division is seq/random (not read/write)",
1736 .type = FIO_OPT_BOOL,
1737 .off1 = td_var_offset(bs_is_seq_rand),
1738 .help = "Consider any blocksize setting to be sequential,random",
1740 .parent = "blocksize",
1741 .category = FIO_OPT_C_IO,
1742 .group = FIO_OPT_G_INVALID,
1745 .name = "randrepeat",
1746 .lname = "Random repeatable",
1747 .type = FIO_OPT_BOOL,
1748 .off1 = td_var_offset(rand_repeatable),
1749 .help = "Use repeatable random IO pattern",
1753 .category = FIO_OPT_C_IO,
1754 .group = FIO_OPT_G_RANDOM,
1758 .lname = "The random generator seed",
1759 .type = FIO_OPT_STR_VAL,
1760 .off1 = td_var_offset(rand_seed),
1761 .help = "Set the random generator seed value",
1764 .category = FIO_OPT_C_IO,
1765 .group = FIO_OPT_G_RANDOM,
1768 .name = "use_os_rand",
1769 .lname = "Use OS random",
1770 .type = FIO_OPT_DEPRECATED,
1771 .off1 = td_var_offset(dep_use_os_rand),
1772 .category = FIO_OPT_C_IO,
1773 .group = FIO_OPT_G_RANDOM,
1776 .name = "norandommap",
1777 .lname = "No randommap",
1778 .type = FIO_OPT_STR_SET,
1779 .off1 = td_var_offset(norandommap),
1780 .help = "Accept potential duplicate random blocks",
1784 .category = FIO_OPT_C_IO,
1785 .group = FIO_OPT_G_RANDOM,
1788 .name = "softrandommap",
1789 .lname = "Soft randommap",
1790 .type = FIO_OPT_BOOL,
1791 .off1 = td_var_offset(softrandommap),
1792 .help = "Set norandommap if randommap allocation fails",
1793 .parent = "norandommap",
1796 .category = FIO_OPT_C_IO,
1797 .group = FIO_OPT_G_RANDOM,
1800 .name = "random_generator",
1801 .type = FIO_OPT_STR,
1802 .off1 = td_var_offset(random_generator),
1803 .help = "Type of random number generator to use",
1804 .def = "tausworthe",
1806 { .ival = "tausworthe",
1807 .oval = FIO_RAND_GEN_TAUSWORTHE,
1808 .help = "Strong Tausworthe generator",
1811 .oval = FIO_RAND_GEN_LFSR,
1812 .help = "Variable length LFSR",
1815 .ival = "tausworthe64",
1816 .oval = FIO_RAND_GEN_TAUSWORTHE64,
1817 .help = "64-bit Tausworthe variant",
1820 .category = FIO_OPT_C_IO,
1821 .group = FIO_OPT_G_RANDOM,
1824 .name = "random_distribution",
1825 .type = FIO_OPT_STR,
1826 .off1 = td_var_offset(random_distribution),
1827 .cb = str_random_distribution_cb,
1828 .help = "Random offset distribution generator",
1832 .oval = FIO_RAND_DIST_RANDOM,
1833 .help = "Completely random",
1836 .oval = FIO_RAND_DIST_ZIPF,
1837 .help = "Zipf distribution",
1840 .oval = FIO_RAND_DIST_PARETO,
1841 .help = "Pareto distribution",
1844 .oval = FIO_RAND_DIST_GAUSS,
1845 .help = "Normal (gaussian) distribution",
1848 .category = FIO_OPT_C_IO,
1849 .group = FIO_OPT_G_RANDOM,
1852 .name = "percentage_random",
1853 .lname = "Percentage Random",
1854 .type = FIO_OPT_INT,
1855 .off1 = td_var_offset(perc_rand[DDIR_READ]),
1856 .off2 = td_var_offset(perc_rand[DDIR_WRITE]),
1857 .off3 = td_var_offset(perc_rand[DDIR_TRIM]),
1859 .help = "Percentage of seq/random mix that should be random",
1860 .def = "100,100,100",
1862 .inverse = "percentage_sequential",
1863 .category = FIO_OPT_C_IO,
1864 .group = FIO_OPT_G_RANDOM,
1867 .name = "percentage_sequential",
1868 .lname = "Percentage Sequential",
1869 .type = FIO_OPT_DEPRECATED,
1870 .category = FIO_OPT_C_IO,
1871 .group = FIO_OPT_G_RANDOM,
1874 .name = "allrandrepeat",
1875 .type = FIO_OPT_BOOL,
1876 .off1 = td_var_offset(allrand_repeatable),
1877 .help = "Use repeatable random numbers for everything",
1879 .category = FIO_OPT_C_IO,
1880 .group = FIO_OPT_G_RANDOM,
1884 .lname = "Number of files",
1885 .alias = "nr_files",
1886 .type = FIO_OPT_INT,
1887 .off1 = td_var_offset(nr_files),
1888 .help = "Split job workload between this number of files",
1891 .category = FIO_OPT_C_FILE,
1892 .group = FIO_OPT_G_INVALID,
1895 .name = "openfiles",
1896 .lname = "Number of open files",
1897 .type = FIO_OPT_INT,
1898 .off1 = td_var_offset(open_files),
1899 .help = "Number of files to keep open at the same time",
1900 .category = FIO_OPT_C_FILE,
1901 .group = FIO_OPT_G_INVALID,
1904 .name = "file_service_type",
1905 .lname = "File service type",
1906 .type = FIO_OPT_STR,
1908 .off1 = td_var_offset(file_service_type),
1909 .help = "How to select which file to service next",
1910 .def = "roundrobin",
1911 .category = FIO_OPT_C_FILE,
1912 .group = FIO_OPT_G_INVALID,
1915 .oval = FIO_FSERVICE_RANDOM,
1916 .help = "Choose a file at random",
1918 { .ival = "roundrobin",
1919 .oval = FIO_FSERVICE_RR,
1920 .help = "Round robin select files",
1922 { .ival = "sequential",
1923 .oval = FIO_FSERVICE_SEQ,
1924 .help = "Finish one file before moving to the next",
1927 .parent = "nrfiles",
1930 #ifdef CONFIG_POSIX_FALLOCATE
1932 .name = "fallocate",
1933 .lname = "Fallocate",
1934 .type = FIO_OPT_STR,
1935 .off1 = td_var_offset(fallocate_mode),
1936 .help = "Whether pre-allocation is performed when laying out files",
1938 .category = FIO_OPT_C_FILE,
1939 .group = FIO_OPT_G_INVALID,
1942 .oval = FIO_FALLOCATE_NONE,
1943 .help = "Do not pre-allocate space",
1946 .oval = FIO_FALLOCATE_POSIX,
1947 .help = "Use posix_fallocate()",
1949 #ifdef CONFIG_LINUX_FALLOCATE
1951 .oval = FIO_FALLOCATE_KEEP_SIZE,
1952 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
1955 /* Compatibility with former boolean values */
1957 .oval = FIO_FALLOCATE_NONE,
1958 .help = "Alias for 'none'",
1961 .oval = FIO_FALLOCATE_POSIX,
1962 .help = "Alias for 'posix'",
1966 #endif /* CONFIG_POSIX_FALLOCATE */
1968 .name = "fadvise_hint",
1969 .lname = "Fadvise hint",
1970 .type = FIO_OPT_BOOL,
1971 .off1 = td_var_offset(fadvise_hint),
1972 .help = "Use fadvise() to advise the kernel on IO pattern",
1974 .category = FIO_OPT_C_FILE,
1975 .group = FIO_OPT_G_INVALID,
1977 #ifdef FIO_HAVE_STREAMID
1979 .name = "fadvise_stream",
1980 .lname = "Fadvise stream",
1981 .type = FIO_OPT_INT,
1982 .off1 = td_var_offset(fadvise_stream),
1983 .help = "Use fadvise() to set stream ID",
1984 .category = FIO_OPT_C_FILE,
1985 .group = FIO_OPT_G_INVALID,
1991 .type = FIO_OPT_INT,
1992 .off1 = td_var_offset(fsync_blocks),
1993 .help = "Issue fsync for writes every given number of blocks",
1996 .category = FIO_OPT_C_FILE,
1997 .group = FIO_OPT_G_INVALID,
2000 .name = "fdatasync",
2001 .lname = "Fdatasync",
2002 .type = FIO_OPT_INT,
2003 .off1 = td_var_offset(fdatasync_blocks),
2004 .help = "Issue fdatasync for writes every given number of blocks",
2007 .category = FIO_OPT_C_FILE,
2008 .group = FIO_OPT_G_INVALID,
2011 .name = "write_barrier",
2012 .lname = "Write barrier",
2013 .type = FIO_OPT_INT,
2014 .off1 = td_var_offset(barrier_blocks),
2015 .help = "Make every Nth write a barrier write",
2018 .category = FIO_OPT_C_IO,
2019 .group = FIO_OPT_G_INVALID,
2021 #ifdef CONFIG_SYNC_FILE_RANGE
2023 .name = "sync_file_range",
2024 .lname = "Sync file range",
2026 { .ival = "wait_before",
2027 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
2028 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
2032 .oval = SYNC_FILE_RANGE_WRITE,
2033 .help = "SYNC_FILE_RANGE_WRITE",
2037 .ival = "wait_after",
2038 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
2039 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
2043 .type = FIO_OPT_STR_MULTI,
2045 .off1 = td_var_offset(sync_file_range),
2046 .help = "Use sync_file_range()",
2047 .category = FIO_OPT_C_FILE,
2048 .group = FIO_OPT_G_INVALID,
2053 .lname = "Direct I/O",
2054 .type = FIO_OPT_BOOL,
2055 .off1 = td_var_offset(odirect),
2056 .help = "Use O_DIRECT IO (negates buffered)",
2058 .inverse = "buffered",
2059 .category = FIO_OPT_C_IO,
2060 .group = FIO_OPT_G_IO_TYPE,
2064 .lname = "Atomic I/O",
2065 .type = FIO_OPT_BOOL,
2066 .off1 = td_var_offset(oatomic),
2067 .help = "Use Atomic IO with O_DIRECT (implies O_DIRECT)",
2069 .category = FIO_OPT_C_IO,
2070 .group = FIO_OPT_G_IO_TYPE,
2074 .lname = "Buffered I/O",
2075 .type = FIO_OPT_BOOL,
2076 .off1 = td_var_offset(odirect),
2078 .help = "Use buffered IO (negates direct)",
2080 .inverse = "direct",
2081 .category = FIO_OPT_C_IO,
2082 .group = FIO_OPT_G_IO_TYPE,
2085 .name = "overwrite",
2086 .lname = "Overwrite",
2087 .type = FIO_OPT_BOOL,
2088 .off1 = td_var_offset(overwrite),
2089 .help = "When writing, set whether to overwrite current data",
2091 .category = FIO_OPT_C_FILE,
2092 .group = FIO_OPT_G_INVALID,
2097 .type = FIO_OPT_INT,
2098 .off1 = td_var_offset(loops),
2099 .help = "Number of times to run the job",
2102 .category = FIO_OPT_C_GENERAL,
2103 .group = FIO_OPT_G_RUNTIME,
2107 .lname = "Number of jobs",
2108 .type = FIO_OPT_INT,
2109 .off1 = td_var_offset(numjobs),
2110 .help = "Duplicate this job this many times",
2113 .category = FIO_OPT_C_GENERAL,
2114 .group = FIO_OPT_G_RUNTIME,
2117 .name = "startdelay",
2118 .lname = "Start delay",
2119 .type = FIO_OPT_STR_VAL_TIME,
2120 .off1 = td_var_offset(start_delay),
2121 .off2 = td_var_offset(start_delay_high),
2122 .help = "Only start job when this period has passed",
2126 .category = FIO_OPT_C_GENERAL,
2127 .group = FIO_OPT_G_RUNTIME,
2133 .type = FIO_OPT_STR_VAL_TIME,
2134 .off1 = td_var_offset(timeout),
2135 .help = "Stop workload when this amount of time has passed",
2139 .category = FIO_OPT_C_GENERAL,
2140 .group = FIO_OPT_G_RUNTIME,
2143 .name = "time_based",
2144 .lname = "Time based",
2145 .type = FIO_OPT_STR_SET,
2146 .off1 = td_var_offset(time_based),
2147 .help = "Keep running until runtime/timeout is met",
2148 .category = FIO_OPT_C_GENERAL,
2149 .group = FIO_OPT_G_RUNTIME,
2152 .name = "verify_only",
2153 .lname = "Verify only",
2154 .type = FIO_OPT_STR_SET,
2155 .off1 = td_var_offset(verify_only),
2156 .help = "Verifies previously written data is still valid",
2157 .category = FIO_OPT_C_GENERAL,
2158 .group = FIO_OPT_G_RUNTIME,
2161 .name = "ramp_time",
2162 .lname = "Ramp time",
2163 .type = FIO_OPT_STR_VAL_TIME,
2164 .off1 = td_var_offset(ramp_time),
2165 .help = "Ramp up time before measuring performance",
2168 .category = FIO_OPT_C_GENERAL,
2169 .group = FIO_OPT_G_RUNTIME,
2172 .name = "clocksource",
2173 .lname = "Clock source",
2174 .type = FIO_OPT_STR,
2175 .cb = fio_clock_source_cb,
2176 .off1 = td_var_offset(clocksource),
2177 .help = "What type of timing source to use",
2178 .category = FIO_OPT_C_GENERAL,
2179 .group = FIO_OPT_G_CLOCK,
2181 #ifdef CONFIG_GETTIMEOFDAY
2182 { .ival = "gettimeofday",
2184 .help = "Use gettimeofday(2) for timing",
2187 #ifdef CONFIG_CLOCK_GETTIME
2188 { .ival = "clock_gettime",
2189 .oval = CS_CGETTIME,
2190 .help = "Use clock_gettime(2) for timing",
2193 #ifdef ARCH_HAVE_CPU_CLOCK
2195 .oval = CS_CPUCLOCK,
2196 .help = "Use CPU private clock",
2204 .lname = "I/O Memory",
2205 .type = FIO_OPT_STR,
2207 .off1 = td_var_offset(mem_type),
2208 .help = "Backing type for IO buffers",
2210 .category = FIO_OPT_C_IO,
2211 .group = FIO_OPT_G_INVALID,
2215 .help = "Use malloc(3) for IO buffers",
2217 #ifndef CONFIG_NO_SHM
2220 .help = "Use shared memory segments for IO buffers",
2222 #ifdef FIO_HAVE_HUGETLB
2223 { .ival = "shmhuge",
2224 .oval = MEM_SHMHUGE,
2225 .help = "Like shm, but use huge pages",
2231 .help = "Use mmap(2) (file or anon) for IO buffers",
2233 { .ival = "mmapshared",
2234 .oval = MEM_MMAPSHARED,
2235 .help = "Like mmap, but use the shared flag",
2237 #ifdef FIO_HAVE_HUGETLB
2238 { .ival = "mmaphuge",
2239 .oval = MEM_MMAPHUGE,
2240 .help = "Like mmap, but use huge pages",
2246 .name = "iomem_align",
2247 .alias = "mem_align",
2248 .lname = "I/O memory alignment",
2249 .type = FIO_OPT_INT,
2250 .off1 = td_var_offset(mem_align),
2252 .help = "IO memory buffer offset alignment",
2256 .category = FIO_OPT_C_IO,
2257 .group = FIO_OPT_G_INVALID,
2262 .type = FIO_OPT_STR,
2263 .off1 = td_var_offset(verify),
2264 .help = "Verify data written",
2266 .category = FIO_OPT_C_IO,
2267 .group = FIO_OPT_G_VERIFY,
2270 .oval = VERIFY_NONE,
2271 .help = "Don't do IO verification",
2275 .help = "Use md5 checksums for verification",
2278 .oval = VERIFY_CRC64,
2279 .help = "Use crc64 checksums for verification",
2282 .oval = VERIFY_CRC32,
2283 .help = "Use crc32 checksums for verification",
2285 { .ival = "crc32c-intel",
2286 .oval = VERIFY_CRC32C,
2287 .help = "Use crc32c checksums for verification (hw assisted, if available)",
2290 .oval = VERIFY_CRC32C,
2291 .help = "Use crc32c checksums for verification (hw assisted, if available)",
2294 .oval = VERIFY_CRC16,
2295 .help = "Use crc16 checksums for verification",
2298 .oval = VERIFY_CRC7,
2299 .help = "Use crc7 checksums for verification",
2302 .oval = VERIFY_SHA1,
2303 .help = "Use sha1 checksums for verification",
2306 .oval = VERIFY_SHA256,
2307 .help = "Use sha256 checksums for verification",
2310 .oval = VERIFY_SHA512,
2311 .help = "Use sha512 checksums for verification",
2314 .oval = VERIFY_XXHASH,
2315 .help = "Use xxhash checksums for verification",
2317 /* Meta information was included into verify_header,
2318 * 'meta' verification is implied by default. */
2320 .oval = VERIFY_HDR_ONLY,
2321 .help = "Use io information for verification. "
2322 "Now is implied by default, thus option is obsolete, "
2325 { .ival = "pattern",
2326 .oval = VERIFY_PATTERN_NO_HDR,
2327 .help = "Verify strict pattern",
2331 .oval = VERIFY_NULL,
2332 .help = "Pretend to verify",
2337 .name = "do_verify",
2338 .lname = "Perform verify step",
2339 .type = FIO_OPT_BOOL,
2340 .off1 = td_var_offset(do_verify),
2341 .help = "Run verification stage after write",
2345 .category = FIO_OPT_C_IO,
2346 .group = FIO_OPT_G_VERIFY,
2349 .name = "verifysort",
2350 .lname = "Verify sort",
2351 .type = FIO_OPT_BOOL,
2352 .off1 = td_var_offset(verifysort),
2353 .help = "Sort written verify blocks for read back",
2357 .category = FIO_OPT_C_IO,
2358 .group = FIO_OPT_G_VERIFY,
2361 .name = "verifysort_nr",
2362 .type = FIO_OPT_INT,
2363 .off1 = td_var_offset(verifysort_nr),
2364 .help = "Pre-load and sort verify blocks for a read workload",
2369 .category = FIO_OPT_C_IO,
2370 .group = FIO_OPT_G_VERIFY,
2373 .name = "verify_interval",
2374 .lname = "Verify interval",
2375 .type = FIO_OPT_INT,
2376 .off1 = td_var_offset(verify_interval),
2377 .minval = 2 * sizeof(struct verify_header),
2378 .help = "Store verify buffer header every N bytes",
2381 .interval = 2 * sizeof(struct verify_header),
2382 .category = FIO_OPT_C_IO,
2383 .group = FIO_OPT_G_VERIFY,
2386 .name = "verify_offset",
2387 .lname = "Verify offset",
2388 .type = FIO_OPT_INT,
2389 .help = "Offset verify header location by N bytes",
2390 .off1 = td_var_offset(verify_offset),
2391 .minval = sizeof(struct verify_header),
2394 .category = FIO_OPT_C_IO,
2395 .group = FIO_OPT_G_VERIFY,
2398 .name = "verify_pattern",
2399 .lname = "Verify pattern",
2400 .type = FIO_OPT_STR,
2401 .cb = str_verify_pattern_cb,
2402 .off1 = td_var_offset(verify_pattern),
2403 .help = "Fill pattern for IO buffers",
2406 .category = FIO_OPT_C_IO,
2407 .group = FIO_OPT_G_VERIFY,
2410 .name = "verify_fatal",
2411 .lname = "Verify fatal",
2412 .type = FIO_OPT_BOOL,
2413 .off1 = td_var_offset(verify_fatal),
2415 .help = "Exit on a single verify failure, don't continue",
2418 .category = FIO_OPT_C_IO,
2419 .group = FIO_OPT_G_VERIFY,
2422 .name = "verify_dump",
2423 .lname = "Verify dump",
2424 .type = FIO_OPT_BOOL,
2425 .off1 = td_var_offset(verify_dump),
2427 .help = "Dump contents of good and bad blocks on failure",
2430 .category = FIO_OPT_C_IO,
2431 .group = FIO_OPT_G_VERIFY,
2434 .name = "verify_async",
2435 .lname = "Verify asynchronously",
2436 .type = FIO_OPT_INT,
2437 .off1 = td_var_offset(verify_async),
2439 .help = "Number of async verifier threads to use",
2442 .category = FIO_OPT_C_IO,
2443 .group = FIO_OPT_G_VERIFY,
2446 .name = "verify_backlog",
2447 .lname = "Verify backlog",
2448 .type = FIO_OPT_STR_VAL,
2449 .off1 = td_var_offset(verify_backlog),
2450 .help = "Verify after this number of blocks are written",
2453 .category = FIO_OPT_C_IO,
2454 .group = FIO_OPT_G_VERIFY,
2457 .name = "verify_backlog_batch",
2458 .lname = "Verify backlog batch",
2459 .type = FIO_OPT_INT,
2460 .off1 = td_var_offset(verify_batch),
2461 .help = "Verify this number of IO blocks",
2464 .category = FIO_OPT_C_IO,
2465 .group = FIO_OPT_G_VERIFY,
2467 #ifdef FIO_HAVE_CPU_AFFINITY
2469 .name = "verify_async_cpus",
2470 .lname = "Async verify CPUs",
2471 .type = FIO_OPT_STR,
2472 .cb = str_verify_cpus_allowed_cb,
2473 .off1 = td_var_offset(verify_cpumask),
2474 .help = "Set CPUs allowed for async verify threads",
2475 .parent = "verify_async",
2477 .category = FIO_OPT_C_IO,
2478 .group = FIO_OPT_G_VERIFY,
2482 .name = "experimental_verify",
2483 .off1 = td_var_offset(experimental_verify),
2484 .type = FIO_OPT_BOOL,
2485 .help = "Enable experimental verification",
2487 .category = FIO_OPT_C_IO,
2488 .group = FIO_OPT_G_VERIFY,
2491 .name = "verify_state_load",
2492 .lname = "Load verify state",
2493 .off1 = td_var_offset(verify_state),
2494 .type = FIO_OPT_BOOL,
2495 .help = "Load verify termination state",
2497 .category = FIO_OPT_C_IO,
2498 .group = FIO_OPT_G_VERIFY,
2501 .name = "verify_state_save",
2502 .lname = "Save verify state",
2503 .off1 = td_var_offset(verify_state_save),
2504 .type = FIO_OPT_BOOL,
2506 .help = "Save verify state on termination",
2508 .category = FIO_OPT_C_IO,
2509 .group = FIO_OPT_G_VERIFY,
2511 #ifdef FIO_HAVE_TRIM
2513 .name = "trim_percentage",
2514 .lname = "Trim percentage",
2515 .type = FIO_OPT_INT,
2516 .off1 = td_var_offset(trim_percentage),
2519 .help = "Number of verify blocks to discard/trim",
2524 .category = FIO_OPT_C_IO,
2525 .group = FIO_OPT_G_TRIM,
2528 .name = "trim_verify_zero",
2529 .lname = "Verify trim zero",
2530 .type = FIO_OPT_BOOL,
2531 .help = "Verify that trim/discarded blocks are returned as zeroes",
2532 .off1 = td_var_offset(trim_zero),
2533 .parent = "trim_percentage",
2536 .category = FIO_OPT_C_IO,
2537 .group = FIO_OPT_G_TRIM,
2540 .name = "trim_backlog",
2541 .lname = "Trim backlog",
2542 .type = FIO_OPT_STR_VAL,
2543 .off1 = td_var_offset(trim_backlog),
2544 .help = "Trim after this number of blocks are written",
2545 .parent = "trim_percentage",
2548 .category = FIO_OPT_C_IO,
2549 .group = FIO_OPT_G_TRIM,
2552 .name = "trim_backlog_batch",
2553 .lname = "Trim backlog batch",
2554 .type = FIO_OPT_INT,
2555 .off1 = td_var_offset(trim_batch),
2556 .help = "Trim this number of IO blocks",
2557 .parent = "trim_percentage",
2560 .category = FIO_OPT_C_IO,
2561 .group = FIO_OPT_G_TRIM,
2565 .name = "write_iolog",
2566 .lname = "Write I/O log",
2567 .type = FIO_OPT_STR_STORE,
2568 .off1 = td_var_offset(write_iolog_file),
2569 .help = "Store IO pattern to file",
2570 .category = FIO_OPT_C_IO,
2571 .group = FIO_OPT_G_IOLOG,
2574 .name = "read_iolog",
2575 .lname = "Read I/O log",
2576 .type = FIO_OPT_STR_STORE,
2577 .off1 = td_var_offset(read_iolog_file),
2578 .help = "Playback IO pattern from file",
2579 .category = FIO_OPT_C_IO,
2580 .group = FIO_OPT_G_IOLOG,
2583 .name = "replay_no_stall",
2584 .lname = "Don't stall on replay",
2585 .type = FIO_OPT_BOOL,
2586 .off1 = td_var_offset(no_stall),
2588 .parent = "read_iolog",
2590 .help = "Playback IO pattern file as fast as possible without stalls",
2591 .category = FIO_OPT_C_IO,
2592 .group = FIO_OPT_G_IOLOG,
2595 .name = "replay_redirect",
2596 .lname = "Redirect device for replay",
2597 .type = FIO_OPT_STR_STORE,
2598 .off1 = td_var_offset(replay_redirect),
2599 .parent = "read_iolog",
2601 .help = "Replay all I/O onto this device, regardless of trace device",
2602 .category = FIO_OPT_C_IO,
2603 .group = FIO_OPT_G_IOLOG,
2606 .name = "replay_scale",
2607 .lname = "Replace offset scale factor",
2608 .type = FIO_OPT_INT,
2609 .off1 = td_var_offset(replay_scale),
2610 .parent = "read_iolog",
2612 .help = "Align offsets to this blocksize",
2613 .category = FIO_OPT_C_IO,
2614 .group = FIO_OPT_G_IOLOG,
2617 .name = "replay_align",
2618 .lname = "Replace alignment",
2619 .type = FIO_OPT_INT,
2620 .off1 = td_var_offset(replay_align),
2621 .parent = "read_iolog",
2622 .help = "Scale offset down by this factor",
2623 .category = FIO_OPT_C_IO,
2624 .group = FIO_OPT_G_IOLOG,
2628 .name = "exec_prerun",
2629 .lname = "Pre-execute runnable",
2630 .type = FIO_OPT_STR_STORE,
2631 .off1 = td_var_offset(exec_prerun),
2632 .help = "Execute this file prior to running job",
2633 .category = FIO_OPT_C_GENERAL,
2634 .group = FIO_OPT_G_INVALID,
2637 .name = "exec_postrun",
2638 .lname = "Post-execute runnable",
2639 .type = FIO_OPT_STR_STORE,
2640 .off1 = td_var_offset(exec_postrun),
2641 .help = "Execute this file after running job",
2642 .category = FIO_OPT_C_GENERAL,
2643 .group = FIO_OPT_G_INVALID,
2645 #ifdef FIO_HAVE_IOSCHED_SWITCH
2647 .name = "ioscheduler",
2648 .lname = "I/O scheduler",
2649 .type = FIO_OPT_STR_STORE,
2650 .off1 = td_var_offset(ioscheduler),
2651 .help = "Use this IO scheduler on the backing device",
2652 .category = FIO_OPT_C_FILE,
2653 .group = FIO_OPT_G_INVALID,
2658 .lname = "Zone size",
2659 .type = FIO_OPT_STR_VAL,
2660 .off1 = td_var_offset(zone_size),
2661 .help = "Amount of data to read per zone",
2663 .interval = 1024 * 1024,
2664 .category = FIO_OPT_C_IO,
2665 .group = FIO_OPT_G_ZONE,
2668 .name = "zonerange",
2669 .lname = "Zone range",
2670 .type = FIO_OPT_STR_VAL,
2671 .off1 = td_var_offset(zone_range),
2672 .help = "Give size of an IO zone",
2674 .interval = 1024 * 1024,
2675 .category = FIO_OPT_C_IO,
2676 .group = FIO_OPT_G_ZONE,
2680 .lname = "Zone skip",
2681 .type = FIO_OPT_STR_VAL,
2682 .off1 = td_var_offset(zone_skip),
2683 .help = "Space between IO zones",
2685 .interval = 1024 * 1024,
2686 .category = FIO_OPT_C_IO,
2687 .group = FIO_OPT_G_ZONE,
2691 .lname = "Lock memory",
2692 .type = FIO_OPT_STR_VAL,
2693 .off1 = td_var_offset(lockmem),
2694 .help = "Lock down this amount of memory (per worker)",
2696 .interval = 1024 * 1024,
2697 .category = FIO_OPT_C_GENERAL,
2698 .group = FIO_OPT_G_INVALID,
2701 .name = "rwmixread",
2702 .lname = "Read/write mix read",
2703 .type = FIO_OPT_INT,
2704 .cb = str_rwmix_read_cb,
2705 .off1 = td_var_offset(rwmix[DDIR_READ]),
2707 .help = "Percentage of mixed workload that is reads",
2710 .inverse = "rwmixwrite",
2711 .category = FIO_OPT_C_IO,
2712 .group = FIO_OPT_G_RWMIX,
2715 .name = "rwmixwrite",
2716 .lname = "Read/write mix write",
2717 .type = FIO_OPT_INT,
2718 .cb = str_rwmix_write_cb,
2719 .off1 = td_var_offset(rwmix[DDIR_WRITE]),
2721 .help = "Percentage of mixed workload that is writes",
2724 .inverse = "rwmixread",
2725 .category = FIO_OPT_C_IO,
2726 .group = FIO_OPT_G_RWMIX,
2729 .name = "rwmixcycle",
2730 .lname = "Read/write mix cycle",
2731 .type = FIO_OPT_DEPRECATED,
2732 .category = FIO_OPT_C_IO,
2733 .group = FIO_OPT_G_RWMIX,
2738 .type = FIO_OPT_INT,
2739 .off1 = td_var_offset(nice),
2740 .help = "Set job CPU nice value",
2745 .category = FIO_OPT_C_GENERAL,
2746 .group = FIO_OPT_G_CRED,
2748 #ifdef FIO_HAVE_IOPRIO
2751 .lname = "I/O nice priority",
2752 .type = FIO_OPT_INT,
2753 .off1 = td_var_offset(ioprio),
2754 .help = "Set job IO priority value",
2758 .category = FIO_OPT_C_GENERAL,
2759 .group = FIO_OPT_G_CRED,
2762 .name = "prioclass",
2763 .lname = "I/O nice priority class",
2764 .type = FIO_OPT_INT,
2765 .off1 = td_var_offset(ioprio_class),
2766 .help = "Set job IO priority class",
2770 .category = FIO_OPT_C_GENERAL,
2771 .group = FIO_OPT_G_CRED,
2775 .name = "thinktime",
2776 .lname = "Thinktime",
2777 .type = FIO_OPT_INT,
2778 .off1 = td_var_offset(thinktime),
2779 .help = "Idle time between IO buffers (usec)",
2782 .category = FIO_OPT_C_IO,
2783 .group = FIO_OPT_G_THINKTIME,
2786 .name = "thinktime_spin",
2787 .lname = "Thinktime spin",
2788 .type = FIO_OPT_INT,
2789 .off1 = td_var_offset(thinktime_spin),
2790 .help = "Start think time by spinning this amount (usec)",
2793 .parent = "thinktime",
2795 .category = FIO_OPT_C_IO,
2796 .group = FIO_OPT_G_THINKTIME,
2799 .name = "thinktime_blocks",
2800 .lname = "Thinktime blocks",
2801 .type = FIO_OPT_INT,
2802 .off1 = td_var_offset(thinktime_blocks),
2803 .help = "IO buffer period between 'thinktime'",
2805 .parent = "thinktime",
2807 .category = FIO_OPT_C_IO,
2808 .group = FIO_OPT_G_THINKTIME,
2812 .lname = "I/O rate",
2813 .type = FIO_OPT_INT,
2814 .off1 = td_var_offset(rate[DDIR_READ]),
2815 .off2 = td_var_offset(rate[DDIR_WRITE]),
2816 .off3 = td_var_offset(rate[DDIR_TRIM]),
2817 .help = "Set bandwidth rate",
2818 .category = FIO_OPT_C_IO,
2819 .group = FIO_OPT_G_RATE,
2824 .lname = "I/O min rate",
2825 .type = FIO_OPT_INT,
2826 .off1 = td_var_offset(ratemin[DDIR_READ]),
2827 .off2 = td_var_offset(ratemin[DDIR_WRITE]),
2828 .off3 = td_var_offset(ratemin[DDIR_TRIM]),
2829 .help = "Job must meet this rate or it will be shutdown",
2832 .category = FIO_OPT_C_IO,
2833 .group = FIO_OPT_G_RATE,
2836 .name = "rate_iops",
2837 .lname = "I/O rate IOPS",
2838 .type = FIO_OPT_INT,
2839 .off1 = td_var_offset(rate_iops[DDIR_READ]),
2840 .off2 = td_var_offset(rate_iops[DDIR_WRITE]),
2841 .off3 = td_var_offset(rate_iops[DDIR_TRIM]),
2842 .help = "Limit IO used to this number of IO operations/sec",
2844 .category = FIO_OPT_C_IO,
2845 .group = FIO_OPT_G_RATE,
2848 .name = "rate_iops_min",
2849 .lname = "I/O min rate IOPS",
2850 .type = FIO_OPT_INT,
2851 .off1 = td_var_offset(rate_iops_min[DDIR_READ]),
2852 .off2 = td_var_offset(rate_iops_min[DDIR_WRITE]),
2853 .off3 = td_var_offset(rate_iops_min[DDIR_TRIM]),
2854 .help = "Job must meet this rate or it will be shut down",
2855 .parent = "rate_iops",
2857 .category = FIO_OPT_C_IO,
2858 .group = FIO_OPT_G_RATE,
2861 .name = "rate_process",
2862 .lname = "Rate Process",
2863 .type = FIO_OPT_STR,
2864 .off1 = td_var_offset(rate_process),
2865 .help = "What process controls how rated IO is managed",
2867 .category = FIO_OPT_C_IO,
2868 .group = FIO_OPT_G_RATE,
2871 .oval = RATE_PROCESS_LINEAR,
2872 .help = "Linear rate of IO",
2876 .oval = RATE_PROCESS_POISSON,
2877 .help = "Rate follows Poisson process",
2883 .name = "rate_cycle",
2884 .alias = "ratecycle",
2885 .lname = "I/O rate cycle",
2886 .type = FIO_OPT_INT,
2887 .off1 = td_var_offset(ratecycle),
2888 .help = "Window average for rate limits (msec)",
2892 .category = FIO_OPT_C_IO,
2893 .group = FIO_OPT_G_RATE,
2896 .name = "max_latency",
2897 .type = FIO_OPT_INT,
2898 .off1 = td_var_offset(max_latency),
2899 .help = "Maximum tolerated IO latency (usec)",
2901 .category = FIO_OPT_C_IO,
2902 .group = FIO_OPT_G_LATPROF,
2905 .name = "latency_target",
2906 .lname = "Latency Target (usec)",
2907 .type = FIO_OPT_STR_VAL_TIME,
2908 .off1 = td_var_offset(latency_target),
2909 .help = "Ramp to max queue depth supporting this latency",
2911 .category = FIO_OPT_C_IO,
2912 .group = FIO_OPT_G_LATPROF,
2915 .name = "latency_window",
2916 .lname = "Latency Window (usec)",
2917 .type = FIO_OPT_STR_VAL_TIME,
2918 .off1 = td_var_offset(latency_window),
2919 .help = "Time to sustain latency_target",
2921 .category = FIO_OPT_C_IO,
2922 .group = FIO_OPT_G_LATPROF,
2925 .name = "latency_percentile",
2926 .lname = "Latency Percentile",
2927 .type = FIO_OPT_FLOAT_LIST,
2928 .off1 = td_var_offset(latency_percentile),
2929 .help = "Percentile of IOs must be below latency_target",
2934 .category = FIO_OPT_C_IO,
2935 .group = FIO_OPT_G_LATPROF,
2938 .name = "invalidate",
2939 .lname = "Cache invalidate",
2940 .type = FIO_OPT_BOOL,
2941 .off1 = td_var_offset(invalidate_cache),
2942 .help = "Invalidate buffer/page cache prior to running job",
2944 .category = FIO_OPT_C_IO,
2945 .group = FIO_OPT_G_IO_TYPE,
2949 .lname = "Synchronous I/O",
2950 .type = FIO_OPT_BOOL,
2951 .off1 = td_var_offset(sync_io),
2952 .help = "Use O_SYNC for buffered writes",
2954 .parent = "buffered",
2956 .category = FIO_OPT_C_IO,
2957 .group = FIO_OPT_G_IO_TYPE,
2960 .name = "create_serialize",
2961 .lname = "Create serialize",
2962 .type = FIO_OPT_BOOL,
2963 .off1 = td_var_offset(create_serialize),
2964 .help = "Serialize creating of job files",
2966 .category = FIO_OPT_C_FILE,
2967 .group = FIO_OPT_G_INVALID,
2970 .name = "create_fsync",
2971 .lname = "Create fsync",
2972 .type = FIO_OPT_BOOL,
2973 .off1 = td_var_offset(create_fsync),
2974 .help = "fsync file after creation",
2976 .category = FIO_OPT_C_FILE,
2977 .group = FIO_OPT_G_INVALID,
2980 .name = "create_on_open",
2981 .lname = "Create on open",
2982 .type = FIO_OPT_BOOL,
2983 .off1 = td_var_offset(create_on_open),
2984 .help = "Create files when they are opened for IO",
2986 .category = FIO_OPT_C_FILE,
2987 .group = FIO_OPT_G_INVALID,
2990 .name = "create_only",
2991 .type = FIO_OPT_BOOL,
2992 .off1 = td_var_offset(create_only),
2993 .help = "Only perform file creation phase",
2994 .category = FIO_OPT_C_FILE,
2998 .name = "allow_file_create",
2999 .lname = "Allow file create",
3000 .type = FIO_OPT_BOOL,
3001 .off1 = td_var_offset(allow_create),
3002 .help = "Permit fio to create files, if they don't exist",
3004 .category = FIO_OPT_C_FILE,
3005 .group = FIO_OPT_G_FILENAME,
3008 .name = "allow_mounted_write",
3009 .lname = "Allow mounted write",
3010 .type = FIO_OPT_BOOL,
3011 .off1 = td_var_offset(allow_mounted_write),
3012 .help = "Allow writes to a mounted partition",
3014 .category = FIO_OPT_C_FILE,
3015 .group = FIO_OPT_G_FILENAME,
3019 .lname = "Pre-read files",
3020 .type = FIO_OPT_BOOL,
3021 .off1 = td_var_offset(pre_read),
3022 .help = "Pre-read files before starting official testing",
3024 .category = FIO_OPT_C_FILE,
3025 .group = FIO_OPT_G_INVALID,
3027 #ifdef FIO_HAVE_CPU_AFFINITY
3030 .lname = "CPU mask",
3031 .type = FIO_OPT_INT,
3032 .cb = str_cpumask_cb,
3033 .off1 = td_var_offset(cpumask),
3034 .help = "CPU affinity mask",
3035 .category = FIO_OPT_C_GENERAL,
3036 .group = FIO_OPT_G_CRED,
3039 .name = "cpus_allowed",
3040 .lname = "CPUs allowed",
3041 .type = FIO_OPT_STR,
3042 .cb = str_cpus_allowed_cb,
3043 .off1 = td_var_offset(cpumask),
3044 .help = "Set CPUs allowed",
3045 .category = FIO_OPT_C_GENERAL,
3046 .group = FIO_OPT_G_CRED,
3049 .name = "cpus_allowed_policy",
3050 .lname = "CPUs allowed distribution policy",
3051 .type = FIO_OPT_STR,
3052 .off1 = td_var_offset(cpus_allowed_policy),
3053 .help = "Distribution policy for cpus_allowed",
3054 .parent = "cpus_allowed",
3058 .oval = FIO_CPUS_SHARED,
3059 .help = "Mask shared between threads",
3062 .oval = FIO_CPUS_SPLIT,
3063 .help = "Mask split between threads",
3066 .category = FIO_OPT_C_GENERAL,
3067 .group = FIO_OPT_G_CRED,
3070 #ifdef CONFIG_LIBNUMA
3072 .name = "numa_cpu_nodes",
3073 .type = FIO_OPT_STR,
3074 .cb = str_numa_cpunodes_cb,
3075 .off1 = td_var_offset(numa_cpunodes),
3076 .help = "NUMA CPU nodes bind",
3077 .category = FIO_OPT_C_GENERAL,
3078 .group = FIO_OPT_G_INVALID,
3081 .name = "numa_mem_policy",
3082 .type = FIO_OPT_STR,
3083 .cb = str_numa_mpol_cb,
3084 .off1 = td_var_offset(numa_memnodes),
3085 .help = "NUMA memory policy setup",
3086 .category = FIO_OPT_C_GENERAL,
3087 .group = FIO_OPT_G_INVALID,
3091 .name = "end_fsync",
3092 .lname = "End fsync",
3093 .type = FIO_OPT_BOOL,
3094 .off1 = td_var_offset(end_fsync),
3095 .help = "Include fsync at the end of job",
3097 .category = FIO_OPT_C_FILE,
3098 .group = FIO_OPT_G_INVALID,
3101 .name = "fsync_on_close",
3102 .lname = "Fsync on close",
3103 .type = FIO_OPT_BOOL,
3104 .off1 = td_var_offset(fsync_on_close),
3105 .help = "fsync files on close",
3107 .category = FIO_OPT_C_FILE,
3108 .group = FIO_OPT_G_INVALID,
3112 .lname = "Unlink file",
3113 .type = FIO_OPT_BOOL,
3114 .off1 = td_var_offset(unlink),
3115 .help = "Unlink created files after job has completed",
3117 .category = FIO_OPT_C_FILE,
3118 .group = FIO_OPT_G_INVALID,
3122 .lname = "Exit-all on terminate",
3123 .type = FIO_OPT_STR_SET,
3124 .cb = str_exitall_cb,
3125 .help = "Terminate all jobs when one exits",
3126 .category = FIO_OPT_C_GENERAL,
3127 .group = FIO_OPT_G_PROCESS,
3130 .name = "stonewall",
3131 .lname = "Wait for previous",
3132 .alias = "wait_for_previous",
3133 .type = FIO_OPT_STR_SET,
3134 .off1 = td_var_offset(stonewall),
3135 .help = "Insert a hard barrier between this job and previous",
3136 .category = FIO_OPT_C_GENERAL,
3137 .group = FIO_OPT_G_PROCESS,
3140 .name = "new_group",
3141 .lname = "New group",
3142 .type = FIO_OPT_STR_SET,
3143 .off1 = td_var_offset(new_group),
3144 .help = "Mark the start of a new group (for reporting)",
3145 .category = FIO_OPT_C_GENERAL,
3146 .group = FIO_OPT_G_PROCESS,
3151 .type = FIO_OPT_STR_SET,
3152 .off1 = td_var_offset(use_thread),
3153 .help = "Use threads instead of processes",
3154 #ifdef CONFIG_NO_SHM
3158 .category = FIO_OPT_C_GENERAL,
3159 .group = FIO_OPT_G_PROCESS,
3162 .name = "per_job_logs",
3163 .type = FIO_OPT_BOOL,
3164 .off1 = td_var_offset(per_job_logs),
3165 .help = "Include job number in generated log files or not",
3167 .category = FIO_OPT_C_LOG,
3168 .group = FIO_OPT_G_INVALID,
3171 .name = "write_bw_log",
3172 .lname = "Write bandwidth log",
3173 .type = FIO_OPT_STR_STORE,
3174 .off1 = td_var_offset(bw_log_file),
3175 .help = "Write log of bandwidth during run",
3176 .category = FIO_OPT_C_LOG,
3177 .group = FIO_OPT_G_INVALID,
3180 .name = "write_lat_log",
3181 .lname = "Write latency log",
3182 .type = FIO_OPT_STR_STORE,
3183 .off1 = td_var_offset(lat_log_file),
3184 .help = "Write log of latency during run",
3185 .category = FIO_OPT_C_LOG,
3186 .group = FIO_OPT_G_INVALID,
3189 .name = "write_iops_log",
3190 .lname = "Write IOPS log",
3191 .type = FIO_OPT_STR_STORE,
3192 .off1 = td_var_offset(iops_log_file),
3193 .help = "Write log of IOPS during run",
3194 .category = FIO_OPT_C_LOG,
3195 .group = FIO_OPT_G_INVALID,
3198 .name = "log_avg_msec",
3199 .lname = "Log averaging (msec)",
3200 .type = FIO_OPT_INT,
3201 .off1 = td_var_offset(log_avg_msec),
3202 .help = "Average bw/iops/lat logs over this period of time",
3204 .category = FIO_OPT_C_LOG,
3205 .group = FIO_OPT_G_INVALID,
3208 .name = "log_offset",
3209 .lname = "Log offset of IO",
3210 .type = FIO_OPT_BOOL,
3211 .off1 = td_var_offset(log_offset),
3212 .help = "Include offset of IO for each log entry",
3214 .category = FIO_OPT_C_LOG,
3215 .group = FIO_OPT_G_INVALID,
3219 .name = "log_compression",
3220 .lname = "Log compression",
3221 .type = FIO_OPT_INT,
3222 .off1 = td_var_offset(log_gz),
3223 .help = "Log in compressed chunks of this size",
3225 .maxval = 512 * 1024 * 1024ULL,
3226 .category = FIO_OPT_C_LOG,
3227 .group = FIO_OPT_G_INVALID,
3230 .name = "log_store_compressed",
3231 .lname = "Log store compressed",
3232 .type = FIO_OPT_BOOL,
3233 .off1 = td_var_offset(log_gz_store),
3234 .help = "Store logs in a compressed format",
3235 .category = FIO_OPT_C_LOG,
3236 .group = FIO_OPT_G_INVALID,
3240 .name = "block_error_percentiles",
3241 .lname = "Block error percentiles",
3242 .type = FIO_OPT_BOOL,
3243 .off1 = td_var_offset(block_error_hist),
3244 .help = "Record trim block errors and make a histogram",
3246 .category = FIO_OPT_C_LOG,
3247 .group = FIO_OPT_G_INVALID,
3250 .name = "bwavgtime",
3251 .lname = "Bandwidth average time",
3252 .type = FIO_OPT_INT,
3253 .off1 = td_var_offset(bw_avg_time),
3254 .help = "Time window over which to calculate bandwidth"
3257 .parent = "write_bw_log",
3260 .category = FIO_OPT_C_LOG,
3261 .group = FIO_OPT_G_INVALID,
3264 .name = "iopsavgtime",
3265 .lname = "IOPS average time",
3266 .type = FIO_OPT_INT,
3267 .off1 = td_var_offset(iops_avg_time),
3268 .help = "Time window over which to calculate IOPS (msec)",
3270 .parent = "write_iops_log",
3273 .category = FIO_OPT_C_LOG,
3274 .group = FIO_OPT_G_INVALID,
3277 .name = "group_reporting",
3278 .lname = "Group reporting",
3279 .type = FIO_OPT_STR_SET,
3280 .off1 = td_var_offset(group_reporting),
3281 .help = "Do reporting on a per-group basis",
3282 .category = FIO_OPT_C_STAT,
3283 .group = FIO_OPT_G_INVALID,
3286 .name = "zero_buffers",
3287 .lname = "Zero I/O buffers",
3288 .type = FIO_OPT_STR_SET,
3289 .off1 = td_var_offset(zero_buffers),
3290 .help = "Init IO buffers to all zeroes",
3291 .category = FIO_OPT_C_IO,
3292 .group = FIO_OPT_G_IO_BUF,
3295 .name = "refill_buffers",
3296 .lname = "Refill I/O buffers",
3297 .type = FIO_OPT_STR_SET,
3298 .off1 = td_var_offset(refill_buffers),
3299 .help = "Refill IO buffers on every IO submit",
3300 .category = FIO_OPT_C_IO,
3301 .group = FIO_OPT_G_IO_BUF,
3304 .name = "scramble_buffers",
3305 .lname = "Scramble I/O buffers",
3306 .type = FIO_OPT_BOOL,
3307 .off1 = td_var_offset(scramble_buffers),
3308 .help = "Slightly scramble buffers on every IO submit",
3310 .category = FIO_OPT_C_IO,
3311 .group = FIO_OPT_G_IO_BUF,
3314 .name = "buffer_pattern",
3315 .lname = "Buffer pattern",
3316 .type = FIO_OPT_STR,
3317 .cb = str_buffer_pattern_cb,
3318 .off1 = td_var_offset(buffer_pattern),
3319 .help = "Fill pattern for IO buffers",
3320 .category = FIO_OPT_C_IO,
3321 .group = FIO_OPT_G_IO_BUF,
3324 .name = "buffer_compress_percentage",
3325 .lname = "Buffer compression percentage",
3326 .type = FIO_OPT_INT,
3327 .cb = str_buffer_compress_cb,
3328 .off1 = td_var_offset(compress_percentage),
3331 .help = "How compressible the buffer is (approximately)",
3333 .category = FIO_OPT_C_IO,
3334 .group = FIO_OPT_G_IO_BUF,
3337 .name = "buffer_compress_chunk",
3338 .lname = "Buffer compression chunk size",
3339 .type = FIO_OPT_INT,
3340 .off1 = td_var_offset(compress_chunk),
3341 .parent = "buffer_compress_percentage",
3343 .help = "Size of compressible region in buffer",
3345 .category = FIO_OPT_C_IO,
3346 .group = FIO_OPT_G_IO_BUF,
3349 .name = "dedupe_percentage",
3350 .lname = "Dedupe percentage",
3351 .type = FIO_OPT_INT,
3352 .cb = str_dedupe_cb,
3353 .off1 = td_var_offset(dedupe_percentage),
3356 .help = "Percentage of buffers that are dedupable",
3358 .category = FIO_OPT_C_IO,
3359 .group = FIO_OPT_G_IO_BUF,
3362 .name = "clat_percentiles",
3363 .lname = "Completion latency percentiles",
3364 .type = FIO_OPT_BOOL,
3365 .off1 = td_var_offset(clat_percentiles),
3366 .help = "Enable the reporting of completion latency percentiles",
3368 .category = FIO_OPT_C_STAT,
3369 .group = FIO_OPT_G_INVALID,
3372 .name = "percentile_list",
3373 .lname = "Percentile list",
3374 .type = FIO_OPT_FLOAT_LIST,
3375 .off1 = td_var_offset(percentile_list),
3376 .off2 = td_var_offset(percentile_precision),
3377 .help = "Specify a custom list of percentiles to report for "
3378 "completion latency and block errors",
3379 .def = "1:5:10:20:30:40:50:60:70:80:90:95:99:99.5:99.9:99.95:99.99",
3380 .maxlen = FIO_IO_U_LIST_MAX_LEN,
3383 .category = FIO_OPT_C_STAT,
3384 .group = FIO_OPT_G_INVALID,
3387 #ifdef FIO_HAVE_DISK_UTIL
3389 .name = "disk_util",
3390 .lname = "Disk utilization",
3391 .type = FIO_OPT_BOOL,
3392 .off1 = td_var_offset(do_disk_util),
3393 .help = "Log disk utilization statistics",
3395 .category = FIO_OPT_C_STAT,
3396 .group = FIO_OPT_G_INVALID,
3400 .name = "gtod_reduce",
3401 .lname = "Reduce gettimeofday() calls",
3402 .type = FIO_OPT_BOOL,
3403 .help = "Greatly reduce number of gettimeofday() calls",
3404 .cb = str_gtod_reduce_cb,
3407 .category = FIO_OPT_C_STAT,
3408 .group = FIO_OPT_G_INVALID,
3411 .name = "disable_lat",
3412 .lname = "Disable all latency stats",
3413 .type = FIO_OPT_BOOL,
3414 .off1 = td_var_offset(disable_lat),
3415 .help = "Disable latency numbers",
3416 .parent = "gtod_reduce",
3419 .category = FIO_OPT_C_STAT,
3420 .group = FIO_OPT_G_INVALID,
3423 .name = "disable_clat",
3424 .lname = "Disable completion latency stats",
3425 .type = FIO_OPT_BOOL,
3426 .off1 = td_var_offset(disable_clat),
3427 .help = "Disable completion latency numbers",
3428 .parent = "gtod_reduce",
3431 .category = FIO_OPT_C_STAT,
3432 .group = FIO_OPT_G_INVALID,
3435 .name = "disable_slat",
3436 .lname = "Disable submission latency stats",
3437 .type = FIO_OPT_BOOL,
3438 .off1 = td_var_offset(disable_slat),
3439 .help = "Disable submission latency numbers",
3440 .parent = "gtod_reduce",
3443 .category = FIO_OPT_C_STAT,
3444 .group = FIO_OPT_G_INVALID,
3447 .name = "disable_bw_measurement",
3448 .lname = "Disable bandwidth stats",
3449 .type = FIO_OPT_BOOL,
3450 .off1 = td_var_offset(disable_bw),
3451 .help = "Disable bandwidth logging",
3452 .parent = "gtod_reduce",
3455 .category = FIO_OPT_C_STAT,
3456 .group = FIO_OPT_G_INVALID,
3460 .lname = "Dedicated gettimeofday() CPU",
3461 .type = FIO_OPT_INT,
3462 .off1 = td_var_offset(gtod_cpu),
3463 .help = "Set up dedicated gettimeofday() thread on this CPU",
3464 .verify = gtod_cpu_verify,
3465 .category = FIO_OPT_C_GENERAL,
3466 .group = FIO_OPT_G_CLOCK,
3469 .name = "unified_rw_reporting",
3470 .type = FIO_OPT_BOOL,
3471 .off1 = td_var_offset(unified_rw_rep),
3472 .help = "Unify reporting across data direction",
3474 .category = FIO_OPT_C_GENERAL,
3475 .group = FIO_OPT_G_INVALID,
3478 .name = "continue_on_error",
3479 .lname = "Continue on error",
3480 .type = FIO_OPT_STR,
3481 .off1 = td_var_offset(continue_on_error),
3482 .help = "Continue on non-fatal errors during IO",
3484 .category = FIO_OPT_C_GENERAL,
3485 .group = FIO_OPT_G_ERR,
3488 .oval = ERROR_TYPE_NONE,
3489 .help = "Exit when an error is encountered",
3492 .oval = ERROR_TYPE_READ,
3493 .help = "Continue on read errors only",
3496 .oval = ERROR_TYPE_WRITE,
3497 .help = "Continue on write errors only",
3500 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
3501 .help = "Continue on any IO errors",
3504 .oval = ERROR_TYPE_VERIFY,
3505 .help = "Continue on verify errors only",
3508 .oval = ERROR_TYPE_ANY,
3509 .help = "Continue on all io and verify errors",
3512 .oval = ERROR_TYPE_NONE,
3513 .help = "Alias for 'none'",
3516 .oval = ERROR_TYPE_ANY,
3517 .help = "Alias for 'all'",
3522 .name = "ignore_error",
3523 .type = FIO_OPT_STR,
3524 .cb = str_ignore_error_cb,
3525 .off1 = td_var_offset(ignore_error_nr),
3526 .help = "Set a specific list of errors to ignore",
3528 .category = FIO_OPT_C_GENERAL,
3529 .group = FIO_OPT_G_ERR,
3532 .name = "error_dump",
3533 .type = FIO_OPT_BOOL,
3534 .off1 = td_var_offset(error_dump),
3536 .help = "Dump info on each error",
3537 .category = FIO_OPT_C_GENERAL,
3538 .group = FIO_OPT_G_ERR,
3543 .type = FIO_OPT_STR_STORE,
3544 .off1 = td_var_offset(profile),
3545 .help = "Select a specific builtin performance test",
3546 .category = FIO_OPT_C_PROFILE,
3547 .group = FIO_OPT_G_INVALID,
3552 .type = FIO_OPT_STR_STORE,
3553 .off1 = td_var_offset(cgroup),
3554 .help = "Add job to cgroup of this name",
3555 .category = FIO_OPT_C_GENERAL,
3556 .group = FIO_OPT_G_CGROUP,
3559 .name = "cgroup_nodelete",
3560 .lname = "Cgroup no-delete",
3561 .type = FIO_OPT_BOOL,
3562 .off1 = td_var_offset(cgroup_nodelete),
3563 .help = "Do not delete cgroups after job completion",
3566 .category = FIO_OPT_C_GENERAL,
3567 .group = FIO_OPT_G_CGROUP,
3570 .name = "cgroup_weight",
3571 .lname = "Cgroup weight",
3572 .type = FIO_OPT_INT,
3573 .off1 = td_var_offset(cgroup_weight),
3574 .help = "Use given weight for cgroup",
3578 .category = FIO_OPT_C_GENERAL,
3579 .group = FIO_OPT_G_CGROUP,
3584 .type = FIO_OPT_INT,
3585 .off1 = td_var_offset(uid),
3586 .help = "Run job with this user ID",
3587 .category = FIO_OPT_C_GENERAL,
3588 .group = FIO_OPT_G_CRED,
3592 .lname = "Group ID",
3593 .type = FIO_OPT_INT,
3594 .off1 = td_var_offset(gid),
3595 .help = "Run job with this group ID",
3596 .category = FIO_OPT_C_GENERAL,
3597 .group = FIO_OPT_G_CRED,
3602 .type = FIO_OPT_INT,
3603 .off1 = td_var_offset(kb_base),
3609 .help = "Use 1024 as the K base",
3613 .help = "Use 1000 as the K base",
3616 .help = "How many bytes per KB for reporting (1000 or 1024)",
3617 .category = FIO_OPT_C_GENERAL,
3618 .group = FIO_OPT_G_INVALID,
3621 .name = "unit_base",
3622 .lname = "Base unit for reporting (Bits or Bytes)",
3623 .type = FIO_OPT_INT,
3624 .off1 = td_var_offset(unit_base),
3629 .help = "Auto-detect",
3633 .help = "Normal (byte based)",
3637 .help = "Bit based",
3640 .help = "Bit multiple of result summary data (8 for byte, 1 for bit)",
3641 .category = FIO_OPT_C_GENERAL,
3642 .group = FIO_OPT_G_INVALID,
3645 .name = "hugepage-size",
3646 .lname = "Hugepage size",
3647 .type = FIO_OPT_INT,
3648 .off1 = td_var_offset(hugepage_size),
3649 .help = "When using hugepages, specify size of each page",
3650 .def = __fio_stringify(FIO_HUGE_PAGE),
3651 .interval = 1024 * 1024,
3652 .category = FIO_OPT_C_GENERAL,
3653 .group = FIO_OPT_G_INVALID,
3657 .lname = "I/O flow ID",
3658 .type = FIO_OPT_INT,
3659 .off1 = td_var_offset(flow_id),
3660 .help = "The flow index ID to use",
3662 .category = FIO_OPT_C_IO,
3663 .group = FIO_OPT_G_IO_FLOW,
3667 .lname = "I/O flow weight",
3668 .type = FIO_OPT_INT,
3669 .off1 = td_var_offset(flow),
3670 .help = "Weight for flow control of this job",
3671 .parent = "flow_id",
3674 .category = FIO_OPT_C_IO,
3675 .group = FIO_OPT_G_IO_FLOW,
3678 .name = "flow_watermark",
3679 .lname = "I/O flow watermark",
3680 .type = FIO_OPT_INT,
3681 .off1 = td_var_offset(flow_watermark),
3682 .help = "High watermark for flow control. This option"
3683 " should be set to the same value for all threads"
3684 " with non-zero flow.",
3685 .parent = "flow_id",
3688 .category = FIO_OPT_C_IO,
3689 .group = FIO_OPT_G_IO_FLOW,
3692 .name = "flow_sleep",
3693 .lname = "I/O flow sleep",
3694 .type = FIO_OPT_INT,
3695 .off1 = td_var_offset(flow_sleep),
3696 .help = "How many microseconds to sleep after being held"
3697 " back by the flow control mechanism",
3698 .parent = "flow_id",
3701 .category = FIO_OPT_C_IO,
3702 .group = FIO_OPT_G_IO_FLOW,
3706 .lname = "Skip operations against bad blocks",
3707 .type = FIO_OPT_BOOL,
3708 .off1 = td_var_offset(skip_bad),
3709 .help = "Skip operations against known bad blocks.",
3712 .category = FIO_OPT_C_IO,
3713 .group = FIO_OPT_G_MTD,
3720 static void add_to_lopt(struct option *lopt, struct fio_option *o,
3721 const char *name, int val)
3723 lopt->name = (char *) name;
3725 if (o->type == FIO_OPT_STR_SET)
3726 lopt->has_arg = optional_argument;
3728 lopt->has_arg = required_argument;
3731 static void options_to_lopts(struct fio_option *opts,
3732 struct option *long_options,
3733 int i, int option_type)
3735 struct fio_option *o = &opts[0];
3737 add_to_lopt(&long_options[i], o, o->name, option_type);
3740 add_to_lopt(&long_options[i], o, o->alias, option_type);
3745 assert(i < FIO_NR_OPTIONS);
3749 void fio_options_set_ioengine_opts(struct option *long_options,
3750 struct thread_data *td)
3755 while (long_options[i].name) {
3756 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
3757 memset(&long_options[i], 0, sizeof(*long_options));
3764 * Just clear out the prior ioengine options.
3769 options_to_lopts(td->io_ops->options, long_options, i,
3770 FIO_GETOPT_IOENGINE);
3773 void fio_options_dup_and_init(struct option *long_options)
3777 options_init(fio_options);
3780 while (long_options[i].name)
3783 options_to_lopts(fio_options, long_options, i, FIO_GETOPT_JOB);
3786 struct fio_keyword {
3792 static struct fio_keyword fio_keywords[] = {
3794 .word = "$pagesize",
3795 .desc = "Page size in the system",
3798 .word = "$mb_memory",
3799 .desc = "Megabytes of memory online",
3803 .desc = "Number of CPUs online in the system",
3810 void fio_keywords_exit(void)
3812 struct fio_keyword *kw;
3814 kw = &fio_keywords[0];
3822 void fio_keywords_init(void)
3824 unsigned long long mb_memory;
3828 sprintf(buf, "%lu", (unsigned long) page_size);
3829 fio_keywords[0].replace = strdup(buf);
3831 mb_memory = os_phys_mem() / (1024 * 1024);
3832 sprintf(buf, "%llu", mb_memory);
3833 fio_keywords[1].replace = strdup(buf);
3836 sprintf(buf, "%lu", l);
3837 fio_keywords[2].replace = strdup(buf);
3842 static char *bc_calc(char *str)
3844 char buf[128], *tmp;
3849 * No math, just return string
3851 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
3852 !strchr(str, '/')) || strchr(str, '\''))
3856 * Split option from value, we only need to calculate the value
3858 tmp = strchr(str, '=');
3865 * Prevent buffer overflows; such a case isn't reasonable anyway
3867 if (strlen(str) >= 128 || strlen(tmp) > 100)
3870 sprintf(buf, "which %s > /dev/null", BC_APP);
3872 log_err("fio: bc is needed for performing math\n");
3876 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
3877 f = popen(buf, "r");
3881 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
3888 buf[(tmp - str) + ret - 1] = '\0';
3889 memcpy(buf, str, tmp - str);
3895 * Return a copy of the input string with substrings of the form ${VARNAME}
3896 * substituted with the value of the environment variable VARNAME. The
3897 * substitution always occurs, even if VARNAME is empty or the corresponding
3898 * environment variable undefined.
3900 static char *option_dup_subs(const char *opt)
3902 char out[OPT_LEN_MAX+1];
3903 char in[OPT_LEN_MAX+1];
3906 char *ch1, *ch2, *env;
3907 ssize_t nchr = OPT_LEN_MAX;
3910 if (strlen(opt) + 1 > OPT_LEN_MAX) {
3911 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
3915 in[OPT_LEN_MAX] = '\0';
3916 strncpy(in, opt, OPT_LEN_MAX);
3918 while (*inptr && nchr > 0) {
3919 if (inptr[0] == '$' && inptr[1] == '{') {
3920 ch2 = strchr(inptr, '}');
3921 if (ch2 && inptr+1 < ch2) {
3928 envlen = strlen(env);
3929 if (envlen <= nchr) {
3930 memcpy(outptr, env, envlen);
3940 *outptr++ = *inptr++;
3949 * Look for reserved variable names and replace them with real values
3951 static char *fio_keyword_replace(char *opt)
3957 for (i = 0; fio_keywords[i].word != NULL; i++) {
3958 struct fio_keyword *kw = &fio_keywords[i];
3960 while ((s = strstr(opt, kw->word)) != NULL) {
3961 char *new = malloc(strlen(opt) + 1);
3967 * Copy part of the string before the keyword and
3968 * sprintf() the replacement after it.
3970 memcpy(new, opt, olen);
3971 len = sprintf(new + olen, "%s", kw->replace);
3974 * If there's more in the original string, copy that
3977 opt += strlen(kw->word) + olen;
3979 memcpy(new + olen + len, opt, opt - o_org - 1);
3982 * replace opt and free the old opt
3992 * Check for potential math and invoke bc, if possible
4000 static char **dup_and_sub_options(char **opts, int num_opts)
4003 char **opts_copy = malloc(num_opts * sizeof(*opts));
4004 for (i = 0; i < num_opts; i++) {
4005 opts_copy[i] = option_dup_subs(opts[i]);
4008 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
4013 static void show_closest_option(const char *opt)
4015 int best_option, best_distance;
4024 while (name[i] != '\0' && name[i] != '=')
4029 best_distance = INT_MAX;
4031 while (fio_options[i].name) {
4032 distance = string_distance(name, fio_options[i].name);
4033 if (distance < best_distance) {
4034 best_distance = distance;
4040 if (best_option != -1 && string_distance_ok(name, best_distance))
4041 log_err("Did you mean %s?\n", fio_options[best_option].name);
4046 int fio_options_parse(struct thread_data *td, char **opts, int num_opts,
4049 int i, ret, unknown;
4052 sort_options(opts, fio_options, num_opts);
4053 opts_copy = dup_and_sub_options(opts, num_opts);
4055 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
4056 struct fio_option *o;
4057 int newret = parse_option(opts_copy[i], opts[i], fio_options,
4058 &o, td, dump_cmdline);
4061 fio_option_mark_set(&td->o, o);
4069 opts_copy[i] = NULL;
4076 ret |= ioengine_load(td);
4078 sort_options(opts_copy, td->io_ops->options, num_opts);
4081 for (i = 0; i < num_opts; i++) {
4082 struct fio_option *o = NULL;
4089 newret = parse_option(opts_copy[i], opts[i],
4090 td->io_ops->options, &o,
4091 td->eo, dump_cmdline);
4095 log_err("Bad option <%s>\n", opts[i]);
4096 show_closest_option(opts[i]);
4099 opts_copy[i] = NULL;
4107 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
4111 ret = parse_cmd_option(opt, val, fio_options, td);
4113 struct fio_option *o;
4115 o = find_option(fio_options, opt);
4117 fio_option_mark_set(&td->o, o);
4123 int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
4126 return parse_cmd_option(opt, val, td->io_ops->options, td->eo);
4129 void fio_fill_default_options(struct thread_data *td)
4131 td->o.magic = OPT_MAGIC;
4132 fill_default_options(td, fio_options);
4135 int fio_show_option_help(const char *opt)
4137 return show_cmd_help(fio_options, opt);
4140 void options_mem_dupe(void *data, struct fio_option *options)
4142 struct fio_option *o;
4145 for (o = &options[0]; o->name; o++) {
4146 if (o->type != FIO_OPT_STR_STORE)
4149 ptr = td_var(data, o, o->off1);
4151 *ptr = strdup(*ptr);
4156 * dupe FIO_OPT_STR_STORE options
4158 void fio_options_mem_dupe(struct thread_data *td)
4160 options_mem_dupe(&td->o, fio_options);
4162 if (td->eo && td->io_ops) {
4163 void *oldeo = td->eo;
4165 td->eo = malloc(td->io_ops->option_struct_size);
4166 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
4167 options_mem_dupe(td->eo, td->io_ops->options);
4171 unsigned int fio_get_kb_base(void *data)
4173 struct thread_options *o = data;
4174 unsigned int kb_base = 0;
4177 * This is a hack... For private options, *data is not holding
4178 * a pointer to the thread_options, but to private data. This means
4179 * we can't safely dereference it, but magic is first so mem wise
4180 * it is valid. But this also means that if the job first sets
4181 * kb_base and expects that to be honored by private options,
4182 * it will be disappointed. We will return the global default
4185 if (o && o->magic == OPT_MAGIC)
4186 kb_base = o->kb_base;
4193 int add_option(struct fio_option *o)
4195 struct fio_option *__o;
4204 if (opt_index + 1 == FIO_MAX_OPTS) {
4205 log_err("fio: FIO_MAX_OPTS is too small\n");
4209 memcpy(&fio_options[opt_index], o, sizeof(*o));
4210 fio_options[opt_index + 1].name = NULL;
4214 void invalidate_profile_options(const char *prof_name)
4216 struct fio_option *o;
4220 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
4221 o->type = FIO_OPT_INVALID;
4222 o->prof_name = NULL;
4228 void add_opt_posval(const char *optname, const char *ival, const char *help)
4230 struct fio_option *o;
4233 o = find_option(fio_options, optname);
4237 for (i = 0; i < PARSE_MAX_VP; i++) {
4238 if (o->posval[i].ival)
4241 o->posval[i].ival = ival;
4242 o->posval[i].help = help;
4247 void del_opt_posval(const char *optname, const char *ival)
4249 struct fio_option *o;
4252 o = find_option(fio_options, optname);
4256 for (i = 0; i < PARSE_MAX_VP; i++) {
4257 if (!o->posval[i].ival)
4259 if (strcmp(o->posval[i].ival, ival))
4262 o->posval[i].ival = NULL;
4263 o->posval[i].help = NULL;
4267 void fio_options_free(struct thread_data *td)
4269 options_free(fio_options, td);
4270 if (td->eo && td->io_ops && td->io_ops->options) {
4271 options_free(td->io_ops->options, td->eo);
4277 struct fio_option *fio_option_find(const char *name)
4279 return find_option(fio_options, name);
4282 static struct fio_option *find_next_opt(struct thread_options *o,
4283 struct fio_option *from,
4286 struct fio_option *opt;
4289 from = &fio_options[0];
4295 if (off1 == from->off1) {
4300 } while (from->name);
4305 static int opt_is_set(struct thread_options *o, struct fio_option *opt)
4307 unsigned int opt_off, index, offset;
4309 opt_off = opt - &fio_options[0];
4310 index = opt_off / (8 * sizeof(uint64_t));
4311 offset = opt_off & ((8 * sizeof(uint64_t)) - 1);
4312 return (o->set_options[index] & ((uint64_t)1 << offset)) != 0;
4315 int __fio_option_is_set(struct thread_options *o, unsigned int off1)
4317 struct fio_option *opt, *next;
4320 while ((opt = find_next_opt(o, next, off1)) != NULL) {
4321 if (opt_is_set(o, opt))
4330 void fio_option_mark_set(struct thread_options *o, struct fio_option *opt)
4332 unsigned int opt_off, index, offset;
4334 opt_off = opt - &fio_options[0];
4335 index = opt_off / (8 * sizeof(uint64_t));
4336 offset = opt_off & ((8 * sizeof(uint64_t)) - 1);
4337 o->set_options[index] |= (uint64_t)1 << offset;