blob: bb77683d06c0cbba39cdfa7069f7d1b22d1b400a [file] [log] [blame]
Jens Axboe214e1ec2007-03-15 10:48:13 +01001#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>
8
9#include "fio.h"
10#include "parse.h"
Jens Axboe90059d62007-07-30 09:33:12 +020011#include "fls.h"
Jens Axboe214e1ec2007-03-15 10:48:13 +010012
Jens Axboe2dc1bbe2007-03-15 15:01:33 +010013#define td_var_offset(var) ((size_t) &((struct thread_options *)0)->var)
Jens Axboe214e1ec2007-03-15 10:48:13 +010014
15/*
16 * Check if mmap/mmaphuge has a :/foo/bar/file at the end. If so, return that.
17 */
18static char *get_opt_postfix(const char *str)
19{
20 char *p = strstr(str, ":");
21
22 if (!p)
23 return NULL;
24
25 p++;
26 strip_blank_front(&p);
27 strip_blank_end(p);
28 return strdup(p);
29}
30
Jens Axboe564ca972007-12-14 12:21:19 +010031static int bs_cmp(const void *p1, const void *p2)
32{
33 const struct bssplit *bsp1 = p1;
34 const struct bssplit *bsp2 = p2;
35
36 return bsp1->perc < bsp2->perc;
37}
38
39static int str_bssplit_cb(void *data, const char *input)
40{
41 struct thread_data *td = data;
42 char *fname, *str, *p;
43 unsigned int i, perc, perc_missing;
44 unsigned int max_bs, min_bs;
45 long long val;
46
47 p = str = strdup(input);
48
49 strip_blank_front(&str);
50 strip_blank_end(str);
51
52 td->o.bssplit_nr = 4;
53 td->o.bssplit = malloc(4 * sizeof(struct bssplit));
54
55 i = 0;
56 max_bs = 0;
57 min_bs = -1;
58 while ((fname = strsep(&str, ":")) != NULL) {
59 char *perc_str;
60
61 if (!strlen(fname))
62 break;
63
64 /*
65 * grow struct buffer, if needed
66 */
67 if (i == td->o.bssplit_nr) {
68 td->o.bssplit_nr <<= 1;
69 td->o.bssplit = realloc(td->o.bssplit, td->o.bssplit_nr * sizeof(struct bssplit));
70 }
71
72 perc_str = strstr(fname, "/");
73 if (perc_str) {
74 *perc_str = '\0';
75 perc_str++;
76 perc = atoi(perc_str);
77 if (perc > 100)
78 perc = 100;
79 else if (!perc)
80 perc = -1;
81 } else
82 perc = -1;
83
84 if (str_to_decimal(fname, &val, 1)) {
85 log_err("fio: bssplit conversion failed\n");
86 free(td->o.bssplit);
87 return 1;
88 }
89
90 if (val > max_bs)
91 max_bs = val;
92 if (val < min_bs)
93 min_bs = val;
94
95 td->o.bssplit[i].bs = val;
96 td->o.bssplit[i].perc = perc;
97 i++;
98 }
99
100 td->o.bssplit_nr = i;
101
102 /*
103 * Now check if the percentages add up, and how much is missing
104 */
105 perc = perc_missing = 0;
106 for (i = 0; i < td->o.bssplit_nr; i++) {
107 struct bssplit *bsp = &td->o.bssplit[i];
108
109 if (bsp->perc == (unsigned char) -1)
110 perc_missing++;
111 else
112 perc += bsp->perc;
113 }
114
115 if (perc > 100) {
116 log_err("fio: bssplit percentages add to more than 100%%\n");
117 free(td->o.bssplit);
118 return 1;
119 }
120 /*
121 * If values didn't have a percentage set, divide the remains between
122 * them.
123 */
124 if (perc_missing) {
125 for (i = 0; i < td->o.bssplit_nr; i++) {
126 struct bssplit *bsp = &td->o.bssplit[i];
127
128 if (bsp->perc == (unsigned char) -1)
129 bsp->perc = (100 - perc) / perc_missing;
130 }
131 }
132
133 td->o.min_bs[DDIR_READ] = td->o.min_bs[DDIR_WRITE] = min_bs;
134 td->o.max_bs[DDIR_READ] = td->o.max_bs[DDIR_WRITE] = max_bs;
135
136 /*
137 * now sort based on percentages, for ease of lookup
138 */
139 qsort(td->o.bssplit, td->o.bssplit_nr, sizeof(struct bssplit), bs_cmp);
140
141 free(p);
142 return 0;
143}
144
Jens Axboe211097b2007-03-22 18:56:45 +0100145static int str_rw_cb(void *data, const char *str)
146{
147 struct thread_data *td = data;
148 char *nr = get_opt_postfix(str);
149
Jens Axboefafdba32007-03-26 10:09:12 +0200150 td->o.ddir_nr = 1;
Jens Axboe211097b2007-03-22 18:56:45 +0100151 if (nr)
152 td->o.ddir_nr = atoi(nr);
153
Jens Axboe211097b2007-03-22 18:56:45 +0100154 return 0;
155}
156
Jens Axboe214e1ec2007-03-15 10:48:13 +0100157static int str_mem_cb(void *data, const char *mem)
158{
159 struct thread_data *td = data;
160
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100161 if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP) {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100162 td->mmapfile = get_opt_postfix(mem);
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100163 if (td->o.mem_type == MEM_MMAPHUGE && !td->mmapfile) {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100164 log_err("fio: mmaphuge:/path/to/file\n");
165 return 1;
166 }
167 }
168
169 return 0;
170}
171
172static int str_lockmem_cb(void fio_unused *data, unsigned long *val)
173{
174 mlock_size = *val;
175 return 0;
176}
177
178#ifdef FIO_HAVE_IOPRIO
179static int str_prioclass_cb(void *data, unsigned int *val)
180{
181 struct thread_data *td = data;
Jens Axboe6cefbe32007-04-18 12:46:56 +0200182 unsigned short mask;
183
184 /*
185 * mask off old class bits, str_prio_cb() may have set a default class
186 */
187 mask = (1 << IOPRIO_CLASS_SHIFT) - 1;
188 td->ioprio &= mask;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100189
190 td->ioprio |= *val << IOPRIO_CLASS_SHIFT;
Jens Axboeac684782007-11-08 08:29:07 +0100191 td->ioprio_set = 1;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100192 return 0;
193}
194
195static int str_prio_cb(void *data, unsigned int *val)
196{
197 struct thread_data *td = data;
198
199 td->ioprio |= *val;
Jens Axboe6cefbe32007-04-18 12:46:56 +0200200
201 /*
202 * If no class is set, assume BE
203 */
204 if ((td->ioprio >> IOPRIO_CLASS_SHIFT) == 0)
205 td->ioprio |= IOPRIO_CLASS_BE << IOPRIO_CLASS_SHIFT;
206
Jens Axboeac684782007-11-08 08:29:07 +0100207 td->ioprio_set = 1;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100208 return 0;
209}
210#endif
211
212static int str_exitall_cb(void)
213{
214 exitall_on_terminate = 1;
215 return 0;
216}
217
Jens Axboe214e1ec2007-03-15 10:48:13 +0100218#ifdef FIO_HAVE_CPU_AFFINITY
Jens Axboe214e1ec2007-03-15 10:48:13 +0100219static int str_cpumask_cb(void *data, unsigned int *val)
220{
221 struct thread_data *td = data;
Jens Axboed2e268b2007-06-15 10:33:49 +0200222 unsigned int i;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100223
Jens Axboed2e268b2007-06-15 10:33:49 +0200224 CPU_ZERO(&td->o.cpumask);
225
226 for (i = 0; i < sizeof(int) * 8; i++)
227 if ((1 << i) & *val)
228 CPU_SET(*val, &td->o.cpumask);
229
Jens Axboe375b2692007-05-22 09:13:02 +0200230 td->o.cpumask_set = 1;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100231 return 0;
232}
233
Jens Axboed2e268b2007-06-15 10:33:49 +0200234static int str_cpus_allowed_cb(void *data, const char *input)
235{
236 struct thread_data *td = data;
237 char *cpu, *str, *p;
238
239 CPU_ZERO(&td->o.cpumask);
240
241 p = str = strdup(input);
242
243 strip_blank_front(&str);
244 strip_blank_end(str);
245
246 while ((cpu = strsep(&str, ",")) != NULL) {
247 if (!strlen(cpu))
248 break;
249 CPU_SET(atoi(cpu), &td->o.cpumask);
250 }
251
252 free(p);
253 td->o.cpumask_set = 1;
Jens Axboed2e268b2007-06-15 10:33:49 +0200254 return 0;
255}
256#endif
257
Jens Axboe214e1ec2007-03-15 10:48:13 +0100258static int str_fst_cb(void *data, const char *str)
259{
260 struct thread_data *td = data;
261 char *nr = get_opt_postfix(str);
262
263 td->file_service_nr = 1;
264 if (nr)
265 td->file_service_nr = atoi(nr);
266
267 return 0;
268}
269
270static int str_filename_cb(void *data, const char *input)
271{
272 struct thread_data *td = data;
273 char *fname, *str, *p;
274
275 p = str = strdup(input);
276
277 strip_blank_front(&str);
278 strip_blank_end(str);
279
280 if (!td->files_index)
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100281 td->o.nr_files = 0;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100282
283 while ((fname = strsep(&str, ":")) != NULL) {
284 if (!strlen(fname))
285 break;
286 add_file(td, fname);
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100287 td->o.nr_files++;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100288 }
289
290 free(p);
291 return 0;
292}
293
294static int str_directory_cb(void *data, const char fio_unused *str)
295{
296 struct thread_data *td = data;
297 struct stat sb;
298
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100299 if (lstat(td->o.directory, &sb) < 0) {
300 log_err("fio: %s is not a directory\n", td->o.directory);
Jens Axboe214e1ec2007-03-15 10:48:13 +0100301 td_verror(td, errno, "lstat");
302 return 1;
303 }
304 if (!S_ISDIR(sb.st_mode)) {
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100305 log_err("fio: %s is not a directory\n", td->o.directory);
Jens Axboe214e1ec2007-03-15 10:48:13 +0100306 return 1;
307 }
308
309 return 0;
310}
311
312static int str_opendir_cb(void *data, const char fio_unused *str)
313{
314 struct thread_data *td = data;
315
316 if (!td->files_index)
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100317 td->o.nr_files = 0;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100318
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100319 return add_dir_files(td, td->o.opendir);
Jens Axboe214e1ec2007-03-15 10:48:13 +0100320}
321
Jens Axboea59e1702007-07-30 08:53:27 +0200322static int str_verify_offset_cb(void *data, unsigned int *off)
Shawn Lewis546a9142007-07-28 21:11:37 +0200323{
324 struct thread_data *td = data;
Jens Axboea59e1702007-07-30 08:53:27 +0200325
Shawn Lewis546a9142007-07-28 21:11:37 +0200326 if (*off && *off < sizeof(struct verify_header)) {
Jens Axboea59e1702007-07-30 08:53:27 +0200327 log_err("fio: verify_offset too small\n");
Shawn Lewis546a9142007-07-28 21:11:37 +0200328 return 1;
329 }
Jens Axboea59e1702007-07-30 08:53:27 +0200330
331 td->o.verify_offset = *off;
Shawn Lewis546a9142007-07-28 21:11:37 +0200332 return 0;
333}
334
Shawn Lewise28218f2008-01-16 11:01:33 +0100335static int str_verify_pattern_cb(void *data, unsigned int *off)
Jens Axboe90059d62007-07-30 09:33:12 +0200336{
337 struct thread_data *td = data;
Shawn Lewise28218f2008-01-16 11:01:33 +0100338 unsigned int msb;
Jens Axboe90059d62007-07-30 09:33:12 +0200339
Shawn Lewise28218f2008-01-16 11:01:33 +0100340 msb = fls(*off);
Jens Axboe90059d62007-07-30 09:33:12 +0200341 if (msb <= 8)
342 td->o.verify_pattern_bytes = 1;
343 else if (msb <= 16)
344 td->o.verify_pattern_bytes = 2;
345 else if (msb <= 24)
346 td->o.verify_pattern_bytes = 3;
347 else
348 td->o.verify_pattern_bytes = 4;
349
Shawn Lewise28218f2008-01-16 11:01:33 +0100350 td->o.verify_pattern = *off;
Jens Axboe90059d62007-07-30 09:33:12 +0200351 return 0;
352}
Jens Axboe214e1ec2007-03-15 10:48:13 +0100353
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100354static int str_lockfile_cb(void *data, const char *str)
355{
356 struct thread_data *td = data;
357 char *nr = get_opt_postfix(str);
358
359 td->o.lockfile_batch = 1;
360 if (nr)
361 td->o.lockfile_batch = atoi(nr);
362
363 return 0;
364}
365
Jens Axboe214e1ec2007-03-15 10:48:13 +0100366#define __stringify_1(x) #x
367#define __stringify(x) __stringify_1(x)
368
369/*
370 * Map of job/command line options
371 */
372static struct fio_option options[] = {
373 {
374 .name = "description",
375 .type = FIO_OPT_STR_STORE,
376 .off1 = td_var_offset(description),
377 .help = "Text job description",
378 },
379 {
380 .name = "name",
381 .type = FIO_OPT_STR_STORE,
382 .off1 = td_var_offset(name),
383 .help = "Name of this job",
384 },
385 {
386 .name = "directory",
387 .type = FIO_OPT_STR_STORE,
388 .off1 = td_var_offset(directory),
389 .cb = str_directory_cb,
390 .help = "Directory to store files in",
391 },
392 {
393 .name = "filename",
394 .type = FIO_OPT_STR_STORE,
395 .off1 = td_var_offset(filename),
396 .cb = str_filename_cb,
397 .help = "File(s) to use for the workload",
398 },
399 {
Jens Axboe29c13492008-03-01 19:25:20 +0100400 .name = "lockfile",
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100401 .type = FIO_OPT_STR,
402 .cb = str_lockfile_cb,
403 .off1 = td_var_offset(file_lock_mode),
Jens Axboe29c13492008-03-01 19:25:20 +0100404 .help = "Lock file when doing IO to it",
405 .parent = "filename",
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100406 .def = "none",
407 .posval = {
408 { .ival = "none",
409 .oval = FILE_LOCK_NONE,
410 .help = "No file locking",
411 },
412 { .ival = "exclusive",
413 .oval = FILE_LOCK_EXCLUSIVE,
414 .help = "Exclusive file lock",
415 },
416 {
417 .ival = "readwrite",
418 .oval = FILE_LOCK_READWRITE,
419 .help = "Read vs write lock",
420 },
421 },
Jens Axboe29c13492008-03-01 19:25:20 +0100422 },
423 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100424 .name = "opendir",
425 .type = FIO_OPT_STR_STORE,
426 .off1 = td_var_offset(opendir),
427 .cb = str_opendir_cb,
428 .help = "Recursively add files from this directory and down",
429 },
430 {
431 .name = "rw",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100432 .alias = "readwrite",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100433 .type = FIO_OPT_STR,
Jens Axboe211097b2007-03-22 18:56:45 +0100434 .cb = str_rw_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100435 .off1 = td_var_offset(td_ddir),
436 .help = "IO direction",
437 .def = "read",
438 .posval = {
439 { .ival = "read",
440 .oval = TD_DDIR_READ,
441 .help = "Sequential read",
442 },
443 { .ival = "write",
444 .oval = TD_DDIR_WRITE,
445 .help = "Sequential write",
446 },
447 { .ival = "randread",
448 .oval = TD_DDIR_RANDREAD,
449 .help = "Random read",
450 },
451 { .ival = "randwrite",
452 .oval = TD_DDIR_RANDWRITE,
453 .help = "Random write",
454 },
455 { .ival = "rw",
456 .oval = TD_DDIR_RW,
457 .help = "Sequential read and write mix",
458 },
459 { .ival = "randrw",
460 .oval = TD_DDIR_RANDRW,
461 .help = "Random read and write mix"
462 },
463 },
464 },
465 {
466 .name = "ioengine",
467 .type = FIO_OPT_STR_STORE,
468 .off1 = td_var_offset(ioengine),
469 .help = "IO engine to use",
470 .def = "sync",
471 .posval = {
472 { .ival = "sync",
473 .help = "Use read/write",
474 },
gurudas paia31041e2007-10-23 15:12:30 +0200475 { .ival = "psync",
476 .help = "Use pread/pwrite",
477 },
Jens Axboe1d2af022008-02-04 10:59:07 +0100478 { .ival = "vsync",
479 .help = "Use readv/writev",
480 },
Jens Axboe214e1ec2007-03-15 10:48:13 +0100481#ifdef FIO_HAVE_LIBAIO
482 { .ival = "libaio",
483 .help = "Linux native asynchronous IO",
484 },
485#endif
486#ifdef FIO_HAVE_POSIXAIO
487 { .ival = "posixaio",
488 .help = "POSIX asynchronous IO",
489 },
490#endif
491 { .ival = "mmap",
492 .help = "Memory mapped IO",
493 },
494#ifdef FIO_HAVE_SPLICE
495 { .ival = "splice",
496 .help = "splice/vmsplice based IO",
497 },
Jens Axboe9cce02e2007-06-22 15:42:21 +0200498 { .ival = "netsplice",
499 .help = "splice/vmsplice to/from the network",
500 },
Jens Axboe214e1ec2007-03-15 10:48:13 +0100501#endif
502#ifdef FIO_HAVE_SGIO
503 { .ival = "sg",
504 .help = "SCSI generic v3 IO",
505 },
506#endif
507 { .ival = "null",
508 .help = "Testing engine (no data transfer)",
509 },
510 { .ival = "net",
511 .help = "Network IO",
512 },
513#ifdef FIO_HAVE_SYSLET
514 { .ival = "syslet-rw",
515 .help = "syslet enabled async pread/pwrite IO",
516 },
517#endif
518 { .ival = "cpuio",
519 .help = "CPU cycler burner engine",
520 },
Jens Axboeb8c82a42007-03-21 08:48:26 +0100521#ifdef FIO_HAVE_GUASI
522 { .ival = "guasi",
523 .help = "GUASI IO engine",
524 },
525#endif
Jens Axboe214e1ec2007-03-15 10:48:13 +0100526 { .ival = "external",
527 .help = "Load external engine (append name)",
528 },
529 },
530 },
531 {
532 .name = "iodepth",
533 .type = FIO_OPT_INT,
534 .off1 = td_var_offset(iodepth),
535 .help = "Amount of IO buffers to keep in flight",
Jens Axboe757aff42007-12-12 19:42:13 +0100536 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100537 .def = "1",
538 },
539 {
540 .name = "iodepth_batch",
541 .type = FIO_OPT_INT,
542 .off1 = td_var_offset(iodepth_batch),
543 .help = "Number of IO to submit in one go",
Jens Axboeafdf9352007-07-31 16:14:34 +0200544 .parent = "iodepth",
Jens Axboea2e6f8a2008-01-18 10:28:11 +0100545 .minval = 1,
546 .def = "1",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100547 },
548 {
549 .name = "iodepth_low",
550 .type = FIO_OPT_INT,
551 .off1 = td_var_offset(iodepth_low),
552 .help = "Low water mark for queuing depth",
Jens Axboeafdf9352007-07-31 16:14:34 +0200553 .parent = "iodepth",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100554 },
555 {
556 .name = "size",
557 .type = FIO_OPT_STR_VAL,
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100558 .off1 = td_var_offset(size),
Jens Axboec3edbdb2007-07-20 14:25:31 +0200559 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100560 .help = "Total size of device or files",
561 },
562 {
Shawn Lewisaa31f1f2008-01-11 09:45:11 +0100563 .name = "fill_device",
564 .type = FIO_OPT_BOOL,
565 .off1 = td_var_offset(fill_device),
566 .help = "Write until an ENOSPC error occurs",
567 .def = "0",
568 },
569 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100570 .name = "filesize",
571 .type = FIO_OPT_STR_VAL,
572 .off1 = td_var_offset(file_size_low),
573 .off2 = td_var_offset(file_size_high),
Jens Axboec3edbdb2007-07-20 14:25:31 +0200574 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100575 .help = "Size of individual files",
576 },
577 {
Jens Axboe67a10002007-07-31 23:12:16 +0200578 .name = "offset",
579 .alias = "fileoffset",
580 .type = FIO_OPT_STR_VAL,
581 .off1 = td_var_offset(start_offset),
582 .help = "Start IO from this offset",
583 .def = "0",
584 },
585 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100586 .name = "bs",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100587 .alias = "blocksize",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100588 .type = FIO_OPT_STR_VAL_INT,
589 .off1 = td_var_offset(bs[DDIR_READ]),
590 .off2 = td_var_offset(bs[DDIR_WRITE]),
Jens Axboec3edbdb2007-07-20 14:25:31 +0200591 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100592 .help = "Block size unit",
593 .def = "4k",
Jens Axboe67a10002007-07-31 23:12:16 +0200594 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100595 },
596 {
597 .name = "bsrange",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100598 .alias = "blocksize_range",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100599 .type = FIO_OPT_RANGE,
600 .off1 = td_var_offset(min_bs[DDIR_READ]),
601 .off2 = td_var_offset(max_bs[DDIR_READ]),
602 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
603 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
Jens Axboec3edbdb2007-07-20 14:25:31 +0200604 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100605 .help = "Set block size range (in more detail than bs)",
Jens Axboe67a10002007-07-31 23:12:16 +0200606 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100607 },
608 {
Jens Axboe564ca972007-12-14 12:21:19 +0100609 .name = "bssplit",
610 .type = FIO_OPT_STR,
611 .cb = str_bssplit_cb,
612 .help = "Set a specific mix of block sizes",
613 .parent = "rw",
614 },
615 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100616 .name = "bs_unaligned",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100617 .alias = "blocksize_unaligned",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100618 .type = FIO_OPT_STR_SET,
619 .off1 = td_var_offset(bs_unaligned),
620 .help = "Don't sector align IO buffer sizes",
Jens Axboe67a10002007-07-31 23:12:16 +0200621 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100622 },
623 {
624 .name = "randrepeat",
625 .type = FIO_OPT_BOOL,
626 .off1 = td_var_offset(rand_repeatable),
627 .help = "Use repeatable random IO pattern",
628 .def = "1",
Jens Axboe67a10002007-07-31 23:12:16 +0200629 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100630 },
631 {
632 .name = "norandommap",
633 .type = FIO_OPT_STR_SET,
634 .off1 = td_var_offset(norandommap),
635 .help = "Accept potential duplicate random blocks",
Jens Axboe67a10002007-07-31 23:12:16 +0200636 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100637 },
638 {
639 .name = "nrfiles",
640 .type = FIO_OPT_INT,
641 .off1 = td_var_offset(nr_files),
642 .help = "Split job workload between this number of files",
643 .def = "1",
644 },
645 {
646 .name = "openfiles",
647 .type = FIO_OPT_INT,
648 .off1 = td_var_offset(open_files),
649 .help = "Number of files to keep open at the same time",
650 },
651 {
652 .name = "file_service_type",
653 .type = FIO_OPT_STR,
654 .cb = str_fst_cb,
655 .off1 = td_var_offset(file_service_type),
656 .help = "How to select which file to service next",
657 .def = "roundrobin",
658 .posval = {
659 { .ival = "random",
660 .oval = FIO_FSERVICE_RANDOM,
661 .help = "Choose a file at random",
662 },
663 { .ival = "roundrobin",
664 .oval = FIO_FSERVICE_RR,
665 .help = "Round robin select files",
666 },
667 },
Jens Axboe67a10002007-07-31 23:12:16 +0200668 .parent = "nrfiles",
669 },
670 {
671 .name = "fadvise_hint",
672 .type = FIO_OPT_BOOL,
673 .off1 = td_var_offset(fadvise_hint),
674 .help = "Use fadvise() to advise the kernel on IO pattern",
675 .def = "1",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100676 },
677 {
678 .name = "fsync",
679 .type = FIO_OPT_INT,
680 .off1 = td_var_offset(fsync_blocks),
681 .help = "Issue fsync for writes every given number of blocks",
682 .def = "0",
683 },
684 {
685 .name = "direct",
686 .type = FIO_OPT_BOOL,
687 .off1 = td_var_offset(odirect),
688 .help = "Use O_DIRECT IO (negates buffered)",
689 .def = "0",
690 },
691 {
692 .name = "buffered",
693 .type = FIO_OPT_BOOL,
694 .off1 = td_var_offset(odirect),
695 .neg = 1,
696 .help = "Use buffered IO (negates direct)",
697 .def = "1",
698 },
699 {
700 .name = "overwrite",
701 .type = FIO_OPT_BOOL,
702 .off1 = td_var_offset(overwrite),
703 .help = "When writing, set whether to overwrite current data",
704 .def = "0",
705 },
706 {
707 .name = "loops",
708 .type = FIO_OPT_INT,
709 .off1 = td_var_offset(loops),
710 .help = "Number of times to run the job",
711 .def = "1",
712 },
713 {
714 .name = "numjobs",
715 .type = FIO_OPT_INT,
716 .off1 = td_var_offset(numjobs),
717 .help = "Duplicate this job this many times",
718 .def = "1",
719 },
720 {
721 .name = "startdelay",
722 .type = FIO_OPT_INT,
723 .off1 = td_var_offset(start_delay),
724 .help = "Only start job when this period has passed",
725 .def = "0",
726 },
727 {
728 .name = "runtime",
729 .alias = "timeout",
730 .type = FIO_OPT_STR_VAL_TIME,
731 .off1 = td_var_offset(timeout),
732 .help = "Stop workload when this amount of time has passed",
733 .def = "0",
734 },
735 {
Jens Axboecf4464c2007-04-17 20:14:42 +0200736 .name = "time_based",
737 .type = FIO_OPT_STR_SET,
738 .off1 = td_var_offset(time_based),
739 .help = "Keep running until runtime/timeout is met",
740 },
741 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100742 .name = "mem",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100743 .alias = "iomem",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100744 .type = FIO_OPT_STR,
745 .cb = str_mem_cb,
746 .off1 = td_var_offset(mem_type),
747 .help = "Backing type for IO buffers",
748 .def = "malloc",
749 .posval = {
750 { .ival = "malloc",
751 .oval = MEM_MALLOC,
752 .help = "Use malloc(3) for IO buffers",
753 },
Jens Axboeb370e462007-03-19 10:51:49 +0100754 { .ival = "shm",
755 .oval = MEM_SHM,
756 .help = "Use shared memory segments for IO buffers",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100757 },
758#ifdef FIO_HAVE_HUGETLB
Jens Axboe37c8cdf2007-03-19 13:14:03 +0100759 { .ival = "shmhuge",
760 .oval = MEM_SHMHUGE,
761 .help = "Like shm, but use huge pages",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100762 },
763#endif
Jens Axboeb370e462007-03-19 10:51:49 +0100764 { .ival = "mmap",
765 .oval = MEM_MMAP,
766 .help = "Use mmap(2) (file or anon) for IO buffers",
767 },
Jens Axboe37c8cdf2007-03-19 13:14:03 +0100768#ifdef FIO_HAVE_HUGETLB
769 { .ival = "mmaphuge",
770 .oval = MEM_MMAPHUGE,
771 .help = "Like mmap, but use huge pages",
772 },
773#endif
Jens Axboe214e1ec2007-03-15 10:48:13 +0100774 },
775 },
776 {
777 .name = "verify",
778 .type = FIO_OPT_STR,
779 .off1 = td_var_offset(verify),
780 .help = "Verify data written",
781 .def = "0",
782 .posval = {
783 { .ival = "0",
784 .oval = VERIFY_NONE,
785 .help = "Don't do IO verification",
786 },
Jens Axboefcca4b52007-07-27 15:42:00 +0200787 { .ival = "md5",
788 .oval = VERIFY_MD5,
789 .help = "Use md5 checksums for verification",
790 },
Jens Axboed77a7af2007-07-27 15:35:06 +0200791 { .ival = "crc64",
792 .oval = VERIFY_CRC64,
793 .help = "Use crc64 checksums for verification",
794 },
Jens Axboe214e1ec2007-03-15 10:48:13 +0100795 { .ival = "crc32",
796 .oval = VERIFY_CRC32,
797 .help = "Use crc32 checksums for verification",
798 },
Jens Axboe969f7ed2007-07-27 09:07:17 +0200799 { .ival = "crc16",
800 .oval = VERIFY_CRC16,
801 .help = "Use crc16 checksums for verification",
802 },
Jens Axboe1e154bd2007-07-27 09:52:40 +0200803 { .ival = "crc7",
804 .oval = VERIFY_CRC7,
805 .help = "Use crc7 checksums for verification",
806 },
Jens Axboecd14cc12007-07-30 10:59:33 +0200807 { .ival = "sha256",
808 .oval = VERIFY_SHA256,
809 .help = "Use sha256 checksums for verification",
810 },
811 { .ival = "sha512",
812 .oval = VERIFY_SHA512,
813 .help = "Use sha512 checksums for verification",
814 },
Shawn Lewis7437ee82007-08-02 21:05:58 +0200815 { .ival = "meta",
816 .oval = VERIFY_META,
817 .help = "Use io information",
818 },
Jens Axboe36690c92007-03-26 10:23:34 +0200819 {
820 .ival = "null",
821 .oval = VERIFY_NULL,
822 .help = "Pretend to verify",
823 },
Jens Axboe214e1ec2007-03-15 10:48:13 +0100824 },
825 },
826 {
Jens Axboe005c5652007-08-02 22:21:36 +0200827 .name = "do_verify",
Jens Axboe68e1f292007-08-10 10:32:14 +0200828 .type = FIO_OPT_BOOL,
Jens Axboe005c5652007-08-02 22:21:36 +0200829 .off1 = td_var_offset(do_verify),
830 .help = "Run verification stage after write",
831 .def = "1",
832 .parent = "verify",
833 },
834 {
Jens Axboe160b9662007-03-27 10:59:49 +0200835 .name = "verifysort",
836 .type = FIO_OPT_BOOL,
837 .off1 = td_var_offset(verifysort),
838 .help = "Sort written verify blocks for read back",
839 .def = "1",
Jens Axboec83f2df2007-07-31 22:51:47 +0200840 .parent = "verify",
Jens Axboe160b9662007-03-27 10:59:49 +0200841 },
842 {
Jens Axboea59e1702007-07-30 08:53:27 +0200843 .name = "verify_interval",
Shawn Lewis3f9f4e22007-07-28 21:10:37 +0200844 .type = FIO_OPT_STR_VAL_INT,
Jens Axboea59e1702007-07-30 08:53:27 +0200845 .off1 = td_var_offset(verify_interval),
Jens Axboe819a9682007-07-28 21:30:31 +0200846 .minval = 2 * sizeof(struct verify_header),
Jens Axboea59e1702007-07-30 08:53:27 +0200847 .help = "Store verify buffer header every N bytes",
Jens Axboeafdf9352007-07-31 16:14:34 +0200848 .parent = "verify",
Shawn Lewis3f9f4e22007-07-28 21:10:37 +0200849 },
850 {
Jens Axboea59e1702007-07-30 08:53:27 +0200851 .name = "verify_offset",
Shawn Lewis546a9142007-07-28 21:11:37 +0200852 .type = FIO_OPT_STR_VAL_INT,
Jens Axboea59e1702007-07-30 08:53:27 +0200853 .help = "Offset verify header location by N bytes",
Shawn Lewis546a9142007-07-28 21:11:37 +0200854 .def = "0",
Jens Axboea59e1702007-07-30 08:53:27 +0200855 .cb = str_verify_offset_cb,
Jens Axboeafdf9352007-07-31 16:14:34 +0200856 .parent = "verify",
Shawn Lewis546a9142007-07-28 21:11:37 +0200857 },
858 {
Shawn Lewise28218f2008-01-16 11:01:33 +0100859 .name = "verify_pattern",
860 .type = FIO_OPT_INT,
861 .cb = str_verify_pattern_cb,
862 .help = "Fill pattern for IO buffers",
863 .parent = "verify",
864 },
865 {
Jens Axboea12a3b42007-08-09 10:20:54 +0200866 .name = "verify_fatal",
Jens Axboe68e1f292007-08-10 10:32:14 +0200867 .type = FIO_OPT_BOOL,
Jens Axboea12a3b42007-08-09 10:20:54 +0200868 .off1 = td_var_offset(verify_fatal),
869 .def = "0",
870 .help = "Exit on a single verify failure, don't continue",
871 .parent = "verify",
872 },
873 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100874 .name = "write_iolog",
875 .type = FIO_OPT_STR_STORE,
876 .off1 = td_var_offset(write_iolog_file),
877 .help = "Store IO pattern to file",
878 },
879 {
880 .name = "read_iolog",
881 .type = FIO_OPT_STR_STORE,
882 .off1 = td_var_offset(read_iolog_file),
883 .help = "Playback IO pattern from file",
884 },
885 {
886 .name = "exec_prerun",
887 .type = FIO_OPT_STR_STORE,
888 .off1 = td_var_offset(exec_prerun),
889 .help = "Execute this file prior to running job",
890 },
891 {
892 .name = "exec_postrun",
893 .type = FIO_OPT_STR_STORE,
894 .off1 = td_var_offset(exec_postrun),
895 .help = "Execute this file after running job",
896 },
897#ifdef FIO_HAVE_IOSCHED_SWITCH
898 {
899 .name = "ioscheduler",
900 .type = FIO_OPT_STR_STORE,
901 .off1 = td_var_offset(ioscheduler),
902 .help = "Use this IO scheduler on the backing device",
903 },
904#endif
905 {
906 .name = "zonesize",
907 .type = FIO_OPT_STR_VAL,
908 .off1 = td_var_offset(zone_size),
909 .help = "Give size of an IO zone",
910 .def = "0",
911 },
912 {
913 .name = "zoneskip",
914 .type = FIO_OPT_STR_VAL,
915 .off1 = td_var_offset(zone_skip),
916 .help = "Space between IO zones",
917 .def = "0",
918 },
919 {
920 .name = "lockmem",
921 .type = FIO_OPT_STR_VAL,
922 .cb = str_lockmem_cb,
923 .help = "Lock down this amount of memory",
924 .def = "0",
925 },
926 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100927 .name = "rwmixread",
928 .type = FIO_OPT_INT,
Jens Axboee47f7992007-03-21 14:05:39 +0100929 .off1 = td_var_offset(rwmix[DDIR_READ]),
Jens Axboe214e1ec2007-03-15 10:48:13 +0100930 .maxval = 100,
931 .help = "Percentage of mixed workload that is reads",
932 .def = "50",
933 },
934 {
935 .name = "rwmixwrite",
936 .type = FIO_OPT_INT,
Jens Axboee47f7992007-03-21 14:05:39 +0100937 .off1 = td_var_offset(rwmix[DDIR_WRITE]),
Jens Axboe214e1ec2007-03-15 10:48:13 +0100938 .maxval = 100,
939 .help = "Percentage of mixed workload that is writes",
940 .def = "50",
941 },
942 {
Jens Axboeafdf9352007-07-31 16:14:34 +0200943 .name = "rwmixcycle",
944 .type = FIO_OPT_INT,
945 .off1 = td_var_offset(rwmixcycle),
946 .help = "Cycle period for mixed read/write workloads (msec)",
947 .def = "500",
948 .parent = "rwmixread",
949 },
950 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100951 .name = "nice",
952 .type = FIO_OPT_INT,
953 .off1 = td_var_offset(nice),
954 .help = "Set job CPU nice value",
955 .minval = -19,
956 .maxval = 20,
957 .def = "0",
958 },
959#ifdef FIO_HAVE_IOPRIO
960 {
961 .name = "prio",
962 .type = FIO_OPT_INT,
963 .cb = str_prio_cb,
964 .help = "Set job IO priority value",
965 .minval = 0,
966 .maxval = 7,
967 },
968 {
969 .name = "prioclass",
970 .type = FIO_OPT_INT,
971 .cb = str_prioclass_cb,
972 .help = "Set job IO priority class",
973 .minval = 0,
974 .maxval = 3,
975 },
976#endif
977 {
978 .name = "thinktime",
979 .type = FIO_OPT_INT,
980 .off1 = td_var_offset(thinktime),
981 .help = "Idle time between IO buffers (usec)",
982 .def = "0",
983 },
984 {
985 .name = "thinktime_spin",
986 .type = FIO_OPT_INT,
987 .off1 = td_var_offset(thinktime_spin),
988 .help = "Start think time by spinning this amount (usec)",
989 .def = "0",
Jens Axboeafdf9352007-07-31 16:14:34 +0200990 .parent = "thinktime",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100991 },
992 {
993 .name = "thinktime_blocks",
994 .type = FIO_OPT_INT,
995 .off1 = td_var_offset(thinktime_blocks),
996 .help = "IO buffer period between 'thinktime'",
997 .def = "1",
Jens Axboeafdf9352007-07-31 16:14:34 +0200998 .parent = "thinktime",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100999 },
1000 {
1001 .name = "rate",
1002 .type = FIO_OPT_INT,
1003 .off1 = td_var_offset(rate),
1004 .help = "Set bandwidth rate",
1005 },
1006 {
1007 .name = "ratemin",
1008 .type = FIO_OPT_INT,
1009 .off1 = td_var_offset(ratemin),
Jens Axboe4e991c22007-03-15 11:41:11 +01001010 .help = "Job must meet this rate or it will be shutdown",
Jens Axboeafdf9352007-07-31 16:14:34 +02001011 .parent = "rate",
Jens Axboe4e991c22007-03-15 11:41:11 +01001012 },
1013 {
1014 .name = "rate_iops",
1015 .type = FIO_OPT_INT,
1016 .off1 = td_var_offset(rate_iops),
1017 .help = "Limit IO used to this number of IO operations/sec",
1018 },
1019 {
1020 .name = "rate_iops_min",
1021 .type = FIO_OPT_INT,
1022 .off1 = td_var_offset(rate_iops_min),
1023 .help = "Job must meet this rate or it will be shutdown",
Jens Axboeafdf9352007-07-31 16:14:34 +02001024 .parent = "rate_iops",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001025 },
1026 {
1027 .name = "ratecycle",
1028 .type = FIO_OPT_INT,
1029 .off1 = td_var_offset(ratecycle),
1030 .help = "Window average for rate limits (msec)",
1031 .def = "1000",
Jens Axboeafdf9352007-07-31 16:14:34 +02001032 .parent = "rate",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001033 },
1034 {
1035 .name = "invalidate",
1036 .type = FIO_OPT_BOOL,
1037 .off1 = td_var_offset(invalidate_cache),
1038 .help = "Invalidate buffer/page cache prior to running job",
1039 .def = "1",
1040 },
1041 {
1042 .name = "sync",
1043 .type = FIO_OPT_BOOL,
1044 .off1 = td_var_offset(sync_io),
1045 .help = "Use O_SYNC for buffered writes",
1046 .def = "0",
Jens Axboe67a10002007-07-31 23:12:16 +02001047 .parent = "buffered",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001048 },
1049 {
1050 .name = "bwavgtime",
1051 .type = FIO_OPT_INT,
1052 .off1 = td_var_offset(bw_avg_time),
1053 .help = "Time window over which to calculate bandwidth (msec)",
1054 .def = "500",
1055 },
1056 {
1057 .name = "create_serialize",
1058 .type = FIO_OPT_BOOL,
1059 .off1 = td_var_offset(create_serialize),
1060 .help = "Serialize creating of job files",
1061 .def = "1",
1062 },
1063 {
1064 .name = "create_fsync",
1065 .type = FIO_OPT_BOOL,
1066 .off1 = td_var_offset(create_fsync),
1067 .help = "Fsync file after creation",
1068 .def = "1",
1069 },
1070 {
1071 .name = "cpuload",
1072 .type = FIO_OPT_INT,
1073 .off1 = td_var_offset(cpuload),
1074 .help = "Use this percentage of CPU",
1075 },
1076 {
1077 .name = "cpuchunks",
1078 .type = FIO_OPT_INT,
1079 .off1 = td_var_offset(cpucycle),
1080 .help = "Length of the CPU burn cycles (usecs)",
1081 .def = "50000",
Jens Axboe67a10002007-07-31 23:12:16 +02001082 .parent = "cpuload",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001083 },
1084#ifdef FIO_HAVE_CPU_AFFINITY
1085 {
1086 .name = "cpumask",
1087 .type = FIO_OPT_INT,
1088 .cb = str_cpumask_cb,
1089 .help = "CPU affinity mask",
1090 },
Jens Axboed2e268b2007-06-15 10:33:49 +02001091 {
1092 .name = "cpus_allowed",
1093 .type = FIO_OPT_STR,
1094 .cb = str_cpus_allowed_cb,
1095 .help = "Set CPUs allowed",
1096 },
Jens Axboe214e1ec2007-03-15 10:48:13 +01001097#endif
1098 {
1099 .name = "end_fsync",
1100 .type = FIO_OPT_BOOL,
1101 .off1 = td_var_offset(end_fsync),
1102 .help = "Include fsync at the end of job",
1103 .def = "0",
1104 },
1105 {
1106 .name = "fsync_on_close",
1107 .type = FIO_OPT_BOOL,
1108 .off1 = td_var_offset(fsync_on_close),
1109 .help = "fsync files on close",
1110 .def = "0",
1111 },
1112 {
1113 .name = "unlink",
1114 .type = FIO_OPT_BOOL,
1115 .off1 = td_var_offset(unlink),
1116 .help = "Unlink created files after job has completed",
1117 .def = "0",
1118 },
1119 {
1120 .name = "exitall",
1121 .type = FIO_OPT_STR_SET,
1122 .cb = str_exitall_cb,
1123 .help = "Terminate all jobs when one exits",
1124 },
1125 {
1126 .name = "stonewall",
1127 .type = FIO_OPT_STR_SET,
1128 .off1 = td_var_offset(stonewall),
1129 .help = "Insert a hard barrier between this job and previous",
1130 },
1131 {
Jens Axboeb3d62a72007-03-20 14:23:26 +01001132 .name = "new_group",
1133 .type = FIO_OPT_STR_SET,
1134 .off1 = td_var_offset(new_group),
1135 .help = "Mark the start of a new group (for reporting)",
1136 },
1137 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001138 .name = "thread",
1139 .type = FIO_OPT_STR_SET,
1140 .off1 = td_var_offset(use_thread),
1141 .help = "Use threads instead of forks",
1142 },
1143 {
1144 .name = "write_bw_log",
1145 .type = FIO_OPT_STR_SET,
1146 .off1 = td_var_offset(write_bw_log),
1147 .help = "Write log of bandwidth during run",
1148 },
1149 {
1150 .name = "write_lat_log",
1151 .type = FIO_OPT_STR_SET,
1152 .off1 = td_var_offset(write_lat_log),
1153 .help = "Write log of latency during run",
1154 },
1155 {
1156 .name = "hugepage-size",
Aaron Carroll357f6182008-02-20 09:14:13 +01001157 .type = FIO_OPT_STR_VAL_INT,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001158 .off1 = td_var_offset(hugepage_size),
1159 .help = "When using hugepages, specify size of each page",
1160 .def = __stringify(FIO_HUGE_PAGE),
1161 },
1162 {
1163 .name = "group_reporting",
1164 .type = FIO_OPT_STR_SET,
1165 .off1 = td_var_offset(group_reporting),
1166 .help = "Do reporting on a per-group basis",
1167 },
1168 {
Jens Axboee9459e52007-04-17 15:46:32 +02001169 .name = "zero_buffers",
1170 .type = FIO_OPT_STR_SET,
1171 .off1 = td_var_offset(zero_buffers),
1172 .help = "Init IO buffers to all zeroes",
1173 },
Jens Axboe0a839f32007-04-26 09:02:34 +02001174#ifdef FIO_HAVE_DISK_UTIL
1175 {
1176 .name = "disk_util",
1177 .type = FIO_OPT_BOOL,
1178 .off1 = td_var_offset(do_disk_util),
1179 .help = "Log disk utilization stats",
1180 .def = "1",
1181 },
1182#endif
Jens Axboee9459e52007-04-17 15:46:32 +02001183 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001184 .name = NULL,
1185 },
1186};
1187
1188void fio_options_dup_and_init(struct option *long_options)
1189{
1190 struct fio_option *o;
1191 unsigned int i;
1192
1193 options_init(options);
1194
1195 i = 0;
1196 while (long_options[i].name)
1197 i++;
1198
1199 o = &options[0];
1200 while (o->name) {
1201 long_options[i].name = o->name;
1202 long_options[i].val = FIO_GETOPT_JOB;
1203 if (o->type == FIO_OPT_STR_SET)
1204 long_options[i].has_arg = no_argument;
1205 else
1206 long_options[i].has_arg = required_argument;
1207
1208 i++;
1209 o++;
1210 assert(i < FIO_NR_OPTIONS);
1211 }
1212}
1213
1214int fio_option_parse(struct thread_data *td, const char *opt)
1215{
1216 return parse_option(opt, options, td);
1217}
1218
1219int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
1220{
1221 return parse_cmd_option(opt, val, options, td);
1222}
1223
1224void fio_fill_default_options(struct thread_data *td)
1225{
1226 fill_default_options(td, options);
1227}
1228
1229int fio_show_option_help(const char *opt)
1230{
1231 return show_cmd_help(options, opt);
1232}
Jens Axboed23bb322007-03-23 15:57:56 +01001233
1234static void __options_mem(struct thread_data *td, int alloc)
1235{
1236 struct thread_options *o = &td->o;
1237 struct fio_option *opt;
1238 char **ptr;
1239 int i;
1240
1241 for (i = 0, opt = &options[0]; opt->name; i++, opt = &options[i]) {
1242 if (opt->type != FIO_OPT_STR_STORE)
1243 continue;
1244
1245 ptr = (void *) o + opt->off1;
1246 if (*ptr) {
1247 if (alloc)
1248 *ptr = strdup(*ptr);
1249 else {
1250 free(*ptr);
1251 *ptr = NULL;
1252 }
1253 }
1254 }
1255}
1256
1257/*
1258 * dupe FIO_OPT_STR_STORE options
1259 */
1260void options_mem_dupe(struct thread_data *td)
1261{
1262 __options_mem(td, 1);
1263}
1264
Jens Axboe22d66212007-03-27 20:06:25 +02001265void options_mem_free(struct thread_data fio_unused *td)
Jens Axboed23bb322007-03-23 15:57:56 +01001266{
Jens Axboe22d66212007-03-27 20:06:25 +02001267#if 0
Jens Axboed23bb322007-03-23 15:57:56 +01001268 __options_mem(td, 0);
Jens Axboe22d66212007-03-27 20:06:25 +02001269#endif
Jens Axboed23bb322007-03-23 15:57:56 +01001270}