447f231e71485268d7c6bcc5149edf5800e60aaa
[fio.git] / options.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <unistd.h>
4 #include <ctype.h>
5 #include <string.h>
6 #include <assert.h>
7 #include <sys/stat.h>
8 #include <netinet/in.h>
9
10 #include "fio.h"
11 #include "verify.h"
12 #include "parse.h"
13 #include "lib/pattern.h"
14 #include "options.h"
15 #include "optgroup.h"
16
17 char client_sockaddr_str[INET6_ADDRSTRLEN] = { 0 };
18
19 #define cb_data_to_td(data)     container_of(data, struct thread_data, o)
20
21 static struct pattern_fmt_desc fmt_desc[] = {
22         {
23                 .fmt   = "%o",
24                 .len   = FIELD_SIZE(struct io_u *, offset),
25                 .paste = paste_blockoff
26         }
27 };
28
29 /*
30  * Check if mmap/mmaphuge has a :/foo/bar/file at the end. If so, return that.
31  */
32 static char *get_opt_postfix(const char *str)
33 {
34         char *p = strstr(str, ":");
35
36         if (!p)
37                 return NULL;
38
39         p++;
40         strip_blank_front(&p);
41         strip_blank_end(p);
42         return strdup(p);
43 }
44
45 static int bs_cmp(const void *p1, const void *p2)
46 {
47         const struct bssplit *bsp1 = p1;
48         const struct bssplit *bsp2 = p2;
49
50         return (int) bsp1->perc - (int) bsp2->perc;
51 }
52
53 struct split {
54         unsigned int nr;
55         unsigned long long val1[ZONESPLIT_MAX];
56         unsigned long long val2[ZONESPLIT_MAX];
57 };
58
59 static int split_parse_ddir(struct thread_options *o, struct split *split,
60                             char *str, bool absolute, unsigned int max_splits)
61 {
62         unsigned long long perc;
63         unsigned int i;
64         long long val;
65         char *fname;
66
67         split->nr = 0;
68
69         i = 0;
70         while ((fname = strsep(&str, ":")) != NULL) {
71                 char *perc_str;
72
73                 if (!strlen(fname))
74                         break;
75
76                 perc_str = strstr(fname, "/");
77                 if (perc_str) {
78                         *perc_str = '\0';
79                         perc_str++;
80                         if (absolute) {
81                                 if (str_to_decimal(perc_str, &val, 1, o, 0, 0)) {
82                                         log_err("fio: split conversion failed\n");
83                                         return 1;
84                                 }
85                                 perc = val;
86                         } else {
87                                 perc = atoi(perc_str);
88                                 if (perc > 100)
89                                         perc = 100;
90                                 else if (!perc)
91                                         perc = -1U;
92                         }
93                 } else {
94                         if (absolute)
95                                 perc = 0;
96                         else
97                                 perc = -1U;
98                 }
99
100                 if (str_to_decimal(fname, &val, 1, o, 0, 0)) {
101                         log_err("fio: split conversion failed\n");
102                         return 1;
103                 }
104
105                 split->val1[i] = val;
106                 split->val2[i] = perc;
107                 i++;
108                 if (i == max_splits) {
109                         log_err("fio: hit max of %d split entries\n", i);
110                         break;
111                 }
112         }
113
114         split->nr = i;
115         return 0;
116 }
117
118 static int bssplit_ddir(struct thread_options *o, enum fio_ddir ddir, char *str,
119                         bool data)
120 {
121         unsigned int i, perc, perc_missing;
122         unsigned long long max_bs, min_bs;
123         struct split split;
124
125         memset(&split, 0, sizeof(split));
126
127         if (split_parse_ddir(o, &split, str, data, BSSPLIT_MAX))
128                 return 1;
129         if (!split.nr)
130                 return 0;
131
132         max_bs = 0;
133         min_bs = -1;
134         o->bssplit[ddir] = malloc(split.nr * sizeof(struct bssplit));
135         o->bssplit_nr[ddir] = split.nr;
136         for (i = 0; i < split.nr; i++) {
137                 if (split.val1[i] > max_bs)
138                         max_bs = split.val1[i];
139                 if (split.val1[i] < min_bs)
140                         min_bs = split.val1[i];
141
142                 o->bssplit[ddir][i].bs = split.val1[i];
143                 o->bssplit[ddir][i].perc =split.val2[i];
144         }
145
146         /*
147          * Now check if the percentages add up, and how much is missing
148          */
149         perc = perc_missing = 0;
150         for (i = 0; i < o->bssplit_nr[ddir]; i++) {
151                 struct bssplit *bsp = &o->bssplit[ddir][i];
152
153                 if (bsp->perc == -1U)
154                         perc_missing++;
155                 else
156                         perc += bsp->perc;
157         }
158
159         if (perc > 100 && perc_missing > 1) {
160                 log_err("fio: bssplit percentages add to more than 100%%\n");
161                 free(o->bssplit[ddir]);
162                 o->bssplit[ddir] = NULL;
163                 return 1;
164         }
165
166         /*
167          * If values didn't have a percentage set, divide the remains between
168          * them.
169          */
170         if (perc_missing) {
171                 if (perc_missing == 1 && o->bssplit_nr[ddir] == 1)
172                         perc = 100;
173                 for (i = 0; i < o->bssplit_nr[ddir]; i++) {
174                         struct bssplit *bsp = &o->bssplit[ddir][i];
175
176                         if (bsp->perc == -1U)
177                                 bsp->perc = (100 - perc) / perc_missing;
178                 }
179         }
180
181         o->min_bs[ddir] = min_bs;
182         o->max_bs[ddir] = max_bs;
183
184         /*
185          * now sort based on percentages, for ease of lookup
186          */
187         qsort(o->bssplit[ddir], o->bssplit_nr[ddir], sizeof(struct bssplit), bs_cmp);
188         return 0;
189 }
190
191 typedef int (split_parse_fn)(struct thread_options *, enum fio_ddir, char *, bool);
192
193 static int str_split_parse(struct thread_data *td, char *str,
194                            split_parse_fn *fn, bool data)
195 {
196         char *odir, *ddir;
197         int ret = 0;
198
199         odir = strchr(str, ',');
200         if (odir) {
201                 ddir = strchr(odir + 1, ',');
202                 if (ddir) {
203                         ret = fn(&td->o, DDIR_TRIM, ddir + 1, data);
204                         if (!ret)
205                                 *ddir = '\0';
206                 } else {
207                         char *op;
208
209                         op = strdup(odir + 1);
210                         ret = fn(&td->o, DDIR_TRIM, op, data);
211
212                         free(op);
213                 }
214                 if (!ret)
215                         ret = fn(&td->o, DDIR_WRITE, odir + 1, data);
216                 if (!ret) {
217                         *odir = '\0';
218                         ret = fn(&td->o, DDIR_READ, str, data);
219                 }
220         } else {
221                 char *op;
222
223                 op = strdup(str);
224                 ret = fn(&td->o, DDIR_WRITE, op, data);
225                 free(op);
226
227                 if (!ret) {
228                         op = strdup(str);
229                         ret = fn(&td->o, DDIR_TRIM, op, data);
230                         free(op);
231                 }
232                 if (!ret)
233                         ret = fn(&td->o, DDIR_READ, str, data);
234         }
235
236         return ret;
237 }
238
239 static int str_bssplit_cb(void *data, const char *input)
240 {
241         struct thread_data *td = cb_data_to_td(data);
242         char *str, *p;
243         int ret = 0;
244
245         p = str = strdup(input);
246
247         strip_blank_front(&str);
248         strip_blank_end(str);
249
250         ret = str_split_parse(td, str, bssplit_ddir, false);
251
252         if (parse_dryrun()) {
253                 int i;
254
255                 for (i = 0; i < DDIR_RWDIR_CNT; i++) {
256                         free(td->o.bssplit[i]);
257                         td->o.bssplit[i] = NULL;
258                         td->o.bssplit_nr[i] = 0;
259                 }
260         }
261
262         free(p);
263         return ret;
264 }
265
266 static int str2error(char *str)
267 {
268         const char *err[] = { "EPERM", "ENOENT", "ESRCH", "EINTR", "EIO",
269                             "ENXIO", "E2BIG", "ENOEXEC", "EBADF",
270                             "ECHILD", "EAGAIN", "ENOMEM", "EACCES",
271                             "EFAULT", "ENOTBLK", "EBUSY", "EEXIST",
272                             "EXDEV", "ENODEV", "ENOTDIR", "EISDIR",
273                             "EINVAL", "ENFILE", "EMFILE", "ENOTTY",
274                             "ETXTBSY","EFBIG", "ENOSPC", "ESPIPE",
275                             "EROFS","EMLINK", "EPIPE", "EDOM", "ERANGE" };
276         int i = 0, num = sizeof(err) / sizeof(char *);
277
278         while (i < num) {
279                 if (!strcmp(err[i], str))
280                         return i + 1;
281                 i++;
282         }
283         return 0;
284 }
285
286 static int ignore_error_type(struct thread_data *td, enum error_type_bit etype,
287                                 char *str)
288 {
289         unsigned int i;
290         int *error;
291         char *fname;
292
293         if (etype >= ERROR_TYPE_CNT) {
294                 log_err("Illegal error type\n");
295                 return 1;
296         }
297
298         td->o.ignore_error_nr[etype] = 4;
299         error = calloc(4, sizeof(int));
300
301         i = 0;
302         while ((fname = strsep(&str, ":")) != NULL) {
303
304                 if (!strlen(fname))
305                         break;
306
307                 /*
308                  * grow struct buffer, if needed
309                  */
310                 if (i == td->o.ignore_error_nr[etype]) {
311                         td->o.ignore_error_nr[etype] <<= 1;
312                         error = realloc(error, td->o.ignore_error_nr[etype]
313                                                   * sizeof(int));
314                 }
315                 if (fname[0] == 'E') {
316                         error[i] = str2error(fname);
317                 } else {
318                         error[i] = atoi(fname);
319                         if (error[i] < 0)
320                                 error[i] = -error[i];
321                 }
322                 if (!error[i]) {
323                         log_err("Unknown error %s, please use number value\n",
324                                   fname);
325                         td->o.ignore_error_nr[etype] = 0;
326                         free(error);
327                         return 1;
328                 }
329                 i++;
330         }
331         if (i) {
332                 td->o.continue_on_error |= 1 << etype;
333                 td->o.ignore_error_nr[etype] = i;
334                 td->o.ignore_error[etype] = error;
335         } else {
336                 td->o.ignore_error_nr[etype] = 0;
337                 free(error);
338         }
339
340         return 0;
341
342 }
343
344 static int str_replay_skip_cb(void *data, const char *input)
345 {
346         struct thread_data *td = cb_data_to_td(data);
347         char *str, *p, *n;
348         int ret = 0;
349
350         if (parse_dryrun())
351                 return 0;
352
353         p = str = strdup(input);
354
355         strip_blank_front(&str);
356         strip_blank_end(str);
357
358         while (p) {
359                 n = strchr(p, ',');
360                 if (n)
361                         *n++ = '\0';
362                 if (!strcmp(p, "read"))
363                         td->o.replay_skip |= 1u << DDIR_READ;
364                 else if (!strcmp(p, "write"))
365                         td->o.replay_skip |= 1u << DDIR_WRITE;
366                 else if (!strcmp(p, "trim"))
367                         td->o.replay_skip |= 1u << DDIR_TRIM;
368                 else if (!strcmp(p, "sync"))
369                         td->o.replay_skip |= 1u << DDIR_SYNC;
370                 else {
371                         log_err("Unknown skip type: %s\n", p);
372                         ret = 1;
373                         break;
374                 }
375                 p = n;
376         }
377         free(str);
378         return ret;
379 }
380
381 static int str_ignore_error_cb(void *data, const char *input)
382 {
383         struct thread_data *td = cb_data_to_td(data);
384         char *str, *p, *n;
385         int ret = 1;
386         enum error_type_bit type = 0;
387
388         if (parse_dryrun())
389                 return 0;
390
391         p = str = strdup(input);
392
393         strip_blank_front(&str);
394         strip_blank_end(str);
395
396         while (p) {
397                 n = strchr(p, ',');
398                 if (n)
399                         *n++ = '\0';
400                 ret = ignore_error_type(td, type, p);
401                 if (ret)
402                         break;
403                 p = n;
404                 type++;
405         }
406         free(str);
407         return ret;
408 }
409
410 static int str_rw_cb(void *data, const char *str)
411 {
412         struct thread_data *td = cb_data_to_td(data);
413         struct thread_options *o = &td->o;
414         char *nr;
415
416         if (parse_dryrun())
417                 return 0;
418
419         o->ddir_seq_nr = 1;
420         o->ddir_seq_add = 0;
421
422         nr = get_opt_postfix(str);
423         if (!nr)
424                 return 0;
425
426         if (td_random(td))
427                 o->ddir_seq_nr = atoi(nr);
428         else {
429                 long long val;
430
431                 if (str_to_decimal(nr, &val, 1, o, 0, 0)) {
432                         log_err("fio: rw postfix parsing failed\n");
433                         free(nr);
434                         return 1;
435                 }
436
437                 o->ddir_seq_add = val;
438         }
439
440         free(nr);
441         return 0;
442 }
443
444 static int str_mem_cb(void *data, const char *mem)
445 {
446         struct thread_data *td = cb_data_to_td(data);
447
448         if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP ||
449             td->o.mem_type == MEM_MMAPSHARED)
450                 td->o.mmapfile = get_opt_postfix(mem);
451
452         return 0;
453 }
454
455 static int fio_clock_source_cb(void *data, const char *str)
456 {
457         struct thread_data *td = cb_data_to_td(data);
458
459         fio_clock_source = td->o.clocksource;
460         fio_clock_source_set = 1;
461         fio_clock_init();
462         return 0;
463 }
464
465 static int str_rwmix_read_cb(void *data, unsigned long long *val)
466 {
467         struct thread_data *td = cb_data_to_td(data);
468
469         td->o.rwmix[DDIR_READ] = *val;
470         td->o.rwmix[DDIR_WRITE] = 100 - *val;
471         return 0;
472 }
473
474 static int str_rwmix_write_cb(void *data, unsigned long long *val)
475 {
476         struct thread_data *td = cb_data_to_td(data);
477
478         td->o.rwmix[DDIR_WRITE] = *val;
479         td->o.rwmix[DDIR_READ] = 100 - *val;
480         return 0;
481 }
482
483 static int str_exitall_cb(void)
484 {
485         exitall_on_terminate = true;
486         return 0;
487 }
488
489 #ifdef FIO_HAVE_CPU_AFFINITY
490 int fio_cpus_split(os_cpu_mask_t *mask, unsigned int cpu_index)
491 {
492         unsigned int i, index, cpus_in_mask;
493         const long max_cpu = cpus_online();
494
495         cpus_in_mask = fio_cpu_count(mask);
496         if (!cpus_in_mask)
497                 return 0;
498
499         cpu_index = cpu_index % cpus_in_mask;
500
501         index = 0;
502         for (i = 0; i < max_cpu; i++) {
503                 if (!fio_cpu_isset(mask, i))
504                         continue;
505
506                 if (cpu_index != index)
507                         fio_cpu_clear(mask, i);
508
509                 index++;
510         }
511
512         return fio_cpu_count(mask);
513 }
514
515 static int str_cpumask_cb(void *data, unsigned long long *val)
516 {
517         struct thread_data *td = cb_data_to_td(data);
518         unsigned int i;
519         long max_cpu;
520         int ret;
521
522         if (parse_dryrun())
523                 return 0;
524
525         ret = fio_cpuset_init(&td->o.cpumask);
526         if (ret < 0) {
527                 log_err("fio: cpuset_init failed\n");
528                 td_verror(td, ret, "fio_cpuset_init");
529                 return 1;
530         }
531
532         max_cpu = cpus_online();
533
534         for (i = 0; i < sizeof(int) * 8; i++) {
535                 if ((1 << i) & *val) {
536                         if (i >= max_cpu) {
537                                 log_err("fio: CPU %d too large (max=%ld)\n", i,
538                                                                 max_cpu - 1);
539                                 return 1;
540                         }
541                         dprint(FD_PARSE, "set cpu allowed %d\n", i);
542                         fio_cpu_set(&td->o.cpumask, i);
543                 }
544         }
545
546         return 0;
547 }
548
549 static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask,
550                             const char *input)
551 {
552         char *cpu, *str, *p;
553         long max_cpu;
554         int ret = 0;
555
556         ret = fio_cpuset_init(mask);
557         if (ret < 0) {
558                 log_err("fio: cpuset_init failed\n");
559                 td_verror(td, ret, "fio_cpuset_init");
560                 return 1;
561         }
562
563         p = str = strdup(input);
564
565         strip_blank_front(&str);
566         strip_blank_end(str);
567
568         max_cpu = cpus_online();
569
570         while ((cpu = strsep(&str, ",")) != NULL) {
571                 char *str2, *cpu2;
572                 int icpu, icpu2;
573
574                 if (!strlen(cpu))
575                         break;
576
577                 str2 = cpu;
578                 icpu2 = -1;
579                 while ((cpu2 = strsep(&str2, "-")) != NULL) {
580                         if (!strlen(cpu2))
581                                 break;
582
583                         icpu2 = atoi(cpu2);
584                 }
585
586                 icpu = atoi(cpu);
587                 if (icpu2 == -1)
588                         icpu2 = icpu;
589                 while (icpu <= icpu2) {
590                         if (icpu >= FIO_MAX_CPUS) {
591                                 log_err("fio: your OS only supports up to"
592                                         " %d CPUs\n", (int) FIO_MAX_CPUS);
593                                 ret = 1;
594                                 break;
595                         }
596                         if (icpu >= max_cpu) {
597                                 log_err("fio: CPU %d too large (max=%ld)\n",
598                                                         icpu, max_cpu - 1);
599                                 ret = 1;
600                                 break;
601                         }
602
603                         dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
604                         fio_cpu_set(mask, icpu);
605                         icpu++;
606                 }
607                 if (ret)
608                         break;
609         }
610
611         free(p);
612         return ret;
613 }
614
615 static int str_cpus_allowed_cb(void *data, const char *input)
616 {
617         struct thread_data *td = cb_data_to_td(data);
618
619         if (parse_dryrun())
620                 return 0;
621
622         return set_cpus_allowed(td, &td->o.cpumask, input);
623 }
624
625 static int str_verify_cpus_allowed_cb(void *data, const char *input)
626 {
627         struct thread_data *td = cb_data_to_td(data);
628
629         if (parse_dryrun())
630                 return 0;
631
632         return set_cpus_allowed(td, &td->o.verify_cpumask, input);
633 }
634
635 #ifdef CONFIG_ZLIB
636 static int str_log_cpus_allowed_cb(void *data, const char *input)
637 {
638         struct thread_data *td = cb_data_to_td(data);
639
640         if (parse_dryrun())
641                 return 0;
642
643         return set_cpus_allowed(td, &td->o.log_gz_cpumask, input);
644 }
645 #endif /* CONFIG_ZLIB */
646
647 #endif /* FIO_HAVE_CPU_AFFINITY */
648
649 #ifdef CONFIG_LIBNUMA
650 static int str_numa_cpunodes_cb(void *data, char *input)
651 {
652         struct thread_data *td = cb_data_to_td(data);
653         struct bitmask *verify_bitmask;
654
655         if (parse_dryrun())
656                 return 0;
657
658         /* numa_parse_nodestring() parses a character string list
659          * of nodes into a bit mask. The bit mask is allocated by
660          * numa_allocate_nodemask(), so it should be freed by
661          * numa_free_nodemask().
662          */
663         verify_bitmask = numa_parse_nodestring(input);
664         if (verify_bitmask == NULL) {
665                 log_err("fio: numa_parse_nodestring failed\n");
666                 td_verror(td, 1, "str_numa_cpunodes_cb");
667                 return 1;
668         }
669         numa_free_nodemask(verify_bitmask);
670
671         td->o.numa_cpunodes = strdup(input);
672         return 0;
673 }
674
675 static int str_numa_mpol_cb(void *data, char *input)
676 {
677         struct thread_data *td = cb_data_to_td(data);
678         const char * const policy_types[] =
679                 { "default", "prefer", "bind", "interleave", "local", NULL };
680         int i;
681         char *nodelist;
682         struct bitmask *verify_bitmask;
683
684         if (parse_dryrun())
685                 return 0;
686
687         nodelist = strchr(input, ':');
688         if (nodelist) {
689                 /* NUL-terminate mode */
690                 *nodelist++ = '\0';
691         }
692
693         for (i = 0; i <= MPOL_LOCAL; i++) {
694                 if (!strcmp(input, policy_types[i])) {
695                         td->o.numa_mem_mode = i;
696                         break;
697                 }
698         }
699         if (i > MPOL_LOCAL) {
700                 log_err("fio: memory policy should be: default, prefer, bind, interleave, local\n");
701                 goto out;
702         }
703
704         switch (td->o.numa_mem_mode) {
705         case MPOL_PREFERRED:
706                 /*
707                  * Insist on a nodelist of one node only
708                  */
709                 if (nodelist) {
710                         char *rest = nodelist;
711                         while (isdigit(*rest))
712                                 rest++;
713                         if (*rest) {
714                                 log_err("fio: one node only for \'prefer\'\n");
715                                 goto out;
716                         }
717                 } else {
718                         log_err("fio: one node is needed for \'prefer\'\n");
719                         goto out;
720                 }
721                 break;
722         case MPOL_INTERLEAVE:
723                 /*
724                  * Default to online nodes with memory if no nodelist
725                  */
726                 if (!nodelist)
727                         nodelist = strdup("all");
728                 break;
729         case MPOL_LOCAL:
730         case MPOL_DEFAULT:
731                 /*
732                  * Don't allow a nodelist
733                  */
734                 if (nodelist) {
735                         log_err("fio: NO nodelist for \'local\'\n");
736                         goto out;
737                 }
738                 break;
739         case MPOL_BIND:
740                 /*
741                  * Insist on a nodelist
742                  */
743                 if (!nodelist) {
744                         log_err("fio: a nodelist is needed for \'bind\'\n");
745                         goto out;
746                 }
747                 break;
748         }
749
750
751         /* numa_parse_nodestring() parses a character string list
752          * of nodes into a bit mask. The bit mask is allocated by
753          * numa_allocate_nodemask(), so it should be freed by
754          * numa_free_nodemask().
755          */
756         switch (td->o.numa_mem_mode) {
757         case MPOL_PREFERRED:
758                 td->o.numa_mem_prefer_node = atoi(nodelist);
759                 break;
760         case MPOL_INTERLEAVE:
761         case MPOL_BIND:
762                 verify_bitmask = numa_parse_nodestring(nodelist);
763                 if (verify_bitmask == NULL) {
764                         log_err("fio: numa_parse_nodestring failed\n");
765                         td_verror(td, 1, "str_numa_memnodes_cb");
766                         return 1;
767                 }
768                 td->o.numa_memnodes = strdup(nodelist);
769                 numa_free_nodemask(verify_bitmask);
770
771                 break;
772         case MPOL_LOCAL:
773         case MPOL_DEFAULT:
774         default:
775                 break;
776         }
777
778         return 0;
779 out:
780         return 1;
781 }
782 #endif
783
784 static int str_fst_cb(void *data, const char *str)
785 {
786         struct thread_data *td = cb_data_to_td(data);
787         double val;
788         bool done = false;
789         char *nr;
790
791         td->file_service_nr = 1;
792
793         switch (td->o.file_service_type) {
794         case FIO_FSERVICE_RANDOM:
795         case FIO_FSERVICE_RR:
796         case FIO_FSERVICE_SEQ:
797                 nr = get_opt_postfix(str);
798                 if (nr) {
799                         td->file_service_nr = atoi(nr);
800                         free(nr);
801                 }
802                 done = true;
803                 break;
804         case FIO_FSERVICE_ZIPF:
805                 val = FIO_DEF_ZIPF;
806                 break;
807         case FIO_FSERVICE_PARETO:
808                 val = FIO_DEF_PARETO;
809                 break;
810         case FIO_FSERVICE_GAUSS:
811                 val = 0.0;
812                 break;
813         default:
814                 log_err("fio: bad file service type: %d\n", td->o.file_service_type);
815                 return 1;
816         }
817
818         if (done)
819                 return 0;
820
821         nr = get_opt_postfix(str);
822         if (nr && !str_to_float(nr, &val, 0)) {
823                 log_err("fio: file service type random postfix parsing failed\n");
824                 free(nr);
825                 return 1;
826         }
827
828         free(nr);
829
830         switch (td->o.file_service_type) {
831         case FIO_FSERVICE_ZIPF:
832                 if (val == 1.00) {
833                         log_err("fio: zipf theta must be different than 1.0\n");
834                         return 1;
835                 }
836                 if (parse_dryrun())
837                         return 0;
838                 td->zipf_theta = val;
839                 break;
840         case FIO_FSERVICE_PARETO:
841                 if (val <= 0.00 || val >= 1.00) {
842                           log_err("fio: pareto input out of range (0 < input < 1.0)\n");
843                           return 1;
844                 }
845                 if (parse_dryrun())
846                         return 0;
847                 td->pareto_h = val;
848                 break;
849         case FIO_FSERVICE_GAUSS:
850                 if (val < 0.00 || val >= 100.00) {
851                           log_err("fio: normal deviation out of range (0 <= input < 100.0)\n");
852                           return 1;
853                 }
854                 if (parse_dryrun())
855                         return 0;
856                 td->gauss_dev = val;
857                 break;
858         }
859
860         return 0;
861 }
862
863 #ifdef CONFIG_SYNC_FILE_RANGE
864 static int str_sfr_cb(void *data, const char *str)
865 {
866         struct thread_data *td = cb_data_to_td(data);
867         char *nr = get_opt_postfix(str);
868
869         td->sync_file_range_nr = 1;
870         if (nr) {
871                 td->sync_file_range_nr = atoi(nr);
872                 free(nr);
873         }
874
875         return 0;
876 }
877 #endif
878
879 static int zone_split_ddir(struct thread_options *o, enum fio_ddir ddir,
880                            char *str, bool absolute)
881 {
882         unsigned int i, perc, perc_missing, sperc, sperc_missing;
883         struct split split;
884
885         memset(&split, 0, sizeof(split));
886
887         if (split_parse_ddir(o, &split, str, absolute, ZONESPLIT_MAX))
888                 return 1;
889         if (!split.nr)
890                 return 0;
891
892         o->zone_split[ddir] = malloc(split.nr * sizeof(struct zone_split));
893         o->zone_split_nr[ddir] = split.nr;
894         for (i = 0; i < split.nr; i++) {
895                 o->zone_split[ddir][i].access_perc = split.val1[i];
896                 if (absolute)
897                         o->zone_split[ddir][i].size = split.val2[i];
898                 else
899                         o->zone_split[ddir][i].size_perc = split.val2[i];
900         }
901
902         /*
903          * Now check if the percentages add up, and how much is missing
904          */
905         perc = perc_missing = 0;
906         sperc = sperc_missing = 0;
907         for (i = 0; i < o->zone_split_nr[ddir]; i++) {
908                 struct zone_split *zsp = &o->zone_split[ddir][i];
909
910                 if (zsp->access_perc == (uint8_t) -1U)
911                         perc_missing++;
912                 else
913                         perc += zsp->access_perc;
914
915                 if (!absolute) {
916                         if (zsp->size_perc == (uint8_t) -1U)
917                                 sperc_missing++;
918                         else
919                                 sperc += zsp->size_perc;
920                 }
921         }
922
923         if (perc > 100 || sperc > 100) {
924                 log_err("fio: zone_split percentages add to more than 100%%\n");
925                 free(o->zone_split[ddir]);
926                 o->zone_split[ddir] = NULL;
927                 return 1;
928         }
929         if (perc < 100) {
930                 log_err("fio: access percentage don't add up to 100 for zoned "
931                         "random distribution (got=%u)\n", perc);
932                 free(o->zone_split[ddir]);
933                 o->zone_split[ddir] = NULL;
934                 return 1;
935         }
936
937         /*
938          * If values didn't have a percentage set, divide the remains between
939          * them.
940          */
941         if (perc_missing) {
942                 if (perc_missing == 1 && o->zone_split_nr[ddir] == 1)
943                         perc = 100;
944                 for (i = 0; i < o->zone_split_nr[ddir]; i++) {
945                         struct zone_split *zsp = &o->zone_split[ddir][i];
946
947                         if (zsp->access_perc == (uint8_t) -1U)
948                                 zsp->access_perc = (100 - perc) / perc_missing;
949                 }
950         }
951         if (sperc_missing) {
952                 if (sperc_missing == 1 && o->zone_split_nr[ddir] == 1)
953                         sperc = 100;
954                 for (i = 0; i < o->zone_split_nr[ddir]; i++) {
955                         struct zone_split *zsp = &o->zone_split[ddir][i];
956
957                         if (zsp->size_perc == (uint8_t) -1U)
958                                 zsp->size_perc = (100 - sperc) / sperc_missing;
959                 }
960         }
961
962         return 0;
963 }
964
965 static int parse_zoned_distribution(struct thread_data *td, const char *input,
966                                     bool absolute)
967 {
968         const char *pre = absolute ? "zoned_abs:" : "zoned:";
969         char *str, *p;
970         int i, ret = 0;
971
972         p = str = strdup(input);
973
974         strip_blank_front(&str);
975         strip_blank_end(str);
976
977         /* We expect it to start like that, bail if not */
978         if (strncmp(str, pre, strlen(pre))) {
979                 log_err("fio: mismatch in zoned input <%s>\n", str);
980                 free(p);
981                 return 1;
982         }
983         str += strlen(pre);
984
985         ret = str_split_parse(td, str, zone_split_ddir, absolute);
986
987         free(p);
988
989         for (i = 0; i < DDIR_RWDIR_CNT; i++) {
990                 int j;
991
992                 dprint(FD_PARSE, "zone ddir %d (nr=%u): \n", i, td->o.zone_split_nr[i]);
993
994                 for (j = 0; j < td->o.zone_split_nr[i]; j++) {
995                         struct zone_split *zsp = &td->o.zone_split[i][j];
996
997                         if (absolute) {
998                                 dprint(FD_PARSE, "\t%d: %u/%llu\n", j,
999                                                 zsp->access_perc,
1000                                                 (unsigned long long) zsp->size);
1001                         } else {
1002                                 dprint(FD_PARSE, "\t%d: %u/%u\n", j,
1003                                                 zsp->access_perc,
1004                                                 zsp->size_perc);
1005                         }
1006                 }
1007         }
1008
1009         if (parse_dryrun()) {
1010                 for (i = 0; i < DDIR_RWDIR_CNT; i++) {
1011                         free(td->o.zone_split[i]);
1012                         td->o.zone_split[i] = NULL;
1013                         td->o.zone_split_nr[i] = 0;
1014                 }
1015
1016                 return ret;
1017         }
1018
1019         if (ret) {
1020                 for (i = 0; i < DDIR_RWDIR_CNT; i++)
1021                         td->o.zone_split_nr[i] = 0;
1022         }
1023
1024         return ret;
1025 }
1026
1027 static int str_random_distribution_cb(void *data, const char *str)
1028 {
1029         struct thread_data *td = cb_data_to_td(data);
1030         double val;
1031         char *nr;
1032
1033         if (td->o.random_distribution == FIO_RAND_DIST_ZIPF)
1034                 val = FIO_DEF_ZIPF;
1035         else if (td->o.random_distribution == FIO_RAND_DIST_PARETO)
1036                 val = FIO_DEF_PARETO;
1037         else if (td->o.random_distribution == FIO_RAND_DIST_GAUSS)
1038                 val = 0.0;
1039         else if (td->o.random_distribution == FIO_RAND_DIST_ZONED)
1040                 return parse_zoned_distribution(td, str, false);
1041         else if (td->o.random_distribution == FIO_RAND_DIST_ZONED_ABS)
1042                 return parse_zoned_distribution(td, str, true);
1043         else
1044                 return 0;
1045
1046         nr = get_opt_postfix(str);
1047         if (nr && !str_to_float(nr, &val, 0)) {
1048                 log_err("fio: random postfix parsing failed\n");
1049                 free(nr);
1050                 return 1;
1051         }
1052
1053         free(nr);
1054
1055         if (td->o.random_distribution == FIO_RAND_DIST_ZIPF) {
1056                 if (val == 1.00) {
1057                         log_err("fio: zipf theta must different than 1.0\n");
1058                         return 1;
1059                 }
1060                 if (parse_dryrun())
1061                         return 0;
1062                 td->o.zipf_theta.u.f = val;
1063         } else if (td->o.random_distribution == FIO_RAND_DIST_PARETO) {
1064                 if (val <= 0.00 || val >= 1.00) {
1065                         log_err("fio: pareto input out of range (0 < input < 1.0)\n");
1066                         return 1;
1067                 }
1068                 if (parse_dryrun())
1069                         return 0;
1070                 td->o.pareto_h.u.f = val;
1071         } else {
1072                 if (val < 0.00 || val >= 100.0) {
1073                         log_err("fio: normal deviation out of range (0 <= input < 100.0)\n");
1074                         return 1;
1075                 }
1076                 if (parse_dryrun())
1077                         return 0;
1078                 td->o.gauss_dev.u.f = val;
1079         }
1080
1081         return 0;
1082 }
1083
1084 static int str_steadystate_cb(void *data, const char *str)
1085 {
1086         struct thread_data *td = cb_data_to_td(data);
1087         double val;
1088         char *nr;
1089         char *pct;
1090         long long ll;
1091
1092         if (td->o.ss_state != FIO_SS_IOPS && td->o.ss_state != FIO_SS_IOPS_SLOPE &&
1093             td->o.ss_state != FIO_SS_BW && td->o.ss_state != FIO_SS_BW_SLOPE) {
1094                 /* should be impossible to get here */
1095                 log_err("fio: unknown steady state criterion\n");
1096                 return 1;
1097         }
1098
1099         nr = get_opt_postfix(str);
1100         if (!nr) {
1101                 log_err("fio: steadystate threshold must be specified in addition to criterion\n");
1102                 free(nr);
1103                 return 1;
1104         }
1105
1106         /* ENHANCEMENT Allow fio to understand size=10.2% and use here */
1107         pct = strstr(nr, "%");
1108         if (pct) {
1109                 *pct = '\0';
1110                 strip_blank_end(nr);
1111                 if (!str_to_float(nr, &val, 0)) {
1112                         log_err("fio: could not parse steadystate threshold percentage\n");
1113                         free(nr);
1114                         return 1;
1115                 }
1116
1117                 dprint(FD_PARSE, "set steady state threshold to %f%%\n", val);
1118                 free(nr);
1119                 if (parse_dryrun())
1120                         return 0;
1121
1122                 td->o.ss_state |= FIO_SS_PCT;
1123                 td->o.ss_limit.u.f = val;
1124         } else if (td->o.ss_state & FIO_SS_IOPS) {
1125                 if (!str_to_float(nr, &val, 0)) {
1126                         log_err("fio: steadystate IOPS threshold postfix parsing failed\n");
1127                         free(nr);
1128                         return 1;
1129                 }
1130
1131                 dprint(FD_PARSE, "set steady state IOPS threshold to %f\n", val);
1132                 free(nr);
1133                 if (parse_dryrun())
1134                         return 0;
1135
1136                 td->o.ss_limit.u.f = val;
1137         } else {        /* bandwidth criterion */
1138                 if (str_to_decimal(nr, &ll, 1, td, 0, 0)) {
1139                         log_err("fio: steadystate BW threshold postfix parsing failed\n");
1140                         free(nr);
1141                         return 1;
1142                 }
1143
1144                 dprint(FD_PARSE, "set steady state BW threshold to %lld\n", ll);
1145                 free(nr);
1146                 if (parse_dryrun())
1147                         return 0;
1148
1149                 td->o.ss_limit.u.f = (double) ll;
1150         }
1151
1152         td->ss.state = td->o.ss_state;
1153         return 0;
1154 }
1155
1156 /*
1157  * Return next name in the string. Files are separated with ':'. If the ':'
1158  * is escaped with a '\', then that ':' is part of the filename and does not
1159  * indicate a new file.
1160  */
1161 char *get_next_str(char **ptr)
1162 {
1163         char *str = *ptr;
1164         char *p, *start;
1165
1166         if (!str || !strlen(str))
1167                 return NULL;
1168
1169         start = str;
1170         do {
1171                 /*
1172                  * No colon, we are done
1173                  */
1174                 p = strchr(str, ':');
1175                 if (!p) {
1176                         *ptr = NULL;
1177                         break;
1178                 }
1179
1180                 /*
1181                  * We got a colon, but it's the first character. Skip and
1182                  * continue
1183                  */
1184                 if (p == start) {
1185                         str = ++start;
1186                         continue;
1187                 }
1188
1189                 if (*(p - 1) != '\\') {
1190                         *p = '\0';
1191                         *ptr = p + 1;
1192                         break;
1193                 }
1194
1195                 memmove(p - 1, p, strlen(p) + 1);
1196                 str = p;
1197         } while (1);
1198
1199         return start;
1200 }
1201
1202
1203 int get_max_str_idx(char *input)
1204 {
1205         unsigned int cur_idx;
1206         char *str, *p;
1207
1208         p = str = strdup(input);
1209         for (cur_idx = 0; ; cur_idx++)
1210                 if (get_next_str(&str) == NULL)
1211                         break;
1212
1213         free(p);
1214         return cur_idx;
1215 }
1216
1217 /*
1218  * Returns the directory at the index, indexes > entires will be
1219  * assigned via modulo division of the index
1220  */
1221 int set_name_idx(char *target, size_t tlen, char *input, int index,
1222                  bool unique_filename)
1223 {
1224         unsigned int cur_idx;
1225         int len;
1226         char *fname, *str, *p;
1227
1228         p = str = strdup(input);
1229
1230         index %= get_max_str_idx(input);
1231         for (cur_idx = 0; cur_idx <= index; cur_idx++)
1232                 fname = get_next_str(&str);
1233
1234         if (client_sockaddr_str[0] && unique_filename) {
1235                 len = snprintf(target, tlen, "%s/%s.", fname,
1236                                 client_sockaddr_str);
1237         } else
1238                 len = snprintf(target, tlen, "%s/", fname);
1239
1240         target[tlen - 1] = '\0';
1241         free(p);
1242
1243         return len;
1244 }
1245
1246 char* get_name_by_idx(char *input, int index)
1247 {
1248         unsigned int cur_idx;
1249         char *fname, *str, *p;
1250
1251         p = str = strdup(input);
1252
1253         index %= get_max_str_idx(input);
1254         for (cur_idx = 0; cur_idx <= index; cur_idx++)
1255                 fname = get_next_str(&str);
1256
1257         fname = strdup(fname);
1258         free(p);
1259
1260         return fname;
1261 }
1262
1263 static int str_filename_cb(void *data, const char *input)
1264 {
1265         struct thread_data *td = cb_data_to_td(data);
1266         char *fname, *str, *p;
1267
1268         p = str = strdup(input);
1269
1270         strip_blank_front(&str);
1271         strip_blank_end(str);
1272
1273         /*
1274          * Ignore what we may already have from nrfiles option.
1275          */
1276         if (!td->files_index)
1277                 td->o.nr_files = 0;
1278
1279         while ((fname = get_next_str(&str)) != NULL) {
1280                 if (!strlen(fname))
1281                         break;
1282                 add_file(td, fname, 0, 1);
1283         }
1284
1285         free(p);
1286         return 0;
1287 }
1288
1289 static int str_directory_cb(void *data, const char fio_unused *unused)
1290 {
1291         struct thread_data *td = cb_data_to_td(data);
1292         struct stat sb;
1293         char *dirname, *str, *p;
1294         int ret = 0;
1295
1296         if (parse_dryrun())
1297                 return 0;
1298
1299         p = str = strdup(td->o.directory);
1300         while ((dirname = get_next_str(&str)) != NULL) {
1301                 if (lstat(dirname, &sb) < 0) {
1302                         ret = errno;
1303
1304                         log_err("fio: %s is not a directory\n", dirname);
1305                         td_verror(td, ret, "lstat");
1306                         goto out;
1307                 }
1308                 if (!S_ISDIR(sb.st_mode)) {
1309                         log_err("fio: %s is not a directory\n", dirname);
1310                         ret = 1;
1311                         goto out;
1312                 }
1313         }
1314
1315 out:
1316         free(p);
1317         return ret;
1318 }
1319
1320 static int str_opendir_cb(void *data, const char fio_unused *str)
1321 {
1322         struct thread_data *td = cb_data_to_td(data);
1323
1324         if (parse_dryrun())
1325                 return 0;
1326
1327         if (!td->files_index)
1328                 td->o.nr_files = 0;
1329
1330         return add_dir_files(td, td->o.opendir);
1331 }
1332
1333 static int str_buffer_pattern_cb(void *data, const char *input)
1334 {
1335         struct thread_data *td = cb_data_to_td(data);
1336         int ret;
1337
1338         /* FIXME: for now buffer pattern does not support formats */
1339         ret = parse_and_fill_pattern(input, strlen(input), td->o.buffer_pattern,
1340                                      MAX_PATTERN_SIZE, NULL, 0, NULL, NULL);
1341         if (ret < 0)
1342                 return 1;
1343
1344         assert(ret != 0);
1345         td->o.buffer_pattern_bytes = ret;
1346
1347         /*
1348          * If this job is doing any reading or has compression set,
1349          * ensure that we refill buffers for writes or we could be
1350          * invalidating the pattern through reads.
1351          */
1352         if (!td->o.compress_percentage && !td_read(td))
1353                 td->o.refill_buffers = 0;
1354         else
1355                 td->o.refill_buffers = 1;
1356
1357         td->o.scramble_buffers = 0;
1358         td->o.zero_buffers = 0;
1359
1360         return 0;
1361 }
1362
1363 static int str_buffer_compress_cb(void *data, unsigned long long *il)
1364 {
1365         struct thread_data *td = cb_data_to_td(data);
1366
1367         td->flags |= TD_F_COMPRESS;
1368         td->o.compress_percentage = *il;
1369         return 0;
1370 }
1371
1372 static int str_dedupe_cb(void *data, unsigned long long *il)
1373 {
1374         struct thread_data *td = cb_data_to_td(data);
1375
1376         td->flags |= TD_F_COMPRESS;
1377         td->o.dedupe_percentage = *il;
1378         td->o.refill_buffers = 1;
1379         return 0;
1380 }
1381
1382 static int str_verify_pattern_cb(void *data, const char *input)
1383 {
1384         struct thread_data *td = cb_data_to_td(data);
1385         int ret;
1386
1387         td->o.verify_fmt_sz = ARRAY_SIZE(td->o.verify_fmt);
1388         ret = parse_and_fill_pattern(input, strlen(input), td->o.verify_pattern,
1389                                      MAX_PATTERN_SIZE, fmt_desc, sizeof(fmt_desc),
1390                                      td->o.verify_fmt, &td->o.verify_fmt_sz);
1391         if (ret < 0)
1392                 return 1;
1393
1394         assert(ret != 0);
1395         td->o.verify_pattern_bytes = ret;
1396         /*
1397          * VERIFY_* could already be set
1398          */
1399         if (!fio_option_is_set(&td->o, verify))
1400                 td->o.verify = VERIFY_PATTERN;
1401
1402         return 0;
1403 }
1404
1405 static int str_gtod_reduce_cb(void *data, int *il)
1406 {
1407         struct thread_data *td = cb_data_to_td(data);
1408         int val = *il;
1409
1410         td->o.disable_lat = !!val;
1411         td->o.disable_clat = !!val;
1412         td->o.disable_slat = !!val;
1413         td->o.disable_bw = !!val;
1414         td->o.clat_percentiles = !val;
1415         if (val)
1416                 td->ts_cache_mask = 63;
1417
1418         return 0;
1419 }
1420
1421 static int str_offset_cb(void *data, unsigned long long *__val)
1422 {
1423         struct thread_data *td = cb_data_to_td(data);
1424         unsigned long long v = *__val;
1425
1426         if (parse_is_percent(v)) {
1427                 td->o.start_offset = 0;
1428                 td->o.start_offset_percent = -1ULL - v;
1429                 dprint(FD_PARSE, "SET start_offset_percent %d\n",
1430                                         td->o.start_offset_percent);
1431         } else
1432                 td->o.start_offset = v;
1433
1434         return 0;
1435 }
1436
1437 static int str_size_cb(void *data, unsigned long long *__val)
1438 {
1439         struct thread_data *td = cb_data_to_td(data);
1440         unsigned long long v = *__val;
1441
1442         if (parse_is_percent(v)) {
1443                 td->o.size = 0;
1444                 td->o.size_percent = -1ULL - v;
1445                 dprint(FD_PARSE, "SET size_percent %d\n",
1446                                         td->o.size_percent);
1447         } else
1448                 td->o.size = v;
1449
1450         return 0;
1451 }
1452
1453 static int str_write_bw_log_cb(void *data, const char *str)
1454 {
1455         struct thread_data *td = cb_data_to_td(data);
1456
1457         if (str)
1458                 td->o.bw_log_file = strdup(str);
1459
1460         td->o.write_bw_log = 1;
1461         return 0;
1462 }
1463
1464 static int str_write_lat_log_cb(void *data, const char *str)
1465 {
1466         struct thread_data *td = cb_data_to_td(data);
1467
1468         if (str)
1469                 td->o.lat_log_file = strdup(str);
1470
1471         td->o.write_lat_log = 1;
1472         return 0;
1473 }
1474
1475 static int str_write_iops_log_cb(void *data, const char *str)
1476 {
1477         struct thread_data *td = cb_data_to_td(data);
1478
1479         if (str)
1480                 td->o.iops_log_file = strdup(str);
1481
1482         td->o.write_iops_log = 1;
1483         return 0;
1484 }
1485
1486 static int str_write_hist_log_cb(void *data, const char *str)
1487 {
1488         struct thread_data *td = cb_data_to_td(data);
1489
1490         if (str)
1491                 td->o.hist_log_file = strdup(str);
1492
1493         td->o.write_hist_log = 1;
1494         return 0;
1495 }
1496
1497 /*
1498  * str is supposed to be a substring of the strdup'd original string,
1499  * and is valid only if it's a regular file path.
1500  * This function keeps the pointer to the path as needed later.
1501  *
1502  * "external:/path/to/so\0" <- original pointer updated with strdup'd
1503  * "external\0"             <- above pointer after parsed, i.e. ->ioengine
1504  *          "/path/to/so\0" <- str argument, i.e. ->ioengine_so_path
1505  */
1506 static int str_ioengine_external_cb(void *data, const char *str)
1507 {
1508         struct thread_data *td = cb_data_to_td(data);
1509         struct stat sb;
1510         char *p;
1511
1512         if (!str) {
1513                 log_err("fio: null external ioengine path\n");
1514                 return 1;
1515         }
1516
1517         p = (char *)str; /* str is mutable */
1518         strip_blank_front(&p);
1519         strip_blank_end(p);
1520
1521         if (stat(p, &sb) || !S_ISREG(sb.st_mode)) {
1522                 log_err("fio: invalid external ioengine path \"%s\"\n", p);
1523                 return 1;
1524         }
1525
1526         td->o.ioengine_so_path = p;
1527         return 0;
1528 }
1529
1530 static int rw_verify(const struct fio_option *o, void *data)
1531 {
1532         struct thread_data *td = cb_data_to_td(data);
1533
1534         if (read_only && (td_write(td) || td_trim(td))) {
1535                 log_err("fio: job <%s> has write or trim bit set, but"
1536                         " fio is in read-only mode\n", td->o.name);
1537                 return 1;
1538         }
1539
1540         return 0;
1541 }
1542
1543 static int gtod_cpu_verify(const struct fio_option *o, void *data)
1544 {
1545 #ifndef FIO_HAVE_CPU_AFFINITY
1546         struct thread_data *td = cb_data_to_td(data);
1547
1548         if (td->o.gtod_cpu) {
1549                 log_err("fio: platform must support CPU affinity for"
1550                         "gettimeofday() offloading\n");
1551                 return 1;
1552         }
1553 #endif
1554
1555         return 0;
1556 }
1557
1558 /*
1559  * Map of job/command line options
1560  */
1561 struct fio_option fio_options[FIO_MAX_OPTS] = {
1562         {
1563                 .name   = "description",
1564                 .lname  = "Description of job",
1565                 .type   = FIO_OPT_STR_STORE,
1566                 .off1   = offsetof(struct thread_options, description),
1567                 .help   = "Text job description",
1568                 .category = FIO_OPT_C_GENERAL,
1569                 .group  = FIO_OPT_G_DESC,
1570         },
1571         {
1572                 .name   = "name",
1573                 .lname  = "Job name",
1574                 .type   = FIO_OPT_STR_STORE,
1575                 .off1   = offsetof(struct thread_options, name),
1576                 .help   = "Name of this job",
1577                 .category = FIO_OPT_C_GENERAL,
1578                 .group  = FIO_OPT_G_DESC,
1579         },
1580         {
1581                 .name   = "wait_for",
1582                 .lname  = "Waitee name",
1583                 .type   = FIO_OPT_STR_STORE,
1584                 .off1   = offsetof(struct thread_options, wait_for),
1585                 .help   = "Name of the job this one wants to wait for before starting",
1586                 .category = FIO_OPT_C_GENERAL,
1587                 .group  = FIO_OPT_G_DESC,
1588         },
1589         {
1590                 .name   = "filename",
1591                 .lname  = "Filename(s)",
1592                 .type   = FIO_OPT_STR_STORE,
1593                 .off1   = offsetof(struct thread_options, filename),
1594                 .cb     = str_filename_cb,
1595                 .prio   = -1, /* must come after "directory" */
1596                 .help   = "File(s) to use for the workload",
1597                 .category = FIO_OPT_C_FILE,
1598                 .group  = FIO_OPT_G_FILENAME,
1599         },
1600         {
1601                 .name   = "directory",
1602                 .lname  = "Directory",
1603                 .type   = FIO_OPT_STR_STORE,
1604                 .off1   = offsetof(struct thread_options, directory),
1605                 .cb     = str_directory_cb,
1606                 .help   = "Directory to store files in",
1607                 .category = FIO_OPT_C_FILE,
1608                 .group  = FIO_OPT_G_FILENAME,
1609         },
1610         {
1611                 .name   = "filename_format",
1612                 .lname  = "Filename Format",
1613                 .type   = FIO_OPT_STR_STORE,
1614                 .off1   = offsetof(struct thread_options, filename_format),
1615                 .prio   = -1, /* must come after "directory" */
1616                 .help   = "Override default $jobname.$jobnum.$filenum naming",
1617                 .def    = "$jobname.$jobnum.$filenum",
1618                 .category = FIO_OPT_C_FILE,
1619                 .group  = FIO_OPT_G_FILENAME,
1620         },
1621         {
1622                 .name   = "unique_filename",
1623                 .lname  = "Unique Filename",
1624                 .type   = FIO_OPT_BOOL,
1625                 .off1   = offsetof(struct thread_options, unique_filename),
1626                 .help   = "For network clients, prefix file with source IP",
1627                 .def    = "1",
1628                 .category = FIO_OPT_C_FILE,
1629                 .group  = FIO_OPT_G_FILENAME,
1630         },
1631         {
1632                 .name   = "lockfile",
1633                 .lname  = "Lockfile",
1634                 .type   = FIO_OPT_STR,
1635                 .off1   = offsetof(struct thread_options, file_lock_mode),
1636                 .help   = "Lock file when doing IO to it",
1637                 .prio   = 1,
1638                 .parent = "filename",
1639                 .hide   = 0,
1640                 .def    = "none",
1641                 .category = FIO_OPT_C_FILE,
1642                 .group  = FIO_OPT_G_FILENAME,
1643                 .posval = {
1644                           { .ival = "none",
1645                             .oval = FILE_LOCK_NONE,
1646                             .help = "No file locking",
1647                           },
1648                           { .ival = "exclusive",
1649                             .oval = FILE_LOCK_EXCLUSIVE,
1650                             .help = "Exclusive file lock",
1651                           },
1652                           {
1653                             .ival = "readwrite",
1654                             .oval = FILE_LOCK_READWRITE,
1655                             .help = "Read vs write lock",
1656                           },
1657                 },
1658         },
1659         {
1660                 .name   = "opendir",
1661                 .lname  = "Open directory",
1662                 .type   = FIO_OPT_STR_STORE,
1663                 .off1   = offsetof(struct thread_options, opendir),
1664                 .cb     = str_opendir_cb,
1665                 .help   = "Recursively add files from this directory and down",
1666                 .category = FIO_OPT_C_FILE,
1667                 .group  = FIO_OPT_G_FILENAME,
1668         },
1669         {
1670                 .name   = "rw",
1671                 .lname  = "Read/write",
1672                 .alias  = "readwrite",
1673                 .type   = FIO_OPT_STR,
1674                 .cb     = str_rw_cb,
1675                 .off1   = offsetof(struct thread_options, td_ddir),
1676                 .help   = "IO direction",
1677                 .def    = "read",
1678                 .verify = rw_verify,
1679                 .category = FIO_OPT_C_IO,
1680                 .group  = FIO_OPT_G_IO_BASIC,
1681                 .posval = {
1682                           { .ival = "read",
1683                             .oval = TD_DDIR_READ,
1684                             .help = "Sequential read",
1685                           },
1686                           { .ival = "write",
1687                             .oval = TD_DDIR_WRITE,
1688                             .help = "Sequential write",
1689                           },
1690                           { .ival = "trim",
1691                             .oval = TD_DDIR_TRIM,
1692                             .help = "Sequential trim",
1693                           },
1694                           { .ival = "randread",
1695                             .oval = TD_DDIR_RANDREAD,
1696                             .help = "Random read",
1697                           },
1698                           { .ival = "randwrite",
1699                             .oval = TD_DDIR_RANDWRITE,
1700                             .help = "Random write",
1701                           },
1702                           { .ival = "randtrim",
1703                             .oval = TD_DDIR_RANDTRIM,
1704                             .help = "Random trim",
1705                           },
1706                           { .ival = "rw",
1707                             .oval = TD_DDIR_RW,
1708                             .help = "Sequential read and write mix",
1709                           },
1710                           { .ival = "readwrite",
1711                             .oval = TD_DDIR_RW,
1712                             .help = "Sequential read and write mix",
1713                           },
1714                           { .ival = "randrw",
1715                             .oval = TD_DDIR_RANDRW,
1716                             .help = "Random read and write mix"
1717                           },
1718                           { .ival = "trimwrite",
1719                             .oval = TD_DDIR_TRIMWRITE,
1720                             .help = "Trim and write mix, trims preceding writes"
1721                           },
1722                 },
1723         },
1724         {
1725                 .name   = "rw_sequencer",
1726                 .lname  = "RW Sequencer",
1727                 .type   = FIO_OPT_STR,
1728                 .off1   = offsetof(struct thread_options, rw_seq),
1729                 .help   = "IO offset generator modifier",
1730                 .def    = "sequential",
1731                 .category = FIO_OPT_C_IO,
1732                 .group  = FIO_OPT_G_IO_BASIC,
1733                 .posval = {
1734                           { .ival = "sequential",
1735                             .oval = RW_SEQ_SEQ,
1736                             .help = "Generate sequential offsets",
1737                           },
1738                           { .ival = "identical",
1739                             .oval = RW_SEQ_IDENT,
1740                             .help = "Generate identical offsets",
1741                           },
1742                 },
1743         },
1744
1745         {
1746                 .name   = "ioengine",
1747                 .lname  = "IO Engine",
1748                 .type   = FIO_OPT_STR_STORE,
1749                 .off1   = offsetof(struct thread_options, ioengine),
1750                 .help   = "IO engine to use",
1751                 .def    = FIO_PREFERRED_ENGINE,
1752                 .category = FIO_OPT_C_IO,
1753                 .group  = FIO_OPT_G_IO_BASIC,
1754                 .posval = {
1755                           { .ival = "sync",
1756                             .help = "Use read/write",
1757                           },
1758                           { .ival = "psync",
1759                             .help = "Use pread/pwrite",
1760                           },
1761                           { .ival = "vsync",
1762                             .help = "Use readv/writev",
1763                           },
1764 #ifdef CONFIG_PWRITEV
1765                           { .ival = "pvsync",
1766                             .help = "Use preadv/pwritev",
1767                           },
1768 #endif
1769 #ifdef FIO_HAVE_PWRITEV2
1770                           { .ival = "pvsync2",
1771                             .help = "Use preadv2/pwritev2",
1772                           },
1773 #endif
1774 #ifdef CONFIG_LIBAIO
1775                           { .ival = "libaio",
1776                             .help = "Linux native asynchronous IO",
1777                           },
1778 #endif
1779 #ifdef ARCH_HAVE_IOURING
1780                           { .ival = "io_uring",
1781                             .help = "Fast Linux native aio",
1782                           },
1783 #endif
1784 #ifdef CONFIG_POSIXAIO
1785                           { .ival = "posixaio",
1786                             .help = "POSIX asynchronous IO",
1787                           },
1788 #endif
1789 #ifdef CONFIG_SOLARISAIO
1790                           { .ival = "solarisaio",
1791                             .help = "Solaris native asynchronous IO",
1792                           },
1793 #endif
1794 #ifdef CONFIG_WINDOWSAIO
1795                           { .ival = "windowsaio",
1796                             .help = "Windows native asynchronous IO"
1797                           },
1798 #endif
1799 #ifdef CONFIG_RBD
1800                           { .ival = "rbd",
1801                             .help = "Rados Block Device asynchronous IO"
1802                           },
1803 #endif
1804                           { .ival = "mmap",
1805                             .help = "Memory mapped IO"
1806                           },
1807 #ifdef CONFIG_LINUX_SPLICE
1808                           { .ival = "splice",
1809                             .help = "splice/vmsplice based IO",
1810                           },
1811                           { .ival = "netsplice",
1812                             .help = "splice/vmsplice to/from the network",
1813                           },
1814 #endif
1815 #ifdef FIO_HAVE_SGIO
1816                           { .ival = "sg",
1817                             .help = "SCSI generic v3 IO",
1818                           },
1819 #endif
1820                           { .ival = "null",
1821                             .help = "Testing engine (no data transfer)",
1822                           },
1823                           { .ival = "net",
1824                             .help = "Network IO",
1825                           },
1826                           { .ival = "cpuio",
1827                             .help = "CPU cycle burner engine",
1828                           },
1829 #ifdef CONFIG_GUASI
1830                           { .ival = "guasi",
1831                             .help = "GUASI IO engine",
1832                           },
1833 #endif
1834 #ifdef CONFIG_RDMA
1835                           { .ival = "rdma",
1836                             .help = "RDMA IO engine",
1837                           },
1838 #endif
1839 #ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
1840                           { .ival = "e4defrag",
1841                             .help = "ext4 defrag engine",
1842                           },
1843 #endif
1844 #ifdef CONFIG_LINUX_FALLOCATE
1845                           { .ival = "falloc",
1846                             .help = "fallocate() file based engine",
1847                           },
1848 #endif
1849 #ifdef CONFIG_GFAPI
1850                           { .ival = "gfapi",
1851                             .help = "Glusterfs libgfapi(sync) based engine"
1852                           },
1853                           { .ival = "gfapi_async",
1854                             .help = "Glusterfs libgfapi(async) based engine"
1855                           },
1856 #endif
1857 #ifdef CONFIG_LIBHDFS
1858                           { .ival = "libhdfs",
1859                             .help = "Hadoop Distributed Filesystem (HDFS) engine"
1860                           },
1861 #endif
1862 #ifdef CONFIG_PMEMBLK
1863                           { .ival = "pmemblk",
1864                             .help = "PMDK libpmemblk based IO engine",
1865                           },
1866
1867 #endif
1868 #ifdef CONFIG_IME
1869                           { .ival = "ime_psync",
1870                             .help = "DDN's IME synchronous IO engine",
1871                           },
1872                           { .ival = "ime_psyncv",
1873                             .help = "DDN's IME synchronous IO engine using iovecs",
1874                           },
1875                           { .ival = "ime_aio",
1876                             .help = "DDN's IME asynchronous IO engine",
1877                           },
1878 #endif
1879 #ifdef CONFIG_LINUX_DEVDAX
1880                           { .ival = "dev-dax",
1881                             .help = "DAX Device based IO engine",
1882                           },
1883 #endif
1884                           {
1885                             .ival = "filecreate",
1886                             .help = "File creation engine",
1887                           },
1888                           { .ival = "external",
1889                             .help = "Load external engine (append name)",
1890                             .cb = str_ioengine_external_cb,
1891                           },
1892 #ifdef CONFIG_LIBPMEM
1893                           { .ival = "libpmem",
1894                             .help = "PMDK libpmem based IO engine",
1895                           },
1896 #endif
1897 #ifdef CONFIG_HTTP
1898                           { .ival = "http",
1899                             .help = "HTTP (WebDAV/S3) IO engine",
1900                           },
1901 #endif
1902                           { .ival = "nbd",
1903                             .help = "Network Block Device (NBD) IO engine"
1904                           },
1905                 },
1906         },
1907         {
1908                 .name   = "iodepth",
1909                 .lname  = "IO Depth",
1910                 .type   = FIO_OPT_INT,
1911                 .off1   = offsetof(struct thread_options, iodepth),
1912                 .help   = "Number of IO buffers to keep in flight",
1913                 .minval = 1,
1914                 .interval = 1,
1915                 .def    = "1",
1916                 .category = FIO_OPT_C_IO,
1917                 .group  = FIO_OPT_G_IO_BASIC,
1918         },
1919         {
1920                 .name   = "iodepth_batch",
1921                 .lname  = "IO Depth batch",
1922                 .alias  = "iodepth_batch_submit",
1923                 .type   = FIO_OPT_INT,
1924                 .off1   = offsetof(struct thread_options, iodepth_batch),
1925                 .help   = "Number of IO buffers to submit in one go",
1926                 .parent = "iodepth",
1927                 .hide   = 1,
1928                 .interval = 1,
1929                 .def    = "1",
1930                 .category = FIO_OPT_C_IO,
1931                 .group  = FIO_OPT_G_IO_BASIC,
1932         },
1933         {
1934                 .name   = "iodepth_batch_complete_min",
1935                 .lname  = "Min IO depth batch complete",
1936                 .alias  = "iodepth_batch_complete",
1937                 .type   = FIO_OPT_INT,
1938                 .off1   = offsetof(struct thread_options, iodepth_batch_complete_min),
1939                 .help   = "Min number of IO buffers to retrieve in one go",
1940                 .parent = "iodepth",
1941                 .hide   = 1,
1942                 .minval = 0,
1943                 .interval = 1,
1944                 .def    = "1",
1945                 .category = FIO_OPT_C_IO,
1946                 .group  = FIO_OPT_G_IO_BASIC,
1947         },
1948         {
1949                 .name   = "iodepth_batch_complete_max",
1950                 .lname  = "Max IO depth batch complete",
1951                 .type   = FIO_OPT_INT,
1952                 .off1   = offsetof(struct thread_options, iodepth_batch_complete_max),
1953                 .help   = "Max number of IO buffers to retrieve in one go",
1954                 .parent = "iodepth",
1955                 .hide   = 1,
1956                 .minval = 0,
1957                 .interval = 1,
1958                 .category = FIO_OPT_C_IO,
1959                 .group  = FIO_OPT_G_IO_BASIC,
1960         },
1961         {
1962                 .name   = "iodepth_low",
1963                 .lname  = "IO Depth batch low",
1964                 .type   = FIO_OPT_INT,
1965                 .off1   = offsetof(struct thread_options, iodepth_low),
1966                 .help   = "Low water mark for queuing depth",
1967                 .parent = "iodepth",
1968                 .hide   = 1,
1969                 .interval = 1,
1970                 .category = FIO_OPT_C_IO,
1971                 .group  = FIO_OPT_G_IO_BASIC,
1972         },
1973         {
1974                 .name   = "serialize_overlap",
1975                 .lname  = "Serialize overlap",
1976                 .off1   = offsetof(struct thread_options, serialize_overlap),
1977                 .type   = FIO_OPT_BOOL,
1978                 .help   = "Wait for in-flight IOs that collide to complete",
1979                 .parent = "iodepth",
1980                 .def    = "0",
1981                 .category = FIO_OPT_C_IO,
1982                 .group  = FIO_OPT_G_IO_BASIC,
1983         },
1984         {
1985                 .name   = "io_submit_mode",
1986                 .lname  = "IO submit mode",
1987                 .type   = FIO_OPT_STR,
1988                 .off1   = offsetof(struct thread_options, io_submit_mode),
1989                 .help   = "How IO submissions and completions are done",
1990                 .def    = "inline",
1991                 .category = FIO_OPT_C_IO,
1992                 .group  = FIO_OPT_G_IO_BASIC,
1993                 .posval = {
1994                           { .ival = "inline",
1995                             .oval = IO_MODE_INLINE,
1996                             .help = "Submit and complete IO inline",
1997                           },
1998                           { .ival = "offload",
1999                             .oval = IO_MODE_OFFLOAD,
2000                             .help = "Offload submit and complete to threads",
2001                           },
2002                 },
2003         },
2004         {
2005                 .name   = "size",
2006                 .lname  = "Size",
2007                 .type   = FIO_OPT_STR_VAL,
2008                 .cb     = str_size_cb,
2009                 .off1   = offsetof(struct thread_options, size),
2010                 .help   = "Total size of device or files",
2011                 .interval = 1024 * 1024,
2012                 .category = FIO_OPT_C_IO,
2013                 .group  = FIO_OPT_G_INVALID,
2014         },
2015         {
2016                 .name   = "io_size",
2017                 .alias  = "io_limit",
2018                 .lname  = "IO Size",
2019                 .type   = FIO_OPT_STR_VAL,
2020                 .off1   = offsetof(struct thread_options, io_size),
2021                 .help   = "Total size of I/O to be performed",
2022                 .interval = 1024 * 1024,
2023                 .category = FIO_OPT_C_IO,
2024                 .group  = FIO_OPT_G_INVALID,
2025         },
2026         {
2027                 .name   = "fill_device",
2028                 .lname  = "Fill device",
2029                 .alias  = "fill_fs",
2030                 .type   = FIO_OPT_BOOL,
2031                 .off1   = offsetof(struct thread_options, fill_device),
2032                 .help   = "Write until an ENOSPC error occurs",
2033                 .def    = "0",
2034                 .category = FIO_OPT_C_FILE,
2035                 .group  = FIO_OPT_G_INVALID,
2036         },
2037         {
2038                 .name   = "filesize",
2039                 .lname  = "File size",
2040                 .type   = FIO_OPT_STR_VAL,
2041                 .off1   = offsetof(struct thread_options, file_size_low),
2042                 .off2   = offsetof(struct thread_options, file_size_high),
2043                 .minval = 1,
2044                 .help   = "Size of individual files",
2045                 .interval = 1024 * 1024,
2046                 .category = FIO_OPT_C_FILE,
2047                 .group  = FIO_OPT_G_INVALID,
2048         },
2049         {
2050                 .name   = "file_append",
2051                 .lname  = "File append",
2052                 .type   = FIO_OPT_BOOL,
2053                 .off1   = offsetof(struct thread_options, file_append),
2054                 .help   = "IO will start at the end of the file(s)",
2055                 .def    = "0",
2056                 .category = FIO_OPT_C_FILE,
2057                 .group  = FIO_OPT_G_INVALID,
2058         },
2059         {
2060                 .name   = "offset",
2061                 .lname  = "IO offset",
2062                 .alias  = "fileoffset",
2063                 .type   = FIO_OPT_STR_VAL,
2064                 .cb     = str_offset_cb,
2065                 .off1   = offsetof(struct thread_options, start_offset),
2066                 .help   = "Start IO from this offset",
2067                 .def    = "0",
2068                 .interval = 1024 * 1024,
2069                 .category = FIO_OPT_C_IO,
2070                 .group  = FIO_OPT_G_INVALID,
2071         },
2072         {
2073                 .name   = "offset_align",
2074                 .lname  = "IO offset alignment",
2075                 .type   = FIO_OPT_INT,
2076                 .off1   = offsetof(struct thread_options, start_offset_align),
2077                 .help   = "Start IO from this offset alignment",
2078                 .def    = "0",
2079                 .interval = 512,
2080                 .category = FIO_OPT_C_IO,
2081                 .group  = FIO_OPT_G_INVALID,
2082         },
2083         {
2084                 .name   = "offset_increment",
2085                 .lname  = "IO offset increment",
2086                 .type   = FIO_OPT_STR_VAL,
2087                 .off1   = offsetof(struct thread_options, offset_increment),
2088                 .help   = "What is the increment from one offset to the next",
2089                 .parent = "offset",
2090                 .hide   = 1,
2091                 .def    = "0",
2092                 .interval = 1024 * 1024,
2093                 .category = FIO_OPT_C_IO,
2094                 .group  = FIO_OPT_G_INVALID,
2095         },
2096         {
2097                 .name   = "number_ios",
2098                 .lname  = "Number of IOs to perform",
2099                 .type   = FIO_OPT_STR_VAL,
2100                 .off1   = offsetof(struct thread_options, number_ios),
2101                 .help   = "Force job completion after this number of IOs",
2102                 .def    = "0",
2103                 .category = FIO_OPT_C_IO,
2104                 .group  = FIO_OPT_G_INVALID,
2105         },
2106         {
2107                 .name   = "bs",
2108                 .lname  = "Block size",
2109                 .alias  = "blocksize",
2110                 .type   = FIO_OPT_ULL,
2111                 .off1   = offsetof(struct thread_options, bs[DDIR_READ]),
2112                 .off2   = offsetof(struct thread_options, bs[DDIR_WRITE]),
2113                 .off3   = offsetof(struct thread_options, bs[DDIR_TRIM]),
2114                 .minval = 1,
2115                 .help   = "Block size unit",
2116                 .def    = "4096",
2117                 .parent = "rw",
2118                 .hide   = 1,
2119                 .interval = 512,
2120                 .category = FIO_OPT_C_IO,
2121                 .group  = FIO_OPT_G_INVALID,
2122         },
2123         {
2124                 .name   = "ba",
2125                 .lname  = "Block size align",
2126                 .alias  = "blockalign",
2127                 .type   = FIO_OPT_ULL,
2128                 .off1   = offsetof(struct thread_options, ba[DDIR_READ]),
2129                 .off2   = offsetof(struct thread_options, ba[DDIR_WRITE]),
2130                 .off3   = offsetof(struct thread_options, ba[DDIR_TRIM]),
2131                 .minval = 1,
2132                 .help   = "IO block offset alignment",
2133                 .parent = "rw",
2134                 .hide   = 1,
2135                 .interval = 512,
2136                 .category = FIO_OPT_C_IO,
2137                 .group  = FIO_OPT_G_INVALID,
2138         },
2139         {
2140                 .name   = "bsrange",
2141                 .lname  = "Block size range",
2142                 .alias  = "blocksize_range",
2143                 .type   = FIO_OPT_RANGE,
2144                 .off1   = offsetof(struct thread_options, min_bs[DDIR_READ]),
2145                 .off2   = offsetof(struct thread_options, max_bs[DDIR_READ]),
2146                 .off3   = offsetof(struct thread_options, min_bs[DDIR_WRITE]),
2147                 .off4   = offsetof(struct thread_options, max_bs[DDIR_WRITE]),
2148                 .off5   = offsetof(struct thread_options, min_bs[DDIR_TRIM]),
2149                 .off6   = offsetof(struct thread_options, max_bs[DDIR_TRIM]),
2150                 .minval = 1,
2151                 .help   = "Set block size range (in more detail than bs)",
2152                 .parent = "rw",
2153                 .hide   = 1,
2154                 .interval = 4096,
2155                 .category = FIO_OPT_C_IO,
2156                 .group  = FIO_OPT_G_INVALID,
2157         },
2158         {
2159                 .name   = "bssplit",
2160                 .lname  = "Block size split",
2161                 .type   = FIO_OPT_STR_ULL,
2162                 .cb     = str_bssplit_cb,
2163                 .off1   = offsetof(struct thread_options, bssplit),
2164                 .help   = "Set a specific mix of block sizes",
2165                 .parent = "rw",
2166                 .hide   = 1,
2167                 .category = FIO_OPT_C_IO,
2168                 .group  = FIO_OPT_G_INVALID,
2169         },
2170         {
2171                 .name   = "bs_unaligned",
2172                 .lname  = "Block size unaligned",
2173                 .alias  = "blocksize_unaligned",
2174                 .type   = FIO_OPT_STR_SET,
2175                 .off1   = offsetof(struct thread_options, bs_unaligned),
2176                 .help   = "Don't sector align IO buffer sizes",
2177                 .parent = "rw",
2178                 .hide   = 1,
2179                 .category = FIO_OPT_C_IO,
2180                 .group  = FIO_OPT_G_INVALID,
2181         },
2182         {
2183                 .name   = "bs_is_seq_rand",
2184                 .lname  = "Block size division is seq/random (not read/write)",
2185                 .type   = FIO_OPT_BOOL,
2186                 .off1   = offsetof(struct thread_options, bs_is_seq_rand),
2187                 .help   = "Consider any blocksize setting to be sequential,random",
2188                 .def    = "0",
2189                 .parent = "blocksize",
2190                 .category = FIO_OPT_C_IO,
2191                 .group  = FIO_OPT_G_INVALID,
2192         },
2193         {
2194                 .name   = "randrepeat",
2195                 .lname  = "Random repeatable",
2196                 .type   = FIO_OPT_BOOL,
2197                 .off1   = offsetof(struct thread_options, rand_repeatable),
2198                 .help   = "Use repeatable random IO pattern",
2199                 .def    = "1",
2200                 .parent = "rw",
2201                 .hide   = 1,
2202                 .category = FIO_OPT_C_IO,
2203                 .group  = FIO_OPT_G_RANDOM,
2204         },
2205         {
2206                 .name   = "randseed",
2207                 .lname  = "The random generator seed",
2208                 .type   = FIO_OPT_STR_VAL,
2209                 .off1   = offsetof(struct thread_options, rand_seed),
2210                 .help   = "Set the random generator seed value",
2211                 .def    = "0x89",
2212                 .parent = "rw",
2213                 .category = FIO_OPT_C_IO,
2214                 .group  = FIO_OPT_G_RANDOM,
2215         },
2216         {
2217                 .name   = "norandommap",
2218                 .lname  = "No randommap",
2219                 .type   = FIO_OPT_STR_SET,
2220                 .off1   = offsetof(struct thread_options, norandommap),
2221                 .help   = "Accept potential duplicate random blocks",
2222                 .parent = "rw",
2223                 .hide   = 1,
2224                 .hide_on_set = 1,
2225                 .category = FIO_OPT_C_IO,
2226                 .group  = FIO_OPT_G_RANDOM,
2227         },
2228         {
2229                 .name   = "softrandommap",
2230                 .lname  = "Soft randommap",
2231                 .type   = FIO_OPT_BOOL,
2232                 .off1   = offsetof(struct thread_options, softrandommap),
2233                 .help   = "Set norandommap if randommap allocation fails",
2234                 .parent = "norandommap",
2235                 .hide   = 1,
2236                 .def    = "0",
2237                 .category = FIO_OPT_C_IO,
2238                 .group  = FIO_OPT_G_RANDOM,
2239         },
2240         {
2241                 .name   = "random_generator",
2242                 .lname  = "Random Generator",
2243                 .type   = FIO_OPT_STR,
2244                 .off1   = offsetof(struct thread_options, random_generator),
2245                 .help   = "Type of random number generator to use",
2246                 .def    = "tausworthe",
2247                 .posval = {
2248                           { .ival = "tausworthe",
2249                             .oval = FIO_RAND_GEN_TAUSWORTHE,
2250                             .help = "Strong Tausworthe generator",
2251                           },
2252                           { .ival = "lfsr",
2253                             .oval = FIO_RAND_GEN_LFSR,
2254                             .help = "Variable length LFSR",
2255                           },
2256                           {
2257                             .ival = "tausworthe64",
2258                             .oval = FIO_RAND_GEN_TAUSWORTHE64,
2259                             .help = "64-bit Tausworthe variant",
2260                           },
2261                 },
2262                 .category = FIO_OPT_C_IO,
2263                 .group  = FIO_OPT_G_RANDOM,
2264         },
2265         {
2266                 .name   = "random_distribution",
2267                 .lname  = "Random Distribution",
2268                 .type   = FIO_OPT_STR,
2269                 .off1   = offsetof(struct thread_options, random_distribution),
2270                 .cb     = str_random_distribution_cb,
2271                 .help   = "Random offset distribution generator",
2272                 .def    = "random",
2273                 .posval = {
2274                           { .ival = "random",
2275                             .oval = FIO_RAND_DIST_RANDOM,
2276                             .help = "Completely random",
2277                           },
2278                           { .ival = "zipf",
2279                             .oval = FIO_RAND_DIST_ZIPF,
2280                             .help = "Zipf distribution",
2281                           },
2282                           { .ival = "pareto",
2283                             .oval = FIO_RAND_DIST_PARETO,
2284                             .help = "Pareto distribution",
2285                           },
2286                           { .ival = "normal",
2287                             .oval = FIO_RAND_DIST_GAUSS,
2288                             .help = "Normal (Gaussian) distribution",
2289                           },
2290                           { .ival = "zoned",
2291                             .oval = FIO_RAND_DIST_ZONED,
2292                             .help = "Zoned random distribution",
2293                           },
2294                           { .ival = "zoned_abs",
2295                             .oval = FIO_RAND_DIST_ZONED_ABS,
2296                             .help = "Zoned absolute random distribution",
2297                           },
2298                 },
2299                 .category = FIO_OPT_C_IO,
2300                 .group  = FIO_OPT_G_RANDOM,
2301         },
2302         {
2303                 .name   = "percentage_random",
2304                 .lname  = "Percentage Random",
2305                 .type   = FIO_OPT_INT,
2306                 .off1   = offsetof(struct thread_options, perc_rand[DDIR_READ]),
2307                 .off2   = offsetof(struct thread_options, perc_rand[DDIR_WRITE]),
2308                 .off3   = offsetof(struct thread_options, perc_rand[DDIR_TRIM]),
2309                 .maxval = 100,
2310                 .help   = "Percentage of seq/random mix that should be random",
2311                 .def    = "100,100,100",
2312                 .interval = 5,
2313                 .inverse = "percentage_sequential",
2314                 .category = FIO_OPT_C_IO,
2315                 .group  = FIO_OPT_G_RANDOM,
2316         },
2317         {
2318                 .name   = "percentage_sequential",
2319                 .lname  = "Percentage Sequential",
2320                 .type   = FIO_OPT_DEPRECATED,
2321                 .category = FIO_OPT_C_IO,
2322                 .group  = FIO_OPT_G_RANDOM,
2323         },
2324         {
2325                 .name   = "allrandrepeat",
2326                 .lname  = "All Random Repeat",
2327                 .type   = FIO_OPT_BOOL,
2328                 .off1   = offsetof(struct thread_options, allrand_repeatable),
2329                 .help   = "Use repeatable random numbers for everything",
2330                 .def    = "0",
2331                 .category = FIO_OPT_C_IO,
2332                 .group  = FIO_OPT_G_RANDOM,
2333         },
2334         {
2335                 .name   = "nrfiles",
2336                 .lname  = "Number of files",
2337                 .alias  = "nr_files",
2338                 .type   = FIO_OPT_INT,
2339                 .off1   = offsetof(struct thread_options, nr_files),
2340                 .help   = "Split job workload between this number of files",
2341                 .def    = "1",
2342                 .interval = 1,
2343                 .category = FIO_OPT_C_FILE,
2344                 .group  = FIO_OPT_G_INVALID,
2345         },
2346         {
2347                 .name   = "openfiles",
2348                 .lname  = "Number of open files",
2349                 .type   = FIO_OPT_INT,
2350                 .off1   = offsetof(struct thread_options, open_files),
2351                 .help   = "Number of files to keep open at the same time",
2352                 .category = FIO_OPT_C_FILE,
2353                 .group  = FIO_OPT_G_INVALID,
2354         },
2355         {
2356                 .name   = "file_service_type",
2357                 .lname  = "File service type",
2358                 .type   = FIO_OPT_STR,
2359                 .cb     = str_fst_cb,
2360                 .off1   = offsetof(struct thread_options, file_service_type),
2361                 .help   = "How to select which file to service next",
2362                 .def    = "roundrobin",
2363                 .category = FIO_OPT_C_FILE,
2364                 .group  = FIO_OPT_G_INVALID,
2365                 .posval = {
2366                           { .ival = "random",
2367                             .oval = FIO_FSERVICE_RANDOM,
2368                             .help = "Choose a file at random (uniform)",
2369                           },
2370                           { .ival = "zipf",
2371                             .oval = FIO_FSERVICE_ZIPF,
2372                             .help = "Zipf randomized",
2373                           },
2374                           { .ival = "pareto",
2375                             .oval = FIO_FSERVICE_PARETO,
2376                             .help = "Pareto randomized",
2377                           },
2378                           { .ival = "normal",
2379                             .oval = FIO_FSERVICE_GAUSS,
2380                             .help = "Normal (Gaussian) randomized",
2381                           },
2382                           { .ival = "gauss",
2383                             .oval = FIO_FSERVICE_GAUSS,
2384                             .help = "Alias for normal",
2385                           },
2386                           { .ival = "roundrobin",
2387                             .oval = FIO_FSERVICE_RR,
2388                             .help = "Round robin select files",
2389                           },
2390                           { .ival = "sequential",
2391                             .oval = FIO_FSERVICE_SEQ,
2392                             .help = "Finish one file before moving to the next",
2393                           },
2394                 },
2395                 .parent = "nrfiles",
2396                 .hide   = 1,
2397         },
2398 #ifdef FIO_HAVE_ANY_FALLOCATE
2399         {
2400                 .name   = "fallocate",
2401                 .lname  = "Fallocate",
2402                 .type   = FIO_OPT_STR,
2403                 .off1   = offsetof(struct thread_options, fallocate_mode),
2404                 .help   = "Whether pre-allocation is performed when laying out files",
2405                 .def    = "native",
2406                 .category = FIO_OPT_C_FILE,
2407                 .group  = FIO_OPT_G_INVALID,
2408                 .posval = {
2409                           { .ival = "none",
2410                             .oval = FIO_FALLOCATE_NONE,
2411                             .help = "Do not pre-allocate space",
2412                           },
2413                           { .ival = "native",
2414                             .oval = FIO_FALLOCATE_NATIVE,
2415                             .help = "Use native pre-allocation if possible",
2416                           },
2417 #ifdef CONFIG_POSIX_FALLOCATE
2418                           { .ival = "posix",
2419                             .oval = FIO_FALLOCATE_POSIX,
2420                             .help = "Use posix_fallocate()",
2421                           },
2422 #endif
2423 #ifdef CONFIG_LINUX_FALLOCATE
2424                           { .ival = "keep",
2425                             .oval = FIO_FALLOCATE_KEEP_SIZE,
2426                             .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
2427                           },
2428 #endif
2429                           /* Compatibility with former boolean values */
2430                           { .ival = "0",
2431                             .oval = FIO_FALLOCATE_NONE,
2432                             .help = "Alias for 'none'",
2433                           },
2434 #ifdef CONFIG_POSIX_FALLOCATE
2435                           { .ival = "1",
2436                             .oval = FIO_FALLOCATE_POSIX,
2437                             .help = "Alias for 'posix'",
2438                           },
2439 #endif
2440                 },
2441         },
2442 #else   /* FIO_HAVE_ANY_FALLOCATE */
2443         {
2444                 .name   = "fallocate",
2445                 .lname  = "Fallocate",
2446                 .type   = FIO_OPT_UNSUPPORTED,
2447                 .help   = "Your platform does not support fallocate",
2448         },
2449 #endif /* FIO_HAVE_ANY_FALLOCATE */
2450         {
2451                 .name   = "fadvise_hint",
2452                 .lname  = "Fadvise hint",
2453                 .type   = FIO_OPT_STR,
2454                 .off1   = offsetof(struct thread_options, fadvise_hint),
2455                 .posval = {
2456                           { .ival = "0",
2457                             .oval = F_ADV_NONE,
2458                             .help = "Don't issue fadvise/madvise",
2459                           },
2460                           { .ival = "1",
2461                             .oval = F_ADV_TYPE,
2462                             .help = "Advise using fio IO pattern",
2463                           },
2464                           { .ival = "random",
2465                             .oval = F_ADV_RANDOM,
2466                             .help = "Advise using FADV_RANDOM",
2467                           },
2468                           { .ival = "sequential",
2469                             .oval = F_ADV_SEQUENTIAL,
2470                             .help = "Advise using FADV_SEQUENTIAL",
2471                           },
2472                 },
2473                 .help   = "Use fadvise() to advise the kernel on IO pattern",
2474                 .def    = "1",
2475                 .category = FIO_OPT_C_FILE,
2476                 .group  = FIO_OPT_G_INVALID,
2477         },
2478         {
2479                 .name   = "fsync",
2480                 .lname  = "Fsync",
2481                 .type   = FIO_OPT_INT,
2482                 .off1   = offsetof(struct thread_options, fsync_blocks),
2483                 .help   = "Issue fsync for writes every given number of blocks",
2484                 .def    = "0",
2485                 .interval = 1,
2486                 .category = FIO_OPT_C_FILE,
2487                 .group  = FIO_OPT_G_INVALID,
2488         },
2489         {
2490                 .name   = "fdatasync",
2491                 .lname  = "Fdatasync",
2492                 .type   = FIO_OPT_INT,
2493                 .off1   = offsetof(struct thread_options, fdatasync_blocks),
2494                 .help   = "Issue fdatasync for writes every given number of blocks",
2495                 .def    = "0",
2496                 .interval = 1,
2497                 .category = FIO_OPT_C_FILE,
2498                 .group  = FIO_OPT_G_INVALID,
2499         },
2500         {
2501                 .name   = "write_barrier",
2502                 .lname  = "Write barrier",
2503                 .type   = FIO_OPT_INT,
2504                 .off1   = offsetof(struct thread_options, barrier_blocks),
2505                 .help   = "Make every Nth write a barrier write",
2506                 .def    = "0",
2507                 .interval = 1,
2508                 .category = FIO_OPT_C_IO,
2509                 .group  = FIO_OPT_G_INVALID,
2510         },
2511 #ifdef CONFIG_SYNC_FILE_RANGE
2512         {
2513                 .name   = "sync_file_range",
2514                 .lname  = "Sync file range",
2515                 .posval = {
2516                           { .ival = "wait_before",
2517                             .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
2518                             .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
2519                             .orval  = 1,
2520                           },
2521                           { .ival = "write",
2522                             .oval = SYNC_FILE_RANGE_WRITE,
2523                             .help = "SYNC_FILE_RANGE_WRITE",
2524                             .orval  = 1,
2525                           },
2526                           {
2527                             .ival = "wait_after",
2528                             .oval = SYNC_FILE_RANGE_WAIT_AFTER,
2529                             .help = "SYNC_FILE_RANGE_WAIT_AFTER",
2530                             .orval  = 1,
2531                           },
2532                 },
2533                 .type   = FIO_OPT_STR_MULTI,
2534                 .cb     = str_sfr_cb,
2535                 .off1   = offsetof(struct thread_options, sync_file_range),
2536                 .help   = "Use sync_file_range()",
2537                 .category = FIO_OPT_C_FILE,
2538                 .group  = FIO_OPT_G_INVALID,
2539         },
2540 #else
2541         {
2542                 .name   = "sync_file_range",
2543                 .lname  = "Sync file range",
2544                 .type   = FIO_OPT_UNSUPPORTED,
2545                 .help   = "Your platform does not support sync_file_range",
2546         },
2547 #endif
2548         {
2549                 .name   = "direct",
2550                 .lname  = "Direct I/O",
2551                 .type   = FIO_OPT_BOOL,
2552                 .off1   = offsetof(struct thread_options, odirect),
2553                 .help   = "Use O_DIRECT IO (negates buffered)",
2554                 .def    = "0",
2555                 .inverse = "buffered",
2556                 .category = FIO_OPT_C_IO,
2557                 .group  = FIO_OPT_G_IO_TYPE,
2558         },
2559         {
2560                 .name   = "atomic",
2561                 .lname  = "Atomic I/O",
2562                 .type   = FIO_OPT_BOOL,
2563                 .off1   = offsetof(struct thread_options, oatomic),
2564                 .help   = "Use Atomic IO with O_DIRECT (implies O_DIRECT)",
2565                 .def    = "0",
2566                 .category = FIO_OPT_C_IO,
2567                 .group  = FIO_OPT_G_IO_TYPE,
2568         },
2569         {
2570                 .name   = "buffered",
2571                 .lname  = "Buffered I/O",
2572                 .type   = FIO_OPT_BOOL,
2573                 .off1   = offsetof(struct thread_options, odirect),
2574                 .neg    = 1,
2575                 .help   = "Use buffered IO (negates direct)",
2576                 .def    = "1",
2577                 .inverse = "direct",
2578                 .category = FIO_OPT_C_IO,
2579                 .group  = FIO_OPT_G_IO_TYPE,
2580         },
2581         {
2582                 .name   = "overwrite",
2583                 .lname  = "Overwrite",
2584                 .type   = FIO_OPT_BOOL,
2585                 .off1   = offsetof(struct thread_options, overwrite),
2586                 .help   = "When writing, set whether to overwrite current data",
2587                 .def    = "0",
2588                 .category = FIO_OPT_C_FILE,
2589                 .group  = FIO_OPT_G_INVALID,
2590         },
2591         {
2592                 .name   = "loops",
2593                 .lname  = "Loops",
2594                 .type   = FIO_OPT_INT,
2595                 .off1   = offsetof(struct thread_options, loops),
2596                 .help   = "Number of times to run the job",
2597                 .def    = "1",
2598                 .interval = 1,
2599                 .category = FIO_OPT_C_GENERAL,
2600                 .group  = FIO_OPT_G_RUNTIME,
2601         },
2602         {
2603                 .name   = "numjobs",
2604                 .lname  = "Number of jobs",
2605                 .type   = FIO_OPT_INT,
2606                 .off1   = offsetof(struct thread_options, numjobs),
2607                 .help   = "Duplicate this job this many times",
2608                 .def    = "1",
2609                 .interval = 1,
2610                 .category = FIO_OPT_C_GENERAL,
2611                 .group  = FIO_OPT_G_RUNTIME,
2612         },
2613         {
2614                 .name   = "startdelay",
2615                 .lname  = "Start delay",
2616                 .type   = FIO_OPT_STR_VAL_TIME,
2617                 .off1   = offsetof(struct thread_options, start_delay),
2618                 .off2   = offsetof(struct thread_options, start_delay_high),
2619                 .help   = "Only start job when this period has passed",
2620                 .def    = "0",
2621                 .is_seconds = 1,
2622                 .is_time = 1,
2623                 .category = FIO_OPT_C_GENERAL,
2624                 .group  = FIO_OPT_G_RUNTIME,
2625         },
2626         {
2627                 .name   = "runtime",
2628                 .lname  = "Runtime",
2629                 .alias  = "timeout",
2630                 .type   = FIO_OPT_STR_VAL_TIME,
2631                 .off1   = offsetof(struct thread_options, timeout),
2632                 .help   = "Stop workload when this amount of time has passed",
2633                 .def    = "0",
2634                 .is_seconds = 1,
2635                 .is_time = 1,
2636                 .category = FIO_OPT_C_GENERAL,
2637                 .group  = FIO_OPT_G_RUNTIME,
2638         },
2639         {
2640                 .name   = "time_based",
2641                 .lname  = "Time based",
2642                 .type   = FIO_OPT_STR_SET,
2643                 .off1   = offsetof(struct thread_options, time_based),
2644                 .help   = "Keep running until runtime/timeout is met",
2645                 .category = FIO_OPT_C_GENERAL,
2646                 .group  = FIO_OPT_G_RUNTIME,
2647         },
2648         {
2649                 .name   = "verify_only",
2650                 .lname  = "Verify only",
2651                 .type   = FIO_OPT_STR_SET,
2652                 .off1   = offsetof(struct thread_options, verify_only),
2653                 .help   = "Verifies previously written data is still valid",
2654                 .category = FIO_OPT_C_GENERAL,
2655                 .group  = FIO_OPT_G_RUNTIME,
2656         },
2657         {
2658                 .name   = "ramp_time",
2659                 .lname  = "Ramp time",
2660                 .type   = FIO_OPT_STR_VAL_TIME,
2661                 .off1   = offsetof(struct thread_options, ramp_time),
2662                 .help   = "Ramp up time before measuring performance",
2663                 .is_seconds = 1,
2664                 .is_time = 1,
2665                 .category = FIO_OPT_C_GENERAL,
2666                 .group  = FIO_OPT_G_RUNTIME,
2667         },
2668         {
2669                 .name   = "clocksource",
2670                 .lname  = "Clock source",
2671                 .type   = FIO_OPT_STR,
2672                 .cb     = fio_clock_source_cb,
2673                 .off1   = offsetof(struct thread_options, clocksource),
2674                 .help   = "What type of timing source to use",
2675                 .category = FIO_OPT_C_GENERAL,
2676                 .group  = FIO_OPT_G_CLOCK,
2677                 .posval = {
2678 #ifdef CONFIG_GETTIMEOFDAY
2679                           { .ival = "gettimeofday",
2680                             .oval = CS_GTOD,
2681                             .help = "Use gettimeofday(2) for timing",
2682                           },
2683 #endif
2684 #ifdef CONFIG_CLOCK_GETTIME
2685                           { .ival = "clock_gettime",
2686                             .oval = CS_CGETTIME,
2687                             .help = "Use clock_gettime(2) for timing",
2688                           },
2689 #endif
2690 #ifdef ARCH_HAVE_CPU_CLOCK
2691                           { .ival = "cpu",
2692                             .oval = CS_CPUCLOCK,
2693                             .help = "Use CPU private clock",
2694                           },
2695 #endif
2696                 },
2697         },
2698         {
2699                 .name   = "mem",
2700                 .alias  = "iomem",
2701                 .lname  = "I/O Memory",
2702                 .type   = FIO_OPT_STR,
2703                 .cb     = str_mem_cb,
2704                 .off1   = offsetof(struct thread_options, mem_type),
2705                 .help   = "Backing type for IO buffers",
2706                 .def    = "malloc",
2707                 .category = FIO_OPT_C_IO,
2708                 .group  = FIO_OPT_G_INVALID,
2709                 .posval = {
2710                           { .ival = "malloc",
2711                             .oval = MEM_MALLOC,
2712                             .help = "Use malloc(3) for IO buffers",
2713                           },
2714 #ifndef CONFIG_NO_SHM
2715                           { .ival = "shm",
2716                             .oval = MEM_SHM,
2717                             .help = "Use shared memory segments for IO buffers",
2718                           },
2719 #ifdef FIO_HAVE_HUGETLB
2720                           { .ival = "shmhuge",
2721                             .oval = MEM_SHMHUGE,
2722                             .help = "Like shm, but use huge pages",
2723                           },
2724 #endif
2725 #endif
2726                           { .ival = "mmap",
2727                             .oval = MEM_MMAP,
2728                             .help = "Use mmap(2) (file or anon) for IO buffers",
2729                           },
2730                           { .ival = "mmapshared",
2731                             .oval = MEM_MMAPSHARED,
2732                             .help = "Like mmap, but use the shared flag",
2733                           },
2734 #ifdef FIO_HAVE_HUGETLB
2735                           { .ival = "mmaphuge",
2736                             .oval = MEM_MMAPHUGE,
2737                             .help = "Like mmap, but use huge pages",
2738                           },
2739 #endif
2740 #ifdef CONFIG_CUDA
2741                           { .ival = "cudamalloc",
2742                             .oval = MEM_CUDA_MALLOC,
2743                             .help = "Allocate GPU device memory for GPUDirect RDMA",
2744                           },
2745 #endif
2746                   },
2747         },
2748         {
2749                 .name   = "iomem_align",
2750                 .alias  = "mem_align",
2751                 .lname  = "I/O memory alignment",
2752                 .type   = FIO_OPT_INT,
2753                 .off1   = offsetof(struct thread_options, mem_align),
2754                 .minval = 0,
2755                 .help   = "IO memory buffer offset alignment",
2756                 .def    = "0",
2757                 .parent = "iomem",
2758                 .hide   = 1,
2759                 .category = FIO_OPT_C_IO,
2760                 .group  = FIO_OPT_G_INVALID,
2761         },
2762         {
2763                 .name   = "verify",
2764                 .lname  = "Verify",
2765                 .type   = FIO_OPT_STR,
2766                 .off1   = offsetof(struct thread_options, verify),
2767                 .help   = "Verify data written",
2768                 .def    = "0",
2769                 .category = FIO_OPT_C_IO,
2770                 .group  = FIO_OPT_G_VERIFY,
2771                 .posval = {
2772                           { .ival = "0",
2773                             .oval = VERIFY_NONE,
2774                             .help = "Don't do IO verification",
2775                           },
2776                           { .ival = "md5",
2777                             .oval = VERIFY_MD5,
2778                             .help = "Use md5 checksums for verification",
2779                           },
2780                           { .ival = "crc64",
2781                             .oval = VERIFY_CRC64,
2782                             .help = "Use crc64 checksums for verification",
2783                           },
2784                           { .ival = "crc32",
2785                             .oval = VERIFY_CRC32,
2786                             .help = "Use crc32 checksums for verification",
2787                           },
2788                           { .ival = "crc32c-intel",
2789                             .oval = VERIFY_CRC32C,
2790                             .help = "Use crc32c checksums for verification (hw assisted, if available)",
2791                           },
2792                           { .ival = "crc32c",
2793                             .oval = VERIFY_CRC32C,
2794                             .help = "Use crc32c checksums for verification (hw assisted, if available)",
2795                           },
2796                           { .ival = "crc16",
2797                             .oval = VERIFY_CRC16,
2798                             .help = "Use crc16 checksums for verification",
2799                           },
2800                           { .ival = "crc7",
2801                             .oval = VERIFY_CRC7,
2802                             .help = "Use crc7 checksums for verification",
2803                           },
2804                           { .ival = "sha1",
2805                             .oval = VERIFY_SHA1,
2806                             .help = "Use sha1 checksums for verification",
2807                           },
2808                           { .ival = "sha256",
2809                             .oval = VERIFY_SHA256,
2810                             .help = "Use sha256 checksums for verification",
2811                           },
2812                           { .ival = "sha512",
2813                             .oval = VERIFY_SHA512,
2814                             .help = "Use sha512 checksums for verification",
2815                           },
2816                           { .ival = "sha3-224",
2817                             .oval = VERIFY_SHA3_224,
2818                             .help = "Use sha3-224 checksums for verification",
2819                           },
2820                           { .ival = "sha3-256",
2821                             .oval = VERIFY_SHA3_256,
2822                             .help = "Use sha3-256 checksums for verification",
2823                           },
2824                           { .ival = "sha3-384",
2825                             .oval = VERIFY_SHA3_384,
2826                             .help = "Use sha3-384 checksums for verification",
2827                           },
2828                           { .ival = "sha3-512",
2829                             .oval = VERIFY_SHA3_512,
2830                             .help = "Use sha3-512 checksums for verification",
2831                           },
2832                           { .ival = "xxhash",
2833                             .oval = VERIFY_XXHASH,
2834                             .help = "Use xxhash checksums for verification",
2835                           },
2836                           /* Meta information was included into verify_header,
2837                            * 'meta' verification is implied by default. */
2838                           { .ival = "meta",
2839                             .oval = VERIFY_HDR_ONLY,
2840                             .help = "Use io information for verification. "
2841                                     "Now is implied by default, thus option is obsolete, "
2842                                     "don't use it",
2843                           },
2844                           { .ival = "pattern",
2845                             .oval = VERIFY_PATTERN_NO_HDR,
2846                             .help = "Verify strict pattern",
2847                           },
2848                           {
2849                             .ival = "null",
2850                             .oval = VERIFY_NULL,
2851                             .help = "Pretend to verify",
2852                           },
2853                 },
2854         },
2855         {
2856                 .name   = "do_verify",
2857                 .lname  = "Perform verify step",
2858                 .type   = FIO_OPT_BOOL,
2859                 .off1   = offsetof(struct thread_options, do_verify),
2860                 .help   = "Run verification stage after write",
2861                 .def    = "1",
2862                 .parent = "verify",
2863                 .hide   = 1,
2864                 .category = FIO_OPT_C_IO,
2865                 .group  = FIO_OPT_G_VERIFY,
2866         },
2867         {
2868                 .name   = "verifysort",
2869                 .lname  = "Verify sort",
2870                 .type   = FIO_OPT_SOFT_DEPRECATED,
2871                 .category = FIO_OPT_C_IO,
2872                 .group  = FIO_OPT_G_VERIFY,
2873         },
2874         {
2875                 .name   = "verifysort_nr",
2876                 .lname  = "Verify Sort Nr",
2877                 .type   = FIO_OPT_SOFT_DEPRECATED,
2878                 .category = FIO_OPT_C_IO,
2879                 .group  = FIO_OPT_G_VERIFY,
2880         },
2881         {
2882                 .name   = "verify_interval",
2883                 .lname  = "Verify interval",
2884                 .type   = FIO_OPT_INT,
2885                 .off1   = offsetof(struct thread_options, verify_interval),
2886                 .minval = 2 * sizeof(struct verify_header),
2887                 .help   = "Store verify buffer header every N bytes",
2888                 .parent = "verify",
2889                 .hide   = 1,
2890                 .interval = 2 * sizeof(struct verify_header),
2891                 .category = FIO_OPT_C_IO,
2892                 .group  = FIO_OPT_G_VERIFY,
2893         },
2894         {
2895                 .name   = "verify_offset",
2896                 .lname  = "Verify offset",
2897                 .type   = FIO_OPT_INT,
2898                 .help   = "Offset verify header location by N bytes",
2899                 .off1   = offsetof(struct thread_options, verify_offset),
2900                 .minval = sizeof(struct verify_header),
2901                 .parent = "verify",
2902                 .hide   = 1,
2903                 .category = FIO_OPT_C_IO,
2904                 .group  = FIO_OPT_G_VERIFY,
2905         },
2906         {
2907                 .name   = "verify_pattern",
2908                 .lname  = "Verify pattern",
2909                 .type   = FIO_OPT_STR,
2910                 .cb     = str_verify_pattern_cb,
2911                 .off1   = offsetof(struct thread_options, verify_pattern),
2912                 .help   = "Fill pattern for IO buffers",
2913                 .parent = "verify",
2914                 .hide   = 1,
2915                 .category = FIO_OPT_C_IO,
2916                 .group  = FIO_OPT_G_VERIFY,
2917         },
2918         {
2919                 .name   = "verify_fatal",
2920                 .lname  = "Verify fatal",
2921                 .type   = FIO_OPT_BOOL,
2922                 .off1   = offsetof(struct thread_options, verify_fatal),
2923                 .def    = "0",
2924                 .help   = "Exit on a single verify failure, don't continue",
2925                 .parent = "verify",
2926                 .hide   = 1,
2927                 .category = FIO_OPT_C_IO,
2928                 .group  = FIO_OPT_G_VERIFY,
2929         },
2930         {
2931                 .name   = "verify_dump",
2932                 .lname  = "Verify dump",
2933                 .type   = FIO_OPT_BOOL,
2934                 .off1   = offsetof(struct thread_options, verify_dump),
2935                 .def    = "0",
2936                 .help   = "Dump contents of good and bad blocks on failure",
2937                 .parent = "verify",
2938                 .hide   = 1,
2939                 .category = FIO_OPT_C_IO,
2940                 .group  = FIO_OPT_G_VERIFY,
2941         },
2942         {
2943                 .name   = "verify_async",
2944                 .lname  = "Verify asynchronously",
2945                 .type   = FIO_OPT_INT,
2946                 .off1   = offsetof(struct thread_options, verify_async),
2947                 .def    = "0",
2948                 .help   = "Number of async verifier threads to use",
2949                 .parent = "verify",
2950                 .hide   = 1,
2951                 .category = FIO_OPT_C_IO,
2952                 .group  = FIO_OPT_G_VERIFY,
2953         },
2954         {
2955                 .name   = "verify_backlog",
2956                 .lname  = "Verify backlog",
2957                 .type   = FIO_OPT_STR_VAL,
2958                 .off1   = offsetof(struct thread_options, verify_backlog),
2959                 .help   = "Verify after this number of blocks are written",
2960                 .parent = "verify",
2961                 .hide   = 1,
2962                 .category = FIO_OPT_C_IO,
2963                 .group  = FIO_OPT_G_VERIFY,
2964         },
2965         {
2966                 .name   = "verify_backlog_batch",
2967                 .lname  = "Verify backlog batch",
2968                 .type   = FIO_OPT_INT,
2969                 .off1   = offsetof(struct thread_options, verify_batch),
2970                 .help   = "Verify this number of IO blocks",
2971                 .parent = "verify",
2972                 .hide   = 1,
2973                 .category = FIO_OPT_C_IO,
2974                 .group  = FIO_OPT_G_VERIFY,
2975         },
2976 #ifdef FIO_HAVE_CPU_AFFINITY
2977         {
2978                 .name   = "verify_async_cpus",
2979                 .lname  = "Async verify CPUs",
2980                 .type   = FIO_OPT_STR,
2981                 .cb     = str_verify_cpus_allowed_cb,
2982                 .off1   = offsetof(struct thread_options, verify_cpumask),
2983                 .help   = "Set CPUs allowed for async verify threads",
2984                 .parent = "verify_async",
2985                 .hide   = 1,
2986                 .category = FIO_OPT_C_IO,
2987                 .group  = FIO_OPT_G_VERIFY,
2988         },
2989 #else
2990         {
2991                 .name   = "verify_async_cpus",
2992                 .lname  = "Async verify CPUs",
2993                 .type   = FIO_OPT_UNSUPPORTED,
2994                 .help   = "Your platform does not support CPU affinities",
2995         },
2996 #endif
2997         {
2998                 .name   = "experimental_verify",
2999                 .lname  = "Experimental Verify",
3000                 .off1   = offsetof(struct thread_options, experimental_verify),
3001                 .type   = FIO_OPT_BOOL,
3002                 .help   = "Enable experimental verification",
3003                 .parent = "verify",
3004                 .category = FIO_OPT_C_IO,
3005                 .group  = FIO_OPT_G_VERIFY,
3006         },
3007         {
3008                 .name   = "verify_state_load",
3009                 .lname  = "Load verify state",
3010                 .off1   = offsetof(struct thread_options, verify_state),
3011                 .type   = FIO_OPT_BOOL,
3012                 .help   = "Load verify termination state",
3013                 .parent = "verify",
3014                 .category = FIO_OPT_C_IO,
3015                 .group  = FIO_OPT_G_VERIFY,
3016         },
3017         {
3018                 .name   = "verify_state_save",
3019                 .lname  = "Save verify state",
3020                 .off1   = offsetof(struct thread_options, verify_state_save),
3021                 .type   = FIO_OPT_BOOL,
3022                 .def    = "1",
3023                 .help   = "Save verify state on termination",
3024                 .parent = "verify",
3025                 .category = FIO_OPT_C_IO,
3026                 .group  = FIO_OPT_G_VERIFY,
3027         },
3028 #ifdef FIO_HAVE_TRIM
3029         {
3030                 .name   = "trim_percentage",
3031                 .lname  = "Trim percentage",
3032                 .type   = FIO_OPT_INT,
3033                 .off1   = offsetof(struct thread_options, trim_percentage),
3034                 .minval = 0,
3035                 .maxval = 100,
3036                 .help   = "Number of verify blocks to trim (i.e., discard)",
3037                 .parent = "verify",
3038                 .def    = "0",
3039                 .interval = 1,
3040                 .hide   = 1,
3041                 .category = FIO_OPT_C_IO,
3042                 .group  = FIO_OPT_G_TRIM,
3043         },
3044         {
3045                 .name   = "trim_verify_zero",
3046                 .lname  = "Verify trim zero",
3047                 .type   = FIO_OPT_BOOL,
3048                 .help   = "Verify that trimmed (i.e., discarded) blocks are returned as zeroes",
3049                 .off1   = offsetof(struct thread_options, trim_zero),
3050                 .parent = "trim_percentage",
3051                 .hide   = 1,
3052                 .def    = "1",
3053                 .category = FIO_OPT_C_IO,
3054                 .group  = FIO_OPT_G_TRIM,
3055         },
3056         {
3057                 .name   = "trim_backlog",
3058                 .lname  = "Trim backlog",
3059                 .type   = FIO_OPT_STR_VAL,
3060                 .off1   = offsetof(struct thread_options, trim_backlog),
3061                 .help   = "Trim after this number of blocks are written",
3062                 .parent = "trim_percentage",
3063                 .hide   = 1,
3064                 .interval = 1,
3065                 .category = FIO_OPT_C_IO,
3066                 .group  = FIO_OPT_G_TRIM,
3067         },
3068         {
3069                 .name   = "trim_backlog_batch",
3070                 .lname  = "Trim backlog batch",
3071                 .type   = FIO_OPT_INT,
3072                 .off1   = offsetof(struct thread_options, trim_batch),
3073                 .help   = "Trim this number of IO blocks",
3074                 .parent = "trim_percentage",
3075                 .hide   = 1,
3076                 .interval = 1,
3077                 .category = FIO_OPT_C_IO,
3078                 .group  = FIO_OPT_G_TRIM,
3079         },
3080 #else
3081         {
3082                 .name   = "trim_percentage",
3083                 .lname  = "Trim percentage",
3084                 .type   = FIO_OPT_UNSUPPORTED,
3085                 .help   = "Fio does not support TRIM on your platform",
3086         },
3087         {
3088                 .name   = "trim_verify_zero",
3089                 .lname  = "Verify trim zero",
3090                 .type   = FIO_OPT_UNSUPPORTED,
3091                 .help   = "Fio does not support TRIM on your platform",
3092         },
3093         {
3094                 .name   = "trim_backlog",
3095                 .lname  = "Trim backlog",
3096                 .type   = FIO_OPT_UNSUPPORTED,
3097                 .help   = "Fio does not support TRIM on your platform",
3098         },
3099         {
3100                 .name   = "trim_backlog_batch",
3101                 .lname  = "Trim backlog batch",
3102                 .type   = FIO_OPT_UNSUPPORTED,
3103                 .help   = "Fio does not support TRIM on your platform",
3104         },
3105 #endif
3106         {
3107                 .name   = "write_iolog",
3108                 .lname  = "Write I/O log",
3109                 .type   = FIO_OPT_STR_STORE,
3110                 .off1   = offsetof(struct thread_options, write_iolog_file),
3111                 .help   = "Store IO pattern to file",
3112                 .category = FIO_OPT_C_IO,
3113                 .group  = FIO_OPT_G_IOLOG,
3114         },
3115         {
3116                 .name   = "read_iolog",
3117                 .lname  = "Read I/O log",
3118                 .type   = FIO_OPT_STR_STORE,
3119                 .off1   = offsetof(struct thread_options, read_iolog_file),
3120                 .help   = "Playback IO pattern from file",
3121                 .category = FIO_OPT_C_IO,
3122                 .group  = FIO_OPT_G_IOLOG,
3123         },
3124         {
3125                 .name   = "read_iolog_chunked",
3126                 .lname  = "Read I/O log in parts",
3127                 .type   = FIO_OPT_BOOL,
3128                 .off1   = offsetof(struct thread_options, read_iolog_chunked),
3129                 .def    = "0",
3130                 .parent = "read_iolog",
3131                 .help   = "Parse IO pattern in chunks",
3132                 .category = FIO_OPT_C_IO,
3133                 .group  = FIO_OPT_G_IOLOG,
3134         },
3135         {
3136                 .name   = "replay_no_stall",
3137                 .lname  = "Don't stall on replay",
3138                 .type   = FIO_OPT_BOOL,
3139                 .off1   = offsetof(struct thread_options, no_stall),
3140                 .def    = "0",
3141                 .parent = "read_iolog",
3142                 .hide   = 1,
3143                 .help   = "Playback IO pattern file as fast as possible without stalls",
3144                 .category = FIO_OPT_C_IO,
3145                 .group  = FIO_OPT_G_IOLOG,
3146         },
3147         {
3148                 .name   = "replay_redirect",
3149                 .lname  = "Redirect device for replay",
3150                 .type   = FIO_OPT_STR_STORE,
3151                 .off1   = offsetof(struct thread_options, replay_redirect),
3152                 .parent = "read_iolog",
3153                 .hide   = 1,
3154                 .help   = "Replay all I/O onto this device, regardless of trace device",
3155                 .category = FIO_OPT_C_IO,
3156                 .group  = FIO_OPT_G_IOLOG,
3157         },
3158         {
3159                 .name   = "replay_scale",
3160                 .lname  = "Replace offset scale factor",
3161                 .type   = FIO_OPT_INT,
3162                 .off1   = offsetof(struct thread_options, replay_scale),
3163                 .parent = "read_iolog",
3164                 .def    = "1",
3165                 .help   = "Align offsets to this blocksize",
3166                 .category = FIO_OPT_C_IO,
3167                 .group  = FIO_OPT_G_IOLOG,
3168         },
3169         {
3170                 .name   = "replay_align",
3171                 .lname  = "Replace alignment",
3172                 .type   = FIO_OPT_INT,
3173                 .off1   = offsetof(struct thread_options, replay_align),
3174                 .parent = "read_iolog",
3175                 .help   = "Scale offset down by this factor",
3176                 .category = FIO_OPT_C_IO,
3177                 .group  = FIO_OPT_G_IOLOG,
3178                 .pow2   = 1,
3179         },
3180         {
3181                 .name   = "replay_time_scale",
3182                 .lname  = "Replay Time Scale",
3183                 .type   = FIO_OPT_INT,
3184                 .off1   = offsetof(struct thread_options, replay_time_scale),
3185                 .def    = "100",
3186                 .minval = 1,
3187                 .parent = "read_iolog",
3188                 .hide   = 1,
3189                 .help   = "Scale time for replay events",
3190                 .category = FIO_OPT_C_IO,
3191                 .group  = FIO_OPT_G_IOLOG,
3192         },
3193         {
3194                 .name   = "replay_skip",
3195                 .lname  = "Replay Skip",
3196                 .type   = FIO_OPT_STR,
3197                 .cb     = str_replay_skip_cb,
3198                 .off1   = offsetof(struct thread_options, replay_skip),
3199                 .parent = "read_iolog",
3200                 .help   = "Skip certain IO types (read,write,trim,flush)",
3201                 .category = FIO_OPT_C_IO,
3202                 .group  = FIO_OPT_G_IOLOG,
3203         },
3204         {
3205                 .name   = "merge_blktrace_file",
3206                 .lname  = "Merged blktrace output filename",
3207                 .type   = FIO_OPT_STR_STORE,
3208                 .off1   = offsetof(struct thread_options, merge_blktrace_file),
3209                 .help   = "Merged blktrace output filename",
3210                 .category = FIO_OPT_C_IO,
3211                 .group = FIO_OPT_G_IOLOG,
3212         },
3213         {
3214                 .name   = "merge_blktrace_scalars",
3215                 .lname  = "Percentage to scale each trace",
3216                 .type   = FIO_OPT_FLOAT_LIST,
3217                 .off1   = offsetof(struct thread_options, merge_blktrace_scalars),
3218                 .maxlen = FIO_IO_U_LIST_MAX_LEN,
3219                 .help   = "Percentage to scale each trace",
3220                 .category = FIO_OPT_C_IO,
3221                 .group  = FIO_OPT_G_IOLOG,
3222         },
3223         {
3224                 .name   = "merge_blktrace_iters",
3225                 .lname  = "Number of iterations to run per trace",
3226                 .type   = FIO_OPT_FLOAT_LIST,
3227                 .off1   = offsetof(struct thread_options, merge_blktrace_iters),
3228                 .maxlen = FIO_IO_U_LIST_MAX_LEN,
3229                 .help   = "Number of iterations to run per trace",
3230                 .category = FIO_OPT_C_IO,
3231                 .group  = FIO_OPT_G_IOLOG,
3232         },
3233         {
3234                 .name   = "exec_prerun",
3235                 .lname  = "Pre-execute runnable",
3236                 .type   = FIO_OPT_STR_STORE,
3237                 .off1   = offsetof(struct thread_options, exec_prerun),
3238                 .help   = "Execute this file prior to running job",
3239                 .category = FIO_OPT_C_GENERAL,
3240                 .group  = FIO_OPT_G_INVALID,
3241         },
3242         {
3243                 .name   = "exec_postrun",
3244                 .lname  = "Post-execute runnable",
3245                 .type   = FIO_OPT_STR_STORE,
3246                 .off1   = offsetof(struct thread_options, exec_postrun),
3247                 .help   = "Execute this file after running job",
3248                 .category = FIO_OPT_C_GENERAL,
3249                 .group  = FIO_OPT_G_INVALID,
3250         },
3251 #ifdef FIO_HAVE_IOSCHED_SWITCH
3252         {
3253                 .name   = "ioscheduler",
3254                 .lname  = "I/O scheduler",
3255                 .type   = FIO_OPT_STR_STORE,
3256                 .off1   = offsetof(struct thread_options, ioscheduler),
3257                 .help   = "Use this IO scheduler on the backing device",
3258                 .category = FIO_OPT_C_FILE,
3259                 .group  = FIO_OPT_G_INVALID,
3260         },
3261 #else
3262         {
3263                 .name   = "ioscheduler",
3264                 .lname  = "I/O scheduler",
3265                 .type   = FIO_OPT_UNSUPPORTED,
3266                 .help   = "Your platform does not support IO scheduler switching",
3267         },
3268 #endif
3269         {
3270                 .name   = "zonemode",
3271                 .lname  = "Zone mode",
3272                 .help   = "Mode for the zonesize, zonerange and zoneskip parameters",
3273                 .type   = FIO_OPT_STR,
3274                 .off1   = offsetof(struct thread_options, zone_mode),
3275                 .def    = "none",
3276                 .category = FIO_OPT_C_IO,
3277                 .group  = FIO_OPT_G_ZONE,
3278                 .posval = {
3279                            { .ival = "none",
3280                              .oval = ZONE_MODE_NONE,
3281                              .help = "no zoning",
3282                            },
3283                            { .ival = "strided",
3284                              .oval = ZONE_MODE_STRIDED,
3285                              .help = "strided mode - random I/O is restricted to a single zone",
3286                            },
3287                            { .ival = "zbd",
3288                              .oval = ZONE_MODE_ZBD,
3289                              .help = "zoned block device mode - random I/O selects one of multiple zones randomly",
3290                            },
3291                 },
3292         },
3293         {
3294                 .name   = "zonesize",
3295                 .lname  = "Zone size",
3296                 .type   = FIO_OPT_STR_VAL,
3297                 .off1   = offsetof(struct thread_options, zone_size),
3298                 .help   = "Amount of data to read per zone",
3299                 .def    = "0",
3300                 .interval = 1024 * 1024,
3301                 .category = FIO_OPT_C_IO,
3302                 .group  = FIO_OPT_G_ZONE,
3303         },
3304         {
3305                 .name   = "zonerange",
3306                 .lname  = "Zone range",
3307                 .type   = FIO_OPT_STR_VAL,
3308                 .off1   = offsetof(struct thread_options, zone_range),
3309                 .help   = "Give size of an IO zone",
3310                 .def    = "0",
3311                 .interval = 1024 * 1024,
3312                 .category = FIO_OPT_C_IO,
3313                 .group  = FIO_OPT_G_ZONE,
3314         },
3315         {
3316                 .name   = "zoneskip",
3317                 .lname  = "Zone skip",
3318                 .type   = FIO_OPT_STR_VAL,
3319                 .off1   = offsetof(struct thread_options, zone_skip),
3320                 .help   = "Space between IO zones",
3321                 .def    = "0",
3322                 .interval = 1024 * 1024,
3323                 .category = FIO_OPT_C_IO,
3324                 .group  = FIO_OPT_G_ZONE,
3325         },
3326         {
3327                 .name   = "read_beyond_wp",
3328                 .lname  = "Allow reads beyond the zone write pointer",
3329                 .type   = FIO_OPT_BOOL,
3330                 .off1   = offsetof(struct thread_options, read_beyond_wp),
3331                 .help   = "Allow reads beyond the zone write pointer",
3332                 .def    = "0",
3333                 .category = FIO_OPT_C_IO,
3334                 .group  = FIO_OPT_G_INVALID,
3335         },
3336         {
3337                 .name   = "max_open_zones",
3338                 .lname  = "Maximum number of open zones",
3339                 .type   = FIO_OPT_INT,
3340                 .off1   = offsetof(struct thread_options, max_open_zones),
3341                 .maxval = FIO_MAX_OPEN_ZBD_ZONES,
3342                 .help   = "Limit random writes to SMR drives to the specified"
3343                           " number of sequential zones",
3344                 .def    = "0",
3345                 .category = FIO_OPT_C_IO,
3346                 .group  = FIO_OPT_G_INVALID,
3347         },
3348         {
3349                 .name   = "zone_reset_threshold",
3350                 .lname  = "Zone reset threshold",
3351                 .help   = "Zoned block device reset threshold",
3352                 .type   = FIO_OPT_FLOAT_LIST,
3353                 .maxlen = 1,
3354                 .off1   = offsetof(struct thread_options, zrt),
3355                 .minfp  = 0,
3356                 .maxfp  = 1,
3357                 .category = FIO_OPT_C_IO,
3358                 .group  = FIO_OPT_G_ZONE,
3359         },
3360         {
3361                 .name   = "zone_reset_frequency",
3362                 .lname  = "Zone reset frequency",
3363                 .help   = "Zoned block device zone reset frequency in HZ",
3364                 .type   = FIO_OPT_FLOAT_LIST,
3365                 .maxlen = 1,
3366                 .off1   = offsetof(struct thread_options, zrf),
3367                 .minfp  = 0,
3368                 .maxfp  = 1,
3369                 .category = FIO_OPT_C_IO,
3370                 .group  = FIO_OPT_G_ZONE,
3371         },
3372         {
3373                 .name   = "lockmem",
3374                 .lname  = "Lock memory",
3375                 .type   = FIO_OPT_STR_VAL,
3376                 .off1   = offsetof(struct thread_options, lockmem),
3377                 .help   = "Lock down this amount of memory (per worker)",
3378                 .def    = "0",
3379                 .interval = 1024 * 1024,
3380                 .category = FIO_OPT_C_GENERAL,
3381                 .group  = FIO_OPT_G_INVALID,
3382         },
3383         {
3384                 .name   = "rwmixread",
3385                 .lname  = "Read/write mix read",
3386                 .type   = FIO_OPT_INT,
3387                 .cb     = str_rwmix_read_cb,
3388                 .off1   = offsetof(struct thread_options, rwmix[DDIR_READ]),
3389                 .maxval = 100,
3390                 .help   = "Percentage of mixed workload that is reads",
3391                 .def    = "50",
3392                 .interval = 5,
3393                 .inverse = "rwmixwrite",
3394                 .category = FIO_OPT_C_IO,
3395                 .group  = FIO_OPT_G_RWMIX,
3396         },
3397         {
3398                 .name   = "rwmixwrite",
3399                 .lname  = "Read/write mix write",
3400                 .type   = FIO_OPT_INT,
3401                 .cb     = str_rwmix_write_cb,
3402                 .off1   = offsetof(struct thread_options, rwmix[DDIR_WRITE]),
3403                 .maxval = 100,
3404                 .help   = "Percentage of mixed workload that is writes",
3405                 .def    = "50",
3406                 .interval = 5,
3407                 .inverse = "rwmixread",
3408                 .category = FIO_OPT_C_IO,
3409                 .group  = FIO_OPT_G_RWMIX,
3410         },
3411         {
3412                 .name   = "rwmixcycle",
3413                 .lname  = "Read/write mix cycle",
3414                 .type   = FIO_OPT_DEPRECATED,
3415                 .category = FIO_OPT_C_IO,
3416                 .group  = FIO_OPT_G_RWMIX,
3417         },
3418         {
3419                 .name   = "nice",
3420                 .lname  = "Nice",
3421                 .type   = FIO_OPT_INT,
3422                 .off1   = offsetof(struct thread_options, nice),
3423                 .help   = "Set job CPU nice value",
3424                 .minval = -20,
3425                 .maxval = 19,
3426                 .def    = "0",
3427                 .interval = 1,
3428                 .category = FIO_OPT_C_GENERAL,
3429                 .group  = FIO_OPT_G_CRED,
3430         },
3431 #ifdef FIO_HAVE_IOPRIO
3432         {
3433                 .name   = "prio",
3434                 .lname  = "I/O nice priority",
3435                 .type   = FIO_OPT_INT,
3436                 .off1   = offsetof(struct thread_options, ioprio),
3437                 .help   = "Set job IO priority value",
3438                 .minval = IOPRIO_MIN_PRIO,
3439                 .maxval = IOPRIO_MAX_PRIO,
3440                 .interval = 1,
3441                 .category = FIO_OPT_C_GENERAL,
3442                 .group  = FIO_OPT_G_CRED,
3443         },
3444 #else
3445         {
3446                 .name   = "prio",
3447                 .lname  = "I/O nice priority",
3448                 .type   = FIO_OPT_UNSUPPORTED,
3449                 .help   = "Your platform does not support IO priorities",
3450         },
3451 #endif
3452 #ifdef FIO_HAVE_IOPRIO_CLASS
3453 #ifndef FIO_HAVE_IOPRIO
3454 #error "FIO_HAVE_IOPRIO_CLASS requires FIO_HAVE_IOPRIO"
3455 #endif
3456         {
3457                 .name   = "prioclass",
3458                 .lname  = "I/O nice priority class",
3459                 .type   = FIO_OPT_INT,
3460                 .off1   = offsetof(struct thread_options, ioprio_class),
3461                 .help   = "Set job IO priority class",
3462                 .minval = IOPRIO_MIN_PRIO_CLASS,
3463                 .maxval = IOPRIO_MAX_PRIO_CLASS,
3464                 .interval = 1,
3465                 .category = FIO_OPT_C_GENERAL,
3466                 .group  = FIO_OPT_G_CRED,
3467         },
3468 #else
3469         {
3470                 .name   = "prioclass",
3471                 .lname  = "I/O nice priority class",
3472                 .type   = FIO_OPT_UNSUPPORTED,
3473                 .help   = "Your platform does not support IO priority classes",
3474         },
3475 #endif
3476         {
3477                 .name   = "thinktime",
3478                 .lname  = "Thinktime",
3479                 .type   = FIO_OPT_INT,
3480                 .off1   = offsetof(struct thread_options, thinktime),
3481                 .help   = "Idle time between IO buffers (usec)",
3482                 .def    = "0",
3483                 .is_time = 1,
3484                 .category = FIO_OPT_C_IO,
3485                 .group  = FIO_OPT_G_THINKTIME,
3486         },
3487         {
3488                 .name   = "thinktime_spin",
3489                 .lname  = "Thinktime spin",
3490                 .type   = FIO_OPT_INT,
3491                 .off1   = offsetof(struct thread_options, thinktime_spin),
3492                 .help   = "Start think time by spinning this amount (usec)",
3493                 .def    = "0",
3494                 .is_time = 1,
3495                 .parent = "thinktime",
3496                 .hide   = 1,
3497                 .category = FIO_OPT_C_IO,
3498                 .group  = FIO_OPT_G_THINKTIME,
3499         },
3500         {
3501                 .name   = "thinktime_blocks",
3502                 .lname  = "Thinktime blocks",
3503                 .type   = FIO_OPT_INT,
3504                 .off1   = offsetof(struct thread_options, thinktime_blocks),
3505                 .help   = "IO buffer period between 'thinktime'",
3506                 .def    = "1",
3507                 .parent = "thinktime",
3508                 .hide   = 1,
3509                 .category = FIO_OPT_C_IO,
3510                 .group  = FIO_OPT_G_THINKTIME,
3511         },
3512         {
3513                 .name   = "rate",
3514                 .lname  = "I/O rate",
3515                 .type   = FIO_OPT_INT,
3516                 .off1   = offsetof(struct thread_options, rate[DDIR_READ]),
3517                 .off2   = offsetof(struct thread_options, rate[DDIR_WRITE]),
3518                 .off3   = offsetof(struct thread_options, rate[DDIR_TRIM]),
3519                 .help   = "Set bandwidth rate",
3520                 .category = FIO_OPT_C_IO,
3521                 .group  = FIO_OPT_G_RATE,
3522         },
3523         {
3524                 .name   = "rate_min",
3525                 .alias  = "ratemin",
3526                 .lname  = "I/O min rate",
3527                 .type   = FIO_OPT_INT,
3528                 .off1   = offsetof(struct thread_options, ratemin[DDIR_READ]),
3529                 .off2   = offsetof(struct thread_options, ratemin[DDIR_WRITE]),
3530                 .off3   = offsetof(struct thread_options, ratemin[DDIR_TRIM]),
3531                 .help   = "Job must meet this rate or it will be shutdown",
3532                 .parent = "rate",
3533                 .hide   = 1,
3534                 .category = FIO_OPT_C_IO,
3535                 .group  = FIO_OPT_G_RATE,
3536         },
3537         {
3538                 .name   = "rate_iops",
3539                 .lname  = "I/O rate IOPS",
3540                 .type   = FIO_OPT_INT,
3541                 .off1   = offsetof(struct thread_options, rate_iops[DDIR_READ]),
3542                 .off2   = offsetof(struct thread_options, rate_iops[DDIR_WRITE]),
3543                 .off3   = offsetof(struct thread_options, rate_iops[DDIR_TRIM]),
3544                 .help   = "Limit IO used to this number of IO operations/sec",
3545                 .hide   = 1,
3546                 .category = FIO_OPT_C_IO,
3547                 .group  = FIO_OPT_G_RATE,
3548         },
3549         {
3550                 .name   = "rate_iops_min",
3551                 .lname  = "I/O min rate IOPS",
3552                 .type   = FIO_OPT_INT,
3553                 .off1   = offsetof(struct thread_options, rate_iops_min[DDIR_READ]),
3554                 .off2   = offsetof(struct thread_options, rate_iops_min[DDIR_WRITE]),
3555                 .off3   = offsetof(struct thread_options, rate_iops_min[DDIR_TRIM]),
3556                 .help   = "Job must meet this rate or it will be shut down",
3557                 .parent = "rate_iops",
3558                 .hide   = 1,
3559                 .category = FIO_OPT_C_IO,
3560                 .group  = FIO_OPT_G_RATE,
3561         },
3562         {
3563                 .name   = "rate_process",
3564                 .lname  = "Rate Process",
3565                 .type   = FIO_OPT_STR,
3566                 .off1   = offsetof(struct thread_options, rate_process),
3567                 .help   = "What process controls how rated IO is managed",
3568                 .def    = "linear",
3569                 .category = FIO_OPT_C_IO,
3570                 .group  = FIO_OPT_G_RATE,
3571                 .posval = {
3572                           { .ival = "linear",
3573                             .oval = RATE_PROCESS_LINEAR,
3574                             .help = "Linear rate of IO",
3575                           },
3576                           {
3577                             .ival = "poisson",
3578                             .oval = RATE_PROCESS_POISSON,
3579                             .help = "Rate follows Poisson process",
3580                           },
3581                 },
3582                 .parent = "rate",
3583         },
3584         {
3585                 .name   = "rate_cycle",
3586                 .alias  = "ratecycle",
3587                 .lname  = "I/O rate cycle",
3588                 .type   = FIO_OPT_INT,
3589                 .off1   = offsetof(struct thread_options, ratecycle),
3590                 .help   = "Window average for rate limits (msec)",
3591                 .def    = "1000",
3592                 .parent = "rate",
3593                 .hide   = 1,
3594                 .category = FIO_OPT_C_IO,
3595                 .group  = FIO_OPT_G_RATE,
3596         },
3597         {
3598                 .name   = "rate_ignore_thinktime",
3599                 .lname  = "Rate ignore thinktime",
3600                 .type   = FIO_OPT_BOOL,
3601                 .off1   = offsetof(struct thread_options, rate_ign_think),
3602                 .help   = "Rated IO ignores thinktime settings",
3603                 .parent = "rate",
3604                 .category = FIO_OPT_C_IO,
3605                 .group  = FIO_OPT_G_RATE,
3606         },
3607         {
3608                 .name   = "max_latency",
3609                 .lname  = "Max Latency (usec)",
3610                 .type   = FIO_OPT_STR_VAL_TIME,
3611                 .off1   = offsetof(struct thread_options, max_latency),
3612                 .help   = "Maximum tolerated IO latency (usec)",
3613                 .is_time = 1,
3614                 .category = FIO_OPT_C_IO,
3615                 .group = FIO_OPT_G_LATPROF,
3616         },
3617         {
3618                 .name   = "latency_target",
3619                 .lname  = "Latency Target (usec)",
3620                 .type   = FIO_OPT_STR_VAL_TIME,
3621                 .off1   = offsetof(struct thread_options, latency_target),
3622                 .help   = "Ramp to max queue depth supporting this latency",
3623                 .is_time = 1,
3624                 .category = FIO_OPT_C_IO,
3625                 .group  = FIO_OPT_G_LATPROF,
3626         },
3627         {
3628                 .name   = "latency_window",
3629                 .lname  = "Latency Window (usec)",
3630                 .type   = FIO_OPT_STR_VAL_TIME,
3631                 .off1   = offsetof(struct thread_options, latency_window),
3632                 .help   = "Time to sustain latency_target",
3633                 .is_time = 1,
3634                 .category = FIO_OPT_C_IO,
3635                 .group  = FIO_OPT_G_LATPROF,
3636         },
3637         {
3638                 .name   = "latency_percentile",
3639                 .lname  = "Latency Percentile",
3640                 .type   = FIO_OPT_FLOAT_LIST,
3641                 .off1   = offsetof(struct thread_options, latency_percentile),
3642                 .help   = "Percentile of IOs must be below latency_target",
3643                 .def    = "100",
3644                 .maxlen = 1,
3645                 .minfp  = 0.0,
3646                 .maxfp  = 100.0,
3647                 .category = FIO_OPT_C_IO,
3648                 .group  = FIO_OPT_G_LATPROF,
3649         },
3650         {
3651                 .name   = "invalidate",
3652                 .lname  = "Cache invalidate",
3653                 .type   = FIO_OPT_BOOL,
3654                 .off1   = offsetof(struct thread_options, invalidate_cache),
3655                 .help   = "Invalidate buffer/page cache prior to running job",
3656                 .def    = "1",
3657                 .category = FIO_OPT_C_IO,
3658                 .group  = FIO_OPT_G_IO_TYPE,
3659         },
3660         {
3661                 .name   = "sync",
3662                 .lname  = "Synchronous I/O",
3663                 .type   = FIO_OPT_BOOL,
3664                 .off1   = offsetof(struct thread_options, sync_io),
3665                 .help   = "Use O_SYNC for buffered writes",
3666                 .def    = "0",
3667                 .parent = "buffered",
3668                 .hide   = 1,
3669                 .category = FIO_OPT_C_IO,
3670                 .group  = FIO_OPT_G_IO_TYPE,
3671         },
3672 #ifdef FIO_HAVE_WRITE_HINT
3673         {
3674                 .name   = "write_hint",
3675                 .lname  = "Write hint",
3676                 .type   = FIO_OPT_STR,
3677                 .off1   = offsetof(struct thread_options, write_hint),
3678                 .help   = "Set expected write life time",
3679                 .category = FIO_OPT_C_ENGINE,
3680                 .group  = FIO_OPT_G_INVALID,
3681                 .posval = {
3682                           { .ival = "none",
3683                             .oval = RWH_WRITE_LIFE_NONE,
3684                           },
3685                           { .ival = "short",
3686                             .oval = RWH_WRITE_LIFE_SHORT,
3687                           },
3688                           { .ival = "medium",
3689                             .oval = RWH_WRITE_LIFE_MEDIUM,
3690                           },
3691                           { .ival = "long",
3692                             .oval = RWH_WRITE_LIFE_LONG,
3693                           },
3694                           { .ival = "extreme",
3695                             .oval = RWH_WRITE_LIFE_EXTREME,
3696                           },
3697                 },
3698         },
3699 #endif
3700         {
3701                 .name   = "create_serialize",
3702                 .lname  = "Create serialize",
3703                 .type   = FIO_OPT_BOOL,
3704                 .off1   = offsetof(struct thread_options, create_serialize),
3705                 .help   = "Serialize creation of job files",
3706                 .def    = "1",
3707                 .category = FIO_OPT_C_FILE,
3708                 .group  = FIO_OPT_G_INVALID,
3709         },
3710         {
3711                 .name   = "create_fsync",
3712                 .lname  = "Create fsync",
3713                 .type   = FIO_OPT_BOOL,
3714                 .off1   = offsetof(struct thread_options, create_fsync),
3715                 .help   = "fsync file after creation",
3716                 .def    = "1",
3717                 .category = FIO_OPT_C_FILE,
3718                 .group  = FIO_OPT_G_INVALID,
3719         },
3720         {
3721                 .name   = "create_on_open",
3722                 .lname  = "Create on open",
3723                 .type   = FIO_OPT_BOOL,
3724                 .off1   = offsetof(struct thread_options, create_on_open),
3725                 .help   = "Create files when they are opened for IO",
3726                 .def    = "0",
3727                 .category = FIO_OPT_C_FILE,
3728                 .group  = FIO_OPT_G_INVALID,
3729         },
3730         {
3731                 .name   = "create_only",
3732                 .lname  = "Create Only",
3733                 .type   = FIO_OPT_BOOL,
3734                 .off1   = offsetof(struct thread_options, create_only),
3735                 .help   = "Only perform file creation phase",
3736                 .category = FIO_OPT_C_FILE,
3737                 .def    = "0",
3738         },
3739         {
3740                 .name   = "allow_file_create",
3741                 .lname  = "Allow file create",
3742                 .type   = FIO_OPT_BOOL,
3743                 .off1   = offsetof(struct thread_options, allow_create),
3744                 .help   = "Permit fio to create files, if they don't exist",
3745                 .def    = "1",
3746                 .category = FIO_OPT_C_FILE,
3747                 .group  = FIO_OPT_G_FILENAME,
3748         },
3749         {
3750                 .name   = "allow_mounted_write",
3751                 .lname  = "Allow mounted write",
3752                 .type   = FIO_OPT_BOOL,
3753                 .off1   = offsetof(struct thread_options, allow_mounted_write),
3754                 .help   = "Allow writes to a mounted partition",
3755                 .def    = "0",
3756                 .category = FIO_OPT_C_FILE,
3757                 .group  = FIO_OPT_G_FILENAME,
3758         },
3759         {
3760                 .name   = "pre_read",
3761                 .lname  = "Pre-read files",
3762                 .type   = FIO_OPT_BOOL,
3763                 .off1   = offsetof(struct thread_options, pre_read),
3764                 .help   = "Pre-read files before starting official testing",
3765                 .def    = "0",
3766                 .category = FIO_OPT_C_FILE,
3767                 .group  = FIO_OPT_G_INVALID,
3768         },
3769 #ifdef FIO_HAVE_CPU_AFFINITY
3770         {
3771                 .name   = "cpumask",
3772                 .lname  = "CPU mask",
3773                 .type   = FIO_OPT_INT,
3774                 .cb     = str_cpumask_cb,
3775                 .off1   = offsetof(struct thread_options, cpumask),
3776                 .help   = "CPU affinity mask",
3777                 .category = FIO_OPT_C_GENERAL,
3778                 .group  = FIO_OPT_G_CRED,
3779         },
3780         {
3781                 .name   = "cpus_allowed",
3782                 .lname  = "CPUs allowed",
3783                 .type   = FIO_OPT_STR,
3784                 .cb     = str_cpus_allowed_cb,
3785                 .off1   = offsetof(struct thread_options, cpumask),
3786                 .help   = "Set CPUs allowed",
3787                 .category = FIO_OPT_C_GENERAL,
3788                 .group  = FIO_OPT_G_CRED,
3789         },
3790         {
3791                 .name   = "cpus_allowed_policy",
3792                 .lname  = "CPUs allowed distribution policy",
3793                 .type   = FIO_OPT_STR,
3794                 .off1   = offsetof(struct thread_options, cpus_allowed_policy),
3795                 .help   = "Distribution policy for cpus_allowed",
3796                 .parent = "cpus_allowed",
3797                 .prio   = 1,
3798                 .posval = {
3799                           { .ival = "shared",
3800                             .oval = FIO_CPUS_SHARED,
3801                             .help = "Mask shared between threads",
3802                           },
3803                           { .ival = "split",
3804                             .oval = FIO_CPUS_SPLIT,
3805                             .help = "Mask split between threads",
3806                           },
3807                 },
3808                 .category = FIO_OPT_C_GENERAL,
3809                 .group  = FIO_OPT_G_CRED,
3810         },
3811 #else
3812         {
3813                 .name   = "cpumask",
3814                 .lname  = "CPU mask",
3815                 .type   = FIO_OPT_UNSUPPORTED,
3816                 .help   = "Your platform does not support CPU affinities",
3817         },
3818         {
3819                 .name   = "cpus_allowed",
3820                 .lname  = "CPUs allowed",
3821                 .type   = FIO_OPT_UNSUPPORTED,
3822                 .help   = "Your platform does not support CPU affinities",
3823         },
3824         {
3825                 .name   = "cpus_allowed_policy",
3826                 .lname  = "CPUs allowed distribution policy",
3827                 .type   = FIO_OPT_UNSUPPORTED,
3828                 .help   = "Your platform does not support CPU affinities",
3829         },
3830 #endif
3831 #ifdef CONFIG_LIBNUMA
3832         {
3833                 .name   = "numa_cpu_nodes",
3834                 .lname  = "NUMA CPU Nodes",
3835                 .type   = FIO_OPT_STR,
3836                 .cb     = str_numa_cpunodes_cb,
3837                 .off1   = offsetof(struct thread_options, numa_cpunodes),
3838                 .help   = "NUMA CPU nodes bind",
3839                 .category = FIO_OPT_C_GENERAL,
3840                 .group  = FIO_OPT_G_INVALID,
3841         },
3842         {
3843                 .name   = "numa_mem_policy",
3844                 .lname  = "NUMA Memory Policy",
3845                 .type   = FIO_OPT_STR,
3846                 .cb     = str_numa_mpol_cb,
3847                 .off1   = offsetof(struct thread_options, numa_memnodes),
3848                 .help   = "NUMA memory policy setup",
3849                 .category = FIO_OPT_C_GENERAL,
3850                 .group  = FIO_OPT_G_INVALID,
3851         },
3852 #else
3853         {
3854                 .name   = "numa_cpu_nodes",
3855                 .lname  = "NUMA CPU Nodes",
3856                 .type   = FIO_OPT_UNSUPPORTED,
3857                 .help   = "Build fio with libnuma-dev(el) to enable this option",
3858         },
3859         {
3860                 .name   = "numa_mem_policy",
3861                 .lname  = "NUMA Memory Policy",
3862                 .type   = FIO_OPT_UNSUPPORTED,
3863                 .help   = "Build fio with libnuma-dev(el) to enable this option",
3864         },
3865 #endif
3866 #ifdef CONFIG_CUDA
3867         {
3868                 .name   = "gpu_dev_id",
3869                 .lname  = "GPU device ID",
3870                 .type   = FIO_OPT_INT,
3871                 .off1   = offsetof(struct thread_options, gpu_dev_id),
3872                 .help   = "Set GPU device ID for GPUDirect RDMA",
3873                 .def    = "0",
3874                 .category = FIO_OPT_C_GENERAL,
3875                 .group  = FIO_OPT_G_INVALID,
3876         },