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