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