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