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> | |
214e1eca | 6 | #include <assert.h> |
921c766f | 7 | #include <libgen.h> |
5921e80c JA |
8 | #include <fcntl.h> |
9 | #include <sys/types.h> | |
10 | #include <sys/stat.h> | |
214e1eca JA |
11 | |
12 | #include "fio.h" | |
4f5af7b2 | 13 | #include "verify.h" |
214e1eca | 14 | #include "parse.h" |
eef32359 | 15 | #include "lib/fls.h" |
9f988e2e | 16 | #include "options.h" |
214e1eca | 17 | |
5d7c5d34 JA |
18 | #include "crc/crc32c.h" |
19 | ||
214e1eca JA |
20 | /* |
21 | * Check if mmap/mmaphuge has a :/foo/bar/file at the end. If so, return that. | |
22 | */ | |
23 | static char *get_opt_postfix(const char *str) | |
24 | { | |
25 | char *p = strstr(str, ":"); | |
26 | ||
27 | if (!p) | |
28 | return NULL; | |
29 | ||
30 | p++; | |
31 | strip_blank_front(&p); | |
32 | strip_blank_end(p); | |
33 | return strdup(p); | |
34 | } | |
35 | ||
0e92f873 RR |
36 | static int converthexchartoint(char a) |
37 | { | |
38 | int base; | |
39 | ||
40 | switch(a) { | |
41 | case '0'...'9': | |
42 | base = '0'; | |
43 | break; | |
44 | case 'A'...'F': | |
45 | base = 'A' - 10; | |
46 | break; | |
47 | case 'a'...'f': | |
48 | base = 'a' - 10; | |
49 | break; | |
50 | default: | |
51 | base = 0; | |
52 | } | |
53 | return (a - base); | |
54 | } | |
55 | ||
564ca972 JA |
56 | static int bs_cmp(const void *p1, const void *p2) |
57 | { | |
58 | const struct bssplit *bsp1 = p1; | |
59 | const struct bssplit *bsp2 = p2; | |
60 | ||
61 | return bsp1->perc < bsp2->perc; | |
62 | } | |
63 | ||
720e84ad | 64 | static int bssplit_ddir(struct thread_data *td, int ddir, char *str) |
564ca972 | 65 | { |
720e84ad | 66 | struct bssplit *bssplit; |
564ca972 JA |
67 | unsigned int i, perc, perc_missing; |
68 | unsigned int max_bs, min_bs; | |
69 | long long val; | |
720e84ad | 70 | char *fname; |
564ca972 | 71 | |
720e84ad JA |
72 | td->o.bssplit_nr[ddir] = 4; |
73 | bssplit = malloc(4 * sizeof(struct bssplit)); | |
564ca972 JA |
74 | |
75 | i = 0; | |
76 | max_bs = 0; | |
77 | min_bs = -1; | |
78 | while ((fname = strsep(&str, ":")) != NULL) { | |
79 | char *perc_str; | |
80 | ||
81 | if (!strlen(fname)) | |
82 | break; | |
83 | ||
84 | /* | |
85 | * grow struct buffer, if needed | |
86 | */ | |
720e84ad JA |
87 | if (i == td->o.bssplit_nr[ddir]) { |
88 | td->o.bssplit_nr[ddir] <<= 1; | |
89 | bssplit = realloc(bssplit, td->o.bssplit_nr[ddir] | |
5ec10eaa | 90 | * sizeof(struct bssplit)); |
564ca972 JA |
91 | } |
92 | ||
93 | perc_str = strstr(fname, "/"); | |
94 | if (perc_str) { | |
95 | *perc_str = '\0'; | |
96 | perc_str++; | |
97 | perc = atoi(perc_str); | |
98 | if (perc > 100) | |
99 | perc = 100; | |
100 | else if (!perc) | |
101 | perc = -1; | |
102 | } else | |
103 | perc = -1; | |
104 | ||
6925dd35 | 105 | if (str_to_decimal(fname, &val, 1, td)) { |
564ca972 JA |
106 | log_err("fio: bssplit conversion failed\n"); |
107 | free(td->o.bssplit); | |
108 | return 1; | |
109 | } | |
110 | ||
111 | if (val > max_bs) | |
112 | max_bs = val; | |
113 | if (val < min_bs) | |
114 | min_bs = val; | |
115 | ||
720e84ad JA |
116 | bssplit[i].bs = val; |
117 | bssplit[i].perc = perc; | |
564ca972 JA |
118 | i++; |
119 | } | |
120 | ||
720e84ad | 121 | td->o.bssplit_nr[ddir] = i; |
564ca972 JA |
122 | |
123 | /* | |
124 | * Now check if the percentages add up, and how much is missing | |
125 | */ | |
126 | perc = perc_missing = 0; | |
720e84ad JA |
127 | for (i = 0; i < td->o.bssplit_nr[ddir]; i++) { |
128 | struct bssplit *bsp = &bssplit[i]; | |
564ca972 JA |
129 | |
130 | if (bsp->perc == (unsigned char) -1) | |
131 | perc_missing++; | |
132 | else | |
133 | perc += bsp->perc; | |
134 | } | |
135 | ||
136 | if (perc > 100) { | |
137 | log_err("fio: bssplit percentages add to more than 100%%\n"); | |
720e84ad | 138 | free(bssplit); |
564ca972 JA |
139 | return 1; |
140 | } | |
141 | /* | |
142 | * If values didn't have a percentage set, divide the remains between | |
143 | * them. | |
144 | */ | |
145 | if (perc_missing) { | |
720e84ad JA |
146 | for (i = 0; i < td->o.bssplit_nr[ddir]; i++) { |
147 | struct bssplit *bsp = &bssplit[i]; | |
564ca972 JA |
148 | |
149 | if (bsp->perc == (unsigned char) -1) | |
150 | bsp->perc = (100 - perc) / perc_missing; | |
151 | } | |
152 | } | |
153 | ||
720e84ad JA |
154 | td->o.min_bs[ddir] = min_bs; |
155 | td->o.max_bs[ddir] = max_bs; | |
564ca972 JA |
156 | |
157 | /* | |
158 | * now sort based on percentages, for ease of lookup | |
159 | */ | |
720e84ad JA |
160 | qsort(bssplit, td->o.bssplit_nr[ddir], sizeof(struct bssplit), bs_cmp); |
161 | td->o.bssplit[ddir] = bssplit; | |
162 | return 0; | |
163 | ||
164 | } | |
165 | ||
166 | static int str_bssplit_cb(void *data, const char *input) | |
167 | { | |
168 | struct thread_data *td = data; | |
6eaf09d6 | 169 | char *str, *p, *odir, *ddir; |
720e84ad JA |
170 | int ret = 0; |
171 | ||
172 | p = str = strdup(input); | |
173 | ||
174 | strip_blank_front(&str); | |
175 | strip_blank_end(str); | |
176 | ||
177 | odir = strchr(str, ','); | |
178 | if (odir) { | |
6eaf09d6 SL |
179 | ddir = strchr(odir + 1, ','); |
180 | if (ddir) { | |
181 | ret = bssplit_ddir(td, DDIR_TRIM, ddir + 1); | |
182 | if (!ret) | |
183 | *ddir = '\0'; | |
184 | } else { | |
185 | char *op; | |
186 | ||
187 | op = strdup(odir + 1); | |
188 | ret = bssplit_ddir(td, DDIR_TRIM, op); | |
189 | ||
190 | free(op); | |
191 | } | |
192 | if (!ret) | |
193 | ret = bssplit_ddir(td, DDIR_WRITE, odir + 1); | |
720e84ad JA |
194 | if (!ret) { |
195 | *odir = '\0'; | |
196 | ret = bssplit_ddir(td, DDIR_READ, str); | |
197 | } | |
198 | } else { | |
199 | char *op; | |
200 | ||
201 | op = strdup(str); | |
6eaf09d6 SL |
202 | ret = bssplit_ddir(td, DDIR_WRITE, op); |
203 | free(op); | |
720e84ad | 204 | |
6eaf09d6 SL |
205 | if (!ret) { |
206 | op = strdup(str); | |
207 | ret = bssplit_ddir(td, DDIR_TRIM, op); | |
208 | free(op); | |
209 | } | |
720e84ad | 210 | ret = bssplit_ddir(td, DDIR_READ, str); |
720e84ad | 211 | } |
564ca972 JA |
212 | |
213 | free(p); | |
720e84ad | 214 | return ret; |
564ca972 JA |
215 | } |
216 | ||
8b28bd41 DM |
217 | static int str2error(char *str) |
218 | { | |
219 | const char * err[] = {"EPERM", "ENOENT", "ESRCH", "EINTR", "EIO", | |
220 | "ENXIO", "E2BIG", "ENOEXEC", "EBADF", | |
221 | "ECHILD", "EAGAIN", "ENOMEM", "EACCES", | |
222 | "EFAULT", "ENOTBLK", "EBUSY", "EEXIST", | |
223 | "EXDEV", "ENODEV", "ENOTDIR", "EISDIR", | |
224 | "EINVAL", "ENFILE", "EMFILE", "ENOTTY", | |
225 | "ETXTBSY","EFBIG", "ENOSPC", "ESPIPE", | |
226 | "EROFS","EMLINK", "EPIPE", "EDOM", "ERANGE"}; | |
227 | int i = 0, num = sizeof(err) / sizeof(void *); | |
228 | ||
229 | while( i < num) { | |
230 | if (!strcmp(err[i], str)) | |
231 | return i + 1; | |
232 | i++; | |
233 | } | |
234 | return 0; | |
235 | } | |
236 | ||
237 | static int ignore_error_type(struct thread_data *td, int etype, char *str) | |
238 | { | |
239 | unsigned int i; | |
240 | int *error; | |
241 | char *fname; | |
242 | ||
243 | if (etype >= ERROR_TYPE_CNT) { | |
244 | log_err("Illegal error type\n"); | |
245 | return 1; | |
246 | } | |
247 | ||
248 | td->o.ignore_error_nr[etype] = 4; | |
249 | error = malloc(4 * sizeof(struct bssplit)); | |
250 | ||
251 | i = 0; | |
252 | while ((fname = strsep(&str, ":")) != NULL) { | |
253 | ||
254 | if (!strlen(fname)) | |
255 | break; | |
256 | ||
257 | /* | |
258 | * grow struct buffer, if needed | |
259 | */ | |
260 | if (i == td->o.ignore_error_nr[etype]) { | |
261 | td->o.ignore_error_nr[etype] <<= 1; | |
262 | error = realloc(error, td->o.ignore_error_nr[etype] | |
263 | * sizeof(int)); | |
264 | } | |
265 | if (fname[0] == 'E') { | |
266 | error[i] = str2error(fname); | |
267 | } else { | |
268 | error[i] = atoi(fname); | |
269 | if (error[i] < 0) | |
270 | error[i] = error[i]; | |
271 | } | |
272 | if (!error[i]) { | |
273 | log_err("Unknown error %s, please use number value \n", | |
274 | fname); | |
275 | return 1; | |
276 | } | |
277 | i++; | |
278 | } | |
279 | if (i) { | |
280 | td->o.continue_on_error |= 1 << etype; | |
281 | td->o.ignore_error_nr[etype] = i; | |
282 | td->o.ignore_error[etype] = error; | |
283 | } | |
284 | return 0; | |
285 | ||
286 | } | |
287 | ||
288 | static int str_ignore_error_cb(void *data, const char *input) | |
289 | { | |
290 | struct thread_data *td = data; | |
291 | char *str, *p, *n; | |
292 | int type = 0, ret = 1; | |
293 | p = str = strdup(input); | |
294 | ||
295 | strip_blank_front(&str); | |
296 | strip_blank_end(str); | |
297 | ||
298 | while (p) { | |
299 | n = strchr(p, ','); | |
300 | if (n) | |
301 | *n++ = '\0'; | |
302 | ret = ignore_error_type(td, type, p); | |
303 | if (ret) | |
304 | break; | |
305 | p = n; | |
306 | type++; | |
307 | } | |
308 | free(str); | |
309 | return ret; | |
310 | } | |
311 | ||
211097b2 JA |
312 | static int str_rw_cb(void *data, const char *str) |
313 | { | |
314 | struct thread_data *td = data; | |
315 | char *nr = get_opt_postfix(str); | |
316 | ||
5736c10d | 317 | td->o.ddir_seq_nr = 1; |
059b0802 JA |
318 | td->o.ddir_seq_add = 0; |
319 | ||
320 | if (!nr) | |
321 | return 0; | |
322 | ||
323 | if (td_random(td)) | |
5736c10d | 324 | td->o.ddir_seq_nr = atoi(nr); |
059b0802 JA |
325 | else { |
326 | long long val; | |
327 | ||
6925dd35 | 328 | if (str_to_decimal(nr, &val, 1, td)) { |
059b0802 JA |
329 | log_err("fio: rw postfix parsing failed\n"); |
330 | free(nr); | |
331 | return 1; | |
332 | } | |
333 | ||
334 | td->o.ddir_seq_add = val; | |
182ec6ee | 335 | } |
211097b2 | 336 | |
059b0802 | 337 | free(nr); |
211097b2 JA |
338 | return 0; |
339 | } | |
340 | ||
214e1eca JA |
341 | static int str_mem_cb(void *data, const char *mem) |
342 | { | |
343 | struct thread_data *td = data; | |
344 | ||
2dc1bbeb | 345 | if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP) { |
214e1eca | 346 | td->mmapfile = get_opt_postfix(mem); |
2dc1bbeb | 347 | if (td->o.mem_type == MEM_MMAPHUGE && !td->mmapfile) { |
214e1eca JA |
348 | log_err("fio: mmaphuge:/path/to/file\n"); |
349 | return 1; | |
350 | } | |
351 | } | |
352 | ||
353 | return 0; | |
354 | } | |
355 | ||
5d7c5d34 JA |
356 | static int str_verify_cb(void *data, const char *mem) |
357 | { | |
358 | struct thread_data *td = data; | |
359 | ||
e3aaafc4 JA |
360 | if (td->o.verify == VERIFY_CRC32C_INTEL || |
361 | td->o.verify == VERIFY_CRC32C) { | |
362 | crc32c_intel_probe(); | |
5d7c5d34 JA |
363 | } |
364 | ||
365 | return 0; | |
366 | } | |
367 | ||
c223da83 JA |
368 | static int fio_clock_source_cb(void *data, const char *str) |
369 | { | |
370 | struct thread_data *td = data; | |
371 | ||
372 | fio_clock_source = td->o.clocksource; | |
373 | fio_time_init(); | |
374 | return 0; | |
375 | } | |
376 | ||
85bc833b | 377 | static int str_lockmem_cb(void fio_unused *data, unsigned long long *val) |
214e1eca JA |
378 | { |
379 | mlock_size = *val; | |
380 | return 0; | |
381 | } | |
382 | ||
85bc833b | 383 | static int str_rwmix_read_cb(void *data, unsigned long long *val) |
cb499fc4 JA |
384 | { |
385 | struct thread_data *td = data; | |
386 | ||
387 | td->o.rwmix[DDIR_READ] = *val; | |
388 | td->o.rwmix[DDIR_WRITE] = 100 - *val; | |
389 | return 0; | |
390 | } | |
391 | ||
85bc833b | 392 | static int str_rwmix_write_cb(void *data, unsigned long long *val) |
cb499fc4 JA |
393 | { |
394 | struct thread_data *td = data; | |
395 | ||
396 | td->o.rwmix[DDIR_WRITE] = *val; | |
397 | td->o.rwmix[DDIR_READ] = 100 - *val; | |
398 | return 0; | |
399 | } | |
400 | ||
214e1eca | 401 | #ifdef FIO_HAVE_IOPRIO |
85bc833b | 402 | static int str_prioclass_cb(void *data, unsigned long long *val) |
214e1eca JA |
403 | { |
404 | struct thread_data *td = data; | |
6cefbe33 JA |
405 | unsigned short mask; |
406 | ||
407 | /* | |
408 | * mask off old class bits, str_prio_cb() may have set a default class | |
409 | */ | |
410 | mask = (1 << IOPRIO_CLASS_SHIFT) - 1; | |
411 | td->ioprio &= mask; | |
214e1eca JA |
412 | |
413 | td->ioprio |= *val << IOPRIO_CLASS_SHIFT; | |
ac684785 | 414 | td->ioprio_set = 1; |
214e1eca JA |
415 | return 0; |
416 | } | |
417 | ||
85bc833b | 418 | static int str_prio_cb(void *data, unsigned long long *val) |
214e1eca JA |
419 | { |
420 | struct thread_data *td = data; | |
421 | ||
422 | td->ioprio |= *val; | |
6cefbe33 JA |
423 | |
424 | /* | |
425 | * If no class is set, assume BE | |
426 | */ | |
427 | if ((td->ioprio >> IOPRIO_CLASS_SHIFT) == 0) | |
428 | td->ioprio |= IOPRIO_CLASS_BE << IOPRIO_CLASS_SHIFT; | |
429 | ||
ac684785 | 430 | td->ioprio_set = 1; |
214e1eca JA |
431 | return 0; |
432 | } | |
433 | #endif | |
434 | ||
435 | static int str_exitall_cb(void) | |
436 | { | |
437 | exitall_on_terminate = 1; | |
438 | return 0; | |
439 | } | |
440 | ||
214e1eca | 441 | #ifdef FIO_HAVE_CPU_AFFINITY |
85bc833b | 442 | static int str_cpumask_cb(void *data, unsigned long long *val) |
d2e268b0 JA |
443 | { |
444 | struct thread_data *td = data; | |
214e1eca | 445 | unsigned int i; |
b03daafb | 446 | long max_cpu; |
d2ce18b5 JA |
447 | int ret; |
448 | ||
449 | ret = fio_cpuset_init(&td->o.cpumask); | |
450 | if (ret < 0) { | |
451 | log_err("fio: cpuset_init failed\n"); | |
452 | td_verror(td, ret, "fio_cpuset_init"); | |
453 | return 1; | |
454 | } | |
214e1eca | 455 | |
c00a2289 | 456 | max_cpu = cpus_online(); |
214e1eca | 457 | |
62a7273d JA |
458 | for (i = 0; i < sizeof(int) * 8; i++) { |
459 | if ((1 << i) & *val) { | |
b03daafb JA |
460 | if (i > max_cpu) { |
461 | log_err("fio: CPU %d too large (max=%ld)\n", i, | |
462 | max_cpu); | |
463 | return 1; | |
464 | } | |
62a7273d | 465 | dprint(FD_PARSE, "set cpu allowed %d\n", i); |
6d459ee7 | 466 | fio_cpu_set(&td->o.cpumask, i); |
62a7273d JA |
467 | } |
468 | } | |
d2e268b0 JA |
469 | |
470 | td->o.cpumask_set = 1; | |
471 | return 0; | |
214e1eca JA |
472 | } |
473 | ||
e8462bd8 JA |
474 | static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask, |
475 | const char *input) | |
214e1eca | 476 | { |
d2e268b0 | 477 | char *cpu, *str, *p; |
b03daafb | 478 | long max_cpu; |
19608d6c | 479 | int ret = 0; |
d2e268b0 | 480 | |
e8462bd8 | 481 | ret = fio_cpuset_init(mask); |
d2ce18b5 JA |
482 | if (ret < 0) { |
483 | log_err("fio: cpuset_init failed\n"); | |
484 | td_verror(td, ret, "fio_cpuset_init"); | |
485 | return 1; | |
486 | } | |
d2e268b0 JA |
487 | |
488 | p = str = strdup(input); | |
214e1eca | 489 | |
d2e268b0 JA |
490 | strip_blank_front(&str); |
491 | strip_blank_end(str); | |
492 | ||
c00a2289 | 493 | max_cpu = cpus_online(); |
b03daafb | 494 | |
d2e268b0 | 495 | while ((cpu = strsep(&str, ",")) != NULL) { |
62a7273d JA |
496 | char *str2, *cpu2; |
497 | int icpu, icpu2; | |
498 | ||
d2e268b0 JA |
499 | if (!strlen(cpu)) |
500 | break; | |
62a7273d JA |
501 | |
502 | str2 = cpu; | |
503 | icpu2 = -1; | |
504 | while ((cpu2 = strsep(&str2, "-")) != NULL) { | |
505 | if (!strlen(cpu2)) | |
506 | break; | |
507 | ||
508 | icpu2 = atoi(cpu2); | |
509 | } | |
510 | ||
511 | icpu = atoi(cpu); | |
512 | if (icpu2 == -1) | |
513 | icpu2 = icpu; | |
514 | while (icpu <= icpu2) { | |
6d459ee7 | 515 | if (icpu >= FIO_MAX_CPUS) { |
19608d6c | 516 | log_err("fio: your OS only supports up to" |
6d459ee7 | 517 | " %d CPUs\n", (int) FIO_MAX_CPUS); |
19608d6c JA |
518 | ret = 1; |
519 | break; | |
520 | } | |
b03daafb JA |
521 | if (icpu > max_cpu) { |
522 | log_err("fio: CPU %d too large (max=%ld)\n", | |
523 | icpu, max_cpu); | |
524 | ret = 1; | |
525 | break; | |
526 | } | |
0b9d69ec | 527 | |
62a7273d | 528 | dprint(FD_PARSE, "set cpu allowed %d\n", icpu); |
e8462bd8 | 529 | fio_cpu_set(mask, icpu); |
62a7273d JA |
530 | icpu++; |
531 | } | |
19608d6c JA |
532 | if (ret) |
533 | break; | |
d2e268b0 JA |
534 | } |
535 | ||
536 | free(p); | |
19608d6c JA |
537 | if (!ret) |
538 | td->o.cpumask_set = 1; | |
539 | return ret; | |
214e1eca | 540 | } |
e8462bd8 JA |
541 | |
542 | static int str_cpus_allowed_cb(void *data, const char *input) | |
543 | { | |
544 | struct thread_data *td = data; | |
545 | int ret; | |
546 | ||
547 | ret = set_cpus_allowed(td, &td->o.cpumask, input); | |
548 | if (!ret) | |
549 | td->o.cpumask_set = 1; | |
550 | ||
551 | return ret; | |
552 | } | |
553 | ||
554 | static int str_verify_cpus_allowed_cb(void *data, const char *input) | |
555 | { | |
556 | struct thread_data *td = data; | |
557 | int ret; | |
558 | ||
559 | ret = set_cpus_allowed(td, &td->o.verify_cpumask, input); | |
560 | if (!ret) | |
561 | td->o.verify_cpumask_set = 1; | |
562 | ||
563 | return ret; | |
564 | } | |
d2e268b0 | 565 | #endif |
214e1eca | 566 | |
d0b937ed YR |
567 | #ifdef FIO_HAVE_LIBNUMA |
568 | static int str_numa_cpunodes_cb(void *data, char *input) | |
569 | { | |
570 | struct thread_data *td = data; | |
571 | ||
572 | /* numa_parse_nodestring() parses a character string list | |
573 | * of nodes into a bit mask. The bit mask is allocated by | |
574 | * numa_allocate_nodemask(), so it should be freed by | |
575 | * numa_free_nodemask(). | |
576 | */ | |
577 | td->o.numa_cpunodesmask = numa_parse_nodestring(input); | |
578 | if (td->o.numa_cpunodesmask == NULL) { | |
579 | log_err("fio: numa_parse_nodestring failed\n"); | |
580 | td_verror(td, 1, "str_numa_cpunodes_cb"); | |
581 | return 1; | |
582 | } | |
583 | ||
584 | td->o.numa_cpumask_set = 1; | |
585 | return 0; | |
586 | } | |
587 | ||
588 | static int str_numa_mpol_cb(void *data, char *input) | |
589 | { | |
590 | struct thread_data *td = data; | |
591 | const char * const policy_types[] = | |
592 | { "default", "prefer", "bind", "interleave", "local" }; | |
593 | int i; | |
594 | ||
595 | char *nodelist = strchr(input, ':'); | |
596 | if (nodelist) { | |
597 | /* NUL-terminate mode */ | |
598 | *nodelist++ = '\0'; | |
599 | } | |
600 | ||
601 | for (i = 0; i <= MPOL_LOCAL; i++) { | |
602 | if (!strcmp(input, policy_types[i])) { | |
603 | td->o.numa_mem_mode = i; | |
604 | break; | |
605 | } | |
606 | } | |
607 | if (i > MPOL_LOCAL) { | |
608 | log_err("fio: memory policy should be: default, prefer, bind, interleave, local\n"); | |
609 | goto out; | |
610 | } | |
611 | ||
612 | switch (td->o.numa_mem_mode) { | |
613 | case MPOL_PREFERRED: | |
614 | /* | |
615 | * Insist on a nodelist of one node only | |
616 | */ | |
617 | if (nodelist) { | |
618 | char *rest = nodelist; | |
619 | while (isdigit(*rest)) | |
620 | rest++; | |
621 | if (*rest) { | |
622 | log_err("fio: one node only for \'prefer\'\n"); | |
623 | goto out; | |
624 | } | |
625 | } else { | |
626 | log_err("fio: one node is needed for \'prefer\'\n"); | |
627 | goto out; | |
628 | } | |
629 | break; | |
630 | case MPOL_INTERLEAVE: | |
631 | /* | |
632 | * Default to online nodes with memory if no nodelist | |
633 | */ | |
634 | if (!nodelist) | |
635 | nodelist = strdup("all"); | |
636 | break; | |
637 | case MPOL_LOCAL: | |
638 | case MPOL_DEFAULT: | |
639 | /* | |
640 | * Don't allow a nodelist | |
641 | */ | |
642 | if (nodelist) { | |
643 | log_err("fio: NO nodelist for \'local\'\n"); | |
644 | goto out; | |
645 | } | |
646 | break; | |
647 | case MPOL_BIND: | |
648 | /* | |
649 | * Insist on a nodelist | |
650 | */ | |
651 | if (!nodelist) { | |
652 | log_err("fio: a nodelist is needed for \'bind\'\n"); | |
653 | goto out; | |
654 | } | |
655 | break; | |
656 | } | |
657 | ||
658 | ||
659 | /* numa_parse_nodestring() parses a character string list | |
660 | * of nodes into a bit mask. The bit mask is allocated by | |
661 | * numa_allocate_nodemask(), so it should be freed by | |
662 | * numa_free_nodemask(). | |
663 | */ | |
664 | switch (td->o.numa_mem_mode) { | |
665 | case MPOL_PREFERRED: | |
666 | td->o.numa_mem_prefer_node = atoi(nodelist); | |
667 | break; | |
668 | case MPOL_INTERLEAVE: | |
669 | case MPOL_BIND: | |
670 | td->o.numa_memnodesmask = numa_parse_nodestring(nodelist); | |
671 | if (td->o.numa_memnodesmask == NULL) { | |
672 | log_err("fio: numa_parse_nodestring failed\n"); | |
673 | td_verror(td, 1, "str_numa_memnodes_cb"); | |
674 | return 1; | |
675 | } | |
676 | break; | |
677 | case MPOL_LOCAL: | |
678 | case MPOL_DEFAULT: | |
679 | default: | |
680 | break; | |
681 | } | |
682 | ||
683 | td->o.numa_memmask_set = 1; | |
684 | return 0; | |
685 | ||
686 | out: | |
687 | return 1; | |
688 | } | |
689 | #endif | |
690 | ||
0d29de83 JA |
691 | #ifdef FIO_HAVE_TRIM |
692 | static int str_verify_trim_cb(void *data, unsigned long long *val) | |
693 | { | |
694 | struct thread_data *td = data; | |
695 | ||
696 | td->o.trim_percentage = *val; | |
697 | return 0; | |
698 | } | |
699 | #endif | |
700 | ||
214e1eca JA |
701 | static int str_fst_cb(void *data, const char *str) |
702 | { | |
703 | struct thread_data *td = data; | |
704 | char *nr = get_opt_postfix(str); | |
705 | ||
706 | td->file_service_nr = 1; | |
182ec6ee | 707 | if (nr) { |
214e1eca | 708 | td->file_service_nr = atoi(nr); |
182ec6ee JA |
709 | free(nr); |
710 | } | |
214e1eca JA |
711 | |
712 | return 0; | |
713 | } | |
714 | ||
3ae06371 | 715 | #ifdef FIO_HAVE_SYNC_FILE_RANGE |
44f29692 JA |
716 | static int str_sfr_cb(void *data, const char *str) |
717 | { | |
718 | struct thread_data *td = data; | |
719 | char *nr = get_opt_postfix(str); | |
720 | ||
721 | td->sync_file_range_nr = 1; | |
722 | if (nr) { | |
723 | td->sync_file_range_nr = atoi(nr); | |
724 | free(nr); | |
725 | } | |
726 | ||
727 | return 0; | |
728 | } | |
3ae06371 | 729 | #endif |
44f29692 | 730 | |
e25839d4 JA |
731 | static int str_random_distribution_cb(void *data, const char *str) |
732 | { | |
733 | struct thread_data *td = data; | |
734 | double val; | |
735 | char *nr; | |
736 | ||
737 | if (td->o.random_distribution == FIO_RAND_DIST_RANDOM) | |
738 | return 0; | |
739 | ||
740 | nr = get_opt_postfix(str); | |
741 | if (!nr) | |
742 | val = 0.6; | |
743 | else if (!str_to_float(nr, &val)) { | |
744 | log_err("fio: random postfix parsing failed\n"); | |
745 | free(nr); | |
746 | return 1; | |
747 | } | |
748 | ||
749 | td->o.zipf_theta = val; | |
750 | free(nr); | |
751 | return 0; | |
752 | } | |
753 | ||
921c766f JA |
754 | static int check_dir(struct thread_data *td, char *fname) |
755 | { | |
3f0ca9b9 | 756 | #if 0 |
921c766f | 757 | char file[PATH_MAX], *dir; |
bc838919 | 758 | int elen = 0; |
921c766f | 759 | |
bc838919 JA |
760 | if (td->o.directory) { |
761 | strcpy(file, td->o.directory); | |
fcef0b35 | 762 | strcat(file, "/"); |
bc838919 JA |
763 | elen = strlen(file); |
764 | } | |
765 | ||
fcef0b35 | 766 | sprintf(file + elen, "%s", fname); |
921c766f JA |
767 | dir = dirname(file); |
768 | ||
fcef0b35 JA |
769 | { |
770 | struct stat sb; | |
771 | /* | |
772 | * We can't do this on FIO_DISKLESSIO engines. The engine isn't loaded | |
773 | * yet, so we can't do this check right here... | |
774 | */ | |
921c766f JA |
775 | if (lstat(dir, &sb) < 0) { |
776 | int ret = errno; | |
777 | ||
778 | log_err("fio: %s is not a directory\n", dir); | |
779 | td_verror(td, ret, "lstat"); | |
780 | return 1; | |
781 | } | |
782 | ||
783 | if (!S_ISDIR(sb.st_mode)) { | |
784 | log_err("fio: %s is not a directory\n", dir); | |
785 | return 1; | |
786 | } | |
fcef0b35 JA |
787 | } |
788 | #endif | |
921c766f JA |
789 | |
790 | return 0; | |
791 | } | |
792 | ||
8e827d35 JA |
793 | /* |
794 | * Return next file in the string. Files are separated with ':'. If the ':' | |
795 | * is escaped with a '\', then that ':' is part of the filename and does not | |
796 | * indicate a new file. | |
797 | */ | |
798 | static char *get_next_file_name(char **ptr) | |
799 | { | |
800 | char *str = *ptr; | |
801 | char *p, *start; | |
802 | ||
803 | if (!str || !strlen(str)) | |
804 | return NULL; | |
805 | ||
806 | start = str; | |
807 | do { | |
808 | /* | |
809 | * No colon, we are done | |
810 | */ | |
811 | p = strchr(str, ':'); | |
812 | if (!p) { | |
813 | *ptr = NULL; | |
814 | break; | |
815 | } | |
816 | ||
817 | /* | |
818 | * We got a colon, but it's the first character. Skip and | |
819 | * continue | |
820 | */ | |
821 | if (p == start) { | |
822 | str = ++start; | |
823 | continue; | |
824 | } | |
825 | ||
826 | if (*(p - 1) != '\\') { | |
827 | *p = '\0'; | |
828 | *ptr = p + 1; | |
829 | break; | |
830 | } | |
831 | ||
832 | memmove(p - 1, p, strlen(p) + 1); | |
833 | str = p; | |
834 | } while (1); | |
835 | ||
836 | return start; | |
837 | } | |
838 | ||
214e1eca JA |
839 | static int str_filename_cb(void *data, const char *input) |
840 | { | |
841 | struct thread_data *td = data; | |
842 | char *fname, *str, *p; | |
843 | ||
844 | p = str = strdup(input); | |
845 | ||
846 | strip_blank_front(&str); | |
847 | strip_blank_end(str); | |
848 | ||
849 | if (!td->files_index) | |
2dc1bbeb | 850 | td->o.nr_files = 0; |
214e1eca | 851 | |
8e827d35 | 852 | while ((fname = get_next_file_name(&str)) != NULL) { |
214e1eca JA |
853 | if (!strlen(fname)) |
854 | break; | |
921c766f JA |
855 | if (check_dir(td, fname)) { |
856 | free(p); | |
857 | return 1; | |
858 | } | |
214e1eca | 859 | add_file(td, fname); |
2dc1bbeb | 860 | td->o.nr_files++; |
214e1eca JA |
861 | } |
862 | ||
863 | free(p); | |
864 | return 0; | |
865 | } | |
866 | ||
867 | static int str_directory_cb(void *data, const char fio_unused *str) | |
868 | { | |
869 | struct thread_data *td = data; | |
870 | struct stat sb; | |
871 | ||
2dc1bbeb | 872 | if (lstat(td->o.directory, &sb) < 0) { |
921c766f JA |
873 | int ret = errno; |
874 | ||
2dc1bbeb | 875 | log_err("fio: %s is not a directory\n", td->o.directory); |
921c766f | 876 | td_verror(td, ret, "lstat"); |
214e1eca JA |
877 | return 1; |
878 | } | |
879 | if (!S_ISDIR(sb.st_mode)) { | |
2dc1bbeb | 880 | log_err("fio: %s is not a directory\n", td->o.directory); |
214e1eca JA |
881 | return 1; |
882 | } | |
883 | ||
884 | return 0; | |
885 | } | |
886 | ||
887 | static int str_opendir_cb(void *data, const char fio_unused *str) | |
888 | { | |
889 | struct thread_data *td = data; | |
890 | ||
891 | if (!td->files_index) | |
2dc1bbeb | 892 | td->o.nr_files = 0; |
214e1eca | 893 | |
2dc1bbeb | 894 | return add_dir_files(td, td->o.opendir); |
214e1eca JA |
895 | } |
896 | ||
85bc833b | 897 | static int str_verify_offset_cb(void *data, unsigned long long *off) |
546a9142 SL |
898 | { |
899 | struct thread_data *td = data; | |
a59e170d | 900 | |
546a9142 | 901 | if (*off && *off < sizeof(struct verify_header)) { |
a59e170d | 902 | log_err("fio: verify_offset too small\n"); |
546a9142 SL |
903 | return 1; |
904 | } | |
a59e170d JA |
905 | |
906 | td->o.verify_offset = *off; | |
546a9142 SL |
907 | return 0; |
908 | } | |
909 | ||
0e92f873 | 910 | static int str_verify_pattern_cb(void *data, const char *input) |
90059d65 JA |
911 | { |
912 | struct thread_data *td = data; | |
0e92f873 RR |
913 | long off; |
914 | int i = 0, j = 0, len, k, base = 10; | |
915 | char* loc1, * loc2; | |
916 | ||
917 | loc1 = strstr(input, "0x"); | |
918 | loc2 = strstr(input, "0X"); | |
919 | if (loc1 || loc2) | |
920 | base = 16; | |
921 | off = strtol(input, NULL, base); | |
922 | if (off != LONG_MAX || errno != ERANGE) { | |
923 | while (off) { | |
924 | td->o.verify_pattern[i] = off & 0xff; | |
925 | off >>= 8; | |
926 | i++; | |
927 | } | |
928 | } else { | |
929 | len = strlen(input); | |
930 | k = len - 1; | |
931 | if (base == 16) { | |
932 | if (loc1) | |
933 | j = loc1 - input + 2; | |
934 | else | |
935 | j = loc2 - input + 2; | |
936 | } else | |
937 | return 1; | |
938 | if (len - j < MAX_PATTERN_SIZE * 2) { | |
939 | while (k >= j) { | |
940 | off = converthexchartoint(input[k--]); | |
941 | if (k >= j) | |
942 | off += (converthexchartoint(input[k--]) | |
943 | * 16); | |
944 | td->o.verify_pattern[i++] = (char) off; | |
945 | } | |
946 | } | |
947 | } | |
efcd9dcc SL |
948 | |
949 | /* | |
950 | * Fill the pattern all the way to the end. This greatly reduces | |
951 | * the number of memcpy's we have to do when verifying the IO. | |
952 | */ | |
953 | while (i > 1 && i * 2 <= MAX_PATTERN_SIZE) { | |
954 | memcpy(&td->o.verify_pattern[i], &td->o.verify_pattern[0], i); | |
955 | i *= 2; | |
956 | } | |
9a2a86d0 SL |
957 | if (i == 1) { |
958 | /* | |
959 | * The code in verify_io_u_pattern assumes a single byte pattern | |
960 | * fills the whole verify pattern buffer. | |
961 | */ | |
962 | memset(td->o.verify_pattern, td->o.verify_pattern[0], | |
963 | MAX_PATTERN_SIZE); | |
964 | } | |
efcd9dcc | 965 | |
0e92f873 | 966 | td->o.verify_pattern_bytes = i; |
efcd9dcc | 967 | |
92bf48d5 JA |
968 | /* |
969 | * VERIFY_META could already be set | |
970 | */ | |
971 | if (td->o.verify == VERIFY_NONE) | |
972 | td->o.verify = VERIFY_PATTERN; | |
efcd9dcc | 973 | |
90059d65 JA |
974 | return 0; |
975 | } | |
214e1eca | 976 | |
4d4e80f2 JA |
977 | static int str_lockfile_cb(void *data, const char *str) |
978 | { | |
979 | struct thread_data *td = data; | |
980 | char *nr = get_opt_postfix(str); | |
981 | ||
982 | td->o.lockfile_batch = 1; | |
182ec6ee | 983 | if (nr) { |
4d4e80f2 | 984 | td->o.lockfile_batch = atoi(nr); |
182ec6ee JA |
985 | free(nr); |
986 | } | |
4d4e80f2 JA |
987 | |
988 | return 0; | |
989 | } | |
990 | ||
e3cedca7 JA |
991 | static int str_write_bw_log_cb(void *data, const char *str) |
992 | { | |
993 | struct thread_data *td = data; | |
994 | ||
995 | if (str) | |
996 | td->o.bw_log_file = strdup(str); | |
997 | ||
998 | td->o.write_bw_log = 1; | |
999 | return 0; | |
1000 | } | |
1001 | ||
1002 | static int str_write_lat_log_cb(void *data, const char *str) | |
1003 | { | |
1004 | struct thread_data *td = data; | |
1005 | ||
1006 | if (str) | |
1007 | td->o.lat_log_file = strdup(str); | |
1008 | ||
1009 | td->o.write_lat_log = 1; | |
1010 | return 0; | |
1011 | } | |
1012 | ||
c8eeb9df JA |
1013 | static int str_write_iops_log_cb(void *data, const char *str) |
1014 | { | |
1015 | struct thread_data *td = data; | |
1016 | ||
1017 | if (str) | |
1018 | td->o.iops_log_file = strdup(str); | |
1019 | ||
1020 | td->o.write_iops_log = 1; | |
1021 | return 0; | |
1022 | } | |
1023 | ||
993bf48b JA |
1024 | static int str_gtod_reduce_cb(void *data, int *il) |
1025 | { | |
1026 | struct thread_data *td = data; | |
1027 | int val = *il; | |
1028 | ||
02af0988 | 1029 | td->o.disable_lat = !!val; |
993bf48b JA |
1030 | td->o.disable_clat = !!val; |
1031 | td->o.disable_slat = !!val; | |
1032 | td->o.disable_bw = !!val; | |
0dc1bc03 | 1033 | td->o.clat_percentiles = !val; |
993bf48b JA |
1034 | if (val) |
1035 | td->tv_cache_mask = 63; | |
1036 | ||
1037 | return 0; | |
1038 | } | |
1039 | ||
85bc833b | 1040 | static int str_gtod_cpu_cb(void *data, long long *il) |
be4ecfdf JA |
1041 | { |
1042 | struct thread_data *td = data; | |
1043 | int val = *il; | |
1044 | ||
1045 | td->o.gtod_cpu = val; | |
1046 | td->o.gtod_offload = 1; | |
1047 | return 0; | |
1048 | } | |
1049 | ||
7bb59102 JA |
1050 | static int str_size_cb(void *data, unsigned long long *__val) |
1051 | { | |
1052 | struct thread_data *td = data; | |
1053 | unsigned long long v = *__val; | |
1054 | ||
1055 | if (parse_is_percent(v)) { | |
1056 | td->o.size = 0; | |
1057 | td->o.size_percent = -1ULL - v; | |
1058 | } else | |
1059 | td->o.size = v; | |
1060 | ||
1061 | return 0; | |
1062 | } | |
1063 | ||
896cac2a JA |
1064 | static int rw_verify(struct fio_option *o, void *data) |
1065 | { | |
1066 | struct thread_data *td = data; | |
1067 | ||
1068 | if (read_only && td_write(td)) { | |
1069 | log_err("fio: job <%s> has write bit set, but fio is in" | |
1070 | " read-only mode\n", td->o.name); | |
1071 | return 1; | |
1072 | } | |
1073 | ||
1074 | return 0; | |
1075 | } | |
1076 | ||
276ca4f7 | 1077 | static int gtod_cpu_verify(struct fio_option *o, void *data) |
29d43ff9 | 1078 | { |
276ca4f7 | 1079 | #ifndef FIO_HAVE_CPU_AFFINITY |
29d43ff9 JA |
1080 | struct thread_data *td = data; |
1081 | ||
29d43ff9 JA |
1082 | if (td->o.gtod_cpu) { |
1083 | log_err("fio: platform must support CPU affinity for" | |
1084 | "gettimeofday() offloading\n"); | |
1085 | return 1; | |
1086 | } | |
1087 | #endif | |
1088 | ||
1089 | return 0; | |
1090 | } | |
1091 | ||
90fef2d1 JA |
1092 | static int kb_base_verify(struct fio_option *o, void *data) |
1093 | { | |
1094 | struct thread_data *td = data; | |
1095 | ||
1096 | if (td->o.kb_base != 1024 && td->o.kb_base != 1000) { | |
1097 | log_err("fio: kb_base set to nonsensical value: %u\n", | |
1098 | td->o.kb_base); | |
1099 | return 1; | |
1100 | } | |
1101 | ||
1102 | return 0; | |
1103 | } | |
1104 | ||
214e1eca JA |
1105 | /* |
1106 | * Map of job/command line options | |
1107 | */ | |
07b3232d | 1108 | static struct fio_option options[FIO_MAX_OPTS] = { |
214e1eca JA |
1109 | { |
1110 | .name = "description", | |
1111 | .type = FIO_OPT_STR_STORE, | |
1112 | .off1 = td_var_offset(description), | |
1113 | .help = "Text job description", | |
1114 | }, | |
1115 | { | |
1116 | .name = "name", | |
1117 | .type = FIO_OPT_STR_STORE, | |
1118 | .off1 = td_var_offset(name), | |
1119 | .help = "Name of this job", | |
1120 | }, | |
1121 | { | |
1122 | .name = "directory", | |
1123 | .type = FIO_OPT_STR_STORE, | |
1124 | .off1 = td_var_offset(directory), | |
1125 | .cb = str_directory_cb, | |
1126 | .help = "Directory to store files in", | |
1127 | }, | |
1128 | { | |
1129 | .name = "filename", | |
1130 | .type = FIO_OPT_STR_STORE, | |
1131 | .off1 = td_var_offset(filename), | |
1132 | .cb = str_filename_cb, | |
f0d524b0 | 1133 | .prio = -1, /* must come after "directory" */ |
214e1eca JA |
1134 | .help = "File(s) to use for the workload", |
1135 | }, | |
90fef2d1 JA |
1136 | { |
1137 | .name = "kb_base", | |
1138 | .type = FIO_OPT_INT, | |
1139 | .off1 = td_var_offset(kb_base), | |
90fef2d1 | 1140 | .verify = kb_base_verify, |
a639f0bb | 1141 | .prio = 1, |
90fef2d1 | 1142 | .def = "1024", |
a639f0bb | 1143 | .help = "How many bytes per KB for reporting (1000 or 1024)", |
90fef2d1 | 1144 | }, |
29c1349f JA |
1145 | { |
1146 | .name = "lockfile", | |
4d4e80f2 JA |
1147 | .type = FIO_OPT_STR, |
1148 | .cb = str_lockfile_cb, | |
1149 | .off1 = td_var_offset(file_lock_mode), | |
29c1349f JA |
1150 | .help = "Lock file when doing IO to it", |
1151 | .parent = "filename", | |
4d4e80f2 JA |
1152 | .def = "none", |
1153 | .posval = { | |
1154 | { .ival = "none", | |
1155 | .oval = FILE_LOCK_NONE, | |
1156 | .help = "No file locking", | |
1157 | }, | |
1158 | { .ival = "exclusive", | |
1159 | .oval = FILE_LOCK_EXCLUSIVE, | |
1160 | .help = "Exclusive file lock", | |
1161 | }, | |
1162 | { | |
1163 | .ival = "readwrite", | |
1164 | .oval = FILE_LOCK_READWRITE, | |
1165 | .help = "Read vs write lock", | |
1166 | }, | |
1167 | }, | |
29c1349f | 1168 | }, |
214e1eca JA |
1169 | { |
1170 | .name = "opendir", | |
1171 | .type = FIO_OPT_STR_STORE, | |
1172 | .off1 = td_var_offset(opendir), | |
1173 | .cb = str_opendir_cb, | |
1174 | .help = "Recursively add files from this directory and down", | |
1175 | }, | |
1176 | { | |
1177 | .name = "rw", | |
d3aad8f2 | 1178 | .alias = "readwrite", |
214e1eca | 1179 | .type = FIO_OPT_STR, |
211097b2 | 1180 | .cb = str_rw_cb, |
214e1eca JA |
1181 | .off1 = td_var_offset(td_ddir), |
1182 | .help = "IO direction", | |
1183 | .def = "read", | |
896cac2a | 1184 | .verify = rw_verify, |
214e1eca JA |
1185 | .posval = { |
1186 | { .ival = "read", | |
1187 | .oval = TD_DDIR_READ, | |
1188 | .help = "Sequential read", | |
1189 | }, | |
1190 | { .ival = "write", | |
1191 | .oval = TD_DDIR_WRITE, | |
1192 | .help = "Sequential write", | |
1193 | }, | |
6eaf09d6 SL |
1194 | { .ival = "trim", |
1195 | .oval = TD_DDIR_TRIM, | |
1196 | .help = "Sequential trim", | |
1197 | }, | |
214e1eca JA |
1198 | { .ival = "randread", |
1199 | .oval = TD_DDIR_RANDREAD, | |
1200 | .help = "Random read", | |
1201 | }, | |
1202 | { .ival = "randwrite", | |
1203 | .oval = TD_DDIR_RANDWRITE, | |
1204 | .help = "Random write", | |
1205 | }, | |
6eaf09d6 SL |
1206 | { .ival = "randtrim", |
1207 | .oval = TD_DDIR_RANDTRIM, | |
1208 | .help = "Random trim", | |
1209 | }, | |
214e1eca JA |
1210 | { .ival = "rw", |
1211 | .oval = TD_DDIR_RW, | |
1212 | .help = "Sequential read and write mix", | |
1213 | }, | |
10b023db JA |
1214 | { .ival = "readwrite", |
1215 | .oval = TD_DDIR_RW, | |
1216 | .help = "Sequential read and write mix", | |
1217 | }, | |
214e1eca JA |
1218 | { .ival = "randrw", |
1219 | .oval = TD_DDIR_RANDRW, | |
1220 | .help = "Random read and write mix" | |
1221 | }, | |
1222 | }, | |
1223 | }, | |
38dad62d JA |
1224 | { |
1225 | .name = "rw_sequencer", | |
1226 | .type = FIO_OPT_STR, | |
1227 | .off1 = td_var_offset(rw_seq), | |
1228 | .help = "IO offset generator modifier", | |
1229 | .def = "sequential", | |
1230 | .posval = { | |
1231 | { .ival = "sequential", | |
1232 | .oval = RW_SEQ_SEQ, | |
1233 | .help = "Generate sequential offsets", | |
1234 | }, | |
1235 | { .ival = "identical", | |
1236 | .oval = RW_SEQ_IDENT, | |
1237 | .help = "Generate identical offsets", | |
1238 | }, | |
1239 | }, | |
1240 | }, | |
1241 | ||
214e1eca JA |
1242 | { |
1243 | .name = "ioengine", | |
1244 | .type = FIO_OPT_STR_STORE, | |
1245 | .off1 = td_var_offset(ioengine), | |
1246 | .help = "IO engine to use", | |
58483fa4 | 1247 | .def = FIO_PREFERRED_ENGINE, |
214e1eca JA |
1248 | .posval = { |
1249 | { .ival = "sync", | |
1250 | .help = "Use read/write", | |
1251 | }, | |
a31041ea | 1252 | { .ival = "psync", |
1253 | .help = "Use pread/pwrite", | |
1254 | }, | |
1d2af02a | 1255 | { .ival = "vsync", |
03e20d68 | 1256 | .help = "Use readv/writev", |
1d2af02a | 1257 | }, |
214e1eca JA |
1258 | #ifdef FIO_HAVE_LIBAIO |
1259 | { .ival = "libaio", | |
1260 | .help = "Linux native asynchronous IO", | |
1261 | }, | |
1262 | #endif | |
1263 | #ifdef FIO_HAVE_POSIXAIO | |
1264 | { .ival = "posixaio", | |
1265 | .help = "POSIX asynchronous IO", | |
1266 | }, | |
417f0068 JA |
1267 | #endif |
1268 | #ifdef FIO_HAVE_SOLARISAIO | |
1269 | { .ival = "solarisaio", | |
1270 | .help = "Solaris native asynchronous IO", | |
1271 | }, | |
214e1eca | 1272 | #endif |
03e20d68 BC |
1273 | #ifdef FIO_HAVE_WINDOWSAIO |
1274 | { .ival = "windowsaio", | |
3be80071 | 1275 | .help = "Windows native asynchronous IO" |
de890a1e | 1276 | }, |
3be80071 | 1277 | #endif |
214e1eca | 1278 | { .ival = "mmap", |
03e20d68 | 1279 | .help = "Memory mapped IO" |
214e1eca JA |
1280 | }, |
1281 | #ifdef FIO_HAVE_SPLICE | |
1282 | { .ival = "splice", | |
1283 | .help = "splice/vmsplice based IO", | |
1284 | }, | |
9cce02e8 JA |
1285 | { .ival = "netsplice", |
1286 | .help = "splice/vmsplice to/from the network", | |
1287 | }, | |
214e1eca JA |
1288 | #endif |
1289 | #ifdef FIO_HAVE_SGIO | |
1290 | { .ival = "sg", | |
1291 | .help = "SCSI generic v3 IO", | |
1292 | }, | |
1293 | #endif | |
1294 | { .ival = "null", | |
1295 | .help = "Testing engine (no data transfer)", | |
1296 | }, | |
1297 | { .ival = "net", | |
1298 | .help = "Network IO", | |
1299 | }, | |
1300 | #ifdef FIO_HAVE_SYSLET | |
1301 | { .ival = "syslet-rw", | |
1302 | .help = "syslet enabled async pread/pwrite IO", | |
1303 | }, | |
1304 | #endif | |
1305 | { .ival = "cpuio", | |
03e20d68 | 1306 | .help = "CPU cycle burner engine", |
214e1eca | 1307 | }, |
b8c82a46 JA |
1308 | #ifdef FIO_HAVE_GUASI |
1309 | { .ival = "guasi", | |
1310 | .help = "GUASI IO engine", | |
1311 | }, | |
79a43187 JA |
1312 | #endif |
1313 | #ifdef FIO_HAVE_BINJECT | |
1314 | { .ival = "binject", | |
1315 | .help = "binject direct inject block engine", | |
1316 | }, | |
21b8aee8 | 1317 | #endif |
1318 | #ifdef FIO_HAVE_RDMA | |
1319 | { .ival = "rdma", | |
1320 | .help = "RDMA IO engine", | |
1321 | }, | |
8200b8c7 JA |
1322 | #endif |
1323 | #ifdef FIO_HAVE_FUSION_AW | |
1324 | { .ival = "fusion-aw-sync", | |
1325 | .help = "Fusion-io atomic write engine", | |
1326 | }, | |
1ecc95ca JA |
1327 | #endif |
1328 | #ifdef FIO_HAVE_E4_ENG | |
1329 | { .ival = "e4defrag", | |
1330 | .help = "ext4 defrag engine", | |
1331 | }, | |
1332 | #endif | |
1333 | #ifdef FIO_HAVE_FALLOC_ENG | |
1334 | { .ival = "falloc", | |
1335 | .help = "fallocate() file based engine", | |
1336 | }, | |
b8c82a46 | 1337 | #endif |
214e1eca JA |
1338 | { .ival = "external", |
1339 | .help = "Load external engine (append name)", | |
1340 | }, | |
1341 | }, | |
1342 | }, | |
1343 | { | |
1344 | .name = "iodepth", | |
1345 | .type = FIO_OPT_INT, | |
1346 | .off1 = td_var_offset(iodepth), | |
03e20d68 | 1347 | .help = "Number of IO buffers to keep in flight", |
757aff4f | 1348 | .minval = 1, |
214e1eca JA |
1349 | .def = "1", |
1350 | }, | |
1351 | { | |
1352 | .name = "iodepth_batch", | |
4950421a | 1353 | .alias = "iodepth_batch_submit", |
214e1eca JA |
1354 | .type = FIO_OPT_INT, |
1355 | .off1 = td_var_offset(iodepth_batch), | |
d65db441 | 1356 | .help = "Number of IO buffers to submit in one go", |
afdf9352 | 1357 | .parent = "iodepth", |
a2e6f8ac JA |
1358 | .minval = 1, |
1359 | .def = "1", | |
4950421a JA |
1360 | }, |
1361 | { | |
1362 | .name = "iodepth_batch_complete", | |
1363 | .type = FIO_OPT_INT, | |
1364 | .off1 = td_var_offset(iodepth_batch_complete), | |
d65db441 | 1365 | .help = "Number of IO buffers to retrieve in one go", |
4950421a JA |
1366 | .parent = "iodepth", |
1367 | .minval = 0, | |
1368 | .def = "1", | |
214e1eca JA |
1369 | }, |
1370 | { | |
1371 | .name = "iodepth_low", | |
1372 | .type = FIO_OPT_INT, | |
1373 | .off1 = td_var_offset(iodepth_low), | |
1374 | .help = "Low water mark for queuing depth", | |
afdf9352 | 1375 | .parent = "iodepth", |
214e1eca JA |
1376 | }, |
1377 | { | |
1378 | .name = "size", | |
1379 | .type = FIO_OPT_STR_VAL, | |
7bb59102 | 1380 | .cb = str_size_cb, |
214e1eca JA |
1381 | .help = "Total size of device or files", |
1382 | }, | |
aa31f1f1 SL |
1383 | { |
1384 | .name = "fill_device", | |
74586c1e | 1385 | .alias = "fill_fs", |
aa31f1f1 SL |
1386 | .type = FIO_OPT_BOOL, |
1387 | .off1 = td_var_offset(fill_device), | |
1388 | .help = "Write until an ENOSPC error occurs", | |
1389 | .def = "0", | |
1390 | }, | |
214e1eca JA |
1391 | { |
1392 | .name = "filesize", | |
1393 | .type = FIO_OPT_STR_VAL, | |
1394 | .off1 = td_var_offset(file_size_low), | |
1395 | .off2 = td_var_offset(file_size_high), | |
c3edbdba | 1396 | .minval = 1, |
214e1eca JA |
1397 | .help = "Size of individual files", |
1398 | }, | |
67a1000f JA |
1399 | { |
1400 | .name = "offset", | |
1401 | .alias = "fileoffset", | |
1402 | .type = FIO_OPT_STR_VAL, | |
1403 | .off1 = td_var_offset(start_offset), | |
1404 | .help = "Start IO from this offset", | |
1405 | .def = "0", | |
1406 | }, | |
2d7cd868 JA |
1407 | { |
1408 | .name = "offset_increment", | |
1409 | .type = FIO_OPT_STR_VAL, | |
1410 | .off1 = td_var_offset(offset_increment), | |
1411 | .help = "What is the increment from one offset to the next", | |
1412 | .parent = "offset", | |
1413 | .def = "0", | |
1414 | }, | |
214e1eca JA |
1415 | { |
1416 | .name = "bs", | |
d3aad8f2 | 1417 | .alias = "blocksize", |
e01b22b8 | 1418 | .type = FIO_OPT_INT, |
214e1eca JA |
1419 | .off1 = td_var_offset(bs[DDIR_READ]), |
1420 | .off2 = td_var_offset(bs[DDIR_WRITE]), | |
6eaf09d6 | 1421 | .off3 = td_var_offset(bs[DDIR_TRIM]), |
c3edbdba | 1422 | .minval = 1, |
214e1eca JA |
1423 | .help = "Block size unit", |
1424 | .def = "4k", | |
67a1000f | 1425 | .parent = "rw", |
214e1eca | 1426 | }, |
2b7a01d0 JA |
1427 | { |
1428 | .name = "ba", | |
1429 | .alias = "blockalign", | |
e01b22b8 | 1430 | .type = FIO_OPT_INT, |
2b7a01d0 JA |
1431 | .off1 = td_var_offset(ba[DDIR_READ]), |
1432 | .off2 = td_var_offset(ba[DDIR_WRITE]), | |
6eaf09d6 | 1433 | .off3 = td_var_offset(ba[DDIR_TRIM]), |
2b7a01d0 JA |
1434 | .minval = 1, |
1435 | .help = "IO block offset alignment", | |
1436 | .parent = "rw", | |
1437 | }, | |
214e1eca JA |
1438 | { |
1439 | .name = "bsrange", | |
d3aad8f2 | 1440 | .alias = "blocksize_range", |
214e1eca JA |
1441 | .type = FIO_OPT_RANGE, |
1442 | .off1 = td_var_offset(min_bs[DDIR_READ]), | |
1443 | .off2 = td_var_offset(max_bs[DDIR_READ]), | |
1444 | .off3 = td_var_offset(min_bs[DDIR_WRITE]), | |
1445 | .off4 = td_var_offset(max_bs[DDIR_WRITE]), | |
6eaf09d6 SL |
1446 | .off5 = td_var_offset(min_bs[DDIR_TRIM]), |
1447 | .off6 = td_var_offset(max_bs[DDIR_TRIM]), | |
c3edbdba | 1448 | .minval = 1, |
214e1eca | 1449 | .help = "Set block size range (in more detail than bs)", |
67a1000f | 1450 | .parent = "rw", |
214e1eca | 1451 | }, |
564ca972 JA |
1452 | { |
1453 | .name = "bssplit", | |
1454 | .type = FIO_OPT_STR, | |
1455 | .cb = str_bssplit_cb, | |
1456 | .help = "Set a specific mix of block sizes", | |
1457 | .parent = "rw", | |
1458 | }, | |
214e1eca JA |
1459 | { |
1460 | .name = "bs_unaligned", | |
d3aad8f2 | 1461 | .alias = "blocksize_unaligned", |
214e1eca JA |
1462 | .type = FIO_OPT_STR_SET, |
1463 | .off1 = td_var_offset(bs_unaligned), | |
1464 | .help = "Don't sector align IO buffer sizes", | |
67a1000f | 1465 | .parent = "rw", |
214e1eca JA |
1466 | }, |
1467 | { | |
1468 | .name = "randrepeat", | |
1469 | .type = FIO_OPT_BOOL, | |
1470 | .off1 = td_var_offset(rand_repeatable), | |
1471 | .help = "Use repeatable random IO pattern", | |
1472 | .def = "1", | |
67a1000f | 1473 | .parent = "rw", |
214e1eca | 1474 | }, |
2615cc4b JA |
1475 | { |
1476 | .name = "use_os_rand", | |
1477 | .type = FIO_OPT_BOOL, | |
1478 | .off1 = td_var_offset(use_os_rand), | |
1479 | .help = "Set to use OS random generator", | |
1480 | .def = "0", | |
1481 | .parent = "rw", | |
1482 | }, | |
214e1eca JA |
1483 | { |
1484 | .name = "norandommap", | |
1485 | .type = FIO_OPT_STR_SET, | |
1486 | .off1 = td_var_offset(norandommap), | |
1487 | .help = "Accept potential duplicate random blocks", | |
67a1000f | 1488 | .parent = "rw", |
214e1eca | 1489 | }, |
2b386d25 JA |
1490 | { |
1491 | .name = "softrandommap", | |
1492 | .type = FIO_OPT_BOOL, | |
1493 | .off1 = td_var_offset(softrandommap), | |
f66ab3c8 | 1494 | .help = "Set norandommap if randommap allocation fails", |
2b386d25 JA |
1495 | .parent = "norandommap", |
1496 | .def = "0", | |
1497 | }, | |
e25839d4 JA |
1498 | { |
1499 | .name = "random_distribution", | |
1500 | .type = FIO_OPT_STR, | |
1501 | .off1 = td_var_offset(random_distribution), | |
1502 | .cb = str_random_distribution_cb, | |
1503 | .help = "Random offset distribution generator", | |
1504 | .def = "random", | |
1505 | .posval = { | |
1506 | { .ival = "random", | |
1507 | .oval = FIO_RAND_DIST_RANDOM, | |
1508 | .help = "Completely random", | |
1509 | }, | |
1510 | { .ival = "zipf", | |
1511 | .oval = FIO_RAND_DIST_ZIPF, | |
1512 | .help = "Zipf distribution", | |
1513 | }, | |
1514 | }, | |
1515 | }, | |
214e1eca JA |
1516 | { |
1517 | .name = "nrfiles", | |
d7c8be03 | 1518 | .alias = "nr_files", |
214e1eca JA |
1519 | .type = FIO_OPT_INT, |
1520 | .off1 = td_var_offset(nr_files), | |
1521 | .help = "Split job workload between this number of files", | |
1522 | .def = "1", | |
1523 | }, | |
1524 | { | |
1525 | .name = "openfiles", | |
1526 | .type = FIO_OPT_INT, | |
1527 | .off1 = td_var_offset(open_files), | |
1528 | .help = "Number of files to keep open at the same time", | |
1529 | }, | |
1530 | { | |
1531 | .name = "file_service_type", | |
1532 | .type = FIO_OPT_STR, | |
1533 | .cb = str_fst_cb, | |
1534 | .off1 = td_var_offset(file_service_type), | |
1535 | .help = "How to select which file to service next", | |
1536 | .def = "roundrobin", | |
1537 | .posval = { | |
1538 | { .ival = "random", | |
1539 | .oval = FIO_FSERVICE_RANDOM, | |
1540 | .help = "Choose a file at random", | |
1541 | }, | |
1542 | { .ival = "roundrobin", | |
1543 | .oval = FIO_FSERVICE_RR, | |
1544 | .help = "Round robin select files", | |
1545 | }, | |
a086c257 JA |
1546 | { .ival = "sequential", |
1547 | .oval = FIO_FSERVICE_SEQ, | |
1548 | .help = "Finish one file before moving to the next", | |
1549 | }, | |
214e1eca | 1550 | }, |
67a1000f JA |
1551 | .parent = "nrfiles", |
1552 | }, | |
7bc8c2cf JA |
1553 | #ifdef FIO_HAVE_FALLOCATE |
1554 | { | |
1555 | .name = "fallocate", | |
a596f047 EG |
1556 | .type = FIO_OPT_STR, |
1557 | .off1 = td_var_offset(fallocate_mode), | |
1558 | .help = "Whether pre-allocation is performed when laying out files", | |
1559 | .def = "posix", | |
1560 | .posval = { | |
1561 | { .ival = "none", | |
1562 | .oval = FIO_FALLOCATE_NONE, | |
1563 | .help = "Do not pre-allocate space", | |
1564 | }, | |
1565 | { .ival = "posix", | |
1566 | .oval = FIO_FALLOCATE_POSIX, | |
1567 | .help = "Use posix_fallocate()", | |
1568 | }, | |
1569 | #ifdef FIO_HAVE_LINUX_FALLOCATE | |
1570 | { .ival = "keep", | |
1571 | .oval = FIO_FALLOCATE_KEEP_SIZE, | |
1572 | .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)", | |
1573 | }, | |
7bc8c2cf | 1574 | #endif |
a596f047 EG |
1575 | /* Compatibility with former boolean values */ |
1576 | { .ival = "0", | |
1577 | .oval = FIO_FALLOCATE_NONE, | |
1578 | .help = "Alias for 'none'", | |
1579 | }, | |
1580 | { .ival = "1", | |
1581 | .oval = FIO_FALLOCATE_POSIX, | |
1582 | .help = "Alias for 'posix'", | |
1583 | }, | |
1584 | }, | |
1585 | }, | |
1586 | #endif /* FIO_HAVE_FALLOCATE */ | |
67a1000f JA |
1587 | { |
1588 | .name = "fadvise_hint", | |
1589 | .type = FIO_OPT_BOOL, | |
1590 | .off1 = td_var_offset(fadvise_hint), | |
1591 | .help = "Use fadvise() to advise the kernel on IO pattern", | |
1592 | .def = "1", | |
214e1eca JA |
1593 | }, |
1594 | { | |
1595 | .name = "fsync", | |
1596 | .type = FIO_OPT_INT, | |
1597 | .off1 = td_var_offset(fsync_blocks), | |
1598 | .help = "Issue fsync for writes every given number of blocks", | |
1599 | .def = "0", | |
1600 | }, | |
5f9099ea JA |
1601 | { |
1602 | .name = "fdatasync", | |
1603 | .type = FIO_OPT_INT, | |
1604 | .off1 = td_var_offset(fdatasync_blocks), | |
1605 | .help = "Issue fdatasync for writes every given number of blocks", | |
1606 | .def = "0", | |
1607 | }, | |
1ef2b6be JA |
1608 | { |
1609 | .name = "write_barrier", | |
1610 | .type = FIO_OPT_INT, | |
1611 | .off1 = td_var_offset(barrier_blocks), | |
1612 | .help = "Make every Nth write a barrier write", | |
1613 | .def = "0", | |
1614 | }, | |
44f29692 JA |
1615 | #ifdef FIO_HAVE_SYNC_FILE_RANGE |
1616 | { | |
1617 | .name = "sync_file_range", | |
1618 | .posval = { | |
1619 | { .ival = "wait_before", | |
1620 | .oval = SYNC_FILE_RANGE_WAIT_BEFORE, | |
1621 | .help = "SYNC_FILE_RANGE_WAIT_BEFORE", | |
3843deb3 | 1622 | .or = 1, |
44f29692 JA |
1623 | }, |
1624 | { .ival = "write", | |
1625 | .oval = SYNC_FILE_RANGE_WRITE, | |
1626 | .help = "SYNC_FILE_RANGE_WRITE", | |
3843deb3 | 1627 | .or = 1, |
44f29692 JA |
1628 | }, |
1629 | { | |
1630 | .ival = "wait_after", | |
1631 | .oval = SYNC_FILE_RANGE_WAIT_AFTER, | |
1632 | .help = "SYNC_FILE_RANGE_WAIT_AFTER", | |
3843deb3 | 1633 | .or = 1, |
44f29692 JA |
1634 | }, |
1635 | }, | |
3843deb3 | 1636 | .type = FIO_OPT_STR_MULTI, |
44f29692 JA |
1637 | .cb = str_sfr_cb, |
1638 | .off1 = td_var_offset(sync_file_range), | |
1639 | .help = "Use sync_file_range()", | |
1640 | }, | |
1641 | #endif | |
214e1eca JA |
1642 | { |
1643 | .name = "direct", | |
1644 | .type = FIO_OPT_BOOL, | |
1645 | .off1 = td_var_offset(odirect), | |
1646 | .help = "Use O_DIRECT IO (negates buffered)", | |
1647 | .def = "0", | |
1648 | }, | |
1649 | { | |
1650 | .name = "buffered", | |
1651 | .type = FIO_OPT_BOOL, | |
1652 | .off1 = td_var_offset(odirect), | |
1653 | .neg = 1, | |
1654 | .help = "Use buffered IO (negates direct)", | |
1655 | .def = "1", | |
1656 | }, | |
1657 | { | |
1658 | .name = "overwrite", | |
1659 | .type = FIO_OPT_BOOL, | |
1660 | .off1 = td_var_offset(overwrite), | |
1661 | .help = "When writing, set whether to overwrite current data", | |
1662 | .def = "0", | |
1663 | }, | |
1664 | { | |
1665 | .name = "loops", | |
1666 | .type = FIO_OPT_INT, | |
1667 | .off1 = td_var_offset(loops), | |
1668 | .help = "Number of times to run the job", | |
1669 | .def = "1", | |
1670 | }, | |
1671 | { | |
1672 | .name = "numjobs", | |
1673 | .type = FIO_OPT_INT, | |
1674 | .off1 = td_var_offset(numjobs), | |
1675 | .help = "Duplicate this job this many times", | |
1676 | .def = "1", | |
1677 | }, | |
1678 | { | |
1679 | .name = "startdelay", | |
a5737c93 | 1680 | .type = FIO_OPT_STR_VAL_TIME, |
214e1eca JA |
1681 | .off1 = td_var_offset(start_delay), |
1682 | .help = "Only start job when this period has passed", | |
1683 | .def = "0", | |
1684 | }, | |
1685 | { | |
1686 | .name = "runtime", | |
1687 | .alias = "timeout", | |
1688 | .type = FIO_OPT_STR_VAL_TIME, | |
1689 | .off1 = td_var_offset(timeout), | |
1690 | .help = "Stop workload when this amount of time has passed", | |
1691 | .def = "0", | |
1692 | }, | |
cf4464ca JA |
1693 | { |
1694 | .name = "time_based", | |
1695 | .type = FIO_OPT_STR_SET, | |
1696 | .off1 = td_var_offset(time_based), | |
1697 | .help = "Keep running until runtime/timeout is met", | |
1698 | }, | |
721938ae JA |
1699 | { |
1700 | .name = "ramp_time", | |
1701 | .type = FIO_OPT_STR_VAL_TIME, | |
1702 | .off1 = td_var_offset(ramp_time), | |
1703 | .help = "Ramp up time before measuring performance", | |
1704 | }, | |
c223da83 JA |
1705 | { |
1706 | .name = "clocksource", | |
1707 | .type = FIO_OPT_STR, | |
1708 | .cb = fio_clock_source_cb, | |
1709 | .off1 = td_var_offset(clocksource), | |
1710 | .help = "What type of timing source to use", | |
c223da83 JA |
1711 | .posval = { |
1712 | { .ival = "gettimeofday", | |
1713 | .oval = CS_GTOD, | |
1714 | .help = "Use gettimeofday(2) for timing", | |
1715 | }, | |
1716 | { .ival = "clock_gettime", | |
1717 | .oval = CS_CGETTIME, | |
1718 | .help = "Use clock_gettime(2) for timing", | |
1719 | }, | |
1720 | #ifdef ARCH_HAVE_CPU_CLOCK | |
1721 | { .ival = "cpu", | |
1722 | .oval = CS_CPUCLOCK, | |
1723 | .help = "Use CPU private clock", | |
1724 | }, | |
1725 | #endif | |
1726 | }, | |
1727 | }, | |
214e1eca JA |
1728 | { |
1729 | .name = "mem", | |
d3aad8f2 | 1730 | .alias = "iomem", |
214e1eca JA |
1731 | .type = FIO_OPT_STR, |
1732 | .cb = str_mem_cb, | |
1733 | .off1 = td_var_offset(mem_type), | |
1734 | .help = "Backing type for IO buffers", | |
1735 | .def = "malloc", | |
1736 | .posval = { | |
1737 | { .ival = "malloc", | |
1738 | .oval = MEM_MALLOC, | |
1739 | .help = "Use malloc(3) for IO buffers", | |
1740 | }, | |
37c8cdfe JA |
1741 | { .ival = "shm", |
1742 | .oval = MEM_SHM, | |
1743 | .help = "Use shared memory segments for IO buffers", | |
1744 | }, | |
214e1eca JA |
1745 | #ifdef FIO_HAVE_HUGETLB |
1746 | { .ival = "shmhuge", | |
1747 | .oval = MEM_SHMHUGE, | |
1748 | .help = "Like shm, but use huge pages", | |
1749 | }, | |
b370e46a | 1750 | #endif |
37c8cdfe JA |
1751 | { .ival = "mmap", |
1752 | .oval = MEM_MMAP, | |
1753 | .help = "Use mmap(2) (file or anon) for IO buffers", | |
1754 | }, | |
214e1eca JA |
1755 | #ifdef FIO_HAVE_HUGETLB |
1756 | { .ival = "mmaphuge", | |
1757 | .oval = MEM_MMAPHUGE, | |
1758 | .help = "Like mmap, but use huge pages", | |
1759 | }, | |
1760 | #endif | |
1761 | }, | |
1762 | }, | |
d529ee19 JA |
1763 | { |
1764 | .name = "iomem_align", | |
1765 | .alias = "mem_align", | |
1766 | .type = FIO_OPT_INT, | |
1767 | .off1 = td_var_offset(mem_align), | |
1768 | .minval = 0, | |
1769 | .help = "IO memory buffer offset alignment", | |
1770 | .def = "0", | |
1771 | .parent = "iomem", | |
1772 | }, | |
214e1eca JA |
1773 | { |
1774 | .name = "verify", | |
1775 | .type = FIO_OPT_STR, | |
1776 | .off1 = td_var_offset(verify), | |
1777 | .help = "Verify data written", | |
5d7c5d34 | 1778 | .cb = str_verify_cb, |
214e1eca JA |
1779 | .def = "0", |
1780 | .posval = { | |
1781 | { .ival = "0", | |
1782 | .oval = VERIFY_NONE, | |
1783 | .help = "Don't do IO verification", | |
1784 | }, | |
fcca4b58 JA |
1785 | { .ival = "md5", |
1786 | .oval = VERIFY_MD5, | |
1787 | .help = "Use md5 checksums for verification", | |
1788 | }, | |
d77a7af3 JA |
1789 | { .ival = "crc64", |
1790 | .oval = VERIFY_CRC64, | |
1791 | .help = "Use crc64 checksums for verification", | |
1792 | }, | |
214e1eca JA |
1793 | { .ival = "crc32", |
1794 | .oval = VERIFY_CRC32, | |
1795 | .help = "Use crc32 checksums for verification", | |
1796 | }, | |
af497e6a | 1797 | { .ival = "crc32c-intel", |
e3aaafc4 JA |
1798 | .oval = VERIFY_CRC32C, |
1799 | .help = "Use crc32c checksums for verification (hw assisted, if available)", | |
af497e6a | 1800 | }, |
bac39e0e JA |
1801 | { .ival = "crc32c", |
1802 | .oval = VERIFY_CRC32C, | |
e3aaafc4 | 1803 | .help = "Use crc32c checksums for verification (hw assisted, if available)", |
bac39e0e | 1804 | }, |
969f7ed3 JA |
1805 | { .ival = "crc16", |
1806 | .oval = VERIFY_CRC16, | |
1807 | .help = "Use crc16 checksums for verification", | |
1808 | }, | |
1e154bdb JA |
1809 | { .ival = "crc7", |
1810 | .oval = VERIFY_CRC7, | |
1811 | .help = "Use crc7 checksums for verification", | |
1812 | }, | |
7c353ceb JA |
1813 | { .ival = "sha1", |
1814 | .oval = VERIFY_SHA1, | |
1815 | .help = "Use sha1 checksums for verification", | |
1816 | }, | |
cd14cc10 JA |
1817 | { .ival = "sha256", |
1818 | .oval = VERIFY_SHA256, | |
1819 | .help = "Use sha256 checksums for verification", | |
1820 | }, | |
1821 | { .ival = "sha512", | |
1822 | .oval = VERIFY_SHA512, | |
1823 | .help = "Use sha512 checksums for verification", | |
1824 | }, | |
7437ee87 SL |
1825 | { .ival = "meta", |
1826 | .oval = VERIFY_META, | |
1827 | .help = "Use io information", | |
1828 | }, | |
36690c9b JA |
1829 | { |
1830 | .ival = "null", | |
1831 | .oval = VERIFY_NULL, | |
1832 | .help = "Pretend to verify", | |
1833 | }, | |
214e1eca JA |
1834 | }, |
1835 | }, | |
005c565a JA |
1836 | { |
1837 | .name = "do_verify", | |
68e1f29a | 1838 | .type = FIO_OPT_BOOL, |
005c565a JA |
1839 | .off1 = td_var_offset(do_verify), |
1840 | .help = "Run verification stage after write", | |
1841 | .def = "1", | |
1842 | .parent = "verify", | |
1843 | }, | |
160b966d JA |
1844 | { |
1845 | .name = "verifysort", | |
1846 | .type = FIO_OPT_BOOL, | |
1847 | .off1 = td_var_offset(verifysort), | |
1848 | .help = "Sort written verify blocks for read back", | |
1849 | .def = "1", | |
c83f2df1 | 1850 | .parent = "verify", |
160b966d | 1851 | }, |
3f9f4e26 | 1852 | { |
a59e170d | 1853 | .name = "verify_interval", |
e01b22b8 | 1854 | .type = FIO_OPT_INT, |
a59e170d | 1855 | .off1 = td_var_offset(verify_interval), |
819a9680 | 1856 | .minval = 2 * sizeof(struct verify_header), |
a59e170d | 1857 | .help = "Store verify buffer header every N bytes", |
afdf9352 | 1858 | .parent = "verify", |
3f9f4e26 | 1859 | }, |
546a9142 | 1860 | { |
a59e170d | 1861 | .name = "verify_offset", |
e01b22b8 | 1862 | .type = FIO_OPT_INT, |
a59e170d | 1863 | .help = "Offset verify header location by N bytes", |
546a9142 | 1864 | .def = "0", |
5ec10eaa | 1865 | .cb = str_verify_offset_cb, |
afdf9352 | 1866 | .parent = "verify", |
546a9142 | 1867 | }, |
e28218f3 SL |
1868 | { |
1869 | .name = "verify_pattern", | |
0e92f873 | 1870 | .type = FIO_OPT_STR, |
e28218f3 SL |
1871 | .cb = str_verify_pattern_cb, |
1872 | .help = "Fill pattern for IO buffers", | |
1873 | .parent = "verify", | |
1874 | }, | |
a12a3b4d JA |
1875 | { |
1876 | .name = "verify_fatal", | |
68e1f29a | 1877 | .type = FIO_OPT_BOOL, |
a12a3b4d JA |
1878 | .off1 = td_var_offset(verify_fatal), |
1879 | .def = "0", | |
1880 | .help = "Exit on a single verify failure, don't continue", | |
1881 | .parent = "verify", | |
1882 | }, | |
b463e936 JA |
1883 | { |
1884 | .name = "verify_dump", | |
1885 | .type = FIO_OPT_BOOL, | |
1886 | .off1 = td_var_offset(verify_dump), | |
ef71e317 | 1887 | .def = "0", |
b463e936 JA |
1888 | .help = "Dump contents of good and bad blocks on failure", |
1889 | .parent = "verify", | |
1890 | }, | |
e8462bd8 JA |
1891 | { |
1892 | .name = "verify_async", | |
1893 | .type = FIO_OPT_INT, | |
1894 | .off1 = td_var_offset(verify_async), | |
1895 | .def = "0", | |
1896 | .help = "Number of async verifier threads to use", | |
1897 | .parent = "verify", | |
1898 | }, | |
9e144189 JA |
1899 | { |
1900 | .name = "verify_backlog", | |
1901 | .type = FIO_OPT_STR_VAL, | |
1902 | .off1 = td_var_offset(verify_backlog), | |
1903 | .help = "Verify after this number of blocks are written", | |
1904 | .parent = "verify", | |
1905 | }, | |
1906 | { | |
1907 | .name = "verify_backlog_batch", | |
1908 | .type = FIO_OPT_INT, | |
1909 | .off1 = td_var_offset(verify_batch), | |
1910 | .help = "Verify this number of IO blocks", | |
0d29de83 | 1911 | .parent = "verify", |
9e144189 | 1912 | }, |
e8462bd8 JA |
1913 | #ifdef FIO_HAVE_CPU_AFFINITY |
1914 | { | |
1915 | .name = "verify_async_cpus", | |
1916 | .type = FIO_OPT_STR, | |
1917 | .cb = str_verify_cpus_allowed_cb, | |
1918 | .help = "Set CPUs allowed for async verify threads", | |
1919 | .parent = "verify_async", | |
1920 | }, | |
0d29de83 JA |
1921 | #endif |
1922 | #ifdef FIO_HAVE_TRIM | |
1923 | { | |
1924 | .name = "trim_percentage", | |
1925 | .type = FIO_OPT_INT, | |
1926 | .cb = str_verify_trim_cb, | |
1927 | .maxval = 100, | |
1928 | .help = "Number of verify blocks to discard/trim", | |
1929 | .parent = "verify", | |
1930 | .def = "0", | |
1931 | }, | |
1932 | { | |
1933 | .name = "trim_verify_zero", | |
1934 | .type = FIO_OPT_INT, | |
1935 | .help = "Verify that trim/discarded blocks are returned as zeroes", | |
1936 | .off1 = td_var_offset(trim_zero), | |
1937 | .parent = "trim_percentage", | |
1938 | .def = "1", | |
1939 | }, | |
1940 | { | |
1941 | .name = "trim_backlog", | |
1942 | .type = FIO_OPT_STR_VAL, | |
1943 | .off1 = td_var_offset(trim_backlog), | |
1944 | .help = "Trim after this number of blocks are written", | |
1945 | .parent = "trim_percentage", | |
1946 | }, | |
1947 | { | |
1948 | .name = "trim_backlog_batch", | |
1949 | .type = FIO_OPT_INT, | |
1950 | .off1 = td_var_offset(trim_batch), | |
1951 | .help = "Trim this number of IO blocks", | |
1952 | .parent = "trim_percentage", | |
1953 | }, | |
e8462bd8 | 1954 | #endif |
214e1eca JA |
1955 | { |
1956 | .name = "write_iolog", | |
1957 | .type = FIO_OPT_STR_STORE, | |
1958 | .off1 = td_var_offset(write_iolog_file), | |
1959 | .help = "Store IO pattern to file", | |
1960 | }, | |
1961 | { | |
1962 | .name = "read_iolog", | |
1963 | .type = FIO_OPT_STR_STORE, | |
1964 | .off1 = td_var_offset(read_iolog_file), | |
1965 | .help = "Playback IO pattern from file", | |
1966 | }, | |
64bbb865 DN |
1967 | { |
1968 | .name = "replay_no_stall", | |
1969 | .type = FIO_OPT_INT, | |
1970 | .off1 = td_var_offset(no_stall), | |
1971 | .def = "0", | |
87e7a972 | 1972 | .parent = "read_iolog", |
64bbb865 DN |
1973 | .help = "Playback IO pattern file as fast as possible without stalls", |
1974 | }, | |
d1c46c04 DN |
1975 | { |
1976 | .name = "replay_redirect", | |
1977 | .type = FIO_OPT_STR_STORE, | |
1978 | .off1 = td_var_offset(replay_redirect), | |
1979 | .parent = "read_iolog", | |
1980 | .help = "Replay all I/O onto this device, regardless of trace device", | |
1981 | }, | |
214e1eca JA |
1982 | { |
1983 | .name = "exec_prerun", | |
1984 | .type = FIO_OPT_STR_STORE, | |
1985 | .off1 = td_var_offset(exec_prerun), | |
1986 | .help = "Execute this file prior to running job", | |
1987 | }, | |
1988 | { | |
1989 | .name = "exec_postrun", | |
1990 | .type = FIO_OPT_STR_STORE, | |
1991 | .off1 = td_var_offset(exec_postrun), | |
1992 | .help = "Execute this file after running job", | |
1993 | }, | |
1994 | #ifdef FIO_HAVE_IOSCHED_SWITCH | |
1995 | { | |
1996 | .name = "ioscheduler", | |
1997 | .type = FIO_OPT_STR_STORE, | |
1998 | .off1 = td_var_offset(ioscheduler), | |
1999 | .help = "Use this IO scheduler on the backing device", | |
2000 | }, | |
2001 | #endif | |
2002 | { | |
2003 | .name = "zonesize", | |
2004 | .type = FIO_OPT_STR_VAL, | |
2005 | .off1 = td_var_offset(zone_size), | |
ed335855 SN |
2006 | .help = "Amount of data to read per zone", |
2007 | .def = "0", | |
2008 | }, | |
2009 | { | |
2010 | .name = "zonerange", | |
2011 | .type = FIO_OPT_STR_VAL, | |
2012 | .off1 = td_var_offset(zone_range), | |
214e1eca JA |
2013 | .help = "Give size of an IO zone", |
2014 | .def = "0", | |
2015 | }, | |
2016 | { | |
2017 | .name = "zoneskip", | |
2018 | .type = FIO_OPT_STR_VAL, | |
2019 | .off1 = td_var_offset(zone_skip), | |
2020 | .help = "Space between IO zones", | |
2021 | .def = "0", | |
2022 | }, | |
2023 | { | |
2024 | .name = "lockmem", | |
2025 | .type = FIO_OPT_STR_VAL, | |
2026 | .cb = str_lockmem_cb, | |
2027 | .help = "Lock down this amount of memory", | |
2028 | .def = "0", | |
2029 | }, | |
214e1eca JA |
2030 | { |
2031 | .name = "rwmixread", | |
2032 | .type = FIO_OPT_INT, | |
cb499fc4 | 2033 | .cb = str_rwmix_read_cb, |
214e1eca JA |
2034 | .maxval = 100, |
2035 | .help = "Percentage of mixed workload that is reads", | |
2036 | .def = "50", | |
2037 | }, | |
2038 | { | |
2039 | .name = "rwmixwrite", | |
2040 | .type = FIO_OPT_INT, | |
cb499fc4 | 2041 | .cb = str_rwmix_write_cb, |
214e1eca JA |
2042 | .maxval = 100, |
2043 | .help = "Percentage of mixed workload that is writes", | |
2044 | .def = "50", | |
2045 | }, | |
afdf9352 JA |
2046 | { |
2047 | .name = "rwmixcycle", | |
15ca150e | 2048 | .type = FIO_OPT_DEPRECATED, |
afdf9352 | 2049 | }, |
214e1eca JA |
2050 | { |
2051 | .name = "nice", | |
2052 | .type = FIO_OPT_INT, | |
2053 | .off1 = td_var_offset(nice), | |
2054 | .help = "Set job CPU nice value", | |
2055 | .minval = -19, | |
2056 | .maxval = 20, | |
2057 | .def = "0", | |
2058 | }, | |
2059 | #ifdef FIO_HAVE_IOPRIO | |
2060 | { | |
2061 | .name = "prio", | |
2062 | .type = FIO_OPT_INT, | |
2063 | .cb = str_prio_cb, | |
2064 | .help = "Set job IO priority value", | |
2065 | .minval = 0, | |
2066 | .maxval = 7, | |
2067 | }, | |
2068 | { | |
2069 | .name = "prioclass", | |
2070 | .type = FIO_OPT_INT, | |
2071 | .cb = str_prioclass_cb, | |
2072 | .help = "Set job IO priority class", | |
2073 | .minval = 0, | |
2074 | .maxval = 3, | |
2075 | }, | |
2076 | #endif | |
2077 | { | |
2078 | .name = "thinktime", | |
2079 | .type = FIO_OPT_INT, | |
2080 | .off1 = td_var_offset(thinktime), | |
2081 | .help = "Idle time between IO buffers (usec)", | |
2082 | .def = "0", | |
2083 | }, | |
2084 | { | |
2085 | .name = "thinktime_spin", | |
2086 | .type = FIO_OPT_INT, | |
2087 | .off1 = td_var_offset(thinktime_spin), | |
2088 | .help = "Start think time by spinning this amount (usec)", | |
2089 | .def = "0", | |
afdf9352 | 2090 | .parent = "thinktime", |
214e1eca JA |
2091 | }, |
2092 | { | |
2093 | .name = "thinktime_blocks", | |
2094 | .type = FIO_OPT_INT, | |
2095 | .off1 = td_var_offset(thinktime_blocks), | |
2096 | .help = "IO buffer period between 'thinktime'", | |
2097 | .def = "1", | |
afdf9352 | 2098 | .parent = "thinktime", |
214e1eca JA |
2099 | }, |
2100 | { | |
2101 | .name = "rate", | |
e01b22b8 | 2102 | .type = FIO_OPT_INT, |
6eaf09d6 SL |
2103 | .off1 = td_var_offset(rate[DDIR_READ]), |
2104 | .off2 = td_var_offset(rate[DDIR_WRITE]), | |
2105 | .off3 = td_var_offset(rate[DDIR_TRIM]), | |
214e1eca JA |
2106 | .help = "Set bandwidth rate", |
2107 | }, | |
2108 | { | |
2109 | .name = "ratemin", | |
e01b22b8 | 2110 | .type = FIO_OPT_INT, |
6eaf09d6 SL |
2111 | .off1 = td_var_offset(ratemin[DDIR_READ]), |
2112 | .off2 = td_var_offset(ratemin[DDIR_WRITE]), | |
2113 | .off3 = td_var_offset(ratemin[DDIR_TRIM]), | |
4e991c23 | 2114 | .help = "Job must meet this rate or it will be shutdown", |
afdf9352 | 2115 | .parent = "rate", |
4e991c23 JA |
2116 | }, |
2117 | { | |
2118 | .name = "rate_iops", | |
e01b22b8 | 2119 | .type = FIO_OPT_INT, |
6eaf09d6 SL |
2120 | .off1 = td_var_offset(rate_iops[DDIR_READ]), |
2121 | .off2 = td_var_offset(rate_iops[DDIR_WRITE]), | |
2122 | .off3 = td_var_offset(rate_iops[DDIR_TRIM]), | |
4e991c23 JA |
2123 | .help = "Limit IO used to this number of IO operations/sec", |
2124 | }, | |
2125 | { | |
2126 | .name = "rate_iops_min", | |
e01b22b8 | 2127 | .type = FIO_OPT_INT, |
6eaf09d6 SL |
2128 | .off1 = td_var_offset(rate_iops_min[DDIR_READ]), |
2129 | .off2 = td_var_offset(rate_iops_min[DDIR_WRITE]), | |
2130 | .off3 = td_var_offset(rate_iops_min[DDIR_TRIM]), | |
03e20d68 | 2131 | .help = "Job must meet this rate or it will be shut down", |
afdf9352 | 2132 | .parent = "rate_iops", |
214e1eca JA |
2133 | }, |
2134 | { | |
2135 | .name = "ratecycle", | |
2136 | .type = FIO_OPT_INT, | |
2137 | .off1 = td_var_offset(ratecycle), | |
2138 | .help = "Window average for rate limits (msec)", | |
2139 | .def = "1000", | |
afdf9352 | 2140 | .parent = "rate", |
214e1eca | 2141 | }, |
15501535 JA |
2142 | { |
2143 | .name = "max_latency", | |
2144 | .type = FIO_OPT_INT, | |
2145 | .off1 = td_var_offset(max_latency), | |
2146 | .help = "Maximum tolerated IO latency (usec)", | |
2147 | }, | |
214e1eca JA |
2148 | { |
2149 | .name = "invalidate", | |
2150 | .type = FIO_OPT_BOOL, | |
2151 | .off1 = td_var_offset(invalidate_cache), | |
2152 | .help = "Invalidate buffer/page cache prior to running job", | |
2153 | .def = "1", | |
2154 | }, | |
2155 | { | |
2156 | .name = "sync", | |
2157 | .type = FIO_OPT_BOOL, | |
2158 | .off1 = td_var_offset(sync_io), | |
2159 | .help = "Use O_SYNC for buffered writes", | |
2160 | .def = "0", | |
67a1000f | 2161 | .parent = "buffered", |
214e1eca JA |
2162 | }, |
2163 | { | |
2164 | .name = "bwavgtime", | |
2165 | .type = FIO_OPT_INT, | |
2166 | .off1 = td_var_offset(bw_avg_time), | |
5ec10eaa JA |
2167 | .help = "Time window over which to calculate bandwidth" |
2168 | " (msec)", | |
214e1eca | 2169 | .def = "500", |
c8eeb9df JA |
2170 | .parent = "write_bw_log", |
2171 | }, | |
2172 | { | |
2173 | .name = "iopsavgtime", | |
2174 | .type = FIO_OPT_INT, | |
2175 | .off1 = td_var_offset(iops_avg_time), | |
2176 | .help = "Time window over which to calculate IOPS (msec)", | |
2177 | .def = "500", | |
2178 | .parent = "write_iops_log", | |
214e1eca JA |
2179 | }, |
2180 | { | |
2181 | .name = "create_serialize", | |
2182 | .type = FIO_OPT_BOOL, | |
2183 | .off1 = td_var_offset(create_serialize), | |
2184 | .help = "Serialize creating of job files", | |
2185 | .def = "1", | |
2186 | }, | |
2187 | { | |
2188 | .name = "create_fsync", | |
2189 | .type = FIO_OPT_BOOL, | |
2190 | .off1 = td_var_offset(create_fsync), | |
03e20d68 | 2191 | .help = "fsync file after creation", |
214e1eca JA |
2192 | .def = "1", |
2193 | }, | |
814452bd JA |
2194 | { |
2195 | .name = "create_on_open", | |
2196 | .type = FIO_OPT_BOOL, | |
2197 | .off1 = td_var_offset(create_on_open), | |
2198 | .help = "Create files when they are opened for IO", | |
2199 | .def = "0", | |
2200 | }, | |
25460cf6 JA |
2201 | { |
2202 | .name = "create_only", | |
2203 | .type = FIO_OPT_BOOL, | |
2204 | .off1 = td_var_offset(create_only), | |
2205 | .help = "Only perform file creation phase", | |
2206 | .def = "0", | |
2207 | }, | |
0b9d69ec | 2208 | { |
afad68f7 ZY |
2209 | .name = "pre_read", |
2210 | .type = FIO_OPT_BOOL, | |
2211 | .off1 = td_var_offset(pre_read), | |
03e20d68 | 2212 | .help = "Pre-read files before starting official testing", |
afad68f7 ZY |
2213 | .def = "0", |
2214 | }, | |
214e1eca JA |
2215 | { |
2216 | .name = "cpuload", | |
2217 | .type = FIO_OPT_INT, | |
2218 | .off1 = td_var_offset(cpuload), | |
2219 | .help = "Use this percentage of CPU", | |
2220 | }, | |
2221 | { | |
2222 | .name = "cpuchunks", | |
2223 | .type = FIO_OPT_INT, | |
2224 | .off1 = td_var_offset(cpucycle), | |
2225 | .help = "Length of the CPU burn cycles (usecs)", | |
2226 | .def = "50000", | |
67a1000f | 2227 | .parent = "cpuload", |
214e1eca JA |
2228 | }, |
2229 | #ifdef FIO_HAVE_CPU_AFFINITY | |
2230 | { | |
2231 | .name = "cpumask", | |
2232 | .type = FIO_OPT_INT, | |
2233 | .cb = str_cpumask_cb, | |
2234 | .help = "CPU affinity mask", | |
2235 | }, | |
d2e268b0 JA |
2236 | { |
2237 | .name = "cpus_allowed", | |
2238 | .type = FIO_OPT_STR, | |
2239 | .cb = str_cpus_allowed_cb, | |
2240 | .help = "Set CPUs allowed", | |
2241 | }, | |
d0b937ed YR |
2242 | #endif |
2243 | #ifdef FIO_HAVE_LIBNUMA | |
2244 | { | |
2245 | .name = "numa_cpu_nodes", | |
2246 | .type = FIO_OPT_STR, | |
2247 | .cb = str_numa_cpunodes_cb, | |
2248 | .help = "NUMA CPU nodes bind", | |
2249 | }, | |
2250 | { | |
2251 | .name = "numa_mem_policy", | |
2252 | .type = FIO_OPT_STR, | |
2253 | .cb = str_numa_mpol_cb, | |
2254 | .help = "NUMA memory policy setup", | |
2255 | }, | |
214e1eca JA |
2256 | #endif |
2257 | { | |
2258 | .name = "end_fsync", | |
2259 | .type = FIO_OPT_BOOL, | |
2260 | .off1 = td_var_offset(end_fsync), | |
2261 | .help = "Include fsync at the end of job", | |
2262 | .def = "0", | |
2263 | }, | |
2264 | { | |
2265 | .name = "fsync_on_close", | |
2266 | .type = FIO_OPT_BOOL, | |
2267 | .off1 = td_var_offset(fsync_on_close), | |
2268 | .help = "fsync files on close", | |
2269 | .def = "0", | |
2270 | }, | |
2271 | { | |
2272 | .name = "unlink", | |
2273 | .type = FIO_OPT_BOOL, | |
2274 | .off1 = td_var_offset(unlink), | |
2275 | .help = "Unlink created files after job has completed", | |
2276 | .def = "0", | |
2277 | }, | |
2278 | { | |
2279 | .name = "exitall", | |
2280 | .type = FIO_OPT_STR_SET, | |
2281 | .cb = str_exitall_cb, | |
2282 | .help = "Terminate all jobs when one exits", | |
2283 | }, | |
2284 | { | |
2285 | .name = "stonewall", | |
d392365e | 2286 | .alias = "wait_for_previous", |
214e1eca JA |
2287 | .type = FIO_OPT_STR_SET, |
2288 | .off1 = td_var_offset(stonewall), | |
2289 | .help = "Insert a hard barrier between this job and previous", | |
2290 | }, | |
b3d62a75 JA |
2291 | { |
2292 | .name = "new_group", | |
2293 | .type = FIO_OPT_STR_SET, | |
2294 | .off1 = td_var_offset(new_group), | |
2295 | .help = "Mark the start of a new group (for reporting)", | |
2296 | }, | |
214e1eca JA |
2297 | { |
2298 | .name = "thread", | |
2299 | .type = FIO_OPT_STR_SET, | |
2300 | .off1 = td_var_offset(use_thread), | |
2301 | .help = "Use threads instead of forks", | |
2302 | }, | |
2303 | { | |
2304 | .name = "write_bw_log", | |
e3cedca7 | 2305 | .type = FIO_OPT_STR, |
214e1eca | 2306 | .off1 = td_var_offset(write_bw_log), |
e3cedca7 | 2307 | .cb = str_write_bw_log_cb, |
214e1eca JA |
2308 | .help = "Write log of bandwidth during run", |
2309 | }, | |
2310 | { | |
2311 | .name = "write_lat_log", | |
e3cedca7 | 2312 | .type = FIO_OPT_STR, |
214e1eca | 2313 | .off1 = td_var_offset(write_lat_log), |
e3cedca7 | 2314 | .cb = str_write_lat_log_cb, |
214e1eca JA |
2315 | .help = "Write log of latency during run", |
2316 | }, | |
c8eeb9df JA |
2317 | { |
2318 | .name = "write_iops_log", | |
2319 | .type = FIO_OPT_STR, | |
2320 | .off1 = td_var_offset(write_iops_log), | |
2321 | .cb = str_write_iops_log_cb, | |
2322 | .help = "Write log of IOPS during run", | |
2323 | }, | |
b8bc8cba JA |
2324 | { |
2325 | .name = "log_avg_msec", | |
2326 | .type = FIO_OPT_INT, | |
2327 | .off1 = td_var_offset(log_avg_msec), | |
2328 | .help = "Average bw/iops/lat logs over this period of time", | |
2329 | .def = "0", | |
2330 | }, | |
214e1eca JA |
2331 | { |
2332 | .name = "hugepage-size", | |
e01b22b8 | 2333 | .type = FIO_OPT_INT, |
214e1eca JA |
2334 | .off1 = td_var_offset(hugepage_size), |
2335 | .help = "When using hugepages, specify size of each page", | |
81179eec | 2336 | .def = __fio_stringify(FIO_HUGE_PAGE), |
214e1eca JA |
2337 | }, |
2338 | { | |
2339 | .name = "group_reporting", | |
2340 | .type = FIO_OPT_STR_SET, | |
2341 | .off1 = td_var_offset(group_reporting), | |
2342 | .help = "Do reporting on a per-group basis", | |
2343 | }, | |
e9459e5a JA |
2344 | { |
2345 | .name = "zero_buffers", | |
2346 | .type = FIO_OPT_STR_SET, | |
2347 | .off1 = td_var_offset(zero_buffers), | |
2348 | .help = "Init IO buffers to all zeroes", | |
2349 | }, | |
5973cafb JA |
2350 | { |
2351 | .name = "refill_buffers", | |
2352 | .type = FIO_OPT_STR_SET, | |
2353 | .off1 = td_var_offset(refill_buffers), | |
2354 | .help = "Refill IO buffers on every IO submit", | |
2355 | }, | |
fd68418e JA |
2356 | { |
2357 | .name = "scramble_buffers", | |
2358 | .type = FIO_OPT_BOOL, | |
2359 | .off1 = td_var_offset(scramble_buffers), | |
2360 | .help = "Slightly scramble buffers on every IO submit", | |
2361 | .def = "1", | |
2362 | }, | |
9c42684e JA |
2363 | { |
2364 | .name = "buffer_compress_percentage", | |
2365 | .type = FIO_OPT_INT, | |
2366 | .off1 = td_var_offset(compress_percentage), | |
2367 | .maxval = 100, | |
2368 | .minval = 1, | |
2369 | .help = "How compressible the buffer is (approximately)", | |
2370 | }, | |
f97a43a1 JA |
2371 | { |
2372 | .name = "buffer_compress_chunk", | |
2373 | .type = FIO_OPT_INT, | |
2374 | .off1 = td_var_offset(compress_chunk), | |
207b18e4 | 2375 | .parent = "buffer_compress_percentage", |
f97a43a1 JA |
2376 | .help = "Size of compressible region in buffer", |
2377 | }, | |
83349190 YH |
2378 | { |
2379 | .name = "clat_percentiles", | |
2380 | .type = FIO_OPT_BOOL, | |
2381 | .off1 = td_var_offset(clat_percentiles), | |
2382 | .help = "Enable the reporting of completion latency percentiles", | |
467b35ed | 2383 | .def = "1", |
83349190 YH |
2384 | }, |
2385 | { | |
2386 | .name = "percentile_list", | |
2387 | .type = FIO_OPT_FLOAT_LIST, | |
2388 | .off1 = td_var_offset(percentile_list), | |
2389 | .off2 = td_var_offset(overwrite_plist), | |
2390 | .help = "Specify a custom list of percentiles to report", | |
2391 | .maxlen = FIO_IO_U_LIST_MAX_LEN, | |
2392 | .minfp = 0.0, | |
2393 | .maxfp = 100.0, | |
2394 | }, | |
2395 | ||
0a839f30 JA |
2396 | #ifdef FIO_HAVE_DISK_UTIL |
2397 | { | |
2398 | .name = "disk_util", | |
2399 | .type = FIO_OPT_BOOL, | |
2400 | .off1 = td_var_offset(do_disk_util), | |
f66ab3c8 | 2401 | .help = "Log disk utilization statistics", |
0a839f30 JA |
2402 | .def = "1", |
2403 | }, | |
2404 | #endif | |
993bf48b JA |
2405 | { |
2406 | .name = "gtod_reduce", | |
2407 | .type = FIO_OPT_BOOL, | |
2408 | .help = "Greatly reduce number of gettimeofday() calls", | |
2409 | .cb = str_gtod_reduce_cb, | |
2410 | .def = "0", | |
2411 | }, | |
02af0988 JA |
2412 | { |
2413 | .name = "disable_lat", | |
2414 | .type = FIO_OPT_BOOL, | |
2415 | .off1 = td_var_offset(disable_lat), | |
2416 | .help = "Disable latency numbers", | |
2417 | .parent = "gtod_reduce", | |
2418 | .def = "0", | |
2419 | }, | |
9520ebb9 JA |
2420 | { |
2421 | .name = "disable_clat", | |
2422 | .type = FIO_OPT_BOOL, | |
2423 | .off1 = td_var_offset(disable_clat), | |
2424 | .help = "Disable completion latency numbers", | |
993bf48b | 2425 | .parent = "gtod_reduce", |
9520ebb9 JA |
2426 | .def = "0", |
2427 | }, | |
2428 | { | |
2429 | .name = "disable_slat", | |
2430 | .type = FIO_OPT_BOOL, | |
2431 | .off1 = td_var_offset(disable_slat), | |
03e20d68 | 2432 | .help = "Disable submission latency numbers", |
993bf48b | 2433 | .parent = "gtod_reduce", |
9520ebb9 JA |
2434 | .def = "0", |
2435 | }, | |
2436 | { | |
2437 | .name = "disable_bw_measurement", | |
2438 | .type = FIO_OPT_BOOL, | |
2439 | .off1 = td_var_offset(disable_bw), | |
2440 | .help = "Disable bandwidth logging", | |
993bf48b | 2441 | .parent = "gtod_reduce", |
9520ebb9 JA |
2442 | .def = "0", |
2443 | }, | |
be4ecfdf JA |
2444 | { |
2445 | .name = "gtod_cpu", | |
2446 | .type = FIO_OPT_INT, | |
2447 | .cb = str_gtod_cpu_cb, | |
03e20d68 | 2448 | .help = "Set up dedicated gettimeofday() thread on this CPU", |
29d43ff9 | 2449 | .verify = gtod_cpu_verify, |
be4ecfdf | 2450 | }, |
f2bba182 RR |
2451 | { |
2452 | .name = "continue_on_error", | |
06842027 | 2453 | .type = FIO_OPT_STR, |
f2bba182 | 2454 | .off1 = td_var_offset(continue_on_error), |
03e20d68 | 2455 | .help = "Continue on non-fatal errors during IO", |
06842027 SL |
2456 | .def = "none", |
2457 | .posval = { | |
2458 | { .ival = "none", | |
2459 | .oval = ERROR_TYPE_NONE, | |
2460 | .help = "Exit when an error is encountered", | |
2461 | }, | |
2462 | { .ival = "read", | |
2463 | .oval = ERROR_TYPE_READ, | |
2464 | .help = "Continue on read errors only", | |
2465 | }, | |
2466 | { .ival = "write", | |
2467 | .oval = ERROR_TYPE_WRITE, | |
2468 | .help = "Continue on write errors only", | |
2469 | }, | |
2470 | { .ival = "io", | |
2471 | .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE, | |
2472 | .help = "Continue on any IO errors", | |
2473 | }, | |
2474 | { .ival = "verify", | |
2475 | .oval = ERROR_TYPE_VERIFY, | |
2476 | .help = "Continue on verify errors only", | |
2477 | }, | |
2478 | { .ival = "all", | |
2479 | .oval = ERROR_TYPE_ANY, | |
2480 | .help = "Continue on all io and verify errors", | |
2481 | }, | |
2482 | { .ival = "0", | |
2483 | .oval = ERROR_TYPE_NONE, | |
2484 | .help = "Alias for 'none'", | |
2485 | }, | |
2486 | { .ival = "1", | |
2487 | .oval = ERROR_TYPE_ANY, | |
2488 | .help = "Alias for 'all'", | |
2489 | }, | |
2490 | }, | |
f2bba182 | 2491 | }, |
8b28bd41 DM |
2492 | { |
2493 | .name = "ignore_error", | |
2494 | .type = FIO_OPT_STR, | |
2495 | .cb = str_ignore_error_cb, | |
2496 | .help = "Set a specific list of errors to ignore", | |
2497 | .parent = "rw", | |
2498 | }, | |
2499 | { | |
2500 | .name = "error_dump", | |
2501 | .type = FIO_OPT_BOOL, | |
2502 | .off1 = td_var_offset(error_dump), | |
2503 | .def = "0", | |
2504 | .help = "Dump info on each error", | |
2505 | }, | |
2506 | ||
9ac8a797 JA |
2507 | { |
2508 | .name = "profile", | |
79d16311 | 2509 | .type = FIO_OPT_STR_STORE, |
9ac8a797 | 2510 | .off1 = td_var_offset(profile), |
9ac8a797 JA |
2511 | .help = "Select a specific builtin performance test", |
2512 | }, | |
a696fa2a JA |
2513 | { |
2514 | .name = "cgroup", | |
2515 | .type = FIO_OPT_STR_STORE, | |
2516 | .off1 = td_var_offset(cgroup), | |
2517 | .help = "Add job to cgroup of this name", | |
2518 | }, | |
2519 | { | |
2520 | .name = "cgroup_weight", | |
2521 | .type = FIO_OPT_INT, | |
2522 | .off1 = td_var_offset(cgroup_weight), | |
2523 | .help = "Use given weight for cgroup", | |
2524 | .minval = 100, | |
2525 | .maxval = 1000, | |
a696fa2a | 2526 | }, |
7de87099 VG |
2527 | { |
2528 | .name = "cgroup_nodelete", | |
2529 | .type = FIO_OPT_BOOL, | |
2530 | .off1 = td_var_offset(cgroup_nodelete), | |
2531 | .help = "Do not delete cgroups after job completion", | |
2532 | .def = "0", | |
2533 | }, | |
e0b0d892 JA |
2534 | { |
2535 | .name = "uid", | |
2536 | .type = FIO_OPT_INT, | |
2537 | .off1 = td_var_offset(uid), | |
2538 | .help = "Run job with this user ID", | |
2539 | }, | |
2540 | { | |
2541 | .name = "gid", | |
2542 | .type = FIO_OPT_INT, | |
2543 | .off1 = td_var_offset(gid), | |
2544 | .help = "Run job with this group ID", | |
2545 | }, | |
9e684a49 DE |
2546 | { |
2547 | .name = "flow_id", | |
2548 | .type = FIO_OPT_INT, | |
2549 | .off1 = td_var_offset(flow_id), | |
2550 | .help = "The flow index ID to use", | |
2551 | .def = "0", | |
2552 | }, | |
2553 | { | |
2554 | .name = "flow", | |
2555 | .type = FIO_OPT_INT, | |
2556 | .off1 = td_var_offset(flow), | |
2557 | .help = "Weight for flow control of this job", | |
2558 | .parent = "flow_id", | |
2559 | .def = "0", | |
2560 | }, | |
2561 | { | |
2562 | .name = "flow_watermark", | |
2563 | .type = FIO_OPT_INT, | |
2564 | .off1 = td_var_offset(flow_watermark), | |
2565 | .help = "High watermark for flow control. This option" | |
2566 | " should be set to the same value for all threads" | |
2567 | " with non-zero flow.", | |
2568 | .parent = "flow_id", | |
2569 | .def = "1024", | |
2570 | }, | |
2571 | { | |
2572 | .name = "flow_sleep", | |
2573 | .type = FIO_OPT_INT, | |
2574 | .off1 = td_var_offset(flow_sleep), | |
2575 | .help = "How many microseconds to sleep after being held" | |
2576 | " back by the flow control mechanism", | |
2577 | .parent = "flow_id", | |
2578 | .def = "0", | |
2579 | }, | |
214e1eca JA |
2580 | { |
2581 | .name = NULL, | |
2582 | }, | |
2583 | }; | |
2584 | ||
17af15d4 | 2585 | static void add_to_lopt(struct option *lopt, struct fio_option *o, |
de890a1e | 2586 | const char *name, int val) |
9f81736c | 2587 | { |
17af15d4 | 2588 | lopt->name = (char *) name; |
de890a1e | 2589 | lopt->val = val; |
9f81736c JA |
2590 | if (o->type == FIO_OPT_STR_SET) |
2591 | lopt->has_arg = no_argument; | |
2592 | else | |
2593 | lopt->has_arg = required_argument; | |
2594 | } | |
2595 | ||
de890a1e SL |
2596 | static void options_to_lopts(struct fio_option *opts, |
2597 | struct option *long_options, | |
2598 | int i, int option_type) | |
214e1eca | 2599 | { |
de890a1e | 2600 | struct fio_option *o = &opts[0]; |
214e1eca | 2601 | while (o->name) { |
de890a1e | 2602 | add_to_lopt(&long_options[i], o, o->name, option_type); |
17af15d4 JA |
2603 | if (o->alias) { |
2604 | i++; | |
de890a1e | 2605 | add_to_lopt(&long_options[i], o, o->alias, option_type); |
17af15d4 | 2606 | } |
214e1eca JA |
2607 | |
2608 | i++; | |
2609 | o++; | |
2610 | assert(i < FIO_NR_OPTIONS); | |
2611 | } | |
2612 | } | |
2613 | ||
de890a1e SL |
2614 | void fio_options_set_ioengine_opts(struct option *long_options, |
2615 | struct thread_data *td) | |
2616 | { | |
2617 | unsigned int i; | |
2618 | ||
2619 | i = 0; | |
2620 | while (long_options[i].name) { | |
2621 | if (long_options[i].val == FIO_GETOPT_IOENGINE) { | |
2622 | memset(&long_options[i], 0, sizeof(*long_options)); | |
2623 | break; | |
2624 | } | |
2625 | i++; | |
2626 | } | |
2627 | ||
2628 | /* | |
2629 | * Just clear out the prior ioengine options. | |
2630 | */ | |
2631 | if (!td || !td->eo) | |
2632 | return; | |
2633 | ||
2634 | options_to_lopts(td->io_ops->options, long_options, i, | |
2635 | FIO_GETOPT_IOENGINE); | |
2636 | } | |
2637 | ||
2638 | void fio_options_dup_and_init(struct option *long_options) | |
2639 | { | |
2640 | unsigned int i; | |
2641 | ||
2642 | options_init(options); | |
2643 | ||
2644 | i = 0; | |
2645 | while (long_options[i].name) | |
2646 | i++; | |
2647 | ||
2648 | options_to_lopts(options, long_options, i, FIO_GETOPT_JOB); | |
2649 | } | |
2650 | ||
74929ac2 JA |
2651 | struct fio_keyword { |
2652 | const char *word; | |
2653 | const char *desc; | |
2654 | char *replace; | |
2655 | }; | |
2656 | ||
2657 | static struct fio_keyword fio_keywords[] = { | |
2658 | { | |
2659 | .word = "$pagesize", | |
2660 | .desc = "Page size in the system", | |
2661 | }, | |
2662 | { | |
2663 | .word = "$mb_memory", | |
2664 | .desc = "Megabytes of memory online", | |
2665 | }, | |
2666 | { | |
2667 | .word = "$ncpus", | |
2668 | .desc = "Number of CPUs online in the system", | |
2669 | }, | |
2670 | { | |
2671 | .word = NULL, | |
2672 | }, | |
2673 | }; | |
2674 | ||
2675 | void fio_keywords_init(void) | |
2676 | { | |
3b2e1464 | 2677 | unsigned long long mb_memory; |
74929ac2 JA |
2678 | char buf[128]; |
2679 | long l; | |
2680 | ||
a4cfc477 | 2681 | sprintf(buf, "%lu", (unsigned long) page_size); |
74929ac2 JA |
2682 | fio_keywords[0].replace = strdup(buf); |
2683 | ||
8eb016d3 | 2684 | mb_memory = os_phys_mem() / (1024 * 1024); |
3b2e1464 | 2685 | sprintf(buf, "%llu", mb_memory); |
74929ac2 JA |
2686 | fio_keywords[1].replace = strdup(buf); |
2687 | ||
c00a2289 | 2688 | l = cpus_online(); |
74929ac2 JA |
2689 | sprintf(buf, "%lu", l); |
2690 | fio_keywords[2].replace = strdup(buf); | |
2691 | } | |
2692 | ||
892a6ffc JA |
2693 | #define BC_APP "bc" |
2694 | ||
2695 | static char *bc_calc(char *str) | |
2696 | { | |
d0c814ec | 2697 | char buf[128], *tmp; |
892a6ffc JA |
2698 | FILE *f; |
2699 | int ret; | |
2700 | ||
2701 | /* | |
2702 | * No math, just return string | |
2703 | */ | |
d0c814ec SL |
2704 | if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') && |
2705 | !strchr(str, '/')) || strchr(str, '\'')) | |
892a6ffc JA |
2706 | return str; |
2707 | ||
2708 | /* | |
2709 | * Split option from value, we only need to calculate the value | |
2710 | */ | |
2711 | tmp = strchr(str, '='); | |
2712 | if (!tmp) | |
2713 | return str; | |
2714 | ||
2715 | tmp++; | |
892a6ffc | 2716 | |
d0c814ec SL |
2717 | /* |
2718 | * Prevent buffer overflows; such a case isn't reasonable anyway | |
2719 | */ | |
2720 | if (strlen(str) >= 128 || strlen(tmp) > 100) | |
2721 | return str; | |
892a6ffc JA |
2722 | |
2723 | sprintf(buf, "which %s > /dev/null", BC_APP); | |
2724 | if (system(buf)) { | |
2725 | log_err("fio: bc is needed for performing math\n"); | |
892a6ffc JA |
2726 | return NULL; |
2727 | } | |
2728 | ||
d0c814ec | 2729 | sprintf(buf, "echo '%s' | %s", tmp, BC_APP); |
892a6ffc JA |
2730 | f = popen(buf, "r"); |
2731 | if (!f) { | |
892a6ffc JA |
2732 | return NULL; |
2733 | } | |
2734 | ||
d0c814ec | 2735 | ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f); |
892a6ffc | 2736 | if (ret <= 0) { |
892a6ffc JA |
2737 | return NULL; |
2738 | } | |
2739 | ||
892a6ffc | 2740 | pclose(f); |
d0c814ec SL |
2741 | buf[(tmp - str) + ret - 1] = '\0'; |
2742 | memcpy(buf, str, tmp - str); | |
892a6ffc | 2743 | free(str); |
d0c814ec SL |
2744 | return strdup(buf); |
2745 | } | |
2746 | ||
2747 | /* | |
2748 | * Return a copy of the input string with substrings of the form ${VARNAME} | |
2749 | * substituted with the value of the environment variable VARNAME. The | |
2750 | * substitution always occurs, even if VARNAME is empty or the corresponding | |
2751 | * environment variable undefined. | |
2752 | */ | |
2753 | static char *option_dup_subs(const char *opt) | |
2754 | { | |
2755 | char out[OPT_LEN_MAX+1]; | |
2756 | char in[OPT_LEN_MAX+1]; | |
2757 | char *outptr = out; | |
2758 | char *inptr = in; | |
2759 | char *ch1, *ch2, *env; | |
2760 | ssize_t nchr = OPT_LEN_MAX; | |
2761 | size_t envlen; | |
2762 | ||
2763 | if (strlen(opt) + 1 > OPT_LEN_MAX) { | |
2764 | log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX); | |
2765 | return NULL; | |
2766 | } | |
2767 | ||
2768 | in[OPT_LEN_MAX] = '\0'; | |
2769 | strncpy(in, opt, OPT_LEN_MAX); | |
2770 | ||
2771 | while (*inptr && nchr > 0) { | |
2772 | if (inptr[0] == '$' && inptr[1] == '{') { | |
2773 | ch2 = strchr(inptr, '}'); | |
2774 | if (ch2 && inptr+1 < ch2) { | |
2775 | ch1 = inptr+2; | |
2776 | inptr = ch2+1; | |
2777 | *ch2 = '\0'; | |
2778 | ||
2779 | env = getenv(ch1); | |
2780 | if (env) { | |
2781 | envlen = strlen(env); | |
2782 | if (envlen <= nchr) { | |
2783 | memcpy(outptr, env, envlen); | |
2784 | outptr += envlen; | |
2785 | nchr -= envlen; | |
2786 | } | |
2787 | } | |
2788 | ||
2789 | continue; | |
2790 | } | |
2791 | } | |
2792 | ||
2793 | *outptr++ = *inptr++; | |
2794 | --nchr; | |
2795 | } | |
2796 | ||
2797 | *outptr = '\0'; | |
2798 | return strdup(out); | |
892a6ffc JA |
2799 | } |
2800 | ||
74929ac2 JA |
2801 | /* |
2802 | * Look for reserved variable names and replace them with real values | |
2803 | */ | |
2804 | static char *fio_keyword_replace(char *opt) | |
2805 | { | |
2806 | char *s; | |
2807 | int i; | |
d0c814ec | 2808 | int docalc = 0; |
74929ac2 JA |
2809 | |
2810 | for (i = 0; fio_keywords[i].word != NULL; i++) { | |
2811 | struct fio_keyword *kw = &fio_keywords[i]; | |
2812 | ||
2813 | while ((s = strstr(opt, kw->word)) != NULL) { | |
2814 | char *new = malloc(strlen(opt) + 1); | |
2815 | char *o_org = opt; | |
2816 | int olen = s - opt; | |
2817 | int len; | |
2818 | ||
2819 | /* | |
2820 | * Copy part of the string before the keyword and | |
2821 | * sprintf() the replacement after it. | |
2822 | */ | |
2823 | memcpy(new, opt, olen); | |
2824 | len = sprintf(new + olen, "%s", kw->replace); | |
2825 | ||
2826 | /* | |
2827 | * If there's more in the original string, copy that | |
2828 | * in too | |
2829 | */ | |
2830 | opt += strlen(kw->word) + olen; | |
2831 | if (strlen(opt)) | |
2832 | memcpy(new + olen + len, opt, opt - o_org - 1); | |
2833 | ||
2834 | /* | |
2835 | * replace opt and free the old opt | |
2836 | */ | |
2837 | opt = new; | |
d0c814ec | 2838 | free(o_org); |
7a958bd5 | 2839 | |
d0c814ec | 2840 | docalc = 1; |
74929ac2 JA |
2841 | } |
2842 | } | |
2843 | ||
d0c814ec SL |
2844 | /* |
2845 | * Check for potential math and invoke bc, if possible | |
2846 | */ | |
2847 | if (docalc) | |
2848 | opt = bc_calc(opt); | |
2849 | ||
7a958bd5 | 2850 | return opt; |
74929ac2 JA |
2851 | } |
2852 | ||
d0c814ec SL |
2853 | static char **dup_and_sub_options(char **opts, int num_opts) |
2854 | { | |
2855 | int i; | |
2856 | char **opts_copy = malloc(num_opts * sizeof(*opts)); | |
2857 | for (i = 0; i < num_opts; i++) { | |
2858 | opts_copy[i] = option_dup_subs(opts[i]); | |
2859 | if (!opts_copy[i]) | |
2860 | continue; | |
2861 | opts_copy[i] = fio_keyword_replace(opts_copy[i]); | |
2862 | } | |
2863 | return opts_copy; | |
2864 | } | |
2865 | ||
3b8b7135 | 2866 | int fio_options_parse(struct thread_data *td, char **opts, int num_opts) |
214e1eca | 2867 | { |
de890a1e | 2868 | int i, ret, unknown; |
d0c814ec | 2869 | char **opts_copy; |
3b8b7135 JA |
2870 | |
2871 | sort_options(opts, options, num_opts); | |
d0c814ec | 2872 | opts_copy = dup_and_sub_options(opts, num_opts); |
3b8b7135 | 2873 | |
de890a1e SL |
2874 | for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) { |
2875 | struct fio_option *o; | |
2876 | int newret = parse_option(opts_copy[i], opts[i], options, &o, | |
2877 | td); | |
d0c814ec | 2878 | |
de890a1e SL |
2879 | if (opts_copy[i]) { |
2880 | if (newret && !o) { | |
2881 | unknown++; | |
2882 | continue; | |
2883 | } | |
d0c814ec | 2884 | free(opts_copy[i]); |
de890a1e SL |
2885 | opts_copy[i] = NULL; |
2886 | } | |
2887 | ||
2888 | ret |= newret; | |
2889 | } | |
2890 | ||
2891 | if (unknown) { | |
2892 | ret |= ioengine_load(td); | |
2893 | if (td->eo) { | |
2894 | sort_options(opts_copy, td->io_ops->options, num_opts); | |
2895 | opts = opts_copy; | |
2896 | } | |
2897 | for (i = 0; i < num_opts; i++) { | |
2898 | struct fio_option *o = NULL; | |
2899 | int newret = 1; | |
2900 | if (!opts_copy[i]) | |
2901 | continue; | |
2902 | ||
2903 | if (td->eo) | |
2904 | newret = parse_option(opts_copy[i], opts[i], | |
2905 | td->io_ops->options, &o, | |
2906 | td->eo); | |
2907 | ||
2908 | ret |= newret; | |
2909 | if (!o) | |
2910 | log_err("Bad option <%s>\n", opts[i]); | |
2911 | ||
2912 | free(opts_copy[i]); | |
2913 | opts_copy[i] = NULL; | |
2914 | } | |
74929ac2 | 2915 | } |
3b8b7135 | 2916 | |
d0c814ec | 2917 | free(opts_copy); |
3b8b7135 | 2918 | return ret; |
214e1eca JA |
2919 | } |
2920 | ||
2921 | int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val) | |
2922 | { | |
07b3232d | 2923 | return parse_cmd_option(opt, val, options, td); |
214e1eca JA |
2924 | } |
2925 | ||
de890a1e SL |
2926 | int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt, |
2927 | char *val) | |
2928 | { | |
2929 | return parse_cmd_option(opt, val, td->io_ops->options, td); | |
2930 | } | |
2931 | ||
214e1eca JA |
2932 | void fio_fill_default_options(struct thread_data *td) |
2933 | { | |
2934 | fill_default_options(td, options); | |
2935 | } | |
2936 | ||
2937 | int fio_show_option_help(const char *opt) | |
2938 | { | |
07b3232d | 2939 | return show_cmd_help(options, opt); |
214e1eca | 2940 | } |
d23bb327 | 2941 | |
de890a1e | 2942 | void options_mem_dupe(void *data, struct fio_option *options) |
d23bb327 | 2943 | { |
de890a1e | 2944 | struct fio_option *o; |
d23bb327 | 2945 | char **ptr; |
d23bb327 | 2946 | |
de890a1e SL |
2947 | for (o = &options[0]; o->name; o++) { |
2948 | if (o->type != FIO_OPT_STR_STORE) | |
d23bb327 JA |
2949 | continue; |
2950 | ||
de890a1e | 2951 | ptr = td_var(data, o->off1); |
7e356b2d JA |
2952 | if (*ptr) |
2953 | *ptr = strdup(*ptr); | |
d23bb327 JA |
2954 | } |
2955 | } | |
2956 | ||
de890a1e SL |
2957 | /* |
2958 | * dupe FIO_OPT_STR_STORE options | |
2959 | */ | |
2960 | void fio_options_mem_dupe(struct thread_data *td) | |
2961 | { | |
2962 | options_mem_dupe(&td->o, options); | |
1647f592 JA |
2963 | |
2964 | if (td->eo && td->io_ops) { | |
de890a1e | 2965 | void *oldeo = td->eo; |
1647f592 | 2966 | |
de890a1e SL |
2967 | td->eo = malloc(td->io_ops->option_struct_size); |
2968 | memcpy(td->eo, oldeo, td->io_ops->option_struct_size); | |
2969 | options_mem_dupe(td->eo, td->io_ops->options); | |
2970 | } | |
2971 | } | |
2972 | ||
d6978a32 JA |
2973 | unsigned int fio_get_kb_base(void *data) |
2974 | { | |
2975 | struct thread_data *td = data; | |
2976 | unsigned int kb_base = 0; | |
2977 | ||
2978 | if (td) | |
2979 | kb_base = td->o.kb_base; | |
2980 | if (!kb_base) | |
2981 | kb_base = 1024; | |
2982 | ||
2983 | return kb_base; | |
2984 | } | |
9f988e2e | 2985 | |
07b3232d | 2986 | int add_option(struct fio_option *o) |
9f988e2e | 2987 | { |
07b3232d JA |
2988 | struct fio_option *__o; |
2989 | int opt_index = 0; | |
2990 | ||
2991 | __o = options; | |
2992 | while (__o->name) { | |
2993 | opt_index++; | |
2994 | __o++; | |
2995 | } | |
2996 | ||
2997 | memcpy(&options[opt_index], o, sizeof(*o)); | |
2998 | return 0; | |
9f988e2e | 2999 | } |
e2de69da | 3000 | |
07b3232d | 3001 | void invalidate_profile_options(const char *prof_name) |
e2de69da | 3002 | { |
07b3232d | 3003 | struct fio_option *o; |
e2de69da | 3004 | |
07b3232d JA |
3005 | o = options; |
3006 | while (o->name) { | |
3007 | if (o->prof_name && !strcmp(o->prof_name, prof_name)) { | |
3008 | o->type = FIO_OPT_INVALID; | |
3009 | o->prof_name = NULL; | |
3010 | } | |
3011 | o++; | |
e2de69da JA |
3012 | } |
3013 | } | |
f5b6bb85 JA |
3014 | |
3015 | void add_opt_posval(const char *optname, const char *ival, const char *help) | |
3016 | { | |
3017 | struct fio_option *o; | |
3018 | unsigned int i; | |
3019 | ||
3020 | o = find_option(options, optname); | |
3021 | if (!o) | |
3022 | return; | |
3023 | ||
3024 | for (i = 0; i < PARSE_MAX_VP; i++) { | |
3025 | if (o->posval[i].ival) | |
3026 | continue; | |
3027 | ||
3028 | o->posval[i].ival = ival; | |
3029 | o->posval[i].help = help; | |
3030 | break; | |
3031 | } | |
3032 | } | |
3033 | ||
3034 | void del_opt_posval(const char *optname, const char *ival) | |
3035 | { | |
3036 | struct fio_option *o; | |
3037 | unsigned int i; | |
3038 | ||
3039 | o = find_option(options, optname); | |
3040 | if (!o) | |
3041 | return; | |
3042 | ||
3043 | for (i = 0; i < PARSE_MAX_VP; i++) { | |
3044 | if (!o->posval[i].ival) | |
3045 | continue; | |
3046 | if (strcmp(o->posval[i].ival, ival)) | |
3047 | continue; | |
3048 | ||
3049 | o->posval[i].ival = NULL; | |
3050 | o->posval[i].help = NULL; | |
3051 | } | |
3052 | } | |
7e356b2d JA |
3053 | |
3054 | void fio_options_free(struct thread_data *td) | |
3055 | { | |
3056 | options_free(options, td); | |
de890a1e SL |
3057 | if (td->eo && td->io_ops && td->io_ops->options) { |
3058 | options_free(td->io_ops->options, td->eo); | |
3059 | free(td->eo); | |
3060 | td->eo = NULL; | |
3061 | } | |
7e356b2d | 3062 | } |