blob: b890420f4e4e06c75f0c8f0c787f9c4597fd844f [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 Axboe182ec6e2008-11-14 13:06:06 +0100157 if (nr) {
Jens Axboe211097b2007-03-22 18:56:45 +0100158 td->o.ddir_nr = atoi(nr);
Jens Axboe182ec6e2008-11-14 13:06:06 +0100159 free(nr);
160 }
Jens Axboe211097b2007-03-22 18:56:45 +0100161
Jens Axboe211097b2007-03-22 18:56:45 +0100162 return 0;
163}
164
Jens Axboe214e1ec2007-03-15 10:48:13 +0100165static int str_mem_cb(void *data, const char *mem)
166{
167 struct thread_data *td = data;
168
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100169 if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP) {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100170 td->mmapfile = get_opt_postfix(mem);
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100171 if (td->o.mem_type == MEM_MMAPHUGE && !td->mmapfile) {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100172 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
Jens Axboecb499fc2008-05-28 10:33:32 +0200186static 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
Jens Axboe214e1ec2007-03-15 10:48:13 +0100204#ifdef FIO_HAVE_IOPRIO
205static int str_prioclass_cb(void *data, unsigned int *val)
206{
207 struct thread_data *td = data;
Jens Axboe6cefbe32007-04-18 12:46:56 +0200208 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;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100215
216 td->ioprio |= *val << IOPRIO_CLASS_SHIFT;
Jens Axboeac684782007-11-08 08:29:07 +0100217 td->ioprio_set = 1;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100218 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;
Jens Axboe6cefbe32007-04-18 12:46:56 +0200226
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
Jens Axboeac684782007-11-08 08:29:07 +0100233 td->ioprio_set = 1;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100234 return 0;
235}
236#endif
237
238static int str_exitall_cb(void)
239{
240 exitall_on_terminate = 1;
241 return 0;
242}
243
Jens Axboe214e1ec2007-03-15 10:48:13 +0100244#ifdef FIO_HAVE_CPU_AFFINITY
Jens Axboe214e1ec2007-03-15 10:48:13 +0100245static int str_cpumask_cb(void *data, unsigned int *val)
246{
247 struct thread_data *td = data;
Jens Axboed2e268b2007-06-15 10:33:49 +0200248 unsigned int i;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100249
Jens Axboed2e268b2007-06-15 10:33:49 +0200250 CPU_ZERO(&td->o.cpumask);
251
252 for (i = 0; i < sizeof(int) * 8; i++)
253 if ((1 << i) & *val)
254 CPU_SET(*val, &td->o.cpumask);
255
Jens Axboe375b2692007-05-22 09:13:02 +0200256 td->o.cpumask_set = 1;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100257 return 0;
258}
259
Jens Axboed2e268b2007-06-15 10:33:49 +0200260static int str_cpus_allowed_cb(void *data, const char *input)
261{
262 struct thread_data *td = data;
263 char *cpu, *str, *p;
264
265 CPU_ZERO(&td->o.cpumask);
266
267 p = str = strdup(input);
268
269 strip_blank_front(&str);
270 strip_blank_end(str);
271
272 while ((cpu = strsep(&str, ",")) != NULL) {
273 if (!strlen(cpu))
274 break;
275 CPU_SET(atoi(cpu), &td->o.cpumask);
276 }
277
278 free(p);
279 td->o.cpumask_set = 1;
Jens Axboed2e268b2007-06-15 10:33:49 +0200280 return 0;
281}
282#endif
283
Jens Axboe214e1ec2007-03-15 10:48:13 +0100284static int str_fst_cb(void *data, const char *str)
285{
286 struct thread_data *td = data;
287 char *nr = get_opt_postfix(str);
288
289 td->file_service_nr = 1;
Jens Axboe182ec6e2008-11-14 13:06:06 +0100290 if (nr) {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100291 td->file_service_nr = atoi(nr);
Jens Axboe182ec6e2008-11-14 13:06:06 +0100292 free(nr);
293 }
Jens Axboe214e1ec2007-03-15 10:48:13 +0100294
295 return 0;
296}
297
Jens Axboe921c7662008-03-26 09:17:55 +0100298static int check_dir(struct thread_data *td, char *fname)
299{
300 char file[PATH_MAX], *dir;
Jens Axboebc838912008-04-07 09:00:54 +0200301 int elen = 0;
Jens Axboe921c7662008-03-26 09:17:55 +0100302
Jens Axboebc838912008-04-07 09:00:54 +0200303 if (td->o.directory) {
304 strcpy(file, td->o.directory);
Jens Axboefcef0b32008-05-26 14:53:24 +0200305 strcat(file, "/");
Jens Axboebc838912008-04-07 09:00:54 +0200306 elen = strlen(file);
307 }
308
Jens Axboefcef0b32008-05-26 14:53:24 +0200309 sprintf(file + elen, "%s", fname);
Jens Axboe921c7662008-03-26 09:17:55 +0100310 dir = dirname(file);
311
Jens Axboefcef0b32008-05-26 14:53:24 +0200312#if 0
313 {
314 struct stat sb;
315 /*
316 * We can't do this on FIO_DISKLESSIO engines. The engine isn't loaded
317 * yet, so we can't do this check right here...
318 */
Jens Axboe921c7662008-03-26 09:17:55 +0100319 if (lstat(dir, &sb) < 0) {
320 int ret = errno;
321
322 log_err("fio: %s is not a directory\n", dir);
323 td_verror(td, ret, "lstat");
324 return 1;
325 }
326
327 if (!S_ISDIR(sb.st_mode)) {
328 log_err("fio: %s is not a directory\n", dir);
329 return 1;
330 }
Jens Axboefcef0b32008-05-26 14:53:24 +0200331 }
332#endif
Jens Axboe921c7662008-03-26 09:17:55 +0100333
334 return 0;
335}
336
Jens Axboe214e1ec2007-03-15 10:48:13 +0100337static int str_filename_cb(void *data, const char *input)
338{
339 struct thread_data *td = data;
340 char *fname, *str, *p;
341
342 p = str = strdup(input);
343
344 strip_blank_front(&str);
345 strip_blank_end(str);
346
347 if (!td->files_index)
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100348 td->o.nr_files = 0;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100349
350 while ((fname = strsep(&str, ":")) != NULL) {
351 if (!strlen(fname))
352 break;
Jens Axboe921c7662008-03-26 09:17:55 +0100353 if (check_dir(td, fname)) {
354 free(p);
355 return 1;
356 }
Jens Axboe214e1ec2007-03-15 10:48:13 +0100357 add_file(td, fname);
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100358 td->o.nr_files++;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100359 }
360
361 free(p);
362 return 0;
363}
364
365static int str_directory_cb(void *data, const char fio_unused *str)
366{
367 struct thread_data *td = data;
368 struct stat sb;
369
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100370 if (lstat(td->o.directory, &sb) < 0) {
Jens Axboe921c7662008-03-26 09:17:55 +0100371 int ret = errno;
372
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100373 log_err("fio: %s is not a directory\n", td->o.directory);
Jens Axboe921c7662008-03-26 09:17:55 +0100374 td_verror(td, ret, "lstat");
Jens Axboe214e1ec2007-03-15 10:48:13 +0100375 return 1;
376 }
377 if (!S_ISDIR(sb.st_mode)) {
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100378 log_err("fio: %s is not a directory\n", td->o.directory);
Jens Axboe214e1ec2007-03-15 10:48:13 +0100379 return 1;
380 }
381
382 return 0;
383}
384
385static int str_opendir_cb(void *data, const char fio_unused *str)
386{
387 struct thread_data *td = data;
388
389 if (!td->files_index)
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100390 td->o.nr_files = 0;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100391
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100392 return add_dir_files(td, td->o.opendir);
Jens Axboe214e1ec2007-03-15 10:48:13 +0100393}
394
Jens Axboea59e1702007-07-30 08:53:27 +0200395static int str_verify_offset_cb(void *data, unsigned int *off)
Shawn Lewis546a9142007-07-28 21:11:37 +0200396{
397 struct thread_data *td = data;
Jens Axboea59e1702007-07-30 08:53:27 +0200398
Shawn Lewis546a9142007-07-28 21:11:37 +0200399 if (*off && *off < sizeof(struct verify_header)) {
Jens Axboea59e1702007-07-30 08:53:27 +0200400 log_err("fio: verify_offset too small\n");
Shawn Lewis546a9142007-07-28 21:11:37 +0200401 return 1;
402 }
Jens Axboea59e1702007-07-30 08:53:27 +0200403
404 td->o.verify_offset = *off;
Shawn Lewis546a9142007-07-28 21:11:37 +0200405 return 0;
406}
407
Shawn Lewise28218f2008-01-16 11:01:33 +0100408static int str_verify_pattern_cb(void *data, unsigned int *off)
Jens Axboe90059d62007-07-30 09:33:12 +0200409{
410 struct thread_data *td = data;
Shawn Lewise28218f2008-01-16 11:01:33 +0100411 unsigned int msb;
Jens Axboe90059d62007-07-30 09:33:12 +0200412
Jens Axboe3c48c2c2008-06-02 12:22:30 +0200413 msb = __fls(*off);
Jens Axboe90059d62007-07-30 09:33:12 +0200414 if (msb <= 8)
415 td->o.verify_pattern_bytes = 1;
416 else if (msb <= 16)
417 td->o.verify_pattern_bytes = 2;
418 else if (msb <= 24)
419 td->o.verify_pattern_bytes = 3;
420 else
421 td->o.verify_pattern_bytes = 4;
422
Shawn Lewise28218f2008-01-16 11:01:33 +0100423 td->o.verify_pattern = *off;
Jens Axboe90059d62007-07-30 09:33:12 +0200424 return 0;
425}
Jens Axboe214e1ec2007-03-15 10:48:13 +0100426
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100427static int str_lockfile_cb(void *data, const char *str)
428{
429 struct thread_data *td = data;
430 char *nr = get_opt_postfix(str);
431
432 td->o.lockfile_batch = 1;
Jens Axboe182ec6e2008-11-14 13:06:06 +0100433 if (nr) {
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100434 td->o.lockfile_batch = atoi(nr);
Jens Axboe182ec6e2008-11-14 13:06:06 +0100435 free(nr);
436 }
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100437
438 return 0;
439}
440
Jens Axboee3cedca2008-11-19 19:57:52 +0100441static int str_write_bw_log_cb(void *data, const char *str)
442{
443 struct thread_data *td = data;
444
445 if (str)
446 td->o.bw_log_file = strdup(str);
447
448 td->o.write_bw_log = 1;
449 return 0;
450}
451
452static int str_write_lat_log_cb(void *data, const char *str)
453{
454 struct thread_data *td = data;
455
456 if (str)
457 td->o.lat_log_file = strdup(str);
458
459 td->o.write_lat_log = 1;
460 return 0;
461}
462
Jens Axboe993bf482008-11-14 13:04:53 +0100463static int str_gtod_reduce_cb(void *data, int *il)
464{
465 struct thread_data *td = data;
466 int val = *il;
467
468 td->o.disable_clat = !!val;
469 td->o.disable_slat = !!val;
470 td->o.disable_bw = !!val;
471 if (val)
472 td->tv_cache_mask = 63;
473
474 return 0;
475}
476
Jens Axboe214e1ec2007-03-15 10:48:13 +0100477#define __stringify_1(x) #x
478#define __stringify(x) __stringify_1(x)
479
480/*
481 * Map of job/command line options
482 */
483static struct fio_option options[] = {
484 {
485 .name = "description",
486 .type = FIO_OPT_STR_STORE,
487 .off1 = td_var_offset(description),
488 .help = "Text job description",
489 },
490 {
491 .name = "name",
492 .type = FIO_OPT_STR_STORE,
493 .off1 = td_var_offset(name),
494 .help = "Name of this job",
495 },
496 {
497 .name = "directory",
498 .type = FIO_OPT_STR_STORE,
499 .off1 = td_var_offset(directory),
500 .cb = str_directory_cb,
501 .help = "Directory to store files in",
502 },
503 {
504 .name = "filename",
505 .type = FIO_OPT_STR_STORE,
506 .off1 = td_var_offset(filename),
507 .cb = str_filename_cb,
Jens Axboe3b8b7132008-06-10 19:46:23 +0200508 .prio = 1, /* must come before "directory" */
Jens Axboe214e1ec2007-03-15 10:48:13 +0100509 .help = "File(s) to use for the workload",
510 },
511 {
Jens Axboe29c13492008-03-01 19:25:20 +0100512 .name = "lockfile",
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100513 .type = FIO_OPT_STR,
514 .cb = str_lockfile_cb,
515 .off1 = td_var_offset(file_lock_mode),
Jens Axboe29c13492008-03-01 19:25:20 +0100516 .help = "Lock file when doing IO to it",
517 .parent = "filename",
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100518 .def = "none",
519 .posval = {
520 { .ival = "none",
521 .oval = FILE_LOCK_NONE,
522 .help = "No file locking",
523 },
524 { .ival = "exclusive",
525 .oval = FILE_LOCK_EXCLUSIVE,
526 .help = "Exclusive file lock",
527 },
528 {
529 .ival = "readwrite",
530 .oval = FILE_LOCK_READWRITE,
531 .help = "Read vs write lock",
532 },
533 },
Jens Axboe29c13492008-03-01 19:25:20 +0100534 },
535 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100536 .name = "opendir",
537 .type = FIO_OPT_STR_STORE,
538 .off1 = td_var_offset(opendir),
539 .cb = str_opendir_cb,
540 .help = "Recursively add files from this directory and down",
541 },
542 {
543 .name = "rw",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100544 .alias = "readwrite",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100545 .type = FIO_OPT_STR,
Jens Axboe211097b2007-03-22 18:56:45 +0100546 .cb = str_rw_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100547 .off1 = td_var_offset(td_ddir),
548 .help = "IO direction",
549 .def = "read",
550 .posval = {
551 { .ival = "read",
552 .oval = TD_DDIR_READ,
553 .help = "Sequential read",
554 },
555 { .ival = "write",
556 .oval = TD_DDIR_WRITE,
557 .help = "Sequential write",
558 },
559 { .ival = "randread",
560 .oval = TD_DDIR_RANDREAD,
561 .help = "Random read",
562 },
563 { .ival = "randwrite",
564 .oval = TD_DDIR_RANDWRITE,
565 .help = "Random write",
566 },
567 { .ival = "rw",
568 .oval = TD_DDIR_RW,
569 .help = "Sequential read and write mix",
570 },
571 { .ival = "randrw",
572 .oval = TD_DDIR_RANDRW,
573 .help = "Random read and write mix"
574 },
575 },
576 },
577 {
578 .name = "ioengine",
579 .type = FIO_OPT_STR_STORE,
580 .off1 = td_var_offset(ioengine),
581 .help = "IO engine to use",
582 .def = "sync",
583 .posval = {
584 { .ival = "sync",
585 .help = "Use read/write",
586 },
gurudas paia31041e2007-10-23 15:12:30 +0200587 { .ival = "psync",
588 .help = "Use pread/pwrite",
589 },
Jens Axboe1d2af022008-02-04 10:59:07 +0100590 { .ival = "vsync",
591 .help = "Use readv/writev",
592 },
Jens Axboe214e1ec2007-03-15 10:48:13 +0100593#ifdef FIO_HAVE_LIBAIO
594 { .ival = "libaio",
595 .help = "Linux native asynchronous IO",
596 },
597#endif
598#ifdef FIO_HAVE_POSIXAIO
599 { .ival = "posixaio",
600 .help = "POSIX asynchronous IO",
601 },
602#endif
Jens Axboe417f0062008-06-02 11:59:30 +0200603#ifdef FIO_HAVE_SOLARISAIO
604 { .ival = "solarisaio",
605 .help = "Solaris native asynchronous IO",
606 },
607#endif
Jens Axboe214e1ec2007-03-15 10:48:13 +0100608 { .ival = "mmap",
609 .help = "Memory mapped IO",
610 },
611#ifdef FIO_HAVE_SPLICE
612 { .ival = "splice",
613 .help = "splice/vmsplice based IO",
614 },
Jens Axboe9cce02e2007-06-22 15:42:21 +0200615 { .ival = "netsplice",
616 .help = "splice/vmsplice to/from the network",
617 },
Jens Axboe214e1ec2007-03-15 10:48:13 +0100618#endif
619#ifdef FIO_HAVE_SGIO
620 { .ival = "sg",
621 .help = "SCSI generic v3 IO",
622 },
623#endif
624 { .ival = "null",
625 .help = "Testing engine (no data transfer)",
626 },
627 { .ival = "net",
628 .help = "Network IO",
629 },
630#ifdef FIO_HAVE_SYSLET
631 { .ival = "syslet-rw",
632 .help = "syslet enabled async pread/pwrite IO",
633 },
634#endif
635 { .ival = "cpuio",
636 .help = "CPU cycler burner engine",
637 },
Jens Axboeb8c82a42007-03-21 08:48:26 +0100638#ifdef FIO_HAVE_GUASI
639 { .ival = "guasi",
640 .help = "GUASI IO engine",
641 },
642#endif
Jens Axboe214e1ec2007-03-15 10:48:13 +0100643 { .ival = "external",
644 .help = "Load external engine (append name)",
645 },
646 },
647 },
648 {
649 .name = "iodepth",
650 .type = FIO_OPT_INT,
651 .off1 = td_var_offset(iodepth),
652 .help = "Amount of IO buffers to keep in flight",
Jens Axboe757aff42007-12-12 19:42:13 +0100653 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100654 .def = "1",
655 },
656 {
657 .name = "iodepth_batch",
Jens Axboe49504212008-06-05 09:03:30 +0200658 .alias = "iodepth_batch_submit",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100659 .type = FIO_OPT_INT,
660 .off1 = td_var_offset(iodepth_batch),
661 .help = "Number of IO to submit in one go",
Jens Axboeafdf9352007-07-31 16:14:34 +0200662 .parent = "iodepth",
Jens Axboea2e6f8a2008-01-18 10:28:11 +0100663 .minval = 1,
664 .def = "1",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100665 },
666 {
Jens Axboe49504212008-06-05 09:03:30 +0200667 .name = "iodepth_batch_complete",
668 .type = FIO_OPT_INT,
669 .off1 = td_var_offset(iodepth_batch_complete),
670 .help = "Number of IO to retrieve in one go",
671 .parent = "iodepth",
672 .minval = 0,
673 .def = "1",
674 },
675 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100676 .name = "iodepth_low",
677 .type = FIO_OPT_INT,
678 .off1 = td_var_offset(iodepth_low),
679 .help = "Low water mark for queuing depth",
Jens Axboeafdf9352007-07-31 16:14:34 +0200680 .parent = "iodepth",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100681 },
682 {
683 .name = "size",
684 .type = FIO_OPT_STR_VAL,
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100685 .off1 = td_var_offset(size),
Jens Axboec3edbdb2007-07-20 14:25:31 +0200686 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100687 .help = "Total size of device or files",
688 },
689 {
Shawn Lewisaa31f1f2008-01-11 09:45:11 +0100690 .name = "fill_device",
691 .type = FIO_OPT_BOOL,
692 .off1 = td_var_offset(fill_device),
693 .help = "Write until an ENOSPC error occurs",
694 .def = "0",
695 },
696 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100697 .name = "filesize",
698 .type = FIO_OPT_STR_VAL,
699 .off1 = td_var_offset(file_size_low),
700 .off2 = td_var_offset(file_size_high),
Jens Axboec3edbdb2007-07-20 14:25:31 +0200701 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100702 .help = "Size of individual files",
703 },
704 {
Jens Axboe67a10002007-07-31 23:12:16 +0200705 .name = "offset",
706 .alias = "fileoffset",
707 .type = FIO_OPT_STR_VAL,
708 .off1 = td_var_offset(start_offset),
709 .help = "Start IO from this offset",
710 .def = "0",
711 },
712 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100713 .name = "bs",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100714 .alias = "blocksize",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100715 .type = FIO_OPT_STR_VAL_INT,
716 .off1 = td_var_offset(bs[DDIR_READ]),
717 .off2 = td_var_offset(bs[DDIR_WRITE]),
Jens Axboec3edbdb2007-07-20 14:25:31 +0200718 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100719 .help = "Block size unit",
720 .def = "4k",
Jens Axboe67a10002007-07-31 23:12:16 +0200721 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100722 },
723 {
724 .name = "bsrange",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100725 .alias = "blocksize_range",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100726 .type = FIO_OPT_RANGE,
727 .off1 = td_var_offset(min_bs[DDIR_READ]),
728 .off2 = td_var_offset(max_bs[DDIR_READ]),
729 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
730 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
Jens Axboec3edbdb2007-07-20 14:25:31 +0200731 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100732 .help = "Set block size range (in more detail than bs)",
Jens Axboe67a10002007-07-31 23:12:16 +0200733 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100734 },
735 {
Jens Axboe564ca972007-12-14 12:21:19 +0100736 .name = "bssplit",
737 .type = FIO_OPT_STR,
738 .cb = str_bssplit_cb,
739 .help = "Set a specific mix of block sizes",
740 .parent = "rw",
741 },
742 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100743 .name = "bs_unaligned",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100744 .alias = "blocksize_unaligned",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100745 .type = FIO_OPT_STR_SET,
746 .off1 = td_var_offset(bs_unaligned),
747 .help = "Don't sector align IO buffer sizes",
Jens Axboe67a10002007-07-31 23:12:16 +0200748 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100749 },
750 {
751 .name = "randrepeat",
752 .type = FIO_OPT_BOOL,
753 .off1 = td_var_offset(rand_repeatable),
754 .help = "Use repeatable random IO pattern",
755 .def = "1",
Jens Axboe67a10002007-07-31 23:12:16 +0200756 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100757 },
758 {
759 .name = "norandommap",
760 .type = FIO_OPT_STR_SET,
761 .off1 = td_var_offset(norandommap),
762 .help = "Accept potential duplicate random blocks",
Jens Axboe67a10002007-07-31 23:12:16 +0200763 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100764 },
765 {
Jens Axboe2b386d22008-03-26 10:32:57 +0100766 .name = "softrandommap",
767 .type = FIO_OPT_BOOL,
768 .off1 = td_var_offset(softrandommap),
Jens Axboef66ab3c2008-06-05 11:48:22 +0200769 .help = "Set norandommap if randommap allocation fails",
Jens Axboe2b386d22008-03-26 10:32:57 +0100770 .parent = "norandommap",
771 .def = "0",
772 },
773 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100774 .name = "nrfiles",
775 .type = FIO_OPT_INT,
776 .off1 = td_var_offset(nr_files),
777 .help = "Split job workload between this number of files",
778 .def = "1",
779 },
780 {
781 .name = "openfiles",
782 .type = FIO_OPT_INT,
783 .off1 = td_var_offset(open_files),
784 .help = "Number of files to keep open at the same time",
785 },
786 {
787 .name = "file_service_type",
788 .type = FIO_OPT_STR,
789 .cb = str_fst_cb,
790 .off1 = td_var_offset(file_service_type),
791 .help = "How to select which file to service next",
792 .def = "roundrobin",
793 .posval = {
794 { .ival = "random",
795 .oval = FIO_FSERVICE_RANDOM,
796 .help = "Choose a file at random",
797 },
798 { .ival = "roundrobin",
799 .oval = FIO_FSERVICE_RR,
800 .help = "Round robin select files",
801 },
802 },
Jens Axboe67a10002007-07-31 23:12:16 +0200803 .parent = "nrfiles",
804 },
805 {
806 .name = "fadvise_hint",
807 .type = FIO_OPT_BOOL,
808 .off1 = td_var_offset(fadvise_hint),
809 .help = "Use fadvise() to advise the kernel on IO pattern",
810 .def = "1",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100811 },
812 {
813 .name = "fsync",
814 .type = FIO_OPT_INT,
815 .off1 = td_var_offset(fsync_blocks),
816 .help = "Issue fsync for writes every given number of blocks",
817 .def = "0",
818 },
819 {
820 .name = "direct",
821 .type = FIO_OPT_BOOL,
822 .off1 = td_var_offset(odirect),
823 .help = "Use O_DIRECT IO (negates buffered)",
824 .def = "0",
825 },
826 {
827 .name = "buffered",
828 .type = FIO_OPT_BOOL,
829 .off1 = td_var_offset(odirect),
830 .neg = 1,
831 .help = "Use buffered IO (negates direct)",
832 .def = "1",
833 },
834 {
835 .name = "overwrite",
836 .type = FIO_OPT_BOOL,
837 .off1 = td_var_offset(overwrite),
838 .help = "When writing, set whether to overwrite current data",
839 .def = "0",
840 },
841 {
842 .name = "loops",
843 .type = FIO_OPT_INT,
844 .off1 = td_var_offset(loops),
845 .help = "Number of times to run the job",
846 .def = "1",
847 },
848 {
849 .name = "numjobs",
850 .type = FIO_OPT_INT,
851 .off1 = td_var_offset(numjobs),
852 .help = "Duplicate this job this many times",
853 .def = "1",
854 },
855 {
856 .name = "startdelay",
857 .type = FIO_OPT_INT,
858 .off1 = td_var_offset(start_delay),
859 .help = "Only start job when this period has passed",
860 .def = "0",
861 },
862 {
863 .name = "runtime",
864 .alias = "timeout",
865 .type = FIO_OPT_STR_VAL_TIME,
866 .off1 = td_var_offset(timeout),
867 .help = "Stop workload when this amount of time has passed",
868 .def = "0",
869 },
870 {
Jens Axboecf4464c2007-04-17 20:14:42 +0200871 .name = "time_based",
872 .type = FIO_OPT_STR_SET,
873 .off1 = td_var_offset(time_based),
874 .help = "Keep running until runtime/timeout is met",
875 },
876 {
Jens Axboe721938a2008-09-10 09:46:16 +0200877 .name = "ramp_time",
878 .type = FIO_OPT_STR_VAL_TIME,
879 .off1 = td_var_offset(ramp_time),
880 .help = "Ramp up time before measuring performance",
881 },
882 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100883 .name = "mem",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100884 .alias = "iomem",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100885 .type = FIO_OPT_STR,
886 .cb = str_mem_cb,
887 .off1 = td_var_offset(mem_type),
888 .help = "Backing type for IO buffers",
889 .def = "malloc",
890 .posval = {
891 { .ival = "malloc",
892 .oval = MEM_MALLOC,
893 .help = "Use malloc(3) for IO buffers",
894 },
Jens Axboeb370e462007-03-19 10:51:49 +0100895 { .ival = "shm",
896 .oval = MEM_SHM,
897 .help = "Use shared memory segments for IO buffers",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100898 },
899#ifdef FIO_HAVE_HUGETLB
Jens Axboe37c8cdf2007-03-19 13:14:03 +0100900 { .ival = "shmhuge",
901 .oval = MEM_SHMHUGE,
902 .help = "Like shm, but use huge pages",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100903 },
904#endif
Jens Axboeb370e462007-03-19 10:51:49 +0100905 { .ival = "mmap",
906 .oval = MEM_MMAP,
907 .help = "Use mmap(2) (file or anon) for IO buffers",
908 },
Jens Axboe37c8cdf2007-03-19 13:14:03 +0100909#ifdef FIO_HAVE_HUGETLB
910 { .ival = "mmaphuge",
911 .oval = MEM_MMAPHUGE,
912 .help = "Like mmap, but use huge pages",
913 },
914#endif
Jens Axboe214e1ec2007-03-15 10:48:13 +0100915 },
916 },
917 {
918 .name = "verify",
919 .type = FIO_OPT_STR,
920 .off1 = td_var_offset(verify),
921 .help = "Verify data written",
922 .def = "0",
923 .posval = {
924 { .ival = "0",
925 .oval = VERIFY_NONE,
926 .help = "Don't do IO verification",
927 },
Jens Axboefcca4b52007-07-27 15:42:00 +0200928 { .ival = "md5",
929 .oval = VERIFY_MD5,
930 .help = "Use md5 checksums for verification",
931 },
Jens Axboed77a7af2007-07-27 15:35:06 +0200932 { .ival = "crc64",
933 .oval = VERIFY_CRC64,
934 .help = "Use crc64 checksums for verification",
935 },
Jens Axboe214e1ec2007-03-15 10:48:13 +0100936 { .ival = "crc32",
937 .oval = VERIFY_CRC32,
938 .help = "Use crc32 checksums for verification",
939 },
Jens Axboeaf497e62008-08-04 15:40:35 +0200940 { .ival = "crc32c-intel",
941 .oval = VERIFY_CRC32C_INTEL,
942 .help = "Use hw crc32c checksums for verification",
943 },
Jens Axboebac39e02008-06-11 20:46:19 +0200944 { .ival = "crc32c",
945 .oval = VERIFY_CRC32C,
946 .help = "Use crc32c checksums for verification",
947 },
Jens Axboe969f7ed2007-07-27 09:07:17 +0200948 { .ival = "crc16",
949 .oval = VERIFY_CRC16,
950 .help = "Use crc16 checksums for verification",
951 },
Jens Axboe1e154bd2007-07-27 09:52:40 +0200952 { .ival = "crc7",
953 .oval = VERIFY_CRC7,
954 .help = "Use crc7 checksums for verification",
955 },
Jens Axboecd14cc12007-07-30 10:59:33 +0200956 { .ival = "sha256",
957 .oval = VERIFY_SHA256,
958 .help = "Use sha256 checksums for verification",
959 },
960 { .ival = "sha512",
961 .oval = VERIFY_SHA512,
962 .help = "Use sha512 checksums for verification",
963 },
Shawn Lewis7437ee82007-08-02 21:05:58 +0200964 { .ival = "meta",
965 .oval = VERIFY_META,
966 .help = "Use io information",
967 },
Jens Axboe36690c92007-03-26 10:23:34 +0200968 {
969 .ival = "null",
970 .oval = VERIFY_NULL,
971 .help = "Pretend to verify",
972 },
Jens Axboe214e1ec2007-03-15 10:48:13 +0100973 },
974 },
975 {
Jens Axboe005c5652007-08-02 22:21:36 +0200976 .name = "do_verify",
Jens Axboe68e1f292007-08-10 10:32:14 +0200977 .type = FIO_OPT_BOOL,
Jens Axboe005c5652007-08-02 22:21:36 +0200978 .off1 = td_var_offset(do_verify),
979 .help = "Run verification stage after write",
980 .def = "1",
981 .parent = "verify",
982 },
983 {
Jens Axboe160b9662007-03-27 10:59:49 +0200984 .name = "verifysort",
985 .type = FIO_OPT_BOOL,
986 .off1 = td_var_offset(verifysort),
987 .help = "Sort written verify blocks for read back",
988 .def = "1",
Jens Axboec83f2df2007-07-31 22:51:47 +0200989 .parent = "verify",
Jens Axboe160b9662007-03-27 10:59:49 +0200990 },
991 {
Jens Axboea59e1702007-07-30 08:53:27 +0200992 .name = "verify_interval",
Shawn Lewis3f9f4e22007-07-28 21:10:37 +0200993 .type = FIO_OPT_STR_VAL_INT,
Jens Axboea59e1702007-07-30 08:53:27 +0200994 .off1 = td_var_offset(verify_interval),
Jens Axboe819a9682007-07-28 21:30:31 +0200995 .minval = 2 * sizeof(struct verify_header),
Jens Axboea59e1702007-07-30 08:53:27 +0200996 .help = "Store verify buffer header every N bytes",
Jens Axboeafdf9352007-07-31 16:14:34 +0200997 .parent = "verify",
Shawn Lewis3f9f4e22007-07-28 21:10:37 +0200998 },
999 {
Jens Axboea59e1702007-07-30 08:53:27 +02001000 .name = "verify_offset",
Shawn Lewis546a9142007-07-28 21:11:37 +02001001 .type = FIO_OPT_STR_VAL_INT,
Jens Axboea59e1702007-07-30 08:53:27 +02001002 .help = "Offset verify header location by N bytes",
Shawn Lewis546a9142007-07-28 21:11:37 +02001003 .def = "0",
Jens Axboe5ec10ea2008-03-06 15:42:00 +01001004 .cb = str_verify_offset_cb,
Jens Axboeafdf9352007-07-31 16:14:34 +02001005 .parent = "verify",
Shawn Lewis546a9142007-07-28 21:11:37 +02001006 },
1007 {
Shawn Lewise28218f2008-01-16 11:01:33 +01001008 .name = "verify_pattern",
1009 .type = FIO_OPT_INT,
1010 .cb = str_verify_pattern_cb,
1011 .help = "Fill pattern for IO buffers",
1012 .parent = "verify",
1013 },
1014 {
Jens Axboea12a3b42007-08-09 10:20:54 +02001015 .name = "verify_fatal",
Jens Axboe68e1f292007-08-10 10:32:14 +02001016 .type = FIO_OPT_BOOL,
Jens Axboea12a3b42007-08-09 10:20:54 +02001017 .off1 = td_var_offset(verify_fatal),
1018 .def = "0",
1019 .help = "Exit on a single verify failure, don't continue",
1020 .parent = "verify",
1021 },
1022 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001023 .name = "write_iolog",
1024 .type = FIO_OPT_STR_STORE,
1025 .off1 = td_var_offset(write_iolog_file),
1026 .help = "Store IO pattern to file",
1027 },
1028 {
1029 .name = "read_iolog",
1030 .type = FIO_OPT_STR_STORE,
1031 .off1 = td_var_offset(read_iolog_file),
1032 .help = "Playback IO pattern from file",
1033 },
1034 {
1035 .name = "exec_prerun",
1036 .type = FIO_OPT_STR_STORE,
1037 .off1 = td_var_offset(exec_prerun),
1038 .help = "Execute this file prior to running job",
1039 },
1040 {
1041 .name = "exec_postrun",
1042 .type = FIO_OPT_STR_STORE,
1043 .off1 = td_var_offset(exec_postrun),
1044 .help = "Execute this file after running job",
1045 },
1046#ifdef FIO_HAVE_IOSCHED_SWITCH
1047 {
1048 .name = "ioscheduler",
1049 .type = FIO_OPT_STR_STORE,
1050 .off1 = td_var_offset(ioscheduler),
1051 .help = "Use this IO scheduler on the backing device",
1052 },
1053#endif
1054 {
1055 .name = "zonesize",
1056 .type = FIO_OPT_STR_VAL,
1057 .off1 = td_var_offset(zone_size),
1058 .help = "Give size of an IO zone",
1059 .def = "0",
1060 },
1061 {
1062 .name = "zoneskip",
1063 .type = FIO_OPT_STR_VAL,
1064 .off1 = td_var_offset(zone_skip),
1065 .help = "Space between IO zones",
1066 .def = "0",
1067 },
1068 {
1069 .name = "lockmem",
1070 .type = FIO_OPT_STR_VAL,
1071 .cb = str_lockmem_cb,
1072 .help = "Lock down this amount of memory",
1073 .def = "0",
1074 },
1075 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001076 .name = "rwmixread",
1077 .type = FIO_OPT_INT,
Jens Axboecb499fc2008-05-28 10:33:32 +02001078 .cb = str_rwmix_read_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001079 .maxval = 100,
1080 .help = "Percentage of mixed workload that is reads",
1081 .def = "50",
1082 },
1083 {
1084 .name = "rwmixwrite",
1085 .type = FIO_OPT_INT,
Jens Axboecb499fc2008-05-28 10:33:32 +02001086 .cb = str_rwmix_write_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001087 .maxval = 100,
1088 .help = "Percentage of mixed workload that is writes",
1089 .def = "50",
1090 },
1091 {
Jens Axboeafdf9352007-07-31 16:14:34 +02001092 .name = "rwmixcycle",
Jens Axboe15ca1502008-04-07 09:26:02 +02001093 .type = FIO_OPT_DEPRECATED,
Jens Axboeafdf9352007-07-31 16:14:34 +02001094 },
1095 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001096 .name = "nice",
1097 .type = FIO_OPT_INT,
1098 .off1 = td_var_offset(nice),
1099 .help = "Set job CPU nice value",
1100 .minval = -19,
1101 .maxval = 20,
1102 .def = "0",
1103 },
1104#ifdef FIO_HAVE_IOPRIO
1105 {
1106 .name = "prio",
1107 .type = FIO_OPT_INT,
1108 .cb = str_prio_cb,
1109 .help = "Set job IO priority value",
1110 .minval = 0,
1111 .maxval = 7,
1112 },
1113 {
1114 .name = "prioclass",
1115 .type = FIO_OPT_INT,
1116 .cb = str_prioclass_cb,
1117 .help = "Set job IO priority class",
1118 .minval = 0,
1119 .maxval = 3,
1120 },
1121#endif
1122 {
1123 .name = "thinktime",
1124 .type = FIO_OPT_INT,
1125 .off1 = td_var_offset(thinktime),
1126 .help = "Idle time between IO buffers (usec)",
1127 .def = "0",
1128 },
1129 {
1130 .name = "thinktime_spin",
1131 .type = FIO_OPT_INT,
1132 .off1 = td_var_offset(thinktime_spin),
1133 .help = "Start think time by spinning this amount (usec)",
1134 .def = "0",
Jens Axboeafdf9352007-07-31 16:14:34 +02001135 .parent = "thinktime",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001136 },
1137 {
1138 .name = "thinktime_blocks",
1139 .type = FIO_OPT_INT,
1140 .off1 = td_var_offset(thinktime_blocks),
1141 .help = "IO buffer period between 'thinktime'",
1142 .def = "1",
Jens Axboeafdf9352007-07-31 16:14:34 +02001143 .parent = "thinktime",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001144 },
1145 {
1146 .name = "rate",
1147 .type = FIO_OPT_INT,
1148 .off1 = td_var_offset(rate),
1149 .help = "Set bandwidth rate",
1150 },
1151 {
1152 .name = "ratemin",
1153 .type = FIO_OPT_INT,
1154 .off1 = td_var_offset(ratemin),
Jens Axboe4e991c22007-03-15 11:41:11 +01001155 .help = "Job must meet this rate or it will be shutdown",
Jens Axboeafdf9352007-07-31 16:14:34 +02001156 .parent = "rate",
Jens Axboe4e991c22007-03-15 11:41:11 +01001157 },
1158 {
1159 .name = "rate_iops",
1160 .type = FIO_OPT_INT,
1161 .off1 = td_var_offset(rate_iops),
1162 .help = "Limit IO used to this number of IO operations/sec",
1163 },
1164 {
1165 .name = "rate_iops_min",
1166 .type = FIO_OPT_INT,
1167 .off1 = td_var_offset(rate_iops_min),
1168 .help = "Job must meet this rate or it will be shutdown",
Jens Axboeafdf9352007-07-31 16:14:34 +02001169 .parent = "rate_iops",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001170 },
1171 {
1172 .name = "ratecycle",
1173 .type = FIO_OPT_INT,
1174 .off1 = td_var_offset(ratecycle),
1175 .help = "Window average for rate limits (msec)",
1176 .def = "1000",
Jens Axboeafdf9352007-07-31 16:14:34 +02001177 .parent = "rate",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001178 },
1179 {
1180 .name = "invalidate",
1181 .type = FIO_OPT_BOOL,
1182 .off1 = td_var_offset(invalidate_cache),
1183 .help = "Invalidate buffer/page cache prior to running job",
1184 .def = "1",
1185 },
1186 {
1187 .name = "sync",
1188 .type = FIO_OPT_BOOL,
1189 .off1 = td_var_offset(sync_io),
1190 .help = "Use O_SYNC for buffered writes",
1191 .def = "0",
Jens Axboe67a10002007-07-31 23:12:16 +02001192 .parent = "buffered",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001193 },
1194 {
1195 .name = "bwavgtime",
1196 .type = FIO_OPT_INT,
1197 .off1 = td_var_offset(bw_avg_time),
Jens Axboe5ec10ea2008-03-06 15:42:00 +01001198 .help = "Time window over which to calculate bandwidth"
1199 " (msec)",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001200 .def = "500",
1201 },
1202 {
1203 .name = "create_serialize",
1204 .type = FIO_OPT_BOOL,
1205 .off1 = td_var_offset(create_serialize),
1206 .help = "Serialize creating of job files",
1207 .def = "1",
1208 },
1209 {
1210 .name = "create_fsync",
1211 .type = FIO_OPT_BOOL,
1212 .off1 = td_var_offset(create_fsync),
1213 .help = "Fsync file after creation",
1214 .def = "1",
1215 },
1216 {
1217 .name = "cpuload",
1218 .type = FIO_OPT_INT,
1219 .off1 = td_var_offset(cpuload),
1220 .help = "Use this percentage of CPU",
1221 },
1222 {
1223 .name = "cpuchunks",
1224 .type = FIO_OPT_INT,
1225 .off1 = td_var_offset(cpucycle),
1226 .help = "Length of the CPU burn cycles (usecs)",
1227 .def = "50000",
Jens Axboe67a10002007-07-31 23:12:16 +02001228 .parent = "cpuload",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001229 },
1230#ifdef FIO_HAVE_CPU_AFFINITY
1231 {
1232 .name = "cpumask",
1233 .type = FIO_OPT_INT,
1234 .cb = str_cpumask_cb,
1235 .help = "CPU affinity mask",
1236 },
Jens Axboed2e268b2007-06-15 10:33:49 +02001237 {
1238 .name = "cpus_allowed",
1239 .type = FIO_OPT_STR,
1240 .cb = str_cpus_allowed_cb,
1241 .help = "Set CPUs allowed",
1242 },
Jens Axboe214e1ec2007-03-15 10:48:13 +01001243#endif
1244 {
1245 .name = "end_fsync",
1246 .type = FIO_OPT_BOOL,
1247 .off1 = td_var_offset(end_fsync),
1248 .help = "Include fsync at the end of job",
1249 .def = "0",
1250 },
1251 {
1252 .name = "fsync_on_close",
1253 .type = FIO_OPT_BOOL,
1254 .off1 = td_var_offset(fsync_on_close),
1255 .help = "fsync files on close",
1256 .def = "0",
1257 },
1258 {
1259 .name = "unlink",
1260 .type = FIO_OPT_BOOL,
1261 .off1 = td_var_offset(unlink),
1262 .help = "Unlink created files after job has completed",
1263 .def = "0",
1264 },
1265 {
1266 .name = "exitall",
1267 .type = FIO_OPT_STR_SET,
1268 .cb = str_exitall_cb,
1269 .help = "Terminate all jobs when one exits",
1270 },
1271 {
1272 .name = "stonewall",
1273 .type = FIO_OPT_STR_SET,
1274 .off1 = td_var_offset(stonewall),
1275 .help = "Insert a hard barrier between this job and previous",
1276 },
1277 {
Jens Axboeb3d62a72007-03-20 14:23:26 +01001278 .name = "new_group",
1279 .type = FIO_OPT_STR_SET,
1280 .off1 = td_var_offset(new_group),
1281 .help = "Mark the start of a new group (for reporting)",
1282 },
1283 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001284 .name = "thread",
1285 .type = FIO_OPT_STR_SET,
1286 .off1 = td_var_offset(use_thread),
1287 .help = "Use threads instead of forks",
1288 },
1289 {
1290 .name = "write_bw_log",
Jens Axboee3cedca2008-11-19 19:57:52 +01001291 .type = FIO_OPT_STR,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001292 .off1 = td_var_offset(write_bw_log),
Jens Axboee3cedca2008-11-19 19:57:52 +01001293 .cb = str_write_bw_log_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001294 .help = "Write log of bandwidth during run",
1295 },
1296 {
1297 .name = "write_lat_log",
Jens Axboee3cedca2008-11-19 19:57:52 +01001298 .type = FIO_OPT_STR,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001299 .off1 = td_var_offset(write_lat_log),
Jens Axboee3cedca2008-11-19 19:57:52 +01001300 .cb = str_write_lat_log_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001301 .help = "Write log of latency during run",
1302 },
1303 {
1304 .name = "hugepage-size",
Aaron Carroll357f6182008-02-20 09:14:13 +01001305 .type = FIO_OPT_STR_VAL_INT,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001306 .off1 = td_var_offset(hugepage_size),
1307 .help = "When using hugepages, specify size of each page",
1308 .def = __stringify(FIO_HUGE_PAGE),
1309 },
1310 {
1311 .name = "group_reporting",
1312 .type = FIO_OPT_STR_SET,
1313 .off1 = td_var_offset(group_reporting),
1314 .help = "Do reporting on a per-group basis",
1315 },
1316 {
Jens Axboee9459e52007-04-17 15:46:32 +02001317 .name = "zero_buffers",
1318 .type = FIO_OPT_STR_SET,
1319 .off1 = td_var_offset(zero_buffers),
1320 .help = "Init IO buffers to all zeroes",
1321 },
Jens Axboe5973caf2008-05-21 19:52:35 +02001322 {
1323 .name = "refill_buffers",
1324 .type = FIO_OPT_STR_SET,
1325 .off1 = td_var_offset(refill_buffers),
1326 .help = "Refill IO buffers on every IO submit",
1327 },
Jens Axboe0a839f32007-04-26 09:02:34 +02001328#ifdef FIO_HAVE_DISK_UTIL
1329 {
1330 .name = "disk_util",
1331 .type = FIO_OPT_BOOL,
1332 .off1 = td_var_offset(do_disk_util),
Jens Axboef66ab3c2008-06-05 11:48:22 +02001333 .help = "Log disk utilization statistics",
Jens Axboe0a839f32007-04-26 09:02:34 +02001334 .def = "1",
1335 },
1336#endif
Jens Axboee9459e52007-04-17 15:46:32 +02001337 {
Jens Axboe993bf482008-11-14 13:04:53 +01001338 .name = "gtod_reduce",
1339 .type = FIO_OPT_BOOL,
1340 .help = "Greatly reduce number of gettimeofday() calls",
1341 .cb = str_gtod_reduce_cb,
1342 .def = "0",
1343 },
1344 {
Jens Axboe9520ebb2008-10-16 21:03:27 +02001345 .name = "disable_clat",
1346 .type = FIO_OPT_BOOL,
1347 .off1 = td_var_offset(disable_clat),
1348 .help = "Disable completion latency numbers",
Jens Axboe993bf482008-11-14 13:04:53 +01001349 .parent = "gtod_reduce",
Jens Axboe9520ebb2008-10-16 21:03:27 +02001350 .def = "0",
1351 },
1352 {
1353 .name = "disable_slat",
1354 .type = FIO_OPT_BOOL,
1355 .off1 = td_var_offset(disable_slat),
1356 .help = "Disable submissionn latency numbers",
Jens Axboe993bf482008-11-14 13:04:53 +01001357 .parent = "gtod_reduce",
Jens Axboe9520ebb2008-10-16 21:03:27 +02001358 .def = "0",
1359 },
1360 {
1361 .name = "disable_bw_measurement",
1362 .type = FIO_OPT_BOOL,
1363 .off1 = td_var_offset(disable_bw),
1364 .help = "Disable bandwidth logging",
Jens Axboe993bf482008-11-14 13:04:53 +01001365 .parent = "gtod_reduce",
Jens Axboe9520ebb2008-10-16 21:03:27 +02001366 .def = "0",
1367 },
1368 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001369 .name = NULL,
1370 },
1371};
1372
1373void fio_options_dup_and_init(struct option *long_options)
1374{
1375 struct fio_option *o;
1376 unsigned int i;
1377
1378 options_init(options);
1379
1380 i = 0;
1381 while (long_options[i].name)
1382 i++;
1383
1384 o = &options[0];
1385 while (o->name) {
Jens Axboe5921e802008-05-30 15:02:38 +02001386 long_options[i].name = (char *) o->name;
Jens Axboe214e1ec2007-03-15 10:48:13 +01001387 long_options[i].val = FIO_GETOPT_JOB;
1388 if (o->type == FIO_OPT_STR_SET)
1389 long_options[i].has_arg = no_argument;
1390 else
1391 long_options[i].has_arg = required_argument;
1392
1393 i++;
1394 o++;
1395 assert(i < FIO_NR_OPTIONS);
1396 }
1397}
1398
Jens Axboe3b8b7132008-06-10 19:46:23 +02001399int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
Jens Axboe214e1ec2007-03-15 10:48:13 +01001400{
Jens Axboe3b8b7132008-06-10 19:46:23 +02001401 int i, ret;
1402
1403 sort_options(opts, options, num_opts);
1404
1405 for (ret = 0, i = 0; i < num_opts; i++)
1406 ret |= parse_option(opts[i], options, td);
1407
1408 return ret;
Jens Axboe214e1ec2007-03-15 10:48:13 +01001409}
1410
1411int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
1412{
1413 return parse_cmd_option(opt, val, options, td);
1414}
1415
1416void fio_fill_default_options(struct thread_data *td)
1417{
1418 fill_default_options(td, options);
1419}
1420
1421int fio_show_option_help(const char *opt)
1422{
1423 return show_cmd_help(options, opt);
1424}
Jens Axboed23bb322007-03-23 15:57:56 +01001425
1426static void __options_mem(struct thread_data *td, int alloc)
1427{
1428 struct thread_options *o = &td->o;
1429 struct fio_option *opt;
1430 char **ptr;
1431 int i;
1432
1433 for (i = 0, opt = &options[0]; opt->name; i++, opt = &options[i]) {
1434 if (opt->type != FIO_OPT_STR_STORE)
1435 continue;
1436
1437 ptr = (void *) o + opt->off1;
1438 if (*ptr) {
1439 if (alloc)
1440 *ptr = strdup(*ptr);
1441 else {
1442 free(*ptr);
1443 *ptr = NULL;
1444 }
1445 }
1446 }
1447}
1448
1449/*
1450 * dupe FIO_OPT_STR_STORE options
1451 */
1452void options_mem_dupe(struct thread_data *td)
1453{
1454 __options_mem(td, 1);
1455}
1456
Jens Axboe22d66212007-03-27 20:06:25 +02001457void options_mem_free(struct thread_data fio_unused *td)
Jens Axboed23bb322007-03-23 15:57:56 +01001458{
Jens Axboe22d66212007-03-27 20:06:25 +02001459#if 0
Jens Axboed23bb322007-03-23 15:57:56 +01001460 __options_mem(td, 0);
Jens Axboe22d66212007-03-27 20:06:25 +02001461#endif
Jens Axboed23bb322007-03-23 15:57:56 +01001462}