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);
351 static int str_verify_cb(void *data, const char *mem)
353 struct thread_data *td = data;
355 if (td->o.verify == VERIFY_CRC32C_INTEL ||
356 td->o.verify == VERIFY_CRC32C) {
357 crc32c_intel_probe();
363 static int fio_clock_source_cb(void *data, const char *str)
365 struct thread_data *td = data;
367 fio_clock_source = td->o.clocksource;
368 fio_clock_source_set = 1;
373 static int str_lockmem_cb(void fio_unused *data, unsigned long long *val)
379 static int str_rwmix_read_cb(void *data, unsigned long long *val)
381 struct thread_data *td = data;
383 td->o.rwmix[DDIR_READ] = *val;
384 td->o.rwmix[DDIR_WRITE] = 100 - *val;
388 static int str_rwmix_write_cb(void *data, unsigned long long *val)
390 struct thread_data *td = data;
392 td->o.rwmix[DDIR_WRITE] = *val;
393 td->o.rwmix[DDIR_READ] = 100 - *val;
397 #ifdef FIO_HAVE_IOPRIO
398 static int str_prioclass_cb(void *data, unsigned long long *val)
400 struct thread_data *td = data;
404 * mask off old class bits, str_prio_cb() may have set a default class
406 mask = (1 << IOPRIO_CLASS_SHIFT) - 1;
409 td->ioprio |= *val << IOPRIO_CLASS_SHIFT;
414 static int str_prio_cb(void *data, unsigned long long *val)
416 struct thread_data *td = data;
421 * If no class is set, assume BE
423 if ((td->ioprio >> IOPRIO_CLASS_SHIFT) == 0)
424 td->ioprio |= IOPRIO_CLASS_BE << IOPRIO_CLASS_SHIFT;
431 static int str_exitall_cb(void)
433 exitall_on_terminate = 1;
437 #ifdef FIO_HAVE_CPU_AFFINITY
438 static int str_cpumask_cb(void *data, unsigned long long *val)
440 struct thread_data *td = data;
445 ret = fio_cpuset_init(&td->o.cpumask);
447 log_err("fio: cpuset_init failed\n");
448 td_verror(td, ret, "fio_cpuset_init");
452 max_cpu = cpus_online();
454 for (i = 0; i < sizeof(int) * 8; i++) {
455 if ((1 << i) & *val) {
457 log_err("fio: CPU %d too large (max=%ld)\n", i,
461 dprint(FD_PARSE, "set cpu allowed %d\n", i);
462 fio_cpu_set(&td->o.cpumask, i);
466 td->o.cpumask_set = 1;
470 static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask,
477 ret = fio_cpuset_init(mask);
479 log_err("fio: cpuset_init failed\n");
480 td_verror(td, ret, "fio_cpuset_init");
484 p = str = strdup(input);
486 strip_blank_front(&str);
487 strip_blank_end(str);
489 max_cpu = cpus_online();
491 while ((cpu = strsep(&str, ",")) != NULL) {
500 while ((cpu2 = strsep(&str2, "-")) != NULL) {
510 while (icpu <= icpu2) {
511 if (icpu >= FIO_MAX_CPUS) {
512 log_err("fio: your OS only supports up to"
513 " %d CPUs\n", (int) FIO_MAX_CPUS);
517 if (icpu > max_cpu) {
518 log_err("fio: CPU %d too large (max=%ld)\n",
524 dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
525 fio_cpu_set(mask, icpu);
534 td->o.cpumask_set = 1;
538 static int str_cpus_allowed_cb(void *data, const char *input)
540 struct thread_data *td = data;
543 ret = set_cpus_allowed(td, &td->o.cpumask, input);
545 td->o.cpumask_set = 1;
550 static int str_verify_cpus_allowed_cb(void *data, const char *input)
552 struct thread_data *td = data;
555 ret = set_cpus_allowed(td, &td->o.verify_cpumask, input);
557 td->o.verify_cpumask_set = 1;
563 #ifdef CONFIG_LIBNUMA
564 static int str_numa_cpunodes_cb(void *data, char *input)
566 struct thread_data *td = data;
568 /* numa_parse_nodestring() parses a character string list
569 * of nodes into a bit mask. The bit mask is allocated by
570 * numa_allocate_nodemask(), so it should be freed by
571 * numa_free_nodemask().
573 td->o.numa_cpunodesmask = numa_parse_nodestring(input);
574 if (td->o.numa_cpunodesmask == NULL) {
575 log_err("fio: numa_parse_nodestring failed\n");
576 td_verror(td, 1, "str_numa_cpunodes_cb");
580 td->o.numa_cpumask_set = 1;
584 static int str_numa_mpol_cb(void *data, char *input)
586 struct thread_data *td = data;
587 const char * const policy_types[] =
588 { "default", "prefer", "bind", "interleave", "local" };
591 char *nodelist = strchr(input, ':');
593 /* NUL-terminate mode */
597 for (i = 0; i <= MPOL_LOCAL; i++) {
598 if (!strcmp(input, policy_types[i])) {
599 td->o.numa_mem_mode = i;
603 if (i > MPOL_LOCAL) {
604 log_err("fio: memory policy should be: default, prefer, bind, interleave, local\n");
608 switch (td->o.numa_mem_mode) {
611 * Insist on a nodelist of one node only
614 char *rest = nodelist;
615 while (isdigit(*rest))
618 log_err("fio: one node only for \'prefer\'\n");
622 log_err("fio: one node is needed for \'prefer\'\n");
626 case MPOL_INTERLEAVE:
628 * Default to online nodes with memory if no nodelist
631 nodelist = strdup("all");
636 * Don't allow a nodelist
639 log_err("fio: NO nodelist for \'local\'\n");
645 * Insist on a nodelist
648 log_err("fio: a nodelist is needed for \'bind\'\n");
655 /* numa_parse_nodestring() parses a character string list
656 * of nodes into a bit mask. The bit mask is allocated by
657 * numa_allocate_nodemask(), so it should be freed by
658 * numa_free_nodemask().
660 switch (td->o.numa_mem_mode) {
662 td->o.numa_mem_prefer_node = atoi(nodelist);
664 case MPOL_INTERLEAVE:
666 td->o.numa_memnodesmask = numa_parse_nodestring(nodelist);
667 if (td->o.numa_memnodesmask == NULL) {
668 log_err("fio: numa_parse_nodestring failed\n");
669 td_verror(td, 1, "str_numa_memnodes_cb");
679 td->o.numa_memmask_set = 1;
688 static int str_verify_trim_cb(void *data, unsigned long long *val)
690 struct thread_data *td = data;
692 td->o.trim_percentage = *val;
697 static int str_fst_cb(void *data, const char *str)
699 struct thread_data *td = data;
700 char *nr = get_opt_postfix(str);
702 td->file_service_nr = 1;
704 td->file_service_nr = atoi(nr);
711 #ifdef CONFIG_SYNC_FILE_RANGE
712 static int str_sfr_cb(void *data, const char *str)
714 struct thread_data *td = data;
715 char *nr = get_opt_postfix(str);
717 td->sync_file_range_nr = 1;
719 td->sync_file_range_nr = atoi(nr);
727 static int str_random_distribution_cb(void *data, const char *str)
729 struct thread_data *td = data;
733 if (td->o.random_distribution == FIO_RAND_DIST_ZIPF)
735 else if (td->o.random_distribution == FIO_RAND_DIST_PARETO)
740 nr = get_opt_postfix(str);
741 if (nr && !str_to_float(nr, &val)) {
742 log_err("fio: random postfix parsing failed\n");
749 if (td->o.random_distribution == FIO_RAND_DIST_ZIPF) {
751 log_err("fio: zipf theta must different than 1.0\n");
754 td->o.zipf_theta = val;
756 if (val <= 0.00 || val >= 1.00) {
757 log_err("fio: pareto input out of range (0 < input < 1.0)\n");
760 td->o.pareto_h = val;
766 static int check_dir(struct thread_data *td, char *fname)
769 char file[PATH_MAX], *dir;
772 if (td->o.directory) {
773 strcpy(file, td->o.directory);
778 sprintf(file + elen, "%s", fname);
784 * We can't do this on FIO_DISKLESSIO engines. The engine isn't loaded
785 * yet, so we can't do this check right here...
787 if (lstat(dir, &sb) < 0) {
790 log_err("fio: %s is not a directory\n", dir);
791 td_verror(td, ret, "lstat");
795 if (!S_ISDIR(sb.st_mode)) {
796 log_err("fio: %s is not a directory\n", dir);
806 * Return next file in the string. Files are separated with ':'. If the ':'
807 * is escaped with a '\', then that ':' is part of the filename and does not
808 * indicate a new file.
810 static char *get_next_file_name(char **ptr)
815 if (!str || !strlen(str))
821 * No colon, we are done
823 p = strchr(str, ':');
830 * We got a colon, but it's the first character. Skip and
838 if (*(p - 1) != '\\') {
844 memmove(p - 1, p, strlen(p) + 1);
851 static int str_filename_cb(void *data, const char *input)
853 struct thread_data *td = data;
854 char *fname, *str, *p;
856 p = str = strdup(input);
858 strip_blank_front(&str);
859 strip_blank_end(str);
861 if (!td->files_index)
864 while ((fname = get_next_file_name(&str)) != NULL) {
867 if (check_dir(td, fname)) {
879 static int str_directory_cb(void *data, const char fio_unused *str)
881 struct thread_data *td = data;
884 if (lstat(td->o.directory, &sb) < 0) {
887 log_err("fio: %s is not a directory\n", td->o.directory);
888 td_verror(td, ret, "lstat");
891 if (!S_ISDIR(sb.st_mode)) {
892 log_err("fio: %s is not a directory\n", td->o.directory);
899 static int str_opendir_cb(void *data, const char fio_unused *str)
901 struct thread_data *td = data;
903 if (!td->files_index)
906 return add_dir_files(td, td->o.opendir);
909 static int str_verify_offset_cb(void *data, unsigned long long *off)
911 struct thread_data *td = data;
913 if (*off && *off < sizeof(struct verify_header)) {
914 log_err("fio: verify_offset too small\n");
918 td->o.verify_offset = *off;
922 static int str_verify_pattern_cb(void *data, const char *input)
924 struct thread_data *td = data;
926 int i = 0, j = 0, len, k, base = 10;
929 loc1 = strstr(input, "0x");
930 loc2 = strstr(input, "0X");
933 off = strtol(input, NULL, base);
934 if (off != LONG_MAX || errno != ERANGE) {
936 td->o.verify_pattern[i] = off & 0xff;
945 j = loc1 - input + 2;
947 j = loc2 - input + 2;
950 if (len - j < MAX_PATTERN_SIZE * 2) {
952 off = converthexchartoint(input[k--]);
954 off += (converthexchartoint(input[k--])
956 td->o.verify_pattern[i++] = (char) off;
962 * Fill the pattern all the way to the end. This greatly reduces
963 * the number of memcpy's we have to do when verifying the IO.
965 while (i > 1 && i * 2 <= MAX_PATTERN_SIZE) {
966 memcpy(&td->o.verify_pattern[i], &td->o.verify_pattern[0], i);
971 * The code in verify_io_u_pattern assumes a single byte pattern
972 * fills the whole verify pattern buffer.
974 memset(td->o.verify_pattern, td->o.verify_pattern[0],
978 td->o.verify_pattern_bytes = i;
981 * VERIFY_META could already be set
983 if (td->o.verify == VERIFY_NONE)
984 td->o.verify = VERIFY_PATTERN;
989 static int str_write_bw_log_cb(void *data, const char *str)
991 struct thread_data *td = data;
994 td->o.bw_log_file = strdup(str);
996 td->o.write_bw_log = 1;
1000 static int str_write_lat_log_cb(void *data, const char *str)
1002 struct thread_data *td = data;
1005 td->o.lat_log_file = strdup(str);
1007 td->o.write_lat_log = 1;
1011 static int str_write_iops_log_cb(void *data, const char *str)
1013 struct thread_data *td = data;
1016 td->o.iops_log_file = strdup(str);
1018 td->o.write_iops_log = 1;
1022 static int str_gtod_reduce_cb(void *data, int *il)
1024 struct thread_data *td = data;
1027 td->o.disable_lat = !!val;
1028 td->o.disable_clat = !!val;
1029 td->o.disable_slat = !!val;
1030 td->o.disable_bw = !!val;
1031 td->o.clat_percentiles = !val;
1033 td->tv_cache_mask = 63;
1038 static int str_gtod_cpu_cb(void *data, long long *il)
1040 struct thread_data *td = data;
1043 td->o.gtod_cpu = val;
1044 td->o.gtod_offload = 1;
1048 static int str_size_cb(void *data, unsigned long long *__val)
1050 struct thread_data *td = data;
1051 unsigned long long v = *__val;
1053 if (parse_is_percent(v)) {
1055 td->o.size_percent = -1ULL - v;
1062 static int rw_verify(struct fio_option *o, void *data)
1064 struct thread_data *td = data;
1066 if (read_only && td_write(td)) {
1067 log_err("fio: job <%s> has write bit set, but fio is in"
1068 " read-only mode\n", td->o.name);
1075 static int gtod_cpu_verify(struct fio_option *o, void *data)
1077 #ifndef FIO_HAVE_CPU_AFFINITY
1078 struct thread_data *td = data;
1080 if (td->o.gtod_cpu) {
1081 log_err("fio: platform must support CPU affinity for"
1082 "gettimeofday() offloading\n");
1091 * Map of job/command line options
1093 static struct fio_option options[FIO_MAX_OPTS] = {
1095 .name = "description",
1096 .type = FIO_OPT_STR_STORE,
1097 .off1 = td_var_offset(description),
1098 .help = "Text job description",
1102 .type = FIO_OPT_STR_STORE,
1103 .off1 = td_var_offset(name),
1104 .help = "Name of this job",
1107 .name = "directory",
1108 .type = FIO_OPT_STR_STORE,
1109 .off1 = td_var_offset(directory),
1110 .cb = str_directory_cb,
1111 .help = "Directory to store files in",
1115 .type = FIO_OPT_STR_STORE,
1116 .off1 = td_var_offset(filename),
1117 .cb = str_filename_cb,
1118 .prio = -1, /* must come after "directory" */
1119 .help = "File(s) to use for the workload",
1122 .name = "filename_format",
1123 .type = FIO_OPT_STR_STORE,
1124 .off1 = td_var_offset(filename_format),
1125 .prio = -1, /* must come after "directory" */
1126 .help = "Override default $jobname.$jobnum.$filenum naming",
1127 .def = "$jobname.$jobnum.$filenum",
1131 .type = FIO_OPT_INT,
1132 .off1 = td_var_offset(kb_base),
1138 .help = "Use 1024 as the K base",
1142 .help = "Use 1000 as the K base",
1145 .help = "How many bytes per KB for reporting (1000 or 1024)",
1148 .name = "unit_base",
1149 .type = FIO_OPT_INT,
1150 .off1 = td_var_offset(unit_base),
1155 .help = "Auto-detect",
1159 .help = "Normal (byte based)",
1163 .help = "Bit based",
1166 .help = "Bit multiple of result summary data (8 for byte, 1 for bit)",
1170 .type = FIO_OPT_STR,
1171 .off1 = td_var_offset(file_lock_mode),
1172 .help = "Lock file when doing IO to it",
1173 .parent = "filename",
1177 .oval = FILE_LOCK_NONE,
1178 .help = "No file locking",
1180 { .ival = "exclusive",
1181 .oval = FILE_LOCK_EXCLUSIVE,
1182 .help = "Exclusive file lock",
1185 .ival = "readwrite",
1186 .oval = FILE_LOCK_READWRITE,
1187 .help = "Read vs write lock",
1193 .type = FIO_OPT_STR_STORE,
1194 .off1 = td_var_offset(opendir),
1195 .cb = str_opendir_cb,
1196 .help = "Recursively add files from this directory and down",
1200 .alias = "readwrite",
1201 .type = FIO_OPT_STR,
1203 .off1 = td_var_offset(td_ddir),
1204 .help = "IO direction",
1206 .verify = rw_verify,
1209 .oval = TD_DDIR_READ,
1210 .help = "Sequential read",
1213 .oval = TD_DDIR_WRITE,
1214 .help = "Sequential write",
1217 .oval = TD_DDIR_TRIM,
1218 .help = "Sequential trim",
1220 { .ival = "randread",
1221 .oval = TD_DDIR_RANDREAD,
1222 .help = "Random read",
1224 { .ival = "randwrite",
1225 .oval = TD_DDIR_RANDWRITE,
1226 .help = "Random write",
1228 { .ival = "randtrim",
1229 .oval = TD_DDIR_RANDTRIM,
1230 .help = "Random trim",
1234 .help = "Sequential read and write mix",
1236 { .ival = "readwrite",
1238 .help = "Sequential read and write mix",
1241 .oval = TD_DDIR_RANDRW,
1242 .help = "Random read and write mix"
1247 .name = "rw_sequencer",
1248 .type = FIO_OPT_STR,
1249 .off1 = td_var_offset(rw_seq),
1250 .help = "IO offset generator modifier",
1251 .def = "sequential",
1253 { .ival = "sequential",
1255 .help = "Generate sequential offsets",
1257 { .ival = "identical",
1258 .oval = RW_SEQ_IDENT,
1259 .help = "Generate identical offsets",
1266 .type = FIO_OPT_STR_STORE,
1267 .off1 = td_var_offset(ioengine),
1268 .help = "IO engine to use",
1269 .def = FIO_PREFERRED_ENGINE,
1272 .help = "Use read/write",
1275 .help = "Use pread/pwrite",
1278 .help = "Use readv/writev",
1280 #ifdef CONFIG_LIBAIO
1282 .help = "Linux native asynchronous IO",
1285 #ifdef CONFIG_POSIXAIO
1286 { .ival = "posixaio",
1287 .help = "POSIX asynchronous IO",
1290 #ifdef CONFIG_SOLARISAIO
1291 { .ival = "solarisaio",
1292 .help = "Solaris native asynchronous IO",
1295 #ifdef CONFIG_WINDOWSAIO
1296 { .ival = "windowsaio",
1297 .help = "Windows native asynchronous IO"
1301 .help = "Memory mapped IO"
1303 #ifdef CONFIG_LINUX_SPLICE
1305 .help = "splice/vmsplice based IO",
1307 { .ival = "netsplice",
1308 .help = "splice/vmsplice to/from the network",
1311 #ifdef FIO_HAVE_SGIO
1313 .help = "SCSI generic v3 IO",
1317 .help = "Testing engine (no data transfer)",
1320 .help = "Network IO",
1323 .help = "CPU cycle burner engine",
1327 .help = "GUASI IO engine",
1330 #ifdef FIO_HAVE_BINJECT
1331 { .ival = "binject",
1332 .help = "binject direct inject block engine",
1337 .help = "RDMA IO engine",
1340 #ifdef CONFIG_FUSION_AW
1341 { .ival = "fusion-aw-sync",
1342 .help = "Fusion-io atomic write engine",
1345 #ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
1346 { .ival = "e4defrag",
1347 .help = "ext4 defrag engine",
1350 #ifdef CONFIG_LINUX_FALLOCATE
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 CONFIG_POSIX_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 CONFIG_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 /* CONFIG_POSIX_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 CONFIG_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 #ifdef CONFIG_GETTIMEOFDAY
1751 { .ival = "gettimeofday",
1753 .help = "Use gettimeofday(2) for timing",
1756 #ifdef CONFIG_CLOCK_GETTIME
1757 { .ival = "clock_gettime",
1758 .oval = CS_CGETTIME,
1759 .help = "Use clock_gettime(2) for timing",
1762 #ifdef ARCH_HAVE_CPU_CLOCK
1764 .oval = CS_CPUCLOCK,
1765 .help = "Use CPU private clock",
1773 .type = FIO_OPT_STR,
1775 .off1 = td_var_offset(mem_type),
1776 .help = "Backing type for IO buffers",
1781 .help = "Use malloc(3) for IO buffers",
1785 .help = "Use shared memory segments for IO buffers",
1787 #ifdef FIO_HAVE_HUGETLB
1788 { .ival = "shmhuge",
1789 .oval = MEM_SHMHUGE,
1790 .help = "Like shm, but use huge pages",
1795 .help = "Use mmap(2) (file or anon) for IO buffers",
1797 #ifdef FIO_HAVE_HUGETLB
1798 { .ival = "mmaphuge",
1799 .oval = MEM_MMAPHUGE,
1800 .help = "Like mmap, but use huge pages",
1806 .name = "iomem_align",
1807 .alias = "mem_align",
1808 .type = FIO_OPT_INT,
1809 .off1 = td_var_offset(mem_align),
1811 .help = "IO memory buffer offset alignment",
1817 .type = FIO_OPT_STR,
1818 .off1 = td_var_offset(verify),
1819 .help = "Verify data written",
1820 .cb = str_verify_cb,
1824 .oval = VERIFY_NONE,
1825 .help = "Don't do IO verification",
1829 .help = "Use md5 checksums for verification",
1832 .oval = VERIFY_CRC64,
1833 .help = "Use crc64 checksums for verification",
1836 .oval = VERIFY_CRC32,
1837 .help = "Use crc32 checksums for verification",
1839 { .ival = "crc32c-intel",
1840 .oval = VERIFY_CRC32C,
1841 .help = "Use crc32c checksums for verification (hw assisted, if available)",
1844 .oval = VERIFY_CRC32C,
1845 .help = "Use crc32c checksums for verification (hw assisted, if available)",
1848 .oval = VERIFY_CRC16,
1849 .help = "Use crc16 checksums for verification",
1852 .oval = VERIFY_CRC7,
1853 .help = "Use crc7 checksums for verification",
1856 .oval = VERIFY_SHA1,
1857 .help = "Use sha1 checksums for verification",
1860 .oval = VERIFY_SHA256,
1861 .help = "Use sha256 checksums for verification",
1864 .oval = VERIFY_SHA512,
1865 .help = "Use sha512 checksums for verification",
1868 .oval = VERIFY_META,
1869 .help = "Use io information",
1873 .oval = VERIFY_NULL,
1874 .help = "Pretend to verify",
1879 .name = "do_verify",
1880 .type = FIO_OPT_BOOL,
1881 .off1 = td_var_offset(do_verify),
1882 .help = "Run verification stage after write",
1887 .name = "verifysort",
1888 .type = FIO_OPT_BOOL,
1889 .off1 = td_var_offset(verifysort),
1890 .help = "Sort written verify blocks for read back",
1895 .name = "verifysort_nr",
1896 .type = FIO_OPT_INT,
1897 .off1 = td_var_offset(verifysort_nr),
1898 .help = "Pre-load and sort verify blocks for a read workload",
1905 .name = "verify_interval",
1906 .type = FIO_OPT_INT,
1907 .off1 = td_var_offset(verify_interval),
1908 .minval = 2 * sizeof(struct verify_header),
1909 .help = "Store verify buffer header every N bytes",
1913 .name = "verify_offset",
1914 .type = FIO_OPT_INT,
1915 .help = "Offset verify header location by N bytes",
1917 .cb = str_verify_offset_cb,
1921 .name = "verify_pattern",
1922 .type = FIO_OPT_STR,
1923 .cb = str_verify_pattern_cb,
1924 .help = "Fill pattern for IO buffers",
1928 .name = "verify_fatal",
1929 .type = FIO_OPT_BOOL,
1930 .off1 = td_var_offset(verify_fatal),
1932 .help = "Exit on a single verify failure, don't continue",
1936 .name = "verify_dump",
1937 .type = FIO_OPT_BOOL,
1938 .off1 = td_var_offset(verify_dump),
1940 .help = "Dump contents of good and bad blocks on failure",
1944 .name = "verify_async",
1945 .type = FIO_OPT_INT,
1946 .off1 = td_var_offset(verify_async),
1948 .help = "Number of async verifier threads to use",
1952 .name = "verify_backlog",
1953 .type = FIO_OPT_STR_VAL,
1954 .off1 = td_var_offset(verify_backlog),
1955 .help = "Verify after this number of blocks are written",
1959 .name = "verify_backlog_batch",
1960 .type = FIO_OPT_INT,
1961 .off1 = td_var_offset(verify_batch),
1962 .help = "Verify this number of IO blocks",
1965 #ifdef FIO_HAVE_CPU_AFFINITY
1967 .name = "verify_async_cpus",
1968 .type = FIO_OPT_STR,
1969 .cb = str_verify_cpus_allowed_cb,
1970 .help = "Set CPUs allowed for async verify threads",
1971 .parent = "verify_async",
1975 .name = "experimental_verify",
1976 .off1 = td_var_offset(experimental_verify),
1977 .type = FIO_OPT_BOOL,
1978 .help = "Enable experimental verification",
1980 #ifdef FIO_HAVE_TRIM
1982 .name = "trim_percentage",
1983 .type = FIO_OPT_INT,
1984 .cb = str_verify_trim_cb,
1986 .help = "Number of verify blocks to discard/trim",
1991 .name = "trim_verify_zero",
1992 .type = FIO_OPT_INT,
1993 .help = "Verify that trim/discarded blocks are returned as zeroes",
1994 .off1 = td_var_offset(trim_zero),
1995 .parent = "trim_percentage",
1999 .name = "trim_backlog",
2000 .type = FIO_OPT_STR_VAL,
2001 .off1 = td_var_offset(trim_backlog),
2002 .help = "Trim after this number of blocks are written",
2003 .parent = "trim_percentage",
2006 .name = "trim_backlog_batch",
2007 .type = FIO_OPT_INT,
2008 .off1 = td_var_offset(trim_batch),
2009 .help = "Trim this number of IO blocks",
2010 .parent = "trim_percentage",
2014 .name = "write_iolog",
2015 .type = FIO_OPT_STR_STORE,
2016 .off1 = td_var_offset(write_iolog_file),
2017 .help = "Store IO pattern to file",
2020 .name = "read_iolog",
2021 .type = FIO_OPT_STR_STORE,
2022 .off1 = td_var_offset(read_iolog_file),
2023 .help = "Playback IO pattern from file",
2026 .name = "replay_no_stall",
2027 .type = FIO_OPT_INT,
2028 .off1 = td_var_offset(no_stall),
2030 .parent = "read_iolog",
2031 .help = "Playback IO pattern file as fast as possible without stalls",
2034 .name = "replay_redirect",
2035 .type = FIO_OPT_STR_STORE,
2036 .off1 = td_var_offset(replay_redirect),
2037 .parent = "read_iolog",
2038 .help = "Replay all I/O onto this device, regardless of trace device",
2041 .name = "exec_prerun",
2042 .type = FIO_OPT_STR_STORE,
2043 .off1 = td_var_offset(exec_prerun),
2044 .help = "Execute this file prior to running job",
2047 .name = "exec_postrun",
2048 .type = FIO_OPT_STR_STORE,
2049 .off1 = td_var_offset(exec_postrun),
2050 .help = "Execute this file after running job",
2052 #ifdef FIO_HAVE_IOSCHED_SWITCH
2054 .name = "ioscheduler",
2055 .type = FIO_OPT_STR_STORE,
2056 .off1 = td_var_offset(ioscheduler),
2057 .help = "Use this IO scheduler on the backing device",
2062 .type = FIO_OPT_STR_VAL,
2063 .off1 = td_var_offset(zone_size),
2064 .help = "Amount of data to read per zone",
2068 .name = "zonerange",
2069 .type = FIO_OPT_STR_VAL,
2070 .off1 = td_var_offset(zone_range),
2071 .help = "Give size of an IO zone",
2076 .type = FIO_OPT_STR_VAL,
2077 .off1 = td_var_offset(zone_skip),
2078 .help = "Space between IO zones",
2083 .type = FIO_OPT_STR_VAL,
2084 .cb = str_lockmem_cb,
2085 .help = "Lock down this amount of memory",
2089 .name = "rwmixread",
2090 .type = FIO_OPT_INT,
2091 .cb = str_rwmix_read_cb,
2093 .help = "Percentage of mixed workload that is reads",
2097 .name = "rwmixwrite",
2098 .type = FIO_OPT_INT,
2099 .cb = str_rwmix_write_cb,
2101 .help = "Percentage of mixed workload that is writes",
2105 .name = "rwmixcycle",
2106 .type = FIO_OPT_DEPRECATED,
2110 .type = FIO_OPT_INT,
2111 .off1 = td_var_offset(nice),
2112 .help = "Set job CPU nice value",
2117 #ifdef FIO_HAVE_IOPRIO
2120 .type = FIO_OPT_INT,
2122 .help = "Set job IO priority value",
2127 .name = "prioclass",
2128 .type = FIO_OPT_INT,
2129 .cb = str_prioclass_cb,
2130 .help = "Set job IO priority class",
2136 .name = "thinktime",
2137 .type = FIO_OPT_INT,
2138 .off1 = td_var_offset(thinktime),
2139 .help = "Idle time between IO buffers (usec)",
2143 .name = "thinktime_spin",
2144 .type = FIO_OPT_INT,
2145 .off1 = td_var_offset(thinktime_spin),
2146 .help = "Start think time by spinning this amount (usec)",
2148 .parent = "thinktime",
2151 .name = "thinktime_blocks",
2152 .type = FIO_OPT_INT,
2153 .off1 = td_var_offset(thinktime_blocks),
2154 .help = "IO buffer period between 'thinktime'",
2156 .parent = "thinktime",
2160 .type = FIO_OPT_INT,
2161 .off1 = td_var_offset(rate[DDIR_READ]),
2162 .off2 = td_var_offset(rate[DDIR_WRITE]),
2163 .off3 = td_var_offset(rate[DDIR_TRIM]),
2164 .help = "Set bandwidth rate",
2168 .type = FIO_OPT_INT,
2169 .off1 = td_var_offset(ratemin[DDIR_READ]),
2170 .off2 = td_var_offset(ratemin[DDIR_WRITE]),
2171 .off3 = td_var_offset(ratemin[DDIR_TRIM]),
2172 .help = "Job must meet this rate or it will be shutdown",
2176 .name = "rate_iops",
2177 .type = FIO_OPT_INT,
2178 .off1 = td_var_offset(rate_iops[DDIR_READ]),
2179 .off2 = td_var_offset(rate_iops[DDIR_WRITE]),
2180 .off3 = td_var_offset(rate_iops[DDIR_TRIM]),
2181 .help = "Limit IO used to this number of IO operations/sec",
2184 .name = "rate_iops_min",
2185 .type = FIO_OPT_INT,
2186 .off1 = td_var_offset(rate_iops_min[DDIR_READ]),
2187 .off2 = td_var_offset(rate_iops_min[DDIR_WRITE]),
2188 .off3 = td_var_offset(rate_iops_min[DDIR_TRIM]),
2189 .help = "Job must meet this rate or it will be shut down",
2190 .parent = "rate_iops",
2193 .name = "ratecycle",
2194 .type = FIO_OPT_INT,
2195 .off1 = td_var_offset(ratecycle),
2196 .help = "Window average for rate limits (msec)",
2201 .name = "max_latency",
2202 .type = FIO_OPT_INT,
2203 .off1 = td_var_offset(max_latency),
2204 .help = "Maximum tolerated IO latency (usec)",
2207 .name = "invalidate",
2208 .type = FIO_OPT_BOOL,
2209 .off1 = td_var_offset(invalidate_cache),
2210 .help = "Invalidate buffer/page cache prior to running job",
2215 .type = FIO_OPT_BOOL,
2216 .off1 = td_var_offset(sync_io),
2217 .help = "Use O_SYNC for buffered writes",
2219 .parent = "buffered",
2222 .name = "bwavgtime",
2223 .type = FIO_OPT_INT,
2224 .off1 = td_var_offset(bw_avg_time),
2225 .help = "Time window over which to calculate bandwidth"
2228 .parent = "write_bw_log",
2231 .name = "iopsavgtime",
2232 .type = FIO_OPT_INT,
2233 .off1 = td_var_offset(iops_avg_time),
2234 .help = "Time window over which to calculate IOPS (msec)",
2236 .parent = "write_iops_log",
2239 .name = "create_serialize",
2240 .type = FIO_OPT_BOOL,
2241 .off1 = td_var_offset(create_serialize),
2242 .help = "Serialize creating of job files",
2246 .name = "create_fsync",
2247 .type = FIO_OPT_BOOL,
2248 .off1 = td_var_offset(create_fsync),
2249 .help = "fsync file after creation",
2253 .name = "create_on_open",
2254 .type = FIO_OPT_BOOL,
2255 .off1 = td_var_offset(create_on_open),
2256 .help = "Create files when they are opened for IO",
2260 .name = "create_only",
2261 .type = FIO_OPT_BOOL,
2262 .off1 = td_var_offset(create_only),
2263 .help = "Only perform file creation phase",
2268 .type = FIO_OPT_BOOL,
2269 .off1 = td_var_offset(pre_read),
2270 .help = "Pre-read files before starting official testing",
2275 .type = FIO_OPT_INT,
2276 .off1 = td_var_offset(cpuload),
2277 .help = "Use this percentage of CPU",
2280 .name = "cpuchunks",
2281 .type = FIO_OPT_INT,
2282 .off1 = td_var_offset(cpucycle),
2283 .help = "Length of the CPU burn cycles (usecs)",
2285 .parent = "cpuload",
2287 #ifdef FIO_HAVE_CPU_AFFINITY
2290 .type = FIO_OPT_INT,
2291 .cb = str_cpumask_cb,
2292 .help = "CPU affinity mask",
2295 .name = "cpus_allowed",
2296 .type = FIO_OPT_STR,
2297 .cb = str_cpus_allowed_cb,
2298 .help = "Set CPUs allowed",
2301 #ifdef CONFIG_LIBNUMA
2303 .name = "numa_cpu_nodes",
2304 .type = FIO_OPT_STR,
2305 .cb = str_numa_cpunodes_cb,
2306 .help = "NUMA CPU nodes bind",
2309 .name = "numa_mem_policy",
2310 .type = FIO_OPT_STR,
2311 .cb = str_numa_mpol_cb,
2312 .help = "NUMA memory policy setup",
2316 .name = "end_fsync",
2317 .type = FIO_OPT_BOOL,
2318 .off1 = td_var_offset(end_fsync),
2319 .help = "Include fsync at the end of job",
2323 .name = "fsync_on_close",
2324 .type = FIO_OPT_BOOL,
2325 .off1 = td_var_offset(fsync_on_close),
2326 .help = "fsync files on close",
2331 .type = FIO_OPT_BOOL,
2332 .off1 = td_var_offset(unlink),
2333 .help = "Unlink created files after job has completed",
2338 .type = FIO_OPT_STR_SET,
2339 .cb = str_exitall_cb,
2340 .help = "Terminate all jobs when one exits",
2343 .name = "stonewall",
2344 .alias = "wait_for_previous",
2345 .type = FIO_OPT_STR_SET,
2346 .off1 = td_var_offset(stonewall),
2347 .help = "Insert a hard barrier between this job and previous",
2350 .name = "new_group",
2351 .type = FIO_OPT_STR_SET,
2352 .off1 = td_var_offset(new_group),
2353 .help = "Mark the start of a new group (for reporting)",
2357 .type = FIO_OPT_STR_SET,
2358 .off1 = td_var_offset(use_thread),
2359 .help = "Use threads instead of forks",
2362 .name = "write_bw_log",
2363 .type = FIO_OPT_STR,
2364 .off1 = td_var_offset(write_bw_log),
2365 .cb = str_write_bw_log_cb,
2366 .help = "Write log of bandwidth during run",
2369 .name = "write_lat_log",
2370 .type = FIO_OPT_STR,
2371 .off1 = td_var_offset(write_lat_log),
2372 .cb = str_write_lat_log_cb,
2373 .help = "Write log of latency during run",
2376 .name = "write_iops_log",
2377 .type = FIO_OPT_STR,
2378 .off1 = td_var_offset(write_iops_log),
2379 .cb = str_write_iops_log_cb,
2380 .help = "Write log of IOPS during run",
2383 .name = "log_avg_msec",
2384 .type = FIO_OPT_INT,
2385 .off1 = td_var_offset(log_avg_msec),
2386 .help = "Average bw/iops/lat logs over this period of time",
2390 .name = "hugepage-size",
2391 .type = FIO_OPT_INT,
2392 .off1 = td_var_offset(hugepage_size),
2393 .help = "When using hugepages, specify size of each page",
2394 .def = __fio_stringify(FIO_HUGE_PAGE),
2397 .name = "group_reporting",
2398 .type = FIO_OPT_STR_SET,
2399 .off1 = td_var_offset(group_reporting),
2400 .help = "Do reporting on a per-group basis",
2403 .name = "zero_buffers",
2404 .type = FIO_OPT_STR_SET,
2405 .off1 = td_var_offset(zero_buffers),
2406 .help = "Init IO buffers to all zeroes",
2409 .name = "refill_buffers",
2410 .type = FIO_OPT_STR_SET,
2411 .off1 = td_var_offset(refill_buffers),
2412 .help = "Refill IO buffers on every IO submit",
2415 .name = "scramble_buffers",
2416 .type = FIO_OPT_BOOL,
2417 .off1 = td_var_offset(scramble_buffers),
2418 .help = "Slightly scramble buffers on every IO submit",
2422 .name = "buffer_compress_percentage",
2423 .type = FIO_OPT_INT,
2424 .off1 = td_var_offset(compress_percentage),
2427 .help = "How compressible the buffer is (approximately)",
2430 .name = "buffer_compress_chunk",
2431 .type = FIO_OPT_INT,
2432 .off1 = td_var_offset(compress_chunk),
2433 .parent = "buffer_compress_percentage",
2434 .help = "Size of compressible region in buffer",
2437 .name = "clat_percentiles",
2438 .type = FIO_OPT_BOOL,
2439 .off1 = td_var_offset(clat_percentiles),
2440 .help = "Enable the reporting of completion latency percentiles",
2444 .name = "percentile_list",
2445 .type = FIO_OPT_FLOAT_LIST,
2446 .off1 = td_var_offset(percentile_list),
2447 .off2 = td_var_offset(percentile_precision),
2448 .help = "Specify a custom list of percentiles to report",
2449 .def = "1:5:10:20:30:40:50:60:70:80:90:95:99:99.5:99.9:99.95:99.99",
2450 .maxlen = FIO_IO_U_LIST_MAX_LEN,
2455 #ifdef FIO_HAVE_DISK_UTIL
2457 .name = "disk_util",
2458 .type = FIO_OPT_BOOL,
2459 .off1 = td_var_offset(do_disk_util),
2460 .help = "Log disk utilization statistics",
2465 .name = "gtod_reduce",
2466 .type = FIO_OPT_BOOL,
2467 .help = "Greatly reduce number of gettimeofday() calls",
2468 .cb = str_gtod_reduce_cb,
2472 .name = "disable_lat",
2473 .type = FIO_OPT_BOOL,
2474 .off1 = td_var_offset(disable_lat),
2475 .help = "Disable latency numbers",
2476 .parent = "gtod_reduce",
2480 .name = "disable_clat",
2481 .type = FIO_OPT_BOOL,
2482 .off1 = td_var_offset(disable_clat),
2483 .help = "Disable completion latency numbers",
2484 .parent = "gtod_reduce",
2488 .name = "disable_slat",
2489 .type = FIO_OPT_BOOL,
2490 .off1 = td_var_offset(disable_slat),
2491 .help = "Disable submission latency numbers",
2492 .parent = "gtod_reduce",
2496 .name = "disable_bw_measurement",
2497 .type = FIO_OPT_BOOL,
2498 .off1 = td_var_offset(disable_bw),
2499 .help = "Disable bandwidth logging",
2500 .parent = "gtod_reduce",
2505 .type = FIO_OPT_INT,
2506 .cb = str_gtod_cpu_cb,
2507 .help = "Set up dedicated gettimeofday() thread on this CPU",
2508 .verify = gtod_cpu_verify,
2511 .name = "unified_rw_reporting",
2512 .type = FIO_OPT_BOOL,
2513 .off1 = td_var_offset(unified_rw_rep),
2514 .help = "Unify reporting across data direction",
2518 .name = "continue_on_error",
2519 .type = FIO_OPT_STR,
2520 .off1 = td_var_offset(continue_on_error),
2521 .help = "Continue on non-fatal errors during IO",
2525 .oval = ERROR_TYPE_NONE,
2526 .help = "Exit when an error is encountered",
2529 .oval = ERROR_TYPE_READ,
2530 .help = "Continue on read errors only",
2533 .oval = ERROR_TYPE_WRITE,
2534 .help = "Continue on write errors only",
2537 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
2538 .help = "Continue on any IO errors",
2541 .oval = ERROR_TYPE_VERIFY,
2542 .help = "Continue on verify errors only",
2545 .oval = ERROR_TYPE_ANY,
2546 .help = "Continue on all io and verify errors",
2549 .oval = ERROR_TYPE_NONE,
2550 .help = "Alias for 'none'",
2553 .oval = ERROR_TYPE_ANY,
2554 .help = "Alias for 'all'",
2559 .name = "ignore_error",
2560 .type = FIO_OPT_STR,
2561 .cb = str_ignore_error_cb,
2562 .help = "Set a specific list of errors to ignore",
2566 .name = "error_dump",
2567 .type = FIO_OPT_BOOL,
2568 .off1 = td_var_offset(error_dump),
2570 .help = "Dump info on each error",
2575 .type = FIO_OPT_STR_STORE,
2576 .off1 = td_var_offset(profile),
2577 .help = "Select a specific builtin performance test",
2581 .type = FIO_OPT_STR_STORE,
2582 .off1 = td_var_offset(cgroup),
2583 .help = "Add job to cgroup of this name",
2586 .name = "cgroup_weight",
2587 .type = FIO_OPT_INT,
2588 .off1 = td_var_offset(cgroup_weight),
2589 .help = "Use given weight for cgroup",
2594 .name = "cgroup_nodelete",
2595 .type = FIO_OPT_BOOL,
2596 .off1 = td_var_offset(cgroup_nodelete),
2597 .help = "Do not delete cgroups after job completion",
2602 .type = FIO_OPT_INT,
2603 .off1 = td_var_offset(uid),
2604 .help = "Run job with this user ID",
2608 .type = FIO_OPT_INT,
2609 .off1 = td_var_offset(gid),
2610 .help = "Run job with this group ID",
2614 .type = FIO_OPT_INT,
2615 .off1 = td_var_offset(flow_id),
2616 .help = "The flow index ID to use",
2621 .type = FIO_OPT_INT,
2622 .off1 = td_var_offset(flow),
2623 .help = "Weight for flow control of this job",
2624 .parent = "flow_id",
2628 .name = "flow_watermark",
2629 .type = FIO_OPT_INT,
2630 .off1 = td_var_offset(flow_watermark),
2631 .help = "High watermark for flow control. This option"
2632 " should be set to the same value for all threads"
2633 " with non-zero flow.",
2634 .parent = "flow_id",
2638 .name = "flow_sleep",
2639 .type = FIO_OPT_INT,
2640 .off1 = td_var_offset(flow_sleep),
2641 .help = "How many microseconds to sleep after being held"
2642 " back by the flow control mechanism",
2643 .parent = "flow_id",
2651 static void add_to_lopt(struct option *lopt, struct fio_option *o,
2652 const char *name, int val)
2654 lopt->name = (char *) name;
2656 if (o->type == FIO_OPT_STR_SET)
2657 lopt->has_arg = no_argument;
2659 lopt->has_arg = required_argument;
2662 static void options_to_lopts(struct fio_option *opts,
2663 struct option *long_options,
2664 int i, int option_type)
2666 struct fio_option *o = &opts[0];
2668 add_to_lopt(&long_options[i], o, o->name, option_type);
2671 add_to_lopt(&long_options[i], o, o->alias, option_type);
2676 assert(i < FIO_NR_OPTIONS);
2680 void fio_options_set_ioengine_opts(struct option *long_options,
2681 struct thread_data *td)
2686 while (long_options[i].name) {
2687 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
2688 memset(&long_options[i], 0, sizeof(*long_options));
2695 * Just clear out the prior ioengine options.
2700 options_to_lopts(td->io_ops->options, long_options, i,
2701 FIO_GETOPT_IOENGINE);
2704 void fio_options_dup_and_init(struct option *long_options)
2708 options_init(options);
2711 while (long_options[i].name)
2714 options_to_lopts(options, long_options, i, FIO_GETOPT_JOB);
2717 struct fio_keyword {
2723 static struct fio_keyword fio_keywords[] = {
2725 .word = "$pagesize",
2726 .desc = "Page size in the system",
2729 .word = "$mb_memory",
2730 .desc = "Megabytes of memory online",
2734 .desc = "Number of CPUs online in the system",
2741 void fio_keywords_init(void)
2743 unsigned long long mb_memory;
2747 sprintf(buf, "%lu", (unsigned long) page_size);
2748 fio_keywords[0].replace = strdup(buf);
2750 mb_memory = os_phys_mem() / (1024 * 1024);
2751 sprintf(buf, "%llu", mb_memory);
2752 fio_keywords[1].replace = strdup(buf);
2755 sprintf(buf, "%lu", l);
2756 fio_keywords[2].replace = strdup(buf);
2761 static char *bc_calc(char *str)
2763 char buf[128], *tmp;
2768 * No math, just return string
2770 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
2771 !strchr(str, '/')) || strchr(str, '\''))
2775 * Split option from value, we only need to calculate the value
2777 tmp = strchr(str, '=');
2784 * Prevent buffer overflows; such a case isn't reasonable anyway
2786 if (strlen(str) >= 128 || strlen(tmp) > 100)
2789 sprintf(buf, "which %s > /dev/null", BC_APP);
2791 log_err("fio: bc is needed for performing math\n");
2795 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
2796 f = popen(buf, "r");
2801 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
2807 buf[(tmp - str) + ret - 1] = '\0';
2808 memcpy(buf, str, tmp - str);
2814 * Return a copy of the input string with substrings of the form ${VARNAME}
2815 * substituted with the value of the environment variable VARNAME. The
2816 * substitution always occurs, even if VARNAME is empty or the corresponding
2817 * environment variable undefined.
2819 static char *option_dup_subs(const char *opt)
2821 char out[OPT_LEN_MAX+1];
2822 char in[OPT_LEN_MAX+1];
2825 char *ch1, *ch2, *env;
2826 ssize_t nchr = OPT_LEN_MAX;
2829 if (strlen(opt) + 1 > OPT_LEN_MAX) {
2830 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
2834 in[OPT_LEN_MAX] = '\0';
2835 strncpy(in, opt, OPT_LEN_MAX);
2837 while (*inptr && nchr > 0) {
2838 if (inptr[0] == '$' && inptr[1] == '{') {
2839 ch2 = strchr(inptr, '}');
2840 if (ch2 && inptr+1 < ch2) {
2847 envlen = strlen(env);
2848 if (envlen <= nchr) {
2849 memcpy(outptr, env, envlen);
2859 *outptr++ = *inptr++;
2868 * Look for reserved variable names and replace them with real values
2870 static char *fio_keyword_replace(char *opt)
2876 for (i = 0; fio_keywords[i].word != NULL; i++) {
2877 struct fio_keyword *kw = &fio_keywords[i];
2879 while ((s = strstr(opt, kw->word)) != NULL) {
2880 char *new = malloc(strlen(opt) + 1);
2886 * Copy part of the string before the keyword and
2887 * sprintf() the replacement after it.
2889 memcpy(new, opt, olen);
2890 len = sprintf(new + olen, "%s", kw->replace);
2893 * If there's more in the original string, copy that
2896 opt += strlen(kw->word) + olen;
2898 memcpy(new + olen + len, opt, opt - o_org - 1);
2901 * replace opt and free the old opt
2911 * Check for potential math and invoke bc, if possible
2919 static char **dup_and_sub_options(char **opts, int num_opts)
2922 char **opts_copy = malloc(num_opts * sizeof(*opts));
2923 for (i = 0; i < num_opts; i++) {
2924 opts_copy[i] = option_dup_subs(opts[i]);
2927 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
2932 int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
2934 int i, ret, unknown;
2937 sort_options(opts, options, num_opts);
2938 opts_copy = dup_and_sub_options(opts, num_opts);
2940 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
2941 struct fio_option *o;
2942 int newret = parse_option(opts_copy[i], opts[i], options, &o,
2951 opts_copy[i] = NULL;
2958 ret |= ioengine_load(td);
2960 sort_options(opts_copy, td->io_ops->options, num_opts);
2963 for (i = 0; i < num_opts; i++) {
2964 struct fio_option *o = NULL;
2970 newret = parse_option(opts_copy[i], opts[i],
2971 td->io_ops->options, &o,
2976 log_err("Bad option <%s>\n", opts[i]);
2979 opts_copy[i] = NULL;
2987 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
2989 return parse_cmd_option(opt, val, options, td);
2992 int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
2995 return parse_cmd_option(opt, val, td->io_ops->options, td);
2998 void fio_fill_default_options(struct thread_data *td)
3000 fill_default_options(td, options);
3003 int fio_show_option_help(const char *opt)
3005 return show_cmd_help(options, opt);
3008 void options_mem_dupe(void *data, struct fio_option *options)
3010 struct fio_option *o;
3013 for (o = &options[0]; o->name; o++) {
3014 if (o->type != FIO_OPT_STR_STORE)
3017 ptr = td_var(data, o->off1);
3019 *ptr = strdup(*ptr);
3024 * dupe FIO_OPT_STR_STORE options
3026 void fio_options_mem_dupe(struct thread_data *td)
3028 options_mem_dupe(&td->o, options);
3030 if (td->eo && td->io_ops) {
3031 void *oldeo = td->eo;
3033 td->eo = malloc(td->io_ops->option_struct_size);
3034 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
3035 options_mem_dupe(td->eo, td->io_ops->options);
3039 unsigned int fio_get_kb_base(void *data)
3041 struct thread_data *td = data;
3042 unsigned int kb_base = 0;
3045 kb_base = td->o.kb_base;
3052 int add_option(struct fio_option *o)
3054 struct fio_option *__o;
3063 memcpy(&options[opt_index], o, sizeof(*o));
3067 void invalidate_profile_options(const char *prof_name)
3069 struct fio_option *o;
3073 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
3074 o->type = FIO_OPT_INVALID;
3075 o->prof_name = NULL;
3081 void add_opt_posval(const char *optname, const char *ival, const char *help)
3083 struct fio_option *o;
3086 o = find_option(options, optname);
3090 for (i = 0; i < PARSE_MAX_VP; i++) {
3091 if (o->posval[i].ival)
3094 o->posval[i].ival = ival;
3095 o->posval[i].help = help;
3100 void del_opt_posval(const char *optname, const char *ival)
3102 struct fio_option *o;
3105 o = find_option(options, optname);
3109 for (i = 0; i < PARSE_MAX_VP; i++) {
3110 if (!o->posval[i].ival)
3112 if (strcmp(o->posval[i].ival, ival))
3115 o->posval[i].ival = NULL;
3116 o->posval[i].help = NULL;
3120 void fio_options_free(struct thread_data *td)
3122 options_free(options, td);
3123 if (td->eo && td->io_ops && td->io_ops->options) {
3124 options_free(td->io_ops->options, td->eo);