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