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 static int rw_verify(struct fio_option *o, void *data)
580 struct thread_data *td = data;
582 if (read_only && td_write(td)) {
583 log_err("fio: job <%s> has write bit set, but fio is in"
584 " read-only mode\n", td->o.name);
591 #define __stringify_1(x) #x
592 #define __stringify(x) __stringify_1(x)
595 * Map of job/command line options
597 static struct fio_option options[] = {
599 .name = "description",
600 .type = FIO_OPT_STR_STORE,
601 .off1 = td_var_offset(description),
602 .help = "Text job description",
606 .type = FIO_OPT_STR_STORE,
607 .off1 = td_var_offset(name),
608 .help = "Name of this job",
612 .type = FIO_OPT_STR_STORE,
613 .off1 = td_var_offset(directory),
614 .cb = str_directory_cb,
615 .help = "Directory to store files in",
619 .type = FIO_OPT_STR_STORE,
620 .off1 = td_var_offset(filename),
621 .cb = str_filename_cb,
622 .prio = -1, /* must come after "directory" */
623 .help = "File(s) to use for the workload",
628 .cb = str_lockfile_cb,
629 .off1 = td_var_offset(file_lock_mode),
630 .help = "Lock file when doing IO to it",
631 .parent = "filename",
635 .oval = FILE_LOCK_NONE,
636 .help = "No file locking",
638 { .ival = "exclusive",
639 .oval = FILE_LOCK_EXCLUSIVE,
640 .help = "Exclusive file lock",
644 .oval = FILE_LOCK_READWRITE,
645 .help = "Read vs write lock",
651 .type = FIO_OPT_STR_STORE,
652 .off1 = td_var_offset(opendir),
653 .cb = str_opendir_cb,
654 .help = "Recursively add files from this directory and down",
658 .alias = "readwrite",
661 .off1 = td_var_offset(td_ddir),
662 .help = "IO direction",
667 .oval = TD_DDIR_READ,
668 .help = "Sequential read",
671 .oval = TD_DDIR_WRITE,
672 .help = "Sequential write",
674 { .ival = "randread",
675 .oval = TD_DDIR_RANDREAD,
676 .help = "Random read",
678 { .ival = "randwrite",
679 .oval = TD_DDIR_RANDWRITE,
680 .help = "Random write",
684 .help = "Sequential read and write mix",
687 .oval = TD_DDIR_RANDRW,
688 .help = "Random read and write mix"
694 .type = FIO_OPT_STR_STORE,
695 .off1 = td_var_offset(ioengine),
696 .help = "IO engine to use",
700 .help = "Use read/write",
703 .help = "Use pread/pwrite",
706 .help = "Use readv/writev",
708 #ifdef FIO_HAVE_LIBAIO
710 .help = "Linux native asynchronous IO",
713 #ifdef FIO_HAVE_POSIXAIO
714 { .ival = "posixaio",
715 .help = "POSIX asynchronous IO",
718 #ifdef FIO_HAVE_SOLARISAIO
719 { .ival = "solarisaio",
720 .help = "Solaris native asynchronous IO",
724 .help = "Memory mapped IO",
726 #ifdef FIO_HAVE_SPLICE
728 .help = "splice/vmsplice based IO",
730 { .ival = "netsplice",
731 .help = "splice/vmsplice to/from the network",
736 .help = "SCSI generic v3 IO",
740 .help = "Testing engine (no data transfer)",
743 .help = "Network IO",
745 #ifdef FIO_HAVE_SYSLET
746 { .ival = "syslet-rw",
747 .help = "syslet enabled async pread/pwrite IO",
751 .help = "CPU cycler burner engine",
753 #ifdef FIO_HAVE_GUASI
755 .help = "GUASI IO engine",
758 { .ival = "external",
759 .help = "Load external engine (append name)",
766 .off1 = td_var_offset(iodepth),
767 .help = "Amount of IO buffers to keep in flight",
772 .name = "iodepth_batch",
773 .alias = "iodepth_batch_submit",
775 .off1 = td_var_offset(iodepth_batch),
776 .help = "Number of IO buffers to submit in one go",
782 .name = "iodepth_batch_complete",
784 .off1 = td_var_offset(iodepth_batch_complete),
785 .help = "Number of IO buffers to retrieve in one go",
791 .name = "iodepth_low",
793 .off1 = td_var_offset(iodepth_low),
794 .help = "Low water mark for queuing depth",
799 .type = FIO_OPT_STR_VAL,
800 .off1 = td_var_offset(size),
802 .help = "Total size of device or files",
805 .name = "fill_device",
806 .type = FIO_OPT_BOOL,
807 .off1 = td_var_offset(fill_device),
808 .help = "Write until an ENOSPC error occurs",
813 .type = FIO_OPT_STR_VAL,
814 .off1 = td_var_offset(file_size_low),
815 .off2 = td_var_offset(file_size_high),
817 .help = "Size of individual files",
821 .alias = "fileoffset",
822 .type = FIO_OPT_STR_VAL,
823 .off1 = td_var_offset(start_offset),
824 .help = "Start IO from this offset",
829 .alias = "blocksize",
831 .off1 = td_var_offset(bs[DDIR_READ]),
832 .off2 = td_var_offset(bs[DDIR_WRITE]),
834 .help = "Block size unit",
840 .alias = "blockalign",
842 .off1 = td_var_offset(ba[DDIR_READ]),
843 .off2 = td_var_offset(ba[DDIR_WRITE]),
845 .help = "IO block offset alignment",
850 .alias = "blocksize_range",
851 .type = FIO_OPT_RANGE,
852 .off1 = td_var_offset(min_bs[DDIR_READ]),
853 .off2 = td_var_offset(max_bs[DDIR_READ]),
854 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
855 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
857 .help = "Set block size range (in more detail than bs)",
863 .cb = str_bssplit_cb,
864 .help = "Set a specific mix of block sizes",
868 .name = "bs_unaligned",
869 .alias = "blocksize_unaligned",
870 .type = FIO_OPT_STR_SET,
871 .off1 = td_var_offset(bs_unaligned),
872 .help = "Don't sector align IO buffer sizes",
876 .name = "randrepeat",
877 .type = FIO_OPT_BOOL,
878 .off1 = td_var_offset(rand_repeatable),
879 .help = "Use repeatable random IO pattern",
884 .name = "norandommap",
885 .type = FIO_OPT_STR_SET,
886 .off1 = td_var_offset(norandommap),
887 .help = "Accept potential duplicate random blocks",
891 .name = "softrandommap",
892 .type = FIO_OPT_BOOL,
893 .off1 = td_var_offset(softrandommap),
894 .help = "Set norandommap if randommap allocation fails",
895 .parent = "norandommap",
901 .off1 = td_var_offset(nr_files),
902 .help = "Split job workload between this number of files",
908 .off1 = td_var_offset(open_files),
909 .help = "Number of files to keep open at the same time",
912 .name = "file_service_type",
915 .off1 = td_var_offset(file_service_type),
916 .help = "How to select which file to service next",
920 .oval = FIO_FSERVICE_RANDOM,
921 .help = "Choose a file at random",
923 { .ival = "roundrobin",
924 .oval = FIO_FSERVICE_RR,
925 .help = "Round robin select files",
927 { .ival = "sequential",
928 .oval = FIO_FSERVICE_SEQ,
929 .help = "Finish one file before moving to the next",
935 .name = "fadvise_hint",
936 .type = FIO_OPT_BOOL,
937 .off1 = td_var_offset(fadvise_hint),
938 .help = "Use fadvise() to advise the kernel on IO pattern",
944 .off1 = td_var_offset(fsync_blocks),
945 .help = "Issue fsync for writes every given number of blocks",
951 .off1 = td_var_offset(fdatasync_blocks),
952 .help = "Issue fdatasync for writes every given number of blocks",
957 .type = FIO_OPT_BOOL,
958 .off1 = td_var_offset(odirect),
959 .help = "Use O_DIRECT IO (negates buffered)",
964 .type = FIO_OPT_BOOL,
965 .off1 = td_var_offset(odirect),
967 .help = "Use buffered IO (negates direct)",
972 .type = FIO_OPT_BOOL,
973 .off1 = td_var_offset(overwrite),
974 .help = "When writing, set whether to overwrite current data",
980 .off1 = td_var_offset(loops),
981 .help = "Number of times to run the job",
987 .off1 = td_var_offset(numjobs),
988 .help = "Duplicate this job this many times",
992 .name = "startdelay",
994 .off1 = td_var_offset(start_delay),
995 .help = "Only start job when this period has passed",
1001 .type = FIO_OPT_STR_VAL_TIME,
1002 .off1 = td_var_offset(timeout),
1003 .help = "Stop workload when this amount of time has passed",
1007 .name = "time_based",
1008 .type = FIO_OPT_STR_SET,
1009 .off1 = td_var_offset(time_based),
1010 .help = "Keep running until runtime/timeout is met",
1013 .name = "ramp_time",
1014 .type = FIO_OPT_STR_VAL_TIME,
1015 .off1 = td_var_offset(ramp_time),
1016 .help = "Ramp up time before measuring performance",
1021 .type = FIO_OPT_STR,
1023 .off1 = td_var_offset(mem_type),
1024 .help = "Backing type for IO buffers",
1029 .help = "Use malloc(3) for IO buffers",
1033 .help = "Use shared memory segments for IO buffers",
1035 #ifdef FIO_HAVE_HUGETLB
1036 { .ival = "shmhuge",
1037 .oval = MEM_SHMHUGE,
1038 .help = "Like shm, but use huge pages",
1043 .help = "Use mmap(2) (file or anon) for IO buffers",
1045 #ifdef FIO_HAVE_HUGETLB
1046 { .ival = "mmaphuge",
1047 .oval = MEM_MMAPHUGE,
1048 .help = "Like mmap, but use huge pages",
1054 .name = "iomem_align",
1055 .alias = "mem_align",
1056 .type = FIO_OPT_INT,
1057 .off1 = td_var_offset(mem_align),
1059 .help = "IO memory buffer offset alignment",
1065 .type = FIO_OPT_STR,
1066 .off1 = td_var_offset(verify),
1067 .help = "Verify data written",
1071 .oval = VERIFY_NONE,
1072 .help = "Don't do IO verification",
1076 .help = "Use md5 checksums for verification",
1079 .oval = VERIFY_CRC64,
1080 .help = "Use crc64 checksums for verification",
1083 .oval = VERIFY_CRC32,
1084 .help = "Use crc32 checksums for verification",
1086 { .ival = "crc32c-intel",
1087 .oval = VERIFY_CRC32C_INTEL,
1088 .help = "Use hw crc32c checksums for verification",
1091 .oval = VERIFY_CRC32C,
1092 .help = "Use crc32c checksums for verification",
1095 .oval = VERIFY_CRC16,
1096 .help = "Use crc16 checksums for verification",
1099 .oval = VERIFY_CRC7,
1100 .help = "Use crc7 checksums for verification",
1103 .oval = VERIFY_SHA256,
1104 .help = "Use sha256 checksums for verification",
1107 .oval = VERIFY_SHA512,
1108 .help = "Use sha512 checksums for verification",
1111 .oval = VERIFY_META,
1112 .help = "Use io information",
1116 .oval = VERIFY_NULL,
1117 .help = "Pretend to verify",
1122 .name = "do_verify",
1123 .type = FIO_OPT_BOOL,
1124 .off1 = td_var_offset(do_verify),
1125 .help = "Run verification stage after write",
1130 .name = "verifysort",
1131 .type = FIO_OPT_BOOL,
1132 .off1 = td_var_offset(verifysort),
1133 .help = "Sort written verify blocks for read back",
1138 .name = "verify_interval",
1139 .type = FIO_OPT_INT,
1140 .off1 = td_var_offset(verify_interval),
1141 .minval = 2 * sizeof(struct verify_header),
1142 .help = "Store verify buffer header every N bytes",
1146 .name = "verify_offset",
1147 .type = FIO_OPT_INT,
1148 .help = "Offset verify header location by N bytes",
1150 .cb = str_verify_offset_cb,
1154 .name = "verify_pattern",
1155 .type = FIO_OPT_INT,
1156 .cb = str_verify_pattern_cb,
1157 .help = "Fill pattern for IO buffers",
1161 .name = "verify_fatal",
1162 .type = FIO_OPT_BOOL,
1163 .off1 = td_var_offset(verify_fatal),
1165 .help = "Exit on a single verify failure, don't continue",
1169 .name = "write_iolog",
1170 .type = FIO_OPT_STR_STORE,
1171 .off1 = td_var_offset(write_iolog_file),
1172 .help = "Store IO pattern to file",
1175 .name = "read_iolog",
1176 .type = FIO_OPT_STR_STORE,
1177 .off1 = td_var_offset(read_iolog_file),
1178 .help = "Playback IO pattern from file",
1181 .name = "exec_prerun",
1182 .type = FIO_OPT_STR_STORE,
1183 .off1 = td_var_offset(exec_prerun),
1184 .help = "Execute this file prior to running job",
1187 .name = "exec_postrun",
1188 .type = FIO_OPT_STR_STORE,
1189 .off1 = td_var_offset(exec_postrun),
1190 .help = "Execute this file after running job",
1192 #ifdef FIO_HAVE_IOSCHED_SWITCH
1194 .name = "ioscheduler",
1195 .type = FIO_OPT_STR_STORE,
1196 .off1 = td_var_offset(ioscheduler),
1197 .help = "Use this IO scheduler on the backing device",
1202 .type = FIO_OPT_STR_VAL,
1203 .off1 = td_var_offset(zone_size),
1204 .help = "Give size of an IO zone",
1209 .type = FIO_OPT_STR_VAL,
1210 .off1 = td_var_offset(zone_skip),
1211 .help = "Space between IO zones",
1216 .type = FIO_OPT_STR_VAL,
1217 .cb = str_lockmem_cb,
1218 .help = "Lock down this amount of memory",
1222 .name = "rwmixread",
1223 .type = FIO_OPT_INT,
1224 .cb = str_rwmix_read_cb,
1226 .help = "Percentage of mixed workload that is reads",
1230 .name = "rwmixwrite",
1231 .type = FIO_OPT_INT,
1232 .cb = str_rwmix_write_cb,
1234 .help = "Percentage of mixed workload that is writes",
1238 .name = "rwmixcycle",
1239 .type = FIO_OPT_DEPRECATED,
1243 .type = FIO_OPT_INT,
1244 .off1 = td_var_offset(nice),
1245 .help = "Set job CPU nice value",
1250 #ifdef FIO_HAVE_IOPRIO
1253 .type = FIO_OPT_INT,
1255 .help = "Set job IO priority value",
1260 .name = "prioclass",
1261 .type = FIO_OPT_INT,
1262 .cb = str_prioclass_cb,
1263 .help = "Set job IO priority class",
1269 .name = "thinktime",
1270 .type = FIO_OPT_INT,
1271 .off1 = td_var_offset(thinktime),
1272 .help = "Idle time between IO buffers (usec)",
1276 .name = "thinktime_spin",
1277 .type = FIO_OPT_INT,
1278 .off1 = td_var_offset(thinktime_spin),
1279 .help = "Start think time by spinning this amount (usec)",
1281 .parent = "thinktime",
1284 .name = "thinktime_blocks",
1285 .type = FIO_OPT_INT,
1286 .off1 = td_var_offset(thinktime_blocks),
1287 .help = "IO buffer period between 'thinktime'",
1289 .parent = "thinktime",
1293 .type = FIO_OPT_INT,
1294 .off1 = td_var_offset(rate[0]),
1295 .off2 = td_var_offset(rate[1]),
1296 .help = "Set bandwidth rate",
1300 .type = FIO_OPT_INT,
1301 .off1 = td_var_offset(ratemin[0]),
1302 .off2 = td_var_offset(ratemin[1]),
1303 .help = "Job must meet this rate or it will be shutdown",
1307 .name = "rate_iops",
1308 .type = FIO_OPT_INT,
1309 .off1 = td_var_offset(rate_iops[0]),
1310 .off2 = td_var_offset(rate_iops[1]),
1311 .help = "Limit IO used to this number of IO operations/sec",
1314 .name = "rate_iops_min",
1315 .type = FIO_OPT_INT,
1316 .off1 = td_var_offset(rate_iops_min[0]),
1317 .off2 = td_var_offset(rate_iops_min[1]),
1318 .help = "Job must meet this rate or it will be shutdown",
1319 .parent = "rate_iops",
1322 .name = "ratecycle",
1323 .type = FIO_OPT_INT,
1324 .off1 = td_var_offset(ratecycle),
1325 .help = "Window average for rate limits (msec)",
1330 .name = "invalidate",
1331 .type = FIO_OPT_BOOL,
1332 .off1 = td_var_offset(invalidate_cache),
1333 .help = "Invalidate buffer/page cache prior to running job",
1338 .type = FIO_OPT_BOOL,
1339 .off1 = td_var_offset(sync_io),
1340 .help = "Use O_SYNC for buffered writes",
1342 .parent = "buffered",
1345 .name = "bwavgtime",
1346 .type = FIO_OPT_INT,
1347 .off1 = td_var_offset(bw_avg_time),
1348 .help = "Time window over which to calculate bandwidth"
1353 .name = "create_serialize",
1354 .type = FIO_OPT_BOOL,
1355 .off1 = td_var_offset(create_serialize),
1356 .help = "Serialize creating of job files",
1360 .name = "create_fsync",
1361 .type = FIO_OPT_BOOL,
1362 .off1 = td_var_offset(create_fsync),
1363 .help = "Fsync file after creation",
1367 .name = "create_on_open",
1368 .type = FIO_OPT_BOOL,
1369 .off1 = td_var_offset(create_on_open),
1370 .help = "Create files when they are opened for IO",
1375 .type = FIO_OPT_BOOL,
1376 .off1 = td_var_offset(pre_read),
1377 .help = "Preread files before starting official testing",
1382 .type = FIO_OPT_INT,
1383 .off1 = td_var_offset(cpuload),
1384 .help = "Use this percentage of CPU",
1387 .name = "cpuchunks",
1388 .type = FIO_OPT_INT,
1389 .off1 = td_var_offset(cpucycle),
1390 .help = "Length of the CPU burn cycles (usecs)",
1392 .parent = "cpuload",
1394 #ifdef FIO_HAVE_CPU_AFFINITY
1397 .type = FIO_OPT_INT,
1398 .cb = str_cpumask_cb,
1399 .help = "CPU affinity mask",
1402 .name = "cpus_allowed",
1403 .type = FIO_OPT_STR,
1404 .cb = str_cpus_allowed_cb,
1405 .help = "Set CPUs allowed",
1409 .name = "end_fsync",
1410 .type = FIO_OPT_BOOL,
1411 .off1 = td_var_offset(end_fsync),
1412 .help = "Include fsync at the end of job",
1416 .name = "fsync_on_close",
1417 .type = FIO_OPT_BOOL,
1418 .off1 = td_var_offset(fsync_on_close),
1419 .help = "fsync files on close",
1424 .type = FIO_OPT_BOOL,
1425 .off1 = td_var_offset(unlink),
1426 .help = "Unlink created files after job has completed",
1431 .type = FIO_OPT_STR_SET,
1432 .cb = str_exitall_cb,
1433 .help = "Terminate all jobs when one exits",
1436 .name = "stonewall",
1437 .type = FIO_OPT_STR_SET,
1438 .off1 = td_var_offset(stonewall),
1439 .help = "Insert a hard barrier between this job and previous",
1442 .name = "new_group",
1443 .type = FIO_OPT_STR_SET,
1444 .off1 = td_var_offset(new_group),
1445 .help = "Mark the start of a new group (for reporting)",
1449 .type = FIO_OPT_STR_SET,
1450 .off1 = td_var_offset(use_thread),
1451 .help = "Use threads instead of forks",
1454 .name = "write_bw_log",
1455 .type = FIO_OPT_STR,
1456 .off1 = td_var_offset(write_bw_log),
1457 .cb = str_write_bw_log_cb,
1458 .help = "Write log of bandwidth during run",
1461 .name = "write_lat_log",
1462 .type = FIO_OPT_STR,
1463 .off1 = td_var_offset(write_lat_log),
1464 .cb = str_write_lat_log_cb,
1465 .help = "Write log of latency during run",
1468 .name = "hugepage-size",
1469 .type = FIO_OPT_INT,
1470 .off1 = td_var_offset(hugepage_size),
1471 .help = "When using hugepages, specify size of each page",
1472 .def = __stringify(FIO_HUGE_PAGE),
1475 .name = "group_reporting",
1476 .type = FIO_OPT_STR_SET,
1477 .off1 = td_var_offset(group_reporting),
1478 .help = "Do reporting on a per-group basis",
1481 .name = "zero_buffers",
1482 .type = FIO_OPT_STR_SET,
1483 .off1 = td_var_offset(zero_buffers),
1484 .help = "Init IO buffers to all zeroes",
1487 .name = "refill_buffers",
1488 .type = FIO_OPT_STR_SET,
1489 .off1 = td_var_offset(refill_buffers),
1490 .help = "Refill IO buffers on every IO submit",
1492 #ifdef FIO_HAVE_DISK_UTIL
1494 .name = "disk_util",
1495 .type = FIO_OPT_BOOL,
1496 .off1 = td_var_offset(do_disk_util),
1497 .help = "Log disk utilization statistics",
1502 .name = "gtod_reduce",
1503 .type = FIO_OPT_BOOL,
1504 .help = "Greatly reduce number of gettimeofday() calls",
1505 .cb = str_gtod_reduce_cb,
1509 .name = "disable_clat",
1510 .type = FIO_OPT_BOOL,
1511 .off1 = td_var_offset(disable_clat),
1512 .help = "Disable completion latency numbers",
1513 .parent = "gtod_reduce",
1517 .name = "disable_slat",
1518 .type = FIO_OPT_BOOL,
1519 .off1 = td_var_offset(disable_slat),
1520 .help = "Disable submissionn latency numbers",
1521 .parent = "gtod_reduce",
1525 .name = "disable_bw_measurement",
1526 .type = FIO_OPT_BOOL,
1527 .off1 = td_var_offset(disable_bw),
1528 .help = "Disable bandwidth logging",
1529 .parent = "gtod_reduce",
1534 .type = FIO_OPT_INT,
1535 .cb = str_gtod_cpu_cb,
1536 .help = "Setup dedicated gettimeofday() thread on this CPU",
1539 .name = "continue_on_error",
1540 .type = FIO_OPT_BOOL,
1541 .off1 = td_var_offset(continue_on_error),
1542 .help = "Continue on non-fatal errors during I/O",
1550 void fio_options_dup_and_init(struct option *long_options)
1552 struct fio_option *o;
1555 options_init(options);
1558 while (long_options[i].name)
1563 long_options[i].name = (char *) o->name;
1564 long_options[i].val = FIO_GETOPT_JOB;
1565 if (o->type == FIO_OPT_STR_SET)
1566 long_options[i].has_arg = no_argument;
1568 long_options[i].has_arg = required_argument;
1572 assert(i < FIO_NR_OPTIONS);
1576 int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
1580 sort_options(opts, options, num_opts);
1582 for (ret = 0, i = 0; i < num_opts; i++)
1583 ret |= parse_option(opts[i], options, td);
1588 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
1590 return parse_cmd_option(opt, val, options, td);
1593 void fio_fill_default_options(struct thread_data *td)
1595 fill_default_options(td, options);
1598 int fio_show_option_help(const char *opt)
1600 return show_cmd_help(options, opt);
1603 static void __options_mem(struct thread_data *td, int alloc)
1605 struct thread_options *o = &td->o;
1606 struct fio_option *opt;
1610 for (i = 0, opt = &options[0]; opt->name; i++, opt = &options[i]) {
1611 if (opt->type != FIO_OPT_STR_STORE)
1614 ptr = (void *) o + opt->off1;
1617 *ptr = strdup(*ptr);
1627 * dupe FIO_OPT_STR_STORE options
1629 void options_mem_dupe(struct thread_data *td)
1631 __options_mem(td, 1);
1634 void options_mem_free(struct thread_data fio_unused *td)
1637 __options_mem(td, 0);