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;
373 fio_clock_source_set = 1;
378 static int str_lockmem_cb(void fio_unused *data, unsigned long long *val)
384 static int str_rwmix_read_cb(void *data, unsigned long long *val)
386 struct thread_data *td = data;
388 td->o.rwmix[DDIR_READ] = *val;
389 td->o.rwmix[DDIR_WRITE] = 100 - *val;
393 static int str_rwmix_write_cb(void *data, unsigned long long *val)
395 struct thread_data *td = data;
397 td->o.rwmix[DDIR_WRITE] = *val;
398 td->o.rwmix[DDIR_READ] = 100 - *val;
402 #ifdef FIO_HAVE_IOPRIO
403 static int str_prioclass_cb(void *data, unsigned long long *val)
405 struct thread_data *td = data;
409 * mask off old class bits, str_prio_cb() may have set a default class
411 mask = (1 << IOPRIO_CLASS_SHIFT) - 1;
414 td->ioprio |= *val << IOPRIO_CLASS_SHIFT;
419 static int str_prio_cb(void *data, unsigned long long *val)
421 struct thread_data *td = data;
426 * If no class is set, assume BE
428 if ((td->ioprio >> IOPRIO_CLASS_SHIFT) == 0)
429 td->ioprio |= IOPRIO_CLASS_BE << IOPRIO_CLASS_SHIFT;
436 static int str_exitall_cb(void)
438 exitall_on_terminate = 1;
442 #ifdef FIO_HAVE_CPU_AFFINITY
443 static int str_cpumask_cb(void *data, unsigned long long *val)
445 struct thread_data *td = data;
450 ret = fio_cpuset_init(&td->o.cpumask);
452 log_err("fio: cpuset_init failed\n");
453 td_verror(td, ret, "fio_cpuset_init");
457 max_cpu = cpus_online();
459 for (i = 0; i < sizeof(int) * 8; i++) {
460 if ((1 << i) & *val) {
462 log_err("fio: CPU %d too large (max=%ld)\n", i,
466 dprint(FD_PARSE, "set cpu allowed %d\n", i);
467 fio_cpu_set(&td->o.cpumask, i);
471 td->o.cpumask_set = 1;
475 static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask,
482 ret = fio_cpuset_init(mask);
484 log_err("fio: cpuset_init failed\n");
485 td_verror(td, ret, "fio_cpuset_init");
489 p = str = strdup(input);
491 strip_blank_front(&str);
492 strip_blank_end(str);
494 max_cpu = cpus_online();
496 while ((cpu = strsep(&str, ",")) != NULL) {
505 while ((cpu2 = strsep(&str2, "-")) != NULL) {
515 while (icpu <= icpu2) {
516 if (icpu >= FIO_MAX_CPUS) {
517 log_err("fio: your OS only supports up to"
518 " %d CPUs\n", (int) FIO_MAX_CPUS);
522 if (icpu > max_cpu) {
523 log_err("fio: CPU %d too large (max=%ld)\n",
529 dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
530 fio_cpu_set(mask, icpu);
539 td->o.cpumask_set = 1;
543 static int str_cpus_allowed_cb(void *data, const char *input)
545 struct thread_data *td = data;
548 ret = set_cpus_allowed(td, &td->o.cpumask, input);
550 td->o.cpumask_set = 1;
555 static int str_verify_cpus_allowed_cb(void *data, const char *input)
557 struct thread_data *td = data;
560 ret = set_cpus_allowed(td, &td->o.verify_cpumask, input);
562 td->o.verify_cpumask_set = 1;
568 #ifdef FIO_HAVE_LIBNUMA
569 static int str_numa_cpunodes_cb(void *data, char *input)
571 struct thread_data *td = data;
573 /* numa_parse_nodestring() parses a character string list
574 * of nodes into a bit mask. The bit mask is allocated by
575 * numa_allocate_nodemask(), so it should be freed by
576 * numa_free_nodemask().
578 td->o.numa_cpunodesmask = numa_parse_nodestring(input);
579 if (td->o.numa_cpunodesmask == NULL) {
580 log_err("fio: numa_parse_nodestring failed\n");
581 td_verror(td, 1, "str_numa_cpunodes_cb");
585 td->o.numa_cpumask_set = 1;
589 static int str_numa_mpol_cb(void *data, char *input)
591 struct thread_data *td = data;
592 const char * const policy_types[] =
593 { "default", "prefer", "bind", "interleave", "local" };
596 char *nodelist = strchr(input, ':');
598 /* NUL-terminate mode */
602 for (i = 0; i <= MPOL_LOCAL; i++) {
603 if (!strcmp(input, policy_types[i])) {
604 td->o.numa_mem_mode = i;
608 if (i > MPOL_LOCAL) {
609 log_err("fio: memory policy should be: default, prefer, bind, interleave, local\n");
613 switch (td->o.numa_mem_mode) {
616 * Insist on a nodelist of one node only
619 char *rest = nodelist;
620 while (isdigit(*rest))
623 log_err("fio: one node only for \'prefer\'\n");
627 log_err("fio: one node is needed for \'prefer\'\n");
631 case MPOL_INTERLEAVE:
633 * Default to online nodes with memory if no nodelist
636 nodelist = strdup("all");
641 * Don't allow a nodelist
644 log_err("fio: NO nodelist for \'local\'\n");
650 * Insist on a nodelist
653 log_err("fio: a nodelist is needed for \'bind\'\n");
660 /* numa_parse_nodestring() parses a character string list
661 * of nodes into a bit mask. The bit mask is allocated by
662 * numa_allocate_nodemask(), so it should be freed by
663 * numa_free_nodemask().
665 switch (td->o.numa_mem_mode) {
667 td->o.numa_mem_prefer_node = atoi(nodelist);
669 case MPOL_INTERLEAVE:
671 td->o.numa_memnodesmask = numa_parse_nodestring(nodelist);
672 if (td->o.numa_memnodesmask == NULL) {
673 log_err("fio: numa_parse_nodestring failed\n");
674 td_verror(td, 1, "str_numa_memnodes_cb");
684 td->o.numa_memmask_set = 1;
693 static int str_verify_trim_cb(void *data, unsigned long long *val)
695 struct thread_data *td = data;
697 td->o.trim_percentage = *val;
702 static int str_fst_cb(void *data, const char *str)
704 struct thread_data *td = data;
705 char *nr = get_opt_postfix(str);
707 td->file_service_nr = 1;
709 td->file_service_nr = atoi(nr);
716 #ifdef FIO_HAVE_SYNC_FILE_RANGE
717 static int str_sfr_cb(void *data, const char *str)
719 struct thread_data *td = data;
720 char *nr = get_opt_postfix(str);
722 td->sync_file_range_nr = 1;
724 td->sync_file_range_nr = atoi(nr);
732 static int str_random_distribution_cb(void *data, const char *str)
734 struct thread_data *td = data;
738 if (td->o.random_distribution == FIO_RAND_DIST_ZIPF)
740 else if (td->o.random_distribution == FIO_RAND_DIST_PARETO)
745 nr = get_opt_postfix(str);
746 if (nr && !str_to_float(nr, &val)) {
747 log_err("fio: random postfix parsing failed\n");
754 if (td->o.random_distribution == FIO_RAND_DIST_ZIPF) {
756 log_err("fio: zipf theta must different than 1.0\n");
759 td->o.zipf_theta = val;
761 if (val <= 0.00 || val >= 1.00) {
762 log_err("fio: pareto input out of range (0 < input < 1.0)\n");
765 td->o.pareto_h = val;
771 static int check_dir(struct thread_data *td, char *fname)
774 char file[PATH_MAX], *dir;
777 if (td->o.directory) {
778 strcpy(file, td->o.directory);
783 sprintf(file + elen, "%s", fname);
789 * We can't do this on FIO_DISKLESSIO engines. The engine isn't loaded
790 * yet, so we can't do this check right here...
792 if (lstat(dir, &sb) < 0) {
795 log_err("fio: %s is not a directory\n", dir);
796 td_verror(td, ret, "lstat");
800 if (!S_ISDIR(sb.st_mode)) {
801 log_err("fio: %s is not a directory\n", dir);
811 * Return next file in the string. Files are separated with ':'. If the ':'
812 * is escaped with a '\', then that ':' is part of the filename and does not
813 * indicate a new file.
815 static char *get_next_file_name(char **ptr)
820 if (!str || !strlen(str))
826 * No colon, we are done
828 p = strchr(str, ':');
835 * We got a colon, but it's the first character. Skip and
843 if (*(p - 1) != '\\') {
849 memmove(p - 1, p, strlen(p) + 1);
856 static int str_filename_cb(void *data, const char *input)
858 struct thread_data *td = data;
859 char *fname, *str, *p;
861 p = str = strdup(input);
863 strip_blank_front(&str);
864 strip_blank_end(str);
866 if (!td->files_index)
869 while ((fname = get_next_file_name(&str)) != NULL) {
872 if (check_dir(td, fname)) {
884 static int str_directory_cb(void *data, const char fio_unused *str)
886 struct thread_data *td = data;
889 if (lstat(td->o.directory, &sb) < 0) {
892 log_err("fio: %s is not a directory\n", td->o.directory);
893 td_verror(td, ret, "lstat");
896 if (!S_ISDIR(sb.st_mode)) {
897 log_err("fio: %s is not a directory\n", td->o.directory);
904 static int str_opendir_cb(void *data, const char fio_unused *str)
906 struct thread_data *td = data;
908 if (!td->files_index)
911 return add_dir_files(td, td->o.opendir);
914 static int str_verify_offset_cb(void *data, unsigned long long *off)
916 struct thread_data *td = data;
918 if (*off && *off < sizeof(struct verify_header)) {
919 log_err("fio: verify_offset too small\n");
923 td->o.verify_offset = *off;
927 static int str_verify_pattern_cb(void *data, const char *input)
929 struct thread_data *td = data;
931 int i = 0, j = 0, len, k, base = 10;
934 loc1 = strstr(input, "0x");
935 loc2 = strstr(input, "0X");
938 off = strtol(input, NULL, base);
939 if (off != LONG_MAX || errno != ERANGE) {
941 td->o.verify_pattern[i] = off & 0xff;
950 j = loc1 - input + 2;
952 j = loc2 - input + 2;
955 if (len - j < MAX_PATTERN_SIZE * 2) {
957 off = converthexchartoint(input[k--]);
959 off += (converthexchartoint(input[k--])
961 td->o.verify_pattern[i++] = (char) off;
967 * Fill the pattern all the way to the end. This greatly reduces
968 * the number of memcpy's we have to do when verifying the IO.
970 while (i > 1 && i * 2 <= MAX_PATTERN_SIZE) {
971 memcpy(&td->o.verify_pattern[i], &td->o.verify_pattern[0], i);
976 * The code in verify_io_u_pattern assumes a single byte pattern
977 * fills the whole verify pattern buffer.
979 memset(td->o.verify_pattern, td->o.verify_pattern[0],
983 td->o.verify_pattern_bytes = i;
986 * VERIFY_META could already be set
988 if (td->o.verify == VERIFY_NONE)
989 td->o.verify = VERIFY_PATTERN;
994 static int str_lockfile_cb(void *data, const char *str)
996 struct thread_data *td = data;
997 char *nr = get_opt_postfix(str);
999 td->o.lockfile_batch = 1;
1001 td->o.lockfile_batch = atoi(nr);
1008 static int str_write_bw_log_cb(void *data, const char *str)
1010 struct thread_data *td = data;
1013 td->o.bw_log_file = strdup(str);
1015 td->o.write_bw_log = 1;
1019 static int str_write_lat_log_cb(void *data, const char *str)
1021 struct thread_data *td = data;
1024 td->o.lat_log_file = strdup(str);
1026 td->o.write_lat_log = 1;
1030 static int str_write_iops_log_cb(void *data, const char *str)
1032 struct thread_data *td = data;
1035 td->o.iops_log_file = strdup(str);
1037 td->o.write_iops_log = 1;
1041 static int str_gtod_reduce_cb(void *data, int *il)
1043 struct thread_data *td = data;
1046 td->o.disable_lat = !!val;
1047 td->o.disable_clat = !!val;
1048 td->o.disable_slat = !!val;
1049 td->o.disable_bw = !!val;
1050 td->o.clat_percentiles = !val;
1052 td->tv_cache_mask = 63;
1057 static int str_gtod_cpu_cb(void *data, long long *il)
1059 struct thread_data *td = data;
1062 td->o.gtod_cpu = val;
1063 td->o.gtod_offload = 1;
1067 static int str_size_cb(void *data, unsigned long long *__val)
1069 struct thread_data *td = data;
1070 unsigned long long v = *__val;
1072 if (parse_is_percent(v)) {
1074 td->o.size_percent = -1ULL - v;
1081 static int rw_verify(struct fio_option *o, void *data)
1083 struct thread_data *td = data;
1085 if (read_only && td_write(td)) {
1086 log_err("fio: job <%s> has write bit set, but fio is in"
1087 " read-only mode\n", td->o.name);
1094 static int gtod_cpu_verify(struct fio_option *o, void *data)
1096 #ifndef FIO_HAVE_CPU_AFFINITY
1097 struct thread_data *td = data;
1099 if (td->o.gtod_cpu) {
1100 log_err("fio: platform must support CPU affinity for"
1101 "gettimeofday() offloading\n");
1109 static int kb_base_verify(struct fio_option *o, void *data)
1111 struct thread_data *td = data;
1113 if (td->o.kb_base != 1024 && td->o.kb_base != 1000) {
1114 log_err("fio: kb_base set to nonsensical value: %u\n",
1123 * Map of job/command line options
1125 static struct fio_option options[FIO_MAX_OPTS] = {
1127 .name = "description",
1128 .type = FIO_OPT_STR_STORE,
1129 .off1 = td_var_offset(description),
1130 .help = "Text job description",
1134 .type = FIO_OPT_STR_STORE,
1135 .off1 = td_var_offset(name),
1136 .help = "Name of this job",
1139 .name = "directory",
1140 .type = FIO_OPT_STR_STORE,
1141 .off1 = td_var_offset(directory),
1142 .cb = str_directory_cb,
1143 .help = "Directory to store files in",
1147 .type = FIO_OPT_STR_STORE,
1148 .off1 = td_var_offset(filename),
1149 .cb = str_filename_cb,
1150 .prio = -1, /* must come after "directory" */
1151 .help = "File(s) to use for the workload",
1155 .type = FIO_OPT_INT,
1156 .off1 = td_var_offset(kb_base),
1157 .verify = kb_base_verify,
1160 .help = "How many bytes per KB for reporting (1000 or 1024)",
1164 .type = FIO_OPT_STR,
1165 .cb = str_lockfile_cb,
1166 .off1 = td_var_offset(file_lock_mode),
1167 .help = "Lock file when doing IO to it",
1168 .parent = "filename",
1172 .oval = FILE_LOCK_NONE,
1173 .help = "No file locking",
1175 { .ival = "exclusive",
1176 .oval = FILE_LOCK_EXCLUSIVE,
1177 .help = "Exclusive file lock",
1180 .ival = "readwrite",
1181 .oval = FILE_LOCK_READWRITE,
1182 .help = "Read vs write lock",
1188 .type = FIO_OPT_STR_STORE,
1189 .off1 = td_var_offset(opendir),
1190 .cb = str_opendir_cb,
1191 .help = "Recursively add files from this directory and down",
1195 .alias = "readwrite",
1196 .type = FIO_OPT_STR,
1198 .off1 = td_var_offset(td_ddir),
1199 .help = "IO direction",
1201 .verify = rw_verify,
1204 .oval = TD_DDIR_READ,
1205 .help = "Sequential read",
1208 .oval = TD_DDIR_WRITE,
1209 .help = "Sequential write",
1212 .oval = TD_DDIR_TRIM,
1213 .help = "Sequential trim",
1215 { .ival = "randread",
1216 .oval = TD_DDIR_RANDREAD,
1217 .help = "Random read",
1219 { .ival = "randwrite",
1220 .oval = TD_DDIR_RANDWRITE,
1221 .help = "Random write",
1223 { .ival = "randtrim",
1224 .oval = TD_DDIR_RANDTRIM,
1225 .help = "Random trim",
1229 .help = "Sequential read and write mix",
1231 { .ival = "readwrite",
1233 .help = "Sequential read and write mix",
1236 .oval = TD_DDIR_RANDRW,
1237 .help = "Random read and write mix"
1242 .name = "rw_sequencer",
1243 .type = FIO_OPT_STR,
1244 .off1 = td_var_offset(rw_seq),
1245 .help = "IO offset generator modifier",
1246 .def = "sequential",
1248 { .ival = "sequential",
1250 .help = "Generate sequential offsets",
1252 { .ival = "identical",
1253 .oval = RW_SEQ_IDENT,
1254 .help = "Generate identical offsets",
1261 .type = FIO_OPT_STR_STORE,
1262 .off1 = td_var_offset(ioengine),
1263 .help = "IO engine to use",
1264 .def = FIO_PREFERRED_ENGINE,
1267 .help = "Use read/write",
1270 .help = "Use pread/pwrite",
1273 .help = "Use readv/writev",
1275 #ifdef FIO_HAVE_LIBAIO
1277 .help = "Linux native asynchronous IO",
1280 #ifdef FIO_HAVE_POSIXAIO
1281 { .ival = "posixaio",
1282 .help = "POSIX asynchronous IO",
1285 #ifdef FIO_HAVE_SOLARISAIO
1286 { .ival = "solarisaio",
1287 .help = "Solaris native asynchronous IO",
1290 #ifdef FIO_HAVE_WINDOWSAIO
1291 { .ival = "windowsaio",
1292 .help = "Windows native asynchronous IO"
1296 .help = "Memory mapped IO"
1298 #ifdef FIO_HAVE_SPLICE
1300 .help = "splice/vmsplice based IO",
1302 { .ival = "netsplice",
1303 .help = "splice/vmsplice to/from the network",
1306 #ifdef FIO_HAVE_SGIO
1308 .help = "SCSI generic v3 IO",
1312 .help = "Testing engine (no data transfer)",
1315 .help = "Network IO",
1317 #ifdef FIO_HAVE_SYSLET
1318 { .ival = "syslet-rw",
1319 .help = "syslet enabled async pread/pwrite IO",
1323 .help = "CPU cycle burner engine",
1325 #ifdef FIO_HAVE_GUASI
1327 .help = "GUASI IO engine",
1330 #ifdef FIO_HAVE_BINJECT
1331 { .ival = "binject",
1332 .help = "binject direct inject block engine",
1335 #ifdef FIO_HAVE_RDMA
1337 .help = "RDMA IO engine",
1340 #ifdef FIO_HAVE_FUSION_AW
1341 { .ival = "fusion-aw-sync",
1342 .help = "Fusion-io atomic write engine",
1345 #ifdef FIO_HAVE_E4_ENG
1346 { .ival = "e4defrag",
1347 .help = "ext4 defrag engine",
1350 #ifdef FIO_HAVE_FALLOC_ENG
1352 .help = "fallocate() file based engine",
1355 { .ival = "external",
1356 .help = "Load external engine (append name)",
1362 .type = FIO_OPT_INT,
1363 .off1 = td_var_offset(iodepth),
1364 .help = "Number of IO buffers to keep in flight",
1369 .name = "iodepth_batch",
1370 .alias = "iodepth_batch_submit",
1371 .type = FIO_OPT_INT,
1372 .off1 = td_var_offset(iodepth_batch),
1373 .help = "Number of IO buffers to submit in one go",
1374 .parent = "iodepth",
1379 .name = "iodepth_batch_complete",
1380 .type = FIO_OPT_INT,
1381 .off1 = td_var_offset(iodepth_batch_complete),
1382 .help = "Number of IO buffers to retrieve in one go",
1383 .parent = "iodepth",
1388 .name = "iodepth_low",
1389 .type = FIO_OPT_INT,
1390 .off1 = td_var_offset(iodepth_low),
1391 .help = "Low water mark for queuing depth",
1392 .parent = "iodepth",
1396 .type = FIO_OPT_STR_VAL,
1398 .help = "Total size of device or files",
1401 .name = "fill_device",
1403 .type = FIO_OPT_BOOL,
1404 .off1 = td_var_offset(fill_device),
1405 .help = "Write until an ENOSPC error occurs",
1410 .type = FIO_OPT_STR_VAL,
1411 .off1 = td_var_offset(file_size_low),
1412 .off2 = td_var_offset(file_size_high),
1414 .help = "Size of individual files",
1418 .alias = "fileoffset",
1419 .type = FIO_OPT_STR_VAL,
1420 .off1 = td_var_offset(start_offset),
1421 .help = "Start IO from this offset",
1425 .name = "offset_increment",
1426 .type = FIO_OPT_STR_VAL,
1427 .off1 = td_var_offset(offset_increment),
1428 .help = "What is the increment from one offset to the next",
1434 .alias = "blocksize",
1435 .type = FIO_OPT_INT,
1436 .off1 = td_var_offset(bs[DDIR_READ]),
1437 .off2 = td_var_offset(bs[DDIR_WRITE]),
1438 .off3 = td_var_offset(bs[DDIR_TRIM]),
1440 .help = "Block size unit",
1446 .alias = "blockalign",
1447 .type = FIO_OPT_INT,
1448 .off1 = td_var_offset(ba[DDIR_READ]),
1449 .off2 = td_var_offset(ba[DDIR_WRITE]),
1450 .off3 = td_var_offset(ba[DDIR_TRIM]),
1452 .help = "IO block offset alignment",
1457 .alias = "blocksize_range",
1458 .type = FIO_OPT_RANGE,
1459 .off1 = td_var_offset(min_bs[DDIR_READ]),
1460 .off2 = td_var_offset(max_bs[DDIR_READ]),
1461 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
1462 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
1463 .off5 = td_var_offset(min_bs[DDIR_TRIM]),
1464 .off6 = td_var_offset(max_bs[DDIR_TRIM]),
1466 .help = "Set block size range (in more detail than bs)",
1471 .type = FIO_OPT_STR,
1472 .cb = str_bssplit_cb,
1473 .help = "Set a specific mix of block sizes",
1477 .name = "bs_unaligned",
1478 .alias = "blocksize_unaligned",
1479 .type = FIO_OPT_STR_SET,
1480 .off1 = td_var_offset(bs_unaligned),
1481 .help = "Don't sector align IO buffer sizes",
1485 .name = "randrepeat",
1486 .type = FIO_OPT_BOOL,
1487 .off1 = td_var_offset(rand_repeatable),
1488 .help = "Use repeatable random IO pattern",
1493 .name = "use_os_rand",
1494 .type = FIO_OPT_BOOL,
1495 .off1 = td_var_offset(use_os_rand),
1496 .help = "Set to use OS random generator",
1501 .name = "norandommap",
1502 .type = FIO_OPT_STR_SET,
1503 .off1 = td_var_offset(norandommap),
1504 .help = "Accept potential duplicate random blocks",
1508 .name = "softrandommap",
1509 .type = FIO_OPT_BOOL,
1510 .off1 = td_var_offset(softrandommap),
1511 .help = "Set norandommap if randommap allocation fails",
1512 .parent = "norandommap",
1516 .name = "random_generator",
1517 .type = FIO_OPT_STR,
1518 .off1 = td_var_offset(random_generator),
1519 .help = "Type of random number generator to use",
1520 .def = "tausworthe",
1522 { .ival = "tausworthe",
1523 .oval = FIO_RAND_GEN_TAUSWORTHE,
1524 .help = "Strong Tausworthe generator",
1527 .oval = FIO_RAND_GEN_LFSR,
1528 .help = "Variable length LFSR",
1533 .name = "random_distribution",
1534 .type = FIO_OPT_STR,
1535 .off1 = td_var_offset(random_distribution),
1536 .cb = str_random_distribution_cb,
1537 .help = "Random offset distribution generator",
1541 .oval = FIO_RAND_DIST_RANDOM,
1542 .help = "Completely random",
1545 .oval = FIO_RAND_DIST_ZIPF,
1546 .help = "Zipf distribution",
1549 .oval = FIO_RAND_DIST_PARETO,
1550 .help = "Pareto distribution",
1556 .alias = "nr_files",
1557 .type = FIO_OPT_INT,
1558 .off1 = td_var_offset(nr_files),
1559 .help = "Split job workload between this number of files",
1563 .name = "openfiles",
1564 .type = FIO_OPT_INT,
1565 .off1 = td_var_offset(open_files),
1566 .help = "Number of files to keep open at the same time",
1569 .name = "file_service_type",
1570 .type = FIO_OPT_STR,
1572 .off1 = td_var_offset(file_service_type),
1573 .help = "How to select which file to service next",
1574 .def = "roundrobin",
1577 .oval = FIO_FSERVICE_RANDOM,
1578 .help = "Choose a file at random",
1580 { .ival = "roundrobin",
1581 .oval = FIO_FSERVICE_RR,
1582 .help = "Round robin select files",
1584 { .ival = "sequential",
1585 .oval = FIO_FSERVICE_SEQ,
1586 .help = "Finish one file before moving to the next",
1589 .parent = "nrfiles",
1591 #ifdef FIO_HAVE_FALLOCATE
1593 .name = "fallocate",
1594 .type = FIO_OPT_STR,
1595 .off1 = td_var_offset(fallocate_mode),
1596 .help = "Whether pre-allocation is performed when laying out files",
1600 .oval = FIO_FALLOCATE_NONE,
1601 .help = "Do not pre-allocate space",
1604 .oval = FIO_FALLOCATE_POSIX,
1605 .help = "Use posix_fallocate()",
1607 #ifdef FIO_HAVE_LINUX_FALLOCATE
1609 .oval = FIO_FALLOCATE_KEEP_SIZE,
1610 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
1613 /* Compatibility with former boolean values */
1615 .oval = FIO_FALLOCATE_NONE,
1616 .help = "Alias for 'none'",
1619 .oval = FIO_FALLOCATE_POSIX,
1620 .help = "Alias for 'posix'",
1624 #endif /* FIO_HAVE_FALLOCATE */
1626 .name = "fadvise_hint",
1627 .type = FIO_OPT_BOOL,
1628 .off1 = td_var_offset(fadvise_hint),
1629 .help = "Use fadvise() to advise the kernel on IO pattern",
1634 .type = FIO_OPT_INT,
1635 .off1 = td_var_offset(fsync_blocks),
1636 .help = "Issue fsync for writes every given number of blocks",
1640 .name = "fdatasync",
1641 .type = FIO_OPT_INT,
1642 .off1 = td_var_offset(fdatasync_blocks),
1643 .help = "Issue fdatasync for writes every given number of blocks",
1647 .name = "write_barrier",
1648 .type = FIO_OPT_INT,
1649 .off1 = td_var_offset(barrier_blocks),
1650 .help = "Make every Nth write a barrier write",
1653 #ifdef FIO_HAVE_SYNC_FILE_RANGE
1655 .name = "sync_file_range",
1657 { .ival = "wait_before",
1658 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
1659 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
1663 .oval = SYNC_FILE_RANGE_WRITE,
1664 .help = "SYNC_FILE_RANGE_WRITE",
1668 .ival = "wait_after",
1669 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
1670 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
1674 .type = FIO_OPT_STR_MULTI,
1676 .off1 = td_var_offset(sync_file_range),
1677 .help = "Use sync_file_range()",
1682 .type = FIO_OPT_BOOL,
1683 .off1 = td_var_offset(odirect),
1684 .help = "Use O_DIRECT IO (negates buffered)",
1689 .type = FIO_OPT_BOOL,
1690 .off1 = td_var_offset(odirect),
1692 .help = "Use buffered IO (negates direct)",
1696 .name = "overwrite",
1697 .type = FIO_OPT_BOOL,
1698 .off1 = td_var_offset(overwrite),
1699 .help = "When writing, set whether to overwrite current data",
1704 .type = FIO_OPT_INT,
1705 .off1 = td_var_offset(loops),
1706 .help = "Number of times to run the job",
1711 .type = FIO_OPT_INT,
1712 .off1 = td_var_offset(numjobs),
1713 .help = "Duplicate this job this many times",
1717 .name = "startdelay",
1718 .type = FIO_OPT_STR_VAL_TIME,
1719 .off1 = td_var_offset(start_delay),
1720 .help = "Only start job when this period has passed",
1726 .type = FIO_OPT_STR_VAL_TIME,
1727 .off1 = td_var_offset(timeout),
1728 .help = "Stop workload when this amount of time has passed",
1732 .name = "time_based",
1733 .type = FIO_OPT_STR_SET,
1734 .off1 = td_var_offset(time_based),
1735 .help = "Keep running until runtime/timeout is met",
1738 .name = "ramp_time",
1739 .type = FIO_OPT_STR_VAL_TIME,
1740 .off1 = td_var_offset(ramp_time),
1741 .help = "Ramp up time before measuring performance",
1744 .name = "clocksource",
1745 .type = FIO_OPT_STR,
1746 .cb = fio_clock_source_cb,
1747 .off1 = td_var_offset(clocksource),
1748 .help = "What type of timing source to use",
1750 { .ival = "gettimeofday",
1752 .help = "Use gettimeofday(2) for timing",
1754 { .ival = "clock_gettime",
1755 .oval = CS_CGETTIME,
1756 .help = "Use clock_gettime(2) for timing",
1758 #ifdef ARCH_HAVE_CPU_CLOCK
1760 .oval = CS_CPUCLOCK,
1761 .help = "Use CPU private clock",
1769 .type = FIO_OPT_STR,
1771 .off1 = td_var_offset(mem_type),
1772 .help = "Backing type for IO buffers",
1777 .help = "Use malloc(3) for IO buffers",
1781 .help = "Use shared memory segments for IO buffers",
1783 #ifdef FIO_HAVE_HUGETLB
1784 { .ival = "shmhuge",
1785 .oval = MEM_SHMHUGE,
1786 .help = "Like shm, but use huge pages",
1791 .help = "Use mmap(2) (file or anon) for IO buffers",
1793 #ifdef FIO_HAVE_HUGETLB
1794 { .ival = "mmaphuge",
1795 .oval = MEM_MMAPHUGE,
1796 .help = "Like mmap, but use huge pages",
1802 .name = "iomem_align",
1803 .alias = "mem_align",
1804 .type = FIO_OPT_INT,
1805 .off1 = td_var_offset(mem_align),
1807 .help = "IO memory buffer offset alignment",
1813 .type = FIO_OPT_STR,
1814 .off1 = td_var_offset(verify),
1815 .help = "Verify data written",
1816 .cb = str_verify_cb,
1820 .oval = VERIFY_NONE,
1821 .help = "Don't do IO verification",
1825 .help = "Use md5 checksums for verification",
1828 .oval = VERIFY_CRC64,
1829 .help = "Use crc64 checksums for verification",
1832 .oval = VERIFY_CRC32,
1833 .help = "Use crc32 checksums for verification",
1835 { .ival = "crc32c-intel",
1836 .oval = VERIFY_CRC32C,
1837 .help = "Use crc32c checksums for verification (hw assisted, if available)",
1840 .oval = VERIFY_CRC32C,
1841 .help = "Use crc32c checksums for verification (hw assisted, if available)",
1844 .oval = VERIFY_CRC16,
1845 .help = "Use crc16 checksums for verification",
1848 .oval = VERIFY_CRC7,
1849 .help = "Use crc7 checksums for verification",
1852 .oval = VERIFY_SHA1,
1853 .help = "Use sha1 checksums for verification",
1856 .oval = VERIFY_SHA256,
1857 .help = "Use sha256 checksums for verification",
1860 .oval = VERIFY_SHA512,
1861 .help = "Use sha512 checksums for verification",
1864 .oval = VERIFY_META,
1865 .help = "Use io information",
1869 .oval = VERIFY_NULL,
1870 .help = "Pretend to verify",
1875 .name = "do_verify",
1876 .type = FIO_OPT_BOOL,
1877 .off1 = td_var_offset(do_verify),
1878 .help = "Run verification stage after write",
1883 .name = "verifysort",
1884 .type = FIO_OPT_BOOL,
1885 .off1 = td_var_offset(verifysort),
1886 .help = "Sort written verify blocks for read back",
1891 .name = "verify_interval",
1892 .type = FIO_OPT_INT,
1893 .off1 = td_var_offset(verify_interval),
1894 .minval = 2 * sizeof(struct verify_header),
1895 .help = "Store verify buffer header every N bytes",
1899 .name = "verify_offset",
1900 .type = FIO_OPT_INT,
1901 .help = "Offset verify header location by N bytes",
1903 .cb = str_verify_offset_cb,
1907 .name = "verify_pattern",
1908 .type = FIO_OPT_STR,
1909 .cb = str_verify_pattern_cb,
1910 .help = "Fill pattern for IO buffers",
1914 .name = "verify_fatal",
1915 .type = FIO_OPT_BOOL,
1916 .off1 = td_var_offset(verify_fatal),
1918 .help = "Exit on a single verify failure, don't continue",
1922 .name = "verify_dump",
1923 .type = FIO_OPT_BOOL,
1924 .off1 = td_var_offset(verify_dump),
1926 .help = "Dump contents of good and bad blocks on failure",
1930 .name = "verify_async",
1931 .type = FIO_OPT_INT,
1932 .off1 = td_var_offset(verify_async),
1934 .help = "Number of async verifier threads to use",
1938 .name = "verify_backlog",
1939 .type = FIO_OPT_STR_VAL,
1940 .off1 = td_var_offset(verify_backlog),
1941 .help = "Verify after this number of blocks are written",
1945 .name = "verify_backlog_batch",
1946 .type = FIO_OPT_INT,
1947 .off1 = td_var_offset(verify_batch),
1948 .help = "Verify this number of IO blocks",
1951 #ifdef FIO_HAVE_CPU_AFFINITY
1953 .name = "verify_async_cpus",
1954 .type = FIO_OPT_STR,
1955 .cb = str_verify_cpus_allowed_cb,
1956 .help = "Set CPUs allowed for async verify threads",
1957 .parent = "verify_async",
1960 #ifdef FIO_HAVE_TRIM
1962 .name = "trim_percentage",
1963 .type = FIO_OPT_INT,
1964 .cb = str_verify_trim_cb,
1966 .help = "Number of verify blocks to discard/trim",
1971 .name = "trim_verify_zero",
1972 .type = FIO_OPT_INT,
1973 .help = "Verify that trim/discarded blocks are returned as zeroes",
1974 .off1 = td_var_offset(trim_zero),
1975 .parent = "trim_percentage",
1979 .name = "trim_backlog",
1980 .type = FIO_OPT_STR_VAL,
1981 .off1 = td_var_offset(trim_backlog),
1982 .help = "Trim after this number of blocks are written",
1983 .parent = "trim_percentage",
1986 .name = "trim_backlog_batch",
1987 .type = FIO_OPT_INT,
1988 .off1 = td_var_offset(trim_batch),
1989 .help = "Trim this number of IO blocks",
1990 .parent = "trim_percentage",
1994 .name = "write_iolog",
1995 .type = FIO_OPT_STR_STORE,
1996 .off1 = td_var_offset(write_iolog_file),
1997 .help = "Store IO pattern to file",
2000 .name = "read_iolog",
2001 .type = FIO_OPT_STR_STORE,
2002 .off1 = td_var_offset(read_iolog_file),
2003 .help = "Playback IO pattern from file",
2006 .name = "replay_no_stall",
2007 .type = FIO_OPT_INT,
2008 .off1 = td_var_offset(no_stall),
2010 .parent = "read_iolog",
2011 .help = "Playback IO pattern file as fast as possible without stalls",
2014 .name = "replay_redirect",
2015 .type = FIO_OPT_STR_STORE,
2016 .off1 = td_var_offset(replay_redirect),
2017 .parent = "read_iolog",
2018 .help = "Replay all I/O onto this device, regardless of trace device",
2021 .name = "exec_prerun",
2022 .type = FIO_OPT_STR_STORE,
2023 .off1 = td_var_offset(exec_prerun),
2024 .help = "Execute this file prior to running job",
2027 .name = "exec_postrun",
2028 .type = FIO_OPT_STR_STORE,
2029 .off1 = td_var_offset(exec_postrun),
2030 .help = "Execute this file after running job",
2032 #ifdef FIO_HAVE_IOSCHED_SWITCH
2034 .name = "ioscheduler",
2035 .type = FIO_OPT_STR_STORE,
2036 .off1 = td_var_offset(ioscheduler),
2037 .help = "Use this IO scheduler on the backing device",
2042 .type = FIO_OPT_STR_VAL,
2043 .off1 = td_var_offset(zone_size),
2044 .help = "Amount of data to read per zone",
2048 .name = "zonerange",
2049 .type = FIO_OPT_STR_VAL,
2050 .off1 = td_var_offset(zone_range),
2051 .help = "Give size of an IO zone",
2056 .type = FIO_OPT_STR_VAL,
2057 .off1 = td_var_offset(zone_skip),
2058 .help = "Space between IO zones",
2063 .type = FIO_OPT_STR_VAL,
2064 .cb = str_lockmem_cb,
2065 .help = "Lock down this amount of memory",
2069 .name = "rwmixread",
2070 .type = FIO_OPT_INT,
2071 .cb = str_rwmix_read_cb,
2073 .help = "Percentage of mixed workload that is reads",
2077 .name = "rwmixwrite",
2078 .type = FIO_OPT_INT,
2079 .cb = str_rwmix_write_cb,
2081 .help = "Percentage of mixed workload that is writes",
2085 .name = "rwmixcycle",
2086 .type = FIO_OPT_DEPRECATED,
2090 .type = FIO_OPT_INT,
2091 .off1 = td_var_offset(nice),
2092 .help = "Set job CPU nice value",
2097 #ifdef FIO_HAVE_IOPRIO
2100 .type = FIO_OPT_INT,
2102 .help = "Set job IO priority value",
2107 .name = "prioclass",
2108 .type = FIO_OPT_INT,
2109 .cb = str_prioclass_cb,
2110 .help = "Set job IO priority class",
2116 .name = "thinktime",
2117 .type = FIO_OPT_INT,
2118 .off1 = td_var_offset(thinktime),
2119 .help = "Idle time between IO buffers (usec)",
2123 .name = "thinktime_spin",
2124 .type = FIO_OPT_INT,
2125 .off1 = td_var_offset(thinktime_spin),
2126 .help = "Start think time by spinning this amount (usec)",
2128 .parent = "thinktime",
2131 .name = "thinktime_blocks",
2132 .type = FIO_OPT_INT,
2133 .off1 = td_var_offset(thinktime_blocks),
2134 .help = "IO buffer period between 'thinktime'",
2136 .parent = "thinktime",
2140 .type = FIO_OPT_INT,
2141 .off1 = td_var_offset(rate[DDIR_READ]),
2142 .off2 = td_var_offset(rate[DDIR_WRITE]),
2143 .off3 = td_var_offset(rate[DDIR_TRIM]),
2144 .help = "Set bandwidth rate",
2148 .type = FIO_OPT_INT,
2149 .off1 = td_var_offset(ratemin[DDIR_READ]),
2150 .off2 = td_var_offset(ratemin[DDIR_WRITE]),
2151 .off3 = td_var_offset(ratemin[DDIR_TRIM]),
2152 .help = "Job must meet this rate or it will be shutdown",
2156 .name = "rate_iops",
2157 .type = FIO_OPT_INT,
2158 .off1 = td_var_offset(rate_iops[DDIR_READ]),
2159 .off2 = td_var_offset(rate_iops[DDIR_WRITE]),
2160 .off3 = td_var_offset(rate_iops[DDIR_TRIM]),
2161 .help = "Limit IO used to this number of IO operations/sec",
2164 .name = "rate_iops_min",
2165 .type = FIO_OPT_INT,
2166 .off1 = td_var_offset(rate_iops_min[DDIR_READ]),
2167 .off2 = td_var_offset(rate_iops_min[DDIR_WRITE]),
2168 .off3 = td_var_offset(rate_iops_min[DDIR_TRIM]),
2169 .help = "Job must meet this rate or it will be shut down",
2170 .parent = "rate_iops",
2173 .name = "ratecycle",
2174 .type = FIO_OPT_INT,
2175 .off1 = td_var_offset(ratecycle),
2176 .help = "Window average for rate limits (msec)",
2181 .name = "max_latency",
2182 .type = FIO_OPT_INT,
2183 .off1 = td_var_offset(max_latency),
2184 .help = "Maximum tolerated IO latency (usec)",
2187 .name = "invalidate",
2188 .type = FIO_OPT_BOOL,
2189 .off1 = td_var_offset(invalidate_cache),
2190 .help = "Invalidate buffer/page cache prior to running job",
2195 .type = FIO_OPT_BOOL,
2196 .off1 = td_var_offset(sync_io),
2197 .help = "Use O_SYNC for buffered writes",
2199 .parent = "buffered",
2202 .name = "bwavgtime",
2203 .type = FIO_OPT_INT,
2204 .off1 = td_var_offset(bw_avg_time),
2205 .help = "Time window over which to calculate bandwidth"
2208 .parent = "write_bw_log",
2211 .name = "iopsavgtime",
2212 .type = FIO_OPT_INT,
2213 .off1 = td_var_offset(iops_avg_time),
2214 .help = "Time window over which to calculate IOPS (msec)",
2216 .parent = "write_iops_log",
2219 .name = "create_serialize",
2220 .type = FIO_OPT_BOOL,
2221 .off1 = td_var_offset(create_serialize),
2222 .help = "Serialize creating of job files",
2226 .name = "create_fsync",
2227 .type = FIO_OPT_BOOL,
2228 .off1 = td_var_offset(create_fsync),
2229 .help = "fsync file after creation",
2233 .name = "create_on_open",
2234 .type = FIO_OPT_BOOL,
2235 .off1 = td_var_offset(create_on_open),
2236 .help = "Create files when they are opened for IO",
2240 .name = "create_only",
2241 .type = FIO_OPT_BOOL,
2242 .off1 = td_var_offset(create_only),
2243 .help = "Only perform file creation phase",
2248 .type = FIO_OPT_BOOL,
2249 .off1 = td_var_offset(pre_read),
2250 .help = "Pre-read files before starting official testing",
2255 .type = FIO_OPT_INT,
2256 .off1 = td_var_offset(cpuload),
2257 .help = "Use this percentage of CPU",
2260 .name = "cpuchunks",
2261 .type = FIO_OPT_INT,
2262 .off1 = td_var_offset(cpucycle),
2263 .help = "Length of the CPU burn cycles (usecs)",
2265 .parent = "cpuload",
2267 #ifdef FIO_HAVE_CPU_AFFINITY
2270 .type = FIO_OPT_INT,
2271 .cb = str_cpumask_cb,
2272 .help = "CPU affinity mask",
2275 .name = "cpus_allowed",
2276 .type = FIO_OPT_STR,
2277 .cb = str_cpus_allowed_cb,
2278 .help = "Set CPUs allowed",
2281 #ifdef FIO_HAVE_LIBNUMA
2283 .name = "numa_cpu_nodes",
2284 .type = FIO_OPT_STR,
2285 .cb = str_numa_cpunodes_cb,
2286 .help = "NUMA CPU nodes bind",
2289 .name = "numa_mem_policy",
2290 .type = FIO_OPT_STR,
2291 .cb = str_numa_mpol_cb,
2292 .help = "NUMA memory policy setup",
2296 .name = "end_fsync",
2297 .type = FIO_OPT_BOOL,
2298 .off1 = td_var_offset(end_fsync),
2299 .help = "Include fsync at the end of job",
2303 .name = "fsync_on_close",
2304 .type = FIO_OPT_BOOL,
2305 .off1 = td_var_offset(fsync_on_close),
2306 .help = "fsync files on close",
2311 .type = FIO_OPT_BOOL,
2312 .off1 = td_var_offset(unlink),
2313 .help = "Unlink created files after job has completed",
2318 .type = FIO_OPT_STR_SET,
2319 .cb = str_exitall_cb,
2320 .help = "Terminate all jobs when one exits",
2323 .name = "stonewall",
2324 .alias = "wait_for_previous",
2325 .type = FIO_OPT_STR_SET,
2326 .off1 = td_var_offset(stonewall),
2327 .help = "Insert a hard barrier between this job and previous",
2330 .name = "new_group",
2331 .type = FIO_OPT_STR_SET,
2332 .off1 = td_var_offset(new_group),
2333 .help = "Mark the start of a new group (for reporting)",
2337 .type = FIO_OPT_STR_SET,
2338 .off1 = td_var_offset(use_thread),
2339 .help = "Use threads instead of forks",
2342 .name = "write_bw_log",
2343 .type = FIO_OPT_STR,
2344 .off1 = td_var_offset(write_bw_log),
2345 .cb = str_write_bw_log_cb,
2346 .help = "Write log of bandwidth during run",
2349 .name = "write_lat_log",
2350 .type = FIO_OPT_STR,
2351 .off1 = td_var_offset(write_lat_log),
2352 .cb = str_write_lat_log_cb,
2353 .help = "Write log of latency during run",
2356 .name = "write_iops_log",
2357 .type = FIO_OPT_STR,
2358 .off1 = td_var_offset(write_iops_log),
2359 .cb = str_write_iops_log_cb,
2360 .help = "Write log of IOPS during run",
2363 .name = "log_avg_msec",
2364 .type = FIO_OPT_INT,
2365 .off1 = td_var_offset(log_avg_msec),
2366 .help = "Average bw/iops/lat logs over this period of time",
2370 .name = "hugepage-size",
2371 .type = FIO_OPT_INT,
2372 .off1 = td_var_offset(hugepage_size),
2373 .help = "When using hugepages, specify size of each page",
2374 .def = __fio_stringify(FIO_HUGE_PAGE),
2377 .name = "group_reporting",
2378 .type = FIO_OPT_STR_SET,
2379 .off1 = td_var_offset(group_reporting),
2380 .help = "Do reporting on a per-group basis",
2383 .name = "zero_buffers",
2384 .type = FIO_OPT_STR_SET,
2385 .off1 = td_var_offset(zero_buffers),
2386 .help = "Init IO buffers to all zeroes",
2389 .name = "refill_buffers",
2390 .type = FIO_OPT_STR_SET,
2391 .off1 = td_var_offset(refill_buffers),
2392 .help = "Refill IO buffers on every IO submit",
2395 .name = "scramble_buffers",
2396 .type = FIO_OPT_BOOL,
2397 .off1 = td_var_offset(scramble_buffers),
2398 .help = "Slightly scramble buffers on every IO submit",
2402 .name = "buffer_compress_percentage",
2403 .type = FIO_OPT_INT,
2404 .off1 = td_var_offset(compress_percentage),
2407 .help = "How compressible the buffer is (approximately)",
2410 .name = "buffer_compress_chunk",
2411 .type = FIO_OPT_INT,
2412 .off1 = td_var_offset(compress_chunk),
2413 .parent = "buffer_compress_percentage",
2414 .help = "Size of compressible region in buffer",
2417 .name = "clat_percentiles",
2418 .type = FIO_OPT_BOOL,
2419 .off1 = td_var_offset(clat_percentiles),
2420 .help = "Enable the reporting of completion latency percentiles",
2424 .name = "percentile_list",
2425 .type = FIO_OPT_FLOAT_LIST,
2426 .off1 = td_var_offset(percentile_list),
2427 .off2 = td_var_offset(overwrite_plist),
2428 .help = "Specify a custom list of percentiles to report",
2429 .maxlen = FIO_IO_U_LIST_MAX_LEN,
2434 #ifdef FIO_HAVE_DISK_UTIL
2436 .name = "disk_util",
2437 .type = FIO_OPT_BOOL,
2438 .off1 = td_var_offset(do_disk_util),
2439 .help = "Log disk utilization statistics",
2444 .name = "gtod_reduce",
2445 .type = FIO_OPT_BOOL,
2446 .help = "Greatly reduce number of gettimeofday() calls",
2447 .cb = str_gtod_reduce_cb,
2451 .name = "disable_lat",
2452 .type = FIO_OPT_BOOL,
2453 .off1 = td_var_offset(disable_lat),
2454 .help = "Disable latency numbers",
2455 .parent = "gtod_reduce",
2459 .name = "disable_clat",
2460 .type = FIO_OPT_BOOL,
2461 .off1 = td_var_offset(disable_clat),
2462 .help = "Disable completion latency numbers",
2463 .parent = "gtod_reduce",
2467 .name = "disable_slat",
2468 .type = FIO_OPT_BOOL,
2469 .off1 = td_var_offset(disable_slat),
2470 .help = "Disable submission latency numbers",
2471 .parent = "gtod_reduce",
2475 .name = "disable_bw_measurement",
2476 .type = FIO_OPT_BOOL,
2477 .off1 = td_var_offset(disable_bw),
2478 .help = "Disable bandwidth logging",
2479 .parent = "gtod_reduce",
2484 .type = FIO_OPT_INT,
2485 .cb = str_gtod_cpu_cb,
2486 .help = "Set up dedicated gettimeofday() thread on this CPU",
2487 .verify = gtod_cpu_verify,
2490 .name = "continue_on_error",
2491 .type = FIO_OPT_STR,
2492 .off1 = td_var_offset(continue_on_error),
2493 .help = "Continue on non-fatal errors during IO",
2497 .oval = ERROR_TYPE_NONE,
2498 .help = "Exit when an error is encountered",
2501 .oval = ERROR_TYPE_READ,
2502 .help = "Continue on read errors only",
2505 .oval = ERROR_TYPE_WRITE,
2506 .help = "Continue on write errors only",
2509 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
2510 .help = "Continue on any IO errors",
2513 .oval = ERROR_TYPE_VERIFY,
2514 .help = "Continue on verify errors only",
2517 .oval = ERROR_TYPE_ANY,
2518 .help = "Continue on all io and verify errors",
2521 .oval = ERROR_TYPE_NONE,
2522 .help = "Alias for 'none'",
2525 .oval = ERROR_TYPE_ANY,
2526 .help = "Alias for 'all'",
2531 .name = "ignore_error",
2532 .type = FIO_OPT_STR,
2533 .cb = str_ignore_error_cb,
2534 .help = "Set a specific list of errors to ignore",
2538 .name = "error_dump",
2539 .type = FIO_OPT_BOOL,
2540 .off1 = td_var_offset(error_dump),
2542 .help = "Dump info on each error",
2547 .type = FIO_OPT_STR_STORE,
2548 .off1 = td_var_offset(profile),
2549 .help = "Select a specific builtin performance test",
2553 .type = FIO_OPT_STR_STORE,
2554 .off1 = td_var_offset(cgroup),
2555 .help = "Add job to cgroup of this name",
2558 .name = "cgroup_weight",
2559 .type = FIO_OPT_INT,
2560 .off1 = td_var_offset(cgroup_weight),
2561 .help = "Use given weight for cgroup",
2566 .name = "cgroup_nodelete",
2567 .type = FIO_OPT_BOOL,
2568 .off1 = td_var_offset(cgroup_nodelete),
2569 .help = "Do not delete cgroups after job completion",
2574 .type = FIO_OPT_INT,
2575 .off1 = td_var_offset(uid),
2576 .help = "Run job with this user ID",
2580 .type = FIO_OPT_INT,
2581 .off1 = td_var_offset(gid),
2582 .help = "Run job with this group ID",
2586 .type = FIO_OPT_INT,
2587 .off1 = td_var_offset(flow_id),
2588 .help = "The flow index ID to use",
2593 .type = FIO_OPT_INT,
2594 .off1 = td_var_offset(flow),
2595 .help = "Weight for flow control of this job",
2596 .parent = "flow_id",
2600 .name = "flow_watermark",
2601 .type = FIO_OPT_INT,
2602 .off1 = td_var_offset(flow_watermark),
2603 .help = "High watermark for flow control. This option"
2604 " should be set to the same value for all threads"
2605 " with non-zero flow.",
2606 .parent = "flow_id",
2610 .name = "flow_sleep",
2611 .type = FIO_OPT_INT,
2612 .off1 = td_var_offset(flow_sleep),
2613 .help = "How many microseconds to sleep after being held"
2614 " back by the flow control mechanism",
2615 .parent = "flow_id",
2623 static void add_to_lopt(struct option *lopt, struct fio_option *o,
2624 const char *name, int val)
2626 lopt->name = (char *) name;
2628 if (o->type == FIO_OPT_STR_SET)
2629 lopt->has_arg = no_argument;
2631 lopt->has_arg = required_argument;
2634 static void options_to_lopts(struct fio_option *opts,
2635 struct option *long_options,
2636 int i, int option_type)
2638 struct fio_option *o = &opts[0];
2640 add_to_lopt(&long_options[i], o, o->name, option_type);
2643 add_to_lopt(&long_options[i], o, o->alias, option_type);
2648 assert(i < FIO_NR_OPTIONS);
2652 void fio_options_set_ioengine_opts(struct option *long_options,
2653 struct thread_data *td)
2658 while (long_options[i].name) {
2659 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
2660 memset(&long_options[i], 0, sizeof(*long_options));
2667 * Just clear out the prior ioengine options.
2672 options_to_lopts(td->io_ops->options, long_options, i,
2673 FIO_GETOPT_IOENGINE);
2676 void fio_options_dup_and_init(struct option *long_options)
2680 options_init(options);
2683 while (long_options[i].name)
2686 options_to_lopts(options, long_options, i, FIO_GETOPT_JOB);
2689 struct fio_keyword {
2695 static struct fio_keyword fio_keywords[] = {
2697 .word = "$pagesize",
2698 .desc = "Page size in the system",
2701 .word = "$mb_memory",
2702 .desc = "Megabytes of memory online",
2706 .desc = "Number of CPUs online in the system",
2713 void fio_keywords_init(void)
2715 unsigned long long mb_memory;
2719 sprintf(buf, "%lu", (unsigned long) page_size);
2720 fio_keywords[0].replace = strdup(buf);
2722 mb_memory = os_phys_mem() / (1024 * 1024);
2723 sprintf(buf, "%llu", mb_memory);
2724 fio_keywords[1].replace = strdup(buf);
2727 sprintf(buf, "%lu", l);
2728 fio_keywords[2].replace = strdup(buf);
2733 static char *bc_calc(char *str)
2735 char buf[128], *tmp;
2740 * No math, just return string
2742 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
2743 !strchr(str, '/')) || strchr(str, '\''))
2747 * Split option from value, we only need to calculate the value
2749 tmp = strchr(str, '=');
2756 * Prevent buffer overflows; such a case isn't reasonable anyway
2758 if (strlen(str) >= 128 || strlen(tmp) > 100)
2761 sprintf(buf, "which %s > /dev/null", BC_APP);
2763 log_err("fio: bc is needed for performing math\n");
2767 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
2768 f = popen(buf, "r");
2773 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
2779 buf[(tmp - str) + ret - 1] = '\0';
2780 memcpy(buf, str, tmp - str);
2786 * Return a copy of the input string with substrings of the form ${VARNAME}
2787 * substituted with the value of the environment variable VARNAME. The
2788 * substitution always occurs, even if VARNAME is empty or the corresponding
2789 * environment variable undefined.
2791 static char *option_dup_subs(const char *opt)
2793 char out[OPT_LEN_MAX+1];
2794 char in[OPT_LEN_MAX+1];
2797 char *ch1, *ch2, *env;
2798 ssize_t nchr = OPT_LEN_MAX;
2801 if (strlen(opt) + 1 > OPT_LEN_MAX) {
2802 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
2806 in[OPT_LEN_MAX] = '\0';
2807 strncpy(in, opt, OPT_LEN_MAX);
2809 while (*inptr && nchr > 0) {
2810 if (inptr[0] == '$' && inptr[1] == '{') {
2811 ch2 = strchr(inptr, '}');
2812 if (ch2 && inptr+1 < ch2) {
2819 envlen = strlen(env);
2820 if (envlen <= nchr) {
2821 memcpy(outptr, env, envlen);
2831 *outptr++ = *inptr++;
2840 * Look for reserved variable names and replace them with real values
2842 static char *fio_keyword_replace(char *opt)
2848 for (i = 0; fio_keywords[i].word != NULL; i++) {
2849 struct fio_keyword *kw = &fio_keywords[i];
2851 while ((s = strstr(opt, kw->word)) != NULL) {
2852 char *new = malloc(strlen(opt) + 1);
2858 * Copy part of the string before the keyword and
2859 * sprintf() the replacement after it.
2861 memcpy(new, opt, olen);
2862 len = sprintf(new + olen, "%s", kw->replace);
2865 * If there's more in the original string, copy that
2868 opt += strlen(kw->word) + olen;
2870 memcpy(new + olen + len, opt, opt - o_org - 1);
2873 * replace opt and free the old opt
2883 * Check for potential math and invoke bc, if possible
2891 static char **dup_and_sub_options(char **opts, int num_opts)
2894 char **opts_copy = malloc(num_opts * sizeof(*opts));
2895 for (i = 0; i < num_opts; i++) {
2896 opts_copy[i] = option_dup_subs(opts[i]);
2899 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
2904 int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
2906 int i, ret, unknown;
2909 sort_options(opts, options, num_opts);
2910 opts_copy = dup_and_sub_options(opts, num_opts);
2912 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
2913 struct fio_option *o;
2914 int newret = parse_option(opts_copy[i], opts[i], options, &o,
2923 opts_copy[i] = NULL;
2930 ret |= ioengine_load(td);
2932 sort_options(opts_copy, td->io_ops->options, num_opts);
2935 for (i = 0; i < num_opts; i++) {
2936 struct fio_option *o = NULL;
2942 newret = parse_option(opts_copy[i], opts[i],
2943 td->io_ops->options, &o,
2948 log_err("Bad option <%s>\n", opts[i]);
2951 opts_copy[i] = NULL;
2959 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
2961 return parse_cmd_option(opt, val, options, td);
2964 int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
2967 return parse_cmd_option(opt, val, td->io_ops->options, td);
2970 void fio_fill_default_options(struct thread_data *td)
2972 fill_default_options(td, options);
2975 int fio_show_option_help(const char *opt)
2977 return show_cmd_help(options, opt);
2980 void options_mem_dupe(void *data, struct fio_option *options)
2982 struct fio_option *o;
2985 for (o = &options[0]; o->name; o++) {
2986 if (o->type != FIO_OPT_STR_STORE)
2989 ptr = td_var(data, o->off1);
2991 *ptr = strdup(*ptr);
2996 * dupe FIO_OPT_STR_STORE options
2998 void fio_options_mem_dupe(struct thread_data *td)
3000 options_mem_dupe(&td->o, options);
3002 if (td->eo && td->io_ops) {
3003 void *oldeo = td->eo;
3005 td->eo = malloc(td->io_ops->option_struct_size);
3006 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
3007 options_mem_dupe(td->eo, td->io_ops->options);
3011 unsigned int fio_get_kb_base(void *data)
3013 struct thread_data *td = data;
3014 unsigned int kb_base = 0;
3017 kb_base = td->o.kb_base;
3024 int add_option(struct fio_option *o)
3026 struct fio_option *__o;
3035 memcpy(&options[opt_index], o, sizeof(*o));
3039 void invalidate_profile_options(const char *prof_name)
3041 struct fio_option *o;
3045 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
3046 o->type = FIO_OPT_INVALID;
3047 o->prof_name = NULL;
3053 void add_opt_posval(const char *optname, const char *ival, const char *help)
3055 struct fio_option *o;
3058 o = find_option(options, optname);
3062 for (i = 0; i < PARSE_MAX_VP; i++) {
3063 if (o->posval[i].ival)
3066 o->posval[i].ival = ival;
3067 o->posval[i].help = help;
3072 void del_opt_posval(const char *optname, const char *ival)
3074 struct fio_option *o;
3077 o = find_option(options, optname);
3081 for (i = 0; i < PARSE_MAX_VP; i++) {
3082 if (!o->posval[i].ival)
3084 if (strcmp(o->posval[i].ival, ival))
3087 o->posval[i].ival = NULL;
3088 o->posval[i].help = NULL;
3092 void fio_options_free(struct thread_data *td)
3094 options_free(options, td);
3095 if (td->eo && td->io_ops && td->io_ops->options) {
3096 options_free(td->io_ops->options, td->eo);