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