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