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