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