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