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;
250 CPU_ZERO(&td->o.cpumask);
252 for (i = 0; i < sizeof(int) * 8; i++) {
253 if ((1 << i) & *val) {
254 dprint(FD_PARSE, "set cpu allowed %d\n", i);
255 CPU_SET(*val, &td->o.cpumask);
259 td->o.cpumask_set = 1;
263 static int str_cpus_allowed_cb(void *data, const char *input)
265 struct thread_data *td = data;
268 CPU_ZERO(&td->o.cpumask);
270 p = str = strdup(input);
272 strip_blank_front(&str);
273 strip_blank_end(str);
275 while ((cpu = strsep(&str, ",")) != NULL) {
284 while ((cpu2 = strsep(&str2, "-")) != NULL) {
294 while (icpu <= icpu2) {
295 dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
296 CPU_SET(atoi(cpu), &td->o.cpumask);
302 td->o.cpumask_set = 1;
307 static int str_fst_cb(void *data, const char *str)
309 struct thread_data *td = data;
310 char *nr = get_opt_postfix(str);
312 td->file_service_nr = 1;
314 td->file_service_nr = atoi(nr);
321 static int check_dir(struct thread_data *td, char *fname)
323 char file[PATH_MAX], *dir;
326 if (td->o.directory) {
327 strcpy(file, td->o.directory);
332 sprintf(file + elen, "%s", fname);
339 * We can't do this on FIO_DISKLESSIO engines. The engine isn't loaded
340 * yet, so we can't do this check right here...
342 if (lstat(dir, &sb) < 0) {
345 log_err("fio: %s is not a directory\n", dir);
346 td_verror(td, ret, "lstat");
350 if (!S_ISDIR(sb.st_mode)) {
351 log_err("fio: %s is not a directory\n", dir);
360 static int str_filename_cb(void *data, const char *input)
362 struct thread_data *td = data;
363 char *fname, *str, *p;
365 p = str = strdup(input);
367 strip_blank_front(&str);
368 strip_blank_end(str);
370 if (!td->files_index)
373 while ((fname = strsep(&str, ":")) != NULL) {
376 if (check_dir(td, fname)) {
388 static int str_directory_cb(void *data, const char fio_unused *str)
390 struct thread_data *td = data;
393 if (lstat(td->o.directory, &sb) < 0) {
396 log_err("fio: %s is not a directory\n", td->o.directory);
397 td_verror(td, ret, "lstat");
400 if (!S_ISDIR(sb.st_mode)) {
401 log_err("fio: %s is not a directory\n", td->o.directory);
408 static int str_opendir_cb(void *data, const char fio_unused *str)
410 struct thread_data *td = data;
412 if (!td->files_index)
415 return add_dir_files(td, td->o.opendir);
418 static int str_verify_offset_cb(void *data, unsigned int *off)
420 struct thread_data *td = data;
422 if (*off && *off < sizeof(struct verify_header)) {
423 log_err("fio: verify_offset too small\n");
427 td->o.verify_offset = *off;
431 static int str_verify_pattern_cb(void *data, unsigned int *off)
433 struct thread_data *td = data;
438 td->o.verify_pattern_bytes = 1;
440 td->o.verify_pattern_bytes = 2;
442 td->o.verify_pattern_bytes = 3;
444 td->o.verify_pattern_bytes = 4;
446 td->o.verify_pattern = *off;
450 static int str_lockfile_cb(void *data, const char *str)
452 struct thread_data *td = data;
453 char *nr = get_opt_postfix(str);
455 td->o.lockfile_batch = 1;
457 td->o.lockfile_batch = atoi(nr);
464 static int str_write_bw_log_cb(void *data, const char *str)
466 struct thread_data *td = data;
469 td->o.bw_log_file = strdup(str);
471 td->o.write_bw_log = 1;
475 static int str_write_lat_log_cb(void *data, const char *str)
477 struct thread_data *td = data;
480 td->o.lat_log_file = strdup(str);
482 td->o.write_lat_log = 1;
486 static int str_gtod_reduce_cb(void *data, int *il)
488 struct thread_data *td = data;
491 td->o.disable_clat = !!val;
492 td->o.disable_slat = !!val;
493 td->o.disable_bw = !!val;
495 td->tv_cache_mask = 63;
500 static int str_gtod_cpu_cb(void *data, int *il)
502 struct thread_data *td = data;
505 td->o.gtod_cpu = val;
506 td->o.gtod_offload = 1;
510 #define __stringify_1(x) #x
511 #define __stringify(x) __stringify_1(x)
514 * Map of job/command line options
516 static struct fio_option options[] = {
518 .name = "description",
519 .type = FIO_OPT_STR_STORE,
520 .off1 = td_var_offset(description),
521 .help = "Text job description",
525 .type = FIO_OPT_STR_STORE,
526 .off1 = td_var_offset(name),
527 .help = "Name of this job",
531 .type = FIO_OPT_STR_STORE,
532 .off1 = td_var_offset(directory),
533 .cb = str_directory_cb,
534 .help = "Directory to store files in",
538 .type = FIO_OPT_STR_STORE,
539 .off1 = td_var_offset(filename),
540 .cb = str_filename_cb,
541 .prio = 1, /* must come before "directory" */
542 .help = "File(s) to use for the workload",
547 .cb = str_lockfile_cb,
548 .off1 = td_var_offset(file_lock_mode),
549 .help = "Lock file when doing IO to it",
550 .parent = "filename",
554 .oval = FILE_LOCK_NONE,
555 .help = "No file locking",
557 { .ival = "exclusive",
558 .oval = FILE_LOCK_EXCLUSIVE,
559 .help = "Exclusive file lock",
563 .oval = FILE_LOCK_READWRITE,
564 .help = "Read vs write lock",
570 .type = FIO_OPT_STR_STORE,
571 .off1 = td_var_offset(opendir),
572 .cb = str_opendir_cb,
573 .help = "Recursively add files from this directory and down",
577 .alias = "readwrite",
580 .off1 = td_var_offset(td_ddir),
581 .help = "IO direction",
585 .oval = TD_DDIR_READ,
586 .help = "Sequential read",
589 .oval = TD_DDIR_WRITE,
590 .help = "Sequential write",
592 { .ival = "randread",
593 .oval = TD_DDIR_RANDREAD,
594 .help = "Random read",
596 { .ival = "randwrite",
597 .oval = TD_DDIR_RANDWRITE,
598 .help = "Random write",
602 .help = "Sequential read and write mix",
605 .oval = TD_DDIR_RANDRW,
606 .help = "Random read and write mix"
612 .type = FIO_OPT_STR_STORE,
613 .off1 = td_var_offset(ioengine),
614 .help = "IO engine to use",
618 .help = "Use read/write",
621 .help = "Use pread/pwrite",
624 .help = "Use readv/writev",
626 #ifdef FIO_HAVE_LIBAIO
628 .help = "Linux native asynchronous IO",
631 #ifdef FIO_HAVE_POSIXAIO
632 { .ival = "posixaio",
633 .help = "POSIX asynchronous IO",
636 #ifdef FIO_HAVE_SOLARISAIO
637 { .ival = "solarisaio",
638 .help = "Solaris native asynchronous IO",
642 .help = "Memory mapped IO",
644 #ifdef FIO_HAVE_SPLICE
646 .help = "splice/vmsplice based IO",
648 { .ival = "netsplice",
649 .help = "splice/vmsplice to/from the network",
654 .help = "SCSI generic v3 IO",
658 .help = "Testing engine (no data transfer)",
661 .help = "Network IO",
663 #ifdef FIO_HAVE_SYSLET
664 { .ival = "syslet-rw",
665 .help = "syslet enabled async pread/pwrite IO",
669 .help = "CPU cycler burner engine",
671 #ifdef FIO_HAVE_GUASI
673 .help = "GUASI IO engine",
676 { .ival = "external",
677 .help = "Load external engine (append name)",
684 .off1 = td_var_offset(iodepth),
685 .help = "Amount of IO buffers to keep in flight",
690 .name = "iodepth_batch",
691 .alias = "iodepth_batch_submit",
693 .off1 = td_var_offset(iodepth_batch),
694 .help = "Number of IO to submit in one go",
700 .name = "iodepth_batch_complete",
702 .off1 = td_var_offset(iodepth_batch_complete),
703 .help = "Number of IO to retrieve in one go",
709 .name = "iodepth_low",
711 .off1 = td_var_offset(iodepth_low),
712 .help = "Low water mark for queuing depth",
717 .type = FIO_OPT_STR_VAL,
718 .off1 = td_var_offset(size),
720 .help = "Total size of device or files",
723 .name = "fill_device",
724 .type = FIO_OPT_BOOL,
725 .off1 = td_var_offset(fill_device),
726 .help = "Write until an ENOSPC error occurs",
731 .type = FIO_OPT_STR_VAL,
732 .off1 = td_var_offset(file_size_low),
733 .off2 = td_var_offset(file_size_high),
735 .help = "Size of individual files",
739 .alias = "fileoffset",
740 .type = FIO_OPT_STR_VAL,
741 .off1 = td_var_offset(start_offset),
742 .help = "Start IO from this offset",
747 .alias = "blocksize",
748 .type = FIO_OPT_STR_VAL_INT,
749 .off1 = td_var_offset(bs[DDIR_READ]),
750 .off2 = td_var_offset(bs[DDIR_WRITE]),
752 .help = "Block size unit",
758 .alias = "blocksize_range",
759 .type = FIO_OPT_RANGE,
760 .off1 = td_var_offset(min_bs[DDIR_READ]),
761 .off2 = td_var_offset(max_bs[DDIR_READ]),
762 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
763 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
765 .help = "Set block size range (in more detail than bs)",
771 .cb = str_bssplit_cb,
772 .help = "Set a specific mix of block sizes",
776 .name = "bs_unaligned",
777 .alias = "blocksize_unaligned",
778 .type = FIO_OPT_STR_SET,
779 .off1 = td_var_offset(bs_unaligned),
780 .help = "Don't sector align IO buffer sizes",
784 .name = "randrepeat",
785 .type = FIO_OPT_BOOL,
786 .off1 = td_var_offset(rand_repeatable),
787 .help = "Use repeatable random IO pattern",
792 .name = "norandommap",
793 .type = FIO_OPT_STR_SET,
794 .off1 = td_var_offset(norandommap),
795 .help = "Accept potential duplicate random blocks",
799 .name = "softrandommap",
800 .type = FIO_OPT_BOOL,
801 .off1 = td_var_offset(softrandommap),
802 .help = "Set norandommap if randommap allocation fails",
803 .parent = "norandommap",
809 .off1 = td_var_offset(nr_files),
810 .help = "Split job workload between this number of files",
816 .off1 = td_var_offset(open_files),
817 .help = "Number of files to keep open at the same time",
820 .name = "file_service_type",
823 .off1 = td_var_offset(file_service_type),
824 .help = "How to select which file to service next",
828 .oval = FIO_FSERVICE_RANDOM,
829 .help = "Choose a file at random",
831 { .ival = "roundrobin",
832 .oval = FIO_FSERVICE_RR,
833 .help = "Round robin select files",
839 .name = "fadvise_hint",
840 .type = FIO_OPT_BOOL,
841 .off1 = td_var_offset(fadvise_hint),
842 .help = "Use fadvise() to advise the kernel on IO pattern",
848 .off1 = td_var_offset(fsync_blocks),
849 .help = "Issue fsync for writes every given number of blocks",
854 .type = FIO_OPT_BOOL,
855 .off1 = td_var_offset(odirect),
856 .help = "Use O_DIRECT IO (negates buffered)",
861 .type = FIO_OPT_BOOL,
862 .off1 = td_var_offset(odirect),
864 .help = "Use buffered IO (negates direct)",
869 .type = FIO_OPT_BOOL,
870 .off1 = td_var_offset(overwrite),
871 .help = "When writing, set whether to overwrite current data",
877 .off1 = td_var_offset(loops),
878 .help = "Number of times to run the job",
884 .off1 = td_var_offset(numjobs),
885 .help = "Duplicate this job this many times",
889 .name = "startdelay",
891 .off1 = td_var_offset(start_delay),
892 .help = "Only start job when this period has passed",
898 .type = FIO_OPT_STR_VAL_TIME,
899 .off1 = td_var_offset(timeout),
900 .help = "Stop workload when this amount of time has passed",
904 .name = "time_based",
905 .type = FIO_OPT_STR_SET,
906 .off1 = td_var_offset(time_based),
907 .help = "Keep running until runtime/timeout is met",
911 .type = FIO_OPT_STR_VAL_TIME,
912 .off1 = td_var_offset(ramp_time),
913 .help = "Ramp up time before measuring performance",
920 .off1 = td_var_offset(mem_type),
921 .help = "Backing type for IO buffers",
926 .help = "Use malloc(3) for IO buffers",
930 .help = "Use shared memory segments for IO buffers",
932 #ifdef FIO_HAVE_HUGETLB
935 .help = "Like shm, but use huge pages",
940 .help = "Use mmap(2) (file or anon) for IO buffers",
942 #ifdef FIO_HAVE_HUGETLB
943 { .ival = "mmaphuge",
944 .oval = MEM_MMAPHUGE,
945 .help = "Like mmap, but use huge pages",
953 .off1 = td_var_offset(verify),
954 .help = "Verify data written",
959 .help = "Don't do IO verification",
963 .help = "Use md5 checksums for verification",
966 .oval = VERIFY_CRC64,
967 .help = "Use crc64 checksums for verification",
970 .oval = VERIFY_CRC32,
971 .help = "Use crc32 checksums for verification",
973 { .ival = "crc32c-intel",
974 .oval = VERIFY_CRC32C_INTEL,
975 .help = "Use hw crc32c checksums for verification",
978 .oval = VERIFY_CRC32C,
979 .help = "Use crc32c checksums for verification",
982 .oval = VERIFY_CRC16,
983 .help = "Use crc16 checksums for verification",
987 .help = "Use crc7 checksums for verification",
990 .oval = VERIFY_SHA256,
991 .help = "Use sha256 checksums for verification",
994 .oval = VERIFY_SHA512,
995 .help = "Use sha512 checksums for verification",
999 .help = "Use io information",
1003 .oval = VERIFY_NULL,
1004 .help = "Pretend to verify",
1009 .name = "do_verify",
1010 .type = FIO_OPT_BOOL,
1011 .off1 = td_var_offset(do_verify),
1012 .help = "Run verification stage after write",
1017 .name = "verifysort",
1018 .type = FIO_OPT_BOOL,
1019 .off1 = td_var_offset(verifysort),
1020 .help = "Sort written verify blocks for read back",
1025 .name = "verify_interval",
1026 .type = FIO_OPT_STR_VAL_INT,
1027 .off1 = td_var_offset(verify_interval),
1028 .minval = 2 * sizeof(struct verify_header),
1029 .help = "Store verify buffer header every N bytes",
1033 .name = "verify_offset",
1034 .type = FIO_OPT_STR_VAL_INT,
1035 .help = "Offset verify header location by N bytes",
1037 .cb = str_verify_offset_cb,
1041 .name = "verify_pattern",
1042 .type = FIO_OPT_INT,
1043 .cb = str_verify_pattern_cb,
1044 .help = "Fill pattern for IO buffers",
1048 .name = "verify_fatal",
1049 .type = FIO_OPT_BOOL,
1050 .off1 = td_var_offset(verify_fatal),
1052 .help = "Exit on a single verify failure, don't continue",
1056 .name = "write_iolog",
1057 .type = FIO_OPT_STR_STORE,
1058 .off1 = td_var_offset(write_iolog_file),
1059 .help = "Store IO pattern to file",
1062 .name = "read_iolog",
1063 .type = FIO_OPT_STR_STORE,
1064 .off1 = td_var_offset(read_iolog_file),
1065 .help = "Playback IO pattern from file",
1068 .name = "exec_prerun",
1069 .type = FIO_OPT_STR_STORE,
1070 .off1 = td_var_offset(exec_prerun),
1071 .help = "Execute this file prior to running job",
1074 .name = "exec_postrun",
1075 .type = FIO_OPT_STR_STORE,
1076 .off1 = td_var_offset(exec_postrun),
1077 .help = "Execute this file after running job",
1079 #ifdef FIO_HAVE_IOSCHED_SWITCH
1081 .name = "ioscheduler",
1082 .type = FIO_OPT_STR_STORE,
1083 .off1 = td_var_offset(ioscheduler),
1084 .help = "Use this IO scheduler on the backing device",
1089 .type = FIO_OPT_STR_VAL,
1090 .off1 = td_var_offset(zone_size),
1091 .help = "Give size of an IO zone",
1096 .type = FIO_OPT_STR_VAL,
1097 .off1 = td_var_offset(zone_skip),
1098 .help = "Space between IO zones",
1103 .type = FIO_OPT_STR_VAL,
1104 .cb = str_lockmem_cb,
1105 .help = "Lock down this amount of memory",
1109 .name = "rwmixread",
1110 .type = FIO_OPT_INT,
1111 .cb = str_rwmix_read_cb,
1113 .help = "Percentage of mixed workload that is reads",
1117 .name = "rwmixwrite",
1118 .type = FIO_OPT_INT,
1119 .cb = str_rwmix_write_cb,
1121 .help = "Percentage of mixed workload that is writes",
1125 .name = "rwmixcycle",
1126 .type = FIO_OPT_DEPRECATED,
1130 .type = FIO_OPT_INT,
1131 .off1 = td_var_offset(nice),
1132 .help = "Set job CPU nice value",
1137 #ifdef FIO_HAVE_IOPRIO
1140 .type = FIO_OPT_INT,
1142 .help = "Set job IO priority value",
1147 .name = "prioclass",
1148 .type = FIO_OPT_INT,
1149 .cb = str_prioclass_cb,
1150 .help = "Set job IO priority class",
1156 .name = "thinktime",
1157 .type = FIO_OPT_INT,
1158 .off1 = td_var_offset(thinktime),
1159 .help = "Idle time between IO buffers (usec)",
1163 .name = "thinktime_spin",
1164 .type = FIO_OPT_INT,
1165 .off1 = td_var_offset(thinktime_spin),
1166 .help = "Start think time by spinning this amount (usec)",
1168 .parent = "thinktime",
1171 .name = "thinktime_blocks",
1172 .type = FIO_OPT_INT,
1173 .off1 = td_var_offset(thinktime_blocks),
1174 .help = "IO buffer period between 'thinktime'",
1176 .parent = "thinktime",
1180 .type = FIO_OPT_INT,
1181 .off1 = td_var_offset(rate),
1182 .help = "Set bandwidth rate",
1186 .type = FIO_OPT_INT,
1187 .off1 = td_var_offset(ratemin),
1188 .help = "Job must meet this rate or it will be shutdown",
1192 .name = "rate_iops",
1193 .type = FIO_OPT_INT,
1194 .off1 = td_var_offset(rate_iops),
1195 .help = "Limit IO used to this number of IO operations/sec",
1198 .name = "rate_iops_min",
1199 .type = FIO_OPT_INT,
1200 .off1 = td_var_offset(rate_iops_min),
1201 .help = "Job must meet this rate or it will be shutdown",
1202 .parent = "rate_iops",
1205 .name = "ratecycle",
1206 .type = FIO_OPT_INT,
1207 .off1 = td_var_offset(ratecycle),
1208 .help = "Window average for rate limits (msec)",
1213 .name = "invalidate",
1214 .type = FIO_OPT_BOOL,
1215 .off1 = td_var_offset(invalidate_cache),
1216 .help = "Invalidate buffer/page cache prior to running job",
1221 .type = FIO_OPT_BOOL,
1222 .off1 = td_var_offset(sync_io),
1223 .help = "Use O_SYNC for buffered writes",
1225 .parent = "buffered",
1228 .name = "bwavgtime",
1229 .type = FIO_OPT_INT,
1230 .off1 = td_var_offset(bw_avg_time),
1231 .help = "Time window over which to calculate bandwidth"
1236 .name = "create_serialize",
1237 .type = FIO_OPT_BOOL,
1238 .off1 = td_var_offset(create_serialize),
1239 .help = "Serialize creating of job files",
1243 .name = "create_fsync",
1244 .type = FIO_OPT_BOOL,
1245 .off1 = td_var_offset(create_fsync),
1246 .help = "Fsync file after creation",
1251 .type = FIO_OPT_INT,
1252 .off1 = td_var_offset(cpuload),
1253 .help = "Use this percentage of CPU",
1256 .name = "cpuchunks",
1257 .type = FIO_OPT_INT,
1258 .off1 = td_var_offset(cpucycle),
1259 .help = "Length of the CPU burn cycles (usecs)",
1261 .parent = "cpuload",
1263 #ifdef FIO_HAVE_CPU_AFFINITY
1266 .type = FIO_OPT_INT,
1267 .cb = str_cpumask_cb,
1268 .help = "CPU affinity mask",
1271 .name = "cpus_allowed",
1272 .type = FIO_OPT_STR,
1273 .cb = str_cpus_allowed_cb,
1274 .help = "Set CPUs allowed",
1278 .name = "end_fsync",
1279 .type = FIO_OPT_BOOL,
1280 .off1 = td_var_offset(end_fsync),
1281 .help = "Include fsync at the end of job",
1285 .name = "fsync_on_close",
1286 .type = FIO_OPT_BOOL,
1287 .off1 = td_var_offset(fsync_on_close),
1288 .help = "fsync files on close",
1293 .type = FIO_OPT_BOOL,
1294 .off1 = td_var_offset(unlink),
1295 .help = "Unlink created files after job has completed",
1300 .type = FIO_OPT_STR_SET,
1301 .cb = str_exitall_cb,
1302 .help = "Terminate all jobs when one exits",
1305 .name = "stonewall",
1306 .type = FIO_OPT_STR_SET,
1307 .off1 = td_var_offset(stonewall),
1308 .help = "Insert a hard barrier between this job and previous",
1311 .name = "new_group",
1312 .type = FIO_OPT_STR_SET,
1313 .off1 = td_var_offset(new_group),
1314 .help = "Mark the start of a new group (for reporting)",
1318 .type = FIO_OPT_STR_SET,
1319 .off1 = td_var_offset(use_thread),
1320 .help = "Use threads instead of forks",
1323 .name = "write_bw_log",
1324 .type = FIO_OPT_STR,
1325 .off1 = td_var_offset(write_bw_log),
1326 .cb = str_write_bw_log_cb,
1327 .help = "Write log of bandwidth during run",
1330 .name = "write_lat_log",
1331 .type = FIO_OPT_STR,
1332 .off1 = td_var_offset(write_lat_log),
1333 .cb = str_write_lat_log_cb,
1334 .help = "Write log of latency during run",
1337 .name = "hugepage-size",
1338 .type = FIO_OPT_STR_VAL_INT,
1339 .off1 = td_var_offset(hugepage_size),
1340 .help = "When using hugepages, specify size of each page",
1341 .def = __stringify(FIO_HUGE_PAGE),
1344 .name = "group_reporting",
1345 .type = FIO_OPT_STR_SET,
1346 .off1 = td_var_offset(group_reporting),
1347 .help = "Do reporting on a per-group basis",
1350 .name = "zero_buffers",
1351 .type = FIO_OPT_STR_SET,
1352 .off1 = td_var_offset(zero_buffers),
1353 .help = "Init IO buffers to all zeroes",
1356 .name = "refill_buffers",
1357 .type = FIO_OPT_STR_SET,
1358 .off1 = td_var_offset(refill_buffers),
1359 .help = "Refill IO buffers on every IO submit",
1361 #ifdef FIO_HAVE_DISK_UTIL
1363 .name = "disk_util",
1364 .type = FIO_OPT_BOOL,
1365 .off1 = td_var_offset(do_disk_util),
1366 .help = "Log disk utilization statistics",
1371 .name = "gtod_reduce",
1372 .type = FIO_OPT_BOOL,
1373 .help = "Greatly reduce number of gettimeofday() calls",
1374 .cb = str_gtod_reduce_cb,
1378 .name = "disable_clat",
1379 .type = FIO_OPT_BOOL,
1380 .off1 = td_var_offset(disable_clat),
1381 .help = "Disable completion latency numbers",
1382 .parent = "gtod_reduce",
1386 .name = "disable_slat",
1387 .type = FIO_OPT_BOOL,
1388 .off1 = td_var_offset(disable_slat),
1389 .help = "Disable submissionn latency numbers",
1390 .parent = "gtod_reduce",
1394 .name = "disable_bw_measurement",
1395 .type = FIO_OPT_BOOL,
1396 .off1 = td_var_offset(disable_bw),
1397 .help = "Disable bandwidth logging",
1398 .parent = "gtod_reduce",
1403 .type = FIO_OPT_INT,
1404 .cb = str_gtod_cpu_cb,
1405 .help = "Setup dedicated gettimeofday() thread on this CPU",
1412 void fio_options_dup_and_init(struct option *long_options)
1414 struct fio_option *o;
1417 options_init(options);
1420 while (long_options[i].name)
1425 long_options[i].name = (char *) o->name;
1426 long_options[i].val = FIO_GETOPT_JOB;
1427 if (o->type == FIO_OPT_STR_SET)
1428 long_options[i].has_arg = no_argument;
1430 long_options[i].has_arg = required_argument;
1434 assert(i < FIO_NR_OPTIONS);
1438 int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
1442 sort_options(opts, options, num_opts);
1444 for (ret = 0, i = 0; i < num_opts; i++)
1445 ret |= parse_option(opts[i], options, td);
1450 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
1452 return parse_cmd_option(opt, val, options, td);
1455 void fio_fill_default_options(struct thread_data *td)
1457 fill_default_options(td, options);
1460 int fio_show_option_help(const char *opt)
1462 return show_cmd_help(options, opt);
1465 static void __options_mem(struct thread_data *td, int alloc)
1467 struct thread_options *o = &td->o;
1468 struct fio_option *opt;
1472 for (i = 0, opt = &options[0]; opt->name; i++, opt = &options[i]) {
1473 if (opt->type != FIO_OPT_STR_STORE)
1476 ptr = (void *) o + opt->off1;
1479 *ptr = strdup(*ptr);
1489 * dupe FIO_OPT_STR_STORE options
1491 void options_mem_dupe(struct thread_data *td)
1493 __options_mem(td, 1);
1496 void options_mem_free(struct thread_data fio_unused *td)
1499 __options_mem(td, 0);