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