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;
165 static int str_bssplit_cb(void *data, const char *input)
167 struct thread_data *td = data;
168 char *str, *p, *odir;
171 p = str = strdup(input);
173 strip_blank_front(&str);
174 strip_blank_end(str);
176 odir = strchr(str, ',');
178 ret = bssplit_ddir(td, DDIR_WRITE, odir + 1);
181 ret = bssplit_ddir(td, DDIR_READ, str);
188 ret = bssplit_ddir(td, DDIR_READ, str);
190 ret = bssplit_ddir(td, DDIR_WRITE, op);
199 static int str_rw_cb(void *data, const char *str)
201 struct thread_data *td = data;
202 char *nr = get_opt_postfix(str);
204 td->o.ddir_seq_nr = 1;
205 td->o.ddir_seq_add = 0;
211 td->o.ddir_seq_nr = atoi(nr);
215 if (str_to_decimal(nr, &val, 1, td)) {
216 log_err("fio: rw postfix parsing failed\n");
221 td->o.ddir_seq_add = val;
228 static int str_mem_cb(void *data, const char *mem)
230 struct thread_data *td = data;
232 if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP) {
233 td->mmapfile = get_opt_postfix(mem);
234 if (td->o.mem_type == MEM_MMAPHUGE && !td->mmapfile) {
235 log_err("fio: mmaphuge:/path/to/file\n");
243 static int str_verify_cb(void *data, const char *mem)
245 struct thread_data *td = data;
247 if (td->o.verify == VERIFY_CRC32C_INTEL ||
248 td->o.verify == VERIFY_CRC32C) {
249 crc32c_intel_probe();
255 static int fio_clock_source_cb(void *data, const char *str)
257 struct thread_data *td = data;
259 fio_clock_source = td->o.clocksource;
264 static int str_lockmem_cb(void fio_unused *data, unsigned long long *val)
270 static int str_rwmix_read_cb(void *data, unsigned long long *val)
272 struct thread_data *td = data;
274 td->o.rwmix[DDIR_READ] = *val;
275 td->o.rwmix[DDIR_WRITE] = 100 - *val;
279 static int str_rwmix_write_cb(void *data, unsigned long long *val)
281 struct thread_data *td = data;
283 td->o.rwmix[DDIR_WRITE] = *val;
284 td->o.rwmix[DDIR_READ] = 100 - *val;
288 #ifdef FIO_HAVE_IOPRIO
289 static int str_prioclass_cb(void *data, unsigned long long *val)
291 struct thread_data *td = data;
295 * mask off old class bits, str_prio_cb() may have set a default class
297 mask = (1 << IOPRIO_CLASS_SHIFT) - 1;
300 td->ioprio |= *val << IOPRIO_CLASS_SHIFT;
305 static int str_prio_cb(void *data, unsigned long long *val)
307 struct thread_data *td = data;
312 * If no class is set, assume BE
314 if ((td->ioprio >> IOPRIO_CLASS_SHIFT) == 0)
315 td->ioprio |= IOPRIO_CLASS_BE << IOPRIO_CLASS_SHIFT;
322 static int str_exitall_cb(void)
324 exitall_on_terminate = 1;
328 #ifdef FIO_HAVE_CPU_AFFINITY
329 static int str_cpumask_cb(void *data, unsigned long long *val)
331 struct thread_data *td = data;
336 ret = fio_cpuset_init(&td->o.cpumask);
338 log_err("fio: cpuset_init failed\n");
339 td_verror(td, ret, "fio_cpuset_init");
343 max_cpu = cpus_online();
345 for (i = 0; i < sizeof(int) * 8; i++) {
346 if ((1 << i) & *val) {
348 log_err("fio: CPU %d too large (max=%ld)\n", i,
352 dprint(FD_PARSE, "set cpu allowed %d\n", i);
353 fio_cpu_set(&td->o.cpumask, i);
357 td->o.cpumask_set = 1;
361 static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask,
368 ret = fio_cpuset_init(mask);
370 log_err("fio: cpuset_init failed\n");
371 td_verror(td, ret, "fio_cpuset_init");
375 p = str = strdup(input);
377 strip_blank_front(&str);
378 strip_blank_end(str);
380 max_cpu = cpus_online();
382 while ((cpu = strsep(&str, ",")) != NULL) {
391 while ((cpu2 = strsep(&str2, "-")) != NULL) {
401 while (icpu <= icpu2) {
402 if (icpu >= FIO_MAX_CPUS) {
403 log_err("fio: your OS only supports up to"
404 " %d CPUs\n", (int) FIO_MAX_CPUS);
408 if (icpu > max_cpu) {
409 log_err("fio: CPU %d too large (max=%ld)\n",
415 dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
416 fio_cpu_set(mask, icpu);
425 td->o.cpumask_set = 1;
429 static int str_cpus_allowed_cb(void *data, const char *input)
431 struct thread_data *td = data;
434 ret = set_cpus_allowed(td, &td->o.cpumask, input);
436 td->o.cpumask_set = 1;
441 static int str_verify_cpus_allowed_cb(void *data, const char *input)
443 struct thread_data *td = data;
446 ret = set_cpus_allowed(td, &td->o.verify_cpumask, input);
448 td->o.verify_cpumask_set = 1;
455 static int str_verify_trim_cb(void *data, unsigned long long *val)
457 struct thread_data *td = data;
459 td->o.trim_percentage = *val;
464 static int str_fst_cb(void *data, const char *str)
466 struct thread_data *td = data;
467 char *nr = get_opt_postfix(str);
469 td->file_service_nr = 1;
471 td->file_service_nr = atoi(nr);
478 #ifdef FIO_HAVE_SYNC_FILE_RANGE
479 static int str_sfr_cb(void *data, const char *str)
481 struct thread_data *td = data;
482 char *nr = get_opt_postfix(str);
484 td->sync_file_range_nr = 1;
486 td->sync_file_range_nr = atoi(nr);
494 static int check_dir(struct thread_data *td, char *fname)
497 char file[PATH_MAX], *dir;
500 if (td->o.directory) {
501 strcpy(file, td->o.directory);
506 sprintf(file + elen, "%s", fname);
512 * We can't do this on FIO_DISKLESSIO engines. The engine isn't loaded
513 * yet, so we can't do this check right here...
515 if (lstat(dir, &sb) < 0) {
518 log_err("fio: %s is not a directory\n", dir);
519 td_verror(td, ret, "lstat");
523 if (!S_ISDIR(sb.st_mode)) {
524 log_err("fio: %s is not a directory\n", dir);
534 * Return next file in the string. Files are separated with ':'. If the ':'
535 * is escaped with a '\', then that ':' is part of the filename and does not
536 * indicate a new file.
538 static char *get_next_file_name(char **ptr)
543 if (!str || !strlen(str))
549 * No colon, we are done
551 p = strchr(str, ':');
558 * We got a colon, but it's the first character. Skip and
566 if (*(p - 1) != '\\') {
572 memmove(p - 1, p, strlen(p) + 1);
579 static int str_filename_cb(void *data, const char *input)
581 struct thread_data *td = data;
582 char *fname, *str, *p;
584 p = str = strdup(input);
586 strip_blank_front(&str);
587 strip_blank_end(str);
589 if (!td->files_index)
592 while ((fname = get_next_file_name(&str)) != NULL) {
595 if (check_dir(td, fname)) {
607 static int str_directory_cb(void *data, const char fio_unused *str)
609 struct thread_data *td = data;
612 if (lstat(td->o.directory, &sb) < 0) {
615 log_err("fio: %s is not a directory\n", td->o.directory);
616 td_verror(td, ret, "lstat");
619 if (!S_ISDIR(sb.st_mode)) {
620 log_err("fio: %s is not a directory\n", td->o.directory);
627 static int str_opendir_cb(void *data, const char fio_unused *str)
629 struct thread_data *td = data;
631 if (!td->files_index)
634 return add_dir_files(td, td->o.opendir);
637 static int str_verify_offset_cb(void *data, unsigned long long *off)
639 struct thread_data *td = data;
641 if (*off && *off < sizeof(struct verify_header)) {
642 log_err("fio: verify_offset too small\n");
646 td->o.verify_offset = *off;
650 static int str_verify_pattern_cb(void *data, const char *input)
652 struct thread_data *td = data;
654 int i = 0, j = 0, len, k, base = 10;
657 loc1 = strstr(input, "0x");
658 loc2 = strstr(input, "0X");
661 off = strtol(input, NULL, base);
662 if (off != LONG_MAX || errno != ERANGE) {
664 td->o.verify_pattern[i] = off & 0xff;
673 j = loc1 - input + 2;
675 j = loc2 - input + 2;
678 if (len - j < MAX_PATTERN_SIZE * 2) {
680 off = converthexchartoint(input[k--]);
682 off += (converthexchartoint(input[k--])
684 td->o.verify_pattern[i++] = (char) off;
690 * Fill the pattern all the way to the end. This greatly reduces
691 * the number of memcpy's we have to do when verifying the IO.
693 while (i > 1 && i * 2 <= MAX_PATTERN_SIZE) {
694 memcpy(&td->o.verify_pattern[i], &td->o.verify_pattern[0], i);
699 * The code in verify_io_u_pattern assumes a single byte pattern
700 * fills the whole verify pattern buffer.
702 memset(td->o.verify_pattern, td->o.verify_pattern[0],
706 td->o.verify_pattern_bytes = i;
709 * VERIFY_META could already be set
711 if (td->o.verify == VERIFY_NONE)
712 td->o.verify = VERIFY_PATTERN;
717 static int str_lockfile_cb(void *data, const char *str)
719 struct thread_data *td = data;
720 char *nr = get_opt_postfix(str);
722 td->o.lockfile_batch = 1;
724 td->o.lockfile_batch = atoi(nr);
731 static int str_write_bw_log_cb(void *data, const char *str)
733 struct thread_data *td = data;
736 td->o.bw_log_file = strdup(str);
738 td->o.write_bw_log = 1;
742 static int str_write_lat_log_cb(void *data, const char *str)
744 struct thread_data *td = data;
747 td->o.lat_log_file = strdup(str);
749 td->o.write_lat_log = 1;
753 static int str_write_iops_log_cb(void *data, const char *str)
755 struct thread_data *td = data;
758 td->o.iops_log_file = strdup(str);
760 td->o.write_iops_log = 1;
764 static int str_gtod_reduce_cb(void *data, int *il)
766 struct thread_data *td = data;
769 td->o.disable_lat = !!val;
770 td->o.disable_clat = !!val;
771 td->o.disable_slat = !!val;
772 td->o.disable_bw = !!val;
773 td->o.clat_percentiles = !val;
775 td->tv_cache_mask = 63;
780 static int str_gtod_cpu_cb(void *data, long long *il)
782 struct thread_data *td = data;
785 td->o.gtod_cpu = val;
786 td->o.gtod_offload = 1;
790 static int str_size_cb(void *data, unsigned long long *__val)
792 struct thread_data *td = data;
793 unsigned long long v = *__val;
795 if (parse_is_percent(v)) {
797 td->o.size_percent = -1ULL - v;
804 static int rw_verify(struct fio_option *o, void *data)
806 struct thread_data *td = data;
808 if (read_only && td_write(td)) {
809 log_err("fio: job <%s> has write bit set, but fio is in"
810 " read-only mode\n", td->o.name);
817 static int gtod_cpu_verify(struct fio_option *o, void *data)
819 #ifndef FIO_HAVE_CPU_AFFINITY
820 struct thread_data *td = data;
822 if (td->o.gtod_cpu) {
823 log_err("fio: platform must support CPU affinity for"
824 "gettimeofday() offloading\n");
832 static int kb_base_verify(struct fio_option *o, void *data)
834 struct thread_data *td = data;
836 if (td->o.kb_base != 1024 && td->o.kb_base != 1000) {
837 log_err("fio: kb_base set to nonsensical value: %u\n",
848 static struct opt_group fio_opt_groups[] = {
850 .name = "Description",
851 .mask = FIO_OPT_G_DESC,
855 .mask = FIO_OPT_G_FILE,
859 .mask = FIO_OPT_G_MISC,
863 .mask = FIO_OPT_G_IO,
866 .name = "IO direction",
867 .mask = FIO_OPT_G_IO_DDIR,
871 .mask = FIO_OPT_G_IO_BUF,
875 .mask = FIO_OPT_G_IO_ENG,
879 .mask = FIO_OPT_G_RAND,
883 .mask = FIO_OPT_G_OS,
887 .mask = FIO_OPT_G_MEM,
891 .mask = FIO_OPT_G_VERIFY,
895 .mask = FIO_OPT_G_CPU,
899 .mask = FIO_OPT_G_LOG,
903 .mask = FIO_OPT_G_ZONE,
907 .mask = FIO_OPT_G_CACHE,
911 .mask = FIO_OPT_G_STAT,
915 .mask = FIO_OPT_G_ERR,
919 .mask = FIO_OPT_G_JOB,
926 struct opt_group *opt_group_from_mask(unsigned int *mask)
928 struct opt_group *og;
931 if (*mask == FIO_OPT_G_INVALID)
934 for (i = 0; fio_opt_groups[i].name; i++) {
935 og = &fio_opt_groups[i];
937 if (*mask & og->mask) {
938 *mask &= ~(og->mask);
947 * Map of job/command line options
949 struct fio_option fio_options[FIO_MAX_OPTS] = {
951 .name = "description",
952 .type = FIO_OPT_STR_STORE,
953 .off1 = td_var_offset(description),
954 .help = "Text job description",
955 .category = FIO_OPT_G_DESC,
959 .type = FIO_OPT_STR_STORE,
960 .off1 = td_var_offset(name),
961 .help = "Name of this job",
962 .category = FIO_OPT_G_DESC,
966 .type = FIO_OPT_STR_STORE,
967 .off1 = td_var_offset(directory),
968 .cb = str_directory_cb,
969 .help = "Directory to store files in",
970 .category = FIO_OPT_G_FILE,
974 .type = FIO_OPT_STR_STORE,
975 .off1 = td_var_offset(filename),
976 .cb = str_filename_cb,
977 .prio = -1, /* must come after "directory" */
978 .help = "File(s) to use for the workload",
979 .category = FIO_OPT_G_FILE,
984 .off1 = td_var_offset(kb_base),
985 .verify = kb_base_verify,
988 .help = "How many bytes per KB for reporting (1000 or 1024)",
989 .category = FIO_OPT_G_MISC,
994 .cb = str_lockfile_cb,
995 .off1 = td_var_offset(file_lock_mode),
996 .help = "Lock file when doing IO to it",
997 .parent = "filename",
1000 .category = FIO_OPT_G_FILE,
1003 .oval = FILE_LOCK_NONE,
1004 .help = "No file locking",
1006 { .ival = "exclusive",
1007 .oval = FILE_LOCK_EXCLUSIVE,
1008 .help = "Exclusive file lock",
1011 .ival = "readwrite",
1012 .oval = FILE_LOCK_READWRITE,
1013 .help = "Read vs write lock",
1019 .type = FIO_OPT_STR_STORE,
1020 .off1 = td_var_offset(opendir),
1021 .cb = str_opendir_cb,
1022 .help = "Recursively add files from this directory and down",
1023 .category = FIO_OPT_G_FILE,
1027 .alias = "readwrite",
1028 .type = FIO_OPT_STR,
1030 .off1 = td_var_offset(td_ddir),
1031 .help = "IO direction",
1033 .verify = rw_verify,
1034 .category = FIO_OPT_G_IO_DDIR,
1037 .oval = TD_DDIR_READ,
1038 .help = "Sequential read",
1041 .oval = TD_DDIR_WRITE,
1042 .help = "Sequential write",
1044 { .ival = "randread",
1045 .oval = TD_DDIR_RANDREAD,
1046 .help = "Random read",
1048 { .ival = "randwrite",
1049 .oval = TD_DDIR_RANDWRITE,
1050 .help = "Random write",
1054 .help = "Sequential read and write mix",
1057 .oval = TD_DDIR_RANDRW,
1058 .help = "Random read and write mix"
1063 .name = "rw_sequencer",
1064 .type = FIO_OPT_STR,
1065 .off1 = td_var_offset(rw_seq),
1066 .help = "IO offset generator modifier",
1067 .def = "sequential",
1068 .category = FIO_OPT_G_IO_DDIR,
1070 { .ival = "sequential",
1072 .help = "Generate sequential offsets",
1074 { .ival = "identical",
1075 .oval = RW_SEQ_IDENT,
1076 .help = "Generate identical offsets",
1083 .type = FIO_OPT_STR_STORE,
1084 .off1 = td_var_offset(ioengine),
1085 .help = "IO engine to use",
1086 .def = FIO_PREFERRED_ENGINE,
1087 .category = FIO_OPT_G_IO,
1090 .help = "Use read/write",
1093 .help = "Use pread/pwrite",
1096 .help = "Use readv/writev",
1098 #ifdef FIO_HAVE_LIBAIO
1100 .help = "Linux native asynchronous IO",
1103 #ifdef FIO_HAVE_POSIXAIO
1104 { .ival = "posixaio",
1105 .help = "POSIX asynchronous IO",
1108 #ifdef FIO_HAVE_SOLARISAIO
1109 { .ival = "solarisaio",
1110 .help = "Solaris native asynchronous IO",
1113 #ifdef FIO_HAVE_WINDOWSAIO
1114 { .ival = "windowsaio",
1115 .help = "Windows native asynchronous IO"
1119 .help = "Memory mapped IO"
1121 #ifdef FIO_HAVE_SPLICE
1123 .help = "splice/vmsplice based IO",
1125 { .ival = "netsplice",
1126 .help = "splice/vmsplice to/from the network",
1129 #ifdef FIO_HAVE_SGIO
1131 .help = "SCSI generic v3 IO",
1135 .help = "Testing engine (no data transfer)",
1138 .help = "Network IO",
1140 #ifdef FIO_HAVE_SYSLET
1141 { .ival = "syslet-rw",
1142 .help = "syslet enabled async pread/pwrite IO",
1146 .help = "CPU cycle burner engine",
1148 #ifdef FIO_HAVE_GUASI
1150 .help = "GUASI IO engine",
1153 #ifdef FIO_HAVE_BINJECT
1154 { .ival = "binject",
1155 .help = "binject direct inject block engine",
1158 #ifdef FIO_HAVE_RDMA
1160 .help = "RDMA IO engine",
1163 { .ival = "external",
1164 .help = "Load external engine (append name)",
1170 .type = FIO_OPT_INT,
1171 .off1 = td_var_offset(iodepth),
1172 .help = "Number of IO buffers to keep in flight",
1176 .category = FIO_OPT_G_IO,
1179 .name = "iodepth_batch",
1180 .alias = "iodepth_batch_submit",
1181 .type = FIO_OPT_INT,
1182 .off1 = td_var_offset(iodepth_batch),
1183 .help = "Number of IO buffers to submit in one go",
1184 .parent = "iodepth",
1189 .category = FIO_OPT_G_IO,
1192 .name = "iodepth_batch_complete",
1193 .type = FIO_OPT_INT,
1194 .off1 = td_var_offset(iodepth_batch_complete),
1195 .help = "Number of IO buffers to retrieve in one go",
1196 .parent = "iodepth",
1201 .category = FIO_OPT_G_IO,
1204 .name = "iodepth_low",
1205 .type = FIO_OPT_INT,
1206 .off1 = td_var_offset(iodepth_low),
1207 .help = "Low water mark for queuing depth",
1208 .parent = "iodepth",
1211 .category = FIO_OPT_G_IO,
1215 .type = FIO_OPT_STR_VAL,
1217 .help = "Total size of device or files",
1218 .interval = 1024 * 1024,
1219 .category = FIO_OPT_G_IO,
1222 .name = "fill_device",
1224 .type = FIO_OPT_BOOL,
1225 .off1 = td_var_offset(fill_device),
1226 .help = "Write until an ENOSPC error occurs",
1228 .category = FIO_OPT_G_IO,
1232 .type = FIO_OPT_STR_VAL,
1233 .off1 = td_var_offset(file_size_low),
1234 .off2 = td_var_offset(file_size_high),
1236 .help = "Size of individual files",
1237 .interval = 1024 * 1024,
1238 .category = FIO_OPT_G_IO | FIO_OPT_G_FILE,
1242 .alias = "fileoffset",
1243 .type = FIO_OPT_STR_VAL,
1244 .off1 = td_var_offset(start_offset),
1245 .help = "Start IO from this offset",
1247 .interval = 1024 * 1024,
1248 .category = FIO_OPT_G_IO,
1251 .name = "offset_increment",
1252 .type = FIO_OPT_STR_VAL,
1253 .off1 = td_var_offset(offset_increment),
1254 .help = "What is the increment from one offset to the next",
1258 .interval = 1024 * 1024,
1259 .category = FIO_OPT_G_IO,
1263 .alias = "blocksize",
1264 .type = FIO_OPT_INT,
1265 .off1 = td_var_offset(bs[DDIR_READ]),
1266 .off2 = td_var_offset(bs[DDIR_WRITE]),
1268 .help = "Block size unit",
1273 .category = FIO_OPT_G_IO,
1277 .alias = "blockalign",
1278 .type = FIO_OPT_INT,
1279 .off1 = td_var_offset(ba[DDIR_READ]),
1280 .off2 = td_var_offset(ba[DDIR_WRITE]),
1282 .help = "IO block offset alignment",
1286 .category = FIO_OPT_G_IO | FIO_OPT_G_IO_BUF,
1290 .alias = "blocksize_range",
1291 .type = FIO_OPT_RANGE,
1292 .off1 = td_var_offset(min_bs[DDIR_READ]),
1293 .off2 = td_var_offset(max_bs[DDIR_READ]),
1294 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
1295 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
1297 .help = "Set block size range (in more detail than bs)",
1301 .category = FIO_OPT_G_IO,
1305 .type = FIO_OPT_STR,
1306 .cb = str_bssplit_cb,
1307 .help = "Set a specific mix of block sizes",
1310 .category = FIO_OPT_G_IO,
1313 .name = "bs_unaligned",
1314 .alias = "blocksize_unaligned",
1315 .type = FIO_OPT_STR_SET,
1316 .off1 = td_var_offset(bs_unaligned),
1317 .help = "Don't sector align IO buffer sizes",
1320 .category = FIO_OPT_G_IO,
1323 .name = "randrepeat",
1324 .type = FIO_OPT_BOOL,
1325 .off1 = td_var_offset(rand_repeatable),
1326 .help = "Use repeatable random IO pattern",
1330 .category = FIO_OPT_G_IO | FIO_OPT_G_RAND,
1333 .name = "use_os_rand",
1334 .type = FIO_OPT_BOOL,
1335 .off1 = td_var_offset(use_os_rand),
1336 .help = "Set to use OS random generator",
1340 .category = FIO_OPT_G_RAND,
1343 .name = "norandommap",
1344 .type = FIO_OPT_STR_SET,
1345 .off1 = td_var_offset(norandommap),
1346 .help = "Accept potential duplicate random blocks",
1349 .category = FIO_OPT_G_RAND,
1352 .name = "softrandommap",
1353 .type = FIO_OPT_BOOL,
1354 .off1 = td_var_offset(softrandommap),
1355 .help = "Set norandommap if randommap allocation fails",
1356 .parent = "norandommap",
1359 .category = FIO_OPT_G_RAND,
1363 .alias = "nr_files",
1364 .type = FIO_OPT_INT,
1365 .off1 = td_var_offset(nr_files),
1366 .help = "Split job workload between this number of files",
1369 .category = FIO_OPT_G_FILE,
1372 .name = "openfiles",
1373 .type = FIO_OPT_INT,
1374 .off1 = td_var_offset(open_files),
1375 .help = "Number of files to keep open at the same time",
1376 .category = FIO_OPT_G_FILE,
1379 .name = "file_service_type",
1380 .type = FIO_OPT_STR,
1382 .off1 = td_var_offset(file_service_type),
1383 .help = "How to select which file to service next",
1384 .def = "roundrobin",
1385 .category = FIO_OPT_G_FILE,
1388 .oval = FIO_FSERVICE_RANDOM,
1389 .help = "Choose a file at random",
1391 { .ival = "roundrobin",
1392 .oval = FIO_FSERVICE_RR,
1393 .help = "Round robin select files",
1395 { .ival = "sequential",
1396 .oval = FIO_FSERVICE_SEQ,
1397 .help = "Finish one file before moving to the next",
1400 .parent = "nrfiles",
1403 #ifdef FIO_HAVE_FALLOCATE
1405 .name = "fallocate",
1406 .type = FIO_OPT_STR,
1407 .off1 = td_var_offset(fallocate_mode),
1408 .help = "Whether pre-allocation is performed when laying out files",
1410 .category = FIO_OPT_G_FILE,
1413 .oval = FIO_FALLOCATE_NONE,
1414 .help = "Do not pre-allocate space",
1417 .oval = FIO_FALLOCATE_POSIX,
1418 .help = "Use posix_fallocate()",
1420 #ifdef FIO_HAVE_LINUX_FALLOCATE
1422 .oval = FIO_FALLOCATE_KEEP_SIZE,
1423 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
1426 /* Compatibility with former boolean values */
1428 .oval = FIO_FALLOCATE_NONE,
1429 .help = "Alias for 'none'",
1432 .oval = FIO_FALLOCATE_POSIX,
1433 .help = "Alias for 'posix'",
1437 #endif /* FIO_HAVE_FALLOCATE */
1439 .name = "fadvise_hint",
1440 .type = FIO_OPT_BOOL,
1441 .off1 = td_var_offset(fadvise_hint),
1442 .help = "Use fadvise() to advise the kernel on IO pattern",
1444 .category = FIO_OPT_G_FILE,
1448 .type = FIO_OPT_INT,
1449 .off1 = td_var_offset(fsync_blocks),
1450 .help = "Issue fsync for writes every given number of blocks",
1453 .category = FIO_OPT_G_FILE,
1456 .name = "fdatasync",
1457 .type = FIO_OPT_INT,
1458 .off1 = td_var_offset(fdatasync_blocks),
1459 .help = "Issue fdatasync for writes every given number of blocks",
1462 .category = FIO_OPT_G_FILE,
1465 .name = "write_barrier",
1466 .type = FIO_OPT_INT,
1467 .off1 = td_var_offset(barrier_blocks),
1468 .help = "Make every Nth write a barrier write",
1471 .category = FIO_OPT_G_IO,
1473 #ifdef FIO_HAVE_SYNC_FILE_RANGE
1475 .name = "sync_file_range",
1477 { .ival = "wait_before",
1478 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
1479 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
1483 .oval = SYNC_FILE_RANGE_WRITE,
1484 .help = "SYNC_FILE_RANGE_WRITE",
1488 .ival = "wait_after",
1489 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
1490 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
1494 .type = FIO_OPT_STR_MULTI,
1496 .off1 = td_var_offset(sync_file_range),
1497 .help = "Use sync_file_range()",
1498 .category = FIO_OPT_G_FILE,
1503 .type = FIO_OPT_BOOL,
1504 .off1 = td_var_offset(odirect),
1505 .help = "Use O_DIRECT IO (negates buffered)",
1507 .category = FIO_OPT_G_IO,
1511 .type = FIO_OPT_BOOL,
1512 .off1 = td_var_offset(odirect),
1514 .help = "Use buffered IO (negates direct)",
1516 .category = FIO_OPT_G_IO,
1519 .name = "overwrite",
1520 .type = FIO_OPT_BOOL,
1521 .off1 = td_var_offset(overwrite),
1522 .help = "When writing, set whether to overwrite current data",
1524 .category = FIO_OPT_G_IO | FIO_OPT_G_FILE,
1528 .type = FIO_OPT_INT,
1529 .off1 = td_var_offset(loops),
1530 .help = "Number of times to run the job",
1533 .category = FIO_OPT_G_MISC,
1537 .type = FIO_OPT_INT,
1538 .off1 = td_var_offset(numjobs),
1539 .help = "Duplicate this job this many times",
1542 .category = FIO_OPT_G_MISC,
1545 .name = "startdelay",
1546 .type = FIO_OPT_STR_VAL_TIME,
1547 .off1 = td_var_offset(start_delay),
1548 .help = "Only start job when this period has passed",
1550 .category = FIO_OPT_G_MISC,
1555 .type = FIO_OPT_STR_VAL_TIME,
1556 .off1 = td_var_offset(timeout),
1557 .help = "Stop workload when this amount of time has passed",
1559 .category = FIO_OPT_G_MISC,
1562 .name = "time_based",
1563 .type = FIO_OPT_STR_SET,
1564 .off1 = td_var_offset(time_based),
1565 .help = "Keep running until runtime/timeout is met",
1566 .category = FIO_OPT_G_MISC,
1569 .name = "ramp_time",
1570 .type = FIO_OPT_STR_VAL_TIME,
1571 .off1 = td_var_offset(ramp_time),
1572 .help = "Ramp up time before measuring performance",
1573 .category = FIO_OPT_G_MISC,
1576 .name = "clocksource",
1577 .type = FIO_OPT_STR,
1578 .cb = fio_clock_source_cb,
1579 .off1 = td_var_offset(clocksource),
1580 .help = "What type of timing source to use",
1581 .category = FIO_OPT_G_OS,
1583 { .ival = "gettimeofday",
1585 .help = "Use gettimeofday(2) for timing",
1587 { .ival = "clock_gettime",
1588 .oval = CS_CGETTIME,
1589 .help = "Use clock_gettime(2) for timing",
1591 #ifdef ARCH_HAVE_CPU_CLOCK
1593 .oval = CS_CPUCLOCK,
1594 .help = "Use CPU private clock",
1602 .type = FIO_OPT_STR,
1604 .off1 = td_var_offset(mem_type),
1605 .help = "Backing type for IO buffers",
1607 .category = FIO_OPT_G_IO_BUF | FIO_OPT_G_MEM,
1611 .help = "Use malloc(3) for IO buffers",
1615 .help = "Use shared memory segments for IO buffers",
1617 #ifdef FIO_HAVE_HUGETLB
1618 { .ival = "shmhuge",
1619 .oval = MEM_SHMHUGE,
1620 .help = "Like shm, but use huge pages",
1625 .help = "Use mmap(2) (file or anon) for IO buffers",
1627 #ifdef FIO_HAVE_HUGETLB
1628 { .ival = "mmaphuge",
1629 .oval = MEM_MMAPHUGE,
1630 .help = "Like mmap, but use huge pages",
1636 .name = "iomem_align",
1637 .alias = "mem_align",
1638 .type = FIO_OPT_INT,
1639 .off1 = td_var_offset(mem_align),
1641 .help = "IO memory buffer offset alignment",
1645 .category = FIO_OPT_G_IO_BUF | FIO_OPT_G_MEM,
1649 .type = FIO_OPT_STR,
1650 .off1 = td_var_offset(verify),
1651 .help = "Verify data written",
1652 .cb = str_verify_cb,
1654 .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY,
1657 .oval = VERIFY_NONE,
1658 .help = "Don't do IO verification",
1662 .help = "Use md5 checksums for verification",
1665 .oval = VERIFY_CRC64,
1666 .help = "Use crc64 checksums for verification",
1669 .oval = VERIFY_CRC32,
1670 .help = "Use crc32 checksums for verification",
1672 { .ival = "crc32c-intel",
1673 .oval = VERIFY_CRC32C,
1674 .help = "Use crc32c checksums for verification (hw assisted, if available)",
1677 .oval = VERIFY_CRC32C,
1678 .help = "Use crc32c checksums for verification (hw assisted, if available)",
1681 .oval = VERIFY_CRC16,
1682 .help = "Use crc16 checksums for verification",
1685 .oval = VERIFY_CRC7,
1686 .help = "Use crc7 checksums for verification",
1689 .oval = VERIFY_SHA1,
1690 .help = "Use sha1 checksums for verification",
1693 .oval = VERIFY_SHA256,
1694 .help = "Use sha256 checksums for verification",
1697 .oval = VERIFY_SHA512,
1698 .help = "Use sha512 checksums for verification",
1701 .oval = VERIFY_META,
1702 .help = "Use io information",
1706 .oval = VERIFY_NULL,
1707 .help = "Pretend to verify",
1712 .name = "do_verify",
1713 .type = FIO_OPT_BOOL,
1714 .off1 = td_var_offset(do_verify),
1715 .help = "Run verification stage after write",
1719 .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY,
1722 .name = "verifysort",
1723 .type = FIO_OPT_BOOL,
1724 .off1 = td_var_offset(verifysort),
1725 .help = "Sort written verify blocks for read back",
1729 .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY,
1732 .name = "verify_interval",
1733 .type = FIO_OPT_INT,
1734 .off1 = td_var_offset(verify_interval),
1735 .minval = 2 * sizeof(struct verify_header),
1736 .help = "Store verify buffer header every N bytes",
1739 .interval = 2 * sizeof(struct verify_header),
1740 .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY,
1743 .name = "verify_offset",
1744 .type = FIO_OPT_INT,
1745 .help = "Offset verify header location by N bytes",
1747 .cb = str_verify_offset_cb,
1750 .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY,
1753 .name = "verify_pattern",
1754 .type = FIO_OPT_STR,
1755 .cb = str_verify_pattern_cb,
1756 .help = "Fill pattern for IO buffers",
1759 .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY,
1762 .name = "verify_fatal",
1763 .type = FIO_OPT_BOOL,
1764 .off1 = td_var_offset(verify_fatal),
1766 .help = "Exit on a single verify failure, don't continue",
1769 .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY | FIO_OPT_G_ERR,
1772 .name = "verify_dump",
1773 .type = FIO_OPT_BOOL,
1774 .off1 = td_var_offset(verify_dump),
1776 .help = "Dump contents of good and bad blocks on failure",
1779 .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY | FIO_OPT_G_ERR,
1782 .name = "verify_async",
1783 .type = FIO_OPT_INT,
1784 .off1 = td_var_offset(verify_async),
1786 .help = "Number of async verifier threads to use",
1789 .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY,
1792 .name = "verify_backlog",
1793 .type = FIO_OPT_STR_VAL,
1794 .off1 = td_var_offset(verify_backlog),
1795 .help = "Verify after this number of blocks are written",
1798 .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY,
1801 .name = "verify_backlog_batch",
1802 .type = FIO_OPT_INT,
1803 .off1 = td_var_offset(verify_batch),
1804 .help = "Verify this number of IO blocks",
1807 .category = FIO_OPT_G_IO | FIO_OPT_G_VERIFY,
1809 #ifdef FIO_HAVE_CPU_AFFINITY
1811 .name = "verify_async_cpus",
1812 .type = FIO_OPT_STR,
1813 .cb = str_verify_cpus_allowed_cb,
1814 .help = "Set CPUs allowed for async verify threads",
1815 .parent = "verify_async",
1817 .category = FIO_OPT_G_OS | FIO_OPT_G_CPU | FIO_OPT_G_VERIFY,
1820 #ifdef FIO_HAVE_TRIM
1822 .name = "trim_percentage",
1823 .type = FIO_OPT_INT,
1824 .cb = str_verify_trim_cb,
1827 .help = "Number of verify blocks to discard/trim",
1832 .category = FIO_OPT_G_IO,
1835 .name = "trim_verify_zero",
1836 .type = FIO_OPT_BOOL,
1837 .help = "Verify that trim/discarded blocks are returned as zeroes",
1838 .off1 = td_var_offset(trim_zero),
1839 .parent = "trim_percentage",
1842 .category = FIO_OPT_G_IO,
1845 .name = "trim_backlog",
1846 .type = FIO_OPT_STR_VAL,
1847 .off1 = td_var_offset(trim_backlog),
1848 .help = "Trim after this number of blocks are written",
1849 .parent = "trim_percentage",
1852 .category = FIO_OPT_G_IO,
1855 .name = "trim_backlog_batch",
1856 .type = FIO_OPT_INT,
1857 .off1 = td_var_offset(trim_batch),
1858 .help = "Trim this number of IO blocks",
1859 .parent = "trim_percentage",
1862 .category = FIO_OPT_G_IO,
1866 .name = "write_iolog",
1867 .type = FIO_OPT_STR_STORE,
1868 .off1 = td_var_offset(write_iolog_file),
1869 .help = "Store IO pattern to file",
1870 .category = FIO_OPT_G_IO | FIO_OPT_G_LOG,
1873 .name = "read_iolog",
1874 .type = FIO_OPT_STR_STORE,
1875 .off1 = td_var_offset(read_iolog_file),
1876 .help = "Playback IO pattern from file",
1877 .category = FIO_OPT_G_IO | FIO_OPT_G_LOG,
1880 .name = "replay_no_stall",
1881 .type = FIO_OPT_BOOL,
1882 .off1 = td_var_offset(no_stall),
1884 .parent = "read_iolog",
1886 .help = "Playback IO pattern file as fast as possible without stalls",
1887 .category = FIO_OPT_G_IO | FIO_OPT_G_LOG,
1890 .name = "replay_redirect",
1891 .type = FIO_OPT_STR_STORE,
1892 .off1 = td_var_offset(replay_redirect),
1893 .parent = "read_iolog",
1895 .help = "Replay all I/O onto this device, regardless of trace device",
1896 .category = FIO_OPT_G_IO | FIO_OPT_G_LOG,
1899 .name = "exec_prerun",
1900 .type = FIO_OPT_STR_STORE,
1901 .off1 = td_var_offset(exec_prerun),
1902 .help = "Execute this file prior to running job",
1903 .category = FIO_OPT_G_MISC | FIO_OPT_G_OS,
1906 .name = "exec_postrun",
1907 .type = FIO_OPT_STR_STORE,
1908 .off1 = td_var_offset(exec_postrun),
1909 .help = "Execute this file after running job",
1910 .category = FIO_OPT_G_MISC | FIO_OPT_G_OS,
1912 #ifdef FIO_HAVE_IOSCHED_SWITCH
1914 .name = "ioscheduler",
1915 .type = FIO_OPT_STR_STORE,
1916 .off1 = td_var_offset(ioscheduler),
1917 .help = "Use this IO scheduler on the backing device",
1918 .category = FIO_OPT_G_OS | FIO_OPT_G_IO,
1923 .type = FIO_OPT_STR_VAL,
1924 .off1 = td_var_offset(zone_size),
1925 .help = "Amount of data to read per zone",
1927 .interval = 1024 * 1024,
1928 .category = FIO_OPT_G_IO | FIO_OPT_G_ZONE,
1931 .name = "zonerange",
1932 .type = FIO_OPT_STR_VAL,
1933 .off1 = td_var_offset(zone_range),
1934 .help = "Give size of an IO zone",
1936 .interval = 1024 * 1024,
1937 .category = FIO_OPT_G_IO | FIO_OPT_G_ZONE,
1941 .type = FIO_OPT_STR_VAL,
1942 .off1 = td_var_offset(zone_skip),
1943 .help = "Space between IO zones",
1945 .interval = 1024 * 1024,
1946 .category = FIO_OPT_G_IO | FIO_OPT_G_ZONE,
1950 .type = FIO_OPT_STR_VAL,
1951 .cb = str_lockmem_cb,
1952 .help = "Lock down this amount of memory",
1954 .interval = 1024 * 1024,
1955 .category = FIO_OPT_G_OS | FIO_OPT_G_MEM,
1958 .name = "rwmixread",
1959 .type = FIO_OPT_INT,
1960 .cb = str_rwmix_read_cb,
1962 .help = "Percentage of mixed workload that is reads",
1965 .category = FIO_OPT_G_IO,
1968 .name = "rwmixwrite",
1969 .type = FIO_OPT_INT,
1970 .cb = str_rwmix_write_cb,
1972 .help = "Percentage of mixed workload that is writes",
1975 .category = FIO_OPT_G_IO,
1978 .name = "rwmixcycle",
1979 .type = FIO_OPT_DEPRECATED,
1980 .category = FIO_OPT_G_IO,
1984 .type = FIO_OPT_INT,
1985 .off1 = td_var_offset(nice),
1986 .help = "Set job CPU nice value",
1991 .category = FIO_OPT_G_OS | FIO_OPT_G_CPU,
1993 #ifdef FIO_HAVE_IOPRIO
1996 .type = FIO_OPT_INT,
1998 .help = "Set job IO priority value",
2002 .category = FIO_OPT_G_OS | FIO_OPT_G_CPU,
2005 .name = "prioclass",
2006 .type = FIO_OPT_INT,
2007 .cb = str_prioclass_cb,
2008 .help = "Set job IO priority class",
2012 .category = FIO_OPT_G_OS | FIO_OPT_G_CPU,
2016 .name = "thinktime",
2017 .type = FIO_OPT_INT,
2018 .off1 = td_var_offset(thinktime),
2019 .help = "Idle time between IO buffers (usec)",
2021 .category = FIO_OPT_G_MISC,
2024 .name = "thinktime_spin",
2025 .type = FIO_OPT_INT,
2026 .off1 = td_var_offset(thinktime_spin),
2027 .help = "Start think time by spinning this amount (usec)",
2029 .parent = "thinktime",
2031 .category = FIO_OPT_G_MISC,
2034 .name = "thinktime_blocks",
2035 .type = FIO_OPT_INT,
2036 .off1 = td_var_offset(thinktime_blocks),
2037 .help = "IO buffer period between 'thinktime'",
2039 .parent = "thinktime",
2041 .category = FIO_OPT_G_MISC,
2045 .type = FIO_OPT_INT,
2046 .off1 = td_var_offset(rate[0]),
2047 .off2 = td_var_offset(rate[1]),
2048 .help = "Set bandwidth rate",
2049 .category = FIO_OPT_G_IO,
2053 .type = FIO_OPT_INT,
2054 .off1 = td_var_offset(ratemin[0]),
2055 .off2 = td_var_offset(ratemin[1]),
2056 .help = "Job must meet this rate or it will be shutdown",
2059 .category = FIO_OPT_G_IO,
2062 .name = "rate_iops",
2063 .type = FIO_OPT_INT,
2064 .off1 = td_var_offset(rate_iops[0]),
2065 .off2 = td_var_offset(rate_iops[1]),
2066 .help = "Limit IO used to this number of IO operations/sec",
2068 .category = FIO_OPT_G_IO,
2071 .name = "rate_iops_min",
2072 .type = FIO_OPT_INT,
2073 .off1 = td_var_offset(rate_iops_min[0]),
2074 .off2 = td_var_offset(rate_iops_min[1]),
2075 .help = "Job must meet this rate or it will be shut down",
2076 .parent = "rate_iops",
2078 .category = FIO_OPT_G_IO,
2081 .name = "ratecycle",
2082 .type = FIO_OPT_INT,
2083 .off1 = td_var_offset(ratecycle),
2084 .help = "Window average for rate limits (msec)",
2088 .category = FIO_OPT_G_IO,
2091 .name = "invalidate",
2092 .type = FIO_OPT_BOOL,
2093 .off1 = td_var_offset(invalidate_cache),
2094 .help = "Invalidate buffer/page cache prior to running job",
2096 .category = FIO_OPT_G_IO | FIO_OPT_G_CACHE,
2100 .type = FIO_OPT_BOOL,
2101 .off1 = td_var_offset(sync_io),
2102 .help = "Use O_SYNC for buffered writes",
2104 .parent = "buffered",
2106 .category = FIO_OPT_G_IO | FIO_OPT_G_FILE,
2109 .name = "bwavgtime",
2110 .type = FIO_OPT_INT,
2111 .off1 = td_var_offset(bw_avg_time),
2112 .help = "Time window over which to calculate bandwidth"
2115 .parent = "write_bw_log",
2118 .category = FIO_OPT_G_LOG | FIO_OPT_G_STAT,
2121 .name = "iopsavgtime",
2122 .type = FIO_OPT_INT,
2123 .off1 = td_var_offset(iops_avg_time),
2124 .help = "Time window over which to calculate IOPS (msec)",
2126 .parent = "write_iops_log",
2129 .category = FIO_OPT_G_LOG | FIO_OPT_G_STAT,
2132 .name = "create_serialize",
2133 .type = FIO_OPT_BOOL,
2134 .off1 = td_var_offset(create_serialize),
2135 .help = "Serialize creating of job files",
2137 .category = FIO_OPT_G_FILE,
2140 .name = "create_fsync",
2141 .type = FIO_OPT_BOOL,
2142 .off1 = td_var_offset(create_fsync),
2143 .help = "fsync file after creation",
2145 .category = FIO_OPT_G_FILE,
2148 .name = "create_on_open",
2149 .type = FIO_OPT_BOOL,
2150 .off1 = td_var_offset(create_on_open),
2151 .help = "Create files when they are opened for IO",
2153 .category = FIO_OPT_G_FILE,
2157 .type = FIO_OPT_BOOL,
2158 .off1 = td_var_offset(pre_read),
2159 .help = "Pre-read files before starting official testing",
2161 .category = FIO_OPT_G_FILE | FIO_OPT_G_CACHE,
2165 .type = FIO_OPT_INT,
2166 .off1 = td_var_offset(cpuload),
2167 .help = "Use this percentage of CPU",
2168 .category = FIO_OPT_G_CPU,
2171 .name = "cpuchunks",
2172 .type = FIO_OPT_INT,
2173 .off1 = td_var_offset(cpucycle),
2174 .help = "Length of the CPU burn cycles (usecs)",
2176 .parent = "cpuload",
2178 .category = FIO_OPT_G_CPU,
2180 #ifdef FIO_HAVE_CPU_AFFINITY
2183 .type = FIO_OPT_INT,
2184 .cb = str_cpumask_cb,
2185 .help = "CPU affinity mask",
2186 .category = FIO_OPT_G_CPU | FIO_OPT_G_OS,
2189 .name = "cpus_allowed",
2190 .type = FIO_OPT_STR,
2191 .cb = str_cpus_allowed_cb,
2192 .help = "Set CPUs allowed",
2193 .category = FIO_OPT_G_CPU | FIO_OPT_G_OS,
2197 .name = "end_fsync",
2198 .type = FIO_OPT_BOOL,
2199 .off1 = td_var_offset(end_fsync),
2200 .help = "Include fsync at the end of job",
2202 .category = FIO_OPT_G_FILE,
2205 .name = "fsync_on_close",
2206 .type = FIO_OPT_BOOL,
2207 .off1 = td_var_offset(fsync_on_close),
2208 .help = "fsync files on close",
2210 .category = FIO_OPT_G_FILE,
2214 .type = FIO_OPT_BOOL,
2215 .off1 = td_var_offset(unlink),
2216 .help = "Unlink created files after job has completed",
2218 .category = FIO_OPT_G_FILE,
2222 .type = FIO_OPT_STR_SET,
2223 .cb = str_exitall_cb,
2224 .help = "Terminate all jobs when one exits",
2225 .category = FIO_OPT_G_MISC | FIO_OPT_G_JOB,
2228 .name = "stonewall",
2229 .alias = "wait_for_previous",
2230 .type = FIO_OPT_STR_SET,
2231 .off1 = td_var_offset(stonewall),
2232 .help = "Insert a hard barrier between this job and previous",
2233 .category = FIO_OPT_G_MISC | FIO_OPT_G_JOB,
2236 .name = "new_group",
2237 .type = FIO_OPT_STR_SET,
2238 .off1 = td_var_offset(new_group),
2239 .help = "Mark the start of a new group (for reporting)",
2240 .category = FIO_OPT_G_MISC | FIO_OPT_G_JOB,
2244 .type = FIO_OPT_STR_SET,
2245 .off1 = td_var_offset(use_thread),
2246 .help = "Use threads instead of processes",
2247 .category = FIO_OPT_G_MISC | FIO_OPT_G_OS | FIO_OPT_G_JOB,
2250 .name = "write_bw_log",
2251 .type = FIO_OPT_STR,
2252 .off1 = td_var_offset(write_bw_log),
2253 .cb = str_write_bw_log_cb,
2254 .help = "Write log of bandwidth during run",
2255 .category = FIO_OPT_G_LOG,
2258 .name = "write_lat_log",
2259 .type = FIO_OPT_STR,
2260 .off1 = td_var_offset(write_lat_log),
2261 .cb = str_write_lat_log_cb,
2262 .help = "Write log of latency during run",
2263 .category = FIO_OPT_G_LOG,
2266 .name = "write_iops_log",
2267 .type = FIO_OPT_STR,
2268 .off1 = td_var_offset(write_iops_log),
2269 .cb = str_write_iops_log_cb,
2270 .help = "Write log of IOPS during run",
2271 .category = FIO_OPT_G_LOG,
2274 .name = "log_avg_msec",
2275 .type = FIO_OPT_INT,
2276 .off1 = td_var_offset(log_avg_msec),
2277 .help = "Average bw/iops/lat logs over this period of time",
2279 .category = FIO_OPT_G_LOG,
2282 .name = "hugepage-size",
2283 .type = FIO_OPT_INT,
2284 .off1 = td_var_offset(hugepage_size),
2285 .help = "When using hugepages, specify size of each page",
2286 .def = __fio_stringify(FIO_HUGE_PAGE),
2287 .interval = 1024 * 1024,
2288 .category = FIO_OPT_G_OS | FIO_OPT_G_MEM,
2291 .name = "group_reporting",
2292 .type = FIO_OPT_STR_SET,
2293 .off1 = td_var_offset(group_reporting),
2294 .help = "Do reporting on a per-group basis",
2295 .category = FIO_OPT_G_MISC,
2298 .name = "zero_buffers",
2299 .type = FIO_OPT_STR_SET,
2300 .off1 = td_var_offset(zero_buffers),
2301 .help = "Init IO buffers to all zeroes",
2302 .category = FIO_OPT_G_IO_BUF,
2305 .name = "refill_buffers",
2306 .type = FIO_OPT_STR_SET,
2307 .off1 = td_var_offset(refill_buffers),
2308 .help = "Refill IO buffers on every IO submit",
2309 .category = FIO_OPT_G_IO_BUF,
2312 .name = "scramble_buffers",
2313 .type = FIO_OPT_BOOL,
2314 .off1 = td_var_offset(scramble_buffers),
2315 .help = "Slightly scramble buffers on every IO submit",
2317 .category = FIO_OPT_G_IO_BUF,
2320 .name = "buffer_compress_percentage",
2321 .type = FIO_OPT_INT,
2322 .off1 = td_var_offset(compress_percentage),
2325 .help = "How compressible the buffer is (approximately)",
2327 .category = FIO_OPT_G_IO_BUF,
2330 .name = "buffer_compress_chunk",
2331 .type = FIO_OPT_INT,
2332 .off1 = td_var_offset(compress_chunk),
2333 .parent = "buffer_compress_percentage",
2335 .help = "Size of compressible region in buffer",
2337 .category = FIO_OPT_G_IO_BUF,
2340 .name = "clat_percentiles",
2341 .type = FIO_OPT_BOOL,
2342 .off1 = td_var_offset(clat_percentiles),
2343 .help = "Enable the reporting of completion latency percentiles",
2345 .category = FIO_OPT_G_STAT,
2348 .name = "percentile_list",
2349 .type = FIO_OPT_FLOAT_LIST,
2350 .off1 = td_var_offset(percentile_list),
2351 .off2 = td_var_offset(overwrite_plist),
2352 .help = "Specify a custom list of percentiles to report",
2353 .maxlen = FIO_IO_U_LIST_MAX_LEN,
2356 .category = FIO_OPT_G_STAT,
2359 #ifdef FIO_HAVE_DISK_UTIL
2361 .name = "disk_util",
2362 .type = FIO_OPT_BOOL,
2363 .off1 = td_var_offset(do_disk_util),
2364 .help = "Log disk utilization statistics",
2366 .category = FIO_OPT_G_OS | FIO_OPT_G_STAT,
2370 .name = "gtod_reduce",
2371 .type = FIO_OPT_BOOL,
2372 .help = "Greatly reduce number of gettimeofday() calls",
2373 .cb = str_gtod_reduce_cb,
2375 .category = FIO_OPT_G_OS | FIO_OPT_G_MISC | FIO_OPT_G_STAT,
2378 .name = "disable_lat",
2379 .type = FIO_OPT_BOOL,
2380 .off1 = td_var_offset(disable_lat),
2381 .help = "Disable latency numbers",
2382 .parent = "gtod_reduce",
2385 .category = FIO_OPT_G_OS | FIO_OPT_G_MISC | FIO_OPT_G_STAT,
2388 .name = "disable_clat",
2389 .type = FIO_OPT_BOOL,
2390 .off1 = td_var_offset(disable_clat),
2391 .help = "Disable completion latency numbers",
2392 .parent = "gtod_reduce",
2395 .category = FIO_OPT_G_OS | FIO_OPT_G_MISC | FIO_OPT_G_STAT,
2398 .name = "disable_slat",
2399 .type = FIO_OPT_BOOL,
2400 .off1 = td_var_offset(disable_slat),
2401 .help = "Disable submission latency numbers",
2402 .parent = "gtod_reduce",
2405 .category = FIO_OPT_G_OS | FIO_OPT_G_MISC | FIO_OPT_G_STAT,
2408 .name = "disable_bw_measurement",
2409 .type = FIO_OPT_BOOL,
2410 .off1 = td_var_offset(disable_bw),
2411 .help = "Disable bandwidth logging",
2412 .parent = "gtod_reduce",
2415 .category = FIO_OPT_G_OS | FIO_OPT_G_MISC | FIO_OPT_G_STAT,
2419 .type = FIO_OPT_INT,
2420 .cb = str_gtod_cpu_cb,
2421 .help = "Set up dedicated gettimeofday() thread on this CPU",
2422 .verify = gtod_cpu_verify,
2423 .category = FIO_OPT_G_OS | FIO_OPT_G_MISC | FIO_OPT_G_STAT,
2426 .name = "continue_on_error",
2427 .type = FIO_OPT_STR,
2428 .off1 = td_var_offset(continue_on_error),
2429 .help = "Continue on non-fatal errors during IO",
2431 .category = FIO_OPT_G_MISC | FIO_OPT_G_ERR,
2434 .oval = ERROR_TYPE_NONE,
2435 .help = "Exit when an error is encountered",
2438 .oval = ERROR_TYPE_READ,
2439 .help = "Continue on read errors only",
2442 .oval = ERROR_TYPE_WRITE,
2443 .help = "Continue on write errors only",
2446 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
2447 .help = "Continue on any IO errors",
2450 .oval = ERROR_TYPE_VERIFY,
2451 .help = "Continue on verify errors only",
2454 .oval = ERROR_TYPE_ANY,
2455 .help = "Continue on all io and verify errors",
2458 .oval = ERROR_TYPE_NONE,
2459 .help = "Alias for 'none'",
2462 .oval = ERROR_TYPE_ANY,
2463 .help = "Alias for 'all'",
2469 .type = FIO_OPT_STR_STORE,
2470 .off1 = td_var_offset(profile),
2471 .help = "Select a specific builtin performance test",
2472 .category = FIO_OPT_G_MISC | FIO_OPT_G_JOB,
2476 .type = FIO_OPT_STR_STORE,
2477 .off1 = td_var_offset(cgroup),
2478 .help = "Add job to cgroup of this name",
2479 .category = FIO_OPT_G_MISC | FIO_OPT_G_OS,
2482 .name = "cgroup_weight",
2483 .type = FIO_OPT_INT,
2484 .off1 = td_var_offset(cgroup_weight),
2485 .help = "Use given weight for cgroup",
2488 .category = FIO_OPT_G_MISC | FIO_OPT_G_OS,
2491 .name = "cgroup_nodelete",
2492 .type = FIO_OPT_BOOL,
2493 .off1 = td_var_offset(cgroup_nodelete),
2494 .help = "Do not delete cgroups after job completion",
2496 .category = FIO_OPT_G_MISC | FIO_OPT_G_OS,
2500 .type = FIO_OPT_INT,
2501 .off1 = td_var_offset(uid),
2502 .help = "Run job with this user ID",
2503 .category = FIO_OPT_G_OS | FIO_OPT_G_JOB,
2507 .type = FIO_OPT_INT,
2508 .off1 = td_var_offset(gid),
2509 .help = "Run job with this group ID",
2510 .category = FIO_OPT_G_OS | FIO_OPT_G_JOB,
2514 .type = FIO_OPT_INT,
2515 .off1 = td_var_offset(flow_id),
2516 .help = "The flow index ID to use",
2518 .category = FIO_OPT_G_IO,
2522 .type = FIO_OPT_INT,
2523 .off1 = td_var_offset(flow),
2524 .help = "Weight for flow control of this job",
2525 .parent = "flow_id",
2528 .category = FIO_OPT_G_IO,
2531 .name = "flow_watermark",
2532 .type = FIO_OPT_INT,
2533 .off1 = td_var_offset(flow_watermark),
2534 .help = "High watermark for flow control. This option"
2535 " should be set to the same value for all threads"
2536 " with non-zero flow.",
2537 .parent = "flow_id",
2540 .category = FIO_OPT_G_IO,
2543 .name = "flow_sleep",
2544 .type = FIO_OPT_INT,
2545 .off1 = td_var_offset(flow_sleep),
2546 .help = "How many microseconds to sleep after being held"
2547 " back by the flow control mechanism",
2548 .parent = "flow_id",
2551 .category = FIO_OPT_G_IO,
2558 static void add_to_lopt(struct option *lopt, struct fio_option *o,
2559 const char *name, int val)
2561 lopt->name = (char *) name;
2563 if (o->type == FIO_OPT_STR_SET)
2564 lopt->has_arg = no_argument;
2566 lopt->has_arg = required_argument;
2569 static void options_to_lopts(struct fio_option *opts,
2570 struct option *long_options,
2571 int i, int option_type)
2573 struct fio_option *o = &opts[0];
2575 add_to_lopt(&long_options[i], o, o->name, option_type);
2578 add_to_lopt(&long_options[i], o, o->alias, option_type);
2583 assert(i < FIO_NR_OPTIONS);
2587 void fio_options_set_ioengine_opts(struct option *long_options,
2588 struct thread_data *td)
2593 while (long_options[i].name) {
2594 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
2595 memset(&long_options[i], 0, sizeof(*long_options));
2602 * Just clear out the prior ioengine options.
2607 options_to_lopts(td->io_ops->options, long_options, i,
2608 FIO_GETOPT_IOENGINE);
2611 void fio_options_dup_and_init(struct option *long_options)
2615 options_init(fio_options);
2618 while (long_options[i].name)
2621 options_to_lopts(fio_options, long_options, i, FIO_GETOPT_JOB);
2624 struct fio_keyword {
2630 static struct fio_keyword fio_keywords[] = {
2632 .word = "$pagesize",
2633 .desc = "Page size in the system",
2636 .word = "$mb_memory",
2637 .desc = "Megabytes of memory online",
2641 .desc = "Number of CPUs online in the system",
2648 void fio_keywords_init(void)
2650 unsigned long long mb_memory;
2654 sprintf(buf, "%lu", page_size);
2655 fio_keywords[0].replace = strdup(buf);
2657 mb_memory = os_phys_mem() / (1024 * 1024);
2658 sprintf(buf, "%llu", mb_memory);
2659 fio_keywords[1].replace = strdup(buf);
2662 sprintf(buf, "%lu", l);
2663 fio_keywords[2].replace = strdup(buf);
2668 static char *bc_calc(char *str)
2670 char buf[128], *tmp;
2675 * No math, just return string
2677 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
2678 !strchr(str, '/')) || strchr(str, '\''))
2682 * Split option from value, we only need to calculate the value
2684 tmp = strchr(str, '=');
2691 * Prevent buffer overflows; such a case isn't reasonable anyway
2693 if (strlen(str) >= 128 || strlen(tmp) > 100)
2696 sprintf(buf, "which %s > /dev/null", BC_APP);
2698 log_err("fio: bc is needed for performing math\n");
2702 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
2703 f = popen(buf, "r");
2708 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
2714 buf[(tmp - str) + ret - 1] = '\0';
2715 memcpy(buf, str, tmp - str);
2721 * Return a copy of the input string with substrings of the form ${VARNAME}
2722 * substituted with the value of the environment variable VARNAME. The
2723 * substitution always occurs, even if VARNAME is empty or the corresponding
2724 * environment variable undefined.
2726 static char *option_dup_subs(const char *opt)
2728 char out[OPT_LEN_MAX+1];
2729 char in[OPT_LEN_MAX+1];
2732 char *ch1, *ch2, *env;
2733 ssize_t nchr = OPT_LEN_MAX;
2736 if (strlen(opt) + 1 > OPT_LEN_MAX) {
2737 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
2741 in[OPT_LEN_MAX] = '\0';
2742 strncpy(in, opt, OPT_LEN_MAX);
2744 while (*inptr && nchr > 0) {
2745 if (inptr[0] == '$' && inptr[1] == '{') {
2746 ch2 = strchr(inptr, '}');
2747 if (ch2 && inptr+1 < ch2) {
2754 envlen = strlen(env);
2755 if (envlen <= nchr) {
2756 memcpy(outptr, env, envlen);
2766 *outptr++ = *inptr++;
2775 * Look for reserved variable names and replace them with real values
2777 static char *fio_keyword_replace(char *opt)
2783 for (i = 0; fio_keywords[i].word != NULL; i++) {
2784 struct fio_keyword *kw = &fio_keywords[i];
2786 while ((s = strstr(opt, kw->word)) != NULL) {
2787 char *new = malloc(strlen(opt) + 1);
2793 * Copy part of the string before the keyword and
2794 * sprintf() the replacement after it.
2796 memcpy(new, opt, olen);
2797 len = sprintf(new + olen, "%s", kw->replace);
2800 * If there's more in the original string, copy that
2803 opt += strlen(kw->word) + olen;
2805 memcpy(new + olen + len, opt, opt - o_org - 1);
2808 * replace opt and free the old opt
2818 * Check for potential math and invoke bc, if possible
2826 static char **dup_and_sub_options(char **opts, int num_opts)
2829 char **opts_copy = malloc(num_opts * sizeof(*opts));
2830 for (i = 0; i < num_opts; i++) {
2831 opts_copy[i] = option_dup_subs(opts[i]);
2834 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
2839 int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
2841 int i, ret, unknown;
2844 sort_options(opts, fio_options, num_opts);
2845 opts_copy = dup_and_sub_options(opts, num_opts);
2847 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
2848 struct fio_option *o;
2849 int newret = parse_option(opts_copy[i], opts[i], fio_options,
2858 opts_copy[i] = NULL;
2865 ret |= ioengine_load(td);
2867 sort_options(opts_copy, td->io_ops->options, num_opts);
2870 for (i = 0; i < num_opts; i++) {
2871 struct fio_option *o = NULL;
2877 newret = parse_option(opts_copy[i], opts[i],
2878 td->io_ops->options, &o,
2883 log_err("Bad option <%s>\n", opts[i]);
2886 opts_copy[i] = NULL;
2894 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
2896 return parse_cmd_option(opt, val, fio_options, td);
2899 int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
2902 return parse_cmd_option(opt, val, td->io_ops->options, td);
2905 void fio_fill_default_options(struct thread_data *td)
2907 fill_default_options(td, fio_options);
2910 int fio_show_option_help(const char *opt)
2912 return show_cmd_help(fio_options, opt);
2915 void options_mem_dupe(void *data, struct fio_option *options)
2917 struct fio_option *o;
2920 for (o = &options[0]; o->name; o++) {
2921 if (o->type != FIO_OPT_STR_STORE)
2924 ptr = td_var(data, o->off1);
2926 *ptr = strdup(*ptr);
2931 * dupe FIO_OPT_STR_STORE options
2933 void fio_options_mem_dupe(struct thread_data *td)
2935 options_mem_dupe(&td->o, fio_options);
2937 if (td->eo && td->io_ops) {
2938 void *oldeo = td->eo;
2940 td->eo = malloc(td->io_ops->option_struct_size);
2941 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
2942 options_mem_dupe(td->eo, td->io_ops->options);
2946 unsigned int fio_get_kb_base(void *data)
2948 struct thread_data *td = data;
2949 unsigned int kb_base = 0;
2952 kb_base = td->o.kb_base;
2959 int add_option(struct fio_option *o)
2961 struct fio_option *__o;
2970 memcpy(&fio_options[opt_index], o, sizeof(*o));
2974 void invalidate_profile_options(const char *prof_name)
2976 struct fio_option *o;
2980 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
2981 o->type = FIO_OPT_INVALID;
2982 o->prof_name = NULL;
2988 void add_opt_posval(const char *optname, const char *ival, const char *help)
2990 struct fio_option *o;
2993 o = find_option(fio_options, optname);
2997 for (i = 0; i < PARSE_MAX_VP; i++) {
2998 if (o->posval[i].ival)
3001 o->posval[i].ival = ival;
3002 o->posval[i].help = help;
3007 void del_opt_posval(const char *optname, const char *ival)
3009 struct fio_option *o;
3012 o = find_option(fio_options, optname);
3016 for (i = 0; i < PARSE_MAX_VP; i++) {
3017 if (!o->posval[i].ival)
3019 if (strcmp(o->posval[i].ival, ival))
3022 o->posval[i].ival = NULL;
3023 o->posval[i].help = NULL;
3027 void fio_options_free(struct thread_data *td)
3029 options_free(fio_options, td);
3030 if (td->eo && td->io_ops && td->io_ops->options) {
3031 options_free(td->io_ops->options, td->eo);