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