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