workqueue: move private exit code to caller
[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>
e13c3b50 11#include <netinet/in.h>
214e1eca
JA
12
13#include "fio.h"
4f5af7b2 14#include "verify.h"
214e1eca 15#include "parse.h"
eef32359 16#include "lib/fls.h"
61b9861d 17#include "lib/pattern.h"
9f988e2e 18#include "options.h"
214e1eca 19
5d7c5d34
JA
20#include "crc/crc32c.h"
21
e13c3b50 22char client_sockaddr_str[INET6_ADDRSTRLEN] = { 0 };
72a703da 23
61b9861d
RP
24struct pattern_fmt_desc fmt_desc[] = {
25 {
26 .fmt = "%o",
27 .len = FIELD_SIZE(struct io_u *, offset),
28 .paste = paste_blockoff
29 }
30};
31
214e1eca
JA
32/*
33 * Check if mmap/mmaphuge has a :/foo/bar/file at the end. If so, return that.
34 */
35static char *get_opt_postfix(const char *str)
36{
37 char *p = strstr(str, ":");
38
39 if (!p)
40 return NULL;
41
42 p++;
43 strip_blank_front(&p);
44 strip_blank_end(p);
45 return strdup(p);
46}
47
564ca972
JA
48static int bs_cmp(const void *p1, const void *p2)
49{
50 const struct bssplit *bsp1 = p1;
51 const struct bssplit *bsp2 = p2;
52
53 return bsp1->perc < bsp2->perc;
54}
55
83ea422a 56static int bssplit_ddir(struct thread_options *o, int ddir, char *str)
564ca972 57{
720e84ad 58 struct bssplit *bssplit;
564ca972
JA
59 unsigned int i, perc, perc_missing;
60 unsigned int max_bs, min_bs;
61 long long val;
720e84ad 62 char *fname;
564ca972 63
83ea422a 64 o->bssplit_nr[ddir] = 4;
720e84ad 65 bssplit = malloc(4 * sizeof(struct bssplit));
564ca972
JA
66
67 i = 0;
68 max_bs = 0;
69 min_bs = -1;
70 while ((fname = strsep(&str, ":")) != NULL) {
71 char *perc_str;
72
73 if (!strlen(fname))
74 break;
75
76 /*
77 * grow struct buffer, if needed
78 */
83ea422a
JA
79 if (i == o->bssplit_nr[ddir]) {
80 o->bssplit_nr[ddir] <<= 1;
81 bssplit = realloc(bssplit, o->bssplit_nr[ddir]
5ec10eaa 82 * sizeof(struct bssplit));
564ca972
JA
83 }
84
85 perc_str = strstr(fname, "/");
86 if (perc_str) {
87 *perc_str = '\0';
88 perc_str++;
89 perc = atoi(perc_str);
90 if (perc > 100)
91 perc = 100;
92 else if (!perc)
d711cce5 93 perc = -1U;
564ca972 94 } else
d711cce5 95 perc = -1U;
564ca972 96
88038bc7 97 if (str_to_decimal(fname, &val, 1, o, 0, 0)) {
564ca972 98 log_err("fio: bssplit conversion failed\n");
d8b97c8e 99 free(bssplit);
564ca972
JA
100 return 1;
101 }
102
103 if (val > max_bs)
104 max_bs = val;
105 if (val < min_bs)
106 min_bs = val;
107
720e84ad
JA
108 bssplit[i].bs = val;
109 bssplit[i].perc = perc;
564ca972
JA
110 i++;
111 }
112
83ea422a 113 o->bssplit_nr[ddir] = i;
564ca972
JA
114
115 /*
116 * Now check if the percentages add up, and how much is missing
117 */
118 perc = perc_missing = 0;
83ea422a 119 for (i = 0; i < o->bssplit_nr[ddir]; i++) {
720e84ad 120 struct bssplit *bsp = &bssplit[i];
564ca972 121
d711cce5 122 if (bsp->perc == -1U)
564ca972
JA
123 perc_missing++;
124 else
125 perc += bsp->perc;
126 }
127
40bafa33 128 if (perc > 100 && perc_missing > 1) {
564ca972 129 log_err("fio: bssplit percentages add to more than 100%%\n");
720e84ad 130 free(bssplit);
564ca972
JA
131 return 1;
132 }
d711cce5 133
564ca972
JA
134 /*
135 * If values didn't have a percentage set, divide the remains between
136 * them.
137 */
138 if (perc_missing) {
d711cce5 139 if (perc_missing == 1 && o->bssplit_nr[ddir] == 1)
40bafa33 140 perc = 100;
83ea422a 141 for (i = 0; i < o->bssplit_nr[ddir]; i++) {
720e84ad 142 struct bssplit *bsp = &bssplit[i];
564ca972 143
d711cce5 144 if (bsp->perc == -1U)
564ca972
JA
145 bsp->perc = (100 - perc) / perc_missing;
146 }
147 }
148
83ea422a
JA
149 o->min_bs[ddir] = min_bs;
150 o->max_bs[ddir] = max_bs;
564ca972
JA
151
152 /*
153 * now sort based on percentages, for ease of lookup
154 */
83ea422a
JA
155 qsort(bssplit, o->bssplit_nr[ddir], sizeof(struct bssplit), bs_cmp);
156 o->bssplit[ddir] = bssplit;
720e84ad 157 return 0;
720e84ad
JA
158}
159
160static int str_bssplit_cb(void *data, const char *input)
161{
162 struct thread_data *td = data;
6eaf09d6 163 char *str, *p, *odir, *ddir;
720e84ad
JA
164 int ret = 0;
165
52c0cea3
JA
166 if (parse_dryrun())
167 return 0;
168
720e84ad
JA
169 p = str = strdup(input);
170
171 strip_blank_front(&str);
172 strip_blank_end(str);
173
174 odir = strchr(str, ',');
175 if (odir) {
6eaf09d6
SL
176 ddir = strchr(odir + 1, ',');
177 if (ddir) {
d79db122 178 ret = bssplit_ddir(&td->o, DDIR_TRIM, ddir + 1);
6eaf09d6
SL
179 if (!ret)
180 *ddir = '\0';
181 } else {
182 char *op;
183
184 op = strdup(odir + 1);
d79db122 185 ret = bssplit_ddir(&td->o, DDIR_TRIM, op);
6eaf09d6
SL
186
187 free(op);
188 }
d79db122
JA
189 if (!ret)
190 ret = bssplit_ddir(&td->o, DDIR_WRITE, odir + 1);
720e84ad
JA
191 if (!ret) {
192 *odir = '\0';
83ea422a 193 ret = bssplit_ddir(&td->o, DDIR_READ, str);
720e84ad
JA
194 }
195 } else {
196 char *op;
197
198 op = strdup(str);
d79db122 199 ret = bssplit_ddir(&td->o, DDIR_WRITE, op);
6eaf09d6 200 free(op);
720e84ad 201
6eaf09d6
SL
202 if (!ret) {
203 op = strdup(str);
d79db122 204 ret = bssplit_ddir(&td->o, DDIR_TRIM, op);
6eaf09d6
SL
205 free(op);
206 }
f0c9c217
JA
207 if (!ret)
208 ret = bssplit_ddir(&td->o, DDIR_READ, str);
720e84ad 209 }
564ca972
JA
210
211 free(p);
720e84ad 212 return ret;
564ca972
JA
213}
214
8b28bd41
DM
215static int str2error(char *str)
216{
a94eb99a 217 const char *err[] = { "EPERM", "ENOENT", "ESRCH", "EINTR", "EIO",
8b28bd41
DM
218 "ENXIO", "E2BIG", "ENOEXEC", "EBADF",
219 "ECHILD", "EAGAIN", "ENOMEM", "EACCES",
220 "EFAULT", "ENOTBLK", "EBUSY", "EEXIST",
221 "EXDEV", "ENODEV", "ENOTDIR", "EISDIR",
222 "EINVAL", "ENFILE", "EMFILE", "ENOTTY",
223 "ETXTBSY","EFBIG", "ENOSPC", "ESPIPE",
a94eb99a 224 "EROFS","EMLINK", "EPIPE", "EDOM", "ERANGE" };
8b28bd41
DM
225 int i = 0, num = sizeof(err) / sizeof(void *);
226
a94eb99a 227 while (i < num) {
8b28bd41
DM
228 if (!strcmp(err[i], str))
229 return i + 1;
230 i++;
231 }
232 return 0;
233}
234
235static int ignore_error_type(struct thread_data *td, int etype, char *str)
236{
237 unsigned int i;
238 int *error;
239 char *fname;
240
241 if (etype >= ERROR_TYPE_CNT) {
242 log_err("Illegal error type\n");
243 return 1;
244 }
245
246 td->o.ignore_error_nr[etype] = 4;
247 error = malloc(4 * sizeof(struct bssplit));
248
249 i = 0;
250 while ((fname = strsep(&str, ":")) != NULL) {
251
252 if (!strlen(fname))
253 break;
254
255 /*
256 * grow struct buffer, if needed
257 */
258 if (i == td->o.ignore_error_nr[etype]) {
259 td->o.ignore_error_nr[etype] <<= 1;
260 error = realloc(error, td->o.ignore_error_nr[etype]
261 * sizeof(int));
262 }
263 if (fname[0] == 'E') {
264 error[i] = str2error(fname);
265 } else {
266 error[i] = atoi(fname);
267 if (error[i] < 0)
1616e025 268 error[i] = -error[i];
8b28bd41
DM
269 }
270 if (!error[i]) {
271 log_err("Unknown error %s, please use number value \n",
272 fname);
0fddbf7a 273 free(error);
8b28bd41
DM
274 return 1;
275 }
276 i++;
277 }
278 if (i) {
279 td->o.continue_on_error |= 1 << etype;
280 td->o.ignore_error_nr[etype] = i;
281 td->o.ignore_error[etype] = error;
c7b086be
JA
282 } else
283 free(error);
284
8b28bd41
DM
285 return 0;
286
287}
288
289static int str_ignore_error_cb(void *data, const char *input)
290{
291 struct thread_data *td = data;
292 char *str, *p, *n;
293 int type = 0, ret = 1;
52c0cea3
JA
294
295 if (parse_dryrun())
296 return 0;
297
8b28bd41
DM
298 p = str = strdup(input);
299
300 strip_blank_front(&str);
301 strip_blank_end(str);
302
303 while (p) {
304 n = strchr(p, ',');
305 if (n)
306 *n++ = '\0';
307 ret = ignore_error_type(td, type, p);
308 if (ret)
309 break;
310 p = n;
311 type++;
312 }
313 free(str);
314 return ret;
315}
316
211097b2
JA
317static int str_rw_cb(void *data, const char *str)
318{
319 struct thread_data *td = data;
83ea422a 320 struct thread_options *o = &td->o;
27ca949f 321 char *nr;
211097b2 322
52c0cea3
JA
323 if (parse_dryrun())
324 return 0;
325
83ea422a
JA
326 o->ddir_seq_nr = 1;
327 o->ddir_seq_add = 0;
059b0802 328
27ca949f 329 nr = get_opt_postfix(str);
059b0802
JA
330 if (!nr)
331 return 0;
332
333 if (td_random(td))
83ea422a 334 o->ddir_seq_nr = atoi(nr);
059b0802
JA
335 else {
336 long long val;
337
88038bc7 338 if (str_to_decimal(nr, &val, 1, o, 0, 0)) {
059b0802
JA
339 log_err("fio: rw postfix parsing failed\n");
340 free(nr);
341 return 1;
342 }
343
83ea422a 344 o->ddir_seq_add = val;
182ec6ee 345 }
211097b2 346
059b0802 347 free(nr);
211097b2
JA
348 return 0;
349}
350
214e1eca
JA
351static int str_mem_cb(void *data, const char *mem)
352{
353 struct thread_data *td = data;
354
217b0f1d
LG
355 if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP ||
356 td->o.mem_type == MEM_MMAPSHARED)
836fcc0f 357 td->o.mmapfile = get_opt_postfix(mem);
214e1eca
JA
358
359 return 0;
360}
361
c223da83
JA
362static int fio_clock_source_cb(void *data, const char *str)
363{
364 struct thread_data *td = data;
365
366 fio_clock_source = td->o.clocksource;
fa80feae 367 fio_clock_source_set = 1;
01423eae 368 fio_clock_init();
c223da83
JA
369 return 0;
370}
371
85bc833b 372static int str_rwmix_read_cb(void *data, unsigned long long *val)
cb499fc4
JA
373{
374 struct thread_data *td = data;
375
376 td->o.rwmix[DDIR_READ] = *val;
377 td->o.rwmix[DDIR_WRITE] = 100 - *val;
378 return 0;
379}
380
85bc833b 381static int str_rwmix_write_cb(void *data, unsigned long long *val)
cb499fc4
JA
382{
383 struct thread_data *td = data;
384
385 td->o.rwmix[DDIR_WRITE] = *val;
386 td->o.rwmix[DDIR_READ] = 100 - *val;
387 return 0;
388}
389
214e1eca
JA
390static int str_exitall_cb(void)
391{
392 exitall_on_terminate = 1;
393 return 0;
394}
395
214e1eca 396#ifdef FIO_HAVE_CPU_AFFINITY
50b5860b 397int fio_cpus_split(os_cpu_mask_t *mask, unsigned int cpu_index)
c2acfbac 398{
50b5860b 399 unsigned int i, index, cpus_in_mask;
c2acfbac 400 const long max_cpu = cpus_online();
c2acfbac 401
50b5860b
JA
402 cpus_in_mask = fio_cpu_count(mask);
403 cpu_index = cpu_index % cpus_in_mask;
404
405 index = 0;
c2acfbac 406 for (i = 0; i < max_cpu; i++) {
50b5860b 407 if (!fio_cpu_isset(mask, i))
c2acfbac 408 continue;
50b5860b
JA
409
410 if (cpu_index != index)
411 fio_cpu_clear(mask, i);
412
413 index++;
c2acfbac
JA
414 }
415
416 return fio_cpu_count(mask);
417}
418
85bc833b 419static int str_cpumask_cb(void *data, unsigned long long *val)
d2e268b0
JA
420{
421 struct thread_data *td = data;
214e1eca 422 unsigned int i;
b03daafb 423 long max_cpu;
d2ce18b5
JA
424 int ret;
425
52c0cea3
JA
426 if (parse_dryrun())
427 return 0;
428
d2ce18b5
JA
429 ret = fio_cpuset_init(&td->o.cpumask);
430 if (ret < 0) {
431 log_err("fio: cpuset_init failed\n");
432 td_verror(td, ret, "fio_cpuset_init");
433 return 1;
434 }
214e1eca 435
c00a2289 436 max_cpu = cpus_online();
214e1eca 437
62a7273d
JA
438 for (i = 0; i < sizeof(int) * 8; i++) {
439 if ((1 << i) & *val) {
b8411399 440 if (i >= max_cpu) {
b03daafb 441 log_err("fio: CPU %d too large (max=%ld)\n", i,
b8411399 442 max_cpu - 1);
b03daafb
JA
443 return 1;
444 }
62a7273d 445 dprint(FD_PARSE, "set cpu allowed %d\n", i);
6d459ee7 446 fio_cpu_set(&td->o.cpumask, i);
62a7273d
JA
447 }
448 }
d2e268b0 449
d2e268b0 450 return 0;
214e1eca
JA
451}
452
e8462bd8
JA
453static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask,
454 const char *input)
214e1eca 455{
d2e268b0 456 char *cpu, *str, *p;
b03daafb 457 long max_cpu;
19608d6c 458 int ret = 0;
d2e268b0 459
e8462bd8 460 ret = fio_cpuset_init(mask);
d2ce18b5
JA
461 if (ret < 0) {
462 log_err("fio: cpuset_init failed\n");
463 td_verror(td, ret, "fio_cpuset_init");
464 return 1;
465 }
d2e268b0
JA
466
467 p = str = strdup(input);
214e1eca 468
d2e268b0
JA
469 strip_blank_front(&str);
470 strip_blank_end(str);
471
c00a2289 472 max_cpu = cpus_online();
b03daafb 473
d2e268b0 474 while ((cpu = strsep(&str, ",")) != NULL) {
62a7273d
JA
475 char *str2, *cpu2;
476 int icpu, icpu2;
477
d2e268b0
JA
478 if (!strlen(cpu))
479 break;
62a7273d
JA
480
481 str2 = cpu;
482 icpu2 = -1;
483 while ((cpu2 = strsep(&str2, "-")) != NULL) {
484 if (!strlen(cpu2))
485 break;
486
487 icpu2 = atoi(cpu2);
488 }
489
490 icpu = atoi(cpu);
491 if (icpu2 == -1)
492 icpu2 = icpu;
493 while (icpu <= icpu2) {
6d459ee7 494 if (icpu >= FIO_MAX_CPUS) {
19608d6c 495 log_err("fio: your OS only supports up to"
6d459ee7 496 " %d CPUs\n", (int) FIO_MAX_CPUS);
19608d6c
JA
497 ret = 1;
498 break;
499 }
9e986889 500 if (icpu >= max_cpu) {
b03daafb 501 log_err("fio: CPU %d too large (max=%ld)\n",
9e986889 502 icpu, max_cpu - 1);
b03daafb
JA
503 ret = 1;
504 break;
505 }
0b9d69ec 506
62a7273d 507 dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
e8462bd8 508 fio_cpu_set(mask, icpu);
62a7273d
JA
509 icpu++;
510 }
19608d6c
JA
511 if (ret)
512 break;
d2e268b0
JA
513 }
514
515 free(p);
19608d6c 516 return ret;
214e1eca 517}
e8462bd8
JA
518
519static int str_cpus_allowed_cb(void *data, const char *input)
520{
521 struct thread_data *td = data;
e8462bd8 522
52c0cea3
JA
523 if (parse_dryrun())
524 return 0;
525
b2a9e649 526 return set_cpus_allowed(td, &td->o.cpumask, input);
e8462bd8
JA
527}
528
529static int str_verify_cpus_allowed_cb(void *data, const char *input)
530{
531 struct thread_data *td = data;
e8462bd8 532
b2a9e649 533 return set_cpus_allowed(td, &td->o.verify_cpumask, input);
e8462bd8 534}
d2e268b0 535#endif
214e1eca 536
67bf9823 537#ifdef CONFIG_LIBNUMA
d0b937ed
YR
538static int str_numa_cpunodes_cb(void *data, char *input)
539{
540 struct thread_data *td = data;
43522848 541 struct bitmask *verify_bitmask;
d0b937ed 542
52c0cea3
JA
543 if (parse_dryrun())
544 return 0;
545
d0b937ed
YR
546 /* numa_parse_nodestring() parses a character string list
547 * of nodes into a bit mask. The bit mask is allocated by
548 * numa_allocate_nodemask(), so it should be freed by
549 * numa_free_nodemask().
550 */
43522848
DG
551 verify_bitmask = numa_parse_nodestring(input);
552 if (verify_bitmask == NULL) {
d0b937ed
YR
553 log_err("fio: numa_parse_nodestring failed\n");
554 td_verror(td, 1, "str_numa_cpunodes_cb");
555 return 1;
556 }
43522848 557 numa_free_nodemask(verify_bitmask);
d0b937ed 558
43522848 559 td->o.numa_cpunodes = strdup(input);
d0b937ed
YR
560 return 0;
561}
562
563static int str_numa_mpol_cb(void *data, char *input)
564{
565 struct thread_data *td = data;
566 const char * const policy_types[] =
05d6f44b 567 { "default", "prefer", "bind", "interleave", "local", NULL };
d0b937ed 568 int i;
52c0cea3 569 char *nodelist;
43522848 570 struct bitmask *verify_bitmask;
52c0cea3
JA
571
572 if (parse_dryrun())
573 return 0;
d0b937ed 574
52c0cea3 575 nodelist = strchr(input, ':');
d0b937ed
YR
576 if (nodelist) {
577 /* NUL-terminate mode */
578 *nodelist++ = '\0';
579 }
580
581 for (i = 0; i <= MPOL_LOCAL; i++) {
582 if (!strcmp(input, policy_types[i])) {
583 td->o.numa_mem_mode = i;
584 break;
585 }
586 }
587 if (i > MPOL_LOCAL) {
588 log_err("fio: memory policy should be: default, prefer, bind, interleave, local\n");
589 goto out;
590 }
591
592 switch (td->o.numa_mem_mode) {
593 case MPOL_PREFERRED:
594 /*
595 * Insist on a nodelist of one node only
596 */
597 if (nodelist) {
598 char *rest = nodelist;
599 while (isdigit(*rest))
600 rest++;
601 if (*rest) {
602 log_err("fio: one node only for \'prefer\'\n");
603 goto out;
604 }
605 } else {
606 log_err("fio: one node is needed for \'prefer\'\n");
607 goto out;
608 }
609 break;
610 case MPOL_INTERLEAVE:
611 /*
612 * Default to online nodes with memory if no nodelist
613 */
614 if (!nodelist)
615 nodelist = strdup("all");
616 break;
617 case MPOL_LOCAL:
618 case MPOL_DEFAULT:
619 /*
620 * Don't allow a nodelist
621 */
622 if (nodelist) {
623 log_err("fio: NO nodelist for \'local\'\n");
624 goto out;
625 }
626 break;
627 case MPOL_BIND:
628 /*
629 * Insist on a nodelist
630 */
631 if (!nodelist) {
632 log_err("fio: a nodelist is needed for \'bind\'\n");
633 goto out;
634 }
635 break;
636 }
637
638
639 /* numa_parse_nodestring() parses a character string list
640 * of nodes into a bit mask. The bit mask is allocated by
641 * numa_allocate_nodemask(), so it should be freed by
642 * numa_free_nodemask().
643 */
644 switch (td->o.numa_mem_mode) {
645 case MPOL_PREFERRED:
646 td->o.numa_mem_prefer_node = atoi(nodelist);
647 break;
648 case MPOL_INTERLEAVE:
649 case MPOL_BIND:
43522848
DG
650 verify_bitmask = numa_parse_nodestring(nodelist);
651 if (verify_bitmask == NULL) {
d0b937ed
YR
652 log_err("fio: numa_parse_nodestring failed\n");
653 td_verror(td, 1, "str_numa_memnodes_cb");
654 return 1;
655 }
43522848
DG
656 td->o.numa_memnodes = strdup(nodelist);
657 numa_free_nodemask(verify_bitmask);
b74e419e 658
d0b937ed
YR
659 break;
660 case MPOL_LOCAL:
661 case MPOL_DEFAULT:
662 default:
663 break;
664 }
665
d0b937ed 666 return 0;
d0b937ed
YR
667out:
668 return 1;
669}
670#endif
671
214e1eca
JA
672static int str_fst_cb(void *data, const char *str)
673{
674 struct thread_data *td = data;
675 char *nr = get_opt_postfix(str);
676
677 td->file_service_nr = 1;
182ec6ee 678 if (nr) {
214e1eca 679 td->file_service_nr = atoi(nr);
182ec6ee
JA
680 free(nr);
681 }
214e1eca
JA
682
683 return 0;
684}
685
67bf9823 686#ifdef CONFIG_SYNC_FILE_RANGE
44f29692
JA
687static int str_sfr_cb(void *data, const char *str)
688{
689 struct thread_data *td = data;
690 char *nr = get_opt_postfix(str);
691
692 td->sync_file_range_nr = 1;
693 if (nr) {
694 td->sync_file_range_nr = atoi(nr);
695 free(nr);
696 }
697
698 return 0;
699}
3ae06371 700#endif
44f29692 701
e25839d4
JA
702static int str_random_distribution_cb(void *data, const char *str)
703{
704 struct thread_data *td = data;
705 double val;
706 char *nr;
707
52c0cea3
JA
708 if (parse_dryrun())
709 return 0;
710
925fee33 711 if (td->o.random_distribution == FIO_RAND_DIST_ZIPF)
c95f9404 712 val = FIO_DEF_ZIPF;
925fee33 713 else if (td->o.random_distribution == FIO_RAND_DIST_PARETO)
c95f9404 714 val = FIO_DEF_PARETO;
56d9fa4b
JA
715 else if (td->o.random_distribution == FIO_RAND_DIST_GAUSS)
716 val = 0.0;
925fee33 717 else
e25839d4
JA
718 return 0;
719
720 nr = get_opt_postfix(str);
88038bc7 721 if (nr && !str_to_float(nr, &val, 0)) {
e25839d4
JA
722 log_err("fio: random postfix parsing failed\n");
723 free(nr);
724 return 1;
725 }
726
078189c1
JA
727 free(nr);
728
18ded917
JA
729 if (td->o.random_distribution == FIO_RAND_DIST_ZIPF) {
730 if (val == 1.00) {
731 log_err("fio: zipf theta must different than 1.0\n");
732 return 1;
733 }
1e5324e7 734 td->o.zipf_theta.u.f = val;
56d9fa4b 735 } else if (td->o.random_distribution == FIO_RAND_DIST_PARETO) {
078189c1
JA
736 if (val <= 0.00 || val >= 1.00) {
737 log_err("fio: pareto input out of range (0 < input < 1.0)\n");
738 return 1;
739 }
1e5324e7 740 td->o.pareto_h.u.f = val;
3cdb8cf3
JA
741 } else {
742 if (val <= 0.00 || val >= 100.0) {
743 log_err("fio: normal deviation out of range (0 < input < 100.0)\n");
744 return 1;
745 }
f88cd222 746 td->o.gauss_dev.u.f = val;
3cdb8cf3 747 }
921c766f
JA
748
749 return 0;
750}
751
8e827d35 752/*
bcbfeefa 753 * Return next name in the string. Files are separated with ':'. If the ':'
8e827d35
JA
754 * is escaped with a '\', then that ':' is part of the filename and does not
755 * indicate a new file.
756 */
bcbfeefa 757static char *get_next_name(char **ptr)
8e827d35
JA
758{
759 char *str = *ptr;
760 char *p, *start;
761
762 if (!str || !strlen(str))
763 return NULL;
764
765 start = str;
766 do {
767 /*
768 * No colon, we are done
769 */
770 p = strchr(str, ':');
771 if (!p) {
772 *ptr = NULL;
773 break;
774 }
775
776 /*
777 * We got a colon, but it's the first character. Skip and
778 * continue
779 */
780 if (p == start) {
781 str = ++start;
782 continue;
783 }
784
785 if (*(p - 1) != '\\') {
786 *p = '\0';
787 *ptr = p + 1;
788 break;
789 }
790
791 memmove(p - 1, p, strlen(p) + 1);
792 str = p;
793 } while (1);
794
795 return start;
796}
797
bcbfeefa
CE
798
799static int get_max_name_idx(char *input)
800{
801 unsigned int cur_idx;
802 char *str, *p;
803
804 p = str = strdup(input);
805 for (cur_idx = 0; ; cur_idx++)
806 if (get_next_name(&str) == NULL)
807 break;
808
809 free(p);
810 return cur_idx;
811}
812
813/*
814 * Returns the directory at the index, indexes > entires will be
815 * assigned via modulo division of the index
816 */
e13c3b50 817int set_name_idx(char *target, size_t tlen, char *input, int index)
bcbfeefa
CE
818{
819 unsigned int cur_idx;
820 int len;
821 char *fname, *str, *p;
822
823 p = str = strdup(input);
824
825 index %= get_max_name_idx(input);
826 for (cur_idx = 0; cur_idx <= index; cur_idx++)
827 fname = get_next_name(&str);
828
72a703da 829 if (client_sockaddr_str[0]) {
e13c3b50
JA
830 len = snprintf(target, tlen, "%s/%s.", fname,
831 client_sockaddr_str);
832 } else
833 len = snprintf(target, tlen, "%s/", fname);
72a703da 834
e13c3b50 835 target[tlen - 1] = '\0';
bcbfeefa
CE
836 free(p);
837
838 return len;
839}
840
214e1eca
JA
841static int str_filename_cb(void *data, const char *input)
842{
843 struct thread_data *td = data;
844 char *fname, *str, *p;
845
846 p = str = strdup(input);
847
848 strip_blank_front(&str);
849 strip_blank_end(str);
850
851 if (!td->files_index)
2dc1bbeb 852 td->o.nr_files = 0;
214e1eca 853
bcbfeefa 854 while ((fname = get_next_name(&str)) != NULL) {
214e1eca
JA
855 if (!strlen(fname))
856 break;
5903e7b7 857 add_file(td, fname, 0, 1);
214e1eca
JA
858 }
859
860 free(p);
861 return 0;
862}
863
bcbfeefa 864static int str_directory_cb(void *data, const char fio_unused *unused)
214e1eca
JA
865{
866 struct thread_data *td = data;
867 struct stat sb;
bcbfeefa
CE
868 char *dirname, *str, *p;
869 int ret = 0;
214e1eca 870
f9633d72
JA
871 if (parse_dryrun())
872 return 0;
873
bcbfeefa
CE
874 p = str = strdup(td->o.directory);
875 while ((dirname = get_next_name(&str)) != NULL) {
876 if (lstat(dirname, &sb) < 0) {
877 ret = errno;
921c766f 878
bcbfeefa
CE
879 log_err("fio: %s is not a directory\n", dirname);
880 td_verror(td, ret, "lstat");
881 goto out;
882 }
883 if (!S_ISDIR(sb.st_mode)) {
884 log_err("fio: %s is not a directory\n", dirname);
885 ret = 1;
886 goto out;
887 }
214e1eca
JA
888 }
889
bcbfeefa
CE
890out:
891 free(p);
892 return ret;
214e1eca
JA
893}
894
895static int str_opendir_cb(void *data, const char fio_unused *str)
896{
897 struct thread_data *td = data;
898
52c0cea3
JA
899 if (parse_dryrun())
900 return 0;
901
214e1eca 902 if (!td->files_index)
2dc1bbeb 903 td->o.nr_files = 0;
214e1eca 904
2dc1bbeb 905 return add_dir_files(td, td->o.opendir);
214e1eca
JA
906}
907
ce35b1ec
JA
908static int str_buffer_pattern_cb(void *data, const char *input)
909{
910 struct thread_data *td = data;
911 int ret;
912
61b9861d
RP
913 /* FIXME: for now buffer pattern does not support formats */
914 ret = parse_and_fill_pattern(input, strlen(input), td->o.buffer_pattern,
915 MAX_PATTERN_SIZE, NULL, 0, NULL, NULL);
916 if (ret < 0)
917 return 1;
ce35b1ec 918
61b9861d
RP
919 assert(ret != 0);
920 td->o.buffer_pattern_bytes = ret;
921 if (!td->o.compress_percentage)
922 td->o.refill_buffers = 0;
923 td->o.scramble_buffers = 0;
924 td->o.zero_buffers = 0;
efcd9dcc 925
61b9861d 926 return 0;
ce35b1ec
JA
927}
928
bedc9dc2
JA
929static int str_buffer_compress_cb(void *data, unsigned long long *il)
930{
931 struct thread_data *td = data;
932
933 td->flags |= TD_F_COMPRESS;
934 td->o.compress_percentage = *il;
935 return 0;
936}
937
5c94b008
JA
938static int str_dedupe_cb(void *data, unsigned long long *il)
939{
940 struct thread_data *td = data;
941
942 td->flags |= TD_F_COMPRESS;
943 td->o.dedupe_percentage = *il;
944 td->o.refill_buffers = 1;
945 return 0;
946}
947
ce35b1ec
JA
948static int str_verify_pattern_cb(void *data, const char *input)
949{
950 struct thread_data *td = data;
951 int ret;
952
61b9861d
RP
953 td->o.verify_fmt_sz = ARRAY_SIZE(td->o.verify_fmt);
954 ret = parse_and_fill_pattern(input, strlen(input), td->o.verify_pattern,
955 MAX_PATTERN_SIZE, fmt_desc, sizeof(fmt_desc),
956 td->o.verify_fmt, &td->o.verify_fmt_sz);
957 if (ret < 0)
958 return 1;
efcd9dcc 959
61b9861d
RP
960 assert(ret != 0);
961 td->o.verify_pattern_bytes = ret;
92bf48d5 962 /*
b638d82f 963 * VERIFY_* could already be set
92bf48d5 964 */
61b9861d 965 if (!fio_option_is_set(&td->o, verify))
92bf48d5 966 td->o.verify = VERIFY_PATTERN;
efcd9dcc 967
61b9861d 968 return 0;
90059d65 969}
214e1eca 970
993bf48b
JA
971static int str_gtod_reduce_cb(void *data, int *il)
972{
973 struct thread_data *td = data;
974 int val = *il;
975
02af0988 976 td->o.disable_lat = !!val;
993bf48b
JA
977 td->o.disable_clat = !!val;
978 td->o.disable_slat = !!val;
979 td->o.disable_bw = !!val;
0dc1bc03 980 td->o.clat_percentiles = !val;
993bf48b
JA
981 if (val)
982 td->tv_cache_mask = 63;
983
984 return 0;
985}
986
7bb59102
JA
987static int str_size_cb(void *data, unsigned long long *__val)
988{
989 struct thread_data *td = data;
990 unsigned long long v = *__val;
991
992 if (parse_is_percent(v)) {
993 td->o.size = 0;
994 td->o.size_percent = -1ULL - v;
995 } else
996 td->o.size = v;
997
998 return 0;
999}
1000
896cac2a
JA
1001static int rw_verify(struct fio_option *o, void *data)
1002{
1003 struct thread_data *td = data;
1004
1005 if (read_only && td_write(td)) {
1006 log_err("fio: job <%s> has write bit set, but fio is in"
1007 " read-only mode\n", td->o.name);
1008 return 1;
1009 }
1010
1011 return 0;
1012}
1013
276ca4f7 1014static int gtod_cpu_verify(struct fio_option *o, void *data)
29d43ff9 1015{
276ca4f7 1016#ifndef FIO_HAVE_CPU_AFFINITY
29d43ff9
JA
1017 struct thread_data *td = data;
1018
29d43ff9
JA
1019 if (td->o.gtod_cpu) {
1020 log_err("fio: platform must support CPU affinity for"
1021 "gettimeofday() offloading\n");
1022 return 1;
1023 }
1024#endif
1025
1026 return 0;
1027}
1028
9af4a244
JA
1029/*
1030 * Option grouping
1031 */
1032static struct opt_group fio_opt_groups[] = {
1033 {
e8b0e958
JA
1034 .name = "General",
1035 .mask = FIO_OPT_C_GENERAL,
9af4a244
JA
1036 },
1037 {
e8b0e958
JA
1038 .name = "I/O",
1039 .mask = FIO_OPT_C_IO,
9af4a244
JA
1040 },
1041 {
e8b0e958
JA
1042 .name = "File",
1043 .mask = FIO_OPT_C_FILE,
9af4a244
JA
1044 },
1045 {
e8b0e958
JA
1046 .name = "Statistics",
1047 .mask = FIO_OPT_C_STAT,
9af4a244
JA
1048 },
1049 {
e8b0e958
JA
1050 .name = "Logging",
1051 .mask = FIO_OPT_C_LOG,
9af4a244 1052 },
13fca827
JA
1053 {
1054 .name = "Profiles",
1055 .mask = FIO_OPT_C_PROFILE,
1056 },
e231bbe6 1057 {
e8b0e958 1058 .name = NULL,
e231bbe6 1059 },
e8b0e958
JA
1060};
1061
1062static struct opt_group *__opt_group_from_mask(struct opt_group *ogs, unsigned int *mask,
1063 unsigned int inv_mask)
1064{
1065 struct opt_group *og;
1066 int i;
1067
1068 if (*mask == inv_mask || !*mask)
1069 return NULL;
1070
1071 for (i = 0; ogs[i].name; i++) {
1072 og = &ogs[i];
1073
1074 if (*mask & og->mask) {
1075 *mask &= ~(og->mask);
1076 return og;
1077 }
1078 }
1079
1080 return NULL;
1081}
1082
1083struct opt_group *opt_group_from_mask(unsigned int *mask)
1084{
1085 return __opt_group_from_mask(fio_opt_groups, mask, FIO_OPT_C_INVALID);
1086}
1087
1088static struct opt_group fio_opt_cat_groups[] = {
3e260a46
JA
1089 {
1090 .name = "Latency profiling",
1091 .mask = FIO_OPT_G_LATPROF,
1092 },
9af4a244 1093 {
e8b0e958
JA
1094 .name = "Rate",
1095 .mask = FIO_OPT_G_RATE,
9af4a244
JA
1096 },
1097 {
e8b0e958
JA
1098 .name = "Zone",
1099 .mask = FIO_OPT_G_ZONE,
9af4a244
JA
1100 },
1101 {
e8b0e958
JA
1102 .name = "Read/write mix",
1103 .mask = FIO_OPT_G_RWMIX,
9af4a244
JA
1104 },
1105 {
1106 .name = "Verify",
1107 .mask = FIO_OPT_G_VERIFY,
1108 },
1109 {
e8b0e958
JA
1110 .name = "Trim",
1111 .mask = FIO_OPT_G_TRIM,
9af4a244
JA
1112 },
1113 {
e8b0e958
JA
1114 .name = "I/O Logging",
1115 .mask = FIO_OPT_G_IOLOG,
9af4a244
JA
1116 },
1117 {
e8b0e958
JA
1118 .name = "I/O Depth",
1119 .mask = FIO_OPT_G_IO_DEPTH,
9af4a244
JA
1120 },
1121 {
e8b0e958
JA
1122 .name = "I/O Flow",
1123 .mask = FIO_OPT_G_IO_FLOW,
9af4a244 1124 },
0626037e
JA
1125 {
1126 .name = "Description",
1127 .mask = FIO_OPT_G_DESC,
1128 },
1129 {
1130 .name = "Filename",
1131 .mask = FIO_OPT_G_FILENAME,
1132 },
1133 {
1134 .name = "General I/O",
1135 .mask = FIO_OPT_G_IO_BASIC,
1136 },
a1f6afec
JA
1137 {
1138 .name = "Cgroups",
1139 .mask = FIO_OPT_G_CGROUP,
1140 },
1141 {
1142 .name = "Runtime",
1143 .mask = FIO_OPT_G_RUNTIME,
1144 },
10860056
JA
1145 {
1146 .name = "Process",
1147 .mask = FIO_OPT_G_PROCESS,
1148 },
1149 {
1150 .name = "Job credentials / priority",
1151 .mask = FIO_OPT_G_CRED,
1152 },
1153 {
1154 .name = "Clock settings",
1155 .mask = FIO_OPT_G_CLOCK,
1156 },
3ceb458f
JA
1157 {
1158 .name = "I/O Type",
1159 .mask = FIO_OPT_G_IO_TYPE,
1160 },
1161 {
1162 .name = "I/O Thinktime",
1163 .mask = FIO_OPT_G_THINKTIME,
1164 },
1165 {
1166 .name = "Randomizations",
1167 .mask = FIO_OPT_G_RANDOM,
1168 },
1169 {
1170 .name = "I/O buffers",
1171 .mask = FIO_OPT_G_IO_BUF,
1172 },
13fca827
JA
1173 {
1174 .name = "Tiobench profile",
1175 .mask = FIO_OPT_G_TIOBENCH,
1176 },
65fa28ca
DE
1177 {
1178 .name = "MTD",
1179 .mask = FIO_OPT_G_MTD,
1180 },
13fca827 1181
9af4a244
JA
1182 {
1183 .name = NULL,
e8b0e958 1184 }
9af4a244
JA
1185};
1186
e8b0e958 1187struct opt_group *opt_group_cat_from_mask(unsigned int *mask)
9af4a244 1188{
e8b0e958 1189 return __opt_group_from_mask(fio_opt_cat_groups, mask, FIO_OPT_G_INVALID);
9af4a244
JA
1190}
1191
214e1eca
JA
1192/*
1193 * Map of job/command line options
1194 */
9af4a244 1195struct fio_option fio_options[FIO_MAX_OPTS] = {
214e1eca
JA
1196 {
1197 .name = "description",
e8b0e958 1198 .lname = "Description of job",
214e1eca
JA
1199 .type = FIO_OPT_STR_STORE,
1200 .off1 = td_var_offset(description),
1201 .help = "Text job description",
e8b0e958 1202 .category = FIO_OPT_C_GENERAL,
0626037e 1203 .group = FIO_OPT_G_DESC,
214e1eca
JA
1204 },
1205 {
1206 .name = "name",
e8b0e958 1207 .lname = "Job name",
214e1eca
JA
1208 .type = FIO_OPT_STR_STORE,
1209 .off1 = td_var_offset(name),
1210 .help = "Name of this job",
e8b0e958 1211 .category = FIO_OPT_C_GENERAL,
0626037e 1212 .group = FIO_OPT_G_DESC,
214e1eca 1213 },
214e1eca
JA
1214 {
1215 .name = "filename",
e8b0e958 1216 .lname = "Filename(s)",
214e1eca
JA
1217 .type = FIO_OPT_STR_STORE,
1218 .off1 = td_var_offset(filename),
1219 .cb = str_filename_cb,
f0d524b0 1220 .prio = -1, /* must come after "directory" */
214e1eca 1221 .help = "File(s) to use for the workload",
e8b0e958 1222 .category = FIO_OPT_C_FILE,
0626037e 1223 .group = FIO_OPT_G_FILENAME,
214e1eca 1224 },
90fef2d1 1225 {
e8b0e958
JA
1226 .name = "directory",
1227 .lname = "Directory",
1228 .type = FIO_OPT_STR_STORE,
1229 .off1 = td_var_offset(directory),
1230 .cb = str_directory_cb,
1231 .help = "Directory to store files in",
1232 .category = FIO_OPT_C_FILE,
0626037e 1233 .group = FIO_OPT_G_FILENAME,
90fef2d1 1234 },
de98bd30
JA
1235 {
1236 .name = "filename_format",
1237 .type = FIO_OPT_STR_STORE,
1238 .off1 = td_var_offset(filename_format),
1239 .prio = -1, /* must come after "directory" */
1240 .help = "Override default $jobname.$jobnum.$filenum naming",
1241 .def = "$jobname.$jobnum.$filenum",
93bb626a
JA
1242 .category = FIO_OPT_C_FILE,
1243 .group = FIO_OPT_G_FILENAME,
ad705bcb 1244 },
29c1349f
JA
1245 {
1246 .name = "lockfile",
e8b0e958 1247 .lname = "Lockfile",
4d4e80f2 1248 .type = FIO_OPT_STR,
4d4e80f2 1249 .off1 = td_var_offset(file_lock_mode),
29c1349f 1250 .help = "Lock file when doing IO to it",
bc6a0a5d 1251 .prio = 1,
29c1349f 1252 .parent = "filename",
d71c154c 1253 .hide = 0,
4d4e80f2 1254 .def = "none",
e8b0e958 1255 .category = FIO_OPT_C_FILE,
0626037e 1256 .group = FIO_OPT_G_FILENAME,
4d4e80f2
JA
1257 .posval = {
1258 { .ival = "none",
1259 .oval = FILE_LOCK_NONE,
1260 .help = "No file locking",
1261 },
1262 { .ival = "exclusive",
1263 .oval = FILE_LOCK_EXCLUSIVE,
1264 .help = "Exclusive file lock",
1265 },
1266 {
1267 .ival = "readwrite",
1268 .oval = FILE_LOCK_READWRITE,
1269 .help = "Read vs write lock",
1270 },
1271 },
29c1349f 1272 },
214e1eca
JA
1273 {
1274 .name = "opendir",
e8b0e958 1275 .lname = "Open directory",
214e1eca
JA
1276 .type = FIO_OPT_STR_STORE,
1277 .off1 = td_var_offset(opendir),
1278 .cb = str_opendir_cb,
1279 .help = "Recursively add files from this directory and down",
e8b0e958 1280 .category = FIO_OPT_C_FILE,
0626037e 1281 .group = FIO_OPT_G_FILENAME,
214e1eca
JA
1282 },
1283 {
1284 .name = "rw",
e8b0e958 1285 .lname = "Read/write",
d3aad8f2 1286 .alias = "readwrite",
214e1eca 1287 .type = FIO_OPT_STR,
211097b2 1288 .cb = str_rw_cb,
214e1eca
JA
1289 .off1 = td_var_offset(td_ddir),
1290 .help = "IO direction",
1291 .def = "read",
896cac2a 1292 .verify = rw_verify,
e8b0e958 1293 .category = FIO_OPT_C_IO,
0626037e 1294 .group = FIO_OPT_G_IO_BASIC,
214e1eca
JA
1295 .posval = {
1296 { .ival = "read",
1297 .oval = TD_DDIR_READ,
1298 .help = "Sequential read",
1299 },
1300 { .ival = "write",
1301 .oval = TD_DDIR_WRITE,
1302 .help = "Sequential write",
1303 },
6eaf09d6
SL
1304 { .ival = "trim",
1305 .oval = TD_DDIR_TRIM,
1306 .help = "Sequential trim",
1307 },
214e1eca
JA
1308 { .ival = "randread",
1309 .oval = TD_DDIR_RANDREAD,
1310 .help = "Random read",
1311 },
1312 { .ival = "randwrite",
1313 .oval = TD_DDIR_RANDWRITE,
1314 .help = "Random write",
1315 },
6eaf09d6
SL
1316 { .ival = "randtrim",
1317 .oval = TD_DDIR_RANDTRIM,
1318 .help = "Random trim",
1319 },
214e1eca
JA
1320 { .ival = "rw",
1321 .oval = TD_DDIR_RW,
1322 .help = "Sequential read and write mix",
1323 },
10b023db
JA
1324 { .ival = "readwrite",
1325 .oval = TD_DDIR_RW,
1326 .help = "Sequential read and write mix",
1327 },
214e1eca
JA
1328 { .ival = "randrw",
1329 .oval = TD_DDIR_RANDRW,
1330 .help = "Random read and write mix"
1331 },
82a90686
JA
1332 { .ival = "trimwrite",
1333 .oval = TD_DDIR_TRIMWRITE,
1334 .help = "Trim and write mix, trims preceding writes"
0e4dd95c 1335 },
214e1eca
JA
1336 },
1337 },
38dad62d
JA
1338 {
1339 .name = "rw_sequencer",
e8b0e958 1340 .lname = "RW Sequencer",
38dad62d
JA
1341 .type = FIO_OPT_STR,
1342 .off1 = td_var_offset(rw_seq),
1343 .help = "IO offset generator modifier",
1344 .def = "sequential",
e8b0e958 1345 .category = FIO_OPT_C_IO,
0626037e 1346 .group = FIO_OPT_G_IO_BASIC,
38dad62d
JA
1347 .posval = {
1348 { .ival = "sequential",
1349 .oval = RW_SEQ_SEQ,
1350 .help = "Generate sequential offsets",
1351 },
1352 { .ival = "identical",
1353 .oval = RW_SEQ_IDENT,
1354 .help = "Generate identical offsets",
1355 },
1356 },
1357 },
1358
214e1eca
JA
1359 {
1360 .name = "ioengine",
e8b0e958 1361 .lname = "IO Engine",
214e1eca
JA
1362 .type = FIO_OPT_STR_STORE,
1363 .off1 = td_var_offset(ioengine),
1364 .help = "IO engine to use",
58483fa4 1365 .def = FIO_PREFERRED_ENGINE,
e8b0e958 1366 .category = FIO_OPT_C_IO,
0626037e 1367 .group = FIO_OPT_G_IO_BASIC,
214e1eca
JA
1368 .posval = {
1369 { .ival = "sync",
1370 .help = "Use read/write",
1371 },
a31041ea 1372 { .ival = "psync",
1373 .help = "Use pread/pwrite",
1374 },
1d2af02a 1375 { .ival = "vsync",
03e20d68 1376 .help = "Use readv/writev",
1d2af02a 1377 },
07fc0acd
JA
1378#ifdef CONFIG_PWRITEV
1379 { .ival = "pvsync",
1380 .help = "Use preadv/pwritev",
1381 },
1382#endif
67bf9823 1383#ifdef CONFIG_LIBAIO
214e1eca
JA
1384 { .ival = "libaio",
1385 .help = "Linux native asynchronous IO",
1386 },
1387#endif
67bf9823 1388#ifdef CONFIG_POSIXAIO
214e1eca
JA
1389 { .ival = "posixaio",
1390 .help = "POSIX asynchronous IO",
1391 },
417f0068 1392#endif
997843cb 1393#ifdef CONFIG_SOLARISAIO
417f0068
JA
1394 { .ival = "solarisaio",
1395 .help = "Solaris native asynchronous IO",
1396 },
214e1eca 1397#endif
4700b234 1398#ifdef CONFIG_WINDOWSAIO
03e20d68 1399 { .ival = "windowsaio",
3be80071 1400 .help = "Windows native asynchronous IO"
de890a1e 1401 },
fc5c0345
DG
1402#endif
1403#ifdef CONFIG_RBD
1404 { .ival = "rbd",
1405 .help = "Rados Block Device asynchronous IO"
1406 },
3be80071 1407#endif
214e1eca 1408 { .ival = "mmap",
03e20d68 1409 .help = "Memory mapped IO"
214e1eca 1410 },
67bf9823 1411#ifdef CONFIG_LINUX_SPLICE
214e1eca
JA
1412 { .ival = "splice",
1413 .help = "splice/vmsplice based IO",
1414 },
9cce02e8
JA
1415 { .ival = "netsplice",
1416 .help = "splice/vmsplice to/from the network",
1417 },
214e1eca
JA
1418#endif
1419#ifdef FIO_HAVE_SGIO
1420 { .ival = "sg",
1421 .help = "SCSI generic v3 IO",
1422 },
1423#endif
1424 { .ival = "null",
1425 .help = "Testing engine (no data transfer)",
1426 },
1427 { .ival = "net",
1428 .help = "Network IO",
1429 },
214e1eca 1430 { .ival = "cpuio",
03e20d68 1431 .help = "CPU cycle burner engine",
214e1eca 1432 },
67bf9823 1433#ifdef CONFIG_GUASI
b8c82a46
JA
1434 { .ival = "guasi",
1435 .help = "GUASI IO engine",
1436 },
79a43187
JA
1437#endif
1438#ifdef FIO_HAVE_BINJECT
1439 { .ival = "binject",
1440 .help = "binject direct inject block engine",
1441 },
21b8aee8 1442#endif
67bf9823 1443#ifdef CONFIG_RDMA
21b8aee8 1444 { .ival = "rdma",
1445 .help = "RDMA IO engine",
1446 },
8200b8c7 1447#endif
67bf9823 1448#ifdef CONFIG_FUSION_AW
8200b8c7
JA
1449 { .ival = "fusion-aw-sync",
1450 .help = "Fusion-io atomic write engine",
1451 },
1ecc95ca 1452#endif
997843cb 1453#ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
1ecc95ca
JA
1454 { .ival = "e4defrag",
1455 .help = "ext4 defrag engine",
1456 },
1457#endif
997843cb 1458#ifdef CONFIG_LINUX_FALLOCATE
1ecc95ca
JA
1459 { .ival = "falloc",
1460 .help = "fallocate() file based engine",
1461 },
b8c82a46 1462#endif
a7c386f4 1463#ifdef CONFIG_GFAPI
1464 { .ival = "gfapi",
cc47f094 1465 .help = "Glusterfs libgfapi(sync) based engine"
1466 },
1467 { .ival = "gfapi_async",
1468 .help = "Glusterfs libgfapi(async) based engine"
a7c386f4 1469 },
1470#endif
1b10477b 1471#ifdef CONFIG_LIBHDFS
b74e419e 1472 { .ival = "libhdfs",
1b10477b
MM
1473 .help = "Hadoop Distributed Filesystem (HDFS) engine"
1474 },
1475#endif
214e1eca
JA
1476 { .ival = "external",
1477 .help = "Load external engine (append name)",
1478 },
1479 },
1480 },
1481 {
1482 .name = "iodepth",
e8b0e958 1483 .lname = "IO Depth",
214e1eca
JA
1484 .type = FIO_OPT_INT,
1485 .off1 = td_var_offset(iodepth),
03e20d68 1486 .help = "Number of IO buffers to keep in flight",
757aff4f 1487 .minval = 1,
20eb06bd 1488 .interval = 1,
214e1eca 1489 .def = "1",
e8b0e958 1490 .category = FIO_OPT_C_IO,
0626037e 1491 .group = FIO_OPT_G_IO_BASIC,
214e1eca
JA
1492 },
1493 {
1494 .name = "iodepth_batch",
e8b0e958 1495 .lname = "IO Depth batch",
4950421a 1496 .alias = "iodepth_batch_submit",
214e1eca
JA
1497 .type = FIO_OPT_INT,
1498 .off1 = td_var_offset(iodepth_batch),
d65db441 1499 .help = "Number of IO buffers to submit in one go",
afdf9352 1500 .parent = "iodepth",
d71c154c 1501 .hide = 1,
a2e6f8ac 1502 .minval = 1,
20eb06bd 1503 .interval = 1,
a2e6f8ac 1504 .def = "1",
e8b0e958 1505 .category = FIO_OPT_C_IO,
0626037e 1506 .group = FIO_OPT_G_IO_BASIC,
4950421a
JA
1507 },
1508 {
82407585
RP
1509 .name = "iodepth_batch_complete_min",
1510 .lname = "Min IO depth batch complete",
1511 .alias = "iodepth_batch_complete",
4950421a 1512 .type = FIO_OPT_INT,
82407585
RP
1513 .off1 = td_var_offset(iodepth_batch_complete_min),
1514 .help = "Min number of IO buffers to retrieve in one go",
4950421a 1515 .parent = "iodepth",
d71c154c 1516 .hide = 1,
4950421a 1517 .minval = 0,
20eb06bd 1518 .interval = 1,
4950421a 1519 .def = "1",
e8b0e958 1520 .category = FIO_OPT_C_IO,
0626037e 1521 .group = FIO_OPT_G_IO_BASIC,
214e1eca 1522 },
82407585
RP
1523 {
1524 .name = "iodepth_batch_complete_max",
1525 .lname = "Max IO depth batch complete",
1526 .type = FIO_OPT_INT,
1527 .off1 = td_var_offset(iodepth_batch_complete_max),
1528 .help = "Max number of IO buffers to retrieve in one go",
1529 .parent = "iodepth",
1530 .hide = 1,
1531 .minval = 0,
1532 .interval = 1,
1533 .category = FIO_OPT_C_IO,
1534 .group = FIO_OPT_G_IO_BASIC,
1535 },
214e1eca
JA
1536 {
1537 .name = "iodepth_low",
e8b0e958 1538 .lname = "IO Depth batch low",
214e1eca
JA
1539 .type = FIO_OPT_INT,
1540 .off1 = td_var_offset(iodepth_low),
1541 .help = "Low water mark for queuing depth",
afdf9352 1542 .parent = "iodepth",
d71c154c 1543 .hide = 1,
20eb06bd 1544 .interval = 1,
e8b0e958 1545 .category = FIO_OPT_C_IO,
0626037e 1546 .group = FIO_OPT_G_IO_BASIC,
214e1eca 1547 },
a9da8ab2
JA
1548 {
1549 .name = "io_submit_mode",
1550 .lname = "IO submit mode",
1551 .type = FIO_OPT_STR,
1552 .off1 = td_var_offset(io_submit_mode),
1553 .help = "How IO submissions and completions are done",
1554 .def = "inline",
1555 .category = FIO_OPT_C_IO,
1556 .group = FIO_OPT_G_IO_BASIC,
1557 .posval = {
1558 { .ival = "inline",
1559 .oval = IO_MODE_INLINE,
1560 .help = "Submit and complete IO inline",
1561 },
1562 { .ival = "offload",
1563 .oval = IO_MODE_OFFLOAD,
1564 .help = "Offload submit and complete to threads",
1565 },
1566 },
1567 },
214e1eca
JA
1568 {
1569 .name = "size",
e8b0e958 1570 .lname = "Size",
214e1eca 1571 .type = FIO_OPT_STR_VAL,
7bb59102 1572 .cb = str_size_cb,
a8523a6a 1573 .off1 = td_var_offset(size),
214e1eca 1574 .help = "Total size of device or files",
20eb06bd 1575 .interval = 1024 * 1024,
e8b0e958
JA
1576 .category = FIO_OPT_C_IO,
1577 .group = FIO_OPT_G_INVALID,
214e1eca 1578 },
77731b29 1579 {
a4d3b4db
JA
1580 .name = "io_size",
1581 .alias = "io_limit",
1582 .lname = "IO Size",
77731b29
JA
1583 .type = FIO_OPT_STR_VAL,
1584 .off1 = td_var_offset(io_limit),
1585 .interval = 1024 * 1024,
1586 .category = FIO_OPT_C_IO,
1587 .group = FIO_OPT_G_INVALID,
1588 },
aa31f1f1
SL
1589 {
1590 .name = "fill_device",
e8b0e958 1591 .lname = "Fill device",
74586c1e 1592 .alias = "fill_fs",
aa31f1f1
SL
1593 .type = FIO_OPT_BOOL,
1594 .off1 = td_var_offset(fill_device),
1595 .help = "Write until an ENOSPC error occurs",
1596 .def = "0",
e8b0e958
JA
1597 .category = FIO_OPT_C_FILE,
1598 .group = FIO_OPT_G_INVALID,
aa31f1f1 1599 },
214e1eca
JA
1600 {
1601 .name = "filesize",
e8b0e958 1602 .lname = "File size",
214e1eca
JA
1603 .type = FIO_OPT_STR_VAL,
1604 .off1 = td_var_offset(file_size_low),
1605 .off2 = td_var_offset(file_size_high),
c3edbdba 1606 .minval = 1,
214e1eca 1607 .help = "Size of individual files",
20eb06bd 1608 .interval = 1024 * 1024,
e8b0e958
JA
1609 .category = FIO_OPT_C_FILE,
1610 .group = FIO_OPT_G_INVALID,
214e1eca 1611 },
bedc9dc2
JA
1612 {
1613 .name = "file_append",
1614 .lname = "File append",
1615 .type = FIO_OPT_BOOL,
1616 .off1 = td_var_offset(file_append),
1617 .help = "IO will start at the end of the file(s)",
1618 .def = "0",
1619 .category = FIO_OPT_C_FILE,
1620 .group = FIO_OPT_G_INVALID,
1621 },
67a1000f
JA
1622 {
1623 .name = "offset",
e8b0e958 1624 .lname = "IO offset",
67a1000f
JA
1625 .alias = "fileoffset",
1626 .type = FIO_OPT_STR_VAL,
1627 .off1 = td_var_offset(start_offset),
1628 .help = "Start IO from this offset",
1629 .def = "0",
20eb06bd 1630 .interval = 1024 * 1024,
e8b0e958
JA
1631 .category = FIO_OPT_C_IO,
1632 .group = FIO_OPT_G_INVALID,
67a1000f 1633 },
2d7cd868
JA
1634 {
1635 .name = "offset_increment",
e8b0e958 1636 .lname = "IO offset increment",
2d7cd868
JA
1637 .type = FIO_OPT_STR_VAL,
1638 .off1 = td_var_offset(offset_increment),
1639 .help = "What is the increment from one offset to the next",
1640 .parent = "offset",
d71c154c 1641 .hide = 1,
2d7cd868 1642 .def = "0",
20eb06bd 1643 .interval = 1024 * 1024,
e8b0e958
JA
1644 .category = FIO_OPT_C_IO,
1645 .group = FIO_OPT_G_INVALID,
2d7cd868 1646 },
ddf24e42
JA
1647 {
1648 .name = "number_ios",
1649 .lname = "Number of IOs to perform",
1650 .type = FIO_OPT_STR_VAL,
1651 .off1 = td_var_offset(number_ios),
be3fec7d 1652 .help = "Force job completion after this number of IOs",
ddf24e42
JA
1653 .def = "0",
1654 .category = FIO_OPT_C_IO,
1655 .group = FIO_OPT_G_INVALID,
1656 },
214e1eca
JA
1657 {
1658 .name = "bs",
e8b0e958 1659 .lname = "Block size",
d3aad8f2 1660 .alias = "blocksize",
e01b22b8 1661 .type = FIO_OPT_INT,
214e1eca
JA
1662 .off1 = td_var_offset(bs[DDIR_READ]),
1663 .off2 = td_var_offset(bs[DDIR_WRITE]),
6eaf09d6 1664 .off3 = td_var_offset(bs[DDIR_TRIM]),
c3edbdba 1665 .minval = 1,
214e1eca
JA
1666 .help = "Block size unit",
1667 .def = "4k",
67a1000f 1668 .parent = "rw",
d71c154c 1669 .hide = 1,
20eb06bd 1670 .interval = 512,
e8b0e958
JA
1671 .category = FIO_OPT_C_IO,
1672 .group = FIO_OPT_G_INVALID,
214e1eca 1673 },
2b7a01d0
JA
1674 {
1675 .name = "ba",
e8b0e958 1676 .lname = "Block size align",
2b7a01d0 1677 .alias = "blockalign",
e01b22b8 1678 .type = FIO_OPT_INT,
2b7a01d0
JA
1679 .off1 = td_var_offset(ba[DDIR_READ]),
1680 .off2 = td_var_offset(ba[DDIR_WRITE]),
6eaf09d6 1681 .off3 = td_var_offset(ba[DDIR_TRIM]),
2b7a01d0
JA
1682 .minval = 1,
1683 .help = "IO block offset alignment",
1684 .parent = "rw",
d71c154c 1685 .hide = 1,
20eb06bd 1686 .interval = 512,
e8b0e958
JA
1687 .category = FIO_OPT_C_IO,
1688 .group = FIO_OPT_G_INVALID,
2b7a01d0 1689 },
214e1eca
JA
1690 {
1691 .name = "bsrange",
e8b0e958 1692 .lname = "Block size range",
d3aad8f2 1693 .alias = "blocksize_range",
214e1eca
JA
1694 .type = FIO_OPT_RANGE,
1695 .off1 = td_var_offset(min_bs[DDIR_READ]),
1696 .off2 = td_var_offset(max_bs[DDIR_READ]),
1697 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
1698 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
6eaf09d6
SL
1699 .off5 = td_var_offset(min_bs[DDIR_TRIM]),
1700 .off6 = td_var_offset(max_bs[DDIR_TRIM]),
c3edbdba 1701 .minval = 1,
214e1eca 1702 .help = "Set block size range (in more detail than bs)",
67a1000f 1703 .parent = "rw",
d71c154c 1704 .hide = 1,
20eb06bd 1705 .interval = 4096,
e8b0e958
JA
1706 .category = FIO_OPT_C_IO,
1707 .group = FIO_OPT_G_INVALID,
214e1eca 1708 },
564ca972
JA
1709 {
1710 .name = "bssplit",
e8b0e958 1711 .lname = "Block size split",
564ca972
JA
1712 .type = FIO_OPT_STR,
1713 .cb = str_bssplit_cb,
a8523a6a 1714 .off1 = td_var_offset(bssplit),
564ca972
JA
1715 .help = "Set a specific mix of block sizes",
1716 .parent = "rw",
d71c154c 1717 .hide = 1,
e8b0e958
JA
1718 .category = FIO_OPT_C_IO,
1719 .group = FIO_OPT_G_INVALID,
564ca972 1720 },
214e1eca
JA
1721 {
1722 .name = "bs_unaligned",
e8b0e958 1723 .lname = "Block size unaligned",
d3aad8f2 1724 .alias = "blocksize_unaligned",
214e1eca
JA
1725 .type = FIO_OPT_STR_SET,
1726 .off1 = td_var_offset(bs_unaligned),
1727 .help = "Don't sector align IO buffer sizes",
67a1000f 1728 .parent = "rw",
d71c154c 1729 .hide = 1,
e8b0e958
JA
1730 .category = FIO_OPT_C_IO,
1731 .group = FIO_OPT_G_INVALID,
214e1eca 1732 },
6aca9b3d
JA
1733 {
1734 .name = "bs_is_seq_rand",
1735 .lname = "Block size division is seq/random (not read/write)",
1736 .type = FIO_OPT_BOOL,
1737 .off1 = td_var_offset(bs_is_seq_rand),
86d59660 1738 .help = "Consider any blocksize setting to be sequential,random",
6aca9b3d
JA
1739 .def = "0",
1740 .parent = "blocksize",
1741 .category = FIO_OPT_C_IO,
1742 .group = FIO_OPT_G_INVALID,
1743 },
214e1eca
JA
1744 {
1745 .name = "randrepeat",
e8b0e958 1746 .lname = "Random repeatable",
214e1eca
JA
1747 .type = FIO_OPT_BOOL,
1748 .off1 = td_var_offset(rand_repeatable),
1749 .help = "Use repeatable random IO pattern",
1750 .def = "1",
67a1000f 1751 .parent = "rw",
d71c154c 1752 .hide = 1,
e8b0e958 1753 .category = FIO_OPT_C_IO,
3ceb458f 1754 .group = FIO_OPT_G_RANDOM,
214e1eca 1755 },
04778baf
JA
1756 {
1757 .name = "randseed",
1758 .lname = "The random generator seed",
363cffa7 1759 .type = FIO_OPT_STR_VAL,
04778baf
JA
1760 .off1 = td_var_offset(rand_seed),
1761 .help = "Set the random generator seed value",
40fe5e7b 1762 .def = "0x89",
04778baf
JA
1763 .parent = "rw",
1764 .category = FIO_OPT_C_IO,
1765 .group = FIO_OPT_G_RANDOM,
1766 },
2615cc4b
JA
1767 {
1768 .name = "use_os_rand",
e8b0e958 1769 .lname = "Use OS random",
54a21917
JA
1770 .type = FIO_OPT_DEPRECATED,
1771 .off1 = td_var_offset(dep_use_os_rand),
e8b0e958 1772 .category = FIO_OPT_C_IO,
3ceb458f 1773 .group = FIO_OPT_G_RANDOM,
2615cc4b 1774 },
214e1eca
JA
1775 {
1776 .name = "norandommap",
e8b0e958 1777 .lname = "No randommap",
214e1eca
JA
1778 .type = FIO_OPT_STR_SET,
1779 .off1 = td_var_offset(norandommap),
1780 .help = "Accept potential duplicate random blocks",
67a1000f 1781 .parent = "rw",
d71c154c 1782 .hide = 1,
b2452a43 1783 .hide_on_set = 1,
e8b0e958 1784 .category = FIO_OPT_C_IO,
3ceb458f 1785 .group = FIO_OPT_G_RANDOM,
214e1eca 1786 },
2b386d25
JA
1787 {
1788 .name = "softrandommap",
e8b0e958 1789 .lname = "Soft randommap",
2b386d25
JA
1790 .type = FIO_OPT_BOOL,
1791 .off1 = td_var_offset(softrandommap),
f66ab3c8 1792 .help = "Set norandommap if randommap allocation fails",
2b386d25 1793 .parent = "norandommap",
d71c154c 1794 .hide = 1,
2b386d25 1795 .def = "0",
e8b0e958 1796 .category = FIO_OPT_C_IO,
3ceb458f 1797 .group = FIO_OPT_G_RANDOM,
2b386d25 1798 },
8055e41d
JA
1799 {
1800 .name = "random_generator",
1801 .type = FIO_OPT_STR,
1802 .off1 = td_var_offset(random_generator),
1803 .help = "Type of random number generator to use",
1804 .def = "tausworthe",
1805 .posval = {
1806 { .ival = "tausworthe",
1807 .oval = FIO_RAND_GEN_TAUSWORTHE,
1808 .help = "Strong Tausworthe generator",
1809 },
1810 { .ival = "lfsr",
1811 .oval = FIO_RAND_GEN_LFSR,
1812 .help = "Variable length LFSR",
1813 },
c3546b53
JA
1814 {
1815 .ival = "tausworthe64",
1816 .oval = FIO_RAND_GEN_TAUSWORTHE64,
1817 .help = "64-bit Tausworthe variant",
1818 },
8055e41d 1819 },
48107598
JA
1820 .category = FIO_OPT_C_IO,
1821 .group = FIO_OPT_G_RANDOM,
8055e41d 1822 },
e25839d4
JA
1823 {
1824 .name = "random_distribution",
1825 .type = FIO_OPT_STR,
1826 .off1 = td_var_offset(random_distribution),
1827 .cb = str_random_distribution_cb,
1828 .help = "Random offset distribution generator",
1829 .def = "random",
1830 .posval = {
1831 { .ival = "random",
1832 .oval = FIO_RAND_DIST_RANDOM,
1833 .help = "Completely random",
1834 },
1835 { .ival = "zipf",
1836 .oval = FIO_RAND_DIST_ZIPF,
1837 .help = "Zipf distribution",
1838 },
925fee33
JA
1839 { .ival = "pareto",
1840 .oval = FIO_RAND_DIST_PARETO,
1841 .help = "Pareto distribution",
1842 },
56d9fa4b
JA
1843 { .ival = "normal",
1844 .oval = FIO_RAND_DIST_GAUSS,
1845 .help = "Normal (gaussian) distribution",
1846 },
e25839d4 1847 },
48107598
JA
1848 .category = FIO_OPT_C_IO,
1849 .group = FIO_OPT_G_RANDOM,
e25839d4 1850 },
211c9b89
JA
1851 {
1852 .name = "percentage_random",
1853 .lname = "Percentage Random",
1854 .type = FIO_OPT_INT,
d9472271
JA
1855 .off1 = td_var_offset(perc_rand[DDIR_READ]),
1856 .off2 = td_var_offset(perc_rand[DDIR_WRITE]),
1857 .off3 = td_var_offset(perc_rand[DDIR_TRIM]),
211c9b89
JA
1858 .maxval = 100,
1859 .help = "Percentage of seq/random mix that should be random",
d9472271 1860 .def = "100,100,100",
211c9b89
JA
1861 .interval = 5,
1862 .inverse = "percentage_sequential",
1863 .category = FIO_OPT_C_IO,
1864 .group = FIO_OPT_G_RANDOM,
1865 },
1866 {
1867 .name = "percentage_sequential",
1868 .lname = "Percentage Sequential",
d9472271 1869 .type = FIO_OPT_DEPRECATED,
211c9b89
JA
1870 .category = FIO_OPT_C_IO,
1871 .group = FIO_OPT_G_RANDOM,
1872 },
56e2a5fc
CE
1873 {
1874 .name = "allrandrepeat",
1875 .type = FIO_OPT_BOOL,
1876 .off1 = td_var_offset(allrand_repeatable),
1877 .help = "Use repeatable random numbers for everything",
1878 .def = "0",
a869d9c6
JA
1879 .category = FIO_OPT_C_IO,
1880 .group = FIO_OPT_G_RANDOM,
56e2a5fc 1881 },
214e1eca
JA
1882 {
1883 .name = "nrfiles",
e8b0e958 1884 .lname = "Number of files",
d7c8be03 1885 .alias = "nr_files",
214e1eca
JA
1886 .type = FIO_OPT_INT,
1887 .off1 = td_var_offset(nr_files),
1888 .help = "Split job workload between this number of files",
1889 .def = "1",
20eb06bd 1890 .interval = 1,
e8b0e958
JA
1891 .category = FIO_OPT_C_FILE,
1892 .group = FIO_OPT_G_INVALID,
214e1eca
JA
1893 },
1894 {
1895 .name = "openfiles",
e8b0e958 1896 .lname = "Number of open files",
214e1eca
JA
1897 .type = FIO_OPT_INT,
1898 .off1 = td_var_offset(open_files),
1899 .help = "Number of files to keep open at the same time",
e8b0e958
JA
1900 .category = FIO_OPT_C_FILE,
1901 .group = FIO_OPT_G_INVALID,
214e1eca
JA
1902 },
1903 {
1904 .name = "file_service_type",
e8b0e958 1905 .lname = "File service type",
214e1eca
JA
1906 .type = FIO_OPT_STR,
1907 .cb = str_fst_cb,
1908 .off1 = td_var_offset(file_service_type),
1909 .help = "How to select which file to service next",
1910 .def = "roundrobin",
e8b0e958
JA
1911 .category = FIO_OPT_C_FILE,
1912 .group = FIO_OPT_G_INVALID,
214e1eca
JA
1913 .posval = {
1914 { .ival = "random",
1915 .oval = FIO_FSERVICE_RANDOM,
1916 .help = "Choose a file at random",
1917 },
1918 { .ival = "roundrobin",
1919 .oval = FIO_FSERVICE_RR,
1920 .help = "Round robin select files",
1921 },
a086c257
JA
1922 { .ival = "sequential",
1923 .oval = FIO_FSERVICE_SEQ,
1924 .help = "Finish one file before moving to the next",
1925 },
214e1eca 1926 },
67a1000f 1927 .parent = "nrfiles",
d71c154c 1928 .hide = 1,
67a1000f 1929 },
97ac992c 1930#ifdef CONFIG_POSIX_FALLOCATE
7bc8c2cf
JA
1931 {
1932 .name = "fallocate",
e8b0e958 1933 .lname = "Fallocate",
a596f047
EG
1934 .type = FIO_OPT_STR,
1935 .off1 = td_var_offset(fallocate_mode),
1936 .help = "Whether pre-allocation is performed when laying out files",
1937 .def = "posix",
e8b0e958
JA
1938 .category = FIO_OPT_C_FILE,
1939 .group = FIO_OPT_G_INVALID,
a596f047
EG
1940 .posval = {
1941 { .ival = "none",
1942 .oval = FIO_FALLOCATE_NONE,
1943 .help = "Do not pre-allocate space",
1944 },
1945 { .ival = "posix",
1946 .oval = FIO_FALLOCATE_POSIX,
1947 .help = "Use posix_fallocate()",
1948 },
97ac992c 1949#ifdef CONFIG_LINUX_FALLOCATE
a596f047
EG
1950 { .ival = "keep",
1951 .oval = FIO_FALLOCATE_KEEP_SIZE,
1952 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
1953 },
7bc8c2cf 1954#endif
a596f047
EG
1955 /* Compatibility with former boolean values */
1956 { .ival = "0",
1957 .oval = FIO_FALLOCATE_NONE,
1958 .help = "Alias for 'none'",
1959 },
1960 { .ival = "1",
1961 .oval = FIO_FALLOCATE_POSIX,
1962 .help = "Alias for 'posix'",
1963 },
1964 },
1965 },
97ac992c 1966#endif /* CONFIG_POSIX_FALLOCATE */
67a1000f
JA
1967 {
1968 .name = "fadvise_hint",
e8b0e958 1969 .lname = "Fadvise hint",
67a1000f
JA
1970 .type = FIO_OPT_BOOL,
1971 .off1 = td_var_offset(fadvise_hint),
1972 .help = "Use fadvise() to advise the kernel on IO pattern",
1973 .def = "1",
e8b0e958
JA
1974 .category = FIO_OPT_C_FILE,
1975 .group = FIO_OPT_G_INVALID,
214e1eca 1976 },
37659335
JA
1977#ifdef FIO_HAVE_STREAMID
1978 {
1979 .name = "fadvise_stream",
1980 .lname = "Fadvise stream",
1981 .type = FIO_OPT_INT,
1982 .off1 = td_var_offset(fadvise_stream),
1983 .help = "Use fadvise() to set stream ID",
1984 .category = FIO_OPT_C_FILE,
1985 .group = FIO_OPT_G_INVALID,
1986 },
1987#endif
214e1eca
JA
1988 {
1989 .name = "fsync",
e8b0e958 1990 .lname = "Fsync",
214e1eca
JA
1991 .type = FIO_OPT_INT,
1992 .off1 = td_var_offset(fsync_blocks),
1993 .help = "Issue fsync for writes every given number of blocks",
1994 .def = "0",
20eb06bd 1995 .interval = 1,
e8b0e958
JA
1996 .category = FIO_OPT_C_FILE,
1997 .group = FIO_OPT_G_INVALID,
214e1eca 1998 },
5f9099ea
JA
1999 {
2000 .name = "fdatasync",
e8b0e958 2001 .lname = "Fdatasync",
5f9099ea
JA
2002 .type = FIO_OPT_INT,
2003 .off1 = td_var_offset(fdatasync_blocks),
2004 .help = "Issue fdatasync for writes every given number of blocks",
2005 .def = "0",
20eb06bd 2006 .interval = 1,
e8b0e958
JA
2007 .category = FIO_OPT_C_FILE,
2008 .group = FIO_OPT_G_INVALID,
5f9099ea 2009 },
1ef2b6be
JA
2010 {
2011 .name = "write_barrier",
e8b0e958 2012 .lname = "Write barrier",
1ef2b6be
JA
2013 .type = FIO_OPT_INT,
2014 .off1 = td_var_offset(barrier_blocks),
2015 .help = "Make every Nth write a barrier write",
2016 .def = "0",
20eb06bd 2017 .interval = 1,
e8b0e958
JA
2018 .category = FIO_OPT_C_IO,
2019 .group = FIO_OPT_G_INVALID,
1ef2b6be 2020 },
67bf9823 2021#ifdef CONFIG_SYNC_FILE_RANGE
44f29692
JA
2022 {
2023 .name = "sync_file_range",
e8b0e958 2024 .lname = "Sync file range",
44f29692
JA
2025 .posval = {
2026 { .ival = "wait_before",
2027 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
2028 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
ebadc0ce 2029 .orval = 1,
44f29692
JA
2030 },
2031 { .ival = "write",
2032 .oval = SYNC_FILE_RANGE_WRITE,
2033 .help = "SYNC_FILE_RANGE_WRITE",
ebadc0ce 2034 .orval = 1,
44f29692
JA
2035 },
2036 {
2037 .ival = "wait_after",
2038 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
2039 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
ebadc0ce 2040 .orval = 1,
44f29692
JA
2041 },
2042 },
3843deb3 2043 .type = FIO_OPT_STR_MULTI,
44f29692
JA
2044 .cb = str_sfr_cb,
2045 .off1 = td_var_offset(sync_file_range),
2046 .help = "Use sync_file_range()",
e8b0e958
JA
2047 .category = FIO_OPT_C_FILE,
2048 .group = FIO_OPT_G_INVALID,
44f29692
JA
2049 },
2050#endif
214e1eca
JA
2051 {
2052 .name = "direct",
e8b0e958 2053 .lname = "Direct I/O",
214e1eca
JA
2054 .type = FIO_OPT_BOOL,
2055 .off1 = td_var_offset(odirect),
2056 .help = "Use O_DIRECT IO (negates buffered)",
2057 .def = "0",
a01a1bc5 2058 .inverse = "buffered",
e8b0e958 2059 .category = FIO_OPT_C_IO,
3ceb458f 2060 .group = FIO_OPT_G_IO_TYPE,
214e1eca 2061 },
d01612f3
CM
2062 {
2063 .name = "atomic",
2064 .lname = "Atomic I/O",
2065 .type = FIO_OPT_BOOL,
2066 .off1 = td_var_offset(oatomic),
2067 .help = "Use Atomic IO with O_DIRECT (implies O_DIRECT)",
2068 .def = "0",
2069 .category = FIO_OPT_C_IO,
2070 .group = FIO_OPT_G_IO_TYPE,
2071 },
214e1eca
JA
2072 {
2073 .name = "buffered",
e8b0e958 2074 .lname = "Buffered I/O",
214e1eca
JA
2075 .type = FIO_OPT_BOOL,
2076 .off1 = td_var_offset(odirect),
2077 .neg = 1,
2078 .help = "Use buffered IO (negates direct)",
2079 .def = "1",
a01a1bc5 2080 .inverse = "direct",
e8b0e958 2081 .category = FIO_OPT_C_IO,
3ceb458f 2082 .group = FIO_OPT_G_IO_TYPE,
214e1eca
JA
2083 },
2084 {
2085 .name = "overwrite",
e8b0e958 2086 .lname = "Overwrite",
214e1eca
JA
2087 .type = FIO_OPT_BOOL,
2088 .off1 = td_var_offset(overwrite),
2089 .help = "When writing, set whether to overwrite current data",
2090 .def = "0",
e8b0e958
JA
2091 .category = FIO_OPT_C_FILE,
2092 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2093 },
2094 {
2095 .name = "loops",
e8b0e958 2096 .lname = "Loops",
214e1eca
JA
2097 .type = FIO_OPT_INT,
2098 .off1 = td_var_offset(loops),
2099 .help = "Number of times to run the job",
2100 .def = "1",
20eb06bd 2101 .interval = 1,
e8b0e958 2102 .category = FIO_OPT_C_GENERAL,
a1f6afec 2103 .group = FIO_OPT_G_RUNTIME,
214e1eca
JA
2104 },
2105 {
2106 .name = "numjobs",
e8b0e958 2107 .lname = "Number of jobs",
214e1eca
JA
2108 .type = FIO_OPT_INT,
2109 .off1 = td_var_offset(numjobs),
2110 .help = "Duplicate this job this many times",
2111 .def = "1",
20eb06bd 2112 .interval = 1,
e8b0e958 2113 .category = FIO_OPT_C_GENERAL,
a1f6afec 2114 .group = FIO_OPT_G_RUNTIME,
214e1eca
JA
2115 },
2116 {
2117 .name = "startdelay",
e8b0e958 2118 .lname = "Start delay",
a5737c93 2119 .type = FIO_OPT_STR_VAL_TIME,
214e1eca 2120 .off1 = td_var_offset(start_delay),
23ed19b0 2121 .off2 = td_var_offset(start_delay_high),
214e1eca
JA
2122 .help = "Only start job when this period has passed",
2123 .def = "0",
0de5b26f 2124 .is_seconds = 1,
88038bc7 2125 .is_time = 1,
e8b0e958 2126 .category = FIO_OPT_C_GENERAL,
a1f6afec 2127 .group = FIO_OPT_G_RUNTIME,
214e1eca
JA
2128 },
2129 {
2130 .name = "runtime",
e8b0e958 2131 .lname = "Runtime",
214e1eca
JA
2132 .alias = "timeout",
2133 .type = FIO_OPT_STR_VAL_TIME,
2134 .off1 = td_var_offset(timeout),
2135 .help = "Stop workload when this amount of time has passed",
2136 .def = "0",
0de5b26f 2137 .is_seconds = 1,
88038bc7 2138 .is_time = 1,
e8b0e958 2139 .category = FIO_OPT_C_GENERAL,
a1f6afec 2140 .group = FIO_OPT_G_RUNTIME,
214e1eca 2141 },
cf4464ca
JA
2142 {
2143 .name = "time_based",
e8b0e958 2144 .lname = "Time based",
cf4464ca
JA
2145 .type = FIO_OPT_STR_SET,
2146 .off1 = td_var_offset(time_based),
2147 .help = "Keep running until runtime/timeout is met",
e8b0e958 2148 .category = FIO_OPT_C_GENERAL,
a1f6afec 2149 .group = FIO_OPT_G_RUNTIME,
cf4464ca 2150 },
62167762
JC
2151 {
2152 .name = "verify_only",
2153 .lname = "Verify only",
2154 .type = FIO_OPT_STR_SET,
2155 .off1 = td_var_offset(verify_only),
2156 .help = "Verifies previously written data is still valid",
2157 .category = FIO_OPT_C_GENERAL,
2158 .group = FIO_OPT_G_RUNTIME,
2159 },
721938ae
JA
2160 {
2161 .name = "ramp_time",
e8b0e958 2162 .lname = "Ramp time",
721938ae
JA
2163 .type = FIO_OPT_STR_VAL_TIME,
2164 .off1 = td_var_offset(ramp_time),
2165 .help = "Ramp up time before measuring performance",
0de5b26f 2166 .is_seconds = 1,
88038bc7 2167 .is_time = 1,
e8b0e958 2168 .category = FIO_OPT_C_GENERAL,
a1f6afec 2169 .group = FIO_OPT_G_RUNTIME,
721938ae 2170 },
c223da83
JA
2171 {
2172 .name = "clocksource",
e8b0e958 2173 .lname = "Clock source",
c223da83
JA
2174 .type = FIO_OPT_STR,
2175 .cb = fio_clock_source_cb,
2176 .off1 = td_var_offset(clocksource),
2177 .help = "What type of timing source to use",
e8b0e958 2178 .category = FIO_OPT_C_GENERAL,
10860056 2179 .group = FIO_OPT_G_CLOCK,
c223da83 2180 .posval = {
67bf9823 2181#ifdef CONFIG_GETTIMEOFDAY
c223da83
JA
2182 { .ival = "gettimeofday",
2183 .oval = CS_GTOD,
2184 .help = "Use gettimeofday(2) for timing",
2185 },
67bf9823
JA
2186#endif
2187#ifdef CONFIG_CLOCK_GETTIME
c223da83
JA
2188 { .ival = "clock_gettime",
2189 .oval = CS_CGETTIME,
2190 .help = "Use clock_gettime(2) for timing",
2191 },
67bf9823 2192#endif
c223da83
JA
2193#ifdef ARCH_HAVE_CPU_CLOCK
2194 { .ival = "cpu",
2195 .oval = CS_CPUCLOCK,
2196 .help = "Use CPU private clock",
2197 },
2198#endif
2199 },
2200 },
214e1eca
JA
2201 {
2202 .name = "mem",
d3aad8f2 2203 .alias = "iomem",
e8b0e958 2204 .lname = "I/O Memory",
214e1eca
JA
2205 .type = FIO_OPT_STR,
2206 .cb = str_mem_cb,
2207 .off1 = td_var_offset(mem_type),
2208 .help = "Backing type for IO buffers",
2209 .def = "malloc",
e8b0e958
JA
2210 .category = FIO_OPT_C_IO,
2211 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2212 .posval = {
2213 { .ival = "malloc",
2214 .oval = MEM_MALLOC,
2215 .help = "Use malloc(3) for IO buffers",
2216 },
c8931876 2217#ifndef CONFIG_NO_SHM
37c8cdfe
JA
2218 { .ival = "shm",
2219 .oval = MEM_SHM,
2220 .help = "Use shared memory segments for IO buffers",
2221 },
214e1eca
JA
2222#ifdef FIO_HAVE_HUGETLB
2223 { .ival = "shmhuge",
2224 .oval = MEM_SHMHUGE,
2225 .help = "Like shm, but use huge pages",
2226 },
c8931876 2227#endif
b370e46a 2228#endif
37c8cdfe
JA
2229 { .ival = "mmap",
2230 .oval = MEM_MMAP,
2231 .help = "Use mmap(2) (file or anon) for IO buffers",
2232 },
217b0f1d
LG
2233 { .ival = "mmapshared",
2234 .oval = MEM_MMAPSHARED,
2235 .help = "Like mmap, but use the shared flag",
2236 },
214e1eca
JA
2237#ifdef FIO_HAVE_HUGETLB
2238 { .ival = "mmaphuge",
2239 .oval = MEM_MMAPHUGE,
2240 .help = "Like mmap, but use huge pages",
2241 },
2242#endif
2243 },
2244 },
d529ee19
JA
2245 {
2246 .name = "iomem_align",
2247 .alias = "mem_align",
e8b0e958 2248 .lname = "I/O memory alignment",
d529ee19
JA
2249 .type = FIO_OPT_INT,
2250 .off1 = td_var_offset(mem_align),
2251 .minval = 0,
2252 .help = "IO memory buffer offset alignment",
2253 .def = "0",
2254 .parent = "iomem",
d71c154c 2255 .hide = 1,
e8b0e958
JA
2256 .category = FIO_OPT_C_IO,
2257 .group = FIO_OPT_G_INVALID,
d529ee19 2258 },
214e1eca
JA
2259 {
2260 .name = "verify",
e8b0e958 2261 .lname = "Verify",
214e1eca
JA
2262 .type = FIO_OPT_STR,
2263 .off1 = td_var_offset(verify),
2264 .help = "Verify data written",
2265 .def = "0",
e8b0e958 2266 .category = FIO_OPT_C_IO,
3ceb458f 2267 .group = FIO_OPT_G_VERIFY,
214e1eca
JA
2268 .posval = {
2269 { .ival = "0",
2270 .oval = VERIFY_NONE,
2271 .help = "Don't do IO verification",
2272 },
fcca4b58
JA
2273 { .ival = "md5",
2274 .oval = VERIFY_MD5,
2275 .help = "Use md5 checksums for verification",
2276 },
d77a7af3
JA
2277 { .ival = "crc64",
2278 .oval = VERIFY_CRC64,
2279 .help = "Use crc64 checksums for verification",
2280 },
214e1eca
JA
2281 { .ival = "crc32",
2282 .oval = VERIFY_CRC32,
2283 .help = "Use crc32 checksums for verification",
2284 },
af497e6a 2285 { .ival = "crc32c-intel",
e3aaafc4
JA
2286 .oval = VERIFY_CRC32C,
2287 .help = "Use crc32c checksums for verification (hw assisted, if available)",
af497e6a 2288 },
bac39e0e
JA
2289 { .ival = "crc32c",
2290 .oval = VERIFY_CRC32C,
e3aaafc4 2291 .help = "Use crc32c checksums for verification (hw assisted, if available)",
bac39e0e 2292 },
969f7ed3
JA
2293 { .ival = "crc16",
2294 .oval = VERIFY_CRC16,
2295 .help = "Use crc16 checksums for verification",
2296 },
1e154bdb
JA
2297 { .ival = "crc7",
2298 .oval = VERIFY_CRC7,
2299 .help = "Use crc7 checksums for verification",
2300 },
7c353ceb
JA
2301 { .ival = "sha1",
2302 .oval = VERIFY_SHA1,
2303 .help = "Use sha1 checksums for verification",
2304 },
cd14cc10
JA
2305 { .ival = "sha256",
2306 .oval = VERIFY_SHA256,
2307 .help = "Use sha256 checksums for verification",
2308 },
2309 { .ival = "sha512",
2310 .oval = VERIFY_SHA512,
2311 .help = "Use sha512 checksums for verification",
2312 },
844ea602
JA
2313 { .ival = "xxhash",
2314 .oval = VERIFY_XXHASH,
2315 .help = "Use xxhash checksums for verification",
2316 },
b638d82f
RP
2317 /* Meta information was included into verify_header,
2318 * 'meta' verification is implied by default. */
7437ee87 2319 { .ival = "meta",
b638d82f
RP
2320 .oval = VERIFY_HDR_ONLY,
2321 .help = "Use io information for verification. "
2322 "Now is implied by default, thus option is obsolete, "
2323 "don't use it",
7437ee87 2324 },
59245381
JA
2325 { .ival = "pattern",
2326 .oval = VERIFY_PATTERN_NO_HDR,
2327 .help = "Verify strict pattern",
2328 },
36690c9b
JA
2329 {
2330 .ival = "null",
2331 .oval = VERIFY_NULL,
2332 .help = "Pretend to verify",
2333 },
214e1eca
JA
2334 },
2335 },
005c565a
JA
2336 {
2337 .name = "do_verify",
e8b0e958 2338 .lname = "Perform verify step",
68e1f29a 2339 .type = FIO_OPT_BOOL,
005c565a
JA
2340 .off1 = td_var_offset(do_verify),
2341 .help = "Run verification stage after write",
2342 .def = "1",
2343 .parent = "verify",
d71c154c 2344 .hide = 1,
e8b0e958
JA
2345 .category = FIO_OPT_C_IO,
2346 .group = FIO_OPT_G_VERIFY,
005c565a 2347 },
160b966d
JA
2348 {
2349 .name = "verifysort",
e8b0e958 2350 .lname = "Verify sort",
160b966d
JA
2351 .type = FIO_OPT_BOOL,
2352 .off1 = td_var_offset(verifysort),
2353 .help = "Sort written verify blocks for read back",
2354 .def = "1",
c83f2df1 2355 .parent = "verify",
d71c154c 2356 .hide = 1,
e8b0e958
JA
2357 .category = FIO_OPT_C_IO,
2358 .group = FIO_OPT_G_VERIFY,
160b966d 2359 },
1ae83d45
JA
2360 {
2361 .name = "verifysort_nr",
2362 .type = FIO_OPT_INT,
2363 .off1 = td_var_offset(verifysort_nr),
2364 .help = "Pre-load and sort verify blocks for a read workload",
2365 .minval = 0,
2366 .maxval = 131072,
2367 .def = "1024",
2368 .parent = "verify",
836fcc0f
JA
2369 .category = FIO_OPT_C_IO,
2370 .group = FIO_OPT_G_VERIFY,
1ae83d45 2371 },
3f9f4e26 2372 {
a59e170d 2373 .name = "verify_interval",
e8b0e958 2374 .lname = "Verify interval",
e01b22b8 2375 .type = FIO_OPT_INT,
a59e170d 2376 .off1 = td_var_offset(verify_interval),
819a9680 2377 .minval = 2 * sizeof(struct verify_header),
a59e170d 2378 .help = "Store verify buffer header every N bytes",
afdf9352 2379 .parent = "verify",
d71c154c 2380 .hide = 1,
20eb06bd 2381 .interval = 2 * sizeof(struct verify_header),
e8b0e958
JA
2382 .category = FIO_OPT_C_IO,
2383 .group = FIO_OPT_G_VERIFY,
3f9f4e26 2384 },
546a9142 2385 {
a59e170d 2386 .name = "verify_offset",
e8b0e958 2387 .lname = "Verify offset",
e01b22b8 2388 .type = FIO_OPT_INT,
a59e170d 2389 .help = "Offset verify header location by N bytes",
203160d5
JA
2390 .off1 = td_var_offset(verify_offset),
2391 .minval = sizeof(struct verify_header),
afdf9352 2392 .parent = "verify",
d71c154c 2393 .hide = 1,
e8b0e958
JA
2394 .category = FIO_OPT_C_IO,
2395 .group = FIO_OPT_G_VERIFY,
546a9142 2396 },
e28218f3
SL
2397 {
2398 .name = "verify_pattern",
e8b0e958 2399 .lname = "Verify pattern",
0e92f873 2400 .type = FIO_OPT_STR,
e28218f3 2401 .cb = str_verify_pattern_cb,
a8523a6a 2402 .off1 = td_var_offset(verify_pattern),
e28218f3
SL
2403 .help = "Fill pattern for IO buffers",
2404 .parent = "verify",
d71c154c 2405 .hide = 1,
e8b0e958
JA
2406 .category = FIO_OPT_C_IO,
2407 .group = FIO_OPT_G_VERIFY,
e28218f3 2408 },
a12a3b4d
JA
2409 {
2410 .name = "verify_fatal",
e8b0e958 2411 .lname = "Verify fatal",
68e1f29a 2412 .type = FIO_OPT_BOOL,
a12a3b4d
JA
2413 .off1 = td_var_offset(verify_fatal),
2414 .def = "0",
2415 .help = "Exit on a single verify failure, don't continue",
2416 .parent = "verify",
d71c154c 2417 .hide = 1,
e8b0e958
JA
2418 .category = FIO_OPT_C_IO,
2419 .group = FIO_OPT_G_VERIFY,
a12a3b4d 2420 },
b463e936
JA
2421 {
2422 .name = "verify_dump",
e8b0e958 2423 .lname = "Verify dump",
b463e936
JA
2424 .type = FIO_OPT_BOOL,
2425 .off1 = td_var_offset(verify_dump),
ef71e317 2426 .def = "0",
b463e936
JA
2427 .help = "Dump contents of good and bad blocks on failure",
2428 .parent = "verify",
d71c154c 2429 .hide = 1,
e8b0e958
JA
2430 .category = FIO_OPT_C_IO,
2431 .group = FIO_OPT_G_VERIFY,
b463e936 2432 },
e8462bd8
JA
2433 {
2434 .name = "verify_async",
e8b0e958 2435 .lname = "Verify asynchronously",
e8462bd8
JA
2436 .type = FIO_OPT_INT,
2437 .off1 = td_var_offset(verify_async),
2438 .def = "0",
2439 .help = "Number of async verifier threads to use",
2440 .parent = "verify",
d71c154c 2441 .hide = 1,
e8b0e958
JA
2442 .category = FIO_OPT_C_IO,
2443 .group = FIO_OPT_G_VERIFY,
e8462bd8 2444 },
9e144189
JA
2445 {
2446 .name = "verify_backlog",
e8b0e958 2447 .lname = "Verify backlog",
9e144189
JA
2448 .type = FIO_OPT_STR_VAL,
2449 .off1 = td_var_offset(verify_backlog),
2450 .help = "Verify after this number of blocks are written",
2451 .parent = "verify",
d71c154c 2452 .hide = 1,
e8b0e958
JA
2453 .category = FIO_OPT_C_IO,
2454 .group = FIO_OPT_G_VERIFY,
9e144189
JA
2455 },
2456 {
2457 .name = "verify_backlog_batch",
e8b0e958 2458 .lname = "Verify backlog batch",
9e144189
JA
2459 .type = FIO_OPT_INT,
2460 .off1 = td_var_offset(verify_batch),
2461 .help = "Verify this number of IO blocks",
0d29de83 2462 .parent = "verify",
d71c154c 2463 .hide = 1,
e8b0e958
JA
2464 .category = FIO_OPT_C_IO,
2465 .group = FIO_OPT_G_VERIFY,
9e144189 2466 },
e8462bd8
JA
2467#ifdef FIO_HAVE_CPU_AFFINITY
2468 {
2469 .name = "verify_async_cpus",
e8b0e958 2470 .lname = "Async verify CPUs",
e8462bd8
JA
2471 .type = FIO_OPT_STR,
2472 .cb = str_verify_cpus_allowed_cb,
a8523a6a 2473 .off1 = td_var_offset(verify_cpumask),
e8462bd8
JA
2474 .help = "Set CPUs allowed for async verify threads",
2475 .parent = "verify_async",
d71c154c 2476 .hide = 1,
e8b0e958
JA
2477 .category = FIO_OPT_C_IO,
2478 .group = FIO_OPT_G_VERIFY,
e8462bd8 2479 },
0d29de83 2480#endif
51aa2da8
JA
2481 {
2482 .name = "experimental_verify",
2483 .off1 = td_var_offset(experimental_verify),
2484 .type = FIO_OPT_BOOL,
b31eaac9 2485 .help = "Enable experimental verification",
ca09be4b
JA
2486 .parent = "verify",
2487 .category = FIO_OPT_C_IO,
2488 .group = FIO_OPT_G_VERIFY,
2489 },
2490 {
2491 .name = "verify_state_load",
2492 .lname = "Load verify state",
2493 .off1 = td_var_offset(verify_state),
2494 .type = FIO_OPT_BOOL,
2495 .help = "Load verify termination state",
2496 .parent = "verify",
2497 .category = FIO_OPT_C_IO,
2498 .group = FIO_OPT_G_VERIFY,
2499 },
2500 {
2501 .name = "verify_state_save",
2502 .lname = "Save verify state",
2503 .off1 = td_var_offset(verify_state_save),
2504 .type = FIO_OPT_BOOL,
2505 .def = "1",
2506 .help = "Save verify state on termination",
2507 .parent = "verify",
836fcc0f
JA
2508 .category = FIO_OPT_C_IO,
2509 .group = FIO_OPT_G_VERIFY,
51aa2da8 2510 },
0d29de83
JA
2511#ifdef FIO_HAVE_TRIM
2512 {
2513 .name = "trim_percentage",
e8b0e958 2514 .lname = "Trim percentage",
0d29de83 2515 .type = FIO_OPT_INT,
203160d5 2516 .off1 = td_var_offset(trim_percentage),
20eb06bd 2517 .minval = 0,
0d29de83
JA
2518 .maxval = 100,
2519 .help = "Number of verify blocks to discard/trim",
2520 .parent = "verify",
2521 .def = "0",
20eb06bd 2522 .interval = 1,
d71c154c 2523 .hide = 1,
e8b0e958
JA
2524 .category = FIO_OPT_C_IO,
2525 .group = FIO_OPT_G_TRIM,
0d29de83
JA
2526 },
2527 {
2528 .name = "trim_verify_zero",
e8b0e958 2529 .lname = "Verify trim zero",
20eb06bd 2530 .type = FIO_OPT_BOOL,
0d29de83
JA
2531 .help = "Verify that trim/discarded blocks are returned as zeroes",
2532 .off1 = td_var_offset(trim_zero),
2533 .parent = "trim_percentage",
d71c154c 2534 .hide = 1,
0d29de83 2535 .def = "1",
e8b0e958
JA
2536 .category = FIO_OPT_C_IO,
2537 .group = FIO_OPT_G_TRIM,
0d29de83
JA
2538 },
2539 {
2540 .name = "trim_backlog",
e8b0e958 2541 .lname = "Trim backlog",
0d29de83
JA
2542 .type = FIO_OPT_STR_VAL,
2543 .off1 = td_var_offset(trim_backlog),
2544 .help = "Trim after this number of blocks are written",
2545 .parent = "trim_percentage",
d71c154c 2546 .hide = 1,
20eb06bd 2547 .interval = 1,
e8b0e958
JA
2548 .category = FIO_OPT_C_IO,
2549 .group = FIO_OPT_G_TRIM,
0d29de83
JA
2550 },
2551 {
2552 .name = "trim_backlog_batch",
e8b0e958 2553 .lname = "Trim backlog batch",
0d29de83
JA
2554 .type = FIO_OPT_INT,
2555 .off1 = td_var_offset(trim_batch),
2556 .help = "Trim this number of IO blocks",
2557 .parent = "trim_percentage",
d71c154c 2558 .hide = 1,
20eb06bd 2559 .interval = 1,
e8b0e958
JA
2560 .category = FIO_OPT_C_IO,
2561 .group = FIO_OPT_G_TRIM,
0d29de83 2562 },
e8462bd8 2563#endif
214e1eca
JA
2564 {
2565 .name = "write_iolog",
e8b0e958 2566 .lname = "Write I/O log",
214e1eca
JA
2567 .type = FIO_OPT_STR_STORE,
2568 .off1 = td_var_offset(write_iolog_file),
2569 .help = "Store IO pattern to file",
e8b0e958
JA
2570 .category = FIO_OPT_C_IO,
2571 .group = FIO_OPT_G_IOLOG,
214e1eca
JA
2572 },
2573 {
2574 .name = "read_iolog",
e8b0e958 2575 .lname = "Read I/O log",
214e1eca
JA
2576 .type = FIO_OPT_STR_STORE,
2577 .off1 = td_var_offset(read_iolog_file),
2578 .help = "Playback IO pattern from file",
e8b0e958
JA
2579 .category = FIO_OPT_C_IO,
2580 .group = FIO_OPT_G_IOLOG,
214e1eca 2581 },
64bbb865
DN
2582 {
2583 .name = "replay_no_stall",
e8b0e958 2584 .lname = "Don't stall on replay",
20eb06bd 2585 .type = FIO_OPT_BOOL,
64bbb865
DN
2586 .off1 = td_var_offset(no_stall),
2587 .def = "0",
87e7a972 2588 .parent = "read_iolog",
d71c154c 2589 .hide = 1,
64bbb865 2590 .help = "Playback IO pattern file as fast as possible without stalls",
e8b0e958
JA
2591 .category = FIO_OPT_C_IO,
2592 .group = FIO_OPT_G_IOLOG,
64bbb865 2593 },
d1c46c04
DN
2594 {
2595 .name = "replay_redirect",
e8b0e958 2596 .lname = "Redirect device for replay",
d1c46c04
DN
2597 .type = FIO_OPT_STR_STORE,
2598 .off1 = td_var_offset(replay_redirect),
2599 .parent = "read_iolog",
d71c154c 2600 .hide = 1,
d1c46c04 2601 .help = "Replay all I/O onto this device, regardless of trace device",
e8b0e958
JA
2602 .category = FIO_OPT_C_IO,
2603 .group = FIO_OPT_G_IOLOG,
d1c46c04 2604 },
0c63576e
JA
2605 {
2606 .name = "replay_scale",
2607 .lname = "Replace offset scale factor",
2608 .type = FIO_OPT_INT,
2609 .off1 = td_var_offset(replay_scale),
2610 .parent = "read_iolog",
2611 .def = "1",
2612 .help = "Align offsets to this blocksize",
2613 .category = FIO_OPT_C_IO,
2614 .group = FIO_OPT_G_IOLOG,
2615 },
2616 {
2617 .name = "replay_align",
2618 .lname = "Replace alignment",
2619 .type = FIO_OPT_INT,
2620 .off1 = td_var_offset(replay_align),
2621 .parent = "read_iolog",
2622 .help = "Scale offset down by this factor",
2623 .category = FIO_OPT_C_IO,
2624 .group = FIO_OPT_G_IOLOG,
2625 .pow2 = 1,
2626 },
214e1eca
JA
2627 {
2628 .name = "exec_prerun",
e8b0e958 2629 .lname = "Pre-execute runnable",
214e1eca
JA
2630 .type = FIO_OPT_STR_STORE,
2631 .off1 = td_var_offset(exec_prerun),
2632 .help = "Execute this file prior to running job",
e8b0e958
JA
2633 .category = FIO_OPT_C_GENERAL,
2634 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2635 },
2636 {
2637 .name = "exec_postrun",
e8b0e958 2638 .lname = "Post-execute runnable",
214e1eca
JA
2639 .type = FIO_OPT_STR_STORE,
2640 .off1 = td_var_offset(exec_postrun),
2641 .help = "Execute this file after running job",
e8b0e958
JA
2642 .category = FIO_OPT_C_GENERAL,
2643 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2644 },
2645#ifdef FIO_HAVE_IOSCHED_SWITCH
2646 {
2647 .name = "ioscheduler",
e8b0e958 2648 .lname = "I/O scheduler",
214e1eca
JA
2649 .type = FIO_OPT_STR_STORE,
2650 .off1 = td_var_offset(ioscheduler),
2651 .help = "Use this IO scheduler on the backing device",
e8b0e958
JA
2652 .category = FIO_OPT_C_FILE,
2653 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2654 },
2655#endif
2656 {
2657 .name = "zonesize",
e8b0e958 2658 .lname = "Zone size",
214e1eca
JA
2659 .type = FIO_OPT_STR_VAL,
2660 .off1 = td_var_offset(zone_size),
ed335855
SN
2661 .help = "Amount of data to read per zone",
2662 .def = "0",
20eb06bd 2663 .interval = 1024 * 1024,
e8b0e958
JA
2664 .category = FIO_OPT_C_IO,
2665 .group = FIO_OPT_G_ZONE,
ed335855
SN
2666 },
2667 {
2668 .name = "zonerange",
e8b0e958 2669 .lname = "Zone range",
ed335855
SN
2670 .type = FIO_OPT_STR_VAL,
2671 .off1 = td_var_offset(zone_range),
214e1eca
JA
2672 .help = "Give size of an IO zone",
2673 .def = "0",
20eb06bd 2674 .interval = 1024 * 1024,
e8b0e958
JA
2675 .category = FIO_OPT_C_IO,
2676 .group = FIO_OPT_G_ZONE,
214e1eca
JA
2677 },
2678 {
2679 .name = "zoneskip",
e8b0e958 2680 .lname = "Zone skip",
214e1eca
JA
2681 .type = FIO_OPT_STR_VAL,
2682 .off1 = td_var_offset(zone_skip),
2683 .help = "Space between IO zones",
2684 .def = "0",
20eb06bd 2685 .interval = 1024 * 1024,
e8b0e958
JA
2686 .category = FIO_OPT_C_IO,
2687 .group = FIO_OPT_G_ZONE,
214e1eca
JA
2688 },
2689 {
2690 .name = "lockmem",
e8b0e958 2691 .lname = "Lock memory",
214e1eca 2692 .type = FIO_OPT_STR_VAL,
1b79a070 2693 .off1 = td_var_offset(lockmem),
81c6b6cd 2694 .help = "Lock down this amount of memory (per worker)",
214e1eca 2695 .def = "0",
20eb06bd 2696 .interval = 1024 * 1024,
e8b0e958
JA
2697 .category = FIO_OPT_C_GENERAL,
2698 .group = FIO_OPT_G_INVALID,
214e1eca 2699 },
214e1eca
JA
2700 {
2701 .name = "rwmixread",
e8b0e958 2702 .lname = "Read/write mix read",
214e1eca 2703 .type = FIO_OPT_INT,
cb499fc4 2704 .cb = str_rwmix_read_cb,
a8523a6a 2705 .off1 = td_var_offset(rwmix[DDIR_READ]),
214e1eca
JA
2706 .maxval = 100,
2707 .help = "Percentage of mixed workload that is reads",
2708 .def = "50",
20eb06bd 2709 .interval = 5,
90265353 2710 .inverse = "rwmixwrite",
e8b0e958
JA
2711 .category = FIO_OPT_C_IO,
2712 .group = FIO_OPT_G_RWMIX,
214e1eca
JA
2713 },
2714 {
2715 .name = "rwmixwrite",
e8b0e958 2716 .lname = "Read/write mix write",
214e1eca 2717 .type = FIO_OPT_INT,
cb499fc4 2718 .cb = str_rwmix_write_cb,
a8523a6a 2719 .off1 = td_var_offset(rwmix[DDIR_WRITE]),
214e1eca
JA
2720 .maxval = 100,
2721 .help = "Percentage of mixed workload that is writes",
2722 .def = "50",
20eb06bd 2723 .interval = 5,
90265353 2724 .inverse = "rwmixread",
e8b0e958
JA
2725 .category = FIO_OPT_C_IO,
2726 .group = FIO_OPT_G_RWMIX,
214e1eca 2727 },
afdf9352
JA
2728 {
2729 .name = "rwmixcycle",
e8b0e958 2730 .lname = "Read/write mix cycle",
15ca150e 2731 .type = FIO_OPT_DEPRECATED,
e8b0e958
JA
2732 .category = FIO_OPT_C_IO,
2733 .group = FIO_OPT_G_RWMIX,
afdf9352 2734 },
214e1eca
JA
2735 {
2736 .name = "nice",
e8b0e958 2737 .lname = "Nice",
214e1eca
JA
2738 .type = FIO_OPT_INT,
2739 .off1 = td_var_offset(nice),
2740 .help = "Set job CPU nice value",
2741 .minval = -19,
2742 .maxval = 20,
2743 .def = "0",
20eb06bd 2744 .interval = 1,
e8b0e958 2745 .category = FIO_OPT_C_GENERAL,
10860056 2746 .group = FIO_OPT_G_CRED,
214e1eca
JA
2747 },
2748#ifdef FIO_HAVE_IOPRIO
2749 {
2750 .name = "prio",
e8b0e958 2751 .lname = "I/O nice priority",
214e1eca 2752 .type = FIO_OPT_INT,
28727df7 2753 .off1 = td_var_offset(ioprio),
214e1eca
JA
2754 .help = "Set job IO priority value",
2755 .minval = 0,
2756 .maxval = 7,
20eb06bd 2757 .interval = 1,
e8b0e958 2758 .category = FIO_OPT_C_GENERAL,
10860056 2759 .group = FIO_OPT_G_CRED,
214e1eca
JA
2760 },
2761 {
2762 .name = "prioclass",
e8b0e958 2763 .lname = "I/O nice priority class",
214e1eca 2764 .type = FIO_OPT_INT,
28727df7 2765 .off1 = td_var_offset(ioprio_class),
214e1eca
JA
2766 .help = "Set job IO priority class",
2767 .minval = 0,
2768 .maxval = 3,
20eb06bd 2769 .interval = 1,
e8b0e958 2770 .category = FIO_OPT_C_GENERAL,
10860056 2771 .group = FIO_OPT_G_CRED,
214e1eca
JA
2772 },
2773#endif
2774 {
2775 .name = "thinktime",
e8b0e958 2776 .lname = "Thinktime",
214e1eca
JA
2777 .type = FIO_OPT_INT,
2778 .off1 = td_var_offset(thinktime),
2779 .help = "Idle time between IO buffers (usec)",
2780 .def = "0",
88038bc7 2781 .is_time = 1,
e8b0e958 2782 .category = FIO_OPT_C_IO,
3ceb458f 2783 .group = FIO_OPT_G_THINKTIME,
214e1eca
JA
2784 },
2785 {
2786 .name = "thinktime_spin",
e8b0e958 2787 .lname = "Thinktime spin",
214e1eca
JA
2788 .type = FIO_OPT_INT,
2789 .off1 = td_var_offset(thinktime_spin),
2790 .help = "Start think time by spinning this amount (usec)",
2791 .def = "0",
88038bc7 2792 .is_time = 1,
afdf9352 2793 .parent = "thinktime",
d71c154c 2794 .hide = 1,
e8b0e958 2795 .category = FIO_OPT_C_IO,
3ceb458f 2796 .group = FIO_OPT_G_THINKTIME,
214e1eca
JA
2797 },
2798 {
2799 .name = "thinktime_blocks",
e8b0e958 2800 .lname = "Thinktime blocks",
214e1eca
JA
2801 .type = FIO_OPT_INT,
2802 .off1 = td_var_offset(thinktime_blocks),
2803 .help = "IO buffer period between 'thinktime'",
2804 .def = "1",
afdf9352 2805 .parent = "thinktime",
d71c154c 2806 .hide = 1,
e8b0e958 2807 .category = FIO_OPT_C_IO,
3ceb458f 2808 .group = FIO_OPT_G_THINKTIME,
214e1eca
JA
2809 },
2810 {
2811 .name = "rate",
e8b0e958 2812 .lname = "I/O rate",
e01b22b8 2813 .type = FIO_OPT_INT,
6eaf09d6
SL
2814 .off1 = td_var_offset(rate[DDIR_READ]),
2815 .off2 = td_var_offset(rate[DDIR_WRITE]),
2816 .off3 = td_var_offset(rate[DDIR_TRIM]),
214e1eca 2817 .help = "Set bandwidth rate",
e8b0e958
JA
2818 .category = FIO_OPT_C_IO,
2819 .group = FIO_OPT_G_RATE,
214e1eca
JA
2820 },
2821 {
6d428bcd
JA
2822 .name = "rate_min",
2823 .alias = "ratemin",
e8b0e958 2824 .lname = "I/O min rate",
e01b22b8 2825 .type = FIO_OPT_INT,
6eaf09d6
SL
2826 .off1 = td_var_offset(ratemin[DDIR_READ]),
2827 .off2 = td_var_offset(ratemin[DDIR_WRITE]),
2828 .off3 = td_var_offset(ratemin[DDIR_TRIM]),
4e991c23 2829 .help = "Job must meet this rate or it will be shutdown",
afdf9352 2830 .parent = "rate",
d71c154c 2831 .hide = 1,
e8b0e958
JA
2832 .category = FIO_OPT_C_IO,
2833 .group = FIO_OPT_G_RATE,
4e991c23
JA
2834 },
2835 {
2836 .name = "rate_iops",
e8b0e958 2837 .lname = "I/O rate IOPS",
e01b22b8 2838 .type = FIO_OPT_INT,
6eaf09d6
SL
2839 .off1 = td_var_offset(rate_iops[DDIR_READ]),
2840 .off2 = td_var_offset(rate_iops[DDIR_WRITE]),
2841 .off3 = td_var_offset(rate_iops[DDIR_TRIM]),
4e991c23 2842 .help = "Limit IO used to this number of IO operations/sec",
d71c154c 2843 .hide = 1,
e8b0e958
JA
2844 .category = FIO_OPT_C_IO,
2845 .group = FIO_OPT_G_RATE,
4e991c23
JA
2846 },
2847 {
2848 .name = "rate_iops_min",
e8b0e958 2849 .lname = "I/O min rate IOPS",
e01b22b8 2850 .type = FIO_OPT_INT,
6eaf09d6
SL
2851 .off1 = td_var_offset(rate_iops_min[DDIR_READ]),
2852 .off2 = td_var_offset(rate_iops_min[DDIR_WRITE]),
2853 .off3 = td_var_offset(rate_iops_min[DDIR_TRIM]),
03e20d68 2854 .help = "Job must meet this rate or it will be shut down",
afdf9352 2855 .parent = "rate_iops",
d71c154c 2856 .hide = 1,
e8b0e958
JA
2857 .category = FIO_OPT_C_IO,
2858 .group = FIO_OPT_G_RATE,
214e1eca 2859 },
ff6bb260 2860 {
6de65959
JA
2861 .name = "rate_process",
2862 .lname = "Rate Process",
2863 .type = FIO_OPT_STR,
2864 .off1 = td_var_offset(rate_process),
2865 .help = "What process controls how rated IO is managed",
2866 .def = "linear",
ff6bb260
SL
2867 .category = FIO_OPT_C_IO,
2868 .group = FIO_OPT_G_RATE,
6de65959
JA
2869 .posval = {
2870 { .ival = "linear",
2871 .oval = RATE_PROCESS_LINEAR,
2872 .help = "Linear rate of IO",
2873 },
2874 {
2875 .ival = "poisson",
2876 .oval = RATE_PROCESS_POISSON,
2877 .help = "Rate follows Poisson process",
2878 },
2879 },
2880 .parent = "rate",
ff6bb260 2881 },
214e1eca 2882 {
6d428bcd
JA
2883 .name = "rate_cycle",
2884 .alias = "ratecycle",
e8b0e958 2885 .lname = "I/O rate cycle",
214e1eca
JA
2886 .type = FIO_OPT_INT,
2887 .off1 = td_var_offset(ratecycle),
2888 .help = "Window average for rate limits (msec)",
2889 .def = "1000",
afdf9352 2890 .parent = "rate",
d71c154c 2891 .hide = 1,
e8b0e958
JA
2892 .category = FIO_OPT_C_IO,
2893 .group = FIO_OPT_G_RATE,
214e1eca 2894 },
15501535
JA
2895 {
2896 .name = "max_latency",
2897 .type = FIO_OPT_INT,
2898 .off1 = td_var_offset(max_latency),
2899 .help = "Maximum tolerated IO latency (usec)",
88038bc7 2900 .is_time = 1,
1e5324e7 2901 .category = FIO_OPT_C_IO,
3e260a46
JA
2902 .group = FIO_OPT_G_LATPROF,
2903 },
2904 {
2905 .name = "latency_target",
2906 .lname = "Latency Target (usec)",
2907 .type = FIO_OPT_STR_VAL_TIME,
2908 .off1 = td_var_offset(latency_target),
2909 .help = "Ramp to max queue depth supporting this latency",
88038bc7 2910 .is_time = 1,
3e260a46
JA
2911 .category = FIO_OPT_C_IO,
2912 .group = FIO_OPT_G_LATPROF,
2913 },
2914 {
2915 .name = "latency_window",
2916 .lname = "Latency Window (usec)",
2917 .type = FIO_OPT_STR_VAL_TIME,
2918 .off1 = td_var_offset(latency_window),
2919 .help = "Time to sustain latency_target",
88038bc7 2920 .is_time = 1,
3e260a46
JA
2921 .category = FIO_OPT_C_IO,
2922 .group = FIO_OPT_G_LATPROF,
2923 },
2924 {
2925 .name = "latency_percentile",
2926 .lname = "Latency Percentile",
2927 .type = FIO_OPT_FLOAT_LIST,
2928 .off1 = td_var_offset(latency_percentile),
2929 .help = "Percentile of IOs must be below latency_target",
2930 .def = "100",
2931 .maxlen = 1,
2932 .minfp = 0.0,
2933 .maxfp = 100.0,
2934 .category = FIO_OPT_C_IO,
2935 .group = FIO_OPT_G_LATPROF,
15501535 2936 },
214e1eca
JA
2937 {
2938 .name = "invalidate",
e8b0e958 2939 .lname = "Cache invalidate",
214e1eca
JA
2940 .type = FIO_OPT_BOOL,
2941 .off1 = td_var_offset(invalidate_cache),
2942 .help = "Invalidate buffer/page cache prior to running job",
2943 .def = "1",
e8b0e958 2944 .category = FIO_OPT_C_IO,
3ceb458f 2945 .group = FIO_OPT_G_IO_TYPE,
214e1eca
JA
2946 },
2947 {
2948 .name = "sync",
e8b0e958 2949 .lname = "Synchronous I/O",
214e1eca
JA
2950 .type = FIO_OPT_BOOL,
2951 .off1 = td_var_offset(sync_io),
2952 .help = "Use O_SYNC for buffered writes",
2953 .def = "0",
67a1000f 2954 .parent = "buffered",
d71c154c 2955 .hide = 1,
e8b0e958 2956 .category = FIO_OPT_C_IO,
3ceb458f 2957 .group = FIO_OPT_G_IO_TYPE,
214e1eca 2958 },
214e1eca
JA
2959 {
2960 .name = "create_serialize",
e8b0e958 2961 .lname = "Create serialize",
214e1eca
JA
2962 .type = FIO_OPT_BOOL,
2963 .off1 = td_var_offset(create_serialize),
2964 .help = "Serialize creating of job files",
2965 .def = "1",
e8b0e958
JA
2966 .category = FIO_OPT_C_FILE,
2967 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2968 },
2969 {
2970 .name = "create_fsync",
e8b0e958 2971 .lname = "Create fsync",
214e1eca
JA
2972 .type = FIO_OPT_BOOL,
2973 .off1 = td_var_offset(create_fsync),
03e20d68 2974 .help = "fsync file after creation",
214e1eca 2975 .def = "1",
e8b0e958
JA
2976 .category = FIO_OPT_C_FILE,
2977 .group = FIO_OPT_G_INVALID,
214e1eca 2978 },
814452bd
JA
2979 {
2980 .name = "create_on_open",
e8b0e958 2981 .lname = "Create on open",
814452bd
JA
2982 .type = FIO_OPT_BOOL,
2983 .off1 = td_var_offset(create_on_open),
2984 .help = "Create files when they are opened for IO",
2985 .def = "0",
e8b0e958
JA
2986 .category = FIO_OPT_C_FILE,
2987 .group = FIO_OPT_G_INVALID,
814452bd 2988 },
25460cf6
JA
2989 {
2990 .name = "create_only",
2991 .type = FIO_OPT_BOOL,
2992 .off1 = td_var_offset(create_only),
2993 .help = "Only perform file creation phase",
d17fda71 2994 .category = FIO_OPT_C_FILE,
25460cf6
JA
2995 .def = "0",
2996 },
2378826d
JA
2997 {
2998 .name = "allow_file_create",
e81ecca3 2999 .lname = "Allow file create",
2378826d
JA
3000 .type = FIO_OPT_BOOL,
3001 .off1 = td_var_offset(allow_create),
3002 .help = "Permit fio to create files, if they don't exist",
3003 .def = "1",
3004 .category = FIO_OPT_C_FILE,
3005 .group = FIO_OPT_G_FILENAME,
3006 },
e81ecca3
JA
3007 {
3008 .name = "allow_mounted_write",
3009 .lname = "Allow mounted write",
3010 .type = FIO_OPT_BOOL,
3011 .off1 = td_var_offset(allow_mounted_write),
3012 .help = "Allow writes to a mounted partition",
3013 .def = "0",
3014 .category = FIO_OPT_C_FILE,
3015 .group = FIO_OPT_G_FILENAME,
3016 },
0b9d69ec 3017 {
afad68f7 3018 .name = "pre_read",
e8b0e958 3019 .lname = "Pre-read files",
afad68f7
ZY
3020 .type = FIO_OPT_BOOL,
3021 .off1 = td_var_offset(pre_read),
03e20d68 3022 .help = "Pre-read files before starting official testing",
afad68f7 3023 .def = "0",
e8b0e958
JA
3024 .category = FIO_OPT_C_FILE,
3025 .group = FIO_OPT_G_INVALID,
afad68f7 3026 },
214e1eca
JA
3027#ifdef FIO_HAVE_CPU_AFFINITY
3028 {
3029 .name = "cpumask",
e8b0e958 3030 .lname = "CPU mask",
214e1eca
JA
3031 .type = FIO_OPT_INT,
3032 .cb = str_cpumask_cb,
a8523a6a 3033 .off1 = td_var_offset(cpumask),
214e1eca 3034 .help = "CPU affinity mask",
e8b0e958 3035 .category = FIO_OPT_C_GENERAL,
10860056 3036 .group = FIO_OPT_G_CRED,
214e1eca 3037 },
d2e268b0
JA
3038 {
3039 .name = "cpus_allowed",
e8b0e958 3040 .lname = "CPUs allowed",
d2e268b0
JA
3041 .type = FIO_OPT_STR,
3042 .cb = str_cpus_allowed_cb,
a8523a6a 3043 .off1 = td_var_offset(cpumask),
d2e268b0 3044 .help = "Set CPUs allowed",
e8b0e958 3045 .category = FIO_OPT_C_GENERAL,
10860056 3046 .group = FIO_OPT_G_CRED,
d2e268b0 3047 },
c2acfbac
JA
3048 {
3049 .name = "cpus_allowed_policy",
3050 .lname = "CPUs allowed distribution policy",
3051 .type = FIO_OPT_STR,
3052 .off1 = td_var_offset(cpus_allowed_policy),
3053 .help = "Distribution policy for cpus_allowed",
3054 .parent = "cpus_allowed",
3055 .prio = 1,
3056 .posval = {
3057 { .ival = "shared",
3058 .oval = FIO_CPUS_SHARED,
3059 .help = "Mask shared between threads",
3060 },
3061 { .ival = "split",
3062 .oval = FIO_CPUS_SPLIT,
3063 .help = "Mask split between threads",
3064 },
3065 },
3066 .category = FIO_OPT_C_GENERAL,
3067 .group = FIO_OPT_G_CRED,
3068 },
d0b937ed 3069#endif
67bf9823 3070#ifdef CONFIG_LIBNUMA
d0b937ed
YR
3071 {
3072 .name = "numa_cpu_nodes",
3073 .type = FIO_OPT_STR,
3074 .cb = str_numa_cpunodes_cb,
b2a9e649 3075 .off1 = td_var_offset(numa_cpunodes),
d0b937ed 3076 .help = "NUMA CPU nodes bind",
6be54b2d
JA
3077 .category = FIO_OPT_C_GENERAL,
3078 .group = FIO_OPT_G_INVALID,
d0b937ed
YR
3079 },
3080 {
3081 .name = "numa_mem_policy",
3082 .type = FIO_OPT_STR,
3083 .cb = str_numa_mpol_cb,
b2a9e649 3084 .off1 = td_var_offset(numa_memnodes),
d0b937ed 3085 .help = "NUMA memory policy setup",
6be54b2d
JA
3086 .category = FIO_OPT_C_GENERAL,
3087 .group = FIO_OPT_G_INVALID,
d0b937ed 3088 },
214e1eca
JA
3089#endif
3090 {
3091 .name = "end_fsync",
e8b0e958 3092 .lname = "End fsync",
214e1eca
JA
3093 .type = FIO_OPT_BOOL,
3094 .off1 = td_var_offset(end_fsync),
3095 .help = "Include fsync at the end of job",
3096 .def = "0",
e8b0e958
JA
3097 .category = FIO_OPT_C_FILE,
3098 .group = FIO_OPT_G_INVALID,
214e1eca
JA
3099 },
3100 {
3101 .name = "fsync_on_close",
e8b0e958 3102 .lname = "Fsync on close",
214e1eca
JA
3103 .type = FIO_OPT_BOOL,
3104 .off1 = td_var_offset(fsync_on_close),
3105 .help = "fsync files on close",
3106 .def = "0",
e8b0e958
JA
3107 .category = FIO_OPT_C_FILE,
3108 .group = FIO_OPT_G_INVALID,
214e1eca
JA
3109 },
3110 {
3111 .name = "unlink",
e8b0e958 3112 .lname = "Unlink file",
214e1eca
JA
3113 .type = FIO_OPT_BOOL,
3114 .off1 = td_var_offset(unlink),
3115 .help = "Unlink created files after job has completed",
3116 .def = "0",
e8b0e958
JA
3117 .category = FIO_OPT_C_FILE,
3118 .group = FIO_OPT_G_INVALID,
214e1eca
JA
3119 },
3120 {
3121 .name = "exitall",
e8b0e958 3122 .lname = "Exit-all on terminate",
214e1eca
JA
3123 .type = FIO_OPT_STR_SET,
3124 .cb = str_exitall_cb,
3125 .help = "Terminate all jobs when one exits",
e8b0e958 3126 .category = FIO_OPT_C_GENERAL,
a1f6afec 3127 .group = FIO_OPT_G_PROCESS,
214e1eca
JA
3128 },
3129 {
3130 .name = "stonewall",
e8b0e958 3131 .lname = "Wait for previous",
d392365e 3132 .alias = "wait_for_previous",
214e1eca
JA
3133 .type = FIO_OPT_STR_SET,
3134 .off1 = td_var_offset(stonewall),
3135 .help = "Insert a hard barrier between this job and previous",
e8b0e958 3136 .category = FIO_OPT_C_GENERAL,
a1f6afec 3137 .group = FIO_OPT_G_PROCESS,
214e1eca 3138 },
b3d62a75
JA
3139 {
3140 .name = "new_group",
e8b0e958 3141 .lname = "New group",
b3d62a75
JA
3142 .type = FIO_OPT_STR_SET,
3143 .off1 = td_var_offset(new_group),
3144 .help = "Mark the start of a new group (for reporting)",
e8b0e958 3145 .category = FIO_OPT_C_GENERAL,
a1f6afec 3146 .group = FIO_OPT_G_PROCESS,
b3d62a75 3147 },
214e1eca
JA
3148 {
3149 .name = "thread",
e8b0e958 3150 .lname = "Thread",
214e1eca
JA
3151 .type = FIO_OPT_STR_SET,
3152 .off1 = td_var_offset(use_thread),
20eb06bd 3153 .help = "Use threads instead of processes",
c8931876
JA
3154#ifdef CONFIG_NO_SHM
3155 .def = "1",
3156 .no_warn_def = 1,
3157#endif
e8b0e958 3158 .category = FIO_OPT_C_GENERAL,
a1f6afec 3159 .group = FIO_OPT_G_PROCESS,
214e1eca 3160 },
3a5db920
JA
3161 {
3162 .name = "per_job_logs",
3163 .type = FIO_OPT_BOOL,
3164 .off1 = td_var_offset(per_job_logs),
3165 .help = "Include job number in generated log files or not",
3166 .def = "1",
3167 .category = FIO_OPT_C_LOG,
3168 .group = FIO_OPT_G_INVALID,
3169 },
214e1eca
JA
3170 {
3171 .name = "write_bw_log",
e8b0e958 3172 .lname = "Write bandwidth log",
203160d5
JA
3173 .type = FIO_OPT_STR_STORE,
3174 .off1 = td_var_offset(bw_log_file),
214e1eca 3175 .help = "Write log of bandwidth during run",
e8b0e958
JA
3176 .category = FIO_OPT_C_LOG,
3177 .group = FIO_OPT_G_INVALID,
214e1eca
JA
3178 },
3179 {
3180 .name = "write_lat_log",
e8b0e958 3181 .lname = "Write latency log",
203160d5
JA
3182 .type = FIO_OPT_STR_STORE,
3183 .off1 = td_var_offset(lat_log_file),
214e1eca 3184 .help = "Write log of latency during run",
e8b0e958
JA
3185 .category = FIO_OPT_C_LOG,
3186 .group = FIO_OPT_G_INVALID,
214e1eca 3187 },
c8eeb9df
JA
3188 {
3189 .name = "write_iops_log",
e8b0e958 3190 .lname = "Write IOPS log",
577c83bd 3191 .type = FIO_OPT_STR_STORE,
203160d5 3192 .off1 = td_var_offset(iops_log_file),
c8eeb9df 3193 .help = "Write log of IOPS during run",
e8b0e958
JA
3194 .category = FIO_OPT_C_LOG,
3195 .group = FIO_OPT_G_INVALID,
c8eeb9df 3196 },
b8bc8cba
JA
3197 {
3198 .name = "log_avg_msec",
e8b0e958 3199 .lname = "Log averaging (msec)",
b8bc8cba
JA
3200 .type = FIO_OPT_INT,
3201 .off1 = td_var_offset(log_avg_msec),
3202 .help = "Average bw/iops/lat logs over this period of time",
3203 .def = "0",
e8b0e958
JA
3204 .category = FIO_OPT_C_LOG,
3205 .group = FIO_OPT_G_INVALID,
b8bc8cba 3206 },
ae588852
JA
3207 {
3208 .name = "log_offset",
3209 .lname = "Log offset of IO",
3210 .type = FIO_OPT_BOOL,
3211 .off1 = td_var_offset(log_offset),
3212 .help = "Include offset of IO for each log entry",
3213 .def = "0",
3214 .category = FIO_OPT_C_LOG,
3215 .group = FIO_OPT_G_INVALID,
3216 },
aee2ab67
JA
3217#ifdef CONFIG_ZLIB
3218 {
3219 .name = "log_compression",
3220 .lname = "Log compression",
3221 .type = FIO_OPT_INT,
3222 .off1 = td_var_offset(log_gz),
3223 .help = "Log in compressed chunks of this size",
9919b27b 3224 .minval = 1024ULL,
aee2ab67
JA
3225 .maxval = 512 * 1024 * 1024ULL,
3226 .category = FIO_OPT_C_LOG,
3227 .group = FIO_OPT_G_INVALID,
3228 },
b26317c9
JA
3229 {
3230 .name = "log_store_compressed",
3231 .lname = "Log store compressed",
3232 .type = FIO_OPT_BOOL,
3233 .off1 = td_var_offset(log_gz_store),
3234 .help = "Store logs in a compressed format",
3235 .category = FIO_OPT_C_LOG,
3236 .group = FIO_OPT_G_INVALID,
3237 },
aee2ab67 3238#endif
66347cfa
DE
3239 {
3240 .name = "block_error_percentiles",
3241 .lname = "Block error percentiles",
3242 .type = FIO_OPT_BOOL,
3243 .off1 = td_var_offset(block_error_hist),
3244 .help = "Record trim block errors and make a histogram",
3245 .def = "0",
3246 .category = FIO_OPT_C_LOG,
3247 .group = FIO_OPT_G_INVALID,
3248 },
c504ee55
JA
3249 {
3250 .name = "bwavgtime",
3251 .lname = "Bandwidth average time",
3252 .type = FIO_OPT_INT,
3253 .off1 = td_var_offset(bw_avg_time),
3254 .help = "Time window over which to calculate bandwidth"
3255 " (msec)",
3256 .def = "500",
3257 .parent = "write_bw_log",
3258 .hide = 1,
3259 .interval = 100,
3260 .category = FIO_OPT_C_LOG,
3261 .group = FIO_OPT_G_INVALID,
3262 },
3263 {
3264 .name = "iopsavgtime",
3265 .lname = "IOPS average time",
3266 .type = FIO_OPT_INT,
3267 .off1 = td_var_offset(iops_avg_time),
3268 .help = "Time window over which to calculate IOPS (msec)",
3269 .def = "500",
3270 .parent = "write_iops_log",
3271 .hide = 1,
3272 .interval = 100,
3273 .category = FIO_OPT_C_LOG,
3274 .group = FIO_OPT_G_INVALID,
3275 },
214e1eca
JA
3276 {
3277 .name = "group_reporting",
e8b0e958 3278 .lname = "Group reporting",
d2507043 3279 .type = FIO_OPT_STR_SET,
214e1eca
JA
3280 .off1 = td_var_offset(group_reporting),
3281 .help = "Do reporting on a per-group basis",
10860056 3282 .category = FIO_OPT_C_STAT,
e8b0e958 3283 .group = FIO_OPT_G_INVALID,
214e1eca 3284 },
e9459e5a
JA
3285 {
3286 .name = "zero_buffers",
e8b0e958 3287 .lname = "Zero I/O buffers",
e9459e5a
JA
3288 .type = FIO_OPT_STR_SET,
3289 .off1 = td_var_offset(zero_buffers),
3290 .help = "Init IO buffers to all zeroes",
e8b0e958 3291 .category = FIO_OPT_C_IO,
3ceb458f 3292 .group = FIO_OPT_G_IO_BUF,
e9459e5a 3293 },
5973cafb
JA
3294 {
3295 .name = "refill_buffers",
e8b0e958 3296 .lname = "Refill I/O buffers",
5973cafb
JA
3297 .type = FIO_OPT_STR_SET,
3298 .off1 = td_var_offset(refill_buffers),
3299 .help = "Refill IO buffers on every IO submit",
e8b0e958 3300 .category = FIO_OPT_C_IO,
3ceb458f 3301 .group = FIO_OPT_G_IO_BUF,
5973cafb 3302 },
fd68418e
JA
3303 {
3304 .name = "scramble_buffers",
e8b0e958 3305 .lname = "Scramble I/O buffers",
fd68418e
JA
3306 .type = FIO_OPT_BOOL,
3307 .off1 = td_var_offset(scramble_buffers),
3308 .help = "Slightly scramble buffers on every IO submit",
3309 .def = "1",
e8b0e958 3310 .category = FIO_OPT_C_IO,
3ceb458f 3311 .group = FIO_OPT_G_IO_BUF,
fd68418e 3312 },
ce35b1ec
JA
3313 {
3314 .name = "buffer_pattern",
3315 .lname = "Buffer pattern",
3316 .type = FIO_OPT_STR,
3317 .cb = str_buffer_pattern_cb,
a8523a6a 3318 .off1 = td_var_offset(buffer_pattern),
ce35b1ec
JA
3319 .help = "Fill pattern for IO buffers",
3320 .category = FIO_OPT_C_IO,
3321 .group = FIO_OPT_G_IO_BUF,
3322 },
9c42684e
JA
3323 {
3324 .name = "buffer_compress_percentage",
e8b0e958 3325 .lname = "Buffer compression percentage",
9c42684e 3326 .type = FIO_OPT_INT,
bedc9dc2 3327 .cb = str_buffer_compress_cb,
a8523a6a 3328 .off1 = td_var_offset(compress_percentage),
9c42684e 3329 .maxval = 100,
e7f5de90 3330 .minval = 0,
9c42684e 3331 .help = "How compressible the buffer is (approximately)",
20eb06bd 3332 .interval = 5,
e8b0e958 3333 .category = FIO_OPT_C_IO,
3ceb458f 3334 .group = FIO_OPT_G_IO_BUF,
9c42684e 3335 },
f97a43a1
JA
3336 {
3337 .name = "buffer_compress_chunk",
e8b0e958 3338 .lname = "Buffer compression chunk size",
f97a43a1
JA
3339 .type = FIO_OPT_INT,
3340 .off1 = td_var_offset(compress_chunk),
207b18e4 3341 .parent = "buffer_compress_percentage",
d71c154c 3342 .hide = 1,
f97a43a1 3343 .help = "Size of compressible region in buffer",
20eb06bd 3344 .interval = 256,
e8b0e958 3345 .category = FIO_OPT_C_IO,
3ceb458f 3346 .group = FIO_OPT_G_IO_BUF,
f97a43a1 3347 },
5c94b008
JA
3348 {
3349 .name = "dedupe_percentage",
3350 .lname = "Dedupe percentage",
3351 .type = FIO_OPT_INT,
3352 .cb = str_dedupe_cb,
a8523a6a 3353 .off1 = td_var_offset(dedupe_percentage),
5c94b008
JA
3354 .maxval = 100,
3355 .minval = 0,
3356 .help = "Percentage of buffers that are dedupable",
3357 .interval = 1,
3358 .category = FIO_OPT_C_IO,
3359 .group = FIO_OPT_G_IO_BUF,
3360 },
83349190
YH
3361 {
3362 .name = "clat_percentiles",
e8b0e958 3363 .lname = "Completion latency percentiles",
83349190
YH
3364 .type = FIO_OPT_BOOL,
3365 .off1 = td_var_offset(clat_percentiles),
3366 .help = "Enable the reporting of completion latency percentiles",
467b35ed 3367 .def = "1",
e8b0e958
JA
3368 .category = FIO_OPT_C_STAT,
3369 .group = FIO_OPT_G_INVALID,
83349190
YH
3370 },
3371 {
3372 .name = "percentile_list",
66347cfa 3373 .lname = "Percentile list",
83349190
YH
3374 .type = FIO_OPT_FLOAT_LIST,
3375 .off1 = td_var_offset(percentile_list),
435d195a 3376 .off2 = td_var_offset(percentile_precision),
66347cfa
DE
3377 .help = "Specify a custom list of percentiles to report for "
3378 "completion latency and block errors",
fd112d34 3379 .def = "1:5:10:20:30:40:50:60:70:80:90:95:99:99.5:99.9:99.95:99.99",
83349190
YH
3380 .maxlen = FIO_IO_U_LIST_MAX_LEN,
3381 .minfp = 0.0,
3382 .maxfp = 100.0,
e8b0e958
JA
3383 .category = FIO_OPT_C_STAT,
3384 .group = FIO_OPT_G_INVALID,
83349190
YH
3385 },
3386
0a839f30
JA
3387#ifdef FIO_HAVE_DISK_UTIL
3388 {
3389 .name = "disk_util",
e8b0e958 3390 .lname = "Disk utilization",
0a839f30
JA
3391 .type = FIO_OPT_BOOL,
3392 .off1 = td_var_offset(do_disk_util),
f66ab3c8 3393 .help = "Log disk utilization statistics",
0a839f30 3394 .def = "1",
e8b0e958
JA
3395 .category = FIO_OPT_C_STAT,
3396 .group = FIO_OPT_G_INVALID,
0a839f30
JA
3397 },
3398#endif
993bf48b
JA
3399 {
3400 .name = "gtod_reduce",
e8b0e958 3401 .lname = "Reduce gettimeofday() calls",
993bf48b
JA
3402 .type = FIO_OPT_BOOL,
3403 .help = "Greatly reduce number of gettimeofday() calls",
3404 .cb = str_gtod_reduce_cb,
3405 .def = "0",
a4ed77fe 3406 .hide_on_set = 1,
e8b0e958
JA
3407 .category = FIO_OPT_C_STAT,
3408 .group = FIO_OPT_G_INVALID,
993bf48b 3409 },
02af0988
JA
3410 {
3411 .name = "disable_lat",
e8b0e958 3412 .lname = "Disable all latency stats",
02af0988
JA
3413 .type = FIO_OPT_BOOL,
3414 .off1 = td_var_offset(disable_lat),
3415 .help = "Disable latency numbers",
3416 .parent = "gtod_reduce",
d71c154c 3417 .hide = 1,
02af0988 3418 .def = "0",
e8b0e958
JA
3419 .category = FIO_OPT_C_STAT,
3420 .group = FIO_OPT_G_INVALID,
02af0988 3421 },
9520ebb9
JA
3422 {
3423 .name = "disable_clat",
e8b0e958 3424 .lname = "Disable completion latency stats",
9520ebb9
JA
3425 .type = FIO_OPT_BOOL,
3426 .off1 = td_var_offset(disable_clat),
3427 .help = "Disable completion latency numbers",
993bf48b 3428 .parent = "gtod_reduce",
d71c154c 3429 .hide = 1,
9520ebb9 3430 .def = "0",
e8b0e958
JA
3431 .category = FIO_OPT_C_STAT,
3432 .group = FIO_OPT_G_INVALID,
9520ebb9
JA
3433 },
3434 {
3435 .name = "disable_slat",
e8b0e958 3436 .lname = "Disable submission latency stats",
9520ebb9
JA
3437 .type = FIO_OPT_BOOL,
3438 .off1 = td_var_offset(disable_slat),
03e20d68 3439 .help = "Disable submission latency numbers",
993bf48b 3440 .parent = "gtod_reduce",
d71c154c 3441 .hide = 1,
9520ebb9 3442 .def = "0",
e8b0e958
JA
3443 .category = FIO_OPT_C_STAT,
3444 .group = FIO_OPT_G_INVALID,
9520ebb9
JA
3445 },
3446 {
3447 .name = "disable_bw_measurement",
e8b0e958 3448 .lname = "Disable bandwidth stats",
9520ebb9
JA
3449 .type = FIO_OPT_BOOL,
3450 .off1 = td_var_offset(disable_bw),
3451 .help = "Disable bandwidth logging",
993bf48b 3452 .parent = "gtod_reduce",
d71c154c 3453 .hide = 1,
9520ebb9 3454 .def = "0",
e8b0e958
JA
3455 .category = FIO_OPT_C_STAT,
3456 .group = FIO_OPT_G_INVALID,
9520ebb9 3457 },
be4ecfdf
JA
3458 {
3459 .name = "gtod_cpu",
e8b0e958 3460 .lname = "Dedicated gettimeofday() CPU",
be4ecfdf 3461 .type = FIO_OPT_INT,
79c896a1 3462 .off1 = td_var_offset(gtod_cpu),
03e20d68 3463 .help = "Set up dedicated gettimeofday() thread on this CPU",
29d43ff9 3464 .verify = gtod_cpu_verify,
e8b0e958 3465 .category = FIO_OPT_C_GENERAL,
10860056 3466 .group = FIO_OPT_G_CLOCK,
be4ecfdf 3467 },
771e58be
JA
3468 {
3469 .name = "unified_rw_reporting",
3470 .type = FIO_OPT_BOOL,
3471 .off1 = td_var_offset(unified_rw_rep),
3472 .help = "Unify reporting across data direction",
3473 .def = "0",
90b7a96d
JA
3474 .category = FIO_OPT_C_GENERAL,
3475 .group = FIO_OPT_G_INVALID,
771e58be 3476 },
f2bba182
RR
3477 {
3478 .name = "continue_on_error",
e8b0e958 3479 .lname = "Continue on error",
06842027 3480 .type = FIO_OPT_STR,
f2bba182 3481 .off1 = td_var_offset(continue_on_error),
03e20d68 3482 .help = "Continue on non-fatal errors during IO",
06842027 3483 .def = "none",
e8b0e958 3484 .category = FIO_OPT_C_GENERAL,
bc3f552f 3485 .group = FIO_OPT_G_ERR,
06842027
SL
3486 .posval = {
3487 { .ival = "none",
3488 .oval = ERROR_TYPE_NONE,
3489 .help = "Exit when an error is encountered",
3490 },
3491 { .ival = "read",
3492 .oval = ERROR_TYPE_READ,
3493 .help = "Continue on read errors only",
3494 },
3495 { .ival = "write",
3496 .oval = ERROR_TYPE_WRITE,
3497 .help = "Continue on write errors only",
3498 },
3499 { .ival = "io",
3500 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
3501 .help = "Continue on any IO errors",
3502 },
3503 { .ival = "verify",
3504 .oval = ERROR_TYPE_VERIFY,
3505 .help = "Continue on verify errors only",
3506 },
3507 { .ival = "all",
3508 .oval = ERROR_TYPE_ANY,
3509 .help = "Continue on all io and verify errors",
3510 },
3511 { .ival = "0",
3512 .oval = ERROR_TYPE_NONE,
3513 .help = "Alias for 'none'",
3514 },
3515 { .ival = "1",
3516 .oval = ERROR_TYPE_ANY,
3517 .help = "Alias for 'all'",
3518 },
3519 },
f2bba182 3520 },
8b28bd41
DM
3521 {
3522 .name = "ignore_error",
3523 .type = FIO_OPT_STR,
3524 .cb = str_ignore_error_cb,
a8523a6a 3525 .off1 = td_var_offset(ignore_error_nr),
8b28bd41
DM
3526 .help = "Set a specific list of errors to ignore",
3527 .parent = "rw",
a94eb99a 3528 .category = FIO_OPT_C_GENERAL,
bc3f552f 3529 .group = FIO_OPT_G_ERR,
8b28bd41
DM
3530 },
3531 {
3532 .name = "error_dump",
3533 .type = FIO_OPT_BOOL,
3534 .off1 = td_var_offset(error_dump),
3535 .def = "0",
3536 .help = "Dump info on each error",
a94eb99a 3537 .category = FIO_OPT_C_GENERAL,
bc3f552f 3538 .group = FIO_OPT_G_ERR,
8b28bd41 3539 },
9ac8a797
JA
3540 {
3541 .name = "profile",
e8b0e958 3542 .lname = "Profile",
79d16311 3543 .type = FIO_OPT_STR_STORE,
9ac8a797 3544 .off1 = td_var_offset(profile),
9ac8a797 3545 .help = "Select a specific builtin performance test",
13fca827 3546 .category = FIO_OPT_C_PROFILE,
e8b0e958 3547 .group = FIO_OPT_G_INVALID,
9ac8a797 3548 },
a696fa2a
JA
3549 {
3550 .name = "cgroup",
e8b0e958 3551 .lname = "Cgroup",
a696fa2a
JA
3552 .type = FIO_OPT_STR_STORE,
3553 .off1 = td_var_offset(cgroup),
3554 .help = "Add job to cgroup of this name",
e8b0e958 3555 .category = FIO_OPT_C_GENERAL,
a1f6afec
JA
3556 .group = FIO_OPT_G_CGROUP,
3557 },
3558 {
3559 .name = "cgroup_nodelete",
3560 .lname = "Cgroup no-delete",
3561 .type = FIO_OPT_BOOL,
3562 .off1 = td_var_offset(cgroup_nodelete),
3563 .help = "Do not delete cgroups after job completion",
3564 .def = "0",
3565 .parent = "cgroup",
3566 .category = FIO_OPT_C_GENERAL,
3567 .group = FIO_OPT_G_CGROUP,
a696fa2a
JA
3568 },
3569 {
3570 .name = "cgroup_weight",
e8b0e958 3571 .lname = "Cgroup weight",
a696fa2a
JA
3572 .type = FIO_OPT_INT,
3573 .off1 = td_var_offset(cgroup_weight),
3574 .help = "Use given weight for cgroup",
3575 .minval = 100,
3576 .maxval = 1000,
a1f6afec 3577 .parent = "cgroup",
e8b0e958 3578 .category = FIO_OPT_C_GENERAL,
a1f6afec 3579 .group = FIO_OPT_G_CGROUP,
7de87099 3580 },
e0b0d892
JA
3581 {
3582 .name = "uid",
e8b0e958 3583 .lname = "User ID",
e0b0d892
JA
3584 .type = FIO_OPT_INT,
3585 .off1 = td_var_offset(uid),
3586 .help = "Run job with this user ID",
e8b0e958 3587 .category = FIO_OPT_C_GENERAL,
10860056 3588 .group = FIO_OPT_G_CRED,
e0b0d892
JA
3589 },
3590 {
3591 .name = "gid",
e8b0e958 3592 .lname = "Group ID",
e0b0d892
JA
3593 .type = FIO_OPT_INT,
3594 .off1 = td_var_offset(gid),
3595 .help = "Run job with this group ID",
e8b0e958 3596 .category = FIO_OPT_C_GENERAL,
10860056 3597 .group = FIO_OPT_G_CRED,
e0b0d892 3598 },
a1f6afec
JA
3599 {
3600 .name = "kb_base",
3601 .lname = "KB Base",
3602 .type = FIO_OPT_INT,
3603 .off1 = td_var_offset(kb_base),
a1f6afec
JA
3604 .prio = 1,
3605 .def = "1024",
ba9c7219
JA
3606 .posval = {
3607 { .ival = "1024",
3608 .oval = 1024,
3609 .help = "Use 1024 as the K base",
3610 },
3611 { .ival = "1000",
3612 .oval = 1000,
3613 .help = "Use 1000 as the K base",
3614 },
3615 },
a1f6afec
JA
3616 .help = "How many bytes per KB for reporting (1000 or 1024)",
3617 .category = FIO_OPT_C_GENERAL,
3618 .group = FIO_OPT_G_INVALID,
3619 },
cf3a0518
JA
3620 {
3621 .name = "unit_base",
ba9c7219 3622 .lname = "Base unit for reporting (Bits or Bytes)",
cf3a0518
JA
3623 .type = FIO_OPT_INT,
3624 .off1 = td_var_offset(unit_base),
cf3a0518 3625 .prio = 1,
71a08258
JA
3626 .posval = {
3627 { .ival = "0",
3628 .oval = 0,
3629 .help = "Auto-detect",
3630 },
3631 { .ival = "8",
3632 .oval = 8,
3633 .help = "Normal (byte based)",
3634 },
3635 { .ival = "1",
3636 .oval = 1,
3637 .help = "Bit based",
3638 },
3639 },
cf3a0518
JA
3640 .help = "Bit multiple of result summary data (8 for byte, 1 for bit)",
3641 .category = FIO_OPT_C_GENERAL,
3642 .group = FIO_OPT_G_INVALID,
3643 },
3ceb458f
JA
3644 {
3645 .name = "hugepage-size",
3646 .lname = "Hugepage size",
3647 .type = FIO_OPT_INT,
3648 .off1 = td_var_offset(hugepage_size),
3649 .help = "When using hugepages, specify size of each page",
3650 .def = __fio_stringify(FIO_HUGE_PAGE),
3651 .interval = 1024 * 1024,
3652 .category = FIO_OPT_C_GENERAL,
3653 .group = FIO_OPT_G_INVALID,
3654 },
9e684a49
DE
3655 {
3656 .name = "flow_id",
e8b0e958 3657 .lname = "I/O flow ID",
9e684a49
DE
3658 .type = FIO_OPT_INT,
3659 .off1 = td_var_offset(flow_id),
3660 .help = "The flow index ID to use",
3661 .def = "0",
e8b0e958
JA
3662 .category = FIO_OPT_C_IO,
3663 .group = FIO_OPT_G_IO_FLOW,
9e684a49
DE
3664 },
3665 {
3666 .name = "flow",
e8b0e958 3667 .lname = "I/O flow weight",
9e684a49
DE
3668 .type = FIO_OPT_INT,
3669 .off1 = td_var_offset(flow),
3670 .help = "Weight for flow control of this job",
3671 .parent = "flow_id",
d71c154c 3672 .hide = 1,
9e684a49 3673 .def = "0",
e8b0e958
JA
3674 .category = FIO_OPT_C_IO,
3675 .group = FIO_OPT_G_IO_FLOW,
9e684a49
DE
3676 },
3677 {
3678 .name = "flow_watermark",
e8b0e958 3679 .lname = "I/O flow watermark",
9e684a49
DE
3680 .type = FIO_OPT_INT,
3681 .off1 = td_var_offset(flow_watermark),
3682 .help = "High watermark for flow control. This option"
3683 " should be set to the same value for all threads"
3684 " with non-zero flow.",
3685 .parent = "flow_id",
d71c154c 3686 .hide = 1,
9e684a49 3687 .def = "1024",
e8b0e958
JA
3688 .category = FIO_OPT_C_IO,
3689 .group = FIO_OPT_G_IO_FLOW,
9e684a49
DE
3690 },
3691 {
3692 .name = "flow_sleep",
e8b0e958 3693 .lname = "I/O flow sleep",
9e684a49
DE
3694 .type = FIO_OPT_INT,
3695 .off1 = td_var_offset(flow_sleep),
3696 .help = "How many microseconds to sleep after being held"
3697 " back by the flow control mechanism",
3698 .parent = "flow_id",
d71c154c 3699 .hide = 1,
9e684a49 3700 .def = "0",
e8b0e958
JA
3701 .category = FIO_OPT_C_IO,
3702 .group = FIO_OPT_G_IO_FLOW,
9e684a49 3703 },
65fa28ca
DE
3704 {
3705 .name = "skip_bad",
3706 .lname = "Skip operations against bad blocks",
3707 .type = FIO_OPT_BOOL,
3708 .off1 = td_var_offset(skip_bad),
3709 .help = "Skip operations against known bad blocks.",
3710 .hide = 1,
3711 .def = "0",
3712 .category = FIO_OPT_C_IO,
3713 .group = FIO_OPT_G_MTD,
3714 },
214e1eca
JA
3715 {
3716 .name = NULL,
3717 },
3718};
3719
17af15d4 3720static void add_to_lopt(struct option *lopt, struct fio_option *o,
de890a1e 3721 const char *name, int val)
9f81736c 3722{
17af15d4 3723 lopt->name = (char *) name;
de890a1e 3724 lopt->val = val;
9f81736c 3725 if (o->type == FIO_OPT_STR_SET)
ff52be3d 3726 lopt->has_arg = optional_argument;
9f81736c
JA
3727 else
3728 lopt->has_arg = required_argument;
3729}
3730
de890a1e
SL
3731static void options_to_lopts(struct fio_option *opts,
3732 struct option *long_options,
3733 int i, int option_type)
214e1eca 3734{
de890a1e 3735 struct fio_option *o = &opts[0];
214e1eca 3736 while (o->name) {
de890a1e 3737 add_to_lopt(&long_options[i], o, o->name, option_type);
17af15d4
JA
3738 if (o->alias) {
3739 i++;
de890a1e 3740 add_to_lopt(&long_options[i], o, o->alias, option_type);
17af15d4 3741 }
214e1eca
JA
3742
3743 i++;
3744 o++;
3745 assert(i < FIO_NR_OPTIONS);
3746 }
3747}
3748
de890a1e
SL
3749void fio_options_set_ioengine_opts(struct option *long_options,
3750 struct thread_data *td)
3751{
3752 unsigned int i;
3753
3754 i = 0;
3755 while (long_options[i].name) {
3756 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
3757 memset(&long_options[i], 0, sizeof(*long_options));
3758 break;
3759 }
3760 i++;
3761 }
3762
3763 /*
3764 * Just clear out the prior ioengine options.
3765 */
3766 if (!td || !td->eo)
3767 return;
3768
3769 options_to_lopts(td->io_ops->options, long_options, i,
3770 FIO_GETOPT_IOENGINE);
3771}
3772
3773void fio_options_dup_and_init(struct option *long_options)
3774{
3775 unsigned int i;
3776
9af4a244 3777 options_init(fio_options);
de890a1e
SL
3778
3779 i = 0;
3780 while (long_options[i].name)
3781 i++;
3782
9af4a244 3783 options_to_lopts(fio_options, long_options, i, FIO_GETOPT_JOB);
de890a1e
SL
3784}
3785
74929ac2
JA
3786struct fio_keyword {
3787 const char *word;
3788 const char *desc;
3789 char *replace;
3790};
3791
3792static struct fio_keyword fio_keywords[] = {
3793 {
3794 .word = "$pagesize",
3795 .desc = "Page size in the system",
3796 },
3797 {
3798 .word = "$mb_memory",
3799 .desc = "Megabytes of memory online",
3800 },
3801 {
3802 .word = "$ncpus",
3803 .desc = "Number of CPUs online in the system",
3804 },
3805 {
3806 .word = NULL,
3807 },
3808};
3809
af1dc266
JA
3810void fio_keywords_exit(void)
3811{
3812 struct fio_keyword *kw;
3813
3814 kw = &fio_keywords[0];
3815 while (kw->word) {
3816 free(kw->replace);
3817 kw->replace = NULL;
3818 kw++;
3819 }
3820}
3821
74929ac2
JA
3822void fio_keywords_init(void)
3823{
3b2e1464 3824 unsigned long long mb_memory;
74929ac2
JA
3825 char buf[128];
3826 long l;
3827
a4cfc477 3828 sprintf(buf, "%lu", (unsigned long) page_size);
74929ac2
JA
3829 fio_keywords[0].replace = strdup(buf);
3830
8eb016d3 3831 mb_memory = os_phys_mem() / (1024 * 1024);
3b2e1464 3832 sprintf(buf, "%llu", mb_memory);
74929ac2
JA
3833 fio_keywords[1].replace = strdup(buf);
3834
c00a2289 3835 l = cpus_online();
74929ac2
JA
3836 sprintf(buf, "%lu", l);
3837 fio_keywords[2].replace = strdup(buf);
3838}
3839
892a6ffc
JA
3840#define BC_APP "bc"
3841
3842static char *bc_calc(char *str)
3843{
d0c814ec 3844 char buf[128], *tmp;
892a6ffc
JA
3845 FILE *f;
3846 int ret;
3847
3848 /*
3849 * No math, just return string
3850 */
d0c814ec
SL
3851 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
3852 !strchr(str, '/')) || strchr(str, '\''))
892a6ffc
JA
3853 return str;
3854
3855 /*
3856 * Split option from value, we only need to calculate the value
3857 */
3858 tmp = strchr(str, '=');
3859 if (!tmp)
3860 return str;
3861
3862 tmp++;
892a6ffc 3863
d0c814ec
SL
3864 /*
3865 * Prevent buffer overflows; such a case isn't reasonable anyway
3866 */
3867 if (strlen(str) >= 128 || strlen(tmp) > 100)
3868 return str;
892a6ffc
JA
3869
3870 sprintf(buf, "which %s > /dev/null", BC_APP);
3871 if (system(buf)) {
3872 log_err("fio: bc is needed for performing math\n");
892a6ffc
JA
3873 return NULL;
3874 }
3875
d0c814ec 3876 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
892a6ffc 3877 f = popen(buf, "r");
3c3ed070 3878 if (!f)
892a6ffc 3879 return NULL;
892a6ffc 3880
d0c814ec 3881 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
1d824f37
JA
3882 if (ret <= 0) {
3883 pclose(f);
892a6ffc 3884 return NULL;
1d824f37 3885 }
892a6ffc 3886
892a6ffc 3887 pclose(f);
d0c814ec
SL
3888 buf[(tmp - str) + ret - 1] = '\0';
3889 memcpy(buf, str, tmp - str);
892a6ffc 3890 free(str);
d0c814ec
SL
3891 return strdup(buf);
3892}
3893
3894/*
3895 * Return a copy of the input string with substrings of the form ${VARNAME}
3896 * substituted with the value of the environment variable VARNAME. The
3897 * substitution always occurs, even if VARNAME is empty or the corresponding
3898 * environment variable undefined.
3899 */
3900static char *option_dup_subs(const char *opt)
3901{
3902 char out[OPT_LEN_MAX+1];
3903 char in[OPT_LEN_MAX+1];
3904 char *outptr = out;
3905 char *inptr = in;
3906 char *ch1, *ch2, *env;
3907 ssize_t nchr = OPT_LEN_MAX;
3908 size_t envlen;
3909
3910 if (strlen(opt) + 1 > OPT_LEN_MAX) {
3911 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
3912 return NULL;
3913 }
3914
3915 in[OPT_LEN_MAX] = '\0';
3916 strncpy(in, opt, OPT_LEN_MAX);
3917
3918 while (*inptr && nchr > 0) {
3919 if (inptr[0] == '$' && inptr[1] == '{') {
3920 ch2 = strchr(inptr, '}');
3921 if (ch2 && inptr+1 < ch2) {
3922 ch1 = inptr+2;
3923 inptr = ch2+1;
3924 *ch2 = '\0';
3925
3926 env = getenv(ch1);
3927 if (env) {
3928 envlen = strlen(env);
3929 if (envlen <= nchr) {
3930 memcpy(outptr, env, envlen);
3931 outptr += envlen;
3932 nchr -= envlen;
3933 }
3934 }
3935
3936 continue;
3937 }
3938 }
3939
3940 *outptr++ = *inptr++;
3941 --nchr;
3942 }
3943
3944 *outptr = '\0';
3945 return strdup(out);
892a6ffc
JA
3946}
3947
74929ac2
JA
3948/*
3949 * Look for reserved variable names and replace them with real values
3950 */
3951static char *fio_keyword_replace(char *opt)
3952{
3953 char *s;
3954 int i;
d0c814ec 3955 int docalc = 0;
74929ac2
JA
3956
3957 for (i = 0; fio_keywords[i].word != NULL; i++) {
3958 struct fio_keyword *kw = &fio_keywords[i];
3959
3960 while ((s = strstr(opt, kw->word)) != NULL) {
3961 char *new = malloc(strlen(opt) + 1);
3962 char *o_org = opt;
3963 int olen = s - opt;
3964 int len;
3965
3966 /*
3967 * Copy part of the string before the keyword and
3968 * sprintf() the replacement after it.
3969 */
3970 memcpy(new, opt, olen);
3971 len = sprintf(new + olen, "%s", kw->replace);
3972
3973 /*
3974 * If there's more in the original string, copy that
3975 * in too
3976 */
3977 opt += strlen(kw->word) + olen;
3978 if (strlen(opt))
3979 memcpy(new + olen + len, opt, opt - o_org - 1);
3980
3981 /*
3982 * replace opt and free the old opt
3983 */
3984 opt = new;
d0c814ec 3985 free(o_org);
7a958bd5 3986
d0c814ec 3987 docalc = 1;
74929ac2
JA
3988 }
3989 }
3990
d0c814ec
SL
3991 /*
3992 * Check for potential math and invoke bc, if possible
3993 */
3994 if (docalc)
3995 opt = bc_calc(opt);
3996
7a958bd5 3997 return opt;
74929ac2
JA
3998}
3999
d0c814ec
SL
4000static char **dup_and_sub_options(char **opts, int num_opts)
4001{
4002 int i;
4003 char **opts_copy = malloc(num_opts * sizeof(*opts));
4004 for (i = 0; i < num_opts; i++) {
4005 opts_copy[i] = option_dup_subs(opts[i]);
4006 if (!opts_copy[i])
4007 continue;
4008 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
4009 }
4010 return opts_copy;
4011}
4012
e15b023b 4013static void show_closest_option(const char *opt)
a2d027b9
JA
4014{
4015 int best_option, best_distance;
4016 int i, distance;
e15b023b
JA
4017 char *name;
4018
4019 if (!strlen(opt))
4020 return;
4021
4022 name = strdup(opt);
4023 i = 0;
4024 while (name[i] != '\0' && name[i] != '=')
4025 i++;
4026 name[i] = '\0';
a2d027b9
JA
4027
4028 best_option = -1;
4029 best_distance = INT_MAX;
4030 i = 0;
4031 while (fio_options[i].name) {
4032 distance = string_distance(name, fio_options[i].name);
4033 if (distance < best_distance) {
4034 best_distance = distance;
4035 best_option = i;
4036 }
4037 i++;
4038 }
4039
3701636d 4040 if (best_option != -1 && string_distance_ok(name, best_distance))
a2d027b9 4041 log_err("Did you mean %s?\n", fio_options[best_option].name);
e15b023b
JA
4042
4043 free(name);
a2d027b9
JA
4044}
4045
292cc475
JA
4046int fio_options_parse(struct thread_data *td, char **opts, int num_opts,
4047 int dump_cmdline)
214e1eca 4048{
de890a1e 4049 int i, ret, unknown;
d0c814ec 4050 char **opts_copy;
3b8b7135 4051
9af4a244 4052 sort_options(opts, fio_options, num_opts);
d0c814ec 4053 opts_copy = dup_and_sub_options(opts, num_opts);
3b8b7135 4054
de890a1e
SL
4055 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
4056 struct fio_option *o;
9af4a244 4057 int newret = parse_option(opts_copy[i], opts[i], fio_options,
292cc475 4058 &o, td, dump_cmdline);
d0c814ec 4059
a8523a6a
JA
4060 if (!newret && o)
4061 fio_option_mark_set(&td->o, o);
4062
de890a1e
SL
4063 if (opts_copy[i]) {
4064 if (newret && !o) {
4065 unknown++;
4066 continue;
4067 }
d0c814ec 4068 free(opts_copy[i]);
de890a1e
SL
4069 opts_copy[i] = NULL;
4070 }
4071
4072 ret |= newret;
4073 }
4074
4075 if (unknown) {
4076 ret |= ioengine_load(td);
4077 if (td->eo) {
4078 sort_options(opts_copy, td->io_ops->options, num_opts);
4079 opts = opts_copy;
4080 }
4081 for (i = 0; i < num_opts; i++) {
4082 struct fio_option *o = NULL;
4083 int newret = 1;
a2d027b9 4084
de890a1e
SL
4085 if (!opts_copy[i])
4086 continue;
4087
4088 if (td->eo)
4089 newret = parse_option(opts_copy[i], opts[i],
4090 td->io_ops->options, &o,
292cc475 4091 td->eo, dump_cmdline);
de890a1e
SL
4092
4093 ret |= newret;
a2d027b9 4094 if (!o) {
de890a1e 4095 log_err("Bad option <%s>\n", opts[i]);
a2d027b9
JA
4096 show_closest_option(opts[i]);
4097 }
de890a1e
SL
4098 free(opts_copy[i]);
4099 opts_copy[i] = NULL;
4100 }
74929ac2 4101 }
3b8b7135 4102
d0c814ec 4103 free(opts_copy);
3b8b7135 4104 return ret;
214e1eca
JA
4105}
4106
4107int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
4108{
a8523a6a
JA
4109 int ret;
4110
4111 ret = parse_cmd_option(opt, val, fio_options, td);
4112 if (!ret) {
4113 struct fio_option *o;
4114
4115 o = find_option(fio_options, opt);
4116 if (o)
4117 fio_option_mark_set(&td->o, o);
4118 }
4119
4120 return ret;
214e1eca
JA
4121}
4122
de890a1e
SL
4123int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
4124 char *val)
4125{
8a96c80e 4126 return parse_cmd_option(opt, val, td->io_ops->options, td->eo);
de890a1e
SL
4127}
4128
214e1eca
JA
4129void fio_fill_default_options(struct thread_data *td)
4130{
cb1402d6 4131 td->o.magic = OPT_MAGIC;
9af4a244 4132 fill_default_options(td, fio_options);
214e1eca
JA
4133}
4134
4135int fio_show_option_help(const char *opt)
4136{
9af4a244 4137 return show_cmd_help(fio_options, opt);
214e1eca 4138}
d23bb327 4139
de890a1e 4140void options_mem_dupe(void *data, struct fio_option *options)
d23bb327 4141{
de890a1e 4142 struct fio_option *o;
d23bb327 4143 char **ptr;
d23bb327 4144
de890a1e
SL
4145 for (o = &options[0]; o->name; o++) {
4146 if (o->type != FIO_OPT_STR_STORE)
d23bb327
JA
4147 continue;
4148
f0fdbcaf 4149 ptr = td_var(data, o, o->off1);
7e356b2d
JA
4150 if (*ptr)
4151 *ptr = strdup(*ptr);
d23bb327
JA
4152 }
4153}
4154
de890a1e
SL
4155/*
4156 * dupe FIO_OPT_STR_STORE options
4157 */
4158void fio_options_mem_dupe(struct thread_data *td)
4159{
9af4a244 4160 options_mem_dupe(&td->o, fio_options);
1647f592
JA
4161
4162 if (td->eo && td->io_ops) {
de890a1e 4163 void *oldeo = td->eo;
1647f592 4164
de890a1e
SL
4165 td->eo = malloc(td->io_ops->option_struct_size);
4166 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
4167 options_mem_dupe(td->eo, td->io_ops->options);
4168 }
4169}
4170
d6978a32
JA
4171unsigned int fio_get_kb_base(void *data)
4172{
83ea422a 4173 struct thread_options *o = data;
d6978a32
JA
4174 unsigned int kb_base = 0;
4175
cb1402d6
JA
4176 /*
4177 * This is a hack... For private options, *data is not holding
4178 * a pointer to the thread_options, but to private data. This means
4179 * we can't safely dereference it, but magic is first so mem wise
4180 * it is valid. But this also means that if the job first sets
4181 * kb_base and expects that to be honored by private options,
4182 * it will be disappointed. We will return the global default
4183 * for this.
4184 */
4185 if (o && o->magic == OPT_MAGIC)
83ea422a 4186 kb_base = o->kb_base;
d6978a32
JA
4187 if (!kb_base)
4188 kb_base = 1024;
4189
4190 return kb_base;
4191}
9f988e2e 4192
07b3232d 4193int add_option(struct fio_option *o)
9f988e2e 4194{
07b3232d
JA
4195 struct fio_option *__o;
4196 int opt_index = 0;
4197
9af4a244 4198 __o = fio_options;
07b3232d
JA
4199 while (__o->name) {
4200 opt_index++;
4201 __o++;
4202 }
4203
7b504edd
JA
4204 if (opt_index + 1 == FIO_MAX_OPTS) {
4205 log_err("fio: FIO_MAX_OPTS is too small\n");
4206 return 1;
4207 }
4208
9af4a244 4209 memcpy(&fio_options[opt_index], o, sizeof(*o));
7b504edd 4210 fio_options[opt_index + 1].name = NULL;
07b3232d 4211 return 0;
9f988e2e 4212}
e2de69da 4213
07b3232d 4214void invalidate_profile_options(const char *prof_name)
e2de69da 4215{
07b3232d 4216 struct fio_option *o;
e2de69da 4217
9af4a244 4218 o = fio_options;
07b3232d
JA
4219 while (o->name) {
4220 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
4221 o->type = FIO_OPT_INVALID;
4222 o->prof_name = NULL;
4223 }
4224 o++;
e2de69da
JA
4225 }
4226}
f5b6bb85
JA
4227
4228void add_opt_posval(const char *optname, const char *ival, const char *help)
4229{
4230 struct fio_option *o;
4231 unsigned int i;
4232
9af4a244 4233 o = find_option(fio_options, optname);
f5b6bb85
JA
4234 if (!o)
4235 return;
4236
4237 for (i = 0; i < PARSE_MAX_VP; i++) {
4238 if (o->posval[i].ival)
4239 continue;
4240
4241 o->posval[i].ival = ival;
4242 o->posval[i].help = help;
4243 break;
4244 }
4245}
4246
4247void del_opt_posval(const char *optname, const char *ival)
4248{
4249 struct fio_option *o;
4250 unsigned int i;
4251
9af4a244 4252 o = find_option(fio_options, optname);
f5b6bb85
JA
4253 if (!o)
4254 return;
4255
4256 for (i = 0; i < PARSE_MAX_VP; i++) {
4257 if (!o->posval[i].ival)
4258 continue;
4259 if (strcmp(o->posval[i].ival, ival))
4260 continue;
4261
4262 o->posval[i].ival = NULL;
4263 o->posval[i].help = NULL;
4264 }
4265}
7e356b2d
JA
4266
4267void fio_options_free(struct thread_data *td)
4268{
9af4a244 4269 options_free(fio_options, td);
de890a1e
SL
4270 if (td->eo && td->io_ops && td->io_ops->options) {
4271 options_free(td->io_ops->options, td->eo);
4272 free(td->eo);
4273 td->eo = NULL;
4274 }
7e356b2d 4275}
c504ee55
JA
4276
4277struct fio_option *fio_option_find(const char *name)
4278{
4279 return find_option(fio_options, name);
4280}
4281
f0e7f45a
JA
4282static struct fio_option *find_next_opt(struct thread_options *o,
4283 struct fio_option *from,
4284 unsigned int off1)
a8523a6a 4285{
f0e7f45a 4286 struct fio_option *opt;
a8523a6a 4287
f0e7f45a
JA
4288 if (!from)
4289 from = &fio_options[0];
4290 else
4291 from++;
4292
4293 opt = NULL;
4294 do {
4295 if (off1 == from->off1) {
4296 opt = from;
a8523a6a
JA
4297 break;
4298 }
f0e7f45a
JA
4299 from++;
4300 } while (from->name);
a8523a6a 4301
f0e7f45a
JA
4302 return opt;
4303}
4304
4305static int opt_is_set(struct thread_options *o, struct fio_option *opt)
4306{
4307 unsigned int opt_off, index, offset;
a8523a6a
JA
4308
4309 opt_off = opt - &fio_options[0];
4310 index = opt_off / (8 * sizeof(uint64_t));
4311 offset = opt_off & ((8 * sizeof(uint64_t)) - 1);
e9d686d6 4312 return (o->set_options[index] & ((uint64_t)1 << offset)) != 0;
a8523a6a
JA
4313}
4314
f0e7f45a
JA
4315int __fio_option_is_set(struct thread_options *o, unsigned int off1)
4316{
4317 struct fio_option *opt, *next;
4318
4319 next = NULL;
4320 while ((opt = find_next_opt(o, next, off1)) != NULL) {
4321 if (opt_is_set(o, opt))
4322 return 1;
4323
4324 next = opt;
4325 }
4326
4327 return 0;
4328}
4329
a8523a6a
JA
4330void fio_option_mark_set(struct thread_options *o, struct fio_option *opt)
4331{
4332 unsigned int opt_off, index, offset;
4333
4334 opt_off = opt - &fio_options[0];
4335 index = opt_off / (8 * sizeof(uint64_t));
4336 offset = opt_off & ((8 * sizeof(uint64_t)) - 1);
e9d686d6 4337 o->set_options[index] |= (uint64_t)1 << offset;
a8523a6a 4338}