4c4f52c001c03b89df76ee5547d391a316df2c1e
[fio.git] / options.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <unistd.h>
4 #include <ctype.h>
5 #include <string.h>
6 #include <assert.h>
7 #include <libgen.h>
8 #include <fcntl.h>
9 #include <sys/types.h>
10 #include <sys/stat.h>
11 #include <netinet/in.h>
12
13 #include "fio.h"
14 #include "verify.h"
15 #include "parse.h"
16 #include "lib/fls.h"
17 #include "lib/pattern.h"
18 #include "options.h"
19 #include "optgroup.h"
20
21 char client_sockaddr_str[INET6_ADDRSTRLEN] = { 0 };
22
23 #define cb_data_to_td(data)     container_of(data, struct thread_data, o)
24
25 static struct pattern_fmt_desc fmt_desc[] = {
26         {
27                 .fmt   = "%o",
28                 .len   = FIELD_SIZE(struct io_u *, offset),
29                 .paste = paste_blockoff
30         }
31 };
32
33 /*
34  * Check if mmap/mmaphuge has a :/foo/bar/file at the end. If so, return that.
35  */
36 static char *get_opt_postfix(const char *str)
37 {
38         char *p = strstr(str, ":");
39
40         if (!p)
41                 return NULL;
42
43         p++;
44         strip_blank_front(&p);
45         strip_blank_end(p);
46         return strdup(p);
47 }
48
49 static int bs_cmp(const void *p1, const void *p2)
50 {
51         const struct bssplit *bsp1 = p1;
52         const struct bssplit *bsp2 = p2;
53
54         return (int) bsp1->perc - (int) bsp2->perc;
55 }
56
57 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 static int str_steadystate_cb(void *data, const char *str)
1065 {
1066         struct thread_data *td = cb_data_to_td(data);
1067         double val;
1068         char *nr;
1069         char *pct;
1070         long long ll;
1071
1072         if (td->o.ss_state != FIO_SS_IOPS && td->o.ss_state != FIO_SS_IOPS_SLOPE &&
1073             td->o.ss_state != FIO_SS_BW && td->o.ss_state != FIO_SS_BW_SLOPE) {
1074                 /* should be impossible to get here */
1075                 log_err("fio: unknown steady state criterion\n");
1076                 return 1;
1077         }
1078
1079         nr = get_opt_postfix(str);
1080         if (!nr) {
1081                 log_err("fio: steadystate threshold must be specified in addition to criterion\n");
1082                 free(nr);
1083                 return 1;
1084         }
1085
1086         /* ENHANCEMENT Allow fio to understand size=10.2% and use here */
1087         pct = strstr(nr, "%");
1088         if (pct) {
1089                 *pct = '\0';
1090                 strip_blank_end(nr);
1091                 if (!str_to_float(nr, &val, 0)) {
1092                         log_err("fio: could not parse steadystate threshold percentage\n");
1093                         free(nr);
1094                         return 1;
1095                 }
1096
1097                 dprint(FD_PARSE, "set steady state threshold to %f%%\n", val);
1098                 free(nr);
1099                 if (parse_dryrun())
1100                         return 0;
1101
1102                 td->o.ss_state |= __FIO_SS_PCT;
1103                 td->o.ss_limit.u.f = val;
1104         } else if (td->o.ss_state & __FIO_SS_IOPS) {
1105                 if (!str_to_float(nr, &val, 0)) {
1106                         log_err("fio: steadystate IOPS threshold postfix parsing failed\n");
1107                         free(nr);
1108                         return 1;
1109                 }
1110
1111                 dprint(FD_PARSE, "set steady state IOPS threshold to %f\n", val);
1112                 free(nr);
1113                 if (parse_dryrun())
1114                         return 0;
1115
1116                 td->o.ss_limit.u.f = val;
1117         } else {        /* bandwidth criterion */
1118                 if (str_to_decimal(nr, &ll, 1, td, 0, 0)) {
1119                         log_err("fio: steadystate BW threshold postfix parsing failed\n");
1120                         free(nr);
1121                         return 1;
1122                 }
1123
1124                 dprint(FD_PARSE, "set steady state BW threshold to %lld\n", ll);
1125                 free(nr);
1126                 if (parse_dryrun())
1127                         return 0;
1128
1129                 td->o.ss_limit.u.f = (double) ll;
1130         }
1131
1132         td->ss.state = td->o.ss_state;
1133         return 0;
1134 }
1135
1136 /*
1137  * Return next name in the string. Files are separated with ':'. If the ':'
1138  * is escaped with a '\', then that ':' is part of the filename and does not
1139  * indicate a new file.
1140  */
1141 static char *get_next_name(char **ptr)
1142 {
1143         char *str = *ptr;
1144         char *p, *start;
1145
1146         if (!str || !strlen(str))
1147                 return NULL;
1148
1149         start = str;
1150         do {
1151                 /*
1152                  * No colon, we are done
1153                  */
1154                 p = strchr(str, ':');
1155                 if (!p) {
1156                         *ptr = NULL;
1157                         break;
1158                 }
1159
1160                 /*
1161                  * We got a colon, but it's the first character. Skip and
1162                  * continue
1163                  */
1164                 if (p == start) {
1165                         str = ++start;
1166                         continue;
1167                 }
1168
1169                 if (*(p - 1) != '\\') {
1170                         *p = '\0';
1171                         *ptr = p + 1;
1172                         break;
1173                 }
1174
1175                 memmove(p - 1, p, strlen(p) + 1);
1176                 str = p;
1177         } while (1);
1178
1179         return start;
1180 }
1181
1182
1183 static int get_max_name_idx(char *input)
1184 {
1185         unsigned int cur_idx;
1186         char *str, *p;
1187
1188         p = str = strdup(input);
1189         for (cur_idx = 0; ; cur_idx++)
1190                 if (get_next_name(&str) == NULL)
1191                         break;
1192
1193         free(p);
1194         return cur_idx;
1195 }
1196
1197 /*
1198  * Returns the directory at the index, indexes > entires will be
1199  * assigned via modulo division of the index
1200  */
1201 int set_name_idx(char *target, size_t tlen, char *input, int index,
1202                  bool unique_filename)
1203 {
1204         unsigned int cur_idx;
1205         int len;
1206         char *fname, *str, *p;
1207
1208         p = str = strdup(input);
1209
1210         index %= get_max_name_idx(input);
1211         for (cur_idx = 0; cur_idx <= index; cur_idx++)
1212                 fname = get_next_name(&str);
1213
1214         if (client_sockaddr_str[0] && unique_filename) {
1215                 len = snprintf(target, tlen, "%s/%s.", fname,
1216                                 client_sockaddr_str);
1217         } else
1218                 len = snprintf(target, tlen, "%s/", fname);
1219
1220         target[tlen - 1] = '\0';
1221         free(p);
1222
1223         return len;
1224 }
1225
1226 static int str_filename_cb(void *data, const char *input)
1227 {
1228         struct thread_data *td = cb_data_to_td(data);
1229         char *fname, *str, *p;
1230
1231         p = str = strdup(input);
1232
1233         strip_blank_front(&str);
1234         strip_blank_end(str);
1235
1236         if (!td->files_index)
1237                 td->o.nr_files = 0;
1238
1239         while ((fname = get_next_name(&str)) != NULL) {
1240                 if (!strlen(fname))
1241                         break;
1242                 add_file(td, fname, 0, 1);
1243         }
1244
1245         free(p);
1246         return 0;
1247 }
1248
1249 static int str_directory_cb(void *data, const char fio_unused *unused)
1250 {
1251         struct thread_data *td = cb_data_to_td(data);
1252         struct stat sb;
1253         char *dirname, *str, *p;
1254         int ret = 0;
1255
1256         if (parse_dryrun())
1257                 return 0;
1258
1259         p = str = strdup(td->o.directory);
1260         while ((dirname = get_next_name(&str)) != NULL) {
1261                 if (lstat(dirname, &sb) < 0) {
1262                         ret = errno;
1263
1264                         log_err("fio: %s is not a directory\n", dirname);
1265                         td_verror(td, ret, "lstat");
1266                         goto out;
1267                 }
1268                 if (!S_ISDIR(sb.st_mode)) {
1269                         log_err("fio: %s is not a directory\n", dirname);
1270                         ret = 1;
1271                         goto out;
1272                 }
1273         }
1274
1275 out:
1276         free(p);
1277         return ret;
1278 }
1279
1280 static int str_opendir_cb(void *data, const char fio_unused *str)
1281 {
1282         struct thread_data *td = cb_data_to_td(data);
1283
1284         if (parse_dryrun())
1285                 return 0;
1286
1287         if (!td->files_index)
1288                 td->o.nr_files = 0;
1289
1290         return add_dir_files(td, td->o.opendir);
1291 }
1292
1293 static int str_buffer_pattern_cb(void *data, const char *input)
1294 {
1295         struct thread_data *td = cb_data_to_td(data);
1296         int ret;
1297
1298         /* FIXME: for now buffer pattern does not support formats */
1299         ret = parse_and_fill_pattern(input, strlen(input), td->o.buffer_pattern,
1300                                      MAX_PATTERN_SIZE, NULL, 0, NULL, NULL);
1301         if (ret < 0)
1302                 return 1;
1303
1304         assert(ret != 0);
1305         td->o.buffer_pattern_bytes = ret;
1306         if (!td->o.compress_percentage)
1307                 td->o.refill_buffers = 0;
1308         td->o.scramble_buffers = 0;
1309         td->o.zero_buffers = 0;
1310
1311         return 0;
1312 }
1313
1314 static int str_buffer_compress_cb(void *data, unsigned long long *il)
1315 {
1316         struct thread_data *td = cb_data_to_td(data);
1317
1318         td->flags |= TD_F_COMPRESS;
1319         td->o.compress_percentage = *il;
1320         return 0;
1321 }
1322
1323 static int str_dedupe_cb(void *data, unsigned long long *il)
1324 {
1325         struct thread_data *td = cb_data_to_td(data);
1326
1327         td->flags |= TD_F_COMPRESS;
1328         td->o.dedupe_percentage = *il;
1329         td->o.refill_buffers = 1;
1330         return 0;
1331 }
1332
1333 static int str_verify_pattern_cb(void *data, const char *input)
1334 {
1335         struct thread_data *td = cb_data_to_td(data);
1336         int ret;
1337
1338         td->o.verify_fmt_sz = ARRAY_SIZE(td->o.verify_fmt);
1339         ret = parse_and_fill_pattern(input, strlen(input), td->o.verify_pattern,
1340                                      MAX_PATTERN_SIZE, fmt_desc, sizeof(fmt_desc),
1341                                      td->o.verify_fmt, &td->o.verify_fmt_sz);
1342         if (ret < 0)
1343                 return 1;
1344
1345         assert(ret != 0);
1346         td->o.verify_pattern_bytes = ret;
1347         /*
1348          * VERIFY_* could already be set
1349          */
1350         if (!fio_option_is_set(&td->o, verify))
1351                 td->o.verify = VERIFY_PATTERN;
1352
1353         return 0;
1354 }
1355
1356 static int str_gtod_reduce_cb(void *data, int *il)
1357 {
1358         struct thread_data *td = cb_data_to_td(data);
1359         int val = *il;
1360
1361         td->o.disable_lat = !!val;
1362         td->o.disable_clat = !!val;
1363         td->o.disable_slat = !!val;
1364         td->o.disable_bw = !!val;
1365         td->o.clat_percentiles = !val;
1366         if (val)
1367                 td->tv_cache_mask = 63;
1368
1369         return 0;
1370 }
1371
1372 static int str_size_cb(void *data, unsigned long long *__val)
1373 {
1374         struct thread_data *td = cb_data_to_td(data);
1375         unsigned long long v = *__val;
1376
1377         if (parse_is_percent(v)) {
1378                 td->o.size = 0;
1379                 td->o.size_percent = -1ULL - v;
1380         } else
1381                 td->o.size = v;
1382
1383         return 0;
1384 }
1385
1386 static int str_write_bw_log_cb(void *data, const char *str)
1387 {
1388         struct thread_data *td = cb_data_to_td(data);
1389
1390         if (str)
1391                 td->o.bw_log_file = strdup(str);
1392
1393         td->o.write_bw_log = 1;
1394         return 0;
1395 }
1396
1397 static int str_write_lat_log_cb(void *data, const char *str)
1398 {
1399         struct thread_data *td = cb_data_to_td(data);
1400
1401         if (str)
1402                 td->o.lat_log_file = strdup(str);
1403
1404         td->o.write_lat_log = 1;
1405         return 0;
1406 }
1407
1408 static int str_write_iops_log_cb(void *data, const char *str)
1409 {
1410         struct thread_data *td = cb_data_to_td(data);
1411
1412         if (str)
1413                 td->o.iops_log_file = strdup(str);
1414
1415         td->o.write_iops_log = 1;
1416         return 0;
1417 }
1418
1419 static int str_write_hist_log_cb(void *data, const char *str)
1420 {
1421         struct thread_data *td = cb_data_to_td(data);
1422
1423         if (str)
1424                 td->o.hist_log_file = strdup(str);
1425
1426         td->o.write_hist_log = 1;
1427         return 0;
1428 }
1429
1430 static int rw_verify(struct fio_option *o, void *data)
1431 {
1432         struct thread_data *td = cb_data_to_td(data);
1433
1434         if (read_only && td_write(td)) {
1435                 log_err("fio: job <%s> has write bit set, but fio is in"
1436                         " read-only mode\n", td->o.name);
1437                 return 1;
1438         }
1439
1440         return 0;
1441 }
1442
1443 static int gtod_cpu_verify(struct fio_option *o, void *data)
1444 {
1445 #ifndef FIO_HAVE_CPU_AFFINITY
1446         struct thread_data *td = cb_data_to_td(data);
1447
1448         if (td->o.gtod_cpu) {
1449                 log_err("fio: platform must support CPU affinity for"
1450                         "gettimeofday() offloading\n");
1451                 return 1;
1452         }
1453 #endif
1454
1455         return 0;
1456 }
1457
1458 /*
1459  * Map of job/command line options
1460  */
1461 struct fio_option fio_options[FIO_MAX_OPTS] = {
1462         {
1463                 .name   = "description",
1464                 .lname  = "Description of job",
1465                 .type   = FIO_OPT_STR_STORE,
1466                 .off1   = offsetof(struct thread_options, description),
1467                 .help   = "Text job description",
1468                 .category = FIO_OPT_C_GENERAL,
1469                 .group  = FIO_OPT_G_DESC,
1470         },
1471         {
1472                 .name   = "name",
1473                 .lname  = "Job name",
1474                 .type   = FIO_OPT_STR_STORE,
1475                 .off1   = offsetof(struct thread_options, name),
1476                 .help   = "Name of this job",
1477                 .category = FIO_OPT_C_GENERAL,
1478                 .group  = FIO_OPT_G_DESC,
1479         },
1480         {
1481                 .name   = "wait_for",
1482                 .lname  = "Waitee name",
1483                 .type   = FIO_OPT_STR_STORE,
1484                 .off1   = offsetof(struct thread_options, wait_for),
1485                 .help   = "Name of the job this one wants to wait for before starting",
1486                 .category = FIO_OPT_C_GENERAL,
1487                 .group  = FIO_OPT_G_DESC,
1488         },
1489         {
1490                 .name   = "filename",
1491                 .lname  = "Filename(s)",
1492                 .type   = FIO_OPT_STR_STORE,
1493                 .off1   = offsetof(struct thread_options, filename),
1494                 .cb     = str_filename_cb,
1495                 .prio   = -1, /* must come after "directory" */
1496                 .help   = "File(s) to use for the workload",
1497                 .category = FIO_OPT_C_FILE,
1498                 .group  = FIO_OPT_G_FILENAME,
1499         },
1500         {
1501                 .name   = "directory",
1502                 .lname  = "Directory",
1503                 .type   = FIO_OPT_STR_STORE,
1504                 .off1   = offsetof(struct thread_options, directory),
1505                 .cb     = str_directory_cb,
1506                 .help   = "Directory to store files in",
1507                 .category = FIO_OPT_C_FILE,
1508                 .group  = FIO_OPT_G_FILENAME,
1509         },
1510         {
1511                 .name   = "filename_format",
1512                 .lname  = "Filename Format",
1513                 .type   = FIO_OPT_STR_STORE,
1514                 .off1   = offsetof(struct thread_options, filename_format),
1515                 .prio   = -1, /* must come after "directory" */
1516                 .help   = "Override default $jobname.$jobnum.$filenum naming",
1517                 .def    = "$jobname.$jobnum.$filenum",
1518                 .category = FIO_OPT_C_FILE,
1519                 .group  = FIO_OPT_G_FILENAME,
1520         },
1521         {
1522                 .name   = "unique_filename",
1523                 .lname  = "Unique Filename",
1524                 .type   = FIO_OPT_BOOL,
1525                 .off1   = offsetof(struct thread_options, unique_filename),
1526                 .help   = "For network clients, prefix file with source IP",
1527                 .def    = "1",
1528                 .category = FIO_OPT_C_FILE,
1529                 .group  = FIO_OPT_G_FILENAME,
1530         },
1531         {
1532                 .name   = "lockfile",
1533                 .lname  = "Lockfile",
1534                 .type   = FIO_OPT_STR,
1535                 .off1   = offsetof(struct thread_options, file_lock_mode),
1536                 .help   = "Lock file when doing IO to it",
1537                 .prio   = 1,
1538                 .parent = "filename",
1539                 .hide   = 0,
1540                 .def    = "none",
1541                 .category = FIO_OPT_C_FILE,
1542                 .group  = FIO_OPT_G_FILENAME,
1543                 .posval = {
1544                           { .ival = "none",
1545                             .oval = FILE_LOCK_NONE,
1546                             .help = "No file locking",
1547                           },
1548                           { .ival = "exclusive",
1549                             .oval = FILE_LOCK_EXCLUSIVE,
1550                             .help = "Exclusive file lock",
1551                           },
1552                           {
1553                             .ival = "readwrite",
1554                             .oval = FILE_LOCK_READWRITE,
1555                             .help = "Read vs write lock",
1556                           },
1557                 },
1558         },
1559         {
1560                 .name   = "opendir",
1561                 .lname  = "Open directory",
1562                 .type   = FIO_OPT_STR_STORE,
1563                 .off1   = offsetof(struct thread_options, opendir),
1564                 .cb     = str_opendir_cb,
1565                 .help   = "Recursively add files from this directory and down",
1566                 .category = FIO_OPT_C_FILE,
1567                 .group  = FIO_OPT_G_FILENAME,
1568         },
1569         {
1570                 .name   = "rw",
1571                 .lname  = "Read/write",
1572                 .alias  = "readwrite",
1573                 .type   = FIO_OPT_STR,
1574                 .cb     = str_rw_cb,
1575                 .off1   = offsetof(struct thread_options, td_ddir),
1576                 .help   = "IO direction",
1577                 .def    = "read",
1578                 .verify = rw_verify,
1579                 .category = FIO_OPT_C_IO,
1580                 .group  = FIO_OPT_G_IO_BASIC,
1581                 .posval = {
1582                           { .ival = "read",
1583                             .oval = TD_DDIR_READ,
1584                             .help = "Sequential read",
1585                           },
1586                           { .ival = "write",
1587                             .oval = TD_DDIR_WRITE,
1588                             .help = "Sequential write",
1589                           },
1590                           { .ival = "trim",
1591                             .oval = TD_DDIR_TRIM,
1592                             .help = "Sequential trim",
1593                           },
1594                           { .ival = "randread",
1595                             .oval = TD_DDIR_RANDREAD,
1596                             .help = "Random read",
1597                           },
1598                           { .ival = "randwrite",
1599                             .oval = TD_DDIR_RANDWRITE,
1600                             .help = "Random write",
1601                           },
1602                           { .ival = "randtrim",
1603                             .oval = TD_DDIR_RANDTRIM,
1604                             .help = "Random trim",
1605                           },
1606                           { .ival = "rw",
1607                             .oval = TD_DDIR_RW,
1608                             .help = "Sequential read and write mix",
1609                           },
1610                           { .ival = "readwrite",
1611                             .oval = TD_DDIR_RW,
1612                             .help = "Sequential read and write mix",
1613                           },
1614                           { .ival = "randrw",
1615                             .oval = TD_DDIR_RANDRW,
1616                             .help = "Random read and write mix"
1617                           },
1618                           { .ival = "trimwrite",
1619                             .oval = TD_DDIR_TRIMWRITE,
1620                             .help = "Trim and write mix, trims preceding writes"
1621                           },
1622                 },
1623         },
1624         {
1625                 .name   = "rw_sequencer",
1626                 .lname  = "RW Sequencer",
1627                 .type   = FIO_OPT_STR,
1628                 .off1   = offsetof(struct thread_options, rw_seq),
1629                 .help   = "IO offset generator modifier",
1630                 .def    = "sequential",
1631                 .category = FIO_OPT_C_IO,
1632                 .group  = FIO_OPT_G_IO_BASIC,
1633                 .posval = {
1634                           { .ival = "sequential",
1635                             .oval = RW_SEQ_SEQ,
1636                             .help = "Generate sequential offsets",
1637                           },
1638                           { .ival = "identical",
1639                             .oval = RW_SEQ_IDENT,
1640                             .help = "Generate identical offsets",
1641                           },
1642                 },
1643         },
1644
1645         {
1646                 .name   = "ioengine",
1647                 .lname  = "IO Engine",
1648                 .type   = FIO_OPT_STR_STORE,
1649                 .off1   = offsetof(struct thread_options, ioengine),
1650                 .help   = "IO engine to use",
1651                 .def    = FIO_PREFERRED_ENGINE,
1652                 .category = FIO_OPT_C_IO,
1653                 .group  = FIO_OPT_G_IO_BASIC,
1654                 .posval = {
1655                           { .ival = "sync",
1656                             .help = "Use read/write",
1657                           },
1658                           { .ival = "psync",
1659                             .help = "Use pread/pwrite",
1660                           },
1661                           { .ival = "vsync",
1662                             .help = "Use readv/writev",
1663                           },
1664 #ifdef CONFIG_PWRITEV
1665                           { .ival = "pvsync",
1666                             .help = "Use preadv/pwritev",
1667                           },
1668 #endif
1669 #ifdef FIO_HAVE_PWRITEV2
1670                           { .ival = "pvsync2",
1671                             .help = "Use preadv2/pwritev2",
1672                           },
1673 #endif
1674 #ifdef CONFIG_LIBAIO
1675                           { .ival = "libaio",
1676                             .help = "Linux native asynchronous IO",
1677                           },
1678 #endif
1679 #ifdef CONFIG_POSIXAIO
1680                           { .ival = "posixaio",
1681                             .help = "POSIX asynchronous IO",
1682                           },
1683 #endif
1684 #ifdef CONFIG_SOLARISAIO
1685                           { .ival = "solarisaio",
1686                             .help = "Solaris native asynchronous IO",
1687                           },
1688 #endif
1689 #ifdef CONFIG_WINDOWSAIO
1690                           { .ival = "windowsaio",
1691                             .help = "Windows native asynchronous IO"
1692                           },
1693 #endif
1694 #ifdef CONFIG_RBD
1695                           { .ival = "rbd",
1696                             .help = "Rados Block Device asynchronous IO"
1697                           },
1698 #endif
1699                           { .ival = "mmap",
1700                             .help = "Memory mapped IO"
1701                           },
1702 #ifdef CONFIG_LINUX_SPLICE
1703                           { .ival = "splice",
1704                             .help = "splice/vmsplice based IO",
1705                           },
1706                           { .ival = "netsplice",
1707                             .help = "splice/vmsplice to/from the network",
1708                           },
1709 #endif
1710 #ifdef FIO_HAVE_SGIO
1711                           { .ival = "sg",
1712                             .help = "SCSI generic v3 IO",
1713                           },
1714 #endif
1715                           { .ival = "null",
1716                             .help = "Testing engine (no data transfer)",
1717                           },
1718                           { .ival = "net",
1719                             .help = "Network IO",
1720                           },
1721                           { .ival = "cpuio",
1722                             .help = "CPU cycle burner engine",
1723                           },
1724 #ifdef CONFIG_GUASI
1725                           { .ival = "guasi",
1726                             .help = "GUASI IO engine",
1727                           },
1728 #endif
1729 #ifdef FIO_HAVE_BINJECT
1730                           { .ival = "binject",
1731                             .help = "binject direct inject block engine",
1732                           },
1733 #endif
1734 #ifdef CONFIG_RDMA
1735                           { .ival = "rdma",
1736                             .help = "RDMA IO engine",
1737                           },
1738 #endif
1739 #ifdef CONFIG_FUSION_AW
1740                           { .ival = "fusion-aw-sync",
1741                             .help = "Fusion-io atomic write engine",
1742                           },
1743 #endif
1744 #ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
1745                           { .ival = "e4defrag",
1746                             .help = "ext4 defrag engine",
1747                           },
1748 #endif
1749 #ifdef CONFIG_LINUX_FALLOCATE
1750                           { .ival = "falloc",
1751                             .help = "fallocate() file based engine",
1752                           },
1753 #endif
1754 #ifdef CONFIG_GFAPI
1755                           { .ival = "gfapi",
1756                             .help = "Glusterfs libgfapi(sync) based engine"
1757                           },
1758                           { .ival = "gfapi_async",
1759                             .help = "Glusterfs libgfapi(async) based engine"
1760                           },
1761 #endif
1762 #ifdef CONFIG_LIBHDFS
1763                           { .ival = "libhdfs",
1764                             .help = "Hadoop Distributed Filesystem (HDFS) engine"
1765                           },
1766 #endif
1767 #ifdef CONFIG_PMEMBLK
1768                           { .ival = "pmemblk",
1769                             .help = "NVML libpmemblk based IO engine",
1770                           },
1771
1772 #endif
1773                           { .ival = "external",
1774                             .help = "Load external engine (append name)",
1775                           },
1776                 },
1777         },
1778         {
1779                 .name   = "iodepth",
1780                 .lname  = "IO Depth",
1781                 .type   = FIO_OPT_INT,
1782                 .off1   = offsetof(struct thread_options, iodepth),
1783                 .help   = "Number of IO buffers to keep in flight",
1784                 .minval = 1,
1785                 .interval = 1,
1786                 .def    = "1",
1787                 .category = FIO_OPT_C_IO,
1788                 .group  = FIO_OPT_G_IO_BASIC,
1789         },
1790         {
1791                 .name   = "iodepth_batch",
1792                 .lname  = "IO Depth batch",
1793                 .alias  = "iodepth_batch_submit",
1794                 .type   = FIO_OPT_INT,
1795                 .off1   = offsetof(struct thread_options, iodepth_batch),
1796                 .help   = "Number of IO buffers to submit in one go",
1797                 .parent = "iodepth",
1798                 .hide   = 1,
1799                 .interval = 1,
1800                 .def    = "1",
1801                 .category = FIO_OPT_C_IO,
1802                 .group  = FIO_OPT_G_IO_BASIC,
1803         },
1804         {
1805                 .name   = "iodepth_batch_complete_min",
1806                 .lname  = "Min IO depth batch complete",
1807                 .alias  = "iodepth_batch_complete",
1808                 .type   = FIO_OPT_INT,
1809                 .off1   = offsetof(struct thread_options, iodepth_batch_complete_min),
1810                 .help   = "Min number of IO buffers to retrieve in one go",
1811                 .parent = "iodepth",
1812                 .hide   = 1,
1813                 .minval = 0,
1814                 .interval = 1,
1815                 .def    = "1",
1816                 .category = FIO_OPT_C_IO,
1817                 .group  = FIO_OPT_G_IO_BASIC,
1818         },
1819         {
1820                 .name   = "iodepth_batch_complete_max",
1821                 .lname  = "Max IO depth batch complete",
1822                 .type   = FIO_OPT_INT,
1823                 .off1   = offsetof(struct thread_options, iodepth_batch_complete_max),
1824                 .help   = "Max number of IO buffers to retrieve in one go",
1825                 .parent = "iodepth",
1826                 .hide   = 1,
1827                 .minval = 0,
1828                 .interval = 1,
1829                 .category = FIO_OPT_C_IO,
1830                 .group  = FIO_OPT_G_IO_BASIC,
1831         },
1832         {
1833                 .name   = "iodepth_low",
1834                 .lname  = "IO Depth batch low",
1835                 .type   = FIO_OPT_INT,
1836                 .off1   = offsetof(struct thread_options, iodepth_low),
1837                 .help   = "Low water mark for queuing depth",
1838                 .parent = "iodepth",
1839                 .hide   = 1,
1840                 .interval = 1,
1841                 .category = FIO_OPT_C_IO,
1842                 .group  = FIO_OPT_G_IO_BASIC,
1843         },
1844         {
1845                 .name   = "io_submit_mode",
1846                 .lname  = "IO submit mode",
1847                 .type   = FIO_OPT_STR,
1848                 .off1   = offsetof(struct thread_options, io_submit_mode),
1849                 .help   = "How IO submissions and completions are done",
1850                 .def    = "inline",
1851                 .category = FIO_OPT_C_IO,
1852                 .group  = FIO_OPT_G_IO_BASIC,
1853                 .posval = {
1854                           { .ival = "inline",
1855                             .oval = IO_MODE_INLINE,
1856                             .help = "Submit and complete IO inline",
1857                           },
1858                           { .ival = "offload",
1859                             .oval = IO_MODE_OFFLOAD,
1860                             .help = "Offload submit and complete to threads",
1861                           },
1862                 },
1863         },
1864         {
1865                 .name   = "size",
1866                 .lname  = "Size",
1867                 .type   = FIO_OPT_STR_VAL,
1868                 .cb     = str_size_cb,
1869                 .off1   = offsetof(struct thread_options, size),
1870                 .help   = "Total size of device or files",
1871                 .interval = 1024 * 1024,
1872                 .category = FIO_OPT_C_IO,
1873                 .group  = FIO_OPT_G_INVALID,
1874         },
1875         {
1876                 .name   = "io_size",
1877                 .alias  = "io_limit",
1878                 .lname  = "IO Size",
1879                 .type   = FIO_OPT_STR_VAL,
1880                 .off1   = offsetof(struct thread_options, io_limit),
1881                 .interval = 1024 * 1024,
1882                 .category = FIO_OPT_C_IO,
1883                 .group  = FIO_OPT_G_INVALID,
1884         },
1885         {
1886                 .name   = "fill_device",
1887                 .lname  = "Fill device",
1888                 .alias  = "fill_fs",
1889                 .type   = FIO_OPT_BOOL,
1890                 .off1   = offsetof(struct thread_options, fill_device),
1891                 .help   = "Write until an ENOSPC error occurs",
1892                 .def    = "0",
1893                 .category = FIO_OPT_C_FILE,
1894                 .group  = FIO_OPT_G_INVALID,
1895         },
1896         {
1897                 .name   = "filesize",
1898                 .lname  = "File size",
1899                 .type   = FIO_OPT_STR_VAL,
1900                 .off1   = offsetof(struct thread_options, file_size_low),
1901                 .off2   = offsetof(struct thread_options, file_size_high),
1902                 .minval = 1,
1903                 .help   = "Size of individual files",
1904                 .interval = 1024 * 1024,
1905                 .category = FIO_OPT_C_FILE,
1906                 .group  = FIO_OPT_G_INVALID,
1907         },
1908         {
1909                 .name   = "file_append",
1910                 .lname  = "File append",
1911                 .type   = FIO_OPT_BOOL,
1912                 .off1   = offsetof(struct thread_options, file_append),
1913                 .help   = "IO will start at the end of the file(s)",
1914                 .def    = "0",
1915                 .category = FIO_OPT_C_FILE,
1916                 .group  = FIO_OPT_G_INVALID,
1917         },
1918         {
1919                 .name   = "offset",
1920                 .lname  = "IO offset",
1921                 .alias  = "fileoffset",
1922                 .type   = FIO_OPT_STR_VAL,
1923                 .off1   = offsetof(struct thread_options, start_offset),
1924                 .help   = "Start IO from this offset",
1925                 .def    = "0",
1926                 .interval = 1024 * 1024,
1927                 .category = FIO_OPT_C_IO,
1928                 .group  = FIO_OPT_G_INVALID,
1929         },
1930         {
1931                 .name   = "offset_increment",
1932                 .lname  = "IO offset increment",
1933                 .type   = FIO_OPT_STR_VAL,
1934                 .off1   = offsetof(struct thread_options, offset_increment),
1935                 .help   = "What is the increment from one offset to the next",
1936                 .parent = "offset",
1937                 .hide   = 1,
1938                 .def    = "0",
1939                 .interval = 1024 * 1024,
1940                 .category = FIO_OPT_C_IO,
1941                 .group  = FIO_OPT_G_INVALID,
1942         },
1943         {
1944                 .name   = "number_ios",
1945                 .lname  = "Number of IOs to perform",
1946                 .type   = FIO_OPT_STR_VAL,
1947                 .off1   = offsetof(struct thread_options, number_ios),
1948                 .help   = "Force job completion after this number of IOs",
1949                 .def    = "0",
1950                 .category = FIO_OPT_C_IO,
1951                 .group  = FIO_OPT_G_INVALID,
1952         },
1953         {
1954                 .name   = "bs",
1955                 .lname  = "Block size",
1956                 .alias  = "blocksize",
1957                 .type   = FIO_OPT_INT,
1958                 .off1   = offsetof(struct thread_options, bs[DDIR_READ]),
1959                 .off2   = offsetof(struct thread_options, bs[DDIR_WRITE]),
1960                 .off3   = offsetof(struct thread_options, bs[DDIR_TRIM]),
1961                 .minval = 1,
1962                 .help   = "Block size unit",
1963                 .def    = "4k",
1964                 .parent = "rw",
1965                 .hide   = 1,
1966                 .interval = 512,
1967                 .category = FIO_OPT_C_IO,
1968                 .group  = FIO_OPT_G_INVALID,
1969         },
1970         {
1971                 .name   = "ba",
1972                 .lname  = "Block size align",
1973                 .alias  = "blockalign",
1974                 .type   = FIO_OPT_INT,
1975                 .off1   = offsetof(struct thread_options, ba[DDIR_READ]),
1976                 .off2   = offsetof(struct thread_options, ba[DDIR_WRITE]),
1977                 .off3   = offsetof(struct thread_options, ba[DDIR_TRIM]),
1978                 .minval = 1,
1979                 .help   = "IO block offset alignment",
1980                 .parent = "rw",
1981                 .hide   = 1,
1982                 .interval = 512,
1983                 .category = FIO_OPT_C_IO,
1984                 .group  = FIO_OPT_G_INVALID,
1985         },
1986         {
1987                 .name   = "bsrange",
1988                 .lname  = "Block size range",
1989                 .alias  = "blocksize_range",
1990                 .type   = FIO_OPT_RANGE,
1991                 .off1   = offsetof(struct thread_options, min_bs[DDIR_READ]),
1992                 .off2   = offsetof(struct thread_options, max_bs[DDIR_READ]),
1993                 .off3   = offsetof(struct thread_options, min_bs[DDIR_WRITE]),
1994                 .off4   = offsetof(struct thread_options, max_bs[DDIR_WRITE]),
1995                 .off5   = offsetof(struct thread_options, min_bs[DDIR_TRIM]),
1996                 .off6   = offsetof(struct thread_options, max_bs[DDIR_TRIM]),
1997                 .minval = 1,
1998                 .help   = "Set block size range (in more detail than bs)",
1999                 .parent = "rw",
2000                 .hide   = 1,
2001                 .interval = 4096,
2002                 .category = FIO_OPT_C_IO,
2003                 .group  = FIO_OPT_G_INVALID,
2004         },
2005         {
2006                 .name   = "bssplit",
2007                 .lname  = "Block size split",
2008                 .type   = FIO_OPT_STR,
2009                 .cb     = str_bssplit_cb,
2010                 .off1   = offsetof(struct thread_options, bssplit),
2011                 .help   = "Set a specific mix of block sizes",
2012                 .parent = "rw",
2013                 .hide   = 1,
2014                 .category = FIO_OPT_C_IO,
2015                 .group  = FIO_OPT_G_INVALID,
2016         },
2017         {
2018                 .name   = "bs_unaligned",
2019                 .lname  = "Block size unaligned",
2020                 .alias  = "blocksize_unaligned",
2021                 .type   = FIO_OPT_STR_SET,
2022                 .off1   = offsetof(struct thread_options, bs_unaligned),
2023                 .help   = "Don't sector align IO buffer sizes",
2024                 .parent = "rw",
2025                 .hide   = 1,
2026                 .category = FIO_OPT_C_IO,
2027                 .group  = FIO_OPT_G_INVALID,
2028         },
2029         {
2030                 .name   = "bs_is_seq_rand",
2031                 .lname  = "Block size division is seq/random (not read/write)",
2032                 .type   = FIO_OPT_BOOL,
2033                 .off1   = offsetof(struct thread_options, bs_is_seq_rand),
2034                 .help   = "Consider any blocksize setting to be sequential,random",
2035                 .def    = "0",
2036                 .parent = "blocksize",
2037                 .category = FIO_OPT_C_IO,
2038                 .group  = FIO_OPT_G_INVALID,
2039         },
2040         {
2041                 .name   = "randrepeat",
2042                 .lname  = "Random repeatable",
2043                 .type   = FIO_OPT_BOOL,
2044                 .off1   = offsetof(struct thread_options, rand_repeatable),
2045                 .help   = "Use repeatable random IO pattern",
2046                 .def    = "1",
2047                 .parent = "rw",
2048                 .hide   = 1,
2049                 .category = FIO_OPT_C_IO,
2050                 .group  = FIO_OPT_G_RANDOM,
2051         },
2052         {
2053                 .name   = "randseed",
2054                 .lname  = "The random generator seed",
2055                 .type   = FIO_OPT_STR_VAL,
2056                 .off1   = offsetof(struct thread_options, rand_seed),
2057                 .help   = "Set the random generator seed value",
2058                 .def    = "0x89",
2059                 .parent = "rw",
2060                 .category = FIO_OPT_C_IO,
2061                 .group  = FIO_OPT_G_RANDOM,
2062         },
2063         {
2064                 .name   = "use_os_rand",
2065                 .lname  = "Use OS random",
2066                 .type   = FIO_OPT_DEPRECATED,
2067                 .off1   = offsetof(struct thread_options, dep_use_os_rand),
2068                 .category = FIO_OPT_C_IO,
2069                 .group  = FIO_OPT_G_RANDOM,
2070         },
2071         {
2072                 .name   = "norandommap",
2073                 .lname  = "No randommap",
2074                 .type   = FIO_OPT_STR_SET,
2075                 .off1   = offsetof(struct thread_options, norandommap),
2076                 .help   = "Accept potential duplicate random blocks",
2077                 .parent = "rw",
2078                 .hide   = 1,
2079                 .hide_on_set = 1,
2080                 .category = FIO_OPT_C_IO,
2081                 .group  = FIO_OPT_G_RANDOM,
2082         },
2083         {
2084                 .name   = "softrandommap",
2085                 .lname  = "Soft randommap",
2086                 .type   = FIO_OPT_BOOL,
2087                 .off1   = offsetof(struct thread_options, softrandommap),
2088                 .help   = "Set norandommap if randommap allocation fails",
2089                 .parent = "norandommap",
2090                 .hide   = 1,
2091                 .def    = "0",
2092                 .category = FIO_OPT_C_IO,
2093                 .group  = FIO_OPT_G_RANDOM,
2094         },
2095         {
2096                 .name   = "random_generator",
2097                 .lname  = "Random Generator",
2098                 .type   = FIO_OPT_STR,
2099                 .off1   = offsetof(struct thread_options, random_generator),
2100                 .help   = "Type of random number generator to use",
2101                 .def    = "tausworthe",
2102                 .posval = {
2103                           { .ival = "tausworthe",
2104                             .oval = FIO_RAND_GEN_TAUSWORTHE,
2105                             .help = "Strong Tausworthe generator",
2106                           },
2107                           { .ival = "lfsr",
2108                             .oval = FIO_RAND_GEN_LFSR,
2109                             .help = "Variable length LFSR",
2110                           },
2111                           {
2112                             .ival = "tausworthe64",
2113                             .oval = FIO_RAND_GEN_TAUSWORTHE64,
2114                             .help = "64-bit Tausworthe variant",
2115                           },
2116                 },
2117                 .category = FIO_OPT_C_IO,
2118                 .group  = FIO_OPT_G_RANDOM,
2119         },
2120         {
2121                 .name   = "random_distribution",
2122                 .lname  = "Random Distribution",
2123                 .type   = FIO_OPT_STR,
2124                 .off1   = offsetof(struct thread_options, random_distribution),
2125                 .cb     = str_random_distribution_cb,
2126                 .help   = "Random offset distribution generator",
2127                 .def    = "random",
2128                 .posval = {
2129                           { .ival = "random",
2130                             .oval = FIO_RAND_DIST_RANDOM,
2131                             .help = "Completely random",
2132                           },
2133                           { .ival = "zipf",
2134                             .oval = FIO_RAND_DIST_ZIPF,
2135                             .help = "Zipf distribution",
2136                           },
2137                           { .ival = "pareto",
2138                             .oval = FIO_RAND_DIST_PARETO,
2139                             .help = "Pareto distribution",
2140                           },
2141                           { .ival = "normal",
2142                             .oval = FIO_RAND_DIST_GAUSS,
2143                             .help = "Normal (Gaussian) distribution",
2144                           },
2145                           { .ival = "zoned",
2146                             .oval = FIO_RAND_DIST_ZONED,
2147                             .help = "Zoned random distribution",
2148                           },
2149
2150                 },
2151                 .category = FIO_OPT_C_IO,
2152                 .group  = FIO_OPT_G_RANDOM,
2153         },
2154         {
2155                 .name   = "percentage_random",
2156                 .lname  = "Percentage Random",
2157                 .type   = FIO_OPT_INT,
2158                 .off1   = offsetof(struct thread_options, perc_rand[DDIR_READ]),
2159                 .off2   = offsetof(struct thread_options, perc_rand[DDIR_WRITE]),
2160                 .off3   = offsetof(struct thread_options, perc_rand[DDIR_TRIM]),
2161                 .maxval = 100,
2162                 .help   = "Percentage of seq/random mix that should be random",
2163                 .def    = "100,100,100",
2164                 .interval = 5,
2165                 .inverse = "percentage_sequential",
2166                 .category = FIO_OPT_C_IO,
2167                 .group  = FIO_OPT_G_RANDOM,
2168         },
2169         {
2170                 .name   = "percentage_sequential",
2171                 .lname  = "Percentage Sequential",
2172                 .type   = FIO_OPT_DEPRECATED,
2173                 .category = FIO_OPT_C_IO,
2174                 .group  = FIO_OPT_G_RANDOM,
2175         },
2176         {
2177                 .name   = "allrandrepeat",
2178                 .lname  = "All Random Repeat",
2179                 .type   = FIO_OPT_BOOL,
2180                 .off1   = offsetof(struct thread_options, allrand_repeatable),
2181                 .help   = "Use repeatable random numbers for everything",
2182                 .def    = "0",
2183                 .category = FIO_OPT_C_IO,
2184                 .group  = FIO_OPT_G_RANDOM,
2185         },
2186         {
2187                 .name   = "nrfiles",
2188                 .lname  = "Number of files",
2189                 .alias  = "nr_files",
2190                 .type   = FIO_OPT_INT,
2191                 .off1   = offsetof(struct thread_options, nr_files),
2192                 .help   = "Split job workload between this number of files",
2193                 .def    = "1",
2194                 .interval = 1,
2195                 .category = FIO_OPT_C_FILE,
2196                 .group  = FIO_OPT_G_INVALID,
2197         },
2198         {
2199                 .name   = "openfiles",
2200                 .lname  = "Number of open files",
2201                 .type   = FIO_OPT_INT,
2202                 .off1   = offsetof(struct thread_options, open_files),
2203                 .help   = "Number of files to keep open at the same time",
2204                 .category = FIO_OPT_C_FILE,
2205                 .group  = FIO_OPT_G_INVALID,
2206         },
2207         {
2208                 .name   = "file_service_type",
2209                 .lname  = "File service type",
2210                 .type   = FIO_OPT_STR,
2211                 .cb     = str_fst_cb,
2212                 .off1   = offsetof(struct thread_options, file_service_type),
2213                 .help   = "How to select which file to service next",
2214                 .def    = "roundrobin",
2215                 .category = FIO_OPT_C_FILE,
2216                 .group  = FIO_OPT_G_INVALID,
2217                 .posval = {
2218                           { .ival = "random",
2219                             .oval = FIO_FSERVICE_RANDOM,
2220                             .help = "Choose a file at random (uniform)",
2221                           },
2222                           { .ival = "zipf",
2223                             .oval = FIO_FSERVICE_ZIPF,
2224                             .help = "Zipf randomized",
2225                           },
2226                           { .ival = "pareto",
2227                             .oval = FIO_FSERVICE_PARETO,
2228                             .help = "Pareto randomized",
2229                           },
2230                           { .ival = "gauss",
2231                             .oval = FIO_FSERVICE_GAUSS,
2232                             .help = "Normal (gaussian) distribution",
2233                           },
2234                           { .ival = "roundrobin",
2235                             .oval = FIO_FSERVICE_RR,
2236                             .help = "Round robin select files",
2237                           },
2238                           { .ival = "sequential",
2239                             .oval = FIO_FSERVICE_SEQ,
2240                             .help = "Finish one file before moving to the next",
2241                           },
2242                 },
2243                 .parent = "nrfiles",
2244                 .hide   = 1,
2245         },
2246 #ifdef CONFIG_POSIX_FALLOCATE
2247         {
2248                 .name   = "fallocate",
2249                 .lname  = "Fallocate",
2250                 .type   = FIO_OPT_STR,
2251                 .off1   = offsetof(struct thread_options, fallocate_mode),
2252                 .help   = "Whether pre-allocation is performed when laying out files",
2253                 .def    = "posix",
2254                 .category = FIO_OPT_C_FILE,
2255                 .group  = FIO_OPT_G_INVALID,
2256                 .posval = {
2257                           { .ival = "none",
2258                             .oval = FIO_FALLOCATE_NONE,
2259                             .help = "Do not pre-allocate space",
2260                           },
2261                           { .ival = "posix",
2262                             .oval = FIO_FALLOCATE_POSIX,
2263                             .help = "Use posix_fallocate()",
2264                           },
2265 #ifdef CONFIG_LINUX_FALLOCATE
2266                           { .ival = "keep",
2267                             .oval = FIO_FALLOCATE_KEEP_SIZE,
2268                             .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
2269                           },
2270 #endif
2271                           /* Compatibility with former boolean values */
2272                           { .ival = "0",
2273                             .oval = FIO_FALLOCATE_NONE,
2274                             .help = "Alias for 'none'",
2275                           },
2276                           { .ival = "1",
2277                             .oval = FIO_FALLOCATE_POSIX,
2278                             .help = "Alias for 'posix'",
2279                           },
2280                 },
2281         },
2282 #else   /* CONFIG_POSIX_FALLOCATE */
2283         {
2284                 .name   = "fallocate",
2285                 .lname  = "Fallocate",
2286                 .type   = FIO_OPT_UNSUPPORTED,
2287                 .help   = "Your platform does not support fallocate",
2288         },
2289 #endif /* CONFIG_POSIX_FALLOCATE */
2290         {
2291                 .name   = "fadvise_hint",
2292                 .lname  = "Fadvise hint",
2293                 .type   = FIO_OPT_BOOL,
2294                 .off1   = offsetof(struct thread_options, fadvise_hint),
2295                 .help   = "Use fadvise() to advise the kernel on IO pattern",
2296                 .def    = "1",
2297                 .category = FIO_OPT_C_FILE,
2298                 .group  = FIO_OPT_G_INVALID,
2299         },
2300 #ifdef FIO_HAVE_STREAMID
2301         {
2302                 .name   = "fadvise_stream",
2303                 .lname  = "Fadvise stream",
2304                 .type   = FIO_OPT_INT,
2305                 .off1   = offsetof(struct thread_options, fadvise_stream),
2306                 .help   = "Use fadvise() to set stream ID",
2307                 .category = FIO_OPT_C_FILE,
2308                 .group  = FIO_OPT_G_INVALID,
2309         },
2310 #else
2311         {
2312                 .name   = "fadvise_stream",
2313                 .lname  = "Fadvise stream",
2314                 .type   = FIO_OPT_UNSUPPORTED,
2315                 .help   = "Your platform does not support fadvise stream ID",
2316         },
2317 #endif
2318         {
2319                 .name   = "fsync",
2320                 .lname  = "Fsync",
2321                 .type   = FIO_OPT_INT,
2322                 .off1   = offsetof(struct thread_options, fsync_blocks),
2323                 .help   = "Issue fsync for writes every given number of blocks",
2324                 .def    = "0",
2325                 .interval = 1,
2326                 .category = FIO_OPT_C_FILE,
2327                 .group  = FIO_OPT_G_INVALID,
2328         },
2329         {
2330                 .name   = "fdatasync",
2331                 .lname  = "Fdatasync",
2332                 .type   = FIO_OPT_INT,
2333                 .off1   = offsetof(struct thread_options, fdatasync_blocks),
2334                 .help   = "Issue fdatasync for writes every given number of blocks",
2335                 .def    = "0",
2336                 .interval = 1,
2337                 .category = FIO_OPT_C_FILE,
2338                 .group  = FIO_OPT_G_INVALID,
2339         },
2340         {
2341                 .name   = "write_barrier",
2342                 .lname  = "Write barrier",
2343                 .type   = FIO_OPT_INT,
2344                 .off1   = offsetof(struct thread_options, barrier_blocks),
2345                 .help   = "Make every Nth write a barrier write",
2346                 .def    = "0",
2347                 .interval = 1,
2348                 .category = FIO_OPT_C_IO,
2349                 .group  = FIO_OPT_G_INVALID,
2350         },
2351 #ifdef CONFIG_SYNC_FILE_RANGE
2352         {
2353                 .name   = "sync_file_range",
2354                 .lname  = "Sync file range",
2355                 .posval = {
2356                           { .ival = "wait_before",
2357                             .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
2358                             .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
2359                             .orval  = 1,
2360                           },
2361                           { .ival = "write",
2362                             .oval = SYNC_FILE_RANGE_WRITE,
2363                             .help = "SYNC_FILE_RANGE_WRITE",
2364                             .orval  = 1,
2365                           },
2366                           {
2367                             .ival = "wait_after",
2368                             .oval = SYNC_FILE_RANGE_WAIT_AFTER,
2369                             .help = "SYNC_FILE_RANGE_WAIT_AFTER",
2370                             .orval  = 1,
2371                           },
2372                 },
2373                 .type   = FIO_OPT_STR_MULTI,
2374                 .cb     = str_sfr_cb,
2375                 .off1   = offsetof(struct thread_options, sync_file_range),
2376                 .help   = "Use sync_file_range()",
2377                 .category = FIO_OPT_C_FILE,
2378                 .group  = FIO_OPT_G_INVALID,
2379         },
2380 #else
2381         {
2382                 .name   = "sync_file_range",
2383                 .lname  = "Sync file range",
2384                 .type   = FIO_OPT_UNSUPPORTED,
2385                 .help   = "Your platform does not support sync_file_range",
2386         },
2387 #endif
2388         {
2389                 .name   = "direct",
2390                 .lname  = "Direct I/O",
2391                 .type   = FIO_OPT_BOOL,
2392                 .off1   = offsetof(struct thread_options, odirect),
2393                 .help   = "Use O_DIRECT IO (negates buffered)",
2394                 .def    = "0",
2395                 .inverse = "buffered",
2396                 .category = FIO_OPT_C_IO,
2397                 .group  = FIO_OPT_G_IO_TYPE,
2398         },
2399         {
2400                 .name   = "atomic",
2401                 .lname  = "Atomic I/O",
2402                 .type   = FIO_OPT_BOOL,
2403                 .off1   = offsetof(struct thread_options, oatomic),
2404                 .help   = "Use Atomic IO with O_DIRECT (implies O_DIRECT)",
2405                 .def    = "0",
2406                 .category = FIO_OPT_C_IO,
2407                 .group  = FIO_OPT_G_IO_TYPE,
2408         },
2409         {
2410                 .name   = "buffered",
2411                 .lname  = "Buffered I/O",
2412                 .type   = FIO_OPT_BOOL,
2413                 .off1   = offsetof(struct thread_options, odirect),
2414                 .neg    = 1,
2415                 .help   = "Use buffered IO (negates direct)",
2416                 .def    = "1",
2417                 .inverse = "direct",
2418                 .category = FIO_OPT_C_IO,
2419                 .group  = FIO_OPT_G_IO_TYPE,
2420         },
2421         {
2422                 .name   = "overwrite",
2423                 .lname  = "Overwrite",
2424                 .type   = FIO_OPT_BOOL,
2425                 .off1   = offsetof(struct thread_options, overwrite),
2426                 .help   = "When writing, set whether to overwrite current data",
2427                 .def    = "0",
2428                 .category = FIO_OPT_C_FILE,
2429                 .group  = FIO_OPT_G_INVALID,
2430         },
2431         {
2432                 .name   = "loops",
2433                 .lname  = "Loops",
2434                 .type   = FIO_OPT_INT,
2435                 .off1   = offsetof(struct thread_options, loops),
2436                 .help   = "Number of times to run the job",
2437                 .def    = "1",
2438                 .interval = 1,
2439                 .category = FIO_OPT_C_GENERAL,
2440                 .group  = FIO_OPT_G_RUNTIME,
2441         },
2442         {
2443                 .name   = "numjobs",
2444                 .lname  = "Number of jobs",
2445                 .type   = FIO_OPT_INT,
2446                 .off1   = offsetof(struct thread_options, numjobs),
2447                 .help   = "Duplicate this job this many times",
2448                 .def    = "1",
2449                 .interval = 1,
2450                 .category = FIO_OPT_C_GENERAL,
2451                 .group  = FIO_OPT_G_RUNTIME,
2452         },
2453         {
2454                 .name   = "startdelay",
2455                 .lname  = "Start delay",
2456                 .type   = FIO_OPT_STR_VAL_TIME,
2457                 .off1   = offsetof(struct thread_options, start_delay),
2458                 .off2   = offsetof(struct thread_options, start_delay_high),
2459                 .help   = "Only start job when this period has passed",
2460                 .def    = "0",
2461                 .is_seconds = 1,
2462                 .is_time = 1,
2463                 .category = FIO_OPT_C_GENERAL,
2464                 .group  = FIO_OPT_G_RUNTIME,
2465         },
2466         {
2467                 .name   = "runtime",
2468                 .lname  = "Runtime",
2469                 .alias  = "timeout",
2470                 .type   = FIO_OPT_STR_VAL_TIME,
2471                 .off1   = offsetof(struct thread_options, timeout),
2472                 .help   = "Stop workload when this amount of time has passed",
2473                 .def    = "0",
2474                 .is_seconds = 1,
2475                 .is_time = 1,
2476                 .category = FIO_OPT_C_GENERAL,
2477                 .group  = FIO_OPT_G_RUNTIME,
2478         },
2479         {
2480                 .name   = "time_based",
2481                 .lname  = "Time based",
2482                 .type   = FIO_OPT_STR_SET,
2483                 .off1   = offsetof(struct thread_options, time_based),
2484                 .help   = "Keep running until runtime/timeout is met",
2485                 .category = FIO_OPT_C_GENERAL,
2486                 .group  = FIO_OPT_G_RUNTIME,
2487         },
2488         {
2489                 .name   = "verify_only",
2490                 .lname  = "Verify only",
2491                 .type   = FIO_OPT_STR_SET,
2492                 .off1   = offsetof(struct thread_options, verify_only),
2493                 .help   = "Verifies previously written data is still valid",
2494                 .category = FIO_OPT_C_GENERAL,
2495                 .group  = FIO_OPT_G_RUNTIME,
2496         },
2497         {
2498                 .name   = "ramp_time",
2499                 .lname  = "Ramp time",
2500                 .type   = FIO_OPT_STR_VAL_TIME,
2501                 .off1   = offsetof(struct thread_options, ramp_time),
2502                 .help   = "Ramp up time before measuring performance",
2503                 .is_seconds = 1,
2504                 .is_time = 1,
2505                 .category = FIO_OPT_C_GENERAL,
2506                 .group  = FIO_OPT_G_RUNTIME,
2507         },
2508         {
2509                 .name   = "clocksource",
2510                 .lname  = "Clock source",
2511                 .type   = FIO_OPT_STR,
2512                 .cb     = fio_clock_source_cb,
2513                 .off1   = offsetof(struct thread_options, clocksource),
2514                 .help   = "What type of timing source to use",
2515                 .category = FIO_OPT_C_GENERAL,
2516                 .group  = FIO_OPT_G_CLOCK,
2517                 .posval = {
2518 #ifdef CONFIG_GETTIMEOFDAY
2519                           { .ival = "gettimeofday",
2520                             .oval = CS_GTOD,
2521                             .help = "Use gettimeofday(2) for timing",
2522                           },
2523 #endif
2524 #ifdef CONFIG_CLOCK_GETTIME
2525                           { .ival = "clock_gettime",
2526                             .oval = CS_CGETTIME,
2527                             .help = "Use clock_gettime(2) for timing",
2528                           },
2529 #endif
2530 #ifdef ARCH_HAVE_CPU_CLOCK
2531                           { .ival = "cpu",
2532                             .oval = CS_CPUCLOCK,
2533                             .help = "Use CPU private clock",
2534                           },
2535 #endif
2536                 },
2537         },
2538         {
2539                 .name   = "mem",
2540                 .alias  = "iomem",
2541                 .lname  = "I/O Memory",
2542                 .type   = FIO_OPT_STR,
2543                 .cb     = str_mem_cb,
2544                 .off1   = offsetof(struct thread_options, mem_type),
2545                 .help   = "Backing type for IO buffers",
2546                 .def    = "malloc",
2547                 .category = FIO_OPT_C_IO,
2548                 .group  = FIO_OPT_G_INVALID,
2549                 .posval = {
2550                           { .ival = "malloc",
2551                             .oval = MEM_MALLOC,
2552                             .help = "Use malloc(3) for IO buffers",
2553                           },
2554 #ifndef CONFIG_NO_SHM
2555                           { .ival = "shm",
2556                             .oval = MEM_SHM,
2557                             .help = "Use shared memory segments for IO buffers",
2558                           },
2559 #ifdef FIO_HAVE_HUGETLB
2560                           { .ival = "shmhuge",
2561                             .oval = MEM_SHMHUGE,
2562                             .help = "Like shm, but use huge pages",
2563                           },
2564 #endif
2565 #endif
2566                           { .ival = "mmap",
2567                             .oval = MEM_MMAP,
2568                             .help = "Use mmap(2) (file or anon) for IO buffers",
2569                           },
2570                           { .ival = "mmapshared",
2571                             .oval = MEM_MMAPSHARED,
2572                             .help = "Like mmap, but use the shared flag",
2573                           },
2574 #ifdef FIO_HAVE_HUGETLB
2575                           { .ival = "mmaphuge",
2576                             .oval = MEM_MMAPHUGE,
2577                             .help = "Like mmap, but use huge pages",
2578                           },
2579 #endif
2580                   },
2581         },
2582         {
2583                 .name   = "iomem_align",
2584                 .alias  = "mem_align",
2585                 .lname  = "I/O memory alignment",
2586                 .type   = FIO_OPT_INT,
2587                 .off1   = offsetof(struct thread_options, mem_align),
2588                 .minval = 0,
2589                 .help   = "IO memory buffer offset alignment",
2590                 .def    = "0",
2591                 .parent = "iomem",
2592                 .hide   = 1,
2593                 .category = FIO_OPT_C_IO,
2594                 .group  = FIO_OPT_G_INVALID,
2595         },
2596         {
2597                 .name   = "verify",
2598                 .lname  = "Verify",
2599                 .type   = FIO_OPT_STR,
2600                 .off1   = offsetof(struct thread_options, verify),
2601                 .help   = "Verify data written",
2602                 .def    = "0",
2603                 .category = FIO_OPT_C_IO,
2604                 .group  = FIO_OPT_G_VERIFY,
2605                 .posval = {
2606                           { .ival = "0",
2607                             .oval = VERIFY_NONE,
2608                             .help = "Don't do IO verification",
2609                           },
2610                           { .ival = "md5",
2611                             .oval = VERIFY_MD5,
2612                             .help = "Use md5 checksums for verification",
2613                           },
2614                           { .ival = "crc64",
2615                             .oval = VERIFY_CRC64,
2616                             .help = "Use crc64 checksums for verification",
2617                           },
2618                           { .ival = "crc32",
2619                             .oval = VERIFY_CRC32,
2620                             .help = "Use crc32 checksums for verification",
2621                           },
2622                           { .ival = "crc32c-intel",
2623                             .oval = VERIFY_CRC32C,
2624                             .help = "Use crc32c checksums for verification (hw assisted, if available)",
2625                           },
2626                           { .ival = "crc32c",
2627                             .oval = VERIFY_CRC32C,
2628                             .help = "Use crc32c checksums for verification (hw assisted, if available)",
2629                           },
2630                           { .ival = "crc16",
2631                             .oval = VERIFY_CRC16,
2632                             .help = "Use crc16 checksums for verification",
2633                           },
2634                           { .ival = "crc7",
2635                             .oval = VERIFY_CRC7,
2636                             .help = "Use crc7 checksums for verification",
2637                           },
2638                           { .ival = "sha1",
2639                             .oval = VERIFY_SHA1,
2640                             .help = "Use sha1 checksums for verification",
2641                           },
2642                           { .ival = "sha256",
2643                             .oval = VERIFY_SHA256,
2644                             .help = "Use sha256 checksums for verification",
2645                           },
2646                           { .ival = "sha512",
2647                             .oval = VERIFY_SHA512,
2648                             .help = "Use sha512 checksums for verification",
2649                           },
2650                           { .ival = "xxhash",
2651                             .oval = VERIFY_XXHASH,
2652                             .help = "Use xxhash checksums for verification",
2653                           },
2654                           /* Meta information was included into verify_header,
2655                            * 'meta' verification is implied by default. */
2656                           { .ival = "meta",
2657                             .oval = VERIFY_HDR_ONLY,
2658                             .help = "Use io information for verification. "
2659                                     "Now is implied by default, thus option is obsolete, "
2660                                     "don't use it",
2661                           },
2662                           { .ival = "pattern",
2663                             .oval = VERIFY_PATTERN_NO_HDR,
2664                             .help = "Verify strict pattern",
2665                           },
2666                           {
2667                             .ival = "null",
2668                             .oval = VERIFY_NULL,
2669                             .help = "Pretend to verify",
2670                           },
2671                 },
2672         },
2673         {
2674                 .name   = "do_verify",
2675                 .lname  = "Perform verify step",
2676                 .type   = FIO_OPT_BOOL,
2677                 .off1   = offsetof(struct thread_options, do_verify),
2678                 .help   = "Run verification stage after write",
2679                 .def    = "1",
2680                 .parent = "verify",
2681                 .hide   = 1,
2682                 .category = FIO_OPT_C_IO,
2683                 .group  = FIO_OPT_G_VERIFY,
2684         },
2685         {
2686                 .name   = "verifysort",
2687                 .lname  = "Verify sort",
2688                 .type   = FIO_OPT_BOOL,
2689                 .off1   = offsetof(struct thread_options, verifysort),
2690                 .help   = "Sort written verify blocks for read back",
2691                 .def    = "1",
2692                 .parent = "verify",
2693                 .hide   = 1,
2694                 .category = FIO_OPT_C_IO,
2695                 .group  = FIO_OPT_G_VERIFY,
2696         },
2697         {
2698                 .name   = "verifysort_nr",
2699                 .lname  = "Verify Sort Nr",
2700                 .type   = FIO_OPT_INT,
2701                 .off1   = offsetof(struct thread_options, verifysort_nr),
2702                 .help   = "Pre-load and sort verify blocks for a read workload",
2703                 .minval = 0,
2704                 .maxval = 131072,
2705                 .def    = "1024",
2706                 .parent = "verify",
2707                 .category = FIO_OPT_C_IO,
2708                 .group  = FIO_OPT_G_VERIFY,
2709         },
2710         {
2711                 .name   = "verify_interval",
2712                 .lname  = "Verify interval",
2713                 .type   = FIO_OPT_INT,
2714                 .off1   = offsetof(struct thread_options, verify_interval),
2715                 .minval = 2 * sizeof(struct verify_header),
2716                 .help   = "Store verify buffer header every N bytes",
2717                 .parent = "verify",
2718                 .hide   = 1,
2719                 .interval = 2 * sizeof(struct verify_header),
2720                 .category = FIO_OPT_C_IO,
2721                 .group  = FIO_OPT_G_VERIFY,
2722         },
2723         {
2724                 .name   = "verify_offset",
2725                 .lname  = "Verify offset",
2726                 .type   = FIO_OPT_INT,
2727                 .help   = "Offset verify header location by N bytes",
2728                 .off1   = offsetof(struct thread_options, verify_offset),
2729                 .minval = sizeof(struct verify_header),
2730                 .parent = "verify",
2731                 .hide   = 1,
2732                 .category = FIO_OPT_C_IO,
2733                 .group  = FIO_OPT_G_VERIFY,
2734         },
2735         {
2736                 .name   = "verify_pattern",
2737                 .lname  = "Verify pattern",
2738                 .type   = FIO_OPT_STR,
2739                 .cb     = str_verify_pattern_cb,
2740                 .off1   = offsetof(struct thread_options, verify_pattern),
2741                 .help   = "Fill pattern for IO buffers",
2742                 .parent = "verify",
2743                 .hide   = 1,
2744                 .category = FIO_OPT_C_IO,
2745                 .group  = FIO_OPT_G_VERIFY,
2746         },
2747         {
2748                 .name   = "verify_fatal",
2749                 .lname  = "Verify fatal",
2750                 .type   = FIO_OPT_BOOL,
2751                 .off1   = offsetof(struct thread_options, verify_fatal),
2752                 .def    = "0",
2753                 .help   = "Exit on a single verify failure, don't continue",
2754                 .parent = "verify",
2755                 .hide   = 1,
2756                 .category = FIO_OPT_C_IO,
2757                 .group  = FIO_OPT_G_VERIFY,
2758         },
2759         {
2760                 .name   = "verify_dump",
2761                 .lname  = "Verify dump",
2762                 .type   = FIO_OPT_BOOL,
2763                 .off1   = offsetof(struct thread_options, verify_dump),
2764                 .def    = "0",
2765                 .help   = "Dump contents of good and bad blocks on failure",
2766                 .parent = "verify",
2767                 .hide   = 1,
2768                 .category = FIO_OPT_C_IO,
2769                 .group  = FIO_OPT_G_VERIFY,
2770         },
2771         {
2772                 .name   = "verify_async",
2773                 .lname  = "Verify asynchronously",
2774                 .type   = FIO_OPT_INT,
2775                 .off1   = offsetof(struct thread_options, verify_async),
2776                 .def    = "0",
2777                 .help   = "Number of async verifier threads to use",
2778                 .parent = "verify",
2779                 .hide   = 1,
2780                 .category = FIO_OPT_C_IO,
2781                 .group  = FIO_OPT_G_VERIFY,
2782         },
2783         {
2784                 .name   = "verify_backlog",
2785                 .lname  = "Verify backlog",
2786                 .type   = FIO_OPT_STR_VAL,
2787                 .off1   = offsetof(struct thread_options, verify_backlog),
2788                 .help   = "Verify after this number of blocks are written",
2789                 .parent = "verify",
2790                 .hide   = 1,
2791                 .category = FIO_OPT_C_IO,
2792                 .group  = FIO_OPT_G_VERIFY,
2793         },
2794         {
2795                 .name   = "verify_backlog_batch",
2796                 .lname  = "Verify backlog batch",
2797                 .type   = FIO_OPT_INT,
2798                 .off1   = offsetof(struct thread_options, verify_batch),
2799                 .help   = "Verify this number of IO blocks",
2800                 .parent = "verify",
2801                 .hide   = 1,
2802                 .category = FIO_OPT_C_IO,
2803                 .group  = FIO_OPT_G_VERIFY,
2804         },
2805 #ifdef FIO_HAVE_CPU_AFFINITY
2806         {
2807                 .name   = "verify_async_cpus",
2808                 .lname  = "Async verify CPUs",
2809                 .type   = FIO_OPT_STR,
2810                 .cb     = str_verify_cpus_allowed_cb,
2811                 .off1   = offsetof(struct thread_options, verify_cpumask),
2812                 .help   = "Set CPUs allowed for async verify threads",
2813                 .parent = "verify_async",
2814                 .hide   = 1,
2815                 .category = FIO_OPT_C_IO,
2816                 .group  = FIO_OPT_G_VERIFY,
2817         },
2818 #else
2819         {
2820                 .name   = "verify_async_cpus",
2821                 .lname  = "Async verify CPUs",
2822                 .type   = FIO_OPT_UNSUPPORTED,
2823                 .help   = "Your platform does not support CPU affinities",
2824         },
2825 #endif
2826         {
2827                 .name   = "experimental_verify",
2828                 .lname  = "Experimental Verify",
2829                 .off1   = offsetof(struct thread_options, experimental_verify),
2830                 .type   = FIO_OPT_BOOL,
2831                 .help   = "Enable experimental verification",
2832                 .parent = "verify",
2833                 .category = FIO_OPT_C_IO,
2834                 .group  = FIO_OPT_G_VERIFY,
2835         },
2836         {
2837                 .name   = "verify_state_load",
2838                 .lname  = "Load verify state",
2839                 .off1   = offsetof(struct thread_options, verify_state),
2840                 .type   = FIO_OPT_BOOL,
2841                 .help   = "Load verify termination state",
2842                 .parent = "verify",
2843                 .category = FIO_OPT_C_IO,
2844                 .group  = FIO_OPT_G_VERIFY,
2845         },
2846         {
2847                 .name   = "verify_state_save",
2848                 .lname  = "Save verify state",
2849                 .off1   = offsetof(struct thread_options, verify_state_save),
2850                 .type   = FIO_OPT_BOOL,
2851                 .def    = "1",
2852                 .help   = "Save verify state on termination",
2853                 .parent = "verify",
2854                 .category = FIO_OPT_C_IO,
2855                 .group  = FIO_OPT_G_VERIFY,
2856         },
2857 #ifdef FIO_HAVE_TRIM
2858         {
2859                 .name   = "trim_percentage",
2860                 .lname  = "Trim percentage",
2861                 .type   = FIO_OPT_INT,
2862                 .off1   = offsetof(struct thread_options, trim_percentage),
2863                 .minval = 0,
2864                 .maxval = 100,
2865                 .help   = "Number of verify blocks to discard/trim",
2866                 .parent = "verify",
2867                 .def    = "0",
2868                 .interval = 1,
2869                 .hide   = 1,
2870                 .category = FIO_OPT_C_IO,
2871                 .group  = FIO_OPT_G_TRIM,
2872         },
2873         {
2874                 .name   = "trim_verify_zero",
2875                 .lname  = "Verify trim zero",
2876                 .type   = FIO_OPT_BOOL,
2877                 .help   = "Verify that trim/discarded blocks are returned as zeroes",
2878                 .off1   = offsetof(struct thread_options, trim_zero),
2879                 .parent = "trim_percentage",
2880                 .hide   = 1,
2881                 .def    = "1",
2882                 .category = FIO_OPT_C_IO,
2883                 .group  = FIO_OPT_G_TRIM,
2884         },
2885         {
2886                 .name   = "trim_backlog",
2887                 .lname  = "Trim backlog",
2888                 .type   = FIO_OPT_STR_VAL,
2889                 .off1   = offsetof(struct thread_options, trim_backlog),
2890                 .help   = "Trim after this number of blocks are written",
2891                 .parent = "trim_percentage",
2892                 .hide   = 1,
2893                 .interval = 1,
2894                 .category = FIO_OPT_C_IO,
2895                 .group  = FIO_OPT_G_TRIM,
2896         },
2897         {
2898                 .name   = "trim_backlog_batch",
2899                 .lname  = "Trim backlog batch",
2900                 .type   = FIO_OPT_INT,
2901                 .off1   = offsetof(struct thread_options, trim_batch),
2902                 .help   = "Trim this number of IO blocks",
2903                 .parent = "trim_percentage",
2904                 .hide   = 1,
2905                 .interval = 1,
2906                 .category = FIO_OPT_C_IO,
2907                 .group  = FIO_OPT_G_TRIM,
2908         },
2909 #else
2910         {
2911                 .name   = "trim_percentage",
2912                 .lname  = "Trim percentage",
2913                 .type   = FIO_OPT_UNSUPPORTED,
2914                 .help   = "Fio does not support TRIM on your platform",
2915         },
2916         {
2917                 .name   = "trim_verify_zero",
2918                 .lname  = "Verify trim zero",
2919                 .type   = FIO_OPT_UNSUPPORTED,
2920                 .help   = "Fio does not support TRIM on your platform",
2921         },
2922         {
2923                 .name   = "trim_backlog",
2924                 .lname  = "Trim backlog",
2925                 .type   = FIO_OPT_UNSUPPORTED,
2926                 .help   = "Fio does not support TRIM on your platform",
2927         },
2928         {
2929                 .name   = "trim_backlog_batch",
2930                 .lname  = "Trim backlog batch",
2931                 .type   = FIO_OPT_UNSUPPORTED,
2932                 .help   = "Fio does not support TRIM on your platform",
2933         },
2934 #endif
2935         {
2936                 .name   = "write_iolog",
2937                 .lname  = "Write I/O log",
2938                 .type   = FIO_OPT_STR_STORE,
2939                 .off1   = offsetof(struct thread_options, write_iolog_file),
2940                 .help   = "Store IO pattern to file",
2941                 .category = FIO_OPT_C_IO,
2942                 .group  = FIO_OPT_G_IOLOG,
2943         },
2944         {
2945                 .name   = "read_iolog",
2946                 .lname  = "Read I/O log",
2947                 .type   = FIO_OPT_STR_STORE,
2948                 .off1   = offsetof(struct thread_options, read_iolog_file),
2949                 .help   = "Playback IO pattern from file",
2950                 .category = FIO_OPT_C_IO,
2951                 .group  = FIO_OPT_G_IOLOG,
2952         },
2953         {
2954                 .name   = "replay_no_stall",
2955                 .lname  = "Don't stall on replay",
2956                 .type   = FIO_OPT_BOOL,
2957                 .off1   = offsetof(struct thread_options, no_stall),
2958                 .def    = "0",
2959                 .parent = "read_iolog",
2960                 .hide   = 1,
2961                 .help   = "Playback IO pattern file as fast as possible without stalls",
2962                 .category = FIO_OPT_C_IO,
2963                 .group  = FIO_OPT_G_IOLOG,
2964         },
2965         {
2966                 .name   = "replay_redirect",
2967                 .lname  = "Redirect device for replay",
2968                 .type   = FIO_OPT_STR_STORE,
2969                 .off1   = offsetof(struct thread_options, replay_redirect),
2970                 .parent = "read_iolog",
2971                 .hide   = 1,
2972                 .help   = "Replay all I/O onto this device, regardless of trace device",
2973                 .category = FIO_OPT_C_IO,
2974                 .group  = FIO_OPT_G_IOLOG,
2975         },
2976         {
2977                 .name   = "replay_scale",
2978                 .lname  = "Replace offset scale factor",
2979                 .type   = FIO_OPT_INT,
2980                 .off1   = offsetof(struct thread_options, replay_scale),
2981                 .parent = "read_iolog",
2982                 .def    = "1",
2983                 .help   = "Align offsets to this blocksize",
2984                 .category = FIO_OPT_C_IO,
2985                 .group  = FIO_OPT_G_IOLOG,
2986         },
2987         {
2988                 .name   = "replay_align",
2989                 .lname  = "Replace alignment",
2990                 .type   = FIO_OPT_INT,
2991                 .off1   = offsetof(struct thread_options, replay_align),
2992                 .parent = "read_iolog",
2993                 .help   = "Scale offset down by this factor",
2994                 .category = FIO_OPT_C_IO,
2995                 .group  = FIO_OPT_G_IOLOG,
2996                 .pow2   = 1,
2997         },
2998         {
2999                 .name   = "exec_prerun",
3000                 .lname  = "Pre-execute runnable",
3001                 .type   = FIO_OPT_STR_STORE,
3002                 .off1   = offsetof(struct thread_options, exec_prerun),
3003                 .help   = "Execute this file prior to running job",
3004                 .category = FIO_OPT_C_GENERAL,
3005                 .group  = FIO_OPT_G_INVALID,
3006         },
3007         {
3008                 .name   = "exec_postrun",
3009                 .lname  = "Post-execute runnable",
3010                 .type   = FIO_OPT_STR_STORE,
3011                 .off1   = offsetof(struct thread_options, exec_postrun),
3012                 .help   = "Execute this file after running job",
3013                 .category = FIO_OPT_C_GENERAL,
3014                 .group  = FIO_OPT_G_INVALID,
3015         },
3016 #ifdef FIO_HAVE_IOSCHED_SWITCH
3017         {
3018                 .name   = "ioscheduler",
3019                 .lname  = "I/O scheduler",
3020                 .type   = FIO_OPT_STR_STORE,
3021                 .off1   = offsetof(struct thread_options, ioscheduler),
3022                 .help   = "Use this IO scheduler on the backing device",
3023                 .category = FIO_OPT_C_FILE,
3024                 .group  = FIO_OPT_G_INVALID,
3025         },
3026 #else
3027         {
3028                 .name   = "ioscheduler",
3029                 .lname  = "I/O scheduler",
3030                 .type   = FIO_OPT_UNSUPPORTED,
3031                 .help   = "Your platform does not support IO scheduler switching",
3032         },
3033 #endif
3034         {
3035                 .name   = "zonesize",
3036                 .lname  = "Zone size",
3037                 .type   = FIO_OPT_STR_VAL,
3038                 .off1   = offsetof(struct thread_options, zone_size),
3039                 .help   = "Amount of data to read per zone",
3040                 .def    = "0",
3041                 .interval = 1024 * 1024,
3042                 .category = FIO_OPT_C_IO,
3043                 .group  = FIO_OPT_G_ZONE,
3044         },
3045         {
3046                 .name   = "zonerange",
3047                 .lname  = "Zone range",
3048                 .type   = FIO_OPT_STR_VAL,
3049                 .off1   = offsetof(struct thread_options, zone_range),
3050                 .help   = "Give size of an IO zone",
3051                 .def    = "0",
3052                 .interval = 1024 * 1024,
3053                 .category = FIO_OPT_C_IO,
3054                 .group  = FIO_OPT_G_ZONE,
3055         },
3056         {
3057                 .name   = "zoneskip",
3058                 .lname  = "Zone skip",
3059                 .type   = FIO_OPT_STR_VAL,
3060                 .off1   = offsetof(struct thread_options, zone_skip),
3061                 .help   = "Space between IO zones",
3062                 .def    = "0",
3063                 .interval = 1024 * 1024,
3064                 .category = FIO_OPT_C_IO,
3065                 .group  = FIO_OPT_G_ZONE,
3066         },
3067         {
3068                 .name   = "lockmem",
3069                 .lname  = "Lock memory",
3070                 .type   = FIO_OPT_STR_VAL,
3071                 .off1   = offsetof(struct thread_options, lockmem),
3072                 .help   = "Lock down this amount of memory (per worker)",
3073                 .def    = "0",
3074                 .interval = 1024 * 1024,
3075                 .category = FIO_OPT_C_GENERAL,
3076                 .group  = FIO_OPT_G_INVALID,
3077         },
3078         {
3079                 .name   = "rwmixread",
3080                 .lname  = "Read/write mix read",
3081                 .type   = FIO_OPT_INT,
3082                 .cb     = str_rwmix_read_cb,
3083                 .off1   = offsetof(struct thread_options, rwmix[DDIR_READ]),
3084                 .maxval = 100,
3085                 .help   = "Percentage of mixed workload that is reads",
3086                 .def    = "50",
3087                 .interval = 5,
3088                 .inverse = "rwmixwrite",
3089                 .category = FIO_OPT_C_IO,
3090                 .group  = FIO_OPT_G_RWMIX,
3091         },
3092         {
3093                 .name   = "rwmixwrite",
3094                 .lname  = "Read/write mix write",
3095                 .type   = FIO_OPT_INT,
3096                 .cb     = str_rwmix_write_cb,
3097                 .off1   = offsetof(struct thread_options, rwmix[DDIR_WRITE]),
3098                 .maxval = 100,
3099                 .help   = "Percentage of mixed workload that is writes",
3100                 .def    = "50",
3101                 .interval = 5,
3102                 .inverse = "rwmixread",
3103                 .category = FIO_OPT_C_IO,
3104                 .group  = FIO_OPT_G_RWMIX,
3105         },
3106         {
3107                 .name   = "rwmixcycle",
3108                 .lname  = "Read/write mix cycle",
3109                 .type   = FIO_OPT_DEPRECATED,
3110                 .category = FIO_OPT_C_IO,
3111                 .group  = FIO_OPT_G_RWMIX,
3112         },
3113         {
3114                 .name   = "nice",
3115                 .lname  = "Nice",
3116                 .type   = FIO_OPT_INT,
3117                 .off1   = offsetof(struct thread_options, nice),
3118                 .help   = "Set job CPU nice value",
3119                 .minval = -19,
3120                 .maxval = 20,
3121                 .def    = "0",
3122                 .interval = 1,
3123                 .category = FIO_OPT_C_GENERAL,
3124                 .group  = FIO_OPT_G_CRED,
3125         },
3126 #ifdef FIO_HAVE_IOPRIO
3127         {
3128                 .name   = "prio",
3129                 .lname  = "I/O nice priority",
3130                 .type   = FIO_OPT_INT,
3131                 .off1   = offsetof(struct thread_options, ioprio),
3132                 .help   = "Set job IO priority value",
3133                 .minval = IOPRIO_MIN_PRIO,
3134                 .maxval = IOPRIO_MAX_PRIO,
3135                 .interval = 1,
3136                 .category = FIO_OPT_C_GENERAL,
3137                 .group  = FIO_OPT_G_CRED,
3138         },
3139 #else
3140         {
3141                 .name   = "prio",
3142                 .lname  = "I/O nice priority",
3143                 .type   = FIO_OPT_UNSUPPORTED,
3144                 .help   = "Your platform does not support IO priorities",
3145         },
3146 #endif
3147 #ifdef FIO_HAVE_IOPRIO_CLASS
3148 #ifndef FIO_HAVE_IOPRIO
3149 #error "FIO_HAVE_IOPRIO_CLASS requires FIO_HAVE_IOPRIO"
3150 #endif
3151         {
3152                 .name   = "prioclass",
3153                 .lname  = "I/O nice priority class",
3154                 .type   = FIO_OPT_INT,
3155                 .off1   = offsetof(struct thread_options, ioprio_class),
3156                 .help   = "Set job IO priority class",
3157                 .minval = IOPRIO_MIN_PRIO_CLASS,
3158                 .maxval = IOPRIO_MAX_PRIO_CLASS,
3159                 .interval = 1,
3160                 .category = FIO_OPT_C_GENERAL,
3161                 .group  = FIO_OPT_G_CRED,
3162         },
3163 #else
3164         {
3165                 .name   = "prioclass",
3166                 .lname  = "I/O nice priority class",
3167                 .type   = FIO_OPT_UNSUPPORTED,
3168                 .help   = "Your platform does not support IO priority classes",
3169         },
3170 #endif
3171         {
3172                 .name   = "thinktime",
3173                 .lname  = "Thinktime",
3174                 .type   = FIO_OPT_INT,
3175                 .off1   = offsetof(struct thread_options, thinktime),
3176                 .help   = "Idle time between IO buffers (usec)",
3177                 .def    = "0",
3178                 .is_time = 1,
3179                 .category = FIO_OPT_C_IO,
3180                 .group  = FIO_OPT_G_THINKTIME,
3181         },
3182         {
3183                 .name   = "thinktime_spin",
3184                 .lname  = "Thinktime spin",
3185                 .type   = FIO_OPT_INT,
3186                 .off1   = offsetof(struct thread_options, thinktime_spin),
3187                 .help   = "Start think time by spinning this amount (usec)",
3188                 .def    = "0",
3189                 .is_time = 1,
3190                 .parent = "thinktime",
3191                 .hide   = 1,
3192                 .category = FIO_OPT_C_IO,
3193                 .group  = FIO_OPT_G_THINKTIME,
3194         },
3195         {
3196                 .name   = "thinktime_blocks",
3197                 .lname  = "Thinktime blocks",
3198                 .type   = FIO_OPT_INT,
3199                 .off1   = offsetof(struct thread_options, thinktime_blocks),
3200                 .help   = "IO buffer period between 'thinktime'",
3201                 .def    = "1",
3202                 .parent = "thinktime",
3203                 .hide   = 1,
3204                 .category = FIO_OPT_C_IO,
3205                 .group  = FIO_OPT_G_THINKTIME,
3206         },
3207         {
3208                 .name   = "rate",
3209                 .lname  = "I/O rate",
3210                 .type   = FIO_OPT_INT,
3211                 .off1   = offsetof(struct thread_options, rate[DDIR_READ]),
3212                 .off2   = offsetof(struct thread_options, rate[DDIR_WRITE]),
3213                 .off3   = offsetof(struct thread_options, rate[DDIR_TRIM]),
3214                 .help   = "Set bandwidth rate",
3215                 .category = FIO_OPT_C_IO,
3216                 .group  = FIO_OPT_G_RATE,
3217         },
3218         {
3219                 .name   = "rate_min",
3220                 .alias  = "ratemin",
3221                 .lname  = "I/O min rate",
3222                 .type   = FIO_OPT_INT,
3223                 .off1   = offsetof(struct thread_options, ratemin[DDIR_READ]),
3224                 .off2   = offsetof(struct thread_options, ratemin[DDIR_WRITE]),
3225                 .off3   = offsetof(struct thread_options, ratemin[DDIR_TRIM]),
3226                 .help   = "Job must meet this rate or it will be shutdown",
3227                 .parent = "rate",
3228                 .hide   = 1,
3229                 .category = FIO_OPT_C_IO,
3230                 .group  = FIO_OPT_G_RATE,
3231         },
3232         {
3233                 .name   = "rate_iops",
3234                 .lname  = "I/O rate IOPS",
3235                 .type   = FIO_OPT_INT,
3236                 .off1   = offsetof(struct thread_options, rate_iops[DDIR_READ]),
3237                 .off2   = offsetof(struct thread_options, rate_iops[DDIR_WRITE]),
3238                 .off3   = offsetof(struct thread_options, rate_iops[DDIR_TRIM]),
3239                 .help   = "Limit IO used to this number of IO operations/sec",
3240                 .hide   = 1,
3241                 .category = FIO_OPT_C_IO,
3242                 .group  = FIO_OPT_G_RATE,
3243         },
3244         {
3245                 .name   = "rate_iops_min",
3246                 .lname  = "I/O min rate IOPS",
3247                 .type   = FIO_OPT_INT,
3248                 .off1   = offsetof(struct thread_options, rate_iops_min[DDIR_READ]),
3249                 .off2   = offsetof(struct thread_options, rate_iops_min[DDIR_WRITE]),
3250                 .off3   = offsetof(struct thread_options, rate_iops_min[DDIR_TRIM]),
3251                 .help   = "Job must meet this rate or it will be shut down",
3252                 .parent = "rate_iops",
3253                 .hide   = 1,
3254                 .category = FIO_OPT_C_IO,
3255                 .group  = FIO_OPT_G_RATE,
3256         },
3257         {
3258                 .name   = "rate_process",
3259                 .lname  = "Rate Process",
3260                 .type   = FIO_OPT_STR,
3261                 .off1   = offsetof(struct thread_options, rate_process),
3262                 .help   = "What process controls how rated IO is managed",
3263                 .def    = "linear",
3264                 .category = FIO_OPT_C_IO,
3265                 .group  = FIO_OPT_G_RATE,
3266                 .posval = {
3267                           { .ival = "linear",
3268                             .oval = RATE_PROCESS_LINEAR,
3269                             .help = "Linear rate of IO",
3270                           },
3271                           {
3272                             .ival = "poisson",
3273                             .oval = RATE_PROCESS_POISSON,
3274                             .help = "Rate follows Poisson process",
3275                           },
3276                 },
3277                 .parent = "rate",
3278         },
3279         {
3280                 .name   = "rate_cycle",
3281                 .alias  = "ratecycle",
3282                 .lname  = "I/O rate cycle",
3283                 .type   = FIO_OPT_INT,
3284                 .off1   = offsetof(struct thread_options, ratecycle),
3285                 .help   = "Window average for rate limits (msec)",
3286                 .def    = "1000",
3287                 .parent = "rate",
3288                 .hide   = 1,
3289                 .category = FIO_OPT_C_IO,
3290                 .group  = FIO_OPT_G_RATE,
3291         },
3292         {
3293                 .name   = "max_latency",
3294                 .lname  = "Max Latency",
3295                 .type   = FIO_OPT_INT,
3296                 .off1   = offsetof(struct thread_options, max_latency),
3297                 .help   = "Maximum tolerated IO latency (usec)",
3298                 .is_time = 1,
3299                 .category = FIO_OPT_C_IO,
3300                 .group = FIO_OPT_G_LATPROF,
3301         },
3302         {
3303                 .name   = "latency_target",
3304                 .lname  = "Latency Target (usec)",
3305                 .type   = FIO_OPT_STR_VAL_TIME,
3306                 .off1   = offsetof(struct thread_options, latency_target),
3307                 .help   = "Ramp to max queue depth supporting this latency",
3308                 .is_time = 1,
3309                 .category = FIO_OPT_C_IO,
3310                 .group  = FIO_OPT_G_LATPROF,
3311         },
3312         {
3313                 .name   = "latency_window",
3314                 .lname  = "Latency Window (usec)",
3315                 .type   = FIO_OPT_STR_VAL_TIME,
3316                 .off1   = offsetof(struct thread_options, latency_window),
3317                 .help   = "Time to sustain latency_target",
3318                 .is_time = 1,
3319                 .category = FIO_OPT_C_IO,
3320                 .group  = FIO_OPT_G_LATPROF,
3321         },
3322         {
3323                 .name   = "latency_percentile",
3324                 .lname  = "Latency Percentile",
3325                 .type   = FIO_OPT_FLOAT_LIST,
3326                 .off1   = offsetof(struct thread_options, latency_percentile),
3327                 .help   = "Percentile of IOs must be below latency_target",
3328                 .def    = "100",
3329                 .maxlen = 1,
3330                 .minfp  = 0.0,
3331                 .maxfp  = 100.0,
3332                 .category = FIO_OPT_C_IO,
3333                 .group  = FIO_OPT_G_LATPROF,
3334         },
3335         {
3336                 .name   = "invalidate",
3337                 .lname  = "Cache invalidate",
3338                 .type   = FIO_OPT_BOOL,
3339                 .off1   = offsetof(struct thread_options, invalidate_cache),
3340                 .help   = "Invalidate buffer/page cache prior to running job",
3341                 .def    = "1",
3342                 .category = FIO_OPT_C_IO,
3343                 .group  = FIO_OPT_G_IO_TYPE,
3344         },
3345         {
3346                 .name   = "sync",
3347                 .lname  = "Synchronous I/O",
3348                 .type   = FIO_OPT_BOOL,
3349                 .off1   = offsetof(struct thread_options, sync_io),
3350                 .help   = "Use O_SYNC for buffered writes",
3351                 .def    = "0",
3352                 .parent = "buffered",
3353                 .hide   = 1,
3354                 .category = FIO_OPT_C_IO,
3355                 .group  = FIO_OPT_G_IO_TYPE,
3356         },
3357         {
3358                 .name   = "create_serialize",
3359                 .lname  = "Create serialize",
3360                 .type   = FIO_OPT_BOOL,
3361                 .off1   = offsetof(struct thread_options, create_serialize),
3362                 .help   = "Serialize creation of job files",
3363                 .def    = "1",
3364                 .category = FIO_OPT_C_FILE,
3365                 .group  = FIO_OPT_G_INVALID,
3366         },
3367         {
3368                 .name   = "create_fsync",
3369                 .lname  = "Create fsync",
3370                 .type   = FIO_OPT_BOOL,
3371                 .off1   = offsetof(struct thread_options, create_fsync),
3372                 .help   = "fsync file after creation",
3373                 .def    = "1",
3374                 .category = FIO_OPT_C_FILE,
3375                 .group  = FIO_OPT_G_INVALID,
3376         },
3377         {
3378                 .name   = "create_on_open",
3379                 .lname  = "Create on open",
3380                 .type   = FIO_OPT_BOOL,
3381                 .off1   = offsetof(struct thread_options, create_on_open),
3382                 .help   = "Create files when they are opened for IO",
3383                 .def    = "0",
3384                 .category = FIO_OPT_C_FILE,
3385                 .group  = FIO_OPT_G_INVALID,
3386         },
3387         {
3388                 .name   = "create_only",
3389                 .lname  = "Create Only",
3390                 .type   = FIO_OPT_BOOL,
3391                 .off1   = offsetof(struct thread_options, create_only),
3392                 .help   = "Only perform file creation phase",
3393                 .category = FIO_OPT_C_FILE,
3394                 .def    = "0",
3395         },
3396         {
3397                 .name   = "allow_file_create",
3398                 .lname  = "Allow file create",
3399                 .type   = FIO_OPT_BOOL,
3400                 .off1   = offsetof(struct thread_options, allow_create),
3401                 .help   = "Permit fio to create files, if they don't exist",
3402                 .def    = "1",
3403                 .category = FIO_OPT_C_FILE,
3404                 .group  = FIO_OPT_G_FILENAME,
3405         },
3406         {
3407                 .name   = "allow_mounted_write",
3408                 .lname  = "Allow mounted write",
3409                 .type   = FIO_OPT_BOOL,
3410                 .off1   = offsetof(struct thread_options, allow_mounted_write),
3411                 .help   = "Allow writes to a mounted partition",
3412                 .def    = "0",
3413                 .category = FIO_OPT_C_FILE,
3414                 .group  = FIO_OPT_G_FILENAME,
3415         },
3416         {
3417                 .name   = "pre_read",
3418                 .lname  = "Pre-read files",
3419                 .type   = FIO_OPT_BOOL,
3420                 .off1   = offsetof(struct thread_options, pre_read),
3421                 .help   = "Pre-read files before starting official testing",
3422                 .def    = "0",
3423                 .category = FIO_OPT_C_FILE,
3424                 .group  = FIO_OPT_G_INVALID,
3425         },
3426 #ifdef FIO_HAVE_CPU_AFFINITY
3427         {
3428                 .name   = "cpumask",
3429                 .lname  = "CPU mask",
3430                 .type   = FIO_OPT_INT,
3431                 .cb     = str_cpumask_cb,
3432                 .off1   = offsetof(struct thread_options, cpumask),
3433                 .help   = "CPU affinity mask",
3434                 .category = FIO_OPT_C_GENERAL,
3435                 .group  = FIO_OPT_G_CRED,
3436         },
3437         {
3438                 .name   = "cpus_allowed",
3439                 .lname  = "CPUs allowed",
3440                 .type   = FIO_OPT_STR,
3441                 .cb     = str_cpus_allowed_cb,
3442                 .off1   = offsetof(struct thread_options, cpumask),
3443                 .help   = "Set CPUs allowed",
3444                 .category = FIO_OPT_C_GENERAL,
3445                 .group  = FIO_OPT_G_CRED,
3446         },
3447         {
3448                 .name   = "cpus_allowed_policy",
3449                 .lname  = "CPUs allowed distribution policy",
3450                 .type   = FIO_OPT_STR,
3451                 .off1   = offsetof(struct thread_options, cpus_allowed_policy),
3452                 .help   = "Distribution policy for cpus_allowed",
3453                 .parent = "cpus_allowed",
3454                 .prio   = 1,
3455                 .posval = {
3456                           { .ival = "shared",
3457                             .oval = FIO_CPUS_SHARED,
3458                             .help = "Mask shared between threads",
3459                           },
3460                           { .ival = "split",
3461                             .oval = FIO_CPUS_SPLIT,
3462                             .help = "Mask split between threads",
3463                           },
3464                 },
3465                 .category = FIO_OPT_C_GENERAL,
3466                 .group  = FIO_OPT_G_CRED,
3467         },
3468 #else
3469         {
3470                 .name   = "cpumask",
3471                 .lname  = "CPU mask",
3472                 .type   = FIO_OPT_UNSUPPORTED,
3473                 .help   = "Your platform does not support CPU affinities",
3474         },
3475         {
3476                 .name   = "cpus_allowed",
3477                 .lname  = "CPUs allowed",
3478                 .type   = FIO_OPT_UNSUPPORTED,
3479                 .help   = "Your platform does not support CPU affinities",
3480         },
3481         {
3482                 .name   = "cpus_allowed_policy",
3483                 .lname  = "CPUs allowed distribution policy",
3484                 .type   = FIO_OPT_UNSUPPORTED,
3485                 .help   = "Your platform does not support CPU affinities",
3486         },
3487 #endif
3488 #ifdef CONFIG_LIBNUMA
3489         {
3490                 .name   = "numa_cpu_nodes",
3491                 .lname  = "NUMA CPU Nodes",
3492                 .type   = FIO_OPT_STR,
3493                 .cb     = str_numa_cpunodes_cb,
3494                 .off1   = offsetof(struct thread_options, numa_cpunodes),
3495                 .help   = "NUMA CPU nodes bind",
3496                 .category = FIO_OPT_C_GENERAL,
3497                 .group  = FIO_OPT_G_INVALID,
3498         },
3499         {
3500                 .name   = "numa_mem_policy",
3501                 .lname  = "NUMA Memory Policy",
3502                 .type   = FIO_OPT_STR,
3503                 .cb     = str_numa_mpol_cb,
3504                 .off1   = offsetof(struct thread_options, numa_memnodes),
3505                 .help   = "NUMA memory policy setup",
3506                 .category = FIO_OPT_C_GENERAL,
3507                 .group  = FIO_OPT_G_INVALID,
3508         },
3509 #else
3510         {
3511                 .name   = "numa_cpu_nodes",
3512                 .lname  = "NUMA CPU Nodes",
3513                 .type   = FIO_OPT_UNSUPPORTED,
3514                 .help   = "Build fio with libnuma-dev(el) to enable this option",
3515         },
3516         {
3517                 .name   = "numa_mem_policy",
3518                 .lname  = "NUMA Memory Policy",
3519                 .type   = FIO_OPT_UNSUPPORTED,
3520                 .help   = "Build fio with libnuma-dev(el) to enable this option",
3521         },
3522 #endif
3523         {
3524                 .name   = "end_fsync",
3525                 .lname  = "End fsync",
3526                 .type   = FIO_OPT_BOOL,
3527                 .off1   = offsetof(struct thread_options, end_fsync),
3528                 .help   = "Include fsync at the end of job",
3529                 .def    = "0",
3530                 .category = FIO_OPT_C_FILE,
3531                 .group  = FIO_OPT_G_INVALID,
3532         },
3533         {
3534                 .name   = "fsync_on_close",
3535                 .lname  = "Fsync on close",
3536                 .type   = FIO_OPT_BOOL,
3537                 .off1   = offsetof(struct thread_options, fsync_on_close),
3538                 .help   = "fsync files on close",
3539                 .def    = "0",
3540                 .category = FIO_OPT_C_FILE,
3541                 .group  = FIO_OPT_G_INVALID,
3542         },
3543         {
3544                 .name   = "unlink",
3545                 .lname  = "Unlink file",
3546                 .type   = FIO_OPT_BOOL,
3547                 .off1   = offsetof(struct thread_options, unlink),
3548                 .help   = "Unlink created files after job has completed",
3549                 .def    = "0",
3550                 .category = FIO_OPT_C_FILE,
3551                 .group  = FIO_OPT_G_INVALID,
3552         },
3553         {
3554                 .name   = "unlink_each_loop",
3555                 .lname  = "Unlink file after each loop of a job",
3556                 .type   = FIO_OPT_BOOL,
3557                 .off1   = offsetof(struct thread_options, unlink_each_loop),
3558                 .help   = "Unlink created files after each loop in a job has completed",
3559                 .def    = "0",
3560                 .category = FIO_OPT_C_FILE,
3561                 .group  = FIO_OPT_G_INVALID,
3562         },
3563         {
3564                 .name   = "exitall",
3565                 .lname  = "Exit-all on terminate",
3566                 .type   = FIO_OPT_STR_SET,
3567                 .cb     = str_exitall_cb,
3568                 .help   = "Terminate all jobs when one exits",
3569                 .category = FIO_OPT_C_GENERAL,
3570                 .group  = FIO_OPT_G_PROCESS,
3571         },
3572         {
3573                 .name   = "exitall_on_error",
3574                 .lname  = "Exit-all on terminate in error",
3575                 .type   = FIO_OPT_STR_SET,
3576                 .off1   = offsetof(struct thread_options, exitall_error),
3577                 .help   = "Terminate all jobs when one exits in error",
3578                 .category = FIO_OPT_C_GENERAL,
3579                 .group  = FIO_OPT_G_PROCESS,
3580         },
3581         {
3582                 .name   = "stonewall",
3583                 .lname  = "Wait for previous",
3584                 .alias  = "wait_for_previous",
3585                 .type   = FIO_OPT_STR_SET,
3586                 .off1   = offsetof(struct thread_options, stonewall),
3587                 .help   = "Insert a hard barrier between this job and previous",
3588                 .category = FIO_OPT_C_GENERAL,
3589                 .group  = FIO_OPT_G_PROCESS,
3590         },
3591         {
3592                 .name   = "new_group",
3593                 .lname  = "New group",
3594                 .type   = FIO_OPT_STR_SET,
3595                 .off1   = offsetof(struct thread_options, new_group),
3596                 .help   = "Mark the start of a new group (for reporting)",
3597                 .category = FIO_OPT_C_GENERAL,
3598                 .group  = FIO_OPT_G_PROCESS,
3599         },
3600         {
3601                 .name   = "thread",
3602                 .lname  = "Thread",
3603                 .type   = FIO_OPT_STR_SET,
3604                 .off1   = offsetof(struct thread_options, use_thread),
3605                 .help   = "Use threads instead of processes",
3606 #ifdef CONFIG_NO_SHM
3607                 .def    = "1",
3608                 .no_warn_def = 1,
3609 #endif
3610                 .category = FIO_OPT_C_GENERAL,
3611                 .group  = FIO_OPT_G_PROCESS,
3612         },
3613         {
3614                 .name   = "per_job_logs",
3615                 .lname  = "Per Job Logs",
3616                 .type   = FIO_OPT_BOOL,
3617                 .off1   = offsetof(struct thread_options, per_job_logs),
3618                 .help   = "Include job number in generated log files or not",
3619                 .def    = "1",
3620                 .category = FIO_OPT_C_LOG,
3621                 .group  = FIO_OPT_G_INVALID,
3622         },
3623         {
3624                 .name   = "write_bw_log",
3625                 .lname  = "Write bandwidth log",
3626                 .type   = FIO_OPT_STR,
3627                 .off1   = offsetof(struct thread_options, bw_log_file),
3628                 .cb     = str_write_bw_log_cb,
3629                 .help   = "Write log of bandwidth during run",
3630                 .category = FIO_OPT_C_LOG,
3631                 .group  = FIO_OPT_G_INVALID,
3632         },
3633         {
3634                 .name   = "write_lat_log",
3635                 .lname  = "Write latency log",
3636                 .type   = FIO_OPT_STR,
3637                 .off1   = offsetof(struct thread_options, lat_log_file),
3638                 .cb     = str_write_lat_log_cb,
3639                 .help   = "Write log of latency during run",
3640                 .category = FIO_OPT_C_LOG,
3641                 .group  = FIO_OPT_G_INVALID,
3642         },
3643         {
3644                 .name   = "write_iops_log",
3645                 .lname  = "Write IOPS log",
3646                 .type   = FIO_OPT_STR,
3647                 .off1   = offsetof(struct thread_options, iops_log_file),
3648                 .cb     = str_write_iops_log_cb,
3649                 .help   = "Write log of IOPS during run",
3650                 .category = FIO_OPT_C_LOG,
3651                 .group  = FIO_OPT_G_INVALID,
3652         },
3653         {
3654                 .name   = "log_avg_msec",
3655                 .lname  = "Log averaging (msec)",
3656                 .type   = FIO_OPT_INT,
3657                 .off1   = offsetof(struct thread_options, log_avg_msec),
3658                 .help   = "Average bw/iops/lat logs over this period of time",
3659                 .def    = "0",
3660                 .category = FIO_OPT_C_LOG,
3661                 .group  = FIO_OPT_G_INVALID,
3662         },
3663         {
3664                 .name   = "log_hist_msec",
3665                 .lname  = "Log histograms (msec)",
3666                 .type   = FIO_OPT_INT,
3667                 .off1   = offsetof(struct thread_options, log_hist_msec),
3668                 .help   = "Dump completion latency histograms at frequency of this time value",
3669                 .def    = "0",
3670                 .category = FIO_OPT_C_LOG,
3671                 .group  = FIO_OPT_G_INVALID,
3672         },
3673         {
3674                 .name   = "log_hist_coarseness",
3675                 .lname  = "Histogram logs coarseness",
3676                 .type   = FIO_OPT_INT,
3677                 .off1   = offsetof(struct thread_options, log_hist_coarseness),
3678                 .help   = "Integer in range [0,6]. Higher coarseness outputs"
3679                         " fewer histogram bins per sample. The number of bins for"
3680                         " these are [1216, 608, 304, 152, 76, 38, 19] respectively.",
3681                 .def    = "0",
3682                 .category = FIO_OPT_C_LOG,
3683                 .group  = FIO_OPT_G_INVALID,
3684         },
3685         {
3686                 .name   = "write_hist_log",
3687                 .lname  = "Write latency histogram logs",
3688                 .type   = FIO_OPT_STR,
3689                 .off1   = offsetof(struct thread_options, hist_log_file),
3690                 .cb     = str_write_hist_log_cb,
3691                 .help   = "Write log of latency histograms during run",
3692                 .category = FIO_OPT_C_LOG,
3693                 .group  = FIO_OPT_G_INVALID,
3694         },
3695         {
3696                 .name   = "log_max_value",
3697                 .lname  = "Log maximum instead of average",
3698                 .type   = FIO_OPT_BOOL,
3699                 .off1   = offsetof(struct thread_options, log_max),
3700                 .help   = "Log max sample in a window instead of average",
3701                 .def    = "0",
3702                 .category = FIO_OPT_C_LOG,
3703                 .group  = FIO_OPT_G_INVALID,
3704         },
3705         {
3706                 .name   = "log_offset",
3707                 .lname  = "Log offset of IO",
3708                 .type   = FIO_OPT_BOOL,
3709                 .off1   = offsetof(struct thread_options, log_offset),
3710                 .help   = "Include offset of IO for each log entry",
3711                 .def    = "0",
3712                 .category = FIO_OPT_C_LOG,
3713                 .group  = FIO_OPT_G_INVALID,
3714         },
3715 #ifdef CONFIG_ZLIB
3716         {
3717                 .name   = "log_compression",
3718                 .lname  = "Log compression",
3719                 .type   = FIO_OPT_INT,
3720                 .off1   = offsetof(struct thread_options, log_gz),
3721                 .help   = "Log in compressed chunks of this size",
3722                 .minval = 1024ULL,
3723                 .maxval = 512 * 1024 * 1024ULL,
3724                 .category = FIO_OPT_C_LOG,
3725                 .group  = FIO_OPT_G_INVALID,
3726         },
3727 #ifdef FIO_HAVE_CPU_AFFINITY
3728         {
3729                 .name   = "log_compression_cpus",
3730                 .lname  = "Log Compression CPUs",
3731                 .type   = FIO_OPT_STR,
3732                 .cb     = str_log_cpus_allowed_cb,
3733                 .off1   = offsetof(struct thread_options, log_gz_cpumask),
3734                 .parent = "log_compression",
3735                 .help   = "Limit log compression to these CPUs",
3736                 .category = FIO_OPT_C_LOG,
3737                 .group  = FIO_OPT_G_INVALID,
3738         },
3739 #else
3740         {
3741                 .name   = "log_compression_cpus",
3742                 .lname  = "Log Compression CPUs",
3743                 .type   = FIO_OPT_UNSUPPORTED,
3744                 .help   = "Your platform does not support CPU affinities",
3745         },
3746 #endif
3747         {
3748                 .name   = "log_store_compressed",
3749                 .lname  = "Log store compressed",
3750                 .type   = FIO_OPT_BOOL,
3751                 .off1   = offsetof(struct thread_options, log_gz_store),
3752                 .help   = "Store logs in a compressed format",
3753                 .category = FIO_OPT_C_LOG,
3754                 .group  = FIO_OPT_G_INVALID,
3755         },
3756 #else
3757         {
3758                 .name   = "log_compression",
3759                 .lname  = "Log compression",
3760                 .type   = FIO_OPT_UNSUPPORTED,
3761                 .help   = "Install libz-dev(el) to get compression support",
3762         },
3763         {
3764                 .name   = "log_store_compressed",
3765                 .lname  = "Log store compressed",
3766                 .type   = FIO_OPT_UNSUPPORTED,
3767                 .help   = "Install libz-dev(el) to get compression support",
3768         },
3769 #endif
3770         {
3771                 .name = "log_unix_epoch",
3772                 .lname = "Log epoch unix",
3773                 .type = FIO_OPT_BOOL,
3774                 .off1 = offsetof(struct thread_options, log_unix_epoch),
3775                 .help = "Use Unix time in log files",
3776                 .category = FIO_OPT_C_LOG,
3777                 .group = FIO_OPT_G_INVALID,
3778         },
3779         {
3780                 .name   = "block_error_percentiles",
3781                 .lname  = "Block error percentiles",
3782                 .type   = FIO_OPT_BOOL,
3783                 .off1   = offsetof(struct thread_options, block_error_hist),
3784                 .help   = "Record trim block errors and make a histogram",
3785                 .def    = "0",
3786                 .category = FIO_OPT_C_LOG,
3787                 .group  = FIO_OPT_G_INVALID,
3788         },
3789         {
3790                 .name   = "bwavgtime",
3791                 .lname  = "Bandwidth average time",
3792                 .type   = FIO_OPT_INT,
3793                 .off1   = offsetof(struct thread_options, bw_avg_time),
3794                 .help   = "Time window over which to calculate bandwidth"
3795                           " (msec)",
3796                 .def    = "500",
3797                 .parent = "write_bw_log",
3798                 .hide   = 1,
3799                 .interval = 100,
3800                 .category = FIO_OPT_C_LOG,
3801                 .group  = FIO_OPT_G_INVALID,
3802         },
3803         {
3804                 .name   = "iopsavgtime",
3805                 .lname  = "IOPS average time",
3806                 .type   = FIO_OPT_INT,
3807                 .off1   = offsetof(struct thread_options, iops_avg_time),
3808                 .help   = "Time window over which to calculate IOPS (msec)",
3809                 .def    = "500",
3810                 .parent = "write_iops_log",
3811                 .hide   = 1,
3812                 .interval = 100,
3813                 .category = FIO_OPT_C_LOG,
3814                 .group  = FIO_OPT_G_INVALID,
3815         },
3816         {
3817                 .name   = "group_reporting",
3818                 .lname  = "Group reporting",
3819                 .type   = FIO_OPT_STR_SET,
3820                 .off1   = offsetof(struct thread_options, group_reporting),
3821                 .help   = "Do reporting on a per-group basis",
3822                 .category = FIO_OPT_C_STAT,
3823                 .group  = FIO_OPT_G_INVALID,
3824         },
3825         {
3826                 .name   = "zero_buffers",
3827                 .lname  = "Zero I/O buffers",
3828                 .type   = FIO_OPT_STR_SET,
3829                 .off1   = offsetof(struct thread_options, zero_buffers),
3830                 .help   = "Init IO buffers to all zeroes",
3831                 .category = FIO_OPT_C_IO,
3832                 .group  = FIO_OPT_G_IO_BUF,
3833         },
3834         {
3835                 .name   = "refill_buffers",
3836                 .lname  = "Refill I/O buffers",
3837                 .type   = FIO_OPT_STR_SET,
3838                 .off1   = offsetof(struct thread_options, refill_buffers),
3839                 .help   = "Refill IO buffers on every IO submit",
3840                 .category = FIO_OPT_C_IO,
3841                 .group  = FIO_OPT_G_IO_BUF,
3842         },
3843         {
3844                 .name   = "scramble_buffers",
3845                 .lname  = "Scramble I/O buffers",
3846                 .type   = FIO_OPT_BOOL,
3847                 .off1   = offsetof(struct thread_options, scramble_buffers),
3848                 .help   = "Slightly scramble buffers on every IO submit",
3849                 .def    = "1",
3850                 .category = FIO_OPT_C_IO,
3851                 .group  = FIO_OPT_G_IO_BUF,
3852         },
3853         {
3854                 .name   = "buffer_pattern",
3855                 .lname  = "Buffer pattern",
3856                 .type   = FIO_OPT_STR,
3857                 .cb     = str_buffer_pattern_cb,
3858                 .off1   = offsetof(struct thread_options, buffer_pattern),
3859                 .help   = "Fill pattern for IO buffers",
3860                 .category = FIO_OPT_C_IO,
3861                 .group  = FIO_OPT_G_IO_BUF,
3862         },
3863         {
3864                 .name   = "buffer_compress_percentage",
3865                 .lname  = "Buffer compression percentage",
3866                 .type   = FIO_OPT_INT,
3867                 .cb     = str_buffer_compress_cb,
3868                 .off1   = offsetof(struct thread_options, compress_percentage),
3869                 .maxval = 100,
3870                 .minval = 0,
3871                 .help   = "How compressible the buffer is (approximately)",
3872                 .interval = 5,
3873                 .category = FIO_OPT_C_IO,
3874                 .group  = FIO_OPT_G_IO_BUF,
3875         },
3876         {
3877                 .name   = "buffer_compress_chunk",
3878                 .lname  = "Buffer compression chunk size",
3879                 .type   = FIO_OPT_INT,
3880                 .off1   = offsetof(struct thread_options, compress_chunk),
3881                 .parent = "buffer_compress_percentage",
3882                 .hide   = 1,
3883                 .help   = "Size of compressible region in buffer",
3884                 .interval = 256,
3885                 .category = FIO_OPT_C_IO,
3886                 .group  = FIO_OPT_G_IO_BUF,
3887         },
3888         {
3889                 .name   = "dedupe_percentage",
3890                 .lname  = "Dedupe percentage",
3891                 .type   = FIO_OPT_INT,
3892                 .cb     = str_dedupe_cb,
3893                 .off1   = offsetof(struct thread_options, dedupe_percentage),
3894                 .maxval = 100,
3895                 .minval = 0,
3896                 .help   = "Percentage of buffers that are dedupable",