10 #include <sys/types.h>
18 #define td_var_offset(var) ((size_t) &((struct thread_options *)0)->var)
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 bs_cmp(const void *p1, const void *p2)
38 const struct bssplit *bsp1 = p1;
39 const struct bssplit *bsp2 = p2;
41 return bsp1->perc < bsp2->perc;
44 static int bssplit_ddir(struct thread_data *td, int ddir, char *str)
46 struct bssplit *bssplit;
47 unsigned int i, perc, perc_missing;
48 unsigned int max_bs, min_bs;
52 td->o.bssplit_nr[ddir] = 4;
53 bssplit = malloc(4 * sizeof(struct bssplit));
58 while ((fname = strsep(&str, ":")) != NULL) {
65 * grow struct buffer, if needed
67 if (i == td->o.bssplit_nr[ddir]) {
68 td->o.bssplit_nr[ddir] <<= 1;
69 bssplit = realloc(bssplit, td->o.bssplit_nr[ddir]
70 * sizeof(struct bssplit));
73 perc_str = strstr(fname, "/");
77 perc = atoi(perc_str);
85 if (str_to_decimal(fname, &val, 1)) {
86 log_err("fio: bssplit conversion failed\n");
97 bssplit[i].perc = perc;
101 td->o.bssplit_nr[ddir] = i;
104 * Now check if the percentages add up, and how much is missing
106 perc = perc_missing = 0;
107 for (i = 0; i < td->o.bssplit_nr[ddir]; i++) {
108 struct bssplit *bsp = &bssplit[i];
110 if (bsp->perc == (unsigned char) -1)
117 log_err("fio: bssplit percentages add to more than 100%%\n");
122 * If values didn't have a percentage set, divide the remains between
126 for (i = 0; i < td->o.bssplit_nr[ddir]; i++) {
127 struct bssplit *bsp = &bssplit[i];
129 if (bsp->perc == (unsigned char) -1)
130 bsp->perc = (100 - perc) / perc_missing;
134 td->o.min_bs[ddir] = min_bs;
135 td->o.max_bs[ddir] = max_bs;
138 * now sort based on percentages, for ease of lookup
140 qsort(bssplit, td->o.bssplit_nr[ddir], sizeof(struct bssplit), bs_cmp);
141 td->o.bssplit[ddir] = bssplit;
146 static int str_bssplit_cb(void *data, const char *input)
148 struct thread_data *td = data;
149 char *str, *p, *odir;
152 p = str = strdup(input);
154 strip_blank_front(&str);
155 strip_blank_end(str);
157 odir = strchr(str, ',');
159 ret = bssplit_ddir(td, DDIR_WRITE, odir + 1);
162 ret = bssplit_ddir(td, DDIR_READ, str);
169 ret = bssplit_ddir(td, DDIR_READ, str);
171 ret = bssplit_ddir(td, DDIR_WRITE, op);
180 static int str_rw_cb(void *data, const char *str)
182 struct thread_data *td = data;
183 char *nr = get_opt_postfix(str);
187 td->o.ddir_nr = atoi(nr);
194 static int str_mem_cb(void *data, const char *mem)
196 struct thread_data *td = data;
198 if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP) {
199 td->mmapfile = get_opt_postfix(mem);
200 if (td->o.mem_type == MEM_MMAPHUGE && !td->mmapfile) {
201 log_err("fio: mmaphuge:/path/to/file\n");
209 static int str_lockmem_cb(void fio_unused *data, unsigned long *val)
215 static int str_rwmix_read_cb(void *data, unsigned int *val)
217 struct thread_data *td = data;
219 td->o.rwmix[DDIR_READ] = *val;
220 td->o.rwmix[DDIR_WRITE] = 100 - *val;
224 static int str_rwmix_write_cb(void *data, unsigned int *val)
226 struct thread_data *td = data;
228 td->o.rwmix[DDIR_WRITE] = *val;
229 td->o.rwmix[DDIR_READ] = 100 - *val;
233 #ifdef FIO_HAVE_IOPRIO
234 static int str_prioclass_cb(void *data, unsigned int *val)
236 struct thread_data *td = data;
240 * mask off old class bits, str_prio_cb() may have set a default class
242 mask = (1 << IOPRIO_CLASS_SHIFT) - 1;
245 td->ioprio |= *val << IOPRIO_CLASS_SHIFT;
250 static int str_prio_cb(void *data, unsigned int *val)
252 struct thread_data *td = data;
257 * If no class is set, assume BE
259 if ((td->ioprio >> IOPRIO_CLASS_SHIFT) == 0)
260 td->ioprio |= IOPRIO_CLASS_BE << IOPRIO_CLASS_SHIFT;
267 static int str_exitall_cb(void)
269 exitall_on_terminate = 1;
273 #ifdef FIO_HAVE_CPU_AFFINITY
274 static int str_cpumask_cb(void *data, unsigned int *val)
276 struct thread_data *td = data;
281 ret = fio_cpuset_init(&td->o.cpumask);
283 log_err("fio: cpuset_init failed\n");
284 td_verror(td, ret, "fio_cpuset_init");
288 max_cpu = sysconf(_SC_NPROCESSORS_ONLN);
290 for (i = 0; i < sizeof(int) * 8; i++) {
291 if ((1 << i) & *val) {
293 log_err("fio: CPU %d too large (max=%ld)\n", i,
297 dprint(FD_PARSE, "set cpu allowed %d\n", i);
298 fio_cpu_set(&td->o.cpumask, i);
302 td->o.cpumask_set = 1;
306 static int str_cpus_allowed_cb(void *data, const char *input)
308 struct thread_data *td = data;
313 ret = fio_cpuset_init(&td->o.cpumask);
315 log_err("fio: cpuset_init failed\n");
316 td_verror(td, ret, "fio_cpuset_init");
320 p = str = strdup(input);
322 strip_blank_front(&str);
323 strip_blank_end(str);
325 max_cpu = sysconf(_SC_NPROCESSORS_ONLN);
327 while ((cpu = strsep(&str, ",")) != NULL) {
336 while ((cpu2 = strsep(&str2, "-")) != NULL) {
346 while (icpu <= icpu2) {
347 if (icpu >= FIO_MAX_CPUS) {
348 log_err("fio: your OS only supports up to"
349 " %d CPUs\n", (int) FIO_MAX_CPUS);
353 if (icpu > max_cpu) {
354 log_err("fio: CPU %d too large (max=%ld)\n",
360 dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
361 fio_cpu_set(&td->o.cpumask, icpu);
370 td->o.cpumask_set = 1;
375 static int str_fst_cb(void *data, const char *str)
377 struct thread_data *td = data;
378 char *nr = get_opt_postfix(str);
380 td->file_service_nr = 1;
382 td->file_service_nr = atoi(nr);
389 static int check_dir(struct thread_data *td, char *fname)
391 char file[PATH_MAX], *dir;
394 if (td->o.directory) {
395 strcpy(file, td->o.directory);
400 sprintf(file + elen, "%s", fname);
407 * We can't do this on FIO_DISKLESSIO engines. The engine isn't loaded
408 * yet, so we can't do this check right here...
410 if (lstat(dir, &sb) < 0) {
413 log_err("fio: %s is not a directory\n", dir);
414 td_verror(td, ret, "lstat");
418 if (!S_ISDIR(sb.st_mode)) {
419 log_err("fio: %s is not a directory\n", dir);
428 static int str_filename_cb(void *data, const char *input)
430 struct thread_data *td = data;
431 char *fname, *str, *p;
433 p = str = strdup(input);
435 strip_blank_front(&str);
436 strip_blank_end(str);
438 if (!td->files_index)
441 while ((fname = strsep(&str, ":")) != NULL) {
444 if (check_dir(td, fname)) {
456 static int str_directory_cb(void *data, const char fio_unused *str)
458 struct thread_data *td = data;
461 if (lstat(td->o.directory, &sb) < 0) {
464 log_err("fio: %s is not a directory\n", td->o.directory);
465 td_verror(td, ret, "lstat");
468 if (!S_ISDIR(sb.st_mode)) {
469 log_err("fio: %s is not a directory\n", td->o.directory);
476 static int str_opendir_cb(void *data, const char fio_unused *str)
478 struct thread_data *td = data;
480 if (!td->files_index)
483 return add_dir_files(td, td->o.opendir);
486 static int str_verify_offset_cb(void *data, unsigned int *off)
488 struct thread_data *td = data;
490 if (*off && *off < sizeof(struct verify_header)) {
491 log_err("fio: verify_offset too small\n");
495 td->o.verify_offset = *off;
499 static int str_verify_pattern_cb(void *data, unsigned int *off)
501 struct thread_data *td = data;
506 td->o.verify_pattern_bytes = 1;
508 td->o.verify_pattern_bytes = 2;
510 td->o.verify_pattern_bytes = 3;
512 td->o.verify_pattern_bytes = 4;
514 td->o.verify_pattern = *off;
518 static int str_lockfile_cb(void *data, const char *str)
520 struct thread_data *td = data;
521 char *nr = get_opt_postfix(str);
523 td->o.lockfile_batch = 1;
525 td->o.lockfile_batch = atoi(nr);
532 static int str_write_bw_log_cb(void *data, const char *str)
534 struct thread_data *td = data;
537 td->o.bw_log_file = strdup(str);
539 td->o.write_bw_log = 1;
543 static int str_write_lat_log_cb(void *data, const char *str)
545 struct thread_data *td = data;
548 td->o.lat_log_file = strdup(str);
550 td->o.write_lat_log = 1;
554 static int str_gtod_reduce_cb(void *data, int *il)
556 struct thread_data *td = data;
559 td->o.disable_clat = !!val;
560 td->o.disable_slat = !!val;
561 td->o.disable_bw = !!val;
563 td->tv_cache_mask = 63;
568 static int str_gtod_cpu_cb(void *data, int *il)
570 struct thread_data *td = data;
573 td->o.gtod_cpu = val;
574 td->o.gtod_offload = 1;
578 #define __stringify_1(x) #x
579 #define __stringify(x) __stringify_1(x)
582 * Map of job/command line options
584 static struct fio_option options[] = {
586 .name = "description",
587 .type = FIO_OPT_STR_STORE,
588 .off1 = td_var_offset(description),
589 .help = "Text job description",
593 .type = FIO_OPT_STR_STORE,
594 .off1 = td_var_offset(name),
595 .help = "Name of this job",
599 .type = FIO_OPT_STR_STORE,
600 .off1 = td_var_offset(directory),
601 .cb = str_directory_cb,
602 .help = "Directory to store files in",
606 .type = FIO_OPT_STR_STORE,
607 .off1 = td_var_offset(filename),
608 .cb = str_filename_cb,
609 .prio = -1, /* must come after "directory" */
610 .help = "File(s) to use for the workload",
615 .cb = str_lockfile_cb,
616 .off1 = td_var_offset(file_lock_mode),
617 .help = "Lock file when doing IO to it",
618 .parent = "filename",
622 .oval = FILE_LOCK_NONE,
623 .help = "No file locking",
625 { .ival = "exclusive",
626 .oval = FILE_LOCK_EXCLUSIVE,
627 .help = "Exclusive file lock",
631 .oval = FILE_LOCK_READWRITE,
632 .help = "Read vs write lock",
638 .type = FIO_OPT_STR_STORE,
639 .off1 = td_var_offset(opendir),
640 .cb = str_opendir_cb,
641 .help = "Recursively add files from this directory and down",
645 .alias = "readwrite",
648 .off1 = td_var_offset(td_ddir),
649 .help = "IO direction",
653 .oval = TD_DDIR_READ,
654 .help = "Sequential read",
657 .oval = TD_DDIR_WRITE,
658 .help = "Sequential write",
660 { .ival = "randread",
661 .oval = TD_DDIR_RANDREAD,
662 .help = "Random read",
664 { .ival = "randwrite",
665 .oval = TD_DDIR_RANDWRITE,
666 .help = "Random write",
670 .help = "Sequential read and write mix",
673 .oval = TD_DDIR_RANDRW,
674 .help = "Random read and write mix"
680 .type = FIO_OPT_STR_STORE,
681 .off1 = td_var_offset(ioengine),
682 .help = "IO engine to use",
686 .help = "Use read/write",
689 .help = "Use pread/pwrite",
692 .help = "Use readv/writev",
694 #ifdef FIO_HAVE_LIBAIO
696 .help = "Linux native asynchronous IO",
699 #ifdef FIO_HAVE_POSIXAIO
700 { .ival = "posixaio",
701 .help = "POSIX asynchronous IO",
704 #ifdef FIO_HAVE_SOLARISAIO
705 { .ival = "solarisaio",
706 .help = "Solaris native asynchronous IO",
710 .help = "Memory mapped IO",
712 #ifdef FIO_HAVE_SPLICE
714 .help = "splice/vmsplice based IO",
716 { .ival = "netsplice",
717 .help = "splice/vmsplice to/from the network",
722 .help = "SCSI generic v3 IO",
726 .help = "Testing engine (no data transfer)",
729 .help = "Network IO",
731 #ifdef FIO_HAVE_SYSLET
732 { .ival = "syslet-rw",
733 .help = "syslet enabled async pread/pwrite IO",
737 .help = "CPU cycler burner engine",
739 #ifdef FIO_HAVE_GUASI
741 .help = "GUASI IO engine",
744 { .ival = "external",
745 .help = "Load external engine (append name)",
752 .off1 = td_var_offset(iodepth),
753 .help = "Amount of IO buffers to keep in flight",
758 .name = "iodepth_batch",
759 .alias = "iodepth_batch_submit",
761 .off1 = td_var_offset(iodepth_batch),
762 .help = "Number of IO buffers to submit in one go",
768 .name = "iodepth_batch_complete",
770 .off1 = td_var_offset(iodepth_batch_complete),
771 .help = "Number of IO buffers to retrieve in one go",
777 .name = "iodepth_low",
779 .off1 = td_var_offset(iodepth_low),
780 .help = "Low water mark for queuing depth",
785 .type = FIO_OPT_STR_VAL,
786 .off1 = td_var_offset(size),
788 .help = "Total size of device or files",
791 .name = "fill_device",
792 .type = FIO_OPT_BOOL,
793 .off1 = td_var_offset(fill_device),
794 .help = "Write until an ENOSPC error occurs",
799 .type = FIO_OPT_STR_VAL,
800 .off1 = td_var_offset(file_size_low),
801 .off2 = td_var_offset(file_size_high),
803 .help = "Size of individual files",
807 .alias = "fileoffset",
808 .type = FIO_OPT_STR_VAL,
809 .off1 = td_var_offset(start_offset),
810 .help = "Start IO from this offset",
815 .alias = "blocksize",
817 .off1 = td_var_offset(bs[DDIR_READ]),
818 .off2 = td_var_offset(bs[DDIR_WRITE]),
820 .help = "Block size unit",
826 .alias = "blockalign",
828 .off1 = td_var_offset(ba[DDIR_READ]),
829 .off2 = td_var_offset(ba[DDIR_WRITE]),
831 .help = "IO block offset alignment",
836 .alias = "blocksize_range",
837 .type = FIO_OPT_RANGE,
838 .off1 = td_var_offset(min_bs[DDIR_READ]),
839 .off2 = td_var_offset(max_bs[DDIR_READ]),
840 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
841 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
843 .help = "Set block size range (in more detail than bs)",
849 .cb = str_bssplit_cb,
850 .help = "Set a specific mix of block sizes",
854 .name = "bs_unaligned",
855 .alias = "blocksize_unaligned",
856 .type = FIO_OPT_STR_SET,
857 .off1 = td_var_offset(bs_unaligned),
858 .help = "Don't sector align IO buffer sizes",
862 .name = "randrepeat",
863 .type = FIO_OPT_BOOL,
864 .off1 = td_var_offset(rand_repeatable),
865 .help = "Use repeatable random IO pattern",
870 .name = "norandommap",
871 .type = FIO_OPT_STR_SET,
872 .off1 = td_var_offset(norandommap),
873 .help = "Accept potential duplicate random blocks",
877 .name = "softrandommap",
878 .type = FIO_OPT_BOOL,
879 .off1 = td_var_offset(softrandommap),
880 .help = "Set norandommap if randommap allocation fails",
881 .parent = "norandommap",
887 .off1 = td_var_offset(nr_files),
888 .help = "Split job workload between this number of files",
894 .off1 = td_var_offset(open_files),
895 .help = "Number of files to keep open at the same time",
898 .name = "file_service_type",
901 .off1 = td_var_offset(file_service_type),
902 .help = "How to select which file to service next",
906 .oval = FIO_FSERVICE_RANDOM,
907 .help = "Choose a file at random",
909 { .ival = "roundrobin",
910 .oval = FIO_FSERVICE_RR,
911 .help = "Round robin select files",
913 { .ival = "sequential",
914 .oval = FIO_FSERVICE_SEQ,
915 .help = "Finish one file before moving to the next",
921 .name = "fadvise_hint",
922 .type = FIO_OPT_BOOL,
923 .off1 = td_var_offset(fadvise_hint),
924 .help = "Use fadvise() to advise the kernel on IO pattern",
930 .off1 = td_var_offset(fsync_blocks),
931 .help = "Issue fsync for writes every given number of blocks",
936 .type = FIO_OPT_BOOL,
937 .off1 = td_var_offset(odirect),
938 .help = "Use O_DIRECT IO (negates buffered)",
943 .type = FIO_OPT_BOOL,
944 .off1 = td_var_offset(odirect),
946 .help = "Use buffered IO (negates direct)",
951 .type = FIO_OPT_BOOL,
952 .off1 = td_var_offset(overwrite),
953 .help = "When writing, set whether to overwrite current data",
959 .off1 = td_var_offset(loops),
960 .help = "Number of times to run the job",
966 .off1 = td_var_offset(numjobs),
967 .help = "Duplicate this job this many times",
971 .name = "startdelay",
973 .off1 = td_var_offset(start_delay),
974 .help = "Only start job when this period has passed",
980 .type = FIO_OPT_STR_VAL_TIME,
981 .off1 = td_var_offset(timeout),
982 .help = "Stop workload when this amount of time has passed",
986 .name = "time_based",
987 .type = FIO_OPT_STR_SET,
988 .off1 = td_var_offset(time_based),
989 .help = "Keep running until runtime/timeout is met",
993 .type = FIO_OPT_STR_VAL_TIME,
994 .off1 = td_var_offset(ramp_time),
995 .help = "Ramp up time before measuring performance",
1000 .type = FIO_OPT_STR,
1002 .off1 = td_var_offset(mem_type),
1003 .help = "Backing type for IO buffers",
1008 .help = "Use malloc(3) for IO buffers",
1012 .help = "Use shared memory segments for IO buffers",
1014 #ifdef FIO_HAVE_HUGETLB
1015 { .ival = "shmhuge",
1016 .oval = MEM_SHMHUGE,
1017 .help = "Like shm, but use huge pages",
1022 .help = "Use mmap(2) (file or anon) for IO buffers",
1024 #ifdef FIO_HAVE_HUGETLB
1025 { .ival = "mmaphuge",
1026 .oval = MEM_MMAPHUGE,
1027 .help = "Like mmap, but use huge pages",
1034 .type = FIO_OPT_STR,
1035 .off1 = td_var_offset(verify),
1036 .help = "Verify data written",
1040 .oval = VERIFY_NONE,
1041 .help = "Don't do IO verification",
1045 .help = "Use md5 checksums for verification",
1048 .oval = VERIFY_CRC64,
1049 .help = "Use crc64 checksums for verification",
1052 .oval = VERIFY_CRC32,
1053 .help = "Use crc32 checksums for verification",
1055 { .ival = "crc32c-intel",
1056 .oval = VERIFY_CRC32C_INTEL,
1057 .help = "Use hw crc32c checksums for verification",
1060 .oval = VERIFY_CRC32C,
1061 .help = "Use crc32c checksums for verification",
1064 .oval = VERIFY_CRC16,
1065 .help = "Use crc16 checksums for verification",
1068 .oval = VERIFY_CRC7,
1069 .help = "Use crc7 checksums for verification",
1072 .oval = VERIFY_SHA256,
1073 .help = "Use sha256 checksums for verification",
1076 .oval = VERIFY_SHA512,
1077 .help = "Use sha512 checksums for verification",
1080 .oval = VERIFY_META,
1081 .help = "Use io information",
1085 .oval = VERIFY_NULL,
1086 .help = "Pretend to verify",
1091 .name = "do_verify",
1092 .type = FIO_OPT_BOOL,
1093 .off1 = td_var_offset(do_verify),
1094 .help = "Run verification stage after write",
1099 .name = "verifysort",
1100 .type = FIO_OPT_BOOL,
1101 .off1 = td_var_offset(verifysort),
1102 .help = "Sort written verify blocks for read back",
1107 .name = "verify_interval",
1108 .type = FIO_OPT_INT,
1109 .off1 = td_var_offset(verify_interval),
1110 .minval = 2 * sizeof(struct verify_header),
1111 .help = "Store verify buffer header every N bytes",
1115 .name = "verify_offset",
1116 .type = FIO_OPT_INT,
1117 .help = "Offset verify header location by N bytes",
1119 .cb = str_verify_offset_cb,
1123 .name = "verify_pattern",
1124 .type = FIO_OPT_INT,
1125 .cb = str_verify_pattern_cb,
1126 .help = "Fill pattern for IO buffers",
1130 .name = "verify_fatal",
1131 .type = FIO_OPT_BOOL,
1132 .off1 = td_var_offset(verify_fatal),
1134 .help = "Exit on a single verify failure, don't continue",
1138 .name = "write_iolog",
1139 .type = FIO_OPT_STR_STORE,
1140 .off1 = td_var_offset(write_iolog_file),
1141 .help = "Store IO pattern to file",
1144 .name = "read_iolog",
1145 .type = FIO_OPT_STR_STORE,
1146 .off1 = td_var_offset(read_iolog_file),
1147 .help = "Playback IO pattern from file",
1150 .name = "exec_prerun",
1151 .type = FIO_OPT_STR_STORE,
1152 .off1 = td_var_offset(exec_prerun),
1153 .help = "Execute this file prior to running job",
1156 .name = "exec_postrun",
1157 .type = FIO_OPT_STR_STORE,
1158 .off1 = td_var_offset(exec_postrun),
1159 .help = "Execute this file after running job",
1161 #ifdef FIO_HAVE_IOSCHED_SWITCH
1163 .name = "ioscheduler",
1164 .type = FIO_OPT_STR_STORE,
1165 .off1 = td_var_offset(ioscheduler),
1166 .help = "Use this IO scheduler on the backing device",
1171 .type = FIO_OPT_STR_VAL,
1172 .off1 = td_var_offset(zone_size),
1173 .help = "Give size of an IO zone",
1178 .type = FIO_OPT_STR_VAL,
1179 .off1 = td_var_offset(zone_skip),
1180 .help = "Space between IO zones",
1185 .type = FIO_OPT_STR_VAL,
1186 .cb = str_lockmem_cb,
1187 .help = "Lock down this amount of memory",
1191 .name = "rwmixread",
1192 .type = FIO_OPT_INT,
1193 .cb = str_rwmix_read_cb,
1195 .help = "Percentage of mixed workload that is reads",
1199 .name = "rwmixwrite",
1200 .type = FIO_OPT_INT,
1201 .cb = str_rwmix_write_cb,
1203 .help = "Percentage of mixed workload that is writes",
1207 .name = "rwmixcycle",
1208 .type = FIO_OPT_DEPRECATED,
1212 .type = FIO_OPT_INT,
1213 .off1 = td_var_offset(nice),
1214 .help = "Set job CPU nice value",
1219 #ifdef FIO_HAVE_IOPRIO
1222 .type = FIO_OPT_INT,
1224 .help = "Set job IO priority value",
1229 .name = "prioclass",
1230 .type = FIO_OPT_INT,
1231 .cb = str_prioclass_cb,
1232 .help = "Set job IO priority class",
1238 .name = "thinktime",
1239 .type = FIO_OPT_INT,
1240 .off1 = td_var_offset(thinktime),
1241 .help = "Idle time between IO buffers (usec)",
1245 .name = "thinktime_spin",
1246 .type = FIO_OPT_INT,
1247 .off1 = td_var_offset(thinktime_spin),
1248 .help = "Start think time by spinning this amount (usec)",
1250 .parent = "thinktime",
1253 .name = "thinktime_blocks",
1254 .type = FIO_OPT_INT,
1255 .off1 = td_var_offset(thinktime_blocks),
1256 .help = "IO buffer period between 'thinktime'",
1258 .parent = "thinktime",
1262 .type = FIO_OPT_INT,
1263 .off1 = td_var_offset(rate[0]),
1264 .off2 = td_var_offset(rate[1]),
1265 .help = "Set bandwidth rate",
1269 .type = FIO_OPT_INT,
1270 .off1 = td_var_offset(ratemin[0]),
1271 .off2 = td_var_offset(ratemin[1]),
1272 .help = "Job must meet this rate or it will be shutdown",
1276 .name = "rate_iops",
1277 .type = FIO_OPT_INT,
1278 .off1 = td_var_offset(rate_iops[0]),
1279 .off2 = td_var_offset(rate_iops[1]),
1280 .help = "Limit IO used to this number of IO operations/sec",
1283 .name = "rate_iops_min",
1284 .type = FIO_OPT_INT,
1285 .off1 = td_var_offset(rate_iops_min[0]),
1286 .off2 = td_var_offset(rate_iops_min[1]),
1287 .help = "Job must meet this rate or it will be shutdown",
1288 .parent = "rate_iops",
1291 .name = "ratecycle",
1292 .type = FIO_OPT_INT,
1293 .off1 = td_var_offset(ratecycle),
1294 .help = "Window average for rate limits (msec)",
1299 .name = "invalidate",
1300 .type = FIO_OPT_BOOL,
1301 .off1 = td_var_offset(invalidate_cache),
1302 .help = "Invalidate buffer/page cache prior to running job",
1307 .type = FIO_OPT_BOOL,
1308 .off1 = td_var_offset(sync_io),
1309 .help = "Use O_SYNC for buffered writes",
1311 .parent = "buffered",
1314 .name = "bwavgtime",
1315 .type = FIO_OPT_INT,
1316 .off1 = td_var_offset(bw_avg_time),
1317 .help = "Time window over which to calculate bandwidth"
1322 .name = "create_serialize",
1323 .type = FIO_OPT_BOOL,
1324 .off1 = td_var_offset(create_serialize),
1325 .help = "Serialize creating of job files",
1329 .name = "create_fsync",
1330 .type = FIO_OPT_BOOL,
1331 .off1 = td_var_offset(create_fsync),
1332 .help = "Fsync file after creation",
1336 .name = "create_on_open",
1337 .type = FIO_OPT_BOOL,
1338 .off1 = td_var_offset(create_on_open),
1339 .help = "Create files when they are opened for IO",
1344 .type = FIO_OPT_BOOL,
1345 .off1 = td_var_offset(pre_read),
1346 .help = "Preread files before starting official testing",
1351 .type = FIO_OPT_INT,
1352 .off1 = td_var_offset(cpuload),
1353 .help = "Use this percentage of CPU",
1356 .name = "cpuchunks",
1357 .type = FIO_OPT_INT,
1358 .off1 = td_var_offset(cpucycle),
1359 .help = "Length of the CPU burn cycles (usecs)",
1361 .parent = "cpuload",
1363 #ifdef FIO_HAVE_CPU_AFFINITY
1366 .type = FIO_OPT_INT,
1367 .cb = str_cpumask_cb,
1368 .help = "CPU affinity mask",
1371 .name = "cpus_allowed",
1372 .type = FIO_OPT_STR,
1373 .cb = str_cpus_allowed_cb,
1374 .help = "Set CPUs allowed",
1378 .name = "end_fsync",
1379 .type = FIO_OPT_BOOL,
1380 .off1 = td_var_offset(end_fsync),
1381 .help = "Include fsync at the end of job",
1385 .name = "fsync_on_close",
1386 .type = FIO_OPT_BOOL,
1387 .off1 = td_var_offset(fsync_on_close),
1388 .help = "fsync files on close",
1393 .type = FIO_OPT_BOOL,
1394 .off1 = td_var_offset(unlink),
1395 .help = "Unlink created files after job has completed",
1400 .type = FIO_OPT_STR_SET,
1401 .cb = str_exitall_cb,
1402 .help = "Terminate all jobs when one exits",
1405 .name = "stonewall",
1406 .type = FIO_OPT_STR_SET,
1407 .off1 = td_var_offset(stonewall),
1408 .help = "Insert a hard barrier between this job and previous",
1411 .name = "new_group",
1412 .type = FIO_OPT_STR_SET,
1413 .off1 = td_var_offset(new_group),
1414 .help = "Mark the start of a new group (for reporting)",
1418 .type = FIO_OPT_STR_SET,
1419 .off1 = td_var_offset(use_thread),
1420 .help = "Use threads instead of forks",
1423 .name = "write_bw_log",
1424 .type = FIO_OPT_STR,
1425 .off1 = td_var_offset(write_bw_log),
1426 .cb = str_write_bw_log_cb,
1427 .help = "Write log of bandwidth during run",
1430 .name = "write_lat_log",
1431 .type = FIO_OPT_STR,
1432 .off1 = td_var_offset(write_lat_log),
1433 .cb = str_write_lat_log_cb,
1434 .help = "Write log of latency during run",
1437 .name = "hugepage-size",
1438 .type = FIO_OPT_INT,
1439 .off1 = td_var_offset(hugepage_size),
1440 .help = "When using hugepages, specify size of each page",
1441 .def = __stringify(FIO_HUGE_PAGE),
1444 .name = "group_reporting",
1445 .type = FIO_OPT_STR_SET,
1446 .off1 = td_var_offset(group_reporting),
1447 .help = "Do reporting on a per-group basis",
1450 .name = "zero_buffers",
1451 .type = FIO_OPT_STR_SET,
1452 .off1 = td_var_offset(zero_buffers),
1453 .help = "Init IO buffers to all zeroes",
1456 .name = "refill_buffers",
1457 .type = FIO_OPT_STR_SET,
1458 .off1 = td_var_offset(refill_buffers),
1459 .help = "Refill IO buffers on every IO submit",
1461 #ifdef FIO_HAVE_DISK_UTIL
1463 .name = "disk_util",
1464 .type = FIO_OPT_BOOL,
1465 .off1 = td_var_offset(do_disk_util),
1466 .help = "Log disk utilization statistics",
1471 .name = "gtod_reduce",
1472 .type = FIO_OPT_BOOL,
1473 .help = "Greatly reduce number of gettimeofday() calls",
1474 .cb = str_gtod_reduce_cb,
1478 .name = "disable_clat",
1479 .type = FIO_OPT_BOOL,
1480 .off1 = td_var_offset(disable_clat),
1481 .help = "Disable completion latency numbers",
1482 .parent = "gtod_reduce",
1486 .name = "disable_slat",
1487 .type = FIO_OPT_BOOL,
1488 .off1 = td_var_offset(disable_slat),
1489 .help = "Disable submissionn latency numbers",
1490 .parent = "gtod_reduce",
1494 .name = "disable_bw_measurement",
1495 .type = FIO_OPT_BOOL,
1496 .off1 = td_var_offset(disable_bw),
1497 .help = "Disable bandwidth logging",
1498 .parent = "gtod_reduce",
1503 .type = FIO_OPT_INT,
1504 .cb = str_gtod_cpu_cb,
1505 .help = "Setup dedicated gettimeofday() thread on this CPU",
1512 void fio_options_dup_and_init(struct option *long_options)
1514 struct fio_option *o;
1517 options_init(options);
1520 while (long_options[i].name)
1525 long_options[i].name = (char *) o->name;
1526 long_options[i].val = FIO_GETOPT_JOB;
1527 if (o->type == FIO_OPT_STR_SET)
1528 long_options[i].has_arg = no_argument;
1530 long_options[i].has_arg = required_argument;
1534 assert(i < FIO_NR_OPTIONS);
1538 int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
1542 sort_options(opts, options, num_opts);
1544 for (ret = 0, i = 0; i < num_opts; i++)
1545 ret |= parse_option(opts[i], options, td);
1550 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
1552 return parse_cmd_option(opt, val, options, td);
1555 void fio_fill_default_options(struct thread_data *td)
1557 fill_default_options(td, options);
1560 int fio_show_option_help(const char *opt)
1562 return show_cmd_help(options, opt);
1565 static void __options_mem(struct thread_data *td, int alloc)
1567 struct thread_options *o = &td->o;
1568 struct fio_option *opt;
1572 for (i = 0, opt = &options[0]; opt->name; i++, opt = &options[i]) {
1573 if (opt->type != FIO_OPT_STR_STORE)
1576 ptr = (void *) o + opt->off1;
1579 *ptr = strdup(*ptr);
1589 * dupe FIO_OPT_STR_STORE options
1591 void options_mem_dupe(struct thread_data *td)
1593 __options_mem(td, 1);
1596 void options_mem_free(struct thread_data fio_unused *td)
1599 __options_mem(td, 0);