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