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