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_lockfile_cb(void *data, const char *str)
991 struct thread_data *td = data;
992 char *nr = get_opt_postfix(str);
994 td->o.lockfile_batch = 1;
996 td->o.lockfile_batch = atoi(nr);
1003 static int str_write_bw_log_cb(void *data, const char *str)
1005 struct thread_data *td = data;
1008 td->o.bw_log_file = strdup(str);
1010 td->o.write_bw_log = 1;
1014 static int str_write_lat_log_cb(void *data, const char *str)
1016 struct thread_data *td = data;
1019 td->o.lat_log_file = strdup(str);
1021 td->o.write_lat_log = 1;
1025 static int str_write_iops_log_cb(void *data, const char *str)
1027 struct thread_data *td = data;
1030 td->o.iops_log_file = strdup(str);
1032 td->o.write_iops_log = 1;
1036 static int str_gtod_reduce_cb(void *data, int *il)
1038 struct thread_data *td = data;
1041 td->o.disable_lat = !!val;
1042 td->o.disable_clat = !!val;
1043 td->o.disable_slat = !!val;
1044 td->o.disable_bw = !!val;
1045 td->o.clat_percentiles = !val;
1047 td->tv_cache_mask = 63;
1052 static int str_gtod_cpu_cb(void *data, long long *il)
1054 struct thread_data *td = data;
1057 td->o.gtod_cpu = val;
1058 td->o.gtod_offload = 1;
1062 static int str_size_cb(void *data, unsigned long long *__val)
1064 struct thread_data *td = data;
1065 unsigned long long v = *__val;
1067 if (parse_is_percent(v)) {
1069 td->o.size_percent = -1ULL - v;
1076 static int rw_verify(struct fio_option *o, void *data)
1078 struct thread_data *td = data;
1080 if (read_only && td_write(td)) {
1081 log_err("fio: job <%s> has write bit set, but fio is in"
1082 " read-only mode\n", td->o.name);
1089 static int gtod_cpu_verify(struct fio_option *o, void *data)
1091 #ifndef FIO_HAVE_CPU_AFFINITY
1092 struct thread_data *td = data;
1094 if (td->o.gtod_cpu) {
1095 log_err("fio: platform must support CPU affinity for"
1096 "gettimeofday() offloading\n");
1104 static int kb_base_verify(struct fio_option *o, void *data)
1106 struct thread_data *td = data;
1108 if (td->o.kb_base != 1024 && td->o.kb_base != 1000) {
1109 log_err("fio: kb_base set to nonsensical value: %u\n",
1118 * Map of job/command line options
1120 static struct fio_option options[FIO_MAX_OPTS] = {
1122 .name = "description",
1123 .type = FIO_OPT_STR_STORE,
1124 .off1 = td_var_offset(description),
1125 .help = "Text job description",
1129 .type = FIO_OPT_STR_STORE,
1130 .off1 = td_var_offset(name),
1131 .help = "Name of this job",
1134 .name = "directory",
1135 .type = FIO_OPT_STR_STORE,
1136 .off1 = td_var_offset(directory),
1137 .cb = str_directory_cb,
1138 .help = "Directory to store files in",
1142 .type = FIO_OPT_STR_STORE,
1143 .off1 = td_var_offset(filename),
1144 .cb = str_filename_cb,
1145 .prio = -1, /* must come after "directory" */
1146 .help = "File(s) to use for the workload",
1150 .type = FIO_OPT_INT,
1151 .off1 = td_var_offset(kb_base),
1152 .verify = kb_base_verify,
1155 .help = "How many bytes per KB for reporting (1000 or 1024)",
1159 .type = FIO_OPT_STR,
1160 .cb = str_lockfile_cb,
1161 .off1 = td_var_offset(file_lock_mode),
1162 .help = "Lock file when doing IO to it",
1163 .parent = "filename",
1167 .oval = FILE_LOCK_NONE,
1168 .help = "No file locking",
1170 { .ival = "exclusive",
1171 .oval = FILE_LOCK_EXCLUSIVE,
1172 .help = "Exclusive file lock",
1175 .ival = "readwrite",
1176 .oval = FILE_LOCK_READWRITE,
1177 .help = "Read vs write lock",
1183 .type = FIO_OPT_STR_STORE,
1184 .off1 = td_var_offset(opendir),
1185 .cb = str_opendir_cb,
1186 .help = "Recursively add files from this directory and down",
1190 .alias = "readwrite",
1191 .type = FIO_OPT_STR,
1193 .off1 = td_var_offset(td_ddir),
1194 .help = "IO direction",
1196 .verify = rw_verify,
1199 .oval = TD_DDIR_READ,
1200 .help = "Sequential read",
1203 .oval = TD_DDIR_WRITE,
1204 .help = "Sequential write",
1207 .oval = TD_DDIR_TRIM,
1208 .help = "Sequential trim",
1210 { .ival = "randread",
1211 .oval = TD_DDIR_RANDREAD,
1212 .help = "Random read",
1214 { .ival = "randwrite",
1215 .oval = TD_DDIR_RANDWRITE,
1216 .help = "Random write",
1218 { .ival = "randtrim",
1219 .oval = TD_DDIR_RANDTRIM,
1220 .help = "Random trim",
1224 .help = "Sequential read and write mix",
1226 { .ival = "readwrite",
1228 .help = "Sequential read and write mix",
1231 .oval = TD_DDIR_RANDRW,
1232 .help = "Random read and write mix"
1237 .name = "rw_sequencer",
1238 .type = FIO_OPT_STR,
1239 .off1 = td_var_offset(rw_seq),
1240 .help = "IO offset generator modifier",
1241 .def = "sequential",
1243 { .ival = "sequential",
1245 .help = "Generate sequential offsets",
1247 { .ival = "identical",
1248 .oval = RW_SEQ_IDENT,
1249 .help = "Generate identical offsets",
1256 .type = FIO_OPT_STR_STORE,
1257 .off1 = td_var_offset(ioengine),
1258 .help = "IO engine to use",
1259 .def = FIO_PREFERRED_ENGINE,
1262 .help = "Use read/write",
1265 .help = "Use pread/pwrite",
1268 .help = "Use readv/writev",
1270 #ifdef CONFIG_LIBAIO
1272 .help = "Linux native asynchronous IO",
1275 #ifdef CONFIG_POSIXAIO
1276 { .ival = "posixaio",
1277 .help = "POSIX asynchronous IO",
1280 #ifdef CONFIG_SOLARISAIO
1281 { .ival = "solarisaio",
1282 .help = "Solaris native asynchronous IO",
1285 #ifdef CONFIG_WINDOWSAIO
1286 { .ival = "windowsaio",
1287 .help = "Windows native asynchronous IO"
1291 .help = "Memory mapped IO"
1293 #ifdef CONFIG_LINUX_SPLICE
1295 .help = "splice/vmsplice based IO",
1297 { .ival = "netsplice",
1298 .help = "splice/vmsplice to/from the network",
1301 #ifdef FIO_HAVE_SGIO
1303 .help = "SCSI generic v3 IO",
1307 .help = "Testing engine (no data transfer)",
1310 .help = "Network IO",
1313 .help = "CPU cycle burner engine",
1317 .help = "GUASI IO engine",
1320 #ifdef FIO_HAVE_BINJECT
1321 { .ival = "binject",
1322 .help = "binject direct inject block engine",
1327 .help = "RDMA IO engine",
1330 #ifdef CONFIG_FUSION_AW
1331 { .ival = "fusion-aw-sync",
1332 .help = "Fusion-io atomic write engine",
1335 #ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
1336 { .ival = "e4defrag",
1337 .help = "ext4 defrag engine",
1340 #ifdef CONFIG_LINUX_FALLOCATE
1342 .help = "fallocate() file based engine",
1345 { .ival = "external",
1346 .help = "Load external engine (append name)",
1352 .type = FIO_OPT_INT,
1353 .off1 = td_var_offset(iodepth),
1354 .help = "Number of IO buffers to keep in flight",
1359 .name = "iodepth_batch",
1360 .alias = "iodepth_batch_submit",
1361 .type = FIO_OPT_INT,
1362 .off1 = td_var_offset(iodepth_batch),
1363 .help = "Number of IO buffers to submit in one go",
1364 .parent = "iodepth",
1369 .name = "iodepth_batch_complete",
1370 .type = FIO_OPT_INT,
1371 .off1 = td_var_offset(iodepth_batch_complete),
1372 .help = "Number of IO buffers to retrieve in one go",
1373 .parent = "iodepth",
1378 .name = "iodepth_low",
1379 .type = FIO_OPT_INT,
1380 .off1 = td_var_offset(iodepth_low),
1381 .help = "Low water mark for queuing depth",
1382 .parent = "iodepth",
1386 .type = FIO_OPT_STR_VAL,
1388 .help = "Total size of device or files",
1391 .name = "fill_device",
1393 .type = FIO_OPT_BOOL,
1394 .off1 = td_var_offset(fill_device),
1395 .help = "Write until an ENOSPC error occurs",
1400 .type = FIO_OPT_STR_VAL,
1401 .off1 = td_var_offset(file_size_low),
1402 .off2 = td_var_offset(file_size_high),
1404 .help = "Size of individual files",
1408 .alias = "fileoffset",
1409 .type = FIO_OPT_STR_VAL,
1410 .off1 = td_var_offset(start_offset),
1411 .help = "Start IO from this offset",
1415 .name = "offset_increment",
1416 .type = FIO_OPT_STR_VAL,
1417 .off1 = td_var_offset(offset_increment),
1418 .help = "What is the increment from one offset to the next",
1424 .alias = "blocksize",
1425 .type = FIO_OPT_INT,
1426 .off1 = td_var_offset(bs[DDIR_READ]),
1427 .off2 = td_var_offset(bs[DDIR_WRITE]),
1428 .off3 = td_var_offset(bs[DDIR_TRIM]),
1430 .help = "Block size unit",
1436 .alias = "blockalign",
1437 .type = FIO_OPT_INT,
1438 .off1 = td_var_offset(ba[DDIR_READ]),
1439 .off2 = td_var_offset(ba[DDIR_WRITE]),
1440 .off3 = td_var_offset(ba[DDIR_TRIM]),
1442 .help = "IO block offset alignment",
1447 .alias = "blocksize_range",
1448 .type = FIO_OPT_RANGE,
1449 .off1 = td_var_offset(min_bs[DDIR_READ]),
1450 .off2 = td_var_offset(max_bs[DDIR_READ]),
1451 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
1452 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
1453 .off5 = td_var_offset(min_bs[DDIR_TRIM]),
1454 .off6 = td_var_offset(max_bs[DDIR_TRIM]),
1456 .help = "Set block size range (in more detail than bs)",
1461 .type = FIO_OPT_STR,
1462 .cb = str_bssplit_cb,
1463 .help = "Set a specific mix of block sizes",
1467 .name = "bs_unaligned",
1468 .alias = "blocksize_unaligned",
1469 .type = FIO_OPT_STR_SET,
1470 .off1 = td_var_offset(bs_unaligned),
1471 .help = "Don't sector align IO buffer sizes",
1475 .name = "randrepeat",
1476 .type = FIO_OPT_BOOL,
1477 .off1 = td_var_offset(rand_repeatable),
1478 .help = "Use repeatable random IO pattern",
1483 .name = "use_os_rand",
1484 .type = FIO_OPT_BOOL,
1485 .off1 = td_var_offset(use_os_rand),
1486 .help = "Set to use OS random generator",
1491 .name = "norandommap",
1492 .type = FIO_OPT_STR_SET,
1493 .off1 = td_var_offset(norandommap),
1494 .help = "Accept potential duplicate random blocks",
1498 .name = "softrandommap",
1499 .type = FIO_OPT_BOOL,
1500 .off1 = td_var_offset(softrandommap),
1501 .help = "Set norandommap if randommap allocation fails",
1502 .parent = "norandommap",
1506 .name = "random_generator",
1507 .type = FIO_OPT_STR,
1508 .off1 = td_var_offset(random_generator),
1509 .help = "Type of random number generator to use",
1510 .def = "tausworthe",
1512 { .ival = "tausworthe",
1513 .oval = FIO_RAND_GEN_TAUSWORTHE,
1514 .help = "Strong Tausworthe generator",
1517 .oval = FIO_RAND_GEN_LFSR,
1518 .help = "Variable length LFSR",
1523 .name = "random_distribution",
1524 .type = FIO_OPT_STR,
1525 .off1 = td_var_offset(random_distribution),
1526 .cb = str_random_distribution_cb,
1527 .help = "Random offset distribution generator",
1531 .oval = FIO_RAND_DIST_RANDOM,
1532 .help = "Completely random",
1535 .oval = FIO_RAND_DIST_ZIPF,
1536 .help = "Zipf distribution",
1539 .oval = FIO_RAND_DIST_PARETO,
1540 .help = "Pareto distribution",
1546 .alias = "nr_files",
1547 .type = FIO_OPT_INT,
1548 .off1 = td_var_offset(nr_files),
1549 .help = "Split job workload between this number of files",
1553 .name = "openfiles",
1554 .type = FIO_OPT_INT,
1555 .off1 = td_var_offset(open_files),
1556 .help = "Number of files to keep open at the same time",
1559 .name = "file_service_type",
1560 .type = FIO_OPT_STR,
1562 .off1 = td_var_offset(file_service_type),
1563 .help = "How to select which file to service next",
1564 .def = "roundrobin",
1567 .oval = FIO_FSERVICE_RANDOM,
1568 .help = "Choose a file at random",
1570 { .ival = "roundrobin",
1571 .oval = FIO_FSERVICE_RR,
1572 .help = "Round robin select files",
1574 { .ival = "sequential",
1575 .oval = FIO_FSERVICE_SEQ,
1576 .help = "Finish one file before moving to the next",
1579 .parent = "nrfiles",
1581 #ifdef CONFIG_POSIX_FALLOCATE
1583 .name = "fallocate",
1584 .type = FIO_OPT_STR,
1585 .off1 = td_var_offset(fallocate_mode),
1586 .help = "Whether pre-allocation is performed when laying out files",
1590 .oval = FIO_FALLOCATE_NONE,
1591 .help = "Do not pre-allocate space",
1594 .oval = FIO_FALLOCATE_POSIX,
1595 .help = "Use posix_fallocate()",
1597 #ifdef CONFIG_LINUX_FALLOCATE
1599 .oval = FIO_FALLOCATE_KEEP_SIZE,
1600 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
1603 /* Compatibility with former boolean values */
1605 .oval = FIO_FALLOCATE_NONE,
1606 .help = "Alias for 'none'",
1609 .oval = FIO_FALLOCATE_POSIX,
1610 .help = "Alias for 'posix'",
1614 #endif /* CONFIG_POSIX_FALLOCATE */
1616 .name = "fadvise_hint",
1617 .type = FIO_OPT_BOOL,
1618 .off1 = td_var_offset(fadvise_hint),
1619 .help = "Use fadvise() to advise the kernel on IO pattern",
1624 .type = FIO_OPT_INT,
1625 .off1 = td_var_offset(fsync_blocks),
1626 .help = "Issue fsync for writes every given number of blocks",
1630 .name = "fdatasync",
1631 .type = FIO_OPT_INT,
1632 .off1 = td_var_offset(fdatasync_blocks),
1633 .help = "Issue fdatasync for writes every given number of blocks",
1637 .name = "write_barrier",
1638 .type = FIO_OPT_INT,
1639 .off1 = td_var_offset(barrier_blocks),
1640 .help = "Make every Nth write a barrier write",
1643 #ifdef CONFIG_SYNC_FILE_RANGE
1645 .name = "sync_file_range",
1647 { .ival = "wait_before",
1648 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
1649 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
1653 .oval = SYNC_FILE_RANGE_WRITE,
1654 .help = "SYNC_FILE_RANGE_WRITE",
1658 .ival = "wait_after",
1659 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
1660 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
1664 .type = FIO_OPT_STR_MULTI,
1666 .off1 = td_var_offset(sync_file_range),
1667 .help = "Use sync_file_range()",
1672 .type = FIO_OPT_BOOL,
1673 .off1 = td_var_offset(odirect),
1674 .help = "Use O_DIRECT IO (negates buffered)",
1679 .type = FIO_OPT_BOOL,
1680 .off1 = td_var_offset(odirect),
1682 .help = "Use buffered IO (negates direct)",
1686 .name = "overwrite",
1687 .type = FIO_OPT_BOOL,
1688 .off1 = td_var_offset(overwrite),
1689 .help = "When writing, set whether to overwrite current data",
1694 .type = FIO_OPT_INT,
1695 .off1 = td_var_offset(loops),
1696 .help = "Number of times to run the job",
1701 .type = FIO_OPT_INT,
1702 .off1 = td_var_offset(numjobs),
1703 .help = "Duplicate this job this many times",
1707 .name = "startdelay",
1708 .type = FIO_OPT_STR_VAL_TIME,
1709 .off1 = td_var_offset(start_delay),
1710 .help = "Only start job when this period has passed",
1716 .type = FIO_OPT_STR_VAL_TIME,
1717 .off1 = td_var_offset(timeout),
1718 .help = "Stop workload when this amount of time has passed",
1722 .name = "time_based",
1723 .type = FIO_OPT_STR_SET,
1724 .off1 = td_var_offset(time_based),
1725 .help = "Keep running until runtime/timeout is met",
1728 .name = "ramp_time",
1729 .type = FIO_OPT_STR_VAL_TIME,
1730 .off1 = td_var_offset(ramp_time),
1731 .help = "Ramp up time before measuring performance",
1734 .name = "clocksource",
1735 .type = FIO_OPT_STR,
1736 .cb = fio_clock_source_cb,
1737 .off1 = td_var_offset(clocksource),
1738 .help = "What type of timing source to use",
1740 #ifdef CONFIG_GETTIMEOFDAY
1741 { .ival = "gettimeofday",
1743 .help = "Use gettimeofday(2) for timing",
1746 #ifdef CONFIG_CLOCK_GETTIME
1747 { .ival = "clock_gettime",
1748 .oval = CS_CGETTIME,
1749 .help = "Use clock_gettime(2) for timing",
1752 #ifdef ARCH_HAVE_CPU_CLOCK
1754 .oval = CS_CPUCLOCK,
1755 .help = "Use CPU private clock",
1763 .type = FIO_OPT_STR,
1765 .off1 = td_var_offset(mem_type),
1766 .help = "Backing type for IO buffers",
1771 .help = "Use malloc(3) for IO buffers",
1775 .help = "Use shared memory segments for IO buffers",
1777 #ifdef FIO_HAVE_HUGETLB
1778 { .ival = "shmhuge",
1779 .oval = MEM_SHMHUGE,
1780 .help = "Like shm, but use huge pages",
1785 .help = "Use mmap(2) (file or anon) for IO buffers",
1787 #ifdef FIO_HAVE_HUGETLB
1788 { .ival = "mmaphuge",
1789 .oval = MEM_MMAPHUGE,
1790 .help = "Like mmap, but use huge pages",
1796 .name = "iomem_align",
1797 .alias = "mem_align",
1798 .type = FIO_OPT_INT,
1799 .off1 = td_var_offset(mem_align),
1801 .help = "IO memory buffer offset alignment",
1807 .type = FIO_OPT_STR,
1808 .off1 = td_var_offset(verify),
1809 .help = "Verify data written",
1810 .cb = str_verify_cb,
1814 .oval = VERIFY_NONE,
1815 .help = "Don't do IO verification",
1819 .help = "Use md5 checksums for verification",
1822 .oval = VERIFY_CRC64,
1823 .help = "Use crc64 checksums for verification",
1826 .oval = VERIFY_CRC32,
1827 .help = "Use crc32 checksums for verification",
1829 { .ival = "crc32c-intel",
1830 .oval = VERIFY_CRC32C,
1831 .help = "Use crc32c checksums for verification (hw assisted, if available)",
1834 .oval = VERIFY_CRC32C,
1835 .help = "Use crc32c checksums for verification (hw assisted, if available)",
1838 .oval = VERIFY_CRC16,
1839 .help = "Use crc16 checksums for verification",
1842 .oval = VERIFY_CRC7,
1843 .help = "Use crc7 checksums for verification",
1846 .oval = VERIFY_SHA1,
1847 .help = "Use sha1 checksums for verification",
1850 .oval = VERIFY_SHA256,
1851 .help = "Use sha256 checksums for verification",
1854 .oval = VERIFY_SHA512,
1855 .help = "Use sha512 checksums for verification",
1858 .oval = VERIFY_META,
1859 .help = "Use io information",
1863 .oval = VERIFY_NULL,
1864 .help = "Pretend to verify",
1869 .name = "do_verify",
1870 .type = FIO_OPT_BOOL,
1871 .off1 = td_var_offset(do_verify),
1872 .help = "Run verification stage after write",
1877 .name = "verifysort",
1878 .type = FIO_OPT_BOOL,
1879 .off1 = td_var_offset(verifysort),
1880 .help = "Sort written verify blocks for read back",
1885 .name = "verifysort_nr",
1886 .type = FIO_OPT_INT,
1887 .off1 = td_var_offset(verifysort_nr),
1888 .help = "Pre-load and sort verify blocks for a read workload",
1895 .name = "verify_interval",
1896 .type = FIO_OPT_INT,
1897 .off1 = td_var_offset(verify_interval),
1898 .minval = 2 * sizeof(struct verify_header),
1899 .help = "Store verify buffer header every N bytes",
1903 .name = "verify_offset",
1904 .type = FIO_OPT_INT,
1905 .help = "Offset verify header location by N bytes",
1907 .cb = str_verify_offset_cb,
1911 .name = "verify_pattern",
1912 .type = FIO_OPT_STR,
1913 .cb = str_verify_pattern_cb,
1914 .help = "Fill pattern for IO buffers",
1918 .name = "verify_fatal",
1919 .type = FIO_OPT_BOOL,
1920 .off1 = td_var_offset(verify_fatal),
1922 .help = "Exit on a single verify failure, don't continue",
1926 .name = "verify_dump",
1927 .type = FIO_OPT_BOOL,
1928 .off1 = td_var_offset(verify_dump),
1930 .help = "Dump contents of good and bad blocks on failure",
1934 .name = "verify_async",
1935 .type = FIO_OPT_INT,
1936 .off1 = td_var_offset(verify_async),
1938 .help = "Number of async verifier threads to use",
1942 .name = "verify_backlog",
1943 .type = FIO_OPT_STR_VAL,
1944 .off1 = td_var_offset(verify_backlog),
1945 .help = "Verify after this number of blocks are written",
1949 .name = "verify_backlog_batch",
1950 .type = FIO_OPT_INT,
1951 .off1 = td_var_offset(verify_batch),
1952 .help = "Verify this number of IO blocks",
1955 #ifdef FIO_HAVE_CPU_AFFINITY
1957 .name = "verify_async_cpus",
1958 .type = FIO_OPT_STR,
1959 .cb = str_verify_cpus_allowed_cb,
1960 .help = "Set CPUs allowed for async verify threads",
1961 .parent = "verify_async",
1965 .name = "experimental_verify",
1966 .off1 = td_var_offset(experimental_verify),
1967 .type = FIO_OPT_BOOL,
1968 .help = "Enable experimental verification",
1970 #ifdef FIO_HAVE_TRIM
1972 .name = "trim_percentage",
1973 .type = FIO_OPT_INT,
1974 .cb = str_verify_trim_cb,
1976 .help = "Number of verify blocks to discard/trim",
1981 .name = "trim_verify_zero",
1982 .type = FIO_OPT_INT,
1983 .help = "Verify that trim/discarded blocks are returned as zeroes",
1984 .off1 = td_var_offset(trim_zero),
1985 .parent = "trim_percentage",
1989 .name = "trim_backlog",
1990 .type = FIO_OPT_STR_VAL,
1991 .off1 = td_var_offset(trim_backlog),
1992 .help = "Trim after this number of blocks are written",
1993 .parent = "trim_percentage",
1996 .name = "trim_backlog_batch",
1997 .type = FIO_OPT_INT,
1998 .off1 = td_var_offset(trim_batch),
1999 .help = "Trim this number of IO blocks",
2000 .parent = "trim_percentage",
2004 .name = "write_iolog",
2005 .type = FIO_OPT_STR_STORE,
2006 .off1 = td_var_offset(write_iolog_file),
2007 .help = "Store IO pattern to file",
2010 .name = "read_iolog",
2011 .type = FIO_OPT_STR_STORE,
2012 .off1 = td_var_offset(read_iolog_file),
2013 .help = "Playback IO pattern from file",
2016 .name = "replay_no_stall",
2017 .type = FIO_OPT_INT,
2018 .off1 = td_var_offset(no_stall),
2020 .parent = "read_iolog",
2021 .help = "Playback IO pattern file as fast as possible without stalls",
2024 .name = "replay_redirect",
2025 .type = FIO_OPT_STR_STORE,
2026 .off1 = td_var_offset(replay_redirect),
2027 .parent = "read_iolog",
2028 .help = "Replay all I/O onto this device, regardless of trace device",
2031 .name = "exec_prerun",
2032 .type = FIO_OPT_STR_STORE,
2033 .off1 = td_var_offset(exec_prerun),
2034 .help = "Execute this file prior to running job",
2037 .name = "exec_postrun",
2038 .type = FIO_OPT_STR_STORE,
2039 .off1 = td_var_offset(exec_postrun),
2040 .help = "Execute this file after running job",
2042 #ifdef FIO_HAVE_IOSCHED_SWITCH
2044 .name = "ioscheduler",
2045 .type = FIO_OPT_STR_STORE,
2046 .off1 = td_var_offset(ioscheduler),
2047 .help = "Use this IO scheduler on the backing device",
2052 .type = FIO_OPT_STR_VAL,
2053 .off1 = td_var_offset(zone_size),
2054 .help = "Amount of data to read per zone",
2058 .name = "zonerange",
2059 .type = FIO_OPT_STR_VAL,
2060 .off1 = td_var_offset(zone_range),
2061 .help = "Give size of an IO zone",
2066 .type = FIO_OPT_STR_VAL,
2067 .off1 = td_var_offset(zone_skip),
2068 .help = "Space between IO zones",
2073 .type = FIO_OPT_STR_VAL,
2074 .cb = str_lockmem_cb,
2075 .help = "Lock down this amount of memory",
2079 .name = "rwmixread",
2080 .type = FIO_OPT_INT,
2081 .cb = str_rwmix_read_cb,
2083 .help = "Percentage of mixed workload that is reads",
2087 .name = "rwmixwrite",
2088 .type = FIO_OPT_INT,
2089 .cb = str_rwmix_write_cb,
2091 .help = "Percentage of mixed workload that is writes",
2095 .name = "rwmixcycle",
2096 .type = FIO_OPT_DEPRECATED,
2100 .type = FIO_OPT_INT,
2101 .off1 = td_var_offset(nice),
2102 .help = "Set job CPU nice value",
2107 #ifdef FIO_HAVE_IOPRIO
2110 .type = FIO_OPT_INT,
2112 .help = "Set job IO priority value",
2117 .name = "prioclass",
2118 .type = FIO_OPT_INT,
2119 .cb = str_prioclass_cb,
2120 .help = "Set job IO priority class",
2126 .name = "thinktime",
2127 .type = FIO_OPT_INT,
2128 .off1 = td_var_offset(thinktime),
2129 .help = "Idle time between IO buffers (usec)",
2133 .name = "thinktime_spin",
2134 .type = FIO_OPT_INT,
2135 .off1 = td_var_offset(thinktime_spin),
2136 .help = "Start think time by spinning this amount (usec)",
2138 .parent = "thinktime",
2141 .name = "thinktime_blocks",
2142 .type = FIO_OPT_INT,
2143 .off1 = td_var_offset(thinktime_blocks),
2144 .help = "IO buffer period between 'thinktime'",
2146 .parent = "thinktime",
2150 .type = FIO_OPT_INT,
2151 .off1 = td_var_offset(rate[DDIR_READ]),
2152 .off2 = td_var_offset(rate[DDIR_WRITE]),
2153 .off3 = td_var_offset(rate[DDIR_TRIM]),
2154 .help = "Set bandwidth rate",
2158 .type = FIO_OPT_INT,
2159 .off1 = td_var_offset(ratemin[DDIR_READ]),
2160 .off2 = td_var_offset(ratemin[DDIR_WRITE]),
2161 .off3 = td_var_offset(ratemin[DDIR_TRIM]),
2162 .help = "Job must meet this rate or it will be shutdown",
2166 .name = "rate_iops",
2167 .type = FIO_OPT_INT,
2168 .off1 = td_var_offset(rate_iops[DDIR_READ]),
2169 .off2 = td_var_offset(rate_iops[DDIR_WRITE]),
2170 .off3 = td_var_offset(rate_iops[DDIR_TRIM]),
2171 .help = "Limit IO used to this number of IO operations/sec",
2174 .name = "rate_iops_min",
2175 .type = FIO_OPT_INT,
2176 .off1 = td_var_offset(rate_iops_min[DDIR_READ]),
2177 .off2 = td_var_offset(rate_iops_min[DDIR_WRITE]),
2178 .off3 = td_var_offset(rate_iops_min[DDIR_TRIM]),
2179 .help = "Job must meet this rate or it will be shut down",
2180 .parent = "rate_iops",
2183 .name = "ratecycle",
2184 .type = FIO_OPT_INT,
2185 .off1 = td_var_offset(ratecycle),
2186 .help = "Window average for rate limits (msec)",
2191 .name = "max_latency",
2192 .type = FIO_OPT_INT,
2193 .off1 = td_var_offset(max_latency),
2194 .help = "Maximum tolerated IO latency (usec)",
2197 .name = "invalidate",
2198 .type = FIO_OPT_BOOL,
2199 .off1 = td_var_offset(invalidate_cache),
2200 .help = "Invalidate buffer/page cache prior to running job",
2205 .type = FIO_OPT_BOOL,
2206 .off1 = td_var_offset(sync_io),
2207 .help = "Use O_SYNC for buffered writes",
2209 .parent = "buffered",
2212 .name = "bwavgtime",
2213 .type = FIO_OPT_INT,
2214 .off1 = td_var_offset(bw_avg_time),
2215 .help = "Time window over which to calculate bandwidth"
2218 .parent = "write_bw_log",
2221 .name = "iopsavgtime",
2222 .type = FIO_OPT_INT,
2223 .off1 = td_var_offset(iops_avg_time),
2224 .help = "Time window over which to calculate IOPS (msec)",
2226 .parent = "write_iops_log",
2229 .name = "create_serialize",
2230 .type = FIO_OPT_BOOL,
2231 .off1 = td_var_offset(create_serialize),
2232 .help = "Serialize creating of job files",
2236 .name = "create_fsync",
2237 .type = FIO_OPT_BOOL,
2238 .off1 = td_var_offset(create_fsync),
2239 .help = "fsync file after creation",
2243 .name = "create_on_open",
2244 .type = FIO_OPT_BOOL,
2245 .off1 = td_var_offset(create_on_open),
2246 .help = "Create files when they are opened for IO",
2250 .name = "create_only",
2251 .type = FIO_OPT_BOOL,
2252 .off1 = td_var_offset(create_only),
2253 .help = "Only perform file creation phase",
2258 .type = FIO_OPT_BOOL,
2259 .off1 = td_var_offset(pre_read),
2260 .help = "Pre-read files before starting official testing",
2265 .type = FIO_OPT_INT,
2266 .off1 = td_var_offset(cpuload),
2267 .help = "Use this percentage of CPU",
2270 .name = "cpuchunks",
2271 .type = FIO_OPT_INT,
2272 .off1 = td_var_offset(cpucycle),
2273 .help = "Length of the CPU burn cycles (usecs)",
2275 .parent = "cpuload",
2277 #ifdef FIO_HAVE_CPU_AFFINITY
2280 .type = FIO_OPT_INT,
2281 .cb = str_cpumask_cb,
2282 .help = "CPU affinity mask",
2285 .name = "cpus_allowed",
2286 .type = FIO_OPT_STR,
2287 .cb = str_cpus_allowed_cb,
2288 .help = "Set CPUs allowed",
2291 #ifdef CONFIG_LIBNUMA
2293 .name = "numa_cpu_nodes",
2294 .type = FIO_OPT_STR,
2295 .cb = str_numa_cpunodes_cb,
2296 .help = "NUMA CPU nodes bind",
2299 .name = "numa_mem_policy",
2300 .type = FIO_OPT_STR,
2301 .cb = str_numa_mpol_cb,
2302 .help = "NUMA memory policy setup",
2306 .name = "end_fsync",
2307 .type = FIO_OPT_BOOL,
2308 .off1 = td_var_offset(end_fsync),
2309 .help = "Include fsync at the end of job",
2313 .name = "fsync_on_close",
2314 .type = FIO_OPT_BOOL,
2315 .off1 = td_var_offset(fsync_on_close),
2316 .help = "fsync files on close",
2321 .type = FIO_OPT_BOOL,
2322 .off1 = td_var_offset(unlink),
2323 .help = "Unlink created files after job has completed",
2328 .type = FIO_OPT_STR_SET,
2329 .cb = str_exitall_cb,
2330 .help = "Terminate all jobs when one exits",
2333 .name = "stonewall",
2334 .alias = "wait_for_previous",
2335 .type = FIO_OPT_STR_SET,
2336 .off1 = td_var_offset(stonewall),
2337 .help = "Insert a hard barrier between this job and previous",
2340 .name = "new_group",
2341 .type = FIO_OPT_STR_SET,
2342 .off1 = td_var_offset(new_group),
2343 .help = "Mark the start of a new group (for reporting)",
2347 .type = FIO_OPT_STR_SET,
2348 .off1 = td_var_offset(use_thread),
2349 .help = "Use threads instead of forks",
2352 .name = "write_bw_log",
2353 .type = FIO_OPT_STR,
2354 .off1 = td_var_offset(write_bw_log),
2355 .cb = str_write_bw_log_cb,
2356 .help = "Write log of bandwidth during run",
2359 .name = "write_lat_log",
2360 .type = FIO_OPT_STR,
2361 .off1 = td_var_offset(write_lat_log),
2362 .cb = str_write_lat_log_cb,
2363 .help = "Write log of latency during run",
2366 .name = "write_iops_log",
2367 .type = FIO_OPT_STR,
2368 .off1 = td_var_offset(write_iops_log),
2369 .cb = str_write_iops_log_cb,
2370 .help = "Write log of IOPS during run",
2373 .name = "log_avg_msec",
2374 .type = FIO_OPT_INT,
2375 .off1 = td_var_offset(log_avg_msec),
2376 .help = "Average bw/iops/lat logs over this period of time",
2380 .name = "hugepage-size",
2381 .type = FIO_OPT_INT,
2382 .off1 = td_var_offset(hugepage_size),
2383 .help = "When using hugepages, specify size of each page",
2384 .def = __fio_stringify(FIO_HUGE_PAGE),
2387 .name = "group_reporting",
2388 .type = FIO_OPT_STR_SET,
2389 .off1 = td_var_offset(group_reporting),
2390 .help = "Do reporting on a per-group basis",
2393 .name = "zero_buffers",
2394 .type = FIO_OPT_STR_SET,
2395 .off1 = td_var_offset(zero_buffers),
2396 .help = "Init IO buffers to all zeroes",
2399 .name = "refill_buffers",
2400 .type = FIO_OPT_STR_SET,
2401 .off1 = td_var_offset(refill_buffers),
2402 .help = "Refill IO buffers on every IO submit",
2405 .name = "scramble_buffers",
2406 .type = FIO_OPT_BOOL,
2407 .off1 = td_var_offset(scramble_buffers),
2408 .help = "Slightly scramble buffers on every IO submit",
2412 .name = "buffer_compress_percentage",
2413 .type = FIO_OPT_INT,
2414 .off1 = td_var_offset(compress_percentage),
2417 .help = "How compressible the buffer is (approximately)",
2420 .name = "buffer_compress_chunk",
2421 .type = FIO_OPT_INT,
2422 .off1 = td_var_offset(compress_chunk),
2423 .parent = "buffer_compress_percentage",
2424 .help = "Size of compressible region in buffer",
2427 .name = "clat_percentiles",
2428 .type = FIO_OPT_BOOL,
2429 .off1 = td_var_offset(clat_percentiles),
2430 .help = "Enable the reporting of completion latency percentiles",
2434 .name = "percentile_list",
2435 .type = FIO_OPT_FLOAT_LIST,
2436 .off1 = td_var_offset(percentile_list),
2437 .off2 = td_var_offset(overwrite_plist),
2438 .help = "Specify a custom list of percentiles to report",
2439 .maxlen = FIO_IO_U_LIST_MAX_LEN,
2444 #ifdef FIO_HAVE_DISK_UTIL
2446 .name = "disk_util",
2447 .type = FIO_OPT_BOOL,
2448 .off1 = td_var_offset(do_disk_util),
2449 .help = "Log disk utilization statistics",
2454 .name = "gtod_reduce",
2455 .type = FIO_OPT_BOOL,
2456 .help = "Greatly reduce number of gettimeofday() calls",
2457 .cb = str_gtod_reduce_cb,
2461 .name = "disable_lat",
2462 .type = FIO_OPT_BOOL,
2463 .off1 = td_var_offset(disable_lat),
2464 .help = "Disable latency numbers",
2465 .parent = "gtod_reduce",
2469 .name = "disable_clat",
2470 .type = FIO_OPT_BOOL,
2471 .off1 = td_var_offset(disable_clat),
2472 .help = "Disable completion latency numbers",
2473 .parent = "gtod_reduce",
2477 .name = "disable_slat",
2478 .type = FIO_OPT_BOOL,
2479 .off1 = td_var_offset(disable_slat),
2480 .help = "Disable submission latency numbers",
2481 .parent = "gtod_reduce",
2485 .name = "disable_bw_measurement",
2486 .type = FIO_OPT_BOOL,
2487 .off1 = td_var_offset(disable_bw),
2488 .help = "Disable bandwidth logging",
2489 .parent = "gtod_reduce",
2494 .type = FIO_OPT_INT,
2495 .cb = str_gtod_cpu_cb,
2496 .help = "Set up dedicated gettimeofday() thread on this CPU",
2497 .verify = gtod_cpu_verify,
2500 .name = "unified_rw_reporting",
2501 .type = FIO_OPT_BOOL,
2502 .off1 = td_var_offset(unified_rw_rep),
2503 .help = "Unify reporting across data direction",
2507 .name = "continue_on_error",
2508 .type = FIO_OPT_STR,
2509 .off1 = td_var_offset(continue_on_error),
2510 .help = "Continue on non-fatal errors during IO",
2514 .oval = ERROR_TYPE_NONE,
2515 .help = "Exit when an error is encountered",
2518 .oval = ERROR_TYPE_READ,
2519 .help = "Continue on read errors only",
2522 .oval = ERROR_TYPE_WRITE,
2523 .help = "Continue on write errors only",
2526 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
2527 .help = "Continue on any IO errors",
2530 .oval = ERROR_TYPE_VERIFY,
2531 .help = "Continue on verify errors only",
2534 .oval = ERROR_TYPE_ANY,
2535 .help = "Continue on all io and verify errors",
2538 .oval = ERROR_TYPE_NONE,
2539 .help = "Alias for 'none'",
2542 .oval = ERROR_TYPE_ANY,
2543 .help = "Alias for 'all'",
2548 .name = "ignore_error",
2549 .type = FIO_OPT_STR,
2550 .cb = str_ignore_error_cb,
2551 .help = "Set a specific list of errors to ignore",
2555 .name = "error_dump",
2556 .type = FIO_OPT_BOOL,
2557 .off1 = td_var_offset(error_dump),
2559 .help = "Dump info on each error",
2564 .type = FIO_OPT_STR_STORE,
2565 .off1 = td_var_offset(profile),
2566 .help = "Select a specific builtin performance test",
2570 .type = FIO_OPT_STR_STORE,
2571 .off1 = td_var_offset(cgroup),
2572 .help = "Add job to cgroup of this name",
2575 .name = "cgroup_weight",
2576 .type = FIO_OPT_INT,
2577 .off1 = td_var_offset(cgroup_weight),
2578 .help = "Use given weight for cgroup",
2583 .name = "cgroup_nodelete",
2584 .type = FIO_OPT_BOOL,
2585 .off1 = td_var_offset(cgroup_nodelete),
2586 .help = "Do not delete cgroups after job completion",
2591 .type = FIO_OPT_INT,
2592 .off1 = td_var_offset(uid),
2593 .help = "Run job with this user ID",
2597 .type = FIO_OPT_INT,
2598 .off1 = td_var_offset(gid),
2599 .help = "Run job with this group ID",
2603 .type = FIO_OPT_INT,
2604 .off1 = td_var_offset(flow_id),
2605 .help = "The flow index ID to use",
2610 .type = FIO_OPT_INT,
2611 .off1 = td_var_offset(flow),
2612 .help = "Weight for flow control of this job",
2613 .parent = "flow_id",
2617 .name = "flow_watermark",
2618 .type = FIO_OPT_INT,
2619 .off1 = td_var_offset(flow_watermark),
2620 .help = "High watermark for flow control. This option"
2621 " should be set to the same value for all threads"
2622 " with non-zero flow.",
2623 .parent = "flow_id",
2627 .name = "flow_sleep",
2628 .type = FIO_OPT_INT,
2629 .off1 = td_var_offset(flow_sleep),
2630 .help = "How many microseconds to sleep after being held"
2631 " back by the flow control mechanism",
2632 .parent = "flow_id",
2640 static void add_to_lopt(struct option *lopt, struct fio_option *o,
2641 const char *name, int val)
2643 lopt->name = (char *) name;
2645 if (o->type == FIO_OPT_STR_SET)
2646 lopt->has_arg = no_argument;
2648 lopt->has_arg = required_argument;
2651 static void options_to_lopts(struct fio_option *opts,
2652 struct option *long_options,
2653 int i, int option_type)
2655 struct fio_option *o = &opts[0];
2657 add_to_lopt(&long_options[i], o, o->name, option_type);
2660 add_to_lopt(&long_options[i], o, o->alias, option_type);
2665 assert(i < FIO_NR_OPTIONS);
2669 void fio_options_set_ioengine_opts(struct option *long_options,
2670 struct thread_data *td)
2675 while (long_options[i].name) {
2676 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
2677 memset(&long_options[i], 0, sizeof(*long_options));
2684 * Just clear out the prior ioengine options.
2689 options_to_lopts(td->io_ops->options, long_options, i,
2690 FIO_GETOPT_IOENGINE);
2693 void fio_options_dup_and_init(struct option *long_options)
2697 options_init(options);
2700 while (long_options[i].name)
2703 options_to_lopts(options, long_options, i, FIO_GETOPT_JOB);
2706 struct fio_keyword {
2712 static struct fio_keyword fio_keywords[] = {
2714 .word = "$pagesize",
2715 .desc = "Page size in the system",
2718 .word = "$mb_memory",
2719 .desc = "Megabytes of memory online",
2723 .desc = "Number of CPUs online in the system",
2730 void fio_keywords_init(void)
2732 unsigned long long mb_memory;
2736 sprintf(buf, "%lu", (unsigned long) page_size);
2737 fio_keywords[0].replace = strdup(buf);
2739 mb_memory = os_phys_mem() / (1024 * 1024);
2740 sprintf(buf, "%llu", mb_memory);
2741 fio_keywords[1].replace = strdup(buf);
2744 sprintf(buf, "%lu", l);
2745 fio_keywords[2].replace = strdup(buf);
2750 static char *bc_calc(char *str)
2752 char buf[128], *tmp;
2757 * No math, just return string
2759 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
2760 !strchr(str, '/')) || strchr(str, '\''))
2764 * Split option from value, we only need to calculate the value
2766 tmp = strchr(str, '=');
2773 * Prevent buffer overflows; such a case isn't reasonable anyway
2775 if (strlen(str) >= 128 || strlen(tmp) > 100)
2778 sprintf(buf, "which %s > /dev/null", BC_APP);
2780 log_err("fio: bc is needed for performing math\n");
2784 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
2785 f = popen(buf, "r");
2790 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
2796 buf[(tmp - str) + ret - 1] = '\0';
2797 memcpy(buf, str, tmp - str);
2803 * Return a copy of the input string with substrings of the form ${VARNAME}
2804 * substituted with the value of the environment variable VARNAME. The
2805 * substitution always occurs, even if VARNAME is empty or the corresponding
2806 * environment variable undefined.
2808 static char *option_dup_subs(const char *opt)
2810 char out[OPT_LEN_MAX+1];
2811 char in[OPT_LEN_MAX+1];
2814 char *ch1, *ch2, *env;
2815 ssize_t nchr = OPT_LEN_MAX;
2818 if (strlen(opt) + 1 > OPT_LEN_MAX) {
2819 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
2823 in[OPT_LEN_MAX] = '\0';
2824 strncpy(in, opt, OPT_LEN_MAX);
2826 while (*inptr && nchr > 0) {
2827 if (inptr[0] == '$' && inptr[1] == '{') {
2828 ch2 = strchr(inptr, '}');
2829 if (ch2 && inptr+1 < ch2) {
2836 envlen = strlen(env);
2837 if (envlen <= nchr) {
2838 memcpy(outptr, env, envlen);
2848 *outptr++ = *inptr++;
2857 * Look for reserved variable names and replace them with real values
2859 static char *fio_keyword_replace(char *opt)
2865 for (i = 0; fio_keywords[i].word != NULL; i++) {
2866 struct fio_keyword *kw = &fio_keywords[i];
2868 while ((s = strstr(opt, kw->word)) != NULL) {
2869 char *new = malloc(strlen(opt) + 1);
2875 * Copy part of the string before the keyword and
2876 * sprintf() the replacement after it.
2878 memcpy(new, opt, olen);
2879 len = sprintf(new + olen, "%s", kw->replace);
2882 * If there's more in the original string, copy that
2885 opt += strlen(kw->word) + olen;
2887 memcpy(new + olen + len, opt, opt - o_org - 1);
2890 * replace opt and free the old opt
2900 * Check for potential math and invoke bc, if possible
2908 static char **dup_and_sub_options(char **opts, int num_opts)
2911 char **opts_copy = malloc(num_opts * sizeof(*opts));
2912 for (i = 0; i < num_opts; i++) {
2913 opts_copy[i] = option_dup_subs(opts[i]);
2916 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
2921 int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
2923 int i, ret, unknown;
2926 sort_options(opts, options, num_opts);
2927 opts_copy = dup_and_sub_options(opts, num_opts);
2929 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
2930 struct fio_option *o;
2931 int newret = parse_option(opts_copy[i], opts[i], options, &o,
2940 opts_copy[i] = NULL;
2947 ret |= ioengine_load(td);
2949 sort_options(opts_copy, td->io_ops->options, num_opts);
2952 for (i = 0; i < num_opts; i++) {
2953 struct fio_option *o = NULL;
2959 newret = parse_option(opts_copy[i], opts[i],
2960 td->io_ops->options, &o,
2965 log_err("Bad option <%s>\n", opts[i]);
2968 opts_copy[i] = NULL;
2976 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
2978 return parse_cmd_option(opt, val, options, td);
2981 int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
2984 return parse_cmd_option(opt, val, td->io_ops->options, td);
2987 void fio_fill_default_options(struct thread_data *td)
2989 fill_default_options(td, options);
2992 int fio_show_option_help(const char *opt)
2994 return show_cmd_help(options, opt);
2997 void options_mem_dupe(void *data, struct fio_option *options)
2999 struct fio_option *o;
3002 for (o = &options[0]; o->name; o++) {
3003 if (o->type != FIO_OPT_STR_STORE)
3006 ptr = td_var(data, o->off1);
3008 *ptr = strdup(*ptr);
3013 * dupe FIO_OPT_STR_STORE options
3015 void fio_options_mem_dupe(struct thread_data *td)
3017 options_mem_dupe(&td->o, options);
3019 if (td->eo && td->io_ops) {
3020 void *oldeo = td->eo;
3022 td->eo = malloc(td->io_ops->option_struct_size);
3023 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
3024 options_mem_dupe(td->eo, td->io_ops->options);
3028 unsigned int fio_get_kb_base(void *data)
3030 struct thread_data *td = data;
3031 unsigned int kb_base = 0;
3034 kb_base = td->o.kb_base;
3041 int add_option(struct fio_option *o)
3043 struct fio_option *__o;
3052 memcpy(&options[opt_index], o, sizeof(*o));
3056 void invalidate_profile_options(const char *prof_name)
3058 struct fio_option *o;
3062 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
3063 o->type = FIO_OPT_INVALID;
3064 o->prof_name = NULL;
3070 void add_opt_posval(const char *optname, const char *ival, const char *help)
3072 struct fio_option *o;
3075 o = find_option(options, optname);
3079 for (i = 0; i < PARSE_MAX_VP; i++) {
3080 if (o->posval[i].ival)
3083 o->posval[i].ival = ival;
3084 o->posval[i].help = help;
3089 void del_opt_posval(const char *optname, const char *ival)
3091 struct fio_option *o;
3094 o = find_option(options, optname);
3098 for (i = 0; i < PARSE_MAX_VP; i++) {
3099 if (!o->posval[i].ival)
3101 if (strcmp(o->posval[i].ival, ival))
3104 o->posval[i].ival = NULL;
3105 o->posval[i].help = NULL;
3109 void fio_options_free(struct thread_data *td)
3111 options_free(options, td);
3112 if (td->eo && td->io_ops && td->io_ops->options) {
3113 options_free(td->io_ops->options, td->eo);