filesetup: add native fallocate
[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
1465static int rw_verify(struct fio_option *o, void *data)
1466{
1467 struct thread_data *td = cb_data_to_td(data);
1468
1469 if (read_only && td_write(td)) {
1470 log_err("fio: job <%s> has write bit set, but fio is in"
1471 " read-only mode\n", td->o.name);
1472 return 1;
1473 }
1474
1475 return 0;
1476}
1477
1478static int gtod_cpu_verify(struct fio_option *o, void *data)
1479{
1480#ifndef FIO_HAVE_CPU_AFFINITY
1481 struct thread_data *td = cb_data_to_td(data);
1482
1483 if (td->o.gtod_cpu) {
1484 log_err("fio: platform must support CPU affinity for"
1485 "gettimeofday() offloading\n");
1486 return 1;
1487 }
1488#endif
1489
1490 return 0;
1491}
1492
1493/*
1494 * Map of job/command line options
1495 */
1496struct fio_option fio_options[FIO_MAX_OPTS] = {
1497 {
1498 .name = "description",
1499 .lname = "Description of job",
1500 .type = FIO_OPT_STR_STORE,
1501 .off1 = offsetof(struct thread_options, description),
1502 .help = "Text job description",
1503 .category = FIO_OPT_C_GENERAL,
1504 .group = FIO_OPT_G_DESC,
1505 },
1506 {
1507 .name = "name",
1508 .lname = "Job name",
1509 .type = FIO_OPT_STR_STORE,
1510 .off1 = offsetof(struct thread_options, name),
1511 .help = "Name of this job",
1512 .category = FIO_OPT_C_GENERAL,
1513 .group = FIO_OPT_G_DESC,
1514 },
1515 {
1516 .name = "wait_for",
1517 .lname = "Waitee name",
1518 .type = FIO_OPT_STR_STORE,
1519 .off1 = offsetof(struct thread_options, wait_for),
1520 .help = "Name of the job this one wants to wait for before starting",
1521 .category = FIO_OPT_C_GENERAL,
1522 .group = FIO_OPT_G_DESC,
1523 },
1524 {
1525 .name = "filename",
1526 .lname = "Filename(s)",
1527 .type = FIO_OPT_STR_STORE,
1528 .off1 = offsetof(struct thread_options, filename),
1529 .cb = str_filename_cb,
1530 .prio = -1, /* must come after "directory" */
1531 .help = "File(s) to use for the workload",
1532 .category = FIO_OPT_C_FILE,
1533 .group = FIO_OPT_G_FILENAME,
1534 },
1535 {
1536 .name = "directory",
1537 .lname = "Directory",
1538 .type = FIO_OPT_STR_STORE,
1539 .off1 = offsetof(struct thread_options, directory),
1540 .cb = str_directory_cb,
1541 .help = "Directory to store files in",
1542 .category = FIO_OPT_C_FILE,
1543 .group = FIO_OPT_G_FILENAME,
1544 },
1545 {
1546 .name = "filename_format",
1547 .lname = "Filename Format",
1548 .type = FIO_OPT_STR_STORE,
1549 .off1 = offsetof(struct thread_options, filename_format),
1550 .prio = -1, /* must come after "directory" */
1551 .help = "Override default $jobname.$jobnum.$filenum naming",
1552 .def = "$jobname.$jobnum.$filenum",
1553 .category = FIO_OPT_C_FILE,
1554 .group = FIO_OPT_G_FILENAME,
1555 },
1556 {
1557 .name = "unique_filename",
1558 .lname = "Unique Filename",
1559 .type = FIO_OPT_BOOL,
1560 .off1 = offsetof(struct thread_options, unique_filename),
1561 .help = "For network clients, prefix file with source IP",
1562 .def = "1",
1563 .category = FIO_OPT_C_FILE,
1564 .group = FIO_OPT_G_FILENAME,
1565 },
1566 {
1567 .name = "lockfile",
1568 .lname = "Lockfile",
1569 .type = FIO_OPT_STR,
1570 .off1 = offsetof(struct thread_options, file_lock_mode),
1571 .help = "Lock file when doing IO to it",
1572 .prio = 1,
1573 .parent = "filename",
1574 .hide = 0,
1575 .def = "none",
1576 .category = FIO_OPT_C_FILE,
1577 .group = FIO_OPT_G_FILENAME,
1578 .posval = {
1579 { .ival = "none",
1580 .oval = FILE_LOCK_NONE,
1581 .help = "No file locking",
1582 },
1583 { .ival = "exclusive",
1584 .oval = FILE_LOCK_EXCLUSIVE,
1585 .help = "Exclusive file lock",
1586 },
1587 {
1588 .ival = "readwrite",
1589 .oval = FILE_LOCK_READWRITE,
1590 .help = "Read vs write lock",
1591 },
1592 },
1593 },
1594 {
1595 .name = "opendir",
1596 .lname = "Open directory",
1597 .type = FIO_OPT_STR_STORE,
1598 .off1 = offsetof(struct thread_options, opendir),
1599 .cb = str_opendir_cb,
1600 .help = "Recursively add files from this directory and down",
1601 .category = FIO_OPT_C_FILE,
1602 .group = FIO_OPT_G_FILENAME,
1603 },
1604 {
1605 .name = "rw",
1606 .lname = "Read/write",
1607 .alias = "readwrite",
1608 .type = FIO_OPT_STR,
1609 .cb = str_rw_cb,
1610 .off1 = offsetof(struct thread_options, td_ddir),
1611 .help = "IO direction",
1612 .def = "read",
1613 .verify = rw_verify,
1614 .category = FIO_OPT_C_IO,
1615 .group = FIO_OPT_G_IO_BASIC,
1616 .posval = {
1617 { .ival = "read",
1618 .oval = TD_DDIR_READ,
1619 .help = "Sequential read",
1620 },
1621 { .ival = "write",
1622 .oval = TD_DDIR_WRITE,
1623 .help = "Sequential write",
1624 },
1625 { .ival = "trim",
1626 .oval = TD_DDIR_TRIM,
1627 .help = "Sequential trim",
1628 },
1629 { .ival = "randread",
1630 .oval = TD_DDIR_RANDREAD,
1631 .help = "Random read",
1632 },
1633 { .ival = "randwrite",
1634 .oval = TD_DDIR_RANDWRITE,
1635 .help = "Random write",
1636 },
1637 { .ival = "randtrim",
1638 .oval = TD_DDIR_RANDTRIM,
1639 .help = "Random trim",
1640 },
1641 { .ival = "rw",
1642 .oval = TD_DDIR_RW,
1643 .help = "Sequential read and write mix",
1644 },
1645 { .ival = "readwrite",
1646 .oval = TD_DDIR_RW,
1647 .help = "Sequential read and write mix",
1648 },
1649 { .ival = "randrw",
1650 .oval = TD_DDIR_RANDRW,
1651 .help = "Random read and write mix"
1652 },
1653 { .ival = "trimwrite",
1654 .oval = TD_DDIR_TRIMWRITE,
1655 .help = "Trim and write mix, trims preceding writes"
1656 },
1657 },
1658 },
1659 {
1660 .name = "rw_sequencer",
1661 .lname = "RW Sequencer",
1662 .type = FIO_OPT_STR,
1663 .off1 = offsetof(struct thread_options, rw_seq),
1664 .help = "IO offset generator modifier",
1665 .def = "sequential",
1666 .category = FIO_OPT_C_IO,
1667 .group = FIO_OPT_G_IO_BASIC,
1668 .posval = {
1669 { .ival = "sequential",
1670 .oval = RW_SEQ_SEQ,
1671 .help = "Generate sequential offsets",
1672 },
1673 { .ival = "identical",
1674 .oval = RW_SEQ_IDENT,
1675 .help = "Generate identical offsets",
1676 },
1677 },
1678 },
1679
1680 {
1681 .name = "ioengine",
1682 .lname = "IO Engine",
1683 .type = FIO_OPT_STR_STORE,
1684 .off1 = offsetof(struct thread_options, ioengine),
1685 .help = "IO engine to use",
1686 .def = FIO_PREFERRED_ENGINE,
1687 .category = FIO_OPT_C_IO,
1688 .group = FIO_OPT_G_IO_BASIC,
1689 .posval = {
1690 { .ival = "sync",
1691 .help = "Use read/write",
1692 },
1693 { .ival = "psync",
1694 .help = "Use pread/pwrite",
1695 },
1696 { .ival = "vsync",
1697 .help = "Use readv/writev",
1698 },
1699#ifdef CONFIG_PWRITEV
1700 { .ival = "pvsync",
1701 .help = "Use preadv/pwritev",
1702 },
1703#endif
1704#ifdef FIO_HAVE_PWRITEV2
1705 { .ival = "pvsync2",
1706 .help = "Use preadv2/pwritev2",
1707 },
1708#endif
1709#ifdef CONFIG_LIBAIO
1710 { .ival = "libaio",
1711 .help = "Linux native asynchronous IO",
1712 },
1713#endif
1714#ifdef CONFIG_POSIXAIO
1715 { .ival = "posixaio",
1716 .help = "POSIX asynchronous IO",
1717 },
1718#endif
1719#ifdef CONFIG_SOLARISAIO
1720 { .ival = "solarisaio",
1721 .help = "Solaris native asynchronous IO",
1722 },
1723#endif
1724#ifdef CONFIG_WINDOWSAIO
1725 { .ival = "windowsaio",
1726 .help = "Windows native asynchronous IO"
1727 },
1728#endif
1729#ifdef CONFIG_RBD
1730 { .ival = "rbd",
1731 .help = "Rados Block Device asynchronous IO"
1732 },
1733#endif
1734 { .ival = "mmap",
1735 .help = "Memory mapped IO"
1736 },
1737#ifdef CONFIG_LINUX_SPLICE
1738 { .ival = "splice",
1739 .help = "splice/vmsplice based IO",
1740 },
1741 { .ival = "netsplice",
1742 .help = "splice/vmsplice to/from the network",
1743 },
1744#endif
1745#ifdef FIO_HAVE_SGIO
1746 { .ival = "sg",
1747 .help = "SCSI generic v3 IO",
1748 },
1749#endif
1750 { .ival = "null",
1751 .help = "Testing engine (no data transfer)",
1752 },
1753 { .ival = "net",
1754 .help = "Network IO",
1755 },
1756 { .ival = "cpuio",
1757 .help = "CPU cycle burner engine",
1758 },
1759#ifdef CONFIG_GUASI
1760 { .ival = "guasi",
1761 .help = "GUASI IO engine",
1762 },
1763#endif
1764#ifdef FIO_HAVE_BINJECT
1765 { .ival = "binject",
1766 .help = "binject direct inject block engine",
1767 },
1768#endif
1769#ifdef CONFIG_RDMA
1770 { .ival = "rdma",
1771 .help = "RDMA IO engine",
1772 },
1773#endif
1774#ifdef CONFIG_FUSION_AW
1775 { .ival = "fusion-aw-sync",
1776 .help = "Fusion-io atomic write engine",
1777 },
1778#endif
1779#ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
1780 { .ival = "e4defrag",
1781 .help = "ext4 defrag engine",
1782 },
1783#endif
1784#ifdef CONFIG_LINUX_FALLOCATE
1785 { .ival = "falloc",
1786 .help = "fallocate() file based engine",
1787 },
1788#endif
1789#ifdef CONFIG_GFAPI
1790 { .ival = "gfapi",
1791 .help = "Glusterfs libgfapi(sync) based engine"
1792 },
1793 { .ival = "gfapi_async",
1794 .help = "Glusterfs libgfapi(async) based engine"
1795 },
1796#endif
1797#ifdef CONFIG_LIBHDFS
1798 { .ival = "libhdfs",
1799 .help = "Hadoop Distributed Filesystem (HDFS) engine"
1800 },
1801#endif
1802#ifdef CONFIG_PMEMBLK
1803 { .ival = "pmemblk",
1804 .help = "NVML libpmemblk based IO engine",
1805 },
1806
1807#endif
1808#ifdef CONFIG_LINUX_DEVDAX
1809 { .ival = "dev-dax",
1810 .help = "DAX Device based IO engine",
1811 },
1812#endif
1813 { .ival = "external",
1814 .help = "Load external engine (append name)",
1815 },
1816 },
1817 },
1818 {
1819 .name = "iodepth",
1820 .lname = "IO Depth",
1821 .type = FIO_OPT_INT,
1822 .off1 = offsetof(struct thread_options, iodepth),
1823 .help = "Number of IO buffers to keep in flight",
1824 .minval = 1,
1825 .interval = 1,
1826 .def = "1",
1827 .category = FIO_OPT_C_IO,
1828 .group = FIO_OPT_G_IO_BASIC,
1829 },
1830 {
1831 .name = "iodepth_batch",
1832 .lname = "IO Depth batch",
1833 .alias = "iodepth_batch_submit",
1834 .type = FIO_OPT_INT,
1835 .off1 = offsetof(struct thread_options, iodepth_batch),
1836 .help = "Number of IO buffers to submit in one go",
1837 .parent = "iodepth",
1838 .hide = 1,
1839 .interval = 1,
1840 .def = "1",
1841 .category = FIO_OPT_C_IO,
1842 .group = FIO_OPT_G_IO_BASIC,
1843 },
1844 {
1845 .name = "iodepth_batch_complete_min",
1846 .lname = "Min IO depth batch complete",
1847 .alias = "iodepth_batch_complete",
1848 .type = FIO_OPT_INT,
1849 .off1 = offsetof(struct thread_options, iodepth_batch_complete_min),
1850 .help = "Min number of IO buffers to retrieve in one go",
1851 .parent = "iodepth",
1852 .hide = 1,
1853 .minval = 0,
1854 .interval = 1,
1855 .def = "1",
1856 .category = FIO_OPT_C_IO,
1857 .group = FIO_OPT_G_IO_BASIC,
1858 },
1859 {
1860 .name = "iodepth_batch_complete_max",
1861 .lname = "Max IO depth batch complete",
1862 .type = FIO_OPT_INT,
1863 .off1 = offsetof(struct thread_options, iodepth_batch_complete_max),
1864 .help = "Max number of IO buffers to retrieve in one go",
1865 .parent = "iodepth",
1866 .hide = 1,
1867 .minval = 0,
1868 .interval = 1,
1869 .category = FIO_OPT_C_IO,
1870 .group = FIO_OPT_G_IO_BASIC,
1871 },
1872 {
1873 .name = "iodepth_low",
1874 .lname = "IO Depth batch low",
1875 .type = FIO_OPT_INT,
1876 .off1 = offsetof(struct thread_options, iodepth_low),
1877 .help = "Low water mark for queuing depth",
1878 .parent = "iodepth",
1879 .hide = 1,
1880 .interval = 1,
1881 .category = FIO_OPT_C_IO,
1882 .group = FIO_OPT_G_IO_BASIC,
1883 },
1884 {
1885 .name = "io_submit_mode",
1886 .lname = "IO submit mode",
1887 .type = FIO_OPT_STR,
1888 .off1 = offsetof(struct thread_options, io_submit_mode),
1889 .help = "How IO submissions and completions are done",
1890 .def = "inline",
1891 .category = FIO_OPT_C_IO,
1892 .group = FIO_OPT_G_IO_BASIC,
1893 .posval = {
1894 { .ival = "inline",
1895 .oval = IO_MODE_INLINE,
1896 .help = "Submit and complete IO inline",
1897 },
1898 { .ival = "offload",
1899 .oval = IO_MODE_OFFLOAD,
1900 .help = "Offload submit and complete to threads",
1901 },
1902 },
1903 },
1904 {
1905 .name = "size",
1906 .lname = "Size",
1907 .type = FIO_OPT_STR_VAL,
1908 .cb = str_size_cb,
1909 .off1 = offsetof(struct thread_options, size),
1910 .help = "Total size of device or files",
1911 .interval = 1024 * 1024,
1912 .category = FIO_OPT_C_IO,
1913 .group = FIO_OPT_G_INVALID,
1914 },
1915 {
1916 .name = "io_size",
1917 .alias = "io_limit",
1918 .lname = "IO Size",
1919 .type = FIO_OPT_STR_VAL,
1920 .off1 = offsetof(struct thread_options, io_size),
1921 .help = "Total size of I/O to be performed",
1922 .interval = 1024 * 1024,
1923 .category = FIO_OPT_C_IO,
1924 .group = FIO_OPT_G_INVALID,
1925 },
1926 {
1927 .name = "fill_device",
1928 .lname = "Fill device",
1929 .alias = "fill_fs",
1930 .type = FIO_OPT_BOOL,
1931 .off1 = offsetof(struct thread_options, fill_device),
1932 .help = "Write until an ENOSPC error occurs",
1933 .def = "0",
1934 .category = FIO_OPT_C_FILE,
1935 .group = FIO_OPT_G_INVALID,
1936 },
1937 {
1938 .name = "filesize",
1939 .lname = "File size",
1940 .type = FIO_OPT_STR_VAL,
1941 .off1 = offsetof(struct thread_options, file_size_low),
1942 .off2 = offsetof(struct thread_options, file_size_high),
1943 .minval = 1,
1944 .help = "Size of individual files",
1945 .interval = 1024 * 1024,
1946 .category = FIO_OPT_C_FILE,
1947 .group = FIO_OPT_G_INVALID,
1948 },
1949 {
1950 .name = "file_append",
1951 .lname = "File append",
1952 .type = FIO_OPT_BOOL,
1953 .off1 = offsetof(struct thread_options, file_append),
1954 .help = "IO will start at the end of the file(s)",
1955 .def = "0",
1956 .category = FIO_OPT_C_FILE,
1957 .group = FIO_OPT_G_INVALID,
1958 },
1959 {
1960 .name = "offset",
1961 .lname = "IO offset",
1962 .alias = "fileoffset",
1963 .type = FIO_OPT_STR_VAL,
1964 .cb = str_offset_cb,
1965 .off1 = offsetof(struct thread_options, start_offset),
1966 .help = "Start IO from this offset",
1967 .def = "0",
1968 .interval = 1024 * 1024,
1969 .category = FIO_OPT_C_IO,
1970 .group = FIO_OPT_G_INVALID,
1971 },
1972 {
1973 .name = "offset_increment",
1974 .lname = "IO offset increment",
1975 .type = FIO_OPT_STR_VAL,
1976 .off1 = offsetof(struct thread_options, offset_increment),
1977 .help = "What is the increment from one offset to the next",
1978 .parent = "offset",
1979 .hide = 1,
1980 .def = "0",
1981 .interval = 1024 * 1024,
1982 .category = FIO_OPT_C_IO,
1983 .group = FIO_OPT_G_INVALID,
1984 },
1985 {
1986 .name = "number_ios",
1987 .lname = "Number of IOs to perform",
1988 .type = FIO_OPT_STR_VAL,
1989 .off1 = offsetof(struct thread_options, number_ios),
1990 .help = "Force job completion after this number of IOs",
1991 .def = "0",
1992 .category = FIO_OPT_C_IO,
1993 .group = FIO_OPT_G_INVALID,
1994 },
1995 {
1996 .name = "bs",
1997 .lname = "Block size",
1998 .alias = "blocksize",
1999 .type = FIO_OPT_INT,
2000 .off1 = offsetof(struct thread_options, bs[DDIR_READ]),
2001 .off2 = offsetof(struct thread_options, bs[DDIR_WRITE]),
2002 .off3 = offsetof(struct thread_options, bs[DDIR_TRIM]),
2003 .minval = 1,
2004 .help = "Block size unit",
2005 .def = "4096",
2006 .parent = "rw",
2007 .hide = 1,
2008 .interval = 512,
2009 .category = FIO_OPT_C_IO,
2010 .group = FIO_OPT_G_INVALID,
2011 },
2012 {
2013 .name = "ba",
2014 .lname = "Block size align",
2015 .alias = "blockalign",
2016 .type = FIO_OPT_INT,
2017 .off1 = offsetof(struct thread_options, ba[DDIR_READ]),
2018 .off2 = offsetof(struct thread_options, ba[DDIR_WRITE]),
2019 .off3 = offsetof(struct thread_options, ba[DDIR_TRIM]),
2020 .minval = 1,
2021 .help = "IO block offset alignment",
2022 .parent = "rw",
2023 .hide = 1,
2024 .interval = 512,
2025 .category = FIO_OPT_C_IO,
2026 .group = FIO_OPT_G_INVALID,
2027 },
2028 {
2029 .name = "bsrange",
2030 .lname = "Block size range",
2031 .alias = "blocksize_range",
2032 .type = FIO_OPT_RANGE,
2033 .off1 = offsetof(struct thread_options, min_bs[DDIR_READ]),
2034 .off2 = offsetof(struct thread_options, max_bs[DDIR_READ]),
2035 .off3 = offsetof(struct thread_options, min_bs[DDIR_WRITE]),
2036 .off4 = offsetof(struct thread_options, max_bs[DDIR_WRITE]),
2037 .off5 = offsetof(struct thread_options, min_bs[DDIR_TRIM]),
2038 .off6 = offsetof(struct thread_options, max_bs[DDIR_TRIM]),
2039 .minval = 1,
2040 .help = "Set block size range (in more detail than bs)",
2041 .parent = "rw",
2042 .hide = 1,
2043 .interval = 4096,
2044 .category = FIO_OPT_C_IO,
2045 .group = FIO_OPT_G_INVALID,
2046 },
2047 {
2048 .name = "bssplit",
2049 .lname = "Block size split",
2050 .type = FIO_OPT_STR,
2051 .cb = str_bssplit_cb,
2052 .off1 = offsetof(struct thread_options, bssplit),
2053 .help = "Set a specific mix of block sizes",
2054 .parent = "rw",
2055 .hide = 1,
2056 .category = FIO_OPT_C_IO,
2057 .group = FIO_OPT_G_INVALID,
2058 },
2059 {
2060 .name = "bs_unaligned",
2061 .lname = "Block size unaligned",
2062 .alias = "blocksize_unaligned",
2063 .type = FIO_OPT_STR_SET,
2064 .off1 = offsetof(struct thread_options, bs_unaligned),
2065 .help = "Don't sector align IO buffer sizes",
2066 .parent = "rw",
2067 .hide = 1,
2068 .category = FIO_OPT_C_IO,
2069 .group = FIO_OPT_G_INVALID,
2070 },
2071 {
2072 .name = "bs_is_seq_rand",
2073 .lname = "Block size division is seq/random (not read/write)",
2074 .type = FIO_OPT_BOOL,
2075 .off1 = offsetof(struct thread_options, bs_is_seq_rand),
2076 .help = "Consider any blocksize setting to be sequential,random",
2077 .def = "0",
2078 .parent = "blocksize",
2079 .category = FIO_OPT_C_IO,
2080 .group = FIO_OPT_G_INVALID,
2081 },
2082 {
2083 .name = "randrepeat",
2084 .lname = "Random repeatable",
2085 .type = FIO_OPT_BOOL,
2086 .off1 = offsetof(struct thread_options, rand_repeatable),
2087 .help = "Use repeatable random IO pattern",
2088 .def = "1",
2089 .parent = "rw",
2090 .hide = 1,
2091 .category = FIO_OPT_C_IO,
2092 .group = FIO_OPT_G_RANDOM,
2093 },
2094 {
2095 .name = "randseed",
2096 .lname = "The random generator seed",
2097 .type = FIO_OPT_STR_VAL,
2098 .off1 = offsetof(struct thread_options, rand_seed),
2099 .help = "Set the random generator seed value",
2100 .def = "0x89",
2101 .parent = "rw",
2102 .category = FIO_OPT_C_IO,
2103 .group = FIO_OPT_G_RANDOM,
2104 },
2105 {
2106 .name = "use_os_rand",
2107 .lname = "Use OS random",
2108 .type = FIO_OPT_DEPRECATED,
2109 .off1 = offsetof(struct thread_options, dep_use_os_rand),
2110 .category = FIO_OPT_C_IO,
2111 .group = FIO_OPT_G_RANDOM,
2112 },
2113 {
2114 .name = "norandommap",
2115 .lname = "No randommap",
2116 .type = FIO_OPT_STR_SET,
2117 .off1 = offsetof(struct thread_options, norandommap),
2118 .help = "Accept potential duplicate random blocks",
2119 .parent = "rw",
2120 .hide = 1,
2121 .hide_on_set = 1,
2122 .category = FIO_OPT_C_IO,
2123 .group = FIO_OPT_G_RANDOM,
2124 },
2125 {
2126 .name = "softrandommap",
2127 .lname = "Soft randommap",
2128 .type = FIO_OPT_BOOL,
2129 .off1 = offsetof(struct thread_options, softrandommap),
2130 .help = "Set norandommap if randommap allocation fails",
2131 .parent = "norandommap",
2132 .hide = 1,
2133 .def = "0",
2134 .category = FIO_OPT_C_IO,
2135 .group = FIO_OPT_G_RANDOM,
2136 },
2137 {
2138 .name = "random_generator",
2139 .lname = "Random Generator",
2140 .type = FIO_OPT_STR,
2141 .off1 = offsetof(struct thread_options, random_generator),
2142 .help = "Type of random number generator to use",
2143 .def = "tausworthe",
2144 .posval = {
2145 { .ival = "tausworthe",
2146 .oval = FIO_RAND_GEN_TAUSWORTHE,
2147 .help = "Strong Tausworthe generator",
2148 },
2149 { .ival = "lfsr",
2150 .oval = FIO_RAND_GEN_LFSR,
2151 .help = "Variable length LFSR",
2152 },
2153 {
2154 .ival = "tausworthe64",
2155 .oval = FIO_RAND_GEN_TAUSWORTHE64,
2156 .help = "64-bit Tausworthe variant",
2157 },
2158 },
2159 .category = FIO_OPT_C_IO,
2160 .group = FIO_OPT_G_RANDOM,
2161 },
2162 {
2163 .name = "random_distribution",
2164 .lname = "Random Distribution",
2165 .type = FIO_OPT_STR,
2166 .off1 = offsetof(struct thread_options, random_distribution),
2167 .cb = str_random_distribution_cb,
2168 .help = "Random offset distribution generator",
2169 .def = "random",
2170 .posval = {
2171 { .ival = "random",
2172 .oval = FIO_RAND_DIST_RANDOM,
2173 .help = "Completely random",
2174 },
2175 { .ival = "zipf",
2176 .oval = FIO_RAND_DIST_ZIPF,
2177 .help = "Zipf distribution",
2178 },
2179 { .ival = "pareto",
2180 .oval = FIO_RAND_DIST_PARETO,
2181 .help = "Pareto distribution",
2182 },
2183 { .ival = "normal",
2184 .oval = FIO_RAND_DIST_GAUSS,
2185 .help = "Normal (Gaussian) distribution",
2186 },
2187 { .ival = "zoned",
2188 .oval = FIO_RAND_DIST_ZONED,
2189 .help = "Zoned random distribution",
2190 },
2191
2192 },
2193 .category = FIO_OPT_C_IO,
2194 .group = FIO_OPT_G_RANDOM,
2195 },
2196 {
2197 .name = "percentage_random",
2198 .lname = "Percentage Random",
2199 .type = FIO_OPT_INT,
2200 .off1 = offsetof(struct thread_options, perc_rand[DDIR_READ]),
2201 .off2 = offsetof(struct thread_options, perc_rand[DDIR_WRITE]),
2202 .off3 = offsetof(struct thread_options, perc_rand[DDIR_TRIM]),
2203 .maxval = 100,
2204 .help = "Percentage of seq/random mix that should be random",
2205 .def = "100,100,100",
2206 .interval = 5,
2207 .inverse = "percentage_sequential",
2208 .category = FIO_OPT_C_IO,
2209 .group = FIO_OPT_G_RANDOM,
2210 },
2211 {
2212 .name = "percentage_sequential",
2213 .lname = "Percentage Sequential",
2214 .type = FIO_OPT_DEPRECATED,
2215 .category = FIO_OPT_C_IO,
2216 .group = FIO_OPT_G_RANDOM,
2217 },
2218 {
2219 .name = "allrandrepeat",
2220 .lname = "All Random Repeat",
2221 .type = FIO_OPT_BOOL,
2222 .off1 = offsetof(struct thread_options, allrand_repeatable),
2223 .help = "Use repeatable random numbers for everything",
2224 .def = "0",
2225 .category = FIO_OPT_C_IO,
2226 .group = FIO_OPT_G_RANDOM,
2227 },
2228 {
2229 .name = "nrfiles",
2230 .lname = "Number of files",
2231 .alias = "nr_files",
2232 .type = FIO_OPT_INT,
2233 .off1 = offsetof(struct thread_options, nr_files),
2234 .help = "Split job workload between this number of files",
2235 .def = "1",
2236 .interval = 1,
2237 .category = FIO_OPT_C_FILE,
2238 .group = FIO_OPT_G_INVALID,
2239 },
2240 {
2241 .name = "openfiles",
2242 .lname = "Number of open files",
2243 .type = FIO_OPT_INT,
2244 .off1 = offsetof(struct thread_options, open_files),
2245 .help = "Number of files to keep open at the same time",
2246 .category = FIO_OPT_C_FILE,
2247 .group = FIO_OPT_G_INVALID,
2248 },
2249 {
2250 .name = "file_service_type",
2251 .lname = "File service type",
2252 .type = FIO_OPT_STR,
2253 .cb = str_fst_cb,
2254 .off1 = offsetof(struct thread_options, file_service_type),
2255 .help = "How to select which file to service next",
2256 .def = "roundrobin",
2257 .category = FIO_OPT_C_FILE,
2258 .group = FIO_OPT_G_INVALID,
2259 .posval = {
2260 { .ival = "random",
2261 .oval = FIO_FSERVICE_RANDOM,
2262 .help = "Choose a file at random (uniform)",
2263 },
2264 { .ival = "zipf",
2265 .oval = FIO_FSERVICE_ZIPF,
2266 .help = "Zipf randomized",
2267 },
2268 { .ival = "pareto",
2269 .oval = FIO_FSERVICE_PARETO,
2270 .help = "Pareto randomized",
2271 },
2272 { .ival = "normal",
2273 .oval = FIO_FSERVICE_GAUSS,
2274 .help = "Normal (Gaussian) randomized",
2275 },
2276 { .ival = "gauss",
2277 .oval = FIO_FSERVICE_GAUSS,
2278 .help = "Alias for normal",
2279 },
2280 { .ival = "roundrobin",
2281 .oval = FIO_FSERVICE_RR,
2282 .help = "Round robin select files",
2283 },
2284 { .ival = "sequential",
2285 .oval = FIO_FSERVICE_SEQ,
2286 .help = "Finish one file before moving to the next",
2287 },
2288 },
2289 .parent = "nrfiles",
2290 .hide = 1,
2291 },
2292#if defined(CONFIG_POSIX_FALLOCATE) || defined(FIO_HAVE_NATIVE_FALLOCATE)
2293 {
2294 .name = "fallocate",
2295 .lname = "Fallocate",
2296 .type = FIO_OPT_STR,
2297 .off1 = offsetof(struct thread_options, fallocate_mode),
2298 .help = "Whether pre-allocation is performed when laying out files",
2299 .def = "native",
2300 .category = FIO_OPT_C_FILE,
2301 .group = FIO_OPT_G_INVALID,
2302 .posval = {
2303 { .ival = "none",
2304 .oval = FIO_FALLOCATE_NONE,
2305 .help = "Do not pre-allocate space",
2306 },
2307 { .ival = "native",
2308 .oval = FIO_FALLOCATE_NATIVE,
2309 .help = "Use native pre-allocation if possible",
2310 },
2311#ifdef CONFIG_POSIX_FALLOCATE
2312 { .ival = "posix",
2313 .oval = FIO_FALLOCATE_POSIX,
2314 .help = "Use posix_fallocate()",
2315 },
2316#endif
2317#ifdef CONFIG_LINUX_FALLOCATE
2318 { .ival = "keep",
2319 .oval = FIO_FALLOCATE_KEEP_SIZE,
2320 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
2321 },
2322#endif
2323 /* Compatibility with former boolean values */
2324 { .ival = "0",
2325 .oval = FIO_FALLOCATE_NONE,
2326 .help = "Alias for 'none'",
2327 },
2328#ifdef CONFIG_POSIX_FALLOCATE
2329 { .ival = "1",
2330 .oval = FIO_FALLOCATE_POSIX,
2331 .help = "Alias for 'posix'",
2332 },
2333#endif
2334 },
2335 },
2336#else /* CONFIG_POSIX_FALLOCATE */
2337 {
2338 .name = "fallocate",
2339 .lname = "Fallocate",
2340 .type = FIO_OPT_UNSUPPORTED,
2341 .help = "Your platform does not support fallocate",
2342 },
2343#endif /* CONFIG_POSIX_FALLOCATE || FIO_HAVE_NATIVE_FALLOCATE */
2344 {
2345 .name = "fadvise_hint",
2346 .lname = "Fadvise hint",
2347 .type = FIO_OPT_STR,
2348 .off1 = offsetof(struct thread_options, fadvise_hint),
2349 .posval = {
2350 { .ival = "0",
2351 .oval = F_ADV_NONE,
2352 .help = "Don't issue fadvise",
2353 },
2354 { .ival = "1",
2355 .oval = F_ADV_TYPE,
2356 .help = "Advise using fio IO pattern",
2357 },
2358 { .ival = "random",
2359 .oval = F_ADV_RANDOM,
2360 .help = "Advise using FADV_RANDOM",
2361 },
2362 { .ival = "sequential",
2363 .oval = F_ADV_SEQUENTIAL,
2364 .help = "Advise using FADV_SEQUENTIAL",
2365 },
2366 },
2367 .help = "Use fadvise() to advise the kernel on IO pattern",
2368 .def = "1",
2369 .category = FIO_OPT_C_FILE,
2370 .group = FIO_OPT_G_INVALID,
2371 },
2372 {
2373 .name = "fsync",
2374 .lname = "Fsync",
2375 .type = FIO_OPT_INT,
2376 .off1 = offsetof(struct thread_options, fsync_blocks),
2377 .help = "Issue fsync for writes every given number of blocks",
2378 .def = "0",
2379 .interval = 1,
2380 .category = FIO_OPT_C_FILE,
2381 .group = FIO_OPT_G_INVALID,
2382 },
2383 {
2384 .name = "fdatasync",
2385 .lname = "Fdatasync",
2386 .type = FIO_OPT_INT,
2387 .off1 = offsetof(struct thread_options, fdatasync_blocks),
2388 .help = "Issue fdatasync for writes every given number of blocks",
2389 .def = "0",
2390 .interval = 1,
2391 .category = FIO_OPT_C_FILE,
2392 .group = FIO_OPT_G_INVALID,
2393 },
2394 {
2395 .name = "write_barrier",
2396 .lname = "Write barrier",
2397 .type = FIO_OPT_INT,
2398 .off1 = offsetof(struct thread_options, barrier_blocks),
2399 .help = "Make every Nth write a barrier write",
2400 .def = "0",
2401 .interval = 1,
2402 .category = FIO_OPT_C_IO,
2403 .group = FIO_OPT_G_INVALID,
2404 },
2405#ifdef CONFIG_SYNC_FILE_RANGE
2406 {
2407 .name = "sync_file_range",
2408 .lname = "Sync file range",
2409 .posval = {
2410 { .ival = "wait_before",
2411 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
2412 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
2413 .orval = 1,
2414 },
2415 { .ival = "write",
2416 .oval = SYNC_FILE_RANGE_WRITE,
2417 .help = "SYNC_FILE_RANGE_WRITE",
2418 .orval = 1,
2419 },
2420 {
2421 .ival = "wait_after",
2422 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
2423 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
2424 .orval = 1,
2425 },
2426 },
2427 .type = FIO_OPT_STR_MULTI,
2428 .cb = str_sfr_cb,
2429 .off1 = offsetof(struct thread_options, sync_file_range),
2430 .help = "Use sync_file_range()",
2431 .category = FIO_OPT_C_FILE,
2432 .group = FIO_OPT_G_INVALID,
2433 },
2434#else
2435 {
2436 .name = "sync_file_range",
2437 .lname = "Sync file range",
2438 .type = FIO_OPT_UNSUPPORTED,
2439 .help = "Your platform does not support sync_file_range",
2440 },
2441#endif
2442 {
2443 .name = "direct",
2444 .lname = "Direct I/O",
2445 .type = FIO_OPT_BOOL,
2446 .off1 = offsetof(struct thread_options, odirect),
2447 .help = "Use O_DIRECT IO (negates buffered)",
2448 .def = "0",
2449 .inverse = "buffered",
2450 .category = FIO_OPT_C_IO,
2451 .group = FIO_OPT_G_IO_TYPE,
2452 },
2453 {
2454 .name = "atomic",
2455 .lname = "Atomic I/O",
2456 .type = FIO_OPT_BOOL,
2457 .off1 = offsetof(struct thread_options, oatomic),
2458 .help = "Use Atomic IO with O_DIRECT (implies O_DIRECT)",
2459 .def = "0",
2460 .category = FIO_OPT_C_IO,
2461 .group = FIO_OPT_G_IO_TYPE,
2462 },
2463 {
2464 .name = "buffered",
2465 .lname = "Buffered I/O",
2466 .type = FIO_OPT_BOOL,
2467 .off1 = offsetof(struct thread_options, odirect),
2468 .neg = 1,
2469 .help = "Use buffered IO (negates direct)",
2470 .def = "1",
2471 .inverse = "direct",
2472 .category = FIO_OPT_C_IO,
2473 .group = FIO_OPT_G_IO_TYPE,
2474 },
2475 {
2476 .name = "overwrite",
2477 .lname = "Overwrite",
2478 .type = FIO_OPT_BOOL,
2479 .off1 = offsetof(struct thread_options, overwrite),
2480 .help = "When writing, set whether to overwrite current data",
2481 .def = "0",
2482 .category = FIO_OPT_C_FILE,
2483 .group = FIO_OPT_G_INVALID,
2484 },
2485 {
2486 .name = "loops",
2487 .lname = "Loops",
2488 .type = FIO_OPT_INT,
2489 .off1 = offsetof(struct thread_options, loops),
2490 .help = "Number of times to run the job",
2491 .def = "1",
2492 .interval = 1,
2493 .category = FIO_OPT_C_GENERAL,
2494 .group = FIO_OPT_G_RUNTIME,
2495 },
2496 {
2497 .name = "numjobs",
2498 .lname = "Number of jobs",
2499 .type = FIO_OPT_INT,
2500 .off1 = offsetof(struct thread_options, numjobs),
2501 .help = "Duplicate this job this many times",
2502 .def = "1",
2503 .interval = 1,
2504 .category = FIO_OPT_C_GENERAL,
2505 .group = FIO_OPT_G_RUNTIME,
2506 },
2507 {
2508 .name = "startdelay",
2509 .lname = "Start delay",
2510 .type = FIO_OPT_STR_VAL_TIME,
2511 .off1 = offsetof(struct thread_options, start_delay),
2512 .off2 = offsetof(struct thread_options, start_delay_high),
2513 .help = "Only start job when this period has passed",
2514 .def = "0",
2515 .is_seconds = 1,
2516 .is_time = 1,
2517 .category = FIO_OPT_C_GENERAL,
2518 .group = FIO_OPT_G_RUNTIME,
2519 },
2520 {
2521 .name = "runtime",
2522 .lname = "Runtime",
2523 .alias = "timeout",
2524 .type = FIO_OPT_STR_VAL_TIME,
2525 .off1 = offsetof(struct thread_options, timeout),
2526 .help = "Stop workload when this amount of time has passed",
2527 .def = "0",
2528 .is_seconds = 1,
2529 .is_time = 1,
2530 .category = FIO_OPT_C_GENERAL,
2531 .group = FIO_OPT_G_RUNTIME,
2532 },
2533 {
2534 .name = "time_based",
2535 .lname = "Time based",
2536 .type = FIO_OPT_STR_SET,
2537 .off1 = offsetof(struct thread_options, time_based),
2538 .help = "Keep running until runtime/timeout is met",
2539 .category = FIO_OPT_C_GENERAL,
2540 .group = FIO_OPT_G_RUNTIME,
2541 },
2542 {
2543 .name = "verify_only",
2544 .lname = "Verify only",
2545 .type = FIO_OPT_STR_SET,
2546 .off1 = offsetof(struct thread_options, verify_only),
2547 .help = "Verifies previously written data is still valid",
2548 .category = FIO_OPT_C_GENERAL,
2549 .group = FIO_OPT_G_RUNTIME,
2550 },
2551 {
2552 .name = "ramp_time",
2553 .lname = "Ramp time",
2554 .type = FIO_OPT_STR_VAL_TIME,
2555 .off1 = offsetof(struct thread_options, ramp_time),
2556 .help = "Ramp up time before measuring performance",
2557 .is_seconds = 1,
2558 .is_time = 1,
2559 .category = FIO_OPT_C_GENERAL,
2560 .group = FIO_OPT_G_RUNTIME,
2561 },
2562 {
2563 .name = "clocksource",
2564 .lname = "Clock source",
2565 .type = FIO_OPT_STR,
2566 .cb = fio_clock_source_cb,
2567 .off1 = offsetof(struct thread_options, clocksource),
2568 .help = "What type of timing source to use",
2569 .category = FIO_OPT_C_GENERAL,
2570 .group = FIO_OPT_G_CLOCK,
2571 .posval = {
2572#ifdef CONFIG_GETTIMEOFDAY
2573 { .ival = "gettimeofday",
2574 .oval = CS_GTOD,
2575 .help = "Use gettimeofday(2) for timing",
2576 },
2577#endif
2578#ifdef CONFIG_CLOCK_GETTIME
2579 { .ival = "clock_gettime",
2580 .oval = CS_CGETTIME,
2581 .help = "Use clock_gettime(2) for timing",
2582 },
2583#endif
2584#ifdef ARCH_HAVE_CPU_CLOCK
2585 { .ival = "cpu",
2586 .oval = CS_CPUCLOCK,
2587 .help = "Use CPU private clock",
2588 },
2589#endif
2590 },
2591 },
2592 {
2593 .name = "mem",
2594 .alias = "iomem",
2595 .lname = "I/O Memory",
2596 .type = FIO_OPT_STR,
2597 .cb = str_mem_cb,
2598 .off1 = offsetof(struct thread_options, mem_type),
2599 .help = "Backing type for IO buffers",
2600 .def = "malloc",
2601 .category = FIO_OPT_C_IO,
2602 .group = FIO_OPT_G_INVALID,
2603 .posval = {
2604 { .ival = "malloc",
2605 .oval = MEM_MALLOC,
2606 .help = "Use malloc(3) for IO buffers",
2607 },
2608#ifndef CONFIG_NO_SHM
2609 { .ival = "shm",
2610 .oval = MEM_SHM,
2611 .help = "Use shared memory segments for IO buffers",
2612 },
2613#ifdef FIO_HAVE_HUGETLB
2614 { .ival = "shmhuge",
2615 .oval = MEM_SHMHUGE,
2616 .help = "Like shm, but use huge pages",
2617 },
2618#endif
2619#endif
2620 { .ival = "mmap",
2621 .oval = MEM_MMAP,
2622 .help = "Use mmap(2) (file or anon) for IO buffers",
2623 },
2624 { .ival = "mmapshared",
2625 .oval = MEM_MMAPSHARED,
2626 .help = "Like mmap, but use the shared flag",
2627 },
2628#ifdef FIO_HAVE_HUGETLB
2629 { .ival = "mmaphuge",
2630 .oval = MEM_MMAPHUGE,
2631 .help = "Like mmap, but use huge pages",
2632 },
2633#endif
2634#ifdef CONFIG_CUDA
2635 { .ival = "cudamalloc",
2636 .oval = MEM_CUDA_MALLOC,
2637 .help = "Allocate GPU device memory for GPUDirect RDMA",
2638 },
2639#endif
2640 },
2641 },
2642 {
2643 .name = "iomem_align",
2644 .alias = "mem_align",
2645 .lname = "I/O memory alignment",
2646 .type = FIO_OPT_INT,
2647 .off1 = offsetof(struct thread_options, mem_align),
2648 .minval = 0,
2649 .help = "IO memory buffer offset alignment",
2650 .def = "0",
2651 .parent = "iomem",
2652 .hide = 1,
2653 .category = FIO_OPT_C_IO,
2654 .group = FIO_OPT_G_INVALID,
2655 },
2656 {
2657 .name = "verify",
2658 .lname = "Verify",
2659 .type = FIO_OPT_STR,
2660 .off1 = offsetof(struct thread_options, verify),
2661 .help = "Verify data written",
2662 .def = "0",
2663 .category = FIO_OPT_C_IO,
2664 .group = FIO_OPT_G_VERIFY,
2665 .posval = {
2666 { .ival = "0",
2667 .oval = VERIFY_NONE,
2668 .help = "Don't do IO verification",
2669 },
2670 { .ival = "md5",
2671 .oval = VERIFY_MD5,
2672 .help = "Use md5 checksums for verification",
2673 },
2674 { .ival = "crc64",
2675 .oval = VERIFY_CRC64,
2676 .help = "Use crc64 checksums for verification",
2677 },
2678 { .ival = "crc32",
2679 .oval = VERIFY_CRC32,
2680 .help = "Use crc32 checksums for verification",
2681 },
2682 { .ival = "crc32c-intel",
2683 .oval = VERIFY_CRC32C,
2684 .help = "Use crc32c checksums for verification (hw assisted, if available)",
2685 },
2686 { .ival = "crc32c",
2687 .oval = VERIFY_CRC32C,
2688 .help = "Use crc32c checksums for verification (hw assisted, if available)",
2689 },
2690 { .ival = "crc16",
2691 .oval = VERIFY_CRC16,
2692 .help = "Use crc16 checksums for verification",
2693 },
2694 { .ival = "crc7",
2695 .oval = VERIFY_CRC7,
2696 .help = "Use crc7 checksums for verification",
2697 },
2698 { .ival = "sha1",
2699 .oval = VERIFY_SHA1,
2700 .help = "Use sha1 checksums for verification",
2701 },
2702 { .ival = "sha256",
2703 .oval = VERIFY_SHA256,
2704 .help = "Use sha256 checksums for verification",
2705 },
2706 { .ival = "sha512",
2707 .oval = VERIFY_SHA512,
2708 .help = "Use sha512 checksums for verification",
2709 },
2710 { .ival = "sha3-224",
2711 .oval = VERIFY_SHA3_224,
2712 .help = "Use sha3-224 checksums for verification",
2713 },
2714 { .ival = "sha3-256",
2715 .oval = VERIFY_SHA3_256,
2716 .help = "Use sha3-256 checksums for verification",
2717 },
2718 { .ival = "sha3-384",
2719 .oval = VERIFY_SHA3_384,
2720 .help = "Use sha3-384 checksums for verification",
2721 },
2722 { .ival = "sha3-512",
2723 .oval = VERIFY_SHA3_512,
2724 .help = "Use sha3-512 checksums for verification",
2725 },
2726 { .ival = "xxhash",
2727 .oval = VERIFY_XXHASH,
2728 .help = "Use xxhash checksums for verification",
2729 },
2730 /* Meta information was included into verify_header,
2731 * 'meta' verification is implied by default. */
2732 { .ival = "meta",
2733 .oval = VERIFY_HDR_ONLY,
2734 .help = "Use io information for verification. "
2735 "Now is implied by default, thus option is obsolete, "
2736 "don't use it",
2737 },
2738 { .ival = "pattern",
2739 .oval = VERIFY_PATTERN_NO_HDR,
2740 .help = "Verify strict pattern",
2741 },
2742 {
2743 .ival = "null",
2744 .oval = VERIFY_NULL,
2745 .help = "Pretend to verify",
2746 },
2747 },
2748 },
2749 {
2750 .name = "do_verify",
2751 .lname = "Perform verify step",
2752 .type = FIO_OPT_BOOL,
2753 .off1 = offsetof(struct thread_options, do_verify),
2754 .help = "Run verification stage after write",
2755 .def = "1",
2756 .parent = "verify",
2757 .hide = 1,
2758 .category = FIO_OPT_C_IO,
2759 .group = FIO_OPT_G_VERIFY,
2760 },
2761 {
2762 .name = "verifysort",
2763 .lname = "Verify sort",
2764 .type = FIO_OPT_BOOL,
2765 .off1 = offsetof(struct thread_options, verifysort),
2766 .help = "Sort written verify blocks for read back",
2767 .def = "1",
2768 .parent = "verify",
2769 .hide = 1,
2770 .category = FIO_OPT_C_IO,
2771 .group = FIO_OPT_G_VERIFY,
2772 },
2773 {
2774 .name = "verifysort_nr",
2775 .lname = "Verify Sort Nr",
2776 .type = FIO_OPT_INT,
2777 .off1 = offsetof(struct thread_options, verifysort_nr),
2778 .help = "Pre-load and sort verify blocks for a read workload",
2779 .minval = 0,
2780 .maxval = 131072,
2781 .def = "1024",
2782 .parent = "verify",
2783 .category = FIO_OPT_C_IO,
2784 .group = FIO_OPT_G_VERIFY,
2785 },
2786 {
2787 .name = "verify_interval",
2788 .lname = "Verify interval",
2789 .type = FIO_OPT_INT,
2790 .off1 = offsetof(struct thread_options, verify_interval),
2791 .minval = 2 * sizeof(struct verify_header),
2792 .help = "Store verify buffer header every N bytes",
2793 .parent = "verify",
2794 .hide = 1,
2795 .interval = 2 * sizeof(struct verify_header),
2796 .category = FIO_OPT_C_IO,
2797 .group = FIO_OPT_G_VERIFY,
2798 },
2799 {
2800 .name = "verify_offset",
2801 .lname = "Verify offset",
2802 .type = FIO_OPT_INT,
2803 .help = "Offset verify header location by N bytes",
2804 .off1 = offsetof(struct thread_options, verify_offset),
2805 .minval = sizeof(struct verify_header),
2806 .parent = "verify",
2807 .hide = 1,
2808 .category = FIO_OPT_C_IO,
2809 .group = FIO_OPT_G_VERIFY,
2810 },
2811 {
2812 .name = "verify_pattern",
2813 .lname = "Verify pattern",
2814 .type = FIO_OPT_STR,
2815 .cb = str_verify_pattern_cb,
2816 .off1 = offsetof(struct thread_options, verify_pattern),
2817 .help = "Fill pattern for IO buffers",
2818 .parent = "verify",
2819 .hide = 1,
2820 .category = FIO_OPT_C_IO,
2821 .group = FIO_OPT_G_VERIFY,
2822 },
2823 {
2824 .name = "verify_fatal",
2825 .lname = "Verify fatal",
2826 .type = FIO_OPT_BOOL,
2827 .off1 = offsetof(struct thread_options, verify_fatal),
2828 .def = "0",
2829 .help = "Exit on a single verify failure, don't continue",
2830 .parent = "verify",
2831 .hide = 1,
2832 .category = FIO_OPT_C_IO,
2833 .group = FIO_OPT_G_VERIFY,
2834 },
2835 {
2836 .name = "verify_dump",
2837 .lname = "Verify dump",
2838 .type = FIO_OPT_BOOL,
2839 .off1 = offsetof(struct thread_options, verify_dump),
2840 .def = "0",
2841 .help = "Dump contents of good and bad blocks on failure",
2842 .parent = "verify",
2843 .hide = 1,
2844 .category = FIO_OPT_C_IO,
2845 .group = FIO_OPT_G_VERIFY,
2846 },
2847 {
2848 .name = "verify_async",
2849 .lname = "Verify asynchronously",
2850 .type = FIO_OPT_INT,
2851 .off1 = offsetof(struct thread_options, verify_async),
2852 .def = "0",
2853 .help = "Number of async verifier threads to use",
2854 .parent = "verify",
2855 .hide = 1,
2856 .category = FIO_OPT_C_IO,
2857 .group = FIO_OPT_G_VERIFY,
2858 },
2859 {
2860 .name = "verify_backlog",
2861 .lname = "Verify backlog",
2862 .type = FIO_OPT_STR_VAL,
2863 .off1 = offsetof(struct thread_options, verify_backlog),
2864 .help = "Verify after this number of blocks are written",
2865 .parent = "verify",
2866 .hide = 1,
2867 .category = FIO_OPT_C_IO,
2868 .group = FIO_OPT_G_VERIFY,
2869 },
2870 {
2871 .name = "verify_backlog_batch",
2872 .lname = "Verify backlog batch",
2873 .type = FIO_OPT_INT,
2874 .off1 = offsetof(struct thread_options, verify_batch),
2875 .help = "Verify this number of IO blocks",
2876 .parent = "verify",
2877 .hide = 1,
2878 .category = FIO_OPT_C_IO,
2879 .group = FIO_OPT_G_VERIFY,
2880 },
2881#ifdef FIO_HAVE_CPU_AFFINITY
2882 {
2883 .name = "verify_async_cpus",
2884 .lname = "Async verify CPUs",
2885 .type = FIO_OPT_STR,
2886 .cb = str_verify_cpus_allowed_cb,
2887 .off1 = offsetof(struct thread_options, verify_cpumask),
2888 .help = "Set CPUs allowed for async verify threads",
2889 .parent = "verify_async",
2890 .hide = 1,
2891 .category = FIO_OPT_C_IO,
2892 .group = FIO_OPT_G_VERIFY,
2893 },
2894#else
2895 {
2896 .name = "verify_async_cpus",
2897 .lname = "Async verify CPUs",
2898 .type = FIO_OPT_UNSUPPORTED,
2899 .help = "Your platform does not support CPU affinities",
2900 },
2901#endif
2902 {
2903 .name = "experimental_verify",
2904 .lname = "Experimental Verify",
2905 .off1 = offsetof(struct thread_options, experimental_verify),
2906 .type = FIO_OPT_BOOL,
2907 .help = "Enable experimental verification",
2908 .parent = "verify",
2909 .category = FIO_OPT_C_IO,
2910 .group = FIO_OPT_G_VERIFY,
2911 },
2912 {
2913 .name = "verify_state_load",
2914 .lname = "Load verify state",
2915 .off1 = offsetof(struct thread_options, verify_state),
2916 .type = FIO_OPT_BOOL,
2917 .help = "Load verify termination state",
2918 .parent = "verify",
2919 .category = FIO_OPT_C_IO,
2920 .group = FIO_OPT_G_VERIFY,
2921 },
2922 {
2923 .name = "verify_state_save",
2924 .lname = "Save verify state",
2925 .off1 = offsetof(struct thread_options, verify_state_save),
2926 .type = FIO_OPT_BOOL,
2927 .def = "1",
2928 .help = "Save verify state on termination",
2929 .parent = "verify",
2930 .category = FIO_OPT_C_IO,
2931 .group = FIO_OPT_G_VERIFY,
2932 },
2933#ifdef FIO_HAVE_TRIM
2934 {
2935 .name = "trim_percentage",
2936 .lname = "Trim percentage",
2937 .type = FIO_OPT_INT,
2938 .off1 = offsetof(struct thread_options, trim_percentage),
2939 .minval = 0,
2940 .maxval = 100,
2941 .help = "Number of verify blocks to trim (i.e., discard)",
2942 .parent = "verify",
2943 .def = "0",
2944 .interval = 1,
2945 .hide = 1,
2946 .category = FIO_OPT_C_IO,
2947 .group = FIO_OPT_G_TRIM,
2948 },
2949 {
2950 .name = "trim_verify_zero",
2951 .lname = "Verify trim zero",
2952 .type = FIO_OPT_BOOL,
2953 .help = "Verify that trimmed (i.e., discarded) blocks are returned as zeroes",
2954 .off1 = offsetof(struct thread_options, trim_zero),
2955 .parent = "trim_percentage",
2956 .hide = 1,
2957 .def = "1",
2958 .category = FIO_OPT_C_IO,
2959 .group = FIO_OPT_G_TRIM,
2960 },
2961 {
2962 .name = "trim_backlog",
2963 .lname = "Trim backlog",
2964 .type = FIO_OPT_STR_VAL,
2965 .off1 = offsetof(struct thread_options, trim_backlog),
2966 .help = "Trim after this number of blocks are written",
2967 .parent = "trim_percentage",
2968 .hide = 1,
2969 .interval = 1,
2970 .category = FIO_OPT_C_IO,
2971 .group = FIO_OPT_G_TRIM,
2972 },
2973 {
2974 .name = "trim_backlog_batch",
2975 .lname = "Trim backlog batch",
2976 .type = FIO_OPT_INT,
2977 .off1 = offsetof(struct thread_options, trim_batch),
2978 .help = "Trim this number of IO blocks",
2979 .parent = "trim_percentage",
2980 .hide = 1,
2981 .interval = 1,
2982 .category = FIO_OPT_C_IO,
2983 .group = FIO_OPT_G_TRIM,
2984 },
2985#else
2986 {
2987 .name = "trim_percentage",
2988 .lname = "Trim percentage",
2989 .type = FIO_OPT_UNSUPPORTED,
2990 .help = "Fio does not support TRIM on your platform",
2991 },
2992 {
2993 .name = "trim_verify_zero",
2994 .lname = "Verify trim zero",
2995 .type = FIO_OPT_UNSUPPORTED,
2996 .help = "Fio does not support TRIM on your platform",
2997 },
2998 {
2999 .name = "trim_backlog",
3000 .lname = "Trim backlog",
3001 .type = FIO_OPT_UNSUPPORTED,
3002 .help = "Fio does not support TRIM on your platform",
3003 },
3004 {
3005 .name = "trim_backlog_batch",
3006 .lname = "Trim backlog batch",
3007 .type = FIO_OPT_UNSUPPORTED,
3008 .help = "Fio does not support TRIM on your platform",
3009 },
3010#endif
3011 {
3012 .name = "write_iolog",
3013 .lname = "Write I/O log",
3014 .type = FIO_OPT_STR_STORE,
3015 .off1 = offsetof(struct thread_options, write_iolog_file),
3016 .help = "Store IO pattern to file",
3017 .category = FIO_OPT_C_IO,
3018 .group = FIO_OPT_G_IOLOG,
3019 },
3020 {
3021 .name = "read_iolog",
3022 .lname = "Read I/O log",
3023 .type = FIO_OPT_STR_STORE,
3024 .off1 = offsetof(struct thread_options, read_iolog_file),
3025 .help = "Playback IO pattern from file",
3026 .category = FIO_OPT_C_IO,
3027 .group = FIO_OPT_G_IOLOG,
3028 },
3029 {
3030 .name = "replay_no_stall",
3031 .lname = "Don't stall on replay",
3032 .type = FIO_OPT_BOOL,
3033 .off1 = offsetof(struct thread_options, no_stall),
3034 .def = "0",
3035 .parent = "read_iolog",
3036 .hide = 1,
3037 .help = "Playback IO pattern file as fast as possible without stalls",
3038 .category = FIO_OPT_C_IO,
3039 .group = FIO_OPT_G_IOLOG,
3040 },
3041 {
3042 .name = "replay_redirect",
3043 .lname = "Redirect device for replay",
3044 .type = FIO_OPT_STR_STORE,
3045 .off1 = offsetof(struct thread_options, replay_redirect),
3046 .parent = "read_iolog",
3047 .hide = 1,
3048 .help = "Replay all I/O onto this device, regardless of trace device",
3049 .category = FIO_OPT_C_IO,
3050 .group = FIO_OPT_G_IOLOG,
3051 },
3052 {
3053 .name = "replay_scale",
3054 .lname = "Replace offset scale factor",
3055 .type = FIO_OPT_INT,
3056 .off1 = offsetof(struct thread_options, replay_scale),
3057 .parent = "read_iolog",
3058 .def = "1",
3059 .help = "Align offsets to this blocksize",
3060 .category = FIO_OPT_C_IO,
3061 .group = FIO_OPT_G_IOLOG,
3062 },
3063 {
3064 .name = "replay_align",
3065 .lname = "Replace alignment",
3066 .type = FIO_OPT_INT,
3067 .off1 = offsetof(struct thread_options, replay_align),
3068 .parent = "read_iolog",
3069 .help = "Scale offset down by this factor",
3070 .category = FIO_OPT_C_IO,
3071 .group = FIO_OPT_G_IOLOG,
3072 .pow2 = 1,
3073 },
3074 {
3075 .name = "exec_prerun",
3076 .lname = "Pre-execute runnable",
3077 .type = FIO_OPT_STR_STORE,
3078 .off1 = offsetof(struct thread_options, exec_prerun),
3079 .help = "Execute this file prior to running job",
3080 .category = FIO_OPT_C_GENERAL,
3081 .group = FIO_OPT_G_INVALID,
3082 },
3083 {
3084 .name = "exec_postrun",
3085 .lname = "Post-execute runnable",
3086 .type = FIO_OPT_STR_STORE,
3087 .off1 = offsetof(struct thread_options, exec_postrun),
3088 .help = "Execute this file after running job",
3089 .category = FIO_OPT_C_GENERAL,
3090 .group = FIO_OPT_G_INVALID,
3091 },
3092#ifdef FIO_HAVE_IOSCHED_SWITCH
3093 {
3094 .name = "ioscheduler",
3095 .lname = "I/O scheduler",
3096 .type = FIO_OPT_STR_STORE,
3097 .off1 = offsetof(struct thread_options, ioscheduler),
3098 .help = "Use this IO scheduler on the backing device",
3099 .category = FIO_OPT_C_FILE,
3100 .group = FIO_OPT_G_INVALID,
3101 },
3102#else
3103 {
3104 .name = "ioscheduler",
3105 .lname = "I/O scheduler",
3106 .type = FIO_OPT_UNSUPPORTED,
3107 .help = "Your platform does not support IO scheduler switching",
3108 },
3109#endif
3110 {
3111 .name = "zonesize",
3112 .lname = "Zone size",
3113 .type = FIO_OPT_STR_VAL,
3114 .off1 = offsetof(struct thread_options, zone_size),
3115 .help = "Amount of data to read per zone",
3116 .def = "0",
3117 .interval = 1024 * 1024,
3118 .category = FIO_OPT_C_IO,
3119 .group = FIO_OPT_G_ZONE,
3120 },
3121 {
3122 .name = "zonerange",
3123 .lname = "Zone range",
3124 .type = FIO_OPT_STR_VAL,
3125 .off1 = offsetof(struct thread_options, zone_range),
3126 .help = "Give size of an IO zone",
3127 .def = "0",
3128 .interval = 1024 * 1024,
3129 .category = FIO_OPT_C_IO,
3130 .group = FIO_OPT_G_ZONE,
3131 },
3132 {
3133 .name = "zoneskip",
3134 .lname = "Zone skip",
3135 .type = FIO_OPT_STR_VAL,
3136 .off1 = offsetof(struct thread_options, zone_skip),
3137 .help = "Space between IO zones",
3138 .def = "0",
3139 .interval = 1024 * 1024,
3140 .category = FIO_OPT_C_IO,
3141 .group = FIO_OPT_G_ZONE,
3142 },
3143 {
3144 .name = "lockmem",
3145 .lname = "Lock memory",
3146 .type = FIO_OPT_STR_VAL,
3147 .off1 = offsetof(struct thread_options, lockmem),
3148 .help = "Lock down this amount of memory (per worker)",
3149 .def = "0",
3150 .interval = 1024 * 1024,
3151 .category = FIO_OPT_C_GENERAL,
3152 .group = FIO_OPT_G_INVALID,
3153 },
3154 {
3155 .name = "rwmixread",
3156 .lname = "Read/write mix read",
3157 .type = FIO_OPT_INT,
3158 .cb = str_rwmix_read_cb,
3159 .off1 = offsetof(struct thread_options, rwmix[DDIR_READ]),
3160 .maxval = 100,
3161 .help = "Percentage of mixed workload that is reads",
3162 .def = "50",
3163 .interval = 5,
3164 .inverse = "rwmixwrite",
3165 .category = FIO_OPT_C_IO,
3166 .group = FIO_OPT_G_RWMIX,
3167 },
3168 {
3169 .name = "rwmixwrite",
3170 .lname = "Read/write mix write",
3171 .type = FIO_OPT_INT,
3172 .cb = str_rwmix_write_cb,
3173 .off1 = offsetof(struct thread_options, rwmix[DDIR_WRITE]),
3174 .maxval = 100,
3175 .help = "Percentage of mixed workload that is writes",
3176 .def = "50",
3177 .interval = 5,
3178 .inverse = "rwmixread",
3179 .category = FIO_OPT_C_IO,
3180 .group = FIO_OPT_G_RWMIX,
3181 },
3182 {
3183 .name = "rwmixcycle",
3184 .lname = "Read/write mix cycle",
3185 .type = FIO_OPT_DEPRECATED,
3186 .category = FIO_OPT_C_IO,
3187 .group = FIO_OPT_G_RWMIX,
3188 },
3189 {
3190 .name = "nice",
3191 .lname = "Nice",
3192 .type = FIO_OPT_INT,
3193 .off1 = offsetof(struct thread_options, nice),
3194 .help = "Set job CPU nice value",
3195 .minval = -19,
3196 .maxval = 20,
3197 .def = "0",
3198 .interval = 1,
3199 .category = FIO_OPT_C_GENERAL,
3200 .group = FIO_OPT_G_CRED,
3201 },
3202#ifdef FIO_HAVE_IOPRIO
3203 {
3204 .name = "prio",
3205 .lname = "I/O nice priority",
3206 .type = FIO_OPT_INT,
3207 .off1 = offsetof(struct thread_options, ioprio),
3208 .help = "Set job IO priority value",
3209 .minval = IOPRIO_MIN_PRIO,
3210 .maxval = IOPRIO_MAX_PRIO,
3211 .interval = 1,
3212 .category = FIO_OPT_C_GENERAL,
3213 .group = FIO_OPT_G_CRED,
3214 },
3215#else
3216 {
3217 .name = "prio",
3218 .lname = "I/O nice priority",
3219 .type = FIO_OPT_UNSUPPORTED,
3220 .help = "Your platform does not support IO priorities",
3221 },
3222#endif
3223#ifdef FIO_HAVE_IOPRIO_CLASS
3224#ifndef FIO_HAVE_IOPRIO
3225#error "FIO_HAVE_IOPRIO_CLASS requires FIO_HAVE_IOPRIO"
3226#endif
3227 {
3228 .name = "prioclass",
3229 .lname = "I/O nice priority class",
3230 .type = FIO_OPT_INT,
3231 .off1 = offsetof(struct thread_options, ioprio_class),
3232 .help = "Set job IO priority class",
3233 .minval = IOPRIO_MIN_PRIO_CLASS,
3234 .maxval = IOPRIO_MAX_PRIO_CLASS,
3235 .interval = 1,
3236 .category = FIO_OPT_C_GENERAL,
3237 .group = FIO_OPT_G_CRED,
3238 },
3239#else
3240 {
3241 .name = "prioclass",
3242 .lname = "I/O nice priority class",
3243 .type = FIO_OPT_UNSUPPORTED,
3244 .help = "Your platform does not support IO priority classes",
3245 },
3246#endif
3247 {
3248 .name = "thinktime",
3249 .lname = "Thinktime",
3250 .type = FIO_OPT_INT,
3251 .off1 = offsetof(struct thread_options, thinktime),
3252 .help = "Idle time between IO buffers (usec)",
3253 .def = "0",
3254 .is_time = 1,
3255 .category = FIO_OPT_C_IO,
3256 .group = FIO_OPT_G_THINKTIME,
3257 },
3258 {
3259 .name = "thinktime_spin",
3260 .lname = "Thinktime spin",
3261 .type = FIO_OPT_INT,
3262 .off1 = offsetof(struct thread_options, thinktime_spin),
3263 .help = "Start think time by spinning this amount (usec)",
3264 .def = "0",
3265 .is_time = 1,
3266 .parent = "thinktime",
3267 .hide = 1,
3268 .category = FIO_OPT_C_IO,
3269 .group = FIO_OPT_G_THINKTIME,
3270 },
3271 {
3272 .name = "thinktime_blocks",
3273 .lname = "Thinktime blocks",
3274 .type = FIO_OPT_INT,
3275 .off1 = offsetof(struct thread_options, thinktime_blocks),
3276 .help = "IO buffer period between 'thinktime'",
3277 .def = "1",
3278 .parent = "thinktime",
3279 .hide = 1,
3280 .category = FIO_OPT_C_IO,
3281 .group = FIO_OPT_G_THINKTIME,
3282 },
3283 {
3284 .name = "rate",
3285 .lname = "I/O rate",
3286 .type = FIO_OPT_INT,
3287 .off1 = offsetof(struct thread_options, rate[DDIR_READ]),
3288 .off2 = offsetof(struct thread_options, rate[DDIR_WRITE]),
3289 .off3 = offsetof(struct thread_options, rate[DDIR_TRIM]),
3290 .help = "Set bandwidth rate",
3291 .category = FIO_OPT_C_IO,
3292 .group = FIO_OPT_G_RATE,
3293 },
3294 {
3295 .name = "rate_min",
3296 .alias = "ratemin",
3297 .lname = "I/O min rate",
3298 .type = FIO_OPT_INT,
3299 .off1 = offsetof(struct thread_options, ratemin[DDIR_READ]),
3300 .off2 = offsetof(struct thread_options, ratemin[DDIR_WRITE]),
3301 .off3 = offsetof(struct thread_options, ratemin[DDIR_TRIM]),
3302 .help = "Job must meet this rate or it will be shutdown",
3303 .parent = "rate",
3304 .hide = 1,
3305 .category = FIO_OPT_C_IO,
3306 .group = FIO_OPT_G_RATE,
3307 },
3308 {
3309 .name = "rate_iops",
3310 .lname = "I/O rate IOPS",
3311 .type = FIO_OPT_INT,
3312 .off1 = offsetof(struct thread_options, rate_iops[DDIR_READ]),
3313 .off2 = offsetof(struct thread_options, rate_iops[DDIR_WRITE]),
3314 .off3 = offsetof(struct thread_options, rate_iops[DDIR_TRIM]),
3315 .help = "Limit IO used to this number of IO operations/sec",
3316 .hide = 1,
3317 .category = FIO_OPT_C_IO,
3318 .group = FIO_OPT_G_RATE,
3319 },
3320 {
3321 .name = "rate_iops_min",
3322 .lname = "I/O min rate IOPS",
3323 .type = FIO_OPT_INT,
3324 .off1 = offsetof(struct thread_options, rate_iops_min[DDIR_READ]),
3325 .off2 = offsetof(struct thread_options, rate_iops_min[DDIR_WRITE]),
3326 .off3 = offsetof(struct thread_options, rate_iops_min[DDIR_TRIM]),
3327 .help = "Job must meet this rate or it will be shut down",
3328 .parent = "rate_iops",
3329 .hide = 1,
3330 .category = FIO_OPT_C_IO,
3331 .group = FIO_OPT_G_RATE,
3332 },
3333 {
3334 .name = "rate_process",
3335 .lname = "Rate Process",
3336 .type = FIO_OPT_STR,
3337 .off1 = offsetof(struct thread_options, rate_process),
3338 .help = "What process controls how rated IO is managed",
3339 .def = "linear",
3340 .category = FIO_OPT_C_IO,
3341 .group = FIO_OPT_G_RATE,
3342 .posval = {
3343 { .ival = "linear",
3344 .oval = RATE_PROCESS_LINEAR,
3345 .help = "Linear rate of IO",
3346 },
3347 {
3348 .ival = "poisson",
3349 .oval = RATE_PROCESS_POISSON,
3350 .help = "Rate follows Poisson process",
3351 },
3352 },
3353 .parent = "rate",
3354 },
3355 {
3356 .name = "rate_cycle",
3357 .alias = "ratecycle",
3358 .lname = "I/O rate cycle",
3359 .type = FIO_OPT_INT,
3360 .off1 = offsetof(struct thread_options, ratecycle),
3361 .help = "Window average for rate limits (msec)",
3362 .def = "1000",
3363 .parent = "rate",
3364 .hide = 1,
3365 .category = FIO_OPT_C_IO,
3366 .group = FIO_OPT_G_RATE,
3367 },
3368 {
3369 .name = "max_latency",
3370 .lname = "Max Latency",
3371 .type = FIO_OPT_INT,
3372 .off1 = offsetof(struct thread_options, max_latency),
3373 .help = "Maximum tolerated IO latency (usec)",
3374 .is_time = 1,
3375 .category = FIO_OPT_C_IO,
3376 .group = FIO_OPT_G_LATPROF,
3377 },
3378 {
3379 .name = "latency_target",
3380 .lname = "Latency Target (usec)",
3381 .type = FIO_OPT_STR_VAL_TIME,
3382 .off1 = offsetof(struct thread_options, latency_target),
3383 .help = "Ramp to max queue depth supporting this latency",
3384 .is_time = 1,
3385 .category = FIO_OPT_C_IO,
3386 .group = FIO_OPT_G_LATPROF,
3387 },
3388 {
3389 .name = "latency_window",
3390 .lname = "Latency Window (usec)",
3391 .type = FIO_OPT_STR_VAL_TIME,
3392 .off1 = offsetof(struct thread_options, latency_window),
3393 .help = "Time to sustain latency_target",
3394 .is_time = 1,
3395 .category = FIO_OPT_C_IO,
3396 .group = FIO_OPT_G_LATPROF,
3397 },
3398 {
3399 .name = "latency_percentile",
3400 .lname = "Latency Percentile",
3401 .type = FIO_OPT_FLOAT_LIST,
3402 .off1 = offsetof(struct thread_options, latency_percentile),
3403 .help = "Percentile of IOs must be below latency_target",
3404 .def = "100",
3405 .maxlen = 1,
3406 .minfp = 0.0,
3407 .maxfp = 100.0,
3408 .category = FIO_OPT_C_IO,
3409 .group = FIO_OPT_G_LATPROF,
3410 },
3411 {
3412 .name = "invalidate",
3413 .lname = "Cache invalidate",
3414 .type = FIO_OPT_BOOL,
3415 .off1 = offsetof(struct thread_options, invalidate_cache),
3416 .help = "Invalidate buffer/page cache prior to running job",
3417 .def = "1",
3418 .category = FIO_OPT_C_IO,
3419 .group = FIO_OPT_G_IO_TYPE,
3420 },
3421 {
3422 .name = "sync",
3423 .lname = "Synchronous I/O",
3424 .type = FIO_OPT_BOOL,
3425 .off1 = offsetof(struct thread_options, sync_io),
3426 .help = "Use O_SYNC for buffered writes",
3427 .def = "0",
3428 .parent = "buffered",
3429 .hide = 1,
3430 .category = FIO_OPT_C_IO,
3431 .group = FIO_OPT_G_IO_TYPE,
3432 },
3433#ifdef FIO_HAVE_WRITE_HINT
3434 {
3435 .name = "write_hint",
3436 .lname = "Write hint",
3437 .type = FIO_OPT_STR,
3438 .off1 = offsetof(struct thread_options, write_hint),
3439 .help = "Set expected write life time",
3440 .category = FIO_OPT_C_ENGINE,
3441 .group = FIO_OPT_G_INVALID,
3442 .posval = {
3443 { .ival = "none",
3444 .oval = RWH_WRITE_LIFE_NONE,
3445 },
3446 { .ival = "short",
3447 .oval = RWH_WRITE_LIFE_SHORT,
3448 },
3449 { .ival = "medium",
3450 .oval = RWH_WRITE_LIFE_MEDIUM,
3451 },
3452 { .ival = "long",
3453 .oval = RWH_WRITE_LIFE_LONG,
3454 },
3455 { .ival = "extreme",
3456 .oval = RWH_WRITE_LIFE_EXTREME,
3457 },
3458 },
3459 },
3460#endif
3461 {
3462 .name = "create_serialize",
3463 .lname = "Create serialize",
3464 .type = FIO_OPT_BOOL,
3465 .off1 = offsetof(struct thread_options, create_serialize),
3466 .help = "Serialize creation of job files",
3467 .def = "1",
3468 .category = FIO_OPT_C_FILE,
3469 .group = FIO_OPT_G_INVALID,
3470 },
3471 {
3472 .name = "create_fsync",
3473 .lname = "Create fsync",
3474 .type = FIO_OPT_BOOL,
3475 .off1 = offsetof(struct thread_options, create_fsync),
3476 .help = "fsync file after creation",
3477 .def = "1",
3478 .category = FIO_OPT_C_FILE,
3479 .group = FIO_OPT_G_INVALID,
3480 },
3481 {
3482 .name = "create_on_open",
3483 .lname = "Create on open",
3484 .type = FIO_OPT_BOOL,
3485 .off1 = offsetof(struct thread_options, create_on_open),
3486 .help = "Create files when they are opened for IO",
3487 .def = "0",
3488 .category = FIO_OPT_C_FILE,
3489 .group = FIO_OPT_G_INVALID,
3490 },
3491 {
3492 .name = "create_only",
3493 .lname = "Create Only",
3494 .type = FIO_OPT_BOOL,
3495 .off1 = offsetof(struct thread_options, create_only),
3496 .help = "Only perform file creation phase",
3497 .category = FIO_OPT_C_FILE,
3498 .def = "0",
3499 },
3500 {
3501 .name = "allow_file_create",
3502 .lname = "Allow file create",
3503 .type = FIO_OPT_BOOL,
3504 .off1 = offsetof(struct thread_options, allow_create),
3505 .help = "Permit fio to create files, if they don't exist",
3506 .def = "1",
3507 .category = FIO_OPT_C_FILE,
3508 .group = FIO_OPT_G_FILENAME,
3509 },
3510 {
3511 .name = "allow_mounted_write",
3512 .lname = "Allow mounted write",
3513 .type = FIO_OPT_BOOL,
3514 .off1 = offsetof(struct thread_options, allow_mounted_write),
3515 .help = "Allow writes to a mounted partition",
3516 .def = "0",
3517 .category = FIO_OPT_C_FILE,
3518 .group = FIO_OPT_G_FILENAME,
3519 },
3520 {
3521 .name = "pre_read",
3522 .lname = "Pre-read files",
3523 .type = FIO_OPT_BOOL,
3524 .off1 = offsetof(struct thread_options, pre_read),
3525 .help = "Pre-read files before starting official testing",
3526 .def = "0",
3527 .category = FIO_OPT_C_FILE,
3528 .group = FIO_OPT_G_INVALID,
3529 },
3530#ifdef FIO_HAVE_CPU_AFFINITY
3531 {
3532 .name = "cpumask",
3533 .lname = "CPU mask",
3534 .type = FIO_OPT_INT,
3535 .cb = str_cpumask_cb,
3536 .off1 = offsetof(struct thread_options, cpumask),
3537 .help = "CPU affinity mask",
3538 .category = FIO_OPT_C_GENERAL,
3539 .group = FIO_OPT_G_CRED,
3540 },
3541 {
3542 .name = "cpus_allowed",
3543 .lname = "CPUs allowed",
3544 .type = FIO_OPT_STR,
3545 .cb = str_cpus_allowed_cb,
3546 .off1 = offsetof(struct thread_options, cpumask),
3547 .help = "Set CPUs allowed",
3548 .category = FIO_OPT_C_GENERAL,
3549 .group = FIO_OPT_G_CRED,
3550 },
3551 {
3552 .name = "cpus_allowed_policy",
3553 .lname = "CPUs allowed distribution policy",
3554 .type = FIO_OPT_STR,
3555 .off1 = offsetof(struct thread_options, cpus_allowed_policy),
3556 .help = "Distribution policy for cpus_allowed",
3557 .parent = "cpus_allowed",
3558 .prio = 1,
3559 .posval = {
3560 { .ival = "shared",
3561 .oval = FIO_CPUS_SHARED,
3562 .help = "Mask shared between threads",
3563 },
3564 { .ival = "split",
3565 .oval = FIO_CPUS_SPLIT,
3566 .help = "Mask split between threads",
3567 },
3568 },
3569 .category = FIO_OPT_C_GENERAL,
3570 .group = FIO_OPT_G_CRED,
3571 },
3572#else
3573 {
3574 .name = "cpumask",
3575 .lname = "CPU mask",
3576 .type = FIO_OPT_UNSUPPORTED,
3577 .help = "Your platform does not support CPU affinities",
3578 },
3579 {
3580 .name = "cpus_allowed",
3581 .lname = "CPUs allowed",
3582 .type = FIO_OPT_UNSUPPORTED,
3583 .help = "Your platform does not support CPU affinities",
3584 },
3585 {
3586 .name = "cpus_allowed_policy",
3587 .lname = "CPUs allowed distribution policy",
3588 .type = FIO_OPT_UNSUPPORTED,
3589 .help = "Your platform does not support CPU affinities",
3590 },
3591#endif
3592#ifdef CONFIG_LIBNUMA
3593 {
3594 .name = "numa_cpu_nodes",
3595 .lname = "NUMA CPU Nodes",
3596 .type = FIO_OPT_STR,
3597 .cb = str_numa_cpunodes_cb,
3598 .off1 = offsetof(struct thread_options, numa_cpunodes),
3599 .help = "NUMA CPU nodes bind",
3600 .category = FIO_OPT_C_GENERAL,
3601 .group = FIO_OPT_G_INVALID,
3602 },
3603 {
3604 .name = "numa_mem_policy",
3605 .lname = "NUMA Memory Policy",
3606 .type = FIO_OPT_STR,
3607 .cb = str_numa_mpol_cb,
3608 .off1 = offsetof(struct thread_options, numa_memnodes),
3609 .help = "NUMA memory policy setup",
3610 .category = FIO_OPT_C_GENERAL,
3611 .group = FIO_OPT_G_INVALID,
3612 },
3613#else
3614 {
3615 .name = "numa_cpu_nodes",
3616 .lname = "NUMA CPU Nodes",
3617 .type = FIO_OPT_UNSUPPORTED,
3618 .help = "Build fio with libnuma-dev(el) to enable this option",
3619 },
3620 {
3621 .name = "numa_mem_policy",
3622 .lname = "NUMA Memory Policy",
3623 .type = FIO_OPT_UNSUPPORTED,
3624 .help = "Build fio with libnuma-dev(el) to enable this option",
3625 },
3626#endif
3627#ifdef CONFIG_CUDA
3628 {
3629 .name = "gpu_dev_id",
3630 .lname = "GPU device ID",
3631 .type = FIO_OPT_INT,
3632 .off1 = offsetof(struct thread_options, gpu_dev_id),
3633 .help = "Set GPU device ID for GPUDirect RDMA",
3634 .def = "0",
3635 .category = FIO_OPT_C_GENERAL,
3636 .group = FIO_OPT_G_INVALID,
3637 },
3638#endif
3639 {
3640 .name = "end_fsync",
3641 .lname = "End fsync",
3642 .type = FIO_OPT_BOOL,
3643 .off1 = offsetof(struct thread_options, end_fsync),
3644 .help = "Include fsync at the end of job",
3645 .def = "0",
3646 .category = FIO_OPT_C_FILE,
3647 .group = FIO_OPT_G_INVALID,
3648 },
3649 {
3650 .name = "fsync_on_close",
3651 .lname = "Fsync on close",
3652 .type = FIO_OPT_BOOL,
3653 .off1 = offsetof(struct thread_options, fsync_on_close),
3654 .help = "fsync files on close",
3655 .def = "0",
3656 .category = FIO_OPT_C_FILE,
3657 .group = FIO_OPT_G_INVALID,
3658 },
3659 {
3660 .name = "unlink",
3661 .lname = "Unlink file",
3662 .type = FIO_OPT_BOOL,
3663 .off1 = offsetof(struct thread_options, unlink),
3664 .help = "Unlink created files after job has completed",
3665 .def = "0",
3666 .category = FIO_OPT_C_FILE,
3667 .group = FIO_OPT_G_INVALID,
3668 },
3669 {
3670 .name = "unlink_each_loop",
3671 .lname = "Unlink file after each loop of a job",
3672 .type = FIO_OPT_BOOL,
3673 .off1 = offsetof(struct thread_options, unlink_each_loop),
3674 .help = "Unlink created files after each loop in a job has completed",
3675 .def = "0",
3676 .category = FIO_OPT_C_FILE,
3677 .group = FIO_OPT_G_INVALID,
3678 },
3679 {
3680 .name = "exitall",
3681 .lname = "Exit-all on terminate",
3682 .type = FIO_OPT_STR_SET,
3683 .cb = str_exitall_cb,
3684 .help = "Terminate all jobs when one exits",
3685 .category = FIO_OPT_C_GENERAL,
3686 .group = FIO_OPT_G_PROCESS,
3687 },
3688 {
3689 .name = "exitall_on_error",
3690 .lname = "Exit-all on terminate in error",
3691 .type = FIO_OPT_STR_SET,
3692 .off1 = offsetof(struct thread_options, exitall_error),
3693 .help = "Terminate all jobs when one exits in error",
3694 .category = FIO_OPT_C_GENERAL,
3695 .group = FIO_OPT_G_PROCESS,
3696 },
3697 {
3698 .name = "stonewall",
3699 .lname = "Wait for previous",
3700 .alias = "wait_for_previous",
3701 .type = FIO_OPT_STR_SET,
3702 .off1 = offsetof(struct thread_options, stonewall),
3703 .help = "Insert a hard barrier between this job and previous",
3704 .category = FIO_OPT_C_GENERAL,
3705 .group = FIO_OPT_G_PROCESS,
3706 },
3707 {
3708 .name = "new_group",
3709 .lname = "New group",
3710 .type = FIO_OPT_STR_SET,
3711 .off1 = offsetof(struct thread_options, new_group),
3712 .help = "Mark the start of a new group (for reporting)",
3713 .category = FIO_OPT_C_GENERAL,
3714 .group = FIO_OPT_G_PROCESS,
3715 },
3716 {
3717 .name = "thread",
3718 .lname = "Thread",
3719 .type = FIO_OPT_STR_SET,
3720 .off1 = offsetof(struct thread_options, use_thread),
3721 .help = "Use threads instead of processes",
3722#ifdef CONFIG_NO_SHM
3723 .def = "1",
3724 .no_warn_def = 1,
3725#endif
3726 .category = FIO_OPT_C_GENERAL,
3727 .group = FIO_OPT_G_PROCESS,
3728 },
3729 {
3730 .name = "per_job_logs",
3731 .lname = "Per Job Logs",
3732 .type = FIO_OPT_BOOL,
3733 .off1 = offsetof(struct thread_options, per_job_logs),
3734 .help = "Include job number in generated log files or not",
3735 .def = "1",
3736 .category = FIO_OPT_C_LOG,
3737 .group = FIO_OPT_G_INVALID,
3738 },
3739 {
3740 .name = "write_bw_log",
3741 .lname = "Write bandwidth log",
3742 .type = FIO_OPT_STR,
3743 .off1 = offsetof(struct thread_options, bw_log_file),
3744 .cb = str_write_bw_log_cb,
3745 .help = "Write log of bandwidth during run",
3746 .category = FIO_OPT_C_LOG,
3747 .group = FIO_OPT_G_INVALID,
3748 },
3749 {
3750 .name = "write_lat_log",
3751 .lname = "Write latency log",
3752 .type = FIO_OPT_STR,
3753 .off1 = offsetof(struct thread_options, lat_log_file),
3754 .cb = str_write_lat_log_cb,
3755 .help = "Write log of latency during run",
3756 .category = FIO_OPT_C_LOG,
3757 .group = FIO_OPT_G_INVALID,
3758 },
3759 {
3760 .name = "write_iops_log",
3761 .lname = "Write IOPS log",
3762 .type = FIO_OPT_STR,
3763 .off1 = offsetof(struct thread_options, iops_log_file),
3764 .cb = str_write_iops_log_cb,
3765 .help = "Write log of IOPS during run",
3766 .category = FIO_OPT_C_LOG,
3767 .group = FIO_OPT_G_INVALID,
3768 },
3769 {
3770 .name = "log_avg_msec",
3771 .lname = "Log averaging (msec)",
3772 .type = FIO_OPT_INT,
3773 .off1 = offsetof(struct thread_options, log_avg_msec),
3774 .help = "Average bw/iops/lat logs over this period of time",
3775 .def = "0",
3776 .category = FIO_OPT_C_LOG,
3777 .group = FIO_OPT_G_INVALID,
3778 },
3779 {
3780 .name = "log_hist_msec",
3781 .lname = "Log histograms (msec)",
3782 .type = FIO_OPT_INT,
3783 .off1 = offsetof(struct thread_options, log_hist_msec),
3784 .help = "Dump completion latency histograms at frequency of this time value",
3785 .def = "0",
3786 .category = FIO_OPT_C_LOG,
3787 .group = FIO_OPT_G_INVALID,
3788 },
3789 {
3790 .name = "log_hist_coarseness",
3791 .lname = "Histogram logs coarseness",
3792 .type = FIO_OPT_INT,
3793 .off1 = offsetof(struct thread_options, log_hist_coarseness),
3794 .help = "Integer in range [0,6]. Higher coarseness outputs"
3795 " fewer histogram bins per sample. The number of bins for"
3796 " these are [1216, 608, 304, 152, 76, 38, 19] respectively.",
3797 .def = "0",
3798 .category = FIO_OPT_C_LOG,
3799 .group = FIO_OPT_G_INVALID,
3800 },
3801 {
3802 .name = "write_hist_log",
3803 .lname = "Write latency histogram logs",
3804 .type = FIO_OPT_STR,
3805 .off1 = offsetof(struct thread_options, hist_log_file),
3806 .cb = str_write_hist_log_cb,
3807 .help = "Write log of latency histograms during run",
3808 .category = FIO_OPT_C_LOG,
3809 .group = FIO_OPT_G_INVALID,
3810 },
3811 {
3812 .name = "log_max_value",
3813 .lname = "Log maximum instead of average",
3814 .type = FIO_OPT_BOOL,
3815 .off1 = offsetof(struct thread_options, log_max),
3816 .help = "Log max sample in a window instead of average",
3817 .def = "0",
3818 .category = FIO_OPT_C_LOG,
3819 .group = FIO_OPT_G_INVALID,
3820 },
3821 {
3822 .name = "log_offset",
3823 .lname = "Log offset of IO",
3824 .type = FIO_OPT_BOOL,
3825 .off1 = offsetof(struct thread_options, log_offset),
3826 .help = "Include offset of IO for each log entry",
3827 .def = "0",
3828 .category = FIO_OPT_C_LOG,
3829 .group = FIO_OPT_G_INVALID,
3830 },
3831#ifdef CONFIG_ZLIB
3832 {
3833 .name = "log_compression",
3834 .lname = "Log compression",
3835 .type = FIO_OPT_INT,
3836 .off1 = offsetof(struct thread_options, log_gz),
3837 .help = "Log in compressed chunks of this size",
3838 .minval = 1024ULL,
3839 .maxval = 512 * 1024 * 1024ULL,
3840 .category = FIO_OPT_C_LOG,
3841 .group = FIO_OPT_G_INVALID,
3842 },
3843#ifdef FIO_HAVE_CPU_AFFINITY
3844 {
3845 .name = "log_compression_cpus",
3846 .lname = "Log Compression CPUs",
3847 .type = FIO_OPT_STR,
3848 .cb = str_log_cpus_allowed_cb,
3849 .off1 = offsetof(struct thread_options, log_gz_cpumask),
3850 .parent = "log_compression",
3851 .help = "Limit log compression to these CPUs",
3852 .category = FIO_OPT_C_LOG,
3853 .group = FIO_OPT_G_INVALID,
3854 },
3855#else
3856 {
3857 .name = "log_compression_cpus",
3858 .lname = "Log Compression CPUs",
3859 .type = FIO_OPT_UNSUPPORTED,
3860 .help = "Your platform does not support CPU affinities",
3861 },
3862#endif
3863 {
3864 .name = "log_store_compressed",
3865 .lname = "Log store compressed",
3866 .type = FIO_OPT_BOOL,
3867 .off1 = offsetof(struct thread_options, log_gz_store),
3868 .help = "Store logs in a compressed format",
3869 .category = FIO_OPT_C_LOG,
3870 .group = FIO_OPT_G_INVALID,
3871 },
3872#else
3873 {
3874 .name = "log_compression",
3875 .lname = "Log compression",
3876 .type = FIO_OPT_UNSUPPORTED,
3877 .help = "Install libz-dev(el) to get compression support",
3878 },
3879 {
3880 .name = "log_store_compressed",
3881 .lname = "Log store compressed",
3882 .type = FIO_OPT_UNSUPPORTED,
3883 .help = "Install libz-dev(el) to get compression support",
3884 },
3885#endif
3886 {
3887 .name = "log_unix_epoch",
3888 .lname = "Log epoch unix",
3889 .type = FIO_OPT_BOOL,
3890 .off1 = offsetof(struct thread_options, log_unix_epoch),
3891 .help = "Use Unix time in log files",
3892 .category = FIO_OPT_C_LOG,
3893 .group = FIO_OPT_G_INVALID,
3894 },
3895 {
3896 .name = "block_error_percentiles",
3897 .lname = "Block error percentiles",
3898 .type = FIO_OPT_BOOL,
3899 .off1 = offsetof(struct thread_options, block_error_hist),
3900 .help = "Record trim block errors and make a histogram",
3901 .def = "0",
3902 .category = FIO_OPT_C_LOG,
3903 .group = FIO_OPT_G_INVALID,
3904 },
3905 {
3906 .name = "bwavgtime",
3907 .lname = "Bandwidth average time",
3908 .type = FIO_OPT_INT,
3909 .off1 = offsetof(struct thread_options, bw_avg_time),
3910 .help = "Time window over which to calculate bandwidth"
3911 " (msec)",
3912 .def = "500",
3913 .parent = "write_bw_log",
3914 .hide = 1,
3915 .interval = 100,
3916 .category = FIO_OPT_C_LOG,
3917 .group = FIO_OPT_G_INVALID,
3918 },
3919 {
3920 .name = "iopsavgtime",
3921 .lname = "IOPS average time",
3922 .type = FIO_OPT_INT,
3923 .off1 = offsetof(struct thread_options, iops_avg_time),
3924 .help = "Time window over which to calculate IOPS (msec)",
3925 .def = "500",
3926 .parent = "write_iops_log",
3927 .hide = 1,
3928 .interval = 100,
3929 .category = FIO_OPT_C_LOG,
3930 .group = FIO_OPT_G_INVALID,
3931 },
3932 {
3933 .name = "group_reporting",
3934 .lname = "Group reporting",
3935 .type = FIO_OPT_STR_SET,
3936 .off1 = offsetof(struct thread_options, group_reporting),
3937 .help = "Do reporting on a per-group basis",
3938 .category = FIO_OPT_C_STAT,
3939 .group = FIO_OPT_G_INVALID,
3940 },
3941 {
3942 .name = "stats",
3943 .lname = "Stats",
3944 .type = FIO_OPT_BOOL,
3945 .off1 = offsetof(struct thread_options, stats),
3946 .help = "Enable collection of stats",
3947 .def = "1",
3948 .category = FIO_OPT_C_STAT,
3949 .group = FIO_OPT_G_INVALID,
3950 },
3951 {
3952 .name = "zero_buffers",
3953 .lname = "Zero I/O buffers",
3954 .type = FIO_OPT_STR_SET,
3955 .off1 = offsetof(struct thread_options, zero_buffers),
3956 .help = "Init IO buffers to all zeroes",
3957 .category = FIO_OPT_C_IO,
3958 .group = FIO_OPT_G_IO_BUF,
3959 },
3960 {
3961 .name = "refill_buffers",
3962 .lname = "Refill I/O buffers",
3963 .type = FIO_OPT_STR_SET,
3964 .off1 = offsetof(struct thread_options, refill_buffers),
3965 .help = "Refill IO buffers on every IO submit",
3966 .category = FIO_OPT_C_IO,
3967 .group = FIO_OPT_G_IO_BUF,
3968 },
3969 {
3970 .name = "scramble_buffers",
3971 .lname = "Scramble I/O buffers",
3972 .type = FIO_OPT_BOOL,
3973 .off1 = offsetof(struct thread_options, scramble_buffers),
3974 .help = "Slightly scramble buffers on every IO submit",
3975 .def = "1",
3976 .category = FIO_OPT_C_IO,
3977 .group = FIO_OPT_G_IO_BUF,
3978 },
3979 {
3980 .name = "buffer_pattern",
3981 .lname = "Buffer pattern",
3982 .type = FIO_OPT_STR,
3983 .cb = str_buffer_pattern_cb,
3984 .off1 = offsetof(struct thread_options, buffer_pattern),
3985 .help = "Fill pattern for IO buffers",
3986 .category = FIO_OPT_C_IO,
3987 .group = FIO_OPT_G_IO_BUF,
3988 },
3989 {
3990 .name = "buffer_compress_percentage",
3991 .lname = "Buffer compression percentage",
3992 .type = FIO_OPT_INT,
3993 .cb = str_buffer_compress_cb,
3994 .off1 = offsetof(struct thread_options, compress_percentage),
3995 .maxval = 100,
3996 .minval = 0,
3997 .help = "How compressible the buffer is (approximately)",
3998 .interval = 5,
3999 .category = FIO_OPT_C_IO,
4000 .group = FIO_OPT_G_IO_BUF,
4001 },
4002 {
4003 .name = "buffer_compress_chunk",
4004 .lname = "Buffer compression chunk size",
4005 .type = FIO_OPT_INT,
4006 .off1 = offsetof(struct thread_options, compress_chunk),
4007 .parent = "buffer_compress_percentage",
4008 .hide = 1,
4009 .help = "Size of compressible region in buffer",
4010 .interval = 256,
4011 .category = FIO_OPT_C_IO,
4012 .group = FIO_OPT_G_IO_BUF,
4013 },
4014 {
4015 .name = "dedupe_percentage",
4016 .lname = "Dedupe percentage",
4017 .type = FIO_OPT_INT,
4018 .cb = str_dedupe_cb,
4019 .off1 = offsetof(struct thread_options, dedupe_percentage),
4020 .maxval = 100,
4021 .minval = 0,
4022 .help = "Percentage of buffers that are dedupable",
4023 .interval = 1,
4024 .category = FIO_OPT_C_IO,
4025 .group = FIO_OPT_G_IO_BUF,
4026 },
4027 {
4028 .name = "clat_percentiles",
4029 .lname = "Completion latency percentiles",
4030 .type = FIO_OPT_BOOL,
4031 .off1 = offsetof(struct thread_options, clat_percentiles),
4032 .help = "Enable the reporting of completion latency percentiles",
4033 .def = "1",
4034 .category = FIO_OPT_C_STAT,
4035 .group = FIO_OPT_G_INVALID,
4036 },
4037 {
4038 .name = "percentile_list",
4039 .lname = "Percentile list",
4040 .type = FIO_OPT_FLOAT_LIST,
4041 .off1 = offsetof(struct thread_options, percentile_list),
4042 .off2 = offsetof(struct thread_options, percentile_precision),
4043 .help = "Specify a custom list of percentiles to report for "
4044 "completion latency and block errors",
4045 .def = "1:5:10:20:30:40:50:60:70:80:90:95:99:99.5:99.9:99.95:99.99",
4046 .maxlen = FIO_IO_U_LIST_MAX_LEN,
4047 .minfp = 0.0,
4048 .maxfp = 100.0,
4049 .category = FIO_OPT_C_STAT,
4050 .group = FIO_OPT_G_INVALID,
4051 },
4052
4053#ifdef FIO_HAVE_DISK_UTIL
4054 {
4055 .name = "disk_util",
4056 .lname = "Disk utilization",
4057 .type = FIO_OPT_BOOL,
4058 .off1 = offsetof(struct thread_options, do_disk_util),
4059 .help = "Log disk utilization statistics",
4060 .def = "1",
4061 .category = FIO_OPT_C_STAT,
4062 .group = FIO_OPT_G_INVALID,
4063 },
4064#else
4065 {
4066 .name = "disk_util",
4067 .lname = "Disk utilization",
4068 .type = FIO_OPT_UNSUPPORTED,
4069 .help = "Your platform does not support disk utilization",
4070 },
4071#endif
4072 {
4073 .name = "gtod_reduce",
4074 .lname = "Reduce gettimeofday() calls",
4075 .type = FIO_OPT_BOOL,
4076 .help = "Greatly reduce number of gettimeofday() calls",
4077 .cb = str_gtod_reduce_cb,
4078 .def = "0",
4079 .hide_on_set = 1,
4080 .category = FIO_OPT_C_STAT,
4081 .group = FIO_OPT_G_INVALID,
4082 },
4083 {
4084 .name = "disable_lat",
4085 .lname = "Disable all latency stats",
4086 .type = FIO_OPT_BOOL,
4087 .off1 = offsetof(struct thread_options, disable_lat),
4088 .help = "Disable latency numbers",
4089 .parent = "gtod_reduce",
4090 .hide = 1,
4091 .def = "0",
4092 .category = FIO_OPT_C_STAT,
4093 .group = FIO_OPT_G_INVALID,
4094 },
4095 {
4096 .name = "disable_clat",
4097 .lname = "Disable completion latency stats",
4098 .type = FIO_OPT_BOOL,
4099 .off1 = offsetof(struct thread_options, disable_clat),
4100 .help = "Disable completion latency numbers",
4101 .parent = "gtod_reduce",
4102 .hide = 1,
4103 .def = "0",
4104 .category = FIO_OPT_C_STAT,
4105 .group = FIO_OPT_G_INVALID,
4106 },
4107 {
4108 .name = "disable_slat",
4109 .lname = "Disable submission latency stats",
4110 .type = FIO_OPT_BOOL,
4111 .off1 = offsetof(struct thread_options, disable_slat),
4112 .help = "Disable submission latency numbers",
4113 .parent = "gtod_reduce",
4114 .hide = 1,
4115 .def = "0",
4116 .category = FIO_OPT_C_STAT,
4117 .group = FIO_OPT_G_INVALID,
4118 },
4119 {
4120 .name = "disable_bw_measurement",
4121 .alias = "disable_bw",
4122 .lname = "Disable bandwidth stats",
4123 .type = FIO_OPT_BOOL,
4124 .off1 = offsetof(struct thread_options, disable_bw),
4125 .help = "Disable bandwidth logging",
4126 .parent = "gtod_reduce",
4127 .hide = 1,
4128 .def = "0",
4129 .category = FIO_OPT_C_STAT,
4130 .group = FIO_OPT_G_INVALID,
4131 },
4132 {
4133 .name = "gtod_cpu",
4134 .lname = "Dedicated gettimeofday() CPU",
4135 .type = FIO_OPT_INT,
4136 .off1 = offsetof(struct thread_options, gtod_cpu),
4137 .help = "Set up dedicated gettimeofday() thread on this CPU",
4138 .verify = gtod_cpu_verify,
4139 .category = FIO_OPT_C_GENERAL,
4140 .group = FIO_OPT_G_CLOCK,
4141 },
4142 {
4143 .name = "unified_rw_reporting",
4144 .lname = "Unified RW Reporting",
4145 .type = FIO_OPT_BOOL,
4146 .off1 = offsetof(struct thread_options, unified_rw_rep),
4147 .help = "Unify reporting across data direction",
4148 .def = "0",
4149 .category = FIO_OPT_C_GENERAL,
4150 .group = FIO_OPT_G_INVALID,
4151 },
4152 {
4153 .name = "continue_on_error",
4154 .lname = "Continue on error",
4155 .type = FIO_OPT_STR,
4156 .off1 = offsetof(struct thread_options, continue_on_error),
4157 .help = "Continue on non-fatal errors during IO",
4158 .def = "none",
4159 .category = FIO_OPT_C_GENERAL,
4160 .group = FIO_OPT_G_ERR,
4161 .posval = {
4162 { .ival = "none",
4163 .oval = ERROR_TYPE_NONE,
4164 .help = "Exit when an error is encountered",
4165 },
4166 { .ival = "read",
4167 .oval = ERROR_TYPE_READ,
4168 .help = "Continue on read errors only",
4169 },
4170 { .ival = "write",
4171 .oval = ERROR_TYPE_WRITE,
4172 .help = "Continue on write errors only",
4173 },
4174 { .ival = "io",
4175 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
4176 .help = "Continue on any IO errors",
4177 },
4178 { .ival = "verify",
4179 .oval = ERROR_TYPE_VERIFY,
4180 .help = "Continue on verify errors only",
4181 },
4182 { .ival = "all",
4183 .oval = ERROR_TYPE_ANY,
4184 .help = "Continue on all io and verify errors",
4185 },
4186 { .ival = "0",
4187 .oval = ERROR_TYPE_NONE,
4188 .help = "Alias for 'none'",
4189 },
4190 { .ival = "1",
4191 .oval = ERROR_TYPE_ANY,
4192 .help = "Alias for 'all'",
4193 },
4194 },
4195 },
4196 {
4197 .name = "ignore_error",
4198 .lname = "Ignore Error",
4199 .type = FIO_OPT_STR,
4200 .cb = str_ignore_error_cb,
4201 .off1 = offsetof(struct thread_options, ignore_error_nr),
4202 .help = "Set a specific list of errors to ignore",
4203 .parent = "rw",
4204 .category = FIO_OPT_C_GENERAL,
4205 .group = FIO_OPT_G_ERR,
4206 },
4207 {
4208 .name = "error_dump",
4209 .lname = "Error Dump",
4210 .type = FIO_OPT_BOOL,
4211 .off1 = offsetof(struct thread_options, error_dump),
4212 .def = "0",
4213 .help = "Dump info on each error",
4214 .category = FIO_OPT_C_GENERAL,
4215 .group = FIO_OPT_G_ERR,
4216 },
4217 {
4218 .name = "profile",
4219 .lname = "Profile",
4220 .type = FIO_OPT_STR_STORE,
4221 .off1 = offsetof(struct thread_options, profile),
4222 .help = "Select a specific builtin performance test",
4223 .category = FIO_OPT_C_PROFILE,
4224 .group = FIO_OPT_G_INVALID,
4225 },
4226 {
4227 .name = "cgroup",
4228 .lname = "Cgroup",
4229 .type = FIO_OPT_STR_STORE,
4230 .off1 = offsetof(struct thread_options, cgroup),
4231 .help = "Add job to cgroup of this name",
4232 .category = FIO_OPT_C_GENERAL,
4233 .group = FIO_OPT_G_CGROUP,
4234 },
4235 {
4236 .name = "cgroup_nodelete",
4237 .lname = "Cgroup no-delete",
4238 .type = FIO_OPT_BOOL,
4239 .off1 = offsetof(struct thread_options, cgroup_nodelete),
4240 .help = "Do not delete cgroups after job completion",
4241 .def = "0",
4242 .parent = "cgroup",
4243 .category = FIO_OPT_C_GENERAL,
4244 .group = FIO_OPT_G_CGROUP,
4245 },
4246 {
4247 .name = "cgroup_weight",
4248 .lname = "Cgroup weight",
4249 .type = FIO_OPT_INT,
4250 .off1 = offsetof(struct thread_options, cgroup_weight),
4251 .help = "Use given weight for cgroup",
4252 .minval = 100,
4253 .maxval = 1000,
4254 .parent = "cgroup",
4255 .category = FIO_OPT_C_GENERAL,
4256 .group = FIO_OPT_G_CGROUP,
4257 },
4258 {
4259 .name = "uid",
4260 .lname = "User ID",
4261 .type = FIO_OPT_INT,
4262 .off1 = offsetof(struct thread_options, uid),
4263 .help = "Run job with this user ID",
4264 .category = FIO_OPT_C_GENERAL,
4265 .group = FIO_OPT_G_CRED,
4266 },
4267 {
4268 .name = "gid",
4269 .lname = "Group ID",
4270 .type = FIO_OPT_INT,
4271 .off1 = offsetof(struct thread_options, gid),
4272 .help = "Run job with this group ID",
4273 .category = FIO_OPT_C_GENERAL,
4274 .group = FIO_OPT_G_CRED,
4275 },
4276 {
4277 .name = "kb_base",
4278 .lname = "KB Base",
4279 .type = FIO_OPT_INT,
4280 .off1 = offsetof(struct thread_options, kb_base),
4281 .prio = 1,
4282 .def = "1024",
4283 .posval = {
4284 { .ival = "1024",
4285 .oval = 1024,
4286 .help = "Inputs invert IEC and SI prefixes (for compatibility); outputs prefer binary",
4287 },
4288 { .ival = "1000",
4289 .oval = 1000,
4290 .help = "Inputs use IEC and SI prefixes; outputs prefer SI",
4291 },
4292 },
4293 .help = "Unit prefix interpretation for quantities of data (IEC and SI)",
4294 .category = FIO_OPT_C_GENERAL,
4295 .group = FIO_OPT_G_INVALID,
4296 },
4297 {
4298 .name = "unit_base",
4299 .lname = "Unit for quantities of data (Bits or Bytes)",
4300 .type = FIO_OPT_INT,
4301 .off1 = offsetof(struct thread_options, unit_base),
4302 .prio = 1,
4303 .posval = {
4304 { .ival = "0",
4305 .oval = 0,
4306 .help = "Auto-detect",
4307 },
4308 { .ival = "8",
4309 .oval = 8,
4310 .help = "Normal (byte based)",
4311 },
4312 { .ival = "1",
4313 .oval = 1,
4314 .help = "Bit based",
4315 },
4316 },
4317 .help = "Bit multiple of result summary data (8 for byte, 1 for bit)",
4318 .category = FIO_OPT_C_GENERAL,
4319 .group = FIO_OPT_G_INVALID,
4320 },
4321 {
4322 .name = "hugepage-size",
4323 .lname = "Hugepage size",
4324 .type = FIO_OPT_INT,
4325 .off1 = offsetof(struct thread_options, hugepage_size),
4326 .help = "When using hugepages, specify size of each page",
4327 .def = __fio_stringify(FIO_HUGE_PAGE),
4328 .interval = 1024 * 1024,
4329 .category = FIO_OPT_C_GENERAL,
4330 .group = FIO_OPT_G_INVALID,
4331 },
4332 {
4333 .name = "flow_id",
4334 .lname = "I/O flow ID",
4335 .type = FIO_OPT_INT,
4336 .off1 = offsetof(struct thread_options, flow_id),
4337 .help = "The flow index ID to use",
4338 .def = "0",
4339 .category = FIO_OPT_C_IO,
4340 .group = FIO_OPT_G_IO_FLOW,
4341 },
4342 {
4343 .name = "flow",
4344 .lname = "I/O flow weight",
4345 .type = FIO_OPT_INT,
4346 .off1 = offsetof(struct thread_options, flow),
4347 .help = "Weight for flow control of this job",
4348 .parent = "flow_id",
4349 .hide = 1,
4350 .def = "0",
4351 .category = FIO_OPT_C_IO,
4352 .group = FIO_OPT_G_IO_FLOW,
4353 },
4354 {
4355 .name = "flow_watermark",
4356 .lname = "I/O flow watermark",
4357 .type = FIO_OPT_INT,
4358 .off1 = offsetof(struct thread_options, flow_watermark),
4359 .help = "High watermark for flow control. This option"
4360 " should be set to the same value for all threads"
4361 " with non-zero flow.",
4362 .parent = "flow_id",
4363 .hide = 1,
4364 .def = "1024",
4365 .category = FIO_OPT_C_IO,
4366 .group = FIO_OPT_G_IO_FLOW,
4367 },
4368 {
4369 .name = "flow_sleep",
4370 .lname = "I/O flow sleep",
4371 .type = FIO_OPT_INT,
4372 .off1 = offsetof(struct thread_options, flow_sleep),
4373 .help = "How many microseconds to sleep after being held"
4374 " back by the flow control mechanism",
4375 .parent = "flow_id",
4376 .hide = 1,
4377 .def = "0",
4378 .category = FIO_OPT_C_IO,
4379 .group = FIO_OPT_G_IO_FLOW,
4380 },
4381 {
4382 .name = "skip_bad",
4383 .lname = "Skip operations against bad blocks",
4384 .type = FIO_OPT_BOOL,
4385 .off1 = offsetof(struct thread_options, skip_bad),
4386 .help = "Skip operations against known bad blocks.",
4387 .hide = 1,
4388 .def = "0",
4389 .category = FIO_OPT_C_IO,
4390 .group = FIO_OPT_G_MTD,
4391 },
4392 {
4393 .name = "steadystate",
4394 .lname = "Steady state threshold",
4395 .alias = "ss",
4396 .type = FIO_OPT_STR,
4397 .off1 = offsetof(struct thread_options, ss_state),
4398 .cb = str_steadystate_cb,
4399 .help = "Define the criterion and limit to judge when a job has reached steady state",
4400 .def = "iops_slope:0.01%",
4401 .posval = {
4402 { .ival = "iops",
4403 .oval = FIO_SS_IOPS,
4404 .help = "maximum mean deviation of IOPS measurements",
4405 },
4406 { .ival = "iops_slope",
4407 .oval = FIO_SS_IOPS_SLOPE,
4408 .help = "slope calculated from IOPS measurements",
4409 },
4410 { .ival = "bw",
4411 .oval = FIO_SS_BW,
4412 .help = "maximum mean deviation of bandwidth measurements",
4413 },
4414 {
4415 .ival = "bw_slope",
4416 .oval = FIO_SS_BW_SLOPE,
4417 .help = "slope calculated from bandwidth measurements",
4418 },
4419 },
4420 .category = FIO_OPT_C_GENERAL,
4421 .group = FIO_OPT_G_RUNTIME,
4422 },
4423 {
4424 .name = "steadystate_duration",
4425 .lname = "Steady state duration",
4426 .alias = "ss_dur",
4427 .parent = "steadystate",
4428 .type = FIO_OPT_STR_VAL_TIME,
4429 .off1 = offsetof(struct thread_options, ss_dur),
4430 .help = "Stop workload upon attaining steady state for specified duration",
4431 .def = "0",
4432 .is_seconds = 1,
4433 .is_time = 1,
4434 .category = FIO_OPT_C_GENERAL,
4435 .group = FIO_OPT_G_RUNTIME,
4436 },
4437 {
4438 .name = "steadystate_ramp_time",
4439 .lname = "Steady state ramp time",
4440 .alias = "ss_ramp",
4441 .parent = "steadystate",
4442 .type = FIO_OPT_STR_VAL_TIME,
4443 .off1 = offsetof(struct thread_options, ss_ramp_time),
4444 .help = "Delay before initiation of data collection for steady state job termination testing",
4445 .def = "0",
4446 .is_seconds = 1,
4447 .is_time = 1,
4448 .category = FIO_OPT_C_GENERAL,
4449 .group = FIO_OPT_G_RUNTIME,
4450 },
4451 {
4452 .name = NULL,
4453 },
4454};
4455
4456static void add_to_lopt(struct option *lopt, struct fio_option *o,
4457 const char *name, int val)
4458{
4459 lopt->name = (char *) name;
4460 lopt->val = val;
4461 if (o->type == FIO_OPT_STR_SET)
4462 lopt->has_arg = optional_argument;
4463 else
4464 lopt->has_arg = required_argument;
4465}
4466
4467static void options_to_lopts(struct fio_option *opts,
4468 struct option *long_options,
4469 int i, int option_type)
4470{
4471 struct fio_option *o = &opts[0];
4472 while (o->name) {
4473 add_to_lopt(&long_options[i], o, o->name, option_type);
4474 if (o->alias) {
4475 i++;
4476 add_to_lopt(&long_options[i], o, o->alias, option_type);
4477 }
4478
4479 i++;
4480 o++;
4481 assert(i < FIO_NR_OPTIONS);
4482 }
4483}
4484
4485void fio_options_set_ioengine_opts(struct option *long_options,
4486 struct thread_data *td)
4487{
4488 unsigned int i;
4489
4490 i = 0;
4491 while (long_options[i].name) {
4492 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
4493 memset(&long_options[i], 0, sizeof(*long_options));
4494 break;
4495 }
4496 i++;
4497 }
4498
4499 /*
4500 * Just clear out the prior ioengine options.
4501 */
4502 if (!td || !td->eo)
4503 return;
4504
4505 options_to_lopts(td->io_ops->options, long_options, i,
4506 FIO_GETOPT_IOENGINE);
4507}
4508
4509void fio_options_dup_and_init(struct option *long_options)
4510{
4511 unsigned int i;
4512
4513 options_init(fio_options);
4514
4515 i = 0;
4516 while (long_options[i].name)
4517 i++;
4518
4519 options_to_lopts(fio_options, long_options, i, FIO_GETOPT_JOB);
4520}
4521
4522struct fio_keyword {
4523 const char *word;
4524 const char *desc;
4525 char *replace;
4526};
4527
4528static struct fio_keyword fio_keywords[] = {
4529 {
4530 .word = "$pagesize",
4531 .desc = "Page size in the system",
4532 },
4533 {
4534 .word = "$mb_memory",
4535 .desc = "Megabytes of memory online",
4536 },
4537 {
4538 .word = "$ncpus",
4539 .desc = "Number of CPUs online in the system",
4540 },
4541 {
4542 .word = NULL,
4543 },
4544};
4545
4546void fio_keywords_exit(void)
4547{
4548 struct fio_keyword *kw;
4549
4550 kw = &fio_keywords[0];
4551 while (kw->word) {
4552 free(kw->replace);
4553 kw->replace = NULL;
4554 kw++;
4555 }
4556}
4557
4558void fio_keywords_init(void)
4559{
4560 unsigned long long mb_memory;
4561 char buf[128];
4562 long l;
4563
4564 sprintf(buf, "%lu", (unsigned long) page_size);
4565 fio_keywords[0].replace = strdup(buf);
4566
4567 mb_memory = os_phys_mem() / (1024 * 1024);
4568 sprintf(buf, "%llu", mb_memory);
4569 fio_keywords[1].replace = strdup(buf);
4570
4571 l = cpus_online();
4572 sprintf(buf, "%lu", l);
4573 fio_keywords[2].replace = strdup(buf);
4574}
4575
4576#define BC_APP "bc"
4577
4578static char *bc_calc(char *str)
4579{
4580 char buf[128], *tmp;
4581 FILE *f;
4582 int ret;
4583
4584 /*
4585 * No math, just return string
4586 */
4587 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
4588 !strchr(str, '/')) || strchr(str, '\''))
4589 return str;
4590
4591 /*
4592 * Split option from value, we only need to calculate the value
4593 */
4594 tmp = strchr(str, '=');
4595 if (!tmp)
4596 return str;
4597
4598 tmp++;
4599
4600 /*
4601 * Prevent buffer overflows; such a case isn't reasonable anyway
4602 */
4603 if (strlen(str) >= 128 || strlen(tmp) > 100)
4604 return str;
4605
4606 sprintf(buf, "which %s > /dev/null", BC_APP);
4607 if (system(buf)) {
4608 log_err("fio: bc is needed for performing math\n");
4609 return NULL;
4610 }
4611
4612 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
4613 f = popen(buf, "r");
4614 if (!f)
4615 return NULL;
4616
4617 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
4618 if (ret <= 0) {
4619 pclose(f);
4620 return NULL;
4621 }
4622
4623 pclose(f);
4624 buf[(tmp - str) + ret - 1] = '\0';
4625 memcpy(buf, str, tmp - str);
4626 free(str);
4627 return strdup(buf);
4628}
4629
4630/*
4631 * Return a copy of the input string with substrings of the form ${VARNAME}
4632 * substituted with the value of the environment variable VARNAME. The
4633 * substitution always occurs, even if VARNAME is empty or the corresponding
4634 * environment variable undefined.
4635 */
4636static char *option_dup_subs(const char *opt)
4637{
4638 char out[OPT_LEN_MAX+1];
4639 char in[OPT_LEN_MAX+1];
4640 char *outptr = out;
4641 char *inptr = in;
4642 char *ch1, *ch2, *env;
4643 ssize_t nchr = OPT_LEN_MAX;
4644 size_t envlen;
4645
4646 if (strlen(opt) + 1 > OPT_LEN_MAX) {
4647 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
4648 return NULL;
4649 }
4650
4651 in[OPT_LEN_MAX] = '\0';
4652 strncpy(in, opt, OPT_LEN_MAX);
4653
4654 while (*inptr && nchr > 0) {
4655 if (inptr[0] == '$' && inptr[1] == '{') {
4656 ch2 = strchr(inptr, '}');
4657 if (ch2 && inptr+1 < ch2) {
4658 ch1 = inptr+2;
4659 inptr = ch2+1;
4660 *ch2 = '\0';
4661
4662 env = getenv(ch1);
4663 if (env) {
4664 envlen = strlen(env);
4665 if (envlen <= nchr) {
4666 memcpy(outptr, env, envlen);
4667 outptr += envlen;
4668 nchr -= envlen;
4669 }
4670 }
4671
4672 continue;
4673 }
4674 }
4675
4676 *outptr++ = *inptr++;
4677 --nchr;
4678 }
4679
4680 *outptr = '\0';
4681 return strdup(out);
4682}
4683
4684/*
4685 * Look for reserved variable names and replace them with real values
4686 */
4687static char *fio_keyword_replace(char *opt)
4688{
4689 char *s;
4690 int i;
4691 int docalc = 0;
4692
4693 for (i = 0; fio_keywords[i].word != NULL; i++) {
4694 struct fio_keyword *kw = &fio_keywords[i];
4695
4696 while ((s = strstr(opt, kw->word)) != NULL) {
4697 char *new = malloc(strlen(opt) + 1);
4698 char *o_org = opt;
4699 int olen = s - opt;
4700 int len;
4701
4702 /*
4703 * Copy part of the string before the keyword and
4704 * sprintf() the replacement after it.
4705 */
4706 memcpy(new, opt, olen);
4707 len = sprintf(new + olen, "%s", kw->replace);
4708
4709 /*
4710 * If there's more in the original string, copy that
4711 * in too
4712 */
4713 opt += strlen(kw->word) + olen;
4714 if (strlen(opt))
4715 memcpy(new + olen + len, opt, opt - o_org - 1);
4716
4717 /*
4718 * replace opt and free the old opt
4719 */
4720 opt = new;
4721 free(o_org);
4722
4723 docalc = 1;
4724 }
4725 }
4726
4727 /*
4728 * Check for potential math and invoke bc, if possible
4729 */
4730 if (docalc)
4731 opt = bc_calc(opt);
4732
4733 return opt;
4734}
4735
4736static char **dup_and_sub_options(char **opts, int num_opts)
4737{
4738 int i;
4739 char **opts_copy = malloc(num_opts * sizeof(*opts));
4740 for (i = 0; i < num_opts; i++) {
4741 opts_copy[i] = option_dup_subs(opts[i]);
4742 if (!opts_copy[i])
4743 continue;
4744 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
4745 }
4746 return opts_copy;
4747}
4748
4749static void show_closest_option(const char *opt)
4750{
4751 int best_option, best_distance;
4752 int i, distance;
4753 char *name;
4754
4755 if (!strlen(opt))
4756 return;
4757
4758 name = strdup(opt);
4759 i = 0;
4760 while (name[i] != '\0' && name[i] != '=')
4761 i++;
4762 name[i] = '\0';
4763
4764 best_option = -1;
4765 best_distance = INT_MAX;
4766 i = 0;
4767 while (fio_options[i].name) {
4768 distance = string_distance(name, fio_options[i].name);
4769 if (distance < best_distance) {
4770 best_distance = distance;
4771 best_option = i;
4772 }
4773 i++;
4774 }
4775
4776 if (best_option != -1 && string_distance_ok(name, best_distance) &&
4777 fio_options[best_option].type != FIO_OPT_UNSUPPORTED)
4778 log_err("Did you mean %s?\n", fio_options[best_option].name);
4779
4780 free(name);
4781}
4782
4783int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
4784{
4785 int i, ret, unknown;
4786 char **opts_copy;
4787
4788 sort_options(opts, fio_options, num_opts);
4789 opts_copy = dup_and_sub_options(opts, num_opts);
4790
4791 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
4792 struct fio_option *o;
4793 int newret = parse_option(opts_copy[i], opts[i], fio_options,
4794 &o, &td->o, &td->opt_list);
4795
4796 if (!newret && o)
4797 fio_option_mark_set(&td->o, o);
4798
4799 if (opts_copy[i]) {
4800 if (newret && !o) {
4801 unknown++;
4802 continue;
4803 }
4804 free(opts_copy[i]);
4805 opts_copy[i] = NULL;
4806 }
4807
4808 ret |= newret;
4809 }
4810
4811 if (unknown) {
4812 ret |= ioengine_load(td);
4813 if (td->eo) {
4814 sort_options(opts_copy, td->io_ops->options, num_opts);
4815 opts = opts_copy;
4816 }
4817 for (i = 0; i < num_opts; i++) {
4818 struct fio_option *o = NULL;
4819 int newret = 1;
4820
4821 if (!opts_copy[i])
4822 continue;
4823
4824 if (td->eo)
4825 newret = parse_option(opts_copy[i], opts[i],
4826 td->io_ops->options, &o,
4827 td->eo, &td->opt_list);
4828
4829 ret |= newret;
4830 if (!o) {
4831 log_err("Bad option <%s>\n", opts[i]);
4832 show_closest_option(opts[i]);
4833 }
4834 free(opts_copy[i]);
4835 opts_copy[i] = NULL;
4836 }
4837 }
4838
4839 free(opts_copy);
4840 return ret;
4841}
4842
4843int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
4844{
4845 int ret;
4846
4847 ret = parse_cmd_option(opt, val, fio_options, &td->o, &td->opt_list);
4848 if (!ret) {
4849 struct fio_option *o;
4850
4851 o = find_option(fio_options, opt);
4852 if (o)
4853 fio_option_mark_set(&td->o, o);
4854 }
4855
4856 return ret;
4857}
4858
4859int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
4860 char *val)
4861{
4862 return parse_cmd_option(opt, val, td->io_ops->options, td->eo,
4863 &td->opt_list);
4864}
4865
4866void fio_fill_default_options(struct thread_data *td)
4867{
4868 td->o.magic = OPT_MAGIC;
4869 fill_default_options(&td->o, fio_options);
4870}
4871
4872int fio_show_option_help(const char *opt)
4873{
4874 return show_cmd_help(fio_options, opt);
4875}
4876
4877/*
4878 * dupe FIO_OPT_STR_STORE options
4879 */
4880void fio_options_mem_dupe(struct thread_data *td)
4881{
4882 options_mem_dupe(fio_options, &td->o);
4883
4884 if (td->eo && td->io_ops) {
4885 void *oldeo = td->eo;
4886
4887 td->eo = malloc(td->io_ops->option_struct_size);
4888 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
4889 options_mem_dupe(td->io_ops->options, td->eo);
4890 }
4891}
4892
4893unsigned int fio_get_kb_base(void *data)
4894{
4895 struct thread_data *td = cb_data_to_td(data);
4896 struct thread_options *o = &td->o;
4897 unsigned int kb_base = 0;
4898
4899 /*
4900 * This is a hack... For private options, *data is not holding
4901 * a pointer to the thread_options, but to private data. This means
4902 * we can't safely dereference it, but magic is first so mem wise
4903 * it is valid. But this also means that if the job first sets
4904 * kb_base and expects that to be honored by private options,
4905 * it will be disappointed. We will return the global default
4906 * for this.
4907 */
4908 if (o && o->magic == OPT_MAGIC)
4909 kb_base = o->kb_base;
4910 if (!kb_base)
4911 kb_base = 1024;
4912
4913 return kb_base;
4914}
4915
4916int add_option(struct fio_option *o)
4917{
4918 struct fio_option *__o;
4919 int opt_index = 0;
4920
4921 __o = fio_options;
4922 while (__o->name) {
4923 opt_index++;
4924 __o++;
4925 }
4926
4927 if (opt_index + 1 == FIO_MAX_OPTS) {
4928 log_err("fio: FIO_MAX_OPTS is too small\n");
4929 return 1;
4930 }
4931
4932 memcpy(&fio_options[opt_index], o, sizeof(*o));
4933 fio_options[opt_index + 1].name = NULL;
4934 return 0;
4935}
4936
4937void invalidate_profile_options(const char *prof_name)
4938{
4939 struct fio_option *o;
4940
4941 o = fio_options;
4942 while (o->name) {
4943 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
4944 o->type = FIO_OPT_INVALID;
4945 o->prof_name = NULL;
4946 }
4947 o++;
4948 }
4949}
4950
4951void add_opt_posval(const char *optname, const char *ival, const char *help)
4952{
4953 struct fio_option *o;
4954 unsigned int i;
4955
4956 o = find_option(fio_options, optname);
4957 if (!o)
4958 return;
4959
4960 for (i = 0; i < PARSE_MAX_VP; i++) {
4961 if (o->posval[i].ival)
4962 continue;
4963
4964 o->posval[i].ival = ival;
4965 o->posval[i].help = help;
4966 break;
4967 }
4968}
4969
4970void del_opt_posval(const char *optname, const char *ival)
4971{
4972 struct fio_option *o;
4973 unsigned int i;
4974
4975 o = find_option(fio_options, optname);
4976 if (!o)
4977 return;
4978
4979 for (i = 0; i < PARSE_MAX_VP; i++) {
4980 if (!o->posval[i].ival)
4981 continue;
4982 if (strcmp(o->posval[i].ival, ival))
4983 continue;
4984
4985 o->posval[i].ival = NULL;
4986 o->posval[i].help = NULL;
4987 }
4988}
4989
4990void fio_options_free(struct thread_data *td)
4991{
4992 options_free(fio_options, &td->o);
4993 if (td->eo && td->io_ops && td->io_ops->options) {
4994 options_free(td->io_ops->options, td->eo);
4995 free(td->eo);
4996 td->eo = NULL;
4997 }
4998}
4999
5000struct fio_option *fio_option_find(const char *name)
5001{
5002 return find_option(fio_options, name);
5003}
5004
5005static struct fio_option *find_next_opt(struct thread_options *o,
5006 struct fio_option *from,
5007 unsigned int off1)
5008{
5009 struct fio_option *opt;
5010
5011 if (!from)
5012 from = &fio_options[0];
5013 else
5014 from++;
5015
5016 opt = NULL;
5017 do {
5018 if (off1 == from->off1) {
5019 opt = from;
5020 break;
5021 }
5022 from++;
5023 } while (from->name);
5024
5025 return opt;
5026}
5027
5028static int opt_is_set(struct thread_options *o, struct fio_option *opt)
5029{
5030 unsigned int opt_off, index, offset;
5031
5032 opt_off = opt - &fio_options[0];
5033 index = opt_off / (8 * sizeof(uint64_t));
5034 offset = opt_off & ((8 * sizeof(uint64_t)) - 1);
5035 return (o->set_options[index] & ((uint64_t)1 << offset)) != 0;
5036}
5037
5038bool __fio_option_is_set(struct thread_options *o, unsigned int off1)
5039{
5040 struct fio_option *opt, *next;
5041
5042 next = NULL;
5043 while ((opt = find_next_opt(o, next, off1)) != NULL) {
5044 if (opt_is_set(o, opt))
5045 return true;
5046
5047 next = opt;
5048 }
5049
5050 return false;
5051}
5052
5053void fio_option_mark_set(struct thread_options *o, struct fio_option *opt)
5054{
5055 unsigned int opt_off, index, offset;
5056
5057 opt_off = opt - &fio_options[0];
5058 index = opt_off / (8 * sizeof(uint64_t));
5059 offset = opt_off & ((8 * sizeof(uint64_t)) - 1);
5060 o->set_options[index] |= (uint64_t)1 << offset;
5061}