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