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