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 str_bssplit_cb(void *data, const char *input)
45 struct thread_data *td = data;
46 char *fname, *str, *p;
47 unsigned int i, perc, perc_missing;
48 unsigned int max_bs, min_bs;
51 p = str = strdup(input);
53 strip_blank_front(&str);
57 td->o.bssplit = malloc(4 * sizeof(struct bssplit));
62 while ((fname = strsep(&str, ":")) != NULL) {
69 * grow struct buffer, if needed
71 if (i == td->o.bssplit_nr) {
72 td->o.bssplit_nr <<= 1;
73 td->o.bssplit = realloc(td->o.bssplit,
75 * sizeof(struct bssplit));
78 perc_str = strstr(fname, "/");
82 perc = atoi(perc_str);
90 if (str_to_decimal(fname, &val, 1)) {
91 log_err("fio: bssplit conversion failed\n");
101 td->o.bssplit[i].bs = val;
102 td->o.bssplit[i].perc = perc;
106 td->o.bssplit_nr = i;
109 * Now check if the percentages add up, and how much is missing
111 perc = perc_missing = 0;
112 for (i = 0; i < td->o.bssplit_nr; i++) {
113 struct bssplit *bsp = &td->o.bssplit[i];
115 if (bsp->perc == (unsigned char) -1)
122 log_err("fio: bssplit percentages add to more than 100%%\n");
127 * If values didn't have a percentage set, divide the remains between
131 for (i = 0; i < td->o.bssplit_nr; i++) {
132 struct bssplit *bsp = &td->o.bssplit[i];
134 if (bsp->perc == (unsigned char) -1)
135 bsp->perc = (100 - perc) / perc_missing;
139 td->o.min_bs[DDIR_READ] = td->o.min_bs[DDIR_WRITE] = min_bs;
140 td->o.max_bs[DDIR_READ] = td->o.max_bs[DDIR_WRITE] = max_bs;
143 * now sort based on percentages, for ease of lookup
145 qsort(td->o.bssplit, td->o.bssplit_nr, sizeof(struct bssplit), bs_cmp);
151 static int str_rw_cb(void *data, const char *str)
153 struct thread_data *td = data;
154 char *nr = get_opt_postfix(str);
158 td->o.ddir_nr = atoi(nr);
165 static int str_mem_cb(void *data, const char *mem)
167 struct thread_data *td = data;
169 if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP) {
170 td->mmapfile = get_opt_postfix(mem);
171 if (td->o.mem_type == MEM_MMAPHUGE && !td->mmapfile) {
172 log_err("fio: mmaphuge:/path/to/file\n");
180 static int str_lockmem_cb(void fio_unused *data, unsigned long *val)
186 static int str_rwmix_read_cb(void *data, unsigned int *val)
188 struct thread_data *td = data;
190 td->o.rwmix[DDIR_READ] = *val;
191 td->o.rwmix[DDIR_WRITE] = 100 - *val;
195 static int str_rwmix_write_cb(void *data, unsigned int *val)
197 struct thread_data *td = data;
199 td->o.rwmix[DDIR_WRITE] = *val;
200 td->o.rwmix[DDIR_READ] = 100 - *val;
204 #ifdef FIO_HAVE_IOPRIO
205 static int str_prioclass_cb(void *data, unsigned int *val)
207 struct thread_data *td = data;
211 * mask off old class bits, str_prio_cb() may have set a default class
213 mask = (1 << IOPRIO_CLASS_SHIFT) - 1;
216 td->ioprio |= *val << IOPRIO_CLASS_SHIFT;
221 static int str_prio_cb(void *data, unsigned int *val)
223 struct thread_data *td = data;
228 * If no class is set, assume BE
230 if ((td->ioprio >> IOPRIO_CLASS_SHIFT) == 0)
231 td->ioprio |= IOPRIO_CLASS_BE << IOPRIO_CLASS_SHIFT;
238 static int str_exitall_cb(void)
240 exitall_on_terminate = 1;
244 #ifdef FIO_HAVE_CPU_AFFINITY
245 static int str_cpumask_cb(void *data, unsigned int *val)
247 struct thread_data *td = data;
252 ret = fio_cpuset_init(&td->o.cpumask);
254 log_err("fio: cpuset_init failed\n");
255 td_verror(td, ret, "fio_cpuset_init");
259 max_cpu = sysconf(_SC_NPROCESSORS_ONLN);
261 for (i = 0; i < sizeof(int) * 8; i++) {
262 if ((1 << i) & *val) {
264 log_err("fio: CPU %d too large (max=%ld)\n", i,
268 dprint(FD_PARSE, "set cpu allowed %d\n", i);
269 fio_cpu_set(&td->o.cpumask, i);
273 td->o.cpumask_set = 1;
277 static int str_cpus_allowed_cb(void *data, const char *input)
279 struct thread_data *td = data;
284 ret = fio_cpuset_init(&td->o.cpumask);
286 log_err("fio: cpuset_init failed\n");
287 td_verror(td, ret, "fio_cpuset_init");
291 p = str = strdup(input);
293 strip_blank_front(&str);
294 strip_blank_end(str);
296 max_cpu = sysconf(_SC_NPROCESSORS_ONLN);
298 while ((cpu = strsep(&str, ",")) != NULL) {
307 while ((cpu2 = strsep(&str2, "-")) != NULL) {
317 while (icpu <= icpu2) {
318 if (icpu >= FIO_MAX_CPUS) {
319 log_err("fio: your OS only supports up to"
320 " %d CPUs\n", (int) FIO_MAX_CPUS);
324 if (icpu > max_cpu) {
325 log_err("fio: CPU %d too large (max=%ld)\n",
331 dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
332 fio_cpu_set(&td->o.cpumask, icpu);
341 td->o.cpumask_set = 1;
346 static int str_fst_cb(void *data, const char *str)
348 struct thread_data *td = data;
349 char *nr = get_opt_postfix(str);
351 td->file_service_nr = 1;
353 td->file_service_nr = atoi(nr);
360 static int check_dir(struct thread_data *td, char *fname)
362 char file[PATH_MAX], *dir;
365 if (td->o.directory) {
366 strcpy(file, td->o.directory);
371 sprintf(file + elen, "%s", fname);
378 * We can't do this on FIO_DISKLESSIO engines. The engine isn't loaded
379 * yet, so we can't do this check right here...
381 if (lstat(dir, &sb) < 0) {
384 log_err("fio: %s is not a directory\n", dir);
385 td_verror(td, ret, "lstat");
389 if (!S_ISDIR(sb.st_mode)) {
390 log_err("fio: %s is not a directory\n", dir);
399 static int str_filename_cb(void *data, const char *input)
401 struct thread_data *td = data;
402 char *fname, *str, *p;
404 p = str = strdup(input);
406 strip_blank_front(&str);
407 strip_blank_end(str);
409 if (!td->files_index)
412 while ((fname = strsep(&str, ":")) != NULL) {
415 if (check_dir(td, fname)) {
427 static int str_directory_cb(void *data, const char fio_unused *str)
429 struct thread_data *td = data;
432 if (lstat(td->o.directory, &sb) < 0) {
435 log_err("fio: %s is not a directory\n", td->o.directory);
436 td_verror(td, ret, "lstat");
439 if (!S_ISDIR(sb.st_mode)) {
440 log_err("fio: %s is not a directory\n", td->o.directory);
447 static int str_opendir_cb(void *data, const char fio_unused *str)
449 struct thread_data *td = data;
451 if (!td->files_index)
454 return add_dir_files(td, td->o.opendir);
457 static int str_verify_offset_cb(void *data, unsigned int *off)
459 struct thread_data *td = data;
461 if (*off && *off < sizeof(struct verify_header)) {
462 log_err("fio: verify_offset too small\n");
466 td->o.verify_offset = *off;
470 static int str_verify_pattern_cb(void *data, unsigned int *off)
472 struct thread_data *td = data;
477 td->o.verify_pattern_bytes = 1;
479 td->o.verify_pattern_bytes = 2;
481 td->o.verify_pattern_bytes = 3;
483 td->o.verify_pattern_bytes = 4;
485 td->o.verify_pattern = *off;
489 static int str_lockfile_cb(void *data, const char *str)
491 struct thread_data *td = data;
492 char *nr = get_opt_postfix(str);
494 td->o.lockfile_batch = 1;
496 td->o.lockfile_batch = atoi(nr);
503 static int str_write_bw_log_cb(void *data, const char *str)
505 struct thread_data *td = data;
508 td->o.bw_log_file = strdup(str);
510 td->o.write_bw_log = 1;
514 static int str_write_lat_log_cb(void *data, const char *str)
516 struct thread_data *td = data;
519 td->o.lat_log_file = strdup(str);
521 td->o.write_lat_log = 1;
525 static int str_gtod_reduce_cb(void *data, int *il)
527 struct thread_data *td = data;
530 td->o.disable_clat = !!val;
531 td->o.disable_slat = !!val;
532 td->o.disable_bw = !!val;
534 td->tv_cache_mask = 63;
539 static int str_gtod_cpu_cb(void *data, int *il)
541 struct thread_data *td = data;
544 td->o.gtod_cpu = val;
545 td->o.gtod_offload = 1;
549 #define __stringify_1(x) #x
550 #define __stringify(x) __stringify_1(x)
553 * Map of job/command line options
555 static struct fio_option options[] = {
557 .name = "description",
558 .type = FIO_OPT_STR_STORE,
559 .off1 = td_var_offset(description),
560 .help = "Text job description",
564 .type = FIO_OPT_STR_STORE,
565 .off1 = td_var_offset(name),
566 .help = "Name of this job",
570 .type = FIO_OPT_STR_STORE,
571 .off1 = td_var_offset(directory),
572 .cb = str_directory_cb,
573 .help = "Directory to store files in",
577 .type = FIO_OPT_STR_STORE,
578 .off1 = td_var_offset(filename),
579 .cb = str_filename_cb,
580 .prio = 1, /* must come before "directory" */
581 .help = "File(s) to use for the workload",
586 .cb = str_lockfile_cb,
587 .off1 = td_var_offset(file_lock_mode),
588 .help = "Lock file when doing IO to it",
589 .parent = "filename",
593 .oval = FILE_LOCK_NONE,
594 .help = "No file locking",
596 { .ival = "exclusive",
597 .oval = FILE_LOCK_EXCLUSIVE,
598 .help = "Exclusive file lock",
602 .oval = FILE_LOCK_READWRITE,
603 .help = "Read vs write lock",
609 .type = FIO_OPT_STR_STORE,
610 .off1 = td_var_offset(opendir),
611 .cb = str_opendir_cb,
612 .help = "Recursively add files from this directory and down",
616 .alias = "readwrite",
619 .off1 = td_var_offset(td_ddir),
620 .help = "IO direction",
624 .oval = TD_DDIR_READ,
625 .help = "Sequential read",
628 .oval = TD_DDIR_WRITE,
629 .help = "Sequential write",
631 { .ival = "randread",
632 .oval = TD_DDIR_RANDREAD,
633 .help = "Random read",
635 { .ival = "randwrite",
636 .oval = TD_DDIR_RANDWRITE,
637 .help = "Random write",
641 .help = "Sequential read and write mix",
644 .oval = TD_DDIR_RANDRW,
645 .help = "Random read and write mix"
651 .type = FIO_OPT_STR_STORE,
652 .off1 = td_var_offset(ioengine),
653 .help = "IO engine to use",
657 .help = "Use read/write",
660 .help = "Use pread/pwrite",
663 .help = "Use readv/writev",
665 #ifdef FIO_HAVE_LIBAIO
667 .help = "Linux native asynchronous IO",
670 #ifdef FIO_HAVE_POSIXAIO
671 { .ival = "posixaio",
672 .help = "POSIX asynchronous IO",
675 #ifdef FIO_HAVE_SOLARISAIO
676 { .ival = "solarisaio",
677 .help = "Solaris native asynchronous IO",
681 .help = "Memory mapped IO",
683 #ifdef FIO_HAVE_SPLICE
685 .help = "splice/vmsplice based IO",
687 { .ival = "netsplice",
688 .help = "splice/vmsplice to/from the network",
693 .help = "SCSI generic v3 IO",
697 .help = "Testing engine (no data transfer)",
700 .help = "Network IO",
702 #ifdef FIO_HAVE_SYSLET
703 { .ival = "syslet-rw",
704 .help = "syslet enabled async pread/pwrite IO",
708 .help = "CPU cycler burner engine",
710 #ifdef FIO_HAVE_GUASI
712 .help = "GUASI IO engine",
715 { .ival = "external",
716 .help = "Load external engine (append name)",
723 .off1 = td_var_offset(iodepth),
724 .help = "Amount of IO buffers to keep in flight",
729 .name = "iodepth_batch",
730 .alias = "iodepth_batch_submit",
732 .off1 = td_var_offset(iodepth_batch),
733 .help = "Number of IO buffers to submit in one go",
739 .name = "iodepth_batch_complete",
741 .off1 = td_var_offset(iodepth_batch_complete),
742 .help = "Number of IO buffers to retrieve in one go",
748 .name = "iodepth_low",
750 .off1 = td_var_offset(iodepth_low),
751 .help = "Low water mark for queuing depth",
756 .type = FIO_OPT_STR_VAL,
757 .off1 = td_var_offset(size),
759 .help = "Total size of device or files",
762 .name = "fill_device",
763 .type = FIO_OPT_BOOL,
764 .off1 = td_var_offset(fill_device),
765 .help = "Write until an ENOSPC error occurs",
770 .type = FIO_OPT_STR_VAL,
771 .off1 = td_var_offset(file_size_low),
772 .off2 = td_var_offset(file_size_high),
774 .help = "Size of individual files",
778 .alias = "fileoffset",
779 .type = FIO_OPT_STR_VAL,
780 .off1 = td_var_offset(start_offset),
781 .help = "Start IO from this offset",
786 .alias = "blocksize",
787 .type = FIO_OPT_STR_VAL_INT,
788 .off1 = td_var_offset(bs[DDIR_READ]),
789 .off2 = td_var_offset(bs[DDIR_WRITE]),
791 .help = "Block size unit",
797 .alias = "blockalign",
798 .type = FIO_OPT_STR_VAL_INT,
799 .off1 = td_var_offset(ba[DDIR_READ]),
800 .off2 = td_var_offset(ba[DDIR_WRITE]),
802 .help = "IO block offset alignment",
807 .alias = "blocksize_range",
808 .type = FIO_OPT_RANGE,
809 .off1 = td_var_offset(min_bs[DDIR_READ]),
810 .off2 = td_var_offset(max_bs[DDIR_READ]),
811 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
812 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
814 .help = "Set block size range (in more detail than bs)",
820 .cb = str_bssplit_cb,
821 .help = "Set a specific mix of block sizes",
825 .name = "bs_unaligned",
826 .alias = "blocksize_unaligned",
827 .type = FIO_OPT_STR_SET,
828 .off1 = td_var_offset(bs_unaligned),
829 .help = "Don't sector align IO buffer sizes",
833 .name = "randrepeat",
834 .type = FIO_OPT_BOOL,
835 .off1 = td_var_offset(rand_repeatable),
836 .help = "Use repeatable random IO pattern",
841 .name = "norandommap",
842 .type = FIO_OPT_STR_SET,
843 .off1 = td_var_offset(norandommap),
844 .help = "Accept potential duplicate random blocks",
848 .name = "softrandommap",
849 .type = FIO_OPT_BOOL,
850 .off1 = td_var_offset(softrandommap),
851 .help = "Set norandommap if randommap allocation fails",
852 .parent = "norandommap",
858 .off1 = td_var_offset(nr_files),
859 .help = "Split job workload between this number of files",
865 .off1 = td_var_offset(open_files),
866 .help = "Number of files to keep open at the same time",
869 .name = "file_service_type",
872 .off1 = td_var_offset(file_service_type),
873 .help = "How to select which file to service next",
877 .oval = FIO_FSERVICE_RANDOM,
878 .help = "Choose a file at random",
880 { .ival = "roundrobin",
881 .oval = FIO_FSERVICE_RR,
882 .help = "Round robin select files",
884 { .ival = "sequential",
885 .oval = FIO_FSERVICE_SEQ,
886 .help = "Finish one file before moving to the next",
892 .name = "fadvise_hint",
893 .type = FIO_OPT_BOOL,
894 .off1 = td_var_offset(fadvise_hint),
895 .help = "Use fadvise() to advise the kernel on IO pattern",
901 .off1 = td_var_offset(fsync_blocks),
902 .help = "Issue fsync for writes every given number of blocks",
907 .type = FIO_OPT_BOOL,
908 .off1 = td_var_offset(odirect),
909 .help = "Use O_DIRECT IO (negates buffered)",
914 .type = FIO_OPT_BOOL,
915 .off1 = td_var_offset(odirect),
917 .help = "Use buffered IO (negates direct)",
922 .type = FIO_OPT_BOOL,
923 .off1 = td_var_offset(overwrite),
924 .help = "When writing, set whether to overwrite current data",
930 .off1 = td_var_offset(loops),
931 .help = "Number of times to run the job",
937 .off1 = td_var_offset(numjobs),
938 .help = "Duplicate this job this many times",
942 .name = "startdelay",
944 .off1 = td_var_offset(start_delay),
945 .help = "Only start job when this period has passed",
951 .type = FIO_OPT_STR_VAL_TIME,
952 .off1 = td_var_offset(timeout),
953 .help = "Stop workload when this amount of time has passed",
957 .name = "time_based",
958 .type = FIO_OPT_STR_SET,
959 .off1 = td_var_offset(time_based),
960 .help = "Keep running until runtime/timeout is met",
964 .type = FIO_OPT_STR_VAL_TIME,
965 .off1 = td_var_offset(ramp_time),
966 .help = "Ramp up time before measuring performance",
973 .off1 = td_var_offset(mem_type),
974 .help = "Backing type for IO buffers",
979 .help = "Use malloc(3) for IO buffers",
983 .help = "Use shared memory segments for IO buffers",
985 #ifdef FIO_HAVE_HUGETLB
988 .help = "Like shm, but use huge pages",
993 .help = "Use mmap(2) (file or anon) for IO buffers",
995 #ifdef FIO_HAVE_HUGETLB
996 { .ival = "mmaphuge",
997 .oval = MEM_MMAPHUGE,
998 .help = "Like mmap, but use huge pages",
1005 .type = FIO_OPT_STR,
1006 .off1 = td_var_offset(verify),
1007 .help = "Verify data written",
1011 .oval = VERIFY_NONE,
1012 .help = "Don't do IO verification",
1016 .help = "Use md5 checksums for verification",
1019 .oval = VERIFY_CRC64,
1020 .help = "Use crc64 checksums for verification",
1023 .oval = VERIFY_CRC32,
1024 .help = "Use crc32 checksums for verification",
1026 { .ival = "crc32c-intel",
1027 .oval = VERIFY_CRC32C_INTEL,
1028 .help = "Use hw crc32c checksums for verification",
1031 .oval = VERIFY_CRC32C,
1032 .help = "Use crc32c checksums for verification",
1035 .oval = VERIFY_CRC16,
1036 .help = "Use crc16 checksums for verification",
1039 .oval = VERIFY_CRC7,
1040 .help = "Use crc7 checksums for verification",
1043 .oval = VERIFY_SHA256,
1044 .help = "Use sha256 checksums for verification",
1047 .oval = VERIFY_SHA512,
1048 .help = "Use sha512 checksums for verification",
1051 .oval = VERIFY_META,
1052 .help = "Use io information",
1056 .oval = VERIFY_NULL,
1057 .help = "Pretend to verify",
1062 .name = "do_verify",
1063 .type = FIO_OPT_BOOL,
1064 .off1 = td_var_offset(do_verify),
1065 .help = "Run verification stage after write",
1070 .name = "verifysort",
1071 .type = FIO_OPT_BOOL,
1072 .off1 = td_var_offset(verifysort),
1073 .help = "Sort written verify blocks for read back",
1078 .name = "verify_interval",
1079 .type = FIO_OPT_STR_VAL_INT,
1080 .off1 = td_var_offset(verify_interval),
1081 .minval = 2 * sizeof(struct verify_header),
1082 .help = "Store verify buffer header every N bytes",
1086 .name = "verify_offset",
1087 .type = FIO_OPT_STR_VAL_INT,
1088 .help = "Offset verify header location by N bytes",
1090 .cb = str_verify_offset_cb,
1094 .name = "verify_pattern",
1095 .type = FIO_OPT_INT,
1096 .cb = str_verify_pattern_cb,
1097 .help = "Fill pattern for IO buffers",
1101 .name = "verify_fatal",
1102 .type = FIO_OPT_BOOL,
1103 .off1 = td_var_offset(verify_fatal),
1105 .help = "Exit on a single verify failure, don't continue",
1109 .name = "write_iolog",
1110 .type = FIO_OPT_STR_STORE,
1111 .off1 = td_var_offset(write_iolog_file),
1112 .help = "Store IO pattern to file",
1115 .name = "read_iolog",
1116 .type = FIO_OPT_STR_STORE,
1117 .off1 = td_var_offset(read_iolog_file),
1118 .help = "Playback IO pattern from file",
1121 .name = "exec_prerun",
1122 .type = FIO_OPT_STR_STORE,
1123 .off1 = td_var_offset(exec_prerun),
1124 .help = "Execute this file prior to running job",
1127 .name = "exec_postrun",
1128 .type = FIO_OPT_STR_STORE,
1129 .off1 = td_var_offset(exec_postrun),
1130 .help = "Execute this file after running job",
1132 #ifdef FIO_HAVE_IOSCHED_SWITCH
1134 .name = "ioscheduler",
1135 .type = FIO_OPT_STR_STORE,
1136 .off1 = td_var_offset(ioscheduler),
1137 .help = "Use this IO scheduler on the backing device",
1142 .type = FIO_OPT_STR_VAL,
1143 .off1 = td_var_offset(zone_size),
1144 .help = "Give size of an IO zone",
1149 .type = FIO_OPT_STR_VAL,
1150 .off1 = td_var_offset(zone_skip),
1151 .help = "Space between IO zones",
1156 .type = FIO_OPT_STR_VAL,
1157 .cb = str_lockmem_cb,
1158 .help = "Lock down this amount of memory",
1162 .name = "rwmixread",
1163 .type = FIO_OPT_INT,
1164 .cb = str_rwmix_read_cb,
1166 .help = "Percentage of mixed workload that is reads",
1170 .name = "rwmixwrite",
1171 .type = FIO_OPT_INT,
1172 .cb = str_rwmix_write_cb,
1174 .help = "Percentage of mixed workload that is writes",
1178 .name = "rwmixcycle",
1179 .type = FIO_OPT_DEPRECATED,
1183 .type = FIO_OPT_INT,
1184 .off1 = td_var_offset(nice),
1185 .help = "Set job CPU nice value",
1190 #ifdef FIO_HAVE_IOPRIO
1193 .type = FIO_OPT_INT,
1195 .help = "Set job IO priority value",
1200 .name = "prioclass",
1201 .type = FIO_OPT_INT,
1202 .cb = str_prioclass_cb,
1203 .help = "Set job IO priority class",
1209 .name = "thinktime",
1210 .type = FIO_OPT_INT,
1211 .off1 = td_var_offset(thinktime),
1212 .help = "Idle time between IO buffers (usec)",
1216 .name = "thinktime_spin",
1217 .type = FIO_OPT_INT,
1218 .off1 = td_var_offset(thinktime_spin),
1219 .help = "Start think time by spinning this amount (usec)",
1221 .parent = "thinktime",
1224 .name = "thinktime_blocks",
1225 .type = FIO_OPT_INT,
1226 .off1 = td_var_offset(thinktime_blocks),
1227 .help = "IO buffer period between 'thinktime'",
1229 .parent = "thinktime",
1233 .type = FIO_OPT_INT,
1234 .off1 = td_var_offset(rate),
1235 .help = "Set bandwidth rate",
1239 .type = FIO_OPT_INT,
1240 .off1 = td_var_offset(ratemin),
1241 .help = "Job must meet this rate or it will be shutdown",
1245 .name = "rate_iops",
1246 .type = FIO_OPT_INT,
1247 .off1 = td_var_offset(rate_iops),
1248 .help = "Limit IO used to this number of IO operations/sec",
1251 .name = "rate_iops_min",
1252 .type = FIO_OPT_INT,
1253 .off1 = td_var_offset(rate_iops_min),
1254 .help = "Job must meet this rate or it will be shutdown",
1255 .parent = "rate_iops",
1258 .name = "ratecycle",
1259 .type = FIO_OPT_INT,
1260 .off1 = td_var_offset(ratecycle),
1261 .help = "Window average for rate limits (msec)",
1266 .name = "invalidate",
1267 .type = FIO_OPT_BOOL,
1268 .off1 = td_var_offset(invalidate_cache),
1269 .help = "Invalidate buffer/page cache prior to running job",
1274 .type = FIO_OPT_BOOL,
1275 .off1 = td_var_offset(sync_io),
1276 .help = "Use O_SYNC for buffered writes",
1278 .parent = "buffered",
1281 .name = "bwavgtime",
1282 .type = FIO_OPT_INT,
1283 .off1 = td_var_offset(bw_avg_time),
1284 .help = "Time window over which to calculate bandwidth"
1289 .name = "create_serialize",
1290 .type = FIO_OPT_BOOL,
1291 .off1 = td_var_offset(create_serialize),
1292 .help = "Serialize creating of job files",
1296 .name = "create_fsync",
1297 .type = FIO_OPT_BOOL,
1298 .off1 = td_var_offset(create_fsync),
1299 .help = "Fsync file after creation",
1303 .name = "create_on_open",
1304 .type = FIO_OPT_BOOL,
1305 .off1 = td_var_offset(create_on_open),
1306 .help = "Create files when they are opened for IO",
1311 .type = FIO_OPT_INT,
1312 .off1 = td_var_offset(cpuload),
1313 .help = "Use this percentage of CPU",
1316 .name = "cpuchunks",
1317 .type = FIO_OPT_INT,
1318 .off1 = td_var_offset(cpucycle),
1319 .help = "Length of the CPU burn cycles (usecs)",
1321 .parent = "cpuload",
1323 #ifdef FIO_HAVE_CPU_AFFINITY
1326 .type = FIO_OPT_INT,
1327 .cb = str_cpumask_cb,
1328 .help = "CPU affinity mask",
1331 .name = "cpus_allowed",
1332 .type = FIO_OPT_STR,
1333 .cb = str_cpus_allowed_cb,
1334 .help = "Set CPUs allowed",
1338 .name = "end_fsync",
1339 .type = FIO_OPT_BOOL,
1340 .off1 = td_var_offset(end_fsync),
1341 .help = "Include fsync at the end of job",
1345 .name = "fsync_on_close",
1346 .type = FIO_OPT_BOOL,
1347 .off1 = td_var_offset(fsync_on_close),
1348 .help = "fsync files on close",
1353 .type = FIO_OPT_BOOL,
1354 .off1 = td_var_offset(unlink),
1355 .help = "Unlink created files after job has completed",
1360 .type = FIO_OPT_STR_SET,
1361 .cb = str_exitall_cb,
1362 .help = "Terminate all jobs when one exits",
1365 .name = "stonewall",
1366 .type = FIO_OPT_STR_SET,
1367 .off1 = td_var_offset(stonewall),
1368 .help = "Insert a hard barrier between this job and previous",
1371 .name = "new_group",
1372 .type = FIO_OPT_STR_SET,
1373 .off1 = td_var_offset(new_group),
1374 .help = "Mark the start of a new group (for reporting)",
1378 .type = FIO_OPT_STR_SET,
1379 .off1 = td_var_offset(use_thread),
1380 .help = "Use threads instead of forks",
1383 .name = "write_bw_log",
1384 .type = FIO_OPT_STR,
1385 .off1 = td_var_offset(write_bw_log),
1386 .cb = str_write_bw_log_cb,
1387 .help = "Write log of bandwidth during run",
1390 .name = "write_lat_log",
1391 .type = FIO_OPT_STR,
1392 .off1 = td_var_offset(write_lat_log),
1393 .cb = str_write_lat_log_cb,
1394 .help = "Write log of latency during run",
1397 .name = "hugepage-size",
1398 .type = FIO_OPT_STR_VAL_INT,
1399 .off1 = td_var_offset(hugepage_size),
1400 .help = "When using hugepages, specify size of each page",
1401 .def = __stringify(FIO_HUGE_PAGE),
1404 .name = "group_reporting",
1405 .type = FIO_OPT_STR_SET,
1406 .off1 = td_var_offset(group_reporting),
1407 .help = "Do reporting on a per-group basis",
1410 .name = "zero_buffers",
1411 .type = FIO_OPT_STR_SET,
1412 .off1 = td_var_offset(zero_buffers),
1413 .help = "Init IO buffers to all zeroes",
1416 .name = "refill_buffers",
1417 .type = FIO_OPT_STR_SET,
1418 .off1 = td_var_offset(refill_buffers),
1419 .help = "Refill IO buffers on every IO submit",
1421 #ifdef FIO_HAVE_DISK_UTIL
1423 .name = "disk_util",
1424 .type = FIO_OPT_BOOL,
1425 .off1 = td_var_offset(do_disk_util),
1426 .help = "Log disk utilization statistics",
1431 .name = "gtod_reduce",
1432 .type = FIO_OPT_BOOL,
1433 .help = "Greatly reduce number of gettimeofday() calls",
1434 .cb = str_gtod_reduce_cb,
1438 .name = "disable_clat",
1439 .type = FIO_OPT_BOOL,
1440 .off1 = td_var_offset(disable_clat),
1441 .help = "Disable completion latency numbers",
1442 .parent = "gtod_reduce",
1446 .name = "disable_slat",
1447 .type = FIO_OPT_BOOL,
1448 .off1 = td_var_offset(disable_slat),
1449 .help = "Disable submissionn latency numbers",
1450 .parent = "gtod_reduce",
1454 .name = "disable_bw_measurement",
1455 .type = FIO_OPT_BOOL,
1456 .off1 = td_var_offset(disable_bw),
1457 .help = "Disable bandwidth logging",
1458 .parent = "gtod_reduce",
1463 .type = FIO_OPT_INT,
1464 .cb = str_gtod_cpu_cb,
1465 .help = "Setup dedicated gettimeofday() thread on this CPU",
1472 void fio_options_dup_and_init(struct option *long_options)
1474 struct fio_option *o;
1477 options_init(options);
1480 while (long_options[i].name)
1485 long_options[i].name = (char *) o->name;
1486 long_options[i].val = FIO_GETOPT_JOB;
1487 if (o->type == FIO_OPT_STR_SET)
1488 long_options[i].has_arg = no_argument;
1490 long_options[i].has_arg = required_argument;
1494 assert(i < FIO_NR_OPTIONS);
1498 int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
1502 sort_options(opts, options, num_opts);
1504 for (ret = 0, i = 0; i < num_opts; i++)
1505 ret |= parse_option(opts[i], options, td);
1510 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
1512 return parse_cmd_option(opt, val, options, td);
1515 void fio_fill_default_options(struct thread_data *td)
1517 fill_default_options(td, options);
1520 int fio_show_option_help(const char *opt)
1522 return show_cmd_help(options, opt);
1525 static void __options_mem(struct thread_data *td, int alloc)
1527 struct thread_options *o = &td->o;
1528 struct fio_option *opt;
1532 for (i = 0, opt = &options[0]; opt->name; i++, opt = &options[i]) {
1533 if (opt->type != FIO_OPT_STR_STORE)
1536 ptr = (void *) o + opt->off1;
1539 *ptr = strdup(*ptr);
1549 * dupe FIO_OPT_STR_STORE options
1551 void options_mem_dupe(struct thread_data *td)
1553 __options_mem(td, 1);
1556 void options_mem_free(struct thread_data fio_unused *td)
1559 __options_mem(td, 0);