Calloc() cleanup
[fio.git] / options.c
<
CommitLineData
214e1eca
JA
1#include <stdio.h>
2#include <stdlib.h>
3#include <unistd.h>
4#include <ctype.h>
5#include <string.h>
214e1eca 6#include <assert.h>
921c766f 7#include <libgen.h>
5921e80c
JA
8#include <fcntl.h>
9#include <sys/types.h>
10#include <sys/stat.h>
214e1eca
JA
11
12#include "fio.h"
4f5af7b2 13#include "verify.h"
214e1eca 14#include "parse.h"
eef32359 15#include "lib/fls.h"
9f988e2e 16#include "options.h"
214e1eca 17
5d7c5d34
JA
18#include "crc/crc32c.h"
19
214e1eca
JA
20/*
21 * Check if mmap/mmaphuge has a :/foo/bar/file at the end. If so, return that.
22 */
23static char *get_opt_postfix(const char *str)
24{
25 char *p = strstr(str, ":");
26
27 if (!p)
28 return NULL;
29
30 p++;
31 strip_blank_front(&p);
32 strip_blank_end(p);
33 return strdup(p);
34}
35
0e92f873
RR
36static int converthexchartoint(char a)
37{
38 int base;
39
3c3ed070 40 switch (a) {
0e92f873
RR
41 case '0'...'9':
42 base = '0';
43 break;
44 case 'A'...'F':
45 base = 'A' - 10;
46 break;
47 case 'a'...'f':
48 base = 'a' - 10;
49 break;
50 default:
51 base = 0;
52 }
3c3ed070 53 return a - base;
0e92f873
RR
54}
55
564ca972
JA
56static int bs_cmp(const void *p1, const void *p2)
57{
58 const struct bssplit *bsp1 = p1;
59 const struct bssplit *bsp2 = p2;
60
61 return bsp1->perc < bsp2->perc;
62}
63
83ea422a 64static int bssplit_ddir(struct thread_options *o, int ddir, char *str)
564ca972 65{
720e84ad 66 struct bssplit *bssplit;
564ca972
JA
67 unsigned int i, perc, perc_missing;
68 unsigned int max_bs, min_bs;
69 long long val;
720e84ad 70 char *fname;
564ca972 71
83ea422a 72 o->bssplit_nr[ddir] = 4;
720e84ad 73 bssplit = malloc(4 * sizeof(struct bssplit));
564ca972
JA
74
75 i = 0;
76 max_bs = 0;
77 min_bs = -1;
78 while ((fname = strsep(&str, ":")) != NULL) {
79 char *perc_str;
80
81 if (!strlen(fname))
82 break;
83
84 /*
85 * grow struct buffer, if needed
86 */
83ea422a
JA
87 if (i == o->bssplit_nr[ddir]) {
88 o->bssplit_nr[ddir] <<= 1;
89 bssplit = realloc(bssplit, o->bssplit_nr[ddir]
5ec10eaa 90 * sizeof(struct bssplit));
564ca972
JA
91 }
92
93 perc_str = strstr(fname, "/");
94 if (perc_str) {
95 *perc_str = '\0';
96 perc_str++;
97 perc = atoi(perc_str);
98 if (perc > 100)
99 perc = 100;
100 else if (!perc)
101 perc = -1;
102 } else
103 perc = -1;
104
83ea422a 105 if (str_to_decimal(fname, &val, 1, o)) {
564ca972 106 log_err("fio: bssplit conversion failed\n");
d8b97c8e 107 free(bssplit);
564ca972
JA
108 return 1;
109 }
110
111 if (val > max_bs)
112 max_bs = val;
113 if (val < min_bs)
114 min_bs = val;
115
720e84ad
JA
116 bssplit[i].bs = val;
117 bssplit[i].perc = perc;
564ca972
JA
118 i++;
119 }
120
83ea422a 121 o->bssplit_nr[ddir] = i;
564ca972
JA
122
123 /*
124 * Now check if the percentages add up, and how much is missing
125 */
126 perc = perc_missing = 0;
83ea422a 127 for (i = 0; i < o->bssplit_nr[ddir]; i++) {
720e84ad 128 struct bssplit *bsp = &bssplit[i];
564ca972
JA
129
130 if (bsp->perc == (unsigned char) -1)
131 perc_missing++;
132 else
133 perc += bsp->perc;
134 }
135
136 if (perc > 100) {
137 log_err("fio: bssplit percentages add to more than 100%%\n");
720e84ad 138 free(bssplit);
564ca972
JA
139 return 1;
140 }
141 /*
142 * If values didn't have a percentage set, divide the remains between
143 * them.
144 */
145 if (perc_missing) {
83ea422a 146 for (i = 0; i < o->bssplit_nr[ddir]; i++) {
720e84ad 147 struct bssplit *bsp = &bssplit[i];
564ca972
JA
148
149 if (bsp->perc == (unsigned char) -1)
150 bsp->perc = (100 - perc) / perc_missing;
151 }
152 }
153
83ea422a
JA
154 o->min_bs[ddir] = min_bs;
155 o->max_bs[ddir] = max_bs;
564ca972
JA
156
157 /*
158 * now sort based on percentages, for ease of lookup
159 */
83ea422a
JA
160 qsort(bssplit, o->bssplit_nr[ddir], sizeof(struct bssplit), bs_cmp);
161 o->bssplit[ddir] = bssplit;
720e84ad 162 return 0;
720e84ad
JA
163}
164
165static int str_bssplit_cb(void *data, const char *input)
166{
167 struct thread_data *td = data;
6eaf09d6 168 char *str, *p, *odir, *ddir;
720e84ad
JA
169 int ret = 0;
170
52c0cea3
JA
171 if (parse_dryrun())
172 return 0;
173
720e84ad
JA
174 p = str = strdup(input);
175
176 strip_blank_front(&str);
177 strip_blank_end(str);
178
179 odir = strchr(str, ',');
180 if (odir) {
6eaf09d6
SL
181 ddir = strchr(odir + 1, ',');
182 if (ddir) {
d79db122 183 ret = bssplit_ddir(&td->o, DDIR_TRIM, ddir + 1);
6eaf09d6
SL
184 if (!ret)
185 *ddir = '\0';
186 } else {
187 char *op;
188
189 op = strdup(odir + 1);
d79db122 190 ret = bssplit_ddir(&td->o, DDIR_TRIM, op);
6eaf09d6
SL
191
192 free(op);
193 }
d79db122
JA
194 if (!ret)
195 ret = bssplit_ddir(&td->o, DDIR_WRITE, odir + 1);
720e84ad
JA
196 if (!ret) {
197 *odir = '\0';
83ea422a 198 ret = bssplit_ddir(&td->o, DDIR_READ, str);
720e84ad
JA
199 }
200 } else {
201 char *op;
202
203 op = strdup(str);
d79db122 204 ret = bssplit_ddir(&td->o, DDIR_WRITE, op);
6eaf09d6 205 free(op);
720e84ad 206
6eaf09d6
SL
207 if (!ret) {
208 op = strdup(str);
d79db122 209 ret = bssplit_ddir(&td->o, DDIR_TRIM, op);
6eaf09d6
SL
210 free(op);
211 }
83ea422a 212 ret = bssplit_ddir(&td->o, DDIR_READ, str);
720e84ad 213 }
564ca972
JA
214
215 free(p);
720e84ad 216 return ret;
564ca972
JA
217}
218
8b28bd41
DM
219static int str2error(char *str)
220{
a94eb99a 221 const char *err[] = { "EPERM", "ENOENT", "ESRCH", "EINTR", "EIO",
8b28bd41
DM
222 "ENXIO", "E2BIG", "ENOEXEC", "EBADF",
223 "ECHILD", "EAGAIN", "ENOMEM", "EACCES",
224 "EFAULT", "ENOTBLK", "EBUSY", "EEXIST",
225 "EXDEV", "ENODEV", "ENOTDIR", "EISDIR",
226 "EINVAL", "ENFILE", "EMFILE", "ENOTTY",
227 "ETXTBSY","EFBIG", "ENOSPC", "ESPIPE",
a94eb99a 228 "EROFS","EMLINK", "EPIPE", "EDOM", "ERANGE" };
8b28bd41
DM
229 int i = 0, num = sizeof(err) / sizeof(void *);
230
a94eb99a 231 while (i < num) {
8b28bd41
DM
232 if (!strcmp(err[i], str))
233 return i + 1;
234 i++;
235 }
236 return 0;
237}
238
239static int ignore_error_type(struct thread_data *td, int etype, char *str)
240{
241 unsigned int i;
242 int *error;
243 char *fname;
244
245 if (etype >= ERROR_TYPE_CNT) {
246 log_err("Illegal error type\n");
247 return 1;
248 }
249
250 td->o.ignore_error_nr[etype] = 4;
251 error = malloc(4 * sizeof(struct bssplit));
252
253 i = 0;
254 while ((fname = strsep(&str, ":")) != NULL) {
255
256 if (!strlen(fname))
257 break;
258
259 /*
260 * grow struct buffer, if needed
261 */
262 if (i == td->o.ignore_error_nr[etype]) {
263 td->o.ignore_error_nr[etype] <<= 1;
264 error = realloc(error, td->o.ignore_error_nr[etype]
265 * sizeof(int));
266 }
267 if (fname[0] == 'E') {
268 error[i] = str2error(fname);
269 } else {
270 error[i] = atoi(fname);
271 if (error[i] < 0)
272 error[i] = error[i];
273 }
274 if (!error[i]) {
275 log_err("Unknown error %s, please use number value \n",
276 fname);
0fddbf7a 277 free(error);
8b28bd41
DM
278 return 1;
279 }
280 i++;
281 }
282 if (i) {
283 td->o.continue_on_error |= 1 << etype;
284 td->o.ignore_error_nr[etype] = i;
285 td->o.ignore_error[etype] = error;
286 }
287 return 0;
288
289}
290
291static int str_ignore_error_cb(void *data, const char *input)
292{
293 struct thread_data *td = data;
294 char *str, *p, *n;
295 int type = 0, ret = 1;
52c0cea3
JA
296
297 if (parse_dryrun())
298 return 0;
299
8b28bd41
DM
300 p = str = strdup(input);
301
302 strip_blank_front(&str);
303 strip_blank_end(str);
304
305 while (p) {
306 n = strchr(p, ',');
307 if (n)
308 *n++ = '\0';
309 ret = ignore_error_type(td, type, p);
310 if (ret)
311 break;
312 p = n;
313 type++;
314 }
315 free(str);
316 return ret;
317}
318
211097b2
JA
319static int str_rw_cb(void *data, const char *str)
320{
321 struct thread_data *td = data;
83ea422a 322 struct thread_options *o = &td->o;
211097b2
JA
323 char *nr = get_opt_postfix(str);
324
52c0cea3
JA
325 if (parse_dryrun())
326 return 0;
327
83ea422a
JA
328 o->ddir_seq_nr = 1;
329 o->ddir_seq_add = 0;
059b0802
JA
330
331 if (!nr)
332 return 0;
333
334 if (td_random(td))
83ea422a 335 o->ddir_seq_nr = atoi(nr);
059b0802
JA
336 else {
337 long long val;
338
83ea422a 339 if (str_to_decimal(nr, &val, 1, o)) {
059b0802
JA
340 log_err("fio: rw postfix parsing failed\n");
341 free(nr);
342 return 1;
343 }
344
83ea422a 345 o->ddir_seq_add = val;
182ec6ee 346 }
211097b2 347
059b0802 348 free(nr);
211097b2
JA
349 return 0;
350}
351
214e1eca
JA
352static int str_mem_cb(void *data, const char *mem)
353{
354 struct thread_data *td = data;
355
d9759b1e 356 if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP)
836fcc0f 357 td->o.mmapfile = get_opt_postfix(mem);
214e1eca
JA
358
359 return 0;
360}
361
c223da83
JA
362static int fio_clock_source_cb(void *data, const char *str)
363{
364 struct thread_data *td = data;
365
366 fio_clock_source = td->o.clocksource;
fa80feae 367 fio_clock_source_set = 1;
01423eae 368 fio_clock_init();
c223da83
JA
369 return 0;
370}
371
85bc833b 372static int str_rwmix_read_cb(void *data, unsigned long long *val)
cb499fc4
JA
373{
374 struct thread_data *td = data;
375
376 td->o.rwmix[DDIR_READ] = *val;
377 td->o.rwmix[DDIR_WRITE] = 100 - *val;
378 return 0;
379}
380
85bc833b 381static int str_rwmix_write_cb(void *data, unsigned long long *val)
cb499fc4
JA
382{
383 struct thread_data *td = data;
384
385 td->o.rwmix[DDIR_WRITE] = *val;
386 td->o.rwmix[DDIR_READ] = 100 - *val;
387 return 0;
388}
389
214e1eca
JA
390static int str_exitall_cb(void)
391{
392 exitall_on_terminate = 1;
393 return 0;
394}
395
214e1eca 396#ifdef FIO_HAVE_CPU_AFFINITY
85bc833b 397static int str_cpumask_cb(void *data, unsigned long long *val)
d2e268b0
JA
398{
399 struct thread_data *td = data;
214e1eca 400 unsigned int i;
b03daafb 401 long max_cpu;
d2ce18b5
JA
402 int ret;
403
52c0cea3
JA
404 if (parse_dryrun())
405 return 0;
406
d2ce18b5
JA
407 ret = fio_cpuset_init(&td->o.cpumask);
408 if (ret < 0) {
409 log_err("fio: cpuset_init failed\n");
410 td_verror(td, ret, "fio_cpuset_init");
411 return 1;
412 }
214e1eca 413
c00a2289 414 max_cpu = cpus_online();
214e1eca 415
62a7273d
JA
416 for (i = 0; i < sizeof(int) * 8; i++) {
417 if ((1 << i) & *val) {
b03daafb
JA
418 if (i > max_cpu) {
419 log_err("fio: CPU %d too large (max=%ld)\n", i,
420 max_cpu);
421 return 1;
422 }
62a7273d 423 dprint(FD_PARSE, "set cpu allowed %d\n", i);
6d459ee7 424 fio_cpu_set(&td->o.cpumask, i);
62a7273d
JA
425 }
426 }
d2e268b0
JA
427
428 td->o.cpumask_set = 1;
429 return 0;
214e1eca
JA
430}
431
e8462bd8
JA
432static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask,
433 const char *input)
214e1eca 434{
d2e268b0 435 char *cpu, *str, *p;
b03daafb 436 long max_cpu;
19608d6c 437 int ret = 0;
d2e268b0 438
e8462bd8 439 ret = fio_cpuset_init(mask);
d2ce18b5
JA
440 if (ret < 0) {
441 log_err("fio: cpuset_init failed\n");
442 td_verror(td, ret, "fio_cpuset_init");
443 return 1;
444 }
d2e268b0
JA
445
446 p = str = strdup(input);
214e1eca 447
d2e268b0
JA
448 strip_blank_front(&str);
449 strip_blank_end(str);
450
c00a2289 451 max_cpu = cpus_online();
b03daafb 452
d2e268b0 453 while ((cpu = strsep(&str, ",")) != NULL) {
62a7273d
JA
454 char *str2, *cpu2;
455 int icpu, icpu2;
456
d2e268b0
JA
457 if (!strlen(cpu))
458 break;
62a7273d
JA
459
460 str2 = cpu;
461 icpu2 = -1;
462 while ((cpu2 = strsep(&str2, "-")) != NULL) {
463 if (!strlen(cpu2))
464 break;
465
466 icpu2 = atoi(cpu2);
467 }
468
469 icpu = atoi(cpu);
470 if (icpu2 == -1)
471 icpu2 = icpu;
472 while (icpu <= icpu2) {
6d459ee7 473 if (icpu >= FIO_MAX_CPUS) {
19608d6c 474 log_err("fio: your OS only supports up to"
6d459ee7 475 " %d CPUs\n", (int) FIO_MAX_CPUS);
19608d6c
JA
476 ret = 1;
477 break;
478 }
b03daafb
JA
479 if (icpu > max_cpu) {
480 log_err("fio: CPU %d too large (max=%ld)\n",
481 icpu, max_cpu);
482 ret = 1;
483 break;
484 }
0b9d69ec 485
62a7273d 486 dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
e8462bd8 487 fio_cpu_set(mask, icpu);
62a7273d
JA
488 icpu++;
489 }
19608d6c
JA
490 if (ret)
491 break;
d2e268b0
JA
492 }
493
494 free(p);
19608d6c
JA
495 if (!ret)
496 td->o.cpumask_set = 1;
497 return ret;
214e1eca 498}
e8462bd8
JA
499
500static int str_cpus_allowed_cb(void *data, const char *input)
501{
502 struct thread_data *td = data;
503 int ret;
504
52c0cea3
JA
505 if (parse_dryrun())
506 return 0;
507
e8462bd8
JA
508 ret = set_cpus_allowed(td, &td->o.cpumask, input);
509 if (!ret)
510 td->o.cpumask_set = 1;
511
512 return ret;
513}
514
515static int str_verify_cpus_allowed_cb(void *data, const char *input)
516{
517 struct thread_data *td = data;
518 int ret;
519
520 ret = set_cpus_allowed(td, &td->o.verify_cpumask, input);
521 if (!ret)
522 td->o.verify_cpumask_set = 1;
523
524 return ret;
525}
d2e268b0 526#endif
214e1eca 527
67bf9823 528#ifdef CONFIG_LIBNUMA
d0b937ed
YR
529static int str_numa_cpunodes_cb(void *data, char *input)
530{
531 struct thread_data *td = data;
532
52c0cea3
JA
533 if (parse_dryrun())
534 return 0;
535
d0b937ed
YR
536 /* numa_parse_nodestring() parses a character string list
537 * of nodes into a bit mask. The bit mask is allocated by
538 * numa_allocate_nodemask(), so it should be freed by
539 * numa_free_nodemask().
540 */
541 td->o.numa_cpunodesmask = numa_parse_nodestring(input);
542 if (td->o.numa_cpunodesmask == NULL) {
543 log_err("fio: numa_parse_nodestring failed\n");
544 td_verror(td, 1, "str_numa_cpunodes_cb");
545 return 1;
546 }
547
548 td->o.numa_cpumask_set = 1;
549 return 0;
550}
551
552static int str_numa_mpol_cb(void *data, char *input)
553{
554 struct thread_data *td = data;
555 const char * const policy_types[] =
05d6f44b 556 { "default", "prefer", "bind", "interleave", "local", NULL };
d0b937ed 557 int i;
52c0cea3
JA
558 char *nodelist;
559
560 if (parse_dryrun())
561 return 0;
d0b937ed 562
52c0cea3 563 nodelist = strchr(input, ':');
d0b937ed
YR
564 if (nodelist) {
565 /* NUL-terminate mode */
566 *nodelist++ = '\0';
567 }
568
569 for (i = 0; i <= MPOL_LOCAL; i++) {
570 if (!strcmp(input, policy_types[i])) {
571 td->o.numa_mem_mode = i;
572 break;
573 }
574 }
575 if (i > MPOL_LOCAL) {
576 log_err("fio: memory policy should be: default, prefer, bind, interleave, local\n");
577 goto out;
578 }
579
580 switch (td->o.numa_mem_mode) {
581 case MPOL_PREFERRED:
582 /*
583 * Insist on a nodelist of one node only
584 */
585 if (nodelist) {
586 char *rest = nodelist;
587 while (isdigit(*rest))
588 rest++;
589 if (*rest) {
590 log_err("fio: one node only for \'prefer\'\n");
591 goto out;
592 }
593 } else {
594 log_err("fio: one node is needed for \'prefer\'\n");
595 goto out;
596 }
597 break;
598 case MPOL_INTERLEAVE:
599 /*
600 * Default to online nodes with memory if no nodelist
601 */
602 if (!nodelist)
603 nodelist = strdup("all");
604 break;
605 case MPOL_LOCAL:
606 case MPOL_DEFAULT:
607 /*
608 * Don't allow a nodelist
609 */
610 if (nodelist) {
611 log_err("fio: NO nodelist for \'local\'\n");
612 goto out;
613 }
614 break;
615 case MPOL_BIND:
616 /*
617 * Insist on a nodelist
618 */
619 if (!nodelist) {
620 log_err("fio: a nodelist is needed for \'bind\'\n");
621 goto out;
622 }
623 break;
624 }
625
626
627 /* numa_parse_nodestring() parses a character string list
628 * of nodes into a bit mask. The bit mask is allocated by
629 * numa_allocate_nodemask(), so it should be freed by
630 * numa_free_nodemask().
631 */
632 switch (td->o.numa_mem_mode) {
633 case MPOL_PREFERRED:
634 td->o.numa_mem_prefer_node = atoi(nodelist);
635 break;
636 case MPOL_INTERLEAVE:
637 case MPOL_BIND:
638 td->o.numa_memnodesmask = numa_parse_nodestring(nodelist);
639 if (td->o.numa_memnodesmask == NULL) {
640 log_err("fio: numa_parse_nodestring failed\n");
641 td_verror(td, 1, "str_numa_memnodes_cb");
642 return 1;
643 }
644 break;
645 case MPOL_LOCAL:
646 case MPOL_DEFAULT:
647 default:
648 break;
649 }
650
651 td->o.numa_memmask_set = 1;
652 return 0;
653
654out:
655 return 1;
656}
657#endif
658
214e1eca
JA
659static int str_fst_cb(void *data, const char *str)
660{
661 struct thread_data *td = data;
662 char *nr = get_opt_postfix(str);
663
664 td->file_service_nr = 1;
182ec6ee 665 if (nr) {
214e1eca 666 td->file_service_nr = atoi(nr);
182ec6ee
JA
667 free(nr);
668 }
214e1eca
JA
669
670 return 0;
671}
672
67bf9823 673#ifdef CONFIG_SYNC_FILE_RANGE
44f29692
JA
674static int str_sfr_cb(void *data, const char *str)
675{
676 struct thread_data *td = data;
677 char *nr = get_opt_postfix(str);
678
679 td->sync_file_range_nr = 1;
680 if (nr) {
681 td->sync_file_range_nr = atoi(nr);
682 free(nr);
683 }
684
685 return 0;
686}
3ae06371 687#endif
44f29692 688
e25839d4
JA
689static int str_random_distribution_cb(void *data, const char *str)
690{
691 struct thread_data *td = data;
692 double val;
693 char *nr;
694
52c0cea3
JA
695 if (parse_dryrun())
696 return 0;
697
925fee33
JA
698 if (td->o.random_distribution == FIO_RAND_DIST_ZIPF)
699 val = 1.1;
700 else if (td->o.random_distribution == FIO_RAND_DIST_PARETO)
701 val = 0.2;
702 else
e25839d4
JA
703 return 0;
704
705 nr = get_opt_postfix(str);
925fee33 706 if (nr && !str_to_float(nr, &val)) {
e25839d4
JA
707 log_err("fio: random postfix parsing failed\n");
708 free(nr);
709 return 1;
710 }
711
078189c1
JA
712 free(nr);
713
18ded917
JA
714 if (td->o.random_distribution == FIO_RAND_DIST_ZIPF) {
715 if (val == 1.00) {
716 log_err("fio: zipf theta must different than 1.0\n");
717 return 1;
718 }
1e5324e7 719 td->o.zipf_theta.u.f = val;
18ded917 720 } else {
078189c1
JA
721 if (val <= 0.00 || val >= 1.00) {
722 log_err("fio: pareto input out of range (0 < input < 1.0)\n");
723 return 1;
724 }
1e5324e7 725 td->o.pareto_h.u.f = val;
fcef0b35 726 }
921c766f
JA
727
728 return 0;
729}
730
8e827d35
JA
731/*
732 * Return next file in the string. Files are separated with ':'. If the ':'
733 * is escaped with a '\', then that ':' is part of the filename and does not
734 * indicate a new file.
735 */
736static char *get_next_file_name(char **ptr)
737{
738 char *str = *ptr;
739 char *p, *start;
740
741 if (!str || !strlen(str))
742 return NULL;
743
744 start = str;
745 do {
746 /*
747 * No colon, we are done
748 */
749 p = strchr(str, ':');
750 if (!p) {
751 *ptr = NULL;
752 break;
753 }
754
755 /*
756 * We got a colon, but it's the first character. Skip and
757 * continue
758 */
759 if (p == start) {
760 str = ++start;
761 continue;
762 }
763
764 if (*(p - 1) != '\\') {
765 *p = '\0';
766 *ptr = p + 1;
767 break;
768 }
769
770 memmove(p - 1, p, strlen(p) + 1);
771 str = p;
772 } while (1);
773
774 return start;
775}
776
214e1eca
JA
777static int str_filename_cb(void *data, const char *input)
778{
779 struct thread_data *td = data;
780 char *fname, *str, *p;
781
782 p = str = strdup(input);
783
784 strip_blank_front(&str);
785 strip_blank_end(str);
786
787 if (!td->files_index)
2dc1bbeb 788 td->o.nr_files = 0;
214e1eca 789
8e827d35 790 while ((fname = get_next_file_name(&str)) != NULL) {
214e1eca
JA
791 if (!strlen(fname))
792 break;
793 add_file(td, fname);
2dc1bbeb 794 td->o.nr_files++;
214e1eca
JA
795 }
796
797 free(p);
798 return 0;
799}
800
801static int str_directory_cb(void *data, const char fio_unused *str)
802{
803 struct thread_data *td = data;
804 struct stat sb;
805
f9633d72
JA
806 if (parse_dryrun())
807 return 0;
808
2dc1bbeb 809 if (lstat(td->o.directory, &sb) < 0) {
921c766f
JA
810 int ret = errno;
811
2dc1bbeb 812 log_err("fio: %s is not a directory\n", td->o.directory);
921c766f 813 td_verror(td, ret, "lstat");
214e1eca
JA
814 return 1;
815 }
816 if (!S_ISDIR(sb.st_mode)) {
2dc1bbeb 817 log_err("fio: %s is not a directory\n", td->o.directory);
214e1eca
JA
818 return 1;
819 }
820
821 return 0;
822}
823
824static int str_opendir_cb(void *data, const char fio_unused *str)
825{
826 struct thread_data *td = data;
827
52c0cea3
JA
828 if (parse_dryrun())
829 return 0;
830
214e1eca 831 if (!td->files_index)
2dc1bbeb 832 td->o.nr_files = 0;
214e1eca 833
2dc1bbeb 834 return add_dir_files(td, td->o.opendir);
214e1eca
JA
835}
836
0e92f873 837static int str_verify_pattern_cb(void *data, const char *input)
90059d65
JA
838{
839 struct thread_data *td = data;
0e92f873 840 long off;
e078de4a 841 int i = 0, j = 0, len, k, base = 10, pattern_length;
3c3ed070 842 char *loc1, *loc2;
0e92f873
RR
843
844 loc1 = strstr(input, "0x");
845 loc2 = strstr(input, "0X");
846 if (loc1 || loc2)
847 base = 16;
848 off = strtol(input, NULL, base);
849 if (off != LONG_MAX || errno != ERANGE) {
850 while (off) {
851 td->o.verify_pattern[i] = off & 0xff;
852 off >>= 8;
853 i++;
854 }
855 } else {
856 len = strlen(input);
857 k = len - 1;
858 if (base == 16) {
859 if (loc1)
860 j = loc1 - input + 2;
861 else
862 j = loc2 - input + 2;
863 } else
864 return 1;
865 if (len - j < MAX_PATTERN_SIZE * 2) {
866 while (k >= j) {
867 off = converthexchartoint(input[k--]);
868 if (k >= j)
869 off += (converthexchartoint(input[k--])
870 * 16);
871 td->o.verify_pattern[i++] = (char) off;
872 }
873 }
874 }
efcd9dcc
SL
875
876 /*
877 * Fill the pattern all the way to the end. This greatly reduces
878 * the number of memcpy's we have to do when verifying the IO.
879 */
e078de4a 880 pattern_length = i;
efcd9dcc
SL
881 while (i > 1 && i * 2 <= MAX_PATTERN_SIZE) {
882 memcpy(&td->o.verify_pattern[i], &td->o.verify_pattern[0], i);
883 i *= 2;
884 }
e078de4a
JA
885
886 /*
887 * Fill remainder, if the pattern multiple ends up not being
888 * MAX_PATTERN_SIZE.
889 */
890 while (i > 1 && i < MAX_PATTERN_SIZE) {
891 unsigned int b = min(pattern_length, MAX_PATTERN_SIZE - i);
892
893 memcpy(&td->o.verify_pattern[i], &td->o.verify_pattern[0], b);
894 i += b;
895 }
896
9a2a86d0
SL
897 if (i == 1) {
898 /*
899 * The code in verify_io_u_pattern assumes a single byte pattern
900 * fills the whole verify pattern buffer.
901 */
902 memset(td->o.verify_pattern, td->o.verify_pattern[0],
903 MAX_PATTERN_SIZE);
904 }
efcd9dcc 905
0e92f873 906 td->o.verify_pattern_bytes = i;
efcd9dcc 907
92bf48d5
JA
908 /*
909 * VERIFY_META could already be set
910 */
911 if (td->o.verify == VERIFY_NONE)
912 td->o.verify = VERIFY_PATTERN;
efcd9dcc 913
90059d65
JA
914 return 0;
915}
214e1eca 916
993bf48b
JA
917static int str_gtod_reduce_cb(void *data, int *il)
918{
919 struct thread_data *td = data;
920 int val = *il;
921
02af0988 922 td->o.disable_lat = !!val;
993bf48b
JA
923 td->o.disable_clat = !!val;
924 td->o.disable_slat = !!val;
925 td->o.disable_bw = !!val;
0dc1bc03 926 td->o.clat_percentiles = !val;
993bf48b
JA
927 if (val)
928 td->tv_cache_mask = 63;
929
930 return 0;
931}
932
85bc833b 933static int str_gtod_cpu_cb(void *data, long long *il)
be4ecfdf
JA
934{
935 struct thread_data *td = data;
936 int val = *il;
937
938 td->o.gtod_cpu = val;
939 td->o.gtod_offload = 1;
940 return 0;
941}
942
7bb59102
JA
943static int str_size_cb(void *data, unsigned long long *__val)
944{
945 struct thread_data *td = data;
946 unsigned long long v = *__val;
947
948 if (parse_is_percent(v)) {
949 td->o.size = 0;
950 td->o.size_percent = -1ULL - v;
951 } else
952 td->o.size = v;
953
954 return 0;
955}
956
896cac2a
JA
957static int rw_verify(struct fio_option *o, void *data)
958{
959 struct thread_data *td = data;
960
961 if (read_only && td_write(td)) {
962 log_err("fio: job <%s> has write bit set, but fio is in"
963 " read-only mode\n", td->o.name);
964 return 1;
965 }
966
967 return 0;
968}
969
276ca4f7 970static int gtod_cpu_verify(struct fio_option *o, void *data)
29d43ff9 971{
276ca4f7 972#ifndef FIO_HAVE_CPU_AFFINITY
29d43ff9
JA
973 struct thread_data *td = data;
974
29d43ff9
JA
975 if (td->o.gtod_cpu) {
976 log_err("fio: platform must support CPU affinity for"
977 "gettimeofday() offloading\n");
978 return 1;
979 }
980#endif
981
982 return 0;
983}
984
9af4a244
JA
985/*
986 * Option grouping
987 */
988static struct opt_group fio_opt_groups[] = {
989 {
e8b0e958
JA
990 .name = "General",
991 .mask = FIO_OPT_C_GENERAL,
9af4a244
JA
992 },
993 {
e8b0e958
JA
994 .name = "I/O",
995 .mask = FIO_OPT_C_IO,
9af4a244
JA
996 },
997 {
e8b0e958
JA
998 .name = "File",
999 .mask = FIO_OPT_C_FILE,
9af4a244
JA
1000 },
1001 {
e8b0e958
JA
1002 .name = "Statistics",
1003 .mask = FIO_OPT_C_STAT,
9af4a244
JA
1004 },
1005 {
e8b0e958
JA
1006 .name = "Logging",
1007 .mask = FIO_OPT_C_LOG,
9af4a244 1008 },
13fca827
JA
1009 {
1010 .name = "Profiles",
1011 .mask = FIO_OPT_C_PROFILE,
1012 },
e231bbe6 1013 {
e8b0e958 1014 .name = NULL,
e231bbe6 1015 },
e8b0e958
JA
1016};
1017
1018static struct opt_group *__opt_group_from_mask(struct opt_group *ogs, unsigned int *mask,
1019 unsigned int inv_mask)
1020{
1021 struct opt_group *og;
1022 int i;
1023
1024 if (*mask == inv_mask || !*mask)
1025 return NULL;
1026
1027 for (i = 0; ogs[i].name; i++) {
1028 og = &ogs[i];
1029
1030 if (*mask & og->mask) {
1031 *mask &= ~(og->mask);
1032 return og;
1033 }
1034 }
1035
1036 return NULL;
1037}
1038
1039struct opt_group *opt_group_from_mask(unsigned int *mask)
1040{
1041 return __opt_group_from_mask(fio_opt_groups, mask, FIO_OPT_C_INVALID);
1042}
1043
1044static struct opt_group fio_opt_cat_groups[] = {
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 1894 },
d01612f3
CM
1895 {
1896 .name = "atomic",
1897 .lname = "Atomic I/O",
1898 .type = FIO_OPT_BOOL,
1899 .off1 = td_var_offset(oatomic),
1900 .help = "Use Atomic IO with O_DIRECT (implies O_DIRECT)",
1901 .def = "0",
1902 .category = FIO_OPT_C_IO,
1903 .group = FIO_OPT_G_IO_TYPE,
1904 },
214e1eca
JA
1905 {
1906 .name = "buffered",
e8b0e958 1907 .lname = "Buffered I/O",
214e1eca
JA
1908 .type = FIO_OPT_BOOL,
1909 .off1 = td_var_offset(odirect),
1910 .neg = 1,
1911 .help = "Use buffered IO (negates direct)",
1912 .def = "1",
a01a1bc5 1913 .inverse = "direct",
e8b0e958 1914 .category = FIO_OPT_C_IO,
3ceb458f 1915 .group = FIO_OPT_G_IO_TYPE,
214e1eca
JA
1916 },
1917 {
1918 .name = "overwrite",
e8b0e958 1919 .lname = "Overwrite",
214e1eca
JA
1920 .type = FIO_OPT_BOOL,
1921 .off1 = td_var_offset(overwrite),
1922 .help = "When writing, set whether to overwrite current data",
1923 .def = "0",
e8b0e958
JA
1924 .category = FIO_OPT_C_FILE,
1925 .group = FIO_OPT_G_INVALID,
214e1eca
JA
1926 },
1927 {
1928 .name = "loops",
e8b0e958 1929 .lname = "Loops",
214e1eca
JA
1930 .type = FIO_OPT_INT,
1931 .off1 = td_var_offset(loops),
1932 .help = "Number of times to run the job",
1933 .def = "1",
20eb06bd 1934 .interval = 1,
e8b0e958 1935 .category = FIO_OPT_C_GENERAL,
a1f6afec 1936 .group = FIO_OPT_G_RUNTIME,
214e1eca
JA
1937 },
1938 {
1939 .name = "numjobs",
e8b0e958 1940 .lname = "Number of jobs",
214e1eca
JA
1941 .type = FIO_OPT_INT,
1942 .off1 = td_var_offset(numjobs),
1943 .help = "Duplicate this job this many times",
1944 .def = "1",
20eb06bd 1945 .interval = 1,
e8b0e958 1946 .category = FIO_OPT_C_GENERAL,
a1f6afec 1947 .group = FIO_OPT_G_RUNTIME,
214e1eca
JA
1948 },
1949 {
1950 .name = "startdelay",
e8b0e958 1951 .lname = "Start delay",
a5737c93 1952 .type = FIO_OPT_STR_VAL_TIME,
214e1eca
JA
1953 .off1 = td_var_offset(start_delay),
1954 .help = "Only start job when this period has passed",
1955 .def = "0",
e8b0e958 1956 .category = FIO_OPT_C_GENERAL,
a1f6afec 1957 .group = FIO_OPT_G_RUNTIME,
214e1eca
JA
1958 },
1959 {
1960 .name = "runtime",
e8b0e958 1961 .lname = "Runtime",
214e1eca
JA
1962 .alias = "timeout",
1963 .type = FIO_OPT_STR_VAL_TIME,
1964 .off1 = td_var_offset(timeout),
1965 .help = "Stop workload when this amount of time has passed",
1966 .def = "0",
e8b0e958 1967 .category = FIO_OPT_C_GENERAL,
a1f6afec 1968 .group = FIO_OPT_G_RUNTIME,
214e1eca 1969 },
cf4464ca
JA
1970 {
1971 .name = "time_based",
e8b0e958 1972 .lname = "Time based",
cf4464ca
JA
1973 .type = FIO_OPT_STR_SET,
1974 .off1 = td_var_offset(time_based),
1975 .help = "Keep running until runtime/timeout is met",
e8b0e958 1976 .category = FIO_OPT_C_GENERAL,
a1f6afec 1977 .group = FIO_OPT_G_RUNTIME,
cf4464ca 1978 },
721938ae
JA
1979 {
1980 .name = "ramp_time",
e8b0e958 1981 .lname = "Ramp time",
721938ae
JA
1982 .type = FIO_OPT_STR_VAL_TIME,
1983 .off1 = td_var_offset(ramp_time),
1984 .help = "Ramp up time before measuring performance",
e8b0e958 1985 .category = FIO_OPT_C_GENERAL,
a1f6afec 1986 .group = FIO_OPT_G_RUNTIME,
721938ae 1987 },
c223da83
JA
1988 {
1989 .name = "clocksource",
e8b0e958 1990 .lname = "Clock source",
c223da83
JA
1991 .type = FIO_OPT_STR,
1992 .cb = fio_clock_source_cb,
1993 .off1 = td_var_offset(clocksource),
1994 .help = "What type of timing source to use",
e8b0e958 1995 .category = FIO_OPT_C_GENERAL,
10860056 1996 .group = FIO_OPT_G_CLOCK,
c223da83 1997 .posval = {
67bf9823 1998#ifdef CONFIG_GETTIMEOFDAY
c223da83
JA
1999 { .ival = "gettimeofday",
2000 .oval = CS_GTOD,
2001 .help = "Use gettimeofday(2) for timing",
2002 },
67bf9823
JA
2003#endif
2004#ifdef CONFIG_CLOCK_GETTIME
c223da83
JA
2005 { .ival = "clock_gettime",
2006 .oval = CS_CGETTIME,
2007 .help = "Use clock_gettime(2) for timing",
2008 },
67bf9823 2009#endif
c223da83
JA
2010#ifdef ARCH_HAVE_CPU_CLOCK
2011 { .ival = "cpu",
2012 .oval = CS_CPUCLOCK,
2013 .help = "Use CPU private clock",
2014 },
2015#endif
2016 },
2017 },
214e1eca
JA
2018 {
2019 .name = "mem",
d3aad8f2 2020 .alias = "iomem",
e8b0e958 2021 .lname = "I/O Memory",
214e1eca
JA
2022 .type = FIO_OPT_STR,
2023 .cb = str_mem_cb,
2024 .off1 = td_var_offset(mem_type),
2025 .help = "Backing type for IO buffers",
2026 .def = "malloc",
e8b0e958
JA
2027 .category = FIO_OPT_C_IO,
2028 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2029 .posval = {
2030 { .ival = "malloc",
2031 .oval = MEM_MALLOC,
2032 .help = "Use malloc(3) for IO buffers",
2033 },
37c8cdfe
JA
2034 { .ival = "shm",
2035 .oval = MEM_SHM,
2036 .help = "Use shared memory segments for IO buffers",
2037 },
214e1eca
JA
2038#ifdef FIO_HAVE_HUGETLB
2039 { .ival = "shmhuge",
2040 .oval = MEM_SHMHUGE,
2041 .help = "Like shm, but use huge pages",
2042 },
b370e46a 2043#endif
37c8cdfe
JA
2044 { .ival = "mmap",
2045 .oval = MEM_MMAP,
2046 .help = "Use mmap(2) (file or anon) for IO buffers",
2047 },
214e1eca
JA
2048#ifdef FIO_HAVE_HUGETLB
2049 { .ival = "mmaphuge",
2050 .oval = MEM_MMAPHUGE,
2051 .help = "Like mmap, but use huge pages",
2052 },
2053#endif
2054 },
2055 },
d529ee19
JA
2056 {
2057 .name = "iomem_align",
2058 .alias = "mem_align",
e8b0e958 2059 .lname = "I/O memory alignment",
d529ee19
JA
2060 .type = FIO_OPT_INT,
2061 .off1 = td_var_offset(mem_align),
2062 .minval = 0,
2063 .help = "IO memory buffer offset alignment",
2064 .def = "0",
2065 .parent = "iomem",
d71c154c 2066 .hide = 1,
e8b0e958
JA
2067 .category = FIO_OPT_C_IO,
2068 .group = FIO_OPT_G_INVALID,
d529ee19 2069 },
214e1eca
JA
2070 {
2071 .name = "verify",
e8b0e958 2072 .lname = "Verify",
214e1eca
JA
2073 .type = FIO_OPT_STR,
2074 .off1 = td_var_offset(verify),
2075 .help = "Verify data written",
2076 .def = "0",
e8b0e958 2077 .category = FIO_OPT_C_IO,
3ceb458f 2078 .group = FIO_OPT_G_VERIFY,
214e1eca
JA
2079 .posval = {
2080 { .ival = "0",
2081 .oval = VERIFY_NONE,
2082 .help = "Don't do IO verification",
2083 },
fcca4b58
JA
2084 { .ival = "md5",
2085 .oval = VERIFY_MD5,
2086 .help = "Use md5 checksums for verification",
2087 },
d77a7af3
JA
2088 { .ival = "crc64",
2089 .oval = VERIFY_CRC64,
2090 .help = "Use crc64 checksums for verification",
2091 },
214e1eca
JA
2092 { .ival = "crc32",
2093 .oval = VERIFY_CRC32,
2094 .help = "Use crc32 checksums for verification",
2095 },
af497e6a 2096 { .ival = "crc32c-intel",
e3aaafc4
JA
2097 .oval = VERIFY_CRC32C,
2098 .help = "Use crc32c checksums for verification (hw assisted, if available)",
af497e6a 2099 },
bac39e0e
JA
2100 { .ival = "crc32c",
2101 .oval = VERIFY_CRC32C,
e3aaafc4 2102 .help = "Use crc32c checksums for verification (hw assisted, if available)",
bac39e0e 2103 },
969f7ed3
JA
2104 { .ival = "crc16",
2105 .oval = VERIFY_CRC16,
2106 .help = "Use crc16 checksums for verification",
2107 },
1e154bdb
JA
2108 { .ival = "crc7",
2109 .oval = VERIFY_CRC7,
2110 .help = "Use crc7 checksums for verification",
2111 },
7c353ceb
JA
2112 { .ival = "sha1",
2113 .oval = VERIFY_SHA1,
2114 .help = "Use sha1 checksums for verification",
2115 },
cd14cc10
JA
2116 { .ival = "sha256",
2117 .oval = VERIFY_SHA256,
2118 .help = "Use sha256 checksums for verification",
2119 },
2120 { .ival = "sha512",
2121 .oval = VERIFY_SHA512,
2122 .help = "Use sha512 checksums for verification",
2123 },
7437ee87
SL
2124 { .ival = "meta",
2125 .oval = VERIFY_META,
2126 .help = "Use io information",
2127 },
36690c9b
JA
2128 {
2129 .ival = "null",
2130 .oval = VERIFY_NULL,
2131 .help = "Pretend to verify",
2132 },
214e1eca
JA
2133 },
2134 },
005c565a
JA
2135 {
2136 .name = "do_verify",
e8b0e958 2137 .lname = "Perform verify step",
68e1f29a 2138 .type = FIO_OPT_BOOL,
005c565a
JA
2139 .off1 = td_var_offset(do_verify),
2140 .help = "Run verification stage after write",
2141 .def = "1",
2142 .parent = "verify",
d71c154c 2143 .hide = 1,
e8b0e958
JA
2144 .category = FIO_OPT_C_IO,
2145 .group = FIO_OPT_G_VERIFY,
005c565a 2146 },
160b966d
JA
2147 {
2148 .name = "verifysort",
e8b0e958 2149 .lname = "Verify sort",
160b966d
JA
2150 .type = FIO_OPT_BOOL,
2151 .off1 = td_var_offset(verifysort),
2152 .help = "Sort written verify blocks for read back",
2153 .def = "1",
c83f2df1 2154 .parent = "verify",
d71c154c 2155 .hide = 1,
e8b0e958
JA
2156 .category = FIO_OPT_C_IO,
2157 .group = FIO_OPT_G_VERIFY,
160b966d 2158 },
1ae83d45
JA
2159 {
2160 .name = "verifysort_nr",
2161 .type = FIO_OPT_INT,
2162 .off1 = td_var_offset(verifysort_nr),
2163 .help = "Pre-load and sort verify blocks for a read workload",
2164 .minval = 0,
2165 .maxval = 131072,
2166 .def = "1024",
2167 .parent = "verify",
836fcc0f
JA
2168 .category = FIO_OPT_C_IO,
2169 .group = FIO_OPT_G_VERIFY,
1ae83d45 2170 },
3f9f4e26 2171 {
a59e170d 2172 .name = "verify_interval",
e8b0e958 2173 .lname = "Verify interval",
e01b22b8 2174 .type = FIO_OPT_INT,
a59e170d 2175 .off1 = td_var_offset(verify_interval),
819a9680 2176 .minval = 2 * sizeof(struct verify_header),
a59e170d 2177 .help = "Store verify buffer header every N bytes",
afdf9352 2178 .parent = "verify",
d71c154c 2179 .hide = 1,
20eb06bd 2180 .interval = 2 * sizeof(struct verify_header),
e8b0e958
JA
2181 .category = FIO_OPT_C_IO,
2182 .group = FIO_OPT_G_VERIFY,
3f9f4e26 2183 },
546a9142 2184 {
a59e170d 2185 .name = "verify_offset",
e8b0e958 2186 .lname = "Verify offset",
e01b22b8 2187 .type = FIO_OPT_INT,
a59e170d 2188 .help = "Offset verify header location by N bytes",
203160d5
JA
2189 .off1 = td_var_offset(verify_offset),
2190 .minval = sizeof(struct verify_header),
afdf9352 2191 .parent = "verify",
d71c154c 2192 .hide = 1,
e8b0e958
JA
2193 .category = FIO_OPT_C_IO,
2194 .group = FIO_OPT_G_VERIFY,
546a9142 2195 },
e28218f3
SL
2196 {
2197 .name = "verify_pattern",
e8b0e958 2198 .lname = "Verify pattern",
0e92f873 2199 .type = FIO_OPT_STR,
e28218f3
SL
2200 .cb = str_verify_pattern_cb,
2201 .help = "Fill pattern for IO buffers",
2202 .parent = "verify",
d71c154c 2203 .hide = 1,
e8b0e958
JA
2204 .category = FIO_OPT_C_IO,
2205 .group = FIO_OPT_G_VERIFY,
e28218f3 2206 },
a12a3b4d
JA
2207 {
2208 .name = "verify_fatal",
e8b0e958 2209 .lname = "Verify fatal",
68e1f29a 2210 .type = FIO_OPT_BOOL,
a12a3b4d
JA
2211 .off1 = td_var_offset(verify_fatal),
2212 .def = "0",
2213 .help = "Exit on a single verify failure, don't continue",
2214 .parent = "verify",
d71c154c 2215 .hide = 1,
e8b0e958
JA
2216 .category = FIO_OPT_C_IO,
2217 .group = FIO_OPT_G_VERIFY,
a12a3b4d 2218 },
b463e936
JA
2219 {
2220 .name = "verify_dump",
e8b0e958 2221 .lname = "Verify dump",
b463e936
JA
2222 .type = FIO_OPT_BOOL,
2223 .off1 = td_var_offset(verify_dump),
ef71e317 2224 .def = "0",
b463e936
JA
2225 .help = "Dump contents of good and bad blocks on failure",
2226 .parent = "verify",
d71c154c 2227 .hide = 1,
e8b0e958
JA
2228 .category = FIO_OPT_C_IO,
2229 .group = FIO_OPT_G_VERIFY,
b463e936 2230 },
e8462bd8
JA
2231 {
2232 .name = "verify_async",
e8b0e958 2233 .lname = "Verify asynchronously",
e8462bd8
JA
2234 .type = FIO_OPT_INT,
2235 .off1 = td_var_offset(verify_async),
2236 .def = "0",
2237 .help = "Number of async verifier threads to use",
2238 .parent = "verify",
d71c154c 2239 .hide = 1,
e8b0e958
JA
2240 .category = FIO_OPT_C_IO,
2241 .group = FIO_OPT_G_VERIFY,
e8462bd8 2242 },
9e144189
JA
2243 {
2244 .name = "verify_backlog",
e8b0e958 2245 .lname = "Verify backlog",
9e144189
JA
2246 .type = FIO_OPT_STR_VAL,
2247 .off1 = td_var_offset(verify_backlog),
2248 .help = "Verify after this number of blocks are written",
2249 .parent = "verify",
d71c154c 2250 .hide = 1,
e8b0e958
JA
2251 .category = FIO_OPT_C_IO,
2252 .group = FIO_OPT_G_VERIFY,
9e144189
JA
2253 },
2254 {
2255 .name = "verify_backlog_batch",
e8b0e958 2256 .lname = "Verify backlog batch",
9e144189
JA
2257 .type = FIO_OPT_INT,
2258 .off1 = td_var_offset(verify_batch),
2259 .help = "Verify this number of IO blocks",
0d29de83 2260 .parent = "verify",
d71c154c 2261 .hide = 1,
e8b0e958
JA
2262 .category = FIO_OPT_C_IO,
2263 .group = FIO_OPT_G_VERIFY,
9e144189 2264 },
e8462bd8
JA
2265#ifdef FIO_HAVE_CPU_AFFINITY
2266 {
2267 .name = "verify_async_cpus",
e8b0e958 2268 .lname = "Async verify CPUs",
e8462bd8
JA
2269 .type = FIO_OPT_STR,
2270 .cb = str_verify_cpus_allowed_cb,
2271 .help = "Set CPUs allowed for async verify threads",
2272 .parent = "verify_async",
d71c154c 2273 .hide = 1,
e8b0e958
JA
2274 .category = FIO_OPT_C_IO,
2275 .group = FIO_OPT_G_VERIFY,
e8462bd8 2276 },
0d29de83 2277#endif
51aa2da8
JA
2278 {
2279 .name = "experimental_verify",
2280 .off1 = td_var_offset(experimental_verify),
2281 .type = FIO_OPT_BOOL,
b31eaac9 2282 .help = "Enable experimental verification",
836fcc0f
JA
2283 .category = FIO_OPT_C_IO,
2284 .group = FIO_OPT_G_VERIFY,
51aa2da8 2285 },
0d29de83
JA
2286#ifdef FIO_HAVE_TRIM
2287 {
2288 .name = "trim_percentage",
e8b0e958 2289 .lname = "Trim percentage",
0d29de83 2290 .type = FIO_OPT_INT,
203160d5 2291 .off1 = td_var_offset(trim_percentage),
20eb06bd 2292 .minval = 0,
0d29de83
JA
2293 .maxval = 100,
2294 .help = "Number of verify blocks to discard/trim",
2295 .parent = "verify",
2296 .def = "0",
20eb06bd 2297 .interval = 1,
d71c154c 2298 .hide = 1,
e8b0e958
JA
2299 .category = FIO_OPT_C_IO,
2300 .group = FIO_OPT_G_TRIM,
0d29de83
JA
2301 },
2302 {
2303 .name = "trim_verify_zero",
e8b0e958 2304 .lname = "Verify trim zero",
20eb06bd 2305 .type = FIO_OPT_BOOL,
0d29de83
JA
2306 .help = "Verify that trim/discarded blocks are returned as zeroes",
2307 .off1 = td_var_offset(trim_zero),
2308 .parent = "trim_percentage",
d71c154c 2309 .hide = 1,
0d29de83 2310 .def = "1",
e8b0e958
JA
2311 .category = FIO_OPT_C_IO,
2312 .group = FIO_OPT_G_TRIM,
0d29de83
JA
2313 },
2314 {
2315 .name = "trim_backlog",
e8b0e958 2316 .lname = "Trim backlog",
0d29de83
JA
2317 .type = FIO_OPT_STR_VAL,
2318 .off1 = td_var_offset(trim_backlog),
2319 .help = "Trim after this number of blocks are written",
2320 .parent = "trim_percentage",
d71c154c 2321 .hide = 1,
20eb06bd 2322 .interval = 1,
e8b0e958
JA
2323 .category = FIO_OPT_C_IO,
2324 .group = FIO_OPT_G_TRIM,
0d29de83
JA
2325 },
2326 {
2327 .name = "trim_backlog_batch",
e8b0e958 2328 .lname = "Trim backlog batch",
0d29de83
JA
2329 .type = FIO_OPT_INT,
2330 .off1 = td_var_offset(trim_batch),
2331 .help = "Trim this number of IO blocks",
2332 .parent = "trim_percentage",
d71c154c 2333 .hide = 1,
20eb06bd 2334 .interval = 1,
e8b0e958
JA
2335 .category = FIO_OPT_C_IO,
2336 .group = FIO_OPT_G_TRIM,
0d29de83 2337 },
e8462bd8 2338#endif
214e1eca
JA
2339 {
2340 .name = "write_iolog",
e8b0e958 2341 .lname = "Write I/O log",
214e1eca
JA
2342 .type = FIO_OPT_STR_STORE,
2343 .off1 = td_var_offset(write_iolog_file),
2344 .help = "Store IO pattern to file",
e8b0e958
JA
2345 .category = FIO_OPT_C_IO,
2346 .group = FIO_OPT_G_IOLOG,
214e1eca
JA
2347 },
2348 {
2349 .name = "read_iolog",
e8b0e958 2350 .lname = "Read I/O log",
214e1eca
JA
2351 .type = FIO_OPT_STR_STORE,
2352 .off1 = td_var_offset(read_iolog_file),
2353 .help = "Playback IO pattern from file",
e8b0e958
JA
2354 .category = FIO_OPT_C_IO,
2355 .group = FIO_OPT_G_IOLOG,
214e1eca 2356 },
64bbb865
DN
2357 {
2358 .name = "replay_no_stall",
e8b0e958 2359 .lname = "Don't stall on replay",
20eb06bd 2360 .type = FIO_OPT_BOOL,
64bbb865
DN
2361 .off1 = td_var_offset(no_stall),
2362 .def = "0",
87e7a972 2363 .parent = "read_iolog",
d71c154c 2364 .hide = 1,
64bbb865 2365 .help = "Playback IO pattern file as fast as possible without stalls",
e8b0e958
JA
2366 .category = FIO_OPT_C_IO,
2367 .group = FIO_OPT_G_IOLOG,
64bbb865 2368 },
d1c46c04
DN
2369 {
2370 .name = "replay_redirect",
e8b0e958 2371 .lname = "Redirect device for replay",
d1c46c04
DN
2372 .type = FIO_OPT_STR_STORE,
2373 .off1 = td_var_offset(replay_redirect),
2374 .parent = "read_iolog",
d71c154c 2375 .hide = 1,
d1c46c04 2376 .help = "Replay all I/O onto this device, regardless of trace device",
e8b0e958
JA
2377 .category = FIO_OPT_C_IO,
2378 .group = FIO_OPT_G_IOLOG,
d1c46c04 2379 },
214e1eca
JA
2380 {
2381 .name = "exec_prerun",
e8b0e958 2382 .lname = "Pre-execute runnable",
214e1eca
JA
2383 .type = FIO_OPT_STR_STORE,
2384 .off1 = td_var_offset(exec_prerun),
2385 .help = "Execute this file prior to running job",
e8b0e958
JA
2386 .category = FIO_OPT_C_GENERAL,
2387 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2388 },
2389 {
2390 .name = "exec_postrun",
e8b0e958 2391 .lname = "Post-execute runnable",
214e1eca
JA
2392 .type = FIO_OPT_STR_STORE,
2393 .off1 = td_var_offset(exec_postrun),
2394 .help = "Execute this file after running job",
e8b0e958
JA
2395 .category = FIO_OPT_C_GENERAL,
2396 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2397 },
2398#ifdef FIO_HAVE_IOSCHED_SWITCH
2399 {
2400 .name = "ioscheduler",
e8b0e958 2401 .lname = "I/O scheduler",
214e1eca
JA
2402 .type = FIO_OPT_STR_STORE,
2403 .off1 = td_var_offset(ioscheduler),
2404 .help = "Use this IO scheduler on the backing device",
e8b0e958
JA
2405 .category = FIO_OPT_C_FILE,
2406 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2407 },
2408#endif
2409 {
2410 .name = "zonesize",
e8b0e958 2411 .lname = "Zone size",
214e1eca
JA
2412 .type = FIO_OPT_STR_VAL,
2413 .off1 = td_var_offset(zone_size),
ed335855
SN
2414 .help = "Amount of data to read per zone",
2415 .def = "0",
20eb06bd 2416 .interval = 1024 * 1024,
e8b0e958
JA
2417 .category = FIO_OPT_C_IO,
2418 .group = FIO_OPT_G_ZONE,
ed335855
SN
2419 },
2420 {
2421 .name = "zonerange",
e8b0e958 2422 .lname = "Zone range",
ed335855
SN
2423 .type = FIO_OPT_STR_VAL,
2424 .off1 = td_var_offset(zone_range),
214e1eca
JA
2425 .help = "Give size of an IO zone",
2426 .def = "0",
20eb06bd 2427 .interval = 1024 * 1024,
e8b0e958
JA
2428 .category = FIO_OPT_C_IO,
2429 .group = FIO_OPT_G_ZONE,
214e1eca
JA
2430 },
2431 {
2432 .name = "zoneskip",
e8b0e958 2433 .lname = "Zone skip",
214e1eca
JA
2434 .type = FIO_OPT_STR_VAL,
2435 .off1 = td_var_offset(zone_skip),
2436 .help = "Space between IO zones",
2437 .def = "0",
20eb06bd 2438 .interval = 1024 * 1024,
e8b0e958
JA
2439 .category = FIO_OPT_C_IO,
2440 .group = FIO_OPT_G_ZONE,
214e1eca
JA
2441 },
2442 {
2443 .name = "lockmem",
e8b0e958 2444 .lname = "Lock memory",
214e1eca 2445 .type = FIO_OPT_STR_VAL,
1b79a070 2446 .off1 = td_var_offset(lockmem),
81c6b6cd 2447 .help = "Lock down this amount of memory (per worker)",
214e1eca 2448 .def = "0",
20eb06bd 2449 .interval = 1024 * 1024,
e8b0e958
JA
2450 .category = FIO_OPT_C_GENERAL,
2451 .group = FIO_OPT_G_INVALID,
214e1eca 2452 },
214e1eca
JA
2453 {
2454 .name = "rwmixread",
e8b0e958 2455 .lname = "Read/write mix read",
214e1eca 2456 .type = FIO_OPT_INT,
cb499fc4 2457 .cb = str_rwmix_read_cb,
214e1eca
JA
2458 .maxval = 100,
2459 .help = "Percentage of mixed workload that is reads",
2460 .def = "50",
20eb06bd 2461 .interval = 5,
90265353 2462 .inverse = "rwmixwrite",
e8b0e958
JA
2463 .category = FIO_OPT_C_IO,
2464 .group = FIO_OPT_G_RWMIX,
214e1eca
JA
2465 },
2466 {
2467 .name = "rwmixwrite",
e8b0e958 2468 .lname = "Read/write mix write",
214e1eca 2469 .type = FIO_OPT_INT,
cb499fc4 2470 .cb = str_rwmix_write_cb,
214e1eca
JA
2471 .maxval = 100,
2472 .help = "Percentage of mixed workload that is writes",
2473 .def = "50",
20eb06bd 2474 .interval = 5,
90265353 2475 .inverse = "rwmixread",
e8b0e958
JA
2476 .category = FIO_OPT_C_IO,
2477 .group = FIO_OPT_G_RWMIX,
214e1eca 2478 },
afdf9352
JA
2479 {
2480 .name = "rwmixcycle",
e8b0e958 2481 .lname = "Read/write mix cycle",
15ca150e 2482 .type = FIO_OPT_DEPRECATED,
e8b0e958
JA
2483 .category = FIO_OPT_C_IO,
2484 .group = FIO_OPT_G_RWMIX,
afdf9352 2485 },
214e1eca
JA
2486 {
2487 .name = "nice",
e8b0e958 2488 .lname = "Nice",
214e1eca
JA
2489 .type = FIO_OPT_INT,
2490 .off1 = td_var_offset(nice),
2491 .help = "Set job CPU nice value",
2492 .minval = -19,
2493 .maxval = 20,
2494 .def = "0",
20eb06bd 2495 .interval = 1,
e8b0e958 2496 .category = FIO_OPT_C_GENERAL,
10860056 2497 .group = FIO_OPT_G_CRED,
214e1eca
JA
2498 },
2499#ifdef FIO_HAVE_IOPRIO
2500 {
2501 .name = "prio",
e8b0e958 2502 .lname = "I/O nice priority",
214e1eca 2503 .type = FIO_OPT_INT,
28727df7 2504 .off1 = td_var_offset(ioprio),
214e1eca
JA
2505 .help = "Set job IO priority value",
2506 .minval = 0,
2507 .maxval = 7,
20eb06bd 2508 .interval = 1,
e8b0e958 2509 .category = FIO_OPT_C_GENERAL,
10860056 2510 .group = FIO_OPT_G_CRED,
214e1eca
JA
2511 },
2512 {
2513 .name = "prioclass",
e8b0e958 2514 .lname = "I/O nice priority class",
214e1eca 2515 .type = FIO_OPT_INT,
28727df7 2516 .off1 = td_var_offset(ioprio_class),
214e1eca
JA
2517 .help = "Set job IO priority class",
2518 .minval = 0,
2519 .maxval = 3,
20eb06bd 2520 .interval = 1,
e8b0e958 2521 .category = FIO_OPT_C_GENERAL,
10860056 2522 .group = FIO_OPT_G_CRED,
214e1eca
JA
2523 },
2524#endif
2525 {
2526 .name = "thinktime",
e8b0e958 2527 .lname = "Thinktime",
214e1eca
JA
2528 .type = FIO_OPT_INT,
2529 .off1 = td_var_offset(thinktime),
2530 .help = "Idle time between IO buffers (usec)",
2531 .def = "0",
e8b0e958 2532 .category = FIO_OPT_C_IO,
3ceb458f 2533 .group = FIO_OPT_G_THINKTIME,
214e1eca
JA
2534 },
2535 {
2536 .name = "thinktime_spin",
e8b0e958 2537 .lname = "Thinktime spin",
214e1eca
JA
2538 .type = FIO_OPT_INT,
2539 .off1 = td_var_offset(thinktime_spin),
2540 .help = "Start think time by spinning this amount (usec)",
2541 .def = "0",
afdf9352 2542 .parent = "thinktime",
d71c154c 2543 .hide = 1,
e8b0e958 2544 .category = FIO_OPT_C_IO,
3ceb458f 2545 .group = FIO_OPT_G_THINKTIME,
214e1eca
JA
2546 },
2547 {
2548 .name = "thinktime_blocks",
e8b0e958 2549 .lname = "Thinktime blocks",
214e1eca
JA
2550 .type = FIO_OPT_INT,
2551 .off1 = td_var_offset(thinktime_blocks),
2552 .help = "IO buffer period between 'thinktime'",
2553 .def = "1",
afdf9352 2554 .parent = "thinktime",
d71c154c 2555 .hide = 1,
e8b0e958 2556 .category = FIO_OPT_C_IO,
3ceb458f 2557 .group = FIO_OPT_G_THINKTIME,
214e1eca
JA
2558 },
2559 {
2560 .name = "rate",
e8b0e958 2561 .lname = "I/O rate",
e01b22b8 2562 .type = FIO_OPT_INT,
6eaf09d6
SL
2563 .off1 = td_var_offset(rate[DDIR_READ]),
2564 .off2 = td_var_offset(rate[DDIR_WRITE]),
2565 .off3 = td_var_offset(rate[DDIR_TRIM]),
214e1eca 2566 .help = "Set bandwidth rate",
e8b0e958
JA
2567 .category = FIO_OPT_C_IO,
2568 .group = FIO_OPT_G_RATE,
214e1eca
JA
2569 },
2570 {
2571 .name = "ratemin",
e8b0e958 2572 .lname = "I/O min rate",
e01b22b8 2573 .type = FIO_OPT_INT,
6eaf09d6
SL
2574 .off1 = td_var_offset(ratemin[DDIR_READ]),
2575 .off2 = td_var_offset(ratemin[DDIR_WRITE]),
2576 .off3 = td_var_offset(ratemin[DDIR_TRIM]),
4e991c23 2577 .help = "Job must meet this rate or it will be shutdown",
afdf9352 2578 .parent = "rate",
d71c154c 2579 .hide = 1,
e8b0e958
JA
2580 .category = FIO_OPT_C_IO,
2581 .group = FIO_OPT_G_RATE,
4e991c23
JA
2582 },
2583 {
2584 .name = "rate_iops",
e8b0e958 2585 .lname = "I/O rate IOPS",
e01b22b8 2586 .type = FIO_OPT_INT,
6eaf09d6
SL
2587 .off1 = td_var_offset(rate_iops[DDIR_READ]),
2588 .off2 = td_var_offset(rate_iops[DDIR_WRITE]),
2589 .off3 = td_var_offset(rate_iops[DDIR_TRIM]),
4e991c23 2590 .help = "Limit IO used to this number of IO operations/sec",
d71c154c 2591 .hide = 1,
e8b0e958
JA
2592 .category = FIO_OPT_C_IO,
2593 .group = FIO_OPT_G_RATE,
4e991c23
JA
2594 },
2595 {
2596 .name = "rate_iops_min",
e8b0e958 2597 .lname = "I/O min rate IOPS",
e01b22b8 2598 .type = FIO_OPT_INT,
6eaf09d6
SL
2599 .off1 = td_var_offset(rate_iops_min[DDIR_READ]),
2600 .off2 = td_var_offset(rate_iops_min[DDIR_WRITE]),
2601 .off3 = td_var_offset(rate_iops_min[DDIR_TRIM]),
03e20d68 2602 .help = "Job must meet this rate or it will be shut down",
afdf9352 2603 .parent = "rate_iops",
d71c154c 2604 .hide = 1,
e8b0e958
JA
2605 .category = FIO_OPT_C_IO,
2606 .group = FIO_OPT_G_RATE,
214e1eca
JA
2607 },
2608 {
2609 .name = "ratecycle",
e8b0e958 2610 .lname = "I/O rate cycle",
214e1eca
JA
2611 .type = FIO_OPT_INT,
2612 .off1 = td_var_offset(ratecycle),
2613 .help = "Window average for rate limits (msec)",
2614 .def = "1000",
afdf9352 2615 .parent = "rate",
d71c154c 2616 .hide = 1,
e8b0e958
JA
2617 .category = FIO_OPT_C_IO,
2618 .group = FIO_OPT_G_RATE,
214e1eca 2619 },
15501535
JA
2620 {
2621 .name = "max_latency",
2622 .type = FIO_OPT_INT,
2623 .off1 = td_var_offset(max_latency),
2624 .help = "Maximum tolerated IO latency (usec)",
1e5324e7
JA
2625 .category = FIO_OPT_C_IO,
2626 .group = FIO_OPT_G_RATE,
15501535 2627 },
214e1eca
JA
2628 {
2629 .name = "invalidate",
e8b0e958 2630 .lname = "Cache invalidate",
214e1eca
JA
2631 .type = FIO_OPT_BOOL,
2632 .off1 = td_var_offset(invalidate_cache),
2633 .help = "Invalidate buffer/page cache prior to running job",
2634 .def = "1",
e8b0e958 2635 .category = FIO_OPT_C_IO,
3ceb458f 2636 .group = FIO_OPT_G_IO_TYPE,
214e1eca
JA
2637 },
2638 {
2639 .name = "sync",
e8b0e958 2640 .lname = "Synchronous I/O",
214e1eca
JA
2641 .type = FIO_OPT_BOOL,
2642 .off1 = td_var_offset(sync_io),
2643 .help = "Use O_SYNC for buffered writes",
2644 .def = "0",
67a1000f 2645 .parent = "buffered",
d71c154c 2646 .hide = 1,
e8b0e958 2647 .category = FIO_OPT_C_IO,
3ceb458f 2648 .group = FIO_OPT_G_IO_TYPE,
214e1eca 2649 },
214e1eca
JA
2650 {
2651 .name = "create_serialize",
e8b0e958 2652 .lname = "Create serialize",
214e1eca
JA
2653 .type = FIO_OPT_BOOL,
2654 .off1 = td_var_offset(create_serialize),
2655 .help = "Serialize creating of job files",
2656 .def = "1",
e8b0e958
JA
2657 .category = FIO_OPT_C_FILE,
2658 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2659 },
2660 {
2661 .name = "create_fsync",
e8b0e958 2662 .lname = "Create fsync",
214e1eca
JA
2663 .type = FIO_OPT_BOOL,
2664 .off1 = td_var_offset(create_fsync),
03e20d68 2665 .help = "fsync file after creation",
214e1eca 2666 .def = "1",
e8b0e958
JA
2667 .category = FIO_OPT_C_FILE,
2668 .group = FIO_OPT_G_INVALID,
214e1eca 2669 },
814452bd
JA
2670 {
2671 .name = "create_on_open",
e8b0e958 2672 .lname = "Create on open",
814452bd
JA
2673 .type = FIO_OPT_BOOL,
2674 .off1 = td_var_offset(create_on_open),
2675 .help = "Create files when they are opened for IO",
2676 .def = "0",
e8b0e958
JA
2677 .category = FIO_OPT_C_FILE,
2678 .group = FIO_OPT_G_INVALID,
814452bd 2679 },
25460cf6
JA
2680 {
2681 .name = "create_only",
2682 .type = FIO_OPT_BOOL,
2683 .off1 = td_var_offset(create_only),
2684 .help = "Only perform file creation phase",
d17fda71 2685 .category = FIO_OPT_C_FILE,
25460cf6
JA
2686 .def = "0",
2687 },
0b9d69ec 2688 {
afad68f7 2689 .name = "pre_read",
e8b0e958 2690 .lname = "Pre-read files",
afad68f7
ZY
2691 .type = FIO_OPT_BOOL,
2692 .off1 = td_var_offset(pre_read),
03e20d68 2693 .help = "Pre-read files before starting official testing",
afad68f7 2694 .def = "0",
e8b0e958
JA
2695 .category = FIO_OPT_C_FILE,
2696 .group = FIO_OPT_G_INVALID,
afad68f7 2697 },
214e1eca
JA
2698#ifdef FIO_HAVE_CPU_AFFINITY
2699 {
2700 .name = "cpumask",
e8b0e958 2701 .lname = "CPU mask",
214e1eca
JA
2702 .type = FIO_OPT_INT,
2703 .cb = str_cpumask_cb,
2704 .help = "CPU affinity mask",
e8b0e958 2705 .category = FIO_OPT_C_GENERAL,
10860056 2706 .group = FIO_OPT_G_CRED,
214e1eca 2707 },
d2e268b0
JA
2708 {
2709 .name = "cpus_allowed",
e8b0e958 2710 .lname = "CPUs allowed",
d2e268b0
JA
2711 .type = FIO_OPT_STR,
2712 .cb = str_cpus_allowed_cb,
2713 .help = "Set CPUs allowed",
e8b0e958 2714 .category = FIO_OPT_C_GENERAL,
10860056 2715 .group = FIO_OPT_G_CRED,
d2e268b0 2716 },
d0b937ed 2717#endif
67bf9823 2718#ifdef CONFIG_LIBNUMA
d0b937ed
YR
2719 {
2720 .name = "numa_cpu_nodes",
2721 .type = FIO_OPT_STR,
2722 .cb = str_numa_cpunodes_cb,
2723 .help = "NUMA CPU nodes bind",
6be54b2d
JA
2724 .category = FIO_OPT_C_GENERAL,
2725 .group = FIO_OPT_G_INVALID,
d0b937ed
YR
2726 },
2727 {
2728 .name = "numa_mem_policy",
2729 .type = FIO_OPT_STR,
2730 .cb = str_numa_mpol_cb,
2731 .help = "NUMA memory policy setup",
6be54b2d
JA
2732 .category = FIO_OPT_C_GENERAL,
2733 .group = FIO_OPT_G_INVALID,
d0b937ed 2734 },
214e1eca
JA
2735#endif
2736 {
2737 .name = "end_fsync",
e8b0e958 2738 .lname = "End fsync",
214e1eca
JA
2739 .type = FIO_OPT_BOOL,
2740 .off1 = td_var_offset(end_fsync),
2741 .help = "Include fsync at the end of job",
2742 .def = "0",
e8b0e958
JA
2743 .category = FIO_OPT_C_FILE,
2744 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2745 },
2746 {
2747 .name = "fsync_on_close",
e8b0e958 2748 .lname = "Fsync on close",
214e1eca
JA
2749 .type = FIO_OPT_BOOL,
2750 .off1 = td_var_offset(fsync_on_close),
2751 .help = "fsync files on close",
2752 .def = "0",
e8b0e958
JA
2753 .category = FIO_OPT_C_FILE,
2754 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2755 },
2756 {
2757 .name = "unlink",
e8b0e958 2758 .lname = "Unlink file",
214e1eca
JA
2759 .type = FIO_OPT_BOOL,
2760 .off1 = td_var_offset(unlink),
2761 .help = "Unlink created files after job has completed",
2762 .def = "0",
e8b0e958
JA
2763 .category = FIO_OPT_C_FILE,
2764 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2765 },
2766 {
2767 .name = "exitall",
e8b0e958 2768 .lname = "Exit-all on terminate",
214e1eca
JA
2769 .type = FIO_OPT_STR_SET,
2770 .cb = str_exitall_cb,
2771 .help = "Terminate all jobs when one exits",
e8b0e958 2772 .category = FIO_OPT_C_GENERAL,
a1f6afec 2773 .group = FIO_OPT_G_PROCESS,
214e1eca
JA
2774 },
2775 {
2776 .name = "stonewall",
e8b0e958 2777 .lname = "Wait for previous",
d392365e 2778 .alias = "wait_for_previous",
214e1eca
JA
2779 .type = FIO_OPT_STR_SET,
2780 .off1 = td_var_offset(stonewall),
2781 .help = "Insert a hard barrier between this job and previous",
e8b0e958 2782 .category = FIO_OPT_C_GENERAL,
a1f6afec 2783 .group = FIO_OPT_G_PROCESS,
214e1eca 2784 },
b3d62a75
JA
2785 {
2786 .name = "new_group",
e8b0e958 2787 .lname = "New group",
b3d62a75
JA
2788 .type = FIO_OPT_STR_SET,
2789 .off1 = td_var_offset(new_group),
2790 .help = "Mark the start of a new group (for reporting)",
e8b0e958 2791 .category = FIO_OPT_C_GENERAL,
a1f6afec 2792 .group = FIO_OPT_G_PROCESS,
b3d62a75 2793 },
214e1eca
JA
2794 {
2795 .name = "thread",
e8b0e958 2796 .lname = "Thread",
214e1eca
JA
2797 .type = FIO_OPT_STR_SET,
2798 .off1 = td_var_offset(use_thread),
20eb06bd 2799 .help = "Use threads instead of processes",
e8b0e958 2800 .category = FIO_OPT_C_GENERAL,
a1f6afec 2801 .group = FIO_OPT_G_PROCESS,
214e1eca
JA
2802 },
2803 {
2804 .name = "write_bw_log",
e8b0e958 2805 .lname = "Write bandwidth log",
203160d5
JA
2806 .type = FIO_OPT_STR_STORE,
2807 .off1 = td_var_offset(bw_log_file),
214e1eca 2808 .help = "Write log of bandwidth during run",
e8b0e958
JA
2809 .category = FIO_OPT_C_LOG,
2810 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2811 },
2812 {
2813 .name = "write_lat_log",
e8b0e958 2814 .lname = "Write latency log",
203160d5
JA
2815 .type = FIO_OPT_STR_STORE,
2816 .off1 = td_var_offset(lat_log_file),
214e1eca 2817 .help = "Write log of latency during run",
e8b0e958
JA
2818 .category = FIO_OPT_C_LOG,
2819 .group = FIO_OPT_G_INVALID,
214e1eca 2820 },
c8eeb9df
JA
2821 {
2822 .name = "write_iops_log",
e8b0e958 2823 .lname = "Write IOPS log",
577c83bd 2824 .type = FIO_OPT_STR_STORE,
203160d5 2825 .off1 = td_var_offset(iops_log_file),
c8eeb9df 2826 .help = "Write log of IOPS during run",
e8b0e958
JA
2827 .category = FIO_OPT_C_LOG,
2828 .group = FIO_OPT_G_INVALID,
c8eeb9df 2829 },
b8bc8cba
JA
2830 {
2831 .name = "log_avg_msec",
e8b0e958 2832 .lname = "Log averaging (msec)",
b8bc8cba
JA
2833 .type = FIO_OPT_INT,
2834 .off1 = td_var_offset(log_avg_msec),
2835 .help = "Average bw/iops/lat logs over this period of time",
2836 .def = "0",
e8b0e958
JA
2837 .category = FIO_OPT_C_LOG,
2838 .group = FIO_OPT_G_INVALID,
b8bc8cba 2839 },
c504ee55
JA
2840 {
2841 .name = "bwavgtime",
2842 .lname = "Bandwidth average time",
2843 .type = FIO_OPT_INT,
2844 .off1 = td_var_offset(bw_avg_time),
2845 .help = "Time window over which to calculate bandwidth"
2846 " (msec)",
2847 .def = "500",
2848 .parent = "write_bw_log",
2849 .hide = 1,
2850 .interval = 100,
2851 .category = FIO_OPT_C_LOG,
2852 .group = FIO_OPT_G_INVALID,
2853 },
2854 {
2855 .name = "iopsavgtime",
2856 .lname = "IOPS average time",
2857 .type = FIO_OPT_INT,
2858 .off1 = td_var_offset(iops_avg_time),
2859 .help = "Time window over which to calculate IOPS (msec)",
2860 .def = "500",
2861 .parent = "write_iops_log",
2862 .hide = 1,
2863 .interval = 100,
2864 .category = FIO_OPT_C_LOG,
2865 .group = FIO_OPT_G_INVALID,
2866 },
214e1eca
JA
2867 {
2868 .name = "group_reporting",
e8b0e958 2869 .lname = "Group reporting",
d2507043 2870 .type = FIO_OPT_STR_SET,
214e1eca
JA
2871 .off1 = td_var_offset(group_reporting),
2872 .help = "Do reporting on a per-group basis",
10860056 2873 .category = FIO_OPT_C_STAT,
e8b0e958 2874 .group = FIO_OPT_G_INVALID,
214e1eca 2875 },
e9459e5a
JA
2876 {
2877 .name = "zero_buffers",
e8b0e958 2878 .lname = "Zero I/O buffers",
e9459e5a
JA
2879 .type = FIO_OPT_STR_SET,
2880 .off1 = td_var_offset(zero_buffers),
2881 .help = "Init IO buffers to all zeroes",
e8b0e958 2882 .category = FIO_OPT_C_IO,
3ceb458f 2883 .group = FIO_OPT_G_IO_BUF,
e9459e5a 2884 },
5973cafb
JA
2885 {
2886 .name = "refill_buffers",
e8b0e958 2887 .lname = "Refill I/O buffers",
5973cafb
JA
2888 .type = FIO_OPT_STR_SET,
2889 .off1 = td_var_offset(refill_buffers),
2890 .help = "Refill IO buffers on every IO submit",
e8b0e958 2891 .category = FIO_OPT_C_IO,
3ceb458f 2892 .group = FIO_OPT_G_IO_BUF,
5973cafb 2893 },
fd68418e
JA
2894 {
2895 .name = "scramble_buffers",
e8b0e958 2896 .lname = "Scramble I/O buffers",
fd68418e
JA
2897 .type = FIO_OPT_BOOL,
2898 .off1 = td_var_offset(scramble_buffers),
2899 .help = "Slightly scramble buffers on every IO submit",
2900 .def = "1",
e8b0e958 2901 .category = FIO_OPT_C_IO,
3ceb458f 2902 .group = FIO_OPT_G_IO_BUF,
fd68418e 2903 },
9c42684e
JA
2904 {
2905 .name = "buffer_compress_percentage",
e8b0e958 2906 .lname = "Buffer compression percentage",
9c42684e
JA
2907 .type = FIO_OPT_INT,
2908 .off1 = td_var_offset(compress_percentage),
2909 .maxval = 100,
2910 .minval = 1,
2911 .help = "How compressible the buffer is (approximately)",
20eb06bd 2912 .interval = 5,
e8b0e958 2913 .category = FIO_OPT_C_IO,
3ceb458f 2914 .group = FIO_OPT_G_IO_BUF,
9c42684e 2915 },
f97a43a1
JA
2916 {
2917 .name = "buffer_compress_chunk",
e8b0e958 2918 .lname = "Buffer compression chunk size",
f97a43a1
JA
2919 .type = FIO_OPT_INT,
2920 .off1 = td_var_offset(compress_chunk),
207b18e4 2921 .parent = "buffer_compress_percentage",
d71c154c 2922 .hide = 1,
f97a43a1 2923 .help = "Size of compressible region in buffer",
20eb06bd 2924 .interval = 256,
e8b0e958 2925 .category = FIO_OPT_C_IO,
3ceb458f 2926 .group = FIO_OPT_G_IO_BUF,
f97a43a1 2927 },
83349190
YH
2928 {
2929 .name = "clat_percentiles",
e8b0e958 2930 .lname = "Completion latency percentiles",
83349190
YH
2931 .type = FIO_OPT_BOOL,
2932 .off1 = td_var_offset(clat_percentiles),
2933 .help = "Enable the reporting of completion latency percentiles",
467b35ed 2934 .def = "1",
e8b0e958
JA
2935 .category = FIO_OPT_C_STAT,
2936 .group = FIO_OPT_G_INVALID,
83349190
YH
2937 },
2938 {
2939 .name = "percentile_list",
e8b0e958 2940 .lname = "Completion latency percentile list",
83349190
YH
2941 .type = FIO_OPT_FLOAT_LIST,
2942 .off1 = td_var_offset(percentile_list),
435d195a 2943 .off2 = td_var_offset(percentile_precision),
83349190 2944 .help = "Specify a custom list of percentiles to report",
fd112d34 2945 .def = "1:5:10:20:30:40:50:60:70:80:90:95:99:99.5:99.9:99.95:99.99",
83349190
YH
2946 .maxlen = FIO_IO_U_LIST_MAX_LEN,
2947 .minfp = 0.0,
2948 .maxfp = 100.0,
e8b0e958
JA
2949 .category = FIO_OPT_C_STAT,
2950 .group = FIO_OPT_G_INVALID,
83349190
YH
2951 },
2952
0a839f30
JA
2953#ifdef FIO_HAVE_DISK_UTIL
2954 {
2955 .name = "disk_util",
e8b0e958 2956 .lname = "Disk utilization",
0a839f30
JA
2957 .type = FIO_OPT_BOOL,
2958 .off1 = td_var_offset(do_disk_util),
f66ab3c8 2959 .help = "Log disk utilization statistics",
0a839f30 2960 .def = "1",
e8b0e958
JA
2961 .category = FIO_OPT_C_STAT,
2962 .group = FIO_OPT_G_INVALID,
0a839f30
JA
2963 },
2964#endif
993bf48b
JA
2965 {
2966 .name = "gtod_reduce",
e8b0e958 2967 .lname = "Reduce gettimeofday() calls",
993bf48b
JA
2968 .type = FIO_OPT_BOOL,
2969 .help = "Greatly reduce number of gettimeofday() calls",
2970 .cb = str_gtod_reduce_cb,
2971 .def = "0",
a4ed77fe 2972 .hide_on_set = 1,
e8b0e958
JA
2973 .category = FIO_OPT_C_STAT,
2974 .group = FIO_OPT_G_INVALID,
993bf48b 2975 },
02af0988
JA
2976 {
2977 .name = "disable_lat",
e8b0e958 2978 .lname = "Disable all latency stats",
02af0988
JA
2979 .type = FIO_OPT_BOOL,
2980 .off1 = td_var_offset(disable_lat),
2981 .help = "Disable latency numbers",
2982 .parent = "gtod_reduce",
d71c154c 2983 .hide = 1,
02af0988 2984 .def = "0",
e8b0e958
JA
2985 .category = FIO_OPT_C_STAT,
2986 .group = FIO_OPT_G_INVALID,
02af0988 2987 },
9520ebb9
JA
2988 {
2989 .name = "disable_clat",
e8b0e958 2990 .lname = "Disable completion latency stats",
9520ebb9
JA
2991 .type = FIO_OPT_BOOL,
2992 .off1 = td_var_offset(disable_clat),
2993 .help = "Disable completion latency numbers",
993bf48b 2994 .parent = "gtod_reduce",
d71c154c 2995 .hide = 1,
9520ebb9 2996 .def = "0",
e8b0e958
JA
2997 .category = FIO_OPT_C_STAT,
2998 .group = FIO_OPT_G_INVALID,
9520ebb9
JA
2999 },
3000 {
3001 .name = "disable_slat",
e8b0e958 3002 .lname = "Disable submission latency stats",
9520ebb9
JA
3003 .type = FIO_OPT_BOOL,
3004 .off1 = td_var_offset(disable_slat),
03e20d68 3005 .help = "Disable submission latency numbers",
993bf48b 3006 .parent = "gtod_reduce",
d71c154c 3007 .hide = 1,
9520ebb9 3008 .def = "0",
e8b0e958
JA
3009 .category = FIO_OPT_C_STAT,
3010 .group = FIO_OPT_G_INVALID,
9520ebb9
JA
3011 },
3012 {
3013 .name = "disable_bw_measurement",
e8b0e958 3014 .lname = "Disable bandwidth stats",
9520ebb9
JA
3015 .type = FIO_OPT_BOOL,
3016 .off1 = td_var_offset(disable_bw),
3017 .help = "Disable bandwidth logging",
993bf48b 3018 .parent = "gtod_reduce",
d71c154c 3019 .hide = 1,
9520ebb9 3020 .def = "0",
e8b0e958
JA
3021 .category = FIO_OPT_C_STAT,
3022 .group = FIO_OPT_G_INVALID,
9520ebb9 3023 },
be4ecfdf
JA
3024 {
3025 .name = "gtod_cpu",
e8b0e958 3026 .lname = "Dedicated gettimeofday() CPU",
be4ecfdf
JA
3027 .type = FIO_OPT_INT,
3028 .cb = str_gtod_cpu_cb,
03e20d68 3029 .help = "Set up dedicated gettimeofday() thread on this CPU",
29d43ff9 3030 .verify = gtod_cpu_verify,
e8b0e958 3031 .category = FIO_OPT_C_GENERAL,
10860056 3032 .group = FIO_OPT_G_CLOCK,
be4ecfdf 3033 },
771e58be
JA
3034 {
3035 .name = "unified_rw_reporting",
3036 .type = FIO_OPT_BOOL,
3037 .off1 = td_var_offset(unified_rw_rep),
3038 .help = "Unify reporting across data direction",
3039 .def = "0",
90b7a96d
JA
3040 .category = FIO_OPT_C_GENERAL,
3041 .group = FIO_OPT_G_INVALID,
771e58be 3042 },
f2bba182
RR
3043 {
3044 .name = "continue_on_error",
e8b0e958 3045 .lname = "Continue on error",
06842027 3046 .type = FIO_OPT_STR,
f2bba182 3047 .off1 = td_var_offset(continue_on_error),
03e20d68 3048 .help = "Continue on non-fatal errors during IO",
06842027 3049 .def = "none",
e8b0e958 3050 .category = FIO_OPT_C_GENERAL,
bc3f552f 3051 .group = FIO_OPT_G_ERR,
06842027
SL
3052 .posval = {
3053 { .ival = "none",
3054 .oval = ERROR_TYPE_NONE,
3055 .help = "Exit when an error is encountered",
3056 },
3057 { .ival = "read",
3058 .oval = ERROR_TYPE_READ,
3059 .help = "Continue on read errors only",
3060 },
3061 { .ival = "write",
3062 .oval = ERROR_TYPE_WRITE,
3063 .help = "Continue on write errors only",
3064 },
3065 { .ival = "io",
3066 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
3067 .help = "Continue on any IO errors",
3068 },
3069 { .ival = "verify",
3070 .oval = ERROR_TYPE_VERIFY,
3071 .help = "Continue on verify errors only",
3072 },
3073 { .ival = "all",
3074 .oval = ERROR_TYPE_ANY,
3075 .help = "Continue on all io and verify errors",
3076 },
3077 { .ival = "0",
3078 .oval = ERROR_TYPE_NONE,
3079 .help = "Alias for 'none'",
3080 },
3081 { .ival = "1",
3082 .oval = ERROR_TYPE_ANY,
3083 .help = "Alias for 'all'",
3084 },
3085 },
f2bba182 3086 },
8b28bd41
DM
3087 {
3088 .name = "ignore_error",
3089 .type = FIO_OPT_STR,
3090 .cb = str_ignore_error_cb,
3091 .help = "Set a specific list of errors to ignore",
3092 .parent = "rw",
a94eb99a 3093 .category = FIO_OPT_C_GENERAL,
bc3f552f 3094 .group = FIO_OPT_G_ERR,
8b28bd41
DM
3095 },
3096 {
3097 .name = "error_dump",
3098 .type = FIO_OPT_BOOL,
3099 .off1 = td_var_offset(error_dump),
3100 .def = "0",
3101 .help = "Dump info on each error",
a94eb99a 3102 .category = FIO_OPT_C_GENERAL,
bc3f552f 3103 .group = FIO_OPT_G_ERR,
8b28bd41 3104 },
9ac8a797
JA
3105 {
3106 .name = "profile",
e8b0e958 3107 .lname = "Profile",
79d16311 3108 .type = FIO_OPT_STR_STORE,
9ac8a797 3109 .off1 = td_var_offset(profile),
9ac8a797 3110 .help = "Select a specific builtin performance test",
13fca827 3111 .category = FIO_OPT_C_PROFILE,
e8b0e958 3112 .group = FIO_OPT_G_INVALID,
9ac8a797 3113 },
a696fa2a
JA
3114 {
3115 .name = "cgroup",
e8b0e958 3116 .lname = "Cgroup",
a696fa2a
JA
3117 .type = FIO_OPT_STR_STORE,
3118 .off1 = td_var_offset(cgroup),
3119 .help = "Add job to cgroup of this name",
e8b0e958 3120 .category = FIO_OPT_C_GENERAL,
a1f6afec
JA
3121 .group = FIO_OPT_G_CGROUP,
3122 },
3123 {
3124 .name = "cgroup_nodelete",
3125 .lname = "Cgroup no-delete",
3126 .type = FIO_OPT_BOOL,
3127 .off1 = td_var_offset(cgroup_nodelete),
3128 .help = "Do not delete cgroups after job completion",
3129 .def = "0",
3130 .parent = "cgroup",
3131 .category = FIO_OPT_C_GENERAL,
3132 .group = FIO_OPT_G_CGROUP,
a696fa2a
JA
3133 },
3134 {
3135 .name = "cgroup_weight",
e8b0e958 3136 .lname = "Cgroup weight",
a696fa2a
JA
3137 .type = FIO_OPT_INT,
3138 .off1 = td_var_offset(cgroup_weight),
3139 .help = "Use given weight for cgroup",
3140 .minval = 100,
3141 .maxval = 1000,
a1f6afec 3142 .parent = "cgroup",
e8b0e958 3143 .category = FIO_OPT_C_GENERAL,
a1f6afec 3144 .group = FIO_OPT_G_CGROUP,
7de87099 3145 },
e0b0d892
JA
3146 {
3147 .name = "uid",
e8b0e958 3148 .lname = "User ID",
e0b0d892
JA
3149 .type = FIO_OPT_INT,
3150 .off1 = td_var_offset(uid),
3151 .help = "Run job with this user ID",
e8b0e958 3152 .category = FIO_OPT_C_GENERAL,
10860056 3153 .group = FIO_OPT_G_CRED,
e0b0d892
JA
3154 },
3155 {
3156 .name = "gid",
e8b0e958 3157 .lname = "Group ID",
e0b0d892
JA
3158 .type = FIO_OPT_INT,
3159 .off1 = td_var_offset(gid),
3160 .help = "Run job with this group ID",
e8b0e958 3161 .category = FIO_OPT_C_GENERAL,
10860056 3162 .group = FIO_OPT_G_CRED,
e0b0d892 3163 },
a1f6afec
JA
3164 {
3165 .name = "kb_base",
3166 .lname = "KB Base",
3167 .type = FIO_OPT_INT,
3168 .off1 = td_var_offset(kb_base),
a1f6afec
JA
3169 .prio = 1,
3170 .def = "1024",
ba9c7219
JA
3171 .posval = {
3172 { .ival = "1024",
3173 .oval = 1024,
3174 .help = "Use 1024 as the K base",
3175 },
3176 { .ival = "1000",
3177 .oval = 1000,
3178 .help = "Use 1000 as the K base",
3179 },
3180 },
a1f6afec
JA
3181 .help = "How many bytes per KB for reporting (1000 or 1024)",
3182 .category = FIO_OPT_C_GENERAL,
3183 .group = FIO_OPT_G_INVALID,
3184 },
cf3a0518
JA
3185 {
3186 .name = "unit_base",
ba9c7219 3187 .lname = "Base unit for reporting (Bits or Bytes)",
cf3a0518
JA
3188 .type = FIO_OPT_INT,
3189 .off1 = td_var_offset(unit_base),
cf3a0518 3190 .prio = 1,
71a08258
JA
3191 .posval = {
3192 { .ival = "0",
3193 .oval = 0,
3194 .help = "Auto-detect",
3195 },
3196 { .ival = "8",
3197 .oval = 8,
3198 .help = "Normal (byte based)",
3199 },
3200 { .ival = "1",
3201 .oval = 1,
3202 .help = "Bit based",
3203 },
3204 },
cf3a0518
JA
3205 .help = "Bit multiple of result summary data (8 for byte, 1 for bit)",
3206 .category = FIO_OPT_C_GENERAL,
3207 .group = FIO_OPT_G_INVALID,
3208 },
3ceb458f
JA
3209 {
3210 .name = "hugepage-size",
3211 .lname = "Hugepage size",
3212 .type = FIO_OPT_INT,
3213 .off1 = td_var_offset(hugepage_size),
3214 .help = "When using hugepages, specify size of each page",
3215 .def = __fio_stringify(FIO_HUGE_PAGE),
3216 .interval = 1024 * 1024,
3217 .category = FIO_OPT_C_GENERAL,
3218 .group = FIO_OPT_G_INVALID,
3219 },
9e684a49
DE
3220 {
3221 .name = "flow_id",
e8b0e958 3222 .lname = "I/O flow ID",
9e684a49
DE
3223 .type = FIO_OPT_INT,
3224 .off1 = td_var_offset(flow_id),
3225 .help = "The flow index ID to use",
3226 .def = "0",
e8b0e958
JA
3227 .category = FIO_OPT_C_IO,
3228 .group = FIO_OPT_G_IO_FLOW,
9e684a49
DE
3229 },
3230 {
3231 .name = "flow",
e8b0e958 3232 .lname = "I/O flow weight",
9e684a49
DE
3233 .type = FIO_OPT_INT,
3234 .off1 = td_var_offset(flow),
3235 .help = "Weight for flow control of this job",
3236 .parent = "flow_id",
d71c154c 3237 .hide = 1,
9e684a49 3238 .def = "0",
e8b0e958
JA
3239 .category = FIO_OPT_C_IO,
3240 .group = FIO_OPT_G_IO_FLOW,
9e684a49
DE
3241 },
3242 {
3243 .name = "flow_watermark",
e8b0e958 3244 .lname = "I/O flow watermark",
9e684a49
DE
3245 .type = FIO_OPT_INT,
3246 .off1 = td_var_offset(flow_watermark),
3247 .help = "High watermark for flow control. This option"
3248 " should be set to the same value for all threads"
3249 " with non-zero flow.",
3250 .parent = "flow_id",
d71c154c 3251 .hide = 1,
9e684a49 3252 .def = "1024",
e8b0e958
JA
3253 .category = FIO_OPT_C_IO,
3254 .group = FIO_OPT_G_IO_FLOW,
9e684a49
DE
3255 },
3256 {
3257 .name = "flow_sleep",
e8b0e958 3258 .lname = "I/O flow sleep",
9e684a49
DE
3259 .type = FIO_OPT_INT,
3260 .off1 = td_var_offset(flow_sleep),
3261 .help = "How many microseconds to sleep after being held"
3262 " back by the flow control mechanism",
3263 .parent = "flow_id",
d71c154c 3264 .hide = 1,
9e684a49 3265 .def = "0",
e8b0e958
JA
3266 .category = FIO_OPT_C_IO,
3267 .group = FIO_OPT_G_IO_FLOW,
9e684a49 3268 },
214e1eca
JA
3269 {
3270 .name = NULL,
3271 },
3272};
3273
17af15d4 3274static void add_to_lopt(struct option *lopt, struct fio_option *o,
de890a1e 3275 const char *name, int val)
9f81736c 3276{
17af15d4 3277 lopt->name = (char *) name;
de890a1e 3278 lopt->val = val;
9f81736c 3279 if (o->type == FIO_OPT_STR_SET)
ff52be3d 3280 lopt->has_arg = optional_argument;
9f81736c
JA
3281 else
3282 lopt->has_arg = required_argument;
3283}
3284
de890a1e
SL
3285static void options_to_lopts(struct fio_option *opts,
3286 struct option *long_options,
3287 int i, int option_type)
214e1eca 3288{
de890a1e 3289 struct fio_option *o = &opts[0];
214e1eca 3290 while (o->name) {
de890a1e 3291 add_to_lopt(&long_options[i], o, o->name, option_type);
17af15d4
JA
3292 if (o->alias) {
3293 i++;
de890a1e 3294 add_to_lopt(&long_options[i], o, o->alias, option_type);
17af15d4 3295 }
214e1eca
JA
3296
3297 i++;
3298 o++;
3299 assert(i < FIO_NR_OPTIONS);
3300 }
3301}
3302
de890a1e
SL
3303void fio_options_set_ioengine_opts(struct option *long_options,
3304 struct thread_data *td)
3305{
3306 unsigned int i;
3307
3308 i = 0;
3309 while (long_options[i].name) {
3310 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
3311 memset(&long_options[i], 0, sizeof(*long_options));
3312 break;
3313 }
3314 i++;
3315 }
3316
3317 /*
3318 * Just clear out the prior ioengine options.
3319 */
3320 if (!td || !td->eo)
3321 return;
3322
3323 options_to_lopts(td->io_ops->options, long_options, i,
3324 FIO_GETOPT_IOENGINE);
3325}
3326
3327void fio_options_dup_and_init(struct option *long_options)
3328{
3329 unsigned int i;
3330
9af4a244 3331 options_init(fio_options);
de890a1e
SL
3332
3333 i = 0;
3334 while (long_options[i].name)
3335 i++;
3336
9af4a244 3337 options_to_lopts(fio_options, long_options, i, FIO_GETOPT_JOB);
de890a1e
SL
3338}
3339
74929ac2
JA
3340struct fio_keyword {
3341 const char *word;
3342 const char *desc;
3343 char *replace;
3344};
3345
3346static struct fio_keyword fio_keywords[] = {
3347 {
3348 .word = "$pagesize",
3349 .desc = "Page size in the system",
3350 },
3351 {
3352 .word = "$mb_memory",
3353 .desc = "Megabytes of memory online",
3354 },
3355 {
3356 .word = "$ncpus",
3357 .desc = "Number of CPUs online in the system",
3358 },
3359 {
3360 .word = NULL,
3361 },
3362};
3363
3364void fio_keywords_init(void)
3365{
3b2e1464 3366 unsigned long long mb_memory;
74929ac2
JA
3367 char buf[128];
3368 long l;
3369
a4cfc477 3370 sprintf(buf, "%lu", (unsigned long) page_size);
74929ac2
JA
3371 fio_keywords[0].replace = strdup(buf);
3372
8eb016d3 3373 mb_memory = os_phys_mem() / (1024 * 1024);
3b2e1464 3374 sprintf(buf, "%llu", mb_memory);
74929ac2
JA
3375 fio_keywords[1].replace = strdup(buf);
3376
c00a2289 3377 l = cpus_online();
74929ac2
JA
3378 sprintf(buf, "%lu", l);
3379 fio_keywords[2].replace = strdup(buf);
3380}
3381
892a6ffc
JA
3382#define BC_APP "bc"
3383
3384static char *bc_calc(char *str)
3385{
d0c814ec 3386 char buf[128], *tmp;
892a6ffc
JA
3387 FILE *f;
3388 int ret;
3389
3390 /*
3391 * No math, just return string
3392 */
d0c814ec
SL
3393 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
3394 !strchr(str, '/')) || strchr(str, '\''))
892a6ffc
JA
3395 return str;
3396
3397 /*
3398 * Split option from value, we only need to calculate the value
3399 */
3400 tmp = strchr(str, '=');
3401 if (!tmp)
3402 return str;
3403
3404 tmp++;
892a6ffc 3405
d0c814ec
SL
3406 /*
3407 * Prevent buffer overflows; such a case isn't reasonable anyway
3408 */
3409 if (strlen(str) >= 128 || strlen(tmp) > 100)
3410 return str;
892a6ffc
JA
3411
3412 sprintf(buf, "which %s > /dev/null", BC_APP);
3413 if (system(buf)) {
3414 log_err("fio: bc is needed for performing math\n");
892a6ffc
JA
3415 return NULL;
3416 }
3417
d0c814ec 3418 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
892a6ffc 3419 f = popen(buf, "r");
3c3ed070 3420 if (!f)
892a6ffc 3421 return NULL;
892a6ffc 3422
d0c814ec 3423 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
3c3ed070 3424 if (ret <= 0)
892a6ffc 3425 return NULL;
892a6ffc 3426
892a6ffc 3427 pclose(f);
d0c814ec
SL
3428 buf[(tmp - str) + ret - 1] = '\0';
3429 memcpy(buf, str, tmp - str);
892a6ffc 3430 free(str);
d0c814ec
SL
3431 return strdup(buf);
3432}
3433
3434/*
3435 * Return a copy of the input string with substrings of the form ${VARNAME}
3436 * substituted with the value of the environment variable VARNAME. The
3437 * substitution always occurs, even if VARNAME is empty or the corresponding
3438 * environment variable undefined.
3439 */
3440static char *option_dup_subs(const char *opt)
3441{
3442 char out[OPT_LEN_MAX+1];
3443 char in[OPT_LEN_MAX+1];
3444 char *outptr = out;
3445 char *inptr = in;
3446 char *ch1, *ch2, *env;
3447 ssize_t nchr = OPT_LEN_MAX;
3448 size_t envlen;
3449
3450 if (strlen(opt) + 1 > OPT_LEN_MAX) {
3451 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
3452 return NULL;
3453 }
3454
3455 in[OPT_LEN_MAX] = '\0';
3456 strncpy(in, opt, OPT_LEN_MAX);
3457
3458 while (*inptr && nchr > 0) {
3459 if (inptr[0] == '$' && inptr[1] == '{') {
3460 ch2 = strchr(inptr, '}');
3461 if (ch2 && inptr+1 < ch2) {
3462 ch1 = inptr+2;
3463 inptr = ch2+1;
3464 *ch2 = '\0';
3465
3466 env = getenv(ch1);
3467 if (env) {
3468 envlen = strlen(env);
3469 if (envlen <= nchr) {
3470 memcpy(outptr, env, envlen);
3471 outptr += envlen;
3472 nchr -= envlen;
3473 }
3474 }
3475
3476 continue;
3477 }
3478 }
3479
3480 *outptr++ = *inptr++;
3481 --nchr;
3482 }
3483
3484 *outptr = '\0';
3485 return strdup(out);
892a6ffc
JA
3486}
3487
74929ac2
JA
3488/*
3489 * Look for reserved variable names and replace them with real values
3490 */
3491static char *fio_keyword_replace(char *opt)
3492{
3493 char *s;
3494 int i;
d0c814ec 3495 int docalc = 0;
74929ac2
JA
3496
3497 for (i = 0; fio_keywords[i].word != NULL; i++) {
3498 struct fio_keyword *kw = &fio_keywords[i];
3499
3500 while ((s = strstr(opt, kw->word)) != NULL) {
3501 char *new = malloc(strlen(opt) + 1);
3502 char *o_org = opt;
3503 int olen = s - opt;
3504 int len;
3505
3506 /*
3507 * Copy part of the string before the keyword and
3508 * sprintf() the replacement after it.
3509 */
3510 memcpy(new, opt, olen);
3511 len = sprintf(new + olen, "%s", kw->replace);
3512
3513 /*
3514 * If there's more in the original string, copy that
3515 * in too
3516 */
3517 opt += strlen(kw->word) + olen;
3518 if (strlen(opt))
3519 memcpy(new + olen + len, opt, opt - o_org - 1);
3520
3521 /*
3522 * replace opt and free the old opt
3523 */
3524 opt = new;
d0c814ec 3525 free(o_org);
7a958bd5 3526
d0c814ec 3527 docalc = 1;
74929ac2
JA
3528 }
3529 }
3530
d0c814ec
SL
3531 /*
3532 * Check for potential math and invoke bc, if possible
3533 */
3534 if (docalc)
3535 opt = bc_calc(opt);
3536
7a958bd5 3537 return opt;
74929ac2
JA
3538}
3539
d0c814ec
SL
3540static char **dup_and_sub_options(char **opts, int num_opts)
3541{
3542 int i;
3543 char **opts_copy = malloc(num_opts * sizeof(*opts));
3544 for (i = 0; i < num_opts; i++) {
3545 opts_copy[i] = option_dup_subs(opts[i]);
3546 if (!opts_copy[i])
3547 continue;
3548 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
3549 }
3550 return opts_copy;
3551}
3552
292cc475
JA
3553int fio_options_parse(struct thread_data *td, char **opts, int num_opts,
3554 int dump_cmdline)
214e1eca 3555{
de890a1e 3556 int i, ret, unknown;
d0c814ec 3557 char **opts_copy;
3b8b7135 3558
9af4a244 3559 sort_options(opts, fio_options, num_opts);
d0c814ec 3560 opts_copy = dup_and_sub_options(opts, num_opts);
3b8b7135 3561
de890a1e
SL
3562 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
3563 struct fio_option *o;
9af4a244 3564 int newret = parse_option(opts_copy[i], opts[i], fio_options,
292cc475 3565 &o, td, dump_cmdline);
d0c814ec 3566
de890a1e
SL
3567 if (opts_copy[i]) {
3568 if (newret && !o) {
3569 unknown++;
3570 continue;
3571 }
d0c814ec