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