Merge branch 'master' into gfio
[fio.git] / options.c
... / ...
CommitLineData
1#include <stdio.h>
2#include <stdlib.h>
3#include <unistd.h>
4#include <ctype.h>
5#include <string.h>
6#include <assert.h>
7#include <libgen.h>
8#include <fcntl.h>
9#include <sys/types.h>
10#include <sys/stat.h>
11
12#include "fio.h"
13#include "verify.h"
14#include "parse.h"
15#include "lib/fls.h"
16#include "options.h"
17
18#include "crc/crc32c.h"
19
20/*
21 * Check if mmap/mmaphuge has a :/foo/bar/file at the end. If so, return that.
22 */
23static char *get_opt_postfix(const char *str)
24{
25 char *p = strstr(str, ":");
26
27 if (!p)
28 return NULL;
29
30 p++;
31 strip_blank_front(&p);
32 strip_blank_end(p);
33 return strdup(p);
34}
35
36static int converthexchartoint(char a)
37{
38 int base;
39
40 switch (a) {
41 case '0'...'9':
42 base = '0';
43 break;
44 case 'A'...'F':
45 base = 'A' - 10;
46 break;
47 case 'a'...'f':
48 base = 'a' - 10;
49 break;
50 default:
51 base = 0;
52 }
53 return a - base;
54}
55
56static int bs_cmp(const void *p1, const void *p2)
57{
58 const struct bssplit *bsp1 = p1;
59 const struct bssplit *bsp2 = p2;
60
61 return bsp1->perc < bsp2->perc;
62}
63
64static int bssplit_ddir(struct thread_options *o, int ddir, char *str)
65{
66 struct bssplit *bssplit;
67 unsigned int i, perc, perc_missing;
68 unsigned int max_bs, min_bs;
69 long long val;
70 char *fname;
71
72 o->bssplit_nr[ddir] = 4;
73 bssplit = malloc(4 * sizeof(struct bssplit));
74
75 i = 0;
76 max_bs = 0;
77 min_bs = -1;
78 while ((fname = strsep(&str, ":")) != NULL) {
79 char *perc_str;
80
81 if (!strlen(fname))
82 break;
83
84 /*
85 * grow struct buffer, if needed
86 */
87 if (i == o->bssplit_nr[ddir]) {
88 o->bssplit_nr[ddir] <<= 1;
89 bssplit = realloc(bssplit, o->bssplit_nr[ddir]
90 * sizeof(struct bssplit));
91 }
92
93 perc_str = strstr(fname, "/");
94 if (perc_str) {
95 *perc_str = '\0';
96 perc_str++;
97 perc = atoi(perc_str);
98 if (perc > 100)
99 perc = 100;
100 else if (!perc)
101 perc = -1;
102 } else
103 perc = -1;
104
105 if (str_to_decimal(fname, &val, 1, o)) {
106 log_err("fio: bssplit conversion failed\n");
107 free(o->bssplit);
108 return 1;
109 }
110
111 if (val > max_bs)
112 max_bs = val;
113 if (val < min_bs)
114 min_bs = val;
115
116 bssplit[i].bs = val;
117 bssplit[i].perc = perc;
118 i++;
119 }
120
121 o->bssplit_nr[ddir] = i;
122
123 /*
124 * Now check if the percentages add up, and how much is missing
125 */
126 perc = perc_missing = 0;
127 for (i = 0; i < o->bssplit_nr[ddir]; i++) {
128 struct bssplit *bsp = &bssplit[i];
129
130 if (bsp->perc == (unsigned char) -1)
131 perc_missing++;
132 else
133 perc += bsp->perc;
134 }
135
136 if (perc > 100) {
137 log_err("fio: bssplit percentages add to more than 100%%\n");
138 free(bssplit);
139 return 1;
140 }
141 /*
142 * If values didn't have a percentage set, divide the remains between
143 * them.
144 */
145 if (perc_missing) {
146 for (i = 0; i < o->bssplit_nr[ddir]; i++) {
147 struct bssplit *bsp = &bssplit[i];
148
149 if (bsp->perc == (unsigned char) -1)
150 bsp->perc = (100 - perc) / perc_missing;
151 }
152 }
153
154 o->min_bs[ddir] = min_bs;
155 o->max_bs[ddir] = max_bs;
156
157 /*
158 * now sort based on percentages, for ease of lookup
159 */
160 qsort(bssplit, o->bssplit_nr[ddir], sizeof(struct bssplit), bs_cmp);
161 o->bssplit[ddir] = bssplit;
162 return 0;
163}
164
165static int str_bssplit_cb(void *data, const char *input)
166{
167 struct thread_data *td = data;
168 char *str, *p, *odir, *ddir;
169 int ret = 0;
170
171 p = str = strdup(input);
172
173 strip_blank_front(&str);
174 strip_blank_end(str);
175
176 odir = strchr(str, ',');
177 if (odir) {
178 ddir = strchr(odir + 1, ',');
179 if (ddir) {
180 ret = bssplit_ddir(&td->o, DDIR_TRIM, ddir + 1);
181 if (!ret)
182 *ddir = '\0';
183 } else {
184 char *op;
185
186 op = strdup(odir + 1);
187 ret = bssplit_ddir(&td->o, DDIR_TRIM, op);
188
189 free(op);
190 }
191 if (!ret)
192 ret = bssplit_ddir(&td->o, DDIR_WRITE, odir + 1);
193 if (!ret) {
194 *odir = '\0';
195 ret = bssplit_ddir(&td->o, DDIR_READ, str);
196 }
197 } else {
198 char *op;
199
200 op = strdup(str);
201 ret = bssplit_ddir(&td->o, DDIR_WRITE, op);
202 free(op);
203
204 if (!ret) {
205 op = strdup(str);
206 ret = bssplit_ddir(&td->o, DDIR_TRIM, op);
207 free(op);
208 }
209 ret = bssplit_ddir(&td->o, DDIR_READ, str);
210 }
211
212 free(p);
213 return ret;
214}
215
216static int str2error(char *str)
217{
218 const char *err[] = { "EPERM", "ENOENT", "ESRCH", "EINTR", "EIO",
219 "ENXIO", "E2BIG", "ENOEXEC", "EBADF",
220 "ECHILD", "EAGAIN", "ENOMEM", "EACCES",
221 "EFAULT", "ENOTBLK", "EBUSY", "EEXIST",
222 "EXDEV", "ENODEV", "ENOTDIR", "EISDIR",
223 "EINVAL", "ENFILE", "EMFILE", "ENOTTY",
224 "ETXTBSY","EFBIG", "ENOSPC", "ESPIPE",
225 "EROFS","EMLINK", "EPIPE", "EDOM", "ERANGE" };
226 int i = 0, num = sizeof(err) / sizeof(void *);
227
228 while (i < num) {
229 if (!strcmp(err[i], str))
230 return i + 1;
231 i++;
232 }
233 return 0;
234}
235
236static int ignore_error_type(struct thread_data *td, int etype, char *str)
237{
238 unsigned int i;
239 int *error;
240 char *fname;
241
242 if (etype >= ERROR_TYPE_CNT) {
243 log_err("Illegal error type\n");
244 return 1;
245 }
246
247 td->o.ignore_error_nr[etype] = 4;
248 error = malloc(4 * sizeof(struct bssplit));
249
250 i = 0;
251 while ((fname = strsep(&str, ":")) != NULL) {
252
253 if (!strlen(fname))
254 break;
255
256 /*
257 * grow struct buffer, if needed
258 */
259 if (i == td->o.ignore_error_nr[etype]) {
260 td->o.ignore_error_nr[etype] <<= 1;
261 error = realloc(error, td->o.ignore_error_nr[etype]
262 * sizeof(int));
263 }
264 if (fname[0] == 'E') {
265 error[i] = str2error(fname);
266 } else {
267 error[i] = atoi(fname);
268 if (error[i] < 0)
269 error[i] = error[i];
270 }
271 if (!error[i]) {
272 log_err("Unknown error %s, please use number value \n",
273 fname);
274 return 1;
275 }
276 i++;
277 }
278 if (i) {
279 td->o.continue_on_error |= 1 << etype;
280 td->o.ignore_error_nr[etype] = i;
281 td->o.ignore_error[etype] = error;
282 }
283 return 0;
284
285}
286
287static int str_ignore_error_cb(void *data, const char *input)
288{
289 struct thread_data *td = data;
290 char *str, *p, *n;
291 int type = 0, ret = 1;
292 p = str = strdup(input);
293
294 strip_blank_front(&str);
295 strip_blank_end(str);
296
297 while (p) {
298 n = strchr(p, ',');
299 if (n)
300 *n++ = '\0';
301 ret = ignore_error_type(td, type, p);
302 if (ret)
303 break;
304 p = n;
305 type++;
306 }
307 free(str);
308 return ret;
309}
310
311static int str_rw_cb(void *data, const char *str)
312{
313 struct thread_data *td = data;
314 struct thread_options *o = &td->o;
315 char *nr = get_opt_postfix(str);
316
317 o->ddir_seq_nr = 1;
318 o->ddir_seq_add = 0;
319
320 if (!nr)
321 return 0;
322
323 if (td_random(td))
324 o->ddir_seq_nr = atoi(nr);
325 else {
326 long long val;
327
328 if (str_to_decimal(nr, &val, 1, o)) {
329 log_err("fio: rw postfix parsing failed\n");
330 free(nr);
331 return 1;
332 }
333
334 o->ddir_seq_add = val;
335 }
336
337 free(nr);
338 return 0;
339}
340
341static int str_mem_cb(void *data, const char *mem)
342{
343 struct thread_data *td = data;
344
345 if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP)
346 td->o.mmapfile = get_opt_postfix(mem);
347
348 return 0;
349}
350
351static int fio_clock_source_cb(void *data, const char *str)
352{
353 struct thread_data *td = data;
354
355 fio_clock_source = td->o.clocksource;
356 fio_clock_source_set = 1;
357 fio_clock_init();
358 return 0;
359}
360
361static int str_rwmix_read_cb(void *data, unsigned long long *val)
362{
363 struct thread_data *td = data;
364
365 td->o.rwmix[DDIR_READ] = *val;
366 td->o.rwmix[DDIR_WRITE] = 100 - *val;
367 return 0;
368}
369
370static int str_rwmix_write_cb(void *data, unsigned long long *val)
371{
372 struct thread_data *td = data;
373
374 td->o.rwmix[DDIR_WRITE] = *val;
375 td->o.rwmix[DDIR_READ] = 100 - *val;
376 return 0;
377}
378
379static int str_exitall_cb(void)
380{
381 exitall_on_terminate = 1;
382 return 0;
383}
384
385#ifdef FIO_HAVE_CPU_AFFINITY
386static int str_cpumask_cb(void *data, unsigned long long *val)
387{
388 struct thread_data *td = data;
389 unsigned int i;
390 long max_cpu;
391 int ret;
392
393 ret = fio_cpuset_init(&td->o.cpumask);
394 if (ret < 0) {
395 log_err("fio: cpuset_init failed\n");
396 td_verror(td, ret, "fio_cpuset_init");
397 return 1;
398 }
399
400 max_cpu = cpus_online();
401
402 for (i = 0; i < sizeof(int) * 8; i++) {
403 if ((1 << i) & *val) {
404 if (i > max_cpu) {
405 log_err("fio: CPU %d too large (max=%ld)\n", i,
406 max_cpu);
407 return 1;
408 }
409 dprint(FD_PARSE, "set cpu allowed %d\n", i);
410 fio_cpu_set(&td->o.cpumask, i);
411 }
412 }
413
414 td->o.cpumask_set = 1;
415 return 0;
416}
417
418static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask,
419 const char *input)
420{
421 char *cpu, *str, *p;
422 long max_cpu;
423 int ret = 0;
424
425 ret = fio_cpuset_init(mask);
426 if (ret < 0) {
427 log_err("fio: cpuset_init failed\n");
428 td_verror(td, ret, "fio_cpuset_init");
429 return 1;
430 }
431
432 p = str = strdup(input);
433
434 strip_blank_front(&str);
435 strip_blank_end(str);
436
437 max_cpu = cpus_online();
438
439 while ((cpu = strsep(&str, ",")) != NULL) {
440 char *str2, *cpu2;
441 int icpu, icpu2;
442
443 if (!strlen(cpu))
444 break;
445
446 str2 = cpu;
447 icpu2 = -1;
448 while ((cpu2 = strsep(&str2, "-")) != NULL) {
449 if (!strlen(cpu2))
450 break;
451
452 icpu2 = atoi(cpu2);
453 }
454
455 icpu = atoi(cpu);
456 if (icpu2 == -1)
457 icpu2 = icpu;
458 while (icpu <= icpu2) {
459 if (icpu >= FIO_MAX_CPUS) {
460 log_err("fio: your OS only supports up to"
461 " %d CPUs\n", (int) FIO_MAX_CPUS);
462 ret = 1;
463 break;
464 }
465 if (icpu > max_cpu) {
466 log_err("fio: CPU %d too large (max=%ld)\n",
467 icpu, max_cpu);
468 ret = 1;
469 break;
470 }
471
472 dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
473 fio_cpu_set(mask, icpu);
474 icpu++;
475 }
476 if (ret)
477 break;
478 }
479
480 free(p);
481 if (!ret)
482 td->o.cpumask_set = 1;
483 return ret;
484}
485
486static int str_cpus_allowed_cb(void *data, const char *input)
487{
488 struct thread_data *td = data;
489 int ret;
490
491 ret = set_cpus_allowed(td, &td->o.cpumask, input);
492 if (!ret)
493 td->o.cpumask_set = 1;
494
495 return ret;
496}
497
498static int str_verify_cpus_allowed_cb(void *data, const char *input)
499{
500 struct thread_data *td = data;
501 int ret;
502
503 ret = set_cpus_allowed(td, &td->o.verify_cpumask, input);
504 if (!ret)
505 td->o.verify_cpumask_set = 1;
506
507 return ret;
508}
509#endif
510
511#ifdef CONFIG_LIBNUMA
512static int str_numa_cpunodes_cb(void *data, char *input)
513{
514 struct thread_data *td = data;
515
516 /* numa_parse_nodestring() parses a character string list
517 * of nodes into a bit mask. The bit mask is allocated by
518 * numa_allocate_nodemask(), so it should be freed by
519 * numa_free_nodemask().
520 */
521 td->o.numa_cpunodesmask = numa_parse_nodestring(input);
522 if (td->o.numa_cpunodesmask == NULL) {
523 log_err("fio: numa_parse_nodestring failed\n");
524 td_verror(td, 1, "str_numa_cpunodes_cb");
525 return 1;
526 }
527
528 td->o.numa_cpumask_set = 1;
529 return 0;
530}
531
532static int str_numa_mpol_cb(void *data, char *input)
533{
534 struct thread_data *td = data;
535 const char * const policy_types[] =
536 { "default", "prefer", "bind", "interleave", "local" };
537 int i;
538
539 char *nodelist = strchr(input, ':');
540 if (nodelist) {
541 /* NUL-terminate mode */
542 *nodelist++ = '\0';
543 }
544
545 for (i = 0; i <= MPOL_LOCAL; i++) {
546 if (!strcmp(input, policy_types[i])) {
547 td->o.numa_mem_mode = i;
548 break;
549 }
550 }
551 if (i > MPOL_LOCAL) {
552 log_err("fio: memory policy should be: default, prefer, bind, interleave, local\n");
553 goto out;
554 }
555
556 switch (td->o.numa_mem_mode) {
557 case MPOL_PREFERRED:
558 /*
559 * Insist on a nodelist of one node only
560 */
561 if (nodelist) {
562 char *rest = nodelist;
563 while (isdigit(*rest))
564 rest++;
565 if (*rest) {
566 log_err("fio: one node only for \'prefer\'\n");
567 goto out;
568 }
569 } else {
570 log_err("fio: one node is needed for \'prefer\'\n");
571 goto out;
572 }
573 break;
574 case MPOL_INTERLEAVE:
575 /*
576 * Default to online nodes with memory if no nodelist
577 */
578 if (!nodelist)
579 nodelist = strdup("all");
580 break;
581 case MPOL_LOCAL:
582 case MPOL_DEFAULT:
583 /*
584 * Don't allow a nodelist
585 */
586 if (nodelist) {
587 log_err("fio: NO nodelist for \'local\'\n");
588 goto out;
589 }
590 break;
591 case MPOL_BIND:
592 /*
593 * Insist on a nodelist
594 */
595 if (!nodelist) {
596 log_err("fio: a nodelist is needed for \'bind\'\n");
597 goto out;
598 }
599 break;
600 }
601
602
603 /* numa_parse_nodestring() parses a character string list
604 * of nodes into a bit mask. The bit mask is allocated by
605 * numa_allocate_nodemask(), so it should be freed by
606 * numa_free_nodemask().
607 */
608 switch (td->o.numa_mem_mode) {
609 case MPOL_PREFERRED:
610 td->o.numa_mem_prefer_node = atoi(nodelist);
611 break;
612 case MPOL_INTERLEAVE:
613 case MPOL_BIND:
614 td->o.numa_memnodesmask = numa_parse_nodestring(nodelist);
615 if (td->o.numa_memnodesmask == NULL) {
616 log_err("fio: numa_parse_nodestring failed\n");
617 td_verror(td, 1, "str_numa_memnodes_cb");
618 return 1;
619 }
620 break;
621 case MPOL_LOCAL:
622 case MPOL_DEFAULT:
623 default:
624 break;
625 }
626
627 td->o.numa_memmask_set = 1;
628 return 0;
629
630out:
631 return 1;
632}
633#endif
634
635static int str_fst_cb(void *data, const char *str)
636{
637 struct thread_data *td = data;
638 char *nr = get_opt_postfix(str);
639
640 td->file_service_nr = 1;
641 if (nr) {
642 td->file_service_nr = atoi(nr);
643 free(nr);
644 }
645
646 return 0;
647}
648
649#ifdef CONFIG_SYNC_FILE_RANGE
650static int str_sfr_cb(void *data, const char *str)
651{
652 struct thread_data *td = data;
653 char *nr = get_opt_postfix(str);
654
655 td->sync_file_range_nr = 1;
656 if (nr) {
657 td->sync_file_range_nr = atoi(nr);
658 free(nr);
659 }
660
661 return 0;
662}
663#endif
664
665static int str_random_distribution_cb(void *data, const char *str)
666{
667 struct thread_data *td = data;
668 double val;
669 char *nr;
670
671 if (td->o.random_distribution == FIO_RAND_DIST_ZIPF)
672 val = 1.1;
673 else if (td->o.random_distribution == FIO_RAND_DIST_PARETO)
674 val = 0.2;
675 else
676 return 0;
677
678 nr = get_opt_postfix(str);
679 if (nr && !str_to_float(nr, &val)) {
680 log_err("fio: random postfix parsing failed\n");
681 free(nr);
682 return 1;
683 }
684
685 free(nr);
686
687 if (td->o.random_distribution == FIO_RAND_DIST_ZIPF) {
688 if (val == 1.00) {
689 log_err("fio: zipf theta must different than 1.0\n");
690 return 1;
691 }
692 td->o.zipf_theta.u.f = val;
693 } else {
694 if (val <= 0.00 || val >= 1.00) {
695 log_err("fio: pareto input out of range (0 < input < 1.0)\n");
696 return 1;
697 }
698 td->o.pareto_h.u.f = val;
699 }
700
701 return 0;
702}
703
704/*
705 * Return next file in the string. Files are separated with ':'. If the ':'
706 * is escaped with a '\', then that ':' is part of the filename and does not
707 * indicate a new file.
708 */
709static char *get_next_file_name(char **ptr)
710{
711 char *str = *ptr;
712 char *p, *start;
713
714 if (!str || !strlen(str))
715 return NULL;
716
717 start = str;
718 do {
719 /*
720 * No colon, we are done
721 */
722 p = strchr(str, ':');
723 if (!p) {
724 *ptr = NULL;
725 break;
726 }
727
728 /*
729 * We got a colon, but it's the first character. Skip and
730 * continue
731 */
732 if (p == start) {
733 str = ++start;
734 continue;
735 }
736
737 if (*(p - 1) != '\\') {
738 *p = '\0';
739 *ptr = p + 1;
740 break;
741 }
742
743 memmove(p - 1, p, strlen(p) + 1);
744 str = p;
745 } while (1);
746
747 return start;
748}
749
750static int str_filename_cb(void *data, const char *input)
751{
752 struct thread_data *td = data;
753 char *fname, *str, *p;
754
755 p = str = strdup(input);
756
757 strip_blank_front(&str);
758 strip_blank_end(str);
759
760 if (!td->files_index)
761 td->o.nr_files = 0;
762
763 while ((fname = get_next_file_name(&str)) != NULL) {
764 if (!strlen(fname))
765 break;
766 add_file(td, fname);
767 td->o.nr_files++;
768 }
769
770 free(p);
771 return 0;
772}
773
774static int str_directory_cb(void *data, const char fio_unused *str)
775{
776 struct thread_data *td = data;
777 struct stat sb;
778
779 if (lstat(td->o.directory, &sb) < 0) {
780 int ret = errno;
781
782 log_err("fio: %s is not a directory\n", td->o.directory);
783 td_verror(td, ret, "lstat");
784 return 1;
785 }
786 if (!S_ISDIR(sb.st_mode)) {
787 log_err("fio: %s is not a directory\n", td->o.directory);
788 return 1;
789 }
790
791 return 0;
792}
793
794static int str_opendir_cb(void *data, const char fio_unused *str)
795{
796 struct thread_data *td = data;
797
798 if (!td->files_index)
799 td->o.nr_files = 0;
800
801 return add_dir_files(td, td->o.opendir);
802}
803
804static int str_verify_pattern_cb(void *data, const char *input)
805{
806 struct thread_data *td = data;
807 long off;
808 int i = 0, j = 0, len, k, base = 10;
809 char *loc1, *loc2;
810
811 loc1 = strstr(input, "0x");
812 loc2 = strstr(input, "0X");
813 if (loc1 || loc2)
814 base = 16;
815 off = strtol(input, NULL, base);
816 if (off != LONG_MAX || errno != ERANGE) {
817 while (off) {
818 td->o.verify_pattern[i] = off & 0xff;
819 off >>= 8;
820 i++;
821 }
822 } else {
823 len = strlen(input);
824 k = len - 1;
825 if (base == 16) {
826 if (loc1)
827 j = loc1 - input + 2;
828 else
829 j = loc2 - input + 2;
830 } else
831 return 1;
832 if (len - j < MAX_PATTERN_SIZE * 2) {
833 while (k >= j) {
834 off = converthexchartoint(input[k--]);
835 if (k >= j)
836 off += (converthexchartoint(input[k--])
837 * 16);
838 td->o.verify_pattern[i++] = (char) off;
839 }
840 }
841 }
842
843 /*
844 * Fill the pattern all the way to the end. This greatly reduces
845 * the number of memcpy's we have to do when verifying the IO.
846 */
847 while (i > 1 && i * 2 <= MAX_PATTERN_SIZE) {
848 memcpy(&td->o.verify_pattern[i], &td->o.verify_pattern[0], i);
849 i *= 2;
850 }
851 if (i == 1) {
852 /*
853 * The code in verify_io_u_pattern assumes a single byte pattern
854 * fills the whole verify pattern buffer.
855 */
856 memset(td->o.verify_pattern, td->o.verify_pattern[0],
857 MAX_PATTERN_SIZE);
858 }
859
860 td->o.verify_pattern_bytes = i;
861
862 /*
863 * VERIFY_META could already be set
864 */
865 if (td->o.verify == VERIFY_NONE)
866 td->o.verify = VERIFY_PATTERN;
867
868 return 0;
869}
870
871static int str_lockfile_cb(void *data, const char *str)
872{
873 struct thread_data *td = data;
874 char *nr = get_opt_postfix(str);
875
876 td->o.lockfile_batch = 1;
877 if (nr) {
878 td->o.lockfile_batch = atoi(nr);
879 free(nr);
880 }
881
882 return 0;
883}
884
885static int str_gtod_reduce_cb(void *data, int *il)
886{
887 struct thread_data *td = data;
888 int val = *il;
889
890 td->o.disable_lat = !!val;
891 td->o.disable_clat = !!val;
892 td->o.disable_slat = !!val;
893 td->o.disable_bw = !!val;
894 td->o.clat_percentiles = !val;
895 if (val)
896 td->tv_cache_mask = 63;
897
898 return 0;
899}
900
901static int str_gtod_cpu_cb(void *data, long long *il)
902{
903 struct thread_data *td = data;
904 int val = *il;
905
906 td->o.gtod_cpu = val;
907 td->o.gtod_offload = 1;
908 return 0;
909}
910
911static int str_size_cb(void *data, unsigned long long *__val)
912{
913 struct thread_data *td = data;
914 unsigned long long v = *__val;
915
916 if (parse_is_percent(v)) {
917 td->o.size = 0;
918 td->o.size_percent = -1ULL - v;
919 } else
920 td->o.size = v;
921
922 return 0;
923}
924
925static int rw_verify(struct fio_option *o, void *data)
926{
927 struct thread_data *td = data;
928
929 if (read_only && td_write(td)) {
930 log_err("fio: job <%s> has write bit set, but fio is in"
931 " read-only mode\n", td->o.name);
932 return 1;
933 }
934
935 return 0;
936}
937
938static int gtod_cpu_verify(struct fio_option *o, void *data)
939{
940#ifndef FIO_HAVE_CPU_AFFINITY
941 struct thread_data *td = data;
942
943 if (td->o.gtod_cpu) {
944 log_err("fio: platform must support CPU affinity for"
945 "gettimeofday() offloading\n");
946 return 1;
947 }
948#endif
949
950 return 0;
951}
952
953static int kb_base_verify(struct fio_option *o, void *data)
954{
955 struct thread_data *td = data;
956
957 if (td->o.kb_base != 1024 && td->o.kb_base != 1000) {
958 log_err("fio: kb_base set to nonsensical value: %u\n",
959 td->o.kb_base);
960 return 1;
961 }
962
963 return 0;
964}
965
966/*
967 * Option grouping
968 */
969static struct opt_group fio_opt_groups[] = {
970 {
971 .name = "General",
972 .mask = FIO_OPT_C_GENERAL,
973 },
974 {
975 .name = "I/O",
976 .mask = FIO_OPT_C_IO,
977 },
978 {
979 .name = "File",
980 .mask = FIO_OPT_C_FILE,
981 },
982 {
983 .name = "Statistics",
984 .mask = FIO_OPT_C_STAT,
985 },
986 {
987 .name = "Logging",
988 .mask = FIO_OPT_C_LOG,
989 },
990 {
991 .name = "Profiles",
992 .mask = FIO_OPT_C_PROFILE,
993 },
994 {
995 .name = NULL,
996 },
997};
998
999static struct opt_group *__opt_group_from_mask(struct opt_group *ogs, unsigned int *mask,
1000 unsigned int inv_mask)
1001{
1002 struct opt_group *og;
1003 int i;
1004
1005 if (*mask == inv_mask || !*mask)
1006 return NULL;
1007
1008 for (i = 0; ogs[i].name; i++) {
1009 og = &ogs[i];
1010
1011 if (*mask & og->mask) {
1012 *mask &= ~(og->mask);
1013 return og;
1014 }
1015 }
1016
1017 return NULL;
1018}
1019
1020struct opt_group *opt_group_from_mask(unsigned int *mask)
1021{
1022 return __opt_group_from_mask(fio_opt_groups, mask, FIO_OPT_C_INVALID);
1023}
1024
1025static struct opt_group fio_opt_cat_groups[] = {
1026 {
1027 .name = "Rate",
1028 .mask = FIO_OPT_G_RATE,
1029 },
1030 {
1031 .name = "Zone",
1032 .mask = FIO_OPT_G_ZONE,
1033 },
1034 {
1035 .name = "Read/write mix",
1036 .mask = FIO_OPT_G_RWMIX,
1037 },
1038 {
1039 .name = "Verify",
1040 .mask = FIO_OPT_G_VERIFY,
1041 },
1042 {
1043 .name = "Trim",
1044 .mask = FIO_OPT_G_TRIM,
1045 },
1046 {
1047 .name = "I/O Logging",
1048 .mask = FIO_OPT_G_IOLOG,
1049 },
1050 {
1051 .name = "I/O Depth",
1052 .mask = FIO_OPT_G_IO_DEPTH,
1053 },
1054 {
1055 .name = "I/O Flow",
1056 .mask = FIO_OPT_G_IO_FLOW,
1057 },
1058 {
1059 .name = "Description",
1060 .mask = FIO_OPT_G_DESC,
1061 },
1062 {
1063 .name = "Filename",
1064 .mask = FIO_OPT_G_FILENAME,
1065 },
1066 {
1067 .name = "General I/O",
1068 .mask = FIO_OPT_G_IO_BASIC,
1069 },
1070 {
1071 .name = "Cgroups",
1072 .mask = FIO_OPT_G_CGROUP,
1073 },
1074 {
1075 .name = "Runtime",
1076 .mask = FIO_OPT_G_RUNTIME,
1077 },
1078 {
1079 .name = "Process",
1080 .mask = FIO_OPT_G_PROCESS,
1081 },
1082 {
1083 .name = "Job credentials / priority",
1084 .mask = FIO_OPT_G_CRED,
1085 },
1086 {
1087 .name = "Clock settings",
1088 .mask = FIO_OPT_G_CLOCK,
1089 },
1090 {
1091 .name = "I/O Type",
1092 .mask = FIO_OPT_G_IO_TYPE,
1093 },
1094 {
1095 .name = "I/O Thinktime",
1096 .mask = FIO_OPT_G_THINKTIME,
1097 },
1098 {
1099 .name = "Randomizations",
1100 .mask = FIO_OPT_G_RANDOM,
1101 },
1102 {
1103 .name = "I/O buffers",
1104 .mask = FIO_OPT_G_IO_BUF,
1105 },
1106 {
1107 .name = "Tiobench profile",
1108 .mask = FIO_OPT_G_TIOBENCH,
1109 },
1110
1111 {
1112 .name = NULL,
1113 }
1114};
1115
1116struct opt_group *opt_group_cat_from_mask(unsigned int *mask)
1117{
1118 return __opt_group_from_mask(fio_opt_cat_groups, mask, FIO_OPT_G_INVALID);
1119}
1120
1121/*
1122 * Map of job/command line options
1123 */
1124struct fio_option fio_options[FIO_MAX_OPTS] = {
1125 {
1126 .name = "description",
1127 .lname = "Description of job",
1128 .type = FIO_OPT_STR_STORE,
1129 .off1 = td_var_offset(description),
1130 .help = "Text job description",
1131 .category = FIO_OPT_C_GENERAL,
1132 .group = FIO_OPT_G_DESC,
1133 },
1134 {
1135 .name = "name",
1136 .lname = "Job name",
1137 .type = FIO_OPT_STR_STORE,
1138 .off1 = td_var_offset(name),
1139 .help = "Name of this job",
1140 .category = FIO_OPT_C_GENERAL,
1141 .group = FIO_OPT_G_DESC,
1142 },
1143 {
1144 .name = "filename",
1145 .lname = "Filename(s)",
1146 .type = FIO_OPT_STR_STORE,
1147 .off1 = td_var_offset(filename),
1148 .cb = str_filename_cb,
1149 .prio = -1, /* must come after "directory" */
1150 .help = "File(s) to use for the workload",
1151 .category = FIO_OPT_C_FILE,
1152 .group = FIO_OPT_G_FILENAME,
1153 },
1154 {
1155 .name = "directory",
1156 .lname = "Directory",
1157 .type = FIO_OPT_STR_STORE,
1158 .off1 = td_var_offset(directory),
1159 .cb = str_directory_cb,
1160 .help = "Directory to store files in",
1161 .category = FIO_OPT_C_FILE,
1162 .group = FIO_OPT_G_FILENAME,
1163 },
1164 {
1165 .name = "lockfile",
1166 .lname = "Lockfile",
1167 .type = FIO_OPT_STR,
1168 .cb = str_lockfile_cb,
1169 .off1 = td_var_offset(file_lock_mode),
1170 .help = "Lock file when doing IO to it",
1171 .parent = "filename",
1172 .hide = 0,
1173 .def = "none",
1174 .category = FIO_OPT_C_FILE,
1175 .group = FIO_OPT_G_FILENAME,
1176 .posval = {
1177 { .ival = "none",
1178 .oval = FILE_LOCK_NONE,
1179 .help = "No file locking",
1180 },
1181 { .ival = "exclusive",
1182 .oval = FILE_LOCK_EXCLUSIVE,
1183 .help = "Exclusive file lock",
1184 },
1185 {
1186 .ival = "readwrite",
1187 .oval = FILE_LOCK_READWRITE,
1188 .help = "Read vs write lock",
1189 },
1190 },
1191 },
1192 {
1193 .name = "opendir",
1194 .lname = "Open directory",
1195 .type = FIO_OPT_STR_STORE,
1196 .off1 = td_var_offset(opendir),
1197 .cb = str_opendir_cb,
1198 .help = "Recursively add files from this directory and down",
1199 .category = FIO_OPT_C_FILE,
1200 .group = FIO_OPT_G_FILENAME,
1201 },
1202 {
1203 .name = "rw",
1204 .lname = "Read/write",
1205 .alias = "readwrite",
1206 .type = FIO_OPT_STR,
1207 .cb = str_rw_cb,
1208 .off1 = td_var_offset(td_ddir),
1209 .help = "IO direction",
1210 .def = "read",
1211 .verify = rw_verify,
1212 .category = FIO_OPT_C_IO,
1213 .group = FIO_OPT_G_IO_BASIC,
1214 .posval = {
1215 { .ival = "read",
1216 .oval = TD_DDIR_READ,
1217 .help = "Sequential read",
1218 },
1219 { .ival = "write",
1220 .oval = TD_DDIR_WRITE,
1221 .help = "Sequential write",
1222 },
1223 { .ival = "trim",
1224 .oval = TD_DDIR_TRIM,
1225 .help = "Sequential trim",
1226 },
1227 { .ival = "randread",
1228 .oval = TD_DDIR_RANDREAD,
1229 .help = "Random read",
1230 },
1231 { .ival = "randwrite",
1232 .oval = TD_DDIR_RANDWRITE,
1233 .help = "Random write",
1234 },
1235 { .ival = "randtrim",
1236 .oval = TD_DDIR_RANDTRIM,
1237 .help = "Random trim",
1238 },
1239 { .ival = "rw",
1240 .oval = TD_DDIR_RW,
1241 .help = "Sequential read and write mix",
1242 },
1243 { .ival = "readwrite",
1244 .oval = TD_DDIR_RW,
1245 .help = "Sequential read and write mix",
1246 },
1247 { .ival = "randrw",
1248 .oval = TD_DDIR_RANDRW,
1249 .help = "Random read and write mix"
1250 },
1251 },
1252 },
1253 {
1254 .name = "rw_sequencer",
1255 .lname = "RW Sequencer",
1256 .type = FIO_OPT_STR,
1257 .off1 = td_var_offset(rw_seq),
1258 .help = "IO offset generator modifier",
1259 .def = "sequential",
1260 .category = FIO_OPT_C_IO,
1261 .group = FIO_OPT_G_IO_BASIC,
1262 .posval = {
1263 { .ival = "sequential",
1264 .oval = RW_SEQ_SEQ,
1265 .help = "Generate sequential offsets",
1266 },
1267 { .ival = "identical",
1268 .oval = RW_SEQ_IDENT,
1269 .help = "Generate identical offsets",
1270 },
1271 },
1272 },
1273
1274 {
1275 .name = "ioengine",
1276 .lname = "IO Engine",
1277 .type = FIO_OPT_STR_STORE,
1278 .off1 = td_var_offset(ioengine),
1279 .help = "IO engine to use",
1280 .def = FIO_PREFERRED_ENGINE,
1281 .category = FIO_OPT_C_IO,
1282 .group = FIO_OPT_G_IO_BASIC,
1283 .posval = {
1284 { .ival = "sync",
1285 .help = "Use read/write",
1286 },
1287 { .ival = "psync",
1288 .help = "Use pread/pwrite",
1289 },
1290 { .ival = "vsync",
1291 .help = "Use readv/writev",
1292 },
1293#ifdef CONFIG_LIBAIO
1294 { .ival = "libaio",
1295 .help = "Linux native asynchronous IO",
1296 },
1297#endif
1298#ifdef CONFIG_POSIXAIO
1299 { .ival = "posixaio",
1300 .help = "POSIX asynchronous IO",
1301 },
1302#endif
1303#ifdef CONFIG_SOLARISAIO
1304 { .ival = "solarisaio",
1305 .help = "Solaris native asynchronous IO",
1306 },
1307#endif
1308#ifdef CONFIG_WINDOWSAIO
1309 { .ival = "windowsaio",
1310 .help = "Windows native asynchronous IO"
1311 },
1312#endif
1313 { .ival = "mmap",
1314 .help = "Memory mapped IO"
1315 },
1316#ifdef CONFIG_LINUX_SPLICE
1317 { .ival = "splice",
1318 .help = "splice/vmsplice based IO",
1319 },
1320 { .ival = "netsplice",
1321 .help = "splice/vmsplice to/from the network",
1322 },
1323#endif
1324#ifdef FIO_HAVE_SGIO
1325 { .ival = "sg",
1326 .help = "SCSI generic v3 IO",
1327 },
1328#endif
1329 { .ival = "null",
1330 .help = "Testing engine (no data transfer)",
1331 },
1332 { .ival = "net",
1333 .help = "Network IO",
1334 },
1335 { .ival = "cpuio",
1336 .help = "CPU cycle burner engine",
1337 },
1338#ifdef CONFIG_GUASI
1339 { .ival = "guasi",
1340 .help = "GUASI IO engine",
1341 },
1342#endif
1343#ifdef FIO_HAVE_BINJECT
1344 { .ival = "binject",
1345 .help = "binject direct inject block engine",
1346 },
1347#endif
1348#ifdef CONFIG_RDMA
1349 { .ival = "rdma",
1350 .help = "RDMA IO engine",
1351 },
1352#endif
1353#ifdef CONFIG_FUSION_AW
1354 { .ival = "fusion-aw-sync",
1355 .help = "Fusion-io atomic write engine",
1356 },
1357#endif
1358#ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
1359 { .ival = "e4defrag",
1360 .help = "ext4 defrag engine",
1361 },
1362#endif
1363#ifdef CONFIG_LINUX_FALLOCATE
1364 { .ival = "falloc",
1365 .help = "fallocate() file based engine",
1366 },
1367#endif
1368 { .ival = "external",
1369 .help = "Load external engine (append name)",
1370 },
1371 },
1372 },
1373 {
1374 .name = "iodepth",
1375 .lname = "IO Depth",
1376 .type = FIO_OPT_INT,
1377 .off1 = td_var_offset(iodepth),
1378 .help = "Number of IO buffers to keep in flight",
1379 .minval = 1,
1380 .interval = 1,
1381 .def = "1",
1382 .category = FIO_OPT_C_IO,
1383 .group = FIO_OPT_G_IO_BASIC,
1384 },
1385 {
1386 .name = "iodepth_batch",
1387 .lname = "IO Depth batch",
1388 .alias = "iodepth_batch_submit",
1389 .type = FIO_OPT_INT,
1390 .off1 = td_var_offset(iodepth_batch),
1391 .help = "Number of IO buffers to submit in one go",
1392 .parent = "iodepth",
1393 .hide = 1,
1394 .minval = 1,
1395 .interval = 1,
1396 .def = "1",
1397 .category = FIO_OPT_C_IO,
1398 .group = FIO_OPT_G_IO_BASIC,
1399 },
1400 {
1401 .name = "iodepth_batch_complete",
1402 .lname = "IO Depth batch complete",
1403 .type = FIO_OPT_INT,
1404 .off1 = td_var_offset(iodepth_batch_complete),
1405 .help = "Number of IO buffers to retrieve in one go",
1406 .parent = "iodepth",
1407 .hide = 1,
1408 .minval = 0,
1409 .interval = 1,
1410 .def = "1",
1411 .category = FIO_OPT_C_IO,
1412 .group = FIO_OPT_G_IO_BASIC,
1413 },
1414 {
1415 .name = "iodepth_low",
1416 .lname = "IO Depth batch low",
1417 .type = FIO_OPT_INT,
1418 .off1 = td_var_offset(iodepth_low),
1419 .help = "Low water mark for queuing depth",
1420 .parent = "iodepth",
1421 .hide = 1,
1422 .interval = 1,
1423 .category = FIO_OPT_C_IO,
1424 .group = FIO_OPT_G_IO_BASIC,
1425 },
1426 {
1427 .name = "size",
1428 .lname = "Size",
1429 .type = FIO_OPT_STR_VAL,
1430 .cb = str_size_cb,
1431 .help = "Total size of device or files",
1432 .interval = 1024 * 1024,
1433 .category = FIO_OPT_C_IO,
1434 .group = FIO_OPT_G_INVALID,
1435 },
1436 {
1437 .name = "fill_device",
1438 .lname = "Fill device",
1439 .alias = "fill_fs",
1440 .type = FIO_OPT_BOOL,
1441 .off1 = td_var_offset(fill_device),
1442 .help = "Write until an ENOSPC error occurs",
1443 .def = "0",
1444 .category = FIO_OPT_C_FILE,
1445 .group = FIO_OPT_G_INVALID,
1446 },
1447 {
1448 .name = "filesize",
1449 .lname = "File size",
1450 .type = FIO_OPT_STR_VAL,
1451 .off1 = td_var_offset(file_size_low),
1452 .off2 = td_var_offset(file_size_high),
1453 .minval = 1,
1454 .help = "Size of individual files",
1455 .interval = 1024 * 1024,
1456 .category = FIO_OPT_C_FILE,
1457 .group = FIO_OPT_G_INVALID,
1458 },
1459 {
1460 .name = "offset",
1461 .lname = "IO offset",
1462 .alias = "fileoffset",
1463 .type = FIO_OPT_STR_VAL,
1464 .off1 = td_var_offset(start_offset),
1465 .help = "Start IO from this offset",
1466 .def = "0",
1467 .interval = 1024 * 1024,
1468 .category = FIO_OPT_C_IO,
1469 .group = FIO_OPT_G_INVALID,
1470 },
1471 {
1472 .name = "offset_increment",
1473 .lname = "IO offset increment",
1474 .type = FIO_OPT_STR_VAL,
1475 .off1 = td_var_offset(offset_increment),
1476 .help = "What is the increment from one offset to the next",
1477 .parent = "offset",
1478 .hide = 1,
1479 .def = "0",
1480 .interval = 1024 * 1024,
1481 .category = FIO_OPT_C_IO,
1482 .group = FIO_OPT_G_INVALID,
1483 },
1484 {
1485 .name = "bs",
1486 .lname = "Block size",
1487 .alias = "blocksize",
1488 .type = FIO_OPT_INT,
1489 .off1 = td_var_offset(bs[DDIR_READ]),
1490 .off2 = td_var_offset(bs[DDIR_WRITE]),
1491 .off3 = td_var_offset(bs[DDIR_TRIM]),
1492 .minval = 1,
1493 .help = "Block size unit",
1494 .def = "4k",
1495 .parent = "rw",
1496 .hide = 1,
1497 .interval = 512,
1498 .category = FIO_OPT_C_IO,
1499 .group = FIO_OPT_G_INVALID,
1500 },
1501 {
1502 .name = "ba",
1503 .lname = "Block size align",
1504 .alias = "blockalign",
1505 .type = FIO_OPT_INT,
1506 .off1 = td_var_offset(ba[DDIR_READ]),
1507 .off2 = td_var_offset(ba[DDIR_WRITE]),
1508 .off3 = td_var_offset(ba[DDIR_TRIM]),
1509 .minval = 1,
1510 .help = "IO block offset alignment",
1511 .parent = "rw",
1512 .hide = 1,
1513 .interval = 512,
1514 .category = FIO_OPT_C_IO,
1515 .group = FIO_OPT_G_INVALID,
1516 },
1517 {
1518 .name = "bsrange",
1519 .lname = "Block size range",
1520 .alias = "blocksize_range",
1521 .type = FIO_OPT_RANGE,
1522 .off1 = td_var_offset(min_bs[DDIR_READ]),
1523 .off2 = td_var_offset(max_bs[DDIR_READ]),
1524 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
1525 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
1526 .off5 = td_var_offset(min_bs[DDIR_TRIM]),
1527 .off6 = td_var_offset(max_bs[DDIR_TRIM]),
1528 .minval = 1,
1529 .help = "Set block size range (in more detail than bs)",
1530 .parent = "rw",
1531 .hide = 1,
1532 .interval = 4096,
1533 .category = FIO_OPT_C_IO,
1534 .group = FIO_OPT_G_INVALID,
1535 },
1536 {
1537 .name = "bssplit",
1538 .lname = "Block size split",
1539 .type = FIO_OPT_STR,
1540 .cb = str_bssplit_cb,
1541 .help = "Set a specific mix of block sizes",
1542 .parent = "rw",
1543 .hide = 1,
1544 .category = FIO_OPT_C_IO,
1545 .group = FIO_OPT_G_INVALID,
1546 },
1547 {
1548 .name = "bs_unaligned",
1549 .lname = "Block size unaligned",
1550 .alias = "blocksize_unaligned",
1551 .type = FIO_OPT_STR_SET,
1552 .off1 = td_var_offset(bs_unaligned),
1553 .help = "Don't sector align IO buffer sizes",
1554 .parent = "rw",
1555 .hide = 1,
1556 .category = FIO_OPT_C_IO,
1557 .group = FIO_OPT_G_INVALID,
1558 },
1559 {
1560 .name = "randrepeat",
1561 .lname = "Random repeatable",
1562 .type = FIO_OPT_BOOL,
1563 .off1 = td_var_offset(rand_repeatable),
1564 .help = "Use repeatable random IO pattern",
1565 .def = "1",
1566 .parent = "rw",
1567 .hide = 1,
1568 .category = FIO_OPT_C_IO,
1569 .group = FIO_OPT_G_RANDOM,
1570 },
1571 {
1572 .name = "use_os_rand",
1573 .lname = "Use OS random",
1574 .type = FIO_OPT_BOOL,
1575 .off1 = td_var_offset(use_os_rand),
1576 .help = "Set to use OS random generator",
1577 .def = "0",
1578 .parent = "rw",
1579 .hide = 1,
1580 .category = FIO_OPT_C_IO,
1581 .group = FIO_OPT_G_RANDOM,
1582 },
1583 {
1584 .name = "norandommap",
1585 .lname = "No randommap",
1586 .type = FIO_OPT_STR_SET,
1587 .off1 = td_var_offset(norandommap),
1588 .help = "Accept potential duplicate random blocks",
1589 .parent = "rw",
1590 .hide = 1,
1591 .hide_on_set = 1,
1592 .category = FIO_OPT_C_IO,
1593 .group = FIO_OPT_G_RANDOM,
1594 },
1595 {
1596 .name = "softrandommap",
1597 .lname = "Soft randommap",
1598 .type = FIO_OPT_BOOL,
1599 .off1 = td_var_offset(softrandommap),
1600 .help = "Set norandommap if randommap allocation fails",
1601 .parent = "norandommap",
1602 .hide = 1,
1603 .def = "0",
1604 .category = FIO_OPT_C_IO,
1605 .group = FIO_OPT_G_RANDOM,
1606 },
1607 {
1608 .name = "random_generator",
1609 .type = FIO_OPT_STR,
1610 .off1 = td_var_offset(random_generator),
1611 .help = "Type of random number generator to use",
1612 .def = "tausworthe",
1613 .posval = {
1614 { .ival = "tausworthe",
1615 .oval = FIO_RAND_GEN_TAUSWORTHE,
1616 .help = "Strong Tausworthe generator",
1617 },
1618 { .ival = "lfsr",
1619 .oval = FIO_RAND_GEN_LFSR,
1620 .help = "Variable length LFSR",
1621 },
1622 },
1623 .category = FIO_OPT_C_IO,
1624 .group = FIO_OPT_G_RANDOM,
1625 },
1626 {
1627 .name = "random_distribution",
1628 .type = FIO_OPT_STR,
1629 .off1 = td_var_offset(random_distribution),
1630 .cb = str_random_distribution_cb,
1631 .help = "Random offset distribution generator",
1632 .def = "random",
1633 .posval = {
1634 { .ival = "random",
1635 .oval = FIO_RAND_DIST_RANDOM,
1636 .help = "Completely random",
1637 },
1638 { .ival = "zipf",
1639 .oval = FIO_RAND_DIST_ZIPF,
1640 .help = "Zipf distribution",
1641 },
1642 { .ival = "pareto",
1643 .oval = FIO_RAND_DIST_PARETO,
1644 .help = "Pareto distribution",
1645 },
1646 },
1647 .category = FIO_OPT_C_IO,
1648 .group = FIO_OPT_G_RANDOM,
1649 },
1650 {
1651 .name = "nrfiles",
1652 .lname = "Number of files",
1653 .alias = "nr_files",
1654 .type = FIO_OPT_INT,
1655 .off1 = td_var_offset(nr_files),
1656 .help = "Split job workload between this number of files",
1657 .def = "1",
1658 .interval = 1,
1659 .category = FIO_OPT_C_FILE,
1660 .group = FIO_OPT_G_INVALID,
1661 },
1662 {
1663 .name = "openfiles",
1664 .lname = "Number of open files",
1665 .type = FIO_OPT_INT,
1666 .off1 = td_var_offset(open_files),
1667 .help = "Number of files to keep open at the same time",
1668 .category = FIO_OPT_C_FILE,
1669 .group = FIO_OPT_G_INVALID,
1670 },
1671 {
1672 .name = "file_service_type",
1673 .lname = "File service type",
1674 .type = FIO_OPT_STR,
1675 .cb = str_fst_cb,
1676 .off1 = td_var_offset(file_service_type),
1677 .help = "How to select which file to service next",
1678 .def = "roundrobin",
1679 .category = FIO_OPT_C_FILE,
1680 .group = FIO_OPT_G_INVALID,
1681 .posval = {
1682 { .ival = "random",
1683 .oval = FIO_FSERVICE_RANDOM,
1684 .help = "Choose a file at random",
1685 },
1686 { .ival = "roundrobin",
1687 .oval = FIO_FSERVICE_RR,
1688 .help = "Round robin select files",
1689 },
1690 { .ival = "sequential",
1691 .oval = FIO_FSERVICE_SEQ,
1692 .help = "Finish one file before moving to the next",
1693 },
1694 },
1695 .parent = "nrfiles",
1696 .hide = 1,
1697 },
1698#ifdef CONFIG_POSIX_FALLOCATE
1699 {
1700 .name = "fallocate",
1701 .lname = "Fallocate",
1702 .type = FIO_OPT_STR,
1703 .off1 = td_var_offset(fallocate_mode),
1704 .help = "Whether pre-allocation is performed when laying out files",
1705 .def = "posix",
1706 .category = FIO_OPT_C_FILE,
1707 .group = FIO_OPT_G_INVALID,
1708 .posval = {
1709 { .ival = "none",
1710 .oval = FIO_FALLOCATE_NONE,
1711 .help = "Do not pre-allocate space",
1712 },
1713 { .ival = "posix",
1714 .oval = FIO_FALLOCATE_POSIX,
1715 .help = "Use posix_fallocate()",
1716 },
1717#ifdef CONFIG_LINUX_FALLOCATE
1718 { .ival = "keep",
1719 .oval = FIO_FALLOCATE_KEEP_SIZE,
1720 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
1721 },
1722#endif
1723 /* Compatibility with former boolean values */
1724 { .ival = "0",
1725 .oval = FIO_FALLOCATE_NONE,
1726 .help = "Alias for 'none'",
1727 },
1728 { .ival = "1",
1729 .oval = FIO_FALLOCATE_POSIX,
1730 .help = "Alias for 'posix'",
1731 },
1732 },
1733 },
1734#endif /* CONFIG_POSIX_FALLOCATE */
1735 {
1736 .name = "fadvise_hint",
1737 .lname = "Fadvise hint",
1738 .type = FIO_OPT_BOOL,
1739 .off1 = td_var_offset(fadvise_hint),
1740 .help = "Use fadvise() to advise the kernel on IO pattern",
1741 .def = "1",
1742 .category = FIO_OPT_C_FILE,
1743 .group = FIO_OPT_G_INVALID,
1744 },
1745 {
1746 .name = "fsync",
1747 .lname = "Fsync",
1748 .type = FIO_OPT_INT,
1749 .off1 = td_var_offset(fsync_blocks),
1750 .help = "Issue fsync for writes every given number of blocks",
1751 .def = "0",
1752 .interval = 1,
1753 .category = FIO_OPT_C_FILE,
1754 .group = FIO_OPT_G_INVALID,
1755 },
1756 {
1757 .name = "fdatasync",
1758 .lname = "Fdatasync",
1759 .type = FIO_OPT_INT,
1760 .off1 = td_var_offset(fdatasync_blocks),
1761 .help = "Issue fdatasync for writes every given number of blocks",
1762 .def = "0",
1763 .interval = 1,
1764 .category = FIO_OPT_C_FILE,
1765 .group = FIO_OPT_G_INVALID,
1766 },
1767 {
1768 .name = "write_barrier",
1769 .lname = "Write barrier",
1770 .type = FIO_OPT_INT,
1771 .off1 = td_var_offset(barrier_blocks),
1772 .help = "Make every Nth write a barrier write",
1773 .def = "0",
1774 .interval = 1,
1775 .category = FIO_OPT_C_IO,
1776 .group = FIO_OPT_G_INVALID,
1777 },
1778#ifdef CONFIG_SYNC_FILE_RANGE
1779 {
1780 .name = "sync_file_range",
1781 .lname = "Sync file range",
1782 .posval = {
1783 { .ival = "wait_before",
1784 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
1785 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
1786 .or = 1,
1787 },
1788 { .ival = "write",
1789 .oval = SYNC_FILE_RANGE_WRITE,
1790 .help = "SYNC_FILE_RANGE_WRITE",
1791 .or = 1,
1792 },
1793 {
1794 .ival = "wait_after",
1795 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
1796 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
1797 .or = 1,
1798 },
1799 },
1800 .type = FIO_OPT_STR_MULTI,
1801 .cb = str_sfr_cb,
1802 .off1 = td_var_offset(sync_file_range),
1803 .help = "Use sync_file_range()",
1804 .category = FIO_OPT_C_FILE,
1805 .group = FIO_OPT_G_INVALID,
1806 },
1807#endif
1808 {
1809 .name = "direct",
1810 .lname = "Direct I/O",
1811 .type = FIO_OPT_BOOL,
1812 .off1 = td_var_offset(odirect),
1813 .help = "Use O_DIRECT IO (negates buffered)",
1814 .def = "0",
1815 .inverse = "buffered",
1816 .category = FIO_OPT_C_IO,
1817 .group = FIO_OPT_G_IO_TYPE,
1818 },
1819 {
1820 .name = "buffered",
1821 .lname = "Buffered I/O",
1822 .type = FIO_OPT_BOOL,
1823 .off1 = td_var_offset(odirect),
1824 .neg = 1,
1825 .help = "Use buffered IO (negates direct)",
1826 .def = "1",
1827 .inverse = "direct",
1828 .category = FIO_OPT_C_IO,
1829 .group = FIO_OPT_G_IO_TYPE,
1830 },
1831 {
1832 .name = "overwrite",
1833 .lname = "Overwrite",
1834 .type = FIO_OPT_BOOL,
1835 .off1 = td_var_offset(overwrite),
1836 .help = "When writing, set whether to overwrite current data",
1837 .def = "0",
1838 .category = FIO_OPT_C_FILE,
1839 .group = FIO_OPT_G_INVALID,
1840 },
1841 {
1842 .name = "loops",
1843 .lname = "Loops",
1844 .type = FIO_OPT_INT,
1845 .off1 = td_var_offset(loops),
1846 .help = "Number of times to run the job",
1847 .def = "1",
1848 .interval = 1,
1849 .category = FIO_OPT_C_GENERAL,
1850 .group = FIO_OPT_G_RUNTIME,
1851 },
1852 {
1853 .name = "numjobs",
1854 .lname = "Number of jobs",
1855 .type = FIO_OPT_INT,
1856 .off1 = td_var_offset(numjobs),
1857 .help = "Duplicate this job this many times",
1858 .def = "1",
1859 .interval = 1,
1860 .category = FIO_OPT_C_GENERAL,
1861 .group = FIO_OPT_G_RUNTIME,
1862 },
1863 {
1864 .name = "startdelay",
1865 .lname = "Start delay",
1866 .type = FIO_OPT_STR_VAL_TIME,
1867 .off1 = td_var_offset(start_delay),
1868 .help = "Only start job when this period has passed",
1869 .def = "0",
1870 .category = FIO_OPT_C_GENERAL,
1871 .group = FIO_OPT_G_RUNTIME,
1872 },
1873 {
1874 .name = "runtime",
1875 .lname = "Runtime",
1876 .alias = "timeout",
1877 .type = FIO_OPT_STR_VAL_TIME,
1878 .off1 = td_var_offset(timeout),
1879 .help = "Stop workload when this amount of time has passed",
1880 .def = "0",
1881 .category = FIO_OPT_C_GENERAL,
1882 .group = FIO_OPT_G_RUNTIME,
1883 },
1884 {
1885 .name = "time_based",
1886 .lname = "Time based",
1887 .type = FIO_OPT_STR_SET,
1888 .off1 = td_var_offset(time_based),
1889 .help = "Keep running until runtime/timeout is met",
1890 .category = FIO_OPT_C_GENERAL,
1891 .group = FIO_OPT_G_RUNTIME,
1892 },
1893 {
1894 .name = "ramp_time",
1895 .lname = "Ramp time",
1896 .type = FIO_OPT_STR_VAL_TIME,
1897 .off1 = td_var_offset(ramp_time),
1898 .help = "Ramp up time before measuring performance",
1899 .category = FIO_OPT_C_GENERAL,
1900 .group = FIO_OPT_G_RUNTIME,
1901 },
1902 {
1903 .name = "clocksource",
1904 .lname = "Clock source",
1905 .type = FIO_OPT_STR,
1906 .cb = fio_clock_source_cb,
1907 .off1 = td_var_offset(clocksource),
1908 .help = "What type of timing source to use",
1909 .category = FIO_OPT_C_GENERAL,
1910 .group = FIO_OPT_G_CLOCK,
1911 .posval = {
1912#ifdef CONFIG_GETTIMEOFDAY
1913 { .ival = "gettimeofday",
1914 .oval = CS_GTOD,
1915 .help = "Use gettimeofday(2) for timing",
1916 },
1917#endif
1918#ifdef CONFIG_CLOCK_GETTIME
1919 { .ival = "clock_gettime",
1920 .oval = CS_CGETTIME,
1921 .help = "Use clock_gettime(2) for timing",
1922 },
1923#endif
1924#ifdef ARCH_HAVE_CPU_CLOCK
1925 { .ival = "cpu",
1926 .oval = CS_CPUCLOCK,
1927 .help = "Use CPU private clock",
1928 },
1929#endif
1930 },
1931 },
1932 {
1933 .name = "mem",
1934 .alias = "iomem",
1935 .lname = "I/O Memory",
1936 .type = FIO_OPT_STR,
1937 .cb = str_mem_cb,
1938 .off1 = td_var_offset(mem_type),
1939 .help = "Backing type for IO buffers",
1940 .def = "malloc",
1941 .category = FIO_OPT_C_IO,
1942 .group = FIO_OPT_G_INVALID,
1943 .posval = {
1944 { .ival = "malloc",
1945 .oval = MEM_MALLOC,
1946 .help = "Use malloc(3) for IO buffers",
1947 },
1948 { .ival = "shm",
1949 .oval = MEM_SHM,
1950 .help = "Use shared memory segments for IO buffers",
1951 },
1952#ifdef FIO_HAVE_HUGETLB
1953 { .ival = "shmhuge",
1954 .oval = MEM_SHMHUGE,
1955 .help = "Like shm, but use huge pages",
1956 },
1957#endif
1958 { .ival = "mmap",
1959 .oval = MEM_MMAP,
1960 .help = "Use mmap(2) (file or anon) for IO buffers",
1961 },
1962#ifdef FIO_HAVE_HUGETLB
1963 { .ival = "mmaphuge",
1964 .oval = MEM_MMAPHUGE,
1965 .help = "Like mmap, but use huge pages",
1966 },
1967#endif
1968 },
1969 },
1970 {
1971 .name = "iomem_align",
1972 .alias = "mem_align",
1973 .lname = "I/O memory alignment",
1974 .type = FIO_OPT_INT,
1975 .off1 = td_var_offset(mem_align),
1976 .minval = 0,
1977 .help = "IO memory buffer offset alignment",
1978 .def = "0",
1979 .parent = "iomem",
1980 .hide = 1,
1981 .category = FIO_OPT_C_IO,
1982 .group = FIO_OPT_G_INVALID,
1983 },
1984 {
1985 .name = "verify",
1986 .lname = "Verify",
1987 .type = FIO_OPT_STR,
1988 .off1 = td_var_offset(verify),
1989 .help = "Verify data written",
1990 .def = "0",
1991 .category = FIO_OPT_C_IO,
1992 .group = FIO_OPT_G_VERIFY,
1993 .posval = {
1994 { .ival = "0",
1995 .oval = VERIFY_NONE,
1996 .help = "Don't do IO verification",
1997 },
1998 { .ival = "md5",
1999 .oval = VERIFY_MD5,
2000 .help = "Use md5 checksums for verification",
2001 },
2002 { .ival = "crc64",
2003 .oval = VERIFY_CRC64,
2004 .help = "Use crc64 checksums for verification",
2005 },
2006 { .ival = "crc32",
2007 .oval = VERIFY_CRC32,
2008 .help = "Use crc32 checksums for verification",
2009 },
2010 { .ival = "crc32c-intel",
2011 .oval = VERIFY_CRC32C,
2012 .help = "Use crc32c checksums for verification (hw assisted, if available)",
2013 },
2014 { .ival = "crc32c",
2015 .oval = VERIFY_CRC32C,
2016 .help = "Use crc32c checksums for verification (hw assisted, if available)",
2017 },
2018 { .ival = "crc16",
2019 .oval = VERIFY_CRC16,
2020 .help = "Use crc16 checksums for verification",
2021 },
2022 { .ival = "crc7",
2023 .oval = VERIFY_CRC7,
2024 .help = "Use crc7 checksums for verification",
2025 },
2026 { .ival = "sha1",
2027 .oval = VERIFY_SHA1,
2028 .help = "Use sha1 checksums for verification",
2029 },
2030 { .ival = "sha256",
2031 .oval = VERIFY_SHA256,
2032 .help = "Use sha256 checksums for verification",
2033 },
2034 { .ival = "sha512",
2035 .oval = VERIFY_SHA512,
2036 .help = "Use sha512 checksums for verification",
2037 },
2038 { .ival = "meta",
2039 .oval = VERIFY_META,
2040 .help = "Use io information",
2041 },
2042 {
2043 .ival = "null",
2044 .oval = VERIFY_NULL,
2045 .help = "Pretend to verify",
2046 },
2047 },
2048 },
2049 {
2050 .name = "do_verify",
2051 .lname = "Perform verify step",
2052 .type = FIO_OPT_BOOL,
2053 .off1 = td_var_offset(do_verify),
2054 .help = "Run verification stage after write",
2055 .def = "1",
2056 .parent = "verify",
2057 .hide = 1,
2058 .category = FIO_OPT_C_IO,
2059 .group = FIO_OPT_G_VERIFY,
2060 },
2061 {
2062 .name = "verifysort",
2063 .lname = "Verify sort",
2064 .type = FIO_OPT_BOOL,
2065 .off1 = td_var_offset(verifysort),
2066 .help = "Sort written verify blocks for read back",
2067 .def = "1",
2068 .parent = "verify",
2069 .hide = 1,
2070 .category = FIO_OPT_C_IO,
2071 .group = FIO_OPT_G_VERIFY,
2072 },
2073 {
2074 .name = "verifysort_nr",
2075 .type = FIO_OPT_INT,
2076 .off1 = td_var_offset(verifysort_nr),
2077 .help = "Pre-load and sort verify blocks for a read workload",
2078 .minval = 0,
2079 .maxval = 131072,
2080 .def = "1024",
2081 .parent = "verify",
2082 .category = FIO_OPT_C_IO,
2083 .group = FIO_OPT_G_VERIFY,
2084 },
2085 {
2086 .name = "verify_interval",
2087 .lname = "Verify interval",
2088 .type = FIO_OPT_INT,
2089 .off1 = td_var_offset(verify_interval),
2090 .minval = 2 * sizeof(struct verify_header),
2091 .help = "Store verify buffer header every N bytes",
2092 .parent = "verify",
2093 .hide = 1,
2094 .interval = 2 * sizeof(struct verify_header),
2095 .category = FIO_OPT_C_IO,
2096 .group = FIO_OPT_G_VERIFY,
2097 },
2098 {
2099 .name = "verify_offset",
2100 .lname = "Verify offset",
2101 .type = FIO_OPT_INT,
2102 .help = "Offset verify header location by N bytes",
2103 .off1 = td_var_offset(verify_offset),
2104 .minval = sizeof(struct verify_header),
2105 .parent = "verify",
2106 .hide = 1,
2107 .category = FIO_OPT_C_IO,
2108 .group = FIO_OPT_G_VERIFY,
2109 },
2110 {
2111 .name = "verify_pattern",
2112 .lname = "Verify pattern",
2113 .type = FIO_OPT_STR,
2114 .cb = str_verify_pattern_cb,
2115 .help = "Fill pattern for IO buffers",
2116 .parent = "verify",
2117 .hide = 1,
2118 .category = FIO_OPT_C_IO,
2119 .group = FIO_OPT_G_VERIFY,
2120 },
2121 {
2122 .name = "verify_fatal",
2123 .lname = "Verify fatal",
2124 .type = FIO_OPT_BOOL,
2125 .off1 = td_var_offset(verify_fatal),
2126 .def = "0",
2127 .help = "Exit on a single verify failure, don't continue",
2128 .parent = "verify",
2129 .hide = 1,
2130 .category = FIO_OPT_C_IO,
2131 .group = FIO_OPT_G_VERIFY,
2132 },
2133 {
2134 .name = "verify_dump",
2135 .lname = "Verify dump",
2136 .type = FIO_OPT_BOOL,
2137 .off1 = td_var_offset(verify_dump),
2138 .def = "0",
2139 .help = "Dump contents of good and bad blocks on failure",
2140 .parent = "verify",
2141 .hide = 1,
2142 .category = FIO_OPT_C_IO,
2143 .group = FIO_OPT_G_VERIFY,
2144 },
2145 {
2146 .name = "verify_async",
2147 .lname = "Verify asynchronously",
2148 .type = FIO_OPT_INT,
2149 .off1 = td_var_offset(verify_async),
2150 .def = "0",
2151 .help = "Number of async verifier threads to use",
2152 .parent = "verify",
2153 .hide = 1,
2154 .category = FIO_OPT_C_IO,
2155 .group = FIO_OPT_G_VERIFY,
2156 },
2157 {
2158 .name = "verify_backlog",
2159 .lname = "Verify backlog",
2160 .type = FIO_OPT_STR_VAL,
2161 .off1 = td_var_offset(verify_backlog),
2162 .help = "Verify after this number of blocks are written",
2163 .parent = "verify",
2164 .hide = 1,
2165 .category = FIO_OPT_C_IO,
2166 .group = FIO_OPT_G_VERIFY,
2167 },
2168 {
2169 .name = "verify_backlog_batch",
2170 .lname = "Verify backlog batch",
2171 .type = FIO_OPT_INT,
2172 .off1 = td_var_offset(verify_batch),
2173 .help = "Verify this number of IO blocks",
2174 .parent = "verify",
2175 .hide = 1,
2176 .category = FIO_OPT_C_IO,
2177 .group = FIO_OPT_G_VERIFY,
2178 },
2179#ifdef FIO_HAVE_CPU_AFFINITY
2180 {
2181 .name = "verify_async_cpus",
2182 .lname = "Async verify CPUs",
2183 .type = FIO_OPT_STR,
2184 .cb = str_verify_cpus_allowed_cb,
2185 .help = "Set CPUs allowed for async verify threads",
2186 .parent = "verify_async",
2187 .hide = 1,
2188 .category = FIO_OPT_C_IO,
2189 .group = FIO_OPT_G_VERIFY,
2190 },
2191#endif
2192 {
2193 .name = "experimental_verify",
2194 .off1 = td_var_offset(experimental_verify),
2195 .type = FIO_OPT_BOOL,
2196 .help = "Enable experimental verification",
2197 .category = FIO_OPT_C_IO,
2198 .group = FIO_OPT_G_VERIFY,
2199 },
2200#ifdef FIO_HAVE_TRIM
2201 {
2202 .name = "trim_percentage",
2203 .lname = "Trim percentage",
2204 .type = FIO_OPT_INT,
2205 .off1 = td_var_offset(trim_percentage),
2206 .minval = 0,
2207 .maxval = 100,
2208 .help = "Number of verify blocks to discard/trim",
2209 .parent = "verify",
2210 .def = "0",
2211 .interval = 1,
2212 .hide = 1,
2213 .category = FIO_OPT_C_IO,
2214 .group = FIO_OPT_G_TRIM,
2215 },
2216 {
2217 .name = "trim_verify_zero",
2218 .lname = "Verify trim zero",
2219 .type = FIO_OPT_BOOL,
2220 .help = "Verify that trim/discarded blocks are returned as zeroes",
2221 .off1 = td_var_offset(trim_zero),
2222 .parent = "trim_percentage",
2223 .hide = 1,
2224 .def = "1",
2225 .category = FIO_OPT_C_IO,
2226 .group = FIO_OPT_G_TRIM,
2227 },
2228 {
2229 .name = "trim_backlog",
2230 .lname = "Trim backlog",
2231 .type = FIO_OPT_STR_VAL,
2232 .off1 = td_var_offset(trim_backlog),
2233 .help = "Trim after this number of blocks are written",
2234 .parent = "trim_percentage",
2235 .hide = 1,
2236 .interval = 1,
2237 .category = FIO_OPT_C_IO,
2238 .group = FIO_OPT_G_TRIM,
2239 },
2240 {
2241 .name = "trim_backlog_batch",
2242 .lname = "Trim backlog batch",
2243 .type = FIO_OPT_INT,
2244 .off1 = td_var_offset(trim_batch),
2245 .help = "Trim this number of IO blocks",
2246 .parent = "trim_percentage",
2247 .hide = 1,
2248 .interval = 1,
2249 .category = FIO_OPT_C_IO,
2250 .group = FIO_OPT_G_TRIM,
2251 },
2252#endif
2253 {
2254 .name = "write_iolog",
2255 .lname = "Write I/O log",
2256 .type = FIO_OPT_STR_STORE,
2257 .off1 = td_var_offset(write_iolog_file),
2258 .help = "Store IO pattern to file",
2259 .category = FIO_OPT_C_IO,
2260 .group = FIO_OPT_G_IOLOG,
2261 },
2262 {
2263 .name = "read_iolog",
2264 .lname = "Read I/O log",
2265 .type = FIO_OPT_STR_STORE,
2266 .off1 = td_var_offset(read_iolog_file),
2267 .help = "Playback IO pattern from file",
2268 .category = FIO_OPT_C_IO,
2269 .group = FIO_OPT_G_IOLOG,
2270 },
2271 {
2272 .name = "replay_no_stall",
2273 .lname = "Don't stall on replay",
2274 .type = FIO_OPT_BOOL,
2275 .off1 = td_var_offset(no_stall),
2276 .def = "0",
2277 .parent = "read_iolog",
2278 .hide = 1,
2279 .help = "Playback IO pattern file as fast as possible without stalls",
2280 .category = FIO_OPT_C_IO,
2281 .group = FIO_OPT_G_IOLOG,
2282 },
2283 {
2284 .name = "replay_redirect",
2285 .lname = "Redirect device for replay",
2286 .type = FIO_OPT_STR_STORE,
2287 .off1 = td_var_offset(replay_redirect),
2288 .parent = "read_iolog",
2289 .hide = 1,
2290 .help = "Replay all I/O onto this device, regardless of trace device",
2291 .category = FIO_OPT_C_IO,
2292 .group = FIO_OPT_G_IOLOG,
2293 },
2294 {
2295 .name = "exec_prerun",
2296 .lname = "Pre-execute runnable",
2297 .type = FIO_OPT_STR_STORE,
2298 .off1 = td_var_offset(exec_prerun),
2299 .help = "Execute this file prior to running job",
2300 .category = FIO_OPT_C_GENERAL,
2301 .group = FIO_OPT_G_INVALID,
2302 },
2303 {
2304 .name = "exec_postrun",
2305 .lname = "Post-execute runnable",
2306 .type = FIO_OPT_STR_STORE,
2307 .off1 = td_var_offset(exec_postrun),
2308 .help = "Execute this file after running job",
2309 .category = FIO_OPT_C_GENERAL,
2310 .group = FIO_OPT_G_INVALID,
2311 },
2312#ifdef FIO_HAVE_IOSCHED_SWITCH
2313 {
2314 .name = "ioscheduler",
2315 .lname = "I/O scheduler",
2316 .type = FIO_OPT_STR_STORE,
2317 .off1 = td_var_offset(ioscheduler),
2318 .help = "Use this IO scheduler on the backing device",
2319 .category = FIO_OPT_C_FILE,
2320 .group = FIO_OPT_G_INVALID,
2321 },
2322#endif
2323 {
2324 .name = "zonesize",
2325 .lname = "Zone size",
2326 .type = FIO_OPT_STR_VAL,
2327 .off1 = td_var_offset(zone_size),
2328 .help = "Amount of data to read per zone",
2329 .def = "0",
2330 .interval = 1024 * 1024,
2331 .category = FIO_OPT_C_IO,
2332 .group = FIO_OPT_G_ZONE,
2333 },
2334 {
2335 .name = "zonerange",
2336 .lname = "Zone range",
2337 .type = FIO_OPT_STR_VAL,
2338 .off1 = td_var_offset(zone_range),
2339 .help = "Give size of an IO zone",
2340 .def = "0",
2341 .interval = 1024 * 1024,
2342 .category = FIO_OPT_C_IO,
2343 .group = FIO_OPT_G_ZONE,
2344 },
2345 {
2346 .name = "zoneskip",
2347 .lname = "Zone skip",
2348 .type = FIO_OPT_STR_VAL,
2349 .off1 = td_var_offset(zone_skip),
2350 .help = "Space between IO zones",
2351 .def = "0",
2352 .interval = 1024 * 1024,
2353 .category = FIO_OPT_C_IO,
2354 .group = FIO_OPT_G_ZONE,
2355 },
2356 {
2357 .name = "lockmem",
2358 .lname = "Lock memory",
2359 .type = FIO_OPT_STR_VAL,
2360 .off1 = td_var_offset(lockmem),
2361 .help = "Lock down this amount of memory",
2362 .def = "0",
2363 .interval = 1024 * 1024,
2364 .category = FIO_OPT_C_GENERAL,
2365 .group = FIO_OPT_G_INVALID,
2366 },
2367 {
2368 .name = "rwmixread",
2369 .lname = "Read/write mix read",
2370 .type = FIO_OPT_INT,
2371 .cb = str_rwmix_read_cb,
2372 .maxval = 100,
2373 .help = "Percentage of mixed workload that is reads",
2374 .def = "50",
2375 .interval = 5,
2376 .inverse = "rwmixwrite",
2377 .category = FIO_OPT_C_IO,
2378 .group = FIO_OPT_G_RWMIX,
2379 },
2380 {
2381 .name = "rwmixwrite",
2382 .lname = "Read/write mix write",
2383 .type = FIO_OPT_INT,
2384 .cb = str_rwmix_write_cb,
2385 .maxval = 100,
2386 .help = "Percentage of mixed workload that is writes",
2387 .def = "50",
2388 .interval = 5,
2389 .inverse = "rwmixread",
2390 .category = FIO_OPT_C_IO,
2391 .group = FIO_OPT_G_RWMIX,
2392 },
2393 {
2394 .name = "rwmixcycle",
2395 .lname = "Read/write mix cycle",
2396 .type = FIO_OPT_DEPRECATED,
2397 .category = FIO_OPT_C_IO,
2398 .group = FIO_OPT_G_RWMIX,
2399 },
2400 {
2401 .name = "nice",
2402 .lname = "Nice",
2403 .type = FIO_OPT_INT,
2404 .off1 = td_var_offset(nice),
2405 .help = "Set job CPU nice value",
2406 .minval = -19,
2407 .maxval = 20,
2408 .def = "0",
2409 .interval = 1,
2410 .category = FIO_OPT_C_GENERAL,
2411 .group = FIO_OPT_G_CRED,
2412 },
2413#ifdef FIO_HAVE_IOPRIO
2414 {
2415 .name = "prio",
2416 .lname = "I/O nice priority",
2417 .type = FIO_OPT_INT,
2418 .off1 = td_var_offset(ioprio),
2419 .help = "Set job IO priority value",
2420 .minval = 0,
2421 .maxval = 7,
2422 .interval = 1,
2423 .category = FIO_OPT_C_GENERAL,
2424 .group = FIO_OPT_G_CRED,
2425 },
2426 {
2427 .name = "prioclass",
2428 .lname = "I/O nice priority class",
2429 .type = FIO_OPT_INT,
2430 .off1 = td_var_offset(ioprio_class),
2431 .help = "Set job IO priority class",
2432 .minval = 0,
2433 .maxval = 3,
2434 .interval = 1,
2435 .category = FIO_OPT_C_GENERAL,
2436 .group = FIO_OPT_G_CRED,
2437 },
2438#endif
2439 {
2440 .name = "thinktime",
2441 .lname = "Thinktime",
2442 .type = FIO_OPT_INT,
2443 .off1 = td_var_offset(thinktime),
2444 .help = "Idle time between IO buffers (usec)",
2445 .def = "0",
2446 .category = FIO_OPT_C_IO,
2447 .group = FIO_OPT_G_THINKTIME,
2448 },
2449 {
2450 .name = "thinktime_spin",
2451 .lname = "Thinktime spin",
2452 .type = FIO_OPT_INT,
2453 .off1 = td_var_offset(thinktime_spin),
2454 .help = "Start think time by spinning this amount (usec)",
2455 .def = "0",
2456 .parent = "thinktime",
2457 .hide = 1,
2458 .category = FIO_OPT_C_IO,
2459 .group = FIO_OPT_G_THINKTIME,
2460 },
2461 {
2462 .name = "thinktime_blocks",
2463 .lname = "Thinktime blocks",
2464 .type = FIO_OPT_INT,
2465 .off1 = td_var_offset(thinktime_blocks),
2466 .help = "IO buffer period between 'thinktime'",
2467 .def = "1",
2468 .parent = "thinktime",
2469 .hide = 1,
2470 .category = FIO_OPT_C_IO,
2471 .group = FIO_OPT_G_THINKTIME,
2472 },
2473 {
2474 .name = "rate",
2475 .lname = "I/O rate",
2476 .type = FIO_OPT_INT,
2477 .off1 = td_var_offset(rate[DDIR_READ]),
2478 .off2 = td_var_offset(rate[DDIR_WRITE]),
2479 .off3 = td_var_offset(rate[DDIR_TRIM]),
2480 .help = "Set bandwidth rate",
2481 .category = FIO_OPT_C_IO,
2482 .group = FIO_OPT_G_RATE,
2483 },
2484 {
2485 .name = "ratemin",
2486 .lname = "I/O min rate",
2487 .type = FIO_OPT_INT,
2488 .off1 = td_var_offset(ratemin[DDIR_READ]),
2489 .off2 = td_var_offset(ratemin[DDIR_WRITE]),
2490 .off3 = td_var_offset(ratemin[DDIR_TRIM]),
2491 .help = "Job must meet this rate or it will be shutdown",
2492 .parent = "rate",
2493 .hide = 1,
2494 .category = FIO_OPT_C_IO,
2495 .group = FIO_OPT_G_RATE,
2496 },
2497 {
2498 .name = "rate_iops",
2499 .lname = "I/O rate IOPS",
2500 .type = FIO_OPT_INT,
2501 .off1 = td_var_offset(rate_iops[DDIR_READ]),
2502 .off2 = td_var_offset(rate_iops[DDIR_WRITE]),
2503 .off3 = td_var_offset(rate_iops[DDIR_TRIM]),
2504 .help = "Limit IO used to this number of IO operations/sec",
2505 .hide = 1,
2506 .category = FIO_OPT_C_IO,
2507 .group = FIO_OPT_G_RATE,
2508 },
2509 {
2510 .name = "rate_iops_min",
2511 .lname = "I/O min rate IOPS",
2512 .type = FIO_OPT_INT,
2513 .off1 = td_var_offset(rate_iops_min[DDIR_READ]),
2514 .off2 = td_var_offset(rate_iops_min[DDIR_WRITE]),
2515 .off3 = td_var_offset(rate_iops_min[DDIR_TRIM]),
2516 .help = "Job must meet this rate or it will be shut down",
2517 .parent = "rate_iops",
2518 .hide = 1,
2519 .category = FIO_OPT_C_IO,
2520 .group = FIO_OPT_G_RATE,
2521 },
2522 {
2523 .name = "ratecycle",
2524 .lname = "I/O rate cycle",
2525 .type = FIO_OPT_INT,
2526 .off1 = td_var_offset(ratecycle),
2527 .help = "Window average for rate limits (msec)",
2528 .def = "1000",
2529 .parent = "rate",
2530 .hide = 1,
2531 .category = FIO_OPT_C_IO,
2532 .group = FIO_OPT_G_RATE,
2533 },
2534 {
2535 .name = "max_latency",
2536 .type = FIO_OPT_INT,
2537 .off1 = td_var_offset(max_latency),
2538 .help = "Maximum tolerated IO latency (usec)",
2539 .category = FIO_OPT_C_IO,
2540 .group = FIO_OPT_G_RATE,
2541 },
2542 {
2543 .name = "invalidate",
2544 .lname = "Cache invalidate",
2545 .type = FIO_OPT_BOOL,
2546 .off1 = td_var_offset(invalidate_cache),
2547 .help = "Invalidate buffer/page cache prior to running job",
2548 .def = "1",
2549 .category = FIO_OPT_C_IO,
2550 .group = FIO_OPT_G_IO_TYPE,
2551 },
2552 {
2553 .name = "sync",
2554 .lname = "Synchronous I/O",
2555 .type = FIO_OPT_BOOL,
2556 .off1 = td_var_offset(sync_io),
2557 .help = "Use O_SYNC for buffered writes",
2558 .def = "0",
2559 .parent = "buffered",
2560 .hide = 1,
2561 .category = FIO_OPT_C_IO,
2562 .group = FIO_OPT_G_IO_TYPE,
2563 },
2564 {
2565 .name = "create_serialize",
2566 .lname = "Create serialize",
2567 .type = FIO_OPT_BOOL,
2568 .off1 = td_var_offset(create_serialize),
2569 .help = "Serialize creating of job files",
2570 .def = "1",
2571 .category = FIO_OPT_C_FILE,
2572 .group = FIO_OPT_G_INVALID,
2573 },
2574 {
2575 .name = "create_fsync",
2576 .lname = "Create fsync",
2577 .type = FIO_OPT_BOOL,
2578 .off1 = td_var_offset(create_fsync),
2579 .help = "fsync file after creation",
2580 .def = "1",
2581 .category = FIO_OPT_C_FILE,
2582 .group = FIO_OPT_G_INVALID,
2583 },
2584 {
2585 .name = "create_on_open",
2586 .lname = "Create on open",
2587 .type = FIO_OPT_BOOL,
2588 .off1 = td_var_offset(create_on_open),
2589 .help = "Create files when they are opened for IO",
2590 .def = "0",
2591 .category = FIO_OPT_C_FILE,
2592 .group = FIO_OPT_G_INVALID,
2593 },
2594 {
2595 .name = "create_only",
2596 .type = FIO_OPT_BOOL,
2597 .off1 = td_var_offset(create_only),
2598 .help = "Only perform file creation phase",
2599 .category = FIO_OPT_C_FILE,
2600 .def = "0",
2601 },
2602 {
2603 .name = "pre_read",
2604 .lname = "Pre-read files",
2605 .type = FIO_OPT_BOOL,
2606 .off1 = td_var_offset(pre_read),
2607 .help = "Pre-read files before starting official testing",
2608 .def = "0",
2609 .category = FIO_OPT_C_FILE,
2610 .group = FIO_OPT_G_INVALID,
2611 },
2612#ifdef FIO_HAVE_CPU_AFFINITY
2613 {
2614 .name = "cpumask",
2615 .lname = "CPU mask",
2616 .type = FIO_OPT_INT,
2617 .cb = str_cpumask_cb,
2618 .help = "CPU affinity mask",
2619 .category = FIO_OPT_C_GENERAL,
2620 .group = FIO_OPT_G_CRED,
2621 },
2622 {
2623 .name = "cpus_allowed",
2624 .lname = "CPUs allowed",
2625 .type = FIO_OPT_STR,
2626 .cb = str_cpus_allowed_cb,
2627 .help = "Set CPUs allowed",
2628 .category = FIO_OPT_C_GENERAL,
2629 .group = FIO_OPT_G_CRED,
2630 },
2631#endif
2632#ifdef CONFIG_LIBNUMA
2633 {
2634 .name = "numa_cpu_nodes",
2635 .type = FIO_OPT_STR,
2636 .cb = str_numa_cpunodes_cb,
2637 .help = "NUMA CPU nodes bind",
2638 },
2639 {
2640 .name = "numa_mem_policy",
2641 .type = FIO_OPT_STR,
2642 .cb = str_numa_mpol_cb,
2643 .help = "NUMA memory policy setup",
2644 },
2645#endif
2646 {
2647 .name = "end_fsync",
2648 .lname = "End fsync",
2649 .type = FIO_OPT_BOOL,
2650 .off1 = td_var_offset(end_fsync),
2651 .help = "Include fsync at the end of job",
2652 .def = "0",
2653 .category = FIO_OPT_C_FILE,
2654 .group = FIO_OPT_G_INVALID,
2655 },
2656 {
2657 .name = "fsync_on_close",
2658 .lname = "Fsync on close",
2659 .type = FIO_OPT_BOOL,
2660 .off1 = td_var_offset(fsync_on_close),
2661 .help = "fsync files on close",
2662 .def = "0",
2663 .category = FIO_OPT_C_FILE,
2664 .group = FIO_OPT_G_INVALID,
2665 },
2666 {
2667 .name = "unlink",
2668 .lname = "Unlink file",
2669 .type = FIO_OPT_BOOL,
2670 .off1 = td_var_offset(unlink),
2671 .help = "Unlink created files after job has completed",
2672 .def = "0",
2673 .category = FIO_OPT_C_FILE,
2674 .group = FIO_OPT_G_INVALID,
2675 },
2676 {
2677 .name = "exitall",
2678 .lname = "Exit-all on terminate",
2679 .type = FIO_OPT_STR_SET,
2680 .cb = str_exitall_cb,
2681 .help = "Terminate all jobs when one exits",
2682 .category = FIO_OPT_C_GENERAL,
2683 .group = FIO_OPT_G_PROCESS,
2684 },
2685 {
2686 .name = "stonewall",
2687 .lname = "Wait for previous",
2688 .alias = "wait_for_previous",
2689 .type = FIO_OPT_STR_SET,
2690 .off1 = td_var_offset(stonewall),
2691 .help = "Insert a hard barrier between this job and previous",
2692 .category = FIO_OPT_C_GENERAL,
2693 .group = FIO_OPT_G_PROCESS,
2694 },
2695 {
2696 .name = "new_group",
2697 .lname = "New group",
2698 .type = FIO_OPT_STR_SET,
2699 .off1 = td_var_offset(new_group),
2700 .help = "Mark the start of a new group (for reporting)",
2701 .category = FIO_OPT_C_GENERAL,
2702 .group = FIO_OPT_G_PROCESS,
2703 },
2704 {
2705 .name = "thread",
2706 .lname = "Thread",
2707 .type = FIO_OPT_STR_SET,
2708 .off1 = td_var_offset(use_thread),
2709 .help = "Use threads instead of processes",
2710 .category = FIO_OPT_C_GENERAL,
2711 .group = FIO_OPT_G_PROCESS,
2712 },
2713 {
2714 .name = "write_bw_log",
2715 .lname = "Write bandwidth log",
2716 .type = FIO_OPT_STR_STORE,
2717 .off1 = td_var_offset(bw_log_file),
2718 .help = "Write log of bandwidth during run",
2719 .category = FIO_OPT_C_LOG,
2720 .group = FIO_OPT_G_INVALID,
2721 },
2722 {
2723 .name = "write_lat_log",
2724 .lname = "Write latency log",
2725 .type = FIO_OPT_STR_STORE,
2726 .off1 = td_var_offset(lat_log_file),
2727 .help = "Write log of latency during run",
2728 .category = FIO_OPT_C_LOG,
2729 .group = FIO_OPT_G_INVALID,
2730 },
2731 {
2732 .name = "write_iops_log",
2733 .lname = "Write IOPS log",
2734 .type = FIO_OPT_STR,
2735 .off1 = td_var_offset(iops_log_file),
2736 .help = "Write log of IOPS during run",
2737 .category = FIO_OPT_C_LOG,
2738 .group = FIO_OPT_G_INVALID,
2739 },
2740 {
2741 .name = "log_avg_msec",
2742 .lname = "Log averaging (msec)",
2743 .type = FIO_OPT_INT,
2744 .off1 = td_var_offset(log_avg_msec),
2745 .help = "Average bw/iops/lat logs over this period of time",
2746 .def = "0",
2747 .category = FIO_OPT_C_LOG,
2748 .group = FIO_OPT_G_INVALID,
2749 },
2750 {
2751 .name = "bwavgtime",
2752 .lname = "Bandwidth average time",
2753 .type = FIO_OPT_INT,
2754 .off1 = td_var_offset(bw_avg_time),
2755 .help = "Time window over which to calculate bandwidth"
2756 " (msec)",
2757 .def = "500",
2758 .parent = "write_bw_log",
2759 .hide = 1,
2760 .interval = 100,
2761 .category = FIO_OPT_C_LOG,
2762 .group = FIO_OPT_G_INVALID,
2763 },
2764 {
2765 .name = "iopsavgtime",
2766 .lname = "IOPS average time",
2767 .type = FIO_OPT_INT,
2768 .off1 = td_var_offset(iops_avg_time),
2769 .help = "Time window over which to calculate IOPS (msec)",
2770 .def = "500",
2771 .parent = "write_iops_log",
2772 .hide = 1,
2773 .interval = 100,
2774 .category = FIO_OPT_C_LOG,
2775 .group = FIO_OPT_G_INVALID,
2776 },
2777 {
2778 .name = "group_reporting",
2779 .lname = "Group reporting",
2780 .type = FIO_OPT_BOOL,
2781 .off1 = td_var_offset(group_reporting),
2782 .help = "Do reporting on a per-group basis",
2783 .def = "1",
2784 .category = FIO_OPT_C_STAT,
2785 .group = FIO_OPT_G_INVALID,
2786 },
2787 {
2788 .name = "zero_buffers",
2789 .lname = "Zero I/O buffers",
2790 .type = FIO_OPT_STR_SET,
2791 .off1 = td_var_offset(zero_buffers),
2792 .help = "Init IO buffers to all zeroes",
2793 .category = FIO_OPT_C_IO,
2794 .group = FIO_OPT_G_IO_BUF,
2795 },
2796 {
2797 .name = "refill_buffers",
2798 .lname = "Refill I/O buffers",
2799 .type = FIO_OPT_STR_SET,
2800 .off1 = td_var_offset(refill_buffers),
2801 .help = "Refill IO buffers on every IO submit",
2802 .category = FIO_OPT_C_IO,
2803 .group = FIO_OPT_G_IO_BUF,
2804 },
2805 {
2806 .name = "scramble_buffers",
2807 .lname = "Scramble I/O buffers",
2808 .type = FIO_OPT_BOOL,
2809 .off1 = td_var_offset(scramble_buffers),
2810 .help = "Slightly scramble buffers on every IO submit",
2811 .def = "1",
2812 .category = FIO_OPT_C_IO,
2813 .group = FIO_OPT_G_IO_BUF,
2814 },
2815 {
2816 .name = "buffer_compress_percentage",
2817 .lname = "Buffer compression percentage",
2818 .type = FIO_OPT_INT,
2819 .off1 = td_var_offset(compress_percentage),
2820 .maxval = 100,
2821 .minval = 1,
2822 .help = "How compressible the buffer is (approximately)",
2823 .interval = 5,
2824 .category = FIO_OPT_C_IO,
2825 .group = FIO_OPT_G_IO_BUF,
2826 },
2827 {
2828 .name = "buffer_compress_chunk",
2829 .lname = "Buffer compression chunk size",
2830 .type = FIO_OPT_INT,
2831 .off1 = td_var_offset(compress_chunk),
2832 .parent = "buffer_compress_percentage",
2833 .hide = 1,
2834 .help = "Size of compressible region in buffer",
2835 .interval = 256,
2836 .category = FIO_OPT_C_IO,
2837 .group = FIO_OPT_G_IO_BUF,
2838 },
2839 {
2840 .name = "clat_percentiles",
2841 .lname = "Completion latency percentiles",
2842 .type = FIO_OPT_BOOL,
2843 .off1 = td_var_offset(clat_percentiles),
2844 .help = "Enable the reporting of completion latency percentiles",
2845 .def = "1",
2846 .category = FIO_OPT_C_STAT,
2847 .group = FIO_OPT_G_INVALID,
2848 },
2849 {
2850 .name = "percentile_list",
2851 .lname = "Completion latency percentile list",
2852 .type = FIO_OPT_FLOAT_LIST,
2853 .off1 = td_var_offset(percentile_list),
2854 .off2 = td_var_offset(overwrite_plist),
2855 .help = "Specify a custom list of percentiles to report",
2856 .maxlen = FIO_IO_U_LIST_MAX_LEN,
2857 .minfp = 0.0,
2858 .maxfp = 100.0,
2859 .category = FIO_OPT_C_STAT,
2860 .group = FIO_OPT_G_INVALID,
2861 },
2862
2863#ifdef FIO_HAVE_DISK_UTIL
2864 {
2865 .name = "disk_util",
2866 .lname = "Disk utilization",
2867 .type = FIO_OPT_BOOL,
2868 .off1 = td_var_offset(do_disk_util),
2869 .help = "Log disk utilization statistics",
2870 .def = "1",
2871 .category = FIO_OPT_C_STAT,
2872 .group = FIO_OPT_G_INVALID,
2873 },
2874#endif
2875 {
2876 .name = "gtod_reduce",
2877 .lname = "Reduce gettimeofday() calls",
2878 .type = FIO_OPT_BOOL,
2879 .help = "Greatly reduce number of gettimeofday() calls",
2880 .cb = str_gtod_reduce_cb,
2881 .def = "0",
2882 .hide_on_set = 1,
2883 .category = FIO_OPT_C_STAT,
2884 .group = FIO_OPT_G_INVALID,
2885 },
2886 {
2887 .name = "disable_lat",
2888 .lname = "Disable all latency stats",
2889 .type = FIO_OPT_BOOL,
2890 .off1 = td_var_offset(disable_lat),
2891 .help = "Disable latency numbers",
2892 .parent = "gtod_reduce",
2893 .hide = 1,
2894 .def = "0",
2895 .category = FIO_OPT_C_STAT,
2896 .group = FIO_OPT_G_INVALID,
2897 },
2898 {
2899 .name = "disable_clat",
2900 .lname = "Disable completion latency stats",
2901 .type = FIO_OPT_BOOL,
2902 .off1 = td_var_offset(disable_clat),
2903 .help = "Disable completion latency numbers",
2904 .parent = "gtod_reduce",
2905 .hide = 1,
2906 .def = "0",
2907 .category = FIO_OPT_C_STAT,
2908 .group = FIO_OPT_G_INVALID,
2909 },
2910 {
2911 .name = "disable_slat",
2912 .lname = "Disable submission latency stats",
2913 .type = FIO_OPT_BOOL,
2914 .off1 = td_var_offset(disable_slat),
2915 .help = "Disable submission latency numbers",
2916 .parent = "gtod_reduce",
2917 .hide = 1,
2918 .def = "0",
2919 .category = FIO_OPT_C_STAT,
2920 .group = FIO_OPT_G_INVALID,
2921 },
2922 {
2923 .name = "disable_bw_measurement",
2924 .lname = "Disable bandwidth stats",
2925 .type = FIO_OPT_BOOL,
2926 .off1 = td_var_offset(disable_bw),
2927 .help = "Disable bandwidth logging",
2928 .parent = "gtod_reduce",
2929 .hide = 1,
2930 .def = "0",
2931 .category = FIO_OPT_C_STAT,
2932 .group = FIO_OPT_G_INVALID,
2933 },
2934 {
2935 .name = "gtod_cpu",
2936 .lname = "Dedicated gettimeofday() CPU",
2937 .type = FIO_OPT_INT,
2938 .cb = str_gtod_cpu_cb,
2939 .help = "Set up dedicated gettimeofday() thread on this CPU",
2940 .verify = gtod_cpu_verify,
2941 .category = FIO_OPT_C_GENERAL,
2942 .group = FIO_OPT_G_CLOCK,
2943 },
2944 {
2945 .name = "continue_on_error",
2946 .lname = "Continue on error",
2947 .type = FIO_OPT_STR,
2948 .off1 = td_var_offset(continue_on_error),
2949 .help = "Continue on non-fatal errors during IO",
2950 .def = "none",
2951 .category = FIO_OPT_C_GENERAL,
2952 .group = FIO_OPT_G_ERR,
2953 .posval = {
2954 { .ival = "none",
2955 .oval = ERROR_TYPE_NONE,
2956 .help = "Exit when an error is encountered",
2957 },
2958 { .ival = "read",
2959 .oval = ERROR_TYPE_READ,
2960 .help = "Continue on read errors only",
2961 },
2962 { .ival = "write",
2963 .oval = ERROR_TYPE_WRITE,
2964 .help = "Continue on write errors only",
2965 },
2966 { .ival = "io",
2967 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
2968 .help = "Continue on any IO errors",
2969 },
2970 { .ival = "verify",
2971 .oval = ERROR_TYPE_VERIFY,
2972 .help = "Continue on verify errors only",
2973 },
2974 { .ival = "all",
2975 .oval = ERROR_TYPE_ANY,
2976 .help = "Continue on all io and verify errors",
2977 },
2978 { .ival = "0",
2979 .oval = ERROR_TYPE_NONE,
2980 .help = "Alias for 'none'",
2981 },
2982 { .ival = "1",
2983 .oval = ERROR_TYPE_ANY,
2984 .help = "Alias for 'all'",
2985 },
2986 },
2987 },
2988 {
2989 .name = "ignore_error",
2990 .type = FIO_OPT_STR,
2991 .cb = str_ignore_error_cb,
2992 .help = "Set a specific list of errors to ignore",
2993 .parent = "rw",
2994 .category = FIO_OPT_C_GENERAL,
2995 .group = FIO_OPT_G_ERR,
2996 },
2997 {
2998 .name = "error_dump",
2999 .type = FIO_OPT_BOOL,
3000 .off1 = td_var_offset(error_dump),
3001 .def = "0",
3002 .help = "Dump info on each error",
3003 .category = FIO_OPT_C_GENERAL,
3004 .group = FIO_OPT_G_ERR,
3005 },
3006 {
3007 .name = "profile",
3008 .lname = "Profile",
3009 .type = FIO_OPT_STR_STORE,
3010 .off1 = td_var_offset(profile),
3011 .help = "Select a specific builtin performance test",
3012 .category = FIO_OPT_C_PROFILE,
3013 .group = FIO_OPT_G_INVALID,
3014 },
3015 {
3016 .name = "cgroup",
3017 .lname = "Cgroup",
3018 .type = FIO_OPT_STR_STORE,
3019 .off1 = td_var_offset(cgroup),
3020 .help = "Add job to cgroup of this name",
3021 .category = FIO_OPT_C_GENERAL,
3022 .group = FIO_OPT_G_CGROUP,
3023 },
3024 {
3025 .name = "cgroup_nodelete",
3026 .lname = "Cgroup no-delete",
3027 .type = FIO_OPT_BOOL,
3028 .off1 = td_var_offset(cgroup_nodelete),
3029 .help = "Do not delete cgroups after job completion",
3030 .def = "0",
3031 .parent = "cgroup",
3032 .category = FIO_OPT_C_GENERAL,
3033 .group = FIO_OPT_G_CGROUP,
3034 },
3035 {
3036 .name = "cgroup_weight",
3037 .lname = "Cgroup weight",
3038 .type = FIO_OPT_INT,
3039 .off1 = td_var_offset(cgroup_weight),
3040 .help = "Use given weight for cgroup",
3041 .minval = 100,
3042 .maxval = 1000,
3043 .parent = "cgroup",
3044 .category = FIO_OPT_C_GENERAL,
3045 .group = FIO_OPT_G_CGROUP,
3046 },
3047 {
3048 .name = "uid",
3049 .lname = "User ID",
3050 .type = FIO_OPT_INT,
3051 .off1 = td_var_offset(uid),
3052 .help = "Run job with this user ID",
3053 .category = FIO_OPT_C_GENERAL,
3054 .group = FIO_OPT_G_CRED,
3055 },
3056 {
3057 .name = "gid",
3058 .lname = "Group ID",
3059 .type = FIO_OPT_INT,
3060 .off1 = td_var_offset(gid),
3061 .help = "Run job with this group ID",
3062 .category = FIO_OPT_C_GENERAL,
3063 .group = FIO_OPT_G_CRED,
3064 },
3065 {
3066 .name = "kb_base",
3067 .lname = "KB Base",
3068 .type = FIO_OPT_INT,
3069 .off1 = td_var_offset(kb_base),
3070 .verify = kb_base_verify,
3071 .prio = 1,
3072 .def = "1024",
3073 .help = "How many bytes per KB for reporting (1000 or 1024)",
3074 .category = FIO_OPT_C_GENERAL,
3075 .group = FIO_OPT_G_INVALID,
3076 },
3077 {
3078 .name = "hugepage-size",
3079 .lname = "Hugepage size",
3080 .type = FIO_OPT_INT,
3081 .off1 = td_var_offset(hugepage_size),
3082 .help = "When using hugepages, specify size of each page",
3083 .def = __fio_stringify(FIO_HUGE_PAGE),
3084 .interval = 1024 * 1024,
3085 .category = FIO_OPT_C_GENERAL,
3086 .group = FIO_OPT_G_INVALID,
3087 },
3088 {
3089 .name = "flow_id",
3090 .lname = "I/O flow ID",
3091 .type = FIO_OPT_INT,
3092 .off1 = td_var_offset(flow_id),
3093 .help = "The flow index ID to use",
3094 .def = "0",
3095 .category = FIO_OPT_C_IO,
3096 .group = FIO_OPT_G_IO_FLOW,
3097 },
3098 {
3099 .name = "flow",
3100 .lname = "I/O flow weight",
3101 .type = FIO_OPT_INT,
3102 .off1 = td_var_offset(flow),
3103 .help = "Weight for flow control of this job",
3104 .parent = "flow_id",
3105 .hide = 1,
3106 .def = "0",
3107 .category = FIO_OPT_C_IO,
3108 .group = FIO_OPT_G_IO_FLOW,
3109 },
3110 {
3111 .name = "flow_watermark",
3112 .lname = "I/O flow watermark",
3113 .type = FIO_OPT_INT,
3114 .off1 = td_var_offset(flow_watermark),
3115 .help = "High watermark for flow control. This option"
3116 " should be set to the same value for all threads"
3117 " with non-zero flow.",
3118 .parent = "flow_id",
3119 .hide = 1,
3120 .def = "1024",
3121 .category = FIO_OPT_C_IO,
3122 .group = FIO_OPT_G_IO_FLOW,
3123 },
3124 {
3125 .name = "flow_sleep",
3126 .lname = "I/O flow sleep",
3127 .type = FIO_OPT_INT,
3128 .off1 = td_var_offset(flow_sleep),
3129 .help = "How many microseconds to sleep after being held"
3130 " back by the flow control mechanism",
3131 .parent = "flow_id",
3132 .hide = 1,
3133 .def = "0",
3134 .category = FIO_OPT_C_IO,
3135 .group = FIO_OPT_G_IO_FLOW,
3136 },
3137 {
3138 .name = NULL,
3139 },
3140};
3141
3142static void add_to_lopt(struct option *lopt, struct fio_option *o,
3143 const char *name, int val)
3144{
3145 lopt->name = (char *) name;
3146 lopt->val = val;
3147 if (o->type == FIO_OPT_STR_SET)
3148 lopt->has_arg = no_argument;
3149 else
3150 lopt->has_arg = required_argument;
3151}
3152
3153static void options_to_lopts(struct fio_option *opts,
3154 struct option *long_options,
3155 int i, int option_type)
3156{
3157 struct fio_option *o = &opts[0];
3158 while (o->name) {
3159 add_to_lopt(&long_options[i], o, o->name, option_type);
3160 if (o->alias) {
3161 i++;
3162 add_to_lopt(&long_options[i], o, o->alias, option_type);
3163 }
3164
3165 i++;
3166 o++;
3167 assert(i < FIO_NR_OPTIONS);
3168 }
3169}
3170
3171void fio_options_set_ioengine_opts(struct option *long_options,
3172 struct thread_data *td)
3173{
3174 unsigned int i;
3175
3176 i = 0;
3177 while (long_options[i].name) {
3178 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
3179 memset(&long_options[i], 0, sizeof(*long_options));
3180 break;
3181 }
3182 i++;
3183 }
3184
3185 /*
3186 * Just clear out the prior ioengine options.
3187 */
3188 if (!td || !td->eo)
3189 return;
3190
3191 options_to_lopts(td->io_ops->options, long_options, i,
3192 FIO_GETOPT_IOENGINE);
3193}
3194
3195void fio_options_dup_and_init(struct option *long_options)
3196{
3197 unsigned int i;
3198
3199 options_init(fio_options);
3200
3201 i = 0;
3202 while (long_options[i].name)
3203 i++;
3204
3205 options_to_lopts(fio_options, long_options, i, FIO_GETOPT_JOB);
3206}
3207
3208struct fio_keyword {
3209 const char *word;
3210 const char *desc;
3211 char *replace;
3212};
3213
3214static struct fio_keyword fio_keywords[] = {
3215 {
3216 .word = "$pagesize",
3217 .desc = "Page size in the system",
3218 },
3219 {
3220 .word = "$mb_memory",
3221 .desc = "Megabytes of memory online",
3222 },
3223 {
3224 .word = "$ncpus",
3225 .desc = "Number of CPUs online in the system",
3226 },
3227 {
3228 .word = NULL,
3229 },
3230};
3231
3232void fio_keywords_init(void)
3233{
3234 unsigned long long mb_memory;
3235 char buf[128];
3236 long l;
3237
3238 sprintf(buf, "%lu", (unsigned long) page_size);
3239 fio_keywords[0].replace = strdup(buf);
3240
3241 mb_memory = os_phys_mem() / (1024 * 1024);
3242 sprintf(buf, "%llu", mb_memory);
3243 fio_keywords[1].replace = strdup(buf);
3244
3245 l = cpus_online();
3246 sprintf(buf, "%lu", l);
3247 fio_keywords[2].replace = strdup(buf);
3248}
3249
3250#define BC_APP "bc"
3251
3252static char *bc_calc(char *str)
3253{
3254 char buf[128], *tmp;
3255 FILE *f;
3256 int ret;
3257
3258 /*
3259 * No math, just return string
3260 */
3261 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
3262 !strchr(str, '/')) || strchr(str, '\''))
3263 return str;
3264
3265 /*
3266 * Split option from value, we only need to calculate the value
3267 */
3268 tmp = strchr(str, '=');
3269 if (!tmp)
3270 return str;
3271
3272 tmp++;
3273
3274 /*
3275 * Prevent buffer overflows; such a case isn't reasonable anyway
3276 */
3277 if (strlen(str) >= 128 || strlen(tmp) > 100)
3278 return str;
3279
3280 sprintf(buf, "which %s > /dev/null", BC_APP);
3281 if (system(buf)) {
3282 log_err("fio: bc is needed for performing math\n");
3283 return NULL;
3284 }
3285
3286 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
3287 f = popen(buf, "r");
3288 if (!f)
3289 return NULL;
3290
3291 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
3292 if (ret <= 0)
3293 return NULL;
3294
3295 pclose(f);
3296 buf[(tmp - str) + ret - 1] = '\0';
3297 memcpy(buf, str, tmp - str);
3298 free(str);
3299 return strdup(buf);
3300}
3301
3302/*
3303 * Return a copy of the input string with substrings of the form ${VARNAME}
3304 * substituted with the value of the environment variable VARNAME. The
3305 * substitution always occurs, even if VARNAME is empty or the corresponding
3306 * environment variable undefined.
3307 */
3308static char *option_dup_subs(const char *opt)
3309{
3310 char out[OPT_LEN_MAX+1];
3311 char in[OPT_LEN_MAX+1];
3312 char *outptr = out;
3313 char *inptr = in;
3314 char *ch1, *ch2, *env;
3315 ssize_t nchr = OPT_LEN_MAX;
3316 size_t envlen;
3317
3318 if (strlen(opt) + 1 > OPT_LEN_MAX) {
3319 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
3320 return NULL;
3321 }
3322
3323 in[OPT_LEN_MAX] = '\0';
3324 strncpy(in, opt, OPT_LEN_MAX);
3325
3326 while (*inptr && nchr > 0) {
3327 if (inptr[0] == '$' && inptr[1] == '{') {
3328 ch2 = strchr(inptr, '}');
3329 if (ch2 && inptr+1 < ch2) {
3330 ch1 = inptr+2;
3331 inptr = ch2+1;
3332 *ch2 = '\0';
3333
3334 env = getenv(ch1);
3335 if (env) {
3336 envlen = strlen(env);
3337 if (envlen <= nchr) {
3338 memcpy(outptr, env, envlen);
3339 outptr += envlen;
3340 nchr -= envlen;
3341 }
3342 }
3343
3344 continue;
3345 }
3346 }
3347
3348 *outptr++ = *inptr++;
3349 --nchr;
3350 }
3351
3352 *outptr = '\0';
3353 return strdup(out);
3354}
3355
3356/*
3357 * Look for reserved variable names and replace them with real values
3358 */
3359static char *fio_keyword_replace(char *opt)
3360{
3361 char *s;
3362 int i;
3363 int docalc = 0;
3364
3365 for (i = 0; fio_keywords[i].word != NULL; i++) {
3366 struct fio_keyword *kw = &fio_keywords[i];
3367
3368 while ((s = strstr(opt, kw->word)) != NULL) {
3369 char *new = malloc(strlen(opt) + 1);
3370 char *o_org = opt;
3371 int olen = s - opt;
3372 int len;
3373
3374 /*
3375 * Copy part of the string before the keyword and
3376 * sprintf() the replacement after it.
3377 */
3378 memcpy(new, opt, olen);
3379 len = sprintf(new + olen, "%s", kw->replace);
3380
3381 /*
3382 * If there's more in the original string, copy that
3383 * in too
3384 */
3385 opt += strlen(kw->word) + olen;
3386 if (strlen(opt))
3387 memcpy(new + olen + len, opt, opt - o_org - 1);
3388
3389 /*
3390 * replace opt and free the old opt
3391 */
3392 opt = new;
3393 free(o_org);
3394
3395 docalc = 1;
3396 }
3397 }
3398
3399 /*
3400 * Check for potential math and invoke bc, if possible
3401 */
3402 if (docalc)
3403 opt = bc_calc(opt);
3404
3405 return opt;
3406}
3407
3408static char **dup_and_sub_options(char **opts, int num_opts)
3409{
3410 int i;
3411 char **opts_copy = malloc(num_opts * sizeof(*opts));
3412 for (i = 0; i < num_opts; i++) {
3413 opts_copy[i] = option_dup_subs(opts[i]);
3414 if (!opts_copy[i])
3415 continue;
3416 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
3417 }
3418 return opts_copy;
3419}
3420
3421int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
3422{
3423 int i, ret, unknown;
3424 char **opts_copy;
3425
3426 sort_options(opts, fio_options, num_opts);
3427 opts_copy = dup_and_sub_options(opts, num_opts);
3428
3429 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
3430 struct fio_option *o;
3431 int newret = parse_option(opts_copy[i], opts[i], fio_options,
3432 &o, td);
3433
3434 if (opts_copy[i]) {
3435 if (newret && !o) {
3436 unknown++;
3437 continue;
3438 }
3439 free(opts_copy[i]);
3440 opts_copy[i] = NULL;
3441 }
3442
3443 ret |= newret;
3444 }
3445
3446 if (unknown) {
3447 ret |= ioengine_load(td);
3448 if (td->eo) {
3449 sort_options(opts_copy, td->io_ops->options, num_opts);
3450 opts = opts_copy;
3451 }
3452 for (i = 0; i < num_opts; i++) {
3453 struct fio_option *o = NULL;
3454 int newret = 1;
3455 if (!opts_copy[i])
3456 continue;
3457
3458 if (td->eo)
3459 newret = parse_option(opts_copy[i], opts[i],
3460 td->io_ops->options, &o,
3461 td->eo);
3462
3463 ret |= newret;
3464 if (!o)
3465 log_err("Bad option <%s>\n", opts[i]);
3466
3467 free(opts_copy[i]);
3468 opts_copy[i] = NULL;
3469 }
3470 }
3471
3472 free(opts_copy);
3473 return ret;
3474}
3475
3476int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
3477{
3478 return parse_cmd_option(opt, val, fio_options, td);
3479}
3480
3481int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
3482 char *val)
3483{
3484 return parse_cmd_option(opt, val, td->io_ops->options, td);
3485}
3486
3487void fio_fill_default_options(struct thread_data *td)
3488{
3489 fill_default_options(td, fio_options);
3490}
3491
3492int fio_show_option_help(const char *opt)
3493{
3494 return show_cmd_help(fio_options, opt);
3495}
3496
3497void options_mem_dupe(void *data, struct fio_option *options)
3498{
3499 struct fio_option *o;
3500 char **ptr;
3501
3502 for (o = &options[0]; o->name; o++) {
3503 if (o->type != FIO_OPT_STR_STORE)
3504 continue;
3505
3506 ptr = td_var(data, o->off1);
3507 if (*ptr)
3508 *ptr = strdup(*ptr);
3509 }
3510}
3511
3512/*
3513 * dupe FIO_OPT_STR_STORE options
3514 */
3515void fio_options_mem_dupe(struct thread_data *td)
3516{
3517 options_mem_dupe(&td->o, fio_options);
3518
3519 if (td->eo && td->io_ops) {
3520 void *oldeo = td->eo;
3521
3522 td->eo = malloc(td->io_ops->option_struct_size);
3523 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
3524 options_mem_dupe(td->eo, td->io_ops->options);
3525 }
3526}
3527
3528unsigned int fio_get_kb_base(void *data)
3529{
3530 struct thread_options *o = data;
3531 unsigned int kb_base = 0;
3532
3533 if (o)
3534 kb_base = o->kb_base;
3535 if (!kb_base)
3536 kb_base = 1024;
3537
3538 return kb_base;
3539}
3540
3541int add_option(struct fio_option *o)
3542{
3543 struct fio_option *__o;
3544 int opt_index = 0;
3545
3546 __o = fio_options;
3547 while (__o->name) {
3548 opt_index++;
3549 __o++;
3550 }
3551
3552 memcpy(&fio_options[opt_index], o, sizeof(*o));
3553 return 0;
3554}
3555
3556void invalidate_profile_options(const char *prof_name)
3557{
3558 struct fio_option *o;
3559
3560 o = fio_options;
3561 while (o->name) {
3562 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
3563 o->type = FIO_OPT_INVALID;
3564 o->prof_name = NULL;
3565 }
3566 o++;
3567 }
3568}
3569
3570void add_opt_posval(const char *optname, const char *ival, const char *help)
3571{
3572 struct fio_option *o;
3573 unsigned int i;
3574
3575 o = find_option(fio_options, optname);
3576 if (!o)
3577 return;
3578
3579 for (i = 0; i < PARSE_MAX_VP; i++) {
3580 if (o->posval[i].ival)
3581 continue;
3582
3583 o->posval[i].ival = ival;
3584 o->posval[i].help = help;
3585 break;
3586 }
3587}
3588
3589void del_opt_posval(const char *optname, const char *ival)
3590{
3591 struct fio_option *o;
3592 unsigned int i;
3593
3594 o = find_option(fio_options, optname);
3595 if (!o)
3596 return;
3597
3598 for (i = 0; i < PARSE_MAX_VP; i++) {
3599 if (!o->posval[i].ival)
3600 continue;
3601 if (strcmp(o->posval[i].ival, ival))
3602 continue;
3603
3604 o->posval[i].ival = NULL;
3605 o->posval[i].help = NULL;
3606 }
3607}
3608
3609void fio_options_free(struct thread_data *td)
3610{
3611 options_free(fio_options, td);
3612 if (td->eo && td->io_ops && td->io_ops->options) {
3613 options_free(td->io_ops->options, td->eo);
3614 free(td->eo);
3615 td->eo = NULL;
3616 }
3617}
3618
3619struct fio_option *fio_option_find(const char *name)
3620{
3621 return find_option(fio_options, name);
3622}
3623