10 #include <sys/types.h>
17 #define td_var_offset(var) ((size_t) &((struct thread_options *)0)->var)
20 * Check if mmap/mmaphuge has a :/foo/bar/file at the end. If so, return that.
22 static char *get_opt_postfix(const char *str)
24 char *p = strstr(str, ":");
30 strip_blank_front(&p);
35 static int bs_cmp(const void *p1, const void *p2)
37 const struct bssplit *bsp1 = p1;
38 const struct bssplit *bsp2 = p2;
40 return bsp1->perc < bsp2->perc;
43 static int bssplit_ddir(struct thread_data *td, int ddir, char *str)
45 struct bssplit *bssplit;
46 unsigned int i, perc, perc_missing;
47 unsigned int max_bs, min_bs;
51 td->o.bssplit_nr[ddir] = 4;
52 bssplit = malloc(4 * sizeof(struct bssplit));
57 while ((fname = strsep(&str, ":")) != NULL) {
64 * grow struct buffer, if needed
66 if (i == td->o.bssplit_nr[ddir]) {
67 td->o.bssplit_nr[ddir] <<= 1;
68 bssplit = realloc(bssplit, td->o.bssplit_nr[ddir]
69 * sizeof(struct bssplit));
72 perc_str = strstr(fname, "/");
76 perc = atoi(perc_str);
84 if (str_to_decimal(fname, &val, 1)) {
85 log_err("fio: bssplit conversion failed\n");
96 bssplit[i].perc = perc;
100 td->o.bssplit_nr[ddir] = i;
103 * Now check if the percentages add up, and how much is missing
105 perc = perc_missing = 0;
106 for (i = 0; i < td->o.bssplit_nr[ddir]; i++) {
107 struct bssplit *bsp = &bssplit[i];
109 if (bsp->perc == (unsigned char) -1)
116 log_err("fio: bssplit percentages add to more than 100%%\n");
121 * If values didn't have a percentage set, divide the remains between
125 for (i = 0; i < td->o.bssplit_nr[ddir]; i++) {
126 struct bssplit *bsp = &bssplit[i];
128 if (bsp->perc == (unsigned char) -1)
129 bsp->perc = (100 - perc) / perc_missing;
133 td->o.min_bs[ddir] = min_bs;
134 td->o.max_bs[ddir] = max_bs;
137 * now sort based on percentages, for ease of lookup
139 qsort(bssplit, td->o.bssplit_nr[ddir], sizeof(struct bssplit), bs_cmp);
140 td->o.bssplit[ddir] = bssplit;
145 static int str_bssplit_cb(void *data, const char *input)
147 struct thread_data *td = data;
148 char *str, *p, *odir;
151 p = str = strdup(input);
153 strip_blank_front(&str);
154 strip_blank_end(str);
156 odir = strchr(str, ',');
158 ret = bssplit_ddir(td, DDIR_WRITE, odir + 1);
161 ret = bssplit_ddir(td, DDIR_READ, str);
168 ret = bssplit_ddir(td, DDIR_READ, str);
170 ret = bssplit_ddir(td, DDIR_WRITE, op);
179 static int str_rw_cb(void *data, const char *str)
181 struct thread_data *td = data;
182 char *nr = get_opt_postfix(str);
186 td->o.ddir_nr = atoi(nr);
193 static int str_mem_cb(void *data, const char *mem)
195 struct thread_data *td = data;
197 if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP) {
198 td->mmapfile = get_opt_postfix(mem);
199 if (td->o.mem_type == MEM_MMAPHUGE && !td->mmapfile) {
200 log_err("fio: mmaphuge:/path/to/file\n");
208 static int str_lockmem_cb(void fio_unused *data, unsigned long *val)
214 static int str_rwmix_read_cb(void *data, unsigned int *val)
216 struct thread_data *td = data;
218 td->o.rwmix[DDIR_READ] = *val;
219 td->o.rwmix[DDIR_WRITE] = 100 - *val;
223 static int str_rwmix_write_cb(void *data, unsigned int *val)
225 struct thread_data *td = data;
227 td->o.rwmix[DDIR_WRITE] = *val;
228 td->o.rwmix[DDIR_READ] = 100 - *val;
232 #ifdef FIO_HAVE_IOPRIO
233 static int str_prioclass_cb(void *data, unsigned int *val)
235 struct thread_data *td = data;
239 * mask off old class bits, str_prio_cb() may have set a default class
241 mask = (1 << IOPRIO_CLASS_SHIFT) - 1;
244 td->ioprio |= *val << IOPRIO_CLASS_SHIFT;
249 static int str_prio_cb(void *data, unsigned int *val)
251 struct thread_data *td = data;
256 * If no class is set, assume BE
258 if ((td->ioprio >> IOPRIO_CLASS_SHIFT) == 0)
259 td->ioprio |= IOPRIO_CLASS_BE << IOPRIO_CLASS_SHIFT;
266 static int str_exitall_cb(void)
268 exitall_on_terminate = 1;
272 #ifdef FIO_HAVE_CPU_AFFINITY
273 static int str_cpumask_cb(void *data, unsigned int *val)
275 struct thread_data *td = data;
280 ret = fio_cpuset_init(&td->o.cpumask);
282 log_err("fio: cpuset_init failed\n");
283 td_verror(td, ret, "fio_cpuset_init");
287 max_cpu = sysconf(_SC_NPROCESSORS_ONLN);
289 for (i = 0; i < sizeof(int) * 8; i++) {
290 if ((1 << i) & *val) {
292 log_err("fio: CPU %d too large (max=%ld)\n", i,
296 dprint(FD_PARSE, "set cpu allowed %d\n", i);
297 fio_cpu_set(&td->o.cpumask, i);
301 td->o.cpumask_set = 1;
305 static int str_cpus_allowed_cb(void *data, const char *input)
307 struct thread_data *td = data;
312 ret = fio_cpuset_init(&td->o.cpumask);
314 log_err("fio: cpuset_init failed\n");
315 td_verror(td, ret, "fio_cpuset_init");
319 p = str = strdup(input);
321 strip_blank_front(&str);
322 strip_blank_end(str);
324 max_cpu = sysconf(_SC_NPROCESSORS_ONLN);
326 while ((cpu = strsep(&str, ",")) != NULL) {
335 while ((cpu2 = strsep(&str2, "-")) != NULL) {
345 while (icpu <= icpu2) {
346 if (icpu >= FIO_MAX_CPUS) {
347 log_err("fio: your OS only supports up to"
348 " %d CPUs\n", (int) FIO_MAX_CPUS);
352 if (icpu > max_cpu) {
353 log_err("fio: CPU %d too large (max=%ld)\n",
359 dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
360 fio_cpu_set(&td->o.cpumask, icpu);
369 td->o.cpumask_set = 1;
374 static int str_fst_cb(void *data, const char *str)
376 struct thread_data *td = data;
377 char *nr = get_opt_postfix(str);
379 td->file_service_nr = 1;
381 td->file_service_nr = atoi(nr);
388 static int check_dir(struct thread_data *td, char *fname)
390 char file[PATH_MAX], *dir;
393 if (td->o.directory) {
394 strcpy(file, td->o.directory);
399 sprintf(file + elen, "%s", fname);
406 * We can't do this on FIO_DISKLESSIO engines. The engine isn't loaded
407 * yet, so we can't do this check right here...
409 if (lstat(dir, &sb) < 0) {
412 log_err("fio: %s is not a directory\n", dir);
413 td_verror(td, ret, "lstat");
417 if (!S_ISDIR(sb.st_mode)) {
418 log_err("fio: %s is not a directory\n", dir);
427 static int str_filename_cb(void *data, const char *input)
429 struct thread_data *td = data;
430 char *fname, *str, *p;
432 p = str = strdup(input);
434 strip_blank_front(&str);
435 strip_blank_end(str);
437 if (!td->files_index)
440 while ((fname = strsep(&str, ":")) != NULL) {
443 if (check_dir(td, fname)) {
455 static int str_directory_cb(void *data, const char fio_unused *str)
457 struct thread_data *td = data;
460 if (lstat(td->o.directory, &sb) < 0) {
463 log_err("fio: %s is not a directory\n", td->o.directory);
464 td_verror(td, ret, "lstat");
467 if (!S_ISDIR(sb.st_mode)) {
468 log_err("fio: %s is not a directory\n", td->o.directory);
475 static int str_opendir_cb(void *data, const char fio_unused *str)
477 struct thread_data *td = data;
479 if (!td->files_index)
482 return add_dir_files(td, td->o.opendir);
485 static int str_verify_offset_cb(void *data, unsigned int *off)
487 struct thread_data *td = data;
489 if (*off && *off < sizeof(struct verify_header)) {
490 log_err("fio: verify_offset too small\n");
494 td->o.verify_offset = *off;
498 static int str_verify_pattern_cb(void *data, unsigned int *off)
500 struct thread_data *td = data;
505 td->o.verify_pattern_bytes = 1;
507 td->o.verify_pattern_bytes = 2;
509 td->o.verify_pattern_bytes = 3;
511 td->o.verify_pattern_bytes = 4;
513 td->o.verify_pattern = *off;
517 static int str_lockfile_cb(void *data, const char *str)
519 struct thread_data *td = data;
520 char *nr = get_opt_postfix(str);
522 td->o.lockfile_batch = 1;
524 td->o.lockfile_batch = atoi(nr);
531 static int str_write_bw_log_cb(void *data, const char *str)
533 struct thread_data *td = data;
536 td->o.bw_log_file = strdup(str);
538 td->o.write_bw_log = 1;
542 static int str_write_lat_log_cb(void *data, const char *str)
544 struct thread_data *td = data;
547 td->o.lat_log_file = strdup(str);
549 td->o.write_lat_log = 1;
553 static int str_gtod_reduce_cb(void *data, int *il)
555 struct thread_data *td = data;
558 td->o.disable_clat = !!val;
559 td->o.disable_slat = !!val;
560 td->o.disable_bw = !!val;
562 td->tv_cache_mask = 63;
567 static int str_gtod_cpu_cb(void *data, int *il)
569 struct thread_data *td = data;
572 td->o.gtod_cpu = val;
573 td->o.gtod_offload = 1;
577 #define __stringify_1(x) #x
578 #define __stringify(x) __stringify_1(x)
581 * Map of job/command line options
583 static struct fio_option options[] = {
585 .name = "description",
586 .type = FIO_OPT_STR_STORE,
587 .off1 = td_var_offset(description),
588 .help = "Text job description",
592 .type = FIO_OPT_STR_STORE,
593 .off1 = td_var_offset(name),
594 .help = "Name of this job",
598 .type = FIO_OPT_STR_STORE,
599 .off1 = td_var_offset(directory),
600 .cb = str_directory_cb,
601 .help = "Directory to store files in",
605 .type = FIO_OPT_STR_STORE,
606 .off1 = td_var_offset(filename),
607 .cb = str_filename_cb,
608 .prio = -1, /* must come after "directory" */
609 .help = "File(s) to use for the workload",
614 .cb = str_lockfile_cb,
615 .off1 = td_var_offset(file_lock_mode),
616 .help = "Lock file when doing IO to it",
617 .parent = "filename",
621 .oval = FILE_LOCK_NONE,
622 .help = "No file locking",
624 { .ival = "exclusive",
625 .oval = FILE_LOCK_EXCLUSIVE,
626 .help = "Exclusive file lock",
630 .oval = FILE_LOCK_READWRITE,
631 .help = "Read vs write lock",
637 .type = FIO_OPT_STR_STORE,
638 .off1 = td_var_offset(opendir),
639 .cb = str_opendir_cb,
640 .help = "Recursively add files from this directory and down",
644 .alias = "readwrite",
647 .off1 = td_var_offset(td_ddir),
648 .help = "IO direction",
652 .oval = TD_DDIR_READ,
653 .help = "Sequential read",
656 .oval = TD_DDIR_WRITE,
657 .help = "Sequential write",
659 { .ival = "randread",
660 .oval = TD_DDIR_RANDREAD,
661 .help = "Random read",
663 { .ival = "randwrite",
664 .oval = TD_DDIR_RANDWRITE,
665 .help = "Random write",
669 .help = "Sequential read and write mix",
672 .oval = TD_DDIR_RANDRW,
673 .help = "Random read and write mix"
679 .type = FIO_OPT_STR_STORE,
680 .off1 = td_var_offset(ioengine),
681 .help = "IO engine to use",
685 .help = "Use read/write",
688 .help = "Use pread/pwrite",
691 .help = "Use readv/writev",
693 #ifdef FIO_HAVE_LIBAIO
695 .help = "Linux native asynchronous IO",
698 #ifdef FIO_HAVE_POSIXAIO
699 { .ival = "posixaio",
700 .help = "POSIX asynchronous IO",
703 #ifdef FIO_HAVE_SOLARISAIO
704 { .ival = "solarisaio",
705 .help = "Solaris native asynchronous IO",
709 .help = "Memory mapped IO",
711 #ifdef FIO_HAVE_SPLICE
713 .help = "splice/vmsplice based IO",
715 { .ival = "netsplice",
716 .help = "splice/vmsplice to/from the network",
721 .help = "SCSI generic v3 IO",
725 .help = "Testing engine (no data transfer)",
728 .help = "Network IO",
730 #ifdef FIO_HAVE_SYSLET
731 { .ival = "syslet-rw",
732 .help = "syslet enabled async pread/pwrite IO",
736 .help = "CPU cycler burner engine",
738 #ifdef FIO_HAVE_GUASI
740 .help = "GUASI IO engine",
743 { .ival = "external",
744 .help = "Load external engine (append name)",
751 .off1 = td_var_offset(iodepth),
752 .help = "Amount of IO buffers to keep in flight",
757 .name = "iodepth_batch",
758 .alias = "iodepth_batch_submit",
760 .off1 = td_var_offset(iodepth_batch),
761 .help = "Number of IO buffers to submit in one go",
767 .name = "iodepth_batch_complete",
769 .off1 = td_var_offset(iodepth_batch_complete),
770 .help = "Number of IO buffers to retrieve in one go",
776 .name = "iodepth_low",
778 .off1 = td_var_offset(iodepth_low),
779 .help = "Low water mark for queuing depth",
784 .type = FIO_OPT_STR_VAL,
785 .off1 = td_var_offset(size),
787 .help = "Total size of device or files",
790 .name = "fill_device",
791 .type = FIO_OPT_BOOL,
792 .off1 = td_var_offset(fill_device),
793 .help = "Write until an ENOSPC error occurs",
798 .type = FIO_OPT_STR_VAL,
799 .off1 = td_var_offset(file_size_low),
800 .off2 = td_var_offset(file_size_high),
802 .help = "Size of individual files",
806 .alias = "fileoffset",
807 .type = FIO_OPT_STR_VAL,
808 .off1 = td_var_offset(start_offset),
809 .help = "Start IO from this offset",
814 .alias = "blocksize",
815 .type = FIO_OPT_STR_VAL_INT,
816 .off1 = td_var_offset(bs[DDIR_READ]),
817 .off2 = td_var_offset(bs[DDIR_WRITE]),
819 .help = "Block size unit",
825 .alias = "blockalign",
826 .type = FIO_OPT_STR_VAL_INT,
827 .off1 = td_var_offset(ba[DDIR_READ]),
828 .off2 = td_var_offset(ba[DDIR_WRITE]),
830 .help = "IO block offset alignment",
835 .alias = "blocksize_range",
836 .type = FIO_OPT_RANGE,
837 .off1 = td_var_offset(min_bs[DDIR_READ]),
838 .off2 = td_var_offset(max_bs[DDIR_READ]),
839 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
840 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
842 .help = "Set block size range (in more detail than bs)",
848 .cb = str_bssplit_cb,
849 .help = "Set a specific mix of block sizes",
853 .name = "bs_unaligned",
854 .alias = "blocksize_unaligned",
855 .type = FIO_OPT_STR_SET,
856 .off1 = td_var_offset(bs_unaligned),
857 .help = "Don't sector align IO buffer sizes",
861 .name = "randrepeat",
862 .type = FIO_OPT_BOOL,
863 .off1 = td_var_offset(rand_repeatable),
864 .help = "Use repeatable random IO pattern",
869 .name = "norandommap",
870 .type = FIO_OPT_STR_SET,
871 .off1 = td_var_offset(norandommap),
872 .help = "Accept potential duplicate random blocks",
876 .name = "softrandommap",
877 .type = FIO_OPT_BOOL,
878 .off1 = td_var_offset(softrandommap),
879 .help = "Set norandommap if randommap allocation fails",
880 .parent = "norandommap",
886 .off1 = td_var_offset(nr_files),
887 .help = "Split job workload between this number of files",
893 .off1 = td_var_offset(open_files),
894 .help = "Number of files to keep open at the same time",
897 .name = "file_service_type",
900 .off1 = td_var_offset(file_service_type),
901 .help = "How to select which file to service next",
905 .oval = FIO_FSERVICE_RANDOM,
906 .help = "Choose a file at random",
908 { .ival = "roundrobin",
909 .oval = FIO_FSERVICE_RR,
910 .help = "Round robin select files",
912 { .ival = "sequential",
913 .oval = FIO_FSERVICE_SEQ,
914 .help = "Finish one file before moving to the next",
920 .name = "fadvise_hint",
921 .type = FIO_OPT_BOOL,
922 .off1 = td_var_offset(fadvise_hint),
923 .help = "Use fadvise() to advise the kernel on IO pattern",
929 .off1 = td_var_offset(fsync_blocks),
930 .help = "Issue fsync for writes every given number of blocks",
935 .type = FIO_OPT_BOOL,
936 .off1 = td_var_offset(odirect),
937 .help = "Use O_DIRECT IO (negates buffered)",
942 .type = FIO_OPT_BOOL,
943 .off1 = td_var_offset(odirect),
945 .help = "Use buffered IO (negates direct)",
950 .type = FIO_OPT_BOOL,
951 .off1 = td_var_offset(overwrite),
952 .help = "When writing, set whether to overwrite current data",
958 .off1 = td_var_offset(loops),
959 .help = "Number of times to run the job",
965 .off1 = td_var_offset(numjobs),
966 .help = "Duplicate this job this many times",
970 .name = "startdelay",
972 .off1 = td_var_offset(start_delay),
973 .help = "Only start job when this period has passed",
979 .type = FIO_OPT_STR_VAL_TIME,
980 .off1 = td_var_offset(timeout),
981 .help = "Stop workload when this amount of time has passed",
985 .name = "time_based",
986 .type = FIO_OPT_STR_SET,
987 .off1 = td_var_offset(time_based),
988 .help = "Keep running until runtime/timeout is met",
992 .type = FIO_OPT_STR_VAL_TIME,
993 .off1 = td_var_offset(ramp_time),
994 .help = "Ramp up time before measuring performance",
1001 .off1 = td_var_offset(mem_type),
1002 .help = "Backing type for IO buffers",
1007 .help = "Use malloc(3) for IO buffers",
1011 .help = "Use shared memory segments for IO buffers",
1013 #ifdef FIO_HAVE_HUGETLB
1014 { .ival = "shmhuge",
1015 .oval = MEM_SHMHUGE,
1016 .help = "Like shm, but use huge pages",
1021 .help = "Use mmap(2) (file or anon) for IO buffers",
1023 #ifdef FIO_HAVE_HUGETLB
1024 { .ival = "mmaphuge",
1025 .oval = MEM_MMAPHUGE,
1026 .help = "Like mmap, but use huge pages",
1033 .type = FIO_OPT_STR,
1034 .off1 = td_var_offset(verify),
1035 .help = "Verify data written",
1039 .oval = VERIFY_NONE,
1040 .help = "Don't do IO verification",
1044 .help = "Use md5 checksums for verification",
1047 .oval = VERIFY_CRC64,
1048 .help = "Use crc64 checksums for verification",
1051 .oval = VERIFY_CRC32,
1052 .help = "Use crc32 checksums for verification",
1054 { .ival = "crc32c-intel",
1055 .oval = VERIFY_CRC32C_INTEL,
1056 .help = "Use hw crc32c checksums for verification",
1059 .oval = VERIFY_CRC32C,
1060 .help = "Use crc32c checksums for verification",
1063 .oval = VERIFY_CRC16,
1064 .help = "Use crc16 checksums for verification",
1067 .oval = VERIFY_CRC7,
1068 .help = "Use crc7 checksums for verification",
1071 .oval = VERIFY_SHA256,
1072 .help = "Use sha256 checksums for verification",
1075 .oval = VERIFY_SHA512,
1076 .help = "Use sha512 checksums for verification",
1079 .oval = VERIFY_META,
1080 .help = "Use io information",
1084 .oval = VERIFY_NULL,
1085 .help = "Pretend to verify",
1090 .name = "do_verify",
1091 .type = FIO_OPT_BOOL,
1092 .off1 = td_var_offset(do_verify),
1093 .help = "Run verification stage after write",
1098 .name = "verifysort",
1099 .type = FIO_OPT_BOOL,
1100 .off1 = td_var_offset(verifysort),
1101 .help = "Sort written verify blocks for read back",
1106 .name = "verify_interval",
1107 .type = FIO_OPT_STR_VAL_INT,
1108 .off1 = td_var_offset(verify_interval),
1109 .minval = 2 * sizeof(struct verify_header),
1110 .help = "Store verify buffer header every N bytes",
1114 .name = "verify_offset",
1115 .type = FIO_OPT_STR_VAL_INT,
1116 .help = "Offset verify header location by N bytes",
1118 .cb = str_verify_offset_cb,
1122 .name = "verify_pattern",
1123 .type = FIO_OPT_INT,
1124 .cb = str_verify_pattern_cb,
1125 .help = "Fill pattern for IO buffers",
1129 .name = "verify_fatal",
1130 .type = FIO_OPT_BOOL,
1131 .off1 = td_var_offset(verify_fatal),
1133 .help = "Exit on a single verify failure, don't continue",
1137 .name = "write_iolog",
1138 .type = FIO_OPT_STR_STORE,
1139 .off1 = td_var_offset(write_iolog_file),
1140 .help = "Store IO pattern to file",
1143 .name = "read_iolog",
1144 .type = FIO_OPT_STR_STORE,
1145 .off1 = td_var_offset(read_iolog_file),
1146 .help = "Playback IO pattern from file",
1149 .name = "exec_prerun",
1150 .type = FIO_OPT_STR_STORE,
1151 .off1 = td_var_offset(exec_prerun),
1152 .help = "Execute this file prior to running job",
1155 .name = "exec_postrun",
1156 .type = FIO_OPT_STR_STORE,
1157 .off1 = td_var_offset(exec_postrun),
1158 .help = "Execute this file after running job",
1160 #ifdef FIO_HAVE_IOSCHED_SWITCH
1162 .name = "ioscheduler",
1163 .type = FIO_OPT_STR_STORE,
1164 .off1 = td_var_offset(ioscheduler),
1165 .help = "Use this IO scheduler on the backing device",
1170 .type = FIO_OPT_STR_VAL,
1171 .off1 = td_var_offset(zone_size),
1172 .help = "Give size of an IO zone",
1177 .type = FIO_OPT_STR_VAL,
1178 .off1 = td_var_offset(zone_skip),
1179 .help = "Space between IO zones",
1184 .type = FIO_OPT_STR_VAL,
1185 .cb = str_lockmem_cb,
1186 .help = "Lock down this amount of memory",
1190 .name = "rwmixread",
1191 .type = FIO_OPT_INT,
1192 .cb = str_rwmix_read_cb,
1194 .help = "Percentage of mixed workload that is reads",
1198 .name = "rwmixwrite",
1199 .type = FIO_OPT_INT,
1200 .cb = str_rwmix_write_cb,
1202 .help = "Percentage of mixed workload that is writes",
1206 .name = "rwmixcycle",
1207 .type = FIO_OPT_DEPRECATED,
1211 .type = FIO_OPT_INT,
1212 .off1 = td_var_offset(nice),
1213 .help = "Set job CPU nice value",
1218 #ifdef FIO_HAVE_IOPRIO
1221 .type = FIO_OPT_INT,
1223 .help = "Set job IO priority value",
1228 .name = "prioclass",
1229 .type = FIO_OPT_INT,
1230 .cb = str_prioclass_cb,
1231 .help = "Set job IO priority class",
1237 .name = "thinktime",
1238 .type = FIO_OPT_INT,
1239 .off1 = td_var_offset(thinktime),
1240 .help = "Idle time between IO buffers (usec)",
1244 .name = "thinktime_spin",
1245 .type = FIO_OPT_INT,
1246 .off1 = td_var_offset(thinktime_spin),
1247 .help = "Start think time by spinning this amount (usec)",
1249 .parent = "thinktime",
1252 .name = "thinktime_blocks",
1253 .type = FIO_OPT_INT,
1254 .off1 = td_var_offset(thinktime_blocks),
1255 .help = "IO buffer period between 'thinktime'",
1257 .parent = "thinktime",
1261 .type = FIO_OPT_INT,
1262 .off1 = td_var_offset(rate),
1263 .help = "Set bandwidth rate",
1267 .type = FIO_OPT_INT,
1268 .off1 = td_var_offset(ratemin),
1269 .help = "Job must meet this rate or it will be shutdown",
1273 .name = "rate_iops",
1274 .type = FIO_OPT_INT,
1275 .off1 = td_var_offset(rate_iops),
1276 .help = "Limit IO used to this number of IO operations/sec",
1279 .name = "rate_iops_min",
1280 .type = FIO_OPT_INT,
1281 .off1 = td_var_offset(rate_iops_min),
1282 .help = "Job must meet this rate or it will be shutdown",
1283 .parent = "rate_iops",
1286 .name = "ratecycle",
1287 .type = FIO_OPT_INT,
1288 .off1 = td_var_offset(ratecycle),
1289 .help = "Window average for rate limits (msec)",
1294 .name = "invalidate",
1295 .type = FIO_OPT_BOOL,
1296 .off1 = td_var_offset(invalidate_cache),
1297 .help = "Invalidate buffer/page cache prior to running job",
1302 .type = FIO_OPT_BOOL,
1303 .off1 = td_var_offset(sync_io),
1304 .help = "Use O_SYNC for buffered writes",
1306 .parent = "buffered",
1309 .name = "bwavgtime",
1310 .type = FIO_OPT_INT,
1311 .off1 = td_var_offset(bw_avg_time),
1312 .help = "Time window over which to calculate bandwidth"
1317 .name = "create_serialize",
1318 .type = FIO_OPT_BOOL,
1319 .off1 = td_var_offset(create_serialize),
1320 .help = "Serialize creating of job files",
1324 .name = "create_fsync",
1325 .type = FIO_OPT_BOOL,
1326 .off1 = td_var_offset(create_fsync),
1327 .help = "Fsync file after creation",
1331 .name = "create_on_open",
1332 .type = FIO_OPT_BOOL,
1333 .off1 = td_var_offset(create_on_open),
1334 .help = "Create files when they are opened for IO",
1339 .type = FIO_OPT_INT,
1340 .off1 = td_var_offset(cpuload),
1341 .help = "Use this percentage of CPU",
1344 .name = "cpuchunks",
1345 .type = FIO_OPT_INT,
1346 .off1 = td_var_offset(cpucycle),
1347 .help = "Length of the CPU burn cycles (usecs)",
1349 .parent = "cpuload",
1351 #ifdef FIO_HAVE_CPU_AFFINITY
1354 .type = FIO_OPT_INT,
1355 .cb = str_cpumask_cb,
1356 .help = "CPU affinity mask",
1359 .name = "cpus_allowed",
1360 .type = FIO_OPT_STR,
1361 .cb = str_cpus_allowed_cb,
1362 .help = "Set CPUs allowed",
1366 .name = "end_fsync",
1367 .type = FIO_OPT_BOOL,
1368 .off1 = td_var_offset(end_fsync),
1369 .help = "Include fsync at the end of job",
1373 .name = "fsync_on_close",
1374 .type = FIO_OPT_BOOL,
1375 .off1 = td_var_offset(fsync_on_close),
1376 .help = "fsync files on close",
1381 .type = FIO_OPT_BOOL,
1382 .off1 = td_var_offset(unlink),
1383 .help = "Unlink created files after job has completed",
1388 .type = FIO_OPT_STR_SET,
1389 .cb = str_exitall_cb,
1390 .help = "Terminate all jobs when one exits",
1393 .name = "stonewall",
1394 .type = FIO_OPT_STR_SET,
1395 .off1 = td_var_offset(stonewall),
1396 .help = "Insert a hard barrier between this job and previous",
1399 .name = "new_group",
1400 .type = FIO_OPT_STR_SET,
1401 .off1 = td_var_offset(new_group),
1402 .help = "Mark the start of a new group (for reporting)",
1406 .type = FIO_OPT_STR_SET,
1407 .off1 = td_var_offset(use_thread),
1408 .help = "Use threads instead of forks",
1411 .name = "write_bw_log",
1412 .type = FIO_OPT_STR,
1413 .off1 = td_var_offset(write_bw_log),
1414 .cb = str_write_bw_log_cb,
1415 .help = "Write log of bandwidth during run",
1418 .name = "write_lat_log",
1419 .type = FIO_OPT_STR,
1420 .off1 = td_var_offset(write_lat_log),
1421 .cb = str_write_lat_log_cb,
1422 .help = "Write log of latency during run",
1425 .name = "hugepage-size",
1426 .type = FIO_OPT_STR_VAL_INT,
1427 .off1 = td_var_offset(hugepage_size),
1428 .help = "When using hugepages, specify size of each page",
1429 .def = __stringify(FIO_HUGE_PAGE),
1432 .name = "group_reporting",
1433 .type = FIO_OPT_STR_SET,
1434 .off1 = td_var_offset(group_reporting),
1435 .help = "Do reporting on a per-group basis",
1438 .name = "zero_buffers",
1439 .type = FIO_OPT_STR_SET,
1440 .off1 = td_var_offset(zero_buffers),
1441 .help = "Init IO buffers to all zeroes",
1444 .name = "refill_buffers",
1445 .type = FIO_OPT_STR_SET,
1446 .off1 = td_var_offset(refill_buffers),
1447 .help = "Refill IO buffers on every IO submit",
1449 #ifdef FIO_HAVE_DISK_UTIL
1451 .name = "disk_util",
1452 .type = FIO_OPT_BOOL,
1453 .off1 = td_var_offset(do_disk_util),
1454 .help = "Log disk utilization statistics",
1459 .name = "gtod_reduce",
1460 .type = FIO_OPT_BOOL,
1461 .help = "Greatly reduce number of gettimeofday() calls",
1462 .cb = str_gtod_reduce_cb,
1466 .name = "disable_clat",
1467 .type = FIO_OPT_BOOL,
1468 .off1 = td_var_offset(disable_clat),
1469 .help = "Disable completion latency numbers",
1470 .parent = "gtod_reduce",
1474 .name = "disable_slat",
1475 .type = FIO_OPT_BOOL,
1476 .off1 = td_var_offset(disable_slat),
1477 .help = "Disable submissionn latency numbers",
1478 .parent = "gtod_reduce",
1482 .name = "disable_bw_measurement",
1483 .type = FIO_OPT_BOOL,
1484 .off1 = td_var_offset(disable_bw),
1485 .help = "Disable bandwidth logging",
1486 .parent = "gtod_reduce",
1491 .type = FIO_OPT_INT,
1492 .cb = str_gtod_cpu_cb,
1493 .help = "Setup dedicated gettimeofday() thread on this CPU",
1500 void fio_options_dup_and_init(struct option *long_options)
1502 struct fio_option *o;
1505 options_init(options);
1508 while (long_options[i].name)
1513 long_options[i].name = (char *) o->name;
1514 long_options[i].val = FIO_GETOPT_JOB;
1515 if (o->type == FIO_OPT_STR_SET)
1516 long_options[i].has_arg = no_argument;
1518 long_options[i].has_arg = required_argument;
1522 assert(i < FIO_NR_OPTIONS);
1526 int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
1530 sort_options(opts, options, num_opts);
1532 for (ret = 0, i = 0; i < num_opts; i++)
1533 ret |= parse_option(opts[i], options, td);
1538 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
1540 return parse_cmd_option(opt, val, options, td);
1543 void fio_fill_default_options(struct thread_data *td)
1545 fill_default_options(td, options);
1548 int fio_show_option_help(const char *opt)
1550 return show_cmd_help(options, opt);
1553 static void __options_mem(struct thread_data *td, int alloc)
1555 struct thread_options *o = &td->o;
1556 struct fio_option *opt;
1560 for (i = 0, opt = &options[0]; opt->name; i++, opt = &options[i]) {
1561 if (opt->type != FIO_OPT_STR_STORE)
1564 ptr = (void *) o + opt->off1;
1567 *ptr = strdup(*ptr);
1577 * dupe FIO_OPT_STR_STORE options
1579 void options_mem_dupe(struct thread_data *td)
1581 __options_mem(td, 1);
1584 void options_mem_free(struct thread_data fio_unused *td)
1587 __options_mem(td, 0);