10 #include <sys/types.h>
18 unsigned int fio_kb_base = 1024;
20 #define td_var_offset(var) ((size_t) &((struct thread_options *)0)->var)
23 * Check if mmap/mmaphuge has a :/foo/bar/file at the end. If so, return that.
25 static char *get_opt_postfix(const char *str)
27 char *p = strstr(str, ":");
33 strip_blank_front(&p);
38 static int bs_cmp(const void *p1, const void *p2)
40 const struct bssplit *bsp1 = p1;
41 const struct bssplit *bsp2 = p2;
43 return bsp1->perc < bsp2->perc;
46 static int bssplit_ddir(struct thread_data *td, int ddir, char *str)
48 struct bssplit *bssplit;
49 unsigned int i, perc, perc_missing;
50 unsigned int max_bs, min_bs;
54 td->o.bssplit_nr[ddir] = 4;
55 bssplit = malloc(4 * sizeof(struct bssplit));
60 while ((fname = strsep(&str, ":")) != NULL) {
67 * grow struct buffer, if needed
69 if (i == td->o.bssplit_nr[ddir]) {
70 td->o.bssplit_nr[ddir] <<= 1;
71 bssplit = realloc(bssplit, td->o.bssplit_nr[ddir]
72 * sizeof(struct bssplit));
75 perc_str = strstr(fname, "/");
79 perc = atoi(perc_str);
87 if (str_to_decimal(fname, &val, 1)) {
88 log_err("fio: bssplit conversion failed\n");
99 bssplit[i].perc = perc;
103 td->o.bssplit_nr[ddir] = i;
106 * Now check if the percentages add up, and how much is missing
108 perc = perc_missing = 0;
109 for (i = 0; i < td->o.bssplit_nr[ddir]; i++) {
110 struct bssplit *bsp = &bssplit[i];
112 if (bsp->perc == (unsigned char) -1)
119 log_err("fio: bssplit percentages add to more than 100%%\n");
124 * If values didn't have a percentage set, divide the remains between
128 for (i = 0; i < td->o.bssplit_nr[ddir]; i++) {
129 struct bssplit *bsp = &bssplit[i];
131 if (bsp->perc == (unsigned char) -1)
132 bsp->perc = (100 - perc) / perc_missing;
136 td->o.min_bs[ddir] = min_bs;
137 td->o.max_bs[ddir] = max_bs;
140 * now sort based on percentages, for ease of lookup
142 qsort(bssplit, td->o.bssplit_nr[ddir], sizeof(struct bssplit), bs_cmp);
143 td->o.bssplit[ddir] = bssplit;
148 static int str_bssplit_cb(void *data, const char *input)
150 struct thread_data *td = data;
151 char *str, *p, *odir;
154 p = str = strdup(input);
156 strip_blank_front(&str);
157 strip_blank_end(str);
159 odir = strchr(str, ',');
161 ret = bssplit_ddir(td, DDIR_WRITE, odir + 1);
164 ret = bssplit_ddir(td, DDIR_READ, str);
171 ret = bssplit_ddir(td, DDIR_READ, str);
173 ret = bssplit_ddir(td, DDIR_WRITE, op);
182 static int str_rw_cb(void *data, const char *str)
184 struct thread_data *td = data;
185 char *nr = get_opt_postfix(str);
189 td->o.ddir_nr = atoi(nr);
196 static int str_mem_cb(void *data, const char *mem)
198 struct thread_data *td = data;
200 if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP) {
201 td->mmapfile = get_opt_postfix(mem);
202 if (td->o.mem_type == MEM_MMAPHUGE && !td->mmapfile) {
203 log_err("fio: mmaphuge:/path/to/file\n");
211 static int str_lockmem_cb(void fio_unused *data, unsigned long *val)
217 static int str_rwmix_read_cb(void *data, unsigned int *val)
219 struct thread_data *td = data;
221 td->o.rwmix[DDIR_READ] = *val;
222 td->o.rwmix[DDIR_WRITE] = 100 - *val;
226 static int str_rwmix_write_cb(void *data, unsigned int *val)
228 struct thread_data *td = data;
230 td->o.rwmix[DDIR_WRITE] = *val;
231 td->o.rwmix[DDIR_READ] = 100 - *val;
235 #ifdef FIO_HAVE_IOPRIO
236 static int str_prioclass_cb(void *data, unsigned int *val)
238 struct thread_data *td = data;
242 * mask off old class bits, str_prio_cb() may have set a default class
244 mask = (1 << IOPRIO_CLASS_SHIFT) - 1;
247 td->ioprio |= *val << IOPRIO_CLASS_SHIFT;
252 static int str_prio_cb(void *data, unsigned int *val)
254 struct thread_data *td = data;
259 * If no class is set, assume BE
261 if ((td->ioprio >> IOPRIO_CLASS_SHIFT) == 0)
262 td->ioprio |= IOPRIO_CLASS_BE << IOPRIO_CLASS_SHIFT;
269 static int str_exitall_cb(void)
271 exitall_on_terminate = 1;
275 #ifdef FIO_HAVE_CPU_AFFINITY
276 static int str_cpumask_cb(void *data, unsigned int *val)
278 struct thread_data *td = data;
283 ret = fio_cpuset_init(&td->o.cpumask);
285 log_err("fio: cpuset_init failed\n");
286 td_verror(td, ret, "fio_cpuset_init");
290 max_cpu = sysconf(_SC_NPROCESSORS_ONLN);
292 for (i = 0; i < sizeof(int) * 8; i++) {
293 if ((1 << i) & *val) {
295 log_err("fio: CPU %d too large (max=%ld)\n", i,
299 dprint(FD_PARSE, "set cpu allowed %d\n", i);
300 fio_cpu_set(&td->o.cpumask, i);
304 td->o.cpumask_set = 1;
308 static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask,
315 ret = fio_cpuset_init(mask);
317 log_err("fio: cpuset_init failed\n");
318 td_verror(td, ret, "fio_cpuset_init");
322 p = str = strdup(input);
324 strip_blank_front(&str);
325 strip_blank_end(str);
327 max_cpu = sysconf(_SC_NPROCESSORS_ONLN);
329 while ((cpu = strsep(&str, ",")) != NULL) {
338 while ((cpu2 = strsep(&str2, "-")) != NULL) {
348 while (icpu <= icpu2) {
349 if (icpu >= FIO_MAX_CPUS) {
350 log_err("fio: your OS only supports up to"
351 " %d CPUs\n", (int) FIO_MAX_CPUS);
355 if (icpu > max_cpu) {
356 log_err("fio: CPU %d too large (max=%ld)\n",
362 dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
363 fio_cpu_set(mask, icpu);
372 td->o.cpumask_set = 1;
376 static int str_cpus_allowed_cb(void *data, const char *input)
378 struct thread_data *td = data;
381 ret = set_cpus_allowed(td, &td->o.cpumask, input);
383 td->o.cpumask_set = 1;
388 static int str_verify_cpus_allowed_cb(void *data, const char *input)
390 struct thread_data *td = data;
393 ret = set_cpus_allowed(td, &td->o.verify_cpumask, input);
395 td->o.verify_cpumask_set = 1;
401 static int str_fst_cb(void *data, const char *str)
403 struct thread_data *td = data;
404 char *nr = get_opt_postfix(str);
406 td->file_service_nr = 1;
408 td->file_service_nr = atoi(nr);
415 static int check_dir(struct thread_data *td, char *fname)
417 char file[PATH_MAX], *dir;
420 if (td->o.directory) {
421 strcpy(file, td->o.directory);
426 sprintf(file + elen, "%s", fname);
433 * We can't do this on FIO_DISKLESSIO engines. The engine isn't loaded
434 * yet, so we can't do this check right here...
436 if (lstat(dir, &sb) < 0) {
439 log_err("fio: %s is not a directory\n", dir);
440 td_verror(td, ret, "lstat");
444 if (!S_ISDIR(sb.st_mode)) {
445 log_err("fio: %s is not a directory\n", dir);
454 static int str_filename_cb(void *data, const char *input)
456 struct thread_data *td = data;
457 char *fname, *str, *p;
459 p = str = strdup(input);
461 strip_blank_front(&str);
462 strip_blank_end(str);
464 if (!td->files_index)
467 while ((fname = strsep(&str, ":")) != NULL) {
470 if (check_dir(td, fname)) {
482 static int str_directory_cb(void *data, const char fio_unused *str)
484 struct thread_data *td = data;
487 if (lstat(td->o.directory, &sb) < 0) {
490 log_err("fio: %s is not a directory\n", td->o.directory);
491 td_verror(td, ret, "lstat");
494 if (!S_ISDIR(sb.st_mode)) {
495 log_err("fio: %s is not a directory\n", td->o.directory);
502 static int str_opendir_cb(void *data, const char fio_unused *str)
504 struct thread_data *td = data;
506 if (!td->files_index)
509 return add_dir_files(td, td->o.opendir);
512 static int str_verify_offset_cb(void *data, unsigned int *off)
514 struct thread_data *td = data;
516 if (*off && *off < sizeof(struct verify_header)) {
517 log_err("fio: verify_offset too small\n");
521 td->o.verify_offset = *off;
525 static int str_verify_pattern_cb(void *data, unsigned int *off)
527 struct thread_data *td = data;
532 td->o.verify_pattern_bytes = 1;
534 td->o.verify_pattern_bytes = 2;
536 td->o.verify_pattern_bytes = 3;
538 td->o.verify_pattern_bytes = 4;
540 td->o.verify_pattern = *off;
544 static int str_lockfile_cb(void *data, const char *str)
546 struct thread_data *td = data;
547 char *nr = get_opt_postfix(str);
549 td->o.lockfile_batch = 1;
551 td->o.lockfile_batch = atoi(nr);
558 static int str_write_bw_log_cb(void *data, const char *str)
560 struct thread_data *td = data;
563 td->o.bw_log_file = strdup(str);
565 td->o.write_bw_log = 1;
569 static int str_write_lat_log_cb(void *data, const char *str)
571 struct thread_data *td = data;
574 td->o.lat_log_file = strdup(str);
576 td->o.write_lat_log = 1;
580 static int str_gtod_reduce_cb(void *data, int *il)
582 struct thread_data *td = data;
585 td->o.disable_clat = !!val;
586 td->o.disable_slat = !!val;
587 td->o.disable_bw = !!val;
589 td->tv_cache_mask = 63;
594 static int str_gtod_cpu_cb(void *data, int *il)
596 struct thread_data *td = data;
599 td->o.gtod_cpu = val;
600 td->o.gtod_offload = 1;
604 static int rw_verify(struct fio_option *o, void *data)
606 struct thread_data *td = data;
608 if (read_only && td_write(td)) {
609 log_err("fio: job <%s> has write bit set, but fio is in"
610 " read-only mode\n", td->o.name);
617 static int gtod_cpu_verify(struct fio_option *o, void *data)
619 #ifndef FIO_HAVE_CPU_AFFINITY
620 struct thread_data *td = data;
622 if (td->o.gtod_cpu) {
623 log_err("fio: platform must support CPU affinity for"
624 "gettimeofday() offloading\n");
632 static int kb_base_verify(struct fio_option *o, void *data)
634 struct thread_data *td = data;
636 if (td->o.kb_base != 1024 && td->o.kb_base != 1000) {
637 log_err("fio: kb_base set to nonsensical value: %u\n",
642 fio_kb_base = td->o.kb_base;
646 #define __stringify_1(x) #x
647 #define __stringify(x) __stringify_1(x)
650 * Map of job/command line options
652 static struct fio_option options[] = {
654 .name = "description",
655 .type = FIO_OPT_STR_STORE,
656 .off1 = td_var_offset(description),
657 .help = "Text job description",
661 .type = FIO_OPT_STR_STORE,
662 .off1 = td_var_offset(name),
663 .help = "Name of this job",
667 .type = FIO_OPT_STR_STORE,
668 .off1 = td_var_offset(directory),
669 .cb = str_directory_cb,
670 .help = "Directory to store files in",
674 .type = FIO_OPT_STR_STORE,
675 .off1 = td_var_offset(filename),
676 .cb = str_filename_cb,
677 .prio = -1, /* must come after "directory" */
678 .help = "File(s) to use for the workload",
683 .off1 = td_var_offset(kb_base),
684 .verify = kb_base_verify,
687 .help = "How many bytes per KB for reporting (1000 or 1024)",
692 .cb = str_lockfile_cb,
693 .off1 = td_var_offset(file_lock_mode),
694 .help = "Lock file when doing IO to it",
695 .parent = "filename",
699 .oval = FILE_LOCK_NONE,
700 .help = "No file locking",
702 { .ival = "exclusive",
703 .oval = FILE_LOCK_EXCLUSIVE,
704 .help = "Exclusive file lock",
708 .oval = FILE_LOCK_READWRITE,
709 .help = "Read vs write lock",
715 .type = FIO_OPT_STR_STORE,
716 .off1 = td_var_offset(opendir),
717 .cb = str_opendir_cb,
718 .help = "Recursively add files from this directory and down",
722 .alias = "readwrite",
725 .off1 = td_var_offset(td_ddir),
726 .help = "IO direction",
731 .oval = TD_DDIR_READ,
732 .help = "Sequential read",
735 .oval = TD_DDIR_WRITE,
736 .help = "Sequential write",
738 { .ival = "randread",
739 .oval = TD_DDIR_RANDREAD,
740 .help = "Random read",
742 { .ival = "randwrite",
743 .oval = TD_DDIR_RANDWRITE,
744 .help = "Random write",
748 .help = "Sequential read and write mix",
751 .oval = TD_DDIR_RANDRW,
752 .help = "Random read and write mix"
758 .type = FIO_OPT_STR_STORE,
759 .off1 = td_var_offset(ioengine),
760 .help = "IO engine to use",
764 .help = "Use read/write",
767 .help = "Use pread/pwrite",
770 .help = "Use readv/writev",
772 #ifdef FIO_HAVE_LIBAIO
774 .help = "Linux native asynchronous IO",
777 #ifdef FIO_HAVE_POSIXAIO
778 { .ival = "posixaio",
779 .help = "POSIX asynchronous IO",
782 #ifdef FIO_HAVE_SOLARISAIO
783 { .ival = "solarisaio",
784 .help = "Solaris native asynchronous IO",
788 .help = "Memory mapped IO",
790 #ifdef FIO_HAVE_SPLICE
792 .help = "splice/vmsplice based IO",
794 { .ival = "netsplice",
795 .help = "splice/vmsplice to/from the network",
800 .help = "SCSI generic v3 IO",
804 .help = "Testing engine (no data transfer)",
807 .help = "Network IO",
809 #ifdef FIO_HAVE_SYSLET
810 { .ival = "syslet-rw",
811 .help = "syslet enabled async pread/pwrite IO",
815 .help = "CPU cycler burner engine",
817 #ifdef FIO_HAVE_GUASI
819 .help = "GUASI IO engine",
822 { .ival = "external",
823 .help = "Load external engine (append name)",
830 .off1 = td_var_offset(iodepth),
831 .help = "Amount of IO buffers to keep in flight",
836 .name = "iodepth_batch",
837 .alias = "iodepth_batch_submit",
839 .off1 = td_var_offset(iodepth_batch),
840 .help = "Number of IO buffers to submit in one go",
846 .name = "iodepth_batch_complete",
848 .off1 = td_var_offset(iodepth_batch_complete),
849 .help = "Number of IO buffers to retrieve in one go",
855 .name = "iodepth_low",
857 .off1 = td_var_offset(iodepth_low),
858 .help = "Low water mark for queuing depth",
863 .type = FIO_OPT_STR_VAL,
864 .off1 = td_var_offset(size),
866 .help = "Total size of device or files",
869 .name = "fill_device",
870 .type = FIO_OPT_BOOL,
871 .off1 = td_var_offset(fill_device),
872 .help = "Write until an ENOSPC error occurs",
877 .type = FIO_OPT_STR_VAL,
878 .off1 = td_var_offset(file_size_low),
879 .off2 = td_var_offset(file_size_high),
881 .help = "Size of individual files",
885 .alias = "fileoffset",
886 .type = FIO_OPT_STR_VAL,
887 .off1 = td_var_offset(start_offset),
888 .help = "Start IO from this offset",
893 .alias = "blocksize",
895 .off1 = td_var_offset(bs[DDIR_READ]),
896 .off2 = td_var_offset(bs[DDIR_WRITE]),
898 .help = "Block size unit",
904 .alias = "blockalign",
906 .off1 = td_var_offset(ba[DDIR_READ]),
907 .off2 = td_var_offset(ba[DDIR_WRITE]),
909 .help = "IO block offset alignment",
914 .alias = "blocksize_range",
915 .type = FIO_OPT_RANGE,
916 .off1 = td_var_offset(min_bs[DDIR_READ]),
917 .off2 = td_var_offset(max_bs[DDIR_READ]),
918 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
919 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
921 .help = "Set block size range (in more detail than bs)",
927 .cb = str_bssplit_cb,
928 .help = "Set a specific mix of block sizes",
932 .name = "bs_unaligned",
933 .alias = "blocksize_unaligned",
934 .type = FIO_OPT_STR_SET,
935 .off1 = td_var_offset(bs_unaligned),
936 .help = "Don't sector align IO buffer sizes",
940 .name = "randrepeat",
941 .type = FIO_OPT_BOOL,
942 .off1 = td_var_offset(rand_repeatable),
943 .help = "Use repeatable random IO pattern",
948 .name = "norandommap",
949 .type = FIO_OPT_STR_SET,
950 .off1 = td_var_offset(norandommap),
951 .help = "Accept potential duplicate random blocks",
955 .name = "softrandommap",
956 .type = FIO_OPT_BOOL,
957 .off1 = td_var_offset(softrandommap),
958 .help = "Set norandommap if randommap allocation fails",
959 .parent = "norandommap",
965 .off1 = td_var_offset(nr_files),
966 .help = "Split job workload between this number of files",
972 .off1 = td_var_offset(open_files),
973 .help = "Number of files to keep open at the same time",
976 .name = "file_service_type",
979 .off1 = td_var_offset(file_service_type),
980 .help = "How to select which file to service next",
984 .oval = FIO_FSERVICE_RANDOM,
985 .help = "Choose a file at random",
987 { .ival = "roundrobin",
988 .oval = FIO_FSERVICE_RR,
989 .help = "Round robin select files",
991 { .ival = "sequential",
992 .oval = FIO_FSERVICE_SEQ,
993 .help = "Finish one file before moving to the next",
999 .name = "fadvise_hint",
1000 .type = FIO_OPT_BOOL,
1001 .off1 = td_var_offset(fadvise_hint),
1002 .help = "Use fadvise() to advise the kernel on IO pattern",
1007 .type = FIO_OPT_INT,
1008 .off1 = td_var_offset(fsync_blocks),
1009 .help = "Issue fsync for writes every given number of blocks",
1013 .name = "fdatasync",
1014 .type = FIO_OPT_INT,
1015 .off1 = td_var_offset(fdatasync_blocks),
1016 .help = "Issue fdatasync for writes every given number of blocks",
1021 .type = FIO_OPT_BOOL,
1022 .off1 = td_var_offset(odirect),
1023 .help = "Use O_DIRECT IO (negates buffered)",
1028 .type = FIO_OPT_BOOL,
1029 .off1 = td_var_offset(odirect),
1031 .help = "Use buffered IO (negates direct)",
1035 .name = "overwrite",
1036 .type = FIO_OPT_BOOL,
1037 .off1 = td_var_offset(overwrite),
1038 .help = "When writing, set whether to overwrite current data",
1043 .type = FIO_OPT_INT,
1044 .off1 = td_var_offset(loops),
1045 .help = "Number of times to run the job",
1050 .type = FIO_OPT_INT,
1051 .off1 = td_var_offset(numjobs),
1052 .help = "Duplicate this job this many times",
1056 .name = "startdelay",
1057 .type = FIO_OPT_INT,
1058 .off1 = td_var_offset(start_delay),
1059 .help = "Only start job when this period has passed",
1065 .type = FIO_OPT_STR_VAL_TIME,
1066 .off1 = td_var_offset(timeout),
1067 .help = "Stop workload when this amount of time has passed",
1071 .name = "time_based",
1072 .type = FIO_OPT_STR_SET,
1073 .off1 = td_var_offset(time_based),
1074 .help = "Keep running until runtime/timeout is met",
1077 .name = "ramp_time",
1078 .type = FIO_OPT_STR_VAL_TIME,
1079 .off1 = td_var_offset(ramp_time),
1080 .help = "Ramp up time before measuring performance",
1085 .type = FIO_OPT_STR,
1087 .off1 = td_var_offset(mem_type),
1088 .help = "Backing type for IO buffers",
1093 .help = "Use malloc(3) for IO buffers",
1097 .help = "Use shared memory segments for IO buffers",
1099 #ifdef FIO_HAVE_HUGETLB
1100 { .ival = "shmhuge",
1101 .oval = MEM_SHMHUGE,
1102 .help = "Like shm, but use huge pages",
1107 .help = "Use mmap(2) (file or anon) for IO buffers",
1109 #ifdef FIO_HAVE_HUGETLB
1110 { .ival = "mmaphuge",
1111 .oval = MEM_MMAPHUGE,
1112 .help = "Like mmap, but use huge pages",
1118 .name = "iomem_align",
1119 .alias = "mem_align",
1120 .type = FIO_OPT_INT,
1121 .off1 = td_var_offset(mem_align),
1123 .help = "IO memory buffer offset alignment",
1129 .type = FIO_OPT_STR,
1130 .off1 = td_var_offset(verify),
1131 .help = "Verify data written",
1135 .oval = VERIFY_NONE,
1136 .help = "Don't do IO verification",
1140 .help = "Use md5 checksums for verification",
1143 .oval = VERIFY_CRC64,
1144 .help = "Use crc64 checksums for verification",
1147 .oval = VERIFY_CRC32,
1148 .help = "Use crc32 checksums for verification",
1150 { .ival = "crc32c-intel",
1151 .oval = VERIFY_CRC32C_INTEL,
1152 .help = "Use hw crc32c checksums for verification",
1155 .oval = VERIFY_CRC32C,
1156 .help = "Use crc32c checksums for verification",
1159 .oval = VERIFY_CRC16,
1160 .help = "Use crc16 checksums for verification",
1163 .oval = VERIFY_CRC7,
1164 .help = "Use crc7 checksums for verification",
1167 .oval = VERIFY_SHA256,
1168 .help = "Use sha256 checksums for verification",
1171 .oval = VERIFY_SHA512,
1172 .help = "Use sha512 checksums for verification",
1175 .oval = VERIFY_META,
1176 .help = "Use io information",
1180 .oval = VERIFY_NULL,
1181 .help = "Pretend to verify",
1186 .name = "do_verify",
1187 .type = FIO_OPT_BOOL,
1188 .off1 = td_var_offset(do_verify),
1189 .help = "Run verification stage after write",
1194 .name = "verifysort",
1195 .type = FIO_OPT_BOOL,
1196 .off1 = td_var_offset(verifysort),
1197 .help = "Sort written verify blocks for read back",
1202 .name = "verify_interval",
1203 .type = FIO_OPT_INT,
1204 .off1 = td_var_offset(verify_interval),
1205 .minval = 2 * sizeof(struct verify_header),
1206 .help = "Store verify buffer header every N bytes",
1210 .name = "verify_offset",
1211 .type = FIO_OPT_INT,
1212 .help = "Offset verify header location by N bytes",
1214 .cb = str_verify_offset_cb,
1218 .name = "verify_pattern",
1219 .type = FIO_OPT_INT,
1220 .cb = str_verify_pattern_cb,
1221 .help = "Fill pattern for IO buffers",
1225 .name = "verify_fatal",
1226 .type = FIO_OPT_BOOL,
1227 .off1 = td_var_offset(verify_fatal),
1229 .help = "Exit on a single verify failure, don't continue",
1233 .name = "verify_async",
1234 .type = FIO_OPT_INT,
1235 .off1 = td_var_offset(verify_async),
1237 .help = "Number of async verifier threads to use",
1240 #ifdef FIO_HAVE_CPU_AFFINITY
1242 .name = "verify_async_cpus",
1243 .type = FIO_OPT_STR,
1244 .cb = str_verify_cpus_allowed_cb,
1245 .help = "Set CPUs allowed for async verify threads",
1246 .parent = "verify_async",
1250 .name = "write_iolog",
1251 .type = FIO_OPT_STR_STORE,
1252 .off1 = td_var_offset(write_iolog_file),
1253 .help = "Store IO pattern to file",
1256 .name = "read_iolog",
1257 .type = FIO_OPT_STR_STORE,
1258 .off1 = td_var_offset(read_iolog_file),
1259 .help = "Playback IO pattern from file",
1262 .name = "exec_prerun",
1263 .type = FIO_OPT_STR_STORE,
1264 .off1 = td_var_offset(exec_prerun),
1265 .help = "Execute this file prior to running job",
1268 .name = "exec_postrun",
1269 .type = FIO_OPT_STR_STORE,
1270 .off1 = td_var_offset(exec_postrun),
1271 .help = "Execute this file after running job",
1273 #ifdef FIO_HAVE_IOSCHED_SWITCH
1275 .name = "ioscheduler",
1276 .type = FIO_OPT_STR_STORE,
1277 .off1 = td_var_offset(ioscheduler),
1278 .help = "Use this IO scheduler on the backing device",
1283 .type = FIO_OPT_STR_VAL,
1284 .off1 = td_var_offset(zone_size),
1285 .help = "Give size of an IO zone",
1290 .type = FIO_OPT_STR_VAL,
1291 .off1 = td_var_offset(zone_skip),
1292 .help = "Space between IO zones",
1297 .type = FIO_OPT_STR_VAL,
1298 .cb = str_lockmem_cb,
1299 .help = "Lock down this amount of memory",
1303 .name = "rwmixread",
1304 .type = FIO_OPT_INT,
1305 .cb = str_rwmix_read_cb,
1307 .help = "Percentage of mixed workload that is reads",
1311 .name = "rwmixwrite",
1312 .type = FIO_OPT_INT,
1313 .cb = str_rwmix_write_cb,
1315 .help = "Percentage of mixed workload that is writes",
1319 .name = "rwmixcycle",
1320 .type = FIO_OPT_DEPRECATED,
1324 .type = FIO_OPT_INT,
1325 .off1 = td_var_offset(nice),
1326 .help = "Set job CPU nice value",
1331 #ifdef FIO_HAVE_IOPRIO
1334 .type = FIO_OPT_INT,
1336 .help = "Set job IO priority value",
1341 .name = "prioclass",
1342 .type = FIO_OPT_INT,
1343 .cb = str_prioclass_cb,
1344 .help = "Set job IO priority class",
1350 .name = "thinktime",
1351 .type = FIO_OPT_INT,
1352 .off1 = td_var_offset(thinktime),
1353 .help = "Idle time between IO buffers (usec)",
1357 .name = "thinktime_spin",
1358 .type = FIO_OPT_INT,
1359 .off1 = td_var_offset(thinktime_spin),
1360 .help = "Start think time by spinning this amount (usec)",
1362 .parent = "thinktime",
1365 .name = "thinktime_blocks",
1366 .type = FIO_OPT_INT,
1367 .off1 = td_var_offset(thinktime_blocks),
1368 .help = "IO buffer period between 'thinktime'",
1370 .parent = "thinktime",
1374 .type = FIO_OPT_INT,
1375 .off1 = td_var_offset(rate[0]),
1376 .off2 = td_var_offset(rate[1]),
1377 .help = "Set bandwidth rate",
1381 .type = FIO_OPT_INT,
1382 .off1 = td_var_offset(ratemin[0]),
1383 .off2 = td_var_offset(ratemin[1]),
1384 .help = "Job must meet this rate or it will be shutdown",
1388 .name = "rate_iops",
1389 .type = FIO_OPT_INT,
1390 .off1 = td_var_offset(rate_iops[0]),
1391 .off2 = td_var_offset(rate_iops[1]),
1392 .help = "Limit IO used to this number of IO operations/sec",
1395 .name = "rate_iops_min",
1396 .type = FIO_OPT_INT,
1397 .off1 = td_var_offset(rate_iops_min[0]),
1398 .off2 = td_var_offset(rate_iops_min[1]),
1399 .help = "Job must meet this rate or it will be shutdown",
1400 .parent = "rate_iops",
1403 .name = "ratecycle",
1404 .type = FIO_OPT_INT,
1405 .off1 = td_var_offset(ratecycle),
1406 .help = "Window average for rate limits (msec)",
1411 .name = "invalidate",
1412 .type = FIO_OPT_BOOL,
1413 .off1 = td_var_offset(invalidate_cache),
1414 .help = "Invalidate buffer/page cache prior to running job",
1419 .type = FIO_OPT_BOOL,
1420 .off1 = td_var_offset(sync_io),
1421 .help = "Use O_SYNC for buffered writes",
1423 .parent = "buffered",
1426 .name = "bwavgtime",
1427 .type = FIO_OPT_INT,
1428 .off1 = td_var_offset(bw_avg_time),
1429 .help = "Time window over which to calculate bandwidth"
1434 .name = "create_serialize",
1435 .type = FIO_OPT_BOOL,
1436 .off1 = td_var_offset(create_serialize),
1437 .help = "Serialize creating of job files",
1441 .name = "create_fsync",
1442 .type = FIO_OPT_BOOL,
1443 .off1 = td_var_offset(create_fsync),
1444 .help = "Fsync file after creation",
1448 .name = "create_on_open",
1449 .type = FIO_OPT_BOOL,
1450 .off1 = td_var_offset(create_on_open),
1451 .help = "Create files when they are opened for IO",
1456 .type = FIO_OPT_BOOL,
1457 .off1 = td_var_offset(pre_read),
1458 .help = "Preread files before starting official testing",
1463 .type = FIO_OPT_INT,
1464 .off1 = td_var_offset(cpuload),
1465 .help = "Use this percentage of CPU",
1468 .name = "cpuchunks",
1469 .type = FIO_OPT_INT,
1470 .off1 = td_var_offset(cpucycle),
1471 .help = "Length of the CPU burn cycles (usecs)",
1473 .parent = "cpuload",
1475 #ifdef FIO_HAVE_CPU_AFFINITY
1478 .type = FIO_OPT_INT,
1479 .cb = str_cpumask_cb,
1480 .help = "CPU affinity mask",
1483 .name = "cpus_allowed",
1484 .type = FIO_OPT_STR,
1485 .cb = str_cpus_allowed_cb,
1486 .help = "Set CPUs allowed",
1490 .name = "end_fsync",
1491 .type = FIO_OPT_BOOL,
1492 .off1 = td_var_offset(end_fsync),
1493 .help = "Include fsync at the end of job",
1497 .name = "fsync_on_close",
1498 .type = FIO_OPT_BOOL,
1499 .off1 = td_var_offset(fsync_on_close),
1500 .help = "fsync files on close",
1505 .type = FIO_OPT_BOOL,
1506 .off1 = td_var_offset(unlink),
1507 .help = "Unlink created files after job has completed",
1512 .type = FIO_OPT_STR_SET,
1513 .cb = str_exitall_cb,
1514 .help = "Terminate all jobs when one exits",
1517 .name = "stonewall",
1518 .type = FIO_OPT_STR_SET,
1519 .off1 = td_var_offset(stonewall),
1520 .help = "Insert a hard barrier between this job and previous",
1523 .name = "new_group",
1524 .type = FIO_OPT_STR_SET,
1525 .off1 = td_var_offset(new_group),
1526 .help = "Mark the start of a new group (for reporting)",
1530 .type = FIO_OPT_STR_SET,
1531 .off1 = td_var_offset(use_thread),
1532 .help = "Use threads instead of forks",
1535 .name = "write_bw_log",
1536 .type = FIO_OPT_STR,
1537 .off1 = td_var_offset(write_bw_log),
1538 .cb = str_write_bw_log_cb,
1539 .help = "Write log of bandwidth during run",
1542 .name = "write_lat_log",
1543 .type = FIO_OPT_STR,
1544 .off1 = td_var_offset(write_lat_log),
1545 .cb = str_write_lat_log_cb,
1546 .help = "Write log of latency during run",
1549 .name = "hugepage-size",
1550 .type = FIO_OPT_INT,
1551 .off1 = td_var_offset(hugepage_size),
1552 .help = "When using hugepages, specify size of each page",
1553 .def = __stringify(FIO_HUGE_PAGE),
1556 .name = "group_reporting",
1557 .type = FIO_OPT_STR_SET,
1558 .off1 = td_var_offset(group_reporting),
1559 .help = "Do reporting on a per-group basis",
1562 .name = "zero_buffers",
1563 .type = FIO_OPT_STR_SET,
1564 .off1 = td_var_offset(zero_buffers),
1565 .help = "Init IO buffers to all zeroes",
1568 .name = "refill_buffers",
1569 .type = FIO_OPT_STR_SET,
1570 .off1 = td_var_offset(refill_buffers),
1571 .help = "Refill IO buffers on every IO submit",
1573 #ifdef FIO_HAVE_DISK_UTIL
1575 .name = "disk_util",
1576 .type = FIO_OPT_BOOL,
1577 .off1 = td_var_offset(do_disk_util),
1578 .help = "Log disk utilization statistics",
1583 .name = "gtod_reduce",
1584 .type = FIO_OPT_BOOL,
1585 .help = "Greatly reduce number of gettimeofday() calls",
1586 .cb = str_gtod_reduce_cb,
1590 .name = "disable_clat",
1591 .type = FIO_OPT_BOOL,
1592 .off1 = td_var_offset(disable_clat),
1593 .help = "Disable completion latency numbers",
1594 .parent = "gtod_reduce",
1598 .name = "disable_slat",
1599 .type = FIO_OPT_BOOL,
1600 .off1 = td_var_offset(disable_slat),
1601 .help = "Disable submissionn latency numbers",
1602 .parent = "gtod_reduce",
1606 .name = "disable_bw_measurement",
1607 .type = FIO_OPT_BOOL,
1608 .off1 = td_var_offset(disable_bw),
1609 .help = "Disable bandwidth logging",
1610 .parent = "gtod_reduce",
1615 .type = FIO_OPT_INT,
1616 .cb = str_gtod_cpu_cb,
1617 .help = "Setup dedicated gettimeofday() thread on this CPU",
1618 .verify = gtod_cpu_verify,
1621 .name = "continue_on_error",
1622 .type = FIO_OPT_BOOL,
1623 .off1 = td_var_offset(continue_on_error),
1624 .help = "Continue on non-fatal errors during I/O",
1632 void fio_options_dup_and_init(struct option *long_options)
1634 struct fio_option *o;
1637 options_init(options);
1640 while (long_options[i].name)
1645 long_options[i].name = (char *) o->name;
1646 long_options[i].val = FIO_GETOPT_JOB;
1647 if (o->type == FIO_OPT_STR_SET)
1648 long_options[i].has_arg = no_argument;
1650 long_options[i].has_arg = required_argument;
1654 assert(i < FIO_NR_OPTIONS);
1658 int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
1662 sort_options(opts, options, num_opts);
1664 for (ret = 0, i = 0; i < num_opts; i++)
1665 ret |= parse_option(opts[i], options, td);
1670 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
1672 return parse_cmd_option(opt, val, options, td);
1675 void fio_fill_default_options(struct thread_data *td)
1677 fill_default_options(td, options);
1680 int fio_show_option_help(const char *opt)
1682 return show_cmd_help(options, opt);
1685 static void __options_mem(struct thread_data *td, int alloc)
1687 struct thread_options *o = &td->o;
1688 struct fio_option *opt;
1692 for (i = 0, opt = &options[0]; opt->name; i++, opt = &options[i]) {
1693 if (opt->type != FIO_OPT_STR_STORE)
1696 ptr = (void *) o + opt->off1;
1699 *ptr = strdup(*ptr);
1709 * dupe FIO_OPT_STR_STORE options
1711 void options_mem_dupe(struct thread_data *td)
1713 __options_mem(td, 1);
1716 void options_mem_free(struct thread_data fio_unused *td)
1719 __options_mem(td, 0);