18 #include "crc/crc32c.h"
21 * Check if mmap/mmaphuge has a :/foo/bar/file at the end. If so, return that.
23 static char *get_opt_postfix(const char *str)
25 char *p = strstr(str, ":");
31 strip_blank_front(&p);
36 static int converthexchartoint(char a)
56 static int bs_cmp(const void *p1, const void *p2)
58 const struct bssplit *bsp1 = p1;
59 const struct bssplit *bsp2 = p2;
61 return bsp1->perc < bsp2->perc;
64 static int bssplit_ddir(struct thread_options *o, int ddir, char *str)
66 struct bssplit *bssplit;
67 unsigned int i, perc, perc_missing;
68 unsigned int max_bs, min_bs;
72 o->bssplit_nr[ddir] = 4;
73 bssplit = malloc(4 * sizeof(struct bssplit));
78 while ((fname = strsep(&str, ":")) != NULL) {
85 * grow struct buffer, if needed
87 if (i == o->bssplit_nr[ddir]) {
88 o->bssplit_nr[ddir] <<= 1;
89 bssplit = realloc(bssplit, o->bssplit_nr[ddir]
90 * sizeof(struct bssplit));
93 perc_str = strstr(fname, "/");
97 perc = atoi(perc_str);
105 if (str_to_decimal(fname, &val, 1, o, 0, 0)) {
106 log_err("fio: bssplit conversion failed\n");
117 bssplit[i].perc = perc;
121 o->bssplit_nr[ddir] = i;
124 * Now check if the percentages add up, and how much is missing
126 perc = perc_missing = 0;
127 for (i = 0; i < o->bssplit_nr[ddir]; i++) {
128 struct bssplit *bsp = &bssplit[i];
130 if (bsp->perc == -1U)
136 if (perc > 100 && perc_missing > 1) {
137 log_err("fio: bssplit percentages add to more than 100%%\n");
143 * If values didn't have a percentage set, divide the remains between
147 if (perc_missing == 1 && o->bssplit_nr[ddir] == 1)
149 for (i = 0; i < o->bssplit_nr[ddir]; i++) {
150 struct bssplit *bsp = &bssplit[i];
152 if (bsp->perc == -1U)
153 bsp->perc = (100 - perc) / perc_missing;
157 o->min_bs[ddir] = min_bs;
158 o->max_bs[ddir] = max_bs;
161 * now sort based on percentages, for ease of lookup
163 qsort(bssplit, o->bssplit_nr[ddir], sizeof(struct bssplit), bs_cmp);
164 o->bssplit[ddir] = bssplit;
168 static int str_bssplit_cb(void *data, const char *input)
170 struct thread_data *td = data;
171 char *str, *p, *odir, *ddir;
177 p = str = strdup(input);
179 strip_blank_front(&str);
180 strip_blank_end(str);
182 odir = strchr(str, ',');
184 ddir = strchr(odir + 1, ',');
186 ret = bssplit_ddir(&td->o, DDIR_TRIM, ddir + 1);
192 op = strdup(odir + 1);
193 ret = bssplit_ddir(&td->o, DDIR_TRIM, op);
198 ret = bssplit_ddir(&td->o, DDIR_WRITE, odir + 1);
201 ret = bssplit_ddir(&td->o, DDIR_READ, str);
207 ret = bssplit_ddir(&td->o, DDIR_WRITE, op);
212 ret = bssplit_ddir(&td->o, DDIR_TRIM, op);
215 ret = bssplit_ddir(&td->o, DDIR_READ, str);
222 static int str2error(char *str)
224 const char *err[] = { "EPERM", "ENOENT", "ESRCH", "EINTR", "EIO",
225 "ENXIO", "E2BIG", "ENOEXEC", "EBADF",
226 "ECHILD", "EAGAIN", "ENOMEM", "EACCES",
227 "EFAULT", "ENOTBLK", "EBUSY", "EEXIST",
228 "EXDEV", "ENODEV", "ENOTDIR", "EISDIR",
229 "EINVAL", "ENFILE", "EMFILE", "ENOTTY",
230 "ETXTBSY","EFBIG", "ENOSPC", "ESPIPE",
231 "EROFS","EMLINK", "EPIPE", "EDOM", "ERANGE" };
232 int i = 0, num = sizeof(err) / sizeof(void *);
235 if (!strcmp(err[i], str))
242 static int ignore_error_type(struct thread_data *td, int etype, char *str)
248 if (etype >= ERROR_TYPE_CNT) {
249 log_err("Illegal error type\n");
253 td->o.ignore_error_nr[etype] = 4;
254 error = malloc(4 * sizeof(struct bssplit));
257 while ((fname = strsep(&str, ":")) != NULL) {
263 * grow struct buffer, if needed
265 if (i == td->o.ignore_error_nr[etype]) {
266 td->o.ignore_error_nr[etype] <<= 1;
267 error = realloc(error, td->o.ignore_error_nr[etype]
270 if (fname[0] == 'E') {
271 error[i] = str2error(fname);
273 error[i] = atoi(fname);
275 error[i] = -error[i];
278 log_err("Unknown error %s, please use number value \n",
286 td->o.continue_on_error |= 1 << etype;
287 td->o.ignore_error_nr[etype] = i;
288 td->o.ignore_error[etype] = error;
296 static int str_ignore_error_cb(void *data, const char *input)
298 struct thread_data *td = data;
300 int type = 0, ret = 1;
305 p = str = strdup(input);
307 strip_blank_front(&str);
308 strip_blank_end(str);
314 ret = ignore_error_type(td, type, p);
324 static int str_rw_cb(void *data, const char *str)
326 struct thread_data *td = data;
327 struct thread_options *o = &td->o;
336 nr = get_opt_postfix(str);
341 o->ddir_seq_nr = atoi(nr);
345 if (str_to_decimal(nr, &val, 1, o, 0, 0)) {
346 log_err("fio: rw postfix parsing failed\n");
351 o->ddir_seq_add = val;
358 static int str_mem_cb(void *data, const char *mem)
360 struct thread_data *td = data;
362 if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP)
363 td->o.mmapfile = get_opt_postfix(mem);
368 static int fio_clock_source_cb(void *data, const char *str)
370 struct thread_data *td = data;
372 fio_clock_source = td->o.clocksource;
373 fio_clock_source_set = 1;
378 static int str_rwmix_read_cb(void *data, unsigned long long *val)
380 struct thread_data *td = data;
382 td->o.rwmix[DDIR_READ] = *val;
383 td->o.rwmix[DDIR_WRITE] = 100 - *val;
387 static int str_rwmix_write_cb(void *data, unsigned long long *val)
389 struct thread_data *td = data;
391 td->o.rwmix[DDIR_WRITE] = *val;
392 td->o.rwmix[DDIR_READ] = 100 - *val;
396 static int str_exitall_cb(void)
398 exitall_on_terminate = 1;
402 #ifdef FIO_HAVE_CPU_AFFINITY
403 int fio_cpus_split(os_cpu_mask_t *mask, unsigned int cpu_index)
405 unsigned int i, index, cpus_in_mask;
406 const long max_cpu = cpus_online();
408 cpus_in_mask = fio_cpu_count(mask);
409 cpu_index = cpu_index % cpus_in_mask;
412 for (i = 0; i < max_cpu; i++) {
413 if (!fio_cpu_isset(mask, i))
416 if (cpu_index != index)
417 fio_cpu_clear(mask, i);
422 return fio_cpu_count(mask);
425 static int str_cpumask_cb(void *data, unsigned long long *val)
427 struct thread_data *td = data;
435 ret = fio_cpuset_init(&td->o.cpumask);
437 log_err("fio: cpuset_init failed\n");
438 td_verror(td, ret, "fio_cpuset_init");
442 max_cpu = cpus_online();
444 for (i = 0; i < sizeof(int) * 8; i++) {
445 if ((1 << i) & *val) {
447 log_err("fio: CPU %d too large (max=%ld)\n", i,
451 dprint(FD_PARSE, "set cpu allowed %d\n", i);
452 fio_cpu_set(&td->o.cpumask, i);
459 static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask,
466 ret = fio_cpuset_init(mask);
468 log_err("fio: cpuset_init failed\n");
469 td_verror(td, ret, "fio_cpuset_init");
473 p = str = strdup(input);
475 strip_blank_front(&str);
476 strip_blank_end(str);
478 max_cpu = cpus_online();
480 while ((cpu = strsep(&str, ",")) != NULL) {
489 while ((cpu2 = strsep(&str2, "-")) != NULL) {
499 while (icpu <= icpu2) {
500 if (icpu >= FIO_MAX_CPUS) {
501 log_err("fio: your OS only supports up to"
502 " %d CPUs\n", (int) FIO_MAX_CPUS);
506 if (icpu > max_cpu) {
507 log_err("fio: CPU %d too large (max=%ld)\n",
513 dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
514 fio_cpu_set(mask, icpu);
525 static int str_cpus_allowed_cb(void *data, const char *input)
527 struct thread_data *td = data;
532 return set_cpus_allowed(td, &td->o.cpumask, input);
535 static int str_verify_cpus_allowed_cb(void *data, const char *input)
537 struct thread_data *td = data;
539 return set_cpus_allowed(td, &td->o.verify_cpumask, input);
543 #ifdef CONFIG_LIBNUMA
544 static int str_numa_cpunodes_cb(void *data, char *input)
546 struct thread_data *td = data;
547 struct bitmask *verify_bitmask;
552 /* numa_parse_nodestring() parses a character string list
553 * of nodes into a bit mask. The bit mask is allocated by
554 * numa_allocate_nodemask(), so it should be freed by
555 * numa_free_nodemask().
557 verify_bitmask = numa_parse_nodestring(input);
558 if (verify_bitmask == NULL) {
559 log_err("fio: numa_parse_nodestring failed\n");
560 td_verror(td, 1, "str_numa_cpunodes_cb");
563 numa_free_nodemask(verify_bitmask);
565 td->o.numa_cpunodes = strdup(input);
569 static int str_numa_mpol_cb(void *data, char *input)
571 struct thread_data *td = data;
572 const char * const policy_types[] =
573 { "default", "prefer", "bind", "interleave", "local", NULL };
576 struct bitmask *verify_bitmask;
581 nodelist = strchr(input, ':');
583 /* NUL-terminate mode */
587 for (i = 0; i <= MPOL_LOCAL; i++) {
588 if (!strcmp(input, policy_types[i])) {
589 td->o.numa_mem_mode = i;
593 if (i > MPOL_LOCAL) {
594 log_err("fio: memory policy should be: default, prefer, bind, interleave, local\n");
598 switch (td->o.numa_mem_mode) {
601 * Insist on a nodelist of one node only
604 char *rest = nodelist;
605 while (isdigit(*rest))
608 log_err("fio: one node only for \'prefer\'\n");
612 log_err("fio: one node is needed for \'prefer\'\n");
616 case MPOL_INTERLEAVE:
618 * Default to online nodes with memory if no nodelist
621 nodelist = strdup("all");
626 * Don't allow a nodelist
629 log_err("fio: NO nodelist for \'local\'\n");
635 * Insist on a nodelist
638 log_err("fio: a nodelist is needed for \'bind\'\n");
645 /* numa_parse_nodestring() parses a character string list
646 * of nodes into a bit mask. The bit mask is allocated by
647 * numa_allocate_nodemask(), so it should be freed by
648 * numa_free_nodemask().
650 switch (td->o.numa_mem_mode) {
652 td->o.numa_mem_prefer_node = atoi(nodelist);
654 case MPOL_INTERLEAVE:
656 verify_bitmask = numa_parse_nodestring(nodelist);
657 if (verify_bitmask == NULL) {
658 log_err("fio: numa_parse_nodestring failed\n");
659 td_verror(td, 1, "str_numa_memnodes_cb");
662 td->o.numa_memnodes = strdup(nodelist);
663 numa_free_nodemask(verify_bitmask);
678 static int str_fst_cb(void *data, const char *str)
680 struct thread_data *td = data;
681 char *nr = get_opt_postfix(str);
683 td->file_service_nr = 1;
685 td->file_service_nr = atoi(nr);
692 #ifdef CONFIG_SYNC_FILE_RANGE
693 static int str_sfr_cb(void *data, const char *str)
695 struct thread_data *td = data;
696 char *nr = get_opt_postfix(str);
698 td->sync_file_range_nr = 1;
700 td->sync_file_range_nr = atoi(nr);
708 static int str_random_distribution_cb(void *data, const char *str)
710 struct thread_data *td = data;
717 if (td->o.random_distribution == FIO_RAND_DIST_ZIPF)
719 else if (td->o.random_distribution == FIO_RAND_DIST_PARETO)
720 val = FIO_DEF_PARETO;
721 else if (td->o.random_distribution == FIO_RAND_DIST_GAUSS)
726 nr = get_opt_postfix(str);
727 if (nr && !str_to_float(nr, &val, 0)) {
728 log_err("fio: random postfix parsing failed\n");
735 if (td->o.random_distribution == FIO_RAND_DIST_ZIPF) {
737 log_err("fio: zipf theta must different than 1.0\n");
740 td->o.zipf_theta.u.f = val;
741 } else if (td->o.random_distribution == FIO_RAND_DIST_PARETO) {
742 if (val <= 0.00 || val >= 1.00) {
743 log_err("fio: pareto input out of range (0 < input < 1.0)\n");
746 td->o.pareto_h.u.f = val;
748 td->o.gauss_dev = val;
754 * Return next name in the string. Files are separated with ':'. If the ':'
755 * is escaped with a '\', then that ':' is part of the filename and does not
756 * indicate a new file.
758 static char *get_next_name(char **ptr)
763 if (!str || !strlen(str))
769 * No colon, we are done
771 p = strchr(str, ':');
778 * We got a colon, but it's the first character. Skip and
786 if (*(p - 1) != '\\') {
792 memmove(p - 1, p, strlen(p) + 1);
800 static int get_max_name_idx(char *input)
802 unsigned int cur_idx;
805 p = str = strdup(input);
806 for (cur_idx = 0; ; cur_idx++)
807 if (get_next_name(&str) == NULL)
815 * Returns the directory at the index, indexes > entires will be
816 * assigned via modulo division of the index
818 int set_name_idx(char *target, char *input, int index)
820 unsigned int cur_idx;
822 char *fname, *str, *p;
824 p = str = strdup(input);
826 index %= get_max_name_idx(input);
827 for (cur_idx = 0; cur_idx <= index; cur_idx++)
828 fname = get_next_name(&str);
830 len = sprintf(target, "%s/", fname);
836 static int str_filename_cb(void *data, const char *input)
838 struct thread_data *td = data;
839 char *fname, *str, *p;
841 p = str = strdup(input);
843 strip_blank_front(&str);
844 strip_blank_end(str);
846 if (!td->files_index)
849 while ((fname = get_next_name(&str)) != NULL) {
852 add_file(td, fname, 0, 1);
859 static int str_directory_cb(void *data, const char fio_unused *unused)
861 struct thread_data *td = data;
863 char *dirname, *str, *p;
869 p = str = strdup(td->o.directory);
870 while ((dirname = get_next_name(&str)) != NULL) {
871 if (lstat(dirname, &sb) < 0) {
874 log_err("fio: %s is not a directory\n", dirname);
875 td_verror(td, ret, "lstat");
878 if (!S_ISDIR(sb.st_mode)) {
879 log_err("fio: %s is not a directory\n", dirname);
890 static int str_opendir_cb(void *data, const char fio_unused *str)
892 struct thread_data *td = data;
897 if (!td->files_index)
900 return add_dir_files(td, td->o.opendir);
903 static int pattern_cb(char *pattern, unsigned int max_size,
904 const char *input, unsigned int *pattern_bytes)
907 int i = 0, j = 0, len, k, base = 10;
908 uint32_t pattern_length;
912 * Check if it's a string input
914 loc1 = strchr(input, '\"');
918 if (*loc1 == '\0' || *loc1 == '\"')
923 } while (i < max_size);
932 * No string, find out if it's decimal or hexidecimal
934 loc1 = strstr(input, "0x");
935 loc2 = strstr(input, "0X");
938 off = strtol(input, NULL, base);
939 if (off != LONG_MAX || errno != ERANGE) {
941 pattern[i] = off & 0xff;
950 j = loc1 - input + 2;
952 j = loc2 - input + 2;
955 if (len - j < max_size * 2) {
957 off = converthexchartoint(input[k--]);
959 off += (converthexchartoint(input[k--])
961 pattern[i++] = (char) off;
967 * Fill the pattern all the way to the end. This greatly reduces
968 * the number of memcpy's we have to do when verifying the IO.
972 while (i > 1 && i * 2 <= max_size) {
973 memcpy(&pattern[i], &pattern[0], i);
978 * Fill remainder, if the pattern multiple ends up not being
981 while (i > 1 && i < max_size) {
982 unsigned int b = min(pattern_length, max_size - i);
984 memcpy(&pattern[i], &pattern[0], b);
990 * The code in verify_io_u_pattern assumes a single byte
991 * pattern fills the whole verify pattern buffer.
993 memset(pattern, pattern[0], max_size);
1000 static int str_buffer_pattern_cb(void *data, const char *input)
1002 struct thread_data *td = data;
1005 ret = pattern_cb(td->o.buffer_pattern, MAX_PATTERN_SIZE, input,
1006 &td->o.buffer_pattern_bytes);
1008 if (!ret && td->o.buffer_pattern_bytes) {
1009 if (!td->o.compress_percentage)
1010 td->o.refill_buffers = 0;
1011 td->o.scramble_buffers = 0;
1012 td->o.zero_buffers = 0;
1014 log_err("fio: failed parsing pattern `%s`\n", input);
1021 static int str_buffer_compress_cb(void *data, unsigned long long *il)
1023 struct thread_data *td = data;
1025 td->flags |= TD_F_COMPRESS;
1026 td->o.compress_percentage = *il;
1030 static int str_dedupe_cb(void *data, unsigned long long *il)
1032 struct thread_data *td = data;
1034 td->flags |= TD_F_COMPRESS;
1035 td->o.dedupe_percentage = *il;
1036 td->o.refill_buffers = 1;
1040 static int str_verify_pattern_cb(void *data, const char *input)
1042 struct thread_data *td = data;
1045 ret = pattern_cb(td->o.verify_pattern, MAX_PATTERN_SIZE, input,
1046 &td->o.verify_pattern_bytes);
1049 * VERIFY_META could already be set
1051 if (!ret && td->o.verify == VERIFY_NONE)
1052 td->o.verify = VERIFY_PATTERN;
1057 static int str_gtod_reduce_cb(void *data, int *il)
1059 struct thread_data *td = data;
1062 td->o.disable_lat = !!val;
1063 td->o.disable_clat = !!val;
1064 td->o.disable_slat = !!val;
1065 td->o.disable_bw = !!val;
1066 td->o.clat_percentiles = !val;
1068 td->tv_cache_mask = 63;
1073 static int str_size_cb(void *data, unsigned long long *__val)
1075 struct thread_data *td = data;
1076 unsigned long long v = *__val;
1078 if (parse_is_percent(v)) {
1080 td->o.size_percent = -1ULL - v;
1087 static int rw_verify(struct fio_option *o, void *data)
1089 struct thread_data *td = data;
1091 if (read_only && td_write(td)) {
1092 log_err("fio: job <%s> has write bit set, but fio is in"
1093 " read-only mode\n", td->o.name);
1100 static int gtod_cpu_verify(struct fio_option *o, void *data)
1102 #ifndef FIO_HAVE_CPU_AFFINITY
1103 struct thread_data *td = data;
1105 if (td->o.gtod_cpu) {
1106 log_err("fio: platform must support CPU affinity for"
1107 "gettimeofday() offloading\n");
1118 static struct opt_group fio_opt_groups[] = {
1121 .mask = FIO_OPT_C_GENERAL,
1125 .mask = FIO_OPT_C_IO,
1129 .mask = FIO_OPT_C_FILE,
1132 .name = "Statistics",
1133 .mask = FIO_OPT_C_STAT,
1137 .mask = FIO_OPT_C_LOG,
1141 .mask = FIO_OPT_C_PROFILE,
1148 static struct opt_group *__opt_group_from_mask(struct opt_group *ogs, unsigned int *mask,
1149 unsigned int inv_mask)
1151 struct opt_group *og;
1154 if (*mask == inv_mask || !*mask)
1157 for (i = 0; ogs[i].name; i++) {
1160 if (*mask & og->mask) {
1161 *mask &= ~(og->mask);
1169 struct opt_group *opt_group_from_mask(unsigned int *mask)
1171 return __opt_group_from_mask(fio_opt_groups, mask, FIO_OPT_C_INVALID);
1174 static struct opt_group fio_opt_cat_groups[] = {
1176 .name = "Latency profiling",
1177 .mask = FIO_OPT_G_LATPROF,
1181 .mask = FIO_OPT_G_RATE,
1185 .mask = FIO_OPT_G_ZONE,
1188 .name = "Read/write mix",
1189 .mask = FIO_OPT_G_RWMIX,
1193 .mask = FIO_OPT_G_VERIFY,
1197 .mask = FIO_OPT_G_TRIM,
1200 .name = "I/O Logging",
1201 .mask = FIO_OPT_G_IOLOG,
1204 .name = "I/O Depth",
1205 .mask = FIO_OPT_G_IO_DEPTH,
1209 .mask = FIO_OPT_G_IO_FLOW,
1212 .name = "Description",
1213 .mask = FIO_OPT_G_DESC,
1217 .mask = FIO_OPT_G_FILENAME,
1220 .name = "General I/O",
1221 .mask = FIO_OPT_G_IO_BASIC,
1225 .mask = FIO_OPT_G_CGROUP,
1229 .mask = FIO_OPT_G_RUNTIME,
1233 .mask = FIO_OPT_G_PROCESS,
1236 .name = "Job credentials / priority",
1237 .mask = FIO_OPT_G_CRED,
1240 .name = "Clock settings",
1241 .mask = FIO_OPT_G_CLOCK,
1245 .mask = FIO_OPT_G_IO_TYPE,
1248 .name = "I/O Thinktime",
1249 .mask = FIO_OPT_G_THINKTIME,
1252 .name = "Randomizations",
1253 .mask = FIO_OPT_G_RANDOM,
1256 .name = "I/O buffers",
1257 .mask = FIO_OPT_G_IO_BUF,
1260 .name = "Tiobench profile",
1261 .mask = FIO_OPT_G_TIOBENCH,
1269 struct opt_group *opt_group_cat_from_mask(unsigned int *mask)
1271 return __opt_group_from_mask(fio_opt_cat_groups, mask, FIO_OPT_G_INVALID);
1275 * Map of job/command line options
1277 struct fio_option fio_options[FIO_MAX_OPTS] = {
1279 .name = "description",
1280 .lname = "Description of job",
1281 .type = FIO_OPT_STR_STORE,
1282 .off1 = td_var_offset(description),
1283 .help = "Text job description",
1284 .category = FIO_OPT_C_GENERAL,
1285 .group = FIO_OPT_G_DESC,
1289 .lname = "Job name",
1290 .type = FIO_OPT_STR_STORE,
1291 .off1 = td_var_offset(name),
1292 .help = "Name of this job",
1293 .category = FIO_OPT_C_GENERAL,
1294 .group = FIO_OPT_G_DESC,
1298 .lname = "Filename(s)",
1299 .type = FIO_OPT_STR_STORE,
1300 .off1 = td_var_offset(filename),
1301 .cb = str_filename_cb,
1302 .prio = -1, /* must come after "directory" */
1303 .help = "File(s) to use for the workload",
1304 .category = FIO_OPT_C_FILE,
1305 .group = FIO_OPT_G_FILENAME,
1308 .name = "directory",
1309 .lname = "Directory",
1310 .type = FIO_OPT_STR_STORE,
1311 .off1 = td_var_offset(directory),
1312 .cb = str_directory_cb,
1313 .help = "Directory to store files in",
1314 .category = FIO_OPT_C_FILE,
1315 .group = FIO_OPT_G_FILENAME,
1318 .name = "filename_format",
1319 .type = FIO_OPT_STR_STORE,
1320 .off1 = td_var_offset(filename_format),
1321 .prio = -1, /* must come after "directory" */
1322 .help = "Override default $jobname.$jobnum.$filenum naming",
1323 .def = "$jobname.$jobnum.$filenum",
1324 .category = FIO_OPT_C_FILE,
1325 .group = FIO_OPT_G_FILENAME,
1329 .lname = "Lockfile",
1330 .type = FIO_OPT_STR,
1331 .off1 = td_var_offset(file_lock_mode),
1332 .help = "Lock file when doing IO to it",
1334 .parent = "filename",
1337 .category = FIO_OPT_C_FILE,
1338 .group = FIO_OPT_G_FILENAME,
1341 .oval = FILE_LOCK_NONE,
1342 .help = "No file locking",
1344 { .ival = "exclusive",
1345 .oval = FILE_LOCK_EXCLUSIVE,
1346 .help = "Exclusive file lock",
1349 .ival = "readwrite",
1350 .oval = FILE_LOCK_READWRITE,
1351 .help = "Read vs write lock",
1357 .lname = "Open directory",
1358 .type = FIO_OPT_STR_STORE,
1359 .off1 = td_var_offset(opendir),
1360 .cb = str_opendir_cb,
1361 .help = "Recursively add files from this directory and down",
1362 .category = FIO_OPT_C_FILE,
1363 .group = FIO_OPT_G_FILENAME,
1367 .lname = "Read/write",
1368 .alias = "readwrite",
1369 .type = FIO_OPT_STR,
1371 .off1 = td_var_offset(td_ddir),
1372 .help = "IO direction",
1374 .verify = rw_verify,
1375 .category = FIO_OPT_C_IO,
1376 .group = FIO_OPT_G_IO_BASIC,
1379 .oval = TD_DDIR_READ,
1380 .help = "Sequential read",
1383 .oval = TD_DDIR_WRITE,
1384 .help = "Sequential write",
1387 .oval = TD_DDIR_TRIM,
1388 .help = "Sequential trim",
1390 { .ival = "randread",
1391 .oval = TD_DDIR_RANDREAD,
1392 .help = "Random read",
1394 { .ival = "randwrite",
1395 .oval = TD_DDIR_RANDWRITE,
1396 .help = "Random write",
1398 { .ival = "randtrim",
1399 .oval = TD_DDIR_RANDTRIM,
1400 .help = "Random trim",
1404 .help = "Sequential read and write mix",
1406 { .ival = "readwrite",
1408 .help = "Sequential read and write mix",
1411 .oval = TD_DDIR_RANDRW,
1412 .help = "Random read and write mix"
1417 .name = "rw_sequencer",
1418 .lname = "RW Sequencer",
1419 .type = FIO_OPT_STR,
1420 .off1 = td_var_offset(rw_seq),
1421 .help = "IO offset generator modifier",
1422 .def = "sequential",
1423 .category = FIO_OPT_C_IO,
1424 .group = FIO_OPT_G_IO_BASIC,
1426 { .ival = "sequential",
1428 .help = "Generate sequential offsets",
1430 { .ival = "identical",
1431 .oval = RW_SEQ_IDENT,
1432 .help = "Generate identical offsets",
1439 .lname = "IO Engine",
1440 .type = FIO_OPT_STR_STORE,
1441 .off1 = td_var_offset(ioengine),
1442 .help = "IO engine to use",
1443 .def = FIO_PREFERRED_ENGINE,
1444 .category = FIO_OPT_C_IO,
1445 .group = FIO_OPT_G_IO_BASIC,
1448 .help = "Use read/write",
1451 .help = "Use pread/pwrite",
1454 .help = "Use readv/writev",
1456 #ifdef CONFIG_PWRITEV
1458 .help = "Use preadv/pwritev",
1461 #ifdef CONFIG_LIBAIO
1463 .help = "Linux native asynchronous IO",
1466 #ifdef CONFIG_POSIXAIO
1467 { .ival = "posixaio",
1468 .help = "POSIX asynchronous IO",
1471 #ifdef CONFIG_SOLARISAIO
1472 { .ival = "solarisaio",
1473 .help = "Solaris native asynchronous IO",
1476 #ifdef CONFIG_WINDOWSAIO
1477 { .ival = "windowsaio",
1478 .help = "Windows native asynchronous IO"
1483 .help = "Rados Block Device asynchronous IO"
1487 .help = "Memory mapped IO"
1489 #ifdef CONFIG_LINUX_SPLICE
1491 .help = "splice/vmsplice based IO",
1493 { .ival = "netsplice",
1494 .help = "splice/vmsplice to/from the network",
1497 #ifdef FIO_HAVE_SGIO
1499 .help = "SCSI generic v3 IO",
1503 .help = "Testing engine (no data transfer)",
1506 .help = "Network IO",
1509 .help = "CPU cycle burner engine",
1513 .help = "GUASI IO engine",
1516 #ifdef FIO_HAVE_BINJECT
1517 { .ival = "binject",
1518 .help = "binject direct inject block engine",
1523 .help = "RDMA IO engine",
1526 #ifdef CONFIG_FUSION_AW
1527 { .ival = "fusion-aw-sync",
1528 .help = "Fusion-io atomic write engine",
1531 #ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
1532 { .ival = "e4defrag",
1533 .help = "ext4 defrag engine",
1536 #ifdef CONFIG_LINUX_FALLOCATE
1538 .help = "fallocate() file based engine",
1543 .help = "Glusterfs libgfapi(sync) based engine"
1545 { .ival = "gfapi_async",
1546 .help = "Glusterfs libgfapi(async) based engine"
1549 #ifdef CONFIG_LIBHDFS
1550 { .ival = "libhdfs",
1551 .help = "Hadoop Distributed Filesystem (HDFS) engine"
1554 { .ival = "external",
1555 .help = "Load external engine (append name)",
1561 .lname = "IO Depth",
1562 .type = FIO_OPT_INT,
1563 .off1 = td_var_offset(iodepth),
1564 .help = "Number of IO buffers to keep in flight",
1568 .category = FIO_OPT_C_IO,
1569 .group = FIO_OPT_G_IO_BASIC,
1572 .name = "iodepth_batch",
1573 .lname = "IO Depth batch",
1574 .alias = "iodepth_batch_submit",
1575 .type = FIO_OPT_INT,
1576 .off1 = td_var_offset(iodepth_batch),
1577 .help = "Number of IO buffers to submit in one go",
1578 .parent = "iodepth",
1583 .category = FIO_OPT_C_IO,
1584 .group = FIO_OPT_G_IO_BASIC,
1587 .name = "iodepth_batch_complete",
1588 .lname = "IO Depth batch complete",
1589 .type = FIO_OPT_INT,
1590 .off1 = td_var_offset(iodepth_batch_complete),
1591 .help = "Number of IO buffers to retrieve in one go",
1592 .parent = "iodepth",
1597 .category = FIO_OPT_C_IO,
1598 .group = FIO_OPT_G_IO_BASIC,
1601 .name = "iodepth_low",
1602 .lname = "IO Depth batch low",
1603 .type = FIO_OPT_INT,
1604 .off1 = td_var_offset(iodepth_low),
1605 .help = "Low water mark for queuing depth",
1606 .parent = "iodepth",
1609 .category = FIO_OPT_C_IO,
1610 .group = FIO_OPT_G_IO_BASIC,
1615 .type = FIO_OPT_STR_VAL,
1617 .off1 = td_var_offset(size),
1618 .help = "Total size of device or files",
1619 .interval = 1024 * 1024,
1620 .category = FIO_OPT_C_IO,
1621 .group = FIO_OPT_G_INVALID,
1625 .alias = "io_limit",
1627 .type = FIO_OPT_STR_VAL,
1628 .off1 = td_var_offset(io_limit),
1629 .interval = 1024 * 1024,
1630 .category = FIO_OPT_C_IO,
1631 .group = FIO_OPT_G_INVALID,
1634 .name = "fill_device",
1635 .lname = "Fill device",
1637 .type = FIO_OPT_BOOL,
1638 .off1 = td_var_offset(fill_device),
1639 .help = "Write until an ENOSPC error occurs",
1641 .category = FIO_OPT_C_FILE,
1642 .group = FIO_OPT_G_INVALID,
1646 .lname = "File size",
1647 .type = FIO_OPT_STR_VAL,
1648 .off1 = td_var_offset(file_size_low),
1649 .off2 = td_var_offset(file_size_high),
1651 .help = "Size of individual files",
1652 .interval = 1024 * 1024,
1653 .category = FIO_OPT_C_FILE,
1654 .group = FIO_OPT_G_INVALID,
1657 .name = "file_append",
1658 .lname = "File append",
1659 .type = FIO_OPT_BOOL,
1660 .off1 = td_var_offset(file_append),
1661 .help = "IO will start at the end of the file(s)",
1663 .category = FIO_OPT_C_FILE,
1664 .group = FIO_OPT_G_INVALID,
1668 .lname = "IO offset",
1669 .alias = "fileoffset",
1670 .type = FIO_OPT_STR_VAL,
1671 .off1 = td_var_offset(start_offset),
1672 .help = "Start IO from this offset",
1674 .interval = 1024 * 1024,
1675 .category = FIO_OPT_C_IO,
1676 .group = FIO_OPT_G_INVALID,
1679 .name = "offset_increment",
1680 .lname = "IO offset increment",
1681 .type = FIO_OPT_STR_VAL,
1682 .off1 = td_var_offset(offset_increment),
1683 .help = "What is the increment from one offset to the next",
1687 .interval = 1024 * 1024,
1688 .category = FIO_OPT_C_IO,
1689 .group = FIO_OPT_G_INVALID,
1692 .name = "number_ios",
1693 .lname = "Number of IOs to perform",
1694 .type = FIO_OPT_STR_VAL,
1695 .off1 = td_var_offset(number_ios),
1696 .help = "Force job completion after this number of IOs",
1698 .category = FIO_OPT_C_IO,
1699 .group = FIO_OPT_G_INVALID,
1703 .lname = "Block size",
1704 .alias = "blocksize",
1705 .type = FIO_OPT_INT,
1706 .off1 = td_var_offset(bs[DDIR_READ]),
1707 .off2 = td_var_offset(bs[DDIR_WRITE]),
1708 .off3 = td_var_offset(bs[DDIR_TRIM]),
1710 .help = "Block size unit",
1715 .category = FIO_OPT_C_IO,
1716 .group = FIO_OPT_G_INVALID,
1720 .lname = "Block size align",
1721 .alias = "blockalign",
1722 .type = FIO_OPT_INT,
1723 .off1 = td_var_offset(ba[DDIR_READ]),
1724 .off2 = td_var_offset(ba[DDIR_WRITE]),
1725 .off3 = td_var_offset(ba[DDIR_TRIM]),
1727 .help = "IO block offset alignment",
1731 .category = FIO_OPT_C_IO,
1732 .group = FIO_OPT_G_INVALID,
1736 .lname = "Block size range",
1737 .alias = "blocksize_range",
1738 .type = FIO_OPT_RANGE,
1739 .off1 = td_var_offset(min_bs[DDIR_READ]),
1740 .off2 = td_var_offset(max_bs[DDIR_READ]),
1741 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
1742 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
1743 .off5 = td_var_offset(min_bs[DDIR_TRIM]),
1744 .off6 = td_var_offset(max_bs[DDIR_TRIM]),
1746 .help = "Set block size range (in more detail than bs)",
1750 .category = FIO_OPT_C_IO,
1751 .group = FIO_OPT_G_INVALID,
1755 .lname = "Block size split",
1756 .type = FIO_OPT_STR,
1757 .cb = str_bssplit_cb,
1758 .off1 = td_var_offset(bssplit),
1759 .help = "Set a specific mix of block sizes",
1762 .category = FIO_OPT_C_IO,
1763 .group = FIO_OPT_G_INVALID,
1766 .name = "bs_unaligned",
1767 .lname = "Block size unaligned",
1768 .alias = "blocksize_unaligned",
1769 .type = FIO_OPT_STR_SET,
1770 .off1 = td_var_offset(bs_unaligned),
1771 .help = "Don't sector align IO buffer sizes",
1774 .category = FIO_OPT_C_IO,
1775 .group = FIO_OPT_G_INVALID,
1778 .name = "bs_is_seq_rand",
1779 .lname = "Block size division is seq/random (not read/write)",
1780 .type = FIO_OPT_BOOL,
1781 .off1 = td_var_offset(bs_is_seq_rand),
1782 .help = "Consider any blocksize setting to be sequential,random",
1784 .parent = "blocksize",
1785 .category = FIO_OPT_C_IO,
1786 .group = FIO_OPT_G_INVALID,
1789 .name = "randrepeat",
1790 .lname = "Random repeatable",
1791 .type = FIO_OPT_BOOL,
1792 .off1 = td_var_offset(rand_repeatable),
1793 .help = "Use repeatable random IO pattern",
1797 .category = FIO_OPT_C_IO,
1798 .group = FIO_OPT_G_RANDOM,
1802 .lname = "The random generator seed",
1803 .type = FIO_OPT_STR_VAL,
1804 .off1 = td_var_offset(rand_seed),
1805 .help = "Set the random generator seed value",
1807 .category = FIO_OPT_C_IO,
1808 .group = FIO_OPT_G_RANDOM,
1811 .name = "use_os_rand",
1812 .lname = "Use OS random",
1813 .type = FIO_OPT_DEPRECATED,
1814 .off1 = td_var_offset(dep_use_os_rand),
1815 .category = FIO_OPT_C_IO,
1816 .group = FIO_OPT_G_RANDOM,
1819 .name = "norandommap",
1820 .lname = "No randommap",
1821 .type = FIO_OPT_STR_SET,
1822 .off1 = td_var_offset(norandommap),
1823 .help = "Accept potential duplicate random blocks",
1827 .category = FIO_OPT_C_IO,
1828 .group = FIO_OPT_G_RANDOM,
1831 .name = "softrandommap",
1832 .lname = "Soft randommap",
1833 .type = FIO_OPT_BOOL,
1834 .off1 = td_var_offset(softrandommap),
1835 .help = "Set norandommap if randommap allocation fails",
1836 .parent = "norandommap",
1839 .category = FIO_OPT_C_IO,
1840 .group = FIO_OPT_G_RANDOM,
1843 .name = "random_generator",
1844 .type = FIO_OPT_STR,
1845 .off1 = td_var_offset(random_generator),
1846 .help = "Type of random number generator to use",
1847 .def = "tausworthe",
1849 { .ival = "tausworthe",
1850 .oval = FIO_RAND_GEN_TAUSWORTHE,
1851 .help = "Strong Tausworthe generator",
1854 .oval = FIO_RAND_GEN_LFSR,
1855 .help = "Variable length LFSR",
1858 .category = FIO_OPT_C_IO,
1859 .group = FIO_OPT_G_RANDOM,
1862 .name = "random_distribution",
1863 .type = FIO_OPT_STR,
1864 .off1 = td_var_offset(random_distribution),
1865 .cb = str_random_distribution_cb,
1866 .help = "Random offset distribution generator",
1870 .oval = FIO_RAND_DIST_RANDOM,
1871 .help = "Completely random",
1874 .oval = FIO_RAND_DIST_ZIPF,
1875 .help = "Zipf distribution",
1878 .oval = FIO_RAND_DIST_PARETO,
1879 .help = "Pareto distribution",
1882 .oval = FIO_RAND_DIST_GAUSS,
1883 .help = "Normal (gaussian) distribution",
1886 .category = FIO_OPT_C_IO,
1887 .group = FIO_OPT_G_RANDOM,
1890 .name = "percentage_random",
1891 .lname = "Percentage Random",
1892 .type = FIO_OPT_INT,
1893 .off1 = td_var_offset(perc_rand[DDIR_READ]),
1894 .off2 = td_var_offset(perc_rand[DDIR_WRITE]),
1895 .off3 = td_var_offset(perc_rand[DDIR_TRIM]),
1897 .help = "Percentage of seq/random mix that should be random",
1898 .def = "100,100,100",
1900 .inverse = "percentage_sequential",
1901 .category = FIO_OPT_C_IO,
1902 .group = FIO_OPT_G_RANDOM,
1905 .name = "percentage_sequential",
1906 .lname = "Percentage Sequential",
1907 .type = FIO_OPT_DEPRECATED,
1908 .category = FIO_OPT_C_IO,
1909 .group = FIO_OPT_G_RANDOM,
1912 .name = "allrandrepeat",
1913 .type = FIO_OPT_BOOL,
1914 .off1 = td_var_offset(allrand_repeatable),
1915 .help = "Use repeatable random numbers for everything",
1917 .category = FIO_OPT_C_IO,
1918 .group = FIO_OPT_G_RANDOM,
1922 .lname = "Number of files",
1923 .alias = "nr_files",
1924 .type = FIO_OPT_INT,
1925 .off1 = td_var_offset(nr_files),
1926 .help = "Split job workload between this number of files",
1929 .category = FIO_OPT_C_FILE,
1930 .group = FIO_OPT_G_INVALID,
1933 .name = "openfiles",
1934 .lname = "Number of open files",
1935 .type = FIO_OPT_INT,
1936 .off1 = td_var_offset(open_files),
1937 .help = "Number of files to keep open at the same time",
1938 .category = FIO_OPT_C_FILE,
1939 .group = FIO_OPT_G_INVALID,
1942 .name = "file_service_type",
1943 .lname = "File service type",
1944 .type = FIO_OPT_STR,
1946 .off1 = td_var_offset(file_service_type),
1947 .help = "How to select which file to service next",
1948 .def = "roundrobin",
1949 .category = FIO_OPT_C_FILE,
1950 .group = FIO_OPT_G_INVALID,
1953 .oval = FIO_FSERVICE_RANDOM,
1954 .help = "Choose a file at random",
1956 { .ival = "roundrobin",
1957 .oval = FIO_FSERVICE_RR,
1958 .help = "Round robin select files",
1960 { .ival = "sequential",
1961 .oval = FIO_FSERVICE_SEQ,
1962 .help = "Finish one file before moving to the next",
1965 .parent = "nrfiles",
1968 #ifdef CONFIG_POSIX_FALLOCATE
1970 .name = "fallocate",
1971 .lname = "Fallocate",
1972 .type = FIO_OPT_STR,
1973 .off1 = td_var_offset(fallocate_mode),
1974 .help = "Whether pre-allocation is performed when laying out files",
1976 .category = FIO_OPT_C_FILE,
1977 .group = FIO_OPT_G_INVALID,
1980 .oval = FIO_FALLOCATE_NONE,
1981 .help = "Do not pre-allocate space",
1984 .oval = FIO_FALLOCATE_POSIX,
1985 .help = "Use posix_fallocate()",
1987 #ifdef CONFIG_LINUX_FALLOCATE
1989 .oval = FIO_FALLOCATE_KEEP_SIZE,
1990 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
1993 /* Compatibility with former boolean values */
1995 .oval = FIO_FALLOCATE_NONE,
1996 .help = "Alias for 'none'",
1999 .oval = FIO_FALLOCATE_POSIX,
2000 .help = "Alias for 'posix'",
2004 #endif /* CONFIG_POSIX_FALLOCATE */
2006 .name = "fadvise_hint",
2007 .lname = "Fadvise hint",
2008 .type = FIO_OPT_BOOL,
2009 .off1 = td_var_offset(fadvise_hint),
2010 .help = "Use fadvise() to advise the kernel on IO pattern",
2012 .category = FIO_OPT_C_FILE,
2013 .group = FIO_OPT_G_INVALID,
2015 #ifdef FIO_HAVE_STREAMID
2017 .name = "fadvise_stream",
2018 .lname = "Fadvise stream",
2019 .type = FIO_OPT_INT,
2020 .off1 = td_var_offset(fadvise_stream),
2021 .help = "Use fadvise() to set stream ID",
2022 .category = FIO_OPT_C_FILE,
2023 .group = FIO_OPT_G_INVALID,
2029 .type = FIO_OPT_INT,
2030 .off1 = td_var_offset(fsync_blocks),
2031 .help = "Issue fsync for writes every given number of blocks",
2034 .category = FIO_OPT_C_FILE,
2035 .group = FIO_OPT_G_INVALID,
2038 .name = "fdatasync",
2039 .lname = "Fdatasync",
2040 .type = FIO_OPT_INT,
2041 .off1 = td_var_offset(fdatasync_blocks),
2042 .help = "Issue fdatasync for writes every given number of blocks",
2045 .category = FIO_OPT_C_FILE,
2046 .group = FIO_OPT_G_INVALID,
2049 .name = "write_barrier",
2050 .lname = "Write barrier",
2051 .type = FIO_OPT_INT,
2052 .off1 = td_var_offset(barrier_blocks),
2053 .help = "Make every Nth write a barrier write",
2056 .category = FIO_OPT_C_IO,
2057 .group = FIO_OPT_G_INVALID,
2059 #ifdef CONFIG_SYNC_FILE_RANGE
2061 .name = "sync_file_range",
2062 .lname = "Sync file range",
2064 { .ival = "wait_before",
2065 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
2066 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
2070 .oval = SYNC_FILE_RANGE_WRITE,
2071 .help = "SYNC_FILE_RANGE_WRITE",
2075 .ival = "wait_after",
2076 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
2077 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
2081 .type = FIO_OPT_STR_MULTI,
2083 .off1 = td_var_offset(sync_file_range),
2084 .help = "Use sync_file_range()",
2085 .category = FIO_OPT_C_FILE,
2086 .group = FIO_OPT_G_INVALID,
2091 .lname = "Direct I/O",
2092 .type = FIO_OPT_BOOL,
2093 .off1 = td_var_offset(odirect),
2094 .help = "Use O_DIRECT IO (negates buffered)",
2096 .inverse = "buffered",
2097 .category = FIO_OPT_C_IO,
2098 .group = FIO_OPT_G_IO_TYPE,
2102 .lname = "Atomic I/O",
2103 .type = FIO_OPT_BOOL,
2104 .off1 = td_var_offset(oatomic),
2105 .help = "Use Atomic IO with O_DIRECT (implies O_DIRECT)",
2107 .category = FIO_OPT_C_IO,
2108 .group = FIO_OPT_G_IO_TYPE,
2112 .lname = "Buffered I/O",
2113 .type = FIO_OPT_BOOL,
2114 .off1 = td_var_offset(odirect),
2116 .help = "Use buffered IO (negates direct)",
2118 .inverse = "direct",
2119 .category = FIO_OPT_C_IO,
2120 .group = FIO_OPT_G_IO_TYPE,
2123 .name = "overwrite",
2124 .lname = "Overwrite",
2125 .type = FIO_OPT_BOOL,
2126 .off1 = td_var_offset(overwrite),
2127 .help = "When writing, set whether to overwrite current data",
2129 .category = FIO_OPT_C_FILE,
2130 .group = FIO_OPT_G_INVALID,
2135 .type = FIO_OPT_INT,
2136 .off1 = td_var_offset(loops),
2137 .help = "Number of times to run the job",
2140 .category = FIO_OPT_C_GENERAL,
2141 .group = FIO_OPT_G_RUNTIME,
2145 .lname = "Number of jobs",
2146 .type = FIO_OPT_INT,
2147 .off1 = td_var_offset(numjobs),
2148 .help = "Duplicate this job this many times",
2151 .category = FIO_OPT_C_GENERAL,
2152 .group = FIO_OPT_G_RUNTIME,
2155 .name = "startdelay",
2156 .lname = "Start delay",
2157 .type = FIO_OPT_STR_VAL_TIME,
2158 .off1 = td_var_offset(start_delay),
2159 .off2 = td_var_offset(start_delay_high),
2160 .help = "Only start job when this period has passed",
2164 .category = FIO_OPT_C_GENERAL,
2165 .group = FIO_OPT_G_RUNTIME,
2171 .type = FIO_OPT_STR_VAL_TIME,
2172 .off1 = td_var_offset(timeout),
2173 .help = "Stop workload when this amount of time has passed",
2177 .category = FIO_OPT_C_GENERAL,
2178 .group = FIO_OPT_G_RUNTIME,
2181 .name = "time_based",
2182 .lname = "Time based",
2183 .type = FIO_OPT_STR_SET,
2184 .off1 = td_var_offset(time_based),
2185 .help = "Keep running until runtime/timeout is met",
2186 .category = FIO_OPT_C_GENERAL,
2187 .group = FIO_OPT_G_RUNTIME,
2190 .name = "verify_only",
2191 .lname = "Verify only",
2192 .type = FIO_OPT_STR_SET,
2193 .off1 = td_var_offset(verify_only),
2194 .help = "Verifies previously written data is still valid",
2195 .category = FIO_OPT_C_GENERAL,
2196 .group = FIO_OPT_G_RUNTIME,
2199 .name = "ramp_time",
2200 .lname = "Ramp time",
2201 .type = FIO_OPT_STR_VAL_TIME,
2202 .off1 = td_var_offset(ramp_time),
2203 .help = "Ramp up time before measuring performance",
2206 .category = FIO_OPT_C_GENERAL,
2207 .group = FIO_OPT_G_RUNTIME,
2210 .name = "clocksource",
2211 .lname = "Clock source",
2212 .type = FIO_OPT_STR,
2213 .cb = fio_clock_source_cb,
2214 .off1 = td_var_offset(clocksource),
2215 .help = "What type of timing source to use",
2216 .category = FIO_OPT_C_GENERAL,
2217 .group = FIO_OPT_G_CLOCK,
2219 #ifdef CONFIG_GETTIMEOFDAY
2220 { .ival = "gettimeofday",
2222 .help = "Use gettimeofday(2) for timing",
2225 #ifdef CONFIG_CLOCK_GETTIME
2226 { .ival = "clock_gettime",
2227 .oval = CS_CGETTIME,
2228 .help = "Use clock_gettime(2) for timing",
2231 #ifdef ARCH_HAVE_CPU_CLOCK
2233 .oval = CS_CPUCLOCK,
2234 .help = "Use CPU private clock",
2242 .lname = "I/O Memory",
2243 .type = FIO_OPT_STR,
2245 .off1 = td_var_offset(mem_type),
2246 .help = "Backing type for IO buffers",
2248 .category = FIO_OPT_C_IO,
2249 .group = FIO_OPT_G_INVALID,
2253 .help = "Use malloc(3) for IO buffers",
2255 #ifndef CONFIG_NO_SHM
2258 .help = "Use shared memory segments for IO buffers",
2260 #ifdef FIO_HAVE_HUGETLB
2261 { .ival = "shmhuge",
2262 .oval = MEM_SHMHUGE,
2263 .help = "Like shm, but use huge pages",
2269 .help = "Use mmap(2) (file or anon) for IO buffers",
2271 #ifdef FIO_HAVE_HUGETLB
2272 { .ival = "mmaphuge",
2273 .oval = MEM_MMAPHUGE,
2274 .help = "Like mmap, but use huge pages",
2280 .name = "iomem_align",
2281 .alias = "mem_align",
2282 .lname = "I/O memory alignment",
2283 .type = FIO_OPT_INT,
2284 .off1 = td_var_offset(mem_align),
2286 .help = "IO memory buffer offset alignment",
2290 .category = FIO_OPT_C_IO,
2291 .group = FIO_OPT_G_INVALID,
2296 .type = FIO_OPT_STR,
2297 .off1 = td_var_offset(verify),
2298 .help = "Verify data written",
2300 .category = FIO_OPT_C_IO,
2301 .group = FIO_OPT_G_VERIFY,
2304 .oval = VERIFY_NONE,
2305 .help = "Don't do IO verification",
2309 .help = "Use md5 checksums for verification",
2312 .oval = VERIFY_CRC64,
2313 .help = "Use crc64 checksums for verification",
2316 .oval = VERIFY_CRC32,
2317 .help = "Use crc32 checksums for verification",
2319 { .ival = "crc32c-intel",
2320 .oval = VERIFY_CRC32C,
2321 .help = "Use crc32c checksums for verification (hw assisted, if available)",
2324 .oval = VERIFY_CRC32C,
2325 .help = "Use crc32c checksums for verification (hw assisted, if available)",
2328 .oval = VERIFY_CRC16,
2329 .help = "Use crc16 checksums for verification",
2332 .oval = VERIFY_CRC7,
2333 .help = "Use crc7 checksums for verification",
2336 .oval = VERIFY_SHA1,
2337 .help = "Use sha1 checksums for verification",
2340 .oval = VERIFY_SHA256,
2341 .help = "Use sha256 checksums for verification",
2344 .oval = VERIFY_SHA512,
2345 .help = "Use sha512 checksums for verification",
2348 .oval = VERIFY_XXHASH,
2349 .help = "Use xxhash checksums for verification",
2352 .oval = VERIFY_META,
2353 .help = "Use io information",
2357 .oval = VERIFY_NULL,
2358 .help = "Pretend to verify",
2363 .name = "do_verify",
2364 .lname = "Perform verify step",
2365 .type = FIO_OPT_BOOL,
2366 .off1 = td_var_offset(do_verify),
2367 .help = "Run verification stage after write",
2371 .category = FIO_OPT_C_IO,
2372 .group = FIO_OPT_G_VERIFY,
2375 .name = "verifysort",
2376 .lname = "Verify sort",
2377 .type = FIO_OPT_BOOL,
2378 .off1 = td_var_offset(verifysort),
2379 .help = "Sort written verify blocks for read back",
2383 .category = FIO_OPT_C_IO,
2384 .group = FIO_OPT_G_VERIFY,
2387 .name = "verifysort_nr",
2388 .type = FIO_OPT_INT,
2389 .off1 = td_var_offset(verifysort_nr),
2390 .help = "Pre-load and sort verify blocks for a read workload",
2395 .category = FIO_OPT_C_IO,
2396 .group = FIO_OPT_G_VERIFY,
2399 .name = "verify_interval",
2400 .lname = "Verify interval",
2401 .type = FIO_OPT_INT,
2402 .off1 = td_var_offset(verify_interval),
2403 .minval = 2 * sizeof(struct verify_header),
2404 .help = "Store verify buffer header every N bytes",
2407 .interval = 2 * sizeof(struct verify_header),
2408 .category = FIO_OPT_C_IO,
2409 .group = FIO_OPT_G_VERIFY,
2412 .name = "verify_offset",
2413 .lname = "Verify offset",
2414 .type = FIO_OPT_INT,
2415 .help = "Offset verify header location by N bytes",
2416 .off1 = td_var_offset(verify_offset),
2417 .minval = sizeof(struct verify_header),
2420 .category = FIO_OPT_C_IO,
2421 .group = FIO_OPT_G_VERIFY,
2424 .name = "verify_pattern",
2425 .lname = "Verify pattern",
2426 .type = FIO_OPT_STR,
2427 .cb = str_verify_pattern_cb,
2428 .off1 = td_var_offset(verify_pattern),
2429 .help = "Fill pattern for IO buffers",
2432 .category = FIO_OPT_C_IO,
2433 .group = FIO_OPT_G_VERIFY,
2436 .name = "verify_fatal",
2437 .lname = "Verify fatal",
2438 .type = FIO_OPT_BOOL,
2439 .off1 = td_var_offset(verify_fatal),
2441 .help = "Exit on a single verify failure, don't continue",
2444 .category = FIO_OPT_C_IO,
2445 .group = FIO_OPT_G_VERIFY,
2448 .name = "verify_dump",
2449 .lname = "Verify dump",
2450 .type = FIO_OPT_BOOL,
2451 .off1 = td_var_offset(verify_dump),
2453 .help = "Dump contents of good and bad blocks on failure",
2456 .category = FIO_OPT_C_IO,
2457 .group = FIO_OPT_G_VERIFY,
2460 .name = "verify_async",
2461 .lname = "Verify asynchronously",
2462 .type = FIO_OPT_INT,
2463 .off1 = td_var_offset(verify_async),
2465 .help = "Number of async verifier threads to use",
2468 .category = FIO_OPT_C_IO,
2469 .group = FIO_OPT_G_VERIFY,
2472 .name = "verify_backlog",
2473 .lname = "Verify backlog",
2474 .type = FIO_OPT_STR_VAL,
2475 .off1 = td_var_offset(verify_backlog),
2476 .help = "Verify after this number of blocks are written",
2479 .category = FIO_OPT_C_IO,
2480 .group = FIO_OPT_G_VERIFY,
2483 .name = "verify_backlog_batch",
2484 .lname = "Verify backlog batch",
2485 .type = FIO_OPT_INT,
2486 .off1 = td_var_offset(verify_batch),
2487 .help = "Verify this number of IO blocks",
2490 .category = FIO_OPT_C_IO,
2491 .group = FIO_OPT_G_VERIFY,
2493 #ifdef FIO_HAVE_CPU_AFFINITY
2495 .name = "verify_async_cpus",
2496 .lname = "Async verify CPUs",
2497 .type = FIO_OPT_STR,
2498 .cb = str_verify_cpus_allowed_cb,
2499 .off1 = td_var_offset(verify_cpumask),
2500 .help = "Set CPUs allowed for async verify threads",
2501 .parent = "verify_async",
2503 .category = FIO_OPT_C_IO,
2504 .group = FIO_OPT_G_VERIFY,
2508 .name = "experimental_verify",
2509 .off1 = td_var_offset(experimental_verify),
2510 .type = FIO_OPT_BOOL,
2511 .help = "Enable experimental verification",
2513 .category = FIO_OPT_C_IO,
2514 .group = FIO_OPT_G_VERIFY,
2517 .name = "verify_state_load",
2518 .lname = "Load verify state",
2519 .off1 = td_var_offset(verify_state),
2520 .type = FIO_OPT_BOOL,
2521 .help = "Load verify termination state",
2523 .category = FIO_OPT_C_IO,
2524 .group = FIO_OPT_G_VERIFY,
2527 .name = "verify_state_save",
2528 .lname = "Save verify state",
2529 .off1 = td_var_offset(verify_state_save),
2530 .type = FIO_OPT_BOOL,
2532 .help = "Save verify state on termination",
2534 .category = FIO_OPT_C_IO,
2535 .group = FIO_OPT_G_VERIFY,
2537 #ifdef FIO_HAVE_TRIM
2539 .name = "trim_percentage",
2540 .lname = "Trim percentage",
2541 .type = FIO_OPT_INT,
2542 .off1 = td_var_offset(trim_percentage),
2545 .help = "Number of verify blocks to discard/trim",
2550 .category = FIO_OPT_C_IO,
2551 .group = FIO_OPT_G_TRIM,
2554 .name = "trim_verify_zero",
2555 .lname = "Verify trim zero",
2556 .type = FIO_OPT_BOOL,
2557 .help = "Verify that trim/discarded blocks are returned as zeroes",
2558 .off1 = td_var_offset(trim_zero),
2559 .parent = "trim_percentage",
2562 .category = FIO_OPT_C_IO,
2563 .group = FIO_OPT_G_TRIM,
2566 .name = "trim_backlog",
2567 .lname = "Trim backlog",
2568 .type = FIO_OPT_STR_VAL,
2569 .off1 = td_var_offset(trim_backlog),
2570 .help = "Trim after this number of blocks are written",
2571 .parent = "trim_percentage",
2574 .category = FIO_OPT_C_IO,
2575 .group = FIO_OPT_G_TRIM,
2578 .name = "trim_backlog_batch",
2579 .lname = "Trim backlog batch",
2580 .type = FIO_OPT_INT,
2581 .off1 = td_var_offset(trim_batch),
2582 .help = "Trim this number of IO blocks",
2583 .parent = "trim_percentage",
2586 .category = FIO_OPT_C_IO,
2587 .group = FIO_OPT_G_TRIM,
2591 .name = "write_iolog",
2592 .lname = "Write I/O log",
2593 .type = FIO_OPT_STR_STORE,
2594 .off1 = td_var_offset(write_iolog_file),
2595 .help = "Store IO pattern to file",
2596 .category = FIO_OPT_C_IO,
2597 .group = FIO_OPT_G_IOLOG,
2600 .name = "read_iolog",
2601 .lname = "Read I/O log",
2602 .type = FIO_OPT_STR_STORE,
2603 .off1 = td_var_offset(read_iolog_file),
2604 .help = "Playback IO pattern from file",
2605 .category = FIO_OPT_C_IO,
2606 .group = FIO_OPT_G_IOLOG,
2609 .name = "replay_no_stall",
2610 .lname = "Don't stall on replay",
2611 .type = FIO_OPT_BOOL,
2612 .off1 = td_var_offset(no_stall),
2614 .parent = "read_iolog",
2616 .help = "Playback IO pattern file as fast as possible without stalls",
2617 .category = FIO_OPT_C_IO,
2618 .group = FIO_OPT_G_IOLOG,
2621 .name = "replay_redirect",
2622 .lname = "Redirect device for replay",
2623 .type = FIO_OPT_STR_STORE,
2624 .off1 = td_var_offset(replay_redirect),
2625 .parent = "read_iolog",
2627 .help = "Replay all I/O onto this device, regardless of trace device",
2628 .category = FIO_OPT_C_IO,
2629 .group = FIO_OPT_G_IOLOG,
2632 .name = "exec_prerun",
2633 .lname = "Pre-execute runnable",
2634 .type = FIO_OPT_STR_STORE,
2635 .off1 = td_var_offset(exec_prerun),
2636 .help = "Execute this file prior to running job",
2637 .category = FIO_OPT_C_GENERAL,
2638 .group = FIO_OPT_G_INVALID,
2641 .name = "exec_postrun",
2642 .lname = "Post-execute runnable",
2643 .type = FIO_OPT_STR_STORE,
2644 .off1 = td_var_offset(exec_postrun),
2645 .help = "Execute this file after running job",
2646 .category = FIO_OPT_C_GENERAL,
2647 .group = FIO_OPT_G_INVALID,
2649 #ifdef FIO_HAVE_IOSCHED_SWITCH
2651 .name = "ioscheduler",
2652 .lname = "I/O scheduler",
2653 .type = FIO_OPT_STR_STORE,
2654 .off1 = td_var_offset(ioscheduler),
2655 .help = "Use this IO scheduler on the backing device",
2656 .category = FIO_OPT_C_FILE,
2657 .group = FIO_OPT_G_INVALID,
2662 .lname = "Zone size",
2663 .type = FIO_OPT_STR_VAL,
2664 .off1 = td_var_offset(zone_size),
2665 .help = "Amount of data to read per zone",
2667 .interval = 1024 * 1024,
2668 .category = FIO_OPT_C_IO,
2669 .group = FIO_OPT_G_ZONE,
2672 .name = "zonerange",
2673 .lname = "Zone range",
2674 .type = FIO_OPT_STR_VAL,
2675 .off1 = td_var_offset(zone_range),
2676 .help = "Give size of an IO zone",
2678 .interval = 1024 * 1024,
2679 .category = FIO_OPT_C_IO,
2680 .group = FIO_OPT_G_ZONE,
2684 .lname = "Zone skip",
2685 .type = FIO_OPT_STR_VAL,
2686 .off1 = td_var_offset(zone_skip),
2687 .help = "Space between IO zones",
2689 .interval = 1024 * 1024,
2690 .category = FIO_OPT_C_IO,
2691 .group = FIO_OPT_G_ZONE,
2695 .lname = "Lock memory",
2696 .type = FIO_OPT_STR_VAL,
2697 .off1 = td_var_offset(lockmem),
2698 .help = "Lock down this amount of memory (per worker)",
2700 .interval = 1024 * 1024,
2701 .category = FIO_OPT_C_GENERAL,
2702 .group = FIO_OPT_G_INVALID,
2705 .name = "rwmixread",
2706 .lname = "Read/write mix read",
2707 .type = FIO_OPT_INT,
2708 .cb = str_rwmix_read_cb,
2709 .off1 = td_var_offset(rwmix[DDIR_READ]),
2711 .help = "Percentage of mixed workload that is reads",
2714 .inverse = "rwmixwrite",
2715 .category = FIO_OPT_C_IO,
2716 .group = FIO_OPT_G_RWMIX,
2719 .name = "rwmixwrite",
2720 .lname = "Read/write mix write",
2721 .type = FIO_OPT_INT,
2722 .cb = str_rwmix_write_cb,
2723 .off1 = td_var_offset(rwmix[DDIR_WRITE]),
2725 .help = "Percentage of mixed workload that is writes",
2728 .inverse = "rwmixread",
2729 .category = FIO_OPT_C_IO,
2730 .group = FIO_OPT_G_RWMIX,
2733 .name = "rwmixcycle",
2734 .lname = "Read/write mix cycle",
2735 .type = FIO_OPT_DEPRECATED,
2736 .category = FIO_OPT_C_IO,
2737 .group = FIO_OPT_G_RWMIX,
2742 .type = FIO_OPT_INT,
2743 .off1 = td_var_offset(nice),
2744 .help = "Set job CPU nice value",
2749 .category = FIO_OPT_C_GENERAL,
2750 .group = FIO_OPT_G_CRED,
2752 #ifdef FIO_HAVE_IOPRIO
2755 .lname = "I/O nice priority",
2756 .type = FIO_OPT_INT,
2757 .off1 = td_var_offset(ioprio),
2758 .help = "Set job IO priority value",
2762 .category = FIO_OPT_C_GENERAL,
2763 .group = FIO_OPT_G_CRED,
2766 .name = "prioclass",
2767 .lname = "I/O nice priority class",
2768 .type = FIO_OPT_INT,
2769 .off1 = td_var_offset(ioprio_class),
2770 .help = "Set job IO priority class",
2774 .category = FIO_OPT_C_GENERAL,
2775 .group = FIO_OPT_G_CRED,
2779 .name = "thinktime",
2780 .lname = "Thinktime",
2781 .type = FIO_OPT_INT,
2782 .off1 = td_var_offset(thinktime),
2783 .help = "Idle time between IO buffers (usec)",
2786 .category = FIO_OPT_C_IO,
2787 .group = FIO_OPT_G_THINKTIME,
2790 .name = "thinktime_spin",
2791 .lname = "Thinktime spin",
2792 .type = FIO_OPT_INT,
2793 .off1 = td_var_offset(thinktime_spin),
2794 .help = "Start think time by spinning this amount (usec)",
2797 .parent = "thinktime",
2799 .category = FIO_OPT_C_IO,
2800 .group = FIO_OPT_G_THINKTIME,
2803 .name = "thinktime_blocks",
2804 .lname = "Thinktime blocks",
2805 .type = FIO_OPT_INT,
2806 .off1 = td_var_offset(thinktime_blocks),
2807 .help = "IO buffer period between 'thinktime'",
2809 .parent = "thinktime",
2811 .category = FIO_OPT_C_IO,
2812 .group = FIO_OPT_G_THINKTIME,
2816 .lname = "I/O rate",
2817 .type = FIO_OPT_INT,
2818 .off1 = td_var_offset(rate[DDIR_READ]),
2819 .off2 = td_var_offset(rate[DDIR_WRITE]),
2820 .off3 = td_var_offset(rate[DDIR_TRIM]),
2821 .help = "Set bandwidth rate",
2822 .category = FIO_OPT_C_IO,
2823 .group = FIO_OPT_G_RATE,
2827 .lname = "I/O min rate",
2828 .type = FIO_OPT_INT,
2829 .off1 = td_var_offset(ratemin[DDIR_READ]),
2830 .off2 = td_var_offset(ratemin[DDIR_WRITE]),
2831 .off3 = td_var_offset(ratemin[DDIR_TRIM]),
2832 .help = "Job must meet this rate or it will be shutdown",
2835 .category = FIO_OPT_C_IO,
2836 .group = FIO_OPT_G_RATE,
2839 .name = "rate_iops",
2840 .lname = "I/O rate IOPS",
2841 .type = FIO_OPT_INT,
2842 .off1 = td_var_offset(rate_iops[DDIR_READ]),
2843 .off2 = td_var_offset(rate_iops[DDIR_WRITE]),
2844 .off3 = td_var_offset(rate_iops[DDIR_TRIM]),
2845 .help = "Limit IO used to this number of IO operations/sec",
2847 .category = FIO_OPT_C_IO,
2848 .group = FIO_OPT_G_RATE,
2851 .name = "rate_iops_min",
2852 .lname = "I/O min rate IOPS",
2853 .type = FIO_OPT_INT,
2854 .off1 = td_var_offset(rate_iops_min[DDIR_READ]),
2855 .off2 = td_var_offset(rate_iops_min[DDIR_WRITE]),
2856 .off3 = td_var_offset(rate_iops_min[DDIR_TRIM]),
2857 .help = "Job must meet this rate or it will be shut down",
2858 .parent = "rate_iops",
2860 .category = FIO_OPT_C_IO,
2861 .group = FIO_OPT_G_RATE,
2864 .name = "ratecycle",
2865 .lname = "I/O rate cycle",
2866 .type = FIO_OPT_INT,
2867 .off1 = td_var_offset(ratecycle),
2868 .help = "Window average for rate limits (msec)",
2872 .category = FIO_OPT_C_IO,
2873 .group = FIO_OPT_G_RATE,
2876 .name = "max_latency",
2877 .type = FIO_OPT_INT,
2878 .off1 = td_var_offset(max_latency),
2879 .help = "Maximum tolerated IO latency (usec)",
2881 .category = FIO_OPT_C_IO,
2882 .group = FIO_OPT_G_LATPROF,
2885 .name = "latency_target",
2886 .lname = "Latency Target (usec)",
2887 .type = FIO_OPT_STR_VAL_TIME,
2888 .off1 = td_var_offset(latency_target),
2889 .help = "Ramp to max queue depth supporting this latency",
2891 .category = FIO_OPT_C_IO,
2892 .group = FIO_OPT_G_LATPROF,
2895 .name = "latency_window",
2896 .lname = "Latency Window (usec)",
2897 .type = FIO_OPT_STR_VAL_TIME,
2898 .off1 = td_var_offset(latency_window),
2899 .help = "Time to sustain latency_target",
2901 .category = FIO_OPT_C_IO,
2902 .group = FIO_OPT_G_LATPROF,
2905 .name = "latency_percentile",
2906 .lname = "Latency Percentile",
2907 .type = FIO_OPT_FLOAT_LIST,
2908 .off1 = td_var_offset(latency_percentile),
2909 .help = "Percentile of IOs must be below latency_target",
2914 .category = FIO_OPT_C_IO,
2915 .group = FIO_OPT_G_LATPROF,
2918 .name = "invalidate",
2919 .lname = "Cache invalidate",
2920 .type = FIO_OPT_BOOL,
2921 .off1 = td_var_offset(invalidate_cache),
2922 .help = "Invalidate buffer/page cache prior to running job",
2924 .category = FIO_OPT_C_IO,
2925 .group = FIO_OPT_G_IO_TYPE,
2929 .lname = "Synchronous I/O",
2930 .type = FIO_OPT_BOOL,
2931 .off1 = td_var_offset(sync_io),
2932 .help = "Use O_SYNC for buffered writes",
2934 .parent = "buffered",
2936 .category = FIO_OPT_C_IO,
2937 .group = FIO_OPT_G_IO_TYPE,
2940 .name = "create_serialize",
2941 .lname = "Create serialize",
2942 .type = FIO_OPT_BOOL,
2943 .off1 = td_var_offset(create_serialize),
2944 .help = "Serialize creating of job files",
2946 .category = FIO_OPT_C_FILE,
2947 .group = FIO_OPT_G_INVALID,
2950 .name = "create_fsync",
2951 .lname = "Create fsync",
2952 .type = FIO_OPT_BOOL,
2953 .off1 = td_var_offset(create_fsync),
2954 .help = "fsync file after creation",
2956 .category = FIO_OPT_C_FILE,
2957 .group = FIO_OPT_G_INVALID,
2960 .name = "create_on_open",
2961 .lname = "Create on open",
2962 .type = FIO_OPT_BOOL,
2963 .off1 = td_var_offset(create_on_open),
2964 .help = "Create files when they are opened for IO",
2966 .category = FIO_OPT_C_FILE,
2967 .group = FIO_OPT_G_INVALID,
2970 .name = "create_only",
2971 .type = FIO_OPT_BOOL,
2972 .off1 = td_var_offset(create_only),
2973 .help = "Only perform file creation phase",
2974 .category = FIO_OPT_C_FILE,
2979 .lname = "Pre-read files",
2980 .type = FIO_OPT_BOOL,
2981 .off1 = td_var_offset(pre_read),
2982 .help = "Pre-read files before starting official testing",
2984 .category = FIO_OPT_C_FILE,
2985 .group = FIO_OPT_G_INVALID,
2987 #ifdef FIO_HAVE_CPU_AFFINITY
2990 .lname = "CPU mask",
2991 .type = FIO_OPT_INT,
2992 .cb = str_cpumask_cb,
2993 .off1 = td_var_offset(cpumask),
2994 .help = "CPU affinity mask",
2995 .category = FIO_OPT_C_GENERAL,
2996 .group = FIO_OPT_G_CRED,
2999 .name = "cpus_allowed",
3000 .lname = "CPUs allowed",
3001 .type = FIO_OPT_STR,
3002 .cb = str_cpus_allowed_cb,
3003 .off1 = td_var_offset(cpumask),
3004 .help = "Set CPUs allowed",
3005 .category = FIO_OPT_C_GENERAL,
3006 .group = FIO_OPT_G_CRED,
3009 .name = "cpus_allowed_policy",
3010 .lname = "CPUs allowed distribution policy",
3011 .type = FIO_OPT_STR,
3012 .off1 = td_var_offset(cpus_allowed_policy),
3013 .help = "Distribution policy for cpus_allowed",
3014 .parent = "cpus_allowed",
3018 .oval = FIO_CPUS_SHARED,
3019 .help = "Mask shared between threads",
3022 .oval = FIO_CPUS_SPLIT,
3023 .help = "Mask split between threads",
3026 .category = FIO_OPT_C_GENERAL,
3027 .group = FIO_OPT_G_CRED,
3030 #ifdef CONFIG_LIBNUMA
3032 .name = "numa_cpu_nodes",
3033 .type = FIO_OPT_STR,
3034 .cb = str_numa_cpunodes_cb,
3035 .off1 = td_var_offset(numa_cpunodes),
3036 .help = "NUMA CPU nodes bind",
3037 .category = FIO_OPT_C_GENERAL,
3038 .group = FIO_OPT_G_INVALID,
3041 .name = "numa_mem_policy",
3042 .type = FIO_OPT_STR,
3043 .cb = str_numa_mpol_cb,
3044 .off1 = td_var_offset(numa_memnodes),
3045 .help = "NUMA memory policy setup",
3046 .category = FIO_OPT_C_GENERAL,
3047 .group = FIO_OPT_G_INVALID,
3051 .name = "end_fsync",
3052 .lname = "End fsync",
3053 .type = FIO_OPT_BOOL,
3054 .off1 = td_var_offset(end_fsync),
3055 .help = "Include fsync at the end of job",
3057 .category = FIO_OPT_C_FILE,
3058 .group = FIO_OPT_G_INVALID,
3061 .name = "fsync_on_close",
3062 .lname = "Fsync on close",
3063 .type = FIO_OPT_BOOL,
3064 .off1 = td_var_offset(fsync_on_close),
3065 .help = "fsync files on close",
3067 .category = FIO_OPT_C_FILE,
3068 .group = FIO_OPT_G_INVALID,
3072 .lname = "Unlink file",
3073 .type = FIO_OPT_BOOL,
3074 .off1 = td_var_offset(unlink),
3075 .help = "Unlink created files after job has completed",
3077 .category = FIO_OPT_C_FILE,
3078 .group = FIO_OPT_G_INVALID,
3082 .lname = "Exit-all on terminate",
3083 .type = FIO_OPT_STR_SET,
3084 .cb = str_exitall_cb,
3085 .help = "Terminate all jobs when one exits",
3086 .category = FIO_OPT_C_GENERAL,
3087 .group = FIO_OPT_G_PROCESS,
3090 .name = "stonewall",
3091 .lname = "Wait for previous",
3092 .alias = "wait_for_previous",
3093 .type = FIO_OPT_STR_SET,
3094 .off1 = td_var_offset(stonewall),
3095 .help = "Insert a hard barrier between this job and previous",
3096 .category = FIO_OPT_C_GENERAL,
3097 .group = FIO_OPT_G_PROCESS,
3100 .name = "new_group",
3101 .lname = "New group",
3102 .type = FIO_OPT_STR_SET,
3103 .off1 = td_var_offset(new_group),
3104 .help = "Mark the start of a new group (for reporting)",
3105 .category = FIO_OPT_C_GENERAL,
3106 .group = FIO_OPT_G_PROCESS,
3111 .type = FIO_OPT_STR_SET,
3112 .off1 = td_var_offset(use_thread),
3113 .help = "Use threads instead of processes",
3114 #ifdef CONFIG_NO_SHM
3118 .category = FIO_OPT_C_GENERAL,
3119 .group = FIO_OPT_G_PROCESS,
3122 .name = "write_bw_log",
3123 .lname = "Write bandwidth log",
3124 .type = FIO_OPT_STR_STORE,
3125 .off1 = td_var_offset(bw_log_file),
3126 .help = "Write log of bandwidth during run",
3127 .category = FIO_OPT_C_LOG,
3128 .group = FIO_OPT_G_INVALID,
3131 .name = "write_lat_log",
3132 .lname = "Write latency log",
3133 .type = FIO_OPT_STR_STORE,
3134 .off1 = td_var_offset(lat_log_file),
3135 .help = "Write log of latency during run",
3136 .category = FIO_OPT_C_LOG,
3137 .group = FIO_OPT_G_INVALID,
3140 .name = "write_iops_log",
3141 .lname = "Write IOPS log",
3142 .type = FIO_OPT_STR_STORE,
3143 .off1 = td_var_offset(iops_log_file),
3144 .help = "Write log of IOPS during run",
3145 .category = FIO_OPT_C_LOG,
3146 .group = FIO_OPT_G_INVALID,
3149 .name = "log_avg_msec",
3150 .lname = "Log averaging (msec)",
3151 .type = FIO_OPT_INT,
3152 .off1 = td_var_offset(log_avg_msec),
3153 .help = "Average bw/iops/lat logs over this period of time",
3155 .category = FIO_OPT_C_LOG,
3156 .group = FIO_OPT_G_INVALID,
3159 .name = "log_offset",
3160 .lname = "Log offset of IO",
3161 .type = FIO_OPT_BOOL,
3162 .off1 = td_var_offset(log_offset),
3163 .help = "Include offset of IO for each log entry",
3165 .category = FIO_OPT_C_LOG,
3166 .group = FIO_OPT_G_INVALID,
3170 .name = "log_compression",
3171 .lname = "Log compression",
3172 .type = FIO_OPT_INT,
3173 .off1 = td_var_offset(log_gz),
3174 .help = "Log in compressed chunks of this size",
3175 .minval = 32 * 1024 * 1024ULL,
3176 .maxval = 512 * 1024 * 1024ULL,
3177 .category = FIO_OPT_C_LOG,
3178 .group = FIO_OPT_G_INVALID,
3181 .name = "log_store_compressed",
3182 .lname = "Log store compressed",
3183 .type = FIO_OPT_BOOL,
3184 .off1 = td_var_offset(log_gz_store),
3185 .help = "Store logs in a compressed format",
3186 .category = FIO_OPT_C_LOG,
3187 .group = FIO_OPT_G_INVALID,
3191 .name = "bwavgtime",
3192 .lname = "Bandwidth average time",
3193 .type = FIO_OPT_INT,
3194 .off1 = td_var_offset(bw_avg_time),
3195 .help = "Time window over which to calculate bandwidth"
3198 .parent = "write_bw_log",
3201 .category = FIO_OPT_C_LOG,
3202 .group = FIO_OPT_G_INVALID,
3205 .name = "iopsavgtime",
3206 .lname = "IOPS average time",
3207 .type = FIO_OPT_INT,
3208 .off1 = td_var_offset(iops_avg_time),
3209 .help = "Time window over which to calculate IOPS (msec)",
3211 .parent = "write_iops_log",
3214 .category = FIO_OPT_C_LOG,
3215 .group = FIO_OPT_G_INVALID,
3218 .name = "group_reporting",
3219 .lname = "Group reporting",
3220 .type = FIO_OPT_STR_SET,
3221 .off1 = td_var_offset(group_reporting),
3222 .help = "Do reporting on a per-group basis",
3223 .category = FIO_OPT_C_STAT,
3224 .group = FIO_OPT_G_INVALID,
3227 .name = "zero_buffers",
3228 .lname = "Zero I/O buffers",
3229 .type = FIO_OPT_STR_SET,
3230 .off1 = td_var_offset(zero_buffers),
3231 .help = "Init IO buffers to all zeroes",
3232 .category = FIO_OPT_C_IO,
3233 .group = FIO_OPT_G_IO_BUF,
3236 .name = "refill_buffers",
3237 .lname = "Refill I/O buffers",
3238 .type = FIO_OPT_STR_SET,
3239 .off1 = td_var_offset(refill_buffers),
3240 .help = "Refill IO buffers on every IO submit",
3241 .category = FIO_OPT_C_IO,
3242 .group = FIO_OPT_G_IO_BUF,
3245 .name = "scramble_buffers",
3246 .lname = "Scramble I/O buffers",
3247 .type = FIO_OPT_BOOL,
3248 .off1 = td_var_offset(scramble_buffers),
3249 .help = "Slightly scramble buffers on every IO submit",
3251 .category = FIO_OPT_C_IO,
3252 .group = FIO_OPT_G_IO_BUF,
3255 .name = "buffer_pattern",
3256 .lname = "Buffer pattern",
3257 .type = FIO_OPT_STR,
3258 .cb = str_buffer_pattern_cb,
3259 .off1 = td_var_offset(buffer_pattern),
3260 .help = "Fill pattern for IO buffers",
3261 .category = FIO_OPT_C_IO,
3262 .group = FIO_OPT_G_IO_BUF,
3265 .name = "buffer_compress_percentage",
3266 .lname = "Buffer compression percentage",
3267 .type = FIO_OPT_INT,
3268 .cb = str_buffer_compress_cb,
3269 .off1 = td_var_offset(compress_percentage),
3272 .help = "How compressible the buffer is (approximately)",
3274 .category = FIO_OPT_C_IO,
3275 .group = FIO_OPT_G_IO_BUF,
3278 .name = "buffer_compress_chunk",
3279 .lname = "Buffer compression chunk size",
3280 .type = FIO_OPT_INT,
3281 .off1 = td_var_offset(compress_chunk),
3282 .parent = "buffer_compress_percentage",
3284 .help = "Size of compressible region in buffer",
3286 .category = FIO_OPT_C_IO,
3287 .group = FIO_OPT_G_IO_BUF,
3290 .name = "dedupe_percentage",
3291 .lname = "Dedupe percentage",
3292 .type = FIO_OPT_INT,
3293 .cb = str_dedupe_cb,
3294 .off1 = td_var_offset(dedupe_percentage),
3297 .help = "Percentage of buffers that are dedupable",
3299 .category = FIO_OPT_C_IO,
3300 .group = FIO_OPT_G_IO_BUF,
3303 .name = "clat_percentiles",
3304 .lname = "Completion latency percentiles",
3305 .type = FIO_OPT_BOOL,
3306 .off1 = td_var_offset(clat_percentiles),
3307 .help = "Enable the reporting of completion latency percentiles",
3309 .category = FIO_OPT_C_STAT,
3310 .group = FIO_OPT_G_INVALID,
3313 .name = "percentile_list",
3314 .lname = "Completion latency percentile list",
3315 .type = FIO_OPT_FLOAT_LIST,
3316 .off1 = td_var_offset(percentile_list),
3317 .off2 = td_var_offset(percentile_precision),
3318 .help = "Specify a custom list of percentiles to report",
3319 .def = "1:5:10:20:30:40:50:60:70:80:90:95:99:99.5:99.9:99.95:99.99",
3320 .maxlen = FIO_IO_U_LIST_MAX_LEN,
3323 .category = FIO_OPT_C_STAT,
3324 .group = FIO_OPT_G_INVALID,
3327 #ifdef FIO_HAVE_DISK_UTIL
3329 .name = "disk_util",
3330 .lname = "Disk utilization",
3331 .type = FIO_OPT_BOOL,
3332 .off1 = td_var_offset(do_disk_util),
3333 .help = "Log disk utilization statistics",
3335 .category = FIO_OPT_C_STAT,
3336 .group = FIO_OPT_G_INVALID,
3340 .name = "gtod_reduce",
3341 .lname = "Reduce gettimeofday() calls",
3342 .type = FIO_OPT_BOOL,
3343 .help = "Greatly reduce number of gettimeofday() calls",
3344 .cb = str_gtod_reduce_cb,
3347 .category = FIO_OPT_C_STAT,
3348 .group = FIO_OPT_G_INVALID,
3351 .name = "disable_lat",
3352 .lname = "Disable all latency stats",
3353 .type = FIO_OPT_BOOL,
3354 .off1 = td_var_offset(disable_lat),
3355 .help = "Disable latency numbers",
3356 .parent = "gtod_reduce",
3359 .category = FIO_OPT_C_STAT,
3360 .group = FIO_OPT_G_INVALID,
3363 .name = "disable_clat",
3364 .lname = "Disable completion latency stats",
3365 .type = FIO_OPT_BOOL,
3366 .off1 = td_var_offset(disable_clat),
3367 .help = "Disable completion latency numbers",
3368 .parent = "gtod_reduce",
3371 .category = FIO_OPT_C_STAT,
3372 .group = FIO_OPT_G_INVALID,
3375 .name = "disable_slat",
3376 .lname = "Disable submission latency stats",
3377 .type = FIO_OPT_BOOL,
3378 .off1 = td_var_offset(disable_slat),
3379 .help = "Disable submission latency numbers",
3380 .parent = "gtod_reduce",
3383 .category = FIO_OPT_C_STAT,
3384 .group = FIO_OPT_G_INVALID,
3387 .name = "disable_bw_measurement",
3388 .lname = "Disable bandwidth stats",
3389 .type = FIO_OPT_BOOL,
3390 .off1 = td_var_offset(disable_bw),
3391 .help = "Disable bandwidth logging",
3392 .parent = "gtod_reduce",
3395 .category = FIO_OPT_C_STAT,
3396 .group = FIO_OPT_G_INVALID,
3400 .lname = "Dedicated gettimeofday() CPU",
3401 .type = FIO_OPT_INT,
3402 .off1 = td_var_offset(gtod_cpu),
3403 .help = "Set up dedicated gettimeofday() thread on this CPU",
3404 .verify = gtod_cpu_verify,
3405 .category = FIO_OPT_C_GENERAL,
3406 .group = FIO_OPT_G_CLOCK,
3409 .name = "unified_rw_reporting",
3410 .type = FIO_OPT_BOOL,
3411 .off1 = td_var_offset(unified_rw_rep),
3412 .help = "Unify reporting across data direction",
3414 .category = FIO_OPT_C_GENERAL,
3415 .group = FIO_OPT_G_INVALID,
3418 .name = "continue_on_error",
3419 .lname = "Continue on error",
3420 .type = FIO_OPT_STR,
3421 .off1 = td_var_offset(continue_on_error),
3422 .help = "Continue on non-fatal errors during IO",
3424 .category = FIO_OPT_C_GENERAL,
3425 .group = FIO_OPT_G_ERR,
3428 .oval = ERROR_TYPE_NONE,
3429 .help = "Exit when an error is encountered",
3432 .oval = ERROR_TYPE_READ,
3433 .help = "Continue on read errors only",
3436 .oval = ERROR_TYPE_WRITE,
3437 .help = "Continue on write errors only",
3440 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
3441 .help = "Continue on any IO errors",
3444 .oval = ERROR_TYPE_VERIFY,
3445 .help = "Continue on verify errors only",
3448 .oval = ERROR_TYPE_ANY,
3449 .help = "Continue on all io and verify errors",
3452 .oval = ERROR_TYPE_NONE,
3453 .help = "Alias for 'none'",
3456 .oval = ERROR_TYPE_ANY,
3457 .help = "Alias for 'all'",
3462 .name = "ignore_error",
3463 .type = FIO_OPT_STR,
3464 .cb = str_ignore_error_cb,
3465 .off1 = td_var_offset(ignore_error_nr),
3466 .help = "Set a specific list of errors to ignore",
3468 .category = FIO_OPT_C_GENERAL,
3469 .group = FIO_OPT_G_ERR,
3472 .name = "error_dump",
3473 .type = FIO_OPT_BOOL,
3474 .off1 = td_var_offset(error_dump),
3476 .help = "Dump info on each error",
3477 .category = FIO_OPT_C_GENERAL,
3478 .group = FIO_OPT_G_ERR,
3483 .type = FIO_OPT_STR_STORE,
3484 .off1 = td_var_offset(profile),
3485 .help = "Select a specific builtin performance test",
3486 .category = FIO_OPT_C_PROFILE,
3487 .group = FIO_OPT_G_INVALID,
3492 .type = FIO_OPT_STR_STORE,
3493 .off1 = td_var_offset(cgroup),
3494 .help = "Add job to cgroup of this name",
3495 .category = FIO_OPT_C_GENERAL,
3496 .group = FIO_OPT_G_CGROUP,
3499 .name = "cgroup_nodelete",
3500 .lname = "Cgroup no-delete",
3501 .type = FIO_OPT_BOOL,
3502 .off1 = td_var_offset(cgroup_nodelete),
3503 .help = "Do not delete cgroups after job completion",
3506 .category = FIO_OPT_C_GENERAL,
3507 .group = FIO_OPT_G_CGROUP,
3510 .name = "cgroup_weight",
3511 .lname = "Cgroup weight",
3512 .type = FIO_OPT_INT,
3513 .off1 = td_var_offset(cgroup_weight),
3514 .help = "Use given weight for cgroup",
3518 .category = FIO_OPT_C_GENERAL,
3519 .group = FIO_OPT_G_CGROUP,
3524 .type = FIO_OPT_INT,
3525 .off1 = td_var_offset(uid),
3526 .help = "Run job with this user ID",
3527 .category = FIO_OPT_C_GENERAL,
3528 .group = FIO_OPT_G_CRED,
3532 .lname = "Group ID",
3533 .type = FIO_OPT_INT,
3534 .off1 = td_var_offset(gid),
3535 .help = "Run job with this group ID",
3536 .category = FIO_OPT_C_GENERAL,
3537 .group = FIO_OPT_G_CRED,
3542 .type = FIO_OPT_INT,
3543 .off1 = td_var_offset(kb_base),
3549 .help = "Use 1024 as the K base",
3553 .help = "Use 1000 as the K base",
3556 .help = "How many bytes per KB for reporting (1000 or 1024)",
3557 .category = FIO_OPT_C_GENERAL,
3558 .group = FIO_OPT_G_INVALID,
3561 .name = "unit_base",
3562 .lname = "Base unit for reporting (Bits or Bytes)",
3563 .type = FIO_OPT_INT,
3564 .off1 = td_var_offset(unit_base),
3569 .help = "Auto-detect",
3573 .help = "Normal (byte based)",
3577 .help = "Bit based",
3580 .help = "Bit multiple of result summary data (8 for byte, 1 for bit)",
3581 .category = FIO_OPT_C_GENERAL,
3582 .group = FIO_OPT_G_INVALID,
3585 .name = "hugepage-size",
3586 .lname = "Hugepage size",
3587 .type = FIO_OPT_INT,
3588 .off1 = td_var_offset(hugepage_size),
3589 .help = "When using hugepages, specify size of each page",
3590 .def = __fio_stringify(FIO_HUGE_PAGE),
3591 .interval = 1024 * 1024,
3592 .category = FIO_OPT_C_GENERAL,
3593 .group = FIO_OPT_G_INVALID,
3597 .lname = "I/O flow ID",
3598 .type = FIO_OPT_INT,
3599 .off1 = td_var_offset(flow_id),
3600 .help = "The flow index ID to use",
3602 .category = FIO_OPT_C_IO,
3603 .group = FIO_OPT_G_IO_FLOW,
3607 .lname = "I/O flow weight",
3608 .type = FIO_OPT_INT,
3609 .off1 = td_var_offset(flow),
3610 .help = "Weight for flow control of this job",
3611 .parent = "flow_id",
3614 .category = FIO_OPT_C_IO,
3615 .group = FIO_OPT_G_IO_FLOW,
3618 .name = "flow_watermark",
3619 .lname = "I/O flow watermark",
3620 .type = FIO_OPT_INT,
3621 .off1 = td_var_offset(flow_watermark),
3622 .help = "High watermark for flow control. This option"
3623 " should be set to the same value for all threads"
3624 " with non-zero flow.",
3625 .parent = "flow_id",
3628 .category = FIO_OPT_C_IO,
3629 .group = FIO_OPT_G_IO_FLOW,
3632 .name = "flow_sleep",
3633 .lname = "I/O flow sleep",
3634 .type = FIO_OPT_INT,
3635 .off1 = td_var_offset(flow_sleep),
3636 .help = "How many microseconds to sleep after being held"
3637 " back by the flow control mechanism",
3638 .parent = "flow_id",
3641 .category = FIO_OPT_C_IO,
3642 .group = FIO_OPT_G_IO_FLOW,
3649 static void add_to_lopt(struct option *lopt, struct fio_option *o,
3650 const char *name, int val)
3652 lopt->name = (char *) name;
3654 if (o->type == FIO_OPT_STR_SET)
3655 lopt->has_arg = optional_argument;
3657 lopt->has_arg = required_argument;
3660 static void options_to_lopts(struct fio_option *opts,
3661 struct option *long_options,
3662 int i, int option_type)
3664 struct fio_option *o = &opts[0];
3666 add_to_lopt(&long_options[i], o, o->name, option_type);
3669 add_to_lopt(&long_options[i], o, o->alias, option_type);
3674 assert(i < FIO_NR_OPTIONS);
3678 void fio_options_set_ioengine_opts(struct option *long_options,
3679 struct thread_data *td)
3684 while (long_options[i].name) {
3685 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
3686 memset(&long_options[i], 0, sizeof(*long_options));
3693 * Just clear out the prior ioengine options.
3698 options_to_lopts(td->io_ops->options, long_options, i,
3699 FIO_GETOPT_IOENGINE);
3702 void fio_options_dup_and_init(struct option *long_options)
3706 options_init(fio_options);
3709 while (long_options[i].name)
3712 options_to_lopts(fio_options, long_options, i, FIO_GETOPT_JOB);
3715 struct fio_keyword {
3721 static struct fio_keyword fio_keywords[] = {
3723 .word = "$pagesize",
3724 .desc = "Page size in the system",
3727 .word = "$mb_memory",
3728 .desc = "Megabytes of memory online",
3732 .desc = "Number of CPUs online in the system",
3739 void fio_keywords_init(void)
3741 unsigned long long mb_memory;
3745 sprintf(buf, "%lu", (unsigned long) page_size);
3746 fio_keywords[0].replace = strdup(buf);
3748 mb_memory = os_phys_mem() / (1024 * 1024);
3749 sprintf(buf, "%llu", mb_memory);
3750 fio_keywords[1].replace = strdup(buf);
3753 sprintf(buf, "%lu", l);
3754 fio_keywords[2].replace = strdup(buf);
3759 static char *bc_calc(char *str)
3761 char buf[128], *tmp;
3766 * No math, just return string
3768 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
3769 !strchr(str, '/')) || strchr(str, '\''))
3773 * Split option from value, we only need to calculate the value
3775 tmp = strchr(str, '=');
3782 * Prevent buffer overflows; such a case isn't reasonable anyway
3784 if (strlen(str) >= 128 || strlen(tmp) > 100)
3787 sprintf(buf, "which %s > /dev/null", BC_APP);
3789 log_err("fio: bc is needed for performing math\n");
3793 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
3794 f = popen(buf, "r");
3798 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
3805 buf[(tmp - str) + ret - 1] = '\0';
3806 memcpy(buf, str, tmp - str);
3812 * Return a copy of the input string with substrings of the form ${VARNAME}
3813 * substituted with the value of the environment variable VARNAME. The
3814 * substitution always occurs, even if VARNAME is empty or the corresponding
3815 * environment variable undefined.
3817 static char *option_dup_subs(const char *opt)
3819 char out[OPT_LEN_MAX+1];
3820 char in[OPT_LEN_MAX+1];
3823 char *ch1, *ch2, *env;
3824 ssize_t nchr = OPT_LEN_MAX;
3827 if (strlen(opt) + 1 > OPT_LEN_MAX) {
3828 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
3832 in[OPT_LEN_MAX] = '\0';
3833 strncpy(in, opt, OPT_LEN_MAX);
3835 while (*inptr && nchr > 0) {
3836 if (inptr[0] == '$' && inptr[1] == '{') {
3837 ch2 = strchr(inptr, '}');
3838 if (ch2 && inptr+1 < ch2) {
3845 envlen = strlen(env);
3846 if (envlen <= nchr) {
3847 memcpy(outptr, env, envlen);
3857 *outptr++ = *inptr++;
3866 * Look for reserved variable names and replace them with real values
3868 static char *fio_keyword_replace(char *opt)
3874 for (i = 0; fio_keywords[i].word != NULL; i++) {
3875 struct fio_keyword *kw = &fio_keywords[i];
3877 while ((s = strstr(opt, kw->word)) != NULL) {
3878 char *new = malloc(strlen(opt) + 1);
3884 * Copy part of the string before the keyword and
3885 * sprintf() the replacement after it.
3887 memcpy(new, opt, olen);
3888 len = sprintf(new + olen, "%s", kw->replace);
3891 * If there's more in the original string, copy that
3894 opt += strlen(kw->word) + olen;
3896 memcpy(new + olen + len, opt, opt - o_org - 1);
3899 * replace opt and free the old opt
3909 * Check for potential math and invoke bc, if possible
3917 static char **dup_and_sub_options(char **opts, int num_opts)
3920 char **opts_copy = malloc(num_opts * sizeof(*opts));
3921 for (i = 0; i < num_opts; i++) {
3922 opts_copy[i] = option_dup_subs(opts[i]);
3925 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
3930 static void show_closest_option(const char *opt)
3932 int best_option, best_distance;
3941 while (name[i] != '\0' && name[i] != '=')
3946 best_distance = INT_MAX;
3948 while (fio_options[i].name) {
3949 distance = string_distance(name, fio_options[i].name);
3950 if (distance < best_distance) {
3951 best_distance = distance;
3957 if (best_option != -1)
3958 log_err("Did you mean %s?\n", fio_options[best_option].name);
3963 int fio_options_parse(struct thread_data *td, char **opts, int num_opts,
3966 int i, ret, unknown;
3969 sort_options(opts, fio_options, num_opts);
3970 opts_copy = dup_and_sub_options(opts, num_opts);
3972 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
3973 struct fio_option *o;
3974 int newret = parse_option(opts_copy[i], opts[i], fio_options,
3975 &o, td, dump_cmdline);
3978 fio_option_mark_set(&td->o, o);
3986 opts_copy[i] = NULL;
3993 ret |= ioengine_load(td);
3995 sort_options(opts_copy, td->io_ops->options, num_opts);
3998 for (i = 0; i < num_opts; i++) {
3999 struct fio_option *o = NULL;
4006 newret = parse_option(opts_copy[i], opts[i],
4007 td->io_ops->options, &o,
4008 td->eo, dump_cmdline);
4012 log_err("Bad option <%s>\n", opts[i]);
4013 show_closest_option(opts[i]);
4016 opts_copy[i] = NULL;
4024 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
4028 ret = parse_cmd_option(opt, val, fio_options, td);
4030 struct fio_option *o;
4032 o = find_option(fio_options, opt);
4034 fio_option_mark_set(&td->o, o);
4040 int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
4043 return parse_cmd_option(opt, val, td->io_ops->options, td->eo);
4046 void fio_fill_default_options(struct thread_data *td)
4048 td->o.magic = OPT_MAGIC;
4049 fill_default_options(td, fio_options);
4052 int fio_show_option_help(const char *opt)
4054 return show_cmd_help(fio_options, opt);
4057 void options_mem_dupe(void *data, struct fio_option *options)
4059 struct fio_option *o;
4062 for (o = &options[0]; o->name; o++) {
4063 if (o->type != FIO_OPT_STR_STORE)
4066 ptr = td_var(data, o, o->off1);
4068 *ptr = strdup(*ptr);
4073 * dupe FIO_OPT_STR_STORE options
4075 void fio_options_mem_dupe(struct thread_data *td)
4077 options_mem_dupe(&td->o, fio_options);
4079 if (td->eo && td->io_ops) {
4080 void *oldeo = td->eo;
4082 td->eo = malloc(td->io_ops->option_struct_size);
4083 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
4084 options_mem_dupe(td->eo, td->io_ops->options);
4088 unsigned int fio_get_kb_base(void *data)
4090 struct thread_options *o = data;
4091 unsigned int kb_base = 0;
4094 * This is a hack... For private options, *data is not holding
4095 * a pointer to the thread_options, but to private data. This means
4096 * we can't safely dereference it, but magic is first so mem wise
4097 * it is valid. But this also means that if the job first sets
4098 * kb_base and expects that to be honored by private options,
4099 * it will be disappointed. We will return the global default
4102 if (o && o->magic == OPT_MAGIC)
4103 kb_base = o->kb_base;
4110 int add_option(struct fio_option *o)
4112 struct fio_option *__o;
4121 if (opt_index + 1 == FIO_MAX_OPTS) {
4122 log_err("fio: FIO_MAX_OPTS is too small\n");
4126 memcpy(&fio_options[opt_index], o, sizeof(*o));
4127 fio_options[opt_index + 1].name = NULL;
4131 void invalidate_profile_options(const char *prof_name)
4133 struct fio_option *o;
4137 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
4138 o->type = FIO_OPT_INVALID;
4139 o->prof_name = NULL;
4145 void add_opt_posval(const char *optname, const char *ival, const char *help)
4147 struct fio_option *o;
4150 o = find_option(fio_options, optname);
4154 for (i = 0; i < PARSE_MAX_VP; i++) {
4155 if (o->posval[i].ival)
4158 o->posval[i].ival = ival;
4159 o->posval[i].help = help;
4164 void del_opt_posval(const char *optname, const char *ival)
4166 struct fio_option *o;
4169 o = find_option(fio_options, optname);
4173 for (i = 0; i < PARSE_MAX_VP; i++) {
4174 if (!o->posval[i].ival)
4176 if (strcmp(o->posval[i].ival, ival))
4179 o->posval[i].ival = NULL;
4180 o->posval[i].help = NULL;
4184 void fio_options_free(struct thread_data *td)
4186 options_free(fio_options, td);
4187 if (td->eo && td->io_ops && td->io_ops->options) {
4188 options_free(td->io_ops->options, td->eo);
4194 struct fio_option *fio_option_find(const char *name)
4196 return find_option(fio_options, name);
4199 static struct fio_option *find_next_opt(struct thread_options *o,
4200 struct fio_option *from,
4203 struct fio_option *opt;
4206 from = &fio_options[0];
4212 if (off1 == from->off1) {
4217 } while (from->name);
4222 static int opt_is_set(struct thread_options *o, struct fio_option *opt)
4224 unsigned int opt_off, index, offset;
4226 opt_off = opt - &fio_options[0];
4227 index = opt_off / (8 * sizeof(uint64_t));
4228 offset = opt_off & ((8 * sizeof(uint64_t)) - 1);
4229 return (o->set_options[index] & (1UL << offset)) != 0;
4232 int __fio_option_is_set(struct thread_options *o, unsigned int off1)
4234 struct fio_option *opt, *next;
4237 while ((opt = find_next_opt(o, next, off1)) != NULL) {
4238 if (opt_is_set(o, opt))
4247 void fio_option_mark_set(struct thread_options *o, struct fio_option *opt)
4249 unsigned int opt_off, index, offset;
4251 opt_off = opt - &fio_options[0];
4252 index = opt_off / (8 * sizeof(uint64_t));
4253 offset = opt_off & ((8 * sizeof(uint64_t)) - 1);
4254 o->set_options[index] |= 1UL << offset;