blob: 66099b58d3bd4ba4d4f2b26390e2392e4966e838 [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
Shaohua Lid9759b12013-01-17 13:28:15 +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 Axboe214e1ec2007-03-15 10:48:13 +0100347
348 return 0;
349}
350
Jens Axboe5d7c5d32010-06-21 15:08:17 +0200351static int str_verify_cb(void *data, const char *mem)
352{
353 struct thread_data *td = data;
354
Jens Axboee3aaafc2012-02-22 20:28:17 +0100355 if (td->o.verify == VERIFY_CRC32C_INTEL ||
356 td->o.verify == VERIFY_CRC32C) {
357 crc32c_intel_probe();
Jens Axboe5d7c5d32010-06-21 15:08:17 +0200358 }
359
360 return 0;
361}
362
Jens Axboec223da82010-03-24 13:23:53 +0100363static int fio_clock_source_cb(void *data, const char *str)
364{
365 struct thread_data *td = data;
366
367 fio_clock_source = td->o.clocksource;
Jens Axboefa80fea2012-12-09 20:29:00 +0100368 fio_clock_source_set = 1;
Jens Axboe01423ea2012-12-14 20:37:06 +0100369 fio_clock_init();
Jens Axboec223da82010-03-24 13:23:53 +0100370 return 0;
371}
372
Cigy Cyriac85bc8332010-08-10 19:21:09 -0400373static int str_lockmem_cb(void fio_unused *data, unsigned long long *val)
Jens Axboe214e1ec2007-03-15 10:48:13 +0100374{
375 mlock_size = *val;
376 return 0;
377}
378
Cigy Cyriac85bc8332010-08-10 19:21:09 -0400379static int str_rwmix_read_cb(void *data, unsigned long long *val)
Jens Axboecb499fc2008-05-28 10:33:32 +0200380{
381 struct thread_data *td = data;
382
383 td->o.rwmix[DDIR_READ] = *val;
384 td->o.rwmix[DDIR_WRITE] = 100 - *val;
385 return 0;
386}
387
Cigy Cyriac85bc8332010-08-10 19:21:09 -0400388static int str_rwmix_write_cb(void *data, unsigned long long *val)
Jens Axboecb499fc2008-05-28 10:33:32 +0200389{
390 struct thread_data *td = data;
391
392 td->o.rwmix[DDIR_WRITE] = *val;
393 td->o.rwmix[DDIR_READ] = 100 - *val;
394 return 0;
395}
396
Jens Axboe214e1ec2007-03-15 10:48:13 +0100397#ifdef FIO_HAVE_IOPRIO
Cigy Cyriac85bc8332010-08-10 19:21:09 -0400398static int str_prioclass_cb(void *data, unsigned long long *val)
Jens Axboe214e1ec2007-03-15 10:48:13 +0100399{
400 struct thread_data *td = data;
Jens Axboe6cefbe32007-04-18 12:46:56 +0200401 unsigned short mask;
402
403 /*
404 * mask off old class bits, str_prio_cb() may have set a default class
405 */
406 mask = (1 << IOPRIO_CLASS_SHIFT) - 1;
407 td->ioprio &= mask;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100408
409 td->ioprio |= *val << IOPRIO_CLASS_SHIFT;
Jens Axboeac684782007-11-08 08:29:07 +0100410 td->ioprio_set = 1;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100411 return 0;
412}
413
Cigy Cyriac85bc8332010-08-10 19:21:09 -0400414static int str_prio_cb(void *data, unsigned long long *val)
Jens Axboe214e1ec2007-03-15 10:48:13 +0100415{
416 struct thread_data *td = data;
417
418 td->ioprio |= *val;
Jens Axboe6cefbe32007-04-18 12:46:56 +0200419
420 /*
421 * If no class is set, assume BE
422 */
423 if ((td->ioprio >> IOPRIO_CLASS_SHIFT) == 0)
424 td->ioprio |= IOPRIO_CLASS_BE << IOPRIO_CLASS_SHIFT;
425
Jens Axboeac684782007-11-08 08:29:07 +0100426 td->ioprio_set = 1;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100427 return 0;
428}
429#endif
430
431static int str_exitall_cb(void)
432{
433 exitall_on_terminate = 1;
434 return 0;
435}
436
Jens Axboe214e1ec2007-03-15 10:48:13 +0100437#ifdef FIO_HAVE_CPU_AFFINITY
Cigy Cyriac85bc8332010-08-10 19:21:09 -0400438static int str_cpumask_cb(void *data, unsigned long long *val)
Jens Axboe214e1ec2007-03-15 10:48:13 +0100439{
440 struct thread_data *td = data;
Jens Axboed2e268b2007-06-15 10:33:49 +0200441 unsigned int i;
Jens Axboeb03daaf2008-12-08 20:31:43 +0100442 long max_cpu;
Jens Axboed2ce18b2008-12-12 20:51:40 +0100443 int ret;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100444
Jens Axboed2ce18b2008-12-12 20:51:40 +0100445 ret = fio_cpuset_init(&td->o.cpumask);
446 if (ret < 0) {
447 log_err("fio: cpuset_init failed\n");
448 td_verror(td, ret, "fio_cpuset_init");
449 return 1;
450 }
451
Jens Axboec00a2282011-07-08 20:56:06 +0200452 max_cpu = cpus_online();
Jens Axboed2e268b2007-06-15 10:33:49 +0200453
Jens Axboe62a72732008-12-08 11:37:01 +0100454 for (i = 0; i < sizeof(int) * 8; i++) {
455 if ((1 << i) & *val) {
Jens Axboeb03daaf2008-12-08 20:31:43 +0100456 if (i > max_cpu) {
457 log_err("fio: CPU %d too large (max=%ld)\n", i,
458 max_cpu);
459 return 1;
460 }
Jens Axboe62a72732008-12-08 11:37:01 +0100461 dprint(FD_PARSE, "set cpu allowed %d\n", i);
Jens Axboe6d459ee2008-12-12 20:02:58 +0100462 fio_cpu_set(&td->o.cpumask, i);
Jens Axboe62a72732008-12-08 11:37:01 +0100463 }
464 }
Jens Axboed2e268b2007-06-15 10:33:49 +0200465
Jens Axboe375b2692007-05-22 09:13:02 +0200466 td->o.cpumask_set = 1;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100467 return 0;
468}
469
Jens Axboee8462bd2009-07-06 12:59:04 +0200470static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask,
471 const char *input)
Jens Axboed2e268b2007-06-15 10:33:49 +0200472{
Jens Axboed2e268b2007-06-15 10:33:49 +0200473 char *cpu, *str, *p;
Jens Axboeb03daaf2008-12-08 20:31:43 +0100474 long max_cpu;
Jens Axboe19608d62008-12-08 15:03:12 +0100475 int ret = 0;
Jens Axboed2e268b2007-06-15 10:33:49 +0200476
Jens Axboee8462bd2009-07-06 12:59:04 +0200477 ret = fio_cpuset_init(mask);
Jens Axboed2ce18b2008-12-12 20:51:40 +0100478 if (ret < 0) {
479 log_err("fio: cpuset_init failed\n");
480 td_verror(td, ret, "fio_cpuset_init");
481 return 1;
482 }
Jens Axboed2e268b2007-06-15 10:33:49 +0200483
484 p = str = strdup(input);
485
486 strip_blank_front(&str);
487 strip_blank_end(str);
488
Jens Axboec00a2282011-07-08 20:56:06 +0200489 max_cpu = cpus_online();
Jens Axboeb03daaf2008-12-08 20:31:43 +0100490
Jens Axboed2e268b2007-06-15 10:33:49 +0200491 while ((cpu = strsep(&str, ",")) != NULL) {
Jens Axboe62a72732008-12-08 11:37:01 +0100492 char *str2, *cpu2;
493 int icpu, icpu2;
494
Jens Axboed2e268b2007-06-15 10:33:49 +0200495 if (!strlen(cpu))
496 break;
Jens Axboe62a72732008-12-08 11:37:01 +0100497
498 str2 = cpu;
499 icpu2 = -1;
500 while ((cpu2 = strsep(&str2, "-")) != NULL) {
501 if (!strlen(cpu2))
502 break;
503
504 icpu2 = atoi(cpu2);
505 }
506
507 icpu = atoi(cpu);
508 if (icpu2 == -1)
509 icpu2 = icpu;
510 while (icpu <= icpu2) {
Jens Axboe6d459ee2008-12-12 20:02:58 +0100511 if (icpu >= FIO_MAX_CPUS) {
Jens Axboe19608d62008-12-08 15:03:12 +0100512 log_err("fio: your OS only supports up to"
Jens Axboe6d459ee2008-12-12 20:02:58 +0100513 " %d CPUs\n", (int) FIO_MAX_CPUS);
Jens Axboe19608d62008-12-08 15:03:12 +0100514 ret = 1;
515 break;
516 }
Jens Axboeb03daaf2008-12-08 20:31:43 +0100517 if (icpu > max_cpu) {
518 log_err("fio: CPU %d too large (max=%ld)\n",
519 icpu, max_cpu);
520 ret = 1;
521 break;
522 }
Jens Axboe0b9d69e2009-09-11 22:29:54 +0200523
Jens Axboe62a72732008-12-08 11:37:01 +0100524 dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
Jens Axboee8462bd2009-07-06 12:59:04 +0200525 fio_cpu_set(mask, icpu);
Jens Axboe62a72732008-12-08 11:37:01 +0100526 icpu++;
527 }
Jens Axboe19608d62008-12-08 15:03:12 +0100528 if (ret)
529 break;
Jens Axboed2e268b2007-06-15 10:33:49 +0200530 }
531
532 free(p);
Jens Axboe19608d62008-12-08 15:03:12 +0100533 if (!ret)
534 td->o.cpumask_set = 1;
535 return ret;
Jens Axboed2e268b2007-06-15 10:33:49 +0200536}
Jens Axboee8462bd2009-07-06 12:59:04 +0200537
538static int str_cpus_allowed_cb(void *data, const char *input)
539{
540 struct thread_data *td = data;
541 int ret;
542
543 ret = set_cpus_allowed(td, &td->o.cpumask, input);
544 if (!ret)
545 td->o.cpumask_set = 1;
546
547 return ret;
548}
549
550static int str_verify_cpus_allowed_cb(void *data, const char *input)
551{
552 struct thread_data *td = data;
553 int ret;
554
555 ret = set_cpus_allowed(td, &td->o.verify_cpumask, input);
556 if (!ret)
557 td->o.verify_cpumask_set = 1;
558
559 return ret;
560}
Jens Axboed2e268b2007-06-15 10:33:49 +0200561#endif
562
Jens Axboe67bf9822013-01-10 11:23:19 +0100563#ifdef CONFIG_LIBNUMA
Yufei Rend0b937e2012-10-19 23:11:52 -0400564static int str_numa_cpunodes_cb(void *data, char *input)
565{
566 struct thread_data *td = data;
567
568 /* numa_parse_nodestring() parses a character string list
569 * of nodes into a bit mask. The bit mask is allocated by
570 * numa_allocate_nodemask(), so it should be freed by
571 * numa_free_nodemask().
572 */
573 td->o.numa_cpunodesmask = numa_parse_nodestring(input);
574 if (td->o.numa_cpunodesmask == NULL) {
575 log_err("fio: numa_parse_nodestring failed\n");
576 td_verror(td, 1, "str_numa_cpunodes_cb");
577 return 1;
578 }
579
580 td->o.numa_cpumask_set = 1;
581 return 0;
582}
583
584static int str_numa_mpol_cb(void *data, char *input)
585{
586 struct thread_data *td = data;
587 const char * const policy_types[] =
588 { "default", "prefer", "bind", "interleave", "local" };
589 int i;
590
591 char *nodelist = strchr(input, ':');
592 if (nodelist) {
593 /* NUL-terminate mode */
594 *nodelist++ = '\0';
595 }
596
597 for (i = 0; i <= MPOL_LOCAL; i++) {
598 if (!strcmp(input, policy_types[i])) {
599 td->o.numa_mem_mode = i;
600 break;
601 }
602 }
603 if (i > MPOL_LOCAL) {
604 log_err("fio: memory policy should be: default, prefer, bind, interleave, local\n");
605 goto out;
606 }
607
608 switch (td->o.numa_mem_mode) {
609 case MPOL_PREFERRED:
610 /*
611 * Insist on a nodelist of one node only
612 */
613 if (nodelist) {
614 char *rest = nodelist;
615 while (isdigit(*rest))
616 rest++;
617 if (*rest) {
618 log_err("fio: one node only for \'prefer\'\n");
619 goto out;
620 }
621 } else {
622 log_err("fio: one node is needed for \'prefer\'\n");
623 goto out;
624 }
625 break;
626 case MPOL_INTERLEAVE:
627 /*
628 * Default to online nodes with memory if no nodelist
629 */
630 if (!nodelist)
631 nodelist = strdup("all");
632 break;
633 case MPOL_LOCAL:
634 case MPOL_DEFAULT:
635 /*
636 * Don't allow a nodelist
637 */
638 if (nodelist) {
639 log_err("fio: NO nodelist for \'local\'\n");
640 goto out;
641 }
642 break;
643 case MPOL_BIND:
644 /*
645 * Insist on a nodelist
646 */
647 if (!nodelist) {
648 log_err("fio: a nodelist is needed for \'bind\'\n");
649 goto out;
650 }
651 break;
652 }
653
654
655 /* numa_parse_nodestring() parses a character string list
656 * of nodes into a bit mask. The bit mask is allocated by
657 * numa_allocate_nodemask(), so it should be freed by
658 * numa_free_nodemask().
659 */
660 switch (td->o.numa_mem_mode) {
661 case MPOL_PREFERRED:
662 td->o.numa_mem_prefer_node = atoi(nodelist);
663 break;
664 case MPOL_INTERLEAVE:
665 case MPOL_BIND:
666 td->o.numa_memnodesmask = numa_parse_nodestring(nodelist);
667 if (td->o.numa_memnodesmask == NULL) {
668 log_err("fio: numa_parse_nodestring failed\n");
669 td_verror(td, 1, "str_numa_memnodes_cb");
670 return 1;
671 }
672 break;
673 case MPOL_LOCAL:
674 case MPOL_DEFAULT:
675 default:
676 break;
677 }
678
679 td->o.numa_memmask_set = 1;
680 return 0;
681
682out:
683 return 1;
684}
685#endif
686
Jens Axboe0d29de82010-09-01 13:54:15 +0200687#ifdef FIO_HAVE_TRIM
688static int str_verify_trim_cb(void *data, unsigned long long *val)
689{
690 struct thread_data *td = data;
691
692 td->o.trim_percentage = *val;
693 return 0;
694}
695#endif
696
Jens Axboe214e1ec2007-03-15 10:48:13 +0100697static int str_fst_cb(void *data, const char *str)
698{
699 struct thread_data *td = data;
700 char *nr = get_opt_postfix(str);
701
702 td->file_service_nr = 1;
Jens Axboe182ec6e2008-11-14 13:06:06 +0100703 if (nr) {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100704 td->file_service_nr = atoi(nr);
Jens Axboe182ec6e2008-11-14 13:06:06 +0100705 free(nr);
706 }
Jens Axboe214e1ec2007-03-15 10:48:13 +0100707
708 return 0;
709}
710
Jens Axboe67bf9822013-01-10 11:23:19 +0100711#ifdef CONFIG_SYNC_FILE_RANGE
Jens Axboe44f29692010-03-09 20:09:44 +0100712static int str_sfr_cb(void *data, const char *str)
713{
714 struct thread_data *td = data;
715 char *nr = get_opt_postfix(str);
716
717 td->sync_file_range_nr = 1;
718 if (nr) {
719 td->sync_file_range_nr = atoi(nr);
720 free(nr);
721 }
722
723 return 0;
724}
Jens Axboe3ae06372010-03-19 19:17:15 +0100725#endif
Jens Axboe44f29692010-03-09 20:09:44 +0100726
Jens Axboee25839d2012-11-06 10:49:42 +0100727static int str_random_distribution_cb(void *data, const char *str)
728{
729 struct thread_data *td = data;
730 double val;
731 char *nr;
732
Jens Axboe925fee32012-11-06 13:50:32 +0100733 if (td->o.random_distribution == FIO_RAND_DIST_ZIPF)
734 val = 1.1;
735 else if (td->o.random_distribution == FIO_RAND_DIST_PARETO)
736 val = 0.2;
737 else
Jens Axboee25839d2012-11-06 10:49:42 +0100738 return 0;
739
740 nr = get_opt_postfix(str);
Jens Axboe925fee32012-11-06 13:50:32 +0100741 if (nr && !str_to_float(nr, &val)) {
Jens Axboee25839d2012-11-06 10:49:42 +0100742 log_err("fio: random postfix parsing failed\n");
743 free(nr);
744 return 1;
745 }
746
Jens Axboe078189c2012-11-07 13:47:22 +0100747 free(nr);
748
Jens Axboe18ded912012-11-08 08:36:00 +0100749 if (td->o.random_distribution == FIO_RAND_DIST_ZIPF) {
750 if (val == 1.00) {
751 log_err("fio: zipf theta must different than 1.0\n");
752 return 1;
753 }
Jens Axboe925fee32012-11-06 13:50:32 +0100754 td->o.zipf_theta = val;
Jens Axboe18ded912012-11-08 08:36:00 +0100755 } else {
Jens Axboe078189c2012-11-07 13:47:22 +0100756 if (val <= 0.00 || val >= 1.00) {
757 log_err("fio: pareto input out of range (0 < input < 1.0)\n");
758 return 1;
759 }
Jens Axboe925fee32012-11-06 13:50:32 +0100760 td->o.pareto_h = val;
Jens Axboe078189c2012-11-07 13:47:22 +0100761 }
Jens Axboe925fee32012-11-06 13:50:32 +0100762
Jens Axboee25839d2012-11-06 10:49:42 +0100763 return 0;
764}
765
Jens Axboe921c7662008-03-26 09:17:55 +0100766static int check_dir(struct thread_data *td, char *fname)
767{
Jens Axboe3f0ca9b2011-05-24 21:36:24 +0200768#if 0
Jens Axboe921c7662008-03-26 09:17:55 +0100769 char file[PATH_MAX], *dir;
Jens Axboebc838912008-04-07 09:00:54 +0200770 int elen = 0;
Jens Axboe921c7662008-03-26 09:17:55 +0100771
Jens Axboebc838912008-04-07 09:00:54 +0200772 if (td->o.directory) {
773 strcpy(file, td->o.directory);
Jens Axboefcef0b32008-05-26 14:53:24 +0200774 strcat(file, "/");
Jens Axboebc838912008-04-07 09:00:54 +0200775 elen = strlen(file);
776 }
777
Jens Axboefcef0b32008-05-26 14:53:24 +0200778 sprintf(file + elen, "%s", fname);
Jens Axboe921c7662008-03-26 09:17:55 +0100779 dir = dirname(file);
780
Jens Axboefcef0b32008-05-26 14:53:24 +0200781 {
782 struct stat sb;
783 /*
784 * We can't do this on FIO_DISKLESSIO engines. The engine isn't loaded
785 * yet, so we can't do this check right here...
786 */
Jens Axboe921c7662008-03-26 09:17:55 +0100787 if (lstat(dir, &sb) < 0) {
788 int ret = errno;
789
790 log_err("fio: %s is not a directory\n", dir);
791 td_verror(td, ret, "lstat");
792 return 1;
793 }
794
795 if (!S_ISDIR(sb.st_mode)) {
796 log_err("fio: %s is not a directory\n", dir);
797 return 1;
798 }
Jens Axboefcef0b32008-05-26 14:53:24 +0200799 }
800#endif
Jens Axboe921c7662008-03-26 09:17:55 +0100801
802 return 0;
803}
804
Jens Axboe8e827d32009-08-04 09:51:48 +0200805/*
806 * Return next file in the string. Files are separated with ':'. If the ':'
807 * is escaped with a '\', then that ':' is part of the filename and does not
808 * indicate a new file.
809 */
810static char *get_next_file_name(char **ptr)
811{
812 char *str = *ptr;
813 char *p, *start;
814
815 if (!str || !strlen(str))
816 return NULL;
817
818 start = str;
819 do {
820 /*
821 * No colon, we are done
822 */
823 p = strchr(str, ':');
824 if (!p) {
825 *ptr = NULL;
826 break;
827 }
828
829 /*
830 * We got a colon, but it's the first character. Skip and
831 * continue
832 */
833 if (p == start) {
834 str = ++start;
835 continue;
836 }
837
838 if (*(p - 1) != '\\') {
839 *p = '\0';
840 *ptr = p + 1;
841 break;
842 }
843
844 memmove(p - 1, p, strlen(p) + 1);
845 str = p;
846 } while (1);
847
848 return start;
849}
850
Jens Axboe214e1ec2007-03-15 10:48:13 +0100851static int str_filename_cb(void *data, const char *input)
852{
853 struct thread_data *td = data;
854 char *fname, *str, *p;
855
856 p = str = strdup(input);
857
858 strip_blank_front(&str);
859 strip_blank_end(str);
860
861 if (!td->files_index)
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100862 td->o.nr_files = 0;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100863
Jens Axboe8e827d32009-08-04 09:51:48 +0200864 while ((fname = get_next_file_name(&str)) != NULL) {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100865 if (!strlen(fname))
866 break;
Jens Axboe921c7662008-03-26 09:17:55 +0100867 if (check_dir(td, fname)) {
868 free(p);
869 return 1;
870 }
Jens Axboe214e1ec2007-03-15 10:48:13 +0100871 add_file(td, fname);
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100872 td->o.nr_files++;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100873 }
874
875 free(p);
876 return 0;
877}
878
879static int str_directory_cb(void *data, const char fio_unused *str)
880{
881 struct thread_data *td = data;
882 struct stat sb;
883
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100884 if (lstat(td->o.directory, &sb) < 0) {
Jens Axboe921c7662008-03-26 09:17:55 +0100885 int ret = errno;
886
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100887 log_err("fio: %s is not a directory\n", td->o.directory);
Jens Axboe921c7662008-03-26 09:17:55 +0100888 td_verror(td, ret, "lstat");
Jens Axboe214e1ec2007-03-15 10:48:13 +0100889 return 1;
890 }
891 if (!S_ISDIR(sb.st_mode)) {
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100892 log_err("fio: %s is not a directory\n", td->o.directory);
Jens Axboe214e1ec2007-03-15 10:48:13 +0100893 return 1;
894 }
895
896 return 0;
897}
898
899static int str_opendir_cb(void *data, const char fio_unused *str)
900{
901 struct thread_data *td = data;
902
903 if (!td->files_index)
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100904 td->o.nr_files = 0;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100905
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100906 return add_dir_files(td, td->o.opendir);
Jens Axboe214e1ec2007-03-15 10:48:13 +0100907}
908
Cigy Cyriac85bc8332010-08-10 19:21:09 -0400909static int str_verify_offset_cb(void *data, unsigned long long *off)
Shawn Lewis546a9142007-07-28 21:11:37 +0200910{
911 struct thread_data *td = data;
Jens Axboea59e1702007-07-30 08:53:27 +0200912
Shawn Lewis546a9142007-07-28 21:11:37 +0200913 if (*off && *off < sizeof(struct verify_header)) {
Jens Axboea59e1702007-07-30 08:53:27 +0200914 log_err("fio: verify_offset too small\n");
Shawn Lewis546a9142007-07-28 21:11:37 +0200915 return 1;
916 }
Jens Axboea59e1702007-07-30 08:53:27 +0200917
918 td->o.verify_offset = *off;
Shawn Lewis546a9142007-07-28 21:11:37 +0200919 return 0;
920}
921
Radha Ramachandran0e92f872009-10-27 20:14:27 +0100922static int str_verify_pattern_cb(void *data, const char *input)
Jens Axboe90059d62007-07-30 09:33:12 +0200923{
924 struct thread_data *td = data;
Radha Ramachandran0e92f872009-10-27 20:14:27 +0100925 long off;
926 int i = 0, j = 0, len, k, base = 10;
927 char* loc1, * loc2;
Jens Axboe90059d62007-07-30 09:33:12 +0200928
Radha Ramachandran0e92f872009-10-27 20:14:27 +0100929 loc1 = strstr(input, "0x");
930 loc2 = strstr(input, "0X");
931 if (loc1 || loc2)
932 base = 16;
933 off = strtol(input, NULL, base);
934 if (off != LONG_MAX || errno != ERANGE) {
935 while (off) {
936 td->o.verify_pattern[i] = off & 0xff;
937 off >>= 8;
938 i++;
939 }
940 } else {
941 len = strlen(input);
942 k = len - 1;
943 if (base == 16) {
944 if (loc1)
945 j = loc1 - input + 2;
946 else
947 j = loc2 - input + 2;
948 } else
949 return 1;
950 if (len - j < MAX_PATTERN_SIZE * 2) {
951 while (k >= j) {
952 off = converthexchartoint(input[k--]);
953 if (k >= j)
954 off += (converthexchartoint(input[k--])
955 * 16);
956 td->o.verify_pattern[i++] = (char) off;
957 }
958 }
959 }
Steven Langefcd9dc2012-02-02 20:22:04 +0100960
961 /*
962 * Fill the pattern all the way to the end. This greatly reduces
963 * the number of memcpy's we have to do when verifying the IO.
964 */
965 while (i > 1 && i * 2 <= MAX_PATTERN_SIZE) {
966 memcpy(&td->o.verify_pattern[i], &td->o.verify_pattern[0], i);
967 i *= 2;
968 }
Steven Lang9a2a86d2012-02-07 09:42:59 +0100969 if (i == 1) {
970 /*
971 * The code in verify_io_u_pattern assumes a single byte pattern
972 * fills the whole verify pattern buffer.
973 */
974 memset(td->o.verify_pattern, td->o.verify_pattern[0],
975 MAX_PATTERN_SIZE);
976 }
Steven Langefcd9dc2012-02-02 20:22:04 +0100977
Radha Ramachandran0e92f872009-10-27 20:14:27 +0100978 td->o.verify_pattern_bytes = i;
Steven Langefcd9dc2012-02-02 20:22:04 +0100979
Jens Axboe92bf48d2011-01-14 21:20:42 +0100980 /*
981 * VERIFY_META could already be set
982 */
983 if (td->o.verify == VERIFY_NONE)
984 td->o.verify = VERIFY_PATTERN;
Steven Langefcd9dc2012-02-02 20:22:04 +0100985
Jens Axboe90059d62007-07-30 09:33:12 +0200986 return 0;
987}
Jens Axboe214e1ec2007-03-15 10:48:13 +0100988
Jens Axboee3cedca2008-11-19 19:57:52 +0100989static int str_write_bw_log_cb(void *data, const char *str)
990{
991 struct thread_data *td = data;
992
993 if (str)
994 td->o.bw_log_file = strdup(str);
995
996 td->o.write_bw_log = 1;
997 return 0;
998}
999
1000static int str_write_lat_log_cb(void *data, const char *str)
1001{
1002 struct thread_data *td = data;
1003
1004 if (str)
1005 td->o.lat_log_file = strdup(str);
1006
1007 td->o.write_lat_log = 1;
1008 return 0;
1009}
1010
Jens Axboec8eeb9d2011-10-05 14:02:22 +02001011static int str_write_iops_log_cb(void *data, const char *str)
1012{
1013 struct thread_data *td = data;
1014
1015 if (str)
1016 td->o.iops_log_file = strdup(str);
1017
1018 td->o.write_iops_log = 1;
1019 return 0;
1020}
1021
Jens Axboe993bf482008-11-14 13:04:53 +01001022static int str_gtod_reduce_cb(void *data, int *il)
1023{
1024 struct thread_data *td = data;
1025 int val = *il;
1026
Jens Axboe02af0982010-06-24 09:59:34 +02001027 td->o.disable_lat = !!val;
Jens Axboe993bf482008-11-14 13:04:53 +01001028 td->o.disable_clat = !!val;
1029 td->o.disable_slat = !!val;
1030 td->o.disable_bw = !!val;
Jens Axboe0dc1bc02011-10-13 08:55:29 +02001031 td->o.clat_percentiles = !val;
Jens Axboe993bf482008-11-14 13:04:53 +01001032 if (val)
1033 td->tv_cache_mask = 63;
1034
1035 return 0;
1036}
1037
Cigy Cyriac85bc8332010-08-10 19:21:09 -04001038static int str_gtod_cpu_cb(void *data, long long *il)
Jens Axboebe4ecfd2008-12-08 14:10:52 +01001039{
1040 struct thread_data *td = data;
1041 int val = *il;
1042
1043 td->o.gtod_cpu = val;
1044 td->o.gtod_offload = 1;
1045 return 0;
1046}
1047
Jens Axboe7bb59102011-07-12 19:47:03 +02001048static int str_size_cb(void *data, unsigned long long *__val)
1049{
1050 struct thread_data *td = data;
1051 unsigned long long v = *__val;
1052
1053 if (parse_is_percent(v)) {
1054 td->o.size = 0;
1055 td->o.size_percent = -1ULL - v;
1056 } else
1057 td->o.size = v;
1058
1059 return 0;
1060}
1061
Jens Axboe896cac22009-07-01 10:38:35 +02001062static int rw_verify(struct fio_option *o, void *data)
1063{
1064 struct thread_data *td = data;
1065
1066 if (read_only && td_write(td)) {
1067 log_err("fio: job <%s> has write bit set, but fio is in"
1068 " read-only mode\n", td->o.name);
1069 return 1;
1070 }
1071
1072 return 0;
1073}
1074
Jens Axboe276ca4f2009-07-01 10:43:05 +02001075static int gtod_cpu_verify(struct fio_option *o, void *data)
Jens Axboe29d43ff2009-07-01 10:42:18 +02001076{
Jens Axboe276ca4f2009-07-01 10:43:05 +02001077#ifndef FIO_HAVE_CPU_AFFINITY
Jens Axboe29d43ff2009-07-01 10:42:18 +02001078 struct thread_data *td = data;
1079
Jens Axboe29d43ff2009-07-01 10:42:18 +02001080 if (td->o.gtod_cpu) {
1081 log_err("fio: platform must support CPU affinity for"
1082 "gettimeofday() offloading\n");
1083 return 1;
1084 }
1085#endif
1086
1087 return 0;
1088}
1089
Jens Axboe90fef2d2009-07-17 22:33:32 +02001090static int kb_base_verify(struct fio_option *o, void *data)
1091{
1092 struct thread_data *td = data;
1093
1094 if (td->o.kb_base != 1024 && td->o.kb_base != 1000) {
1095 log_err("fio: kb_base set to nonsensical value: %u\n",
1096 td->o.kb_base);
1097 return 1;
1098 }
1099
1100 return 0;
1101}
1102
Steven Noonanad705bc2013-04-08 15:05:25 -07001103static int unit_base_verify(struct fio_option *o, void *data)
1104{
1105 struct thread_data *td = data;
1106
1107 /* 0 = default, pick based on engine
1108 * 1 = use bits
1109 * 8 = use bytes
1110 */
1111 if (td->o.unit_base != 0 &&
1112 td->o.unit_base != 1 &&
1113 td->o.unit_base != 8) {
1114 log_err("fio: unit_base set to nonsensical value: %u\n",
1115 td->o.unit_base);
1116 return 1;
1117 }
1118
1119 return 0;
1120}
1121
Jens Axboe214e1ec2007-03-15 10:48:13 +01001122/*
1123 * Map of job/command line options
1124 */
Jens Axboe07b32322010-03-05 09:48:44 +01001125static struct fio_option options[FIO_MAX_OPTS] = {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001126 {
1127 .name = "description",
1128 .type = FIO_OPT_STR_STORE,
1129 .off1 = td_var_offset(description),
1130 .help = "Text job description",
1131 },
1132 {
1133 .name = "name",
1134 .type = FIO_OPT_STR_STORE,
1135 .off1 = td_var_offset(name),
1136 .help = "Name of this job",
1137 },
1138 {
1139 .name = "directory",
1140 .type = FIO_OPT_STR_STORE,
1141 .off1 = td_var_offset(directory),
1142 .cb = str_directory_cb,
1143 .help = "Directory to store files in",
1144 },
1145 {
1146 .name = "filename",
1147 .type = FIO_OPT_STR_STORE,
1148 .off1 = td_var_offset(filename),
1149 .cb = str_filename_cb,
Jens Axboef0d524b2009-04-27 08:00:48 +02001150 .prio = -1, /* must come after "directory" */
Jens Axboe214e1ec2007-03-15 10:48:13 +01001151 .help = "File(s) to use for the workload",
1152 },
1153 {
Jens Axboede98bd32013-04-05 11:09:20 +02001154 .name = "filename_format",
1155 .type = FIO_OPT_STR_STORE,
1156 .off1 = td_var_offset(filename_format),
1157 .prio = -1, /* must come after "directory" */
1158 .help = "Override default $jobname.$jobnum.$filenum naming",
1159 .def = "$jobname.$jobnum.$filenum",
1160 },
1161 {
Jens Axboe90fef2d2009-07-17 22:33:32 +02001162 .name = "kb_base",
1163 .type = FIO_OPT_INT,
1164 .off1 = td_var_offset(kb_base),
Jens Axboe90fef2d2009-07-17 22:33:32 +02001165 .verify = kb_base_verify,
Jens Axboea639f0b2009-07-18 08:25:35 +02001166 .prio = 1,
Jens Axboe90fef2d2009-07-17 22:33:32 +02001167 .def = "1024",
Jens Axboea639f0b2009-07-18 08:25:35 +02001168 .help = "How many bytes per KB for reporting (1000 or 1024)",
Jens Axboe90fef2d2009-07-17 22:33:32 +02001169 },
1170 {
Steven Noonanad705bc2013-04-08 15:05:25 -07001171 .name = "unit_base",
1172 .type = FIO_OPT_INT,
1173 .off1 = td_var_offset(unit_base),
1174 .verify = unit_base_verify,
1175 .prio = 1,
1176 .def = "0",
1177 .help = "Bit multiple of result summary data (8 for byte, 1 for bit)",
1178 },
1179 {
Jens Axboe29c13492008-03-01 19:25:20 +01001180 .name = "lockfile",
Jens Axboe4d4e80f2008-03-04 10:18:56 +01001181 .type = FIO_OPT_STR,
Jens Axboe4d4e80f2008-03-04 10:18:56 +01001182 .off1 = td_var_offset(file_lock_mode),
Jens Axboe29c13492008-03-01 19:25:20 +01001183 .help = "Lock file when doing IO to it",
1184 .parent = "filename",
Jens Axboe4d4e80f2008-03-04 10:18:56 +01001185 .def = "none",
1186 .posval = {
1187 { .ival = "none",
1188 .oval = FILE_LOCK_NONE,
1189 .help = "No file locking",
1190 },
1191 { .ival = "exclusive",
1192 .oval = FILE_LOCK_EXCLUSIVE,
1193 .help = "Exclusive file lock",
1194 },
1195 {
1196 .ival = "readwrite",
1197 .oval = FILE_LOCK_READWRITE,
1198 .help = "Read vs write lock",
1199 },
1200 },
Jens Axboe29c13492008-03-01 19:25:20 +01001201 },
1202 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001203 .name = "opendir",
1204 .type = FIO_OPT_STR_STORE,
1205 .off1 = td_var_offset(opendir),
1206 .cb = str_opendir_cb,
1207 .help = "Recursively add files from this directory and down",
1208 },
1209 {
1210 .name = "rw",
Jens Axboed3aad8f2007-03-15 14:12:05 +01001211 .alias = "readwrite",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001212 .type = FIO_OPT_STR,
Jens Axboe211097b2007-03-22 18:56:45 +01001213 .cb = str_rw_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001214 .off1 = td_var_offset(td_ddir),
1215 .help = "IO direction",
1216 .def = "read",
Jens Axboe896cac22009-07-01 10:38:35 +02001217 .verify = rw_verify,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001218 .posval = {
1219 { .ival = "read",
1220 .oval = TD_DDIR_READ,
1221 .help = "Sequential read",
1222 },
1223 { .ival = "write",
1224 .oval = TD_DDIR_WRITE,
1225 .help = "Sequential write",
1226 },
Shaohua Li6eaf09d2012-09-14 08:49:43 +02001227 { .ival = "trim",
1228 .oval = TD_DDIR_TRIM,
1229 .help = "Sequential trim",
1230 },
Jens Axboe214e1ec2007-03-15 10:48:13 +01001231 { .ival = "randread",
1232 .oval = TD_DDIR_RANDREAD,
1233 .help = "Random read",
1234 },
1235 { .ival = "randwrite",
1236 .oval = TD_DDIR_RANDWRITE,
1237 .help = "Random write",
1238 },
Shaohua Li6eaf09d2012-09-14 08:49:43 +02001239 { .ival = "randtrim",
1240 .oval = TD_DDIR_RANDTRIM,
1241 .help = "Random trim",
1242 },
Jens Axboe214e1ec2007-03-15 10:48:13 +01001243 { .ival = "rw",
1244 .oval = TD_DDIR_RW,
1245 .help = "Sequential read and write mix",
1246 },
Jens Axboe10b023d2012-03-23 13:40:06 +01001247 { .ival = "readwrite",
1248 .oval = TD_DDIR_RW,
1249 .help = "Sequential read and write mix",
1250 },
Jens Axboe214e1ec2007-03-15 10:48:13 +01001251 { .ival = "randrw",
1252 .oval = TD_DDIR_RANDRW,
1253 .help = "Random read and write mix"
1254 },
1255 },
1256 },
1257 {
Jens Axboe38dad622010-07-20 14:46:00 -06001258 .name = "rw_sequencer",
1259 .type = FIO_OPT_STR,
1260 .off1 = td_var_offset(rw_seq),
1261 .help = "IO offset generator modifier",
1262 .def = "sequential",
1263 .posval = {
1264 { .ival = "sequential",
1265 .oval = RW_SEQ_SEQ,
1266 .help = "Generate sequential offsets",
1267 },
1268 { .ival = "identical",
1269 .oval = RW_SEQ_IDENT,
1270 .help = "Generate identical offsets",
1271 },
1272 },
1273 },
1274
1275 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001276 .name = "ioengine",
1277 .type = FIO_OPT_STR_STORE,
1278 .off1 = td_var_offset(ioengine),
1279 .help = "IO engine to use",
Jens Axboe58483fa2011-01-19 11:09:58 -07001280 .def = FIO_PREFERRED_ENGINE,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001281 .posval = {
1282 { .ival = "sync",
1283 .help = "Use read/write",
1284 },
gurudas paia31041e2007-10-23 15:12:30 +02001285 { .ival = "psync",
1286 .help = "Use pread/pwrite",
1287 },
Jens Axboe1d2af022008-02-04 10:59:07 +01001288 { .ival = "vsync",
Bruce Cran03e20d62011-01-02 20:14:54 +01001289 .help = "Use readv/writev",
Jens Axboe1d2af022008-02-04 10:59:07 +01001290 },
Jens Axboe67bf9822013-01-10 11:23:19 +01001291#ifdef CONFIG_LIBAIO
Jens Axboe214e1ec2007-03-15 10:48:13 +01001292 { .ival = "libaio",
1293 .help = "Linux native asynchronous IO",
1294 },
1295#endif
Jens Axboe67bf9822013-01-10 11:23:19 +01001296#ifdef CONFIG_POSIXAIO
Jens Axboe214e1ec2007-03-15 10:48:13 +01001297 { .ival = "posixaio",
1298 .help = "POSIX asynchronous IO",
1299 },
1300#endif
Jens Axboe997843c2013-01-24 15:27:40 -07001301#ifdef CONFIG_SOLARISAIO
Jens Axboe417f0062008-06-02 11:59:30 +02001302 { .ival = "solarisaio",
1303 .help = "Solaris native asynchronous IO",
1304 },
1305#endif
Jens Axboe4700b232013-01-24 15:33:33 -07001306#ifdef CONFIG_WINDOWSAIO
Bruce Cran03e20d62011-01-02 20:14:54 +01001307 { .ival = "windowsaio",
Jens Axboe3be80072011-01-19 11:07:28 -07001308 .help = "Windows native asynchronous IO"
Steven Langde890a12011-11-09 14:03:34 +01001309 },
Jens Axboe3be80072011-01-19 11:07:28 -07001310#endif
Jens Axboe214e1ec2007-03-15 10:48:13 +01001311 { .ival = "mmap",
Bruce Cran03e20d62011-01-02 20:14:54 +01001312 .help = "Memory mapped IO"
Jens Axboe214e1ec2007-03-15 10:48:13 +01001313 },
Jens Axboe67bf9822013-01-10 11:23:19 +01001314#ifdef CONFIG_LINUX_SPLICE
Jens Axboe214e1ec2007-03-15 10:48:13 +01001315 { .ival = "splice",
1316 .help = "splice/vmsplice based IO",
1317 },
Jens Axboe9cce02e2007-06-22 15:42:21 +02001318 { .ival = "netsplice",
1319 .help = "splice/vmsplice to/from the network",
1320 },
Jens Axboe214e1ec2007-03-15 10:48:13 +01001321#endif
1322#ifdef FIO_HAVE_SGIO
1323 { .ival = "sg",
1324 .help = "SCSI generic v3 IO",
1325 },
1326#endif
1327 { .ival = "null",
1328 .help = "Testing engine (no data transfer)",
1329 },
1330 { .ival = "net",
1331 .help = "Network IO",
1332 },
Jens Axboe214e1ec2007-03-15 10:48:13 +01001333 { .ival = "cpuio",
Bruce Cran03e20d62011-01-02 20:14:54 +01001334 .help = "CPU cycle burner engine",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001335 },
Jens Axboe67bf9822013-01-10 11:23:19 +01001336#ifdef CONFIG_GUASI
Jens Axboeb8c82a42007-03-21 08:48:26 +01001337 { .ival = "guasi",
1338 .help = "GUASI IO engine",
1339 },
1340#endif
Jens Axboe79a43182010-09-07 13:28:58 +02001341#ifdef FIO_HAVE_BINJECT
1342 { .ival = "binject",
1343 .help = "binject direct inject block engine",
1344 },
1345#endif
Jens Axboe67bf9822013-01-10 11:23:19 +01001346#ifdef CONFIG_RDMA
ren yufei21b8aee2011-08-01 10:01:57 +02001347 { .ival = "rdma",
1348 .help = "RDMA IO engine",
1349 },
1350#endif
Jens Axboe67bf9822013-01-10 11:23:19 +01001351#ifdef CONFIG_FUSION_AW
Jens Axboe8200b8c2012-09-18 23:55:43 +02001352 { .ival = "fusion-aw-sync",
1353 .help = "Fusion-io atomic write engine",
1354 },
1355#endif
Jens Axboe997843c2013-01-24 15:27:40 -07001356#ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT
Jens Axboe1ecc95c2012-09-20 13:46:34 +02001357 { .ival = "e4defrag",
1358 .help = "ext4 defrag engine",
1359 },
1360#endif
Jens Axboe997843c2013-01-24 15:27:40 -07001361#ifdef CONFIG_LINUX_FALLOCATE
Jens Axboe1ecc95c2012-09-20 13:46:34 +02001362 { .ival = "falloc",
1363 .help = "fallocate() file based engine",
1364 },
1365#endif
Jens Axboe214e1ec2007-03-15 10:48:13 +01001366 { .ival = "external",
1367 .help = "Load external engine (append name)",
1368 },
1369 },
1370 },
1371 {
1372 .name = "iodepth",
1373 .type = FIO_OPT_INT,
1374 .off1 = td_var_offset(iodepth),
Bruce Cran03e20d62011-01-02 20:14:54 +01001375 .help = "Number of IO buffers to keep in flight",
Jens Axboe757aff42007-12-12 19:42:13 +01001376 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001377 .def = "1",
1378 },
1379 {
1380 .name = "iodepth_batch",
Jens Axboe49504212008-06-05 09:03:30 +02001381 .alias = "iodepth_batch_submit",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001382 .type = FIO_OPT_INT,
1383 .off1 = td_var_offset(iodepth_batch),
Jens Axboed65db442009-01-16 19:15:33 +01001384 .help = "Number of IO buffers to submit in one go",
Jens Axboeafdf9352007-07-31 16:14:34 +02001385 .parent = "iodepth",
Jens Axboea2e6f8a2008-01-18 10:28:11 +01001386 .minval = 1,
1387 .def = "1",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001388 },
1389 {
Jens Axboe49504212008-06-05 09:03:30 +02001390 .name = "iodepth_batch_complete",
1391 .type = FIO_OPT_INT,
1392 .off1 = td_var_offset(iodepth_batch_complete),
Jens Axboed65db442009-01-16 19:15:33 +01001393 .help = "Number of IO buffers to retrieve in one go",
Jens Axboe49504212008-06-05 09:03:30 +02001394 .parent = "iodepth",
1395 .minval = 0,
1396 .def = "1",
1397 },
1398 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001399 .name = "iodepth_low",
1400 .type = FIO_OPT_INT,
1401 .off1 = td_var_offset(iodepth_low),
1402 .help = "Low water mark for queuing depth",
Jens Axboeafdf9352007-07-31 16:14:34 +02001403 .parent = "iodepth",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001404 },
1405 {
1406 .name = "size",
1407 .type = FIO_OPT_STR_VAL,
Jens Axboe7bb59102011-07-12 19:47:03 +02001408 .cb = str_size_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001409 .help = "Total size of device or files",
1410 },
1411 {
Shawn Lewisaa31f1f2008-01-11 09:45:11 +01001412 .name = "fill_device",
Jens Axboe74586c12011-01-20 10:16:03 -07001413 .alias = "fill_fs",
Shawn Lewisaa31f1f2008-01-11 09:45:11 +01001414 .type = FIO_OPT_BOOL,
1415 .off1 = td_var_offset(fill_device),
1416 .help = "Write until an ENOSPC error occurs",
1417 .def = "0",
1418 },
1419 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001420 .name = "filesize",
1421 .type = FIO_OPT_STR_VAL,
1422 .off1 = td_var_offset(file_size_low),
1423 .off2 = td_var_offset(file_size_high),
Jens Axboec3edbdb2007-07-20 14:25:31 +02001424 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001425 .help = "Size of individual files",
1426 },
1427 {
Jens Axboe67a10002007-07-31 23:12:16 +02001428 .name = "offset",
1429 .alias = "fileoffset",
1430 .type = FIO_OPT_STR_VAL,
1431 .off1 = td_var_offset(start_offset),
1432 .help = "Start IO from this offset",
1433 .def = "0",
1434 },
1435 {
Jens Axboe2d7cd862012-03-15 14:53:38 +01001436 .name = "offset_increment",
1437 .type = FIO_OPT_STR_VAL,
1438 .off1 = td_var_offset(offset_increment),
1439 .help = "What is the increment from one offset to the next",
1440 .parent = "offset",
1441 .def = "0",
1442 },
1443 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001444 .name = "bs",
Jens Axboed3aad8f2007-03-15 14:12:05 +01001445 .alias = "blocksize",
Jens Axboee01b22b2009-06-09 15:43:25 +02001446 .type = FIO_OPT_INT,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001447 .off1 = td_var_offset(bs[DDIR_READ]),
1448 .off2 = td_var_offset(bs[DDIR_WRITE]),
Shaohua Li6eaf09d2012-09-14 08:49:43 +02001449 .off3 = td_var_offset(bs[DDIR_TRIM]),
Jens Axboec3edbdb2007-07-20 14:25:31 +02001450 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001451 .help = "Block size unit",
1452 .def = "4k",
Jens Axboe67a10002007-07-31 23:12:16 +02001453 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001454 },
1455 {
Jens Axboe2b7a01d2009-03-11 11:00:13 +01001456 .name = "ba",
1457 .alias = "blockalign",
Jens Axboee01b22b2009-06-09 15:43:25 +02001458 .type = FIO_OPT_INT,
Jens Axboe2b7a01d2009-03-11 11:00:13 +01001459 .off1 = td_var_offset(ba[DDIR_READ]),
1460 .off2 = td_var_offset(ba[DDIR_WRITE]),
Shaohua Li6eaf09d2012-09-14 08:49:43 +02001461 .off3 = td_var_offset(ba[DDIR_TRIM]),
Jens Axboe2b7a01d2009-03-11 11:00:13 +01001462 .minval = 1,
1463 .help = "IO block offset alignment",
1464 .parent = "rw",
1465 },
1466 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001467 .name = "bsrange",
Jens Axboed3aad8f2007-03-15 14:12:05 +01001468 .alias = "blocksize_range",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001469 .type = FIO_OPT_RANGE,
1470 .off1 = td_var_offset(min_bs[DDIR_READ]),
1471 .off2 = td_var_offset(max_bs[DDIR_READ]),
1472 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
1473 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
Shaohua Li6eaf09d2012-09-14 08:49:43 +02001474 .off5 = td_var_offset(min_bs[DDIR_TRIM]),
1475 .off6 = td_var_offset(max_bs[DDIR_TRIM]),
Jens Axboec3edbdb2007-07-20 14:25:31 +02001476 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001477 .help = "Set block size range (in more detail than bs)",
Jens Axboe67a10002007-07-31 23:12:16 +02001478 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001479 },
1480 {
Jens Axboe564ca972007-12-14 12:21:19 +01001481 .name = "bssplit",
1482 .type = FIO_OPT_STR,
1483 .cb = str_bssplit_cb,
1484 .help = "Set a specific mix of block sizes",
1485 .parent = "rw",
1486 },
1487 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001488 .name = "bs_unaligned",
Jens Axboed3aad8f2007-03-15 14:12:05 +01001489 .alias = "blocksize_unaligned",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001490 .type = FIO_OPT_STR_SET,
1491 .off1 = td_var_offset(bs_unaligned),
1492 .help = "Don't sector align IO buffer sizes",
Jens Axboe67a10002007-07-31 23:12:16 +02001493 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001494 },
1495 {
1496 .name = "randrepeat",
1497 .type = FIO_OPT_BOOL,
1498 .off1 = td_var_offset(rand_repeatable),
1499 .help = "Use repeatable random IO pattern",
1500 .def = "1",
Jens Axboe67a10002007-07-31 23:12:16 +02001501 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001502 },
1503 {
Jens Axboe2615cc42011-03-28 09:35:09 +02001504 .name = "use_os_rand",
1505 .type = FIO_OPT_BOOL,
1506 .off1 = td_var_offset(use_os_rand),
1507 .help = "Set to use OS random generator",
1508 .def = "0",
1509 .parent = "rw",
1510 },
1511 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001512 .name = "norandommap",
1513 .type = FIO_OPT_STR_SET,
1514 .off1 = td_var_offset(norandommap),
1515 .help = "Accept potential duplicate random blocks",
Jens Axboe67a10002007-07-31 23:12:16 +02001516 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001517 },
1518 {
Jens Axboe2b386d22008-03-26 10:32:57 +01001519 .name = "softrandommap",
1520 .type = FIO_OPT_BOOL,
1521 .off1 = td_var_offset(softrandommap),
Jens Axboef66ab3c2008-06-05 11:48:22 +02001522 .help = "Set norandommap if randommap allocation fails",
Jens Axboe2b386d22008-03-26 10:32:57 +01001523 .parent = "norandommap",
1524 .def = "0",
1525 },
1526 {
Jens Axboe8055e412012-11-26 08:43:47 +01001527 .name = "random_generator",
1528 .type = FIO_OPT_STR,
1529 .off1 = td_var_offset(random_generator),
1530 .help = "Type of random number generator to use",
1531 .def = "tausworthe",
1532 .posval = {
1533 { .ival = "tausworthe",
1534 .oval = FIO_RAND_GEN_TAUSWORTHE,
1535 .help = "Strong Tausworthe generator",
1536 },
1537 { .ival = "lfsr",
1538 .oval = FIO_RAND_GEN_LFSR,
1539 .help = "Variable length LFSR",
1540 },
1541 },
1542 },
1543 {
Jens Axboee25839d2012-11-06 10:49:42 +01001544 .name = "random_distribution",
1545 .type = FIO_OPT_STR,
1546 .off1 = td_var_offset(random_distribution),
1547 .cb = str_random_distribution_cb,
1548 .help = "Random offset distribution generator",
1549 .def = "random",
1550 .posval = {
1551 { .ival = "random",
1552 .oval = FIO_RAND_DIST_RANDOM,
1553 .help = "Completely random",
1554 },
1555 { .ival = "zipf",
1556 .oval = FIO_RAND_DIST_ZIPF,
1557 .help = "Zipf distribution",
1558 },
Jens Axboe925fee32012-11-06 13:50:32 +01001559 { .ival = "pareto",
1560 .oval = FIO_RAND_DIST_PARETO,
1561 .help = "Pareto distribution",
1562 },
Jens Axboee25839d2012-11-06 10:49:42 +01001563 },
1564 },
1565 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001566 .name = "nrfiles",
Jens Axboed7c8be02010-11-25 08:21:39 +01001567 .alias = "nr_files",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001568 .type = FIO_OPT_INT,
1569 .off1 = td_var_offset(nr_files),
1570 .help = "Split job workload between this number of files",
1571 .def = "1",
1572 },
1573 {
1574 .name = "openfiles",
1575 .type = FIO_OPT_INT,
1576 .off1 = td_var_offset(open_files),
1577 .help = "Number of files to keep open at the same time",
1578 },
1579 {
1580 .name = "file_service_type",
1581 .type = FIO_OPT_STR,
1582 .cb = str_fst_cb,
1583 .off1 = td_var_offset(file_service_type),
1584 .help = "How to select which file to service next",
1585 .def = "roundrobin",
1586 .posval = {
1587 { .ival = "random",
1588 .oval = FIO_FSERVICE_RANDOM,
1589 .help = "Choose a file at random",
1590 },
1591 { .ival = "roundrobin",
1592 .oval = FIO_FSERVICE_RR,
1593 .help = "Round robin select files",
1594 },
Jens Axboea086c252009-03-04 08:27:37 +01001595 { .ival = "sequential",
1596 .oval = FIO_FSERVICE_SEQ,
1597 .help = "Finish one file before moving to the next",
1598 },
Jens Axboe214e1ec2007-03-15 10:48:13 +01001599 },
Jens Axboe67a10002007-07-31 23:12:16 +02001600 .parent = "nrfiles",
1601 },
Jens Axboe97ac9922013-01-24 15:00:25 -07001602#ifdef CONFIG_POSIX_FALLOCATE
Jens Axboe7bc8c2c2010-01-28 11:31:31 +01001603 {
1604 .name = "fallocate",
Eric Gourioua596f042011-06-17 09:11:45 +02001605 .type = FIO_OPT_STR,
1606 .off1 = td_var_offset(fallocate_mode),
1607 .help = "Whether pre-allocation is performed when laying out files",
1608 .def = "posix",
1609 .posval = {
1610 { .ival = "none",
1611 .oval = FIO_FALLOCATE_NONE,
1612 .help = "Do not pre-allocate space",
1613 },
1614 { .ival = "posix",
1615 .oval = FIO_FALLOCATE_POSIX,
1616 .help = "Use posix_fallocate()",
1617 },
Jens Axboe97ac9922013-01-24 15:00:25 -07001618#ifdef CONFIG_LINUX_FALLOCATE
Eric Gourioua596f042011-06-17 09:11:45 +02001619 { .ival = "keep",
1620 .oval = FIO_FALLOCATE_KEEP_SIZE,
1621 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)",
1622 },
Jens Axboe7bc8c2c2010-01-28 11:31:31 +01001623#endif
Eric Gourioua596f042011-06-17 09:11:45 +02001624 /* Compatibility with former boolean values */
1625 { .ival = "0",
1626 .oval = FIO_FALLOCATE_NONE,
1627 .help = "Alias for 'none'",
1628 },
1629 { .ival = "1",
1630 .oval = FIO_FALLOCATE_POSIX,
1631 .help = "Alias for 'posix'",
1632 },
1633 },
1634 },
Jens Axboe97ac9922013-01-24 15:00:25 -07001635#endif /* CONFIG_POSIX_FALLOCATE */
Jens Axboe67a10002007-07-31 23:12:16 +02001636 {
1637 .name = "fadvise_hint",
1638 .type = FIO_OPT_BOOL,
1639 .off1 = td_var_offset(fadvise_hint),
1640 .help = "Use fadvise() to advise the kernel on IO pattern",
1641 .def = "1",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001642 },
1643 {
1644 .name = "fsync",
1645 .type = FIO_OPT_INT,
1646 .off1 = td_var_offset(fsync_blocks),
1647 .help = "Issue fsync for writes every given number of blocks",
1648 .def = "0",
1649 },
1650 {
Jens Axboe5f9099e2009-06-16 22:40:26 +02001651 .name = "fdatasync",
1652 .type = FIO_OPT_INT,
1653 .off1 = td_var_offset(fdatasync_blocks),
1654 .help = "Issue fdatasync for writes every given number of blocks",
1655 .def = "0",
1656 },
Jens Axboe1ef2b6b2010-10-08 15:07:01 +02001657 {
1658 .name = "write_barrier",
1659 .type = FIO_OPT_INT,
1660 .off1 = td_var_offset(barrier_blocks),
1661 .help = "Make every Nth write a barrier write",
1662 .def = "0",
1663 },
Jens Axboe67bf9822013-01-10 11:23:19 +01001664#ifdef CONFIG_SYNC_FILE_RANGE
Jens Axboe44f29692010-03-09 20:09:44 +01001665 {
1666 .name = "sync_file_range",
1667 .posval = {
1668 { .ival = "wait_before",
1669 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
1670 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
Jens Axboe3843deb2010-03-09 20:41:15 +01001671 .or = 1,
Jens Axboe44f29692010-03-09 20:09:44 +01001672 },
1673 { .ival = "write",
1674 .oval = SYNC_FILE_RANGE_WRITE,
1675 .help = "SYNC_FILE_RANGE_WRITE",
Jens Axboe3843deb2010-03-09 20:41:15 +01001676 .or = 1,
Jens Axboe44f29692010-03-09 20:09:44 +01001677 },
1678 {
1679 .ival = "wait_after",
1680 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
1681 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
Jens Axboe3843deb2010-03-09 20:41:15 +01001682 .or = 1,
Jens Axboe44f29692010-03-09 20:09:44 +01001683 },
1684 },
Jens Axboe3843deb2010-03-09 20:41:15 +01001685 .type = FIO_OPT_STR_MULTI,
Jens Axboe44f29692010-03-09 20:09:44 +01001686 .cb = str_sfr_cb,
1687 .off1 = td_var_offset(sync_file_range),
1688 .help = "Use sync_file_range()",
1689 },
1690#endif
Jens Axboe5f9099e2009-06-16 22:40:26 +02001691 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001692 .name = "direct",
1693 .type = FIO_OPT_BOOL,
1694 .off1 = td_var_offset(odirect),
1695 .help = "Use O_DIRECT IO (negates buffered)",
1696 .def = "0",
1697 },
1698 {
1699 .name = "buffered",
1700 .type = FIO_OPT_BOOL,
1701 .off1 = td_var_offset(odirect),
1702 .neg = 1,
1703 .help = "Use buffered IO (negates direct)",
1704 .def = "1",
1705 },
1706 {
1707 .name = "overwrite",
1708 .type = FIO_OPT_BOOL,
1709 .off1 = td_var_offset(overwrite),
1710 .help = "When writing, set whether to overwrite current data",
1711 .def = "0",
1712 },
1713 {
1714 .name = "loops",
1715 .type = FIO_OPT_INT,
1716 .off1 = td_var_offset(loops),
1717 .help = "Number of times to run the job",
1718 .def = "1",
1719 },
1720 {
1721 .name = "numjobs",
1722 .type = FIO_OPT_INT,
1723 .off1 = td_var_offset(numjobs),
1724 .help = "Duplicate this job this many times",
1725 .def = "1",
1726 },
1727 {
1728 .name = "startdelay",
Jens Axboea5737c92010-06-29 10:40:30 +02001729 .type = FIO_OPT_STR_VAL_TIME,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001730 .off1 = td_var_offset(start_delay),
1731 .help = "Only start job when this period has passed",
1732 .def = "0",
1733 },
1734 {
1735 .name = "runtime",
1736 .alias = "timeout",
1737 .type = FIO_OPT_STR_VAL_TIME,
1738 .off1 = td_var_offset(timeout),
1739 .help = "Stop workload when this amount of time has passed",
1740 .def = "0",
1741 },
1742 {
Jens Axboecf4464c2007-04-17 20:14:42 +02001743 .name = "time_based",
1744 .type = FIO_OPT_STR_SET,
1745 .off1 = td_var_offset(time_based),
1746 .help = "Keep running until runtime/timeout is met",
1747 },
1748 {
Jens Axboe721938a2008-09-10 09:46:16 +02001749 .name = "ramp_time",
1750 .type = FIO_OPT_STR_VAL_TIME,
1751 .off1 = td_var_offset(ramp_time),
1752 .help = "Ramp up time before measuring performance",
1753 },
1754 {
Jens Axboec223da82010-03-24 13:23:53 +01001755 .name = "clocksource",
1756 .type = FIO_OPT_STR,
1757 .cb = fio_clock_source_cb,
1758 .off1 = td_var_offset(clocksource),
1759 .help = "What type of timing source to use",
Jens Axboec223da82010-03-24 13:23:53 +01001760 .posval = {
Jens Axboe67bf9822013-01-10 11:23:19 +01001761#ifdef CONFIG_GETTIMEOFDAY
Jens Axboec223da82010-03-24 13:23:53 +01001762 { .ival = "gettimeofday",
1763 .oval = CS_GTOD,
1764 .help = "Use gettimeofday(2) for timing",
1765 },
Jens Axboe67bf9822013-01-10 11:23:19 +01001766#endif
1767#ifdef CONFIG_CLOCK_GETTIME
Jens Axboec223da82010-03-24 13:23:53 +01001768 { .ival = "clock_gettime",
1769 .oval = CS_CGETTIME,
1770 .help = "Use clock_gettime(2) for timing",
1771 },
Jens Axboe67bf9822013-01-10 11:23:19 +01001772#endif
Jens Axboec223da82010-03-24 13:23:53 +01001773#ifdef ARCH_HAVE_CPU_CLOCK
1774 { .ival = "cpu",
1775 .oval = CS_CPUCLOCK,
1776 .help = "Use CPU private clock",
1777 },
1778#endif
1779 },
1780 },
1781 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001782 .name = "mem",
Jens Axboed3aad8f2007-03-15 14:12:05 +01001783 .alias = "iomem",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001784 .type = FIO_OPT_STR,
1785 .cb = str_mem_cb,
1786 .off1 = td_var_offset(mem_type),
1787 .help = "Backing type for IO buffers",
1788 .def = "malloc",
1789 .posval = {
1790 { .ival = "malloc",
1791 .oval = MEM_MALLOC,
1792 .help = "Use malloc(3) for IO buffers",
1793 },
Jens Axboeb370e462007-03-19 10:51:49 +01001794 { .ival = "shm",
1795 .oval = MEM_SHM,
1796 .help = "Use shared memory segments for IO buffers",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001797 },
1798#ifdef FIO_HAVE_HUGETLB
Jens Axboe37c8cdf2007-03-19 13:14:03 +01001799 { .ival = "shmhuge",
1800 .oval = MEM_SHMHUGE,
1801 .help = "Like shm, but use huge pages",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001802 },
1803#endif
Jens Axboeb370e462007-03-19 10:51:49 +01001804 { .ival = "mmap",
1805 .oval = MEM_MMAP,
1806 .help = "Use mmap(2) (file or anon) for IO buffers",
1807 },
Jens Axboe37c8cdf2007-03-19 13:14:03 +01001808#ifdef FIO_HAVE_HUGETLB
1809 { .ival = "mmaphuge",
1810 .oval = MEM_MMAPHUGE,
1811 .help = "Like mmap, but use huge pages",
1812 },
1813#endif
Jens Axboe214e1ec2007-03-15 10:48:13 +01001814 },
1815 },
1816 {
Jens Axboed529ee12009-07-01 10:33:03 +02001817 .name = "iomem_align",
1818 .alias = "mem_align",
1819 .type = FIO_OPT_INT,
1820 .off1 = td_var_offset(mem_align),
1821 .minval = 0,
1822 .help = "IO memory buffer offset alignment",
1823 .def = "0",
1824 .parent = "iomem",
1825 },
1826 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001827 .name = "verify",
1828 .type = FIO_OPT_STR,
1829 .off1 = td_var_offset(verify),
1830 .help = "Verify data written",
Jens Axboe5d7c5d32010-06-21 15:08:17 +02001831 .cb = str_verify_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001832 .def = "0",
1833 .posval = {
1834 { .ival = "0",
1835 .oval = VERIFY_NONE,
1836 .help = "Don't do IO verification",
1837 },
Jens Axboefcca4b52007-07-27 15:42:00 +02001838 { .ival = "md5",
1839 .oval = VERIFY_MD5,
1840 .help = "Use md5 checksums for verification",
1841 },
Jens Axboed77a7af2007-07-27 15:35:06 +02001842 { .ival = "crc64",
1843 .oval = VERIFY_CRC64,
1844 .help = "Use crc64 checksums for verification",
1845 },
Jens Axboe214e1ec2007-03-15 10:48:13 +01001846 { .ival = "crc32",
1847 .oval = VERIFY_CRC32,
1848 .help = "Use crc32 checksums for verification",
1849 },
Jens Axboeaf497e62008-08-04 15:40:35 +02001850 { .ival = "crc32c-intel",
Jens Axboee3aaafc2012-02-22 20:28:17 +01001851 .oval = VERIFY_CRC32C,
1852 .help = "Use crc32c checksums for verification (hw assisted, if available)",
Jens Axboeaf497e62008-08-04 15:40:35 +02001853 },
Jens Axboebac39e02008-06-11 20:46:19 +02001854 { .ival = "crc32c",
1855 .oval = VERIFY_CRC32C,
Jens Axboee3aaafc2012-02-22 20:28:17 +01001856 .help = "Use crc32c checksums for verification (hw assisted, if available)",
Jens Axboebac39e02008-06-11 20:46:19 +02001857 },
Jens Axboe969f7ed2007-07-27 09:07:17 +02001858 { .ival = "crc16",
1859 .oval = VERIFY_CRC16,
1860 .help = "Use crc16 checksums for verification",
1861 },
Jens Axboe1e154bd2007-07-27 09:52:40 +02001862 { .ival = "crc7",
1863 .oval = VERIFY_CRC7,
1864 .help = "Use crc7 checksums for verification",
1865 },
Jens Axboe7c353ce2009-08-09 22:40:33 +02001866 { .ival = "sha1",
1867 .oval = VERIFY_SHA1,
1868 .help = "Use sha1 checksums for verification",
1869 },
Jens Axboecd14cc12007-07-30 10:59:33 +02001870 { .ival = "sha256",
1871 .oval = VERIFY_SHA256,
1872 .help = "Use sha256 checksums for verification",
1873 },
1874 { .ival = "sha512",
1875 .oval = VERIFY_SHA512,
1876 .help = "Use sha512 checksums for verification",
1877 },
Shawn Lewis7437ee82007-08-02 21:05:58 +02001878 { .ival = "meta",
1879 .oval = VERIFY_META,
1880 .help = "Use io information",
1881 },
Jens Axboe36690c92007-03-26 10:23:34 +02001882 {
1883 .ival = "null",
1884 .oval = VERIFY_NULL,
1885 .help = "Pretend to verify",
1886 },
Jens Axboe214e1ec2007-03-15 10:48:13 +01001887 },
1888 },
1889 {
Jens Axboe005c5652007-08-02 22:21:36 +02001890 .name = "do_verify",
Jens Axboe68e1f292007-08-10 10:32:14 +02001891 .type = FIO_OPT_BOOL,
Jens Axboe005c5652007-08-02 22:21:36 +02001892 .off1 = td_var_offset(do_verify),
1893 .help = "Run verification stage after write",
1894 .def = "1",
1895 .parent = "verify",
1896 },
1897 {
Jens Axboe160b9662007-03-27 10:59:49 +02001898 .name = "verifysort",
1899 .type = FIO_OPT_BOOL,
1900 .off1 = td_var_offset(verifysort),
1901 .help = "Sort written verify blocks for read back",
1902 .def = "1",
Jens Axboec83f2df2007-07-31 22:51:47 +02001903 .parent = "verify",
Jens Axboe160b9662007-03-27 10:59:49 +02001904 },
1905 {
Jens Axboe1ae83d42013-01-12 01:44:15 -07001906 .name = "verifysort_nr",
1907 .type = FIO_OPT_INT,
1908 .off1 = td_var_offset(verifysort_nr),
1909 .help = "Pre-load and sort verify blocks for a read workload",
1910 .minval = 0,
1911 .maxval = 131072,
1912 .def = "1024",
1913 .parent = "verify",
1914 },
1915 {
Jens Axboea59e1702007-07-30 08:53:27 +02001916 .name = "verify_interval",
Jens Axboee01b22b2009-06-09 15:43:25 +02001917 .type = FIO_OPT_INT,
Jens Axboea59e1702007-07-30 08:53:27 +02001918 .off1 = td_var_offset(verify_interval),
Jens Axboe819a9682007-07-28 21:30:31 +02001919 .minval = 2 * sizeof(struct verify_header),
Jens Axboea59e1702007-07-30 08:53:27 +02001920 .help = "Store verify buffer header every N bytes",
Jens Axboeafdf9352007-07-31 16:14:34 +02001921 .parent = "verify",
Shawn Lewis3f9f4e22007-07-28 21:10:37 +02001922 },
1923 {
Jens Axboea59e1702007-07-30 08:53:27 +02001924 .name = "verify_offset",
Jens Axboee01b22b2009-06-09 15:43:25 +02001925 .type = FIO_OPT_INT,
Jens Axboea59e1702007-07-30 08:53:27 +02001926 .help = "Offset verify header location by N bytes",
Shawn Lewis546a9142007-07-28 21:11:37 +02001927 .def = "0",
Jens Axboe5ec10ea2008-03-06 15:42:00 +01001928 .cb = str_verify_offset_cb,
Jens Axboeafdf9352007-07-31 16:14:34 +02001929 .parent = "verify",
Shawn Lewis546a9142007-07-28 21:11:37 +02001930 },
1931 {
Shawn Lewise28218f2008-01-16 11:01:33 +01001932 .name = "verify_pattern",
Radha Ramachandran0e92f872009-10-27 20:14:27 +01001933 .type = FIO_OPT_STR,
Shawn Lewise28218f2008-01-16 11:01:33 +01001934 .cb = str_verify_pattern_cb,
1935 .help = "Fill pattern for IO buffers",
1936 .parent = "verify",
1937 },
1938 {
Jens Axboea12a3b42007-08-09 10:20:54 +02001939 .name = "verify_fatal",
Jens Axboe68e1f292007-08-10 10:32:14 +02001940 .type = FIO_OPT_BOOL,
Jens Axboea12a3b42007-08-09 10:20:54 +02001941 .off1 = td_var_offset(verify_fatal),
1942 .def = "0",
1943 .help = "Exit on a single verify failure, don't continue",
1944 .parent = "verify",
1945 },
1946 {
Jens Axboeb463e932011-01-12 09:03:23 +01001947 .name = "verify_dump",
1948 .type = FIO_OPT_BOOL,
1949 .off1 = td_var_offset(verify_dump),
Jens Axboeef71e312011-10-25 22:43:36 +02001950 .def = "0",
Jens Axboeb463e932011-01-12 09:03:23 +01001951 .help = "Dump contents of good and bad blocks on failure",
1952 .parent = "verify",
1953 },
1954 {
Jens Axboee8462bd2009-07-06 12:59:04 +02001955 .name = "verify_async",
1956 .type = FIO_OPT_INT,
1957 .off1 = td_var_offset(verify_async),
1958 .def = "0",
1959 .help = "Number of async verifier threads to use",
1960 .parent = "verify",
1961 },
Jens Axboe9e144182010-06-15 14:25:36 +02001962 {
1963 .name = "verify_backlog",
1964 .type = FIO_OPT_STR_VAL,
1965 .off1 = td_var_offset(verify_backlog),
1966 .help = "Verify after this number of blocks are written",
1967 .parent = "verify",
1968 },
1969 {
1970 .name = "verify_backlog_batch",
1971 .type = FIO_OPT_INT,
1972 .off1 = td_var_offset(verify_batch),
1973 .help = "Verify this number of IO blocks",
Jens Axboe0d29de82010-09-01 13:54:15 +02001974 .parent = "verify",
Jens Axboe9e144182010-06-15 14:25:36 +02001975 },
Jens Axboee8462bd2009-07-06 12:59:04 +02001976#ifdef FIO_HAVE_CPU_AFFINITY
1977 {
1978 .name = "verify_async_cpus",
1979 .type = FIO_OPT_STR,
1980 .cb = str_verify_cpus_allowed_cb,
1981 .help = "Set CPUs allowed for async verify threads",
1982 .parent = "verify_async",
1983 },
1984#endif
Jens Axboe51aa2da2013-01-21 10:55:02 -07001985 {
1986 .name = "experimental_verify",
1987 .off1 = td_var_offset(experimental_verify),
1988 .type = FIO_OPT_BOOL,
Jens Axboeb31eaac2013-01-24 15:29:58 -07001989 .help = "Enable experimental verification",
Jens Axboe51aa2da2013-01-21 10:55:02 -07001990 },
Jens Axboe0d29de82010-09-01 13:54:15 +02001991#ifdef FIO_HAVE_TRIM
1992 {
1993 .name = "trim_percentage",
1994 .type = FIO_OPT_INT,
1995 .cb = str_verify_trim_cb,
1996 .maxval = 100,
1997 .help = "Number of verify blocks to discard/trim",
1998 .parent = "verify",
1999 .def = "0",
2000 },
2001 {
2002 .name = "trim_verify_zero",
2003 .type = FIO_OPT_INT,
2004 .help = "Verify that trim/discarded blocks are returned as zeroes",
2005 .off1 = td_var_offset(trim_zero),
2006 .parent = "trim_percentage",
2007 .def = "1",
2008 },
2009 {
2010 .name = "trim_backlog",
2011 .type = FIO_OPT_STR_VAL,
2012 .off1 = td_var_offset(trim_backlog),
2013 .help = "Trim after this number of blocks are written",
2014 .parent = "trim_percentage",
2015 },
2016 {
2017 .name = "trim_backlog_batch",
2018 .type = FIO_OPT_INT,
2019 .off1 = td_var_offset(trim_batch),
2020 .help = "Trim this number of IO blocks",
2021 .parent = "trim_percentage",
2022 },
2023#endif
Jens Axboee8462bd2009-07-06 12:59:04 +02002024 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01002025 .name = "write_iolog",
2026 .type = FIO_OPT_STR_STORE,
2027 .off1 = td_var_offset(write_iolog_file),
2028 .help = "Store IO pattern to file",
2029 },
2030 {
2031 .name = "read_iolog",
2032 .type = FIO_OPT_STR_STORE,
2033 .off1 = td_var_offset(read_iolog_file),
2034 .help = "Playback IO pattern from file",
2035 },
2036 {
David Nellans64bbb862010-08-24 22:13:30 +02002037 .name = "replay_no_stall",
2038 .type = FIO_OPT_INT,
2039 .off1 = td_var_offset(no_stall),
2040 .def = "0",
Jens Axboe87e7a972010-08-25 09:01:25 +02002041 .parent = "read_iolog",
David Nellans64bbb862010-08-24 22:13:30 +02002042 .help = "Playback IO pattern file as fast as possible without stalls",
2043 },
2044 {
David Nellansd1c46c02010-08-31 21:20:47 +02002045 .name = "replay_redirect",
2046 .type = FIO_OPT_STR_STORE,
2047 .off1 = td_var_offset(replay_redirect),
2048 .parent = "read_iolog",
2049 .help = "Replay all I/O onto this device, regardless of trace device",
2050 },
2051 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01002052 .name = "exec_prerun",
2053 .type = FIO_OPT_STR_STORE,
2054 .off1 = td_var_offset(exec_prerun),
2055 .help = "Execute this file prior to running job",
2056 },
2057 {
2058 .name = "exec_postrun",
2059 .type = FIO_OPT_STR_STORE,
2060 .off1 = td_var_offset(exec_postrun),
2061 .help = "Execute this file after running job",
2062 },
2063#ifdef FIO_HAVE_IOSCHED_SWITCH
2064 {
2065 .name = "ioscheduler",
2066 .type = FIO_OPT_STR_STORE,
2067 .off1 = td_var_offset(ioscheduler),
2068 .help = "Use this IO scheduler on the backing device",
2069 },
2070#endif
2071 {
2072 .name = "zonesize",
2073 .type = FIO_OPT_STR_VAL,
2074 .off1 = td_var_offset(zone_size),
Steven Noonaned335852012-01-31 13:58:00 +01002075 .help = "Amount of data to read per zone",
2076 .def = "0",
2077 },
2078 {
2079 .name = "zonerange",
2080 .type = FIO_OPT_STR_VAL,
2081 .off1 = td_var_offset(zone_range),
Jens Axboe214e1ec2007-03-15 10:48:13 +01002082 .help = "Give size of an IO zone",
2083 .def = "0",
2084 },
2085 {
2086 .name = "zoneskip",
2087 .type = FIO_OPT_STR_VAL,
2088 .off1 = td_var_offset(zone_skip),
2089 .help = "Space between IO zones",
2090 .def = "0",
2091 },
2092 {
2093 .name = "lockmem",
2094 .type = FIO_OPT_STR_VAL,
2095 .cb = str_lockmem_cb,
2096 .help = "Lock down this amount of memory",
2097 .def = "0",
2098 },
2099 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01002100 .name = "rwmixread",
2101 .type = FIO_OPT_INT,
Jens Axboecb499fc2008-05-28 10:33:32 +02002102 .cb = str_rwmix_read_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01002103 .maxval = 100,
2104 .help = "Percentage of mixed workload that is reads",
2105 .def = "50",
2106 },
2107 {
2108 .name = "rwmixwrite",
2109 .type = FIO_OPT_INT,
Jens Axboecb499fc2008-05-28 10:33:32 +02002110 .cb = str_rwmix_write_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01002111 .maxval = 100,
2112 .help = "Percentage of mixed workload that is writes",
2113 .def = "50",
2114 },
2115 {
Jens Axboeafdf9352007-07-31 16:14:34 +02002116 .name = "rwmixcycle",
Jens Axboe15ca1502008-04-07 09:26:02 +02002117 .type = FIO_OPT_DEPRECATED,
Jens Axboeafdf9352007-07-31 16:14:34 +02002118 },
2119 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01002120 .name = "nice",
2121 .type = FIO_OPT_INT,
2122 .off1 = td_var_offset(nice),
2123 .help = "Set job CPU nice value",
2124 .minval = -19,
2125 .maxval = 20,
2126 .def = "0",
2127 },
2128#ifdef FIO_HAVE_IOPRIO
2129 {
2130 .name = "prio",
2131 .type = FIO_OPT_INT,
2132 .cb = str_prio_cb,
2133 .help = "Set job IO priority value",
2134 .minval = 0,
2135 .maxval = 7,
2136 },
2137 {
2138 .name = "prioclass",
2139 .type = FIO_OPT_INT,
2140 .cb = str_prioclass_cb,
2141 .help = "Set job IO priority class",
2142 .minval = 0,
2143 .maxval = 3,
2144 },
2145#endif
2146 {
2147 .name = "thinktime",
2148 .type = FIO_OPT_INT,
2149 .off1 = td_var_offset(thinktime),
2150 .help = "Idle time between IO buffers (usec)",
2151 .def = "0",
2152 },
2153 {
2154 .name = "thinktime_spin",
2155 .type = FIO_OPT_INT,
2156 .off1 = td_var_offset(thinktime_spin),
2157 .help = "Start think time by spinning this amount (usec)",
2158 .def = "0",
Jens Axboeafdf9352007-07-31 16:14:34 +02002159 .parent = "thinktime",
Jens Axboe214e1ec2007-03-15 10:48:13 +01002160 },
2161 {
2162 .name = "thinktime_blocks",
2163 .type = FIO_OPT_INT,
2164 .off1 = td_var_offset(thinktime_blocks),
2165 .help = "IO buffer period between 'thinktime'",
2166 .def = "1",
Jens Axboeafdf9352007-07-31 16:14:34 +02002167 .parent = "thinktime",
Jens Axboe214e1ec2007-03-15 10:48:13 +01002168 },
2169 {
2170 .name = "rate",
Jens Axboee01b22b2009-06-09 15:43:25 +02002171 .type = FIO_OPT_INT,
Shaohua Li6eaf09d2012-09-14 08:49:43 +02002172 .off1 = td_var_offset(rate[DDIR_READ]),
2173 .off2 = td_var_offset(rate[DDIR_WRITE]),
2174 .off3 = td_var_offset(rate[DDIR_TRIM]),
Jens Axboe214e1ec2007-03-15 10:48:13 +01002175 .help = "Set bandwidth rate",
2176 },
2177 {
2178 .name = "ratemin",
Jens Axboee01b22b2009-06-09 15:43:25 +02002179 .type = FIO_OPT_INT,
Shaohua Li6eaf09d2012-09-14 08:49:43 +02002180 .off1 = td_var_offset(ratemin[DDIR_READ]),
2181 .off2 = td_var_offset(ratemin[DDIR_WRITE]),
2182 .off3 = td_var_offset(ratemin[DDIR_TRIM]),
Jens Axboe4e991c22007-03-15 11:41:11 +01002183 .help = "Job must meet this rate or it will be shutdown",
Jens Axboeafdf9352007-07-31 16:14:34 +02002184 .parent = "rate",
Jens Axboe4e991c22007-03-15 11:41:11 +01002185 },
2186 {
2187 .name = "rate_iops",
Jens Axboee01b22b2009-06-09 15:43:25 +02002188 .type = FIO_OPT_INT,
Shaohua Li6eaf09d2012-09-14 08:49:43 +02002189 .off1 = td_var_offset(rate_iops[DDIR_READ]),
2190 .off2 = td_var_offset(rate_iops[DDIR_WRITE]),
2191 .off3 = td_var_offset(rate_iops[DDIR_TRIM]),
Jens Axboe4e991c22007-03-15 11:41:11 +01002192 .help = "Limit IO used to this number of IO operations/sec",
2193 },
2194 {
2195 .name = "rate_iops_min",
Jens Axboee01b22b2009-06-09 15:43:25 +02002196 .type = FIO_OPT_INT,
Shaohua Li6eaf09d2012-09-14 08:49:43 +02002197 .off1 = td_var_offset(rate_iops_min[DDIR_READ]),
2198 .off2 = td_var_offset(rate_iops_min[DDIR_WRITE]),
2199 .off3 = td_var_offset(rate_iops_min[DDIR_TRIM]),
Bruce Cran03e20d62011-01-02 20:14:54 +01002200 .help = "Job must meet this rate or it will be shut down",
Jens Axboeafdf9352007-07-31 16:14:34 +02002201 .parent = "rate_iops",
Jens Axboe214e1ec2007-03-15 10:48:13 +01002202 },
2203 {
2204 .name = "ratecycle",
2205 .type = FIO_OPT_INT,
2206 .off1 = td_var_offset(ratecycle),
2207 .help = "Window average for rate limits (msec)",
2208 .def = "1000",
Jens Axboeafdf9352007-07-31 16:14:34 +02002209 .parent = "rate",
Jens Axboe214e1ec2007-03-15 10:48:13 +01002210 },
2211 {
Jens Axboe15501532012-10-24 16:37:45 +02002212 .name = "max_latency",
2213 .type = FIO_OPT_INT,
2214 .off1 = td_var_offset(max_latency),
2215 .help = "Maximum tolerated IO latency (usec)",
2216 },
2217 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01002218 .name = "invalidate",
2219 .type = FIO_OPT_BOOL,
2220 .off1 = td_var_offset(invalidate_cache),
2221 .help = "Invalidate buffer/page cache prior to running job",
2222 .def = "1",
2223 },
2224 {
2225 .name = "sync",
2226 .type = FIO_OPT_BOOL,
2227 .off1 = td_var_offset(sync_io),
2228 .help = "Use O_SYNC for buffered writes",
2229 .def = "0",
Jens Axboe67a10002007-07-31 23:12:16 +02002230 .parent = "buffered",
Jens Axboe214e1ec2007-03-15 10:48:13 +01002231 },
2232 {
2233 .name = "bwavgtime",
2234 .type = FIO_OPT_INT,
2235 .off1 = td_var_offset(bw_avg_time),
Jens Axboe5ec10ea2008-03-06 15:42:00 +01002236 .help = "Time window over which to calculate bandwidth"
2237 " (msec)",
Jens Axboe214e1ec2007-03-15 10:48:13 +01002238 .def = "500",
Jens Axboec8eeb9d2011-10-05 14:02:22 +02002239 .parent = "write_bw_log",
2240 },
2241 {
2242 .name = "iopsavgtime",
2243 .type = FIO_OPT_INT,
2244 .off1 = td_var_offset(iops_avg_time),
2245 .help = "Time window over which to calculate IOPS (msec)",
2246 .def = "500",
2247 .parent = "write_iops_log",
Jens Axboe214e1ec2007-03-15 10:48:13 +01002248 },
2249 {
2250 .name = "create_serialize",
2251 .type = FIO_OPT_BOOL,
2252 .off1 = td_var_offset(create_serialize),
2253 .help = "Serialize creating of job files",
2254 .def = "1",
2255 },
2256 {
2257 .name = "create_fsync",
2258 .type = FIO_OPT_BOOL,
2259 .off1 = td_var_offset(create_fsync),
Bruce Cran03e20d62011-01-02 20:14:54 +01002260 .help = "fsync file after creation",
Jens Axboe214e1ec2007-03-15 10:48:13 +01002261 .def = "1",
2262 },
2263 {
Jens Axboe814452b2009-03-04 12:53:13 +01002264 .name = "create_on_open",
2265 .type = FIO_OPT_BOOL,
2266 .off1 = td_var_offset(create_on_open),
2267 .help = "Create files when they are opened for IO",
2268 .def = "0",
2269 },
Jens Axboe0b9d69e2009-09-11 22:29:54 +02002270 {
Jens Axboe25460cf2012-05-02 13:58:02 +02002271 .name = "create_only",
2272 .type = FIO_OPT_BOOL,
2273 .off1 = td_var_offset(create_only),
2274 .help = "Only perform file creation phase",
2275 .def = "0",
2276 },
2277 {
Zhang, Yanminafad68f2009-05-20 11:30:55 +02002278 .name = "pre_read",
2279 .type = FIO_OPT_BOOL,
2280 .off1 = td_var_offset(pre_read),
Bruce Cran03e20d62011-01-02 20:14:54 +01002281 .help = "Pre-read files before starting official testing",
Zhang, Yanminafad68f2009-05-20 11:30:55 +02002282 .def = "0",
2283 },
Jens Axboe814452b2009-03-04 12:53:13 +01002284 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01002285 .name = "cpuload",
2286 .type = FIO_OPT_INT,
2287 .off1 = td_var_offset(cpuload),
2288 .help = "Use this percentage of CPU",
2289 },
2290 {
2291 .name = "cpuchunks",
2292 .type = FIO_OPT_INT,
2293 .off1 = td_var_offset(cpucycle),
2294 .help = "Length of the CPU burn cycles (usecs)",
2295 .def = "50000",
Jens Axboe67a10002007-07-31 23:12:16 +02002296 .parent = "cpuload",
Jens Axboe214e1ec2007-03-15 10:48:13 +01002297 },
2298#ifdef FIO_HAVE_CPU_AFFINITY
2299 {
2300 .name = "cpumask",
2301 .type = FIO_OPT_INT,
2302 .cb = str_cpumask_cb,
2303 .help = "CPU affinity mask",
2304 },
Jens Axboed2e268b2007-06-15 10:33:49 +02002305 {
2306 .name = "cpus_allowed",
2307 .type = FIO_OPT_STR,
2308 .cb = str_cpus_allowed_cb,
2309 .help = "Set CPUs allowed",
2310 },
Jens Axboe214e1ec2007-03-15 10:48:13 +01002311#endif
Jens Axboe67bf9822013-01-10 11:23:19 +01002312#ifdef CONFIG_LIBNUMA
Yufei Rend0b937e2012-10-19 23:11:52 -04002313 {
2314 .name = "numa_cpu_nodes",
2315 .type = FIO_OPT_STR,
2316 .cb = str_numa_cpunodes_cb,
2317 .help = "NUMA CPU nodes bind",
2318 },
2319 {
2320 .name = "numa_mem_policy",
2321 .type = FIO_OPT_STR,
2322 .cb = str_numa_mpol_cb,
2323 .help = "NUMA memory policy setup",
2324 },
2325#endif
Jens Axboe214e1ec2007-03-15 10:48:13 +01002326 {
2327 .name = "end_fsync",
2328 .type = FIO_OPT_BOOL,
2329 .off1 = td_var_offset(end_fsync),
2330 .help = "Include fsync at the end of job",
2331 .def = "0",
2332 },
2333 {
2334 .name = "fsync_on_close",
2335 .type = FIO_OPT_BOOL,
2336 .off1 = td_var_offset(fsync_on_close),
2337 .help = "fsync files on close",
2338 .def = "0",
2339 },
2340 {
2341 .name = "unlink",
2342 .type = FIO_OPT_BOOL,
2343 .off1 = td_var_offset(unlink),
2344 .help = "Unlink created files after job has completed",
2345 .def = "0",
2346 },
2347 {
2348 .name = "exitall",
2349 .type = FIO_OPT_STR_SET,
2350 .cb = str_exitall_cb,
2351 .help = "Terminate all jobs when one exits",
2352 },
2353 {
2354 .name = "stonewall",
Jens Axboed3923652011-08-03 12:38:39 +02002355 .alias = "wait_for_previous",
Jens Axboe214e1ec2007-03-15 10:48:13 +01002356 .type = FIO_OPT_STR_SET,
2357 .off1 = td_var_offset(stonewall),
2358 .help = "Insert a hard barrier between this job and previous",
2359 },
2360 {
Jens Axboeb3d62a72007-03-20 14:23:26 +01002361 .name = "new_group",
2362 .type = FIO_OPT_STR_SET,
2363 .off1 = td_var_offset(new_group),
2364 .help = "Mark the start of a new group (for reporting)",
2365 },
2366 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01002367 .name = "thread",
2368 .type = FIO_OPT_STR_SET,
2369 .off1 = td_var_offset(use_thread),
2370 .help = "Use threads instead of forks",
2371 },
2372 {
2373 .name = "write_bw_log",
Jens Axboee3cedca2008-11-19 19:57:52 +01002374 .type = FIO_OPT_STR,
Jens Axboe214e1ec2007-03-15 10:48:13 +01002375 .off1 = td_var_offset(write_bw_log),
Jens Axboee3cedca2008-11-19 19:57:52 +01002376 .cb = str_write_bw_log_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01002377 .help = "Write log of bandwidth during run",
2378 },
2379 {
2380 .name = "write_lat_log",
Jens Axboee3cedca2008-11-19 19:57:52 +01002381 .type = FIO_OPT_STR,
Jens Axboe214e1ec2007-03-15 10:48:13 +01002382 .off1 = td_var_offset(write_lat_log),
Jens Axboee3cedca2008-11-19 19:57:52 +01002383 .cb = str_write_lat_log_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01002384 .help = "Write log of latency during run",
2385 },
2386 {
Jens Axboec8eeb9d2011-10-05 14:02:22 +02002387 .name = "write_iops_log",
2388 .type = FIO_OPT_STR,
2389 .off1 = td_var_offset(write_iops_log),
2390 .cb = str_write_iops_log_cb,
2391 .help = "Write log of IOPS during run",
2392 },
2393 {
Jens Axboeb8bc8cb2011-12-01 09:04:31 +01002394 .name = "log_avg_msec",
2395 .type = FIO_OPT_INT,
2396 .off1 = td_var_offset(log_avg_msec),
2397 .help = "Average bw/iops/lat logs over this period of time",
2398 .def = "0",
2399 },
2400 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01002401 .name = "hugepage-size",
Jens Axboee01b22b2009-06-09 15:43:25 +02002402 .type = FIO_OPT_INT,
Jens Axboe214e1ec2007-03-15 10:48:13 +01002403 .off1 = td_var_offset(hugepage_size),
2404 .help = "When using hugepages, specify size of each page",
Jens Axboe81179ee2011-10-04 12:42:06 +02002405 .def = __fio_stringify(FIO_HUGE_PAGE),
Jens Axboe214e1ec2007-03-15 10:48:13 +01002406 },
2407 {
2408 .name = "group_reporting",
2409 .type = FIO_OPT_STR_SET,
2410 .off1 = td_var_offset(group_reporting),
2411 .help = "Do reporting on a per-group basis",
2412 },
2413 {
Jens Axboee9459e52007-04-17 15:46:32 +02002414 .name = "zero_buffers",
2415 .type = FIO_OPT_STR_SET,
2416 .off1 = td_var_offset(zero_buffers),
2417 .help = "Init IO buffers to all zeroes",
2418 },
Jens Axboe5973caf2008-05-21 19:52:35 +02002419 {
2420 .name = "refill_buffers",
2421 .type = FIO_OPT_STR_SET,
2422 .off1 = td_var_offset(refill_buffers),
2423 .help = "Refill IO buffers on every IO submit",
2424 },
Yu-ju Hong83349192011-08-13 00:53:44 +02002425 {
Jens Axboefd684182011-09-19 09:24:44 +02002426 .name = "scramble_buffers",
2427 .type = FIO_OPT_BOOL,
2428 .off1 = td_var_offset(scramble_buffers),
2429 .help = "Slightly scramble buffers on every IO submit",
2430 .def = "1",
2431 },
2432 {
Jens Axboe9c426842012-03-02 21:02:12 +01002433 .name = "buffer_compress_percentage",
2434 .type = FIO_OPT_INT,
2435 .off1 = td_var_offset(compress_percentage),
2436 .maxval = 100,
2437 .minval = 1,
2438 .help = "How compressible the buffer is (approximately)",
2439 },
2440 {
Jens Axboef97a43a2012-03-09 19:06:24 +01002441 .name = "buffer_compress_chunk",
2442 .type = FIO_OPT_INT,
2443 .off1 = td_var_offset(compress_chunk),
Jens Axboe207b18e2012-03-09 19:11:25 +01002444 .parent = "buffer_compress_percentage",
Jens Axboef97a43a2012-03-09 19:06:24 +01002445 .help = "Size of compressible region in buffer",
2446 },
2447 {
Yu-ju Hong83349192011-08-13 00:53:44 +02002448 .name = "clat_percentiles",
2449 .type = FIO_OPT_BOOL,
2450 .off1 = td_var_offset(clat_percentiles),
2451 .help = "Enable the reporting of completion latency percentiles",
Jens Axboe467b35e2011-10-13 08:53:24 +02002452 .def = "1",
Yu-ju Hong83349192011-08-13 00:53:44 +02002453 },
2454 {
2455 .name = "percentile_list",
2456 .type = FIO_OPT_FLOAT_LIST,
2457 .off1 = td_var_offset(percentile_list),
Vincent Kang Fu435d1952013-02-06 08:43:40 +01002458 .off2 = td_var_offset(percentile_precision),
Yu-ju Hong83349192011-08-13 00:53:44 +02002459 .help = "Specify a custom list of percentiles to report",
Vincent Kang Fufd112d32013-02-02 09:28:55 +01002460 .def = "1:5:10:20:30:40:50:60:70:80:90:95:99:99.5:99.9:99.95:99.99",
Yu-ju Hong83349192011-08-13 00:53:44 +02002461 .maxlen = FIO_IO_U_LIST_MAX_LEN,
2462 .minfp = 0.0,
2463 .maxfp = 100.0,
2464 },
2465
Jens Axboe0a839f32007-04-26 09:02:34 +02002466#ifdef FIO_HAVE_DISK_UTIL
2467 {
2468 .name = "disk_util",
2469 .type = FIO_OPT_BOOL,
2470 .off1 = td_var_offset(do_disk_util),
Jens Axboef66ab3c2008-06-05 11:48:22 +02002471 .help = "Log disk utilization statistics",
Jens Axboe0a839f32007-04-26 09:02:34 +02002472 .def = "1",
2473 },
2474#endif
Jens Axboee9459e52007-04-17 15:46:32 +02002475 {
Jens Axboe993bf482008-11-14 13:04:53 +01002476 .name = "gtod_reduce",
2477 .type = FIO_OPT_BOOL,
2478 .help = "Greatly reduce number of gettimeofday() calls",
2479 .cb = str_gtod_reduce_cb,
2480 .def = "0",
2481 },
2482 {
Jens Axboe02af0982010-06-24 09:59:34 +02002483 .name = "disable_lat",
2484 .type = FIO_OPT_BOOL,
2485 .off1 = td_var_offset(disable_lat),
2486 .help = "Disable latency numbers",
2487 .parent = "gtod_reduce",
2488 .def = "0",
2489 },
2490 {
Jens Axboe9520ebb2008-10-16 21:03:27 +02002491 .name = "disable_clat",
2492 .type = FIO_OPT_BOOL,
2493 .off1 = td_var_offset(disable_clat),
2494 .help = "Disable completion latency numbers",
Jens Axboe993bf482008-11-14 13:04:53 +01002495 .parent = "gtod_reduce",
Jens Axboe9520ebb2008-10-16 21:03:27 +02002496 .def = "0",
2497 },
2498 {
2499 .name = "disable_slat",
2500 .type = FIO_OPT_BOOL,
2501 .off1 = td_var_offset(disable_slat),
Bruce Cran03e20d62011-01-02 20:14:54 +01002502 .help = "Disable submission latency numbers",
Jens Axboe993bf482008-11-14 13:04:53 +01002503 .parent = "gtod_reduce",
Jens Axboe9520ebb2008-10-16 21:03:27 +02002504 .def = "0",
2505 },
2506 {
2507 .name = "disable_bw_measurement",
2508 .type = FIO_OPT_BOOL,
2509 .off1 = td_var_offset(disable_bw),
2510 .help = "Disable bandwidth logging",
Jens Axboe993bf482008-11-14 13:04:53 +01002511 .parent = "gtod_reduce",
Jens Axboe9520ebb2008-10-16 21:03:27 +02002512 .def = "0",
2513 },
2514 {
Jens Axboebe4ecfd2008-12-08 14:10:52 +01002515 .name = "gtod_cpu",
2516 .type = FIO_OPT_INT,
2517 .cb = str_gtod_cpu_cb,
Bruce Cran03e20d62011-01-02 20:14:54 +01002518 .help = "Set up dedicated gettimeofday() thread on this CPU",
Jens Axboe29d43ff2009-07-01 10:42:18 +02002519 .verify = gtod_cpu_verify,
Jens Axboebe4ecfd2008-12-08 14:10:52 +01002520 },
2521 {
Jens Axboe771e58b2013-01-30 12:56:23 +01002522 .name = "unified_rw_reporting",
2523 .type = FIO_OPT_BOOL,
2524 .off1 = td_var_offset(unified_rw_rep),
2525 .help = "Unify reporting across data direction",
2526 .def = "0",
2527 },
2528 {
Radha Ramachandranf2bba182009-06-15 08:40:16 +02002529 .name = "continue_on_error",
Steven Lang06842022011-11-17 09:45:17 +01002530 .type = FIO_OPT_STR,
Radha Ramachandranf2bba182009-06-15 08:40:16 +02002531 .off1 = td_var_offset(continue_on_error),
Bruce Cran03e20d62011-01-02 20:14:54 +01002532 .help = "Continue on non-fatal errors during IO",
Steven Lang06842022011-11-17 09:45:17 +01002533 .def = "none",
2534 .posval = {
2535 { .ival = "none",
2536 .oval = ERROR_TYPE_NONE,
2537 .help = "Exit when an error is encountered",
2538 },
2539 { .ival = "read",
2540 .oval = ERROR_TYPE_READ,
2541 .help = "Continue on read errors only",
2542 },
2543 { .ival = "write",
2544 .oval = ERROR_TYPE_WRITE,
2545 .help = "Continue on write errors only",
2546 },
2547 { .ival = "io",
2548 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE,
2549 .help = "Continue on any IO errors",
2550 },
2551 { .ival = "verify",
2552 .oval = ERROR_TYPE_VERIFY,
2553 .help = "Continue on verify errors only",
2554 },
2555 { .ival = "all",
2556 .oval = ERROR_TYPE_ANY,
2557 .help = "Continue on all io and verify errors",
2558 },
2559 { .ival = "0",
2560 .oval = ERROR_TYPE_NONE,
2561 .help = "Alias for 'none'",
2562 },
2563 { .ival = "1",
2564 .oval = ERROR_TYPE_ANY,
2565 .help = "Alias for 'all'",
2566 },
2567 },
Radha Ramachandranf2bba182009-06-15 08:40:16 +02002568 },
2569 {
Dmitry Monakhov8b28bd42012-09-23 15:46:09 +04002570 .name = "ignore_error",
2571 .type = FIO_OPT_STR,
2572 .cb = str_ignore_error_cb,
2573 .help = "Set a specific list of errors to ignore",
2574 .parent = "rw",
2575 },
2576 {
2577 .name = "error_dump",
2578 .type = FIO_OPT_BOOL,
2579 .off1 = td_var_offset(error_dump),
2580 .def = "0",
2581 .help = "Dump info on each error",
2582 },
2583
2584 {
Jens Axboe9ac8a792009-11-13 21:23:07 +01002585 .name = "profile",
Jens Axboe79d16312010-03-04 12:43:20 +01002586 .type = FIO_OPT_STR_STORE,
Jens Axboe9ac8a792009-11-13 21:23:07 +01002587 .off1 = td_var_offset(profile),
Jens Axboe9ac8a792009-11-13 21:23:07 +01002588 .help = "Select a specific builtin performance test",
2589 },
2590 {
Jens Axboea696fa22009-12-04 10:05:02 +01002591 .name = "cgroup",
2592 .type = FIO_OPT_STR_STORE,
2593 .off1 = td_var_offset(cgroup),
2594 .help = "Add job to cgroup of this name",
2595 },
2596 {
2597 .name = "cgroup_weight",
2598 .type = FIO_OPT_INT,
2599 .off1 = td_var_offset(cgroup_weight),
2600 .help = "Use given weight for cgroup",
2601 .minval = 100,
2602 .maxval = 1000,
Jens Axboea696fa22009-12-04 10:05:02 +01002603 },
2604 {
Vivek Goyal7de87092010-03-31 22:55:15 +02002605 .name = "cgroup_nodelete",
2606 .type = FIO_OPT_BOOL,
2607 .off1 = td_var_offset(cgroup_nodelete),
2608 .help = "Do not delete cgroups after job completion",
2609 .def = "0",
2610 },
2611 {
Jens Axboee0b0d892009-12-08 10:10:14 +01002612 .name = "uid",
2613 .type = FIO_OPT_INT,
2614 .off1 = td_var_offset(uid),
2615 .help = "Run job with this user ID",
2616 },
2617 {
2618 .name = "gid",
2619 .type = FIO_OPT_INT,
2620 .off1 = td_var_offset(gid),
2621 .help = "Run job with this group ID",
2622 },
2623 {
Dan Ehrenberg9e684a42012-02-20 11:05:14 +01002624 .name = "flow_id",
2625 .type = FIO_OPT_INT,
2626 .off1 = td_var_offset(flow_id),
2627 .help = "The flow index ID to use",
2628 .def = "0",
2629 },
2630 {
2631 .name = "flow",
2632 .type = FIO_OPT_INT,
2633 .off1 = td_var_offset(flow),
2634 .help = "Weight for flow control of this job",
2635 .parent = "flow_id",
2636 .def = "0",
2637 },
2638 {
2639 .name = "flow_watermark",
2640 .type = FIO_OPT_INT,
2641 .off1 = td_var_offset(flow_watermark),
2642 .help = "High watermark for flow control. This option"
2643 " should be set to the same value for all threads"
2644 " with non-zero flow.",
2645 .parent = "flow_id",
2646 .def = "1024",
2647 },
2648 {
2649 .name = "flow_sleep",
2650 .type = FIO_OPT_INT,
2651 .off1 = td_var_offset(flow_sleep),
2652 .help = "How many microseconds to sleep after being held"
2653 " back by the flow control mechanism",
2654 .parent = "flow_id",
2655 .def = "0",
2656 },
2657 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01002658 .name = NULL,
2659 },
2660};
2661
Jens Axboe17af15d2010-04-13 10:38:16 +02002662static void add_to_lopt(struct option *lopt, struct fio_option *o,
Steven Langde890a12011-11-09 14:03:34 +01002663 const char *name, int val)
Jens Axboe9f817362010-03-04 14:38:10 +01002664{
Jens Axboe17af15d2010-04-13 10:38:16 +02002665 lopt->name = (char *) name;
Steven Langde890a12011-11-09 14:03:34 +01002666 lopt->val = val;
Jens Axboe9f817362010-03-04 14:38:10 +01002667 if (o->type == FIO_OPT_STR_SET)
2668 lopt->has_arg = no_argument;
2669 else
2670 lopt->has_arg = required_argument;
2671}
2672
Steven Langde890a12011-11-09 14:03:34 +01002673static void options_to_lopts(struct fio_option *opts,
2674 struct option *long_options,
2675 int i, int option_type)
2676{
2677 struct fio_option *o = &opts[0];
2678 while (o->name) {
2679 add_to_lopt(&long_options[i], o, o->name, option_type);
2680 if (o->alias) {
2681 i++;
2682 add_to_lopt(&long_options[i], o, o->alias, option_type);
2683 }
2684
2685 i++;
2686 o++;
2687 assert(i < FIO_NR_OPTIONS);
2688 }
2689}
2690
2691void fio_options_set_ioengine_opts(struct option *long_options,
2692 struct thread_data *td)
2693{
2694 unsigned int i;
2695
2696 i = 0;
2697 while (long_options[i].name) {
2698 if (long_options[i].val == FIO_GETOPT_IOENGINE) {
2699 memset(&long_options[i], 0, sizeof(*long_options));
2700 break;
2701 }
2702 i++;
2703 }
2704
2705 /*
2706 * Just clear out the prior ioengine options.
2707 */
2708 if (!td || !td->eo)
2709 return;
2710
2711 options_to_lopts(td->io_ops->options, long_options, i,
2712 FIO_GETOPT_IOENGINE);
2713}
2714
Jens Axboe214e1ec2007-03-15 10:48:13 +01002715void fio_options_dup_and_init(struct option *long_options)
2716{
Jens Axboe214e1ec2007-03-15 10:48:13 +01002717 unsigned int i;
2718
2719 options_init(options);
2720
2721 i = 0;
2722 while (long_options[i].name)
2723 i++;
2724
Steven Langde890a12011-11-09 14:03:34 +01002725 options_to_lopts(options, long_options, i, FIO_GETOPT_JOB);
Jens Axboe214e1ec2007-03-15 10:48:13 +01002726}
2727
Jens Axboe74929ac2009-08-05 11:42:37 +02002728struct fio_keyword {
2729 const char *word;
2730 const char *desc;
2731 char *replace;
2732};
2733
2734static struct fio_keyword fio_keywords[] = {
2735 {
2736 .word = "$pagesize",
2737 .desc = "Page size in the system",
2738 },
2739 {
2740 .word = "$mb_memory",
2741 .desc = "Megabytes of memory online",
2742 },
2743 {
2744 .word = "$ncpus",
2745 .desc = "Number of CPUs online in the system",
2746 },
2747 {
2748 .word = NULL,
2749 },
2750};
2751
2752void fio_keywords_init(void)
2753{
Jens Axboe3b2e1462009-12-15 08:58:10 +01002754 unsigned long long mb_memory;
Jens Axboe74929ac2009-08-05 11:42:37 +02002755 char buf[128];
2756 long l;
2757
Jens Axboea4cfc472012-10-09 10:30:48 -06002758 sprintf(buf, "%lu", (unsigned long) page_size);
Jens Axboe74929ac2009-08-05 11:42:37 +02002759 fio_keywords[0].replace = strdup(buf);
2760
Jens Axboe8eb016d2011-07-11 10:24:20 +02002761 mb_memory = os_phys_mem() / (1024 * 1024);
Jens Axboe3b2e1462009-12-15 08:58:10 +01002762 sprintf(buf, "%llu", mb_memory);
Jens Axboe74929ac2009-08-05 11:42:37 +02002763 fio_keywords[1].replace = strdup(buf);
2764
Jens Axboec00a2282011-07-08 20:56:06 +02002765 l = cpus_online();
Jens Axboe74929ac2009-08-05 11:42:37 +02002766 sprintf(buf, "%lu", l);
2767 fio_keywords[2].replace = strdup(buf);
2768}
2769
Jens Axboe892a6ff2009-11-13 12:19:49 +01002770#define BC_APP "bc"
2771
2772static char *bc_calc(char *str)
2773{
Steven Langd0c814e2011-10-28 08:37:13 +02002774 char buf[128], *tmp;
Jens Axboe892a6ff2009-11-13 12:19:49 +01002775 FILE *f;
2776 int ret;
2777
2778 /*
2779 * No math, just return string
2780 */
Steven Langd0c814e2011-10-28 08:37:13 +02002781 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
2782 !strchr(str, '/')) || strchr(str, '\''))
Jens Axboe892a6ff2009-11-13 12:19:49 +01002783 return str;
2784
2785 /*
2786 * Split option from value, we only need to calculate the value
2787 */
2788 tmp = strchr(str, '=');
2789 if (!tmp)
2790 return str;
2791
2792 tmp++;
Jens Axboe892a6ff2009-11-13 12:19:49 +01002793
Steven Langd0c814e2011-10-28 08:37:13 +02002794 /*
2795 * Prevent buffer overflows; such a case isn't reasonable anyway
2796 */
2797 if (strlen(str) >= 128 || strlen(tmp) > 100)
2798 return str;
Jens Axboe892a6ff2009-11-13 12:19:49 +01002799
2800 sprintf(buf, "which %s > /dev/null", BC_APP);
2801 if (system(buf)) {
2802 log_err("fio: bc is needed for performing math\n");
Jens Axboe892a6ff2009-11-13 12:19:49 +01002803 return NULL;
2804 }
2805
Steven Langd0c814e2011-10-28 08:37:13 +02002806 sprintf(buf, "echo '%s' | %s", tmp, BC_APP);
Jens Axboe892a6ff2009-11-13 12:19:49 +01002807 f = popen(buf, "r");
2808 if (!f) {
Jens Axboe892a6ff2009-11-13 12:19:49 +01002809 return NULL;
2810 }
2811
Steven Langd0c814e2011-10-28 08:37:13 +02002812 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f);
Jens Axboe892a6ff2009-11-13 12:19:49 +01002813 if (ret <= 0) {
Jens Axboe892a6ff2009-11-13 12:19:49 +01002814 return NULL;
2815 }
2816
Jens Axboe892a6ff2009-11-13 12:19:49 +01002817 pclose(f);
Steven Langd0c814e2011-10-28 08:37:13 +02002818 buf[(tmp - str) + ret - 1] = '\0';
2819 memcpy(buf, str, tmp - str);
Jens Axboe892a6ff2009-11-13 12:19:49 +01002820 free(str);
Steven Langd0c814e2011-10-28 08:37:13 +02002821 return strdup(buf);
2822}
2823
2824/*
2825 * Return a copy of the input string with substrings of the form ${VARNAME}
2826 * substituted with the value of the environment variable VARNAME. The
2827 * substitution always occurs, even if VARNAME is empty or the corresponding
2828 * environment variable undefined.
2829 */
2830static char *option_dup_subs(const char *opt)
2831{
2832 char out[OPT_LEN_MAX+1];
2833 char in[OPT_LEN_MAX+1];
2834 char *outptr = out;
2835 char *inptr = in;
2836 char *ch1, *ch2, *env;
2837 ssize_t nchr = OPT_LEN_MAX;
2838 size_t envlen;
2839
2840 if (strlen(opt) + 1 > OPT_LEN_MAX) {
2841 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX);
2842 return NULL;
2843 }
2844
2845 in[OPT_LEN_MAX] = '\0';
2846 strncpy(in, opt, OPT_LEN_MAX);
2847
2848 while (*inptr && nchr > 0) {
2849 if (inptr[0] == '$' && inptr[1] == '{') {
2850 ch2 = strchr(inptr, '}');
2851 if (ch2 && inptr+1 < ch2) {
2852 ch1 = inptr+2;
2853 inptr = ch2+1;
2854 *ch2 = '\0';
2855
2856 env = getenv(ch1);
2857 if (env) {
2858 envlen = strlen(env);
2859 if (envlen <= nchr) {
2860 memcpy(outptr, env, envlen);
2861 outptr += envlen;
2862 nchr -= envlen;
2863 }
2864 }
2865
2866 continue;
2867 }
2868 }
2869
2870 *outptr++ = *inptr++;
2871 --nchr;
2872 }
2873
2874 *outptr = '\0';
2875 return strdup(out);
Jens Axboe892a6ff2009-11-13 12:19:49 +01002876}
2877
Jens Axboe74929ac2009-08-05 11:42:37 +02002878/*
2879 * Look for reserved variable names and replace them with real values
2880 */
2881static char *fio_keyword_replace(char *opt)
2882{
2883 char *s;
2884 int i;
Steven Langd0c814e2011-10-28 08:37:13 +02002885 int docalc = 0;
Jens Axboe74929ac2009-08-05 11:42:37 +02002886
2887 for (i = 0; fio_keywords[i].word != NULL; i++) {
2888 struct fio_keyword *kw = &fio_keywords[i];
2889
2890 while ((s = strstr(opt, kw->word)) != NULL) {
2891 char *new = malloc(strlen(opt) + 1);
2892 char *o_org = opt;
2893 int olen = s - opt;
2894 int len;
2895
2896 /*
2897 * Copy part of the string before the keyword and
2898 * sprintf() the replacement after it.
2899 */
2900 memcpy(new, opt, olen);
2901 len = sprintf(new + olen, "%s", kw->replace);
2902
2903 /*
2904 * If there's more in the original string, copy that
2905 * in too
2906 */
2907 opt += strlen(kw->word) + olen;
2908 if (strlen(opt))
2909 memcpy(new + olen + len, opt, opt - o_org - 1);
2910
2911 /*
2912 * replace opt and free the old opt
2913 */
2914 opt = new;
Steven Langd0c814e2011-10-28 08:37:13 +02002915 free(o_org);
Jens Axboe7a958bd2009-11-13 12:33:54 +01002916
Steven Langd0c814e2011-10-28 08:37:13 +02002917 docalc = 1;
Jens Axboe74929ac2009-08-05 11:42:37 +02002918 }
2919 }
2920
Steven Langd0c814e2011-10-28 08:37:13 +02002921 /*
2922 * Check for potential math and invoke bc, if possible
2923 */
2924 if (docalc)
2925 opt = bc_calc(opt);
2926
Jens Axboe7a958bd2009-11-13 12:33:54 +01002927 return opt;
Jens Axboe74929ac2009-08-05 11:42:37 +02002928}
2929
Steven Langd0c814e2011-10-28 08:37:13 +02002930static char **dup_and_sub_options(char **opts, int num_opts)
2931{
2932 int i;
2933 char **opts_copy = malloc(num_opts * sizeof(*opts));
2934 for (i = 0; i < num_opts; i++) {
2935 opts_copy[i] = option_dup_subs(opts[i]);
2936 if (!opts_copy[i])
2937 continue;
2938 opts_copy[i] = fio_keyword_replace(opts_copy[i]);
2939 }
2940 return opts_copy;
2941}
2942
Jens Axboe3b8b7132008-06-10 19:46:23 +02002943int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
Jens Axboe214e1ec2007-03-15 10:48:13 +01002944{
Steven Langde890a12011-11-09 14:03:34 +01002945 int i, ret, unknown;
Steven Langd0c814e2011-10-28 08:37:13 +02002946 char **opts_copy;
Jens Axboe3b8b7132008-06-10 19:46:23 +02002947
2948 sort_options(opts, options, num_opts);
Steven Langd0c814e2011-10-28 08:37:13 +02002949 opts_copy = dup_and_sub_options(opts, num_opts);
Jens Axboe3b8b7132008-06-10 19:46:23 +02002950
Steven Langde890a12011-11-09 14:03:34 +01002951 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) {
2952 struct fio_option *o;
2953 int newret = parse_option(opts_copy[i], opts[i], options, &o,
2954 td);
Steven Langd0c814e2011-10-28 08:37:13 +02002955
Steven Langde890a12011-11-09 14:03:34 +01002956 if (opts_copy[i]) {
2957 if (newret && !o) {
2958 unknown++;
2959 continue;
2960 }
Steven Langd0c814e2011-10-28 08:37:13 +02002961 free(opts_copy[i]);
Steven Langde890a12011-11-09 14:03:34 +01002962 opts_copy[i] = NULL;
2963 }
2964
2965 ret |= newret;
2966 }
2967
2968 if (unknown) {
2969 ret |= ioengine_load(td);
2970 if (td->eo) {
2971 sort_options(opts_copy, td->io_ops->options, num_opts);
2972 opts = opts_copy;
2973 }
2974 for (i = 0; i < num_opts; i++) {
2975 struct fio_option *o = NULL;
2976 int newret = 1;
2977 if (!opts_copy[i])
2978 continue;
2979
2980 if (td->eo)
2981 newret = parse_option(opts_copy[i], opts[i],
2982 td->io_ops->options, &o,
2983 td->eo);
2984
2985 ret |= newret;
2986 if (!o)
2987 log_err("Bad option <%s>\n", opts[i]);
2988
2989 free(opts_copy[i]);
2990 opts_copy[i] = NULL;
2991 }
Jens Axboe74929ac2009-08-05 11:42:37 +02002992 }
Jens Axboe3b8b7132008-06-10 19:46:23 +02002993
Steven Langd0c814e2011-10-28 08:37:13 +02002994 free(opts_copy);
Jens Axboe3b8b7132008-06-10 19:46:23 +02002995 return ret;
Jens Axboe214e1ec2007-03-15 10:48:13 +01002996}
2997
2998int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
2999{
Jens Axboe07b32322010-03-05 09:48:44 +01003000 return parse_cmd_option(opt, val, options, td);
Jens Axboe214e1ec2007-03-15 10:48:13 +01003001}
3002
Steven Langde890a12011-11-09 14:03:34 +01003003int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt,
3004 char *val)
3005{
3006 return parse_cmd_option(opt, val, td->io_ops->options, td);
3007}
3008
Jens Axboe214e1ec2007-03-15 10:48:13 +01003009void fio_fill_default_options(struct thread_data *td)
3010{
3011 fill_default_options(td, options);
3012}
3013
3014int fio_show_option_help(const char *opt)
3015{
Jens Axboe07b32322010-03-05 09:48:44 +01003016 return show_cmd_help(options, opt);
Jens Axboe214e1ec2007-03-15 10:48:13 +01003017}
Jens Axboed23bb322007-03-23 15:57:56 +01003018
Steven Langde890a12011-11-09 14:03:34 +01003019void options_mem_dupe(void *data, struct fio_option *options)
3020{
3021 struct fio_option *o;
3022 char **ptr;
3023
3024 for (o = &options[0]; o->name; o++) {
3025 if (o->type != FIO_OPT_STR_STORE)
3026 continue;
3027
3028 ptr = td_var(data, o->off1);
3029 if (*ptr)
3030 *ptr = strdup(*ptr);
3031 }
3032}
3033
Jens Axboe7e356b22011-10-14 10:55:16 +02003034/*
3035 * dupe FIO_OPT_STR_STORE options
3036 */
Steven Langde890a12011-11-09 14:03:34 +01003037void fio_options_mem_dupe(struct thread_data *td)
Jens Axboed23bb322007-03-23 15:57:56 +01003038{
Steven Langde890a12011-11-09 14:03:34 +01003039 options_mem_dupe(&td->o, options);
Jens Axboe1647f592011-11-09 20:25:21 +01003040
3041 if (td->eo && td->io_ops) {
Steven Langde890a12011-11-09 14:03:34 +01003042 void *oldeo = td->eo;
Jens Axboe1647f592011-11-09 20:25:21 +01003043
Steven Langde890a12011-11-09 14:03:34 +01003044 td->eo = malloc(td->io_ops->option_struct_size);
3045 memcpy(td->eo, oldeo, td->io_ops->option_struct_size);
3046 options_mem_dupe(td->eo, td->io_ops->options);
Jens Axboed23bb322007-03-23 15:57:56 +01003047 }
3048}
3049
Jens Axboed6978a32009-07-18 21:04:09 +02003050unsigned int fio_get_kb_base(void *data)
3051{
3052 struct thread_data *td = data;
3053 unsigned int kb_base = 0;
3054
3055 if (td)
3056 kb_base = td->o.kb_base;
3057 if (!kb_base)
3058 kb_base = 1024;
3059
3060 return kb_base;
3061}
Jens Axboe9f988e22010-03-04 10:42:38 +01003062
Jens Axboe07b32322010-03-05 09:48:44 +01003063int add_option(struct fio_option *o)
Jens Axboe9f988e22010-03-04 10:42:38 +01003064{
Jens Axboe07b32322010-03-05 09:48:44 +01003065 struct fio_option *__o;
3066 int opt_index = 0;
3067
3068 __o = options;
3069 while (__o->name) {
3070 opt_index++;
3071 __o++;
3072 }
3073
3074 memcpy(&options[opt_index], o, sizeof(*o));
3075 return 0;
Jens Axboe9f988e22010-03-04 10:42:38 +01003076}
Jens Axboee2de69d2010-03-04 14:05:48 +01003077
Jens Axboe07b32322010-03-05 09:48:44 +01003078void invalidate_profile_options(const char *prof_name)
Jens Axboee2de69d2010-03-04 14:05:48 +01003079{
Jens Axboe07b32322010-03-05 09:48:44 +01003080 struct fio_option *o;
Jens Axboee2de69d2010-03-04 14:05:48 +01003081
Jens Axboe07b32322010-03-05 09:48:44 +01003082 o = options;
3083 while (o->name) {
3084 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
3085 o->type = FIO_OPT_INVALID;
3086 o->prof_name = NULL;
3087 }
3088 o++;
Jens Axboee2de69d2010-03-04 14:05:48 +01003089 }
3090}
Jens Axboef5b6bb82010-03-05 10:09:59 +01003091
3092void add_opt_posval(const char *optname, const char *ival, const char *help)
3093{
3094 struct fio_option *o;
3095 unsigned int i;
3096
3097 o = find_option(options, optname);
3098 if (!o)
3099 return;
3100
3101 for (i = 0; i < PARSE_MAX_VP; i++) {
3102 if (o->posval[i].ival)
3103 continue;
3104
3105 o->posval[i].ival = ival;
3106 o->posval[i].help = help;
3107 break;
3108 }
3109}
3110
3111void del_opt_posval(const char *optname, const char *ival)
3112{
3113 struct fio_option *o;
3114 unsigned int i;
3115
3116 o = find_option(options, optname);
3117 if (!o)
3118 return;
3119
3120 for (i = 0; i < PARSE_MAX_VP; i++) {
3121 if (!o->posval[i].ival)
3122 continue;
3123 if (strcmp(o->posval[i].ival, ival))
3124 continue;
3125
3126 o->posval[i].ival = NULL;
3127 o->posval[i].help = NULL;
3128 }
3129}
Jens Axboe7e356b22011-10-14 10:55:16 +02003130
3131void fio_options_free(struct thread_data *td)
3132{
3133 options_free(options, td);
Steven Langde890a12011-11-09 14:03:34 +01003134 if (td->eo && td->io_ops && td->io_ops->options) {
3135 options_free(td->io_ops->options, td->eo);
3136 free(td->eo);
3137 td->eo = NULL;
3138 }
Jens Axboe7e356b22011-10-14 10:55:16 +02003139}