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