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