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;
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");
753 if (td->o.random_distribution == FIO_RAND_DIST_ZIPF) {
755 log_err("fio: zipf theta must different than 1.0\n");
758 td->o.zipf_theta = val;
760 if (val <= 0.00 || val >= 1.00) {
761 log_err("fio: pareto input out of range (0 < input < 1.0)\n");
764 td->o.pareto_h = val;
770 static int check_dir(struct thread_data *td, char *fname)
773 char file[PATH_MAX], *dir;
776 if (td->o.directory) {
777 strcpy(file, td->o.directory);
782 sprintf(file + elen, "%s", fname);
788 * We can't do this on FIO_DISKLESSIO engines. The engine isn't loaded
789 * yet, so we can't do this check right here...
791 if (lstat(dir, &sb) < 0) {
794 log_err("fio: %s is not a directory\n", dir);
795 td_verror(td, ret, "lstat");
799 if (!S_ISDIR(sb.st_mode)) {
800 log_err("fio: %s is not a directory\n", dir);
810 * Return next file in the string. Files are separated with ':'. If the ':'
811 * is escaped with a '\', then that ':' is part of the filename and does not
812 * indicate a new file.
814 static char *get_next_file_name(char **ptr)
819 if (!str || !strlen(str))
825 * No colon, we are done
827 p = strchr(str, ':');
834 * We got a colon, but it's the first character. Skip and
842 if (*(p - 1) != '\\') {
848 memmove(p - 1, p, strlen(p) + 1);
855 static int str_filename_cb(void *data, const char *input)
857 struct thread_data *td = data;
858 char *fname, *str, *p;
860 p = str = strdup(input);
862 strip_blank_front(&str);
863 strip_blank_end(str);
865 if (!td->files_index)
868 while ((fname = get_next_file_name(&str)) != NULL) {
871 if (check_dir(td, fname)) {
883 static int str_directory_cb(void *data, const char fio_unused *str)
885 struct thread_data *td = data;
888 if (lstat(td->o.directory, &sb) < 0) {
891 log_err("fio: %s is not a directory\n", td->o.directory);
892 td_verror(td, ret, "lstat");
895 if (!S_ISDIR(sb.st_mode)) {
896 log_err("fio: %s is not a directory\n", td->o.directory);
903 static int str_opendir_cb(void *data, const char fio_unused *str)
905 struct thread_data *td = data;
907 if (!td->files_index)
910 return add_dir_files(td, td->o.opendir);
913 static int str_verify_offset_cb(void *data, unsigned long long *off)
915 struct thread_data *td = data;
917 if (*off && *off < sizeof(struct verify_header)) {
918 log_err("fio: verify_offset too small\n");
922 td->o.verify_offset = *off;
926 static int str_verify_pattern_cb(void *data, const char *input)
928 struct thread_data *td = data;
930 int i = 0, j = 0, len, k, base = 10;
933 loc1 = strstr(input, "0x");
934 loc2 = strstr(input, "0X");
937 off = strtol(input, NULL, base);
938 if (off != LONG_MAX || errno != ERANGE) {
940 td->o.verify_pattern[i] = off & 0xff;
949 j = loc1 - input + 2;
951 j = loc2 - input + 2;
954 if (len - j < MAX_PATTERN_SIZE * 2) {
956 off = converthexchartoint(input[k--]);
958 off += (converthexchartoint(input[k--])
960 td->o.verify_pattern[i++] = (char) off;
966 * Fill the pattern all the way to the end. This greatly reduces
967 * the number of memcpy's we have to do when verifying the IO.
969 while (i > 1 && i * 2 <= MAX_PATTERN_SIZE) {
970 memcpy(&td->o.verify_pattern[i], &td->o.verify_pattern[0], i);
975 * The code in verify_io_u_pattern assumes a single byte pattern
976 * fills the whole verify pattern buffer.
978 memset(td->o.verify_pattern, td->o.verify_pattern[0],
982 td->o.verify_pattern_bytes = i;
985 * VERIFY_META could already be set
987 if (td->o.verify == VERIFY_NONE)
988 td->o.verify = VERIFY_PATTERN;
993 static int str_lockfile_cb(void *data, const char *str)
995 struct thread_data *td = data;
996 char *nr = get_opt_postfix(str);
998 td->o.lockfile_batch = 1;
1000 td->o.lockfile_batch = atoi(nr);
1007 static int str_write_bw_log_cb(void *data, const char *str)
1009 struct thread_data *td = data;
1012 td->o.bw_log_file = strdup(str);
1014 td->o.write_bw_log = 1;
1018 static int str_write_lat_log_cb(void *data, const char *str)
1020 struct thread_data *td = data;
1023 td->o.lat_log_file = strdup(str);
1025 td->o.write_lat_log = 1;
1029 static int str_write_iops_log_cb(void *data, const char *str)
1031 struct thread_data *td = data;
1034 td->o.iops_log_file = strdup(str);
1036 td->o.write_iops_log = 1;
1040 static int str_gtod_reduce_cb(void *data, int *il)
1042 struct thread_data *td = data;
1045 td->o.disable_lat = !!val;
1046 td->o.disable_clat = !!val;
1047 td->o.disable_slat = !!val;
1048 td->o.disable_bw = !!val;
1049 td->o.clat_percentiles = !val;
1051 td->tv_cache_mask = 63;
1056 static int str_gtod_cpu_cb(void *data, long long *il)
1058 struct thread_data *td = data;
1061 td->o.gtod_cpu = val;
1062 td->o.gtod_offload = 1;
1066 static int str_size_cb(void *data, unsigned long long *__val)
1068 struct thread_data *td = data;
1069 unsigned long long v = *__val;
1071 if (parse_is_percent(v)) {
1073 td->o.size_percent = -1ULL - v;
1080 static int rw_verify(struct fio_option *o, void *data)
1082 struct thread_data *td = data;
1084 if (read_only && td_write(td)) {
1085 log_err("fio: job <%s> has write bit set, but fio is in"
1086 " read-only mode\n", td->o.name);
1093 static int gtod_cpu_verify(struct fio_option *o, void *data)
1095 #ifndef FIO_HAVE_CPU_AFFINITY
1096 struct thread_data *td = data;
1098 if (td->o.gtod_cpu) {
1099 log_err("fio: platform must support CPU affinity for"
1100 "gettimeofday() offloading\n");
1108 static int kb_base_verify(struct fio_option *o, void *data)
1110 struct thread_data *td = data;
1112 if (td->o.kb_base != 1024 && td->o.kb_base != 1000) {
1113 log_err("fio: kb_base set to nonsensical value: %u\n",
1122 * Map of job/command line options
1124 static struct fio_option options[FIO_MAX_OPTS] = {
1126 .name = "description",
1127 .type = FIO_OPT_STR_STORE,
1128 .off1 = td_var_offset(description),
1129 .help = "Text job description",
1133 .type = FIO_OPT_STR_STORE,
1134 .off1 = td_var_offset(name),
1135 .help = "Name of this job",
1138 .name = "directory",
1139 .type = FIO_OPT_STR_STORE,
1140 .off1 = td_var_offset(directory),
1141 .cb = str_directory_cb,
1142 .help = "Directory to store files in",
1146 .type = FIO_OPT_STR_STORE,
1147 .off1 = td_var_offset(filename),
1148 .cb = str_filename_cb,
1149 .prio = -1, /* must come after "directory" */
1150 .help = "File(s) to use for the workload",
1154 .type = FIO_OPT_INT,
1155 .off1 = td_var_offset(kb_base),
1156 .verify = kb_base_verify,
1159 .help = "How many bytes per KB for reporting (1000 or 1024)",
1163 .type = FIO_OPT_STR,
1164 .cb = str_lockfile_cb,
1165 .off1 = td_var_offset(file_lock_mode),
1166 .help = "Lock file when doing IO to it",
1167 .parent = "filename",
1171 .oval = FILE_LOCK_NONE,
1172 .help = "No file locking",
1174 { .ival = "exclusive",
1175 .oval = FILE_LOCK_EXCLUSIVE,
1176 .help = "Exclusive file lock",
1179 .ival = "readwrite",
1180 .oval = FILE_LOCK_READWRITE,
1181 .help = "Read vs write lock",
1187 .type = FIO_OPT_STR_STORE,
1188 .off1 = td_var_offset(opendir),
1189 .cb = str_opendir_cb,
1190 .help = "Recursively add files from this directory and down",
1194 .alias = "readwrite",
1195 .type = FIO_OPT_STR,
1197 .off1 = td_var_offset(td_ddir),
1198 .help = "IO direction",
1200 .verify = rw_verify,
1203 .oval = TD_DDIR_READ,
1204 .help = "Sequential read",
1207 .oval = TD_DDIR_WRITE,
1208 .help = "Sequential write",
1211 .oval = TD_DDIR_TRIM,
1212 .help = "Sequential trim",
1214 { .ival = "randread",
1215 .oval = TD_DDIR_RANDREAD,
1216 .help = "Random read",
1218 { .ival = "randwrite",
1219 .oval = TD_DDIR_RANDWRITE,
1220 .help = "Random write",
1222 { .ival = "randtrim",
1223 .oval = TD_DDIR_RANDTRIM,
1224 .help = "Random trim",
1228 .help = "Sequential read and write mix",
1230 { .ival = "readwrite",
1232 .help = "Sequential read and write mix",
1235 .oval = TD_DDIR_RANDRW,
1236 .help = "Random read and write mix"
1241 .name = "rw_sequencer",
1242 .type = FIO_OPT_STR,
1243 .off1 = td_var_offset(rw_seq),
1244 .help = "IO offset generator modifier",
1245 .def = "sequential",
1247 { .ival = "sequential",
1249 .help = "Generate sequential offsets",
1251 { .ival = "identical",
1252 .oval = RW_SEQ_IDENT,
1253 .help = "Generate identical offsets",
1260 .type = FIO_OPT_STR_STORE,
1261 .off1 = td_var_offset(ioengine),
1262 .help = "IO engine to use",
1263 .def = FIO_PREFERRED_ENGINE,
1266 .help = "Use read/write",
1269 .help = "Use pread/pwrite",
1272 .help = "Use readv/writev",
1274 #ifdef FIO_HAVE_LIBAIO
1276 .help = "Linux native asynchronous IO",
1279 #ifdef FIO_HAVE_POSIXAIO
1280 { .ival = "posixaio",
1281 .help = "POSIX asynchronous IO",
1284 #ifdef FIO_HAVE_SOLARISAIO
1285 { .ival = "solarisaio",
1286 .help = "Solaris native asynchronous IO",
1289 #ifdef FIO_HAVE_WINDOWSAIO
1290 { .ival = "windowsaio",
1291 .help = "Windows native asynchronous IO"
1295 .help = "Memory mapped IO"
1297 #ifdef FIO_HAVE_SPLICE
1299 .help = "splice/vmsplice based IO",
1301 { .ival = "netsplice",
1302 .help = "splice/vmsplice to/from the network",
1305 #ifdef FIO_HAVE_SGIO
1307 .help = "SCSI generic v3 IO",
1311 .help = "Testing engine (no data transfer)",
1314 .help = "Network IO",
1316 #ifdef FIO_HAVE_SYSLET
1317 { .ival = "syslet-rw",
1318 .help = "syslet enabled async pread/pwrite IO",
1322 .help = "CPU cycle burner engine",
1324 #ifdef FIO_HAVE_GUASI
1326 .help = "GUASI IO engine",
1329 #ifdef FIO_HAVE_BINJECT
1330 { .ival = "binject",
1331 .help = "binject direct inject block engine",
1334 #ifdef FIO_HAVE_RDMA
1336 .help = "RDMA IO engine",
1339 #ifdef FIO_HAVE_FUSION_AW
1340 { .ival = "fusion-aw-sync",
1341 .help = "Fusion-io atomic write engine",
1344 #ifdef FIO_HAVE_E4_ENG
1345 { .ival = "e4defrag",
1346 .help = "ext4 defrag engine",
1349 #ifdef FIO_HAVE_FALLOC_ENG
1351 .help = "fallocate() file based engine",
1354 { .ival = "external",
1355 .help = "Load external engine (append name)",
1361 .type = FIO_OPT_INT,
1362 .off1 = td_var_offset(iodepth),
1363 .help = "Number of IO buffers to keep in flight",
1368 .name = "iodepth_batch",
1369 .alias = "iodepth_batch_submit",
1370 .type = FIO_OPT_INT,
1371 .off1 = td_var_offset(iodepth_batch),
1372 .help = "Number of IO buffers to submit in one go",
1373 .parent = "iodepth",
1378 .name = "iodepth_batch_complete",
1379 .type = FIO_OPT_INT,
1380 .off1 = td_var_offset(iodepth_batch_complete),
1381 .help = "Number of IO buffers to retrieve in one go",
1382 .parent = "iodepth",
1387 .name = "iodepth_low",
1388 .type = FIO_OPT_INT,
1389 .off1 = td_var_offset(iodepth_low),
1390 .help = "Low water mark for queuing depth",
1391 .parent = "iodepth",
1395 .type = FIO_OPT_STR_VAL,
1397 .help = "Total size of device or files",
1400 .name = "fill_device",
1402 .type = FIO_OPT_BOOL,
1403 .off1 = td_var_offset(fill_device),
1404 .help = "Write until an ENOSPC error occurs",
1409 .type = FIO_OPT_STR_VAL,
1410 .off1 = td_var_offset(file_size_low),
1411 .off2 = td_var_offset(file_size_high),
1413 .help = "Size of individual files",
1417 .alias = "fileoffset",
1418 .type = FIO_OPT_STR_VAL,
1419 .off1 = td_var_offset(start_offset),
1420 .help = "Start IO from this offset",
1424 .name = "offset_increment",
1425 .type = FIO_OPT_STR_VAL,
1426 .off1 = td_var_offset(offset_increment),
1427 .help = "What is the increment from one offset to the next",
1433 .alias = "blocksize",
1434 .type = FIO_OPT_INT,
1435 .off1 = td_var_offset(bs[DDIR_READ]),
1436 .off2 = td_var_offset(bs[DDIR_WRITE]),
1437 .off3 = td_var_offset(bs[DDIR_TRIM]),
1439 .help = "Block size unit",
1445 .alias = "blockalign",
1446 .type = FIO_OPT_INT,
1447 .off1 = td_var_offset(ba[DDIR_READ]),
1448 .off2 = td_var_offset(ba[DDIR_WRITE]),
1449 .off3 = td_var_offset(ba[DDIR_TRIM]),
1451 .help = "IO block offset alignment",
1456 .alias = "blocksize_range",
1457 .type = FIO_OPT_RANGE,
1458 .off1 = td_var_offset(min_bs[DDIR_READ]),
1459 .off2 = td_var_offset(max_bs[DDIR_READ]),
1460 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
1461 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
1462 .off5 = td_var_offset(min_bs[DDIR_TRIM]),
1463 .off6 = td_var_offset(max_bs[DDIR_TRIM]),
1465 .help = "Set block size range (in more detail than bs)",
1470 .type = FIO_OPT_STR,
1471 .cb = str_bssplit_cb,
1472 .help = "Set a specific mix of block sizes",
1476 .name = "bs_unaligned",
1477 .alias = "blocksize_unaligned",
1478 .type = FIO_OPT_STR_SET,
1479 .off1 = td_var_offset(bs_unaligned),
1480 .help = "Don't sector align IO buffer sizes",
1484 .name = "randrepeat",
1485 .type = FIO_OPT_BOOL,
1486 .off1 = td_var_offset(rand_repeatable),
1487 .help = "Use repeatable random IO pattern",
1492 .name = "use_os_rand",
1493 .type = FIO_OPT_BOOL,
1494 .off1 = td_var_offset(use_os_rand),
1495 .help = "Set to use OS random generator",
1500 .name = "norandommap",
1501 .type = FIO_OPT_STR_SET,
1502 .off1 = td_var_offset(norandommap),
1503 .help = "Accept potential duplicate random blocks",
1507 .name = "softrandommap",
1508 .type = FIO_OPT_BOOL,
1509 .off1 = td_var_offset(softrandommap),
1510 .help = "Set norandommap if randommap allocation fails",
1511 .parent = "norandommap",
1515 .name = "random_generator",
1516 .type = FIO_OPT_STR,
1517 .off1 = td_var_offset(random_generator),
1518 .help = "Type of random number generator to use",
1519 .def = "tausworthe",
1521 { .ival = "tausworthe",
1522 .oval = FIO_RAND_GEN_TAUSWORTHE,
1523 .help = "Strong Tausworthe generator",
1526 .oval = FIO_RAND_GEN_LFSR,
1527 .help = "Variable length LFSR",
1532 .name = "random_distribution",
1533 .type = FIO_OPT_STR,
1534 .off1 = td_var_offset(random_distribution),
1535 .cb = str_random_distribution_cb,
1536 .help = "Random offset distribution generator",
1540 .oval = FIO_RAND_DIST_RANDOM,
1541 .help = "Completely random",
1544 .oval = FIO_RAND_DIST_ZIPF,
1545 .help = "Zipf distribution",
1548 .oval = FIO_RAND_DIST_PARETO,
1549 .help = "Pareto distribution",
1555 .alias = "nr_files",
1556 .type = FIO_OPT_INT,
1557 .off1 = td_var_offset(nr_files),
1558 .help = "Split job workload between this number of files",
1562 .name = "openfiles",
1563 .type = FIO_OPT_INT,
1564 .off1 = td_var_offset(open_files),
1565 .help = "Number of files to keep open at the same time",
1568 .name = "file_service_type",
1569 .type = FIO_OPT_STR,
1571 .off1 = td_var_offset(file_service_type),
1572 .help = "How to select which file to service next",
1573 .def = "roundrobin",
1576 .oval = FIO_FSERVICE_RANDOM,
1577 .help = "Choose a file at random",
1579 { .ival = "roundrobin",
1580 .oval = FIO_FSERVICE_RR,
1581 .help = "Round robin select files",
1583 { .ival = "sequential",
1584 .oval = FIO_FSERVICE_SEQ,
1585 .help = "Finish one file before moving to the next",
1588 .parent = "nrfiles",
1590 #ifdef FIO_HAVE_FALLOCATE
1592 .name = "fallocate",
1593 .type = FIO_OPT_STR,
1594 .off1 = td_var_offset(fallocate_mode),
1595 .help = "Whether pre-allocation is performed when laying out files",
1599 .oval = FIO_FALLOCATE_NONE,
1600 .help = "Do not pre-allocate space",
1603 .oval = FIO_FALLOCATE_POSIX,
1604 .help = "Use posix_fallocate()",
1606 #ifdef FIO_HAVE_LINUX_FALLOCATE
1608 .oval = FIO_FALLOCATE_KEEP_SIZE,
1609 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
1612 /* Compatibility with former boolean values */
1614 .oval = FIO_FALLOCATE_NONE,
1615 .help = "Alias for 'none'",
1618 .oval = FIO_FALLOCATE_POSIX,
1619 .help = "Alias for 'posix'",
1623 #endif /* FIO_HAVE_FALLOCATE */
1625 .name = "fadvise_hint",
1626 .type = FIO_OPT_BOOL,
1627 .off1 = td_var_offset(fadvise_hint),
1628 .help = "Use fadvise() to advise the kernel on IO pattern",
1633 .type = FIO_OPT_INT,
1634 .off1 = td_var_offset(fsync_blocks),
1635 .help = "Issue fsync for writes every given number of blocks",
1639 .name = "fdatasync",
1640 .type = FIO_OPT_INT,
1641 .off1 = td_var_offset(fdatasync_blocks),
1642 .help = "Issue fdatasync for writes every given number of blocks",
1646 .name = "write_barrier",
1647 .type = FIO_OPT_INT,
1648 .off1 = td_var_offset(barrier_blocks),
1649 .help = "Make every Nth write a barrier write",
1652 #ifdef FIO_HAVE_SYNC_FILE_RANGE
1654 .name = "sync_file_range",
1656 { .ival = "wait_before",
1657 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
1658 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
1662 .oval = SYNC_FILE_RANGE_WRITE,
1663 .help = "SYNC_FILE_RANGE_WRITE",
1667 .ival = "wait_after",
1668 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
1669 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
1673 .type = FIO_OPT_STR_MULTI,
1675 .off1 = td_var_offset(sync_file_range),
1676 .help = "Use sync_file_range()",
1681 .type = FIO_OPT_BOOL,
1682 .off1 = td_var_offset(odirect),
1683 .help = "Use O_DIRECT IO (negates buffered)",
1688 .type = FIO_OPT_BOOL,
1689 .off1 = td_var_offset(odirect),
1691 .help = "Use buffered IO (negates direct)",
1695 .name = "overwrite",
1696 .type = FIO_OPT_BOOL,
1697 .off1 = td_var_offset(overwrite),
1698 .help = "When writing, set whether to overwrite current data",
1703 .type = FIO_OPT_INT,
1704 .off1 = td_var_offset(loops),
1705 .help = "Number of times to run the job",
1710 .type = FIO_OPT_INT,
1711 .off1 = td_var_offset(numjobs),
1712 .help = "Duplicate this job this many times",
1716 .name = "startdelay",
1717 .type = FIO_OPT_STR_VAL_TIME,
1718 .off1 = td_var_offset(start_delay),
1719 .help = "Only start job when this period has passed",
1725 .type = FIO_OPT_STR_VAL_TIME,
1726 .off1 = td_var_offset(timeout),
1727 .help = "Stop workload when this amount of time has passed",
1731 .name = "time_based",
1732 .type = FIO_OPT_STR_SET,
1733 .off1 = td_var_offset(time_based),
1734 .help = "Keep running until runtime/timeout is met",
1737 .name = "ramp_time",
1738 .type = FIO_OPT_STR_VAL_TIME,
1739 .off1 = td_var_offset(ramp_time),
1740 .help = "Ramp up time before measuring performance",
1743 .name = "clocksource",
1744 .type = FIO_OPT_STR,
1745 .cb = fio_clock_source_cb,
1746 .off1 = td_var_offset(clocksource),
1747 .help = "What type of timing source to use",
1749 { .ival = "gettimeofday",
1751 .help = "Use gettimeofday(2) for timing",
1753 { .ival = "clock_gettime",
1754 .oval = CS_CGETTIME,
1755 .help = "Use clock_gettime(2) for timing",
1757 #ifdef ARCH_HAVE_CPU_CLOCK
1759 .oval = CS_CPUCLOCK,
1760 .help = "Use CPU private clock",
1768 .type = FIO_OPT_STR,
1770 .off1 = td_var_offset(mem_type),
1771 .help = "Backing type for IO buffers",
1776 .help = "Use malloc(3) for IO buffers",
1780 .help = "Use shared memory segments for IO buffers",
1782 #ifdef FIO_HAVE_HUGETLB
1783 { .ival = "shmhuge",
1784 .oval = MEM_SHMHUGE,
1785 .help = "Like shm, but use huge pages",
1790 .help = "Use mmap(2) (file or anon) for IO buffers",
1792 #ifdef FIO_HAVE_HUGETLB
1793 { .ival = "mmaphuge",
1794 .oval = MEM_MMAPHUGE,
1795 .help = "Like mmap, but use huge pages",
1801 .name = "iomem_align",
1802 .alias = "mem_align",
1803 .type = FIO_OPT_INT,
1804 .off1 = td_var_offset(mem_align),
1806 .help = "IO memory buffer offset alignment",
1812 .type = FIO_OPT_STR,
1813 .off1 = td_var_offset(verify),
1814 .help = "Verify data written",
1815 .cb = str_verify_cb,
1819 .oval = VERIFY_NONE,
1820 .help = "Don't do IO verification",
1824 .help = "Use md5 checksums for verification",
1827 .oval = VERIFY_CRC64,
1828 .help = "Use crc64 checksums for verification",
1831 .oval = VERIFY_CRC32,
1832 .help = "Use crc32 checksums for verification",
1834 { .ival = "crc32c-intel",
1835 .oval = VERIFY_CRC32C,
1836 .help = "Use crc32c checksums for verification (hw assisted, if available)",
1839 .oval = VERIFY_CRC32C,
1840 .help = "Use crc32c checksums for verification (hw assisted, if available)",
1843 .oval = VERIFY_CRC16,
1844 .help = "Use crc16 checksums for verification",
1847 .oval = VERIFY_CRC7,
1848 .help = "Use crc7 checksums for verification",
1851 .oval = VERIFY_SHA1,
1852 .help = "Use sha1 checksums for verification",
1855 .oval = VERIFY_SHA256,
1856 .help = "Use sha256 checksums for verification",
1859 .oval = VERIFY_SHA512,
1860 .help = "Use sha512 checksums for verification",
1863 .oval = VERIFY_META,
1864 .help = "Use io information",
1868 .oval = VERIFY_NULL,
1869 .help = "Pretend to verify",
1874 .name = "do_verify",
1875 .type = FIO_OPT_BOOL,
1876 .off1 = td_var_offset(do_verify),
1877 .help = "Run verification stage after write",
1882 .name = "verifysort",
1883 .type = FIO_OPT_BOOL,
1884 .off1 = td_var_offset(verifysort),
1885 .help = "Sort written verify blocks for read back",
1890 .name = "verify_interval",
1891 .type = FIO_OPT_INT,
1892 .off1 = td_var_offset(verify_interval),
1893 .minval = 2 * sizeof(struct verify_header),
1894 .help = "Store verify buffer header every N bytes",
1898 .name = "verify_offset",
1899 .type = FIO_OPT_INT,
1900 .help = "Offset verify header location by N bytes",
1902 .cb = str_verify_offset_cb,
1906 .name = "verify_pattern",
1907 .type = FIO_OPT_STR,
1908 .cb = str_verify_pattern_cb,
1909 .help = "Fill pattern for IO buffers",
1913 .name = "verify_fatal",
1914 .type = FIO_OPT_BOOL,
1915 .off1 = td_var_offset(verify_fatal),
1917 .help = "Exit on a single verify failure, don't continue",
1921 .name = "verify_dump",
1922 .type = FIO_OPT_BOOL,
1923 .off1 = td_var_offset(verify_dump),
1925 .help = "Dump contents of good and bad blocks on failure",
1929 .name = "verify_async",
1930 .type = FIO_OPT_INT,
1931 .off1 = td_var_offset(verify_async),
1933 .help = "Number of async verifier threads to use",
1937 .name = "verify_backlog",
1938 .type = FIO_OPT_STR_VAL,
1939 .off1 = td_var_offset(verify_backlog),
1940 .help = "Verify after this number of blocks are written",
1944 .name = "verify_backlog_batch",
1945 .type = FIO_OPT_INT,
1946 .off1 = td_var_offset(verify_batch),
1947 .help = "Verify this number of IO blocks",
1950 #ifdef FIO_HAVE_CPU_AFFINITY
1952 .name = "verify_async_cpus",
1953 .type = FIO_OPT_STR,
1954 .cb = str_verify_cpus_allowed_cb,
1955 .help = "Set CPUs allowed for async verify threads",
1956 .parent = "verify_async",
1959 #ifdef FIO_HAVE_TRIM
1961 .name = "trim_percentage",
1962 .type = FIO_OPT_INT,
1963 .cb = str_verify_trim_cb,
1965 .help = "Number of verify blocks to discard/trim",
1970 .name = "trim_verify_zero",
1971 .type = FIO_OPT_INT,
1972 .help = "Verify that trim/discarded blocks are returned as zeroes",
1973 .off1 = td_var_offset(trim_zero),
1974 .parent = "trim_percentage",
1978 .name = "trim_backlog",
1979 .type = FIO_OPT_STR_VAL,
1980 .off1 = td_var_offset(trim_backlog),
1981 .help = "Trim after this number of blocks are written",
1982 .parent = "trim_percentage",
1985 .name = "trim_backlog_batch",
1986 .type = FIO_OPT_INT,
1987 .off1 = td_var_offset(trim_batch),
1988 .help = "Trim this number of IO blocks",
1989 .parent = "trim_percentage",
1993 .name = "write_iolog",
1994 .type = FIO_OPT_STR_STORE,
1995 .off1 = td_var_offset(write_iolog_file),
1996 .help = "Store IO pattern to file",
1999 .name = "read_iolog",
2000 .type = FIO_OPT_STR_STORE,
2001 .off1 = td_var_offset(read_iolog_file),
2002 .help = "Playback IO pattern from file",
2005 .name = "replay_no_stall",
2006 .type = FIO_OPT_INT,
2007 .off1 = td_var_offset(no_stall),
2009 .parent = "read_iolog",
2010 .help = "Playback IO pattern file as fast as possible without stalls",
2013 .name = "replay_redirect",
2014 .type = FIO_OPT_STR_STORE,
2015 .off1 = td_var_offset(replay_redirect),
2016 .parent = "read_iolog",
2017 .help = "Replay all I/O onto this device, regardless of trace device",
2020 .name = "exec_prerun",
2021 .type = FIO_OPT_STR_STORE,
2022 .off1 = td_var_offset(exec_prerun),
2023 .help = "Execute this file prior to running job",
2026 .name = "exec_postrun",
2027 .type = FIO_OPT_STR_STORE,
2028 .off1 = td_var_offset(exec_postrun),
2029 .help = "Execute this file after running job",
2031 #ifdef FIO_HAVE_IOSCHED_SWITCH
2033 .name = "ioscheduler",
2034 .type = FIO_OPT_STR_STORE,
2035 .off1 = td_var_offset(ioscheduler),
2036 .help = "Use this IO scheduler on the backing device",
2041 .type = FIO_OPT_STR_VAL,
2042 .off1 = td_var_offset(zone_size),
2043 .help = "Amount of data to read per zone",
2047 .name = "zonerange",
2048 .type = FIO_OPT_STR_VAL,
2049 .off1 = td_var_offset(zone_range),
2050 .help = "Give size of an IO zone",
2055 .type = FIO_OPT_STR_VAL,
2056 .off1 = td_var_offset(zone_skip),
2057 .help = "Space between IO zones",
2062 .type = FIO_OPT_STR_VAL,
2063 .cb = str_lockmem_cb,
2064 .help = "Lock down this amount of memory",
2068 .name = "rwmixread",
2069 .type = FIO_OPT_INT,
2070 .cb = str_rwmix_read_cb,
2072 .help = "Percentage of mixed workload that is reads",
2076 .name = "rwmixwrite",
2077 .type = FIO_OPT_INT,
2078 .cb = str_rwmix_write_cb,
2080 .help = "Percentage of mixed workload that is writes",
2084 .name = "rwmixcycle",
2085 .type = FIO_OPT_DEPRECATED,
2089 .type = FIO_OPT_INT,
2090 .off1 = td_var_offset(nice),
2091 .help = "Set job CPU nice value",
2096 #ifdef FIO_HAVE_IOPRIO
2099 .type = FIO_OPT_INT,
2101 .help = "Set job IO priority value",
2106 .name = "prioclass",
2107 .type = FIO_OPT_INT,
2108 .cb = str_prioclass_cb,
2109 .help = "Set job IO priority class",
2115 .name = "thinktime",
2116 .type = FIO_OPT_INT,
2117 .off1 = td_var_offset(thinktime),
2118 .help = "Idle time between IO buffers (usec)",
2122 .name = "thinktime_spin",
2123 .type = FIO_OPT_INT,
2124 .off1 = td_var_offset(thinktime_spin),
2125 .help = "Start think time by spinning this amount (usec)",
2127 .parent = "thinktime",
2130 .name = "thinktime_blocks",
2131 .type = FIO_OPT_INT,
2132 .off1 = td_var_offset(thinktime_blocks),
2133 .help = "IO buffer period between 'thinktime'",
2135 .parent = "thinktime",
2139 .type = FIO_OPT_INT,
2140 .off1 = td_var_offset(rate[DDIR_READ]),
2141 .off2 = td_var_offset(rate[DDIR_WRITE]),
2142 .off3 = td_var_offset(rate[DDIR_TRIM]),
2143 .help = "Set bandwidth rate",
2147 .type = FIO_OPT_INT,
2148 .off1 = td_var_offset(ratemin[DDIR_READ]),
2149 .off2 = td_var_offset(ratemin[DDIR_WRITE]),
2150 .off3 = td_var_offset(ratemin[DDIR_TRIM]),
2151 .help = "Job must meet this rate or it will be shutdown",
2155 .name = "rate_iops",
2156 .type = FIO_OPT_INT,
2157 .off1 = td_var_offset(rate_iops[DDIR_READ]),
2158 .off2 = td_var_offset(rate_iops[DDIR_WRITE]),
2159 .off3 = td_var_offset(rate_iops[DDIR_TRIM]),
2160 .help = "Limit IO used to this number of IO operations/sec",
2163 .name = "rate_iops_min",
2164 .type = FIO_OPT_INT,
2165 .off1 = td_var_offset(rate_iops_min[DDIR_READ]),
2166 .off2 = td_var_offset(rate_iops_min[DDIR_WRITE]),
2167 .off3 = td_var_offset(rate_iops_min[DDIR_TRIM]),
2168 .help = "Job must meet this rate or it will be shut down",
2169 .parent = "rate_iops",
2172 .name = "ratecycle",
2173 .type = FIO_OPT_INT,
2174 .off1 = td_var_offset(ratecycle),
2175 .help = "Window average for rate limits (msec)",
2180 .name = "max_latency",
2181 .type = FIO_OPT_INT,
2182 .off1 = td_var_offset(max_latency),
2183 .help = "Maximum tolerated IO latency (usec)",
2186 .name = "invalidate",
2187 .type = FIO_OPT_BOOL,
2188 .off1 = td_var_offset(invalidate_cache),
2189 .help = "Invalidate buffer/page cache prior to running job",
2194 .type = FIO_OPT_BOOL,
2195 .off1 = td_var_offset(sync_io),
2196 .help = "Use O_SYNC for buffered writes",
2198 .parent = "buffered",
2201 .name = "bwavgtime",
2202 .type = FIO_OPT_INT,
2203 .off1 = td_var_offset(bw_avg_time),
2204 .help = "Time window over which to calculate bandwidth"
2207 .parent = "write_bw_log",
2210 .name = "iopsavgtime",
2211 .type = FIO_OPT_INT,
2212 .off1 = td_var_offset(iops_avg_time),
2213 .help = "Time window over which to calculate IOPS (msec)",
2215 .parent = "write_iops_log",
2218 .name = "create_serialize",
2219 .type = FIO_OPT_BOOL,
2220 .off1 = td_var_offset(create_serialize),
2221 .help = "Serialize creating of job files",
2225 .name = "create_fsync",
2226 .type = FIO_OPT_BOOL,
2227 .off1 = td_var_offset(create_fsync),
2228 .help = "fsync file after creation",
2232 .name = "create_on_open",
2233 .type = FIO_OPT_BOOL,
2234 .off1 = td_var_offset(create_on_open),
2235 .help = "Create files when they are opened for IO",
2239 .name = "create_only",
2240 .type = FIO_OPT_BOOL,
2241 .off1 = td_var_offset(create_only),
2242 .help = "Only perform file creation phase",
2247 .type = FIO_OPT_BOOL,
2248 .off1 = td_var_offset(pre_read),
2249 .help = "Pre-read files before starting official testing",
2254 .type = FIO_OPT_INT,
2255 .off1 = td_var_offset(cpuload),
2256 .help = "Use this percentage of CPU",
2259 .name = "cpuchunks",
2260 .type = FIO_OPT_INT,
2261 .off1 = td_var_offset(cpucycle),
2262 .help = "Length of the CPU burn cycles (usecs)",
2264 .parent = "cpuload",
2266 #ifdef FIO_HAVE_CPU_AFFINITY
2269 .type = FIO_OPT_INT,
2270 .cb = str_cpumask_cb,
2271 .help = "CPU affinity mask",
2274 .name = "cpus_allowed",
2275 .type = FIO_OPT_STR,
2276 .cb = str_cpus_allowed_cb,
2277 .help = "Set CPUs allowed",
2280 #ifdef FIO_HAVE_LIBNUMA
2282 .name = "numa_cpu_nodes",
2283 .type = FIO_OPT_STR,
2284 .cb = str_numa_cpunodes_cb,
2285 .help = "NUMA CPU nodes bind",
2288 .name = "numa_mem_policy",
2289 .type = FIO_OPT_STR,
2290 .cb = str_numa_mpol_cb,
2291 .help = "NUMA memory policy setup",
2295 .name = "end_fsync",
2296 .type = FIO_OPT_BOOL,
2297 .off1 = td_var_offset(end_fsync),
2298 .help = "Include fsync at the end of job",
2302 .name = "fsync_on_close",
2303 .type = FIO_OPT_BOOL,
2304 .off1 = td_var_offset(fsync_on_close),
2305 .help = "fsync files on close",
2310 .type = FIO_OPT_BOOL,
2311 .off1 = td_var_offset(unlink),
2312 .help = "Unlink created files after job has completed",
2317 .type = FIO_OPT_STR_SET,
2318 .cb = str_exitall_cb,
2319 .help = "Terminate all jobs when one exits",
2322 .name = "stonewall",
2323 .alias = "wait_for_previous",
2324 .type = FIO_OPT_STR_SET,
2325 .off1 = td_var_offset(stonewall),
2326 .help = "Insert a hard barrier between this job and previous",
2329 .name = "new_group",
2330 .type = FIO_OPT_STR_SET,
2331 .off1 = td_var_offset(new_group),
2332 .help = "Mark the start of a new group (for reporting)",
2336 .type = FIO_OPT_STR_SET,
2337 .off1 = td_var_offset(use_thread),
2338 .help = "Use threads instead of forks",
2341 .name = "write_bw_log",
2342 .type = FIO_OPT_STR,
2343 .off1 = td_var_offset(write_bw_log),
2344 .cb = str_write_bw_log_cb,
2345 .help = "Write log of bandwidth during run",
2348 .name = "write_lat_log",
2349 .type = FIO_OPT_STR,
2350 .off1 = td_var_offset(write_lat_log),
2351 .cb = str_write_lat_log_cb,
2352 .help = "Write log of latency during run",
2355 .name = "write_iops_log",
2356 .type = FIO_OPT_STR,
2357 .off1 = td_var_offset(write_iops_log),
2358 .cb = str_write_iops_log_cb,
2359 .help = "Write log of IOPS during run",
2362 .name = "log_avg_msec",
2363 .type = FIO_OPT_INT,
2364 .off1 = td_var_offset(log_avg_msec),
2365 .help = "Average bw/iops/lat logs over this period of time",
2369 .name = "hugepage-size",
2370 .type = FIO_OPT_INT,
2371 .off1 = td_var_offset(hugepage_size),
2372 .help = "When using hugepages, specify size of each page",
2373 .def = __fio_stringify(FIO_HUGE_PAGE),
2376 .name = "group_reporting",
2377 .type = FIO_OPT_STR_SET,
2378 .off1 = td_var_offset(group_reporting),
2379 .help = "Do reporting on a per-group basis",
2382 .name = "zero_buffers",
2383 .type = FIO_OPT_STR_SET,
2384 .off1 = td_var_offset(zero_buffers),
2385 .help = "Init IO buffers to all zeroes",
2388 .name = "refill_buffers",
2389 .type = FIO_OPT_STR_SET,
2390 .off1 = td_var_offset(refill_buffers),
2391 .help = "Refill IO buffers on every IO submit",
2394 .name = "scramble_buffers",
2395 .type = FIO_OPT_BOOL,
2396 .off1 = td_var_offset(scramble_buffers),
2397 .help = "Slightly scramble buffers on every IO submit",
2401 .name = "buffer_compress_percentage",
2402 .type = FIO_OPT_INT,
2403 .off1 = td_var_offset(compress_percentage),
2406 .help = "How compressible the buffer is (approximately)",
2409 .name = "buffer_compress_chunk",
2410 .type = FIO_OPT_INT,
2411 .off1 = td_var_offset(compress_chunk),
2412 .parent = "buffer_compress_percentage",
2413 .help = "Size of compressible region in buffer",
2416 .name = "clat_percentiles",
2417 .type = FIO_OPT_BOOL,
2418 .off1 = td_var_offset(clat_percentiles),
2419 .help = "Enable the reporting of completion latency percentiles",
2423 .name = "percentile_list",
2424 .type = FIO_OPT_FLOAT_LIST,
2425 .off1 = td_var_offset(percentile_list),
2426 .off2 = td_var_offset(overwrite_plist),
2427 .help = "Specify a custom list of percentiles to report",
2428 .maxlen = FIO_IO_U_LIST_MAX_LEN,
2433 #ifdef FIO_HAVE_DISK_UTIL
2435 .name = "disk_util",
2436 .type = FIO_OPT_BOOL,
2437 .off1 = td_var_offset(do_disk_util),
2438 .help = "Log disk utilization statistics",
2443 .name = "gtod_reduce",
2444 .type = FIO_OPT_BOOL,
2445 .help = "Greatly reduce number of gettimeofday() calls",
2446 .cb = str_gtod_reduce_cb,
2450 .name = "disable_lat",
2451 .type = FIO_OPT_BOOL,
2452 .off1 = td_var_offset(disable_lat),
2453 .help = "Disable latency numbers",
2454 .parent = "gtod_reduce",
2458 .name = "disable_clat",
2459 .type = FIO_OPT_BOOL,
2460 .off1 = td_var_offset(disable_clat),
2461 .help = "Disable completion latency numbers",
2462 .parent = "gtod_reduce",
2466 .name = "disable_slat",
2467 .type = FIO_OPT_BOOL,
2468 .off1 = td_var_offset(disable_slat),
2469 .help = "Disable submission latency numbers",
2470 .parent = "gtod_reduce",
2474 .name = "disable_bw_measurement",
2475 .type = FIO_OPT_BOOL,
2476 .off1 = td_var_offset(disable_bw),
2477 .help = "Disable bandwidth logging",
2478 .parent = "gtod_reduce",
2483 .type = FIO_OPT_INT,
2484 .cb = str_gtod_cpu_cb,
2485 .help = "Set up dedicated gettimeofday() thread on this CPU",
2486 .verify = gtod_cpu_verify,
2489 .name = "continue_on_error",
2490 .type = FIO_OPT_STR,
2491 .off1 = td_var_offset(continue_on_error),
2492 .help = "Continue on non-fatal errors during IO",
2496 .oval = ERROR_TYPE_NONE,
2497 .help = "Exit when an error is encountered",
2500 .oval = ERROR_TYPE_READ,
2501 .help = "Continue on read errors only",
2504 .oval = ERROR_TYPE_WRITE,
2505 .help = "Continue on write errors only",
2508 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
2509 .help = "Continue on any IO errors",
2512 .oval = ERROR_TYPE_VERIFY,
2513 .help = "Continue on verify errors only",
2516 .oval = ERROR_TYPE_ANY,
2517 .help = "Continue on all io and verify errors",
2520 .oval = ERROR_TYPE_NONE,
2521 .help = "Alias for 'none'",
2524 .oval = ERROR_TYPE_ANY,
2525 .help = "Alias for 'all'",
2530 .name = "ignore_error",
2531 .type = FIO_OPT_STR,
2532 .cb = str_ignore_error_cb,
2533 .help = "Set a specific list of errors to ignore",
2537 .name = "error_dump",
2538 .type = FIO_OPT_BOOL,
2539 .off1 = td_var_offset(error_dump),
2541 .help = "Dump info on each error",
2546 .type = FIO_OPT_STR_STORE,
2547 .off1 = td_var_offset(profile),
2548 .help = "Select a specific builtin performance test",
2552 .type = FIO_OPT_STR_STORE,
2553 .off1 = td_var_offset(cgroup),
2554 .help = "Add job to cgroup of this name",
2557 .name = "cgroup_weight",
2558 .type = FIO_OPT_INT,
2559 .off1 = td_var_offset(cgroup_weight),
2560 .help = "Use given weight for cgroup",
2565 .name = "cgroup_nodelete",
2566 .type = FIO_OPT_BOOL,
2567 .off1 = td_var_offset(cgroup_nodelete),
2568 .help = "Do not delete cgroups after job completion",
2573 .type = FIO_OPT_INT,
2574 .off1 = td_var_offset(uid),
2575 .help = "Run job with this user ID",
2579 .type = FIO_OPT_INT,
2580 .off1 = td_var_offset(gid),
2581 .help = "Run job with this group ID",
2585 .type = FIO_OPT_INT,
2586 .off1 = td_var_offset(flow_id),
2587 .help = "The flow index ID to use",
2592 .type = FIO_OPT_INT,
2593 .off1 = td_var_offset(flow),
2594 .help = "Weight for flow control of this job",
2595 .parent = "flow_id",
2599 .name = "flow_watermark",
2600 .type = FIO_OPT_INT,
2601 .off1 = td_var_offset(flow_watermark),
2602 .help = "High watermark for flow control. This option"
2603 " should be set to the same value for all threads"
2604 " with non-zero flow.",
2605 .parent = "flow_id",
2609 .name = "flow_sleep",
2610 .type = FIO_OPT_INT,
2611 .off1 = td_var_offset(flow_sleep),
2612 .help = "How many microseconds to sleep after being held"
2613 " back by the flow control mechanism",
2614 .parent = "flow_id",
2622 static void add_to_lopt(struct option *lopt, struct fio_option *o,
2623 const char *name, int val)
2625 lopt->name = (char *) name;
2627 if (o->type == FIO_OPT_STR_SET)
2628 lopt->has_arg = no_argument;
2630 lopt->has_arg = required_argument;
2633 static void options_to_lopts(struct fio_option *opts,
2634 struct option *long_options,
2635 int i, int option_type)
2637 struct fio_option *o = &opts[0];
2639 add_to_lopt(&long_options[i], o, o->name, option_type);
2642 add_to_lopt(&long_options[i], o, o->alias, option_type);
2647 assert(i < FIO_NR_OPTIONS);
2651 void fio_options_set_ioengine_opts(struct option *long_options,
2652 struct thread_data *td)
2657 while (long_options[i].name) {
2658 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
2659 memset(&long_options[i], 0, sizeof(*long_options));
2666 * Just clear out the prior ioengine options.
2671 options_to_lopts(td->io_ops->options, long_options, i,
2672 FIO_GETOPT_IOENGINE);
2675 void fio_options_dup_and_init(struct option *long_options)
2679 options_init(options);
2682 while (long_options[i].name)
2685 options_to_lopts(options, long_options, i, FIO_GETOPT_JOB);
2688 struct fio_keyword {
2694 static struct fio_keyword fio_keywords[] = {
2696 .word = "$pagesize",
2697 .desc = "Page size in the system",
2700 .word = "$mb_memory",
2701 .desc = "Megabytes of memory online",
2705 .desc = "Number of CPUs online in the system",
2712 void fio_keywords_init(void)
2714 unsigned long long mb_memory;
2718 sprintf(buf, "%lu", (unsigned long) page_size);
2719 fio_keywords[0].replace = strdup(buf);
2721 mb_memory = os_phys_mem() / (1024 * 1024);
2722 sprintf(buf, "%llu", mb_memory);
2723 fio_keywords[1].replace = strdup(buf);
2726 sprintf(buf, "%lu", l);
2727 fio_keywords[2].replace = strdup(buf);
2732 static char *bc_calc(char *str)
2734 char buf[128], *tmp;
2739 * No math, just return string
2741 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
2742 !strchr(str, '/')) || strchr(str, '\''))
2746 * Split option from value, we only need to calculate the value
2748 tmp = strchr(str, '=');
2755 * Prevent buffer overflows; such a case isn't reasonable anyway
2757 if (strlen(str) >= 128 || strlen(tmp) > 100)
2760 sprintf(buf, "which %s > /dev/null", BC_APP);
2762 log_err("fio: bc is needed for performing math\n");
2766 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
2767 f = popen(buf, "r");
2772 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
2778 buf[(tmp - str) + ret - 1] = '\0';
2779 memcpy(buf, str, tmp - str);
2785 * Return a copy of the input string with substrings of the form ${VARNAME}
2786 * substituted with the value of the environment variable VARNAME. The
2787 * substitution always occurs, even if VARNAME is empty or the corresponding
2788 * environment variable undefined.
2790 static char *option_dup_subs(const char *opt)
2792 char out[OPT_LEN_MAX+1];
2793 char in[OPT_LEN_MAX+1];
2796 char *ch1, *ch2, *env;
2797 ssize_t nchr = OPT_LEN_MAX;
2800 if (strlen(opt) + 1 > OPT_LEN_MAX) {
2801 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
2805 in[OPT_LEN_MAX] = '\0';
2806 strncpy(in, opt, OPT_LEN_MAX);
2808 while (*inptr && nchr > 0) {
2809 if (inptr[0] == '$' && inptr[1] == '{') {
2810 ch2 = strchr(inptr, '}');
2811 if (ch2 && inptr+1 < ch2) {
2818 envlen = strlen(env);
2819 if (envlen <= nchr) {
2820 memcpy(outptr, env, envlen);
2830 *outptr++ = *inptr++;
2839 * Look for reserved variable names and replace them with real values
2841 static char *fio_keyword_replace(char *opt)
2847 for (i = 0; fio_keywords[i].word != NULL; i++) {
2848 struct fio_keyword *kw = &fio_keywords[i];
2850 while ((s = strstr(opt, kw->word)) != NULL) {
2851 char *new = malloc(strlen(opt) + 1);
2857 * Copy part of the string before the keyword and
2858 * sprintf() the replacement after it.
2860 memcpy(new, opt, olen);
2861 len = sprintf(new + olen, "%s", kw->replace);
2864 * If there's more in the original string, copy that
2867 opt += strlen(kw->word) + olen;
2869 memcpy(new + olen + len, opt, opt - o_org - 1);
2872 * replace opt and free the old opt
2882 * Check for potential math and invoke bc, if possible
2890 static char **dup_and_sub_options(char **opts, int num_opts)
2893 char **opts_copy = malloc(num_opts * sizeof(*opts));
2894 for (i = 0; i < num_opts; i++) {
2895 opts_copy[i] = option_dup_subs(opts[i]);
2898 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
2903 int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
2905 int i, ret, unknown;
2908 sort_options(opts, options, num_opts);
2909 opts_copy = dup_and_sub_options(opts, num_opts);
2911 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
2912 struct fio_option *o;
2913 int newret = parse_option(opts_copy[i], opts[i], options, &o,
2922 opts_copy[i] = NULL;
2929 ret |= ioengine_load(td);
2931 sort_options(opts_copy, td->io_ops->options, num_opts);
2934 for (i = 0; i < num_opts; i++) {
2935 struct fio_option *o = NULL;
2941 newret = parse_option(opts_copy[i], opts[i],
2942 td->io_ops->options, &o,
2947 log_err("Bad option <%s>\n", opts[i]);
2950 opts_copy[i] = NULL;
2958 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
2960 return parse_cmd_option(opt, val, options, td);
2963 int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
2966 return parse_cmd_option(opt, val, td->io_ops->options, td);
2969 void fio_fill_default_options(struct thread_data *td)
2971 fill_default_options(td, options);
2974 int fio_show_option_help(const char *opt)
2976 return show_cmd_help(options, opt);
2979 void options_mem_dupe(void *data, struct fio_option *options)
2981 struct fio_option *o;
2984 for (o = &options[0]; o->name; o++) {
2985 if (o->type != FIO_OPT_STR_STORE)
2988 ptr = td_var(data, o->off1);
2990 *ptr = strdup(*ptr);
2995 * dupe FIO_OPT_STR_STORE options
2997 void fio_options_mem_dupe(struct thread_data *td)
2999 options_mem_dupe(&td->o, options);
3001 if (td->eo && td->io_ops) {
3002 void *oldeo = td->eo;
3004 td->eo = malloc(td->io_ops->option_struct_size);
3005 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
3006 options_mem_dupe(td->eo, td->io_ops->options);
3010 unsigned int fio_get_kb_base(void *data)
3012 struct thread_data *td = data;
3013 unsigned int kb_base = 0;
3016 kb_base = td->o.kb_base;
3023 int add_option(struct fio_option *o)
3025 struct fio_option *__o;
3034 memcpy(&options[opt_index], o, sizeof(*o));
3038 void invalidate_profile_options(const char *prof_name)
3040 struct fio_option *o;
3044 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
3045 o->type = FIO_OPT_INVALID;
3046 o->prof_name = NULL;
3052 void add_opt_posval(const char *optname, const char *ival, const char *help)
3054 struct fio_option *o;
3057 o = find_option(options, optname);
3061 for (i = 0; i < PARSE_MAX_VP; i++) {
3062 if (o->posval[i].ival)
3065 o->posval[i].ival = ival;
3066 o->posval[i].help = help;
3071 void del_opt_posval(const char *optname, const char *ival)
3073 struct fio_option *o;
3076 o = find_option(options, optname);
3080 for (i = 0; i < PARSE_MAX_VP; i++) {
3081 if (!o->posval[i].ival)
3083 if (strcmp(o->posval[i].ival, ival))
3086 o->posval[i].ival = NULL;
3087 o->posval[i].help = NULL;
3091 void fio_options_free(struct thread_data *td)
3093 options_free(options, td);
3094 if (td->eo && td->io_ops && td->io_ops->options) {
3095 options_free(td->io_ops->options, td->eo);