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++)
254 CPU_SET(*val, &td->o.cpumask);
256 td->o.cpumask_set = 1;
260 static int str_cpus_allowed_cb(void *data, const char *input)
262 struct thread_data *td = data;
265 CPU_ZERO(&td->o.cpumask);
267 p = str = strdup(input);
269 strip_blank_front(&str);
270 strip_blank_end(str);
272 while ((cpu = strsep(&str, ",")) != NULL) {
275 CPU_SET(atoi(cpu), &td->o.cpumask);
279 td->o.cpumask_set = 1;
284 static int str_fst_cb(void *data, const char *str)
286 struct thread_data *td = data;
287 char *nr = get_opt_postfix(str);
289 td->file_service_nr = 1;
291 td->file_service_nr = atoi(nr);
298 static int check_dir(struct thread_data *td, char *fname)
300 char file[PATH_MAX], *dir;
303 if (td->o.directory) {
304 strcpy(file, td->o.directory);
309 sprintf(file + elen, "%s", fname);
316 * We can't do this on FIO_DISKLESSIO engines. The engine isn't loaded
317 * yet, so we can't do this check right here...
319 if (lstat(dir, &sb) < 0) {
322 log_err("fio: %s is not a directory\n", dir);
323 td_verror(td, ret, "lstat");
327 if (!S_ISDIR(sb.st_mode)) {
328 log_err("fio: %s is not a directory\n", dir);
337 static int str_filename_cb(void *data, const char *input)
339 struct thread_data *td = data;
340 char *fname, *str, *p;
342 p = str = strdup(input);
344 strip_blank_front(&str);
345 strip_blank_end(str);
347 if (!td->files_index)
350 while ((fname = strsep(&str, ":")) != NULL) {
353 if (check_dir(td, fname)) {
365 static int str_directory_cb(void *data, const char fio_unused *str)
367 struct thread_data *td = data;
370 if (lstat(td->o.directory, &sb) < 0) {
373 log_err("fio: %s is not a directory\n", td->o.directory);
374 td_verror(td, ret, "lstat");
377 if (!S_ISDIR(sb.st_mode)) {
378 log_err("fio: %s is not a directory\n", td->o.directory);
385 static int str_opendir_cb(void *data, const char fio_unused *str)
387 struct thread_data *td = data;
389 if (!td->files_index)
392 return add_dir_files(td, td->o.opendir);
395 static int str_verify_offset_cb(void *data, unsigned int *off)
397 struct thread_data *td = data;
399 if (*off && *off < sizeof(struct verify_header)) {
400 log_err("fio: verify_offset too small\n");
404 td->o.verify_offset = *off;
408 static int str_verify_pattern_cb(void *data, unsigned int *off)
410 struct thread_data *td = data;
415 td->o.verify_pattern_bytes = 1;
417 td->o.verify_pattern_bytes = 2;
419 td->o.verify_pattern_bytes = 3;
421 td->o.verify_pattern_bytes = 4;
423 td->o.verify_pattern = *off;
427 static int str_lockfile_cb(void *data, const char *str)
429 struct thread_data *td = data;
430 char *nr = get_opt_postfix(str);
432 td->o.lockfile_batch = 1;
434 td->o.lockfile_batch = atoi(nr);
441 static int str_write_bw_log_cb(void *data, const char *str)
443 struct thread_data *td = data;
446 td->o.bw_log_file = strdup(str);
448 td->o.write_bw_log = 1;
452 static int str_write_lat_log_cb(void *data, const char *str)
454 struct thread_data *td = data;
457 td->o.lat_log_file = strdup(str);
459 td->o.write_lat_log = 1;
463 static int str_gtod_reduce_cb(void *data, int *il)
465 struct thread_data *td = data;
468 td->o.disable_clat = !!val;
469 td->o.disable_slat = !!val;
470 td->o.disable_bw = !!val;
472 td->tv_cache_mask = 63;
477 #define __stringify_1(x) #x
478 #define __stringify(x) __stringify_1(x)
481 * Map of job/command line options
483 static struct fio_option options[] = {
485 .name = "description",
486 .type = FIO_OPT_STR_STORE,
487 .off1 = td_var_offset(description),
488 .help = "Text job description",
492 .type = FIO_OPT_STR_STORE,
493 .off1 = td_var_offset(name),
494 .help = "Name of this job",
498 .type = FIO_OPT_STR_STORE,
499 .off1 = td_var_offset(directory),
500 .cb = str_directory_cb,
501 .help = "Directory to store files in",
505 .type = FIO_OPT_STR_STORE,
506 .off1 = td_var_offset(filename),
507 .cb = str_filename_cb,
508 .prio = 1, /* must come before "directory" */
509 .help = "File(s) to use for the workload",
514 .cb = str_lockfile_cb,
515 .off1 = td_var_offset(file_lock_mode),
516 .help = "Lock file when doing IO to it",
517 .parent = "filename",
521 .oval = FILE_LOCK_NONE,
522 .help = "No file locking",
524 { .ival = "exclusive",
525 .oval = FILE_LOCK_EXCLUSIVE,
526 .help = "Exclusive file lock",
530 .oval = FILE_LOCK_READWRITE,
531 .help = "Read vs write lock",
537 .type = FIO_OPT_STR_STORE,
538 .off1 = td_var_offset(opendir),
539 .cb = str_opendir_cb,
540 .help = "Recursively add files from this directory and down",
544 .alias = "readwrite",
547 .off1 = td_var_offset(td_ddir),
548 .help = "IO direction",
552 .oval = TD_DDIR_READ,
553 .help = "Sequential read",
556 .oval = TD_DDIR_WRITE,
557 .help = "Sequential write",
559 { .ival = "randread",
560 .oval = TD_DDIR_RANDREAD,
561 .help = "Random read",
563 { .ival = "randwrite",
564 .oval = TD_DDIR_RANDWRITE,
565 .help = "Random write",
569 .help = "Sequential read and write mix",
572 .oval = TD_DDIR_RANDRW,
573 .help = "Random read and write mix"
579 .type = FIO_OPT_STR_STORE,
580 .off1 = td_var_offset(ioengine),
581 .help = "IO engine to use",
585 .help = "Use read/write",
588 .help = "Use pread/pwrite",
591 .help = "Use readv/writev",
593 #ifdef FIO_HAVE_LIBAIO
595 .help = "Linux native asynchronous IO",
598 #ifdef FIO_HAVE_POSIXAIO
599 { .ival = "posixaio",
600 .help = "POSIX asynchronous IO",
603 #ifdef FIO_HAVE_SOLARISAIO
604 { .ival = "solarisaio",
605 .help = "Solaris native asynchronous IO",
609 .help = "Memory mapped IO",
611 #ifdef FIO_HAVE_SPLICE
613 .help = "splice/vmsplice based IO",
615 { .ival = "netsplice",
616 .help = "splice/vmsplice to/from the network",
621 .help = "SCSI generic v3 IO",
625 .help = "Testing engine (no data transfer)",
628 .help = "Network IO",
630 #ifdef FIO_HAVE_SYSLET
631 { .ival = "syslet-rw",
632 .help = "syslet enabled async pread/pwrite IO",
636 .help = "CPU cycler burner engine",
638 #ifdef FIO_HAVE_GUASI
640 .help = "GUASI IO engine",
643 { .ival = "external",
644 .help = "Load external engine (append name)",
651 .off1 = td_var_offset(iodepth),
652 .help = "Amount of IO buffers to keep in flight",
657 .name = "iodepth_batch",
658 .alias = "iodepth_batch_submit",
660 .off1 = td_var_offset(iodepth_batch),
661 .help = "Number of IO to submit in one go",
667 .name = "iodepth_batch_complete",
669 .off1 = td_var_offset(iodepth_batch_complete),
670 .help = "Number of IO to retrieve in one go",
676 .name = "iodepth_low",
678 .off1 = td_var_offset(iodepth_low),
679 .help = "Low water mark for queuing depth",
684 .type = FIO_OPT_STR_VAL,
685 .off1 = td_var_offset(size),
687 .help = "Total size of device or files",
690 .name = "fill_device",
691 .type = FIO_OPT_BOOL,
692 .off1 = td_var_offset(fill_device),
693 .help = "Write until an ENOSPC error occurs",
698 .type = FIO_OPT_STR_VAL,
699 .off1 = td_var_offset(file_size_low),
700 .off2 = td_var_offset(file_size_high),
702 .help = "Size of individual files",
706 .alias = "fileoffset",
707 .type = FIO_OPT_STR_VAL,
708 .off1 = td_var_offset(start_offset),
709 .help = "Start IO from this offset",
714 .alias = "blocksize",
715 .type = FIO_OPT_STR_VAL_INT,
716 .off1 = td_var_offset(bs[DDIR_READ]),
717 .off2 = td_var_offset(bs[DDIR_WRITE]),
719 .help = "Block size unit",
725 .alias = "blocksize_range",
726 .type = FIO_OPT_RANGE,
727 .off1 = td_var_offset(min_bs[DDIR_READ]),
728 .off2 = td_var_offset(max_bs[DDIR_READ]),
729 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
730 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
732 .help = "Set block size range (in more detail than bs)",
738 .cb = str_bssplit_cb,
739 .help = "Set a specific mix of block sizes",
743 .name = "bs_unaligned",
744 .alias = "blocksize_unaligned",
745 .type = FIO_OPT_STR_SET,
746 .off1 = td_var_offset(bs_unaligned),
747 .help = "Don't sector align IO buffer sizes",
751 .name = "randrepeat",
752 .type = FIO_OPT_BOOL,
753 .off1 = td_var_offset(rand_repeatable),
754 .help = "Use repeatable random IO pattern",
759 .name = "norandommap",
760 .type = FIO_OPT_STR_SET,
761 .off1 = td_var_offset(norandommap),
762 .help = "Accept potential duplicate random blocks",
766 .name = "softrandommap",
767 .type = FIO_OPT_BOOL,
768 .off1 = td_var_offset(softrandommap),
769 .help = "Set norandommap if randommap allocation fails",
770 .parent = "norandommap",
776 .off1 = td_var_offset(nr_files),
777 .help = "Split job workload between this number of files",
783 .off1 = td_var_offset(open_files),
784 .help = "Number of files to keep open at the same time",
787 .name = "file_service_type",
790 .off1 = td_var_offset(file_service_type),
791 .help = "How to select which file to service next",
795 .oval = FIO_FSERVICE_RANDOM,
796 .help = "Choose a file at random",
798 { .ival = "roundrobin",
799 .oval = FIO_FSERVICE_RR,
800 .help = "Round robin select files",
806 .name = "fadvise_hint",
807 .type = FIO_OPT_BOOL,
808 .off1 = td_var_offset(fadvise_hint),
809 .help = "Use fadvise() to advise the kernel on IO pattern",
815 .off1 = td_var_offset(fsync_blocks),
816 .help = "Issue fsync for writes every given number of blocks",
821 .type = FIO_OPT_BOOL,
822 .off1 = td_var_offset(odirect),
823 .help = "Use O_DIRECT IO (negates buffered)",
828 .type = FIO_OPT_BOOL,
829 .off1 = td_var_offset(odirect),
831 .help = "Use buffered IO (negates direct)",
836 .type = FIO_OPT_BOOL,
837 .off1 = td_var_offset(overwrite),
838 .help = "When writing, set whether to overwrite current data",
844 .off1 = td_var_offset(loops),
845 .help = "Number of times to run the job",
851 .off1 = td_var_offset(numjobs),
852 .help = "Duplicate this job this many times",
856 .name = "startdelay",
858 .off1 = td_var_offset(start_delay),
859 .help = "Only start job when this period has passed",
865 .type = FIO_OPT_STR_VAL_TIME,
866 .off1 = td_var_offset(timeout),
867 .help = "Stop workload when this amount of time has passed",
871 .name = "time_based",
872 .type = FIO_OPT_STR_SET,
873 .off1 = td_var_offset(time_based),
874 .help = "Keep running until runtime/timeout is met",
878 .type = FIO_OPT_STR_VAL_TIME,
879 .off1 = td_var_offset(ramp_time),
880 .help = "Ramp up time before measuring performance",
887 .off1 = td_var_offset(mem_type),
888 .help = "Backing type for IO buffers",
893 .help = "Use malloc(3) for IO buffers",
897 .help = "Use shared memory segments for IO buffers",
899 #ifdef FIO_HAVE_HUGETLB
902 .help = "Like shm, but use huge pages",
907 .help = "Use mmap(2) (file or anon) for IO buffers",
909 #ifdef FIO_HAVE_HUGETLB
910 { .ival = "mmaphuge",
911 .oval = MEM_MMAPHUGE,
912 .help = "Like mmap, but use huge pages",
920 .off1 = td_var_offset(verify),
921 .help = "Verify data written",
926 .help = "Don't do IO verification",
930 .help = "Use md5 checksums for verification",
933 .oval = VERIFY_CRC64,
934 .help = "Use crc64 checksums for verification",
937 .oval = VERIFY_CRC32,
938 .help = "Use crc32 checksums for verification",
940 { .ival = "crc32c-intel",
941 .oval = VERIFY_CRC32C_INTEL,
942 .help = "Use hw crc32c checksums for verification",
945 .oval = VERIFY_CRC32C,
946 .help = "Use crc32c checksums for verification",
949 .oval = VERIFY_CRC16,
950 .help = "Use crc16 checksums for verification",
954 .help = "Use crc7 checksums for verification",
957 .oval = VERIFY_SHA256,
958 .help = "Use sha256 checksums for verification",
961 .oval = VERIFY_SHA512,
962 .help = "Use sha512 checksums for verification",
966 .help = "Use io information",
971 .help = "Pretend to verify",
977 .type = FIO_OPT_BOOL,
978 .off1 = td_var_offset(do_verify),
979 .help = "Run verification stage after write",
984 .name = "verifysort",
985 .type = FIO_OPT_BOOL,
986 .off1 = td_var_offset(verifysort),
987 .help = "Sort written verify blocks for read back",
992 .name = "verify_interval",
993 .type = FIO_OPT_STR_VAL_INT,
994 .off1 = td_var_offset(verify_interval),
995 .minval = 2 * sizeof(struct verify_header),
996 .help = "Store verify buffer header every N bytes",
1000 .name = "verify_offset",
1001 .type = FIO_OPT_STR_VAL_INT,
1002 .help = "Offset verify header location by N bytes",
1004 .cb = str_verify_offset_cb,
1008 .name = "verify_pattern",
1009 .type = FIO_OPT_INT,
1010 .cb = str_verify_pattern_cb,
1011 .help = "Fill pattern for IO buffers",
1015 .name = "verify_fatal",
1016 .type = FIO_OPT_BOOL,
1017 .off1 = td_var_offset(verify_fatal),
1019 .help = "Exit on a single verify failure, don't continue",
1023 .name = "write_iolog",
1024 .type = FIO_OPT_STR_STORE,
1025 .off1 = td_var_offset(write_iolog_file),
1026 .help = "Store IO pattern to file",
1029 .name = "read_iolog",
1030 .type = FIO_OPT_STR_STORE,
1031 .off1 = td_var_offset(read_iolog_file),
1032 .help = "Playback IO pattern from file",
1035 .name = "exec_prerun",
1036 .type = FIO_OPT_STR_STORE,
1037 .off1 = td_var_offset(exec_prerun),
1038 .help = "Execute this file prior to running job",
1041 .name = "exec_postrun",
1042 .type = FIO_OPT_STR_STORE,
1043 .off1 = td_var_offset(exec_postrun),
1044 .help = "Execute this file after running job",
1046 #ifdef FIO_HAVE_IOSCHED_SWITCH
1048 .name = "ioscheduler",
1049 .type = FIO_OPT_STR_STORE,
1050 .off1 = td_var_offset(ioscheduler),
1051 .help = "Use this IO scheduler on the backing device",
1056 .type = FIO_OPT_STR_VAL,
1057 .off1 = td_var_offset(zone_size),
1058 .help = "Give size of an IO zone",
1063 .type = FIO_OPT_STR_VAL,
1064 .off1 = td_var_offset(zone_skip),
1065 .help = "Space between IO zones",
1070 .type = FIO_OPT_STR_VAL,
1071 .cb = str_lockmem_cb,
1072 .help = "Lock down this amount of memory",
1076 .name = "rwmixread",
1077 .type = FIO_OPT_INT,
1078 .cb = str_rwmix_read_cb,
1080 .help = "Percentage of mixed workload that is reads",
1084 .name = "rwmixwrite",
1085 .type = FIO_OPT_INT,
1086 .cb = str_rwmix_write_cb,
1088 .help = "Percentage of mixed workload that is writes",
1092 .name = "rwmixcycle",
1093 .type = FIO_OPT_DEPRECATED,
1097 .type = FIO_OPT_INT,
1098 .off1 = td_var_offset(nice),
1099 .help = "Set job CPU nice value",
1104 #ifdef FIO_HAVE_IOPRIO
1107 .type = FIO_OPT_INT,
1109 .help = "Set job IO priority value",
1114 .name = "prioclass",
1115 .type = FIO_OPT_INT,
1116 .cb = str_prioclass_cb,
1117 .help = "Set job IO priority class",
1123 .name = "thinktime",
1124 .type = FIO_OPT_INT,
1125 .off1 = td_var_offset(thinktime),
1126 .help = "Idle time between IO buffers (usec)",
1130 .name = "thinktime_spin",
1131 .type = FIO_OPT_INT,
1132 .off1 = td_var_offset(thinktime_spin),
1133 .help = "Start think time by spinning this amount (usec)",
1135 .parent = "thinktime",
1138 .name = "thinktime_blocks",
1139 .type = FIO_OPT_INT,
1140 .off1 = td_var_offset(thinktime_blocks),
1141 .help = "IO buffer period between 'thinktime'",
1143 .parent = "thinktime",
1147 .type = FIO_OPT_INT,
1148 .off1 = td_var_offset(rate),
1149 .help = "Set bandwidth rate",
1153 .type = FIO_OPT_INT,
1154 .off1 = td_var_offset(ratemin),
1155 .help = "Job must meet this rate or it will be shutdown",
1159 .name = "rate_iops",
1160 .type = FIO_OPT_INT,
1161 .off1 = td_var_offset(rate_iops),
1162 .help = "Limit IO used to this number of IO operations/sec",
1165 .name = "rate_iops_min",
1166 .type = FIO_OPT_INT,
1167 .off1 = td_var_offset(rate_iops_min),
1168 .help = "Job must meet this rate or it will be shutdown",
1169 .parent = "rate_iops",
1172 .name = "ratecycle",
1173 .type = FIO_OPT_INT,
1174 .off1 = td_var_offset(ratecycle),
1175 .help = "Window average for rate limits (msec)",
1180 .name = "invalidate",
1181 .type = FIO_OPT_BOOL,
1182 .off1 = td_var_offset(invalidate_cache),
1183 .help = "Invalidate buffer/page cache prior to running job",
1188 .type = FIO_OPT_BOOL,
1189 .off1 = td_var_offset(sync_io),
1190 .help = "Use O_SYNC for buffered writes",
1192 .parent = "buffered",
1195 .name = "bwavgtime",
1196 .type = FIO_OPT_INT,
1197 .off1 = td_var_offset(bw_avg_time),
1198 .help = "Time window over which to calculate bandwidth"
1203 .name = "create_serialize",
1204 .type = FIO_OPT_BOOL,
1205 .off1 = td_var_offset(create_serialize),
1206 .help = "Serialize creating of job files",
1210 .name = "create_fsync",
1211 .type = FIO_OPT_BOOL,
1212 .off1 = td_var_offset(create_fsync),
1213 .help = "Fsync file after creation",
1218 .type = FIO_OPT_INT,
1219 .off1 = td_var_offset(cpuload),
1220 .help = "Use this percentage of CPU",
1223 .name = "cpuchunks",
1224 .type = FIO_OPT_INT,
1225 .off1 = td_var_offset(cpucycle),
1226 .help = "Length of the CPU burn cycles (usecs)",
1228 .parent = "cpuload",
1230 #ifdef FIO_HAVE_CPU_AFFINITY
1233 .type = FIO_OPT_INT,
1234 .cb = str_cpumask_cb,
1235 .help = "CPU affinity mask",
1238 .name = "cpus_allowed",
1239 .type = FIO_OPT_STR,
1240 .cb = str_cpus_allowed_cb,
1241 .help = "Set CPUs allowed",
1245 .name = "end_fsync",
1246 .type = FIO_OPT_BOOL,
1247 .off1 = td_var_offset(end_fsync),
1248 .help = "Include fsync at the end of job",
1252 .name = "fsync_on_close",
1253 .type = FIO_OPT_BOOL,
1254 .off1 = td_var_offset(fsync_on_close),
1255 .help = "fsync files on close",
1260 .type = FIO_OPT_BOOL,
1261 .off1 = td_var_offset(unlink),
1262 .help = "Unlink created files after job has completed",
1267 .type = FIO_OPT_STR_SET,
1268 .cb = str_exitall_cb,
1269 .help = "Terminate all jobs when one exits",
1272 .name = "stonewall",
1273 .type = FIO_OPT_STR_SET,
1274 .off1 = td_var_offset(stonewall),
1275 .help = "Insert a hard barrier between this job and previous",
1278 .name = "new_group",
1279 .type = FIO_OPT_STR_SET,
1280 .off1 = td_var_offset(new_group),
1281 .help = "Mark the start of a new group (for reporting)",
1285 .type = FIO_OPT_STR_SET,
1286 .off1 = td_var_offset(use_thread),
1287 .help = "Use threads instead of forks",
1290 .name = "write_bw_log",
1291 .type = FIO_OPT_STR,
1292 .off1 = td_var_offset(write_bw_log),
1293 .cb = str_write_bw_log_cb,
1294 .help = "Write log of bandwidth during run",
1297 .name = "write_lat_log",
1298 .type = FIO_OPT_STR,
1299 .off1 = td_var_offset(write_lat_log),
1300 .cb = str_write_lat_log_cb,
1301 .help = "Write log of latency during run",
1304 .name = "hugepage-size",
1305 .type = FIO_OPT_STR_VAL_INT,
1306 .off1 = td_var_offset(hugepage_size),
1307 .help = "When using hugepages, specify size of each page",
1308 .def = __stringify(FIO_HUGE_PAGE),
1311 .name = "group_reporting",
1312 .type = FIO_OPT_STR_SET,
1313 .off1 = td_var_offset(group_reporting),
1314 .help = "Do reporting on a per-group basis",
1317 .name = "zero_buffers",
1318 .type = FIO_OPT_STR_SET,
1319 .off1 = td_var_offset(zero_buffers),
1320 .help = "Init IO buffers to all zeroes",
1323 .name = "refill_buffers",
1324 .type = FIO_OPT_STR_SET,
1325 .off1 = td_var_offset(refill_buffers),
1326 .help = "Refill IO buffers on every IO submit",
1328 #ifdef FIO_HAVE_DISK_UTIL
1330 .name = "disk_util",
1331 .type = FIO_OPT_BOOL,
1332 .off1 = td_var_offset(do_disk_util),
1333 .help = "Log disk utilization statistics",
1338 .name = "gtod_reduce",
1339 .type = FIO_OPT_BOOL,
1340 .help = "Greatly reduce number of gettimeofday() calls",
1341 .cb = str_gtod_reduce_cb,
1345 .name = "disable_clat",
1346 .type = FIO_OPT_BOOL,
1347 .off1 = td_var_offset(disable_clat),
1348 .help = "Disable completion latency numbers",
1349 .parent = "gtod_reduce",
1353 .name = "disable_slat",
1354 .type = FIO_OPT_BOOL,
1355 .off1 = td_var_offset(disable_slat),
1356 .help = "Disable submissionn latency numbers",
1357 .parent = "gtod_reduce",
1361 .name = "disable_bw_measurement",
1362 .type = FIO_OPT_BOOL,
1363 .off1 = td_var_offset(disable_bw),
1364 .help = "Disable bandwidth logging",
1365 .parent = "gtod_reduce",
1373 void fio_options_dup_and_init(struct option *long_options)
1375 struct fio_option *o;
1378 options_init(options);
1381 while (long_options[i].name)
1386 long_options[i].name = (char *) o->name;
1387 long_options[i].val = FIO_GETOPT_JOB;
1388 if (o->type == FIO_OPT_STR_SET)
1389 long_options[i].has_arg = no_argument;
1391 long_options[i].has_arg = required_argument;
1395 assert(i < FIO_NR_OPTIONS);
1399 int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
1403 sort_options(opts, options, num_opts);
1405 for (ret = 0, i = 0; i < num_opts; i++)
1406 ret |= parse_option(opts[i], options, td);
1411 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
1413 return parse_cmd_option(opt, val, options, td);
1416 void fio_fill_default_options(struct thread_data *td)
1418 fill_default_options(td, options);
1421 int fio_show_option_help(const char *opt)
1423 return show_cmd_help(options, opt);
1426 static void __options_mem(struct thread_data *td, int alloc)
1428 struct thread_options *o = &td->o;
1429 struct fio_option *opt;
1433 for (i = 0, opt = &options[0]; opt->name; i++, opt = &options[i]) {
1434 if (opt->type != FIO_OPT_STR_STORE)
1437 ptr = (void *) o + opt->off1;
1440 *ptr = strdup(*ptr);
1450 * dupe FIO_OPT_STR_STORE options
1452 void options_mem_dupe(struct thread_data *td)
1454 __options_mem(td, 1);
1457 void options_mem_free(struct thread_data fio_unused *td)
1460 __options_mem(td, 0);