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