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_data *td, int ddir, char *str)
66 struct bssplit *bssplit;
67 unsigned int i, perc, perc_missing;
68 unsigned int max_bs, min_bs;
72 td->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 == td->o.bssplit_nr[ddir]) {
88 td->o.bssplit_nr[ddir] <<= 1;
89 bssplit = realloc(bssplit, td->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, td)) {
106 log_err("fio: bssplit conversion failed\n");
117 bssplit[i].perc = perc;
121 td->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 < td->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 < td->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 td->o.min_bs[ddir] = min_bs;
155 td->o.max_bs[ddir] = max_bs;
158 * now sort based on percentages, for ease of lookup
160 qsort(bssplit, td->o.bssplit_nr[ddir], sizeof(struct bssplit), bs_cmp);
161 td->o.bssplit[ddir] = bssplit;
166 static int str_bssplit_cb(void *data, const char *input)
168 struct thread_data *td = data;
169 char *str, *p, *odir, *ddir;
172 p = str = strdup(input);
174 strip_blank_front(&str);
175 strip_blank_end(str);
177 odir = strchr(str, ',');
179 ddir = strchr(odir + 1, ',');
181 ret = bssplit_ddir(td, DDIR_TRIM, ddir + 1);
187 op = strdup(odir + 1);
188 ret = bssplit_ddir(td, DDIR_TRIM, op);
193 ret = bssplit_ddir(td, DDIR_WRITE, odir + 1);
196 ret = bssplit_ddir(td, DDIR_READ, str);
202 ret = bssplit_ddir(td, DDIR_WRITE, op);
207 ret = bssplit_ddir(td, DDIR_TRIM, op);
210 ret = bssplit_ddir(td, DDIR_READ, str);
217 static int str2error(char *str)
219 const char * err[] = {"EPERM", "ENOENT", "ESRCH", "EINTR", "EIO",
220 "ENXIO", "E2BIG", "ENOEXEC", "EBADF",
221 "ECHILD", "EAGAIN", "ENOMEM", "EACCES",
222 "EFAULT", "ENOTBLK", "EBUSY", "EEXIST",
223 "EXDEV", "ENODEV", "ENOTDIR", "EISDIR",
224 "EINVAL", "ENFILE", "EMFILE", "ENOTTY",
225 "ETXTBSY","EFBIG", "ENOSPC", "ESPIPE",
226 "EROFS","EMLINK", "EPIPE", "EDOM", "ERANGE"};
227 int i = 0, num = sizeof(err) / sizeof(void *);
230 if (!strcmp(err[i], str))
237 static int ignore_error_type(struct thread_data *td, int etype, char *str)
243 if (etype >= ERROR_TYPE_CNT) {
244 log_err("Illegal error type\n");
248 td->o.ignore_error_nr[etype] = 4;
249 error = malloc(4 * sizeof(struct bssplit));
252 while ((fname = strsep(&str, ":")) != NULL) {
258 * grow struct buffer, if needed
260 if (i == td->o.ignore_error_nr[etype]) {
261 td->o.ignore_error_nr[etype] <<= 1;
262 error = realloc(error, td->o.ignore_error_nr[etype]
265 if (fname[0] == 'E') {
266 error[i] = str2error(fname);
268 error[i] = atoi(fname);
273 log_err("Unknown error %s, please use number value \n",
280 td->o.continue_on_error |= 1 << etype;
281 td->o.ignore_error_nr[etype] = i;
282 td->o.ignore_error[etype] = error;
288 static int str_ignore_error_cb(void *data, const char *input)
290 struct thread_data *td = data;
292 int type = 0, ret = 1;
293 p = str = strdup(input);
295 strip_blank_front(&str);
296 strip_blank_end(str);
302 ret = ignore_error_type(td, type, p);
312 static int str_rw_cb(void *data, const char *str)
314 struct thread_data *td = data;
315 char *nr = get_opt_postfix(str);
317 td->o.ddir_seq_nr = 1;
318 td->o.ddir_seq_add = 0;
324 td->o.ddir_seq_nr = atoi(nr);
328 if (str_to_decimal(nr, &val, 1, td)) {
329 log_err("fio: rw postfix parsing failed\n");
334 td->o.ddir_seq_add = val;
341 static int str_mem_cb(void *data, const char *mem)
343 struct thread_data *td = data;
345 if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP) {
346 td->mmapfile = get_opt_postfix(mem);
347 if (td->o.mem_type == MEM_MMAPHUGE && !td->mmapfile) {
348 log_err("fio: mmaphuge:/path/to/file\n");
356 static int str_verify_cb(void *data, const char *mem)
358 struct thread_data *td = data;
360 if (td->o.verify == VERIFY_CRC32C_INTEL ||
361 td->o.verify == VERIFY_CRC32C) {
362 crc32c_intel_probe();
368 static int fio_clock_source_cb(void *data, const char *str)
370 struct thread_data *td = data;
372 fio_clock_source = td->o.clocksource;
377 static int str_lockmem_cb(void fio_unused *data, unsigned long long *val)
383 static int str_rwmix_read_cb(void *data, unsigned long long *val)
385 struct thread_data *td = data;
387 td->o.rwmix[DDIR_READ] = *val;
388 td->o.rwmix[DDIR_WRITE] = 100 - *val;
392 static int str_rwmix_write_cb(void *data, unsigned long long *val)
394 struct thread_data *td = data;
396 td->o.rwmix[DDIR_WRITE] = *val;
397 td->o.rwmix[DDIR_READ] = 100 - *val;
401 #ifdef FIO_HAVE_IOPRIO
402 static int str_prioclass_cb(void *data, unsigned long long *val)
404 struct thread_data *td = data;
408 * mask off old class bits, str_prio_cb() may have set a default class
410 mask = (1 << IOPRIO_CLASS_SHIFT) - 1;
413 td->ioprio |= *val << IOPRIO_CLASS_SHIFT;
418 static int str_prio_cb(void *data, unsigned long long *val)
420 struct thread_data *td = data;
425 * If no class is set, assume BE
427 if ((td->ioprio >> IOPRIO_CLASS_SHIFT) == 0)
428 td->ioprio |= IOPRIO_CLASS_BE << IOPRIO_CLASS_SHIFT;
435 static int str_exitall_cb(void)
437 exitall_on_terminate = 1;
441 #ifdef FIO_HAVE_CPU_AFFINITY
442 static int str_cpumask_cb(void *data, unsigned long long *val)
444 struct thread_data *td = data;
449 ret = fio_cpuset_init(&td->o.cpumask);
451 log_err("fio: cpuset_init failed\n");
452 td_verror(td, ret, "fio_cpuset_init");
456 max_cpu = cpus_online();
458 for (i = 0; i < sizeof(int) * 8; i++) {
459 if ((1 << i) & *val) {
461 log_err("fio: CPU %d too large (max=%ld)\n", i,
465 dprint(FD_PARSE, "set cpu allowed %d\n", i);
466 fio_cpu_set(&td->o.cpumask, i);
470 td->o.cpumask_set = 1;
474 static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask,
481 ret = fio_cpuset_init(mask);
483 log_err("fio: cpuset_init failed\n");
484 td_verror(td, ret, "fio_cpuset_init");
488 p = str = strdup(input);
490 strip_blank_front(&str);
491 strip_blank_end(str);
493 max_cpu = cpus_online();
495 while ((cpu = strsep(&str, ",")) != NULL) {
504 while ((cpu2 = strsep(&str2, "-")) != NULL) {
514 while (icpu <= icpu2) {
515 if (icpu >= FIO_MAX_CPUS) {
516 log_err("fio: your OS only supports up to"
517 " %d CPUs\n", (int) FIO_MAX_CPUS);
521 if (icpu > max_cpu) {
522 log_err("fio: CPU %d too large (max=%ld)\n",
528 dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
529 fio_cpu_set(mask, icpu);
538 td->o.cpumask_set = 1;
542 static int str_cpus_allowed_cb(void *data, const char *input)
544 struct thread_data *td = data;
547 ret = set_cpus_allowed(td, &td->o.cpumask, input);
549 td->o.cpumask_set = 1;
554 static int str_verify_cpus_allowed_cb(void *data, const char *input)
556 struct thread_data *td = data;
559 ret = set_cpus_allowed(td, &td->o.verify_cpumask, input);
561 td->o.verify_cpumask_set = 1;
568 static int str_verify_trim_cb(void *data, unsigned long long *val)
570 struct thread_data *td = data;
572 td->o.trim_percentage = *val;
577 static int str_fst_cb(void *data, const char *str)
579 struct thread_data *td = data;
580 char *nr = get_opt_postfix(str);
582 td->file_service_nr = 1;
584 td->file_service_nr = atoi(nr);
591 #ifdef FIO_HAVE_SYNC_FILE_RANGE
592 static int str_sfr_cb(void *data, const char *str)
594 struct thread_data *td = data;
595 char *nr = get_opt_postfix(str);
597 td->sync_file_range_nr = 1;
599 td->sync_file_range_nr = atoi(nr);
607 static int check_dir(struct thread_data *td, char *fname)
610 char file[PATH_MAX], *dir;
613 if (td->o.directory) {
614 strcpy(file, td->o.directory);
619 sprintf(file + elen, "%s", fname);
625 * We can't do this on FIO_DISKLESSIO engines. The engine isn't loaded
626 * yet, so we can't do this check right here...
628 if (lstat(dir, &sb) < 0) {
631 log_err("fio: %s is not a directory\n", dir);
632 td_verror(td, ret, "lstat");
636 if (!S_ISDIR(sb.st_mode)) {
637 log_err("fio: %s is not a directory\n", dir);
647 * Return next file in the string. Files are separated with ':'. If the ':'
648 * is escaped with a '\', then that ':' is part of the filename and does not
649 * indicate a new file.
651 static char *get_next_file_name(char **ptr)
656 if (!str || !strlen(str))
662 * No colon, we are done
664 p = strchr(str, ':');
671 * We got a colon, but it's the first character. Skip and
679 if (*(p - 1) != '\\') {
685 memmove(p - 1, p, strlen(p) + 1);
692 static int str_filename_cb(void *data, const char *input)
694 struct thread_data *td = data;
695 char *fname, *str, *p;
697 p = str = strdup(input);
699 strip_blank_front(&str);
700 strip_blank_end(str);
702 if (!td->files_index)
705 while ((fname = get_next_file_name(&str)) != NULL) {
708 if (check_dir(td, fname)) {
720 static int str_directory_cb(void *data, const char fio_unused *str)
722 struct thread_data *td = data;
725 if (lstat(td->o.directory, &sb) < 0) {
728 log_err("fio: %s is not a directory\n", td->o.directory);
729 td_verror(td, ret, "lstat");
732 if (!S_ISDIR(sb.st_mode)) {
733 log_err("fio: %s is not a directory\n", td->o.directory);
740 static int str_opendir_cb(void *data, const char fio_unused *str)
742 struct thread_data *td = data;
744 if (!td->files_index)
747 return add_dir_files(td, td->o.opendir);
750 static int str_verify_offset_cb(void *data, unsigned long long *off)
752 struct thread_data *td = data;
754 if (*off && *off < sizeof(struct verify_header)) {
755 log_err("fio: verify_offset too small\n");
759 td->o.verify_offset = *off;
763 static int str_verify_pattern_cb(void *data, const char *input)
765 struct thread_data *td = data;
767 int i = 0, j = 0, len, k, base = 10;
770 loc1 = strstr(input, "0x");
771 loc2 = strstr(input, "0X");
774 off = strtol(input, NULL, base);
775 if (off != LONG_MAX || errno != ERANGE) {
777 td->o.verify_pattern[i] = off & 0xff;
786 j = loc1 - input + 2;
788 j = loc2 - input + 2;
791 if (len - j < MAX_PATTERN_SIZE * 2) {
793 off = converthexchartoint(input[k--]);
795 off += (converthexchartoint(input[k--])
797 td->o.verify_pattern[i++] = (char) off;
803 * Fill the pattern all the way to the end. This greatly reduces
804 * the number of memcpy's we have to do when verifying the IO.
806 while (i > 1 && i * 2 <= MAX_PATTERN_SIZE) {
807 memcpy(&td->o.verify_pattern[i], &td->o.verify_pattern[0], i);
812 * The code in verify_io_u_pattern assumes a single byte pattern
813 * fills the whole verify pattern buffer.
815 memset(td->o.verify_pattern, td->o.verify_pattern[0],
819 td->o.verify_pattern_bytes = i;
822 * VERIFY_META could already be set
824 if (td->o.verify == VERIFY_NONE)
825 td->o.verify = VERIFY_PATTERN;
830 static int str_lockfile_cb(void *data, const char *str)
832 struct thread_data *td = data;
833 char *nr = get_opt_postfix(str);
835 td->o.lockfile_batch = 1;
837 td->o.lockfile_batch = atoi(nr);
844 static int str_write_bw_log_cb(void *data, const char *str)
846 struct thread_data *td = data;
849 td->o.bw_log_file = strdup(str);
851 td->o.write_bw_log = 1;
855 static int str_write_lat_log_cb(void *data, const char *str)
857 struct thread_data *td = data;
860 td->o.lat_log_file = strdup(str);
862 td->o.write_lat_log = 1;
866 static int str_write_iops_log_cb(void *data, const char *str)
868 struct thread_data *td = data;
871 td->o.iops_log_file = strdup(str);
873 td->o.write_iops_log = 1;
877 static int str_gtod_reduce_cb(void *data, int *il)
879 struct thread_data *td = data;
882 td->o.disable_lat = !!val;
883 td->o.disable_clat = !!val;
884 td->o.disable_slat = !!val;
885 td->o.disable_bw = !!val;
886 td->o.clat_percentiles = !val;
888 td->tv_cache_mask = 63;
893 static int str_gtod_cpu_cb(void *data, long long *il)
895 struct thread_data *td = data;
898 td->o.gtod_cpu = val;
899 td->o.gtod_offload = 1;
903 static int str_size_cb(void *data, unsigned long long *__val)
905 struct thread_data *td = data;
906 unsigned long long v = *__val;
908 if (parse_is_percent(v)) {
910 td->o.size_percent = -1ULL - v;
917 static int rw_verify(struct fio_option *o, void *data)
919 struct thread_data *td = data;
921 if (read_only && td_write(td)) {
922 log_err("fio: job <%s> has write bit set, but fio is in"
923 " read-only mode\n", td->o.name);
930 static int gtod_cpu_verify(struct fio_option *o, void *data)
932 #ifndef FIO_HAVE_CPU_AFFINITY
933 struct thread_data *td = data;
935 if (td->o.gtod_cpu) {
936 log_err("fio: platform must support CPU affinity for"
937 "gettimeofday() offloading\n");
945 static int kb_base_verify(struct fio_option *o, void *data)
947 struct thread_data *td = data;
949 if (td->o.kb_base != 1024 && td->o.kb_base != 1000) {
950 log_err("fio: kb_base set to nonsensical value: %u\n",
959 * Map of job/command line options
961 static struct fio_option options[FIO_MAX_OPTS] = {
963 .name = "description",
964 .type = FIO_OPT_STR_STORE,
965 .off1 = td_var_offset(description),
966 .help = "Text job description",
970 .type = FIO_OPT_STR_STORE,
971 .off1 = td_var_offset(name),
972 .help = "Name of this job",
976 .type = FIO_OPT_STR_STORE,
977 .off1 = td_var_offset(directory),
978 .cb = str_directory_cb,
979 .help = "Directory to store files in",
983 .type = FIO_OPT_STR_STORE,
984 .off1 = td_var_offset(filename),
985 .cb = str_filename_cb,
986 .prio = -1, /* must come after "directory" */
987 .help = "File(s) to use for the workload",
992 .off1 = td_var_offset(kb_base),
993 .verify = kb_base_verify,
996 .help = "How many bytes per KB for reporting (1000 or 1024)",
1000 .type = FIO_OPT_STR,
1001 .cb = str_lockfile_cb,
1002 .off1 = td_var_offset(file_lock_mode),
1003 .help = "Lock file when doing IO to it",
1004 .parent = "filename",
1008 .oval = FILE_LOCK_NONE,
1009 .help = "No file locking",
1011 { .ival = "exclusive",
1012 .oval = FILE_LOCK_EXCLUSIVE,
1013 .help = "Exclusive file lock",
1016 .ival = "readwrite",
1017 .oval = FILE_LOCK_READWRITE,
1018 .help = "Read vs write lock",
1024 .type = FIO_OPT_STR_STORE,
1025 .off1 = td_var_offset(opendir),
1026 .cb = str_opendir_cb,
1027 .help = "Recursively add files from this directory and down",
1031 .alias = "readwrite",
1032 .type = FIO_OPT_STR,
1034 .off1 = td_var_offset(td_ddir),
1035 .help = "IO direction",
1037 .verify = rw_verify,
1040 .oval = TD_DDIR_READ,
1041 .help = "Sequential read",
1044 .oval = TD_DDIR_WRITE,
1045 .help = "Sequential write",
1048 .oval = TD_DDIR_TRIM,
1049 .help = "Sequential trim",
1051 { .ival = "randread",
1052 .oval = TD_DDIR_RANDREAD,
1053 .help = "Random read",
1055 { .ival = "randwrite",
1056 .oval = TD_DDIR_RANDWRITE,
1057 .help = "Random write",
1059 { .ival = "randtrim",
1060 .oval = TD_DDIR_RANDTRIM,
1061 .help = "Random trim",
1065 .help = "Sequential read and write mix",
1067 { .ival = "readwrite",
1069 .help = "Sequential read and write mix",
1072 .oval = TD_DDIR_RANDRW,
1073 .help = "Random read and write mix"
1078 .name = "rw_sequencer",
1079 .type = FIO_OPT_STR,
1080 .off1 = td_var_offset(rw_seq),
1081 .help = "IO offset generator modifier",
1082 .def = "sequential",
1084 { .ival = "sequential",
1086 .help = "Generate sequential offsets",
1088 { .ival = "identical",
1089 .oval = RW_SEQ_IDENT,
1090 .help = "Generate identical offsets",
1097 .type = FIO_OPT_STR_STORE,
1098 .off1 = td_var_offset(ioengine),
1099 .help = "IO engine to use",
1100 .def = FIO_PREFERRED_ENGINE,
1103 .help = "Use read/write",
1106 .help = "Use pread/pwrite",
1109 .help = "Use readv/writev",
1111 #ifdef FIO_HAVE_LIBAIO
1113 .help = "Linux native asynchronous IO",
1116 #ifdef FIO_HAVE_POSIXAIO
1117 { .ival = "posixaio",
1118 .help = "POSIX asynchronous IO",
1121 #ifdef FIO_HAVE_SOLARISAIO
1122 { .ival = "solarisaio",
1123 .help = "Solaris native asynchronous IO",
1126 #ifdef FIO_HAVE_WINDOWSAIO
1127 { .ival = "windowsaio",
1128 .help = "Windows native asynchronous IO"
1132 .help = "Memory mapped IO"
1134 #ifdef FIO_HAVE_SPLICE
1136 .help = "splice/vmsplice based IO",
1138 { .ival = "netsplice",
1139 .help = "splice/vmsplice to/from the network",
1142 #ifdef FIO_HAVE_SGIO
1144 .help = "SCSI generic v3 IO",
1148 .help = "Testing engine (no data transfer)",
1151 .help = "Network IO",
1153 #ifdef FIO_HAVE_SYSLET
1154 { .ival = "syslet-rw",
1155 .help = "syslet enabled async pread/pwrite IO",
1159 .help = "CPU cycle burner engine",
1161 #ifdef FIO_HAVE_GUASI
1163 .help = "GUASI IO engine",
1166 #ifdef FIO_HAVE_BINJECT
1167 { .ival = "binject",
1168 .help = "binject direct inject block engine",
1171 #ifdef FIO_HAVE_RDMA
1173 .help = "RDMA IO engine",
1176 #ifdef FIO_HAVE_FUSION_AW
1177 { .ival = "fusion-aw-sync",
1178 .help = "Fusion-io atomic write engine",
1181 #ifdef FIO_HAVE_E4_ENG
1182 { .ival = "e4defrag",
1183 .help = "ext4 defrag engine",
1186 #ifdef FIO_HAVE_FALLOC_ENG
1188 .help = "fallocate() file based engine",
1191 { .ival = "external",
1192 .help = "Load external engine (append name)",
1198 .type = FIO_OPT_INT,
1199 .off1 = td_var_offset(iodepth),
1200 .help = "Number of IO buffers to keep in flight",
1205 .name = "iodepth_batch",
1206 .alias = "iodepth_batch_submit",
1207 .type = FIO_OPT_INT,
1208 .off1 = td_var_offset(iodepth_batch),
1209 .help = "Number of IO buffers to submit in one go",
1210 .parent = "iodepth",
1215 .name = "iodepth_batch_complete",
1216 .type = FIO_OPT_INT,
1217 .off1 = td_var_offset(iodepth_batch_complete),
1218 .help = "Number of IO buffers to retrieve in one go",
1219 .parent = "iodepth",
1224 .name = "iodepth_low",
1225 .type = FIO_OPT_INT,
1226 .off1 = td_var_offset(iodepth_low),
1227 .help = "Low water mark for queuing depth",
1228 .parent = "iodepth",
1232 .type = FIO_OPT_STR_VAL,
1234 .help = "Total size of device or files",
1237 .name = "fill_device",
1239 .type = FIO_OPT_BOOL,
1240 .off1 = td_var_offset(fill_device),
1241 .help = "Write until an ENOSPC error occurs",
1246 .type = FIO_OPT_STR_VAL,
1247 .off1 = td_var_offset(file_size_low),
1248 .off2 = td_var_offset(file_size_high),
1250 .help = "Size of individual files",
1254 .alias = "fileoffset",
1255 .type = FIO_OPT_STR_VAL,
1256 .off1 = td_var_offset(start_offset),
1257 .help = "Start IO from this offset",
1261 .name = "offset_increment",
1262 .type = FIO_OPT_STR_VAL,
1263 .off1 = td_var_offset(offset_increment),
1264 .help = "What is the increment from one offset to the next",
1270 .alias = "blocksize",
1271 .type = FIO_OPT_INT,
1272 .off1 = td_var_offset(bs[DDIR_READ]),
1273 .off2 = td_var_offset(bs[DDIR_WRITE]),
1274 .off3 = td_var_offset(bs[DDIR_TRIM]),
1276 .help = "Block size unit",
1282 .alias = "blockalign",
1283 .type = FIO_OPT_INT,
1284 .off1 = td_var_offset(ba[DDIR_READ]),
1285 .off2 = td_var_offset(ba[DDIR_WRITE]),
1286 .off3 = td_var_offset(ba[DDIR_TRIM]),
1288 .help = "IO block offset alignment",
1293 .alias = "blocksize_range",
1294 .type = FIO_OPT_RANGE,
1295 .off1 = td_var_offset(min_bs[DDIR_READ]),
1296 .off2 = td_var_offset(max_bs[DDIR_READ]),
1297 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
1298 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
1299 .off5 = td_var_offset(min_bs[DDIR_TRIM]),
1300 .off6 = td_var_offset(max_bs[DDIR_TRIM]),
1302 .help = "Set block size range (in more detail than bs)",
1307 .type = FIO_OPT_STR,
1308 .cb = str_bssplit_cb,
1309 .help = "Set a specific mix of block sizes",
1313 .name = "bs_unaligned",
1314 .alias = "blocksize_unaligned",
1315 .type = FIO_OPT_STR_SET,
1316 .off1 = td_var_offset(bs_unaligned),
1317 .help = "Don't sector align IO buffer sizes",
1321 .name = "randrepeat",
1322 .type = FIO_OPT_BOOL,
1323 .off1 = td_var_offset(rand_repeatable),
1324 .help = "Use repeatable random IO pattern",
1329 .name = "use_os_rand",
1330 .type = FIO_OPT_BOOL,
1331 .off1 = td_var_offset(use_os_rand),
1332 .help = "Set to use OS random generator",
1337 .name = "norandommap",
1338 .type = FIO_OPT_STR_SET,
1339 .off1 = td_var_offset(norandommap),
1340 .help = "Accept potential duplicate random blocks",
1344 .name = "softrandommap",
1345 .type = FIO_OPT_BOOL,
1346 .off1 = td_var_offset(softrandommap),
1347 .help = "Set norandommap if randommap allocation fails",
1348 .parent = "norandommap",
1353 .alias = "nr_files",
1354 .type = FIO_OPT_INT,
1355 .off1 = td_var_offset(nr_files),
1356 .help = "Split job workload between this number of files",
1360 .name = "openfiles",
1361 .type = FIO_OPT_INT,
1362 .off1 = td_var_offset(open_files),
1363 .help = "Number of files to keep open at the same time",
1366 .name = "file_service_type",
1367 .type = FIO_OPT_STR,
1369 .off1 = td_var_offset(file_service_type),
1370 .help = "How to select which file to service next",
1371 .def = "roundrobin",
1374 .oval = FIO_FSERVICE_RANDOM,
1375 .help = "Choose a file at random",
1377 { .ival = "roundrobin",
1378 .oval = FIO_FSERVICE_RR,
1379 .help = "Round robin select files",
1381 { .ival = "sequential",
1382 .oval = FIO_FSERVICE_SEQ,
1383 .help = "Finish one file before moving to the next",
1386 .parent = "nrfiles",
1388 #ifdef FIO_HAVE_FALLOCATE
1390 .name = "fallocate",
1391 .type = FIO_OPT_STR,
1392 .off1 = td_var_offset(fallocate_mode),
1393 .help = "Whether pre-allocation is performed when laying out files",
1397 .oval = FIO_FALLOCATE_NONE,
1398 .help = "Do not pre-allocate space",
1401 .oval = FIO_FALLOCATE_POSIX,
1402 .help = "Use posix_fallocate()",
1404 #ifdef FIO_HAVE_LINUX_FALLOCATE
1406 .oval = FIO_FALLOCATE_KEEP_SIZE,
1407 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
1410 /* Compatibility with former boolean values */
1412 .oval = FIO_FALLOCATE_NONE,
1413 .help = "Alias for 'none'",
1416 .oval = FIO_FALLOCATE_POSIX,
1417 .help = "Alias for 'posix'",
1421 #endif /* FIO_HAVE_FALLOCATE */
1423 .name = "fadvise_hint",
1424 .type = FIO_OPT_BOOL,
1425 .off1 = td_var_offset(fadvise_hint),
1426 .help = "Use fadvise() to advise the kernel on IO pattern",
1431 .type = FIO_OPT_INT,
1432 .off1 = td_var_offset(fsync_blocks),
1433 .help = "Issue fsync for writes every given number of blocks",
1437 .name = "fdatasync",
1438 .type = FIO_OPT_INT,
1439 .off1 = td_var_offset(fdatasync_blocks),
1440 .help = "Issue fdatasync for writes every given number of blocks",
1444 .name = "write_barrier",
1445 .type = FIO_OPT_INT,
1446 .off1 = td_var_offset(barrier_blocks),
1447 .help = "Make every Nth write a barrier write",
1450 #ifdef FIO_HAVE_SYNC_FILE_RANGE
1452 .name = "sync_file_range",
1454 { .ival = "wait_before",
1455 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
1456 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
1460 .oval = SYNC_FILE_RANGE_WRITE,
1461 .help = "SYNC_FILE_RANGE_WRITE",
1465 .ival = "wait_after",
1466 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
1467 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
1471 .type = FIO_OPT_STR_MULTI,
1473 .off1 = td_var_offset(sync_file_range),
1474 .help = "Use sync_file_range()",
1479 .type = FIO_OPT_BOOL,
1480 .off1 = td_var_offset(odirect),
1481 .help = "Use O_DIRECT IO (negates buffered)",
1486 .type = FIO_OPT_BOOL,
1487 .off1 = td_var_offset(odirect),
1489 .help = "Use buffered IO (negates direct)",
1493 .name = "overwrite",
1494 .type = FIO_OPT_BOOL,
1495 .off1 = td_var_offset(overwrite),
1496 .help = "When writing, set whether to overwrite current data",
1501 .type = FIO_OPT_INT,
1502 .off1 = td_var_offset(loops),
1503 .help = "Number of times to run the job",
1508 .type = FIO_OPT_INT,
1509 .off1 = td_var_offset(numjobs),
1510 .help = "Duplicate this job this many times",
1514 .name = "startdelay",
1515 .type = FIO_OPT_STR_VAL_TIME,
1516 .off1 = td_var_offset(start_delay),
1517 .help = "Only start job when this period has passed",
1523 .type = FIO_OPT_STR_VAL_TIME,
1524 .off1 = td_var_offset(timeout),
1525 .help = "Stop workload when this amount of time has passed",
1529 .name = "time_based",
1530 .type = FIO_OPT_STR_SET,
1531 .off1 = td_var_offset(time_based),
1532 .help = "Keep running until runtime/timeout is met",
1535 .name = "ramp_time",
1536 .type = FIO_OPT_STR_VAL_TIME,
1537 .off1 = td_var_offset(ramp_time),
1538 .help = "Ramp up time before measuring performance",
1541 .name = "clocksource",
1542 .type = FIO_OPT_STR,
1543 .cb = fio_clock_source_cb,
1544 .off1 = td_var_offset(clocksource),
1545 .help = "What type of timing source to use",
1547 { .ival = "gettimeofday",
1549 .help = "Use gettimeofday(2) for timing",
1551 { .ival = "clock_gettime",
1552 .oval = CS_CGETTIME,
1553 .help = "Use clock_gettime(2) for timing",
1555 #ifdef ARCH_HAVE_CPU_CLOCK
1557 .oval = CS_CPUCLOCK,
1558 .help = "Use CPU private clock",
1566 .type = FIO_OPT_STR,
1568 .off1 = td_var_offset(mem_type),
1569 .help = "Backing type for IO buffers",
1574 .help = "Use malloc(3) for IO buffers",
1578 .help = "Use shared memory segments for IO buffers",
1580 #ifdef FIO_HAVE_HUGETLB
1581 { .ival = "shmhuge",
1582 .oval = MEM_SHMHUGE,
1583 .help = "Like shm, but use huge pages",
1588 .help = "Use mmap(2) (file or anon) for IO buffers",
1590 #ifdef FIO_HAVE_HUGETLB
1591 { .ival = "mmaphuge",
1592 .oval = MEM_MMAPHUGE,
1593 .help = "Like mmap, but use huge pages",
1599 .name = "iomem_align",
1600 .alias = "mem_align",
1601 .type = FIO_OPT_INT,
1602 .off1 = td_var_offset(mem_align),
1604 .help = "IO memory buffer offset alignment",
1610 .type = FIO_OPT_STR,
1611 .off1 = td_var_offset(verify),
1612 .help = "Verify data written",
1613 .cb = str_verify_cb,
1617 .oval = VERIFY_NONE,
1618 .help = "Don't do IO verification",
1622 .help = "Use md5 checksums for verification",
1625 .oval = VERIFY_CRC64,
1626 .help = "Use crc64 checksums for verification",
1629 .oval = VERIFY_CRC32,
1630 .help = "Use crc32 checksums for verification",
1632 { .ival = "crc32c-intel",
1633 .oval = VERIFY_CRC32C,
1634 .help = "Use crc32c checksums for verification (hw assisted, if available)",
1637 .oval = VERIFY_CRC32C,
1638 .help = "Use crc32c checksums for verification (hw assisted, if available)",
1641 .oval = VERIFY_CRC16,
1642 .help = "Use crc16 checksums for verification",
1645 .oval = VERIFY_CRC7,
1646 .help = "Use crc7 checksums for verification",
1649 .oval = VERIFY_SHA1,
1650 .help = "Use sha1 checksums for verification",
1653 .oval = VERIFY_SHA256,
1654 .help = "Use sha256 checksums for verification",
1657 .oval = VERIFY_SHA512,
1658 .help = "Use sha512 checksums for verification",
1661 .oval = VERIFY_META,
1662 .help = "Use io information",
1666 .oval = VERIFY_NULL,
1667 .help = "Pretend to verify",
1672 .name = "do_verify",
1673 .type = FIO_OPT_BOOL,
1674 .off1 = td_var_offset(do_verify),
1675 .help = "Run verification stage after write",
1680 .name = "verifysort",
1681 .type = FIO_OPT_BOOL,
1682 .off1 = td_var_offset(verifysort),
1683 .help = "Sort written verify blocks for read back",
1688 .name = "verify_interval",
1689 .type = FIO_OPT_INT,
1690 .off1 = td_var_offset(verify_interval),
1691 .minval = 2 * sizeof(struct verify_header),
1692 .help = "Store verify buffer header every N bytes",
1696 .name = "verify_offset",
1697 .type = FIO_OPT_INT,
1698 .help = "Offset verify header location by N bytes",
1700 .cb = str_verify_offset_cb,
1704 .name = "verify_pattern",
1705 .type = FIO_OPT_STR,
1706 .cb = str_verify_pattern_cb,
1707 .help = "Fill pattern for IO buffers",
1711 .name = "verify_fatal",
1712 .type = FIO_OPT_BOOL,
1713 .off1 = td_var_offset(verify_fatal),
1715 .help = "Exit on a single verify failure, don't continue",
1719 .name = "verify_dump",
1720 .type = FIO_OPT_BOOL,
1721 .off1 = td_var_offset(verify_dump),
1723 .help = "Dump contents of good and bad blocks on failure",
1727 .name = "verify_async",
1728 .type = FIO_OPT_INT,
1729 .off1 = td_var_offset(verify_async),
1731 .help = "Number of async verifier threads to use",
1735 .name = "verify_backlog",
1736 .type = FIO_OPT_STR_VAL,
1737 .off1 = td_var_offset(verify_backlog),
1738 .help = "Verify after this number of blocks are written",
1742 .name = "verify_backlog_batch",
1743 .type = FIO_OPT_INT,
1744 .off1 = td_var_offset(verify_batch),
1745 .help = "Verify this number of IO blocks",
1748 #ifdef FIO_HAVE_CPU_AFFINITY
1750 .name = "verify_async_cpus",
1751 .type = FIO_OPT_STR,
1752 .cb = str_verify_cpus_allowed_cb,
1753 .help = "Set CPUs allowed for async verify threads",
1754 .parent = "verify_async",
1757 #ifdef FIO_HAVE_TRIM
1759 .name = "trim_percentage",
1760 .type = FIO_OPT_INT,
1761 .cb = str_verify_trim_cb,
1763 .help = "Number of verify blocks to discard/trim",
1768 .name = "trim_verify_zero",
1769 .type = FIO_OPT_INT,
1770 .help = "Verify that trim/discarded blocks are returned as zeroes",
1771 .off1 = td_var_offset(trim_zero),
1772 .parent = "trim_percentage",
1776 .name = "trim_backlog",
1777 .type = FIO_OPT_STR_VAL,
1778 .off1 = td_var_offset(trim_backlog),
1779 .help = "Trim after this number of blocks are written",
1780 .parent = "trim_percentage",
1783 .name = "trim_backlog_batch",
1784 .type = FIO_OPT_INT,
1785 .off1 = td_var_offset(trim_batch),
1786 .help = "Trim this number of IO blocks",
1787 .parent = "trim_percentage",
1791 .name = "write_iolog",
1792 .type = FIO_OPT_STR_STORE,
1793 .off1 = td_var_offset(write_iolog_file),
1794 .help = "Store IO pattern to file",
1797 .name = "read_iolog",
1798 .type = FIO_OPT_STR_STORE,
1799 .off1 = td_var_offset(read_iolog_file),
1800 .help = "Playback IO pattern from file",
1803 .name = "replay_no_stall",
1804 .type = FIO_OPT_INT,
1805 .off1 = td_var_offset(no_stall),
1807 .parent = "read_iolog",
1808 .help = "Playback IO pattern file as fast as possible without stalls",
1811 .name = "replay_redirect",
1812 .type = FIO_OPT_STR_STORE,
1813 .off1 = td_var_offset(replay_redirect),
1814 .parent = "read_iolog",
1815 .help = "Replay all I/O onto this device, regardless of trace device",
1818 .name = "exec_prerun",
1819 .type = FIO_OPT_STR_STORE,
1820 .off1 = td_var_offset(exec_prerun),
1821 .help = "Execute this file prior to running job",
1824 .name = "exec_postrun",
1825 .type = FIO_OPT_STR_STORE,
1826 .off1 = td_var_offset(exec_postrun),
1827 .help = "Execute this file after running job",
1829 #ifdef FIO_HAVE_IOSCHED_SWITCH
1831 .name = "ioscheduler",
1832 .type = FIO_OPT_STR_STORE,
1833 .off1 = td_var_offset(ioscheduler),
1834 .help = "Use this IO scheduler on the backing device",
1839 .type = FIO_OPT_STR_VAL,
1840 .off1 = td_var_offset(zone_size),
1841 .help = "Amount of data to read per zone",
1845 .name = "zonerange",
1846 .type = FIO_OPT_STR_VAL,
1847 .off1 = td_var_offset(zone_range),
1848 .help = "Give size of an IO zone",
1853 .type = FIO_OPT_STR_VAL,
1854 .off1 = td_var_offset(zone_skip),
1855 .help = "Space between IO zones",
1860 .type = FIO_OPT_STR_VAL,
1861 .cb = str_lockmem_cb,
1862 .help = "Lock down this amount of memory",
1866 .name = "rwmixread",
1867 .type = FIO_OPT_INT,
1868 .cb = str_rwmix_read_cb,
1870 .help = "Percentage of mixed workload that is reads",
1874 .name = "rwmixwrite",
1875 .type = FIO_OPT_INT,
1876 .cb = str_rwmix_write_cb,
1878 .help = "Percentage of mixed workload that is writes",
1882 .name = "rwmixcycle",
1883 .type = FIO_OPT_DEPRECATED,
1887 .type = FIO_OPT_INT,
1888 .off1 = td_var_offset(nice),
1889 .help = "Set job CPU nice value",
1894 #ifdef FIO_HAVE_IOPRIO
1897 .type = FIO_OPT_INT,
1899 .help = "Set job IO priority value",
1904 .name = "prioclass",
1905 .type = FIO_OPT_INT,
1906 .cb = str_prioclass_cb,
1907 .help = "Set job IO priority class",
1913 .name = "thinktime",
1914 .type = FIO_OPT_INT,
1915 .off1 = td_var_offset(thinktime),
1916 .help = "Idle time between IO buffers (usec)",
1920 .name = "thinktime_spin",
1921 .type = FIO_OPT_INT,
1922 .off1 = td_var_offset(thinktime_spin),
1923 .help = "Start think time by spinning this amount (usec)",
1925 .parent = "thinktime",
1928 .name = "thinktime_blocks",
1929 .type = FIO_OPT_INT,
1930 .off1 = td_var_offset(thinktime_blocks),
1931 .help = "IO buffer period between 'thinktime'",
1933 .parent = "thinktime",
1937 .type = FIO_OPT_INT,
1938 .off1 = td_var_offset(rate[DDIR_READ]),
1939 .off2 = td_var_offset(rate[DDIR_WRITE]),
1940 .off3 = td_var_offset(rate[DDIR_TRIM]),
1941 .help = "Set bandwidth rate",
1945 .type = FIO_OPT_INT,
1946 .off1 = td_var_offset(ratemin[DDIR_READ]),
1947 .off2 = td_var_offset(ratemin[DDIR_WRITE]),
1948 .off3 = td_var_offset(ratemin[DDIR_TRIM]),
1949 .help = "Job must meet this rate or it will be shutdown",
1953 .name = "rate_iops",
1954 .type = FIO_OPT_INT,
1955 .off1 = td_var_offset(rate_iops[DDIR_READ]),
1956 .off2 = td_var_offset(rate_iops[DDIR_WRITE]),
1957 .off3 = td_var_offset(rate_iops[DDIR_TRIM]),
1958 .help = "Limit IO used to this number of IO operations/sec",
1961 .name = "rate_iops_min",
1962 .type = FIO_OPT_INT,
1963 .off1 = td_var_offset(rate_iops_min[DDIR_READ]),
1964 .off2 = td_var_offset(rate_iops_min[DDIR_WRITE]),
1965 .off3 = td_var_offset(rate_iops_min[DDIR_TRIM]),
1966 .help = "Job must meet this rate or it will be shut down",
1967 .parent = "rate_iops",
1970 .name = "ratecycle",
1971 .type = FIO_OPT_INT,
1972 .off1 = td_var_offset(ratecycle),
1973 .help = "Window average for rate limits (msec)",
1978 .name = "invalidate",
1979 .type = FIO_OPT_BOOL,
1980 .off1 = td_var_offset(invalidate_cache),
1981 .help = "Invalidate buffer/page cache prior to running job",
1986 .type = FIO_OPT_BOOL,
1987 .off1 = td_var_offset(sync_io),
1988 .help = "Use O_SYNC for buffered writes",
1990 .parent = "buffered",
1993 .name = "bwavgtime",
1994 .type = FIO_OPT_INT,
1995 .off1 = td_var_offset(bw_avg_time),
1996 .help = "Time window over which to calculate bandwidth"
1999 .parent = "write_bw_log",
2002 .name = "iopsavgtime",
2003 .type = FIO_OPT_INT,
2004 .off1 = td_var_offset(iops_avg_time),
2005 .help = "Time window over which to calculate IOPS (msec)",
2007 .parent = "write_iops_log",
2010 .name = "create_serialize",
2011 .type = FIO_OPT_BOOL,
2012 .off1 = td_var_offset(create_serialize),
2013 .help = "Serialize creating of job files",
2017 .name = "create_fsync",
2018 .type = FIO_OPT_BOOL,
2019 .off1 = td_var_offset(create_fsync),
2020 .help = "fsync file after creation",
2024 .name = "create_on_open",
2025 .type = FIO_OPT_BOOL,
2026 .off1 = td_var_offset(create_on_open),
2027 .help = "Create files when they are opened for IO",
2031 .name = "create_only",
2032 .type = FIO_OPT_BOOL,
2033 .off1 = td_var_offset(create_only),
2034 .help = "Only perform file creation phase",
2039 .type = FIO_OPT_BOOL,
2040 .off1 = td_var_offset(pre_read),
2041 .help = "Pre-read files before starting official testing",
2046 .type = FIO_OPT_INT,
2047 .off1 = td_var_offset(cpuload),
2048 .help = "Use this percentage of CPU",
2051 .name = "cpuchunks",
2052 .type = FIO_OPT_INT,
2053 .off1 = td_var_offset(cpucycle),
2054 .help = "Length of the CPU burn cycles (usecs)",
2056 .parent = "cpuload",
2058 #ifdef FIO_HAVE_CPU_AFFINITY
2061 .type = FIO_OPT_INT,
2062 .cb = str_cpumask_cb,
2063 .help = "CPU affinity mask",
2066 .name = "cpus_allowed",
2067 .type = FIO_OPT_STR,
2068 .cb = str_cpus_allowed_cb,
2069 .help = "Set CPUs allowed",
2073 .name = "end_fsync",
2074 .type = FIO_OPT_BOOL,
2075 .off1 = td_var_offset(end_fsync),
2076 .help = "Include fsync at the end of job",
2080 .name = "fsync_on_close",
2081 .type = FIO_OPT_BOOL,
2082 .off1 = td_var_offset(fsync_on_close),
2083 .help = "fsync files on close",
2088 .type = FIO_OPT_BOOL,
2089 .off1 = td_var_offset(unlink),
2090 .help = "Unlink created files after job has completed",
2095 .type = FIO_OPT_STR_SET,
2096 .cb = str_exitall_cb,
2097 .help = "Terminate all jobs when one exits",
2100 .name = "stonewall",
2101 .alias = "wait_for_previous",
2102 .type = FIO_OPT_STR_SET,
2103 .off1 = td_var_offset(stonewall),
2104 .help = "Insert a hard barrier between this job and previous",
2107 .name = "new_group",
2108 .type = FIO_OPT_STR_SET,
2109 .off1 = td_var_offset(new_group),
2110 .help = "Mark the start of a new group (for reporting)",
2114 .type = FIO_OPT_STR_SET,
2115 .off1 = td_var_offset(use_thread),
2116 .help = "Use threads instead of forks",
2119 .name = "write_bw_log",
2120 .type = FIO_OPT_STR,
2121 .off1 = td_var_offset(write_bw_log),
2122 .cb = str_write_bw_log_cb,
2123 .help = "Write log of bandwidth during run",
2126 .name = "write_lat_log",
2127 .type = FIO_OPT_STR,
2128 .off1 = td_var_offset(write_lat_log),
2129 .cb = str_write_lat_log_cb,
2130 .help = "Write log of latency during run",
2133 .name = "write_iops_log",
2134 .type = FIO_OPT_STR,
2135 .off1 = td_var_offset(write_iops_log),
2136 .cb = str_write_iops_log_cb,
2137 .help = "Write log of IOPS during run",
2140 .name = "log_avg_msec",
2141 .type = FIO_OPT_INT,
2142 .off1 = td_var_offset(log_avg_msec),
2143 .help = "Average bw/iops/lat logs over this period of time",
2147 .name = "hugepage-size",
2148 .type = FIO_OPT_INT,
2149 .off1 = td_var_offset(hugepage_size),
2150 .help = "When using hugepages, specify size of each page",
2151 .def = __fio_stringify(FIO_HUGE_PAGE),
2154 .name = "group_reporting",
2155 .type = FIO_OPT_STR_SET,
2156 .off1 = td_var_offset(group_reporting),
2157 .help = "Do reporting on a per-group basis",
2160 .name = "zero_buffers",
2161 .type = FIO_OPT_STR_SET,
2162 .off1 = td_var_offset(zero_buffers),
2163 .help = "Init IO buffers to all zeroes",
2166 .name = "refill_buffers",
2167 .type = FIO_OPT_STR_SET,
2168 .off1 = td_var_offset(refill_buffers),
2169 .help = "Refill IO buffers on every IO submit",
2172 .name = "scramble_buffers",
2173 .type = FIO_OPT_BOOL,
2174 .off1 = td_var_offset(scramble_buffers),
2175 .help = "Slightly scramble buffers on every IO submit",
2179 .name = "buffer_compress_percentage",
2180 .type = FIO_OPT_INT,
2181 .off1 = td_var_offset(compress_percentage),
2184 .help = "How compressible the buffer is (approximately)",
2187 .name = "buffer_compress_chunk",
2188 .type = FIO_OPT_INT,
2189 .off1 = td_var_offset(compress_chunk),
2190 .parent = "buffer_compress_percentage",
2191 .help = "Size of compressible region in buffer",
2194 .name = "clat_percentiles",
2195 .type = FIO_OPT_BOOL,
2196 .off1 = td_var_offset(clat_percentiles),
2197 .help = "Enable the reporting of completion latency percentiles",
2201 .name = "percentile_list",
2202 .type = FIO_OPT_FLOAT_LIST,
2203 .off1 = td_var_offset(percentile_list),
2204 .off2 = td_var_offset(overwrite_plist),
2205 .help = "Specify a custom list of percentiles to report",
2206 .maxlen = FIO_IO_U_LIST_MAX_LEN,
2211 #ifdef FIO_HAVE_DISK_UTIL
2213 .name = "disk_util",
2214 .type = FIO_OPT_BOOL,
2215 .off1 = td_var_offset(do_disk_util),
2216 .help = "Log disk utilization statistics",
2221 .name = "gtod_reduce",
2222 .type = FIO_OPT_BOOL,
2223 .help = "Greatly reduce number of gettimeofday() calls",
2224 .cb = str_gtod_reduce_cb,
2228 .name = "disable_lat",
2229 .type = FIO_OPT_BOOL,
2230 .off1 = td_var_offset(disable_lat),
2231 .help = "Disable latency numbers",
2232 .parent = "gtod_reduce",
2236 .name = "disable_clat",
2237 .type = FIO_OPT_BOOL,
2238 .off1 = td_var_offset(disable_clat),
2239 .help = "Disable completion latency numbers",
2240 .parent = "gtod_reduce",
2244 .name = "disable_slat",
2245 .type = FIO_OPT_BOOL,
2246 .off1 = td_var_offset(disable_slat),
2247 .help = "Disable submission latency numbers",
2248 .parent = "gtod_reduce",
2252 .name = "disable_bw_measurement",
2253 .type = FIO_OPT_BOOL,
2254 .off1 = td_var_offset(disable_bw),
2255 .help = "Disable bandwidth logging",
2256 .parent = "gtod_reduce",
2261 .type = FIO_OPT_INT,
2262 .cb = str_gtod_cpu_cb,
2263 .help = "Set up dedicated gettimeofday() thread on this CPU",
2264 .verify = gtod_cpu_verify,
2267 .name = "continue_on_error",
2268 .type = FIO_OPT_STR,
2269 .off1 = td_var_offset(continue_on_error),
2270 .help = "Continue on non-fatal errors during IO",
2274 .oval = ERROR_TYPE_NONE,
2275 .help = "Exit when an error is encountered",
2278 .oval = ERROR_TYPE_READ,
2279 .help = "Continue on read errors only",
2282 .oval = ERROR_TYPE_WRITE,
2283 .help = "Continue on write errors only",
2286 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
2287 .help = "Continue on any IO errors",
2290 .oval = ERROR_TYPE_VERIFY,
2291 .help = "Continue on verify errors only",
2294 .oval = ERROR_TYPE_ANY,
2295 .help = "Continue on all io and verify errors",
2298 .oval = ERROR_TYPE_NONE,
2299 .help = "Alias for 'none'",
2302 .oval = ERROR_TYPE_ANY,
2303 .help = "Alias for 'all'",
2308 .name = "ignore_error",
2309 .type = FIO_OPT_STR,
2310 .cb = str_ignore_error_cb,
2311 .help = "Set a specific list of errors to ignore",
2315 .name = "error_dump",
2316 .type = FIO_OPT_BOOL,
2317 .off1 = td_var_offset(error_dump),
2319 .help = "Dump info on each error",
2324 .type = FIO_OPT_STR_STORE,
2325 .off1 = td_var_offset(profile),
2326 .help = "Select a specific builtin performance test",
2330 .type = FIO_OPT_STR_STORE,
2331 .off1 = td_var_offset(cgroup),
2332 .help = "Add job to cgroup of this name",
2335 .name = "cgroup_weight",
2336 .type = FIO_OPT_INT,
2337 .off1 = td_var_offset(cgroup_weight),
2338 .help = "Use given weight for cgroup",
2343 .name = "cgroup_nodelete",
2344 .type = FIO_OPT_BOOL,
2345 .off1 = td_var_offset(cgroup_nodelete),
2346 .help = "Do not delete cgroups after job completion",
2351 .type = FIO_OPT_INT,
2352 .off1 = td_var_offset(uid),
2353 .help = "Run job with this user ID",
2357 .type = FIO_OPT_INT,
2358 .off1 = td_var_offset(gid),
2359 .help = "Run job with this group ID",
2363 .type = FIO_OPT_INT,
2364 .off1 = td_var_offset(flow_id),
2365 .help = "The flow index ID to use",
2370 .type = FIO_OPT_INT,
2371 .off1 = td_var_offset(flow),
2372 .help = "Weight for flow control of this job",
2373 .parent = "flow_id",
2377 .name = "flow_watermark",
2378 .type = FIO_OPT_INT,
2379 .off1 = td_var_offset(flow_watermark),
2380 .help = "High watermark for flow control. This option"
2381 " should be set to the same value for all threads"
2382 " with non-zero flow.",
2383 .parent = "flow_id",
2387 .name = "flow_sleep",
2388 .type = FIO_OPT_INT,
2389 .off1 = td_var_offset(flow_sleep),
2390 .help = "How many microseconds to sleep after being held"
2391 " back by the flow control mechanism",
2392 .parent = "flow_id",
2400 static void add_to_lopt(struct option *lopt, struct fio_option *o,
2401 const char *name, int val)
2403 lopt->name = (char *) name;
2405 if (o->type == FIO_OPT_STR_SET)
2406 lopt->has_arg = no_argument;
2408 lopt->has_arg = required_argument;
2411 static void options_to_lopts(struct fio_option *opts,
2412 struct option *long_options,
2413 int i, int option_type)
2415 struct fio_option *o = &opts[0];
2417 add_to_lopt(&long_options[i], o, o->name, option_type);
2420 add_to_lopt(&long_options[i], o, o->alias, option_type);
2425 assert(i < FIO_NR_OPTIONS);
2429 void fio_options_set_ioengine_opts(struct option *long_options,
2430 struct thread_data *td)
2435 while (long_options[i].name) {
2436 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
2437 memset(&long_options[i], 0, sizeof(*long_options));
2444 * Just clear out the prior ioengine options.
2449 options_to_lopts(td->io_ops->options, long_options, i,
2450 FIO_GETOPT_IOENGINE);
2453 void fio_options_dup_and_init(struct option *long_options)
2457 options_init(options);
2460 while (long_options[i].name)
2463 options_to_lopts(options, long_options, i, FIO_GETOPT_JOB);
2466 struct fio_keyword {
2472 static struct fio_keyword fio_keywords[] = {
2474 .word = "$pagesize",
2475 .desc = "Page size in the system",
2478 .word = "$mb_memory",
2479 .desc = "Megabytes of memory online",
2483 .desc = "Number of CPUs online in the system",
2490 void fio_keywords_init(void)
2492 unsigned long long mb_memory;
2496 sprintf(buf, "%lu", page_size);
2497 fio_keywords[0].replace = strdup(buf);
2499 mb_memory = os_phys_mem() / (1024 * 1024);
2500 sprintf(buf, "%llu", mb_memory);
2501 fio_keywords[1].replace = strdup(buf);
2504 sprintf(buf, "%lu", l);
2505 fio_keywords[2].replace = strdup(buf);
2510 static char *bc_calc(char *str)
2512 char buf[128], *tmp;
2517 * No math, just return string
2519 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
2520 !strchr(str, '/')) || strchr(str, '\''))
2524 * Split option from value, we only need to calculate the value
2526 tmp = strchr(str, '=');
2533 * Prevent buffer overflows; such a case isn't reasonable anyway
2535 if (strlen(str) >= 128 || strlen(tmp) > 100)
2538 sprintf(buf, "which %s > /dev/null", BC_APP);
2540 log_err("fio: bc is needed for performing math\n");
2544 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
2545 f = popen(buf, "r");
2550 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
2556 buf[(tmp - str) + ret - 1] = '\0';
2557 memcpy(buf, str, tmp - str);
2563 * Return a copy of the input string with substrings of the form ${VARNAME}
2564 * substituted with the value of the environment variable VARNAME. The
2565 * substitution always occurs, even if VARNAME is empty or the corresponding
2566 * environment variable undefined.
2568 static char *option_dup_subs(const char *opt)
2570 char out[OPT_LEN_MAX+1];
2571 char in[OPT_LEN_MAX+1];
2574 char *ch1, *ch2, *env;
2575 ssize_t nchr = OPT_LEN_MAX;
2578 if (strlen(opt) + 1 > OPT_LEN_MAX) {
2579 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
2583 in[OPT_LEN_MAX] = '\0';
2584 strncpy(in, opt, OPT_LEN_MAX);
2586 while (*inptr && nchr > 0) {
2587 if (inptr[0] == '$' && inptr[1] == '{') {
2588 ch2 = strchr(inptr, '}');
2589 if (ch2 && inptr+1 < ch2) {
2596 envlen = strlen(env);
2597 if (envlen <= nchr) {
2598 memcpy(outptr, env, envlen);
2608 *outptr++ = *inptr++;
2617 * Look for reserved variable names and replace them with real values
2619 static char *fio_keyword_replace(char *opt)
2625 for (i = 0; fio_keywords[i].word != NULL; i++) {
2626 struct fio_keyword *kw = &fio_keywords[i];
2628 while ((s = strstr(opt, kw->word)) != NULL) {
2629 char *new = malloc(strlen(opt) + 1);
2635 * Copy part of the string before the keyword and
2636 * sprintf() the replacement after it.
2638 memcpy(new, opt, olen);
2639 len = sprintf(new + olen, "%s", kw->replace);
2642 * If there's more in the original string, copy that
2645 opt += strlen(kw->word) + olen;
2647 memcpy(new + olen + len, opt, opt - o_org - 1);
2650 * replace opt and free the old opt
2660 * Check for potential math and invoke bc, if possible
2668 static char **dup_and_sub_options(char **opts, int num_opts)
2671 char **opts_copy = malloc(num_opts * sizeof(*opts));
2672 for (i = 0; i < num_opts; i++) {
2673 opts_copy[i] = option_dup_subs(opts[i]);
2676 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
2681 int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
2683 int i, ret, unknown;
2686 sort_options(opts, options, num_opts);
2687 opts_copy = dup_and_sub_options(opts, num_opts);
2689 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
2690 struct fio_option *o;
2691 int newret = parse_option(opts_copy[i], opts[i], options, &o,
2700 opts_copy[i] = NULL;
2707 ret |= ioengine_load(td);
2709 sort_options(opts_copy, td->io_ops->options, num_opts);
2712 for (i = 0; i < num_opts; i++) {
2713 struct fio_option *o = NULL;
2719 newret = parse_option(opts_copy[i], opts[i],
2720 td->io_ops->options, &o,
2725 log_err("Bad option <%s>\n", opts[i]);
2728 opts_copy[i] = NULL;
2736 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
2738 return parse_cmd_option(opt, val, options, td);
2741 int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
2744 return parse_cmd_option(opt, val, td->io_ops->options, td);
2747 void fio_fill_default_options(struct thread_data *td)
2749 fill_default_options(td, options);
2752 int fio_show_option_help(const char *opt)
2754 return show_cmd_help(options, opt);
2757 void options_mem_dupe(void *data, struct fio_option *options)
2759 struct fio_option *o;
2762 for (o = &options[0]; o->name; o++) {
2763 if (o->type != FIO_OPT_STR_STORE)
2766 ptr = td_var(data, o->off1);
2768 *ptr = strdup(*ptr);
2773 * dupe FIO_OPT_STR_STORE options
2775 void fio_options_mem_dupe(struct thread_data *td)
2777 options_mem_dupe(&td->o, options);
2779 if (td->eo && td->io_ops) {
2780 void *oldeo = td->eo;
2782 td->eo = malloc(td->io_ops->option_struct_size);
2783 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
2784 options_mem_dupe(td->eo, td->io_ops->options);
2788 unsigned int fio_get_kb_base(void *data)
2790 struct thread_data *td = data;
2791 unsigned int kb_base = 0;
2794 kb_base = td->o.kb_base;
2801 int add_option(struct fio_option *o)
2803 struct fio_option *__o;
2812 memcpy(&options[opt_index], o, sizeof(*o));
2816 void invalidate_profile_options(const char *prof_name)
2818 struct fio_option *o;
2822 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
2823 o->type = FIO_OPT_INVALID;
2824 o->prof_name = NULL;
2830 void add_opt_posval(const char *optname, const char *ival, const char *help)
2832 struct fio_option *o;
2835 o = find_option(options, optname);
2839 for (i = 0; i < PARSE_MAX_VP; i++) {
2840 if (o->posval[i].ival)
2843 o->posval[i].ival = ival;
2844 o->posval[i].help = help;
2849 void del_opt_posval(const char *optname, const char *ival)
2851 struct fio_option *o;
2854 o = find_option(options, optname);
2858 for (i = 0; i < PARSE_MAX_VP; i++) {
2859 if (!o->posval[i].ival)
2861 if (strcmp(o->posval[i].ival, ival))
2864 o->posval[i].ival = NULL;
2865 o->posval[i].help = NULL;
2869 void fio_options_free(struct thread_data *td)
2871 options_free(options, td);
2872 if (td->eo && td->io_ops && td->io_ops->options) {
2873 options_free(td->io_ops->options, td->eo);