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;
171 p = str = strdup(input);
173 strip_blank_front(&str);
174 strip_blank_end(str);
176 odir = strchr(str, ',');
178 ret = bssplit_ddir(&td->o, DDIR_WRITE, odir + 1);
181 ret = bssplit_ddir(&td->o, DDIR_READ, str);
188 ret = bssplit_ddir(&td->o, DDIR_READ, str);
190 ret = bssplit_ddir(&td->o, DDIR_WRITE, op);
199 static int str_rw_cb(void *data, const char *str)
201 struct thread_data *td = data;
202 struct thread_options *o = &td->o;
203 char *nr = get_opt_postfix(str);
212 o->ddir_seq_nr = atoi(nr);
216 if (str_to_decimal(nr, &val, 1, o)) {
217 log_err("fio: rw postfix parsing failed\n");
222 o->ddir_seq_add = val;
229 static int str_mem_cb(void *data, const char *mem)
231 struct thread_data *td = data;
232 struct thread_options *o = &td->o;
234 if (o->mem_type == MEM_MMAPHUGE || o->mem_type == MEM_MMAP) {
235 o->mmapfile = get_opt_postfix(mem);
236 if (o->mem_type == MEM_MMAPHUGE && !o->mmapfile) {
237 log_err("fio: mmaphuge:/path/to/file\n");
245 static int fio_clock_source_cb(void *data, const char *str)
247 struct thread_data *td = data;
249 fio_clock_source = td->o.clocksource;
254 static int str_rwmix_read_cb(void *data, unsigned long long *val)
256 struct thread_data *td = data;
258 td->o.rwmix[DDIR_READ] = *val;
259 td->o.rwmix[DDIR_WRITE] = 100 - *val;
263 static int str_rwmix_write_cb(void *data, unsigned long long *val)
265 struct thread_data *td = data;
267 td->o.rwmix[DDIR_WRITE] = *val;
268 td->o.rwmix[DDIR_READ] = 100 - *val;
272 #ifdef FIO_HAVE_IOPRIO
273 static int str_prioclass_cb(void *data, unsigned long long *val)
275 struct thread_data *td = data;
279 * mask off old class bits, str_prio_cb() may have set a default class
281 mask = (1 << IOPRIO_CLASS_SHIFT) - 1;
284 td->ioprio |= *val << IOPRIO_CLASS_SHIFT;
289 static int str_prio_cb(void *data, unsigned long long *val)
291 struct thread_data *td = data;
296 * If no class is set, assume BE
298 if ((td->ioprio >> IOPRIO_CLASS_SHIFT) == 0)
299 td->ioprio |= IOPRIO_CLASS_BE << IOPRIO_CLASS_SHIFT;
306 static int str_exitall_cb(void)
308 exitall_on_terminate = 1;
312 #ifdef FIO_HAVE_CPU_AFFINITY
313 static int str_cpumask_cb(void *data, unsigned long long *val)
315 struct thread_data *td = data;
320 ret = fio_cpuset_init(&td->o.cpumask);
322 log_err("fio: cpuset_init failed\n");
323 td_verror(td, ret, "fio_cpuset_init");
327 max_cpu = cpus_online();
329 for (i = 0; i < sizeof(int) * 8; i++) {
330 if ((1 << i) & *val) {
332 log_err("fio: CPU %d too large (max=%ld)\n", i,
336 dprint(FD_PARSE, "set cpu allowed %d\n", i);
337 fio_cpu_set(&td->o.cpumask, i);
341 td->o.cpumask_set = 1;
345 static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask,
352 ret = fio_cpuset_init(mask);
354 log_err("fio: cpuset_init failed\n");
355 td_verror(td, ret, "fio_cpuset_init");
359 p = str = strdup(input);
361 strip_blank_front(&str);
362 strip_blank_end(str);
364 max_cpu = cpus_online();
366 while ((cpu = strsep(&str, ",")) != NULL) {
375 while ((cpu2 = strsep(&str2, "-")) != NULL) {
385 while (icpu <= icpu2) {
386 if (icpu >= FIO_MAX_CPUS) {
387 log_err("fio: your OS only supports up to"
388 " %d CPUs\n", (int) FIO_MAX_CPUS);
392 if (icpu > max_cpu) {
393 log_err("fio: CPU %d too large (max=%ld)\n",
399 dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
400 fio_cpu_set(mask, icpu);
409 td->o.cpumask_set = 1;
413 static int str_cpus_allowed_cb(void *data, const char *input)
415 struct thread_data *td = data;
418 ret = set_cpus_allowed(td, &td->o.cpumask, input);
420 td->o.cpumask_set = 1;
425 static int str_verify_cpus_allowed_cb(void *data, const char *input)
427 struct thread_data *td = data;
430 ret = set_cpus_allowed(td, &td->o.verify_cpumask, input);
432 td->o.verify_cpumask_set = 1;
439 static int str_verify_trim_cb(void *data, unsigned long long *val)
441 struct thread_data *td = data;
443 td->o.trim_percentage = *val;
448 static int str_fst_cb(void *data, const char *str)
450 struct thread_data *td = data;
451 char *nr = get_opt_postfix(str);
453 td->file_service_nr = 1;
455 td->file_service_nr = atoi(nr);
462 #ifdef FIO_HAVE_SYNC_FILE_RANGE
463 static int str_sfr_cb(void *data, const char *str)
465 struct thread_data *td = data;
466 char *nr = get_opt_postfix(str);
468 td->sync_file_range_nr = 1;
470 td->sync_file_range_nr = atoi(nr);
478 static int check_dir(struct thread_data *td, char *fname)
481 char file[PATH_MAX], *dir;
484 if (td->o.directory) {
485 strcpy(file, td->o.directory);
490 sprintf(file + elen, "%s", fname);
496 * We can't do this on FIO_DISKLESSIO engines. The engine isn't loaded
497 * yet, so we can't do this check right here...
499 if (lstat(dir, &sb) < 0) {
502 log_err("fio: %s is not a directory\n", dir);
503 td_verror(td, ret, "lstat");
507 if (!S_ISDIR(sb.st_mode)) {
508 log_err("fio: %s is not a directory\n", dir);
518 * Return next file in the string. Files are separated with ':'. If the ':'
519 * is escaped with a '\', then that ':' is part of the filename and does not
520 * indicate a new file.
522 static char *get_next_file_name(char **ptr)
527 if (!str || !strlen(str))
533 * No colon, we are done
535 p = strchr(str, ':');
542 * We got a colon, but it's the first character. Skip and
550 if (*(p - 1) != '\\') {
556 memmove(p - 1, p, strlen(p) + 1);
563 static int str_filename_cb(void *data, const char *input)
565 struct thread_data *td = data;
566 char *fname, *str, *p;
568 p = str = strdup(input);
570 strip_blank_front(&str);
571 strip_blank_end(str);
573 if (!td->files_index)
576 while ((fname = get_next_file_name(&str)) != NULL) {
579 if (check_dir(td, fname)) {
591 static int str_directory_cb(void *data, const char fio_unused *str)
593 struct thread_data *td = data;
596 if (lstat(td->o.directory, &sb) < 0) {
599 log_err("fio: %s is not a directory\n", td->o.directory);
600 td_verror(td, ret, "lstat");
603 if (!S_ISDIR(sb.st_mode)) {
604 log_err("fio: %s is not a directory\n", td->o.directory);
611 static int str_opendir_cb(void *data, const char fio_unused *str)
613 struct thread_data *td = data;
615 if (!td->files_index)
618 return add_dir_files(td, td->o.opendir);
621 static int str_verify_offset_cb(void *data, unsigned long long *off)
623 struct thread_data *td = data;
625 if (*off && *off < sizeof(struct verify_header)) {
626 log_err("fio: verify_offset too small\n");
630 td->o.verify_offset = *off;
634 static int str_verify_pattern_cb(void *data, const char *input)
636 struct thread_data *td = data;
638 int i = 0, j = 0, len, k, base = 10;
641 loc1 = strstr(input, "0x");
642 loc2 = strstr(input, "0X");
645 off = strtol(input, NULL, base);
646 if (off != LONG_MAX || errno != ERANGE) {
648 td->o.verify_pattern[i] = off & 0xff;
657 j = loc1 - input + 2;
659 j = loc2 - input + 2;
662 if (len - j < MAX_PATTERN_SIZE * 2) {
664 off = converthexchartoint(input[k--]);
666 off += (converthexchartoint(input[k--])
668 td->o.verify_pattern[i++] = (char) off;
674 * Fill the pattern all the way to the end. This greatly reduces
675 * the number of memcpy's we have to do when verifying the IO.
677 while (i > 1 && i * 2 <= MAX_PATTERN_SIZE) {
678 memcpy(&td->o.verify_pattern[i], &td->o.verify_pattern[0], i);
683 * The code in verify_io_u_pattern assumes a single byte pattern
684 * fills the whole verify pattern buffer.
686 memset(td->o.verify_pattern, td->o.verify_pattern[0],
690 td->o.verify_pattern_bytes = i;
693 * VERIFY_META could already be set
695 if (td->o.verify == VERIFY_NONE)
696 td->o.verify = VERIFY_PATTERN;
701 static int str_lockfile_cb(void *data, const char *str)
703 struct thread_data *td = data;
704 char *nr = get_opt_postfix(str);
706 td->o.lockfile_batch = 1;
708 td->o.lockfile_batch = atoi(nr);
715 static int str_write_bw_log_cb(void *data, const char *str)
717 struct thread_data *td = data;
720 td->o.bw_log_file = strdup(str);
722 td->o.write_bw_log = 1;
726 static int str_write_lat_log_cb(void *data, const char *str)
728 struct thread_data *td = data;
731 td->o.lat_log_file = strdup(str);
733 td->o.write_lat_log = 1;
737 static int str_write_iops_log_cb(void *data, const char *str)
739 struct thread_data *td = data;
742 td->o.iops_log_file = strdup(str);
744 td->o.write_iops_log = 1;
748 static int str_gtod_reduce_cb(void *data, int *il)
750 struct thread_data *td = data;
753 td->o.disable_lat = !!val;
754 td->o.disable_clat = !!val;
755 td->o.disable_slat = !!val;
756 td->o.disable_bw = !!val;
757 td->o.clat_percentiles = !val;
759 td->tv_cache_mask = 63;
764 static int str_gtod_cpu_cb(void *data, long long *il)
766 struct thread_data *td = data;
769 td->o.gtod_cpu = val;
770 td->o.gtod_offload = 1;
774 static int str_size_cb(void *data, unsigned long long *__val)
776 struct thread_data *td = data;
777 unsigned long long v = *__val;
779 if (parse_is_percent(v)) {
781 td->o.size_percent = -1ULL - v;
788 static int rw_verify(struct fio_option *o, void *data)
790 struct thread_data *td = data;
792 if (read_only && td_write(td)) {
793 log_err("fio: job <%s> has write bit set, but fio is in"
794 " read-only mode\n", td->o.name);
801 static int gtod_cpu_verify(struct fio_option *o, void *data)
803 #ifndef FIO_HAVE_CPU_AFFINITY
804 struct thread_data *td = data;
806 if (td->o.gtod_cpu) {
807 log_err("fio: platform must support CPU affinity for"
808 "gettimeofday() offloading\n");
816 static int kb_base_verify(struct fio_option *o, void *data)
818 struct thread_data *td = data;
820 if (td->o.kb_base != 1024 && td->o.kb_base != 1000) {
821 log_err("fio: kb_base set to nonsensical value: %u\n",
832 static struct opt_group fio_opt_groups[] = {
835 .mask = FIO_OPT_C_GENERAL,
839 .mask = FIO_OPT_C_IO,
843 .mask = FIO_OPT_C_FILE,
846 .name = "Statistics",
847 .mask = FIO_OPT_C_STAT,
851 .mask = FIO_OPT_C_LOG,
858 static struct opt_group *__opt_group_from_mask(struct opt_group *ogs, unsigned int *mask,
859 unsigned int inv_mask)
861 struct opt_group *og;
864 if (*mask == inv_mask || !*mask)
867 for (i = 0; ogs[i].name; i++) {
870 if (*mask & og->mask) {
871 *mask &= ~(og->mask);
879 struct opt_group *opt_group_from_mask(unsigned int *mask)
881 return __opt_group_from_mask(fio_opt_groups, mask, FIO_OPT_C_INVALID);
884 static struct opt_group fio_opt_cat_groups[] = {
887 .mask = FIO_OPT_G_RATE,
891 .mask = FIO_OPT_G_ZONE,
894 .name = "Read/write mix",
895 .mask = FIO_OPT_G_RWMIX,
899 .mask = FIO_OPT_G_VERIFY,
903 .mask = FIO_OPT_G_TRIM,
906 .name = "I/O Logging",
907 .mask = FIO_OPT_G_IOLOG,
911 .mask = FIO_OPT_G_IO_DEPTH,
915 .mask = FIO_OPT_G_IO_FLOW,
918 .name = "Description",
919 .mask = FIO_OPT_G_DESC,
923 .mask = FIO_OPT_G_FILENAME,
926 .name = "General I/O",
927 .mask = FIO_OPT_G_IO_BASIC,
931 .mask = FIO_OPT_G_CGROUP,
935 .mask = FIO_OPT_G_RUNTIME,
939 .mask = FIO_OPT_G_PROCESS,
942 .name = "Job credentials / priority",
943 .mask = FIO_OPT_G_CRED,
946 .name = "Clock settings",
947 .mask = FIO_OPT_G_CLOCK,
951 .mask = FIO_OPT_G_IO_TYPE,
954 .name = "I/O Thinktime",
955 .mask = FIO_OPT_G_THINKTIME,
958 .name = "Randomizations",
959 .mask = FIO_OPT_G_RANDOM,
962 .name = "I/O buffers",
963 .mask = FIO_OPT_G_IO_BUF,
970 struct opt_group *opt_group_cat_from_mask(unsigned int *mask)
972 return __opt_group_from_mask(fio_opt_cat_groups, mask, FIO_OPT_G_INVALID);
976 * Map of job/command line options
978 struct fio_option fio_options[FIO_MAX_OPTS] = {
980 .name = "description",
981 .lname = "Description of job",
982 .type = FIO_OPT_STR_STORE,
983 .off1 = td_var_offset(description),
984 .help = "Text job description",
985 .category = FIO_OPT_C_GENERAL,
986 .group = FIO_OPT_G_DESC,
991 .type = FIO_OPT_STR_STORE,
992 .off1 = td_var_offset(name),
993 .help = "Name of this job",
994 .category = FIO_OPT_C_GENERAL,
995 .group = FIO_OPT_G_DESC,
999 .lname = "Filename(s)",
1000 .type = FIO_OPT_STR_STORE,
1001 .off1 = td_var_offset(filename),
1002 .cb = str_filename_cb,
1003 .prio = -1, /* must come after "directory" */
1004 .help = "File(s) to use for the workload",
1005 .category = FIO_OPT_C_FILE,
1006 .group = FIO_OPT_G_FILENAME,
1009 .name = "directory",
1010 .lname = "Directory",
1011 .type = FIO_OPT_STR_STORE,
1012 .off1 = td_var_offset(directory),
1013 .cb = str_directory_cb,
1014 .help = "Directory to store files in",
1015 .category = FIO_OPT_C_FILE,
1016 .group = FIO_OPT_G_FILENAME,
1020 .lname = "Lockfile",
1021 .type = FIO_OPT_STR,
1022 .cb = str_lockfile_cb,
1023 .off1 = td_var_offset(file_lock_mode),
1024 .help = "Lock file when doing IO to it",
1025 .parent = "filename",
1028 .category = FIO_OPT_C_FILE,
1029 .group = FIO_OPT_G_FILENAME,
1032 .oval = FILE_LOCK_NONE,
1033 .help = "No file locking",
1035 { .ival = "exclusive",
1036 .oval = FILE_LOCK_EXCLUSIVE,
1037 .help = "Exclusive file lock",
1040 .ival = "readwrite",
1041 .oval = FILE_LOCK_READWRITE,
1042 .help = "Read vs write lock",
1048 .lname = "Open directory",
1049 .type = FIO_OPT_STR_STORE,
1050 .off1 = td_var_offset(opendir),
1051 .cb = str_opendir_cb,
1052 .help = "Recursively add files from this directory and down",
1053 .category = FIO_OPT_C_FILE,
1054 .group = FIO_OPT_G_FILENAME,
1058 .lname = "Read/write",
1059 .alias = "readwrite",
1060 .type = FIO_OPT_STR,
1062 .off1 = td_var_offset(td_ddir),
1063 .help = "IO direction",
1065 .verify = rw_verify,
1066 .category = FIO_OPT_C_IO,
1067 .group = FIO_OPT_G_IO_BASIC,
1070 .oval = TD_DDIR_READ,
1071 .help = "Sequential read",
1074 .oval = TD_DDIR_WRITE,
1075 .help = "Sequential write",
1077 { .ival = "randread",
1078 .oval = TD_DDIR_RANDREAD,
1079 .help = "Random read",
1081 { .ival = "randwrite",
1082 .oval = TD_DDIR_RANDWRITE,
1083 .help = "Random write",
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 { .ival = "external",
1201 .help = "Load external engine (append name)",
1207 .lname = "IO Depth",
1208 .type = FIO_OPT_INT,
1209 .off1 = td_var_offset(iodepth),
1210 .help = "Number of IO buffers to keep in flight",
1214 .category = FIO_OPT_C_IO,
1215 .group = FIO_OPT_G_IO_BASIC,
1218 .name = "iodepth_batch",
1219 .lname = "IO Depth batch",
1220 .alias = "iodepth_batch_submit",
1221 .type = FIO_OPT_INT,
1222 .off1 = td_var_offset(iodepth_batch),
1223 .help = "Number of IO buffers to submit in one go",
1224 .parent = "iodepth",
1229 .category = FIO_OPT_C_IO,
1230 .group = FIO_OPT_G_IO_BASIC,
1233 .name = "iodepth_batch_complete",
1234 .lname = "IO Depth batch complete",
1235 .type = FIO_OPT_INT,
1236 .off1 = td_var_offset(iodepth_batch_complete),
1237 .help = "Number of IO buffers to retrieve in one go",
1238 .parent = "iodepth",
1243 .category = FIO_OPT_C_IO,
1244 .group = FIO_OPT_G_IO_BASIC,
1247 .name = "iodepth_low",
1248 .lname = "IO Depth batch low",
1249 .type = FIO_OPT_INT,
1250 .off1 = td_var_offset(iodepth_low),
1251 .help = "Low water mark for queuing depth",
1252 .parent = "iodepth",
1255 .category = FIO_OPT_C_IO,
1256 .group = FIO_OPT_G_IO_BASIC,
1261 .type = FIO_OPT_STR_VAL,
1263 .help = "Total size of device or files",
1264 .interval = 1024 * 1024,
1265 .category = FIO_OPT_C_IO,
1266 .group = FIO_OPT_G_INVALID,
1269 .name = "fill_device",
1270 .lname = "Fill device",
1272 .type = FIO_OPT_BOOL,
1273 .off1 = td_var_offset(fill_device),
1274 .help = "Write until an ENOSPC error occurs",
1276 .category = FIO_OPT_C_FILE,
1277 .group = FIO_OPT_G_INVALID,
1281 .lname = "File size",
1282 .type = FIO_OPT_STR_VAL,
1283 .off1 = td_var_offset(file_size_low),
1284 .off2 = td_var_offset(file_size_high),
1286 .help = "Size of individual files",
1287 .interval = 1024 * 1024,
1288 .category = FIO_OPT_C_FILE,
1289 .group = FIO_OPT_G_INVALID,
1293 .lname = "IO offset",
1294 .alias = "fileoffset",
1295 .type = FIO_OPT_STR_VAL,
1296 .off1 = td_var_offset(start_offset),
1297 .help = "Start IO from this offset",
1299 .interval = 1024 * 1024,
1300 .category = FIO_OPT_C_IO,
1301 .group = FIO_OPT_G_INVALID,
1304 .name = "offset_increment",
1305 .lname = "IO offset increment",
1306 .type = FIO_OPT_STR_VAL,
1307 .off1 = td_var_offset(offset_increment),
1308 .help = "What is the increment from one offset to the next",
1312 .interval = 1024 * 1024,
1313 .category = FIO_OPT_C_IO,
1314 .group = FIO_OPT_G_INVALID,
1318 .lname = "Block size",
1319 .alias = "blocksize",
1320 .type = FIO_OPT_INT,
1321 .off1 = td_var_offset(bs[DDIR_READ]),
1322 .off2 = td_var_offset(bs[DDIR_WRITE]),
1324 .help = "Block size unit",
1329 .category = FIO_OPT_C_IO,
1330 .group = FIO_OPT_G_INVALID,
1334 .lname = "Block size align",
1335 .alias = "blockalign",
1336 .type = FIO_OPT_INT,
1337 .off1 = td_var_offset(ba[DDIR_READ]),
1338 .off2 = td_var_offset(ba[DDIR_WRITE]),
1340 .help = "IO block offset alignment",
1344 .category = FIO_OPT_C_IO,
1345 .group = FIO_OPT_G_INVALID,
1349 .lname = "Block size range",
1350 .alias = "blocksize_range",
1351 .type = FIO_OPT_RANGE,
1352 .off1 = td_var_offset(min_bs[DDIR_READ]),
1353 .off2 = td_var_offset(max_bs[DDIR_READ]),
1354 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
1355 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
1357 .help = "Set block size range (in more detail than bs)",
1361 .category = FIO_OPT_C_IO,
1362 .group = FIO_OPT_G_INVALID,
1366 .lname = "Block size split",
1367 .type = FIO_OPT_STR,
1368 .cb = str_bssplit_cb,
1369 .help = "Set a specific mix of block sizes",
1372 .category = FIO_OPT_C_IO,
1373 .group = FIO_OPT_G_INVALID,
1376 .name = "bs_unaligned",
1377 .lname = "Block size unaligned",
1378 .alias = "blocksize_unaligned",
1379 .type = FIO_OPT_STR_SET,
1380 .off1 = td_var_offset(bs_unaligned),
1381 .help = "Don't sector align IO buffer sizes",
1384 .category = FIO_OPT_C_IO,
1385 .group = FIO_OPT_G_INVALID,
1388 .name = "randrepeat",
1389 .lname = "Random repeatable",
1390 .type = FIO_OPT_BOOL,
1391 .off1 = td_var_offset(rand_repeatable),
1392 .help = "Use repeatable random IO pattern",
1396 .category = FIO_OPT_C_IO,
1397 .group = FIO_OPT_G_RANDOM,
1400 .name = "use_os_rand",
1401 .lname = "Use OS random",
1402 .type = FIO_OPT_BOOL,
1403 .off1 = td_var_offset(use_os_rand),
1404 .help = "Set to use OS random generator",
1408 .category = FIO_OPT_C_IO,
1409 .group = FIO_OPT_G_RANDOM,
1412 .name = "norandommap",
1413 .lname = "No randommap",
1414 .type = FIO_OPT_STR_SET,
1415 .off1 = td_var_offset(norandommap),
1416 .help = "Accept potential duplicate random blocks",
1420 .category = FIO_OPT_C_IO,
1421 .group = FIO_OPT_G_RANDOM,
1424 .name = "softrandommap",
1425 .lname = "Soft randommap",
1426 .type = FIO_OPT_BOOL,
1427 .off1 = td_var_offset(softrandommap),
1428 .help = "Set norandommap if randommap allocation fails",
1429 .parent = "norandommap",
1432 .category = FIO_OPT_C_IO,
1433 .group = FIO_OPT_G_RANDOM,
1437 .lname = "Number of files",
1438 .alias = "nr_files",
1439 .type = FIO_OPT_INT,
1440 .off1 = td_var_offset(nr_files),
1441 .help = "Split job workload between this number of files",
1444 .category = FIO_OPT_C_FILE,
1445 .group = FIO_OPT_G_INVALID,
1448 .name = "openfiles",
1449 .lname = "Number of open files",
1450 .type = FIO_OPT_INT,
1451 .off1 = td_var_offset(open_files),
1452 .help = "Number of files to keep open at the same time",
1453 .category = FIO_OPT_C_FILE,
1454 .group = FIO_OPT_G_INVALID,
1457 .name = "file_service_type",
1458 .lname = "File service type",
1459 .type = FIO_OPT_STR,
1461 .off1 = td_var_offset(file_service_type),
1462 .help = "How to select which file to service next",
1463 .def = "roundrobin",
1464 .category = FIO_OPT_C_FILE,
1465 .group = FIO_OPT_G_INVALID,
1468 .oval = FIO_FSERVICE_RANDOM,
1469 .help = "Choose a file at random",
1471 { .ival = "roundrobin",
1472 .oval = FIO_FSERVICE_RR,
1473 .help = "Round robin select files",
1475 { .ival = "sequential",
1476 .oval = FIO_FSERVICE_SEQ,
1477 .help = "Finish one file before moving to the next",
1480 .parent = "nrfiles",
1483 #ifdef FIO_HAVE_FALLOCATE
1485 .name = "fallocate",
1486 .lname = "Fallocate",
1487 .type = FIO_OPT_STR,
1488 .off1 = td_var_offset(fallocate_mode),
1489 .help = "Whether pre-allocation is performed when laying out files",
1491 .category = FIO_OPT_C_FILE,
1492 .group = FIO_OPT_G_INVALID,
1495 .oval = FIO_FALLOCATE_NONE,
1496 .help = "Do not pre-allocate space",
1499 .oval = FIO_FALLOCATE_POSIX,
1500 .help = "Use posix_fallocate()",
1502 #ifdef FIO_HAVE_LINUX_FALLOCATE
1504 .oval = FIO_FALLOCATE_KEEP_SIZE,
1505 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
1508 /* Compatibility with former boolean values */
1510 .oval = FIO_FALLOCATE_NONE,
1511 .help = "Alias for 'none'",
1514 .oval = FIO_FALLOCATE_POSIX,
1515 .help = "Alias for 'posix'",
1519 #endif /* FIO_HAVE_FALLOCATE */
1521 .name = "fadvise_hint",
1522 .lname = "Fadvise hint",
1523 .type = FIO_OPT_BOOL,
1524 .off1 = td_var_offset(fadvise_hint),
1525 .help = "Use fadvise() to advise the kernel on IO pattern",
1527 .category = FIO_OPT_C_FILE,
1528 .group = FIO_OPT_G_INVALID,
1533 .type = FIO_OPT_INT,
1534 .off1 = td_var_offset(fsync_blocks),
1535 .help = "Issue fsync for writes every given number of blocks",
1538 .category = FIO_OPT_C_FILE,
1539 .group = FIO_OPT_G_INVALID,
1542 .name = "fdatasync",
1543 .lname = "Fdatasync",
1544 .type = FIO_OPT_INT,
1545 .off1 = td_var_offset(fdatasync_blocks),
1546 .help = "Issue fdatasync for writes every given number of blocks",
1549 .category = FIO_OPT_C_FILE,
1550 .group = FIO_OPT_G_INVALID,
1553 .name = "write_barrier",
1554 .lname = "Write barrier",
1555 .type = FIO_OPT_INT,
1556 .off1 = td_var_offset(barrier_blocks),
1557 .help = "Make every Nth write a barrier write",
1560 .category = FIO_OPT_C_IO,
1561 .group = FIO_OPT_G_INVALID,
1563 #ifdef FIO_HAVE_SYNC_FILE_RANGE
1565 .name = "sync_file_range",
1566 .lname = "Sync file range",
1568 { .ival = "wait_before",
1569 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
1570 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
1574 .oval = SYNC_FILE_RANGE_WRITE,
1575 .help = "SYNC_FILE_RANGE_WRITE",
1579 .ival = "wait_after",
1580 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
1581 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
1585 .type = FIO_OPT_STR_MULTI,
1587 .off1 = td_var_offset(sync_file_range),
1588 .help = "Use sync_file_range()",
1589 .category = FIO_OPT_C_FILE,
1590 .group = FIO_OPT_G_INVALID,
1595 .lname = "Direct I/O",
1596 .type = FIO_OPT_BOOL,
1597 .off1 = td_var_offset(odirect),
1598 .help = "Use O_DIRECT IO (negates buffered)",
1600 .inverse = "buffered",
1601 .category = FIO_OPT_C_IO,
1602 .group = FIO_OPT_G_IO_TYPE,
1606 .lname = "Buffered I/O",
1607 .type = FIO_OPT_BOOL,
1608 .off1 = td_var_offset(odirect),
1610 .help = "Use buffered IO (negates direct)",
1612 .inverse = "direct",
1613 .category = FIO_OPT_C_IO,
1614 .group = FIO_OPT_G_IO_TYPE,
1617 .name = "overwrite",
1618 .lname = "Overwrite",
1619 .type = FIO_OPT_BOOL,
1620 .off1 = td_var_offset(overwrite),
1621 .help = "When writing, set whether to overwrite current data",
1623 .category = FIO_OPT_C_FILE,
1624 .group = FIO_OPT_G_INVALID,
1629 .type = FIO_OPT_INT,
1630 .off1 = td_var_offset(loops),
1631 .help = "Number of times to run the job",
1634 .category = FIO_OPT_C_GENERAL,
1635 .group = FIO_OPT_G_RUNTIME,
1639 .lname = "Number of jobs",
1640 .type = FIO_OPT_INT,
1641 .off1 = td_var_offset(numjobs),
1642 .help = "Duplicate this job this many times",
1645 .category = FIO_OPT_C_GENERAL,
1646 .group = FIO_OPT_G_RUNTIME,
1649 .name = "startdelay",
1650 .lname = "Start delay",
1651 .type = FIO_OPT_STR_VAL_TIME,
1652 .off1 = td_var_offset(start_delay),
1653 .help = "Only start job when this period has passed",
1655 .category = FIO_OPT_C_GENERAL,
1656 .group = FIO_OPT_G_RUNTIME,
1662 .type = FIO_OPT_STR_VAL_TIME,
1663 .off1 = td_var_offset(timeout),
1664 .help = "Stop workload when this amount of time has passed",
1666 .category = FIO_OPT_C_GENERAL,
1667 .group = FIO_OPT_G_RUNTIME,
1670 .name = "time_based",
1671 .lname = "Time based",
1672 .type = FIO_OPT_STR_SET,
1673 .off1 = td_var_offset(time_based),
1674 .help = "Keep running until runtime/timeout is met",
1675 .category = FIO_OPT_C_GENERAL,
1676 .group = FIO_OPT_G_RUNTIME,
1679 .name = "ramp_time",
1680 .lname = "Ramp time",
1681 .type = FIO_OPT_STR_VAL_TIME,
1682 .off1 = td_var_offset(ramp_time),
1683 .help = "Ramp up time before measuring performance",
1684 .category = FIO_OPT_C_GENERAL,
1685 .group = FIO_OPT_G_RUNTIME,
1688 .name = "clocksource",
1689 .lname = "Clock source",
1690 .type = FIO_OPT_STR,
1691 .cb = fio_clock_source_cb,
1692 .off1 = td_var_offset(clocksource),
1693 .help = "What type of timing source to use",
1694 .category = FIO_OPT_C_GENERAL,
1695 .group = FIO_OPT_G_CLOCK,
1697 { .ival = "gettimeofday",
1699 .help = "Use gettimeofday(2) for timing",
1701 { .ival = "clock_gettime",
1702 .oval = CS_CGETTIME,
1703 .help = "Use clock_gettime(2) for timing",
1705 #ifdef ARCH_HAVE_CPU_CLOCK
1707 .oval = CS_CPUCLOCK,
1708 .help = "Use CPU private clock",
1716 .lname = "I/O Memory",
1717 .type = FIO_OPT_STR,
1719 .off1 = td_var_offset(mem_type),
1720 .help = "Backing type for IO buffers",
1722 .category = FIO_OPT_C_IO,
1723 .group = FIO_OPT_G_INVALID,
1727 .help = "Use malloc(3) for IO buffers",
1731 .help = "Use shared memory segments for IO buffers",
1733 #ifdef FIO_HAVE_HUGETLB
1734 { .ival = "shmhuge",
1735 .oval = MEM_SHMHUGE,
1736 .help = "Like shm, but use huge pages",
1741 .help = "Use mmap(2) (file or anon) for IO buffers",
1743 #ifdef FIO_HAVE_HUGETLB
1744 { .ival = "mmaphuge",
1745 .oval = MEM_MMAPHUGE,
1746 .help = "Like mmap, but use huge pages",
1752 .name = "iomem_align",
1753 .alias = "mem_align",
1754 .lname = "I/O memory alignment",
1755 .type = FIO_OPT_INT,
1756 .off1 = td_var_offset(mem_align),
1758 .help = "IO memory buffer offset alignment",
1762 .category = FIO_OPT_C_IO,
1763 .group = FIO_OPT_G_INVALID,
1768 .type = FIO_OPT_STR,
1769 .off1 = td_var_offset(verify),
1770 .help = "Verify data written",
1772 .category = FIO_OPT_C_IO,
1773 .group = FIO_OPT_G_VERIFY,
1776 .oval = VERIFY_NONE,
1777 .help = "Don't do IO verification",
1781 .help = "Use md5 checksums for verification",
1784 .oval = VERIFY_CRC64,
1785 .help = "Use crc64 checksums for verification",
1788 .oval = VERIFY_CRC32,
1789 .help = "Use crc32 checksums for verification",
1791 { .ival = "crc32c-intel",
1792 .oval = VERIFY_CRC32C,
1793 .help = "Use crc32c checksums for verification (hw assisted, if available)",
1796 .oval = VERIFY_CRC32C,
1797 .help = "Use crc32c checksums for verification (hw assisted, if available)",
1800 .oval = VERIFY_CRC16,
1801 .help = "Use crc16 checksums for verification",
1804 .oval = VERIFY_CRC7,
1805 .help = "Use crc7 checksums for verification",
1808 .oval = VERIFY_SHA1,
1809 .help = "Use sha1 checksums for verification",
1812 .oval = VERIFY_SHA256,
1813 .help = "Use sha256 checksums for verification",
1816 .oval = VERIFY_SHA512,
1817 .help = "Use sha512 checksums for verification",
1820 .oval = VERIFY_META,
1821 .help = "Use io information",
1825 .oval = VERIFY_NULL,
1826 .help = "Pretend to verify",
1831 .name = "do_verify",
1832 .lname = "Perform verify step",
1833 .type = FIO_OPT_BOOL,
1834 .off1 = td_var_offset(do_verify),
1835 .help = "Run verification stage after write",
1839 .category = FIO_OPT_C_IO,
1840 .group = FIO_OPT_G_VERIFY,
1843 .name = "verifysort",
1844 .lname = "Verify sort",
1845 .type = FIO_OPT_BOOL,
1846 .off1 = td_var_offset(verifysort),
1847 .help = "Sort written verify blocks for read back",
1851 .category = FIO_OPT_C_IO,
1852 .group = FIO_OPT_G_VERIFY,
1855 .name = "verify_interval",
1856 .lname = "Verify interval",
1857 .type = FIO_OPT_INT,
1858 .off1 = td_var_offset(verify_interval),
1859 .minval = 2 * sizeof(struct verify_header),
1860 .help = "Store verify buffer header every N bytes",
1863 .interval = 2 * sizeof(struct verify_header),
1864 .category = FIO_OPT_C_IO,
1865 .group = FIO_OPT_G_VERIFY,
1868 .name = "verify_offset",
1869 .lname = "Verify offset",
1870 .type = FIO_OPT_INT,
1871 .help = "Offset verify header location by N bytes",
1873 .cb = str_verify_offset_cb,
1876 .category = FIO_OPT_C_IO,
1877 .group = FIO_OPT_G_VERIFY,
1880 .name = "verify_pattern",
1881 .lname = "Verify pattern",
1882 .type = FIO_OPT_STR,
1883 .cb = str_verify_pattern_cb,
1884 .help = "Fill pattern for IO buffers",
1887 .category = FIO_OPT_C_IO,
1888 .group = FIO_OPT_G_VERIFY,
1891 .name = "verify_fatal",
1892 .lname = "Verify fatal",
1893 .type = FIO_OPT_BOOL,
1894 .off1 = td_var_offset(verify_fatal),
1896 .help = "Exit on a single verify failure, don't continue",
1899 .category = FIO_OPT_C_IO,
1900 .group = FIO_OPT_G_VERIFY,
1903 .name = "verify_dump",
1904 .lname = "Verify dump",
1905 .type = FIO_OPT_BOOL,
1906 .off1 = td_var_offset(verify_dump),
1908 .help = "Dump contents of good and bad blocks on failure",
1911 .category = FIO_OPT_C_IO,
1912 .group = FIO_OPT_G_VERIFY,
1915 .name = "verify_async",
1916 .lname = "Verify asynchronously",
1917 .type = FIO_OPT_INT,
1918 .off1 = td_var_offset(verify_async),
1920 .help = "Number of async verifier threads to use",
1923 .category = FIO_OPT_C_IO,
1924 .group = FIO_OPT_G_VERIFY,
1927 .name = "verify_backlog",
1928 .lname = "Verify backlog",
1929 .type = FIO_OPT_STR_VAL,
1930 .off1 = td_var_offset(verify_backlog),
1931 .help = "Verify after this number of blocks are written",
1934 .category = FIO_OPT_C_IO,
1935 .group = FIO_OPT_G_VERIFY,
1938 .name = "verify_backlog_batch",
1939 .lname = "Verify backlog batch",
1940 .type = FIO_OPT_INT,
1941 .off1 = td_var_offset(verify_batch),
1942 .help = "Verify this number of IO blocks",
1945 .category = FIO_OPT_C_IO,
1946 .group = FIO_OPT_G_VERIFY,
1948 #ifdef FIO_HAVE_CPU_AFFINITY
1950 .name = "verify_async_cpus",
1951 .lname = "Async verify CPUs",
1952 .type = FIO_OPT_STR,
1953 .cb = str_verify_cpus_allowed_cb,
1954 .help = "Set CPUs allowed for async verify threads",
1955 .parent = "verify_async",
1957 .category = FIO_OPT_C_IO,
1958 .group = FIO_OPT_G_VERIFY,
1961 #ifdef FIO_HAVE_TRIM
1963 .name = "trim_percentage",
1964 .lname = "Trim percentage",
1965 .type = FIO_OPT_INT,
1966 .cb = str_verify_trim_cb,
1969 .help = "Number of verify blocks to discard/trim",
1974 .category = FIO_OPT_C_IO,
1975 .group = FIO_OPT_G_TRIM,
1978 .name = "trim_verify_zero",
1979 .lname = "Verify trim zero",
1980 .type = FIO_OPT_BOOL,
1981 .help = "Verify that trim/discarded blocks are returned as zeroes",
1982 .off1 = td_var_offset(trim_zero),
1983 .parent = "trim_percentage",
1986 .category = FIO_OPT_C_IO,
1987 .group = FIO_OPT_G_TRIM,
1990 .name = "trim_backlog",
1991 .lname = "Trim backlog",
1992 .type = FIO_OPT_STR_VAL,
1993 .off1 = td_var_offset(trim_backlog),
1994 .help = "Trim after this number of blocks are written",
1995 .parent = "trim_percentage",
1998 .category = FIO_OPT_C_IO,
1999 .group = FIO_OPT_G_TRIM,
2002 .name = "trim_backlog_batch",
2003 .lname = "Trim backlog batch",
2004 .type = FIO_OPT_INT,
2005 .off1 = td_var_offset(trim_batch),
2006 .help = "Trim this number of IO blocks",
2007 .parent = "trim_percentage",
2010 .category = FIO_OPT_C_IO,
2011 .group = FIO_OPT_G_TRIM,
2015 .name = "write_iolog",
2016 .lname = "Write I/O log",
2017 .type = FIO_OPT_STR_STORE,
2018 .off1 = td_var_offset(write_iolog_file),
2019 .help = "Store IO pattern to file",
2020 .category = FIO_OPT_C_IO,
2021 .group = FIO_OPT_G_IOLOG,
2024 .name = "read_iolog",
2025 .lname = "Read I/O log",
2026 .type = FIO_OPT_STR_STORE,
2027 .off1 = td_var_offset(read_iolog_file),
2028 .help = "Playback IO pattern from file",
2029 .category = FIO_OPT_C_IO,
2030 .group = FIO_OPT_G_IOLOG,
2033 .name = "replay_no_stall",
2034 .lname = "Don't stall on replay",
2035 .type = FIO_OPT_BOOL,
2036 .off1 = td_var_offset(no_stall),
2038 .parent = "read_iolog",
2040 .help = "Playback IO pattern file as fast as possible without stalls",
2041 .category = FIO_OPT_C_IO,
2042 .group = FIO_OPT_G_IOLOG,
2045 .name = "replay_redirect",
2046 .lname = "Redirect device for replay",
2047 .type = FIO_OPT_STR_STORE,
2048 .off1 = td_var_offset(replay_redirect),
2049 .parent = "read_iolog",
2051 .help = "Replay all I/O onto this device, regardless of trace device",
2052 .category = FIO_OPT_C_IO,
2053 .group = FIO_OPT_G_IOLOG,
2056 .name = "exec_prerun",
2057 .lname = "Pre-execute runnable",
2058 .type = FIO_OPT_STR_STORE,
2059 .off1 = td_var_offset(exec_prerun),
2060 .help = "Execute this file prior to running job",
2061 .category = FIO_OPT_C_GENERAL,
2062 .group = FIO_OPT_G_INVALID,
2065 .name = "exec_postrun",
2066 .lname = "Post-execute runnable",
2067 .type = FIO_OPT_STR_STORE,
2068 .off1 = td_var_offset(exec_postrun),
2069 .help = "Execute this file after running job",
2070 .category = FIO_OPT_C_GENERAL,
2071 .group = FIO_OPT_G_INVALID,
2073 #ifdef FIO_HAVE_IOSCHED_SWITCH
2075 .name = "ioscheduler",
2076 .lname = "I/O scheduler",
2077 .type = FIO_OPT_STR_STORE,
2078 .off1 = td_var_offset(ioscheduler),
2079 .help = "Use this IO scheduler on the backing device",
2080 .category = FIO_OPT_C_FILE,
2081 .group = FIO_OPT_G_INVALID,
2086 .lname = "Zone size",
2087 .type = FIO_OPT_STR_VAL,
2088 .off1 = td_var_offset(zone_size),
2089 .help = "Amount of data to read per zone",
2091 .interval = 1024 * 1024,
2092 .category = FIO_OPT_C_IO,
2093 .group = FIO_OPT_G_ZONE,
2096 .name = "zonerange",
2097 .lname = "Zone range",
2098 .type = FIO_OPT_STR_VAL,
2099 .off1 = td_var_offset(zone_range),
2100 .help = "Give size of an IO zone",
2102 .interval = 1024 * 1024,
2103 .category = FIO_OPT_C_IO,
2104 .group = FIO_OPT_G_ZONE,
2108 .lname = "Zone skip",
2109 .type = FIO_OPT_STR_VAL,
2110 .off1 = td_var_offset(zone_skip),
2111 .help = "Space between IO zones",
2113 .interval = 1024 * 1024,
2114 .category = FIO_OPT_C_IO,
2115 .group = FIO_OPT_G_ZONE,
2119 .lname = "Lock memory",
2120 .type = FIO_OPT_STR_VAL,
2121 .off1 = td_var_offset(lockmem),
2122 .help = "Lock down this amount of memory",
2124 .interval = 1024 * 1024,
2125 .category = FIO_OPT_C_GENERAL,
2126 .group = FIO_OPT_G_INVALID,
2129 .name = "rwmixread",
2130 .lname = "Read/write mix read",
2131 .type = FIO_OPT_INT,
2132 .cb = str_rwmix_read_cb,
2134 .help = "Percentage of mixed workload that is reads",
2137 .inverse = "rwmixwrite",
2138 .category = FIO_OPT_C_IO,
2139 .group = FIO_OPT_G_RWMIX,
2142 .name = "rwmixwrite",
2143 .lname = "Read/write mix write",
2144 .type = FIO_OPT_INT,
2145 .cb = str_rwmix_write_cb,
2147 .help = "Percentage of mixed workload that is writes",
2150 .inverse = "rwmixread",
2151 .category = FIO_OPT_C_IO,
2152 .group = FIO_OPT_G_RWMIX,
2155 .name = "rwmixcycle",
2156 .lname = "Read/write mix cycle",
2157 .type = FIO_OPT_DEPRECATED,
2158 .category = FIO_OPT_C_IO,
2159 .group = FIO_OPT_G_RWMIX,
2164 .type = FIO_OPT_INT,
2165 .off1 = td_var_offset(nice),
2166 .help = "Set job CPU nice value",
2171 .category = FIO_OPT_C_GENERAL,
2172 .group = FIO_OPT_G_CRED,
2174 #ifdef FIO_HAVE_IOPRIO
2177 .lname = "I/O nice priority",
2178 .type = FIO_OPT_INT,
2180 .help = "Set job IO priority value",
2184 .category = FIO_OPT_C_GENERAL,
2185 .group = FIO_OPT_G_CRED,
2188 .name = "prioclass",
2189 .lname = "I/O nice priority class",
2190 .type = FIO_OPT_INT,
2191 .cb = str_prioclass_cb,
2192 .help = "Set job IO priority class",
2196 .category = FIO_OPT_C_GENERAL,
2197 .group = FIO_OPT_G_CRED,
2201 .name = "thinktime",
2202 .lname = "Thinktime",
2203 .type = FIO_OPT_INT,
2204 .off1 = td_var_offset(thinktime),
2205 .help = "Idle time between IO buffers (usec)",
2207 .category = FIO_OPT_C_IO,
2208 .group = FIO_OPT_G_THINKTIME,
2211 .name = "thinktime_spin",
2212 .lname = "Thinktime spin",
2213 .type = FIO_OPT_INT,
2214 .off1 = td_var_offset(thinktime_spin),
2215 .help = "Start think time by spinning this amount (usec)",
2217 .parent = "thinktime",
2219 .category = FIO_OPT_C_IO,
2220 .group = FIO_OPT_G_THINKTIME,
2223 .name = "thinktime_blocks",
2224 .lname = "Thinktime blocks",
2225 .type = FIO_OPT_INT,
2226 .off1 = td_var_offset(thinktime_blocks),
2227 .help = "IO buffer period between 'thinktime'",
2229 .parent = "thinktime",
2231 .category = FIO_OPT_C_IO,
2232 .group = FIO_OPT_G_THINKTIME,
2236 .lname = "I/O rate",
2237 .type = FIO_OPT_INT,
2238 .off1 = td_var_offset(rate[0]),
2239 .off2 = td_var_offset(rate[1]),
2240 .help = "Set bandwidth rate",
2241 .category = FIO_OPT_C_IO,
2242 .group = FIO_OPT_G_RATE,
2246 .lname = "I/O min rate",
2247 .type = FIO_OPT_INT,
2248 .off1 = td_var_offset(ratemin[0]),
2249 .off2 = td_var_offset(ratemin[1]),
2250 .help = "Job must meet this rate or it will be shutdown",
2253 .category = FIO_OPT_C_IO,
2254 .group = FIO_OPT_G_RATE,
2257 .name = "rate_iops",
2258 .lname = "I/O rate IOPS",
2259 .type = FIO_OPT_INT,
2260 .off1 = td_var_offset(rate_iops[0]),
2261 .off2 = td_var_offset(rate_iops[1]),
2262 .help = "Limit IO used to this number of IO operations/sec",
2264 .category = FIO_OPT_C_IO,
2265 .group = FIO_OPT_G_RATE,
2268 .name = "rate_iops_min",
2269 .lname = "I/O min rate IOPS",
2270 .type = FIO_OPT_INT,
2271 .off1 = td_var_offset(rate_iops_min[0]),
2272 .off2 = td_var_offset(rate_iops_min[1]),
2273 .help = "Job must meet this rate or it will be shut down",
2274 .parent = "rate_iops",
2276 .category = FIO_OPT_C_IO,
2277 .group = FIO_OPT_G_RATE,
2280 .name = "ratecycle",
2281 .lname = "I/O rate cycle",
2282 .type = FIO_OPT_INT,
2283 .off1 = td_var_offset(ratecycle),
2284 .help = "Window average for rate limits (msec)",
2288 .category = FIO_OPT_C_IO,
2289 .group = FIO_OPT_G_RATE,
2292 .name = "invalidate",
2293 .lname = "Cache invalidate",
2294 .type = FIO_OPT_BOOL,
2295 .off1 = td_var_offset(invalidate_cache),
2296 .help = "Invalidate buffer/page cache prior to running job",
2298 .category = FIO_OPT_C_IO,
2299 .group = FIO_OPT_G_IO_TYPE,
2303 .lname = "Synchronous I/O",
2304 .type = FIO_OPT_BOOL,
2305 .off1 = td_var_offset(sync_io),
2306 .help = "Use O_SYNC for buffered writes",
2308 .parent = "buffered",
2310 .category = FIO_OPT_C_IO,
2311 .group = FIO_OPT_G_IO_TYPE,
2314 .name = "create_serialize",
2315 .lname = "Create serialize",
2316 .type = FIO_OPT_BOOL,
2317 .off1 = td_var_offset(create_serialize),
2318 .help = "Serialize creating of job files",
2320 .category = FIO_OPT_C_FILE,
2321 .group = FIO_OPT_G_INVALID,
2324 .name = "create_fsync",
2325 .lname = "Create fsync",
2326 .type = FIO_OPT_BOOL,
2327 .off1 = td_var_offset(create_fsync),
2328 .help = "fsync file after creation",
2330 .category = FIO_OPT_C_FILE,
2331 .group = FIO_OPT_G_INVALID,
2334 .name = "create_on_open",
2335 .lname = "Create on open",
2336 .type = FIO_OPT_BOOL,
2337 .off1 = td_var_offset(create_on_open),
2338 .help = "Create files when they are opened for IO",
2340 .category = FIO_OPT_C_FILE,
2341 .group = FIO_OPT_G_INVALID,
2345 .lname = "Pre-read files",
2346 .type = FIO_OPT_BOOL,
2347 .off1 = td_var_offset(pre_read),
2348 .help = "Pre-read files before starting official testing",
2350 .category = FIO_OPT_C_FILE,
2351 .group = FIO_OPT_G_INVALID,
2353 #ifdef FIO_HAVE_CPU_AFFINITY
2356 .lname = "CPU mask",
2357 .type = FIO_OPT_INT,
2358 .cb = str_cpumask_cb,
2359 .help = "CPU affinity mask",
2360 .category = FIO_OPT_C_GENERAL,
2361 .group = FIO_OPT_G_CRED,
2364 .name = "cpus_allowed",
2365 .lname = "CPUs allowed",
2366 .type = FIO_OPT_STR,
2367 .cb = str_cpus_allowed_cb,
2368 .help = "Set CPUs allowed",
2369 .category = FIO_OPT_C_GENERAL,
2370 .group = FIO_OPT_G_CRED,
2374 .name = "end_fsync",
2375 .lname = "End fsync",
2376 .type = FIO_OPT_BOOL,
2377 .off1 = td_var_offset(end_fsync),
2378 .help = "Include fsync at the end of job",
2380 .category = FIO_OPT_C_FILE,
2381 .group = FIO_OPT_G_INVALID,
2384 .name = "fsync_on_close",
2385 .lname = "Fsync on close",
2386 .type = FIO_OPT_BOOL,
2387 .off1 = td_var_offset(fsync_on_close),
2388 .help = "fsync files on close",
2390 .category = FIO_OPT_C_FILE,
2391 .group = FIO_OPT_G_INVALID,
2395 .lname = "Unlink file",
2396 .type = FIO_OPT_BOOL,
2397 .off1 = td_var_offset(unlink),
2398 .help = "Unlink created files after job has completed",
2400 .category = FIO_OPT_C_FILE,
2401 .group = FIO_OPT_G_INVALID,
2405 .lname = "Exit-all on terminate",
2406 .type = FIO_OPT_STR_SET,
2407 .cb = str_exitall_cb,
2408 .help = "Terminate all jobs when one exits",
2409 .category = FIO_OPT_C_GENERAL,
2410 .group = FIO_OPT_G_PROCESS,
2413 .name = "stonewall",
2414 .lname = "Wait for previous",
2415 .alias = "wait_for_previous",
2416 .type = FIO_OPT_STR_SET,
2417 .off1 = td_var_offset(stonewall),
2418 .help = "Insert a hard barrier between this job and previous",
2419 .category = FIO_OPT_C_GENERAL,
2420 .group = FIO_OPT_G_PROCESS,
2423 .name = "new_group",
2424 .lname = "New group",
2425 .type = FIO_OPT_STR_SET,
2426 .off1 = td_var_offset(new_group),
2427 .help = "Mark the start of a new group (for reporting)",
2428 .category = FIO_OPT_C_GENERAL,
2429 .group = FIO_OPT_G_PROCESS,
2434 .type = FIO_OPT_STR_SET,
2435 .off1 = td_var_offset(use_thread),
2436 .help = "Use threads instead of processes",
2437 .category = FIO_OPT_C_GENERAL,
2438 .group = FIO_OPT_G_PROCESS,
2441 .name = "write_bw_log",
2442 .lname = "Write bandwidth log",
2443 .type = FIO_OPT_STR,
2444 .off1 = td_var_offset(write_bw_log),
2445 .cb = str_write_bw_log_cb,
2446 .help = "Write log of bandwidth during run",
2447 .category = FIO_OPT_C_LOG,
2448 .group = FIO_OPT_G_INVALID,
2451 .name = "write_lat_log",
2452 .lname = "Write latency log",
2453 .type = FIO_OPT_STR,
2454 .off1 = td_var_offset(write_lat_log),
2455 .cb = str_write_lat_log_cb,
2456 .help = "Write log of latency during run",
2457 .category = FIO_OPT_C_LOG,
2458 .group = FIO_OPT_G_INVALID,
2461 .name = "write_iops_log",
2462 .lname = "Write IOPS log",
2463 .type = FIO_OPT_STR,
2464 .off1 = td_var_offset(write_iops_log),
2465 .cb = str_write_iops_log_cb,
2466 .help = "Write log of IOPS during run",
2467 .category = FIO_OPT_C_LOG,
2468 .group = FIO_OPT_G_INVALID,
2471 .name = "log_avg_msec",
2472 .lname = "Log averaging (msec)",
2473 .type = FIO_OPT_INT,
2474 .off1 = td_var_offset(log_avg_msec),
2475 .help = "Average bw/iops/lat logs over this period of time",
2477 .category = FIO_OPT_C_LOG,
2478 .group = FIO_OPT_G_INVALID,
2481 .name = "bwavgtime",
2482 .lname = "Bandwidth average time",
2483 .type = FIO_OPT_INT,
2484 .off1 = td_var_offset(bw_avg_time),
2485 .help = "Time window over which to calculate bandwidth"
2488 .parent = "write_bw_log",
2491 .category = FIO_OPT_C_LOG,
2492 .group = FIO_OPT_G_INVALID,
2495 .name = "iopsavgtime",
2496 .lname = "IOPS average time",
2497 .type = FIO_OPT_INT,
2498 .off1 = td_var_offset(iops_avg_time),
2499 .help = "Time window over which to calculate IOPS (msec)",
2501 .parent = "write_iops_log",
2504 .category = FIO_OPT_C_LOG,
2505 .group = FIO_OPT_G_INVALID,
2508 .name = "group_reporting",
2509 .lname = "Group reporting",
2510 .type = FIO_OPT_BOOL,
2511 .off1 = td_var_offset(group_reporting),
2512 .help = "Do reporting on a per-group basis",
2514 .category = FIO_OPT_C_STAT,
2515 .group = FIO_OPT_G_INVALID,
2518 .name = "zero_buffers",
2519 .lname = "Zero I/O buffers",
2520 .type = FIO_OPT_STR_SET,
2521 .off1 = td_var_offset(zero_buffers),
2522 .help = "Init IO buffers to all zeroes",
2523 .category = FIO_OPT_C_IO,
2524 .group = FIO_OPT_G_IO_BUF,
2527 .name = "refill_buffers",
2528 .lname = "Refill I/O buffers",
2529 .type = FIO_OPT_STR_SET,
2530 .off1 = td_var_offset(refill_buffers),
2531 .help = "Refill IO buffers on every IO submit",
2532 .category = FIO_OPT_C_IO,
2533 .group = FIO_OPT_G_IO_BUF,
2536 .name = "scramble_buffers",
2537 .lname = "Scramble I/O buffers",
2538 .type = FIO_OPT_BOOL,
2539 .off1 = td_var_offset(scramble_buffers),
2540 .help = "Slightly scramble buffers on every IO submit",
2542 .category = FIO_OPT_C_IO,
2543 .group = FIO_OPT_G_IO_BUF,
2546 .name = "buffer_compress_percentage",
2547 .lname = "Buffer compression percentage",
2548 .type = FIO_OPT_INT,
2549 .off1 = td_var_offset(compress_percentage),
2552 .help = "How compressible the buffer is (approximately)",
2554 .category = FIO_OPT_C_IO,
2555 .group = FIO_OPT_G_IO_BUF,
2558 .name = "buffer_compress_chunk",
2559 .lname = "Buffer compression chunk size",
2560 .type = FIO_OPT_INT,
2561 .off1 = td_var_offset(compress_chunk),
2562 .parent = "buffer_compress_percentage",
2564 .help = "Size of compressible region in buffer",
2566 .category = FIO_OPT_C_IO,
2567 .group = FIO_OPT_G_IO_BUF,
2570 .name = "clat_percentiles",
2571 .lname = "Completion latency percentiles",
2572 .type = FIO_OPT_BOOL,
2573 .off1 = td_var_offset(clat_percentiles),
2574 .help = "Enable the reporting of completion latency percentiles",
2576 .category = FIO_OPT_C_STAT,
2577 .group = FIO_OPT_G_INVALID,
2580 .name = "percentile_list",
2581 .lname = "Completion latency percentile list",
2582 .type = FIO_OPT_FLOAT_LIST,
2583 .off1 = td_var_offset(percentile_list),
2584 .off2 = td_var_offset(overwrite_plist),
2585 .help = "Specify a custom list of percentiles to report",
2586 .maxlen = FIO_IO_U_LIST_MAX_LEN,
2589 .category = FIO_OPT_C_STAT,
2590 .group = FIO_OPT_G_INVALID,
2593 #ifdef FIO_HAVE_DISK_UTIL
2595 .name = "disk_util",
2596 .lname = "Disk utilization",
2597 .type = FIO_OPT_BOOL,
2598 .off1 = td_var_offset(do_disk_util),
2599 .help = "Log disk utilization statistics",
2601 .category = FIO_OPT_C_STAT,
2602 .group = FIO_OPT_G_INVALID,
2606 .name = "gtod_reduce",
2607 .lname = "Reduce gettimeofday() calls",
2608 .type = FIO_OPT_BOOL,
2609 .help = "Greatly reduce number of gettimeofday() calls",
2610 .cb = str_gtod_reduce_cb,
2613 .category = FIO_OPT_C_STAT,
2614 .group = FIO_OPT_G_INVALID,
2617 .name = "disable_lat",
2618 .lname = "Disable all latency stats",
2619 .type = FIO_OPT_BOOL,
2620 .off1 = td_var_offset(disable_lat),
2621 .help = "Disable latency numbers",
2622 .parent = "gtod_reduce",
2625 .category = FIO_OPT_C_STAT,
2626 .group = FIO_OPT_G_INVALID,
2629 .name = "disable_clat",
2630 .lname = "Disable completion latency stats",
2631 .type = FIO_OPT_BOOL,
2632 .off1 = td_var_offset(disable_clat),
2633 .help = "Disable completion latency numbers",
2634 .parent = "gtod_reduce",
2637 .category = FIO_OPT_C_STAT,
2638 .group = FIO_OPT_G_INVALID,
2641 .name = "disable_slat",
2642 .lname = "Disable submission latency stats",
2643 .type = FIO_OPT_BOOL,
2644 .off1 = td_var_offset(disable_slat),
2645 .help = "Disable submission latency numbers",
2646 .parent = "gtod_reduce",
2649 .category = FIO_OPT_C_STAT,
2650 .group = FIO_OPT_G_INVALID,
2653 .name = "disable_bw_measurement",
2654 .lname = "Disable bandwidth stats",
2655 .type = FIO_OPT_BOOL,
2656 .off1 = td_var_offset(disable_bw),
2657 .help = "Disable bandwidth logging",
2658 .parent = "gtod_reduce",
2661 .category = FIO_OPT_C_STAT,
2662 .group = FIO_OPT_G_INVALID,
2666 .lname = "Dedicated gettimeofday() CPU",
2667 .type = FIO_OPT_INT,
2668 .cb = str_gtod_cpu_cb,
2669 .help = "Set up dedicated gettimeofday() thread on this CPU",
2670 .verify = gtod_cpu_verify,
2671 .category = FIO_OPT_C_GENERAL,
2672 .group = FIO_OPT_G_CLOCK,
2675 .name = "continue_on_error",
2676 .lname = "Continue on error",
2677 .type = FIO_OPT_STR,
2678 .off1 = td_var_offset(continue_on_error),
2679 .help = "Continue on non-fatal errors during IO",
2681 .category = FIO_OPT_C_GENERAL,
2682 .group = FIO_OPT_G_INVALID,
2685 .oval = ERROR_TYPE_NONE,
2686 .help = "Exit when an error is encountered",
2689 .oval = ERROR_TYPE_READ,
2690 .help = "Continue on read errors only",
2693 .oval = ERROR_TYPE_WRITE,
2694 .help = "Continue on write errors only",
2697 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
2698 .help = "Continue on any IO errors",
2701 .oval = ERROR_TYPE_VERIFY,
2702 .help = "Continue on verify errors only",
2705 .oval = ERROR_TYPE_ANY,
2706 .help = "Continue on all io and verify errors",
2709 .oval = ERROR_TYPE_NONE,
2710 .help = "Alias for 'none'",
2713 .oval = ERROR_TYPE_ANY,
2714 .help = "Alias for 'all'",
2721 .type = FIO_OPT_STR_STORE,
2722 .off1 = td_var_offset(profile),
2723 .help = "Select a specific builtin performance test",
2724 .category = FIO_OPT_C_GENERAL,
2725 .group = FIO_OPT_G_INVALID,
2730 .type = FIO_OPT_STR_STORE,
2731 .off1 = td_var_offset(cgroup),
2732 .help = "Add job to cgroup of this name",
2733 .category = FIO_OPT_C_GENERAL,
2734 .group = FIO_OPT_G_CGROUP,
2737 .name = "cgroup_nodelete",
2738 .lname = "Cgroup no-delete",
2739 .type = FIO_OPT_BOOL,
2740 .off1 = td_var_offset(cgroup_nodelete),
2741 .help = "Do not delete cgroups after job completion",
2744 .category = FIO_OPT_C_GENERAL,
2745 .group = FIO_OPT_G_CGROUP,
2748 .name = "cgroup_weight",
2749 .lname = "Cgroup weight",
2750 .type = FIO_OPT_INT,
2751 .off1 = td_var_offset(cgroup_weight),
2752 .help = "Use given weight for cgroup",
2756 .category = FIO_OPT_C_GENERAL,
2757 .group = FIO_OPT_G_CGROUP,
2762 .type = FIO_OPT_INT,
2763 .off1 = td_var_offset(uid),
2764 .help = "Run job with this user ID",
2765 .category = FIO_OPT_C_GENERAL,
2766 .group = FIO_OPT_G_CRED,
2770 .lname = "Group ID",
2771 .type = FIO_OPT_INT,
2772 .off1 = td_var_offset(gid),
2773 .help = "Run job with this group ID",
2774 .category = FIO_OPT_C_GENERAL,
2775 .group = FIO_OPT_G_CRED,
2780 .type = FIO_OPT_INT,
2781 .off1 = td_var_offset(kb_base),
2782 .verify = kb_base_verify,
2785 .help = "How many bytes per KB for reporting (1000 or 1024)",
2786 .category = FIO_OPT_C_GENERAL,
2787 .group = FIO_OPT_G_INVALID,
2790 .name = "hugepage-size",
2791 .lname = "Hugepage size",
2792 .type = FIO_OPT_INT,
2793 .off1 = td_var_offset(hugepage_size),
2794 .help = "When using hugepages, specify size of each page",
2795 .def = __fio_stringify(FIO_HUGE_PAGE),
2796 .interval = 1024 * 1024,
2797 .category = FIO_OPT_C_GENERAL,
2798 .group = FIO_OPT_G_INVALID,
2802 .lname = "I/O flow ID",
2803 .type = FIO_OPT_INT,
2804 .off1 = td_var_offset(flow_id),
2805 .help = "The flow index ID to use",
2807 .category = FIO_OPT_C_IO,
2808 .group = FIO_OPT_G_IO_FLOW,
2812 .lname = "I/O flow weight",
2813 .type = FIO_OPT_INT,
2814 .off1 = td_var_offset(flow),
2815 .help = "Weight for flow control of this job",
2816 .parent = "flow_id",
2819 .category = FIO_OPT_C_IO,
2820 .group = FIO_OPT_G_IO_FLOW,
2823 .name = "flow_watermark",
2824 .lname = "I/O flow watermark",
2825 .type = FIO_OPT_INT,
2826 .off1 = td_var_offset(flow_watermark),
2827 .help = "High watermark for flow control. This option"
2828 " should be set to the same value for all threads"
2829 " with non-zero flow.",
2830 .parent = "flow_id",
2833 .category = FIO_OPT_C_IO,
2834 .group = FIO_OPT_G_IO_FLOW,
2837 .name = "flow_sleep",
2838 .lname = "I/O flow sleep",
2839 .type = FIO_OPT_INT,
2840 .off1 = td_var_offset(flow_sleep),
2841 .help = "How many microseconds to sleep after being held"
2842 " back by the flow control mechanism",
2843 .parent = "flow_id",
2846 .category = FIO_OPT_C_IO,
2847 .group = FIO_OPT_G_IO_FLOW,
2854 static void add_to_lopt(struct option *lopt, struct fio_option *o,
2855 const char *name, int val)
2857 lopt->name = (char *) name;
2859 if (o->type == FIO_OPT_STR_SET)
2860 lopt->has_arg = no_argument;
2862 lopt->has_arg = required_argument;
2865 static void options_to_lopts(struct fio_option *opts,
2866 struct option *long_options,
2867 int i, int option_type)
2869 struct fio_option *o = &opts[0];
2871 add_to_lopt(&long_options[i], o, o->name, option_type);
2874 add_to_lopt(&long_options[i], o, o->alias, option_type);
2879 assert(i < FIO_NR_OPTIONS);
2883 void fio_options_set_ioengine_opts(struct option *long_options,
2884 struct thread_data *td)
2889 while (long_options[i].name) {
2890 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
2891 memset(&long_options[i], 0, sizeof(*long_options));
2898 * Just clear out the prior ioengine options.
2903 options_to_lopts(td->io_ops->options, long_options, i,
2904 FIO_GETOPT_IOENGINE);
2907 void fio_options_dup_and_init(struct option *long_options)
2911 options_init(fio_options);
2914 while (long_options[i].name)
2917 options_to_lopts(fio_options, long_options, i, FIO_GETOPT_JOB);
2920 struct fio_keyword {
2926 static struct fio_keyword fio_keywords[] = {
2928 .word = "$pagesize",
2929 .desc = "Page size in the system",
2932 .word = "$mb_memory",
2933 .desc = "Megabytes of memory online",
2937 .desc = "Number of CPUs online in the system",
2944 void fio_keywords_init(void)
2946 unsigned long long mb_memory;
2950 sprintf(buf, "%lu", page_size);
2951 fio_keywords[0].replace = strdup(buf);
2953 mb_memory = os_phys_mem() / (1024 * 1024);
2954 sprintf(buf, "%llu", mb_memory);
2955 fio_keywords[1].replace = strdup(buf);
2958 sprintf(buf, "%lu", l);
2959 fio_keywords[2].replace = strdup(buf);
2964 static char *bc_calc(char *str)
2966 char buf[128], *tmp;
2971 * No math, just return string
2973 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
2974 !strchr(str, '/')) || strchr(str, '\''))
2978 * Split option from value, we only need to calculate the value
2980 tmp = strchr(str, '=');
2987 * Prevent buffer overflows; such a case isn't reasonable anyway
2989 if (strlen(str) >= 128 || strlen(tmp) > 100)
2992 sprintf(buf, "which %s > /dev/null", BC_APP);
2994 log_err("fio: bc is needed for performing math\n");
2998 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
2999 f = popen(buf, "r");
3003 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
3008 buf[(tmp - str) + ret - 1] = '\0';
3009 memcpy(buf, str, tmp - str);
3015 * Return a copy of the input string with substrings of the form ${VARNAME}
3016 * substituted with the value of the environment variable VARNAME. The
3017 * substitution always occurs, even if VARNAME is empty or the corresponding
3018 * environment variable undefined.
3020 static char *option_dup_subs(const char *opt)
3022 char out[OPT_LEN_MAX+1];
3023 char in[OPT_LEN_MAX+1];
3026 char *ch1, *ch2, *env;
3027 ssize_t nchr = OPT_LEN_MAX;
3030 if (strlen(opt) + 1 > OPT_LEN_MAX) {
3031 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
3035 in[OPT_LEN_MAX] = '\0';
3036 strncpy(in, opt, OPT_LEN_MAX);
3038 while (*inptr && nchr > 0) {
3039 if (inptr[0] == '$' && inptr[1] == '{') {
3040 ch2 = strchr(inptr, '}');
3041 if (ch2 && inptr+1 < ch2) {
3048 envlen = strlen(env);
3049 if (envlen <= nchr) {
3050 memcpy(outptr, env, envlen);
3060 *outptr++ = *inptr++;
3069 * Look for reserved variable names and replace them with real values
3071 static char *fio_keyword_replace(char *opt)
3077 for (i = 0; fio_keywords[i].word != NULL; i++) {
3078 struct fio_keyword *kw = &fio_keywords[i];
3080 while ((s = strstr(opt, kw->word)) != NULL) {
3081 char *new = malloc(strlen(opt) + 1);
3087 * Copy part of the string before the keyword and
3088 * sprintf() the replacement after it.
3090 memcpy(new, opt, olen);
3091 len = sprintf(new + olen, "%s", kw->replace);
3094 * If there's more in the original string, copy that
3097 opt += strlen(kw->word) + olen;
3099 memcpy(new + olen + len, opt, opt - o_org - 1);
3102 * replace opt and free the old opt
3112 * Check for potential math and invoke bc, if possible
3120 static char **dup_and_sub_options(char **opts, int num_opts)
3123 char **opts_copy = malloc(num_opts * sizeof(*opts));
3124 for (i = 0; i < num_opts; i++) {
3125 opts_copy[i] = option_dup_subs(opts[i]);
3128 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
3133 int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
3135 int i, ret, unknown;
3138 sort_options(opts, fio_options, num_opts);
3139 opts_copy = dup_and_sub_options(opts, num_opts);
3141 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
3142 struct fio_option *o;
3143 int newret = parse_option(opts_copy[i], opts[i], fio_options,
3152 opts_copy[i] = NULL;
3159 ret |= ioengine_load(td);
3161 sort_options(opts_copy, td->io_ops->options, num_opts);
3164 for (i = 0; i < num_opts; i++) {
3165 struct fio_option *o = NULL;
3171 newret = parse_option(opts_copy[i], opts[i],
3172 td->io_ops->options, &o,
3177 log_err("Bad option <%s>\n", opts[i]);
3180 opts_copy[i] = NULL;
3188 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
3190 return parse_cmd_option(opt, val, fio_options, td);
3193 int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
3196 return parse_cmd_option(opt, val, td->io_ops->options, td);
3199 void fio_fill_default_options(struct thread_data *td)
3201 fill_default_options(td, fio_options);
3204 int fio_show_option_help(const char *opt)
3206 return show_cmd_help(fio_options, opt);
3209 void options_mem_dupe(void *data, struct fio_option *options)
3211 struct fio_option *o;
3214 for (o = &options[0]; o->name; o++) {
3215 if (o->type != FIO_OPT_STR_STORE)
3218 ptr = td_var(data, o->off1);
3220 *ptr = strdup(*ptr);
3225 * dupe FIO_OPT_STR_STORE options
3227 void fio_options_mem_dupe(struct thread_data *td)
3229 options_mem_dupe(&td->o, fio_options);
3231 if (td->eo && td->io_ops) {
3232 void *oldeo = td->eo;
3234 td->eo = malloc(td->io_ops->option_struct_size);
3235 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
3236 options_mem_dupe(td->eo, td->io_ops->options);
3240 unsigned int fio_get_kb_base(void *data)
3242 struct thread_options *o = data;
3243 unsigned int kb_base = 0;
3246 kb_base = o->kb_base;
3253 int add_option(struct fio_option *o)
3255 struct fio_option *__o;
3264 memcpy(&fio_options[opt_index], o, sizeof(*o));
3268 void invalidate_profile_options(const char *prof_name)
3270 struct fio_option *o;
3274 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
3275 o->type = FIO_OPT_INVALID;
3276 o->prof_name = NULL;
3282 void add_opt_posval(const char *optname, const char *ival, const char *help)
3284 struct fio_option *o;
3287 o = find_option(fio_options, optname);
3291 for (i = 0; i < PARSE_MAX_VP; i++) {
3292 if (o->posval[i].ival)
3295 o->posval[i].ival = ival;
3296 o->posval[i].help = help;
3301 void del_opt_posval(const char *optname, const char *ival)
3303 struct fio_option *o;
3306 o = find_option(fio_options, optname);
3310 for (i = 0; i < PARSE_MAX_VP; i++) {
3311 if (!o->posval[i].ival)
3313 if (strcmp(o->posval[i].ival, ival))
3316 o->posval[i].ival = NULL;
3317 o->posval[i].help = NULL;
3321 void fio_options_free(struct thread_data *td)
3323 options_free(fio_options, td);
3324 if (td->eo && td->io_ops && td->io_ops->options) {
3325 options_free(td->io_ops->options, td->eo);
3331 struct fio_option *fio_option_find(const char *name)
3333 return find_option(fio_options, name);