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