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