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