blob: 84101d1a3752ce3e3c0f60b9587962edab4562a1 [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>
Jens Axboe214e1ec2007-03-15 10:48:13 +01006#include <assert.h>
Jens Axboe921c7662008-03-26 09:17:55 +01007#include <libgen.h>
Jens Axboe5921e802008-05-30 15:02:38 +02008#include <fcntl.h>
9#include <sys/types.h>
10#include <sys/stat.h>
Jens Axboe214e1ec2007-03-15 10:48:13 +010011
12#include "fio.h"
Jens Axboe4f5af7b2009-06-03 08:45:40 +020013#include "verify.h"
Jens Axboe214e1ec2007-03-15 10:48:13 +010014#include "parse.h"
Jens Axboeeef32352008-06-02 13:31:26 +020015#include "lib/fls.h"
Jens Axboe9f988e22010-03-04 10:42:38 +010016#include "options.h"
Jens Axboe214e1ec2007-03-15 10:48:13 +010017
Jens Axboe5d7c5d32010-06-21 15:08:17 +020018#include "crc/crc32c.h"
19
Jens Axboe214e1ec2007-03-15 10:48:13 +010020/*
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
Radha Ramachandran0e92f872009-10-27 20:14:27 +010036static int converthexchartoint(char a)
37{
38 int base;
39
40 switch(a) {
41 case '0'...'9':
42 base = '0';
43 break;
44 case 'A'...'F':
45 base = 'A' - 10;
46 break;
47 case 'a'...'f':
48 base = 'a' - 10;
49 break;
50 default:
51 base = 0;
52 }
53 return (a - base);
54}
55
Jens Axboe564ca972007-12-14 12:21:19 +010056static int bs_cmp(const void *p1, const void *p2)
57{
58 const struct bssplit *bsp1 = p1;
59 const struct bssplit *bsp2 = p2;
60
61 return bsp1->perc < bsp2->perc;
62}
63
Jens Axboe720e84a2009-04-21 08:29:55 +020064static int bssplit_ddir(struct thread_data *td, int ddir, char *str)
Jens Axboe564ca972007-12-14 12:21:19 +010065{
Jens Axboe720e84a2009-04-21 08:29:55 +020066 struct bssplit *bssplit;
Jens Axboe564ca972007-12-14 12:21:19 +010067 unsigned int i, perc, perc_missing;
68 unsigned int max_bs, min_bs;
69 long long val;
Jens Axboe720e84a2009-04-21 08:29:55 +020070 char *fname;
Jens Axboe564ca972007-12-14 12:21:19 +010071
Jens Axboe720e84a2009-04-21 08:29:55 +020072 td->o.bssplit_nr[ddir] = 4;
73 bssplit = malloc(4 * sizeof(struct bssplit));
Jens Axboe564ca972007-12-14 12:21:19 +010074
75 i = 0;
76 max_bs = 0;
77 min_bs = -1;
78 while ((fname = strsep(&str, ":")) != NULL) {
79 char *perc_str;
80
81 if (!strlen(fname))
82 break;
83
84 /*
85 * grow struct buffer, if needed
86 */
Jens Axboe720e84a2009-04-21 08:29:55 +020087 if (i == td->o.bssplit_nr[ddir]) {
88 td->o.bssplit_nr[ddir] <<= 1;
89 bssplit = realloc(bssplit, td->o.bssplit_nr[ddir]
Jens Axboe5ec10ea2008-03-06 15:42:00 +010090 * sizeof(struct bssplit));
Jens Axboe564ca972007-12-14 12:21:19 +010091 }
92
93 perc_str = strstr(fname, "/");
94 if (perc_str) {
95 *perc_str = '\0';
96 perc_str++;
97 perc = atoi(perc_str);
98 if (perc > 100)
99 perc = 100;
100 else if (!perc)
101 perc = -1;
102 } else
103 perc = -1;
104
Jens Axboe6925dd32011-09-07 22:10:11 +0200105 if (str_to_decimal(fname, &val, 1, td)) {
Jens Axboe564ca972007-12-14 12:21:19 +0100106 log_err("fio: bssplit conversion failed\n");
107 free(td->o.bssplit);
108 return 1;
109 }
110
111 if (val > max_bs)
112 max_bs = val;
113 if (val < min_bs)
114 min_bs = val;
115
Jens Axboe720e84a2009-04-21 08:29:55 +0200116 bssplit[i].bs = val;
117 bssplit[i].perc = perc;
Jens Axboe564ca972007-12-14 12:21:19 +0100118 i++;
119 }
120
Jens Axboe720e84a2009-04-21 08:29:55 +0200121 td->o.bssplit_nr[ddir] = i;
Jens Axboe564ca972007-12-14 12:21:19 +0100122
123 /*
124 * Now check if the percentages add up, and how much is missing
125 */
126 perc = perc_missing = 0;
Jens Axboe720e84a2009-04-21 08:29:55 +0200127 for (i = 0; i < td->o.bssplit_nr[ddir]; i++) {
128 struct bssplit *bsp = &bssplit[i];
Jens Axboe564ca972007-12-14 12:21:19 +0100129
130 if (bsp->perc == (unsigned char) -1)
131 perc_missing++;
132 else
133 perc += bsp->perc;
134 }
135
136 if (perc > 100) {
137 log_err("fio: bssplit percentages add to more than 100%%\n");
Jens Axboe720e84a2009-04-21 08:29:55 +0200138 free(bssplit);
Jens Axboe564ca972007-12-14 12:21:19 +0100139 return 1;
140 }
141 /*
142 * If values didn't have a percentage set, divide the remains between
143 * them.
144 */
145 if (perc_missing) {
Jens Axboe720e84a2009-04-21 08:29:55 +0200146 for (i = 0; i < td->o.bssplit_nr[ddir]; i++) {
147 struct bssplit *bsp = &bssplit[i];
Jens Axboe564ca972007-12-14 12:21:19 +0100148
149 if (bsp->perc == (unsigned char) -1)
150 bsp->perc = (100 - perc) / perc_missing;
151 }
152 }
153
Jens Axboe720e84a2009-04-21 08:29:55 +0200154 td->o.min_bs[ddir] = min_bs;
155 td->o.max_bs[ddir] = max_bs;
Jens Axboe564ca972007-12-14 12:21:19 +0100156
157 /*
158 * now sort based on percentages, for ease of lookup
159 */
Jens Axboe720e84a2009-04-21 08:29:55 +0200160 qsort(bssplit, td->o.bssplit_nr[ddir], sizeof(struct bssplit), bs_cmp);
161 td->o.bssplit[ddir] = bssplit;
162 return 0;
163
164}
165
166static int str_bssplit_cb(void *data, const char *input)
167{
168 struct thread_data *td = data;
Shaohua Li6eaf09d2012-09-14 08:49:43 +0200169 char *str, *p, *odir, *ddir;
Jens Axboe720e84a2009-04-21 08:29:55 +0200170 int ret = 0;
171
172 p = str = strdup(input);
173
174 strip_blank_front(&str);
175 strip_blank_end(str);
176
177 odir = strchr(str, ',');
178 if (odir) {
Shaohua Li6eaf09d2012-09-14 08:49:43 +0200179 ddir = strchr(odir + 1, ',');
180 if (ddir) {
181 ret = bssplit_ddir(td, DDIR_TRIM, ddir + 1);
182 if (!ret)
183 *ddir = '\0';
184 } else {
185 char *op;
186
187 op = strdup(odir + 1);
188 ret = bssplit_ddir(td, DDIR_TRIM, op);
189
190 free(op);
191 }
192 if (!ret)
193 ret = bssplit_ddir(td, DDIR_WRITE, odir + 1);
Jens Axboe720e84a2009-04-21 08:29:55 +0200194 if (!ret) {
195 *odir = '\0';
196 ret = bssplit_ddir(td, DDIR_READ, str);
197 }
198 } else {
199 char *op;
200
201 op = strdup(str);
Shaohua Li6eaf09d2012-09-14 08:49:43 +0200202 ret = bssplit_ddir(td, DDIR_WRITE, op);
Jens Axboe720e84a2009-04-21 08:29:55 +0200203 free(op);
Shaohua Li6eaf09d2012-09-14 08:49:43 +0200204
205 if (!ret) {
206 op = strdup(str);
207 ret = bssplit_ddir(td, DDIR_TRIM, op);
208 free(op);
209 }
210 ret = bssplit_ddir(td, DDIR_READ, str);
Jens Axboe720e84a2009-04-21 08:29:55 +0200211 }
Jens Axboe564ca972007-12-14 12:21:19 +0100212
213 free(p);
Jens Axboe720e84a2009-04-21 08:29:55 +0200214 return ret;
Jens Axboe564ca972007-12-14 12:21:19 +0100215}
216
Dmitry Monakhov8b28bd42012-09-23 15:46:09 +0400217static int str2error(char *str)
218{
219 const char * err[] = {"EPERM", "ENOENT", "ESRCH", "EINTR", "EIO",
220 "ENXIO", "E2BIG", "ENOEXEC", "EBADF",
221 "ECHILD", "EAGAIN", "ENOMEM", "EACCES",
222 "EFAULT", "ENOTBLK", "EBUSY", "EEXIST",
223 "EXDEV", "ENODEV", "ENOTDIR", "EISDIR",
224 "EINVAL", "ENFILE", "EMFILE", "ENOTTY",
225 "ETXTBSY","EFBIG", "ENOSPC", "ESPIPE",
226 "EROFS","EMLINK", "EPIPE", "EDOM", "ERANGE"};
227 int i = 0, num = sizeof(err) / sizeof(void *);
228
229 while( i < num) {
230 if (!strcmp(err[i], str))
231 return i + 1;
232 i++;
233 }
234 return 0;
235}
236
237static int ignore_error_type(struct thread_data *td, int etype, char *str)
238{
239 unsigned int i;
240 int *error;
241 char *fname;
242
243 if (etype >= ERROR_TYPE_CNT) {
244 log_err("Illegal error type\n");
245 return 1;
246 }
247
248 td->o.ignore_error_nr[etype] = 4;
249 error = malloc(4 * sizeof(struct bssplit));
250
251 i = 0;
252 while ((fname = strsep(&str, ":")) != NULL) {
253
254 if (!strlen(fname))
255 break;
256
257 /*
258 * grow struct buffer, if needed
259 */
260 if (i == td->o.ignore_error_nr[etype]) {
261 td->o.ignore_error_nr[etype] <<= 1;
262 error = realloc(error, td->o.ignore_error_nr[etype]
263 * sizeof(int));
264 }
265 if (fname[0] == 'E') {
266 error[i] = str2error(fname);
267 } else {
268 error[i] = atoi(fname);
269 if (error[i] < 0)
270 error[i] = error[i];
271 }
272 if (!error[i]) {
273 log_err("Unknown error %s, please use number value \n",
274 fname);
275 return 1;
276 }
277 i++;
278 }
279 if (i) {
280 td->o.continue_on_error |= 1 << etype;
281 td->o.ignore_error_nr[etype] = i;
282 td->o.ignore_error[etype] = error;
283 }
284 return 0;
285
286}
287
288static int str_ignore_error_cb(void *data, const char *input)
289{
290 struct thread_data *td = data;
291 char *str, *p, *n;
292 int type = 0, ret = 1;
293 p = str = strdup(input);
294
295 strip_blank_front(&str);
296 strip_blank_end(str);
297
298 while (p) {
299 n = strchr(p, ',');
300 if (n)
301 *n++ = '\0';
302 ret = ignore_error_type(td, type, p);
303 if (ret)
304 break;
305 p = n;
306 type++;
307 }
308 free(str);
309 return ret;
310}
311
Jens Axboe211097b2007-03-22 18:56:45 +0100312static int str_rw_cb(void *data, const char *str)
313{
314 struct thread_data *td = data;
315 char *nr = get_opt_postfix(str);
316
Jens Axboe5736c102010-07-20 12:03:25 -0600317 td->o.ddir_seq_nr = 1;
Jens Axboe059b0802011-08-25 09:09:37 +0200318 td->o.ddir_seq_add = 0;
319
320 if (!nr)
321 return 0;
322
323 if (td_random(td))
Jens Axboe5736c102010-07-20 12:03:25 -0600324 td->o.ddir_seq_nr = atoi(nr);
Jens Axboe059b0802011-08-25 09:09:37 +0200325 else {
326 long long val;
327
Jens Axboe6925dd32011-09-07 22:10:11 +0200328 if (str_to_decimal(nr, &val, 1, td)) {
Jens Axboe059b0802011-08-25 09:09:37 +0200329 log_err("fio: rw postfix parsing failed\n");
330 free(nr);
331 return 1;
332 }
333
334 td->o.ddir_seq_add = val;
Jens Axboe182ec6e2008-11-14 13:06:06 +0100335 }
Jens Axboe211097b2007-03-22 18:56:45 +0100336
Jens Axboe059b0802011-08-25 09:09:37 +0200337 free(nr);
Jens Axboe211097b2007-03-22 18:56:45 +0100338 return 0;
339}
340
Jens Axboe214e1ec2007-03-15 10:48:13 +0100341static int str_mem_cb(void *data, const char *mem)
342{
343 struct thread_data *td = data;
344
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100345 if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP) {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100346 td->mmapfile = get_opt_postfix(mem);
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100347 if (td->o.mem_type == MEM_MMAPHUGE && !td->mmapfile) {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100348 log_err("fio: mmaphuge:/path/to/file\n");
349 return 1;
350 }
351 }
352
353 return 0;
354}
355
Jens Axboe5d7c5d32010-06-21 15:08:17 +0200356static int str_verify_cb(void *data, const char *mem)
357{
358 struct thread_data *td = data;
359
Jens Axboee3aaafc2012-02-22 20:28:17 +0100360 if (td->o.verify == VERIFY_CRC32C_INTEL ||
361 td->o.verify == VERIFY_CRC32C) {
362 crc32c_intel_probe();
Jens Axboe5d7c5d32010-06-21 15:08:17 +0200363 }
364
365 return 0;
366}
367
Jens Axboec223da82010-03-24 13:23:53 +0100368static int fio_clock_source_cb(void *data, const char *str)
369{
370 struct thread_data *td = data;
371
372 fio_clock_source = td->o.clocksource;
373 fio_time_init();
374 return 0;
375}
376
Cigy Cyriac85bc8332010-08-10 19:21:09 -0400377static int str_lockmem_cb(void fio_unused *data, unsigned long long *val)
Jens Axboe214e1ec2007-03-15 10:48:13 +0100378{
379 mlock_size = *val;
380 return 0;
381}
382
Cigy Cyriac85bc8332010-08-10 19:21:09 -0400383static int str_rwmix_read_cb(void *data, unsigned long long *val)
Jens Axboecb499fc2008-05-28 10:33:32 +0200384{
385 struct thread_data *td = data;
386
387 td->o.rwmix[DDIR_READ] = *val;
388 td->o.rwmix[DDIR_WRITE] = 100 - *val;
389 return 0;
390}
391
Cigy Cyriac85bc8332010-08-10 19:21:09 -0400392static int str_rwmix_write_cb(void *data, unsigned long long *val)
Jens Axboecb499fc2008-05-28 10:33:32 +0200393{
394 struct thread_data *td = data;
395
396 td->o.rwmix[DDIR_WRITE] = *val;
397 td->o.rwmix[DDIR_READ] = 100 - *val;
398 return 0;
399}
400
Jens Axboe214e1ec2007-03-15 10:48:13 +0100401#ifdef FIO_HAVE_IOPRIO
Cigy Cyriac85bc8332010-08-10 19:21:09 -0400402static int str_prioclass_cb(void *data, unsigned long long *val)
Jens Axboe214e1ec2007-03-15 10:48:13 +0100403{
404 struct thread_data *td = data;
Jens Axboe6cefbe32007-04-18 12:46:56 +0200405 unsigned short mask;
406
407 /*
408 * mask off old class bits, str_prio_cb() may have set a default class
409 */
410 mask = (1 << IOPRIO_CLASS_SHIFT) - 1;
411 td->ioprio &= mask;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100412
413 td->ioprio |= *val << IOPRIO_CLASS_SHIFT;
Jens Axboeac684782007-11-08 08:29:07 +0100414 td->ioprio_set = 1;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100415 return 0;
416}
417
Cigy Cyriac85bc8332010-08-10 19:21:09 -0400418static int str_prio_cb(void *data, unsigned long long *val)
Jens Axboe214e1ec2007-03-15 10:48:13 +0100419{
420 struct thread_data *td = data;
421
422 td->ioprio |= *val;
Jens Axboe6cefbe32007-04-18 12:46:56 +0200423
424 /*
425 * If no class is set, assume BE
426 */
427 if ((td->ioprio >> IOPRIO_CLASS_SHIFT) == 0)
428 td->ioprio |= IOPRIO_CLASS_BE << IOPRIO_CLASS_SHIFT;
429
Jens Axboeac684782007-11-08 08:29:07 +0100430 td->ioprio_set = 1;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100431 return 0;
432}
433#endif
434
435static int str_exitall_cb(void)
436{
437 exitall_on_terminate = 1;
438 return 0;
439}
440
Jens Axboe214e1ec2007-03-15 10:48:13 +0100441#ifdef FIO_HAVE_CPU_AFFINITY
Cigy Cyriac85bc8332010-08-10 19:21:09 -0400442static int str_cpumask_cb(void *data, unsigned long long *val)
Jens Axboe214e1ec2007-03-15 10:48:13 +0100443{
444 struct thread_data *td = data;
Jens Axboed2e268b2007-06-15 10:33:49 +0200445 unsigned int i;
Jens Axboeb03daaf2008-12-08 20:31:43 +0100446 long max_cpu;
Jens Axboed2ce18b2008-12-12 20:51:40 +0100447 int ret;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100448
Jens Axboed2ce18b2008-12-12 20:51:40 +0100449 ret = fio_cpuset_init(&td->o.cpumask);
450 if (ret < 0) {
451 log_err("fio: cpuset_init failed\n");
452 td_verror(td, ret, "fio_cpuset_init");
453 return 1;
454 }
455
Jens Axboec00a2282011-07-08 20:56:06 +0200456 max_cpu = cpus_online();
Jens Axboed2e268b2007-06-15 10:33:49 +0200457
Jens Axboe62a72732008-12-08 11:37:01 +0100458 for (i = 0; i < sizeof(int) * 8; i++) {
459 if ((1 << i) & *val) {
Jens Axboeb03daaf2008-12-08 20:31:43 +0100460 if (i > max_cpu) {
461 log_err("fio: CPU %d too large (max=%ld)\n", i,
462 max_cpu);
463 return 1;
464 }
Jens Axboe62a72732008-12-08 11:37:01 +0100465 dprint(FD_PARSE, "set cpu allowed %d\n", i);
Jens Axboe6d459ee2008-12-12 20:02:58 +0100466 fio_cpu_set(&td->o.cpumask, i);
Jens Axboe62a72732008-12-08 11:37:01 +0100467 }
468 }
Jens Axboed2e268b2007-06-15 10:33:49 +0200469
Jens Axboe375b2692007-05-22 09:13:02 +0200470 td->o.cpumask_set = 1;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100471 return 0;
472}
473
Jens Axboee8462bd2009-07-06 12:59:04 +0200474static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask,
475 const char *input)
Jens Axboed2e268b2007-06-15 10:33:49 +0200476{
Jens Axboed2e268b2007-06-15 10:33:49 +0200477 char *cpu, *str, *p;
Jens Axboeb03daaf2008-12-08 20:31:43 +0100478 long max_cpu;
Jens Axboe19608d62008-12-08 15:03:12 +0100479 int ret = 0;
Jens Axboed2e268b2007-06-15 10:33:49 +0200480
Jens Axboee8462bd2009-07-06 12:59:04 +0200481 ret = fio_cpuset_init(mask);
Jens Axboed2ce18b2008-12-12 20:51:40 +0100482 if (ret < 0) {
483 log_err("fio: cpuset_init failed\n");
484 td_verror(td, ret, "fio_cpuset_init");
485 return 1;
486 }
Jens Axboed2e268b2007-06-15 10:33:49 +0200487
488 p = str = strdup(input);
489
490 strip_blank_front(&str);
491 strip_blank_end(str);
492
Jens Axboec00a2282011-07-08 20:56:06 +0200493 max_cpu = cpus_online();
Jens Axboeb03daaf2008-12-08 20:31:43 +0100494
Jens Axboed2e268b2007-06-15 10:33:49 +0200495 while ((cpu = strsep(&str, ",")) != NULL) {
Jens Axboe62a72732008-12-08 11:37:01 +0100496 char *str2, *cpu2;
497 int icpu, icpu2;
498
Jens Axboed2e268b2007-06-15 10:33:49 +0200499 if (!strlen(cpu))
500 break;
Jens Axboe62a72732008-12-08 11:37:01 +0100501
502 str2 = cpu;
503 icpu2 = -1;
504 while ((cpu2 = strsep(&str2, "-")) != NULL) {
505 if (!strlen(cpu2))
506 break;
507
508 icpu2 = atoi(cpu2);
509 }
510
511 icpu = atoi(cpu);
512 if (icpu2 == -1)
513 icpu2 = icpu;
514 while (icpu <= icpu2) {
Jens Axboe6d459ee2008-12-12 20:02:58 +0100515 if (icpu >= FIO_MAX_CPUS) {
Jens Axboe19608d62008-12-08 15:03:12 +0100516 log_err("fio: your OS only supports up to"
Jens Axboe6d459ee2008-12-12 20:02:58 +0100517 " %d CPUs\n", (int) FIO_MAX_CPUS);
Jens Axboe19608d62008-12-08 15:03:12 +0100518 ret = 1;
519 break;
520 }
Jens Axboeb03daaf2008-12-08 20:31:43 +0100521 if (icpu > max_cpu) {
522 log_err("fio: CPU %d too large (max=%ld)\n",
523 icpu, max_cpu);
524 ret = 1;
525 break;
526 }
Jens Axboe0b9d69e2009-09-11 22:29:54 +0200527
Jens Axboe62a72732008-12-08 11:37:01 +0100528 dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
Jens Axboee8462bd2009-07-06 12:59:04 +0200529 fio_cpu_set(mask, icpu);
Jens Axboe62a72732008-12-08 11:37:01 +0100530 icpu++;
531 }
Jens Axboe19608d62008-12-08 15:03:12 +0100532 if (ret)
533 break;
Jens Axboed2e268b2007-06-15 10:33:49 +0200534 }
535
536 free(p);
Jens Axboe19608d62008-12-08 15:03:12 +0100537 if (!ret)
538 td->o.cpumask_set = 1;
539 return ret;
Jens Axboed2e268b2007-06-15 10:33:49 +0200540}
Jens Axboee8462bd2009-07-06 12:59:04 +0200541
542static int str_cpus_allowed_cb(void *data, const char *input)
543{
544 struct thread_data *td = data;
545 int ret;
546
547 ret = set_cpus_allowed(td, &td->o.cpumask, input);
548 if (!ret)
549 td->o.cpumask_set = 1;
550
551 return ret;
552}
553
554static int str_verify_cpus_allowed_cb(void *data, const char *input)
555{
556 struct thread_data *td = data;
557 int ret;
558
559 ret = set_cpus_allowed(td, &td->o.verify_cpumask, input);
560 if (!ret)
561 td->o.verify_cpumask_set = 1;
562
563 return ret;
564}
Jens Axboed2e268b2007-06-15 10:33:49 +0200565#endif
566
Jens Axboe0d29de82010-09-01 13:54:15 +0200567#ifdef FIO_HAVE_TRIM
568static int str_verify_trim_cb(void *data, unsigned long long *val)
569{
570 struct thread_data *td = data;
571
572 td->o.trim_percentage = *val;
573 return 0;
574}
575#endif
576
Jens Axboe214e1ec2007-03-15 10:48:13 +0100577static int str_fst_cb(void *data, const char *str)
578{
579 struct thread_data *td = data;
580 char *nr = get_opt_postfix(str);
581
582 td->file_service_nr = 1;
Jens Axboe182ec6e2008-11-14 13:06:06 +0100583 if (nr) {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100584 td->file_service_nr = atoi(nr);
Jens Axboe182ec6e2008-11-14 13:06:06 +0100585 free(nr);
586 }
Jens Axboe214e1ec2007-03-15 10:48:13 +0100587
588 return 0;
589}
590
Jens Axboe3ae06372010-03-19 19:17:15 +0100591#ifdef FIO_HAVE_SYNC_FILE_RANGE
Jens Axboe44f29692010-03-09 20:09:44 +0100592static int str_sfr_cb(void *data, const char *str)
593{
594 struct thread_data *td = data;
595 char *nr = get_opt_postfix(str);
596
597 td->sync_file_range_nr = 1;
598 if (nr) {
599 td->sync_file_range_nr = atoi(nr);
600 free(nr);
601 }
602
603 return 0;
604}
Jens Axboe3ae06372010-03-19 19:17:15 +0100605#endif
Jens Axboe44f29692010-03-09 20:09:44 +0100606
Jens Axboe921c7662008-03-26 09:17:55 +0100607static int check_dir(struct thread_data *td, char *fname)
608{
Jens Axboe3f0ca9b2011-05-24 21:36:24 +0200609#if 0
Jens Axboe921c7662008-03-26 09:17:55 +0100610 char file[PATH_MAX], *dir;
Jens Axboebc838912008-04-07 09:00:54 +0200611 int elen = 0;
Jens Axboe921c7662008-03-26 09:17:55 +0100612
Jens Axboebc838912008-04-07 09:00:54 +0200613 if (td->o.directory) {
614 strcpy(file, td->o.directory);
Jens Axboefcef0b32008-05-26 14:53:24 +0200615 strcat(file, "/");
Jens Axboebc838912008-04-07 09:00:54 +0200616 elen = strlen(file);
617 }
618
Jens Axboefcef0b32008-05-26 14:53:24 +0200619 sprintf(file + elen, "%s", fname);
Jens Axboe921c7662008-03-26 09:17:55 +0100620 dir = dirname(file);
621
Jens Axboefcef0b32008-05-26 14:53:24 +0200622 {
623 struct stat sb;
624 /*
625 * We can't do this on FIO_DISKLESSIO engines. The engine isn't loaded
626 * yet, so we can't do this check right here...
627 */
Jens Axboe921c7662008-03-26 09:17:55 +0100628 if (lstat(dir, &sb) < 0) {
629 int ret = errno;
630
631 log_err("fio: %s is not a directory\n", dir);
632 td_verror(td, ret, "lstat");
633 return 1;
634 }
635
636 if (!S_ISDIR(sb.st_mode)) {
637 log_err("fio: %s is not a directory\n", dir);
638 return 1;
639 }
Jens Axboefcef0b32008-05-26 14:53:24 +0200640 }
641#endif
Jens Axboe921c7662008-03-26 09:17:55 +0100642
643 return 0;
644}
645
Jens Axboe8e827d32009-08-04 09:51:48 +0200646/*
647 * Return next file in the string. Files are separated with ':'. If the ':'
648 * is escaped with a '\', then that ':' is part of the filename and does not
649 * indicate a new file.
650 */
651static char *get_next_file_name(char **ptr)
652{
653 char *str = *ptr;
654 char *p, *start;
655
656 if (!str || !strlen(str))
657 return NULL;
658
659 start = str;
660 do {
661 /*
662 * No colon, we are done
663 */
664 p = strchr(str, ':');
665 if (!p) {
666 *ptr = NULL;
667 break;
668 }
669
670 /*
671 * We got a colon, but it's the first character. Skip and
672 * continue
673 */
674 if (p == start) {
675 str = ++start;
676 continue;
677 }
678
679 if (*(p - 1) != '\\') {
680 *p = '\0';
681 *ptr = p + 1;
682 break;
683 }
684
685 memmove(p - 1, p, strlen(p) + 1);
686 str = p;
687 } while (1);
688
689 return start;
690}
691
Jens Axboe214e1ec2007-03-15 10:48:13 +0100692static int str_filename_cb(void *data, const char *input)
693{
694 struct thread_data *td = data;
695 char *fname, *str, *p;
696
697 p = str = strdup(input);
698
699 strip_blank_front(&str);
700 strip_blank_end(str);
701
702 if (!td->files_index)
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100703 td->o.nr_files = 0;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100704
Jens Axboe8e827d32009-08-04 09:51:48 +0200705 while ((fname = get_next_file_name(&str)) != NULL) {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100706 if (!strlen(fname))
707 break;
Jens Axboe921c7662008-03-26 09:17:55 +0100708 if (check_dir(td, fname)) {
709 free(p);
710 return 1;
711 }
Jens Axboe214e1ec2007-03-15 10:48:13 +0100712 add_file(td, fname);
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100713 td->o.nr_files++;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100714 }
715
716 free(p);
717 return 0;
718}
719
720static int str_directory_cb(void *data, const char fio_unused *str)
721{
722 struct thread_data *td = data;
723 struct stat sb;
724
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100725 if (lstat(td->o.directory, &sb) < 0) {
Jens Axboe921c7662008-03-26 09:17:55 +0100726 int ret = errno;
727
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100728 log_err("fio: %s is not a directory\n", td->o.directory);
Jens Axboe921c7662008-03-26 09:17:55 +0100729 td_verror(td, ret, "lstat");
Jens Axboe214e1ec2007-03-15 10:48:13 +0100730 return 1;
731 }
732 if (!S_ISDIR(sb.st_mode)) {
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100733 log_err("fio: %s is not a directory\n", td->o.directory);
Jens Axboe214e1ec2007-03-15 10:48:13 +0100734 return 1;
735 }
736
737 return 0;
738}
739
740static int str_opendir_cb(void *data, const char fio_unused *str)
741{
742 struct thread_data *td = data;
743
744 if (!td->files_index)
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100745 td->o.nr_files = 0;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100746
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100747 return add_dir_files(td, td->o.opendir);
Jens Axboe214e1ec2007-03-15 10:48:13 +0100748}
749
Cigy Cyriac85bc8332010-08-10 19:21:09 -0400750static int str_verify_offset_cb(void *data, unsigned long long *off)
Shawn Lewis546a9142007-07-28 21:11:37 +0200751{
752 struct thread_data *td = data;
Jens Axboea59e1702007-07-30 08:53:27 +0200753
Shawn Lewis546a9142007-07-28 21:11:37 +0200754 if (*off && *off < sizeof(struct verify_header)) {
Jens Axboea59e1702007-07-30 08:53:27 +0200755 log_err("fio: verify_offset too small\n");
Shawn Lewis546a9142007-07-28 21:11:37 +0200756 return 1;
757 }
Jens Axboea59e1702007-07-30 08:53:27 +0200758
759 td->o.verify_offset = *off;
Shawn Lewis546a9142007-07-28 21:11:37 +0200760 return 0;
761}
762
Radha Ramachandran0e92f872009-10-27 20:14:27 +0100763static int str_verify_pattern_cb(void *data, const char *input)
Jens Axboe90059d62007-07-30 09:33:12 +0200764{
765 struct thread_data *td = data;
Radha Ramachandran0e92f872009-10-27 20:14:27 +0100766 long off;
767 int i = 0, j = 0, len, k, base = 10;
768 char* loc1, * loc2;
Jens Axboe90059d62007-07-30 09:33:12 +0200769
Radha Ramachandran0e92f872009-10-27 20:14:27 +0100770 loc1 = strstr(input, "0x");
771 loc2 = strstr(input, "0X");
772 if (loc1 || loc2)
773 base = 16;
774 off = strtol(input, NULL, base);
775 if (off != LONG_MAX || errno != ERANGE) {
776 while (off) {
777 td->o.verify_pattern[i] = off & 0xff;
778 off >>= 8;
779 i++;
780 }
781 } else {
782 len = strlen(input);
783 k = len - 1;
784 if (base == 16) {
785 if (loc1)
786 j = loc1 - input + 2;
787 else
788 j = loc2 - input + 2;
789 } else
790 return 1;
791 if (len - j < MAX_PATTERN_SIZE * 2) {
792 while (k >= j) {
793 off = converthexchartoint(input[k--]);
794 if (k >= j)
795 off += (converthexchartoint(input[k--])
796 * 16);
797 td->o.verify_pattern[i++] = (char) off;
798 }
799 }
800 }
Steven Langefcd9dc2012-02-02 20:22:04 +0100801
802 /*
803 * Fill the pattern all the way to the end. This greatly reduces
804 * the number of memcpy's we have to do when verifying the IO.
805 */
806 while (i > 1 && i * 2 <= MAX_PATTERN_SIZE) {
807 memcpy(&td->o.verify_pattern[i], &td->o.verify_pattern[0], i);
808 i *= 2;
809 }
Steven Lang9a2a86d2012-02-07 09:42:59 +0100810 if (i == 1) {
811 /*
812 * The code in verify_io_u_pattern assumes a single byte pattern
813 * fills the whole verify pattern buffer.
814 */
815 memset(td->o.verify_pattern, td->o.verify_pattern[0],
816 MAX_PATTERN_SIZE);
817 }
Steven Langefcd9dc2012-02-02 20:22:04 +0100818
Radha Ramachandran0e92f872009-10-27 20:14:27 +0100819 td->o.verify_pattern_bytes = i;
Steven Langefcd9dc2012-02-02 20:22:04 +0100820
Jens Axboe92bf48d2011-01-14 21:20:42 +0100821 /*
822 * VERIFY_META could already be set
823 */
824 if (td->o.verify == VERIFY_NONE)
825 td->o.verify = VERIFY_PATTERN;
Steven Langefcd9dc2012-02-02 20:22:04 +0100826
Jens Axboe90059d62007-07-30 09:33:12 +0200827 return 0;
828}
Jens Axboe214e1ec2007-03-15 10:48:13 +0100829
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100830static int str_lockfile_cb(void *data, const char *str)
831{
832 struct thread_data *td = data;
833 char *nr = get_opt_postfix(str);
834
835 td->o.lockfile_batch = 1;
Jens Axboe182ec6e2008-11-14 13:06:06 +0100836 if (nr) {
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100837 td->o.lockfile_batch = atoi(nr);
Jens Axboe182ec6e2008-11-14 13:06:06 +0100838 free(nr);
839 }
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100840
841 return 0;
842}
843
Jens Axboee3cedca2008-11-19 19:57:52 +0100844static int str_write_bw_log_cb(void *data, const char *str)
845{
846 struct thread_data *td = data;
847
848 if (str)
849 td->o.bw_log_file = strdup(str);
850
851 td->o.write_bw_log = 1;
852 return 0;
853}
854
855static int str_write_lat_log_cb(void *data, const char *str)
856{
857 struct thread_data *td = data;
858
859 if (str)
860 td->o.lat_log_file = strdup(str);
861
862 td->o.write_lat_log = 1;
863 return 0;
864}
865
Jens Axboec8eeb9d2011-10-05 14:02:22 +0200866static int str_write_iops_log_cb(void *data, const char *str)
867{
868 struct thread_data *td = data;
869
870 if (str)
871 td->o.iops_log_file = strdup(str);
872
873 td->o.write_iops_log = 1;
874 return 0;
875}
876
Jens Axboe993bf482008-11-14 13:04:53 +0100877static int str_gtod_reduce_cb(void *data, int *il)
878{
879 struct thread_data *td = data;
880 int val = *il;
881
Jens Axboe02af0982010-06-24 09:59:34 +0200882 td->o.disable_lat = !!val;
Jens Axboe993bf482008-11-14 13:04:53 +0100883 td->o.disable_clat = !!val;
884 td->o.disable_slat = !!val;
885 td->o.disable_bw = !!val;
Jens Axboe0dc1bc02011-10-13 08:55:29 +0200886 td->o.clat_percentiles = !val;
Jens Axboe993bf482008-11-14 13:04:53 +0100887 if (val)
888 td->tv_cache_mask = 63;
889
890 return 0;
891}
892
Cigy Cyriac85bc8332010-08-10 19:21:09 -0400893static int str_gtod_cpu_cb(void *data, long long *il)
Jens Axboebe4ecfd2008-12-08 14:10:52 +0100894{
895 struct thread_data *td = data;
896 int val = *il;
897
898 td->o.gtod_cpu = val;
899 td->o.gtod_offload = 1;
900 return 0;
901}
902
Jens Axboe7bb59102011-07-12 19:47:03 +0200903static int str_size_cb(void *data, unsigned long long *__val)
904{
905 struct thread_data *td = data;
906 unsigned long long v = *__val;
907
908 if (parse_is_percent(v)) {
909 td->o.size = 0;
910 td->o.size_percent = -1ULL - v;
911 } else
912 td->o.size = v;
913
914 return 0;
915}
916
Jens Axboe896cac22009-07-01 10:38:35 +0200917static int rw_verify(struct fio_option *o, void *data)
918{
919 struct thread_data *td = data;
920
921 if (read_only && td_write(td)) {
922 log_err("fio: job <%s> has write bit set, but fio is in"
923 " read-only mode\n", td->o.name);
924 return 1;
925 }
926
927 return 0;
928}
929
Jens Axboe276ca4f2009-07-01 10:43:05 +0200930static int gtod_cpu_verify(struct fio_option *o, void *data)
Jens Axboe29d43ff2009-07-01 10:42:18 +0200931{
Jens Axboe276ca4f2009-07-01 10:43:05 +0200932#ifndef FIO_HAVE_CPU_AFFINITY
Jens Axboe29d43ff2009-07-01 10:42:18 +0200933 struct thread_data *td = data;
934
Jens Axboe29d43ff2009-07-01 10:42:18 +0200935 if (td->o.gtod_cpu) {
936 log_err("fio: platform must support CPU affinity for"
937 "gettimeofday() offloading\n");
938 return 1;
939 }
940#endif
941
942 return 0;
943}
944
Jens Axboe90fef2d2009-07-17 22:33:32 +0200945static int kb_base_verify(struct fio_option *o, void *data)
946{
947 struct thread_data *td = data;
948
949 if (td->o.kb_base != 1024 && td->o.kb_base != 1000) {
950 log_err("fio: kb_base set to nonsensical value: %u\n",
951 td->o.kb_base);
952 return 1;
953 }
954
955 return 0;
956}
957
Jens Axboe214e1ec2007-03-15 10:48:13 +0100958/*
959 * Map of job/command line options
960 */
Jens Axboe07b32322010-03-05 09:48:44 +0100961static struct fio_option options[FIO_MAX_OPTS] = {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100962 {
963 .name = "description",
964 .type = FIO_OPT_STR_STORE,
965 .off1 = td_var_offset(description),
966 .help = "Text job description",
967 },
968 {
969 .name = "name",
970 .type = FIO_OPT_STR_STORE,
971 .off1 = td_var_offset(name),
972 .help = "Name of this job",
973 },
974 {
975 .name = "directory",
976 .type = FIO_OPT_STR_STORE,
977 .off1 = td_var_offset(directory),
978 .cb = str_directory_cb,
979 .help = "Directory to store files in",
980 },
981 {
982 .name = "filename",
983 .type = FIO_OPT_STR_STORE,
984 .off1 = td_var_offset(filename),
985 .cb = str_filename_cb,
Jens Axboef0d524b2009-04-27 08:00:48 +0200986 .prio = -1, /* must come after "directory" */
Jens Axboe214e1ec2007-03-15 10:48:13 +0100987 .help = "File(s) to use for the workload",
988 },
989 {
Jens Axboe90fef2d2009-07-17 22:33:32 +0200990 .name = "kb_base",
991 .type = FIO_OPT_INT,
992 .off1 = td_var_offset(kb_base),
Jens Axboe90fef2d2009-07-17 22:33:32 +0200993 .verify = kb_base_verify,
Jens Axboea639f0b2009-07-18 08:25:35 +0200994 .prio = 1,
Jens Axboe90fef2d2009-07-17 22:33:32 +0200995 .def = "1024",
Jens Axboea639f0b2009-07-18 08:25:35 +0200996 .help = "How many bytes per KB for reporting (1000 or 1024)",
Jens Axboe90fef2d2009-07-17 22:33:32 +0200997 },
998 {
Jens Axboe29c13492008-03-01 19:25:20 +0100999 .name = "lockfile",
Jens Axboe4d4e80f2008-03-04 10:18:56 +01001000 .type = FIO_OPT_STR,
1001 .cb = str_lockfile_cb,
1002 .off1 = td_var_offset(file_lock_mode),
Jens Axboe29c13492008-03-01 19:25:20 +01001003 .help = "Lock file when doing IO to it",
1004 .parent = "filename",
Jens Axboe4d4e80f2008-03-04 10:18:56 +01001005 .def = "none",
1006 .posval = {
1007 { .ival = "none",
1008 .oval = FILE_LOCK_NONE,
1009 .help = "No file locking",
1010 },
1011 { .ival = "exclusive",
1012 .oval = FILE_LOCK_EXCLUSIVE,
1013 .help = "Exclusive file lock",
1014 },
1015 {
1016 .ival = "readwrite",
1017 .oval = FILE_LOCK_READWRITE,
1018 .help = "Read vs write lock",
1019 },
1020 },
Jens Axboe29c13492008-03-01 19:25:20 +01001021 },
1022 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001023 .name = "opendir",
1024 .type = FIO_OPT_STR_STORE,
1025 .off1 = td_var_offset(opendir),
1026 .cb = str_opendir_cb,
1027 .help = "Recursively add files from this directory and down",
1028 },
1029 {
1030 .name = "rw",
Jens Axboed3aad8f2007-03-15 14:12:05 +01001031 .alias = "readwrite",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001032 .type = FIO_OPT_STR,
Jens Axboe211097b2007-03-22 18:56:45 +01001033 .cb = str_rw_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001034 .off1 = td_var_offset(td_ddir),
1035 .help = "IO direction",
1036 .def = "read",
Jens Axboe896cac22009-07-01 10:38:35 +02001037 .verify = rw_verify,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001038 .posval = {
1039 { .ival = "read",
1040 .oval = TD_DDIR_READ,
1041 .help = "Sequential read",
1042 },
1043 { .ival = "write",
1044 .oval = TD_DDIR_WRITE,
1045 .help = "Sequential write",
1046 },
Shaohua Li6eaf09d2012-09-14 08:49:43 +02001047 { .ival = "trim",
1048 .oval = TD_DDIR_TRIM,
1049 .help = "Sequential trim",
1050 },
Jens Axboe214e1ec2007-03-15 10:48:13 +01001051 { .ival = "randread",
1052 .oval = TD_DDIR_RANDREAD,
1053 .help = "Random read",
1054 },
1055 { .ival = "randwrite",
1056 .oval = TD_DDIR_RANDWRITE,
1057 .help = "Random write",
1058 },
Shaohua Li6eaf09d2012-09-14 08:49:43 +02001059 { .ival = "randtrim",
1060 .oval = TD_DDIR_RANDTRIM,
1061 .help = "Random trim",
1062 },
Jens Axboe214e1ec2007-03-15 10:48:13 +01001063 { .ival = "rw",
1064 .oval = TD_DDIR_RW,
1065 .help = "Sequential read and write mix",
1066 },
Jens Axboe10b023d2012-03-23 13:40:06 +01001067 { .ival = "readwrite",
1068 .oval = TD_DDIR_RW,
1069 .help = "Sequential read and write mix",
1070 },
Jens Axboe214e1ec2007-03-15 10:48:13 +01001071 { .ival = "randrw",
1072 .oval = TD_DDIR_RANDRW,
1073 .help = "Random read and write mix"
1074 },
1075 },
1076 },
1077 {
Jens Axboe38dad622010-07-20 14:46:00 -06001078 .name = "rw_sequencer",
1079 .type = FIO_OPT_STR,
1080 .off1 = td_var_offset(rw_seq),
1081 .help = "IO offset generator modifier",
1082 .def = "sequential",
1083 .posval = {
1084 { .ival = "sequential",
1085 .oval = RW_SEQ_SEQ,
1086 .help = "Generate sequential offsets",
1087 },
1088 { .ival = "identical",
1089 .oval = RW_SEQ_IDENT,
1090 .help = "Generate identical offsets",
1091 },
1092 },
1093 },
1094
1095 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001096 .name = "ioengine",
1097 .type = FIO_OPT_STR_STORE,
1098 .off1 = td_var_offset(ioengine),
1099 .help = "IO engine to use",
Jens Axboe58483fa2011-01-19 11:09:58 -07001100 .def = FIO_PREFERRED_ENGINE,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001101 .posval = {
1102 { .ival = "sync",
1103 .help = "Use read/write",
1104 },
gurudas paia31041e2007-10-23 15:12:30 +02001105 { .ival = "psync",
1106 .help = "Use pread/pwrite",
1107 },
Jens Axboe1d2af022008-02-04 10:59:07 +01001108 { .ival = "vsync",
Bruce Cran03e20d62011-01-02 20:14:54 +01001109 .help = "Use readv/writev",
Jens Axboe1d2af022008-02-04 10:59:07 +01001110 },
Jens Axboe214e1ec2007-03-15 10:48:13 +01001111#ifdef FIO_HAVE_LIBAIO
1112 { .ival = "libaio",
1113 .help = "Linux native asynchronous IO",
1114 },
1115#endif
1116#ifdef FIO_HAVE_POSIXAIO
1117 { .ival = "posixaio",
1118 .help = "POSIX asynchronous IO",
1119 },
1120#endif
Jens Axboe417f0062008-06-02 11:59:30 +02001121#ifdef FIO_HAVE_SOLARISAIO
1122 { .ival = "solarisaio",
1123 .help = "Solaris native asynchronous IO",
1124 },
1125#endif
Bruce Cran03e20d62011-01-02 20:14:54 +01001126#ifdef FIO_HAVE_WINDOWSAIO
1127 { .ival = "windowsaio",
Jens Axboe3be80072011-01-19 11:07:28 -07001128 .help = "Windows native asynchronous IO"
Steven Langde890a12011-11-09 14:03:34 +01001129 },
Jens Axboe3be80072011-01-19 11:07:28 -07001130#endif
Jens Axboe214e1ec2007-03-15 10:48:13 +01001131 { .ival = "mmap",
Bruce Cran03e20d62011-01-02 20:14:54 +01001132 .help = "Memory mapped IO"
Jens Axboe214e1ec2007-03-15 10:48:13 +01001133 },
1134#ifdef FIO_HAVE_SPLICE
1135 { .ival = "splice",
1136 .help = "splice/vmsplice based IO",
1137 },
Jens Axboe9cce02e2007-06-22 15:42:21 +02001138 { .ival = "netsplice",
1139 .help = "splice/vmsplice to/from the network",
1140 },
Jens Axboe214e1ec2007-03-15 10:48:13 +01001141#endif
1142#ifdef FIO_HAVE_SGIO
1143 { .ival = "sg",
1144 .help = "SCSI generic v3 IO",
1145 },
1146#endif
1147 { .ival = "null",
1148 .help = "Testing engine (no data transfer)",
1149 },
1150 { .ival = "net",
1151 .help = "Network IO",
1152 },
1153#ifdef FIO_HAVE_SYSLET
1154 { .ival = "syslet-rw",
1155 .help = "syslet enabled async pread/pwrite IO",
1156 },
1157#endif
1158 { .ival = "cpuio",
Bruce Cran03e20d62011-01-02 20:14:54 +01001159 .help = "CPU cycle burner engine",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001160 },
Jens Axboeb8c82a42007-03-21 08:48:26 +01001161#ifdef FIO_HAVE_GUASI
1162 { .ival = "guasi",
1163 .help = "GUASI IO engine",
1164 },
1165#endif
Jens Axboe79a43182010-09-07 13:28:58 +02001166#ifdef FIO_HAVE_BINJECT
1167 { .ival = "binject",
1168 .help = "binject direct inject block engine",
1169 },
1170#endif
ren yufei21b8aee2011-08-01 10:01:57 +02001171#ifdef FIO_HAVE_RDMA
1172 { .ival = "rdma",
1173 .help = "RDMA IO engine",
1174 },
1175#endif
Jens Axboe8200b8c2012-09-18 23:55:43 +02001176#ifdef FIO_HAVE_FUSION_AW
1177 { .ival = "fusion-aw-sync",
1178 .help = "Fusion-io atomic write engine",
1179 },
1180#endif
Jens Axboe1ecc95c2012-09-20 13:46:34 +02001181#ifdef FIO_HAVE_E4_ENG
1182 { .ival = "e4defrag",
1183 .help = "ext4 defrag engine",
1184 },
1185#endif
1186#ifdef FIO_HAVE_FALLOC_ENG
1187 { .ival = "falloc",
1188 .help = "fallocate() file based engine",
1189 },
1190#endif
Jens Axboe214e1ec2007-03-15 10:48:13 +01001191 { .ival = "external",
1192 .help = "Load external engine (append name)",
1193 },
1194 },
1195 },
1196 {
1197 .name = "iodepth",
1198 .type = FIO_OPT_INT,
1199 .off1 = td_var_offset(iodepth),
Bruce Cran03e20d62011-01-02 20:14:54 +01001200 .help = "Number of IO buffers to keep in flight",
Jens Axboe757aff42007-12-12 19:42:13 +01001201 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001202 .def = "1",
1203 },
1204 {
1205 .name = "iodepth_batch",
Jens Axboe49504212008-06-05 09:03:30 +02001206 .alias = "iodepth_batch_submit",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001207 .type = FIO_OPT_INT,
1208 .off1 = td_var_offset(iodepth_batch),
Jens Axboed65db442009-01-16 19:15:33 +01001209 .help = "Number of IO buffers to submit in one go",
Jens Axboeafdf9352007-07-31 16:14:34 +02001210 .parent = "iodepth",
Jens Axboea2e6f8a2008-01-18 10:28:11 +01001211 .minval = 1,
1212 .def = "1",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001213 },
1214 {
Jens Axboe49504212008-06-05 09:03:30 +02001215 .name = "iodepth_batch_complete",
1216 .type = FIO_OPT_INT,
1217 .off1 = td_var_offset(iodepth_batch_complete),
Jens Axboed65db442009-01-16 19:15:33 +01001218 .help = "Number of IO buffers to retrieve in one go",
Jens Axboe49504212008-06-05 09:03:30 +02001219 .parent = "iodepth",
1220 .minval = 0,
1221 .def = "1",
1222 },
1223 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001224 .name = "iodepth_low",
1225 .type = FIO_OPT_INT,
1226 .off1 = td_var_offset(iodepth_low),
1227 .help = "Low water mark for queuing depth",
Jens Axboeafdf9352007-07-31 16:14:34 +02001228 .parent = "iodepth",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001229 },
1230 {
1231 .name = "size",
1232 .type = FIO_OPT_STR_VAL,
Jens Axboe7bb59102011-07-12 19:47:03 +02001233 .cb = str_size_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001234 .help = "Total size of device or files",
1235 },
1236 {
Shawn Lewisaa31f1f2008-01-11 09:45:11 +01001237 .name = "fill_device",
Jens Axboe74586c12011-01-20 10:16:03 -07001238 .alias = "fill_fs",
Shawn Lewisaa31f1f2008-01-11 09:45:11 +01001239 .type = FIO_OPT_BOOL,
1240 .off1 = td_var_offset(fill_device),
1241 .help = "Write until an ENOSPC error occurs",
1242 .def = "0",
1243 },
1244 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001245 .name = "filesize",
1246 .type = FIO_OPT_STR_VAL,
1247 .off1 = td_var_offset(file_size_low),
1248 .off2 = td_var_offset(file_size_high),
Jens Axboec3edbdb2007-07-20 14:25:31 +02001249 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001250 .help = "Size of individual files",
1251 },
1252 {
Jens Axboe67a10002007-07-31 23:12:16 +02001253 .name = "offset",
1254 .alias = "fileoffset",
1255 .type = FIO_OPT_STR_VAL,
1256 .off1 = td_var_offset(start_offset),
1257 .help = "Start IO from this offset",
1258 .def = "0",
1259 },
1260 {
Jens Axboe2d7cd862012-03-15 14:53:38 +01001261 .name = "offset_increment",
1262 .type = FIO_OPT_STR_VAL,
1263 .off1 = td_var_offset(offset_increment),
1264 .help = "What is the increment from one offset to the next",
1265 .parent = "offset",
1266 .def = "0",
1267 },
1268 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001269 .name = "bs",
Jens Axboed3aad8f2007-03-15 14:12:05 +01001270 .alias = "blocksize",
Jens Axboee01b22b2009-06-09 15:43:25 +02001271 .type = FIO_OPT_INT,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001272 .off1 = td_var_offset(bs[DDIR_READ]),
1273 .off2 = td_var_offset(bs[DDIR_WRITE]),
Shaohua Li6eaf09d2012-09-14 08:49:43 +02001274 .off3 = td_var_offset(bs[DDIR_TRIM]),
Jens Axboec3edbdb2007-07-20 14:25:31 +02001275 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001276 .help = "Block size unit",
1277 .def = "4k",
Jens Axboe67a10002007-07-31 23:12:16 +02001278 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001279 },
1280 {
Jens Axboe2b7a01d2009-03-11 11:00:13 +01001281 .name = "ba",
1282 .alias = "blockalign",
Jens Axboee01b22b2009-06-09 15:43:25 +02001283 .type = FIO_OPT_INT,
Jens Axboe2b7a01d2009-03-11 11:00:13 +01001284 .off1 = td_var_offset(ba[DDIR_READ]),
1285 .off2 = td_var_offset(ba[DDIR_WRITE]),
Shaohua Li6eaf09d2012-09-14 08:49:43 +02001286 .off3 = td_var_offset(ba[DDIR_TRIM]),
Jens Axboe2b7a01d2009-03-11 11:00:13 +01001287 .minval = 1,
1288 .help = "IO block offset alignment",
1289 .parent = "rw",
1290 },
1291 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001292 .name = "bsrange",
Jens Axboed3aad8f2007-03-15 14:12:05 +01001293 .alias = "blocksize_range",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001294 .type = FIO_OPT_RANGE,
1295 .off1 = td_var_offset(min_bs[DDIR_READ]),
1296 .off2 = td_var_offset(max_bs[DDIR_READ]),
1297 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
1298 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
Shaohua Li6eaf09d2012-09-14 08:49:43 +02001299 .off5 = td_var_offset(min_bs[DDIR_TRIM]),
1300 .off6 = td_var_offset(max_bs[DDIR_TRIM]),
Jens Axboec3edbdb2007-07-20 14:25:31 +02001301 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001302 .help = "Set block size range (in more detail than bs)",
Jens Axboe67a10002007-07-31 23:12:16 +02001303 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001304 },
1305 {
Jens Axboe564ca972007-12-14 12:21:19 +01001306 .name = "bssplit",
1307 .type = FIO_OPT_STR,
1308 .cb = str_bssplit_cb,
1309 .help = "Set a specific mix of block sizes",
1310 .parent = "rw",
1311 },
1312 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001313 .name = "bs_unaligned",
Jens Axboed3aad8f2007-03-15 14:12:05 +01001314 .alias = "blocksize_unaligned",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001315 .type = FIO_OPT_STR_SET,
1316 .off1 = td_var_offset(bs_unaligned),
1317 .help = "Don't sector align IO buffer sizes",
Jens Axboe67a10002007-07-31 23:12:16 +02001318 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001319 },
1320 {
1321 .name = "randrepeat",
1322 .type = FIO_OPT_BOOL,
1323 .off1 = td_var_offset(rand_repeatable),
1324 .help = "Use repeatable random IO pattern",
1325 .def = "1",
Jens Axboe67a10002007-07-31 23:12:16 +02001326 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001327 },
1328 {
Jens Axboe2615cc42011-03-28 09:35:09 +02001329 .name = "use_os_rand",
1330 .type = FIO_OPT_BOOL,
1331 .off1 = td_var_offset(use_os_rand),
1332 .help = "Set to use OS random generator",
1333 .def = "0",
1334 .parent = "rw",
1335 },
1336 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001337 .name = "norandommap",
1338 .type = FIO_OPT_STR_SET,
1339 .off1 = td_var_offset(norandommap),
1340 .help = "Accept potential duplicate random blocks",
Jens Axboe67a10002007-07-31 23:12:16 +02001341 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001342 },
1343 {
Jens Axboe2b386d22008-03-26 10:32:57 +01001344 .name = "softrandommap",
1345 .type = FIO_OPT_BOOL,
1346 .off1 = td_var_offset(softrandommap),
Jens Axboef66ab3c2008-06-05 11:48:22 +02001347 .help = "Set norandommap if randommap allocation fails",
Jens Axboe2b386d22008-03-26 10:32:57 +01001348 .parent = "norandommap",
1349 .def = "0",
1350 },
1351 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001352 .name = "nrfiles",
Jens Axboed7c8be02010-11-25 08:21:39 +01001353 .alias = "nr_files",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001354 .type = FIO_OPT_INT,
1355 .off1 = td_var_offset(nr_files),
1356 .help = "Split job workload between this number of files",
1357 .def = "1",
1358 },
1359 {
1360 .name = "openfiles",
1361 .type = FIO_OPT_INT,
1362 .off1 = td_var_offset(open_files),
1363 .help = "Number of files to keep open at the same time",
1364 },
1365 {
1366 .name = "file_service_type",
1367 .type = FIO_OPT_STR,
1368 .cb = str_fst_cb,
1369 .off1 = td_var_offset(file_service_type),
1370 .help = "How to select which file to service next",
1371 .def = "roundrobin",
1372 .posval = {
1373 { .ival = "random",
1374 .oval = FIO_FSERVICE_RANDOM,
1375 .help = "Choose a file at random",
1376 },
1377 { .ival = "roundrobin",
1378 .oval = FIO_FSERVICE_RR,
1379 .help = "Round robin select files",
1380 },
Jens Axboea086c252009-03-04 08:27:37 +01001381 { .ival = "sequential",
1382 .oval = FIO_FSERVICE_SEQ,
1383 .help = "Finish one file before moving to the next",
1384 },
Jens Axboe214e1ec2007-03-15 10:48:13 +01001385 },
Jens Axboe67a10002007-07-31 23:12:16 +02001386 .parent = "nrfiles",
1387 },
Jens Axboe7bc8c2c2010-01-28 11:31:31 +01001388#ifdef FIO_HAVE_FALLOCATE
1389 {
1390 .name = "fallocate",
Eric Gourioua596f042011-06-17 09:11:45 +02001391 .type = FIO_OPT_STR,
1392 .off1 = td_var_offset(fallocate_mode),
1393 .help = "Whether pre-allocation is performed when laying out files",
1394 .def = "posix",
1395 .posval = {
1396 { .ival = "none",
1397 .oval = FIO_FALLOCATE_NONE,
1398 .help = "Do not pre-allocate space",
1399 },
1400 { .ival = "posix",
1401 .oval = FIO_FALLOCATE_POSIX,
1402 .help = "Use posix_fallocate()",
1403 },
1404#ifdef FIO_HAVE_LINUX_FALLOCATE
1405 { .ival = "keep",
1406 .oval = FIO_FALLOCATE_KEEP_SIZE,
1407 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
1408 },
Jens Axboe7bc8c2c2010-01-28 11:31:31 +01001409#endif
Eric Gourioua596f042011-06-17 09:11:45 +02001410 /* Compatibility with former boolean values */
1411 { .ival = "0",
1412 .oval = FIO_FALLOCATE_NONE,
1413 .help = "Alias for 'none'",
1414 },
1415 { .ival = "1",
1416 .oval = FIO_FALLOCATE_POSIX,
1417 .help = "Alias for 'posix'",
1418 },
1419 },
1420 },
1421#endif /* FIO_HAVE_FALLOCATE */
Jens Axboe67a10002007-07-31 23:12:16 +02001422 {
1423 .name = "fadvise_hint",
1424 .type = FIO_OPT_BOOL,
1425 .off1 = td_var_offset(fadvise_hint),
1426 .help = "Use fadvise() to advise the kernel on IO pattern",
1427 .def = "1",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001428 },
1429 {
1430 .name = "fsync",
1431 .type = FIO_OPT_INT,
1432 .off1 = td_var_offset(fsync_blocks),
1433 .help = "Issue fsync for writes every given number of blocks",
1434 .def = "0",
1435 },
1436 {
Jens Axboe5f9099e2009-06-16 22:40:26 +02001437 .name = "fdatasync",
1438 .type = FIO_OPT_INT,
1439 .off1 = td_var_offset(fdatasync_blocks),
1440 .help = "Issue fdatasync for writes every given number of blocks",
1441 .def = "0",
1442 },
Jens Axboe1ef2b6b2010-10-08 15:07:01 +02001443 {
1444 .name = "write_barrier",
1445 .type = FIO_OPT_INT,
1446 .off1 = td_var_offset(barrier_blocks),
1447 .help = "Make every Nth write a barrier write",
1448 .def = "0",
1449 },
Jens Axboe44f29692010-03-09 20:09:44 +01001450#ifdef FIO_HAVE_SYNC_FILE_RANGE
1451 {
1452 .name = "sync_file_range",
1453 .posval = {
1454 { .ival = "wait_before",
1455 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
1456 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
Jens Axboe3843deb2010-03-09 20:41:15 +01001457 .or = 1,
Jens Axboe44f29692010-03-09 20:09:44 +01001458 },
1459 { .ival = "write",
1460 .oval = SYNC_FILE_RANGE_WRITE,
1461 .help = "SYNC_FILE_RANGE_WRITE",
Jens Axboe3843deb2010-03-09 20:41:15 +01001462 .or = 1,
Jens Axboe44f29692010-03-09 20:09:44 +01001463 },
1464 {
1465 .ival = "wait_after",
1466 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
1467 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
Jens Axboe3843deb2010-03-09 20:41:15 +01001468 .or = 1,
Jens Axboe44f29692010-03-09 20:09:44 +01001469 },
1470 },
Jens Axboe3843deb2010-03-09 20:41:15 +01001471 .type = FIO_OPT_STR_MULTI,
Jens Axboe44f29692010-03-09 20:09:44 +01001472 .cb = str_sfr_cb,
1473 .off1 = td_var_offset(sync_file_range),
1474 .help = "Use sync_file_range()",
1475 },
1476#endif
Jens Axboe5f9099e2009-06-16 22:40:26 +02001477 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001478 .name = "direct",
1479 .type = FIO_OPT_BOOL,
1480 .off1 = td_var_offset(odirect),
1481 .help = "Use O_DIRECT IO (negates buffered)",
1482 .def = "0",
1483 },
1484 {
1485 .name = "buffered",
1486 .type = FIO_OPT_BOOL,
1487 .off1 = td_var_offset(odirect),
1488 .neg = 1,
1489 .help = "Use buffered IO (negates direct)",
1490 .def = "1",
1491 },
1492 {
1493 .name = "overwrite",
1494 .type = FIO_OPT_BOOL,
1495 .off1 = td_var_offset(overwrite),
1496 .help = "When writing, set whether to overwrite current data",
1497 .def = "0",
1498 },
1499 {
1500 .name = "loops",
1501 .type = FIO_OPT_INT,
1502 .off1 = td_var_offset(loops),
1503 .help = "Number of times to run the job",
1504 .def = "1",
1505 },
1506 {
1507 .name = "numjobs",
1508 .type = FIO_OPT_INT,
1509 .off1 = td_var_offset(numjobs),
1510 .help = "Duplicate this job this many times",
1511 .def = "1",
1512 },
1513 {
1514 .name = "startdelay",
Jens Axboea5737c92010-06-29 10:40:30 +02001515 .type = FIO_OPT_STR_VAL_TIME,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001516 .off1 = td_var_offset(start_delay),
1517 .help = "Only start job when this period has passed",
1518 .def = "0",
1519 },
1520 {
1521 .name = "runtime",
1522 .alias = "timeout",
1523 .type = FIO_OPT_STR_VAL_TIME,
1524 .off1 = td_var_offset(timeout),
1525 .help = "Stop workload when this amount of time has passed",
1526 .def = "0",
1527 },
1528 {
Jens Axboecf4464c2007-04-17 20:14:42 +02001529 .name = "time_based",
1530 .type = FIO_OPT_STR_SET,
1531 .off1 = td_var_offset(time_based),
1532 .help = "Keep running until runtime/timeout is met",
1533 },
1534 {
Jens Axboe721938a2008-09-10 09:46:16 +02001535 .name = "ramp_time",
1536 .type = FIO_OPT_STR_VAL_TIME,
1537 .off1 = td_var_offset(ramp_time),
1538 .help = "Ramp up time before measuring performance",
1539 },
1540 {
Jens Axboec223da82010-03-24 13:23:53 +01001541 .name = "clocksource",
1542 .type = FIO_OPT_STR,
1543 .cb = fio_clock_source_cb,
1544 .off1 = td_var_offset(clocksource),
1545 .help = "What type of timing source to use",
Jens Axboec223da82010-03-24 13:23:53 +01001546 .posval = {
1547 { .ival = "gettimeofday",
1548 .oval = CS_GTOD,
1549 .help = "Use gettimeofday(2) for timing",
1550 },
1551 { .ival = "clock_gettime",
1552 .oval = CS_CGETTIME,
1553 .help = "Use clock_gettime(2) for timing",
1554 },
1555#ifdef ARCH_HAVE_CPU_CLOCK
1556 { .ival = "cpu",
1557 .oval = CS_CPUCLOCK,
1558 .help = "Use CPU private clock",
1559 },
1560#endif
1561 },
1562 },
1563 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001564 .name = "mem",
Jens Axboed3aad8f2007-03-15 14:12:05 +01001565 .alias = "iomem",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001566 .type = FIO_OPT_STR,
1567 .cb = str_mem_cb,
1568 .off1 = td_var_offset(mem_type),
1569 .help = "Backing type for IO buffers",
1570 .def = "malloc",
1571 .posval = {
1572 { .ival = "malloc",
1573 .oval = MEM_MALLOC,
1574 .help = "Use malloc(3) for IO buffers",
1575 },
Jens Axboeb370e462007-03-19 10:51:49 +01001576 { .ival = "shm",
1577 .oval = MEM_SHM,
1578 .help = "Use shared memory segments for IO buffers",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001579 },
1580#ifdef FIO_HAVE_HUGETLB
Jens Axboe37c8cdf2007-03-19 13:14:03 +01001581 { .ival = "shmhuge",
1582 .oval = MEM_SHMHUGE,
1583 .help = "Like shm, but use huge pages",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001584 },
1585#endif
Jens Axboeb370e462007-03-19 10:51:49 +01001586 { .ival = "mmap",
1587 .oval = MEM_MMAP,
1588 .help = "Use mmap(2) (file or anon) for IO buffers",
1589 },
Jens Axboe37c8cdf2007-03-19 13:14:03 +01001590#ifdef FIO_HAVE_HUGETLB
1591 { .ival = "mmaphuge",
1592 .oval = MEM_MMAPHUGE,
1593 .help = "Like mmap, but use huge pages",
1594 },
1595#endif
Jens Axboe214e1ec2007-03-15 10:48:13 +01001596 },
1597 },
1598 {
Jens Axboed529ee12009-07-01 10:33:03 +02001599 .name = "iomem_align",
1600 .alias = "mem_align",
1601 .type = FIO_OPT_INT,
1602 .off1 = td_var_offset(mem_align),
1603 .minval = 0,
1604 .help = "IO memory buffer offset alignment",
1605 .def = "0",
1606 .parent = "iomem",
1607 },
1608 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001609 .name = "verify",
1610 .type = FIO_OPT_STR,
1611 .off1 = td_var_offset(verify),
1612 .help = "Verify data written",
Jens Axboe5d7c5d32010-06-21 15:08:17 +02001613 .cb = str_verify_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001614 .def = "0",
1615 .posval = {
1616 { .ival = "0",
1617 .oval = VERIFY_NONE,
1618 .help = "Don't do IO verification",
1619 },
Jens Axboefcca4b52007-07-27 15:42:00 +02001620 { .ival = "md5",
1621 .oval = VERIFY_MD5,
1622 .help = "Use md5 checksums for verification",
1623 },
Jens Axboed77a7af2007-07-27 15:35:06 +02001624 { .ival = "crc64",
1625 .oval = VERIFY_CRC64,
1626 .help = "Use crc64 checksums for verification",
1627 },
Jens Axboe214e1ec2007-03-15 10:48:13 +01001628 { .ival = "crc32",
1629 .oval = VERIFY_CRC32,
1630 .help = "Use crc32 checksums for verification",
1631 },
Jens Axboeaf497e62008-08-04 15:40:35 +02001632 { .ival = "crc32c-intel",
Jens Axboee3aaafc2012-02-22 20:28:17 +01001633 .oval = VERIFY_CRC32C,
1634 .help = "Use crc32c checksums for verification (hw assisted, if available)",
Jens Axboeaf497e62008-08-04 15:40:35 +02001635 },
Jens Axboebac39e02008-06-11 20:46:19 +02001636 { .ival = "crc32c",
1637 .oval = VERIFY_CRC32C,
Jens Axboee3aaafc2012-02-22 20:28:17 +01001638 .help = "Use crc32c checksums for verification (hw assisted, if available)",
Jens Axboebac39e02008-06-11 20:46:19 +02001639 },
Jens Axboe969f7ed2007-07-27 09:07:17 +02001640 { .ival = "crc16",
1641 .oval = VERIFY_CRC16,
1642 .help = "Use crc16 checksums for verification",
1643 },
Jens Axboe1e154bd2007-07-27 09:52:40 +02001644 { .ival = "crc7",
1645 .oval = VERIFY_CRC7,
1646 .help = "Use crc7 checksums for verification",
1647 },
Jens Axboe7c353ce2009-08-09 22:40:33 +02001648 { .ival = "sha1",
1649 .oval = VERIFY_SHA1,
1650 .help = "Use sha1 checksums for verification",
1651 },
Jens Axboecd14cc12007-07-30 10:59:33 +02001652 { .ival = "sha256",
1653 .oval = VERIFY_SHA256,
1654 .help = "Use sha256 checksums for verification",
1655 },
1656 { .ival = "sha512",
1657 .oval = VERIFY_SHA512,
1658 .help = "Use sha512 checksums for verification",
1659 },
Shawn Lewis7437ee82007-08-02 21:05:58 +02001660 { .ival = "meta",
1661 .oval = VERIFY_META,
1662 .help = "Use io information",
1663 },
Jens Axboe36690c92007-03-26 10:23:34 +02001664 {
1665 .ival = "null",
1666 .oval = VERIFY_NULL,
1667 .help = "Pretend to verify",
1668 },
Jens Axboe214e1ec2007-03-15 10:48:13 +01001669 },
1670 },
1671 {
Jens Axboe005c5652007-08-02 22:21:36 +02001672 .name = "do_verify",
Jens Axboe68e1f292007-08-10 10:32:14 +02001673 .type = FIO_OPT_BOOL,
Jens Axboe005c5652007-08-02 22:21:36 +02001674 .off1 = td_var_offset(do_verify),
1675 .help = "Run verification stage after write",
1676 .def = "1",
1677 .parent = "verify",
1678 },
1679 {
Jens Axboe160b9662007-03-27 10:59:49 +02001680 .name = "verifysort",
1681 .type = FIO_OPT_BOOL,
1682 .off1 = td_var_offset(verifysort),
1683 .help = "Sort written verify blocks for read back",
1684 .def = "1",
Jens Axboec83f2df2007-07-31 22:51:47 +02001685 .parent = "verify",
Jens Axboe160b9662007-03-27 10:59:49 +02001686 },
1687 {
Jens Axboea59e1702007-07-30 08:53:27 +02001688 .name = "verify_interval",
Jens Axboee01b22b2009-06-09 15:43:25 +02001689 .type = FIO_OPT_INT,
Jens Axboea59e1702007-07-30 08:53:27 +02001690 .off1 = td_var_offset(verify_interval),
Jens Axboe819a9682007-07-28 21:30:31 +02001691 .minval = 2 * sizeof(struct verify_header),
Jens Axboea59e1702007-07-30 08:53:27 +02001692 .help = "Store verify buffer header every N bytes",
Jens Axboeafdf9352007-07-31 16:14:34 +02001693 .parent = "verify",
Shawn Lewis3f9f4e22007-07-28 21:10:37 +02001694 },
1695 {
Jens Axboea59e1702007-07-30 08:53:27 +02001696 .name = "verify_offset",
Jens Axboee01b22b2009-06-09 15:43:25 +02001697 .type = FIO_OPT_INT,
Jens Axboea59e1702007-07-30 08:53:27 +02001698 .help = "Offset verify header location by N bytes",
Shawn Lewis546a9142007-07-28 21:11:37 +02001699 .def = "0",
Jens Axboe5ec10ea2008-03-06 15:42:00 +01001700 .cb = str_verify_offset_cb,
Jens Axboeafdf9352007-07-31 16:14:34 +02001701 .parent = "verify",
Shawn Lewis546a9142007-07-28 21:11:37 +02001702 },
1703 {
Shawn Lewise28218f2008-01-16 11:01:33 +01001704 .name = "verify_pattern",
Radha Ramachandran0e92f872009-10-27 20:14:27 +01001705 .type = FIO_OPT_STR,
Shawn Lewise28218f2008-01-16 11:01:33 +01001706 .cb = str_verify_pattern_cb,
1707 .help = "Fill pattern for IO buffers",
1708 .parent = "verify",
1709 },
1710 {
Jens Axboea12a3b42007-08-09 10:20:54 +02001711 .name = "verify_fatal",
Jens Axboe68e1f292007-08-10 10:32:14 +02001712 .type = FIO_OPT_BOOL,
Jens Axboea12a3b42007-08-09 10:20:54 +02001713 .off1 = td_var_offset(verify_fatal),
1714 .def = "0",
1715 .help = "Exit on a single verify failure, don't continue",
1716 .parent = "verify",
1717 },
1718 {
Jens Axboeb463e932011-01-12 09:03:23 +01001719 .name = "verify_dump",
1720 .type = FIO_OPT_BOOL,
1721 .off1 = td_var_offset(verify_dump),
Jens Axboeef71e312011-10-25 22:43:36 +02001722 .def = "0",
Jens Axboeb463e932011-01-12 09:03:23 +01001723 .help = "Dump contents of good and bad blocks on failure",
1724 .parent = "verify",
1725 },
1726 {
Jens Axboee8462bd2009-07-06 12:59:04 +02001727 .name = "verify_async",
1728 .type = FIO_OPT_INT,
1729 .off1 = td_var_offset(verify_async),
1730 .def = "0",
1731 .help = "Number of async verifier threads to use",
1732 .parent = "verify",
1733 },
Jens Axboe9e144182010-06-15 14:25:36 +02001734 {
1735 .name = "verify_backlog",
1736 .type = FIO_OPT_STR_VAL,
1737 .off1 = td_var_offset(verify_backlog),
1738 .help = "Verify after this number of blocks are written",
1739 .parent = "verify",
1740 },
1741 {
1742 .name = "verify_backlog_batch",
1743 .type = FIO_OPT_INT,
1744 .off1 = td_var_offset(verify_batch),
1745 .help = "Verify this number of IO blocks",
Jens Axboe0d29de82010-09-01 13:54:15 +02001746 .parent = "verify",
Jens Axboe9e144182010-06-15 14:25:36 +02001747 },
Jens Axboee8462bd2009-07-06 12:59:04 +02001748#ifdef FIO_HAVE_CPU_AFFINITY
1749 {
1750 .name = "verify_async_cpus",
1751 .type = FIO_OPT_STR,
1752 .cb = str_verify_cpus_allowed_cb,
1753 .help = "Set CPUs allowed for async verify threads",
1754 .parent = "verify_async",
1755 },
1756#endif
Jens Axboe0d29de82010-09-01 13:54:15 +02001757#ifdef FIO_HAVE_TRIM
1758 {
1759 .name = "trim_percentage",
1760 .type = FIO_OPT_INT,
1761 .cb = str_verify_trim_cb,
1762 .maxval = 100,
1763 .help = "Number of verify blocks to discard/trim",
1764 .parent = "verify",
1765 .def = "0",
1766 },
1767 {
1768 .name = "trim_verify_zero",
1769 .type = FIO_OPT_INT,
1770 .help = "Verify that trim/discarded blocks are returned as zeroes",
1771 .off1 = td_var_offset(trim_zero),
1772 .parent = "trim_percentage",
1773 .def = "1",
1774 },
1775 {
1776 .name = "trim_backlog",
1777 .type = FIO_OPT_STR_VAL,
1778 .off1 = td_var_offset(trim_backlog),
1779 .help = "Trim after this number of blocks are written",
1780 .parent = "trim_percentage",
1781 },
1782 {
1783 .name = "trim_backlog_batch",
1784 .type = FIO_OPT_INT,
1785 .off1 = td_var_offset(trim_batch),
1786 .help = "Trim this number of IO blocks",
1787 .parent = "trim_percentage",
1788 },
1789#endif
Jens Axboee8462bd2009-07-06 12:59:04 +02001790 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001791 .name = "write_iolog",
1792 .type = FIO_OPT_STR_STORE,
1793 .off1 = td_var_offset(write_iolog_file),
1794 .help = "Store IO pattern to file",
1795 },
1796 {
1797 .name = "read_iolog",
1798 .type = FIO_OPT_STR_STORE,
1799 .off1 = td_var_offset(read_iolog_file),
1800 .help = "Playback IO pattern from file",
1801 },
1802 {
David Nellans64bbb862010-08-24 22:13:30 +02001803 .name = "replay_no_stall",
1804 .type = FIO_OPT_INT,
1805 .off1 = td_var_offset(no_stall),
1806 .def = "0",
Jens Axboe87e7a972010-08-25 09:01:25 +02001807 .parent = "read_iolog",
David Nellans64bbb862010-08-24 22:13:30 +02001808 .help = "Playback IO pattern file as fast as possible without stalls",
1809 },
1810 {
David Nellansd1c46c02010-08-31 21:20:47 +02001811 .name = "replay_redirect",
1812 .type = FIO_OPT_STR_STORE,
1813 .off1 = td_var_offset(replay_redirect),
1814 .parent = "read_iolog",
1815 .help = "Replay all I/O onto this device, regardless of trace device",
1816 },
1817 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001818 .name = "exec_prerun",
1819 .type = FIO_OPT_STR_STORE,
1820 .off1 = td_var_offset(exec_prerun),
1821 .help = "Execute this file prior to running job",
1822 },
1823 {
1824 .name = "exec_postrun",
1825 .type = FIO_OPT_STR_STORE,
1826 .off1 = td_var_offset(exec_postrun),
1827 .help = "Execute this file after running job",
1828 },
1829#ifdef FIO_HAVE_IOSCHED_SWITCH
1830 {
1831 .name = "ioscheduler",
1832 .type = FIO_OPT_STR_STORE,
1833 .off1 = td_var_offset(ioscheduler),
1834 .help = "Use this IO scheduler on the backing device",
1835 },
1836#endif
1837 {
1838 .name = "zonesize",
1839 .type = FIO_OPT_STR_VAL,
1840 .off1 = td_var_offset(zone_size),
Steven Noonaned335852012-01-31 13:58:00 +01001841 .help = "Amount of data to read per zone",
1842 .def = "0",
1843 },
1844 {
1845 .name = "zonerange",
1846 .type = FIO_OPT_STR_VAL,
1847 .off1 = td_var_offset(zone_range),
Jens Axboe214e1ec2007-03-15 10:48:13 +01001848 .help = "Give size of an IO zone",
1849 .def = "0",
1850 },
1851 {
1852 .name = "zoneskip",
1853 .type = FIO_OPT_STR_VAL,
1854 .off1 = td_var_offset(zone_skip),
1855 .help = "Space between IO zones",
1856 .def = "0",
1857 },
1858 {
1859 .name = "lockmem",
1860 .type = FIO_OPT_STR_VAL,
1861 .cb = str_lockmem_cb,
1862 .help = "Lock down this amount of memory",
1863 .def = "0",
1864 },
1865 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001866 .name = "rwmixread",
1867 .type = FIO_OPT_INT,
Jens Axboecb499fc2008-05-28 10:33:32 +02001868 .cb = str_rwmix_read_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001869 .maxval = 100,
1870 .help = "Percentage of mixed workload that is reads",
1871 .def = "50",
1872 },
1873 {
1874 .name = "rwmixwrite",
1875 .type = FIO_OPT_INT,
Jens Axboecb499fc2008-05-28 10:33:32 +02001876 .cb = str_rwmix_write_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001877 .maxval = 100,
1878 .help = "Percentage of mixed workload that is writes",
1879 .def = "50",
1880 },
1881 {
Jens Axboeafdf9352007-07-31 16:14:34 +02001882 .name = "rwmixcycle",
Jens Axboe15ca1502008-04-07 09:26:02 +02001883 .type = FIO_OPT_DEPRECATED,
Jens Axboeafdf9352007-07-31 16:14:34 +02001884 },
1885 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001886 .name = "nice",
1887 .type = FIO_OPT_INT,
1888 .off1 = td_var_offset(nice),
1889 .help = "Set job CPU nice value",
1890 .minval = -19,
1891 .maxval = 20,
1892 .def = "0",
1893 },
1894#ifdef FIO_HAVE_IOPRIO
1895 {
1896 .name = "prio",
1897 .type = FIO_OPT_INT,
1898 .cb = str_prio_cb,
1899 .help = "Set job IO priority value",
1900 .minval = 0,
1901 .maxval = 7,
1902 },
1903 {
1904 .name = "prioclass",
1905 .type = FIO_OPT_INT,
1906 .cb = str_prioclass_cb,
1907 .help = "Set job IO priority class",
1908 .minval = 0,
1909 .maxval = 3,
1910 },
1911#endif
1912 {
1913 .name = "thinktime",
1914 .type = FIO_OPT_INT,
1915 .off1 = td_var_offset(thinktime),
1916 .help = "Idle time between IO buffers (usec)",
1917 .def = "0",
1918 },
1919 {
1920 .name = "thinktime_spin",
1921 .type = FIO_OPT_INT,
1922 .off1 = td_var_offset(thinktime_spin),
1923 .help = "Start think time by spinning this amount (usec)",
1924 .def = "0",
Jens Axboeafdf9352007-07-31 16:14:34 +02001925 .parent = "thinktime",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001926 },
1927 {
1928 .name = "thinktime_blocks",
1929 .type = FIO_OPT_INT,
1930 .off1 = td_var_offset(thinktime_blocks),
1931 .help = "IO buffer period between 'thinktime'",
1932 .def = "1",
Jens Axboeafdf9352007-07-31 16:14:34 +02001933 .parent = "thinktime",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001934 },
1935 {
1936 .name = "rate",
Jens Axboee01b22b2009-06-09 15:43:25 +02001937 .type = FIO_OPT_INT,
Shaohua Li6eaf09d2012-09-14 08:49:43 +02001938 .off1 = td_var_offset(rate[DDIR_READ]),
1939 .off2 = td_var_offset(rate[DDIR_WRITE]),
1940 .off3 = td_var_offset(rate[DDIR_TRIM]),
Jens Axboe214e1ec2007-03-15 10:48:13 +01001941 .help = "Set bandwidth rate",
1942 },
1943 {
1944 .name = "ratemin",
Jens Axboee01b22b2009-06-09 15:43:25 +02001945 .type = FIO_OPT_INT,
Shaohua Li6eaf09d2012-09-14 08:49:43 +02001946 .off1 = td_var_offset(ratemin[DDIR_READ]),
1947 .off2 = td_var_offset(ratemin[DDIR_WRITE]),
1948 .off3 = td_var_offset(ratemin[DDIR_TRIM]),
Jens Axboe4e991c22007-03-15 11:41:11 +01001949 .help = "Job must meet this rate or it will be shutdown",
Jens Axboeafdf9352007-07-31 16:14:34 +02001950 .parent = "rate",
Jens Axboe4e991c22007-03-15 11:41:11 +01001951 },
1952 {
1953 .name = "rate_iops",
Jens Axboee01b22b2009-06-09 15:43:25 +02001954 .type = FIO_OPT_INT,
Shaohua Li6eaf09d2012-09-14 08:49:43 +02001955 .off1 = td_var_offset(rate_iops[DDIR_READ]),
1956 .off2 = td_var_offset(rate_iops[DDIR_WRITE]),
1957 .off3 = td_var_offset(rate_iops[DDIR_TRIM]),
Jens Axboe4e991c22007-03-15 11:41:11 +01001958 .help = "Limit IO used to this number of IO operations/sec",
1959 },
1960 {
1961 .name = "rate_iops_min",
Jens Axboee01b22b2009-06-09 15:43:25 +02001962 .type = FIO_OPT_INT,
Shaohua Li6eaf09d2012-09-14 08:49:43 +02001963 .off1 = td_var_offset(rate_iops_min[DDIR_READ]),
1964 .off2 = td_var_offset(rate_iops_min[DDIR_WRITE]),
1965 .off3 = td_var_offset(rate_iops_min[DDIR_TRIM]),
Bruce Cran03e20d62011-01-02 20:14:54 +01001966 .help = "Job must meet this rate or it will be shut down",
Jens Axboeafdf9352007-07-31 16:14:34 +02001967 .parent = "rate_iops",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001968 },
1969 {
1970 .name = "ratecycle",
1971 .type = FIO_OPT_INT,
1972 .off1 = td_var_offset(ratecycle),
1973 .help = "Window average for rate limits (msec)",
1974 .def = "1000",
Jens Axboeafdf9352007-07-31 16:14:34 +02001975 .parent = "rate",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001976 },
1977 {
1978 .name = "invalidate",
1979 .type = FIO_OPT_BOOL,
1980 .off1 = td_var_offset(invalidate_cache),
1981 .help = "Invalidate buffer/page cache prior to running job",
1982 .def = "1",
1983 },
1984 {
1985 .name = "sync",
1986 .type = FIO_OPT_BOOL,
1987 .off1 = td_var_offset(sync_io),
1988 .help = "Use O_SYNC for buffered writes",
1989 .def = "0",
Jens Axboe67a10002007-07-31 23:12:16 +02001990 .parent = "buffered",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001991 },
1992 {
1993 .name = "bwavgtime",
1994 .type = FIO_OPT_INT,
1995 .off1 = td_var_offset(bw_avg_time),
Jens Axboe5ec10ea2008-03-06 15:42:00 +01001996 .help = "Time window over which to calculate bandwidth"
1997 " (msec)",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001998 .def = "500",
Jens Axboec8eeb9d2011-10-05 14:02:22 +02001999 .parent = "write_bw_log",
2000 },
2001 {
2002 .name = "iopsavgtime",
2003 .type = FIO_OPT_INT,
2004 .off1 = td_var_offset(iops_avg_time),
2005 .help = "Time window over which to calculate IOPS (msec)",
2006 .def = "500",
2007 .parent = "write_iops_log",
Jens Axboe214e1ec2007-03-15 10:48:13 +01002008 },
2009 {
2010 .name = "create_serialize",
2011 .type = FIO_OPT_BOOL,
2012 .off1 = td_var_offset(create_serialize),
2013 .help = "Serialize creating of job files",
2014 .def = "1",
2015 },
2016 {
2017 .name = "create_fsync",
2018 .type = FIO_OPT_BOOL,
2019 .off1 = td_var_offset(create_fsync),
Bruce Cran03e20d62011-01-02 20:14:54 +01002020 .help = "fsync file after creation",
Jens Axboe214e1ec2007-03-15 10:48:13 +01002021 .def = "1",
2022 },
2023 {
Jens Axboe814452b2009-03-04 12:53:13 +01002024 .name = "create_on_open",
2025 .type = FIO_OPT_BOOL,
2026 .off1 = td_var_offset(create_on_open),
2027 .help = "Create files when they are opened for IO",
2028 .def = "0",
2029 },
Jens Axboe0b9d69e2009-09-11 22:29:54 +02002030 {
Jens Axboe25460cf2012-05-02 13:58:02 +02002031 .name = "create_only",
2032 .type = FIO_OPT_BOOL,
2033 .off1 = td_var_offset(create_only),
2034 .help = "Only perform file creation phase",
2035 .def = "0",
2036 },
2037 {
Zhang, Yanminafad68f2009-05-20 11:30:55 +02002038 .name = "pre_read",
2039 .type = FIO_OPT_BOOL,
2040 .off1 = td_var_offset(pre_read),
Bruce Cran03e20d62011-01-02 20:14:54 +01002041 .help = "Pre-read files before starting official testing",
Zhang, Yanminafad68f2009-05-20 11:30:55 +02002042 .def = "0",
2043 },
Jens Axboe814452b2009-03-04 12:53:13 +01002044 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01002045 .name = "cpuload",
2046 .type = FIO_OPT_INT,
2047 .off1 = td_var_offset(cpuload),
2048 .help = "Use this percentage of CPU",
2049 },
2050 {
2051 .name = "cpuchunks",
2052 .type = FIO_OPT_INT,
2053 .off1 = td_var_offset(cpucycle),
2054 .help = "Length of the CPU burn cycles (usecs)",
2055 .def = "50000",
Jens Axboe67a10002007-07-31 23:12:16 +02002056 .parent = "cpuload",
Jens Axboe214e1ec2007-03-15 10:48:13 +01002057 },
2058#ifdef FIO_HAVE_CPU_AFFINITY
2059 {
2060 .name = "cpumask",
2061 .type = FIO_OPT_INT,
2062 .cb = str_cpumask_cb,
2063 .help = "CPU affinity mask",
2064 },
Jens Axboed2e268b2007-06-15 10:33:49 +02002065 {
2066 .name = "cpus_allowed",
2067 .type = FIO_OPT_STR,
2068 .cb = str_cpus_allowed_cb,
2069 .help = "Set CPUs allowed",
2070 },
Jens Axboe214e1ec2007-03-15 10:48:13 +01002071#endif
2072 {
2073 .name = "end_fsync",
2074 .type = FIO_OPT_BOOL,
2075 .off1 = td_var_offset(end_fsync),
2076 .help = "Include fsync at the end of job",
2077 .def = "0",
2078 },
2079 {
2080 .name = "fsync_on_close",
2081 .type = FIO_OPT_BOOL,
2082 .off1 = td_var_offset(fsync_on_close),
2083 .help = "fsync files on close",
2084 .def = "0",
2085 },
2086 {
2087 .name = "unlink",
2088 .type = FIO_OPT_BOOL,
2089 .off1 = td_var_offset(unlink),
2090 .help = "Unlink created files after job has completed",
2091 .def = "0",
2092 },
2093 {
2094 .name = "exitall",
2095 .type = FIO_OPT_STR_SET,
2096 .cb = str_exitall_cb,
2097 .help = "Terminate all jobs when one exits",
2098 },
2099 {
2100 .name = "stonewall",
Jens Axboed3923652011-08-03 12:38:39 +02002101 .alias = "wait_for_previous",
Jens Axboe214e1ec2007-03-15 10:48:13 +01002102 .type = FIO_OPT_STR_SET,
2103 .off1 = td_var_offset(stonewall),
2104 .help = "Insert a hard barrier between this job and previous",
2105 },
2106 {
Jens Axboeb3d62a72007-03-20 14:23:26 +01002107 .name = "new_group",
2108 .type = FIO_OPT_STR_SET,
2109 .off1 = td_var_offset(new_group),
2110 .help = "Mark the start of a new group (for reporting)",
2111 },
2112 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01002113 .name = "thread",
2114 .type = FIO_OPT_STR_SET,
2115 .off1 = td_var_offset(use_thread),
2116 .help = "Use threads instead of forks",
2117 },
2118 {
2119 .name = "write_bw_log",
Jens Axboee3cedca2008-11-19 19:57:52 +01002120 .type = FIO_OPT_STR,
Jens Axboe214e1ec2007-03-15 10:48:13 +01002121 .off1 = td_var_offset(write_bw_log),
Jens Axboee3cedca2008-11-19 19:57:52 +01002122 .cb = str_write_bw_log_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01002123 .help = "Write log of bandwidth during run",
2124 },
2125 {
2126 .name = "write_lat_log",
Jens Axboee3cedca2008-11-19 19:57:52 +01002127 .type = FIO_OPT_STR,
Jens Axboe214e1ec2007-03-15 10:48:13 +01002128 .off1 = td_var_offset(write_lat_log),
Jens Axboee3cedca2008-11-19 19:57:52 +01002129 .cb = str_write_lat_log_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01002130 .help = "Write log of latency during run",
2131 },
2132 {
Jens Axboec8eeb9d2011-10-05 14:02:22 +02002133 .name = "write_iops_log",
2134 .type = FIO_OPT_STR,
2135 .off1 = td_var_offset(write_iops_log),
2136 .cb = str_write_iops_log_cb,
2137 .help = "Write log of IOPS during run",
2138 },
2139 {
Jens Axboeb8bc8cb2011-12-01 09:04:31 +01002140 .name = "log_avg_msec",
2141 .type = FIO_OPT_INT,
2142 .off1 = td_var_offset(log_avg_msec),
2143 .help = "Average bw/iops/lat logs over this period of time",
2144 .def = "0",
2145 },
2146 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01002147 .name = "hugepage-size",
Jens Axboee01b22b2009-06-09 15:43:25 +02002148 .type = FIO_OPT_INT,
Jens Axboe214e1ec2007-03-15 10:48:13 +01002149 .off1 = td_var_offset(hugepage_size),
2150 .help = "When using hugepages, specify size of each page",
Jens Axboe81179ee2011-10-04 12:42:06 +02002151 .def = __fio_stringify(FIO_HUGE_PAGE),
Jens Axboe214e1ec2007-03-15 10:48:13 +01002152 },
2153 {
2154 .name = "group_reporting",
2155 .type = FIO_OPT_STR_SET,
2156 .off1 = td_var_offset(group_reporting),
2157 .help = "Do reporting on a per-group basis",
2158 },
2159 {
Jens Axboee9459e52007-04-17 15:46:32 +02002160 .name = "zero_buffers",
2161 .type = FIO_OPT_STR_SET,
2162 .off1 = td_var_offset(zero_buffers),
2163 .help = "Init IO buffers to all zeroes",
2164 },
Jens Axboe5973caf2008-05-21 19:52:35 +02002165 {
2166 .name = "refill_buffers",
2167 .type = FIO_OPT_STR_SET,
2168 .off1 = td_var_offset(refill_buffers),
2169 .help = "Refill IO buffers on every IO submit",
2170 },
Yu-ju Hong83349192011-08-13 00:53:44 +02002171 {
Jens Axboefd684182011-09-19 09:24:44 +02002172 .name = "scramble_buffers",
2173 .type = FIO_OPT_BOOL,
2174 .off1 = td_var_offset(scramble_buffers),
2175 .help = "Slightly scramble buffers on every IO submit",
2176 .def = "1",
2177 },
2178 {
Jens Axboe9c426842012-03-02 21:02:12 +01002179 .name = "buffer_compress_percentage",
2180 .type = FIO_OPT_INT,
2181 .off1 = td_var_offset(compress_percentage),
2182 .maxval = 100,
2183 .minval = 1,
2184 .help = "How compressible the buffer is (approximately)",
2185 },
2186 {
Jens Axboef97a43a2012-03-09 19:06:24 +01002187 .name = "buffer_compress_chunk",
2188 .type = FIO_OPT_INT,
2189 .off1 = td_var_offset(compress_chunk),
Jens Axboe207b18e2012-03-09 19:11:25 +01002190 .parent = "buffer_compress_percentage",
Jens Axboef97a43a2012-03-09 19:06:24 +01002191 .help = "Size of compressible region in buffer",
2192 },
2193 {
Yu-ju Hong83349192011-08-13 00:53:44 +02002194 .name = "clat_percentiles",
2195 .type = FIO_OPT_BOOL,
2196 .off1 = td_var_offset(clat_percentiles),
2197 .help = "Enable the reporting of completion latency percentiles",
Jens Axboe467b35e2011-10-13 08:53:24 +02002198 .def = "1",
Yu-ju Hong83349192011-08-13 00:53:44 +02002199 },
2200 {
2201 .name = "percentile_list",
2202 .type = FIO_OPT_FLOAT_LIST,
2203 .off1 = td_var_offset(percentile_list),
2204 .off2 = td_var_offset(overwrite_plist),
2205 .help = "Specify a custom list of percentiles to report",
2206 .maxlen = FIO_IO_U_LIST_MAX_LEN,
2207 .minfp = 0.0,
2208 .maxfp = 100.0,
2209 },
2210
Jens Axboe0a839f32007-04-26 09:02:34 +02002211#ifdef FIO_HAVE_DISK_UTIL
2212 {
2213 .name = "disk_util",
2214 .type = FIO_OPT_BOOL,
2215 .off1 = td_var_offset(do_disk_util),
Jens Axboef66ab3c2008-06-05 11:48:22 +02002216 .help = "Log disk utilization statistics",
Jens Axboe0a839f32007-04-26 09:02:34 +02002217 .def = "1",
2218 },
2219#endif
Jens Axboee9459e52007-04-17 15:46:32 +02002220 {
Jens Axboe993bf482008-11-14 13:04:53 +01002221 .name = "gtod_reduce",
2222 .type = FIO_OPT_BOOL,
2223 .help = "Greatly reduce number of gettimeofday() calls",
2224 .cb = str_gtod_reduce_cb,
2225 .def = "0",
2226 },
2227 {
Jens Axboe02af0982010-06-24 09:59:34 +02002228 .name = "disable_lat",
2229 .type = FIO_OPT_BOOL,
2230 .off1 = td_var_offset(disable_lat),
2231 .help = "Disable latency numbers",
2232 .parent = "gtod_reduce",
2233 .def = "0",
2234 },
2235 {
Jens Axboe9520ebb2008-10-16 21:03:27 +02002236 .name = "disable_clat",
2237 .type = FIO_OPT_BOOL,
2238 .off1 = td_var_offset(disable_clat),
2239 .help = "Disable completion latency numbers",
Jens Axboe993bf482008-11-14 13:04:53 +01002240 .parent = "gtod_reduce",
Jens Axboe9520ebb2008-10-16 21:03:27 +02002241 .def = "0",
2242 },
2243 {
2244 .name = "disable_slat",
2245 .type = FIO_OPT_BOOL,
2246 .off1 = td_var_offset(disable_slat),
Bruce Cran03e20d62011-01-02 20:14:54 +01002247 .help = "Disable submission latency numbers",
Jens Axboe993bf482008-11-14 13:04:53 +01002248 .parent = "gtod_reduce",
Jens Axboe9520ebb2008-10-16 21:03:27 +02002249 .def = "0",
2250 },
2251 {
2252 .name = "disable_bw_measurement",
2253 .type = FIO_OPT_BOOL,
2254 .off1 = td_var_offset(disable_bw),
2255 .help = "Disable bandwidth logging",
Jens Axboe993bf482008-11-14 13:04:53 +01002256 .parent = "gtod_reduce",
Jens Axboe9520ebb2008-10-16 21:03:27 +02002257 .def = "0",
2258 },
2259 {
Jens Axboebe4ecfd2008-12-08 14:10:52 +01002260 .name = "gtod_cpu",
2261 .type = FIO_OPT_INT,
2262 .cb = str_gtod_cpu_cb,
Bruce Cran03e20d62011-01-02 20:14:54 +01002263 .help = "Set up dedicated gettimeofday() thread on this CPU",
Jens Axboe29d43ff2009-07-01 10:42:18 +02002264 .verify = gtod_cpu_verify,
Jens Axboebe4ecfd2008-12-08 14:10:52 +01002265 },
2266 {
Radha Ramachandranf2bba182009-06-15 08:40:16 +02002267 .name = "continue_on_error",
Steven Lang06842022011-11-17 09:45:17 +01002268 .type = FIO_OPT_STR,
Radha Ramachandranf2bba182009-06-15 08:40:16 +02002269 .off1 = td_var_offset(continue_on_error),
Bruce Cran03e20d62011-01-02 20:14:54 +01002270 .help = "Continue on non-fatal errors during IO",
Steven Lang06842022011-11-17 09:45:17 +01002271 .def = "none",
2272 .posval = {
2273 { .ival = "none",
2274 .oval = ERROR_TYPE_NONE,
2275 .help = "Exit when an error is encountered",
2276 },
2277 { .ival = "read",
2278 .oval = ERROR_TYPE_READ,
2279 .help = "Continue on read errors only",
2280 },
2281 { .ival = "write",
2282 .oval = ERROR_TYPE_WRITE,
2283 .help = "Continue on write errors only",
2284 },
2285 { .ival = "io",
2286 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
2287 .help = "Continue on any IO errors",
2288 },
2289 { .ival = "verify",
2290 .oval = ERROR_TYPE_VERIFY,
2291 .help = "Continue on verify errors only",
2292 },
2293 { .ival = "all",
2294 .oval = ERROR_TYPE_ANY,
2295 .help = "Continue on all io and verify errors",
2296 },
2297 { .ival = "0",
2298 .oval = ERROR_TYPE_NONE,
2299 .help = "Alias for 'none'",
2300 },
2301 { .ival = "1",
2302 .oval = ERROR_TYPE_ANY,
2303 .help = "Alias for 'all'",
2304 },
2305 },
Radha Ramachandranf2bba182009-06-15 08:40:16 +02002306 },
2307 {
Dmitry Monakhov8b28bd42012-09-23 15:46:09 +04002308 .name = "ignore_error",
2309 .type = FIO_OPT_STR,
2310 .cb = str_ignore_error_cb,
2311 .help = "Set a specific list of errors to ignore",
2312 .parent = "rw",
2313 },
2314 {
2315 .name = "error_dump",
2316 .type = FIO_OPT_BOOL,
2317 .off1 = td_var_offset(error_dump),
2318 .def = "0",
2319 .help = "Dump info on each error",
2320 },
2321
2322 {
Jens Axboe9ac8a792009-11-13 21:23:07 +01002323 .name = "profile",
Jens Axboe79d16312010-03-04 12:43:20 +01002324 .type = FIO_OPT_STR_STORE,
Jens Axboe9ac8a792009-11-13 21:23:07 +01002325 .off1 = td_var_offset(profile),
Jens Axboe9ac8a792009-11-13 21:23:07 +01002326 .help = "Select a specific builtin performance test",
2327 },
2328 {
Jens Axboea696fa22009-12-04 10:05:02 +01002329 .name = "cgroup",
2330 .type = FIO_OPT_STR_STORE,
2331 .off1 = td_var_offset(cgroup),
2332 .help = "Add job to cgroup of this name",
2333 },
2334 {
2335 .name = "cgroup_weight",
2336 .type = FIO_OPT_INT,
2337 .off1 = td_var_offset(cgroup_weight),
2338 .help = "Use given weight for cgroup",
2339 .minval = 100,
2340 .maxval = 1000,
Jens Axboea696fa22009-12-04 10:05:02 +01002341 },
2342 {
Vivek Goyal7de87092010-03-31 22:55:15 +02002343 .name = "cgroup_nodelete",
2344 .type = FIO_OPT_BOOL,
2345 .off1 = td_var_offset(cgroup_nodelete),
2346 .help = "Do not delete cgroups after job completion",
2347 .def = "0",
2348 },
2349 {
Jens Axboee0b0d892009-12-08 10:10:14 +01002350 .name = "uid",
2351 .type = FIO_OPT_INT,
2352 .off1 = td_var_offset(uid),
2353 .help = "Run job with this user ID",
2354 },
2355 {
2356 .name = "gid",
2357 .type = FIO_OPT_INT,
2358 .off1 = td_var_offset(gid),
2359 .help = "Run job with this group ID",
2360 },
2361 {
Dan Ehrenberg9e684a42012-02-20 11:05:14 +01002362 .name = "flow_id",
2363 .type = FIO_OPT_INT,
2364 .off1 = td_var_offset(flow_id),
2365 .help = "The flow index ID to use",
2366 .def = "0",
2367 },
2368 {
2369 .name = "flow",
2370 .type = FIO_OPT_INT,
2371 .off1 = td_var_offset(flow),
2372 .help = "Weight for flow control of this job",
2373 .parent = "flow_id",
2374 .def = "0",
2375 },
2376 {
2377 .name = "flow_watermark",
2378 .type = FIO_OPT_INT,
2379 .off1 = td_var_offset(flow_watermark),
2380 .help = "High watermark for flow control. This option"
2381 " should be set to the same value for all threads"
2382 " with non-zero flow.",
2383 .parent = "flow_id",
2384 .def = "1024",
2385 },
2386 {
2387 .name = "flow_sleep",
2388 .type = FIO_OPT_INT,
2389 .off1 = td_var_offset(flow_sleep),
2390 .help = "How many microseconds to sleep after being held"
2391 " back by the flow control mechanism",
2392 .parent = "flow_id",
2393 .def = "0",
2394 },
2395 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01002396 .name = NULL,
2397 },
2398};
2399
Jens Axboe17af15d2010-04-13 10:38:16 +02002400static void add_to_lopt(struct option *lopt, struct fio_option *o,
Steven Langde890a12011-11-09 14:03:34 +01002401 const char *name, int val)
Jens Axboe9f817362010-03-04 14:38:10 +01002402{
Jens Axboe17af15d2010-04-13 10:38:16 +02002403 lopt->name = (char *) name;
Steven Langde890a12011-11-09 14:03:34 +01002404 lopt->val = val;
Jens Axboe9f817362010-03-04 14:38:10 +01002405 if (o->type == FIO_OPT_STR_SET)
2406 lopt->has_arg = no_argument;
2407 else
2408 lopt->has_arg = required_argument;
2409}
2410
Steven Langde890a12011-11-09 14:03:34 +01002411static void options_to_lopts(struct fio_option *opts,
2412 struct option *long_options,
2413 int i, int option_type)
2414{
2415 struct fio_option *o = &opts[0];
2416 while (o->name) {
2417 add_to_lopt(&long_options[i], o, o->name, option_type);
2418 if (o->alias) {
2419 i++;
2420 add_to_lopt(&long_options[i], o, o->alias, option_type);
2421 }
2422
2423 i++;
2424 o++;
2425 assert(i < FIO_NR_OPTIONS);
2426 }
2427}
2428
2429void fio_options_set_ioengine_opts(struct option *long_options,
2430 struct thread_data *td)
2431{
2432 unsigned int i;
2433
2434 i = 0;
2435 while (long_options[i].name) {
2436 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
2437 memset(&long_options[i], 0, sizeof(*long_options));
2438 break;
2439 }
2440 i++;
2441 }
2442
2443 /*
2444 * Just clear out the prior ioengine options.
2445 */
2446 if (!td || !td->eo)
2447 return;
2448
2449 options_to_lopts(td->io_ops->options, long_options, i,
2450 FIO_GETOPT_IOENGINE);
2451}
2452
Jens Axboe214e1ec2007-03-15 10:48:13 +01002453void fio_options_dup_and_init(struct option *long_options)
2454{
Jens Axboe214e1ec2007-03-15 10:48:13 +01002455 unsigned int i;
2456
2457 options_init(options);
2458
2459 i = 0;
2460 while (long_options[i].name)
2461 i++;
2462
Steven Langde890a12011-11-09 14:03:34 +01002463 options_to_lopts(options, long_options, i, FIO_GETOPT_JOB);
Jens Axboe214e1ec2007-03-15 10:48:13 +01002464}
2465
Jens Axboe74929ac2009-08-05 11:42:37 +02002466struct fio_keyword {
2467 const char *word;
2468 const char *desc;
2469 char *replace;
2470};
2471
2472static struct fio_keyword fio_keywords[] = {
2473 {
2474 .word = "$pagesize",
2475 .desc = "Page size in the system",
2476 },
2477 {
2478 .word = "$mb_memory",
2479 .desc = "Megabytes of memory online",
2480 },
2481 {
2482 .word = "$ncpus",
2483 .desc = "Number of CPUs online in the system",
2484 },
2485 {
2486 .word = NULL,
2487 },
2488};
2489
2490void fio_keywords_init(void)
2491{
Jens Axboe3b2e1462009-12-15 08:58:10 +01002492 unsigned long long mb_memory;
Jens Axboe74929ac2009-08-05 11:42:37 +02002493 char buf[128];
2494 long l;
2495
Jens Axboea4cfc472012-10-09 10:30:48 -06002496 sprintf(buf, "%lu", (unsigned long) page_size);
Jens Axboe74929ac2009-08-05 11:42:37 +02002497 fio_keywords[0].replace = strdup(buf);
2498
Jens Axboe8eb016d2011-07-11 10:24:20 +02002499 mb_memory = os_phys_mem() / (1024 * 1024);
Jens Axboe3b2e1462009-12-15 08:58:10 +01002500 sprintf(buf, "%llu", mb_memory);
Jens Axboe74929ac2009-08-05 11:42:37 +02002501 fio_keywords[1].replace = strdup(buf);
2502
Jens Axboec00a2282011-07-08 20:56:06 +02002503 l = cpus_online();
Jens Axboe74929ac2009-08-05 11:42:37 +02002504 sprintf(buf, "%lu", l);
2505 fio_keywords[2].replace = strdup(buf);
2506}
2507
Jens Axboe892a6ff2009-11-13 12:19:49 +01002508#define BC_APP "bc"
2509
2510static char *bc_calc(char *str)
2511{
Steven Langd0c814e2011-10-28 08:37:13 +02002512 char buf[128], *tmp;
Jens Axboe892a6ff2009-11-13 12:19:49 +01002513 FILE *f;
2514 int ret;
2515
2516 /*
2517 * No math, just return string
2518 */
Steven Langd0c814e2011-10-28 08:37:13 +02002519 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
2520 !strchr(str, '/')) || strchr(str, '\''))
Jens Axboe892a6ff2009-11-13 12:19:49 +01002521 return str;
2522
2523 /*
2524 * Split option from value, we only need to calculate the value
2525 */
2526 tmp = strchr(str, '=');
2527 if (!tmp)
2528 return str;
2529
2530 tmp++;
Jens Axboe892a6ff2009-11-13 12:19:49 +01002531
Steven Langd0c814e2011-10-28 08:37:13 +02002532 /*
2533 * Prevent buffer overflows; such a case isn't reasonable anyway
2534 */
2535 if (strlen(str) >= 128 || strlen(tmp) > 100)
2536 return str;
Jens Axboe892a6ff2009-11-13 12:19:49 +01002537
2538 sprintf(buf, "which %s > /dev/null", BC_APP);
2539 if (system(buf)) {
2540 log_err("fio: bc is needed for performing math\n");
Jens Axboe892a6ff2009-11-13 12:19:49 +01002541 return NULL;
2542 }
2543
Steven Langd0c814e2011-10-28 08:37:13 +02002544 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
Jens Axboe892a6ff2009-11-13 12:19:49 +01002545 f = popen(buf, "r");
2546 if (!f) {
Jens Axboe892a6ff2009-11-13 12:19:49 +01002547 return NULL;
2548 }
2549
Steven Langd0c814e2011-10-28 08:37:13 +02002550 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
Jens Axboe892a6ff2009-11-13 12:19:49 +01002551 if (ret <= 0) {
Jens Axboe892a6ff2009-11-13 12:19:49 +01002552 return NULL;
2553 }
2554
Jens Axboe892a6ff2009-11-13 12:19:49 +01002555 pclose(f);
Steven Langd0c814e2011-10-28 08:37:13 +02002556 buf[(tmp - str) + ret - 1] = '\0';
2557 memcpy(buf, str, tmp - str);
Jens Axboe892a6ff2009-11-13 12:19:49 +01002558 free(str);
Steven Langd0c814e2011-10-28 08:37:13 +02002559 return strdup(buf);
2560}
2561
2562/*
2563 * Return a copy of the input string with substrings of the form ${VARNAME}
2564 * substituted with the value of the environment variable VARNAME. The
2565 * substitution always occurs, even if VARNAME is empty or the corresponding
2566 * environment variable undefined.
2567 */
2568static char *option_dup_subs(const char *opt)
2569{
2570 char out[OPT_LEN_MAX+1];
2571 char in[OPT_LEN_MAX+1];
2572 char *outptr = out;
2573 char *inptr = in;
2574 char *ch1, *ch2, *env;
2575 ssize_t nchr = OPT_LEN_MAX;
2576 size_t envlen;
2577
2578 if (strlen(opt) + 1 > OPT_LEN_MAX) {
2579 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
2580 return NULL;
2581 }
2582
2583 in[OPT_LEN_MAX] = '\0';
2584 strncpy(in, opt, OPT_LEN_MAX);
2585
2586 while (*inptr && nchr > 0) {
2587 if (inptr[0] == '$' && inptr[1] == '{') {
2588 ch2 = strchr(inptr, '}');
2589 if (ch2 && inptr+1 < ch2) {
2590 ch1 = inptr+2;
2591 inptr = ch2+1;
2592 *ch2 = '\0';
2593
2594 env = getenv(ch1);
2595 if (env) {
2596 envlen = strlen(env);
2597 if (envlen <= nchr) {
2598 memcpy(outptr, env, envlen);
2599 outptr += envlen;
2600 nchr -= envlen;
2601 }
2602 }
2603
2604 continue;
2605 }
2606 }
2607
2608 *outptr++ = *inptr++;
2609 --nchr;
2610 }
2611
2612 *outptr = '\0';
2613 return strdup(out);
Jens Axboe892a6ff2009-11-13 12:19:49 +01002614}
2615
Jens Axboe74929ac2009-08-05 11:42:37 +02002616/*
2617 * Look for reserved variable names and replace them with real values
2618 */
2619static char *fio_keyword_replace(char *opt)
2620{
2621 char *s;
2622 int i;
Steven Langd0c814e2011-10-28 08:37:13 +02002623 int docalc = 0;
Jens Axboe74929ac2009-08-05 11:42:37 +02002624
2625 for (i = 0; fio_keywords[i].word != NULL; i++) {
2626 struct fio_keyword *kw = &fio_keywords[i];
2627
2628 while ((s = strstr(opt, kw->word)) != NULL) {
2629 char *new = malloc(strlen(opt) + 1);
2630 char *o_org = opt;
2631 int olen = s - opt;
2632 int len;
2633
2634 /*
2635 * Copy part of the string before the keyword and
2636 * sprintf() the replacement after it.
2637 */
2638 memcpy(new, opt, olen);
2639 len = sprintf(new + olen, "%s", kw->replace);
2640
2641 /*
2642 * If there's more in the original string, copy that
2643 * in too
2644 */
2645 opt += strlen(kw->word) + olen;
2646 if (strlen(opt))
2647 memcpy(new + olen + len, opt, opt - o_org - 1);
2648
2649 /*
2650 * replace opt and free the old opt
2651 */
2652 opt = new;
Steven Langd0c814e2011-10-28 08:37:13 +02002653 free(o_org);
Jens Axboe7a958bd2009-11-13 12:33:54 +01002654
Steven Langd0c814e2011-10-28 08:37:13 +02002655 docalc = 1;
Jens Axboe74929ac2009-08-05 11:42:37 +02002656 }
2657 }
2658
Steven Langd0c814e2011-10-28 08:37:13 +02002659 /*
2660 * Check for potential math and invoke bc, if possible
2661 */
2662 if (docalc)
2663 opt = bc_calc(opt);
2664
Jens Axboe7a958bd2009-11-13 12:33:54 +01002665 return opt;
Jens Axboe74929ac2009-08-05 11:42:37 +02002666}
2667
Steven Langd0c814e2011-10-28 08:37:13 +02002668static char **dup_and_sub_options(char **opts, int num_opts)
2669{
2670 int i;
2671 char **opts_copy = malloc(num_opts * sizeof(*opts));
2672 for (i = 0; i < num_opts; i++) {
2673 opts_copy[i] = option_dup_subs(opts[i]);
2674 if (!opts_copy[i])
2675 continue;
2676 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
2677 }
2678 return opts_copy;
2679}
2680
Jens Axboe3b8b7132008-06-10 19:46:23 +02002681int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
Jens Axboe214e1ec2007-03-15 10:48:13 +01002682{
Steven Langde890a12011-11-09 14:03:34 +01002683 int i, ret, unknown;
Steven Langd0c814e2011-10-28 08:37:13 +02002684 char **opts_copy;
Jens Axboe3b8b7132008-06-10 19:46:23 +02002685
2686 sort_options(opts, options, num_opts);
Steven Langd0c814e2011-10-28 08:37:13 +02002687 opts_copy = dup_and_sub_options(opts, num_opts);
Jens Axboe3b8b7132008-06-10 19:46:23 +02002688
Steven Langde890a12011-11-09 14:03:34 +01002689 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
2690 struct fio_option *o;
2691 int newret = parse_option(opts_copy[i], opts[i], options, &o,
2692 td);
Steven Langd0c814e2011-10-28 08:37:13 +02002693
Steven Langde890a12011-11-09 14:03:34 +01002694 if (opts_copy[i]) {
2695 if (newret && !o) {
2696 unknown++;
2697 continue;
2698 }
Steven Langd0c814e2011-10-28 08:37:13 +02002699 free(opts_copy[i]);
Steven Langde890a12011-11-09 14:03:34 +01002700 opts_copy[i] = NULL;
2701 }
2702
2703 ret |= newret;
2704 }
2705
2706 if (unknown) {
2707 ret |= ioengine_load(td);
2708 if (td->eo) {
2709 sort_options(opts_copy, td->io_ops->options, num_opts);
2710 opts = opts_copy;
2711 }
2712 for (i = 0; i < num_opts; i++) {
2713 struct fio_option *o = NULL;
2714 int newret = 1;
2715 if (!opts_copy[i])
2716 continue;
2717
2718 if (td->eo)
2719 newret = parse_option(opts_copy[i], opts[i],
2720 td->io_ops->options, &o,
2721 td->eo);
2722
2723 ret |= newret;
2724 if (!o)
2725 log_err("Bad option <%s>\n", opts[i]);
2726
2727 free(opts_copy[i]);
2728 opts_copy[i] = NULL;
2729 }
Jens Axboe74929ac2009-08-05 11:42:37 +02002730 }
Jens Axboe3b8b7132008-06-10 19:46:23 +02002731
Steven Langd0c814e2011-10-28 08:37:13 +02002732 free(opts_copy);
Jens Axboe3b8b7132008-06-10 19:46:23 +02002733 return ret;
Jens Axboe214e1ec2007-03-15 10:48:13 +01002734}
2735
2736int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
2737{
Jens Axboe07b32322010-03-05 09:48:44 +01002738 return parse_cmd_option(opt, val, options, td);
Jens Axboe214e1ec2007-03-15 10:48:13 +01002739}
2740
Steven Langde890a12011-11-09 14:03:34 +01002741int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
2742 char *val)
2743{
2744 return parse_cmd_option(opt, val, td->io_ops->options, td);
2745}
2746
Jens Axboe214e1ec2007-03-15 10:48:13 +01002747void fio_fill_default_options(struct thread_data *td)
2748{
2749 fill_default_options(td, options);
2750}
2751
2752int fio_show_option_help(const char *opt)
2753{
Jens Axboe07b32322010-03-05 09:48:44 +01002754 return show_cmd_help(options, opt);
Jens Axboe214e1ec2007-03-15 10:48:13 +01002755}
Jens Axboed23bb322007-03-23 15:57:56 +01002756
Steven Langde890a12011-11-09 14:03:34 +01002757void options_mem_dupe(void *data, struct fio_option *options)
2758{
2759 struct fio_option *o;
2760 char **ptr;
2761
2762 for (o = &options[0]; o->name; o++) {
2763 if (o->type != FIO_OPT_STR_STORE)
2764 continue;
2765
2766 ptr = td_var(data, o->off1);
2767 if (*ptr)
2768 *ptr = strdup(*ptr);
2769 }
2770}
2771
Jens Axboe7e356b22011-10-14 10:55:16 +02002772/*
2773 * dupe FIO_OPT_STR_STORE options
2774 */
Steven Langde890a12011-11-09 14:03:34 +01002775void fio_options_mem_dupe(struct thread_data *td)
Jens Axboed23bb322007-03-23 15:57:56 +01002776{
Steven Langde890a12011-11-09 14:03:34 +01002777 options_mem_dupe(&td->o, options);
Jens Axboe1647f592011-11-09 20:25:21 +01002778
2779 if (td->eo && td->io_ops) {
Steven Langde890a12011-11-09 14:03:34 +01002780 void *oldeo = td->eo;
Jens Axboe1647f592011-11-09 20:25:21 +01002781
Steven Langde890a12011-11-09 14:03:34 +01002782 td->eo = malloc(td->io_ops->option_struct_size);
2783 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
2784 options_mem_dupe(td->eo, td->io_ops->options);
Jens Axboed23bb322007-03-23 15:57:56 +01002785 }
2786}
2787
Jens Axboed6978a32009-07-18 21:04:09 +02002788unsigned int fio_get_kb_base(void *data)
2789{
2790 struct thread_data *td = data;
2791 unsigned int kb_base = 0;
2792
2793 if (td)
2794 kb_base = td->o.kb_base;
2795 if (!kb_base)
2796 kb_base = 1024;
2797
2798 return kb_base;
2799}
Jens Axboe9f988e22010-03-04 10:42:38 +01002800
Jens Axboe07b32322010-03-05 09:48:44 +01002801int add_option(struct fio_option *o)
Jens Axboe9f988e22010-03-04 10:42:38 +01002802{
Jens Axboe07b32322010-03-05 09:48:44 +01002803 struct fio_option *__o;
2804 int opt_index = 0;
2805
2806 __o = options;
2807 while (__o->name) {
2808 opt_index++;
2809 __o++;
2810 }
2811
2812 memcpy(&options[opt_index], o, sizeof(*o));
2813 return 0;
Jens Axboe9f988e22010-03-04 10:42:38 +01002814}
Jens Axboee2de69d2010-03-04 14:05:48 +01002815
Jens Axboe07b32322010-03-05 09:48:44 +01002816void invalidate_profile_options(const char *prof_name)
Jens Axboee2de69d2010-03-04 14:05:48 +01002817{
Jens Axboe07b32322010-03-05 09:48:44 +01002818 struct fio_option *o;
Jens Axboee2de69d2010-03-04 14:05:48 +01002819
Jens Axboe07b32322010-03-05 09:48:44 +01002820 o = options;
2821 while (o->name) {
2822 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
2823 o->type = FIO_OPT_INVALID;
2824 o->prof_name = NULL;
2825 }
2826 o++;
Jens Axboee2de69d2010-03-04 14:05:48 +01002827 }
2828}
Jens Axboef5b6bb82010-03-05 10:09:59 +01002829
2830void add_opt_posval(const char *optname, const char *ival, const char *help)
2831{
2832 struct fio_option *o;
2833 unsigned int i;
2834
2835 o = find_option(options, optname);
2836 if (!o)
2837 return;
2838
2839 for (i = 0; i < PARSE_MAX_VP; i++) {
2840 if (o->posval[i].ival)
2841 continue;
2842
2843 o->posval[i].ival = ival;
2844 o->posval[i].help = help;
2845 break;
2846 }
2847}
2848
2849void del_opt_posval(const char *optname, const char *ival)
2850{
2851 struct fio_option *o;
2852 unsigned int i;
2853
2854 o = find_option(options, optname);
2855 if (!o)
2856 return;
2857
2858 for (i = 0; i < PARSE_MAX_VP; i++) {
2859 if (!o->posval[i].ival)
2860 continue;
2861 if (strcmp(o->posval[i].ival, ival))
2862 continue;
2863
2864 o->posval[i].ival = NULL;
2865 o->posval[i].help = NULL;
2866 }
2867}
Jens Axboe7e356b22011-10-14 10:55:16 +02002868
2869void fio_options_free(struct thread_data *td)
2870{
2871 options_free(options, td);
Steven Langde890a12011-11-09 14:03:34 +01002872 if (td->eo && td->io_ops && td->io_ops->options) {
2873 options_free(td->io_ops->options, td->eo);
2874 free(td->eo);
2875 td->eo = NULL;
2876 }
Jens Axboe7e356b22011-10-14 10:55:16 +02002877}