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)) {
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 == (unsigned char) -1)
137 log_err("fio: bssplit percentages add to more than 100%%\n");
142 * If values didn't have a percentage set, divide the remains between
146 for (i = 0; i < o->bssplit_nr[ddir]; i++) {
147 struct bssplit *bsp = &bssplit[i];
149 if (bsp->perc == (unsigned char) -1)
150 bsp->perc = (100 - perc) / perc_missing;
154 o->min_bs[ddir] = min_bs;
155 o->max_bs[ddir] = max_bs;
158 * now sort based on percentages, for ease of lookup
160 qsort(bssplit, o->bssplit_nr[ddir], sizeof(struct bssplit), bs_cmp);
161 o->bssplit[ddir] = bssplit;
165 static int str_bssplit_cb(void *data, const char *input)
167 struct thread_data *td = data;
168 char *str, *p, *odir, *ddir;
171 p = str = strdup(input);
173 strip_blank_front(&str);
174 strip_blank_end(str);
176 odir = strchr(str, ',');
178 ddir = strchr(odir + 1, ',');
180 ret = bssplit_ddir(&td->o, DDIR_TRIM, ddir + 1);
186 op = strdup(odir + 1);
187 ret = bssplit_ddir(&td->o, DDIR_TRIM, op);
192 ret = bssplit_ddir(&td->o, DDIR_WRITE, odir + 1);
195 ret = bssplit_ddir(&td->o, DDIR_READ, str);
201 ret = bssplit_ddir(&td->o, DDIR_WRITE, op);
206 ret = bssplit_ddir(&td->o, DDIR_TRIM, op);
209 ret = bssplit_ddir(&td->o, DDIR_READ, str);
216 static int str2error(char *str)
218 const char *err[] = { "EPERM", "ENOENT", "ESRCH", "EINTR", "EIO",
219 "ENXIO", "E2BIG", "ENOEXEC", "EBADF",
220 "ECHILD", "EAGAIN", "ENOMEM", "EACCES",
221 "EFAULT", "ENOTBLK", "EBUSY", "EEXIST",
222 "EXDEV", "ENODEV", "ENOTDIR", "EISDIR",
223 "EINVAL", "ENFILE", "EMFILE", "ENOTTY",
224 "ETXTBSY","EFBIG", "ENOSPC", "ESPIPE",
225 "EROFS","EMLINK", "EPIPE", "EDOM", "ERANGE" };
226 int i = 0, num = sizeof(err) / sizeof(void *);
229 if (!strcmp(err[i], str))
236 static int ignore_error_type(struct thread_data *td, int etype, char *str)
242 if (etype >= ERROR_TYPE_CNT) {
243 log_err("Illegal error type\n");
247 td->o.ignore_error_nr[etype] = 4;
248 error = malloc(4 * sizeof(struct bssplit));
251 while ((fname = strsep(&str, ":")) != NULL) {
257 * grow struct buffer, if needed
259 if (i == td->o.ignore_error_nr[etype]) {
260 td->o.ignore_error_nr[etype] <<= 1;
261 error = realloc(error, td->o.ignore_error_nr[etype]
264 if (fname[0] == 'E') {
265 error[i] = str2error(fname);
267 error[i] = atoi(fname);
272 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;
287 static int str_ignore_error_cb(void *data, const char *input)
289 struct thread_data *td = data;
291 int type = 0, ret = 1;
292 p = str = strdup(input);
294 strip_blank_front(&str);
295 strip_blank_end(str);
301 ret = ignore_error_type(td, type, p);
311 static int str_rw_cb(void *data, const char *str)
313 struct thread_data *td = data;
314 struct thread_options *o = &td->o;
315 char *nr = get_opt_postfix(str);
324 o->ddir_seq_nr = atoi(nr);
328 if (str_to_decimal(nr, &val, 1, o)) {
329 log_err("fio: rw postfix parsing failed\n");
334 o->ddir_seq_add = val;
341 static int str_mem_cb(void *data, const char *mem)
343 struct thread_data *td = data;
344 struct thread_options *o = &td->o;
346 if (o->mem_type == MEM_MMAPHUGE || o->mem_type == MEM_MMAP) {
347 o->mmapfile = get_opt_postfix(mem);
348 if (o->mem_type == MEM_MMAPHUGE && !o->mmapfile) {
349 log_err("fio: mmaphuge:/path/to/file\n");
357 static int fio_clock_source_cb(void *data, const char *str)
359 struct thread_data *td = data;
361 fio_clock_source = td->o.clocksource;
366 static int str_rwmix_read_cb(void *data, unsigned long long *val)
368 struct thread_data *td = data;
370 td->o.rwmix[DDIR_READ] = *val;
371 td->o.rwmix[DDIR_WRITE] = 100 - *val;
375 static int str_rwmix_write_cb(void *data, unsigned long long *val)
377 struct thread_data *td = data;
379 td->o.rwmix[DDIR_WRITE] = *val;
380 td->o.rwmix[DDIR_READ] = 100 - *val;
384 static int str_exitall_cb(void)
386 exitall_on_terminate = 1;
390 #ifdef FIO_HAVE_CPU_AFFINITY
391 static int str_cpumask_cb(void *data, unsigned long long *val)
393 struct thread_data *td = data;
398 ret = fio_cpuset_init(&td->o.cpumask);
400 log_err("fio: cpuset_init failed\n");
401 td_verror(td, ret, "fio_cpuset_init");
405 max_cpu = cpus_online();
407 for (i = 0; i < sizeof(int) * 8; i++) {
408 if ((1 << i) & *val) {
410 log_err("fio: CPU %d too large (max=%ld)\n", i,
414 dprint(FD_PARSE, "set cpu allowed %d\n", i);
415 fio_cpu_set(&td->o.cpumask, i);
419 td->o.cpumask_set = 1;
423 static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask,
430 ret = fio_cpuset_init(mask);
432 log_err("fio: cpuset_init failed\n");
433 td_verror(td, ret, "fio_cpuset_init");
437 p = str = strdup(input);
439 strip_blank_front(&str);
440 strip_blank_end(str);
442 max_cpu = cpus_online();
444 while ((cpu = strsep(&str, ",")) != NULL) {
453 while ((cpu2 = strsep(&str2, "-")) != NULL) {
463 while (icpu <= icpu2) {
464 if (icpu >= FIO_MAX_CPUS) {
465 log_err("fio: your OS only supports up to"
466 " %d CPUs\n", (int) FIO_MAX_CPUS);
470 if (icpu > max_cpu) {
471 log_err("fio: CPU %d too large (max=%ld)\n",
477 dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
478 fio_cpu_set(mask, icpu);
487 td->o.cpumask_set = 1;
491 static int str_cpus_allowed_cb(void *data, const char *input)
493 struct thread_data *td = data;
496 ret = set_cpus_allowed(td, &td->o.cpumask, input);
498 td->o.cpumask_set = 1;
503 static int str_verify_cpus_allowed_cb(void *data, const char *input)
505 struct thread_data *td = data;
508 ret = set_cpus_allowed(td, &td->o.verify_cpumask, input);
510 td->o.verify_cpumask_set = 1;
516 static int str_fst_cb(void *data, const char *str)
518 struct thread_data *td = data;
519 char *nr = get_opt_postfix(str);
521 td->file_service_nr = 1;
523 td->file_service_nr = atoi(nr);
530 #ifdef FIO_HAVE_SYNC_FILE_RANGE
531 static int str_sfr_cb(void *data, const char *str)
533 struct thread_data *td = data;
534 char *nr = get_opt_postfix(str);
536 td->sync_file_range_nr = 1;
538 td->sync_file_range_nr = atoi(nr);
547 * Return next file in the string. Files are separated with ':'. If the ':'
548 * is escaped with a '\', then that ':' is part of the filename and does not
549 * indicate a new file.
551 static char *get_next_file_name(char **ptr)
556 if (!str || !strlen(str))
562 * No colon, we are done
564 p = strchr(str, ':');
571 * We got a colon, but it's the first character. Skip and
579 if (*(p - 1) != '\\') {
585 memmove(p - 1, p, strlen(p) + 1);
592 static int str_filename_cb(void *data, const char *input)
594 struct thread_data *td = data;
595 char *fname, *str, *p;
597 p = str = strdup(input);
599 strip_blank_front(&str);
600 strip_blank_end(str);
602 if (!td->files_index)
605 while ((fname = get_next_file_name(&str)) != NULL) {
616 static int str_directory_cb(void *data, const char fio_unused *str)
618 struct thread_data *td = data;
621 if (lstat(td->o.directory, &sb) < 0) {
624 log_err("fio: %s is not a directory\n", td->o.directory);
625 td_verror(td, ret, "lstat");
628 if (!S_ISDIR(sb.st_mode)) {
629 log_err("fio: %s is not a directory\n", td->o.directory);
636 static int str_opendir_cb(void *data, const char fio_unused *str)
638 struct thread_data *td = data;
640 if (!td->files_index)
643 return add_dir_files(td, td->o.opendir);
646 static int str_verify_pattern_cb(void *data, const char *input)
648 struct thread_data *td = data;
650 int i = 0, j = 0, len, k, base = 10;
653 loc1 = strstr(input, "0x");
654 loc2 = strstr(input, "0X");
657 off = strtol(input, NULL, base);
658 if (off != LONG_MAX || errno != ERANGE) {
660 td->o.verify_pattern[i] = off & 0xff;
669 j = loc1 - input + 2;
671 j = loc2 - input + 2;
674 if (len - j < MAX_PATTERN_SIZE * 2) {
676 off = converthexchartoint(input[k--]);
678 off += (converthexchartoint(input[k--])
680 td->o.verify_pattern[i++] = (char) off;
686 * Fill the pattern all the way to the end. This greatly reduces
687 * the number of memcpy's we have to do when verifying the IO.
689 while (i > 1 && i * 2 <= MAX_PATTERN_SIZE) {
690 memcpy(&td->o.verify_pattern[i], &td->o.verify_pattern[0], i);
695 * The code in verify_io_u_pattern assumes a single byte pattern
696 * fills the whole verify pattern buffer.
698 memset(td->o.verify_pattern, td->o.verify_pattern[0],
702 td->o.verify_pattern_bytes = i;
705 * VERIFY_META could already be set
707 if (td->o.verify == VERIFY_NONE)
708 td->o.verify = VERIFY_PATTERN;
713 static int str_lockfile_cb(void *data, const char *str)
715 struct thread_data *td = data;
716 char *nr = get_opt_postfix(str);
718 td->o.lockfile_batch = 1;
720 td->o.lockfile_batch = atoi(nr);
727 static int str_gtod_reduce_cb(void *data, int *il)
729 struct thread_data *td = data;
732 td->o.disable_lat = !!val;
733 td->o.disable_clat = !!val;
734 td->o.disable_slat = !!val;
735 td->o.disable_bw = !!val;
736 td->o.clat_percentiles = !val;
738 td->tv_cache_mask = 63;
743 static int str_gtod_cpu_cb(void *data, long long *il)
745 struct thread_data *td = data;
748 td->o.gtod_cpu = val;
749 td->o.gtod_offload = 1;
753 static int str_size_cb(void *data, unsigned long long *__val)
755 struct thread_data *td = data;
756 unsigned long long v = *__val;
758 if (parse_is_percent(v)) {
760 td->o.size_percent = -1ULL - v;
767 static int rw_verify(struct fio_option *o, void *data)
769 struct thread_data *td = data;
771 if (read_only && td_write(td)) {
772 log_err("fio: job <%s> has write bit set, but fio is in"
773 " read-only mode\n", td->o.name);
780 static int gtod_cpu_verify(struct fio_option *o, void *data)
782 #ifndef FIO_HAVE_CPU_AFFINITY
783 struct thread_data *td = data;
785 if (td->o.gtod_cpu) {
786 log_err("fio: platform must support CPU affinity for"
787 "gettimeofday() offloading\n");
795 static int kb_base_verify(struct fio_option *o, void *data)
797 struct thread_data *td = data;
799 if (td->o.kb_base != 1024 && td->o.kb_base != 1000) {
800 log_err("fio: kb_base set to nonsensical value: %u\n",
811 static struct opt_group fio_opt_groups[] = {
814 .mask = FIO_OPT_C_GENERAL,
818 .mask = FIO_OPT_C_IO,
822 .mask = FIO_OPT_C_FILE,
825 .name = "Statistics",
826 .mask = FIO_OPT_C_STAT,
830 .mask = FIO_OPT_C_LOG,
834 .mask = FIO_OPT_C_PROFILE,
841 static struct opt_group *__opt_group_from_mask(struct opt_group *ogs, unsigned int *mask,
842 unsigned int inv_mask)
844 struct opt_group *og;
847 if (*mask == inv_mask || !*mask)
850 for (i = 0; ogs[i].name; i++) {
853 if (*mask & og->mask) {
854 *mask &= ~(og->mask);
862 struct opt_group *opt_group_from_mask(unsigned int *mask)
864 return __opt_group_from_mask(fio_opt_groups, mask, FIO_OPT_C_INVALID);
867 static struct opt_group fio_opt_cat_groups[] = {
870 .mask = FIO_OPT_G_RATE,
874 .mask = FIO_OPT_G_ZONE,
877 .name = "Read/write mix",
878 .mask = FIO_OPT_G_RWMIX,
882 .mask = FIO_OPT_G_VERIFY,
886 .mask = FIO_OPT_G_TRIM,
889 .name = "I/O Logging",
890 .mask = FIO_OPT_G_IOLOG,
894 .mask = FIO_OPT_G_IO_DEPTH,
898 .mask = FIO_OPT_G_IO_FLOW,
901 .name = "Description",
902 .mask = FIO_OPT_G_DESC,
906 .mask = FIO_OPT_G_FILENAME,
909 .name = "General I/O",
910 .mask = FIO_OPT_G_IO_BASIC,
914 .mask = FIO_OPT_G_CGROUP,
918 .mask = FIO_OPT_G_RUNTIME,
922 .mask = FIO_OPT_G_PROCESS,
925 .name = "Job credentials / priority",
926 .mask = FIO_OPT_G_CRED,
929 .name = "Clock settings",
930 .mask = FIO_OPT_G_CLOCK,
934 .mask = FIO_OPT_G_IO_TYPE,
937 .name = "I/O Thinktime",
938 .mask = FIO_OPT_G_THINKTIME,
941 .name = "Randomizations",
942 .mask = FIO_OPT_G_RANDOM,
945 .name = "I/O buffers",
946 .mask = FIO_OPT_G_IO_BUF,
949 .name = "Tiobench profile",
950 .mask = FIO_OPT_G_TIOBENCH,
958 struct opt_group *opt_group_cat_from_mask(unsigned int *mask)
960 return __opt_group_from_mask(fio_opt_cat_groups, mask, FIO_OPT_G_INVALID);
964 * Map of job/command line options
966 struct fio_option fio_options[FIO_MAX_OPTS] = {
968 .name = "description",
969 .lname = "Description of job",
970 .type = FIO_OPT_STR_STORE,
971 .off1 = td_var_offset(description),
972 .help = "Text job description",
973 .category = FIO_OPT_C_GENERAL,
974 .group = FIO_OPT_G_DESC,
979 .type = FIO_OPT_STR_STORE,
980 .off1 = td_var_offset(name),
981 .help = "Name of this job",
982 .category = FIO_OPT_C_GENERAL,
983 .group = FIO_OPT_G_DESC,
987 .lname = "Filename(s)",
988 .type = FIO_OPT_STR_STORE,
989 .off1 = td_var_offset(filename),
990 .cb = str_filename_cb,
991 .prio = -1, /* must come after "directory" */
992 .help = "File(s) to use for the workload",
993 .category = FIO_OPT_C_FILE,
994 .group = FIO_OPT_G_FILENAME,
998 .lname = "Directory",
999 .type = FIO_OPT_STR_STORE,
1000 .off1 = td_var_offset(directory),
1001 .cb = str_directory_cb,
1002 .help = "Directory to store files in",
1003 .category = FIO_OPT_C_FILE,
1004 .group = FIO_OPT_G_FILENAME,
1008 .lname = "Lockfile",
1009 .type = FIO_OPT_STR,
1010 .cb = str_lockfile_cb,
1011 .off1 = td_var_offset(file_lock_mode),
1012 .help = "Lock file when doing IO to it",
1013 .parent = "filename",
1016 .category = FIO_OPT_C_FILE,
1017 .group = FIO_OPT_G_FILENAME,
1020 .oval = FILE_LOCK_NONE,
1021 .help = "No file locking",
1023 { .ival = "exclusive",
1024 .oval = FILE_LOCK_EXCLUSIVE,
1025 .help = "Exclusive file lock",
1028 .ival = "readwrite",
1029 .oval = FILE_LOCK_READWRITE,
1030 .help = "Read vs write lock",
1036 .lname = "Open directory",
1037 .type = FIO_OPT_STR_STORE,
1038 .off1 = td_var_offset(opendir),
1039 .cb = str_opendir_cb,
1040 .help = "Recursively add files from this directory and down",
1041 .category = FIO_OPT_C_FILE,
1042 .group = FIO_OPT_G_FILENAME,
1046 .lname = "Read/write",
1047 .alias = "readwrite",
1048 .type = FIO_OPT_STR,
1050 .off1 = td_var_offset(td_ddir),
1051 .help = "IO direction",
1053 .verify = rw_verify,
1054 .category = FIO_OPT_C_IO,
1055 .group = FIO_OPT_G_IO_BASIC,
1058 .oval = TD_DDIR_READ,
1059 .help = "Sequential read",
1062 .oval = TD_DDIR_WRITE,
1063 .help = "Sequential write",
1066 .oval = TD_DDIR_TRIM,
1067 .help = "Sequential trim",
1069 { .ival = "randread",
1070 .oval = TD_DDIR_RANDREAD,
1071 .help = "Random read",
1073 { .ival = "randwrite",
1074 .oval = TD_DDIR_RANDWRITE,
1075 .help = "Random write",
1077 { .ival = "randtrim",
1078 .oval = TD_DDIR_RANDTRIM,
1079 .help = "Random trim",
1083 .help = "Sequential read and write mix",
1085 { .ival = "readwrite",
1087 .help = "Sequential read and write mix",
1090 .oval = TD_DDIR_RANDRW,
1091 .help = "Random read and write mix"
1096 .name = "rw_sequencer",
1097 .lname = "RW Sequencer",
1098 .type = FIO_OPT_STR,
1099 .off1 = td_var_offset(rw_seq),
1100 .help = "IO offset generator modifier",
1101 .def = "sequential",
1102 .category = FIO_OPT_C_IO,
1103 .group = FIO_OPT_G_IO_BASIC,
1105 { .ival = "sequential",
1107 .help = "Generate sequential offsets",
1109 { .ival = "identical",
1110 .oval = RW_SEQ_IDENT,
1111 .help = "Generate identical offsets",
1118 .lname = "IO Engine",
1119 .type = FIO_OPT_STR_STORE,
1120 .off1 = td_var_offset(ioengine),
1121 .help = "IO engine to use",
1122 .def = FIO_PREFERRED_ENGINE,
1123 .category = FIO_OPT_C_IO,
1124 .group = FIO_OPT_G_IO_BASIC,
1127 .help = "Use read/write",
1130 .help = "Use pread/pwrite",
1133 .help = "Use readv/writev",
1135 #ifdef FIO_HAVE_LIBAIO
1137 .help = "Linux native asynchronous IO",
1140 #ifdef FIO_HAVE_POSIXAIO
1141 { .ival = "posixaio",
1142 .help = "POSIX asynchronous IO",
1145 #ifdef FIO_HAVE_SOLARISAIO
1146 { .ival = "solarisaio",
1147 .help = "Solaris native asynchronous IO",
1150 #ifdef FIO_HAVE_WINDOWSAIO
1151 { .ival = "windowsaio",
1152 .help = "Windows native asynchronous IO"
1156 .help = "Memory mapped IO"
1158 #ifdef FIO_HAVE_SPLICE
1160 .help = "splice/vmsplice based IO",
1162 { .ival = "netsplice",
1163 .help = "splice/vmsplice to/from the network",
1166 #ifdef FIO_HAVE_SGIO
1168 .help = "SCSI generic v3 IO",
1172 .help = "Testing engine (no data transfer)",
1175 .help = "Network IO",
1177 #ifdef FIO_HAVE_SYSLET
1178 { .ival = "syslet-rw",
1179 .help = "syslet enabled async pread/pwrite IO",
1183 .help = "CPU cycle burner engine",
1185 #ifdef FIO_HAVE_GUASI
1187 .help = "GUASI IO engine",
1190 #ifdef FIO_HAVE_BINJECT
1191 { .ival = "binject",
1192 .help = "binject direct inject block engine",
1195 #ifdef FIO_HAVE_RDMA
1197 .help = "RDMA IO engine",
1200 #ifdef FIO_HAVE_FUSION_AW
1201 { .ival = "fusion-aw-sync",
1202 .help = "Fusion-io atomic write engine",
1205 #ifdef FIO_HAVE_E4_ENG
1206 { .ival = "e4defrag",
1207 .help = "ext4 defrag engine",
1210 #ifdef FIO_HAVE_FALLOC_ENG
1212 .help = "fallocate() file based engine",
1215 { .ival = "external",
1216 .help = "Load external engine (append name)",
1222 .lname = "IO Depth",
1223 .type = FIO_OPT_INT,
1224 .off1 = td_var_offset(iodepth),
1225 .help = "Number of IO buffers to keep in flight",
1229 .category = FIO_OPT_C_IO,
1230 .group = FIO_OPT_G_IO_BASIC,
1233 .name = "iodepth_batch",
1234 .lname = "IO Depth batch",
1235 .alias = "iodepth_batch_submit",
1236 .type = FIO_OPT_INT,
1237 .off1 = td_var_offset(iodepth_batch),
1238 .help = "Number of IO buffers to submit in one go",
1239 .parent = "iodepth",
1244 .category = FIO_OPT_C_IO,
1245 .group = FIO_OPT_G_IO_BASIC,
1248 .name = "iodepth_batch_complete",
1249 .lname = "IO Depth batch complete",
1250 .type = FIO_OPT_INT,
1251 .off1 = td_var_offset(iodepth_batch_complete),
1252 .help = "Number of IO buffers to retrieve in one go",
1253 .parent = "iodepth",
1258 .category = FIO_OPT_C_IO,
1259 .group = FIO_OPT_G_IO_BASIC,
1262 .name = "iodepth_low",
1263 .lname = "IO Depth batch low",
1264 .type = FIO_OPT_INT,
1265 .off1 = td_var_offset(iodepth_low),
1266 .help = "Low water mark for queuing depth",
1267 .parent = "iodepth",
1270 .category = FIO_OPT_C_IO,
1271 .group = FIO_OPT_G_IO_BASIC,
1276 .type = FIO_OPT_STR_VAL,
1278 .help = "Total size of device or files",
1279 .interval = 1024 * 1024,
1280 .category = FIO_OPT_C_IO,
1281 .group = FIO_OPT_G_INVALID,
1284 .name = "fill_device",
1285 .lname = "Fill device",
1287 .type = FIO_OPT_BOOL,
1288 .off1 = td_var_offset(fill_device),
1289 .help = "Write until an ENOSPC error occurs",
1291 .category = FIO_OPT_C_FILE,
1292 .group = FIO_OPT_G_INVALID,
1296 .lname = "File size",
1297 .type = FIO_OPT_STR_VAL,
1298 .off1 = td_var_offset(file_size_low),
1299 .off2 = td_var_offset(file_size_high),
1301 .help = "Size of individual files",
1302 .interval = 1024 * 1024,
1303 .category = FIO_OPT_C_FILE,
1304 .group = FIO_OPT_G_INVALID,
1308 .lname = "IO offset",
1309 .alias = "fileoffset",
1310 .type = FIO_OPT_STR_VAL,
1311 .off1 = td_var_offset(start_offset),
1312 .help = "Start IO from this offset",
1314 .interval = 1024 * 1024,
1315 .category = FIO_OPT_C_IO,
1316 .group = FIO_OPT_G_INVALID,
1319 .name = "offset_increment",
1320 .lname = "IO offset increment",
1321 .type = FIO_OPT_STR_VAL,
1322 .off1 = td_var_offset(offset_increment),
1323 .help = "What is the increment from one offset to the next",
1327 .interval = 1024 * 1024,
1328 .category = FIO_OPT_C_IO,
1329 .group = FIO_OPT_G_INVALID,
1333 .lname = "Block size",
1334 .alias = "blocksize",
1335 .type = FIO_OPT_INT,
1336 .off1 = td_var_offset(bs[DDIR_READ]),
1337 .off2 = td_var_offset(bs[DDIR_WRITE]),
1338 .off3 = td_var_offset(bs[DDIR_TRIM]),
1340 .help = "Block size unit",
1345 .category = FIO_OPT_C_IO,
1346 .group = FIO_OPT_G_INVALID,
1350 .lname = "Block size align",
1351 .alias = "blockalign",
1352 .type = FIO_OPT_INT,
1353 .off1 = td_var_offset(ba[DDIR_READ]),
1354 .off2 = td_var_offset(ba[DDIR_WRITE]),
1355 .off3 = td_var_offset(ba[DDIR_TRIM]),
1357 .help = "IO block offset alignment",
1361 .category = FIO_OPT_C_IO,
1362 .group = FIO_OPT_G_INVALID,
1366 .lname = "Block size range",
1367 .alias = "blocksize_range",
1368 .type = FIO_OPT_RANGE,
1369 .off1 = td_var_offset(min_bs[DDIR_READ]),
1370 .off2 = td_var_offset(max_bs[DDIR_READ]),
1371 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
1372 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
1373 .off5 = td_var_offset(min_bs[DDIR_TRIM]),
1374 .off6 = td_var_offset(max_bs[DDIR_TRIM]),
1376 .help = "Set block size range (in more detail than bs)",
1380 .category = FIO_OPT_C_IO,
1381 .group = FIO_OPT_G_INVALID,
1385 .lname = "Block size split",
1386 .type = FIO_OPT_STR,
1387 .cb = str_bssplit_cb,
1388 .help = "Set a specific mix of block sizes",
1391 .category = FIO_OPT_C_IO,
1392 .group = FIO_OPT_G_INVALID,
1395 .name = "bs_unaligned",
1396 .lname = "Block size unaligned",
1397 .alias = "blocksize_unaligned",
1398 .type = FIO_OPT_STR_SET,
1399 .off1 = td_var_offset(bs_unaligned),
1400 .help = "Don't sector align IO buffer sizes",
1403 .category = FIO_OPT_C_IO,
1404 .group = FIO_OPT_G_INVALID,
1407 .name = "randrepeat",
1408 .lname = "Random repeatable",
1409 .type = FIO_OPT_BOOL,
1410 .off1 = td_var_offset(rand_repeatable),
1411 .help = "Use repeatable random IO pattern",
1415 .category = FIO_OPT_C_IO,
1416 .group = FIO_OPT_G_RANDOM,
1419 .name = "use_os_rand",
1420 .lname = "Use OS random",
1421 .type = FIO_OPT_BOOL,
1422 .off1 = td_var_offset(use_os_rand),
1423 .help = "Set to use OS random generator",
1427 .category = FIO_OPT_C_IO,
1428 .group = FIO_OPT_G_RANDOM,
1431 .name = "norandommap",
1432 .lname = "No randommap",
1433 .type = FIO_OPT_STR_SET,
1434 .off1 = td_var_offset(norandommap),
1435 .help = "Accept potential duplicate random blocks",
1439 .category = FIO_OPT_C_IO,
1440 .group = FIO_OPT_G_RANDOM,
1443 .name = "softrandommap",
1444 .lname = "Soft randommap",
1445 .type = FIO_OPT_BOOL,
1446 .off1 = td_var_offset(softrandommap),
1447 .help = "Set norandommap if randommap allocation fails",
1448 .parent = "norandommap",
1451 .category = FIO_OPT_C_IO,
1452 .group = FIO_OPT_G_RANDOM,
1456 .lname = "Number of files",
1457 .alias = "nr_files",
1458 .type = FIO_OPT_INT,
1459 .off1 = td_var_offset(nr_files),
1460 .help = "Split job workload between this number of files",
1463 .category = FIO_OPT_C_FILE,
1464 .group = FIO_OPT_G_INVALID,
1467 .name = "openfiles",
1468 .lname = "Number of open files",
1469 .type = FIO_OPT_INT,
1470 .off1 = td_var_offset(open_files),
1471 .help = "Number of files to keep open at the same time",
1472 .category = FIO_OPT_C_FILE,
1473 .group = FIO_OPT_G_INVALID,
1476 .name = "file_service_type",
1477 .lname = "File service type",
1478 .type = FIO_OPT_STR,
1480 .off1 = td_var_offset(file_service_type),
1481 .help = "How to select which file to service next",
1482 .def = "roundrobin",
1483 .category = FIO_OPT_C_FILE,
1484 .group = FIO_OPT_G_INVALID,
1487 .oval = FIO_FSERVICE_RANDOM,
1488 .help = "Choose a file at random",
1490 { .ival = "roundrobin",
1491 .oval = FIO_FSERVICE_RR,
1492 .help = "Round robin select files",
1494 { .ival = "sequential",
1495 .oval = FIO_FSERVICE_SEQ,
1496 .help = "Finish one file before moving to the next",
1499 .parent = "nrfiles",
1502 #ifdef FIO_HAVE_FALLOCATE
1504 .name = "fallocate",
1505 .lname = "Fallocate",
1506 .type = FIO_OPT_STR,
1507 .off1 = td_var_offset(fallocate_mode),
1508 .help = "Whether pre-allocation is performed when laying out files",
1510 .category = FIO_OPT_C_FILE,
1511 .group = FIO_OPT_G_INVALID,
1514 .oval = FIO_FALLOCATE_NONE,
1515 .help = "Do not pre-allocate space",
1518 .oval = FIO_FALLOCATE_POSIX,
1519 .help = "Use posix_fallocate()",
1521 #ifdef FIO_HAVE_LINUX_FALLOCATE
1523 .oval = FIO_FALLOCATE_KEEP_SIZE,
1524 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
1527 /* Compatibility with former boolean values */
1529 .oval = FIO_FALLOCATE_NONE,
1530 .help = "Alias for 'none'",
1533 .oval = FIO_FALLOCATE_POSIX,
1534 .help = "Alias for 'posix'",
1538 #endif /* FIO_HAVE_FALLOCATE */
1540 .name = "fadvise_hint",
1541 .lname = "Fadvise hint",
1542 .type = FIO_OPT_BOOL,
1543 .off1 = td_var_offset(fadvise_hint),
1544 .help = "Use fadvise() to advise the kernel on IO pattern",
1546 .category = FIO_OPT_C_FILE,
1547 .group = FIO_OPT_G_INVALID,
1552 .type = FIO_OPT_INT,
1553 .off1 = td_var_offset(fsync_blocks),
1554 .help = "Issue fsync for writes every given number of blocks",
1557 .category = FIO_OPT_C_FILE,
1558 .group = FIO_OPT_G_INVALID,
1561 .name = "fdatasync",
1562 .lname = "Fdatasync",
1563 .type = FIO_OPT_INT,
1564 .off1 = td_var_offset(fdatasync_blocks),
1565 .help = "Issue fdatasync for writes every given number of blocks",
1568 .category = FIO_OPT_C_FILE,
1569 .group = FIO_OPT_G_INVALID,
1572 .name = "write_barrier",
1573 .lname = "Write barrier",
1574 .type = FIO_OPT_INT,
1575 .off1 = td_var_offset(barrier_blocks),
1576 .help = "Make every Nth write a barrier write",
1579 .category = FIO_OPT_C_IO,
1580 .group = FIO_OPT_G_INVALID,
1582 #ifdef FIO_HAVE_SYNC_FILE_RANGE
1584 .name = "sync_file_range",
1585 .lname = "Sync file range",
1587 { .ival = "wait_before",
1588 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
1589 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
1593 .oval = SYNC_FILE_RANGE_WRITE,
1594 .help = "SYNC_FILE_RANGE_WRITE",
1598 .ival = "wait_after",
1599 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
1600 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
1604 .type = FIO_OPT_STR_MULTI,
1606 .off1 = td_var_offset(sync_file_range),
1607 .help = "Use sync_file_range()",
1608 .category = FIO_OPT_C_FILE,
1609 .group = FIO_OPT_G_INVALID,
1614 .lname = "Direct I/O",
1615 .type = FIO_OPT_BOOL,
1616 .off1 = td_var_offset(odirect),
1617 .help = "Use O_DIRECT IO (negates buffered)",
1619 .inverse = "buffered",
1620 .category = FIO_OPT_C_IO,
1621 .group = FIO_OPT_G_IO_TYPE,
1625 .lname = "Buffered I/O",
1626 .type = FIO_OPT_BOOL,
1627 .off1 = td_var_offset(odirect),
1629 .help = "Use buffered IO (negates direct)",
1631 .inverse = "direct",
1632 .category = FIO_OPT_C_IO,
1633 .group = FIO_OPT_G_IO_TYPE,
1636 .name = "overwrite",
1637 .lname = "Overwrite",
1638 .type = FIO_OPT_BOOL,
1639 .off1 = td_var_offset(overwrite),
1640 .help = "When writing, set whether to overwrite current data",
1642 .category = FIO_OPT_C_FILE,
1643 .group = FIO_OPT_G_INVALID,
1648 .type = FIO_OPT_INT,
1649 .off1 = td_var_offset(loops),
1650 .help = "Number of times to run the job",
1653 .category = FIO_OPT_C_GENERAL,
1654 .group = FIO_OPT_G_RUNTIME,
1658 .lname = "Number of jobs",
1659 .type = FIO_OPT_INT,
1660 .off1 = td_var_offset(numjobs),
1661 .help = "Duplicate this job this many times",
1664 .category = FIO_OPT_C_GENERAL,
1665 .group = FIO_OPT_G_RUNTIME,
1668 .name = "startdelay",
1669 .lname = "Start delay",
1670 .type = FIO_OPT_STR_VAL_TIME,
1671 .off1 = td_var_offset(start_delay),
1672 .help = "Only start job when this period has passed",
1674 .category = FIO_OPT_C_GENERAL,
1675 .group = FIO_OPT_G_RUNTIME,
1681 .type = FIO_OPT_STR_VAL_TIME,
1682 .off1 = td_var_offset(timeout),
1683 .help = "Stop workload when this amount of time has passed",
1685 .category = FIO_OPT_C_GENERAL,
1686 .group = FIO_OPT_G_RUNTIME,
1689 .name = "time_based",
1690 .lname = "Time based",
1691 .type = FIO_OPT_STR_SET,
1692 .off1 = td_var_offset(time_based),
1693 .help = "Keep running until runtime/timeout is met",
1694 .category = FIO_OPT_C_GENERAL,
1695 .group = FIO_OPT_G_RUNTIME,
1698 .name = "ramp_time",
1699 .lname = "Ramp time",
1700 .type = FIO_OPT_STR_VAL_TIME,
1701 .off1 = td_var_offset(ramp_time),
1702 .help = "Ramp up time before measuring performance",
1703 .category = FIO_OPT_C_GENERAL,
1704 .group = FIO_OPT_G_RUNTIME,
1707 .name = "clocksource",
1708 .lname = "Clock source",
1709 .type = FIO_OPT_STR,
1710 .cb = fio_clock_source_cb,
1711 .off1 = td_var_offset(clocksource),
1712 .help = "What type of timing source to use",
1713 .category = FIO_OPT_C_GENERAL,
1714 .group = FIO_OPT_G_CLOCK,
1716 { .ival = "gettimeofday",
1718 .help = "Use gettimeofday(2) for timing",
1720 { .ival = "clock_gettime",
1721 .oval = CS_CGETTIME,
1722 .help = "Use clock_gettime(2) for timing",
1724 #ifdef ARCH_HAVE_CPU_CLOCK
1726 .oval = CS_CPUCLOCK,
1727 .help = "Use CPU private clock",
1735 .lname = "I/O Memory",
1736 .type = FIO_OPT_STR,
1738 .off1 = td_var_offset(mem_type),
1739 .help = "Backing type for IO buffers",
1741 .category = FIO_OPT_C_IO,
1742 .group = FIO_OPT_G_INVALID,
1746 .help = "Use malloc(3) for IO buffers",
1750 .help = "Use shared memory segments for IO buffers",
1752 #ifdef FIO_HAVE_HUGETLB
1753 { .ival = "shmhuge",
1754 .oval = MEM_SHMHUGE,
1755 .help = "Like shm, but use huge pages",
1760 .help = "Use mmap(2) (file or anon) for IO buffers",
1762 #ifdef FIO_HAVE_HUGETLB
1763 { .ival = "mmaphuge",
1764 .oval = MEM_MMAPHUGE,
1765 .help = "Like mmap, but use huge pages",
1771 .name = "iomem_align",
1772 .alias = "mem_align",
1773 .lname = "I/O memory alignment",
1774 .type = FIO_OPT_INT,
1775 .off1 = td_var_offset(mem_align),
1777 .help = "IO memory buffer offset alignment",
1781 .category = FIO_OPT_C_IO,
1782 .group = FIO_OPT_G_INVALID,
1787 .type = FIO_OPT_STR,
1788 .off1 = td_var_offset(verify),
1789 .help = "Verify data written",
1791 .category = FIO_OPT_C_IO,
1792 .group = FIO_OPT_G_VERIFY,
1795 .oval = VERIFY_NONE,
1796 .help = "Don't do IO verification",
1800 .help = "Use md5 checksums for verification",
1803 .oval = VERIFY_CRC64,
1804 .help = "Use crc64 checksums for verification",
1807 .oval = VERIFY_CRC32,
1808 .help = "Use crc32 checksums for verification",
1810 { .ival = "crc32c-intel",
1811 .oval = VERIFY_CRC32C,
1812 .help = "Use crc32c checksums for verification (hw assisted, if available)",
1815 .oval = VERIFY_CRC32C,
1816 .help = "Use crc32c checksums for verification (hw assisted, if available)",
1819 .oval = VERIFY_CRC16,
1820 .help = "Use crc16 checksums for verification",
1823 .oval = VERIFY_CRC7,
1824 .help = "Use crc7 checksums for verification",
1827 .oval = VERIFY_SHA1,
1828 .help = "Use sha1 checksums for verification",
1831 .oval = VERIFY_SHA256,
1832 .help = "Use sha256 checksums for verification",
1835 .oval = VERIFY_SHA512,
1836 .help = "Use sha512 checksums for verification",
1839 .oval = VERIFY_META,
1840 .help = "Use io information",
1844 .oval = VERIFY_NULL,
1845 .help = "Pretend to verify",
1850 .name = "do_verify",
1851 .lname = "Perform verify step",
1852 .type = FIO_OPT_BOOL,
1853 .off1 = td_var_offset(do_verify),
1854 .help = "Run verification stage after write",
1858 .category = FIO_OPT_C_IO,
1859 .group = FIO_OPT_G_VERIFY,
1862 .name = "verifysort",
1863 .lname = "Verify sort",
1864 .type = FIO_OPT_BOOL,
1865 .off1 = td_var_offset(verifysort),
1866 .help = "Sort written verify blocks for read back",
1870 .category = FIO_OPT_C_IO,
1871 .group = FIO_OPT_G_VERIFY,
1874 .name = "verify_interval",
1875 .lname = "Verify interval",
1876 .type = FIO_OPT_INT,
1877 .off1 = td_var_offset(verify_interval),
1878 .minval = 2 * sizeof(struct verify_header),
1879 .help = "Store verify buffer header every N bytes",
1882 .interval = 2 * sizeof(struct verify_header),
1883 .category = FIO_OPT_C_IO,
1884 .group = FIO_OPT_G_VERIFY,
1887 .name = "verify_offset",
1888 .lname = "Verify offset",
1889 .type = FIO_OPT_INT,
1890 .help = "Offset verify header location by N bytes",
1891 .off1 = td_var_offset(verify_offset),
1892 .minval = sizeof(struct verify_header),
1895 .category = FIO_OPT_C_IO,
1896 .group = FIO_OPT_G_VERIFY,
1899 .name = "verify_pattern",
1900 .lname = "Verify pattern",
1901 .type = FIO_OPT_STR,
1902 .cb = str_verify_pattern_cb,
1903 .help = "Fill pattern for IO buffers",
1906 .category = FIO_OPT_C_IO,
1907 .group = FIO_OPT_G_VERIFY,
1910 .name = "verify_fatal",
1911 .lname = "Verify fatal",
1912 .type = FIO_OPT_BOOL,
1913 .off1 = td_var_offset(verify_fatal),
1915 .help = "Exit on a single verify failure, don't continue",
1918 .category = FIO_OPT_C_IO,
1919 .group = FIO_OPT_G_VERIFY,
1922 .name = "verify_dump",
1923 .lname = "Verify dump",
1924 .type = FIO_OPT_BOOL,
1925 .off1 = td_var_offset(verify_dump),
1927 .help = "Dump contents of good and bad blocks on failure",
1930 .category = FIO_OPT_C_IO,
1931 .group = FIO_OPT_G_VERIFY,
1934 .name = "verify_async",
1935 .lname = "Verify asynchronously",
1936 .type = FIO_OPT_INT,
1937 .off1 = td_var_offset(verify_async),
1939 .help = "Number of async verifier threads to use",
1942 .category = FIO_OPT_C_IO,
1943 .group = FIO_OPT_G_VERIFY,
1946 .name = "verify_backlog",
1947 .lname = "Verify backlog",
1948 .type = FIO_OPT_STR_VAL,
1949 .off1 = td_var_offset(verify_backlog),
1950 .help = "Verify after this number of blocks are written",
1953 .category = FIO_OPT_C_IO,
1954 .group = FIO_OPT_G_VERIFY,
1957 .name = "verify_backlog_batch",
1958 .lname = "Verify backlog batch",
1959 .type = FIO_OPT_INT,
1960 .off1 = td_var_offset(verify_batch),
1961 .help = "Verify this number of IO blocks",
1964 .category = FIO_OPT_C_IO,
1965 .group = FIO_OPT_G_VERIFY,
1967 #ifdef FIO_HAVE_CPU_AFFINITY
1969 .name = "verify_async_cpus",
1970 .lname = "Async verify CPUs",
1971 .type = FIO_OPT_STR,
1972 .cb = str_verify_cpus_allowed_cb,
1973 .help = "Set CPUs allowed for async verify threads",
1974 .parent = "verify_async",
1976 .category = FIO_OPT_C_IO,
1977 .group = FIO_OPT_G_VERIFY,
1980 #ifdef FIO_HAVE_TRIM
1982 .name = "trim_percentage",
1983 .lname = "Trim percentage",
1984 .type = FIO_OPT_INT,
1985 .off1 = td_var_offset(trim_percentage),
1988 .help = "Number of verify blocks to discard/trim",
1993 .category = FIO_OPT_C_IO,
1994 .group = FIO_OPT_G_TRIM,
1997 .name = "trim_verify_zero",
1998 .lname = "Verify trim zero",
1999 .type = FIO_OPT_BOOL,
2000 .help = "Verify that trim/discarded blocks are returned as zeroes",
2001 .off1 = td_var_offset(trim_zero),
2002 .parent = "trim_percentage",
2005 .category = FIO_OPT_C_IO,
2006 .group = FIO_OPT_G_TRIM,
2009 .name = "trim_backlog",
2010 .lname = "Trim backlog",
2011 .type = FIO_OPT_STR_VAL,
2012 .off1 = td_var_offset(trim_backlog),
2013 .help = "Trim after this number of blocks are written",
2014 .parent = "trim_percentage",
2017 .category = FIO_OPT_C_IO,
2018 .group = FIO_OPT_G_TRIM,
2021 .name = "trim_backlog_batch",
2022 .lname = "Trim backlog batch",
2023 .type = FIO_OPT_INT,
2024 .off1 = td_var_offset(trim_batch),
2025 .help = "Trim this number of IO blocks",
2026 .parent = "trim_percentage",
2029 .category = FIO_OPT_C_IO,
2030 .group = FIO_OPT_G_TRIM,
2034 .name = "write_iolog",
2035 .lname = "Write I/O log",
2036 .type = FIO_OPT_STR_STORE,
2037 .off1 = td_var_offset(write_iolog_file),
2038 .help = "Store IO pattern to file",
2039 .category = FIO_OPT_C_IO,
2040 .group = FIO_OPT_G_IOLOG,
2043 .name = "read_iolog",
2044 .lname = "Read I/O log",
2045 .type = FIO_OPT_STR_STORE,
2046 .off1 = td_var_offset(read_iolog_file),
2047 .help = "Playback IO pattern from file",
2048 .category = FIO_OPT_C_IO,
2049 .group = FIO_OPT_G_IOLOG,
2052 .name = "replay_no_stall",
2053 .lname = "Don't stall on replay",
2054 .type = FIO_OPT_BOOL,
2055 .off1 = td_var_offset(no_stall),
2057 .parent = "read_iolog",
2059 .help = "Playback IO pattern file as fast as possible without stalls",
2060 .category = FIO_OPT_C_IO,
2061 .group = FIO_OPT_G_IOLOG,
2064 .name = "replay_redirect",
2065 .lname = "Redirect device for replay",
2066 .type = FIO_OPT_STR_STORE,
2067 .off1 = td_var_offset(replay_redirect),
2068 .parent = "read_iolog",
2070 .help = "Replay all I/O onto this device, regardless of trace device",
2071 .category = FIO_OPT_C_IO,
2072 .group = FIO_OPT_G_IOLOG,
2075 .name = "exec_prerun",
2076 .lname = "Pre-execute runnable",
2077 .type = FIO_OPT_STR_STORE,
2078 .off1 = td_var_offset(exec_prerun),
2079 .help = "Execute this file prior to running job",
2080 .category = FIO_OPT_C_GENERAL,
2081 .group = FIO_OPT_G_INVALID,
2084 .name = "exec_postrun",
2085 .lname = "Post-execute runnable",
2086 .type = FIO_OPT_STR_STORE,
2087 .off1 = td_var_offset(exec_postrun),
2088 .help = "Execute this file after running job",
2089 .category = FIO_OPT_C_GENERAL,
2090 .group = FIO_OPT_G_INVALID,
2092 #ifdef FIO_HAVE_IOSCHED_SWITCH
2094 .name = "ioscheduler",
2095 .lname = "I/O scheduler",
2096 .type = FIO_OPT_STR_STORE,
2097 .off1 = td_var_offset(ioscheduler),
2098 .help = "Use this IO scheduler on the backing device",
2099 .category = FIO_OPT_C_FILE,
2100 .group = FIO_OPT_G_INVALID,
2105 .lname = "Zone size",
2106 .type = FIO_OPT_STR_VAL,
2107 .off1 = td_var_offset(zone_size),
2108 .help = "Amount of data to read per zone",
2110 .interval = 1024 * 1024,
2111 .category = FIO_OPT_C_IO,
2112 .group = FIO_OPT_G_ZONE,
2115 .name = "zonerange",
2116 .lname = "Zone range",
2117 .type = FIO_OPT_STR_VAL,
2118 .off1 = td_var_offset(zone_range),
2119 .help = "Give size of an IO zone",
2121 .interval = 1024 * 1024,
2122 .category = FIO_OPT_C_IO,
2123 .group = FIO_OPT_G_ZONE,
2127 .lname = "Zone skip",
2128 .type = FIO_OPT_STR_VAL,
2129 .off1 = td_var_offset(zone_skip),
2130 .help = "Space between IO zones",
2132 .interval = 1024 * 1024,
2133 .category = FIO_OPT_C_IO,
2134 .group = FIO_OPT_G_ZONE,
2138 .lname = "Lock memory",
2139 .type = FIO_OPT_STR_VAL,
2140 .off1 = td_var_offset(lockmem),
2141 .help = "Lock down this amount of memory",
2143 .interval = 1024 * 1024,
2144 .category = FIO_OPT_C_GENERAL,
2145 .group = FIO_OPT_G_INVALID,
2148 .name = "rwmixread",
2149 .lname = "Read/write mix read",
2150 .type = FIO_OPT_INT,
2151 .cb = str_rwmix_read_cb,
2153 .help = "Percentage of mixed workload that is reads",
2156 .inverse = "rwmixwrite",
2157 .category = FIO_OPT_C_IO,
2158 .group = FIO_OPT_G_RWMIX,
2161 .name = "rwmixwrite",
2162 .lname = "Read/write mix write",
2163 .type = FIO_OPT_INT,
2164 .cb = str_rwmix_write_cb,
2166 .help = "Percentage of mixed workload that is writes",
2169 .inverse = "rwmixread",
2170 .category = FIO_OPT_C_IO,
2171 .group = FIO_OPT_G_RWMIX,
2174 .name = "rwmixcycle",
2175 .lname = "Read/write mix cycle",
2176 .type = FIO_OPT_DEPRECATED,
2177 .category = FIO_OPT_C_IO,
2178 .group = FIO_OPT_G_RWMIX,
2183 .type = FIO_OPT_INT,
2184 .off1 = td_var_offset(nice),
2185 .help = "Set job CPU nice value",
2190 .category = FIO_OPT_C_GENERAL,
2191 .group = FIO_OPT_G_CRED,
2193 #ifdef FIO_HAVE_IOPRIO
2196 .lname = "I/O nice priority",
2197 .type = FIO_OPT_INT,
2198 .off1 = td_var_offset(ioprio),
2199 .help = "Set job IO priority value",
2203 .category = FIO_OPT_C_GENERAL,
2204 .group = FIO_OPT_G_CRED,
2207 .name = "prioclass",
2208 .lname = "I/O nice priority class",
2209 .type = FIO_OPT_INT,
2210 .off1 = td_var_offset(ioprio_class),
2211 .help = "Set job IO priority class",
2215 .category = FIO_OPT_C_GENERAL,
2216 .group = FIO_OPT_G_CRED,
2220 .name = "thinktime",
2221 .lname = "Thinktime",
2222 .type = FIO_OPT_INT,
2223 .off1 = td_var_offset(thinktime),
2224 .help = "Idle time between IO buffers (usec)",
2226 .category = FIO_OPT_C_IO,
2227 .group = FIO_OPT_G_THINKTIME,
2230 .name = "thinktime_spin",
2231 .lname = "Thinktime spin",
2232 .type = FIO_OPT_INT,
2233 .off1 = td_var_offset(thinktime_spin),
2234 .help = "Start think time by spinning this amount (usec)",
2236 .parent = "thinktime",
2238 .category = FIO_OPT_C_IO,
2239 .group = FIO_OPT_G_THINKTIME,
2242 .name = "thinktime_blocks",
2243 .lname = "Thinktime blocks",
2244 .type = FIO_OPT_INT,
2245 .off1 = td_var_offset(thinktime_blocks),
2246 .help = "IO buffer period between 'thinktime'",
2248 .parent = "thinktime",
2250 .category = FIO_OPT_C_IO,
2251 .group = FIO_OPT_G_THINKTIME,
2255 .lname = "I/O rate",
2256 .type = FIO_OPT_INT,
2257 .off1 = td_var_offset(rate[DDIR_READ]),
2258 .off2 = td_var_offset(rate[DDIR_WRITE]),
2259 .off3 = td_var_offset(rate[DDIR_TRIM]),
2260 .help = "Set bandwidth rate",
2261 .category = FIO_OPT_C_IO,
2262 .group = FIO_OPT_G_RATE,
2266 .lname = "I/O min rate",
2267 .type = FIO_OPT_INT,
2268 .off1 = td_var_offset(ratemin[DDIR_READ]),
2269 .off2 = td_var_offset(ratemin[DDIR_WRITE]),
2270 .off3 = td_var_offset(ratemin[DDIR_TRIM]),
2271 .help = "Job must meet this rate or it will be shutdown",
2274 .category = FIO_OPT_C_IO,
2275 .group = FIO_OPT_G_RATE,
2278 .name = "rate_iops",
2279 .lname = "I/O rate IOPS",
2280 .type = FIO_OPT_INT,
2281 .off1 = td_var_offset(rate_iops[DDIR_READ]),
2282 .off2 = td_var_offset(rate_iops[DDIR_WRITE]),
2283 .off3 = td_var_offset(rate_iops[DDIR_TRIM]),
2284 .help = "Limit IO used to this number of IO operations/sec",
2286 .category = FIO_OPT_C_IO,
2287 .group = FIO_OPT_G_RATE,
2290 .name = "rate_iops_min",
2291 .lname = "I/O min rate IOPS",
2292 .type = FIO_OPT_INT,
2293 .off1 = td_var_offset(rate_iops_min[DDIR_READ]),
2294 .off2 = td_var_offset(rate_iops_min[DDIR_WRITE]),
2295 .off3 = td_var_offset(rate_iops_min[DDIR_TRIM]),
2296 .help = "Job must meet this rate or it will be shut down",
2297 .parent = "rate_iops",
2299 .category = FIO_OPT_C_IO,
2300 .group = FIO_OPT_G_RATE,
2303 .name = "ratecycle",
2304 .lname = "I/O rate cycle",
2305 .type = FIO_OPT_INT,
2306 .off1 = td_var_offset(ratecycle),
2307 .help = "Window average for rate limits (msec)",
2311 .category = FIO_OPT_C_IO,
2312 .group = FIO_OPT_G_RATE,
2315 .name = "invalidate",
2316 .lname = "Cache invalidate",
2317 .type = FIO_OPT_BOOL,
2318 .off1 = td_var_offset(invalidate_cache),
2319 .help = "Invalidate buffer/page cache prior to running job",
2321 .category = FIO_OPT_C_IO,
2322 .group = FIO_OPT_G_IO_TYPE,
2326 .lname = "Synchronous I/O",
2327 .type = FIO_OPT_BOOL,
2328 .off1 = td_var_offset(sync_io),
2329 .help = "Use O_SYNC for buffered writes",
2331 .parent = "buffered",
2333 .category = FIO_OPT_C_IO,
2334 .group = FIO_OPT_G_IO_TYPE,
2337 .name = "create_serialize",
2338 .lname = "Create serialize",
2339 .type = FIO_OPT_BOOL,
2340 .off1 = td_var_offset(create_serialize),
2341 .help = "Serialize creating of job files",
2343 .category = FIO_OPT_C_FILE,
2344 .group = FIO_OPT_G_INVALID,
2347 .name = "create_fsync",
2348 .lname = "Create fsync",
2349 .type = FIO_OPT_BOOL,
2350 .off1 = td_var_offset(create_fsync),
2351 .help = "fsync file after creation",
2353 .category = FIO_OPT_C_FILE,
2354 .group = FIO_OPT_G_INVALID,
2357 .name = "create_on_open",
2358 .lname = "Create on open",
2359 .type = FIO_OPT_BOOL,
2360 .off1 = td_var_offset(create_on_open),
2361 .help = "Create files when they are opened for IO",
2363 .category = FIO_OPT_C_FILE,
2364 .group = FIO_OPT_G_INVALID,
2367 .name = "create_only",
2368 .type = FIO_OPT_BOOL,
2369 .off1 = td_var_offset(create_only),
2370 .help = "Only perform file creation phase",
2371 .category = FIO_OPT_C_FILE,
2376 .lname = "Pre-read files",
2377 .type = FIO_OPT_BOOL,
2378 .off1 = td_var_offset(pre_read),
2379 .help = "Pre-read files before starting official testing",
2381 .category = FIO_OPT_C_FILE,
2382 .group = FIO_OPT_G_INVALID,
2384 #ifdef FIO_HAVE_CPU_AFFINITY
2387 .lname = "CPU mask",
2388 .type = FIO_OPT_INT,
2389 .cb = str_cpumask_cb,
2390 .help = "CPU affinity mask",
2391 .category = FIO_OPT_C_GENERAL,
2392 .group = FIO_OPT_G_CRED,
2395 .name = "cpus_allowed",
2396 .lname = "CPUs allowed",
2397 .type = FIO_OPT_STR,
2398 .cb = str_cpus_allowed_cb,
2399 .help = "Set CPUs allowed",
2400 .category = FIO_OPT_C_GENERAL,
2401 .group = FIO_OPT_G_CRED,
2405 .name = "end_fsync",
2406 .lname = "End fsync",
2407 .type = FIO_OPT_BOOL,
2408 .off1 = td_var_offset(end_fsync),
2409 .help = "Include fsync at the end of job",
2411 .category = FIO_OPT_C_FILE,
2412 .group = FIO_OPT_G_INVALID,
2415 .name = "fsync_on_close",
2416 .lname = "Fsync on close",
2417 .type = FIO_OPT_BOOL,
2418 .off1 = td_var_offset(fsync_on_close),
2419 .help = "fsync files on close",
2421 .category = FIO_OPT_C_FILE,
2422 .group = FIO_OPT_G_INVALID,
2426 .lname = "Unlink file",
2427 .type = FIO_OPT_BOOL,
2428 .off1 = td_var_offset(unlink),
2429 .help = "Unlink created files after job has completed",
2431 .category = FIO_OPT_C_FILE,
2432 .group = FIO_OPT_G_INVALID,
2436 .lname = "Exit-all on terminate",
2437 .type = FIO_OPT_STR_SET,
2438 .cb = str_exitall_cb,
2439 .help = "Terminate all jobs when one exits",
2440 .category = FIO_OPT_C_GENERAL,
2441 .group = FIO_OPT_G_PROCESS,
2444 .name = "stonewall",
2445 .lname = "Wait for previous",
2446 .alias = "wait_for_previous",
2447 .type = FIO_OPT_STR_SET,
2448 .off1 = td_var_offset(stonewall),
2449 .help = "Insert a hard barrier between this job and previous",
2450 .category = FIO_OPT_C_GENERAL,
2451 .group = FIO_OPT_G_PROCESS,
2454 .name = "new_group",
2455 .lname = "New group",
2456 .type = FIO_OPT_STR_SET,
2457 .off1 = td_var_offset(new_group),
2458 .help = "Mark the start of a new group (for reporting)",
2459 .category = FIO_OPT_C_GENERAL,
2460 .group = FIO_OPT_G_PROCESS,
2465 .type = FIO_OPT_STR_SET,
2466 .off1 = td_var_offset(use_thread),
2467 .help = "Use threads instead of processes",
2468 .category = FIO_OPT_C_GENERAL,
2469 .group = FIO_OPT_G_PROCESS,
2472 .name = "write_bw_log",
2473 .lname = "Write bandwidth log",
2474 .type = FIO_OPT_STR_STORE,
2475 .off1 = td_var_offset(bw_log_file),
2476 .help = "Write log of bandwidth during run",
2477 .category = FIO_OPT_C_LOG,
2478 .group = FIO_OPT_G_INVALID,
2481 .name = "write_lat_log",
2482 .lname = "Write latency log",
2483 .type = FIO_OPT_STR_STORE,
2484 .off1 = td_var_offset(lat_log_file),
2485 .help = "Write log of latency during run",
2486 .category = FIO_OPT_C_LOG,
2487 .group = FIO_OPT_G_INVALID,
2490 .name = "write_iops_log",
2491 .lname = "Write IOPS log",
2492 .type = FIO_OPT_STR,
2493 .off1 = td_var_offset(iops_log_file),
2494 .help = "Write log of IOPS during run",
2495 .category = FIO_OPT_C_LOG,
2496 .group = FIO_OPT_G_INVALID,
2499 .name = "log_avg_msec",
2500 .lname = "Log averaging (msec)",
2501 .type = FIO_OPT_INT,
2502 .off1 = td_var_offset(log_avg_msec),
2503 .help = "Average bw/iops/lat logs over this period of time",
2505 .category = FIO_OPT_C_LOG,
2506 .group = FIO_OPT_G_INVALID,
2509 .name = "bwavgtime",
2510 .lname = "Bandwidth average time",
2511 .type = FIO_OPT_INT,
2512 .off1 = td_var_offset(bw_avg_time),
2513 .help = "Time window over which to calculate bandwidth"
2516 .parent = "write_bw_log",
2519 .category = FIO_OPT_C_LOG,
2520 .group = FIO_OPT_G_INVALID,
2523 .name = "iopsavgtime",
2524 .lname = "IOPS average time",
2525 .type = FIO_OPT_INT,
2526 .off1 = td_var_offset(iops_avg_time),
2527 .help = "Time window over which to calculate IOPS (msec)",
2529 .parent = "write_iops_log",
2532 .category = FIO_OPT_C_LOG,
2533 .group = FIO_OPT_G_INVALID,
2536 .name = "group_reporting",
2537 .lname = "Group reporting",
2538 .type = FIO_OPT_BOOL,
2539 .off1 = td_var_offset(group_reporting),
2540 .help = "Do reporting on a per-group basis",
2542 .category = FIO_OPT_C_STAT,
2543 .group = FIO_OPT_G_INVALID,
2546 .name = "zero_buffers",
2547 .lname = "Zero I/O buffers",
2548 .type = FIO_OPT_STR_SET,
2549 .off1 = td_var_offset(zero_buffers),
2550 .help = "Init IO buffers to all zeroes",
2551 .category = FIO_OPT_C_IO,
2552 .group = FIO_OPT_G_IO_BUF,
2555 .name = "refill_buffers",
2556 .lname = "Refill I/O buffers",
2557 .type = FIO_OPT_STR_SET,
2558 .off1 = td_var_offset(refill_buffers),
2559 .help = "Refill IO buffers on every IO submit",
2560 .category = FIO_OPT_C_IO,
2561 .group = FIO_OPT_G_IO_BUF,
2564 .name = "scramble_buffers",
2565 .lname = "Scramble I/O buffers",
2566 .type = FIO_OPT_BOOL,
2567 .off1 = td_var_offset(scramble_buffers),
2568 .help = "Slightly scramble buffers on every IO submit",
2570 .category = FIO_OPT_C_IO,
2571 .group = FIO_OPT_G_IO_BUF,
2574 .name = "buffer_compress_percentage",
2575 .lname = "Buffer compression percentage",
2576 .type = FIO_OPT_INT,
2577 .off1 = td_var_offset(compress_percentage),
2580 .help = "How compressible the buffer is (approximately)",
2582 .category = FIO_OPT_C_IO,
2583 .group = FIO_OPT_G_IO_BUF,
2586 .name = "buffer_compress_chunk",
2587 .lname = "Buffer compression chunk size",
2588 .type = FIO_OPT_INT,
2589 .off1 = td_var_offset(compress_chunk),
2590 .parent = "buffer_compress_percentage",
2592 .help = "Size of compressible region in buffer",
2594 .category = FIO_OPT_C_IO,
2595 .group = FIO_OPT_G_IO_BUF,
2598 .name = "clat_percentiles",
2599 .lname = "Completion latency percentiles",
2600 .type = FIO_OPT_BOOL,
2601 .off1 = td_var_offset(clat_percentiles),
2602 .help = "Enable the reporting of completion latency percentiles",
2604 .category = FIO_OPT_C_STAT,
2605 .group = FIO_OPT_G_INVALID,
2608 .name = "percentile_list",
2609 .lname = "Completion latency percentile list",
2610 .type = FIO_OPT_FLOAT_LIST,
2611 .off1 = td_var_offset(percentile_list),
2612 .off2 = td_var_offset(overwrite_plist),
2613 .help = "Specify a custom list of percentiles to report",
2614 .maxlen = FIO_IO_U_LIST_MAX_LEN,
2617 .category = FIO_OPT_C_STAT,
2618 .group = FIO_OPT_G_INVALID,
2621 #ifdef FIO_HAVE_DISK_UTIL
2623 .name = "disk_util",
2624 .lname = "Disk utilization",
2625 .type = FIO_OPT_BOOL,
2626 .off1 = td_var_offset(do_disk_util),
2627 .help = "Log disk utilization statistics",
2629 .category = FIO_OPT_C_STAT,
2630 .group = FIO_OPT_G_INVALID,
2634 .name = "gtod_reduce",
2635 .lname = "Reduce gettimeofday() calls",
2636 .type = FIO_OPT_BOOL,
2637 .help = "Greatly reduce number of gettimeofday() calls",
2638 .cb = str_gtod_reduce_cb,
2641 .category = FIO_OPT_C_STAT,
2642 .group = FIO_OPT_G_INVALID,
2645 .name = "disable_lat",
2646 .lname = "Disable all latency stats",
2647 .type = FIO_OPT_BOOL,
2648 .off1 = td_var_offset(disable_lat),
2649 .help = "Disable latency numbers",
2650 .parent = "gtod_reduce",
2653 .category = FIO_OPT_C_STAT,
2654 .group = FIO_OPT_G_INVALID,
2657 .name = "disable_clat",
2658 .lname = "Disable completion latency stats",
2659 .type = FIO_OPT_BOOL,
2660 .off1 = td_var_offset(disable_clat),
2661 .help = "Disable completion latency numbers",
2662 .parent = "gtod_reduce",
2665 .category = FIO_OPT_C_STAT,
2666 .group = FIO_OPT_G_INVALID,
2669 .name = "disable_slat",
2670 .lname = "Disable submission latency stats",
2671 .type = FIO_OPT_BOOL,
2672 .off1 = td_var_offset(disable_slat),
2673 .help = "Disable submission latency numbers",
2674 .parent = "gtod_reduce",
2677 .category = FIO_OPT_C_STAT,
2678 .group = FIO_OPT_G_INVALID,
2681 .name = "disable_bw_measurement",
2682 .lname = "Disable bandwidth stats",
2683 .type = FIO_OPT_BOOL,
2684 .off1 = td_var_offset(disable_bw),
2685 .help = "Disable bandwidth logging",
2686 .parent = "gtod_reduce",
2689 .category = FIO_OPT_C_STAT,
2690 .group = FIO_OPT_G_INVALID,
2694 .lname = "Dedicated gettimeofday() CPU",
2695 .type = FIO_OPT_INT,
2696 .cb = str_gtod_cpu_cb,
2697 .help = "Set up dedicated gettimeofday() thread on this CPU",
2698 .verify = gtod_cpu_verify,
2699 .category = FIO_OPT_C_GENERAL,
2700 .group = FIO_OPT_G_CLOCK,
2703 .name = "continue_on_error",
2704 .lname = "Continue on error",
2705 .type = FIO_OPT_STR,
2706 .off1 = td_var_offset(continue_on_error),
2707 .help = "Continue on non-fatal errors during IO",
2709 .category = FIO_OPT_C_GENERAL,
2710 .group = FIO_OPT_G_INVALID,
2713 .oval = ERROR_TYPE_NONE,
2714 .help = "Exit when an error is encountered",
2717 .oval = ERROR_TYPE_READ,
2718 .help = "Continue on read errors only",
2721 .oval = ERROR_TYPE_WRITE,
2722 .help = "Continue on write errors only",
2725 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
2726 .help = "Continue on any IO errors",
2729 .oval = ERROR_TYPE_VERIFY,
2730 .help = "Continue on verify errors only",
2733 .oval = ERROR_TYPE_ANY,
2734 .help = "Continue on all io and verify errors",
2737 .oval = ERROR_TYPE_NONE,
2738 .help = "Alias for 'none'",
2741 .oval = ERROR_TYPE_ANY,
2742 .help = "Alias for 'all'",
2747 .name = "ignore_error",
2748 .type = FIO_OPT_STR,
2749 .cb = str_ignore_error_cb,
2750 .help = "Set a specific list of errors to ignore",
2752 .category = FIO_OPT_C_GENERAL,
2753 .group = FIO_OPT_G_INVALID,
2756 .name = "error_dump",
2757 .type = FIO_OPT_BOOL,
2758 .off1 = td_var_offset(error_dump),
2760 .help = "Dump info on each error",
2761 .category = FIO_OPT_C_GENERAL,
2762 .group = FIO_OPT_G_INVALID,
2767 .type = FIO_OPT_STR_STORE,
2768 .off1 = td_var_offset(profile),
2769 .help = "Select a specific builtin performance test",
2770 .category = FIO_OPT_C_PROFILE,
2771 .group = FIO_OPT_G_INVALID,
2776 .type = FIO_OPT_STR_STORE,
2777 .off1 = td_var_offset(cgroup),
2778 .help = "Add job to cgroup of this name",
2779 .category = FIO_OPT_C_GENERAL,
2780 .group = FIO_OPT_G_CGROUP,
2783 .name = "cgroup_nodelete",
2784 .lname = "Cgroup no-delete",
2785 .type = FIO_OPT_BOOL,
2786 .off1 = td_var_offset(cgroup_nodelete),
2787 .help = "Do not delete cgroups after job completion",
2790 .category = FIO_OPT_C_GENERAL,
2791 .group = FIO_OPT_G_CGROUP,
2794 .name = "cgroup_weight",
2795 .lname = "Cgroup weight",
2796 .type = FIO_OPT_INT,
2797 .off1 = td_var_offset(cgroup_weight),
2798 .help = "Use given weight for cgroup",
2802 .category = FIO_OPT_C_GENERAL,
2803 .group = FIO_OPT_G_CGROUP,
2808 .type = FIO_OPT_INT,
2809 .off1 = td_var_offset(uid),
2810 .help = "Run job with this user ID",
2811 .category = FIO_OPT_C_GENERAL,
2812 .group = FIO_OPT_G_CRED,
2816 .lname = "Group ID",
2817 .type = FIO_OPT_INT,
2818 .off1 = td_var_offset(gid),
2819 .help = "Run job with this group ID",
2820 .category = FIO_OPT_C_GENERAL,
2821 .group = FIO_OPT_G_CRED,
2826 .type = FIO_OPT_INT,
2827 .off1 = td_var_offset(kb_base),
2828 .verify = kb_base_verify,
2831 .help = "How many bytes per KB for reporting (1000 or 1024)",
2832 .category = FIO_OPT_C_GENERAL,
2833 .group = FIO_OPT_G_INVALID,
2836 .name = "hugepage-size",
2837 .lname = "Hugepage size",
2838 .type = FIO_OPT_INT,
2839 .off1 = td_var_offset(hugepage_size),
2840 .help = "When using hugepages, specify size of each page",
2841 .def = __fio_stringify(FIO_HUGE_PAGE),
2842 .interval = 1024 * 1024,
2843 .category = FIO_OPT_C_GENERAL,
2844 .group = FIO_OPT_G_INVALID,
2848 .lname = "I/O flow ID",
2849 .type = FIO_OPT_INT,
2850 .off1 = td_var_offset(flow_id),
2851 .help = "The flow index ID to use",
2853 .category = FIO_OPT_C_IO,
2854 .group = FIO_OPT_G_IO_FLOW,
2858 .lname = "I/O flow weight",
2859 .type = FIO_OPT_INT,
2860 .off1 = td_var_offset(flow),
2861 .help = "Weight for flow control of this job",
2862 .parent = "flow_id",
2865 .category = FIO_OPT_C_IO,
2866 .group = FIO_OPT_G_IO_FLOW,
2869 .name = "flow_watermark",
2870 .lname = "I/O flow watermark",
2871 .type = FIO_OPT_INT,
2872 .off1 = td_var_offset(flow_watermark),
2873 .help = "High watermark for flow control. This option"
2874 " should be set to the same value for all threads"
2875 " with non-zero flow.",
2876 .parent = "flow_id",
2879 .category = FIO_OPT_C_IO,
2880 .group = FIO_OPT_G_IO_FLOW,
2883 .name = "flow_sleep",
2884 .lname = "I/O flow sleep",
2885 .type = FIO_OPT_INT,
2886 .off1 = td_var_offset(flow_sleep),
2887 .help = "How many microseconds to sleep after being held"
2888 " back by the flow control mechanism",
2889 .parent = "flow_id",
2892 .category = FIO_OPT_C_IO,
2893 .group = FIO_OPT_G_IO_FLOW,
2900 static void add_to_lopt(struct option *lopt, struct fio_option *o,
2901 const char *name, int val)
2903 lopt->name = (char *) name;
2905 if (o->type == FIO_OPT_STR_SET)
2906 lopt->has_arg = no_argument;
2908 lopt->has_arg = required_argument;
2911 static void options_to_lopts(struct fio_option *opts,
2912 struct option *long_options,
2913 int i, int option_type)
2915 struct fio_option *o = &opts[0];
2917 add_to_lopt(&long_options[i], o, o->name, option_type);
2920 add_to_lopt(&long_options[i], o, o->alias, option_type);
2925 assert(i < FIO_NR_OPTIONS);
2929 void fio_options_set_ioengine_opts(struct option *long_options,
2930 struct thread_data *td)
2935 while (long_options[i].name) {
2936 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
2937 memset(&long_options[i], 0, sizeof(*long_options));
2944 * Just clear out the prior ioengine options.
2949 options_to_lopts(td->io_ops->options, long_options, i,
2950 FIO_GETOPT_IOENGINE);
2953 void fio_options_dup_and_init(struct option *long_options)
2957 options_init(fio_options);
2960 while (long_options[i].name)
2963 options_to_lopts(fio_options, long_options, i, FIO_GETOPT_JOB);
2966 struct fio_keyword {
2972 static struct fio_keyword fio_keywords[] = {
2974 .word = "$pagesize",
2975 .desc = "Page size in the system",
2978 .word = "$mb_memory",
2979 .desc = "Megabytes of memory online",
2983 .desc = "Number of CPUs online in the system",
2990 void fio_keywords_init(void)
2992 unsigned long long mb_memory;
2996 sprintf(buf, "%lu", page_size);
2997 fio_keywords[0].replace = strdup(buf);
2999 mb_memory = os_phys_mem() / (1024 * 1024);
3000 sprintf(buf, "%llu", mb_memory);
3001 fio_keywords[1].replace = strdup(buf);
3004 sprintf(buf, "%lu", l);
3005 fio_keywords[2].replace = strdup(buf);
3010 static char *bc_calc(char *str)
3012 char buf[128], *tmp;
3017 * No math, just return string
3019 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
3020 !strchr(str, '/')) || strchr(str, '\''))
3024 * Split option from value, we only need to calculate the value
3026 tmp = strchr(str, '=');
3033 * Prevent buffer overflows; such a case isn't reasonable anyway
3035 if (strlen(str) >= 128 || strlen(tmp) > 100)
3038 sprintf(buf, "which %s > /dev/null", BC_APP);
3040 log_err("fio: bc is needed for performing math\n");
3044 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
3045 f = popen(buf, "r");
3049 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
3054 buf[(tmp - str) + ret - 1] = '\0';
3055 memcpy(buf, str, tmp - str);
3061 * Return a copy of the input string with substrings of the form ${VARNAME}
3062 * substituted with the value of the environment variable VARNAME. The
3063 * substitution always occurs, even if VARNAME is empty or the corresponding
3064 * environment variable undefined.
3066 static char *option_dup_subs(const char *opt)
3068 char out[OPT_LEN_MAX+1];
3069 char in[OPT_LEN_MAX+1];
3072 char *ch1, *ch2, *env;
3073 ssize_t nchr = OPT_LEN_MAX;
3076 if (strlen(opt) + 1 > OPT_LEN_MAX) {
3077 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
3081 in[OPT_LEN_MAX] = '\0';
3082 strncpy(in, opt, OPT_LEN_MAX);
3084 while (*inptr && nchr > 0) {
3085 if (inptr[0] == '$' && inptr[1] == '{') {
3086 ch2 = strchr(inptr, '}');
3087 if (ch2 && inptr+1 < ch2) {
3094 envlen = strlen(env);
3095 if (envlen <= nchr) {
3096 memcpy(outptr, env, envlen);
3106 *outptr++ = *inptr++;
3115 * Look for reserved variable names and replace them with real values
3117 static char *fio_keyword_replace(char *opt)
3123 for (i = 0; fio_keywords[i].word != NULL; i++) {
3124 struct fio_keyword *kw = &fio_keywords[i];
3126 while ((s = strstr(opt, kw->word)) != NULL) {
3127 char *new = malloc(strlen(opt) + 1);
3133 * Copy part of the string before the keyword and
3134 * sprintf() the replacement after it.
3136 memcpy(new, opt, olen);
3137 len = sprintf(new + olen, "%s", kw->replace);
3140 * If there's more in the original string, copy that
3143 opt += strlen(kw->word) + olen;
3145 memcpy(new + olen + len, opt, opt - o_org - 1);
3148 * replace opt and free the old opt
3158 * Check for potential math and invoke bc, if possible
3166 static char **dup_and_sub_options(char **opts, int num_opts)
3169 char **opts_copy = malloc(num_opts * sizeof(*opts));
3170 for (i = 0; i < num_opts; i++) {
3171 opts_copy[i] = option_dup_subs(opts[i]);
3174 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
3179 int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
3181 int i, ret, unknown;
3184 sort_options(opts, fio_options, num_opts);
3185 opts_copy = dup_and_sub_options(opts, num_opts);
3187 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
3188 struct fio_option *o;
3189 int newret = parse_option(opts_copy[i], opts[i], fio_options,
3198 opts_copy[i] = NULL;
3205 ret |= ioengine_load(td);
3207 sort_options(opts_copy, td->io_ops->options, num_opts);
3210 for (i = 0; i < num_opts; i++) {
3211 struct fio_option *o = NULL;
3217 newret = parse_option(opts_copy[i], opts[i],
3218 td->io_ops->options, &o,
3223 log_err("Bad option <%s>\n", opts[i]);
3226 opts_copy[i] = NULL;
3234 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
3236 return parse_cmd_option(opt, val, fio_options, td);
3239 int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
3242 return parse_cmd_option(opt, val, td->io_ops->options, td);
3245 void fio_fill_default_options(struct thread_data *td)
3247 fill_default_options(td, fio_options);
3250 int fio_show_option_help(const char *opt)
3252 return show_cmd_help(fio_options, opt);
3255 void options_mem_dupe(void *data, struct fio_option *options)
3257 struct fio_option *o;
3260 for (o = &options[0]; o->name; o++) {
3261 if (o->type != FIO_OPT_STR_STORE)
3264 ptr = td_var(data, o->off1);
3266 *ptr = strdup(*ptr);
3271 * dupe FIO_OPT_STR_STORE options
3273 void fio_options_mem_dupe(struct thread_data *td)
3275 options_mem_dupe(&td->o, fio_options);
3277 if (td->eo && td->io_ops) {
3278 void *oldeo = td->eo;
3280 td->eo = malloc(td->io_ops->option_struct_size);
3281 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
3282 options_mem_dupe(td->eo, td->io_ops->options);
3286 unsigned int fio_get_kb_base(void *data)
3288 struct thread_options *o = data;
3289 unsigned int kb_base = 0;
3292 kb_base = o->kb_base;
3299 int add_option(struct fio_option *o)
3301 struct fio_option *__o;
3310 memcpy(&fio_options[opt_index], o, sizeof(*o));
3314 void invalidate_profile_options(const char *prof_name)
3316 struct fio_option *o;
3320 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
3321 o->type = FIO_OPT_INVALID;
3322 o->prof_name = NULL;
3328 void add_opt_posval(const char *optname, const char *ival, const char *help)
3330 struct fio_option *o;
3333 o = find_option(fio_options, optname);
3337 for (i = 0; i < PARSE_MAX_VP; i++) {
3338 if (o->posval[i].ival)
3341 o->posval[i].ival = ival;
3342 o->posval[i].help = help;
3347 void del_opt_posval(const char *optname, const char *ival)
3349 struct fio_option *o;
3352 o = find_option(fio_options, optname);
3356 for (i = 0; i < PARSE_MAX_VP; i++) {
3357 if (!o->posval[i].ival)
3359 if (strcmp(o->posval[i].ival, ival))
3362 o->posval[i].ival = NULL;
3363 o->posval[i].help = NULL;
3367 void fio_options_free(struct thread_data *td)
3369 options_free(fio_options, td);
3370 if (td->eo && td->io_ops && td->io_ops->options) {
3371 options_free(td->io_ops->options, td->eo);
3377 struct fio_option *fio_option_find(const char *name)
3379 return find_option(fio_options, name);