Fix up some style
[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
fc8d6d05 25static struct pattern_fmt_desc fmt_desc[] = {
4205998f
JA
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{
94f218f6 1066 struct thread_data *td = cb_data_to_td(data);
16e56d25
VF
1067 double val;
1068 char *nr;
1069 char *pct;
1070 long long ll;
1071
2c5d94bc
VF
1072 if (td->o.ss_state != FIO_SS_IOPS && td->o.ss_state != FIO_SS_IOPS_SLOPE &&
1073 td->o.ss_state != FIO_SS_BW && td->o.ss_state != FIO_SS_BW_SLOPE) {
16e56d25
VF
1074 /* should be impossible to get here */
1075 log_err("fio: unknown steady state criterion\n");
1076 return 1;
1077 }
1078
1079 nr = get_opt_postfix(str);
1080 if (!nr) {
1081 log_err("fio: steadystate threshold must be specified in addition to criterion\n");
1082 free(nr);
1083 return 1;
1084 }
1085
1086 /* ENHANCEMENT Allow fio to understand size=10.2% and use here */
1087 pct = strstr(nr, "%");
1088 if (pct) {
1089 *pct = '\0';
1090 strip_blank_end(nr);
1091 if (!str_to_float(nr, &val, 0)) {
1092 log_err("fio: could not parse steadystate threshold percentage\n");
1093 free(nr);
1094 return 1;
1095 }
1096
1097 dprint(FD_PARSE, "set steady state threshold to %f%%\n", val);
1098 free(nr);
1099 if (parse_dryrun())
1100 return 0;
1101
2c5d94bc 1102 td->o.ss_state |= __FIO_SS_PCT;
16e56d25 1103 td->o.ss_limit.u.f = val;
2c5d94bc 1104 } else if (td->o.ss_state & __FIO_SS_IOPS) {
16e56d25
VF
1105 if (!str_to_float(nr, &val, 0)) {
1106 log_err("fio: steadystate IOPS threshold postfix parsing failed\n");
1107 free(nr);
1108 return 1;
1109 }
1110
1111 dprint(FD_PARSE, "set steady state IOPS threshold to %f\n", val);
1112 free(nr);
1113 if (parse_dryrun())
1114 return 0;
1115
16e56d25 1116 td->o.ss_limit.u.f = val;
16e56d25
VF
1117 } else { /* bandwidth criterion */
1118 if (str_to_decimal(nr, &ll, 1, td, 0, 0)) {
1119 log_err("fio: steadystate BW threshold postfix parsing failed\n");
1120 free(nr);
1121 return 1;
1122 }
1123
1124 dprint(FD_PARSE, "set steady state BW threshold to %lld\n", ll);
1125 free(nr);
1126 if (parse_dryrun())
1127 return 0;
1128
16e56d25 1129 td->o.ss_limit.u.f = (double) ll;
16e56d25
VF
1130 }
1131
2c5d94bc 1132 td->ss.state = td->o.ss_state;
16e56d25
VF
1133 return 0;
1134}
1135
8e827d35 1136/*
bcbfeefa 1137 * Return next name in the string. Files are separated with ':'. If the ':'
8e827d35
JA
1138 * is escaped with a '\', then that ':' is part of the filename and does not
1139 * indicate a new file.
1140 */
bcbfeefa 1141static char *get_next_name(char **ptr)
8e827d35
JA
1142{
1143 char *str = *ptr;
1144 char *p, *start;
1145
1146 if (!str || !strlen(str))
1147 return NULL;
1148
1149 start = str;
1150 do {
1151 /*
1152 * No colon, we are done
1153 */
1154 p = strchr(str, ':');
1155 if (!p) {
1156 *ptr = NULL;
1157 break;
1158 }
1159
1160 /*
1161 * We got a colon, but it's the first character. Skip and
1162 * continue
1163 */
1164 if (p == start) {
1165 str = ++start;
1166 continue;
1167 }
1168
1169 if (*(p - 1) != '\\') {
1170 *p = '\0';
1171 *ptr = p + 1;
1172 break;
1173 }
1174
1175 memmove(p - 1, p, strlen(p) + 1);
1176 str = p;
1177 } while (1);
1178
1179 return start;
1180}
1181
bcbfeefa
CE
1182
1183static int get_max_name_idx(char *input)
1184{
1185 unsigned int cur_idx;
1186 char *str, *p;
1187
1188 p = str = strdup(input);
1189 for (cur_idx = 0; ; cur_idx++)
1190 if (get_next_name(&str) == NULL)
1191 break;
1192
1193 free(p);
1194 return cur_idx;
1195}
1196
1197/*
1198 * Returns the directory at the index, indexes > entires will be
1199 * assigned via modulo division of the index
1200 */
922a5be8
JA
1201int set_name_idx(char *target, size_t tlen, char *input, int index,
1202 bool unique_filename)
bcbfeefa
CE
1203{
1204 unsigned int cur_idx;
1205 int len;
1206 char *fname, *str, *p;
1207
1208 p = str = strdup(input);
1209
1210 index %= get_max_name_idx(input);
1211 for (cur_idx = 0; cur_idx <= index; cur_idx++)
1212 fname = get_next_name(&str);
1213
922a5be8 1214 if (client_sockaddr_str[0] && unique_filename) {
e13c3b50
JA
1215 len = snprintf(target, tlen, "%s/%s.", fname,
1216 client_sockaddr_str);
1217 } else
1218 len = snprintf(target, tlen, "%s/", fname);
72a703da 1219
e13c3b50 1220 target[tlen - 1] = '\0';
bcbfeefa
CE
1221 free(p);
1222
1223 return len;
1224}
1225
214e1eca
JA
1226static int str_filename_cb(void *data, const char *input)
1227{
a609f12a 1228 struct thread_data *td = cb_data_to_td(data);
214e1eca
JA
1229 char *fname, *str, *p;
1230
1231 p = str = strdup(input);
1232
1233 strip_blank_front(&str);
1234 strip_blank_end(str);
1235
79591fa9
TK
1236 /*
1237 * Ignore what we may already have from nrfiles option.
1238 */
214e1eca 1239 if (!td->files_index)
2dc1bbeb 1240 td->o.nr_files = 0;
214e1eca 1241
bcbfeefa 1242 while ((fname = get_next_name(&str)) != NULL) {
214e1eca
JA
1243 if (!strlen(fname))
1244 break;
5903e7b7 1245 add_file(td, fname, 0, 1);
214e1eca
JA
1246 }
1247
1248 free(p);
1249 return 0;
1250}
1251
bcbfeefa 1252static int str_directory_cb(void *data, const char fio_unused *unused)
214e1eca 1253{
a609f12a 1254 struct thread_data *td = cb_data_to_td(data);
214e1eca 1255 struct stat sb;
bcbfeefa
CE
1256 char *dirname, *str, *p;
1257 int ret = 0;
214e1eca 1258
f9633d72
JA
1259 if (parse_dryrun())
1260 return 0;
1261
bcbfeefa
CE
1262 p = str = strdup(td->o.directory);
1263 while ((dirname = get_next_name(&str)) != NULL) {
1264 if (lstat(dirname, &sb) < 0) {
1265 ret = errno;
921c766f 1266
bcbfeefa
CE
1267 log_err("fio: %s is not a directory\n", dirname);
1268 td_verror(td, ret, "lstat");
1269 goto out;
1270 }
1271 if (!S_ISDIR(sb.st_mode)) {
1272 log_err("fio: %s is not a directory\n", dirname);
1273 ret = 1;
1274 goto out;
1275 }
214e1eca
JA
1276 }
1277
bcbfeefa
CE
1278out:
1279 free(p);
1280 return ret;
214e1eca
JA
1281}
1282
1283static int str_opendir_cb(void *data, const char fio_unused *str)
1284{
a609f12a 1285 struct thread_data *td = cb_data_to_td(data);
214e1eca 1286
52c0cea3
JA
1287 if (parse_dryrun())
1288 return 0;
1289
214e1eca 1290 if (!td->files_index)
2dc1bbeb 1291 td->o.nr_files = 0;
214e1eca 1292
2dc1bbeb 1293 return add_dir_files(td, td->o.opendir);
214e1eca
JA
1294}
1295
ce35b1ec
JA
1296static int str_buffer_pattern_cb(void *data, const char *input)
1297{
a609f12a 1298 struct thread_data *td = cb_data_to_td(data);
ce35b1ec
JA
1299 int ret;
1300
61b9861d
RP
1301 /* FIXME: for now buffer pattern does not support formats */
1302 ret = parse_and_fill_pattern(input, strlen(input), td->o.buffer_pattern,
1303 MAX_PATTERN_SIZE, NULL, 0, NULL, NULL);
1304 if (ret < 0)
1305 return 1;
ce35b1ec 1306
61b9861d
RP
1307 assert(ret != 0);
1308 td->o.buffer_pattern_bytes = ret;
c55fae03
JA
1309
1310 /*
1311 * If this job is doing any reading or has compression set,
1312 * ensure that we refill buffers for writes or we could be
1313 * invalidating the pattern through reads.
1314 */
1315 if (!td->o.compress_percentage && !td_read(td))
61b9861d 1316 td->o.refill_buffers = 0;
c55fae03
JA
1317 else
1318 td->o.refill_buffers = 1;
1319
61b9861d
RP
1320 td->o.scramble_buffers = 0;
1321 td->o.zero_buffers = 0;
efcd9dcc 1322
61b9861d 1323 return 0;
ce35b1ec
JA
1324}
1325
bedc9dc2
JA
1326static int str_buffer_compress_cb(void *data, unsigned long long *il)
1327{
a609f12a 1328 struct thread_data *td = cb_data_to_td(data);
bedc9dc2
JA
1329
1330 td->flags |= TD_F_COMPRESS;
1331 td->o.compress_percentage = *il;
1332 return 0;
1333}
1334
5c94b008
JA
1335static int str_dedupe_cb(void *data, unsigned long long *il)
1336{
a609f12a 1337 struct thread_data *td = cb_data_to_td(data);
5c94b008
JA
1338
1339 td->flags |= TD_F_COMPRESS;
1340 td->o.dedupe_percentage = *il;
1341 td->o.refill_buffers = 1;
1342 return 0;
1343}
1344
ce35b1ec
JA
1345static int str_verify_pattern_cb(void *data, const char *input)
1346{
a609f12a 1347 struct thread_data *td = cb_data_to_td(data);
ce35b1ec
JA
1348 int ret;
1349
61b9861d
RP
1350 td->o.verify_fmt_sz = ARRAY_SIZE(td->o.verify_fmt);
1351 ret = parse_and_fill_pattern(input, strlen(input), td->o.verify_pattern,
4205998f
JA
1352 MAX_PATTERN_SIZE, fmt_desc, sizeof(fmt_desc),
1353 td->o.verify_fmt, &td->o.verify_fmt_sz);
61b9861d
RP
1354 if (ret < 0)
1355 return 1;
efcd9dcc 1356
61b9861d
RP
1357 assert(ret != 0);
1358 td->o.verify_pattern_bytes = ret;
92bf48d5 1359 /*
b638d82f 1360 * VERIFY_* could already be set
92bf48d5 1361 */
61b9861d 1362 if (!fio_option_is_set(&td->o, verify))
92bf48d5 1363 td->o.verify = VERIFY_PATTERN;
efcd9dcc 1364
61b9861d 1365 return 0;
90059d65 1366}
214e1eca 1367
993bf48b
JA
1368static int str_gtod_reduce_cb(void *data, int *il)
1369{
a609f12a 1370 struct thread_data *td = cb_data_to_td(data);
993bf48b
JA
1371 int val = *il;
1372
02af0988 1373 td->o.disable_lat = !!val;
993bf48b
JA
1374 td->o.disable_clat = !!val;
1375 td->o.disable_slat = !!val;
1376 td->o.disable_bw = !!val;
0dc1bc03 1377 td->o.clat_percentiles = !val;
993bf48b
JA
1378 if (val)
1379 td->tv_cache_mask = 63;
1380
1381 return 0;
1382}
1383
89978a6b
BW
1384static int str_offset_cb(void *data, unsigned long long *__val)
1385{
1386 struct thread_data *td = cb_data_to_td(data);
1387 unsigned long long v = *__val;
1388
1389 if (parse_is_percent(v)) {
1390 td->o.start_offset = 0;
1391 td->o.start_offset_percent = -1ULL - v;
872e0415
JA
1392 dprint(FD_PARSE, "SET start_offset_percent %d\n",
1393 td->o.start_offset_percent);
89978a6b
BW
1394 } else
1395 td->o.start_offset = v;
1396
1397 return 0;
1398}
1399
7bb59102
JA
1400static int str_size_cb(void *data, unsigned long long *__val)
1401{
a609f12a 1402 struct thread_data *td = cb_data_to_td(data);
7bb59102
JA
1403 unsigned long long v = *__val;
1404
1405 if (parse_is_percent(v)) {
1406 td->o.size = 0;
1407 td->o.size_percent = -1ULL - v;
1408 } else
1409 td->o.size = v;
1410
1411 return 0;
1412}
1413
dded427c
OS
1414static int str_write_bw_log_cb(void *data, const char *str)
1415{
1416 struct thread_data *td = cb_data_to_td(data);
1417
1418 if (str)
1419 td->o.bw_log_file = strdup(str);
1420
1421 td->o.write_bw_log = 1;
1422 return 0;
1423}
1424
1425static int str_write_lat_log_cb(void *data, const char *str)
1426{
1427 struct thread_data *td = cb_data_to_td(data);
1428
1429 if (str)
1430 td->o.lat_log_file = strdup(str);
1431
1432 td->o.write_lat_log = 1;
1433 return 0;
1434}
1435
1436static int str_write_iops_log_cb(void *data, const char *str)
1437{
1438 struct thread_data *td = cb_data_to_td(data);
1439
1440 if (str)
1441 td->o.iops_log_file = strdup(str);
1442
1443 td->o.write_iops_log = 1;
1444 return 0;
1445}
1446
1447static int str_write_hist_log_cb(void *data, const char *str)
1448{
1449 struct thread_data *td = cb_data_to_td(data);
1450
1451 if (str)
1452 td->o.hist_log_file = strdup(str);
1453
1454 td->o.write_hist_log = 1;
1455 return 0;
1456}
1457
896cac2a
JA
1458static int rw_verify(struct fio_option *o, void *data)
1459{
a609f12a 1460 struct thread_data *td = cb_data_to_td(data);
896cac2a
JA
1461
1462 if (read_only && td_write(td)) {
1463 log_err("fio: job <%s> has write bit set, but fio is in"
1464 " read-only mode\n", td->o.name);
1465 return 1;
1466 }
1467
1468 return 0;
1469}
1470
276ca4f7 1471static int gtod_cpu_verify(struct fio_option *o, void *data)
29d43ff9 1472{
276ca4f7 1473#ifndef FIO_HAVE_CPU_AFFINITY
a609f12a 1474 struct thread_data *td = cb_data_to_td(data);
29d43ff9 1475
29d43ff9
JA
1476 if (td->o.gtod_cpu) {
1477 log_err("fio: platform must support CPU affinity for"
1478 "gettimeofday() offloading\n");
1479 return 1;
1480 }
1481#endif
1482
1483 return 0;
1484}
1485
214e1eca
JA
1486/*
1487 * Map of job/command line options
1488 */
9af4a244 1489struct fio_option fio_options[FIO_MAX_OPTS] = {
214e1eca
JA
1490 {
1491 .name = "description",
e8b0e958 1492 .lname = "Description of job",
214e1eca 1493 .type = FIO_OPT_STR_STORE,
a609f12a 1494 .off1 = offsetof(struct thread_options, description),
214e1eca 1495 .help = "Text job description",
e8b0e958 1496 .category = FIO_OPT_C_GENERAL,
0626037e 1497 .group = FIO_OPT_G_DESC,
214e1eca
JA
1498 },
1499 {
1500 .name = "name",
e8b0e958 1501 .lname = "Job name",
214e1eca 1502 .type = FIO_OPT_STR_STORE,
a609f12a 1503 .off1 = offsetof(struct thread_options, name),
214e1eca 1504 .help = "Name of this job",
e8b0e958 1505 .category = FIO_OPT_C_GENERAL,
0626037e 1506 .group = FIO_OPT_G_DESC,
214e1eca 1507 },
9cc8cb91
AK
1508 {
1509 .name = "wait_for",
1510 .lname = "Waitee name",
1511 .type = FIO_OPT_STR_STORE,
a609f12a 1512 .off1 = offsetof(struct thread_options, wait_for),
9cc8cb91
AK
1513 .help = "Name of the job this one wants to wait for before starting",
1514 .category = FIO_OPT_C_GENERAL,
1515 .group = FIO_OPT_G_DESC,
1516 },
214e1eca
JA
1517 {
1518 .name = "filename",
e8b0e958 1519 .lname = "Filename(s)",
214e1eca 1520 .type = FIO_OPT_STR_STORE,
a609f12a 1521 .off1 = offsetof(struct thread_options, filename),
214e1eca 1522 .cb = str_filename_cb,
f0d524b0 1523 .prio = -1, /* must come after "directory" */
214e1eca 1524 .help = "File(s) to use for the workload",
e8b0e958 1525 .category = FIO_OPT_C_FILE,
0626037e 1526 .group = FIO_OPT_G_FILENAME,
214e1eca 1527 },
90fef2d1 1528 {
e8b0e958
JA
1529 .name = "directory",
1530 .lname = "Directory",
1531 .type = FIO_OPT_STR_STORE,
a609f12a 1532 .off1 = offsetof(struct thread_options, directory),
e8b0e958
JA
1533 .cb = str_directory_cb,
1534 .help = "Directory to store files in",
1535 .category = FIO_OPT_C_FILE,
0626037e 1536 .group = FIO_OPT_G_FILENAME,
90fef2d1 1537 },
de98bd30
JA
1538 {
1539 .name = "filename_format",
922a5be8 1540 .lname = "Filename Format",
de98bd30 1541 .type = FIO_OPT_STR_STORE,
a609f12a 1542 .off1 = offsetof(struct thread_options, filename_format),
de98bd30
JA
1543 .prio = -1, /* must come after "directory" */
1544 .help = "Override default $jobname.$jobnum.$filenum naming",
1545 .def = "$jobname.$jobnum.$filenum",
93bb626a
JA
1546 .category = FIO_OPT_C_FILE,
1547 .group = FIO_OPT_G_FILENAME,
ad705bcb 1548 },
922a5be8
JA
1549 {
1550 .name = "unique_filename",
1551 .lname = "Unique Filename",
1552 .type = FIO_OPT_BOOL,
a609f12a 1553 .off1 = offsetof(struct thread_options, unique_filename),
922a5be8
JA
1554 .help = "For network clients, prefix file with source IP",
1555 .def = "1",
1556 .category = FIO_OPT_C_FILE,
1557 .group = FIO_OPT_G_FILENAME,
1558 },
29c1349f
JA
1559 {
1560 .name = "lockfile",
e8b0e958 1561 .lname = "Lockfile",
4d4e80f2 1562 .type = FIO_OPT_STR,
a609f12a 1563 .off1 = offsetof(struct thread_options, file_lock_mode),
29c1349f 1564 .help = "Lock file when doing IO to it",
bc6a0a5d 1565 .prio = 1,
29c1349f 1566 .parent = "filename",
d71c154c 1567 .hide = 0,
4d4e80f2 1568 .def = "none",
e8b0e958 1569 .category = FIO_OPT_C_FILE,
0626037e 1570 .group = FIO_OPT_G_FILENAME,
4d4e80f2
JA
1571 .posval = {
1572 { .ival = "none",
1573 .oval = FILE_LOCK_NONE,
1574 .help = "No file locking",
1575 },
1576 { .ival = "exclusive",
1577 .oval = FILE_LOCK_EXCLUSIVE,
1578 .help = "Exclusive file lock",
1579 },
1580 {
1581 .ival = "readwrite",
1582 .oval = FILE_LOCK_READWRITE,
1583 .help = "Read vs write lock",
1584 },
1585 },
29c1349f 1586 },
214e1eca
JA
1587 {
1588 .name = "opendir",
e8b0e958 1589 .lname = "Open directory",
214e1eca 1590 .type = FIO_OPT_STR_STORE,
a609f12a 1591 .off1 = offsetof(struct thread_options, opendir),
214e1eca
JA
1592 .cb = str_opendir_cb,
1593 .help = "Recursively add files from this directory and down",
e8b0e958 1594 .category = FIO_OPT_C_FILE,
0626037e 1595 .group = FIO_OPT_G_FILENAME,
214e1eca
JA
1596 },
1597 {
1598 .name = "rw",
e8b0e958 1599 .lname = "Read/write",
d3aad8f2 1600 .alias = "readwrite",
214e1eca 1601 .type = FIO_OPT_STR,
211097b2 1602 .cb = str_rw_cb,
a609f12a 1603 .off1 = offsetof(struct thread_options, td_ddir),
214e1eca
JA
1604 .help = "IO direction",
1605 .def = "read",
896cac2a 1606 .verify = rw_verify,
e8b0e958 1607 .category = FIO_OPT_C_IO,
0626037e 1608 .group = FIO_OPT_G_IO_BASIC,
214e1eca
JA
1609 .posval = {
1610 { .ival = "read",
1611 .oval = TD_DDIR_READ,
1612 .help = "Sequential read",
1613 },
1614 { .ival = "write",
1615 .oval = TD_DDIR_WRITE,
1616 .help = "Sequential write",
1617 },
6eaf09d6
SL
1618 { .ival = "trim",
1619 .oval = TD_DDIR_TRIM,
1620 .help = "Sequential trim",
1621 },
214e1eca
JA
1622 { .ival = "randread",
1623 .oval = TD_DDIR_RANDREAD,
1624 .help = "Random read",
1625 },
1626 { .ival = "randwrite",
1627 .oval = TD_DDIR_RANDWRITE,
1628 .help = "Random write",
1629 },
6eaf09d6
SL
1630 { .ival = "randtrim",
1631 .oval = TD_DDIR_RANDTRIM,
1632 .help = "Random trim",
1633 },
214e1eca
JA
1634 { .ival = "rw",
1635 .oval = TD_DDIR_RW,
1636 .help = "Sequential read and write mix",
1637 },
10b023db
JA
1638 { .ival = "readwrite",
1639 .oval = TD_DDIR_RW,
1640 .help = "Sequential read and write mix",
1641 },
214e1eca
JA
1642 { .ival = "randrw",
1643 .oval = TD_DDIR_RANDRW,
1644 .help = "Random read and write mix"
1645 },
82a90686
JA
1646 { .ival = "trimwrite",
1647 .oval = TD_DDIR_TRIMWRITE,
1648 .help = "Trim and write mix, trims preceding writes"
0e4dd95c 1649 },
214e1eca
JA
1650 },
1651 },
38dad62d
JA
1652 {
1653 .name = "rw_sequencer",
e8b0e958 1654 .lname = "RW Sequencer",
38dad62d 1655 .type = FIO_OPT_STR,
a609f12a 1656 .off1 = offsetof(struct thread_options, rw_seq),
38dad62d
JA
1657 .help = "IO offset generator modifier",
1658 .def = "sequential",
e8b0e958 1659 .category = FIO_OPT_C_IO,
0626037e 1660 .group = FIO_OPT_G_IO_BASIC,
38dad62d
JA
1661 .posval = {
1662 { .ival = "sequential",
1663 .oval = RW_SEQ_SEQ,
1664 .help = "Generate sequential offsets",
1665 },
1666 { .ival = "identical",
1667 .oval = RW_SEQ_IDENT,
1668 .help = "Generate identical offsets",
1669 },
1670 },
1671 },
1672
214e1eca
JA
1673 {
1674 .name = "ioengine",
e8b0e958 1675 .lname = "IO Engine",
214e1eca 1676 .type = FIO_OPT_STR_STORE,
a609f12a 1677 .off1 = offsetof(struct thread_options, ioengine),
214e1eca 1678 .help = "IO engine to use",
58483fa4 1679 .def = FIO_PREFERRED_ENGINE,
e8b0e958 1680 .category = FIO_OPT_C_IO,
0626037e 1681 .group = FIO_OPT_G_IO_BASIC,
214e1eca
JA
1682 .posval = {
1683 { .ival = "sync",
1684 .help = "Use read/write",
1685 },
a31041ea 1686 { .ival = "psync",
1687 .help = "Use pread/pwrite",
1688 },
1d2af02a 1689 { .ival = "vsync",
03e20d68 1690 .help = "Use readv/writev",
1d2af02a 1691 },
07fc0acd
JA
1692#ifdef CONFIG_PWRITEV
1693 { .ival = "pvsync",
1694 .help = "Use preadv/pwritev",
1695 },
1696#endif
6562685f 1697#ifdef FIO_HAVE_PWRITEV2
2cafffbe
JA
1698 { .ival = "pvsync2",
1699 .help = "Use preadv2/pwritev2",
1700 },
1701#endif
67bf9823 1702#ifdef CONFIG_LIBAIO
214e1eca
JA
1703 { .ival = "libaio",
1704 .help = "Linux native asynchronous IO",
1705 },
1706#endif
67bf9823 1707#ifdef CONFIG_POSIXAIO
214e1eca
JA
1708 { .ival = "posixaio",
1709 .help = "POSIX asynchronous IO",
1710 },
417f0068 1711#endif
997843cb 1712#ifdef CONFIG_SOLARISAIO
417f0068
JA
1713 { .ival = "solarisaio",
1714 .help = "Solaris native asynchronous IO",
1715 },
214e1eca 1716#endif
4700b234 1717#ifdef CONFIG_WINDOWSAIO
03e20d68 1718 { .ival = "windowsaio",
3be80071 1719 .help = "Windows native asynchronous IO"
de890a1e 1720 },
fc5c0345
DG
1721#endif
1722#ifdef CONFIG_RBD
1723 { .ival = "rbd",
1724 .help = "Rados Block Device asynchronous IO"
1725 },
3be80071 1726#endif
214e1eca 1727 { .ival = "mmap",
03e20d68 1728 .help = "Memory mapped IO"
214e1eca 1729 },
67bf9823 1730#ifdef CONFIG_LINUX_SPLICE
214e1eca
JA
1731 { .ival = "splice",
1732 .help = "splice/vmsplice based IO",
1733 },
9cce02e8
JA
1734 { .ival = "netsplice",
1735 .help = "splice/vmsplice to/from the network",
1736 },
214e1eca
JA
1737#endif
1738#ifdef FIO_HAVE_SGIO
1739 { .ival = "sg",
1740 .help = "SCSI generic v3 IO",
1741 },
1742#endif
1743 { .ival = "null",
1744 .help = "Testing engine (no data transfer)",
1745 },
1746 { .ival = "net",
1747 .help = "Network IO",
1748 },
214e1eca 1749 { .ival = "cpuio",
03e20d68 1750 .help = "CPU cycle burner engine",
214e1eca 1751 },
67bf9823 1752#ifdef CONFIG_GUASI
b8c82a46
JA
1753 { .ival = "guasi",
1754 .help = "GUASI IO engine",
1755 },
79a43187
JA
1756#endif
1757#ifdef FIO_HAVE_BINJECT
1758 { .ival = "binject",
1759 .help = "binject direct inject block engine",
1760 },
21b8aee8 1761#endif
67bf9823 1762#ifdef CONFIG_RDMA
21b8aee8 1763 { .ival = "rdma",
1764 .help = "RDMA IO engine",
1765 },
8200b8c7 1766#endif
67bf9823 1767#ifdef CONFIG_FUSION_AW
8200b8c7
JA
1768 { .ival = "fusion-aw-sync",
1769 .help = "Fusion-io atomic write engine",
1770 },
1ecc95ca 1771#endif
997843cb 1772#ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
1ecc95ca
JA
1773 { .ival = "e4defrag",
1774 .help = "ext4 defrag engine",
1775 },
1776#endif
997843cb 1777#ifdef CONFIG_LINUX_FALLOCATE
1ecc95ca
JA
1778 { .ival = "falloc",
1779 .help = "fallocate() file based engine",
1780 },
b8c82a46 1781#endif
a7c386f4 1782#ifdef CONFIG_GFAPI
1783 { .ival = "gfapi",
cc47f094 1784 .help = "Glusterfs libgfapi(sync) based engine"
1785 },
1786 { .ival = "gfapi_async",
1787 .help = "Glusterfs libgfapi(async) based engine"
a7c386f4 1788 },
1789#endif
1b10477b 1790#ifdef CONFIG_LIBHDFS
b74e419e 1791 { .ival = "libhdfs",
1b10477b
MM
1792 .help = "Hadoop Distributed Filesystem (HDFS) engine"
1793 },
5c4ef02e
JA
1794#endif
1795#ifdef CONFIG_PMEMBLK
1796 { .ival = "pmemblk",
1797 .help = "NVML libpmemblk based IO engine",
1798 },
1799
104ee4de
DJ
1800#endif
1801#ifdef CONFIG_LINUX_DEVDAX
1802 { .ival = "dev-dax",
1803 .help = "DAX Device based IO engine",
1804 },
1b10477b 1805#endif
214e1eca
JA
1806 { .ival = "external",
1807 .help = "Load external engine (append name)",
1808 },
1809 },
1810 },
1811 {
1812 .name = "iodepth",
e8b0e958 1813 .lname = "IO Depth",
214e1eca 1814 .type = FIO_OPT_INT,
a609f12a 1815 .off1 = offsetof(struct thread_options, iodepth),
03e20d68 1816 .help = "Number of IO buffers to keep in flight",
757aff4f 1817 .minval = 1,
20eb06bd 1818 .interval = 1,
214e1eca 1819 .def = "1",
e8b0e958 1820 .category = FIO_OPT_C_IO,
0626037e 1821 .group = FIO_OPT_G_IO_BASIC,
214e1eca
JA
1822 },
1823 {
1824 .name = "iodepth_batch",
e8b0e958 1825 .lname = "IO Depth batch",
4950421a 1826 .alias = "iodepth_batch_submit",
214e1eca 1827 .type = FIO_OPT_INT,
a609f12a 1828 .off1 = offsetof(struct thread_options, iodepth_batch),
d65db441 1829 .help = "Number of IO buffers to submit in one go",
afdf9352 1830 .parent = "iodepth",
d71c154c 1831 .hide = 1,
20eb06bd 1832 .interval = 1,
a2e6f8ac 1833 .def = "1",
e8b0e958 1834 .category = FIO_OPT_C_IO,
0626037e 1835 .group = FIO_OPT_G_IO_BASIC,
4950421a
JA
1836 },
1837 {
82407585
RP
1838 .name = "iodepth_batch_complete_min",
1839 .lname = "Min IO depth batch complete",
1840 .alias = "iodepth_batch_complete",
4950421a 1841 .type = FIO_OPT_INT,
a609f12a 1842 .off1 = offsetof(struct thread_options, iodepth_batch_complete_min),
82407585 1843 .help = "Min number of IO buffers to retrieve in one go",
4950421a 1844 .parent = "iodepth",
d71c154c 1845 .hide = 1,
4950421a 1846 .minval = 0,
20eb06bd 1847 .interval = 1,
4950421a 1848 .def = "1",
e8b0e958 1849 .category = FIO_OPT_C_IO,
0626037e 1850 .group = FIO_OPT_G_IO_BASIC,
214e1eca 1851 },
82407585
RP
1852 {
1853 .name = "iodepth_batch_complete_max",
1854 .lname = "Max IO depth batch complete",
1855 .type = FIO_OPT_INT,
a609f12a 1856 .off1 = offsetof(struct thread_options, iodepth_batch_complete_max),
82407585
RP
1857 .help = "Max number of IO buffers to retrieve in one go",
1858 .parent = "iodepth",
1859 .hide = 1,
1860 .minval = 0,
1861 .interval = 1,
1862 .category = FIO_OPT_C_IO,
1863 .group = FIO_OPT_G_IO_BASIC,
1864 },
214e1eca
JA
1865 {
1866 .name = "iodepth_low",
e8b0e958 1867 .lname = "IO Depth batch low",
214e1eca 1868 .type = FIO_OPT_INT,
a609f12a 1869 .off1 = offsetof(struct thread_options, iodepth_low),
214e1eca 1870 .help = "Low water mark for queuing depth",
afdf9352 1871 .parent = "iodepth",
d71c154c 1872 .hide = 1,
20eb06bd 1873 .interval = 1,
e8b0e958 1874 .category = FIO_OPT_C_IO,
0626037e 1875 .group = FIO_OPT_G_IO_BASIC,
214e1eca 1876 },
a9da8ab2
JA
1877 {
1878 .name = "io_submit_mode",
1879 .lname = "IO submit mode",
1880 .type = FIO_OPT_STR,
a609f12a 1881 .off1 = offsetof(struct thread_options, io_submit_mode),
a9da8ab2
JA
1882 .help = "How IO submissions and completions are done",
1883 .def = "inline",
1884 .category = FIO_OPT_C_IO,
1885 .group = FIO_OPT_G_IO_BASIC,
1886 .posval = {
1887 { .ival = "inline",
1888 .oval = IO_MODE_INLINE,
1889 .help = "Submit and complete IO inline",
1890 },
1891 { .ival = "offload",
1892 .oval = IO_MODE_OFFLOAD,
1893 .help = "Offload submit and complete to threads",
1894 },
1895 },
1896 },
214e1eca
JA
1897 {
1898 .name = "size",
e8b0e958 1899 .lname = "Size",
214e1eca 1900 .type = FIO_OPT_STR_VAL,
7bb59102 1901 .cb = str_size_cb,
a609f12a 1902 .off1 = offsetof(struct thread_options, size),
214e1eca 1903 .help = "Total size of device or files",
20eb06bd 1904 .interval = 1024 * 1024,
e8b0e958
JA
1905 .category = FIO_OPT_C_IO,
1906 .group = FIO_OPT_G_INVALID,
214e1eca 1907 },
77731b29 1908 {
a4d3b4db
JA
1909 .name = "io_size",
1910 .alias = "io_limit",
1911 .lname = "IO Size",
77731b29 1912 .type = FIO_OPT_STR_VAL,
5be9bf09 1913 .off1 = offsetof(struct thread_options, io_size),
1684f7fd 1914 .help = "Total size of I/O to be performed",
77731b29
JA
1915 .interval = 1024 * 1024,
1916 .category = FIO_OPT_C_IO,
1917 .group = FIO_OPT_G_INVALID,
1918 },
aa31f1f1
SL
1919 {
1920 .name = "fill_device",
e8b0e958 1921 .lname = "Fill device",
74586c1e 1922 .alias = "fill_fs",
aa31f1f1 1923 .type = FIO_OPT_BOOL,
a609f12a 1924 .off1 = offsetof(struct thread_options, fill_device),
aa31f1f1
SL
1925 .help = "Write until an ENOSPC error occurs",
1926 .def = "0",
e8b0e958
JA
1927 .category = FIO_OPT_C_FILE,
1928 .group = FIO_OPT_G_INVALID,
aa31f1f1 1929 },
214e1eca
JA
1930 {
1931 .name = "filesize",
e8b0e958 1932 .lname = "File size",
214e1eca 1933 .type = FIO_OPT_STR_VAL,
a609f12a
JA
1934 .off1 = offsetof(struct thread_options, file_size_low),
1935 .off2 = offsetof(struct thread_options, file_size_high),
c3edbdba 1936 .minval = 1,
214e1eca 1937 .help = "Size of individual files",
20eb06bd 1938 .interval = 1024 * 1024,
e8b0e958
JA
1939 .category = FIO_OPT_C_FILE,
1940 .group = FIO_OPT_G_INVALID,
214e1eca 1941 },
bedc9dc2
JA
1942 {
1943 .name = "file_append",
1944 .lname = "File append",
1945 .type = FIO_OPT_BOOL,
a609f12a 1946 .off1 = offsetof(struct thread_options, file_append),
bedc9dc2
JA
1947 .help = "IO will start at the end of the file(s)",
1948 .def = "0",
1949 .category = FIO_OPT_C_FILE,
1950 .group = FIO_OPT_G_INVALID,
1951 },
67a1000f
JA
1952 {
1953 .name = "offset",
e8b0e958 1954 .lname = "IO offset",
67a1000f
JA
1955 .alias = "fileoffset",
1956 .type = FIO_OPT_STR_VAL,
89978a6b 1957 .cb = str_offset_cb,
a609f12a 1958 .off1 = offsetof(struct thread_options, start_offset),
67a1000f
JA
1959 .help = "Start IO from this offset",
1960 .def = "0",
20eb06bd 1961 .interval = 1024 * 1024,
e8b0e958
JA
1962 .category = FIO_OPT_C_IO,
1963 .group = FIO_OPT_G_INVALID,
67a1000f 1964 },
2d7cd868
JA
1965 {
1966 .name = "offset_increment",
e8b0e958 1967 .lname = "IO offset increment",
2d7cd868 1968 .type = FIO_OPT_STR_VAL,
a609f12a 1969 .off1 = offsetof(struct thread_options, offset_increment),
2d7cd868
JA
1970 .help = "What is the increment from one offset to the next",
1971 .parent = "offset",
d71c154c 1972 .hide = 1,
2d7cd868 1973 .def = "0",
20eb06bd 1974 .interval = 1024 * 1024,
e8b0e958
JA
1975 .category = FIO_OPT_C_IO,
1976 .group = FIO_OPT_G_INVALID,
2d7cd868 1977 },
ddf24e42
JA
1978 {
1979 .name = "number_ios",
1980 .lname = "Number of IOs to perform",
1981 .type = FIO_OPT_STR_VAL,
a609f12a 1982 .off1 = offsetof(struct thread_options, number_ios),
be3fec7d 1983 .help = "Force job completion after this number of IOs",
ddf24e42
JA
1984 .def = "0",
1985 .category = FIO_OPT_C_IO,
1986 .group = FIO_OPT_G_INVALID,
1987 },
214e1eca
JA
1988 {
1989 .name = "bs",
e8b0e958 1990 .lname = "Block size",
d3aad8f2 1991 .alias = "blocksize",
e01b22b8 1992 .type = FIO_OPT_INT,
a609f12a
JA
1993 .off1 = offsetof(struct thread_options, bs[DDIR_READ]),
1994 .off2 = offsetof(struct thread_options, bs[DDIR_WRITE]),
1995 .off3 = offsetof(struct thread_options, bs[DDIR_TRIM]),
c3edbdba 1996 .minval = 1,
214e1eca 1997 .help = "Block size unit",
2b9136a3 1998 .def = "4096",
67a1000f 1999 .parent = "rw",
d71c154c 2000 .hide = 1,
20eb06bd 2001 .interval = 512,
e8b0e958
JA
2002 .category = FIO_OPT_C_IO,
2003 .group = FIO_OPT_G_INVALID,
214e1eca 2004 },
2b7a01d0
JA
2005 {
2006 .name = "ba",
e8b0e958 2007 .lname = "Block size align",
2b7a01d0 2008 .alias = "blockalign",
e01b22b8 2009 .type = FIO_OPT_INT,
a609f12a
JA
2010 .off1 = offsetof(struct thread_options, ba[DDIR_READ]),
2011 .off2 = offsetof(struct thread_options, ba[DDIR_WRITE]),
2012 .off3 = offsetof(struct thread_options, ba[DDIR_TRIM]),
2b7a01d0
JA
2013 .minval = 1,
2014 .help = "IO block offset alignment",
2015 .parent = "rw",
d71c154c 2016 .hide = 1,
20eb06bd 2017 .interval = 512,
e8b0e958
JA
2018 .category = FIO_OPT_C_IO,
2019 .group = FIO_OPT_G_INVALID,
2b7a01d0 2020 },
214e1eca
JA
2021 {
2022 .name = "bsrange",
e8b0e958 2023 .lname = "Block size range",
d3aad8f2 2024 .alias = "blocksize_range",
214e1eca 2025 .type = FIO_OPT_RANGE,
a609f12a
JA
2026 .off1 = offsetof(struct thread_options, min_bs[DDIR_READ]),
2027 .off2 = offsetof(struct thread_options, max_bs[DDIR_READ]),
2028 .off3 = offsetof(struct thread_options, min_bs[DDIR_WRITE]),
2029 .off4 = offsetof(struct thread_options, max_bs[DDIR_WRITE]),
2030 .off5 = offsetof(struct thread_options, min_bs[DDIR_TRIM]),
2031 .off6 = offsetof(struct thread_options, max_bs[DDIR_TRIM]),
c3edbdba 2032 .minval = 1,
214e1eca 2033 .help = "Set block size range (in more detail than bs)",
67a1000f 2034 .parent = "rw",
d71c154c 2035 .hide = 1,
20eb06bd 2036 .interval = 4096,
e8b0e958
JA
2037 .category = FIO_OPT_C_IO,
2038 .group = FIO_OPT_G_INVALID,
214e1eca 2039 },
564ca972
JA
2040 {
2041 .name = "bssplit",
e8b0e958 2042 .lname = "Block size split",
564ca972
JA
2043 .type = FIO_OPT_STR,
2044 .cb = str_bssplit_cb,
a609f12a 2045 .off1 = offsetof(struct thread_options, bssplit),
564ca972
JA
2046 .help = "Set a specific mix of block sizes",
2047 .parent = "rw",
d71c154c 2048 .hide = 1,
e8b0e958
JA
2049 .category = FIO_OPT_C_IO,
2050 .group = FIO_OPT_G_INVALID,
564ca972 2051 },
214e1eca
JA
2052 {
2053 .name = "bs_unaligned",
e8b0e958 2054 .lname = "Block size unaligned",
d3aad8f2 2055 .alias = "blocksize_unaligned",
214e1eca 2056 .type = FIO_OPT_STR_SET,
a609f12a 2057 .off1 = offsetof(struct thread_options, bs_unaligned),
214e1eca 2058 .help = "Don't sector align IO buffer sizes",
67a1000f 2059 .parent = "rw",
d71c154c 2060 .hide = 1,
e8b0e958
JA
2061 .category = FIO_OPT_C_IO,
2062 .group = FIO_OPT_G_INVALID,
214e1eca 2063 },
6aca9b3d
JA
2064 {
2065 .name = "bs_is_seq_rand",
2066 .lname = "Block size division is seq/random (not read/write)",
2067 .type = FIO_OPT_BOOL,
a609f12a 2068 .off1 = offsetof(struct thread_options, bs_is_seq_rand),
86d59660 2069 .help = "Consider any blocksize setting to be sequential,random",
6aca9b3d
JA
2070 .def = "0",
2071 .parent = "blocksize",
2072 .category = FIO_OPT_C_IO,
2073 .group = FIO_OPT_G_INVALID,
2074 },
214e1eca
JA
2075 {
2076 .name = "randrepeat",
e8b0e958 2077 .lname = "Random repeatable",
214e1eca 2078 .type = FIO_OPT_BOOL,
a609f12a 2079 .off1 = offsetof(struct thread_options, rand_repeatable),
214e1eca
JA
2080 .help = "Use repeatable random IO pattern",
2081 .def = "1",
67a1000f 2082 .parent = "rw",
d71c154c 2083 .hide = 1,
e8b0e958 2084 .category = FIO_OPT_C_IO,
3ceb458f 2085 .group = FIO_OPT_G_RANDOM,
214e1eca 2086 },
04778baf
JA
2087 {
2088 .name = "randseed",
2089 .lname = "The random generator seed",
363cffa7 2090 .type = FIO_OPT_STR_VAL,
a609f12a 2091 .off1 = offsetof(struct thread_options, rand_seed),
04778baf 2092 .help = "Set the random generator seed value",
40fe5e7b 2093 .def = "0x89",
04778baf
JA
2094 .parent = "rw",
2095 .category = FIO_OPT_C_IO,
2096 .group = FIO_OPT_G_RANDOM,
2097 },
2615cc4b
JA
2098 {
2099 .name = "use_os_rand",
e8b0e958 2100 .lname = "Use OS random",
54a21917 2101 .type = FIO_OPT_DEPRECATED,
a609f12a 2102 .off1 = offsetof(struct thread_options, dep_use_os_rand),
e8b0e958 2103 .category = FIO_OPT_C_IO,
3ceb458f 2104 .group = FIO_OPT_G_RANDOM,
2615cc4b 2105 },
214e1eca
JA
2106 {
2107 .name = "norandommap",
e8b0e958 2108 .lname = "No randommap",
214e1eca 2109 .type = FIO_OPT_STR_SET,
a609f12a 2110 .off1 = offsetof(struct thread_options, norandommap),
214e1eca 2111 .help = "Accept potential duplicate random blocks",
67a1000f 2112 .parent = "rw",
d71c154c 2113 .hide = 1,
b2452a43 2114 .hide_on_set = 1,
e8b0e958 2115 .category = FIO_OPT_C_IO,
3ceb458f 2116 .group = FIO_OPT_G_RANDOM,
214e1eca 2117 },
2b386d25
JA
2118 {
2119 .name = "softrandommap",
e8b0e958 2120 .lname = "Soft randommap",
2b386d25 2121 .type = FIO_OPT_BOOL,
a609f12a 2122 .off1 = offsetof(struct thread_options, softrandommap),
f66ab3c8 2123 .help = "Set norandommap if randommap allocation fails",
2b386d25 2124 .parent = "norandommap",
d71c154c 2125 .hide = 1,
2b386d25 2126 .def = "0",
e8b0e958 2127 .category = FIO_OPT_C_IO,
3ceb458f 2128 .group = FIO_OPT_G_RANDOM,
2b386d25 2129 },
8055e41d
JA
2130 {
2131 .name = "random_generator",
cce2fdfe 2132 .lname = "Random Generator",
8055e41d 2133 .type = FIO_OPT_STR,
a609f12a 2134 .off1 = offsetof(struct thread_options, random_generator),
8055e41d
JA
2135 .help = "Type of random number generator to use",
2136 .def = "tausworthe",
2137 .posval = {
2138 { .ival = "tausworthe",
2139 .oval = FIO_RAND_GEN_TAUSWORTHE,
2140 .help = "Strong Tausworthe generator",
2141 },
2142 { .ival = "lfsr",
2143 .oval = FIO_RAND_GEN_LFSR,
2144 .help = "Variable length LFSR",
2145 },
c3546b53
JA
2146 {
2147 .ival = "tausworthe64",
2148 .oval = FIO_RAND_GEN_TAUSWORTHE64,
2149 .help = "64-bit Tausworthe variant",
2150 },
8055e41d 2151 },
48107598
JA
2152 .category = FIO_OPT_C_IO,
2153 .group = FIO_OPT_G_RANDOM,
8055e41d 2154 },
e25839d4
JA
2155 {
2156 .name = "random_distribution",
cce2fdfe 2157 .lname = "Random Distribution",
e25839d4 2158 .type = FIO_OPT_STR,
a609f12a 2159 .off1 = offsetof(struct thread_options, random_distribution),
e25839d4
JA
2160 .cb = str_random_distribution_cb,
2161 .help = "Random offset distribution generator",
2162 .def = "random",
2163 .posval = {
2164 { .ival = "random",
2165 .oval = FIO_RAND_DIST_RANDOM,
2166 .help = "Completely random",
2167 },
2168 { .ival = "zipf",
2169 .oval = FIO_RAND_DIST_ZIPF,
2170 .help = "Zipf distribution",
2171 },
925fee33
JA
2172 { .ival = "pareto",
2173 .oval = FIO_RAND_DIST_PARETO,
2174 .help = "Pareto distribution",
2175 },
56d9fa4b
JA
2176 { .ival = "normal",
2177 .oval = FIO_RAND_DIST_GAUSS,
ba2b3b07 2178 .help = "Normal (Gaussian) distribution",
56d9fa4b 2179 },
e0a04ac1
JA
2180 { .ival = "zoned",
2181 .oval = FIO_RAND_DIST_ZONED,
2182 .help = "Zoned random distribution",
2183 },
2184
e25839d4 2185 },
48107598
JA
2186 .category = FIO_OPT_C_IO,
2187 .group = FIO_OPT_G_RANDOM,
e25839d4 2188 },
211c9b89
JA
2189 {
2190 .name = "percentage_random",
2191 .lname = "Percentage Random",
2192 .type = FIO_OPT_INT,
a609f12a
JA
2193 .off1 = offsetof(struct thread_options, perc_rand[DDIR_READ]),
2194 .off2 = offsetof(struct thread_options, perc_rand[DDIR_WRITE]),
2195 .off3 = offsetof(struct thread_options, perc_rand[DDIR_TRIM]),
211c9b89
JA
2196 .maxval = 100,
2197 .help = "Percentage of seq/random mix that should be random",
d9472271 2198 .def = "100,100,100",
211c9b89
JA
2199 .interval = 5,
2200 .inverse = "percentage_sequential",
2201 .category = FIO_OPT_C_IO,
2202 .group = FIO_OPT_G_RANDOM,
2203 },
2204 {
2205 .name = "percentage_sequential",
2206 .lname = "Percentage Sequential",
d9472271 2207 .type = FIO_OPT_DEPRECATED,
211c9b89
JA
2208 .category = FIO_OPT_C_IO,
2209 .group = FIO_OPT_G_RANDOM,
2210 },
56e2a5fc
CE
2211 {
2212 .name = "allrandrepeat",
cce2fdfe 2213 .lname = "All Random Repeat",
56e2a5fc 2214 .type = FIO_OPT_BOOL,
a609f12a 2215 .off1 = offsetof(struct thread_options, allrand_repeatable),
56e2a5fc
CE
2216 .help = "Use repeatable random numbers for everything",
2217 .def = "0",
a869d9c6
JA
2218 .category = FIO_OPT_C_IO,
2219 .group = FIO_OPT_G_RANDOM,
56e2a5fc 2220 },
214e1eca
JA
2221 {
2222 .name = "nrfiles",
e8b0e958 2223 .lname = "Number of files",
d7c8be03 2224 .alias = "nr_files",
214e1eca 2225 .type = FIO_OPT_INT,
a609f12a 2226 .off1 = offsetof(struct thread_options, nr_files),
214e1eca
JA
2227 .help = "Split job workload between this number of files",
2228 .def = "1",
20eb06bd 2229 .interval = 1,
e8b0e958
JA
2230 .category = FIO_OPT_C_FILE,
2231 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2232 },
2233 {
2234 .name = "openfiles",
e8b0e958 2235 .lname = "Number of open files",
214e1eca 2236 .type = FIO_OPT_INT,
a609f12a 2237 .off1 = offsetof(struct thread_options, open_files),
214e1eca 2238 .help = "Number of files to keep open at the same time",
e8b0e958
JA
2239 .category = FIO_OPT_C_FILE,
2240 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2241 },
2242 {
2243 .name = "file_service_type",
e8b0e958 2244 .lname = "File service type",
214e1eca
JA
2245 .type = FIO_OPT_STR,
2246 .cb = str_fst_cb,
a609f12a 2247 .off1 = offsetof(struct thread_options, file_service_type),
214e1eca
JA
2248 .help = "How to select which file to service next",
2249 .def = "roundrobin",
e8b0e958
JA
2250 .category = FIO_OPT_C_FILE,
2251 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2252 .posval = {
2253 { .ival = "random",
2254 .oval = FIO_FSERVICE_RANDOM,
8c07860d
JA
2255 .help = "Choose a file at random (uniform)",
2256 },
2257 { .ival = "zipf",
2258 .oval = FIO_FSERVICE_ZIPF,
2259 .help = "Zipf randomized",
2260 },
2261 { .ival = "pareto",
2262 .oval = FIO_FSERVICE_PARETO,
2263 .help = "Pareto randomized",
2264 },
2265 { .ival = "gauss",
2266 .oval = FIO_FSERVICE_GAUSS,
c60ebc45 2267 .help = "Normal (Gaussian) distribution",
214e1eca
JA
2268 },
2269 { .ival = "roundrobin",
2270 .oval = FIO_FSERVICE_RR,
2271 .help = "Round robin select files",
2272 },
a086c257
JA
2273 { .ival = "sequential",
2274 .oval = FIO_FSERVICE_SEQ,
2275 .help = "Finish one file before moving to the next",
2276 },
214e1eca 2277 },
67a1000f 2278 .parent = "nrfiles",
d71c154c 2279 .hide = 1,
67a1000f 2280 },
97ac992c 2281#ifdef CONFIG_POSIX_FALLOCATE
7bc8c2cf
JA
2282 {
2283 .name = "fallocate",
e8b0e958 2284 .lname = "Fallocate",
a596f047 2285 .type = FIO_OPT_STR,
a609f12a 2286 .off1 = offsetof(struct thread_options, fallocate_mode),
a596f047
EG
2287 .help = "Whether pre-allocation is performed when laying out files",
2288 .def = "posix",
e8b0e958
JA
2289 .category = FIO_OPT_C_FILE,
2290 .group = FIO_OPT_G_INVALID,
a596f047
EG
2291 .posval = {
2292 { .ival = "none",
2293 .oval = FIO_FALLOCATE_NONE,
2294 .help = "Do not pre-allocate space",
2295 },
2296 { .ival = "posix",
2297 .oval = FIO_FALLOCATE_POSIX,
2298 .help = "Use posix_fallocate()",
2299 },
97ac992c 2300#ifdef CONFIG_LINUX_FALLOCATE
a596f047
EG
2301 { .ival = "keep",
2302 .oval = FIO_FALLOCATE_KEEP_SIZE,
2303 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
2304 },
7bc8c2cf 2305#endif
a596f047
EG
2306 /* Compatibility with former boolean values */
2307 { .ival = "0",
2308 .oval = FIO_FALLOCATE_NONE,
2309 .help = "Alias for 'none'",
2310 },
2311 { .ival = "1",
2312 .oval = FIO_FALLOCATE_POSIX,
2313 .help = "Alias for 'posix'",
2314 },
2315 },
2316 },
a275c37a
JA
2317#else /* CONFIG_POSIX_FALLOCATE */
2318 {
2319 .name = "fallocate",
2320 .lname = "Fallocate",
2321 .type = FIO_OPT_UNSUPPORTED,
2322 .help = "Your platform does not support fallocate",
2323 },
2324#endif /* CONFIG_POSIX_FALLOCATE */
67a1000f
JA
2325 {
2326 .name = "fadvise_hint",
e8b0e958 2327 .lname = "Fadvise hint",
ecb2083d 2328 .type = FIO_OPT_STR,
a609f12a 2329 .off1 = offsetof(struct thread_options, fadvise_hint),
ecb2083d
JA
2330 .posval = {
2331 { .ival = "0",
2332 .oval = F_ADV_NONE,
2333 .help = "Don't issue fadvise",
2334 },
2335 { .ival = "1",
2336 .oval = F_ADV_TYPE,
2337 .help = "Advise using fio IO pattern",
2338 },
2339 { .ival = "random",
2340 .oval = F_ADV_RANDOM,
2341 .help = "Advise using FADV_RANDOM",
2342 },
2343 { .ival = "sequential",
2344 .oval = F_ADV_SEQUENTIAL,
2345 .help = "Advise using FADV_SEQUENTIAL",
2346 },
2347 },
67a1000f
JA
2348 .help = "Use fadvise() to advise the kernel on IO pattern",
2349 .def = "1",
e8b0e958
JA
2350 .category = FIO_OPT_C_FILE,
2351 .group = FIO_OPT_G_INVALID,
214e1eca 2352 },
37659335
JA
2353#ifdef FIO_HAVE_STREAMID
2354 {
2355 .name = "fadvise_stream",
2356 .lname = "Fadvise stream",
2357 .type = FIO_OPT_INT,
a609f12a 2358 .off1 = offsetof(struct thread_options, fadvise_stream),
37659335
JA
2359 .help = "Use fadvise() to set stream ID",
2360 .category = FIO_OPT_C_FILE,
2361 .group = FIO_OPT_G_INVALID,
2362 },
a275c37a 2363#else
54d0a315 2364 {
a275c37a
JA
2365 .name = "fadvise_stream",
2366 .lname = "Fadvise stream",
2367 .type = FIO_OPT_UNSUPPORTED,
2368 .help = "Your platform does not support fadvise stream ID",
2369 },
37659335 2370#endif
214e1eca
JA
2371 {
2372 .name = "fsync",
e8b0e958 2373 .lname = "Fsync",
214e1eca 2374 .type = FIO_OPT_INT,
a609f12a 2375 .off1 = offsetof(struct thread_options, fsync_blocks),
214e1eca
JA
2376 .help = "Issue fsync for writes every given number of blocks",
2377 .def = "0",
20eb06bd 2378 .interval = 1,
e8b0e958
JA
2379 .category = FIO_OPT_C_FILE,
2380 .group = FIO_OPT_G_INVALID,
214e1eca 2381 },
5f9099ea
JA
2382 {
2383 .name = "fdatasync",
e8b0e958 2384 .lname = "Fdatasync",
5f9099ea 2385 .type = FIO_OPT_INT,
a609f12a 2386 .off1 = offsetof(struct thread_options, fdatasync_blocks),
5f9099ea
JA
2387 .help = "Issue fdatasync for writes every given number of blocks",
2388 .def = "0",
20eb06bd 2389 .interval = 1,
e8b0e958
JA
2390 .category = FIO_OPT_C_FILE,
2391 .group = FIO_OPT_G_INVALID,
5f9099ea 2392 },
1ef2b6be
JA
2393 {
2394 .name = "write_barrier",
e8b0e958 2395 .lname = "Write barrier",
1ef2b6be 2396 .type = FIO_OPT_INT,
a609f12a 2397 .off1 = offsetof(struct thread_options, barrier_blocks),
1ef2b6be
JA
2398 .help = "Make every Nth write a barrier write",
2399 .def = "0",
20eb06bd 2400 .interval = 1,
e8b0e958
JA
2401 .category = FIO_OPT_C_IO,
2402 .group = FIO_OPT_G_INVALID,
1ef2b6be 2403 },
67bf9823 2404#ifdef CONFIG_SYNC_FILE_RANGE
44f29692
JA
2405 {
2406 .name = "sync_file_range",
e8b0e958 2407 .lname = "Sync file range",
44f29692
JA
2408 .posval = {
2409 { .ival = "wait_before",
2410 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
2411 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
ebadc0ce 2412 .orval = 1,
44f29692
JA
2413 },
2414 { .ival = "write",
2415 .oval = SYNC_FILE_RANGE_WRITE,
2416 .help = "SYNC_FILE_RANGE_WRITE",
ebadc0ce 2417 .orval = 1,
44f29692
JA
2418 },
2419 {
2420 .ival = "wait_after",
2421 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
2422 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
ebadc0ce 2423 .orval = 1,
44f29692
JA
2424 },
2425 },
3843deb3 2426 .type = FIO_OPT_STR_MULTI,
44f29692 2427 .cb = str_sfr_cb,
a609f12a 2428 .off1 = offsetof(struct thread_options, sync_file_range),
44f29692 2429 .help = "Use sync_file_range()",
e8b0e958
JA
2430 .category = FIO_OPT_C_FILE,
2431 .group = FIO_OPT_G_INVALID,
44f29692 2432 },
a275c37a 2433#else
54d0a315 2434 {
a275c37a
JA
2435 .name = "sync_file_range",
2436 .lname = "Sync file range",
2437 .type = FIO_OPT_UNSUPPORTED,
2438 .help = "Your platform does not support sync_file_range",
2439 },
44f29692 2440#endif
214e1eca
JA
2441 {
2442 .name = "direct",
e8b0e958 2443 .lname = "Direct I/O",
214e1eca 2444 .type = FIO_OPT_BOOL,
a609f12a 2445 .off1 = offsetof(struct thread_options, odirect),
214e1eca
JA
2446 .help = "Use O_DIRECT IO (negates buffered)",
2447 .def = "0",
a01a1bc5 2448 .inverse = "buffered",
e8b0e958 2449 .category = FIO_OPT_C_IO,
3ceb458f 2450 .group = FIO_OPT_G_IO_TYPE,
214e1eca 2451 },
d01612f3
CM
2452 {
2453 .name = "atomic",
2454 .lname = "Atomic I/O",
2455 .type = FIO_OPT_BOOL,
a609f12a 2456 .off1 = offsetof(struct thread_options, oatomic),
d01612f3
CM
2457 .help = "Use Atomic IO with O_DIRECT (implies O_DIRECT)",
2458 .def = "0",
2459 .category = FIO_OPT_C_IO,
2460 .group = FIO_OPT_G_IO_TYPE,
2461 },
214e1eca
JA
2462 {
2463 .name = "buffered",
e8b0e958 2464 .lname = "Buffered I/O",
214e1eca 2465 .type = FIO_OPT_BOOL,
a609f12a 2466 .off1 = offsetof(struct thread_options, odirect),
214e1eca
JA
2467 .neg = 1,
2468 .help = "Use buffered IO (negates direct)",
2469 .def = "1",
a01a1bc5 2470 .inverse = "direct",
e8b0e958 2471 .category = FIO_OPT_C_IO,
3ceb458f 2472 .group = FIO_OPT_G_IO_TYPE,
214e1eca
JA
2473 },
2474 {
2475 .name = "overwrite",
e8b0e958 2476 .lname = "Overwrite",
214e1eca 2477 .type = FIO_OPT_BOOL,
a609f12a 2478 .off1 = offsetof(struct thread_options, overwrite),
214e1eca
JA
2479 .help = "When writing, set whether to overwrite current data",
2480 .def = "0",
e8b0e958
JA
2481 .category = FIO_OPT_C_FILE,
2482 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2483 },
2484 {
2485 .name = "loops",
e8b0e958 2486 .lname = "Loops",
214e1eca 2487 .type = FIO_OPT_INT,
a609f12a 2488 .off1 = offsetof(struct thread_options, loops),
214e1eca
JA
2489 .help = "Number of times to run the job",
2490 .def = "1",
20eb06bd 2491 .interval = 1,
e8b0e958 2492 .category = FIO_OPT_C_GENERAL,
a1f6afec 2493 .group = FIO_OPT_G_RUNTIME,
214e1eca
JA
2494 },
2495 {
2496 .name = "numjobs",
e8b0e958 2497 .lname = "Number of jobs",
214e1eca 2498 .type = FIO_OPT_INT,
a609f12a 2499 .off1 = offsetof(struct thread_options, numjobs),
214e1eca
JA
2500 .help = "Duplicate this job this many times",
2501 .def = "1",
20eb06bd 2502 .interval = 1,
e8b0e958 2503 .category = FIO_OPT_C_GENERAL,
a1f6afec 2504 .group = FIO_OPT_G_RUNTIME,
214e1eca
JA
2505 },
2506 {
2507 .name = "startdelay",
e8b0e958 2508 .lname = "Start delay",
a5737c93 2509 .type = FIO_OPT_STR_VAL_TIME,
a609f12a
JA
2510 .off1 = offsetof(struct thread_options, start_delay),
2511 .off2 = offsetof(struct thread_options, start_delay_high),
214e1eca
JA
2512 .help = "Only start job when this period has passed",
2513 .def = "0",
0de5b26f 2514 .is_seconds = 1,
88038bc7 2515 .is_time = 1,
e8b0e958 2516 .category = FIO_OPT_C_GENERAL,
a1f6afec 2517 .group = FIO_OPT_G_RUNTIME,
214e1eca
JA
2518 },
2519 {
2520 .name = "runtime",
e8b0e958 2521 .lname = "Runtime",
214e1eca
JA
2522 .alias = "timeout",
2523 .type = FIO_OPT_STR_VAL_TIME,
a609f12a 2524 .off1 = offsetof(struct thread_options, timeout),
214e1eca
JA
2525 .help = "Stop workload when this amount of time has passed",
2526 .def = "0",
0de5b26f 2527 .is_seconds = 1,
88038bc7 2528 .is_time = 1,
e8b0e958 2529 .category = FIO_OPT_C_GENERAL,
a1f6afec 2530 .group = FIO_OPT_G_RUNTIME,
214e1eca 2531 },
cf4464ca
JA
2532 {
2533 .name = "time_based",
e8b0e958 2534 .lname = "Time based",
cf4464ca 2535 .type = FIO_OPT_STR_SET,
a609f12a 2536 .off1 = offsetof(struct thread_options, time_based),
cf4464ca 2537 .help = "Keep running until runtime/timeout is met",
e8b0e958 2538 .category = FIO_OPT_C_GENERAL,
a1f6afec 2539 .group = FIO_OPT_G_RUNTIME,
cf4464ca 2540 },
62167762
JC
2541 {
2542 .name = "verify_only",
2543 .lname = "Verify only",
2544 .type = FIO_OPT_STR_SET,
a609f12a 2545 .off1 = offsetof(struct thread_options, verify_only),
62167762
JC
2546 .help = "Verifies previously written data is still valid",
2547 .category = FIO_OPT_C_GENERAL,
2548 .group = FIO_OPT_G_RUNTIME,
2549 },
721938ae
JA
2550 {
2551 .name = "ramp_time",
e8b0e958 2552 .lname = "Ramp time",
721938ae 2553 .type = FIO_OPT_STR_VAL_TIME,
a609f12a 2554 .off1 = offsetof(struct thread_options, ramp_time),
721938ae 2555 .help = "Ramp up time before measuring performance",
0de5b26f 2556 .is_seconds = 1,
88038bc7 2557 .is_time = 1,
e8b0e958 2558 .category = FIO_OPT_C_GENERAL,
a1f6afec 2559 .group = FIO_OPT_G_RUNTIME,
721938ae 2560 },
c223da83
JA
2561 {
2562 .name = "clocksource",
e8b0e958 2563 .lname = "Clock source",
c223da83
JA
2564 .type = FIO_OPT_STR,
2565 .cb = fio_clock_source_cb,
a609f12a 2566 .off1 = offsetof(struct thread_options, clocksource),
c223da83 2567 .help = "What type of timing source to use",
e8b0e958 2568 .category = FIO_OPT_C_GENERAL,
10860056 2569 .group = FIO_OPT_G_CLOCK,
c223da83 2570 .posval = {
67bf9823 2571#ifdef CONFIG_GETTIMEOFDAY
c223da83
JA
2572 { .ival = "gettimeofday",
2573 .oval = CS_GTOD,
2574 .help = "Use gettimeofday(2) for timing",
2575 },
67bf9823
JA
2576#endif
2577#ifdef CONFIG_CLOCK_GETTIME
c223da83
JA
2578 { .ival = "clock_gettime",
2579 .oval = CS_CGETTIME,
2580 .help = "Use clock_gettime(2) for timing",
2581 },
67bf9823 2582#endif
c223da83
JA
2583#ifdef ARCH_HAVE_CPU_CLOCK
2584 { .ival = "cpu",
2585 .oval = CS_CPUCLOCK,
2586 .help = "Use CPU private clock",
2587 },
2588#endif
2589 },
2590 },
214e1eca
JA
2591 {
2592 .name = "mem",
d3aad8f2 2593 .alias = "iomem",
e8b0e958 2594 .lname = "I/O Memory",
214e1eca
JA
2595 .type = FIO_OPT_STR,
2596 .cb = str_mem_cb,
a609f12a 2597 .off1 = offsetof(struct thread_options, mem_type),
214e1eca
JA
2598 .help = "Backing type for IO buffers",
2599 .def = "malloc",
e8b0e958
JA
2600 .category = FIO_OPT_C_IO,
2601 .group = FIO_OPT_G_INVALID,
214e1eca
JA
2602 .posval = {
2603 { .ival = "malloc",
2604 .oval = MEM_MALLOC,
2605 .help = "Use malloc(3) for IO buffers",
2606 },
c8931876 2607#ifndef CONFIG_NO_SHM
37c8cdfe
JA
2608 { .ival = "shm",
2609 .oval = MEM_SHM,
2610 .help = "Use shared memory segments for IO buffers",
2611 },
214e1eca
JA
2612#ifdef FIO_HAVE_HUGETLB
2613 { .ival = "shmhuge",
2614 .oval = MEM_SHMHUGE,
2615 .help = "Like shm, but use huge pages",
2616 },
c8931876 2617#endif
b370e46a 2618#endif
37c8cdfe
JA
2619 { .ival = "mmap",
2620 .oval = MEM_MMAP,
2621 .help = "Use mmap(2) (file or anon) for IO buffers",
2622 },
217b0f1d
LG
2623 { .ival = "mmapshared",
2624 .oval = MEM_MMAPSHARED,
2625 .help = "Like mmap, but use the shared flag",
2626 },
214e1eca
JA
2627#ifdef FIO_HAVE_HUGETLB
2628 { .ival = "mmaphuge",
2629 .oval = MEM_MMAPHUGE,
2630 .help = "Like mmap, but use huge pages",
2631 },
03553853
YR
2632#endif
2633#ifdef CONFIG_CUDA
2634 { .ival = "cudamalloc",
2635 .oval = MEM_CUDA_MALLOC,
2636 .help = "Allocate GPU device memory for GPUDirect RDMA",
2637 },
214e1eca
JA
2638#endif
2639 },
2640 },
d529ee19
JA
2641 {
2642 .name = "iomem_align",
2643 .alias = "mem_align",
e8b0e958 2644 .lname = "I/O memory alignment",
d529ee19 2645 .type = FIO_OPT_INT,
a609f12a 2646 .off1 = offsetof(struct thread_options, mem_align),
d529ee19
JA
2647 .minval = 0,
2648 .help = "IO memory buffer offset alignment",
2649 .def = "0",
2650 .parent = "iomem",
d71c154c 2651 .hide = 1,
e8b0e958
JA
2652 .category = FIO_OPT_C_IO,
2653 .group = FIO_OPT_G_INVALID,
d529ee19 2654 },
214e1eca
JA
2655 {
2656 .name = "verify",
e8b0e958 2657 .lname = "Verify",
214e1eca 2658 .type = FIO_OPT_STR,
a609f12a 2659 .off1 = offsetof(struct thread_options, verify),
214e1eca
JA
2660 .help = "Verify data written",
2661 .def = "0",
e8b0e958 2662 .category = FIO_OPT_C_IO,
3ceb458f 2663 .group = FIO_OPT_G_VERIFY,
214e1eca
JA
2664 .posval = {
2665 { .ival = "0",
2666 .oval = VERIFY_NONE,
2667 .help = "Don't do IO verification",
2668 },
fcca4b58
JA
2669 { .ival = "md5",
2670 .oval = VERIFY_MD5,
2671 .help = "Use md5 checksums for verification",
2672 },
d77a7af3
JA
2673 { .ival = "crc64",
2674 .oval = VERIFY_CRC64,
2675 .help = "Use crc64 checksums for verification",
2676 },
214e1eca
JA
2677 { .ival = "crc32",
2678 .oval = VERIFY_CRC32,
2679 .help = "Use crc32 checksums for verification",
2680 },
af497e6a 2681 { .ival = "crc32c-intel",
e3aaafc4
JA
2682 .oval = VERIFY_CRC32C,
2683 .help = "Use crc32c checksums for verification (hw assisted, if available)",
af497e6a 2684 },
bac39e0e
JA
2685 { .ival = "crc32c",
2686 .oval = VERIFY_CRC32C,
e3aaafc4 2687 .help = "Use crc32c checksums for verification (hw assisted, if available)",
bac39e0e 2688 },
969f7ed3
JA
2689 { .ival = "crc16",
2690 .oval = VERIFY_CRC16,
2691 .help = "Use crc16 checksums for verification",
2692 },
1e154bdb
JA
2693 { .ival = "crc7",
2694 .oval = VERIFY_CRC7,
2695 .help = "Use crc7 checksums for verification",
2696 },
7c353ceb
JA
2697 { .ival = "sha1",
2698 .oval = VERIFY_SHA1,
2699 .help = "Use sha1 checksums for verification",
2700 },
cd14cc10
JA
2701 { .ival = "sha256",
2702 .oval = VERIFY_SHA256,
2703 .help = "Use sha256 checksums for verification",
2704 },
2705 { .ival = "sha512",
2706 .oval = VERIFY_SHA512,
2707 .help = "Use sha512 checksums for verification",
ae3a5acc
JA
2708 },
2709 { .ival = "sha3-224",
2710 .oval = VERIFY_SHA3_224,
2711 .help = "Use sha3-224 checksums for verification",
2712 },
2713 { .ival = "sha3-256",
2714 .oval = VERIFY_SHA3_256,
2715 .help = "Use sha3-256 checksums for verification",
2716 },
2717 { .ival = "sha3-384",
2718 .oval = VERIFY_SHA3_384,
2719 .help = "Use sha3-384 checksums for verification",
2720 },
2721 { .ival = "sha3-512",
2722 .oval = VERIFY_SHA3_512,
2723 .help = "Use sha3-512 checksums for verification",
cd14cc10 2724 },
844ea602
JA
2725 { .ival = "xxhash",
2726 .oval = VERIFY_XXHASH,
2727 .help = "Use xxhash checksums for verification",
2728 },
b638d82f
RP
2729 /* Meta information was included into verify_header,
2730 * 'meta' verification is implied by default. */
7437ee87 2731 { .ival = "meta",
b638d82f
RP
2732 .oval = VERIFY_HDR_ONLY,
2733 .help = "Use io information for verification. "
2734 "Now is implied by default, thus option is obsolete, "
2735 "don't use it",
7437ee87 2736 },
59245381
JA
2737 { .ival = "pattern",
2738 .oval = VERIFY_PATTERN_NO_HDR,
2739 .help = "Verify strict pattern",
2740 },
36690c9b
JA
2741 {
2742 .ival = "null",
2743 .oval = VERIFY_NULL,
2744 .help = "Pretend to verify",
2745 },
214e1eca
JA
2746 },
2747 },
005c565a
JA
2748 {
2749 .name = "do_verify",
e8b0e958 2750 .lname = "Perform verify step",
68e1f29a 2751 .type = FIO_OPT_BOOL,
a609f12a 2752 .off1 = offsetof(struct thread_options, do_verify),
005c565a
JA
2753 .help = "Run verification stage after write",
2754 .def = "1",
2755 .parent = "verify",
d71c154c 2756 .hide = 1,
e8b0e958
JA
2757 .category = FIO_OPT_C_IO,
2758 .group = FIO_OPT_G_VERIFY,
005c565a 2759 },
160b966d
JA
2760 {
2761 .name = "verifysort",
e8b0e958 2762 .lname = "Verify sort",
160b966d 2763 .type = FIO_OPT_BOOL,
a609f12a 2764 .off1 = offsetof(struct thread_options, verifysort),
160b966d
JA
2765 .help = "Sort written verify blocks for read back",
2766 .def = "1",
c83f2df1 2767 .parent = "verify",
d71c154c 2768 .hide = 1,
e8b0e958
JA
2769 .category = FIO_OPT_C_IO,
2770 .group = FIO_OPT_G_VERIFY,
160b966d 2771 },
1ae83d45
JA
2772 {
2773 .name = "verifysort_nr",
cce2fdfe 2774 .lname = "Verify Sort Nr",
1ae83d45 2775 .type = FIO_OPT_INT,
a609f12a 2776 .off1 = offsetof(struct thread_options, verifysort_nr),
1ae83d45
JA
2777 .help = "Pre-load and sort verify blocks for a read workload",
2778 .minval = 0,
2779 .maxval = 131072,
2780 .def = "1024",
2781 .parent = "verify",
836fcc0f
JA
2782 .category = FIO_OPT_C_IO,
2783 .group = FIO_OPT_G_VERIFY,
1ae83d45 2784 },
3f9f4e26 2785 {
a59e170d 2786 .name = "verify_interval",
e8b0e958 2787 .lname = "Verify interval",
e01b22b8 2788 .type = FIO_OPT_INT,
a609f12a 2789 .off1 = offsetof(struct thread_options, verify_interval),
819a9680 2790 .minval = 2 * sizeof(struct verify_header),
a59e170d 2791 .help = "Store verify buffer header every N bytes",
afdf9352 2792 .parent = "verify",
d71c154c 2793 .hide = 1,
20eb06bd 2794 .interval = 2 * sizeof(struct verify_header),
e8b0e958
JA
2795 .category = FIO_OPT_C_IO,
2796 .group = FIO_OPT_G_VERIFY,
3f9f4e26 2797 },
546a9142 2798 {
a59e170d 2799 .name = "verify_offset",
e8b0e958 2800 .lname = "Verify offset",
e01b22b8 2801 .type = FIO_OPT_INT,
a59e170d 2802 .help = "Offset verify header location by N bytes",
a609f12a 2803 .off1 = offsetof(struct thread_options, verify_offset),
203160d5 2804 .minval = sizeof(struct verify_header),
afdf9352 2805 .parent = "verify",
d71c154c 2806 .hide = 1,
e8b0e958
JA
2807 .category = FIO_OPT_C_IO,
2808 .group = FIO_OPT_G_VERIFY,
546a9142 2809 },
e28218f3
SL
2810 {
2811 .name = "verify_pattern",
e8b0e958 2812 .lname = "Verify pattern",
0e92f873 2813 .type = FIO_OPT_STR,
e28218f3 2814 .cb = str_verify_pattern_cb,
a609f12a 2815 .off1 = offsetof(struct thread_options, verify_pattern),
e28218f3
SL
2816 .help = "Fill pattern for IO buffers",
2817 .parent = "verify",
d71c154c 2818 .hide = 1,
e8b0e958
JA
2819 .category = FIO_OPT_C_IO,
2820 .group = FIO_OPT_G_VERIFY,
e28218f3 2821 },
a12a3b4d
JA
2822 {
2823 .name = "verify_fatal",
e8b0e958 2824 .lname = "Verify fatal",
68e1f29a 2825 .type = FIO_OPT_BOOL,
a609f12a 2826 .off1 = offsetof(struct thread_options, verify_fatal),
a12a3b4d
JA
2827 .def = "0",
2828 .help = "Exit on a single verify failure, don't continue",
2829 .parent = "verify",
d71c154c 2830 .hide = 1,
e8b0e958
JA
2831 .category = FIO_OPT_C_IO,
2832 .group = FIO_OPT_G_VERIFY,
a12a3b4d 2833 },
b463e936
JA
2834 {
2835 .name = "verify_dump",
e8b0e958 2836 .lname = "Verify dump",
b463e936 2837 .type = FIO_OPT_BOOL,
a609f12a 2838 .off1 = offsetof(struct thread_options, verify_dump),
ef71e317 2839 .def = "0",
b463e936
JA
2840 .help = "Dump contents of good and bad blocks on failure",
2841 .parent = "verify",
d71c154c 2842 .hide = 1,
e8b0e958
JA
2843 .category = FIO_OPT_C_IO,
2844 .group = FIO_OPT_G_VERIFY,
b463e936 2845 },
e8462bd8
JA
2846 {
2847 .name = "verify_async",
e8b0e958 2848 .lname = "Verify asynchronously",
e8462bd8 2849 .type = FIO_OPT_INT,
a609f12a 2850 .off1 = offsetof(struct thread_options, verify_async),
e8462bd8
JA
2851 .def = "0",
2852 .help = "Number of async verifier threads to use",
2853 .parent = "verify",
d71c154c 2854 .hide = 1,
e8b0e958
JA
2855 .category = FIO_OPT_C_IO,
2856 .group = FIO_OPT_G_VERIFY,
e8462bd8 2857 },
9e144189
JA
2858 {
2859 .name = "verify_backlog",
e8b0e958 2860 .lname = "Verify backlog",
9e144189 2861 .type = FIO_OPT_STR_VAL,
a609f12a 2862 .off1 = offsetof(struct thread_options, verify_backlog),
9e144189
JA
2863 .help = "Verify after this number of blocks are written",
2864 .parent = "verify",
d71c154c 2865 .hide = 1,
e8b0e958
JA
2866 .category = FIO_OPT_C_IO,
2867 .group = FIO_OPT_G_VERIFY,
9e144189
JA
2868 },
2869 {
2870 .name = "verify_backlog_batch",
e8b0e958 2871 .lname = "Verify backlog batch",
9e144189 2872 .type = FIO_OPT_INT,
a609f12a 2873 .off1 = offsetof(struct thread_options, verify_batch),
9e144189 2874 .help = "Verify this number of IO blocks",
0d29de83 2875 .parent = "verify",
d71c154c 2876 .hide = 1,
e8b0e958
JA
2877 .category = FIO_OPT_C_IO,
2878 .group = FIO_OPT_G_VERIFY,
9e144189 2879 },
e8462bd8
JA
2880#ifdef FIO_HAVE_CPU_AFFINITY
2881 {
2882 .name = "verify_async_cpus",
e8b0e958 2883 .lname = "Async verify CPUs",
e8462bd8
JA
2884 .type = FIO_OPT_STR,
2885 .cb = str_verify_cpus_allowed_cb,
a609f12a 2886 .off1 = offsetof(struct thread_options, verify_cpumask),
e8462bd8
JA
2887 .help = "Set CPUs allowed for async verify threads",
2888 .parent = "verify_async",
d71c154c 2889 .hide = 1,
e8b0e958
JA
2890 .category = FIO_OPT_C_IO,
2891 .group = FIO_OPT_G_VERIFY,
e8462bd8 2892 },
a275c37a
JA
2893#else
2894 {
2895 .name = "verify_async_cpus",
2896 .lname = "Async verify CPUs",
2897 .type = FIO_OPT_UNSUPPORTED,
54d0a315 2898 .help = "Your platform does not support CPU affinities",
a275c37a 2899 },
0d29de83 2900#endif
51aa2da8
JA
2901 {
2902 .name = "experimental_verify",
cce2fdfe 2903 .lname = "Experimental Verify",
a609f12a 2904 .off1 = offsetof(struct thread_options, experimental_verify),
51aa2da8 2905 .type = FIO_OPT_BOOL,
b31eaac9 2906 .help = "Enable experimental verification",
ca09be4b
JA
2907 .parent = "verify",
2908 .category = FIO_OPT_C_IO,
2909 .group = FIO_OPT_G_VERIFY,
2910 },
2911 {
2912 .name = "verify_state_load",
2913 .lname = "Load verify state",
a609f12a 2914 .off1 = offsetof(struct thread_options, verify_state),
ca09be4b
JA
2915 .type = FIO_OPT_BOOL,
2916 .help = "Load verify termination state",
2917 .parent = "verify",
2918 .category = FIO_OPT_C_IO,
2919 .group = FIO_OPT_G_VERIFY,
2920 },
2921 {
2922 .name = "verify_state_save",
2923 .lname = "Save verify state",
a609f12a 2924 .off1 = offsetof(struct thread_options, verify_state_save),
ca09be4b
JA
2925 .type = FIO_OPT_BOOL,
2926 .def = "1",
2927 .help = "Save verify state on termination",
2928 .parent = "verify",
836fcc0f
JA
2929 .category = FIO_OPT_C_IO,
2930 .group = FIO_OPT_G_VERIFY,
51aa2da8 2931 },
0d29de83
JA
2932#ifdef FIO_HAVE_TRIM
2933 {
2934 .name = "trim_percentage",
e8b0e958 2935 .lname = "Trim percentage",
0d29de83 2936 .type = FIO_OPT_INT,
a609f12a 2937 .off1 = offsetof(struct thread_options, trim_percentage),
20eb06bd 2938 .minval = 0,
0d29de83 2939 .maxval = 100,
169c098d 2940 .help = "Number of verify blocks to trim (i.e., discard)",
0d29de83
JA
2941 .parent = "verify",
2942 .def = "0",
20eb06bd 2943 .interval = 1,
d71c154c 2944 .hide = 1,
e8b0e958
JA
2945 .category = FIO_OPT_C_IO,
2946 .group = FIO_OPT_G_TRIM,
0d29de83
JA
2947 },
2948 {
2949 .name = "trim_verify_zero",
e8b0e958 2950 .lname = "Verify trim zero",
20eb06bd 2951 .type = FIO_OPT_BOOL,
169c098d 2952 .help = "Verify that trimmed (i.e., discarded) blocks are returned as zeroes",
a609f12a 2953 .off1 = offsetof(struct thread_options, trim_zero),
0d29de83 2954 .parent = "trim_percentage",
d71c154c 2955 .hide = 1,
0d29de83 2956 .def = "1",
e8b0e958
JA
2957 .category = FIO_OPT_C_IO,
2958 .group = FIO_OPT_G_TRIM,
0d29de83
JA
2959 },
2960 {
2961 .name = "trim_backlog",
e8b0e958 2962 .lname = "Trim backlog",
0d29de83 2963 .type = FIO_OPT_STR_VAL,
a609f12a 2964 .off1 = offsetof(struct thread_options, trim_backlog),
0d29de83
JA
2965 .help = "Trim after this number of blocks are written",
2966 .parent = "trim_percentage",
d71c154c 2967 .hide = 1,
20eb06bd 2968 .interval = 1,
e8b0e958
JA
2969 .category = FIO_OPT_C_IO,
2970 .group = FIO_OPT_G_TRIM,
0d29de83
JA
2971 },
2972 {
2973 .name = "trim_backlog_batch",
e8b0e958 2974 .lname = "Trim backlog batch",
0d29de83 2975 .type = FIO_OPT_INT,
a609f12a 2976 .off1 = offsetof(struct thread_options, trim_batch),
0d29de83
JA
2977 .help = "Trim this number of IO blocks",
2978 .parent = "trim_percentage",
d71c154c 2979 .hide = 1,
20eb06bd 2980 .interval = 1,
e8b0e958
JA
2981 .category = FIO_OPT_C_IO,
2982 .group = FIO_OPT_G_TRIM,
0d29de83 2983 },
a275c37a
JA
2984#else
2985 {
2986 .name = "trim_percentage",
2987 .lname = "Trim percentage",
2988 .type = FIO_OPT_UNSUPPORTED,
2989 .help = "Fio does not support TRIM on your platform",
2990 },
2991 {
2992 .name = "trim_verify_zero",
2993 .lname = "Verify trim zero",
2994 .type = FIO_OPT_UNSUPPORTED,
2995 .help = "Fio does not support TRIM on your platform",
2996 },
2997 {
2998 .name = "trim_backlog",
2999 .lname = "Trim backlog",
3000 .type = FIO_OPT_UNSUPPORTED,
3001 .help = "Fio does not support TRIM on your platform",
3002 },
3003 {
3004 .name = "trim_backlog_batch",
3005 .lname = "Trim backlog batch",
3006 .type = FIO_OPT_UNSUPPORTED,
3007 .help = "Fio does not support TRIM on your platform",
3008 },
e8462bd8 3009#endif
214e1eca
JA
3010 {
3011 .name = "write_iolog",
e8b0e958 3012 .lname = "Write I/O log",
214e1eca 3013 .type = FIO_OPT_STR_STORE,
a609f12a 3014 .off1 = offsetof(struct thread_options, write_iolog_file),
214e1eca 3015 .help = "Store IO pattern to file",
e8b0e958
JA
3016 .category = FIO_OPT_C_IO,
3017 .group = FIO_OPT_G_IOLOG,
214e1eca
JA
3018 },
3019 {
3020 .name = "read_iolog",
e8b0e958 3021 .lname = "Read I/O log",
214e1eca 3022 .type = FIO_OPT_STR_STORE,
a609f12a 3023 .off1 = offsetof(struct thread_options, read_iolog_file),
214e1eca 3024 .help = "Playback IO pattern from file",
e8b0e958
JA
3025 .category = FIO_OPT_C_IO,
3026 .group = FIO_OPT_G_IOLOG,
214e1eca 3027 },
64bbb865
DN
3028 {
3029 .name = "replay_no_stall",
e8b0e958 3030 .lname = "Don't stall on replay",
20eb06bd 3031 .type = FIO_OPT_BOOL,
a609f12a 3032 .off1 = offsetof(struct thread_options, no_stall),
64bbb865 3033 .def = "0",
87e7a972 3034 .parent = "read_iolog",
d71c154c 3035 .hide = 1,
64bbb865 3036 .help = "Playback IO pattern file as fast as possible without stalls",
e8b0e958
JA
3037 .category = FIO_OPT_C_IO,
3038 .group = FIO_OPT_G_IOLOG,
64bbb865 3039 },
d1c46c04
DN
3040 {
3041 .name = "replay_redirect",
e8b0e958 3042 .lname = "Redirect device for replay",
d1c46c04 3043 .type = FIO_OPT_STR_STORE,
a609f12a 3044 .off1 = offsetof(struct thread_options, replay_redirect),
d1c46c04 3045 .parent = "read_iolog",
d71c154c 3046 .hide = 1,
d1c46c04 3047 .help = "Replay all I/O onto this device, regardless of trace device",
e8b0e958
JA
3048 .category = FIO_OPT_C_IO,
3049 .group = FIO_OPT_G_IOLOG,
d1c46c04 3050 },
0c63576e
JA
3051 {
3052 .name = "replay_scale",
3053 .lname = "Replace offset scale factor",
3054 .type = FIO_OPT_INT,
a609f12a 3055 .off1 = offsetof(struct thread_options, replay_scale),
0c63576e
JA
3056 .parent = "read_iolog",
3057 .def = "1",
3058 .help = "Align offsets to this blocksize",
3059 .category = FIO_OPT_C_IO,
3060 .group = FIO_OPT_G_IOLOG,
3061 },
3062 {
3063 .name = "replay_align",
3064 .lname = "Replace alignment",
3065 .type = FIO_OPT_INT,
a609f12a 3066 .off1 = offsetof(struct thread_options, replay_align),
0c63576e
JA
3067 .parent = "read_iolog",
3068 .help = "Scale offset down by this factor",
3069 .category = FIO_OPT_C_IO,
3070 .group = FIO_OPT_G_IOLOG,
3071 .pow2 = 1,
3072 },
214e1eca
JA
3073 {
3074 .name = "exec_prerun",
e8b0e958 3075 .lname = "Pre-execute runnable",
214e1eca 3076 .type = FIO_OPT_STR_STORE,
a609f12a 3077 .off1 = offsetof(struct thread_options, exec_prerun),
214e1eca 3078 .help = "Execute this file prior to running job",
e8b0e958
JA
3079 .category = FIO_OPT_C_GENERAL,
3080 .group = FIO_OPT_G_INVALID,
214e1eca
JA
3081 },
3082 {
3083 .name = "exec_postrun",
e8b0e958 3084 .lname = "Post-execute runnable",
214e1eca 3085 .type = FIO_OPT_STR_STORE,
a609f12a 3086 .off1 = offsetof(struct thread_options, exec_postrun),
214e1eca 3087 .help = "Execute this file after running job",
e8b0e958
JA
3088 .category = FIO_OPT_C_GENERAL,
3089 .group = FIO_OPT_G_INVALID,
214e1eca
JA
3090 },
3091#ifdef FIO_HAVE_IOSCHED_SWITCH
3092 {
3093 .name = "ioscheduler",
e8b0e958 3094 .lname = "I/O scheduler",
214e1eca 3095 .type = FIO_OPT_STR_STORE,
a609f12a 3096 .off1 = offsetof(struct thread_options, ioscheduler),
214e1eca 3097 .help = "Use this IO scheduler on the backing device",
e8b0e958
JA
3098 .category = FIO_OPT_C_FILE,
3099 .group = FIO_OPT_G_INVALID,
214e1eca 3100 },
a275c37a
JA
3101#else
3102 {
3103 .name = "ioscheduler",
3104 .lname = "I/O scheduler",
3105 .type = FIO_OPT_UNSUPPORTED,
3106 .help = "Your platform does not support IO scheduler switching",
3107 },
214e1eca
JA
3108#endif
3109 {
3110 .name = "zonesize",
e8b0e958 3111 .lname = "Zone size",
214e1eca 3112 .type = FIO_OPT_STR_VAL,
a609f12a 3113 .off1 = offsetof(struct thread_options, zone_size),
ed335855
SN
3114 .help = "Amount of data to read per zone",
3115 .def = "0",
20eb06bd 3116 .interval = 1024 * 1024,
e8b0e958
JA
3117 .category = FIO_OPT_C_IO,
3118 .group = FIO_OPT_G_ZONE,
ed335855
SN
3119 },
3120 {
3121 .name = "zonerange",
e8b0e958 3122 .lname = "Zone range",
ed335855 3123 .type = FIO_OPT_STR_VAL,
a609f12a 3124 .off1 = offsetof(struct thread_options, zone_range),
214e1eca
JA
3125 .help = "Give size of an IO zone",
3126 .def = "0",
20eb06bd 3127 .interval = 1024 * 1024,
e8b0e958
JA
3128 .category = FIO_OPT_C_IO,
3129 .group = FIO_OPT_G_ZONE,
214e1eca
JA
3130 },
3131 {
3132 .name = "zoneskip",
e8b0e958 3133 .lname = "Zone skip",
214e1eca 3134 .type = FIO_OPT_STR_VAL,
a609f12a 3135 .off1 = offsetof(struct thread_options, zone_skip),
214e1eca
JA
3136 .help = "Space between IO zones",
3137 .def = "0",
20eb06bd 3138 .interval = 1024 * 1024,
e8b0e958
JA
3139 .category = FIO_OPT_C_IO,
3140 .group = FIO_OPT_G_ZONE,
214e1eca
JA
3141 },
3142 {
3143 .name = "lockmem",
e8b0e958 3144 .lname = "Lock memory",
214e1eca 3145 .type = FIO_OPT_STR_VAL,
a609f12a 3146 .off1 = offsetof(struct thread_options, lockmem),
81c6b6cd 3147 .help = "Lock down this amount of memory (per worker)",
214e1eca 3148 .def = "0",
20eb06bd 3149 .interval = 1024 * 1024,
e8b0e958
JA
3150 .category = FIO_OPT_C_GENERAL,
3151 .group = FIO_OPT_G_INVALID,
214e1eca 3152 },
214e1eca
JA
3153 {
3154 .name = "rwmixread",
e8b0e958 3155 .lname = "Read/write mix read",
214e1eca 3156 .type = FIO_OPT_INT,
cb499fc4 3157 .cb = str_rwmix_read_cb,
a609f12a 3158 .off1 = offsetof(struct thread_options, rwmix[DDIR_READ]),
214e1eca
JA
3159 .maxval = 100,
3160 .help = "Percentage of mixed workload that is reads",
3161 .def = "50",
20eb06bd 3162 .interval = 5,
90265353 3163 .inverse = "rwmixwrite",
e8b0e958
JA
3164 .category = FIO_OPT_C_IO,
3165 .group = FIO_OPT_G_RWMIX,
214e1eca
JA
3166 },
3167 {
3168 .name = "rwmixwrite",
e8b0e958 3169 .lname = "Read/write mix write",
214e1eca 3170 .type = FIO_OPT_INT,
cb499fc4 3171 .cb = str_rwmix_write_cb,
a609f12a 3172 .off1 = offsetof(struct thread_options, rwmix[DDIR_WRITE]),
214e1eca
JA
3173 .maxval = 100,
3174 .help = "Percentage of mixed workload that is writes",
3175 .def = "50",
20eb06bd 3176 .interval = 5,
90265353 3177 .inverse = "rwmixread",
e8b0e958
JA
3178 .category = FIO_OPT_C_IO,
3179 .group = FIO_OPT_G_RWMIX,
214e1eca 3180 },
afdf9352
JA
3181 {
3182 .name = "rwmixcycle",
e8b0e958 3183 .lname = "Read/write mix cycle",
15ca150e 3184 .type = FIO_OPT_DEPRECATED,
e8b0e958
JA
3185 .category = FIO_OPT_C_IO,
3186 .group = FIO_OPT_G_RWMIX,
afdf9352 3187 },
214e1eca
JA
3188 {
3189 .name = "nice",
e8b0e958 3190 .lname = "Nice",
214e1eca 3191 .type = FIO_OPT_INT,
a609f12a 3192 .off1 = offsetof(struct thread_options, nice),
214e1eca
JA
3193 .help = "Set job CPU nice value",
3194 .minval = -19,
3195 .maxval = 20,
3196 .def = "0",
20eb06bd 3197 .interval = 1,
e8b0e958 3198 .category = FIO_OPT_C_GENERAL,
10860056 3199 .group = FIO_OPT_G_CRED,
214e1eca
JA
3200 },
3201#ifdef FIO_HAVE_IOPRIO
3202 {
3203 .name = "prio",
e8b0e958 3204 .lname = "I/O nice priority",
214e1eca 3205 .type = FIO_OPT_INT,
a609f12a 3206 .off1 = offsetof(struct thread_options, ioprio),
214e1eca 3207 .help = "Set job IO priority value",
1767bd34
TK
3208 .minval = IOPRIO_MIN_PRIO,
3209 .maxval = IOPRIO_MAX_PRIO,
20eb06bd 3210 .interval = 1,
e8b0e958 3211 .category = FIO_OPT_C_GENERAL,
10860056 3212 .group = FIO_OPT_G_CRED,
214e1eca 3213 },
32ef447a
TK
3214#else
3215 {
3216 .name = "prio",
3217 .lname = "I/O nice priority",
3218 .type = FIO_OPT_UNSUPPORTED,
3219 .help = "Your platform does not support IO priorities",
3220 },
3221#endif
3222#ifdef FIO_HAVE_IOPRIO_CLASS
3223#ifndef FIO_HAVE_IOPRIO
3224#error "FIO_HAVE_IOPRIO_CLASS requires FIO_HAVE_IOPRIO"
3225#endif
214e1eca
JA
3226 {
3227 .name = "prioclass",
e8b0e958 3228 .lname = "I/O nice priority class",
214e1eca 3229 .type = FIO_OPT_INT,
a609f12a 3230 .off1 = offsetof(struct thread_options, ioprio_class),
214e1eca 3231 .help = "Set job IO priority class",
1767bd34
TK
3232 .minval = IOPRIO_MIN_PRIO_CLASS,
3233 .maxval = IOPRIO_MAX_PRIO_CLASS,
20eb06bd 3234 .interval = 1,
e8b0e958 3235 .category = FIO_OPT_C_GENERAL,
10860056 3236 .group = FIO_OPT_G_CRED,
214e1eca 3237 },
a275c37a 3238#else
a275c37a
JA
3239 {
3240 .name = "prioclass",
3241 .lname = "I/O nice priority class",
3242 .type = FIO_OPT_UNSUPPORTED,
32ef447a 3243 .help = "Your platform does not support IO priority classes",
a275c37a 3244 },
214e1eca
JA
3245#endif
3246 {
3247 .name = "thinktime",
e8b0e958 3248 .lname = "Thinktime",
214e1eca 3249 .type = FIO_OPT_INT,
a609f12a 3250 .off1 = offsetof(struct thread_options, thinktime),
214e1eca
JA
3251 .help = "Idle time between IO buffers (usec)",
3252 .def = "0",
88038bc7 3253 .is_time = 1,
e8b0e958 3254 .category = FIO_OPT_C_IO,
3ceb458f 3255 .group = FIO_OPT_G_THINKTIME,
214e1eca
JA
3256 },
3257 {
3258 .name = "thinktime_spin",
e8b0e958 3259 .lname = "Thinktime spin",
214e1eca 3260 .type = FIO_OPT_INT,
a609f12a 3261 .off1 = offsetof(struct thread_options, thinktime_spin),
214e1eca
JA
3262 .help = "Start think time by spinning this amount (usec)",
3263 .def = "0",
88038bc7 3264 .is_time = 1,
afdf9352 3265 .parent = "thinktime",
d71c154c 3266 .hide = 1,
e8b0e958 3267 .category = FIO_OPT_C_IO,
3ceb458f 3268 .group = FIO_OPT_G_THINKTIME,
214e1eca
JA
3269 },
3270 {
3271 .name = "thinktime_blocks",
e8b0e958 3272 .lname = "Thinktime blocks",
214e1eca 3273 .type = FIO_OPT_INT,
a609f12a 3274 .off1 = offsetof(struct thread_options, thinktime_blocks),
214e1eca
JA
3275 .help = "IO buffer period between 'thinktime'",
3276 .def = "1",
afdf9352 3277 .parent = "thinktime",
d71c154c 3278 .hide = 1,
e8b0e958 3279 .category = FIO_OPT_C_IO,
3ceb458f 3280 .group = FIO_OPT_G_THINKTIME,
214e1eca
JA
3281 },
3282 {
3283 .name = "rate",
e8b0e958 3284 .lname = "I/O rate",
e01b22b8 3285 .type = FIO_OPT_INT,
a609f12a
JA
3286 .off1 = offsetof(struct thread_options, rate[DDIR_READ]),
3287 .off2 = offsetof(struct thread_options, rate[DDIR_WRITE]),
3288 .off3 = offsetof(struct thread_options, rate[DDIR_TRIM]),
214e1eca 3289 .help = "Set bandwidth rate",
e8b0e958
JA
3290 .category = FIO_OPT_C_IO,
3291 .group = FIO_OPT_G_RATE,
214e1eca
JA
3292 },
3293 {
6d428bcd
JA
3294 .name = "rate_min",
3295 .alias = "ratemin",
e8b0e958 3296 .lname = "I/O min rate",
e01b22b8 3297 .type = FIO_OPT_INT,
a609f12a
JA
3298 .off1 = offsetof(struct thread_options, ratemin[DDIR_READ]),
3299 .off2 = offsetof(struct thread_options, ratemin[DDIR_WRITE]),
3300 .off3 = offsetof(struct thread_options, ratemin[DDIR_TRIM]),
4e991c23 3301 .help = "Job must meet this rate or it will be shutdown",
afdf9352 3302 .parent = "rate",
d71c154c 3303 .hide = 1,
e8b0e958
JA
3304 .category = FIO_OPT_C_IO,
3305 .group = FIO_OPT_G_RATE,
4e991c23
JA
3306 },
3307 {
3308 .name = "rate_iops",
e8b0e958 3309 .lname = "I/O rate IOPS",
e01b22b8 3310 .type = FIO_OPT_INT,
a609f12a
JA
3311 .off1 = offsetof(struct thread_options, rate_iops[DDIR_READ]),
3312 .off2 = offsetof(struct thread_options, rate_iops[DDIR_WRITE]),
3313 .off3 = offsetof(struct thread_options, rate_iops[DDIR_TRIM]),
4e991c23 3314 .help = "Limit IO used to this number of IO operations/sec",
d71c154c 3315 .hide = 1,
e8b0e958
JA
3316 .category = FIO_OPT_C_IO,
3317 .group = FIO_OPT_G_RATE,
4e991c23
JA
3318 },
3319 {
3320 .name = "rate_iops_min",
e8b0e958 3321 .lname = "I/O min rate IOPS",
e01b22b8 3322 .type = FIO_OPT_INT,
a609f12a
JA
3323 .off1 = offsetof(struct thread_options, rate_iops_min[DDIR_READ]),
3324 .off2 = offsetof(struct thread_options, rate_iops_min[DDIR_WRITE]),
3325 .off3 = offsetof(struct thread_options, rate_iops_min[DDIR_TRIM]),
03e20d68 3326 .help = "Job must meet this rate or it will be shut down",
afdf9352 3327 .parent = "rate_iops",
d71c154c 3328 .hide = 1,
e8b0e958
JA
3329 .category = FIO_OPT_C_IO,
3330 .group = FIO_OPT_G_RATE,
214e1eca 3331 },
ff6bb260 3332 {
6de65959
JA
3333 .name = "rate_process",
3334 .lname = "Rate Process",
3335 .type = FIO_OPT_STR,
a609f12a 3336 .off1 = offsetof(struct thread_options, rate_process),
6de65959
JA
3337 .help = "What process controls how rated IO is managed",
3338 .def = "linear",
ff6bb260
SL
3339 .category = FIO_OPT_C_IO,
3340 .group = FIO_OPT_G_RATE,
6de65959
JA
3341 .posval = {
3342 { .ival = "linear",
3343 .oval = RATE_PROCESS_LINEAR,
3344 .help = "Linear rate of IO",
3345 },
3346 {
3347 .ival = "poisson",
3348 .oval = RATE_PROCESS_POISSON,
3349 .help = "Rate follows Poisson process",
3350 },
3351 },
3352 .parent = "rate",
ff6bb260 3353 },
214e1eca 3354 {
6d428bcd
JA
3355 .name = "rate_cycle",
3356 .alias = "ratecycle",
e8b0e958 3357 .lname = "I/O rate cycle",
214e1eca 3358 .type = FIO_OPT_INT,
a609f12a 3359 .off1 = offsetof(struct thread_options, ratecycle),
214e1eca
JA
3360 .help = "Window average for rate limits (msec)",
3361 .def = "1000",
afdf9352 3362 .parent = "rate",
d71c154c 3363 .hide = 1,
e8b0e958
JA
3364 .category = FIO_OPT_C_IO,
3365 .group = FIO_OPT_G_RATE,
214e1eca 3366 },
15501535
JA
3367 {
3368 .name = "max_latency",
cce2fdfe 3369 .lname = "Max Latency",
15501535 3370 .type = FIO_OPT_INT,
a609f12a 3371 .off1 = offsetof(struct thread_options, max_latency),
15501535 3372 .help = "Maximum tolerated IO latency (usec)",
88038bc7 3373 .is_time = 1,
1e5324e7 3374 .category = FIO_OPT_C_IO,
3e260a46
JA
3375 .group = FIO_OPT_G_LATPROF,
3376 },
3377 {
3378 .name = "latency_target",
3379 .lname = "Latency Target (usec)",
3380 .type = FIO_OPT_STR_VAL_TIME,
a609f12a 3381 .off1 = offsetof(struct thread_options, latency_target),
3e260a46 3382 .help = "Ramp to max queue depth supporting this latency",
88038bc7 3383 .is_time = 1,
3e260a46
JA
3384 .category = FIO_OPT_C_IO,
3385 .group = FIO_OPT_G_LATPROF,
3386 },
3387 {
3388 .name = "latency_window",
3389 .lname = "Latency Window (usec)",
3390 .type = FIO_OPT_STR_VAL_TIME,
a609f12a 3391 .off1 = offsetof(struct thread_options, latency_window),
3e260a46 3392 .help = "Time to sustain latency_target",
88038bc7 3393 .is_time = 1,
3e260a46
JA
3394 .category = FIO_OPT_C_IO,
3395 .group = FIO_OPT_G_LATPROF,
3396 },
3397 {
3398 .name = "latency_percentile",
3399 .lname = "Latency Percentile",
3400 .type = FIO_OPT_FLOAT_LIST,
a609f12a 3401 .off1 = offsetof(struct thread_options, latency_percentile),
3e260a46
JA
3402 .help = "Percentile of IOs must be below latency_target",
3403 .def = "100",
3404 .maxlen = 1,
3405 .minfp = 0.0,
3406 .maxfp = 100.0,
3407 .category = FIO_OPT_C_IO,
3408 .group = FIO_OPT_G_LATPROF,
15501535 3409 },
214e1eca
JA
3410 {
3411 .name = "invalidate",
e8b0e958 3412 .lname = "Cache invalidate",
214e1eca 3413 .type = FIO_OPT_BOOL,
a609f12a 3414 .off1 = offsetof(struct thread_options, invalidate_cache),
214e1eca
JA
3415 .help = "Invalidate buffer/page cache prior to running job",
3416 .def = "1",
e8b0e958 3417 .category = FIO_OPT_C_IO,
3ceb458f 3418 .group = FIO_OPT_G_IO_TYPE,
214e1eca
JA
3419 },
3420 {
3421 .name = "sync",
e8b0e958 3422 .lname = "Synchronous I/O",
214e1eca 3423 .type = FIO_OPT_BOOL,
a609f12a 3424 .off1 = offsetof(struct thread_options, sync_io),
214e1eca
JA
3425 .help = "Use O_SYNC for buffered writes",
3426 .def = "0",
67a1000f 3427 .parent = "buffered",
d71c154c 3428 .hide = 1,
e8b0e958 3429 .category = FIO_OPT_C_IO,
3ceb458f 3430 .group = FIO_OPT_G_IO_TYPE,
214e1eca 3431 },
214e1eca
JA
3432 {
3433 .name = "create_serialize",
e8b0e958 3434 .lname = "Create serialize",
214e1eca 3435 .type = FIO_OPT_BOOL,
a609f12a 3436 .off1 = offsetof(struct thread_options, create_serialize),
c2b8035f 3437 .help = "Serialize creation of job files",
214e1eca 3438 .def = "1",
e8b0e958
JA
3439 .category = FIO_OPT_C_FILE,
3440 .group = FIO_OPT_G_INVALID,
214e1eca
JA
3441 },
3442 {
3443 .name = "create_fsync",
e8b0e958 3444 .lname = "Create fsync",
214e1eca 3445 .type = FIO_OPT_BOOL,
a609f12a 3446 .off1 = offsetof(struct thread_options, create_fsync),
03e20d68 3447 .help = "fsync file after creation",
214e1eca 3448 .def = "1",
e8b0e958
JA
3449 .category = FIO_OPT_C_FILE,
3450 .group = FIO_OPT_G_INVALID,
214e1eca 3451 },
814452bd
JA
3452 {
3453 .name = "create_on_open",
e8b0e958 3454 .lname = "Create on open",
814452bd 3455 .type = FIO_OPT_BOOL,
a609f12a 3456 .off1 = offsetof(struct thread_options, create_on_open),
814452bd
JA
3457 .help = "Create files when they are opened for IO",
3458 .def = "0",
e8b0e958
JA
3459 .category = FIO_OPT_C_FILE,
3460 .group = FIO_OPT_G_INVALID,