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