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);
163 static int str_mem_cb(void *data, const char *mem)
165 struct thread_data *td = data;
167 if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP) {
168 td->mmapfile = get_opt_postfix(mem);
169 if (td->o.mem_type == MEM_MMAPHUGE && !td->mmapfile) {
170 log_err("fio: mmaphuge:/path/to/file\n");
178 static int str_lockmem_cb(void fio_unused *data, unsigned long *val)
184 static int str_rwmix_read_cb(void *data, unsigned int *val)
186 struct thread_data *td = data;
188 td->o.rwmix[DDIR_READ] = *val;
189 td->o.rwmix[DDIR_WRITE] = 100 - *val;
193 static int str_rwmix_write_cb(void *data, unsigned int *val)
195 struct thread_data *td = data;
197 td->o.rwmix[DDIR_WRITE] = *val;
198 td->o.rwmix[DDIR_READ] = 100 - *val;
202 #ifdef FIO_HAVE_IOPRIO
203 static int str_prioclass_cb(void *data, unsigned int *val)
205 struct thread_data *td = data;
209 * mask off old class bits, str_prio_cb() may have set a default class
211 mask = (1 << IOPRIO_CLASS_SHIFT) - 1;
214 td->ioprio |= *val << IOPRIO_CLASS_SHIFT;
219 static int str_prio_cb(void *data, unsigned int *val)
221 struct thread_data *td = data;
226 * If no class is set, assume BE
228 if ((td->ioprio >> IOPRIO_CLASS_SHIFT) == 0)
229 td->ioprio |= IOPRIO_CLASS_BE << IOPRIO_CLASS_SHIFT;
236 static int str_exitall_cb(void)
238 exitall_on_terminate = 1;
242 #ifdef FIO_HAVE_CPU_AFFINITY
243 static int str_cpumask_cb(void *data, unsigned int *val)
245 struct thread_data *td = data;
248 CPU_ZERO(&td->o.cpumask);
250 for (i = 0; i < sizeof(int) * 8; i++)
252 CPU_SET(*val, &td->o.cpumask);
254 td->o.cpumask_set = 1;
258 static int str_cpus_allowed_cb(void *data, const char *input)
260 struct thread_data *td = data;
263 CPU_ZERO(&td->o.cpumask);
265 p = str = strdup(input);
267 strip_blank_front(&str);
268 strip_blank_end(str);
270 while ((cpu = strsep(&str, ",")) != NULL) {
273 CPU_SET(atoi(cpu), &td->o.cpumask);
277 td->o.cpumask_set = 1;
282 static int str_fst_cb(void *data, const char *str)
284 struct thread_data *td = data;
285 char *nr = get_opt_postfix(str);
287 td->file_service_nr = 1;
289 td->file_service_nr = atoi(nr);
294 static int check_dir(struct thread_data *td, char *fname)
296 char file[PATH_MAX], *dir;
299 if (td->o.directory) {
300 strcpy(file, td->o.directory);
305 sprintf(file + elen, "%s", fname);
312 * We can't do this on FIO_DISKLESSIO engines. The engine isn't loaded
313 * yet, so we can't do this check right here...
315 if (lstat(dir, &sb) < 0) {
318 log_err("fio: %s is not a directory\n", dir);
319 td_verror(td, ret, "lstat");
323 if (!S_ISDIR(sb.st_mode)) {
324 log_err("fio: %s is not a directory\n", dir);
333 static int str_filename_cb(void *data, const char *input)
335 struct thread_data *td = data;
336 char *fname, *str, *p;
338 p = str = strdup(input);
340 strip_blank_front(&str);
341 strip_blank_end(str);
343 if (!td->files_index)
346 while ((fname = strsep(&str, ":")) != NULL) {
349 if (check_dir(td, fname)) {
361 static int str_directory_cb(void *data, const char fio_unused *str)
363 struct thread_data *td = data;
366 if (lstat(td->o.directory, &sb) < 0) {
369 log_err("fio: %s is not a directory\n", td->o.directory);
370 td_verror(td, ret, "lstat");
373 if (!S_ISDIR(sb.st_mode)) {
374 log_err("fio: %s is not a directory\n", td->o.directory);
381 static int str_opendir_cb(void *data, const char fio_unused *str)
383 struct thread_data *td = data;
385 if (!td->files_index)
388 return add_dir_files(td, td->o.opendir);
391 static int str_verify_offset_cb(void *data, unsigned int *off)
393 struct thread_data *td = data;
395 if (*off && *off < sizeof(struct verify_header)) {
396 log_err("fio: verify_offset too small\n");
400 td->o.verify_offset = *off;
404 static int str_verify_pattern_cb(void *data, unsigned int *off)
406 struct thread_data *td = data;
411 td->o.verify_pattern_bytes = 1;
413 td->o.verify_pattern_bytes = 2;
415 td->o.verify_pattern_bytes = 3;
417 td->o.verify_pattern_bytes = 4;
419 td->o.verify_pattern = *off;
423 static int str_lockfile_cb(void *data, const char *str)
425 struct thread_data *td = data;
426 char *nr = get_opt_postfix(str);
428 td->o.lockfile_batch = 1;
430 td->o.lockfile_batch = atoi(nr);
435 static int str_gtod_reduce_cb(void *data, int *il)
437 struct thread_data *td = data;
440 td->o.disable_clat = !!val;
441 td->o.disable_slat = !!val;
442 td->o.disable_bw = !!val;
444 td->tv_cache_mask = 63;
449 #define __stringify_1(x) #x
450 #define __stringify(x) __stringify_1(x)
453 * Map of job/command line options
455 static struct fio_option options[] = {
457 .name = "description",
458 .type = FIO_OPT_STR_STORE,
459 .off1 = td_var_offset(description),
460 .help = "Text job description",
464 .type = FIO_OPT_STR_STORE,
465 .off1 = td_var_offset(name),
466 .help = "Name of this job",
470 .type = FIO_OPT_STR_STORE,
471 .off1 = td_var_offset(directory),
472 .cb = str_directory_cb,
473 .help = "Directory to store files in",
477 .type = FIO_OPT_STR_STORE,
478 .off1 = td_var_offset(filename),
479 .cb = str_filename_cb,
480 .prio = 1, /* must come before "directory" */
481 .help = "File(s) to use for the workload",
486 .cb = str_lockfile_cb,
487 .off1 = td_var_offset(file_lock_mode),
488 .help = "Lock file when doing IO to it",
489 .parent = "filename",
493 .oval = FILE_LOCK_NONE,
494 .help = "No file locking",
496 { .ival = "exclusive",
497 .oval = FILE_LOCK_EXCLUSIVE,
498 .help = "Exclusive file lock",
502 .oval = FILE_LOCK_READWRITE,
503 .help = "Read vs write lock",
509 .type = FIO_OPT_STR_STORE,
510 .off1 = td_var_offset(opendir),
511 .cb = str_opendir_cb,
512 .help = "Recursively add files from this directory and down",
516 .alias = "readwrite",
519 .off1 = td_var_offset(td_ddir),
520 .help = "IO direction",
524 .oval = TD_DDIR_READ,
525 .help = "Sequential read",
528 .oval = TD_DDIR_WRITE,
529 .help = "Sequential write",
531 { .ival = "randread",
532 .oval = TD_DDIR_RANDREAD,
533 .help = "Random read",
535 { .ival = "randwrite",
536 .oval = TD_DDIR_RANDWRITE,
537 .help = "Random write",
541 .help = "Sequential read and write mix",
544 .oval = TD_DDIR_RANDRW,
545 .help = "Random read and write mix"
551 .type = FIO_OPT_STR_STORE,
552 .off1 = td_var_offset(ioengine),
553 .help = "IO engine to use",
557 .help = "Use read/write",
560 .help = "Use pread/pwrite",
563 .help = "Use readv/writev",
565 #ifdef FIO_HAVE_LIBAIO
567 .help = "Linux native asynchronous IO",
570 #ifdef FIO_HAVE_POSIXAIO
571 { .ival = "posixaio",
572 .help = "POSIX asynchronous IO",
575 #ifdef FIO_HAVE_SOLARISAIO
576 { .ival = "solarisaio",
577 .help = "Solaris native asynchronous IO",
581 .help = "Memory mapped IO",
583 #ifdef FIO_HAVE_SPLICE
585 .help = "splice/vmsplice based IO",
587 { .ival = "netsplice",
588 .help = "splice/vmsplice to/from the network",
593 .help = "SCSI generic v3 IO",
597 .help = "Testing engine (no data transfer)",
600 .help = "Network IO",
602 #ifdef FIO_HAVE_SYSLET
603 { .ival = "syslet-rw",
604 .help = "syslet enabled async pread/pwrite IO",
608 .help = "CPU cycler burner engine",
610 #ifdef FIO_HAVE_GUASI
612 .help = "GUASI IO engine",
615 { .ival = "external",
616 .help = "Load external engine (append name)",
623 .off1 = td_var_offset(iodepth),
624 .help = "Amount of IO buffers to keep in flight",
629 .name = "iodepth_batch",
630 .alias = "iodepth_batch_submit",
632 .off1 = td_var_offset(iodepth_batch),
633 .help = "Number of IO to submit in one go",
639 .name = "iodepth_batch_complete",
641 .off1 = td_var_offset(iodepth_batch_complete),
642 .help = "Number of IO to retrieve in one go",
648 .name = "iodepth_low",
650 .off1 = td_var_offset(iodepth_low),
651 .help = "Low water mark for queuing depth",
656 .type = FIO_OPT_STR_VAL,
657 .off1 = td_var_offset(size),
659 .help = "Total size of device or files",
662 .name = "fill_device",
663 .type = FIO_OPT_BOOL,
664 .off1 = td_var_offset(fill_device),
665 .help = "Write until an ENOSPC error occurs",
670 .type = FIO_OPT_STR_VAL,
671 .off1 = td_var_offset(file_size_low),
672 .off2 = td_var_offset(file_size_high),
674 .help = "Size of individual files",
678 .alias = "fileoffset",
679 .type = FIO_OPT_STR_VAL,
680 .off1 = td_var_offset(start_offset),
681 .help = "Start IO from this offset",
686 .alias = "blocksize",
687 .type = FIO_OPT_STR_VAL_INT,
688 .off1 = td_var_offset(bs[DDIR_READ]),
689 .off2 = td_var_offset(bs[DDIR_WRITE]),
691 .help = "Block size unit",
697 .alias = "blocksize_range",
698 .type = FIO_OPT_RANGE,
699 .off1 = td_var_offset(min_bs[DDIR_READ]),
700 .off2 = td_var_offset(max_bs[DDIR_READ]),
701 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
702 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
704 .help = "Set block size range (in more detail than bs)",
710 .cb = str_bssplit_cb,
711 .help = "Set a specific mix of block sizes",
715 .name = "bs_unaligned",
716 .alias = "blocksize_unaligned",
717 .type = FIO_OPT_STR_SET,
718 .off1 = td_var_offset(bs_unaligned),
719 .help = "Don't sector align IO buffer sizes",
723 .name = "randrepeat",
724 .type = FIO_OPT_BOOL,
725 .off1 = td_var_offset(rand_repeatable),
726 .help = "Use repeatable random IO pattern",
731 .name = "norandommap",
732 .type = FIO_OPT_STR_SET,
733 .off1 = td_var_offset(norandommap),
734 .help = "Accept potential duplicate random blocks",
738 .name = "softrandommap",
739 .type = FIO_OPT_BOOL,
740 .off1 = td_var_offset(softrandommap),
741 .help = "Set norandommap if randommap allocation fails",
742 .parent = "norandommap",
748 .off1 = td_var_offset(nr_files),
749 .help = "Split job workload between this number of files",
755 .off1 = td_var_offset(open_files),
756 .help = "Number of files to keep open at the same time",
759 .name = "file_service_type",
762 .off1 = td_var_offset(file_service_type),
763 .help = "How to select which file to service next",
767 .oval = FIO_FSERVICE_RANDOM,
768 .help = "Choose a file at random",
770 { .ival = "roundrobin",
771 .oval = FIO_FSERVICE_RR,
772 .help = "Round robin select files",
778 .name = "fadvise_hint",
779 .type = FIO_OPT_BOOL,
780 .off1 = td_var_offset(fadvise_hint),
781 .help = "Use fadvise() to advise the kernel on IO pattern",
787 .off1 = td_var_offset(fsync_blocks),
788 .help = "Issue fsync for writes every given number of blocks",
793 .type = FIO_OPT_BOOL,
794 .off1 = td_var_offset(odirect),
795 .help = "Use O_DIRECT IO (negates buffered)",
800 .type = FIO_OPT_BOOL,
801 .off1 = td_var_offset(odirect),
803 .help = "Use buffered IO (negates direct)",
808 .type = FIO_OPT_BOOL,
809 .off1 = td_var_offset(overwrite),
810 .help = "When writing, set whether to overwrite current data",
816 .off1 = td_var_offset(loops),
817 .help = "Number of times to run the job",
823 .off1 = td_var_offset(numjobs),
824 .help = "Duplicate this job this many times",
828 .name = "startdelay",
830 .off1 = td_var_offset(start_delay),
831 .help = "Only start job when this period has passed",
837 .type = FIO_OPT_STR_VAL_TIME,
838 .off1 = td_var_offset(timeout),
839 .help = "Stop workload when this amount of time has passed",
843 .name = "time_based",
844 .type = FIO_OPT_STR_SET,
845 .off1 = td_var_offset(time_based),
846 .help = "Keep running until runtime/timeout is met",
850 .type = FIO_OPT_STR_VAL_TIME,
851 .off1 = td_var_offset(ramp_time),
852 .help = "Ramp up time before measuring performance",
859 .off1 = td_var_offset(mem_type),
860 .help = "Backing type for IO buffers",
865 .help = "Use malloc(3) for IO buffers",
869 .help = "Use shared memory segments for IO buffers",
871 #ifdef FIO_HAVE_HUGETLB
874 .help = "Like shm, but use huge pages",
879 .help = "Use mmap(2) (file or anon) for IO buffers",
881 #ifdef FIO_HAVE_HUGETLB
882 { .ival = "mmaphuge",
883 .oval = MEM_MMAPHUGE,
884 .help = "Like mmap, but use huge pages",
892 .off1 = td_var_offset(verify),
893 .help = "Verify data written",
898 .help = "Don't do IO verification",
902 .help = "Use md5 checksums for verification",
905 .oval = VERIFY_CRC64,
906 .help = "Use crc64 checksums for verification",
909 .oval = VERIFY_CRC32,
910 .help = "Use crc32 checksums for verification",
912 { .ival = "crc32c-intel",
913 .oval = VERIFY_CRC32C_INTEL,
914 .help = "Use hw crc32c checksums for verification",
917 .oval = VERIFY_CRC32C,
918 .help = "Use crc32c checksums for verification",
921 .oval = VERIFY_CRC16,
922 .help = "Use crc16 checksums for verification",
926 .help = "Use crc7 checksums for verification",
929 .oval = VERIFY_SHA256,
930 .help = "Use sha256 checksums for verification",
933 .oval = VERIFY_SHA512,
934 .help = "Use sha512 checksums for verification",
938 .help = "Use io information",
943 .help = "Pretend to verify",
949 .type = FIO_OPT_BOOL,
950 .off1 = td_var_offset(do_verify),
951 .help = "Run verification stage after write",
956 .name = "verifysort",
957 .type = FIO_OPT_BOOL,
958 .off1 = td_var_offset(verifysort),
959 .help = "Sort written verify blocks for read back",
964 .name = "verify_interval",
965 .type = FIO_OPT_STR_VAL_INT,
966 .off1 = td_var_offset(verify_interval),
967 .minval = 2 * sizeof(struct verify_header),
968 .help = "Store verify buffer header every N bytes",
972 .name = "verify_offset",
973 .type = FIO_OPT_STR_VAL_INT,
974 .help = "Offset verify header location by N bytes",
976 .cb = str_verify_offset_cb,
980 .name = "verify_pattern",
982 .cb = str_verify_pattern_cb,
983 .help = "Fill pattern for IO buffers",
987 .name = "verify_fatal",
988 .type = FIO_OPT_BOOL,
989 .off1 = td_var_offset(verify_fatal),
991 .help = "Exit on a single verify failure, don't continue",
995 .name = "write_iolog",
996 .type = FIO_OPT_STR_STORE,
997 .off1 = td_var_offset(write_iolog_file),
998 .help = "Store IO pattern to file",
1001 .name = "read_iolog",
1002 .type = FIO_OPT_STR_STORE,
1003 .off1 = td_var_offset(read_iolog_file),
1004 .help = "Playback IO pattern from file",
1007 .name = "exec_prerun",
1008 .type = FIO_OPT_STR_STORE,
1009 .off1 = td_var_offset(exec_prerun),
1010 .help = "Execute this file prior to running job",
1013 .name = "exec_postrun",
1014 .type = FIO_OPT_STR_STORE,
1015 .off1 = td_var_offset(exec_postrun),
1016 .help = "Execute this file after running job",
1018 #ifdef FIO_HAVE_IOSCHED_SWITCH
1020 .name = "ioscheduler",
1021 .type = FIO_OPT_STR_STORE,
1022 .off1 = td_var_offset(ioscheduler),
1023 .help = "Use this IO scheduler on the backing device",
1028 .type = FIO_OPT_STR_VAL,
1029 .off1 = td_var_offset(zone_size),
1030 .help = "Give size of an IO zone",
1035 .type = FIO_OPT_STR_VAL,
1036 .off1 = td_var_offset(zone_skip),
1037 .help = "Space between IO zones",
1042 .type = FIO_OPT_STR_VAL,
1043 .cb = str_lockmem_cb,
1044 .help = "Lock down this amount of memory",
1048 .name = "rwmixread",
1049 .type = FIO_OPT_INT,
1050 .cb = str_rwmix_read_cb,
1052 .help = "Percentage of mixed workload that is reads",
1056 .name = "rwmixwrite",
1057 .type = FIO_OPT_INT,
1058 .cb = str_rwmix_write_cb,
1060 .help = "Percentage of mixed workload that is writes",
1064 .name = "rwmixcycle",
1065 .type = FIO_OPT_DEPRECATED,
1069 .type = FIO_OPT_INT,
1070 .off1 = td_var_offset(nice),
1071 .help = "Set job CPU nice value",
1076 #ifdef FIO_HAVE_IOPRIO
1079 .type = FIO_OPT_INT,
1081 .help = "Set job IO priority value",
1086 .name = "prioclass",
1087 .type = FIO_OPT_INT,
1088 .cb = str_prioclass_cb,
1089 .help = "Set job IO priority class",
1095 .name = "thinktime",
1096 .type = FIO_OPT_INT,
1097 .off1 = td_var_offset(thinktime),
1098 .help = "Idle time between IO buffers (usec)",
1102 .name = "thinktime_spin",
1103 .type = FIO_OPT_INT,
1104 .off1 = td_var_offset(thinktime_spin),
1105 .help = "Start think time by spinning this amount (usec)",
1107 .parent = "thinktime",
1110 .name = "thinktime_blocks",
1111 .type = FIO_OPT_INT,
1112 .off1 = td_var_offset(thinktime_blocks),
1113 .help = "IO buffer period between 'thinktime'",
1115 .parent = "thinktime",
1119 .type = FIO_OPT_INT,
1120 .off1 = td_var_offset(rate),
1121 .help = "Set bandwidth rate",
1125 .type = FIO_OPT_INT,
1126 .off1 = td_var_offset(ratemin),
1127 .help = "Job must meet this rate or it will be shutdown",
1131 .name = "rate_iops",
1132 .type = FIO_OPT_INT,
1133 .off1 = td_var_offset(rate_iops),
1134 .help = "Limit IO used to this number of IO operations/sec",
1137 .name = "rate_iops_min",
1138 .type = FIO_OPT_INT,
1139 .off1 = td_var_offset(rate_iops_min),
1140 .help = "Job must meet this rate or it will be shutdown",
1141 .parent = "rate_iops",
1144 .name = "ratecycle",
1145 .type = FIO_OPT_INT,
1146 .off1 = td_var_offset(ratecycle),
1147 .help = "Window average for rate limits (msec)",
1152 .name = "invalidate",
1153 .type = FIO_OPT_BOOL,
1154 .off1 = td_var_offset(invalidate_cache),
1155 .help = "Invalidate buffer/page cache prior to running job",
1160 .type = FIO_OPT_BOOL,
1161 .off1 = td_var_offset(sync_io),
1162 .help = "Use O_SYNC for buffered writes",
1164 .parent = "buffered",
1167 .name = "bwavgtime",
1168 .type = FIO_OPT_INT,
1169 .off1 = td_var_offset(bw_avg_time),
1170 .help = "Time window over which to calculate bandwidth"
1175 .name = "create_serialize",
1176 .type = FIO_OPT_BOOL,
1177 .off1 = td_var_offset(create_serialize),
1178 .help = "Serialize creating of job files",
1182 .name = "create_fsync",
1183 .type = FIO_OPT_BOOL,
1184 .off1 = td_var_offset(create_fsync),
1185 .help = "Fsync file after creation",
1190 .type = FIO_OPT_INT,
1191 .off1 = td_var_offset(cpuload),
1192 .help = "Use this percentage of CPU",
1195 .name = "cpuchunks",
1196 .type = FIO_OPT_INT,
1197 .off1 = td_var_offset(cpucycle),
1198 .help = "Length of the CPU burn cycles (usecs)",
1200 .parent = "cpuload",
1202 #ifdef FIO_HAVE_CPU_AFFINITY
1205 .type = FIO_OPT_INT,
1206 .cb = str_cpumask_cb,
1207 .help = "CPU affinity mask",
1210 .name = "cpus_allowed",
1211 .type = FIO_OPT_STR,
1212 .cb = str_cpus_allowed_cb,
1213 .help = "Set CPUs allowed",
1217 .name = "end_fsync",
1218 .type = FIO_OPT_BOOL,
1219 .off1 = td_var_offset(end_fsync),
1220 .help = "Include fsync at the end of job",
1224 .name = "fsync_on_close",
1225 .type = FIO_OPT_BOOL,
1226 .off1 = td_var_offset(fsync_on_close),
1227 .help = "fsync files on close",
1232 .type = FIO_OPT_BOOL,
1233 .off1 = td_var_offset(unlink),
1234 .help = "Unlink created files after job has completed",
1239 .type = FIO_OPT_STR_SET,
1240 .cb = str_exitall_cb,
1241 .help = "Terminate all jobs when one exits",
1244 .name = "stonewall",
1245 .type = FIO_OPT_STR_SET,
1246 .off1 = td_var_offset(stonewall),
1247 .help = "Insert a hard barrier between this job and previous",
1250 .name = "new_group",
1251 .type = FIO_OPT_STR_SET,
1252 .off1 = td_var_offset(new_group),
1253 .help = "Mark the start of a new group (for reporting)",
1257 .type = FIO_OPT_STR_SET,
1258 .off1 = td_var_offset(use_thread),
1259 .help = "Use threads instead of forks",
1262 .name = "write_bw_log",
1263 .type = FIO_OPT_STR_SET,
1264 .off1 = td_var_offset(write_bw_log),
1265 .help = "Write log of bandwidth during run",
1268 .name = "write_lat_log",
1269 .type = FIO_OPT_STR_SET,
1270 .off1 = td_var_offset(write_lat_log),
1271 .help = "Write log of latency during run",
1274 .name = "hugepage-size",
1275 .type = FIO_OPT_STR_VAL_INT,
1276 .off1 = td_var_offset(hugepage_size),
1277 .help = "When using hugepages, specify size of each page",
1278 .def = __stringify(FIO_HUGE_PAGE),
1281 .name = "group_reporting",
1282 .type = FIO_OPT_STR_SET,
1283 .off1 = td_var_offset(group_reporting),
1284 .help = "Do reporting on a per-group basis",
1287 .name = "zero_buffers",
1288 .type = FIO_OPT_STR_SET,
1289 .off1 = td_var_offset(zero_buffers),
1290 .help = "Init IO buffers to all zeroes",
1293 .name = "refill_buffers",
1294 .type = FIO_OPT_STR_SET,
1295 .off1 = td_var_offset(refill_buffers),
1296 .help = "Refill IO buffers on every IO submit",
1298 #ifdef FIO_HAVE_DISK_UTIL
1300 .name = "disk_util",
1301 .type = FIO_OPT_BOOL,
1302 .off1 = td_var_offset(do_disk_util),
1303 .help = "Log disk utilization statistics",
1308 .name = "gtod_reduce",
1309 .type = FIO_OPT_BOOL,
1310 .help = "Greatly reduce number of gettimeofday() calls",
1311 .cb = str_gtod_reduce_cb,
1315 .name = "disable_clat",
1316 .type = FIO_OPT_BOOL,
1317 .off1 = td_var_offset(disable_clat),
1318 .help = "Disable completion latency numbers",
1319 .parent = "gtod_reduce",
1323 .name = "disable_slat",
1324 .type = FIO_OPT_BOOL,
1325 .off1 = td_var_offset(disable_slat),
1326 .help = "Disable submissionn latency numbers",
1327 .parent = "gtod_reduce",
1331 .name = "disable_bw_measurement",
1332 .type = FIO_OPT_BOOL,
1333 .off1 = td_var_offset(disable_bw),
1334 .help = "Disable bandwidth logging",
1335 .parent = "gtod_reduce",
1343 void fio_options_dup_and_init(struct option *long_options)
1345 struct fio_option *o;
1348 options_init(options);
1351 while (long_options[i].name)
1356 long_options[i].name = (char *) o->name;
1357 long_options[i].val = FIO_GETOPT_JOB;
1358 if (o->type == FIO_OPT_STR_SET)
1359 long_options[i].has_arg = no_argument;
1361 long_options[i].has_arg = required_argument;
1365 assert(i < FIO_NR_OPTIONS);
1369 int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
1373 sort_options(opts, options, num_opts);
1375 for (ret = 0, i = 0; i < num_opts; i++)
1376 ret |= parse_option(opts[i], options, td);
1381 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
1383 return parse_cmd_option(opt, val, options, td);
1386 void fio_fill_default_options(struct thread_data *td)
1388 fill_default_options(td, options);
1391 int fio_show_option_help(const char *opt)
1393 return show_cmd_help(options, opt);
1396 static void __options_mem(struct thread_data *td, int alloc)
1398 struct thread_options *o = &td->o;
1399 struct fio_option *opt;
1403 for (i = 0, opt = &options[0]; opt->name; i++, opt = &options[i]) {
1404 if (opt->type != FIO_OPT_STR_STORE)
1407 ptr = (void *) o + opt->off1;
1410 *ptr = strdup(*ptr);
1420 * dupe FIO_OPT_STR_STORE options
1422 void options_mem_dupe(struct thread_data *td)
1424 __options_mem(td, 1);
1427 void options_mem_free(struct thread_data fio_unused *td)
1430 __options_mem(td, 0);