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