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