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