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