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 static int gtod_cpu_rw_verify(struct fio_option *o, void *data)
593 struct thread_data *td = data;
595 #ifndef FIO_HAVE_CPU_AFFINITY
596 if (td->o.gtod_cpu) {
597 log_err("fio: platform must support CPU affinity for"
598 "gettimeofday() offloading\n");
606 #define __stringify_1(x) #x
607 #define __stringify(x) __stringify_1(x)
610 * Map of job/command line options
612 static struct fio_option options[] = {
614 .name = "description",
615 .type = FIO_OPT_STR_STORE,
616 .off1 = td_var_offset(description),
617 .help = "Text job description",
621 .type = FIO_OPT_STR_STORE,
622 .off1 = td_var_offset(name),
623 .help = "Name of this job",
627 .type = FIO_OPT_STR_STORE,
628 .off1 = td_var_offset(directory),
629 .cb = str_directory_cb,
630 .help = "Directory to store files in",
634 .type = FIO_OPT_STR_STORE,
635 .off1 = td_var_offset(filename),
636 .cb = str_filename_cb,
637 .prio = -1, /* must come after "directory" */
638 .help = "File(s) to use for the workload",
643 .cb = str_lockfile_cb,
644 .off1 = td_var_offset(file_lock_mode),
645 .help = "Lock file when doing IO to it",
646 .parent = "filename",
650 .oval = FILE_LOCK_NONE,
651 .help = "No file locking",
653 { .ival = "exclusive",
654 .oval = FILE_LOCK_EXCLUSIVE,
655 .help = "Exclusive file lock",
659 .oval = FILE_LOCK_READWRITE,
660 .help = "Read vs write lock",
666 .type = FIO_OPT_STR_STORE,
667 .off1 = td_var_offset(opendir),
668 .cb = str_opendir_cb,
669 .help = "Recursively add files from this directory and down",
673 .alias = "readwrite",
676 .off1 = td_var_offset(td_ddir),
677 .help = "IO direction",
682 .oval = TD_DDIR_READ,
683 .help = "Sequential read",
686 .oval = TD_DDIR_WRITE,
687 .help = "Sequential write",
689 { .ival = "randread",
690 .oval = TD_DDIR_RANDREAD,
691 .help = "Random read",
693 { .ival = "randwrite",
694 .oval = TD_DDIR_RANDWRITE,
695 .help = "Random write",
699 .help = "Sequential read and write mix",
702 .oval = TD_DDIR_RANDRW,
703 .help = "Random read and write mix"
709 .type = FIO_OPT_STR_STORE,
710 .off1 = td_var_offset(ioengine),
711 .help = "IO engine to use",
715 .help = "Use read/write",
718 .help = "Use pread/pwrite",
721 .help = "Use readv/writev",
723 #ifdef FIO_HAVE_LIBAIO
725 .help = "Linux native asynchronous IO",
728 #ifdef FIO_HAVE_POSIXAIO
729 { .ival = "posixaio",
730 .help = "POSIX asynchronous IO",
733 #ifdef FIO_HAVE_SOLARISAIO
734 { .ival = "solarisaio",
735 .help = "Solaris native asynchronous IO",
739 .help = "Memory mapped IO",
741 #ifdef FIO_HAVE_SPLICE
743 .help = "splice/vmsplice based IO",
745 { .ival = "netsplice",
746 .help = "splice/vmsplice to/from the network",
751 .help = "SCSI generic v3 IO",
755 .help = "Testing engine (no data transfer)",
758 .help = "Network IO",
760 #ifdef FIO_HAVE_SYSLET
761 { .ival = "syslet-rw",
762 .help = "syslet enabled async pread/pwrite IO",
766 .help = "CPU cycler burner engine",
768 #ifdef FIO_HAVE_GUASI
770 .help = "GUASI IO engine",
773 { .ival = "external",
774 .help = "Load external engine (append name)",
781 .off1 = td_var_offset(iodepth),
782 .help = "Amount of IO buffers to keep in flight",
787 .name = "iodepth_batch",
788 .alias = "iodepth_batch_submit",
790 .off1 = td_var_offset(iodepth_batch),
791 .help = "Number of IO buffers to submit in one go",
797 .name = "iodepth_batch_complete",
799 .off1 = td_var_offset(iodepth_batch_complete),
800 .help = "Number of IO buffers to retrieve in one go",
806 .name = "iodepth_low",
808 .off1 = td_var_offset(iodepth_low),
809 .help = "Low water mark for queuing depth",
814 .type = FIO_OPT_STR_VAL,
815 .off1 = td_var_offset(size),
817 .help = "Total size of device or files",
820 .name = "fill_device",
821 .type = FIO_OPT_BOOL,
822 .off1 = td_var_offset(fill_device),
823 .help = "Write until an ENOSPC error occurs",
828 .type = FIO_OPT_STR_VAL,
829 .off1 = td_var_offset(file_size_low),
830 .off2 = td_var_offset(file_size_high),
832 .help = "Size of individual files",
836 .alias = "fileoffset",
837 .type = FIO_OPT_STR_VAL,
838 .off1 = td_var_offset(start_offset),
839 .help = "Start IO from this offset",
844 .alias = "blocksize",
846 .off1 = td_var_offset(bs[DDIR_READ]),
847 .off2 = td_var_offset(bs[DDIR_WRITE]),
849 .help = "Block size unit",
855 .alias = "blockalign",
857 .off1 = td_var_offset(ba[DDIR_READ]),
858 .off2 = td_var_offset(ba[DDIR_WRITE]),
860 .help = "IO block offset alignment",
865 .alias = "blocksize_range",
866 .type = FIO_OPT_RANGE,
867 .off1 = td_var_offset(min_bs[DDIR_READ]),
868 .off2 = td_var_offset(max_bs[DDIR_READ]),
869 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
870 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
872 .help = "Set block size range (in more detail than bs)",
878 .cb = str_bssplit_cb,
879 .help = "Set a specific mix of block sizes",
883 .name = "bs_unaligned",
884 .alias = "blocksize_unaligned",
885 .type = FIO_OPT_STR_SET,
886 .off1 = td_var_offset(bs_unaligned),
887 .help = "Don't sector align IO buffer sizes",
891 .name = "randrepeat",
892 .type = FIO_OPT_BOOL,
893 .off1 = td_var_offset(rand_repeatable),
894 .help = "Use repeatable random IO pattern",
899 .name = "norandommap",
900 .type = FIO_OPT_STR_SET,
901 .off1 = td_var_offset(norandommap),
902 .help = "Accept potential duplicate random blocks",
906 .name = "softrandommap",
907 .type = FIO_OPT_BOOL,
908 .off1 = td_var_offset(softrandommap),
909 .help = "Set norandommap if randommap allocation fails",
910 .parent = "norandommap",
916 .off1 = td_var_offset(nr_files),
917 .help = "Split job workload between this number of files",
923 .off1 = td_var_offset(open_files),
924 .help = "Number of files to keep open at the same time",
927 .name = "file_service_type",
930 .off1 = td_var_offset(file_service_type),
931 .help = "How to select which file to service next",
935 .oval = FIO_FSERVICE_RANDOM,
936 .help = "Choose a file at random",
938 { .ival = "roundrobin",
939 .oval = FIO_FSERVICE_RR,
940 .help = "Round robin select files",
942 { .ival = "sequential",
943 .oval = FIO_FSERVICE_SEQ,
944 .help = "Finish one file before moving to the next",
950 .name = "fadvise_hint",
951 .type = FIO_OPT_BOOL,
952 .off1 = td_var_offset(fadvise_hint),
953 .help = "Use fadvise() to advise the kernel on IO pattern",
959 .off1 = td_var_offset(fsync_blocks),
960 .help = "Issue fsync for writes every given number of blocks",
966 .off1 = td_var_offset(fdatasync_blocks),
967 .help = "Issue fdatasync for writes every given number of blocks",
972 .type = FIO_OPT_BOOL,
973 .off1 = td_var_offset(odirect),
974 .help = "Use O_DIRECT IO (negates buffered)",
979 .type = FIO_OPT_BOOL,
980 .off1 = td_var_offset(odirect),
982 .help = "Use buffered IO (negates direct)",
987 .type = FIO_OPT_BOOL,
988 .off1 = td_var_offset(overwrite),
989 .help = "When writing, set whether to overwrite current data",
995 .off1 = td_var_offset(loops),
996 .help = "Number of times to run the job",
1001 .type = FIO_OPT_INT,
1002 .off1 = td_var_offset(numjobs),
1003 .help = "Duplicate this job this many times",
1007 .name = "startdelay",
1008 .type = FIO_OPT_INT,
1009 .off1 = td_var_offset(start_delay),
1010 .help = "Only start job when this period has passed",
1016 .type = FIO_OPT_STR_VAL_TIME,
1017 .off1 = td_var_offset(timeout),
1018 .help = "Stop workload when this amount of time has passed",
1022 .name = "time_based",
1023 .type = FIO_OPT_STR_SET,
1024 .off1 = td_var_offset(time_based),
1025 .help = "Keep running until runtime/timeout is met",
1028 .name = "ramp_time",
1029 .type = FIO_OPT_STR_VAL_TIME,
1030 .off1 = td_var_offset(ramp_time),
1031 .help = "Ramp up time before measuring performance",
1036 .type = FIO_OPT_STR,
1038 .off1 = td_var_offset(mem_type),
1039 .help = "Backing type for IO buffers",
1044 .help = "Use malloc(3) for IO buffers",
1048 .help = "Use shared memory segments for IO buffers",
1050 #ifdef FIO_HAVE_HUGETLB
1051 { .ival = "shmhuge",
1052 .oval = MEM_SHMHUGE,
1053 .help = "Like shm, but use huge pages",
1058 .help = "Use mmap(2) (file or anon) for IO buffers",
1060 #ifdef FIO_HAVE_HUGETLB
1061 { .ival = "mmaphuge",
1062 .oval = MEM_MMAPHUGE,
1063 .help = "Like mmap, but use huge pages",
1069 .name = "iomem_align",
1070 .alias = "mem_align",
1071 .type = FIO_OPT_INT,
1072 .off1 = td_var_offset(mem_align),
1074 .help = "IO memory buffer offset alignment",
1080 .type = FIO_OPT_STR,
1081 .off1 = td_var_offset(verify),
1082 .help = "Verify data written",
1086 .oval = VERIFY_NONE,
1087 .help = "Don't do IO verification",
1091 .help = "Use md5 checksums for verification",
1094 .oval = VERIFY_CRC64,
1095 .help = "Use crc64 checksums for verification",
1098 .oval = VERIFY_CRC32,
1099 .help = "Use crc32 checksums for verification",
1101 { .ival = "crc32c-intel",
1102 .oval = VERIFY_CRC32C_INTEL,
1103 .help = "Use hw crc32c checksums for verification",
1106 .oval = VERIFY_CRC32C,
1107 .help = "Use crc32c checksums for verification",
1110 .oval = VERIFY_CRC16,
1111 .help = "Use crc16 checksums for verification",
1114 .oval = VERIFY_CRC7,
1115 .help = "Use crc7 checksums for verification",
1118 .oval = VERIFY_SHA256,
1119 .help = "Use sha256 checksums for verification",
1122 .oval = VERIFY_SHA512,
1123 .help = "Use sha512 checksums for verification",
1126 .oval = VERIFY_META,
1127 .help = "Use io information",
1131 .oval = VERIFY_NULL,
1132 .help = "Pretend to verify",
1137 .name = "do_verify",
1138 .type = FIO_OPT_BOOL,
1139 .off1 = td_var_offset(do_verify),
1140 .help = "Run verification stage after write",
1145 .name = "verifysort",
1146 .type = FIO_OPT_BOOL,
1147 .off1 = td_var_offset(verifysort),
1148 .help = "Sort written verify blocks for read back",
1153 .name = "verify_interval",
1154 .type = FIO_OPT_INT,
1155 .off1 = td_var_offset(verify_interval),
1156 .minval = 2 * sizeof(struct verify_header),
1157 .help = "Store verify buffer header every N bytes",
1161 .name = "verify_offset",
1162 .type = FIO_OPT_INT,
1163 .help = "Offset verify header location by N bytes",
1165 .cb = str_verify_offset_cb,
1169 .name = "verify_pattern",
1170 .type = FIO_OPT_INT,
1171 .cb = str_verify_pattern_cb,
1172 .help = "Fill pattern for IO buffers",
1176 .name = "verify_fatal",
1177 .type = FIO_OPT_BOOL,
1178 .off1 = td_var_offset(verify_fatal),
1180 .help = "Exit on a single verify failure, don't continue",
1184 .name = "write_iolog",
1185 .type = FIO_OPT_STR_STORE,
1186 .off1 = td_var_offset(write_iolog_file),
1187 .help = "Store IO pattern to file",
1190 .name = "read_iolog",
1191 .type = FIO_OPT_STR_STORE,
1192 .off1 = td_var_offset(read_iolog_file),
1193 .help = "Playback IO pattern from file",
1196 .name = "exec_prerun",
1197 .type = FIO_OPT_STR_STORE,
1198 .off1 = td_var_offset(exec_prerun),
1199 .help = "Execute this file prior to running job",
1202 .name = "exec_postrun",
1203 .type = FIO_OPT_STR_STORE,
1204 .off1 = td_var_offset(exec_postrun),
1205 .help = "Execute this file after running job",
1207 #ifdef FIO_HAVE_IOSCHED_SWITCH
1209 .name = "ioscheduler",
1210 .type = FIO_OPT_STR_STORE,
1211 .off1 = td_var_offset(ioscheduler),
1212 .help = "Use this IO scheduler on the backing device",
1217 .type = FIO_OPT_STR_VAL,
1218 .off1 = td_var_offset(zone_size),
1219 .help = "Give size of an IO zone",
1224 .type = FIO_OPT_STR_VAL,
1225 .off1 = td_var_offset(zone_skip),
1226 .help = "Space between IO zones",
1231 .type = FIO_OPT_STR_VAL,
1232 .cb = str_lockmem_cb,
1233 .help = "Lock down this amount of memory",
1237 .name = "rwmixread",
1238 .type = FIO_OPT_INT,
1239 .cb = str_rwmix_read_cb,
1241 .help = "Percentage of mixed workload that is reads",
1245 .name = "rwmixwrite",
1246 .type = FIO_OPT_INT,
1247 .cb = str_rwmix_write_cb,
1249 .help = "Percentage of mixed workload that is writes",
1253 .name = "rwmixcycle",
1254 .type = FIO_OPT_DEPRECATED,
1258 .type = FIO_OPT_INT,
1259 .off1 = td_var_offset(nice),
1260 .help = "Set job CPU nice value",
1265 #ifdef FIO_HAVE_IOPRIO
1268 .type = FIO_OPT_INT,
1270 .help = "Set job IO priority value",
1275 .name = "prioclass",
1276 .type = FIO_OPT_INT,
1277 .cb = str_prioclass_cb,
1278 .help = "Set job IO priority class",
1284 .name = "thinktime",
1285 .type = FIO_OPT_INT,
1286 .off1 = td_var_offset(thinktime),
1287 .help = "Idle time between IO buffers (usec)",
1291 .name = "thinktime_spin",
1292 .type = FIO_OPT_INT,
1293 .off1 = td_var_offset(thinktime_spin),
1294 .help = "Start think time by spinning this amount (usec)",
1296 .parent = "thinktime",
1299 .name = "thinktime_blocks",
1300 .type = FIO_OPT_INT,
1301 .off1 = td_var_offset(thinktime_blocks),
1302 .help = "IO buffer period between 'thinktime'",
1304 .parent = "thinktime",
1308 .type = FIO_OPT_INT,
1309 .off1 = td_var_offset(rate[0]),
1310 .off2 = td_var_offset(rate[1]),
1311 .help = "Set bandwidth rate",
1315 .type = FIO_OPT_INT,
1316 .off1 = td_var_offset(ratemin[0]),
1317 .off2 = td_var_offset(ratemin[1]),
1318 .help = "Job must meet this rate or it will be shutdown",
1322 .name = "rate_iops",
1323 .type = FIO_OPT_INT,
1324 .off1 = td_var_offset(rate_iops[0]),
1325 .off2 = td_var_offset(rate_iops[1]),
1326 .help = "Limit IO used to this number of IO operations/sec",
1329 .name = "rate_iops_min",
1330 .type = FIO_OPT_INT,
1331 .off1 = td_var_offset(rate_iops_min[0]),
1332 .off2 = td_var_offset(rate_iops_min[1]),
1333 .help = "Job must meet this rate or it will be shutdown",
1334 .parent = "rate_iops",
1337 .name = "ratecycle",
1338 .type = FIO_OPT_INT,
1339 .off1 = td_var_offset(ratecycle),
1340 .help = "Window average for rate limits (msec)",
1345 .name = "invalidate",
1346 .type = FIO_OPT_BOOL,
1347 .off1 = td_var_offset(invalidate_cache),
1348 .help = "Invalidate buffer/page cache prior to running job",
1353 .type = FIO_OPT_BOOL,
1354 .off1 = td_var_offset(sync_io),
1355 .help = "Use O_SYNC for buffered writes",
1357 .parent = "buffered",
1360 .name = "bwavgtime",
1361 .type = FIO_OPT_INT,
1362 .off1 = td_var_offset(bw_avg_time),
1363 .help = "Time window over which to calculate bandwidth"
1368 .name = "create_serialize",
1369 .type = FIO_OPT_BOOL,
1370 .off1 = td_var_offset(create_serialize),
1371 .help = "Serialize creating of job files",
1375 .name = "create_fsync",
1376 .type = FIO_OPT_BOOL,
1377 .off1 = td_var_offset(create_fsync),
1378 .help = "Fsync file after creation",
1382 .name = "create_on_open",
1383 .type = FIO_OPT_BOOL,
1384 .off1 = td_var_offset(create_on_open),
1385 .help = "Create files when they are opened for IO",
1390 .type = FIO_OPT_BOOL,
1391 .off1 = td_var_offset(pre_read),
1392 .help = "Preread files before starting official testing",
1397 .type = FIO_OPT_INT,
1398 .off1 = td_var_offset(cpuload),
1399 .help = "Use this percentage of CPU",
1402 .name = "cpuchunks",
1403 .type = FIO_OPT_INT,
1404 .off1 = td_var_offset(cpucycle),
1405 .help = "Length of the CPU burn cycles (usecs)",
1407 .parent = "cpuload",
1409 #ifdef FIO_HAVE_CPU_AFFINITY
1412 .type = FIO_OPT_INT,
1413 .cb = str_cpumask_cb,
1414 .help = "CPU affinity mask",
1417 .name = "cpus_allowed",
1418 .type = FIO_OPT_STR,
1419 .cb = str_cpus_allowed_cb,
1420 .help = "Set CPUs allowed",
1424 .name = "end_fsync",
1425 .type = FIO_OPT_BOOL,
1426 .off1 = td_var_offset(end_fsync),
1427 .help = "Include fsync at the end of job",
1431 .name = "fsync_on_close",
1432 .type = FIO_OPT_BOOL,
1433 .off1 = td_var_offset(fsync_on_close),
1434 .help = "fsync files on close",
1439 .type = FIO_OPT_BOOL,
1440 .off1 = td_var_offset(unlink),
1441 .help = "Unlink created files after job has completed",
1446 .type = FIO_OPT_STR_SET,
1447 .cb = str_exitall_cb,
1448 .help = "Terminate all jobs when one exits",
1451 .name = "stonewall",
1452 .type = FIO_OPT_STR_SET,
1453 .off1 = td_var_offset(stonewall),
1454 .help = "Insert a hard barrier between this job and previous",
1457 .name = "new_group",
1458 .type = FIO_OPT_STR_SET,
1459 .off1 = td_var_offset(new_group),
1460 .help = "Mark the start of a new group (for reporting)",
1464 .type = FIO_OPT_STR_SET,
1465 .off1 = td_var_offset(use_thread),
1466 .help = "Use threads instead of forks",
1469 .name = "write_bw_log",
1470 .type = FIO_OPT_STR,
1471 .off1 = td_var_offset(write_bw_log),
1472 .cb = str_write_bw_log_cb,
1473 .help = "Write log of bandwidth during run",
1476 .name = "write_lat_log",
1477 .type = FIO_OPT_STR,
1478 .off1 = td_var_offset(write_lat_log),
1479 .cb = str_write_lat_log_cb,
1480 .help = "Write log of latency during run",
1483 .name = "hugepage-size",
1484 .type = FIO_OPT_INT,
1485 .off1 = td_var_offset(hugepage_size),
1486 .help = "When using hugepages, specify size of each page",
1487 .def = __stringify(FIO_HUGE_PAGE),
1490 .name = "group_reporting",
1491 .type = FIO_OPT_STR_SET,
1492 .off1 = td_var_offset(group_reporting),
1493 .help = "Do reporting on a per-group basis",
1496 .name = "zero_buffers",
1497 .type = FIO_OPT_STR_SET,
1498 .off1 = td_var_offset(zero_buffers),
1499 .help = "Init IO buffers to all zeroes",
1502 .name = "refill_buffers",
1503 .type = FIO_OPT_STR_SET,
1504 .off1 = td_var_offset(refill_buffers),
1505 .help = "Refill IO buffers on every IO submit",
1507 #ifdef FIO_HAVE_DISK_UTIL
1509 .name = "disk_util",
1510 .type = FIO_OPT_BOOL,
1511 .off1 = td_var_offset(do_disk_util),
1512 .help = "Log disk utilization statistics",
1517 .name = "gtod_reduce",
1518 .type = FIO_OPT_BOOL,
1519 .help = "Greatly reduce number of gettimeofday() calls",
1520 .cb = str_gtod_reduce_cb,
1524 .name = "disable_clat",
1525 .type = FIO_OPT_BOOL,
1526 .off1 = td_var_offset(disable_clat),
1527 .help = "Disable completion latency numbers",
1528 .parent = "gtod_reduce",
1532 .name = "disable_slat",
1533 .type = FIO_OPT_BOOL,
1534 .off1 = td_var_offset(disable_slat),
1535 .help = "Disable submissionn latency numbers",
1536 .parent = "gtod_reduce",
1540 .name = "disable_bw_measurement",
1541 .type = FIO_OPT_BOOL,
1542 .off1 = td_var_offset(disable_bw),
1543 .help = "Disable bandwidth logging",
1544 .parent = "gtod_reduce",
1549 .type = FIO_OPT_INT,
1550 .cb = str_gtod_cpu_cb,
1551 .help = "Setup dedicated gettimeofday() thread on this CPU",
1552 .verify = gtod_cpu_verify,
1555 .name = "continue_on_error",
1556 .type = FIO_OPT_BOOL,
1557 .off1 = td_var_offset(continue_on_error),
1558 .help = "Continue on non-fatal errors during I/O",
1566 void fio_options_dup_and_init(struct option *long_options)
1568 struct fio_option *o;
1571 options_init(options);
1574 while (long_options[i].name)
1579 long_options[i].name = (char *) o->name;
1580 long_options[i].val = FIO_GETOPT_JOB;
1581 if (o->type == FIO_OPT_STR_SET)
1582 long_options[i].has_arg = no_argument;
1584 long_options[i].has_arg = required_argument;
1588 assert(i < FIO_NR_OPTIONS);
1592 int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
1596 sort_options(opts, options, num_opts);
1598 for (ret = 0, i = 0; i < num_opts; i++)
1599 ret |= parse_option(opts[i], options, td);
1604 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
1606 return parse_cmd_option(opt, val, options, td);
1609 void fio_fill_default_options(struct thread_data *td)
1611 fill_default_options(td, options);
1614 int fio_show_option_help(const char *opt)
1616 return show_cmd_help(options, opt);
1619 static void __options_mem(struct thread_data *td, int alloc)
1621 struct thread_options *o = &td->o;
1622 struct fio_option *opt;
1626 for (i = 0, opt = &options[0]; opt->name; i++, opt = &options[i]) {
1627 if (opt->type != FIO_OPT_STR_STORE)
1630 ptr = (void *) o + opt->off1;
1633 *ptr = strdup(*ptr);
1643 * dupe FIO_OPT_STR_STORE options
1645 void options_mem_dupe(struct thread_data *td)
1647 __options_mem(td, 1);
1650 void options_mem_free(struct thread_data fio_unused *td)
1653 __options_mem(td, 0);