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;
172 p = str = strdup(input);
174 strip_blank_front(&str);
175 strip_blank_end(str);
177 odir = strchr(str, ',');
179 ret = bssplit_ddir(td, DDIR_WRITE, odir + 1);
182 ret = bssplit_ddir(td, DDIR_READ, str);
189 ret = bssplit_ddir(td, DDIR_READ, str);
191 ret = bssplit_ddir(td, DDIR_WRITE, op);
200 static int str_rw_cb(void *data, const char *str)
202 struct thread_data *td = data;
203 char *nr = get_opt_postfix(str);
205 td->o.ddir_seq_nr = 1;
206 td->o.ddir_seq_add = 0;
212 td->o.ddir_seq_nr = atoi(nr);
216 if (str_to_decimal(nr, &val, 1, td)) {
217 log_err("fio: rw postfix parsing failed\n");
222 td->o.ddir_seq_add = val;
229 #ifdef FIO_HAVE_LIBAIO
230 static int str_libaio_cb(void *data, const char *str)
232 struct thread_data *td = data;
234 if (!strcmp(str, "userspace_reap")) {
235 td->o.userspace_libaio_reap = 1;
239 log_err("fio: bad libaio sub-option: %s\n", str);
244 static int str_mem_cb(void *data, const char *mem)
246 struct thread_data *td = data;
248 if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP) {
249 td->mmapfile = get_opt_postfix(mem);
250 if (td->o.mem_type == MEM_MMAPHUGE && !td->mmapfile) {
251 log_err("fio: mmaphuge:/path/to/file\n");
259 static int str_verify_cb(void *data, const char *mem)
261 struct thread_data *td = data;
263 if (td->o.verify != VERIFY_CRC32C_INTEL)
266 if (!crc32c_intel_works()) {
267 log_info("fio: System does not support hw accelerated crc32c. Falling back to sw crc32c.\n");
268 td->o.verify = VERIFY_CRC32C;
274 static int fio_clock_source_cb(void *data, const char *str)
276 struct thread_data *td = data;
278 fio_clock_source = td->o.clocksource;
283 static int str_lockmem_cb(void fio_unused *data, unsigned long long *val)
289 static int str_rwmix_read_cb(void *data, unsigned long long *val)
291 struct thread_data *td = data;
293 td->o.rwmix[DDIR_READ] = *val;
294 td->o.rwmix[DDIR_WRITE] = 100 - *val;
298 static int str_rwmix_write_cb(void *data, unsigned long long *val)
300 struct thread_data *td = data;
302 td->o.rwmix[DDIR_WRITE] = *val;
303 td->o.rwmix[DDIR_READ] = 100 - *val;
307 #ifdef FIO_HAVE_IOPRIO
308 static int str_prioclass_cb(void *data, unsigned long long *val)
310 struct thread_data *td = data;
314 * mask off old class bits, str_prio_cb() may have set a default class
316 mask = (1 << IOPRIO_CLASS_SHIFT) - 1;
319 td->ioprio |= *val << IOPRIO_CLASS_SHIFT;
324 static int str_prio_cb(void *data, unsigned long long *val)
326 struct thread_data *td = data;
331 * If no class is set, assume BE
333 if ((td->ioprio >> IOPRIO_CLASS_SHIFT) == 0)
334 td->ioprio |= IOPRIO_CLASS_BE << IOPRIO_CLASS_SHIFT;
341 static int str_exitall_cb(void)
343 exitall_on_terminate = 1;
347 #ifdef FIO_HAVE_CPU_AFFINITY
348 static int str_cpumask_cb(void *data, unsigned long long *val)
350 struct thread_data *td = data;
355 ret = fio_cpuset_init(&td->o.cpumask);
357 log_err("fio: cpuset_init failed\n");
358 td_verror(td, ret, "fio_cpuset_init");
362 max_cpu = cpus_online();
364 for (i = 0; i < sizeof(int) * 8; i++) {
365 if ((1 << i) & *val) {
367 log_err("fio: CPU %d too large (max=%ld)\n", i,
371 dprint(FD_PARSE, "set cpu allowed %d\n", i);
372 fio_cpu_set(&td->o.cpumask, i);
376 td->o.cpumask_set = 1;
380 static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask,
387 ret = fio_cpuset_init(mask);
389 log_err("fio: cpuset_init failed\n");
390 td_verror(td, ret, "fio_cpuset_init");
394 p = str = strdup(input);
396 strip_blank_front(&str);
397 strip_blank_end(str);
399 max_cpu = cpus_online();
401 while ((cpu = strsep(&str, ",")) != NULL) {
410 while ((cpu2 = strsep(&str2, "-")) != NULL) {
420 while (icpu <= icpu2) {
421 if (icpu >= FIO_MAX_CPUS) {
422 log_err("fio: your OS only supports up to"
423 " %d CPUs\n", (int) FIO_MAX_CPUS);
427 if (icpu > max_cpu) {
428 log_err("fio: CPU %d too large (max=%ld)\n",
434 dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
435 fio_cpu_set(mask, icpu);
444 td->o.cpumask_set = 1;
448 static int str_cpus_allowed_cb(void *data, const char *input)
450 struct thread_data *td = data;
453 ret = set_cpus_allowed(td, &td->o.cpumask, input);
455 td->o.cpumask_set = 1;
460 static int str_verify_cpus_allowed_cb(void *data, const char *input)
462 struct thread_data *td = data;
465 ret = set_cpus_allowed(td, &td->o.verify_cpumask, input);
467 td->o.verify_cpumask_set = 1;
474 static int str_verify_trim_cb(void *data, unsigned long long *val)
476 struct thread_data *td = data;
478 td->o.trim_percentage = *val;
483 static int str_fst_cb(void *data, const char *str)
485 struct thread_data *td = data;
486 char *nr = get_opt_postfix(str);
488 td->file_service_nr = 1;
490 td->file_service_nr = atoi(nr);
497 #ifdef FIO_HAVE_SYNC_FILE_RANGE
498 static int str_sfr_cb(void *data, const char *str)
500 struct thread_data *td = data;
501 char *nr = get_opt_postfix(str);
503 td->sync_file_range_nr = 1;
505 td->sync_file_range_nr = atoi(nr);
513 static int check_dir(struct thread_data *td, char *fname)
516 char file[PATH_MAX], *dir;
519 if (td->o.directory) {
520 strcpy(file, td->o.directory);
525 sprintf(file + elen, "%s", fname);
531 * We can't do this on FIO_DISKLESSIO engines. The engine isn't loaded
532 * yet, so we can't do this check right here...
534 if (lstat(dir, &sb) < 0) {
537 log_err("fio: %s is not a directory\n", dir);
538 td_verror(td, ret, "lstat");
542 if (!S_ISDIR(sb.st_mode)) {
543 log_err("fio: %s is not a directory\n", dir);
553 * Return next file in the string. Files are separated with ':'. If the ':'
554 * is escaped with a '\', then that ':' is part of the filename and does not
555 * indicate a new file.
557 static char *get_next_file_name(char **ptr)
562 if (!str || !strlen(str))
568 * No colon, we are done
570 p = strchr(str, ':');
577 * We got a colon, but it's the first character. Skip and
585 if (*(p - 1) != '\\') {
591 memmove(p - 1, p, strlen(p) + 1);
598 static int str_hostname_cb(void *data, const char *input)
600 struct thread_data *td = data;
602 td->o.filename = strdup(input);
606 static int str_filename_cb(void *data, const char *input)
608 struct thread_data *td = data;
609 char *fname, *str, *p;
611 p = str = strdup(input);
613 strip_blank_front(&str);
614 strip_blank_end(str);
616 if (!td->files_index)
619 while ((fname = get_next_file_name(&str)) != NULL) {
622 if (check_dir(td, fname)) {
634 static int str_directory_cb(void *data, const char fio_unused *str)
636 struct thread_data *td = data;
639 if (lstat(td->o.directory, &sb) < 0) {
642 log_err("fio: %s is not a directory\n", td->o.directory);
643 td_verror(td, ret, "lstat");
646 if (!S_ISDIR(sb.st_mode)) {
647 log_err("fio: %s is not a directory\n", td->o.directory);
654 static int str_opendir_cb(void *data, const char fio_unused *str)
656 struct thread_data *td = data;
658 if (!td->files_index)
661 return add_dir_files(td, td->o.opendir);
664 static int str_verify_offset_cb(void *data, unsigned long long *off)
666 struct thread_data *td = data;
668 if (*off && *off < sizeof(struct verify_header)) {
669 log_err("fio: verify_offset too small\n");
673 td->o.verify_offset = *off;
677 static int str_verify_pattern_cb(void *data, const char *input)
679 struct thread_data *td = data;
681 int i = 0, j = 0, len, k, base = 10;
684 loc1 = strstr(input, "0x");
685 loc2 = strstr(input, "0X");
688 off = strtol(input, NULL, base);
689 if (off != LONG_MAX || errno != ERANGE) {
691 td->o.verify_pattern[i] = off & 0xff;
700 j = loc1 - input + 2;
702 j = loc2 - input + 2;
705 if (len - j < MAX_PATTERN_SIZE * 2) {
707 off = converthexchartoint(input[k--]);
709 off += (converthexchartoint(input[k--])
711 td->o.verify_pattern[i++] = (char) off;
715 td->o.verify_pattern_bytes = i;
717 * VERIFY_META could already be set
719 if (td->o.verify == VERIFY_NONE)
720 td->o.verify = VERIFY_PATTERN;
724 static int str_lockfile_cb(void *data, const char *str)
726 struct thread_data *td = data;
727 char *nr = get_opt_postfix(str);
729 td->o.lockfile_batch = 1;
731 td->o.lockfile_batch = atoi(nr);
738 static int str_write_bw_log_cb(void *data, const char *str)
740 struct thread_data *td = data;
743 td->o.bw_log_file = strdup(str);
745 td->o.write_bw_log = 1;
749 static int str_write_lat_log_cb(void *data, const char *str)
751 struct thread_data *td = data;
754 td->o.lat_log_file = strdup(str);
756 td->o.write_lat_log = 1;
760 static int str_write_iops_log_cb(void *data, const char *str)
762 struct thread_data *td = data;
765 td->o.iops_log_file = strdup(str);
767 td->o.write_iops_log = 1;
771 static int str_gtod_reduce_cb(void *data, int *il)
773 struct thread_data *td = data;
776 td->o.disable_lat = !!val;
777 td->o.disable_clat = !!val;
778 td->o.disable_slat = !!val;
779 td->o.disable_bw = !!val;
780 td->o.clat_percentiles = !val;
782 td->tv_cache_mask = 63;
787 static int str_gtod_cpu_cb(void *data, long long *il)
789 struct thread_data *td = data;
792 td->o.gtod_cpu = val;
793 td->o.gtod_offload = 1;
797 static int str_size_cb(void *data, unsigned long long *__val)
799 struct thread_data *td = data;
800 unsigned long long v = *__val;
802 if (parse_is_percent(v)) {
804 td->o.size_percent = -1ULL - v;
811 static int rw_verify(struct fio_option *o, void *data)
813 struct thread_data *td = data;
815 if (read_only && td_write(td)) {
816 log_err("fio: job <%s> has write bit set, but fio is in"
817 " read-only mode\n", td->o.name);
824 static int gtod_cpu_verify(struct fio_option *o, void *data)
826 #ifndef FIO_HAVE_CPU_AFFINITY
827 struct thread_data *td = data;
829 if (td->o.gtod_cpu) {
830 log_err("fio: platform must support CPU affinity for"
831 "gettimeofday() offloading\n");
839 static int kb_base_verify(struct fio_option *o, void *data)
841 struct thread_data *td = data;
843 if (td->o.kb_base != 1024 && td->o.kb_base != 1000) {
844 log_err("fio: kb_base set to nonsensical value: %u\n",
853 * Map of job/command line options
855 static struct fio_option options[FIO_MAX_OPTS] = {
857 .name = "description",
858 .type = FIO_OPT_STR_STORE,
859 .off1 = td_var_offset(description),
860 .help = "Text job description",
864 .type = FIO_OPT_STR_STORE,
865 .off1 = td_var_offset(name),
866 .help = "Name of this job",
870 .type = FIO_OPT_STR_STORE,
871 .off1 = td_var_offset(directory),
872 .cb = str_directory_cb,
873 .help = "Directory to store files in",
877 .type = FIO_OPT_STR_STORE,
878 .off1 = td_var_offset(filename),
879 .cb = str_filename_cb,
880 .prio = -1, /* must come after "directory" */
881 .help = "File(s) to use for the workload",
885 .type = FIO_OPT_STR_STORE,
886 .cb = str_hostname_cb,
887 .help = "Hostname for net IO engine",
892 .off1 = td_var_offset(kb_base),
893 .verify = kb_base_verify,
896 .help = "How many bytes per KB for reporting (1000 or 1024)",
901 .cb = str_lockfile_cb,
902 .off1 = td_var_offset(file_lock_mode),
903 .help = "Lock file when doing IO to it",
904 .parent = "filename",
908 .oval = FILE_LOCK_NONE,
909 .help = "No file locking",
911 { .ival = "exclusive",
912 .oval = FILE_LOCK_EXCLUSIVE,
913 .help = "Exclusive file lock",
917 .oval = FILE_LOCK_READWRITE,
918 .help = "Read vs write lock",
924 .type = FIO_OPT_STR_STORE,
925 .off1 = td_var_offset(opendir),
926 .cb = str_opendir_cb,
927 .help = "Recursively add files from this directory and down",
931 .alias = "readwrite",
934 .off1 = td_var_offset(td_ddir),
935 .help = "IO direction",
940 .oval = TD_DDIR_READ,
941 .help = "Sequential read",
944 .oval = TD_DDIR_WRITE,
945 .help = "Sequential write",
947 { .ival = "randread",
948 .oval = TD_DDIR_RANDREAD,
949 .help = "Random read",
951 { .ival = "randwrite",
952 .oval = TD_DDIR_RANDWRITE,
953 .help = "Random write",
957 .help = "Sequential read and write mix",
960 .oval = TD_DDIR_RANDRW,
961 .help = "Random read and write mix"
966 .name = "rw_sequencer",
968 .off1 = td_var_offset(rw_seq),
969 .help = "IO offset generator modifier",
972 { .ival = "sequential",
974 .help = "Generate sequential offsets",
976 { .ival = "identical",
977 .oval = RW_SEQ_IDENT,
978 .help = "Generate identical offsets",
985 .type = FIO_OPT_STR_STORE,
986 .off1 = td_var_offset(ioengine),
987 .help = "IO engine to use",
988 .def = FIO_PREFERRED_ENGINE,
991 .help = "Use read/write",
994 .help = "Use pread/pwrite",
997 .help = "Use readv/writev",
999 #ifdef FIO_HAVE_LIBAIO
1001 .help = "Linux native asynchronous IO",
1002 .cb = str_libaio_cb,
1005 #ifdef FIO_HAVE_POSIXAIO
1006 { .ival = "posixaio",
1007 .help = "POSIX asynchronous IO",
1010 #ifdef FIO_HAVE_SOLARISAIO
1011 { .ival = "solarisaio",
1012 .help = "Solaris native asynchronous IO",
1015 #ifdef FIO_HAVE_WINDOWSAIO
1016 { .ival = "windowsaio",
1017 .help = "Windows native asynchronous IO"
1021 .help = "Memory mapped IO"
1023 #ifdef FIO_HAVE_SPLICE
1025 .help = "splice/vmsplice based IO",
1027 { .ival = "netsplice",
1028 .help = "splice/vmsplice to/from the network",
1031 #ifdef FIO_HAVE_SGIO
1033 .help = "SCSI generic v3 IO",
1037 .help = "Testing engine (no data transfer)",
1040 .help = "Network IO",
1042 #ifdef FIO_HAVE_SYSLET
1043 { .ival = "syslet-rw",
1044 .help = "syslet enabled async pread/pwrite IO",
1048 .help = "CPU cycle burner engine",
1050 #ifdef FIO_HAVE_GUASI
1052 .help = "GUASI IO engine",
1055 #ifdef FIO_HAVE_BINJECT
1056 { .ival = "binject",
1057 .help = "binject direct inject block engine",
1060 #ifdef FIO_HAVE_RDMA
1062 .help = "RDMA IO engine",
1065 { .ival = "external",
1066 .help = "Load external engine (append name)",
1072 .type = FIO_OPT_INT,
1073 .off1 = td_var_offset(iodepth),
1074 .help = "Number of IO buffers to keep in flight",
1079 .name = "iodepth_batch",
1080 .alias = "iodepth_batch_submit",
1081 .type = FIO_OPT_INT,
1082 .off1 = td_var_offset(iodepth_batch),
1083 .help = "Number of IO buffers to submit in one go",
1084 .parent = "iodepth",
1089 .name = "iodepth_batch_complete",
1090 .type = FIO_OPT_INT,
1091 .off1 = td_var_offset(iodepth_batch_complete),
1092 .help = "Number of IO buffers to retrieve in one go",
1093 .parent = "iodepth",
1098 .name = "iodepth_low",
1099 .type = FIO_OPT_INT,
1100 .off1 = td_var_offset(iodepth_low),
1101 .help = "Low water mark for queuing depth",
1102 .parent = "iodepth",
1106 .type = FIO_OPT_STR_VAL,
1108 .help = "Total size of device or files",
1111 .name = "fill_device",
1113 .type = FIO_OPT_BOOL,
1114 .off1 = td_var_offset(fill_device),
1115 .help = "Write until an ENOSPC error occurs",
1120 .type = FIO_OPT_STR_VAL,
1121 .off1 = td_var_offset(file_size_low),
1122 .off2 = td_var_offset(file_size_high),
1124 .help = "Size of individual files",
1128 .alias = "fileoffset",
1129 .type = FIO_OPT_STR_VAL,
1130 .off1 = td_var_offset(start_offset),
1131 .help = "Start IO from this offset",
1136 .alias = "blocksize",
1137 .type = FIO_OPT_INT,
1138 .off1 = td_var_offset(bs[DDIR_READ]),
1139 .off2 = td_var_offset(bs[DDIR_WRITE]),
1141 .help = "Block size unit",
1147 .alias = "blockalign",
1148 .type = FIO_OPT_INT,
1149 .off1 = td_var_offset(ba[DDIR_READ]),
1150 .off2 = td_var_offset(ba[DDIR_WRITE]),
1152 .help = "IO block offset alignment",
1157 .alias = "blocksize_range",
1158 .type = FIO_OPT_RANGE,
1159 .off1 = td_var_offset(min_bs[DDIR_READ]),
1160 .off2 = td_var_offset(max_bs[DDIR_READ]),
1161 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
1162 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
1164 .help = "Set block size range (in more detail than bs)",
1169 .type = FIO_OPT_STR,
1170 .cb = str_bssplit_cb,
1171 .help = "Set a specific mix of block sizes",
1175 .name = "bs_unaligned",
1176 .alias = "blocksize_unaligned",
1177 .type = FIO_OPT_STR_SET,
1178 .off1 = td_var_offset(bs_unaligned),
1179 .help = "Don't sector align IO buffer sizes",
1183 .name = "randrepeat",
1184 .type = FIO_OPT_BOOL,
1185 .off1 = td_var_offset(rand_repeatable),
1186 .help = "Use repeatable random IO pattern",
1191 .name = "use_os_rand",
1192 .type = FIO_OPT_BOOL,
1193 .off1 = td_var_offset(use_os_rand),
1194 .help = "Set to use OS random generator",
1199 .name = "norandommap",
1200 .type = FIO_OPT_STR_SET,
1201 .off1 = td_var_offset(norandommap),
1202 .help = "Accept potential duplicate random blocks",
1206 .name = "softrandommap",
1207 .type = FIO_OPT_BOOL,
1208 .off1 = td_var_offset(softrandommap),
1209 .help = "Set norandommap if randommap allocation fails",
1210 .parent = "norandommap",
1215 .alias = "nr_files",
1216 .type = FIO_OPT_INT,
1217 .off1 = td_var_offset(nr_files),
1218 .help = "Split job workload between this number of files",
1222 .name = "openfiles",
1223 .type = FIO_OPT_INT,
1224 .off1 = td_var_offset(open_files),
1225 .help = "Number of files to keep open at the same time",
1228 .name = "file_service_type",
1229 .type = FIO_OPT_STR,
1231 .off1 = td_var_offset(file_service_type),
1232 .help = "How to select which file to service next",
1233 .def = "roundrobin",
1236 .oval = FIO_FSERVICE_RANDOM,
1237 .help = "Choose a file at random",
1239 { .ival = "roundrobin",
1240 .oval = FIO_FSERVICE_RR,
1241 .help = "Round robin select files",
1243 { .ival = "sequential",
1244 .oval = FIO_FSERVICE_SEQ,
1245 .help = "Finish one file before moving to the next",
1248 .parent = "nrfiles",
1250 #ifdef FIO_HAVE_FALLOCATE
1252 .name = "fallocate",
1253 .type = FIO_OPT_STR,
1254 .off1 = td_var_offset(fallocate_mode),
1255 .help = "Whether pre-allocation is performed when laying out files",
1259 .oval = FIO_FALLOCATE_NONE,
1260 .help = "Do not pre-allocate space",
1263 .oval = FIO_FALLOCATE_POSIX,
1264 .help = "Use posix_fallocate()",
1266 #ifdef FIO_HAVE_LINUX_FALLOCATE
1268 .oval = FIO_FALLOCATE_KEEP_SIZE,
1269 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
1272 /* Compatibility with former boolean values */
1274 .oval = FIO_FALLOCATE_NONE,
1275 .help = "Alias for 'none'",
1278 .oval = FIO_FALLOCATE_POSIX,
1279 .help = "Alias for 'posix'",
1283 #endif /* FIO_HAVE_FALLOCATE */
1285 .name = "fadvise_hint",
1286 .type = FIO_OPT_BOOL,
1287 .off1 = td_var_offset(fadvise_hint),
1288 .help = "Use fadvise() to advise the kernel on IO pattern",
1293 .type = FIO_OPT_INT,
1294 .off1 = td_var_offset(fsync_blocks),
1295 .help = "Issue fsync for writes every given number of blocks",
1299 .name = "fdatasync",
1300 .type = FIO_OPT_INT,
1301 .off1 = td_var_offset(fdatasync_blocks),
1302 .help = "Issue fdatasync for writes every given number of blocks",
1306 .name = "write_barrier",
1307 .type = FIO_OPT_INT,
1308 .off1 = td_var_offset(barrier_blocks),
1309 .help = "Make every Nth write a barrier write",
1312 #ifdef FIO_HAVE_SYNC_FILE_RANGE
1314 .name = "sync_file_range",
1316 { .ival = "wait_before",
1317 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
1318 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
1322 .oval = SYNC_FILE_RANGE_WRITE,
1323 .help = "SYNC_FILE_RANGE_WRITE",
1327 .ival = "wait_after",
1328 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
1329 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
1333 .type = FIO_OPT_STR_MULTI,
1335 .off1 = td_var_offset(sync_file_range),
1336 .help = "Use sync_file_range()",
1341 .type = FIO_OPT_BOOL,
1342 .off1 = td_var_offset(odirect),
1343 .help = "Use O_DIRECT IO (negates buffered)",
1348 .type = FIO_OPT_BOOL,
1349 .off1 = td_var_offset(odirect),
1351 .help = "Use buffered IO (negates direct)",
1355 .name = "overwrite",
1356 .type = FIO_OPT_BOOL,
1357 .off1 = td_var_offset(overwrite),
1358 .help = "When writing, set whether to overwrite current data",
1363 .type = FIO_OPT_INT,
1364 .off1 = td_var_offset(loops),
1365 .help = "Number of times to run the job",
1370 .type = FIO_OPT_INT,
1371 .off1 = td_var_offset(numjobs),
1372 .help = "Duplicate this job this many times",
1376 .name = "startdelay",
1377 .type = FIO_OPT_STR_VAL_TIME,
1378 .off1 = td_var_offset(start_delay),
1379 .help = "Only start job when this period has passed",
1385 .type = FIO_OPT_STR_VAL_TIME,
1386 .off1 = td_var_offset(timeout),
1387 .help = "Stop workload when this amount of time has passed",
1391 .name = "time_based",
1392 .type = FIO_OPT_STR_SET,
1393 .off1 = td_var_offset(time_based),
1394 .help = "Keep running until runtime/timeout is met",
1397 .name = "ramp_time",
1398 .type = FIO_OPT_STR_VAL_TIME,
1399 .off1 = td_var_offset(ramp_time),
1400 .help = "Ramp up time before measuring performance",
1403 .name = "clocksource",
1404 .type = FIO_OPT_STR,
1405 .cb = fio_clock_source_cb,
1406 .off1 = td_var_offset(clocksource),
1407 .help = "What type of timing source to use",
1409 { .ival = "gettimeofday",
1411 .help = "Use gettimeofday(2) for timing",
1413 { .ival = "clock_gettime",
1414 .oval = CS_CGETTIME,
1415 .help = "Use clock_gettime(2) for timing",
1417 #ifdef ARCH_HAVE_CPU_CLOCK
1419 .oval = CS_CPUCLOCK,
1420 .help = "Use CPU private clock",
1428 .type = FIO_OPT_STR,
1430 .off1 = td_var_offset(mem_type),
1431 .help = "Backing type for IO buffers",
1436 .help = "Use malloc(3) for IO buffers",
1440 .help = "Use shared memory segments for IO buffers",
1442 #ifdef FIO_HAVE_HUGETLB
1443 { .ival = "shmhuge",
1444 .oval = MEM_SHMHUGE,
1445 .help = "Like shm, but use huge pages",
1450 .help = "Use mmap(2) (file or anon) for IO buffers",
1452 #ifdef FIO_HAVE_HUGETLB
1453 { .ival = "mmaphuge",
1454 .oval = MEM_MMAPHUGE,
1455 .help = "Like mmap, but use huge pages",
1461 .name = "iomem_align",
1462 .alias = "mem_align",
1463 .type = FIO_OPT_INT,
1464 .off1 = td_var_offset(mem_align),
1466 .help = "IO memory buffer offset alignment",
1472 .type = FIO_OPT_STR,
1473 .off1 = td_var_offset(verify),
1474 .help = "Verify data written",
1475 .cb = str_verify_cb,
1479 .oval = VERIFY_NONE,
1480 .help = "Don't do IO verification",
1484 .help = "Use md5 checksums for verification",
1487 .oval = VERIFY_CRC64,
1488 .help = "Use crc64 checksums for verification",
1491 .oval = VERIFY_CRC32,
1492 .help = "Use crc32 checksums for verification",
1494 { .ival = "crc32c-intel",
1495 .oval = VERIFY_CRC32C_INTEL,
1496 .help = "Use hw crc32c checksums for verification",
1499 .oval = VERIFY_CRC32C,
1500 .help = "Use crc32c checksums for verification",
1503 .oval = VERIFY_CRC16,
1504 .help = "Use crc16 checksums for verification",
1507 .oval = VERIFY_CRC7,
1508 .help = "Use crc7 checksums for verification",
1511 .oval = VERIFY_SHA1,
1512 .help = "Use sha1 checksums for verification",
1515 .oval = VERIFY_SHA256,
1516 .help = "Use sha256 checksums for verification",
1519 .oval = VERIFY_SHA512,
1520 .help = "Use sha512 checksums for verification",
1523 .oval = VERIFY_META,
1524 .help = "Use io information",
1528 .oval = VERIFY_NULL,
1529 .help = "Pretend to verify",
1534 .name = "do_verify",
1535 .type = FIO_OPT_BOOL,
1536 .off1 = td_var_offset(do_verify),
1537 .help = "Run verification stage after write",
1542 .name = "verifysort",
1543 .type = FIO_OPT_BOOL,
1544 .off1 = td_var_offset(verifysort),
1545 .help = "Sort written verify blocks for read back",
1550 .name = "verify_interval",
1551 .type = FIO_OPT_INT,
1552 .off1 = td_var_offset(verify_interval),
1553 .minval = 2 * sizeof(struct verify_header),
1554 .help = "Store verify buffer header every N bytes",
1558 .name = "verify_offset",
1559 .type = FIO_OPT_INT,
1560 .help = "Offset verify header location by N bytes",
1562 .cb = str_verify_offset_cb,
1566 .name = "verify_pattern",
1567 .type = FIO_OPT_STR,
1568 .cb = str_verify_pattern_cb,
1569 .help = "Fill pattern for IO buffers",
1573 .name = "verify_fatal",
1574 .type = FIO_OPT_BOOL,
1575 .off1 = td_var_offset(verify_fatal),
1577 .help = "Exit on a single verify failure, don't continue",
1581 .name = "verify_dump",
1582 .type = FIO_OPT_BOOL,
1583 .off1 = td_var_offset(verify_dump),
1585 .help = "Dump contents of good and bad blocks on failure",
1589 .name = "verify_async",
1590 .type = FIO_OPT_INT,
1591 .off1 = td_var_offset(verify_async),
1593 .help = "Number of async verifier threads to use",
1597 .name = "verify_backlog",
1598 .type = FIO_OPT_STR_VAL,
1599 .off1 = td_var_offset(verify_backlog),
1600 .help = "Verify after this number of blocks are written",
1604 .name = "verify_backlog_batch",
1605 .type = FIO_OPT_INT,
1606 .off1 = td_var_offset(verify_batch),
1607 .help = "Verify this number of IO blocks",
1610 #ifdef FIO_HAVE_CPU_AFFINITY
1612 .name = "verify_async_cpus",
1613 .type = FIO_OPT_STR,
1614 .cb = str_verify_cpus_allowed_cb,
1615 .help = "Set CPUs allowed for async verify threads",
1616 .parent = "verify_async",
1619 #ifdef FIO_HAVE_TRIM
1621 .name = "trim_percentage",
1622 .type = FIO_OPT_INT,
1623 .cb = str_verify_trim_cb,
1625 .help = "Number of verify blocks to discard/trim",
1630 .name = "trim_verify_zero",
1631 .type = FIO_OPT_INT,
1632 .help = "Verify that trim/discarded blocks are returned as zeroes",
1633 .off1 = td_var_offset(trim_zero),
1634 .parent = "trim_percentage",
1638 .name = "trim_backlog",
1639 .type = FIO_OPT_STR_VAL,
1640 .off1 = td_var_offset(trim_backlog),
1641 .help = "Trim after this number of blocks are written",
1642 .parent = "trim_percentage",
1645 .name = "trim_backlog_batch",
1646 .type = FIO_OPT_INT,
1647 .off1 = td_var_offset(trim_batch),
1648 .help = "Trim this number of IO blocks",
1649 .parent = "trim_percentage",
1653 .name = "write_iolog",
1654 .type = FIO_OPT_STR_STORE,
1655 .off1 = td_var_offset(write_iolog_file),
1656 .help = "Store IO pattern to file",
1659 .name = "read_iolog",
1660 .type = FIO_OPT_STR_STORE,
1661 .off1 = td_var_offset(read_iolog_file),
1662 .help = "Playback IO pattern from file",
1665 .name = "replay_no_stall",
1666 .type = FIO_OPT_INT,
1667 .off1 = td_var_offset(no_stall),
1669 .parent = "read_iolog",
1670 .help = "Playback IO pattern file as fast as possible without stalls",
1673 .name = "replay_redirect",
1674 .type = FIO_OPT_STR_STORE,
1675 .off1 = td_var_offset(replay_redirect),
1676 .parent = "read_iolog",
1677 .help = "Replay all I/O onto this device, regardless of trace device",
1680 .name = "exec_prerun",
1681 .type = FIO_OPT_STR_STORE,
1682 .off1 = td_var_offset(exec_prerun),
1683 .help = "Execute this file prior to running job",
1686 .name = "exec_postrun",
1687 .type = FIO_OPT_STR_STORE,
1688 .off1 = td_var_offset(exec_postrun),
1689 .help = "Execute this file after running job",
1691 #ifdef FIO_HAVE_IOSCHED_SWITCH
1693 .name = "ioscheduler",
1694 .type = FIO_OPT_STR_STORE,
1695 .off1 = td_var_offset(ioscheduler),
1696 .help = "Use this IO scheduler on the backing device",
1701 .type = FIO_OPT_STR_VAL,
1702 .off1 = td_var_offset(zone_size),
1703 .help = "Give size of an IO zone",
1708 .type = FIO_OPT_STR_VAL,
1709 .off1 = td_var_offset(zone_skip),
1710 .help = "Space between IO zones",
1715 .type = FIO_OPT_STR_VAL,
1716 .cb = str_lockmem_cb,
1717 .help = "Lock down this amount of memory",
1721 .name = "rwmixread",
1722 .type = FIO_OPT_INT,
1723 .cb = str_rwmix_read_cb,
1725 .help = "Percentage of mixed workload that is reads",
1729 .name = "rwmixwrite",
1730 .type = FIO_OPT_INT,
1731 .cb = str_rwmix_write_cb,
1733 .help = "Percentage of mixed workload that is writes",
1737 .name = "rwmixcycle",
1738 .type = FIO_OPT_DEPRECATED,
1742 .type = FIO_OPT_INT,
1743 .off1 = td_var_offset(nice),
1744 .help = "Set job CPU nice value",
1749 #ifdef FIO_HAVE_IOPRIO
1752 .type = FIO_OPT_INT,
1754 .help = "Set job IO priority value",
1759 .name = "prioclass",
1760 .type = FIO_OPT_INT,
1761 .cb = str_prioclass_cb,
1762 .help = "Set job IO priority class",
1768 .name = "thinktime",
1769 .type = FIO_OPT_INT,
1770 .off1 = td_var_offset(thinktime),
1771 .help = "Idle time between IO buffers (usec)",
1775 .name = "thinktime_spin",
1776 .type = FIO_OPT_INT,
1777 .off1 = td_var_offset(thinktime_spin),
1778 .help = "Start think time by spinning this amount (usec)",
1780 .parent = "thinktime",
1783 .name = "thinktime_blocks",
1784 .type = FIO_OPT_INT,
1785 .off1 = td_var_offset(thinktime_blocks),
1786 .help = "IO buffer period between 'thinktime'",
1788 .parent = "thinktime",
1792 .type = FIO_OPT_INT,
1793 .off1 = td_var_offset(rate[0]),
1794 .off2 = td_var_offset(rate[1]),
1795 .help = "Set bandwidth rate",
1799 .type = FIO_OPT_INT,
1800 .off1 = td_var_offset(ratemin[0]),
1801 .off2 = td_var_offset(ratemin[1]),
1802 .help = "Job must meet this rate or it will be shutdown",
1806 .name = "rate_iops",
1807 .type = FIO_OPT_INT,
1808 .off1 = td_var_offset(rate_iops[0]),
1809 .off2 = td_var_offset(rate_iops[1]),
1810 .help = "Limit IO used to this number of IO operations/sec",
1813 .name = "rate_iops_min",
1814 .type = FIO_OPT_INT,
1815 .off1 = td_var_offset(rate_iops_min[0]),
1816 .off2 = td_var_offset(rate_iops_min[1]),
1817 .help = "Job must meet this rate or it will be shut down",
1818 .parent = "rate_iops",
1821 .name = "ratecycle",
1822 .type = FIO_OPT_INT,
1823 .off1 = td_var_offset(ratecycle),
1824 .help = "Window average for rate limits (msec)",
1829 .name = "invalidate",
1830 .type = FIO_OPT_BOOL,
1831 .off1 = td_var_offset(invalidate_cache),
1832 .help = "Invalidate buffer/page cache prior to running job",
1837 .type = FIO_OPT_BOOL,
1838 .off1 = td_var_offset(sync_io),
1839 .help = "Use O_SYNC for buffered writes",
1841 .parent = "buffered",
1844 .name = "bwavgtime",
1845 .type = FIO_OPT_INT,
1846 .off1 = td_var_offset(bw_avg_time),
1847 .help = "Time window over which to calculate bandwidth"
1850 .parent = "write_bw_log",
1853 .name = "iopsavgtime",
1854 .type = FIO_OPT_INT,
1855 .off1 = td_var_offset(iops_avg_time),
1856 .help = "Time window over which to calculate IOPS (msec)",
1858 .parent = "write_iops_log",
1861 .name = "create_serialize",
1862 .type = FIO_OPT_BOOL,
1863 .off1 = td_var_offset(create_serialize),
1864 .help = "Serialize creating of job files",
1868 .name = "create_fsync",
1869 .type = FIO_OPT_BOOL,
1870 .off1 = td_var_offset(create_fsync),
1871 .help = "fsync file after creation",
1875 .name = "create_on_open",
1876 .type = FIO_OPT_BOOL,
1877 .off1 = td_var_offset(create_on_open),
1878 .help = "Create files when they are opened for IO",
1883 .type = FIO_OPT_BOOL,
1884 .off1 = td_var_offset(pre_read),
1885 .help = "Pre-read files before starting official testing",
1890 .type = FIO_OPT_INT,
1891 .off1 = td_var_offset(cpuload),
1892 .help = "Use this percentage of CPU",
1895 .name = "cpuchunks",
1896 .type = FIO_OPT_INT,
1897 .off1 = td_var_offset(cpucycle),
1898 .help = "Length of the CPU burn cycles (usecs)",
1900 .parent = "cpuload",
1902 #ifdef FIO_HAVE_CPU_AFFINITY
1905 .type = FIO_OPT_INT,
1906 .cb = str_cpumask_cb,
1907 .help = "CPU affinity mask",
1910 .name = "cpus_allowed",
1911 .type = FIO_OPT_STR,
1912 .cb = str_cpus_allowed_cb,
1913 .help = "Set CPUs allowed",
1917 .name = "end_fsync",
1918 .type = FIO_OPT_BOOL,
1919 .off1 = td_var_offset(end_fsync),
1920 .help = "Include fsync at the end of job",
1924 .name = "fsync_on_close",
1925 .type = FIO_OPT_BOOL,
1926 .off1 = td_var_offset(fsync_on_close),
1927 .help = "fsync files on close",
1932 .type = FIO_OPT_BOOL,
1933 .off1 = td_var_offset(unlink),
1934 .help = "Unlink created files after job has completed",
1939 .type = FIO_OPT_STR_SET,
1940 .cb = str_exitall_cb,
1941 .help = "Terminate all jobs when one exits",
1944 .name = "stonewall",
1945 .alias = "wait_for_previous",
1946 .type = FIO_OPT_STR_SET,
1947 .off1 = td_var_offset(stonewall),
1948 .help = "Insert a hard barrier between this job and previous",
1951 .name = "new_group",
1952 .type = FIO_OPT_STR_SET,
1953 .off1 = td_var_offset(new_group),
1954 .help = "Mark the start of a new group (for reporting)",
1958 .type = FIO_OPT_STR_SET,
1959 .off1 = td_var_offset(use_thread),
1960 .help = "Use threads instead of forks",
1963 .name = "write_bw_log",
1964 .type = FIO_OPT_STR,
1965 .off1 = td_var_offset(write_bw_log),
1966 .cb = str_write_bw_log_cb,
1967 .help = "Write log of bandwidth during run",
1970 .name = "write_lat_log",
1971 .type = FIO_OPT_STR,
1972 .off1 = td_var_offset(write_lat_log),
1973 .cb = str_write_lat_log_cb,
1974 .help = "Write log of latency during run",
1977 .name = "write_iops_log",
1978 .type = FIO_OPT_STR,
1979 .off1 = td_var_offset(write_iops_log),
1980 .cb = str_write_iops_log_cb,
1981 .help = "Write log of IOPS during run",
1984 .name = "hugepage-size",
1985 .type = FIO_OPT_INT,
1986 .off1 = td_var_offset(hugepage_size),
1987 .help = "When using hugepages, specify size of each page",
1988 .def = __fio_stringify(FIO_HUGE_PAGE),
1991 .name = "group_reporting",
1992 .type = FIO_OPT_STR_SET,
1993 .off1 = td_var_offset(group_reporting),
1994 .help = "Do reporting on a per-group basis",
1997 .name = "zero_buffers",
1998 .type = FIO_OPT_STR_SET,
1999 .off1 = td_var_offset(zero_buffers),
2000 .help = "Init IO buffers to all zeroes",
2003 .name = "refill_buffers",
2004 .type = FIO_OPT_STR_SET,
2005 .off1 = td_var_offset(refill_buffers),
2006 .help = "Refill IO buffers on every IO submit",
2009 .name = "scramble_buffers",
2010 .type = FIO_OPT_BOOL,
2011 .off1 = td_var_offset(scramble_buffers),
2012 .help = "Slightly scramble buffers on every IO submit",
2016 .name = "clat_percentiles",
2017 .type = FIO_OPT_BOOL,
2018 .off1 = td_var_offset(clat_percentiles),
2019 .help = "Enable the reporting of completion latency percentiles",
2023 .name = "percentile_list",
2024 .type = FIO_OPT_FLOAT_LIST,
2025 .off1 = td_var_offset(percentile_list),
2026 .off2 = td_var_offset(overwrite_plist),
2027 .help = "Specify a custom list of percentiles to report",
2028 .maxlen = FIO_IO_U_LIST_MAX_LEN,
2033 #ifdef FIO_HAVE_DISK_UTIL
2035 .name = "disk_util",
2036 .type = FIO_OPT_BOOL,
2037 .off1 = td_var_offset(do_disk_util),
2038 .help = "Log disk utilization statistics",
2043 .name = "gtod_reduce",
2044 .type = FIO_OPT_BOOL,
2045 .help = "Greatly reduce number of gettimeofday() calls",
2046 .cb = str_gtod_reduce_cb,
2050 .name = "disable_lat",
2051 .type = FIO_OPT_BOOL,
2052 .off1 = td_var_offset(disable_lat),
2053 .help = "Disable latency numbers",
2054 .parent = "gtod_reduce",
2058 .name = "disable_clat",
2059 .type = FIO_OPT_BOOL,
2060 .off1 = td_var_offset(disable_clat),
2061 .help = "Disable completion latency numbers",
2062 .parent = "gtod_reduce",
2066 .name = "disable_slat",
2067 .type = FIO_OPT_BOOL,
2068 .off1 = td_var_offset(disable_slat),
2069 .help = "Disable submission latency numbers",
2070 .parent = "gtod_reduce",
2074 .name = "disable_bw_measurement",
2075 .type = FIO_OPT_BOOL,
2076 .off1 = td_var_offset(disable_bw),
2077 .help = "Disable bandwidth logging",
2078 .parent = "gtod_reduce",
2083 .type = FIO_OPT_INT,
2084 .cb = str_gtod_cpu_cb,
2085 .help = "Set up dedicated gettimeofday() thread on this CPU",
2086 .verify = gtod_cpu_verify,
2089 .name = "continue_on_error",
2090 .type = FIO_OPT_BOOL,
2091 .off1 = td_var_offset(continue_on_error),
2092 .help = "Continue on non-fatal errors during IO",
2097 .type = FIO_OPT_STR_STORE,
2098 .off1 = td_var_offset(profile),
2099 .help = "Select a specific builtin performance test",
2103 .type = FIO_OPT_STR_STORE,
2104 .off1 = td_var_offset(cgroup),
2105 .help = "Add job to cgroup of this name",
2108 .name = "cgroup_weight",
2109 .type = FIO_OPT_INT,
2110 .off1 = td_var_offset(cgroup_weight),
2111 .help = "Use given weight for cgroup",
2116 .name = "cgroup_nodelete",
2117 .type = FIO_OPT_BOOL,
2118 .off1 = td_var_offset(cgroup_nodelete),
2119 .help = "Do not delete cgroups after job completion",
2124 .type = FIO_OPT_INT,
2125 .off1 = td_var_offset(uid),
2126 .help = "Run job with this user ID",
2130 .type = FIO_OPT_INT,
2131 .off1 = td_var_offset(gid),
2132 .help = "Run job with this group ID",
2139 static void add_to_lopt(struct option *lopt, struct fio_option *o,
2142 lopt->name = (char *) name;
2143 lopt->val = FIO_GETOPT_JOB;
2144 if (o->type == FIO_OPT_STR_SET)
2145 lopt->has_arg = no_argument;
2147 lopt->has_arg = required_argument;
2150 void fio_options_dup_and_init(struct option *long_options)
2152 struct fio_option *o;
2155 options_init(options);
2158 while (long_options[i].name)
2163 add_to_lopt(&long_options[i], o, o->name);
2166 add_to_lopt(&long_options[i], o, o->alias);
2171 assert(i < FIO_NR_OPTIONS);
2175 struct fio_keyword {
2181 static struct fio_keyword fio_keywords[] = {
2183 .word = "$pagesize",
2184 .desc = "Page size in the system",
2187 .word = "$mb_memory",
2188 .desc = "Megabytes of memory online",
2192 .desc = "Number of CPUs online in the system",
2199 void fio_keywords_init(void)
2201 unsigned long long mb_memory;
2205 sprintf(buf, "%lu", page_size);
2206 fio_keywords[0].replace = strdup(buf);
2208 mb_memory = os_phys_mem() / (1024 * 1024);
2209 sprintf(buf, "%llu", mb_memory);
2210 fio_keywords[1].replace = strdup(buf);
2213 sprintf(buf, "%lu", l);
2214 fio_keywords[2].replace = strdup(buf);
2219 static char *bc_calc(char *str)
2221 char *buf, *tmp, opt[80];
2226 * No math, just return string
2228 if (!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
2233 * Split option from value, we only need to calculate the value
2235 tmp = strchr(str, '=');
2240 memset(opt, 0, sizeof(opt));
2241 strncpy(opt, str, tmp - str);
2245 sprintf(buf, "which %s > /dev/null", BC_APP);
2247 log_err("fio: bc is needed for performing math\n");
2252 sprintf(buf, "echo %s | %s", tmp, BC_APP);
2253 f = popen(buf, "r");
2259 ret = fread(buf, 1, 128, f);
2265 buf[ret - 1] = '\0';
2274 * Look for reserved variable names and replace them with real values
2276 static char *fio_keyword_replace(char *opt)
2281 for (i = 0; fio_keywords[i].word != NULL; i++) {
2282 struct fio_keyword *kw = &fio_keywords[i];
2284 while ((s = strstr(opt, kw->word)) != NULL) {
2285 char *new = malloc(strlen(opt) + 1);
2291 * Copy part of the string before the keyword and
2292 * sprintf() the replacement after it.
2294 memcpy(new, opt, olen);
2295 len = sprintf(new + olen, "%s", kw->replace);
2298 * If there's more in the original string, copy that
2301 opt += strlen(kw->word) + olen;
2303 memcpy(new + olen + len, opt, opt - o_org - 1);
2306 * replace opt and free the old opt
2312 * Check for potential math and invoke bc, if possible
2321 int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
2325 sort_options(opts, options, num_opts);
2327 for (ret = 0, i = 0; i < num_opts; i++) {
2328 opts[i] = fio_keyword_replace(opts[i]);
2329 ret |= parse_option(opts[i], options, td);
2335 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
2337 return parse_cmd_option(opt, val, options, td);
2340 void fio_fill_default_options(struct thread_data *td)
2342 fill_default_options(td, options);
2345 int fio_show_option_help(const char *opt)
2347 return show_cmd_help(options, opt);
2351 * dupe FIO_OPT_STR_STORE options
2353 void options_mem_dupe(struct thread_data *td)
2355 struct thread_options *o = &td->o;
2356 struct fio_option *opt;
2360 for (i = 0, opt = &options[0]; opt->name; i++, opt = &options[i]) {
2361 if (opt->type != FIO_OPT_STR_STORE)
2364 ptr = (void *) o + opt->off1;
2366 ptr = td_var(o, opt->off1);
2368 *ptr = strdup(*ptr);
2372 unsigned int fio_get_kb_base(void *data)
2374 struct thread_data *td = data;
2375 unsigned int kb_base = 0;
2378 kb_base = td->o.kb_base;
2385 int add_option(struct fio_option *o)
2387 struct fio_option *__o;
2396 memcpy(&options[opt_index], o, sizeof(*o));
2400 void invalidate_profile_options(const char *prof_name)
2402 struct fio_option *o;
2406 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
2407 o->type = FIO_OPT_INVALID;
2408 o->prof_name = NULL;
2414 void add_opt_posval(const char *optname, const char *ival, const char *help)
2416 struct fio_option *o;
2419 o = find_option(options, optname);
2423 for (i = 0; i < PARSE_MAX_VP; i++) {
2424 if (o->posval[i].ival)
2427 o->posval[i].ival = ival;
2428 o->posval[i].help = help;
2433 void del_opt_posval(const char *optname, const char *ival)
2435 struct fio_option *o;
2438 o = find_option(options, optname);
2442 for (i = 0; i < PARSE_MAX_VP; i++) {
2443 if (!o->posval[i].ival)
2445 if (strcmp(o->posval[i].ival, ival))
2448 o->posval[i].ival = NULL;
2449 o->posval[i].help = NULL;
2453 void fio_options_free(struct thread_data *td)
2455 options_free(options, td);