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