Add aarch64 support.
[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);
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 /*
988 * The code in verify_io_u_pattern assumes a single byte pattern
989 * fills the whole verify pattern buffer.
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
1006 if (!ret) {
1007 td->o.refill_buffers = 0;
1008 td->o.scramble_buffers = 0;
1009 td->o.zero_buffers = 0;
9a2a86d0 1010 }
efcd9dcc 1011
ce35b1ec
JA
1012 return ret;
1013}
1014
bedc9dc2
JA
1015static int str_buffer_compress_cb(void *data, unsigned long long *il)
1016{
1017 struct thread_data *td = data;
1018
1019 td->flags |= TD_F_COMPRESS;
1020 td->o.compress_percentage = *il;
1021 return 0;
1022}
1023
ce35b1ec
JA
1024static int str_verify_pattern_cb(void *data, const char *input)
1025{
1026 struct thread_data *td = data;
1027 int ret;
1028
1029 ret = pattern_cb(td->o.verify_pattern, MAX_PATTERN_SIZE, input,
1030 &td->o.verify_pattern_bytes);
efcd9dcc 1031
92bf48d5
JA
1032 /*
1033 * VERIFY_META could already be set
1034 */
ce35b1ec 1035 if (!ret && td->o.verify == VERIFY_NONE)
92bf48d5 1036 td->o.verify = VERIFY_PATTERN;
efcd9dcc 1037
ce35b1ec 1038 return ret;
90059d65 1039}
214e1eca 1040
993bf48b
JA
1041static int str_gtod_reduce_cb(void *data, int *il)
1042{
1043 struct thread_data *td = data;
1044 int val = *il;
1045
02af0988 1046 td->o.disable_lat = !!val;
993bf48b
JA
1047 td->o.disable_clat = !!val;
1048 td->o.disable_slat = !!val;
1049 td->o.disable_bw = !!val;
0dc1bc03 1050 td->o.clat_percentiles = !val;
993bf48b
JA
1051 if (val)
1052 td->tv_cache_mask = 63;
1053
1054 return 0;
1055}
1056
85bc833b 1057static int str_gtod_cpu_cb(void *data, long long *il)
be4ecfdf
JA
1058{
1059 struct thread_data *td = data;
1060 int val = *il;
1061
1062 td->o.gtod_cpu = val;
1063 td->o.gtod_offload = 1;
1064 return 0;
1065}
1066
7bb59102
JA
1067static int str_size_cb(void *data, unsigned long long *__val)
1068{
1069 struct thread_data *td = data;
1070 unsigned long long v = *__val;
1071
1072 if (parse_is_percent(v)) {
1073 td->o.size = 0;
1074 td->o.size_percent = -1ULL - v;
1075 } else
1076 td->o.size = v;
1077
1078 return 0;
1079}
1080
896cac2a
JA
1081static int rw_verify(struct fio_option *o, void *data)
1082{
1083 struct thread_data *td = data;
1084
1085 if (read_only && td_write(td)) {
1086 log_err("fio: job <%s> has write bit set, but fio is in"
1087 " read-only mode\n", td->o.name);
1088 return 1;
1089 }
1090
1091 return 0;
1092}
1093
276ca4f7 1094static int gtod_cpu_verify(struct fio_option *o, void *data)
29d43ff9 1095{
276ca4f7 1096#ifndef FIO_HAVE_CPU_AFFINITY
29d43ff9
JA
1097 struct thread_data *td = data;
1098
29d43ff9
JA
1099 if (td->o.gtod_cpu) {
1100 log_err("fio: platform must support CPU affinity for"
1101 "gettimeofday() offloading\n");
1102 return 1;
1103 }
1104#endif
1105
1106 return 0;
1107}
1108
9af4a244
JA
1109/*
1110 * Option grouping
1111 */
1112static struct opt_group fio_opt_groups[] = {
1113 {
e8b0e958
JA
1114 .name = "General",
1115 .mask = FIO_OPT_C_GENERAL,
9af4a244
JA
1116 },
1117 {
e8b0e958
JA
1118 .name = "I/O",
1119 .mask = FIO_OPT_C_IO,
9af4a244
JA
1120 },
1121 {
e8b0e958
JA
1122 .name = "File",
1123 .mask = FIO_OPT_C_FILE,
9af4a244
JA
1124 },
1125 {
e8b0e958
JA
1126 .name = "Statistics",
1127 .mask = FIO_OPT_C_STAT,
9af4a244
JA
1128 },
1129 {
e8b0e958
JA
1130 .name = "Logging",
1131 .mask = FIO_OPT_C_LOG,
9af4a244 1132 },
13fca827
JA
1133 {
1134 .name = "Profiles",
1135 .mask = FIO_OPT_C_PROFILE,
1136 },
e231bbe6 1137 {
e8b0e958 1138 .name = NULL,
e231bbe6 1139 },
e8b0e958
JA
1140};
1141
1142static struct opt_group *__opt_group_from_mask(struct opt_group *ogs, unsigned int *mask,
1143 unsigned int inv_mask)
1144{
1145 struct opt_group *og;
1146 int i;
1147
1148 if (*mask == inv_mask || !*mask)
1149 return NULL;
1150
1151 for (i = 0; ogs[i].name; i++) {
1152 og = &ogs[i];
1153
1154 if (*mask & og->mask) {
1155 *mask &= ~(og->mask);
1156 return og;
1157 }
1158 }
1159
1160 return NULL;
1161}
1162
1163struct opt_group *opt_group_from_mask(unsigned int *mask)
1164{
1165 return __opt_group_from_mask(fio_opt_groups, mask, FIO_OPT_C_INVALID);
1166}
1167
1168static struct opt_group fio_opt_cat_groups[] = {
3e260a46
JA
1169 {
1170 .name = "Latency profiling",
1171 .mask = FIO_OPT_G_LATPROF,
1172 },
9af4a244 1173 {
e8b0e958
JA
1174 .name = "Rate",
1175 .mask = FIO_OPT_G_RATE,
9af4a244
JA
1176 },
1177 {
e8b0e958
JA
1178 .name = "Zone",
1179 .mask = FIO_OPT_G_ZONE,
9af4a244
JA
1180 },
1181 {
e8b0e958
JA
1182 .name = "Read/write mix",
1183 .mask = FIO_OPT_G_RWMIX,
9af4a244
JA
1184 },
1185 {
1186 .name = "Verify",
1187 .mask = FIO_OPT_G_VERIFY,
1188 },
1189 {
e8b0e958
JA
1190 .name = "Trim",
1191 .mask = FIO_OPT_G_TRIM,
9af4a244
JA
1192 },
1193 {
e8b0e958
JA
1194 .name = "I/O Logging",
1195 .mask = FIO_OPT_G_IOLOG,
9af4a244
JA
1196 },
1197 {
e8b0e958
JA
1198 .name = "I/O Depth",
1199 .mask = FIO_OPT_G_IO_DEPTH,
9af4a244
JA
1200 },
1201 {
e8b0e958
JA
1202 .name = "I/O Flow",
1203 .mask = FIO_OPT_G_IO_FLOW,
9af4a244 1204 },
0626037e
JA
1205 {
1206 .name = "Description",
1207 .mask = FIO_OPT_G_DESC,
1208 },
1209 {
1210 .name = "Filename",
1211 .mask = FIO_OPT_G_FILENAME,
1212 },
1213 {
1214 .name = "General I/O",
1215 .mask = FIO_OPT_G_IO_BASIC,
1216 },
a1f6afec
JA
1217 {
1218 .name = "Cgroups",
1219 .mask = FIO_OPT_G_CGROUP,
1220 },
1221 {
1222 .name = "Runtime",
1223 .mask = FIO_OPT_G_RUNTIME,
1224 },
10860056
JA
1225 {
1226 .name = "Process",
1227 .mask = FIO_OPT_G_PROCESS,
1228 },
1229 {
1230 .name = "Job credentials / priority",
1231 .mask = FIO_OPT_G_CRED,
1232 },
1233 {
1234 .name = "Clock settings",
1235 .mask = FIO_OPT_G_CLOCK,
1236 },
3ceb458f
JA
1237 {
1238 .name = "I/O Type",
1239 .mask = FIO_OPT_G_IO_TYPE,
1240 },
1241 {
1242 .name = "I/O Thinktime",
1243 .mask = FIO_OPT_G_THINKTIME,
1244 },
1245 {
1246 .name = "Randomizations",
1247 .mask = FIO_OPT_G_RANDOM,
1248 },
1249 {
1250 .name = "I/O buffers",
1251 .mask = FIO_OPT_G_IO_BUF,
1252 },
13fca827
JA
1253 {
1254 .name = "Tiobench profile",
1255 .mask = FIO_OPT_G_TIOBENCH,
1256 },
1257
9af4a244
JA
1258 {
1259 .name = NULL,
e8b0e958 1260 }
9af4a244
JA
1261};
1262
e8b0e958 1263struct opt_group *opt_group_cat_from_mask(unsigned int *mask)
9af4a244 1264{
e8b0e958 1265 return __opt_group_from_mask(fio_opt_cat_groups, mask, FIO_OPT_G_INVALID);
9af4a244
JA
1266}
1267
214e1eca
JA
1268/*
1269 * Map of job/command line options
1270 */
9af4a244 1271struct fio_option fio_options[FIO_MAX_OPTS] = {
214e1eca
JA
1272 {
1273 .name = "description",
e8b0e958 1274 .lname = "Description of job",
214e1eca
JA
1275 .type = FIO_OPT_STR_STORE,
1276 .off1 = td_var_offset(description),
1277 .help = "Text job description",
e8b0e958 1278 .category = FIO_OPT_C_GENERAL,
0626037e 1279 .group = FIO_OPT_G_DESC,
214e1eca
JA
1280 },
1281 {
1282 .name = "name",
e8b0e958 1283 .lname = "Job name",
214e1eca
JA
1284 .type = FIO_OPT_STR_STORE,
1285 .off1 = td_var_offset(name),
1286 .help = "Name of this job",
e8b0e958 1287 .category = FIO_OPT_C_GENERAL,
0626037e 1288 .group = FIO_OPT_G_DESC,
214e1eca 1289 },
214e1eca
JA
1290 {
1291 .name = "filename",
e8b0e958 1292 .lname = "Filename(s)",
214e1eca
JA
1293 .type = FIO_OPT_STR_STORE,
1294 .off1 = td_var_offset(filename),
1295 .cb = str_filename_cb,
f0d524b0 1296 .prio = -1, /* must come after "directory" */
214e1eca 1297 .help = "File(s) to use for the workload",
e8b0e958 1298 .category = FIO_OPT_C_FILE,
0626037e 1299 .group = FIO_OPT_G_FILENAME,
214e1eca 1300 },
90fef2d1 1301 {
e8b0e958
JA
1302 .name = "directory",
1303 .lname = "Directory",
1304 .type = FIO_OPT_STR_STORE,
1305 .off1 = td_var_offset(directory),
1306 .cb = str_directory_cb,
1307 .help = "Directory to store files in",
1308 .category = FIO_OPT_C_FILE,
0626037e 1309 .group = FIO_OPT_G_FILENAME,
90fef2d1 1310 },
de98bd30
JA
1311 {
1312 .name = "filename_format",
1313 .type = FIO_OPT_STR_STORE,
1314 .off1 = td_var_offset(filename_format),
1315 .prio = -1, /* must come after "directory" */
1316 .help = "Override default $jobname.$jobnum.$filenum naming",
1317 .def = "$jobname.$jobnum.$filenum",
93bb626a
JA
1318 .category = FIO_OPT_C_FILE,
1319 .group = FIO_OPT_G_FILENAME,
ad705bcb 1320 },
29c1349f
JA
1321 {
1322 .name = "lockfile",
e8b0e958 1323 .lname = "Lockfile",
4d4e80f2 1324 .type = FIO_OPT_STR,
4d4e80f2 1325 .off1 = td_var_offset(file_lock_mode),
29c1349f 1326 .help = "Lock file when doing IO to it",
bc6a0a5d 1327 .prio = 1,
29c1349f 1328 .parent = "filename",
d71c154c 1329 .hide = 0,
4d4e80f2 1330 .def = "none",
f2a2803a 1331 .cb = str_lockfile_cb,
e8b0e958 1332 .category = FIO_OPT_C_FILE,
0626037e 1333 .group = FIO_OPT_G_FILENAME,
4d4e80f2
JA
1334 .posval = {
1335 { .ival = "none",
1336 .oval = FILE_LOCK_NONE,
1337 .help = "No file locking",
1338 },
1339 { .ival = "exclusive",
1340 .oval = FILE_LOCK_EXCLUSIVE,
1341 .help = "Exclusive file lock",
1342 },
1343 {
1344 .ival = "readwrite",
1345 .oval = FILE_LOCK_READWRITE,
1346 .help = "Read vs write lock",
1347 },
1348 },
29c1349f 1349 },
214e1eca
JA
1350 {
1351 .name = "opendir",
e8b0e958 1352 .lname = "Open directory",
214e1eca
JA
1353 .type = FIO_OPT_STR_STORE,
1354 .off1 = td_var_offset(opendir),
1355 .cb = str_opendir_cb,
1356 .help = "Recursively add files from this directory and down",
e8b0e958 1357 .category = FIO_OPT_C_FILE,
0626037e 1358 .group = FIO_OPT_G_FILENAME,
214e1eca
JA
1359 },
1360 {
1361 .name = "rw",
e8b0e958 1362 .lname = "Read/write",
d3aad8f2 1363 .alias = "readwrite",
214e1eca 1364 .type = FIO_OPT_STR,
211097b2 1365 .cb = str_rw_cb,
214e1eca
JA
1366 .off1 = td_var_offset(td_ddir),
1367 .help = "IO direction",
1368 .def = "read",
896cac2a 1369 .verify = rw_verify,
e8b0e958 1370 .category = FIO_OPT_C_IO,
0626037e 1371 .group = FIO_OPT_G_IO_BASIC,
214e1eca
JA
1372 .posval = {
1373 { .ival = "read",
1374 .oval = TD_DDIR_READ,
1375 .help = "Sequential read",
1376 },
1377 { .ival = "write",
1378 .oval = TD_DDIR_WRITE,
1379 .help = "Sequential write",
1380 },
6eaf09d6
SL
1381 { .ival = "trim",
1382 .oval = TD_DDIR_TRIM,
1383 .help = "Sequential trim",
1384 },
214e1eca
JA
1385 { .ival = "randread",
1386 .oval = TD_DDIR_RANDREAD,
1387 .help = "Random read",
1388 },
1389 { .ival = "randwrite",
1390 .oval = TD_DDIR_RANDWRITE,
1391 .help = "Random write",
1392 },
6eaf09d6
SL
1393 { .ival = "randtrim",
1394 .oval = TD_DDIR_RANDTRIM,
1395 .help = "Random trim",
1396 },
214e1eca
JA
1397 { .ival = "rw",
1398 .oval = TD_DDIR_RW,
1399 .help = "Sequential read and write mix",
1400 },
10b023db
JA
1401 { .ival = "readwrite",
1402 .oval = TD_DDIR_RW,
1403 .help = "Sequential read and write mix",
1404 },
214e1eca
JA
1405 { .ival = "randrw",
1406 .oval = TD_DDIR_RANDRW,
1407 .help = "Random read and write mix"
1408 },
1409 },
1410 },
38dad62d
JA
1411 {
1412 .name = "rw_sequencer",
e8b0e958 1413 .lname = "RW Sequencer",
38dad62d
JA
1414 .type = FIO_OPT_STR,
1415 .off1 = td_var_offset(rw_seq),
1416 .help = "IO offset generator modifier",
1417 .def = "sequential",
e8b0e958 1418 .category = FIO_OPT_C_IO,
0626037e 1419 .group = FIO_OPT_G_IO_BASIC,
38dad62d
JA
1420 .posval = {
1421 { .ival = "sequential",
1422 .oval = RW_SEQ_SEQ,
1423 .help = "Generate sequential offsets",
1424 },
1425 { .ival = "identical",
1426 .oval = RW_SEQ_IDENT,
1427 .help = "Generate identical offsets",
1428 },
1429 },
1430 },
1431
214e1eca
JA
1432 {
1433 .name = "ioengine",
e8b0e958 1434 .lname = "IO Engine",
214e1eca
JA
1435 .type = FIO_OPT_STR_STORE,
1436 .off1 = td_var_offset(ioengine),
1437 .help = "IO engine to use",
58483fa4 1438 .def = FIO_PREFERRED_ENGINE,
e8b0e958 1439 .category = FIO_OPT_C_IO,
0626037e 1440 .group = FIO_OPT_G_IO_BASIC,
214e1eca
JA
1441 .posval = {
1442 { .ival = "sync",
1443 .help = "Use read/write",
1444 },
a31041ea 1445 { .ival = "psync",
1446 .help = "Use pread/pwrite",
1447 },
1d2af02a 1448 { .ival = "vsync",
03e20d68 1449 .help = "Use readv/writev",
1d2af02a 1450 },
07fc0acd
JA
1451#ifdef CONFIG_PWRITEV
1452 { .ival = "pvsync",
1453 .help = "Use preadv/pwritev",
1454 },
1455#endif
67bf9823 1456#ifdef CONFIG_LIBAIO
214e1eca
JA
1457 { .ival = "libaio",
1458 .help = "Linux native asynchronous IO",
1459 },
1460#endif
67bf9823 1461#ifdef CONFIG_POSIXAIO
214e1eca
JA
1462 { .ival = "posixaio",
1463 .help = "POSIX asynchronous IO",
1464 },
417f0068 1465#endif
997843cb 1466#ifdef CONFIG_SOLARISAIO
417f0068
JA
1467 { .ival = "solarisaio",
1468 .help = "Solaris native asynchronous IO",
1469 },
214e1eca 1470#endif
4700b234 1471#ifdef CONFIG_WINDOWSAIO
03e20d68 1472 { .ival = "windowsaio",
3be80071 1473 .help = "Windows native asynchronous IO"
de890a1e 1474 },
fc5c0345
DG
1475#endif
1476#ifdef CONFIG_RBD
1477 { .ival = "rbd",
1478 .help = "Rados Block Device asynchronous IO"
1479 },
3be80071 1480#endif
214e1eca 1481 { .ival = "mmap",
03e20d68 1482 .help = "Memory mapped IO"
214e1eca 1483 },
67bf9823 1484#ifdef CONFIG_LINUX_SPLICE
214e1eca
JA
1485 { .ival = "splice",
1486 .help = "splice/vmsplice based IO",
1487 },
9cce02e8
JA
1488 { .ival = "netsplice",
1489 .help = "splice/vmsplice to/from the network",
1490 },
214e1eca
JA
1491#endif
1492#ifdef FIO_HAVE_SGIO
1493 { .ival = "sg",
1494 .help = "SCSI generic v3 IO",
1495 },
1496#endif
1497 { .ival = "null",
1498 .help = "Testing engine (no data transfer)",
1499 },
1500 { .ival = "net",
1501 .help = "Network IO",
1502 },
214e1eca 1503 { .ival = "cpuio",
03e20d68 1504 .help = "CPU cycle burner engine",
214e1eca 1505 },
67bf9823 1506#ifdef CONFIG_GUASI
b8c82a46
JA
1507 { .ival = "guasi",
1508 .help = "GUASI IO engine",
1509 },
79a43187
JA
1510#endif
1511#ifdef FIO_HAVE_BINJECT
1512 { .ival = "binject",
1513 .help = "binject direct inject block engine",
1514 },
21b8aee8 1515#endif
67bf9823 1516#ifdef CONFIG_RDMA
21b8aee8 1517 { .ival = "rdma",
1518 .help = "RDMA IO engine",
1519 },
8200b8c7 1520#endif
67bf9823 1521#ifdef CONFIG_FUSION_AW
8200b8c7
JA
1522 { .ival = "fusion-aw-sync",
1523 .help = "Fusion-io atomic write engine",
1524 },
1ecc95ca 1525#endif
997843cb 1526#ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
1ecc95ca
JA
1527 { .ival = "e4defrag",
1528 .help = "ext4 defrag engine",
1529 },
1530#endif
997843cb 1531#ifdef CONFIG_LINUX_FALLOCATE
1ecc95ca
JA
1532 { .ival = "falloc",
1533 .help = "fallocate() file based engine",
1534 },
b8c82a46 1535#endif
a7c386f4 1536#ifdef CONFIG_GFAPI
1537 { .ival = "gfapi",
cc47f094 1538 .help = "Glusterfs libgfapi(sync) based engine"
1539 },
1540 { .ival = "gfapi_async",
1541 .help = "Glusterfs libgfapi(async) based engine"
a7c386f4 1542 },
1543#endif
1544
214e1eca
JA
1545 { .ival = "external",
1546 .help = "Load external engine (append name)",
1547 },
1548 },
1549 },
1550 {
1551 .name = "iodepth",
e8b0e958 1552 .lname = "IO Depth",
214e1eca
JA
1553 .type = FIO_OPT_INT,
1554 .off1 = td_var_offset(iodepth),
03e20d68 1555 .help = "Number of IO buffers to keep in flight",
757aff4f 1556 .minval = 1,
20eb06bd 1557 .interval = 1,
214e1eca 1558 .def = "1",
e8b0e958 1559 .category = FIO_OPT_C_IO,
0626037e 1560 .group = FIO_OPT_G_IO_BASIC,
214e1eca
JA
1561 },
1562 {
1563 .name = "iodepth_batch",
e8b0e958 1564 .lname = "IO Depth batch",
4950421a 1565 .alias = "iodepth_batch_submit",
214e1eca
JA
1566 .type = FIO_OPT_INT,
1567 .off1 = td_var_offset(iodepth_batch),
d65db441 1568 .help = "Number of IO buffers to submit in one go",
afdf9352 1569 .parent = "iodepth",
d71c154c 1570 .hide = 1,
a2e6f8ac 1571 .minval = 1,
20eb06bd 1572 .interval = 1,
a2e6f8ac 1573 .def = "1",
e8b0e958 1574 .category = FIO_OPT_C_IO,
0626037e 1575 .group = FIO_OPT_G_IO_BASIC,
4950421a
JA
1576 },
1577 {
1578 .name = "iodepth_batch_complete",
e8b0e958 1579 .lname = "IO Depth batch complete",
4950421a
JA
1580 .type = FIO_OPT_INT,
1581 .off1 = td_var_offset(iodepth_batch_complete),
d65db441 1582 .help = "Number of IO buffers to retrieve in one go",
4950421a 1583 .parent = "iodepth",
d71c154c 1584 .hide = 1,
4950421a 1585 .minval = 0,
20eb06bd 1586 .interval = 1,
4950421a 1587 .def = "1",
e8b0e958 1588 .category = FIO_OPT_C_IO,
0626037e 1589 .group = FIO_OPT_G_IO_BASIC,
214e1eca
JA
1590 },
1591 {
1592 .name = "iodepth_low",
e8b0e958 1593 .lname = "IO Depth batch low",
214e1eca
JA
1594 .type = FIO_OPT_INT,
1595 .off1 = td_var_offset(iodepth_low),
1596 .help = "Low water mark for queuing depth",
afdf9352 1597 .parent = "iodepth",
d71c154c 1598 .hide = 1,
20eb06bd 1599 .interval = 1,
e8b0e958 1600 .category = FIO_OPT_C_IO,
0626037e 1601 .group = FIO_OPT_G_IO_BASIC,
214e1eca
JA
1602 },
1603 {
1604 .name = "size",
e8b0e958 1605 .lname = "Size",
214e1eca 1606 .type = FIO_OPT_STR_VAL,
7bb59102 1607 .cb = str_size_cb,
214e1eca 1608 .help = "Total size of device or files",
20eb06bd 1609 .interval = 1024 * 1024,
e8b0e958
JA
1610 .category = FIO_OPT_C_IO,
1611 .group = FIO_OPT_G_INVALID,
214e1eca 1612 },
77731b29
JA
1613 {
1614 .name = "io_limit",
1615 .lname = "IO Limit",
1616 .type = FIO_OPT_STR_VAL,
1617 .off1 = td_var_offset(io_limit),
1618 .interval = 1024 * 1024,
1619 .category = FIO_OPT_C_IO,
1620 .group = FIO_OPT_G_INVALID,
1621 },
aa31f1f1
SL
1622 {
1623 .name = "fill_device",
e8b0e958 1624 .lname = "Fill device",
74586c1e 1625 .alias = "fill_fs",
aa31f1f1
SL
1626 .type = FIO_OPT_BOOL,
1627 .off1 = td_var_offset(fill_device),
1628 .help = "Write until an ENOSPC error occurs",
1629 .def = "0",
e8b0e958
JA
1630 .category = FIO_OPT_C_FILE,
1631 .group = FIO_OPT_G_INVALID,
aa31f1f1 1632 },
214e1eca
JA
1633 {
1634 .name = "filesize",
e8b0e958 1635 .lname = "File size",
214e1eca
JA
1636 .type = FIO_OPT_STR_VAL,
1637 .off1 = td_var_offset(file_size_low),
1638 .off2 = td_var_offset(file_size_high),
c3edbdba 1639 .minval = 1,
214e1eca 1640 .help = "Size of individual files",
20eb06bd 1641 .interval = 1024 * 1024,
e8b0e958
JA
1642 .category = FIO_OPT_C_FILE,
1643 .group = FIO_OPT_G_INVALID,
214e1eca 1644 },
bedc9dc2
JA
1645 {
1646 .name = "file_append",
1647 .lname = "File append",
1648 .type = FIO_OPT_BOOL,
1649 .off1 = td_var_offset(file_append),
1650 .help = "IO will start at the end of the file(s)",
1651 .def = "0",
1652 .category = FIO_OPT_C_FILE,
1653 .group = FIO_OPT_G_INVALID,
1654 },
67a1000f
JA
1655 {
1656 .name = "offset",
e8b0e958 1657 .lname = "IO offset",
67a1000f
JA
1658 .alias = "fileoffset",
1659 .type = FIO_OPT_STR_VAL,
1660 .off1 = td_var_offset(start_offset),
1661 .help = "Start IO from this offset",
1662 .def = "0",
20eb06bd 1663 .interval = 1024 * 1024,
e8b0e958
JA
1664 .category = FIO_OPT_C_IO,
1665 .group = FIO_OPT_G_INVALID,
67a1000f 1666 },
2d7cd868
JA
1667 {
1668 .name = "offset_increment",
e8b0e958 1669 .lname = "IO offset increment",
2d7cd868
JA
1670 .type = FIO_OPT_STR_VAL,
1671 .off1 = td_var_offset(offset_increment),
1672 .help = "What is the increment from one offset to the next",
1673 .parent = "offset",
d71c154c 1674 .hide = 1,
2d7cd868 1675 .def = "0",
20eb06bd 1676 .interval = 1024 * 1024,
e8b0e958
JA
1677 .category = FIO_OPT_C_IO,
1678 .group = FIO_OPT_G_INVALID,
2d7cd868 1679 },
ddf24e42
JA
1680 {
1681 .name = "number_ios",
1682 .lname = "Number of IOs to perform",
1683 .type = FIO_OPT_STR_VAL,
1684 .off1 = td_var_offset(number_ios),
1685 .help = "Force job completion of this number of IOs",
1686 .def = "0",
1687 .category = FIO_OPT_C_IO,
1688 .group = FIO_OPT_G_INVALID,
1689 },
214e1eca
JA
1690 {
1691 .name = "bs",
e8b0e958 1692 .lname = "Block size",
d3aad8f2 1693 .alias = "blocksize",
e01b22b8 1694 .type = FIO_OPT_INT,
214e1eca
JA
1695 .off1 = td_var_offset(bs[DDIR_READ]),
1696 .off2 = td_var_offset(bs[DDIR_WRITE]),
6eaf09d6 1697 .off3 = td_var_offset(bs[DDIR_TRIM]),
c3edbdba 1698 .minval = 1,
214e1eca
JA
1699 .help = "Block size unit",
1700 .def = "4k",
67a1000f 1701 .parent = "rw",
d71c154c 1702 .hide = 1,
20eb06bd 1703 .interval = 512,
e8b0e958
JA
1704 .category = FIO_OPT_C_IO,
1705 .group = FIO_OPT_G_INVALID,
214e1eca 1706 },
2b7a01d0
JA
1707 {
1708 .name = "ba",
e8b0e958 1709 .lname = "Block size align",
2b7a01d0 1710 .alias = "blockalign",
e01b22b8 1711 .type = FIO_OPT_INT,
2b7a01d0
JA
1712 .off1 = td_var_offset(ba[DDIR_READ]),
1713 .off2 = td_var_offset(ba[DDIR_WRITE]),
6eaf09d6 1714 .off3 = td_var_offset(ba[DDIR_TRIM]),
2b7a01d0
JA
1715 .minval = 1,
1716 .help = "IO block offset alignment",
1717 .parent = "rw",
d71c154c 1718 .hide = 1,
20eb06bd 1719 .interval = 512,
e8b0e958
JA
1720 .category = FIO_OPT_C_IO,
1721 .group = FIO_OPT_G_INVALID,
2b7a01d0 1722 },
214e1eca
JA
1723 {
1724 .name = "bsrange",
e8b0e958 1725 .lname = "Block size range",
d3aad8f2 1726 .alias = "blocksize_range",
214e1eca
JA
1727 .type = FIO_OPT_RANGE,
1728 .off1 = td_var_offset(min_bs[DDIR_READ]),
1729 .off2 = td_var_offset(max_bs[DDIR_READ]),
1730 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
1731 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
6eaf09d6
SL
1732 .off5 = td_var_offset(min_bs[DDIR_TRIM]),
1733 .off6 = td_var_offset(max_bs[DDIR_TRIM]),
c3edbdba 1734 .minval = 1,
214e1eca 1735 .help = "Set block size range (in more detail than bs)",
67a1000f 1736 .parent = "rw",
d71c154c 1737 .hide = 1,
20eb06bd 1738 .interval = 4096,
e8b0e958
JA
1739 .category = FIO_OPT_C_IO,
1740 .group = FIO_OPT_G_INVALID,
214e1eca 1741 },
564ca972
JA
1742 {
1743 .name = "bssplit",
e8b0e958 1744 .lname = "Block size split",
564ca972
JA
1745 .type = FIO_OPT_STR,
1746 .cb = str_bssplit_cb,
1747 .help = "Set a specific mix of block sizes",
1748 .parent = "rw",
d71c154c 1749 .hide = 1,
e8b0e958
JA
1750 .category = FIO_OPT_C_IO,
1751 .group = FIO_OPT_G_INVALID,
564ca972 1752 },
214e1eca
JA
1753 {
1754 .name = "bs_unaligned",
e8b0e958 1755 .lname = "Block size unaligned",
d3aad8f2 1756 .alias = "blocksize_unaligned",
214e1eca
JA
1757 .type = FIO_OPT_STR_SET,
1758 .off1 = td_var_offset(bs_unaligned),
1759 .help = "Don't sector align IO buffer sizes",
67a1000f 1760 .parent = "rw",
d71c154c 1761 .hide = 1,
e8b0e958
JA
1762 .category = FIO_OPT_C_IO,
1763 .group = FIO_OPT_G_INVALID,
214e1eca 1764 },
6aca9b3d
JA
1765 {
1766 .name = "bs_is_seq_rand",
1767 .lname = "Block size division is seq/random (not read/write)",
1768 .type = FIO_OPT_BOOL,
1769 .off1 = td_var_offset(bs_is_seq_rand),
1770 .help = "Consider any blocksize setting to be sequential,ramdom",
1771 .def = "0",
1772 .parent = "blocksize",
1773 .category = FIO_OPT_C_IO,
1774 .group = FIO_OPT_G_INVALID,
1775 },
214e1eca
JA
1776 {
1777 .name = "randrepeat",
e8b0e958 1778 .lname = "Random repeatable",
214e1eca
JA
1779 .type = FIO_OPT_BOOL,
1780 .off1 = td_var_offset(rand_repeatable),
1781 .help = "Use repeatable random IO pattern",
1782 .def = "1",
67a1000f 1783 .parent = "rw",
d71c154c 1784 .hide = 1,
e8b0e958 1785 .category = FIO_OPT_C_IO,
3ceb458f 1786 .group = FIO_OPT_G_RANDOM,
214e1eca 1787 },
04778baf
JA
1788 {
1789 .name = "randseed",
1790 .lname = "The random generator seed",
363cffa7 1791 .type = FIO_OPT_STR_VAL,
04778baf
JA
1792 .off1 = td_var_offset(rand_seed),
1793 .help = "Set the random generator seed value",
1794 .parent = "rw",
1795 .category = FIO_OPT_C_IO,
1796 .group = FIO_OPT_G_RANDOM,
1797 },
2615cc4b
JA
1798 {
1799 .name = "use_os_rand",
e8b0e958 1800 .lname = "Use OS random",
2615cc4b
JA
1801 .type = FIO_OPT_BOOL,
1802 .off1 = td_var_offset(use_os_rand),
1803 .help = "Set to use OS random generator",
1804 .def = "0",
1805 .parent = "rw",
d71c154c 1806 .hide = 1,
e8b0e958 1807 .category = FIO_OPT_C_IO,
3ceb458f 1808 .group = FIO_OPT_G_RANDOM,
2615cc4b 1809 },
214e1eca
JA
1810 {
1811 .name = "norandommap",
e8b0e958 1812 .lname = "No randommap",
214e1eca
JA
1813 .type = FIO_OPT_STR_SET,
1814 .off1 = td_var_offset(norandommap),
1815 .help = "Accept potential duplicate random blocks",
67a1000f 1816 .parent = "rw",
d71c154c 1817 .hide = 1,
b2452a43 1818 .hide_on_set = 1,
e8b0e958 1819 .category = FIO_OPT_C_IO,
3ceb458f 1820 .group = FIO_OPT_G_RANDOM,
214e1eca 1821 },
2b386d25
JA
1822 {
1823 .name = "softrandommap",
e8b0e958 1824 .lname = "Soft randommap",
2b386d25
JA
1825 .type = FIO_OPT_BOOL,
1826 .off1 = td_var_offset(softrandommap),
f66ab3c8 1827 .help = "Set norandommap if randommap allocation fails",
2b386d25 1828 .parent = "norandommap",
d71c154c 1829 .hide = 1,
2b386d25 1830 .def = "0",
e8b0e958 1831 .category = FIO_OPT_C_IO,
3ceb458f 1832 .group = FIO_OPT_G_RANDOM,
2b386d25 1833 },
8055e41d
JA
1834 {
1835 .name = "random_generator",
1836 .type = FIO_OPT_STR,
1837 .off1 = td_var_offset(random_generator),
1838 .help = "Type of random number generator to use",
1839 .def = "tausworthe",
1840 .posval = {
1841 { .ival = "tausworthe",
1842 .oval = FIO_RAND_GEN_TAUSWORTHE,
1843 .help = "Strong Tausworthe generator",
1844 },
1845 { .ival = "lfsr",
1846 .oval = FIO_RAND_GEN_LFSR,
1847 .help = "Variable length LFSR",
1848 },
1849 },
48107598
JA
1850 .category = FIO_OPT_C_IO,
1851 .group = FIO_OPT_G_RANDOM,
8055e41d 1852 },
e25839d4
JA
1853 {
1854 .name = "random_distribution",
1855 .type = FIO_OPT_STR,
1856 .off1 = td_var_offset(random_distribution),
1857 .cb = str_random_distribution_cb,
1858 .help = "Random offset distribution generator",
1859 .def = "random",
1860 .posval = {
1861 { .ival = "random",
1862 .oval = FIO_RAND_DIST_RANDOM,
1863 .help = "Completely random",
1864 },
1865 { .ival = "zipf",
1866 .oval = FIO_RAND_DIST_ZIPF,
1867 .help = "Zipf distribution",
1868 },
925fee33
JA
1869 { .ival = "pareto",
1870 .oval = FIO_RAND_DIST_PARETO,
1871 .help = "Pareto distribution",
1872 },
e25839d4 1873 },
48107598
JA
1874 .category = FIO_OPT_C_IO,
1875 .group = FIO_OPT_G_RANDOM,
e25839d4 1876 },
211c9b89
JA
1877 {
1878 .name = "percentage_random",
1879 .lname = "Percentage Random",
1880 .type = FIO_OPT_INT,
d9472271
JA
1881 .off1 = td_var_offset(perc_rand[DDIR_READ]),
1882 .off2 = td_var_offset(perc_rand[DDIR_WRITE]),
1883 .off3 = td_var_offset(perc_rand[DDIR_TRIM]),
211c9b89
JA
1884 .maxval = 100,
1885 .help = "Percentage of seq/random mix that should be random",
d9472271 1886 .def = "100,100,100",
211c9b89
JA
1887 .interval = 5,
1888 .inverse = "percentage_sequential",
1889 .category = FIO_OPT_C_IO,
1890 .group = FIO_OPT_G_RANDOM,
1891 },
1892 {
1893 .name = "percentage_sequential",
1894 .lname = "Percentage Sequential",
d9472271 1895 .type = FIO_OPT_DEPRECATED,
211c9b89
JA
1896 .category = FIO_OPT_C_IO,
1897 .group = FIO_OPT_G_RANDOM,
1898 },
56e2a5fc
CE
1899 {
1900 .name = "allrandrepeat",
1901 .type = FIO_OPT_BOOL,
1902 .off1 = td_var_offset(allrand_repeatable),
1903 .help = "Use repeatable random numbers for everything",
1904 .def = "0",
a869d9c6
JA
1905 .category = FIO_OPT_C_IO,
1906 .group = FIO_OPT_G_RANDOM,
56e2a5fc 1907 },
214e1eca
JA
1908 {
1909 .name = "nrfiles",
e8b0e958 1910 .lname = "Number of files",
d7c8be03 1911 .alias = "nr_files",
214e1eca
JA
1912 .type = FIO_OPT_INT,
1913 .off1 = td_var_offset(nr_files),
1914 .help = "Split job workload between this number of files",
1915 .def = "1",
20eb06bd 1916 .interval = 1,
e8b0e958
JA
1917 .category = FIO_OPT_C_FILE,
1918 .group = FIO_OPT_G_INVALID,
214e1eca
JA
1919 },
1920 {
1921 .name = "openfiles",
e8b0e958 1922 .lname = "Number of open files",
214e1eca
JA
1923 .type = FIO_OPT_INT,
1924 .off1 = td_var_offset(open_files),
1925 .help = "Number of files to keep open at the same time",
e8b0e958
JA
1926 .category = FIO_OPT_C_FILE,
1927 .group = FIO_OPT_G_INVALID,
214e1eca
JA
1928 },
1929 {
1930 .name = "file_service_type",
e8b0e958 1931 .lname = "File service type",
214e1eca
JA
1932 .type = FIO_OPT_STR,
1933 .cb = str_fst_cb,
1934 .off1 = td_var_offset(file_service_type),
1935 .help = "How to select which file to service next",
1936 .def = "roundrobin",
e8b0e958
JA
1937 .category = FIO_OPT_C_FILE,
1938 .group = FIO_OPT_G_INVALID,
214e1eca
JA
1939 .posval = {
1940 { .ival = "random",
1941 .oval = FIO_FSERVICE_RANDOM,
1942 .help = "Choose a file at random",
1943 },
1944 { .ival = "roundrobin",
1945 .oval = FIO_FSERVICE_RR,
1946 .help = "Round robin select files",
1947 },
a086c257
JA
1948 { .ival = "sequential",
1949 .oval = FIO_FSERVICE_SEQ,
1950 .help = "Finish one file before moving to the next",
1951 },
214e1eca 1952 },
67a1000f 1953 .parent = "nrfiles",
d71c154c 1954 .hide = 1,
67a1000f 1955 },
97ac992c 1956#ifdef CONFIG_POSIX_FALLOCATE
7bc8c2cf
JA
1957 {
1958 .name = "fallocate",
e8b0e958 1959 .lname = "Fallocate",
a596f047
EG
1960 .type = FIO_OPT_STR,
1961 .off1 = td_var_offset(fallocate_mode),
1962 .help = "Whether pre-allocation is performed when laying out files",
1963 .def = "posix",
e8b0e958
JA
1964 .category = FIO_OPT_C_FILE,
1965 .group = FIO_OPT_G_INVALID,
a596f047
EG
1966 .posval = {
1967 { .ival = "none",
1968 .oval = FIO_FALLOCATE_NONE,
1969 .help = "Do not pre-allocate space",
1970 },
1971 { .ival = "posix",
1972 .oval = FIO_FALLOCATE_POSIX,
1973 .help = "Use posix_fallocate()",
1974 },
97ac992c 1975#ifdef CONFIG_LINUX_FALLOCATE
a596f047
EG
1976 { .ival = "keep",
1977 .oval = FIO_FALLOCATE_KEEP_SIZE,
1978 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
1979 },
7bc8c2cf 1980#endif
a596f047
EG
1981 /* Compatibility with former boolean values */
1982 { .ival = "0",
1983 .oval = FIO_FALLOCATE_NONE,
1984 .help = "Alias for 'none'",
1985 },
1986 { .ival = "1",
1987 .oval = FIO_FALLOCATE_POSIX,
1988 .help = "Alias for 'posix'",
1989 },
1990 },
1991 },
97ac992c 1992#endif /* CONFIG_POSIX_FALLOCATE */
67a1000f
JA
1993 {
1994 .name = "fadvise_hint",
e8b0e958 1995 .lname = "Fadvise hint",
67a1000f
JA
1996 .type = FIO_OPT_BOOL,
1997 .off1 = td_var_offset(fadvise_hint),
1998 .help = "Use fadvise() to advise the kernel on IO pattern",
1999 .def = "1",
e8b0e958
JA
2000 .category = FIO_OPT_C_FILE,
2001 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2002 },
2003 {
2004 .name = "fsync",
e8b0e958 2005 .lname = "Fsync",
214e1eca
JA
2006 .type = FIO_OPT_INT,
2007 .off1 = td_var_offset(fsync_blocks),
2008 .help = "Issue fsync for writes every given number of blocks",
2009 .def = "0",
20eb06bd 2010 .interval = 1,
e8b0e958
JA
2011 .category = FIO_OPT_C_FILE,
2012 .group = FIO_OPT_G_INVALID,
214e1eca 2013 },
5f9099ea
JA
2014 {
2015 .name = "fdatasync",
e8b0e958 2016 .lname = "Fdatasync",
5f9099ea
JA
2017 .type = FIO_OPT_INT,
2018 .off1 = td_var_offset(fdatasync_blocks),
2019 .help = "Issue fdatasync for writes every given number of blocks",
2020 .def = "0",
20eb06bd 2021 .interval = 1,
e8b0e958
JA
2022 .category = FIO_OPT_C_FILE,
2023 .group = FIO_OPT_G_INVALID,
5f9099ea 2024 },
1ef2b6be
JA
2025 {
2026 .name = "write_barrier",
e8b0e958 2027 .lname = "Write barrier",
1ef2b6be
JA
2028 .type = FIO_OPT_INT,
2029 .off1 = td_var_offset(barrier_blocks),
2030 .help = "Make every Nth write a barrier write",
2031 .def = "0",
20eb06bd 2032 .interval = 1,
e8b0e958
JA
2033 .category = FIO_OPT_C_IO,
2034 .group = FIO_OPT_G_INVALID,
1ef2b6be 2035 },
67bf9823 2036#ifdef CONFIG_SYNC_FILE_RANGE
44f29692
JA
2037 {
2038 .name = "sync_file_range",
e8b0e958 2039 .lname = "Sync file range",
44f29692
JA
2040 .posval = {
2041 { .ival = "wait_before",
2042 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
2043 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
ebadc0ce 2044 .orval = 1,
44f29692
JA
2045 },
2046 { .ival = "write",
2047 .oval = SYNC_FILE_RANGE_WRITE,
2048 .help = "SYNC_FILE_RANGE_WRITE",
ebadc0ce 2049 .orval = 1,
44f29692
JA
2050 },
2051 {
2052 .ival = "wait_after",
2053 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
2054 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
ebadc0ce 2055 .orval = 1,
44f29692
JA
2056 },
2057 },
3843deb3 2058 .type = FIO_OPT_STR_MULTI,
44f29692
JA
2059 .cb = str_sfr_cb,
2060 .off1 = td_var_offset(sync_file_range),
2061 .help = "Use sync_file_range()",
e8b0e958
JA
2062 .category = FIO_OPT_C_FILE,
2063 .group = FIO_OPT_G_INVALID,
44f29692
JA
2064 },
2065#endif
214e1eca
JA
2066 {
2067 .name = "direct",
e8b0e958 2068 .lname = "Direct I/O",
214e1eca
JA
2069 .type = FIO_OPT_BOOL,
2070 .off1 = td_var_offset(odirect),
2071 .help = "Use O_DIRECT IO (negates buffered)",
2072 .def = "0",
a01a1bc5 2073 .inverse = "buffered",
e8b0e958 2074 .category = FIO_OPT_C_IO,
3ceb458f 2075 .group = FIO_OPT_G_IO_TYPE,
214e1eca 2076 },
d01612f3
CM
2077 {
2078 .name = "atomic",
2079 .lname = "Atomic I/O",
2080 .type = FIO_OPT_BOOL,
2081 .off1 = td_var_offset(oatomic),
2082 .help = "Use Atomic IO with O_DIRECT (implies O_DIRECT)",
2083 .def = "0",
2084 .category = FIO_OPT_C_IO,
2085 .group = FIO_OPT_G_IO_TYPE,
2086 },
214e1eca
JA
2087 {
2088 .name = "buffered",
e8b0e958 2089 .lname = "Buffered I/O",
214e1eca
JA
2090 .type = FIO_OPT_BOOL,
2091 .off1 = td_var_offset(odirect),
2092 .neg = 1,
2093 .help = "Use buffered IO (negates direct)",
2094 .def = "1",
a01a1bc5 2095 .inverse = "direct",
e8b0e958 2096 .category = FIO_OPT_C_IO,
3ceb458f 2097 .group = FIO_OPT_G_IO_TYPE,
214e1eca
JA
2098 },
2099 {
2100 .name = "overwrite",
e8b0e958 2101 .lname = "Overwrite",
214e1eca
JA
2102 .type = FIO_OPT_BOOL,
2103 .off1 = td_var_offset(overwrite),
2104 .help = "When writing, set whether to overwrite current data",
2105 .def = "0",
e8b0e958
JA
2106 .category = FIO_OPT_C_FILE,
2107 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2108 },
2109 {
2110 .name = "loops",
e8b0e958 2111 .lname = "Loops",
214e1eca
JA
2112 .type = FIO_OPT_INT,
2113 .off1 = td_var_offset(loops),
2114 .help = "Number of times to run the job",
2115 .def = "1",
20eb06bd 2116 .interval = 1,
e8b0e958 2117 .category = FIO_OPT_C_GENERAL,
a1f6afec 2118 .group = FIO_OPT_G_RUNTIME,
214e1eca
JA
2119 },
2120 {
2121 .name = "numjobs",
e8b0e958 2122 .lname = "Number of jobs",
214e1eca
JA
2123 .type = FIO_OPT_INT,
2124 .off1 = td_var_offset(numjobs),
2125 .help = "Duplicate this job this many times",
2126 .def = "1",
20eb06bd 2127 .interval = 1,
e8b0e958 2128 .category = FIO_OPT_C_GENERAL,
a1f6afec 2129 .group = FIO_OPT_G_RUNTIME,
214e1eca
JA
2130 },
2131 {
2132 .name = "startdelay",
e8b0e958 2133 .lname = "Start delay",
a5737c93 2134 .type = FIO_OPT_STR_VAL_TIME,
214e1eca 2135 .off1 = td_var_offset(start_delay),
23ed19b0 2136 .off2 = td_var_offset(start_delay_high),
214e1eca
JA
2137 .help = "Only start job when this period has passed",
2138 .def = "0",
0de5b26f 2139 .is_seconds = 1,
e8b0e958 2140 .category = FIO_OPT_C_GENERAL,
a1f6afec 2141 .group = FIO_OPT_G_RUNTIME,
214e1eca
JA
2142 },
2143 {
2144 .name = "runtime",
e8b0e958 2145 .lname = "Runtime",
214e1eca
JA
2146 .alias = "timeout",
2147 .type = FIO_OPT_STR_VAL_TIME,
2148 .off1 = td_var_offset(timeout),
2149 .help = "Stop workload when this amount of time has passed",
2150 .def = "0",
0de5b26f 2151 .is_seconds = 1,
e8b0e958 2152 .category = FIO_OPT_C_GENERAL,
a1f6afec 2153 .group = FIO_OPT_G_RUNTIME,
214e1eca 2154 },
cf4464ca
JA
2155 {
2156 .name = "time_based",
e8b0e958 2157 .lname = "Time based",
cf4464ca
JA
2158 .type = FIO_OPT_STR_SET,
2159 .off1 = td_var_offset(time_based),
2160 .help = "Keep running until runtime/timeout is met",
e8b0e958 2161 .category = FIO_OPT_C_GENERAL,
a1f6afec 2162 .group = FIO_OPT_G_RUNTIME,
cf4464ca 2163 },
62167762
JC
2164 {
2165 .name = "verify_only",
2166 .lname = "Verify only",
2167 .type = FIO_OPT_STR_SET,
2168 .off1 = td_var_offset(verify_only),
2169 .help = "Verifies previously written data is still valid",
2170 .category = FIO_OPT_C_GENERAL,
2171 .group = FIO_OPT_G_RUNTIME,
2172 },
721938ae
JA
2173 {
2174 .name = "ramp_time",
e8b0e958 2175 .lname = "Ramp time",
721938ae
JA
2176 .type = FIO_OPT_STR_VAL_TIME,
2177 .off1 = td_var_offset(ramp_time),
2178 .help = "Ramp up time before measuring performance",
0de5b26f 2179 .is_seconds = 1,
e8b0e958 2180 .category = FIO_OPT_C_GENERAL,
a1f6afec 2181 .group = FIO_OPT_G_RUNTIME,
721938ae 2182 },
c223da83
JA
2183 {
2184 .name = "clocksource",
e8b0e958 2185 .lname = "Clock source",
c223da83
JA
2186 .type = FIO_OPT_STR,
2187 .cb = fio_clock_source_cb,
2188 .off1 = td_var_offset(clocksource),
2189 .help = "What type of timing source to use",
e8b0e958 2190 .category = FIO_OPT_C_GENERAL,
10860056 2191 .group = FIO_OPT_G_CLOCK,
c223da83 2192 .posval = {
67bf9823 2193#ifdef CONFIG_GETTIMEOFDAY
c223da83
JA
2194 { .ival = "gettimeofday",
2195 .oval = CS_GTOD,
2196 .help = "Use gettimeofday(2) for timing",
2197 },
67bf9823
JA
2198#endif
2199#ifdef CONFIG_CLOCK_GETTIME
c223da83
JA
2200 { .ival = "clock_gettime",
2201 .oval = CS_CGETTIME,
2202 .help = "Use clock_gettime(2) for timing",
2203 },
67bf9823 2204#endif
c223da83
JA
2205#ifdef ARCH_HAVE_CPU_CLOCK
2206 { .ival = "cpu",
2207 .oval = CS_CPUCLOCK,
2208 .help = "Use CPU private clock",
2209 },
2210#endif
2211 },
2212 },
214e1eca
JA
2213 {
2214 .name = "mem",
d3aad8f2 2215 .alias = "iomem",
e8b0e958 2216 .lname = "I/O Memory",
214e1eca
JA
2217 .type = FIO_OPT_STR,
2218 .cb = str_mem_cb,
2219 .off1 = td_var_offset(mem_type),
2220 .help = "Backing type for IO buffers",
2221 .def = "malloc",
e8b0e958
JA
2222 .category = FIO_OPT_C_IO,
2223 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2224 .posval = {
2225 { .ival = "malloc",
2226 .oval = MEM_MALLOC,
2227 .help = "Use malloc(3) for IO buffers",
2228 },
37c8cdfe
JA
2229 { .ival = "shm",
2230 .oval = MEM_SHM,
2231 .help = "Use shared memory segments for IO buffers",
2232 },
214e1eca
JA
2233#ifdef FIO_HAVE_HUGETLB
2234 { .ival = "shmhuge",
2235 .oval = MEM_SHMHUGE,
2236 .help = "Like shm, but use huge pages",
2237 },
b370e46a 2238#endif
37c8cdfe
JA
2239 { .ival = "mmap",
2240 .oval = MEM_MMAP,
2241 .help = "Use mmap(2) (file or anon) for IO buffers",
2242 },
214e1eca
JA
2243#ifdef FIO_HAVE_HUGETLB
2244 { .ival = "mmaphuge",
2245 .oval = MEM_MMAPHUGE,
2246 .help = "Like mmap, but use huge pages",
2247 },
2248#endif
2249 },
2250 },
d529ee19
JA
2251 {
2252 .name = "iomem_align",
2253 .alias = "mem_align",
e8b0e958 2254 .lname = "I/O memory alignment",
d529ee19
JA
2255 .type = FIO_OPT_INT,
2256 .off1 = td_var_offset(mem_align),
2257 .minval = 0,
2258 .help = "IO memory buffer offset alignment",
2259 .def = "0",
2260 .parent = "iomem",
d71c154c 2261 .hide = 1,
e8b0e958
JA
2262 .category = FIO_OPT_C_IO,
2263 .group = FIO_OPT_G_INVALID,
d529ee19 2264 },
214e1eca
JA
2265 {
2266 .name = "verify",
e8b0e958 2267 .lname = "Verify",
214e1eca
JA
2268 .type = FIO_OPT_STR,
2269 .off1 = td_var_offset(verify),
2270 .help = "Verify data written",
2271 .def = "0",
e8b0e958 2272 .category = FIO_OPT_C_IO,
3ceb458f 2273 .group = FIO_OPT_G_VERIFY,
214e1eca
JA
2274 .posval = {
2275 { .ival = "0",
2276 .oval = VERIFY_NONE,
2277 .help = "Don't do IO verification",
2278 },
fcca4b58
JA
2279 { .ival = "md5",
2280 .oval = VERIFY_MD5,
2281 .help = "Use md5 checksums for verification",
2282 },
d77a7af3
JA
2283 { .ival = "crc64",
2284 .oval = VERIFY_CRC64,
2285 .help = "Use crc64 checksums for verification",
2286 },
214e1eca
JA
2287 { .ival = "crc32",
2288 .oval = VERIFY_CRC32,
2289 .help = "Use crc32 checksums for verification",
2290 },
af497e6a 2291 { .ival = "crc32c-intel",
e3aaafc4
JA
2292 .oval = VERIFY_CRC32C,
2293 .help = "Use crc32c checksums for verification (hw assisted, if available)",
af497e6a 2294 },
bac39e0e
JA
2295 { .ival = "crc32c",
2296 .oval = VERIFY_CRC32C,
e3aaafc4 2297 .help = "Use crc32c checksums for verification (hw assisted, if available)",
bac39e0e 2298 },
969f7ed3
JA
2299 { .ival = "crc16",
2300 .oval = VERIFY_CRC16,
2301 .help = "Use crc16 checksums for verification",
2302 },
1e154bdb
JA
2303 { .ival = "crc7",
2304 .oval = VERIFY_CRC7,
2305 .help = "Use crc7 checksums for verification",
2306 },
7c353ceb
JA
2307 { .ival = "sha1",
2308 .oval = VERIFY_SHA1,
2309 .help = "Use sha1 checksums for verification",
2310 },
cd14cc10
JA
2311 { .ival = "sha256",
2312 .oval = VERIFY_SHA256,
2313 .help = "Use sha256 checksums for verification",
2314 },
2315 { .ival = "sha512",
2316 .oval = VERIFY_SHA512,
2317 .help = "Use sha512 checksums for verification",
2318 },
844ea602
JA
2319 { .ival = "xxhash",
2320 .oval = VERIFY_XXHASH,
2321 .help = "Use xxhash checksums for verification",
2322 },
7437ee87
SL
2323 { .ival = "meta",
2324 .oval = VERIFY_META,
2325 .help = "Use io information",
2326 },
36690c9b
JA
2327 {
2328 .ival = "null",
2329 .oval = VERIFY_NULL,
2330 .help = "Pretend to verify",
2331 },
214e1eca
JA
2332 },
2333 },
005c565a
JA
2334 {
2335 .name = "do_verify",
e8b0e958 2336 .lname = "Perform verify step",
68e1f29a 2337 .type = FIO_OPT_BOOL,
005c565a
JA
2338 .off1 = td_var_offset(do_verify),
2339 .help = "Run verification stage after write",
2340 .def = "1",
2341 .parent = "verify",
d71c154c 2342 .hide = 1,
e8b0e958
JA
2343 .category = FIO_OPT_C_IO,
2344 .group = FIO_OPT_G_VERIFY,
005c565a 2345 },
160b966d
JA
2346 {
2347 .name = "verifysort",
e8b0e958 2348 .lname = "Verify sort",
160b966d
JA
2349 .type = FIO_OPT_BOOL,
2350 .off1 = td_var_offset(verifysort),
2351 .help = "Sort written verify blocks for read back",
2352 .def = "1",
c83f2df1 2353 .parent = "verify",
d71c154c 2354 .hide = 1,
e8b0e958
JA
2355 .category = FIO_OPT_C_IO,
2356 .group = FIO_OPT_G_VERIFY,
160b966d 2357 },
1ae83d45
JA
2358 {
2359 .name = "verifysort_nr",
2360 .type = FIO_OPT_INT,
2361 .off1 = td_var_offset(verifysort_nr),
2362 .help = "Pre-load and sort verify blocks for a read workload",
2363 .minval = 0,
2364 .maxval = 131072,
2365 .def = "1024",
2366 .parent = "verify",
836fcc0f
JA
2367 .category = FIO_OPT_C_IO,
2368 .group = FIO_OPT_G_VERIFY,
1ae83d45 2369 },
3f9f4e26 2370 {
a59e170d 2371 .name = "verify_interval",
e8b0e958 2372 .lname = "Verify interval",
e01b22b8 2373 .type = FIO_OPT_INT,
a59e170d 2374 .off1 = td_var_offset(verify_interval),
819a9680 2375 .minval = 2 * sizeof(struct verify_header),
a59e170d 2376 .help = "Store verify buffer header every N bytes",
afdf9352 2377 .parent = "verify",
d71c154c 2378 .hide = 1,
20eb06bd 2379 .interval = 2 * sizeof(struct verify_header),
e8b0e958
JA
2380 .category = FIO_OPT_C_IO,
2381 .group = FIO_OPT_G_VERIFY,
3f9f4e26 2382 },
546a9142 2383 {
a59e170d 2384 .name = "verify_offset",
e8b0e958 2385 .lname = "Verify offset",
e01b22b8 2386 .type = FIO_OPT_INT,
a59e170d 2387 .help = "Offset verify header location by N bytes",
203160d5
JA
2388 .off1 = td_var_offset(verify_offset),
2389 .minval = sizeof(struct verify_header),
afdf9352 2390 .parent = "verify",
d71c154c 2391 .hide = 1,
e8b0e958
JA
2392 .category = FIO_OPT_C_IO,
2393 .group = FIO_OPT_G_VERIFY,
546a9142 2394 },
e28218f3
SL
2395 {
2396 .name = "verify_pattern",
e8b0e958 2397 .lname = "Verify pattern",
0e92f873 2398 .type = FIO_OPT_STR,
e28218f3
SL
2399 .cb = str_verify_pattern_cb,
2400 .help = "Fill pattern for IO buffers",
2401 .parent = "verify",
d71c154c 2402 .hide = 1,
e8b0e958
JA
2403 .category = FIO_OPT_C_IO,
2404 .group = FIO_OPT_G_VERIFY,
e28218f3 2405 },
a12a3b4d
JA
2406 {
2407 .name = "verify_fatal",
e8b0e958 2408 .lname = "Verify fatal",
68e1f29a 2409 .type = FIO_OPT_BOOL,
a12a3b4d
JA
2410 .off1 = td_var_offset(verify_fatal),
2411 .def = "0",
2412 .help = "Exit on a single verify failure, don't continue",
2413 .parent = "verify",
d71c154c 2414 .hide = 1,
e8b0e958
JA
2415 .category = FIO_OPT_C_IO,
2416 .group = FIO_OPT_G_VERIFY,
a12a3b4d 2417 },
b463e936
JA
2418 {
2419 .name = "verify_dump",
e8b0e958 2420 .lname = "Verify dump",
b463e936
JA
2421 .type = FIO_OPT_BOOL,
2422 .off1 = td_var_offset(verify_dump),
ef71e317 2423 .def = "0",
b463e936
JA
2424 .help = "Dump contents of good and bad blocks on failure",
2425 .parent = "verify",
d71c154c 2426 .hide = 1,
e8b0e958
JA
2427 .category = FIO_OPT_C_IO,
2428 .group = FIO_OPT_G_VERIFY,
b463e936 2429 },
e8462bd8
JA
2430 {
2431 .name = "verify_async",
e8b0e958 2432 .lname = "Verify asynchronously",
e8462bd8
JA
2433 .type = FIO_OPT_INT,
2434 .off1 = td_var_offset(verify_async),
2435 .def = "0",
2436 .help = "Number of async verifier threads to use",
2437 .parent = "verify",
d71c154c 2438 .hide = 1,
e8b0e958
JA
2439 .category = FIO_OPT_C_IO,
2440 .group = FIO_OPT_G_VERIFY,
e8462bd8 2441 },
9e144189
JA
2442 {
2443 .name = "verify_backlog",
e8b0e958 2444 .lname = "Verify backlog",
9e144189
JA
2445 .type = FIO_OPT_STR_VAL,
2446 .off1 = td_var_offset(verify_backlog),
2447 .help = "Verify after this number of blocks are written",
2448 .parent = "verify",
d71c154c 2449 .hide = 1,
e8b0e958
JA
2450 .category = FIO_OPT_C_IO,
2451 .group = FIO_OPT_G_VERIFY,
9e144189
JA
2452 },
2453 {
2454 .name = "verify_backlog_batch",
e8b0e958 2455 .lname = "Verify backlog batch",
9e144189
JA
2456 .type = FIO_OPT_INT,
2457 .off1 = td_var_offset(verify_batch),
2458 .help = "Verify this number of IO blocks",
0d29de83 2459 .parent = "verify",
d71c154c 2460 .hide = 1,
e8b0e958
JA
2461 .category = FIO_OPT_C_IO,
2462 .group = FIO_OPT_G_VERIFY,
9e144189 2463 },
e8462bd8
JA
2464#ifdef FIO_HAVE_CPU_AFFINITY
2465 {
2466 .name = "verify_async_cpus",
e8b0e958 2467 .lname = "Async verify CPUs",
e8462bd8
JA
2468 .type = FIO_OPT_STR,
2469 .cb = str_verify_cpus_allowed_cb,
2470 .help = "Set CPUs allowed for async verify threads",
2471 .parent = "verify_async",
d71c154c 2472 .hide = 1,
e8b0e958
JA
2473 .category = FIO_OPT_C_IO,
2474 .group = FIO_OPT_G_VERIFY,
e8462bd8 2475 },
0d29de83 2476#endif
51aa2da8
JA
2477 {
2478 .name = "experimental_verify",
2479 .off1 = td_var_offset(experimental_verify),
2480 .type = FIO_OPT_BOOL,
b31eaac9 2481 .help = "Enable experimental verification",
836fcc0f
JA
2482 .category = FIO_OPT_C_IO,
2483 .group = FIO_OPT_G_VERIFY,
51aa2da8 2484 },
0d29de83
JA
2485#ifdef FIO_HAVE_TRIM
2486 {
2487 .name = "trim_percentage",
e8b0e958 2488 .lname = "Trim percentage",
0d29de83 2489 .type = FIO_OPT_INT,
203160d5 2490 .off1 = td_var_offset(trim_percentage),
20eb06bd 2491 .minval = 0,
0d29de83
JA
2492 .maxval = 100,
2493 .help = "Number of verify blocks to discard/trim",
2494 .parent = "verify",
2495 .def = "0",
20eb06bd 2496 .interval = 1,
d71c154c 2497 .hide = 1,
e8b0e958
JA
2498 .category = FIO_OPT_C_IO,
2499 .group = FIO_OPT_G_TRIM,
0d29de83
JA
2500 },
2501 {
2502 .name = "trim_verify_zero",
e8b0e958 2503 .lname = "Verify trim zero",
20eb06bd 2504 .type = FIO_OPT_BOOL,
0d29de83
JA
2505 .help = "Verify that trim/discarded blocks are returned as zeroes",
2506 .off1 = td_var_offset(trim_zero),
2507 .parent = "trim_percentage",
d71c154c 2508 .hide = 1,
0d29de83 2509 .def = "1",
e8b0e958
JA
2510 .category = FIO_OPT_C_IO,
2511 .group = FIO_OPT_G_TRIM,
0d29de83
JA
2512 },
2513 {
2514 .name = "trim_backlog",
e8b0e958 2515 .lname = "Trim backlog",
0d29de83
JA
2516 .type = FIO_OPT_STR_VAL,
2517 .off1 = td_var_offset(trim_backlog),
2518 .help = "Trim after this number of blocks are written",
2519 .parent = "trim_percentage",
d71c154c 2520 .hide = 1,
20eb06bd 2521 .interval = 1,
e8b0e958
JA
2522 .category = FIO_OPT_C_IO,
2523 .group = FIO_OPT_G_TRIM,
0d29de83
JA
2524 },
2525 {
2526 .name = "trim_backlog_batch",
e8b0e958 2527 .lname = "Trim backlog batch",
0d29de83
JA
2528 .type = FIO_OPT_INT,
2529 .off1 = td_var_offset(trim_batch),
2530 .help = "Trim this number of IO blocks",
2531 .parent = "trim_percentage",
d71c154c 2532 .hide = 1,
20eb06bd 2533 .interval = 1,
e8b0e958
JA
2534 .category = FIO_OPT_C_IO,
2535 .group = FIO_OPT_G_TRIM,
0d29de83 2536 },
e8462bd8 2537#endif
214e1eca
JA
2538 {
2539 .name = "write_iolog",
e8b0e958 2540 .lname = "Write I/O log",
214e1eca
JA
2541 .type = FIO_OPT_STR_STORE,
2542 .off1 = td_var_offset(write_iolog_file),
2543 .help = "Store IO pattern to file",
e8b0e958
JA
2544 .category = FIO_OPT_C_IO,
2545 .group = FIO_OPT_G_IOLOG,
214e1eca
JA
2546 },
2547 {
2548 .name = "read_iolog",
e8b0e958 2549 .lname = "Read I/O log",
214e1eca
JA
2550 .type = FIO_OPT_STR_STORE,
2551 .off1 = td_var_offset(read_iolog_file),
2552 .help = "Playback IO pattern from file",
e8b0e958
JA
2553 .category = FIO_OPT_C_IO,
2554 .group = FIO_OPT_G_IOLOG,
214e1eca 2555 },
64bbb865
DN
2556 {
2557 .name = "replay_no_stall",
e8b0e958 2558 .lname = "Don't stall on replay",
20eb06bd 2559 .type = FIO_OPT_BOOL,
64bbb865
DN
2560 .off1 = td_var_offset(no_stall),
2561 .def = "0",
87e7a972 2562 .parent = "read_iolog",
d71c154c 2563 .hide = 1,
64bbb865 2564 .help = "Playback IO pattern file as fast as possible without stalls",
e8b0e958
JA
2565 .category = FIO_OPT_C_IO,
2566 .group = FIO_OPT_G_IOLOG,
64bbb865 2567 },
d1c46c04
DN
2568 {
2569 .name = "replay_redirect",
e8b0e958 2570 .lname = "Redirect device for replay",
d1c46c04
DN
2571 .type = FIO_OPT_STR_STORE,
2572 .off1 = td_var_offset(replay_redirect),
2573 .parent = "read_iolog",
d71c154c 2574 .hide = 1,
d1c46c04 2575 .help = "Replay all I/O onto this device, regardless of trace device",
e8b0e958
JA
2576 .category = FIO_OPT_C_IO,
2577 .group = FIO_OPT_G_IOLOG,
d1c46c04 2578 },
214e1eca
JA
2579 {
2580 .name = "exec_prerun",
e8b0e958 2581 .lname = "Pre-execute runnable",
214e1eca
JA
2582 .type = FIO_OPT_STR_STORE,
2583 .off1 = td_var_offset(exec_prerun),
2584 .help = "Execute this file prior to running job",
e8b0e958
JA
2585 .category = FIO_OPT_C_GENERAL,
2586 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2587 },
2588 {
2589 .name = "exec_postrun",
e8b0e958 2590 .lname = "Post-execute runnable",
214e1eca
JA
2591 .type = FIO_OPT_STR_STORE,
2592 .off1 = td_var_offset(exec_postrun),
2593 .help = "Execute this file after running job",
e8b0e958
JA
2594 .category = FIO_OPT_C_GENERAL,
2595 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2596 },
2597#ifdef FIO_HAVE_IOSCHED_SWITCH
2598 {
2599 .name = "ioscheduler",
e8b0e958 2600 .lname = "I/O scheduler",
214e1eca
JA
2601 .type = FIO_OPT_STR_STORE,
2602 .off1 = td_var_offset(ioscheduler),
2603 .help = "Use this IO scheduler on the backing device",
e8b0e958
JA
2604 .category = FIO_OPT_C_FILE,
2605 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2606 },
2607#endif
2608 {
2609 .name = "zonesize",
e8b0e958 2610 .lname = "Zone size",
214e1eca
JA
2611 .type = FIO_OPT_STR_VAL,
2612 .off1 = td_var_offset(zone_size),
ed335855
SN
2613 .help = "Amount of data to read per zone",
2614 .def = "0",
20eb06bd 2615 .interval = 1024 * 1024,
e8b0e958
JA
2616 .category = FIO_OPT_C_IO,
2617 .group = FIO_OPT_G_ZONE,
ed335855
SN
2618 },
2619 {
2620 .name = "zonerange",
e8b0e958 2621 .lname = "Zone range",
ed335855
SN
2622 .type = FIO_OPT_STR_VAL,
2623 .off1 = td_var_offset(zone_range),
214e1eca
JA
2624 .help = "Give size of an IO zone",
2625 .def = "0",
20eb06bd 2626 .interval = 1024 * 1024,
e8b0e958
JA
2627 .category = FIO_OPT_C_IO,
2628 .group = FIO_OPT_G_ZONE,
214e1eca
JA
2629 },
2630 {
2631 .name = "zoneskip",
e8b0e958 2632 .lname = "Zone skip",
214e1eca
JA
2633 .type = FIO_OPT_STR_VAL,
2634 .off1 = td_var_offset(zone_skip),
2635 .help = "Space between IO zones",
2636 .def = "0",
20eb06bd 2637 .interval = 1024 * 1024,
e8b0e958
JA
2638 .category = FIO_OPT_C_IO,
2639 .group = FIO_OPT_G_ZONE,
214e1eca
JA
2640 },
2641 {
2642 .name = "lockmem",
e8b0e958 2643 .lname = "Lock memory",
214e1eca 2644 .type = FIO_OPT_STR_VAL,
1b79a070 2645 .off1 = td_var_offset(lockmem),
81c6b6cd 2646 .help = "Lock down this amount of memory (per worker)",
214e1eca 2647 .def = "0",
20eb06bd 2648 .interval = 1024 * 1024,
e8b0e958
JA
2649 .category = FIO_OPT_C_GENERAL,
2650 .group = FIO_OPT_G_INVALID,
214e1eca 2651 },
214e1eca
JA
2652 {
2653 .name = "rwmixread",
e8b0e958 2654 .lname = "Read/write mix read",
214e1eca 2655 .type = FIO_OPT_INT,
cb499fc4 2656 .cb = str_rwmix_read_cb,
214e1eca
JA
2657 .maxval = 100,
2658 .help = "Percentage of mixed workload that is reads",
2659 .def = "50",
20eb06bd 2660 .interval = 5,
90265353 2661 .inverse = "rwmixwrite",
e8b0e958
JA
2662 .category = FIO_OPT_C_IO,
2663 .group = FIO_OPT_G_RWMIX,
214e1eca
JA
2664 },
2665 {
2666 .name = "rwmixwrite",
e8b0e958 2667 .lname = "Read/write mix write",
214e1eca 2668 .type = FIO_OPT_INT,
cb499fc4 2669 .cb = str_rwmix_write_cb,
214e1eca
JA
2670 .maxval = 100,
2671 .help = "Percentage of mixed workload that is writes",
2672 .def = "50",
20eb06bd 2673 .interval = 5,
90265353 2674 .inverse = "rwmixread",
e8b0e958
JA
2675 .category = FIO_OPT_C_IO,
2676 .group = FIO_OPT_G_RWMIX,
214e1eca 2677 },
afdf9352
JA
2678 {
2679 .name = "rwmixcycle",
e8b0e958 2680 .lname = "Read/write mix cycle",
15ca150e 2681 .type = FIO_OPT_DEPRECATED,
e8b0e958
JA
2682 .category = FIO_OPT_C_IO,
2683 .group = FIO_OPT_G_RWMIX,
afdf9352 2684 },
214e1eca
JA
2685 {
2686 .name = "nice",
e8b0e958 2687 .lname = "Nice",
214e1eca
JA
2688 .type = FIO_OPT_INT,
2689 .off1 = td_var_offset(nice),
2690 .help = "Set job CPU nice value",
2691 .minval = -19,
2692 .maxval = 20,
2693 .def = "0",
20eb06bd 2694 .interval = 1,
e8b0e958 2695 .category = FIO_OPT_C_GENERAL,
10860056 2696 .group = FIO_OPT_G_CRED,
214e1eca
JA
2697 },
2698#ifdef FIO_HAVE_IOPRIO
2699 {
2700 .name = "prio",
e8b0e958 2701 .lname = "I/O nice priority",
214e1eca 2702 .type = FIO_OPT_INT,
28727df7 2703 .off1 = td_var_offset(ioprio),
214e1eca
JA
2704 .help = "Set job IO priority value",
2705 .minval = 0,
2706 .maxval = 7,
20eb06bd 2707 .interval = 1,
e8b0e958 2708 .category = FIO_OPT_C_GENERAL,
10860056 2709 .group = FIO_OPT_G_CRED,
214e1eca
JA
2710 },
2711 {
2712 .name = "prioclass",
e8b0e958 2713 .lname = "I/O nice priority class",
214e1eca 2714 .type = FIO_OPT_INT,
28727df7 2715 .off1 = td_var_offset(ioprio_class),
214e1eca
JA
2716 .help = "Set job IO priority class",
2717 .minval = 0,
2718 .maxval = 3,
20eb06bd 2719 .interval = 1,
e8b0e958 2720 .category = FIO_OPT_C_GENERAL,
10860056 2721 .group = FIO_OPT_G_CRED,
214e1eca
JA
2722 },
2723#endif
2724 {
2725 .name = "thinktime",
e8b0e958 2726 .lname = "Thinktime",
214e1eca
JA
2727 .type = FIO_OPT_INT,
2728 .off1 = td_var_offset(thinktime),
2729 .help = "Idle time between IO buffers (usec)",
2730 .def = "0",
e8b0e958 2731 .category = FIO_OPT_C_IO,
3ceb458f 2732 .group = FIO_OPT_G_THINKTIME,
214e1eca
JA
2733 },
2734 {
2735 .name = "thinktime_spin",
e8b0e958 2736 .lname = "Thinktime spin",
214e1eca
JA
2737 .type = FIO_OPT_INT,
2738 .off1 = td_var_offset(thinktime_spin),
2739 .help = "Start think time by spinning this amount (usec)",
2740 .def = "0",
afdf9352 2741 .parent = "thinktime",
d71c154c 2742 .hide = 1,
e8b0e958 2743 .category = FIO_OPT_C_IO,
3ceb458f 2744 .group = FIO_OPT_G_THINKTIME,
214e1eca
JA
2745 },
2746 {
2747 .name = "thinktime_blocks",
e8b0e958 2748 .lname = "Thinktime blocks",
214e1eca
JA
2749 .type = FIO_OPT_INT,
2750 .off1 = td_var_offset(thinktime_blocks),
2751 .help = "IO buffer period between 'thinktime'",
2752 .def = "1",
afdf9352 2753 .parent = "thinktime",
d71c154c 2754 .hide = 1,
e8b0e958 2755 .category = FIO_OPT_C_IO,
3ceb458f 2756 .group = FIO_OPT_G_THINKTIME,
214e1eca
JA
2757 },
2758 {
2759 .name = "rate",
e8b0e958 2760 .lname = "I/O rate",
e01b22b8 2761 .type = FIO_OPT_INT,
6eaf09d6
SL
2762 .off1 = td_var_offset(rate[DDIR_READ]),
2763 .off2 = td_var_offset(rate[DDIR_WRITE]),
2764 .off3 = td_var_offset(rate[DDIR_TRIM]),
214e1eca 2765 .help = "Set bandwidth rate",
e8b0e958
JA
2766 .category = FIO_OPT_C_IO,
2767 .group = FIO_OPT_G_RATE,
214e1eca
JA
2768 },
2769 {
2770 .name = "ratemin",
e8b0e958 2771 .lname = "I/O min rate",
e01b22b8 2772 .type = FIO_OPT_INT,
6eaf09d6
SL
2773 .off1 = td_var_offset(ratemin[DDIR_READ]),
2774 .off2 = td_var_offset(ratemin[DDIR_WRITE]),
2775 .off3 = td_var_offset(ratemin[DDIR_TRIM]),
4e991c23 2776 .help = "Job must meet this rate or it will be shutdown",
afdf9352 2777 .parent = "rate",
d71c154c 2778 .hide = 1,
e8b0e958
JA
2779 .category = FIO_OPT_C_IO,
2780 .group = FIO_OPT_G_RATE,
4e991c23
JA
2781 },
2782 {
2783 .name = "rate_iops",
e8b0e958 2784 .lname = "I/O rate IOPS",
e01b22b8 2785 .type = FIO_OPT_INT,
6eaf09d6
SL
2786 .off1 = td_var_offset(rate_iops[DDIR_READ]),
2787 .off2 = td_var_offset(rate_iops[DDIR_WRITE]),
2788 .off3 = td_var_offset(rate_iops[DDIR_TRIM]),
4e991c23 2789 .help = "Limit IO used to this number of IO operations/sec",
d71c154c 2790 .hide = 1,
e8b0e958
JA
2791 .category = FIO_OPT_C_IO,
2792 .group = FIO_OPT_G_RATE,
4e991c23
JA
2793 },
2794 {
2795 .name = "rate_iops_min",
e8b0e958 2796 .lname = "I/O min rate IOPS",
e01b22b8 2797 .type = FIO_OPT_INT,
6eaf09d6
SL
2798 .off1 = td_var_offset(rate_iops_min[DDIR_READ]),
2799 .off2 = td_var_offset(rate_iops_min[DDIR_WRITE]),
2800 .off3 = td_var_offset(rate_iops_min[DDIR_TRIM]),
03e20d68 2801 .help = "Job must meet this rate or it will be shut down",
afdf9352 2802 .parent = "rate_iops",
d71c154c 2803 .hide = 1,
e8b0e958
JA
2804 .category = FIO_OPT_C_IO,
2805 .group = FIO_OPT_G_RATE,
214e1eca
JA
2806 },
2807 {
2808 .name = "ratecycle",
e8b0e958 2809 .lname = "I/O rate cycle",
214e1eca
JA
2810 .type = FIO_OPT_INT,
2811 .off1 = td_var_offset(ratecycle),
2812 .help = "Window average for rate limits (msec)",
2813 .def = "1000",
afdf9352 2814 .parent = "rate",
d71c154c 2815 .hide = 1,
e8b0e958
JA
2816 .category = FIO_OPT_C_IO,
2817 .group = FIO_OPT_G_RATE,
214e1eca 2818 },
15501535
JA
2819 {
2820 .name = "max_latency",
2821 .type = FIO_OPT_INT,
2822 .off1 = td_var_offset(max_latency),
2823 .help = "Maximum tolerated IO latency (usec)",
1e5324e7 2824 .category = FIO_OPT_C_IO,
3e260a46
JA
2825 .group = FIO_OPT_G_LATPROF,
2826 },
2827 {
2828 .name = "latency_target",
2829 .lname = "Latency Target (usec)",
2830 .type = FIO_OPT_STR_VAL_TIME,
2831 .off1 = td_var_offset(latency_target),
2832 .help = "Ramp to max queue depth supporting this latency",
2833 .category = FIO_OPT_C_IO,
2834 .group = FIO_OPT_G_LATPROF,
2835 },
2836 {
2837 .name = "latency_window",
2838 .lname = "Latency Window (usec)",
2839 .type = FIO_OPT_STR_VAL_TIME,
2840 .off1 = td_var_offset(latency_window),
2841 .help = "Time to sustain latency_target",
2842 .category = FIO_OPT_C_IO,
2843 .group = FIO_OPT_G_LATPROF,
2844 },
2845 {
2846 .name = "latency_percentile",
2847 .lname = "Latency Percentile",
2848 .type = FIO_OPT_FLOAT_LIST,
2849 .off1 = td_var_offset(latency_percentile),
2850 .help = "Percentile of IOs must be below latency_target",
2851 .def = "100",
2852 .maxlen = 1,
2853 .minfp = 0.0,
2854 .maxfp = 100.0,
2855 .category = FIO_OPT_C_IO,
2856 .group = FIO_OPT_G_LATPROF,
15501535 2857 },
214e1eca
JA
2858 {
2859 .name = "invalidate",
e8b0e958 2860 .lname = "Cache invalidate",
214e1eca
JA
2861 .type = FIO_OPT_BOOL,
2862 .off1 = td_var_offset(invalidate_cache),
2863 .help = "Invalidate buffer/page cache prior to running job",
2864 .def = "1",
e8b0e958 2865 .category = FIO_OPT_C_IO,
3ceb458f 2866 .group = FIO_OPT_G_IO_TYPE,
214e1eca
JA
2867 },
2868 {
2869 .name = "sync",
e8b0e958 2870 .lname = "Synchronous I/O",
214e1eca
JA
2871 .type = FIO_OPT_BOOL,
2872 .off1 = td_var_offset(sync_io),
2873 .help = "Use O_SYNC for buffered writes",
2874 .def = "0",
67a1000f 2875 .parent = "buffered",
d71c154c 2876 .hide = 1,
e8b0e958 2877 .category = FIO_OPT_C_IO,
3ceb458f 2878 .group = FIO_OPT_G_IO_TYPE,
214e1eca 2879 },
214e1eca
JA
2880 {
2881 .name = "create_serialize",
e8b0e958 2882 .lname = "Create serialize",
214e1eca
JA
2883 .type = FIO_OPT_BOOL,
2884 .off1 = td_var_offset(create_serialize),
2885 .help = "Serialize creating of job files",
2886 .def = "1",
e8b0e958
JA
2887 .category = FIO_OPT_C_FILE,
2888 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2889 },
2890 {
2891 .name = "create_fsync",
e8b0e958 2892 .lname = "Create fsync",
214e1eca
JA
2893 .type = FIO_OPT_BOOL,
2894 .off1 = td_var_offset(create_fsync),
03e20d68 2895 .help = "fsync file after creation",
214e1eca 2896 .def = "1",
e8b0e958
JA
2897 .category = FIO_OPT_C_FILE,
2898 .group = FIO_OPT_G_INVALID,
214e1eca 2899 },
814452bd
JA
2900 {
2901 .name = "create_on_open",
e8b0e958 2902 .lname = "Create on open",
814452bd
JA
2903 .type = FIO_OPT_BOOL,
2904 .off1 = td_var_offset(create_on_open),
2905 .help = "Create files when they are opened for IO",
2906 .def = "0",
e8b0e958
JA
2907 .category = FIO_OPT_C_FILE,
2908 .group = FIO_OPT_G_INVALID,
814452bd 2909 },
25460cf6
JA
2910 {
2911 .name = "create_only",
2912 .type = FIO_OPT_BOOL,
2913 .off1 = td_var_offset(create_only),
2914 .help = "Only perform file creation phase",
d17fda71 2915 .category = FIO_OPT_C_FILE,
25460cf6
JA
2916 .def = "0",
2917 },
0b9d69ec 2918 {
afad68f7 2919 .name = "pre_read",
e8b0e958 2920 .lname = "Pre-read files",
afad68f7
ZY
2921 .type = FIO_OPT_BOOL,
2922 .off1 = td_var_offset(pre_read),
03e20d68 2923 .help = "Pre-read files before starting official testing",
afad68f7 2924 .def = "0",
e8b0e958
JA
2925 .category = FIO_OPT_C_FILE,
2926 .group = FIO_OPT_G_INVALID,
afad68f7 2927 },
214e1eca
JA
2928#ifdef FIO_HAVE_CPU_AFFINITY
2929 {
2930 .name = "cpumask",
e8b0e958 2931 .lname = "CPU mask",
214e1eca
JA
2932 .type = FIO_OPT_INT,
2933 .cb = str_cpumask_cb,
2934 .help = "CPU affinity mask",
e8b0e958 2935 .category = FIO_OPT_C_GENERAL,
10860056 2936 .group = FIO_OPT_G_CRED,
214e1eca 2937 },
d2e268b0
JA
2938 {
2939 .name = "cpus_allowed",
e8b0e958 2940 .lname = "CPUs allowed",
d2e268b0
JA
2941 .type = FIO_OPT_STR,
2942 .cb = str_cpus_allowed_cb,
2943 .help = "Set CPUs allowed",
e8b0e958 2944 .category = FIO_OPT_C_GENERAL,
10860056 2945 .group = FIO_OPT_G_CRED,
d2e268b0 2946 },
c2acfbac
JA
2947 {
2948 .name = "cpus_allowed_policy",
2949 .lname = "CPUs allowed distribution policy",
2950 .type = FIO_OPT_STR,
2951 .off1 = td_var_offset(cpus_allowed_policy),
2952 .help = "Distribution policy for cpus_allowed",
2953 .parent = "cpus_allowed",
2954 .prio = 1,
2955 .posval = {
2956 { .ival = "shared",
2957 .oval = FIO_CPUS_SHARED,
2958 .help = "Mask shared between threads",
2959 },
2960 { .ival = "split",
2961 .oval = FIO_CPUS_SPLIT,
2962 .help = "Mask split between threads",
2963 },
2964 },
2965 .category = FIO_OPT_C_GENERAL,
2966 .group = FIO_OPT_G_CRED,
2967 },
d0b937ed 2968#endif
67bf9823 2969#ifdef CONFIG_LIBNUMA
d0b937ed
YR
2970 {
2971 .name = "numa_cpu_nodes",
2972 .type = FIO_OPT_STR,
2973 .cb = str_numa_cpunodes_cb,
2974 .help = "NUMA CPU nodes bind",
6be54b2d
JA
2975 .category = FIO_OPT_C_GENERAL,
2976 .group = FIO_OPT_G_INVALID,
d0b937ed
YR
2977 },
2978 {
2979 .name = "numa_mem_policy",
2980 .type = FIO_OPT_STR,
2981 .cb = str_numa_mpol_cb,
2982 .help = "NUMA memory policy setup",
6be54b2d
JA
2983 .category = FIO_OPT_C_GENERAL,
2984 .group = FIO_OPT_G_INVALID,
d0b937ed 2985 },
214e1eca
JA
2986#endif
2987 {
2988 .name = "end_fsync",
e8b0e958 2989 .lname = "End fsync",
214e1eca
JA
2990 .type = FIO_OPT_BOOL,
2991 .off1 = td_var_offset(end_fsync),
2992 .help = "Include fsync at the end of job",
2993 .def = "0",
e8b0e958
JA
2994 .category = FIO_OPT_C_FILE,
2995 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2996 },
2997 {
2998 .name = "fsync_on_close",
e8b0e958 2999 .lname = "Fsync on close",
214e1eca
JA
3000 .type = FIO_OPT_BOOL,
3001 .off1 = td_var_offset(fsync_on_close),
3002 .help = "fsync files on close",
3003 .def = "0",
e8b0e958
JA
3004 .category = FIO_OPT_C_FILE,
3005 .group = FIO_OPT_G_INVALID,
214e1eca
JA
3006 },
3007 {
3008 .name = "unlink",
e8b0e958 3009 .lname = "Unlink file",
214e1eca
JA
3010 .type = FIO_OPT_BOOL,
3011 .off1 = td_var_offset(unlink),
3012 .help = "Unlink created files after job has completed",
3013 .def = "0",
e8b0e958
JA
3014 .category = FIO_OPT_C_FILE,
3015 .group = FIO_OPT_G_INVALID,
214e1eca
JA
3016 },
3017 {
3018 .name = "exitall",
e8b0e958 3019 .lname = "Exit-all on terminate",
214e1eca
JA
3020 .type = FIO_OPT_STR_SET,
3021 .cb = str_exitall_cb,
3022 .help = "Terminate all jobs when one exits",
e8b0e958 3023 .category = FIO_OPT_C_GENERAL,
a1f6afec 3024 .group = FIO_OPT_G_PROCESS,
214e1eca
JA
3025 },
3026 {
3027 .name = "stonewall",
e8b0e958 3028 .lname = "Wait for previous",
d392365e 3029 .alias = "wait_for_previous",
214e1eca
JA
3030 .type = FIO_OPT_STR_SET,
3031 .off1 = td_var_offset(stonewall),
3032 .help = "Insert a hard barrier between this job and previous",
e8b0e958 3033 .category = FIO_OPT_C_GENERAL,
a1f6afec 3034 .group = FIO_OPT_G_PROCESS,
214e1eca 3035 },
b3d62a75
JA
3036 {
3037 .name = "new_group",
e8b0e958 3038 .lname = "New group",
b3d62a75
JA
3039 .type = FIO_OPT_STR_SET,
3040 .off1 = td_var_offset(new_group),
3041 .help = "Mark the start of a new group (for reporting)",
e8b0e958 3042 .category = FIO_OPT_C_GENERAL,
a1f6afec 3043 .group = FIO_OPT_G_PROCESS,
b3d62a75 3044 },
214e1eca
JA
3045 {
3046 .name = "thread",
e8b0e958 3047 .lname = "Thread",
214e1eca
JA
3048 .type = FIO_OPT_STR_SET,
3049 .off1 = td_var_offset(use_thread),
20eb06bd 3050 .help = "Use threads instead of processes",
e8b0e958 3051 .category = FIO_OPT_C_GENERAL,
a1f6afec 3052 .group = FIO_OPT_G_PROCESS,
214e1eca
JA
3053 },
3054 {
3055 .name = "write_bw_log",
e8b0e958 3056 .lname = "Write bandwidth log",
203160d5
JA
3057 .type = FIO_OPT_STR_STORE,
3058 .off1 = td_var_offset(bw_log_file),
214e1eca 3059 .help = "Write log of bandwidth during run",
e8b0e958
JA
3060 .category = FIO_OPT_C_LOG,
3061 .group = FIO_OPT_G_INVALID,
214e1eca
JA
3062 },
3063 {
3064 .name = "write_lat_log",
e8b0e958 3065 .lname = "Write latency log",
203160d5
JA
3066 .type = FIO_OPT_STR_STORE,
3067 .off1 = td_var_offset(lat_log_file),
214e1eca 3068 .help = "Write log of latency during run",
e8b0e958
JA
3069 .category = FIO_OPT_C_LOG,
3070 .group = FIO_OPT_G_INVALID,
214e1eca 3071 },
c8eeb9df
JA
3072 {
3073 .name = "write_iops_log",
e8b0e958 3074 .lname = "Write IOPS log",
577c83bd 3075 .type = FIO_OPT_STR_STORE,
203160d5 3076 .off1 = td_var_offset(iops_log_file),
c8eeb9df 3077 .help = "Write log of IOPS during run",
e8b0e958
JA
3078 .category = FIO_OPT_C_LOG,
3079 .group = FIO_OPT_G_INVALID,
c8eeb9df 3080 },
b8bc8cba
JA
3081 {
3082 .name = "log_avg_msec",
e8b0e958 3083 .lname = "Log averaging (msec)",
b8bc8cba
JA
3084 .type = FIO_OPT_INT,
3085 .off1 = td_var_offset(log_avg_msec),
3086 .help = "Average bw/iops/lat logs over this period of time",
3087 .def = "0",
e8b0e958
JA
3088 .category = FIO_OPT_C_LOG,
3089 .group = FIO_OPT_G_INVALID,
b8bc8cba 3090 },
c504ee55
JA
3091 {
3092 .name = "bwavgtime",
3093 .lname = "Bandwidth average time",
3094 .type = FIO_OPT_INT,
3095 .off1 = td_var_offset(bw_avg_time),
3096 .help = "Time window over which to calculate bandwidth"
3097 " (msec)",
3098 .def = "500",
3099 .parent = "write_bw_log",
3100 .hide = 1,
3101 .interval = 100,
3102 .category = FIO_OPT_C_LOG,
3103 .group = FIO_OPT_G_INVALID,
3104 },
3105 {
3106 .name = "iopsavgtime",
3107 .lname = "IOPS average time",
3108 .type = FIO_OPT_INT,
3109 .off1 = td_var_offset(iops_avg_time),
3110 .help = "Time window over which to calculate IOPS (msec)",
3111 .def = "500",
3112 .parent = "write_iops_log",
3113 .hide = 1,
3114 .interval = 100,
3115 .category = FIO_OPT_C_LOG,
3116 .group = FIO_OPT_G_INVALID,
3117 },
214e1eca
JA
3118 {
3119 .name = "group_reporting",
e8b0e958 3120 .lname = "Group reporting",
d2507043 3121 .type = FIO_OPT_STR_SET,
214e1eca
JA
3122 .off1 = td_var_offset(group_reporting),
3123 .help = "Do reporting on a per-group basis",
10860056 3124 .category = FIO_OPT_C_STAT,
e8b0e958 3125 .group = FIO_OPT_G_INVALID,
214e1eca 3126 },
e9459e5a
JA
3127 {
3128 .name = "zero_buffers",
e8b0e958 3129 .lname = "Zero I/O buffers",
e9459e5a
JA
3130 .type = FIO_OPT_STR_SET,
3131 .off1 = td_var_offset(zero_buffers),
3132 .help = "Init IO buffers to all zeroes",
e8b0e958 3133 .category = FIO_OPT_C_IO,
3ceb458f 3134 .group = FIO_OPT_G_IO_BUF,
e9459e5a 3135 },
5973cafb
JA
3136 {
3137 .name = "refill_buffers",
e8b0e958 3138 .lname = "Refill I/O buffers",
5973cafb
JA
3139 .type = FIO_OPT_STR_SET,
3140 .off1 = td_var_offset(refill_buffers),
3141 .help = "Refill IO buffers on every IO submit",
e8b0e958 3142 .category = FIO_OPT_C_IO,
3ceb458f 3143 .group = FIO_OPT_G_IO_BUF,
5973cafb 3144 },
fd68418e
JA
3145 {
3146 .name = "scramble_buffers",
e8b0e958 3147 .lname = "Scramble I/O buffers",
fd68418e
JA
3148 .type = FIO_OPT_BOOL,
3149 .off1 = td_var_offset(scramble_buffers),
3150 .help = "Slightly scramble buffers on every IO submit",
3151 .def = "1",
e8b0e958 3152 .category = FIO_OPT_C_IO,
3ceb458f 3153 .group = FIO_OPT_G_IO_BUF,
fd68418e 3154 },
ce35b1ec
JA
3155 {
3156 .name = "buffer_pattern",
3157 .lname = "Buffer pattern",
3158 .type = FIO_OPT_STR,
3159 .cb = str_buffer_pattern_cb,
3160 .help = "Fill pattern for IO buffers",
3161 .category = FIO_OPT_C_IO,
3162 .group = FIO_OPT_G_IO_BUF,
3163 },
9c42684e
JA
3164 {
3165 .name = "buffer_compress_percentage",
e8b0e958 3166 .lname = "Buffer compression percentage",
9c42684e 3167 .type = FIO_OPT_INT,
bedc9dc2 3168 .cb = str_buffer_compress_cb,
9c42684e 3169 .maxval = 100,
e7f5de90 3170 .minval = 0,
9c42684e 3171 .help = "How compressible the buffer is (approximately)",
20eb06bd 3172 .interval = 5,
e8b0e958 3173 .category = FIO_OPT_C_IO,
3ceb458f 3174 .group = FIO_OPT_G_IO_BUF,
9c42684e 3175 },
f97a43a1
JA
3176 {
3177 .name = "buffer_compress_chunk",
e8b0e958 3178 .lname = "Buffer compression chunk size",
f97a43a1
JA
3179 .type = FIO_OPT_INT,
3180 .off1 = td_var_offset(compress_chunk),
207b18e4 3181 .parent = "buffer_compress_percentage",
d71c154c 3182 .hide = 1,
f97a43a1 3183 .help = "Size of compressible region in buffer",
20eb06bd 3184 .interval = 256,
e8b0e958 3185 .category = FIO_OPT_C_IO,
3ceb458f 3186 .group = FIO_OPT_G_IO_BUF,
f97a43a1 3187 },
83349190
YH
3188 {
3189 .name = "clat_percentiles",
e8b0e958 3190 .lname = "Completion latency percentiles",
83349190
YH
3191 .type = FIO_OPT_BOOL,
3192 .off1 = td_var_offset(clat_percentiles),
3193 .help = "Enable the reporting of completion latency percentiles",
467b35ed 3194 .def = "1",
e8b0e958
JA
3195 .category = FIO_OPT_C_STAT,
3196 .group = FIO_OPT_G_INVALID,
83349190
YH
3197 },
3198 {
3199 .name = "percentile_list",
e8b0e958 3200 .lname = "Completion latency percentile list",
83349190
YH
3201 .type = FIO_OPT_FLOAT_LIST,
3202 .off1 = td_var_offset(percentile_list),
435d195a 3203 .off2 = td_var_offset(percentile_precision),
83349190 3204 .help = "Specify a custom list of percentiles to report",
fd112d34 3205 .def = "1:5:10:20:30:40:50:60:70:80:90:95:99:99.5:99.9:99.95:99.99",
83349190
YH
3206 .maxlen = FIO_IO_U_LIST_MAX_LEN,
3207 .minfp = 0.0,
3208 .maxfp = 100.0,
e8b0e958
JA
3209 .category = FIO_OPT_C_STAT,
3210 .group = FIO_OPT_G_INVALID,
83349190
YH
3211 },
3212
0a839f30
JA
3213#ifdef FIO_HAVE_DISK_UTIL
3214 {
3215 .name = "disk_util",
e8b0e958 3216 .lname = "Disk utilization",
0a839f30
JA
3217 .type = FIO_OPT_BOOL,
3218 .off1 = td_var_offset(do_disk_util),
f66ab3c8 3219 .help = "Log disk utilization statistics",
0a839f30 3220 .def = "1",
e8b0e958
JA
3221 .category = FIO_OPT_C_STAT,
3222 .group = FIO_OPT_G_INVALID,
0a839f30
JA
3223 },
3224#endif
993bf48b
JA
3225 {
3226 .name = "gtod_reduce",
e8b0e958 3227 .lname = "Reduce gettimeofday() calls",
993bf48b
JA
3228 .type = FIO_OPT_BOOL,
3229 .help = "Greatly reduce number of gettimeofday() calls",
3230 .cb = str_gtod_reduce_cb,
3231 .def = "0",
a4ed77fe 3232 .hide_on_set = 1,
e8b0e958
JA
3233 .category = FIO_OPT_C_STAT,
3234 .group = FIO_OPT_G_INVALID,
993bf48b 3235 },
02af0988
JA
3236 {
3237 .name = "disable_lat",
e8b0e958 3238 .lname = "Disable all latency stats",
02af0988
JA
3239 .type = FIO_OPT_BOOL,
3240 .off1 = td_var_offset(disable_lat),
3241 .help = "Disable latency numbers",
3242 .parent = "gtod_reduce",
d71c154c 3243 .hide = 1,
02af0988 3244 .def = "0",
e8b0e958
JA
3245 .category = FIO_OPT_C_STAT,
3246 .group = FIO_OPT_G_INVALID,
02af0988 3247 },
9520ebb9
JA
3248 {
3249 .name = "disable_clat",
e8b0e958 3250 .lname = "Disable completion latency stats",
9520ebb9
JA
3251 .type = FIO_OPT_BOOL,
3252 .off1 = td_var_offset(disable_clat),
3253 .help = "Disable completion latency numbers",
993bf48b 3254 .parent = "gtod_reduce",
d71c154c 3255 .hide = 1,
9520ebb9 3256 .def = "0",
e8b0e958
JA
3257 .category = FIO_OPT_C_STAT,
3258 .group = FIO_OPT_G_INVALID,
9520ebb9
JA
3259 },
3260 {
3261 .name = "disable_slat",
e8b0e958 3262 .lname = "Disable submission latency stats",
9520ebb9
JA
3263 .type = FIO_OPT_BOOL,
3264 .off1 = td_var_offset(disable_slat),
03e20d68 3265 .help = "Disable submission latency numbers",
993bf48b 3266 .parent = "gtod_reduce",
d71c154c 3267 .hide = 1,
9520ebb9 3268 .def = "0",
e8b0e958
JA
3269 .category = FIO_OPT_C_STAT,
3270 .group = FIO_OPT_G_INVALID,
9520ebb9
JA
3271 },
3272 {
3273 .name = "disable_bw_measurement",
e8b0e958 3274 .lname = "Disable bandwidth stats",
9520ebb9
JA
3275 .type = FIO_OPT_BOOL,
3276 .off1 = td_var_offset(disable_bw),
3277 .help = "Disable bandwidth logging",
993bf48b 3278 .parent = "gtod_reduce",
d71c154c 3279 .hide = 1,
9520ebb9 3280 .def = "0",
e8b0e958
JA
3281 .category = FIO_OPT_C_STAT,
3282 .group = FIO_OPT_G_INVALID,
9520ebb9 3283 },
be4ecfdf
JA
3284 {
3285 .name = "gtod_cpu",
e8b0e958 3286 .lname = "Dedicated gettimeofday() CPU",
be4ecfdf
JA
3287 .type = FIO_OPT_INT,
3288 .cb = str_gtod_cpu_cb,
03e20d68 3289 .help = "Set up dedicated gettimeofday() thread on this CPU",
29d43ff9 3290 .verify = gtod_cpu_verify,
e8b0e958 3291 .category = FIO_OPT_C_GENERAL,
10860056 3292 .group = FIO_OPT_G_CLOCK,
be4ecfdf 3293 },
771e58be
JA
3294 {
3295 .name = "unified_rw_reporting",
3296 .type = FIO_OPT_BOOL,
3297 .off1 = td_var_offset(unified_rw_rep),
3298 .help = "Unify reporting across data direction",
3299 .def = "0",
90b7a96d
JA
3300 .category = FIO_OPT_C_GENERAL,
3301 .group = FIO_OPT_G_INVALID,
771e58be 3302 },
f2bba182
RR
3303 {
3304 .name = "continue_on_error",
e8b0e958 3305 .lname = "Continue on error",
06842027 3306 .type = FIO_OPT_STR,
f2bba182 3307 .off1 = td_var_offset(continue_on_error),
03e20d68 3308 .help = "Continue on non-fatal errors during IO",
06842027 3309 .def = "none",
e8b0e958 3310 .category = FIO_OPT_C_GENERAL,
bc3f552f 3311 .group = FIO_OPT_G_ERR,
06842027
SL
3312 .posval = {
3313 { .ival = "none",
3314 .oval = ERROR_TYPE_NONE,
3315 .help = "Exit when an error is encountered",
3316 },
3317 { .ival = "read",
3318 .oval = ERROR_TYPE_READ,
3319 .help = "Continue on read errors only",
3320 },
3321 { .ival = "write",
3322 .oval = ERROR_TYPE_WRITE,
3323 .help = "Continue on write errors only",
3324 },
3325 { .ival = "io",
3326 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
3327 .help = "Continue on any IO errors",
3328 },
3329 { .ival = "verify",
3330 .oval = ERROR_TYPE_VERIFY,
3331 .help = "Continue on verify errors only",
3332 },
3333 { .ival = "all",
3334 .oval = ERROR_TYPE_ANY,
3335 .help = "Continue on all io and verify errors",
3336 },
3337 { .ival = "0",
3338 .oval = ERROR_TYPE_NONE,
3339 .help = "Alias for 'none'",
3340 },
3341 { .ival = "1",
3342 .oval = ERROR_TYPE_ANY,
3343 .help = "Alias for 'all'",
3344 },
3345 },
f2bba182 3346 },
8b28bd41
DM
3347 {
3348 .name = "ignore_error",
3349 .type = FIO_OPT_STR,
3350 .cb = str_ignore_error_cb,
3351 .help = "Set a specific list of errors to ignore",
3352 .parent = "rw",
a94eb99a 3353 .category = FIO_OPT_C_GENERAL,
bc3f552f 3354 .group = FIO_OPT_G_ERR,
8b28bd41
DM
3355 },
3356 {
3357 .name = "error_dump",
3358 .type = FIO_OPT_BOOL,
3359 .off1 = td_var_offset(error_dump),
3360 .def = "0",
3361 .help = "Dump info on each error",
a94eb99a 3362 .category = FIO_OPT_C_GENERAL,
bc3f552f 3363 .group = FIO_OPT_G_ERR,
8b28bd41 3364 },
9ac8a797
JA
3365 {
3366 .name = "profile",
e8b0e958 3367 .lname = "Profile",
79d16311 3368 .type = FIO_OPT_STR_STORE,
9ac8a797 3369 .off1 = td_var_offset(profile),
9ac8a797 3370 .help = "Select a specific builtin performance test",
13fca827 3371 .category = FIO_OPT_C_PROFILE,
e8b0e958 3372 .group = FIO_OPT_G_INVALID,
9ac8a797 3373 },
a696fa2a
JA
3374 {
3375 .name = "cgroup",
e8b0e958 3376 .lname = "Cgroup",
a696fa2a
JA
3377 .type = FIO_OPT_STR_STORE,
3378 .off1 = td_var_offset(cgroup),
3379 .help = "Add job to cgroup of this name",
e8b0e958 3380 .category = FIO_OPT_C_GENERAL,
a1f6afec
JA
3381 .group = FIO_OPT_G_CGROUP,
3382 },
3383 {
3384 .name = "cgroup_nodelete",
3385 .lname = "Cgroup no-delete",
3386 .type = FIO_OPT_BOOL,
3387 .off1 = td_var_offset(cgroup_nodelete),
3388 .help = "Do not delete cgroups after job completion",
3389 .def = "0",
3390 .parent = "cgroup",
3391 .category = FIO_OPT_C_GENERAL,
3392 .group = FIO_OPT_G_CGROUP,
a696fa2a
JA
3393 },
3394 {
3395 .name = "cgroup_weight",
e8b0e958 3396 .lname = "Cgroup weight",
a696fa2a
JA
3397 .type = FIO_OPT_INT,
3398 .off1 = td_var_offset(cgroup_weight),
3399 .help = "Use given weight for cgroup",
3400 .minval = 100,
3401 .maxval = 1000,
a1f6afec 3402 .parent = "cgroup",
e8b0e958 3403 .category = FIO_OPT_C_GENERAL,
a1f6afec 3404 .group = FIO_OPT_G_CGROUP,
7de87099 3405 },
e0b0d892
JA
3406 {
3407 .name = "uid",
e8b0e958 3408 .lname = "User ID",
e0b0d892
JA
3409 .type = FIO_OPT_INT,
3410 .off1 = td_var_offset(uid),
3411 .help = "Run job with this user ID",
e8b0e958 3412 .category = FIO_OPT_C_GENERAL,
10860056 3413 .group = FIO_OPT_G_CRED,
e0b0d892
JA
3414 },
3415 {
3416 .name = "gid",
e8b0e958 3417 .lname = "Group ID",
e0b0d892
JA
3418 .type = FIO_OPT_INT,
3419 .off1 = td_var_offset(gid),
3420 .help = "Run job with this group ID",
e8b0e958 3421 .category = FIO_OPT_C_GENERAL,
10860056 3422 .group = FIO_OPT_G_CRED,
e0b0d892 3423 },
a1f6afec
JA
3424 {
3425 .name = "kb_base",
3426 .lname = "KB Base",
3427 .type = FIO_OPT_INT,
3428 .off1 = td_var_offset(kb_base),
a1f6afec
JA
3429 .prio = 1,
3430 .def = "1024",
ba9c7219
JA
3431 .posval = {
3432 { .ival = "1024",
3433 .oval = 1024,
3434 .help = "Use 1024 as the K base",
3435 },
3436 { .ival = "1000",
3437 .oval = 1000,
3438 .help = "Use 1000 as the K base",
3439 },
3440 },
a1f6afec
JA
3441 .help = "How many bytes per KB for reporting (1000 or 1024)",
3442 .category = FIO_OPT_C_GENERAL,
3443 .group = FIO_OPT_G_INVALID,
3444 },
cf3a0518
JA
3445 {
3446 .name = "unit_base",
ba9c7219 3447 .lname = "Base unit for reporting (Bits or Bytes)",
cf3a0518
JA
3448 .type = FIO_OPT_INT,
3449 .off1 = td_var_offset(unit_base),
cf3a0518 3450 .prio = 1,
71a08258
JA
3451 .posval = {
3452 { .ival = "0",
3453 .oval = 0,
3454 .help = "Auto-detect",
3455 },
3456 { .ival = "8",
3457 .oval = 8,
3458 .help = "Normal (byte based)",
3459 },
3460 { .ival = "1",
3461 .oval = 1,
3462 .help = "Bit based",
3463 },
3464 },
cf3a0518
JA
3465 .help = "Bit multiple of result summary data (8 for byte, 1 for bit)",
3466 .category = FIO_OPT_C_GENERAL,
3467 .group = FIO_OPT_G_INVALID,
3468 },
3ceb458f
JA
3469 {
3470 .name = "hugepage-size",
3471 .lname = "Hugepage size",
3472 .type = FIO_OPT_INT,
3473 .off1 = td_var_offset(hugepage_size),
3474 .help = "When using hugepages, specify size of each page",
3475 .def = __fio_stringify(FIO_HUGE_PAGE),
3476 .interval = 1024 * 1024,
3477 .category = FIO_OPT_C_GENERAL,
3478 .group = FIO_OPT_G_INVALID,
3479 },
9e684a49
DE
3480 {
3481 .name = "flow_id",
e8b0e958 3482 .lname = "I/O flow ID",
9e684a49
DE
3483 .type = FIO_OPT_INT,
3484 .off1 = td_var_offset(flow_id),
3485 .help = "The flow index ID to use",
3486 .def = "0",
e8b0e958
JA
3487 .category = FIO_OPT_C_IO,
3488 .group = FIO_OPT_G_IO_FLOW,
9e684a49
DE
3489 },
3490 {
3491 .name = "flow",
e8b0e958 3492 .lname = "I/O flow weight",
9e684a49
DE
3493 .type = FIO_OPT_INT,
3494 .off1 = td_var_offset(flow),
3495 .help = "Weight for flow control of this job",
3496 .parent = "flow_id",
d71c154c 3497 .hide = 1,
9e684a49 3498 .def = "0",
e8b0e958
JA
3499 .category = FIO_OPT_C_IO,
3500 .group = FIO_OPT_G_IO_FLOW,
9e684a49
DE
3501 },
3502 {
3503 .name = "flow_watermark",
e8b0e958 3504 .lname = "I/O flow watermark",
9e684a49
DE
3505 .type = FIO_OPT_INT,
3506 .off1 = td_var_offset(flow_watermark),
3507 .help = "High watermark for flow control. This option"
3508 " should be set to the same value for all threads"
3509 " with non-zero flow.",
3510 .parent = "flow_id",
d71c154c 3511 .hide = 1,
9e684a49 3512 .def = "1024",
e8b0e958
JA
3513 .category = FIO_OPT_C_IO,
3514 .group = FIO_OPT_G_IO_FLOW,
9e684a49
DE
3515 },
3516 {
3517 .name = "flow_sleep",
e8b0e958 3518 .lname = "I/O flow sleep",
9e684a49
DE
3519 .type = FIO_OPT_INT,
3520 .off1 = td_var_offset(flow_sleep),
3521 .help = "How many microseconds to sleep after being held"
3522 " back by the flow control mechanism",
3523 .parent = "flow_id",
d71c154c 3524 .hide = 1,
9e684a49 3525 .def = "0",
e8b0e958
JA
3526 .category = FIO_OPT_C_IO,
3527 .group = FIO_OPT_G_IO_FLOW,
9e684a49 3528 },
214e1eca
JA
3529 {
3530 .name = NULL,
3531 },
3532};
3533
17af15d4 3534static void add_to_lopt(struct option *lopt, struct fio_option *o,
de890a1e 3535 const char *name, int val)
9f81736c 3536{
17af15d4 3537 lopt->name = (char *) name;
de890a1e 3538 lopt->val = val;
9f81736c 3539 if (o->type == FIO_OPT_STR_SET)
ff52be3d 3540 lopt->has_arg = optional_argument;
9f81736c
JA
3541 else
3542 lopt->has_arg = required_argument;
3543}
3544
de890a1e
SL
3545static void options_to_lopts(struct fio_option *opts,
3546 struct option *long_options,
3547 int i, int option_type)
214e1eca 3548{
de890a1e 3549 struct fio_option *o = &opts[0];
214e1eca 3550 while (o->name) {
de890a1e 3551 add_to_lopt(&long_options[i], o, o->name, option_type);
17af15d4
JA
3552 if (o->alias) {
3553 i++;
de890a1e 3554 add_to_lopt(&long_options[i], o, o->alias, option_type);
17af15d4 3555 }
214e1eca
JA
3556
3557 i++;
3558 o++;
3559 assert(i < FIO_NR_OPTIONS);
3560 }
3561}
3562
de890a1e
SL
3563void fio_options_set_ioengine_opts(struct option *long_options,
3564 struct thread_data *td)
3565{
3566 unsigned int i;
3567
3568 i = 0;
3569 while (long_options[i].name) {
3570 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
3571 memset(&long_options[i], 0, sizeof(*long_options));
3572 break;
3573 }
3574 i++;
3575 }
3576
3577 /*
3578 * Just clear out the prior ioengine options.
3579 */
3580 if (!td || !td->eo)
3581 return;
3582
3583 options_to_lopts(td->io_ops->options, long_options, i,
3584 FIO_GETOPT_IOENGINE);
3585}
3586
3587void fio_options_dup_and_init(struct option *long_options)
3588{
3589 unsigned int i;
3590
9af4a244 3591 options_init(fio_options);
de890a1e
SL
3592
3593 i = 0;
3594 while (long_options[i].name)
3595 i++;
3596
9af4a244 3597 options_to_lopts(fio_options, long_options, i, FIO_GETOPT_JOB);
de890a1e
SL
3598}
3599
74929ac2
JA
3600struct fio_keyword {
3601 const char *word;
3602 const char *desc;
3603 char *replace;
3604};
3605
3606static struct fio_keyword fio_keywords[] = {
3607 {
3608 .word = "$pagesize",
3609 .desc = "Page size in the system",
3610 },
3611 {
3612 .word = "$mb_memory",
3613 .desc = "Megabytes of memory online",
3614 },
3615 {
3616 .word = "$ncpus",
3617 .desc = "Number of CPUs online in the system",
3618 },
3619 {
3620 .word = NULL,
3621 },
3622};
3623
3624void fio_keywords_init(void)
3625{
3b2e1464 3626 unsigned long long mb_memory;
74929ac2
JA
3627 char buf[128];
3628 long l;
3629
a4cfc477 3630 sprintf(buf, "%lu", (unsigned long) page_size);
74929ac2
JA
3631 fio_keywords[0].replace = strdup(buf);
3632
8eb016d3 3633 mb_memory = os_phys_mem() / (1024 * 1024);
3b2e1464 3634 sprintf(buf, "%llu", mb_memory);
74929ac2
JA
3635 fio_keywords[1].replace = strdup(buf);
3636
c00a2289 3637 l = cpus_online();
74929ac2
JA
3638 sprintf(buf, "%lu", l);
3639 fio_keywords[2].replace = strdup(buf);
3640}
3641
892a6ffc
JA
3642#define BC_APP "bc"
3643
3644static char *bc_calc(char *str)
3645{
d0c814ec 3646 char buf[128], *tmp;
892a6ffc
JA
3647 FILE *f;
3648 int ret;
3649
3650 /*
3651 * No math, just return string
3652 */
d0c814ec
SL
3653 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
3654 !strchr(str, '/')) || strchr(str, '\''))
892a6ffc
JA
3655 return str;
3656
3657 /*
3658 * Split option from value, we only need to calculate the value
3659 */
3660 tmp = strchr(str, '=');
3661 if (!tmp)
3662 return str;
3663
3664 tmp++;
892a6ffc 3665
d0c814ec
SL
3666 /*
3667 * Prevent buffer overflows; such a case isn't reasonable anyway
3668 */
3669 if (strlen(str) >= 128 || strlen(tmp) > 100)
3670 return str;
892a6ffc
JA
3671
3672 sprintf(buf, "which %s > /dev/null", BC_APP);
3673 if (system(buf)) {
3674 log_err("fio: bc is needed for performing math\n");
892a6ffc
JA
3675 return NULL;
3676 }
3677
d0c814ec 3678 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
892a6ffc 3679 f = popen(buf, "r");
3c3ed070 3680 if (!f)
892a6ffc 3681 return NULL;
892a6ffc 3682
d0c814ec 3683 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
1d824f37
JA
3684 if (ret <= 0) {
3685 pclose(f);
892a6ffc 3686 return NULL;
1d824f37 3687 }
892a6ffc 3688
892a6ffc 3689 pclose(f);
d0c814ec
SL
3690 buf[(tmp - str) + ret - 1] = '\0';
3691 memcpy(buf, str, tmp - str);
892a6ffc 3692 free(str);
d0c814ec
SL
3693 return strdup(buf);
3694}
3695
3696/*
3697 * Return a copy of the input string with substrings of the form ${VARNAME}
3698 * substituted with the value of the environment variable VARNAME. The
3699 * substitution always occurs, even if VARNAME is empty or the corresponding
3700 * environment variable undefined.
3701 */
3702static char *option_dup_subs(const char *opt)
3703{
3704 char out[OPT_LEN_MAX+1];
3705 char in[OPT_LEN_MAX+1];
3706 char *outptr = out;
3707 char *inptr = in;
3708 char *ch1, *ch2, *env;
3709 ssize_t nchr = OPT_LEN_MAX;
3710 size_t envlen;
3711
3712 if (strlen(opt) + 1 > OPT_LEN_MAX) {
3713 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
3714 return NULL;
3715 }
3716
3717 in[OPT_LEN_MAX] = '\0';
3718 strncpy(in, opt, OPT_LEN_MAX);
3719
3720 while (*inptr && nchr > 0) {
3721 if (inptr[0] == '$' && inptr[1] == '{') {
3722 ch2 = strchr(inptr, '}');
3723 if (ch2 && inptr+1 < ch2) {
3724 ch1 = inptr+2;
3725 inptr = ch2+1;
3726 *ch2 = '\0';
3727
3728 env = getenv(ch1);
3729 if (env) {
3730 envlen = strlen(env);
3731 if (envlen <= nchr) {
3732 memcpy(outptr, env, envlen);
3733 outptr += envlen;
3734 nchr -= envlen;
3735 }
3736 }
3737
3738 continue;
3739 }
3740 }
3741
3742 *outptr++ = *inptr++;
3743 --nchr;
3744 }
3745
3746 *outptr = '\0';
3747 return strdup(out);
892a6ffc
JA
3748}
3749
74929ac2
JA
3750/*
3751 * Look for reserved variable names and replace them with real values
3752 */
3753static char *fio_keyword_replace(char *opt)
3754{
3755 char *s;
3756 int i;
d0c814ec 3757 int docalc = 0;
74929ac2
JA
3758
3759 for (i = 0; fio_keywords[i].word != NULL; i++) {
3760 struct fio_keyword *kw = &fio_keywords[i];
3761
3762 while ((s = strstr(opt, kw->word)) != NULL) {
3763 char *new = malloc(strlen(opt) + 1);
3764 char *o_org = opt;
3765 int olen = s - opt;
3766 int len;
3767
3768 /*
3769 * Copy part of the string before the keyword and
3770 * sprintf() the replacement after it.
3771 */
3772 memcpy(new, opt, olen);
3773 len = sprintf(new + olen, "%s", kw->replace);
3774
3775 /*
3776 * If there's more in the original string, copy that
3777 * in too
3778 */
3779 opt += strlen(kw->word) + olen;
3780 if (strlen(opt))
3781 memcpy(new + olen + len, opt, opt - o_org - 1);
3782
3783 /*
3784 * replace opt and free the old opt
3785 */
3786 opt = new;
d0c814ec 3787 free(o_org);
7a958bd5 3788
d0c814ec 3789 docalc = 1;
74929ac2
JA
3790 }
3791 }
3792
d0c814ec
SL
3793 /*
3794 * Check for potential math and invoke bc, if possible
3795 */
3796 if (docalc)
3797 opt = bc_calc(opt);
3798
7a958bd5 3799 return opt;
74929ac2
JA
3800}
3801
d0c814ec
SL
3802static char **dup_and_sub_options(char **opts, int num_opts)
3803{
3804 int i;
3805 char **opts_copy = malloc(num_opts * sizeof(*opts));
3806 for (i = 0; i < num_opts; i++) {
3807 opts_copy[i] = option_dup_subs(opts[i]);
3808 if (!opts_copy[i])
3809 continue;
3810 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
3811 }
3812 return opts_copy;
3813}
3814
292cc475
JA
3815int fio_options_parse(struct thread_data *td, char **opts, int num_opts,
3816 int dump_cmdline)
214e1eca 3817{
de890a1e 3818 int i, ret, unknown;
d0c814ec 3819 char **opts_copy;
3b8b7135 3820
9af4a244 3821 sort_options(opts, fio_options, num_opts);
d0c814ec 3822 opts_copy = dup_and_sub_options(opts, num_opts);
3b8b7135 3823
de890a1e
SL
3824 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
3825 struct fio_option *o;
9af4a244 3826 int newret = parse_option(opts_copy[i], opts[i], fio_options,
292cc475 3827 &o, td, dump_cmdline);
d0c814ec 3828
de890a1e
SL
3829 if (opts_copy[i]) {
3830 if (newret && !o) {
3831 unknown++;
3832 continue;
3833 }
d0c814ec 3834 free(opts_copy[i]);
de890a1e
SL
3835 opts_copy[i] = NULL;
3836 }
3837
3838 ret |= newret;
3839 }
3840
3841 if (unknown) {
3842 ret |= ioengine_load(td);
3843 if (td->eo) {
3844 sort_options(opts_copy, td->io_ops->options, num_opts);
3845 opts = opts_copy;
3846 }
3847 for (i = 0; i < num_opts; i++) {
3848 struct fio_option *o = NULL;
3849 int newret = 1;
3850 if (!opts_copy[i])
3851 continue;
3852
3853 if (td->eo)
3854 newret = parse_option(opts_copy[i], opts[i],
3855 td->io_ops->options, &o,
292cc475 3856 td->eo, dump_cmdline);
de890a1e
SL
3857
3858 ret |= newret;
3859 if (!o)
3860 log_err("Bad option <%s>\n", opts[i]);
3861
3862 free(opts_copy[i]);
3863 opts_copy[i] = NULL;
3864 }
74929ac2 3865 }
3b8b7135 3866
d0c814ec 3867 free(opts_copy);
3b8b7135 3868 return ret;
214e1eca
JA
3869}
3870
3871int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
3872{
9af4a244 3873 return parse_cmd_option(opt, val, fio_options, td);
214e1eca
JA
3874}
3875
de890a1e
SL
3876int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
3877 char *val)
3878{
8a96c80e 3879 return parse_cmd_option(opt, val, td->io_ops->options, td->eo);
de890a1e
SL
3880}
3881
214e1eca
JA
3882void fio_fill_default_options(struct thread_data *td)
3883{
cb1402d6 3884 td->o.magic = OPT_MAGIC;
9af4a244 3885 fill_default_options(td, fio_options);
214e1eca
JA
3886}
3887
3888int fio_show_option_help(const char *opt)
3889{
9af4a244 3890 return show_cmd_help(fio_options, opt);
214e1eca 3891}
d23bb327 3892
de890a1e 3893void options_mem_dupe(void *data, struct fio_option *options)
d23bb327 3894{
de890a1e 3895 struct fio_option *o;
d23bb327 3896 char **ptr;
d23bb327 3897
de890a1e
SL
3898 for (o = &options[0]; o->name; o++) {
3899 if (o->type != FIO_OPT_STR_STORE)
d23bb327
JA
3900 continue;
3901
f0fdbcaf 3902 ptr = td_var(data, o, o->off1);
7e356b2d
JA
3903 if (*ptr)
3904 *ptr = strdup(*ptr);
d23bb327
JA
3905 }
3906}
3907
de890a1e
SL
3908/*
3909 * dupe FIO_OPT_STR_STORE options
3910 */
3911void fio_options_mem_dupe(struct thread_data *td)
3912{
9af4a244 3913 options_mem_dupe(&td->o, fio_options);
1647f592
JA
3914
3915 if (td->eo && td->io_ops) {
de890a1e 3916 void *oldeo = td->eo;
1647f592 3917
de890a1e
SL
3918 td->eo = malloc(td->io_ops->option_struct_size);
3919 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
3920 options_mem_dupe(td->eo, td->io_ops->options);
3921 }
3922}
3923
d6978a32
JA
3924unsigned int fio_get_kb_base(void *data)
3925{
83ea422a 3926 struct thread_options *o = data;
d6978a32
JA
3927 unsigned int kb_base = 0;
3928
cb1402d6
JA
3929 /*
3930 * This is a hack... For private options, *data is not holding
3931 * a pointer to the thread_options, but to private data. This means
3932 * we can't safely dereference it, but magic is first so mem wise
3933 * it is valid. But this also means that if the job first sets
3934 * kb_base and expects that to be honored by private options,
3935 * it will be disappointed. We will return the global default
3936 * for this.
3937 */
3938 if (o && o->magic == OPT_MAGIC)
83ea422a 3939 kb_base = o->kb_base;
d6978a32
JA
3940 if (!kb_base)
3941 kb_base = 1024;
3942
3943 return kb_base;
3944}
9f988e2e 3945
07b3232d 3946int add_option(struct fio_option *o)
9f988e2e 3947{
07b3232d
JA
3948 struct fio_option *__o;
3949 int opt_index = 0;
3950
9af4a244 3951 __o = fio_options;
07b3232d
JA
3952 while (__o->name) {
3953 opt_index++;
3954 __o++;
3955 }
3956
7b504edd
JA
3957 if (opt_index + 1 == FIO_MAX_OPTS) {
3958 log_err("fio: FIO_MAX_OPTS is too small\n");
3959 return 1;
3960 }
3961
9af4a244 3962 memcpy(&fio_options[opt_index], o, sizeof(*o));
7b504edd 3963 fio_options[opt_index + 1].name = NULL;
07b3232d 3964 return 0;
9f988e2e 3965}
e2de69da 3966
07b3232d 3967void invalidate_profile_options(const char *prof_name)
e2de69da 3968{
07b3232d 3969 struct fio_option *o;
e2de69da 3970
9af4a244 3971 o = fio_options;
07b3232d
JA
3972 while (o->name) {
3973 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
3974 o->type = FIO_OPT_INVALID;
3975 o->prof_name = NULL;
3976 }
3977 o++;
e2de69da
JA
3978 }
3979}
f5b6bb85
JA
3980
3981void add_opt_posval(const char *optname, const char *ival, const char *help)
3982{
3983 struct fio_option *o;
3984 unsigned int i;
3985
9af4a244 3986 o = find_option(fio_options, optname);
f5b6bb85
JA
3987 if (!o)
3988 return;
3989
3990 for (i = 0; i < PARSE_MAX_VP; i++) {
3991 if (o->posval[i].ival)
3992 continue;
3993
3994 o->posval[i].ival = ival;
3995 o->posval[i].help = help;
3996 break;
3997 }
3998}
3999
4000void del_opt_posval(const char *optname, const char *ival)
4001{
4002 struct fio_option *o;
4003 unsigned int i;
4004
9af4a244 4005 o = find_option(fio_options, optname);
f5b6bb85
JA
4006 if (!o)
4007 return;
4008
4009 for (i = 0; i < PARSE_MAX_VP; i++) {
4010 if (!o->posval[i].ival)
4011 continue;
4012 if (strcmp(o->posval[i].ival, ival))
4013 continue;
4014
4015 o->posval[i].ival = NULL;
4016 o->posval[i].help = NULL;
4017 }
4018}
7e356b2d
JA
4019
4020void fio_options_free(struct thread_data *td)
4021{
9af4a244 4022 options_free(fio_options, td);
de890a1e
SL
4023 if (td->eo && td->io_ops && td->io_ops->options) {
4024 options_free(td->io_ops->options, td->eo);
4025 free(td->eo);
4026 td->eo = NULL;
4027 }
7e356b2d 4028}
c504ee55
JA
4029
4030struct fio_option *fio_option_find(const char *name)
4031{
4032 return find_option(fio_options, name);
4033}
4034