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