10 #include <sys/types.h>
18 #define td_var_offset(var) ((size_t) &((struct thread_options *)0)->var)
21 * Check if mmap/mmaphuge has a :/foo/bar/file at the end. If so, return that.
23 static char *get_opt_postfix(const char *str)
25 char *p = strstr(str, ":");
31 strip_blank_front(&p);
36 static int bs_cmp(const void *p1, const void *p2)
38 const struct bssplit *bsp1 = p1;
39 const struct bssplit *bsp2 = p2;
41 return bsp1->perc < bsp2->perc;
44 static int bssplit_ddir(struct thread_data *td, int ddir, char *str)
46 struct bssplit *bssplit;
47 unsigned int i, perc, perc_missing;
48 unsigned int max_bs, min_bs;
52 td->o.bssplit_nr[ddir] = 4;
53 bssplit = malloc(4 * sizeof(struct bssplit));
58 while ((fname = strsep(&str, ":")) != NULL) {
65 * grow struct buffer, if needed
67 if (i == td->o.bssplit_nr[ddir]) {
68 td->o.bssplit_nr[ddir] <<= 1;
69 bssplit = realloc(bssplit, td->o.bssplit_nr[ddir]
70 * sizeof(struct bssplit));
73 perc_str = strstr(fname, "/");
77 perc = atoi(perc_str);
85 if (str_to_decimal(fname, &val, 1)) {
86 log_err("fio: bssplit conversion failed\n");
97 bssplit[i].perc = perc;
101 td->o.bssplit_nr[ddir] = i;
104 * Now check if the percentages add up, and how much is missing
106 perc = perc_missing = 0;
107 for (i = 0; i < td->o.bssplit_nr[ddir]; i++) {
108 struct bssplit *bsp = &bssplit[i];
110 if (bsp->perc == (unsigned char) -1)
117 log_err("fio: bssplit percentages add to more than 100%%\n");
122 * If values didn't have a percentage set, divide the remains between
126 for (i = 0; i < td->o.bssplit_nr[ddir]; i++) {
127 struct bssplit *bsp = &bssplit[i];
129 if (bsp->perc == (unsigned char) -1)
130 bsp->perc = (100 - perc) / perc_missing;
134 td->o.min_bs[ddir] = min_bs;
135 td->o.max_bs[ddir] = max_bs;
138 * now sort based on percentages, for ease of lookup
140 qsort(bssplit, td->o.bssplit_nr[ddir], sizeof(struct bssplit), bs_cmp);
141 td->o.bssplit[ddir] = bssplit;
146 static int str_bssplit_cb(void *data, const char *input)
148 struct thread_data *td = data;
149 char *str, *p, *odir;
152 p = str = strdup(input);
154 strip_blank_front(&str);
155 strip_blank_end(str);
157 odir = strchr(str, ',');
159 ret = bssplit_ddir(td, DDIR_WRITE, odir + 1);
162 ret = bssplit_ddir(td, DDIR_READ, str);
169 ret = bssplit_ddir(td, DDIR_READ, str);
171 ret = bssplit_ddir(td, DDIR_WRITE, op);
180 static int str_rw_cb(void *data, const char *str)
182 struct thread_data *td = data;
183 char *nr = get_opt_postfix(str);
187 td->o.ddir_nr = atoi(nr);
194 static int str_mem_cb(void *data, const char *mem)
196 struct thread_data *td = data;
198 if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP) {
199 td->mmapfile = get_opt_postfix(mem);
200 if (td->o.mem_type == MEM_MMAPHUGE && !td->mmapfile) {
201 log_err("fio: mmaphuge:/path/to/file\n");
209 static int str_lockmem_cb(void fio_unused *data, unsigned long *val)
215 static int str_rwmix_read_cb(void *data, unsigned int *val)
217 struct thread_data *td = data;
219 td->o.rwmix[DDIR_READ] = *val;
220 td->o.rwmix[DDIR_WRITE] = 100 - *val;
224 static int str_rwmix_write_cb(void *data, unsigned int *val)
226 struct thread_data *td = data;
228 td->o.rwmix[DDIR_WRITE] = *val;
229 td->o.rwmix[DDIR_READ] = 100 - *val;
233 #ifdef FIO_HAVE_IOPRIO
234 static int str_prioclass_cb(void *data, unsigned int *val)
236 struct thread_data *td = data;
240 * mask off old class bits, str_prio_cb() may have set a default class
242 mask = (1 << IOPRIO_CLASS_SHIFT) - 1;
245 td->ioprio |= *val << IOPRIO_CLASS_SHIFT;
250 static int str_prio_cb(void *data, unsigned int *val)
252 struct thread_data *td = data;
257 * If no class is set, assume BE
259 if ((td->ioprio >> IOPRIO_CLASS_SHIFT) == 0)
260 td->ioprio |= IOPRIO_CLASS_BE << IOPRIO_CLASS_SHIFT;
267 static int str_exitall_cb(void)
269 exitall_on_terminate = 1;
273 #ifdef FIO_HAVE_CPU_AFFINITY
274 static int str_cpumask_cb(void *data, unsigned int *val)
276 struct thread_data *td = data;
281 ret = fio_cpuset_init(&td->o.cpumask);
283 log_err("fio: cpuset_init failed\n");
284 td_verror(td, ret, "fio_cpuset_init");
288 max_cpu = sysconf(_SC_NPROCESSORS_ONLN);
290 for (i = 0; i < sizeof(int) * 8; i++) {
291 if ((1 << i) & *val) {
293 log_err("fio: CPU %d too large (max=%ld)\n", i,
297 dprint(FD_PARSE, "set cpu allowed %d\n", i);
298 fio_cpu_set(&td->o.cpumask, i);
302 td->o.cpumask_set = 1;
306 static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask,
313 ret = fio_cpuset_init(mask);
315 log_err("fio: cpuset_init failed\n");
316 td_verror(td, ret, "fio_cpuset_init");
320 p = str = strdup(input);
322 strip_blank_front(&str);
323 strip_blank_end(str);
325 max_cpu = sysconf(_SC_NPROCESSORS_ONLN);
327 while ((cpu = strsep(&str, ",")) != NULL) {
336 while ((cpu2 = strsep(&str2, "-")) != NULL) {
346 while (icpu <= icpu2) {
347 if (icpu >= FIO_MAX_CPUS) {
348 log_err("fio: your OS only supports up to"
349 " %d CPUs\n", (int) FIO_MAX_CPUS);
353 if (icpu > max_cpu) {
354 log_err("fio: CPU %d too large (max=%ld)\n",
360 dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
361 fio_cpu_set(mask, icpu);
370 td->o.cpumask_set = 1;
374 static int str_cpus_allowed_cb(void *data, const char *input)
376 struct thread_data *td = data;
379 ret = set_cpus_allowed(td, &td->o.cpumask, input);
381 td->o.cpumask_set = 1;
386 static int str_verify_cpus_allowed_cb(void *data, const char *input)
388 struct thread_data *td = data;
391 ret = set_cpus_allowed(td, &td->o.verify_cpumask, input);
393 td->o.verify_cpumask_set = 1;
399 static int str_fst_cb(void *data, const char *str)
401 struct thread_data *td = data;
402 char *nr = get_opt_postfix(str);
404 td->file_service_nr = 1;
406 td->file_service_nr = atoi(nr);
413 static int check_dir(struct thread_data *td, char *fname)
415 char file[PATH_MAX], *dir;
418 if (td->o.directory) {
419 strcpy(file, td->o.directory);
424 sprintf(file + elen, "%s", fname);
431 * We can't do this on FIO_DISKLESSIO engines. The engine isn't loaded
432 * yet, so we can't do this check right here...
434 if (lstat(dir, &sb) < 0) {
437 log_err("fio: %s is not a directory\n", dir);
438 td_verror(td, ret, "lstat");
442 if (!S_ISDIR(sb.st_mode)) {
443 log_err("fio: %s is not a directory\n", dir);
452 static int str_filename_cb(void *data, const char *input)
454 struct thread_data *td = data;
455 char *fname, *str, *p;
457 p = str = strdup(input);
459 strip_blank_front(&str);
460 strip_blank_end(str);
462 if (!td->files_index)
465 while ((fname = strsep(&str, ":")) != NULL) {
468 if (check_dir(td, fname)) {
480 static int str_directory_cb(void *data, const char fio_unused *str)
482 struct thread_data *td = data;
485 if (lstat(td->o.directory, &sb) < 0) {
488 log_err("fio: %s is not a directory\n", td->o.directory);
489 td_verror(td, ret, "lstat");
492 if (!S_ISDIR(sb.st_mode)) {
493 log_err("fio: %s is not a directory\n", td->o.directory);
500 static int str_opendir_cb(void *data, const char fio_unused *str)
502 struct thread_data *td = data;
504 if (!td->files_index)
507 return add_dir_files(td, td->o.opendir);
510 static int str_verify_offset_cb(void *data, unsigned int *off)
512 struct thread_data *td = data;
514 if (*off && *off < sizeof(struct verify_header)) {
515 log_err("fio: verify_offset too small\n");
519 td->o.verify_offset = *off;
523 static int str_verify_pattern_cb(void *data, unsigned int *off)
525 struct thread_data *td = data;
530 td->o.verify_pattern_bytes = 1;
532 td->o.verify_pattern_bytes = 2;
534 td->o.verify_pattern_bytes = 3;
536 td->o.verify_pattern_bytes = 4;
538 td->o.verify_pattern = *off;
542 static int str_lockfile_cb(void *data, const char *str)
544 struct thread_data *td = data;
545 char *nr = get_opt_postfix(str);
547 td->o.lockfile_batch = 1;
549 td->o.lockfile_batch = atoi(nr);
556 static int str_write_bw_log_cb(void *data, const char *str)
558 struct thread_data *td = data;
561 td->o.bw_log_file = strdup(str);
563 td->o.write_bw_log = 1;
567 static int str_write_lat_log_cb(void *data, const char *str)
569 struct thread_data *td = data;
572 td->o.lat_log_file = strdup(str);
574 td->o.write_lat_log = 1;
578 static int str_gtod_reduce_cb(void *data, int *il)
580 struct thread_data *td = data;
583 td->o.disable_clat = !!val;
584 td->o.disable_slat = !!val;
585 td->o.disable_bw = !!val;
587 td->tv_cache_mask = 63;
592 static int str_gtod_cpu_cb(void *data, int *il)
594 struct thread_data *td = data;
597 td->o.gtod_cpu = val;
598 td->o.gtod_offload = 1;
602 static int rw_verify(struct fio_option *o, void *data)
604 struct thread_data *td = data;
606 if (read_only && td_write(td)) {
607 log_err("fio: job <%s> has write bit set, but fio is in"
608 " read-only mode\n", td->o.name);
615 static int gtod_cpu_verify(struct fio_option *o, void *data)
617 #ifndef FIO_HAVE_CPU_AFFINITY
618 struct thread_data *td = data;
620 if (td->o.gtod_cpu) {
621 log_err("fio: platform must support CPU affinity for"
622 "gettimeofday() offloading\n");
630 #define __stringify_1(x) #x
631 #define __stringify(x) __stringify_1(x)
634 * Map of job/command line options
636 static struct fio_option options[] = {
638 .name = "description",
639 .type = FIO_OPT_STR_STORE,
640 .off1 = td_var_offset(description),
641 .help = "Text job description",
645 .type = FIO_OPT_STR_STORE,
646 .off1 = td_var_offset(name),
647 .help = "Name of this job",
651 .type = FIO_OPT_STR_STORE,
652 .off1 = td_var_offset(directory),
653 .cb = str_directory_cb,
654 .help = "Directory to store files in",
658 .type = FIO_OPT_STR_STORE,
659 .off1 = td_var_offset(filename),
660 .cb = str_filename_cb,
661 .prio = -1, /* must come after "directory" */
662 .help = "File(s) to use for the workload",
667 .cb = str_lockfile_cb,
668 .off1 = td_var_offset(file_lock_mode),
669 .help = "Lock file when doing IO to it",
670 .parent = "filename",
674 .oval = FILE_LOCK_NONE,
675 .help = "No file locking",
677 { .ival = "exclusive",
678 .oval = FILE_LOCK_EXCLUSIVE,
679 .help = "Exclusive file lock",
683 .oval = FILE_LOCK_READWRITE,
684 .help = "Read vs write lock",
690 .type = FIO_OPT_STR_STORE,
691 .off1 = td_var_offset(opendir),
692 .cb = str_opendir_cb,
693 .help = "Recursively add files from this directory and down",
697 .alias = "readwrite",
700 .off1 = td_var_offset(td_ddir),
701 .help = "IO direction",
706 .oval = TD_DDIR_READ,
707 .help = "Sequential read",
710 .oval = TD_DDIR_WRITE,
711 .help = "Sequential write",
713 { .ival = "randread",
714 .oval = TD_DDIR_RANDREAD,
715 .help = "Random read",
717 { .ival = "randwrite",
718 .oval = TD_DDIR_RANDWRITE,
719 .help = "Random write",
723 .help = "Sequential read and write mix",
726 .oval = TD_DDIR_RANDRW,
727 .help = "Random read and write mix"
733 .type = FIO_OPT_STR_STORE,
734 .off1 = td_var_offset(ioengine),
735 .help = "IO engine to use",
739 .help = "Use read/write",
742 .help = "Use pread/pwrite",
745 .help = "Use readv/writev",
747 #ifdef FIO_HAVE_LIBAIO
749 .help = "Linux native asynchronous IO",
752 #ifdef FIO_HAVE_POSIXAIO
753 { .ival = "posixaio",
754 .help = "POSIX asynchronous IO",
757 #ifdef FIO_HAVE_SOLARISAIO
758 { .ival = "solarisaio",
759 .help = "Solaris native asynchronous IO",
763 .help = "Memory mapped IO",
765 #ifdef FIO_HAVE_SPLICE
767 .help = "splice/vmsplice based IO",
769 { .ival = "netsplice",
770 .help = "splice/vmsplice to/from the network",
775 .help = "SCSI generic v3 IO",
779 .help = "Testing engine (no data transfer)",
782 .help = "Network IO",
784 #ifdef FIO_HAVE_SYSLET
785 { .ival = "syslet-rw",
786 .help = "syslet enabled async pread/pwrite IO",
790 .help = "CPU cycler burner engine",
792 #ifdef FIO_HAVE_GUASI
794 .help = "GUASI IO engine",
797 { .ival = "external",
798 .help = "Load external engine (append name)",
805 .off1 = td_var_offset(iodepth),
806 .help = "Amount of IO buffers to keep in flight",
811 .name = "iodepth_batch",
812 .alias = "iodepth_batch_submit",
814 .off1 = td_var_offset(iodepth_batch),
815 .help = "Number of IO buffers to submit in one go",
821 .name = "iodepth_batch_complete",
823 .off1 = td_var_offset(iodepth_batch_complete),
824 .help = "Number of IO buffers to retrieve in one go",
830 .name = "iodepth_low",
832 .off1 = td_var_offset(iodepth_low),
833 .help = "Low water mark for queuing depth",
838 .type = FIO_OPT_STR_VAL,
839 .off1 = td_var_offset(size),
841 .help = "Total size of device or files",
844 .name = "fill_device",
845 .type = FIO_OPT_BOOL,
846 .off1 = td_var_offset(fill_device),
847 .help = "Write until an ENOSPC error occurs",
852 .type = FIO_OPT_STR_VAL,
853 .off1 = td_var_offset(file_size_low),
854 .off2 = td_var_offset(file_size_high),
856 .help = "Size of individual files",
860 .alias = "fileoffset",
861 .type = FIO_OPT_STR_VAL,
862 .off1 = td_var_offset(start_offset),
863 .help = "Start IO from this offset",
868 .alias = "blocksize",
870 .off1 = td_var_offset(bs[DDIR_READ]),
871 .off2 = td_var_offset(bs[DDIR_WRITE]),
873 .help = "Block size unit",
879 .alias = "blockalign",
881 .off1 = td_var_offset(ba[DDIR_READ]),
882 .off2 = td_var_offset(ba[DDIR_WRITE]),
884 .help = "IO block offset alignment",
889 .alias = "blocksize_range",
890 .type = FIO_OPT_RANGE,
891 .off1 = td_var_offset(min_bs[DDIR_READ]),
892 .off2 = td_var_offset(max_bs[DDIR_READ]),
893 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
894 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
896 .help = "Set block size range (in more detail than bs)",
902 .cb = str_bssplit_cb,
903 .help = "Set a specific mix of block sizes",
907 .name = "bs_unaligned",
908 .alias = "blocksize_unaligned",
909 .type = FIO_OPT_STR_SET,
910 .off1 = td_var_offset(bs_unaligned),
911 .help = "Don't sector align IO buffer sizes",
915 .name = "randrepeat",
916 .type = FIO_OPT_BOOL,
917 .off1 = td_var_offset(rand_repeatable),
918 .help = "Use repeatable random IO pattern",
923 .name = "norandommap",
924 .type = FIO_OPT_STR_SET,
925 .off1 = td_var_offset(norandommap),
926 .help = "Accept potential duplicate random blocks",
930 .name = "softrandommap",
931 .type = FIO_OPT_BOOL,
932 .off1 = td_var_offset(softrandommap),
933 .help = "Set norandommap if randommap allocation fails",
934 .parent = "norandommap",
940 .off1 = td_var_offset(nr_files),
941 .help = "Split job workload between this number of files",
947 .off1 = td_var_offset(open_files),
948 .help = "Number of files to keep open at the same time",
951 .name = "file_service_type",
954 .off1 = td_var_offset(file_service_type),
955 .help = "How to select which file to service next",
959 .oval = FIO_FSERVICE_RANDOM,
960 .help = "Choose a file at random",
962 { .ival = "roundrobin",
963 .oval = FIO_FSERVICE_RR,
964 .help = "Round robin select files",
966 { .ival = "sequential",
967 .oval = FIO_FSERVICE_SEQ,
968 .help = "Finish one file before moving to the next",
974 .name = "fadvise_hint",
975 .type = FIO_OPT_BOOL,
976 .off1 = td_var_offset(fadvise_hint),
977 .help = "Use fadvise() to advise the kernel on IO pattern",
983 .off1 = td_var_offset(fsync_blocks),
984 .help = "Issue fsync for writes every given number of blocks",
990 .off1 = td_var_offset(fdatasync_blocks),
991 .help = "Issue fdatasync for writes every given number of blocks",
996 .type = FIO_OPT_BOOL,
997 .off1 = td_var_offset(odirect),
998 .help = "Use O_DIRECT IO (negates buffered)",
1003 .type = FIO_OPT_BOOL,
1004 .off1 = td_var_offset(odirect),
1006 .help = "Use buffered IO (negates direct)",
1010 .name = "overwrite",
1011 .type = FIO_OPT_BOOL,
1012 .off1 = td_var_offset(overwrite),
1013 .help = "When writing, set whether to overwrite current data",
1018 .type = FIO_OPT_INT,
1019 .off1 = td_var_offset(loops),
1020 .help = "Number of times to run the job",
1025 .type = FIO_OPT_INT,
1026 .off1 = td_var_offset(numjobs),
1027 .help = "Duplicate this job this many times",
1031 .name = "startdelay",
1032 .type = FIO_OPT_INT,
1033 .off1 = td_var_offset(start_delay),
1034 .help = "Only start job when this period has passed",
1040 .type = FIO_OPT_STR_VAL_TIME,
1041 .off1 = td_var_offset(timeout),
1042 .help = "Stop workload when this amount of time has passed",
1046 .name = "time_based",
1047 .type = FIO_OPT_STR_SET,
1048 .off1 = td_var_offset(time_based),
1049 .help = "Keep running until runtime/timeout is met",
1052 .name = "ramp_time",
1053 .type = FIO_OPT_STR_VAL_TIME,
1054 .off1 = td_var_offset(ramp_time),
1055 .help = "Ramp up time before measuring performance",
1060 .type = FIO_OPT_STR,
1062 .off1 = td_var_offset(mem_type),
1063 .help = "Backing type for IO buffers",
1068 .help = "Use malloc(3) for IO buffers",
1072 .help = "Use shared memory segments for IO buffers",
1074 #ifdef FIO_HAVE_HUGETLB
1075 { .ival = "shmhuge",
1076 .oval = MEM_SHMHUGE,
1077 .help = "Like shm, but use huge pages",
1082 .help = "Use mmap(2) (file or anon) for IO buffers",
1084 #ifdef FIO_HAVE_HUGETLB
1085 { .ival = "mmaphuge",
1086 .oval = MEM_MMAPHUGE,
1087 .help = "Like mmap, but use huge pages",
1093 .name = "iomem_align",
1094 .alias = "mem_align",
1095 .type = FIO_OPT_INT,
1096 .off1 = td_var_offset(mem_align),
1098 .help = "IO memory buffer offset alignment",
1104 .type = FIO_OPT_STR,
1105 .off1 = td_var_offset(verify),
1106 .help = "Verify data written",
1110 .oval = VERIFY_NONE,
1111 .help = "Don't do IO verification",
1115 .help = "Use md5 checksums for verification",
1118 .oval = VERIFY_CRC64,
1119 .help = "Use crc64 checksums for verification",
1122 .oval = VERIFY_CRC32,
1123 .help = "Use crc32 checksums for verification",
1125 { .ival = "crc32c-intel",
1126 .oval = VERIFY_CRC32C_INTEL,
1127 .help = "Use hw crc32c checksums for verification",
1130 .oval = VERIFY_CRC32C,
1131 .help = "Use crc32c checksums for verification",
1134 .oval = VERIFY_CRC16,
1135 .help = "Use crc16 checksums for verification",
1138 .oval = VERIFY_CRC7,
1139 .help = "Use crc7 checksums for verification",
1142 .oval = VERIFY_SHA256,
1143 .help = "Use sha256 checksums for verification",
1146 .oval = VERIFY_SHA512,
1147 .help = "Use sha512 checksums for verification",
1150 .oval = VERIFY_META,
1151 .help = "Use io information",
1155 .oval = VERIFY_NULL,
1156 .help = "Pretend to verify",
1161 .name = "do_verify",
1162 .type = FIO_OPT_BOOL,
1163 .off1 = td_var_offset(do_verify),
1164 .help = "Run verification stage after write",
1169 .name = "verifysort",
1170 .type = FIO_OPT_BOOL,
1171 .off1 = td_var_offset(verifysort),
1172 .help = "Sort written verify blocks for read back",
1177 .name = "verify_interval",
1178 .type = FIO_OPT_INT,
1179 .off1 = td_var_offset(verify_interval),
1180 .minval = 2 * sizeof(struct verify_header),
1181 .help = "Store verify buffer header every N bytes",
1185 .name = "verify_offset",
1186 .type = FIO_OPT_INT,
1187 .help = "Offset verify header location by N bytes",
1189 .cb = str_verify_offset_cb,
1193 .name = "verify_pattern",
1194 .type = FIO_OPT_INT,
1195 .cb = str_verify_pattern_cb,
1196 .help = "Fill pattern for IO buffers",
1200 .name = "verify_fatal",
1201 .type = FIO_OPT_BOOL,
1202 .off1 = td_var_offset(verify_fatal),
1204 .help = "Exit on a single verify failure, don't continue",
1208 .name = "verify_async",
1209 .type = FIO_OPT_INT,
1210 .off1 = td_var_offset(verify_async),
1212 .help = "Number of async verifier threads to use",
1215 #ifdef FIO_HAVE_CPU_AFFINITY
1217 .name = "verify_async_cpus",
1218 .type = FIO_OPT_STR,
1219 .cb = str_verify_cpus_allowed_cb,
1220 .help = "Set CPUs allowed for async verify threads",
1221 .parent = "verify_async",
1225 .name = "write_iolog",
1226 .type = FIO_OPT_STR_STORE,
1227 .off1 = td_var_offset(write_iolog_file),
1228 .help = "Store IO pattern to file",
1231 .name = "read_iolog",
1232 .type = FIO_OPT_STR_STORE,
1233 .off1 = td_var_offset(read_iolog_file),
1234 .help = "Playback IO pattern from file",
1237 .name = "exec_prerun",
1238 .type = FIO_OPT_STR_STORE,
1239 .off1 = td_var_offset(exec_prerun),
1240 .help = "Execute this file prior to running job",
1243 .name = "exec_postrun",
1244 .type = FIO_OPT_STR_STORE,
1245 .off1 = td_var_offset(exec_postrun),
1246 .help = "Execute this file after running job",
1248 #ifdef FIO_HAVE_IOSCHED_SWITCH
1250 .name = "ioscheduler",
1251 .type = FIO_OPT_STR_STORE,
1252 .off1 = td_var_offset(ioscheduler),
1253 .help = "Use this IO scheduler on the backing device",
1258 .type = FIO_OPT_STR_VAL,
1259 .off1 = td_var_offset(zone_size),
1260 .help = "Give size of an IO zone",
1265 .type = FIO_OPT_STR_VAL,
1266 .off1 = td_var_offset(zone_skip),
1267 .help = "Space between IO zones",
1272 .type = FIO_OPT_STR_VAL,
1273 .cb = str_lockmem_cb,
1274 .help = "Lock down this amount of memory",
1278 .name = "rwmixread",
1279 .type = FIO_OPT_INT,
1280 .cb = str_rwmix_read_cb,
1282 .help = "Percentage of mixed workload that is reads",
1286 .name = "rwmixwrite",
1287 .type = FIO_OPT_INT,
1288 .cb = str_rwmix_write_cb,
1290 .help = "Percentage of mixed workload that is writes",
1294 .name = "rwmixcycle",
1295 .type = FIO_OPT_DEPRECATED,
1299 .type = FIO_OPT_INT,
1300 .off1 = td_var_offset(nice),
1301 .help = "Set job CPU nice value",
1306 #ifdef FIO_HAVE_IOPRIO
1309 .type = FIO_OPT_INT,
1311 .help = "Set job IO priority value",
1316 .name = "prioclass",
1317 .type = FIO_OPT_INT,
1318 .cb = str_prioclass_cb,
1319 .help = "Set job IO priority class",
1325 .name = "thinktime",
1326 .type = FIO_OPT_INT,
1327 .off1 = td_var_offset(thinktime),
1328 .help = "Idle time between IO buffers (usec)",
1332 .name = "thinktime_spin",
1333 .type = FIO_OPT_INT,
1334 .off1 = td_var_offset(thinktime_spin),
1335 .help = "Start think time by spinning this amount (usec)",
1337 .parent = "thinktime",
1340 .name = "thinktime_blocks",
1341 .type = FIO_OPT_INT,
1342 .off1 = td_var_offset(thinktime_blocks),
1343 .help = "IO buffer period between 'thinktime'",
1345 .parent = "thinktime",
1349 .type = FIO_OPT_INT,
1350 .off1 = td_var_offset(rate[0]),
1351 .off2 = td_var_offset(rate[1]),
1352 .help = "Set bandwidth rate",
1356 .type = FIO_OPT_INT,
1357 .off1 = td_var_offset(ratemin[0]),
1358 .off2 = td_var_offset(ratemin[1]),
1359 .help = "Job must meet this rate or it will be shutdown",
1363 .name = "rate_iops",
1364 .type = FIO_OPT_INT,
1365 .off1 = td_var_offset(rate_iops[0]),
1366 .off2 = td_var_offset(rate_iops[1]),
1367 .help = "Limit IO used to this number of IO operations/sec",
1370 .name = "rate_iops_min",
1371 .type = FIO_OPT_INT,
1372 .off1 = td_var_offset(rate_iops_min[0]),
1373 .off2 = td_var_offset(rate_iops_min[1]),
1374 .help = "Job must meet this rate or it will be shutdown",
1375 .parent = "rate_iops",
1378 .name = "ratecycle",
1379 .type = FIO_OPT_INT,
1380 .off1 = td_var_offset(ratecycle),
1381 .help = "Window average for rate limits (msec)",
1386 .name = "invalidate",
1387 .type = FIO_OPT_BOOL,
1388 .off1 = td_var_offset(invalidate_cache),
1389 .help = "Invalidate buffer/page cache prior to running job",
1394 .type = FIO_OPT_BOOL,
1395 .off1 = td_var_offset(sync_io),
1396 .help = "Use O_SYNC for buffered writes",
1398 .parent = "buffered",
1401 .name = "bwavgtime",
1402 .type = FIO_OPT_INT,
1403 .off1 = td_var_offset(bw_avg_time),
1404 .help = "Time window over which to calculate bandwidth"
1409 .name = "create_serialize",
1410 .type = FIO_OPT_BOOL,
1411 .off1 = td_var_offset(create_serialize),
1412 .help = "Serialize creating of job files",
1416 .name = "create_fsync",
1417 .type = FIO_OPT_BOOL,
1418 .off1 = td_var_offset(create_fsync),
1419 .help = "Fsync file after creation",
1423 .name = "create_on_open",
1424 .type = FIO_OPT_BOOL,
1425 .off1 = td_var_offset(create_on_open),
1426 .help = "Create files when they are opened for IO",
1431 .type = FIO_OPT_BOOL,
1432 .off1 = td_var_offset(pre_read),
1433 .help = "Preread files before starting official testing",
1438 .type = FIO_OPT_INT,
1439 .off1 = td_var_offset(cpuload),
1440 .help = "Use this percentage of CPU",
1443 .name = "cpuchunks",
1444 .type = FIO_OPT_INT,
1445 .off1 = td_var_offset(cpucycle),
1446 .help = "Length of the CPU burn cycles (usecs)",
1448 .parent = "cpuload",
1450 #ifdef FIO_HAVE_CPU_AFFINITY
1453 .type = FIO_OPT_INT,
1454 .cb = str_cpumask_cb,
1455 .help = "CPU affinity mask",
1458 .name = "cpus_allowed",
1459 .type = FIO_OPT_STR,
1460 .cb = str_cpus_allowed_cb,
1461 .help = "Set CPUs allowed",
1465 .name = "end_fsync",
1466 .type = FIO_OPT_BOOL,
1467 .off1 = td_var_offset(end_fsync),
1468 .help = "Include fsync at the end of job",
1472 .name = "fsync_on_close",
1473 .type = FIO_OPT_BOOL,
1474 .off1 = td_var_offset(fsync_on_close),
1475 .help = "fsync files on close",
1480 .type = FIO_OPT_BOOL,
1481 .off1 = td_var_offset(unlink),
1482 .help = "Unlink created files after job has completed",
1487 .type = FIO_OPT_STR_SET,
1488 .cb = str_exitall_cb,
1489 .help = "Terminate all jobs when one exits",
1492 .name = "stonewall",
1493 .type = FIO_OPT_STR_SET,
1494 .off1 = td_var_offset(stonewall),
1495 .help = "Insert a hard barrier between this job and previous",
1498 .name = "new_group",
1499 .type = FIO_OPT_STR_SET,
1500 .off1 = td_var_offset(new_group),
1501 .help = "Mark the start of a new group (for reporting)",
1505 .type = FIO_OPT_STR_SET,
1506 .off1 = td_var_offset(use_thread),
1507 .help = "Use threads instead of forks",
1510 .name = "write_bw_log",
1511 .type = FIO_OPT_STR,
1512 .off1 = td_var_offset(write_bw_log),
1513 .cb = str_write_bw_log_cb,
1514 .help = "Write log of bandwidth during run",
1517 .name = "write_lat_log",
1518 .type = FIO_OPT_STR,
1519 .off1 = td_var_offset(write_lat_log),
1520 .cb = str_write_lat_log_cb,
1521 .help = "Write log of latency during run",
1524 .name = "hugepage-size",
1525 .type = FIO_OPT_INT,
1526 .off1 = td_var_offset(hugepage_size),
1527 .help = "When using hugepages, specify size of each page",
1528 .def = __stringify(FIO_HUGE_PAGE),
1531 .name = "group_reporting",
1532 .type = FIO_OPT_STR_SET,
1533 .off1 = td_var_offset(group_reporting),
1534 .help = "Do reporting on a per-group basis",
1537 .name = "zero_buffers",
1538 .type = FIO_OPT_STR_SET,
1539 .off1 = td_var_offset(zero_buffers),
1540 .help = "Init IO buffers to all zeroes",
1543 .name = "refill_buffers",
1544 .type = FIO_OPT_STR_SET,
1545 .off1 = td_var_offset(refill_buffers),
1546 .help = "Refill IO buffers on every IO submit",
1548 #ifdef FIO_HAVE_DISK_UTIL
1550 .name = "disk_util",
1551 .type = FIO_OPT_BOOL,
1552 .off1 = td_var_offset(do_disk_util),
1553 .help = "Log disk utilization statistics",
1558 .name = "gtod_reduce",
1559 .type = FIO_OPT_BOOL,
1560 .help = "Greatly reduce number of gettimeofday() calls",
1561 .cb = str_gtod_reduce_cb,
1565 .name = "disable_clat",
1566 .type = FIO_OPT_BOOL,
1567 .off1 = td_var_offset(disable_clat),
1568 .help = "Disable completion latency numbers",
1569 .parent = "gtod_reduce",
1573 .name = "disable_slat",
1574 .type = FIO_OPT_BOOL,
1575 .off1 = td_var_offset(disable_slat),
1576 .help = "Disable submissionn latency numbers",
1577 .parent = "gtod_reduce",
1581 .name = "disable_bw_measurement",
1582 .type = FIO_OPT_BOOL,
1583 .off1 = td_var_offset(disable_bw),
1584 .help = "Disable bandwidth logging",
1585 .parent = "gtod_reduce",
1590 .type = FIO_OPT_INT,
1591 .cb = str_gtod_cpu_cb,
1592 .help = "Setup dedicated gettimeofday() thread on this CPU",
1593 .verify = gtod_cpu_verify,
1596 .name = "continue_on_error",
1597 .type = FIO_OPT_BOOL,
1598 .off1 = td_var_offset(continue_on_error),
1599 .help = "Continue on non-fatal errors during I/O",
1607 void fio_options_dup_and_init(struct option *long_options)
1609 struct fio_option *o;
1612 options_init(options);
1615 while (long_options[i].name)
1620 long_options[i].name = (char *) o->name;
1621 long_options[i].val = FIO_GETOPT_JOB;
1622 if (o->type == FIO_OPT_STR_SET)
1623 long_options[i].has_arg = no_argument;
1625 long_options[i].has_arg = required_argument;
1629 assert(i < FIO_NR_OPTIONS);
1633 int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
1637 sort_options(opts, options, num_opts);
1639 for (ret = 0, i = 0; i < num_opts; i++)
1640 ret |= parse_option(opts[i], options, td);
1645 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
1647 return parse_cmd_option(opt, val, options, td);
1650 void fio_fill_default_options(struct thread_data *td)
1652 fill_default_options(td, options);
1655 int fio_show_option_help(const char *opt)
1657 return show_cmd_help(options, opt);
1660 static void __options_mem(struct thread_data *td, int alloc)
1662 struct thread_options *o = &td->o;
1663 struct fio_option *opt;
1667 for (i = 0, opt = &options[0]; opt->name; i++, opt = &options[i]) {
1668 if (opt->type != FIO_OPT_STR_STORE)
1671 ptr = (void *) o + opt->off1;
1674 *ptr = strdup(*ptr);
1684 * dupe FIO_OPT_STR_STORE options
1686 void options_mem_dupe(struct thread_data *td)
1688 __options_mem(td, 1);
1691 void options_mem_free(struct thread_data fio_unused *td)
1694 __options_mem(td, 0);