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