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