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