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