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_lockmem_cb(void fio_unused *data, unsigned long long *val)
260 static int str_rwmix_read_cb(void *data, unsigned long long *val)
262 struct thread_data *td = data;
264 td->o.rwmix[DDIR_READ] = *val;
265 td->o.rwmix[DDIR_WRITE] = 100 - *val;
269 static int str_rwmix_write_cb(void *data, unsigned long long *val)
271 struct thread_data *td = data;
273 td->o.rwmix[DDIR_WRITE] = *val;
274 td->o.rwmix[DDIR_READ] = 100 - *val;
278 #ifdef FIO_HAVE_IOPRIO
279 static int str_prioclass_cb(void *data, unsigned long long *val)
281 struct thread_data *td = data;
285 * mask off old class bits, str_prio_cb() may have set a default class
287 mask = (1 << IOPRIO_CLASS_SHIFT) - 1;
290 td->ioprio |= *val << IOPRIO_CLASS_SHIFT;
295 static int str_prio_cb(void *data, unsigned long long *val)
297 struct thread_data *td = data;
302 * If no class is set, assume BE
304 if ((td->ioprio >> IOPRIO_CLASS_SHIFT) == 0)
305 td->ioprio |= IOPRIO_CLASS_BE << IOPRIO_CLASS_SHIFT;
312 static int str_exitall_cb(void)
314 exitall_on_terminate = 1;
318 #ifdef FIO_HAVE_CPU_AFFINITY
319 static int str_cpumask_cb(void *data, unsigned long long *val)
321 struct thread_data *td = data;
326 ret = fio_cpuset_init(&td->o.cpumask);
328 log_err("fio: cpuset_init failed\n");
329 td_verror(td, ret, "fio_cpuset_init");
333 max_cpu = cpus_online();
335 for (i = 0; i < sizeof(int) * 8; i++) {
336 if ((1 << i) & *val) {
338 log_err("fio: CPU %d too large (max=%ld)\n", i,
342 dprint(FD_PARSE, "set cpu allowed %d\n", i);
343 fio_cpu_set(&td->o.cpumask, i);
347 td->o.cpumask_set = 1;
351 static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask,
358 ret = fio_cpuset_init(mask);
360 log_err("fio: cpuset_init failed\n");
361 td_verror(td, ret, "fio_cpuset_init");
365 p = str = strdup(input);
367 strip_blank_front(&str);
368 strip_blank_end(str);
370 max_cpu = cpus_online();
372 while ((cpu = strsep(&str, ",")) != NULL) {
381 while ((cpu2 = strsep(&str2, "-")) != NULL) {
391 while (icpu <= icpu2) {
392 if (icpu >= FIO_MAX_CPUS) {
393 log_err("fio: your OS only supports up to"
394 " %d CPUs\n", (int) FIO_MAX_CPUS);
398 if (icpu > max_cpu) {
399 log_err("fio: CPU %d too large (max=%ld)\n",
405 dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
406 fio_cpu_set(mask, icpu);
415 td->o.cpumask_set = 1;
419 static int str_cpus_allowed_cb(void *data, const char *input)
421 struct thread_data *td = data;
424 ret = set_cpus_allowed(td, &td->o.cpumask, input);
426 td->o.cpumask_set = 1;
431 static int str_verify_cpus_allowed_cb(void *data, const char *input)
433 struct thread_data *td = data;
436 ret = set_cpus_allowed(td, &td->o.verify_cpumask, input);
438 td->o.verify_cpumask_set = 1;
445 static int str_verify_trim_cb(void *data, unsigned long long *val)
447 struct thread_data *td = data;
449 td->o.trim_percentage = *val;
454 static int str_fst_cb(void *data, const char *str)
456 struct thread_data *td = data;
457 char *nr = get_opt_postfix(str);
459 td->file_service_nr = 1;
461 td->file_service_nr = atoi(nr);
468 #ifdef FIO_HAVE_SYNC_FILE_RANGE
469 static int str_sfr_cb(void *data, const char *str)
471 struct thread_data *td = data;
472 char *nr = get_opt_postfix(str);
474 td->sync_file_range_nr = 1;
476 td->sync_file_range_nr = atoi(nr);
484 static int check_dir(struct thread_data *td, char *fname)
487 char file[PATH_MAX], *dir;
490 if (td->o.directory) {
491 strcpy(file, td->o.directory);
496 sprintf(file + elen, "%s", fname);
502 * We can't do this on FIO_DISKLESSIO engines. The engine isn't loaded
503 * yet, so we can't do this check right here...
505 if (lstat(dir, &sb) < 0) {
508 log_err("fio: %s is not a directory\n", dir);
509 td_verror(td, ret, "lstat");
513 if (!S_ISDIR(sb.st_mode)) {
514 log_err("fio: %s is not a directory\n", dir);
524 * Return next file in the string. Files are separated with ':'. If the ':'
525 * is escaped with a '\', then that ':' is part of the filename and does not
526 * indicate a new file.
528 static char *get_next_file_name(char **ptr)
533 if (!str || !strlen(str))
539 * No colon, we are done
541 p = strchr(str, ':');
548 * We got a colon, but it's the first character. Skip and
556 if (*(p - 1) != '\\') {
562 memmove(p - 1, p, strlen(p) + 1);
569 static int str_filename_cb(void *data, const char *input)
571 struct thread_data *td = data;
572 char *fname, *str, *p;
574 p = str = strdup(input);
576 strip_blank_front(&str);
577 strip_blank_end(str);
579 if (!td->files_index)
582 while ((fname = get_next_file_name(&str)) != NULL) {
585 if (check_dir(td, fname)) {
597 static int str_directory_cb(void *data, const char fio_unused *str)
599 struct thread_data *td = data;
602 if (lstat(td->o.directory, &sb) < 0) {
605 log_err("fio: %s is not a directory\n", td->o.directory);
606 td_verror(td, ret, "lstat");
609 if (!S_ISDIR(sb.st_mode)) {
610 log_err("fio: %s is not a directory\n", td->o.directory);
617 static int str_opendir_cb(void *data, const char fio_unused *str)
619 struct thread_data *td = data;
621 if (!td->files_index)
624 return add_dir_files(td, td->o.opendir);
627 static int str_verify_offset_cb(void *data, unsigned long long *off)
629 struct thread_data *td = data;
631 if (*off && *off < sizeof(struct verify_header)) {
632 log_err("fio: verify_offset too small\n");
636 td->o.verify_offset = *off;
640 static int str_verify_pattern_cb(void *data, const char *input)
642 struct thread_data *td = data;
644 int i = 0, j = 0, len, k, base = 10;
647 loc1 = strstr(input, "0x");
648 loc2 = strstr(input, "0X");
651 off = strtol(input, NULL, base);
652 if (off != LONG_MAX || errno != ERANGE) {
654 td->o.verify_pattern[i] = off & 0xff;
663 j = loc1 - input + 2;
665 j = loc2 - input + 2;
668 if (len - j < MAX_PATTERN_SIZE * 2) {
670 off = converthexchartoint(input[k--]);
672 off += (converthexchartoint(input[k--])
674 td->o.verify_pattern[i++] = (char) off;
680 * Fill the pattern all the way to the end. This greatly reduces
681 * the number of memcpy's we have to do when verifying the IO.
683 while (i > 1 && i * 2 <= MAX_PATTERN_SIZE) {
684 memcpy(&td->o.verify_pattern[i], &td->o.verify_pattern[0], i);
689 * The code in verify_io_u_pattern assumes a single byte pattern
690 * fills the whole verify pattern buffer.
692 memset(td->o.verify_pattern, td->o.verify_pattern[0],
696 td->o.verify_pattern_bytes = i;
699 * VERIFY_META could already be set
701 if (td->o.verify == VERIFY_NONE)
702 td->o.verify = VERIFY_PATTERN;
707 static int str_lockfile_cb(void *data, const char *str)
709 struct thread_data *td = data;
710 char *nr = get_opt_postfix(str);
712 td->o.lockfile_batch = 1;
714 td->o.lockfile_batch = atoi(nr);
721 static int str_write_bw_log_cb(void *data, const char *str)
723 struct thread_data *td = data;
726 td->o.bw_log_file = strdup(str);
728 td->o.write_bw_log = 1;
732 static int str_write_lat_log_cb(void *data, const char *str)
734 struct thread_data *td = data;
737 td->o.lat_log_file = strdup(str);
739 td->o.write_lat_log = 1;
743 static int str_write_iops_log_cb(void *data, const char *str)
745 struct thread_data *td = data;
748 td->o.iops_log_file = strdup(str);
750 td->o.write_iops_log = 1;
754 static int str_gtod_reduce_cb(void *data, int *il)
756 struct thread_data *td = data;
759 td->o.disable_lat = !!val;
760 td->o.disable_clat = !!val;
761 td->o.disable_slat = !!val;
762 td->o.disable_bw = !!val;
763 td->o.clat_percentiles = !val;
765 td->tv_cache_mask = 63;
770 static int str_gtod_cpu_cb(void *data, long long *il)
772 struct thread_data *td = data;
775 td->o.gtod_cpu = val;
776 td->o.gtod_offload = 1;
780 static int str_size_cb(void *data, unsigned long long *__val)
782 struct thread_data *td = data;
783 unsigned long long v = *__val;
785 if (parse_is_percent(v)) {
787 td->o.size_percent = -1ULL - v;
794 static int rw_verify(struct fio_option *o, void *data)
796 struct thread_data *td = data;
798 if (read_only && td_write(td)) {
799 log_err("fio: job <%s> has write bit set, but fio is in"
800 " read-only mode\n", td->o.name);
807 static int gtod_cpu_verify(struct fio_option *o, void *data)
809 #ifndef FIO_HAVE_CPU_AFFINITY
810 struct thread_data *td = data;
812 if (td->o.gtod_cpu) {
813 log_err("fio: platform must support CPU affinity for"
814 "gettimeofday() offloading\n");
822 static int kb_base_verify(struct fio_option *o, void *data)
824 struct thread_data *td = data;
826 if (td->o.kb_base != 1024 && td->o.kb_base != 1000) {
827 log_err("fio: kb_base set to nonsensical value: %u\n",
838 static struct opt_group fio_opt_groups[] = {
841 .mask = FIO_OPT_C_GENERAL,
845 .mask = FIO_OPT_C_IO,
849 .mask = FIO_OPT_C_FILE,
852 .name = "Statistics",
853 .mask = FIO_OPT_C_STAT,
857 .mask = FIO_OPT_C_LOG,
864 static struct opt_group *__opt_group_from_mask(struct opt_group *ogs, unsigned int *mask,
865 unsigned int inv_mask)
867 struct opt_group *og;
870 if (*mask == inv_mask || !*mask)
873 for (i = 0; ogs[i].name; i++) {
876 if (*mask & og->mask) {
877 *mask &= ~(og->mask);
885 struct opt_group *opt_group_from_mask(unsigned int *mask)
887 return __opt_group_from_mask(fio_opt_groups, mask, FIO_OPT_C_INVALID);
890 static struct opt_group fio_opt_cat_groups[] = {
893 .mask = FIO_OPT_G_RATE,
897 .mask = FIO_OPT_G_ZONE,
900 .name = "Read/write mix",
901 .mask = FIO_OPT_G_RWMIX,
905 .mask = FIO_OPT_G_VERIFY,
909 .mask = FIO_OPT_G_TRIM,
912 .name = "I/O Logging",
913 .mask = FIO_OPT_G_IOLOG,
917 .mask = FIO_OPT_G_IO_DEPTH,
921 .mask = FIO_OPT_G_IO_FLOW,
924 .name = "Description",
925 .mask = FIO_OPT_G_DESC,
929 .mask = FIO_OPT_G_FILENAME,
932 .name = "General I/O",
933 .mask = FIO_OPT_G_IO_BASIC,
937 .mask = FIO_OPT_G_CGROUP,
941 .mask = FIO_OPT_G_RUNTIME,
945 .mask = FIO_OPT_G_PROCESS,
948 .name = "Job credentials / priority",
949 .mask = FIO_OPT_G_CRED,
952 .name = "Clock settings",
953 .mask = FIO_OPT_G_CLOCK,
957 .mask = FIO_OPT_G_IO_TYPE,
960 .name = "I/O Thinktime",
961 .mask = FIO_OPT_G_THINKTIME,
964 .name = "Randomizations",
965 .mask = FIO_OPT_G_RANDOM,
968 .name = "I/O buffers",
969 .mask = FIO_OPT_G_IO_BUF,
976 struct opt_group *opt_group_cat_from_mask(unsigned int *mask)
978 return __opt_group_from_mask(fio_opt_cat_groups, mask, FIO_OPT_G_INVALID);
982 * Map of job/command line options
984 struct fio_option fio_options[FIO_MAX_OPTS] = {
986 .name = "description",
987 .lname = "Description of job",
988 .type = FIO_OPT_STR_STORE,
989 .off1 = td_var_offset(description),
990 .help = "Text job description",
991 .category = FIO_OPT_C_GENERAL,
992 .group = FIO_OPT_G_DESC,
997 .type = FIO_OPT_STR_STORE,
998 .off1 = td_var_offset(name),
999 .help = "Name of this job",
1000 .category = FIO_OPT_C_GENERAL,
1001 .group = FIO_OPT_G_DESC,
1005 .lname = "Filename(s)",
1006 .type = FIO_OPT_STR_STORE,
1007 .off1 = td_var_offset(filename),
1008 .cb = str_filename_cb,
1009 .prio = -1, /* must come after "directory" */
1010 .help = "File(s) to use for the workload",
1011 .category = FIO_OPT_C_FILE,
1012 .group = FIO_OPT_G_FILENAME,
1015 .name = "directory",
1016 .lname = "Directory",
1017 .type = FIO_OPT_STR_STORE,
1018 .off1 = td_var_offset(directory),
1019 .cb = str_directory_cb,
1020 .help = "Directory to store files in",
1021 .category = FIO_OPT_C_FILE,
1022 .group = FIO_OPT_G_FILENAME,
1026 .lname = "Lockfile",
1027 .type = FIO_OPT_STR,
1028 .cb = str_lockfile_cb,
1029 .off1 = td_var_offset(file_lock_mode),
1030 .help = "Lock file when doing IO to it",
1031 .parent = "filename",
1034 .category = FIO_OPT_C_FILE,
1035 .group = FIO_OPT_G_FILENAME,
1038 .oval = FILE_LOCK_NONE,
1039 .help = "No file locking",
1041 { .ival = "exclusive",
1042 .oval = FILE_LOCK_EXCLUSIVE,
1043 .help = "Exclusive file lock",
1046 .ival = "readwrite",
1047 .oval = FILE_LOCK_READWRITE,
1048 .help = "Read vs write lock",
1054 .lname = "Open directory",
1055 .type = FIO_OPT_STR_STORE,
1056 .off1 = td_var_offset(opendir),
1057 .cb = str_opendir_cb,
1058 .help = "Recursively add files from this directory and down",
1059 .category = FIO_OPT_C_FILE,
1060 .group = FIO_OPT_G_FILENAME,
1064 .lname = "Read/write",
1065 .alias = "readwrite",
1066 .type = FIO_OPT_STR,
1068 .off1 = td_var_offset(td_ddir),
1069 .help = "IO direction",
1071 .verify = rw_verify,
1072 .category = FIO_OPT_C_IO,
1073 .group = FIO_OPT_G_IO_BASIC,
1076 .oval = TD_DDIR_READ,
1077 .help = "Sequential read",
1080 .oval = TD_DDIR_WRITE,
1081 .help = "Sequential write",
1083 { .ival = "randread",
1084 .oval = TD_DDIR_RANDREAD,
1085 .help = "Random read",
1087 { .ival = "randwrite",
1088 .oval = TD_DDIR_RANDWRITE,
1089 .help = "Random write",
1093 .help = "Sequential read and write mix",
1096 .oval = TD_DDIR_RANDRW,
1097 .help = "Random read and write mix"
1102 .name = "rw_sequencer",
1103 .lname = "RW Sequencer",
1104 .type = FIO_OPT_STR,
1105 .off1 = td_var_offset(rw_seq),
1106 .help = "IO offset generator modifier",
1107 .def = "sequential",
1108 .category = FIO_OPT_C_IO,
1109 .group = FIO_OPT_G_IO_BASIC,
1111 { .ival = "sequential",
1113 .help = "Generate sequential offsets",
1115 { .ival = "identical",
1116 .oval = RW_SEQ_IDENT,
1117 .help = "Generate identical offsets",
1124 .lname = "IO Engine",
1125 .type = FIO_OPT_STR_STORE,
1126 .off1 = td_var_offset(ioengine),
1127 .help = "IO engine to use",
1128 .def = FIO_PREFERRED_ENGINE,
1129 .category = FIO_OPT_C_IO,
1130 .group = FIO_OPT_G_IO_BASIC,
1133 .help = "Use read/write",
1136 .help = "Use pread/pwrite",
1139 .help = "Use readv/writev",
1141 #ifdef FIO_HAVE_LIBAIO
1143 .help = "Linux native asynchronous IO",
1146 #ifdef FIO_HAVE_POSIXAIO
1147 { .ival = "posixaio",
1148 .help = "POSIX asynchronous IO",
1151 #ifdef FIO_HAVE_SOLARISAIO
1152 { .ival = "solarisaio",
1153 .help = "Solaris native asynchronous IO",
1156 #ifdef FIO_HAVE_WINDOWSAIO
1157 { .ival = "windowsaio",
1158 .help = "Windows native asynchronous IO"
1162 .help = "Memory mapped IO"
1164 #ifdef FIO_HAVE_SPLICE
1166 .help = "splice/vmsplice based IO",
1168 { .ival = "netsplice",
1169 .help = "splice/vmsplice to/from the network",
1172 #ifdef FIO_HAVE_SGIO
1174 .help = "SCSI generic v3 IO",
1178 .help = "Testing engine (no data transfer)",
1181 .help = "Network IO",
1183 #ifdef FIO_HAVE_SYSLET
1184 { .ival = "syslet-rw",
1185 .help = "syslet enabled async pread/pwrite IO",
1189 .help = "CPU cycle burner engine",
1191 #ifdef FIO_HAVE_GUASI
1193 .help = "GUASI IO engine",
1196 #ifdef FIO_HAVE_BINJECT
1197 { .ival = "binject",
1198 .help = "binject direct inject block engine",
1201 #ifdef FIO_HAVE_RDMA
1203 .help = "RDMA IO engine",
1206 { .ival = "external",
1207 .help = "Load external engine (append name)",
1213 .lname = "IO Depth",
1214 .type = FIO_OPT_INT,
1215 .off1 = td_var_offset(iodepth),
1216 .help = "Number of IO buffers to keep in flight",
1220 .category = FIO_OPT_C_IO,
1221 .group = FIO_OPT_G_IO_BASIC,
1224 .name = "iodepth_batch",
1225 .lname = "IO Depth batch",
1226 .alias = "iodepth_batch_submit",
1227 .type = FIO_OPT_INT,
1228 .off1 = td_var_offset(iodepth_batch),
1229 .help = "Number of IO buffers to submit in one go",
1230 .parent = "iodepth",
1235 .category = FIO_OPT_C_IO,
1236 .group = FIO_OPT_G_IO_BASIC,
1239 .name = "iodepth_batch_complete",
1240 .lname = "IO Depth batch complete",
1241 .type = FIO_OPT_INT,
1242 .off1 = td_var_offset(iodepth_batch_complete),
1243 .help = "Number of IO buffers to retrieve in one go",
1244 .parent = "iodepth",
1249 .category = FIO_OPT_C_IO,
1250 .group = FIO_OPT_G_IO_BASIC,
1253 .name = "iodepth_low",
1254 .lname = "IO Depth batch low",
1255 .type = FIO_OPT_INT,
1256 .off1 = td_var_offset(iodepth_low),
1257 .help = "Low water mark for queuing depth",
1258 .parent = "iodepth",
1261 .category = FIO_OPT_C_IO,
1262 .group = FIO_OPT_G_IO_BASIC,
1267 .type = FIO_OPT_STR_VAL,
1269 .help = "Total size of device or files",
1270 .interval = 1024 * 1024,
1271 .category = FIO_OPT_C_IO,
1272 .group = FIO_OPT_G_INVALID,
1275 .name = "fill_device",
1276 .lname = "Fill device",
1278 .type = FIO_OPT_BOOL,
1279 .off1 = td_var_offset(fill_device),
1280 .help = "Write until an ENOSPC error occurs",
1282 .category = FIO_OPT_C_FILE,
1283 .group = FIO_OPT_G_INVALID,
1287 .lname = "File size",
1288 .type = FIO_OPT_STR_VAL,
1289 .off1 = td_var_offset(file_size_low),
1290 .off2 = td_var_offset(file_size_high),
1292 .help = "Size of individual files",
1293 .interval = 1024 * 1024,
1294 .category = FIO_OPT_C_FILE,
1295 .group = FIO_OPT_G_INVALID,
1299 .lname = "IO offset",
1300 .alias = "fileoffset",
1301 .type = FIO_OPT_STR_VAL,
1302 .off1 = td_var_offset(start_offset),
1303 .help = "Start IO from this offset",
1305 .interval = 1024 * 1024,
1306 .category = FIO_OPT_C_IO,
1307 .group = FIO_OPT_G_INVALID,
1310 .name = "offset_increment",
1311 .lname = "IO offset increment",
1312 .type = FIO_OPT_STR_VAL,
1313 .off1 = td_var_offset(offset_increment),
1314 .help = "What is the increment from one offset to the next",
1318 .interval = 1024 * 1024,
1319 .category = FIO_OPT_C_IO,
1320 .group = FIO_OPT_G_INVALID,
1324 .lname = "Block size",
1325 .alias = "blocksize",
1326 .type = FIO_OPT_INT,
1327 .off1 = td_var_offset(bs[DDIR_READ]),
1328 .off2 = td_var_offset(bs[DDIR_WRITE]),
1330 .help = "Block size unit",
1335 .category = FIO_OPT_C_IO,
1336 .group = FIO_OPT_G_INVALID,
1340 .lname = "Block size align",
1341 .alias = "blockalign",
1342 .type = FIO_OPT_INT,
1343 .off1 = td_var_offset(ba[DDIR_READ]),
1344 .off2 = td_var_offset(ba[DDIR_WRITE]),
1346 .help = "IO block offset alignment",
1350 .category = FIO_OPT_C_IO,
1351 .group = FIO_OPT_G_INVALID,
1355 .lname = "Block size range",
1356 .alias = "blocksize_range",
1357 .type = FIO_OPT_RANGE,
1358 .off1 = td_var_offset(min_bs[DDIR_READ]),
1359 .off2 = td_var_offset(max_bs[DDIR_READ]),
1360 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
1361 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
1363 .help = "Set block size range (in more detail than bs)",
1367 .category = FIO_OPT_C_IO,
1368 .group = FIO_OPT_G_INVALID,
1372 .lname = "Block size split",
1373 .type = FIO_OPT_STR,
1374 .cb = str_bssplit_cb,
1375 .help = "Set a specific mix of block sizes",
1378 .category = FIO_OPT_C_IO,
1379 .group = FIO_OPT_G_INVALID,
1382 .name = "bs_unaligned",
1383 .lname = "Block size unaligned",
1384 .alias = "blocksize_unaligned",
1385 .type = FIO_OPT_STR_SET,
1386 .off1 = td_var_offset(bs_unaligned),
1387 .help = "Don't sector align IO buffer sizes",
1390 .category = FIO_OPT_C_IO,
1391 .group = FIO_OPT_G_INVALID,
1394 .name = "randrepeat",
1395 .lname = "Random repeatable",
1396 .type = FIO_OPT_BOOL,
1397 .off1 = td_var_offset(rand_repeatable),
1398 .help = "Use repeatable random IO pattern",
1402 .category = FIO_OPT_C_IO,
1403 .group = FIO_OPT_G_RANDOM,
1406 .name = "use_os_rand",
1407 .lname = "Use OS random",
1408 .type = FIO_OPT_BOOL,
1409 .off1 = td_var_offset(use_os_rand),
1410 .help = "Set to use OS random generator",
1414 .category = FIO_OPT_C_IO,
1415 .group = FIO_OPT_G_RANDOM,
1418 .name = "norandommap",
1419 .lname = "No randommap",
1420 .type = FIO_OPT_STR_SET,
1421 .off1 = td_var_offset(norandommap),
1422 .help = "Accept potential duplicate random blocks",
1426 .category = FIO_OPT_C_IO,
1427 .group = FIO_OPT_G_RANDOM,
1430 .name = "softrandommap",
1431 .lname = "Soft randommap",
1432 .type = FIO_OPT_BOOL,
1433 .off1 = td_var_offset(softrandommap),
1434 .help = "Set norandommap if randommap allocation fails",
1435 .parent = "norandommap",
1438 .category = FIO_OPT_C_IO,
1439 .group = FIO_OPT_G_RANDOM,
1443 .lname = "Number of files",
1444 .alias = "nr_files",
1445 .type = FIO_OPT_INT,
1446 .off1 = td_var_offset(nr_files),
1447 .help = "Split job workload between this number of files",
1450 .category = FIO_OPT_C_FILE,
1451 .group = FIO_OPT_G_INVALID,
1454 .name = "openfiles",
1455 .lname = "Number of open files",
1456 .type = FIO_OPT_INT,
1457 .off1 = td_var_offset(open_files),
1458 .help = "Number of files to keep open at the same time",
1459 .category = FIO_OPT_C_FILE,
1460 .group = FIO_OPT_G_INVALID,
1463 .name = "file_service_type",
1464 .lname = "File service type",
1465 .type = FIO_OPT_STR,
1467 .off1 = td_var_offset(file_service_type),
1468 .help = "How to select which file to service next",
1469 .def = "roundrobin",
1470 .category = FIO_OPT_C_FILE,
1471 .group = FIO_OPT_G_INVALID,
1474 .oval = FIO_FSERVICE_RANDOM,
1475 .help = "Choose a file at random",
1477 { .ival = "roundrobin",
1478 .oval = FIO_FSERVICE_RR,
1479 .help = "Round robin select files",
1481 { .ival = "sequential",
1482 .oval = FIO_FSERVICE_SEQ,
1483 .help = "Finish one file before moving to the next",
1486 .parent = "nrfiles",
1489 #ifdef FIO_HAVE_FALLOCATE
1491 .name = "fallocate",
1492 .lname = "Fallocate",
1493 .type = FIO_OPT_STR,
1494 .off1 = td_var_offset(fallocate_mode),
1495 .help = "Whether pre-allocation is performed when laying out files",
1497 .category = FIO_OPT_C_FILE,
1498 .group = FIO_OPT_G_INVALID,
1501 .oval = FIO_FALLOCATE_NONE,
1502 .help = "Do not pre-allocate space",
1505 .oval = FIO_FALLOCATE_POSIX,
1506 .help = "Use posix_fallocate()",
1508 #ifdef FIO_HAVE_LINUX_FALLOCATE
1510 .oval = FIO_FALLOCATE_KEEP_SIZE,
1511 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
1514 /* Compatibility with former boolean values */
1516 .oval = FIO_FALLOCATE_NONE,
1517 .help = "Alias for 'none'",
1520 .oval = FIO_FALLOCATE_POSIX,
1521 .help = "Alias for 'posix'",
1525 #endif /* FIO_HAVE_FALLOCATE */
1527 .name = "fadvise_hint",
1528 .lname = "Fadvise hint",
1529 .type = FIO_OPT_BOOL,
1530 .off1 = td_var_offset(fadvise_hint),
1531 .help = "Use fadvise() to advise the kernel on IO pattern",
1533 .category = FIO_OPT_C_FILE,
1534 .group = FIO_OPT_G_INVALID,
1539 .type = FIO_OPT_INT,
1540 .off1 = td_var_offset(fsync_blocks),
1541 .help = "Issue fsync for writes every given number of blocks",
1544 .category = FIO_OPT_C_FILE,
1545 .group = FIO_OPT_G_INVALID,
1548 .name = "fdatasync",
1549 .lname = "Fdatasync",
1550 .type = FIO_OPT_INT,
1551 .off1 = td_var_offset(fdatasync_blocks),
1552 .help = "Issue fdatasync for writes every given number of blocks",
1555 .category = FIO_OPT_C_FILE,
1556 .group = FIO_OPT_G_INVALID,
1559 .name = "write_barrier",
1560 .lname = "Write barrier",
1561 .type = FIO_OPT_INT,
1562 .off1 = td_var_offset(barrier_blocks),
1563 .help = "Make every Nth write a barrier write",
1566 .category = FIO_OPT_C_IO,
1567 .group = FIO_OPT_G_INVALID,
1569 #ifdef FIO_HAVE_SYNC_FILE_RANGE
1571 .name = "sync_file_range",
1572 .lname = "Sync file range",
1574 { .ival = "wait_before",
1575 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
1576 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
1580 .oval = SYNC_FILE_RANGE_WRITE,
1581 .help = "SYNC_FILE_RANGE_WRITE",
1585 .ival = "wait_after",
1586 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
1587 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
1591 .type = FIO_OPT_STR_MULTI,
1593 .off1 = td_var_offset(sync_file_range),
1594 .help = "Use sync_file_range()",
1595 .category = FIO_OPT_C_FILE,
1596 .group = FIO_OPT_G_INVALID,
1601 .lname = "Direct I/O",
1602 .type = FIO_OPT_BOOL,
1603 .off1 = td_var_offset(odirect),
1604 .help = "Use O_DIRECT IO (negates buffered)",
1606 .inverse = "buffered",
1607 .category = FIO_OPT_C_IO,
1608 .group = FIO_OPT_G_IO_TYPE,
1612 .lname = "Buffered I/O",
1613 .type = FIO_OPT_BOOL,
1614 .off1 = td_var_offset(odirect),
1616 .help = "Use buffered IO (negates direct)",
1618 .inverse = "direct",
1619 .category = FIO_OPT_C_IO,
1620 .group = FIO_OPT_G_IO_TYPE,
1623 .name = "overwrite",
1624 .lname = "Overwrite",
1625 .type = FIO_OPT_BOOL,
1626 .off1 = td_var_offset(overwrite),
1627 .help = "When writing, set whether to overwrite current data",
1629 .category = FIO_OPT_C_FILE,
1630 .group = FIO_OPT_G_INVALID,
1635 .type = FIO_OPT_INT,
1636 .off1 = td_var_offset(loops),
1637 .help = "Number of times to run the job",
1640 .category = FIO_OPT_C_GENERAL,
1641 .group = FIO_OPT_G_RUNTIME,
1645 .lname = "Number of jobs",
1646 .type = FIO_OPT_INT,
1647 .off1 = td_var_offset(numjobs),
1648 .help = "Duplicate this job this many times",
1651 .category = FIO_OPT_C_GENERAL,
1652 .group = FIO_OPT_G_RUNTIME,
1655 .name = "startdelay",
1656 .lname = "Start delay",
1657 .type = FIO_OPT_STR_VAL_TIME,
1658 .off1 = td_var_offset(start_delay),
1659 .help = "Only start job when this period has passed",
1661 .category = FIO_OPT_C_GENERAL,
1662 .group = FIO_OPT_G_RUNTIME,
1668 .type = FIO_OPT_STR_VAL_TIME,
1669 .off1 = td_var_offset(timeout),
1670 .help = "Stop workload when this amount of time has passed",
1672 .category = FIO_OPT_C_GENERAL,
1673 .group = FIO_OPT_G_RUNTIME,
1676 .name = "time_based",
1677 .lname = "Time based",
1678 .type = FIO_OPT_STR_SET,
1679 .off1 = td_var_offset(time_based),
1680 .help = "Keep running until runtime/timeout is met",
1681 .category = FIO_OPT_C_GENERAL,
1682 .group = FIO_OPT_G_RUNTIME,
1685 .name = "ramp_time",
1686 .lname = "Ramp time",
1687 .type = FIO_OPT_STR_VAL_TIME,
1688 .off1 = td_var_offset(ramp_time),
1689 .help = "Ramp up time before measuring performance",
1690 .category = FIO_OPT_C_GENERAL,
1691 .group = FIO_OPT_G_RUNTIME,
1694 .name = "clocksource",
1695 .lname = "Clock source",
1696 .type = FIO_OPT_STR,
1697 .cb = fio_clock_source_cb,
1698 .off1 = td_var_offset(clocksource),
1699 .help = "What type of timing source to use",
1700 .category = FIO_OPT_C_GENERAL,
1701 .group = FIO_OPT_G_CLOCK,
1703 { .ival = "gettimeofday",
1705 .help = "Use gettimeofday(2) for timing",
1707 { .ival = "clock_gettime",
1708 .oval = CS_CGETTIME,
1709 .help = "Use clock_gettime(2) for timing",
1711 #ifdef ARCH_HAVE_CPU_CLOCK
1713 .oval = CS_CPUCLOCK,
1714 .help = "Use CPU private clock",
1722 .lname = "I/O Memory",
1723 .type = FIO_OPT_STR,
1725 .off1 = td_var_offset(mem_type),
1726 .help = "Backing type for IO buffers",
1728 .category = FIO_OPT_C_IO,
1729 .group = FIO_OPT_G_INVALID,
1733 .help = "Use malloc(3) for IO buffers",
1737 .help = "Use shared memory segments for IO buffers",
1739 #ifdef FIO_HAVE_HUGETLB
1740 { .ival = "shmhuge",
1741 .oval = MEM_SHMHUGE,
1742 .help = "Like shm, but use huge pages",
1747 .help = "Use mmap(2) (file or anon) for IO buffers",
1749 #ifdef FIO_HAVE_HUGETLB
1750 { .ival = "mmaphuge",
1751 .oval = MEM_MMAPHUGE,
1752 .help = "Like mmap, but use huge pages",
1758 .name = "iomem_align",
1759 .alias = "mem_align",
1760 .lname = "I/O memory alignment",
1761 .type = FIO_OPT_INT,
1762 .off1 = td_var_offset(mem_align),
1764 .help = "IO memory buffer offset alignment",
1768 .category = FIO_OPT_C_IO,
1769 .group = FIO_OPT_G_INVALID,
1774 .type = FIO_OPT_STR,
1775 .off1 = td_var_offset(verify),
1776 .help = "Verify data written",
1778 .category = FIO_OPT_C_IO,
1779 .group = FIO_OPT_G_VERIFY,
1782 .oval = VERIFY_NONE,
1783 .help = "Don't do IO verification",
1787 .help = "Use md5 checksums for verification",
1790 .oval = VERIFY_CRC64,
1791 .help = "Use crc64 checksums for verification",
1794 .oval = VERIFY_CRC32,
1795 .help = "Use crc32 checksums for verification",
1797 { .ival = "crc32c-intel",
1798 .oval = VERIFY_CRC32C,
1799 .help = "Use crc32c checksums for verification (hw assisted, if available)",
1802 .oval = VERIFY_CRC32C,
1803 .help = "Use crc32c checksums for verification (hw assisted, if available)",
1806 .oval = VERIFY_CRC16,
1807 .help = "Use crc16 checksums for verification",
1810 .oval = VERIFY_CRC7,
1811 .help = "Use crc7 checksums for verification",
1814 .oval = VERIFY_SHA1,
1815 .help = "Use sha1 checksums for verification",
1818 .oval = VERIFY_SHA256,
1819 .help = "Use sha256 checksums for verification",
1822 .oval = VERIFY_SHA512,
1823 .help = "Use sha512 checksums for verification",
1826 .oval = VERIFY_META,
1827 .help = "Use io information",
1831 .oval = VERIFY_NULL,
1832 .help = "Pretend to verify",
1837 .name = "do_verify",
1838 .lname = "Perform verify step",
1839 .type = FIO_OPT_BOOL,
1840 .off1 = td_var_offset(do_verify),
1841 .help = "Run verification stage after write",
1845 .category = FIO_OPT_C_IO,
1846 .group = FIO_OPT_G_VERIFY,
1849 .name = "verifysort",
1850 .lname = "Verify sort",
1851 .type = FIO_OPT_BOOL,
1852 .off1 = td_var_offset(verifysort),
1853 .help = "Sort written verify blocks for read back",
1857 .category = FIO_OPT_C_IO,
1858 .group = FIO_OPT_G_VERIFY,
1861 .name = "verify_interval",
1862 .lname = "Verify interval",
1863 .type = FIO_OPT_INT,
1864 .off1 = td_var_offset(verify_interval),
1865 .minval = 2 * sizeof(struct verify_header),
1866 .help = "Store verify buffer header every N bytes",
1869 .interval = 2 * sizeof(struct verify_header),
1870 .category = FIO_OPT_C_IO,
1871 .group = FIO_OPT_G_VERIFY,
1874 .name = "verify_offset",
1875 .lname = "Verify offset",
1876 .type = FIO_OPT_INT,
1877 .help = "Offset verify header location by N bytes",
1879 .cb = str_verify_offset_cb,
1882 .category = FIO_OPT_C_IO,
1883 .group = FIO_OPT_G_VERIFY,
1886 .name = "verify_pattern",
1887 .lname = "Verify pattern",
1888 .type = FIO_OPT_STR,
1889 .cb = str_verify_pattern_cb,
1890 .help = "Fill pattern for IO buffers",
1893 .category = FIO_OPT_C_IO,
1894 .group = FIO_OPT_G_VERIFY,
1897 .name = "verify_fatal",
1898 .lname = "Verify fatal",
1899 .type = FIO_OPT_BOOL,
1900 .off1 = td_var_offset(verify_fatal),
1902 .help = "Exit on a single verify failure, don't continue",
1905 .category = FIO_OPT_C_IO,
1906 .group = FIO_OPT_G_VERIFY,
1909 .name = "verify_dump",
1910 .lname = "Verify dump",
1911 .type = FIO_OPT_BOOL,
1912 .off1 = td_var_offset(verify_dump),
1914 .help = "Dump contents of good and bad blocks on failure",
1917 .category = FIO_OPT_C_IO,
1918 .group = FIO_OPT_G_VERIFY,
1921 .name = "verify_async",
1922 .lname = "Verify asynchronously",
1923 .type = FIO_OPT_INT,
1924 .off1 = td_var_offset(verify_async),
1926 .help = "Number of async verifier threads to use",
1929 .category = FIO_OPT_C_IO,
1930 .group = FIO_OPT_G_VERIFY,
1933 .name = "verify_backlog",
1934 .lname = "Verify backlog",
1935 .type = FIO_OPT_STR_VAL,
1936 .off1 = td_var_offset(verify_backlog),
1937 .help = "Verify after this number of blocks are written",
1940 .category = FIO_OPT_C_IO,
1941 .group = FIO_OPT_G_VERIFY,
1944 .name = "verify_backlog_batch",
1945 .lname = "Verify backlog batch",
1946 .type = FIO_OPT_INT,
1947 .off1 = td_var_offset(verify_batch),
1948 .help = "Verify this number of IO blocks",
1951 .category = FIO_OPT_C_IO,
1952 .group = FIO_OPT_G_VERIFY,
1954 #ifdef FIO_HAVE_CPU_AFFINITY
1956 .name = "verify_async_cpus",
1957 .lname = "Async verify CPUs",
1958 .type = FIO_OPT_STR,
1959 .cb = str_verify_cpus_allowed_cb,
1960 .help = "Set CPUs allowed for async verify threads",
1961 .parent = "verify_async",
1963 .category = FIO_OPT_C_IO,
1964 .group = FIO_OPT_G_VERIFY,
1967 #ifdef FIO_HAVE_TRIM
1969 .name = "trim_percentage",
1970 .lname = "Trim percentage",
1971 .type = FIO_OPT_INT,
1972 .cb = str_verify_trim_cb,
1975 .help = "Number of verify blocks to discard/trim",
1980 .category = FIO_OPT_C_IO,
1981 .group = FIO_OPT_G_TRIM,
1984 .name = "trim_verify_zero",
1985 .lname = "Verify trim zero",
1986 .type = FIO_OPT_BOOL,
1987 .help = "Verify that trim/discarded blocks are returned as zeroes",
1988 .off1 = td_var_offset(trim_zero),
1989 .parent = "trim_percentage",
1992 .category = FIO_OPT_C_IO,
1993 .group = FIO_OPT_G_TRIM,
1996 .name = "trim_backlog",
1997 .lname = "Trim backlog",
1998 .type = FIO_OPT_STR_VAL,
1999 .off1 = td_var_offset(trim_backlog),
2000 .help = "Trim after this number of blocks are written",
2001 .parent = "trim_percentage",
2004 .category = FIO_OPT_C_IO,
2005 .group = FIO_OPT_G_TRIM,
2008 .name = "trim_backlog_batch",
2009 .lname = "Trim backlog batch",
2010 .type = FIO_OPT_INT,
2011 .off1 = td_var_offset(trim_batch),
2012 .help = "Trim this number of IO blocks",
2013 .parent = "trim_percentage",
2016 .category = FIO_OPT_C_IO,
2017 .group = FIO_OPT_G_TRIM,
2021 .name = "write_iolog",
2022 .lname = "Write I/O log",
2023 .type = FIO_OPT_STR_STORE,
2024 .off1 = td_var_offset(write_iolog_file),
2025 .help = "Store IO pattern to file",
2026 .category = FIO_OPT_C_IO,
2027 .group = FIO_OPT_G_IOLOG,
2030 .name = "read_iolog",
2031 .lname = "Read I/O log",
2032 .type = FIO_OPT_STR_STORE,
2033 .off1 = td_var_offset(read_iolog_file),
2034 .help = "Playback IO pattern from file",
2035 .category = FIO_OPT_C_IO,
2036 .group = FIO_OPT_G_IOLOG,
2039 .name = "replay_no_stall",
2040 .lname = "Don't stall on replay",
2041 .type = FIO_OPT_BOOL,
2042 .off1 = td_var_offset(no_stall),
2044 .parent = "read_iolog",
2046 .help = "Playback IO pattern file as fast as possible without stalls",
2047 .category = FIO_OPT_C_IO,
2048 .group = FIO_OPT_G_IOLOG,
2051 .name = "replay_redirect",
2052 .lname = "Redirect device for replay",
2053 .type = FIO_OPT_STR_STORE,
2054 .off1 = td_var_offset(replay_redirect),
2055 .parent = "read_iolog",
2057 .help = "Replay all I/O onto this device, regardless of trace device",
2058 .category = FIO_OPT_C_IO,
2059 .group = FIO_OPT_G_IOLOG,
2062 .name = "exec_prerun",
2063 .lname = "Pre-execute runnable",
2064 .type = FIO_OPT_STR_STORE,
2065 .off1 = td_var_offset(exec_prerun),
2066 .help = "Execute this file prior to running job",
2067 .category = FIO_OPT_C_GENERAL,
2068 .group = FIO_OPT_G_INVALID,
2071 .name = "exec_postrun",
2072 .lname = "Post-execute runnable",
2073 .type = FIO_OPT_STR_STORE,
2074 .off1 = td_var_offset(exec_postrun),
2075 .help = "Execute this file after running job",
2076 .category = FIO_OPT_C_GENERAL,
2077 .group = FIO_OPT_G_INVALID,
2079 #ifdef FIO_HAVE_IOSCHED_SWITCH
2081 .name = "ioscheduler",
2082 .lname = "I/O scheduler",
2083 .type = FIO_OPT_STR_STORE,
2084 .off1 = td_var_offset(ioscheduler),
2085 .help = "Use this IO scheduler on the backing device",
2086 .category = FIO_OPT_C_FILE,
2087 .group = FIO_OPT_G_INVALID,
2092 .lname = "Zone size",
2093 .type = FIO_OPT_STR_VAL,
2094 .off1 = td_var_offset(zone_size),
2095 .help = "Amount of data to read per zone",
2097 .interval = 1024 * 1024,
2098 .category = FIO_OPT_C_IO,
2099 .group = FIO_OPT_G_ZONE,
2102 .name = "zonerange",
2103 .lname = "Zone range",
2104 .type = FIO_OPT_STR_VAL,
2105 .off1 = td_var_offset(zone_range),
2106 .help = "Give size of an IO zone",
2108 .interval = 1024 * 1024,
2109 .category = FIO_OPT_C_IO,
2110 .group = FIO_OPT_G_ZONE,
2114 .lname = "Zone skip",
2115 .type = FIO_OPT_STR_VAL,
2116 .off1 = td_var_offset(zone_skip),
2117 .help = "Space between IO zones",
2119 .interval = 1024 * 1024,
2120 .category = FIO_OPT_C_IO,
2121 .group = FIO_OPT_G_ZONE,
2125 .lname = "Lock memory",
2126 .type = FIO_OPT_STR_VAL,
2127 .cb = str_lockmem_cb,
2128 .help = "Lock down this amount of memory",
2130 .interval = 1024 * 1024,
2131 .category = FIO_OPT_C_GENERAL,
2132 .group = FIO_OPT_G_INVALID,
2135 .name = "rwmixread",
2136 .lname = "Read/write mix read",
2137 .type = FIO_OPT_INT,
2138 .cb = str_rwmix_read_cb,
2140 .help = "Percentage of mixed workload that is reads",
2143 .inverse = "rwmixwrite",
2144 .category = FIO_OPT_C_IO,
2145 .group = FIO_OPT_G_RWMIX,
2148 .name = "rwmixwrite",
2149 .lname = "Read/write mix write",
2150 .type = FIO_OPT_INT,
2151 .cb = str_rwmix_write_cb,
2153 .help = "Percentage of mixed workload that is writes",
2156 .inverse = "rwmixread",
2157 .category = FIO_OPT_C_IO,
2158 .group = FIO_OPT_G_RWMIX,
2161 .name = "rwmixcycle",
2162 .lname = "Read/write mix cycle",
2163 .type = FIO_OPT_DEPRECATED,
2164 .category = FIO_OPT_C_IO,
2165 .group = FIO_OPT_G_RWMIX,
2170 .type = FIO_OPT_INT,
2171 .off1 = td_var_offset(nice),
2172 .help = "Set job CPU nice value",
2177 .category = FIO_OPT_C_GENERAL,
2178 .group = FIO_OPT_G_CRED,
2180 #ifdef FIO_HAVE_IOPRIO
2183 .lname = "I/O nice priority",
2184 .type = FIO_OPT_INT,
2186 .help = "Set job IO priority value",
2190 .category = FIO_OPT_C_GENERAL,
2191 .group = FIO_OPT_G_CRED,
2194 .name = "prioclass",
2195 .lname = "I/O nice priority class",
2196 .type = FIO_OPT_INT,
2197 .cb = str_prioclass_cb,
2198 .help = "Set job IO priority class",
2202 .category = FIO_OPT_C_GENERAL,
2203 .group = FIO_OPT_G_CRED,
2207 .name = "thinktime",
2208 .lname = "Thinktime",
2209 .type = FIO_OPT_INT,
2210 .off1 = td_var_offset(thinktime),
2211 .help = "Idle time between IO buffers (usec)",
2213 .category = FIO_OPT_C_IO,
2214 .group = FIO_OPT_G_THINKTIME,
2217 .name = "thinktime_spin",
2218 .lname = "Thinktime spin",
2219 .type = FIO_OPT_INT,
2220 .off1 = td_var_offset(thinktime_spin),
2221 .help = "Start think time by spinning this amount (usec)",
2223 .parent = "thinktime",
2225 .category = FIO_OPT_C_IO,
2226 .group = FIO_OPT_G_THINKTIME,
2229 .name = "thinktime_blocks",
2230 .lname = "Thinktime blocks",
2231 .type = FIO_OPT_INT,
2232 .off1 = td_var_offset(thinktime_blocks),
2233 .help = "IO buffer period between 'thinktime'",
2235 .parent = "thinktime",
2237 .category = FIO_OPT_C_IO,
2238 .group = FIO_OPT_G_THINKTIME,
2242 .lname = "I/O rate",
2243 .type = FIO_OPT_INT,
2244 .off1 = td_var_offset(rate[0]),
2245 .off2 = td_var_offset(rate[1]),
2246 .help = "Set bandwidth rate",
2247 .category = FIO_OPT_C_IO,
2248 .group = FIO_OPT_G_RATE,
2252 .lname = "I/O min rate",
2253 .type = FIO_OPT_INT,
2254 .off1 = td_var_offset(ratemin[0]),
2255 .off2 = td_var_offset(ratemin[1]),
2256 .help = "Job must meet this rate or it will be shutdown",
2259 .category = FIO_OPT_C_IO,
2260 .group = FIO_OPT_G_RATE,
2263 .name = "rate_iops",
2264 .lname = "I/O rate IOPS",
2265 .type = FIO_OPT_INT,
2266 .off1 = td_var_offset(rate_iops[0]),
2267 .off2 = td_var_offset(rate_iops[1]),
2268 .help = "Limit IO used to this number of IO operations/sec",
2270 .category = FIO_OPT_C_IO,
2271 .group = FIO_OPT_G_RATE,
2274 .name = "rate_iops_min",
2275 .lname = "I/O min rate IOPS",
2276 .type = FIO_OPT_INT,
2277 .off1 = td_var_offset(rate_iops_min[0]),
2278 .off2 = td_var_offset(rate_iops_min[1]),
2279 .help = "Job must meet this rate or it will be shut down",
2280 .parent = "rate_iops",
2282 .category = FIO_OPT_C_IO,
2283 .group = FIO_OPT_G_RATE,
2286 .name = "ratecycle",
2287 .lname = "I/O rate cycle",
2288 .type = FIO_OPT_INT,
2289 .off1 = td_var_offset(ratecycle),
2290 .help = "Window average for rate limits (msec)",
2294 .category = FIO_OPT_C_IO,
2295 .group = FIO_OPT_G_RATE,
2298 .name = "invalidate",
2299 .lname = "Cache invalidate",
2300 .type = FIO_OPT_BOOL,
2301 .off1 = td_var_offset(invalidate_cache),
2302 .help = "Invalidate buffer/page cache prior to running job",
2304 .category = FIO_OPT_C_IO,
2305 .group = FIO_OPT_G_IO_TYPE,
2309 .lname = "Synchronous I/O",
2310 .type = FIO_OPT_BOOL,
2311 .off1 = td_var_offset(sync_io),
2312 .help = "Use O_SYNC for buffered writes",
2314 .parent = "buffered",
2316 .category = FIO_OPT_C_IO,
2317 .group = FIO_OPT_G_IO_TYPE,
2320 .name = "create_serialize",
2321 .lname = "Create serialize",
2322 .type = FIO_OPT_BOOL,
2323 .off1 = td_var_offset(create_serialize),
2324 .help = "Serialize creating of job files",
2326 .category = FIO_OPT_C_FILE,
2327 .group = FIO_OPT_G_INVALID,
2330 .name = "create_fsync",
2331 .lname = "Create fsync",
2332 .type = FIO_OPT_BOOL,
2333 .off1 = td_var_offset(create_fsync),
2334 .help = "fsync file after creation",
2336 .category = FIO_OPT_C_FILE,
2337 .group = FIO_OPT_G_INVALID,
2340 .name = "create_on_open",
2341 .lname = "Create on open",
2342 .type = FIO_OPT_BOOL,
2343 .off1 = td_var_offset(create_on_open),
2344 .help = "Create files when they are opened for IO",
2346 .category = FIO_OPT_C_FILE,
2347 .group = FIO_OPT_G_INVALID,
2351 .lname = "Pre-read files",
2352 .type = FIO_OPT_BOOL,
2353 .off1 = td_var_offset(pre_read),
2354 .help = "Pre-read files before starting official testing",
2356 .category = FIO_OPT_C_FILE,
2357 .group = FIO_OPT_G_INVALID,
2359 #ifdef FIO_HAVE_CPU_AFFINITY
2362 .lname = "CPU mask",
2363 .type = FIO_OPT_INT,
2364 .cb = str_cpumask_cb,
2365 .help = "CPU affinity mask",
2366 .category = FIO_OPT_C_GENERAL,
2367 .group = FIO_OPT_G_CRED,
2370 .name = "cpus_allowed",
2371 .lname = "CPUs allowed",
2372 .type = FIO_OPT_STR,
2373 .cb = str_cpus_allowed_cb,
2374 .help = "Set CPUs allowed",
2375 .category = FIO_OPT_C_GENERAL,
2376 .group = FIO_OPT_G_CRED,
2380 .name = "end_fsync",
2381 .lname = "End fsync",
2382 .type = FIO_OPT_BOOL,
2383 .off1 = td_var_offset(end_fsync),
2384 .help = "Include fsync at the end of job",
2386 .category = FIO_OPT_C_FILE,
2387 .group = FIO_OPT_G_INVALID,
2390 .name = "fsync_on_close",
2391 .lname = "Fsync on close",
2392 .type = FIO_OPT_BOOL,
2393 .off1 = td_var_offset(fsync_on_close),
2394 .help = "fsync files on close",
2396 .category = FIO_OPT_C_FILE,
2397 .group = FIO_OPT_G_INVALID,
2401 .lname = "Unlink file",
2402 .type = FIO_OPT_BOOL,
2403 .off1 = td_var_offset(unlink),
2404 .help = "Unlink created files after job has completed",
2406 .category = FIO_OPT_C_FILE,
2407 .group = FIO_OPT_G_INVALID,
2411 .lname = "Exit-all on terminate",
2412 .type = FIO_OPT_STR_SET,
2413 .cb = str_exitall_cb,
2414 .help = "Terminate all jobs when one exits",
2415 .category = FIO_OPT_C_GENERAL,
2416 .group = FIO_OPT_G_PROCESS,
2419 .name = "stonewall",
2420 .lname = "Wait for previous",
2421 .alias = "wait_for_previous",
2422 .type = FIO_OPT_STR_SET,
2423 .off1 = td_var_offset(stonewall),
2424 .help = "Insert a hard barrier between this job and previous",
2425 .category = FIO_OPT_C_GENERAL,
2426 .group = FIO_OPT_G_PROCESS,
2429 .name = "new_group",
2430 .lname = "New group",
2431 .type = FIO_OPT_STR_SET,
2432 .off1 = td_var_offset(new_group),
2433 .help = "Mark the start of a new group (for reporting)",
2434 .category = FIO_OPT_C_GENERAL,
2435 .group = FIO_OPT_G_PROCESS,
2440 .type = FIO_OPT_STR_SET,
2441 .off1 = td_var_offset(use_thread),
2442 .help = "Use threads instead of processes",
2443 .category = FIO_OPT_C_GENERAL,
2444 .group = FIO_OPT_G_PROCESS,
2447 .name = "write_bw_log",
2448 .lname = "Write bandwidth log",
2449 .type = FIO_OPT_STR,
2450 .off1 = td_var_offset(write_bw_log),
2451 .cb = str_write_bw_log_cb,
2452 .help = "Write log of bandwidth during run",
2453 .category = FIO_OPT_C_LOG,
2454 .group = FIO_OPT_G_INVALID,
2457 .name = "write_lat_log",
2458 .lname = "Write latency log",
2459 .type = FIO_OPT_STR,
2460 .off1 = td_var_offset(write_lat_log),
2461 .cb = str_write_lat_log_cb,
2462 .help = "Write log of latency during run",
2463 .category = FIO_OPT_C_LOG,
2464 .group = FIO_OPT_G_INVALID,
2467 .name = "write_iops_log",
2468 .lname = "Write IOPS log",
2469 .type = FIO_OPT_STR,
2470 .off1 = td_var_offset(write_iops_log),
2471 .cb = str_write_iops_log_cb,
2472 .help = "Write log of IOPS during run",
2473 .category = FIO_OPT_C_LOG,
2474 .group = FIO_OPT_G_INVALID,
2477 .name = "log_avg_msec",
2478 .lname = "Log averaging (msec)",
2479 .type = FIO_OPT_INT,
2480 .off1 = td_var_offset(log_avg_msec),
2481 .help = "Average bw/iops/lat logs over this period of time",
2483 .category = FIO_OPT_C_LOG,
2484 .group = FIO_OPT_G_INVALID,
2487 .name = "bwavgtime",
2488 .lname = "Bandwidth average time",
2489 .type = FIO_OPT_INT,
2490 .off1 = td_var_offset(bw_avg_time),
2491 .help = "Time window over which to calculate bandwidth"
2494 .parent = "write_bw_log",
2497 .category = FIO_OPT_C_LOG,
2498 .group = FIO_OPT_G_INVALID,
2501 .name = "iopsavgtime",
2502 .lname = "IOPS average time",
2503 .type = FIO_OPT_INT,
2504 .off1 = td_var_offset(iops_avg_time),
2505 .help = "Time window over which to calculate IOPS (msec)",
2507 .parent = "write_iops_log",
2510 .category = FIO_OPT_C_LOG,
2511 .group = FIO_OPT_G_INVALID,
2514 .name = "group_reporting",
2515 .lname = "Group reporting",
2516 .type = FIO_OPT_BOOL,
2517 .off1 = td_var_offset(group_reporting),
2518 .help = "Do reporting on a per-group basis",
2520 .category = FIO_OPT_C_STAT,
2521 .group = FIO_OPT_G_INVALID,
2524 .name = "zero_buffers",
2525 .lname = "Zero I/O buffers",
2526 .type = FIO_OPT_STR_SET,
2527 .off1 = td_var_offset(zero_buffers),
2528 .help = "Init IO buffers to all zeroes",
2529 .category = FIO_OPT_C_IO,
2530 .group = FIO_OPT_G_IO_BUF,
2533 .name = "refill_buffers",
2534 .lname = "Refill I/O buffers",
2535 .type = FIO_OPT_STR_SET,
2536 .off1 = td_var_offset(refill_buffers),
2537 .help = "Refill IO buffers on every IO submit",
2538 .category = FIO_OPT_C_IO,
2539 .group = FIO_OPT_G_IO_BUF,
2542 .name = "scramble_buffers",
2543 .lname = "Scramble I/O buffers",
2544 .type = FIO_OPT_BOOL,
2545 .off1 = td_var_offset(scramble_buffers),
2546 .help = "Slightly scramble buffers on every IO submit",
2548 .category = FIO_OPT_C_IO,
2549 .group = FIO_OPT_G_IO_BUF,
2552 .name = "buffer_compress_percentage",
2553 .lname = "Buffer compression percentage",
2554 .type = FIO_OPT_INT,
2555 .off1 = td_var_offset(compress_percentage),
2558 .help = "How compressible the buffer is (approximately)",
2560 .category = FIO_OPT_C_IO,
2561 .group = FIO_OPT_G_IO_BUF,
2564 .name = "buffer_compress_chunk",
2565 .lname = "Buffer compression chunk size",
2566 .type = FIO_OPT_INT,
2567 .off1 = td_var_offset(compress_chunk),
2568 .parent = "buffer_compress_percentage",
2570 .help = "Size of compressible region in buffer",
2572 .category = FIO_OPT_C_IO,
2573 .group = FIO_OPT_G_IO_BUF,
2576 .name = "clat_percentiles",
2577 .lname = "Completion latency percentiles",
2578 .type = FIO_OPT_BOOL,
2579 .off1 = td_var_offset(clat_percentiles),
2580 .help = "Enable the reporting of completion latency percentiles",
2582 .category = FIO_OPT_C_STAT,
2583 .group = FIO_OPT_G_INVALID,
2586 .name = "percentile_list",
2587 .lname = "Completion latency percentile list",
2588 .type = FIO_OPT_FLOAT_LIST,
2589 .off1 = td_var_offset(percentile_list),
2590 .off2 = td_var_offset(overwrite_plist),
2591 .help = "Specify a custom list of percentiles to report",
2592 .maxlen = FIO_IO_U_LIST_MAX_LEN,
2595 .category = FIO_OPT_C_STAT,
2596 .group = FIO_OPT_G_INVALID,
2599 #ifdef FIO_HAVE_DISK_UTIL
2601 .name = "disk_util",
2602 .lname = "Disk utilization",
2603 .type = FIO_OPT_BOOL,
2604 .off1 = td_var_offset(do_disk_util),
2605 .help = "Log disk utilization statistics",
2607 .category = FIO_OPT_C_STAT,
2608 .group = FIO_OPT_G_INVALID,
2612 .name = "gtod_reduce",
2613 .lname = "Reduce gettimeofday() calls",
2614 .type = FIO_OPT_BOOL,
2615 .help = "Greatly reduce number of gettimeofday() calls",
2616 .cb = str_gtod_reduce_cb,
2619 .category = FIO_OPT_C_STAT,
2620 .group = FIO_OPT_G_INVALID,
2623 .name = "disable_lat",
2624 .lname = "Disable all latency stats",
2625 .type = FIO_OPT_BOOL,
2626 .off1 = td_var_offset(disable_lat),
2627 .help = "Disable latency numbers",
2628 .parent = "gtod_reduce",
2631 .category = FIO_OPT_C_STAT,
2632 .group = FIO_OPT_G_INVALID,
2635 .name = "disable_clat",
2636 .lname = "Disable completion latency stats",
2637 .type = FIO_OPT_BOOL,
2638 .off1 = td_var_offset(disable_clat),
2639 .help = "Disable completion latency numbers",
2640 .parent = "gtod_reduce",
2643 .category = FIO_OPT_C_STAT,
2644 .group = FIO_OPT_G_INVALID,
2647 .name = "disable_slat",
2648 .lname = "Disable submission latency stats",
2649 .type = FIO_OPT_BOOL,
2650 .off1 = td_var_offset(disable_slat),
2651 .help = "Disable submission latency numbers",
2652 .parent = "gtod_reduce",
2655 .category = FIO_OPT_C_STAT,
2656 .group = FIO_OPT_G_INVALID,
2659 .name = "disable_bw_measurement",
2660 .lname = "Disable bandwidth stats",
2661 .type = FIO_OPT_BOOL,
2662 .off1 = td_var_offset(disable_bw),
2663 .help = "Disable bandwidth logging",
2664 .parent = "gtod_reduce",
2667 .category = FIO_OPT_C_STAT,
2668 .group = FIO_OPT_G_INVALID,
2672 .lname = "Dedicated gettimeofday() CPU",
2673 .type = FIO_OPT_INT,
2674 .cb = str_gtod_cpu_cb,
2675 .help = "Set up dedicated gettimeofday() thread on this CPU",
2676 .verify = gtod_cpu_verify,
2677 .category = FIO_OPT_C_GENERAL,
2678 .group = FIO_OPT_G_CLOCK,
2681 .name = "continue_on_error",
2682 .lname = "Continue on error",
2683 .type = FIO_OPT_STR,
2684 .off1 = td_var_offset(continue_on_error),
2685 .help = "Continue on non-fatal errors during IO",
2687 .category = FIO_OPT_C_GENERAL,
2688 .group = FIO_OPT_G_INVALID,
2691 .oval = ERROR_TYPE_NONE,
2692 .help = "Exit when an error is encountered",
2695 .oval = ERROR_TYPE_READ,
2696 .help = "Continue on read errors only",
2699 .oval = ERROR_TYPE_WRITE,
2700 .help = "Continue on write errors only",
2703 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
2704 .help = "Continue on any IO errors",
2707 .oval = ERROR_TYPE_VERIFY,
2708 .help = "Continue on verify errors only",
2711 .oval = ERROR_TYPE_ANY,
2712 .help = "Continue on all io and verify errors",
2715 .oval = ERROR_TYPE_NONE,
2716 .help = "Alias for 'none'",
2719 .oval = ERROR_TYPE_ANY,
2720 .help = "Alias for 'all'",
2727 .type = FIO_OPT_STR_STORE,
2728 .off1 = td_var_offset(profile),
2729 .help = "Select a specific builtin performance test",
2730 .category = FIO_OPT_C_GENERAL,
2731 .group = FIO_OPT_G_INVALID,
2736 .type = FIO_OPT_STR_STORE,
2737 .off1 = td_var_offset(cgroup),
2738 .help = "Add job to cgroup of this name",
2739 .category = FIO_OPT_C_GENERAL,
2740 .group = FIO_OPT_G_CGROUP,
2743 .name = "cgroup_nodelete",
2744 .lname = "Cgroup no-delete",
2745 .type = FIO_OPT_BOOL,
2746 .off1 = td_var_offset(cgroup_nodelete),
2747 .help = "Do not delete cgroups after job completion",
2750 .category = FIO_OPT_C_GENERAL,
2751 .group = FIO_OPT_G_CGROUP,
2754 .name = "cgroup_weight",
2755 .lname = "Cgroup weight",
2756 .type = FIO_OPT_INT,
2757 .off1 = td_var_offset(cgroup_weight),
2758 .help = "Use given weight for cgroup",
2762 .category = FIO_OPT_C_GENERAL,
2763 .group = FIO_OPT_G_CGROUP,
2768 .type = FIO_OPT_INT,
2769 .off1 = td_var_offset(uid),
2770 .help = "Run job with this user ID",
2771 .category = FIO_OPT_C_GENERAL,
2772 .group = FIO_OPT_G_CRED,
2776 .lname = "Group ID",
2777 .type = FIO_OPT_INT,
2778 .off1 = td_var_offset(gid),
2779 .help = "Run job with this group ID",
2780 .category = FIO_OPT_C_GENERAL,
2781 .group = FIO_OPT_G_CRED,
2786 .type = FIO_OPT_INT,
2787 .off1 = td_var_offset(kb_base),
2788 .verify = kb_base_verify,
2791 .help = "How many bytes per KB for reporting (1000 or 1024)",
2792 .category = FIO_OPT_C_GENERAL,
2793 .group = FIO_OPT_G_INVALID,
2796 .name = "hugepage-size",
2797 .lname = "Hugepage size",
2798 .type = FIO_OPT_INT,
2799 .off1 = td_var_offset(hugepage_size),
2800 .help = "When using hugepages, specify size of each page",
2801 .def = __fio_stringify(FIO_HUGE_PAGE),
2802 .interval = 1024 * 1024,
2803 .category = FIO_OPT_C_GENERAL,
2804 .group = FIO_OPT_G_INVALID,
2808 .lname = "I/O flow ID",
2809 .type = FIO_OPT_INT,
2810 .off1 = td_var_offset(flow_id),
2811 .help = "The flow index ID to use",
2813 .category = FIO_OPT_C_IO,
2814 .group = FIO_OPT_G_IO_FLOW,
2818 .lname = "I/O flow weight",
2819 .type = FIO_OPT_INT,
2820 .off1 = td_var_offset(flow),
2821 .help = "Weight for flow control of this job",
2822 .parent = "flow_id",
2825 .category = FIO_OPT_C_IO,
2826 .group = FIO_OPT_G_IO_FLOW,
2829 .name = "flow_watermark",
2830 .lname = "I/O flow watermark",
2831 .type = FIO_OPT_INT,
2832 .off1 = td_var_offset(flow_watermark),
2833 .help = "High watermark for flow control. This option"
2834 " should be set to the same value for all threads"
2835 " with non-zero flow.",
2836 .parent = "flow_id",
2839 .category = FIO_OPT_C_IO,
2840 .group = FIO_OPT_G_IO_FLOW,
2843 .name = "flow_sleep",
2844 .lname = "I/O flow sleep",
2845 .type = FIO_OPT_INT,
2846 .off1 = td_var_offset(flow_sleep),
2847 .help = "How many microseconds to sleep after being held"
2848 " back by the flow control mechanism",
2849 .parent = "flow_id",
2852 .category = FIO_OPT_C_IO,
2853 .group = FIO_OPT_G_IO_FLOW,
2860 static void add_to_lopt(struct option *lopt, struct fio_option *o,
2861 const char *name, int val)
2863 lopt->name = (char *) name;
2865 if (o->type == FIO_OPT_STR_SET)
2866 lopt->has_arg = no_argument;
2868 lopt->has_arg = required_argument;
2871 static void options_to_lopts(struct fio_option *opts,
2872 struct option *long_options,
2873 int i, int option_type)
2875 struct fio_option *o = &opts[0];
2877 add_to_lopt(&long_options[i], o, o->name, option_type);
2880 add_to_lopt(&long_options[i], o, o->alias, option_type);
2885 assert(i < FIO_NR_OPTIONS);
2889 void fio_options_set_ioengine_opts(struct option *long_options,
2890 struct thread_data *td)
2895 while (long_options[i].name) {
2896 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
2897 memset(&long_options[i], 0, sizeof(*long_options));
2904 * Just clear out the prior ioengine options.
2909 options_to_lopts(td->io_ops->options, long_options, i,
2910 FIO_GETOPT_IOENGINE);
2913 void fio_options_dup_and_init(struct option *long_options)
2917 options_init(fio_options);
2920 while (long_options[i].name)
2923 options_to_lopts(fio_options, long_options, i, FIO_GETOPT_JOB);
2926 struct fio_keyword {
2932 static struct fio_keyword fio_keywords[] = {
2934 .word = "$pagesize",
2935 .desc = "Page size in the system",
2938 .word = "$mb_memory",
2939 .desc = "Megabytes of memory online",
2943 .desc = "Number of CPUs online in the system",
2950 void fio_keywords_init(void)
2952 unsigned long long mb_memory;
2956 sprintf(buf, "%lu", page_size);
2957 fio_keywords[0].replace = strdup(buf);
2959 mb_memory = os_phys_mem() / (1024 * 1024);
2960 sprintf(buf, "%llu", mb_memory);
2961 fio_keywords[1].replace = strdup(buf);
2964 sprintf(buf, "%lu", l);
2965 fio_keywords[2].replace = strdup(buf);
2970 static char *bc_calc(char *str)
2972 char buf[128], *tmp;
2977 * No math, just return string
2979 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
2980 !strchr(str, '/')) || strchr(str, '\''))
2984 * Split option from value, we only need to calculate the value
2986 tmp = strchr(str, '=');
2993 * Prevent buffer overflows; such a case isn't reasonable anyway
2995 if (strlen(str) >= 128 || strlen(tmp) > 100)
2998 sprintf(buf, "which %s > /dev/null", BC_APP);
3000 log_err("fio: bc is needed for performing math\n");
3004 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
3005 f = popen(buf, "r");
3009 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
3014 buf[(tmp - str) + ret - 1] = '\0';
3015 memcpy(buf, str, tmp - str);
3021 * Return a copy of the input string with substrings of the form ${VARNAME}
3022 * substituted with the value of the environment variable VARNAME. The
3023 * substitution always occurs, even if VARNAME is empty or the corresponding
3024 * environment variable undefined.
3026 static char *option_dup_subs(const char *opt)
3028 char out[OPT_LEN_MAX+1];
3029 char in[OPT_LEN_MAX+1];
3032 char *ch1, *ch2, *env;
3033 ssize_t nchr = OPT_LEN_MAX;
3036 if (strlen(opt) + 1 > OPT_LEN_MAX) {
3037 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
3041 in[OPT_LEN_MAX] = '\0';
3042 strncpy(in, opt, OPT_LEN_MAX);
3044 while (*inptr && nchr > 0) {
3045 if (inptr[0] == '$' && inptr[1] == '{') {
3046 ch2 = strchr(inptr, '}');
3047 if (ch2 && inptr+1 < ch2) {
3054 envlen = strlen(env);
3055 if (envlen <= nchr) {
3056 memcpy(outptr, env, envlen);
3066 *outptr++ = *inptr++;
3075 * Look for reserved variable names and replace them with real values
3077 static char *fio_keyword_replace(char *opt)
3083 for (i = 0; fio_keywords[i].word != NULL; i++) {
3084 struct fio_keyword *kw = &fio_keywords[i];
3086 while ((s = strstr(opt, kw->word)) != NULL) {
3087 char *new = malloc(strlen(opt) + 1);
3093 * Copy part of the string before the keyword and
3094 * sprintf() the replacement after it.
3096 memcpy(new, opt, olen);
3097 len = sprintf(new + olen, "%s", kw->replace);
3100 * If there's more in the original string, copy that
3103 opt += strlen(kw->word) + olen;
3105 memcpy(new + olen + len, opt, opt - o_org - 1);
3108 * replace opt and free the old opt
3118 * Check for potential math and invoke bc, if possible
3126 static char **dup_and_sub_options(char **opts, int num_opts)
3129 char **opts_copy = malloc(num_opts * sizeof(*opts));
3130 for (i = 0; i < num_opts; i++) {
3131 opts_copy[i] = option_dup_subs(opts[i]);
3134 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
3139 int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
3141 int i, ret, unknown;
3144 sort_options(opts, fio_options, num_opts);
3145 opts_copy = dup_and_sub_options(opts, num_opts);
3147 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
3148 struct fio_option *o;
3149 int newret = parse_option(opts_copy[i], opts[i], fio_options,
3158 opts_copy[i] = NULL;
3165 ret |= ioengine_load(td);
3167 sort_options(opts_copy, td->io_ops->options, num_opts);
3170 for (i = 0; i < num_opts; i++) {
3171 struct fio_option *o = NULL;
3177 newret = parse_option(opts_copy[i], opts[i],
3178 td->io_ops->options, &o,
3183 log_err("Bad option <%s>\n", opts[i]);
3186 opts_copy[i] = NULL;
3194 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
3196 return parse_cmd_option(opt, val, fio_options, td);
3199 int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
3202 return parse_cmd_option(opt, val, td->io_ops->options, td);
3205 void fio_fill_default_options(struct thread_data *td)
3207 fill_default_options(td, fio_options);
3210 int fio_show_option_help(const char *opt)
3212 return show_cmd_help(fio_options, opt);
3215 void options_mem_dupe(void *data, struct fio_option *options)
3217 struct fio_option *o;
3220 for (o = &options[0]; o->name; o++) {
3221 if (o->type != FIO_OPT_STR_STORE)
3224 ptr = td_var(data, o->off1);
3226 *ptr = strdup(*ptr);
3231 * dupe FIO_OPT_STR_STORE options
3233 void fio_options_mem_dupe(struct thread_data *td)
3235 options_mem_dupe(&td->o, fio_options);
3237 if (td->eo && td->io_ops) {
3238 void *oldeo = td->eo;
3240 td->eo = malloc(td->io_ops->option_struct_size);
3241 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
3242 options_mem_dupe(td->eo, td->io_ops->options);
3246 unsigned int fio_get_kb_base(void *data)
3248 struct thread_options *o = data;
3249 unsigned int kb_base = 0;
3252 kb_base = o->kb_base;
3259 int add_option(struct fio_option *o)
3261 struct fio_option *__o;
3270 memcpy(&fio_options[opt_index], o, sizeof(*o));
3274 void invalidate_profile_options(const char *prof_name)
3276 struct fio_option *o;
3280 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
3281 o->type = FIO_OPT_INVALID;
3282 o->prof_name = NULL;
3288 void add_opt_posval(const char *optname, const char *ival, const char *help)
3290 struct fio_option *o;
3293 o = find_option(fio_options, optname);
3297 for (i = 0; i < PARSE_MAX_VP; i++) {
3298 if (o->posval[i].ival)
3301 o->posval[i].ival = ival;
3302 o->posval[i].help = help;
3307 void del_opt_posval(const char *optname, const char *ival)
3309 struct fio_option *o;
3312 o = find_option(fio_options, optname);
3316 for (i = 0; i < PARSE_MAX_VP; i++) {
3317 if (!o->posval[i].ival)
3319 if (strcmp(o->posval[i].ival, ival))
3322 o->posval[i].ival = NULL;
3323 o->posval[i].help = NULL;
3327 void fio_options_free(struct thread_data *td)
3329 options_free(fio_options, td);
3330 if (td->eo && td->io_ops && td->io_ops->options) {
3331 options_free(td->io_ops->options, td->eo);
3337 struct fio_option *fio_option_find(const char *name)
3339 return find_option(fio_options, name);