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 str_rw_cb(void *data, const char *str)
218 struct thread_data *td = data;
219 struct thread_options *o = &td->o;
220 char *nr = get_opt_postfix(str);
229 o->ddir_seq_nr = atoi(nr);
233 if (str_to_decimal(nr, &val, 1, o)) {
234 log_err("fio: rw postfix parsing failed\n");
239 o->ddir_seq_add = val;
246 static int str_mem_cb(void *data, const char *mem)
248 struct thread_data *td = data;
249 struct thread_options *o = &td->o;
251 if (o->mem_type == MEM_MMAPHUGE || o->mem_type == MEM_MMAP) {
252 o->mmapfile = get_opt_postfix(mem);
253 if (o->mem_type == MEM_MMAPHUGE && !o->mmapfile) {
254 log_err("fio: mmaphuge:/path/to/file\n");
262 static int fio_clock_source_cb(void *data, const char *str)
264 struct thread_data *td = data;
266 fio_clock_source = td->o.clocksource;
271 static int str_rwmix_read_cb(void *data, unsigned long long *val)
273 struct thread_data *td = data;
275 td->o.rwmix[DDIR_READ] = *val;
276 td->o.rwmix[DDIR_WRITE] = 100 - *val;
280 static int str_rwmix_write_cb(void *data, unsigned long long *val)
282 struct thread_data *td = data;
284 td->o.rwmix[DDIR_WRITE] = *val;
285 td->o.rwmix[DDIR_READ] = 100 - *val;
289 static int str_exitall_cb(void)
291 exitall_on_terminate = 1;
295 #ifdef FIO_HAVE_CPU_AFFINITY
296 static int str_cpumask_cb(void *data, unsigned long long *val)
298 struct thread_data *td = data;
303 ret = fio_cpuset_init(&td->o.cpumask);
305 log_err("fio: cpuset_init failed\n");
306 td_verror(td, ret, "fio_cpuset_init");
310 max_cpu = cpus_online();
312 for (i = 0; i < sizeof(int) * 8; i++) {
313 if ((1 << i) & *val) {
315 log_err("fio: CPU %d too large (max=%ld)\n", i,
319 dprint(FD_PARSE, "set cpu allowed %d\n", i);
320 fio_cpu_set(&td->o.cpumask, i);
324 td->o.cpumask_set = 1;
328 static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask,
335 ret = fio_cpuset_init(mask);
337 log_err("fio: cpuset_init failed\n");
338 td_verror(td, ret, "fio_cpuset_init");
342 p = str = strdup(input);
344 strip_blank_front(&str);
345 strip_blank_end(str);
347 max_cpu = cpus_online();
349 while ((cpu = strsep(&str, ",")) != NULL) {
358 while ((cpu2 = strsep(&str2, "-")) != NULL) {
368 while (icpu <= icpu2) {
369 if (icpu >= FIO_MAX_CPUS) {
370 log_err("fio: your OS only supports up to"
371 " %d CPUs\n", (int) FIO_MAX_CPUS);
375 if (icpu > max_cpu) {
376 log_err("fio: CPU %d too large (max=%ld)\n",
382 dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
383 fio_cpu_set(mask, icpu);
392 td->o.cpumask_set = 1;
396 static int str_cpus_allowed_cb(void *data, const char *input)
398 struct thread_data *td = data;
401 ret = set_cpus_allowed(td, &td->o.cpumask, input);
403 td->o.cpumask_set = 1;
408 static int str_verify_cpus_allowed_cb(void *data, const char *input)
410 struct thread_data *td = data;
413 ret = set_cpus_allowed(td, &td->o.verify_cpumask, input);
415 td->o.verify_cpumask_set = 1;
421 static int str_fst_cb(void *data, const char *str)
423 struct thread_data *td = data;
424 char *nr = get_opt_postfix(str);
426 td->file_service_nr = 1;
428 td->file_service_nr = atoi(nr);
435 #ifdef FIO_HAVE_SYNC_FILE_RANGE
436 static int str_sfr_cb(void *data, const char *str)
438 struct thread_data *td = data;
439 char *nr = get_opt_postfix(str);
441 td->sync_file_range_nr = 1;
443 td->sync_file_range_nr = atoi(nr);
452 * Return next file in the string. Files are separated with ':'. If the ':'
453 * is escaped with a '\', then that ':' is part of the filename and does not
454 * indicate a new file.
456 static char *get_next_file_name(char **ptr)
461 if (!str || !strlen(str))
467 * No colon, we are done
469 p = strchr(str, ':');
476 * We got a colon, but it's the first character. Skip and
484 if (*(p - 1) != '\\') {
490 memmove(p - 1, p, strlen(p) + 1);
497 static int str_filename_cb(void *data, const char *input)
499 struct thread_data *td = data;
500 char *fname, *str, *p;
502 p = str = strdup(input);
504 strip_blank_front(&str);
505 strip_blank_end(str);
507 if (!td->files_index)
510 while ((fname = get_next_file_name(&str)) != NULL) {
521 static int str_directory_cb(void *data, const char fio_unused *str)
523 struct thread_data *td = data;
526 if (lstat(td->o.directory, &sb) < 0) {
529 log_err("fio: %s is not a directory\n", td->o.directory);
530 td_verror(td, ret, "lstat");
533 if (!S_ISDIR(sb.st_mode)) {
534 log_err("fio: %s is not a directory\n", td->o.directory);
541 static int str_opendir_cb(void *data, const char fio_unused *str)
543 struct thread_data *td = data;
545 if (!td->files_index)
548 return add_dir_files(td, td->o.opendir);
551 static int str_verify_pattern_cb(void *data, const char *input)
553 struct thread_data *td = data;
555 int i = 0, j = 0, len, k, base = 10;
558 loc1 = strstr(input, "0x");
559 loc2 = strstr(input, "0X");
562 off = strtol(input, NULL, base);
563 if (off != LONG_MAX || errno != ERANGE) {
565 td->o.verify_pattern[i] = off & 0xff;
574 j = loc1 - input + 2;
576 j = loc2 - input + 2;
579 if (len - j < MAX_PATTERN_SIZE * 2) {
581 off = converthexchartoint(input[k--]);
583 off += (converthexchartoint(input[k--])
585 td->o.verify_pattern[i++] = (char) off;
591 * Fill the pattern all the way to the end. This greatly reduces
592 * the number of memcpy's we have to do when verifying the IO.
594 while (i > 1 && i * 2 <= MAX_PATTERN_SIZE) {
595 memcpy(&td->o.verify_pattern[i], &td->o.verify_pattern[0], i);
600 * The code in verify_io_u_pattern assumes a single byte pattern
601 * fills the whole verify pattern buffer.
603 memset(td->o.verify_pattern, td->o.verify_pattern[0],
607 td->o.verify_pattern_bytes = i;
610 * VERIFY_META could already be set
612 if (td->o.verify == VERIFY_NONE)
613 td->o.verify = VERIFY_PATTERN;
618 static int str_lockfile_cb(void *data, const char *str)
620 struct thread_data *td = data;
621 char *nr = get_opt_postfix(str);
623 td->o.lockfile_batch = 1;
625 td->o.lockfile_batch = atoi(nr);
632 static int str_gtod_reduce_cb(void *data, int *il)
634 struct thread_data *td = data;
637 td->o.disable_lat = !!val;
638 td->o.disable_clat = !!val;
639 td->o.disable_slat = !!val;
640 td->o.disable_bw = !!val;
641 td->o.clat_percentiles = !val;
643 td->tv_cache_mask = 63;
648 static int str_gtod_cpu_cb(void *data, long long *il)
650 struct thread_data *td = data;
653 td->o.gtod_cpu = val;
654 td->o.gtod_offload = 1;
658 static int str_size_cb(void *data, unsigned long long *__val)
660 struct thread_data *td = data;
661 unsigned long long v = *__val;
663 if (parse_is_percent(v)) {
665 td->o.size_percent = -1ULL - v;
672 static int rw_verify(struct fio_option *o, void *data)
674 struct thread_data *td = data;
676 if (read_only && td_write(td)) {
677 log_err("fio: job <%s> has write bit set, but fio is in"
678 " read-only mode\n", td->o.name);
685 static int gtod_cpu_verify(struct fio_option *o, void *data)
687 #ifndef FIO_HAVE_CPU_AFFINITY
688 struct thread_data *td = data;
690 if (td->o.gtod_cpu) {
691 log_err("fio: platform must support CPU affinity for"
692 "gettimeofday() offloading\n");
700 static int kb_base_verify(struct fio_option *o, void *data)
702 struct thread_data *td = data;
704 if (td->o.kb_base != 1024 && td->o.kb_base != 1000) {
705 log_err("fio: kb_base set to nonsensical value: %u\n",
716 static struct opt_group fio_opt_groups[] = {
719 .mask = FIO_OPT_C_GENERAL,
723 .mask = FIO_OPT_C_IO,
727 .mask = FIO_OPT_C_FILE,
730 .name = "Statistics",
731 .mask = FIO_OPT_C_STAT,
735 .mask = FIO_OPT_C_LOG,
739 .mask = FIO_OPT_C_PROFILE,
746 static struct opt_group *__opt_group_from_mask(struct opt_group *ogs, unsigned int *mask,
747 unsigned int inv_mask)
749 struct opt_group *og;
752 if (*mask == inv_mask || !*mask)
755 for (i = 0; ogs[i].name; i++) {
758 if (*mask & og->mask) {
759 *mask &= ~(og->mask);
767 struct opt_group *opt_group_from_mask(unsigned int *mask)
769 return __opt_group_from_mask(fio_opt_groups, mask, FIO_OPT_C_INVALID);
772 static struct opt_group fio_opt_cat_groups[] = {
775 .mask = FIO_OPT_G_RATE,
779 .mask = FIO_OPT_G_ZONE,
782 .name = "Read/write mix",
783 .mask = FIO_OPT_G_RWMIX,
787 .mask = FIO_OPT_G_VERIFY,
791 .mask = FIO_OPT_G_TRIM,
794 .name = "I/O Logging",
795 .mask = FIO_OPT_G_IOLOG,
799 .mask = FIO_OPT_G_IO_DEPTH,
803 .mask = FIO_OPT_G_IO_FLOW,
806 .name = "Description",
807 .mask = FIO_OPT_G_DESC,
811 .mask = FIO_OPT_G_FILENAME,
814 .name = "General I/O",
815 .mask = FIO_OPT_G_IO_BASIC,
819 .mask = FIO_OPT_G_CGROUP,
823 .mask = FIO_OPT_G_RUNTIME,
827 .mask = FIO_OPT_G_PROCESS,
830 .name = "Job credentials / priority",
831 .mask = FIO_OPT_G_CRED,
834 .name = "Clock settings",
835 .mask = FIO_OPT_G_CLOCK,
839 .mask = FIO_OPT_G_IO_TYPE,
842 .name = "I/O Thinktime",
843 .mask = FIO_OPT_G_THINKTIME,
846 .name = "Randomizations",
847 .mask = FIO_OPT_G_RANDOM,
850 .name = "I/O buffers",
851 .mask = FIO_OPT_G_IO_BUF,
854 .name = "Tiobench profile",
855 .mask = FIO_OPT_G_TIOBENCH,
863 struct opt_group *opt_group_cat_from_mask(unsigned int *mask)
865 return __opt_group_from_mask(fio_opt_cat_groups, mask, FIO_OPT_G_INVALID);
869 * Map of job/command line options
871 struct fio_option fio_options[FIO_MAX_OPTS] = {
873 .name = "description",
874 .lname = "Description of job",
875 .type = FIO_OPT_STR_STORE,
876 .off1 = td_var_offset(description),
877 .help = "Text job description",
878 .category = FIO_OPT_C_GENERAL,
879 .group = FIO_OPT_G_DESC,
884 .type = FIO_OPT_STR_STORE,
885 .off1 = td_var_offset(name),
886 .help = "Name of this job",
887 .category = FIO_OPT_C_GENERAL,
888 .group = FIO_OPT_G_DESC,
892 .lname = "Filename(s)",
893 .type = FIO_OPT_STR_STORE,
894 .off1 = td_var_offset(filename),
895 .cb = str_filename_cb,
896 .prio = -1, /* must come after "directory" */
897 .help = "File(s) to use for the workload",
898 .category = FIO_OPT_C_FILE,
899 .group = FIO_OPT_G_FILENAME,
903 .lname = "Directory",
904 .type = FIO_OPT_STR_STORE,
905 .off1 = td_var_offset(directory),
906 .cb = str_directory_cb,
907 .help = "Directory to store files in",
908 .category = FIO_OPT_C_FILE,
909 .group = FIO_OPT_G_FILENAME,
915 .cb = str_lockfile_cb,
916 .off1 = td_var_offset(file_lock_mode),
917 .help = "Lock file when doing IO to it",
918 .parent = "filename",
921 .category = FIO_OPT_C_FILE,
922 .group = FIO_OPT_G_FILENAME,
925 .oval = FILE_LOCK_NONE,
926 .help = "No file locking",
928 { .ival = "exclusive",
929 .oval = FILE_LOCK_EXCLUSIVE,
930 .help = "Exclusive file lock",
934 .oval = FILE_LOCK_READWRITE,
935 .help = "Read vs write lock",
941 .lname = "Open directory",
942 .type = FIO_OPT_STR_STORE,
943 .off1 = td_var_offset(opendir),
944 .cb = str_opendir_cb,
945 .help = "Recursively add files from this directory and down",
946 .category = FIO_OPT_C_FILE,
947 .group = FIO_OPT_G_FILENAME,
951 .lname = "Read/write",
952 .alias = "readwrite",
955 .off1 = td_var_offset(td_ddir),
956 .help = "IO direction",
959 .category = FIO_OPT_C_IO,
960 .group = FIO_OPT_G_IO_BASIC,
963 .oval = TD_DDIR_READ,
964 .help = "Sequential read",
967 .oval = TD_DDIR_WRITE,
968 .help = "Sequential write",
971 .oval = TD_DDIR_TRIM,
972 .help = "Sequential trim",
974 { .ival = "randread",
975 .oval = TD_DDIR_RANDREAD,
976 .help = "Random read",
978 { .ival = "randwrite",
979 .oval = TD_DDIR_RANDWRITE,
980 .help = "Random write",
982 { .ival = "randtrim",
983 .oval = TD_DDIR_RANDTRIM,
984 .help = "Random trim",
988 .help = "Sequential read and write mix",
990 { .ival = "readwrite",
992 .help = "Sequential read and write mix",
995 .oval = TD_DDIR_RANDRW,
996 .help = "Random read and write mix"
1001 .name = "rw_sequencer",
1002 .lname = "RW Sequencer",
1003 .type = FIO_OPT_STR,
1004 .off1 = td_var_offset(rw_seq),
1005 .help = "IO offset generator modifier",
1006 .def = "sequential",
1007 .category = FIO_OPT_C_IO,
1008 .group = FIO_OPT_G_IO_BASIC,
1010 { .ival = "sequential",
1012 .help = "Generate sequential offsets",
1014 { .ival = "identical",
1015 .oval = RW_SEQ_IDENT,
1016 .help = "Generate identical offsets",
1023 .lname = "IO Engine",
1024 .type = FIO_OPT_STR_STORE,
1025 .off1 = td_var_offset(ioengine),
1026 .help = "IO engine to use",
1027 .def = FIO_PREFERRED_ENGINE,
1028 .category = FIO_OPT_C_IO,
1029 .group = FIO_OPT_G_IO_BASIC,
1032 .help = "Use read/write",
1035 .help = "Use pread/pwrite",
1038 .help = "Use readv/writev",
1040 #ifdef FIO_HAVE_LIBAIO
1042 .help = "Linux native asynchronous IO",
1045 #ifdef FIO_HAVE_POSIXAIO
1046 { .ival = "posixaio",
1047 .help = "POSIX asynchronous IO",
1050 #ifdef FIO_HAVE_SOLARISAIO
1051 { .ival = "solarisaio",
1052 .help = "Solaris native asynchronous IO",
1055 #ifdef FIO_HAVE_WINDOWSAIO
1056 { .ival = "windowsaio",
1057 .help = "Windows native asynchronous IO"
1061 .help = "Memory mapped IO"
1063 #ifdef FIO_HAVE_SPLICE
1065 .help = "splice/vmsplice based IO",
1067 { .ival = "netsplice",
1068 .help = "splice/vmsplice to/from the network",
1071 #ifdef FIO_HAVE_SGIO
1073 .help = "SCSI generic v3 IO",
1077 .help = "Testing engine (no data transfer)",
1080 .help = "Network IO",
1082 #ifdef FIO_HAVE_SYSLET
1083 { .ival = "syslet-rw",
1084 .help = "syslet enabled async pread/pwrite IO",
1088 .help = "CPU cycle burner engine",
1090 #ifdef FIO_HAVE_GUASI
1092 .help = "GUASI IO engine",
1095 #ifdef FIO_HAVE_BINJECT
1096 { .ival = "binject",
1097 .help = "binject direct inject block engine",
1100 #ifdef FIO_HAVE_RDMA
1102 .help = "RDMA IO engine",
1105 #ifdef FIO_HAVE_FUSION_AW
1106 { .ival = "fusion-aw-sync",
1107 .help = "Fusion-io atomic write engine",
1110 #ifdef FIO_HAVE_E4_ENG
1111 { .ival = "e4defrag",
1112 .help = "ext4 defrag engine",
1115 #ifdef FIO_HAVE_FALLOC_ENG
1117 .help = "fallocate() file based engine",
1120 { .ival = "external",
1121 .help = "Load external engine (append name)",
1127 .lname = "IO Depth",
1128 .type = FIO_OPT_INT,
1129 .off1 = td_var_offset(iodepth),
1130 .help = "Number of IO buffers to keep in flight",
1134 .category = FIO_OPT_C_IO,
1135 .group = FIO_OPT_G_IO_BASIC,
1138 .name = "iodepth_batch",
1139 .lname = "IO Depth batch",
1140 .alias = "iodepth_batch_submit",
1141 .type = FIO_OPT_INT,
1142 .off1 = td_var_offset(iodepth_batch),
1143 .help = "Number of IO buffers to submit in one go",
1144 .parent = "iodepth",
1149 .category = FIO_OPT_C_IO,
1150 .group = FIO_OPT_G_IO_BASIC,
1153 .name = "iodepth_batch_complete",
1154 .lname = "IO Depth batch complete",
1155 .type = FIO_OPT_INT,
1156 .off1 = td_var_offset(iodepth_batch_complete),
1157 .help = "Number of IO buffers to retrieve in one go",
1158 .parent = "iodepth",
1163 .category = FIO_OPT_C_IO,
1164 .group = FIO_OPT_G_IO_BASIC,
1167 .name = "iodepth_low",
1168 .lname = "IO Depth batch low",
1169 .type = FIO_OPT_INT,
1170 .off1 = td_var_offset(iodepth_low),
1171 .help = "Low water mark for queuing depth",
1172 .parent = "iodepth",
1175 .category = FIO_OPT_C_IO,
1176 .group = FIO_OPT_G_IO_BASIC,
1181 .type = FIO_OPT_STR_VAL,
1183 .help = "Total size of device or files",
1184 .interval = 1024 * 1024,
1185 .category = FIO_OPT_C_IO,
1186 .group = FIO_OPT_G_INVALID,
1189 .name = "fill_device",
1190 .lname = "Fill device",
1192 .type = FIO_OPT_BOOL,
1193 .off1 = td_var_offset(fill_device),
1194 .help = "Write until an ENOSPC error occurs",
1196 .category = FIO_OPT_C_FILE,
1197 .group = FIO_OPT_G_INVALID,
1201 .lname = "File size",
1202 .type = FIO_OPT_STR_VAL,
1203 .off1 = td_var_offset(file_size_low),
1204 .off2 = td_var_offset(file_size_high),
1206 .help = "Size of individual files",
1207 .interval = 1024 * 1024,
1208 .category = FIO_OPT_C_FILE,
1209 .group = FIO_OPT_G_INVALID,
1213 .lname = "IO offset",
1214 .alias = "fileoffset",
1215 .type = FIO_OPT_STR_VAL,
1216 .off1 = td_var_offset(start_offset),
1217 .help = "Start IO from this offset",
1219 .interval = 1024 * 1024,
1220 .category = FIO_OPT_C_IO,
1221 .group = FIO_OPT_G_INVALID,
1224 .name = "offset_increment",
1225 .lname = "IO offset increment",
1226 .type = FIO_OPT_STR_VAL,
1227 .off1 = td_var_offset(offset_increment),
1228 .help = "What is the increment from one offset to the next",
1232 .interval = 1024 * 1024,
1233 .category = FIO_OPT_C_IO,
1234 .group = FIO_OPT_G_INVALID,
1238 .lname = "Block size",
1239 .alias = "blocksize",
1240 .type = FIO_OPT_INT,
1241 .off1 = td_var_offset(bs[DDIR_READ]),
1242 .off2 = td_var_offset(bs[DDIR_WRITE]),
1243 .off3 = td_var_offset(bs[DDIR_TRIM]),
1245 .help = "Block size unit",
1250 .category = FIO_OPT_C_IO,
1251 .group = FIO_OPT_G_INVALID,
1255 .lname = "Block size align",
1256 .alias = "blockalign",
1257 .type = FIO_OPT_INT,
1258 .off1 = td_var_offset(ba[DDIR_READ]),
1259 .off2 = td_var_offset(ba[DDIR_WRITE]),
1260 .off3 = td_var_offset(ba[DDIR_TRIM]),
1262 .help = "IO block offset alignment",
1266 .category = FIO_OPT_C_IO,
1267 .group = FIO_OPT_G_INVALID,
1271 .lname = "Block size range",
1272 .alias = "blocksize_range",
1273 .type = FIO_OPT_RANGE,
1274 .off1 = td_var_offset(min_bs[DDIR_READ]),
1275 .off2 = td_var_offset(max_bs[DDIR_READ]),
1276 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
1277 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
1278 .off5 = td_var_offset(min_bs[DDIR_TRIM]),
1279 .off6 = td_var_offset(max_bs[DDIR_TRIM]),
1281 .help = "Set block size range (in more detail than bs)",
1285 .category = FIO_OPT_C_IO,
1286 .group = FIO_OPT_G_INVALID,
1290 .lname = "Block size split",
1291 .type = FIO_OPT_STR,
1292 .cb = str_bssplit_cb,
1293 .help = "Set a specific mix of block sizes",
1296 .category = FIO_OPT_C_IO,
1297 .group = FIO_OPT_G_INVALID,
1300 .name = "bs_unaligned",
1301 .lname = "Block size unaligned",
1302 .alias = "blocksize_unaligned",
1303 .type = FIO_OPT_STR_SET,
1304 .off1 = td_var_offset(bs_unaligned),
1305 .help = "Don't sector align IO buffer sizes",
1308 .category = FIO_OPT_C_IO,
1309 .group = FIO_OPT_G_INVALID,
1312 .name = "randrepeat",
1313 .lname = "Random repeatable",
1314 .type = FIO_OPT_BOOL,
1315 .off1 = td_var_offset(rand_repeatable),
1316 .help = "Use repeatable random IO pattern",
1320 .category = FIO_OPT_C_IO,
1321 .group = FIO_OPT_G_RANDOM,
1324 .name = "use_os_rand",
1325 .lname = "Use OS random",
1326 .type = FIO_OPT_BOOL,
1327 .off1 = td_var_offset(use_os_rand),
1328 .help = "Set to use OS random generator",
1332 .category = FIO_OPT_C_IO,
1333 .group = FIO_OPT_G_RANDOM,
1336 .name = "norandommap",
1337 .lname = "No randommap",
1338 .type = FIO_OPT_STR_SET,
1339 .off1 = td_var_offset(norandommap),
1340 .help = "Accept potential duplicate random blocks",
1344 .category = FIO_OPT_C_IO,
1345 .group = FIO_OPT_G_RANDOM,
1348 .name = "softrandommap",
1349 .lname = "Soft randommap",
1350 .type = FIO_OPT_BOOL,
1351 .off1 = td_var_offset(softrandommap),
1352 .help = "Set norandommap if randommap allocation fails",
1353 .parent = "norandommap",
1356 .category = FIO_OPT_C_IO,
1357 .group = FIO_OPT_G_RANDOM,
1361 .lname = "Number of files",
1362 .alias = "nr_files",
1363 .type = FIO_OPT_INT,
1364 .off1 = td_var_offset(nr_files),
1365 .help = "Split job workload between this number of files",
1368 .category = FIO_OPT_C_FILE,
1369 .group = FIO_OPT_G_INVALID,
1372 .name = "openfiles",
1373 .lname = "Number of open files",
1374 .type = FIO_OPT_INT,
1375 .off1 = td_var_offset(open_files),
1376 .help = "Number of files to keep open at the same time",
1377 .category = FIO_OPT_C_FILE,
1378 .group = FIO_OPT_G_INVALID,
1381 .name = "file_service_type",
1382 .lname = "File service type",
1383 .type = FIO_OPT_STR,
1385 .off1 = td_var_offset(file_service_type),
1386 .help = "How to select which file to service next",
1387 .def = "roundrobin",
1388 .category = FIO_OPT_C_FILE,
1389 .group = FIO_OPT_G_INVALID,
1392 .oval = FIO_FSERVICE_RANDOM,
1393 .help = "Choose a file at random",
1395 { .ival = "roundrobin",
1396 .oval = FIO_FSERVICE_RR,
1397 .help = "Round robin select files",
1399 { .ival = "sequential",
1400 .oval = FIO_FSERVICE_SEQ,
1401 .help = "Finish one file before moving to the next",
1404 .parent = "nrfiles",
1407 #ifdef FIO_HAVE_FALLOCATE
1409 .name = "fallocate",
1410 .lname = "Fallocate",
1411 .type = FIO_OPT_STR,
1412 .off1 = td_var_offset(fallocate_mode),
1413 .help = "Whether pre-allocation is performed when laying out files",
1415 .category = FIO_OPT_C_FILE,
1416 .group = FIO_OPT_G_INVALID,
1419 .oval = FIO_FALLOCATE_NONE,
1420 .help = "Do not pre-allocate space",
1423 .oval = FIO_FALLOCATE_POSIX,
1424 .help = "Use posix_fallocate()",
1426 #ifdef FIO_HAVE_LINUX_FALLOCATE
1428 .oval = FIO_FALLOCATE_KEEP_SIZE,
1429 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
1432 /* Compatibility with former boolean values */
1434 .oval = FIO_FALLOCATE_NONE,
1435 .help = "Alias for 'none'",
1438 .oval = FIO_FALLOCATE_POSIX,
1439 .help = "Alias for 'posix'",
1443 #endif /* FIO_HAVE_FALLOCATE */
1445 .name = "fadvise_hint",
1446 .lname = "Fadvise hint",
1447 .type = FIO_OPT_BOOL,
1448 .off1 = td_var_offset(fadvise_hint),
1449 .help = "Use fadvise() to advise the kernel on IO pattern",
1451 .category = FIO_OPT_C_FILE,
1452 .group = FIO_OPT_G_INVALID,
1457 .type = FIO_OPT_INT,
1458 .off1 = td_var_offset(fsync_blocks),
1459 .help = "Issue fsync for writes every given number of blocks",
1462 .category = FIO_OPT_C_FILE,
1463 .group = FIO_OPT_G_INVALID,
1466 .name = "fdatasync",
1467 .lname = "Fdatasync",
1468 .type = FIO_OPT_INT,
1469 .off1 = td_var_offset(fdatasync_blocks),
1470 .help = "Issue fdatasync for writes every given number of blocks",
1473 .category = FIO_OPT_C_FILE,
1474 .group = FIO_OPT_G_INVALID,
1477 .name = "write_barrier",
1478 .lname = "Write barrier",
1479 .type = FIO_OPT_INT,
1480 .off1 = td_var_offset(barrier_blocks),
1481 .help = "Make every Nth write a barrier write",
1484 .category = FIO_OPT_C_IO,
1485 .group = FIO_OPT_G_INVALID,
1487 #ifdef FIO_HAVE_SYNC_FILE_RANGE
1489 .name = "sync_file_range",
1490 .lname = "Sync file range",
1492 { .ival = "wait_before",
1493 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
1494 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
1498 .oval = SYNC_FILE_RANGE_WRITE,
1499 .help = "SYNC_FILE_RANGE_WRITE",
1503 .ival = "wait_after",
1504 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
1505 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
1509 .type = FIO_OPT_STR_MULTI,
1511 .off1 = td_var_offset(sync_file_range),
1512 .help = "Use sync_file_range()",
1513 .category = FIO_OPT_C_FILE,
1514 .group = FIO_OPT_G_INVALID,
1519 .lname = "Direct I/O",
1520 .type = FIO_OPT_BOOL,
1521 .off1 = td_var_offset(odirect),
1522 .help = "Use O_DIRECT IO (negates buffered)",
1524 .inverse = "buffered",
1525 .category = FIO_OPT_C_IO,
1526 .group = FIO_OPT_G_IO_TYPE,
1530 .lname = "Buffered I/O",
1531 .type = FIO_OPT_BOOL,
1532 .off1 = td_var_offset(odirect),
1534 .help = "Use buffered IO (negates direct)",
1536 .inverse = "direct",
1537 .category = FIO_OPT_C_IO,
1538 .group = FIO_OPT_G_IO_TYPE,
1541 .name = "overwrite",
1542 .lname = "Overwrite",
1543 .type = FIO_OPT_BOOL,
1544 .off1 = td_var_offset(overwrite),
1545 .help = "When writing, set whether to overwrite current data",
1547 .category = FIO_OPT_C_FILE,
1548 .group = FIO_OPT_G_INVALID,
1553 .type = FIO_OPT_INT,
1554 .off1 = td_var_offset(loops),
1555 .help = "Number of times to run the job",
1558 .category = FIO_OPT_C_GENERAL,
1559 .group = FIO_OPT_G_RUNTIME,
1563 .lname = "Number of jobs",
1564 .type = FIO_OPT_INT,
1565 .off1 = td_var_offset(numjobs),
1566 .help = "Duplicate this job this many times",
1569 .category = FIO_OPT_C_GENERAL,
1570 .group = FIO_OPT_G_RUNTIME,
1573 .name = "startdelay",
1574 .lname = "Start delay",
1575 .type = FIO_OPT_STR_VAL_TIME,
1576 .off1 = td_var_offset(start_delay),
1577 .help = "Only start job when this period has passed",
1579 .category = FIO_OPT_C_GENERAL,
1580 .group = FIO_OPT_G_RUNTIME,
1586 .type = FIO_OPT_STR_VAL_TIME,
1587 .off1 = td_var_offset(timeout),
1588 .help = "Stop workload when this amount of time has passed",
1590 .category = FIO_OPT_C_GENERAL,
1591 .group = FIO_OPT_G_RUNTIME,
1594 .name = "time_based",
1595 .lname = "Time based",
1596 .type = FIO_OPT_STR_SET,
1597 .off1 = td_var_offset(time_based),
1598 .help = "Keep running until runtime/timeout is met",
1599 .category = FIO_OPT_C_GENERAL,
1600 .group = FIO_OPT_G_RUNTIME,
1603 .name = "ramp_time",
1604 .lname = "Ramp time",
1605 .type = FIO_OPT_STR_VAL_TIME,
1606 .off1 = td_var_offset(ramp_time),
1607 .help = "Ramp up time before measuring performance",
1608 .category = FIO_OPT_C_GENERAL,
1609 .group = FIO_OPT_G_RUNTIME,
1612 .name = "clocksource",
1613 .lname = "Clock source",
1614 .type = FIO_OPT_STR,
1615 .cb = fio_clock_source_cb,
1616 .off1 = td_var_offset(clocksource),
1617 .help = "What type of timing source to use",
1618 .category = FIO_OPT_C_GENERAL,
1619 .group = FIO_OPT_G_CLOCK,
1621 { .ival = "gettimeofday",
1623 .help = "Use gettimeofday(2) for timing",
1625 { .ival = "clock_gettime",
1626 .oval = CS_CGETTIME,
1627 .help = "Use clock_gettime(2) for timing",
1629 #ifdef ARCH_HAVE_CPU_CLOCK
1631 .oval = CS_CPUCLOCK,
1632 .help = "Use CPU private clock",
1640 .lname = "I/O Memory",
1641 .type = FIO_OPT_STR,
1643 .off1 = td_var_offset(mem_type),
1644 .help = "Backing type for IO buffers",
1646 .category = FIO_OPT_C_IO,
1647 .group = FIO_OPT_G_INVALID,
1651 .help = "Use malloc(3) for IO buffers",
1655 .help = "Use shared memory segments for IO buffers",
1657 #ifdef FIO_HAVE_HUGETLB
1658 { .ival = "shmhuge",
1659 .oval = MEM_SHMHUGE,
1660 .help = "Like shm, but use huge pages",
1665 .help = "Use mmap(2) (file or anon) for IO buffers",
1667 #ifdef FIO_HAVE_HUGETLB
1668 { .ival = "mmaphuge",
1669 .oval = MEM_MMAPHUGE,
1670 .help = "Like mmap, but use huge pages",
1676 .name = "iomem_align",
1677 .alias = "mem_align",
1678 .lname = "I/O memory alignment",
1679 .type = FIO_OPT_INT,
1680 .off1 = td_var_offset(mem_align),
1682 .help = "IO memory buffer offset alignment",
1686 .category = FIO_OPT_C_IO,
1687 .group = FIO_OPT_G_INVALID,
1692 .type = FIO_OPT_STR,
1693 .off1 = td_var_offset(verify),
1694 .help = "Verify data written",
1696 .category = FIO_OPT_C_IO,
1697 .group = FIO_OPT_G_VERIFY,
1700 .oval = VERIFY_NONE,
1701 .help = "Don't do IO verification",
1705 .help = "Use md5 checksums for verification",
1708 .oval = VERIFY_CRC64,
1709 .help = "Use crc64 checksums for verification",
1712 .oval = VERIFY_CRC32,
1713 .help = "Use crc32 checksums for verification",
1715 { .ival = "crc32c-intel",
1716 .oval = VERIFY_CRC32C,
1717 .help = "Use crc32c checksums for verification (hw assisted, if available)",
1720 .oval = VERIFY_CRC32C,
1721 .help = "Use crc32c checksums for verification (hw assisted, if available)",
1724 .oval = VERIFY_CRC16,
1725 .help = "Use crc16 checksums for verification",
1728 .oval = VERIFY_CRC7,
1729 .help = "Use crc7 checksums for verification",
1732 .oval = VERIFY_SHA1,
1733 .help = "Use sha1 checksums for verification",
1736 .oval = VERIFY_SHA256,
1737 .help = "Use sha256 checksums for verification",
1740 .oval = VERIFY_SHA512,
1741 .help = "Use sha512 checksums for verification",
1744 .oval = VERIFY_META,
1745 .help = "Use io information",
1749 .oval = VERIFY_NULL,
1750 .help = "Pretend to verify",
1755 .name = "do_verify",
1756 .lname = "Perform verify step",
1757 .type = FIO_OPT_BOOL,
1758 .off1 = td_var_offset(do_verify),
1759 .help = "Run verification stage after write",
1763 .category = FIO_OPT_C_IO,
1764 .group = FIO_OPT_G_VERIFY,
1767 .name = "verifysort",
1768 .lname = "Verify sort",
1769 .type = FIO_OPT_BOOL,
1770 .off1 = td_var_offset(verifysort),
1771 .help = "Sort written verify blocks for read back",
1775 .category = FIO_OPT_C_IO,
1776 .group = FIO_OPT_G_VERIFY,
1779 .name = "verify_interval",
1780 .lname = "Verify interval",
1781 .type = FIO_OPT_INT,
1782 .off1 = td_var_offset(verify_interval),
1783 .minval = 2 * sizeof(struct verify_header),
1784 .help = "Store verify buffer header every N bytes",
1787 .interval = 2 * sizeof(struct verify_header),
1788 .category = FIO_OPT_C_IO,
1789 .group = FIO_OPT_G_VERIFY,
1792 .name = "verify_offset",
1793 .lname = "Verify offset",
1794 .type = FIO_OPT_INT,
1795 .help = "Offset verify header location by N bytes",
1796 .off1 = td_var_offset(verify_offset),
1797 .minval = sizeof(struct verify_header),
1800 .category = FIO_OPT_C_IO,
1801 .group = FIO_OPT_G_VERIFY,
1804 .name = "verify_pattern",
1805 .lname = "Verify pattern",
1806 .type = FIO_OPT_STR,
1807 .cb = str_verify_pattern_cb,
1808 .help = "Fill pattern for IO buffers",
1811 .category = FIO_OPT_C_IO,
1812 .group = FIO_OPT_G_VERIFY,
1815 .name = "verify_fatal",
1816 .lname = "Verify fatal",
1817 .type = FIO_OPT_BOOL,
1818 .off1 = td_var_offset(verify_fatal),
1820 .help = "Exit on a single verify failure, don't continue",
1823 .category = FIO_OPT_C_IO,
1824 .group = FIO_OPT_G_VERIFY,
1827 .name = "verify_dump",
1828 .lname = "Verify dump",
1829 .type = FIO_OPT_BOOL,
1830 .off1 = td_var_offset(verify_dump),
1832 .help = "Dump contents of good and bad blocks on failure",
1835 .category = FIO_OPT_C_IO,
1836 .group = FIO_OPT_G_VERIFY,
1839 .name = "verify_async",
1840 .lname = "Verify asynchronously",
1841 .type = FIO_OPT_INT,
1842 .off1 = td_var_offset(verify_async),
1844 .help = "Number of async verifier threads to use",
1847 .category = FIO_OPT_C_IO,
1848 .group = FIO_OPT_G_VERIFY,
1851 .name = "verify_backlog",
1852 .lname = "Verify backlog",
1853 .type = FIO_OPT_STR_VAL,
1854 .off1 = td_var_offset(verify_backlog),
1855 .help = "Verify after this number of blocks are written",
1858 .category = FIO_OPT_C_IO,
1859 .group = FIO_OPT_G_VERIFY,
1862 .name = "verify_backlog_batch",
1863 .lname = "Verify backlog batch",
1864 .type = FIO_OPT_INT,
1865 .off1 = td_var_offset(verify_batch),
1866 .help = "Verify this number of IO blocks",
1869 .category = FIO_OPT_C_IO,
1870 .group = FIO_OPT_G_VERIFY,
1872 #ifdef FIO_HAVE_CPU_AFFINITY
1874 .name = "verify_async_cpus",
1875 .lname = "Async verify CPUs",
1876 .type = FIO_OPT_STR,
1877 .cb = str_verify_cpus_allowed_cb,
1878 .help = "Set CPUs allowed for async verify threads",
1879 .parent = "verify_async",
1881 .category = FIO_OPT_C_IO,
1882 .group = FIO_OPT_G_VERIFY,
1885 #ifdef FIO_HAVE_TRIM
1887 .name = "trim_percentage",
1888 .lname = "Trim percentage",
1889 .type = FIO_OPT_INT,
1890 .off1 = td_var_offset(trim_percentage),
1893 .help = "Number of verify blocks to discard/trim",
1898 .category = FIO_OPT_C_IO,
1899 .group = FIO_OPT_G_TRIM,
1902 .name = "trim_verify_zero",
1903 .lname = "Verify trim zero",
1904 .type = FIO_OPT_BOOL,
1905 .help = "Verify that trim/discarded blocks are returned as zeroes",
1906 .off1 = td_var_offset(trim_zero),
1907 .parent = "trim_percentage",
1910 .category = FIO_OPT_C_IO,
1911 .group = FIO_OPT_G_TRIM,
1914 .name = "trim_backlog",
1915 .lname = "Trim backlog",
1916 .type = FIO_OPT_STR_VAL,
1917 .off1 = td_var_offset(trim_backlog),
1918 .help = "Trim after this number of blocks are written",
1919 .parent = "trim_percentage",
1922 .category = FIO_OPT_C_IO,
1923 .group = FIO_OPT_G_TRIM,
1926 .name = "trim_backlog_batch",
1927 .lname = "Trim backlog batch",
1928 .type = FIO_OPT_INT,
1929 .off1 = td_var_offset(trim_batch),
1930 .help = "Trim this number of IO blocks",
1931 .parent = "trim_percentage",
1934 .category = FIO_OPT_C_IO,
1935 .group = FIO_OPT_G_TRIM,
1939 .name = "write_iolog",
1940 .lname = "Write I/O log",
1941 .type = FIO_OPT_STR_STORE,
1942 .off1 = td_var_offset(write_iolog_file),
1943 .help = "Store IO pattern to file",
1944 .category = FIO_OPT_C_IO,
1945 .group = FIO_OPT_G_IOLOG,
1948 .name = "read_iolog",
1949 .lname = "Read I/O log",
1950 .type = FIO_OPT_STR_STORE,
1951 .off1 = td_var_offset(read_iolog_file),
1952 .help = "Playback IO pattern from file",
1953 .category = FIO_OPT_C_IO,
1954 .group = FIO_OPT_G_IOLOG,
1957 .name = "replay_no_stall",
1958 .lname = "Don't stall on replay",
1959 .type = FIO_OPT_BOOL,
1960 .off1 = td_var_offset(no_stall),
1962 .parent = "read_iolog",
1964 .help = "Playback IO pattern file as fast as possible without stalls",
1965 .category = FIO_OPT_C_IO,
1966 .group = FIO_OPT_G_IOLOG,
1969 .name = "replay_redirect",
1970 .lname = "Redirect device for replay",
1971 .type = FIO_OPT_STR_STORE,
1972 .off1 = td_var_offset(replay_redirect),
1973 .parent = "read_iolog",
1975 .help = "Replay all I/O onto this device, regardless of trace device",
1976 .category = FIO_OPT_C_IO,
1977 .group = FIO_OPT_G_IOLOG,
1980 .name = "exec_prerun",
1981 .lname = "Pre-execute runnable",
1982 .type = FIO_OPT_STR_STORE,
1983 .off1 = td_var_offset(exec_prerun),
1984 .help = "Execute this file prior to running job",
1985 .category = FIO_OPT_C_GENERAL,
1986 .group = FIO_OPT_G_INVALID,
1989 .name = "exec_postrun",
1990 .lname = "Post-execute runnable",
1991 .type = FIO_OPT_STR_STORE,
1992 .off1 = td_var_offset(exec_postrun),
1993 .help = "Execute this file after running job",
1994 .category = FIO_OPT_C_GENERAL,
1995 .group = FIO_OPT_G_INVALID,
1997 #ifdef FIO_HAVE_IOSCHED_SWITCH
1999 .name = "ioscheduler",
2000 .lname = "I/O scheduler",
2001 .type = FIO_OPT_STR_STORE,
2002 .off1 = td_var_offset(ioscheduler),
2003 .help = "Use this IO scheduler on the backing device",
2004 .category = FIO_OPT_C_FILE,
2005 .group = FIO_OPT_G_INVALID,
2010 .lname = "Zone size",
2011 .type = FIO_OPT_STR_VAL,
2012 .off1 = td_var_offset(zone_size),
2013 .help = "Amount of data to read per zone",
2015 .interval = 1024 * 1024,
2016 .category = FIO_OPT_C_IO,
2017 .group = FIO_OPT_G_ZONE,
2020 .name = "zonerange",
2021 .lname = "Zone range",
2022 .type = FIO_OPT_STR_VAL,
2023 .off1 = td_var_offset(zone_range),
2024 .help = "Give size of an IO zone",
2026 .interval = 1024 * 1024,
2027 .category = FIO_OPT_C_IO,
2028 .group = FIO_OPT_G_ZONE,
2032 .lname = "Zone skip",
2033 .type = FIO_OPT_STR_VAL,
2034 .off1 = td_var_offset(zone_skip),
2035 .help = "Space between IO zones",
2037 .interval = 1024 * 1024,
2038 .category = FIO_OPT_C_IO,
2039 .group = FIO_OPT_G_ZONE,
2043 .lname = "Lock memory",
2044 .type = FIO_OPT_STR_VAL,
2045 .off1 = td_var_offset(lockmem),
2046 .help = "Lock down this amount of memory",
2048 .interval = 1024 * 1024,
2049 .category = FIO_OPT_C_GENERAL,
2050 .group = FIO_OPT_G_INVALID,
2053 .name = "rwmixread",
2054 .lname = "Read/write mix read",
2055 .type = FIO_OPT_INT,
2056 .cb = str_rwmix_read_cb,
2058 .help = "Percentage of mixed workload that is reads",
2061 .inverse = "rwmixwrite",
2062 .category = FIO_OPT_C_IO,
2063 .group = FIO_OPT_G_RWMIX,
2066 .name = "rwmixwrite",
2067 .lname = "Read/write mix write",
2068 .type = FIO_OPT_INT,
2069 .cb = str_rwmix_write_cb,
2071 .help = "Percentage of mixed workload that is writes",
2074 .inverse = "rwmixread",
2075 .category = FIO_OPT_C_IO,
2076 .group = FIO_OPT_G_RWMIX,
2079 .name = "rwmixcycle",
2080 .lname = "Read/write mix cycle",
2081 .type = FIO_OPT_DEPRECATED,
2082 .category = FIO_OPT_C_IO,
2083 .group = FIO_OPT_G_RWMIX,
2088 .type = FIO_OPT_INT,
2089 .off1 = td_var_offset(nice),
2090 .help = "Set job CPU nice value",
2095 .category = FIO_OPT_C_GENERAL,
2096 .group = FIO_OPT_G_CRED,
2098 #ifdef FIO_HAVE_IOPRIO
2101 .lname = "I/O nice priority",
2102 .type = FIO_OPT_INT,
2103 .off1 = td_var_offset(ioprio),
2104 .help = "Set job IO priority value",
2108 .category = FIO_OPT_C_GENERAL,
2109 .group = FIO_OPT_G_CRED,
2112 .name = "prioclass",
2113 .lname = "I/O nice priority class",
2114 .type = FIO_OPT_INT,
2115 .off1 = td_var_offset(ioprio_class),
2116 .help = "Set job IO priority class",
2120 .category = FIO_OPT_C_GENERAL,
2121 .group = FIO_OPT_G_CRED,
2125 .name = "thinktime",
2126 .lname = "Thinktime",
2127 .type = FIO_OPT_INT,
2128 .off1 = td_var_offset(thinktime),
2129 .help = "Idle time between IO buffers (usec)",
2131 .category = FIO_OPT_C_IO,
2132 .group = FIO_OPT_G_THINKTIME,
2135 .name = "thinktime_spin",
2136 .lname = "Thinktime spin",
2137 .type = FIO_OPT_INT,
2138 .off1 = td_var_offset(thinktime_spin),
2139 .help = "Start think time by spinning this amount (usec)",
2141 .parent = "thinktime",
2143 .category = FIO_OPT_C_IO,
2144 .group = FIO_OPT_G_THINKTIME,
2147 .name = "thinktime_blocks",
2148 .lname = "Thinktime blocks",
2149 .type = FIO_OPT_INT,
2150 .off1 = td_var_offset(thinktime_blocks),
2151 .help = "IO buffer period between 'thinktime'",
2153 .parent = "thinktime",
2155 .category = FIO_OPT_C_IO,
2156 .group = FIO_OPT_G_THINKTIME,
2160 .lname = "I/O rate",
2161 .type = FIO_OPT_INT,
2162 .off1 = td_var_offset(rate[DDIR_READ]),
2163 .off2 = td_var_offset(rate[DDIR_WRITE]),
2164 .off3 = td_var_offset(rate[DDIR_TRIM]),
2165 .help = "Set bandwidth rate",
2166 .category = FIO_OPT_C_IO,
2167 .group = FIO_OPT_G_RATE,
2171 .lname = "I/O min rate",
2172 .type = FIO_OPT_INT,
2173 .off1 = td_var_offset(ratemin[DDIR_READ]),
2174 .off2 = td_var_offset(ratemin[DDIR_WRITE]),
2175 .off3 = td_var_offset(ratemin[DDIR_TRIM]),
2176 .help = "Job must meet this rate or it will be shutdown",
2179 .category = FIO_OPT_C_IO,
2180 .group = FIO_OPT_G_RATE,
2183 .name = "rate_iops",
2184 .lname = "I/O rate IOPS",
2185 .type = FIO_OPT_INT,
2186 .off1 = td_var_offset(rate_iops[DDIR_READ]),
2187 .off2 = td_var_offset(rate_iops[DDIR_WRITE]),
2188 .off3 = td_var_offset(rate_iops[DDIR_TRIM]),
2189 .help = "Limit IO used to this number of IO operations/sec",
2191 .category = FIO_OPT_C_IO,
2192 .group = FIO_OPT_G_RATE,
2195 .name = "rate_iops_min",
2196 .lname = "I/O min rate IOPS",
2197 .type = FIO_OPT_INT,
2198 .off1 = td_var_offset(rate_iops_min[DDIR_READ]),
2199 .off2 = td_var_offset(rate_iops_min[DDIR_WRITE]),
2200 .off3 = td_var_offset(rate_iops_min[DDIR_TRIM]),
2201 .help = "Job must meet this rate or it will be shut down",
2202 .parent = "rate_iops",
2204 .category = FIO_OPT_C_IO,
2205 .group = FIO_OPT_G_RATE,
2208 .name = "ratecycle",
2209 .lname = "I/O rate cycle",
2210 .type = FIO_OPT_INT,
2211 .off1 = td_var_offset(ratecycle),
2212 .help = "Window average for rate limits (msec)",
2216 .category = FIO_OPT_C_IO,
2217 .group = FIO_OPT_G_RATE,
2220 .name = "invalidate",
2221 .lname = "Cache invalidate",
2222 .type = FIO_OPT_BOOL,
2223 .off1 = td_var_offset(invalidate_cache),
2224 .help = "Invalidate buffer/page cache prior to running job",
2226 .category = FIO_OPT_C_IO,
2227 .group = FIO_OPT_G_IO_TYPE,
2231 .lname = "Synchronous I/O",
2232 .type = FIO_OPT_BOOL,
2233 .off1 = td_var_offset(sync_io),
2234 .help = "Use O_SYNC for buffered writes",
2236 .parent = "buffered",
2238 .category = FIO_OPT_C_IO,
2239 .group = FIO_OPT_G_IO_TYPE,
2242 .name = "create_serialize",
2243 .lname = "Create serialize",
2244 .type = FIO_OPT_BOOL,
2245 .off1 = td_var_offset(create_serialize),
2246 .help = "Serialize creating of job files",
2248 .category = FIO_OPT_C_FILE,
2249 .group = FIO_OPT_G_INVALID,
2252 .name = "create_fsync",
2253 .lname = "Create fsync",
2254 .type = FIO_OPT_BOOL,
2255 .off1 = td_var_offset(create_fsync),
2256 .help = "fsync file after creation",
2258 .category = FIO_OPT_C_FILE,
2259 .group = FIO_OPT_G_INVALID,
2262 .name = "create_on_open",
2263 .lname = "Create on open",
2264 .type = FIO_OPT_BOOL,
2265 .off1 = td_var_offset(create_on_open),
2266 .help = "Create files when they are opened for IO",
2268 .category = FIO_OPT_C_FILE,
2269 .group = FIO_OPT_G_INVALID,
2272 .name = "create_only",
2273 .type = FIO_OPT_BOOL,
2274 .off1 = td_var_offset(create_only),
2275 .help = "Only perform file creation phase",
2276 .category = FIO_OPT_C_FILE,
2281 .lname = "Pre-read files",
2282 .type = FIO_OPT_BOOL,
2283 .off1 = td_var_offset(pre_read),
2284 .help = "Pre-read files before starting official testing",
2286 .category = FIO_OPT_C_FILE,
2287 .group = FIO_OPT_G_INVALID,
2289 #ifdef FIO_HAVE_CPU_AFFINITY
2292 .lname = "CPU mask",
2293 .type = FIO_OPT_INT,
2294 .cb = str_cpumask_cb,
2295 .help = "CPU affinity mask",
2296 .category = FIO_OPT_C_GENERAL,
2297 .group = FIO_OPT_G_CRED,
2300 .name = "cpus_allowed",
2301 .lname = "CPUs allowed",
2302 .type = FIO_OPT_STR,
2303 .cb = str_cpus_allowed_cb,
2304 .help = "Set CPUs allowed",
2305 .category = FIO_OPT_C_GENERAL,
2306 .group = FIO_OPT_G_CRED,
2310 .name = "end_fsync",
2311 .lname = "End fsync",
2312 .type = FIO_OPT_BOOL,
2313 .off1 = td_var_offset(end_fsync),
2314 .help = "Include fsync at the end of job",
2316 .category = FIO_OPT_C_FILE,
2317 .group = FIO_OPT_G_INVALID,
2320 .name = "fsync_on_close",
2321 .lname = "Fsync on close",
2322 .type = FIO_OPT_BOOL,
2323 .off1 = td_var_offset(fsync_on_close),
2324 .help = "fsync files on close",
2326 .category = FIO_OPT_C_FILE,
2327 .group = FIO_OPT_G_INVALID,
2331 .lname = "Unlink file",
2332 .type = FIO_OPT_BOOL,
2333 .off1 = td_var_offset(unlink),
2334 .help = "Unlink created files after job has completed",
2336 .category = FIO_OPT_C_FILE,
2337 .group = FIO_OPT_G_INVALID,
2341 .lname = "Exit-all on terminate",
2342 .type = FIO_OPT_STR_SET,
2343 .cb = str_exitall_cb,
2344 .help = "Terminate all jobs when one exits",
2345 .category = FIO_OPT_C_GENERAL,
2346 .group = FIO_OPT_G_PROCESS,
2349 .name = "stonewall",
2350 .lname = "Wait for previous",
2351 .alias = "wait_for_previous",
2352 .type = FIO_OPT_STR_SET,
2353 .off1 = td_var_offset(stonewall),
2354 .help = "Insert a hard barrier between this job and previous",
2355 .category = FIO_OPT_C_GENERAL,
2356 .group = FIO_OPT_G_PROCESS,
2359 .name = "new_group",
2360 .lname = "New group",
2361 .type = FIO_OPT_STR_SET,
2362 .off1 = td_var_offset(new_group),
2363 .help = "Mark the start of a new group (for reporting)",
2364 .category = FIO_OPT_C_GENERAL,
2365 .group = FIO_OPT_G_PROCESS,
2370 .type = FIO_OPT_STR_SET,
2371 .off1 = td_var_offset(use_thread),
2372 .help = "Use threads instead of processes",
2373 .category = FIO_OPT_C_GENERAL,
2374 .group = FIO_OPT_G_PROCESS,
2377 .name = "write_bw_log",
2378 .lname = "Write bandwidth log",
2379 .type = FIO_OPT_STR_STORE,
2380 .off1 = td_var_offset(bw_log_file),
2381 .help = "Write log of bandwidth during run",
2382 .category = FIO_OPT_C_LOG,
2383 .group = FIO_OPT_G_INVALID,
2386 .name = "write_lat_log",
2387 .lname = "Write latency log",
2388 .type = FIO_OPT_STR_STORE,
2389 .off1 = td_var_offset(lat_log_file),
2390 .help = "Write log of latency during run",
2391 .category = FIO_OPT_C_LOG,
2392 .group = FIO_OPT_G_INVALID,
2395 .name = "write_iops_log",
2396 .lname = "Write IOPS log",
2397 .type = FIO_OPT_STR,
2398 .off1 = td_var_offset(iops_log_file),
2399 .help = "Write log of IOPS during run",
2400 .category = FIO_OPT_C_LOG,
2401 .group = FIO_OPT_G_INVALID,
2404 .name = "log_avg_msec",
2405 .lname = "Log averaging (msec)",
2406 .type = FIO_OPT_INT,
2407 .off1 = td_var_offset(log_avg_msec),
2408 .help = "Average bw/iops/lat logs over this period of time",
2410 .category = FIO_OPT_C_LOG,
2411 .group = FIO_OPT_G_INVALID,
2414 .name = "bwavgtime",
2415 .lname = "Bandwidth average time",
2416 .type = FIO_OPT_INT,
2417 .off1 = td_var_offset(bw_avg_time),
2418 .help = "Time window over which to calculate bandwidth"
2421 .parent = "write_bw_log",
2424 .category = FIO_OPT_C_LOG,
2425 .group = FIO_OPT_G_INVALID,
2428 .name = "iopsavgtime",
2429 .lname = "IOPS average time",
2430 .type = FIO_OPT_INT,
2431 .off1 = td_var_offset(iops_avg_time),
2432 .help = "Time window over which to calculate IOPS (msec)",
2434 .parent = "write_iops_log",
2437 .category = FIO_OPT_C_LOG,
2438 .group = FIO_OPT_G_INVALID,
2441 .name = "group_reporting",
2442 .lname = "Group reporting",
2443 .type = FIO_OPT_BOOL,
2444 .off1 = td_var_offset(group_reporting),
2445 .help = "Do reporting on a per-group basis",
2447 .category = FIO_OPT_C_STAT,
2448 .group = FIO_OPT_G_INVALID,
2451 .name = "zero_buffers",
2452 .lname = "Zero I/O buffers",
2453 .type = FIO_OPT_STR_SET,
2454 .off1 = td_var_offset(zero_buffers),
2455 .help = "Init IO buffers to all zeroes",
2456 .category = FIO_OPT_C_IO,
2457 .group = FIO_OPT_G_IO_BUF,
2460 .name = "refill_buffers",
2461 .lname = "Refill I/O buffers",
2462 .type = FIO_OPT_STR_SET,
2463 .off1 = td_var_offset(refill_buffers),
2464 .help = "Refill IO buffers on every IO submit",
2465 .category = FIO_OPT_C_IO,
2466 .group = FIO_OPT_G_IO_BUF,
2469 .name = "scramble_buffers",
2470 .lname = "Scramble I/O buffers",
2471 .type = FIO_OPT_BOOL,
2472 .off1 = td_var_offset(scramble_buffers),
2473 .help = "Slightly scramble buffers on every IO submit",
2475 .category = FIO_OPT_C_IO,
2476 .group = FIO_OPT_G_IO_BUF,
2479 .name = "buffer_compress_percentage",
2480 .lname = "Buffer compression percentage",
2481 .type = FIO_OPT_INT,
2482 .off1 = td_var_offset(compress_percentage),
2485 .help = "How compressible the buffer is (approximately)",
2487 .category = FIO_OPT_C_IO,
2488 .group = FIO_OPT_G_IO_BUF,
2491 .name = "buffer_compress_chunk",
2492 .lname = "Buffer compression chunk size",
2493 .type = FIO_OPT_INT,
2494 .off1 = td_var_offset(compress_chunk),
2495 .parent = "buffer_compress_percentage",
2497 .help = "Size of compressible region in buffer",
2499 .category = FIO_OPT_C_IO,
2500 .group = FIO_OPT_G_IO_BUF,
2503 .name = "clat_percentiles",
2504 .lname = "Completion latency percentiles",
2505 .type = FIO_OPT_BOOL,
2506 .off1 = td_var_offset(clat_percentiles),
2507 .help = "Enable the reporting of completion latency percentiles",
2509 .category = FIO_OPT_C_STAT,
2510 .group = FIO_OPT_G_INVALID,
2513 .name = "percentile_list",
2514 .lname = "Completion latency percentile list",
2515 .type = FIO_OPT_FLOAT_LIST,
2516 .off1 = td_var_offset(percentile_list),
2517 .off2 = td_var_offset(overwrite_plist),
2518 .help = "Specify a custom list of percentiles to report",
2519 .maxlen = FIO_IO_U_LIST_MAX_LEN,
2522 .category = FIO_OPT_C_STAT,
2523 .group = FIO_OPT_G_INVALID,
2526 #ifdef FIO_HAVE_DISK_UTIL
2528 .name = "disk_util",
2529 .lname = "Disk utilization",
2530 .type = FIO_OPT_BOOL,
2531 .off1 = td_var_offset(do_disk_util),
2532 .help = "Log disk utilization statistics",
2534 .category = FIO_OPT_C_STAT,
2535 .group = FIO_OPT_G_INVALID,
2539 .name = "gtod_reduce",
2540 .lname = "Reduce gettimeofday() calls",
2541 .type = FIO_OPT_BOOL,
2542 .help = "Greatly reduce number of gettimeofday() calls",
2543 .cb = str_gtod_reduce_cb,
2546 .category = FIO_OPT_C_STAT,
2547 .group = FIO_OPT_G_INVALID,
2550 .name = "disable_lat",
2551 .lname = "Disable all latency stats",
2552 .type = FIO_OPT_BOOL,
2553 .off1 = td_var_offset(disable_lat),
2554 .help = "Disable latency numbers",
2555 .parent = "gtod_reduce",
2558 .category = FIO_OPT_C_STAT,
2559 .group = FIO_OPT_G_INVALID,
2562 .name = "disable_clat",
2563 .lname = "Disable completion latency stats",
2564 .type = FIO_OPT_BOOL,
2565 .off1 = td_var_offset(disable_clat),
2566 .help = "Disable completion latency numbers",
2567 .parent = "gtod_reduce",
2570 .category = FIO_OPT_C_STAT,
2571 .group = FIO_OPT_G_INVALID,
2574 .name = "disable_slat",
2575 .lname = "Disable submission latency stats",
2576 .type = FIO_OPT_BOOL,
2577 .off1 = td_var_offset(disable_slat),
2578 .help = "Disable submission latency numbers",
2579 .parent = "gtod_reduce",
2582 .category = FIO_OPT_C_STAT,
2583 .group = FIO_OPT_G_INVALID,
2586 .name = "disable_bw_measurement",
2587 .lname = "Disable bandwidth stats",
2588 .type = FIO_OPT_BOOL,
2589 .off1 = td_var_offset(disable_bw),
2590 .help = "Disable bandwidth logging",
2591 .parent = "gtod_reduce",
2594 .category = FIO_OPT_C_STAT,
2595 .group = FIO_OPT_G_INVALID,
2599 .lname = "Dedicated gettimeofday() CPU",
2600 .type = FIO_OPT_INT,
2601 .cb = str_gtod_cpu_cb,
2602 .help = "Set up dedicated gettimeofday() thread on this CPU",
2603 .verify = gtod_cpu_verify,
2604 .category = FIO_OPT_C_GENERAL,
2605 .group = FIO_OPT_G_CLOCK,
2608 .name = "continue_on_error",
2609 .lname = "Continue on error",
2610 .type = FIO_OPT_STR,
2611 .off1 = td_var_offset(continue_on_error),
2612 .help = "Continue on non-fatal errors during IO",
2614 .category = FIO_OPT_C_GENERAL,
2615 .group = FIO_OPT_G_INVALID,
2618 .oval = ERROR_TYPE_NONE,
2619 .help = "Exit when an error is encountered",
2622 .oval = ERROR_TYPE_READ,
2623 .help = "Continue on read errors only",
2626 .oval = ERROR_TYPE_WRITE,
2627 .help = "Continue on write errors only",
2630 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
2631 .help = "Continue on any IO errors",
2634 .oval = ERROR_TYPE_VERIFY,
2635 .help = "Continue on verify errors only",
2638 .oval = ERROR_TYPE_ANY,
2639 .help = "Continue on all io and verify errors",
2642 .oval = ERROR_TYPE_NONE,
2643 .help = "Alias for 'none'",
2646 .oval = ERROR_TYPE_ANY,
2647 .help = "Alias for 'all'",
2654 .type = FIO_OPT_STR_STORE,
2655 .off1 = td_var_offset(profile),
2656 .help = "Select a specific builtin performance test",
2657 .category = FIO_OPT_C_PROFILE,
2658 .group = FIO_OPT_G_INVALID,
2663 .type = FIO_OPT_STR_STORE,
2664 .off1 = td_var_offset(cgroup),
2665 .help = "Add job to cgroup of this name",
2666 .category = FIO_OPT_C_GENERAL,
2667 .group = FIO_OPT_G_CGROUP,
2670 .name = "cgroup_nodelete",
2671 .lname = "Cgroup no-delete",
2672 .type = FIO_OPT_BOOL,
2673 .off1 = td_var_offset(cgroup_nodelete),
2674 .help = "Do not delete cgroups after job completion",
2677 .category = FIO_OPT_C_GENERAL,
2678 .group = FIO_OPT_G_CGROUP,
2681 .name = "cgroup_weight",
2682 .lname = "Cgroup weight",
2683 .type = FIO_OPT_INT,
2684 .off1 = td_var_offset(cgroup_weight),
2685 .help = "Use given weight for cgroup",
2689 .category = FIO_OPT_C_GENERAL,
2690 .group = FIO_OPT_G_CGROUP,
2695 .type = FIO_OPT_INT,
2696 .off1 = td_var_offset(uid),
2697 .help = "Run job with this user ID",
2698 .category = FIO_OPT_C_GENERAL,
2699 .group = FIO_OPT_G_CRED,
2703 .lname = "Group ID",
2704 .type = FIO_OPT_INT,
2705 .off1 = td_var_offset(gid),
2706 .help = "Run job with this group ID",
2707 .category = FIO_OPT_C_GENERAL,
2708 .group = FIO_OPT_G_CRED,
2713 .type = FIO_OPT_INT,
2714 .off1 = td_var_offset(kb_base),
2715 .verify = kb_base_verify,
2718 .help = "How many bytes per KB for reporting (1000 or 1024)",
2719 .category = FIO_OPT_C_GENERAL,
2720 .group = FIO_OPT_G_INVALID,
2723 .name = "hugepage-size",
2724 .lname = "Hugepage size",
2725 .type = FIO_OPT_INT,
2726 .off1 = td_var_offset(hugepage_size),
2727 .help = "When using hugepages, specify size of each page",
2728 .def = __fio_stringify(FIO_HUGE_PAGE),
2729 .interval = 1024 * 1024,
2730 .category = FIO_OPT_C_GENERAL,
2731 .group = FIO_OPT_G_INVALID,
2735 .lname = "I/O flow ID",
2736 .type = FIO_OPT_INT,
2737 .off1 = td_var_offset(flow_id),
2738 .help = "The flow index ID to use",
2740 .category = FIO_OPT_C_IO,
2741 .group = FIO_OPT_G_IO_FLOW,
2745 .lname = "I/O flow weight",
2746 .type = FIO_OPT_INT,
2747 .off1 = td_var_offset(flow),
2748 .help = "Weight for flow control of this job",
2749 .parent = "flow_id",
2752 .category = FIO_OPT_C_IO,
2753 .group = FIO_OPT_G_IO_FLOW,
2756 .name = "flow_watermark",
2757 .lname = "I/O flow watermark",
2758 .type = FIO_OPT_INT,
2759 .off1 = td_var_offset(flow_watermark),
2760 .help = "High watermark for flow control. This option"
2761 " should be set to the same value for all threads"
2762 " with non-zero flow.",
2763 .parent = "flow_id",
2766 .category = FIO_OPT_C_IO,
2767 .group = FIO_OPT_G_IO_FLOW,
2770 .name = "flow_sleep",
2771 .lname = "I/O flow sleep",
2772 .type = FIO_OPT_INT,
2773 .off1 = td_var_offset(flow_sleep),
2774 .help = "How many microseconds to sleep after being held"
2775 " back by the flow control mechanism",
2776 .parent = "flow_id",
2779 .category = FIO_OPT_C_IO,
2780 .group = FIO_OPT_G_IO_FLOW,
2787 static void add_to_lopt(struct option *lopt, struct fio_option *o,
2788 const char *name, int val)
2790 lopt->name = (char *) name;
2792 if (o->type == FIO_OPT_STR_SET)
2793 lopt->has_arg = no_argument;
2795 lopt->has_arg = required_argument;
2798 static void options_to_lopts(struct fio_option *opts,
2799 struct option *long_options,
2800 int i, int option_type)
2802 struct fio_option *o = &opts[0];
2804 add_to_lopt(&long_options[i], o, o->name, option_type);
2807 add_to_lopt(&long_options[i], o, o->alias, option_type);
2812 assert(i < FIO_NR_OPTIONS);
2816 void fio_options_set_ioengine_opts(struct option *long_options,
2817 struct thread_data *td)
2822 while (long_options[i].name) {
2823 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
2824 memset(&long_options[i], 0, sizeof(*long_options));
2831 * Just clear out the prior ioengine options.
2836 options_to_lopts(td->io_ops->options, long_options, i,
2837 FIO_GETOPT_IOENGINE);
2840 void fio_options_dup_and_init(struct option *long_options)
2844 options_init(fio_options);
2847 while (long_options[i].name)
2850 options_to_lopts(fio_options, long_options, i, FIO_GETOPT_JOB);
2853 struct fio_keyword {
2859 static struct fio_keyword fio_keywords[] = {
2861 .word = "$pagesize",
2862 .desc = "Page size in the system",
2865 .word = "$mb_memory",
2866 .desc = "Megabytes of memory online",
2870 .desc = "Number of CPUs online in the system",
2877 void fio_keywords_init(void)
2879 unsigned long long mb_memory;
2883 sprintf(buf, "%lu", page_size);
2884 fio_keywords[0].replace = strdup(buf);
2886 mb_memory = os_phys_mem() / (1024 * 1024);
2887 sprintf(buf, "%llu", mb_memory);
2888 fio_keywords[1].replace = strdup(buf);
2891 sprintf(buf, "%lu", l);
2892 fio_keywords[2].replace = strdup(buf);
2897 static char *bc_calc(char *str)
2899 char buf[128], *tmp;
2904 * No math, just return string
2906 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
2907 !strchr(str, '/')) || strchr(str, '\''))
2911 * Split option from value, we only need to calculate the value
2913 tmp = strchr(str, '=');
2920 * Prevent buffer overflows; such a case isn't reasonable anyway
2922 if (strlen(str) >= 128 || strlen(tmp) > 100)
2925 sprintf(buf, "which %s > /dev/null", BC_APP);
2927 log_err("fio: bc is needed for performing math\n");
2931 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
2932 f = popen(buf, "r");
2936 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
2941 buf[(tmp - str) + ret - 1] = '\0';
2942 memcpy(buf, str, tmp - str);
2948 * Return a copy of the input string with substrings of the form ${VARNAME}
2949 * substituted with the value of the environment variable VARNAME. The
2950 * substitution always occurs, even if VARNAME is empty or the corresponding
2951 * environment variable undefined.
2953 static char *option_dup_subs(const char *opt)
2955 char out[OPT_LEN_MAX+1];
2956 char in[OPT_LEN_MAX+1];
2959 char *ch1, *ch2, *env;
2960 ssize_t nchr = OPT_LEN_MAX;
2963 if (strlen(opt) + 1 > OPT_LEN_MAX) {
2964 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
2968 in[OPT_LEN_MAX] = '\0';
2969 strncpy(in, opt, OPT_LEN_MAX);
2971 while (*inptr && nchr > 0) {
2972 if (inptr[0] == '$' && inptr[1] == '{') {
2973 ch2 = strchr(inptr, '}');
2974 if (ch2 && inptr+1 < ch2) {
2981 envlen = strlen(env);
2982 if (envlen <= nchr) {
2983 memcpy(outptr, env, envlen);
2993 *outptr++ = *inptr++;
3002 * Look for reserved variable names and replace them with real values
3004 static char *fio_keyword_replace(char *opt)
3010 for (i = 0; fio_keywords[i].word != NULL; i++) {
3011 struct fio_keyword *kw = &fio_keywords[i];
3013 while ((s = strstr(opt, kw->word)) != NULL) {
3014 char *new = malloc(strlen(opt) + 1);
3020 * Copy part of the string before the keyword and
3021 * sprintf() the replacement after it.
3023 memcpy(new, opt, olen);
3024 len = sprintf(new + olen, "%s", kw->replace);
3027 * If there's more in the original string, copy that
3030 opt += strlen(kw->word) + olen;
3032 memcpy(new + olen + len, opt, opt - o_org - 1);
3035 * replace opt and free the old opt
3045 * Check for potential math and invoke bc, if possible
3053 static char **dup_and_sub_options(char **opts, int num_opts)
3056 char **opts_copy = malloc(num_opts * sizeof(*opts));
3057 for (i = 0; i < num_opts; i++) {
3058 opts_copy[i] = option_dup_subs(opts[i]);
3061 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
3066 int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
3068 int i, ret, unknown;
3071 sort_options(opts, fio_options, num_opts);
3072 opts_copy = dup_and_sub_options(opts, num_opts);
3074 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
3075 struct fio_option *o;
3076 int newret = parse_option(opts_copy[i], opts[i], fio_options,
3085 opts_copy[i] = NULL;
3092 ret |= ioengine_load(td);
3094 sort_options(opts_copy, td->io_ops->options, num_opts);
3097 for (i = 0; i < num_opts; i++) {
3098 struct fio_option *o = NULL;
3104 newret = parse_option(opts_copy[i], opts[i],
3105 td->io_ops->options, &o,
3110 log_err("Bad option <%s>\n", opts[i]);
3113 opts_copy[i] = NULL;
3121 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
3123 return parse_cmd_option(opt, val, fio_options, td);
3126 int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
3129 return parse_cmd_option(opt, val, td->io_ops->options, td);
3132 void fio_fill_default_options(struct thread_data *td)
3134 fill_default_options(td, fio_options);
3137 int fio_show_option_help(const char *opt)
3139 return show_cmd_help(fio_options, opt);
3142 void options_mem_dupe(void *data, struct fio_option *options)
3144 struct fio_option *o;
3147 for (o = &options[0]; o->name; o++) {
3148 if (o->type != FIO_OPT_STR_STORE)
3151 ptr = td_var(data, o->off1);
3153 *ptr = strdup(*ptr);
3158 * dupe FIO_OPT_STR_STORE options
3160 void fio_options_mem_dupe(struct thread_data *td)
3162 options_mem_dupe(&td->o, fio_options);
3164 if (td->eo && td->io_ops) {
3165 void *oldeo = td->eo;
3167 td->eo = malloc(td->io_ops->option_struct_size);
3168 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
3169 options_mem_dupe(td->eo, td->io_ops->options);
3173 unsigned int fio_get_kb_base(void *data)
3175 struct thread_options *o = data;
3176 unsigned int kb_base = 0;
3179 kb_base = o->kb_base;
3186 int add_option(struct fio_option *o)
3188 struct fio_option *__o;
3197 memcpy(&fio_options[opt_index], o, sizeof(*o));
3201 void invalidate_profile_options(const char *prof_name)
3203 struct fio_option *o;
3207 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
3208 o->type = FIO_OPT_INVALID;
3209 o->prof_name = NULL;
3215 void add_opt_posval(const char *optname, const char *ival, const char *help)
3217 struct fio_option *o;
3220 o = find_option(fio_options, optname);
3224 for (i = 0; i < PARSE_MAX_VP; i++) {
3225 if (o->posval[i].ival)
3228 o->posval[i].ival = ival;
3229 o->posval[i].help = help;
3234 void del_opt_posval(const char *optname, const char *ival)
3236 struct fio_option *o;
3239 o = find_option(fio_options, optname);
3243 for (i = 0; i < PARSE_MAX_VP; i++) {
3244 if (!o->posval[i].ival)
3246 if (strcmp(o->posval[i].ival, ival))
3249 o->posval[i].ival = NULL;
3250 o->posval[i].help = NULL;
3254 void fio_options_free(struct thread_data *td)
3256 options_free(fio_options, td);
3257 if (td->eo && td->io_ops && td->io_ops->options) {
3258 options_free(td->io_ops->options, td->eo);
3264 struct fio_option *fio_option_find(const char *name)
3266 return find_option(fio_options, name);