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