Enable IPv6 in the Windows build
[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",
363cffa7 1659 .type = FIO_OPT_STR_VAL,
04778baf
JA
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 },
62167762
JC
2020 {
2021 .name = "verify_only",
2022 .lname = "Verify only",
2023 .type = FIO_OPT_STR_SET,
2024 .off1 = td_var_offset(verify_only),
2025 .help = "Verifies previously written data is still valid",
2026 .category = FIO_OPT_C_GENERAL,
2027 .group = FIO_OPT_G_RUNTIME,
2028 },
721938ae
JA
2029 {
2030 .name = "ramp_time",
e8b0e958 2031 .lname = "Ramp time",
721938ae
JA
2032 .type = FIO_OPT_STR_VAL_TIME,
2033 .off1 = td_var_offset(ramp_time),
2034 .help = "Ramp up time before measuring performance",
e8b0e958 2035 .category = FIO_OPT_C_GENERAL,
a1f6afec 2036 .group = FIO_OPT_G_RUNTIME,
721938ae 2037 },
c223da83
JA
2038 {
2039 .name = "clocksource",
e8b0e958 2040 .lname = "Clock source",
c223da83
JA
2041 .type = FIO_OPT_STR,
2042 .cb = fio_clock_source_cb,
2043 .off1 = td_var_offset(clocksource),
2044 .help = "What type of timing source to use",
e8b0e958 2045 .category = FIO_OPT_C_GENERAL,
10860056 2046 .group = FIO_OPT_G_CLOCK,
c223da83 2047 .posval = {
67bf9823 2048#ifdef CONFIG_GETTIMEOFDAY
c223da83
JA
2049 { .ival = "gettimeofday",
2050 .oval = CS_GTOD,
2051 .help = "Use gettimeofday(2) for timing",
2052 },
67bf9823
JA
2053#endif
2054#ifdef CONFIG_CLOCK_GETTIME
c223da83
JA
2055 { .ival = "clock_gettime",
2056 .oval = CS_CGETTIME,
2057 .help = "Use clock_gettime(2) for timing",
2058 },
67bf9823 2059#endif
c223da83
JA
2060#ifdef ARCH_HAVE_CPU_CLOCK
2061 { .ival = "cpu",
2062 .oval = CS_CPUCLOCK,
2063 .help = "Use CPU private clock",
2064 },
2065#endif
2066 },
2067 },
214e1eca
JA
2068 {
2069 .name = "mem",
d3aad8f2 2070 .alias = "iomem",
e8b0e958 2071 .lname = "I/O Memory",
214e1eca
JA
2072 .type = FIO_OPT_STR,
2073 .cb = str_mem_cb,
2074 .off1 = td_var_offset(mem_type),
2075 .help = "Backing type for IO buffers",
2076 .def = "malloc",
e8b0e958
JA
2077 .category = FIO_OPT_C_IO,
2078 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2079 .posval = {
2080 { .ival = "malloc",
2081 .oval = MEM_MALLOC,
2082 .help = "Use malloc(3) for IO buffers",
2083 },
37c8cdfe
JA
2084 { .ival = "shm",
2085 .oval = MEM_SHM,
2086 .help = "Use shared memory segments for IO buffers",
2087 },
214e1eca
JA
2088#ifdef FIO_HAVE_HUGETLB
2089 { .ival = "shmhuge",
2090 .oval = MEM_SHMHUGE,
2091 .help = "Like shm, but use huge pages",
2092 },
b370e46a 2093#endif
37c8cdfe
JA
2094 { .ival = "mmap",
2095 .oval = MEM_MMAP,
2096 .help = "Use mmap(2) (file or anon) for IO buffers",
2097 },
214e1eca
JA
2098#ifdef FIO_HAVE_HUGETLB
2099 { .ival = "mmaphuge",
2100 .oval = MEM_MMAPHUGE,
2101 .help = "Like mmap, but use huge pages",
2102 },
2103#endif
2104 },
2105 },
d529ee19
JA
2106 {
2107 .name = "iomem_align",
2108 .alias = "mem_align",
e8b0e958 2109 .lname = "I/O memory alignment",
d529ee19
JA
2110 .type = FIO_OPT_INT,
2111 .off1 = td_var_offset(mem_align),
2112 .minval = 0,
2113 .help = "IO memory buffer offset alignment",
2114 .def = "0",
2115 .parent = "iomem",
d71c154c 2116 .hide = 1,
e8b0e958
JA
2117 .category = FIO_OPT_C_IO,
2118 .group = FIO_OPT_G_INVALID,
d529ee19 2119 },
214e1eca
JA
2120 {
2121 .name = "verify",
e8b0e958 2122 .lname = "Verify",
214e1eca
JA
2123 .type = FIO_OPT_STR,
2124 .off1 = td_var_offset(verify),
2125 .help = "Verify data written",
2126 .def = "0",
e8b0e958 2127 .category = FIO_OPT_C_IO,
3ceb458f 2128 .group = FIO_OPT_G_VERIFY,
214e1eca
JA
2129 .posval = {
2130 { .ival = "0",
2131 .oval = VERIFY_NONE,
2132 .help = "Don't do IO verification",
2133 },
fcca4b58
JA
2134 { .ival = "md5",
2135 .oval = VERIFY_MD5,
2136 .help = "Use md5 checksums for verification",
2137 },
d77a7af3
JA
2138 { .ival = "crc64",
2139 .oval = VERIFY_CRC64,
2140 .help = "Use crc64 checksums for verification",
2141 },
214e1eca
JA
2142 { .ival = "crc32",
2143 .oval = VERIFY_CRC32,
2144 .help = "Use crc32 checksums for verification",
2145 },
af497e6a 2146 { .ival = "crc32c-intel",
e3aaafc4
JA
2147 .oval = VERIFY_CRC32C,
2148 .help = "Use crc32c checksums for verification (hw assisted, if available)",
af497e6a 2149 },
bac39e0e
JA
2150 { .ival = "crc32c",
2151 .oval = VERIFY_CRC32C,
e3aaafc4 2152 .help = "Use crc32c checksums for verification (hw assisted, if available)",
bac39e0e 2153 },
969f7ed3
JA
2154 { .ival = "crc16",
2155 .oval = VERIFY_CRC16,
2156 .help = "Use crc16 checksums for verification",
2157 },
1e154bdb
JA
2158 { .ival = "crc7",
2159 .oval = VERIFY_CRC7,
2160 .help = "Use crc7 checksums for verification",
2161 },
7c353ceb
JA
2162 { .ival = "sha1",
2163 .oval = VERIFY_SHA1,
2164 .help = "Use sha1 checksums for verification",
2165 },
cd14cc10
JA
2166 { .ival = "sha256",
2167 .oval = VERIFY_SHA256,
2168 .help = "Use sha256 checksums for verification",
2169 },
2170 { .ival = "sha512",
2171 .oval = VERIFY_SHA512,
2172 .help = "Use sha512 checksums for verification",
2173 },
7437ee87
SL
2174 { .ival = "meta",
2175 .oval = VERIFY_META,
2176 .help = "Use io information",
2177 },
36690c9b
JA
2178 {
2179 .ival = "null",
2180 .oval = VERIFY_NULL,
2181 .help = "Pretend to verify",
2182 },
214e1eca
JA
2183 },
2184 },
005c565a
JA
2185 {
2186 .name = "do_verify",
e8b0e958 2187 .lname = "Perform verify step",
68e1f29a 2188 .type = FIO_OPT_BOOL,
005c565a
JA
2189 .off1 = td_var_offset(do_verify),
2190 .help = "Run verification stage after write",
2191 .def = "1",
2192 .parent = "verify",
d71c154c 2193 .hide = 1,
e8b0e958
JA
2194 .category = FIO_OPT_C_IO,
2195 .group = FIO_OPT_G_VERIFY,
005c565a 2196 },
160b966d
JA
2197 {
2198 .name = "verifysort",
e8b0e958 2199 .lname = "Verify sort",
160b966d
JA
2200 .type = FIO_OPT_BOOL,
2201 .off1 = td_var_offset(verifysort),
2202 .help = "Sort written verify blocks for read back",
2203 .def = "1",
c83f2df1 2204 .parent = "verify",
d71c154c 2205 .hide = 1,
e8b0e958
JA
2206 .category = FIO_OPT_C_IO,
2207 .group = FIO_OPT_G_VERIFY,
160b966d 2208 },
1ae83d45
JA
2209 {
2210 .name = "verifysort_nr",
2211 .type = FIO_OPT_INT,
2212 .off1 = td_var_offset(verifysort_nr),
2213 .help = "Pre-load and sort verify blocks for a read workload",
2214 .minval = 0,
2215 .maxval = 131072,
2216 .def = "1024",
2217 .parent = "verify",
836fcc0f
JA
2218 .category = FIO_OPT_C_IO,
2219 .group = FIO_OPT_G_VERIFY,
1ae83d45 2220 },
3f9f4e26 2221 {
a59e170d 2222 .name = "verify_interval",
e8b0e958 2223 .lname = "Verify interval",
e01b22b8 2224 .type = FIO_OPT_INT,
a59e170d 2225 .off1 = td_var_offset(verify_interval),
819a9680 2226 .minval = 2 * sizeof(struct verify_header),
a59e170d 2227 .help = "Store verify buffer header every N bytes",
afdf9352 2228 .parent = "verify",
d71c154c 2229 .hide = 1,
20eb06bd 2230 .interval = 2 * sizeof(struct verify_header),
e8b0e958
JA
2231 .category = FIO_OPT_C_IO,
2232 .group = FIO_OPT_G_VERIFY,
3f9f4e26 2233 },
546a9142 2234 {
a59e170d 2235 .name = "verify_offset",
e8b0e958 2236 .lname = "Verify offset",
e01b22b8 2237 .type = FIO_OPT_INT,
a59e170d 2238 .help = "Offset verify header location by N bytes",
203160d5
JA
2239 .off1 = td_var_offset(verify_offset),
2240 .minval = sizeof(struct verify_header),
afdf9352 2241 .parent = "verify",
d71c154c 2242 .hide = 1,
e8b0e958
JA
2243 .category = FIO_OPT_C_IO,
2244 .group = FIO_OPT_G_VERIFY,
546a9142 2245 },
e28218f3
SL
2246 {
2247 .name = "verify_pattern",
e8b0e958 2248 .lname = "Verify pattern",
0e92f873 2249 .type = FIO_OPT_STR,
e28218f3
SL
2250 .cb = str_verify_pattern_cb,
2251 .help = "Fill pattern for IO buffers",
2252 .parent = "verify",
d71c154c 2253 .hide = 1,
e8b0e958
JA
2254 .category = FIO_OPT_C_IO,
2255 .group = FIO_OPT_G_VERIFY,
e28218f3 2256 },
a12a3b4d
JA
2257 {
2258 .name = "verify_fatal",
e8b0e958 2259 .lname = "Verify fatal",
68e1f29a 2260 .type = FIO_OPT_BOOL,
a12a3b4d
JA
2261 .off1 = td_var_offset(verify_fatal),
2262 .def = "0",
2263 .help = "Exit on a single verify failure, don't continue",
2264 .parent = "verify",
d71c154c 2265 .hide = 1,
e8b0e958
JA
2266 .category = FIO_OPT_C_IO,
2267 .group = FIO_OPT_G_VERIFY,
a12a3b4d 2268 },
b463e936
JA
2269 {
2270 .name = "verify_dump",
e8b0e958 2271 .lname = "Verify dump",
b463e936
JA
2272 .type = FIO_OPT_BOOL,
2273 .off1 = td_var_offset(verify_dump),
ef71e317 2274 .def = "0",
b463e936
JA
2275 .help = "Dump contents of good and bad blocks on failure",
2276 .parent = "verify",
d71c154c 2277 .hide = 1,
e8b0e958
JA
2278 .category = FIO_OPT_C_IO,
2279 .group = FIO_OPT_G_VERIFY,
b463e936 2280 },
e8462bd8
JA
2281 {
2282 .name = "verify_async",
e8b0e958 2283 .lname = "Verify asynchronously",
e8462bd8
JA
2284 .type = FIO_OPT_INT,
2285 .off1 = td_var_offset(verify_async),
2286 .def = "0",
2287 .help = "Number of async verifier threads to use",
2288 .parent = "verify",
d71c154c 2289 .hide = 1,
e8b0e958
JA
2290 .category = FIO_OPT_C_IO,
2291 .group = FIO_OPT_G_VERIFY,
e8462bd8 2292 },
9e144189
JA
2293 {
2294 .name = "verify_backlog",
e8b0e958 2295 .lname = "Verify backlog",
9e144189
JA
2296 .type = FIO_OPT_STR_VAL,
2297 .off1 = td_var_offset(verify_backlog),
2298 .help = "Verify after this number of blocks are written",
2299 .parent = "verify",
d71c154c 2300 .hide = 1,
e8b0e958
JA
2301 .category = FIO_OPT_C_IO,
2302 .group = FIO_OPT_G_VERIFY,
9e144189
JA
2303 },
2304 {
2305 .name = "verify_backlog_batch",
e8b0e958 2306 .lname = "Verify backlog batch",
9e144189
JA
2307 .type = FIO_OPT_INT,
2308 .off1 = td_var_offset(verify_batch),
2309 .help = "Verify this number of IO blocks",
0d29de83 2310 .parent = "verify",
d71c154c 2311 .hide = 1,
e8b0e958
JA
2312 .category = FIO_OPT_C_IO,
2313 .group = FIO_OPT_G_VERIFY,
9e144189 2314 },
e8462bd8
JA
2315#ifdef FIO_HAVE_CPU_AFFINITY
2316 {
2317 .name = "verify_async_cpus",
e8b0e958 2318 .lname = "Async verify CPUs",
e8462bd8
JA
2319 .type = FIO_OPT_STR,
2320 .cb = str_verify_cpus_allowed_cb,
2321 .help = "Set CPUs allowed for async verify threads",
2322 .parent = "verify_async",
d71c154c 2323 .hide = 1,
e8b0e958
JA
2324 .category = FIO_OPT_C_IO,
2325 .group = FIO_OPT_G_VERIFY,
e8462bd8 2326 },
0d29de83 2327#endif
51aa2da8
JA
2328 {
2329 .name = "experimental_verify",
2330 .off1 = td_var_offset(experimental_verify),
2331 .type = FIO_OPT_BOOL,
b31eaac9 2332 .help = "Enable experimental verification",
836fcc0f
JA
2333 .category = FIO_OPT_C_IO,
2334 .group = FIO_OPT_G_VERIFY,
51aa2da8 2335 },
0d29de83
JA
2336#ifdef FIO_HAVE_TRIM
2337 {
2338 .name = "trim_percentage",
e8b0e958 2339 .lname = "Trim percentage",
0d29de83 2340 .type = FIO_OPT_INT,
203160d5 2341 .off1 = td_var_offset(trim_percentage),
20eb06bd 2342 .minval = 0,
0d29de83
JA
2343 .maxval = 100,
2344 .help = "Number of verify blocks to discard/trim",
2345 .parent = "verify",
2346 .def = "0",
20eb06bd 2347 .interval = 1,
d71c154c 2348 .hide = 1,
e8b0e958
JA
2349 .category = FIO_OPT_C_IO,
2350 .group = FIO_OPT_G_TRIM,
0d29de83
JA
2351 },
2352 {
2353 .name = "trim_verify_zero",
e8b0e958 2354 .lname = "Verify trim zero",
20eb06bd 2355 .type = FIO_OPT_BOOL,
0d29de83
JA
2356 .help = "Verify that trim/discarded blocks are returned as zeroes",
2357 .off1 = td_var_offset(trim_zero),
2358 .parent = "trim_percentage",
d71c154c 2359 .hide = 1,
0d29de83 2360 .def = "1",
e8b0e958
JA
2361 .category = FIO_OPT_C_IO,
2362 .group = FIO_OPT_G_TRIM,
0d29de83
JA
2363 },
2364 {
2365 .name = "trim_backlog",
e8b0e958 2366 .lname = "Trim backlog",
0d29de83
JA
2367 .type = FIO_OPT_STR_VAL,
2368 .off1 = td_var_offset(trim_backlog),
2369 .help = "Trim after this number of blocks are written",
2370 .parent = "trim_percentage",
d71c154c 2371 .hide = 1,
20eb06bd 2372 .interval = 1,
e8b0e958
JA
2373 .category = FIO_OPT_C_IO,
2374 .group = FIO_OPT_G_TRIM,
0d29de83
JA
2375 },
2376 {
2377 .name = "trim_backlog_batch",
e8b0e958 2378 .lname = "Trim backlog batch",
0d29de83
JA
2379 .type = FIO_OPT_INT,
2380 .off1 = td_var_offset(trim_batch),
2381 .help = "Trim this number of IO blocks",
2382 .parent = "trim_percentage",
d71c154c 2383 .hide = 1,
20eb06bd 2384 .interval = 1,
e8b0e958
JA
2385 .category = FIO_OPT_C_IO,
2386 .group = FIO_OPT_G_TRIM,
0d29de83 2387 },
e8462bd8 2388#endif
214e1eca
JA
2389 {
2390 .name = "write_iolog",
e8b0e958 2391 .lname = "Write I/O log",
214e1eca
JA
2392 .type = FIO_OPT_STR_STORE,
2393 .off1 = td_var_offset(write_iolog_file),
2394 .help = "Store IO pattern to file",
e8b0e958
JA
2395 .category = FIO_OPT_C_IO,
2396 .group = FIO_OPT_G_IOLOG,
214e1eca
JA
2397 },
2398 {
2399 .name = "read_iolog",
e8b0e958 2400 .lname = "Read I/O log",
214e1eca
JA
2401 .type = FIO_OPT_STR_STORE,
2402 .off1 = td_var_offset(read_iolog_file),
2403 .help = "Playback IO pattern from file",
e8b0e958
JA
2404 .category = FIO_OPT_C_IO,
2405 .group = FIO_OPT_G_IOLOG,
214e1eca 2406 },
64bbb865
DN
2407 {
2408 .name = "replay_no_stall",
e8b0e958 2409 .lname = "Don't stall on replay",
20eb06bd 2410 .type = FIO_OPT_BOOL,
64bbb865
DN
2411 .off1 = td_var_offset(no_stall),
2412 .def = "0",
87e7a972 2413 .parent = "read_iolog",
d71c154c 2414 .hide = 1,
64bbb865 2415 .help = "Playback IO pattern file as fast as possible without stalls",
e8b0e958
JA
2416 .category = FIO_OPT_C_IO,
2417 .group = FIO_OPT_G_IOLOG,
64bbb865 2418 },
d1c46c04
DN
2419 {
2420 .name = "replay_redirect",
e8b0e958 2421 .lname = "Redirect device for replay",
d1c46c04
DN
2422 .type = FIO_OPT_STR_STORE,
2423 .off1 = td_var_offset(replay_redirect),
2424 .parent = "read_iolog",
d71c154c 2425 .hide = 1,
d1c46c04 2426 .help = "Replay all I/O onto this device, regardless of trace device",
e8b0e958
JA
2427 .category = FIO_OPT_C_IO,
2428 .group = FIO_OPT_G_IOLOG,
d1c46c04 2429 },
214e1eca
JA
2430 {
2431 .name = "exec_prerun",
e8b0e958 2432 .lname = "Pre-execute runnable",
214e1eca
JA
2433 .type = FIO_OPT_STR_STORE,
2434 .off1 = td_var_offset(exec_prerun),
2435 .help = "Execute this file prior to running job",
e8b0e958
JA
2436 .category = FIO_OPT_C_GENERAL,
2437 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2438 },
2439 {
2440 .name = "exec_postrun",
e8b0e958 2441 .lname = "Post-execute runnable",
214e1eca
JA
2442 .type = FIO_OPT_STR_STORE,
2443 .off1 = td_var_offset(exec_postrun),
2444 .help = "Execute this file after running job",
e8b0e958
JA
2445 .category = FIO_OPT_C_GENERAL,
2446 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2447 },
2448#ifdef FIO_HAVE_IOSCHED_SWITCH
2449 {
2450 .name = "ioscheduler",
e8b0e958 2451 .lname = "I/O scheduler",
214e1eca
JA
2452 .type = FIO_OPT_STR_STORE,
2453 .off1 = td_var_offset(ioscheduler),
2454 .help = "Use this IO scheduler on the backing device",
e8b0e958
JA
2455 .category = FIO_OPT_C_FILE,
2456 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2457 },
2458#endif
2459 {
2460 .name = "zonesize",
e8b0e958 2461 .lname = "Zone size",
214e1eca
JA
2462 .type = FIO_OPT_STR_VAL,
2463 .off1 = td_var_offset(zone_size),
ed335855
SN
2464 .help = "Amount of data to read per zone",
2465 .def = "0",
20eb06bd 2466 .interval = 1024 * 1024,
e8b0e958
JA
2467 .category = FIO_OPT_C_IO,
2468 .group = FIO_OPT_G_ZONE,
ed335855
SN
2469 },
2470 {
2471 .name = "zonerange",
e8b0e958 2472 .lname = "Zone range",
ed335855
SN
2473 .type = FIO_OPT_STR_VAL,
2474 .off1 = td_var_offset(zone_range),
214e1eca
JA
2475 .help = "Give size of an IO zone",
2476 .def = "0",
20eb06bd 2477 .interval = 1024 * 1024,
e8b0e958
JA
2478 .category = FIO_OPT_C_IO,
2479 .group = FIO_OPT_G_ZONE,
214e1eca
JA
2480 },
2481 {
2482 .name = "zoneskip",
e8b0e958 2483 .lname = "Zone skip",
214e1eca
JA
2484 .type = FIO_OPT_STR_VAL,
2485 .off1 = td_var_offset(zone_skip),
2486 .help = "Space between IO zones",
2487 .def = "0",
20eb06bd 2488 .interval = 1024 * 1024,
e8b0e958
JA
2489 .category = FIO_OPT_C_IO,
2490 .group = FIO_OPT_G_ZONE,
214e1eca
JA
2491 },
2492 {
2493 .name = "lockmem",
e8b0e958 2494 .lname = "Lock memory",
214e1eca 2495 .type = FIO_OPT_STR_VAL,
1b79a070 2496 .off1 = td_var_offset(lockmem),
81c6b6cd 2497 .help = "Lock down this amount of memory (per worker)",
214e1eca 2498 .def = "0",
20eb06bd 2499 .interval = 1024 * 1024,
e8b0e958
JA
2500 .category = FIO_OPT_C_GENERAL,
2501 .group = FIO_OPT_G_INVALID,
214e1eca 2502 },
214e1eca
JA
2503 {
2504 .name = "rwmixread",
e8b0e958 2505 .lname = "Read/write mix read",
214e1eca 2506 .type = FIO_OPT_INT,
cb499fc4 2507 .cb = str_rwmix_read_cb,
214e1eca
JA
2508 .maxval = 100,
2509 .help = "Percentage of mixed workload that is reads",
2510 .def = "50",
20eb06bd 2511 .interval = 5,
90265353 2512 .inverse = "rwmixwrite",
e8b0e958
JA
2513 .category = FIO_OPT_C_IO,
2514 .group = FIO_OPT_G_RWMIX,
214e1eca
JA
2515 },
2516 {
2517 .name = "rwmixwrite",
e8b0e958 2518 .lname = "Read/write mix write",
214e1eca 2519 .type = FIO_OPT_INT,
cb499fc4 2520 .cb = str_rwmix_write_cb,
214e1eca
JA
2521 .maxval = 100,
2522 .help = "Percentage of mixed workload that is writes",
2523 .def = "50",
20eb06bd 2524 .interval = 5,
90265353 2525 .inverse = "rwmixread",
e8b0e958
JA
2526 .category = FIO_OPT_C_IO,
2527 .group = FIO_OPT_G_RWMIX,
214e1eca 2528 },
afdf9352
JA
2529 {
2530 .name = "rwmixcycle",
e8b0e958 2531 .lname = "Read/write mix cycle",
15ca150e 2532 .type = FIO_OPT_DEPRECATED,
e8b0e958
JA
2533 .category = FIO_OPT_C_IO,
2534 .group = FIO_OPT_G_RWMIX,
afdf9352 2535 },
214e1eca
JA
2536 {
2537 .name = "nice",
e8b0e958 2538 .lname = "Nice",
214e1eca
JA
2539 .type = FIO_OPT_INT,
2540 .off1 = td_var_offset(nice),
2541 .help = "Set job CPU nice value",
2542 .minval = -19,
2543 .maxval = 20,
2544 .def = "0",
20eb06bd 2545 .interval = 1,
e8b0e958 2546 .category = FIO_OPT_C_GENERAL,
10860056 2547 .group = FIO_OPT_G_CRED,
214e1eca
JA
2548 },
2549#ifdef FIO_HAVE_IOPRIO
2550 {
2551 .name = "prio",
e8b0e958 2552 .lname = "I/O nice priority",
214e1eca 2553 .type = FIO_OPT_INT,
28727df7 2554 .off1 = td_var_offset(ioprio),
214e1eca
JA
2555 .help = "Set job IO priority value",
2556 .minval = 0,
2557 .maxval = 7,
20eb06bd 2558 .interval = 1,
e8b0e958 2559 .category = FIO_OPT_C_GENERAL,
10860056 2560 .group = FIO_OPT_G_CRED,
214e1eca
JA
2561 },
2562 {
2563 .name = "prioclass",
e8b0e958 2564 .lname = "I/O nice priority class",
214e1eca 2565 .type = FIO_OPT_INT,
28727df7 2566 .off1 = td_var_offset(ioprio_class),
214e1eca
JA
2567 .help = "Set job IO priority class",
2568 .minval = 0,
2569 .maxval = 3,
20eb06bd 2570 .interval = 1,
e8b0e958 2571 .category = FIO_OPT_C_GENERAL,
10860056 2572 .group = FIO_OPT_G_CRED,
214e1eca
JA
2573 },
2574#endif
2575 {
2576 .name = "thinktime",
e8b0e958 2577 .lname = "Thinktime",
214e1eca
JA
2578 .type = FIO_OPT_INT,
2579 .off1 = td_var_offset(thinktime),
2580 .help = "Idle time between IO buffers (usec)",
2581 .def = "0",
e8b0e958 2582 .category = FIO_OPT_C_IO,
3ceb458f 2583 .group = FIO_OPT_G_THINKTIME,
214e1eca
JA
2584 },
2585 {
2586 .name = "thinktime_spin",
e8b0e958 2587 .lname = "Thinktime spin",
214e1eca
JA
2588 .type = FIO_OPT_INT,
2589 .off1 = td_var_offset(thinktime_spin),
2590 .help = "Start think time by spinning this amount (usec)",
2591 .def = "0",
afdf9352 2592 .parent = "thinktime",
d71c154c 2593 .hide = 1,
e8b0e958 2594 .category = FIO_OPT_C_IO,
3ceb458f 2595 .group = FIO_OPT_G_THINKTIME,
214e1eca
JA
2596 },
2597 {
2598 .name = "thinktime_blocks",
e8b0e958 2599 .lname = "Thinktime blocks",
214e1eca
JA
2600 .type = FIO_OPT_INT,
2601 .off1 = td_var_offset(thinktime_blocks),
2602 .help = "IO buffer period between 'thinktime'",
2603 .def = "1",
afdf9352 2604 .parent = "thinktime",
d71c154c 2605 .hide = 1,
e8b0e958 2606 .category = FIO_OPT_C_IO,
3ceb458f 2607 .group = FIO_OPT_G_THINKTIME,
214e1eca
JA
2608 },
2609 {
2610 .name = "rate",
e8b0e958 2611 .lname = "I/O rate",
e01b22b8 2612 .type = FIO_OPT_INT,
6eaf09d6
SL
2613 .off1 = td_var_offset(rate[DDIR_READ]),
2614 .off2 = td_var_offset(rate[DDIR_WRITE]),
2615 .off3 = td_var_offset(rate[DDIR_TRIM]),
214e1eca 2616 .help = "Set bandwidth rate",
e8b0e958
JA
2617 .category = FIO_OPT_C_IO,
2618 .group = FIO_OPT_G_RATE,
214e1eca
JA
2619 },
2620 {
2621 .name = "ratemin",
e8b0e958 2622 .lname = "I/O min rate",
e01b22b8 2623 .type = FIO_OPT_INT,
6eaf09d6
SL
2624 .off1 = td_var_offset(ratemin[DDIR_READ]),
2625 .off2 = td_var_offset(ratemin[DDIR_WRITE]),
2626 .off3 = td_var_offset(ratemin[DDIR_TRIM]),
4e991c23 2627 .help = "Job must meet this rate or it will be shutdown",
afdf9352 2628 .parent = "rate",
d71c154c 2629 .hide = 1,
e8b0e958
JA
2630 .category = FIO_OPT_C_IO,
2631 .group = FIO_OPT_G_RATE,
4e991c23
JA
2632 },
2633 {
2634 .name = "rate_iops",
e8b0e958 2635 .lname = "I/O rate IOPS",
e01b22b8 2636 .type = FIO_OPT_INT,
6eaf09d6
SL
2637 .off1 = td_var_offset(rate_iops[DDIR_READ]),
2638 .off2 = td_var_offset(rate_iops[DDIR_WRITE]),
2639 .off3 = td_var_offset(rate_iops[DDIR_TRIM]),
4e991c23 2640 .help = "Limit IO used to this number of IO operations/sec",
d71c154c 2641 .hide = 1,
e8b0e958
JA
2642 .category = FIO_OPT_C_IO,
2643 .group = FIO_OPT_G_RATE,
4e991c23
JA
2644 },
2645 {
2646 .name = "rate_iops_min",
e8b0e958 2647 .lname = "I/O min rate IOPS",
e01b22b8 2648 .type = FIO_OPT_INT,
6eaf09d6
SL
2649 .off1 = td_var_offset(rate_iops_min[DDIR_READ]),
2650 .off2 = td_var_offset(rate_iops_min[DDIR_WRITE]),
2651 .off3 = td_var_offset(rate_iops_min[DDIR_TRIM]),
03e20d68 2652 .help = "Job must meet this rate or it will be shut down",
afdf9352 2653 .parent = "rate_iops",
d71c154c 2654 .hide = 1,
e8b0e958
JA
2655 .category = FIO_OPT_C_IO,
2656 .group = FIO_OPT_G_RATE,
214e1eca
JA
2657 },
2658 {
2659 .name = "ratecycle",
e8b0e958 2660 .lname = "I/O rate cycle",
214e1eca
JA
2661 .type = FIO_OPT_INT,
2662 .off1 = td_var_offset(ratecycle),
2663 .help = "Window average for rate limits (msec)",
2664 .def = "1000",
afdf9352 2665 .parent = "rate",
d71c154c 2666 .hide = 1,
e8b0e958
JA
2667 .category = FIO_OPT_C_IO,
2668 .group = FIO_OPT_G_RATE,
214e1eca 2669 },
15501535
JA
2670 {
2671 .name = "max_latency",
2672 .type = FIO_OPT_INT,
2673 .off1 = td_var_offset(max_latency),
2674 .help = "Maximum tolerated IO latency (usec)",
1e5324e7 2675 .category = FIO_OPT_C_IO,
3e260a46
JA
2676 .group = FIO_OPT_G_LATPROF,
2677 },
2678 {
2679 .name = "latency_target",
2680 .lname = "Latency Target (usec)",
2681 .type = FIO_OPT_STR_VAL_TIME,
2682 .off1 = td_var_offset(latency_target),
2683 .help = "Ramp to max queue depth supporting this latency",
2684 .category = FIO_OPT_C_IO,
2685 .group = FIO_OPT_G_LATPROF,
2686 },
2687 {
2688 .name = "latency_window",
2689 .lname = "Latency Window (usec)",
2690 .type = FIO_OPT_STR_VAL_TIME,
2691 .off1 = td_var_offset(latency_window),
2692 .help = "Time to sustain latency_target",
2693 .category = FIO_OPT_C_IO,
2694 .group = FIO_OPT_G_LATPROF,
2695 },
2696 {
2697 .name = "latency_percentile",
2698 .lname = "Latency Percentile",
2699 .type = FIO_OPT_FLOAT_LIST,
2700 .off1 = td_var_offset(latency_percentile),
2701 .help = "Percentile of IOs must be below latency_target",
2702 .def = "100",
2703 .maxlen = 1,
2704 .minfp = 0.0,
2705 .maxfp = 100.0,
2706 .category = FIO_OPT_C_IO,
2707 .group = FIO_OPT_G_LATPROF,
15501535 2708 },
214e1eca
JA
2709 {
2710 .name = "invalidate",
e8b0e958 2711 .lname = "Cache invalidate",
214e1eca
JA
2712 .type = FIO_OPT_BOOL,
2713 .off1 = td_var_offset(invalidate_cache),
2714 .help = "Invalidate buffer/page cache prior to running job",
2715 .def = "1",
e8b0e958 2716 .category = FIO_OPT_C_IO,
3ceb458f 2717 .group = FIO_OPT_G_IO_TYPE,
214e1eca
JA
2718 },
2719 {
2720 .name = "sync",
e8b0e958 2721 .lname = "Synchronous I/O",
214e1eca
JA
2722 .type = FIO_OPT_BOOL,
2723 .off1 = td_var_offset(sync_io),
2724 .help = "Use O_SYNC for buffered writes",
2725 .def = "0",
67a1000f 2726 .parent = "buffered",
d71c154c 2727 .hide = 1,
e8b0e958 2728 .category = FIO_OPT_C_IO,
3ceb458f 2729 .group = FIO_OPT_G_IO_TYPE,
214e1eca 2730 },
214e1eca
JA
2731 {
2732 .name = "create_serialize",
e8b0e958 2733 .lname = "Create serialize",
214e1eca
JA
2734 .type = FIO_OPT_BOOL,
2735 .off1 = td_var_offset(create_serialize),
2736 .help = "Serialize creating of job files",
2737 .def = "1",
e8b0e958
JA
2738 .category = FIO_OPT_C_FILE,
2739 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2740 },
2741 {
2742 .name = "create_fsync",
e8b0e958 2743 .lname = "Create fsync",
214e1eca
JA
2744 .type = FIO_OPT_BOOL,
2745 .off1 = td_var_offset(create_fsync),
03e20d68 2746 .help = "fsync file after creation",
214e1eca 2747 .def = "1",
e8b0e958
JA
2748 .category = FIO_OPT_C_FILE,
2749 .group = FIO_OPT_G_INVALID,
214e1eca 2750 },
814452bd
JA
2751 {
2752 .name = "create_on_open",
e8b0e958 2753 .lname = "Create on open",
814452bd
JA
2754 .type = FIO_OPT_BOOL,
2755 .off1 = td_var_offset(create_on_open),
2756 .help = "Create files when they are opened for IO",
2757 .def = "0",
e8b0e958
JA
2758 .category = FIO_OPT_C_FILE,
2759 .group = FIO_OPT_G_INVALID,
814452bd 2760 },
25460cf6
JA
2761 {
2762 .name = "create_only",
2763 .type = FIO_OPT_BOOL,
2764 .off1 = td_var_offset(create_only),
2765 .help = "Only perform file creation phase",
d17fda71 2766 .category = FIO_OPT_C_FILE,
25460cf6
JA
2767 .def = "0",
2768 },
0b9d69ec 2769 {
afad68f7 2770 .name = "pre_read",
e8b0e958 2771 .lname = "Pre-read files",
afad68f7
ZY
2772 .type = FIO_OPT_BOOL,
2773 .off1 = td_var_offset(pre_read),
03e20d68 2774 .help = "Pre-read files before starting official testing",
afad68f7 2775 .def = "0",
e8b0e958
JA
2776 .category = FIO_OPT_C_FILE,
2777 .group = FIO_OPT_G_INVALID,
afad68f7 2778 },
214e1eca
JA
2779#ifdef FIO_HAVE_CPU_AFFINITY
2780 {
2781 .name = "cpumask",
e8b0e958 2782 .lname = "CPU mask",
214e1eca
JA
2783 .type = FIO_OPT_INT,
2784 .cb = str_cpumask_cb,
2785 .help = "CPU affinity mask",
e8b0e958 2786 .category = FIO_OPT_C_GENERAL,
10860056 2787 .group = FIO_OPT_G_CRED,
214e1eca 2788 },
d2e268b0
JA
2789 {
2790 .name = "cpus_allowed",
e8b0e958 2791 .lname = "CPUs allowed",
d2e268b0
JA
2792 .type = FIO_OPT_STR,
2793 .cb = str_cpus_allowed_cb,
2794 .help = "Set CPUs allowed",
e8b0e958 2795 .category = FIO_OPT_C_GENERAL,
10860056 2796 .group = FIO_OPT_G_CRED,
d2e268b0 2797 },
d0b937ed 2798#endif
67bf9823 2799#ifdef CONFIG_LIBNUMA
d0b937ed
YR
2800 {
2801 .name = "numa_cpu_nodes",
2802 .type = FIO_OPT_STR,
2803 .cb = str_numa_cpunodes_cb,
2804 .help = "NUMA CPU nodes bind",
6be54b2d
JA
2805 .category = FIO_OPT_C_GENERAL,
2806 .group = FIO_OPT_G_INVALID,
d0b937ed
YR
2807 },
2808 {
2809 .name = "numa_mem_policy",
2810 .type = FIO_OPT_STR,
2811 .cb = str_numa_mpol_cb,
2812 .help = "NUMA memory policy setup",
6be54b2d
JA
2813 .category = FIO_OPT_C_GENERAL,
2814 .group = FIO_OPT_G_INVALID,
d0b937ed 2815 },
214e1eca
JA
2816#endif
2817 {
2818 .name = "end_fsync",
e8b0e958 2819 .lname = "End fsync",
214e1eca
JA
2820 .type = FIO_OPT_BOOL,
2821 .off1 = td_var_offset(end_fsync),
2822 .help = "Include fsync at the end of job",
2823 .def = "0",
e8b0e958
JA
2824 .category = FIO_OPT_C_FILE,
2825 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2826 },
2827 {
2828 .name = "fsync_on_close",
e8b0e958 2829 .lname = "Fsync on close",
214e1eca
JA
2830 .type = FIO_OPT_BOOL,
2831 .off1 = td_var_offset(fsync_on_close),
2832 .help = "fsync files on close",
2833 .def = "0",
e8b0e958
JA
2834 .category = FIO_OPT_C_FILE,
2835 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2836 },
2837 {
2838 .name = "unlink",
e8b0e958 2839 .lname = "Unlink file",
214e1eca
JA
2840 .type = FIO_OPT_BOOL,
2841 .off1 = td_var_offset(unlink),
2842 .help = "Unlink created files after job has completed",
2843 .def = "0",
e8b0e958
JA
2844 .category = FIO_OPT_C_FILE,
2845 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2846 },
2847 {
2848 .name = "exitall",
e8b0e958 2849 .lname = "Exit-all on terminate",
214e1eca
JA
2850 .type = FIO_OPT_STR_SET,
2851 .cb = str_exitall_cb,
2852 .help = "Terminate all jobs when one exits",
e8b0e958 2853 .category = FIO_OPT_C_GENERAL,
a1f6afec 2854 .group = FIO_OPT_G_PROCESS,
214e1eca
JA
2855 },
2856 {
2857 .name = "stonewall",
e8b0e958 2858 .lname = "Wait for previous",
d392365e 2859 .alias = "wait_for_previous",
214e1eca
JA
2860 .type = FIO_OPT_STR_SET,
2861 .off1 = td_var_offset(stonewall),
2862 .help = "Insert a hard barrier between this job and previous",
e8b0e958 2863 .category = FIO_OPT_C_GENERAL,
a1f6afec 2864 .group = FIO_OPT_G_PROCESS,
214e1eca 2865 },
b3d62a75
JA
2866 {
2867 .name = "new_group",
e8b0e958 2868 .lname = "New group",
b3d62a75
JA
2869 .type = FIO_OPT_STR_SET,
2870 .off1 = td_var_offset(new_group),
2871 .help = "Mark the start of a new group (for reporting)",
e8b0e958 2872 .category = FIO_OPT_C_GENERAL,
a1f6afec 2873 .group = FIO_OPT_G_PROCESS,
b3d62a75 2874 },
214e1eca
JA
2875 {
2876 .name = "thread",
e8b0e958 2877 .lname = "Thread",
214e1eca
JA
2878 .type = FIO_OPT_STR_SET,
2879 .off1 = td_var_offset(use_thread),
20eb06bd 2880 .help = "Use threads instead of processes",
e8b0e958 2881 .category = FIO_OPT_C_GENERAL,
a1f6afec 2882 .group = FIO_OPT_G_PROCESS,
214e1eca
JA
2883 },
2884 {
2885 .name = "write_bw_log",
e8b0e958 2886 .lname = "Write bandwidth log",
203160d5
JA
2887 .type = FIO_OPT_STR_STORE,
2888 .off1 = td_var_offset(bw_log_file),
214e1eca 2889 .help = "Write log of bandwidth during run",
e8b0e958
JA
2890 .category = FIO_OPT_C_LOG,
2891 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2892 },
2893 {
2894 .name = "write_lat_log",
e8b0e958 2895 .lname = "Write latency log",
203160d5
JA
2896 .type = FIO_OPT_STR_STORE,
2897 .off1 = td_var_offset(lat_log_file),
214e1eca 2898 .help = "Write log of latency during run",
e8b0e958
JA
2899 .category = FIO_OPT_C_LOG,
2900 .group = FIO_OPT_G_INVALID,
214e1eca 2901 },
c8eeb9df
JA
2902 {
2903 .name = "write_iops_log",
e8b0e958 2904 .lname = "Write IOPS log",
577c83bd 2905 .type = FIO_OPT_STR_STORE,
203160d5 2906 .off1 = td_var_offset(iops_log_file),
c8eeb9df 2907 .help = "Write log of IOPS during run",
e8b0e958
JA
2908 .category = FIO_OPT_C_LOG,
2909 .group = FIO_OPT_G_INVALID,
c8eeb9df 2910 },
b8bc8cba
JA
2911 {
2912 .name = "log_avg_msec",
e8b0e958 2913 .lname = "Log averaging (msec)",
b8bc8cba
JA
2914 .type = FIO_OPT_INT,
2915 .off1 = td_var_offset(log_avg_msec),
2916 .help = "Average bw/iops/lat logs over this period of time",
2917 .def = "0",
e8b0e958
JA
2918 .category = FIO_OPT_C_LOG,
2919 .group = FIO_OPT_G_INVALID,
b8bc8cba 2920 },
c504ee55
JA
2921 {
2922 .name = "bwavgtime",
2923 .lname = "Bandwidth average time",
2924 .type = FIO_OPT_INT,
2925 .off1 = td_var_offset(bw_avg_time),
2926 .help = "Time window over which to calculate bandwidth"
2927 " (msec)",
2928 .def = "500",
2929 .parent = "write_bw_log",
2930 .hide = 1,
2931 .interval = 100,
2932 .category = FIO_OPT_C_LOG,
2933 .group = FIO_OPT_G_INVALID,
2934 },
2935 {
2936 .name = "iopsavgtime",
2937 .lname = "IOPS average time",
2938 .type = FIO_OPT_INT,
2939 .off1 = td_var_offset(iops_avg_time),
2940 .help = "Time window over which to calculate IOPS (msec)",
2941 .def = "500",
2942 .parent = "write_iops_log",
2943 .hide = 1,
2944 .interval = 100,
2945 .category = FIO_OPT_C_LOG,
2946 .group = FIO_OPT_G_INVALID,
2947 },
214e1eca
JA
2948 {
2949 .name = "group_reporting",
e8b0e958 2950 .lname = "Group reporting",
d2507043 2951 .type = FIO_OPT_STR_SET,
214e1eca
JA
2952 .off1 = td_var_offset(group_reporting),
2953 .help = "Do reporting on a per-group basis",
10860056 2954 .category = FIO_OPT_C_STAT,
e8b0e958 2955 .group = FIO_OPT_G_INVALID,
214e1eca 2956 },
e9459e5a
JA
2957 {
2958 .name = "zero_buffers",
e8b0e958 2959 .lname = "Zero I/O buffers",
e9459e5a
JA
2960 .type = FIO_OPT_STR_SET,
2961 .off1 = td_var_offset(zero_buffers),
2962 .help = "Init IO buffers to all zeroes",
e8b0e958 2963 .category = FIO_OPT_C_IO,
3ceb458f 2964 .group = FIO_OPT_G_IO_BUF,
e9459e5a 2965 },
5973cafb
JA
2966 {
2967 .name = "refill_buffers",
e8b0e958 2968 .lname = "Refill I/O buffers",
5973cafb
JA
2969 .type = FIO_OPT_STR_SET,
2970 .off1 = td_var_offset(refill_buffers),
2971 .help = "Refill IO buffers on every IO submit",
e8b0e958 2972 .category = FIO_OPT_C_IO,
3ceb458f 2973 .group = FIO_OPT_G_IO_BUF,
5973cafb 2974 },
fd68418e
JA
2975 {
2976 .name = "scramble_buffers",
e8b0e958 2977 .lname = "Scramble I/O buffers",
fd68418e
JA
2978 .type = FIO_OPT_BOOL,
2979 .off1 = td_var_offset(scramble_buffers),
2980 .help = "Slightly scramble buffers on every IO submit",
2981 .def = "1",
e8b0e958 2982 .category = FIO_OPT_C_IO,
3ceb458f 2983 .group = FIO_OPT_G_IO_BUF,
fd68418e 2984 },
ce35b1ec
JA
2985 {
2986 .name = "buffer_pattern",
2987 .lname = "Buffer pattern",
2988 .type = FIO_OPT_STR,
2989 .cb = str_buffer_pattern_cb,
2990 .help = "Fill pattern for IO buffers",
2991 .category = FIO_OPT_C_IO,
2992 .group = FIO_OPT_G_IO_BUF,
2993 },
9c42684e
JA
2994 {
2995 .name = "buffer_compress_percentage",
e8b0e958 2996 .lname = "Buffer compression percentage",
9c42684e
JA
2997 .type = FIO_OPT_INT,
2998 .off1 = td_var_offset(compress_percentage),
2999 .maxval = 100,
3000 .minval = 1,
3001 .help = "How compressible the buffer is (approximately)",
20eb06bd 3002 .interval = 5,
e8b0e958 3003 .category = FIO_OPT_C_IO,
3ceb458f 3004 .group = FIO_OPT_G_IO_BUF,
9c42684e 3005 },
f97a43a1
JA
3006 {
3007 .name = "buffer_compress_chunk",
e8b0e958 3008 .lname = "Buffer compression chunk size",
f97a43a1
JA
3009 .type = FIO_OPT_INT,
3010 .off1 = td_var_offset(compress_chunk),
207b18e4 3011 .parent = "buffer_compress_percentage",
d71c154c 3012 .hide = 1,
f97a43a1 3013 .help = "Size of compressible region in buffer",
20eb06bd 3014 .interval = 256,
e8b0e958 3015 .category = FIO_OPT_C_IO,
3ceb458f 3016 .group = FIO_OPT_G_IO_BUF,
f97a43a1 3017 },
83349190
YH
3018 {
3019 .name = "clat_percentiles",
e8b0e958 3020 .lname = "Completion latency percentiles",
83349190
YH
3021 .type = FIO_OPT_BOOL,
3022 .off1 = td_var_offset(clat_percentiles),
3023 .help = "Enable the reporting of completion latency percentiles",
467b35ed 3024 .def = "1",
e8b0e958
JA
3025 .category = FIO_OPT_C_STAT,
3026 .group = FIO_OPT_G_INVALID,
83349190
YH
3027 },
3028 {
3029 .name = "percentile_list",
e8b0e958 3030 .lname = "Completion latency percentile list",
83349190
YH
3031 .type = FIO_OPT_FLOAT_LIST,
3032 .off1 = td_var_offset(percentile_list),
435d195a 3033 .off2 = td_var_offset(percentile_precision),
83349190 3034 .help = "Specify a custom list of percentiles to report",
fd112d34 3035 .def = "1:5:10:20:30:40:50:60:70:80:90:95:99:99.5:99.9:99.95:99.99",
83349190
YH
3036 .maxlen = FIO_IO_U_LIST_MAX_LEN,
3037 .minfp = 0.0,
3038 .maxfp = 100.0,
e8b0e958
JA
3039 .category = FIO_OPT_C_STAT,
3040 .group = FIO_OPT_G_INVALID,
83349190
YH
3041 },
3042
0a839f30
JA
3043#ifdef FIO_HAVE_DISK_UTIL
3044 {
3045 .name = "disk_util",
e8b0e958 3046 .lname = "Disk utilization",
0a839f30
JA
3047 .type = FIO_OPT_BOOL,
3048 .off1 = td_var_offset(do_disk_util),
f66ab3c8 3049 .help = "Log disk utilization statistics",
0a839f30 3050 .def = "1",
e8b0e958
JA
3051 .category = FIO_OPT_C_STAT,
3052 .group = FIO_OPT_G_INVALID,
0a839f30
JA
3053 },
3054#endif
993bf48b
JA
3055 {
3056 .name = "gtod_reduce",
e8b0e958 3057 .lname = "Reduce gettimeofday() calls",
993bf48b
JA
3058 .type = FIO_OPT_BOOL,
3059 .help = "Greatly reduce number of gettimeofday() calls",
3060 .cb = str_gtod_reduce_cb,
3061 .def = "0",
a4ed77fe 3062 .hide_on_set = 1,
e8b0e958
JA
3063 .category = FIO_OPT_C_STAT,
3064 .group = FIO_OPT_G_INVALID,
993bf48b 3065 },
02af0988
JA
3066 {
3067 .name = "disable_lat",
e8b0e958 3068 .lname = "Disable all latency stats",
02af0988
JA
3069 .type = FIO_OPT_BOOL,
3070 .off1 = td_var_offset(disable_lat),
3071 .help = "Disable latency numbers",
3072 .parent = "gtod_reduce",
d71c154c 3073 .hide = 1,
02af0988 3074 .def = "0",
e8b0e958
JA
3075 .category = FIO_OPT_C_STAT,
3076 .group = FIO_OPT_G_INVALID,
02af0988 3077 },
9520ebb9
JA
3078 {
3079 .name = "disable_clat",
e8b0e958 3080 .lname = "Disable completion latency stats",
9520ebb9
JA
3081 .type = FIO_OPT_BOOL,
3082 .off1 = td_var_offset(disable_clat),
3083 .help = "Disable completion latency numbers",
993bf48b 3084 .parent = "gtod_reduce",
d71c154c 3085 .hide = 1,
9520ebb9 3086 .def = "0",
e8b0e958
JA
3087 .category = FIO_OPT_C_STAT,
3088 .group = FIO_OPT_G_INVALID,
9520ebb9
JA
3089 },
3090 {
3091 .name = "disable_slat",
e8b0e958 3092 .lname = "Disable submission latency stats",
9520ebb9
JA
3093 .type = FIO_OPT_BOOL,
3094 .off1 = td_var_offset(disable_slat),
03e20d68 3095 .help = "Disable submission latency numbers",
993bf48b 3096 .parent = "gtod_reduce",
d71c154c 3097 .hide = 1,
9520ebb9 3098 .def = "0",
e8b0e958
JA
3099 .category = FIO_OPT_C_STAT,
3100 .group = FIO_OPT_G_INVALID,
9520ebb9
JA
3101 },
3102 {
3103 .name = "disable_bw_measurement",
e8b0e958 3104 .lname = "Disable bandwidth stats",
9520ebb9
JA
3105 .type = FIO_OPT_BOOL,
3106 .off1 = td_var_offset(disable_bw),
3107 .help = "Disable bandwidth logging",
993bf48b 3108 .parent = "gtod_reduce",
d71c154c 3109 .hide = 1,
9520ebb9 3110 .def = "0",
e8b0e958
JA
3111 .category = FIO_OPT_C_STAT,
3112 .group = FIO_OPT_G_INVALID,
9520ebb9 3113 },
be4ecfdf
JA
3114 {
3115 .name = "gtod_cpu",
e8b0e958 3116 .lname = "Dedicated gettimeofday() CPU",
be4ecfdf
JA
3117 .type = FIO_OPT_INT,
3118 .cb = str_gtod_cpu_cb,
03e20d68 3119 .help = "Set up dedicated gettimeofday() thread on this CPU",
29d43ff9 3120 .verify = gtod_cpu_verify,
e8b0e958 3121 .category = FIO_OPT_C_GENERAL,
10860056 3122 .group = FIO_OPT_G_CLOCK,
be4ecfdf 3123 },
771e58be
JA
3124 {
3125 .name = "unified_rw_reporting",
3126 .type = FIO_OPT_BOOL,
3127 .off1 = td_var_offset(unified_rw_rep),
3128 .help = "Unify reporting across data direction",
3129 .def = "0",
90b7a96d
JA
3130 .category = FIO_OPT_C_GENERAL,
3131 .group = FIO_OPT_G_INVALID,
771e58be 3132 },
f2bba182
RR
3133 {
3134 .name = "continue_on_error",
e8b0e958 3135 .lname = "Continue on error",
06842027 3136 .type = FIO_OPT_STR,
f2bba182 3137 .off1 = td_var_offset(continue_on_error),
03e20d68 3138 .help = "Continue on non-fatal errors during IO",
06842027 3139 .def = "none",
e8b0e958 3140 .category = FIO_OPT_C_GENERAL,
bc3f552f 3141 .group = FIO_OPT_G_ERR,
06842027
SL
3142 .posval = {
3143 { .ival = "none",
3144 .oval = ERROR_TYPE_NONE,
3145 .help = "Exit when an error is encountered",
3146 },
3147 { .ival = "read",
3148 .oval = ERROR_TYPE_READ,
3149 .help = "Continue on read errors only",
3150 },
3151 { .ival = "write",
3152 .oval = ERROR_TYPE_WRITE,
3153 .help = "Continue on write errors only",
3154 },
3155 { .ival = "io",
3156 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
3157 .help = "Continue on any IO errors",
3158 },
3159 { .ival = "verify",
3160 .oval = ERROR_TYPE_VERIFY,
3161 .help = "Continue on verify errors only",
3162 },
3163 { .ival = "all",
3164 .oval = ERROR_TYPE_ANY,
3165 .help = "Continue on all io and verify errors",
3166 },
3167 { .ival = "0",
3168 .oval = ERROR_TYPE_NONE,
3169 .help = "Alias for 'none'",
3170 },
3171 { .ival = "1",
3172 .oval = ERROR_TYPE_ANY,
3173 .help = "Alias for 'all'",
3174 },
3175 },
f2bba182 3176 },
8b28bd41
DM
3177 {
3178 .name = "ignore_error",
3179 .type = FIO_OPT_STR,
3180 .cb = str_ignore_error_cb,
3181 .help = "Set a specific list of errors to ignore",
3182 .parent = "rw",
a94eb99a 3183 .category = FIO_OPT_C_GENERAL,
bc3f552f 3184 .group = FIO_OPT_G_ERR,
8b28bd41
DM
3185 },
3186 {
3187 .name = "error_dump",
3188 .type = FIO_OPT_BOOL,
3189 .off1 = td_var_offset(error_dump),
3190 .def = "0",
3191 .help = "Dump info on each error",
a94eb99a 3192 .category = FIO_OPT_C_GENERAL,
bc3f552f 3193 .group = FIO_OPT_G_ERR,
8b28bd41 3194 },
9ac8a797
JA
3195 {
3196 .name = "profile",
e8b0e958 3197 .lname = "Profile",
79d16311 3198 .type = FIO_OPT_STR_STORE,
9ac8a797 3199 .off1 = td_var_offset(profile),
9ac8a797 3200 .help = "Select a specific builtin performance test",
13fca827 3201 .category = FIO_OPT_C_PROFILE,
e8b0e958 3202 .group = FIO_OPT_G_INVALID,
9ac8a797 3203 },
a696fa2a
JA
3204 {
3205 .name = "cgroup",
e8b0e958 3206 .lname = "Cgroup",
a696fa2a
JA
3207 .type = FIO_OPT_STR_STORE,
3208 .off1 = td_var_offset(cgroup),
3209 .help = "Add job to cgroup of this name",
e8b0e958 3210 .category = FIO_OPT_C_GENERAL,
a1f6afec
JA
3211 .group = FIO_OPT_G_CGROUP,
3212 },
3213 {
3214 .name = "cgroup_nodelete",
3215 .lname = "Cgroup no-delete",
3216 .type = FIO_OPT_BOOL,
3217 .off1 = td_var_offset(cgroup_nodelete),
3218 .help = "Do not delete cgroups after job completion",
3219 .def = "0",
3220 .parent = "cgroup",
3221 .category = FIO_OPT_C_GENERAL,
3222 .group = FIO_OPT_G_CGROUP,
a696fa2a
JA
3223 },
3224 {
3225 .name = "cgroup_weight",
e8b0e958 3226 .lname = "Cgroup weight",
a696fa2a
JA
3227 .type = FIO_OPT_INT,
3228 .off1 = td_var_offset(cgroup_weight),
3229 .help = "Use given weight for cgroup",
3230 .minval = 100,
3231 .maxval = 1000,
a1f6afec 3232 .parent = "cgroup",
e8b0e958 3233 .category = FIO_OPT_C_GENERAL,
a1f6afec 3234 .group = FIO_OPT_G_CGROUP,
7de87099 3235 },
e0b0d892
JA
3236 {
3237 .name = "uid",
e8b0e958 3238 .lname = "User ID",
e0b0d892
JA
3239 .type = FIO_OPT_INT,
3240 .off1 = td_var_offset(uid),
3241 .help = "Run job with this user ID",
e8b0e958 3242 .category = FIO_OPT_C_GENERAL,
10860056 3243 .group = FIO_OPT_G_CRED,
e0b0d892
JA
3244 },
3245 {
3246 .name = "gid",
e8b0e958 3247 .lname = "Group ID",
e0b0d892
JA
3248 .type = FIO_OPT_INT,
3249 .off1 = td_var_offset(gid),
3250 .help = "Run job with this group ID",
e8b0e958 3251 .category = FIO_OPT_C_GENERAL,
10860056 3252 .group = FIO_OPT_G_CRED,
e0b0d892 3253 },
a1f6afec
JA
3254 {
3255 .name = "kb_base",
3256 .lname = "KB Base",
3257 .type = FIO_OPT_INT,
3258 .off1 = td_var_offset(kb_base),
a1f6afec
JA
3259 .prio = 1,
3260 .def = "1024",
ba9c7219
JA
3261 .posval = {
3262 { .ival = "1024",
3263 .oval = 1024,
3264 .help = "Use 1024 as the K base",
3265 },
3266 { .ival = "1000",
3267 .oval = 1000,
3268 .help = "Use 1000 as the K base",
3269 },
3270 },
a1f6afec
JA
3271 .help = "How many bytes per KB for reporting (1000 or 1024)",
3272 .category = FIO_OPT_C_GENERAL,
3273 .group = FIO_OPT_G_INVALID,
3274 },
cf3a0518
JA
3275 {
3276 .name = "unit_base",
ba9c7219 3277 .lname = "Base unit for reporting (Bits or Bytes)",
cf3a0518
JA
3278 .type = FIO_OPT_INT,
3279 .off1 = td_var_offset(unit_base),
cf3a0518 3280 .prio = 1,
71a08258
JA
3281 .posval = {
3282 { .ival = "0",
3283 .oval = 0,
3284 .help = "Auto-detect",
3285 },
3286 { .ival = "8",
3287 .oval = 8,
3288 .help = "Normal (byte based)",
3289 },
3290 { .ival = "1",
3291 .oval = 1,
3292 .help = "Bit based",
3293 },
3294 },
cf3a0518
JA
3295 .help = "Bit multiple of result summary data (8 for byte, 1 for bit)",
3296 .category = FIO_OPT_C_GENERAL,
3297 .group = FIO_OPT_G_INVALID,
3298 },
3ceb458f
JA
3299 {
3300 .name = "hugepage-size",
3301 .lname = "Hugepage size",
3302 .type = FIO_OPT_INT,
3303 .off1 = td_var_offset(hugepage_size),
3304 .help = "When using hugepages, specify size of each page",
3305 .def = __fio_stringify(FIO_HUGE_PAGE),
3306 .interval = 1024 * 1024,
3307 .category = FIO_OPT_C_GENERAL,
3308 .group = FIO_OPT_G_INVALID,
3309 },
9e684a49
DE
3310 {
3311 .name = "flow_id",
e8b0e958 3312 .lname = "I/O flow ID",
9e684a49
DE
3313 .type = FIO_OPT_INT,
3314 .off1 = td_var_offset(flow_id),
3315 .help = "The flow index ID to use",
3316 .def = "0",
e8b0e958
JA
3317 .category = FIO_OPT_C_IO,
3318 .group = FIO_OPT_G_IO_FLOW,
9e684a49
DE
3319 },
3320 {
3321 .name = "flow",
e8b0e958 3322 .lname = "I/O flow weight",
9e684a49
DE
3323 .type = FIO_OPT_INT,
3324 .off1 = td_var_offset(flow),
3325 .help = "Weight for flow control of this job",
3326 .parent = "flow_id",
d71c154c 3327 .hide = 1,
9e684a49 3328 .def = "0",
e8b0e958
JA
3329 .category = FIO_OPT_C_IO,
3330 .group = FIO_OPT_G_IO_FLOW,
9e684a49
DE
3331 },
3332 {
3333 .name = "flow_watermark",
e8b0e958 3334 .lname = "I/O flow watermark",
9e684a49
DE
3335 .type = FIO_OPT_INT,
3336 .off1 = td_var_offset(flow_watermark),
3337 .help = "High watermark for flow control. This option"
3338 " should be set to the same value for all threads"
3339 " with non-zero flow.",
3340 .parent = "flow_id",
d71c154c 3341 .hide = 1,
9e684a49 3342 .def = "1024",
e8b0e958
JA
3343 .category = FIO_OPT_C_IO,
3344 .group = FIO_OPT_G_IO_FLOW,
9e684a49
DE
3345 },
3346 {
3347 .name = "flow_sleep",
e8b0e958 3348 .lname = "I/O flow sleep",
9e684a49
DE
3349 .type = FIO_OPT_INT,
3350 .off1 = td_var_offset(flow_sleep),
3351 .help = "How many microseconds to sleep after being held"
3352 " back by the flow control mechanism",
3353 .parent = "flow_id",
d71c154c 3354 .hide = 1,
9e684a49 3355 .def = "0",
e8b0e958
JA
3356 .category = FIO_OPT_C_IO,
3357 .group = FIO_OPT_G_IO_FLOW,
9e684a49 3358 },
214e1eca
JA
3359 {
3360 .name = NULL,
3361 },
3362};
3363
17af15d4 3364static void add_to_lopt(struct option *lopt, struct fio_option *o,
de890a1e 3365 const char *name, int val)
9f81736c 3366{
17af15d4 3367 lopt->name = (char *) name;
de890a1e 3368 lopt->val = val;
9f81736c 3369 if (o->type == FIO_OPT_STR_SET)
ff52be3d 3370 lopt->has_arg = optional_argument;
9f81736c
JA
3371 else
3372 lopt->has_arg = required_argument;
3373}
3374
de890a1e
SL
3375static void options_to_lopts(struct fio_option *opts,
3376 struct option *long_options,
3377 int i, int option_type)
214e1eca 3378{
de890a1e 3379 struct fio_option *o = &opts[0];
214e1eca 3380 while (o->name) {
de890a1e 3381 add_to_lopt(&long_options[i], o, o->name, option_type);
17af15d4
JA
3382 if (o->alias) {
3383 i++;
de890a1e 3384 add_to_lopt(&long_options[i], o, o->alias, option_type);
17af15d4 3385 }
214e1eca
JA
3386
3387 i++;
3388 o++;
3389 assert(i < FIO_NR_OPTIONS);
3390 }
3391}
3392
de890a1e
SL
3393void fio_options_set_ioengine_opts(struct option *long_options,
3394 struct thread_data *td)
3395{
3396 unsigned int i;
3397
3398 i = 0;
3399 while (long_options[i].name) {
3400 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
3401 memset(&long_options[i], 0, sizeof(*long_options));
3402 break;
3403 }
3404 i++;
3405 }
3406
3407 /*
3408 * Just clear out the prior ioengine options.
3409 */
3410 if (!td || !td->eo)
3411 return;
3412
3413 options_to_lopts(td->io_ops->options, long_options, i,
3414 FIO_GETOPT_IOENGINE);
3415}
3416
3417void fio_options_dup_and_init(struct option *long_options)
3418{
3419 unsigned int i;
3420
9af4a244 3421 options_init(fio_options);
de890a1e
SL
3422
3423 i = 0;
3424 while (long_options[i].name)
3425 i++;
3426
9af4a244 3427 options_to_lopts(fio_options, long_options, i, FIO_GETOPT_JOB);
de890a1e
SL
3428}
3429
74929ac2
JA
3430struct fio_keyword {
3431 const char *word;
3432 const char *desc;
3433 char *replace;
3434};
3435
3436static struct fio_keyword fio_keywords[] = {
3437 {
3438 .word = "$pagesize",
3439 .desc = "Page size in the system",
3440 },
3441 {
3442 .word = "$mb_memory",
3443 .desc = "Megabytes of memory online",
3444 },
3445 {
3446 .word = "$ncpus",
3447 .desc = "Number of CPUs online in the system",
3448 },
3449 {
3450 .word = NULL,
3451 },
3452};
3453
3454void fio_keywords_init(void)
3455{
3b2e1464 3456 unsigned long long mb_memory;
74929ac2
JA
3457 char buf[128];
3458 long l;
3459
a4cfc477 3460 sprintf(buf, "%lu", (unsigned long) page_size);
74929ac2
JA
3461 fio_keywords[0].replace = strdup(buf);
3462
8eb016d3 3463 mb_memory = os_phys_mem() / (1024 * 1024);
3b2e1464 3464 sprintf(buf, "%llu", mb_memory);
74929ac2
JA
3465 fio_keywords[1].replace = strdup(buf);
3466
c00a2289 3467 l = cpus_online();
74929ac2
JA
3468 sprintf(buf, "%lu", l);
3469 fio_keywords[2].replace = strdup(buf);
3470}
3471
892a6ffc
JA
3472#define BC_APP "bc"
3473
3474static char *bc_calc(char *str)
3475{
d0c814ec 3476 char buf[128], *tmp;
892a6ffc
JA
3477 FILE *f;
3478 int ret;
3479
3480 /*
3481 * No math, just return string
3482 */
d0c814ec
SL
3483 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
3484 !strchr(str, '/')) || strchr(str, '\''))
892a6ffc
JA
3485 return str;
3486
3487 /*
3488 * Split option from value, we only need to calculate the value
3489 */
3490 tmp = strchr(str, '=');
3491 if (!tmp)
3492 return str;
3493
3494 tmp++;
892a6ffc 3495
d0c814ec
SL
3496 /*
3497 * Prevent buffer overflows; such a case isn't reasonable anyway
3498 */
3499 if (strlen(str) >= 128 || strlen(tmp) > 100)
3500 return str;
892a6ffc
JA
3501
3502 sprintf(buf, "which %s > /dev/null", BC_APP);
3503 if (system(buf)) {
3504 log_err("fio: bc is needed for performing math\n");
892a6ffc
JA
3505 return NULL;
3506 }
3507
d0c814ec 3508 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
892a6ffc 3509 f = popen(buf, "r");
3c3ed070 3510 if (!f)
892a6ffc 3511 return NULL;
892a6ffc 3512
d0c814ec 3513 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
3c3ed070 3514 if (ret <= 0)
892a6ffc 3515 return NULL;
892a6ffc 3516
892a6ffc 3517 pclose(f);
d0c814ec
SL
3518 buf[(tmp - str) + ret - 1] = '\0';
3519 memcpy(buf, str, tmp - str);
892a6ffc 3520 free(str);
d0c814ec
SL
3521 return strdup(buf);
3522}
3523
3524/*
3525 * Return a copy of the input string with substrings of the form ${VARNAME}
3526 * substituted with the value of the environment variable VARNAME. The
3527 * substitution always occurs, even if VARNAME is empty or the corresponding
3528 * environment variable undefined.
3529 */
3530static char *option_dup_subs(const char *opt)
3531{
3532 char out[OPT_LEN_MAX+1];
3533 char in[OPT_LEN_MAX+1];
3534 char *outptr = out;
3535 char *inptr = in;
3536 char *ch1, *ch2, *env;
3537 ssize_t nchr = OPT_LEN_MAX;
3538 size_t envlen;
3539
3540 if (strlen(opt) + 1 > OPT_LEN_MAX) {
3541 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
3542 return NULL;
3543 }
3544
3545 in[OPT_LEN_MAX] = '\0';
3546 strncpy(in, opt, OPT_LEN_MAX);
3547
3548 while (*inptr && nchr > 0) {
3549 if (inptr[0] == '$' && inptr[1] == '{') {
3550 ch2 = strchr(inptr, '}');
3551 if (ch2 && inptr+1 < ch2) {
3552 ch1 = inptr+2;
3553 inptr = ch2+1;
3554 *ch2 = '\0';
3555
3556 env = getenv(ch1);
3557 if (env) {
3558 envlen = strlen(env);
3559 if (envlen <= nchr) {
3560 memcpy(outptr, env, envlen);
3561 outptr += envlen;
3562 nchr -= envlen;
3563 }
3564 }
3565
3566 continue;
3567 }
3568 }
3569
3570 *outptr++ = *inptr++;
3571 --nchr;
3572 }
3573
3574 *outptr = '\0';
3575 return strdup(out);
892a6ffc
JA
3576}
3577
74929ac2
JA
3578/*
3579 * Look for reserved variable names and replace them with real values
3580 */
3581static char *fio_keyword_replace(char *opt)
3582{
3583 char *s;
3584 int i;
d0c814ec 3585 int docalc = 0;
74929ac2
JA
3586
3587 for (i = 0; fio_keywords[i].word != NULL; i++) {
3588 struct fio_keyword *kw = &fio_keywords[i];
3589
3590 while ((s = strstr(opt, kw->word)) != NULL) {
3591 char *new = malloc(strlen(opt) + 1);
3592 char *o_org = opt;
3593 int olen = s - opt;
3594 int len;
3595
3596 /*
3597 * Copy part of the string before the keyword and
3598 * sprintf() the replacement after it.
3599 */
3600 memcpy(new, opt, olen);
3601 len = sprintf(new + olen, "%s", kw->replace);
3602
3603 /*
3604 * If there's more in the original string, copy that
3605 * in too
3606 */
3607 opt += strlen(kw->word) + olen;
3608 if (strlen(opt))
3609 memcpy(new + olen + len, opt, opt - o_org - 1);
3610
3611 /*
3612 * replace opt and free the old opt
3613 */
3614 opt = new;
d0c814ec 3615 free(o_org);
7a958bd5 3616
d0c814ec 3617 docalc = 1;
74929ac2
JA
3618 }
3619 }
3620
d0c814ec
SL
3621 /*
3622 * Check for potential math and invoke bc, if possible
3623 */
3624 if (docalc)
3625 opt = bc_calc(opt);
3626
7a958bd5 3627 return opt;
74929ac2
JA
3628}
3629
d0c814ec
SL
3630static char **dup_and_sub_options(char **opts, int num_opts)
3631{
3632 int i;
3633 char **opts_copy = malloc(num_opts * sizeof(*opts));
3634 for (i = 0; i < num_opts; i++) {
3635 opts_copy[i] = option_dup_subs(opts[i]);
3636 if (!opts_copy[i])
3637 continue;
3638 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
3639 }
3640 return opts_copy;
3641}
3642
292cc475
JA
3643int fio_options_parse(struct thread_data *td, char **opts, int num_opts,
3644 int dump_cmdline)
214e1eca 3645{
de890a1e 3646 int i, ret, unknown;
d0c814ec 3647 char **opts_copy;
3b8b7135 3648
9af4a244 3649 sort_options(opts, fio_options, num_opts);
d0c814ec 3650 opts_copy = dup_and_sub_options(opts, num_opts);
3b8b7135 3651
de890a1e
SL
3652 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
3653 struct fio_option *o;
9af4a244 3654 int newret = parse_option(opts_copy[i], opts[i], fio_options,
292cc475 3655 &o, td, dump_cmdline);
d0c814ec 3656
de890a1e
SL
3657 if (opts_copy[i]) {
3658 if (newret && !o) {
3659 unknown++;
3660 continue;
3661 }
d0c814ec 3662 free(opts_copy[i]);
de890a1e
SL
3663 opts_copy[i] = NULL;
3664 }
3665
3666 ret |= newret;
3667 }
3668
3669 if (unknown) {
3670 ret |= ioengine_load(td);
3671 if (td->eo) {
3672 sort_options(opts_copy, td->io_ops->options, num_opts);
3673 opts = opts_copy;
3674 }
3675 for (i = 0; i < num_opts; i++) {
3676 struct fio_option *o = NULL;
3677 int newret = 1;
3678 if (!opts_copy[i])
3679 continue;
3680
3681 if (td->eo)
3682 newret = parse_option(opts_copy[i], opts[i],
3683 td->io_ops->options, &o,
292cc475 3684 td->eo, dump_cmdline);
de890a1e
SL
3685
3686 ret |= newret;
3687 if (!o)
3688 log_err("Bad option <%s>\n", opts[i]);
3689
3690 free(opts_copy[i]);
3691 opts_copy[i] = NULL;
3692 }
74929ac2 3693 }
3b8b7135 3694
d0c814ec 3695 free(opts_copy);
3b8b7135 3696 return ret;
214e1eca
JA
3697}
3698
3699int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
3700{
9af4a244 3701 return parse_cmd_option(opt, val, fio_options, td);
214e1eca
JA
3702}
3703
de890a1e
SL
3704int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
3705 char *val)
3706{
8a96c80e 3707 return parse_cmd_option(opt, val, td->io_ops->options, td->eo);
de890a1e
SL
3708}
3709
214e1eca
JA
3710void fio_fill_default_options(struct thread_data *td)
3711{
9af4a244 3712 fill_default_options(td, fio_options);
214e1eca
JA
3713}
3714
3715int fio_show_option_help(const char *opt)
3716{
9af4a244 3717 return show_cmd_help(fio_options, opt);
214e1eca 3718}
d23bb327 3719
de890a1e 3720void options_mem_dupe(void *data, struct fio_option *options)
d23bb327 3721{
de890a1e 3722 struct fio_option *o;
d23bb327 3723 char **ptr;
d23bb327 3724
de890a1e
SL
3725 for (o = &options[0]; o->name; o++) {
3726 if (o->type != FIO_OPT_STR_STORE)
d23bb327
JA
3727 continue;
3728
de890a1e 3729 ptr = td_var(data, o->off1);
7e356b2d
JA
3730 if (*ptr)
3731 *ptr = strdup(*ptr);
d23bb327
JA
3732 }
3733}
3734
de890a1e
SL
3735/*
3736 * dupe FIO_OPT_STR_STORE options
3737 */
3738void fio_options_mem_dupe(struct thread_data *td)
3739{
9af4a244 3740 options_mem_dupe(&td->o, fio_options);
1647f592
JA
3741
3742 if (td->eo && td->io_ops) {
de890a1e 3743 void *oldeo = td->eo;
1647f592 3744
de890a1e
SL
3745 td->eo = malloc(td->io_ops->option_struct_size);
3746 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
3747 options_mem_dupe(td->eo, td->io_ops->options);
3748 }
3749}
3750
d6978a32
JA
3751unsigned int fio_get_kb_base(void *data)
3752{
83ea422a 3753 struct thread_options *o = data;
d6978a32
JA
3754 unsigned int kb_base = 0;
3755
83ea422a
JA
3756 if (o)
3757 kb_base = o->kb_base;
d6978a32
JA
3758 if (!kb_base)
3759 kb_base = 1024;
3760
3761 return kb_base;
3762}
9f988e2e 3763
07b3232d 3764int add_option(struct fio_option *o)
9f988e2e 3765{
07b3232d
JA
3766 struct fio_option *__o;
3767 int opt_index = 0;
3768
9af4a244 3769 __o = fio_options;
07b3232d
JA
3770 while (__o->name) {
3771 opt_index++;
3772 __o++;
3773 }
3774
9af4a244 3775 memcpy(&fio_options[opt_index], o, sizeof(*o));
07b3232d 3776 return 0;
9f988e2e 3777}
e2de69da 3778
07b3232d 3779void invalidate_profile_options(const char *prof_name)
e2de69da 3780{
07b3232d 3781 struct fio_option *o;
e2de69da 3782
9af4a244 3783 o = fio_options;
07b3232d
JA
3784 while (o->name) {
3785 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
3786 o->type = FIO_OPT_INVALID;
3787 o->prof_name = NULL;
3788 }
3789 o++;
e2de69da
JA
3790 }
3791}
f5b6bb85
JA
3792
3793void add_opt_posval(const char *optname, const char *ival, const char *help)
3794{
3795 struct fio_option *o;
3796 unsigned int i;
3797
9af4a244 3798 o = find_option(fio_options, optname);
f5b6bb85
JA
3799 if (!o)
3800 return;
3801
3802 for (i = 0; i < PARSE_MAX_VP; i++) {
3803 if (o->posval[i].ival)
3804 continue;
3805
3806 o->posval[i].ival = ival;
3807 o->posval[i].help = help;
3808 break;
3809 }
3810}
3811
3812void del_opt_posval(const char *optname, const char *ival)
3813{
3814 struct fio_option *o;
3815 unsigned int i;
3816
9af4a244 3817 o = find_option(fio_options, optname);
f5b6bb85
JA
3818 if (!o)
3819 return;
3820
3821 for (i = 0; i < PARSE_MAX_VP; i++) {
3822 if (!o->posval[i].ival)
3823 continue;
3824 if (strcmp(o->posval[i].ival, ival))
3825 continue;
3826
3827 o->posval[i].ival = NULL;
3828 o->posval[i].help = NULL;
3829 }
3830}
7e356b2d
JA
3831
3832void fio_options_free(struct thread_data *td)
3833{
9af4a244 3834 options_free(fio_options, td);
de890a1e
SL
3835 if (td->eo && td->io_ops && td->io_ops->options) {
3836 options_free(td->io_ops->options, td->eo);
3837 free(td->eo);
3838 td->eo = NULL;
3839 }
7e356b2d 3840}
c504ee55
JA
3841
3842struct fio_option *fio_option_find(const char *name)
3843{
3844 return find_option(fio_options, name);
3845}
3846