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