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