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