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