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 #define __stringify_1(x) #x
501 #define __stringify(x) __stringify_1(x)
504 * Map of job/command line options
506 static struct fio_option options[] = {
508 .name = "description",
509 .type = FIO_OPT_STR_STORE,
510 .off1 = td_var_offset(description),
511 .help = "Text job description",
515 .type = FIO_OPT_STR_STORE,
516 .off1 = td_var_offset(name),
517 .help = "Name of this job",
521 .type = FIO_OPT_STR_STORE,
522 .off1 = td_var_offset(directory),
523 .cb = str_directory_cb,
524 .help = "Directory to store files in",
528 .type = FIO_OPT_STR_STORE,
529 .off1 = td_var_offset(filename),
530 .cb = str_filename_cb,
531 .prio = 1, /* must come before "directory" */
532 .help = "File(s) to use for the workload",
537 .cb = str_lockfile_cb,
538 .off1 = td_var_offset(file_lock_mode),
539 .help = "Lock file when doing IO to it",
540 .parent = "filename",
544 .oval = FILE_LOCK_NONE,
545 .help = "No file locking",
547 { .ival = "exclusive",
548 .oval = FILE_LOCK_EXCLUSIVE,
549 .help = "Exclusive file lock",
553 .oval = FILE_LOCK_READWRITE,
554 .help = "Read vs write lock",
560 .type = FIO_OPT_STR_STORE,
561 .off1 = td_var_offset(opendir),
562 .cb = str_opendir_cb,
563 .help = "Recursively add files from this directory and down",
567 .alias = "readwrite",
570 .off1 = td_var_offset(td_ddir),
571 .help = "IO direction",
575 .oval = TD_DDIR_READ,
576 .help = "Sequential read",
579 .oval = TD_DDIR_WRITE,
580 .help = "Sequential write",
582 { .ival = "randread",
583 .oval = TD_DDIR_RANDREAD,
584 .help = "Random read",
586 { .ival = "randwrite",
587 .oval = TD_DDIR_RANDWRITE,
588 .help = "Random write",
592 .help = "Sequential read and write mix",
595 .oval = TD_DDIR_RANDRW,
596 .help = "Random read and write mix"
602 .type = FIO_OPT_STR_STORE,
603 .off1 = td_var_offset(ioengine),
604 .help = "IO engine to use",
608 .help = "Use read/write",
611 .help = "Use pread/pwrite",
614 .help = "Use readv/writev",
616 #ifdef FIO_HAVE_LIBAIO
618 .help = "Linux native asynchronous IO",
621 #ifdef FIO_HAVE_POSIXAIO
622 { .ival = "posixaio",
623 .help = "POSIX asynchronous IO",
626 #ifdef FIO_HAVE_SOLARISAIO
627 { .ival = "solarisaio",
628 .help = "Solaris native asynchronous IO",
632 .help = "Memory mapped IO",
634 #ifdef FIO_HAVE_SPLICE
636 .help = "splice/vmsplice based IO",
638 { .ival = "netsplice",
639 .help = "splice/vmsplice to/from the network",
644 .help = "SCSI generic v3 IO",
648 .help = "Testing engine (no data transfer)",
651 .help = "Network IO",
653 #ifdef FIO_HAVE_SYSLET
654 { .ival = "syslet-rw",
655 .help = "syslet enabled async pread/pwrite IO",
659 .help = "CPU cycler burner engine",
661 #ifdef FIO_HAVE_GUASI
663 .help = "GUASI IO engine",
666 { .ival = "external",
667 .help = "Load external engine (append name)",
674 .off1 = td_var_offset(iodepth),
675 .help = "Amount of IO buffers to keep in flight",
680 .name = "iodepth_batch",
681 .alias = "iodepth_batch_submit",
683 .off1 = td_var_offset(iodepth_batch),
684 .help = "Number of IO to submit in one go",
690 .name = "iodepth_batch_complete",
692 .off1 = td_var_offset(iodepth_batch_complete),
693 .help = "Number of IO to retrieve in one go",
699 .name = "iodepth_low",
701 .off1 = td_var_offset(iodepth_low),
702 .help = "Low water mark for queuing depth",
707 .type = FIO_OPT_STR_VAL,
708 .off1 = td_var_offset(size),
710 .help = "Total size of device or files",
713 .name = "fill_device",
714 .type = FIO_OPT_BOOL,
715 .off1 = td_var_offset(fill_device),
716 .help = "Write until an ENOSPC error occurs",
721 .type = FIO_OPT_STR_VAL,
722 .off1 = td_var_offset(file_size_low),
723 .off2 = td_var_offset(file_size_high),
725 .help = "Size of individual files",
729 .alias = "fileoffset",
730 .type = FIO_OPT_STR_VAL,
731 .off1 = td_var_offset(start_offset),
732 .help = "Start IO from this offset",
737 .alias = "blocksize",
738 .type = FIO_OPT_STR_VAL_INT,
739 .off1 = td_var_offset(bs[DDIR_READ]),
740 .off2 = td_var_offset(bs[DDIR_WRITE]),
742 .help = "Block size unit",
748 .alias = "blocksize_range",
749 .type = FIO_OPT_RANGE,
750 .off1 = td_var_offset(min_bs[DDIR_READ]),
751 .off2 = td_var_offset(max_bs[DDIR_READ]),
752 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
753 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
755 .help = "Set block size range (in more detail than bs)",
761 .cb = str_bssplit_cb,
762 .help = "Set a specific mix of block sizes",
766 .name = "bs_unaligned",
767 .alias = "blocksize_unaligned",
768 .type = FIO_OPT_STR_SET,
769 .off1 = td_var_offset(bs_unaligned),
770 .help = "Don't sector align IO buffer sizes",
774 .name = "randrepeat",
775 .type = FIO_OPT_BOOL,
776 .off1 = td_var_offset(rand_repeatable),
777 .help = "Use repeatable random IO pattern",
782 .name = "norandommap",
783 .type = FIO_OPT_STR_SET,
784 .off1 = td_var_offset(norandommap),
785 .help = "Accept potential duplicate random blocks",
789 .name = "softrandommap",
790 .type = FIO_OPT_BOOL,
791 .off1 = td_var_offset(softrandommap),
792 .help = "Set norandommap if randommap allocation fails",
793 .parent = "norandommap",
799 .off1 = td_var_offset(nr_files),
800 .help = "Split job workload between this number of files",
806 .off1 = td_var_offset(open_files),
807 .help = "Number of files to keep open at the same time",
810 .name = "file_service_type",
813 .off1 = td_var_offset(file_service_type),
814 .help = "How to select which file to service next",
818 .oval = FIO_FSERVICE_RANDOM,
819 .help = "Choose a file at random",
821 { .ival = "roundrobin",
822 .oval = FIO_FSERVICE_RR,
823 .help = "Round robin select files",
829 .name = "fadvise_hint",
830 .type = FIO_OPT_BOOL,
831 .off1 = td_var_offset(fadvise_hint),
832 .help = "Use fadvise() to advise the kernel on IO pattern",
838 .off1 = td_var_offset(fsync_blocks),
839 .help = "Issue fsync for writes every given number of blocks",
844 .type = FIO_OPT_BOOL,
845 .off1 = td_var_offset(odirect),
846 .help = "Use O_DIRECT IO (negates buffered)",
851 .type = FIO_OPT_BOOL,
852 .off1 = td_var_offset(odirect),
854 .help = "Use buffered IO (negates direct)",
859 .type = FIO_OPT_BOOL,
860 .off1 = td_var_offset(overwrite),
861 .help = "When writing, set whether to overwrite current data",
867 .off1 = td_var_offset(loops),
868 .help = "Number of times to run the job",
874 .off1 = td_var_offset(numjobs),
875 .help = "Duplicate this job this many times",
879 .name = "startdelay",
881 .off1 = td_var_offset(start_delay),
882 .help = "Only start job when this period has passed",
888 .type = FIO_OPT_STR_VAL_TIME,
889 .off1 = td_var_offset(timeout),
890 .help = "Stop workload when this amount of time has passed",
894 .name = "time_based",
895 .type = FIO_OPT_STR_SET,
896 .off1 = td_var_offset(time_based),
897 .help = "Keep running until runtime/timeout is met",
901 .type = FIO_OPT_STR_VAL_TIME,
902 .off1 = td_var_offset(ramp_time),
903 .help = "Ramp up time before measuring performance",
910 .off1 = td_var_offset(mem_type),
911 .help = "Backing type for IO buffers",
916 .help = "Use malloc(3) for IO buffers",
920 .help = "Use shared memory segments for IO buffers",
922 #ifdef FIO_HAVE_HUGETLB
925 .help = "Like shm, but use huge pages",
930 .help = "Use mmap(2) (file or anon) for IO buffers",
932 #ifdef FIO_HAVE_HUGETLB
933 { .ival = "mmaphuge",
934 .oval = MEM_MMAPHUGE,
935 .help = "Like mmap, but use huge pages",
943 .off1 = td_var_offset(verify),
944 .help = "Verify data written",
949 .help = "Don't do IO verification",
953 .help = "Use md5 checksums for verification",
956 .oval = VERIFY_CRC64,
957 .help = "Use crc64 checksums for verification",
960 .oval = VERIFY_CRC32,
961 .help = "Use crc32 checksums for verification",
963 { .ival = "crc32c-intel",
964 .oval = VERIFY_CRC32C_INTEL,
965 .help = "Use hw crc32c checksums for verification",
968 .oval = VERIFY_CRC32C,
969 .help = "Use crc32c checksums for verification",
972 .oval = VERIFY_CRC16,
973 .help = "Use crc16 checksums for verification",
977 .help = "Use crc7 checksums for verification",
980 .oval = VERIFY_SHA256,
981 .help = "Use sha256 checksums for verification",
984 .oval = VERIFY_SHA512,
985 .help = "Use sha512 checksums for verification",
989 .help = "Use io information",
994 .help = "Pretend to verify",
1000 .type = FIO_OPT_BOOL,
1001 .off1 = td_var_offset(do_verify),
1002 .help = "Run verification stage after write",
1007 .name = "verifysort",
1008 .type = FIO_OPT_BOOL,
1009 .off1 = td_var_offset(verifysort),
1010 .help = "Sort written verify blocks for read back",
1015 .name = "verify_interval",
1016 .type = FIO_OPT_STR_VAL_INT,
1017 .off1 = td_var_offset(verify_interval),
1018 .minval = 2 * sizeof(struct verify_header),
1019 .help = "Store verify buffer header every N bytes",
1023 .name = "verify_offset",
1024 .type = FIO_OPT_STR_VAL_INT,
1025 .help = "Offset verify header location by N bytes",
1027 .cb = str_verify_offset_cb,
1031 .name = "verify_pattern",
1032 .type = FIO_OPT_INT,
1033 .cb = str_verify_pattern_cb,
1034 .help = "Fill pattern for IO buffers",
1038 .name = "verify_fatal",
1039 .type = FIO_OPT_BOOL,
1040 .off1 = td_var_offset(verify_fatal),
1042 .help = "Exit on a single verify failure, don't continue",
1046 .name = "write_iolog",
1047 .type = FIO_OPT_STR_STORE,
1048 .off1 = td_var_offset(write_iolog_file),
1049 .help = "Store IO pattern to file",
1052 .name = "read_iolog",
1053 .type = FIO_OPT_STR_STORE,
1054 .off1 = td_var_offset(read_iolog_file),
1055 .help = "Playback IO pattern from file",
1058 .name = "exec_prerun",
1059 .type = FIO_OPT_STR_STORE,
1060 .off1 = td_var_offset(exec_prerun),
1061 .help = "Execute this file prior to running job",
1064 .name = "exec_postrun",
1065 .type = FIO_OPT_STR_STORE,
1066 .off1 = td_var_offset(exec_postrun),
1067 .help = "Execute this file after running job",
1069 #ifdef FIO_HAVE_IOSCHED_SWITCH
1071 .name = "ioscheduler",
1072 .type = FIO_OPT_STR_STORE,
1073 .off1 = td_var_offset(ioscheduler),
1074 .help = "Use this IO scheduler on the backing device",
1079 .type = FIO_OPT_STR_VAL,
1080 .off1 = td_var_offset(zone_size),
1081 .help = "Give size of an IO zone",
1086 .type = FIO_OPT_STR_VAL,
1087 .off1 = td_var_offset(zone_skip),
1088 .help = "Space between IO zones",
1093 .type = FIO_OPT_STR_VAL,
1094 .cb = str_lockmem_cb,
1095 .help = "Lock down this amount of memory",
1099 .name = "rwmixread",
1100 .type = FIO_OPT_INT,
1101 .cb = str_rwmix_read_cb,
1103 .help = "Percentage of mixed workload that is reads",
1107 .name = "rwmixwrite",
1108 .type = FIO_OPT_INT,
1109 .cb = str_rwmix_write_cb,
1111 .help = "Percentage of mixed workload that is writes",
1115 .name = "rwmixcycle",
1116 .type = FIO_OPT_DEPRECATED,
1120 .type = FIO_OPT_INT,
1121 .off1 = td_var_offset(nice),
1122 .help = "Set job CPU nice value",
1127 #ifdef FIO_HAVE_IOPRIO
1130 .type = FIO_OPT_INT,
1132 .help = "Set job IO priority value",
1137 .name = "prioclass",
1138 .type = FIO_OPT_INT,
1139 .cb = str_prioclass_cb,
1140 .help = "Set job IO priority class",
1146 .name = "thinktime",
1147 .type = FIO_OPT_INT,
1148 .off1 = td_var_offset(thinktime),
1149 .help = "Idle time between IO buffers (usec)",
1153 .name = "thinktime_spin",
1154 .type = FIO_OPT_INT,
1155 .off1 = td_var_offset(thinktime_spin),
1156 .help = "Start think time by spinning this amount (usec)",
1158 .parent = "thinktime",
1161 .name = "thinktime_blocks",
1162 .type = FIO_OPT_INT,
1163 .off1 = td_var_offset(thinktime_blocks),
1164 .help = "IO buffer period between 'thinktime'",
1166 .parent = "thinktime",
1170 .type = FIO_OPT_INT,
1171 .off1 = td_var_offset(rate),
1172 .help = "Set bandwidth rate",
1176 .type = FIO_OPT_INT,
1177 .off1 = td_var_offset(ratemin),
1178 .help = "Job must meet this rate or it will be shutdown",
1182 .name = "rate_iops",
1183 .type = FIO_OPT_INT,
1184 .off1 = td_var_offset(rate_iops),
1185 .help = "Limit IO used to this number of IO operations/sec",
1188 .name = "rate_iops_min",
1189 .type = FIO_OPT_INT,
1190 .off1 = td_var_offset(rate_iops_min),
1191 .help = "Job must meet this rate or it will be shutdown",
1192 .parent = "rate_iops",
1195 .name = "ratecycle",
1196 .type = FIO_OPT_INT,
1197 .off1 = td_var_offset(ratecycle),
1198 .help = "Window average for rate limits (msec)",
1203 .name = "invalidate",
1204 .type = FIO_OPT_BOOL,
1205 .off1 = td_var_offset(invalidate_cache),
1206 .help = "Invalidate buffer/page cache prior to running job",
1211 .type = FIO_OPT_BOOL,
1212 .off1 = td_var_offset(sync_io),
1213 .help = "Use O_SYNC for buffered writes",
1215 .parent = "buffered",
1218 .name = "bwavgtime",
1219 .type = FIO_OPT_INT,
1220 .off1 = td_var_offset(bw_avg_time),
1221 .help = "Time window over which to calculate bandwidth"
1226 .name = "create_serialize",
1227 .type = FIO_OPT_BOOL,
1228 .off1 = td_var_offset(create_serialize),
1229 .help = "Serialize creating of job files",
1233 .name = "create_fsync",
1234 .type = FIO_OPT_BOOL,
1235 .off1 = td_var_offset(create_fsync),
1236 .help = "Fsync file after creation",
1241 .type = FIO_OPT_INT,
1242 .off1 = td_var_offset(cpuload),
1243 .help = "Use this percentage of CPU",
1246 .name = "cpuchunks",
1247 .type = FIO_OPT_INT,
1248 .off1 = td_var_offset(cpucycle),
1249 .help = "Length of the CPU burn cycles (usecs)",
1251 .parent = "cpuload",
1253 #ifdef FIO_HAVE_CPU_AFFINITY
1256 .type = FIO_OPT_INT,
1257 .cb = str_cpumask_cb,
1258 .help = "CPU affinity mask",
1261 .name = "cpus_allowed",
1262 .type = FIO_OPT_STR,
1263 .cb = str_cpus_allowed_cb,
1264 .help = "Set CPUs allowed",
1268 .name = "end_fsync",
1269 .type = FIO_OPT_BOOL,
1270 .off1 = td_var_offset(end_fsync),
1271 .help = "Include fsync at the end of job",
1275 .name = "fsync_on_close",
1276 .type = FIO_OPT_BOOL,
1277 .off1 = td_var_offset(fsync_on_close),
1278 .help = "fsync files on close",
1283 .type = FIO_OPT_BOOL,
1284 .off1 = td_var_offset(unlink),
1285 .help = "Unlink created files after job has completed",
1290 .type = FIO_OPT_STR_SET,
1291 .cb = str_exitall_cb,
1292 .help = "Terminate all jobs when one exits",
1295 .name = "stonewall",
1296 .type = FIO_OPT_STR_SET,
1297 .off1 = td_var_offset(stonewall),
1298 .help = "Insert a hard barrier between this job and previous",
1301 .name = "new_group",
1302 .type = FIO_OPT_STR_SET,
1303 .off1 = td_var_offset(new_group),
1304 .help = "Mark the start of a new group (for reporting)",
1308 .type = FIO_OPT_STR_SET,
1309 .off1 = td_var_offset(use_thread),
1310 .help = "Use threads instead of forks",
1313 .name = "write_bw_log",
1314 .type = FIO_OPT_STR,
1315 .off1 = td_var_offset(write_bw_log),
1316 .cb = str_write_bw_log_cb,
1317 .help = "Write log of bandwidth during run",
1320 .name = "write_lat_log",
1321 .type = FIO_OPT_STR,
1322 .off1 = td_var_offset(write_lat_log),
1323 .cb = str_write_lat_log_cb,
1324 .help = "Write log of latency during run",
1327 .name = "hugepage-size",
1328 .type = FIO_OPT_STR_VAL_INT,
1329 .off1 = td_var_offset(hugepage_size),
1330 .help = "When using hugepages, specify size of each page",
1331 .def = __stringify(FIO_HUGE_PAGE),
1334 .name = "group_reporting",
1335 .type = FIO_OPT_STR_SET,
1336 .off1 = td_var_offset(group_reporting),
1337 .help = "Do reporting on a per-group basis",
1340 .name = "zero_buffers",
1341 .type = FIO_OPT_STR_SET,
1342 .off1 = td_var_offset(zero_buffers),
1343 .help = "Init IO buffers to all zeroes",
1346 .name = "refill_buffers",
1347 .type = FIO_OPT_STR_SET,
1348 .off1 = td_var_offset(refill_buffers),
1349 .help = "Refill IO buffers on every IO submit",
1351 #ifdef FIO_HAVE_DISK_UTIL
1353 .name = "disk_util",
1354 .type = FIO_OPT_BOOL,
1355 .off1 = td_var_offset(do_disk_util),
1356 .help = "Log disk utilization statistics",
1361 .name = "gtod_reduce",
1362 .type = FIO_OPT_BOOL,
1363 .help = "Greatly reduce number of gettimeofday() calls",
1364 .cb = str_gtod_reduce_cb,
1368 .name = "disable_clat",
1369 .type = FIO_OPT_BOOL,
1370 .off1 = td_var_offset(disable_clat),
1371 .help = "Disable completion latency numbers",
1372 .parent = "gtod_reduce",
1376 .name = "disable_slat",
1377 .type = FIO_OPT_BOOL,
1378 .off1 = td_var_offset(disable_slat),
1379 .help = "Disable submissionn latency numbers",
1380 .parent = "gtod_reduce",
1384 .name = "disable_bw_measurement",
1385 .type = FIO_OPT_BOOL,
1386 .off1 = td_var_offset(disable_bw),
1387 .help = "Disable bandwidth logging",
1388 .parent = "gtod_reduce",
1396 void fio_options_dup_and_init(struct option *long_options)
1398 struct fio_option *o;
1401 options_init(options);
1404 while (long_options[i].name)
1409 long_options[i].name = (char *) o->name;
1410 long_options[i].val = FIO_GETOPT_JOB;
1411 if (o->type == FIO_OPT_STR_SET)
1412 long_options[i].has_arg = no_argument;
1414 long_options[i].has_arg = required_argument;
1418 assert(i < FIO_NR_OPTIONS);
1422 int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
1426 sort_options(opts, options, num_opts);
1428 for (ret = 0, i = 0; i < num_opts; i++)
1429 ret |= parse_option(opts[i], options, td);
1434 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
1436 return parse_cmd_option(opt, val, options, td);
1439 void fio_fill_default_options(struct thread_data *td)
1441 fill_default_options(td, options);
1444 int fio_show_option_help(const char *opt)
1446 return show_cmd_help(options, opt);
1449 static void __options_mem(struct thread_data *td, int alloc)
1451 struct thread_options *o = &td->o;
1452 struct fio_option *opt;
1456 for (i = 0, opt = &options[0]; opt->name; i++, opt = &options[i]) {
1457 if (opt->type != FIO_OPT_STR_STORE)
1460 ptr = (void *) o + opt->off1;
1463 *ptr = strdup(*ptr);
1473 * dupe FIO_OPT_STR_STORE options
1475 void options_mem_dupe(struct thread_data *td)
1477 __options_mem(td, 1);
1480 void options_mem_free(struct thread_data fio_unused *td)
1483 __options_mem(td, 0);