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