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, &td)) {
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 static int kb_base_verify(struct fio_option *o, void *data)
632 struct thread_data *td = data;
634 if (td->o.kb_base != 1024 && td->o.kb_base != 1000) {
635 log_err("fio: kb_base set to nonsensical value: %u\n",
643 #define __stringify_1(x) #x
644 #define __stringify(x) __stringify_1(x)
647 * Map of job/command line options
649 static struct fio_option options[] = {
651 .name = "description",
652 .type = FIO_OPT_STR_STORE,
653 .off1 = td_var_offset(description),
654 .help = "Text job description",
658 .type = FIO_OPT_STR_STORE,
659 .off1 = td_var_offset(name),
660 .help = "Name of this job",
664 .type = FIO_OPT_STR_STORE,
665 .off1 = td_var_offset(directory),
666 .cb = str_directory_cb,
667 .help = "Directory to store files in",
671 .type = FIO_OPT_STR_STORE,
672 .off1 = td_var_offset(filename),
673 .cb = str_filename_cb,
674 .prio = -1, /* must come after "directory" */
675 .help = "File(s) to use for the workload",
680 .off1 = td_var_offset(kb_base),
681 .verify = kb_base_verify,
684 .help = "How many bytes per KB for reporting (1000 or 1024)",
689 .cb = str_lockfile_cb,
690 .off1 = td_var_offset(file_lock_mode),
691 .help = "Lock file when doing IO to it",
692 .parent = "filename",
696 .oval = FILE_LOCK_NONE,
697 .help = "No file locking",
699 { .ival = "exclusive",
700 .oval = FILE_LOCK_EXCLUSIVE,
701 .help = "Exclusive file lock",
705 .oval = FILE_LOCK_READWRITE,
706 .help = "Read vs write lock",
712 .type = FIO_OPT_STR_STORE,
713 .off1 = td_var_offset(opendir),
714 .cb = str_opendir_cb,
715 .help = "Recursively add files from this directory and down",
719 .alias = "readwrite",
722 .off1 = td_var_offset(td_ddir),
723 .help = "IO direction",
728 .oval = TD_DDIR_READ,
729 .help = "Sequential read",
732 .oval = TD_DDIR_WRITE,
733 .help = "Sequential write",
735 { .ival = "randread",
736 .oval = TD_DDIR_RANDREAD,
737 .help = "Random read",
739 { .ival = "randwrite",
740 .oval = TD_DDIR_RANDWRITE,
741 .help = "Random write",
745 .help = "Sequential read and write mix",
748 .oval = TD_DDIR_RANDRW,
749 .help = "Random read and write mix"
755 .type = FIO_OPT_STR_STORE,
756 .off1 = td_var_offset(ioengine),
757 .help = "IO engine to use",
761 .help = "Use read/write",
764 .help = "Use pread/pwrite",
767 .help = "Use readv/writev",
769 #ifdef FIO_HAVE_LIBAIO
771 .help = "Linux native asynchronous IO",
774 #ifdef FIO_HAVE_POSIXAIO
775 { .ival = "posixaio",
776 .help = "POSIX asynchronous IO",
779 #ifdef FIO_HAVE_SOLARISAIO
780 { .ival = "solarisaio",
781 .help = "Solaris native asynchronous IO",
785 .help = "Memory mapped IO",
787 #ifdef FIO_HAVE_SPLICE
789 .help = "splice/vmsplice based IO",
791 { .ival = "netsplice",
792 .help = "splice/vmsplice to/from the network",
797 .help = "SCSI generic v3 IO",
801 .help = "Testing engine (no data transfer)",
804 .help = "Network IO",
806 #ifdef FIO_HAVE_SYSLET
807 { .ival = "syslet-rw",
808 .help = "syslet enabled async pread/pwrite IO",
812 .help = "CPU cycler burner engine",
814 #ifdef FIO_HAVE_GUASI
816 .help = "GUASI IO engine",
819 { .ival = "external",
820 .help = "Load external engine (append name)",
827 .off1 = td_var_offset(iodepth),
828 .help = "Amount of IO buffers to keep in flight",
833 .name = "iodepth_batch",
834 .alias = "iodepth_batch_submit",
836 .off1 = td_var_offset(iodepth_batch),
837 .help = "Number of IO buffers to submit in one go",
843 .name = "iodepth_batch_complete",
845 .off1 = td_var_offset(iodepth_batch_complete),
846 .help = "Number of IO buffers to retrieve in one go",
852 .name = "iodepth_low",
854 .off1 = td_var_offset(iodepth_low),
855 .help = "Low water mark for queuing depth",
860 .type = FIO_OPT_STR_VAL,
861 .off1 = td_var_offset(size),
863 .help = "Total size of device or files",
866 .name = "fill_device",
867 .type = FIO_OPT_BOOL,
868 .off1 = td_var_offset(fill_device),
869 .help = "Write until an ENOSPC error occurs",
874 .type = FIO_OPT_STR_VAL,
875 .off1 = td_var_offset(file_size_low),
876 .off2 = td_var_offset(file_size_high),
878 .help = "Size of individual files",
882 .alias = "fileoffset",
883 .type = FIO_OPT_STR_VAL,
884 .off1 = td_var_offset(start_offset),
885 .help = "Start IO from this offset",
890 .alias = "blocksize",
892 .off1 = td_var_offset(bs[DDIR_READ]),
893 .off2 = td_var_offset(bs[DDIR_WRITE]),
895 .help = "Block size unit",
901 .alias = "blockalign",
903 .off1 = td_var_offset(ba[DDIR_READ]),
904 .off2 = td_var_offset(ba[DDIR_WRITE]),
906 .help = "IO block offset alignment",
911 .alias = "blocksize_range",
912 .type = FIO_OPT_RANGE,
913 .off1 = td_var_offset(min_bs[DDIR_READ]),
914 .off2 = td_var_offset(max_bs[DDIR_READ]),
915 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
916 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
918 .help = "Set block size range (in more detail than bs)",
924 .cb = str_bssplit_cb,
925 .help = "Set a specific mix of block sizes",
929 .name = "bs_unaligned",
930 .alias = "blocksize_unaligned",
931 .type = FIO_OPT_STR_SET,
932 .off1 = td_var_offset(bs_unaligned),
933 .help = "Don't sector align IO buffer sizes",
937 .name = "randrepeat",
938 .type = FIO_OPT_BOOL,
939 .off1 = td_var_offset(rand_repeatable),
940 .help = "Use repeatable random IO pattern",
945 .name = "norandommap",
946 .type = FIO_OPT_STR_SET,
947 .off1 = td_var_offset(norandommap),
948 .help = "Accept potential duplicate random blocks",
952 .name = "softrandommap",
953 .type = FIO_OPT_BOOL,
954 .off1 = td_var_offset(softrandommap),
955 .help = "Set norandommap if randommap allocation fails",
956 .parent = "norandommap",
962 .off1 = td_var_offset(nr_files),
963 .help = "Split job workload between this number of files",
969 .off1 = td_var_offset(open_files),
970 .help = "Number of files to keep open at the same time",
973 .name = "file_service_type",
976 .off1 = td_var_offset(file_service_type),
977 .help = "How to select which file to service next",
981 .oval = FIO_FSERVICE_RANDOM,
982 .help = "Choose a file at random",
984 { .ival = "roundrobin",
985 .oval = FIO_FSERVICE_RR,
986 .help = "Round robin select files",
988 { .ival = "sequential",
989 .oval = FIO_FSERVICE_SEQ,
990 .help = "Finish one file before moving to the next",
996 .name = "fadvise_hint",
997 .type = FIO_OPT_BOOL,
998 .off1 = td_var_offset(fadvise_hint),
999 .help = "Use fadvise() to advise the kernel on IO pattern",
1004 .type = FIO_OPT_INT,
1005 .off1 = td_var_offset(fsync_blocks),
1006 .help = "Issue fsync for writes every given number of blocks",
1010 .name = "fdatasync",
1011 .type = FIO_OPT_INT,
1012 .off1 = td_var_offset(fdatasync_blocks),
1013 .help = "Issue fdatasync for writes every given number of blocks",
1018 .type = FIO_OPT_BOOL,
1019 .off1 = td_var_offset(odirect),
1020 .help = "Use O_DIRECT IO (negates buffered)",
1025 .type = FIO_OPT_BOOL,
1026 .off1 = td_var_offset(odirect),
1028 .help = "Use buffered IO (negates direct)",
1032 .name = "overwrite",
1033 .type = FIO_OPT_BOOL,
1034 .off1 = td_var_offset(overwrite),
1035 .help = "When writing, set whether to overwrite current data",
1040 .type = FIO_OPT_INT,
1041 .off1 = td_var_offset(loops),
1042 .help = "Number of times to run the job",
1047 .type = FIO_OPT_INT,
1048 .off1 = td_var_offset(numjobs),
1049 .help = "Duplicate this job this many times",
1053 .name = "startdelay",
1054 .type = FIO_OPT_INT,
1055 .off1 = td_var_offset(start_delay),
1056 .help = "Only start job when this period has passed",
1062 .type = FIO_OPT_STR_VAL_TIME,
1063 .off1 = td_var_offset(timeout),
1064 .help = "Stop workload when this amount of time has passed",
1068 .name = "time_based",
1069 .type = FIO_OPT_STR_SET,
1070 .off1 = td_var_offset(time_based),
1071 .help = "Keep running until runtime/timeout is met",
1074 .name = "ramp_time",
1075 .type = FIO_OPT_STR_VAL_TIME,
1076 .off1 = td_var_offset(ramp_time),
1077 .help = "Ramp up time before measuring performance",
1082 .type = FIO_OPT_STR,
1084 .off1 = td_var_offset(mem_type),
1085 .help = "Backing type for IO buffers",
1090 .help = "Use malloc(3) for IO buffers",
1094 .help = "Use shared memory segments for IO buffers",
1096 #ifdef FIO_HAVE_HUGETLB
1097 { .ival = "shmhuge",
1098 .oval = MEM_SHMHUGE,
1099 .help = "Like shm, but use huge pages",
1104 .help = "Use mmap(2) (file or anon) for IO buffers",
1106 #ifdef FIO_HAVE_HUGETLB
1107 { .ival = "mmaphuge",
1108 .oval = MEM_MMAPHUGE,
1109 .help = "Like mmap, but use huge pages",
1115 .name = "iomem_align",
1116 .alias = "mem_align",
1117 .type = FIO_OPT_INT,
1118 .off1 = td_var_offset(mem_align),
1120 .help = "IO memory buffer offset alignment",
1126 .type = FIO_OPT_STR,
1127 .off1 = td_var_offset(verify),
1128 .help = "Verify data written",
1132 .oval = VERIFY_NONE,
1133 .help = "Don't do IO verification",
1137 .help = "Use md5 checksums for verification",
1140 .oval = VERIFY_CRC64,
1141 .help = "Use crc64 checksums for verification",
1144 .oval = VERIFY_CRC32,
1145 .help = "Use crc32 checksums for verification",
1147 { .ival = "crc32c-intel",
1148 .oval = VERIFY_CRC32C_INTEL,
1149 .help = "Use hw crc32c checksums for verification",
1152 .oval = VERIFY_CRC32C,
1153 .help = "Use crc32c checksums for verification",
1156 .oval = VERIFY_CRC16,
1157 .help = "Use crc16 checksums for verification",
1160 .oval = VERIFY_CRC7,
1161 .help = "Use crc7 checksums for verification",
1164 .oval = VERIFY_SHA256,
1165 .help = "Use sha256 checksums for verification",
1168 .oval = VERIFY_SHA512,
1169 .help = "Use sha512 checksums for verification",
1172 .oval = VERIFY_META,
1173 .help = "Use io information",
1177 .oval = VERIFY_NULL,
1178 .help = "Pretend to verify",
1183 .name = "do_verify",
1184 .type = FIO_OPT_BOOL,
1185 .off1 = td_var_offset(do_verify),
1186 .help = "Run verification stage after write",
1191 .name = "verifysort",
1192 .type = FIO_OPT_BOOL,
1193 .off1 = td_var_offset(verifysort),
1194 .help = "Sort written verify blocks for read back",
1199 .name = "verify_interval",
1200 .type = FIO_OPT_INT,
1201 .off1 = td_var_offset(verify_interval),
1202 .minval = 2 * sizeof(struct verify_header),
1203 .help = "Store verify buffer header every N bytes",
1207 .name = "verify_offset",
1208 .type = FIO_OPT_INT,
1209 .help = "Offset verify header location by N bytes",
1211 .cb = str_verify_offset_cb,
1215 .name = "verify_pattern",
1216 .type = FIO_OPT_INT,
1217 .cb = str_verify_pattern_cb,
1218 .help = "Fill pattern for IO buffers",
1222 .name = "verify_fatal",
1223 .type = FIO_OPT_BOOL,
1224 .off1 = td_var_offset(verify_fatal),
1226 .help = "Exit on a single verify failure, don't continue",
1230 .name = "verify_async",
1231 .type = FIO_OPT_INT,
1232 .off1 = td_var_offset(verify_async),
1234 .help = "Number of async verifier threads to use",
1237 #ifdef FIO_HAVE_CPU_AFFINITY
1239 .name = "verify_async_cpus",
1240 .type = FIO_OPT_STR,
1241 .cb = str_verify_cpus_allowed_cb,
1242 .help = "Set CPUs allowed for async verify threads",
1243 .parent = "verify_async",
1247 .name = "write_iolog",
1248 .type = FIO_OPT_STR_STORE,
1249 .off1 = td_var_offset(write_iolog_file),
1250 .help = "Store IO pattern to file",
1253 .name = "read_iolog",
1254 .type = FIO_OPT_STR_STORE,
1255 .off1 = td_var_offset(read_iolog_file),
1256 .help = "Playback IO pattern from file",
1259 .name = "exec_prerun",
1260 .type = FIO_OPT_STR_STORE,
1261 .off1 = td_var_offset(exec_prerun),
1262 .help = "Execute this file prior to running job",
1265 .name = "exec_postrun",
1266 .type = FIO_OPT_STR_STORE,
1267 .off1 = td_var_offset(exec_postrun),
1268 .help = "Execute this file after running job",
1270 #ifdef FIO_HAVE_IOSCHED_SWITCH
1272 .name = "ioscheduler",
1273 .type = FIO_OPT_STR_STORE,
1274 .off1 = td_var_offset(ioscheduler),
1275 .help = "Use this IO scheduler on the backing device",
1280 .type = FIO_OPT_STR_VAL,
1281 .off1 = td_var_offset(zone_size),
1282 .help = "Give size of an IO zone",
1287 .type = FIO_OPT_STR_VAL,
1288 .off1 = td_var_offset(zone_skip),
1289 .help = "Space between IO zones",
1294 .type = FIO_OPT_STR_VAL,
1295 .cb = str_lockmem_cb,
1296 .help = "Lock down this amount of memory",
1300 .name = "rwmixread",
1301 .type = FIO_OPT_INT,
1302 .cb = str_rwmix_read_cb,
1304 .help = "Percentage of mixed workload that is reads",
1308 .name = "rwmixwrite",
1309 .type = FIO_OPT_INT,
1310 .cb = str_rwmix_write_cb,
1312 .help = "Percentage of mixed workload that is writes",
1316 .name = "rwmixcycle",
1317 .type = FIO_OPT_DEPRECATED,
1321 .type = FIO_OPT_INT,
1322 .off1 = td_var_offset(nice),
1323 .help = "Set job CPU nice value",
1328 #ifdef FIO_HAVE_IOPRIO
1331 .type = FIO_OPT_INT,
1333 .help = "Set job IO priority value",
1338 .name = "prioclass",
1339 .type = FIO_OPT_INT,
1340 .cb = str_prioclass_cb,
1341 .help = "Set job IO priority class",
1347 .name = "thinktime",
1348 .type = FIO_OPT_INT,
1349 .off1 = td_var_offset(thinktime),
1350 .help = "Idle time between IO buffers (usec)",
1354 .name = "thinktime_spin",
1355 .type = FIO_OPT_INT,
1356 .off1 = td_var_offset(thinktime_spin),
1357 .help = "Start think time by spinning this amount (usec)",
1359 .parent = "thinktime",
1362 .name = "thinktime_blocks",
1363 .type = FIO_OPT_INT,
1364 .off1 = td_var_offset(thinktime_blocks),
1365 .help = "IO buffer period between 'thinktime'",
1367 .parent = "thinktime",
1371 .type = FIO_OPT_INT,
1372 .off1 = td_var_offset(rate[0]),
1373 .off2 = td_var_offset(rate[1]),
1374 .help = "Set bandwidth rate",
1378 .type = FIO_OPT_INT,
1379 .off1 = td_var_offset(ratemin[0]),
1380 .off2 = td_var_offset(ratemin[1]),
1381 .help = "Job must meet this rate or it will be shutdown",
1385 .name = "rate_iops",
1386 .type = FIO_OPT_INT,
1387 .off1 = td_var_offset(rate_iops[0]),
1388 .off2 = td_var_offset(rate_iops[1]),
1389 .help = "Limit IO used to this number of IO operations/sec",
1392 .name = "rate_iops_min",
1393 .type = FIO_OPT_INT,
1394 .off1 = td_var_offset(rate_iops_min[0]),
1395 .off2 = td_var_offset(rate_iops_min[1]),
1396 .help = "Job must meet this rate or it will be shutdown",
1397 .parent = "rate_iops",
1400 .name = "ratecycle",
1401 .type = FIO_OPT_INT,
1402 .off1 = td_var_offset(ratecycle),
1403 .help = "Window average for rate limits (msec)",
1408 .name = "invalidate",
1409 .type = FIO_OPT_BOOL,
1410 .off1 = td_var_offset(invalidate_cache),
1411 .help = "Invalidate buffer/page cache prior to running job",
1416 .type = FIO_OPT_BOOL,
1417 .off1 = td_var_offset(sync_io),
1418 .help = "Use O_SYNC for buffered writes",
1420 .parent = "buffered",
1423 .name = "bwavgtime",
1424 .type = FIO_OPT_INT,
1425 .off1 = td_var_offset(bw_avg_time),
1426 .help = "Time window over which to calculate bandwidth"
1431 .name = "create_serialize",
1432 .type = FIO_OPT_BOOL,
1433 .off1 = td_var_offset(create_serialize),
1434 .help = "Serialize creating of job files",
1438 .name = "create_fsync",
1439 .type = FIO_OPT_BOOL,
1440 .off1 = td_var_offset(create_fsync),
1441 .help = "Fsync file after creation",
1445 .name = "create_on_open",
1446 .type = FIO_OPT_BOOL,
1447 .off1 = td_var_offset(create_on_open),
1448 .help = "Create files when they are opened for IO",
1453 .type = FIO_OPT_BOOL,
1454 .off1 = td_var_offset(pre_read),
1455 .help = "Preread files before starting official testing",
1460 .type = FIO_OPT_INT,
1461 .off1 = td_var_offset(cpuload),
1462 .help = "Use this percentage of CPU",
1465 .name = "cpuchunks",
1466 .type = FIO_OPT_INT,
1467 .off1 = td_var_offset(cpucycle),
1468 .help = "Length of the CPU burn cycles (usecs)",
1470 .parent = "cpuload",
1472 #ifdef FIO_HAVE_CPU_AFFINITY
1475 .type = FIO_OPT_INT,
1476 .cb = str_cpumask_cb,
1477 .help = "CPU affinity mask",
1480 .name = "cpus_allowed",
1481 .type = FIO_OPT_STR,
1482 .cb = str_cpus_allowed_cb,
1483 .help = "Set CPUs allowed",
1487 .name = "end_fsync",
1488 .type = FIO_OPT_BOOL,
1489 .off1 = td_var_offset(end_fsync),
1490 .help = "Include fsync at the end of job",
1494 .name = "fsync_on_close",
1495 .type = FIO_OPT_BOOL,
1496 .off1 = td_var_offset(fsync_on_close),
1497 .help = "fsync files on close",
1502 .type = FIO_OPT_BOOL,
1503 .off1 = td_var_offset(unlink),
1504 .help = "Unlink created files after job has completed",
1509 .type = FIO_OPT_STR_SET,
1510 .cb = str_exitall_cb,
1511 .help = "Terminate all jobs when one exits",
1514 .name = "stonewall",
1515 .type = FIO_OPT_STR_SET,
1516 .off1 = td_var_offset(stonewall),
1517 .help = "Insert a hard barrier between this job and previous",
1520 .name = "new_group",
1521 .type = FIO_OPT_STR_SET,
1522 .off1 = td_var_offset(new_group),
1523 .help = "Mark the start of a new group (for reporting)",
1527 .type = FIO_OPT_STR_SET,
1528 .off1 = td_var_offset(use_thread),
1529 .help = "Use threads instead of forks",
1532 .name = "write_bw_log",
1533 .type = FIO_OPT_STR,
1534 .off1 = td_var_offset(write_bw_log),
1535 .cb = str_write_bw_log_cb,
1536 .help = "Write log of bandwidth during run",
1539 .name = "write_lat_log",
1540 .type = FIO_OPT_STR,
1541 .off1 = td_var_offset(write_lat_log),
1542 .cb = str_write_lat_log_cb,
1543 .help = "Write log of latency during run",
1546 .name = "hugepage-size",
1547 .type = FIO_OPT_INT,
1548 .off1 = td_var_offset(hugepage_size),
1549 .help = "When using hugepages, specify size of each page",
1550 .def = __stringify(FIO_HUGE_PAGE),
1553 .name = "group_reporting",
1554 .type = FIO_OPT_STR_SET,
1555 .off1 = td_var_offset(group_reporting),
1556 .help = "Do reporting on a per-group basis",
1559 .name = "zero_buffers",
1560 .type = FIO_OPT_STR_SET,
1561 .off1 = td_var_offset(zero_buffers),
1562 .help = "Init IO buffers to all zeroes",
1565 .name = "refill_buffers",
1566 .type = FIO_OPT_STR_SET,
1567 .off1 = td_var_offset(refill_buffers),
1568 .help = "Refill IO buffers on every IO submit",
1570 #ifdef FIO_HAVE_DISK_UTIL
1572 .name = "disk_util",
1573 .type = FIO_OPT_BOOL,
1574 .off1 = td_var_offset(do_disk_util),
1575 .help = "Log disk utilization statistics",
1580 .name = "gtod_reduce",
1581 .type = FIO_OPT_BOOL,
1582 .help = "Greatly reduce number of gettimeofday() calls",
1583 .cb = str_gtod_reduce_cb,
1587 .name = "disable_clat",
1588 .type = FIO_OPT_BOOL,
1589 .off1 = td_var_offset(disable_clat),
1590 .help = "Disable completion latency numbers",
1591 .parent = "gtod_reduce",
1595 .name = "disable_slat",
1596 .type = FIO_OPT_BOOL,
1597 .off1 = td_var_offset(disable_slat),
1598 .help = "Disable submissionn latency numbers",
1599 .parent = "gtod_reduce",
1603 .name = "disable_bw_measurement",
1604 .type = FIO_OPT_BOOL,
1605 .off1 = td_var_offset(disable_bw),
1606 .help = "Disable bandwidth logging",
1607 .parent = "gtod_reduce",
1612 .type = FIO_OPT_INT,
1613 .cb = str_gtod_cpu_cb,
1614 .help = "Setup dedicated gettimeofday() thread on this CPU",
1615 .verify = gtod_cpu_verify,
1618 .name = "continue_on_error",
1619 .type = FIO_OPT_BOOL,
1620 .off1 = td_var_offset(continue_on_error),
1621 .help = "Continue on non-fatal errors during I/O",
1629 void fio_options_dup_and_init(struct option *long_options)
1631 struct fio_option *o;
1634 options_init(options);
1637 while (long_options[i].name)
1642 long_options[i].name = (char *) o->name;
1643 long_options[i].val = FIO_GETOPT_JOB;
1644 if (o->type == FIO_OPT_STR_SET)
1645 long_options[i].has_arg = no_argument;
1647 long_options[i].has_arg = required_argument;
1651 assert(i < FIO_NR_OPTIONS);
1655 int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
1659 sort_options(opts, options, num_opts);
1661 for (ret = 0, i = 0; i < num_opts; i++)
1662 ret |= parse_option(opts[i], options, td);
1667 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
1669 return parse_cmd_option(opt, val, options, td);
1672 void fio_fill_default_options(struct thread_data *td)
1674 fill_default_options(td, options);
1677 int fio_show_option_help(const char *opt)
1679 return show_cmd_help(options, opt);
1682 static void __options_mem(struct thread_data *td, int alloc)
1684 struct thread_options *o = &td->o;
1685 struct fio_option *opt;
1689 for (i = 0, opt = &options[0]; opt->name; i++, opt = &options[i]) {
1690 if (opt->type != FIO_OPT_STR_STORE)
1693 ptr = (void *) o + opt->off1;
1696 *ptr = strdup(*ptr);
1706 * dupe FIO_OPT_STR_STORE options
1708 void options_mem_dupe(struct thread_data *td)
1710 __options_mem(td, 1);
1713 void options_mem_free(struct thread_data fio_unused *td)
1716 __options_mem(td, 0);
1720 unsigned int fio_get_kb_base(void *data)
1722 struct thread_data *td = data;
1723 unsigned int kb_base = 0;
1726 kb_base = td->o.kb_base;