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