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