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