blob: 6941af0e8d9efa91e1a7a0d67152e9266322432f [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 Axboe2dc1bbe2007-03-15 15:01:33 +010018#define td_var_offset(var) ((size_t) &((struct thread_options *)0)->var)
Jens Axboe214e1ec2007-03-15 10:48:13 +010019
20/*
21 * Check if mmap/mmaphuge has a :/foo/bar/file at the end. If so, return that.
22 */
23static char *get_opt_postfix(const char *str)
24{
25 char *p = strstr(str, ":");
26
27 if (!p)
28 return NULL;
29
30 p++;
31 strip_blank_front(&p);
32 strip_blank_end(p);
33 return strdup(p);
34}
35
Jens Axboe564ca972007-12-14 12:21:19 +010036static int bs_cmp(const void *p1, const void *p2)
37{
38 const struct bssplit *bsp1 = p1;
39 const struct bssplit *bsp2 = p2;
40
41 return bsp1->perc < bsp2->perc;
42}
43
Jens Axboe720e84a2009-04-21 08:29:55 +020044static int bssplit_ddir(struct thread_data *td, int ddir, char *str)
Jens Axboe564ca972007-12-14 12:21:19 +010045{
Jens Axboe720e84a2009-04-21 08:29:55 +020046 struct bssplit *bssplit;
Jens Axboe564ca972007-12-14 12:21:19 +010047 unsigned int i, perc, perc_missing;
48 unsigned int max_bs, min_bs;
49 long long val;
Jens Axboe720e84a2009-04-21 08:29:55 +020050 char *fname;
Jens Axboe564ca972007-12-14 12:21:19 +010051
Jens Axboe720e84a2009-04-21 08:29:55 +020052 td->o.bssplit_nr[ddir] = 4;
53 bssplit = malloc(4 * sizeof(struct bssplit));
Jens Axboe564ca972007-12-14 12:21:19 +010054
55 i = 0;
56 max_bs = 0;
57 min_bs = -1;
58 while ((fname = strsep(&str, ":")) != NULL) {
59 char *perc_str;
60
61 if (!strlen(fname))
62 break;
63
64 /*
65 * grow struct buffer, if needed
66 */
Jens Axboe720e84a2009-04-21 08:29:55 +020067 if (i == td->o.bssplit_nr[ddir]) {
68 td->o.bssplit_nr[ddir] <<= 1;
69 bssplit = realloc(bssplit, td->o.bssplit_nr[ddir]
Jens Axboe5ec10ea2008-03-06 15:42:00 +010070 * sizeof(struct bssplit));
Jens Axboe564ca972007-12-14 12:21:19 +010071 }
72
73 perc_str = strstr(fname, "/");
74 if (perc_str) {
75 *perc_str = '\0';
76 perc_str++;
77 perc = atoi(perc_str);
78 if (perc > 100)
79 perc = 100;
80 else if (!perc)
81 perc = -1;
82 } else
83 perc = -1;
84
Jens Axboed6978a32009-07-18 21:04:09 +020085 if (str_to_decimal(fname, &val, 1, &td)) {
Jens Axboe564ca972007-12-14 12:21:19 +010086 log_err("fio: bssplit conversion failed\n");
87 free(td->o.bssplit);
88 return 1;
89 }
90
91 if (val > max_bs)
92 max_bs = val;
93 if (val < min_bs)
94 min_bs = val;
95
Jens Axboe720e84a2009-04-21 08:29:55 +020096 bssplit[i].bs = val;
97 bssplit[i].perc = perc;
Jens Axboe564ca972007-12-14 12:21:19 +010098 i++;
99 }
100
Jens Axboe720e84a2009-04-21 08:29:55 +0200101 td->o.bssplit_nr[ddir] = i;
Jens Axboe564ca972007-12-14 12:21:19 +0100102
103 /*
104 * Now check if the percentages add up, and how much is missing
105 */
106 perc = perc_missing = 0;
Jens Axboe720e84a2009-04-21 08:29:55 +0200107 for (i = 0; i < td->o.bssplit_nr[ddir]; i++) {
108 struct bssplit *bsp = &bssplit[i];
Jens Axboe564ca972007-12-14 12:21:19 +0100109
110 if (bsp->perc == (unsigned char) -1)
111 perc_missing++;
112 else
113 perc += bsp->perc;
114 }
115
116 if (perc > 100) {
117 log_err("fio: bssplit percentages add to more than 100%%\n");
Jens Axboe720e84a2009-04-21 08:29:55 +0200118 free(bssplit);
Jens Axboe564ca972007-12-14 12:21:19 +0100119 return 1;
120 }
121 /*
122 * If values didn't have a percentage set, divide the remains between
123 * them.
124 */
125 if (perc_missing) {
Jens Axboe720e84a2009-04-21 08:29:55 +0200126 for (i = 0; i < td->o.bssplit_nr[ddir]; i++) {
127 struct bssplit *bsp = &bssplit[i];
Jens Axboe564ca972007-12-14 12:21:19 +0100128
129 if (bsp->perc == (unsigned char) -1)
130 bsp->perc = (100 - perc) / perc_missing;
131 }
132 }
133
Jens Axboe720e84a2009-04-21 08:29:55 +0200134 td->o.min_bs[ddir] = min_bs;
135 td->o.max_bs[ddir] = max_bs;
Jens Axboe564ca972007-12-14 12:21:19 +0100136
137 /*
138 * now sort based on percentages, for ease of lookup
139 */
Jens Axboe720e84a2009-04-21 08:29:55 +0200140 qsort(bssplit, td->o.bssplit_nr[ddir], sizeof(struct bssplit), bs_cmp);
141 td->o.bssplit[ddir] = bssplit;
142 return 0;
143
144}
145
146static int str_bssplit_cb(void *data, const char *input)
147{
148 struct thread_data *td = data;
149 char *str, *p, *odir;
150 int ret = 0;
151
152 p = str = strdup(input);
153
154 strip_blank_front(&str);
155 strip_blank_end(str);
156
157 odir = strchr(str, ',');
158 if (odir) {
159 ret = bssplit_ddir(td, DDIR_WRITE, odir + 1);
160 if (!ret) {
161 *odir = '\0';
162 ret = bssplit_ddir(td, DDIR_READ, str);
163 }
164 } else {
165 char *op;
166
167 op = strdup(str);
168
169 ret = bssplit_ddir(td, DDIR_READ, str);
170 if (!ret)
171 ret = bssplit_ddir(td, DDIR_WRITE, op);
172
173 free(op);
174 }
Jens Axboe564ca972007-12-14 12:21:19 +0100175
176 free(p);
Jens Axboe720e84a2009-04-21 08:29:55 +0200177 return ret;
Jens Axboe564ca972007-12-14 12:21:19 +0100178}
179
Jens Axboe211097b2007-03-22 18:56:45 +0100180static int str_rw_cb(void *data, const char *str)
181{
182 struct thread_data *td = data;
183 char *nr = get_opt_postfix(str);
184
Jens Axboefafdba32007-03-26 10:09:12 +0200185 td->o.ddir_nr = 1;
Jens Axboe182ec6e2008-11-14 13:06:06 +0100186 if (nr) {
Jens Axboe211097b2007-03-22 18:56:45 +0100187 td->o.ddir_nr = atoi(nr);
Jens Axboe182ec6e2008-11-14 13:06:06 +0100188 free(nr);
189 }
Jens Axboe211097b2007-03-22 18:56:45 +0100190
Jens Axboe211097b2007-03-22 18:56:45 +0100191 return 0;
192}
193
Jens Axboe214e1ec2007-03-15 10:48:13 +0100194static int str_mem_cb(void *data, const char *mem)
195{
196 struct thread_data *td = data;
197
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100198 if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP) {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100199 td->mmapfile = get_opt_postfix(mem);
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100200 if (td->o.mem_type == MEM_MMAPHUGE && !td->mmapfile) {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100201 log_err("fio: mmaphuge:/path/to/file\n");
202 return 1;
203 }
204 }
205
206 return 0;
207}
208
209static int str_lockmem_cb(void fio_unused *data, unsigned long *val)
210{
211 mlock_size = *val;
212 return 0;
213}
214
Jens Axboecb499fc2008-05-28 10:33:32 +0200215static int str_rwmix_read_cb(void *data, unsigned int *val)
216{
217 struct thread_data *td = data;
218
219 td->o.rwmix[DDIR_READ] = *val;
220 td->o.rwmix[DDIR_WRITE] = 100 - *val;
221 return 0;
222}
223
224static int str_rwmix_write_cb(void *data, unsigned int *val)
225{
226 struct thread_data *td = data;
227
228 td->o.rwmix[DDIR_WRITE] = *val;
229 td->o.rwmix[DDIR_READ] = 100 - *val;
230 return 0;
231}
232
Jens Axboe214e1ec2007-03-15 10:48:13 +0100233#ifdef FIO_HAVE_IOPRIO
234static int str_prioclass_cb(void *data, unsigned int *val)
235{
236 struct thread_data *td = data;
Jens Axboe6cefbe32007-04-18 12:46:56 +0200237 unsigned short mask;
238
239 /*
240 * mask off old class bits, str_prio_cb() may have set a default class
241 */
242 mask = (1 << IOPRIO_CLASS_SHIFT) - 1;
243 td->ioprio &= mask;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100244
245 td->ioprio |= *val << IOPRIO_CLASS_SHIFT;
Jens Axboeac684782007-11-08 08:29:07 +0100246 td->ioprio_set = 1;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100247 return 0;
248}
249
250static int str_prio_cb(void *data, unsigned int *val)
251{
252 struct thread_data *td = data;
253
254 td->ioprio |= *val;
Jens Axboe6cefbe32007-04-18 12:46:56 +0200255
256 /*
257 * If no class is set, assume BE
258 */
259 if ((td->ioprio >> IOPRIO_CLASS_SHIFT) == 0)
260 td->ioprio |= IOPRIO_CLASS_BE << IOPRIO_CLASS_SHIFT;
261
Jens Axboeac684782007-11-08 08:29:07 +0100262 td->ioprio_set = 1;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100263 return 0;
264}
265#endif
266
267static int str_exitall_cb(void)
268{
269 exitall_on_terminate = 1;
270 return 0;
271}
272
Jens Axboe214e1ec2007-03-15 10:48:13 +0100273#ifdef FIO_HAVE_CPU_AFFINITY
Jens Axboe214e1ec2007-03-15 10:48:13 +0100274static int str_cpumask_cb(void *data, unsigned int *val)
275{
276 struct thread_data *td = data;
Jens Axboed2e268b2007-06-15 10:33:49 +0200277 unsigned int i;
Jens Axboeb03daaf2008-12-08 20:31:43 +0100278 long max_cpu;
Jens Axboed2ce18b2008-12-12 20:51:40 +0100279 int ret;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100280
Jens Axboed2ce18b2008-12-12 20:51:40 +0100281 ret = fio_cpuset_init(&td->o.cpumask);
282 if (ret < 0) {
283 log_err("fio: cpuset_init failed\n");
284 td_verror(td, ret, "fio_cpuset_init");
285 return 1;
286 }
287
Jens Axboeb03daaf2008-12-08 20:31:43 +0100288 max_cpu = sysconf(_SC_NPROCESSORS_ONLN);
Jens Axboed2e268b2007-06-15 10:33:49 +0200289
Jens Axboe62a72732008-12-08 11:37:01 +0100290 for (i = 0; i < sizeof(int) * 8; i++) {
291 if ((1 << i) & *val) {
Jens Axboeb03daaf2008-12-08 20:31:43 +0100292 if (i > max_cpu) {
293 log_err("fio: CPU %d too large (max=%ld)\n", i,
294 max_cpu);
295 return 1;
296 }
Jens Axboe62a72732008-12-08 11:37:01 +0100297 dprint(FD_PARSE, "set cpu allowed %d\n", i);
Jens Axboe6d459ee2008-12-12 20:02:58 +0100298 fio_cpu_set(&td->o.cpumask, i);
Jens Axboe62a72732008-12-08 11:37:01 +0100299 }
300 }
Jens Axboed2e268b2007-06-15 10:33:49 +0200301
Jens Axboe375b2692007-05-22 09:13:02 +0200302 td->o.cpumask_set = 1;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100303 return 0;
304}
305
Jens Axboee8462bd2009-07-06 12:59:04 +0200306static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask,
307 const char *input)
Jens Axboed2e268b2007-06-15 10:33:49 +0200308{
Jens Axboed2e268b2007-06-15 10:33:49 +0200309 char *cpu, *str, *p;
Jens Axboeb03daaf2008-12-08 20:31:43 +0100310 long max_cpu;
Jens Axboe19608d62008-12-08 15:03:12 +0100311 int ret = 0;
Jens Axboed2e268b2007-06-15 10:33:49 +0200312
Jens Axboee8462bd2009-07-06 12:59:04 +0200313 ret = fio_cpuset_init(mask);
Jens Axboed2ce18b2008-12-12 20:51:40 +0100314 if (ret < 0) {
315 log_err("fio: cpuset_init failed\n");
316 td_verror(td, ret, "fio_cpuset_init");
317 return 1;
318 }
Jens Axboed2e268b2007-06-15 10:33:49 +0200319
320 p = str = strdup(input);
321
322 strip_blank_front(&str);
323 strip_blank_end(str);
324
Jens Axboeb03daaf2008-12-08 20:31:43 +0100325 max_cpu = sysconf(_SC_NPROCESSORS_ONLN);
326
Jens Axboed2e268b2007-06-15 10:33:49 +0200327 while ((cpu = strsep(&str, ",")) != NULL) {
Jens Axboe62a72732008-12-08 11:37:01 +0100328 char *str2, *cpu2;
329 int icpu, icpu2;
330
Jens Axboed2e268b2007-06-15 10:33:49 +0200331 if (!strlen(cpu))
332 break;
Jens Axboe62a72732008-12-08 11:37:01 +0100333
334 str2 = cpu;
335 icpu2 = -1;
336 while ((cpu2 = strsep(&str2, "-")) != NULL) {
337 if (!strlen(cpu2))
338 break;
339
340 icpu2 = atoi(cpu2);
341 }
342
343 icpu = atoi(cpu);
344 if (icpu2 == -1)
345 icpu2 = icpu;
346 while (icpu <= icpu2) {
Jens Axboe6d459ee2008-12-12 20:02:58 +0100347 if (icpu >= FIO_MAX_CPUS) {
Jens Axboe19608d62008-12-08 15:03:12 +0100348 log_err("fio: your OS only supports up to"
Jens Axboe6d459ee2008-12-12 20:02:58 +0100349 " %d CPUs\n", (int) FIO_MAX_CPUS);
Jens Axboe19608d62008-12-08 15:03:12 +0100350 ret = 1;
351 break;
352 }
Jens Axboeb03daaf2008-12-08 20:31:43 +0100353 if (icpu > max_cpu) {
354 log_err("fio: CPU %d too large (max=%ld)\n",
355 icpu, max_cpu);
356 ret = 1;
357 break;
358 }
359
Jens Axboe62a72732008-12-08 11:37:01 +0100360 dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
Jens Axboee8462bd2009-07-06 12:59:04 +0200361 fio_cpu_set(mask, icpu);
Jens Axboe62a72732008-12-08 11:37:01 +0100362 icpu++;
363 }
Jens Axboe19608d62008-12-08 15:03:12 +0100364 if (ret)
365 break;
Jens Axboed2e268b2007-06-15 10:33:49 +0200366 }
367
368 free(p);
Jens Axboe19608d62008-12-08 15:03:12 +0100369 if (!ret)
370 td->o.cpumask_set = 1;
371 return ret;
Jens Axboed2e268b2007-06-15 10:33:49 +0200372}
Jens Axboee8462bd2009-07-06 12:59:04 +0200373
374static int str_cpus_allowed_cb(void *data, const char *input)
375{
376 struct thread_data *td = data;
377 int ret;
378
379 ret = set_cpus_allowed(td, &td->o.cpumask, input);
380 if (!ret)
381 td->o.cpumask_set = 1;
382
383 return ret;
384}
385
386static int str_verify_cpus_allowed_cb(void *data, const char *input)
387{
388 struct thread_data *td = data;
389 int ret;
390
391 ret = set_cpus_allowed(td, &td->o.verify_cpumask, input);
392 if (!ret)
393 td->o.verify_cpumask_set = 1;
394
395 return ret;
396}
Jens Axboed2e268b2007-06-15 10:33:49 +0200397#endif
398
Jens Axboe214e1ec2007-03-15 10:48:13 +0100399static int str_fst_cb(void *data, const char *str)
400{
401 struct thread_data *td = data;
402 char *nr = get_opt_postfix(str);
403
404 td->file_service_nr = 1;
Jens Axboe182ec6e2008-11-14 13:06:06 +0100405 if (nr) {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100406 td->file_service_nr = atoi(nr);
Jens Axboe182ec6e2008-11-14 13:06:06 +0100407 free(nr);
408 }
Jens Axboe214e1ec2007-03-15 10:48:13 +0100409
410 return 0;
411}
412
Jens Axboe921c7662008-03-26 09:17:55 +0100413static int check_dir(struct thread_data *td, char *fname)
414{
415 char file[PATH_MAX], *dir;
Jens Axboebc838912008-04-07 09:00:54 +0200416 int elen = 0;
Jens Axboe921c7662008-03-26 09:17:55 +0100417
Jens Axboebc838912008-04-07 09:00:54 +0200418 if (td->o.directory) {
419 strcpy(file, td->o.directory);
Jens Axboefcef0b32008-05-26 14:53:24 +0200420 strcat(file, "/");
Jens Axboebc838912008-04-07 09:00:54 +0200421 elen = strlen(file);
422 }
423
Jens Axboefcef0b32008-05-26 14:53:24 +0200424 sprintf(file + elen, "%s", fname);
Jens Axboe921c7662008-03-26 09:17:55 +0100425 dir = dirname(file);
426
Jens Axboefcef0b32008-05-26 14:53:24 +0200427#if 0
428 {
429 struct stat sb;
430 /*
431 * We can't do this on FIO_DISKLESSIO engines. The engine isn't loaded
432 * yet, so we can't do this check right here...
433 */
Jens Axboe921c7662008-03-26 09:17:55 +0100434 if (lstat(dir, &sb) < 0) {
435 int ret = errno;
436
437 log_err("fio: %s is not a directory\n", dir);
438 td_verror(td, ret, "lstat");
439 return 1;
440 }
441
442 if (!S_ISDIR(sb.st_mode)) {
443 log_err("fio: %s is not a directory\n", dir);
444 return 1;
445 }
Jens Axboefcef0b32008-05-26 14:53:24 +0200446 }
447#endif
Jens Axboe921c7662008-03-26 09:17:55 +0100448
449 return 0;
450}
451
Jens Axboe214e1ec2007-03-15 10:48:13 +0100452static int str_filename_cb(void *data, const char *input)
453{
454 struct thread_data *td = data;
455 char *fname, *str, *p;
456
457 p = str = strdup(input);
458
459 strip_blank_front(&str);
460 strip_blank_end(str);
461
462 if (!td->files_index)
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100463 td->o.nr_files = 0;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100464
465 while ((fname = strsep(&str, ":")) != NULL) {
466 if (!strlen(fname))
467 break;
Jens Axboe921c7662008-03-26 09:17:55 +0100468 if (check_dir(td, fname)) {
469 free(p);
470 return 1;
471 }
Jens Axboe214e1ec2007-03-15 10:48:13 +0100472 add_file(td, fname);
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100473 td->o.nr_files++;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100474 }
475
476 free(p);
477 return 0;
478}
479
480static int str_directory_cb(void *data, const char fio_unused *str)
481{
482 struct thread_data *td = data;
483 struct stat sb;
484
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100485 if (lstat(td->o.directory, &sb) < 0) {
Jens Axboe921c7662008-03-26 09:17:55 +0100486 int ret = errno;
487
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100488 log_err("fio: %s is not a directory\n", td->o.directory);
Jens Axboe921c7662008-03-26 09:17:55 +0100489 td_verror(td, ret, "lstat");
Jens Axboe214e1ec2007-03-15 10:48:13 +0100490 return 1;
491 }
492 if (!S_ISDIR(sb.st_mode)) {
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100493 log_err("fio: %s is not a directory\n", td->o.directory);
Jens Axboe214e1ec2007-03-15 10:48:13 +0100494 return 1;
495 }
496
497 return 0;
498}
499
500static int str_opendir_cb(void *data, const char fio_unused *str)
501{
502 struct thread_data *td = data;
503
504 if (!td->files_index)
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100505 td->o.nr_files = 0;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100506
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100507 return add_dir_files(td, td->o.opendir);
Jens Axboe214e1ec2007-03-15 10:48:13 +0100508}
509
Jens Axboea59e1702007-07-30 08:53:27 +0200510static int str_verify_offset_cb(void *data, unsigned int *off)
Shawn Lewis546a9142007-07-28 21:11:37 +0200511{
512 struct thread_data *td = data;
Jens Axboea59e1702007-07-30 08:53:27 +0200513
Shawn Lewis546a9142007-07-28 21:11:37 +0200514 if (*off && *off < sizeof(struct verify_header)) {
Jens Axboea59e1702007-07-30 08:53:27 +0200515 log_err("fio: verify_offset too small\n");
Shawn Lewis546a9142007-07-28 21:11:37 +0200516 return 1;
517 }
Jens Axboea59e1702007-07-30 08:53:27 +0200518
519 td->o.verify_offset = *off;
Shawn Lewis546a9142007-07-28 21:11:37 +0200520 return 0;
521}
522
Shawn Lewise28218f2008-01-16 11:01:33 +0100523static int str_verify_pattern_cb(void *data, unsigned int *off)
Jens Axboe90059d62007-07-30 09:33:12 +0200524{
525 struct thread_data *td = data;
Shawn Lewise28218f2008-01-16 11:01:33 +0100526 unsigned int msb;
Jens Axboe90059d62007-07-30 09:33:12 +0200527
Jens Axboe3c48c2c2008-06-02 12:22:30 +0200528 msb = __fls(*off);
Jens Axboe90059d62007-07-30 09:33:12 +0200529 if (msb <= 8)
530 td->o.verify_pattern_bytes = 1;
531 else if (msb <= 16)
532 td->o.verify_pattern_bytes = 2;
533 else if (msb <= 24)
534 td->o.verify_pattern_bytes = 3;
535 else
536 td->o.verify_pattern_bytes = 4;
537
Shawn Lewise28218f2008-01-16 11:01:33 +0100538 td->o.verify_pattern = *off;
Jens Axboe90059d62007-07-30 09:33:12 +0200539 return 0;
540}
Jens Axboe214e1ec2007-03-15 10:48:13 +0100541
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100542static int str_lockfile_cb(void *data, const char *str)
543{
544 struct thread_data *td = data;
545 char *nr = get_opt_postfix(str);
546
547 td->o.lockfile_batch = 1;
Jens Axboe182ec6e2008-11-14 13:06:06 +0100548 if (nr) {
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100549 td->o.lockfile_batch = atoi(nr);
Jens Axboe182ec6e2008-11-14 13:06:06 +0100550 free(nr);
551 }
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100552
553 return 0;
554}
555
Jens Axboee3cedca2008-11-19 19:57:52 +0100556static int str_write_bw_log_cb(void *data, const char *str)
557{
558 struct thread_data *td = data;
559
560 if (str)
561 td->o.bw_log_file = strdup(str);
562
563 td->o.write_bw_log = 1;
564 return 0;
565}
566
567static int str_write_lat_log_cb(void *data, const char *str)
568{
569 struct thread_data *td = data;
570
571 if (str)
572 td->o.lat_log_file = strdup(str);
573
574 td->o.write_lat_log = 1;
575 return 0;
576}
577
Jens Axboe993bf482008-11-14 13:04:53 +0100578static int str_gtod_reduce_cb(void *data, int *il)
579{
580 struct thread_data *td = data;
581 int val = *il;
582
583 td->o.disable_clat = !!val;
584 td->o.disable_slat = !!val;
585 td->o.disable_bw = !!val;
586 if (val)
587 td->tv_cache_mask = 63;
588
589 return 0;
590}
591
Jens Axboebe4ecfd2008-12-08 14:10:52 +0100592static int str_gtod_cpu_cb(void *data, int *il)
593{
594 struct thread_data *td = data;
595 int val = *il;
596
597 td->o.gtod_cpu = val;
598 td->o.gtod_offload = 1;
599 return 0;
600}
601
Jens Axboe896cac22009-07-01 10:38:35 +0200602static int rw_verify(struct fio_option *o, void *data)
603{
604 struct thread_data *td = data;
605
606 if (read_only && td_write(td)) {
607 log_err("fio: job <%s> has write bit set, but fio is in"
608 " read-only mode\n", td->o.name);
609 return 1;
610 }
611
612 return 0;
613}
614
Jens Axboe276ca4f2009-07-01 10:43:05 +0200615static int gtod_cpu_verify(struct fio_option *o, void *data)
Jens Axboe29d43ff2009-07-01 10:42:18 +0200616{
Jens Axboe276ca4f2009-07-01 10:43:05 +0200617#ifndef FIO_HAVE_CPU_AFFINITY
Jens Axboe29d43ff2009-07-01 10:42:18 +0200618 struct thread_data *td = data;
619
Jens Axboe29d43ff2009-07-01 10:42:18 +0200620 if (td->o.gtod_cpu) {
621 log_err("fio: platform must support CPU affinity for"
622 "gettimeofday() offloading\n");
623 return 1;
624 }
625#endif
626
627 return 0;
628}
629
Jens Axboe90fef2d2009-07-17 22:33:32 +0200630static int kb_base_verify(struct fio_option *o, void *data)
631{
632 struct thread_data *td = data;
633
634 if (td->o.kb_base != 1024 && td->o.kb_base != 1000) {
635 log_err("fio: kb_base set to nonsensical value: %u\n",
636 td->o.kb_base);
637 return 1;
638 }
639
640 return 0;
641}
642
Jens Axboe214e1ec2007-03-15 10:48:13 +0100643#define __stringify_1(x) #x
644#define __stringify(x) __stringify_1(x)
645
646/*
647 * Map of job/command line options
648 */
649static struct fio_option options[] = {
650 {
651 .name = "description",
652 .type = FIO_OPT_STR_STORE,
653 .off1 = td_var_offset(description),
654 .help = "Text job description",
655 },
656 {
657 .name = "name",
658 .type = FIO_OPT_STR_STORE,
659 .off1 = td_var_offset(name),
660 .help = "Name of this job",
661 },
662 {
663 .name = "directory",
664 .type = FIO_OPT_STR_STORE,
665 .off1 = td_var_offset(directory),
666 .cb = str_directory_cb,
667 .help = "Directory to store files in",
668 },
669 {
670 .name = "filename",
671 .type = FIO_OPT_STR_STORE,
672 .off1 = td_var_offset(filename),
673 .cb = str_filename_cb,
Jens Axboef0d524b2009-04-27 08:00:48 +0200674 .prio = -1, /* must come after "directory" */
Jens Axboe214e1ec2007-03-15 10:48:13 +0100675 .help = "File(s) to use for the workload",
676 },
677 {
Jens Axboe90fef2d2009-07-17 22:33:32 +0200678 .name = "kb_base",
679 .type = FIO_OPT_INT,
680 .off1 = td_var_offset(kb_base),
Jens Axboe90fef2d2009-07-17 22:33:32 +0200681 .verify = kb_base_verify,
Jens Axboea639f0b2009-07-18 08:25:35 +0200682 .prio = 1,
Jens Axboe90fef2d2009-07-17 22:33:32 +0200683 .def = "1024",
Jens Axboea639f0b2009-07-18 08:25:35 +0200684 .help = "How many bytes per KB for reporting (1000 or 1024)",
Jens Axboe90fef2d2009-07-17 22:33:32 +0200685 },
686 {
Jens Axboe29c13492008-03-01 19:25:20 +0100687 .name = "lockfile",
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100688 .type = FIO_OPT_STR,
689 .cb = str_lockfile_cb,
690 .off1 = td_var_offset(file_lock_mode),
Jens Axboe29c13492008-03-01 19:25:20 +0100691 .help = "Lock file when doing IO to it",
692 .parent = "filename",
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100693 .def = "none",
694 .posval = {
695 { .ival = "none",
696 .oval = FILE_LOCK_NONE,
697 .help = "No file locking",
698 },
699 { .ival = "exclusive",
700 .oval = FILE_LOCK_EXCLUSIVE,
701 .help = "Exclusive file lock",
702 },
703 {
704 .ival = "readwrite",
705 .oval = FILE_LOCK_READWRITE,
706 .help = "Read vs write lock",
707 },
708 },
Jens Axboe29c13492008-03-01 19:25:20 +0100709 },
710 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100711 .name = "opendir",
712 .type = FIO_OPT_STR_STORE,
713 .off1 = td_var_offset(opendir),
714 .cb = str_opendir_cb,
715 .help = "Recursively add files from this directory and down",
716 },
717 {
718 .name = "rw",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100719 .alias = "readwrite",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100720 .type = FIO_OPT_STR,
Jens Axboe211097b2007-03-22 18:56:45 +0100721 .cb = str_rw_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100722 .off1 = td_var_offset(td_ddir),
723 .help = "IO direction",
724 .def = "read",
Jens Axboe896cac22009-07-01 10:38:35 +0200725 .verify = rw_verify,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100726 .posval = {
727 { .ival = "read",
728 .oval = TD_DDIR_READ,
729 .help = "Sequential read",
730 },
731 { .ival = "write",
732 .oval = TD_DDIR_WRITE,
733 .help = "Sequential write",
734 },
735 { .ival = "randread",
736 .oval = TD_DDIR_RANDREAD,
737 .help = "Random read",
738 },
739 { .ival = "randwrite",
740 .oval = TD_DDIR_RANDWRITE,
741 .help = "Random write",
742 },
743 { .ival = "rw",
744 .oval = TD_DDIR_RW,
745 .help = "Sequential read and write mix",
746 },
747 { .ival = "randrw",
748 .oval = TD_DDIR_RANDRW,
749 .help = "Random read and write mix"
750 },
751 },
752 },
753 {
754 .name = "ioengine",
755 .type = FIO_OPT_STR_STORE,
756 .off1 = td_var_offset(ioengine),
757 .help = "IO engine to use",
758 .def = "sync",
759 .posval = {
760 { .ival = "sync",
761 .help = "Use read/write",
762 },
gurudas paia31041e2007-10-23 15:12:30 +0200763 { .ival = "psync",
764 .help = "Use pread/pwrite",
765 },
Jens Axboe1d2af022008-02-04 10:59:07 +0100766 { .ival = "vsync",
767 .help = "Use readv/writev",
768 },
Jens Axboe214e1ec2007-03-15 10:48:13 +0100769#ifdef FIO_HAVE_LIBAIO
770 { .ival = "libaio",
771 .help = "Linux native asynchronous IO",
772 },
773#endif
774#ifdef FIO_HAVE_POSIXAIO
775 { .ival = "posixaio",
776 .help = "POSIX asynchronous IO",
777 },
778#endif
Jens Axboe417f0062008-06-02 11:59:30 +0200779#ifdef FIO_HAVE_SOLARISAIO
780 { .ival = "solarisaio",
781 .help = "Solaris native asynchronous IO",
782 },
783#endif
Jens Axboe214e1ec2007-03-15 10:48:13 +0100784 { .ival = "mmap",
785 .help = "Memory mapped IO",
786 },
787#ifdef FIO_HAVE_SPLICE
788 { .ival = "splice",
789 .help = "splice/vmsplice based IO",
790 },
Jens Axboe9cce02e2007-06-22 15:42:21 +0200791 { .ival = "netsplice",
792 .help = "splice/vmsplice to/from the network",
793 },
Jens Axboe214e1ec2007-03-15 10:48:13 +0100794#endif
795#ifdef FIO_HAVE_SGIO
796 { .ival = "sg",
797 .help = "SCSI generic v3 IO",
798 },
799#endif
800 { .ival = "null",
801 .help = "Testing engine (no data transfer)",
802 },
803 { .ival = "net",
804 .help = "Network IO",
805 },
806#ifdef FIO_HAVE_SYSLET
807 { .ival = "syslet-rw",
808 .help = "syslet enabled async pread/pwrite IO",
809 },
810#endif
811 { .ival = "cpuio",
812 .help = "CPU cycler burner engine",
813 },
Jens Axboeb8c82a42007-03-21 08:48:26 +0100814#ifdef FIO_HAVE_GUASI
815 { .ival = "guasi",
816 .help = "GUASI IO engine",
817 },
818#endif
Jens Axboe214e1ec2007-03-15 10:48:13 +0100819 { .ival = "external",
820 .help = "Load external engine (append name)",
821 },
822 },
823 },
824 {
825 .name = "iodepth",
826 .type = FIO_OPT_INT,
827 .off1 = td_var_offset(iodepth),
828 .help = "Amount of IO buffers to keep in flight",
Jens Axboe757aff42007-12-12 19:42:13 +0100829 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100830 .def = "1",
831 },
832 {
833 .name = "iodepth_batch",
Jens Axboe49504212008-06-05 09:03:30 +0200834 .alias = "iodepth_batch_submit",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100835 .type = FIO_OPT_INT,
836 .off1 = td_var_offset(iodepth_batch),
Jens Axboed65db442009-01-16 19:15:33 +0100837 .help = "Number of IO buffers to submit in one go",
Jens Axboeafdf9352007-07-31 16:14:34 +0200838 .parent = "iodepth",
Jens Axboea2e6f8a2008-01-18 10:28:11 +0100839 .minval = 1,
840 .def = "1",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100841 },
842 {
Jens Axboe49504212008-06-05 09:03:30 +0200843 .name = "iodepth_batch_complete",
844 .type = FIO_OPT_INT,
845 .off1 = td_var_offset(iodepth_batch_complete),
Jens Axboed65db442009-01-16 19:15:33 +0100846 .help = "Number of IO buffers to retrieve in one go",
Jens Axboe49504212008-06-05 09:03:30 +0200847 .parent = "iodepth",
848 .minval = 0,
849 .def = "1",
850 },
851 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100852 .name = "iodepth_low",
853 .type = FIO_OPT_INT,
854 .off1 = td_var_offset(iodepth_low),
855 .help = "Low water mark for queuing depth",
Jens Axboeafdf9352007-07-31 16:14:34 +0200856 .parent = "iodepth",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100857 },
858 {
859 .name = "size",
860 .type = FIO_OPT_STR_VAL,
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100861 .off1 = td_var_offset(size),
Jens Axboec3edbdb2007-07-20 14:25:31 +0200862 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100863 .help = "Total size of device or files",
864 },
865 {
Shawn Lewisaa31f1f2008-01-11 09:45:11 +0100866 .name = "fill_device",
867 .type = FIO_OPT_BOOL,
868 .off1 = td_var_offset(fill_device),
869 .help = "Write until an ENOSPC error occurs",
870 .def = "0",
871 },
872 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100873 .name = "filesize",
874 .type = FIO_OPT_STR_VAL,
875 .off1 = td_var_offset(file_size_low),
876 .off2 = td_var_offset(file_size_high),
Jens Axboec3edbdb2007-07-20 14:25:31 +0200877 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100878 .help = "Size of individual files",
879 },
880 {
Jens Axboe67a10002007-07-31 23:12:16 +0200881 .name = "offset",
882 .alias = "fileoffset",
883 .type = FIO_OPT_STR_VAL,
884 .off1 = td_var_offset(start_offset),
885 .help = "Start IO from this offset",
886 .def = "0",
887 },
888 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100889 .name = "bs",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100890 .alias = "blocksize",
Jens Axboee01b22b2009-06-09 15:43:25 +0200891 .type = FIO_OPT_INT,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100892 .off1 = td_var_offset(bs[DDIR_READ]),
893 .off2 = td_var_offset(bs[DDIR_WRITE]),
Jens Axboec3edbdb2007-07-20 14:25:31 +0200894 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100895 .help = "Block size unit",
896 .def = "4k",
Jens Axboe67a10002007-07-31 23:12:16 +0200897 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100898 },
899 {
Jens Axboe2b7a01d2009-03-11 11:00:13 +0100900 .name = "ba",
901 .alias = "blockalign",
Jens Axboee01b22b2009-06-09 15:43:25 +0200902 .type = FIO_OPT_INT,
Jens Axboe2b7a01d2009-03-11 11:00:13 +0100903 .off1 = td_var_offset(ba[DDIR_READ]),
904 .off2 = td_var_offset(ba[DDIR_WRITE]),
905 .minval = 1,
906 .help = "IO block offset alignment",
907 .parent = "rw",
908 },
909 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100910 .name = "bsrange",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100911 .alias = "blocksize_range",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100912 .type = FIO_OPT_RANGE,
913 .off1 = td_var_offset(min_bs[DDIR_READ]),
914 .off2 = td_var_offset(max_bs[DDIR_READ]),
915 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
916 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
Jens Axboec3edbdb2007-07-20 14:25:31 +0200917 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100918 .help = "Set block size range (in more detail than bs)",
Jens Axboe67a10002007-07-31 23:12:16 +0200919 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100920 },
921 {
Jens Axboe564ca972007-12-14 12:21:19 +0100922 .name = "bssplit",
923 .type = FIO_OPT_STR,
924 .cb = str_bssplit_cb,
925 .help = "Set a specific mix of block sizes",
926 .parent = "rw",
927 },
928 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100929 .name = "bs_unaligned",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100930 .alias = "blocksize_unaligned",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100931 .type = FIO_OPT_STR_SET,
932 .off1 = td_var_offset(bs_unaligned),
933 .help = "Don't sector align IO buffer sizes",
Jens Axboe67a10002007-07-31 23:12:16 +0200934 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100935 },
936 {
937 .name = "randrepeat",
938 .type = FIO_OPT_BOOL,
939 .off1 = td_var_offset(rand_repeatable),
940 .help = "Use repeatable random IO pattern",
941 .def = "1",
Jens Axboe67a10002007-07-31 23:12:16 +0200942 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100943 },
944 {
945 .name = "norandommap",
946 .type = FIO_OPT_STR_SET,
947 .off1 = td_var_offset(norandommap),
948 .help = "Accept potential duplicate random blocks",
Jens Axboe67a10002007-07-31 23:12:16 +0200949 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100950 },
951 {
Jens Axboe2b386d22008-03-26 10:32:57 +0100952 .name = "softrandommap",
953 .type = FIO_OPT_BOOL,
954 .off1 = td_var_offset(softrandommap),
Jens Axboef66ab3c2008-06-05 11:48:22 +0200955 .help = "Set norandommap if randommap allocation fails",
Jens Axboe2b386d22008-03-26 10:32:57 +0100956 .parent = "norandommap",
957 .def = "0",
958 },
959 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100960 .name = "nrfiles",
961 .type = FIO_OPT_INT,
962 .off1 = td_var_offset(nr_files),
963 .help = "Split job workload between this number of files",
964 .def = "1",
965 },
966 {
967 .name = "openfiles",
968 .type = FIO_OPT_INT,
969 .off1 = td_var_offset(open_files),
970 .help = "Number of files to keep open at the same time",
971 },
972 {
973 .name = "file_service_type",
974 .type = FIO_OPT_STR,
975 .cb = str_fst_cb,
976 .off1 = td_var_offset(file_service_type),
977 .help = "How to select which file to service next",
978 .def = "roundrobin",
979 .posval = {
980 { .ival = "random",
981 .oval = FIO_FSERVICE_RANDOM,
982 .help = "Choose a file at random",
983 },
984 { .ival = "roundrobin",
985 .oval = FIO_FSERVICE_RR,
986 .help = "Round robin select files",
987 },
Jens Axboea086c252009-03-04 08:27:37 +0100988 { .ival = "sequential",
989 .oval = FIO_FSERVICE_SEQ,
990 .help = "Finish one file before moving to the next",
991 },
Jens Axboe214e1ec2007-03-15 10:48:13 +0100992 },
Jens Axboe67a10002007-07-31 23:12:16 +0200993 .parent = "nrfiles",
994 },
995 {
996 .name = "fadvise_hint",
997 .type = FIO_OPT_BOOL,
998 .off1 = td_var_offset(fadvise_hint),
999 .help = "Use fadvise() to advise the kernel on IO pattern",
1000 .def = "1",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001001 },
1002 {
1003 .name = "fsync",
1004 .type = FIO_OPT_INT,
1005 .off1 = td_var_offset(fsync_blocks),
1006 .help = "Issue fsync for writes every given number of blocks",
1007 .def = "0",
1008 },
1009 {
Jens Axboe5f9099e2009-06-16 22:40:26 +02001010 .name = "fdatasync",
1011 .type = FIO_OPT_INT,
1012 .off1 = td_var_offset(fdatasync_blocks),
1013 .help = "Issue fdatasync for writes every given number of blocks",
1014 .def = "0",
1015 },
1016 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001017 .name = "direct",
1018 .type = FIO_OPT_BOOL,
1019 .off1 = td_var_offset(odirect),
1020 .help = "Use O_DIRECT IO (negates buffered)",
1021 .def = "0",
1022 },
1023 {
1024 .name = "buffered",
1025 .type = FIO_OPT_BOOL,
1026 .off1 = td_var_offset(odirect),
1027 .neg = 1,
1028 .help = "Use buffered IO (negates direct)",
1029 .def = "1",
1030 },
1031 {
1032 .name = "overwrite",
1033 .type = FIO_OPT_BOOL,
1034 .off1 = td_var_offset(overwrite),
1035 .help = "When writing, set whether to overwrite current data",
1036 .def = "0",
1037 },
1038 {
1039 .name = "loops",
1040 .type = FIO_OPT_INT,
1041 .off1 = td_var_offset(loops),
1042 .help = "Number of times to run the job",
1043 .def = "1",
1044 },
1045 {
1046 .name = "numjobs",
1047 .type = FIO_OPT_INT,
1048 .off1 = td_var_offset(numjobs),
1049 .help = "Duplicate this job this many times",
1050 .def = "1",
1051 },
1052 {
1053 .name = "startdelay",
1054 .type = FIO_OPT_INT,
1055 .off1 = td_var_offset(start_delay),
1056 .help = "Only start job when this period has passed",
1057 .def = "0",
1058 },
1059 {
1060 .name = "runtime",
1061 .alias = "timeout",
1062 .type = FIO_OPT_STR_VAL_TIME,
1063 .off1 = td_var_offset(timeout),
1064 .help = "Stop workload when this amount of time has passed",
1065 .def = "0",
1066 },
1067 {
Jens Axboecf4464c2007-04-17 20:14:42 +02001068 .name = "time_based",
1069 .type = FIO_OPT_STR_SET,
1070 .off1 = td_var_offset(time_based),
1071 .help = "Keep running until runtime/timeout is met",
1072 },
1073 {
Jens Axboe721938a2008-09-10 09:46:16 +02001074 .name = "ramp_time",
1075 .type = FIO_OPT_STR_VAL_TIME,
1076 .off1 = td_var_offset(ramp_time),
1077 .help = "Ramp up time before measuring performance",
1078 },
1079 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001080 .name = "mem",
Jens Axboed3aad8f2007-03-15 14:12:05 +01001081 .alias = "iomem",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001082 .type = FIO_OPT_STR,
1083 .cb = str_mem_cb,
1084 .off1 = td_var_offset(mem_type),
1085 .help = "Backing type for IO buffers",
1086 .def = "malloc",
1087 .posval = {
1088 { .ival = "malloc",
1089 .oval = MEM_MALLOC,
1090 .help = "Use malloc(3) for IO buffers",
1091 },
Jens Axboeb370e462007-03-19 10:51:49 +01001092 { .ival = "shm",
1093 .oval = MEM_SHM,
1094 .help = "Use shared memory segments for IO buffers",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001095 },
1096#ifdef FIO_HAVE_HUGETLB
Jens Axboe37c8cdf2007-03-19 13:14:03 +01001097 { .ival = "shmhuge",
1098 .oval = MEM_SHMHUGE,
1099 .help = "Like shm, but use huge pages",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001100 },
1101#endif
Jens Axboeb370e462007-03-19 10:51:49 +01001102 { .ival = "mmap",
1103 .oval = MEM_MMAP,
1104 .help = "Use mmap(2) (file or anon) for IO buffers",
1105 },
Jens Axboe37c8cdf2007-03-19 13:14:03 +01001106#ifdef FIO_HAVE_HUGETLB
1107 { .ival = "mmaphuge",
1108 .oval = MEM_MMAPHUGE,
1109 .help = "Like mmap, but use huge pages",
1110 },
1111#endif
Jens Axboe214e1ec2007-03-15 10:48:13 +01001112 },
1113 },
1114 {
Jens Axboed529ee12009-07-01 10:33:03 +02001115 .name = "iomem_align",
1116 .alias = "mem_align",
1117 .type = FIO_OPT_INT,
1118 .off1 = td_var_offset(mem_align),
1119 .minval = 0,
1120 .help = "IO memory buffer offset alignment",
1121 .def = "0",
1122 .parent = "iomem",
1123 },
1124 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001125 .name = "verify",
1126 .type = FIO_OPT_STR,
1127 .off1 = td_var_offset(verify),
1128 .help = "Verify data written",
1129 .def = "0",
1130 .posval = {
1131 { .ival = "0",
1132 .oval = VERIFY_NONE,
1133 .help = "Don't do IO verification",
1134 },
Jens Axboefcca4b52007-07-27 15:42:00 +02001135 { .ival = "md5",
1136 .oval = VERIFY_MD5,
1137 .help = "Use md5 checksums for verification",
1138 },
Jens Axboed77a7af2007-07-27 15:35:06 +02001139 { .ival = "crc64",
1140 .oval = VERIFY_CRC64,
1141 .help = "Use crc64 checksums for verification",
1142 },
Jens Axboe214e1ec2007-03-15 10:48:13 +01001143 { .ival = "crc32",
1144 .oval = VERIFY_CRC32,
1145 .help = "Use crc32 checksums for verification",
1146 },
Jens Axboeaf497e62008-08-04 15:40:35 +02001147 { .ival = "crc32c-intel",
1148 .oval = VERIFY_CRC32C_INTEL,
1149 .help = "Use hw crc32c checksums for verification",
1150 },
Jens Axboebac39e02008-06-11 20:46:19 +02001151 { .ival = "crc32c",
1152 .oval = VERIFY_CRC32C,
1153 .help = "Use crc32c checksums for verification",
1154 },
Jens Axboe969f7ed2007-07-27 09:07:17 +02001155 { .ival = "crc16",
1156 .oval = VERIFY_CRC16,
1157 .help = "Use crc16 checksums for verification",
1158 },
Jens Axboe1e154bd2007-07-27 09:52:40 +02001159 { .ival = "crc7",
1160 .oval = VERIFY_CRC7,
1161 .help = "Use crc7 checksums for verification",
1162 },
Jens Axboecd14cc12007-07-30 10:59:33 +02001163 { .ival = "sha256",
1164 .oval = VERIFY_SHA256,
1165 .help = "Use sha256 checksums for verification",
1166 },
1167 { .ival = "sha512",
1168 .oval = VERIFY_SHA512,
1169 .help = "Use sha512 checksums for verification",
1170 },
Shawn Lewis7437ee82007-08-02 21:05:58 +02001171 { .ival = "meta",
1172 .oval = VERIFY_META,
1173 .help = "Use io information",
1174 },
Jens Axboe36690c92007-03-26 10:23:34 +02001175 {
1176 .ival = "null",
1177 .oval = VERIFY_NULL,
1178 .help = "Pretend to verify",
1179 },
Jens Axboe214e1ec2007-03-15 10:48:13 +01001180 },
1181 },
1182 {
Jens Axboe005c5652007-08-02 22:21:36 +02001183 .name = "do_verify",
Jens Axboe68e1f292007-08-10 10:32:14 +02001184 .type = FIO_OPT_BOOL,
Jens Axboe005c5652007-08-02 22:21:36 +02001185 .off1 = td_var_offset(do_verify),
1186 .help = "Run verification stage after write",
1187 .def = "1",
1188 .parent = "verify",
1189 },
1190 {
Jens Axboe160b9662007-03-27 10:59:49 +02001191 .name = "verifysort",
1192 .type = FIO_OPT_BOOL,
1193 .off1 = td_var_offset(verifysort),
1194 .help = "Sort written verify blocks for read back",
1195 .def = "1",
Jens Axboec83f2df2007-07-31 22:51:47 +02001196 .parent = "verify",
Jens Axboe160b9662007-03-27 10:59:49 +02001197 },
1198 {
Jens Axboea59e1702007-07-30 08:53:27 +02001199 .name = "verify_interval",
Jens Axboee01b22b2009-06-09 15:43:25 +02001200 .type = FIO_OPT_INT,
Jens Axboea59e1702007-07-30 08:53:27 +02001201 .off1 = td_var_offset(verify_interval),
Jens Axboe819a9682007-07-28 21:30:31 +02001202 .minval = 2 * sizeof(struct verify_header),
Jens Axboea59e1702007-07-30 08:53:27 +02001203 .help = "Store verify buffer header every N bytes",
Jens Axboeafdf9352007-07-31 16:14:34 +02001204 .parent = "verify",
Shawn Lewis3f9f4e22007-07-28 21:10:37 +02001205 },
1206 {
Jens Axboea59e1702007-07-30 08:53:27 +02001207 .name = "verify_offset",
Jens Axboee01b22b2009-06-09 15:43:25 +02001208 .type = FIO_OPT_INT,
Jens Axboea59e1702007-07-30 08:53:27 +02001209 .help = "Offset verify header location by N bytes",
Shawn Lewis546a9142007-07-28 21:11:37 +02001210 .def = "0",
Jens Axboe5ec10ea2008-03-06 15:42:00 +01001211 .cb = str_verify_offset_cb,
Jens Axboeafdf9352007-07-31 16:14:34 +02001212 .parent = "verify",
Shawn Lewis546a9142007-07-28 21:11:37 +02001213 },
1214 {
Shawn Lewise28218f2008-01-16 11:01:33 +01001215 .name = "verify_pattern",
1216 .type = FIO_OPT_INT,
1217 .cb = str_verify_pattern_cb,
1218 .help = "Fill pattern for IO buffers",
1219 .parent = "verify",
1220 },
1221 {
Jens Axboea12a3b42007-08-09 10:20:54 +02001222 .name = "verify_fatal",
Jens Axboe68e1f292007-08-10 10:32:14 +02001223 .type = FIO_OPT_BOOL,
Jens Axboea12a3b42007-08-09 10:20:54 +02001224 .off1 = td_var_offset(verify_fatal),
1225 .def = "0",
1226 .help = "Exit on a single verify failure, don't continue",
1227 .parent = "verify",
1228 },
1229 {
Jens Axboee8462bd2009-07-06 12:59:04 +02001230 .name = "verify_async",
1231 .type = FIO_OPT_INT,
1232 .off1 = td_var_offset(verify_async),
1233 .def = "0",
1234 .help = "Number of async verifier threads to use",
1235 .parent = "verify",
1236 },
1237#ifdef FIO_HAVE_CPU_AFFINITY
1238 {
1239 .name = "verify_async_cpus",
1240 .type = FIO_OPT_STR,
1241 .cb = str_verify_cpus_allowed_cb,
1242 .help = "Set CPUs allowed for async verify threads",
1243 .parent = "verify_async",
1244 },
1245#endif
1246 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001247 .name = "write_iolog",
1248 .type = FIO_OPT_STR_STORE,
1249 .off1 = td_var_offset(write_iolog_file),
1250 .help = "Store IO pattern to file",
1251 },
1252 {
1253 .name = "read_iolog",
1254 .type = FIO_OPT_STR_STORE,
1255 .off1 = td_var_offset(read_iolog_file),
1256 .help = "Playback IO pattern from file",
1257 },
1258 {
1259 .name = "exec_prerun",
1260 .type = FIO_OPT_STR_STORE,
1261 .off1 = td_var_offset(exec_prerun),
1262 .help = "Execute this file prior to running job",
1263 },
1264 {
1265 .name = "exec_postrun",
1266 .type = FIO_OPT_STR_STORE,
1267 .off1 = td_var_offset(exec_postrun),
1268 .help = "Execute this file after running job",
1269 },
1270#ifdef FIO_HAVE_IOSCHED_SWITCH
1271 {
1272 .name = "ioscheduler",
1273 .type = FIO_OPT_STR_STORE,
1274 .off1 = td_var_offset(ioscheduler),
1275 .help = "Use this IO scheduler on the backing device",
1276 },
1277#endif
1278 {
1279 .name = "zonesize",
1280 .type = FIO_OPT_STR_VAL,
1281 .off1 = td_var_offset(zone_size),
1282 .help = "Give size of an IO zone",
1283 .def = "0",
1284 },
1285 {
1286 .name = "zoneskip",
1287 .type = FIO_OPT_STR_VAL,
1288 .off1 = td_var_offset(zone_skip),
1289 .help = "Space between IO zones",
1290 .def = "0",
1291 },
1292 {
1293 .name = "lockmem",
1294 .type = FIO_OPT_STR_VAL,
1295 .cb = str_lockmem_cb,
1296 .help = "Lock down this amount of memory",
1297 .def = "0",
1298 },
1299 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001300 .name = "rwmixread",
1301 .type = FIO_OPT_INT,
Jens Axboecb499fc2008-05-28 10:33:32 +02001302 .cb = str_rwmix_read_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001303 .maxval = 100,
1304 .help = "Percentage of mixed workload that is reads",
1305 .def = "50",
1306 },
1307 {
1308 .name = "rwmixwrite",
1309 .type = FIO_OPT_INT,
Jens Axboecb499fc2008-05-28 10:33:32 +02001310 .cb = str_rwmix_write_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001311 .maxval = 100,
1312 .help = "Percentage of mixed workload that is writes",
1313 .def = "50",
1314 },
1315 {
Jens Axboeafdf9352007-07-31 16:14:34 +02001316 .name = "rwmixcycle",
Jens Axboe15ca1502008-04-07 09:26:02 +02001317 .type = FIO_OPT_DEPRECATED,
Jens Axboeafdf9352007-07-31 16:14:34 +02001318 },
1319 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001320 .name = "nice",
1321 .type = FIO_OPT_INT,
1322 .off1 = td_var_offset(nice),
1323 .help = "Set job CPU nice value",
1324 .minval = -19,
1325 .maxval = 20,
1326 .def = "0",
1327 },
1328#ifdef FIO_HAVE_IOPRIO
1329 {
1330 .name = "prio",
1331 .type = FIO_OPT_INT,
1332 .cb = str_prio_cb,
1333 .help = "Set job IO priority value",
1334 .minval = 0,
1335 .maxval = 7,
1336 },
1337 {
1338 .name = "prioclass",
1339 .type = FIO_OPT_INT,
1340 .cb = str_prioclass_cb,
1341 .help = "Set job IO priority class",
1342 .minval = 0,
1343 .maxval = 3,
1344 },
1345#endif
1346 {
1347 .name = "thinktime",
1348 .type = FIO_OPT_INT,
1349 .off1 = td_var_offset(thinktime),
1350 .help = "Idle time between IO buffers (usec)",
1351 .def = "0",
1352 },
1353 {
1354 .name = "thinktime_spin",
1355 .type = FIO_OPT_INT,
1356 .off1 = td_var_offset(thinktime_spin),
1357 .help = "Start think time by spinning this amount (usec)",
1358 .def = "0",
Jens Axboeafdf9352007-07-31 16:14:34 +02001359 .parent = "thinktime",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001360 },
1361 {
1362 .name = "thinktime_blocks",
1363 .type = FIO_OPT_INT,
1364 .off1 = td_var_offset(thinktime_blocks),
1365 .help = "IO buffer period between 'thinktime'",
1366 .def = "1",
Jens Axboeafdf9352007-07-31 16:14:34 +02001367 .parent = "thinktime",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001368 },
1369 {
1370 .name = "rate",
Jens Axboee01b22b2009-06-09 15:43:25 +02001371 .type = FIO_OPT_INT,
Jens Axboe581e7142009-06-09 12:47:16 +02001372 .off1 = td_var_offset(rate[0]),
1373 .off2 = td_var_offset(rate[1]),
Jens Axboe214e1ec2007-03-15 10:48:13 +01001374 .help = "Set bandwidth rate",
1375 },
1376 {
1377 .name = "ratemin",
Jens Axboee01b22b2009-06-09 15:43:25 +02001378 .type = FIO_OPT_INT,
Jens Axboe581e7142009-06-09 12:47:16 +02001379 .off1 = td_var_offset(ratemin[0]),
1380 .off2 = td_var_offset(ratemin[1]),
Jens Axboe4e991c22007-03-15 11:41:11 +01001381 .help = "Job must meet this rate or it will be shutdown",
Jens Axboeafdf9352007-07-31 16:14:34 +02001382 .parent = "rate",
Jens Axboe4e991c22007-03-15 11:41:11 +01001383 },
1384 {
1385 .name = "rate_iops",
Jens Axboee01b22b2009-06-09 15:43:25 +02001386 .type = FIO_OPT_INT,
Jens Axboe581e7142009-06-09 12:47:16 +02001387 .off1 = td_var_offset(rate_iops[0]),
1388 .off2 = td_var_offset(rate_iops[1]),
Jens Axboe4e991c22007-03-15 11:41:11 +01001389 .help = "Limit IO used to this number of IO operations/sec",
1390 },
1391 {
1392 .name = "rate_iops_min",
Jens Axboee01b22b2009-06-09 15:43:25 +02001393 .type = FIO_OPT_INT,
Jens Axboe581e7142009-06-09 12:47:16 +02001394 .off1 = td_var_offset(rate_iops_min[0]),
1395 .off2 = td_var_offset(rate_iops_min[1]),
Jens Axboe4e991c22007-03-15 11:41:11 +01001396 .help = "Job must meet this rate or it will be shutdown",
Jens Axboeafdf9352007-07-31 16:14:34 +02001397 .parent = "rate_iops",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001398 },
1399 {
1400 .name = "ratecycle",
1401 .type = FIO_OPT_INT,
1402 .off1 = td_var_offset(ratecycle),
1403 .help = "Window average for rate limits (msec)",
1404 .def = "1000",
Jens Axboeafdf9352007-07-31 16:14:34 +02001405 .parent = "rate",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001406 },
1407 {
1408 .name = "invalidate",
1409 .type = FIO_OPT_BOOL,
1410 .off1 = td_var_offset(invalidate_cache),
1411 .help = "Invalidate buffer/page cache prior to running job",
1412 .def = "1",
1413 },
1414 {
1415 .name = "sync",
1416 .type = FIO_OPT_BOOL,
1417 .off1 = td_var_offset(sync_io),
1418 .help = "Use O_SYNC for buffered writes",
1419 .def = "0",
Jens Axboe67a10002007-07-31 23:12:16 +02001420 .parent = "buffered",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001421 },
1422 {
1423 .name = "bwavgtime",
1424 .type = FIO_OPT_INT,
1425 .off1 = td_var_offset(bw_avg_time),
Jens Axboe5ec10ea2008-03-06 15:42:00 +01001426 .help = "Time window over which to calculate bandwidth"
1427 " (msec)",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001428 .def = "500",
1429 },
1430 {
1431 .name = "create_serialize",
1432 .type = FIO_OPT_BOOL,
1433 .off1 = td_var_offset(create_serialize),
1434 .help = "Serialize creating of job files",
1435 .def = "1",
1436 },
1437 {
1438 .name = "create_fsync",
1439 .type = FIO_OPT_BOOL,
1440 .off1 = td_var_offset(create_fsync),
1441 .help = "Fsync file after creation",
1442 .def = "1",
1443 },
1444 {
Jens Axboe814452b2009-03-04 12:53:13 +01001445 .name = "create_on_open",
1446 .type = FIO_OPT_BOOL,
1447 .off1 = td_var_offset(create_on_open),
1448 .help = "Create files when they are opened for IO",
1449 .def = "0",
1450 },
Zhang, Yanminafad68f2009-05-20 11:30:55 +02001451 {
1452 .name = "pre_read",
1453 .type = FIO_OPT_BOOL,
1454 .off1 = td_var_offset(pre_read),
1455 .help = "Preread files before starting official testing",
1456 .def = "0",
1457 },
Jens Axboe814452b2009-03-04 12:53:13 +01001458 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001459 .name = "cpuload",
1460 .type = FIO_OPT_INT,
1461 .off1 = td_var_offset(cpuload),
1462 .help = "Use this percentage of CPU",
1463 },
1464 {
1465 .name = "cpuchunks",
1466 .type = FIO_OPT_INT,
1467 .off1 = td_var_offset(cpucycle),
1468 .help = "Length of the CPU burn cycles (usecs)",
1469 .def = "50000",
Jens Axboe67a10002007-07-31 23:12:16 +02001470 .parent = "cpuload",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001471 },
1472#ifdef FIO_HAVE_CPU_AFFINITY
1473 {
1474 .name = "cpumask",
1475 .type = FIO_OPT_INT,
1476 .cb = str_cpumask_cb,
1477 .help = "CPU affinity mask",
1478 },
Jens Axboed2e268b2007-06-15 10:33:49 +02001479 {
1480 .name = "cpus_allowed",
1481 .type = FIO_OPT_STR,
1482 .cb = str_cpus_allowed_cb,
1483 .help = "Set CPUs allowed",
1484 },
Jens Axboe214e1ec2007-03-15 10:48:13 +01001485#endif
1486 {
1487 .name = "end_fsync",
1488 .type = FIO_OPT_BOOL,
1489 .off1 = td_var_offset(end_fsync),
1490 .help = "Include fsync at the end of job",
1491 .def = "0",
1492 },
1493 {
1494 .name = "fsync_on_close",
1495 .type = FIO_OPT_BOOL,
1496 .off1 = td_var_offset(fsync_on_close),
1497 .help = "fsync files on close",
1498 .def = "0",
1499 },
1500 {
1501 .name = "unlink",
1502 .type = FIO_OPT_BOOL,
1503 .off1 = td_var_offset(unlink),
1504 .help = "Unlink created files after job has completed",
1505 .def = "0",
1506 },
1507 {
1508 .name = "exitall",
1509 .type = FIO_OPT_STR_SET,
1510 .cb = str_exitall_cb,
1511 .help = "Terminate all jobs when one exits",
1512 },
1513 {
1514 .name = "stonewall",
1515 .type = FIO_OPT_STR_SET,
1516 .off1 = td_var_offset(stonewall),
1517 .help = "Insert a hard barrier between this job and previous",
1518 },
1519 {
Jens Axboeb3d62a72007-03-20 14:23:26 +01001520 .name = "new_group",
1521 .type = FIO_OPT_STR_SET,
1522 .off1 = td_var_offset(new_group),
1523 .help = "Mark the start of a new group (for reporting)",
1524 },
1525 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001526 .name = "thread",
1527 .type = FIO_OPT_STR_SET,
1528 .off1 = td_var_offset(use_thread),
1529 .help = "Use threads instead of forks",
1530 },
1531 {
1532 .name = "write_bw_log",
Jens Axboee3cedca2008-11-19 19:57:52 +01001533 .type = FIO_OPT_STR,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001534 .off1 = td_var_offset(write_bw_log),
Jens Axboee3cedca2008-11-19 19:57:52 +01001535 .cb = str_write_bw_log_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001536 .help = "Write log of bandwidth during run",
1537 },
1538 {
1539 .name = "write_lat_log",
Jens Axboee3cedca2008-11-19 19:57:52 +01001540 .type = FIO_OPT_STR,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001541 .off1 = td_var_offset(write_lat_log),
Jens Axboee3cedca2008-11-19 19:57:52 +01001542 .cb = str_write_lat_log_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001543 .help = "Write log of latency during run",
1544 },
1545 {
1546 .name = "hugepage-size",
Jens Axboee01b22b2009-06-09 15:43:25 +02001547 .type = FIO_OPT_INT,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001548 .off1 = td_var_offset(hugepage_size),
1549 .help = "When using hugepages, specify size of each page",
1550 .def = __stringify(FIO_HUGE_PAGE),
1551 },
1552 {
1553 .name = "group_reporting",
1554 .type = FIO_OPT_STR_SET,
1555 .off1 = td_var_offset(group_reporting),
1556 .help = "Do reporting on a per-group basis",
1557 },
1558 {
Jens Axboee9459e52007-04-17 15:46:32 +02001559 .name = "zero_buffers",
1560 .type = FIO_OPT_STR_SET,
1561 .off1 = td_var_offset(zero_buffers),
1562 .help = "Init IO buffers to all zeroes",
1563 },
Jens Axboe5973caf2008-05-21 19:52:35 +02001564 {
1565 .name = "refill_buffers",
1566 .type = FIO_OPT_STR_SET,
1567 .off1 = td_var_offset(refill_buffers),
1568 .help = "Refill IO buffers on every IO submit",
1569 },
Jens Axboe0a839f32007-04-26 09:02:34 +02001570#ifdef FIO_HAVE_DISK_UTIL
1571 {
1572 .name = "disk_util",
1573 .type = FIO_OPT_BOOL,
1574 .off1 = td_var_offset(do_disk_util),
Jens Axboef66ab3c2008-06-05 11:48:22 +02001575 .help = "Log disk utilization statistics",
Jens Axboe0a839f32007-04-26 09:02:34 +02001576 .def = "1",
1577 },
1578#endif
Jens Axboee9459e52007-04-17 15:46:32 +02001579 {
Jens Axboe993bf482008-11-14 13:04:53 +01001580 .name = "gtod_reduce",
1581 .type = FIO_OPT_BOOL,
1582 .help = "Greatly reduce number of gettimeofday() calls",
1583 .cb = str_gtod_reduce_cb,
1584 .def = "0",
1585 },
1586 {
Jens Axboe9520ebb2008-10-16 21:03:27 +02001587 .name = "disable_clat",
1588 .type = FIO_OPT_BOOL,
1589 .off1 = td_var_offset(disable_clat),
1590 .help = "Disable completion latency numbers",
Jens Axboe993bf482008-11-14 13:04:53 +01001591 .parent = "gtod_reduce",
Jens Axboe9520ebb2008-10-16 21:03:27 +02001592 .def = "0",
1593 },
1594 {
1595 .name = "disable_slat",
1596 .type = FIO_OPT_BOOL,
1597 .off1 = td_var_offset(disable_slat),
1598 .help = "Disable submissionn latency numbers",
Jens Axboe993bf482008-11-14 13:04:53 +01001599 .parent = "gtod_reduce",
Jens Axboe9520ebb2008-10-16 21:03:27 +02001600 .def = "0",
1601 },
1602 {
1603 .name = "disable_bw_measurement",
1604 .type = FIO_OPT_BOOL,
1605 .off1 = td_var_offset(disable_bw),
1606 .help = "Disable bandwidth logging",
Jens Axboe993bf482008-11-14 13:04:53 +01001607 .parent = "gtod_reduce",
Jens Axboe9520ebb2008-10-16 21:03:27 +02001608 .def = "0",
1609 },
1610 {
Jens Axboebe4ecfd2008-12-08 14:10:52 +01001611 .name = "gtod_cpu",
1612 .type = FIO_OPT_INT,
1613 .cb = str_gtod_cpu_cb,
1614 .help = "Setup dedicated gettimeofday() thread on this CPU",
Jens Axboe29d43ff2009-07-01 10:42:18 +02001615 .verify = gtod_cpu_verify,
Jens Axboebe4ecfd2008-12-08 14:10:52 +01001616 },
1617 {
Radha Ramachandranf2bba182009-06-15 08:40:16 +02001618 .name = "continue_on_error",
1619 .type = FIO_OPT_BOOL,
1620 .off1 = td_var_offset(continue_on_error),
1621 .help = "Continue on non-fatal errors during I/O",
1622 .def = "0",
1623 },
1624 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001625 .name = NULL,
1626 },
1627};
1628
1629void fio_options_dup_and_init(struct option *long_options)
1630{
1631 struct fio_option *o;
1632 unsigned int i;
1633
1634 options_init(options);
1635
1636 i = 0;
1637 while (long_options[i].name)
1638 i++;
1639
1640 o = &options[0];
1641 while (o->name) {
Jens Axboe5921e802008-05-30 15:02:38 +02001642 long_options[i].name = (char *) o->name;
Jens Axboe214e1ec2007-03-15 10:48:13 +01001643 long_options[i].val = FIO_GETOPT_JOB;
1644 if (o->type == FIO_OPT_STR_SET)
1645 long_options[i].has_arg = no_argument;
1646 else
1647 long_options[i].has_arg = required_argument;
1648
1649 i++;
1650 o++;
1651 assert(i < FIO_NR_OPTIONS);
1652 }
1653}
1654
Jens Axboe3b8b7132008-06-10 19:46:23 +02001655int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
Jens Axboe214e1ec2007-03-15 10:48:13 +01001656{
Jens Axboe3b8b7132008-06-10 19:46:23 +02001657 int i, ret;
1658
1659 sort_options(opts, options, num_opts);
1660
1661 for (ret = 0, i = 0; i < num_opts; i++)
1662 ret |= parse_option(opts[i], options, td);
1663
1664 return ret;
Jens Axboe214e1ec2007-03-15 10:48:13 +01001665}
1666
1667int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
1668{
1669 return parse_cmd_option(opt, val, options, td);
1670}
1671
1672void fio_fill_default_options(struct thread_data *td)
1673{
1674 fill_default_options(td, options);
1675}
1676
1677int fio_show_option_help(const char *opt)
1678{
1679 return show_cmd_help(options, opt);
1680}
Jens Axboed23bb322007-03-23 15:57:56 +01001681
1682static void __options_mem(struct thread_data *td, int alloc)
1683{
1684 struct thread_options *o = &td->o;
1685 struct fio_option *opt;
1686 char **ptr;
1687 int i;
1688
1689 for (i = 0, opt = &options[0]; opt->name; i++, opt = &options[i]) {
1690 if (opt->type != FIO_OPT_STR_STORE)
1691 continue;
1692
1693 ptr = (void *) o + opt->off1;
1694 if (*ptr) {
1695 if (alloc)
1696 *ptr = strdup(*ptr);
1697 else {
1698 free(*ptr);
1699 *ptr = NULL;
1700 }
1701 }
1702 }
1703}
1704
1705/*
1706 * dupe FIO_OPT_STR_STORE options
1707 */
1708void options_mem_dupe(struct thread_data *td)
1709{
1710 __options_mem(td, 1);
1711}
1712
Jens Axboe22d66212007-03-27 20:06:25 +02001713void options_mem_free(struct thread_data fio_unused *td)
Jens Axboed23bb322007-03-23 15:57:56 +01001714{
Jens Axboe22d66212007-03-27 20:06:25 +02001715#if 0
Jens Axboed23bb322007-03-23 15:57:56 +01001716 __options_mem(td, 0);
Jens Axboe22d66212007-03-27 20:06:25 +02001717#endif
Jens Axboed23bb322007-03-23 15:57:56 +01001718}
Jens Axboed6978a32009-07-18 21:04:09 +02001719
1720unsigned int fio_get_kb_base(void *data)
1721{
1722 struct thread_data *td = data;
1723 unsigned int kb_base = 0;
1724
1725 if (td)
1726 kb_base = td->o.kb_base;
1727 if (!kb_base)
1728 kb_base = 1024;
1729
1730 return kb_base;
1731}