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