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