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