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