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