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