blob: bd7a85e528d554d0f66ecdce74d3f45b3ba7b6a6 [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"
Jens Axboe4f5af7b2009-06-03 08:45:40 +020014#include "verify.h"
Jens Axboe214e1ec2007-03-15 10:48:13 +010015#include "parse.h"
Jens Axboeeef32352008-06-02 13:31:26 +020016#include "lib/fls.h"
Jens Axboe214e1ec2007-03-15 10:48:13 +010017
Jens Axboea639f0b2009-07-18 08:25:35 +020018unsigned int fio_kb_base = 1024;
19
Jens Axboe2dc1bbe2007-03-15 15:01:33 +010020#define td_var_offset(var) ((size_t) &((struct thread_options *)0)->var)
Jens Axboe214e1ec2007-03-15 10:48:13 +010021
22/*
23 * Check if mmap/mmaphuge has a :/foo/bar/file at the end. If so, return that.
24 */
25static char *get_opt_postfix(const char *str)
26{
27 char *p = strstr(str, ":");
28
29 if (!p)
30 return NULL;
31
32 p++;
33 strip_blank_front(&p);
34 strip_blank_end(p);
35 return strdup(p);
36}
37
Jens Axboe564ca972007-12-14 12:21:19 +010038static int bs_cmp(const void *p1, const void *p2)
39{
40 const struct bssplit *bsp1 = p1;
41 const struct bssplit *bsp2 = p2;
42
43 return bsp1->perc < bsp2->perc;
44}
45
Jens Axboe720e84a2009-04-21 08:29:55 +020046static int bssplit_ddir(struct thread_data *td, int ddir, char *str)
Jens Axboe564ca972007-12-14 12:21:19 +010047{
Jens Axboe720e84a2009-04-21 08:29:55 +020048 struct bssplit *bssplit;
Jens Axboe564ca972007-12-14 12:21:19 +010049 unsigned int i, perc, perc_missing;
50 unsigned int max_bs, min_bs;
51 long long val;
Jens Axboe720e84a2009-04-21 08:29:55 +020052 char *fname;
Jens Axboe564ca972007-12-14 12:21:19 +010053
Jens Axboe720e84a2009-04-21 08:29:55 +020054 td->o.bssplit_nr[ddir] = 4;
55 bssplit = malloc(4 * sizeof(struct bssplit));
Jens Axboe564ca972007-12-14 12:21:19 +010056
57 i = 0;
58 max_bs = 0;
59 min_bs = -1;
60 while ((fname = strsep(&str, ":")) != NULL) {
61 char *perc_str;
62
63 if (!strlen(fname))
64 break;
65
66 /*
67 * grow struct buffer, if needed
68 */
Jens Axboe720e84a2009-04-21 08:29:55 +020069 if (i == td->o.bssplit_nr[ddir]) {
70 td->o.bssplit_nr[ddir] <<= 1;
71 bssplit = realloc(bssplit, td->o.bssplit_nr[ddir]
Jens Axboe5ec10ea2008-03-06 15:42:00 +010072 * sizeof(struct bssplit));
Jens Axboe564ca972007-12-14 12:21:19 +010073 }
74
75 perc_str = strstr(fname, "/");
76 if (perc_str) {
77 *perc_str = '\0';
78 perc_str++;
79 perc = atoi(perc_str);
80 if (perc > 100)
81 perc = 100;
82 else if (!perc)
83 perc = -1;
84 } else
85 perc = -1;
86
87 if (str_to_decimal(fname, &val, 1)) {
88 log_err("fio: bssplit conversion failed\n");
89 free(td->o.bssplit);
90 return 1;
91 }
92
93 if (val > max_bs)
94 max_bs = val;
95 if (val < min_bs)
96 min_bs = val;
97
Jens Axboe720e84a2009-04-21 08:29:55 +020098 bssplit[i].bs = val;
99 bssplit[i].perc = perc;
Jens Axboe564ca972007-12-14 12:21:19 +0100100 i++;
101 }
102
Jens Axboe720e84a2009-04-21 08:29:55 +0200103 td->o.bssplit_nr[ddir] = i;
Jens Axboe564ca972007-12-14 12:21:19 +0100104
105 /*
106 * Now check if the percentages add up, and how much is missing
107 */
108 perc = perc_missing = 0;
Jens Axboe720e84a2009-04-21 08:29:55 +0200109 for (i = 0; i < td->o.bssplit_nr[ddir]; i++) {
110 struct bssplit *bsp = &bssplit[i];
Jens Axboe564ca972007-12-14 12:21:19 +0100111
112 if (bsp->perc == (unsigned char) -1)
113 perc_missing++;
114 else
115 perc += bsp->perc;
116 }
117
118 if (perc > 100) {
119 log_err("fio: bssplit percentages add to more than 100%%\n");
Jens Axboe720e84a2009-04-21 08:29:55 +0200120 free(bssplit);
Jens Axboe564ca972007-12-14 12:21:19 +0100121 return 1;
122 }
123 /*
124 * If values didn't have a percentage set, divide the remains between
125 * them.
126 */
127 if (perc_missing) {
Jens Axboe720e84a2009-04-21 08:29:55 +0200128 for (i = 0; i < td->o.bssplit_nr[ddir]; i++) {
129 struct bssplit *bsp = &bssplit[i];
Jens Axboe564ca972007-12-14 12:21:19 +0100130
131 if (bsp->perc == (unsigned char) -1)
132 bsp->perc = (100 - perc) / perc_missing;
133 }
134 }
135
Jens Axboe720e84a2009-04-21 08:29:55 +0200136 td->o.min_bs[ddir] = min_bs;
137 td->o.max_bs[ddir] = max_bs;
Jens Axboe564ca972007-12-14 12:21:19 +0100138
139 /*
140 * now sort based on percentages, for ease of lookup
141 */
Jens Axboe720e84a2009-04-21 08:29:55 +0200142 qsort(bssplit, td->o.bssplit_nr[ddir], sizeof(struct bssplit), bs_cmp);
143 td->o.bssplit[ddir] = bssplit;
144 return 0;
145
146}
147
148static int str_bssplit_cb(void *data, const char *input)
149{
150 struct thread_data *td = data;
151 char *str, *p, *odir;
152 int ret = 0;
153
154 p = str = strdup(input);
155
156 strip_blank_front(&str);
157 strip_blank_end(str);
158
159 odir = strchr(str, ',');
160 if (odir) {
161 ret = bssplit_ddir(td, DDIR_WRITE, odir + 1);
162 if (!ret) {
163 *odir = '\0';
164 ret = bssplit_ddir(td, DDIR_READ, str);
165 }
166 } else {
167 char *op;
168
169 op = strdup(str);
170
171 ret = bssplit_ddir(td, DDIR_READ, str);
172 if (!ret)
173 ret = bssplit_ddir(td, DDIR_WRITE, op);
174
175 free(op);
176 }
Jens Axboe564ca972007-12-14 12:21:19 +0100177
178 free(p);
Jens Axboe720e84a2009-04-21 08:29:55 +0200179 return ret;
Jens Axboe564ca972007-12-14 12:21:19 +0100180}
181
Jens Axboe211097b2007-03-22 18:56:45 +0100182static int str_rw_cb(void *data, const char *str)
183{
184 struct thread_data *td = data;
185 char *nr = get_opt_postfix(str);
186
Jens Axboefafdba32007-03-26 10:09:12 +0200187 td->o.ddir_nr = 1;
Jens Axboe182ec6e2008-11-14 13:06:06 +0100188 if (nr) {
Jens Axboe211097b2007-03-22 18:56:45 +0100189 td->o.ddir_nr = atoi(nr);
Jens Axboe182ec6e2008-11-14 13:06:06 +0100190 free(nr);
191 }
Jens Axboe211097b2007-03-22 18:56:45 +0100192
Jens Axboe211097b2007-03-22 18:56:45 +0100193 return 0;
194}
195
Jens Axboe214e1ec2007-03-15 10:48:13 +0100196static int str_mem_cb(void *data, const char *mem)
197{
198 struct thread_data *td = data;
199
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100200 if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP) {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100201 td->mmapfile = get_opt_postfix(mem);
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100202 if (td->o.mem_type == MEM_MMAPHUGE && !td->mmapfile) {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100203 log_err("fio: mmaphuge:/path/to/file\n");
204 return 1;
205 }
206 }
207
208 return 0;
209}
210
211static int str_lockmem_cb(void fio_unused *data, unsigned long *val)
212{
213 mlock_size = *val;
214 return 0;
215}
216
Jens Axboecb499fc2008-05-28 10:33:32 +0200217static int str_rwmix_read_cb(void *data, unsigned int *val)
218{
219 struct thread_data *td = data;
220
221 td->o.rwmix[DDIR_READ] = *val;
222 td->o.rwmix[DDIR_WRITE] = 100 - *val;
223 return 0;
224}
225
226static int str_rwmix_write_cb(void *data, unsigned int *val)
227{
228 struct thread_data *td = data;
229
230 td->o.rwmix[DDIR_WRITE] = *val;
231 td->o.rwmix[DDIR_READ] = 100 - *val;
232 return 0;
233}
234
Jens Axboe214e1ec2007-03-15 10:48:13 +0100235#ifdef FIO_HAVE_IOPRIO
236static int str_prioclass_cb(void *data, unsigned int *val)
237{
238 struct thread_data *td = data;
Jens Axboe6cefbe32007-04-18 12:46:56 +0200239 unsigned short mask;
240
241 /*
242 * mask off old class bits, str_prio_cb() may have set a default class
243 */
244 mask = (1 << IOPRIO_CLASS_SHIFT) - 1;
245 td->ioprio &= mask;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100246
247 td->ioprio |= *val << IOPRIO_CLASS_SHIFT;
Jens Axboeac684782007-11-08 08:29:07 +0100248 td->ioprio_set = 1;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100249 return 0;
250}
251
252static int str_prio_cb(void *data, unsigned int *val)
253{
254 struct thread_data *td = data;
255
256 td->ioprio |= *val;
Jens Axboe6cefbe32007-04-18 12:46:56 +0200257
258 /*
259 * If no class is set, assume BE
260 */
261 if ((td->ioprio >> IOPRIO_CLASS_SHIFT) == 0)
262 td->ioprio |= IOPRIO_CLASS_BE << IOPRIO_CLASS_SHIFT;
263
Jens Axboeac684782007-11-08 08:29:07 +0100264 td->ioprio_set = 1;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100265 return 0;
266}
267#endif
268
269static int str_exitall_cb(void)
270{
271 exitall_on_terminate = 1;
272 return 0;
273}
274
Jens Axboe214e1ec2007-03-15 10:48:13 +0100275#ifdef FIO_HAVE_CPU_AFFINITY
Jens Axboe214e1ec2007-03-15 10:48:13 +0100276static int str_cpumask_cb(void *data, unsigned int *val)
277{
278 struct thread_data *td = data;
Jens Axboed2e268b2007-06-15 10:33:49 +0200279 unsigned int i;
Jens Axboeb03daaf2008-12-08 20:31:43 +0100280 long max_cpu;
Jens Axboed2ce18b2008-12-12 20:51:40 +0100281 int ret;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100282
Jens Axboed2ce18b2008-12-12 20:51:40 +0100283 ret = fio_cpuset_init(&td->o.cpumask);
284 if (ret < 0) {
285 log_err("fio: cpuset_init failed\n");
286 td_verror(td, ret, "fio_cpuset_init");
287 return 1;
288 }
289
Jens Axboeb03daaf2008-12-08 20:31:43 +0100290 max_cpu = sysconf(_SC_NPROCESSORS_ONLN);
Jens Axboed2e268b2007-06-15 10:33:49 +0200291
Jens Axboe62a72732008-12-08 11:37:01 +0100292 for (i = 0; i < sizeof(int) * 8; i++) {
293 if ((1 << i) & *val) {
Jens Axboeb03daaf2008-12-08 20:31:43 +0100294 if (i > max_cpu) {
295 log_err("fio: CPU %d too large (max=%ld)\n", i,
296 max_cpu);
297 return 1;
298 }
Jens Axboe62a72732008-12-08 11:37:01 +0100299 dprint(FD_PARSE, "set cpu allowed %d\n", i);
Jens Axboe6d459ee2008-12-12 20:02:58 +0100300 fio_cpu_set(&td->o.cpumask, i);
Jens Axboe62a72732008-12-08 11:37:01 +0100301 }
302 }
Jens Axboed2e268b2007-06-15 10:33:49 +0200303
Jens Axboe375b2692007-05-22 09:13:02 +0200304 td->o.cpumask_set = 1;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100305 return 0;
306}
307
Jens Axboee8462bd2009-07-06 12:59:04 +0200308static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask,
309 const char *input)
Jens Axboed2e268b2007-06-15 10:33:49 +0200310{
Jens Axboed2e268b2007-06-15 10:33:49 +0200311 char *cpu, *str, *p;
Jens Axboeb03daaf2008-12-08 20:31:43 +0100312 long max_cpu;
Jens Axboe19608d62008-12-08 15:03:12 +0100313 int ret = 0;
Jens Axboed2e268b2007-06-15 10:33:49 +0200314
Jens Axboee8462bd2009-07-06 12:59:04 +0200315 ret = fio_cpuset_init(mask);
Jens Axboed2ce18b2008-12-12 20:51:40 +0100316 if (ret < 0) {
317 log_err("fio: cpuset_init failed\n");
318 td_verror(td, ret, "fio_cpuset_init");
319 return 1;
320 }
Jens Axboed2e268b2007-06-15 10:33:49 +0200321
322 p = str = strdup(input);
323
324 strip_blank_front(&str);
325 strip_blank_end(str);
326
Jens Axboeb03daaf2008-12-08 20:31:43 +0100327 max_cpu = sysconf(_SC_NPROCESSORS_ONLN);
328
Jens Axboed2e268b2007-06-15 10:33:49 +0200329 while ((cpu = strsep(&str, ",")) != NULL) {
Jens Axboe62a72732008-12-08 11:37:01 +0100330 char *str2, *cpu2;
331 int icpu, icpu2;
332
Jens Axboed2e268b2007-06-15 10:33:49 +0200333 if (!strlen(cpu))
334 break;
Jens Axboe62a72732008-12-08 11:37:01 +0100335
336 str2 = cpu;
337 icpu2 = -1;
338 while ((cpu2 = strsep(&str2, "-")) != NULL) {
339 if (!strlen(cpu2))
340 break;
341
342 icpu2 = atoi(cpu2);
343 }
344
345 icpu = atoi(cpu);
346 if (icpu2 == -1)
347 icpu2 = icpu;
348 while (icpu <= icpu2) {
Jens Axboe6d459ee2008-12-12 20:02:58 +0100349 if (icpu >= FIO_MAX_CPUS) {
Jens Axboe19608d62008-12-08 15:03:12 +0100350 log_err("fio: your OS only supports up to"
Jens Axboe6d459ee2008-12-12 20:02:58 +0100351 " %d CPUs\n", (int) FIO_MAX_CPUS);
Jens Axboe19608d62008-12-08 15:03:12 +0100352 ret = 1;
353 break;
354 }
Jens Axboeb03daaf2008-12-08 20:31:43 +0100355 if (icpu > max_cpu) {
356 log_err("fio: CPU %d too large (max=%ld)\n",
357 icpu, max_cpu);
358 ret = 1;
359 break;
360 }
361
Jens Axboe62a72732008-12-08 11:37:01 +0100362 dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
Jens Axboee8462bd2009-07-06 12:59:04 +0200363 fio_cpu_set(mask, icpu);
Jens Axboe62a72732008-12-08 11:37:01 +0100364 icpu++;
365 }
Jens Axboe19608d62008-12-08 15:03:12 +0100366 if (ret)
367 break;
Jens Axboed2e268b2007-06-15 10:33:49 +0200368 }
369
370 free(p);
Jens Axboe19608d62008-12-08 15:03:12 +0100371 if (!ret)
372 td->o.cpumask_set = 1;
373 return ret;
Jens Axboed2e268b2007-06-15 10:33:49 +0200374}
Jens Axboee8462bd2009-07-06 12:59:04 +0200375
376static int str_cpus_allowed_cb(void *data, const char *input)
377{
378 struct thread_data *td = data;
379 int ret;
380
381 ret = set_cpus_allowed(td, &td->o.cpumask, input);
382 if (!ret)
383 td->o.cpumask_set = 1;
384
385 return ret;
386}
387
388static int str_verify_cpus_allowed_cb(void *data, const char *input)
389{
390 struct thread_data *td = data;
391 int ret;
392
393 ret = set_cpus_allowed(td, &td->o.verify_cpumask, input);
394 if (!ret)
395 td->o.verify_cpumask_set = 1;
396
397 return ret;
398}
Jens Axboed2e268b2007-06-15 10:33:49 +0200399#endif
400
Jens Axboe214e1ec2007-03-15 10:48:13 +0100401static int str_fst_cb(void *data, const char *str)
402{
403 struct thread_data *td = data;
404 char *nr = get_opt_postfix(str);
405
406 td->file_service_nr = 1;
Jens Axboe182ec6e2008-11-14 13:06:06 +0100407 if (nr) {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100408 td->file_service_nr = atoi(nr);
Jens Axboe182ec6e2008-11-14 13:06:06 +0100409 free(nr);
410 }
Jens Axboe214e1ec2007-03-15 10:48:13 +0100411
412 return 0;
413}
414
Jens Axboe921c7662008-03-26 09:17:55 +0100415static int check_dir(struct thread_data *td, char *fname)
416{
417 char file[PATH_MAX], *dir;
Jens Axboebc838912008-04-07 09:00:54 +0200418 int elen = 0;
Jens Axboe921c7662008-03-26 09:17:55 +0100419
Jens Axboebc838912008-04-07 09:00:54 +0200420 if (td->o.directory) {
421 strcpy(file, td->o.directory);
Jens Axboefcef0b32008-05-26 14:53:24 +0200422 strcat(file, "/");
Jens Axboebc838912008-04-07 09:00:54 +0200423 elen = strlen(file);
424 }
425
Jens Axboefcef0b32008-05-26 14:53:24 +0200426 sprintf(file + elen, "%s", fname);
Jens Axboe921c7662008-03-26 09:17:55 +0100427 dir = dirname(file);
428
Jens Axboefcef0b32008-05-26 14:53:24 +0200429#if 0
430 {
431 struct stat sb;
432 /*
433 * We can't do this on FIO_DISKLESSIO engines. The engine isn't loaded
434 * yet, so we can't do this check right here...
435 */
Jens Axboe921c7662008-03-26 09:17:55 +0100436 if (lstat(dir, &sb) < 0) {
437 int ret = errno;
438
439 log_err("fio: %s is not a directory\n", dir);
440 td_verror(td, ret, "lstat");
441 return 1;
442 }
443
444 if (!S_ISDIR(sb.st_mode)) {
445 log_err("fio: %s is not a directory\n", dir);
446 return 1;
447 }
Jens Axboefcef0b32008-05-26 14:53:24 +0200448 }
449#endif
Jens Axboe921c7662008-03-26 09:17:55 +0100450
451 return 0;
452}
453
Jens Axboe214e1ec2007-03-15 10:48:13 +0100454static int str_filename_cb(void *data, const char *input)
455{
456 struct thread_data *td = data;
457 char *fname, *str, *p;
458
459 p = str = strdup(input);
460
461 strip_blank_front(&str);
462 strip_blank_end(str);
463
464 if (!td->files_index)
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100465 td->o.nr_files = 0;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100466
467 while ((fname = strsep(&str, ":")) != NULL) {
468 if (!strlen(fname))
469 break;
Jens Axboe921c7662008-03-26 09:17:55 +0100470 if (check_dir(td, fname)) {
471 free(p);
472 return 1;
473 }
Jens Axboe214e1ec2007-03-15 10:48:13 +0100474 add_file(td, fname);
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100475 td->o.nr_files++;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100476 }
477
478 free(p);
479 return 0;
480}
481
482static int str_directory_cb(void *data, const char fio_unused *str)
483{
484 struct thread_data *td = data;
485 struct stat sb;
486
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100487 if (lstat(td->o.directory, &sb) < 0) {
Jens Axboe921c7662008-03-26 09:17:55 +0100488 int ret = errno;
489
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100490 log_err("fio: %s is not a directory\n", td->o.directory);
Jens Axboe921c7662008-03-26 09:17:55 +0100491 td_verror(td, ret, "lstat");
Jens Axboe214e1ec2007-03-15 10:48:13 +0100492 return 1;
493 }
494 if (!S_ISDIR(sb.st_mode)) {
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100495 log_err("fio: %s is not a directory\n", td->o.directory);
Jens Axboe214e1ec2007-03-15 10:48:13 +0100496 return 1;
497 }
498
499 return 0;
500}
501
502static int str_opendir_cb(void *data, const char fio_unused *str)
503{
504 struct thread_data *td = data;
505
506 if (!td->files_index)
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100507 td->o.nr_files = 0;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100508
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100509 return add_dir_files(td, td->o.opendir);
Jens Axboe214e1ec2007-03-15 10:48:13 +0100510}
511
Jens Axboea59e1702007-07-30 08:53:27 +0200512static int str_verify_offset_cb(void *data, unsigned int *off)
Shawn Lewis546a9142007-07-28 21:11:37 +0200513{
514 struct thread_data *td = data;
Jens Axboea59e1702007-07-30 08:53:27 +0200515
Shawn Lewis546a9142007-07-28 21:11:37 +0200516 if (*off && *off < sizeof(struct verify_header)) {
Jens Axboea59e1702007-07-30 08:53:27 +0200517 log_err("fio: verify_offset too small\n");
Shawn Lewis546a9142007-07-28 21:11:37 +0200518 return 1;
519 }
Jens Axboea59e1702007-07-30 08:53:27 +0200520
521 td->o.verify_offset = *off;
Shawn Lewis546a9142007-07-28 21:11:37 +0200522 return 0;
523}
524
Shawn Lewise28218f2008-01-16 11:01:33 +0100525static int str_verify_pattern_cb(void *data, unsigned int *off)
Jens Axboe90059d62007-07-30 09:33:12 +0200526{
527 struct thread_data *td = data;
Shawn Lewise28218f2008-01-16 11:01:33 +0100528 unsigned int msb;
Jens Axboe90059d62007-07-30 09:33:12 +0200529
Jens Axboe3c48c2c2008-06-02 12:22:30 +0200530 msb = __fls(*off);
Jens Axboe90059d62007-07-30 09:33:12 +0200531 if (msb <= 8)
532 td->o.verify_pattern_bytes = 1;
533 else if (msb <= 16)
534 td->o.verify_pattern_bytes = 2;
535 else if (msb <= 24)
536 td->o.verify_pattern_bytes = 3;
537 else
538 td->o.verify_pattern_bytes = 4;
539
Shawn Lewise28218f2008-01-16 11:01:33 +0100540 td->o.verify_pattern = *off;
Jens Axboe90059d62007-07-30 09:33:12 +0200541 return 0;
542}
Jens Axboe214e1ec2007-03-15 10:48:13 +0100543
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100544static int str_lockfile_cb(void *data, const char *str)
545{
546 struct thread_data *td = data;
547 char *nr = get_opt_postfix(str);
548
549 td->o.lockfile_batch = 1;
Jens Axboe182ec6e2008-11-14 13:06:06 +0100550 if (nr) {
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100551 td->o.lockfile_batch = atoi(nr);
Jens Axboe182ec6e2008-11-14 13:06:06 +0100552 free(nr);
553 }
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100554
555 return 0;
556}
557
Jens Axboee3cedca2008-11-19 19:57:52 +0100558static int str_write_bw_log_cb(void *data, const char *str)
559{
560 struct thread_data *td = data;
561
562 if (str)
563 td->o.bw_log_file = strdup(str);
564
565 td->o.write_bw_log = 1;
566 return 0;
567}
568
569static int str_write_lat_log_cb(void *data, const char *str)
570{
571 struct thread_data *td = data;
572
573 if (str)
574 td->o.lat_log_file = strdup(str);
575
576 td->o.write_lat_log = 1;
577 return 0;
578}
579
Jens Axboe993bf482008-11-14 13:04:53 +0100580static int str_gtod_reduce_cb(void *data, int *il)
581{
582 struct thread_data *td = data;
583 int val = *il;
584
585 td->o.disable_clat = !!val;
586 td->o.disable_slat = !!val;
587 td->o.disable_bw = !!val;
588 if (val)
589 td->tv_cache_mask = 63;
590
591 return 0;
592}
593
Jens Axboebe4ecfd2008-12-08 14:10:52 +0100594static int str_gtod_cpu_cb(void *data, int *il)
595{
596 struct thread_data *td = data;
597 int val = *il;
598
599 td->o.gtod_cpu = val;
600 td->o.gtod_offload = 1;
601 return 0;
602}
603
Jens Axboe896cac22009-07-01 10:38:35 +0200604static int rw_verify(struct fio_option *o, void *data)
605{
606 struct thread_data *td = data;
607
608 if (read_only && td_write(td)) {
609 log_err("fio: job <%s> has write bit set, but fio is in"
610 " read-only mode\n", td->o.name);
611 return 1;
612 }
613
614 return 0;
615}
616
Jens Axboe276ca4f2009-07-01 10:43:05 +0200617static int gtod_cpu_verify(struct fio_option *o, void *data)
Jens Axboe29d43ff2009-07-01 10:42:18 +0200618{
Jens Axboe276ca4f2009-07-01 10:43:05 +0200619#ifndef FIO_HAVE_CPU_AFFINITY
Jens Axboe29d43ff2009-07-01 10:42:18 +0200620 struct thread_data *td = data;
621
Jens Axboe29d43ff2009-07-01 10:42:18 +0200622 if (td->o.gtod_cpu) {
623 log_err("fio: platform must support CPU affinity for"
624 "gettimeofday() offloading\n");
625 return 1;
626 }
627#endif
628
629 return 0;
630}
631
Jens Axboe90fef2d2009-07-17 22:33:32 +0200632static int kb_base_verify(struct fio_option *o, void *data)
633{
634 struct thread_data *td = data;
635
636 if (td->o.kb_base != 1024 && td->o.kb_base != 1000) {
637 log_err("fio: kb_base set to nonsensical value: %u\n",
638 td->o.kb_base);
639 return 1;
640 }
641
Jens Axboea639f0b2009-07-18 08:25:35 +0200642 fio_kb_base = td->o.kb_base;
Jens Axboe90fef2d2009-07-17 22:33:32 +0200643 return 0;
644}
645
Jens Axboe214e1ec2007-03-15 10:48:13 +0100646#define __stringify_1(x) #x
647#define __stringify(x) __stringify_1(x)
648
649/*
650 * Map of job/command line options
651 */
652static struct fio_option options[] = {
653 {
654 .name = "description",
655 .type = FIO_OPT_STR_STORE,
656 .off1 = td_var_offset(description),
657 .help = "Text job description",
658 },
659 {
660 .name = "name",
661 .type = FIO_OPT_STR_STORE,
662 .off1 = td_var_offset(name),
663 .help = "Name of this job",
664 },
665 {
666 .name = "directory",
667 .type = FIO_OPT_STR_STORE,
668 .off1 = td_var_offset(directory),
669 .cb = str_directory_cb,
670 .help = "Directory to store files in",
671 },
672 {
673 .name = "filename",
674 .type = FIO_OPT_STR_STORE,
675 .off1 = td_var_offset(filename),
676 .cb = str_filename_cb,
Jens Axboef0d524b2009-04-27 08:00:48 +0200677 .prio = -1, /* must come after "directory" */
Jens Axboe214e1ec2007-03-15 10:48:13 +0100678 .help = "File(s) to use for the workload",
679 },
680 {
Jens Axboe90fef2d2009-07-17 22:33:32 +0200681 .name = "kb_base",
682 .type = FIO_OPT_INT,
683 .off1 = td_var_offset(kb_base),
Jens Axboe90fef2d2009-07-17 22:33:32 +0200684 .verify = kb_base_verify,
Jens Axboea639f0b2009-07-18 08:25:35 +0200685 .prio = 1,
Jens Axboe90fef2d2009-07-17 22:33:32 +0200686 .def = "1024",
Jens Axboea639f0b2009-07-18 08:25:35 +0200687 .help = "How many bytes per KB for reporting (1000 or 1024)",
Jens Axboe90fef2d2009-07-17 22:33:32 +0200688 },
689 {
Jens Axboe29c13492008-03-01 19:25:20 +0100690 .name = "lockfile",
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100691 .type = FIO_OPT_STR,
692 .cb = str_lockfile_cb,
693 .off1 = td_var_offset(file_lock_mode),
Jens Axboe29c13492008-03-01 19:25:20 +0100694 .help = "Lock file when doing IO to it",
695 .parent = "filename",
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100696 .def = "none",
697 .posval = {
698 { .ival = "none",
699 .oval = FILE_LOCK_NONE,
700 .help = "No file locking",
701 },
702 { .ival = "exclusive",
703 .oval = FILE_LOCK_EXCLUSIVE,
704 .help = "Exclusive file lock",
705 },
706 {
707 .ival = "readwrite",
708 .oval = FILE_LOCK_READWRITE,
709 .help = "Read vs write lock",
710 },
711 },
Jens Axboe29c13492008-03-01 19:25:20 +0100712 },
713 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100714 .name = "opendir",
715 .type = FIO_OPT_STR_STORE,
716 .off1 = td_var_offset(opendir),
717 .cb = str_opendir_cb,
718 .help = "Recursively add files from this directory and down",
719 },
720 {
721 .name = "rw",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100722 .alias = "readwrite",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100723 .type = FIO_OPT_STR,
Jens Axboe211097b2007-03-22 18:56:45 +0100724 .cb = str_rw_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100725 .off1 = td_var_offset(td_ddir),
726 .help = "IO direction",
727 .def = "read",
Jens Axboe896cac22009-07-01 10:38:35 +0200728 .verify = rw_verify,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100729 .posval = {
730 { .ival = "read",
731 .oval = TD_DDIR_READ,
732 .help = "Sequential read",
733 },
734 { .ival = "write",
735 .oval = TD_DDIR_WRITE,
736 .help = "Sequential write",
737 },
738 { .ival = "randread",
739 .oval = TD_DDIR_RANDREAD,
740 .help = "Random read",
741 },
742 { .ival = "randwrite",
743 .oval = TD_DDIR_RANDWRITE,
744 .help = "Random write",
745 },
746 { .ival = "rw",
747 .oval = TD_DDIR_RW,
748 .help = "Sequential read and write mix",
749 },
750 { .ival = "randrw",
751 .oval = TD_DDIR_RANDRW,
752 .help = "Random read and write mix"
753 },
754 },
755 },
756 {
757 .name = "ioengine",
758 .type = FIO_OPT_STR_STORE,
759 .off1 = td_var_offset(ioengine),
760 .help = "IO engine to use",
761 .def = "sync",
762 .posval = {
763 { .ival = "sync",
764 .help = "Use read/write",
765 },
gurudas paia31041e2007-10-23 15:12:30 +0200766 { .ival = "psync",
767 .help = "Use pread/pwrite",
768 },
Jens Axboe1d2af022008-02-04 10:59:07 +0100769 { .ival = "vsync",
770 .help = "Use readv/writev",
771 },
Jens Axboe214e1ec2007-03-15 10:48:13 +0100772#ifdef FIO_HAVE_LIBAIO
773 { .ival = "libaio",
774 .help = "Linux native asynchronous IO",
775 },
776#endif
777#ifdef FIO_HAVE_POSIXAIO
778 { .ival = "posixaio",
779 .help = "POSIX asynchronous IO",
780 },
781#endif
Jens Axboe417f0062008-06-02 11:59:30 +0200782#ifdef FIO_HAVE_SOLARISAIO
783 { .ival = "solarisaio",
784 .help = "Solaris native asynchronous IO",
785 },
786#endif
Jens Axboe214e1ec2007-03-15 10:48:13 +0100787 { .ival = "mmap",
788 .help = "Memory mapped IO",
789 },
790#ifdef FIO_HAVE_SPLICE
791 { .ival = "splice",
792 .help = "splice/vmsplice based IO",
793 },
Jens Axboe9cce02e2007-06-22 15:42:21 +0200794 { .ival = "netsplice",
795 .help = "splice/vmsplice to/from the network",
796 },
Jens Axboe214e1ec2007-03-15 10:48:13 +0100797#endif
798#ifdef FIO_HAVE_SGIO
799 { .ival = "sg",
800 .help = "SCSI generic v3 IO",
801 },
802#endif
803 { .ival = "null",
804 .help = "Testing engine (no data transfer)",
805 },
806 { .ival = "net",
807 .help = "Network IO",
808 },
809#ifdef FIO_HAVE_SYSLET
810 { .ival = "syslet-rw",
811 .help = "syslet enabled async pread/pwrite IO",
812 },
813#endif
814 { .ival = "cpuio",
815 .help = "CPU cycler burner engine",
816 },
Jens Axboeb8c82a42007-03-21 08:48:26 +0100817#ifdef FIO_HAVE_GUASI
818 { .ival = "guasi",
819 .help = "GUASI IO engine",
820 },
821#endif
Jens Axboe214e1ec2007-03-15 10:48:13 +0100822 { .ival = "external",
823 .help = "Load external engine (append name)",
824 },
825 },
826 },
827 {
828 .name = "iodepth",
829 .type = FIO_OPT_INT,
830 .off1 = td_var_offset(iodepth),
831 .help = "Amount of IO buffers to keep in flight",
Jens Axboe757aff42007-12-12 19:42:13 +0100832 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100833 .def = "1",
834 },
835 {
836 .name = "iodepth_batch",
Jens Axboe49504212008-06-05 09:03:30 +0200837 .alias = "iodepth_batch_submit",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100838 .type = FIO_OPT_INT,
839 .off1 = td_var_offset(iodepth_batch),
Jens Axboed65db442009-01-16 19:15:33 +0100840 .help = "Number of IO buffers to submit in one go",
Jens Axboeafdf9352007-07-31 16:14:34 +0200841 .parent = "iodepth",
Jens Axboea2e6f8a2008-01-18 10:28:11 +0100842 .minval = 1,
843 .def = "1",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100844 },
845 {
Jens Axboe49504212008-06-05 09:03:30 +0200846 .name = "iodepth_batch_complete",
847 .type = FIO_OPT_INT,
848 .off1 = td_var_offset(iodepth_batch_complete),
Jens Axboed65db442009-01-16 19:15:33 +0100849 .help = "Number of IO buffers to retrieve in one go",
Jens Axboe49504212008-06-05 09:03:30 +0200850 .parent = "iodepth",
851 .minval = 0,
852 .def = "1",
853 },
854 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100855 .name = "iodepth_low",
856 .type = FIO_OPT_INT,
857 .off1 = td_var_offset(iodepth_low),
858 .help = "Low water mark for queuing depth",
Jens Axboeafdf9352007-07-31 16:14:34 +0200859 .parent = "iodepth",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100860 },
861 {
862 .name = "size",
863 .type = FIO_OPT_STR_VAL,
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100864 .off1 = td_var_offset(size),
Jens Axboec3edbdb2007-07-20 14:25:31 +0200865 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100866 .help = "Total size of device or files",
867 },
868 {
Shawn Lewisaa31f1f2008-01-11 09:45:11 +0100869 .name = "fill_device",
870 .type = FIO_OPT_BOOL,
871 .off1 = td_var_offset(fill_device),
872 .help = "Write until an ENOSPC error occurs",
873 .def = "0",
874 },
875 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100876 .name = "filesize",
877 .type = FIO_OPT_STR_VAL,
878 .off1 = td_var_offset(file_size_low),
879 .off2 = td_var_offset(file_size_high),
Jens Axboec3edbdb2007-07-20 14:25:31 +0200880 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100881 .help = "Size of individual files",
882 },
883 {
Jens Axboe67a10002007-07-31 23:12:16 +0200884 .name = "offset",
885 .alias = "fileoffset",
886 .type = FIO_OPT_STR_VAL,
887 .off1 = td_var_offset(start_offset),
888 .help = "Start IO from this offset",
889 .def = "0",
890 },
891 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100892 .name = "bs",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100893 .alias = "blocksize",
Jens Axboee01b22b2009-06-09 15:43:25 +0200894 .type = FIO_OPT_INT,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100895 .off1 = td_var_offset(bs[DDIR_READ]),
896 .off2 = td_var_offset(bs[DDIR_WRITE]),
Jens Axboec3edbdb2007-07-20 14:25:31 +0200897 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100898 .help = "Block size unit",
899 .def = "4k",
Jens Axboe67a10002007-07-31 23:12:16 +0200900 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100901 },
902 {
Jens Axboe2b7a01d2009-03-11 11:00:13 +0100903 .name = "ba",
904 .alias = "blockalign",
Jens Axboee01b22b2009-06-09 15:43:25 +0200905 .type = FIO_OPT_INT,
Jens Axboe2b7a01d2009-03-11 11:00:13 +0100906 .off1 = td_var_offset(ba[DDIR_READ]),
907 .off2 = td_var_offset(ba[DDIR_WRITE]),
908 .minval = 1,
909 .help = "IO block offset alignment",
910 .parent = "rw",
911 },
912 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100913 .name = "bsrange",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100914 .alias = "blocksize_range",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100915 .type = FIO_OPT_RANGE,
916 .off1 = td_var_offset(min_bs[DDIR_READ]),
917 .off2 = td_var_offset(max_bs[DDIR_READ]),
918 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
919 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
Jens Axboec3edbdb2007-07-20 14:25:31 +0200920 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100921 .help = "Set block size range (in more detail than bs)",
Jens Axboe67a10002007-07-31 23:12:16 +0200922 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100923 },
924 {
Jens Axboe564ca972007-12-14 12:21:19 +0100925 .name = "bssplit",
926 .type = FIO_OPT_STR,
927 .cb = str_bssplit_cb,
928 .help = "Set a specific mix of block sizes",
929 .parent = "rw",
930 },
931 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100932 .name = "bs_unaligned",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100933 .alias = "blocksize_unaligned",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100934 .type = FIO_OPT_STR_SET,
935 .off1 = td_var_offset(bs_unaligned),
936 .help = "Don't sector align IO buffer sizes",
Jens Axboe67a10002007-07-31 23:12:16 +0200937 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100938 },
939 {
940 .name = "randrepeat",
941 .type = FIO_OPT_BOOL,
942 .off1 = td_var_offset(rand_repeatable),
943 .help = "Use repeatable random IO pattern",
944 .def = "1",
Jens Axboe67a10002007-07-31 23:12:16 +0200945 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100946 },
947 {
948 .name = "norandommap",
949 .type = FIO_OPT_STR_SET,
950 .off1 = td_var_offset(norandommap),
951 .help = "Accept potential duplicate random blocks",
Jens Axboe67a10002007-07-31 23:12:16 +0200952 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100953 },
954 {
Jens Axboe2b386d22008-03-26 10:32:57 +0100955 .name = "softrandommap",
956 .type = FIO_OPT_BOOL,
957 .off1 = td_var_offset(softrandommap),
Jens Axboef66ab3c2008-06-05 11:48:22 +0200958 .help = "Set norandommap if randommap allocation fails",
Jens Axboe2b386d22008-03-26 10:32:57 +0100959 .parent = "norandommap",
960 .def = "0",
961 },
962 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100963 .name = "nrfiles",
964 .type = FIO_OPT_INT,
965 .off1 = td_var_offset(nr_files),
966 .help = "Split job workload between this number of files",
967 .def = "1",
968 },
969 {
970 .name = "openfiles",
971 .type = FIO_OPT_INT,
972 .off1 = td_var_offset(open_files),
973 .help = "Number of files to keep open at the same time",
974 },
975 {
976 .name = "file_service_type",
977 .type = FIO_OPT_STR,
978 .cb = str_fst_cb,
979 .off1 = td_var_offset(file_service_type),
980 .help = "How to select which file to service next",
981 .def = "roundrobin",
982 .posval = {
983 { .ival = "random",
984 .oval = FIO_FSERVICE_RANDOM,
985 .help = "Choose a file at random",
986 },
987 { .ival = "roundrobin",
988 .oval = FIO_FSERVICE_RR,
989 .help = "Round robin select files",
990 },
Jens Axboea086c252009-03-04 08:27:37 +0100991 { .ival = "sequential",
992 .oval = FIO_FSERVICE_SEQ,
993 .help = "Finish one file before moving to the next",
994 },
Jens Axboe214e1ec2007-03-15 10:48:13 +0100995 },
Jens Axboe67a10002007-07-31 23:12:16 +0200996 .parent = "nrfiles",
997 },
998 {
999 .name = "fadvise_hint",
1000 .type = FIO_OPT_BOOL,
1001 .off1 = td_var_offset(fadvise_hint),
1002 .help = "Use fadvise() to advise the kernel on IO pattern",
1003 .def = "1",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001004 },
1005 {
1006 .name = "fsync",
1007 .type = FIO_OPT_INT,
1008 .off1 = td_var_offset(fsync_blocks),
1009 .help = "Issue fsync for writes every given number of blocks",
1010 .def = "0",
1011 },
1012 {
Jens Axboe5f9099e2009-06-16 22:40:26 +02001013 .name = "fdatasync",
1014 .type = FIO_OPT_INT,
1015 .off1 = td_var_offset(fdatasync_blocks),
1016 .help = "Issue fdatasync for writes every given number of blocks",
1017 .def = "0",
1018 },
1019 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001020 .name = "direct",
1021 .type = FIO_OPT_BOOL,
1022 .off1 = td_var_offset(odirect),
1023 .help = "Use O_DIRECT IO (negates buffered)",
1024 .def = "0",
1025 },
1026 {
1027 .name = "buffered",
1028 .type = FIO_OPT_BOOL,
1029 .off1 = td_var_offset(odirect),
1030 .neg = 1,
1031 .help = "Use buffered IO (negates direct)",
1032 .def = "1",
1033 },
1034 {
1035 .name = "overwrite",
1036 .type = FIO_OPT_BOOL,
1037 .off1 = td_var_offset(overwrite),
1038 .help = "When writing, set whether to overwrite current data",
1039 .def = "0",
1040 },
1041 {
1042 .name = "loops",
1043 .type = FIO_OPT_INT,
1044 .off1 = td_var_offset(loops),
1045 .help = "Number of times to run the job",
1046 .def = "1",
1047 },
1048 {
1049 .name = "numjobs",
1050 .type = FIO_OPT_INT,
1051 .off1 = td_var_offset(numjobs),
1052 .help = "Duplicate this job this many times",
1053 .def = "1",
1054 },
1055 {
1056 .name = "startdelay",
1057 .type = FIO_OPT_INT,
1058 .off1 = td_var_offset(start_delay),
1059 .help = "Only start job when this period has passed",
1060 .def = "0",
1061 },
1062 {
1063 .name = "runtime",
1064 .alias = "timeout",
1065 .type = FIO_OPT_STR_VAL_TIME,
1066 .off1 = td_var_offset(timeout),
1067 .help = "Stop workload when this amount of time has passed",
1068 .def = "0",
1069 },
1070 {
Jens Axboecf4464c2007-04-17 20:14:42 +02001071 .name = "time_based",
1072 .type = FIO_OPT_STR_SET,
1073 .off1 = td_var_offset(time_based),
1074 .help = "Keep running until runtime/timeout is met",
1075 },
1076 {
Jens Axboe721938a2008-09-10 09:46:16 +02001077 .name = "ramp_time",
1078 .type = FIO_OPT_STR_VAL_TIME,
1079 .off1 = td_var_offset(ramp_time),
1080 .help = "Ramp up time before measuring performance",
1081 },
1082 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001083 .name = "mem",
Jens Axboed3aad8f2007-03-15 14:12:05 +01001084 .alias = "iomem",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001085 .type = FIO_OPT_STR,
1086 .cb = str_mem_cb,
1087 .off1 = td_var_offset(mem_type),
1088 .help = "Backing type for IO buffers",
1089 .def = "malloc",
1090 .posval = {
1091 { .ival = "malloc",
1092 .oval = MEM_MALLOC,
1093 .help = "Use malloc(3) for IO buffers",
1094 },
Jens Axboeb370e462007-03-19 10:51:49 +01001095 { .ival = "shm",
1096 .oval = MEM_SHM,
1097 .help = "Use shared memory segments for IO buffers",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001098 },
1099#ifdef FIO_HAVE_HUGETLB
Jens Axboe37c8cdf2007-03-19 13:14:03 +01001100 { .ival = "shmhuge",
1101 .oval = MEM_SHMHUGE,
1102 .help = "Like shm, but use huge pages",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001103 },
1104#endif
Jens Axboeb370e462007-03-19 10:51:49 +01001105 { .ival = "mmap",
1106 .oval = MEM_MMAP,
1107 .help = "Use mmap(2) (file or anon) for IO buffers",
1108 },
Jens Axboe37c8cdf2007-03-19 13:14:03 +01001109#ifdef FIO_HAVE_HUGETLB
1110 { .ival = "mmaphuge",
1111 .oval = MEM_MMAPHUGE,
1112 .help = "Like mmap, but use huge pages",
1113 },
1114#endif
Jens Axboe214e1ec2007-03-15 10:48:13 +01001115 },
1116 },
1117 {
Jens Axboed529ee12009-07-01 10:33:03 +02001118 .name = "iomem_align",
1119 .alias = "mem_align",
1120 .type = FIO_OPT_INT,
1121 .off1 = td_var_offset(mem_align),
1122 .minval = 0,
1123 .help = "IO memory buffer offset alignment",
1124 .def = "0",
1125 .parent = "iomem",
1126 },
1127 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001128 .name = "verify",
1129 .type = FIO_OPT_STR,
1130 .off1 = td_var_offset(verify),
1131 .help = "Verify data written",
1132 .def = "0",
1133 .posval = {
1134 { .ival = "0",
1135 .oval = VERIFY_NONE,
1136 .help = "Don't do IO verification",
1137 },
Jens Axboefcca4b52007-07-27 15:42:00 +02001138 { .ival = "md5",
1139 .oval = VERIFY_MD5,
1140 .help = "Use md5 checksums for verification",
1141 },
Jens Axboed77a7af2007-07-27 15:35:06 +02001142 { .ival = "crc64",
1143 .oval = VERIFY_CRC64,
1144 .help = "Use crc64 checksums for verification",
1145 },
Jens Axboe214e1ec2007-03-15 10:48:13 +01001146 { .ival = "crc32",
1147 .oval = VERIFY_CRC32,
1148 .help = "Use crc32 checksums for verification",
1149 },
Jens Axboeaf497e62008-08-04 15:40:35 +02001150 { .ival = "crc32c-intel",
1151 .oval = VERIFY_CRC32C_INTEL,
1152 .help = "Use hw crc32c checksums for verification",
1153 },
Jens Axboebac39e02008-06-11 20:46:19 +02001154 { .ival = "crc32c",
1155 .oval = VERIFY_CRC32C,
1156 .help = "Use crc32c checksums for verification",
1157 },
Jens Axboe969f7ed2007-07-27 09:07:17 +02001158 { .ival = "crc16",
1159 .oval = VERIFY_CRC16,
1160 .help = "Use crc16 checksums for verification",
1161 },
Jens Axboe1e154bd2007-07-27 09:52:40 +02001162 { .ival = "crc7",
1163 .oval = VERIFY_CRC7,
1164 .help = "Use crc7 checksums for verification",
1165 },
Jens Axboecd14cc12007-07-30 10:59:33 +02001166 { .ival = "sha256",
1167 .oval = VERIFY_SHA256,
1168 .help = "Use sha256 checksums for verification",
1169 },
1170 { .ival = "sha512",
1171 .oval = VERIFY_SHA512,
1172 .help = "Use sha512 checksums for verification",
1173 },
Shawn Lewis7437ee82007-08-02 21:05:58 +02001174 { .ival = "meta",
1175 .oval = VERIFY_META,
1176 .help = "Use io information",
1177 },
Jens Axboe36690c92007-03-26 10:23:34 +02001178 {
1179 .ival = "null",
1180 .oval = VERIFY_NULL,
1181 .help = "Pretend to verify",
1182 },
Jens Axboe214e1ec2007-03-15 10:48:13 +01001183 },
1184 },
1185 {
Jens Axboe005c5652007-08-02 22:21:36 +02001186 .name = "do_verify",
Jens Axboe68e1f292007-08-10 10:32:14 +02001187 .type = FIO_OPT_BOOL,
Jens Axboe005c5652007-08-02 22:21:36 +02001188 .off1 = td_var_offset(do_verify),
1189 .help = "Run verification stage after write",
1190 .def = "1",
1191 .parent = "verify",
1192 },
1193 {
Jens Axboe160b9662007-03-27 10:59:49 +02001194 .name = "verifysort",
1195 .type = FIO_OPT_BOOL,
1196 .off1 = td_var_offset(verifysort),
1197 .help = "Sort written verify blocks for read back",
1198 .def = "1",
Jens Axboec83f2df2007-07-31 22:51:47 +02001199 .parent = "verify",
Jens Axboe160b9662007-03-27 10:59:49 +02001200 },
1201 {
Jens Axboea59e1702007-07-30 08:53:27 +02001202 .name = "verify_interval",
Jens Axboee01b22b2009-06-09 15:43:25 +02001203 .type = FIO_OPT_INT,
Jens Axboea59e1702007-07-30 08:53:27 +02001204 .off1 = td_var_offset(verify_interval),
Jens Axboe819a9682007-07-28 21:30:31 +02001205 .minval = 2 * sizeof(struct verify_header),
Jens Axboea59e1702007-07-30 08:53:27 +02001206 .help = "Store verify buffer header every N bytes",
Jens Axboeafdf9352007-07-31 16:14:34 +02001207 .parent = "verify",
Shawn Lewis3f9f4e22007-07-28 21:10:37 +02001208 },
1209 {
Jens Axboea59e1702007-07-30 08:53:27 +02001210 .name = "verify_offset",
Jens Axboee01b22b2009-06-09 15:43:25 +02001211 .type = FIO_OPT_INT,
Jens Axboea59e1702007-07-30 08:53:27 +02001212 .help = "Offset verify header location by N bytes",
Shawn Lewis546a9142007-07-28 21:11:37 +02001213 .def = "0",
Jens Axboe5ec10ea2008-03-06 15:42:00 +01001214 .cb = str_verify_offset_cb,
Jens Axboeafdf9352007-07-31 16:14:34 +02001215 .parent = "verify",
Shawn Lewis546a9142007-07-28 21:11:37 +02001216 },
1217 {
Shawn Lewise28218f2008-01-16 11:01:33 +01001218 .name = "verify_pattern",
1219 .type = FIO_OPT_INT,
1220 .cb = str_verify_pattern_cb,
1221 .help = "Fill pattern for IO buffers",
1222 .parent = "verify",
1223 },
1224 {
Jens Axboea12a3b42007-08-09 10:20:54 +02001225 .name = "verify_fatal",
Jens Axboe68e1f292007-08-10 10:32:14 +02001226 .type = FIO_OPT_BOOL,
Jens Axboea12a3b42007-08-09 10:20:54 +02001227 .off1 = td_var_offset(verify_fatal),
1228 .def = "0",
1229 .help = "Exit on a single verify failure, don't continue",
1230 .parent = "verify",
1231 },
1232 {
Jens Axboee8462bd2009-07-06 12:59:04 +02001233 .name = "verify_async",
1234 .type = FIO_OPT_INT,
1235 .off1 = td_var_offset(verify_async),
1236 .def = "0",
1237 .help = "Number of async verifier threads to use",
1238 .parent = "verify",
1239 },
1240#ifdef FIO_HAVE_CPU_AFFINITY
1241 {
1242 .name = "verify_async_cpus",
1243 .type = FIO_OPT_STR,
1244 .cb = str_verify_cpus_allowed_cb,
1245 .help = "Set CPUs allowed for async verify threads",
1246 .parent = "verify_async",
1247 },
1248#endif
1249 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001250 .name = "write_iolog",
1251 .type = FIO_OPT_STR_STORE,
1252 .off1 = td_var_offset(write_iolog_file),
1253 .help = "Store IO pattern to file",
1254 },
1255 {
1256 .name = "read_iolog",
1257 .type = FIO_OPT_STR_STORE,
1258 .off1 = td_var_offset(read_iolog_file),
1259 .help = "Playback IO pattern from file",
1260 },
1261 {
1262 .name = "exec_prerun",
1263 .type = FIO_OPT_STR_STORE,
1264 .off1 = td_var_offset(exec_prerun),
1265 .help = "Execute this file prior to running job",
1266 },
1267 {
1268 .name = "exec_postrun",
1269 .type = FIO_OPT_STR_STORE,
1270 .off1 = td_var_offset(exec_postrun),
1271 .help = "Execute this file after running job",
1272 },
1273#ifdef FIO_HAVE_IOSCHED_SWITCH
1274 {
1275 .name = "ioscheduler",
1276 .type = FIO_OPT_STR_STORE,
1277 .off1 = td_var_offset(ioscheduler),
1278 .help = "Use this IO scheduler on the backing device",
1279 },
1280#endif
1281 {
1282 .name = "zonesize",
1283 .type = FIO_OPT_STR_VAL,
1284 .off1 = td_var_offset(zone_size),
1285 .help = "Give size of an IO zone",
1286 .def = "0",
1287 },
1288 {
1289 .name = "zoneskip",
1290 .type = FIO_OPT_STR_VAL,
1291 .off1 = td_var_offset(zone_skip),
1292 .help = "Space between IO zones",
1293 .def = "0",
1294 },
1295 {
1296 .name = "lockmem",
1297 .type = FIO_OPT_STR_VAL,
1298 .cb = str_lockmem_cb,
1299 .help = "Lock down this amount of memory",
1300 .def = "0",
1301 },
1302 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001303 .name = "rwmixread",
1304 .type = FIO_OPT_INT,
Jens Axboecb499fc2008-05-28 10:33:32 +02001305 .cb = str_rwmix_read_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001306 .maxval = 100,
1307 .help = "Percentage of mixed workload that is reads",
1308 .def = "50",
1309 },
1310 {
1311 .name = "rwmixwrite",
1312 .type = FIO_OPT_INT,
Jens Axboecb499fc2008-05-28 10:33:32 +02001313 .cb = str_rwmix_write_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001314 .maxval = 100,
1315 .help = "Percentage of mixed workload that is writes",
1316 .def = "50",
1317 },
1318 {
Jens Axboeafdf9352007-07-31 16:14:34 +02001319 .name = "rwmixcycle",
Jens Axboe15ca1502008-04-07 09:26:02 +02001320 .type = FIO_OPT_DEPRECATED,
Jens Axboeafdf9352007-07-31 16:14:34 +02001321 },
1322 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001323 .name = "nice",
1324 .type = FIO_OPT_INT,
1325 .off1 = td_var_offset(nice),
1326 .help = "Set job CPU nice value",
1327 .minval = -19,
1328 .maxval = 20,
1329 .def = "0",
1330 },
1331#ifdef FIO_HAVE_IOPRIO
1332 {
1333 .name = "prio",
1334 .type = FIO_OPT_INT,
1335 .cb = str_prio_cb,
1336 .help = "Set job IO priority value",
1337 .minval = 0,
1338 .maxval = 7,
1339 },
1340 {
1341 .name = "prioclass",
1342 .type = FIO_OPT_INT,
1343 .cb = str_prioclass_cb,
1344 .help = "Set job IO priority class",
1345 .minval = 0,
1346 .maxval = 3,
1347 },
1348#endif
1349 {
1350 .name = "thinktime",
1351 .type = FIO_OPT_INT,
1352 .off1 = td_var_offset(thinktime),
1353 .help = "Idle time between IO buffers (usec)",
1354 .def = "0",
1355 },
1356 {
1357 .name = "thinktime_spin",
1358 .type = FIO_OPT_INT,
1359 .off1 = td_var_offset(thinktime_spin),
1360 .help = "Start think time by spinning this amount (usec)",
1361 .def = "0",
Jens Axboeafdf9352007-07-31 16:14:34 +02001362 .parent = "thinktime",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001363 },
1364 {
1365 .name = "thinktime_blocks",
1366 .type = FIO_OPT_INT,
1367 .off1 = td_var_offset(thinktime_blocks),
1368 .help = "IO buffer period between 'thinktime'",
1369 .def = "1",
Jens Axboeafdf9352007-07-31 16:14:34 +02001370 .parent = "thinktime",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001371 },
1372 {
1373 .name = "rate",
Jens Axboee01b22b2009-06-09 15:43:25 +02001374 .type = FIO_OPT_INT,
Jens Axboe581e7142009-06-09 12:47:16 +02001375 .off1 = td_var_offset(rate[0]),
1376 .off2 = td_var_offset(rate[1]),
Jens Axboe214e1ec2007-03-15 10:48:13 +01001377 .help = "Set bandwidth rate",
1378 },
1379 {
1380 .name = "ratemin",
Jens Axboee01b22b2009-06-09 15:43:25 +02001381 .type = FIO_OPT_INT,
Jens Axboe581e7142009-06-09 12:47:16 +02001382 .off1 = td_var_offset(ratemin[0]),
1383 .off2 = td_var_offset(ratemin[1]),
Jens Axboe4e991c22007-03-15 11:41:11 +01001384 .help = "Job must meet this rate or it will be shutdown",
Jens Axboeafdf9352007-07-31 16:14:34 +02001385 .parent = "rate",
Jens Axboe4e991c22007-03-15 11:41:11 +01001386 },
1387 {
1388 .name = "rate_iops",
Jens Axboee01b22b2009-06-09 15:43:25 +02001389 .type = FIO_OPT_INT,
Jens Axboe581e7142009-06-09 12:47:16 +02001390 .off1 = td_var_offset(rate_iops[0]),
1391 .off2 = td_var_offset(rate_iops[1]),
Jens Axboe4e991c22007-03-15 11:41:11 +01001392 .help = "Limit IO used to this number of IO operations/sec",
1393 },
1394 {
1395 .name = "rate_iops_min",
Jens Axboee01b22b2009-06-09 15:43:25 +02001396 .type = FIO_OPT_INT,
Jens Axboe581e7142009-06-09 12:47:16 +02001397 .off1 = td_var_offset(rate_iops_min[0]),
1398 .off2 = td_var_offset(rate_iops_min[1]),
Jens Axboe4e991c22007-03-15 11:41:11 +01001399 .help = "Job must meet this rate or it will be shutdown",
Jens Axboeafdf9352007-07-31 16:14:34 +02001400 .parent = "rate_iops",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001401 },
1402 {
1403 .name = "ratecycle",
1404 .type = FIO_OPT_INT,
1405 .off1 = td_var_offset(ratecycle),
1406 .help = "Window average for rate limits (msec)",
1407 .def = "1000",
Jens Axboeafdf9352007-07-31 16:14:34 +02001408 .parent = "rate",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001409 },
1410 {
1411 .name = "invalidate",
1412 .type = FIO_OPT_BOOL,
1413 .off1 = td_var_offset(invalidate_cache),
1414 .help = "Invalidate buffer/page cache prior to running job",
1415 .def = "1",
1416 },
1417 {
1418 .name = "sync",
1419 .type = FIO_OPT_BOOL,
1420 .off1 = td_var_offset(sync_io),
1421 .help = "Use O_SYNC for buffered writes",
1422 .def = "0",
Jens Axboe67a10002007-07-31 23:12:16 +02001423 .parent = "buffered",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001424 },
1425 {
1426 .name = "bwavgtime",
1427 .type = FIO_OPT_INT,
1428 .off1 = td_var_offset(bw_avg_time),
Jens Axboe5ec10ea2008-03-06 15:42:00 +01001429 .help = "Time window over which to calculate bandwidth"
1430 " (msec)",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001431 .def = "500",
1432 },
1433 {
1434 .name = "create_serialize",
1435 .type = FIO_OPT_BOOL,
1436 .off1 = td_var_offset(create_serialize),
1437 .help = "Serialize creating of job files",
1438 .def = "1",
1439 },
1440 {
1441 .name = "create_fsync",
1442 .type = FIO_OPT_BOOL,
1443 .off1 = td_var_offset(create_fsync),
1444 .help = "Fsync file after creation",
1445 .def = "1",
1446 },
1447 {
Jens Axboe814452b2009-03-04 12:53:13 +01001448 .name = "create_on_open",
1449 .type = FIO_OPT_BOOL,
1450 .off1 = td_var_offset(create_on_open),
1451 .help = "Create files when they are opened for IO",
1452 .def = "0",
1453 },
Zhang, Yanminafad68f2009-05-20 11:30:55 +02001454 {
1455 .name = "pre_read",
1456 .type = FIO_OPT_BOOL,
1457 .off1 = td_var_offset(pre_read),
1458 .help = "Preread files before starting official testing",
1459 .def = "0",
1460 },
Jens Axboe814452b2009-03-04 12:53:13 +01001461 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001462 .name = "cpuload",
1463 .type = FIO_OPT_INT,
1464 .off1 = td_var_offset(cpuload),
1465 .help = "Use this percentage of CPU",
1466 },
1467 {
1468 .name = "cpuchunks",
1469 .type = FIO_OPT_INT,
1470 .off1 = td_var_offset(cpucycle),
1471 .help = "Length of the CPU burn cycles (usecs)",
1472 .def = "50000",
Jens Axboe67a10002007-07-31 23:12:16 +02001473 .parent = "cpuload",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001474 },
1475#ifdef FIO_HAVE_CPU_AFFINITY
1476 {
1477 .name = "cpumask",
1478 .type = FIO_OPT_INT,
1479 .cb = str_cpumask_cb,
1480 .help = "CPU affinity mask",
1481 },
Jens Axboed2e268b2007-06-15 10:33:49 +02001482 {
1483 .name = "cpus_allowed",
1484 .type = FIO_OPT_STR,
1485 .cb = str_cpus_allowed_cb,
1486 .help = "Set CPUs allowed",
1487 },
Jens Axboe214e1ec2007-03-15 10:48:13 +01001488#endif
1489 {
1490 .name = "end_fsync",
1491 .type = FIO_OPT_BOOL,
1492 .off1 = td_var_offset(end_fsync),
1493 .help = "Include fsync at the end of job",
1494 .def = "0",
1495 },
1496 {
1497 .name = "fsync_on_close",
1498 .type = FIO_OPT_BOOL,
1499 .off1 = td_var_offset(fsync_on_close),
1500 .help = "fsync files on close",
1501 .def = "0",
1502 },
1503 {
1504 .name = "unlink",
1505 .type = FIO_OPT_BOOL,
1506 .off1 = td_var_offset(unlink),
1507 .help = "Unlink created files after job has completed",
1508 .def = "0",
1509 },
1510 {
1511 .name = "exitall",
1512 .type = FIO_OPT_STR_SET,
1513 .cb = str_exitall_cb,
1514 .help = "Terminate all jobs when one exits",
1515 },
1516 {
1517 .name = "stonewall",
1518 .type = FIO_OPT_STR_SET,
1519 .off1 = td_var_offset(stonewall),
1520 .help = "Insert a hard barrier between this job and previous",
1521 },
1522 {
Jens Axboeb3d62a72007-03-20 14:23:26 +01001523 .name = "new_group",
1524 .type = FIO_OPT_STR_SET,
1525 .off1 = td_var_offset(new_group),
1526 .help = "Mark the start of a new group (for reporting)",
1527 },
1528 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001529 .name = "thread",
1530 .type = FIO_OPT_STR_SET,
1531 .off1 = td_var_offset(use_thread),
1532 .help = "Use threads instead of forks",
1533 },
1534 {
1535 .name = "write_bw_log",
Jens Axboee3cedca2008-11-19 19:57:52 +01001536 .type = FIO_OPT_STR,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001537 .off1 = td_var_offset(write_bw_log),
Jens Axboee3cedca2008-11-19 19:57:52 +01001538 .cb = str_write_bw_log_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001539 .help = "Write log of bandwidth during run",
1540 },
1541 {
1542 .name = "write_lat_log",
Jens Axboee3cedca2008-11-19 19:57:52 +01001543 .type = FIO_OPT_STR,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001544 .off1 = td_var_offset(write_lat_log),
Jens Axboee3cedca2008-11-19 19:57:52 +01001545 .cb = str_write_lat_log_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001546 .help = "Write log of latency during run",
1547 },
1548 {
1549 .name = "hugepage-size",
Jens Axboee01b22b2009-06-09 15:43:25 +02001550 .type = FIO_OPT_INT,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001551 .off1 = td_var_offset(hugepage_size),
1552 .help = "When using hugepages, specify size of each page",
1553 .def = __stringify(FIO_HUGE_PAGE),
1554 },
1555 {
1556 .name = "group_reporting",
1557 .type = FIO_OPT_STR_SET,
1558 .off1 = td_var_offset(group_reporting),
1559 .help = "Do reporting on a per-group basis",
1560 },
1561 {
Jens Axboee9459e52007-04-17 15:46:32 +02001562 .name = "zero_buffers",
1563 .type = FIO_OPT_STR_SET,
1564 .off1 = td_var_offset(zero_buffers),
1565 .help = "Init IO buffers to all zeroes",
1566 },
Jens Axboe5973caf2008-05-21 19:52:35 +02001567 {
1568 .name = "refill_buffers",
1569 .type = FIO_OPT_STR_SET,
1570 .off1 = td_var_offset(refill_buffers),
1571 .help = "Refill IO buffers on every IO submit",
1572 },
Jens Axboe0a839f32007-04-26 09:02:34 +02001573#ifdef FIO_HAVE_DISK_UTIL
1574 {
1575 .name = "disk_util",
1576 .type = FIO_OPT_BOOL,
1577 .off1 = td_var_offset(do_disk_util),
Jens Axboef66ab3c2008-06-05 11:48:22 +02001578 .help = "Log disk utilization statistics",
Jens Axboe0a839f32007-04-26 09:02:34 +02001579 .def = "1",
1580 },
1581#endif
Jens Axboee9459e52007-04-17 15:46:32 +02001582 {
Jens Axboe993bf482008-11-14 13:04:53 +01001583 .name = "gtod_reduce",
1584 .type = FIO_OPT_BOOL,
1585 .help = "Greatly reduce number of gettimeofday() calls",
1586 .cb = str_gtod_reduce_cb,
1587 .def = "0",
1588 },
1589 {
Jens Axboe9520ebb2008-10-16 21:03:27 +02001590 .name = "disable_clat",
1591 .type = FIO_OPT_BOOL,
1592 .off1 = td_var_offset(disable_clat),
1593 .help = "Disable completion latency numbers",
Jens Axboe993bf482008-11-14 13:04:53 +01001594 .parent = "gtod_reduce",
Jens Axboe9520ebb2008-10-16 21:03:27 +02001595 .def = "0",
1596 },
1597 {
1598 .name = "disable_slat",
1599 .type = FIO_OPT_BOOL,
1600 .off1 = td_var_offset(disable_slat),
1601 .help = "Disable submissionn latency numbers",
Jens Axboe993bf482008-11-14 13:04:53 +01001602 .parent = "gtod_reduce",
Jens Axboe9520ebb2008-10-16 21:03:27 +02001603 .def = "0",
1604 },
1605 {
1606 .name = "disable_bw_measurement",
1607 .type = FIO_OPT_BOOL,
1608 .off1 = td_var_offset(disable_bw),
1609 .help = "Disable bandwidth logging",
Jens Axboe993bf482008-11-14 13:04:53 +01001610 .parent = "gtod_reduce",
Jens Axboe9520ebb2008-10-16 21:03:27 +02001611 .def = "0",
1612 },
1613 {
Jens Axboebe4ecfd2008-12-08 14:10:52 +01001614 .name = "gtod_cpu",
1615 .type = FIO_OPT_INT,
1616 .cb = str_gtod_cpu_cb,
1617 .help = "Setup dedicated gettimeofday() thread on this CPU",
Jens Axboe29d43ff2009-07-01 10:42:18 +02001618 .verify = gtod_cpu_verify,
Jens Axboebe4ecfd2008-12-08 14:10:52 +01001619 },
1620 {
Radha Ramachandranf2bba182009-06-15 08:40:16 +02001621 .name = "continue_on_error",
1622 .type = FIO_OPT_BOOL,
1623 .off1 = td_var_offset(continue_on_error),
1624 .help = "Continue on non-fatal errors during I/O",
1625 .def = "0",
1626 },
1627 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001628 .name = NULL,
1629 },
1630};
1631
1632void fio_options_dup_and_init(struct option *long_options)
1633{
1634 struct fio_option *o;
1635 unsigned int i;
1636
1637 options_init(options);
1638
1639 i = 0;
1640 while (long_options[i].name)
1641 i++;
1642
1643 o = &options[0];
1644 while (o->name) {
Jens Axboe5921e802008-05-30 15:02:38 +02001645 long_options[i].name = (char *) o->name;
Jens Axboe214e1ec2007-03-15 10:48:13 +01001646 long_options[i].val = FIO_GETOPT_JOB;
1647 if (o->type == FIO_OPT_STR_SET)
1648 long_options[i].has_arg = no_argument;
1649 else
1650 long_options[i].has_arg = required_argument;
1651
1652 i++;
1653 o++;
1654 assert(i < FIO_NR_OPTIONS);
1655 }
1656}
1657
Jens Axboe3b8b7132008-06-10 19:46:23 +02001658int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
Jens Axboe214e1ec2007-03-15 10:48:13 +01001659{
Jens Axboe3b8b7132008-06-10 19:46:23 +02001660 int i, ret;
1661
1662 sort_options(opts, options, num_opts);
1663
1664 for (ret = 0, i = 0; i < num_opts; i++)
1665 ret |= parse_option(opts[i], options, td);
1666
1667 return ret;
Jens Axboe214e1ec2007-03-15 10:48:13 +01001668}
1669
1670int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
1671{
1672 return parse_cmd_option(opt, val, options, td);
1673}
1674
1675void fio_fill_default_options(struct thread_data *td)
1676{
1677 fill_default_options(td, options);
1678}
1679
1680int fio_show_option_help(const char *opt)
1681{
1682 return show_cmd_help(options, opt);
1683}
Jens Axboed23bb322007-03-23 15:57:56 +01001684
1685static void __options_mem(struct thread_data *td, int alloc)
1686{
1687 struct thread_options *o = &td->o;
1688 struct fio_option *opt;
1689 char **ptr;
1690 int i;
1691
1692 for (i = 0, opt = &options[0]; opt->name; i++, opt = &options[i]) {
1693 if (opt->type != FIO_OPT_STR_STORE)
1694 continue;
1695
1696 ptr = (void *) o + opt->off1;
1697 if (*ptr) {
1698 if (alloc)
1699 *ptr = strdup(*ptr);
1700 else {
1701 free(*ptr);
1702 *ptr = NULL;
1703 }
1704 }
1705 }
1706}
1707
1708/*
1709 * dupe FIO_OPT_STR_STORE options
1710 */
1711void options_mem_dupe(struct thread_data *td)
1712{
1713 __options_mem(td, 1);
1714}
1715
Jens Axboe22d66212007-03-27 20:06:25 +02001716void options_mem_free(struct thread_data fio_unused *td)
Jens Axboed23bb322007-03-23 15:57:56 +01001717{
Jens Axboe22d66212007-03-27 20:06:25 +02001718#if 0
Jens Axboed23bb322007-03-23 15:57:56 +01001719 __options_mem(td, 0);
Jens Axboe22d66212007-03-27 20:06:25 +02001720#endif
Jens Axboed23bb322007-03-23 15:57:56 +01001721}