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