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