blob: bdf358204197b7ad1ed40bf6c2a749c2403c229c [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
Kenneth Watersdf9cf922009-10-15 07:08:48 +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;
169 char *str, *p, *odir;
170 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) {
179 ret = bssplit_ddir(td, DDIR_WRITE, odir + 1);
180 if (!ret) {
181 *odir = '\0';
182 ret = bssplit_ddir(td, DDIR_READ, str);
183 }
184 } else {
185 char *op;
186
187 op = strdup(str);
188
189 ret = bssplit_ddir(td, DDIR_READ, str);
190 if (!ret)
191 ret = bssplit_ddir(td, DDIR_WRITE, op);
192
193 free(op);
194 }
Jens Axboe564ca972007-12-14 12:21:19 +0100195
196 free(p);
Jens Axboe720e84a2009-04-21 08:29:55 +0200197 return ret;
Jens Axboe564ca972007-12-14 12:21:19 +0100198}
199
Jens Axboe211097b2007-03-22 18:56:45 +0100200static int str_rw_cb(void *data, const char *str)
201{
202 struct thread_data *td = data;
203 char *nr = get_opt_postfix(str);
204
Jens Axboe5736c102010-07-20 12:03:25 -0600205 td->o.ddir_seq_nr = 1;
Jens Axboe182ec6e2008-11-14 13:06:06 +0100206 if (nr) {
Jens Axboe5736c102010-07-20 12:03:25 -0600207 td->o.ddir_seq_nr = atoi(nr);
Jens Axboe182ec6e2008-11-14 13:06:06 +0100208 free(nr);
209 }
Jens Axboe211097b2007-03-22 18:56:45 +0100210
Jens Axboe211097b2007-03-22 18:56:45 +0100211 return 0;
212}
213
Jens Axboe214e1ec2007-03-15 10:48:13 +0100214static int str_mem_cb(void *data, const char *mem)
215{
216 struct thread_data *td = data;
217
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100218 if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP) {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100219 td->mmapfile = get_opt_postfix(mem);
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100220 if (td->o.mem_type == MEM_MMAPHUGE && !td->mmapfile) {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100221 log_err("fio: mmaphuge:/path/to/file\n");
222 return 1;
223 }
224 }
225
226 return 0;
227}
228
Jens Axboe5d7c5d32010-06-21 15:08:17 +0200229static int str_verify_cb(void *data, const char *mem)
230{
231 struct thread_data *td = data;
232
233 if (td->o.verify != VERIFY_CRC32C_INTEL)
234 return 0;
235
236 if (!crc32c_intel_works()) {
237 log_info("fio: System does not support hw accelerated crc32c. Falling back to sw crc32c.\n");
238 td->o.verify = VERIFY_CRC32C;
239 }
240
241 return 0;
242}
243
Jens Axboec223da82010-03-24 13:23:53 +0100244static int fio_clock_source_cb(void *data, const char *str)
245{
246 struct thread_data *td = data;
247
248 fio_clock_source = td->o.clocksource;
249 fio_time_init();
250 return 0;
251}
252
Cigy Cyriac85bc8332010-08-10 19:21:09 -0400253static int str_lockmem_cb(void fio_unused *data, unsigned long long *val)
Jens Axboe214e1ec2007-03-15 10:48:13 +0100254{
255 mlock_size = *val;
256 return 0;
257}
258
Cigy Cyriac85bc8332010-08-10 19:21:09 -0400259static int str_rwmix_read_cb(void *data, unsigned long long *val)
Jens Axboecb499fc2008-05-28 10:33:32 +0200260{
261 struct thread_data *td = data;
262
263 td->o.rwmix[DDIR_READ] = *val;
264 td->o.rwmix[DDIR_WRITE] = 100 - *val;
265 return 0;
266}
267
Cigy Cyriac85bc8332010-08-10 19:21:09 -0400268static int str_rwmix_write_cb(void *data, unsigned long long *val)
Jens Axboecb499fc2008-05-28 10:33:32 +0200269{
270 struct thread_data *td = data;
271
272 td->o.rwmix[DDIR_WRITE] = *val;
273 td->o.rwmix[DDIR_READ] = 100 - *val;
274 return 0;
275}
276
Jens Axboe214e1ec2007-03-15 10:48:13 +0100277#ifdef FIO_HAVE_IOPRIO
Cigy Cyriac85bc8332010-08-10 19:21:09 -0400278static int str_prioclass_cb(void *data, unsigned long long *val)
Jens Axboe214e1ec2007-03-15 10:48:13 +0100279{
280 struct thread_data *td = data;
Jens Axboe6cefbe32007-04-18 12:46:56 +0200281 unsigned short mask;
282
283 /*
284 * mask off old class bits, str_prio_cb() may have set a default class
285 */
286 mask = (1 << IOPRIO_CLASS_SHIFT) - 1;
287 td->ioprio &= mask;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100288
289 td->ioprio |= *val << IOPRIO_CLASS_SHIFT;
Jens Axboeac684782007-11-08 08:29:07 +0100290 td->ioprio_set = 1;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100291 return 0;
292}
293
Cigy Cyriac85bc8332010-08-10 19:21:09 -0400294static int str_prio_cb(void *data, unsigned long long *val)
Jens Axboe214e1ec2007-03-15 10:48:13 +0100295{
296 struct thread_data *td = data;
297
298 td->ioprio |= *val;
Jens Axboe6cefbe32007-04-18 12:46:56 +0200299
300 /*
301 * If no class is set, assume BE
302 */
303 if ((td->ioprio >> IOPRIO_CLASS_SHIFT) == 0)
304 td->ioprio |= IOPRIO_CLASS_BE << IOPRIO_CLASS_SHIFT;
305
Jens Axboeac684782007-11-08 08:29:07 +0100306 td->ioprio_set = 1;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100307 return 0;
308}
309#endif
310
311static int str_exitall_cb(void)
312{
313 exitall_on_terminate = 1;
314 return 0;
315}
316
Jens Axboe214e1ec2007-03-15 10:48:13 +0100317#ifdef FIO_HAVE_CPU_AFFINITY
Cigy Cyriac85bc8332010-08-10 19:21:09 -0400318static int str_cpumask_cb(void *data, unsigned long long *val)
Jens Axboe214e1ec2007-03-15 10:48:13 +0100319{
320 struct thread_data *td = data;
Jens Axboed2e268b2007-06-15 10:33:49 +0200321 unsigned int i;
Jens Axboeb03daaf2008-12-08 20:31:43 +0100322 long max_cpu;
Jens Axboed2ce18b2008-12-12 20:51:40 +0100323 int ret;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100324
Jens Axboed2ce18b2008-12-12 20:51:40 +0100325 ret = fio_cpuset_init(&td->o.cpumask);
326 if (ret < 0) {
327 log_err("fio: cpuset_init failed\n");
328 td_verror(td, ret, "fio_cpuset_init");
329 return 1;
330 }
331
Jens Axboeb03daaf2008-12-08 20:31:43 +0100332 max_cpu = sysconf(_SC_NPROCESSORS_ONLN);
Jens Axboed2e268b2007-06-15 10:33:49 +0200333
Jens Axboe62a72732008-12-08 11:37:01 +0100334 for (i = 0; i < sizeof(int) * 8; i++) {
335 if ((1 << i) & *val) {
Jens Axboeb03daaf2008-12-08 20:31:43 +0100336 if (i > max_cpu) {
337 log_err("fio: CPU %d too large (max=%ld)\n", i,
338 max_cpu);
339 return 1;
340 }
Jens Axboe62a72732008-12-08 11:37:01 +0100341 dprint(FD_PARSE, "set cpu allowed %d\n", i);
Jens Axboe6d459ee2008-12-12 20:02:58 +0100342 fio_cpu_set(&td->o.cpumask, i);
Jens Axboe62a72732008-12-08 11:37:01 +0100343 }
344 }
Jens Axboed2e268b2007-06-15 10:33:49 +0200345
Jens Axboe375b2692007-05-22 09:13:02 +0200346 td->o.cpumask_set = 1;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100347 return 0;
348}
349
Jens Axboee8462bd2009-07-06 12:59:04 +0200350static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask,
351 const char *input)
Jens Axboed2e268b2007-06-15 10:33:49 +0200352{
Jens Axboed2e268b2007-06-15 10:33:49 +0200353 char *cpu, *str, *p;
Jens Axboeb03daaf2008-12-08 20:31:43 +0100354 long max_cpu;
Jens Axboe19608d62008-12-08 15:03:12 +0100355 int ret = 0;
Jens Axboed2e268b2007-06-15 10:33:49 +0200356
Jens Axboee8462bd2009-07-06 12:59:04 +0200357 ret = fio_cpuset_init(mask);
Jens Axboed2ce18b2008-12-12 20:51:40 +0100358 if (ret < 0) {
359 log_err("fio: cpuset_init failed\n");
360 td_verror(td, ret, "fio_cpuset_init");
361 return 1;
362 }
Jens Axboed2e268b2007-06-15 10:33:49 +0200363
364 p = str = strdup(input);
365
366 strip_blank_front(&str);
367 strip_blank_end(str);
368
Jens Axboeb03daaf2008-12-08 20:31:43 +0100369 max_cpu = sysconf(_SC_NPROCESSORS_ONLN);
370
Jens Axboed2e268b2007-06-15 10:33:49 +0200371 while ((cpu = strsep(&str, ",")) != NULL) {
Jens Axboe62a72732008-12-08 11:37:01 +0100372 char *str2, *cpu2;
373 int icpu, icpu2;
374
Jens Axboed2e268b2007-06-15 10:33:49 +0200375 if (!strlen(cpu))
376 break;
Jens Axboe62a72732008-12-08 11:37:01 +0100377
378 str2 = cpu;
379 icpu2 = -1;
380 while ((cpu2 = strsep(&str2, "-")) != NULL) {
381 if (!strlen(cpu2))
382 break;
383
384 icpu2 = atoi(cpu2);
385 }
386
387 icpu = atoi(cpu);
388 if (icpu2 == -1)
389 icpu2 = icpu;
390 while (icpu <= icpu2) {
Jens Axboe6d459ee2008-12-12 20:02:58 +0100391 if (icpu >= FIO_MAX_CPUS) {
Jens Axboe19608d62008-12-08 15:03:12 +0100392 log_err("fio: your OS only supports up to"
Jens Axboe6d459ee2008-12-12 20:02:58 +0100393 " %d CPUs\n", (int) FIO_MAX_CPUS);
Jens Axboe19608d62008-12-08 15:03:12 +0100394 ret = 1;
395 break;
396 }
Jens Axboeb03daaf2008-12-08 20:31:43 +0100397 if (icpu > max_cpu) {
398 log_err("fio: CPU %d too large (max=%ld)\n",
399 icpu, max_cpu);
400 ret = 1;
401 break;
402 }
Jens Axboe0b9d69e2009-09-11 22:29:54 +0200403
Jens Axboe62a72732008-12-08 11:37:01 +0100404 dprint(FD_PARSE, "set cpu allowed %d\n", icpu);
Jens Axboee8462bd2009-07-06 12:59:04 +0200405 fio_cpu_set(mask, icpu);
Jens Axboe62a72732008-12-08 11:37:01 +0100406 icpu++;
407 }
Jens Axboe19608d62008-12-08 15:03:12 +0100408 if (ret)
409 break;
Jens Axboed2e268b2007-06-15 10:33:49 +0200410 }
411
412 free(p);
Jens Axboe19608d62008-12-08 15:03:12 +0100413 if (!ret)
414 td->o.cpumask_set = 1;
415 return ret;
Jens Axboed2e268b2007-06-15 10:33:49 +0200416}
Jens Axboee8462bd2009-07-06 12:59:04 +0200417
418static int str_cpus_allowed_cb(void *data, const char *input)
419{
420 struct thread_data *td = data;
421 int ret;
422
423 ret = set_cpus_allowed(td, &td->o.cpumask, input);
424 if (!ret)
425 td->o.cpumask_set = 1;
426
427 return ret;
428}
429
430static int str_verify_cpus_allowed_cb(void *data, const char *input)
431{
432 struct thread_data *td = data;
433 int ret;
434
435 ret = set_cpus_allowed(td, &td->o.verify_cpumask, input);
436 if (!ret)
437 td->o.verify_cpumask_set = 1;
438
439 return ret;
440}
Jens Axboed2e268b2007-06-15 10:33:49 +0200441#endif
442
Jens Axboe0d29de82010-09-01 13:54:15 +0200443#ifdef FIO_HAVE_TRIM
444static int str_verify_trim_cb(void *data, unsigned long long *val)
445{
446 struct thread_data *td = data;
447
448 td->o.trim_percentage = *val;
449 return 0;
450}
451#endif
452
Jens Axboe214e1ec2007-03-15 10:48:13 +0100453static int str_fst_cb(void *data, const char *str)
454{
455 struct thread_data *td = data;
456 char *nr = get_opt_postfix(str);
457
458 td->file_service_nr = 1;
Jens Axboe182ec6e2008-11-14 13:06:06 +0100459 if (nr) {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100460 td->file_service_nr = atoi(nr);
Jens Axboe182ec6e2008-11-14 13:06:06 +0100461 free(nr);
462 }
Jens Axboe214e1ec2007-03-15 10:48:13 +0100463
464 return 0;
465}
466
Jens Axboe3ae06372010-03-19 19:17:15 +0100467#ifdef FIO_HAVE_SYNC_FILE_RANGE
Jens Axboe44f29692010-03-09 20:09:44 +0100468static int str_sfr_cb(void *data, const char *str)
469{
470 struct thread_data *td = data;
471 char *nr = get_opt_postfix(str);
472
473 td->sync_file_range_nr = 1;
474 if (nr) {
475 td->sync_file_range_nr = atoi(nr);
476 free(nr);
477 }
478
479 return 0;
480}
Jens Axboe3ae06372010-03-19 19:17:15 +0100481#endif
Jens Axboe44f29692010-03-09 20:09:44 +0100482
Jens Axboe921c7662008-03-26 09:17:55 +0100483static int check_dir(struct thread_data *td, char *fname)
484{
485 char file[PATH_MAX], *dir;
Jens Axboebc838912008-04-07 09:00:54 +0200486 int elen = 0;
Jens Axboe921c7662008-03-26 09:17:55 +0100487
Jens Axboebc838912008-04-07 09:00:54 +0200488 if (td->o.directory) {
489 strcpy(file, td->o.directory);
Jens Axboefcef0b32008-05-26 14:53:24 +0200490 strcat(file, "/");
Jens Axboebc838912008-04-07 09:00:54 +0200491 elen = strlen(file);
492 }
493
Jens Axboefcef0b32008-05-26 14:53:24 +0200494 sprintf(file + elen, "%s", fname);
Jens Axboe921c7662008-03-26 09:17:55 +0100495 dir = dirname(file);
496
Jens Axboefcef0b32008-05-26 14:53:24 +0200497#if 0
498 {
499 struct stat sb;
500 /*
501 * We can't do this on FIO_DISKLESSIO engines. The engine isn't loaded
502 * yet, so we can't do this check right here...
503 */
Jens Axboe921c7662008-03-26 09:17:55 +0100504 if (lstat(dir, &sb) < 0) {
505 int ret = errno;
506
507 log_err("fio: %s is not a directory\n", dir);
508 td_verror(td, ret, "lstat");
509 return 1;
510 }
511
512 if (!S_ISDIR(sb.st_mode)) {
513 log_err("fio: %s is not a directory\n", dir);
514 return 1;
515 }
Jens Axboefcef0b32008-05-26 14:53:24 +0200516 }
517#endif
Jens Axboe921c7662008-03-26 09:17:55 +0100518
519 return 0;
520}
521
Jens Axboe8e827d32009-08-04 09:51:48 +0200522/*
523 * Return next file in the string. Files are separated with ':'. If the ':'
524 * is escaped with a '\', then that ':' is part of the filename and does not
525 * indicate a new file.
526 */
527static char *get_next_file_name(char **ptr)
528{
529 char *str = *ptr;
530 char *p, *start;
531
532 if (!str || !strlen(str))
533 return NULL;
534
535 start = str;
536 do {
537 /*
538 * No colon, we are done
539 */
540 p = strchr(str, ':');
541 if (!p) {
542 *ptr = NULL;
543 break;
544 }
545
546 /*
547 * We got a colon, but it's the first character. Skip and
548 * continue
549 */
550 if (p == start) {
551 str = ++start;
552 continue;
553 }
554
555 if (*(p - 1) != '\\') {
556 *p = '\0';
557 *ptr = p + 1;
558 break;
559 }
560
561 memmove(p - 1, p, strlen(p) + 1);
562 str = p;
563 } while (1);
564
565 return start;
566}
567
Jens Axboe214e1ec2007-03-15 10:48:13 +0100568static int str_filename_cb(void *data, const char *input)
569{
570 struct thread_data *td = data;
571 char *fname, *str, *p;
572
573 p = str = strdup(input);
574
575 strip_blank_front(&str);
576 strip_blank_end(str);
577
578 if (!td->files_index)
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100579 td->o.nr_files = 0;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100580
Jens Axboe8e827d32009-08-04 09:51:48 +0200581 while ((fname = get_next_file_name(&str)) != NULL) {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100582 if (!strlen(fname))
583 break;
Jens Axboe921c7662008-03-26 09:17:55 +0100584 if (check_dir(td, fname)) {
585 free(p);
586 return 1;
587 }
Jens Axboe214e1ec2007-03-15 10:48:13 +0100588 add_file(td, fname);
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100589 td->o.nr_files++;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100590 }
591
592 free(p);
593 return 0;
594}
595
596static int str_directory_cb(void *data, const char fio_unused *str)
597{
598 struct thread_data *td = data;
599 struct stat sb;
600
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100601 if (lstat(td->o.directory, &sb) < 0) {
Jens Axboe921c7662008-03-26 09:17:55 +0100602 int ret = errno;
603
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100604 log_err("fio: %s is not a directory\n", td->o.directory);
Jens Axboe921c7662008-03-26 09:17:55 +0100605 td_verror(td, ret, "lstat");
Jens Axboe214e1ec2007-03-15 10:48:13 +0100606 return 1;
607 }
608 if (!S_ISDIR(sb.st_mode)) {
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100609 log_err("fio: %s is not a directory\n", td->o.directory);
Jens Axboe214e1ec2007-03-15 10:48:13 +0100610 return 1;
611 }
612
613 return 0;
614}
615
616static int str_opendir_cb(void *data, const char fio_unused *str)
617{
618 struct thread_data *td = data;
619
620 if (!td->files_index)
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100621 td->o.nr_files = 0;
Jens Axboe214e1ec2007-03-15 10:48:13 +0100622
Jens Axboe2dc1bbe2007-03-15 15:01:33 +0100623 return add_dir_files(td, td->o.opendir);
Jens Axboe214e1ec2007-03-15 10:48:13 +0100624}
625
Cigy Cyriac85bc8332010-08-10 19:21:09 -0400626static int str_verify_offset_cb(void *data, unsigned long long *off)
Shawn Lewis546a9142007-07-28 21:11:37 +0200627{
628 struct thread_data *td = data;
Jens Axboea59e1702007-07-30 08:53:27 +0200629
Shawn Lewis546a9142007-07-28 21:11:37 +0200630 if (*off && *off < sizeof(struct verify_header)) {
Jens Axboea59e1702007-07-30 08:53:27 +0200631 log_err("fio: verify_offset too small\n");
Shawn Lewis546a9142007-07-28 21:11:37 +0200632 return 1;
633 }
Jens Axboea59e1702007-07-30 08:53:27 +0200634
635 td->o.verify_offset = *off;
Shawn Lewis546a9142007-07-28 21:11:37 +0200636 return 0;
637}
638
Radha Ramachandran0e92f872009-10-27 20:14:27 +0100639static int str_verify_pattern_cb(void *data, const char *input)
Jens Axboe90059d62007-07-30 09:33:12 +0200640{
641 struct thread_data *td = data;
Radha Ramachandran0e92f872009-10-27 20:14:27 +0100642 long off;
643 int i = 0, j = 0, len, k, base = 10;
644 char* loc1, * loc2;
Jens Axboe90059d62007-07-30 09:33:12 +0200645
Radha Ramachandran0e92f872009-10-27 20:14:27 +0100646 loc1 = strstr(input, "0x");
647 loc2 = strstr(input, "0X");
648 if (loc1 || loc2)
649 base = 16;
650 off = strtol(input, NULL, base);
651 if (off != LONG_MAX || errno != ERANGE) {
652 while (off) {
653 td->o.verify_pattern[i] = off & 0xff;
654 off >>= 8;
655 i++;
656 }
657 } else {
658 len = strlen(input);
659 k = len - 1;
660 if (base == 16) {
661 if (loc1)
662 j = loc1 - input + 2;
663 else
664 j = loc2 - input + 2;
665 } else
666 return 1;
667 if (len - j < MAX_PATTERN_SIZE * 2) {
668 while (k >= j) {
669 off = converthexchartoint(input[k--]);
670 if (k >= j)
671 off += (converthexchartoint(input[k--])
672 * 16);
673 td->o.verify_pattern[i++] = (char) off;
674 }
675 }
676 }
677 td->o.verify_pattern_bytes = i;
Jens Axboe90059d62007-07-30 09:33:12 +0200678 return 0;
679}
Jens Axboe214e1ec2007-03-15 10:48:13 +0100680
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100681static int str_lockfile_cb(void *data, const char *str)
682{
683 struct thread_data *td = data;
684 char *nr = get_opt_postfix(str);
685
686 td->o.lockfile_batch = 1;
Jens Axboe182ec6e2008-11-14 13:06:06 +0100687 if (nr) {
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100688 td->o.lockfile_batch = atoi(nr);
Jens Axboe182ec6e2008-11-14 13:06:06 +0100689 free(nr);
690 }
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100691
692 return 0;
693}
694
Jens Axboee3cedca2008-11-19 19:57:52 +0100695static int str_write_bw_log_cb(void *data, const char *str)
696{
697 struct thread_data *td = data;
698
699 if (str)
700 td->o.bw_log_file = strdup(str);
701
702 td->o.write_bw_log = 1;
703 return 0;
704}
705
706static int str_write_lat_log_cb(void *data, const char *str)
707{
708 struct thread_data *td = data;
709
710 if (str)
711 td->o.lat_log_file = strdup(str);
712
713 td->o.write_lat_log = 1;
714 return 0;
715}
716
Jens Axboe993bf482008-11-14 13:04:53 +0100717static int str_gtod_reduce_cb(void *data, int *il)
718{
719 struct thread_data *td = data;
720 int val = *il;
721
Jens Axboe02af0982010-06-24 09:59:34 +0200722 td->o.disable_lat = !!val;
Jens Axboe993bf482008-11-14 13:04:53 +0100723 td->o.disable_clat = !!val;
724 td->o.disable_slat = !!val;
725 td->o.disable_bw = !!val;
726 if (val)
727 td->tv_cache_mask = 63;
728
729 return 0;
730}
731
Cigy Cyriac85bc8332010-08-10 19:21:09 -0400732static int str_gtod_cpu_cb(void *data, long long *il)
Jens Axboebe4ecfd2008-12-08 14:10:52 +0100733{
734 struct thread_data *td = data;
735 int val = *il;
736
737 td->o.gtod_cpu = val;
738 td->o.gtod_offload = 1;
739 return 0;
740}
741
Jens Axboe896cac22009-07-01 10:38:35 +0200742static int rw_verify(struct fio_option *o, void *data)
743{
744 struct thread_data *td = data;
745
746 if (read_only && td_write(td)) {
747 log_err("fio: job <%s> has write bit set, but fio is in"
748 " read-only mode\n", td->o.name);
749 return 1;
750 }
751
752 return 0;
753}
754
Jens Axboe276ca4f2009-07-01 10:43:05 +0200755static int gtod_cpu_verify(struct fio_option *o, void *data)
Jens Axboe29d43ff2009-07-01 10:42:18 +0200756{
Jens Axboe276ca4f2009-07-01 10:43:05 +0200757#ifndef FIO_HAVE_CPU_AFFINITY
Jens Axboe29d43ff2009-07-01 10:42:18 +0200758 struct thread_data *td = data;
759
Jens Axboe29d43ff2009-07-01 10:42:18 +0200760 if (td->o.gtod_cpu) {
761 log_err("fio: platform must support CPU affinity for"
762 "gettimeofday() offloading\n");
763 return 1;
764 }
765#endif
766
767 return 0;
768}
769
Jens Axboe90fef2d2009-07-17 22:33:32 +0200770static int kb_base_verify(struct fio_option *o, void *data)
771{
772 struct thread_data *td = data;
773
774 if (td->o.kb_base != 1024 && td->o.kb_base != 1000) {
775 log_err("fio: kb_base set to nonsensical value: %u\n",
776 td->o.kb_base);
777 return 1;
778 }
779
780 return 0;
781}
782
Jens Axboe214e1ec2007-03-15 10:48:13 +0100783#define __stringify_1(x) #x
784#define __stringify(x) __stringify_1(x)
785
786/*
787 * Map of job/command line options
788 */
Jens Axboe07b32322010-03-05 09:48:44 +0100789static struct fio_option options[FIO_MAX_OPTS] = {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100790 {
791 .name = "description",
792 .type = FIO_OPT_STR_STORE,
793 .off1 = td_var_offset(description),
794 .help = "Text job description",
795 },
796 {
797 .name = "name",
798 .type = FIO_OPT_STR_STORE,
799 .off1 = td_var_offset(name),
800 .help = "Name of this job",
801 },
802 {
803 .name = "directory",
804 .type = FIO_OPT_STR_STORE,
805 .off1 = td_var_offset(directory),
806 .cb = str_directory_cb,
807 .help = "Directory to store files in",
808 },
809 {
810 .name = "filename",
811 .type = FIO_OPT_STR_STORE,
812 .off1 = td_var_offset(filename),
813 .cb = str_filename_cb,
Jens Axboef0d524b2009-04-27 08:00:48 +0200814 .prio = -1, /* must come after "directory" */
Jens Axboe214e1ec2007-03-15 10:48:13 +0100815 .help = "File(s) to use for the workload",
816 },
817 {
Jens Axboe90fef2d2009-07-17 22:33:32 +0200818 .name = "kb_base",
819 .type = FIO_OPT_INT,
820 .off1 = td_var_offset(kb_base),
Jens Axboe90fef2d2009-07-17 22:33:32 +0200821 .verify = kb_base_verify,
Jens Axboea639f0b2009-07-18 08:25:35 +0200822 .prio = 1,
Jens Axboe90fef2d2009-07-17 22:33:32 +0200823 .def = "1024",
Jens Axboea639f0b2009-07-18 08:25:35 +0200824 .help = "How many bytes per KB for reporting (1000 or 1024)",
Jens Axboe90fef2d2009-07-17 22:33:32 +0200825 },
826 {
Jens Axboe29c13492008-03-01 19:25:20 +0100827 .name = "lockfile",
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100828 .type = FIO_OPT_STR,
829 .cb = str_lockfile_cb,
830 .off1 = td_var_offset(file_lock_mode),
Jens Axboe29c13492008-03-01 19:25:20 +0100831 .help = "Lock file when doing IO to it",
832 .parent = "filename",
Jens Axboe4d4e80f2008-03-04 10:18:56 +0100833 .def = "none",
834 .posval = {
835 { .ival = "none",
836 .oval = FILE_LOCK_NONE,
837 .help = "No file locking",
838 },
839 { .ival = "exclusive",
840 .oval = FILE_LOCK_EXCLUSIVE,
841 .help = "Exclusive file lock",
842 },
843 {
844 .ival = "readwrite",
845 .oval = FILE_LOCK_READWRITE,
846 .help = "Read vs write lock",
847 },
848 },
Jens Axboe29c13492008-03-01 19:25:20 +0100849 },
850 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100851 .name = "opendir",
852 .type = FIO_OPT_STR_STORE,
853 .off1 = td_var_offset(opendir),
854 .cb = str_opendir_cb,
855 .help = "Recursively add files from this directory and down",
856 },
857 {
858 .name = "rw",
Jens Axboed3aad8f2007-03-15 14:12:05 +0100859 .alias = "readwrite",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100860 .type = FIO_OPT_STR,
Jens Axboe211097b2007-03-22 18:56:45 +0100861 .cb = str_rw_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100862 .off1 = td_var_offset(td_ddir),
863 .help = "IO direction",
864 .def = "read",
Jens Axboe896cac22009-07-01 10:38:35 +0200865 .verify = rw_verify,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100866 .posval = {
867 { .ival = "read",
868 .oval = TD_DDIR_READ,
869 .help = "Sequential read",
870 },
871 { .ival = "write",
872 .oval = TD_DDIR_WRITE,
873 .help = "Sequential write",
874 },
875 { .ival = "randread",
876 .oval = TD_DDIR_RANDREAD,
877 .help = "Random read",
878 },
879 { .ival = "randwrite",
880 .oval = TD_DDIR_RANDWRITE,
881 .help = "Random write",
882 },
883 { .ival = "rw",
884 .oval = TD_DDIR_RW,
885 .help = "Sequential read and write mix",
886 },
887 { .ival = "randrw",
888 .oval = TD_DDIR_RANDRW,
889 .help = "Random read and write mix"
890 },
891 },
892 },
893 {
Jens Axboe38dad622010-07-20 14:46:00 -0600894 .name = "rw_sequencer",
895 .type = FIO_OPT_STR,
896 .off1 = td_var_offset(rw_seq),
897 .help = "IO offset generator modifier",
898 .def = "sequential",
899 .posval = {
900 { .ival = "sequential",
901 .oval = RW_SEQ_SEQ,
902 .help = "Generate sequential offsets",
903 },
904 { .ival = "identical",
905 .oval = RW_SEQ_IDENT,
906 .help = "Generate identical offsets",
907 },
908 },
909 },
910
911 {
Jens Axboe214e1ec2007-03-15 10:48:13 +0100912 .name = "ioengine",
913 .type = FIO_OPT_STR_STORE,
914 .off1 = td_var_offset(ioengine),
915 .help = "IO engine to use",
916 .def = "sync",
917 .posval = {
918 { .ival = "sync",
919 .help = "Use read/write",
920 },
gurudas paia31041e2007-10-23 15:12:30 +0200921 { .ival = "psync",
922 .help = "Use pread/pwrite",
923 },
Jens Axboe1d2af022008-02-04 10:59:07 +0100924 { .ival = "vsync",
925 .help = "Use readv/writev",
926 },
Jens Axboe214e1ec2007-03-15 10:48:13 +0100927#ifdef FIO_HAVE_LIBAIO
928 { .ival = "libaio",
929 .help = "Linux native asynchronous IO",
930 },
931#endif
932#ifdef FIO_HAVE_POSIXAIO
933 { .ival = "posixaio",
934 .help = "POSIX asynchronous IO",
935 },
936#endif
Jens Axboe417f0062008-06-02 11:59:30 +0200937#ifdef FIO_HAVE_SOLARISAIO
938 { .ival = "solarisaio",
939 .help = "Solaris native asynchronous IO",
940 },
941#endif
Jens Axboe214e1ec2007-03-15 10:48:13 +0100942 { .ival = "mmap",
943 .help = "Memory mapped IO",
944 },
945#ifdef FIO_HAVE_SPLICE
946 { .ival = "splice",
947 .help = "splice/vmsplice based IO",
948 },
Jens Axboe9cce02e2007-06-22 15:42:21 +0200949 { .ival = "netsplice",
950 .help = "splice/vmsplice to/from the network",
951 },
Jens Axboe214e1ec2007-03-15 10:48:13 +0100952#endif
953#ifdef FIO_HAVE_SGIO
954 { .ival = "sg",
955 .help = "SCSI generic v3 IO",
956 },
957#endif
958 { .ival = "null",
959 .help = "Testing engine (no data transfer)",
960 },
961 { .ival = "net",
962 .help = "Network IO",
963 },
964#ifdef FIO_HAVE_SYSLET
965 { .ival = "syslet-rw",
966 .help = "syslet enabled async pread/pwrite IO",
967 },
968#endif
969 { .ival = "cpuio",
970 .help = "CPU cycler burner engine",
971 },
Jens Axboeb8c82a42007-03-21 08:48:26 +0100972#ifdef FIO_HAVE_GUASI
973 { .ival = "guasi",
974 .help = "GUASI IO engine",
975 },
976#endif
Jens Axboe79a43182010-09-07 13:28:58 +0200977#ifdef FIO_HAVE_BINJECT
978 { .ival = "binject",
979 .help = "binject direct inject block engine",
980 },
981#endif
Jens Axboe214e1ec2007-03-15 10:48:13 +0100982 { .ival = "external",
983 .help = "Load external engine (append name)",
984 },
985 },
986 },
987 {
988 .name = "iodepth",
989 .type = FIO_OPT_INT,
990 .off1 = td_var_offset(iodepth),
991 .help = "Amount of IO buffers to keep in flight",
Jens Axboe757aff42007-12-12 19:42:13 +0100992 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +0100993 .def = "1",
994 },
995 {
996 .name = "iodepth_batch",
Jens Axboe49504212008-06-05 09:03:30 +0200997 .alias = "iodepth_batch_submit",
Jens Axboe214e1ec2007-03-15 10:48:13 +0100998 .type = FIO_OPT_INT,
999 .off1 = td_var_offset(iodepth_batch),
Jens Axboed65db442009-01-16 19:15:33 +01001000 .help = "Number of IO buffers to submit in one go",
Jens Axboeafdf9352007-07-31 16:14:34 +02001001 .parent = "iodepth",
Jens Axboea2e6f8a2008-01-18 10:28:11 +01001002 .minval = 1,
1003 .def = "1",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001004 },
1005 {
Jens Axboe49504212008-06-05 09:03:30 +02001006 .name = "iodepth_batch_complete",
1007 .type = FIO_OPT_INT,
1008 .off1 = td_var_offset(iodepth_batch_complete),
Jens Axboed65db442009-01-16 19:15:33 +01001009 .help = "Number of IO buffers to retrieve in one go",
Jens Axboe49504212008-06-05 09:03:30 +02001010 .parent = "iodepth",
1011 .minval = 0,
1012 .def = "1",
1013 },
1014 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001015 .name = "iodepth_low",
1016 .type = FIO_OPT_INT,
1017 .off1 = td_var_offset(iodepth_low),
1018 .help = "Low water mark for queuing depth",
Jens Axboeafdf9352007-07-31 16:14:34 +02001019 .parent = "iodepth",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001020 },
1021 {
1022 .name = "size",
1023 .type = FIO_OPT_STR_VAL,
Jens Axboe2dc1bbe2007-03-15 15:01:33 +01001024 .off1 = td_var_offset(size),
Jens Axboec3edbdb2007-07-20 14:25:31 +02001025 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001026 .help = "Total size of device or files",
1027 },
1028 {
Shawn Lewisaa31f1f2008-01-11 09:45:11 +01001029 .name = "fill_device",
1030 .type = FIO_OPT_BOOL,
1031 .off1 = td_var_offset(fill_device),
1032 .help = "Write until an ENOSPC error occurs",
1033 .def = "0",
1034 },
1035 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001036 .name = "filesize",
1037 .type = FIO_OPT_STR_VAL,
1038 .off1 = td_var_offset(file_size_low),
1039 .off2 = td_var_offset(file_size_high),
Jens Axboec3edbdb2007-07-20 14:25:31 +02001040 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001041 .help = "Size of individual files",
1042 },
1043 {
Jens Axboe67a10002007-07-31 23:12:16 +02001044 .name = "offset",
1045 .alias = "fileoffset",
1046 .type = FIO_OPT_STR_VAL,
1047 .off1 = td_var_offset(start_offset),
1048 .help = "Start IO from this offset",
1049 .def = "0",
1050 },
1051 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001052 .name = "bs",
Jens Axboed3aad8f2007-03-15 14:12:05 +01001053 .alias = "blocksize",
Jens Axboee01b22b2009-06-09 15:43:25 +02001054 .type = FIO_OPT_INT,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001055 .off1 = td_var_offset(bs[DDIR_READ]),
1056 .off2 = td_var_offset(bs[DDIR_WRITE]),
Jens Axboec3edbdb2007-07-20 14:25:31 +02001057 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001058 .help = "Block size unit",
1059 .def = "4k",
Jens Axboe67a10002007-07-31 23:12:16 +02001060 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001061 },
1062 {
Jens Axboe2b7a01d2009-03-11 11:00:13 +01001063 .name = "ba",
1064 .alias = "blockalign",
Jens Axboee01b22b2009-06-09 15:43:25 +02001065 .type = FIO_OPT_INT,
Jens Axboe2b7a01d2009-03-11 11:00:13 +01001066 .off1 = td_var_offset(ba[DDIR_READ]),
1067 .off2 = td_var_offset(ba[DDIR_WRITE]),
1068 .minval = 1,
1069 .help = "IO block offset alignment",
1070 .parent = "rw",
1071 },
1072 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001073 .name = "bsrange",
Jens Axboed3aad8f2007-03-15 14:12:05 +01001074 .alias = "blocksize_range",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001075 .type = FIO_OPT_RANGE,
1076 .off1 = td_var_offset(min_bs[DDIR_READ]),
1077 .off2 = td_var_offset(max_bs[DDIR_READ]),
1078 .off3 = td_var_offset(min_bs[DDIR_WRITE]),
1079 .off4 = td_var_offset(max_bs[DDIR_WRITE]),
Jens Axboec3edbdb2007-07-20 14:25:31 +02001080 .minval = 1,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001081 .help = "Set block size range (in more detail than bs)",
Jens Axboe67a10002007-07-31 23:12:16 +02001082 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001083 },
1084 {
Jens Axboe564ca972007-12-14 12:21:19 +01001085 .name = "bssplit",
1086 .type = FIO_OPT_STR,
1087 .cb = str_bssplit_cb,
1088 .help = "Set a specific mix of block sizes",
1089 .parent = "rw",
1090 },
1091 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001092 .name = "bs_unaligned",
Jens Axboed3aad8f2007-03-15 14:12:05 +01001093 .alias = "blocksize_unaligned",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001094 .type = FIO_OPT_STR_SET,
1095 .off1 = td_var_offset(bs_unaligned),
1096 .help = "Don't sector align IO buffer sizes",
Jens Axboe67a10002007-07-31 23:12:16 +02001097 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001098 },
1099 {
1100 .name = "randrepeat",
1101 .type = FIO_OPT_BOOL,
1102 .off1 = td_var_offset(rand_repeatable),
1103 .help = "Use repeatable random IO pattern",
1104 .def = "1",
Jens Axboe67a10002007-07-31 23:12:16 +02001105 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001106 },
1107 {
1108 .name = "norandommap",
1109 .type = FIO_OPT_STR_SET,
1110 .off1 = td_var_offset(norandommap),
1111 .help = "Accept potential duplicate random blocks",
Jens Axboe67a10002007-07-31 23:12:16 +02001112 .parent = "rw",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001113 },
1114 {
Jens Axboe2b386d22008-03-26 10:32:57 +01001115 .name = "softrandommap",
1116 .type = FIO_OPT_BOOL,
1117 .off1 = td_var_offset(softrandommap),
Jens Axboef66ab3c2008-06-05 11:48:22 +02001118 .help = "Set norandommap if randommap allocation fails",
Jens Axboe2b386d22008-03-26 10:32:57 +01001119 .parent = "norandommap",
1120 .def = "0",
1121 },
1122 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001123 .name = "nrfiles",
1124 .type = FIO_OPT_INT,
1125 .off1 = td_var_offset(nr_files),
1126 .help = "Split job workload between this number of files",
1127 .def = "1",
1128 },
1129 {
1130 .name = "openfiles",
1131 .type = FIO_OPT_INT,
1132 .off1 = td_var_offset(open_files),
1133 .help = "Number of files to keep open at the same time",
1134 },
1135 {
1136 .name = "file_service_type",
1137 .type = FIO_OPT_STR,
1138 .cb = str_fst_cb,
1139 .off1 = td_var_offset(file_service_type),
1140 .help = "How to select which file to service next",
1141 .def = "roundrobin",
1142 .posval = {
1143 { .ival = "random",
1144 .oval = FIO_FSERVICE_RANDOM,
1145 .help = "Choose a file at random",
1146 },
1147 { .ival = "roundrobin",
1148 .oval = FIO_FSERVICE_RR,
1149 .help = "Round robin select files",
1150 },
Jens Axboea086c252009-03-04 08:27:37 +01001151 { .ival = "sequential",
1152 .oval = FIO_FSERVICE_SEQ,
1153 .help = "Finish one file before moving to the next",
1154 },
Jens Axboe214e1ec2007-03-15 10:48:13 +01001155 },
Jens Axboe67a10002007-07-31 23:12:16 +02001156 .parent = "nrfiles",
1157 },
Jens Axboe7bc8c2c2010-01-28 11:31:31 +01001158#ifdef FIO_HAVE_FALLOCATE
1159 {
1160 .name = "fallocate",
1161 .type = FIO_OPT_BOOL,
1162 .off1 = td_var_offset(fallocate),
1163 .help = "Use fallocate() when laying out files",
1164 .def = "1",
1165 },
1166#endif
Jens Axboe67a10002007-07-31 23:12:16 +02001167 {
1168 .name = "fadvise_hint",
1169 .type = FIO_OPT_BOOL,
1170 .off1 = td_var_offset(fadvise_hint),
1171 .help = "Use fadvise() to advise the kernel on IO pattern",
1172 .def = "1",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001173 },
1174 {
1175 .name = "fsync",
1176 .type = FIO_OPT_INT,
1177 .off1 = td_var_offset(fsync_blocks),
1178 .help = "Issue fsync for writes every given number of blocks",
1179 .def = "0",
1180 },
1181 {
Jens Axboe5f9099e2009-06-16 22:40:26 +02001182 .name = "fdatasync",
1183 .type = FIO_OPT_INT,
1184 .off1 = td_var_offset(fdatasync_blocks),
1185 .help = "Issue fdatasync for writes every given number of blocks",
1186 .def = "0",
1187 },
Jens Axboe44f29692010-03-09 20:09:44 +01001188#ifdef FIO_HAVE_SYNC_FILE_RANGE
1189 {
1190 .name = "sync_file_range",
1191 .posval = {
1192 { .ival = "wait_before",
1193 .oval = SYNC_FILE_RANGE_WAIT_BEFORE,
1194 .help = "SYNC_FILE_RANGE_WAIT_BEFORE",
Jens Axboe3843deb2010-03-09 20:41:15 +01001195 .or = 1,
Jens Axboe44f29692010-03-09 20:09:44 +01001196 },
1197 { .ival = "write",
1198 .oval = SYNC_FILE_RANGE_WRITE,
1199 .help = "SYNC_FILE_RANGE_WRITE",
Jens Axboe3843deb2010-03-09 20:41:15 +01001200 .or = 1,
Jens Axboe44f29692010-03-09 20:09:44 +01001201 },
1202 {
1203 .ival = "wait_after",
1204 .oval = SYNC_FILE_RANGE_WAIT_AFTER,
1205 .help = "SYNC_FILE_RANGE_WAIT_AFTER",
Jens Axboe3843deb2010-03-09 20:41:15 +01001206 .or = 1,
Jens Axboe44f29692010-03-09 20:09:44 +01001207 },
1208 },
Jens Axboe3843deb2010-03-09 20:41:15 +01001209 .type = FIO_OPT_STR_MULTI,
Jens Axboe44f29692010-03-09 20:09:44 +01001210 .cb = str_sfr_cb,
1211 .off1 = td_var_offset(sync_file_range),
1212 .help = "Use sync_file_range()",
1213 },
1214#endif
Jens Axboe5f9099e2009-06-16 22:40:26 +02001215 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001216 .name = "direct",
1217 .type = FIO_OPT_BOOL,
1218 .off1 = td_var_offset(odirect),
1219 .help = "Use O_DIRECT IO (negates buffered)",
1220 .def = "0",
1221 },
1222 {
1223 .name = "buffered",
1224 .type = FIO_OPT_BOOL,
1225 .off1 = td_var_offset(odirect),
1226 .neg = 1,
1227 .help = "Use buffered IO (negates direct)",
1228 .def = "1",
1229 },
1230 {
1231 .name = "overwrite",
1232 .type = FIO_OPT_BOOL,
1233 .off1 = td_var_offset(overwrite),
1234 .help = "When writing, set whether to overwrite current data",
1235 .def = "0",
1236 },
1237 {
1238 .name = "loops",
1239 .type = FIO_OPT_INT,
1240 .off1 = td_var_offset(loops),
1241 .help = "Number of times to run the job",
1242 .def = "1",
1243 },
1244 {
1245 .name = "numjobs",
1246 .type = FIO_OPT_INT,
1247 .off1 = td_var_offset(numjobs),
1248 .help = "Duplicate this job this many times",
1249 .def = "1",
1250 },
1251 {
1252 .name = "startdelay",
Jens Axboea5737c92010-06-29 10:40:30 +02001253 .type = FIO_OPT_STR_VAL_TIME,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001254 .off1 = td_var_offset(start_delay),
1255 .help = "Only start job when this period has passed",
1256 .def = "0",
1257 },
1258 {
1259 .name = "runtime",
1260 .alias = "timeout",
1261 .type = FIO_OPT_STR_VAL_TIME,
1262 .off1 = td_var_offset(timeout),
1263 .help = "Stop workload when this amount of time has passed",
1264 .def = "0",
1265 },
1266 {
Jens Axboecf4464c2007-04-17 20:14:42 +02001267 .name = "time_based",
1268 .type = FIO_OPT_STR_SET,
1269 .off1 = td_var_offset(time_based),
1270 .help = "Keep running until runtime/timeout is met",
1271 },
1272 {
Jens Axboe721938a2008-09-10 09:46:16 +02001273 .name = "ramp_time",
1274 .type = FIO_OPT_STR_VAL_TIME,
1275 .off1 = td_var_offset(ramp_time),
1276 .help = "Ramp up time before measuring performance",
1277 },
1278 {
Jens Axboec223da82010-03-24 13:23:53 +01001279 .name = "clocksource",
1280 .type = FIO_OPT_STR,
1281 .cb = fio_clock_source_cb,
1282 .off1 = td_var_offset(clocksource),
1283 .help = "What type of timing source to use",
Jens Axboec223da82010-03-24 13:23:53 +01001284 .posval = {
1285 { .ival = "gettimeofday",
1286 .oval = CS_GTOD,
1287 .help = "Use gettimeofday(2) for timing",
1288 },
1289 { .ival = "clock_gettime",
1290 .oval = CS_CGETTIME,
1291 .help = "Use clock_gettime(2) for timing",
1292 },
1293#ifdef ARCH_HAVE_CPU_CLOCK
1294 { .ival = "cpu",
1295 .oval = CS_CPUCLOCK,
1296 .help = "Use CPU private clock",
1297 },
1298#endif
1299 },
1300 },
1301 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001302 .name = "mem",
Jens Axboed3aad8f2007-03-15 14:12:05 +01001303 .alias = "iomem",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001304 .type = FIO_OPT_STR,
1305 .cb = str_mem_cb,
1306 .off1 = td_var_offset(mem_type),
1307 .help = "Backing type for IO buffers",
1308 .def = "malloc",
1309 .posval = {
1310 { .ival = "malloc",
1311 .oval = MEM_MALLOC,
1312 .help = "Use malloc(3) for IO buffers",
1313 },
Jens Axboeb370e462007-03-19 10:51:49 +01001314 { .ival = "shm",
1315 .oval = MEM_SHM,
1316 .help = "Use shared memory segments for IO buffers",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001317 },
1318#ifdef FIO_HAVE_HUGETLB
Jens Axboe37c8cdf2007-03-19 13:14:03 +01001319 { .ival = "shmhuge",
1320 .oval = MEM_SHMHUGE,
1321 .help = "Like shm, but use huge pages",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001322 },
1323#endif
Jens Axboeb370e462007-03-19 10:51:49 +01001324 { .ival = "mmap",
1325 .oval = MEM_MMAP,
1326 .help = "Use mmap(2) (file or anon) for IO buffers",
1327 },
Jens Axboe37c8cdf2007-03-19 13:14:03 +01001328#ifdef FIO_HAVE_HUGETLB
1329 { .ival = "mmaphuge",
1330 .oval = MEM_MMAPHUGE,
1331 .help = "Like mmap, but use huge pages",
1332 },
1333#endif
Jens Axboe214e1ec2007-03-15 10:48:13 +01001334 },
1335 },
1336 {
Jens Axboed529ee12009-07-01 10:33:03 +02001337 .name = "iomem_align",
1338 .alias = "mem_align",
1339 .type = FIO_OPT_INT,
1340 .off1 = td_var_offset(mem_align),
1341 .minval = 0,
1342 .help = "IO memory buffer offset alignment",
1343 .def = "0",
1344 .parent = "iomem",
1345 },
1346 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001347 .name = "verify",
1348 .type = FIO_OPT_STR,
1349 .off1 = td_var_offset(verify),
1350 .help = "Verify data written",
Jens Axboe5d7c5d32010-06-21 15:08:17 +02001351 .cb = str_verify_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001352 .def = "0",
1353 .posval = {
1354 { .ival = "0",
1355 .oval = VERIFY_NONE,
1356 .help = "Don't do IO verification",
1357 },
Jens Axboefcca4b52007-07-27 15:42:00 +02001358 { .ival = "md5",
1359 .oval = VERIFY_MD5,
1360 .help = "Use md5 checksums for verification",
1361 },
Jens Axboed77a7af2007-07-27 15:35:06 +02001362 { .ival = "crc64",
1363 .oval = VERIFY_CRC64,
1364 .help = "Use crc64 checksums for verification",
1365 },
Jens Axboe214e1ec2007-03-15 10:48:13 +01001366 { .ival = "crc32",
1367 .oval = VERIFY_CRC32,
1368 .help = "Use crc32 checksums for verification",
1369 },
Jens Axboeaf497e62008-08-04 15:40:35 +02001370 { .ival = "crc32c-intel",
1371 .oval = VERIFY_CRC32C_INTEL,
1372 .help = "Use hw crc32c checksums for verification",
1373 },
Jens Axboebac39e02008-06-11 20:46:19 +02001374 { .ival = "crc32c",
1375 .oval = VERIFY_CRC32C,
1376 .help = "Use crc32c checksums for verification",
1377 },
Jens Axboe969f7ed2007-07-27 09:07:17 +02001378 { .ival = "crc16",
1379 .oval = VERIFY_CRC16,
1380 .help = "Use crc16 checksums for verification",
1381 },
Jens Axboe1e154bd2007-07-27 09:52:40 +02001382 { .ival = "crc7",
1383 .oval = VERIFY_CRC7,
1384 .help = "Use crc7 checksums for verification",
1385 },
Jens Axboe7c353ce2009-08-09 22:40:33 +02001386 { .ival = "sha1",
1387 .oval = VERIFY_SHA1,
1388 .help = "Use sha1 checksums for verification",
1389 },
Jens Axboecd14cc12007-07-30 10:59:33 +02001390 { .ival = "sha256",
1391 .oval = VERIFY_SHA256,
1392 .help = "Use sha256 checksums for verification",
1393 },
1394 { .ival = "sha512",
1395 .oval = VERIFY_SHA512,
1396 .help = "Use sha512 checksums for verification",
1397 },
Shawn Lewis7437ee82007-08-02 21:05:58 +02001398 { .ival = "meta",
1399 .oval = VERIFY_META,
1400 .help = "Use io information",
1401 },
Jens Axboe36690c92007-03-26 10:23:34 +02001402 {
1403 .ival = "null",
1404 .oval = VERIFY_NULL,
1405 .help = "Pretend to verify",
1406 },
Jens Axboe214e1ec2007-03-15 10:48:13 +01001407 },
1408 },
1409 {
Jens Axboe005c5652007-08-02 22:21:36 +02001410 .name = "do_verify",
Jens Axboe68e1f292007-08-10 10:32:14 +02001411 .type = FIO_OPT_BOOL,
Jens Axboe005c5652007-08-02 22:21:36 +02001412 .off1 = td_var_offset(do_verify),
1413 .help = "Run verification stage after write",
1414 .def = "1",
1415 .parent = "verify",
1416 },
1417 {
Jens Axboe160b9662007-03-27 10:59:49 +02001418 .name = "verifysort",
1419 .type = FIO_OPT_BOOL,
1420 .off1 = td_var_offset(verifysort),
1421 .help = "Sort written verify blocks for read back",
1422 .def = "1",
Jens Axboec83f2df2007-07-31 22:51:47 +02001423 .parent = "verify",
Jens Axboe160b9662007-03-27 10:59:49 +02001424 },
1425 {
Jens Axboea59e1702007-07-30 08:53:27 +02001426 .name = "verify_interval",
Jens Axboee01b22b2009-06-09 15:43:25 +02001427 .type = FIO_OPT_INT,
Jens Axboea59e1702007-07-30 08:53:27 +02001428 .off1 = td_var_offset(verify_interval),
Jens Axboe819a9682007-07-28 21:30:31 +02001429 .minval = 2 * sizeof(struct verify_header),
Jens Axboea59e1702007-07-30 08:53:27 +02001430 .help = "Store verify buffer header every N bytes",
Jens Axboeafdf9352007-07-31 16:14:34 +02001431 .parent = "verify",
Shawn Lewis3f9f4e22007-07-28 21:10:37 +02001432 },
1433 {
Jens Axboea59e1702007-07-30 08:53:27 +02001434 .name = "verify_offset",
Jens Axboee01b22b2009-06-09 15:43:25 +02001435 .type = FIO_OPT_INT,
Jens Axboea59e1702007-07-30 08:53:27 +02001436 .help = "Offset verify header location by N bytes",
Shawn Lewis546a9142007-07-28 21:11:37 +02001437 .def = "0",
Jens Axboe5ec10ea2008-03-06 15:42:00 +01001438 .cb = str_verify_offset_cb,
Jens Axboeafdf9352007-07-31 16:14:34 +02001439 .parent = "verify",
Shawn Lewis546a9142007-07-28 21:11:37 +02001440 },
1441 {
Shawn Lewise28218f2008-01-16 11:01:33 +01001442 .name = "verify_pattern",
Radha Ramachandran0e92f872009-10-27 20:14:27 +01001443 .type = FIO_OPT_STR,
Shawn Lewise28218f2008-01-16 11:01:33 +01001444 .cb = str_verify_pattern_cb,
1445 .help = "Fill pattern for IO buffers",
1446 .parent = "verify",
1447 },
1448 {
Jens Axboea12a3b42007-08-09 10:20:54 +02001449 .name = "verify_fatal",
Jens Axboe68e1f292007-08-10 10:32:14 +02001450 .type = FIO_OPT_BOOL,
Jens Axboea12a3b42007-08-09 10:20:54 +02001451 .off1 = td_var_offset(verify_fatal),
1452 .def = "0",
1453 .help = "Exit on a single verify failure, don't continue",
1454 .parent = "verify",
1455 },
1456 {
Jens Axboee8462bd2009-07-06 12:59:04 +02001457 .name = "verify_async",
1458 .type = FIO_OPT_INT,
1459 .off1 = td_var_offset(verify_async),
1460 .def = "0",
1461 .help = "Number of async verifier threads to use",
1462 .parent = "verify",
1463 },
Jens Axboe9e144182010-06-15 14:25:36 +02001464 {
1465 .name = "verify_backlog",
1466 .type = FIO_OPT_STR_VAL,
1467 .off1 = td_var_offset(verify_backlog),
1468 .help = "Verify after this number of blocks are written",
1469 .parent = "verify",
1470 },
1471 {
1472 .name = "verify_backlog_batch",
1473 .type = FIO_OPT_INT,
1474 .off1 = td_var_offset(verify_batch),
1475 .help = "Verify this number of IO blocks",
Jens Axboe0d29de82010-09-01 13:54:15 +02001476 .parent = "verify",
Jens Axboe9e144182010-06-15 14:25:36 +02001477 },
Jens Axboee8462bd2009-07-06 12:59:04 +02001478#ifdef FIO_HAVE_CPU_AFFINITY
1479 {
1480 .name = "verify_async_cpus",
1481 .type = FIO_OPT_STR,
1482 .cb = str_verify_cpus_allowed_cb,
1483 .help = "Set CPUs allowed for async verify threads",
1484 .parent = "verify_async",
1485 },
1486#endif
Jens Axboe0d29de82010-09-01 13:54:15 +02001487#ifdef FIO_HAVE_TRIM
1488 {
1489 .name = "trim_percentage",
1490 .type = FIO_OPT_INT,
1491 .cb = str_verify_trim_cb,
1492 .maxval = 100,
1493 .help = "Number of verify blocks to discard/trim",
1494 .parent = "verify",
1495 .def = "0",
1496 },
1497 {
1498 .name = "trim_verify_zero",
1499 .type = FIO_OPT_INT,
1500 .help = "Verify that trim/discarded blocks are returned as zeroes",
1501 .off1 = td_var_offset(trim_zero),
1502 .parent = "trim_percentage",
1503 .def = "1",
1504 },
1505 {
1506 .name = "trim_backlog",
1507 .type = FIO_OPT_STR_VAL,
1508 .off1 = td_var_offset(trim_backlog),
1509 .help = "Trim after this number of blocks are written",
1510 .parent = "trim_percentage",
1511 },
1512 {
1513 .name = "trim_backlog_batch",
1514 .type = FIO_OPT_INT,
1515 .off1 = td_var_offset(trim_batch),
1516 .help = "Trim this number of IO blocks",
1517 .parent = "trim_percentage",
1518 },
1519#endif
Jens Axboee8462bd2009-07-06 12:59:04 +02001520 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001521 .name = "write_iolog",
1522 .type = FIO_OPT_STR_STORE,
1523 .off1 = td_var_offset(write_iolog_file),
1524 .help = "Store IO pattern to file",
1525 },
1526 {
1527 .name = "read_iolog",
1528 .type = FIO_OPT_STR_STORE,
1529 .off1 = td_var_offset(read_iolog_file),
1530 .help = "Playback IO pattern from file",
1531 },
1532 {
David Nellans64bbb862010-08-24 22:13:30 +02001533 .name = "replay_no_stall",
1534 .type = FIO_OPT_INT,
1535 .off1 = td_var_offset(no_stall),
1536 .def = "0",
Jens Axboe87e7a972010-08-25 09:01:25 +02001537 .parent = "read_iolog",
David Nellans64bbb862010-08-24 22:13:30 +02001538 .help = "Playback IO pattern file as fast as possible without stalls",
1539 },
1540 {
David Nellansd1c46c02010-08-31 21:20:47 +02001541 .name = "replay_redirect",
1542 .type = FIO_OPT_STR_STORE,
1543 .off1 = td_var_offset(replay_redirect),
1544 .parent = "read_iolog",
1545 .help = "Replay all I/O onto this device, regardless of trace device",
1546 },
1547 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001548 .name = "exec_prerun",
1549 .type = FIO_OPT_STR_STORE,
1550 .off1 = td_var_offset(exec_prerun),
1551 .help = "Execute this file prior to running job",
1552 },
1553 {
1554 .name = "exec_postrun",
1555 .type = FIO_OPT_STR_STORE,
1556 .off1 = td_var_offset(exec_postrun),
1557 .help = "Execute this file after running job",
1558 },
1559#ifdef FIO_HAVE_IOSCHED_SWITCH
1560 {
1561 .name = "ioscheduler",
1562 .type = FIO_OPT_STR_STORE,
1563 .off1 = td_var_offset(ioscheduler),
1564 .help = "Use this IO scheduler on the backing device",
1565 },
1566#endif
1567 {
1568 .name = "zonesize",
1569 .type = FIO_OPT_STR_VAL,
1570 .off1 = td_var_offset(zone_size),
1571 .help = "Give size of an IO zone",
1572 .def = "0",
1573 },
1574 {
1575 .name = "zoneskip",
1576 .type = FIO_OPT_STR_VAL,
1577 .off1 = td_var_offset(zone_skip),
1578 .help = "Space between IO zones",
1579 .def = "0",
1580 },
1581 {
1582 .name = "lockmem",
1583 .type = FIO_OPT_STR_VAL,
1584 .cb = str_lockmem_cb,
1585 .help = "Lock down this amount of memory",
1586 .def = "0",
1587 },
1588 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001589 .name = "rwmixread",
1590 .type = FIO_OPT_INT,
Jens Axboecb499fc2008-05-28 10:33:32 +02001591 .cb = str_rwmix_read_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001592 .maxval = 100,
1593 .help = "Percentage of mixed workload that is reads",
1594 .def = "50",
1595 },
1596 {
1597 .name = "rwmixwrite",
1598 .type = FIO_OPT_INT,
Jens Axboecb499fc2008-05-28 10:33:32 +02001599 .cb = str_rwmix_write_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001600 .maxval = 100,
1601 .help = "Percentage of mixed workload that is writes",
1602 .def = "50",
1603 },
1604 {
Jens Axboeafdf9352007-07-31 16:14:34 +02001605 .name = "rwmixcycle",
Jens Axboe15ca1502008-04-07 09:26:02 +02001606 .type = FIO_OPT_DEPRECATED,
Jens Axboeafdf9352007-07-31 16:14:34 +02001607 },
1608 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001609 .name = "nice",
1610 .type = FIO_OPT_INT,
1611 .off1 = td_var_offset(nice),
1612 .help = "Set job CPU nice value",
1613 .minval = -19,
1614 .maxval = 20,
1615 .def = "0",
1616 },
1617#ifdef FIO_HAVE_IOPRIO
1618 {
1619 .name = "prio",
1620 .type = FIO_OPT_INT,
1621 .cb = str_prio_cb,
1622 .help = "Set job IO priority value",
1623 .minval = 0,
1624 .maxval = 7,
1625 },
1626 {
1627 .name = "prioclass",
1628 .type = FIO_OPT_INT,
1629 .cb = str_prioclass_cb,
1630 .help = "Set job IO priority class",
1631 .minval = 0,
1632 .maxval = 3,
1633 },
1634#endif
1635 {
1636 .name = "thinktime",
1637 .type = FIO_OPT_INT,
1638 .off1 = td_var_offset(thinktime),
1639 .help = "Idle time between IO buffers (usec)",
1640 .def = "0",
1641 },
1642 {
1643 .name = "thinktime_spin",
1644 .type = FIO_OPT_INT,
1645 .off1 = td_var_offset(thinktime_spin),
1646 .help = "Start think time by spinning this amount (usec)",
1647 .def = "0",
Jens Axboeafdf9352007-07-31 16:14:34 +02001648 .parent = "thinktime",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001649 },
1650 {
1651 .name = "thinktime_blocks",
1652 .type = FIO_OPT_INT,
1653 .off1 = td_var_offset(thinktime_blocks),
1654 .help = "IO buffer period between 'thinktime'",
1655 .def = "1",
Jens Axboeafdf9352007-07-31 16:14:34 +02001656 .parent = "thinktime",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001657 },
1658 {
1659 .name = "rate",
Jens Axboee01b22b2009-06-09 15:43:25 +02001660 .type = FIO_OPT_INT,
Jens Axboe581e7142009-06-09 12:47:16 +02001661 .off1 = td_var_offset(rate[0]),
1662 .off2 = td_var_offset(rate[1]),
Jens Axboe214e1ec2007-03-15 10:48:13 +01001663 .help = "Set bandwidth rate",
1664 },
1665 {
1666 .name = "ratemin",
Jens Axboee01b22b2009-06-09 15:43:25 +02001667 .type = FIO_OPT_INT,
Jens Axboe581e7142009-06-09 12:47:16 +02001668 .off1 = td_var_offset(ratemin[0]),
1669 .off2 = td_var_offset(ratemin[1]),
Jens Axboe4e991c22007-03-15 11:41:11 +01001670 .help = "Job must meet this rate or it will be shutdown",
Jens Axboeafdf9352007-07-31 16:14:34 +02001671 .parent = "rate",
Jens Axboe4e991c22007-03-15 11:41:11 +01001672 },
1673 {
1674 .name = "rate_iops",
Jens Axboee01b22b2009-06-09 15:43:25 +02001675 .type = FIO_OPT_INT,
Jens Axboe581e7142009-06-09 12:47:16 +02001676 .off1 = td_var_offset(rate_iops[0]),
1677 .off2 = td_var_offset(rate_iops[1]),
Jens Axboe4e991c22007-03-15 11:41:11 +01001678 .help = "Limit IO used to this number of IO operations/sec",
1679 },
1680 {
1681 .name = "rate_iops_min",
Jens Axboee01b22b2009-06-09 15:43:25 +02001682 .type = FIO_OPT_INT,
Jens Axboe581e7142009-06-09 12:47:16 +02001683 .off1 = td_var_offset(rate_iops_min[0]),
1684 .off2 = td_var_offset(rate_iops_min[1]),
Jens Axboe4e991c22007-03-15 11:41:11 +01001685 .help = "Job must meet this rate or it will be shutdown",
Jens Axboeafdf9352007-07-31 16:14:34 +02001686 .parent = "rate_iops",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001687 },
1688 {
1689 .name = "ratecycle",
1690 .type = FIO_OPT_INT,
1691 .off1 = td_var_offset(ratecycle),
1692 .help = "Window average for rate limits (msec)",
1693 .def = "1000",
Jens Axboeafdf9352007-07-31 16:14:34 +02001694 .parent = "rate",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001695 },
1696 {
1697 .name = "invalidate",
1698 .type = FIO_OPT_BOOL,
1699 .off1 = td_var_offset(invalidate_cache),
1700 .help = "Invalidate buffer/page cache prior to running job",
1701 .def = "1",
1702 },
1703 {
1704 .name = "sync",
1705 .type = FIO_OPT_BOOL,
1706 .off1 = td_var_offset(sync_io),
1707 .help = "Use O_SYNC for buffered writes",
1708 .def = "0",
Jens Axboe67a10002007-07-31 23:12:16 +02001709 .parent = "buffered",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001710 },
1711 {
1712 .name = "bwavgtime",
1713 .type = FIO_OPT_INT,
1714 .off1 = td_var_offset(bw_avg_time),
Jens Axboe5ec10ea2008-03-06 15:42:00 +01001715 .help = "Time window over which to calculate bandwidth"
1716 " (msec)",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001717 .def = "500",
1718 },
1719 {
1720 .name = "create_serialize",
1721 .type = FIO_OPT_BOOL,
1722 .off1 = td_var_offset(create_serialize),
1723 .help = "Serialize creating of job files",
1724 .def = "1",
1725 },
1726 {
1727 .name = "create_fsync",
1728 .type = FIO_OPT_BOOL,
1729 .off1 = td_var_offset(create_fsync),
1730 .help = "Fsync file after creation",
1731 .def = "1",
1732 },
1733 {
Jens Axboe814452b2009-03-04 12:53:13 +01001734 .name = "create_on_open",
1735 .type = FIO_OPT_BOOL,
1736 .off1 = td_var_offset(create_on_open),
1737 .help = "Create files when they are opened for IO",
1738 .def = "0",
1739 },
Jens Axboe0b9d69e2009-09-11 22:29:54 +02001740 {
Zhang, Yanminafad68f2009-05-20 11:30:55 +02001741 .name = "pre_read",
1742 .type = FIO_OPT_BOOL,
1743 .off1 = td_var_offset(pre_read),
1744 .help = "Preread files before starting official testing",
1745 .def = "0",
1746 },
Jens Axboe814452b2009-03-04 12:53:13 +01001747 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001748 .name = "cpuload",
1749 .type = FIO_OPT_INT,
1750 .off1 = td_var_offset(cpuload),
1751 .help = "Use this percentage of CPU",
1752 },
1753 {
1754 .name = "cpuchunks",
1755 .type = FIO_OPT_INT,
1756 .off1 = td_var_offset(cpucycle),
1757 .help = "Length of the CPU burn cycles (usecs)",
1758 .def = "50000",
Jens Axboe67a10002007-07-31 23:12:16 +02001759 .parent = "cpuload",
Jens Axboe214e1ec2007-03-15 10:48:13 +01001760 },
1761#ifdef FIO_HAVE_CPU_AFFINITY
1762 {
1763 .name = "cpumask",
1764 .type = FIO_OPT_INT,
1765 .cb = str_cpumask_cb,
1766 .help = "CPU affinity mask",
1767 },
Jens Axboed2e268b2007-06-15 10:33:49 +02001768 {
1769 .name = "cpus_allowed",
1770 .type = FIO_OPT_STR,
1771 .cb = str_cpus_allowed_cb,
1772 .help = "Set CPUs allowed",
1773 },
Jens Axboe214e1ec2007-03-15 10:48:13 +01001774#endif
1775 {
1776 .name = "end_fsync",
1777 .type = FIO_OPT_BOOL,
1778 .off1 = td_var_offset(end_fsync),
1779 .help = "Include fsync at the end of job",
1780 .def = "0",
1781 },
1782 {
1783 .name = "fsync_on_close",
1784 .type = FIO_OPT_BOOL,
1785 .off1 = td_var_offset(fsync_on_close),
1786 .help = "fsync files on close",
1787 .def = "0",
1788 },
1789 {
1790 .name = "unlink",
1791 .type = FIO_OPT_BOOL,
1792 .off1 = td_var_offset(unlink),
1793 .help = "Unlink created files after job has completed",
1794 .def = "0",
1795 },
1796 {
1797 .name = "exitall",
1798 .type = FIO_OPT_STR_SET,
1799 .cb = str_exitall_cb,
1800 .help = "Terminate all jobs when one exits",
1801 },
1802 {
1803 .name = "stonewall",
1804 .type = FIO_OPT_STR_SET,
1805 .off1 = td_var_offset(stonewall),
1806 .help = "Insert a hard barrier between this job and previous",
1807 },
1808 {
Jens Axboeb3d62a72007-03-20 14:23:26 +01001809 .name = "new_group",
1810 .type = FIO_OPT_STR_SET,
1811 .off1 = td_var_offset(new_group),
1812 .help = "Mark the start of a new group (for reporting)",
1813 },
1814 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001815 .name = "thread",
1816 .type = FIO_OPT_STR_SET,
1817 .off1 = td_var_offset(use_thread),
1818 .help = "Use threads instead of forks",
1819 },
1820 {
1821 .name = "write_bw_log",
Jens Axboee3cedca2008-11-19 19:57:52 +01001822 .type = FIO_OPT_STR,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001823 .off1 = td_var_offset(write_bw_log),
Jens Axboee3cedca2008-11-19 19:57:52 +01001824 .cb = str_write_bw_log_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001825 .help = "Write log of bandwidth during run",
1826 },
1827 {
1828 .name = "write_lat_log",
Jens Axboee3cedca2008-11-19 19:57:52 +01001829 .type = FIO_OPT_STR,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001830 .off1 = td_var_offset(write_lat_log),
Jens Axboee3cedca2008-11-19 19:57:52 +01001831 .cb = str_write_lat_log_cb,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001832 .help = "Write log of latency during run",
1833 },
1834 {
1835 .name = "hugepage-size",
Jens Axboee01b22b2009-06-09 15:43:25 +02001836 .type = FIO_OPT_INT,
Jens Axboe214e1ec2007-03-15 10:48:13 +01001837 .off1 = td_var_offset(hugepage_size),
1838 .help = "When using hugepages, specify size of each page",
1839 .def = __stringify(FIO_HUGE_PAGE),
1840 },
1841 {
1842 .name = "group_reporting",
1843 .type = FIO_OPT_STR_SET,
1844 .off1 = td_var_offset(group_reporting),
1845 .help = "Do reporting on a per-group basis",
1846 },
1847 {
Jens Axboee9459e52007-04-17 15:46:32 +02001848 .name = "zero_buffers",
1849 .type = FIO_OPT_STR_SET,
1850 .off1 = td_var_offset(zero_buffers),
1851 .help = "Init IO buffers to all zeroes",
1852 },
Jens Axboe5973caf2008-05-21 19:52:35 +02001853 {
1854 .name = "refill_buffers",
1855 .type = FIO_OPT_STR_SET,
1856 .off1 = td_var_offset(refill_buffers),
1857 .help = "Refill IO buffers on every IO submit",
1858 },
Jens Axboe0a839f32007-04-26 09:02:34 +02001859#ifdef FIO_HAVE_DISK_UTIL
1860 {
1861 .name = "disk_util",
1862 .type = FIO_OPT_BOOL,
1863 .off1 = td_var_offset(do_disk_util),
Jens Axboef66ab3c2008-06-05 11:48:22 +02001864 .help = "Log disk utilization statistics",
Jens Axboe0a839f32007-04-26 09:02:34 +02001865 .def = "1",
1866 },
1867#endif
Jens Axboee9459e52007-04-17 15:46:32 +02001868 {
Jens Axboe993bf482008-11-14 13:04:53 +01001869 .name = "gtod_reduce",
1870 .type = FIO_OPT_BOOL,
1871 .help = "Greatly reduce number of gettimeofday() calls",
1872 .cb = str_gtod_reduce_cb,
1873 .def = "0",
1874 },
1875 {
Jens Axboe02af0982010-06-24 09:59:34 +02001876 .name = "disable_lat",
1877 .type = FIO_OPT_BOOL,
1878 .off1 = td_var_offset(disable_lat),
1879 .help = "Disable latency numbers",
1880 .parent = "gtod_reduce",
1881 .def = "0",
1882 },
1883 {
Jens Axboe9520ebb2008-10-16 21:03:27 +02001884 .name = "disable_clat",
1885 .type = FIO_OPT_BOOL,
1886 .off1 = td_var_offset(disable_clat),
1887 .help = "Disable completion latency numbers",
Jens Axboe993bf482008-11-14 13:04:53 +01001888 .parent = "gtod_reduce",
Jens Axboe9520ebb2008-10-16 21:03:27 +02001889 .def = "0",
1890 },
1891 {
1892 .name = "disable_slat",
1893 .type = FIO_OPT_BOOL,
1894 .off1 = td_var_offset(disable_slat),
1895 .help = "Disable submissionn latency numbers",
Jens Axboe993bf482008-11-14 13:04:53 +01001896 .parent = "gtod_reduce",
Jens Axboe9520ebb2008-10-16 21:03:27 +02001897 .def = "0",
1898 },
1899 {
1900 .name = "disable_bw_measurement",
1901 .type = FIO_OPT_BOOL,
1902 .off1 = td_var_offset(disable_bw),
1903 .help = "Disable bandwidth logging",
Jens Axboe993bf482008-11-14 13:04:53 +01001904 .parent = "gtod_reduce",
Jens Axboe9520ebb2008-10-16 21:03:27 +02001905 .def = "0",
1906 },
1907 {
Jens Axboebe4ecfd2008-12-08 14:10:52 +01001908 .name = "gtod_cpu",
1909 .type = FIO_OPT_INT,
1910 .cb = str_gtod_cpu_cb,
1911 .help = "Setup dedicated gettimeofday() thread on this CPU",
Jens Axboe29d43ff2009-07-01 10:42:18 +02001912 .verify = gtod_cpu_verify,
Jens Axboebe4ecfd2008-12-08 14:10:52 +01001913 },
1914 {
Radha Ramachandranf2bba182009-06-15 08:40:16 +02001915 .name = "continue_on_error",
1916 .type = FIO_OPT_BOOL,
1917 .off1 = td_var_offset(continue_on_error),
1918 .help = "Continue on non-fatal errors during I/O",
1919 .def = "0",
1920 },
1921 {
Jens Axboe9ac8a792009-11-13 21:23:07 +01001922 .name = "profile",
Jens Axboe79d16312010-03-04 12:43:20 +01001923 .type = FIO_OPT_STR_STORE,
Jens Axboe9ac8a792009-11-13 21:23:07 +01001924 .off1 = td_var_offset(profile),
Jens Axboe9ac8a792009-11-13 21:23:07 +01001925 .help = "Select a specific builtin performance test",
1926 },
1927 {
Jens Axboea696fa22009-12-04 10:05:02 +01001928 .name = "cgroup",
1929 .type = FIO_OPT_STR_STORE,
1930 .off1 = td_var_offset(cgroup),
1931 .help = "Add job to cgroup of this name",
1932 },
1933 {
1934 .name = "cgroup_weight",
1935 .type = FIO_OPT_INT,
1936 .off1 = td_var_offset(cgroup_weight),
1937 .help = "Use given weight for cgroup",
1938 .minval = 100,
1939 .maxval = 1000,
Jens Axboea696fa22009-12-04 10:05:02 +01001940 },
1941 {
Vivek Goyal7de87092010-03-31 22:55:15 +02001942 .name = "cgroup_nodelete",
1943 .type = FIO_OPT_BOOL,
1944 .off1 = td_var_offset(cgroup_nodelete),
1945 .help = "Do not delete cgroups after job completion",
1946 .def = "0",
1947 },
1948 {
Jens Axboee0b0d892009-12-08 10:10:14 +01001949 .name = "uid",
1950 .type = FIO_OPT_INT,
1951 .off1 = td_var_offset(uid),
1952 .help = "Run job with this user ID",
1953 },
1954 {
1955 .name = "gid",
1956 .type = FIO_OPT_INT,
1957 .off1 = td_var_offset(gid),
1958 .help = "Run job with this group ID",
1959 },
1960 {
Jens Axboe214e1ec2007-03-15 10:48:13 +01001961 .name = NULL,
1962 },
1963};
1964
Jens Axboe17af15d2010-04-13 10:38:16 +02001965static void add_to_lopt(struct option *lopt, struct fio_option *o,
1966 const char *name)
Jens Axboe9f817362010-03-04 14:38:10 +01001967{
Jens Axboe17af15d2010-04-13 10:38:16 +02001968 lopt->name = (char *) name;
Jens Axboe9f817362010-03-04 14:38:10 +01001969 lopt->val = FIO_GETOPT_JOB;
1970 if (o->type == FIO_OPT_STR_SET)
1971 lopt->has_arg = no_argument;
1972 else
1973 lopt->has_arg = required_argument;
1974}
1975
Jens Axboe214e1ec2007-03-15 10:48:13 +01001976void fio_options_dup_and_init(struct option *long_options)
1977{
1978 struct fio_option *o;
1979 unsigned int i;
1980
1981 options_init(options);
1982
1983 i = 0;
1984 while (long_options[i].name)
1985 i++;
1986
1987 o = &options[0];
1988 while (o->name) {
Jens Axboe17af15d2010-04-13 10:38:16 +02001989 add_to_lopt(&long_options[i], o, o->name);
1990 if (o->alias) {
1991 i++;
1992 add_to_lopt(&long_options[i], o, o->alias);
1993 }
Jens Axboe214e1ec2007-03-15 10:48:13 +01001994
1995 i++;
1996 o++;
1997 assert(i < FIO_NR_OPTIONS);
1998 }
1999}
2000
Jens Axboe74929ac2009-08-05 11:42:37 +02002001struct fio_keyword {
2002 const char *word;
2003 const char *desc;
2004 char *replace;
2005};
2006
2007static struct fio_keyword fio_keywords[] = {
2008 {
2009 .word = "$pagesize",
2010 .desc = "Page size in the system",
2011 },
2012 {
2013 .word = "$mb_memory",
2014 .desc = "Megabytes of memory online",
2015 },
2016 {
2017 .word = "$ncpus",
2018 .desc = "Number of CPUs online in the system",
2019 },
2020 {
2021 .word = NULL,
2022 },
2023};
2024
2025void fio_keywords_init(void)
2026{
Jens Axboe3b2e1462009-12-15 08:58:10 +01002027 unsigned long long mb_memory;
Jens Axboe74929ac2009-08-05 11:42:37 +02002028 char buf[128];
2029 long l;
2030
2031 sprintf(buf, "%lu", page_size);
2032 fio_keywords[0].replace = strdup(buf);
2033
Jens Axboe3b2e1462009-12-15 08:58:10 +01002034 mb_memory = os_phys_mem() / page_size;
2035 sprintf(buf, "%llu", mb_memory);
Jens Axboe74929ac2009-08-05 11:42:37 +02002036 fio_keywords[1].replace = strdup(buf);
2037
2038 l = sysconf(_SC_NPROCESSORS_ONLN);
2039 sprintf(buf, "%lu", l);
2040 fio_keywords[2].replace = strdup(buf);
2041}
2042
Jens Axboe892a6ff2009-11-13 12:19:49 +01002043#define BC_APP "bc"
2044
2045static char *bc_calc(char *str)
2046{
2047 char *buf, *tmp, opt[80];
2048 FILE *f;
2049 int ret;
2050
2051 /*
2052 * No math, just return string
2053 */
2054 if (!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') &&
2055 !strchr(str, '/'))
2056 return str;
2057
2058 /*
2059 * Split option from value, we only need to calculate the value
2060 */
2061 tmp = strchr(str, '=');
2062 if (!tmp)
2063 return str;
2064
2065 tmp++;
Jens Axboe9ac8a792009-11-13 21:23:07 +01002066 memset(opt, 0, sizeof(opt));
Jens Axboe892a6ff2009-11-13 12:19:49 +01002067 strncpy(opt, str, tmp - str);
2068
2069 buf = malloc(128);
2070
2071 sprintf(buf, "which %s > /dev/null", BC_APP);
2072 if (system(buf)) {
2073 log_err("fio: bc is needed for performing math\n");
2074 free(buf);
2075 return NULL;
2076 }
2077
2078 sprintf(buf, "echo %s | %s", tmp, BC_APP);
2079 f = popen(buf, "r");
2080 if (!f) {
2081 free(buf);
2082 return NULL;
2083 }
2084
2085 ret = fread(buf, 1, 128, f);
2086 if (ret <= 0) {
2087 free(buf);
2088 return NULL;
2089 }
2090
2091 buf[ret - 1] = '\0';
2092 strcat(opt, buf);
2093 strcpy(buf, opt);
2094 pclose(f);
2095 free(str);
2096 return buf;
2097}
2098
Jens Axboe74929ac2009-08-05 11:42:37 +02002099/*
2100 * Look for reserved variable names and replace them with real values
2101 */
2102static char *fio_keyword_replace(char *opt)
2103{
2104 char *s;
2105 int i;
2106
2107 for (i = 0; fio_keywords[i].word != NULL; i++) {
2108 struct fio_keyword *kw = &fio_keywords[i];
2109
2110 while ((s = strstr(opt, kw->word)) != NULL) {
2111 char *new = malloc(strlen(opt) + 1);
2112 char *o_org = opt;
2113 int olen = s - opt;
2114 int len;
2115
2116 /*
2117 * Copy part of the string before the keyword and
2118 * sprintf() the replacement after it.
2119 */
2120 memcpy(new, opt, olen);
2121 len = sprintf(new + olen, "%s", kw->replace);
2122
2123 /*
2124 * If there's more in the original string, copy that
2125 * in too
2126 */
2127 opt += strlen(kw->word) + olen;
2128 if (strlen(opt))
2129 memcpy(new + olen + len, opt, opt - o_org - 1);
2130
2131 /*
2132 * replace opt and free the old opt
2133 */
2134 opt = new;
Jens Axboe9ac8a792009-11-13 21:23:07 +01002135 //free(o_org);
Jens Axboe7a958bd2009-11-13 12:33:54 +01002136
2137 /*
2138 * Check for potential math and invoke bc, if possible
2139 */
2140 opt = bc_calc(opt);
Jens Axboe74929ac2009-08-05 11:42:37 +02002141 }
2142 }
2143
Jens Axboe7a958bd2009-11-13 12:33:54 +01002144 return opt;
Jens Axboe74929ac2009-08-05 11:42:37 +02002145}
2146
Jens Axboe3b8b7132008-06-10 19:46:23 +02002147int fio_options_parse(struct thread_data *td, char **opts, int num_opts)
Jens Axboe214e1ec2007-03-15 10:48:13 +01002148{
Jens Axboe3b8b7132008-06-10 19:46:23 +02002149 int i, ret;
2150
2151 sort_options(opts, options, num_opts);
2152
Jens Axboe74929ac2009-08-05 11:42:37 +02002153 for (ret = 0, i = 0; i < num_opts; i++) {
2154 opts[i] = fio_keyword_replace(opts[i]);
Jens Axboe07b32322010-03-05 09:48:44 +01002155 ret |= parse_option(opts[i], options, td);
Jens Axboe74929ac2009-08-05 11:42:37 +02002156 }
Jens Axboe3b8b7132008-06-10 19:46:23 +02002157
2158 return ret;
Jens Axboe214e1ec2007-03-15 10:48:13 +01002159}
2160
2161int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val)
2162{
Jens Axboe07b32322010-03-05 09:48:44 +01002163 return parse_cmd_option(opt, val, options, td);
Jens Axboe214e1ec2007-03-15 10:48:13 +01002164}
2165
2166void fio_fill_default_options(struct thread_data *td)
2167{
2168 fill_default_options(td, options);
2169}
2170
2171int fio_show_option_help(const char *opt)
2172{
Jens Axboe07b32322010-03-05 09:48:44 +01002173 return show_cmd_help(options, opt);
Jens Axboe214e1ec2007-03-15 10:48:13 +01002174}
Jens Axboed23bb322007-03-23 15:57:56 +01002175
2176static void __options_mem(struct thread_data *td, int alloc)
2177{
2178 struct thread_options *o = &td->o;
2179 struct fio_option *opt;
2180 char **ptr;
2181 int i;
2182
2183 for (i = 0, opt = &options[0]; opt->name; i++, opt = &options[i]) {
2184 if (opt->type != FIO_OPT_STR_STORE)
2185 continue;
2186
2187 ptr = (void *) o + opt->off1;
2188 if (*ptr) {
2189 if (alloc)
2190 *ptr = strdup(*ptr);
2191 else {
2192 free(*ptr);
2193 *ptr = NULL;
2194 }
2195 }
2196 }
2197}
2198
2199/*
2200 * dupe FIO_OPT_STR_STORE options
2201 */
2202void options_mem_dupe(struct thread_data *td)
2203{
2204 __options_mem(td, 1);
2205}
2206
Jens Axboe22d66212007-03-27 20:06:25 +02002207void options_mem_free(struct thread_data fio_unused *td)
Jens Axboed23bb322007-03-23 15:57:56 +01002208{
Jens Axboe22d66212007-03-27 20:06:25 +02002209#if 0
Jens Axboed23bb322007-03-23 15:57:56 +01002210 __options_mem(td, 0);
Jens Axboe22d66212007-03-27 20:06:25 +02002211#endif
Jens Axboed23bb322007-03-23 15:57:56 +01002212}
Jens Axboed6978a32009-07-18 21:04:09 +02002213
2214unsigned int fio_get_kb_base(void *data)
2215{
2216 struct thread_data *td = data;
2217 unsigned int kb_base = 0;
2218
2219 if (td)
2220 kb_base = td->o.kb_base;
2221 if (!kb_base)
2222 kb_base = 1024;
2223
2224 return kb_base;
2225}
Jens Axboe9f988e22010-03-04 10:42:38 +01002226
Jens Axboe07b32322010-03-05 09:48:44 +01002227int add_option(struct fio_option *o)
Jens Axboe9f988e22010-03-04 10:42:38 +01002228{
Jens Axboe07b32322010-03-05 09:48:44 +01002229 struct fio_option *__o;
2230 int opt_index = 0;
2231
2232 __o = options;
2233 while (__o->name) {
2234 opt_index++;
2235 __o++;
2236 }
2237
2238 memcpy(&options[opt_index], o, sizeof(*o));
2239 return 0;
Jens Axboe9f988e22010-03-04 10:42:38 +01002240}
Jens Axboee2de69d2010-03-04 14:05:48 +01002241
Jens Axboe07b32322010-03-05 09:48:44 +01002242void invalidate_profile_options(const char *prof_name)
Jens Axboee2de69d2010-03-04 14:05:48 +01002243{
Jens Axboe07b32322010-03-05 09:48:44 +01002244 struct fio_option *o;
Jens Axboee2de69d2010-03-04 14:05:48 +01002245
Jens Axboe07b32322010-03-05 09:48:44 +01002246 o = options;
2247 while (o->name) {
2248 if (o->prof_name && !strcmp(o->prof_name, prof_name)) {
2249 o->type = FIO_OPT_INVALID;
2250 o->prof_name = NULL;
2251 }
2252 o++;
Jens Axboee2de69d2010-03-04 14:05:48 +01002253 }
2254}
Jens Axboef5b6bb82010-03-05 10:09:59 +01002255
2256void add_opt_posval(const char *optname, const char *ival, const char *help)
2257{
2258 struct fio_option *o;
2259 unsigned int i;
2260
2261 o = find_option(options, optname);
2262 if (!o)
2263 return;
2264
2265 for (i = 0; i < PARSE_MAX_VP; i++) {
2266 if (o->posval[i].ival)
2267 continue;
2268
2269 o->posval[i].ival = ival;
2270 o->posval[i].help = help;
2271 break;
2272 }
2273}
2274
2275void del_opt_posval(const char *optname, const char *ival)
2276{
2277 struct fio_option *o;
2278 unsigned int i;
2279
2280 o = find_option(options, optname);
2281 if (!o)
2282 return;
2283
2284 for (i = 0; i < PARSE_MAX_VP; i++) {
2285 if (!o->posval[i].ival)
2286 continue;
2287 if (strcmp(o->posval[i].ival, ival))
2288 continue;
2289
2290 o->posval[i].ival = NULL;
2291 o->posval[i].help = NULL;
2292 }
2293}