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