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 max_cpu = sysconf(_SC_NPROCESSORS_ONLN);
254 for (i = 0; i < sizeof(int) * 8; i++) {
255 if ((1 << i) & *val) {
257 log_err("fio: CPU %d too large (max=%ld)\n", i,
261 dprint(FD_PARSE, "set cpu allowed %d\n", i);
262 fio_cpu_set(&td->o.cpumask, i);
266 td->o.cpumask_set = 1;
270 static int str_cpus_allowed_cb(void *data, const char *input)
272 struct thread_data *td = data;
279 p = str = strdup(input);
281 strip_blank_front(&str);
282 strip_blank_end(str);
284 max_cpu = sysconf(_SC_NPROCESSORS_ONLN);
286 while ((cpu = strsep(&str, ",")) != NULL) {
295 while ((cpu2 = strsep(&str2, "-")) != NULL) {
305 while (icpu <= icpu2) {
306 if (icpu >= FIO_MAX_CPUS) {
307 log_err("fio: your OS only supports up to"
308 " %d CPUs\n", (int) FIO_MAX_CPUS);
312 if (icpu > max_cpu) {
313 log_err("fio: CPU %d too large (max=%ld)\n",
319 dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
320 fio_cpu_set(&td->o.cpumask, icpu);
329 td->o.cpumask_set = 1;
334 static int str_fst_cb(void *data, const char *str)
336 struct thread_data *td = data;
337 char *nr = get_opt_postfix(str);
339 td->file_service_nr = 1;
341 td->file_service_nr = atoi(nr);
348 static int check_dir(struct thread_data *td, char *fname)
350 char file[PATH_MAX], *dir;
353 if (td->o.directory) {
354 strcpy(file, td->o.directory);
359 sprintf(file + elen, "%s", fname);
366 * We can't do this on FIO_DISKLESSIO engines. The engine isn't loaded
367 * yet, so we can't do this check right here...
369 if (lstat(dir, &sb) < 0) {
372 log_err("fio: %s is not a directory\n", dir);
373 td_verror(td, ret, "lstat");
377 if (!S_ISDIR(sb.st_mode)) {
378 log_err("fio: %s is not a directory\n", dir);
387 static int str_filename_cb(void *data, const char *input)
389 struct thread_data *td = data;
390 char *fname, *str, *p;
392 p = str = strdup(input);
394 strip_blank_front(&str);
395 strip_blank_end(str);
397 if (!td->files_index)
400 while ((fname = strsep(&str, ":")) != NULL) {
403 if (check_dir(td, fname)) {
415 static int str_directory_cb(void *data, const char fio_unused *str)
417 struct thread_data *td = data;
420 if (lstat(td->o.directory, &sb) < 0) {
423 log_err("fio: %s is not a directory\n", td->o.directory);
424 td_verror(td, ret, "lstat");
427 if (!S_ISDIR(sb.st_mode)) {
428 log_err("fio: %s is not a directory\n", td->o.directory);
435 static int str_opendir_cb(void *data, const char fio_unused *str)
437 struct thread_data *td = data;
439 if (!td->files_index)
442 return add_dir_files(td, td->o.opendir);
445 static int str_verify_offset_cb(void *data, unsigned int *off)
447 struct thread_data *td = data;
449 if (*off && *off < sizeof(struct verify_header)) {
450 log_err("fio: verify_offset too small\n");
454 td->o.verify_offset = *off;
458 static int str_verify_pattern_cb(void *data, unsigned int *off)
460 struct thread_data *td = data;
465 td->o.verify_pattern_bytes = 1;
467 td->o.verify_pattern_bytes = 2;
469 td->o.verify_pattern_bytes = 3;
471 td->o.verify_pattern_bytes = 4;
473 td->o.verify_pattern = *off;
477 static int str_lockfile_cb(void *data, const char *str)
479 struct thread_data *td = data;
480 char *nr = get_opt_postfix(str);
482 td->o.lockfile_batch = 1;
484 td->o.lockfile_batch = atoi(nr);
491 static int str_write_bw_log_cb(void *data, const char *str)
493 struct thread_data *td = data;
496 td->o.bw_log_file = strdup(str);
498 td->o.write_bw_log = 1;
502 static int str_write_lat_log_cb(void *data, const char *str)
504 struct thread_data *td = data;
507 td->o.lat_log_file = strdup(str);
509 td->o.write_lat_log = 1;
513 static int str_gtod_reduce_cb(void *data, int *il)
515 struct thread_data *td = data;
518 td->o.disable_clat = !!val;
519 td->o.disable_slat = !!val;
520 td->o.disable_bw = !!val;
522 td->tv_cache_mask = 63;
527 static int str_gtod_cpu_cb(void *data, int *il)
529 struct thread_data *td = data;
532 td->o.gtod_cpu = val;
533 td->o.gtod_offload = 1;
537 #define __stringify_1(x) #x
538 #define __stringify(x) __stringify_1(x)
541 * Map of job/command line options
543 static struct fio_option options[] = {
545 .name = "description",
546 .type = FIO_OPT_STR_STORE,
547 .off1 = td_var_offset(description),
548 .help = "Text job description",
552 .type = FIO_OPT_STR_STORE,
553 .off1 = td_var_offset(name),
554 .help = "Name of this job",
558 .type = FIO_OPT_STR_STORE,
559 .off1 = td_var_offset(directory),
560 .cb = str_directory_cb,
561 .help = "Directory to store files in",
565 .type = FIO_OPT_STR_STORE,
566 .off1 = td_var_offset(filename),
567 .cb = str_filename_cb,
568 .prio = 1, /* must come before "directory" */
569 .help = "File(s) to use for the workload",
574 .cb = str_lockfile_cb,
575 .off1 = td_var_offset(file_lock_mode),
576 .help = "Lock file when doing IO to it",
577 .parent = "filename",
581 .oval = FILE_LOCK_NONE,
582 .help = "No file locking",
584 { .ival = "exclusive",
585 .oval = FILE_LOCK_EXCLUSIVE,
586 .help = "Exclusive file lock",
590 .oval = FILE_LOCK_READWRITE,
591 .help = "Read vs write lock",
597 .type = FIO_OPT_STR_STORE,
598 .off1 = td_var_offset(opendir),
599 .cb = str_opendir_cb,
600 .help = "Recursively add files from this directory and down",
604 .alias = "readwrite",
607 .off1 = td_var_offset(td_ddir),
608 .help = "IO direction",
612 .oval = TD_DDIR_READ,
613 .help = "Sequential read",
616 .oval = TD_DDIR_WRITE,
617 .help = "Sequential write",
619 { .ival = "randread",
620 .oval = TD_DDIR_RANDREAD,
621 .help = "Random read",
623 { .ival = "randwrite",
624 .oval = TD_DDIR_RANDWRITE,
625 .help = "Random write",
629 .help = "Sequential read and write mix",
632 .oval = TD_DDIR_RANDRW,
633 .help = "Random read and write mix"
639 .type = FIO_OPT_STR_STORE,
640 .off1 = td_var_offset(ioengine),
641 .help = "IO engine to use",
645 .help = "Use read/write",
648 .help = "Use pread/pwrite",
651 .help = "Use readv/writev",
653 #ifdef FIO_HAVE_LIBAIO
655 .help = "Linux native asynchronous IO",
658 #ifdef FIO_HAVE_POSIXAIO
659 { .ival = "posixaio",
660 .help = "POSIX asynchronous IO",
663 #ifdef FIO_HAVE_SOLARISAIO
664 { .ival = "solarisaio",
665 .help = "Solaris native asynchronous IO",
669 .help = "Memory mapped IO",
671 #ifdef FIO_HAVE_SPLICE
673 .help = "splice/vmsplice based IO",
675 { .ival = "netsplice",
676 .help = "splice/vmsplice to/from the network",
681 .help = "SCSI generic v3 IO",
685 .help = "Testing engine (no data transfer)",
688 .help = "Network IO",
690 #ifdef FIO_HAVE_SYSLET
691 { .ival = "syslet-rw",
692 .help = "syslet enabled async pread/pwrite IO",
696 .help = "CPU cycler burner engine",
698 #ifdef FIO_HAVE_GUASI
700 .help = "GUASI IO engine",
703 { .ival = "external",
704 .help = "Load external engine (append name)",
711 .off1 = td_var_offset(iodepth),
712 .help = "Amount of IO buffers to keep in flight",
717 .name = "iodepth_batch",
718 .alias = "iodepth_batch_submit",
720 .off1 = td_var_offset(iodepth_batch),
721 .help = "Number of IO to submit in one go",
727 .name = "iodepth_batch_complete",
729 .off1 = td_var_offset(iodepth_batch_complete),
730 .help = "Number of IO to retrieve in one go",
736 .name = "iodepth_low",
738 .off1 = td_var_offset(iodepth_low),
739 .help = "Low water mark for queuing depth",
744 .type = FIO_OPT_STR_VAL,
745 .off1 = td_var_offset(size),
747 .help = "Total size of device or files",
750 .name = "fill_device",
751 .type = FIO_OPT_BOOL,
752 .off1 = td_var_offset(fill_device),
753 .help = "Write until an ENOSPC error occurs",
758 .type = FIO_OPT_STR_VAL,
759 .off1 = td_var_offset(file_size_low),
760 .off2 = td_var_offset(file_size_high),
762 .help = "Size of individual files",
766 .alias = "fileoffset",
767 .type = FIO_OPT_STR_VAL,
768 .off1 = td_var_offset(start_offset),
769 .help = "Start IO from this offset",
774 .alias = "blocksize",
775 .type = FIO_OPT_STR_VAL_INT,
776 .off1 = td_var_offset(bs[DDIR_READ]),
777 .off2 = td_var_offset(bs[DDIR_WRITE]),
779 .help = "Block size unit",
785 .alias = "blocksize_range",
786 .type = FIO_OPT_RANGE,
787 .off1 = td_var_offset(min_bs[DDIR_READ]),
788 .off2 = td_var_offset(max_bs[DDIR_READ]),
789 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
790 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
792 .help = "Set block size range (in more detail than bs)",
798 .cb = str_bssplit_cb,
799 .help = "Set a specific mix of block sizes",
803 .name = "bs_unaligned",
804 .alias = "blocksize_unaligned",
805 .type = FIO_OPT_STR_SET,
806 .off1 = td_var_offset(bs_unaligned),
807 .help = "Don't sector align IO buffer sizes",
811 .name = "randrepeat",
812 .type = FIO_OPT_BOOL,
813 .off1 = td_var_offset(rand_repeatable),
814 .help = "Use repeatable random IO pattern",
819 .name = "norandommap",
820 .type = FIO_OPT_STR_SET,
821 .off1 = td_var_offset(norandommap),
822 .help = "Accept potential duplicate random blocks",
826 .name = "softrandommap",
827 .type = FIO_OPT_BOOL,
828 .off1 = td_var_offset(softrandommap),
829 .help = "Set norandommap if randommap allocation fails",
830 .parent = "norandommap",
836 .off1 = td_var_offset(nr_files),
837 .help = "Split job workload between this number of files",
843 .off1 = td_var_offset(open_files),
844 .help = "Number of files to keep open at the same time",
847 .name = "file_service_type",
850 .off1 = td_var_offset(file_service_type),
851 .help = "How to select which file to service next",
855 .oval = FIO_FSERVICE_RANDOM,
856 .help = "Choose a file at random",
858 { .ival = "roundrobin",
859 .oval = FIO_FSERVICE_RR,
860 .help = "Round robin select files",
866 .name = "fadvise_hint",
867 .type = FIO_OPT_BOOL,
868 .off1 = td_var_offset(fadvise_hint),
869 .help = "Use fadvise() to advise the kernel on IO pattern",
875 .off1 = td_var_offset(fsync_blocks),
876 .help = "Issue fsync for writes every given number of blocks",
881 .type = FIO_OPT_BOOL,
882 .off1 = td_var_offset(odirect),
883 .help = "Use O_DIRECT IO (negates buffered)",
888 .type = FIO_OPT_BOOL,
889 .off1 = td_var_offset(odirect),
891 .help = "Use buffered IO (negates direct)",
896 .type = FIO_OPT_BOOL,
897 .off1 = td_var_offset(overwrite),
898 .help = "When writing, set whether to overwrite current data",
904 .off1 = td_var_offset(loops),
905 .help = "Number of times to run the job",
911 .off1 = td_var_offset(numjobs),
912 .help = "Duplicate this job this many times",
916 .name = "startdelay",
918 .off1 = td_var_offset(start_delay),
919 .help = "Only start job when this period has passed",
925 .type = FIO_OPT_STR_VAL_TIME,
926 .off1 = td_var_offset(timeout),
927 .help = "Stop workload when this amount of time has passed",
931 .name = "time_based",
932 .type = FIO_OPT_STR_SET,
933 .off1 = td_var_offset(time_based),
934 .help = "Keep running until runtime/timeout is met",
938 .type = FIO_OPT_STR_VAL_TIME,
939 .off1 = td_var_offset(ramp_time),
940 .help = "Ramp up time before measuring performance",
947 .off1 = td_var_offset(mem_type),
948 .help = "Backing type for IO buffers",
953 .help = "Use malloc(3) for IO buffers",
957 .help = "Use shared memory segments for IO buffers",
959 #ifdef FIO_HAVE_HUGETLB
962 .help = "Like shm, but use huge pages",
967 .help = "Use mmap(2) (file or anon) for IO buffers",
969 #ifdef FIO_HAVE_HUGETLB
970 { .ival = "mmaphuge",
971 .oval = MEM_MMAPHUGE,
972 .help = "Like mmap, but use huge pages",
980 .off1 = td_var_offset(verify),
981 .help = "Verify data written",
986 .help = "Don't do IO verification",
990 .help = "Use md5 checksums for verification",
993 .oval = VERIFY_CRC64,
994 .help = "Use crc64 checksums for verification",
997 .oval = VERIFY_CRC32,
998 .help = "Use crc32 checksums for verification",
1000 { .ival = "crc32c-intel",
1001 .oval = VERIFY_CRC32C_INTEL,
1002 .help = "Use hw crc32c checksums for verification",
1005 .oval = VERIFY_CRC32C,
1006 .help = "Use crc32c checksums for verification",
1009 .oval = VERIFY_CRC16,
1010 .help = "Use crc16 checksums for verification",
1013 .oval = VERIFY_CRC7,
1014 .help = "Use crc7 checksums for verification",
1017 .oval = VERIFY_SHA256,
1018 .help = "Use sha256 checksums for verification",
1021 .oval = VERIFY_SHA512,
1022 .help = "Use sha512 checksums for verification",
1025 .oval = VERIFY_META,
1026 .help = "Use io information",
1030 .oval = VERIFY_NULL,
1031 .help = "Pretend to verify",
1036 .name = "do_verify",
1037 .type = FIO_OPT_BOOL,
1038 .off1 = td_var_offset(do_verify),
1039 .help = "Run verification stage after write",
1044 .name = "verifysort",
1045 .type = FIO_OPT_BOOL,
1046 .off1 = td_var_offset(verifysort),
1047 .help = "Sort written verify blocks for read back",
1052 .name = "verify_interval",
1053 .type = FIO_OPT_STR_VAL_INT,
1054 .off1 = td_var_offset(verify_interval),
1055 .minval = 2 * sizeof(struct verify_header),
1056 .help = "Store verify buffer header every N bytes",
1060 .name = "verify_offset",
1061 .type = FIO_OPT_STR_VAL_INT,
1062 .help = "Offset verify header location by N bytes",
1064 .cb = str_verify_offset_cb,
1068 .name = "verify_pattern",
1069 .type = FIO_OPT_INT,
1070 .cb = str_verify_pattern_cb,
1071 .help = "Fill pattern for IO buffers",
1075 .name = "verify_fatal",
1076 .type = FIO_OPT_BOOL,
1077 .off1 = td_var_offset(verify_fatal),
1079 .help = "Exit on a single verify failure, don't continue",
1083 .name = "write_iolog",
1084 .type = FIO_OPT_STR_STORE,
1085 .off1 = td_var_offset(write_iolog_file),
1086 .help = "Store IO pattern to file",
1089 .name = "read_iolog",
1090 .type = FIO_OPT_STR_STORE,
1091 .off1 = td_var_offset(read_iolog_file),
1092 .help = "Playback IO pattern from file",
1095 .name = "exec_prerun",
1096 .type = FIO_OPT_STR_STORE,
1097 .off1 = td_var_offset(exec_prerun),
1098 .help = "Execute this file prior to running job",
1101 .name = "exec_postrun",
1102 .type = FIO_OPT_STR_STORE,
1103 .off1 = td_var_offset(exec_postrun),
1104 .help = "Execute this file after running job",
1106 #ifdef FIO_HAVE_IOSCHED_SWITCH
1108 .name = "ioscheduler",
1109 .type = FIO_OPT_STR_STORE,
1110 .off1 = td_var_offset(ioscheduler),
1111 .help = "Use this IO scheduler on the backing device",
1116 .type = FIO_OPT_STR_VAL,
1117 .off1 = td_var_offset(zone_size),
1118 .help = "Give size of an IO zone",
1123 .type = FIO_OPT_STR_VAL,
1124 .off1 = td_var_offset(zone_skip),
1125 .help = "Space between IO zones",
1130 .type = FIO_OPT_STR_VAL,
1131 .cb = str_lockmem_cb,
1132 .help = "Lock down this amount of memory",
1136 .name = "rwmixread",
1137 .type = FIO_OPT_INT,
1138 .cb = str_rwmix_read_cb,
1140 .help = "Percentage of mixed workload that is reads",
1144 .name = "rwmixwrite",
1145 .type = FIO_OPT_INT,
1146 .cb = str_rwmix_write_cb,
1148 .help = "Percentage of mixed workload that is writes",
1152 .name = "rwmixcycle",
1153 .type = FIO_OPT_DEPRECATED,
1157 .type = FIO_OPT_INT,
1158 .off1 = td_var_offset(nice),
1159 .help = "Set job CPU nice value",
1164 #ifdef FIO_HAVE_IOPRIO
1167 .type = FIO_OPT_INT,
1169 .help = "Set job IO priority value",
1174 .name = "prioclass",
1175 .type = FIO_OPT_INT,
1176 .cb = str_prioclass_cb,
1177 .help = "Set job IO priority class",
1183 .name = "thinktime",
1184 .type = FIO_OPT_INT,
1185 .off1 = td_var_offset(thinktime),
1186 .help = "Idle time between IO buffers (usec)",
1190 .name = "thinktime_spin",
1191 .type = FIO_OPT_INT,
1192 .off1 = td_var_offset(thinktime_spin),
1193 .help = "Start think time by spinning this amount (usec)",
1195 .parent = "thinktime",
1198 .name = "thinktime_blocks",
1199 .type = FIO_OPT_INT,
1200 .off1 = td_var_offset(thinktime_blocks),
1201 .help = "IO buffer period between 'thinktime'",
1203 .parent = "thinktime",
1207 .type = FIO_OPT_INT,
1208 .off1 = td_var_offset(rate),
1209 .help = "Set bandwidth rate",
1213 .type = FIO_OPT_INT,
1214 .off1 = td_var_offset(ratemin),
1215 .help = "Job must meet this rate or it will be shutdown",
1219 .name = "rate_iops",
1220 .type = FIO_OPT_INT,
1221 .off1 = td_var_offset(rate_iops),
1222 .help = "Limit IO used to this number of IO operations/sec",
1225 .name = "rate_iops_min",
1226 .type = FIO_OPT_INT,
1227 .off1 = td_var_offset(rate_iops_min),
1228 .help = "Job must meet this rate or it will be shutdown",
1229 .parent = "rate_iops",
1232 .name = "ratecycle",
1233 .type = FIO_OPT_INT,
1234 .off1 = td_var_offset(ratecycle),
1235 .help = "Window average for rate limits (msec)",
1240 .name = "invalidate",
1241 .type = FIO_OPT_BOOL,
1242 .off1 = td_var_offset(invalidate_cache),
1243 .help = "Invalidate buffer/page cache prior to running job",
1248 .type = FIO_OPT_BOOL,
1249 .off1 = td_var_offset(sync_io),
1250 .help = "Use O_SYNC for buffered writes",
1252 .parent = "buffered",
1255 .name = "bwavgtime",
1256 .type = FIO_OPT_INT,
1257 .off1 = td_var_offset(bw_avg_time),
1258 .help = "Time window over which to calculate bandwidth"
1263 .name = "create_serialize",
1264 .type = FIO_OPT_BOOL,
1265 .off1 = td_var_offset(create_serialize),
1266 .help = "Serialize creating of job files",
1270 .name = "create_fsync",
1271 .type = FIO_OPT_BOOL,
1272 .off1 = td_var_offset(create_fsync),
1273 .help = "Fsync file after creation",
1278 .type = FIO_OPT_INT,
1279 .off1 = td_var_offset(cpuload),
1280 .help = "Use this percentage of CPU",
1283 .name = "cpuchunks",
1284 .type = FIO_OPT_INT,
1285 .off1 = td_var_offset(cpucycle),
1286 .help = "Length of the CPU burn cycles (usecs)",
1288 .parent = "cpuload",
1290 #ifdef FIO_HAVE_CPU_AFFINITY
1293 .type = FIO_OPT_INT,
1294 .cb = str_cpumask_cb,
1295 .help = "CPU affinity mask",
1298 .name = "cpus_allowed",
1299 .type = FIO_OPT_STR,
1300 .cb = str_cpus_allowed_cb,
1301 .help = "Set CPUs allowed",
1305 .name = "end_fsync",
1306 .type = FIO_OPT_BOOL,
1307 .off1 = td_var_offset(end_fsync),
1308 .help = "Include fsync at the end of job",
1312 .name = "fsync_on_close",
1313 .type = FIO_OPT_BOOL,
1314 .off1 = td_var_offset(fsync_on_close),
1315 .help = "fsync files on close",
1320 .type = FIO_OPT_BOOL,
1321 .off1 = td_var_offset(unlink),
1322 .help = "Unlink created files after job has completed",
1327 .type = FIO_OPT_STR_SET,
1328 .cb = str_exitall_cb,
1329 .help = "Terminate all jobs when one exits",
1332 .name = "stonewall",
1333 .type = FIO_OPT_STR_SET,
1334 .off1 = td_var_offset(stonewall),
1335 .help = "Insert a hard barrier between this job and previous",
1338 .name = "new_group",
1339 .type = FIO_OPT_STR_SET,
1340 .off1 = td_var_offset(new_group),
1341 .help = "Mark the start of a new group (for reporting)",
1345 .type = FIO_OPT_STR_SET,
1346 .off1 = td_var_offset(use_thread),
1347 .help = "Use threads instead of forks",
1350 .name = "write_bw_log",
1351 .type = FIO_OPT_STR,
1352 .off1 = td_var_offset(write_bw_log),
1353 .cb = str_write_bw_log_cb,
1354 .help = "Write log of bandwidth during run",
1357 .name = "write_lat_log",
1358 .type = FIO_OPT_STR,
1359 .off1 = td_var_offset(write_lat_log),
1360 .cb = str_write_lat_log_cb,
1361 .help = "Write log of latency during run",
1364 .name = "hugepage-size",
1365 .type = FIO_OPT_STR_VAL_INT,
1366 .off1 = td_var_offset(hugepage_size),
1367 .help = "When using hugepages, specify size of each page",
1368 .def = __stringify(FIO_HUGE_PAGE),
1371 .name = "group_reporting",
1372 .type = FIO_OPT_STR_SET,
1373 .off1 = td_var_offset(group_reporting),
1374 .help = "Do reporting on a per-group basis",
1377 .name = "zero_buffers",
1378 .type = FIO_OPT_STR_SET,
1379 .off1 = td_var_offset(zero_buffers),
1380 .help = "Init IO buffers to all zeroes",
1383 .name = "refill_buffers",
1384 .type = FIO_OPT_STR_SET,
1385 .off1 = td_var_offset(refill_buffers),
1386 .help = "Refill IO buffers on every IO submit",
1388 #ifdef FIO_HAVE_DISK_UTIL
1390 .name = "disk_util",
1391 .type = FIO_OPT_BOOL,
1392 .off1 = td_var_offset(do_disk_util),
1393 .help = "Log disk utilization statistics",
1398 .name = "gtod_reduce",
1399 .type = FIO_OPT_BOOL,
1400 .help = "Greatly reduce number of gettimeofday() calls",
1401 .cb = str_gtod_reduce_cb,
1405 .name = "disable_clat",
1406 .type = FIO_OPT_BOOL,
1407 .off1 = td_var_offset(disable_clat),
1408 .help = "Disable completion latency numbers",
1409 .parent = "gtod_reduce",
1413 .name = "disable_slat",
1414 .type = FIO_OPT_BOOL,
1415 .off1 = td_var_offset(disable_slat),
1416 .help = "Disable submissionn latency numbers",
1417 .parent = "gtod_reduce",
1421 .name = "disable_bw_measurement",
1422 .type = FIO_OPT_BOOL,
1423 .off1 = td_var_offset(disable_bw),
1424 .help = "Disable bandwidth logging",
1425 .parent = "gtod_reduce",
1430 .type = FIO_OPT_INT,
1431 .cb = str_gtod_cpu_cb,
1432 .help = "Setup dedicated gettimeofday() thread on this CPU",
1439 void fio_options_dup_and_init(struct option *long_options)
1441 struct fio_option *o;
1444 options_init(options);
1447 while (long_options[i].name)
1452 long_options[i].name = (char *) o->name;
1453 long_options[i].val = FIO_GETOPT_JOB;
1454 if (o->type == FIO_OPT_STR_SET)
1455 long_options[i].has_arg = no_argument;
1457 long_options[i].has_arg = required_argument;
1461 assert(i < FIO_NR_OPTIONS);
1465 int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
1469 sort_options(opts, options, num_opts);
1471 for (ret = 0, i = 0; i < num_opts; i++)
1472 ret |= parse_option(opts[i], options, td);
1477 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
1479 return parse_cmd_option(opt, val, options, td);
1482 void fio_fill_default_options(struct thread_data *td)
1484 fill_default_options(td, options);
1487 int fio_show_option_help(const char *opt)
1489 return show_cmd_help(options, opt);
1492 static void __options_mem(struct thread_data *td, int alloc)
1494 struct thread_options *o = &td->o;
1495 struct fio_option *opt;
1499 for (i = 0, opt = &options[0]; opt->name; i++, opt = &options[i]) {
1500 if (opt->type != FIO_OPT_STR_STORE)
1503 ptr = (void *) o + opt->off1;
1506 *ptr = strdup(*ptr);
1516 * dupe FIO_OPT_STR_STORE options
1518 void options_mem_dupe(struct thread_data *td)
1520 __options_mem(td, 1);
1523 void options_mem_free(struct thread_data fio_unused *td)
1526 __options_mem(td, 0);