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