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