blob: a7225eab37c38b37408d1b74b5ec80adb8d7361f [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>
Jens Axboe921c7662008-03-26 09:17:55 +01008#include <libgen.h>
Jens Axboe5921e802008-05-30 15:02:38 +02009#include <fcntl.h>
10#include <sys/types.h>
11#include <sys/stat.h>
Jens Axboe214e1ec2007-03-15 10:48:13 +010012
13#include "fio.h"
14#include "parse.h"
Jens Axboeeef32352008-06-02 13:31:26 +020015#include "lib/fls.h"
Jens Axboe214e1ec2007-03-15 10:48:13 +010016
Jens Axboe2dc1bbe2007-03-15 15:01:33 +010017#define td_var_offset(var) ((size_t) &((struct thread_options *)0)->var)
Jens Axboe214e1ec2007-03-15 10:48:13 +010018
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
Jens Axboe564ca972007-12-14 12:21:19 +010035static 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;
Jens Axboe5ec10ea2008-03-06 15:42:00 +010073 td->o.bssplit = realloc(td->o.bssplit,
74 td->o.bssplit_nr
75 * sizeof(struct bssplit));
Jens Axboe564ca972007-12-14 12:21:19 +010076 }
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
Jens Axboe211097b2007-03-22 18:56:45 +0100151static int str_rw_cb(void *data, const char *str)
152{
153 struct thread_data *td = data;
154 char *nr = get_opt_postfix(str);
155
Jens Axboefafdba32007-03-26 10:09:12 +0200156 td->o.ddir_nr = 1;
Jens Axboe211097b2007-03-22 18:56:45 +0100157 if (nr)
158 td->o.ddir_nr = atoi(nr);
159
Jens Axboe211097b2007-03-22 18:56:45 +0100160 return 0;
161}
162
Jens Axboe214e1ec2007-03-15 10:48:13 +0100163static int str_mem_cb(void *data, const char *mem)
164{
165 struct thread_data *td = data;
166
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100167 if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP) {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100168 td->mmapfile = get_opt_postfix(mem);
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100169 if (td->o.mem_type == MEM_MMAPHUGE && !td->mmapfile) {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100170 log_err("fio: mmaphuge:/path/to/file\n");
171 return 1;
172 }
173 }
174
175 return 0;
176}
177
178static int str_lockmem_cb(void fio_unused *data, unsigned long *val)
179{
180 mlock_size = *val;
181 return 0;
182}
183
Jens Axboecb499fc2008-05-28 10:33:32 +0200184static int str_rwmix_read_cb(void *data, unsigned int *val)
185{
186 struct thread_data *td = data;
187
188 td->o.rwmix[DDIR_READ] = *val;
189 td->o.rwmix[DDIR_WRITE] = 100 - *val;
190 return 0;
191}
192
193static int str_rwmix_write_cb(void *data, unsigned int *val)
194{
195 struct thread_data *td = data;
196
197 td->o.rwmix[DDIR_WRITE] = *val;
198 td->o.rwmix[DDIR_READ] = 100 - *val;
199 return 0;
200}
201
Jens Axboe214e1ec2007-03-15 10:48:13 +0100202#ifdef FIO_HAVE_IOPRIO
203static int str_prioclass_cb(void *data, unsigned int *val)
204{
205 struct thread_data *td = data;
Jens Axboe6cefbe32007-04-18 12:46:56 +0200206 unsigned short mask;
207
208 /*
209 * mask off old class bits, str_prio_cb() may have set a default class
210 */
211 mask = (1 << IOPRIO_CLASS_SHIFT) - 1;
212 td->ioprio &= mask;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100213
214 td->ioprio |= *val << IOPRIO_CLASS_SHIFT;
Jens Axboeac684782007-11-08 08:29:07 +0100215 td->ioprio_set = 1;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100216 return 0;
217}
218
219static int str_prio_cb(void *data, unsigned int *val)
220{
221 struct thread_data *td = data;
222
223 td->ioprio |= *val;
Jens Axboe6cefbe32007-04-18 12:46:56 +0200224
225 /*
226 * If no class is set, assume BE
227 */
228 if ((td->ioprio >> IOPRIO_CLASS_SHIFT) == 0)
229 td->ioprio |= IOPRIO_CLASS_BE << IOPRIO_CLASS_SHIFT;
230
Jens Axboeac684782007-11-08 08:29:07 +0100231 td->ioprio_set = 1;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100232 return 0;
233}
234#endif
235
236static int str_exitall_cb(void)
237{
238 exitall_on_terminate = 1;
239 return 0;
240}
241
Jens Axboe214e1ec2007-03-15 10:48:13 +0100242#ifdef FIO_HAVE_CPU_AFFINITY
Jens Axboe214e1ec2007-03-15 10:48:13 +0100243static int str_cpumask_cb(void *data, unsigned int *val)
244{
245 struct thread_data *td = data;
Jens Axboed2e268b2007-06-15 10:33:49 +0200246 unsigned int i;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100247
Jens Axboed2e268b2007-06-15 10:33:49 +0200248 CPU_ZERO(&td->o.cpumask);
249
250 for (i = 0; i < sizeof(int) * 8; i++)
251 if ((1 << i) & *val)
252 CPU_SET(*val, &td->o.cpumask);
253
Jens Axboe375b2692007-05-22 09:13:02 +0200254 td->o.cpumask_set = 1;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100255 return 0;
256}
257
Jens Axboed2e268b2007-06-15 10:33:49 +0200258static int str_cpus_allowed_cb(void *data, const char *input)
259{
260 struct thread_data *td = data;
261 char *cpu, *str, *p;
262
263 CPU_ZERO(&td->o.cpumask);
264
265 p = str = strdup(input);
266
267 strip_blank_front(&str);
268 strip_blank_end(str);
269
270 while ((cpu = strsep(&str, ",")) != NULL) {
271 if (!strlen(cpu))
272 break;
273 CPU_SET(atoi(cpu), &td->o.cpumask);
274 }
275
276 free(p);
277 td->o.cpumask_set = 1;
Jens Axboed2e268b2007-06-15 10:33:49 +0200278 return 0;
279}
280#endif
281
Jens Axboe214e1ec2007-03-15 10:48:13 +0100282static int str_fst_cb(void *data, const char *str)
283{
284 struct thread_data *td = data;
285 char *nr = get_opt_postfix(str);
286
287 td->file_service_nr = 1;
288 if (nr)
289 td->file_service_nr = atoi(nr);
290
291 return 0;
292}
293
Jens Axboe921c7662008-03-26 09:17:55 +0100294static int check_dir(struct thread_data *td, char *fname)
295{
296 char file[PATH_MAX], *dir;
Jens Axboebc838912008-04-07 09:00:54 +0200297 int elen = 0;
Jens Axboe921c7662008-03-26 09:17:55 +0100298
Jens Axboebc838912008-04-07 09:00:54 +0200299 if (td->o.directory) {
300 strcpy(file, td->o.directory);
Jens Axboefcef0b32008-05-26 14:53:24 +0200301 strcat(file, "/");
Jens Axboebc838912008-04-07 09:00:54 +0200302 elen = strlen(file);
303 }
304
Jens Axboefcef0b32008-05-26 14:53:24 +0200305 sprintf(file + elen, "%s", fname);
Jens Axboe921c7662008-03-26 09:17:55 +0100306 dir = dirname(file);
307
Jens Axboefcef0b32008-05-26 14:53:24 +0200308#if 0
309 {
310 struct stat sb;
311 /*
312 * We can't do this on FIO_DISKLESSIO engines. The engine isn't loaded
313 * yet, so we can't do this check right here...
314 */
Jens Axboe921c7662008-03-26 09:17:55 +0100315 if (lstat(dir, &sb) < 0) {
316 int ret = errno;
317
318 log_err("fio: %s is not a directory\n", dir);
319 td_verror(td, ret, "lstat");
320 return 1;
321 }
322
323 if (!S_ISDIR(sb.st_mode)) {
324 log_err("fio: %s is not a directory\n", dir);
325 return 1;
326 }
Jens Axboefcef0b32008-05-26 14:53:24 +0200327 }
328#endif
Jens Axboe921c7662008-03-26 09:17:55 +0100329
330 return 0;
331}
332
Jens Axboe214e1ec2007-03-15 10:48:13 +0100333static int str_filename_cb(void *data, const char *input)
334{
335 struct thread_data *td = data;
336 char *fname, *str, *p;
337
338 p = str = strdup(input);
339
340 strip_blank_front(&str);
341 strip_blank_end(str);
342
343 if (!td->files_index)
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100344 td->o.nr_files = 0;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100345
346 while ((fname = strsep(&str, ":")) != NULL) {
347 if (!strlen(fname))
348 break;
Jens Axboe921c7662008-03-26 09:17:55 +0100349 if (check_dir(td, fname)) {
350 free(p);
351 return 1;
352 }
Jens Axboe214e1ec2007-03-15 10:48:13 +0100353 add_file(td, fname);
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100354 td->o.nr_files++;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100355 }
356
357 free(p);
358 return 0;
359}
360
361static int str_directory_cb(void *data, const char fio_unused *str)
362{
363 struct thread_data *td = data;
364 struct stat sb;
365
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100366 if (lstat(td->o.directory, &sb) < 0) {
Jens Axboe921c7662008-03-26 09:17:55 +0100367 int ret = errno;
368
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100369 log_err("fio: %s is not a directory\n", td->o.directory);
Jens Axboe921c7662008-03-26 09:17:55 +0100370 td_verror(td, ret, "lstat");
Jens Axboe214e1ec2007-03-15 10:48:13 +0100371 return 1;
372 }
373 if (!S_ISDIR(sb.st_mode)) {
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100374 log_err("fio: %s is not a directory\n", td->o.directory);
Jens Axboe214e1ec2007-03-15 10:48:13 +0100375 return 1;
376 }
377
378 return 0;
379}
380
381static int str_opendir_cb(void *data, const char fio_unused *str)
382{
383 struct thread_data *td = data;
384
385 if (!td->files_index)
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100386 td->o.nr_files = 0;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100387
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100388 return add_dir_files(td, td->o.opendir);
Jens Axboe214e1ec2007-03-15 10:48:13 +0100389}
390
Jens Axboea59e1702007-07-30 08:53:27 +0200391static int str_verify_offset_cb(void *data, unsigned int *off)
Shawn Lewis546a9142007-07-28 21:11:37 +0200392{
393 struct thread_data *td = data;
Jens Axboea59e1702007-07-30 08:53:27 +0200394
Shawn Lewis546a9142007-07-28 21:11:37 +0200395 if (*off && *off < sizeof(struct verify_header)) {
Jens Axboea59e1702007-07-30 08:53:27 +0200396 log_err("fio: verify_offset too small\n");
Shawn Lewis546a9142007-07-28 21:11:37 +0200397 return 1;
398 }
Jens Axboea59e1702007-07-30 08:53:27 +0200399
400 td->o.verify_offset = *off;
Shawn Lewis546a9142007-07-28 21:11:37 +0200401 return 0;
402}
403
Shawn Lewise28218f2008-01-16 11:01:33 +0100404static int str_verify_pattern_cb(void *data, unsigned int *off)
Jens Axboe90059d62007-07-30 09:33:12 +0200405{
406 struct thread_data *td = data;
Shawn Lewise28218f2008-01-16 11:01:33 +0100407 unsigned int msb;
Jens Axboe90059d62007-07-30 09:33:12 +0200408
Jens Axboe3c48c2c2008-06-02 12:22:30 +0200409 msb = __fls(*off);
Jens Axboe90059d62007-07-30 09:33:12 +0200410 if (msb <= 8)
411 td->o.verify_pattern_bytes = 1;
412 else if (msb <= 16)
413 td->o.verify_pattern_bytes = 2;
414 else if (msb <= 24)
415 td->o.verify_pattern_bytes = 3;
416 else
417 td->o.verify_pattern_bytes = 4;
418
Shawn Lewise28218f2008-01-16 11:01:33 +0100419 td->o.verify_pattern = *off;
Jens Axboe90059d62007-07-30 09:33:12 +0200420 return 0;
421}
Jens Axboe214e1ec2007-03-15 10:48:13 +0100422
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100423static int str_lockfile_cb(void *data, const char *str)
424{
425 struct thread_data *td = data;
426 char *nr = get_opt_postfix(str);
427
428 td->o.lockfile_batch = 1;
429 if (nr)
430 td->o.lockfile_batch = atoi(nr);
431
432 return 0;
433}
434
Jens Axboe214e1ec2007-03-15 10:48:13 +0100435#define __stringify_1(x) #x
436#define __stringify(x) __stringify_1(x)
437
438/*
439 * Map of job/command line options
440 */
441static struct fio_option options[] = {
442 {
443 .name = "description",
444 .type = FIO_OPT_STR_STORE,
445 .off1 = td_var_offset(description),
446 .help = "Text job description",
447 },
448 {
449 .name = "name",
450 .type = FIO_OPT_STR_STORE,
451 .off1 = td_var_offset(name),
452 .help = "Name of this job",
453 },
454 {
455 .name = "directory",
456 .type = FIO_OPT_STR_STORE,
457 .off1 = td_var_offset(directory),
458 .cb = str_directory_cb,
459 .help = "Directory to store files in",
460 },
461 {
462 .name = "filename",
463 .type = FIO_OPT_STR_STORE,
464 .off1 = td_var_offset(filename),
465 .cb = str_filename_cb,
466 .help = "File(s) to use for the workload",
467 },
468 {
Jens Axboe29c13492008-03-01 19:25:20 +0100469 .name = "lockfile",
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100470 .type = FIO_OPT_STR,
471 .cb = str_lockfile_cb,
472 .off1 = td_var_offset(file_lock_mode),
Jens Axboe29c13492008-03-01 19:25:20 +0100473 .help = "Lock file when doing IO to it",
474 .parent = "filename",
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100475 .def = "none",
476 .posval = {
477 { .ival = "none",
478 .oval = FILE_LOCK_NONE,
479 .help = "No file locking",
480 },
481 { .ival = "exclusive",
482 .oval = FILE_LOCK_EXCLUSIVE,
483 .help = "Exclusive file lock",
484 },
485 {
486 .ival = "readwrite",
487 .oval = FILE_LOCK_READWRITE,
488 .help = "Read vs write lock",
489 },
490 },
Jens Axboe29c13492008-03-01 19:25:20 +0100491 },
492 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100493 .name = "opendir",
494 .type = FIO_OPT_STR_STORE,
495 .off1 = td_var_offset(opendir),
496 .cb = str_opendir_cb,
497 .help = "Recursively add files from this directory and down",
498 },
499 {
500 .name = "rw",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100501 .alias = "readwrite",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100502 .type = FIO_OPT_STR,
Jens Axboe211097b2007-03-22 18:56:45 +0100503 .cb = str_rw_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100504 .off1 = td_var_offset(td_ddir),
505 .help = "IO direction",
506 .def = "read",
507 .posval = {
508 { .ival = "read",
509 .oval = TD_DDIR_READ,
510 .help = "Sequential read",
511 },
512 { .ival = "write",
513 .oval = TD_DDIR_WRITE,
514 .help = "Sequential write",
515 },
516 { .ival = "randread",
517 .oval = TD_DDIR_RANDREAD,
518 .help = "Random read",
519 },
520 { .ival = "randwrite",
521 .oval = TD_DDIR_RANDWRITE,
522 .help = "Random write",
523 },
524 { .ival = "rw",
525 .oval = TD_DDIR_RW,
526 .help = "Sequential read and write mix",
527 },
528 { .ival = "randrw",
529 .oval = TD_DDIR_RANDRW,
530 .help = "Random read and write mix"
531 },
532 },
533 },
534 {
535 .name = "ioengine",
536 .type = FIO_OPT_STR_STORE,
537 .off1 = td_var_offset(ioengine),
538 .help = "IO engine to use",
539 .def = "sync",
540 .posval = {
541 { .ival = "sync",
542 .help = "Use read/write",
543 },
gurudas paia31041e2007-10-23 15:12:30 +0200544 { .ival = "psync",
545 .help = "Use pread/pwrite",
546 },
Jens Axboe1d2af022008-02-04 10:59:07 +0100547 { .ival = "vsync",
548 .help = "Use readv/writev",
549 },
Jens Axboe214e1ec2007-03-15 10:48:13 +0100550#ifdef FIO_HAVE_LIBAIO
551 { .ival = "libaio",
552 .help = "Linux native asynchronous IO",
553 },
554#endif
555#ifdef FIO_HAVE_POSIXAIO
556 { .ival = "posixaio",
557 .help = "POSIX asynchronous IO",
558 },
559#endif
Jens Axboe417f0062008-06-02 11:59:30 +0200560#ifdef FIO_HAVE_SOLARISAIO
561 { .ival = "solarisaio",
562 .help = "Solaris native asynchronous IO",
563 },
564#endif
Jens Axboe214e1ec2007-03-15 10:48:13 +0100565 { .ival = "mmap",
566 .help = "Memory mapped IO",
567 },
568#ifdef FIO_HAVE_SPLICE
569 { .ival = "splice",
570 .help = "splice/vmsplice based IO",
571 },
Jens Axboe9cce02e2007-06-22 15:42:21 +0200572 { .ival = "netsplice",
573 .help = "splice/vmsplice to/from the network",
574 },
Jens Axboe214e1ec2007-03-15 10:48:13 +0100575#endif
576#ifdef FIO_HAVE_SGIO
577 { .ival = "sg",
578 .help = "SCSI generic v3 IO",
579 },
580#endif
581 { .ival = "null",
582 .help = "Testing engine (no data transfer)",
583 },
584 { .ival = "net",
585 .help = "Network IO",
586 },
587#ifdef FIO_HAVE_SYSLET
588 { .ival = "syslet-rw",
589 .help = "syslet enabled async pread/pwrite IO",
590 },
591#endif
592 { .ival = "cpuio",
593 .help = "CPU cycler burner engine",
594 },
Jens Axboeb8c82a42007-03-21 08:48:26 +0100595#ifdef FIO_HAVE_GUASI
596 { .ival = "guasi",
597 .help = "GUASI IO engine",
598 },
599#endif
Jens Axboe214e1ec2007-03-15 10:48:13 +0100600 { .ival = "external",
601 .help = "Load external engine (append name)",
602 },
603 },
604 },
605 {
606 .name = "iodepth",
607 .type = FIO_OPT_INT,
608 .off1 = td_var_offset(iodepth),
609 .help = "Amount of IO buffers to keep in flight",
Jens Axboe757aff42007-12-12 19:42:13 +0100610 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100611 .def = "1",
612 },
613 {
614 .name = "iodepth_batch",
Jens Axboe49504212008-06-05 09:03:30 +0200615 .alias = "iodepth_batch_submit",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100616 .type = FIO_OPT_INT,
617 .off1 = td_var_offset(iodepth_batch),
618 .help = "Number of IO to submit in one go",
Jens Axboeafdf9352007-07-31 16:14:34 +0200619 .parent = "iodepth",
Jens Axboea2e6f8a2008-01-18 10:28:11 +0100620 .minval = 1,
621 .def = "1",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100622 },
623 {
Jens Axboe49504212008-06-05 09:03:30 +0200624 .name = "iodepth_batch_complete",
625 .type = FIO_OPT_INT,
626 .off1 = td_var_offset(iodepth_batch_complete),
627 .help = "Number of IO to retrieve in one go",
628 .parent = "iodepth",
629 .minval = 0,
630 .def = "1",
631 },
632 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100633 .name = "iodepth_low",
634 .type = FIO_OPT_INT,
635 .off1 = td_var_offset(iodepth_low),
636 .help = "Low water mark for queuing depth",
Jens Axboeafdf9352007-07-31 16:14:34 +0200637 .parent = "iodepth",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100638 },
639 {
640 .name = "size",
641 .type = FIO_OPT_STR_VAL,
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100642 .off1 = td_var_offset(size),
Jens Axboec3edbdb2007-07-20 14:25:31 +0200643 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100644 .help = "Total size of device or files",
645 },
646 {
Shawn Lewisaa31f1f2008-01-11 09:45:11 +0100647 .name = "fill_device",
648 .type = FIO_OPT_BOOL,
649 .off1 = td_var_offset(fill_device),
650 .help = "Write until an ENOSPC error occurs",
651 .def = "0",
652 },
653 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100654 .name = "filesize",
655 .type = FIO_OPT_STR_VAL,
656 .off1 = td_var_offset(file_size_low),
657 .off2 = td_var_offset(file_size_high),
Jens Axboec3edbdb2007-07-20 14:25:31 +0200658 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100659 .help = "Size of individual files",
660 },
661 {
Jens Axboe67a10002007-07-31 23:12:16 +0200662 .name = "offset",
663 .alias = "fileoffset",
664 .type = FIO_OPT_STR_VAL,
665 .off1 = td_var_offset(start_offset),
666 .help = "Start IO from this offset",
667 .def = "0",
668 },
669 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100670 .name = "bs",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100671 .alias = "blocksize",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100672 .type = FIO_OPT_STR_VAL_INT,
673 .off1 = td_var_offset(bs[DDIR_READ]),
674 .off2 = td_var_offset(bs[DDIR_WRITE]),
Jens Axboec3edbdb2007-07-20 14:25:31 +0200675 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100676 .help = "Block size unit",
677 .def = "4k",
Jens Axboe67a10002007-07-31 23:12:16 +0200678 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100679 },
680 {
681 .name = "bsrange",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100682 .alias = "blocksize_range",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100683 .type = FIO_OPT_RANGE,
684 .off1 = td_var_offset(min_bs[DDIR_READ]),
685 .off2 = td_var_offset(max_bs[DDIR_READ]),
686 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
687 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
Jens Axboec3edbdb2007-07-20 14:25:31 +0200688 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100689 .help = "Set block size range (in more detail than bs)",
Jens Axboe67a10002007-07-31 23:12:16 +0200690 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100691 },
692 {
Jens Axboe564ca972007-12-14 12:21:19 +0100693 .name = "bssplit",
694 .type = FIO_OPT_STR,
695 .cb = str_bssplit_cb,
696 .help = "Set a specific mix of block sizes",
697 .parent = "rw",
698 },
699 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100700 .name = "bs_unaligned",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100701 .alias = "blocksize_unaligned",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100702 .type = FIO_OPT_STR_SET,
703 .off1 = td_var_offset(bs_unaligned),
704 .help = "Don't sector align IO buffer sizes",
Jens Axboe67a10002007-07-31 23:12:16 +0200705 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100706 },
707 {
708 .name = "randrepeat",
709 .type = FIO_OPT_BOOL,
710 .off1 = td_var_offset(rand_repeatable),
711 .help = "Use repeatable random IO pattern",
712 .def = "1",
Jens Axboe67a10002007-07-31 23:12:16 +0200713 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100714 },
715 {
716 .name = "norandommap",
717 .type = FIO_OPT_STR_SET,
718 .off1 = td_var_offset(norandommap),
719 .help = "Accept potential duplicate random blocks",
Jens Axboe67a10002007-07-31 23:12:16 +0200720 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100721 },
722 {
Jens Axboe2b386d22008-03-26 10:32:57 +0100723 .name = "softrandommap",
724 .type = FIO_OPT_BOOL,
725 .off1 = td_var_offset(softrandommap),
Jens Axboef66ab3c2008-06-05 11:48:22 +0200726 .help = "Set norandommap if randommap allocation fails",
Jens Axboe2b386d22008-03-26 10:32:57 +0100727 .parent = "norandommap",
728 .def = "0",
729 },
730 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100731 .name = "nrfiles",
732 .type = FIO_OPT_INT,
733 .off1 = td_var_offset(nr_files),
734 .help = "Split job workload between this number of files",
735 .def = "1",
736 },
737 {
738 .name = "openfiles",
739 .type = FIO_OPT_INT,
740 .off1 = td_var_offset(open_files),
741 .help = "Number of files to keep open at the same time",
742 },
743 {
744 .name = "file_service_type",
745 .type = FIO_OPT_STR,
746 .cb = str_fst_cb,
747 .off1 = td_var_offset(file_service_type),
748 .help = "How to select which file to service next",
749 .def = "roundrobin",
750 .posval = {
751 { .ival = "random",
752 .oval = FIO_FSERVICE_RANDOM,
753 .help = "Choose a file at random",
754 },
755 { .ival = "roundrobin",
756 .oval = FIO_FSERVICE_RR,
757 .help = "Round robin select files",
758 },
759 },
Jens Axboe67a10002007-07-31 23:12:16 +0200760 .parent = "nrfiles",
761 },
762 {
763 .name = "fadvise_hint",
764 .type = FIO_OPT_BOOL,
765 .off1 = td_var_offset(fadvise_hint),
766 .help = "Use fadvise() to advise the kernel on IO pattern",
767 .def = "1",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100768 },
769 {
770 .name = "fsync",
771 .type = FIO_OPT_INT,
772 .off1 = td_var_offset(fsync_blocks),
773 .help = "Issue fsync for writes every given number of blocks",
774 .def = "0",
775 },
776 {
777 .name = "direct",
778 .type = FIO_OPT_BOOL,
779 .off1 = td_var_offset(odirect),
780 .help = "Use O_DIRECT IO (negates buffered)",
781 .def = "0",
782 },
783 {
784 .name = "buffered",
785 .type = FIO_OPT_BOOL,
786 .off1 = td_var_offset(odirect),
787 .neg = 1,
788 .help = "Use buffered IO (negates direct)",
789 .def = "1",
790 },
791 {
792 .name = "overwrite",
793 .type = FIO_OPT_BOOL,
794 .off1 = td_var_offset(overwrite),
795 .help = "When writing, set whether to overwrite current data",
796 .def = "0",
797 },
798 {
799 .name = "loops",
800 .type = FIO_OPT_INT,
801 .off1 = td_var_offset(loops),
802 .help = "Number of times to run the job",
803 .def = "1",
804 },
805 {
806 .name = "numjobs",
807 .type = FIO_OPT_INT,
808 .off1 = td_var_offset(numjobs),
809 .help = "Duplicate this job this many times",
810 .def = "1",
811 },
812 {
813 .name = "startdelay",
814 .type = FIO_OPT_INT,
815 .off1 = td_var_offset(start_delay),
816 .help = "Only start job when this period has passed",
817 .def = "0",
818 },
819 {
820 .name = "runtime",
821 .alias = "timeout",
822 .type = FIO_OPT_STR_VAL_TIME,
823 .off1 = td_var_offset(timeout),
824 .help = "Stop workload when this amount of time has passed",
825 .def = "0",
826 },
827 {
Jens Axboecf4464c2007-04-17 20:14:42 +0200828 .name = "time_based",
829 .type = FIO_OPT_STR_SET,
830 .off1 = td_var_offset(time_based),
831 .help = "Keep running until runtime/timeout is met",
832 },
833 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100834 .name = "mem",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100835 .alias = "iomem",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100836 .type = FIO_OPT_STR,
837 .cb = str_mem_cb,
838 .off1 = td_var_offset(mem_type),
839 .help = "Backing type for IO buffers",
840 .def = "malloc",
841 .posval = {
842 { .ival = "malloc",
843 .oval = MEM_MALLOC,
844 .help = "Use malloc(3) for IO buffers",
845 },
Jens Axboeb370e462007-03-19 10:51:49 +0100846 { .ival = "shm",
847 .oval = MEM_SHM,
848 .help = "Use shared memory segments for IO buffers",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100849 },
850#ifdef FIO_HAVE_HUGETLB
Jens Axboe37c8cdf2007-03-19 13:14:03 +0100851 { .ival = "shmhuge",
852 .oval = MEM_SHMHUGE,
853 .help = "Like shm, but use huge pages",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100854 },
855#endif
Jens Axboeb370e462007-03-19 10:51:49 +0100856 { .ival = "mmap",
857 .oval = MEM_MMAP,
858 .help = "Use mmap(2) (file or anon) for IO buffers",
859 },
Jens Axboe37c8cdf2007-03-19 13:14:03 +0100860#ifdef FIO_HAVE_HUGETLB
861 { .ival = "mmaphuge",
862 .oval = MEM_MMAPHUGE,
863 .help = "Like mmap, but use huge pages",
864 },
865#endif
Jens Axboe214e1ec2007-03-15 10:48:13 +0100866 },
867 },
868 {
869 .name = "verify",
870 .type = FIO_OPT_STR,
871 .off1 = td_var_offset(verify),
872 .help = "Verify data written",
873 .def = "0",
874 .posval = {
875 { .ival = "0",
876 .oval = VERIFY_NONE,
877 .help = "Don't do IO verification",
878 },
Jens Axboefcca4b52007-07-27 15:42:00 +0200879 { .ival = "md5",
880 .oval = VERIFY_MD5,
881 .help = "Use md5 checksums for verification",
882 },
Jens Axboed77a7af2007-07-27 15:35:06 +0200883 { .ival = "crc64",
884 .oval = VERIFY_CRC64,
885 .help = "Use crc64 checksums for verification",
886 },
Jens Axboe214e1ec2007-03-15 10:48:13 +0100887 { .ival = "crc32",
888 .oval = VERIFY_CRC32,
889 .help = "Use crc32 checksums for verification",
890 },
Jens Axboe969f7ed2007-07-27 09:07:17 +0200891 { .ival = "crc16",
892 .oval = VERIFY_CRC16,
893 .help = "Use crc16 checksums for verification",
894 },
Jens Axboe1e154bd2007-07-27 09:52:40 +0200895 { .ival = "crc7",
896 .oval = VERIFY_CRC7,
897 .help = "Use crc7 checksums for verification",
898 },
Jens Axboecd14cc12007-07-30 10:59:33 +0200899 { .ival = "sha256",
900 .oval = VERIFY_SHA256,
901 .help = "Use sha256 checksums for verification",
902 },
903 { .ival = "sha512",
904 .oval = VERIFY_SHA512,
905 .help = "Use sha512 checksums for verification",
906 },
Shawn Lewis7437ee82007-08-02 21:05:58 +0200907 { .ival = "meta",
908 .oval = VERIFY_META,
909 .help = "Use io information",
910 },
Jens Axboe36690c92007-03-26 10:23:34 +0200911 {
912 .ival = "null",
913 .oval = VERIFY_NULL,
914 .help = "Pretend to verify",
915 },
Jens Axboe214e1ec2007-03-15 10:48:13 +0100916 },
917 },
918 {
Jens Axboe005c5652007-08-02 22:21:36 +0200919 .name = "do_verify",
Jens Axboe68e1f292007-08-10 10:32:14 +0200920 .type = FIO_OPT_BOOL,
Jens Axboe005c5652007-08-02 22:21:36 +0200921 .off1 = td_var_offset(do_verify),
922 .help = "Run verification stage after write",
923 .def = "1",
924 .parent = "verify",
925 },
926 {
Jens Axboe160b9662007-03-27 10:59:49 +0200927 .name = "verifysort",
928 .type = FIO_OPT_BOOL,
929 .off1 = td_var_offset(verifysort),
930 .help = "Sort written verify blocks for read back",
931 .def = "1",
Jens Axboec83f2df2007-07-31 22:51:47 +0200932 .parent = "verify",
Jens Axboe160b9662007-03-27 10:59:49 +0200933 },
934 {
Jens Axboea59e1702007-07-30 08:53:27 +0200935 .name = "verify_interval",
Shawn Lewis3f9f4e22007-07-28 21:10:37 +0200936 .type = FIO_OPT_STR_VAL_INT,
Jens Axboea59e1702007-07-30 08:53:27 +0200937 .off1 = td_var_offset(verify_interval),
Jens Axboe819a9682007-07-28 21:30:31 +0200938 .minval = 2 * sizeof(struct verify_header),
Jens Axboea59e1702007-07-30 08:53:27 +0200939 .help = "Store verify buffer header every N bytes",
Jens Axboeafdf9352007-07-31 16:14:34 +0200940 .parent = "verify",
Shawn Lewis3f9f4e22007-07-28 21:10:37 +0200941 },
942 {
Jens Axboea59e1702007-07-30 08:53:27 +0200943 .name = "verify_offset",
Shawn Lewis546a9142007-07-28 21:11:37 +0200944 .type = FIO_OPT_STR_VAL_INT,
Jens Axboea59e1702007-07-30 08:53:27 +0200945 .help = "Offset verify header location by N bytes",
Shawn Lewis546a9142007-07-28 21:11:37 +0200946 .def = "0",
Jens Axboe5ec10ea2008-03-06 15:42:00 +0100947 .cb = str_verify_offset_cb,
Jens Axboeafdf9352007-07-31 16:14:34 +0200948 .parent = "verify",
Shawn Lewis546a9142007-07-28 21:11:37 +0200949 },
950 {
Shawn Lewise28218f2008-01-16 11:01:33 +0100951 .name = "verify_pattern",
952 .type = FIO_OPT_INT,
953 .cb = str_verify_pattern_cb,
954 .help = "Fill pattern for IO buffers",
955 .parent = "verify",
956 },
957 {
Jens Axboea12a3b42007-08-09 10:20:54 +0200958 .name = "verify_fatal",
Jens Axboe68e1f292007-08-10 10:32:14 +0200959 .type = FIO_OPT_BOOL,
Jens Axboea12a3b42007-08-09 10:20:54 +0200960 .off1 = td_var_offset(verify_fatal),
961 .def = "0",
962 .help = "Exit on a single verify failure, don't continue",
963 .parent = "verify",
964 },
965 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100966 .name = "write_iolog",
967 .type = FIO_OPT_STR_STORE,
968 .off1 = td_var_offset(write_iolog_file),
969 .help = "Store IO pattern to file",
970 },
971 {
972 .name = "read_iolog",
973 .type = FIO_OPT_STR_STORE,
974 .off1 = td_var_offset(read_iolog_file),
975 .help = "Playback IO pattern from file",
976 },
977 {
978 .name = "exec_prerun",
979 .type = FIO_OPT_STR_STORE,
980 .off1 = td_var_offset(exec_prerun),
981 .help = "Execute this file prior to running job",
982 },
983 {
984 .name = "exec_postrun",
985 .type = FIO_OPT_STR_STORE,
986 .off1 = td_var_offset(exec_postrun),
987 .help = "Execute this file after running job",
988 },
989#ifdef FIO_HAVE_IOSCHED_SWITCH
990 {
991 .name = "ioscheduler",
992 .type = FIO_OPT_STR_STORE,
993 .off1 = td_var_offset(ioscheduler),
994 .help = "Use this IO scheduler on the backing device",
995 },
996#endif
997 {
998 .name = "zonesize",
999 .type = FIO_OPT_STR_VAL,
1000 .off1 = td_var_offset(zone_size),
1001 .help = "Give size of an IO zone",
1002 .def = "0",
1003 },
1004 {
1005 .name = "zoneskip",
1006 .type = FIO_OPT_STR_VAL,
1007 .off1 = td_var_offset(zone_skip),
1008 .help = "Space between IO zones",
1009 .def = "0",
1010 },
1011 {
1012 .name = "lockmem",
1013 .type = FIO_OPT_STR_VAL,
1014 .cb = str_lockmem_cb,
1015 .help = "Lock down this amount of memory",
1016 .def = "0",
1017 },
1018 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001019 .name = "rwmixread",
1020 .type = FIO_OPT_INT,
Jens Axboecb499fc2008-05-28 10:33:32 +02001021 .cb = str_rwmix_read_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001022 .maxval = 100,
1023 .help = "Percentage of mixed workload that is reads",
1024 .def = "50",
1025 },
1026 {
1027 .name = "rwmixwrite",
1028 .type = FIO_OPT_INT,
Jens Axboecb499fc2008-05-28 10:33:32 +02001029 .cb = str_rwmix_write_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001030 .maxval = 100,
1031 .help = "Percentage of mixed workload that is writes",
1032 .def = "50",
1033 },
1034 {
Jens Axboeafdf9352007-07-31 16:14:34 +02001035 .name = "rwmixcycle",
Jens Axboe15ca1502008-04-07 09:26:02 +02001036 .type = FIO_OPT_DEPRECATED,
Jens Axboeafdf9352007-07-31 16:14:34 +02001037 },
1038 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001039 .name = "nice",
1040 .type = FIO_OPT_INT,
1041 .off1 = td_var_offset(nice),
1042 .help = "Set job CPU nice value",
1043 .minval = -19,
1044 .maxval = 20,
1045 .def = "0",
1046 },
1047#ifdef FIO_HAVE_IOPRIO
1048 {
1049 .name = "prio",
1050 .type = FIO_OPT_INT,
1051 .cb = str_prio_cb,
1052 .help = "Set job IO priority value",
1053 .minval = 0,
1054 .maxval = 7,
1055 },
1056 {
1057 .name = "prioclass",
1058 .type = FIO_OPT_INT,
1059 .cb = str_prioclass_cb,
1060 .help = "Set job IO priority class",
1061 .minval = 0,
1062 .maxval = 3,
1063 },
1064#endif
1065 {
1066 .name = "thinktime",
1067 .type = FIO_OPT_INT,
1068 .off1 = td_var_offset(thinktime),
1069 .help = "Idle time between IO buffers (usec)",
1070 .def = "0",
1071 },
1072 {
1073 .name = "thinktime_spin",
1074 .type = FIO_OPT_INT,
1075 .off1 = td_var_offset(thinktime_spin),
1076 .help = "Start think time by spinning this amount (usec)",
1077 .def = "0",
Jens Axboeafdf9352007-07-31 16:14:34 +02001078 .parent = "thinktime",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001079 },
1080 {
1081 .name = "thinktime_blocks",
1082 .type = FIO_OPT_INT,
1083 .off1 = td_var_offset(thinktime_blocks),
1084 .help = "IO buffer period between 'thinktime'",
1085 .def = "1",
Jens Axboeafdf9352007-07-31 16:14:34 +02001086 .parent = "thinktime",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001087 },
1088 {
1089 .name = "rate",
1090 .type = FIO_OPT_INT,
1091 .off1 = td_var_offset(rate),
1092 .help = "Set bandwidth rate",
1093 },
1094 {
1095 .name = "ratemin",
1096 .type = FIO_OPT_INT,
1097 .off1 = td_var_offset(ratemin),
Jens Axboe4e991c22007-03-15 11:41:11 +01001098 .help = "Job must meet this rate or it will be shutdown",
Jens Axboeafdf9352007-07-31 16:14:34 +02001099 .parent = "rate",
Jens Axboe4e991c22007-03-15 11:41:11 +01001100 },
1101 {
1102 .name = "rate_iops",
1103 .type = FIO_OPT_INT,
1104 .off1 = td_var_offset(rate_iops),
1105 .help = "Limit IO used to this number of IO operations/sec",
1106 },
1107 {
1108 .name = "rate_iops_min",
1109 .type = FIO_OPT_INT,
1110 .off1 = td_var_offset(rate_iops_min),
1111 .help = "Job must meet this rate or it will be shutdown",
Jens Axboeafdf9352007-07-31 16:14:34 +02001112 .parent = "rate_iops",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001113 },
1114 {
1115 .name = "ratecycle",
1116 .type = FIO_OPT_INT,
1117 .off1 = td_var_offset(ratecycle),
1118 .help = "Window average for rate limits (msec)",
1119 .def = "1000",
Jens Axboeafdf9352007-07-31 16:14:34 +02001120 .parent = "rate",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001121 },
1122 {
1123 .name = "invalidate",
1124 .type = FIO_OPT_BOOL,
1125 .off1 = td_var_offset(invalidate_cache),
1126 .help = "Invalidate buffer/page cache prior to running job",
1127 .def = "1",
1128 },
1129 {
1130 .name = "sync",
1131 .type = FIO_OPT_BOOL,
1132 .off1 = td_var_offset(sync_io),
1133 .help = "Use O_SYNC for buffered writes",
1134 .def = "0",
Jens Axboe67a10002007-07-31 23:12:16 +02001135 .parent = "buffered",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001136 },
1137 {
1138 .name = "bwavgtime",
1139 .type = FIO_OPT_INT,
1140 .off1 = td_var_offset(bw_avg_time),
Jens Axboe5ec10ea2008-03-06 15:42:00 +01001141 .help = "Time window over which to calculate bandwidth"
1142 " (msec)",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001143 .def = "500",
1144 },
1145 {
1146 .name = "create_serialize",
1147 .type = FIO_OPT_BOOL,
1148 .off1 = td_var_offset(create_serialize),
1149 .help = "Serialize creating of job files",
1150 .def = "1",
1151 },
1152 {
1153 .name = "create_fsync",
1154 .type = FIO_OPT_BOOL,
1155 .off1 = td_var_offset(create_fsync),
1156 .help = "Fsync file after creation",
1157 .def = "1",
1158 },
1159 {
1160 .name = "cpuload",
1161 .type = FIO_OPT_INT,
1162 .off1 = td_var_offset(cpuload),
1163 .help = "Use this percentage of CPU",
1164 },
1165 {
1166 .name = "cpuchunks",
1167 .type = FIO_OPT_INT,
1168 .off1 = td_var_offset(cpucycle),
1169 .help = "Length of the CPU burn cycles (usecs)",
1170 .def = "50000",
Jens Axboe67a10002007-07-31 23:12:16 +02001171 .parent = "cpuload",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001172 },
1173#ifdef FIO_HAVE_CPU_AFFINITY
1174 {
1175 .name = "cpumask",
1176 .type = FIO_OPT_INT,
1177 .cb = str_cpumask_cb,
1178 .help = "CPU affinity mask",
1179 },
Jens Axboed2e268b2007-06-15 10:33:49 +02001180 {
1181 .name = "cpus_allowed",
1182 .type = FIO_OPT_STR,
1183 .cb = str_cpus_allowed_cb,
1184 .help = "Set CPUs allowed",
1185 },
Jens Axboe214e1ec2007-03-15 10:48:13 +01001186#endif
1187 {
1188 .name = "end_fsync",
1189 .type = FIO_OPT_BOOL,
1190 .off1 = td_var_offset(end_fsync),
1191 .help = "Include fsync at the end of job",
1192 .def = "0",
1193 },
1194 {
1195 .name = "fsync_on_close",
1196 .type = FIO_OPT_BOOL,
1197 .off1 = td_var_offset(fsync_on_close),
1198 .help = "fsync files on close",
1199 .def = "0",
1200 },
1201 {
1202 .name = "unlink",
1203 .type = FIO_OPT_BOOL,
1204 .off1 = td_var_offset(unlink),
1205 .help = "Unlink created files after job has completed",
1206 .def = "0",
1207 },
1208 {
1209 .name = "exitall",
1210 .type = FIO_OPT_STR_SET,
1211 .cb = str_exitall_cb,
1212 .help = "Terminate all jobs when one exits",
1213 },
1214 {
1215 .name = "stonewall",
1216 .type = FIO_OPT_STR_SET,
1217 .off1 = td_var_offset(stonewall),
1218 .help = "Insert a hard barrier between this job and previous",
1219 },
1220 {
Jens Axboeb3d62a72007-03-20 14:23:26 +01001221 .name = "new_group",
1222 .type = FIO_OPT_STR_SET,
1223 .off1 = td_var_offset(new_group),
1224 .help = "Mark the start of a new group (for reporting)",
1225 },
1226 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001227 .name = "thread",
1228 .type = FIO_OPT_STR_SET,
1229 .off1 = td_var_offset(use_thread),
1230 .help = "Use threads instead of forks",
1231 },
1232 {
1233 .name = "write_bw_log",
1234 .type = FIO_OPT_STR_SET,
1235 .off1 = td_var_offset(write_bw_log),
1236 .help = "Write log of bandwidth during run",
1237 },
1238 {
1239 .name = "write_lat_log",
1240 .type = FIO_OPT_STR_SET,
1241 .off1 = td_var_offset(write_lat_log),
1242 .help = "Write log of latency during run",
1243 },
1244 {
1245 .name = "hugepage-size",
Aaron Carroll357f6182008-02-20 09:14:13 +01001246 .type = FIO_OPT_STR_VAL_INT,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001247 .off1 = td_var_offset(hugepage_size),
1248 .help = "When using hugepages, specify size of each page",
1249 .def = __stringify(FIO_HUGE_PAGE),
1250 },
1251 {
1252 .name = "group_reporting",
1253 .type = FIO_OPT_STR_SET,
1254 .off1 = td_var_offset(group_reporting),
1255 .help = "Do reporting on a per-group basis",
1256 },
1257 {
Jens Axboee9459e52007-04-17 15:46:32 +02001258 .name = "zero_buffers",
1259 .type = FIO_OPT_STR_SET,
1260 .off1 = td_var_offset(zero_buffers),
1261 .help = "Init IO buffers to all zeroes",
1262 },
Jens Axboe5973caf2008-05-21 19:52:35 +02001263 {
1264 .name = "refill_buffers",
1265 .type = FIO_OPT_STR_SET,
1266 .off1 = td_var_offset(refill_buffers),
1267 .help = "Refill IO buffers on every IO submit",
1268 },
Jens Axboe0a839f32007-04-26 09:02:34 +02001269#ifdef FIO_HAVE_DISK_UTIL
1270 {
1271 .name = "disk_util",
1272 .type = FIO_OPT_BOOL,
1273 .off1 = td_var_offset(do_disk_util),
Jens Axboef66ab3c2008-06-05 11:48:22 +02001274 .help = "Log disk utilization statistics",
Jens Axboe0a839f32007-04-26 09:02:34 +02001275 .def = "1",
1276 },
1277#endif
Jens Axboee9459e52007-04-17 15:46:32 +02001278 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001279 .name = NULL,
1280 },
1281};
1282
1283void fio_options_dup_and_init(struct option *long_options)
1284{
1285 struct fio_option *o;
1286 unsigned int i;
1287
1288 options_init(options);
1289
1290 i = 0;
1291 while (long_options[i].name)
1292 i++;
1293
1294 o = &options[0];
1295 while (o->name) {
Jens Axboe5921e802008-05-30 15:02:38 +02001296 long_options[i].name = (char *) o->name;
Jens Axboe214e1ec2007-03-15 10:48:13 +01001297 long_options[i].val = FIO_GETOPT_JOB;
1298 if (o->type == FIO_OPT_STR_SET)
1299 long_options[i].has_arg = no_argument;
1300 else
1301 long_options[i].has_arg = required_argument;
1302
1303 i++;
1304 o++;
1305 assert(i < FIO_NR_OPTIONS);
1306 }
1307}
1308
1309int fio_option_parse(struct thread_data *td, const char *opt)
1310{
1311 return parse_option(opt, options, td);
1312}
1313
1314int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
1315{
1316 return parse_cmd_option(opt, val, options, td);
1317}
1318
1319void fio_fill_default_options(struct thread_data *td)
1320{
1321 fill_default_options(td, options);
1322}
1323
1324int fio_show_option_help(const char *opt)
1325{
1326 return show_cmd_help(options, opt);
1327}
Jens Axboed23bb322007-03-23 15:57:56 +01001328
1329static void __options_mem(struct thread_data *td, int alloc)
1330{
1331 struct thread_options *o = &td->o;
1332 struct fio_option *opt;
1333 char **ptr;
1334 int i;
1335
1336 for (i = 0, opt = &options[0]; opt->name; i++, opt = &options[i]) {
1337 if (opt->type != FIO_OPT_STR_STORE)
1338 continue;
1339
1340 ptr = (void *) o + opt->off1;
1341 if (*ptr) {
1342 if (alloc)
1343 *ptr = strdup(*ptr);
1344 else {
1345 free(*ptr);
1346 *ptr = NULL;
1347 }
1348 }
1349 }
1350}
1351
1352/*
1353 * dupe FIO_OPT_STR_STORE options
1354 */
1355void options_mem_dupe(struct thread_data *td)
1356{
1357 __options_mem(td, 1);
1358}
1359
Jens Axboe22d66212007-03-27 20:06:25 +02001360void options_mem_free(struct thread_data fio_unused *td)
Jens Axboed23bb322007-03-23 15:57:56 +01001361{
Jens Axboe22d66212007-03-27 20:06:25 +02001362#if 0
Jens Axboed23bb322007-03-23 15:57:56 +01001363 __options_mem(td, 0);
Jens Axboe22d66212007-03-27 20:06:25 +02001364#endif
Jens Axboed23bb322007-03-23 15:57:56 +01001365}