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;
567 #ifdef FIO_HAVE_LIBNUMA
568 static int str_numa_cpunodes_cb(void *data, char *input)
570 struct thread_data *td = data;
572 /* numa_parse_nodestring() parses a character string list
573 * of nodes into a bit mask. The bit mask is allocated by
574 * numa_allocate_nodemask(), so it should be freed by
575 * numa_free_nodemask().
577 td->o.numa_cpunodesmask = numa_parse_nodestring(input);
578 if (td->o.numa_cpunodesmask == NULL) {
579 log_err("fio: numa_parse_nodestring failed\n");
580 td_verror(td, 1, "str_numa_cpunodes_cb");
584 td->o.numa_cpumask_set = 1;
588 static int str_numa_mpol_cb(void *data, char *input)
590 struct thread_data *td = data;
591 const char * const policy_types[] =
592 { "default", "prefer", "bind", "interleave", "local" };
595 char *nodelist = strchr(input, ':');
597 /* NUL-terminate mode */
601 for (i = 0; i <= MPOL_LOCAL; i++) {
602 if (!strcmp(input, policy_types[i])) {
603 td->o.numa_mem_mode = i;
607 if (i > MPOL_LOCAL) {
608 log_err("fio: memory policy should be: default, prefer, bind, interleave, local\n");
612 switch (td->o.numa_mem_mode) {
615 * Insist on a nodelist of one node only
618 char *rest = nodelist;
619 while (isdigit(*rest))
622 log_err("fio: one node only for \'prefer\'\n");
626 log_err("fio: one node is needed for \'prefer\'\n");
630 case MPOL_INTERLEAVE:
632 * Default to online nodes with memory if no nodelist
635 nodelist = strdup("all");
640 * Don't allow a nodelist
643 log_err("fio: NO nodelist for \'local\'\n");
649 * Insist on a nodelist
652 log_err("fio: a nodelist is needed for \'bind\'\n");
659 /* numa_parse_nodestring() parses a character string list
660 * of nodes into a bit mask. The bit mask is allocated by
661 * numa_allocate_nodemask(), so it should be freed by
662 * numa_free_nodemask().
664 switch (td->o.numa_mem_mode) {
666 td->o.numa_mem_prefer_node = atoi(nodelist);
668 case MPOL_INTERLEAVE:
670 td->o.numa_memnodesmask = numa_parse_nodestring(nodelist);
671 if (td->o.numa_memnodesmask == NULL) {
672 log_err("fio: numa_parse_nodestring failed\n");
673 td_verror(td, 1, "str_numa_memnodes_cb");
683 td->o.numa_memmask_set = 1;
692 static int str_verify_trim_cb(void *data, unsigned long long *val)
694 struct thread_data *td = data;
696 td->o.trim_percentage = *val;
701 static int str_fst_cb(void *data, const char *str)
703 struct thread_data *td = data;
704 char *nr = get_opt_postfix(str);
706 td->file_service_nr = 1;
708 td->file_service_nr = atoi(nr);
715 #ifdef FIO_HAVE_SYNC_FILE_RANGE
716 static int str_sfr_cb(void *data, const char *str)
718 struct thread_data *td = data;
719 char *nr = get_opt_postfix(str);
721 td->sync_file_range_nr = 1;
723 td->sync_file_range_nr = atoi(nr);
731 static int str_random_distribution_cb(void *data, const char *str)
733 struct thread_data *td = data;
737 if (td->o.random_distribution == FIO_RAND_DIST_ZIPF)
739 else if (td->o.random_distribution == FIO_RAND_DIST_PARETO)
744 nr = get_opt_postfix(str);
745 if (nr && !str_to_float(nr, &val)) {
746 log_err("fio: random postfix parsing failed\n");
751 if (td->o.random_distribution == FIO_RAND_DIST_ZIPF)
752 td->o.zipf_theta = val;
754 td->o.pareto_h = val;
760 static int check_dir(struct thread_data *td, char *fname)
763 char file[PATH_MAX], *dir;
766 if (td->o.directory) {
767 strcpy(file, td->o.directory);
772 sprintf(file + elen, "%s", fname);
778 * We can't do this on FIO_DISKLESSIO engines. The engine isn't loaded
779 * yet, so we can't do this check right here...
781 if (lstat(dir, &sb) < 0) {
784 log_err("fio: %s is not a directory\n", dir);
785 td_verror(td, ret, "lstat");
789 if (!S_ISDIR(sb.st_mode)) {
790 log_err("fio: %s is not a directory\n", dir);
800 * Return next file in the string. Files are separated with ':'. If the ':'
801 * is escaped with a '\', then that ':' is part of the filename and does not
802 * indicate a new file.
804 static char *get_next_file_name(char **ptr)
809 if (!str || !strlen(str))
815 * No colon, we are done
817 p = strchr(str, ':');
824 * We got a colon, but it's the first character. Skip and
832 if (*(p - 1) != '\\') {
838 memmove(p - 1, p, strlen(p) + 1);
845 static int str_filename_cb(void *data, const char *input)
847 struct thread_data *td = data;
848 char *fname, *str, *p;
850 p = str = strdup(input);
852 strip_blank_front(&str);
853 strip_blank_end(str);
855 if (!td->files_index)
858 while ((fname = get_next_file_name(&str)) != NULL) {
861 if (check_dir(td, fname)) {
873 static int str_directory_cb(void *data, const char fio_unused *str)
875 struct thread_data *td = data;
878 if (lstat(td->o.directory, &sb) < 0) {
881 log_err("fio: %s is not a directory\n", td->o.directory);
882 td_verror(td, ret, "lstat");
885 if (!S_ISDIR(sb.st_mode)) {
886 log_err("fio: %s is not a directory\n", td->o.directory);
893 static int str_opendir_cb(void *data, const char fio_unused *str)
895 struct thread_data *td = data;
897 if (!td->files_index)
900 return add_dir_files(td, td->o.opendir);
903 static int str_verify_offset_cb(void *data, unsigned long long *off)
905 struct thread_data *td = data;
907 if (*off && *off < sizeof(struct verify_header)) {
908 log_err("fio: verify_offset too small\n");
912 td->o.verify_offset = *off;
916 static int str_verify_pattern_cb(void *data, const char *input)
918 struct thread_data *td = data;
920 int i = 0, j = 0, len, k, base = 10;
923 loc1 = strstr(input, "0x");
924 loc2 = strstr(input, "0X");
927 off = strtol(input, NULL, base);
928 if (off != LONG_MAX || errno != ERANGE) {
930 td->o.verify_pattern[i] = off & 0xff;
939 j = loc1 - input + 2;
941 j = loc2 - input + 2;
944 if (len - j < MAX_PATTERN_SIZE * 2) {
946 off = converthexchartoint(input[k--]);
948 off += (converthexchartoint(input[k--])
950 td->o.verify_pattern[i++] = (char) off;
956 * Fill the pattern all the way to the end. This greatly reduces
957 * the number of memcpy's we have to do when verifying the IO.
959 while (i > 1 && i * 2 <= MAX_PATTERN_SIZE) {
960 memcpy(&td->o.verify_pattern[i], &td->o.verify_pattern[0], i);
965 * The code in verify_io_u_pattern assumes a single byte pattern
966 * fills the whole verify pattern buffer.
968 memset(td->o.verify_pattern, td->o.verify_pattern[0],
972 td->o.verify_pattern_bytes = i;
975 * VERIFY_META could already be set
977 if (td->o.verify == VERIFY_NONE)
978 td->o.verify = VERIFY_PATTERN;
983 static int str_lockfile_cb(void *data, const char *str)
985 struct thread_data *td = data;
986 char *nr = get_opt_postfix(str);
988 td->o.lockfile_batch = 1;
990 td->o.lockfile_batch = atoi(nr);
997 static int str_write_bw_log_cb(void *data, const char *str)
999 struct thread_data *td = data;
1002 td->o.bw_log_file = strdup(str);
1004 td->o.write_bw_log = 1;
1008 static int str_write_lat_log_cb(void *data, const char *str)
1010 struct thread_data *td = data;
1013 td->o.lat_log_file = strdup(str);
1015 td->o.write_lat_log = 1;
1019 static int str_write_iops_log_cb(void *data, const char *str)
1021 struct thread_data *td = data;
1024 td->o.iops_log_file = strdup(str);
1026 td->o.write_iops_log = 1;
1030 static int str_gtod_reduce_cb(void *data, int *il)
1032 struct thread_data *td = data;
1035 td->o.disable_lat = !!val;
1036 td->o.disable_clat = !!val;
1037 td->o.disable_slat = !!val;
1038 td->o.disable_bw = !!val;
1039 td->o.clat_percentiles = !val;
1041 td->tv_cache_mask = 63;
1046 static int str_gtod_cpu_cb(void *data, long long *il)
1048 struct thread_data *td = data;
1051 td->o.gtod_cpu = val;
1052 td->o.gtod_offload = 1;
1056 static int str_size_cb(void *data, unsigned long long *__val)
1058 struct thread_data *td = data;
1059 unsigned long long v = *__val;
1061 if (parse_is_percent(v)) {
1063 td->o.size_percent = -1ULL - v;
1070 static int rw_verify(struct fio_option *o, void *data)
1072 struct thread_data *td = data;
1074 if (read_only && td_write(td)) {
1075 log_err("fio: job <%s> has write bit set, but fio is in"
1076 " read-only mode\n", td->o.name);
1083 static int gtod_cpu_verify(struct fio_option *o, void *data)
1085 #ifndef FIO_HAVE_CPU_AFFINITY
1086 struct thread_data *td = data;
1088 if (td->o.gtod_cpu) {
1089 log_err("fio: platform must support CPU affinity for"
1090 "gettimeofday() offloading\n");
1098 static int kb_base_verify(struct fio_option *o, void *data)
1100 struct thread_data *td = data;
1102 if (td->o.kb_base != 1024 && td->o.kb_base != 1000) {
1103 log_err("fio: kb_base set to nonsensical value: %u\n",
1112 * Map of job/command line options
1114 static struct fio_option options[FIO_MAX_OPTS] = {
1116 .name = "description",
1117 .type = FIO_OPT_STR_STORE,
1118 .off1 = td_var_offset(description),
1119 .help = "Text job description",
1123 .type = FIO_OPT_STR_STORE,
1124 .off1 = td_var_offset(name),
1125 .help = "Name of this job",
1128 .name = "directory",
1129 .type = FIO_OPT_STR_STORE,
1130 .off1 = td_var_offset(directory),
1131 .cb = str_directory_cb,
1132 .help = "Directory to store files in",
1136 .type = FIO_OPT_STR_STORE,
1137 .off1 = td_var_offset(filename),
1138 .cb = str_filename_cb,
1139 .prio = -1, /* must come after "directory" */
1140 .help = "File(s) to use for the workload",
1144 .type = FIO_OPT_INT,
1145 .off1 = td_var_offset(kb_base),
1146 .verify = kb_base_verify,
1149 .help = "How many bytes per KB for reporting (1000 or 1024)",
1153 .type = FIO_OPT_STR,
1154 .cb = str_lockfile_cb,
1155 .off1 = td_var_offset(file_lock_mode),
1156 .help = "Lock file when doing IO to it",
1157 .parent = "filename",
1161 .oval = FILE_LOCK_NONE,
1162 .help = "No file locking",
1164 { .ival = "exclusive",
1165 .oval = FILE_LOCK_EXCLUSIVE,
1166 .help = "Exclusive file lock",
1169 .ival = "readwrite",
1170 .oval = FILE_LOCK_READWRITE,
1171 .help = "Read vs write lock",
1177 .type = FIO_OPT_STR_STORE,
1178 .off1 = td_var_offset(opendir),
1179 .cb = str_opendir_cb,
1180 .help = "Recursively add files from this directory and down",
1184 .alias = "readwrite",
1185 .type = FIO_OPT_STR,
1187 .off1 = td_var_offset(td_ddir),
1188 .help = "IO direction",
1190 .verify = rw_verify,
1193 .oval = TD_DDIR_READ,
1194 .help = "Sequential read",
1197 .oval = TD_DDIR_WRITE,
1198 .help = "Sequential write",
1201 .oval = TD_DDIR_TRIM,
1202 .help = "Sequential trim",
1204 { .ival = "randread",
1205 .oval = TD_DDIR_RANDREAD,
1206 .help = "Random read",
1208 { .ival = "randwrite",
1209 .oval = TD_DDIR_RANDWRITE,
1210 .help = "Random write",
1212 { .ival = "randtrim",
1213 .oval = TD_DDIR_RANDTRIM,
1214 .help = "Random trim",
1218 .help = "Sequential read and write mix",
1220 { .ival = "readwrite",
1222 .help = "Sequential read and write mix",
1225 .oval = TD_DDIR_RANDRW,
1226 .help = "Random read and write mix"
1231 .name = "rw_sequencer",
1232 .type = FIO_OPT_STR,
1233 .off1 = td_var_offset(rw_seq),
1234 .help = "IO offset generator modifier",
1235 .def = "sequential",
1237 { .ival = "sequential",
1239 .help = "Generate sequential offsets",
1241 { .ival = "identical",
1242 .oval = RW_SEQ_IDENT,
1243 .help = "Generate identical offsets",
1250 .type = FIO_OPT_STR_STORE,
1251 .off1 = td_var_offset(ioengine),
1252 .help = "IO engine to use",
1253 .def = FIO_PREFERRED_ENGINE,
1256 .help = "Use read/write",
1259 .help = "Use pread/pwrite",
1262 .help = "Use readv/writev",
1264 #ifdef FIO_HAVE_LIBAIO
1266 .help = "Linux native asynchronous IO",
1269 #ifdef FIO_HAVE_POSIXAIO
1270 { .ival = "posixaio",
1271 .help = "POSIX asynchronous IO",
1274 #ifdef FIO_HAVE_SOLARISAIO
1275 { .ival = "solarisaio",
1276 .help = "Solaris native asynchronous IO",
1279 #ifdef FIO_HAVE_WINDOWSAIO
1280 { .ival = "windowsaio",
1281 .help = "Windows native asynchronous IO"
1285 .help = "Memory mapped IO"
1287 #ifdef FIO_HAVE_SPLICE
1289 .help = "splice/vmsplice based IO",
1291 { .ival = "netsplice",
1292 .help = "splice/vmsplice to/from the network",
1295 #ifdef FIO_HAVE_SGIO
1297 .help = "SCSI generic v3 IO",
1301 .help = "Testing engine (no data transfer)",
1304 .help = "Network IO",
1306 #ifdef FIO_HAVE_SYSLET
1307 { .ival = "syslet-rw",
1308 .help = "syslet enabled async pread/pwrite IO",
1312 .help = "CPU cycle burner engine",
1314 #ifdef FIO_HAVE_GUASI
1316 .help = "GUASI IO engine",
1319 #ifdef FIO_HAVE_BINJECT
1320 { .ival = "binject",
1321 .help = "binject direct inject block engine",
1324 #ifdef FIO_HAVE_RDMA
1326 .help = "RDMA IO engine",
1329 #ifdef FIO_HAVE_FUSION_AW
1330 { .ival = "fusion-aw-sync",
1331 .help = "Fusion-io atomic write engine",
1334 #ifdef FIO_HAVE_E4_ENG
1335 { .ival = "e4defrag",
1336 .help = "ext4 defrag engine",
1339 #ifdef FIO_HAVE_FALLOC_ENG
1341 .help = "fallocate() file based engine",
1344 { .ival = "external",
1345 .help = "Load external engine (append name)",
1351 .type = FIO_OPT_INT,
1352 .off1 = td_var_offset(iodepth),
1353 .help = "Number of IO buffers to keep in flight",
1358 .name = "iodepth_batch",
1359 .alias = "iodepth_batch_submit",
1360 .type = FIO_OPT_INT,
1361 .off1 = td_var_offset(iodepth_batch),
1362 .help = "Number of IO buffers to submit in one go",
1363 .parent = "iodepth",
1368 .name = "iodepth_batch_complete",
1369 .type = FIO_OPT_INT,
1370 .off1 = td_var_offset(iodepth_batch_complete),
1371 .help = "Number of IO buffers to retrieve in one go",
1372 .parent = "iodepth",
1377 .name = "iodepth_low",
1378 .type = FIO_OPT_INT,
1379 .off1 = td_var_offset(iodepth_low),
1380 .help = "Low water mark for queuing depth",
1381 .parent = "iodepth",
1385 .type = FIO_OPT_STR_VAL,
1387 .help = "Total size of device or files",
1390 .name = "fill_device",
1392 .type = FIO_OPT_BOOL,
1393 .off1 = td_var_offset(fill_device),
1394 .help = "Write until an ENOSPC error occurs",
1399 .type = FIO_OPT_STR_VAL,
1400 .off1 = td_var_offset(file_size_low),
1401 .off2 = td_var_offset(file_size_high),
1403 .help = "Size of individual files",
1407 .alias = "fileoffset",
1408 .type = FIO_OPT_STR_VAL,
1409 .off1 = td_var_offset(start_offset),
1410 .help = "Start IO from this offset",
1414 .name = "offset_increment",
1415 .type = FIO_OPT_STR_VAL,
1416 .off1 = td_var_offset(offset_increment),
1417 .help = "What is the increment from one offset to the next",
1423 .alias = "blocksize",
1424 .type = FIO_OPT_INT,
1425 .off1 = td_var_offset(bs[DDIR_READ]),
1426 .off2 = td_var_offset(bs[DDIR_WRITE]),
1427 .off3 = td_var_offset(bs[DDIR_TRIM]),
1429 .help = "Block size unit",
1435 .alias = "blockalign",
1436 .type = FIO_OPT_INT,
1437 .off1 = td_var_offset(ba[DDIR_READ]),
1438 .off2 = td_var_offset(ba[DDIR_WRITE]),
1439 .off3 = td_var_offset(ba[DDIR_TRIM]),
1441 .help = "IO block offset alignment",
1446 .alias = "blocksize_range",
1447 .type = FIO_OPT_RANGE,
1448 .off1 = td_var_offset(min_bs[DDIR_READ]),
1449 .off2 = td_var_offset(max_bs[DDIR_READ]),
1450 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
1451 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
1452 .off5 = td_var_offset(min_bs[DDIR_TRIM]),
1453 .off6 = td_var_offset(max_bs[DDIR_TRIM]),
1455 .help = "Set block size range (in more detail than bs)",
1460 .type = FIO_OPT_STR,
1461 .cb = str_bssplit_cb,
1462 .help = "Set a specific mix of block sizes",
1466 .name = "bs_unaligned",
1467 .alias = "blocksize_unaligned",
1468 .type = FIO_OPT_STR_SET,
1469 .off1 = td_var_offset(bs_unaligned),
1470 .help = "Don't sector align IO buffer sizes",
1474 .name = "randrepeat",
1475 .type = FIO_OPT_BOOL,
1476 .off1 = td_var_offset(rand_repeatable),
1477 .help = "Use repeatable random IO pattern",
1482 .name = "use_os_rand",
1483 .type = FIO_OPT_BOOL,
1484 .off1 = td_var_offset(use_os_rand),
1485 .help = "Set to use OS random generator",
1490 .name = "norandommap",
1491 .type = FIO_OPT_STR_SET,
1492 .off1 = td_var_offset(norandommap),
1493 .help = "Accept potential duplicate random blocks",
1497 .name = "softrandommap",
1498 .type = FIO_OPT_BOOL,
1499 .off1 = td_var_offset(softrandommap),
1500 .help = "Set norandommap if randommap allocation fails",
1501 .parent = "norandommap",
1505 .name = "random_distribution",
1506 .type = FIO_OPT_STR,
1507 .off1 = td_var_offset(random_distribution),
1508 .cb = str_random_distribution_cb,
1509 .help = "Random offset distribution generator",
1513 .oval = FIO_RAND_DIST_RANDOM,
1514 .help = "Completely random",
1517 .oval = FIO_RAND_DIST_ZIPF,
1518 .help = "Zipf distribution",
1521 .oval = FIO_RAND_DIST_PARETO,
1522 .help = "Pareto distribution",
1528 .alias = "nr_files",
1529 .type = FIO_OPT_INT,
1530 .off1 = td_var_offset(nr_files),
1531 .help = "Split job workload between this number of files",
1535 .name = "openfiles",
1536 .type = FIO_OPT_INT,
1537 .off1 = td_var_offset(open_files),
1538 .help = "Number of files to keep open at the same time",
1541 .name = "file_service_type",
1542 .type = FIO_OPT_STR,
1544 .off1 = td_var_offset(file_service_type),
1545 .help = "How to select which file to service next",
1546 .def = "roundrobin",
1549 .oval = FIO_FSERVICE_RANDOM,
1550 .help = "Choose a file at random",
1552 { .ival = "roundrobin",
1553 .oval = FIO_FSERVICE_RR,
1554 .help = "Round robin select files",
1556 { .ival = "sequential",
1557 .oval = FIO_FSERVICE_SEQ,
1558 .help = "Finish one file before moving to the next",
1561 .parent = "nrfiles",
1563 #ifdef FIO_HAVE_FALLOCATE
1565 .name = "fallocate",
1566 .type = FIO_OPT_STR,
1567 .off1 = td_var_offset(fallocate_mode),
1568 .help = "Whether pre-allocation is performed when laying out files",
1572 .oval = FIO_FALLOCATE_NONE,
1573 .help = "Do not pre-allocate space",
1576 .oval = FIO_FALLOCATE_POSIX,
1577 .help = "Use posix_fallocate()",
1579 #ifdef FIO_HAVE_LINUX_FALLOCATE
1581 .oval = FIO_FALLOCATE_KEEP_SIZE,
1582 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
1585 /* Compatibility with former boolean values */
1587 .oval = FIO_FALLOCATE_NONE,
1588 .help = "Alias for 'none'",
1591 .oval = FIO_FALLOCATE_POSIX,
1592 .help = "Alias for 'posix'",
1596 #endif /* FIO_HAVE_FALLOCATE */
1598 .name = "fadvise_hint",
1599 .type = FIO_OPT_BOOL,
1600 .off1 = td_var_offset(fadvise_hint),
1601 .help = "Use fadvise() to advise the kernel on IO pattern",
1606 .type = FIO_OPT_INT,
1607 .off1 = td_var_offset(fsync_blocks),
1608 .help = "Issue fsync for writes every given number of blocks",
1612 .name = "fdatasync",
1613 .type = FIO_OPT_INT,
1614 .off1 = td_var_offset(fdatasync_blocks),
1615 .help = "Issue fdatasync for writes every given number of blocks",
1619 .name = "write_barrier",
1620 .type = FIO_OPT_INT,
1621 .off1 = td_var_offset(barrier_blocks),
1622 .help = "Make every Nth write a barrier write",
1625 #ifdef FIO_HAVE_SYNC_FILE_RANGE
1627 .name = "sync_file_range",
1629 { .ival = "wait_before",
1630 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
1631 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
1635 .oval = SYNC_FILE_RANGE_WRITE,
1636 .help = "SYNC_FILE_RANGE_WRITE",
1640 .ival = "wait_after",
1641 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
1642 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
1646 .type = FIO_OPT_STR_MULTI,
1648 .off1 = td_var_offset(sync_file_range),
1649 .help = "Use sync_file_range()",
1654 .type = FIO_OPT_BOOL,
1655 .off1 = td_var_offset(odirect),
1656 .help = "Use O_DIRECT IO (negates buffered)",
1661 .type = FIO_OPT_BOOL,
1662 .off1 = td_var_offset(odirect),
1664 .help = "Use buffered IO (negates direct)",
1668 .name = "overwrite",
1669 .type = FIO_OPT_BOOL,
1670 .off1 = td_var_offset(overwrite),
1671 .help = "When writing, set whether to overwrite current data",
1676 .type = FIO_OPT_INT,
1677 .off1 = td_var_offset(loops),
1678 .help = "Number of times to run the job",
1683 .type = FIO_OPT_INT,
1684 .off1 = td_var_offset(numjobs),
1685 .help = "Duplicate this job this many times",
1689 .name = "startdelay",
1690 .type = FIO_OPT_STR_VAL_TIME,
1691 .off1 = td_var_offset(start_delay),
1692 .help = "Only start job when this period has passed",
1698 .type = FIO_OPT_STR_VAL_TIME,
1699 .off1 = td_var_offset(timeout),
1700 .help = "Stop workload when this amount of time has passed",
1704 .name = "time_based",
1705 .type = FIO_OPT_STR_SET,
1706 .off1 = td_var_offset(time_based),
1707 .help = "Keep running until runtime/timeout is met",
1710 .name = "ramp_time",
1711 .type = FIO_OPT_STR_VAL_TIME,
1712 .off1 = td_var_offset(ramp_time),
1713 .help = "Ramp up time before measuring performance",
1716 .name = "clocksource",
1717 .type = FIO_OPT_STR,
1718 .cb = fio_clock_source_cb,
1719 .off1 = td_var_offset(clocksource),
1720 .help = "What type of timing source to use",
1722 { .ival = "gettimeofday",
1724 .help = "Use gettimeofday(2) for timing",
1726 { .ival = "clock_gettime",
1727 .oval = CS_CGETTIME,
1728 .help = "Use clock_gettime(2) for timing",
1730 #ifdef ARCH_HAVE_CPU_CLOCK
1732 .oval = CS_CPUCLOCK,
1733 .help = "Use CPU private clock",
1741 .type = FIO_OPT_STR,
1743 .off1 = td_var_offset(mem_type),
1744 .help = "Backing type for IO buffers",
1749 .help = "Use malloc(3) for IO buffers",
1753 .help = "Use shared memory segments for IO buffers",
1755 #ifdef FIO_HAVE_HUGETLB
1756 { .ival = "shmhuge",
1757 .oval = MEM_SHMHUGE,
1758 .help = "Like shm, but use huge pages",
1763 .help = "Use mmap(2) (file or anon) for IO buffers",
1765 #ifdef FIO_HAVE_HUGETLB
1766 { .ival = "mmaphuge",
1767 .oval = MEM_MMAPHUGE,
1768 .help = "Like mmap, but use huge pages",
1774 .name = "iomem_align",
1775 .alias = "mem_align",
1776 .type = FIO_OPT_INT,
1777 .off1 = td_var_offset(mem_align),
1779 .help = "IO memory buffer offset alignment",
1785 .type = FIO_OPT_STR,
1786 .off1 = td_var_offset(verify),
1787 .help = "Verify data written",
1788 .cb = str_verify_cb,
1792 .oval = VERIFY_NONE,
1793 .help = "Don't do IO verification",
1797 .help = "Use md5 checksums for verification",
1800 .oval = VERIFY_CRC64,
1801 .help = "Use crc64 checksums for verification",
1804 .oval = VERIFY_CRC32,
1805 .help = "Use crc32 checksums for verification",
1807 { .ival = "crc32c-intel",
1808 .oval = VERIFY_CRC32C,
1809 .help = "Use crc32c checksums for verification (hw assisted, if available)",
1812 .oval = VERIFY_CRC32C,
1813 .help = "Use crc32c checksums for verification (hw assisted, if available)",
1816 .oval = VERIFY_CRC16,
1817 .help = "Use crc16 checksums for verification",
1820 .oval = VERIFY_CRC7,
1821 .help = "Use crc7 checksums for verification",
1824 .oval = VERIFY_SHA1,
1825 .help = "Use sha1 checksums for verification",
1828 .oval = VERIFY_SHA256,
1829 .help = "Use sha256 checksums for verification",
1832 .oval = VERIFY_SHA512,
1833 .help = "Use sha512 checksums for verification",
1836 .oval = VERIFY_META,
1837 .help = "Use io information",
1841 .oval = VERIFY_NULL,
1842 .help = "Pretend to verify",
1847 .name = "do_verify",
1848 .type = FIO_OPT_BOOL,
1849 .off1 = td_var_offset(do_verify),
1850 .help = "Run verification stage after write",
1855 .name = "verifysort",
1856 .type = FIO_OPT_BOOL,
1857 .off1 = td_var_offset(verifysort),
1858 .help = "Sort written verify blocks for read back",
1863 .name = "verify_interval",
1864 .type = FIO_OPT_INT,
1865 .off1 = td_var_offset(verify_interval),
1866 .minval = 2 * sizeof(struct verify_header),
1867 .help = "Store verify buffer header every N bytes",
1871 .name = "verify_offset",
1872 .type = FIO_OPT_INT,
1873 .help = "Offset verify header location by N bytes",
1875 .cb = str_verify_offset_cb,
1879 .name = "verify_pattern",
1880 .type = FIO_OPT_STR,
1881 .cb = str_verify_pattern_cb,
1882 .help = "Fill pattern for IO buffers",
1886 .name = "verify_fatal",
1887 .type = FIO_OPT_BOOL,
1888 .off1 = td_var_offset(verify_fatal),
1890 .help = "Exit on a single verify failure, don't continue",
1894 .name = "verify_dump",
1895 .type = FIO_OPT_BOOL,
1896 .off1 = td_var_offset(verify_dump),
1898 .help = "Dump contents of good and bad blocks on failure",
1902 .name = "verify_async",
1903 .type = FIO_OPT_INT,
1904 .off1 = td_var_offset(verify_async),
1906 .help = "Number of async verifier threads to use",
1910 .name = "verify_backlog",
1911 .type = FIO_OPT_STR_VAL,
1912 .off1 = td_var_offset(verify_backlog),
1913 .help = "Verify after this number of blocks are written",
1917 .name = "verify_backlog_batch",
1918 .type = FIO_OPT_INT,
1919 .off1 = td_var_offset(verify_batch),
1920 .help = "Verify this number of IO blocks",
1923 #ifdef FIO_HAVE_CPU_AFFINITY
1925 .name = "verify_async_cpus",
1926 .type = FIO_OPT_STR,
1927 .cb = str_verify_cpus_allowed_cb,
1928 .help = "Set CPUs allowed for async verify threads",
1929 .parent = "verify_async",
1932 #ifdef FIO_HAVE_TRIM
1934 .name = "trim_percentage",
1935 .type = FIO_OPT_INT,
1936 .cb = str_verify_trim_cb,
1938 .help = "Number of verify blocks to discard/trim",
1943 .name = "trim_verify_zero",
1944 .type = FIO_OPT_INT,
1945 .help = "Verify that trim/discarded blocks are returned as zeroes",
1946 .off1 = td_var_offset(trim_zero),
1947 .parent = "trim_percentage",
1951 .name = "trim_backlog",
1952 .type = FIO_OPT_STR_VAL,
1953 .off1 = td_var_offset(trim_backlog),
1954 .help = "Trim after this number of blocks are written",
1955 .parent = "trim_percentage",
1958 .name = "trim_backlog_batch",
1959 .type = FIO_OPT_INT,
1960 .off1 = td_var_offset(trim_batch),
1961 .help = "Trim this number of IO blocks",
1962 .parent = "trim_percentage",
1966 .name = "write_iolog",
1967 .type = FIO_OPT_STR_STORE,
1968 .off1 = td_var_offset(write_iolog_file),
1969 .help = "Store IO pattern to file",
1972 .name = "read_iolog",
1973 .type = FIO_OPT_STR_STORE,
1974 .off1 = td_var_offset(read_iolog_file),
1975 .help = "Playback IO pattern from file",
1978 .name = "replay_no_stall",
1979 .type = FIO_OPT_INT,
1980 .off1 = td_var_offset(no_stall),
1982 .parent = "read_iolog",
1983 .help = "Playback IO pattern file as fast as possible without stalls",
1986 .name = "replay_redirect",
1987 .type = FIO_OPT_STR_STORE,
1988 .off1 = td_var_offset(replay_redirect),
1989 .parent = "read_iolog",
1990 .help = "Replay all I/O onto this device, regardless of trace device",
1993 .name = "exec_prerun",
1994 .type = FIO_OPT_STR_STORE,
1995 .off1 = td_var_offset(exec_prerun),
1996 .help = "Execute this file prior to running job",
1999 .name = "exec_postrun",
2000 .type = FIO_OPT_STR_STORE,
2001 .off1 = td_var_offset(exec_postrun),
2002 .help = "Execute this file after running job",
2004 #ifdef FIO_HAVE_IOSCHED_SWITCH
2006 .name = "ioscheduler",
2007 .type = FIO_OPT_STR_STORE,
2008 .off1 = td_var_offset(ioscheduler),
2009 .help = "Use this IO scheduler on the backing device",
2014 .type = FIO_OPT_STR_VAL,
2015 .off1 = td_var_offset(zone_size),
2016 .help = "Amount of data to read per zone",
2020 .name = "zonerange",
2021 .type = FIO_OPT_STR_VAL,
2022 .off1 = td_var_offset(zone_range),
2023 .help = "Give size of an IO zone",
2028 .type = FIO_OPT_STR_VAL,
2029 .off1 = td_var_offset(zone_skip),
2030 .help = "Space between IO zones",
2035 .type = FIO_OPT_STR_VAL,
2036 .cb = str_lockmem_cb,
2037 .help = "Lock down this amount of memory",
2041 .name = "rwmixread",
2042 .type = FIO_OPT_INT,
2043 .cb = str_rwmix_read_cb,
2045 .help = "Percentage of mixed workload that is reads",
2049 .name = "rwmixwrite",
2050 .type = FIO_OPT_INT,
2051 .cb = str_rwmix_write_cb,
2053 .help = "Percentage of mixed workload that is writes",
2057 .name = "rwmixcycle",
2058 .type = FIO_OPT_DEPRECATED,
2062 .type = FIO_OPT_INT,
2063 .off1 = td_var_offset(nice),
2064 .help = "Set job CPU nice value",
2069 #ifdef FIO_HAVE_IOPRIO
2072 .type = FIO_OPT_INT,
2074 .help = "Set job IO priority value",
2079 .name = "prioclass",
2080 .type = FIO_OPT_INT,
2081 .cb = str_prioclass_cb,
2082 .help = "Set job IO priority class",
2088 .name = "thinktime",
2089 .type = FIO_OPT_INT,
2090 .off1 = td_var_offset(thinktime),
2091 .help = "Idle time between IO buffers (usec)",
2095 .name = "thinktime_spin",
2096 .type = FIO_OPT_INT,
2097 .off1 = td_var_offset(thinktime_spin),
2098 .help = "Start think time by spinning this amount (usec)",
2100 .parent = "thinktime",
2103 .name = "thinktime_blocks",
2104 .type = FIO_OPT_INT,
2105 .off1 = td_var_offset(thinktime_blocks),
2106 .help = "IO buffer period between 'thinktime'",
2108 .parent = "thinktime",
2112 .type = FIO_OPT_INT,
2113 .off1 = td_var_offset(rate[DDIR_READ]),
2114 .off2 = td_var_offset(rate[DDIR_WRITE]),
2115 .off3 = td_var_offset(rate[DDIR_TRIM]),
2116 .help = "Set bandwidth rate",
2120 .type = FIO_OPT_INT,
2121 .off1 = td_var_offset(ratemin[DDIR_READ]),
2122 .off2 = td_var_offset(ratemin[DDIR_WRITE]),
2123 .off3 = td_var_offset(ratemin[DDIR_TRIM]),
2124 .help = "Job must meet this rate or it will be shutdown",
2128 .name = "rate_iops",
2129 .type = FIO_OPT_INT,
2130 .off1 = td_var_offset(rate_iops[DDIR_READ]),
2131 .off2 = td_var_offset(rate_iops[DDIR_WRITE]),
2132 .off3 = td_var_offset(rate_iops[DDIR_TRIM]),
2133 .help = "Limit IO used to this number of IO operations/sec",
2136 .name = "rate_iops_min",
2137 .type = FIO_OPT_INT,
2138 .off1 = td_var_offset(rate_iops_min[DDIR_READ]),
2139 .off2 = td_var_offset(rate_iops_min[DDIR_WRITE]),
2140 .off3 = td_var_offset(rate_iops_min[DDIR_TRIM]),
2141 .help = "Job must meet this rate or it will be shut down",
2142 .parent = "rate_iops",
2145 .name = "ratecycle",
2146 .type = FIO_OPT_INT,
2147 .off1 = td_var_offset(ratecycle),
2148 .help = "Window average for rate limits (msec)",
2153 .name = "max_latency",
2154 .type = FIO_OPT_INT,
2155 .off1 = td_var_offset(max_latency),
2156 .help = "Maximum tolerated IO latency (usec)",
2159 .name = "invalidate",
2160 .type = FIO_OPT_BOOL,
2161 .off1 = td_var_offset(invalidate_cache),
2162 .help = "Invalidate buffer/page cache prior to running job",
2167 .type = FIO_OPT_BOOL,
2168 .off1 = td_var_offset(sync_io),
2169 .help = "Use O_SYNC for buffered writes",
2171 .parent = "buffered",
2174 .name = "bwavgtime",
2175 .type = FIO_OPT_INT,
2176 .off1 = td_var_offset(bw_avg_time),
2177 .help = "Time window over which to calculate bandwidth"
2180 .parent = "write_bw_log",
2183 .name = "iopsavgtime",
2184 .type = FIO_OPT_INT,
2185 .off1 = td_var_offset(iops_avg_time),
2186 .help = "Time window over which to calculate IOPS (msec)",
2188 .parent = "write_iops_log",
2191 .name = "create_serialize",
2192 .type = FIO_OPT_BOOL,
2193 .off1 = td_var_offset(create_serialize),
2194 .help = "Serialize creating of job files",
2198 .name = "create_fsync",
2199 .type = FIO_OPT_BOOL,
2200 .off1 = td_var_offset(create_fsync),
2201 .help = "fsync file after creation",
2205 .name = "create_on_open",
2206 .type = FIO_OPT_BOOL,
2207 .off1 = td_var_offset(create_on_open),
2208 .help = "Create files when they are opened for IO",
2212 .name = "create_only",
2213 .type = FIO_OPT_BOOL,
2214 .off1 = td_var_offset(create_only),
2215 .help = "Only perform file creation phase",
2220 .type = FIO_OPT_BOOL,
2221 .off1 = td_var_offset(pre_read),
2222 .help = "Pre-read files before starting official testing",
2227 .type = FIO_OPT_INT,
2228 .off1 = td_var_offset(cpuload),
2229 .help = "Use this percentage of CPU",
2232 .name = "cpuchunks",
2233 .type = FIO_OPT_INT,
2234 .off1 = td_var_offset(cpucycle),
2235 .help = "Length of the CPU burn cycles (usecs)",
2237 .parent = "cpuload",
2239 #ifdef FIO_HAVE_CPU_AFFINITY
2242 .type = FIO_OPT_INT,
2243 .cb = str_cpumask_cb,
2244 .help = "CPU affinity mask",
2247 .name = "cpus_allowed",
2248 .type = FIO_OPT_STR,
2249 .cb = str_cpus_allowed_cb,
2250 .help = "Set CPUs allowed",
2253 #ifdef FIO_HAVE_LIBNUMA
2255 .name = "numa_cpu_nodes",
2256 .type = FIO_OPT_STR,
2257 .cb = str_numa_cpunodes_cb,
2258 .help = "NUMA CPU nodes bind",
2261 .name = "numa_mem_policy",
2262 .type = FIO_OPT_STR,
2263 .cb = str_numa_mpol_cb,
2264 .help = "NUMA memory policy setup",
2268 .name = "end_fsync",
2269 .type = FIO_OPT_BOOL,
2270 .off1 = td_var_offset(end_fsync),
2271 .help = "Include fsync at the end of job",
2275 .name = "fsync_on_close",
2276 .type = FIO_OPT_BOOL,
2277 .off1 = td_var_offset(fsync_on_close),
2278 .help = "fsync files on close",
2283 .type = FIO_OPT_BOOL,
2284 .off1 = td_var_offset(unlink),
2285 .help = "Unlink created files after job has completed",
2290 .type = FIO_OPT_STR_SET,
2291 .cb = str_exitall_cb,
2292 .help = "Terminate all jobs when one exits",
2295 .name = "stonewall",
2296 .alias = "wait_for_previous",
2297 .type = FIO_OPT_STR_SET,
2298 .off1 = td_var_offset(stonewall),
2299 .help = "Insert a hard barrier between this job and previous",
2302 .name = "new_group",
2303 .type = FIO_OPT_STR_SET,
2304 .off1 = td_var_offset(new_group),
2305 .help = "Mark the start of a new group (for reporting)",
2309 .type = FIO_OPT_STR_SET,
2310 .off1 = td_var_offset(use_thread),
2311 .help = "Use threads instead of forks",
2314 .name = "write_bw_log",
2315 .type = FIO_OPT_STR,
2316 .off1 = td_var_offset(write_bw_log),
2317 .cb = str_write_bw_log_cb,
2318 .help = "Write log of bandwidth during run",
2321 .name = "write_lat_log",
2322 .type = FIO_OPT_STR,
2323 .off1 = td_var_offset(write_lat_log),
2324 .cb = str_write_lat_log_cb,
2325 .help = "Write log of latency during run",
2328 .name = "write_iops_log",
2329 .type = FIO_OPT_STR,
2330 .off1 = td_var_offset(write_iops_log),
2331 .cb = str_write_iops_log_cb,
2332 .help = "Write log of IOPS during run",
2335 .name = "log_avg_msec",
2336 .type = FIO_OPT_INT,
2337 .off1 = td_var_offset(log_avg_msec),
2338 .help = "Average bw/iops/lat logs over this period of time",
2342 .name = "hugepage-size",
2343 .type = FIO_OPT_INT,
2344 .off1 = td_var_offset(hugepage_size),
2345 .help = "When using hugepages, specify size of each page",
2346 .def = __fio_stringify(FIO_HUGE_PAGE),
2349 .name = "group_reporting",
2350 .type = FIO_OPT_STR_SET,
2351 .off1 = td_var_offset(group_reporting),
2352 .help = "Do reporting on a per-group basis",
2355 .name = "zero_buffers",
2356 .type = FIO_OPT_STR_SET,
2357 .off1 = td_var_offset(zero_buffers),
2358 .help = "Init IO buffers to all zeroes",
2361 .name = "refill_buffers",
2362 .type = FIO_OPT_STR_SET,
2363 .off1 = td_var_offset(refill_buffers),
2364 .help = "Refill IO buffers on every IO submit",
2367 .name = "scramble_buffers",
2368 .type = FIO_OPT_BOOL,
2369 .off1 = td_var_offset(scramble_buffers),
2370 .help = "Slightly scramble buffers on every IO submit",
2374 .name = "buffer_compress_percentage",
2375 .type = FIO_OPT_INT,
2376 .off1 = td_var_offset(compress_percentage),
2379 .help = "How compressible the buffer is (approximately)",
2382 .name = "buffer_compress_chunk",
2383 .type = FIO_OPT_INT,
2384 .off1 = td_var_offset(compress_chunk),
2385 .parent = "buffer_compress_percentage",
2386 .help = "Size of compressible region in buffer",
2389 .name = "clat_percentiles",
2390 .type = FIO_OPT_BOOL,
2391 .off1 = td_var_offset(clat_percentiles),
2392 .help = "Enable the reporting of completion latency percentiles",
2396 .name = "percentile_list",
2397 .type = FIO_OPT_FLOAT_LIST,
2398 .off1 = td_var_offset(percentile_list),
2399 .off2 = td_var_offset(overwrite_plist),
2400 .help = "Specify a custom list of percentiles to report",
2401 .maxlen = FIO_IO_U_LIST_MAX_LEN,
2406 #ifdef FIO_HAVE_DISK_UTIL
2408 .name = "disk_util",
2409 .type = FIO_OPT_BOOL,
2410 .off1 = td_var_offset(do_disk_util),
2411 .help = "Log disk utilization statistics",
2416 .name = "gtod_reduce",
2417 .type = FIO_OPT_BOOL,
2418 .help = "Greatly reduce number of gettimeofday() calls",
2419 .cb = str_gtod_reduce_cb,
2423 .name = "disable_lat",
2424 .type = FIO_OPT_BOOL,
2425 .off1 = td_var_offset(disable_lat),
2426 .help = "Disable latency numbers",
2427 .parent = "gtod_reduce",
2431 .name = "disable_clat",
2432 .type = FIO_OPT_BOOL,
2433 .off1 = td_var_offset(disable_clat),
2434 .help = "Disable completion latency numbers",
2435 .parent = "gtod_reduce",
2439 .name = "disable_slat",
2440 .type = FIO_OPT_BOOL,
2441 .off1 = td_var_offset(disable_slat),
2442 .help = "Disable submission latency numbers",
2443 .parent = "gtod_reduce",
2447 .name = "disable_bw_measurement",
2448 .type = FIO_OPT_BOOL,
2449 .off1 = td_var_offset(disable_bw),
2450 .help = "Disable bandwidth logging",
2451 .parent = "gtod_reduce",
2456 .type = FIO_OPT_INT,
2457 .cb = str_gtod_cpu_cb,
2458 .help = "Set up dedicated gettimeofday() thread on this CPU",
2459 .verify = gtod_cpu_verify,
2462 .name = "continue_on_error",
2463 .type = FIO_OPT_STR,
2464 .off1 = td_var_offset(continue_on_error),
2465 .help = "Continue on non-fatal errors during IO",
2469 .oval = ERROR_TYPE_NONE,
2470 .help = "Exit when an error is encountered",
2473 .oval = ERROR_TYPE_READ,
2474 .help = "Continue on read errors only",
2477 .oval = ERROR_TYPE_WRITE,
2478 .help = "Continue on write errors only",
2481 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
2482 .help = "Continue on any IO errors",
2485 .oval = ERROR_TYPE_VERIFY,
2486 .help = "Continue on verify errors only",
2489 .oval = ERROR_TYPE_ANY,
2490 .help = "Continue on all io and verify errors",
2493 .oval = ERROR_TYPE_NONE,
2494 .help = "Alias for 'none'",
2497 .oval = ERROR_TYPE_ANY,
2498 .help = "Alias for 'all'",
2503 .name = "ignore_error",
2504 .type = FIO_OPT_STR,
2505 .cb = str_ignore_error_cb,
2506 .help = "Set a specific list of errors to ignore",
2510 .name = "error_dump",
2511 .type = FIO_OPT_BOOL,
2512 .off1 = td_var_offset(error_dump),
2514 .help = "Dump info on each error",
2519 .type = FIO_OPT_STR_STORE,
2520 .off1 = td_var_offset(profile),
2521 .help = "Select a specific builtin performance test",
2525 .type = FIO_OPT_STR_STORE,
2526 .off1 = td_var_offset(cgroup),
2527 .help = "Add job to cgroup of this name",
2530 .name = "cgroup_weight",
2531 .type = FIO_OPT_INT,
2532 .off1 = td_var_offset(cgroup_weight),
2533 .help = "Use given weight for cgroup",
2538 .name = "cgroup_nodelete",
2539 .type = FIO_OPT_BOOL,
2540 .off1 = td_var_offset(cgroup_nodelete),
2541 .help = "Do not delete cgroups after job completion",
2546 .type = FIO_OPT_INT,
2547 .off1 = td_var_offset(uid),
2548 .help = "Run job with this user ID",
2552 .type = FIO_OPT_INT,
2553 .off1 = td_var_offset(gid),
2554 .help = "Run job with this group ID",
2558 .type = FIO_OPT_INT,
2559 .off1 = td_var_offset(flow_id),
2560 .help = "The flow index ID to use",
2565 .type = FIO_OPT_INT,
2566 .off1 = td_var_offset(flow),
2567 .help = "Weight for flow control of this job",
2568 .parent = "flow_id",
2572 .name = "flow_watermark",
2573 .type = FIO_OPT_INT,
2574 .off1 = td_var_offset(flow_watermark),
2575 .help = "High watermark for flow control. This option"
2576 " should be set to the same value for all threads"
2577 " with non-zero flow.",
2578 .parent = "flow_id",
2582 .name = "flow_sleep",
2583 .type = FIO_OPT_INT,
2584 .off1 = td_var_offset(flow_sleep),
2585 .help = "How many microseconds to sleep after being held"
2586 " back by the flow control mechanism",
2587 .parent = "flow_id",
2595 static void add_to_lopt(struct option *lopt, struct fio_option *o,
2596 const char *name, int val)
2598 lopt->name = (char *) name;
2600 if (o->type == FIO_OPT_STR_SET)
2601 lopt->has_arg = no_argument;
2603 lopt->has_arg = required_argument;
2606 static void options_to_lopts(struct fio_option *opts,
2607 struct option *long_options,
2608 int i, int option_type)
2610 struct fio_option *o = &opts[0];
2612 add_to_lopt(&long_options[i], o, o->name, option_type);
2615 add_to_lopt(&long_options[i], o, o->alias, option_type);
2620 assert(i < FIO_NR_OPTIONS);
2624 void fio_options_set_ioengine_opts(struct option *long_options,
2625 struct thread_data *td)
2630 while (long_options[i].name) {
2631 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
2632 memset(&long_options[i], 0, sizeof(*long_options));
2639 * Just clear out the prior ioengine options.
2644 options_to_lopts(td->io_ops->options, long_options, i,
2645 FIO_GETOPT_IOENGINE);
2648 void fio_options_dup_and_init(struct option *long_options)
2652 options_init(options);
2655 while (long_options[i].name)
2658 options_to_lopts(options, long_options, i, FIO_GETOPT_JOB);
2661 struct fio_keyword {
2667 static struct fio_keyword fio_keywords[] = {
2669 .word = "$pagesize",
2670 .desc = "Page size in the system",
2673 .word = "$mb_memory",
2674 .desc = "Megabytes of memory online",
2678 .desc = "Number of CPUs online in the system",
2685 void fio_keywords_init(void)
2687 unsigned long long mb_memory;
2691 sprintf(buf, "%lu", (unsigned long) page_size);
2692 fio_keywords[0].replace = strdup(buf);
2694 mb_memory = os_phys_mem() / (1024 * 1024);
2695 sprintf(buf, "%llu", mb_memory);
2696 fio_keywords[1].replace = strdup(buf);
2699 sprintf(buf, "%lu", l);
2700 fio_keywords[2].replace = strdup(buf);
2705 static char *bc_calc(char *str)
2707 char buf[128], *tmp;
2712 * No math, just return string
2714 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
2715 !strchr(str, '/')) || strchr(str, '\''))
2719 * Split option from value, we only need to calculate the value
2721 tmp = strchr(str, '=');
2728 * Prevent buffer overflows; such a case isn't reasonable anyway
2730 if (strlen(str) >= 128 || strlen(tmp) > 100)
2733 sprintf(buf, "which %s > /dev/null", BC_APP);
2735 log_err("fio: bc is needed for performing math\n");
2739 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
2740 f = popen(buf, "r");
2745 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
2751 buf[(tmp - str) + ret - 1] = '\0';
2752 memcpy(buf, str, tmp - str);
2758 * Return a copy of the input string with substrings of the form ${VARNAME}
2759 * substituted with the value of the environment variable VARNAME. The
2760 * substitution always occurs, even if VARNAME is empty or the corresponding
2761 * environment variable undefined.
2763 static char *option_dup_subs(const char *opt)
2765 char out[OPT_LEN_MAX+1];
2766 char in[OPT_LEN_MAX+1];
2769 char *ch1, *ch2, *env;
2770 ssize_t nchr = OPT_LEN_MAX;
2773 if (strlen(opt) + 1 > OPT_LEN_MAX) {
2774 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
2778 in[OPT_LEN_MAX] = '\0';
2779 strncpy(in, opt, OPT_LEN_MAX);
2781 while (*inptr && nchr > 0) {
2782 if (inptr[0] == '$' && inptr[1] == '{') {
2783 ch2 = strchr(inptr, '}');
2784 if (ch2 && inptr+1 < ch2) {
2791 envlen = strlen(env);
2792 if (envlen <= nchr) {
2793 memcpy(outptr, env, envlen);
2803 *outptr++ = *inptr++;
2812 * Look for reserved variable names and replace them with real values
2814 static char *fio_keyword_replace(char *opt)
2820 for (i = 0; fio_keywords[i].word != NULL; i++) {
2821 struct fio_keyword *kw = &fio_keywords[i];
2823 while ((s = strstr(opt, kw->word)) != NULL) {
2824 char *new = malloc(strlen(opt) + 1);
2830 * Copy part of the string before the keyword and
2831 * sprintf() the replacement after it.
2833 memcpy(new, opt, olen);
2834 len = sprintf(new + olen, "%s", kw->replace);
2837 * If there's more in the original string, copy that
2840 opt += strlen(kw->word) + olen;
2842 memcpy(new + olen + len, opt, opt - o_org - 1);
2845 * replace opt and free the old opt
2855 * Check for potential math and invoke bc, if possible
2863 static char **dup_and_sub_options(char **opts, int num_opts)
2866 char **opts_copy = malloc(num_opts * sizeof(*opts));
2867 for (i = 0; i < num_opts; i++) {
2868 opts_copy[i] = option_dup_subs(opts[i]);
2871 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
2876 int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
2878 int i, ret, unknown;
2881 sort_options(opts, options, num_opts);
2882 opts_copy = dup_and_sub_options(opts, num_opts);
2884 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
2885 struct fio_option *o;
2886 int newret = parse_option(opts_copy[i], opts[i], options, &o,
2895 opts_copy[i] = NULL;
2902 ret |= ioengine_load(td);
2904 sort_options(opts_copy, td->io_ops->options, num_opts);
2907 for (i = 0; i < num_opts; i++) {
2908 struct fio_option *o = NULL;
2914 newret = parse_option(opts_copy[i], opts[i],
2915 td->io_ops->options, &o,
2920 log_err("Bad option <%s>\n", opts[i]);
2923 opts_copy[i] = NULL;
2931 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
2933 return parse_cmd_option(opt, val, options, td);
2936 int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
2939 return parse_cmd_option(opt, val, td->io_ops->options, td);
2942 void fio_fill_default_options(struct thread_data *td)
2944 fill_default_options(td, options);
2947 int fio_show_option_help(const char *opt)
2949 return show_cmd_help(options, opt);
2952 void options_mem_dupe(void *data, struct fio_option *options)
2954 struct fio_option *o;
2957 for (o = &options[0]; o->name; o++) {
2958 if (o->type != FIO_OPT_STR_STORE)
2961 ptr = td_var(data, o->off1);
2963 *ptr = strdup(*ptr);
2968 * dupe FIO_OPT_STR_STORE options
2970 void fio_options_mem_dupe(struct thread_data *td)
2972 options_mem_dupe(&td->o, options);
2974 if (td->eo && td->io_ops) {
2975 void *oldeo = td->eo;
2977 td->eo = malloc(td->io_ops->option_struct_size);
2978 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
2979 options_mem_dupe(td->eo, td->io_ops->options);
2983 unsigned int fio_get_kb_base(void *data)
2985 struct thread_data *td = data;
2986 unsigned int kb_base = 0;
2989 kb_base = td->o.kb_base;
2996 int add_option(struct fio_option *o)
2998 struct fio_option *__o;
3007 memcpy(&options[opt_index], o, sizeof(*o));
3011 void invalidate_profile_options(const char *prof_name)
3013 struct fio_option *o;
3017 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
3018 o->type = FIO_OPT_INVALID;
3019 o->prof_name = NULL;
3025 void add_opt_posval(const char *optname, const char *ival, const char *help)
3027 struct fio_option *o;
3030 o = find_option(options, optname);
3034 for (i = 0; i < PARSE_MAX_VP; i++) {
3035 if (o->posval[i].ival)
3038 o->posval[i].ival = ival;
3039 o->posval[i].help = help;
3044 void del_opt_posval(const char *optname, const char *ival)
3046 struct fio_option *o;
3049 o = find_option(options, optname);
3053 for (i = 0; i < PARSE_MAX_VP; i++) {
3054 if (!o->posval[i].ival)
3056 if (strcmp(o->posval[i].ival, ival))
3059 o->posval[i].ival = NULL;
3060 o->posval[i].help = NULL;
3064 void fio_options_free(struct thread_data *td)
3066 options_free(options, td);
3067 if (td->eo && td->io_ops && td->io_ops->options) {
3068 options_free(td->io_ops->options, td->eo);