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