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