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