Allow ranges of CPUs in cpus_allowed option
[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>
6#include <getopt.h>
7#include <assert.h>
921c766f 8#include <libgen.h>
5921e80c
JA
9#include <fcntl.h>
10#include <sys/types.h>
11#include <sys/stat.h>
214e1eca
JA
12
13#include "fio.h"
14#include "parse.h"
eef32359 15#include "lib/fls.h"
214e1eca 16
2dc1bbeb 17#define td_var_offset(var) ((size_t) &((struct thread_options *)0)->var)
214e1eca
JA
18
19/*
20 * Check if mmap/mmaphuge has a :/foo/bar/file at the end. If so, return that.
21 */
22static char *get_opt_postfix(const char *str)
23{
24 char *p = strstr(str, ":");
25
26 if (!p)
27 return NULL;
28
29 p++;
30 strip_blank_front(&p);
31 strip_blank_end(p);
32 return strdup(p);
33}
34
564ca972
JA
35static int bs_cmp(const void *p1, const void *p2)
36{
37 const struct bssplit *bsp1 = p1;
38 const struct bssplit *bsp2 = p2;
39
40 return bsp1->perc < bsp2->perc;
41}
42
43static int str_bssplit_cb(void *data, const char *input)
44{
45 struct thread_data *td = data;
46 char *fname, *str, *p;
47 unsigned int i, perc, perc_missing;
48 unsigned int max_bs, min_bs;
49 long long val;
50
51 p = str = strdup(input);
52
53 strip_blank_front(&str);
54 strip_blank_end(str);
55
56 td->o.bssplit_nr = 4;
57 td->o.bssplit = malloc(4 * sizeof(struct bssplit));
58
59 i = 0;
60 max_bs = 0;
61 min_bs = -1;
62 while ((fname = strsep(&str, ":")) != NULL) {
63 char *perc_str;
64
65 if (!strlen(fname))
66 break;
67
68 /*
69 * grow struct buffer, if needed
70 */
71 if (i == td->o.bssplit_nr) {
72 td->o.bssplit_nr <<= 1;
5ec10eaa
JA
73 td->o.bssplit = realloc(td->o.bssplit,
74 td->o.bssplit_nr
75 * sizeof(struct bssplit));
564ca972
JA
76 }
77
78 perc_str = strstr(fname, "/");
79 if (perc_str) {
80 *perc_str = '\0';
81 perc_str++;
82 perc = atoi(perc_str);
83 if (perc > 100)
84 perc = 100;
85 else if (!perc)
86 perc = -1;
87 } else
88 perc = -1;
89
90 if (str_to_decimal(fname, &val, 1)) {
91 log_err("fio: bssplit conversion failed\n");
92 free(td->o.bssplit);
93 return 1;
94 }
95
96 if (val > max_bs)
97 max_bs = val;
98 if (val < min_bs)
99 min_bs = val;
100
101 td->o.bssplit[i].bs = val;
102 td->o.bssplit[i].perc = perc;
103 i++;
104 }
105
106 td->o.bssplit_nr = i;
107
108 /*
109 * Now check if the percentages add up, and how much is missing
110 */
111 perc = perc_missing = 0;
112 for (i = 0; i < td->o.bssplit_nr; i++) {
113 struct bssplit *bsp = &td->o.bssplit[i];
114
115 if (bsp->perc == (unsigned char) -1)
116 perc_missing++;
117 else
118 perc += bsp->perc;
119 }
120
121 if (perc > 100) {
122 log_err("fio: bssplit percentages add to more than 100%%\n");
123 free(td->o.bssplit);
124 return 1;
125 }
126 /*
127 * If values didn't have a percentage set, divide the remains between
128 * them.
129 */
130 if (perc_missing) {
131 for (i = 0; i < td->o.bssplit_nr; i++) {
132 struct bssplit *bsp = &td->o.bssplit[i];
133
134 if (bsp->perc == (unsigned char) -1)
135 bsp->perc = (100 - perc) / perc_missing;
136 }
137 }
138
139 td->o.min_bs[DDIR_READ] = td->o.min_bs[DDIR_WRITE] = min_bs;
140 td->o.max_bs[DDIR_READ] = td->o.max_bs[DDIR_WRITE] = max_bs;
141
142 /*
143 * now sort based on percentages, for ease of lookup
144 */
145 qsort(td->o.bssplit, td->o.bssplit_nr, sizeof(struct bssplit), bs_cmp);
146
147 free(p);
148 return 0;
149}
150
211097b2
JA
151static int str_rw_cb(void *data, const char *str)
152{
153 struct thread_data *td = data;
154 char *nr = get_opt_postfix(str);
155
fafdba3c 156 td->o.ddir_nr = 1;
182ec6ee 157 if (nr) {
211097b2 158 td->o.ddir_nr = atoi(nr);
182ec6ee
JA
159 free(nr);
160 }
211097b2 161
211097b2
JA
162 return 0;
163}
164
214e1eca
JA
165static int str_mem_cb(void *data, const char *mem)
166{
167 struct thread_data *td = data;
168
2dc1bbeb 169 if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP) {
214e1eca 170 td->mmapfile = get_opt_postfix(mem);
2dc1bbeb 171 if (td->o.mem_type == MEM_MMAPHUGE && !td->mmapfile) {
214e1eca
JA
172 log_err("fio: mmaphuge:/path/to/file\n");
173 return 1;
174 }
175 }
176
177 return 0;
178}
179
180static int str_lockmem_cb(void fio_unused *data, unsigned long *val)
181{
182 mlock_size = *val;
183 return 0;
184}
185
cb499fc4
JA
186static int str_rwmix_read_cb(void *data, unsigned int *val)
187{
188 struct thread_data *td = data;
189
190 td->o.rwmix[DDIR_READ] = *val;
191 td->o.rwmix[DDIR_WRITE] = 100 - *val;
192 return 0;
193}
194
195static int str_rwmix_write_cb(void *data, unsigned int *val)
196{
197 struct thread_data *td = data;
198
199 td->o.rwmix[DDIR_WRITE] = *val;
200 td->o.rwmix[DDIR_READ] = 100 - *val;
201 return 0;
202}
203
214e1eca
JA
204#ifdef FIO_HAVE_IOPRIO
205static int str_prioclass_cb(void *data, unsigned int *val)
206{
207 struct thread_data *td = data;
6cefbe33
JA
208 unsigned short mask;
209
210 /*
211 * mask off old class bits, str_prio_cb() may have set a default class
212 */
213 mask = (1 << IOPRIO_CLASS_SHIFT) - 1;
214 td->ioprio &= mask;
214e1eca
JA
215
216 td->ioprio |= *val << IOPRIO_CLASS_SHIFT;
ac684785 217 td->ioprio_set = 1;
214e1eca
JA
218 return 0;
219}
220
221static int str_prio_cb(void *data, unsigned int *val)
222{
223 struct thread_data *td = data;
224
225 td->ioprio |= *val;
6cefbe33
JA
226
227 /*
228 * If no class is set, assume BE
229 */
230 if ((td->ioprio >> IOPRIO_CLASS_SHIFT) == 0)
231 td->ioprio |= IOPRIO_CLASS_BE << IOPRIO_CLASS_SHIFT;
232
ac684785 233 td->ioprio_set = 1;
214e1eca
JA
234 return 0;
235}
236#endif
237
238static int str_exitall_cb(void)
239{
240 exitall_on_terminate = 1;
241 return 0;
242}
243
214e1eca 244#ifdef FIO_HAVE_CPU_AFFINITY
d2e268b0
JA
245static int str_cpumask_cb(void *data, unsigned int *val)
246{
247 struct thread_data *td = data;
214e1eca
JA
248 unsigned int i;
249
d2e268b0 250 CPU_ZERO(&td->o.cpumask);
214e1eca 251
62a7273d
JA
252 for (i = 0; i < sizeof(int) * 8; i++) {
253 if ((1 << i) & *val) {
254 dprint(FD_PARSE, "set cpu allowed %d\n", i);
d2e268b0 255 CPU_SET(*val, &td->o.cpumask);
62a7273d
JA
256 }
257 }
d2e268b0
JA
258
259 td->o.cpumask_set = 1;
260 return 0;
214e1eca
JA
261}
262
d2e268b0 263static int str_cpus_allowed_cb(void *data, const char *input)
214e1eca
JA
264{
265 struct thread_data *td = data;
d2e268b0
JA
266 char *cpu, *str, *p;
267
268 CPU_ZERO(&td->o.cpumask);
269
270 p = str = strdup(input);
214e1eca 271
d2e268b0
JA
272 strip_blank_front(&str);
273 strip_blank_end(str);
274
275 while ((cpu = strsep(&str, ",")) != NULL) {
62a7273d
JA
276 char *str2, *cpu2;
277 int icpu, icpu2;
278
d2e268b0
JA
279 if (!strlen(cpu))
280 break;
62a7273d
JA
281
282 str2 = cpu;
283 icpu2 = -1;
284 while ((cpu2 = strsep(&str2, "-")) != NULL) {
285 if (!strlen(cpu2))
286 break;
287
288 icpu2 = atoi(cpu2);
289 }
290
291 icpu = atoi(cpu);
292 if (icpu2 == -1)
293 icpu2 = icpu;
294 while (icpu <= icpu2) {
295 dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
296 CPU_SET(atoi(cpu), &td->o.cpumask);
297 icpu++;
298 }
d2e268b0
JA
299 }
300
301 free(p);
375b2695 302 td->o.cpumask_set = 1;
214e1eca
JA
303 return 0;
304}
d2e268b0 305#endif
214e1eca
JA
306
307static int str_fst_cb(void *data, const char *str)
308{
309 struct thread_data *td = data;
310 char *nr = get_opt_postfix(str);
311
312 td->file_service_nr = 1;
182ec6ee 313 if (nr) {
214e1eca 314 td->file_service_nr = atoi(nr);
182ec6ee
JA
315 free(nr);
316 }
214e1eca
JA
317
318 return 0;
319}
320
921c766f
JA
321static int check_dir(struct thread_data *td, char *fname)
322{
323 char file[PATH_MAX], *dir;
bc838919 324 int elen = 0;
921c766f 325
bc838919
JA
326 if (td->o.directory) {
327 strcpy(file, td->o.directory);
fcef0b35 328 strcat(file, "/");
bc838919
JA
329 elen = strlen(file);
330 }
331
fcef0b35 332 sprintf(file + elen, "%s", fname);
921c766f
JA
333 dir = dirname(file);
334
fcef0b35
JA
335#if 0
336 {
337 struct stat sb;
338 /*
339 * We can't do this on FIO_DISKLESSIO engines. The engine isn't loaded
340 * yet, so we can't do this check right here...
341 */
921c766f
JA
342 if (lstat(dir, &sb) < 0) {
343 int ret = errno;
344
345 log_err("fio: %s is not a directory\n", dir);
346 td_verror(td, ret, "lstat");
347 return 1;
348 }
349
350 if (!S_ISDIR(sb.st_mode)) {
351 log_err("fio: %s is not a directory\n", dir);
352 return 1;
353 }
fcef0b35
JA
354 }
355#endif
921c766f
JA
356
357 return 0;
358}
359
214e1eca
JA
360static int str_filename_cb(void *data, const char *input)
361{
362 struct thread_data *td = data;
363 char *fname, *str, *p;
364
365 p = str = strdup(input);
366
367 strip_blank_front(&str);
368 strip_blank_end(str);
369
370 if (!td->files_index)
2dc1bbeb 371 td->o.nr_files = 0;
214e1eca
JA
372
373 while ((fname = strsep(&str, ":")) != NULL) {
374 if (!strlen(fname))
375 break;
921c766f
JA
376 if (check_dir(td, fname)) {
377 free(p);
378 return 1;
379 }
214e1eca 380 add_file(td, fname);
2dc1bbeb 381 td->o.nr_files++;
214e1eca
JA
382 }
383
384 free(p);
385 return 0;
386}
387
388static int str_directory_cb(void *data, const char fio_unused *str)
389{
390 struct thread_data *td = data;
391 struct stat sb;
392
2dc1bbeb 393 if (lstat(td->o.directory, &sb) < 0) {
921c766f
JA
394 int ret = errno;
395
2dc1bbeb 396 log_err("fio: %s is not a directory\n", td->o.directory);
921c766f 397 td_verror(td, ret, "lstat");
214e1eca
JA
398 return 1;
399 }
400 if (!S_ISDIR(sb.st_mode)) {
2dc1bbeb 401 log_err("fio: %s is not a directory\n", td->o.directory);
214e1eca
JA
402 return 1;
403 }
404
405 return 0;
406}
407
408static int str_opendir_cb(void *data, const char fio_unused *str)
409{
410 struct thread_data *td = data;
411
412 if (!td->files_index)
2dc1bbeb 413 td->o.nr_files = 0;
214e1eca 414
2dc1bbeb 415 return add_dir_files(td, td->o.opendir);
214e1eca
JA
416}
417
a59e170d 418static int str_verify_offset_cb(void *data, unsigned int *off)
546a9142
SL
419{
420 struct thread_data *td = data;
a59e170d 421
546a9142 422 if (*off && *off < sizeof(struct verify_header)) {
a59e170d 423 log_err("fio: verify_offset too small\n");
546a9142
SL
424 return 1;
425 }
a59e170d
JA
426
427 td->o.verify_offset = *off;
546a9142
SL
428 return 0;
429}
430
e28218f3 431static int str_verify_pattern_cb(void *data, unsigned int *off)
90059d65
JA
432{
433 struct thread_data *td = data;
e28218f3 434 unsigned int msb;
90059d65 435
3c48c2c1 436 msb = __fls(*off);
90059d65
JA
437 if (msb <= 8)
438 td->o.verify_pattern_bytes = 1;
439 else if (msb <= 16)
440 td->o.verify_pattern_bytes = 2;
441 else if (msb <= 24)
442 td->o.verify_pattern_bytes = 3;
443 else
444 td->o.verify_pattern_bytes = 4;
445
e28218f3 446 td->o.verify_pattern = *off;
90059d65
JA
447 return 0;
448}
214e1eca 449
4d4e80f2
JA
450static int str_lockfile_cb(void *data, const char *str)
451{
452 struct thread_data *td = data;
453 char *nr = get_opt_postfix(str);
454
455 td->o.lockfile_batch = 1;
182ec6ee 456 if (nr) {
4d4e80f2 457 td->o.lockfile_batch = atoi(nr);
182ec6ee
JA
458 free(nr);
459 }
4d4e80f2
JA
460
461 return 0;
462}
463
e3cedca7
JA
464static int str_write_bw_log_cb(void *data, const char *str)
465{
466 struct thread_data *td = data;
467
468 if (str)
469 td->o.bw_log_file = strdup(str);
470
471 td->o.write_bw_log = 1;
472 return 0;
473}
474
475static int str_write_lat_log_cb(void *data, const char *str)
476{
477 struct thread_data *td = data;
478
479 if (str)
480 td->o.lat_log_file = strdup(str);
481
482 td->o.write_lat_log = 1;
483 return 0;
484}
485
993bf48b
JA
486static int str_gtod_reduce_cb(void *data, int *il)
487{
488 struct thread_data *td = data;
489 int val = *il;
490
491 td->o.disable_clat = !!val;
492 td->o.disable_slat = !!val;
493 td->o.disable_bw = !!val;
494 if (val)
495 td->tv_cache_mask = 63;
496
497 return 0;
498}
499
214e1eca
JA
500#define __stringify_1(x) #x
501#define __stringify(x) __stringify_1(x)
502
503/*
504 * Map of job/command line options
505 */
506static struct fio_option options[] = {
507 {
508 .name = "description",
509 .type = FIO_OPT_STR_STORE,
510 .off1 = td_var_offset(description),
511 .help = "Text job description",
512 },
513 {
514 .name = "name",
515 .type = FIO_OPT_STR_STORE,
516 .off1 = td_var_offset(name),
517 .help = "Name of this job",
518 },
519 {
520 .name = "directory",
521 .type = FIO_OPT_STR_STORE,
522 .off1 = td_var_offset(directory),
523 .cb = str_directory_cb,
524 .help = "Directory to store files in",
525 },
526 {
527 .name = "filename",
528 .type = FIO_OPT_STR_STORE,
529 .off1 = td_var_offset(filename),
530 .cb = str_filename_cb,
3b8b7135 531 .prio = 1, /* must come before "directory" */
214e1eca
JA
532 .help = "File(s) to use for the workload",
533 },
29c1349f
JA
534 {
535 .name = "lockfile",
4d4e80f2
JA
536 .type = FIO_OPT_STR,
537 .cb = str_lockfile_cb,
538 .off1 = td_var_offset(file_lock_mode),
29c1349f
JA
539 .help = "Lock file when doing IO to it",
540 .parent = "filename",
4d4e80f2
JA
541 .def = "none",
542 .posval = {
543 { .ival = "none",
544 .oval = FILE_LOCK_NONE,
545 .help = "No file locking",
546 },
547 { .ival = "exclusive",
548 .oval = FILE_LOCK_EXCLUSIVE,
549 .help = "Exclusive file lock",
550 },
551 {
552 .ival = "readwrite",
553 .oval = FILE_LOCK_READWRITE,
554 .help = "Read vs write lock",
555 },
556 },
29c1349f 557 },
214e1eca
JA
558 {
559 .name = "opendir",
560 .type = FIO_OPT_STR_STORE,
561 .off1 = td_var_offset(opendir),
562 .cb = str_opendir_cb,
563 .help = "Recursively add files from this directory and down",
564 },
565 {
566 .name = "rw",
d3aad8f2 567 .alias = "readwrite",
214e1eca 568 .type = FIO_OPT_STR,
211097b2 569 .cb = str_rw_cb,
214e1eca
JA
570 .off1 = td_var_offset(td_ddir),
571 .help = "IO direction",
572 .def = "read",
573 .posval = {
574 { .ival = "read",
575 .oval = TD_DDIR_READ,
576 .help = "Sequential read",
577 },
578 { .ival = "write",
579 .oval = TD_DDIR_WRITE,
580 .help = "Sequential write",
581 },
582 { .ival = "randread",
583 .oval = TD_DDIR_RANDREAD,
584 .help = "Random read",
585 },
586 { .ival = "randwrite",
587 .oval = TD_DDIR_RANDWRITE,
588 .help = "Random write",
589 },
590 { .ival = "rw",
591 .oval = TD_DDIR_RW,
592 .help = "Sequential read and write mix",
593 },
594 { .ival = "randrw",
595 .oval = TD_DDIR_RANDRW,
596 .help = "Random read and write mix"
597 },
598 },
599 },
600 {
601 .name = "ioengine",
602 .type = FIO_OPT_STR_STORE,
603 .off1 = td_var_offset(ioengine),
604 .help = "IO engine to use",
605 .def = "sync",
606 .posval = {
607 { .ival = "sync",
608 .help = "Use read/write",
609 },
a31041ea 610 { .ival = "psync",
611 .help = "Use pread/pwrite",
612 },
1d2af02a
JA
613 { .ival = "vsync",
614 .help = "Use readv/writev",
615 },
214e1eca
JA
616#ifdef FIO_HAVE_LIBAIO
617 { .ival = "libaio",
618 .help = "Linux native asynchronous IO",
619 },
620#endif
621#ifdef FIO_HAVE_POSIXAIO
622 { .ival = "posixaio",
623 .help = "POSIX asynchronous IO",
624 },
417f0068
JA
625#endif
626#ifdef FIO_HAVE_SOLARISAIO
627 { .ival = "solarisaio",
628 .help = "Solaris native asynchronous IO",
629 },
214e1eca
JA
630#endif
631 { .ival = "mmap",
632 .help = "Memory mapped IO",
633 },
634#ifdef FIO_HAVE_SPLICE
635 { .ival = "splice",
636 .help = "splice/vmsplice based IO",
637 },
9cce02e8
JA
638 { .ival = "netsplice",
639 .help = "splice/vmsplice to/from the network",
640 },
214e1eca
JA
641#endif
642#ifdef FIO_HAVE_SGIO
643 { .ival = "sg",
644 .help = "SCSI generic v3 IO",
645 },
646#endif
647 { .ival = "null",
648 .help = "Testing engine (no data transfer)",
649 },
650 { .ival = "net",
651 .help = "Network IO",
652 },
653#ifdef FIO_HAVE_SYSLET
654 { .ival = "syslet-rw",
655 .help = "syslet enabled async pread/pwrite IO",
656 },
657#endif
658 { .ival = "cpuio",
659 .help = "CPU cycler burner engine",
660 },
b8c82a46
JA
661#ifdef FIO_HAVE_GUASI
662 { .ival = "guasi",
663 .help = "GUASI IO engine",
664 },
665#endif
214e1eca
JA
666 { .ival = "external",
667 .help = "Load external engine (append name)",
668 },
669 },
670 },
671 {
672 .name = "iodepth",
673 .type = FIO_OPT_INT,
674 .off1 = td_var_offset(iodepth),
675 .help = "Amount of IO buffers to keep in flight",
757aff4f 676 .minval = 1,
214e1eca
JA
677 .def = "1",
678 },
679 {
680 .name = "iodepth_batch",
4950421a 681 .alias = "iodepth_batch_submit",
214e1eca
JA
682 .type = FIO_OPT_INT,
683 .off1 = td_var_offset(iodepth_batch),
684 .help = "Number of IO to submit in one go",
afdf9352 685 .parent = "iodepth",
a2e6f8ac
JA
686 .minval = 1,
687 .def = "1",
4950421a
JA
688 },
689 {
690 .name = "iodepth_batch_complete",
691 .type = FIO_OPT_INT,
692 .off1 = td_var_offset(iodepth_batch_complete),
693 .help = "Number of IO to retrieve in one go",
694 .parent = "iodepth",
695 .minval = 0,
696 .def = "1",
214e1eca
JA
697 },
698 {
699 .name = "iodepth_low",
700 .type = FIO_OPT_INT,
701 .off1 = td_var_offset(iodepth_low),
702 .help = "Low water mark for queuing depth",
afdf9352 703 .parent = "iodepth",
214e1eca
JA
704 },
705 {
706 .name = "size",
707 .type = FIO_OPT_STR_VAL,
2dc1bbeb 708 .off1 = td_var_offset(size),
c3edbdba 709 .minval = 1,
214e1eca
JA
710 .help = "Total size of device or files",
711 },
aa31f1f1
SL
712 {
713 .name = "fill_device",
714 .type = FIO_OPT_BOOL,
715 .off1 = td_var_offset(fill_device),
716 .help = "Write until an ENOSPC error occurs",
717 .def = "0",
718 },
214e1eca
JA
719 {
720 .name = "filesize",
721 .type = FIO_OPT_STR_VAL,
722 .off1 = td_var_offset(file_size_low),
723 .off2 = td_var_offset(file_size_high),
c3edbdba 724 .minval = 1,
214e1eca
JA
725 .help = "Size of individual files",
726 },
67a1000f
JA
727 {
728 .name = "offset",
729 .alias = "fileoffset",
730 .type = FIO_OPT_STR_VAL,
731 .off1 = td_var_offset(start_offset),
732 .help = "Start IO from this offset",
733 .def = "0",
734 },
214e1eca
JA
735 {
736 .name = "bs",
d3aad8f2 737 .alias = "blocksize",
214e1eca
JA
738 .type = FIO_OPT_STR_VAL_INT,
739 .off1 = td_var_offset(bs[DDIR_READ]),
740 .off2 = td_var_offset(bs[DDIR_WRITE]),
c3edbdba 741 .minval = 1,
214e1eca
JA
742 .help = "Block size unit",
743 .def = "4k",
67a1000f 744 .parent = "rw",
214e1eca
JA
745 },
746 {
747 .name = "bsrange",
d3aad8f2 748 .alias = "blocksize_range",
214e1eca
JA
749 .type = FIO_OPT_RANGE,
750 .off1 = td_var_offset(min_bs[DDIR_READ]),
751 .off2 = td_var_offset(max_bs[DDIR_READ]),
752 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
753 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
c3edbdba 754 .minval = 1,
214e1eca 755 .help = "Set block size range (in more detail than bs)",
67a1000f 756 .parent = "rw",
214e1eca 757 },
564ca972
JA
758 {
759 .name = "bssplit",
760 .type = FIO_OPT_STR,
761 .cb = str_bssplit_cb,
762 .help = "Set a specific mix of block sizes",
763 .parent = "rw",
764 },
214e1eca
JA
765 {
766 .name = "bs_unaligned",
d3aad8f2 767 .alias = "blocksize_unaligned",
214e1eca
JA
768 .type = FIO_OPT_STR_SET,
769 .off1 = td_var_offset(bs_unaligned),
770 .help = "Don't sector align IO buffer sizes",
67a1000f 771 .parent = "rw",
214e1eca
JA
772 },
773 {
774 .name = "randrepeat",
775 .type = FIO_OPT_BOOL,
776 .off1 = td_var_offset(rand_repeatable),
777 .help = "Use repeatable random IO pattern",
778 .def = "1",
67a1000f 779 .parent = "rw",
214e1eca
JA
780 },
781 {
782 .name = "norandommap",
783 .type = FIO_OPT_STR_SET,
784 .off1 = td_var_offset(norandommap),
785 .help = "Accept potential duplicate random blocks",
67a1000f 786 .parent = "rw",
214e1eca 787 },
2b386d25
JA
788 {
789 .name = "softrandommap",
790 .type = FIO_OPT_BOOL,
791 .off1 = td_var_offset(softrandommap),
f66ab3c8 792 .help = "Set norandommap if randommap allocation fails",
2b386d25
JA
793 .parent = "norandommap",
794 .def = "0",
795 },
214e1eca
JA
796 {
797 .name = "nrfiles",
798 .type = FIO_OPT_INT,
799 .off1 = td_var_offset(nr_files),
800 .help = "Split job workload between this number of files",
801 .def = "1",
802 },
803 {
804 .name = "openfiles",
805 .type = FIO_OPT_INT,
806 .off1 = td_var_offset(open_files),
807 .help = "Number of files to keep open at the same time",
808 },
809 {
810 .name = "file_service_type",
811 .type = FIO_OPT_STR,
812 .cb = str_fst_cb,
813 .off1 = td_var_offset(file_service_type),
814 .help = "How to select which file to service next",
815 .def = "roundrobin",
816 .posval = {
817 { .ival = "random",
818 .oval = FIO_FSERVICE_RANDOM,
819 .help = "Choose a file at random",
820 },
821 { .ival = "roundrobin",
822 .oval = FIO_FSERVICE_RR,
823 .help = "Round robin select files",
824 },
825 },
67a1000f
JA
826 .parent = "nrfiles",
827 },
828 {
829 .name = "fadvise_hint",
830 .type = FIO_OPT_BOOL,
831 .off1 = td_var_offset(fadvise_hint),
832 .help = "Use fadvise() to advise the kernel on IO pattern",
833 .def = "1",
214e1eca
JA
834 },
835 {
836 .name = "fsync",
837 .type = FIO_OPT_INT,
838 .off1 = td_var_offset(fsync_blocks),
839 .help = "Issue fsync for writes every given number of blocks",
840 .def = "0",
841 },
842 {
843 .name = "direct",
844 .type = FIO_OPT_BOOL,
845 .off1 = td_var_offset(odirect),
846 .help = "Use O_DIRECT IO (negates buffered)",
847 .def = "0",
848 },
849 {
850 .name = "buffered",
851 .type = FIO_OPT_BOOL,
852 .off1 = td_var_offset(odirect),
853 .neg = 1,
854 .help = "Use buffered IO (negates direct)",
855 .def = "1",
856 },
857 {
858 .name = "overwrite",
859 .type = FIO_OPT_BOOL,
860 .off1 = td_var_offset(overwrite),
861 .help = "When writing, set whether to overwrite current data",
862 .def = "0",
863 },
864 {
865 .name = "loops",
866 .type = FIO_OPT_INT,
867 .off1 = td_var_offset(loops),
868 .help = "Number of times to run the job",
869 .def = "1",
870 },
871 {
872 .name = "numjobs",
873 .type = FIO_OPT_INT,
874 .off1 = td_var_offset(numjobs),
875 .help = "Duplicate this job this many times",
876 .def = "1",
877 },
878 {
879 .name = "startdelay",
880 .type = FIO_OPT_INT,
881 .off1 = td_var_offset(start_delay),
882 .help = "Only start job when this period has passed",
883 .def = "0",
884 },
885 {
886 .name = "runtime",
887 .alias = "timeout",
888 .type = FIO_OPT_STR_VAL_TIME,
889 .off1 = td_var_offset(timeout),
890 .help = "Stop workload when this amount of time has passed",
891 .def = "0",
892 },
cf4464ca
JA
893 {
894 .name = "time_based",
895 .type = FIO_OPT_STR_SET,
896 .off1 = td_var_offset(time_based),
897 .help = "Keep running until runtime/timeout is met",
898 },
721938ae
JA
899 {
900 .name = "ramp_time",
901 .type = FIO_OPT_STR_VAL_TIME,
902 .off1 = td_var_offset(ramp_time),
903 .help = "Ramp up time before measuring performance",
904 },
214e1eca
JA
905 {
906 .name = "mem",
d3aad8f2 907 .alias = "iomem",
214e1eca
JA
908 .type = FIO_OPT_STR,
909 .cb = str_mem_cb,
910 .off1 = td_var_offset(mem_type),
911 .help = "Backing type for IO buffers",
912 .def = "malloc",
913 .posval = {
914 { .ival = "malloc",
915 .oval = MEM_MALLOC,
916 .help = "Use malloc(3) for IO buffers",
917 },
37c8cdfe
JA
918 { .ival = "shm",
919 .oval = MEM_SHM,
920 .help = "Use shared memory segments for IO buffers",
921 },
214e1eca
JA
922#ifdef FIO_HAVE_HUGETLB
923 { .ival = "shmhuge",
924 .oval = MEM_SHMHUGE,
925 .help = "Like shm, but use huge pages",
926 },
b370e46a 927#endif
37c8cdfe
JA
928 { .ival = "mmap",
929 .oval = MEM_MMAP,
930 .help = "Use mmap(2) (file or anon) for IO buffers",
931 },
214e1eca
JA
932#ifdef FIO_HAVE_HUGETLB
933 { .ival = "mmaphuge",
934 .oval = MEM_MMAPHUGE,
935 .help = "Like mmap, but use huge pages",
936 },
937#endif
938 },
939 },
940 {
941 .name = "verify",
942 .type = FIO_OPT_STR,
943 .off1 = td_var_offset(verify),
944 .help = "Verify data written",
945 .def = "0",
946 .posval = {
947 { .ival = "0",
948 .oval = VERIFY_NONE,
949 .help = "Don't do IO verification",
950 },
fcca4b58
JA
951 { .ival = "md5",
952 .oval = VERIFY_MD5,
953 .help = "Use md5 checksums for verification",
954 },
d77a7af3
JA
955 { .ival = "crc64",
956 .oval = VERIFY_CRC64,
957 .help = "Use crc64 checksums for verification",
958 },
214e1eca
JA
959 { .ival = "crc32",
960 .oval = VERIFY_CRC32,
961 .help = "Use crc32 checksums for verification",
962 },
af497e6a
JA
963 { .ival = "crc32c-intel",
964 .oval = VERIFY_CRC32C_INTEL,
965 .help = "Use hw crc32c checksums for verification",
966 },
bac39e0e
JA
967 { .ival = "crc32c",
968 .oval = VERIFY_CRC32C,
969 .help = "Use crc32c checksums for verification",
970 },
969f7ed3
JA
971 { .ival = "crc16",
972 .oval = VERIFY_CRC16,
973 .help = "Use crc16 checksums for verification",
974 },
1e154bdb
JA
975 { .ival = "crc7",
976 .oval = VERIFY_CRC7,
977 .help = "Use crc7 checksums for verification",
978 },
cd14cc10
JA
979 { .ival = "sha256",
980 .oval = VERIFY_SHA256,
981 .help = "Use sha256 checksums for verification",
982 },
983 { .ival = "sha512",
984 .oval = VERIFY_SHA512,
985 .help = "Use sha512 checksums for verification",
986 },
7437ee87
SL
987 { .ival = "meta",
988 .oval = VERIFY_META,
989 .help = "Use io information",
990 },
36690c9b
JA
991 {
992 .ival = "null",
993 .oval = VERIFY_NULL,
994 .help = "Pretend to verify",
995 },
214e1eca
JA
996 },
997 },
005c565a
JA
998 {
999 .name = "do_verify",
68e1f29a 1000 .type = FIO_OPT_BOOL,
005c565a
JA
1001 .off1 = td_var_offset(do_verify),
1002 .help = "Run verification stage after write",
1003 .def = "1",
1004 .parent = "verify",
1005 },
160b966d
JA
1006 {
1007 .name = "verifysort",
1008 .type = FIO_OPT_BOOL,
1009 .off1 = td_var_offset(verifysort),
1010 .help = "Sort written verify blocks for read back",
1011 .def = "1",
c83f2df1 1012 .parent = "verify",
160b966d 1013 },
3f9f4e26 1014 {
a59e170d 1015 .name = "verify_interval",
3f9f4e26 1016 .type = FIO_OPT_STR_VAL_INT,
a59e170d 1017 .off1 = td_var_offset(verify_interval),
819a9680 1018 .minval = 2 * sizeof(struct verify_header),
a59e170d 1019 .help = "Store verify buffer header every N bytes",
afdf9352 1020 .parent = "verify",
3f9f4e26 1021 },
546a9142 1022 {
a59e170d 1023 .name = "verify_offset",
546a9142 1024 .type = FIO_OPT_STR_VAL_INT,
a59e170d 1025 .help = "Offset verify header location by N bytes",
546a9142 1026 .def = "0",
5ec10eaa 1027 .cb = str_verify_offset_cb,
afdf9352 1028 .parent = "verify",
546a9142 1029 },
e28218f3
SL
1030 {
1031 .name = "verify_pattern",
1032 .type = FIO_OPT_INT,
1033 .cb = str_verify_pattern_cb,
1034 .help = "Fill pattern for IO buffers",
1035 .parent = "verify",
1036 },
a12a3b4d
JA
1037 {
1038 .name = "verify_fatal",
68e1f29a 1039 .type = FIO_OPT_BOOL,
a12a3b4d
JA
1040 .off1 = td_var_offset(verify_fatal),
1041 .def = "0",
1042 .help = "Exit on a single verify failure, don't continue",
1043 .parent = "verify",
1044 },
214e1eca
JA
1045 {
1046 .name = "write_iolog",
1047 .type = FIO_OPT_STR_STORE,
1048 .off1 = td_var_offset(write_iolog_file),
1049 .help = "Store IO pattern to file",
1050 },
1051 {
1052 .name = "read_iolog",
1053 .type = FIO_OPT_STR_STORE,
1054 .off1 = td_var_offset(read_iolog_file),
1055 .help = "Playback IO pattern from file",
1056 },
1057 {
1058 .name = "exec_prerun",
1059 .type = FIO_OPT_STR_STORE,
1060 .off1 = td_var_offset(exec_prerun),
1061 .help = "Execute this file prior to running job",
1062 },
1063 {
1064 .name = "exec_postrun",
1065 .type = FIO_OPT_STR_STORE,
1066 .off1 = td_var_offset(exec_postrun),
1067 .help = "Execute this file after running job",
1068 },
1069#ifdef FIO_HAVE_IOSCHED_SWITCH
1070 {
1071 .name = "ioscheduler",
1072 .type = FIO_OPT_STR_STORE,
1073 .off1 = td_var_offset(ioscheduler),
1074 .help = "Use this IO scheduler on the backing device",
1075 },
1076#endif
1077 {
1078 .name = "zonesize",
1079 .type = FIO_OPT_STR_VAL,
1080 .off1 = td_var_offset(zone_size),
1081 .help = "Give size of an IO zone",
1082 .def = "0",
1083 },
1084 {
1085 .name = "zoneskip",
1086 .type = FIO_OPT_STR_VAL,
1087 .off1 = td_var_offset(zone_skip),
1088 .help = "Space between IO zones",
1089 .def = "0",
1090 },
1091 {
1092 .name = "lockmem",
1093 .type = FIO_OPT_STR_VAL,
1094 .cb = str_lockmem_cb,
1095 .help = "Lock down this amount of memory",
1096 .def = "0",
1097 },
214e1eca
JA
1098 {
1099 .name = "rwmixread",
1100 .type = FIO_OPT_INT,
cb499fc4 1101 .cb = str_rwmix_read_cb,
214e1eca
JA
1102 .maxval = 100,
1103 .help = "Percentage of mixed workload that is reads",
1104 .def = "50",
1105 },
1106 {
1107 .name = "rwmixwrite",
1108 .type = FIO_OPT_INT,
cb499fc4 1109 .cb = str_rwmix_write_cb,
214e1eca
JA
1110 .maxval = 100,
1111 .help = "Percentage of mixed workload that is writes",
1112 .def = "50",
1113 },
afdf9352
JA
1114 {
1115 .name = "rwmixcycle",
15ca150e 1116 .type = FIO_OPT_DEPRECATED,
afdf9352 1117 },
214e1eca
JA
1118 {
1119 .name = "nice",
1120 .type = FIO_OPT_INT,
1121 .off1 = td_var_offset(nice),
1122 .help = "Set job CPU nice value",
1123 .minval = -19,
1124 .maxval = 20,
1125 .def = "0",
1126 },
1127#ifdef FIO_HAVE_IOPRIO
1128 {
1129 .name = "prio",
1130 .type = FIO_OPT_INT,
1131 .cb = str_prio_cb,
1132 .help = "Set job IO priority value",
1133 .minval = 0,
1134 .maxval = 7,
1135 },
1136 {
1137 .name = "prioclass",
1138 .type = FIO_OPT_INT,
1139 .cb = str_prioclass_cb,
1140 .help = "Set job IO priority class",
1141 .minval = 0,
1142 .maxval = 3,
1143 },
1144#endif
1145 {
1146 .name = "thinktime",
1147 .type = FIO_OPT_INT,
1148 .off1 = td_var_offset(thinktime),
1149 .help = "Idle time between IO buffers (usec)",
1150 .def = "0",
1151 },
1152 {
1153 .name = "thinktime_spin",
1154 .type = FIO_OPT_INT,
1155 .off1 = td_var_offset(thinktime_spin),
1156 .help = "Start think time by spinning this amount (usec)",
1157 .def = "0",
afdf9352 1158 .parent = "thinktime",
214e1eca
JA
1159 },
1160 {
1161 .name = "thinktime_blocks",
1162 .type = FIO_OPT_INT,
1163 .off1 = td_var_offset(thinktime_blocks),
1164 .help = "IO buffer period between 'thinktime'",
1165 .def = "1",
afdf9352 1166 .parent = "thinktime",
214e1eca
JA
1167 },
1168 {
1169 .name = "rate",
1170 .type = FIO_OPT_INT,
1171 .off1 = td_var_offset(rate),
1172 .help = "Set bandwidth rate",
1173 },
1174 {
1175 .name = "ratemin",
1176 .type = FIO_OPT_INT,
1177 .off1 = td_var_offset(ratemin),
4e991c23 1178 .help = "Job must meet this rate or it will be shutdown",
afdf9352 1179 .parent = "rate",
4e991c23
JA
1180 },
1181 {
1182 .name = "rate_iops",
1183 .type = FIO_OPT_INT,
1184 .off1 = td_var_offset(rate_iops),
1185 .help = "Limit IO used to this number of IO operations/sec",
1186 },
1187 {
1188 .name = "rate_iops_min",
1189 .type = FIO_OPT_INT,
1190 .off1 = td_var_offset(rate_iops_min),
1191 .help = "Job must meet this rate or it will be shutdown",
afdf9352 1192 .parent = "rate_iops",
214e1eca
JA
1193 },
1194 {
1195 .name = "ratecycle",
1196 .type = FIO_OPT_INT,
1197 .off1 = td_var_offset(ratecycle),
1198 .help = "Window average for rate limits (msec)",
1199 .def = "1000",
afdf9352 1200 .parent = "rate",
214e1eca
JA
1201 },
1202 {
1203 .name = "invalidate",
1204 .type = FIO_OPT_BOOL,
1205 .off1 = td_var_offset(invalidate_cache),
1206 .help = "Invalidate buffer/page cache prior to running job",
1207 .def = "1",
1208 },
1209 {
1210 .name = "sync",
1211 .type = FIO_OPT_BOOL,
1212 .off1 = td_var_offset(sync_io),
1213 .help = "Use O_SYNC for buffered writes",
1214 .def = "0",
67a1000f 1215 .parent = "buffered",
214e1eca
JA
1216 },
1217 {
1218 .name = "bwavgtime",
1219 .type = FIO_OPT_INT,
1220 .off1 = td_var_offset(bw_avg_time),
5ec10eaa
JA
1221 .help = "Time window over which to calculate bandwidth"
1222 " (msec)",
214e1eca
JA
1223 .def = "500",
1224 },
1225 {
1226 .name = "create_serialize",
1227 .type = FIO_OPT_BOOL,
1228 .off1 = td_var_offset(create_serialize),
1229 .help = "Serialize creating of job files",
1230 .def = "1",
1231 },
1232 {
1233 .name = "create_fsync",
1234 .type = FIO_OPT_BOOL,
1235 .off1 = td_var_offset(create_fsync),
1236 .help = "Fsync file after creation",
1237 .def = "1",
1238 },
1239 {
1240 .name = "cpuload",
1241 .type = FIO_OPT_INT,
1242 .off1 = td_var_offset(cpuload),
1243 .help = "Use this percentage of CPU",
1244 },
1245 {
1246 .name = "cpuchunks",
1247 .type = FIO_OPT_INT,
1248 .off1 = td_var_offset(cpucycle),
1249 .help = "Length of the CPU burn cycles (usecs)",
1250 .def = "50000",
67a1000f 1251 .parent = "cpuload",
214e1eca
JA
1252 },
1253#ifdef FIO_HAVE_CPU_AFFINITY
1254 {
1255 .name = "cpumask",
1256 .type = FIO_OPT_INT,
1257 .cb = str_cpumask_cb,
1258 .help = "CPU affinity mask",
1259 },
d2e268b0
JA
1260 {
1261 .name = "cpus_allowed",
1262 .type = FIO_OPT_STR,
1263 .cb = str_cpus_allowed_cb,
1264 .help = "Set CPUs allowed",
1265 },
214e1eca
JA
1266#endif
1267 {
1268 .name = "end_fsync",
1269 .type = FIO_OPT_BOOL,
1270 .off1 = td_var_offset(end_fsync),
1271 .help = "Include fsync at the end of job",
1272 .def = "0",
1273 },
1274 {
1275 .name = "fsync_on_close",
1276 .type = FIO_OPT_BOOL,
1277 .off1 = td_var_offset(fsync_on_close),
1278 .help = "fsync files on close",
1279 .def = "0",
1280 },
1281 {
1282 .name = "unlink",
1283 .type = FIO_OPT_BOOL,
1284 .off1 = td_var_offset(unlink),
1285 .help = "Unlink created files after job has completed",
1286 .def = "0",
1287 },
1288 {
1289 .name = "exitall",
1290 .type = FIO_OPT_STR_SET,
1291 .cb = str_exitall_cb,
1292 .help = "Terminate all jobs when one exits",
1293 },
1294 {
1295 .name = "stonewall",
1296 .type = FIO_OPT_STR_SET,
1297 .off1 = td_var_offset(stonewall),
1298 .help = "Insert a hard barrier between this job and previous",
1299 },
b3d62a75
JA
1300 {
1301 .name = "new_group",
1302 .type = FIO_OPT_STR_SET,
1303 .off1 = td_var_offset(new_group),
1304 .help = "Mark the start of a new group (for reporting)",
1305 },
214e1eca
JA
1306 {
1307 .name = "thread",
1308 .type = FIO_OPT_STR_SET,
1309 .off1 = td_var_offset(use_thread),
1310 .help = "Use threads instead of forks",
1311 },
1312 {
1313 .name = "write_bw_log",
e3cedca7 1314 .type = FIO_OPT_STR,
214e1eca 1315 .off1 = td_var_offset(write_bw_log),
e3cedca7 1316 .cb = str_write_bw_log_cb,
214e1eca
JA
1317 .help = "Write log of bandwidth during run",
1318 },
1319 {
1320 .name = "write_lat_log",
e3cedca7 1321 .type = FIO_OPT_STR,
214e1eca 1322 .off1 = td_var_offset(write_lat_log),
e3cedca7 1323 .cb = str_write_lat_log_cb,
214e1eca
JA
1324 .help = "Write log of latency during run",
1325 },
1326 {
1327 .name = "hugepage-size",
357f618e 1328 .type = FIO_OPT_STR_VAL_INT,
214e1eca
JA
1329 .off1 = td_var_offset(hugepage_size),
1330 .help = "When using hugepages, specify size of each page",
1331 .def = __stringify(FIO_HUGE_PAGE),
1332 },
1333 {
1334 .name = "group_reporting",
1335 .type = FIO_OPT_STR_SET,
1336 .off1 = td_var_offset(group_reporting),
1337 .help = "Do reporting on a per-group basis",
1338 },
e9459e5a
JA
1339 {
1340 .name = "zero_buffers",
1341 .type = FIO_OPT_STR_SET,
1342 .off1 = td_var_offset(zero_buffers),
1343 .help = "Init IO buffers to all zeroes",
1344 },
5973cafb
JA
1345 {
1346 .name = "refill_buffers",
1347 .type = FIO_OPT_STR_SET,
1348 .off1 = td_var_offset(refill_buffers),
1349 .help = "Refill IO buffers on every IO submit",
1350 },
0a839f30
JA
1351#ifdef FIO_HAVE_DISK_UTIL
1352 {
1353 .name = "disk_util",
1354 .type = FIO_OPT_BOOL,
1355 .off1 = td_var_offset(do_disk_util),
f66ab3c8 1356 .help = "Log disk utilization statistics",
0a839f30
JA
1357 .def = "1",
1358 },
1359#endif
993bf48b
JA
1360 {
1361 .name = "gtod_reduce",
1362 .type = FIO_OPT_BOOL,
1363 .help = "Greatly reduce number of gettimeofday() calls",
1364 .cb = str_gtod_reduce_cb,
1365 .def = "0",
1366 },
9520ebb9
JA
1367 {
1368 .name = "disable_clat",
1369 .type = FIO_OPT_BOOL,
1370 .off1 = td_var_offset(disable_clat),
1371 .help = "Disable completion latency numbers",
993bf48b 1372 .parent = "gtod_reduce",
9520ebb9
JA
1373 .def = "0",
1374 },
1375 {
1376 .name = "disable_slat",
1377 .type = FIO_OPT_BOOL,
1378 .off1 = td_var_offset(disable_slat),
1379 .help = "Disable submissionn latency numbers",
993bf48b 1380 .parent = "gtod_reduce",
9520ebb9
JA
1381 .def = "0",
1382 },
1383 {
1384 .name = "disable_bw_measurement",
1385 .type = FIO_OPT_BOOL,
1386 .off1 = td_var_offset(disable_bw),
1387 .help = "Disable bandwidth logging",
993bf48b 1388 .parent = "gtod_reduce",
9520ebb9
JA
1389 .def = "0",
1390 },
214e1eca
JA
1391 {
1392 .name = NULL,
1393 },
1394};
1395
1396void fio_options_dup_and_init(struct option *long_options)
1397{
1398 struct fio_option *o;
1399 unsigned int i;
1400
1401 options_init(options);
1402
1403 i = 0;
1404 while (long_options[i].name)
1405 i++;
1406
1407 o = &options[0];
1408 while (o->name) {
5921e80c 1409 long_options[i].name = (char *) o->name;
214e1eca
JA
1410 long_options[i].val = FIO_GETOPT_JOB;
1411 if (o->type == FIO_OPT_STR_SET)
1412 long_options[i].has_arg = no_argument;
1413 else
1414 long_options[i].has_arg = required_argument;
1415
1416 i++;
1417 o++;
1418 assert(i < FIO_NR_OPTIONS);
1419 }
1420}
1421
3b8b7135 1422int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
214e1eca 1423{
3b8b7135
JA
1424 int i, ret;
1425
1426 sort_options(opts, options, num_opts);
1427
1428 for (ret = 0, i = 0; i < num_opts; i++)
1429 ret |= parse_option(opts[i], options, td);
1430
1431 return ret;
214e1eca
JA
1432}
1433
1434int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
1435{
1436 return parse_cmd_option(opt, val, options, td);
1437}
1438
1439void fio_fill_default_options(struct thread_data *td)
1440{
1441 fill_default_options(td, options);
1442}
1443
1444int fio_show_option_help(const char *opt)
1445{
1446 return show_cmd_help(options, opt);
1447}
d23bb327
JA
1448
1449static void __options_mem(struct thread_data *td, int alloc)
1450{
1451 struct thread_options *o = &td->o;
1452 struct fio_option *opt;
1453 char **ptr;
1454 int i;
1455
1456 for (i = 0, opt = &options[0]; opt->name; i++, opt = &options[i]) {
1457 if (opt->type != FIO_OPT_STR_STORE)
1458 continue;
1459
1460 ptr = (void *) o + opt->off1;
1461 if (*ptr) {
1462 if (alloc)
1463 *ptr = strdup(*ptr);
1464 else {
1465 free(*ptr);
1466 *ptr = NULL;
1467 }
1468 }
1469 }
1470}
1471
1472/*
1473 * dupe FIO_OPT_STR_STORE options
1474 */
1475void options_mem_dupe(struct thread_data *td)
1476{
1477 __options_mem(td, 1);
1478}
1479
22d66213 1480void options_mem_free(struct thread_data fio_unused *td)
d23bb327 1481{
22d66213 1482#if 0
d23bb327 1483 __options_mem(td, 0);
22d66213 1484#endif
d23bb327 1485}