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