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;
269 CPU_ZERO(&td->o.cpumask);
271 p = str = strdup(input);
273 strip_blank_front(&str);
274 strip_blank_end(str);
276 while ((cpu = strsep(&str, ",")) != NULL) {
285 while ((cpu2 = strsep(&str2, "-")) != NULL) {
295 while (icpu <= icpu2) {
296 if (icpu >= CPU_SETSIZE) {
297 log_err("fio: your OS only supports up to"
298 " %d CPUs\n", (int) CPU_SETSIZE);
303 dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
304 CPU_SET(atoi(cpu), &td->o.cpumask);
313 td->o.cpumask_set = 1;
318 static int str_fst_cb(void *data, const char *str)
320 struct thread_data *td = data;
321 char *nr = get_opt_postfix(str);
323 td->file_service_nr = 1;
325 td->file_service_nr = atoi(nr);
332 static int check_dir(struct thread_data *td, char *fname)
334 char file[PATH_MAX], *dir;
337 if (td->o.directory) {
338 strcpy(file, td->o.directory);
343 sprintf(file + elen, "%s", fname);
350 * We can't do this on FIO_DISKLESSIO engines. The engine isn't loaded
351 * yet, so we can't do this check right here...
353 if (lstat(dir, &sb) < 0) {
356 log_err("fio: %s is not a directory\n", dir);
357 td_verror(td, ret, "lstat");
361 if (!S_ISDIR(sb.st_mode)) {
362 log_err("fio: %s is not a directory\n", dir);
371 static int str_filename_cb(void *data, const char *input)
373 struct thread_data *td = data;
374 char *fname, *str, *p;
376 p = str = strdup(input);
378 strip_blank_front(&str);
379 strip_blank_end(str);
381 if (!td->files_index)
384 while ((fname = strsep(&str, ":")) != NULL) {
387 if (check_dir(td, fname)) {
399 static int str_directory_cb(void *data, const char fio_unused *str)
401 struct thread_data *td = data;
404 if (lstat(td->o.directory, &sb) < 0) {
407 log_err("fio: %s is not a directory\n", td->o.directory);
408 td_verror(td, ret, "lstat");
411 if (!S_ISDIR(sb.st_mode)) {
412 log_err("fio: %s is not a directory\n", td->o.directory);
419 static int str_opendir_cb(void *data, const char fio_unused *str)
421 struct thread_data *td = data;
423 if (!td->files_index)
426 return add_dir_files(td, td->o.opendir);
429 static int str_verify_offset_cb(void *data, unsigned int *off)
431 struct thread_data *td = data;
433 if (*off && *off < sizeof(struct verify_header)) {
434 log_err("fio: verify_offset too small\n");
438 td->o.verify_offset = *off;
442 static int str_verify_pattern_cb(void *data, unsigned int *off)
444 struct thread_data *td = data;
449 td->o.verify_pattern_bytes = 1;
451 td->o.verify_pattern_bytes = 2;
453 td->o.verify_pattern_bytes = 3;
455 td->o.verify_pattern_bytes = 4;
457 td->o.verify_pattern = *off;
461 static int str_lockfile_cb(void *data, const char *str)
463 struct thread_data *td = data;
464 char *nr = get_opt_postfix(str);
466 td->o.lockfile_batch = 1;
468 td->o.lockfile_batch = atoi(nr);
475 static int str_write_bw_log_cb(void *data, const char *str)
477 struct thread_data *td = data;
480 td->o.bw_log_file = strdup(str);
482 td->o.write_bw_log = 1;
486 static int str_write_lat_log_cb(void *data, const char *str)
488 struct thread_data *td = data;
491 td->o.lat_log_file = strdup(str);
493 td->o.write_lat_log = 1;
497 static int str_gtod_reduce_cb(void *data, int *il)
499 struct thread_data *td = data;
502 td->o.disable_clat = !!val;
503 td->o.disable_slat = !!val;
504 td->o.disable_bw = !!val;
506 td->tv_cache_mask = 63;
511 static int str_gtod_cpu_cb(void *data, int *il)
513 struct thread_data *td = data;
516 td->o.gtod_cpu = val;
517 td->o.gtod_offload = 1;
521 #define __stringify_1(x) #x
522 #define __stringify(x) __stringify_1(x)
525 * Map of job/command line options
527 static struct fio_option options[] = {
529 .name = "description",
530 .type = FIO_OPT_STR_STORE,
531 .off1 = td_var_offset(description),
532 .help = "Text job description",
536 .type = FIO_OPT_STR_STORE,
537 .off1 = td_var_offset(name),
538 .help = "Name of this job",
542 .type = FIO_OPT_STR_STORE,
543 .off1 = td_var_offset(directory),
544 .cb = str_directory_cb,
545 .help = "Directory to store files in",
549 .type = FIO_OPT_STR_STORE,
550 .off1 = td_var_offset(filename),
551 .cb = str_filename_cb,
552 .prio = 1, /* must come before "directory" */
553 .help = "File(s) to use for the workload",
558 .cb = str_lockfile_cb,
559 .off1 = td_var_offset(file_lock_mode),
560 .help = "Lock file when doing IO to it",
561 .parent = "filename",
565 .oval = FILE_LOCK_NONE,
566 .help = "No file locking",
568 { .ival = "exclusive",
569 .oval = FILE_LOCK_EXCLUSIVE,
570 .help = "Exclusive file lock",
574 .oval = FILE_LOCK_READWRITE,
575 .help = "Read vs write lock",
581 .type = FIO_OPT_STR_STORE,
582 .off1 = td_var_offset(opendir),
583 .cb = str_opendir_cb,
584 .help = "Recursively add files from this directory and down",
588 .alias = "readwrite",
591 .off1 = td_var_offset(td_ddir),
592 .help = "IO direction",
596 .oval = TD_DDIR_READ,
597 .help = "Sequential read",
600 .oval = TD_DDIR_WRITE,
601 .help = "Sequential write",
603 { .ival = "randread",
604 .oval = TD_DDIR_RANDREAD,
605 .help = "Random read",
607 { .ival = "randwrite",
608 .oval = TD_DDIR_RANDWRITE,
609 .help = "Random write",
613 .help = "Sequential read and write mix",
616 .oval = TD_DDIR_RANDRW,
617 .help = "Random read and write mix"
623 .type = FIO_OPT_STR_STORE,
624 .off1 = td_var_offset(ioengine),
625 .help = "IO engine to use",
629 .help = "Use read/write",
632 .help = "Use pread/pwrite",
635 .help = "Use readv/writev",
637 #ifdef FIO_HAVE_LIBAIO
639 .help = "Linux native asynchronous IO",
642 #ifdef FIO_HAVE_POSIXAIO
643 { .ival = "posixaio",
644 .help = "POSIX asynchronous IO",
647 #ifdef FIO_HAVE_SOLARISAIO
648 { .ival = "solarisaio",
649 .help = "Solaris native asynchronous IO",
653 .help = "Memory mapped IO",
655 #ifdef FIO_HAVE_SPLICE
657 .help = "splice/vmsplice based IO",
659 { .ival = "netsplice",
660 .help = "splice/vmsplice to/from the network",
665 .help = "SCSI generic v3 IO",
669 .help = "Testing engine (no data transfer)",
672 .help = "Network IO",
674 #ifdef FIO_HAVE_SYSLET
675 { .ival = "syslet-rw",
676 .help = "syslet enabled async pread/pwrite IO",
680 .help = "CPU cycler burner engine",
682 #ifdef FIO_HAVE_GUASI
684 .help = "GUASI IO engine",
687 { .ival = "external",
688 .help = "Load external engine (append name)",
695 .off1 = td_var_offset(iodepth),
696 .help = "Amount of IO buffers to keep in flight",
701 .name = "iodepth_batch",
702 .alias = "iodepth_batch_submit",
704 .off1 = td_var_offset(iodepth_batch),
705 .help = "Number of IO to submit in one go",
711 .name = "iodepth_batch_complete",
713 .off1 = td_var_offset(iodepth_batch_complete),
714 .help = "Number of IO to retrieve in one go",
720 .name = "iodepth_low",
722 .off1 = td_var_offset(iodepth_low),
723 .help = "Low water mark for queuing depth",
728 .type = FIO_OPT_STR_VAL,
729 .off1 = td_var_offset(size),
731 .help = "Total size of device or files",
734 .name = "fill_device",
735 .type = FIO_OPT_BOOL,
736 .off1 = td_var_offset(fill_device),
737 .help = "Write until an ENOSPC error occurs",
742 .type = FIO_OPT_STR_VAL,
743 .off1 = td_var_offset(file_size_low),
744 .off2 = td_var_offset(file_size_high),
746 .help = "Size of individual files",
750 .alias = "fileoffset",
751 .type = FIO_OPT_STR_VAL,
752 .off1 = td_var_offset(start_offset),
753 .help = "Start IO from this offset",
758 .alias = "blocksize",
759 .type = FIO_OPT_STR_VAL_INT,
760 .off1 = td_var_offset(bs[DDIR_READ]),
761 .off2 = td_var_offset(bs[DDIR_WRITE]),
763 .help = "Block size unit",
769 .alias = "blocksize_range",
770 .type = FIO_OPT_RANGE,
771 .off1 = td_var_offset(min_bs[DDIR_READ]),
772 .off2 = td_var_offset(max_bs[DDIR_READ]),
773 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
774 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
776 .help = "Set block size range (in more detail than bs)",
782 .cb = str_bssplit_cb,
783 .help = "Set a specific mix of block sizes",
787 .name = "bs_unaligned",
788 .alias = "blocksize_unaligned",
789 .type = FIO_OPT_STR_SET,
790 .off1 = td_var_offset(bs_unaligned),
791 .help = "Don't sector align IO buffer sizes",
795 .name = "randrepeat",
796 .type = FIO_OPT_BOOL,
797 .off1 = td_var_offset(rand_repeatable),
798 .help = "Use repeatable random IO pattern",
803 .name = "norandommap",
804 .type = FIO_OPT_STR_SET,
805 .off1 = td_var_offset(norandommap),
806 .help = "Accept potential duplicate random blocks",
810 .name = "softrandommap",
811 .type = FIO_OPT_BOOL,
812 .off1 = td_var_offset(softrandommap),
813 .help = "Set norandommap if randommap allocation fails",
814 .parent = "norandommap",
820 .off1 = td_var_offset(nr_files),
821 .help = "Split job workload between this number of files",
827 .off1 = td_var_offset(open_files),
828 .help = "Number of files to keep open at the same time",
831 .name = "file_service_type",
834 .off1 = td_var_offset(file_service_type),
835 .help = "How to select which file to service next",
839 .oval = FIO_FSERVICE_RANDOM,
840 .help = "Choose a file at random",
842 { .ival = "roundrobin",
843 .oval = FIO_FSERVICE_RR,
844 .help = "Round robin select files",
850 .name = "fadvise_hint",
851 .type = FIO_OPT_BOOL,
852 .off1 = td_var_offset(fadvise_hint),
853 .help = "Use fadvise() to advise the kernel on IO pattern",
859 .off1 = td_var_offset(fsync_blocks),
860 .help = "Issue fsync for writes every given number of blocks",
865 .type = FIO_OPT_BOOL,
866 .off1 = td_var_offset(odirect),
867 .help = "Use O_DIRECT IO (negates buffered)",
872 .type = FIO_OPT_BOOL,
873 .off1 = td_var_offset(odirect),
875 .help = "Use buffered IO (negates direct)",
880 .type = FIO_OPT_BOOL,
881 .off1 = td_var_offset(overwrite),
882 .help = "When writing, set whether to overwrite current data",
888 .off1 = td_var_offset(loops),
889 .help = "Number of times to run the job",
895 .off1 = td_var_offset(numjobs),
896 .help = "Duplicate this job this many times",
900 .name = "startdelay",
902 .off1 = td_var_offset(start_delay),
903 .help = "Only start job when this period has passed",
909 .type = FIO_OPT_STR_VAL_TIME,
910 .off1 = td_var_offset(timeout),
911 .help = "Stop workload when this amount of time has passed",
915 .name = "time_based",
916 .type = FIO_OPT_STR_SET,
917 .off1 = td_var_offset(time_based),
918 .help = "Keep running until runtime/timeout is met",
922 .type = FIO_OPT_STR_VAL_TIME,
923 .off1 = td_var_offset(ramp_time),
924 .help = "Ramp up time before measuring performance",
931 .off1 = td_var_offset(mem_type),
932 .help = "Backing type for IO buffers",
937 .help = "Use malloc(3) for IO buffers",
941 .help = "Use shared memory segments for IO buffers",
943 #ifdef FIO_HAVE_HUGETLB
946 .help = "Like shm, but use huge pages",
951 .help = "Use mmap(2) (file or anon) for IO buffers",
953 #ifdef FIO_HAVE_HUGETLB
954 { .ival = "mmaphuge",
955 .oval = MEM_MMAPHUGE,
956 .help = "Like mmap, but use huge pages",
964 .off1 = td_var_offset(verify),
965 .help = "Verify data written",
970 .help = "Don't do IO verification",
974 .help = "Use md5 checksums for verification",
977 .oval = VERIFY_CRC64,
978 .help = "Use crc64 checksums for verification",
981 .oval = VERIFY_CRC32,
982 .help = "Use crc32 checksums for verification",
984 { .ival = "crc32c-intel",
985 .oval = VERIFY_CRC32C_INTEL,
986 .help = "Use hw crc32c checksums for verification",
989 .oval = VERIFY_CRC32C,
990 .help = "Use crc32c checksums for verification",
993 .oval = VERIFY_CRC16,
994 .help = "Use crc16 checksums for verification",
998 .help = "Use crc7 checksums for verification",
1001 .oval = VERIFY_SHA256,
1002 .help = "Use sha256 checksums for verification",
1005 .oval = VERIFY_SHA512,
1006 .help = "Use sha512 checksums for verification",
1009 .oval = VERIFY_META,
1010 .help = "Use io information",
1014 .oval = VERIFY_NULL,
1015 .help = "Pretend to verify",
1020 .name = "do_verify",
1021 .type = FIO_OPT_BOOL,
1022 .off1 = td_var_offset(do_verify),
1023 .help = "Run verification stage after write",
1028 .name = "verifysort",
1029 .type = FIO_OPT_BOOL,
1030 .off1 = td_var_offset(verifysort),
1031 .help = "Sort written verify blocks for read back",
1036 .name = "verify_interval",
1037 .type = FIO_OPT_STR_VAL_INT,
1038 .off1 = td_var_offset(verify_interval),
1039 .minval = 2 * sizeof(struct verify_header),
1040 .help = "Store verify buffer header every N bytes",
1044 .name = "verify_offset",
1045 .type = FIO_OPT_STR_VAL_INT,
1046 .help = "Offset verify header location by N bytes",
1048 .cb = str_verify_offset_cb,
1052 .name = "verify_pattern",
1053 .type = FIO_OPT_INT,
1054 .cb = str_verify_pattern_cb,
1055 .help = "Fill pattern for IO buffers",
1059 .name = "verify_fatal",
1060 .type = FIO_OPT_BOOL,
1061 .off1 = td_var_offset(verify_fatal),
1063 .help = "Exit on a single verify failure, don't continue",
1067 .name = "write_iolog",
1068 .type = FIO_OPT_STR_STORE,
1069 .off1 = td_var_offset(write_iolog_file),
1070 .help = "Store IO pattern to file",
1073 .name = "read_iolog",
1074 .type = FIO_OPT_STR_STORE,
1075 .off1 = td_var_offset(read_iolog_file),
1076 .help = "Playback IO pattern from file",
1079 .name = "exec_prerun",
1080 .type = FIO_OPT_STR_STORE,
1081 .off1 = td_var_offset(exec_prerun),
1082 .help = "Execute this file prior to running job",
1085 .name = "exec_postrun",
1086 .type = FIO_OPT_STR_STORE,
1087 .off1 = td_var_offset(exec_postrun),
1088 .help = "Execute this file after running job",
1090 #ifdef FIO_HAVE_IOSCHED_SWITCH
1092 .name = "ioscheduler",
1093 .type = FIO_OPT_STR_STORE,
1094 .off1 = td_var_offset(ioscheduler),
1095 .help = "Use this IO scheduler on the backing device",
1100 .type = FIO_OPT_STR_VAL,
1101 .off1 = td_var_offset(zone_size),
1102 .help = "Give size of an IO zone",
1107 .type = FIO_OPT_STR_VAL,
1108 .off1 = td_var_offset(zone_skip),
1109 .help = "Space between IO zones",
1114 .type = FIO_OPT_STR_VAL,
1115 .cb = str_lockmem_cb,
1116 .help = "Lock down this amount of memory",
1120 .name = "rwmixread",
1121 .type = FIO_OPT_INT,
1122 .cb = str_rwmix_read_cb,
1124 .help = "Percentage of mixed workload that is reads",
1128 .name = "rwmixwrite",
1129 .type = FIO_OPT_INT,
1130 .cb = str_rwmix_write_cb,
1132 .help = "Percentage of mixed workload that is writes",
1136 .name = "rwmixcycle",
1137 .type = FIO_OPT_DEPRECATED,
1141 .type = FIO_OPT_INT,
1142 .off1 = td_var_offset(nice),
1143 .help = "Set job CPU nice value",
1148 #ifdef FIO_HAVE_IOPRIO
1151 .type = FIO_OPT_INT,
1153 .help = "Set job IO priority value",
1158 .name = "prioclass",
1159 .type = FIO_OPT_INT,
1160 .cb = str_prioclass_cb,
1161 .help = "Set job IO priority class",
1167 .name = "thinktime",
1168 .type = FIO_OPT_INT,
1169 .off1 = td_var_offset(thinktime),
1170 .help = "Idle time between IO buffers (usec)",
1174 .name = "thinktime_spin",
1175 .type = FIO_OPT_INT,
1176 .off1 = td_var_offset(thinktime_spin),
1177 .help = "Start think time by spinning this amount (usec)",
1179 .parent = "thinktime",
1182 .name = "thinktime_blocks",
1183 .type = FIO_OPT_INT,
1184 .off1 = td_var_offset(thinktime_blocks),
1185 .help = "IO buffer period between 'thinktime'",
1187 .parent = "thinktime",
1191 .type = FIO_OPT_INT,
1192 .off1 = td_var_offset(rate),
1193 .help = "Set bandwidth rate",
1197 .type = FIO_OPT_INT,
1198 .off1 = td_var_offset(ratemin),
1199 .help = "Job must meet this rate or it will be shutdown",
1203 .name = "rate_iops",
1204 .type = FIO_OPT_INT,
1205 .off1 = td_var_offset(rate_iops),
1206 .help = "Limit IO used to this number of IO operations/sec",
1209 .name = "rate_iops_min",
1210 .type = FIO_OPT_INT,
1211 .off1 = td_var_offset(rate_iops_min),
1212 .help = "Job must meet this rate or it will be shutdown",
1213 .parent = "rate_iops",
1216 .name = "ratecycle",
1217 .type = FIO_OPT_INT,
1218 .off1 = td_var_offset(ratecycle),
1219 .help = "Window average for rate limits (msec)",
1224 .name = "invalidate",
1225 .type = FIO_OPT_BOOL,
1226 .off1 = td_var_offset(invalidate_cache),
1227 .help = "Invalidate buffer/page cache prior to running job",
1232 .type = FIO_OPT_BOOL,
1233 .off1 = td_var_offset(sync_io),
1234 .help = "Use O_SYNC for buffered writes",
1236 .parent = "buffered",
1239 .name = "bwavgtime",
1240 .type = FIO_OPT_INT,
1241 .off1 = td_var_offset(bw_avg_time),
1242 .help = "Time window over which to calculate bandwidth"
1247 .name = "create_serialize",
1248 .type = FIO_OPT_BOOL,
1249 .off1 = td_var_offset(create_serialize),
1250 .help = "Serialize creating of job files",
1254 .name = "create_fsync",
1255 .type = FIO_OPT_BOOL,
1256 .off1 = td_var_offset(create_fsync),
1257 .help = "Fsync file after creation",
1262 .type = FIO_OPT_INT,
1263 .off1 = td_var_offset(cpuload),
1264 .help = "Use this percentage of CPU",
1267 .name = "cpuchunks",
1268 .type = FIO_OPT_INT,
1269 .off1 = td_var_offset(cpucycle),
1270 .help = "Length of the CPU burn cycles (usecs)",
1272 .parent = "cpuload",
1274 #ifdef FIO_HAVE_CPU_AFFINITY
1277 .type = FIO_OPT_INT,
1278 .cb = str_cpumask_cb,
1279 .help = "CPU affinity mask",
1282 .name = "cpus_allowed",
1283 .type = FIO_OPT_STR,
1284 .cb = str_cpus_allowed_cb,
1285 .help = "Set CPUs allowed",
1289 .name = "end_fsync",
1290 .type = FIO_OPT_BOOL,
1291 .off1 = td_var_offset(end_fsync),
1292 .help = "Include fsync at the end of job",
1296 .name = "fsync_on_close",
1297 .type = FIO_OPT_BOOL,
1298 .off1 = td_var_offset(fsync_on_close),
1299 .help = "fsync files on close",
1304 .type = FIO_OPT_BOOL,
1305 .off1 = td_var_offset(unlink),
1306 .help = "Unlink created files after job has completed",
1311 .type = FIO_OPT_STR_SET,
1312 .cb = str_exitall_cb,
1313 .help = "Terminate all jobs when one exits",
1316 .name = "stonewall",
1317 .type = FIO_OPT_STR_SET,
1318 .off1 = td_var_offset(stonewall),
1319 .help = "Insert a hard barrier between this job and previous",
1322 .name = "new_group",
1323 .type = FIO_OPT_STR_SET,
1324 .off1 = td_var_offset(new_group),
1325 .help = "Mark the start of a new group (for reporting)",
1329 .type = FIO_OPT_STR_SET,
1330 .off1 = td_var_offset(use_thread),
1331 .help = "Use threads instead of forks",
1334 .name = "write_bw_log",
1335 .type = FIO_OPT_STR,
1336 .off1 = td_var_offset(write_bw_log),
1337 .cb = str_write_bw_log_cb,
1338 .help = "Write log of bandwidth during run",
1341 .name = "write_lat_log",
1342 .type = FIO_OPT_STR,
1343 .off1 = td_var_offset(write_lat_log),
1344 .cb = str_write_lat_log_cb,
1345 .help = "Write log of latency during run",
1348 .name = "hugepage-size",
1349 .type = FIO_OPT_STR_VAL_INT,
1350 .off1 = td_var_offset(hugepage_size),
1351 .help = "When using hugepages, specify size of each page",
1352 .def = __stringify(FIO_HUGE_PAGE),
1355 .name = "group_reporting",
1356 .type = FIO_OPT_STR_SET,
1357 .off1 = td_var_offset(group_reporting),
1358 .help = "Do reporting on a per-group basis",
1361 .name = "zero_buffers",
1362 .type = FIO_OPT_STR_SET,
1363 .off1 = td_var_offset(zero_buffers),
1364 .help = "Init IO buffers to all zeroes",
1367 .name = "refill_buffers",
1368 .type = FIO_OPT_STR_SET,
1369 .off1 = td_var_offset(refill_buffers),
1370 .help = "Refill IO buffers on every IO submit",
1372 #ifdef FIO_HAVE_DISK_UTIL
1374 .name = "disk_util",
1375 .type = FIO_OPT_BOOL,
1376 .off1 = td_var_offset(do_disk_util),
1377 .help = "Log disk utilization statistics",
1382 .name = "gtod_reduce",
1383 .type = FIO_OPT_BOOL,
1384 .help = "Greatly reduce number of gettimeofday() calls",
1385 .cb = str_gtod_reduce_cb,
1389 .name = "disable_clat",
1390 .type = FIO_OPT_BOOL,
1391 .off1 = td_var_offset(disable_clat),
1392 .help = "Disable completion latency numbers",
1393 .parent = "gtod_reduce",
1397 .name = "disable_slat",
1398 .type = FIO_OPT_BOOL,
1399 .off1 = td_var_offset(disable_slat),
1400 .help = "Disable submissionn latency numbers",
1401 .parent = "gtod_reduce",
1405 .name = "disable_bw_measurement",
1406 .type = FIO_OPT_BOOL,
1407 .off1 = td_var_offset(disable_bw),
1408 .help = "Disable bandwidth logging",
1409 .parent = "gtod_reduce",
1414 .type = FIO_OPT_INT,
1415 .cb = str_gtod_cpu_cb,
1416 .help = "Setup dedicated gettimeofday() thread on this CPU",
1423 void fio_options_dup_and_init(struct option *long_options)
1425 struct fio_option *o;
1428 options_init(options);
1431 while (long_options[i].name)
1436 long_options[i].name = (char *) o->name;
1437 long_options[i].val = FIO_GETOPT_JOB;
1438 if (o->type == FIO_OPT_STR_SET)
1439 long_options[i].has_arg = no_argument;
1441 long_options[i].has_arg = required_argument;
1445 assert(i < FIO_NR_OPTIONS);
1449 int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
1453 sort_options(opts, options, num_opts);
1455 for (ret = 0, i = 0; i < num_opts; i++)
1456 ret |= parse_option(opts[i], options, td);
1461 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
1463 return parse_cmd_option(opt, val, options, td);
1466 void fio_fill_default_options(struct thread_data *td)
1468 fill_default_options(td, options);
1471 int fio_show_option_help(const char *opt)
1473 return show_cmd_help(options, opt);
1476 static void __options_mem(struct thread_data *td, int alloc)
1478 struct thread_options *o = &td->o;
1479 struct fio_option *opt;
1483 for (i = 0, opt = &options[0]; opt->name; i++, opt = &options[i]) {
1484 if (opt->type != FIO_OPT_STR_STORE)
1487 ptr = (void *) o + opt->off1;
1490 *ptr = strdup(*ptr);
1500 * dupe FIO_OPT_STR_STORE options
1502 void options_mem_dupe(struct thread_data *td)
1504 __options_mem(td, 1);
1507 void options_mem_free(struct thread_data fio_unused *td)
1510 __options_mem(td, 0);