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 .help = "File(s) to use for the workload",
471 .cb = str_lockfile_cb,
472 .off1 = td_var_offset(file_lock_mode),
473 .help = "Lock file when doing IO to it",
474 .parent = "filename",
478 .oval = FILE_LOCK_NONE,
479 .help = "No file locking",
481 { .ival = "exclusive",
482 .oval = FILE_LOCK_EXCLUSIVE,
483 .help = "Exclusive file lock",
487 .oval = FILE_LOCK_READWRITE,
488 .help = "Read vs write lock",
494 .type = FIO_OPT_STR_STORE,
495 .off1 = td_var_offset(opendir),
496 .cb = str_opendir_cb,
497 .help = "Recursively add files from this directory and down",
501 .alias = "readwrite",
504 .off1 = td_var_offset(td_ddir),
505 .help = "IO direction",
509 .oval = TD_DDIR_READ,
510 .help = "Sequential read",
513 .oval = TD_DDIR_WRITE,
514 .help = "Sequential write",
516 { .ival = "randread",
517 .oval = TD_DDIR_RANDREAD,
518 .help = "Random read",
520 { .ival = "randwrite",
521 .oval = TD_DDIR_RANDWRITE,
522 .help = "Random write",
526 .help = "Sequential read and write mix",
529 .oval = TD_DDIR_RANDRW,
530 .help = "Random read and write mix"
536 .type = FIO_OPT_STR_STORE,
537 .off1 = td_var_offset(ioengine),
538 .help = "IO engine to use",
542 .help = "Use read/write",
545 .help = "Use pread/pwrite",
548 .help = "Use readv/writev",
550 #ifdef FIO_HAVE_LIBAIO
552 .help = "Linux native asynchronous IO",
555 #ifdef FIO_HAVE_POSIXAIO
556 { .ival = "posixaio",
557 .help = "POSIX asynchronous IO",
560 #ifdef FIO_HAVE_SOLARISAIO
561 { .ival = "solarisaio",
562 .help = "Solaris native asynchronous IO",
566 .help = "Memory mapped IO",
568 #ifdef FIO_HAVE_SPLICE
570 .help = "splice/vmsplice based IO",
572 { .ival = "netsplice",
573 .help = "splice/vmsplice to/from the network",
578 .help = "SCSI generic v3 IO",
582 .help = "Testing engine (no data transfer)",
585 .help = "Network IO",
587 #ifdef FIO_HAVE_SYSLET
588 { .ival = "syslet-rw",
589 .help = "syslet enabled async pread/pwrite IO",
593 .help = "CPU cycler burner engine",
595 #ifdef FIO_HAVE_GUASI
597 .help = "GUASI IO engine",
600 { .ival = "external",
601 .help = "Load external engine (append name)",
608 .off1 = td_var_offset(iodepth),
609 .help = "Amount of IO buffers to keep in flight",
614 .name = "iodepth_batch",
615 .alias = "iodepth_batch_submit",
617 .off1 = td_var_offset(iodepth_batch),
618 .help = "Number of IO to submit in one go",
624 .name = "iodepth_batch_complete",
626 .off1 = td_var_offset(iodepth_batch_complete),
627 .help = "Number of IO to retrieve in one go",
633 .name = "iodepth_low",
635 .off1 = td_var_offset(iodepth_low),
636 .help = "Low water mark for queuing depth",
641 .type = FIO_OPT_STR_VAL,
642 .off1 = td_var_offset(size),
644 .help = "Total size of device or files",
647 .name = "fill_device",
648 .type = FIO_OPT_BOOL,
649 .off1 = td_var_offset(fill_device),
650 .help = "Write until an ENOSPC error occurs",
655 .type = FIO_OPT_STR_VAL,
656 .off1 = td_var_offset(file_size_low),
657 .off2 = td_var_offset(file_size_high),
659 .help = "Size of individual files",
663 .alias = "fileoffset",
664 .type = FIO_OPT_STR_VAL,
665 .off1 = td_var_offset(start_offset),
666 .help = "Start IO from this offset",
671 .alias = "blocksize",
672 .type = FIO_OPT_STR_VAL_INT,
673 .off1 = td_var_offset(bs[DDIR_READ]),
674 .off2 = td_var_offset(bs[DDIR_WRITE]),
676 .help = "Block size unit",
682 .alias = "blocksize_range",
683 .type = FIO_OPT_RANGE,
684 .off1 = td_var_offset(min_bs[DDIR_READ]),
685 .off2 = td_var_offset(max_bs[DDIR_READ]),
686 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
687 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
689 .help = "Set block size range (in more detail than bs)",
695 .cb = str_bssplit_cb,
696 .help = "Set a specific mix of block sizes",
700 .name = "bs_unaligned",
701 .alias = "blocksize_unaligned",
702 .type = FIO_OPT_STR_SET,
703 .off1 = td_var_offset(bs_unaligned),
704 .help = "Don't sector align IO buffer sizes",
708 .name = "randrepeat",
709 .type = FIO_OPT_BOOL,
710 .off1 = td_var_offset(rand_repeatable),
711 .help = "Use repeatable random IO pattern",
716 .name = "norandommap",
717 .type = FIO_OPT_STR_SET,
718 .off1 = td_var_offset(norandommap),
719 .help = "Accept potential duplicate random blocks",
723 .name = "softrandommap",
724 .type = FIO_OPT_BOOL,
725 .off1 = td_var_offset(softrandommap),
726 .help = "Set norandommap if randommap allocation fails",
727 .parent = "norandommap",
733 .off1 = td_var_offset(nr_files),
734 .help = "Split job workload between this number of files",
740 .off1 = td_var_offset(open_files),
741 .help = "Number of files to keep open at the same time",
744 .name = "file_service_type",
747 .off1 = td_var_offset(file_service_type),
748 .help = "How to select which file to service next",
752 .oval = FIO_FSERVICE_RANDOM,
753 .help = "Choose a file at random",
755 { .ival = "roundrobin",
756 .oval = FIO_FSERVICE_RR,
757 .help = "Round robin select files",
763 .name = "fadvise_hint",
764 .type = FIO_OPT_BOOL,
765 .off1 = td_var_offset(fadvise_hint),
766 .help = "Use fadvise() to advise the kernel on IO pattern",
772 .off1 = td_var_offset(fsync_blocks),
773 .help = "Issue fsync for writes every given number of blocks",
778 .type = FIO_OPT_BOOL,
779 .off1 = td_var_offset(odirect),
780 .help = "Use O_DIRECT IO (negates buffered)",
785 .type = FIO_OPT_BOOL,
786 .off1 = td_var_offset(odirect),
788 .help = "Use buffered IO (negates direct)",
793 .type = FIO_OPT_BOOL,
794 .off1 = td_var_offset(overwrite),
795 .help = "When writing, set whether to overwrite current data",
801 .off1 = td_var_offset(loops),
802 .help = "Number of times to run the job",
808 .off1 = td_var_offset(numjobs),
809 .help = "Duplicate this job this many times",
813 .name = "startdelay",
815 .off1 = td_var_offset(start_delay),
816 .help = "Only start job when this period has passed",
822 .type = FIO_OPT_STR_VAL_TIME,
823 .off1 = td_var_offset(timeout),
824 .help = "Stop workload when this amount of time has passed",
828 .name = "time_based",
829 .type = FIO_OPT_STR_SET,
830 .off1 = td_var_offset(time_based),
831 .help = "Keep running until runtime/timeout is met",
838 .off1 = td_var_offset(mem_type),
839 .help = "Backing type for IO buffers",
844 .help = "Use malloc(3) for IO buffers",
848 .help = "Use shared memory segments for IO buffers",
850 #ifdef FIO_HAVE_HUGETLB
853 .help = "Like shm, but use huge pages",
858 .help = "Use mmap(2) (file or anon) for IO buffers",
860 #ifdef FIO_HAVE_HUGETLB
861 { .ival = "mmaphuge",
862 .oval = MEM_MMAPHUGE,
863 .help = "Like mmap, but use huge pages",
871 .off1 = td_var_offset(verify),
872 .help = "Verify data written",
877 .help = "Don't do IO verification",
881 .help = "Use md5 checksums for verification",
884 .oval = VERIFY_CRC64,
885 .help = "Use crc64 checksums for verification",
888 .oval = VERIFY_CRC32,
889 .help = "Use crc32 checksums for verification",
892 .oval = VERIFY_CRC16,
893 .help = "Use crc16 checksums for verification",
897 .help = "Use crc7 checksums for verification",
900 .oval = VERIFY_SHA256,
901 .help = "Use sha256 checksums for verification",
904 .oval = VERIFY_SHA512,
905 .help = "Use sha512 checksums for verification",
909 .help = "Use io information",
914 .help = "Pretend to verify",
920 .type = FIO_OPT_BOOL,
921 .off1 = td_var_offset(do_verify),
922 .help = "Run verification stage after write",
927 .name = "verifysort",
928 .type = FIO_OPT_BOOL,
929 .off1 = td_var_offset(verifysort),
930 .help = "Sort written verify blocks for read back",
935 .name = "verify_interval",
936 .type = FIO_OPT_STR_VAL_INT,
937 .off1 = td_var_offset(verify_interval),
938 .minval = 2 * sizeof(struct verify_header),
939 .help = "Store verify buffer header every N bytes",
943 .name = "verify_offset",
944 .type = FIO_OPT_STR_VAL_INT,
945 .help = "Offset verify header location by N bytes",
947 .cb = str_verify_offset_cb,
951 .name = "verify_pattern",
953 .cb = str_verify_pattern_cb,
954 .help = "Fill pattern for IO buffers",
958 .name = "verify_fatal",
959 .type = FIO_OPT_BOOL,
960 .off1 = td_var_offset(verify_fatal),
962 .help = "Exit on a single verify failure, don't continue",
966 .name = "write_iolog",
967 .type = FIO_OPT_STR_STORE,
968 .off1 = td_var_offset(write_iolog_file),
969 .help = "Store IO pattern to file",
972 .name = "read_iolog",
973 .type = FIO_OPT_STR_STORE,
974 .off1 = td_var_offset(read_iolog_file),
975 .help = "Playback IO pattern from file",
978 .name = "exec_prerun",
979 .type = FIO_OPT_STR_STORE,
980 .off1 = td_var_offset(exec_prerun),
981 .help = "Execute this file prior to running job",
984 .name = "exec_postrun",
985 .type = FIO_OPT_STR_STORE,
986 .off1 = td_var_offset(exec_postrun),
987 .help = "Execute this file after running job",
989 #ifdef FIO_HAVE_IOSCHED_SWITCH
991 .name = "ioscheduler",
992 .type = FIO_OPT_STR_STORE,
993 .off1 = td_var_offset(ioscheduler),
994 .help = "Use this IO scheduler on the backing device",
999 .type = FIO_OPT_STR_VAL,
1000 .off1 = td_var_offset(zone_size),
1001 .help = "Give size of an IO zone",
1006 .type = FIO_OPT_STR_VAL,
1007 .off1 = td_var_offset(zone_skip),
1008 .help = "Space between IO zones",
1013 .type = FIO_OPT_STR_VAL,
1014 .cb = str_lockmem_cb,
1015 .help = "Lock down this amount of memory",
1019 .name = "rwmixread",
1020 .type = FIO_OPT_INT,
1021 .cb = str_rwmix_read_cb,
1023 .help = "Percentage of mixed workload that is reads",
1027 .name = "rwmixwrite",
1028 .type = FIO_OPT_INT,
1029 .cb = str_rwmix_write_cb,
1031 .help = "Percentage of mixed workload that is writes",
1035 .name = "rwmixcycle",
1036 .type = FIO_OPT_DEPRECATED,
1040 .type = FIO_OPT_INT,
1041 .off1 = td_var_offset(nice),
1042 .help = "Set job CPU nice value",
1047 #ifdef FIO_HAVE_IOPRIO
1050 .type = FIO_OPT_INT,
1052 .help = "Set job IO priority value",
1057 .name = "prioclass",
1058 .type = FIO_OPT_INT,
1059 .cb = str_prioclass_cb,
1060 .help = "Set job IO priority class",
1066 .name = "thinktime",
1067 .type = FIO_OPT_INT,
1068 .off1 = td_var_offset(thinktime),
1069 .help = "Idle time between IO buffers (usec)",
1073 .name = "thinktime_spin",
1074 .type = FIO_OPT_INT,
1075 .off1 = td_var_offset(thinktime_spin),
1076 .help = "Start think time by spinning this amount (usec)",
1078 .parent = "thinktime",
1081 .name = "thinktime_blocks",
1082 .type = FIO_OPT_INT,
1083 .off1 = td_var_offset(thinktime_blocks),
1084 .help = "IO buffer period between 'thinktime'",
1086 .parent = "thinktime",
1090 .type = FIO_OPT_INT,
1091 .off1 = td_var_offset(rate),
1092 .help = "Set bandwidth rate",
1096 .type = FIO_OPT_INT,
1097 .off1 = td_var_offset(ratemin),
1098 .help = "Job must meet this rate or it will be shutdown",
1102 .name = "rate_iops",
1103 .type = FIO_OPT_INT,
1104 .off1 = td_var_offset(rate_iops),
1105 .help = "Limit IO used to this number of IO operations/sec",
1108 .name = "rate_iops_min",
1109 .type = FIO_OPT_INT,
1110 .off1 = td_var_offset(rate_iops_min),
1111 .help = "Job must meet this rate or it will be shutdown",
1112 .parent = "rate_iops",
1115 .name = "ratecycle",
1116 .type = FIO_OPT_INT,
1117 .off1 = td_var_offset(ratecycle),
1118 .help = "Window average for rate limits (msec)",
1123 .name = "invalidate",
1124 .type = FIO_OPT_BOOL,
1125 .off1 = td_var_offset(invalidate_cache),
1126 .help = "Invalidate buffer/page cache prior to running job",
1131 .type = FIO_OPT_BOOL,
1132 .off1 = td_var_offset(sync_io),
1133 .help = "Use O_SYNC for buffered writes",
1135 .parent = "buffered",
1138 .name = "bwavgtime",
1139 .type = FIO_OPT_INT,
1140 .off1 = td_var_offset(bw_avg_time),
1141 .help = "Time window over which to calculate bandwidth"
1146 .name = "create_serialize",
1147 .type = FIO_OPT_BOOL,
1148 .off1 = td_var_offset(create_serialize),
1149 .help = "Serialize creating of job files",
1153 .name = "create_fsync",
1154 .type = FIO_OPT_BOOL,
1155 .off1 = td_var_offset(create_fsync),
1156 .help = "Fsync file after creation",
1161 .type = FIO_OPT_INT,
1162 .off1 = td_var_offset(cpuload),
1163 .help = "Use this percentage of CPU",
1166 .name = "cpuchunks",
1167 .type = FIO_OPT_INT,
1168 .off1 = td_var_offset(cpucycle),
1169 .help = "Length of the CPU burn cycles (usecs)",
1171 .parent = "cpuload",
1173 #ifdef FIO_HAVE_CPU_AFFINITY
1176 .type = FIO_OPT_INT,
1177 .cb = str_cpumask_cb,
1178 .help = "CPU affinity mask",
1181 .name = "cpus_allowed",
1182 .type = FIO_OPT_STR,
1183 .cb = str_cpus_allowed_cb,
1184 .help = "Set CPUs allowed",
1188 .name = "end_fsync",
1189 .type = FIO_OPT_BOOL,
1190 .off1 = td_var_offset(end_fsync),
1191 .help = "Include fsync at the end of job",
1195 .name = "fsync_on_close",
1196 .type = FIO_OPT_BOOL,
1197 .off1 = td_var_offset(fsync_on_close),
1198 .help = "fsync files on close",
1203 .type = FIO_OPT_BOOL,
1204 .off1 = td_var_offset(unlink),
1205 .help = "Unlink created files after job has completed",
1210 .type = FIO_OPT_STR_SET,
1211 .cb = str_exitall_cb,
1212 .help = "Terminate all jobs when one exits",
1215 .name = "stonewall",
1216 .type = FIO_OPT_STR_SET,
1217 .off1 = td_var_offset(stonewall),
1218 .help = "Insert a hard barrier between this job and previous",
1221 .name = "new_group",
1222 .type = FIO_OPT_STR_SET,
1223 .off1 = td_var_offset(new_group),
1224 .help = "Mark the start of a new group (for reporting)",
1228 .type = FIO_OPT_STR_SET,
1229 .off1 = td_var_offset(use_thread),
1230 .help = "Use threads instead of forks",
1233 .name = "write_bw_log",
1234 .type = FIO_OPT_STR_SET,
1235 .off1 = td_var_offset(write_bw_log),
1236 .help = "Write log of bandwidth during run",
1239 .name = "write_lat_log",
1240 .type = FIO_OPT_STR_SET,
1241 .off1 = td_var_offset(write_lat_log),
1242 .help = "Write log of latency during run",
1245 .name = "hugepage-size",
1246 .type = FIO_OPT_STR_VAL_INT,
1247 .off1 = td_var_offset(hugepage_size),
1248 .help = "When using hugepages, specify size of each page",
1249 .def = __stringify(FIO_HUGE_PAGE),
1252 .name = "group_reporting",
1253 .type = FIO_OPT_STR_SET,
1254 .off1 = td_var_offset(group_reporting),
1255 .help = "Do reporting on a per-group basis",
1258 .name = "zero_buffers",
1259 .type = FIO_OPT_STR_SET,
1260 .off1 = td_var_offset(zero_buffers),
1261 .help = "Init IO buffers to all zeroes",
1264 .name = "refill_buffers",
1265 .type = FIO_OPT_STR_SET,
1266 .off1 = td_var_offset(refill_buffers),
1267 .help = "Refill IO buffers on every IO submit",
1269 #ifdef FIO_HAVE_DISK_UTIL
1271 .name = "disk_util",
1272 .type = FIO_OPT_BOOL,
1273 .off1 = td_var_offset(do_disk_util),
1274 .help = "Log disk utilization statistics",
1283 void fio_options_dup_and_init(struct option *long_options)
1285 struct fio_option *o;
1288 options_init(options);
1291 while (long_options[i].name)
1296 long_options[i].name = (char *) o->name;
1297 long_options[i].val = FIO_GETOPT_JOB;
1298 if (o->type == FIO_OPT_STR_SET)
1299 long_options[i].has_arg = no_argument;
1301 long_options[i].has_arg = required_argument;
1305 assert(i < FIO_NR_OPTIONS);
1309 int fio_option_parse(struct thread_data *td, const char *opt)
1311 return parse_option(opt, options, td);
1314 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
1316 return parse_cmd_option(opt, val, options, td);
1319 void fio_fill_default_options(struct thread_data *td)
1321 fill_default_options(td, options);
1324 int fio_show_option_help(const char *opt)
1326 return show_cmd_help(options, opt);
1329 static void __options_mem(struct thread_data *td, int alloc)
1331 struct thread_options *o = &td->o;
1332 struct fio_option *opt;
1336 for (i = 0, opt = &options[0]; opt->name; i++, opt = &options[i]) {
1337 if (opt->type != FIO_OPT_STR_STORE)
1340 ptr = (void *) o + opt->off1;
1343 *ptr = strdup(*ptr);
1353 * dupe FIO_OPT_STR_STORE options
1355 void options_mem_dupe(struct thread_data *td)
1357 __options_mem(td, 1);
1360 void options_mem_free(struct thread_data fio_unused *td)
1363 __options_mem(td, 0);