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