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