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 #define __stringify_1(x) #x
436 #define __stringify(x) __stringify_1(x)
439 * Map of job/command line options
441 static struct fio_option options[] = {
443 .name = "description",
444 .type = FIO_OPT_STR_STORE,
445 .off1 = td_var_offset(description),
446 .help = "Text job description",
450 .type = FIO_OPT_STR_STORE,
451 .off1 = td_var_offset(name),
452 .help = "Name of this job",
456 .type = FIO_OPT_STR_STORE,
457 .off1 = td_var_offset(directory),
458 .cb = str_directory_cb,
459 .help = "Directory to store files in",
463 .type = FIO_OPT_STR_STORE,
464 .off1 = td_var_offset(filename),
465 .cb = str_filename_cb,
466 .prio = 1, /* must come before "directory" */
467 .help = "File(s) to use for the workload",
472 .cb = str_lockfile_cb,
473 .off1 = td_var_offset(file_lock_mode),
474 .help = "Lock file when doing IO to it",
475 .parent = "filename",
479 .oval = FILE_LOCK_NONE,
480 .help = "No file locking",
482 { .ival = "exclusive",
483 .oval = FILE_LOCK_EXCLUSIVE,
484 .help = "Exclusive file lock",
488 .oval = FILE_LOCK_READWRITE,
489 .help = "Read vs write lock",
495 .type = FIO_OPT_STR_STORE,
496 .off1 = td_var_offset(opendir),
497 .cb = str_opendir_cb,
498 .help = "Recursively add files from this directory and down",
502 .alias = "readwrite",
505 .off1 = td_var_offset(td_ddir),
506 .help = "IO direction",
510 .oval = TD_DDIR_READ,
511 .help = "Sequential read",
514 .oval = TD_DDIR_WRITE,
515 .help = "Sequential write",
517 { .ival = "randread",
518 .oval = TD_DDIR_RANDREAD,
519 .help = "Random read",
521 { .ival = "randwrite",
522 .oval = TD_DDIR_RANDWRITE,
523 .help = "Random write",
527 .help = "Sequential read and write mix",
530 .oval = TD_DDIR_RANDRW,
531 .help = "Random read and write mix"
537 .type = FIO_OPT_STR_STORE,
538 .off1 = td_var_offset(ioengine),
539 .help = "IO engine to use",
543 .help = "Use read/write",
546 .help = "Use pread/pwrite",
549 .help = "Use readv/writev",
551 #ifdef FIO_HAVE_LIBAIO
553 .help = "Linux native asynchronous IO",
556 #ifdef FIO_HAVE_POSIXAIO
557 { .ival = "posixaio",
558 .help = "POSIX asynchronous IO",
561 #ifdef FIO_HAVE_SOLARISAIO
562 { .ival = "solarisaio",
563 .help = "Solaris native asynchronous IO",
567 .help = "Memory mapped IO",
569 #ifdef FIO_HAVE_SPLICE
571 .help = "splice/vmsplice based IO",
573 { .ival = "netsplice",
574 .help = "splice/vmsplice to/from the network",
579 .help = "SCSI generic v3 IO",
583 .help = "Testing engine (no data transfer)",
586 .help = "Network IO",
588 #ifdef FIO_HAVE_SYSLET
589 { .ival = "syslet-rw",
590 .help = "syslet enabled async pread/pwrite IO",
594 .help = "CPU cycler burner engine",
596 #ifdef FIO_HAVE_GUASI
598 .help = "GUASI IO engine",
601 { .ival = "external",
602 .help = "Load external engine (append name)",
609 .off1 = td_var_offset(iodepth),
610 .help = "Amount of IO buffers to keep in flight",
615 .name = "iodepth_batch",
616 .alias = "iodepth_batch_submit",
618 .off1 = td_var_offset(iodepth_batch),
619 .help = "Number of IO to submit in one go",
625 .name = "iodepth_batch_complete",
627 .off1 = td_var_offset(iodepth_batch_complete),
628 .help = "Number of IO to retrieve in one go",
634 .name = "iodepth_low",
636 .off1 = td_var_offset(iodepth_low),
637 .help = "Low water mark for queuing depth",
642 .type = FIO_OPT_STR_VAL,
643 .off1 = td_var_offset(size),
645 .help = "Total size of device or files",
648 .name = "fill_device",
649 .type = FIO_OPT_BOOL,
650 .off1 = td_var_offset(fill_device),
651 .help = "Write until an ENOSPC error occurs",
656 .type = FIO_OPT_STR_VAL,
657 .off1 = td_var_offset(file_size_low),
658 .off2 = td_var_offset(file_size_high),
660 .help = "Size of individual files",
664 .alias = "fileoffset",
665 .type = FIO_OPT_STR_VAL,
666 .off1 = td_var_offset(start_offset),
667 .help = "Start IO from this offset",
672 .alias = "blocksize",
673 .type = FIO_OPT_STR_VAL_INT,
674 .off1 = td_var_offset(bs[DDIR_READ]),
675 .off2 = td_var_offset(bs[DDIR_WRITE]),
677 .help = "Block size unit",
683 .alias = "blocksize_range",
684 .type = FIO_OPT_RANGE,
685 .off1 = td_var_offset(min_bs[DDIR_READ]),
686 .off2 = td_var_offset(max_bs[DDIR_READ]),
687 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
688 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
690 .help = "Set block size range (in more detail than bs)",
696 .cb = str_bssplit_cb,
697 .help = "Set a specific mix of block sizes",
701 .name = "bs_unaligned",
702 .alias = "blocksize_unaligned",
703 .type = FIO_OPT_STR_SET,
704 .off1 = td_var_offset(bs_unaligned),
705 .help = "Don't sector align IO buffer sizes",
709 .name = "randrepeat",
710 .type = FIO_OPT_BOOL,
711 .off1 = td_var_offset(rand_repeatable),
712 .help = "Use repeatable random IO pattern",
717 .name = "norandommap",
718 .type = FIO_OPT_STR_SET,
719 .off1 = td_var_offset(norandommap),
720 .help = "Accept potential duplicate random blocks",
724 .name = "softrandommap",
725 .type = FIO_OPT_BOOL,
726 .off1 = td_var_offset(softrandommap),
727 .help = "Set norandommap if randommap allocation fails",
728 .parent = "norandommap",
734 .off1 = td_var_offset(nr_files),
735 .help = "Split job workload between this number of files",
741 .off1 = td_var_offset(open_files),
742 .help = "Number of files to keep open at the same time",
745 .name = "file_service_type",
748 .off1 = td_var_offset(file_service_type),
749 .help = "How to select which file to service next",
753 .oval = FIO_FSERVICE_RANDOM,
754 .help = "Choose a file at random",
756 { .ival = "roundrobin",
757 .oval = FIO_FSERVICE_RR,
758 .help = "Round robin select files",
764 .name = "fadvise_hint",
765 .type = FIO_OPT_BOOL,
766 .off1 = td_var_offset(fadvise_hint),
767 .help = "Use fadvise() to advise the kernel on IO pattern",
773 .off1 = td_var_offset(fsync_blocks),
774 .help = "Issue fsync for writes every given number of blocks",
779 .type = FIO_OPT_BOOL,
780 .off1 = td_var_offset(odirect),
781 .help = "Use O_DIRECT IO (negates buffered)",
786 .type = FIO_OPT_BOOL,
787 .off1 = td_var_offset(odirect),
789 .help = "Use buffered IO (negates direct)",
794 .type = FIO_OPT_BOOL,
795 .off1 = td_var_offset(overwrite),
796 .help = "When writing, set whether to overwrite current data",
802 .off1 = td_var_offset(loops),
803 .help = "Number of times to run the job",
809 .off1 = td_var_offset(numjobs),
810 .help = "Duplicate this job this many times",
814 .name = "startdelay",
816 .off1 = td_var_offset(start_delay),
817 .help = "Only start job when this period has passed",
823 .type = FIO_OPT_STR_VAL_TIME,
824 .off1 = td_var_offset(timeout),
825 .help = "Stop workload when this amount of time has passed",
829 .name = "time_based",
830 .type = FIO_OPT_STR_SET,
831 .off1 = td_var_offset(time_based),
832 .help = "Keep running until runtime/timeout is met",
836 .type = FIO_OPT_STR_VAL_TIME,
837 .off1 = td_var_offset(ramp_time),
838 .help = "Ramp up time before measuring performance",
845 .off1 = td_var_offset(mem_type),
846 .help = "Backing type for IO buffers",
851 .help = "Use malloc(3) for IO buffers",
855 .help = "Use shared memory segments for IO buffers",
857 #ifdef FIO_HAVE_HUGETLB
860 .help = "Like shm, but use huge pages",
865 .help = "Use mmap(2) (file or anon) for IO buffers",
867 #ifdef FIO_HAVE_HUGETLB
868 { .ival = "mmaphuge",
869 .oval = MEM_MMAPHUGE,
870 .help = "Like mmap, but use huge pages",
878 .off1 = td_var_offset(verify),
879 .help = "Verify data written",
884 .help = "Don't do IO verification",
888 .help = "Use md5 checksums for verification",
891 .oval = VERIFY_CRC64,
892 .help = "Use crc64 checksums for verification",
895 .oval = VERIFY_CRC32,
896 .help = "Use crc32 checksums for verification",
898 { .ival = "crc32c-intel",
899 .oval = VERIFY_CRC32C_INTEL,
900 .help = "Use hw crc32c checksums for verification",
903 .oval = VERIFY_CRC32C,
904 .help = "Use crc32c checksums for verification",
907 .oval = VERIFY_CRC16,
908 .help = "Use crc16 checksums for verification",
912 .help = "Use crc7 checksums for verification",
915 .oval = VERIFY_SHA256,
916 .help = "Use sha256 checksums for verification",
919 .oval = VERIFY_SHA512,
920 .help = "Use sha512 checksums for verification",
924 .help = "Use io information",
929 .help = "Pretend to verify",
935 .type = FIO_OPT_BOOL,
936 .off1 = td_var_offset(do_verify),
937 .help = "Run verification stage after write",
942 .name = "verifysort",
943 .type = FIO_OPT_BOOL,
944 .off1 = td_var_offset(verifysort),
945 .help = "Sort written verify blocks for read back",
950 .name = "verify_interval",
951 .type = FIO_OPT_STR_VAL_INT,
952 .off1 = td_var_offset(verify_interval),
953 .minval = 2 * sizeof(struct verify_header),
954 .help = "Store verify buffer header every N bytes",
958 .name = "verify_offset",
959 .type = FIO_OPT_STR_VAL_INT,
960 .help = "Offset verify header location by N bytes",
962 .cb = str_verify_offset_cb,
966 .name = "verify_pattern",
968 .cb = str_verify_pattern_cb,
969 .help = "Fill pattern for IO buffers",
973 .name = "verify_fatal",
974 .type = FIO_OPT_BOOL,
975 .off1 = td_var_offset(verify_fatal),
977 .help = "Exit on a single verify failure, don't continue",
981 .name = "write_iolog",
982 .type = FIO_OPT_STR_STORE,
983 .off1 = td_var_offset(write_iolog_file),
984 .help = "Store IO pattern to file",
987 .name = "read_iolog",
988 .type = FIO_OPT_STR_STORE,
989 .off1 = td_var_offset(read_iolog_file),
990 .help = "Playback IO pattern from file",
993 .name = "exec_prerun",
994 .type = FIO_OPT_STR_STORE,
995 .off1 = td_var_offset(exec_prerun),
996 .help = "Execute this file prior to running job",
999 .name = "exec_postrun",
1000 .type = FIO_OPT_STR_STORE,
1001 .off1 = td_var_offset(exec_postrun),
1002 .help = "Execute this file after running job",
1004 #ifdef FIO_HAVE_IOSCHED_SWITCH
1006 .name = "ioscheduler",
1007 .type = FIO_OPT_STR_STORE,
1008 .off1 = td_var_offset(ioscheduler),
1009 .help = "Use this IO scheduler on the backing device",
1014 .type = FIO_OPT_STR_VAL,
1015 .off1 = td_var_offset(zone_size),
1016 .help = "Give size of an IO zone",
1021 .type = FIO_OPT_STR_VAL,
1022 .off1 = td_var_offset(zone_skip),
1023 .help = "Space between IO zones",
1028 .type = FIO_OPT_STR_VAL,
1029 .cb = str_lockmem_cb,
1030 .help = "Lock down this amount of memory",
1034 .name = "rwmixread",
1035 .type = FIO_OPT_INT,
1036 .cb = str_rwmix_read_cb,
1038 .help = "Percentage of mixed workload that is reads",
1042 .name = "rwmixwrite",
1043 .type = FIO_OPT_INT,
1044 .cb = str_rwmix_write_cb,
1046 .help = "Percentage of mixed workload that is writes",
1050 .name = "rwmixcycle",
1051 .type = FIO_OPT_DEPRECATED,
1055 .type = FIO_OPT_INT,
1056 .off1 = td_var_offset(nice),
1057 .help = "Set job CPU nice value",
1062 #ifdef FIO_HAVE_IOPRIO
1065 .type = FIO_OPT_INT,
1067 .help = "Set job IO priority value",
1072 .name = "prioclass",
1073 .type = FIO_OPT_INT,
1074 .cb = str_prioclass_cb,
1075 .help = "Set job IO priority class",
1081 .name = "thinktime",
1082 .type = FIO_OPT_INT,
1083 .off1 = td_var_offset(thinktime),
1084 .help = "Idle time between IO buffers (usec)",
1088 .name = "thinktime_spin",
1089 .type = FIO_OPT_INT,
1090 .off1 = td_var_offset(thinktime_spin),
1091 .help = "Start think time by spinning this amount (usec)",
1093 .parent = "thinktime",
1096 .name = "thinktime_blocks",
1097 .type = FIO_OPT_INT,
1098 .off1 = td_var_offset(thinktime_blocks),
1099 .help = "IO buffer period between 'thinktime'",
1101 .parent = "thinktime",
1105 .type = FIO_OPT_INT,
1106 .off1 = td_var_offset(rate),
1107 .help = "Set bandwidth rate",
1111 .type = FIO_OPT_INT,
1112 .off1 = td_var_offset(ratemin),
1113 .help = "Job must meet this rate or it will be shutdown",
1117 .name = "rate_iops",
1118 .type = FIO_OPT_INT,
1119 .off1 = td_var_offset(rate_iops),
1120 .help = "Limit IO used to this number of IO operations/sec",
1123 .name = "rate_iops_min",
1124 .type = FIO_OPT_INT,
1125 .off1 = td_var_offset(rate_iops_min),
1126 .help = "Job must meet this rate or it will be shutdown",
1127 .parent = "rate_iops",
1130 .name = "ratecycle",
1131 .type = FIO_OPT_INT,
1132 .off1 = td_var_offset(ratecycle),
1133 .help = "Window average for rate limits (msec)",
1138 .name = "invalidate",
1139 .type = FIO_OPT_BOOL,
1140 .off1 = td_var_offset(invalidate_cache),
1141 .help = "Invalidate buffer/page cache prior to running job",
1146 .type = FIO_OPT_BOOL,
1147 .off1 = td_var_offset(sync_io),
1148 .help = "Use O_SYNC for buffered writes",
1150 .parent = "buffered",
1153 .name = "bwavgtime",
1154 .type = FIO_OPT_INT,
1155 .off1 = td_var_offset(bw_avg_time),
1156 .help = "Time window over which to calculate bandwidth"
1161 .name = "create_serialize",
1162 .type = FIO_OPT_BOOL,
1163 .off1 = td_var_offset(create_serialize),
1164 .help = "Serialize creating of job files",
1168 .name = "create_fsync",
1169 .type = FIO_OPT_BOOL,
1170 .off1 = td_var_offset(create_fsync),
1171 .help = "Fsync file after creation",
1176 .type = FIO_OPT_INT,
1177 .off1 = td_var_offset(cpuload),
1178 .help = "Use this percentage of CPU",
1181 .name = "cpuchunks",
1182 .type = FIO_OPT_INT,
1183 .off1 = td_var_offset(cpucycle),
1184 .help = "Length of the CPU burn cycles (usecs)",
1186 .parent = "cpuload",
1188 #ifdef FIO_HAVE_CPU_AFFINITY
1191 .type = FIO_OPT_INT,
1192 .cb = str_cpumask_cb,
1193 .help = "CPU affinity mask",
1196 .name = "cpus_allowed",
1197 .type = FIO_OPT_STR,
1198 .cb = str_cpus_allowed_cb,
1199 .help = "Set CPUs allowed",
1203 .name = "end_fsync",
1204 .type = FIO_OPT_BOOL,
1205 .off1 = td_var_offset(end_fsync),
1206 .help = "Include fsync at the end of job",
1210 .name = "fsync_on_close",
1211 .type = FIO_OPT_BOOL,
1212 .off1 = td_var_offset(fsync_on_close),
1213 .help = "fsync files on close",
1218 .type = FIO_OPT_BOOL,
1219 .off1 = td_var_offset(unlink),
1220 .help = "Unlink created files after job has completed",
1225 .type = FIO_OPT_STR_SET,
1226 .cb = str_exitall_cb,
1227 .help = "Terminate all jobs when one exits",
1230 .name = "stonewall",
1231 .type = FIO_OPT_STR_SET,
1232 .off1 = td_var_offset(stonewall),
1233 .help = "Insert a hard barrier between this job and previous",
1236 .name = "new_group",
1237 .type = FIO_OPT_STR_SET,
1238 .off1 = td_var_offset(new_group),
1239 .help = "Mark the start of a new group (for reporting)",
1243 .type = FIO_OPT_STR_SET,
1244 .off1 = td_var_offset(use_thread),
1245 .help = "Use threads instead of forks",
1248 .name = "write_bw_log",
1249 .type = FIO_OPT_STR_SET,
1250 .off1 = td_var_offset(write_bw_log),
1251 .help = "Write log of bandwidth during run",
1254 .name = "write_lat_log",
1255 .type = FIO_OPT_STR_SET,
1256 .off1 = td_var_offset(write_lat_log),
1257 .help = "Write log of latency during run",
1260 .name = "hugepage-size",
1261 .type = FIO_OPT_STR_VAL_INT,
1262 .off1 = td_var_offset(hugepage_size),
1263 .help = "When using hugepages, specify size of each page",
1264 .def = __stringify(FIO_HUGE_PAGE),
1267 .name = "group_reporting",
1268 .type = FIO_OPT_STR_SET,
1269 .off1 = td_var_offset(group_reporting),
1270 .help = "Do reporting on a per-group basis",
1273 .name = "zero_buffers",
1274 .type = FIO_OPT_STR_SET,
1275 .off1 = td_var_offset(zero_buffers),
1276 .help = "Init IO buffers to all zeroes",
1279 .name = "refill_buffers",
1280 .type = FIO_OPT_STR_SET,
1281 .off1 = td_var_offset(refill_buffers),
1282 .help = "Refill IO buffers on every IO submit",
1284 #ifdef FIO_HAVE_DISK_UTIL
1286 .name = "disk_util",
1287 .type = FIO_OPT_BOOL,
1288 .off1 = td_var_offset(do_disk_util),
1289 .help = "Log disk utilization statistics",
1298 void fio_options_dup_and_init(struct option *long_options)
1300 struct fio_option *o;
1303 options_init(options);
1306 while (long_options[i].name)
1311 long_options[i].name = (char *) o->name;
1312 long_options[i].val = FIO_GETOPT_JOB;
1313 if (o->type == FIO_OPT_STR_SET)
1314 long_options[i].has_arg = no_argument;
1316 long_options[i].has_arg = required_argument;
1320 assert(i < FIO_NR_OPTIONS);
1324 int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
1328 sort_options(opts, options, num_opts);
1330 for (ret = 0, i = 0; i < num_opts; i++)
1331 ret |= parse_option(opts[i], options, td);
1336 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
1338 return parse_cmd_option(opt, val, options, td);
1341 void fio_fill_default_options(struct thread_data *td)
1343 fill_default_options(td, options);
1346 int fio_show_option_help(const char *opt)
1348 return show_cmd_help(options, opt);
1351 static void __options_mem(struct thread_data *td, int alloc)
1353 struct thread_options *o = &td->o;
1354 struct fio_option *opt;
1358 for (i = 0, opt = &options[0]; opt->name; i++, opt = &options[i]) {
1359 if (opt->type != FIO_OPT_STR_STORE)
1362 ptr = (void *) o + opt->off1;
1365 *ptr = strdup(*ptr);
1375 * dupe FIO_OPT_STR_STORE options
1377 void options_mem_dupe(struct thread_data *td)
1379 __options_mem(td, 1);
1382 void options_mem_free(struct thread_data fio_unused *td)
1385 __options_mem(td, 0);