Commit | Line | Data |
---|---|---|
214e1eca JA |
1 | #include <stdio.h> |
2 | #include <stdlib.h> | |
3 | #include <unistd.h> | |
4 | #include <ctype.h> | |
5 | #include <string.h> | |
6 | #include <getopt.h> | |
7 | #include <assert.h> | |
921c766f | 8 | #include <libgen.h> |
214e1eca JA |
9 | |
10 | #include "fio.h" | |
11 | #include "parse.h" | |
90059d65 | 12 | #include "fls.h" |
214e1eca | 13 | |
2dc1bbeb | 14 | #define td_var_offset(var) ((size_t) &((struct thread_options *)0)->var) |
214e1eca JA |
15 | |
16 | /* | |
17 | * Check if mmap/mmaphuge has a :/foo/bar/file at the end. If so, return that. | |
18 | */ | |
19 | static char *get_opt_postfix(const char *str) | |
20 | { | |
21 | char *p = strstr(str, ":"); | |
22 | ||
23 | if (!p) | |
24 | return NULL; | |
25 | ||
26 | p++; | |
27 | strip_blank_front(&p); | |
28 | strip_blank_end(p); | |
29 | return strdup(p); | |
30 | } | |
31 | ||
564ca972 JA |
32 | static int bs_cmp(const void *p1, const void *p2) |
33 | { | |
34 | const struct bssplit *bsp1 = p1; | |
35 | const struct bssplit *bsp2 = p2; | |
36 | ||
37 | return bsp1->perc < bsp2->perc; | |
38 | } | |
39 | ||
40 | static int str_bssplit_cb(void *data, const char *input) | |
41 | { | |
42 | struct thread_data *td = data; | |
43 | char *fname, *str, *p; | |
44 | unsigned int i, perc, perc_missing; | |
45 | unsigned int max_bs, min_bs; | |
46 | long long val; | |
47 | ||
48 | p = str = strdup(input); | |
49 | ||
50 | strip_blank_front(&str); | |
51 | strip_blank_end(str); | |
52 | ||
53 | td->o.bssplit_nr = 4; | |
54 | td->o.bssplit = malloc(4 * sizeof(struct bssplit)); | |
55 | ||
56 | i = 0; | |
57 | max_bs = 0; | |
58 | min_bs = -1; | |
59 | while ((fname = strsep(&str, ":")) != NULL) { | |
60 | char *perc_str; | |
61 | ||
62 | if (!strlen(fname)) | |
63 | break; | |
64 | ||
65 | /* | |
66 | * grow struct buffer, if needed | |
67 | */ | |
68 | if (i == td->o.bssplit_nr) { | |
69 | td->o.bssplit_nr <<= 1; | |
5ec10eaa JA |
70 | td->o.bssplit = realloc(td->o.bssplit, |
71 | td->o.bssplit_nr | |
72 | * sizeof(struct bssplit)); | |
564ca972 JA |
73 | } |
74 | ||
75 | perc_str = strstr(fname, "/"); | |
76 | if (perc_str) { | |
77 | *perc_str = '\0'; | |
78 | perc_str++; | |
79 | perc = atoi(perc_str); | |
80 | if (perc > 100) | |
81 | perc = 100; | |
82 | else if (!perc) | |
83 | perc = -1; | |
84 | } else | |
85 | perc = -1; | |
86 | ||
87 | if (str_to_decimal(fname, &val, 1)) { | |
88 | log_err("fio: bssplit conversion failed\n"); | |
89 | free(td->o.bssplit); | |
90 | return 1; | |
91 | } | |
92 | ||
93 | if (val > max_bs) | |
94 | max_bs = val; | |
95 | if (val < min_bs) | |
96 | min_bs = val; | |
97 | ||
98 | td->o.bssplit[i].bs = val; | |
99 | td->o.bssplit[i].perc = perc; | |
100 | i++; | |
101 | } | |
102 | ||
103 | td->o.bssplit_nr = i; | |
104 | ||
105 | /* | |
106 | * Now check if the percentages add up, and how much is missing | |
107 | */ | |
108 | perc = perc_missing = 0; | |
109 | for (i = 0; i < td->o.bssplit_nr; i++) { | |
110 | struct bssplit *bsp = &td->o.bssplit[i]; | |
111 | ||
112 | if (bsp->perc == (unsigned char) -1) | |
113 | perc_missing++; | |
114 | else | |
115 | perc += bsp->perc; | |
116 | } | |
117 | ||
118 | if (perc > 100) { | |
119 | log_err("fio: bssplit percentages add to more than 100%%\n"); | |
120 | free(td->o.bssplit); | |
121 | return 1; | |
122 | } | |
123 | /* | |
124 | * If values didn't have a percentage set, divide the remains between | |
125 | * them. | |
126 | */ | |
127 | if (perc_missing) { | |
128 | for (i = 0; i < td->o.bssplit_nr; i++) { | |
129 | struct bssplit *bsp = &td->o.bssplit[i]; | |
130 | ||
131 | if (bsp->perc == (unsigned char) -1) | |
132 | bsp->perc = (100 - perc) / perc_missing; | |
133 | } | |
134 | } | |
135 | ||
136 | td->o.min_bs[DDIR_READ] = td->o.min_bs[DDIR_WRITE] = min_bs; | |
137 | td->o.max_bs[DDIR_READ] = td->o.max_bs[DDIR_WRITE] = max_bs; | |
138 | ||
139 | /* | |
140 | * now sort based on percentages, for ease of lookup | |
141 | */ | |
142 | qsort(td->o.bssplit, td->o.bssplit_nr, sizeof(struct bssplit), bs_cmp); | |
143 | ||
144 | free(p); | |
145 | return 0; | |
146 | } | |
147 | ||
211097b2 JA |
148 | static int str_rw_cb(void *data, const char *str) |
149 | { | |
150 | struct thread_data *td = data; | |
151 | char *nr = get_opt_postfix(str); | |
152 | ||
fafdba3c | 153 | td->o.ddir_nr = 1; |
211097b2 JA |
154 | if (nr) |
155 | td->o.ddir_nr = atoi(nr); | |
156 | ||
211097b2 JA |
157 | return 0; |
158 | } | |
159 | ||
214e1eca JA |
160 | static int str_mem_cb(void *data, const char *mem) |
161 | { | |
162 | struct thread_data *td = data; | |
163 | ||
2dc1bbeb | 164 | if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP) { |
214e1eca | 165 | td->mmapfile = get_opt_postfix(mem); |
2dc1bbeb | 166 | if (td->o.mem_type == MEM_MMAPHUGE && !td->mmapfile) { |
214e1eca JA |
167 | log_err("fio: mmaphuge:/path/to/file\n"); |
168 | return 1; | |
169 | } | |
170 | } | |
171 | ||
172 | return 0; | |
173 | } | |
174 | ||
175 | static int str_lockmem_cb(void fio_unused *data, unsigned long *val) | |
176 | { | |
177 | mlock_size = *val; | |
178 | return 0; | |
179 | } | |
180 | ||
181 | #ifdef FIO_HAVE_IOPRIO | |
182 | static int str_prioclass_cb(void *data, unsigned int *val) | |
183 | { | |
184 | struct thread_data *td = data; | |
6cefbe33 JA |
185 | unsigned short mask; |
186 | ||
187 | /* | |
188 | * mask off old class bits, str_prio_cb() may have set a default class | |
189 | */ | |
190 | mask = (1 << IOPRIO_CLASS_SHIFT) - 1; | |
191 | td->ioprio &= mask; | |
214e1eca JA |
192 | |
193 | td->ioprio |= *val << IOPRIO_CLASS_SHIFT; | |
ac684785 | 194 | td->ioprio_set = 1; |
214e1eca JA |
195 | return 0; |
196 | } | |
197 | ||
198 | static int str_prio_cb(void *data, unsigned int *val) | |
199 | { | |
200 | struct thread_data *td = data; | |
201 | ||
202 | td->ioprio |= *val; | |
6cefbe33 JA |
203 | |
204 | /* | |
205 | * If no class is set, assume BE | |
206 | */ | |
207 | if ((td->ioprio >> IOPRIO_CLASS_SHIFT) == 0) | |
208 | td->ioprio |= IOPRIO_CLASS_BE << IOPRIO_CLASS_SHIFT; | |
209 | ||
ac684785 | 210 | td->ioprio_set = 1; |
214e1eca JA |
211 | return 0; |
212 | } | |
213 | #endif | |
214 | ||
215 | static int str_exitall_cb(void) | |
216 | { | |
217 | exitall_on_terminate = 1; | |
218 | return 0; | |
219 | } | |
220 | ||
214e1eca | 221 | #ifdef FIO_HAVE_CPU_AFFINITY |
d2e268b0 JA |
222 | static int str_cpumask_cb(void *data, unsigned int *val) |
223 | { | |
224 | struct thread_data *td = data; | |
214e1eca JA |
225 | unsigned int i; |
226 | ||
d2e268b0 | 227 | CPU_ZERO(&td->o.cpumask); |
214e1eca | 228 | |
e600f7f1 | 229 | for (i = 0; i < sizeof(int) * 8; i++) |
d2e268b0 JA |
230 | if ((1 << i) & *val) |
231 | CPU_SET(*val, &td->o.cpumask); | |
232 | ||
233 | td->o.cpumask_set = 1; | |
234 | return 0; | |
214e1eca JA |
235 | } |
236 | ||
d2e268b0 | 237 | static int str_cpus_allowed_cb(void *data, const char *input) |
214e1eca JA |
238 | { |
239 | struct thread_data *td = data; | |
d2e268b0 JA |
240 | char *cpu, *str, *p; |
241 | ||
242 | CPU_ZERO(&td->o.cpumask); | |
243 | ||
244 | p = str = strdup(input); | |
214e1eca | 245 | |
d2e268b0 JA |
246 | strip_blank_front(&str); |
247 | strip_blank_end(str); | |
248 | ||
249 | while ((cpu = strsep(&str, ",")) != NULL) { | |
250 | if (!strlen(cpu)) | |
251 | break; | |
252 | CPU_SET(atoi(cpu), &td->o.cpumask); | |
253 | } | |
254 | ||
255 | free(p); | |
375b2695 | 256 | td->o.cpumask_set = 1; |
214e1eca JA |
257 | return 0; |
258 | } | |
d2e268b0 | 259 | #endif |
214e1eca JA |
260 | |
261 | static int str_fst_cb(void *data, const char *str) | |
262 | { | |
263 | struct thread_data *td = data; | |
264 | char *nr = get_opt_postfix(str); | |
265 | ||
266 | td->file_service_nr = 1; | |
267 | if (nr) | |
268 | td->file_service_nr = atoi(nr); | |
269 | ||
270 | return 0; | |
271 | } | |
272 | ||
921c766f JA |
273 | static int check_dir(struct thread_data *td, char *fname) |
274 | { | |
275 | char file[PATH_MAX], *dir; | |
276 | struct stat sb; | |
bc838919 | 277 | int elen = 0; |
921c766f | 278 | |
bc838919 JA |
279 | if (td->o.directory) { |
280 | strcpy(file, td->o.directory); | |
281 | elen = strlen(file); | |
282 | } | |
283 | ||
284 | sprintf(file + elen, "/%s", fname); | |
921c766f JA |
285 | dir = dirname(file); |
286 | ||
287 | if (lstat(dir, &sb) < 0) { | |
288 | int ret = errno; | |
289 | ||
290 | log_err("fio: %s is not a directory\n", dir); | |
291 | td_verror(td, ret, "lstat"); | |
292 | return 1; | |
293 | } | |
294 | ||
295 | if (!S_ISDIR(sb.st_mode)) { | |
296 | log_err("fio: %s is not a directory\n", dir); | |
297 | return 1; | |
298 | } | |
299 | ||
300 | return 0; | |
301 | } | |
302 | ||
214e1eca JA |
303 | static int str_filename_cb(void *data, const char *input) |
304 | { | |
305 | struct thread_data *td = data; | |
306 | char *fname, *str, *p; | |
307 | ||
308 | p = str = strdup(input); | |
309 | ||
310 | strip_blank_front(&str); | |
311 | strip_blank_end(str); | |
312 | ||
313 | if (!td->files_index) | |
2dc1bbeb | 314 | td->o.nr_files = 0; |
214e1eca JA |
315 | |
316 | while ((fname = strsep(&str, ":")) != NULL) { | |
317 | if (!strlen(fname)) | |
318 | break; | |
921c766f JA |
319 | if (check_dir(td, fname)) { |
320 | free(p); | |
321 | return 1; | |
322 | } | |
214e1eca | 323 | add_file(td, fname); |
2dc1bbeb | 324 | td->o.nr_files++; |
214e1eca JA |
325 | } |
326 | ||
327 | free(p); | |
328 | return 0; | |
329 | } | |
330 | ||
331 | static int str_directory_cb(void *data, const char fio_unused *str) | |
332 | { | |
333 | struct thread_data *td = data; | |
334 | struct stat sb; | |
335 | ||
2dc1bbeb | 336 | if (lstat(td->o.directory, &sb) < 0) { |
921c766f JA |
337 | int ret = errno; |
338 | ||
2dc1bbeb | 339 | log_err("fio: %s is not a directory\n", td->o.directory); |
921c766f | 340 | td_verror(td, ret, "lstat"); |
214e1eca JA |
341 | return 1; |
342 | } | |
343 | if (!S_ISDIR(sb.st_mode)) { | |
2dc1bbeb | 344 | log_err("fio: %s is not a directory\n", td->o.directory); |
214e1eca JA |
345 | return 1; |
346 | } | |
347 | ||
348 | return 0; | |
349 | } | |
350 | ||
351 | static int str_opendir_cb(void *data, const char fio_unused *str) | |
352 | { | |
353 | struct thread_data *td = data; | |
354 | ||
355 | if (!td->files_index) | |
2dc1bbeb | 356 | td->o.nr_files = 0; |
214e1eca | 357 | |
2dc1bbeb | 358 | return add_dir_files(td, td->o.opendir); |
214e1eca JA |
359 | } |
360 | ||
a59e170d | 361 | static int str_verify_offset_cb(void *data, unsigned int *off) |
546a9142 SL |
362 | { |
363 | struct thread_data *td = data; | |
a59e170d | 364 | |
546a9142 | 365 | if (*off && *off < sizeof(struct verify_header)) { |
a59e170d | 366 | log_err("fio: verify_offset too small\n"); |
546a9142 SL |
367 | return 1; |
368 | } | |
a59e170d JA |
369 | |
370 | td->o.verify_offset = *off; | |
546a9142 SL |
371 | return 0; |
372 | } | |
373 | ||
e28218f3 | 374 | static int str_verify_pattern_cb(void *data, unsigned int *off) |
90059d65 JA |
375 | { |
376 | struct thread_data *td = data; | |
e28218f3 | 377 | unsigned int msb; |
90059d65 | 378 | |
e28218f3 | 379 | msb = fls(*off); |
90059d65 JA |
380 | if (msb <= 8) |
381 | td->o.verify_pattern_bytes = 1; | |
382 | else if (msb <= 16) | |
383 | td->o.verify_pattern_bytes = 2; | |
384 | else if (msb <= 24) | |
385 | td->o.verify_pattern_bytes = 3; | |
386 | else | |
387 | td->o.verify_pattern_bytes = 4; | |
388 | ||
e28218f3 | 389 | td->o.verify_pattern = *off; |
90059d65 JA |
390 | return 0; |
391 | } | |
214e1eca | 392 | |
4d4e80f2 JA |
393 | static int str_lockfile_cb(void *data, const char *str) |
394 | { | |
395 | struct thread_data *td = data; | |
396 | char *nr = get_opt_postfix(str); | |
397 | ||
398 | td->o.lockfile_batch = 1; | |
399 | if (nr) | |
400 | td->o.lockfile_batch = atoi(nr); | |
401 | ||
402 | return 0; | |
403 | } | |
404 | ||
214e1eca JA |
405 | #define __stringify_1(x) #x |
406 | #define __stringify(x) __stringify_1(x) | |
407 | ||
408 | /* | |
409 | * Map of job/command line options | |
410 | */ | |
411 | static struct fio_option options[] = { | |
412 | { | |
413 | .name = "description", | |
414 | .type = FIO_OPT_STR_STORE, | |
415 | .off1 = td_var_offset(description), | |
416 | .help = "Text job description", | |
417 | }, | |
418 | { | |
419 | .name = "name", | |
420 | .type = FIO_OPT_STR_STORE, | |
421 | .off1 = td_var_offset(name), | |
422 | .help = "Name of this job", | |
423 | }, | |
424 | { | |
425 | .name = "directory", | |
426 | .type = FIO_OPT_STR_STORE, | |
427 | .off1 = td_var_offset(directory), | |
428 | .cb = str_directory_cb, | |
429 | .help = "Directory to store files in", | |
430 | }, | |
431 | { | |
432 | .name = "filename", | |
433 | .type = FIO_OPT_STR_STORE, | |
434 | .off1 = td_var_offset(filename), | |
435 | .cb = str_filename_cb, | |
436 | .help = "File(s) to use for the workload", | |
437 | }, | |
29c1349f JA |
438 | { |
439 | .name = "lockfile", | |
4d4e80f2 JA |
440 | .type = FIO_OPT_STR, |
441 | .cb = str_lockfile_cb, | |
442 | .off1 = td_var_offset(file_lock_mode), | |
29c1349f JA |
443 | .help = "Lock file when doing IO to it", |
444 | .parent = "filename", | |
4d4e80f2 JA |
445 | .def = "none", |
446 | .posval = { | |
447 | { .ival = "none", | |
448 | .oval = FILE_LOCK_NONE, | |
449 | .help = "No file locking", | |
450 | }, | |
451 | { .ival = "exclusive", | |
452 | .oval = FILE_LOCK_EXCLUSIVE, | |
453 | .help = "Exclusive file lock", | |
454 | }, | |
455 | { | |
456 | .ival = "readwrite", | |
457 | .oval = FILE_LOCK_READWRITE, | |
458 | .help = "Read vs write lock", | |
459 | }, | |
460 | }, | |
29c1349f | 461 | }, |
214e1eca JA |
462 | { |
463 | .name = "opendir", | |
464 | .type = FIO_OPT_STR_STORE, | |
465 | .off1 = td_var_offset(opendir), | |
466 | .cb = str_opendir_cb, | |
467 | .help = "Recursively add files from this directory and down", | |
468 | }, | |
469 | { | |
470 | .name = "rw", | |
d3aad8f2 | 471 | .alias = "readwrite", |
214e1eca | 472 | .type = FIO_OPT_STR, |
211097b2 | 473 | .cb = str_rw_cb, |
214e1eca JA |
474 | .off1 = td_var_offset(td_ddir), |
475 | .help = "IO direction", | |
476 | .def = "read", | |
477 | .posval = { | |
478 | { .ival = "read", | |
479 | .oval = TD_DDIR_READ, | |
480 | .help = "Sequential read", | |
481 | }, | |
482 | { .ival = "write", | |
483 | .oval = TD_DDIR_WRITE, | |
484 | .help = "Sequential write", | |
485 | }, | |
486 | { .ival = "randread", | |
487 | .oval = TD_DDIR_RANDREAD, | |
488 | .help = "Random read", | |
489 | }, | |
490 | { .ival = "randwrite", | |
491 | .oval = TD_DDIR_RANDWRITE, | |
492 | .help = "Random write", | |
493 | }, | |
494 | { .ival = "rw", | |
495 | .oval = TD_DDIR_RW, | |
496 | .help = "Sequential read and write mix", | |
497 | }, | |
498 | { .ival = "randrw", | |
499 | .oval = TD_DDIR_RANDRW, | |
500 | .help = "Random read and write mix" | |
501 | }, | |
502 | }, | |
503 | }, | |
504 | { | |
505 | .name = "ioengine", | |
506 | .type = FIO_OPT_STR_STORE, | |
507 | .off1 = td_var_offset(ioengine), | |
508 | .help = "IO engine to use", | |
509 | .def = "sync", | |
510 | .posval = { | |
511 | { .ival = "sync", | |
512 | .help = "Use read/write", | |
513 | }, | |
a31041ea | 514 | { .ival = "psync", |
515 | .help = "Use pread/pwrite", | |
516 | }, | |
1d2af02a JA |
517 | { .ival = "vsync", |
518 | .help = "Use readv/writev", | |
519 | }, | |
214e1eca JA |
520 | #ifdef FIO_HAVE_LIBAIO |
521 | { .ival = "libaio", | |
522 | .help = "Linux native asynchronous IO", | |
523 | }, | |
524 | #endif | |
525 | #ifdef FIO_HAVE_POSIXAIO | |
526 | { .ival = "posixaio", | |
527 | .help = "POSIX asynchronous IO", | |
528 | }, | |
529 | #endif | |
530 | { .ival = "mmap", | |
531 | .help = "Memory mapped IO", | |
532 | }, | |
533 | #ifdef FIO_HAVE_SPLICE | |
534 | { .ival = "splice", | |
535 | .help = "splice/vmsplice based IO", | |
536 | }, | |
9cce02e8 JA |
537 | { .ival = "netsplice", |
538 | .help = "splice/vmsplice to/from the network", | |
539 | }, | |
214e1eca JA |
540 | #endif |
541 | #ifdef FIO_HAVE_SGIO | |
542 | { .ival = "sg", | |
543 | .help = "SCSI generic v3 IO", | |
544 | }, | |
545 | #endif | |
546 | { .ival = "null", | |
547 | .help = "Testing engine (no data transfer)", | |
548 | }, | |
549 | { .ival = "net", | |
550 | .help = "Network IO", | |
551 | }, | |
552 | #ifdef FIO_HAVE_SYSLET | |
553 | { .ival = "syslet-rw", | |
554 | .help = "syslet enabled async pread/pwrite IO", | |
555 | }, | |
556 | #endif | |
557 | { .ival = "cpuio", | |
558 | .help = "CPU cycler burner engine", | |
559 | }, | |
b8c82a46 JA |
560 | #ifdef FIO_HAVE_GUASI |
561 | { .ival = "guasi", | |
562 | .help = "GUASI IO engine", | |
563 | }, | |
564 | #endif | |
214e1eca JA |
565 | { .ival = "external", |
566 | .help = "Load external engine (append name)", | |
567 | }, | |
568 | }, | |
569 | }, | |
570 | { | |
571 | .name = "iodepth", | |
572 | .type = FIO_OPT_INT, | |
573 | .off1 = td_var_offset(iodepth), | |
574 | .help = "Amount of IO buffers to keep in flight", | |
757aff4f | 575 | .minval = 1, |
214e1eca JA |
576 | .def = "1", |
577 | }, | |
578 | { | |
579 | .name = "iodepth_batch", | |
580 | .type = FIO_OPT_INT, | |
581 | .off1 = td_var_offset(iodepth_batch), | |
582 | .help = "Number of IO to submit in one go", | |
afdf9352 | 583 | .parent = "iodepth", |
a2e6f8ac JA |
584 | .minval = 1, |
585 | .def = "1", | |
214e1eca JA |
586 | }, |
587 | { | |
588 | .name = "iodepth_low", | |
589 | .type = FIO_OPT_INT, | |
590 | .off1 = td_var_offset(iodepth_low), | |
591 | .help = "Low water mark for queuing depth", | |
afdf9352 | 592 | .parent = "iodepth", |
214e1eca JA |
593 | }, |
594 | { | |
595 | .name = "size", | |
596 | .type = FIO_OPT_STR_VAL, | |
2dc1bbeb | 597 | .off1 = td_var_offset(size), |
c3edbdba | 598 | .minval = 1, |
214e1eca JA |
599 | .help = "Total size of device or files", |
600 | }, | |
aa31f1f1 SL |
601 | { |
602 | .name = "fill_device", | |
603 | .type = FIO_OPT_BOOL, | |
604 | .off1 = td_var_offset(fill_device), | |
605 | .help = "Write until an ENOSPC error occurs", | |
606 | .def = "0", | |
607 | }, | |
214e1eca JA |
608 | { |
609 | .name = "filesize", | |
610 | .type = FIO_OPT_STR_VAL, | |
611 | .off1 = td_var_offset(file_size_low), | |
612 | .off2 = td_var_offset(file_size_high), | |
c3edbdba | 613 | .minval = 1, |
214e1eca JA |
614 | .help = "Size of individual files", |
615 | }, | |
67a1000f JA |
616 | { |
617 | .name = "offset", | |
618 | .alias = "fileoffset", | |
619 | .type = FIO_OPT_STR_VAL, | |
620 | .off1 = td_var_offset(start_offset), | |
621 | .help = "Start IO from this offset", | |
622 | .def = "0", | |
623 | }, | |
214e1eca JA |
624 | { |
625 | .name = "bs", | |
d3aad8f2 | 626 | .alias = "blocksize", |
214e1eca JA |
627 | .type = FIO_OPT_STR_VAL_INT, |
628 | .off1 = td_var_offset(bs[DDIR_READ]), | |
629 | .off2 = td_var_offset(bs[DDIR_WRITE]), | |
c3edbdba | 630 | .minval = 1, |
214e1eca JA |
631 | .help = "Block size unit", |
632 | .def = "4k", | |
67a1000f | 633 | .parent = "rw", |
214e1eca JA |
634 | }, |
635 | { | |
636 | .name = "bsrange", | |
d3aad8f2 | 637 | .alias = "blocksize_range", |
214e1eca JA |
638 | .type = FIO_OPT_RANGE, |
639 | .off1 = td_var_offset(min_bs[DDIR_READ]), | |
640 | .off2 = td_var_offset(max_bs[DDIR_READ]), | |
641 | .off3 = td_var_offset(min_bs[DDIR_WRITE]), | |
642 | .off4 = td_var_offset(max_bs[DDIR_WRITE]), | |
c3edbdba | 643 | .minval = 1, |
214e1eca | 644 | .help = "Set block size range (in more detail than bs)", |
67a1000f | 645 | .parent = "rw", |
214e1eca | 646 | }, |
564ca972 JA |
647 | { |
648 | .name = "bssplit", | |
649 | .type = FIO_OPT_STR, | |
650 | .cb = str_bssplit_cb, | |
651 | .help = "Set a specific mix of block sizes", | |
652 | .parent = "rw", | |
653 | }, | |
214e1eca JA |
654 | { |
655 | .name = "bs_unaligned", | |
d3aad8f2 | 656 | .alias = "blocksize_unaligned", |
214e1eca JA |
657 | .type = FIO_OPT_STR_SET, |
658 | .off1 = td_var_offset(bs_unaligned), | |
659 | .help = "Don't sector align IO buffer sizes", | |
67a1000f | 660 | .parent = "rw", |
214e1eca JA |
661 | }, |
662 | { | |
663 | .name = "randrepeat", | |
664 | .type = FIO_OPT_BOOL, | |
665 | .off1 = td_var_offset(rand_repeatable), | |
666 | .help = "Use repeatable random IO pattern", | |
667 | .def = "1", | |
67a1000f | 668 | .parent = "rw", |
214e1eca JA |
669 | }, |
670 | { | |
671 | .name = "norandommap", | |
672 | .type = FIO_OPT_STR_SET, | |
673 | .off1 = td_var_offset(norandommap), | |
674 | .help = "Accept potential duplicate random blocks", | |
67a1000f | 675 | .parent = "rw", |
214e1eca | 676 | }, |
2b386d25 JA |
677 | { |
678 | .name = "softrandommap", | |
679 | .type = FIO_OPT_BOOL, | |
680 | .off1 = td_var_offset(softrandommap), | |
681 | .help = "Allow randommap to fail and continue witout", | |
682 | .parent = "norandommap", | |
683 | .def = "0", | |
684 | }, | |
214e1eca JA |
685 | { |
686 | .name = "nrfiles", | |
687 | .type = FIO_OPT_INT, | |
688 | .off1 = td_var_offset(nr_files), | |
689 | .help = "Split job workload between this number of files", | |
690 | .def = "1", | |
691 | }, | |
692 | { | |
693 | .name = "openfiles", | |
694 | .type = FIO_OPT_INT, | |
695 | .off1 = td_var_offset(open_files), | |
696 | .help = "Number of files to keep open at the same time", | |
697 | }, | |
698 | { | |
699 | .name = "file_service_type", | |
700 | .type = FIO_OPT_STR, | |
701 | .cb = str_fst_cb, | |
702 | .off1 = td_var_offset(file_service_type), | |
703 | .help = "How to select which file to service next", | |
704 | .def = "roundrobin", | |
705 | .posval = { | |
706 | { .ival = "random", | |
707 | .oval = FIO_FSERVICE_RANDOM, | |
708 | .help = "Choose a file at random", | |
709 | }, | |
710 | { .ival = "roundrobin", | |
711 | .oval = FIO_FSERVICE_RR, | |
712 | .help = "Round robin select files", | |
713 | }, | |
714 | }, | |
67a1000f JA |
715 | .parent = "nrfiles", |
716 | }, | |
717 | { | |
718 | .name = "fadvise_hint", | |
719 | .type = FIO_OPT_BOOL, | |
720 | .off1 = td_var_offset(fadvise_hint), | |
721 | .help = "Use fadvise() to advise the kernel on IO pattern", | |
722 | .def = "1", | |
214e1eca JA |
723 | }, |
724 | { | |
725 | .name = "fsync", | |
726 | .type = FIO_OPT_INT, | |
727 | .off1 = td_var_offset(fsync_blocks), | |
728 | .help = "Issue fsync for writes every given number of blocks", | |
729 | .def = "0", | |
730 | }, | |
731 | { | |
732 | .name = "direct", | |
733 | .type = FIO_OPT_BOOL, | |
734 | .off1 = td_var_offset(odirect), | |
735 | .help = "Use O_DIRECT IO (negates buffered)", | |
736 | .def = "0", | |
737 | }, | |
738 | { | |
739 | .name = "buffered", | |
740 | .type = FIO_OPT_BOOL, | |
741 | .off1 = td_var_offset(odirect), | |
742 | .neg = 1, | |
743 | .help = "Use buffered IO (negates direct)", | |
744 | .def = "1", | |
745 | }, | |
746 | { | |
747 | .name = "overwrite", | |
748 | .type = FIO_OPT_BOOL, | |
749 | .off1 = td_var_offset(overwrite), | |
750 | .help = "When writing, set whether to overwrite current data", | |
751 | .def = "0", | |
752 | }, | |
753 | { | |
754 | .name = "loops", | |
755 | .type = FIO_OPT_INT, | |
756 | .off1 = td_var_offset(loops), | |
757 | .help = "Number of times to run the job", | |
758 | .def = "1", | |
759 | }, | |
760 | { | |
761 | .name = "numjobs", | |
762 | .type = FIO_OPT_INT, | |
763 | .off1 = td_var_offset(numjobs), | |
764 | .help = "Duplicate this job this many times", | |
765 | .def = "1", | |
766 | }, | |
767 | { | |
768 | .name = "startdelay", | |
769 | .type = FIO_OPT_INT, | |
770 | .off1 = td_var_offset(start_delay), | |
771 | .help = "Only start job when this period has passed", | |
772 | .def = "0", | |
773 | }, | |
774 | { | |
775 | .name = "runtime", | |
776 | .alias = "timeout", | |
777 | .type = FIO_OPT_STR_VAL_TIME, | |
778 | .off1 = td_var_offset(timeout), | |
779 | .help = "Stop workload when this amount of time has passed", | |
780 | .def = "0", | |
781 | }, | |
cf4464ca JA |
782 | { |
783 | .name = "time_based", | |
784 | .type = FIO_OPT_STR_SET, | |
785 | .off1 = td_var_offset(time_based), | |
786 | .help = "Keep running until runtime/timeout is met", | |
787 | }, | |
214e1eca JA |
788 | { |
789 | .name = "mem", | |
d3aad8f2 | 790 | .alias = "iomem", |
214e1eca JA |
791 | .type = FIO_OPT_STR, |
792 | .cb = str_mem_cb, | |
793 | .off1 = td_var_offset(mem_type), | |
794 | .help = "Backing type for IO buffers", | |
795 | .def = "malloc", | |
796 | .posval = { | |
797 | { .ival = "malloc", | |
798 | .oval = MEM_MALLOC, | |
799 | .help = "Use malloc(3) for IO buffers", | |
800 | }, | |
37c8cdfe JA |
801 | { .ival = "shm", |
802 | .oval = MEM_SHM, | |
803 | .help = "Use shared memory segments for IO buffers", | |
804 | }, | |
214e1eca JA |
805 | #ifdef FIO_HAVE_HUGETLB |
806 | { .ival = "shmhuge", | |
807 | .oval = MEM_SHMHUGE, | |
808 | .help = "Like shm, but use huge pages", | |
809 | }, | |
b370e46a | 810 | #endif |
37c8cdfe JA |
811 | { .ival = "mmap", |
812 | .oval = MEM_MMAP, | |
813 | .help = "Use mmap(2) (file or anon) for IO buffers", | |
814 | }, | |
214e1eca JA |
815 | #ifdef FIO_HAVE_HUGETLB |
816 | { .ival = "mmaphuge", | |
817 | .oval = MEM_MMAPHUGE, | |
818 | .help = "Like mmap, but use huge pages", | |
819 | }, | |
820 | #endif | |
821 | }, | |
822 | }, | |
823 | { | |
824 | .name = "verify", | |
825 | .type = FIO_OPT_STR, | |
826 | .off1 = td_var_offset(verify), | |
827 | .help = "Verify data written", | |
828 | .def = "0", | |
829 | .posval = { | |
830 | { .ival = "0", | |
831 | .oval = VERIFY_NONE, | |
832 | .help = "Don't do IO verification", | |
833 | }, | |
fcca4b58 JA |
834 | { .ival = "md5", |
835 | .oval = VERIFY_MD5, | |
836 | .help = "Use md5 checksums for verification", | |
837 | }, | |
d77a7af3 JA |
838 | { .ival = "crc64", |
839 | .oval = VERIFY_CRC64, | |
840 | .help = "Use crc64 checksums for verification", | |
841 | }, | |
214e1eca JA |
842 | { .ival = "crc32", |
843 | .oval = VERIFY_CRC32, | |
844 | .help = "Use crc32 checksums for verification", | |
845 | }, | |
969f7ed3 JA |
846 | { .ival = "crc16", |
847 | .oval = VERIFY_CRC16, | |
848 | .help = "Use crc16 checksums for verification", | |
849 | }, | |
1e154bdb JA |
850 | { .ival = "crc7", |
851 | .oval = VERIFY_CRC7, | |
852 | .help = "Use crc7 checksums for verification", | |
853 | }, | |
cd14cc10 JA |
854 | { .ival = "sha256", |
855 | .oval = VERIFY_SHA256, | |
856 | .help = "Use sha256 checksums for verification", | |
857 | }, | |
858 | { .ival = "sha512", | |
859 | .oval = VERIFY_SHA512, | |
860 | .help = "Use sha512 checksums for verification", | |
861 | }, | |
7437ee87 SL |
862 | { .ival = "meta", |
863 | .oval = VERIFY_META, | |
864 | .help = "Use io information", | |
865 | }, | |
36690c9b JA |
866 | { |
867 | .ival = "null", | |
868 | .oval = VERIFY_NULL, | |
869 | .help = "Pretend to verify", | |
870 | }, | |
214e1eca JA |
871 | }, |
872 | }, | |
005c565a JA |
873 | { |
874 | .name = "do_verify", | |
68e1f29a | 875 | .type = FIO_OPT_BOOL, |
005c565a JA |
876 | .off1 = td_var_offset(do_verify), |
877 | .help = "Run verification stage after write", | |
878 | .def = "1", | |
879 | .parent = "verify", | |
880 | }, | |
160b966d JA |
881 | { |
882 | .name = "verifysort", | |
883 | .type = FIO_OPT_BOOL, | |
884 | .off1 = td_var_offset(verifysort), | |
885 | .help = "Sort written verify blocks for read back", | |
886 | .def = "1", | |
c83f2df1 | 887 | .parent = "verify", |
160b966d | 888 | }, |
3f9f4e26 | 889 | { |
a59e170d | 890 | .name = "verify_interval", |
3f9f4e26 | 891 | .type = FIO_OPT_STR_VAL_INT, |
a59e170d | 892 | .off1 = td_var_offset(verify_interval), |
819a9680 | 893 | .minval = 2 * sizeof(struct verify_header), |
a59e170d | 894 | .help = "Store verify buffer header every N bytes", |
afdf9352 | 895 | .parent = "verify", |
3f9f4e26 | 896 | }, |
546a9142 | 897 | { |
a59e170d | 898 | .name = "verify_offset", |
546a9142 | 899 | .type = FIO_OPT_STR_VAL_INT, |
a59e170d | 900 | .help = "Offset verify header location by N bytes", |
546a9142 | 901 | .def = "0", |
5ec10eaa | 902 | .cb = str_verify_offset_cb, |
afdf9352 | 903 | .parent = "verify", |
546a9142 | 904 | }, |
e28218f3 SL |
905 | { |
906 | .name = "verify_pattern", | |
907 | .type = FIO_OPT_INT, | |
908 | .cb = str_verify_pattern_cb, | |
909 | .help = "Fill pattern for IO buffers", | |
910 | .parent = "verify", | |
911 | }, | |
a12a3b4d JA |
912 | { |
913 | .name = "verify_fatal", | |
68e1f29a | 914 | .type = FIO_OPT_BOOL, |
a12a3b4d JA |
915 | .off1 = td_var_offset(verify_fatal), |
916 | .def = "0", | |
917 | .help = "Exit on a single verify failure, don't continue", | |
918 | .parent = "verify", | |
919 | }, | |
214e1eca JA |
920 | { |
921 | .name = "write_iolog", | |
922 | .type = FIO_OPT_STR_STORE, | |
923 | .off1 = td_var_offset(write_iolog_file), | |
924 | .help = "Store IO pattern to file", | |
925 | }, | |
926 | { | |
927 | .name = "read_iolog", | |
928 | .type = FIO_OPT_STR_STORE, | |
929 | .off1 = td_var_offset(read_iolog_file), | |
930 | .help = "Playback IO pattern from file", | |
931 | }, | |
932 | { | |
933 | .name = "exec_prerun", | |
934 | .type = FIO_OPT_STR_STORE, | |
935 | .off1 = td_var_offset(exec_prerun), | |
936 | .help = "Execute this file prior to running job", | |
937 | }, | |
938 | { | |
939 | .name = "exec_postrun", | |
940 | .type = FIO_OPT_STR_STORE, | |
941 | .off1 = td_var_offset(exec_postrun), | |
942 | .help = "Execute this file after running job", | |
943 | }, | |
944 | #ifdef FIO_HAVE_IOSCHED_SWITCH | |
945 | { | |
946 | .name = "ioscheduler", | |
947 | .type = FIO_OPT_STR_STORE, | |
948 | .off1 = td_var_offset(ioscheduler), | |
949 | .help = "Use this IO scheduler on the backing device", | |
950 | }, | |
951 | #endif | |
952 | { | |
953 | .name = "zonesize", | |
954 | .type = FIO_OPT_STR_VAL, | |
955 | .off1 = td_var_offset(zone_size), | |
956 | .help = "Give size of an IO zone", | |
957 | .def = "0", | |
958 | }, | |
959 | { | |
960 | .name = "zoneskip", | |
961 | .type = FIO_OPT_STR_VAL, | |
962 | .off1 = td_var_offset(zone_skip), | |
963 | .help = "Space between IO zones", | |
964 | .def = "0", | |
965 | }, | |
966 | { | |
967 | .name = "lockmem", | |
968 | .type = FIO_OPT_STR_VAL, | |
969 | .cb = str_lockmem_cb, | |
970 | .help = "Lock down this amount of memory", | |
971 | .def = "0", | |
972 | }, | |
214e1eca JA |
973 | { |
974 | .name = "rwmixread", | |
975 | .type = FIO_OPT_INT, | |
e47f799f | 976 | .off1 = td_var_offset(rwmix[DDIR_READ]), |
214e1eca JA |
977 | .maxval = 100, |
978 | .help = "Percentage of mixed workload that is reads", | |
979 | .def = "50", | |
980 | }, | |
981 | { | |
982 | .name = "rwmixwrite", | |
983 | .type = FIO_OPT_INT, | |
e47f799f | 984 | .off1 = td_var_offset(rwmix[DDIR_WRITE]), |
214e1eca JA |
985 | .maxval = 100, |
986 | .help = "Percentage of mixed workload that is writes", | |
987 | .def = "50", | |
988 | }, | |
afdf9352 JA |
989 | { |
990 | .name = "rwmixcycle", | |
15ca150e | 991 | .type = FIO_OPT_DEPRECATED, |
afdf9352 | 992 | }, |
214e1eca JA |
993 | { |
994 | .name = "nice", | |
995 | .type = FIO_OPT_INT, | |
996 | .off1 = td_var_offset(nice), | |
997 | .help = "Set job CPU nice value", | |
998 | .minval = -19, | |
999 | .maxval = 20, | |
1000 | .def = "0", | |
1001 | }, | |
1002 | #ifdef FIO_HAVE_IOPRIO | |
1003 | { | |
1004 | .name = "prio", | |
1005 | .type = FIO_OPT_INT, | |
1006 | .cb = str_prio_cb, | |
1007 | .help = "Set job IO priority value", | |
1008 | .minval = 0, | |
1009 | .maxval = 7, | |
1010 | }, | |
1011 | { | |
1012 | .name = "prioclass", | |
1013 | .type = FIO_OPT_INT, | |
1014 | .cb = str_prioclass_cb, | |
1015 | .help = "Set job IO priority class", | |
1016 | .minval = 0, | |
1017 | .maxval = 3, | |
1018 | }, | |
1019 | #endif | |
1020 | { | |
1021 | .name = "thinktime", | |
1022 | .type = FIO_OPT_INT, | |
1023 | .off1 = td_var_offset(thinktime), | |
1024 | .help = "Idle time between IO buffers (usec)", | |
1025 | .def = "0", | |
1026 | }, | |
1027 | { | |
1028 | .name = "thinktime_spin", | |
1029 | .type = FIO_OPT_INT, | |
1030 | .off1 = td_var_offset(thinktime_spin), | |
1031 | .help = "Start think time by spinning this amount (usec)", | |
1032 | .def = "0", | |
afdf9352 | 1033 | .parent = "thinktime", |
214e1eca JA |
1034 | }, |
1035 | { | |
1036 | .name = "thinktime_blocks", | |
1037 | .type = FIO_OPT_INT, | |
1038 | .off1 = td_var_offset(thinktime_blocks), | |
1039 | .help = "IO buffer period between 'thinktime'", | |
1040 | .def = "1", | |
afdf9352 | 1041 | .parent = "thinktime", |
214e1eca JA |
1042 | }, |
1043 | { | |
1044 | .name = "rate", | |
1045 | .type = FIO_OPT_INT, | |
1046 | .off1 = td_var_offset(rate), | |
1047 | .help = "Set bandwidth rate", | |
1048 | }, | |
1049 | { | |
1050 | .name = "ratemin", | |
1051 | .type = FIO_OPT_INT, | |
1052 | .off1 = td_var_offset(ratemin), | |
4e991c23 | 1053 | .help = "Job must meet this rate or it will be shutdown", |
afdf9352 | 1054 | .parent = "rate", |
4e991c23 JA |
1055 | }, |
1056 | { | |
1057 | .name = "rate_iops", | |
1058 | .type = FIO_OPT_INT, | |
1059 | .off1 = td_var_offset(rate_iops), | |
1060 | .help = "Limit IO used to this number of IO operations/sec", | |
1061 | }, | |
1062 | { | |
1063 | .name = "rate_iops_min", | |
1064 | .type = FIO_OPT_INT, | |
1065 | .off1 = td_var_offset(rate_iops_min), | |
1066 | .help = "Job must meet this rate or it will be shutdown", | |
afdf9352 | 1067 | .parent = "rate_iops", |
214e1eca JA |
1068 | }, |
1069 | { | |
1070 | .name = "ratecycle", | |
1071 | .type = FIO_OPT_INT, | |
1072 | .off1 = td_var_offset(ratecycle), | |
1073 | .help = "Window average for rate limits (msec)", | |
1074 | .def = "1000", | |
afdf9352 | 1075 | .parent = "rate", |
214e1eca JA |
1076 | }, |
1077 | { | |
1078 | .name = "invalidate", | |
1079 | .type = FIO_OPT_BOOL, | |
1080 | .off1 = td_var_offset(invalidate_cache), | |
1081 | .help = "Invalidate buffer/page cache prior to running job", | |
1082 | .def = "1", | |
1083 | }, | |
1084 | { | |
1085 | .name = "sync", | |
1086 | .type = FIO_OPT_BOOL, | |
1087 | .off1 = td_var_offset(sync_io), | |
1088 | .help = "Use O_SYNC for buffered writes", | |
1089 | .def = "0", | |
67a1000f | 1090 | .parent = "buffered", |
214e1eca JA |
1091 | }, |
1092 | { | |
1093 | .name = "bwavgtime", | |
1094 | .type = FIO_OPT_INT, | |
1095 | .off1 = td_var_offset(bw_avg_time), | |
5ec10eaa JA |
1096 | .help = "Time window over which to calculate bandwidth" |
1097 | " (msec)", | |
214e1eca JA |
1098 | .def = "500", |
1099 | }, | |
1100 | { | |
1101 | .name = "create_serialize", | |
1102 | .type = FIO_OPT_BOOL, | |
1103 | .off1 = td_var_offset(create_serialize), | |
1104 | .help = "Serialize creating of job files", | |
1105 | .def = "1", | |
1106 | }, | |
1107 | { | |
1108 | .name = "create_fsync", | |
1109 | .type = FIO_OPT_BOOL, | |
1110 | .off1 = td_var_offset(create_fsync), | |
1111 | .help = "Fsync file after creation", | |
1112 | .def = "1", | |
1113 | }, | |
1114 | { | |
1115 | .name = "cpuload", | |
1116 | .type = FIO_OPT_INT, | |
1117 | .off1 = td_var_offset(cpuload), | |
1118 | .help = "Use this percentage of CPU", | |
1119 | }, | |
1120 | { | |
1121 | .name = "cpuchunks", | |
1122 | .type = FIO_OPT_INT, | |
1123 | .off1 = td_var_offset(cpucycle), | |
1124 | .help = "Length of the CPU burn cycles (usecs)", | |
1125 | .def = "50000", | |
67a1000f | 1126 | .parent = "cpuload", |
214e1eca JA |
1127 | }, |
1128 | #ifdef FIO_HAVE_CPU_AFFINITY | |
1129 | { | |
1130 | .name = "cpumask", | |
1131 | .type = FIO_OPT_INT, | |
1132 | .cb = str_cpumask_cb, | |
1133 | .help = "CPU affinity mask", | |
1134 | }, | |
d2e268b0 JA |
1135 | { |
1136 | .name = "cpus_allowed", | |
1137 | .type = FIO_OPT_STR, | |
1138 | .cb = str_cpus_allowed_cb, | |
1139 | .help = "Set CPUs allowed", | |
1140 | }, | |
214e1eca JA |
1141 | #endif |
1142 | { | |
1143 | .name = "end_fsync", | |
1144 | .type = FIO_OPT_BOOL, | |
1145 | .off1 = td_var_offset(end_fsync), | |
1146 | .help = "Include fsync at the end of job", | |
1147 | .def = "0", | |
1148 | }, | |
1149 | { | |
1150 | .name = "fsync_on_close", | |
1151 | .type = FIO_OPT_BOOL, | |
1152 | .off1 = td_var_offset(fsync_on_close), | |
1153 | .help = "fsync files on close", | |
1154 | .def = "0", | |
1155 | }, | |
1156 | { | |
1157 | .name = "unlink", | |
1158 | .type = FIO_OPT_BOOL, | |
1159 | .off1 = td_var_offset(unlink), | |
1160 | .help = "Unlink created files after job has completed", | |
1161 | .def = "0", | |
1162 | }, | |
1163 | { | |
1164 | .name = "exitall", | |
1165 | .type = FIO_OPT_STR_SET, | |
1166 | .cb = str_exitall_cb, | |
1167 | .help = "Terminate all jobs when one exits", | |
1168 | }, | |
1169 | { | |
1170 | .name = "stonewall", | |
1171 | .type = FIO_OPT_STR_SET, | |
1172 | .off1 = td_var_offset(stonewall), | |
1173 | .help = "Insert a hard barrier between this job and previous", | |
1174 | }, | |
b3d62a75 JA |
1175 | { |
1176 | .name = "new_group", | |
1177 | .type = FIO_OPT_STR_SET, | |
1178 | .off1 = td_var_offset(new_group), | |
1179 | .help = "Mark the start of a new group (for reporting)", | |
1180 | }, | |
214e1eca JA |
1181 | { |
1182 | .name = "thread", | |
1183 | .type = FIO_OPT_STR_SET, | |
1184 | .off1 = td_var_offset(use_thread), | |
1185 | .help = "Use threads instead of forks", | |
1186 | }, | |
1187 | { | |
1188 | .name = "write_bw_log", | |
1189 | .type = FIO_OPT_STR_SET, | |
1190 | .off1 = td_var_offset(write_bw_log), | |
1191 | .help = "Write log of bandwidth during run", | |
1192 | }, | |
1193 | { | |
1194 | .name = "write_lat_log", | |
1195 | .type = FIO_OPT_STR_SET, | |
1196 | .off1 = td_var_offset(write_lat_log), | |
1197 | .help = "Write log of latency during run", | |
1198 | }, | |
1199 | { | |
1200 | .name = "hugepage-size", | |
357f618e | 1201 | .type = FIO_OPT_STR_VAL_INT, |
214e1eca JA |
1202 | .off1 = td_var_offset(hugepage_size), |
1203 | .help = "When using hugepages, specify size of each page", | |
1204 | .def = __stringify(FIO_HUGE_PAGE), | |
1205 | }, | |
1206 | { | |
1207 | .name = "group_reporting", | |
1208 | .type = FIO_OPT_STR_SET, | |
1209 | .off1 = td_var_offset(group_reporting), | |
1210 | .help = "Do reporting on a per-group basis", | |
1211 | }, | |
e9459e5a JA |
1212 | { |
1213 | .name = "zero_buffers", | |
1214 | .type = FIO_OPT_STR_SET, | |
1215 | .off1 = td_var_offset(zero_buffers), | |
1216 | .help = "Init IO buffers to all zeroes", | |
1217 | }, | |
0a839f30 JA |
1218 | #ifdef FIO_HAVE_DISK_UTIL |
1219 | { | |
1220 | .name = "disk_util", | |
1221 | .type = FIO_OPT_BOOL, | |
1222 | .off1 = td_var_offset(do_disk_util), | |
1223 | .help = "Log disk utilization stats", | |
1224 | .def = "1", | |
1225 | }, | |
1226 | #endif | |
214e1eca JA |
1227 | { |
1228 | .name = NULL, | |
1229 | }, | |
1230 | }; | |
1231 | ||
1232 | void fio_options_dup_and_init(struct option *long_options) | |
1233 | { | |
1234 | struct fio_option *o; | |
1235 | unsigned int i; | |
1236 | ||
1237 | options_init(options); | |
1238 | ||
1239 | i = 0; | |
1240 | while (long_options[i].name) | |
1241 | i++; | |
1242 | ||
1243 | o = &options[0]; | |
1244 | while (o->name) { | |
1245 | long_options[i].name = o->name; | |
1246 | long_options[i].val = FIO_GETOPT_JOB; | |
1247 | if (o->type == FIO_OPT_STR_SET) | |
1248 | long_options[i].has_arg = no_argument; | |
1249 | else | |
1250 | long_options[i].has_arg = required_argument; | |
1251 | ||
1252 | i++; | |
1253 | o++; | |
1254 | assert(i < FIO_NR_OPTIONS); | |
1255 | } | |
1256 | } | |
1257 | ||
1258 | int fio_option_parse(struct thread_data *td, const char *opt) | |
1259 | { | |
1260 | return parse_option(opt, options, td); | |
1261 | } | |
1262 | ||
1263 | int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val) | |
1264 | { | |
1265 | return parse_cmd_option(opt, val, options, td); | |
1266 | } | |
1267 | ||
1268 | void fio_fill_default_options(struct thread_data *td) | |
1269 | { | |
1270 | fill_default_options(td, options); | |
1271 | } | |
1272 | ||
1273 | int fio_show_option_help(const char *opt) | |
1274 | { | |
1275 | return show_cmd_help(options, opt); | |
1276 | } | |
d23bb327 JA |
1277 | |
1278 | static void __options_mem(struct thread_data *td, int alloc) | |
1279 | { | |
1280 | struct thread_options *o = &td->o; | |
1281 | struct fio_option *opt; | |
1282 | char **ptr; | |
1283 | int i; | |
1284 | ||
1285 | for (i = 0, opt = &options[0]; opt->name; i++, opt = &options[i]) { | |
1286 | if (opt->type != FIO_OPT_STR_STORE) | |
1287 | continue; | |
1288 | ||
1289 | ptr = (void *) o + opt->off1; | |
1290 | if (*ptr) { | |
1291 | if (alloc) | |
1292 | *ptr = strdup(*ptr); | |
1293 | else { | |
1294 | free(*ptr); | |
1295 | *ptr = NULL; | |
1296 | } | |
1297 | } | |
1298 | } | |
1299 | } | |
1300 | ||
1301 | /* | |
1302 | * dupe FIO_OPT_STR_STORE options | |
1303 | */ | |
1304 | void options_mem_dupe(struct thread_data *td) | |
1305 | { | |
1306 | __options_mem(td, 1); | |
1307 | } | |
1308 | ||
22d66213 | 1309 | void options_mem_free(struct thread_data fio_unused *td) |
d23bb327 | 1310 | { |
22d66213 | 1311 | #if 0 |
d23bb327 | 1312 | __options_mem(td, 0); |
22d66213 | 1313 | #endif |
d23bb327 | 1314 | } |