0b3a895d14d83ab00d5c495b9393e307bba1c4c2
[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 <sys/stat.h>
8 #include <netinet/in.h>
9
10 #include "fio.h"
11 #include "verify.h"
12 #include "parse.h"
13 #include "lib/pattern.h"
14 #include "options.h"
15 #include "optgroup.h"
16
17 char client_sockaddr_str[INET6_ADDRSTRLEN] = { 0 };
18
19 #define cb_data_to_td(data)     container_of(data, struct thread_data, o)
20
21 static struct pattern_fmt_desc fmt_desc[] = {
22         {
23                 .fmt   = "%o",
24                 .len   = FIELD_SIZE(struct io_u *, offset),
25                 .paste = paste_blockoff
26         }
27 };
28
29 /*
30  * Check if mmap/mmaphuge has a :/foo/bar/file at the end. If so, return that.
31  */
32 static char *get_opt_postfix(const char *str)
33 {
34         char *p = strstr(str, ":");
35
36         if (!p)
37                 return NULL;
38
39         p++;
40         strip_blank_front(&p);
41         strip_blank_end(p);
42         return strdup(p);
43 }
44
45 static int bs_cmp(const void *p1, const void *p2)
46 {
47         const struct bssplit *bsp1 = p1;
48         const struct bssplit *bsp2 = p2;
49
50         return (int) bsp1->perc - (int) bsp2->perc;
51 }
52
53 struct split {
54         unsigned int nr;
55         unsigned int val1[ZONESPLIT_MAX];
56         unsigned long long val2[ZONESPLIT_MAX];
57 };
58
59 static int split_parse_ddir(struct thread_options *o, struct split *split,
60                             enum fio_ddir ddir, char *str, bool absolute,
61                             unsigned int max_splits)
62 {
63         unsigned long long perc;
64         unsigned int i;
65         long long val;
66         char *fname;
67
68         split->nr = 0;
69
70         i = 0;
71         while ((fname = strsep(&str, ":")) != NULL) {
72                 char *perc_str;
73
74                 if (!strlen(fname))
75                         break;
76
77                 perc_str = strstr(fname, "/");
78                 if (perc_str) {
79                         *perc_str = '\0';
80                         perc_str++;
81                         if (absolute) {
82                                 if (str_to_decimal(perc_str, &val, 1, o, 0, 0)) {
83                                         log_err("fio: split conversion failed\n");
84                                         return 1;
85                                 }
86                                 perc = val;
87                         } else {
88                                 perc = atoi(perc_str);
89                                 if (perc > 100)
90                                         perc = 100;
91                                 else if (!perc)
92                                         perc = -1U;
93                         }
94                 } else {
95                         if (absolute)
96                                 perc = 0;
97                         else
98                                 perc = -1U;
99                 }
100
101                 if (str_to_decimal(fname, &val, 1, o, 0, 0)) {
102                         log_err("fio: split conversion failed\n");
103                         return 1;
104                 }
105
106                 split->val1[i] = val;
107                 split->val2[i] = perc;
108                 i++;
109                 if (i == max_splits) {
110                         log_err("fio: hit max of %d split entries\n", i);
111                         break;
112                 }
113         }
114
115         split->nr = i;
116         return 0;
117 }
118
119 static int bssplit_ddir(struct thread_options *o, enum fio_ddir ddir, char *str,
120                         bool data)
121 {
122         unsigned int i, perc, perc_missing;
123         unsigned int max_bs, min_bs;
124         struct split split;
125
126         memset(&split, 0, sizeof(split));
127
128         if (split_parse_ddir(o, &split, ddir, str, data, BSSPLIT_MAX))
129                 return 1;
130         if (!split.nr)
131                 return 0;
132
133         max_bs = 0;
134         min_bs = -1;
135         o->bssplit[ddir] = malloc(split.nr * sizeof(struct bssplit));
136         o->bssplit_nr[ddir] = split.nr;
137         for (i = 0; i < split.nr; i++) {
138                 if (split.val1[i] > max_bs)
139                         max_bs = split.val1[i];
140                 if (split.val1[i] < min_bs)
141                         min_bs = split.val1[i];
142
143                 o->bssplit[ddir][i].bs = split.val1[i];
144                 o->bssplit[ddir][i].perc =split.val2[i];
145         }
146
147         /*
148          * Now check if the percentages add up, and how much is missing
149          */
150         perc = perc_missing = 0;
151         for (i = 0; i < o->bssplit_nr[ddir]; i++) {
152                 struct bssplit *bsp = &o->bssplit[ddir][i];
153
154                 if (bsp->perc == -1U)
155                         perc_missing++;
156                 else
157                         perc += bsp->perc;
158         }
159
160         if (perc > 100 && perc_missing > 1) {
161                 log_err("fio: bssplit percentages add to more than 100%%\n");
162                 free(o->bssplit[ddir]);
163                 o->bssplit[ddir] = NULL;
164                 return 1;
165         }
166
167         /*
168          * If values didn't have a percentage set, divide the remains between
169          * them.
170          */
171         if (perc_missing) {
172                 if (perc_missing == 1 && o->bssplit_nr[ddir] == 1)
173                         perc = 100;
174                 for (i = 0; i < o->bssplit_nr[ddir]; i++) {
175                         struct bssplit *bsp = &o->bssplit[ddir][i];
176
177                         if (bsp->perc == -1U)
178                                 bsp->perc = (100 - perc) / perc_missing;
179                 }
180         }
181
182         o->min_bs[ddir] = min_bs;
183         o->max_bs[ddir] = max_bs;
184
185         /*
186          * now sort based on percentages, for ease of lookup
187          */
188         qsort(o->bssplit[ddir], o->bssplit_nr[ddir], sizeof(struct bssplit), bs_cmp);
189         return 0;
190 }
191
192 typedef int (split_parse_fn)(struct thread_options *, enum fio_ddir, char *, bool);
193
194 static int str_split_parse(struct thread_data *td, char *str,
195                            split_parse_fn *fn, bool data)
196 {
197         char *odir, *ddir;
198         int ret = 0;
199
200         odir = strchr(str, ',');
201         if (odir) {
202                 ddir = strchr(odir + 1, ',');
203                 if (ddir) {
204                         ret = fn(&td->o, DDIR_TRIM, ddir + 1, data);
205                         if (!ret)
206                                 *ddir = '\0';
207                 } else {
208                         char *op;
209
210                         op = strdup(odir + 1);
211                         ret = fn(&td->o, DDIR_TRIM, op, data);
212
213                         free(op);
214                 }
215                 if (!ret)
216                         ret = fn(&td->o, DDIR_WRITE, odir + 1, data);
217                 if (!ret) {
218                         *odir = '\0';
219                         ret = fn(&td->o, DDIR_READ, str, data);
220                 }
221         } else {
222                 char *op;
223
224                 op = strdup(str);
225                 ret = fn(&td->o, DDIR_WRITE, op, data);
226                 free(op);
227
228                 if (!ret) {
229                         op = strdup(str);
230                         ret = fn(&td->o, DDIR_TRIM, op, data);
231                         free(op);
232                 }
233                 if (!ret)
234                         ret = fn(&td->o, DDIR_READ, str, data);
235         }
236
237         return ret;
238 }
239
240 static int str_bssplit_cb(void *data, const char *input)
241 {
242         struct thread_data *td = cb_data_to_td(data);
243         char *str, *p;
244         int ret = 0;
245
246         p = str = strdup(input);
247
248         strip_blank_front(&str);
249         strip_blank_end(str);
250
251         ret = str_split_parse(td, str, bssplit_ddir, false);
252
253         if (parse_dryrun()) {
254                 int i;
255
256                 for (i = 0; i < DDIR_RWDIR_CNT; i++) {
257                         free(td->o.bssplit[i]);
258                         td->o.bssplit[i] = NULL;
259                         td->o.bssplit_nr[i] = 0;
260                 }
261         }
262
263         free(p);
264         return ret;
265 }
266
267 static int str2error(char *str)
268 {
269         const char *err[] = { "EPERM", "ENOENT", "ESRCH", "EINTR", "EIO",
270                             "ENXIO", "E2BIG", "ENOEXEC", "EBADF",
271                             "ECHILD", "EAGAIN", "ENOMEM", "EACCES",
272                             "EFAULT", "ENOTBLK", "EBUSY", "EEXIST",
273                             "EXDEV", "ENODEV", "ENOTDIR", "EISDIR",
274                             "EINVAL", "ENFILE", "EMFILE", "ENOTTY",
275                             "ETXTBSY","EFBIG", "ENOSPC", "ESPIPE",
276                             "EROFS","EMLINK", "EPIPE", "EDOM", "ERANGE" };
277         int i = 0, num = sizeof(err) / sizeof(char *);
278
279         while (i < num) {
280                 if (!strcmp(err[i], str))
281                         return i + 1;
282                 i++;
283         }
284         return 0;
285 }
286
287 static int ignore_error_type(struct thread_data *td, enum error_type_bit etype,
288                                 char *str)
289 {
290         unsigned int i;
291         int *error;
292         char *fname;
293
294         if (etype >= ERROR_TYPE_CNT) {
295                 log_err("Illegal error type\n");
296                 return 1;
297         }
298
299         td->o.ignore_error_nr[etype] = 4;
300         error = calloc(4, sizeof(int));
301
302         i = 0;
303         while ((fname = strsep(&str, ":")) != NULL) {
304
305                 if (!strlen(fname))
306                         break;
307
308                 /*
309                  * grow struct buffer, if needed
310                  */
311                 if (i == td->o.ignore_error_nr[etype]) {
312                         td->o.ignore_error_nr[etype] <<= 1;
313                         error = realloc(error, td->o.ignore_error_nr[etype]
314                                                   * sizeof(int));
315                 }
316                 if (fname[0] == 'E') {
317                         error[i] = str2error(fname);
318                 } else {
319                         error[i] = atoi(fname);
320                         if (error[i] < 0)
321                                 error[i] = -error[i];
322                 }
323                 if (!error[i]) {
324                         log_err("Unknown error %s, please use number value\n",
325                                   fname);
326                         td->o.ignore_error_nr[etype] = 0;
327                         free(error);
328                         return 1;
329                 }
330                 i++;
331         }
332         if (i) {
333                 td->o.continue_on_error |= 1 << etype;
334                 td->o.ignore_error_nr[etype] = i;
335                 td->o.ignore_error[etype] = error;
336         } else {
337                 td->o.ignore_error_nr[etype] = 0;
338                 free(error);
339         }
340
341         return 0;
342
343 }
344
345 static int str_ignore_error_cb(void *data, const char *input)
346 {
347         struct thread_data *td = cb_data_to_td(data);
348         char *str, *p, *n;
349         int ret = 1;
350         enum error_type_bit type = 0;
351
352         if (parse_dryrun())
353                 return 0;
354
355         p = str = strdup(input);
356
357         strip_blank_front(&str);
358         strip_blank_end(str);
359
360         while (p) {
361                 n = strchr(p, ',');
362                 if (n)
363                         *n++ = '\0';
364                 ret = ignore_error_type(td, type, p);
365                 if (ret)
366                         break;
367                 p = n;
368                 type++;
369         }
370         free(str);
371         return ret;
372 }
373
374 static int str_rw_cb(void *data, const char *str)
375 {
376         struct thread_data *td = cb_data_to_td(data);
377         struct thread_options *o = &td->o;
378         char *nr;
379
380         if (parse_dryrun())
381                 return 0;
382
383         o->ddir_seq_nr = 1;
384         o->ddir_seq_add = 0;
385
386         nr = get_opt_postfix(str);
387         if (!nr)
388                 return 0;
389
390         if (td_random(td))
391                 o->ddir_seq_nr = atoi(nr);
392         else {
393                 long long val;
394
395                 if (str_to_decimal(nr, &val, 1, o, 0, 0)) {
396                         log_err("fio: rw postfix parsing failed\n");
397                         free(nr);
398                         return 1;
399                 }
400
401                 o->ddir_seq_add = val;
402         }
403
404         free(nr);
405         return 0;
406 }
407
408 static int str_mem_cb(void *data, const char *mem)
409 {
410         struct thread_data *td = cb_data_to_td(data);
411
412         if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP ||
413             td->o.mem_type == MEM_MMAPSHARED)
414                 td->o.mmapfile = get_opt_postfix(mem);
415
416         return 0;
417 }
418
419 static int fio_clock_source_cb(void *data, const char *str)
420 {
421         struct thread_data *td = cb_data_to_td(data);
422
423         fio_clock_source = td->o.clocksource;
424         fio_clock_source_set = 1;
425         fio_clock_init();
426         return 0;
427 }
428
429 static int str_rwmix_read_cb(void *data, unsigned long long *val)
430 {
431         struct thread_data *td = cb_data_to_td(data);
432
433         td->o.rwmix[DDIR_READ] = *val;
434         td->o.rwmix[DDIR_WRITE] = 100 - *val;
435         return 0;
436 }
437
438 static int str_rwmix_write_cb(void *data, unsigned long long *val)
439 {
440         struct thread_data *td = cb_data_to_td(data);
441
442         td->o.rwmix[DDIR_WRITE] = *val;
443         td->o.rwmix[DDIR_READ] = 100 - *val;
444         return 0;
445 }
446
447 static int str_exitall_cb(void)
448 {
449         exitall_on_terminate = 1;
450         return 0;
451 }
452
453 #ifdef FIO_HAVE_CPU_AFFINITY
454 int fio_cpus_split(os_cpu_mask_t *mask, unsigned int cpu_index)
455 {
456         unsigned int i, index, cpus_in_mask;
457         const long max_cpu = cpus_online();
458
459         cpus_in_mask = fio_cpu_count(mask);
460         cpu_index = cpu_index % cpus_in_mask;
461
462         index = 0;
463         for (i = 0; i < max_cpu; i++) {
464                 if (!fio_cpu_isset(mask, i))
465                         continue;
466
467                 if (cpu_index != index)
468                         fio_cpu_clear(mask, i);
469
470                 index++;
471         }
472
473         return fio_cpu_count(mask);
474 }
475
476 static int str_cpumask_cb(void *data, unsigned long long *val)
477 {
478         struct thread_data *td = cb_data_to_td(data);
479         unsigned int i;
480         long max_cpu;
481         int ret;
482
483         if (parse_dryrun())
484                 return 0;
485
486         ret = fio_cpuset_init(&td->o.cpumask);
487         if (ret < 0) {
488                 log_err("fio: cpuset_init failed\n");
489                 td_verror(td, ret, "fio_cpuset_init");
490                 return 1;
491         }
492
493         max_cpu = cpus_online();
494
495         for (i = 0; i < sizeof(int) * 8; i++) {
496                 if ((1 << i) & *val) {
497                         if (i >= max_cpu) {
498                                 log_err("fio: CPU %d too large (max=%ld)\n", i,
499                                                                 max_cpu - 1);
500                                 return 1;
501                         }
502                         dprint(FD_PARSE, "set cpu allowed %d\n", i);
503                         fio_cpu_set(&td->o.cpumask, i);
504                 }
505         }
506
507         return 0;
508 }
509
510 static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask,
511                             const char *input)
512 {
513         char *cpu, *str, *p;
514         long max_cpu;
515         int ret = 0;
516
517         ret = fio_cpuset_init(mask);
518         if (ret < 0) {
519                 log_err("fio: cpuset_init failed\n");
520                 td_verror(td, ret, "fio_cpuset_init");
521                 return 1;
522         }
523
524         p = str = strdup(input);
525
526         strip_blank_front(&str);
527         strip_blank_end(str);
528
529         max_cpu = cpus_online();
530
531         while ((cpu = strsep(&str, ",")) != NULL) {
532                 char *str2, *cpu2;
533                 int icpu, icpu2;
534
535                 if (!strlen(cpu))
536                         break;
537
538                 str2 = cpu;
539                 icpu2 = -1;
540                 while ((cpu2 = strsep(&str2, "-")) != NULL) {
541                         if (!strlen(cpu2))
542                                 break;
543
544                         icpu2 = atoi(cpu2);
545                 }
546
547                 icpu = atoi(cpu);
548                 if (icpu2 == -1)
549                         icpu2 = icpu;
550                 while (icpu <= icpu2) {
551                         if (icpu >= FIO_MAX_CPUS) {
552                                 log_err("fio: your OS only supports up to"
553                                         " %d CPUs\n", (int) FIO_MAX_CPUS);
554                                 ret = 1;
555                                 break;
556                         }
557                         if (icpu >= max_cpu) {
558                                 log_err("fio: CPU %d too large (max=%ld)\n",
559                                                         icpu, max_cpu - 1);
560                                 ret = 1;
561                                 break;
562                         }
563
564                         dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
565                         fio_cpu_set(mask, icpu);
566                         icpu++;
567                 }
568                 if (ret)
569                         break;
570         }
571
572         free(p);
573         return ret;
574 }
575
576 static int str_cpus_allowed_cb(void *data, const char *input)
577 {
578         struct thread_data *td = cb_data_to_td(data);
579
580         if (parse_dryrun())
581                 return 0;
582
583         return set_cpus_allowed(td, &td->o.cpumask, input);
584 }
585
586 static int str_verify_cpus_allowed_cb(void *data, const char *input)
587 {
588         struct thread_data *td = cb_data_to_td(data);
589
590         if (parse_dryrun())
591                 return 0;
592
593         return set_cpus_allowed(td, &td->o.verify_cpumask, input);
594 }
595
596 #ifdef CONFIG_ZLIB
597 static int str_log_cpus_allowed_cb(void *data, const char *input)
598 {
599         struct thread_data *td = cb_data_to_td(data);
600
601         if (parse_dryrun())
602                 return 0;
603
604         return set_cpus_allowed(td, &td->o.log_gz_cpumask, input);
605 }
606 #endif /* CONFIG_ZLIB */
607
608 #endif /* FIO_HAVE_CPU_AFFINITY */
609
610 #ifdef CONFIG_LIBNUMA
611 static int str_numa_cpunodes_cb(void *data, char *input)
612 {
613         struct thread_data *td = cb_data_to_td(data);
614         struct bitmask *verify_bitmask;
615
616         if (parse_dryrun())
617                 return 0;
618
619         /* numa_parse_nodestring() parses a character string list
620          * of nodes into a bit mask. The bit mask is allocated by
621          * numa_allocate_nodemask(), so it should be freed by
622          * numa_free_nodemask().
623          */
624         verify_bitmask = numa_parse_nodestring(input);
625         if (verify_bitmask == NULL) {
626                 log_err("fio: numa_parse_nodestring failed\n");
627                 td_verror(td, 1, "str_numa_cpunodes_cb");
628                 return 1;
629         }
630         numa_free_nodemask(verify_bitmask);
631
632         td->o.numa_cpunodes = strdup(input);
633         return 0;
634 }
635
636 static int str_numa_mpol_cb(void *data, char *input)
637 {
638         struct thread_data *td = cb_data_to_td(data);
639         const char * const policy_types[] =
640                 { "default", "prefer", "bind", "interleave", "local", NULL };
641         int i;
642         char *nodelist;
643         struct bitmask *verify_bitmask;
644
645         if (parse_dryrun())
646                 return 0;
647
648         nodelist = strchr(input, ':');
649         if (nodelist) {
650                 /* NUL-terminate mode */
651                 *nodelist++ = '\0';
652         }
653
654         for (i = 0; i <= MPOL_LOCAL; i++) {
655                 if (!strcmp(input, policy_types[i])) {
656                         td->o.numa_mem_mode = i;
657                         break;
658                 }
659         }
660         if (i > MPOL_LOCAL) {
661                 log_err("fio: memory policy should be: default, prefer, bind, interleave, local\n");
662                 goto out;
663         }
664
665         switch (td->o.numa_mem_mode) {
666         case MPOL_PREFERRED:
667                 /*
668                  * Insist on a nodelist of one node only
669                  */
670                 if (nodelist) {
671                         char *rest = nodelist;
672                         while (isdigit(*rest))
673                                 rest++;
674                         if (*rest) {
675                                 log_err("fio: one node only for \'prefer\'\n");
676                                 goto out;
677                         }
678                 } else {
679                         log_err("fio: one node is needed for \'prefer\'\n");
680                         goto out;
681                 }
682                 break;
683         case MPOL_INTERLEAVE:
684                 /*
685                  * Default to online nodes with memory if no nodelist
686                  */
687                 if (!nodelist)
688                         nodelist = strdup("all");
689                 break;
690         case MPOL_LOCAL:
691         case MPOL_DEFAULT:
692                 /*
693                  * Don't allow a nodelist
694                  */
695                 if (nodelist) {
696                         log_err("fio: NO nodelist for \'local\'\n");
697                         goto out;
698                 }
699                 break;
700         case MPOL_BIND:
701                 /*
702                  * Insist on a nodelist
703                  */
704                 if (!nodelist) {
705                         log_err("fio: a nodelist is needed for \'bind\'\n");
706                         goto out;
707                 }
708                 break;
709         }
710
711
712         /* numa_parse_nodestring() parses a character string list
713          * of nodes into a bit mask. The bit mask is allocated by
714          * numa_allocate_nodemask(), so it should be freed by
715          * numa_free_nodemask().
716          */
717         switch (td->o.numa_mem_mode) {
718         case MPOL_PREFERRED:
719                 td->o.numa_mem_prefer_node = atoi(nodelist);
720                 break;
721         case MPOL_INTERLEAVE:
722         case MPOL_BIND:
723                 verify_bitmask = numa_parse_nodestring(nodelist);
724                 if (verify_bitmask == NULL) {
725                         log_err("fio: numa_parse_nodestring failed\n");
726                         td_verror(td, 1, "str_numa_memnodes_cb");
727                         return 1;
728                 }
729                 td->o.numa_memnodes = strdup(nodelist);
730                 numa_free_nodemask(verify_bitmask);
731
732                 break;
733         case MPOL_LOCAL:
734         case MPOL_DEFAULT:
735         default:
736                 break;
737         }
738
739         return 0;
740 out:
741         return 1;
742 }
743 #endif
744
745 static int str_fst_cb(void *data, const char *str)
746 {
747         struct thread_data *td = cb_data_to_td(data);
748         double val;
749         bool done = false;
750         char *nr;
751
752         td->file_service_nr = 1;
753
754         switch (td->o.file_service_type) {
755         case FIO_FSERVICE_RANDOM:
756         case FIO_FSERVICE_RR:
757         case FIO_FSERVICE_SEQ:
758                 nr = get_opt_postfix(str);
759                 if (nr) {
760                         td->file_service_nr = atoi(nr);
761                         free(nr);
762                 }
763                 done = true;
764                 break;
765         case FIO_FSERVICE_ZIPF:
766                 val = FIO_DEF_ZIPF;
767                 break;
768         case FIO_FSERVICE_PARETO:
769                 val = FIO_DEF_PARETO;
770                 break;
771         case FIO_FSERVICE_GAUSS:
772                 val = 0.0;
773                 break;
774         default:
775                 log_err("fio: bad file service type: %d\n", td->o.file_service_type);
776                 return 1;
777         }
778
779         if (done)
780                 return 0;
781
782         nr = get_opt_postfix(str);
783         if (nr && !str_to_float(nr, &val, 0)) {
784                 log_err("fio: file service type random postfix parsing failed\n");
785                 free(nr);
786                 return 1;
787         }
788
789         free(nr);
790
791         switch (td->o.file_service_type) {
792         case FIO_FSERVICE_ZIPF:
793                 if (val == 1.00) {
794                         log_err("fio: zipf theta must be different than 1.0\n");
795                         return 1;
796                 }
797                 if (parse_dryrun())
798                         return 0;
799                 td->zipf_theta = val;
800                 break;
801         case FIO_FSERVICE_PARETO:
802                 if (val <= 0.00 || val >= 1.00) {
803                           log_err("fio: pareto input out of range (0 < input < 1.0)\n");
804                           return 1;
805                 }
806                 if (parse_dryrun())
807                         return 0;
808                 td->pareto_h = val;
809                 break;
810         case FIO_FSERVICE_GAUSS:
811                 if (val < 0.00 || val >= 100.00) {
812                           log_err("fio: normal deviation out of range (0 <= input < 100.0)\n");
813                           return 1;
814                 }
815                 if (parse_dryrun())
816                         return 0;
817                 td->gauss_dev = val;
818                 break;
819         }
820
821         return 0;
822 }
823
824 #ifdef CONFIG_SYNC_FILE_RANGE
825 static int str_sfr_cb(void *data, const char *str)
826 {
827         struct thread_data *td = cb_data_to_td(data);
828         char *nr = get_opt_postfix(str);
829
830         td->sync_file_range_nr = 1;
831         if (nr) {
832                 td->sync_file_range_nr = atoi(nr);
833                 free(nr);
834         }
835
836         return 0;
837 }
838 #endif
839
840 static int zone_split_ddir(struct thread_options *o, enum fio_ddir ddir,
841                            char *str, bool absolute)
842 {
843         unsigned int i, perc, perc_missing, sperc, sperc_missing;
844         struct split split;
845
846         memset(&split, 0, sizeof(split));
847
848         if (split_parse_ddir(o, &split, ddir, str, absolute, ZONESPLIT_MAX))
849                 return 1;
850         if (!split.nr)
851                 return 0;
852
853         o->zone_split[ddir] = malloc(split.nr * sizeof(struct zone_split));
854         o->zone_split_nr[ddir] = split.nr;
855         for (i = 0; i < split.nr; i++) {
856                 o->zone_split[ddir][i].access_perc = split.val1[i];
857                 if (absolute)
858                         o->zone_split[ddir][i].size = split.val2[i];
859                 else
860                         o->zone_split[ddir][i].size_perc = split.val2[i];
861         }
862
863         /*
864          * Now check if the percentages add up, and how much is missing
865          */
866         perc = perc_missing = 0;
867         sperc = sperc_missing = 0;
868         for (i = 0; i < o->zone_split_nr[ddir]; i++) {
869                 struct zone_split *zsp = &o->zone_split[ddir][i];
870
871                 if (zsp->access_perc == (uint8_t) -1U)
872                         perc_missing++;
873                 else
874                         perc += zsp->access_perc;
875
876                 if (!absolute) {
877                         if (zsp->size_perc == (uint8_t) -1U)
878                                 sperc_missing++;
879                         else
880                                 sperc += zsp->size_perc;
881                 }
882         }
883
884         if (perc > 100 || sperc > 100) {
885                 log_err("fio: zone_split percentages add to more than 100%%\n");
886                 free(o->zone_split[ddir]);
887                 o->zone_split[ddir] = NULL;
888                 return 1;
889         }
890         if (perc < 100) {
891                 log_err("fio: access percentage don't add up to 100 for zoned "
892                         "random distribution (got=%u)\n", perc);
893                 free(o->zone_split[ddir]);
894                 o->zone_split[ddir] = NULL;
895                 return 1;
896         }
897
898         /*
899          * If values didn't have a percentage set, divide the remains between
900          * them.
901          */
902         if (perc_missing) {
903                 if (perc_missing == 1 && o->zone_split_nr[ddir] == 1)
904                         perc = 100;
905                 for (i = 0; i < o->zone_split_nr[ddir]; i++) {
906                         struct zone_split *zsp = &o->zone_split[ddir][i];
907
908                         if (zsp->access_perc == (uint8_t) -1U)
909                                 zsp->access_perc = (100 - perc) / perc_missing;
910                 }
911         }
912         if (sperc_missing) {
913                 if (sperc_missing == 1 && o->zone_split_nr[ddir] == 1)
914                         sperc = 100;
915                 for (i = 0; i < o->zone_split_nr[ddir]; i++) {
916                         struct zone_split *zsp = &o->zone_split[ddir][i];
917
918                         if (zsp->size_perc == (uint8_t) -1U)
919                                 zsp->size_perc = (100 - sperc) / sperc_missing;
920                 }
921         }
922
923         return 0;
924 }
925
926 static void __td_zone_gen_index(struct thread_data *td, enum fio_ddir ddir)
927 {
928         unsigned int i, j, sprev, aprev;
929         uint64_t sprev_sz;
930
931         td->zone_state_index[ddir] = malloc(sizeof(struct zone_split_index) * 100);
932
933         sprev_sz = sprev = aprev = 0;
934         for (i = 0; i < td->o.zone_split_nr[ddir]; i++) {
935                 struct zone_split *zsp = &td->o.zone_split[ddir][i];
936
937                 for (j = aprev; j < aprev + zsp->access_perc; j++) {
938                         struct zone_split_index *zsi = &td->zone_state_index[ddir][j];
939
940                         zsi->size_perc = sprev + zsp->size_perc;
941                         zsi->size_perc_prev = sprev;
942
943                         zsi->size = sprev_sz + zsp->size;
944                         zsi->size_prev = sprev_sz;
945                 }
946
947                 aprev += zsp->access_perc;
948                 sprev += zsp->size_perc;
949                 sprev_sz += zsp->size;
950         }
951 }
952
953 /*
954  * Generate state table for indexes, so we don't have to do it inline from
955  * the hot IO path
956  */
957 static void td_zone_gen_index(struct thread_data *td)
958 {
959         int i;
960
961         td->zone_state_index = malloc(DDIR_RWDIR_CNT *
962                                         sizeof(struct zone_split_index *));
963
964         for (i = 0; i < DDIR_RWDIR_CNT; i++)
965                 __td_zone_gen_index(td, i);
966 }
967
968 static int parse_zoned_distribution(struct thread_data *td, const char *input,
969                                     bool absolute)
970 {
971         const char *pre = absolute ? "zoned_abs:" : "zoned:";
972         char *str, *p;
973         int i, ret = 0;
974
975         p = str = strdup(input);
976
977         strip_blank_front(&str);
978         strip_blank_end(str);
979
980         /* We expect it to start like that, bail if not */
981         if (strncmp(str, pre, strlen(pre))) {
982                 log_err("fio: mismatch in zoned input <%s>\n", str);
983                 free(p);
984                 return 1;
985         }
986         str += strlen(pre);
987
988         ret = str_split_parse(td, str, zone_split_ddir, absolute);
989
990         free(p);
991
992         for (i = 0; i < DDIR_RWDIR_CNT; i++) {
993                 int j;
994
995                 dprint(FD_PARSE, "zone ddir %d (nr=%u): \n", i, td->o.zone_split_nr[i]);
996
997                 for (j = 0; j < td->o.zone_split_nr[i]; j++) {
998                         struct zone_split *zsp = &td->o.zone_split[i][j];
999
1000                         if (absolute) {
1001                                 dprint(FD_PARSE, "\t%d: %u/%llu\n", j,
1002                                                 zsp->access_perc,
1003                                                 (unsigned long long) zsp->size);
1004                         } else {
1005                                 dprint(FD_PARSE, "\t%d: %u/%u\n", j,
1006                                                 zsp->access_perc,
1007                                                 zsp->size_perc);
1008                         }
1009                 }
1010         }
1011
1012         if (parse_dryrun()) {
1013                 int i;
1014
1015                 for (i = 0; i < DDIR_RWDIR_CNT; i++) {
1016                         free(td->o.zone_split[i]);
1017                         td->o.zone_split[i] = NULL;
1018                         td->o.zone_split_nr[i] = 0;
1019                 }
1020
1021                 return ret;
1022         }
1023
1024         if (!ret)
1025                 td_zone_gen_index(td);
1026         else {
1027                 for (i = 0; i < DDIR_RWDIR_CNT; i++)
1028                         td->o.zone_split_nr[i] = 0;
1029         }
1030
1031         return ret;
1032 }
1033
1034 static int str_random_distribution_cb(void *data, const char *str)
1035 {
1036         struct thread_data *td = cb_data_to_td(data);
1037         double val;
1038         char *nr;
1039
1040         if (td->o.random_distribution == FIO_RAND_DIST_ZIPF)
1041                 val = FIO_DEF_ZIPF;
1042         else if (td->o.random_distribution == FIO_RAND_DIST_PARETO)
1043                 val = FIO_DEF_PARETO;
1044         else if (td->o.random_distribution == FIO_RAND_DIST_GAUSS)
1045                 val = 0.0;
1046         else if (td->o.random_distribution == FIO_RAND_DIST_ZONED)
1047                 return parse_zoned_distribution(td, str, false);
1048         else if (td->o.random_distribution == FIO_RAND_DIST_ZONED_ABS)
1049                 return parse_zoned_distribution(td, str, true);
1050         else
1051                 return 0;
1052
1053         nr = get_opt_postfix(str);
1054         if (nr && !str_to_float(nr, &val, 0)) {
1055                 log_err("fio: random postfix parsing failed\n");
1056                 free(nr);
1057                 return 1;
1058         }
1059
1060         free(nr);
1061
1062         if (td->o.random_distribution == FIO_RAND_DIST_ZIPF) {
1063                 if (val == 1.00) {
1064                         log_err("fio: zipf theta must different than 1.0\n");
1065                         return 1;
1066                 }
1067                 if (parse_dryrun())
1068                         return 0;
1069                 td->o.zipf_theta.u.f = val;
1070         } else if (td->o.random_distribution == FIO_RAND_DIST_PARETO) {
1071                 if (val <= 0.00 || val >= 1.00) {
1072                         log_err("fio: pareto input out of range (0 < input < 1.0)\n");
1073                         return 1;
1074                 }
1075                 if (parse_dryrun())
1076                         return 0;
1077                 td->o.pareto_h.u.f = val;
1078         } else {
1079                 if (val < 0.00 || val >= 100.0) {
1080                         log_err("fio: normal deviation out of range (0 <= input < 100.0)\n");
1081                         return 1;
1082                 }
1083                 if (parse_dryrun())
1084                         return 0;
1085                 td->o.gauss_dev.u.f = val;
1086         }
1087
1088         return 0;
1089 }
1090
1091 static int str_steadystate_cb(void *data, const char *str)
1092 {
1093         struct thread_data *td = cb_data_to_td(data);
1094         double val;
1095         char *nr;
1096         char *pct;
1097         long long ll;
1098
1099         if (td->o.ss_state != FIO_SS_IOPS && td->o.ss_state != FIO_SS_IOPS_SLOPE &&
1100             td->o.ss_state != FIO_SS_BW && td->o.ss_state != FIO_SS_BW_SLOPE) {
1101                 /* should be impossible to get here */
1102                 log_err("fio: unknown steady state criterion\n");
1103                 return 1;
1104         }
1105
1106         nr = get_opt_postfix(str);
1107         if (!nr) {
1108                 log_err("fio: steadystate threshold must be specified in addition to criterion\n");
1109                 free(nr);
1110                 return 1;
1111         }
1112
1113         /* ENHANCEMENT Allow fio to understand size=10.2% and use here */
1114         pct = strstr(nr, "%");
1115         if (pct) {
1116                 *pct = '\0';
1117                 strip_blank_end(nr);
1118                 if (!str_to_float(nr, &val, 0)) {
1119                         log_err("fio: could not parse steadystate threshold percentage\n");
1120                         free(nr);
1121                         return 1;
1122                 }
1123
1124                 dprint(FD_PARSE, "set steady state threshold to %f%%\n", val);
1125                 free(nr);
1126                 if (parse_dryrun())
1127                         return 0;
1128
1129                 td->o.ss_state |= FIO_SS_PCT;
1130                 td->o.ss_limit.u.f = val;
1131         } else if (td->o.ss_state & FIO_SS_IOPS) {
1132                 if (!str_to_float(nr, &val, 0)) {
1133                         log_err("fio: steadystate IOPS threshold postfix parsing failed\n");
1134                         free(nr);
1135                         return 1;
1136                 }
1137
1138                 dprint(FD_PARSE, "set steady state IOPS threshold to %f\n", val);
1139                 free(nr);
1140                 if (parse_dryrun())
1141                         return 0;
1142
1143                 td->o.ss_limit.u.f = val;
1144         } else {        /* bandwidth criterion */
1145                 if (str_to_decimal(nr, &ll, 1, td, 0, 0)) {
1146                         log_err("fio: steadystate BW threshold postfix parsing failed\n");
1147                         free(nr);
1148                         return 1;
1149                 }
1150
1151                 dprint(FD_PARSE, "set steady state BW threshold to %lld\n", ll);
1152                 free(nr);
1153                 if (parse_dryrun())
1154                         return 0;
1155
1156                 td->o.ss_limit.u.f = (double) ll;
1157         }
1158
1159         td->ss.state = td->o.ss_state;
1160         return 0;
1161 }
1162
1163 /*
1164  * Return next name in the string. Files are separated with ':'. If the ':'
1165  * is escaped with a '\', then that ':' is part of the filename and does not
1166  * indicate a new file.
1167  */
1168 static char *get_next_name(char **ptr)
1169 {
1170         char *str = *ptr;
1171         char *p, *start;
1172
1173         if (!str || !strlen(str))
1174                 return NULL;
1175
1176         start = str;
1177         do {
1178                 /*
1179                  * No colon, we are done
1180                  */
1181                 p = strchr(str, ':');
1182                 if (!p) {
1183                         *ptr = NULL;
1184                         break;
1185                 }
1186
1187                 /*
1188                  * We got a colon, but it's the first character. Skip and
1189                  * continue
1190                  */
1191                 if (p == start) {
1192                         str = ++start;
1193                         continue;
1194                 }
1195
1196                 if (*(p - 1) != '\\') {
1197                         *p = '\0';
1198                         *ptr = p + 1;
1199                         break;
1200                 }
1201
1202                 memmove(p - 1, p, strlen(p) + 1);
1203                 str = p;
1204         } while (1);
1205
1206         return start;
1207 }
1208
1209
1210 static int get_max_name_idx(char *input)
1211 {
1212         unsigned int cur_idx;
1213         char *str, *p;
1214
1215         p = str = strdup(input);
1216         for (cur_idx = 0; ; cur_idx++)
1217                 if (get_next_name(&str) == NULL)
1218                         break;
1219
1220         free(p);
1221         return cur_idx;
1222 }
1223
1224 /*
1225  * Returns the directory at the index, indexes > entires will be
1226  * assigned via modulo division of the index
1227  */
1228 int set_name_idx(char *target, size_t tlen, char *input, int index,
1229                  bool unique_filename)
1230 {
1231         unsigned int cur_idx;
1232         int len;
1233         char *fname, *str, *p;
1234
1235         p = str = strdup(input);
1236
1237         index %= get_max_name_idx(input);
1238         for (cur_idx = 0; cur_idx <= index; cur_idx++)
1239                 fname = get_next_name(&str);
1240
1241         if (client_sockaddr_str[0] && unique_filename) {
1242                 len = snprintf(target, tlen, "%s/%s.", fname,
1243                                 client_sockaddr_str);
1244         } else
1245                 len = snprintf(target, tlen, "%s/", fname);
1246
1247         target[tlen - 1] = '\0';
1248         free(p);
1249
1250         return len;
1251 }
1252
1253 static int str_filename_cb(void *data, const char *input)
1254 {
1255         struct thread_data *td = cb_data_to_td(data);
1256         char *fname, *str, *p;
1257
1258         p = str = strdup(input);
1259
1260         strip_blank_front(&str);
1261         strip_blank_end(str);
1262
1263         /*
1264          * Ignore what we may already have from nrfiles option.
1265          */
1266         if (!td->files_index)
1267                 td->o.nr_files = 0;
1268
1269         while ((fname = get_next_name(&str)) != NULL) {
1270                 if (!strlen(fname))
1271                         break;
1272                 add_file(td, fname, 0, 1);
1273         }
1274
1275         free(p);
1276         return 0;
1277 }
1278
1279 static int str_directory_cb(void *data, const char fio_unused *unused)
1280 {
1281         struct thread_data *td = cb_data_to_td(data);
1282         struct stat sb;
1283         char *dirname, *str, *p;
1284         int ret = 0;
1285
1286         if (parse_dryrun())
1287                 return 0;
1288
1289         p = str = strdup(td->o.directory);
1290         while ((dirname = get_next_name(&str)) != NULL) {
1291                 if (lstat(dirname, &sb) < 0) {
1292                         ret = errno;
1293
1294                         log_err("fio: %s is not a directory\n", dirname);
1295                         td_verror(td, ret, "lstat");
1296                         goto out;
1297                 }
1298                 if (!S_ISDIR(sb.st_mode)) {
1299                         log_err("fio: %s is not a directory\n", dirname);
1300                         ret = 1;
1301                         goto out;
1302                 }
1303         }
1304
1305 out:
1306         free(p);
1307         return ret;
1308 }
1309
1310 static int str_opendir_cb(void *data, const char fio_unused *str)
1311 {
1312         struct thread_data *td = cb_data_to_td(data);
1313
1314         if (parse_dryrun())
1315                 return 0;
1316
1317         if (!td->files_index)
1318                 td->o.nr_files = 0;
1319
1320         return add_dir_files(td, td->o.opendir);
1321 }
1322
1323 static int str_buffer_pattern_cb(void *data, const char *input)
1324 {
1325         struct thread_data *td = cb_data_to_td(data);
1326         int ret;
1327
1328         /* FIXME: for now buffer pattern does not support formats */
1329         ret = parse_and_fill_pattern(input, strlen(input), td->o.buffer_pattern,
1330                                      MAX_PATTERN_SIZE, NULL, 0, NULL, NULL);
1331         if (ret < 0)
1332                 return 1;
1333
1334         assert(ret != 0);
1335         td->o.buffer_pattern_bytes = ret;
1336
1337         /*
1338          * If this job is doing any reading or has compression set,
1339          * ensure that we refill buffers for writes or we could be
1340          * invalidating the pattern through reads.
1341          */
1342         if (!td->o.compress_percentage && !td_read(td))
1343                 td->o.refill_buffers = 0;
1344         else
1345                 td->o.refill_buffers = 1;
1346
1347         td->o.scramble_buffers = 0;
1348         td->o.zero_buffers = 0;
1349
1350         return 0;
1351 }
1352
1353 static int str_buffer_compress_cb(void *data, unsigned long long *il)
1354 {
1355         struct thread_data *td = cb_data_to_td(data);
1356
1357         td->flags |= TD_F_COMPRESS;
1358         td->o.compress_percentage = *il;
1359         return 0;
1360 }
1361
1362 static int str_dedupe_cb(void *data, unsigned long long *il)
1363 {
1364         struct thread_data *td = cb_data_to_td(data);
1365
1366         td->flags |= TD_F_COMPRESS;
1367         td->o.dedupe_percentage = *il;
1368         td->o.refill_buffers = 1;
1369         return 0;
1370 }
1371
1372 static int str_verify_pattern_cb(void *data, const char *input)
1373 {
1374         struct thread_data *td = cb_data_to_td(data);
1375         int ret;
1376
1377         td->o.verify_fmt_sz = ARRAY_SIZE(td->o.verify_fmt);
1378         ret = parse_and_fill_pattern(input, strlen(input), td->o.verify_pattern,
1379                                      MAX_PATTERN_SIZE, fmt_desc, sizeof(fmt_desc),
1380                                      td->o.verify_fmt, &td->o.verify_fmt_sz);
1381         if (ret < 0)
1382                 return 1;
1383
1384         assert(ret != 0);
1385         td->o.verify_pattern_bytes = ret;
1386         /*
1387          * VERIFY_* could already be set
1388          */
1389         if (!fio_option_is_set(&td->o, verify))
1390                 td->o.verify = VERIFY_PATTERN;
1391
1392         return 0;
1393 }
1394
1395 static int str_gtod_reduce_cb(void *data, int *il)
1396 {
1397         struct thread_data *td = cb_data_to_td(data);
1398         int val = *il;
1399
1400         td->o.disable_lat = !!val;
1401         td->o.disable_clat = !!val;
1402         td->o.disable_slat = !!val;
1403         td->o.disable_bw = !!val;
1404         td->o.clat_percentiles = !val;
1405         if (val)
1406                 td->ts_cache_mask = 63;
1407
1408         return 0;
1409 }
1410
1411 static int str_offset_cb(void *data, unsigned long long *__val)
1412 {
1413         struct thread_data *td = cb_data_to_td(data);
1414         unsigned long long v = *__val;
1415
1416         if (parse_is_percent(v)) {
1417                 td->o.start_offset = 0;
1418                 td->o.start_offset_percent = -1ULL - v;
1419                 dprint(FD_PARSE, "SET start_offset_percent %d\n",
1420                                         td->o.start_offset_percent);
1421         } else
1422                 td->o.start_offset = v;
1423
1424         return 0;
1425 }
1426
1427 static int str_size_cb(void *data, unsigned long long *__val)
1428 {
1429         struct thread_data *td = cb_data_to_td(data);
1430         unsigned long long v = *__val;
1431
1432         if (parse_is_percent(v)) {
1433                 td->o.size = 0;
1434                 td->o.size_percent = -1ULL - v;
1435                 dprint(FD_PARSE, "SET size_percent %d\n",
1436                                         td->o.size_percent);
1437         } else
1438                 td->o.size = v;
1439
1440         return 0;
1441 }
1442
1443 static int str_write_bw_log_cb(void *data, const char *str)
1444 {
1445         struct thread_data *td = cb_data_to_td(data);
1446
1447         if (str)
1448                 td->o.bw_log_file = strdup(str);
1449
1450         td->o.write_bw_log = 1;
1451         return 0;
1452 }
1453
1454 static int str_write_lat_log_cb(void *data, const char *str)
1455 {
1456         struct thread_data *td = cb_data_to_td(data);
1457
1458         if (str)
1459                 td->o.lat_log_file = strdup(str);
1460
1461         td->o.write_lat_log = 1;
1462         return 0;
1463 }
1464
1465 static int str_write_iops_log_cb(void *data, const char *str)
1466 {
1467         struct thread_data *td = cb_data_to_td(data);
1468
1469         if (str)
1470                 td->o.iops_log_file = strdup(str);
1471
1472         td->o.write_iops_log = 1;
1473         return 0;
1474 }
1475
1476 static int str_write_hist_log_cb(void *data, const char *str)
1477 {
1478         struct thread_data *td = cb_data_to_td(data);
1479
1480         if (str)
1481                 td->o.hist_log_file = strdup(str);
1482
1483         td->o.write_hist_log = 1;
1484         return 0;
1485 }
1486
1487 /*
1488  * str is supposed to be a substring of the strdup'd original string,
1489  * and is valid only if it's a regular file path.
1490  * This function keeps the pointer to the path as needed later.
1491  *
1492  * "external:/path/to/so\0" <- original pointer updated with strdup'd
1493  * "external\0"             <- above pointer after parsed, i.e. ->ioengine
1494  *          "/path/to/so\0" <- str argument, i.e. ->ioengine_so_path
1495  */
1496 static int str_ioengine_external_cb(void *data, const char *str)
1497 {
1498         struct thread_data *td = cb_data_to_td(data);
1499         struct stat sb;
1500         char *p;
1501
1502         if (!str) {
1503                 log_err("fio: null external ioengine path\n");
1504                 return 1;
1505         }
1506
1507         p = (char *)str; /* str is mutable */
1508         strip_blank_front(&p);
1509         strip_blank_end(p);
1510
1511         if (stat(p, &sb) || !S_ISREG(sb.st_mode)) {
1512                 log_err("fio: invalid external ioengine path \"%s\"\n", p);
1513                 return 1;
1514         }
1515
1516         td->o.ioengine_so_path = p;
1517         return 0;
1518 }
1519
1520 static int rw_verify(const struct fio_option *o, void *data)
1521 {
1522         struct thread_data *td = cb_data_to_td(data);
1523
1524         if (read_only && td_write(td)) {
1525                 log_err("fio: job <%s> has write bit set, but fio is in"
1526                         " read-only mode\n", td->o.name);
1527                 return 1;
1528         }
1529
1530         return 0;
1531 }
1532
1533 static int gtod_cpu_verify(const struct fio_option *o, void *data)
1534 {
1535 #ifndef FIO_HAVE_CPU_AFFINITY
1536         struct thread_data *td = cb_data_to_td(data);
1537
1538         if (td->o.gtod_cpu) {
1539                 log_err("fio: platform must support CPU affinity for"
1540                         "gettimeofday() offloading\n");
1541                 return 1;
1542         }
1543 #endif
1544
1545         return 0;
1546 }
1547
1548 /*
1549  * Map of job/command line options
1550  */
1551 struct fio_option fio_options[FIO_MAX_OPTS] = {
1552         {
1553                 .name   = "description",
1554                 .lname  = "Description of job",
1555                 .type   = FIO_OPT_STR_STORE,
1556                 .off1   = offsetof(struct thread_options, description),
1557                 .help   = "Text job description",
1558                 .category = FIO_OPT_C_GENERAL,
1559                 .group  = FIO_OPT_G_DESC,
1560         },
1561         {
1562                 .name   = "name",
1563                 .lname  = "Job name",
1564                 .type   = FIO_OPT_STR_STORE,
1565                 .off1   = offsetof(struct thread_options, name),
1566                 .help   = "Name of this job",
1567                 .category = FIO_OPT_C_GENERAL,
1568                 .group  = FIO_OPT_G_DESC,
1569         },
1570         {
1571                 .name   = "wait_for",
1572                 .lname  = "Waitee name",
1573                 .type   = FIO_OPT_STR_STORE,
1574                 .off1   = offsetof(struct thread_options, wait_for),
1575                 .help   = "Name of the job this one wants to wait for before starting",
1576                 .category = FIO_OPT_C_GENERAL,
1577                 .group  = FIO_OPT_G_DESC,
1578         },
1579         {
1580                 .name   = "filename",
1581                 .lname  = "Filename(s)",
1582                 .type   = FIO_OPT_STR_STORE,
1583                 .off1   = offsetof(struct thread_options, filename),
1584                 .cb     = str_filename_cb,
1585                 .prio   = -1, /* must come after "directory" */
1586                 .help   = "File(s) to use for the workload",
1587                 .category = FIO_OPT_C_FILE,
1588                 .group  = FIO_OPT_G_FILENAME,
1589         },
1590         {
1591                 .name   = "directory",
1592                 .lname  = "Directory",
1593                 .type   = FIO_OPT_STR_STORE,
1594                 .off1   = offsetof(struct thread_options, directory),
1595                 .cb     = str_directory_cb,
1596                 .help   = "Directory to store files in",
1597                 .category = FIO_OPT_C_FILE,
1598                 .group  = FIO_OPT_G_FILENAME,
1599         },
1600         {
1601                 .name   = "filename_format",
1602                 .lname  = "Filename Format",
1603                 .type   = FIO_OPT_STR_STORE,
1604                 .off1   = offsetof(struct thread_options, filename_format),
1605                 .prio   = -1, /* must come after "directory" */
1606                 .help   = "Override default $jobname.$jobnum.$filenum naming",
1607                 .def    = "$jobname.$jobnum.$filenum",
1608                 .category = FIO_OPT_C_FILE,
1609                 .group  = FIO_OPT_G_FILENAME,
1610         },
1611         {
1612                 .name   = "unique_filename",
1613                 .lname  = "Unique Filename",
1614                 .type   = FIO_OPT_BOOL,
1615                 .off1   = offsetof(struct thread_options, unique_filename),
1616                 .help   = "For network clients, prefix file with source IP",
1617                 .def    = "1",
1618                 .category = FIO_OPT_C_FILE,
1619                 .group  = FIO_OPT_G_FILENAME,
1620         },
1621         {
1622                 .name   = "lockfile",
1623                 .lname  = "Lockfile",
1624                 .type   = FIO_OPT_STR,
1625                 .off1   = offsetof(struct thread_options, file_lock_mode),
1626                 .help   = "Lock file when doing IO to it",
1627                 .prio   = 1,
1628                 .parent = "filename",
1629                 .hide   = 0,
1630                 .def    = "none",
1631                 .category = FIO_OPT_C_FILE,
1632                 .group  = FIO_OPT_G_FILENAME,
1633                 .posval = {
1634                           { .ival = "none",
1635                             .oval = FILE_LOCK_NONE,
1636                             .help = "No file locking",
1637                           },
1638                           { .ival = "exclusive",
1639                             .oval = FILE_LOCK_EXCLUSIVE,
1640                             .help = "Exclusive file lock",
1641                           },
1642                           {
1643                             .ival = "readwrite",
1644                             .oval = FILE_LOCK_READWRITE,
1645                             .help = "Read vs write lock",
1646                           },
1647                 },
1648         },
1649         {
1650                 .name   = "opendir",
1651                 .lname  = "Open directory",
1652                 .type   = FIO_OPT_STR_STORE,
1653                 .off1   = offsetof(struct thread_options, opendir),
1654                 .cb     = str_opendir_cb,
1655                 .help   = "Recursively add files from this directory and down",
1656                 .category = FIO_OPT_C_FILE,
1657                 .group  = FIO_OPT_G_FILENAME,
1658         },
1659         {
1660                 .name   = "rw",
1661                 .lname  = "Read/write",
1662                 .alias  = "readwrite",
1663                 .type   = FIO_OPT_STR,
1664                 .cb     = str_rw_cb,
1665                 .off1   = offsetof(struct thread_options, td_ddir),
1666                 .help   = "IO direction",
1667                 .def    = "read",
1668                 .verify = rw_verify,
1669                 .category = FIO_OPT_C_IO,
1670                 .group  = FIO_OPT_G_IO_BASIC,
1671                 .posval = {
1672                           { .ival = "read",
1673                             .oval = TD_DDIR_READ,
1674                             .help = "Sequential read",
1675                           },
1676                           { .ival = "write",
1677                             .oval = TD_DDIR_WRITE,
1678                             .help = "Sequential write",
1679                           },
1680                           { .ival = "trim",
1681                             .oval = TD_DDIR_TRIM,
1682                             .help = "Sequential trim",
1683                           },
1684                           { .ival = "randread",
1685                             .oval = TD_DDIR_RANDREAD,
1686                             .help = "Random read",
1687                           },
1688                           { .ival = "randwrite",
1689                             .oval = TD_DDIR_RANDWRITE,
1690                             .help = "Random write",
1691                           },
1692                           { .ival = "randtrim",
1693                             .oval = TD_DDIR_RANDTRIM,
1694                             .help = "Random trim",
1695                           },
1696                           { .ival = "rw",
1697                             .oval = TD_DDIR_RW,
1698                             .help = "Sequential read and write mix",
1699                           },
1700                           { .ival = "readwrite",
1701                             .oval = TD_DDIR_RW,
1702                             .help = "Sequential read and write mix",
1703                           },
1704                           { .ival = "randrw",
1705                             .oval = TD_DDIR_RANDRW,
1706                             .help = "Random read and write mix"
1707                           },
1708                           { .ival = "trimwrite",
1709                             .oval = TD_DDIR_TRIMWRITE,
1710                             .help = "Trim and write mix, trims preceding writes"
1711                           },
1712                 },
1713         },
1714         {
1715                 .name   = "rw_sequencer",
1716                 .lname  = "RW Sequencer",
1717                 .type   = FIO_OPT_STR,
1718                 .off1   = offsetof(struct thread_options, rw_seq),
1719                 .help   = "IO offset generator modifier",
1720                 .def    = "sequential",
1721                 .category = FIO_OPT_C_IO,
1722                 .group  = FIO_OPT_G_IO_BASIC,
1723                 .posval = {
1724                           { .ival = "sequential",
1725                             .oval = RW_SEQ_SEQ,
1726                             .help = "Generate sequential offsets",
1727                           },
1728                           { .ival = "identical",
1729                             .oval = RW_SEQ_IDENT,
1730                             .help = "Generate identical offsets",
1731                           },
1732                 },
1733         },
1734
1735         {
1736                 .name   = "ioengine",
1737                 .lname  = "IO Engine",
1738                 .type   = FIO_OPT_STR_STORE,
1739                 .off1   = offsetof(struct thread_options, ioengine),
1740                 .help   = "IO engine to use",
1741                 .def    = FIO_PREFERRED_ENGINE,
1742                 .category = FIO_OPT_C_IO,
1743                 .group  = FIO_OPT_G_IO_BASIC,
1744                 .posval = {
1745                           { .ival = "sync",
1746                             .help = "Use read/write",
1747                           },
1748                           { .ival = "psync",
1749                             .help = "Use pread/pwrite",
1750                           },
1751                           { .ival = "vsync",
1752                             .help = "Use readv/writev",
1753                           },
1754 #ifdef CONFIG_PWRITEV
1755                           { .ival = "pvsync",
1756                             .help = "Use preadv/pwritev",
1757                           },
1758 #endif
1759 #ifdef FIO_HAVE_PWRITEV2
1760                           { .ival = "pvsync2",
1761                             .help = "Use preadv2/pwritev2",
1762                           },
1763 #endif
1764 #ifdef CONFIG_LIBAIO
1765                           { .ival = "libaio",
1766                             .help = "Linux native asynchronous IO",
1767                           },
1768 #endif
1769 #ifdef CONFIG_POSIXAIO
1770                           { .ival = "posixaio",
1771                             .help = "POSIX asynchronous IO",
1772                           },
1773 #endif
1774 #ifdef CONFIG_SOLARISAIO
1775                           { .ival = "solarisaio",
1776                             .help = "Solaris native asynchronous IO",
1777                           },
1778 #endif
1779 #ifdef CONFIG_WINDOWSAIO
1780                           { .ival = "windowsaio",
1781                             .help = "Windows native asynchronous IO"
1782                           },
1783 #endif
1784 #ifdef CONFIG_RBD
1785                           { .ival = "rbd",
1786                             .help = "Rados Block Device asynchronous IO"
1787                           },
1788 #endif
1789                           { .ival = "mmap",
1790                             .help = "Memory mapped IO"
1791                           },
1792 #ifdef CONFIG_LINUX_SPLICE
1793                           { .ival = "splice",
1794                             .help = "splice/vmsplice based IO",
1795                           },
1796                           { .ival = "netsplice",
1797                             .help = "splice/vmsplice to/from the network",
1798                           },
1799 #endif
1800 #ifdef FIO_HAVE_SGIO
1801                           { .ival = "sg",
1802                             .help = "SCSI generic v3 IO",
1803                           },
1804 #endif
1805                           { .ival = "null",
1806                             .help = "Testing engine (no data transfer)",
1807                           },
1808                           { .ival = "net",
1809                             .help = "Network IO",
1810                           },
1811                           { .ival = "cpuio",
1812                             .help = "CPU cycle burner engine",
1813                           },
1814 #ifdef CONFIG_GUASI
1815                           { .ival = "guasi",
1816                             .help = "GUASI IO engine",
1817                           },
1818 #endif
1819 #ifdef CONFIG_RDMA
1820                           { .ival = "rdma",
1821                             .help = "RDMA IO engine",
1822                           },
1823 #endif
1824 #ifdef CONFIG_FUSION_AW
1825                           { .ival = "fusion-aw-sync",
1826                             .help = "Fusion-io atomic write engine",
1827                           },
1828 #endif
1829 #ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
1830                           { .ival = "e4defrag",
1831                             .help = "ext4 defrag engine",
1832                           },
1833 #endif
1834 #ifdef CONFIG_LINUX_FALLOCATE
1835                           { .ival = "falloc",
1836                             .help = "fallocate() file based engine",
1837                           },
1838 #endif
1839 #ifdef CONFIG_GFAPI
1840                           { .ival = "gfapi",
1841                             .help = "Glusterfs libgfapi(sync) based engine"
1842                           },
1843                           { .ival = "gfapi_async",
1844                             .help = "Glusterfs libgfapi(async) based engine"
1845                           },
1846 #endif
1847 #ifdef CONFIG_LIBHDFS
1848                           { .ival = "libhdfs",
1849                             .help = "Hadoop Distributed Filesystem (HDFS) engine"
1850                           },
1851 #endif
1852 #ifdef CONFIG_PMEMBLK
1853                           { .ival = "pmemblk",
1854                             .help = "PMDK libpmemblk based IO engine",
1855                           },
1856
1857 #endif
1858 #ifdef CONFIG_LINUX_DEVDAX
1859                           { .ival = "dev-dax",
1860                             .help = "DAX Device based IO engine",
1861                           },
1862 #endif
1863                           {
1864                             .ival = "filecreate",
1865                             .help = "File creation engine",
1866                           },
1867                           { .ival = "external",
1868                             .help = "Load external engine (append name)",
1869                             .cb = str_ioengine_external_cb,
1870                           },
1871 #ifdef CONFIG_LIBPMEM
1872                           { .ival = "libpmem",
1873                             .help = "PMDK libpmem based IO engine",
1874                           },
1875 #endif
1876                 },
1877         },
1878         {
1879                 .name   = "iodepth",
1880                 .lname  = "IO Depth",
1881                 .type   = FIO_OPT_INT,
1882                 .off1   = offsetof(struct thread_options, iodepth),
1883                 .help   = "Number of IO buffers to keep in flight",
1884                 .minval = 1,
1885                 .interval = 1,
1886                 .def    = "1",
1887                 .category = FIO_OPT_C_IO,
1888                 .group  = FIO_OPT_G_IO_BASIC,
1889         },
1890         {
1891                 .name   = "iodepth_batch",
1892                 .lname  = "IO Depth batch",
1893                 .alias  = "iodepth_batch_submit",
1894                 .type   = FIO_OPT_INT,
1895                 .off1   = offsetof(struct thread_options, iodepth_batch),
1896                 .help   = "Number of IO buffers to submit in one go",
1897                 .parent = "iodepth",
1898                 .hide   = 1,
1899                 .interval = 1,
1900                 .def    = "1",
1901                 .category = FIO_OPT_C_IO,
1902                 .group  = FIO_OPT_G_IO_BASIC,
1903         },
1904         {
1905                 .name   = "iodepth_batch_complete_min",
1906                 .lname  = "Min IO depth batch complete",
1907                 .alias  = "iodepth_batch_complete",
1908                 .type   = FIO_OPT_INT,
1909                 .off1   = offsetof(struct thread_options, iodepth_batch_complete_min),
1910                 .help   = "Min number of IO buffers to retrieve in one go",
1911                 .parent = "iodepth",
1912                 .hide   = 1,
1913                 .minval = 0,
1914                 .interval = 1,
1915                 .def    = "1",
1916                 .category = FIO_OPT_C_IO,
1917                 .group  = FIO_OPT_G_IO_BASIC,
1918         },
1919         {
1920                 .name   = "iodepth_batch_complete_max",
1921                 .lname  = "Max IO depth batch complete",
1922                 .type   = FIO_OPT_INT,
1923                 .off1   = offsetof(struct thread_options, iodepth_batch_complete_max),
1924                 .help   = "Max number of IO buffers to retrieve in one go",
1925                 .parent = "iodepth",
1926                 .hide   = 1,
1927                 .minval = 0,
1928                 .interval = 1,
1929                 .category = FIO_OPT_C_IO,
1930                 .group  = FIO_OPT_G_IO_BASIC,
1931         },
1932         {
1933                 .name   = "iodepth_low",
1934                 .lname  = "IO Depth batch low",
1935                 .type   = FIO_OPT_INT,
1936                 .off1   = offsetof(struct thread_options, iodepth_low),
1937                 .help   = "Low water mark for queuing depth",
1938                 .parent = "iodepth",
1939                 .hide   = 1,
1940                 .interval = 1,
1941                 .category = FIO_OPT_C_IO,
1942                 .group  = FIO_OPT_G_IO_BASIC,
1943         },
1944         {
1945                 .name   = "serialize_overlap",
1946                 .lname  = "Serialize overlap",
1947                 .off1   = offsetof(struct thread_options, serialize_overlap),
1948                 .type   = FIO_OPT_BOOL,
1949                 .help   = "Wait for in-flight IOs that collide to complete",
1950                 .parent = "iodepth",
1951                 .def    = "0",
1952                 .category = FIO_OPT_C_IO,
1953                 .group  = FIO_OPT_G_IO_BASIC,
1954         },
1955         {
1956                 .name   = "io_submit_mode",
1957                 .lname  = "IO submit mode",
1958                 .type   = FIO_OPT_STR,
1959                 .off1   = offsetof(struct thread_options, io_submit_mode),
1960                 .help   = "How IO submissions and completions are done",
1961                 .def    = "inline",
1962                 .category = FIO_OPT_C_IO,
1963                 .group  = FIO_OPT_G_IO_BASIC,
1964                 .posval = {
1965                           { .ival = "inline",
1966                             .oval = IO_MODE_INLINE,
1967                             .help = "Submit and complete IO inline",
1968                           },
1969                           { .ival = "offload",
1970                             .oval = IO_MODE_OFFLOAD,
1971                             .help = "Offload submit and complete to threads",
1972                           },
1973                 },
1974         },
1975         {
1976                 .name   = "size",
1977                 .lname  = "Size",
1978                 .type   = FIO_OPT_STR_VAL,
1979                 .cb     = str_size_cb,
1980                 .off1   = offsetof(struct thread_options, size),
1981                 .help   = "Total size of device or files",
1982                 .interval = 1024 * 1024,
1983                 .category = FIO_OPT_C_IO,
1984                 .group  = FIO_OPT_G_INVALID,
1985         },
1986         {
1987                 .name   = "io_size",
1988                 .alias  = "io_limit",
1989                 .lname  = "IO Size",
1990                 .type   = FIO_OPT_STR_VAL,
1991                 .off1   = offsetof(struct thread_options, io_size),
1992                 .help   = "Total size of I/O to be performed",
1993                 .interval = 1024 * 1024,
1994                 .category = FIO_OPT_C_IO,
1995                 .group  = FIO_OPT_G_INVALID,
1996         },
1997         {
1998                 .name   = "fill_device",
1999                 .lname  = "Fill device",
2000                 .alias  = "fill_fs",
2001                 .type   = FIO_OPT_BOOL,
2002                 .off1   = offsetof(struct thread_options, fill_device),
2003                 .help   = "Write until an ENOSPC error occurs",
2004                 .def    = "0",
2005                 .category = FIO_OPT_C_FILE,
2006                 .group  = FIO_OPT_G_INVALID,
2007         },
2008         {
2009                 .name   = "filesize",
2010                 .lname  = "File size",
2011                 .type   = FIO_OPT_STR_VAL,
2012                 .off1   = offsetof(struct thread_options, file_size_low),
2013                 .off2   = offsetof(struct thread_options, file_size_high),
2014                 .minval = 1,
2015                 .help   = "Size of individual files",
2016                 .interval = 1024 * 1024,
2017                 .category = FIO_OPT_C_FILE,
2018                 .group  = FIO_OPT_G_INVALID,
2019         },
2020         {
2021                 .name   = "file_append",
2022                 .lname  = "File append",
2023                 .type   = FIO_OPT_BOOL,
2024                 .off1   = offsetof(struct thread_options, file_append),
2025                 .help   = "IO will start at the end of the file(s)",
2026                 .def    = "0",
2027                 .category = FIO_OPT_C_FILE,
2028                 .group  = FIO_OPT_G_INVALID,
2029         },
2030         {
2031                 .name   = "offset",
2032                 .lname  = "IO offset",
2033                 .alias  = "fileoffset",
2034                 .type   = FIO_OPT_STR_VAL,
2035                 .cb     = str_offset_cb,
2036                 .off1   = offsetof(struct thread_options, start_offset),
2037                 .help   = "Start IO from this offset",
2038                 .def    = "0",
2039                 .interval = 1024 * 1024,
2040                 .category = FIO_OPT_C_IO,
2041                 .group  = FIO_OPT_G_INVALID,
2042         },
2043         {
2044                 .name   = "offset_align",
2045                 .lname  = "IO offset alignment",
2046                 .type   = FIO_OPT_INT,
2047                 .off1   = offsetof(struct thread_options, start_offset_align),
2048                 .help   = "Start IO from this offset alignment",
2049                 .def    = "0",
2050                 .interval = 512,
2051                 .category = FIO_OPT_C_IO,
2052                 .group  = FIO_OPT_G_INVALID,
2053         },
2054         {
2055                 .name   = "offset_increment",
2056                 .lname  = "IO offset increment",
2057                 .type   = FIO_OPT_STR_VAL,
2058                 .off1   = offsetof(struct thread_options, offset_increment),
2059                 .help   = "What is the increment from one offset to the next",
2060                 .parent = "offset",
2061                 .hide   = 1,
2062                 .def    = "0",
2063                 .interval = 1024 * 1024,
2064                 .category = FIO_OPT_C_IO,
2065                 .group  = FIO_OPT_G_INVALID,
2066         },
2067         {
2068                 .name   = "number_ios",
2069                 .lname  = "Number of IOs to perform",
2070                 .type   = FIO_OPT_STR_VAL,
2071                 .off1   = offsetof(struct thread_options, number_ios),
2072                 .help   = "Force job completion after this number of IOs",
2073                 .def    = "0",
2074                 .category = FIO_OPT_C_IO,
2075                 .group  = FIO_OPT_G_INVALID,
2076         },
2077         {
2078                 .name   = "bs",
2079                 .lname  = "Block size",
2080                 .alias  = "blocksize",
2081                 .type   = FIO_OPT_INT,
2082                 .off1   = offsetof(struct thread_options, bs[DDIR_READ]),
2083                 .off2   = offsetof(struct thread_options, bs[DDIR_WRITE]),
2084                 .off3   = offsetof(struct thread_options, bs[DDIR_TRIM]),
2085                 .minval = 1,
2086                 .help   = "Block size unit",
2087                 .def    = "4096",
2088                 .parent = "rw",
2089                 .hide   = 1,
2090                 .interval = 512,
2091                 .category = FIO_OPT_C_IO,
2092                 .group  = FIO_OPT_G_INVALID,
2093         },
2094         {
2095                 .name   = "ba",
2096                 .lname  = "Block size align",
2097                 .alias  = "blockalign",
2098                 .type   = FIO_OPT_INT,
2099                 .off1   = offsetof(struct thread_options, ba[DDIR_READ]),
2100                 .off2   = offsetof(struct thread_options, ba[DDIR_WRITE]),
2101                 .off3   = offsetof(struct thread_options, ba[DDIR_TRIM]),
2102                 .minval = 1,
2103                 .help   = "IO block offset alignment",
2104                 .parent = "rw",
2105                 .hide   = 1,
2106                 .interval = 512,
2107                 .category = FIO_OPT_C_IO,
2108                 .group  = FIO_OPT_G_INVALID,
2109         },
2110         {
2111                 .name   = "bsrange",
2112                 .lname  = "Block size range",
2113                 .alias  = "blocksize_range",
2114                 .type   = FIO_OPT_RANGE,
2115                 .off1   = offsetof(struct thread_options, min_bs[DDIR_READ]),
2116                 .off2   = offsetof(struct thread_options, max_bs[DDIR_READ]),
2117                 .off3   = offsetof(struct thread_options, min_bs[DDIR_WRITE]),
2118                 .off4   = offsetof(struct thread_options, max_bs[DDIR_WRITE]),
2119                 .off5   = offsetof(struct thread_options, min_bs[DDIR_TRIM]),
2120                 .off6   = offsetof(struct thread_options, max_bs[DDIR_TRIM]),
2121                 .minval = 1,
2122                 .help   = "Set block size range (in more detail than bs)",
2123                 .parent = "rw",
2124                 .hide   = 1,
2125                 .interval = 4096,
2126                 .category = FIO_OPT_C_IO,
2127                 .group  = FIO_OPT_G_INVALID,
2128         },
2129         {
2130                 .name   = "bssplit",
2131                 .lname  = "Block size split",
2132                 .type   = FIO_OPT_STR,
2133                 .cb     = str_bssplit_cb,
2134                 .off1   = offsetof(struct thread_options, bssplit),
2135                 .help   = "Set a specific mix of block sizes",
2136                 .parent = "rw",
2137                 .hide   = 1,
2138                 .category = FIO_OPT_C_IO,
2139                 .group  = FIO_OPT_G_INVALID,
2140         },
2141         {
2142                 .name   = "bs_unaligned",
2143                 .lname  = "Block size unaligned",
2144                 .alias  = "blocksize_unaligned",
2145                 .type   = FIO_OPT_STR_SET,
2146                 .off1   = offsetof(struct thread_options, bs_unaligned),
2147                 .help   = "Don't sector align IO buffer sizes",
2148                 .parent = "rw",
2149                 .hide   = 1,
2150                 .category = FIO_OPT_C_IO,
2151                 .group  = FIO_OPT_G_INVALID,
2152         },
2153         {
2154                 .name   = "bs_is_seq_rand",
2155                 .lname  = "Block size division is seq/random (not read/write)",
2156                 .type   = FIO_OPT_BOOL,
2157                 .off1   = offsetof(struct thread_options, bs_is_seq_rand),
2158                 .help   = "Consider any blocksize setting to be sequential,random",
2159                 .def    = "0",
2160                 .parent = "blocksize",
2161                 .category = FIO_OPT_C_IO,
2162                 .group  = FIO_OPT_G_INVALID,
2163         },
2164         {
2165                 .name   = "randrepeat",
2166                 .lname  = "Random repeatable",
2167                 .type   = FIO_OPT_BOOL,
2168                 .off1   = offsetof(struct thread_options, rand_repeatable),
2169                 .help   = "Use repeatable random IO pattern",
2170                 .def    = "1",
2171                 .parent = "rw",
2172                 .hide   = 1,
2173                 .category = FIO_OPT_C_IO,
2174                 .group  = FIO_OPT_G_RANDOM,
2175         },
2176         {
2177                 .name   = "randseed",
2178                 .lname  = "The random generator seed",
2179                 .type   = FIO_OPT_STR_VAL,
2180                 .off1   = offsetof(struct thread_options, rand_seed),
2181                 .help   = "Set the random generator seed value",
2182                 .def    = "0x89",
2183                 .parent = "rw",
2184                 .category = FIO_OPT_C_IO,
2185                 .group  = FIO_OPT_G_RANDOM,
2186         },
2187         {
2188                 .name   = "use_os_rand",
2189                 .lname  = "Use OS random",
2190                 .type   = FIO_OPT_DEPRECATED,
2191                 .off1   = offsetof(struct thread_options, dep_use_os_rand),
2192                 .category = FIO_OPT_C_IO,
2193                 .group  = FIO_OPT_G_RANDOM,
2194         },
2195         {
2196                 .name   = "norandommap",
2197                 .lname  = "No randommap",
2198                 .type   = FIO_OPT_STR_SET,
2199                 .off1   = offsetof(struct thread_options, norandommap),
2200                 .help   = "Accept potential duplicate random blocks",
2201                 .parent = "rw",
2202                 .hide   = 1,
2203                 .hide_on_set = 1,
2204                 .category = FIO_OPT_C_IO,
2205                 .group  = FIO_OPT_G_RANDOM,
2206         },
2207         {
2208                 .name   = "softrandommap",
2209                 .lname  = "Soft randommap",
2210                 .type   = FIO_OPT_BOOL,
2211                 .off1   = offsetof(struct thread_options, softrandommap),
2212                 .help   = "Set norandommap if randommap allocation fails",
2213                 .parent = "norandommap",
2214                 .hide   = 1,
2215                 .def    = "0",
2216                 .category = FIO_OPT_C_IO,
2217                 .group  = FIO_OPT_G_RANDOM,
2218         },
2219         {
2220                 .name   = "random_generator",
2221                 .lname  = "Random Generator",
2222                 .type   = FIO_OPT_STR,
2223                 .off1   = offsetof(struct thread_options, random_generator),
2224                 .help   = "Type of random number generator to use",
2225                 .def    = "tausworthe",
2226                 .posval = {
2227                           { .ival = "tausworthe",
2228                             .oval = FIO_RAND_GEN_TAUSWORTHE,
2229                             .help = "Strong Tausworthe generator",
2230                           },
2231                           { .ival = "lfsr",
2232                             .oval = FIO_RAND_GEN_LFSR,
2233                             .help = "Variable length LFSR",
2234                           },
2235                           {
2236                             .ival = "tausworthe64",
2237                             .oval = FIO_RAND_GEN_TAUSWORTHE64,
2238                             .help = "64-bit Tausworthe variant",
2239                           },
2240                 },
2241                 .category = FIO_OPT_C_IO,
2242                 .group  = FIO_OPT_G_RANDOM,
2243         },
2244         {
2245                 .name   = "random_distribution",
2246                 .lname  = "Random Distribution",
2247                 .type   = FIO_OPT_STR,
2248                 .off1   = offsetof(struct thread_options, random_distribution),
2249                 .cb     = str_random_distribution_cb,
2250                 .help   = "Random offset distribution generator",
2251                 .def    = "random",
2252                 .posval = {
2253                           { .ival = "random",
2254                             .oval = FIO_RAND_DIST_RANDOM,
2255                             .help = "Completely random",
2256                           },
2257                           { .ival = "zipf",
2258                             .oval = FIO_RAND_DIST_ZIPF,
2259                             .help = "Zipf distribution",
2260                           },
2261                           { .ival = "pareto",
2262                             .oval = FIO_RAND_DIST_PARETO,
2263                             .help = "Pareto distribution",
2264                           },
2265                           { .ival = "normal",
2266                             .oval = FIO_RAND_DIST_GAUSS,
2267                             .help = "Normal (Gaussian) distribution",
2268                           },
2269                           { .ival = "zoned",
2270                             .oval = FIO_RAND_DIST_ZONED,
2271                             .help = "Zoned random distribution",
2272                           },
2273                           { .ival = "zoned_abs",
2274                             .oval = FIO_RAND_DIST_ZONED_ABS,
2275                             .help = "Zoned absolute random distribution",
2276                           },
2277                 },
2278                 .category = FIO_OPT_C_IO,
2279                 .group  = FIO_OPT_G_RANDOM,
2280         },
2281         {
2282                 .name   = "percentage_random",
2283                 .lname  = "Percentage Random",
2284                 .type   = FIO_OPT_INT,
2285                 .off1   = offsetof(struct thread_options, perc_rand[DDIR_READ]),
2286                 .off2   = offsetof(struct thread_options, perc_rand[DDIR_WRITE]),
2287                 .off3   = offsetof(struct thread_options, perc_rand[DDIR_TRIM]),
2288                 .maxval = 100,
2289                 .help   = "Percentage of seq/random mix that should be random",
2290                 .def    = "100,100,100",
2291                 .interval = 5,
2292                 .inverse = "percentage_sequential",
2293                 .category = FIO_OPT_C_IO,
2294                 .group  = FIO_OPT_G_RANDOM,
2295         },
2296         {
2297                 .name   = "percentage_sequential",
2298                 .lname  = "Percentage Sequential",
2299                 .type   = FIO_OPT_DEPRECATED,
2300                 .category = FIO_OPT_C_IO,
2301                 .group  = FIO_OPT_G_RANDOM,
2302         },
2303         {
2304                 .name   = "allrandrepeat",
2305                 .lname  = "All Random Repeat",
2306                 .type   = FIO_OPT_BOOL,
2307                 .off1   = offsetof(struct thread_options, allrand_repeatable),
2308                 .help   = "Use repeatable random numbers for everything",
2309                 .def    = "0",
2310                 .category = FIO_OPT_C_IO,
2311                 .group  = FIO_OPT_G_RANDOM,
2312         },
2313         {
2314                 .name   = "nrfiles",
2315                 .lname  = "Number of files",
2316                 .alias  = "nr_files",
2317                 .type   = FIO_OPT_INT,
2318                 .off1   = offsetof(struct thread_options, nr_files),
2319                 .help   = "Split job workload between this number of files",
2320                 .def    = "1",
2321                 .interval = 1,
2322                 .category = FIO_OPT_C_FILE,
2323                 .group  = FIO_OPT_G_INVALID,
2324         },
2325         {
2326                 .name   = "openfiles",
2327                 .lname  = "Number of open files",
2328                 .type   = FIO_OPT_INT,
2329                 .off1   = offsetof(struct thread_options, open_files),
2330                 .help   = "Number of files to keep open at the same time",
2331                 .category = FIO_OPT_C_FILE,
2332                 .group  = FIO_OPT_G_INVALID,
2333         },
2334         {
2335                 .name   = "file_service_type",
2336                 .lname  = "File service type",
2337                 .type   = FIO_OPT_STR,
2338                 .cb     = str_fst_cb,
2339                 .off1   = offsetof(struct thread_options, file_service_type),
2340                 .help   = "How to select which file to service next",
2341                 .def    = "roundrobin",
2342                 .category = FIO_OPT_C_FILE,
2343                 .group  = FIO_OPT_G_INVALID,
2344                 .posval = {
2345                           { .ival = "random",
2346                             .oval = FIO_FSERVICE_RANDOM,
2347                             .help = "Choose a file at random (uniform)",
2348                           },
2349                           { .ival = "zipf",
2350                             .oval = FIO_FSERVICE_ZIPF,
2351                             .help = "Zipf randomized",
2352                           },
2353                           { .ival = "pareto",
2354                             .oval = FIO_FSERVICE_PARETO,
2355                             .help = "Pareto randomized",
2356                           },
2357                           { .ival = "normal",
2358                             .oval = FIO_FSERVICE_GAUSS,
2359                             .help = "Normal (Gaussian) randomized",
2360                           },
2361                           { .ival = "gauss",
2362                             .oval = FIO_FSERVICE_GAUSS,
2363                             .help = "Alias for normal",
2364                           },
2365                           { .ival = "roundrobin",
2366                             .oval = FIO_FSERVICE_RR,
2367                             .help = "Round robin select files",
2368                           },
2369                           { .ival = "sequential",
2370                             .oval = FIO_FSERVICE_SEQ,
2371                             .help = "Finish one file before moving to the next",
2372                           },
2373                 },
2374                 .parent = "nrfiles",
2375                 .hide   = 1,
2376         },
2377 #ifdef FIO_HAVE_ANY_FALLOCATE
2378         {
2379                 .name   = "fallocate",
2380                 .lname  = "Fallocate",
2381                 .type   = FIO_OPT_STR,
2382                 .off1   = offsetof(struct thread_options, fallocate_mode),
2383                 .help   = "Whether pre-allocation is performed when laying out files",
2384                 .def    = "native",
2385                 .category = FIO_OPT_C_FILE,
2386                 .group  = FIO_OPT_G_INVALID,
2387                 .posval = {
2388                           { .ival = "none",
2389                             .oval = FIO_FALLOCATE_NONE,
2390                             .help = "Do not pre-allocate space",
2391                           },
2392                           { .ival = "native",
2393                             .oval = FIO_FALLOCATE_NATIVE,
2394                             .help = "Use native pre-allocation if possible",
2395                           },
2396 #ifdef CONFIG_POSIX_FALLOCATE
2397                           { .ival = "posix",
2398                             .oval = FIO_FALLOCATE_POSIX,
2399                             .help = "Use posix_fallocate()",
2400                           },
2401 #endif
2402 #ifdef CONFIG_LINUX_FALLOCATE
2403                           { .ival = "keep",
2404                             .oval = FIO_FALLOCATE_KEEP_SIZE,
2405                             .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
2406                           },
2407 #endif
2408                           /* Compatibility with former boolean values */
2409                           { .ival = "0",
2410                             .oval = FIO_FALLOCATE_NONE,
2411                             .help = "Alias for 'none'",
2412                           },
2413 #ifdef CONFIG_POSIX_FALLOCATE
2414                           { .ival = "1",
2415                             .oval = FIO_FALLOCATE_POSIX,
2416                             .help = "Alias for 'posix'",
2417                           },
2418 #endif
2419                 },
2420         },
2421 #else   /* FIO_HAVE_ANY_FALLOCATE */
2422         {
2423                 .name   = "fallocate",
2424                 .lname  = "Fallocate",
2425                 .type   = FIO_OPT_UNSUPPORTED,
2426                 .help   = "Your platform does not support fallocate",
2427         },
2428 #endif /* FIO_HAVE_ANY_FALLOCATE */
2429         {
2430                 .name   = "fadvise_hint",
2431                 .lname  = "Fadvise hint",
2432                 .type   = FIO_OPT_STR,
2433                 .off1   = offsetof(struct thread_options, fadvise_hint),
2434                 .posval = {
2435                           { .ival = "0",
2436                             .oval = F_ADV_NONE,
2437                             .help = "Don't issue fadvise/madvise",
2438                           },
2439                           { .ival = "1",
2440                             .oval = F_ADV_TYPE,
2441                             .help = "Advise using fio IO pattern",
2442                           },
2443                           { .ival = "random",
2444                             .oval = F_ADV_RANDOM,
2445                             .help = "Advise using FADV_RANDOM",
2446                           },
2447                           { .ival = "sequential",
2448                             .oval = F_ADV_SEQUENTIAL,
2449                             .help = "Advise using FADV_SEQUENTIAL",
2450                           },
2451                 },
2452                 .help   = "Use fadvise() to advise the kernel on IO pattern",
2453                 .def    = "1",
2454                 .category = FIO_OPT_C_FILE,
2455                 .group  = FIO_OPT_G_INVALID,
2456         },
2457         {
2458                 .name   = "fsync",
2459                 .lname  = "Fsync",
2460                 .type   = FIO_OPT_INT,
2461                 .off1   = offsetof(struct thread_options, fsync_blocks),
2462                 .help   = "Issue fsync for writes every given number of blocks",
2463                 .def    = "0",
2464                 .interval = 1,
2465                 .category = FIO_OPT_C_FILE,
2466                 .group  = FIO_OPT_G_INVALID,
2467         },
2468         {
2469                 .name   = "fdatasync",
2470                 .lname  = "Fdatasync",
2471                 .type   = FIO_OPT_INT,
2472                 .off1   = offsetof(struct thread_options, fdatasync_blocks),
2473                 .help   = "Issue fdatasync for writes every given number of blocks",
2474                 .def    = "0",
2475                 .interval = 1,
2476                 .category = FIO_OPT_C_FILE,
2477                 .group  = FIO_OPT_G_INVALID,
2478         },
2479         {
2480                 .name   = "write_barrier",
2481                 .lname  = "Write barrier",
2482                 .type   = FIO_OPT_INT,
2483                 .off1   = offsetof(struct thread_options, barrier_blocks),
2484                 .help   = "Make every Nth write a barrier write",
2485                 .def    = "0",
2486                 .interval = 1,
2487                 .category = FIO_OPT_C_IO,
2488                 .group  = FIO_OPT_G_INVALID,
2489         },
2490 #ifdef CONFIG_SYNC_FILE_RANGE
2491         {
2492                 .name   = "sync_file_range",
2493                 .lname  = "Sync file range",
2494                 .posval = {
2495                           { .ival = "wait_before",
2496                             .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
2497                             .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
2498                             .orval  = 1,
2499                           },
2500                           { .ival = "write",
2501                             .oval = SYNC_FILE_RANGE_WRITE,
2502                             .help = "SYNC_FILE_RANGE_WRITE",
2503                             .orval  = 1,
2504                           },
2505                           {
2506                             .ival = "wait_after",
2507                             .oval = SYNC_FILE_RANGE_WAIT_AFTER,
2508                             .help = "SYNC_FILE_RANGE_WAIT_AFTER",
2509                             .orval  = 1,
2510                           },
2511                 },
2512                 .type   = FIO_OPT_STR_MULTI,
2513                 .cb     = str_sfr_cb,
2514                 .off1   = offsetof(struct thread_options, sync_file_range),
2515                 .help   = "Use sync_file_range()",
2516                 .category = FIO_OPT_C_FILE,
2517                 .group  = FIO_OPT_G_INVALID,
2518         },
2519 #else
2520         {
2521                 .name   = "sync_file_range",
2522                 .lname  = "Sync file range",
2523                 .type   = FIO_OPT_UNSUPPORTED,
2524                 .help   = "Your platform does not support sync_file_range",
2525         },
2526 #endif
2527         {
2528                 .name   = "direct",
2529                 .lname  = "Direct I/O",
2530                 .type   = FIO_OPT_BOOL,
2531                 .off1   = offsetof(struct thread_options, odirect),
2532                 .help   = "Use O_DIRECT IO (negates buffered)",
2533                 .def    = "0",
2534                 .inverse = "buffered",
2535                 .category = FIO_OPT_C_IO,
2536                 .group  = FIO_OPT_G_IO_TYPE,
2537         },
2538         {
2539                 .name   = "atomic",
2540                 .lname  = "Atomic I/O",
2541                 .type   = FIO_OPT_BOOL,
2542                 .off1   = offsetof(struct thread_options, oatomic),
2543                 .help   = "Use Atomic IO with O_DIRECT (implies O_DIRECT)",
2544                 .def    = "0",
2545                 .category = FIO_OPT_C_IO,
2546                 .group  = FIO_OPT_G_IO_TYPE,
2547         },
2548         {
2549                 .name   = "buffered",
2550                 .lname  = "Buffered I/O",
2551                 .type   = FIO_OPT_BOOL,
2552                 .off1   = offsetof(struct thread_options, odirect),
2553                 .neg    = 1,
2554                 .help   = "Use buffered IO (negates direct)",
2555                 .def    = "1",
2556                 .inverse = "direct",
2557                 .category = FIO_OPT_C_IO,
2558                 .group  = FIO_OPT_G_IO_TYPE,
2559         },
2560         {
2561                 .name   = "overwrite",
2562                 .lname  = "Overwrite",
2563                 .type   = FIO_OPT_BOOL,
2564                 .off1   = offsetof(struct thread_options, overwrite),
2565                 .help   = "When writing, set whether to overwrite current data",
2566                 .def    = "0",
2567                 .category = FIO_OPT_C_FILE,
2568                 .group  = FIO_OPT_G_INVALID,
2569         },
2570         {
2571                 .name   = "loops",
2572                 .lname  = "Loops",
2573                 .type   = FIO_OPT_INT,
2574                 .off1   = offsetof(struct thread_options, loops),
2575                 .help   = "Number of times to run the job",
2576                 .def    = "1",
2577                 .interval = 1,
2578                 .category = FIO_OPT_C_GENERAL,
2579                 .group  = FIO_OPT_G_RUNTIME,
2580         },
2581         {
2582                 .name   = "numjobs",
2583                 .lname  = "Number of jobs",
2584                 .type   = FIO_OPT_INT,
2585                 .off1   = offsetof(struct thread_options, numjobs),
2586                 .help   = "Duplicate this job this many times",
2587                 .def    = "1",
2588                 .interval = 1,
2589                 .category = FIO_OPT_C_GENERAL,
2590                 .group  = FIO_OPT_G_RUNTIME,
2591         },
2592         {
2593                 .name   = "startdelay",
2594                 .lname  = "Start delay",
2595                 .type   = FIO_OPT_STR_VAL_TIME,
2596                 .off1   = offsetof(struct thread_options, start_delay),
2597                 .off2   = offsetof(struct thread_options, start_delay_high),
2598                 .help   = "Only start job when this period has passed",
2599                 .def    = "0",
2600                 .is_seconds = 1,
2601                 .is_time = 1,
2602                 .category = FIO_OPT_C_GENERAL,
2603                 .group  = FIO_OPT_G_RUNTIME,
2604         },
2605         {
2606                 .name   = "runtime",
2607                 .lname  = "Runtime",
2608                 .alias  = "timeout",
2609                 .type   = FIO_OPT_STR_VAL_TIME,
2610                 .off1   = offsetof(struct thread_options, timeout),
2611                 .help   = "Stop workload when this amount of time has passed",
2612                 .def    = "0",
2613                 .is_seconds = 1,
2614                 .is_time = 1,
2615                 .category = FIO_OPT_C_GENERAL,
2616                 .group  = FIO_OPT_G_RUNTIME,
2617         },
2618         {
2619                 .name   = "time_based",
2620                 .lname  = "Time based",
2621                 .type   = FIO_OPT_STR_SET,
2622                 .off1   = offsetof(struct thread_options, time_based),
2623                 .help   = "Keep running until runtime/timeout is met",
2624                 .category = FIO_OPT_C_GENERAL,
2625                 .group  = FIO_OPT_G_RUNTIME,
2626         },
2627         {
2628                 .name   = "verify_only",
2629                 .lname  = "Verify only",
2630                 .type   = FIO_OPT_STR_SET,
2631                 .off1   = offsetof(struct thread_options, verify_only),
2632                 .help   = "Verifies previously written data is still valid",
2633                 .category = FIO_OPT_C_GENERAL,
2634                 .group  = FIO_OPT_G_RUNTIME,
2635         },
2636         {
2637                 .name   = "ramp_time",
2638                 .lname  = "Ramp time",
2639                 .type   = FIO_OPT_STR_VAL_TIME,
2640                 .off1   = offsetof(struct thread_options, ramp_time),
2641                 .help   = "Ramp up time before measuring performance",
2642                 .is_seconds = 1,
2643                 .is_time = 1,
2644                 .category = FIO_OPT_C_GENERAL,
2645                 .group  = FIO_OPT_G_RUNTIME,
2646         },
2647         {
2648                 .name   = "clocksource",
2649                 .lname  = "Clock source",
2650                 .type   = FIO_OPT_STR,
2651                 .cb     = fio_clock_source_cb,
2652                 .off1   = offsetof(struct thread_options, clocksource),
2653                 .help   = "What type of timing source to use",
2654                 .category = FIO_OPT_C_GENERAL,
2655                 .group  = FIO_OPT_G_CLOCK,
2656                 .posval = {
2657 #ifdef CONFIG_GETTIMEOFDAY
2658                           { .ival = "gettimeofday",
2659                             .oval = CS_GTOD,
2660                             .help = "Use gettimeofday(2) for timing",
2661                           },
2662 #endif
2663 #ifdef CONFIG_CLOCK_GETTIME
2664                           { .ival = "clock_gettime",
2665                             .oval = CS_CGETTIME,
2666                             .help = "Use clock_gettime(2) for timing",
2667                           },
2668 #endif
2669 #ifdef ARCH_HAVE_CPU_CLOCK
2670                           { .ival = "cpu",
2671                             .oval = CS_CPUCLOCK,
2672                             .help = "Use CPU private clock",
2673                           },
2674 #endif
2675                 },
2676         },
2677         {
2678                 .name   = "mem",
2679                 .alias  = "iomem",
2680                 .lname  = "I/O Memory",
2681                 .type   = FIO_OPT_STR,
2682                 .cb     = str_mem_cb,
2683                 .off1   = offsetof(struct thread_options, mem_type),
2684                 .help   = "Backing type for IO buffers",
2685                 .def    = "malloc",
2686                 .category = FIO_OPT_C_IO,
2687                 .group  = FIO_OPT_G_INVALID,
2688                 .posval = {
2689                           { .ival = "malloc",
2690                             .oval = MEM_MALLOC,
2691                             .help = "Use malloc(3) for IO buffers",
2692                           },
2693 #ifndef CONFIG_NO_SHM
2694                           { .ival = "shm",
2695                             .oval = MEM_SHM,
2696                             .help = "Use shared memory segments for IO buffers",
2697                           },
2698 #ifdef FIO_HAVE_HUGETLB
2699                           { .ival = "shmhuge",
2700                             .oval = MEM_SHMHUGE,
2701                             .help = "Like shm, but use huge pages",
2702                           },
2703 #endif
2704 #endif
2705                           { .ival = "mmap",
2706                             .oval = MEM_MMAP,
2707                             .help = "Use mmap(2) (file or anon) for IO buffers",
2708                           },
2709                           { .ival = "mmapshared",
2710                             .oval = MEM_MMAPSHARED,
2711                             .help = "Like mmap, but use the shared flag",
2712                           },
2713 #ifdef FIO_HAVE_HUGETLB
2714                           { .ival = "mmaphuge",
2715                             .oval = MEM_MMAPHUGE,
2716                             .help = "Like mmap, but use huge pages",
2717                           },
2718 #endif
2719 #ifdef CONFIG_CUDA
2720                           { .ival = "cudamalloc",
2721                             .oval = MEM_CUDA_MALLOC,
2722                             .help = "Allocate GPU device memory for GPUDirect RDMA",
2723                           },
2724 #endif
2725                   },
2726         },
2727         {
2728                 .name   = "iomem_align",
2729                 .alias  = "mem_align",
2730                 .lname  = "I/O memory alignment",
2731                 .type   = FIO_OPT_INT,
2732                 .off1   = offsetof(struct thread_options, mem_align),
2733                 .minval = 0,
2734                 .help   = "IO memory buffer offset alignment",
2735                 .def    = "0",
2736                 .parent = "iomem",
2737                 .hide   = 1,
2738                 .category = FIO_OPT_C_IO,
2739                 .group  = FIO_OPT_G_INVALID,
2740         },
2741         {
2742                 .name   = "verify",
2743                 .lname  = "Verify",
2744                 .type   = FIO_OPT_STR,
2745                 .off1   = offsetof(struct thread_options, verify),
2746                 .help   = "Verify data written",
2747                 .def    = "0",
2748                 .category = FIO_OPT_C_IO,
2749                 .group  = FIO_OPT_G_VERIFY,
2750                 .posval = {
2751                           { .ival = "0",
2752                             .oval = VERIFY_NONE,
2753                             .help = "Don't do IO verification",
2754                           },
2755                           { .ival = "md5",
2756                             .oval = VERIFY_MD5,
2757                             .help = "Use md5 checksums for verification",
2758                           },
2759                           { .ival = "crc64",
2760                             .oval = VERIFY_CRC64,
2761                             .help = "Use crc64 checksums for verification",
2762                           },
2763                           { .ival = "crc32",
2764                             .oval = VERIFY_CRC32,
2765                             .help = "Use crc32 checksums for verification",
2766                           },
2767                           { .ival = "crc32c-intel",
2768                             .oval = VERIFY_CRC32C,
2769                             .help = "Use crc32c checksums for verification (hw assisted, if available)",
2770                           },
2771                           { .ival = "crc32c",
2772                             .oval = VERIFY_CRC32C,
2773                             .help = "Use crc32c checksums for verification (hw assisted, if available)",
2774                           },
2775                           { .ival = "crc16",
2776                             .oval = VERIFY_CRC16,
2777                             .help = "Use crc16 checksums for verification",
2778                           },
2779                           { .ival = "crc7",
2780                             .oval = VERIFY_CRC7,
2781                             .help = "Use crc7 checksums for verification",
2782                           },
2783                           { .ival = "sha1",
2784                             .oval = VERIFY_SHA1,
2785                             .help = "Use sha1 checksums for verification",
2786                           },
2787                           { .ival = "sha256",
2788                             .oval = VERIFY_SHA256,
2789                             .help = "Use sha256 checksums for verification",
2790                           },
2791                           { .ival = "sha512",
2792                             .oval = VERIFY_SHA512,
2793                             .help = "Use sha512 checksums for verification",
2794                           },
2795                           { .ival = "sha3-224",
2796                             .oval = VERIFY_SHA3_224,
2797                             .help = "Use sha3-224 checksums for verification",
2798                           },
2799                           { .ival = "sha3-256",
2800                             .oval = VERIFY_SHA3_256,
2801                             .help = "Use sha3-256 checksums for verification",
2802                           },
2803                           { .ival = "sha3-384",
2804                             .oval = VERIFY_SHA3_384,
2805                             .help = "Use sha3-384 checksums for verification",
2806                           },
2807                           { .ival = "sha3-512",
2808                             .oval = VERIFY_SHA3_512,
2809                             .help = "Use sha3-512 checksums for verification",
2810                           },
2811                           { .ival = "xxhash",
2812                             .oval = VERIFY_XXHASH,
2813                             .help = "Use xxhash checksums for verification",
2814                           },
2815                           /* Meta information was included into verify_header,
2816                            * 'meta' verification is implied by default. */
2817                           { .ival = "meta",
2818                             .oval = VERIFY_HDR_ONLY,
2819                             .help = "Use io information for verification. "
2820                                     "Now is implied by default, thus option is obsolete, "
2821                                     "don't use it",
2822                           },
2823                           { .ival = "pattern",
2824                             .oval = VERIFY_PATTERN_NO_HDR,
2825                             .help = "Verify strict pattern",
2826                           },
2827                           {
2828                             .ival = "null",
2829                             .oval = VERIFY_NULL,
2830                             .help = "Pretend to verify",
2831                           },
2832                 },
2833         },
2834         {
2835                 .name   = "do_verify",
2836                 .lname  = "Perform verify step",
2837                 .type   = FIO_OPT_BOOL,
2838                 .off1   = offsetof(struct thread_options, do_verify),
2839                 .help   = "Run verification stage after write",
2840                 .def    = "1",
2841                 .parent = "verify",
2842                 .hide   = 1,
2843                 .category = FIO_OPT_C_IO,
2844                 .group  = FIO_OPT_G_VERIFY,
2845         },
2846         {
2847                 .name   = "verifysort",
2848                 .lname  = "Verify sort",
2849                 .type   = FIO_OPT_SOFT_DEPRECATED,
2850                 .category = FIO_OPT_C_IO,
2851                 .group  = FIO_OPT_G_VERIFY,
2852         },
2853         {
2854                 .name   = "verifysort_nr",
2855                 .lname  = "Verify Sort Nr",
2856                 .type   = FIO_OPT_SOFT_DEPRECATED,
2857                 .category = FIO_OPT_C_IO,
2858                 .group  = FIO_OPT_G_VERIFY,
2859         },
2860         {
2861                 .name   = "verify_interval",
2862                 .lname  = "Verify interval",
2863                 .type   = FIO_OPT_INT,
2864                 .off1   = offsetof(struct thread_options, verify_interval),
2865                 .minval = 2 * sizeof(struct verify_header),
2866                 .help   = "Store verify buffer header every N bytes",
2867                 .parent = "verify",
2868                 .hide   = 1,
2869                 .interval = 2 * sizeof(struct verify_header),
2870                 .category = FIO_OPT_C_IO,
2871                 .group  = FIO_OPT_G_VERIFY,
2872         },
2873         {
2874                 .name   = "verify_offset",
2875                 .lname  = "Verify offset",
2876                 .type   = FIO_OPT_INT,
2877                 .help   = "Offset verify header location by N bytes",
2878                 .off1   = offsetof(struct thread_options, verify_offset),
2879                 .minval = sizeof(struct verify_header),
2880                 .parent = "verify",
2881                 .hide   = 1,
2882                 .category = FIO_OPT_C_IO,
2883                 .group  = FIO_OPT_G_VERIFY,
2884         },
2885         {
2886                 .name   = "verify_pattern",
2887                 .lname  = "Verify pattern",
2888                 .type   = FIO_OPT_STR,
2889                 .cb     = str_verify_pattern_cb,
2890                 .off1   = offsetof(struct thread_options, verify_pattern),
2891                 .help   = "Fill pattern for IO buffers",
2892                 .parent = "verify",
2893                 .hide   = 1,
2894                 .category = FIO_OPT_C_IO,
2895                 .group  = FIO_OPT_G_VERIFY,
2896         },
2897         {
2898                 .name   = "verify_fatal",
2899                 .lname  = "Verify fatal",
2900                 .type   = FIO_OPT_BOOL,
2901                 .off1   = offsetof(struct thread_options, verify_fatal),
2902                 .def    = "0",
2903                 .help   = "Exit on a single verify failure, don't continue",
2904                 .parent = "verify",
2905                 .hide   = 1,
2906                 .category = FIO_OPT_C_IO,
2907                 .group  = FIO_OPT_G_VERIFY,
2908         },
2909         {
2910                 .name   = "verify_dump",
2911                 .lname  = "Verify dump",
2912                 .type   = FIO_OPT_BOOL,
2913                 .off1   = offsetof(struct thread_options, verify_dump),
2914                 .def    = "0",
2915                 .help   = "Dump contents of good and bad blocks on failure",
2916                 .parent = "verify",
2917                 .hide   = 1,
2918                 .category = FIO_OPT_C_IO,
2919                 .group  = FIO_OPT_G_VERIFY,
2920         },
2921         {
2922                 .name   = "verify_async",
2923                 .lname  = "Verify asynchronously",
2924                 .type   = FIO_OPT_INT,
2925                 .off1   = offsetof(struct thread_options, verify_async),
2926                 .def    = "0",
2927                 .help   = "Number of async verifier threads to use",
2928                 .parent = "verify",
2929                 .hide   = 1,
2930                 .category = FIO_OPT_C_IO,
2931                 .group  = FIO_OPT_G_VERIFY,
2932         },
2933         {
2934                 .name   = "verify_backlog",
2935                 .lname  = "Verify backlog",
2936                 .type   = FIO_OPT_STR_VAL,
2937                 .off1   = offsetof(struct thread_options, verify_backlog),
2938                 .help   = "Verify after this number of blocks are written",
2939                 .parent = "verify",
2940                 .hide   = 1,
2941                 .category = FIO_OPT_C_IO,
2942                 .group  = FIO_OPT_G_VERIFY,
2943         },
2944         {
2945                 .name   = "verify_backlog_batch",
2946                 .lname  = "Verify backlog batch",
2947                 .type   = FIO_OPT_INT,
2948                 .off1   = offsetof(struct thread_options, verify_batch),
2949                 .help   = "Verify this number of IO blocks",
2950                 .parent = "verify",
2951                 .hide   = 1,
2952                 .category = FIO_OPT_C_IO,
2953                 .group  = FIO_OPT_G_VERIFY,
2954         },
2955 #ifdef FIO_HAVE_CPU_AFFINITY
2956         {
2957                 .name   = "verify_async_cpus",
2958                 .lname  = "Async verify CPUs",
2959                 .type   = FIO_OPT_STR,
2960                 .cb     = str_verify_cpus_allowed_cb,
2961                 .off1   = offsetof(struct thread_options, verify_cpumask),
2962                 .help   = "Set CPUs allowed for async verify threads",
2963                 .parent = "verify_async",
2964                 .hide   = 1,
2965                 .category = FIO_OPT_C_IO,
2966                 .group  = FIO_OPT_G_VERIFY,
2967         },
2968 #else
2969         {
2970                 .name   = "verify_async_cpus",
2971                 .lname  = "Async verify CPUs",
2972                 .type   = FIO_OPT_UNSUPPORTED,
2973                 .help   = "Your platform does not support CPU affinities",
2974         },
2975 #endif
2976         {
2977                 .name   = "experimental_verify",
2978                 .lname  = "Experimental Verify",
2979                 .off1   = offsetof(struct thread_options, experimental_verify),
2980                 .type   = FIO_OPT_BOOL,
2981                 .help   = "Enable experimental verification",
2982                 .parent = "verify",
2983                 .category = FIO_OPT_C_IO,
2984                 .group  = FIO_OPT_G_VERIFY,
2985         },
2986         {
2987                 .name   = "verify_state_load",
2988                 .lname  = "Load verify state",
2989                 .off1   = offsetof(struct thread_options, verify_state),
2990                 .type   = FIO_OPT_BOOL,
2991                 .help   = "Load verify termination state",
2992                 .parent = "verify",
2993                 .category = FIO_OPT_C_IO,
2994                 .group  = FIO_OPT_G_VERIFY,
2995         },
2996         {
2997                 .name   = "verify_state_save",
2998                 .lname  = "Save verify state",
2999                 .off1   = offsetof(struct thread_options, verify_state_save),
3000                 .type   = FIO_OPT_BOOL,
3001                 .def    = "1",
3002                 .help   = "Save verify state on termination",
3003                 .parent = "verify",
3004                 .category = FIO_OPT_C_IO,
3005                 .group  = FIO_OPT_G_VERIFY,
3006         },
3007 #ifdef FIO_HAVE_TRIM
3008         {
3009                 .name   = "trim_percentage",
3010                 .lname  = "Trim percentage",
3011                 .type   = FIO_OPT_INT,
3012                 .off1   = offsetof(struct thread_options, trim_percentage),
3013                 .minval = 0,
3014                 .maxval = 100,
3015                 .help   = "Number of verify blocks to trim (i.e., discard)",
3016                 .parent = "verify",
3017                 .def    = "0",
3018                 .interval = 1,
3019                 .hide   = 1,
3020                 .category = FIO_OPT_C_IO,
3021                 .group  = FIO_OPT_G_TRIM,
3022         },
3023         {
3024                 .name   = "trim_verify_zero",
3025                 .lname  = "Verify trim zero",
3026                 .type   = FIO_OPT_BOOL,
3027                 .help   = "Verify that trimmed (i.e., discarded) blocks are returned as zeroes",
3028                 .off1   = offsetof(struct thread_options, trim_zero),
3029                 .parent = "trim_percentage",
3030                 .hide   = 1,
3031                 .def    = "1",
3032                 .category = FIO_OPT_C_IO,
3033                 .group  = FIO_OPT_G_TRIM,
3034         },
3035         {
3036                 .name   = "trim_backlog",
3037                 .lname  = "Trim backlog",
3038                 .type   = FIO_OPT_STR_VAL,
3039                 .off1   = offsetof(struct thread_options, trim_backlog),
3040                 .help   = "Trim after this number of blocks are written",
3041                 .parent = "trim_percentage",
3042                 .hide   = 1,
3043                 .interval = 1,
3044                 .category = FIO_OPT_C_IO,
3045                 .group  = FIO_OPT_G_TRIM,
3046         },
3047         {
3048                 .name   = "trim_backlog_batch",
3049                 .lname  = "Trim backlog batch",
3050                 .type   = FIO_OPT_INT,
3051                 .off1   = offsetof(struct thread_options, trim_batch),
3052                 .help   = "Trim this number of IO blocks",
3053                 .parent = "trim_percentage",
3054                 .hide   = 1,
3055                 .interval = 1,
3056                 .category = FIO_OPT_C_IO,
3057                 .group  = FIO_OPT_G_TRIM,
3058         },
3059 #else
3060         {
3061                 .name   = "trim_percentage",
3062                 .lname  = "Trim percentage",
3063                 .type   = FIO_OPT_UNSUPPORTED,
3064                 .help   = "Fio does not support TRIM on your platform",
3065         },
3066         {
3067                 .name   = "trim_verify_zero",
3068                 .lname  = "Verify trim zero",
3069                 .type   = FIO_OPT_UNSUPPORTED,
3070                 .help   = "Fio does not support TRIM on your platform",
3071         },
3072         {
3073                 .name   = "trim_backlog",
3074                 .lname  = "Trim backlog",
3075                 .type   = FIO_OPT_UNSUPPORTED,
3076                 .help   = "Fio does not support TRIM on your platform",
3077         },
3078         {
3079                 .name   = "trim_backlog_batch",
3080                 .lname  = "Trim backlog batch",
3081                 .type   = FIO_OPT_UNSUPPORTED,
3082                 .help   = "Fio does not support TRIM on your platform",
3083         },
3084 #endif
3085         {
3086                 .name   = "write_iolog",
3087                 .lname  = "Write I/O log",
3088                 .type   = FIO_OPT_STR_STORE,
3089                 .off1   = offsetof(struct thread_options, write_iolog_file),
3090                 .help   = "Store IO pattern to file",
3091                 .category = FIO_OPT_C_IO,
3092                 .group  = FIO_OPT_G_IOLOG,
3093         },
3094         {
3095                 .name   = "read_iolog",
3096                 .lname  = "Read I/O log",
3097                 .type   = FIO_OPT_STR_STORE,
3098                 .off1   = offsetof(struct thread_options, read_iolog_file),
3099                 .help   = "Playback IO pattern from file",
3100                 .category = FIO_OPT_C_IO,
3101                 .group  = FIO_OPT_G_IOLOG,
3102         },
3103         {
3104                 .name   = "replay_no_stall",
3105                 .lname  = "Don't stall on replay",
3106                 .type   = FIO_OPT_BOOL,
3107                 .off1   = offsetof(struct thread_options, no_stall),
3108                 .def    = "0",
3109                 .parent = "read_iolog",
3110                 .hide   = 1,
3111                 .help   = "Playback IO pattern file as fast as possible without stalls",
3112                 .category = FIO_OPT_C_IO,
3113                 .group  = FIO_OPT_G_IOLOG,
3114         },
3115         {
3116                 .name   = "replay_redirect",
3117                 .lname  = "Redirect device for replay",
3118                 .type   = FIO_OPT_STR_STORE,
3119                 .off1   = offsetof(struct thread_options, replay_redirect),
3120                 .parent = "read_iolog",
3121                 .hide   = 1,
3122                 .help   = "Replay all I/O onto this device, regardless of trace device",
3123                 .category = FIO_OPT_C_IO,
3124                 .group  = FIO_OPT_G_IOLOG,
3125         },
3126         {
3127                 .name   = "replay_scale",
3128                 .lname  = "Replace offset scale factor",
3129                 .type   = FIO_OPT_INT,
3130                 .off1   = offsetof(struct thread_options, replay_scale),
3131                 .parent = "read_iolog",
3132                 .def    = "1",
3133                 .help   = "Align offsets to this blocksize",
3134                 .category = FIO_OPT_C_IO,
3135                 .group  = FIO_OPT_G_IOLOG,
3136         },
3137         {
3138                 .name   = "replay_align",
3139                 .lname  = "Replace alignment",
3140                 .type   = FIO_OPT_INT,
3141                 .off1   = offsetof(struct thread_options, replay_align),
3142                 .parent = "read_iolog",
3143                 .help   = "Scale offset down by this factor",
3144                 .category = FIO_OPT_C_IO,
3145                 .group  = FIO_OPT_G_IOLOG,
3146                 .pow2   = 1,
3147         },
3148         {
3149                 .name   = "replay_time_scale",
3150                 .lname  = "Replay Time Scale",
3151                 .type   = FIO_OPT_INT,
3152                 .off1   = offsetof(struct thread_options, replay_time_scale),
3153                 .def    = "100",
3154                 .minval = 1,
3155                 .parent = "read_iolog",
3156                 .hide   = 1,
3157                 .help   = "Scale time for replay events",
3158                 .category = FIO_OPT_C_IO,
3159                 .group  = FIO_OPT_G_IOLOG,
3160         },
3161         {
3162                 .name   = "exec_prerun",
3163                 .lname  = "Pre-execute runnable",
3164                 .type   = FIO_OPT_STR_STORE,
3165                 .off1   = offsetof(struct thread_options, exec_prerun),
3166                 .help   = "Execute this file prior to running job",
3167                 .category = FIO_OPT_C_GENERAL,
3168                 .group  = FIO_OPT_G_INVALID,
3169         },
3170         {
3171                 .name   = "exec_postrun",
3172                 .lname  = "Post-execute runnable",
3173                 .type   = FIO_OPT_STR_STORE,
3174                 .off1   = offsetof(struct thread_options, exec_postrun),
3175                 .help   = "Execute this file after running job",
3176                 .category = FIO_OPT_C_GENERAL,
3177                 .group  = FIO_OPT_G_INVALID,
3178         },
3179 #ifdef FIO_HAVE_IOSCHED_SWITCH
3180         {
3181                 .name   = "ioscheduler",
3182                 .lname  = "I/O scheduler",
3183                 .type   = FIO_OPT_STR_STORE,
3184                 .off1   = offsetof(struct thread_options, ioscheduler),
3185                 .help   = "Use this IO scheduler on the backing device",
3186                 .category = FIO_OPT_C_FILE,
3187                 .group  = FIO_OPT_G_INVALID,
3188         },
3189 #else
3190         {
3191                 .name   = "ioscheduler",
3192                 .lname  = "I/O scheduler",
3193                 .type   = FIO_OPT_UNSUPPORTED,
3194                 .help   = "Your platform does not support IO scheduler switching",
3195         },
3196 #endif
3197         {
3198                 .name   = "zonesize",
3199                 .lname  = "Zone size",
3200                 .type   = FIO_OPT_STR_VAL,
3201                 .off1   = offsetof(struct thread_options, zone_size),
3202                 .help   = "Amount of data to read per zone",
3203                 .def    = "0",
3204                 .interval = 1024 * 1024,
3205                 .category = FIO_OPT_C_IO,
3206                 .group  = FIO_OPT_G_ZONE,
3207         },
3208         {
3209                 .name   = "zonerange",
3210                 .lname  = "Zone range",
3211                 .type   = FIO_OPT_STR_VAL,
3212                 .off1   = offsetof(struct thread_options, zone_range),
3213                 .help   = "Give size of an IO zone",
3214                 .def    = "0",
3215                 .interval = 1024 * 1024,
3216                 .category = FIO_OPT_C_IO,
3217                 .group  = FIO_OPT_G_ZONE,
3218         },
3219         {
3220                 .name   = "zoneskip",
3221                 .lname  = "Zone skip",
3222                 .type   = FIO_OPT_STR_VAL,
3223                 .off1   = offsetof(struct thread_options, zone_skip),
3224                 .help   = "Space between IO zones",
3225                 .def    = "0",
3226                 .interval = 1024 * 1024,
3227                 .category = FIO_OPT_C_IO,
3228                 .group  = FIO_OPT_G_ZONE,
3229         },
3230         {
3231                 .name   = "lockmem",
3232                 .lname  = "Lock memory",
3233                 .type   = FIO_OPT_STR_VAL,
3234                 .off1   = offsetof(struct thread_options, lockmem),
3235                 .help   = "Lock down this amount of memory (per worker)",
3236                 .def    = "0",
3237                 .interval = 1024 * 1024,
3238                 .category = FIO_OPT_C_GENERAL,
3239                 .group  = FIO_OPT_G_INVALID,
3240         },
3241         {
3242                 .name   = "rwmixread",
3243                 .lname  = "Read/write mix read",
3244                 .type   = FIO_OPT_INT,
3245                 .cb     = str_rwmix_read_cb,
3246                 .off1   = offsetof(struct thread_options, rwmix[DDIR_READ]),
3247                 .maxval = 100,
3248                 .help   = "Percentage of mixed workload that is reads",
3249                 .def    = "50",
3250                 .interval = 5,
3251                 .inverse = "rwmixwrite",
3252                 .category = FIO_OPT_C_IO,
3253                 .group  = FIO_OPT_G_RWMIX,
3254         },
3255         {
3256                 .name   = "rwmixwrite",
3257                 .lname  = "Read/write mix write",
3258                 .type   = FIO_OPT_INT,
3259                 .cb     = str_rwmix_write_cb,
3260                 .off1   = offsetof(struct thread_options, rwmix[DDIR_WRITE]),
3261                 .maxval = 100,
3262                 .help   = "Percentage of mixed workload that is writes",
3263                 .def    = "50",
3264                 .interval = 5,
3265                 .inverse = "rwmixread",
3266                 .category = FIO_OPT_C_IO,
3267                 .group  = FIO_OPT_G_RWMIX,
3268         },
3269         {
3270                 .name   = "rwmixcycle",
3271                 .lname  = "Read/write mix cycle",
3272                 .type   = FIO_OPT_DEPRECATED,
3273                 .category = FIO_OPT_C_IO,
3274                 .group  = FIO_OPT_G_RWMIX,
3275         },
3276         {
3277                 .name   = "nice",
3278                 .lname  = "Nice",
3279                 .type   = FIO_OPT_INT,
3280                 .off1   = offsetof(struct thread_options, nice),
3281                 .help   = "Set job CPU nice value",
3282                 .minval = -20,
3283                 .maxval = 19,
3284                 .def    = "0",
3285                 .interval = 1,
3286                 .category = FIO_OPT_C_GENERAL,
3287                 .group  = FIO_OPT_G_CRED,
3288         },
3289 #ifdef FIO_HAVE_IOPRIO
3290         {
3291                 .name   = "prio",
3292                 .lname  = "I/O nice priority",
3293                 .type   = FIO_OPT_INT,
3294                 .off1   = offsetof(struct thread_options, ioprio),
3295                 .help   = "Set job IO priority value",
3296                 .minval = IOPRIO_MIN_PRIO,
3297                 .maxval = IOPRIO_MAX_PRIO,
3298                 .interval = 1,
3299                 .category = FIO_OPT_C_GENERAL,
3300                 .group  = FIO_OPT_G_CRED,
3301         },
3302 #else
3303         {
3304                 .name   = "prio",
3305                 .lname  = "I/O nice priority",
3306                 .type   = FIO_OPT_UNSUPPORTED,
3307                 .help   = "Your platform does not support IO priorities",
3308         },
3309 #endif
3310 #ifdef FIO_HAVE_IOPRIO_CLASS
3311 #ifndef FIO_HAVE_IOPRIO
3312 #error "FIO_HAVE_IOPRIO_CLASS requires FIO_HAVE_IOPRIO"
3313 #endif
3314         {
3315                 .name   = "prioclass",
3316                 .lname  = "I/O nice priority class",
3317                 .type   = FIO_OPT_INT,
3318                 .off1   = offsetof(struct thread_options, ioprio_class),
3319                 .help   = "Set job IO priority class",
3320                 .minval = IOPRIO_MIN_PRIO_CLASS,
3321                 .maxval = IOPRIO_MAX_PRIO_CLASS,
3322                 .interval = 1,
3323                 .category = FIO_OPT_C_GENERAL,
3324                 .group  = FIO_OPT_G_CRED,
3325         },
3326 #else
3327         {
3328                 .name   = "prioclass",
3329                 .lname  = "I/O nice priority class",
3330                 .type   = FIO_OPT_UNSUPPORTED,
3331                 .help   = "Your platform does not support IO priority classes",
3332         },
3333 #endif
3334         {
3335                 .name   = "thinktime",
3336                 .lname  = "Thinktime",
3337                 .type   = FIO_OPT_INT,
3338                 .off1   = offsetof(struct thread_options, thinktime),
3339                 .help   = "Idle time between IO buffers (usec)",
3340                 .def    = "0",
3341                 .is_time = 1,
3342                 .category = FIO_OPT_C_IO,
3343                 .group  = FIO_OPT_G_THINKTIME,
3344         },
3345         {
3346                 .name   = "thinktime_spin",
3347                 .lname  = "Thinktime spin",
3348                 .type   = FIO_OPT_INT,
3349                 .off1   = offsetof(struct thread_options, thinktime_spin),
3350                 .help   = "Start think time by spinning this amount (usec)",
3351                 .def    = "0",
3352                 .is_time = 1,
3353                 .parent = "thinktime",
3354                 .hide   = 1,
3355                 .category = FIO_OPT_C_IO,
3356                 .group  = FIO_OPT_G_THINKTIME,
3357         },
3358         {
3359                 .name   = "thinktime_blocks",
3360                 .lname  = "Thinktime blocks",
3361                 .type   = FIO_OPT_INT,
3362                 .off1   = offsetof(struct thread_options, thinktime_blocks),
3363                 .help   = "IO buffer period between 'thinktime'",
3364                 .def    = "1",
3365                 .parent = "thinktime",
3366                 .hide   = 1,
3367                 .category = FIO_OPT_C_IO,
3368                 .group  = FIO_OPT_G_THINKTIME,
3369         },
3370         {
3371                 .name   = "rate",
3372                 .lname  = "I/O rate",
3373                 .type   = FIO_OPT_INT,
3374                 .off1   = offsetof(struct thread_options, rate[DDIR_READ]),
3375                 .off2   = offsetof(struct thread_options, rate[DDIR_WRITE]),
3376                 .off3   = offsetof(struct thread_options, rate[DDIR_TRIM]),
3377                 .help   = "Set bandwidth rate",
3378                 .category = FIO_OPT_C_IO,
3379                 .group  = FIO_OPT_G_RATE,
3380         },
3381         {
3382                 .name   = "rate_min",
3383                 .alias  = "ratemin",
3384                 .lname  = "I/O min rate",
3385                 .type   = FIO_OPT_INT,
3386                 .off1   = offsetof(struct thread_options, ratemin[DDIR_READ]),
3387                 .off2   = offsetof(struct thread_options, ratemin[DDIR_WRITE]),
3388                 .off3   = offsetof(struct thread_options, ratemin[DDIR_TRIM]),
3389                 .help   = "Job must meet this rate or it will be shutdown",
3390                 .parent = "rate",
3391                 .hide   = 1,
3392                 .category = FIO_OPT_C_IO,
3393                 .group  = FIO_OPT_G_RATE,
3394         },
3395         {
3396                 .name   = "rate_iops",
3397                 .lname  = "I/O rate IOPS",
3398                 .type   = FIO_OPT_INT,
3399                 .off1   = offsetof(struct thread_options, rate_iops[DDIR_READ]),
3400                 .off2   = offsetof(struct thread_options, rate_iops[DDIR_WRITE]),
3401                 .off3   = offsetof(struct thread_options, rate_iops[DDIR_TRIM]),
3402                 .help   = "Limit IO used to this number of IO operations/sec",
3403                 .hide   = 1,
3404                 .category = FIO_OPT_C_IO,
3405                 .group  = FIO_OPT_G_RATE,
3406         },
3407         {
3408                 .name   = "rate_iops_min",
3409                 .lname  = "I/O min rate IOPS",
3410                 .type   = FIO_OPT_INT,
3411                 .off1   = offsetof(struct thread_options, rate_iops_min[DDIR_READ]),
3412                 .off2   = offsetof(struct thread_options, rate_iops_min[DDIR_WRITE]),
3413                 .off3   = offsetof(struct thread_options, rate_iops_min[DDIR_TRIM]),
3414                 .help   = "Job must meet this rate or it will be shut down",
3415                 .parent = "rate_iops",
3416                 .hide   = 1,
3417                 .category = FIO_OPT_C_IO,
3418                 .group  = FIO_OPT_G_RATE,
3419         },
3420         {
3421                 .name   = "rate_process",
3422                 .lname  = "Rate Process",
3423                 .type   = FIO_OPT_STR,
3424                 .off1   = offsetof(struct thread_options, rate_process),
3425                 .help   = "What process controls how rated IO is managed",
3426                 .def    = "linear",
3427                 .category = FIO_OPT_C_IO,
3428                 .group  = FIO_OPT_G_RATE,
3429                 .posval = {
3430                           { .ival = "linear",
3431                             .oval = RATE_PROCESS_LINEAR,
3432                             .help = "Linear rate of IO",
3433                           },
3434                           {
3435                             .ival = "poisson",
3436                             .oval = RATE_PROCESS_POISSON,
3437                             .help = "Rate follows Poisson process",
3438                           },
3439                 },
3440                 .parent = "rate",
3441         },
3442         {
3443                 .name   = "rate_cycle",
3444                 .alias  = "ratecycle",
3445                 .lname  = "I/O rate cycle",
3446                 .type   = FIO_OPT_INT,
3447                 .off1   = offsetof(struct thread_options, ratecycle),
3448                 .help   = "Window average for rate limits (msec)",
3449                 .def    = "1000",
3450                 .parent = "rate",
3451                 .hide   = 1,
3452                 .category = FIO_OPT_C_IO,
3453                 .group  = FIO_OPT_G_RATE,
3454         },
3455         {
3456                 .name   = "rate_ignore_thinktime",
3457                 .lname  = "Rate ignore thinktime",
3458                 .type   = FIO_OPT_BOOL,
3459                 .off1   = offsetof(struct thread_options, rate_ign_think),
3460                 .help   = "Rated IO ignores thinktime settings",
3461                 .parent = "rate",
3462                 .category = FIO_OPT_C_IO,
3463                 .group  = FIO_OPT_G_RATE,
3464         },
3465         {
3466                 .name   = "max_latency",
3467                 .lname  = "Max Latency (usec)",
3468                 .type   = FIO_OPT_STR_VAL_TIME,
3469                 .off1   = offsetof(struct thread_options, max_latency),
3470                 .help   = "Maximum tolerated IO latency (usec)",
3471                 .is_time = 1,
3472                 .category = FIO_OPT_C_IO,
3473                 .group = FIO_OPT_G_LATPROF,
3474         },
3475         {
3476                 .name   = "latency_target",
3477                 .lname  = "Latency Target (usec)",
3478                 .type   = FIO_OPT_STR_VAL_TIME,
3479                 .off1   = offsetof(struct thread_options, latency_target),
3480                 .help   = "Ramp to max queue depth supporting this latency",
3481                 .is_time = 1,
3482                 .category = FIO_OPT_C_IO,
3483                 .group  = FIO_OPT_G_LATPROF,
3484         },
3485         {
3486                 .name   = "latency_window",
3487                 .lname  = "Latency Window (usec)",
3488                 .type   = FIO_OPT_STR_VAL_TIME,
3489                 .off1   = offsetof(struct thread_options, latency_window),
3490                 .help   = "Time to sustain latency_target",
3491                 .is_time = 1,
3492                 .category = FIO_OPT_C_IO,
3493                 .group  = FIO_OPT_G_LATPROF,
3494         },
3495         {
3496                 .name   = "latency_percentile",
3497                 .lname  = "Latency Percentile",
3498                 .type   = FIO_OPT_FLOAT_LIST,
3499                 .off1   = offsetof(struct thread_options, latency_percentile),
3500                 .help   = "Percentile of IOs must be below latency_target",
3501                 .def    = "100",
3502                 .maxlen = 1,
3503                 .minfp  = 0.0,
3504                 .maxfp  = 100.0,
3505                 .category = FIO_OPT_C_IO,
3506                 .group  = FIO_OPT_G_LATPROF,
3507         },
3508         {
3509                 .name   = "invalidate",
3510                 .lname  = "Cache invalidate",
3511                 .type   = FIO_OPT_BOOL,
3512                 .off1   = offsetof(struct thread_options, invalidate_cache),
3513                 .help   = "Invalidate buffer/page cache prior to running job",
3514                 .def    = "1",
3515                 .category = FIO_OPT_C_IO,
3516                 .group  = FIO_OPT_G_IO_TYPE,
3517         },
3518         {
3519                 .name   = "sync",
3520                 .lname  = "Synchronous I/O",
3521                 .type   = FIO_OPT_BOOL,
3522                 .off1   = offsetof(struct thread_options, sync_io),
3523                 .help   = "Use O_SYNC for buffered writes",
3524                 .def    = "0",
3525                 .parent = "buffered",
3526                 .hide   = 1,
3527                 .category = FIO_OPT_C_IO,
3528                 .group  = FIO_OPT_G_IO_TYPE,
3529         },
3530 #ifdef FIO_HAVE_WRITE_HINT
3531         {
3532                 .name   = "write_hint",
3533                 .lname  = "Write hint",
3534                 .type   = FIO_OPT_STR,
3535                 .off1   = offsetof(struct thread_options, write_hint),
3536                 .help   = "Set expected write life time",
3537                 .category = FIO_OPT_C_ENGINE,
3538                 .group  = FIO_OPT_G_INVALID,
3539                 .posval = {
3540                           { .ival = "none",
3541                             .oval = RWH_WRITE_LIFE_NONE,
3542                           },
3543                           { .ival = "short",
3544                             .oval = RWH_WRITE_LIFE_SHORT,
3545                           },
3546                           { .ival = "medium",
3547                             .oval = RWH_WRITE_LIFE_MEDIUM,
3548                           },
3549                           { .ival = "long",
3550                             .oval = RWH_WRITE_LIFE_LONG,
3551                           },
3552                           { .ival = "extreme",
3553                             .oval = RWH_WRITE_LIFE_EXTREME,
3554                           },
3555                 },
3556         },
3557 #endif
3558         {
3559                 .name   = "create_serialize",
3560                 .lname  = "Create serialize",
3561                 .type   = FIO_OPT_BOOL,
3562                 .off1   = offsetof(struct thread_options, create_serialize),
3563                 .help   = "Serialize creation of job files",
3564                 .def    = "1",
3565                 .category = FIO_OPT_C_FILE,
3566                 .group  = FIO_OPT_G_INVALID,
3567         },
3568         {
3569                 .name   = "create_fsync",
3570                 .lname  = "Create fsync",
3571                 .type   = FIO_OPT_BOOL,
3572                 .off1   = offsetof(struct thread_options, create_fsync),
3573                 .help   = "fsync file after creation",
3574                 .def    = "1",
3575                 .category = FIO_OPT_C_FILE,
3576                 .group  = FIO_OPT_G_INVALID,
3577         },
3578         {
3579                 .name   = "create_on_open",
3580                 .lname  = "Create on open",
3581                 .type   = FIO_OPT_BOOL,
3582                 .off1   = offsetof(struct thread_options, create_on_open),
3583                 .help   = "Create files when they are opened for IO",
3584                 .def    = "0",
3585                 .category = FIO_OPT_C_FILE,
3586                 .group  = FIO_OPT_G_INVALID,
3587         },
3588         {
3589                 .name   = "create_only",
3590                 .lname  = "Create Only",
3591                 .type   = FIO_OPT_BOOL,
3592                 .off1   = offsetof(struct thread_options, create_only),
3593                 .help   = "Only perform file creation phase",
3594                 .category = FIO_OPT_C_FILE,
3595                 .def    = "0",
3596         },
3597         {
3598                 .name   = "allow_file_create",
3599                 .lname  = "Allow file create",
3600                 .type   = FIO_OPT_BOOL,
3601                 .off1   = offsetof(struct thread_options, allow_create),
3602                 .help   = "Permit fio to create files, if they don't exist",
3603                 .def    = "1",
3604                 .category = FIO_OPT_C_FILE,
3605                 .group  = FIO_OPT_G_FILENAME,
3606         },
3607         {
3608                 .name   = "allow_mounted_write",
3609                 .lname  = "Allow mounted write",
3610                 .type   = FIO_OPT_BOOL,
3611                 .off1   = offsetof(struct thread_options, allow_mounted_write),
3612                 .help   = "Allow writes to a mounted partition",
3613                 .def    = "0",
3614                 .category = FIO_OPT_C_FILE,
3615                 .group  = FIO_OPT_G_FILENAME,
3616         },
3617         {
3618                 .name   = "pre_read",
3619                 .lname  = "Pre-read files",
3620                 .type   = FIO_OPT_BOOL,
3621                 .off1   = offsetof(struct thread_options, pre_read),
3622                 .help   = "Pre-read files before starting official testing",
3623                 .def    = "0",
3624                 .category = FIO_OPT_C_FILE,
3625                 .group  = FIO_OPT_G_INVALID,
3626         },
3627 #ifdef FIO_HAVE_CPU_AFFINITY
3628         {
3629                 .name   = "cpumask",
3630                 .lname  = "CPU mask",
3631                 .type   = FIO_OPT_INT,
3632                 .cb     = str_cpumask_cb,
3633                 .off1   = offsetof(struct thread_options, cpumask),
3634                 .help   = "CPU affinity mask",
3635                 .category = FIO_OPT_C_GENERAL,
3636                 .group  = FIO_OPT_G_CRED,
3637         },
3638         {
3639                 .name   = "cpus_allowed",
3640                 .lname  = "CPUs allowed",
3641                 .type   = FIO_OPT_STR,
3642                 .cb     = str_cpus_allowed_cb,
3643                 .off1   = offsetof(struct thread_options, cpumask),
3644                 .help   = "Set CPUs allowed",
3645                 .category = FIO_OPT_C_GENERAL,
3646                 .group  = FIO_OPT_G_CRED,
3647         },
3648         {
3649                 .name   = "cpus_allowed_policy",
3650                 .lname  = "CPUs allowed distribution policy",
3651                 .type   = FIO_OPT_STR,
3652                 .off1   = offsetof(struct thread_options, cpus_allowed_policy),
3653                 .help   = "Distribution policy for cpus_allowed",
3654                 .parent = "cpus_allowed",
3655                 .prio   = 1,
3656                 .posval = {
3657                           { .ival = "shared",
3658                             .oval = FIO_CPUS_SHARED,
3659                             .help = "Mask shared between threads",
3660                           },
3661                           { .ival = "split",
3662                             .oval = FIO_CPUS_SPLIT,
3663                             .help = "Mask split between threads",
3664                           },
3665                 },
3666                 .category = FIO_OPT_C_GENERAL,
3667                 .group  = FIO_OPT_G_CRED,
3668         },
3669 #else
3670         {
3671                 .name   = "cpumask",
3672                 .lname  = "CPU mask",
3673                 .type   = FIO_OPT_UNSUPPORTED,
3674                 .help   = "Your platform does not support CPU affinities",
3675         },
3676         {
3677                 .name   = "cpus_allowed",
3678                 .lname  = "CPUs allowed",
3679                 .type   = FIO_OPT_UNSUPPORTED,
3680                 .help   = "Your platform does not support CPU affinities",
3681         },
3682         {
3683                 .name   = "cpus_allowed_policy",
3684                 .lname  = "CPUs allowed distribution policy",
3685                 .type   = FIO_OPT_UNSUPPORTED,
3686                 .help   = "Your platform does not support CPU affinities",
3687         },
3688 #endif
3689 #ifdef CONFIG_LIBNUMA
3690         {
3691                 .name   = "numa_cpu_nodes",
3692                 .lname  = "NUMA CPU Nodes",
3693                 .type   = FIO_OPT_STR,
3694                 .cb     = str_numa_cpunodes_cb,
3695                 .off1   = offsetof(struct thread_options, numa_cpunodes),
3696                 .help   = "NUMA CPU nodes bind",
3697                 .category = FIO_OPT_C_GENERAL,
3698                 .group  = FIO_OPT_G_INVALID,
3699         },
3700         {
3701                 .name   = "numa_mem_policy",
3702                 .lname  = "NUMA Memory Policy",
3703                 .type   = FIO_OPT_STR,
3704                 .cb     = str_numa_mpol_cb,
3705                 .off1   = offsetof(struct thread_options, numa_memnodes),
3706                 .help   = "NUMA memory policy setup",
3707                 .category = FIO_OPT_C_GENERAL,
3708                 .group  = FIO_OPT_G_INVALID,
3709         },
3710 #else
3711         {
3712                 .name   = "numa_cpu_nodes",
3713                 .lname  = "NUMA CPU Nodes",
3714                 .type   = FIO_OPT_UNSUPPORTED,
3715                 .help   = "Build fio with libnuma-dev(el) to enable this option",
3716         },
3717         {
3718                 .name   = "numa_mem_policy",
3719                 .lname  = "NUMA Memory Policy",
3720                 .type   = FIO_OPT_UNSUPPORTED,
3721                 .help   = "Build fio with libnuma-dev(el) to enable this option",
3722         },
3723 #endif
3724 #ifdef CONFIG_CUDA
3725         {
3726                 .name   = "gpu_dev_id",
3727                 .lname  = "GPU device ID",
3728                 .type   = FIO_OPT_INT,
3729                 .off1   = offsetof(struct thread_options, gpu_dev_id),
3730                 .help   = "Set GPU device ID for GPUDirect RDMA",
3731                 .def    = "0",
3732                 .category = FIO_OPT_C_GENERAL,
3733                 .group  = FIO_OPT_G_INVALID,
3734         },
3735 #endif
3736         {
3737                 .name   = "end_fsync",
3738                 .lname  = "End fsync",
3739                 .type   = FIO_OPT_BOOL,
3740                 .off1   = offsetof(struct thread_options, end_fsync),
3741                 .help   = "Include fsync at the end of job",
3742                 .def    = "0",
3743                 .category = FIO_OPT_C_FILE,
3744                 .group  = FIO_OPT_G_INVALID,
3745         },
3746         {
3747                 .name   = "fsync_on_close",
3748                 .lname  = "Fsync on close",
3749                 .type   = FIO_OPT_BOOL,
3750                 .off1   = offsetof(struct thread_options, fsync_on_close),
3751                 .help   = "fsync files on close",
3752                 .def    = "0",
3753                 .category = FIO_OPT_C_FILE,
3754                 .group  = FIO_OPT_G_INVALID,
3755         },
3756         {
3757                 .name   = "unlink",
3758                 .lname  = "Unlink file",
3759                 .type   = FIO_OPT_BOOL,
3760                 .off1   = offsetof(struct thread_options, unlink),
3761                 .help   = "Unlink created files after job has completed",
3762                 .def    = "0",
3763                 .category = FIO_OPT_C_FILE,
3764                 .group  = FIO_OPT_G_INVALID,
3765         },
3766         {
3767                 .name   = "unlink_each_loop",
3768                 .lname  = "Unlink file after each loop of a job",
3769                 .type   = FIO_OPT_BOOL,
3770                 .off1   = offsetof(struct thread_options, unlink_each_loop),
3771                 .help   = "Unlink created files after each loop in a job has completed",
3772                 .def    = "0",
3773                 .category = FIO_OPT_C_FILE,
3774                 .group  = FIO_OPT_G_INVALID,
3775         },
3776         {
3777                 .name   = "exitall",
3778                 .lname  = "Exit-all on terminate",
3779                 .type   = FIO_OPT_STR_SET,
3780                 .cb     = str_exitall_cb,
3781                 .help   = "Terminate all jobs when one exits",
3782                 .category = FIO_OPT_C_GENERAL,
3783                 .group  = FIO_OPT_G_PROCESS,
3784         },
3785         {
3786                 .name   = "exitall_on_error",
3787                 .lname  = "Exit-all on terminate in error",
3788                 .type   = FIO_OPT_STR_SET,
3789                 .off1   = offsetof(struct thread_options, exitall_error),
3790                 .help   = "Terminate all jobs when one exits in error",
3791                 .category = FIO_OPT_C_GENERAL,
3792                 .group  = FIO_OPT_G_PROCESS,
3793         },
3794         {
3795                 .name   = "stonewall",
3796                 .lname  = "Wait for previous",
3797                 .alias  = "wait_for_previous",
3798                 .type   = FIO_OPT_STR_SET,
3799                 .off1   = offsetof(struct thread_options, stonewall),
3800                 .help   = "Insert a hard barrier between this job and previous",
3801                 .category = FIO_OPT_C_GENERAL,
3802                 .group  = FIO_OPT_G_PROCESS,
3803         },
3804         {
3805                 .name   = "new_group",
3806                 .lname  = "New group",
3807                 .type   = FIO_OPT_STR_SET,
3808                 .off1   = offsetof(struct thread_options, new_group),
3809                 .help   = "Mark the start of a new group (for reporting)",
3810                 .category = FIO_OPT_C_GENERAL,
3811                 .group  = FIO_OPT_G_PROCESS,
3812         },
3813         {
3814                 .name   = "thread",
3815                 .lname  = "Thread",
3816                 .type   = FIO_OPT_STR_SET,
3817                 .off1   = offsetof(struct thread_options, use_thread),
3818                 .help   = "Use threads instead of processes",
3819 #ifdef CONFIG_NO_SHM
3820                 .def    = "1",
3821                 .no_warn_def = 1,
3822 #endif
3823                 .category = FIO_OPT_C_GENERAL,
3824                 .group  = FIO_OPT_G_PROCESS,
3825         },
3826         {
3827                 .name   = "per_job_logs",
3828                 .lname  = "Per Job Logs",
3829                 .type   = FIO_OPT_BOOL,
3830                 .off1   = offsetof(struct thread_options, per_job_logs),
3831                 .help   = "Include job number in generated log files or not",
3832                 .def    = "1",
3833                 .category = FIO_OPT_C_LOG,
3834                 .group  = FIO_OPT_G_INVALID,
3835         },
3836         {
3837                 .name   = "write_bw_log",
3838                 .lname  = "Write bandwidth log",
3839                 .type   = FIO_OPT_STR,
3840                 .off1   = offsetof(struct thread_options, bw_log_file),
3841                 .cb     = str_write_bw_log_cb,
3842                 .help   = "Write log of bandwidth during run",
3843                 .category = FIO_OPT_C_LOG,
3844                 .group  = FIO_OPT_G_INVALID,
3845         },
3846         {
3847                 .name   = "write_lat_log",
3848                 .lname  = "Write latency log",
3849                 .type   = FIO_OPT_STR,
3850                 .off1   = offsetof(struct thread_options, lat_log_file),
3851                 .cb     = str_write_lat_log_cb,
3852                 .help   = "Write log of latency during run",
3853                 .category = FIO_OPT_C_LOG,
3854                 .group  = FIO_OPT_G_INVALID,
3855         },
3856         {
3857                 .name   = "write_iops_log",
3858                 .lname  = "Write IOPS log",
3859                 .type   = FIO_OPT_STR,
3860                 .off1   = offsetof(struct thread_options, iops_log_file),
3861                 .cb     = str_write_iops_log_cb,
3862                 .help   = "Write log of IOPS during run",
3863                 .category = FIO_OPT_C_LOG,
3864                 .group  = FIO_OPT_G_INVALID,
3865         },
3866         {
3867                 .name   = "log_avg_msec",
3868                 .lname  = "Log averaging (msec)",
3869                 .type   = FIO_OPT_INT,
3870                 .off1   = offsetof(struct thread_options, log_avg_msec),
3871                 .help   = "Average bw/iops/lat logs over this period of time",
3872                 .def    = "0",
3873                 .category = FIO_OPT_C_LOG,
3874                 .group  = FIO_OPT_G_INVALID,
3875         },
3876         {
3877                 .name   = "log_hist_msec",
3878                 .lname  = "Log histograms (msec)",
3879                 .type   = FIO_OPT_INT,
3880                 .off1   = offsetof(struct thread_options, log_hist_msec),
3881                 .help   = "Dump completion latency histograms at frequency of this time value",
3882                 .def    = "0",
3883                 .category = FIO_OPT_C_LOG,
3884                 .group  = FIO_OPT_G_INVALID,
3885         },
3886         {
3887                 .name   = "log_hist_coarseness",
3888                 .lname  = "Histogram logs coarseness",
3889                 .type   = FIO_OPT_INT,
3890                 .off1   = offsetof(struct thread_options, log_hist_coarseness),
3891                 .help   = "Integer in range [0,6]. Higher coarseness outputs"
3892                         " fewer histogram bins per sample. The number of bins for"
3893                         " these are [1216, 608, 304, 152, 76, 38, 19] respectively.",
3894                 .def    = "0",
3895                 .category = FIO_OPT_C_LOG,
3896                 .group  = FIO_OPT_G_INVALID,
3897         },
3898         {
3899                 .name   = "write_hist_log",
3900                 .lname  = "Write latency histogram logs",
3901                 .type   = FIO_OPT_STR,
3902                 .off1   = offsetof(struct thread_options, hist_log_file),
3903                 .cb     = str_write_hist_log_cb,
3904                 .help   = "Write log of latency histograms during run",
3905                 .category = FIO_OPT_C_LOG,
3906                 .group  = FIO_OPT_G_INVALID,
3907         },
3908         {
3909                 .name   = "log_max_value",
3910                 .lname  = "Log maximum instead of average",
3911                 .type   = FIO_OPT_BOOL,
3912                 .off1   = offsetof(struct thread_options, log_max),
3913                 .help   = "Log max sample in a window instead of average",
3914                 .def    = "0",
3915                 .category = FIO_OPT_C_LOG,
3916                 .group  = FIO_OPT_G_INVALID,
3917         },
3918         {
3919                 .name   = "log_offset",
3920                 .lname  = "Log offset of IO",
3921                 .type   = FIO_OPT_BOOL,
3922                 .off1   = offsetof(struct thread_options, log_offset),
3923                 .help   = "Include offset of IO for each log entry",
3924                 .def    = "0",
3925                 .category = FIO_OPT_C_LOG,
3926                 .group  = FIO_OPT_G_INVALID,
3927         },
3928 #ifdef CONFIG_ZLIB
3929         {
3930                 .name   = "log_compression",
3931                 .lname  = "Log compression",
3932                 .type   = FIO_OPT_INT,
3933                 .off1   = offsetof(struct thread_options, log_gz),
3934                 .help   = "Log in compressed chunks of this size",
3935                 .minval = 1024ULL,
3936                 .maxval = 512 * 1024 * 1024ULL,
3937                 .category = FIO_OPT_C_LOG,
3938                 .group  = FIO_OPT_G_INVALID,
3939         },
3940 #ifdef FIO_HAVE_CPU_AFFINITY
3941         {
3942                 .name   = "log_compression_cpus",
3943                 .lname  = "Log Compression CPUs",
3944                 .type   = FIO_OPT_STR,
3945                 .cb     = str_log_cpus_allowed_cb,
3946                 .off1   = offsetof(struct thread_options, log_gz_cpumask),
3947                 .parent = "log_compression",
3948                 .help   = "Limit log compression to these CPUs",
3949                 .category = FIO_OPT_C_LOG,
3950                 .group  = FIO_OPT_G_INVALID,
3951         },
3952 #else
3953         {
3954                 .name   = "log_compression_cpus",
3955                 .lname  = "Log Compression CPUs",
3956                 .type   = FIO_OPT_UNSUPPORTED,
3957                 .help   = "Your platform does not support CPU affinities",
3958         },
3959 #endif
3960         {
3961                 .name   = "log_store_compressed",
3962                 .lname  = "Log store compressed",
3963                 .type   = FIO_OPT_BOOL,
3964                 .off1   = offsetof(struct thread_options, log_gz_store),
3965                 .help   = "Store logs in a compressed format",
3966                 .category = FIO_OPT_C_LOG,
3967                 .group  = FIO_OPT_G_INVALID,
3968         },
3969 #else
3970         {
3971                 .name   = "log_compression",
3972                 .lname  = "Log compression",
3973                 .type   = FIO_OPT_UNSUPPORTED,
3974                 .help   = "Install libz-dev(el) to get compression support",
3975         },
3976         {
3977                 .name   = "log_store_compressed",
3978                 .lname  = "Log store compressed",
3979                 .type   = FIO_OPT_UNSUPPORTED,
3980                 .help   = "Install libz-dev(el) to get compression support",
3981         },
3982 #endif
3983         {
3984                 .name = "log_unix_epoch",
3985                 .lname = "Log epoch unix",
3986                 .type = FIO_OPT_BOOL,
3987                 .off1 = offsetof(struct thread_options, log_unix_epoch),
3988                 .help = "Use Unix time in log files",
3989                 .category = FIO_OPT_C_LOG,
3990                 .group = FIO_OPT_G_INVALID,
3991         },
3992         {
3993                 .name   = "block_error_percentiles",
3994                 .lname  = "Block error percentiles",
3995                 .type   = FIO_OPT_BOOL,
3996                 .off1   = offsetof(struct thread_options, block_error_hist),
3997                 .help   = "Record trim block errors and make a histogram",
3998                 .def    = "0",
3999                 .category = FIO_OPT_C_LOG,
4000                 .group  = FIO_OPT_G_INVALID,
4001         },
4002         {
4003                 .name   = "bwavgtime",
4004                 .lname  = "Bandwidth average time",
4005                 .type   = FIO_OPT_INT,
4006                 .off1   = offsetof(struct thread_options, bw_avg_time),
4007                 .help   = "Time window over which to calculate bandwidth"
4008                           " (msec)",
4009                 .def    = "500",
4010                 .parent = "write_bw_log",
4011                 .hide   = 1,
4012                 .interval = 100,
4013                 .category = FIO_OPT_C_LOG,
4014                 .group  = FIO_OPT_G_INVALID,
4015         },
4016         {
4017                 .name   = "iopsavgtime",
4018                 .lname  = "IOPS average time",
4019                 .type   = FIO_OPT_INT,
4020                 .off1   = offsetof(struct thread_options, iops_avg_time),
4021                 .help   = "Time window over which to calculate IOPS (msec)",
4022                 .def    = "500",
4023                 .parent = "write_iops_log",
4024                 .hide   = 1,
4025                 .interval = 100,
4026                 .category = FIO_OPT_C_LOG,
4027                 .group  = FIO_OPT_G_INVALID,
4028         },
4029         {
4030                 .name   = "group_reporting",
4031                 .lname  = "Group reporting",
4032                 .type   = FIO_OPT_STR_SET,
4033                 .off1   = offsetof(struct thread_options, group_reporting),
4034                 .help   = "Do reporting on a per-group basis",
4035                 .category = FIO_OPT_C_STAT,
4036                 .group  = FIO_OPT_G_INVALID,
4037         },
4038         {
4039                 .name   = "stats",
4040                 .lname  = "Stats",
4041                 .type   = FIO_OPT_BOOL,
4042                 .off1   = offsetof(struct thread_options, stats),
4043                 .help   = "Enable collection of stats",
4044                 .def    = "1",
4045                 .category = FIO_OPT_C_STAT,
4046                 .group  = FIO_OPT_G_INVALID,
4047         },
4048         {
4049                 .name   = "zero_buffers",
4050                 .lname  = "Zero I/O buffers",
4051                 .type   = FIO_OPT_STR_SET,
4052                 .off1   = offsetof(struct thread_options, zero_buffers),
4053                 .help   = "Init IO buffers to all zeroes",
4054                 .category = FIO_OPT_C_IO,
4055                 .group  = FIO_OPT_G_IO_BUF,
4056         },
4057         {
4058                 .name   = "refill_buffers",
4059                 .lname  = "Refill I/O buffers",
4060                 .type   = FIO_OPT_STR_SET,
4061                 .off1   = offsetof(struct thread_options, refill_buffers),
4062                 .help   = "Refill IO buffers on every IO submit",
4063                 .category = FIO_OPT_C_IO,
4064                 .group  = FIO_OPT_G_IO_BUF,
4065         },
4066         {
4067                 .name   = "scramble_buffers",
4068                 .lname  = "Scramble I/O buffers",
4069                 .type   = FIO_OPT_BOOL,
4070                 .off1   = offsetof(struct thread_options, scramble_buffers),
4071                 .help   = "Slightly scramble buffers on every IO submit",
4072                 .def    = "1",
4073                 .category = FIO_OPT_C_IO,
4074                 .group  = FIO_OPT_G_IO_BUF,
4075         },
4076         {
4077                 .name   = "buffer_pattern",
4078                 .lname  = "Buffer pattern",
4079                 .type   = FIO_OPT_STR,
4080                 .cb     = str_buffer_pattern_cb,
4081                 .off1   = offsetof(struct thread_options, buffer_pattern),
4082                 .help   = "Fill pattern for IO buffers",
4083                 .category = FIO_OPT_C_IO,
4084                 .group  = FIO_OPT_G_IO_BUF,
4085         },
4086         {
4087                 .name   = "buffer_compress_percentage",
4088                 .lname  = "Buffer compression percentage",
4089                 .type   = FIO_OPT_INT,
4090                 .cb     = str_buffer_compress_cb,
4091                 .off1   = offsetof(struct thread_options, compress_percentage),
4092                 .maxval = 100,
4093                 .minval = 0,
4094                 .help   = "How compressible the buffer is (approximately)",
4095                 .interval = 5,
4096                 .category = FIO_OPT_C_IO,
4097                 .group  = FIO_OPT_G_IO_BUF,
4098         },
4099         {
4100                 .name   = "buffer_compress_chunk",
4101                 .lname  = "Buffer compression chunk size",
4102                 .type   = FIO_OPT_INT,
4103                 .off1   = offsetof(struct thread_options, compress_chunk),
4104                 .parent = "buffer_compress_percentage",
4105                 .hide   = 1,
4106                 .help   = "Size of compressible region in buffer",
4107                 .def    = "512",
4108                 .interval = 256,
4109                 .category = FIO_OPT_C_IO,
4110                 .group  = FIO_OPT_G_IO_BUF,
4111         },
4112         {
4113                 .name   = "dedupe_percentage",
4114                 .lname  = "Dedupe percentage",
4115                 .type   = FIO_OPT_INT,
4116                 .cb     = str_dedupe_cb,
4117                 .off1   = offsetof(struct thread_options, dedupe_percentage),
4118                 .maxval = 100,
4119                 .minval = 0,
4120                 .help   = "Percentage of buffers that are dedupable",
4121                 .interval = 1,
4122                 .category = FIO_OPT_C_IO,
4123                 .group  = FIO_OPT_G_IO_BUF,
4124         },
4125         {
4126                 .name   = "clat_percentiles",
4127                 .lname  = "Completion latency percentiles",
4128                 .type   = FIO_OPT_BOOL,
4129                 .off1   = offsetof(struct thread_options, clat_percentiles),
4130                 .help   = "Enable the reporting of completion latency percentiles",
4131                 .def    = "1",
4132                 .inverse = "lat_percentiles",
4133                 .category = FIO_OPT_C_STAT,
4134                 .group  = FIO_OPT_G_INVALID,
4135         },
4136         {
4137                 .name   = "lat_percentiles",
4138                 .lname  = "IO latency percentiles",
4139                 .type   = FIO_OPT_BOOL,
4140                 .off1   = offsetof(struct thread_options, lat_percentiles),
4141                 .help   = "Enable the reporting of IO latency percentiles",
4142                 .def    = "0",
4143                 .inverse = "clat_percentiles",
4144                 .category = FIO_OPT_C_STAT,
4145                 .group  = FIO_OPT_G_INVALID,
4146         },
4147         {
4148                 .name   = "percentile_list",
4149                 .lname  = "Percentile list",
4150                 .type   = FIO_OPT_FLOAT_LIST,
4151                 .off1   = offsetof(struct thread_options, percentile_list),
4152                 .off2   = offsetof(struct thread_options, percentile_precision),
4153                 .help   = "Specify a custom list of percentiles to report for "
4154                           "completion latency and block errors",
4155                 .def    = "1:5:10:20:30:40:50:60:70:80:90:95:99:99.5:99.9:99.95:99.99",
4156                 .maxlen = FIO_IO_U_LIST_MAX_LEN,
4157                 .minfp  = 0.0,
4158                 .maxfp  = 100.0,
4159                 .category = FIO_OPT_C_STAT,
4160                 .group  = FIO_OPT_G_INVALID,
4161         },
4162         {
4163                 .name   = "significant_figures",
4164                 .lname  = "Significant figures",
4165                 .type   = FIO_OPT_INT,
4166                 .off1   = offsetof(struct thread_options, sig_figs),
4167                 .maxval = 10,
4168                 .minval = 1,
4169                 .help   = "Significant figures for output-format set to normal",
4170                 .def    = "4",
4171                 .interval = 1,
4172                 .category = FIO_OPT_C_STAT,
4173                 .group  = FIO_OPT_G_INVALID,
4174         },
4175
4176 #ifdef FIO_HAVE_DISK_UTIL
4177         {
4178                 .name   = "disk_util",
4179                 .lname  = "Disk utilization",
4180                 .type   = FIO_OPT_BOOL,
4181                 .off1   = offsetof(struct thread_options, do_disk_util),
4182                 .help   = "Log disk utilization statistics",
4183                 .def    = "1",
4184                 .category = FIO_OPT_C_STAT,
4185                 .group  = FIO_OPT_G_INVALID,
4186         },
4187 #else
4188         {
4189                 .name   = "disk_util",
4190                 .lname  = "Disk utilization",
4191                 .type   = FIO_OPT_UNSUPPORTED,
4192                 .help   = "Your platform does not support disk utilization",
4193         },
4194 #endif
4195         {
4196                 .name   = "gtod_reduce",
4197                 .lname  = "Reduce gettimeofday() calls",
4198                 .type   = FIO_OPT_BOOL,
4199                 .help   = "Greatly reduce number of gettimeofday() calls",
4200                 .cb     = str_gtod_reduce_cb,
4201                 .def    = "0",
4202                 .hide_on_set = 1,
4203                 .category = FIO_OPT_C_STAT,
4204                 .group  = FIO_OPT_G_INVALID,
4205         },
4206         {
4207                 .name   = "disable_lat",
4208                 .lname  = "Disable all latency stats",
4209                 .type   = FIO_OPT_BOOL,
4210                 .off1   = offsetof(struct thread_options, disable_lat),
4211                 .help   = "Disable latency numbers",
4212                 .parent = "gtod_reduce",
4213                 .hide   = 1,
4214                 .def    = "0",
4215                 .category = FIO_OPT_C_STAT,
4216                 .group  = FIO_OPT_G_INVALID,
4217         },
4218         {
4219                 .name   = "disable_clat",
4220                 .lname  = "Disable completion latency stats",
4221                 .type   = FIO_OPT_BOOL,
4222                 .off1   = offsetof(struct thread_options, disable_clat),
4223                 .help   = "Disable completion latency numbers",
4224                 .parent = "gtod_reduce",
4225                 .hide   = 1,
4226                 .def    = "0",
4227                 .category = FIO_OPT_C_STAT,
4228                 .group  = FIO_OPT_G_INVALID,
4229         },
4230         {
4231                 .name   = "disable_slat",
4232                 .lname  = "Disable submission latency stats",
4233                 .type   = FIO_OPT_BOOL,
4234                 .off1   = offsetof(struct thread_options, disable_slat),
4235                 .help   = "Disable submission latency numbers",
4236                 .parent = "gtod_reduce",
4237                 .hide   = 1,
4238                 .def    = "0",
4239                 .category = FIO_OPT_C_STAT,
4240                 .group  = FIO_OPT_G_INVALID,
4241         },
4242         {
4243                 .name   = "disable_bw_measurement",
4244                 .alias  = "disable_bw",
4245                 .lname  = "Disable bandwidth stats",
4246                 .type   = FIO_OPT_BOOL,
4247                 .off1   = offsetof(struct thread_options, disable_bw),
4248                 .help   = "Disable bandwidth logging",
4249                 .parent = "gtod_reduce",
4250                 .hide   = 1,
4251                 .def    = "0",
4252                 .category = FIO_OPT_C_STAT,
4253                 .group  = FIO_OPT_G_INVALID,
4254         },
4255         {
4256                 .name   = "gtod_cpu",
4257                 .lname  = "Dedicated gettimeofday() CPU",
4258                 .type   = FIO_OPT_INT,
4259                 .off1   = offsetof(struct thread_options, gtod_cpu),
4260                 .help   = "Set up dedicated gettimeofday() thread on this CPU",
4261                 .verify = gtod_cpu_verify,
4262                 .category = FIO_OPT_C_GENERAL,
4263                 .group  = FIO_OPT_G_CLOCK,
4264         },
4265         {
4266                 .name   = "unified_rw_reporting",
4267                 .lname  = "Unified RW Reporting",
4268                 .type   = FIO_OPT_BOOL,
4269                 .off1   = offsetof(struct thread_options, unified_rw_rep),
4270                 .help   = "Unify reporting across data direction",
4271                 .def    = "0",
4272                 .category = FIO_OPT_C_GENERAL,
4273                 .group  = FIO_OPT_G_INVALID,
4274         },
4275         {
4276                 .name   = "continue_on_error",
4277                 .lname  = "Continue on error",
4278                 .type   = FIO_OPT_STR,
4279                 .off1   = offsetof(struct thread_options, continue_on_error),
4280                 .help   = "Continue on non-fatal errors during IO",
4281                 .def    = "none",
4282                 .category = FIO_OPT_C_GENERAL,
4283                 .group  = FIO_OPT_G_ERR,
4284                 .posval = {
4285                           { .ival = "none",
4286                             .oval = ERROR_TYPE_NONE,
4287                             .help = "Exit when an error is encountered",
4288                           },
4289                           { .ival = "read",
4290                             .oval = ERROR_TYPE_READ,
4291                             .help = "Continue on read errors only",
4292                           },
4293                           { .ival = "write",
4294                             .oval = ERROR_TYPE_WRITE,
4295                             .help = "Continue on write errors only",
4296                           },
4297                           { .ival = "io",
4298                             .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
4299                             .help = "Continue on any IO errors",
4300                           },
4301                           { .ival = "verify",
4302                             .oval = ERROR_TYPE_VERIFY,
4303                             .help = "Continue on verify errors only",
4304                           },
4305                           { .ival = "all",
4306                             .oval = ERROR_TYPE_ANY,
4307                             .help = "Continue on all io and verify errors",
4308                           },
4309                           { .ival = "0",
4310                             .oval = ERROR_TYPE_NONE,
4311                             .help = "Alias for 'none'",
4312                           },
4313                           { .ival = "1",
4314                             .oval = ERROR_TYPE_ANY,
4315                             .help = "Alias for 'all'",
4316                           },
4317                 },
4318         },
4319         {
4320                 .name   = "ignore_error",
4321                 .lname  = "Ignore Error",
4322                 .type   = FIO_OPT_STR,
4323                 .cb     = str_ignore_error_cb,
4324                 .off1   = offsetof(struct thread_options, ignore_error_nr),
4325                 .help   = "Set a specific list of errors to ignore",
4326                 .parent = "rw",
4327                 .category = FIO_OPT_C_GENERAL,
4328                 .group  = FIO_OPT_G_ERR,
4329         },
4330         {
4331                 .name   = "error_dump",
4332                 .lname  = "Error Dump",
4333                 .type   = FIO_OPT_BOOL,
4334                 .off1   = offsetof(struct thread_options, error_dump),
4335                 .def    = "0",
4336                 .help   = "Dump info on each error",
4337                 .category = FIO_OPT_C_GENERAL,
4338                 .group  = FIO_OPT_G_ERR,
4339         },
4340         {
4341                 .name   = "profile",
4342                 .lname  = "Profile",
4343                 .type   = FIO_OPT_STR_STORE,
4344                 .off1   = offsetof(struct thread_options, profile),
4345                 .help   = "Select a specific builtin performance test",
4346                 .category = FIO_OPT_C_PROFILE,
4347                 .group  = FIO_OPT_G_INVALID,
4348         },
4349         {
4350                 .name   = "cgroup",
4351                 .lname  = "Cgroup",
4352                 .type   = FIO_OPT_STR_STORE,
4353                 .off1   = offsetof(struct thread_options, cgroup),
4354                 .help   = "Add job to cgroup of this name",
4355                 .category = FIO_OPT_C_GENERAL,
4356                 .group  = FIO_OPT_G_CGROUP,
4357         },
4358         {
4359                 .name   = "cgroup_nodelete",
4360                 .lname  = "Cgroup no-delete",
4361                 .type   = FIO_OPT_BOOL,
4362                 .off1   = offsetof(struct thread_options, cgroup_nodelete),
4363                 .help   = "Do not delete cgroups after job completion",
4364                 .def    = "0",
4365                 .parent = "cgroup",
4366                 .category = FIO_OPT_C_GENERAL,
4367                 .group  = FIO_OPT_G_CGROUP,
4368         },
4369         {
4370                 .name   = "cgroup_weight",
4371                 .lname  = "Cgroup weight",
4372                 .type   = FIO_OPT_INT,
4373                 .off1   = offsetof(struct thread_options, cgroup_weight),
4374                 .help   = "Use given weight for cgroup",
4375                 .minval = 100,
4376                 .maxval = 1000,
4377                 .parent = "cgroup",
4378                 .category = FIO_OPT_C_GENERAL,
4379                 .group  = FIO_OPT_G_CGROUP,
4380         },
4381         {
4382                 .name   = "uid",
4383                 .lname  = "User ID",
4384                 .type   = FIO_OPT_INT,
4385                 .off1   = offsetof(struct thread_options, uid),
4386                 .help   = "Run job with this user ID",
4387                 .category = FIO_OPT_C_GENERAL,
4388                 .group  = FIO_OPT_G_CRED,
4389         },
4390         {
4391                 .name   = "gid",
4392                 .lname  = "Group ID",
4393                 .type   = FIO_OPT_INT,
4394                 .off1   = offsetof(struct thread_options, gid),
4395                 .help   = "Run job with this group ID",
4396                 .category = FIO_OPT_C_GENERAL,
4397                 .group  = FIO_OPT_G_CRED,
4398         },
4399         {
4400                 .name   = "kb_base",
4401                 .lname  = "KB Base",
4402                 .type   = FIO_OPT_INT,
4403                 .off1   = offsetof(struct thread_options, kb_base),
4404                 .prio   = 1,
4405                 .def    = "1024",
4406                 .posval = {
4407                           { .ival = "1024",
4408                             .oval = 1024,
4409                             .help = "Inputs invert IEC and SI prefixes (for compatibility); outputs prefer binary",
4410                           },
4411                           { .ival = "1000",
4412                             .oval = 1000,
4413                             .help = "Inputs use IEC and SI prefixes; outputs prefer SI",
4414                           },
4415                 },
4416                 .help   = "Unit prefix interpretation for quantities of data (IEC and SI)",
4417                 .category = FIO_OPT_C_GENERAL,
4418                 .group  = FIO_OPT_G_INVALID,
4419         },
4420         {
4421                 .name   = "unit_base",
4422                 .lname  = "Unit for quantities of data (Bits or Bytes)",
4423                 .type   = FIO_OPT_INT,
4424                 .off1   = offsetof(struct thread_options, unit_base),
4425                 .prio   = 1,
4426                 .posval = {
4427                           { .ival = "0",
4428                             .oval = N2S_NONE,
4429                             .help = "Auto-detect",
4430                           },
4431                           { .ival = "8",
4432                             .oval = N2S_BYTEPERSEC,
4433                             .help = "Normal (byte based)",
4434                           },
4435                           { .ival = "1",
4436                             .oval = N2S_BITPERSEC,
4437                             .help = "Bit based",
4438                           },
4439                 },
4440                 .help   = "Bit multiple of result summary data (8 for byte, 1 for bit)",
4441                 .category = FIO_OPT_C_GENERAL,
4442                 .group  = FIO_OPT_G_INVALID,
4443         },
4444         {
4445                 .name   = "hugepage-size",
4446                 .lname  = "Hugepage size",
4447                 .type   = FIO_OPT_INT,
4448                 .off1   = offsetof(struct thread_options, hugepage_size),
4449                 .help   = "When using hugepages, specify size of each page",
4450                 .def    = __fio_stringify(FIO_HUGE_PAGE),
4451                 .interval = 1024 * 1024,
4452                 .category = FIO_OPT_C_GENERAL,
4453                 .group  = FIO_OPT_G_INVALID,
4454         },
4455         {
4456                 .name   = "flow_id",
4457                 .lname  = "I/O flow ID",
4458                 .type   = FIO_OPT_INT,
4459                 .off1   = offsetof(struct thread_options, flow_id),
4460                 .help   = "The flow index ID to use",
4461                 .def    = "0",
4462                 .category = FIO_OPT_C_IO,
4463                 .group  = FIO_OPT_G_IO_FLOW,
4464         },
4465         {
4466                 .name   = "flow",
4467                 .lname  = "I/O flow weight",
4468                 .type   = FIO_OPT_INT,
4469                 .off1   = offsetof(struct thread_options, flow),
4470                 .help   = "Weight for flow control of this job",
4471                 .parent = "flow_id",
4472                 .hide   = 1,
4473                 .def    = "0",
4474                 .category = FIO_OPT_C_IO,
4475                 .group  = FIO_OPT_G_IO_FLOW,
4476         },
4477         {
4478                 .name   = "flow_watermark",
4479                 .lname  = "I/O flow watermark",
4480                 .type   = FIO_OPT_INT,
4481                 .off1   = offsetof(struct thread_options, flow_watermark),
4482                 .help   = "High watermark for flow control. This option"
4483                         " should be set to the same value for all threads"
4484                         " with non-zero flow.",
4485                 .parent = "flow_id",
4486                 .hide   = 1,
4487                 .def    = "1024",
4488                 .category = FIO_OPT_C_IO,
4489                 .group  = FIO_OPT_G_IO_FLOW,
4490         },
4491         {
4492                 .name   = "flow_sleep",
4493                 .lname  = "I/O flow sleep",
4494                 .type   = FIO_OPT_INT,
4495                 .off1   = offsetof(struct thread_options, flow_sleep),
4496                 .help   = "How many microseconds to sleep after being held"
4497                         " back by the flow control mechanism",
4498                 .parent = "flow_id",
4499                 .hide   = 1,
4500                 .def    = "0",
4501                 .category = FIO_OPT_C_IO,
4502                 .group  = FIO_OPT_G_IO_FLOW,
4503         },
4504         {
4505                 .name   = "steadystate",
4506                 .lname  = "Steady state threshold",
4507                 .alias  = "ss",
4508                 .type   = FIO_OPT_STR,
4509                 .off1   = offsetof(struct thread_options, ss_state),
4510                 .cb     = str_steadystate_cb,
4511                 .help   = "Define the criterion and limit to judge when a job has reached steady state",
4512                 .def    = "iops_slope:0.01%",
4513                 .posval = {
4514                           { .ival = "iops",
4515                             .oval = FIO_SS_IOPS,
4516                             .help = "maximum mean deviation of IOPS measurements",
4517                           },
4518                           { .ival = "iops_slope",
4519                             .oval = FIO_SS_IOPS_SLOPE,
4520                             .help = "slope calculated from IOPS measurements",
4521                           },
4522                           { .ival = "bw",
4523                             .oval = FIO_SS_BW,
4524                             .help = "maximum mean deviation of bandwidth measurements",
4525                           },
4526                           {
4527                             .ival = "bw_slope",
4528                             .oval = FIO_SS_BW_SLOPE,
4529                             .help = "slope calculated from bandwidth measurements",
4530                           },
4531                 },
4532                 .category = FIO_OPT_C_GENERAL,
4533                 .group  = FIO_OPT_G_RUNTIME,
4534         },
4535         {
4536                 .name   = "steadystate_duration",
4537                 .lname  = "Steady state duration",
4538                 .alias  = "ss_dur",
4539                 .parent = "steadystate",
4540                 .type   = FIO_OPT_STR_VAL_TIME,
4541                 .off1   = offsetof(struct thread_options, ss_dur),
4542                 .help   = "Stop workload upon attaining steady state for specified duration",
4543                 .def    = "0",
4544                 .is_seconds = 1,
4545                 .is_time = 1,
4546                 .category = FIO_OPT_C_GENERAL,
4547                 .group  = FIO_OPT_G_RUNTIME,
4548         },
4549         {
4550                 .name   = "steadystate_ramp_time",
4551                 .lname  = "Steady state ramp time",
4552                 .alias  = "ss_ramp",
4553                 .parent = "steadystate",
4554                 .type   = FIO_OPT_STR_VAL_TIME,
4555                 .off1   = offsetof(struct thread_options, ss_ramp_time),
4556                 .help   = "Delay before initiation of data collection for steady state job termination testing",
4557                 .def    = "0",
4558                 .is_seconds = 1,
4559                 .is_time = 1,
4560                 .category = FIO_OPT_C_GENERAL,
4561                 .group  = FIO_OPT_G_RUNTIME,
4562         },
4563         {
4564                 .name = NULL,
4565         },
4566 };
4567
4568 static void add_to_lopt(struct option *lopt, struct fio_option *o,
4569                         const char *name, int val)
4570 {
4571         lopt->name = (char *) name;
4572         lopt->val = val;
4573         if (o->type == FIO_OPT_STR_SET)
4574                 lopt->has_arg = optional_argument;
4575         else
4576                 lopt->has_arg = required_argument;
4577 }
4578
4579 static void options_to_lopts(struct fio_option *opts,
4580                               struct option *long_options,
4581                               int i, int option_type)
4582 {
4583         struct fio_option *o = &opts[0];
4584         while (o->name) {
4585                 add_to_lopt(&long_options[i], o, o->name, option_type);
4586                 if (o->alias) {
4587                         i++;
4588                         add_to_lopt(&long_options[i], o, o->alias, option_type);
4589                 }
4590
4591                 i++;
4592                 o++;
4593                 assert(i < FIO_NR_OPTIONS);
4594         }
4595 }
4596
4597 void fio_options_set_ioengine_opts(struct option *long_options,
4598                                    struct thread_data *td)
4599 {
4600         unsigned int i;
4601
4602         i = 0;
4603         while (long_options[i].name) {
4604                 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
4605                         memset(&long_options[i], 0, sizeof(*long_options));
4606                         break;
4607                 }
4608                 i++;
4609         }
4610
4611         /*
4612          * Just clear out the prior ioengine options.
4613          */
4614         if (!td || !td->eo)
4615                 return;
4616
4617         options_to_lopts(td->io_ops->options, long_options, i,
4618                          FIO_GETOPT_IOENGINE);
4619 }
4620
4621 void fio_options_dup_and_init(struct option *long_options)
4622 {
4623         unsigned int i;
4624
4625         options_init(fio_options);
4626
4627         i = 0;
4628         while (long_options[i].name)
4629                 i++;
4630
4631         options_to_lopts(fio_options, long_options, i, FIO_GETOPT_JOB);
4632 }
4633
4634 struct fio_keyword {
4635         const char *word;
4636         const char *desc;
4637         char *replace;
4638 };
4639
4640 static struct fio_keyword fio_keywords[] = {
4641         {
4642                 .word   = "$pagesize",
4643                 .desc   = "Page size in the system",
4644         },
4645         {
4646                 .word   = "$mb_memory",
4647                 .desc   = "Megabytes of memory online",
4648         },
4649         {
4650                 .word   = "$ncpus",
4651                 .desc   = "Number of CPUs online in the system",
4652         },
4653         {
4654                 .word   = NULL,
4655         },
4656 };
4657
4658 void fio_keywords_exit(void)
4659 {
4660         struct fio_keyword *kw;
4661
4662         kw = &fio_keywords[0];
4663         while (kw->word) {
4664                 free(kw->replace);
4665                 kw->replace = NULL;
4666                 kw++;
4667         }
4668 }
4669
4670 void fio_keywords_init(void)
4671 {
4672         unsigned long long mb_memory;
4673         char buf[128];
4674         long l;
4675
4676         sprintf(buf, "%lu", (unsigned long) page_size);
4677         fio_keywords[0].replace = strdup(buf);
4678
4679         mb_memory = os_phys_mem() / (1024 * 1024);
4680         sprintf(buf, "%llu", mb_memory);
4681         fio_keywords[1].replace = strdup(buf);
4682
4683         l = cpus_online();
4684         sprintf(buf, "%lu", l);
4685         fio_keywords[2].replace = strdup(buf);
4686 }
4687
4688 #define BC_APP          "bc"
4689
4690 static char *bc_calc(char *str)
4691 {
4692         char buf[128], *tmp;
4693         FILE *f;
4694         int ret;
4695
4696         /*
4697          * No math, just return string
4698          */
4699         if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
4700              !strchr(str, '/')) || strchr(str, '\''))
4701                 return str;
4702
4703         /*
4704          * Split option from value, we only need to calculate the value
4705          */
4706         tmp = strchr(str, '=');
4707         if (!tmp)
4708                 return str;
4709
4710         tmp++;
4711
4712         /*
4713          * Prevent buffer overflows; such a case isn't reasonable anyway
4714          */
4715         if (strlen(str) >= 128 || strlen(tmp) > 100)
4716                 return str;
4717
4718         sprintf(buf, "which %s > /dev/null", BC_APP);
4719         if (system(buf)) {
4720                 log_err("fio: bc is needed for performing math\n");
4721                 return NULL;
4722         }
4723
4724         sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
4725         f = popen(buf, "r");
4726         if (!f)
4727                 return NULL;
4728
4729         ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
4730         if (ret <= 0) {
4731                 pclose(f);
4732                 return NULL;
4733         }
4734
4735         pclose(f);
4736         buf[(tmp - str) + ret - 1] = '\0';
4737         memcpy(buf, str, tmp - str);
4738         free(str);
4739         return strdup(buf);
4740 }
4741
4742 /*
4743  * Return a copy of the input string with substrings of the form ${VARNAME}
4744  * substituted with the value of the environment variable VARNAME.  The
4745  * substitution always occurs, even if VARNAME is empty or the corresponding
4746  * environment variable undefined.
4747  */
4748 static char *option_dup_subs(const char *opt)
4749 {
4750         char out[OPT_LEN_MAX+1];
4751         char in[OPT_LEN_MAX+1];
4752         char *outptr = out;
4753         char *inptr = in;
4754         char *ch1, *ch2, *env;
4755         ssize_t nchr = OPT_LEN_MAX;
4756         size_t envlen;
4757
4758         if (strlen(opt) + 1 > OPT_LEN_MAX) {
4759                 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
4760                 return NULL;
4761         }
4762
4763         in[OPT_LEN_MAX] = '\0';
4764         strncpy(in, opt, OPT_LEN_MAX);
4765
4766         while (*inptr && nchr > 0) {
4767                 if (inptr[0] == '$' && inptr[1] == '{') {
4768                         ch2 = strchr(inptr, '}');
4769                         if (ch2 && inptr+1 < ch2) {
4770                                 ch1 = inptr+2;
4771                                 inptr = ch2+1;
4772                                 *ch2 = '\0';
4773
4774                                 env = getenv(ch1);
4775                                 if (env) {
4776                                         envlen = strlen(env);
4777                                         if (envlen <= nchr) {
4778                                                 memcpy(outptr, env, envlen);
4779                                                 outptr += envlen;
4780                                                 nchr -= envlen;
4781                                         }
4782                                 }
4783
4784                                 continue;
4785                         }
4786                 }
4787
4788                 *outptr++ = *inptr++;
4789                 --nchr;
4790         }
4791
4792         *outptr = '\0';
4793         return strdup(out);
4794 }
4795
4796 /*
4797  * Look for reserved variable names and replace them with real values
4798  */
4799 static char *fio_keyword_replace(char *opt)
4800 {
4801         char *s;
4802         int i;
4803         int docalc = 0;
4804
4805         for (i = 0; fio_keywords[i].word != NULL; i++) {
4806                 struct fio_keyword *kw = &fio_keywords[i];
4807
4808                 while ((s = strstr(opt, kw->word)) != NULL) {
4809                         char *new = malloc(strlen(opt) + 1);
4810                         char *o_org = opt;
4811                         int olen = s - opt;
4812                         int len;
4813
4814                         /*
4815                          * Copy part of the string before the keyword and
4816                          * sprintf() the replacement after it.
4817                          */
4818                         memcpy(new, opt, olen);
4819                         len = sprintf(new + olen, "%s", kw->replace);
4820
4821                         /*
4822                          * If there's more in the original string, copy that
4823                          * in too
4824                          */
4825                         opt += strlen(kw->word) + olen;
4826                         if (strlen(opt))
4827                                 memcpy(new + olen + len, opt, opt - o_org - 1);
4828
4829                         /*
4830                          * replace opt and free the old opt
4831                          */
4832                         opt = new;
4833                         free(o_org);
4834
4835                         docalc = 1;
4836                 }
4837         }
4838
4839         /*
4840          * Check for potential math and invoke bc, if possible
4841          */
4842         if (docalc)
4843                 opt = bc_calc(opt);
4844
4845         return opt;
4846 }
4847
4848 static char **dup_and_sub_options(char **opts, int num_opts)
4849 {
4850         int i;
4851         char **opts_copy = malloc(num_opts * sizeof(*opts));
4852         for (i = 0; i < num_opts; i++) {
4853                 opts_copy[i] = option_dup_subs(opts[i]);
4854                 if (!opts_copy[i])
4855                         continue;
4856                 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
4857         }
4858         return opts_copy;
4859 }
4860
4861 static void show_closest_option(const char *opt)
4862 {
4863         int best_option, best_distance;
4864         int i, distance;
4865         char *name;
4866
4867         if (!strlen(opt))
4868                 return;
4869
4870         name = strdup(opt);
4871         i = 0;
4872         while (name[i] != '\0' && name[i] != '=')
4873                 i++;
4874         name[i] = '\0';
4875
4876         best_option = -1;
4877         best_distance = INT_MAX;
4878         i = 0;
4879         while (fio_options[i].name) {
4880                 distance = string_distance(name, fio_options[i].name);
4881                 if (distance < best_distance) {
4882                         best_distance = distance;
4883                         best_option = i;
4884                 }
4885                 i++;
4886         }
4887
4888         if (best_option != -1 && string_distance_ok(name, best_distance) &&
4889             fio_options[best_option].type != FIO_OPT_UNSUPPORTED)
4890                 log_err("Did you mean %s?\n", fio_options[best_option].name);
4891
4892         free(name);
4893 }
4894
4895 int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
4896 {
4897         int i, ret, unknown;
4898         char **opts_copy;
4899
4900         sort_options(opts, fio_options, num_opts);
4901         opts_copy = dup_and_sub_options(opts, num_opts);
4902
4903         for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
4904                 const struct fio_option *o;
4905                 int newret = parse_option(opts_copy[i], opts[i], fio_options,
4906                                                 &o, &td->o, &td->opt_list);
4907
4908                 if (!newret && o)
4909                         fio_option_mark_set(&td->o, o);
4910
4911                 if (opts_copy[i]) {
4912                         if (newret && !o) {
4913                                 unknown++;
4914                                 continue;
4915                         }
4916                         free(opts_copy[i]);
4917                         opts_copy[i] = NULL;
4918                 }
4919
4920                 ret |= newret;
4921         }
4922
4923         if (unknown) {
4924                 ret |= ioengine_load(td);
4925                 if (td->eo) {
4926                         sort_options(opts_copy, td->io_ops->options, num_opts);
4927                         opts = opts_copy;
4928                 }
4929                 for (i = 0; i < num_opts; i++) {
4930                         const struct fio_option *o = NULL;
4931                         int newret = 1;
4932
4933                         if (!opts_copy[i])
4934                                 continue;
4935
4936                         if (td->eo)
4937                                 newret = parse_option(opts_copy[i], opts[i],
4938                                                       td->io_ops->options, &o,
4939                                                       td->eo, &td->opt_list);
4940
4941                         ret |= newret;
4942                         if (!o) {
4943                                 log_err("Bad option <%s>\n", opts[i]);
4944                                 show_closest_option(opts[i]);
4945                         }
4946                         free(opts_copy[i]);
4947                         opts_copy[i] = NULL;
4948                 }
4949         }
4950
4951         free(opts_copy);
4952         return ret;
4953 }
4954
4955 int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
4956 {
4957         int ret;
4958
4959         ret = parse_cmd_option(opt, val, fio_options, &td->o, &td->opt_list);
4960         if (!ret) {
4961                 const struct fio_option *o;
4962
4963                 o = find_option_c(fio_options, opt);
4964                 if (o)
4965                         fio_option_mark_set(&td->o, o);
4966         }
4967
4968         return ret;
4969 }
4970
4971 int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
4972                                 char *val)
4973 {
4974         return parse_cmd_option(opt, val, td->io_ops->options, td->eo,
4975                                         &td->opt_list);
4976 }
4977
4978 void fio_fill_default_options(struct thread_data *td)
4979 {
4980         td->o.magic = OPT_MAGIC;
4981         fill_default_options(&td->o, fio_options);
4982 }
4983
4984 int fio_show_option_help(const char *opt)
4985 {
4986         return show_cmd_help(fio_options, opt);
4987 }
4988
4989 /*
4990  * dupe FIO_OPT_STR_STORE options
4991  */
4992 void fio_options_mem_dupe(struct thread_data *td)
4993 {
4994         options_mem_dupe(fio_options, &td->o);
4995
4996         if (td->eo && td->io_ops) {
4997                 void *oldeo = td->eo;
4998
4999                 td->eo = malloc(td->io_ops->option_struct_size);
5000                 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
5001                 options_mem_dupe(td->io_ops->options, td->eo);
5002         }
5003 }
5004
5005 unsigned int fio_get_kb_base(void *data)
5006 {
5007         struct thread_data *td = cb_data_to_td(data);
5008         struct thread_options *o = &td->o;
5009         unsigned int kb_base = 0;
5010
5011         /*
5012          * This is a hack... For private options, *data is not holding
5013          * a pointer to the thread_options, but to private data. This means
5014          * we can't safely dereference it, but magic is first so mem wise
5015          * it is valid. But this also means that if the job first sets
5016          * kb_base and expects that to be honored by private options,
5017          * it will be disappointed. We will return the global default
5018          * for this.
5019          */
5020         if (o && o->magic == OPT_MAGIC)
5021                 kb_base = o->kb_base;
5022         if (!kb_base)
5023                 kb_base = 1024;
5024
5025         return kb_base;
5026 }
5027
5028 int add_option(const struct fio_option *o)
5029 {
5030         struct fio_option *__o;
5031         int opt_index = 0;
5032
5033         __o = fio_options;
5034         while (__o->name) {
5035                 opt_index++;
5036                 __o++;
5037         }
5038
5039         if (opt_index + 1 == FIO_MAX_OPTS) {
5040                 log_err("fio: FIO_MAX_OPTS is too small\n");
5041                 return 1;
5042         }
5043
5044         memcpy(&fio_options[opt_index], o, sizeof(*o));
5045         fio_options[opt_index + 1].name = NULL;
5046         return 0;
5047 }
5048
5049 void invalidate_profile_options(const char *prof_name)
5050 {
5051         struct fio_option *o;
5052
5053         o = fio_options;
5054         while (o->name) {
5055                 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
5056                         o->type = FIO_OPT_INVALID;
5057                         o->prof_name = NULL;
5058                 }
5059                 o++;
5060         }
5061 }
5062
5063 void add_opt_posval(const char *optname, const char *ival, const char *help)
5064 {
5065         struct fio_option *o;
5066         unsigned int i;
5067
5068         o = find_option(fio_options, optname);
5069         if (!o)
5070                 return;
5071
5072         for (i = 0; i < PARSE_MAX_VP; i++) {
5073                 if (o->posval[i].ival)
5074                         continue;
5075
5076                 o->posval[i].ival = ival;
5077                 o->posval[i].help = help;
5078                 break;
5079         }
5080 }
5081
5082 void del_opt_posval(const char *optname, const char *ival)
5083 {
5084         struct fio_option *o;
5085         unsigned int i;
5086
5087         o = find_option(fio_options, optname);
5088         if (!o)
5089                 return;
5090
5091         for (i = 0; i < PARSE_MAX_VP; i++) {
5092                 if (!o->posval[i].ival)
5093                         continue;
5094                 if (strcmp(o->posval[i].ival, ival))
5095                         continue;
5096
5097                 o->posval[i].ival = NULL;
5098                 o->posval[i].help = NULL;
5099         }
5100 }
5101
5102 void fio_options_free(struct thread_data *td)
5103 {
5104         options_free(fio_options, &td->o);
5105         if (td->eo && td->io_ops && td->io_ops->options) {
5106                 options_free(td->io_ops->options, td->eo);
5107                 free(td->eo);
5108                 td->eo = NULL;
5109         }
5110 }
5111
5112 struct fio_option *fio_option_find(const char *name)
5113 {
5114         return find_option(fio_options, name);
5115 }
5116
5117 static struct fio_option *find_next_opt(struct thread_options *o,
5118                                         struct fio_option *from,
5119                                         unsigned int off1)
5120 {
5121         struct fio_option *opt;
5122
5123         if (!from)
5124                 from = &fio_options[0];
5125         else
5126                 from++;
5127
5128         opt = NULL;
5129         do {
5130                 if (off1 == from->off1) {
5131                         opt = from;
5132                         break;
5133                 }
5134                 from++;
5135         } while (from->name);
5136
5137         return opt;
5138 }
5139
5140 static int opt_is_set(struct thread_options *o, struct fio_option *opt)
5141 {
5142         unsigned int opt_off, index, offset;
5143
5144         opt_off = opt - &fio_options[0];
5145         index = opt_off / (8 * sizeof(uint64_t));
5146         offset = opt_off & ((8 * sizeof(uint64_t)) - 1);
5147         return (o->set_options[index] & ((uint64_t)1 << offset)) != 0;
5148 }
5149
5150 bool __fio_option_is_set(struct thread_options *o, unsigned int off1)
5151 {
5152         struct fio_option *opt, *next;
5153
5154         next = NULL;
5155         while ((opt = find_next_opt(o, next, off1)) != NULL) {
5156                 if (opt_is_set(o, opt))
5157                         return true;
5158
5159                 next = opt;
5160         }
5161
5162         return false;
5163 }
5164
5165 void fio_option_mark_set(struct thread_options *o, const struct fio_option *opt)
5166 {
5167         unsigned int opt_off, index, offset;
5168
5169         opt_off = opt - &fio_options[0];
5170         index = opt_off / (8 * sizeof(uint64_t));
5171         offset = opt_off & ((8 * sizeof(uint64_t)) - 1);
5172         o->set_options[index] |= (uint64_t)1 << offset;
5173 }