options.c revision d7213923067aa49922962a469a691c3ec951064d
1#include <stdio.h> 2#include <stdlib.h> 3#include <unistd.h> 4#include <ctype.h> 5#include <string.h> 6#include <assert.h> 7#include <libgen.h> 8#include <fcntl.h> 9#include <sys/types.h> 10#include <sys/stat.h> 11 12#include "fio.h" 13#include "verify.h" 14#include "parse.h" 15#include "lib/fls.h" 16#include "options.h" 17 18#include "crc/crc32c.h" 19 20/* 21 * Check if mmap/mmaphuge has a :/foo/bar/file at the end. If so, return that. 22 */ 23static 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 36static 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 56static 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 64static int bssplit_ddir(struct thread_options *o, int ddir, char *str) 65{ 66 struct bssplit *bssplit; 67 unsigned int i, perc, perc_missing; 68 unsigned int max_bs, min_bs; 69 long long val; 70 char *fname; 71 72 o->bssplit_nr[ddir] = 4; 73 bssplit = malloc(4 * sizeof(struct bssplit)); 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 */ 87 if (i == o->bssplit_nr[ddir]) { 88 o->bssplit_nr[ddir] <<= 1; 89 bssplit = realloc(bssplit, o->bssplit_nr[ddir] 90 * sizeof(struct bssplit)); 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 105 if (str_to_decimal(fname, &val, 1, o)) { 106 log_err("fio: bssplit conversion failed\n"); 107 free(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 116 bssplit[i].bs = val; 117 bssplit[i].perc = perc; 118 i++; 119 } 120 121 o->bssplit_nr[ddir] = i; 122 123 /* 124 * Now check if the percentages add up, and how much is missing 125 */ 126 perc = perc_missing = 0; 127 for (i = 0; i < o->bssplit_nr[ddir]; i++) { 128 struct bssplit *bsp = &bssplit[i]; 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"); 138 free(bssplit); 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) { 146 for (i = 0; i < o->bssplit_nr[ddir]; i++) { 147 struct bssplit *bsp = &bssplit[i]; 148 149 if (bsp->perc == (unsigned char) -1) 150 bsp->perc = (100 - perc) / perc_missing; 151 } 152 } 153 154 o->min_bs[ddir] = min_bs; 155 o->max_bs[ddir] = max_bs; 156 157 /* 158 * now sort based on percentages, for ease of lookup 159 */ 160 qsort(bssplit, o->bssplit_nr[ddir], sizeof(struct bssplit), bs_cmp); 161 o->bssplit[ddir] = bssplit; 162 return 0; 163} 164 165static int str_bssplit_cb(void *data, const char *input) 166{ 167 struct thread_data *td = data; 168 char *str, *p, *odir, *ddir; 169 int ret = 0; 170 171 p = str = strdup(input); 172 173 strip_blank_front(&str); 174 strip_blank_end(str); 175 176 odir = strchr(str, ','); 177 if (odir) { 178 ddir = strchr(odir + 1, ','); 179 if (ddir) { 180 ret = bssplit_ddir(&td->o, DDIR_TRIM, ddir + 1); 181 if (!ret) 182 *ddir = '\0'; 183 } else { 184 char *op; 185 186 op = strdup(odir + 1); 187 ret = bssplit_ddir(&td->o, DDIR_TRIM, op); 188 189 free(op); 190 } 191 if (!ret) 192 ret = bssplit_ddir(&td->o, DDIR_WRITE, odir + 1); 193 if (!ret) { 194 *odir = '\0'; 195 ret = bssplit_ddir(&td->o, DDIR_READ, str); 196 } 197 } else { 198 char *op; 199 200 op = strdup(str); 201 ret = bssplit_ddir(&td->o, DDIR_WRITE, op); 202 free(op); 203 204 if (!ret) { 205 op = strdup(str); 206 ret = bssplit_ddir(&td->o, DDIR_TRIM, op); 207 free(op); 208 } 209 ret = bssplit_ddir(&td->o, DDIR_READ, str); 210 } 211 212 free(p); 213 return ret; 214} 215 216static int str2error(char *str) 217{ 218 const char *err[] = { "EPERM", "ENOENT", "ESRCH", "EINTR", "EIO", 219 "ENXIO", "E2BIG", "ENOEXEC", "EBADF", 220 "ECHILD", "EAGAIN", "ENOMEM", "EACCES", 221 "EFAULT", "ENOTBLK", "EBUSY", "EEXIST", 222 "EXDEV", "ENODEV", "ENOTDIR", "EISDIR", 223 "EINVAL", "ENFILE", "EMFILE", "ENOTTY", 224 "ETXTBSY","EFBIG", "ENOSPC", "ESPIPE", 225 "EROFS","EMLINK", "EPIPE", "EDOM", "ERANGE" }; 226 int i = 0, num = sizeof(err) / sizeof(void *); 227 228 while (i < num) { 229 if (!strcmp(err[i], str)) 230 return i + 1; 231 i++; 232 } 233 return 0; 234} 235 236static int ignore_error_type(struct thread_data *td, int etype, char *str) 237{ 238 unsigned int i; 239 int *error; 240 char *fname; 241 242 if (etype >= ERROR_TYPE_CNT) { 243 log_err("Illegal error type\n"); 244 return 1; 245 } 246 247 td->o.ignore_error_nr[etype] = 4; 248 error = malloc(4 * sizeof(struct bssplit)); 249 250 i = 0; 251 while ((fname = strsep(&str, ":")) != NULL) { 252 253 if (!strlen(fname)) 254 break; 255 256 /* 257 * grow struct buffer, if needed 258 */ 259 if (i == td->o.ignore_error_nr[etype]) { 260 td->o.ignore_error_nr[etype] <<= 1; 261 error = realloc(error, td->o.ignore_error_nr[etype] 262 * sizeof(int)); 263 } 264 if (fname[0] == 'E') { 265 error[i] = str2error(fname); 266 } else { 267 error[i] = atoi(fname); 268 if (error[i] < 0) 269 error[i] = error[i]; 270 } 271 if (!error[i]) { 272 log_err("Unknown error %s, please use number value \n", 273 fname); 274 return 1; 275 } 276 i++; 277 } 278 if (i) { 279 td->o.continue_on_error |= 1 << etype; 280 td->o.ignore_error_nr[etype] = i; 281 td->o.ignore_error[etype] = error; 282 } 283 return 0; 284 285} 286 287static int str_ignore_error_cb(void *data, const char *input) 288{ 289 struct thread_data *td = data; 290 char *str, *p, *n; 291 int type = 0, ret = 1; 292 p = str = strdup(input); 293 294 strip_blank_front(&str); 295 strip_blank_end(str); 296 297 while (p) { 298 n = strchr(p, ','); 299 if (n) 300 *n++ = '\0'; 301 ret = ignore_error_type(td, type, p); 302 if (ret) 303 break; 304 p = n; 305 type++; 306 } 307 free(str); 308 return ret; 309} 310 311static int str_rw_cb(void *data, const char *str) 312{ 313 struct thread_data *td = data; 314 struct thread_options *o = &td->o; 315 char *nr = get_opt_postfix(str); 316 317 o->ddir_seq_nr = 1; 318 o->ddir_seq_add = 0; 319 320 if (!nr) 321 return 0; 322 323 if (td_random(td)) 324 o->ddir_seq_nr = atoi(nr); 325 else { 326 long long val; 327 328 if (str_to_decimal(nr, &val, 1, o)) { 329 log_err("fio: rw postfix parsing failed\n"); 330 free(nr); 331 return 1; 332 } 333 334 o->ddir_seq_add = val; 335 } 336 337 free(nr); 338 return 0; 339} 340 341static int str_mem_cb(void *data, const char *mem) 342{ 343 struct thread_data *td = data; 344 345 if (td->o.mem_type == MEM_MMAPHUGE || td->o.mem_type == MEM_MMAP) 346 td->o.mmapfile = get_opt_postfix(mem); 347 348 return 0; 349} 350 351static int fio_clock_source_cb(void *data, const char *str) 352{ 353 struct thread_data *td = data; 354 355 fio_clock_source = td->o.clocksource; 356 fio_clock_source_set = 1; 357 fio_clock_init(); 358 return 0; 359} 360 361static int str_rwmix_read_cb(void *data, unsigned long long *val) 362{ 363 struct thread_data *td = data; 364 365 td->o.rwmix[DDIR_READ] = *val; 366 td->o.rwmix[DDIR_WRITE] = 100 - *val; 367 return 0; 368} 369 370static int str_rwmix_write_cb(void *data, unsigned long long *val) 371{ 372 struct thread_data *td = data; 373 374 td->o.rwmix[DDIR_WRITE] = *val; 375 td->o.rwmix[DDIR_READ] = 100 - *val; 376 return 0; 377} 378 379static int str_exitall_cb(void) 380{ 381 exitall_on_terminate = 1; 382 return 0; 383} 384 385#ifdef FIO_HAVE_CPU_AFFINITY 386static int str_cpumask_cb(void *data, unsigned long long *val) 387{ 388 struct thread_data *td = data; 389 unsigned int i; 390 long max_cpu; 391 int ret; 392 393 ret = fio_cpuset_init(&td->o.cpumask); 394 if (ret < 0) { 395 log_err("fio: cpuset_init failed\n"); 396 td_verror(td, ret, "fio_cpuset_init"); 397 return 1; 398 } 399 400 max_cpu = cpus_online(); 401 402 for (i = 0; i < sizeof(int) * 8; i++) { 403 if ((1 << i) & *val) { 404 if (i > max_cpu) { 405 log_err("fio: CPU %d too large (max=%ld)\n", i, 406 max_cpu); 407 return 1; 408 } 409 dprint(FD_PARSE, "set cpu allowed %d\n", i); 410 fio_cpu_set(&td->o.cpumask, i); 411 } 412 } 413 414 td->o.cpumask_set = 1; 415 return 0; 416} 417 418static int set_cpus_allowed(struct thread_data *td, os_cpu_mask_t *mask, 419 const char *input) 420{ 421 char *cpu, *str, *p; 422 long max_cpu; 423 int ret = 0; 424 425 ret = fio_cpuset_init(mask); 426 if (ret < 0) { 427 log_err("fio: cpuset_init failed\n"); 428 td_verror(td, ret, "fio_cpuset_init"); 429 return 1; 430 } 431 432 p = str = strdup(input); 433 434 strip_blank_front(&str); 435 strip_blank_end(str); 436 437 max_cpu = cpus_online(); 438 439 while ((cpu = strsep(&str, ",")) != NULL) { 440 char *str2, *cpu2; 441 int icpu, icpu2; 442 443 if (!strlen(cpu)) 444 break; 445 446 str2 = cpu; 447 icpu2 = -1; 448 while ((cpu2 = strsep(&str2, "-")) != NULL) { 449 if (!strlen(cpu2)) 450 break; 451 452 icpu2 = atoi(cpu2); 453 } 454 455 icpu = atoi(cpu); 456 if (icpu2 == -1) 457 icpu2 = icpu; 458 while (icpu <= icpu2) { 459 if (icpu >= FIO_MAX_CPUS) { 460 log_err("fio: your OS only supports up to" 461 " %d CPUs\n", (int) FIO_MAX_CPUS); 462 ret = 1; 463 break; 464 } 465 if (icpu > max_cpu) { 466 log_err("fio: CPU %d too large (max=%ld)\n", 467 icpu, max_cpu); 468 ret = 1; 469 break; 470 } 471 472 dprint(FD_PARSE, "set cpu allowed %d\n", icpu); 473 fio_cpu_set(mask, icpu); 474 icpu++; 475 } 476 if (ret) 477 break; 478 } 479 480 free(p); 481 if (!ret) 482 td->o.cpumask_set = 1; 483 return ret; 484} 485 486static int str_cpus_allowed_cb(void *data, const char *input) 487{ 488 struct thread_data *td = data; 489 int ret; 490 491 ret = set_cpus_allowed(td, &td->o.cpumask, input); 492 if (!ret) 493 td->o.cpumask_set = 1; 494 495 return ret; 496} 497 498static int str_verify_cpus_allowed_cb(void *data, const char *input) 499{ 500 struct thread_data *td = data; 501 int ret; 502 503 ret = set_cpus_allowed(td, &td->o.verify_cpumask, input); 504 if (!ret) 505 td->o.verify_cpumask_set = 1; 506 507 return ret; 508} 509#endif 510 511#ifdef CONFIG_LIBNUMA 512static int str_numa_cpunodes_cb(void *data, char *input) 513{ 514 struct thread_data *td = data; 515 516 /* numa_parse_nodestring() parses a character string list 517 * of nodes into a bit mask. The bit mask is allocated by 518 * numa_allocate_nodemask(), so it should be freed by 519 * numa_free_nodemask(). 520 */ 521 td->o.numa_cpunodesmask = numa_parse_nodestring(input); 522 if (td->o.numa_cpunodesmask == NULL) { 523 log_err("fio: numa_parse_nodestring failed\n"); 524 td_verror(td, 1, "str_numa_cpunodes_cb"); 525 return 1; 526 } 527 528 td->o.numa_cpumask_set = 1; 529 return 0; 530} 531 532static int str_numa_mpol_cb(void *data, char *input) 533{ 534 struct thread_data *td = data; 535 const char * const policy_types[] = 536 { "default", "prefer", "bind", "interleave", "local" }; 537 int i; 538 539 char *nodelist = strchr(input, ':'); 540 if (nodelist) { 541 /* NUL-terminate mode */ 542 *nodelist++ = '\0'; 543 } 544 545 for (i = 0; i <= MPOL_LOCAL; i++) { 546 if (!strcmp(input, policy_types[i])) { 547 td->o.numa_mem_mode = i; 548 break; 549 } 550 } 551 if (i > MPOL_LOCAL) { 552 log_err("fio: memory policy should be: default, prefer, bind, interleave, local\n"); 553 goto out; 554 } 555 556 switch (td->o.numa_mem_mode) { 557 case MPOL_PREFERRED: 558 /* 559 * Insist on a nodelist of one node only 560 */ 561 if (nodelist) { 562 char *rest = nodelist; 563 while (isdigit(*rest)) 564 rest++; 565 if (*rest) { 566 log_err("fio: one node only for \'prefer\'\n"); 567 goto out; 568 } 569 } else { 570 log_err("fio: one node is needed for \'prefer\'\n"); 571 goto out; 572 } 573 break; 574 case MPOL_INTERLEAVE: 575 /* 576 * Default to online nodes with memory if no nodelist 577 */ 578 if (!nodelist) 579 nodelist = strdup("all"); 580 break; 581 case MPOL_LOCAL: 582 case MPOL_DEFAULT: 583 /* 584 * Don't allow a nodelist 585 */ 586 if (nodelist) { 587 log_err("fio: NO nodelist for \'local\'\n"); 588 goto out; 589 } 590 break; 591 case MPOL_BIND: 592 /* 593 * Insist on a nodelist 594 */ 595 if (!nodelist) { 596 log_err("fio: a nodelist is needed for \'bind\'\n"); 597 goto out; 598 } 599 break; 600 } 601 602 603 /* numa_parse_nodestring() parses a character string list 604 * of nodes into a bit mask. The bit mask is allocated by 605 * numa_allocate_nodemask(), so it should be freed by 606 * numa_free_nodemask(). 607 */ 608 switch (td->o.numa_mem_mode) { 609 case MPOL_PREFERRED: 610 td->o.numa_mem_prefer_node = atoi(nodelist); 611 break; 612 case MPOL_INTERLEAVE: 613 case MPOL_BIND: 614 td->o.numa_memnodesmask = numa_parse_nodestring(nodelist); 615 if (td->o.numa_memnodesmask == NULL) { 616 log_err("fio: numa_parse_nodestring failed\n"); 617 td_verror(td, 1, "str_numa_memnodes_cb"); 618 return 1; 619 } 620 break; 621 case MPOL_LOCAL: 622 case MPOL_DEFAULT: 623 default: 624 break; 625 } 626 627 td->o.numa_memmask_set = 1; 628 return 0; 629 630out: 631 return 1; 632} 633#endif 634 635static int str_fst_cb(void *data, const char *str) 636{ 637 struct thread_data *td = data; 638 char *nr = get_opt_postfix(str); 639 640 td->file_service_nr = 1; 641 if (nr) { 642 td->file_service_nr = atoi(nr); 643 free(nr); 644 } 645 646 return 0; 647} 648 649#ifdef CONFIG_SYNC_FILE_RANGE 650static int str_sfr_cb(void *data, const char *str) 651{ 652 struct thread_data *td = data; 653 char *nr = get_opt_postfix(str); 654 655 td->sync_file_range_nr = 1; 656 if (nr) { 657 td->sync_file_range_nr = atoi(nr); 658 free(nr); 659 } 660 661 return 0; 662} 663#endif 664 665static int str_random_distribution_cb(void *data, const char *str) 666{ 667 struct thread_data *td = data; 668 double val; 669 char *nr; 670 671 if (td->o.random_distribution == FIO_RAND_DIST_ZIPF) 672 val = 1.1; 673 else if (td->o.random_distribution == FIO_RAND_DIST_PARETO) 674 val = 0.2; 675 else 676 return 0; 677 678 nr = get_opt_postfix(str); 679 if (nr && !str_to_float(nr, &val)) { 680 log_err("fio: random postfix parsing failed\n"); 681 free(nr); 682 return 1; 683 } 684 685 free(nr); 686 687 if (td->o.random_distribution == FIO_RAND_DIST_ZIPF) { 688 if (val == 1.00) { 689 log_err("fio: zipf theta must different than 1.0\n"); 690 return 1; 691 } 692 td->o.zipf_theta.u.f = val; 693 } else { 694 if (val <= 0.00 || val >= 1.00) { 695 log_err("fio: pareto input out of range (0 < input < 1.0)\n"); 696 return 1; 697 } 698 td->o.pareto_h.u.f = val; 699 } 700 701 return 0; 702} 703 704/* 705 * Return next file in the string. Files are separated with ':'. If the ':' 706 * is escaped with a '\', then that ':' is part of the filename and does not 707 * indicate a new file. 708 */ 709static char *get_next_file_name(char **ptr) 710{ 711 char *str = *ptr; 712 char *p, *start; 713 714 if (!str || !strlen(str)) 715 return NULL; 716 717 start = str; 718 do { 719 /* 720 * No colon, we are done 721 */ 722 p = strchr(str, ':'); 723 if (!p) { 724 *ptr = NULL; 725 break; 726 } 727 728 /* 729 * We got a colon, but it's the first character. Skip and 730 * continue 731 */ 732 if (p == start) { 733 str = ++start; 734 continue; 735 } 736 737 if (*(p - 1) != '\\') { 738 *p = '\0'; 739 *ptr = p + 1; 740 break; 741 } 742 743 memmove(p - 1, p, strlen(p) + 1); 744 str = p; 745 } while (1); 746 747 return start; 748} 749 750static int str_filename_cb(void *data, const char *input) 751{ 752 struct thread_data *td = data; 753 char *fname, *str, *p; 754 755 p = str = strdup(input); 756 757 strip_blank_front(&str); 758 strip_blank_end(str); 759 760 if (!td->files_index) 761 td->o.nr_files = 0; 762 763 while ((fname = get_next_file_name(&str)) != NULL) { 764 if (!strlen(fname)) 765 break; 766 add_file(td, fname); 767 td->o.nr_files++; 768 } 769 770 free(p); 771 return 0; 772} 773 774static int str_directory_cb(void *data, const char fio_unused *str) 775{ 776 struct thread_data *td = data; 777 struct stat sb; 778 779 if (lstat(td->o.directory, &sb) < 0) { 780 int ret = errno; 781 782 log_err("fio: %s is not a directory\n", td->o.directory); 783 td_verror(td, ret, "lstat"); 784 return 1; 785 } 786 if (!S_ISDIR(sb.st_mode)) { 787 log_err("fio: %s is not a directory\n", td->o.directory); 788 return 1; 789 } 790 791 return 0; 792} 793 794static int str_opendir_cb(void *data, const char fio_unused *str) 795{ 796 struct thread_data *td = data; 797 798 if (!td->files_index) 799 td->o.nr_files = 0; 800 801 return add_dir_files(td, td->o.opendir); 802} 803 804static int str_verify_pattern_cb(void *data, const char *input) 805{ 806 struct thread_data *td = data; 807 long off; 808 int i = 0, j = 0, len, k, base = 10; 809 char *loc1, *loc2; 810 811 loc1 = strstr(input, "0x"); 812 loc2 = strstr(input, "0X"); 813 if (loc1 || loc2) 814 base = 16; 815 off = strtol(input, NULL, base); 816 if (off != LONG_MAX || errno != ERANGE) { 817 while (off) { 818 td->o.verify_pattern[i] = off & 0xff; 819 off >>= 8; 820 i++; 821 } 822 } else { 823 len = strlen(input); 824 k = len - 1; 825 if (base == 16) { 826 if (loc1) 827 j = loc1 - input + 2; 828 else 829 j = loc2 - input + 2; 830 } else 831 return 1; 832 if (len - j < MAX_PATTERN_SIZE * 2) { 833 while (k >= j) { 834 off = converthexchartoint(input[k--]); 835 if (k >= j) 836 off += (converthexchartoint(input[k--]) 837 * 16); 838 td->o.verify_pattern[i++] = (char) off; 839 } 840 } 841 } 842 843 /* 844 * Fill the pattern all the way to the end. This greatly reduces 845 * the number of memcpy's we have to do when verifying the IO. 846 */ 847 while (i > 1 && i * 2 <= MAX_PATTERN_SIZE) { 848 memcpy(&td->o.verify_pattern[i], &td->o.verify_pattern[0], i); 849 i *= 2; 850 } 851 if (i == 1) { 852 /* 853 * The code in verify_io_u_pattern assumes a single byte pattern 854 * fills the whole verify pattern buffer. 855 */ 856 memset(td->o.verify_pattern, td->o.verify_pattern[0], 857 MAX_PATTERN_SIZE); 858 } 859 860 td->o.verify_pattern_bytes = i; 861 862 /* 863 * VERIFY_META could already be set 864 */ 865 if (td->o.verify == VERIFY_NONE) 866 td->o.verify = VERIFY_PATTERN; 867 868 return 0; 869} 870 871static int str_gtod_reduce_cb(void *data, int *il) 872{ 873 struct thread_data *td = data; 874 int val = *il; 875 876 td->o.disable_lat = !!val; 877 td->o.disable_clat = !!val; 878 td->o.disable_slat = !!val; 879 td->o.disable_bw = !!val; 880 td->o.clat_percentiles = !val; 881 if (val) 882 td->tv_cache_mask = 63; 883 884 return 0; 885} 886 887static int str_gtod_cpu_cb(void *data, long long *il) 888{ 889 struct thread_data *td = data; 890 int val = *il; 891 892 td->o.gtod_cpu = val; 893 td->o.gtod_offload = 1; 894 return 0; 895} 896 897static int str_size_cb(void *data, unsigned long long *__val) 898{ 899 struct thread_data *td = data; 900 unsigned long long v = *__val; 901 902 if (parse_is_percent(v)) { 903 td->o.size = 0; 904 td->o.size_percent = -1ULL - v; 905 } else 906 td->o.size = v; 907 908 return 0; 909} 910 911static int rw_verify(struct fio_option *o, void *data) 912{ 913 struct thread_data *td = data; 914 915 if (read_only && td_write(td)) { 916 log_err("fio: job <%s> has write bit set, but fio is in" 917 " read-only mode\n", td->o.name); 918 return 1; 919 } 920 921 return 0; 922} 923 924static int gtod_cpu_verify(struct fio_option *o, void *data) 925{ 926#ifndef FIO_HAVE_CPU_AFFINITY 927 struct thread_data *td = data; 928 929 if (td->o.gtod_cpu) { 930 log_err("fio: platform must support CPU affinity for" 931 "gettimeofday() offloading\n"); 932 return 1; 933 } 934#endif 935 936 return 0; 937} 938 939static int kb_base_verify(struct fio_option *o, void *data) 940{ 941 struct thread_data *td = data; 942 943 if (td->o.kb_base != 1024 && td->o.kb_base != 1000) { 944 log_err("fio: kb_base set to nonsensical value: %u\n", 945 td->o.kb_base); 946 return 1; 947 } 948 949 return 0; 950} 951 952/* 953 * Option grouping 954 */ 955static struct opt_group fio_opt_groups[] = { 956 { 957 .name = "General", 958 .mask = FIO_OPT_C_GENERAL, 959 }, 960 { 961 .name = "I/O", 962 .mask = FIO_OPT_C_IO, 963 }, 964 { 965 .name = "File", 966 .mask = FIO_OPT_C_FILE, 967 }, 968 { 969 .name = "Statistics", 970 .mask = FIO_OPT_C_STAT, 971 }, 972 { 973 .name = "Logging", 974 .mask = FIO_OPT_C_LOG, 975 }, 976 { 977 .name = "Profiles", 978 .mask = FIO_OPT_C_PROFILE, 979 }, 980 { 981 .name = NULL, 982 }, 983}; 984 985static struct opt_group *__opt_group_from_mask(struct opt_group *ogs, unsigned int *mask, 986 unsigned int inv_mask) 987{ 988 struct opt_group *og; 989 int i; 990 991 if (*mask == inv_mask || !*mask) 992 return NULL; 993 994 for (i = 0; ogs[i].name; i++) { 995 og = &ogs[i]; 996 997 if (*mask & og->mask) { 998 *mask &= ~(og->mask); 999 return og; 1000 } 1001 } 1002 1003 return NULL; 1004} 1005 1006struct opt_group *opt_group_from_mask(unsigned int *mask) 1007{ 1008 return __opt_group_from_mask(fio_opt_groups, mask, FIO_OPT_C_INVALID); 1009} 1010 1011static struct opt_group fio_opt_cat_groups[] = { 1012 { 1013 .name = "Rate", 1014 .mask = FIO_OPT_G_RATE, 1015 }, 1016 { 1017 .name = "Zone", 1018 .mask = FIO_OPT_G_ZONE, 1019 }, 1020 { 1021 .name = "Read/write mix", 1022 .mask = FIO_OPT_G_RWMIX, 1023 }, 1024 { 1025 .name = "Verify", 1026 .mask = FIO_OPT_G_VERIFY, 1027 }, 1028 { 1029 .name = "Trim", 1030 .mask = FIO_OPT_G_TRIM, 1031 }, 1032 { 1033 .name = "I/O Logging", 1034 .mask = FIO_OPT_G_IOLOG, 1035 }, 1036 { 1037 .name = "I/O Depth", 1038 .mask = FIO_OPT_G_IO_DEPTH, 1039 }, 1040 { 1041 .name = "I/O Flow", 1042 .mask = FIO_OPT_G_IO_FLOW, 1043 }, 1044 { 1045 .name = "Description", 1046 .mask = FIO_OPT_G_DESC, 1047 }, 1048 { 1049 .name = "Filename", 1050 .mask = FIO_OPT_G_FILENAME, 1051 }, 1052 { 1053 .name = "General I/O", 1054 .mask = FIO_OPT_G_IO_BASIC, 1055 }, 1056 { 1057 .name = "Cgroups", 1058 .mask = FIO_OPT_G_CGROUP, 1059 }, 1060 { 1061 .name = "Runtime", 1062 .mask = FIO_OPT_G_RUNTIME, 1063 }, 1064 { 1065 .name = "Process", 1066 .mask = FIO_OPT_G_PROCESS, 1067 }, 1068 { 1069 .name = "Job credentials / priority", 1070 .mask = FIO_OPT_G_CRED, 1071 }, 1072 { 1073 .name = "Clock settings", 1074 .mask = FIO_OPT_G_CLOCK, 1075 }, 1076 { 1077 .name = "I/O Type", 1078 .mask = FIO_OPT_G_IO_TYPE, 1079 }, 1080 { 1081 .name = "I/O Thinktime", 1082 .mask = FIO_OPT_G_THINKTIME, 1083 }, 1084 { 1085 .name = "Randomizations", 1086 .mask = FIO_OPT_G_RANDOM, 1087 }, 1088 { 1089 .name = "I/O buffers", 1090 .mask = FIO_OPT_G_IO_BUF, 1091 }, 1092 { 1093 .name = "Tiobench profile", 1094 .mask = FIO_OPT_G_TIOBENCH, 1095 }, 1096 1097 { 1098 .name = NULL, 1099 } 1100}; 1101 1102struct opt_group *opt_group_cat_from_mask(unsigned int *mask) 1103{ 1104 return __opt_group_from_mask(fio_opt_cat_groups, mask, FIO_OPT_G_INVALID); 1105} 1106 1107/* 1108 * Map of job/command line options 1109 */ 1110struct fio_option fio_options[FIO_MAX_OPTS] = { 1111 { 1112 .name = "description", 1113 .lname = "Description of job", 1114 .type = FIO_OPT_STR_STORE, 1115 .off1 = td_var_offset(description), 1116 .help = "Text job description", 1117 .category = FIO_OPT_C_GENERAL, 1118 .group = FIO_OPT_G_DESC, 1119 }, 1120 { 1121 .name = "name", 1122 .lname = "Job name", 1123 .type = FIO_OPT_STR_STORE, 1124 .off1 = td_var_offset(name), 1125 .help = "Name of this job", 1126 .category = FIO_OPT_C_GENERAL, 1127 .group = FIO_OPT_G_DESC, 1128 }, 1129 { 1130 .name = "filename", 1131 .lname = "Filename(s)", 1132 .type = FIO_OPT_STR_STORE, 1133 .off1 = td_var_offset(filename), 1134 .cb = str_filename_cb, 1135 .prio = -1, /* must come after "directory" */ 1136 .help = "File(s) to use for the workload", 1137 .category = FIO_OPT_C_FILE, 1138 .group = FIO_OPT_G_FILENAME, 1139 }, 1140 { 1141 .name = "directory", 1142 .lname = "Directory", 1143 .type = FIO_OPT_STR_STORE, 1144 .off1 = td_var_offset(directory), 1145 .cb = str_directory_cb, 1146 .help = "Directory to store files in", 1147 .category = FIO_OPT_C_FILE, 1148 .group = FIO_OPT_G_FILENAME, 1149 }, 1150 { 1151 .name = "lockfile", 1152 .lname = "Lockfile", 1153 .type = FIO_OPT_STR, 1154 .off1 = td_var_offset(file_lock_mode), 1155 .help = "Lock file when doing IO to it", 1156 .parent = "filename", 1157 .hide = 0, 1158 .def = "none", 1159 .category = FIO_OPT_C_FILE, 1160 .group = FIO_OPT_G_FILENAME, 1161 .posval = { 1162 { .ival = "none", 1163 .oval = FILE_LOCK_NONE, 1164 .help = "No file locking", 1165 }, 1166 { .ival = "exclusive", 1167 .oval = FILE_LOCK_EXCLUSIVE, 1168 .help = "Exclusive file lock", 1169 }, 1170 { 1171 .ival = "readwrite", 1172 .oval = FILE_LOCK_READWRITE, 1173 .help = "Read vs write lock", 1174 }, 1175 }, 1176 }, 1177 { 1178 .name = "opendir", 1179 .lname = "Open directory", 1180 .type = FIO_OPT_STR_STORE, 1181 .off1 = td_var_offset(opendir), 1182 .cb = str_opendir_cb, 1183 .help = "Recursively add files from this directory and down", 1184 .category = FIO_OPT_C_FILE, 1185 .group = FIO_OPT_G_FILENAME, 1186 }, 1187 { 1188 .name = "rw", 1189 .lname = "Read/write", 1190 .alias = "readwrite", 1191 .type = FIO_OPT_STR, 1192 .cb = str_rw_cb, 1193 .off1 = td_var_offset(td_ddir), 1194 .help = "IO direction", 1195 .def = "read", 1196 .verify = rw_verify, 1197 .category = FIO_OPT_C_IO, 1198 .group = FIO_OPT_G_IO_BASIC, 1199 .posval = { 1200 { .ival = "read", 1201 .oval = TD_DDIR_READ, 1202 .help = "Sequential read", 1203 }, 1204 { .ival = "write", 1205 .oval = TD_DDIR_WRITE, 1206 .help = "Sequential write", 1207 }, 1208 { .ival = "trim", 1209 .oval = TD_DDIR_TRIM, 1210 .help = "Sequential trim", 1211 }, 1212 { .ival = "randread", 1213 .oval = TD_DDIR_RANDREAD, 1214 .help = "Random read", 1215 }, 1216 { .ival = "randwrite", 1217 .oval = TD_DDIR_RANDWRITE, 1218 .help = "Random write", 1219 }, 1220 { .ival = "randtrim", 1221 .oval = TD_DDIR_RANDTRIM, 1222 .help = "Random trim", 1223 }, 1224 { .ival = "rw", 1225 .oval = TD_DDIR_RW, 1226 .help = "Sequential read and write mix", 1227 }, 1228 { .ival = "readwrite", 1229 .oval = TD_DDIR_RW, 1230 .help = "Sequential read and write mix", 1231 }, 1232 { .ival = "randrw", 1233 .oval = TD_DDIR_RANDRW, 1234 .help = "Random read and write mix" 1235 }, 1236 }, 1237 }, 1238 { 1239 .name = "rw_sequencer", 1240 .lname = "RW Sequencer", 1241 .type = FIO_OPT_STR, 1242 .off1 = td_var_offset(rw_seq), 1243 .help = "IO offset generator modifier", 1244 .def = "sequential", 1245 .category = FIO_OPT_C_IO, 1246 .group = FIO_OPT_G_IO_BASIC, 1247 .posval = { 1248 { .ival = "sequential", 1249 .oval = RW_SEQ_SEQ, 1250 .help = "Generate sequential offsets", 1251 }, 1252 { .ival = "identical", 1253 .oval = RW_SEQ_IDENT, 1254 .help = "Generate identical offsets", 1255 }, 1256 }, 1257 }, 1258 1259 { 1260 .name = "ioengine", 1261 .lname = "IO Engine", 1262 .type = FIO_OPT_STR_STORE, 1263 .off1 = td_var_offset(ioengine), 1264 .help = "IO engine to use", 1265 .def = FIO_PREFERRED_ENGINE, 1266 .category = FIO_OPT_C_IO, 1267 .group = FIO_OPT_G_IO_BASIC, 1268 .posval = { 1269 { .ival = "sync", 1270 .help = "Use read/write", 1271 }, 1272 { .ival = "psync", 1273 .help = "Use pread/pwrite", 1274 }, 1275 { .ival = "vsync", 1276 .help = "Use readv/writev", 1277 }, 1278#ifdef CONFIG_LIBAIO 1279 { .ival = "libaio", 1280 .help = "Linux native asynchronous IO", 1281 }, 1282#endif 1283#ifdef CONFIG_POSIXAIO 1284 { .ival = "posixaio", 1285 .help = "POSIX asynchronous IO", 1286 }, 1287#endif 1288#ifdef CONFIG_SOLARISAIO 1289 { .ival = "solarisaio", 1290 .help = "Solaris native asynchronous IO", 1291 }, 1292#endif 1293#ifdef CONFIG_WINDOWSAIO 1294 { .ival = "windowsaio", 1295 .help = "Windows native asynchronous IO" 1296 }, 1297#endif 1298 { .ival = "mmap", 1299 .help = "Memory mapped IO" 1300 }, 1301#ifdef CONFIG_LINUX_SPLICE 1302 { .ival = "splice", 1303 .help = "splice/vmsplice based IO", 1304 }, 1305 { .ival = "netsplice", 1306 .help = "splice/vmsplice to/from the network", 1307 }, 1308#endif 1309#ifdef FIO_HAVE_SGIO 1310 { .ival = "sg", 1311 .help = "SCSI generic v3 IO", 1312 }, 1313#endif 1314 { .ival = "null", 1315 .help = "Testing engine (no data transfer)", 1316 }, 1317 { .ival = "net", 1318 .help = "Network IO", 1319 }, 1320 { .ival = "cpuio", 1321 .help = "CPU cycle burner engine", 1322 }, 1323#ifdef CONFIG_GUASI 1324 { .ival = "guasi", 1325 .help = "GUASI IO engine", 1326 }, 1327#endif 1328#ifdef FIO_HAVE_BINJECT 1329 { .ival = "binject", 1330 .help = "binject direct inject block engine", 1331 }, 1332#endif 1333#ifdef CONFIG_RDMA 1334 { .ival = "rdma", 1335 .help = "RDMA IO engine", 1336 }, 1337#endif 1338#ifdef CONFIG_FUSION_AW 1339 { .ival = "fusion-aw-sync", 1340 .help = "Fusion-io atomic write engine", 1341 }, 1342#endif 1343#ifdef CONFIG_LINUX_EXT4_MOVE_EXTENT 1344 { .ival = "e4defrag", 1345 .help = "ext4 defrag engine", 1346 }, 1347#endif 1348#ifdef CONFIG_LINUX_FALLOCATE 1349 { .ival = "falloc", 1350 .help = "fallocate() file based engine", 1351 }, 1352#endif 1353 { .ival = "external", 1354 .help = "Load external engine (append name)", 1355 }, 1356 }, 1357 }, 1358 { 1359 .name = "iodepth", 1360 .lname = "IO Depth", 1361 .type = FIO_OPT_INT, 1362 .off1 = td_var_offset(iodepth), 1363 .help = "Number of IO buffers to keep in flight", 1364 .minval = 1, 1365 .interval = 1, 1366 .def = "1", 1367 .category = FIO_OPT_C_IO, 1368 .group = FIO_OPT_G_IO_BASIC, 1369 }, 1370 { 1371 .name = "iodepth_batch", 1372 .lname = "IO Depth batch", 1373 .alias = "iodepth_batch_submit", 1374 .type = FIO_OPT_INT, 1375 .off1 = td_var_offset(iodepth_batch), 1376 .help = "Number of IO buffers to submit in one go", 1377 .parent = "iodepth", 1378 .hide = 1, 1379 .minval = 1, 1380 .interval = 1, 1381 .def = "1", 1382 .category = FIO_OPT_C_IO, 1383 .group = FIO_OPT_G_IO_BASIC, 1384 }, 1385 { 1386 .name = "iodepth_batch_complete", 1387 .lname = "IO Depth batch complete", 1388 .type = FIO_OPT_INT, 1389 .off1 = td_var_offset(iodepth_batch_complete), 1390 .help = "Number of IO buffers to retrieve in one go", 1391 .parent = "iodepth", 1392 .hide = 1, 1393 .minval = 0, 1394 .interval = 1, 1395 .def = "1", 1396 .category = FIO_OPT_C_IO, 1397 .group = FIO_OPT_G_IO_BASIC, 1398 }, 1399 { 1400 .name = "iodepth_low", 1401 .lname = "IO Depth batch low", 1402 .type = FIO_OPT_INT, 1403 .off1 = td_var_offset(iodepth_low), 1404 .help = "Low water mark for queuing depth", 1405 .parent = "iodepth", 1406 .hide = 1, 1407 .interval = 1, 1408 .category = FIO_OPT_C_IO, 1409 .group = FIO_OPT_G_IO_BASIC, 1410 }, 1411 { 1412 .name = "size", 1413 .lname = "Size", 1414 .type = FIO_OPT_STR_VAL, 1415 .cb = str_size_cb, 1416 .help = "Total size of device or files", 1417 .interval = 1024 * 1024, 1418 .category = FIO_OPT_C_IO, 1419 .group = FIO_OPT_G_INVALID, 1420 }, 1421 { 1422 .name = "fill_device", 1423 .lname = "Fill device", 1424 .alias = "fill_fs", 1425 .type = FIO_OPT_BOOL, 1426 .off1 = td_var_offset(fill_device), 1427 .help = "Write until an ENOSPC error occurs", 1428 .def = "0", 1429 .category = FIO_OPT_C_FILE, 1430 .group = FIO_OPT_G_INVALID, 1431 }, 1432 { 1433 .name = "filesize", 1434 .lname = "File size", 1435 .type = FIO_OPT_STR_VAL, 1436 .off1 = td_var_offset(file_size_low), 1437 .off2 = td_var_offset(file_size_high), 1438 .minval = 1, 1439 .help = "Size of individual files", 1440 .interval = 1024 * 1024, 1441 .category = FIO_OPT_C_FILE, 1442 .group = FIO_OPT_G_INVALID, 1443 }, 1444 { 1445 .name = "offset", 1446 .lname = "IO offset", 1447 .alias = "fileoffset", 1448 .type = FIO_OPT_STR_VAL, 1449 .off1 = td_var_offset(start_offset), 1450 .help = "Start IO from this offset", 1451 .def = "0", 1452 .interval = 1024 * 1024, 1453 .category = FIO_OPT_C_IO, 1454 .group = FIO_OPT_G_INVALID, 1455 }, 1456 { 1457 .name = "offset_increment", 1458 .lname = "IO offset increment", 1459 .type = FIO_OPT_STR_VAL, 1460 .off1 = td_var_offset(offset_increment), 1461 .help = "What is the increment from one offset to the next", 1462 .parent = "offset", 1463 .hide = 1, 1464 .def = "0", 1465 .interval = 1024 * 1024, 1466 .category = FIO_OPT_C_IO, 1467 .group = FIO_OPT_G_INVALID, 1468 }, 1469 { 1470 .name = "bs", 1471 .lname = "Block size", 1472 .alias = "blocksize", 1473 .type = FIO_OPT_INT, 1474 .off1 = td_var_offset(bs[DDIR_READ]), 1475 .off2 = td_var_offset(bs[DDIR_WRITE]), 1476 .off3 = td_var_offset(bs[DDIR_TRIM]), 1477 .minval = 1, 1478 .help = "Block size unit", 1479 .def = "4k", 1480 .parent = "rw", 1481 .hide = 1, 1482 .interval = 512, 1483 .category = FIO_OPT_C_IO, 1484 .group = FIO_OPT_G_INVALID, 1485 }, 1486 { 1487 .name = "ba", 1488 .lname = "Block size align", 1489 .alias = "blockalign", 1490 .type = FIO_OPT_INT, 1491 .off1 = td_var_offset(ba[DDIR_READ]), 1492 .off2 = td_var_offset(ba[DDIR_WRITE]), 1493 .off3 = td_var_offset(ba[DDIR_TRIM]), 1494 .minval = 1, 1495 .help = "IO block offset alignment", 1496 .parent = "rw", 1497 .hide = 1, 1498 .interval = 512, 1499 .category = FIO_OPT_C_IO, 1500 .group = FIO_OPT_G_INVALID, 1501 }, 1502 { 1503 .name = "bsrange", 1504 .lname = "Block size range", 1505 .alias = "blocksize_range", 1506 .type = FIO_OPT_RANGE, 1507 .off1 = td_var_offset(min_bs[DDIR_READ]), 1508 .off2 = td_var_offset(max_bs[DDIR_READ]), 1509 .off3 = td_var_offset(min_bs[DDIR_WRITE]), 1510 .off4 = td_var_offset(max_bs[DDIR_WRITE]), 1511 .off5 = td_var_offset(min_bs[DDIR_TRIM]), 1512 .off6 = td_var_offset(max_bs[DDIR_TRIM]), 1513 .minval = 1, 1514 .help = "Set block size range (in more detail than bs)", 1515 .parent = "rw", 1516 .hide = 1, 1517 .interval = 4096, 1518 .category = FIO_OPT_C_IO, 1519 .group = FIO_OPT_G_INVALID, 1520 }, 1521 { 1522 .name = "bssplit", 1523 .lname = "Block size split", 1524 .type = FIO_OPT_STR, 1525 .cb = str_bssplit_cb, 1526 .help = "Set a specific mix of block sizes", 1527 .parent = "rw", 1528 .hide = 1, 1529 .category = FIO_OPT_C_IO, 1530 .group = FIO_OPT_G_INVALID, 1531 }, 1532 { 1533 .name = "bs_unaligned", 1534 .lname = "Block size unaligned", 1535 .alias = "blocksize_unaligned", 1536 .type = FIO_OPT_STR_SET, 1537 .off1 = td_var_offset(bs_unaligned), 1538 .help = "Don't sector align IO buffer sizes", 1539 .parent = "rw", 1540 .hide = 1, 1541 .category = FIO_OPT_C_IO, 1542 .group = FIO_OPT_G_INVALID, 1543 }, 1544 { 1545 .name = "randrepeat", 1546 .lname = "Random repeatable", 1547 .type = FIO_OPT_BOOL, 1548 .off1 = td_var_offset(rand_repeatable), 1549 .help = "Use repeatable random IO pattern", 1550 .def = "1", 1551 .parent = "rw", 1552 .hide = 1, 1553 .category = FIO_OPT_C_IO, 1554 .group = FIO_OPT_G_RANDOM, 1555 }, 1556 { 1557 .name = "use_os_rand", 1558 .lname = "Use OS random", 1559 .type = FIO_OPT_BOOL, 1560 .off1 = td_var_offset(use_os_rand), 1561 .help = "Set to use OS random generator", 1562 .def = "0", 1563 .parent = "rw", 1564 .hide = 1, 1565 .category = FIO_OPT_C_IO, 1566 .group = FIO_OPT_G_RANDOM, 1567 }, 1568 { 1569 .name = "norandommap", 1570 .lname = "No randommap", 1571 .type = FIO_OPT_STR_SET, 1572 .off1 = td_var_offset(norandommap), 1573 .help = "Accept potential duplicate random blocks", 1574 .parent = "rw", 1575 .hide = 1, 1576 .hide_on_set = 1, 1577 .category = FIO_OPT_C_IO, 1578 .group = FIO_OPT_G_RANDOM, 1579 }, 1580 { 1581 .name = "softrandommap", 1582 .lname = "Soft randommap", 1583 .type = FIO_OPT_BOOL, 1584 .off1 = td_var_offset(softrandommap), 1585 .help = "Set norandommap if randommap allocation fails", 1586 .parent = "norandommap", 1587 .hide = 1, 1588 .def = "0", 1589 .category = FIO_OPT_C_IO, 1590 .group = FIO_OPT_G_RANDOM, 1591 }, 1592 { 1593 .name = "random_generator", 1594 .type = FIO_OPT_STR, 1595 .off1 = td_var_offset(random_generator), 1596 .help = "Type of random number generator to use", 1597 .def = "tausworthe", 1598 .posval = { 1599 { .ival = "tausworthe", 1600 .oval = FIO_RAND_GEN_TAUSWORTHE, 1601 .help = "Strong Tausworthe generator", 1602 }, 1603 { .ival = "lfsr", 1604 .oval = FIO_RAND_GEN_LFSR, 1605 .help = "Variable length LFSR", 1606 }, 1607 }, 1608 .category = FIO_OPT_C_IO, 1609 .group = FIO_OPT_G_RANDOM, 1610 }, 1611 { 1612 .name = "random_distribution", 1613 .type = FIO_OPT_STR, 1614 .off1 = td_var_offset(random_distribution), 1615 .cb = str_random_distribution_cb, 1616 .help = "Random offset distribution generator", 1617 .def = "random", 1618 .posval = { 1619 { .ival = "random", 1620 .oval = FIO_RAND_DIST_RANDOM, 1621 .help = "Completely random", 1622 }, 1623 { .ival = "zipf", 1624 .oval = FIO_RAND_DIST_ZIPF, 1625 .help = "Zipf distribution", 1626 }, 1627 { .ival = "pareto", 1628 .oval = FIO_RAND_DIST_PARETO, 1629 .help = "Pareto distribution", 1630 }, 1631 }, 1632 .category = FIO_OPT_C_IO, 1633 .group = FIO_OPT_G_RANDOM, 1634 }, 1635 { 1636 .name = "nrfiles", 1637 .lname = "Number of files", 1638 .alias = "nr_files", 1639 .type = FIO_OPT_INT, 1640 .off1 = td_var_offset(nr_files), 1641 .help = "Split job workload between this number of files", 1642 .def = "1", 1643 .interval = 1, 1644 .category = FIO_OPT_C_FILE, 1645 .group = FIO_OPT_G_INVALID, 1646 }, 1647 { 1648 .name = "openfiles", 1649 .lname = "Number of open files", 1650 .type = FIO_OPT_INT, 1651 .off1 = td_var_offset(open_files), 1652 .help = "Number of files to keep open at the same time", 1653 .category = FIO_OPT_C_FILE, 1654 .group = FIO_OPT_G_INVALID, 1655 }, 1656 { 1657 .name = "file_service_type", 1658 .lname = "File service type", 1659 .type = FIO_OPT_STR, 1660 .cb = str_fst_cb, 1661 .off1 = td_var_offset(file_service_type), 1662 .help = "How to select which file to service next", 1663 .def = "roundrobin", 1664 .category = FIO_OPT_C_FILE, 1665 .group = FIO_OPT_G_INVALID, 1666 .posval = { 1667 { .ival = "random", 1668 .oval = FIO_FSERVICE_RANDOM, 1669 .help = "Choose a file at random", 1670 }, 1671 { .ival = "roundrobin", 1672 .oval = FIO_FSERVICE_RR, 1673 .help = "Round robin select files", 1674 }, 1675 { .ival = "sequential", 1676 .oval = FIO_FSERVICE_SEQ, 1677 .help = "Finish one file before moving to the next", 1678 }, 1679 }, 1680 .parent = "nrfiles", 1681 .hide = 1, 1682 }, 1683#ifdef CONFIG_POSIX_FALLOCATE 1684 { 1685 .name = "fallocate", 1686 .lname = "Fallocate", 1687 .type = FIO_OPT_STR, 1688 .off1 = td_var_offset(fallocate_mode), 1689 .help = "Whether pre-allocation is performed when laying out files", 1690 .def = "posix", 1691 .category = FIO_OPT_C_FILE, 1692 .group = FIO_OPT_G_INVALID, 1693 .posval = { 1694 { .ival = "none", 1695 .oval = FIO_FALLOCATE_NONE, 1696 .help = "Do not pre-allocate space", 1697 }, 1698 { .ival = "posix", 1699 .oval = FIO_FALLOCATE_POSIX, 1700 .help = "Use posix_fallocate()", 1701 }, 1702#ifdef CONFIG_LINUX_FALLOCATE 1703 { .ival = "keep", 1704 .oval = FIO_FALLOCATE_KEEP_SIZE, 1705 .help = "Use fallocate(..., FALLOC_FL_KEEP_SIZE, ...)", 1706 }, 1707#endif 1708 /* Compatibility with former boolean values */ 1709 { .ival = "0", 1710 .oval = FIO_FALLOCATE_NONE, 1711 .help = "Alias for 'none'", 1712 }, 1713 { .ival = "1", 1714 .oval = FIO_FALLOCATE_POSIX, 1715 .help = "Alias for 'posix'", 1716 }, 1717 }, 1718 }, 1719#endif /* CONFIG_POSIX_FALLOCATE */ 1720 { 1721 .name = "fadvise_hint", 1722 .lname = "Fadvise hint", 1723 .type = FIO_OPT_BOOL, 1724 .off1 = td_var_offset(fadvise_hint), 1725 .help = "Use fadvise() to advise the kernel on IO pattern", 1726 .def = "1", 1727 .category = FIO_OPT_C_FILE, 1728 .group = FIO_OPT_G_INVALID, 1729 }, 1730 { 1731 .name = "fsync", 1732 .lname = "Fsync", 1733 .type = FIO_OPT_INT, 1734 .off1 = td_var_offset(fsync_blocks), 1735 .help = "Issue fsync for writes every given number of blocks", 1736 .def = "0", 1737 .interval = 1, 1738 .category = FIO_OPT_C_FILE, 1739 .group = FIO_OPT_G_INVALID, 1740 }, 1741 { 1742 .name = "fdatasync", 1743 .lname = "Fdatasync", 1744 .type = FIO_OPT_INT, 1745 .off1 = td_var_offset(fdatasync_blocks), 1746 .help = "Issue fdatasync for writes every given number of blocks", 1747 .def = "0", 1748 .interval = 1, 1749 .category = FIO_OPT_C_FILE, 1750 .group = FIO_OPT_G_INVALID, 1751 }, 1752 { 1753 .name = "write_barrier", 1754 .lname = "Write barrier", 1755 .type = FIO_OPT_INT, 1756 .off1 = td_var_offset(barrier_blocks), 1757 .help = "Make every Nth write a barrier write", 1758 .def = "0", 1759 .interval = 1, 1760 .category = FIO_OPT_C_IO, 1761 .group = FIO_OPT_G_INVALID, 1762 }, 1763#ifdef CONFIG_SYNC_FILE_RANGE 1764 { 1765 .name = "sync_file_range", 1766 .lname = "Sync file range", 1767 .posval = { 1768 { .ival = "wait_before", 1769 .oval = SYNC_FILE_RANGE_WAIT_BEFORE, 1770 .help = "SYNC_FILE_RANGE_WAIT_BEFORE", 1771 .or = 1, 1772 }, 1773 { .ival = "write", 1774 .oval = SYNC_FILE_RANGE_WRITE, 1775 .help = "SYNC_FILE_RANGE_WRITE", 1776 .or = 1, 1777 }, 1778 { 1779 .ival = "wait_after", 1780 .oval = SYNC_FILE_RANGE_WAIT_AFTER, 1781 .help = "SYNC_FILE_RANGE_WAIT_AFTER", 1782 .or = 1, 1783 }, 1784 }, 1785 .type = FIO_OPT_STR_MULTI, 1786 .cb = str_sfr_cb, 1787 .off1 = td_var_offset(sync_file_range), 1788 .help = "Use sync_file_range()", 1789 .category = FIO_OPT_C_FILE, 1790 .group = FIO_OPT_G_INVALID, 1791 }, 1792#endif 1793 { 1794 .name = "direct", 1795 .lname = "Direct I/O", 1796 .type = FIO_OPT_BOOL, 1797 .off1 = td_var_offset(odirect), 1798 .help = "Use O_DIRECT IO (negates buffered)", 1799 .def = "0", 1800 .inverse = "buffered", 1801 .category = FIO_OPT_C_IO, 1802 .group = FIO_OPT_G_IO_TYPE, 1803 }, 1804 { 1805 .name = "buffered", 1806 .lname = "Buffered I/O", 1807 .type = FIO_OPT_BOOL, 1808 .off1 = td_var_offset(odirect), 1809 .neg = 1, 1810 .help = "Use buffered IO (negates direct)", 1811 .def = "1", 1812 .inverse = "direct", 1813 .category = FIO_OPT_C_IO, 1814 .group = FIO_OPT_G_IO_TYPE, 1815 }, 1816 { 1817 .name = "overwrite", 1818 .lname = "Overwrite", 1819 .type = FIO_OPT_BOOL, 1820 .off1 = td_var_offset(overwrite), 1821 .help = "When writing, set whether to overwrite current data", 1822 .def = "0", 1823 .category = FIO_OPT_C_FILE, 1824 .group = FIO_OPT_G_INVALID, 1825 }, 1826 { 1827 .name = "loops", 1828 .lname = "Loops", 1829 .type = FIO_OPT_INT, 1830 .off1 = td_var_offset(loops), 1831 .help = "Number of times to run the job", 1832 .def = "1", 1833 .interval = 1, 1834 .category = FIO_OPT_C_GENERAL, 1835 .group = FIO_OPT_G_RUNTIME, 1836 }, 1837 { 1838 .name = "numjobs", 1839 .lname = "Number of jobs", 1840 .type = FIO_OPT_INT, 1841 .off1 = td_var_offset(numjobs), 1842 .help = "Duplicate this job this many times", 1843 .def = "1", 1844 .interval = 1, 1845 .category = FIO_OPT_C_GENERAL, 1846 .group = FIO_OPT_G_RUNTIME, 1847 }, 1848 { 1849 .name = "startdelay", 1850 .lname = "Start delay", 1851 .type = FIO_OPT_STR_VAL_TIME, 1852 .off1 = td_var_offset(start_delay), 1853 .help = "Only start job when this period has passed", 1854 .def = "0", 1855 .category = FIO_OPT_C_GENERAL, 1856 .group = FIO_OPT_G_RUNTIME, 1857 }, 1858 { 1859 .name = "runtime", 1860 .lname = "Runtime", 1861 .alias = "timeout", 1862 .type = FIO_OPT_STR_VAL_TIME, 1863 .off1 = td_var_offset(timeout), 1864 .help = "Stop workload when this amount of time has passed", 1865 .def = "0", 1866 .category = FIO_OPT_C_GENERAL, 1867 .group = FIO_OPT_G_RUNTIME, 1868 }, 1869 { 1870 .name = "time_based", 1871 .lname = "Time based", 1872 .type = FIO_OPT_STR_SET, 1873 .off1 = td_var_offset(time_based), 1874 .help = "Keep running until runtime/timeout is met", 1875 .category = FIO_OPT_C_GENERAL, 1876 .group = FIO_OPT_G_RUNTIME, 1877 }, 1878 { 1879 .name = "ramp_time", 1880 .lname = "Ramp time", 1881 .type = FIO_OPT_STR_VAL_TIME, 1882 .off1 = td_var_offset(ramp_time), 1883 .help = "Ramp up time before measuring performance", 1884 .category = FIO_OPT_C_GENERAL, 1885 .group = FIO_OPT_G_RUNTIME, 1886 }, 1887 { 1888 .name = "clocksource", 1889 .lname = "Clock source", 1890 .type = FIO_OPT_STR, 1891 .cb = fio_clock_source_cb, 1892 .off1 = td_var_offset(clocksource), 1893 .help = "What type of timing source to use", 1894 .category = FIO_OPT_C_GENERAL, 1895 .group = FIO_OPT_G_CLOCK, 1896 .posval = { 1897#ifdef CONFIG_GETTIMEOFDAY 1898 { .ival = "gettimeofday", 1899 .oval = CS_GTOD, 1900 .help = "Use gettimeofday(2) for timing", 1901 }, 1902#endif 1903#ifdef CONFIG_CLOCK_GETTIME 1904 { .ival = "clock_gettime", 1905 .oval = CS_CGETTIME, 1906 .help = "Use clock_gettime(2) for timing", 1907 }, 1908#endif 1909#ifdef ARCH_HAVE_CPU_CLOCK 1910 { .ival = "cpu", 1911 .oval = CS_CPUCLOCK, 1912 .help = "Use CPU private clock", 1913 }, 1914#endif 1915 }, 1916 }, 1917 { 1918 .name = "mem", 1919 .alias = "iomem", 1920 .lname = "I/O Memory", 1921 .type = FIO_OPT_STR, 1922 .cb = str_mem_cb, 1923 .off1 = td_var_offset(mem_type), 1924 .help = "Backing type for IO buffers", 1925 .def = "malloc", 1926 .category = FIO_OPT_C_IO, 1927 .group = FIO_OPT_G_INVALID, 1928 .posval = { 1929 { .ival = "malloc", 1930 .oval = MEM_MALLOC, 1931 .help = "Use malloc(3) for IO buffers", 1932 }, 1933 { .ival = "shm", 1934 .oval = MEM_SHM, 1935 .help = "Use shared memory segments for IO buffers", 1936 }, 1937#ifdef FIO_HAVE_HUGETLB 1938 { .ival = "shmhuge", 1939 .oval = MEM_SHMHUGE, 1940 .help = "Like shm, but use huge pages", 1941 }, 1942#endif 1943 { .ival = "mmap", 1944 .oval = MEM_MMAP, 1945 .help = "Use mmap(2) (file or anon) for IO buffers", 1946 }, 1947#ifdef FIO_HAVE_HUGETLB 1948 { .ival = "mmaphuge", 1949 .oval = MEM_MMAPHUGE, 1950 .help = "Like mmap, but use huge pages", 1951 }, 1952#endif 1953 }, 1954 }, 1955 { 1956 .name = "iomem_align", 1957 .alias = "mem_align", 1958 .lname = "I/O memory alignment", 1959 .type = FIO_OPT_INT, 1960 .off1 = td_var_offset(mem_align), 1961 .minval = 0, 1962 .help = "IO memory buffer offset alignment", 1963 .def = "0", 1964 .parent = "iomem", 1965 .hide = 1, 1966 .category = FIO_OPT_C_IO, 1967 .group = FIO_OPT_G_INVALID, 1968 }, 1969 { 1970 .name = "verify", 1971 .lname = "Verify", 1972 .type = FIO_OPT_STR, 1973 .off1 = td_var_offset(verify), 1974 .help = "Verify data written", 1975 .def = "0", 1976 .category = FIO_OPT_C_IO, 1977 .group = FIO_OPT_G_VERIFY, 1978 .posval = { 1979 { .ival = "0", 1980 .oval = VERIFY_NONE, 1981 .help = "Don't do IO verification", 1982 }, 1983 { .ival = "md5", 1984 .oval = VERIFY_MD5, 1985 .help = "Use md5 checksums for verification", 1986 }, 1987 { .ival = "crc64", 1988 .oval = VERIFY_CRC64, 1989 .help = "Use crc64 checksums for verification", 1990 }, 1991 { .ival = "crc32", 1992 .oval = VERIFY_CRC32, 1993 .help = "Use crc32 checksums for verification", 1994 }, 1995 { .ival = "crc32c-intel", 1996 .oval = VERIFY_CRC32C, 1997 .help = "Use crc32c checksums for verification (hw assisted, if available)", 1998 }, 1999 { .ival = "crc32c", 2000 .oval = VERIFY_CRC32C, 2001 .help = "Use crc32c checksums for verification (hw assisted, if available)", 2002 }, 2003 { .ival = "crc16", 2004 .oval = VERIFY_CRC16, 2005 .help = "Use crc16 checksums for verification", 2006 }, 2007 { .ival = "crc7", 2008 .oval = VERIFY_CRC7, 2009 .help = "Use crc7 checksums for verification", 2010 }, 2011 { .ival = "sha1", 2012 .oval = VERIFY_SHA1, 2013 .help = "Use sha1 checksums for verification", 2014 }, 2015 { .ival = "sha256", 2016 .oval = VERIFY_SHA256, 2017 .help = "Use sha256 checksums for verification", 2018 }, 2019 { .ival = "sha512", 2020 .oval = VERIFY_SHA512, 2021 .help = "Use sha512 checksums for verification", 2022 }, 2023 { .ival = "meta", 2024 .oval = VERIFY_META, 2025 .help = "Use io information", 2026 }, 2027 { 2028 .ival = "null", 2029 .oval = VERIFY_NULL, 2030 .help = "Pretend to verify", 2031 }, 2032 }, 2033 }, 2034 { 2035 .name = "do_verify", 2036 .lname = "Perform verify step", 2037 .type = FIO_OPT_BOOL, 2038 .off1 = td_var_offset(do_verify), 2039 .help = "Run verification stage after write", 2040 .def = "1", 2041 .parent = "verify", 2042 .hide = 1, 2043 .category = FIO_OPT_C_IO, 2044 .group = FIO_OPT_G_VERIFY, 2045 }, 2046 { 2047 .name = "verifysort", 2048 .lname = "Verify sort", 2049 .type = FIO_OPT_BOOL, 2050 .off1 = td_var_offset(verifysort), 2051 .help = "Sort written verify blocks for read back", 2052 .def = "1", 2053 .parent = "verify", 2054 .hide = 1, 2055 .category = FIO_OPT_C_IO, 2056 .group = FIO_OPT_G_VERIFY, 2057 }, 2058 { 2059 .name = "verifysort_nr", 2060 .type = FIO_OPT_INT, 2061 .off1 = td_var_offset(verifysort_nr), 2062 .help = "Pre-load and sort verify blocks for a read workload", 2063 .minval = 0, 2064 .maxval = 131072, 2065 .def = "1024", 2066 .parent = "verify", 2067 .category = FIO_OPT_C_IO, 2068 .group = FIO_OPT_G_VERIFY, 2069 }, 2070 { 2071 .name = "verify_interval", 2072 .lname = "Verify interval", 2073 .type = FIO_OPT_INT, 2074 .off1 = td_var_offset(verify_interval), 2075 .minval = 2 * sizeof(struct verify_header), 2076 .help = "Store verify buffer header every N bytes", 2077 .parent = "verify", 2078 .hide = 1, 2079 .interval = 2 * sizeof(struct verify_header), 2080 .category = FIO_OPT_C_IO, 2081 .group = FIO_OPT_G_VERIFY, 2082 }, 2083 { 2084 .name = "verify_offset", 2085 .lname = "Verify offset", 2086 .type = FIO_OPT_INT, 2087 .help = "Offset verify header location by N bytes", 2088 .off1 = td_var_offset(verify_offset), 2089 .minval = sizeof(struct verify_header), 2090 .parent = "verify", 2091 .hide = 1, 2092 .category = FIO_OPT_C_IO, 2093 .group = FIO_OPT_G_VERIFY, 2094 }, 2095 { 2096 .name = "verify_pattern", 2097 .lname = "Verify pattern", 2098 .type = FIO_OPT_STR, 2099 .cb = str_verify_pattern_cb, 2100 .help = "Fill pattern for IO buffers", 2101 .parent = "verify", 2102 .hide = 1, 2103 .category = FIO_OPT_C_IO, 2104 .group = FIO_OPT_G_VERIFY, 2105 }, 2106 { 2107 .name = "verify_fatal", 2108 .lname = "Verify fatal", 2109 .type = FIO_OPT_BOOL, 2110 .off1 = td_var_offset(verify_fatal), 2111 .def = "0", 2112 .help = "Exit on a single verify failure, don't continue", 2113 .parent = "verify", 2114 .hide = 1, 2115 .category = FIO_OPT_C_IO, 2116 .group = FIO_OPT_G_VERIFY, 2117 }, 2118 { 2119 .name = "verify_dump", 2120 .lname = "Verify dump", 2121 .type = FIO_OPT_BOOL, 2122 .off1 = td_var_offset(verify_dump), 2123 .def = "0", 2124 .help = "Dump contents of good and bad blocks on failure", 2125 .parent = "verify", 2126 .hide = 1, 2127 .category = FIO_OPT_C_IO, 2128 .group = FIO_OPT_G_VERIFY, 2129 }, 2130 { 2131 .name = "verify_async", 2132 .lname = "Verify asynchronously", 2133 .type = FIO_OPT_INT, 2134 .off1 = td_var_offset(verify_async), 2135 .def = "0", 2136 .help = "Number of async verifier threads to use", 2137 .parent = "verify", 2138 .hide = 1, 2139 .category = FIO_OPT_C_IO, 2140 .group = FIO_OPT_G_VERIFY, 2141 }, 2142 { 2143 .name = "verify_backlog", 2144 .lname = "Verify backlog", 2145 .type = FIO_OPT_STR_VAL, 2146 .off1 = td_var_offset(verify_backlog), 2147 .help = "Verify after this number of blocks are written", 2148 .parent = "verify", 2149 .hide = 1, 2150 .category = FIO_OPT_C_IO, 2151 .group = FIO_OPT_G_VERIFY, 2152 }, 2153 { 2154 .name = "verify_backlog_batch", 2155 .lname = "Verify backlog batch", 2156 .type = FIO_OPT_INT, 2157 .off1 = td_var_offset(verify_batch), 2158 .help = "Verify this number of IO blocks", 2159 .parent = "verify", 2160 .hide = 1, 2161 .category = FIO_OPT_C_IO, 2162 .group = FIO_OPT_G_VERIFY, 2163 }, 2164#ifdef FIO_HAVE_CPU_AFFINITY 2165 { 2166 .name = "verify_async_cpus", 2167 .lname = "Async verify CPUs", 2168 .type = FIO_OPT_STR, 2169 .cb = str_verify_cpus_allowed_cb, 2170 .help = "Set CPUs allowed for async verify threads", 2171 .parent = "verify_async", 2172 .hide = 1, 2173 .category = FIO_OPT_C_IO, 2174 .group = FIO_OPT_G_VERIFY, 2175 }, 2176#endif 2177 { 2178 .name = "experimental_verify", 2179 .off1 = td_var_offset(experimental_verify), 2180 .type = FIO_OPT_BOOL, 2181 .help = "Enable experimental verification", 2182 .category = FIO_OPT_C_IO, 2183 .group = FIO_OPT_G_VERIFY, 2184 }, 2185#ifdef FIO_HAVE_TRIM 2186 { 2187 .name = "trim_percentage", 2188 .lname = "Trim percentage", 2189 .type = FIO_OPT_INT, 2190 .off1 = td_var_offset(trim_percentage), 2191 .minval = 0, 2192 .maxval = 100, 2193 .help = "Number of verify blocks to discard/trim", 2194 .parent = "verify", 2195 .def = "0", 2196 .interval = 1, 2197 .hide = 1, 2198 .category = FIO_OPT_C_IO, 2199 .group = FIO_OPT_G_TRIM, 2200 }, 2201 { 2202 .name = "trim_verify_zero", 2203 .lname = "Verify trim zero", 2204 .type = FIO_OPT_BOOL, 2205 .help = "Verify that trim/discarded blocks are returned as zeroes", 2206 .off1 = td_var_offset(trim_zero), 2207 .parent = "trim_percentage", 2208 .hide = 1, 2209 .def = "1", 2210 .category = FIO_OPT_C_IO, 2211 .group = FIO_OPT_G_TRIM, 2212 }, 2213 { 2214 .name = "trim_backlog", 2215 .lname = "Trim backlog", 2216 .type = FIO_OPT_STR_VAL, 2217 .off1 = td_var_offset(trim_backlog), 2218 .help = "Trim after this number of blocks are written", 2219 .parent = "trim_percentage", 2220 .hide = 1, 2221 .interval = 1, 2222 .category = FIO_OPT_C_IO, 2223 .group = FIO_OPT_G_TRIM, 2224 }, 2225 { 2226 .name = "trim_backlog_batch", 2227 .lname = "Trim backlog batch", 2228 .type = FIO_OPT_INT, 2229 .off1 = td_var_offset(trim_batch), 2230 .help = "Trim this number of IO blocks", 2231 .parent = "trim_percentage", 2232 .hide = 1, 2233 .interval = 1, 2234 .category = FIO_OPT_C_IO, 2235 .group = FIO_OPT_G_TRIM, 2236 }, 2237#endif 2238 { 2239 .name = "write_iolog", 2240 .lname = "Write I/O log", 2241 .type = FIO_OPT_STR_STORE, 2242 .off1 = td_var_offset(write_iolog_file), 2243 .help = "Store IO pattern to file", 2244 .category = FIO_OPT_C_IO, 2245 .group = FIO_OPT_G_IOLOG, 2246 }, 2247 { 2248 .name = "read_iolog", 2249 .lname = "Read I/O log", 2250 .type = FIO_OPT_STR_STORE, 2251 .off1 = td_var_offset(read_iolog_file), 2252 .help = "Playback IO pattern from file", 2253 .category = FIO_OPT_C_IO, 2254 .group = FIO_OPT_G_IOLOG, 2255 }, 2256 { 2257 .name = "replay_no_stall", 2258 .lname = "Don't stall on replay", 2259 .type = FIO_OPT_BOOL, 2260 .off1 = td_var_offset(no_stall), 2261 .def = "0", 2262 .parent = "read_iolog", 2263 .hide = 1, 2264 .help = "Playback IO pattern file as fast as possible without stalls", 2265 .category = FIO_OPT_C_IO, 2266 .group = FIO_OPT_G_IOLOG, 2267 }, 2268 { 2269 .name = "replay_redirect", 2270 .lname = "Redirect device for replay", 2271 .type = FIO_OPT_STR_STORE, 2272 .off1 = td_var_offset(replay_redirect), 2273 .parent = "read_iolog", 2274 .hide = 1, 2275 .help = "Replay all I/O onto this device, regardless of trace device", 2276 .category = FIO_OPT_C_IO, 2277 .group = FIO_OPT_G_IOLOG, 2278 }, 2279 { 2280 .name = "exec_prerun", 2281 .lname = "Pre-execute runnable", 2282 .type = FIO_OPT_STR_STORE, 2283 .off1 = td_var_offset(exec_prerun), 2284 .help = "Execute this file prior to running job", 2285 .category = FIO_OPT_C_GENERAL, 2286 .group = FIO_OPT_G_INVALID, 2287 }, 2288 { 2289 .name = "exec_postrun", 2290 .lname = "Post-execute runnable", 2291 .type = FIO_OPT_STR_STORE, 2292 .off1 = td_var_offset(exec_postrun), 2293 .help = "Execute this file after running job", 2294 .category = FIO_OPT_C_GENERAL, 2295 .group = FIO_OPT_G_INVALID, 2296 }, 2297#ifdef FIO_HAVE_IOSCHED_SWITCH 2298 { 2299 .name = "ioscheduler", 2300 .lname = "I/O scheduler", 2301 .type = FIO_OPT_STR_STORE, 2302 .off1 = td_var_offset(ioscheduler), 2303 .help = "Use this IO scheduler on the backing device", 2304 .category = FIO_OPT_C_FILE, 2305 .group = FIO_OPT_G_INVALID, 2306 }, 2307#endif 2308 { 2309 .name = "zonesize", 2310 .lname = "Zone size", 2311 .type = FIO_OPT_STR_VAL, 2312 .off1 = td_var_offset(zone_size), 2313 .help = "Amount of data to read per zone", 2314 .def = "0", 2315 .interval = 1024 * 1024, 2316 .category = FIO_OPT_C_IO, 2317 .group = FIO_OPT_G_ZONE, 2318 }, 2319 { 2320 .name = "zonerange", 2321 .lname = "Zone range", 2322 .type = FIO_OPT_STR_VAL, 2323 .off1 = td_var_offset(zone_range), 2324 .help = "Give size of an IO zone", 2325 .def = "0", 2326 .interval = 1024 * 1024, 2327 .category = FIO_OPT_C_IO, 2328 .group = FIO_OPT_G_ZONE, 2329 }, 2330 { 2331 .name = "zoneskip", 2332 .lname = "Zone skip", 2333 .type = FIO_OPT_STR_VAL, 2334 .off1 = td_var_offset(zone_skip), 2335 .help = "Space between IO zones", 2336 .def = "0", 2337 .interval = 1024 * 1024, 2338 .category = FIO_OPT_C_IO, 2339 .group = FIO_OPT_G_ZONE, 2340 }, 2341 { 2342 .name = "lockmem", 2343 .lname = "Lock memory", 2344 .type = FIO_OPT_STR_VAL, 2345 .off1 = td_var_offset(lockmem), 2346 .help = "Lock down this amount of memory", 2347 .def = "0", 2348 .interval = 1024 * 1024, 2349 .category = FIO_OPT_C_GENERAL, 2350 .group = FIO_OPT_G_INVALID, 2351 }, 2352 { 2353 .name = "rwmixread", 2354 .lname = "Read/write mix read", 2355 .type = FIO_OPT_INT, 2356 .cb = str_rwmix_read_cb, 2357 .maxval = 100, 2358 .help = "Percentage of mixed workload that is reads", 2359 .def = "50", 2360 .interval = 5, 2361 .inverse = "rwmixwrite", 2362 .category = FIO_OPT_C_IO, 2363 .group = FIO_OPT_G_RWMIX, 2364 }, 2365 { 2366 .name = "rwmixwrite", 2367 .lname = "Read/write mix write", 2368 .type = FIO_OPT_INT, 2369 .cb = str_rwmix_write_cb, 2370 .maxval = 100, 2371 .help = "Percentage of mixed workload that is writes", 2372 .def = "50", 2373 .interval = 5, 2374 .inverse = "rwmixread", 2375 .category = FIO_OPT_C_IO, 2376 .group = FIO_OPT_G_RWMIX, 2377 }, 2378 { 2379 .name = "rwmixcycle", 2380 .lname = "Read/write mix cycle", 2381 .type = FIO_OPT_DEPRECATED, 2382 .category = FIO_OPT_C_IO, 2383 .group = FIO_OPT_G_RWMIX, 2384 }, 2385 { 2386 .name = "nice", 2387 .lname = "Nice", 2388 .type = FIO_OPT_INT, 2389 .off1 = td_var_offset(nice), 2390 .help = "Set job CPU nice value", 2391 .minval = -19, 2392 .maxval = 20, 2393 .def = "0", 2394 .interval = 1, 2395 .category = FIO_OPT_C_GENERAL, 2396 .group = FIO_OPT_G_CRED, 2397 }, 2398#ifdef FIO_HAVE_IOPRIO 2399 { 2400 .name = "prio", 2401 .lname = "I/O nice priority", 2402 .type = FIO_OPT_INT, 2403 .off1 = td_var_offset(ioprio), 2404 .help = "Set job IO priority value", 2405 .minval = 0, 2406 .maxval = 7, 2407 .interval = 1, 2408 .category = FIO_OPT_C_GENERAL, 2409 .group = FIO_OPT_G_CRED, 2410 }, 2411 { 2412 .name = "prioclass", 2413 .lname = "I/O nice priority class", 2414 .type = FIO_OPT_INT, 2415 .off1 = td_var_offset(ioprio_class), 2416 .help = "Set job IO priority class", 2417 .minval = 0, 2418 .maxval = 3, 2419 .interval = 1, 2420 .category = FIO_OPT_C_GENERAL, 2421 .group = FIO_OPT_G_CRED, 2422 }, 2423#endif 2424 { 2425 .name = "thinktime", 2426 .lname = "Thinktime", 2427 .type = FIO_OPT_INT, 2428 .off1 = td_var_offset(thinktime), 2429 .help = "Idle time between IO buffers (usec)", 2430 .def = "0", 2431 .category = FIO_OPT_C_IO, 2432 .group = FIO_OPT_G_THINKTIME, 2433 }, 2434 { 2435 .name = "thinktime_spin", 2436 .lname = "Thinktime spin", 2437 .type = FIO_OPT_INT, 2438 .off1 = td_var_offset(thinktime_spin), 2439 .help = "Start think time by spinning this amount (usec)", 2440 .def = "0", 2441 .parent = "thinktime", 2442 .hide = 1, 2443 .category = FIO_OPT_C_IO, 2444 .group = FIO_OPT_G_THINKTIME, 2445 }, 2446 { 2447 .name = "thinktime_blocks", 2448 .lname = "Thinktime blocks", 2449 .type = FIO_OPT_INT, 2450 .off1 = td_var_offset(thinktime_blocks), 2451 .help = "IO buffer period between 'thinktime'", 2452 .def = "1", 2453 .parent = "thinktime", 2454 .hide = 1, 2455 .category = FIO_OPT_C_IO, 2456 .group = FIO_OPT_G_THINKTIME, 2457 }, 2458 { 2459 .name = "rate", 2460 .lname = "I/O rate", 2461 .type = FIO_OPT_INT, 2462 .off1 = td_var_offset(rate[DDIR_READ]), 2463 .off2 = td_var_offset(rate[DDIR_WRITE]), 2464 .off3 = td_var_offset(rate[DDIR_TRIM]), 2465 .help = "Set bandwidth rate", 2466 .category = FIO_OPT_C_IO, 2467 .group = FIO_OPT_G_RATE, 2468 }, 2469 { 2470 .name = "ratemin", 2471 .lname = "I/O min rate", 2472 .type = FIO_OPT_INT, 2473 .off1 = td_var_offset(ratemin[DDIR_READ]), 2474 .off2 = td_var_offset(ratemin[DDIR_WRITE]), 2475 .off3 = td_var_offset(ratemin[DDIR_TRIM]), 2476 .help = "Job must meet this rate or it will be shutdown", 2477 .parent = "rate", 2478 .hide = 1, 2479 .category = FIO_OPT_C_IO, 2480 .group = FIO_OPT_G_RATE, 2481 }, 2482 { 2483 .name = "rate_iops", 2484 .lname = "I/O rate IOPS", 2485 .type = FIO_OPT_INT, 2486 .off1 = td_var_offset(rate_iops[DDIR_READ]), 2487 .off2 = td_var_offset(rate_iops[DDIR_WRITE]), 2488 .off3 = td_var_offset(rate_iops[DDIR_TRIM]), 2489 .help = "Limit IO used to this number of IO operations/sec", 2490 .hide = 1, 2491 .category = FIO_OPT_C_IO, 2492 .group = FIO_OPT_G_RATE, 2493 }, 2494 { 2495 .name = "rate_iops_min", 2496 .lname = "I/O min rate IOPS", 2497 .type = FIO_OPT_INT, 2498 .off1 = td_var_offset(rate_iops_min[DDIR_READ]), 2499 .off2 = td_var_offset(rate_iops_min[DDIR_WRITE]), 2500 .off3 = td_var_offset(rate_iops_min[DDIR_TRIM]), 2501 .help = "Job must meet this rate or it will be shut down", 2502 .parent = "rate_iops", 2503 .hide = 1, 2504 .category = FIO_OPT_C_IO, 2505 .group = FIO_OPT_G_RATE, 2506 }, 2507 { 2508 .name = "ratecycle", 2509 .lname = "I/O rate cycle", 2510 .type = FIO_OPT_INT, 2511 .off1 = td_var_offset(ratecycle), 2512 .help = "Window average for rate limits (msec)", 2513 .def = "1000", 2514 .parent = "rate", 2515 .hide = 1, 2516 .category = FIO_OPT_C_IO, 2517 .group = FIO_OPT_G_RATE, 2518 }, 2519 { 2520 .name = "max_latency", 2521 .type = FIO_OPT_INT, 2522 .off1 = td_var_offset(max_latency), 2523 .help = "Maximum tolerated IO latency (usec)", 2524 .category = FIO_OPT_C_IO, 2525 .group = FIO_OPT_G_RATE, 2526 }, 2527 { 2528 .name = "invalidate", 2529 .lname = "Cache invalidate", 2530 .type = FIO_OPT_BOOL, 2531 .off1 = td_var_offset(invalidate_cache), 2532 .help = "Invalidate buffer/page cache prior to running job", 2533 .def = "1", 2534 .category = FIO_OPT_C_IO, 2535 .group = FIO_OPT_G_IO_TYPE, 2536 }, 2537 { 2538 .name = "sync", 2539 .lname = "Synchronous I/O", 2540 .type = FIO_OPT_BOOL, 2541 .off1 = td_var_offset(sync_io), 2542 .help = "Use O_SYNC for buffered writes", 2543 .def = "0", 2544 .parent = "buffered", 2545 .hide = 1, 2546 .category = FIO_OPT_C_IO, 2547 .group = FIO_OPT_G_IO_TYPE, 2548 }, 2549 { 2550 .name = "create_serialize", 2551 .lname = "Create serialize", 2552 .type = FIO_OPT_BOOL, 2553 .off1 = td_var_offset(create_serialize), 2554 .help = "Serialize creating of job files", 2555 .def = "1", 2556 .category = FIO_OPT_C_FILE, 2557 .group = FIO_OPT_G_INVALID, 2558 }, 2559 { 2560 .name = "create_fsync", 2561 .lname = "Create fsync", 2562 .type = FIO_OPT_BOOL, 2563 .off1 = td_var_offset(create_fsync), 2564 .help = "fsync file after creation", 2565 .def = "1", 2566 .category = FIO_OPT_C_FILE, 2567 .group = FIO_OPT_G_INVALID, 2568 }, 2569 { 2570 .name = "create_on_open", 2571 .lname = "Create on open", 2572 .type = FIO_OPT_BOOL, 2573 .off1 = td_var_offset(create_on_open), 2574 .help = "Create files when they are opened for IO", 2575 .def = "0", 2576 .category = FIO_OPT_C_FILE, 2577 .group = FIO_OPT_G_INVALID, 2578 }, 2579 { 2580 .name = "create_only", 2581 .type = FIO_OPT_BOOL, 2582 .off1 = td_var_offset(create_only), 2583 .help = "Only perform file creation phase", 2584 .category = FIO_OPT_C_FILE, 2585 .def = "0", 2586 }, 2587 { 2588 .name = "pre_read", 2589 .lname = "Pre-read files", 2590 .type = FIO_OPT_BOOL, 2591 .off1 = td_var_offset(pre_read), 2592 .help = "Pre-read files before starting official testing", 2593 .def = "0", 2594 .category = FIO_OPT_C_FILE, 2595 .group = FIO_OPT_G_INVALID, 2596 }, 2597#ifdef FIO_HAVE_CPU_AFFINITY 2598 { 2599 .name = "cpumask", 2600 .lname = "CPU mask", 2601 .type = FIO_OPT_INT, 2602 .cb = str_cpumask_cb, 2603 .help = "CPU affinity mask", 2604 .category = FIO_OPT_C_GENERAL, 2605 .group = FIO_OPT_G_CRED, 2606 }, 2607 { 2608 .name = "cpus_allowed", 2609 .lname = "CPUs allowed", 2610 .type = FIO_OPT_STR, 2611 .cb = str_cpus_allowed_cb, 2612 .help = "Set CPUs allowed", 2613 .category = FIO_OPT_C_GENERAL, 2614 .group = FIO_OPT_G_CRED, 2615 }, 2616#endif 2617#ifdef CONFIG_LIBNUMA 2618 { 2619 .name = "numa_cpu_nodes", 2620 .type = FIO_OPT_STR, 2621 .cb = str_numa_cpunodes_cb, 2622 .help = "NUMA CPU nodes bind", 2623 }, 2624 { 2625 .name = "numa_mem_policy", 2626 .type = FIO_OPT_STR, 2627 .cb = str_numa_mpol_cb, 2628 .help = "NUMA memory policy setup", 2629 }, 2630#endif 2631 { 2632 .name = "end_fsync", 2633 .lname = "End fsync", 2634 .type = FIO_OPT_BOOL, 2635 .off1 = td_var_offset(end_fsync), 2636 .help = "Include fsync at the end of job", 2637 .def = "0", 2638 .category = FIO_OPT_C_FILE, 2639 .group = FIO_OPT_G_INVALID, 2640 }, 2641 { 2642 .name = "fsync_on_close", 2643 .lname = "Fsync on close", 2644 .type = FIO_OPT_BOOL, 2645 .off1 = td_var_offset(fsync_on_close), 2646 .help = "fsync files on close", 2647 .def = "0", 2648 .category = FIO_OPT_C_FILE, 2649 .group = FIO_OPT_G_INVALID, 2650 }, 2651 { 2652 .name = "unlink", 2653 .lname = "Unlink file", 2654 .type = FIO_OPT_BOOL, 2655 .off1 = td_var_offset(unlink), 2656 .help = "Unlink created files after job has completed", 2657 .def = "0", 2658 .category = FIO_OPT_C_FILE, 2659 .group = FIO_OPT_G_INVALID, 2660 }, 2661 { 2662 .name = "exitall", 2663 .lname = "Exit-all on terminate", 2664 .type = FIO_OPT_STR_SET, 2665 .cb = str_exitall_cb, 2666 .help = "Terminate all jobs when one exits", 2667 .category = FIO_OPT_C_GENERAL, 2668 .group = FIO_OPT_G_PROCESS, 2669 }, 2670 { 2671 .name = "stonewall", 2672 .lname = "Wait for previous", 2673 .alias = "wait_for_previous", 2674 .type = FIO_OPT_STR_SET, 2675 .off1 = td_var_offset(stonewall), 2676 .help = "Insert a hard barrier between this job and previous", 2677 .category = FIO_OPT_C_GENERAL, 2678 .group = FIO_OPT_G_PROCESS, 2679 }, 2680 { 2681 .name = "new_group", 2682 .lname = "New group", 2683 .type = FIO_OPT_STR_SET, 2684 .off1 = td_var_offset(new_group), 2685 .help = "Mark the start of a new group (for reporting)", 2686 .category = FIO_OPT_C_GENERAL, 2687 .group = FIO_OPT_G_PROCESS, 2688 }, 2689 { 2690 .name = "thread", 2691 .lname = "Thread", 2692 .type = FIO_OPT_STR_SET, 2693 .off1 = td_var_offset(use_thread), 2694 .help = "Use threads instead of processes", 2695 .category = FIO_OPT_C_GENERAL, 2696 .group = FIO_OPT_G_PROCESS, 2697 }, 2698 { 2699 .name = "write_bw_log", 2700 .lname = "Write bandwidth log", 2701 .type = FIO_OPT_STR_STORE, 2702 .off1 = td_var_offset(bw_log_file), 2703 .help = "Write log of bandwidth during run", 2704 .category = FIO_OPT_C_LOG, 2705 .group = FIO_OPT_G_INVALID, 2706 }, 2707 { 2708 .name = "write_lat_log", 2709 .lname = "Write latency log", 2710 .type = FIO_OPT_STR_STORE, 2711 .off1 = td_var_offset(lat_log_file), 2712 .help = "Write log of latency during run", 2713 .category = FIO_OPT_C_LOG, 2714 .group = FIO_OPT_G_INVALID, 2715 }, 2716 { 2717 .name = "write_iops_log", 2718 .lname = "Write IOPS log", 2719 .type = FIO_OPT_STR, 2720 .off1 = td_var_offset(iops_log_file), 2721 .help = "Write log of IOPS during run", 2722 .category = FIO_OPT_C_LOG, 2723 .group = FIO_OPT_G_INVALID, 2724 }, 2725 { 2726 .name = "log_avg_msec", 2727 .lname = "Log averaging (msec)", 2728 .type = FIO_OPT_INT, 2729 .off1 = td_var_offset(log_avg_msec), 2730 .help = "Average bw/iops/lat logs over this period of time", 2731 .def = "0", 2732 .category = FIO_OPT_C_LOG, 2733 .group = FIO_OPT_G_INVALID, 2734 }, 2735 { 2736 .name = "bwavgtime", 2737 .lname = "Bandwidth average time", 2738 .type = FIO_OPT_INT, 2739 .off1 = td_var_offset(bw_avg_time), 2740 .help = "Time window over which to calculate bandwidth" 2741 " (msec)", 2742 .def = "500", 2743 .parent = "write_bw_log", 2744 .hide = 1, 2745 .interval = 100, 2746 .category = FIO_OPT_C_LOG, 2747 .group = FIO_OPT_G_INVALID, 2748 }, 2749 { 2750 .name = "iopsavgtime", 2751 .lname = "IOPS average time", 2752 .type = FIO_OPT_INT, 2753 .off1 = td_var_offset(iops_avg_time), 2754 .help = "Time window over which to calculate IOPS (msec)", 2755 .def = "500", 2756 .parent = "write_iops_log", 2757 .hide = 1, 2758 .interval = 100, 2759 .category = FIO_OPT_C_LOG, 2760 .group = FIO_OPT_G_INVALID, 2761 }, 2762 { 2763 .name = "group_reporting", 2764 .lname = "Group reporting", 2765 .type = FIO_OPT_BOOL, 2766 .off1 = td_var_offset(group_reporting), 2767 .help = "Do reporting on a per-group basis", 2768 .def = "1", 2769 .category = FIO_OPT_C_STAT, 2770 .group = FIO_OPT_G_INVALID, 2771 }, 2772 { 2773 .name = "zero_buffers", 2774 .lname = "Zero I/O buffers", 2775 .type = FIO_OPT_STR_SET, 2776 .off1 = td_var_offset(zero_buffers), 2777 .help = "Init IO buffers to all zeroes", 2778 .category = FIO_OPT_C_IO, 2779 .group = FIO_OPT_G_IO_BUF, 2780 }, 2781 { 2782 .name = "refill_buffers", 2783 .lname = "Refill I/O buffers", 2784 .type = FIO_OPT_STR_SET, 2785 .off1 = td_var_offset(refill_buffers), 2786 .help = "Refill IO buffers on every IO submit", 2787 .category = FIO_OPT_C_IO, 2788 .group = FIO_OPT_G_IO_BUF, 2789 }, 2790 { 2791 .name = "scramble_buffers", 2792 .lname = "Scramble I/O buffers", 2793 .type = FIO_OPT_BOOL, 2794 .off1 = td_var_offset(scramble_buffers), 2795 .help = "Slightly scramble buffers on every IO submit", 2796 .def = "1", 2797 .category = FIO_OPT_C_IO, 2798 .group = FIO_OPT_G_IO_BUF, 2799 }, 2800 { 2801 .name = "buffer_compress_percentage", 2802 .lname = "Buffer compression percentage", 2803 .type = FIO_OPT_INT, 2804 .off1 = td_var_offset(compress_percentage), 2805 .maxval = 100, 2806 .minval = 1, 2807 .help = "How compressible the buffer is (approximately)", 2808 .interval = 5, 2809 .category = FIO_OPT_C_IO, 2810 .group = FIO_OPT_G_IO_BUF, 2811 }, 2812 { 2813 .name = "buffer_compress_chunk", 2814 .lname = "Buffer compression chunk size", 2815 .type = FIO_OPT_INT, 2816 .off1 = td_var_offset(compress_chunk), 2817 .parent = "buffer_compress_percentage", 2818 .hide = 1, 2819 .help = "Size of compressible region in buffer", 2820 .interval = 256, 2821 .category = FIO_OPT_C_IO, 2822 .group = FIO_OPT_G_IO_BUF, 2823 }, 2824 { 2825 .name = "clat_percentiles", 2826 .lname = "Completion latency percentiles", 2827 .type = FIO_OPT_BOOL, 2828 .off1 = td_var_offset(clat_percentiles), 2829 .help = "Enable the reporting of completion latency percentiles", 2830 .def = "1", 2831 .category = FIO_OPT_C_STAT, 2832 .group = FIO_OPT_G_INVALID, 2833 }, 2834 { 2835 .name = "percentile_list", 2836 .lname = "Completion latency percentile list", 2837 .type = FIO_OPT_FLOAT_LIST, 2838 .off1 = td_var_offset(percentile_list), 2839 .off2 = td_var_offset(percentile_precision), 2840 .help = "Specify a custom list of percentiles to report", 2841 .def = "1:5:10:20:30:40:50:60:70:80:90:95:99:99.5:99.9:99.95:99.99", 2842 .maxlen = FIO_IO_U_LIST_MAX_LEN, 2843 .minfp = 0.0, 2844 .maxfp = 100.0, 2845 .category = FIO_OPT_C_STAT, 2846 .group = FIO_OPT_G_INVALID, 2847 }, 2848 2849#ifdef FIO_HAVE_DISK_UTIL 2850 { 2851 .name = "disk_util", 2852 .lname = "Disk utilization", 2853 .type = FIO_OPT_BOOL, 2854 .off1 = td_var_offset(do_disk_util), 2855 .help = "Log disk utilization statistics", 2856 .def = "1", 2857 .category = FIO_OPT_C_STAT, 2858 .group = FIO_OPT_G_INVALID, 2859 }, 2860#endif 2861 { 2862 .name = "gtod_reduce", 2863 .lname = "Reduce gettimeofday() calls", 2864 .type = FIO_OPT_BOOL, 2865 .help = "Greatly reduce number of gettimeofday() calls", 2866 .cb = str_gtod_reduce_cb, 2867 .def = "0", 2868 .hide_on_set = 1, 2869 .category = FIO_OPT_C_STAT, 2870 .group = FIO_OPT_G_INVALID, 2871 }, 2872 { 2873 .name = "disable_lat", 2874 .lname = "Disable all latency stats", 2875 .type = FIO_OPT_BOOL, 2876 .off1 = td_var_offset(disable_lat), 2877 .help = "Disable latency numbers", 2878 .parent = "gtod_reduce", 2879 .hide = 1, 2880 .def = "0", 2881 .category = FIO_OPT_C_STAT, 2882 .group = FIO_OPT_G_INVALID, 2883 }, 2884 { 2885 .name = "disable_clat", 2886 .lname = "Disable completion latency stats", 2887 .type = FIO_OPT_BOOL, 2888 .off1 = td_var_offset(disable_clat), 2889 .help = "Disable completion latency numbers", 2890 .parent = "gtod_reduce", 2891 .hide = 1, 2892 .def = "0", 2893 .category = FIO_OPT_C_STAT, 2894 .group = FIO_OPT_G_INVALID, 2895 }, 2896 { 2897 .name = "disable_slat", 2898 .lname = "Disable submission latency stats", 2899 .type = FIO_OPT_BOOL, 2900 .off1 = td_var_offset(disable_slat), 2901 .help = "Disable submission latency numbers", 2902 .parent = "gtod_reduce", 2903 .hide = 1, 2904 .def = "0", 2905 .category = FIO_OPT_C_STAT, 2906 .group = FIO_OPT_G_INVALID, 2907 }, 2908 { 2909 .name = "disable_bw_measurement", 2910 .lname = "Disable bandwidth stats", 2911 .type = FIO_OPT_BOOL, 2912 .off1 = td_var_offset(disable_bw), 2913 .help = "Disable bandwidth logging", 2914 .parent = "gtod_reduce", 2915 .hide = 1, 2916 .def = "0", 2917 .category = FIO_OPT_C_STAT, 2918 .group = FIO_OPT_G_INVALID, 2919 }, 2920 { 2921 .name = "gtod_cpu", 2922 .lname = "Dedicated gettimeofday() CPU", 2923 .type = FIO_OPT_INT, 2924 .cb = str_gtod_cpu_cb, 2925 .help = "Set up dedicated gettimeofday() thread on this CPU", 2926 .verify = gtod_cpu_verify, 2927 .category = FIO_OPT_C_GENERAL, 2928 .group = FIO_OPT_G_CLOCK, 2929 }, 2930 { 2931 .name = "unified_rw_reporting", 2932 .type = FIO_OPT_BOOL, 2933 .off1 = td_var_offset(unified_rw_rep), 2934 .help = "Unify reporting across data direction", 2935 .def = "0", 2936 .category = FIO_OPT_C_GENERAL, 2937 .group = FIO_OPT_G_INVALID, 2938 }, 2939 { 2940 .name = "continue_on_error", 2941 .lname = "Continue on error", 2942 .type = FIO_OPT_STR, 2943 .off1 = td_var_offset(continue_on_error), 2944 .help = "Continue on non-fatal errors during IO", 2945 .def = "none", 2946 .category = FIO_OPT_C_GENERAL, 2947 .group = FIO_OPT_G_ERR, 2948 .posval = { 2949 { .ival = "none", 2950 .oval = ERROR_TYPE_NONE, 2951 .help = "Exit when an error is encountered", 2952 }, 2953 { .ival = "read", 2954 .oval = ERROR_TYPE_READ, 2955 .help = "Continue on read errors only", 2956 }, 2957 { .ival = "write", 2958 .oval = ERROR_TYPE_WRITE, 2959 .help = "Continue on write errors only", 2960 }, 2961 { .ival = "io", 2962 .oval = ERROR_TYPE_READ | ERROR_TYPE_WRITE, 2963 .help = "Continue on any IO errors", 2964 }, 2965 { .ival = "verify", 2966 .oval = ERROR_TYPE_VERIFY, 2967 .help = "Continue on verify errors only", 2968 }, 2969 { .ival = "all", 2970 .oval = ERROR_TYPE_ANY, 2971 .help = "Continue on all io and verify errors", 2972 }, 2973 { .ival = "0", 2974 .oval = ERROR_TYPE_NONE, 2975 .help = "Alias for 'none'", 2976 }, 2977 { .ival = "1", 2978 .oval = ERROR_TYPE_ANY, 2979 .help = "Alias for 'all'", 2980 }, 2981 }, 2982 }, 2983 { 2984 .name = "ignore_error", 2985 .type = FIO_OPT_STR, 2986 .cb = str_ignore_error_cb, 2987 .help = "Set a specific list of errors to ignore", 2988 .parent = "rw", 2989 .category = FIO_OPT_C_GENERAL, 2990 .group = FIO_OPT_G_ERR, 2991 }, 2992 { 2993 .name = "error_dump", 2994 .type = FIO_OPT_BOOL, 2995 .off1 = td_var_offset(error_dump), 2996 .def = "0", 2997 .help = "Dump info on each error", 2998 .category = FIO_OPT_C_GENERAL, 2999 .group = FIO_OPT_G_ERR, 3000 }, 3001 { 3002 .name = "profile", 3003 .lname = "Profile", 3004 .type = FIO_OPT_STR_STORE, 3005 .off1 = td_var_offset(profile), 3006 .help = "Select a specific builtin performance test", 3007 .category = FIO_OPT_C_PROFILE, 3008 .group = FIO_OPT_G_INVALID, 3009 }, 3010 { 3011 .name = "cgroup", 3012 .lname = "Cgroup", 3013 .type = FIO_OPT_STR_STORE, 3014 .off1 = td_var_offset(cgroup), 3015 .help = "Add job to cgroup of this name", 3016 .category = FIO_OPT_C_GENERAL, 3017 .group = FIO_OPT_G_CGROUP, 3018 }, 3019 { 3020 .name = "cgroup_nodelete", 3021 .lname = "Cgroup no-delete", 3022 .type = FIO_OPT_BOOL, 3023 .off1 = td_var_offset(cgroup_nodelete), 3024 .help = "Do not delete cgroups after job completion", 3025 .def = "0", 3026 .parent = "cgroup", 3027 .category = FIO_OPT_C_GENERAL, 3028 .group = FIO_OPT_G_CGROUP, 3029 }, 3030 { 3031 .name = "cgroup_weight", 3032 .lname = "Cgroup weight", 3033 .type = FIO_OPT_INT, 3034 .off1 = td_var_offset(cgroup_weight), 3035 .help = "Use given weight for cgroup", 3036 .minval = 100, 3037 .maxval = 1000, 3038 .parent = "cgroup", 3039 .category = FIO_OPT_C_GENERAL, 3040 .group = FIO_OPT_G_CGROUP, 3041 }, 3042 { 3043 .name = "uid", 3044 .lname = "User ID", 3045 .type = FIO_OPT_INT, 3046 .off1 = td_var_offset(uid), 3047 .help = "Run job with this user ID", 3048 .category = FIO_OPT_C_GENERAL, 3049 .group = FIO_OPT_G_CRED, 3050 }, 3051 { 3052 .name = "gid", 3053 .lname = "Group ID", 3054 .type = FIO_OPT_INT, 3055 .off1 = td_var_offset(gid), 3056 .help = "Run job with this group ID", 3057 .category = FIO_OPT_C_GENERAL, 3058 .group = FIO_OPT_G_CRED, 3059 }, 3060 { 3061 .name = "kb_base", 3062 .lname = "KB Base", 3063 .type = FIO_OPT_INT, 3064 .off1 = td_var_offset(kb_base), 3065 .verify = kb_base_verify, 3066 .prio = 1, 3067 .def = "1024", 3068 .help = "How many bytes per KB for reporting (1000 or 1024)", 3069 .category = FIO_OPT_C_GENERAL, 3070 .group = FIO_OPT_G_INVALID, 3071 }, 3072 { 3073 .name = "hugepage-size", 3074 .lname = "Hugepage size", 3075 .type = FIO_OPT_INT, 3076 .off1 = td_var_offset(hugepage_size), 3077 .help = "When using hugepages, specify size of each page", 3078 .def = __fio_stringify(FIO_HUGE_PAGE), 3079 .interval = 1024 * 1024, 3080 .category = FIO_OPT_C_GENERAL, 3081 .group = FIO_OPT_G_INVALID, 3082 }, 3083 { 3084 .name = "flow_id", 3085 .lname = "I/O flow ID", 3086 .type = FIO_OPT_INT, 3087 .off1 = td_var_offset(flow_id), 3088 .help = "The flow index ID to use", 3089 .def = "0", 3090 .category = FIO_OPT_C_IO, 3091 .group = FIO_OPT_G_IO_FLOW, 3092 }, 3093 { 3094 .name = "flow", 3095 .lname = "I/O flow weight", 3096 .type = FIO_OPT_INT, 3097 .off1 = td_var_offset(flow), 3098 .help = "Weight for flow control of this job", 3099 .parent = "flow_id", 3100 .hide = 1, 3101 .def = "0", 3102 .category = FIO_OPT_C_IO, 3103 .group = FIO_OPT_G_IO_FLOW, 3104 }, 3105 { 3106 .name = "flow_watermark", 3107 .lname = "I/O flow watermark", 3108 .type = FIO_OPT_INT, 3109 .off1 = td_var_offset(flow_watermark), 3110 .help = "High watermark for flow control. This option" 3111 " should be set to the same value for all threads" 3112 " with non-zero flow.", 3113 .parent = "flow_id", 3114 .hide = 1, 3115 .def = "1024", 3116 .category = FIO_OPT_C_IO, 3117 .group = FIO_OPT_G_IO_FLOW, 3118 }, 3119 { 3120 .name = "flow_sleep", 3121 .lname = "I/O flow sleep", 3122 .type = FIO_OPT_INT, 3123 .off1 = td_var_offset(flow_sleep), 3124 .help = "How many microseconds to sleep after being held" 3125 " back by the flow control mechanism", 3126 .parent = "flow_id", 3127 .hide = 1, 3128 .def = "0", 3129 .category = FIO_OPT_C_IO, 3130 .group = FIO_OPT_G_IO_FLOW, 3131 }, 3132 { 3133 .name = NULL, 3134 }, 3135}; 3136 3137static void add_to_lopt(struct option *lopt, struct fio_option *o, 3138 const char *name, int val) 3139{ 3140 lopt->name = (char *) name; 3141 lopt->val = val; 3142 if (o->type == FIO_OPT_STR_SET) 3143 lopt->has_arg = no_argument; 3144 else 3145 lopt->has_arg = required_argument; 3146} 3147 3148static void options_to_lopts(struct fio_option *opts, 3149 struct option *long_options, 3150 int i, int option_type) 3151{ 3152 struct fio_option *o = &opts[0]; 3153 while (o->name) { 3154 add_to_lopt(&long_options[i], o, o->name, option_type); 3155 if (o->alias) { 3156 i++; 3157 add_to_lopt(&long_options[i], o, o->alias, option_type); 3158 } 3159 3160 i++; 3161 o++; 3162 assert(i < FIO_NR_OPTIONS); 3163 } 3164} 3165 3166void fio_options_set_ioengine_opts(struct option *long_options, 3167 struct thread_data *td) 3168{ 3169 unsigned int i; 3170 3171 i = 0; 3172 while (long_options[i].name) { 3173 if (long_options[i].val == FIO_GETOPT_IOENGINE) { 3174 memset(&long_options[i], 0, sizeof(*long_options)); 3175 break; 3176 } 3177 i++; 3178 } 3179 3180 /* 3181 * Just clear out the prior ioengine options. 3182 */ 3183 if (!td || !td->eo) 3184 return; 3185 3186 options_to_lopts(td->io_ops->options, long_options, i, 3187 FIO_GETOPT_IOENGINE); 3188} 3189 3190void fio_options_dup_and_init(struct option *long_options) 3191{ 3192 unsigned int i; 3193 3194 options_init(fio_options); 3195 3196 i = 0; 3197 while (long_options[i].name) 3198 i++; 3199 3200 options_to_lopts(fio_options, long_options, i, FIO_GETOPT_JOB); 3201} 3202 3203struct fio_keyword { 3204 const char *word; 3205 const char *desc; 3206 char *replace; 3207}; 3208 3209static struct fio_keyword fio_keywords[] = { 3210 { 3211 .word = "$pagesize", 3212 .desc = "Page size in the system", 3213 }, 3214 { 3215 .word = "$mb_memory", 3216 .desc = "Megabytes of memory online", 3217 }, 3218 { 3219 .word = "$ncpus", 3220 .desc = "Number of CPUs online in the system", 3221 }, 3222 { 3223 .word = NULL, 3224 }, 3225}; 3226 3227void fio_keywords_init(void) 3228{ 3229 unsigned long long mb_memory; 3230 char buf[128]; 3231 long l; 3232 3233 sprintf(buf, "%lu", (unsigned long) page_size); 3234 fio_keywords[0].replace = strdup(buf); 3235 3236 mb_memory = os_phys_mem() / (1024 * 1024); 3237 sprintf(buf, "%llu", mb_memory); 3238 fio_keywords[1].replace = strdup(buf); 3239 3240 l = cpus_online(); 3241 sprintf(buf, "%lu", l); 3242 fio_keywords[2].replace = strdup(buf); 3243} 3244 3245#define BC_APP "bc" 3246 3247static char *bc_calc(char *str) 3248{ 3249 char buf[128], *tmp; 3250 FILE *f; 3251 int ret; 3252 3253 /* 3254 * No math, just return string 3255 */ 3256 if ((!strchr(str, '+') && !strchr(str, '-') && !strchr(str, '*') && 3257 !strchr(str, '/')) || strchr(str, '\'')) 3258 return str; 3259 3260 /* 3261 * Split option from value, we only need to calculate the value 3262 */ 3263 tmp = strchr(str, '='); 3264 if (!tmp) 3265 return str; 3266 3267 tmp++; 3268 3269 /* 3270 * Prevent buffer overflows; such a case isn't reasonable anyway 3271 */ 3272 if (strlen(str) >= 128 || strlen(tmp) > 100) 3273 return str; 3274 3275 sprintf(buf, "which %s > /dev/null", BC_APP); 3276 if (system(buf)) { 3277 log_err("fio: bc is needed for performing math\n"); 3278 return NULL; 3279 } 3280 3281 sprintf(buf, "echo '%s' | %s", tmp, BC_APP); 3282 f = popen(buf, "r"); 3283 if (!f) 3284 return NULL; 3285 3286 ret = fread(&buf[tmp - str], 1, 128 - (tmp - str), f); 3287 if (ret <= 0) 3288 return NULL; 3289 3290 pclose(f); 3291 buf[(tmp - str) + ret - 1] = '\0'; 3292 memcpy(buf, str, tmp - str); 3293 free(str); 3294 return strdup(buf); 3295} 3296 3297/* 3298 * Return a copy of the input string with substrings of the form ${VARNAME} 3299 * substituted with the value of the environment variable VARNAME. The 3300 * substitution always occurs, even if VARNAME is empty or the corresponding 3301 * environment variable undefined. 3302 */ 3303static char *option_dup_subs(const char *opt) 3304{ 3305 char out[OPT_LEN_MAX+1]; 3306 char in[OPT_LEN_MAX+1]; 3307 char *outptr = out; 3308 char *inptr = in; 3309 char *ch1, *ch2, *env; 3310 ssize_t nchr = OPT_LEN_MAX; 3311 size_t envlen; 3312 3313 if (strlen(opt) + 1 > OPT_LEN_MAX) { 3314 log_err("OPT_LEN_MAX (%d) is too small\n", OPT_LEN_MAX); 3315 return NULL; 3316 } 3317 3318 in[OPT_LEN_MAX] = '\0'; 3319 strncpy(in, opt, OPT_LEN_MAX); 3320 3321 while (*inptr && nchr > 0) { 3322 if (inptr[0] == '$' && inptr[1] == '{') { 3323 ch2 = strchr(inptr, '}'); 3324 if (ch2 && inptr+1 < ch2) { 3325 ch1 = inptr+2; 3326 inptr = ch2+1; 3327 *ch2 = '\0'; 3328 3329 env = getenv(ch1); 3330 if (env) { 3331 envlen = strlen(env); 3332 if (envlen <= nchr) { 3333 memcpy(outptr, env, envlen); 3334 outptr += envlen; 3335 nchr -= envlen; 3336 } 3337 } 3338 3339 continue; 3340 } 3341 } 3342 3343 *outptr++ = *inptr++; 3344 --nchr; 3345 } 3346 3347 *outptr = '\0'; 3348 return strdup(out); 3349} 3350 3351/* 3352 * Look for reserved variable names and replace them with real values 3353 */ 3354static char *fio_keyword_replace(char *opt) 3355{ 3356 char *s; 3357 int i; 3358 int docalc = 0; 3359 3360 for (i = 0; fio_keywords[i].word != NULL; i++) { 3361 struct fio_keyword *kw = &fio_keywords[i]; 3362 3363 while ((s = strstr(opt, kw->word)) != NULL) { 3364 char *new = malloc(strlen(opt) + 1); 3365 char *o_org = opt; 3366 int olen = s - opt; 3367 int len; 3368 3369 /* 3370 * Copy part of the string before the keyword and 3371 * sprintf() the replacement after it. 3372 */ 3373 memcpy(new, opt, olen); 3374 len = sprintf(new + olen, "%s", kw->replace); 3375 3376 /* 3377 * If there's more in the original string, copy that 3378 * in too 3379 */ 3380 opt += strlen(kw->word) + olen; 3381 if (strlen(opt)) 3382 memcpy(new + olen + len, opt, opt - o_org - 1); 3383 3384 /* 3385 * replace opt and free the old opt 3386 */ 3387 opt = new; 3388 free(o_org); 3389 3390 docalc = 1; 3391 } 3392 } 3393 3394 /* 3395 * Check for potential math and invoke bc, if possible 3396 */ 3397 if (docalc) 3398 opt = bc_calc(opt); 3399 3400 return opt; 3401} 3402 3403static char **dup_and_sub_options(char **opts, int num_opts) 3404{ 3405 int i; 3406 char **opts_copy = malloc(num_opts * sizeof(*opts)); 3407 for (i = 0; i < num_opts; i++) { 3408 opts_copy[i] = option_dup_subs(opts[i]); 3409 if (!opts_copy[i]) 3410 continue; 3411 opts_copy[i] = fio_keyword_replace(opts_copy[i]); 3412 } 3413 return opts_copy; 3414} 3415 3416int fio_options_parse(struct thread_data *td, char **opts, int num_opts) 3417{ 3418 int i, ret, unknown; 3419 char **opts_copy; 3420 3421 sort_options(opts, fio_options, num_opts); 3422 opts_copy = dup_and_sub_options(opts, num_opts); 3423 3424 for (ret = 0, i = 0, unknown = 0; i < num_opts; i++) { 3425 struct fio_option *o; 3426 int newret = parse_option(opts_copy[i], opts[i], fio_options, 3427 &o, td); 3428 3429 if (opts_copy[i]) { 3430 if (newret && !o) { 3431 unknown++; 3432 continue; 3433 } 3434 free(opts_copy[i]); 3435 opts_copy[i] = NULL; 3436 } 3437 3438 ret |= newret; 3439 } 3440 3441 if (unknown) { 3442 ret |= ioengine_load(td); 3443 if (td->eo) { 3444 sort_options(opts_copy, td->io_ops->options, num_opts); 3445 opts = opts_copy; 3446 } 3447 for (i = 0; i < num_opts; i++) { 3448 struct fio_option *o = NULL; 3449 int newret = 1; 3450 if (!opts_copy[i]) 3451 continue; 3452 3453 if (td->eo) 3454 newret = parse_option(opts_copy[i], opts[i], 3455 td->io_ops->options, &o, 3456 td->eo); 3457 3458 ret |= newret; 3459 if (!o) 3460 log_err("Bad option <%s>\n", opts[i]); 3461 3462 free(opts_copy[i]); 3463 opts_copy[i] = NULL; 3464 } 3465 } 3466 3467 free(opts_copy); 3468 return ret; 3469} 3470 3471int fio_cmd_option_parse(struct thread_data *td, const char *opt, char *val) 3472{ 3473 return parse_cmd_option(opt, val, fio_options, td); 3474} 3475 3476int fio_cmd_ioengine_option_parse(struct thread_data *td, const char *opt, 3477 char *val) 3478{ 3479 return parse_cmd_option(opt, val, td->io_ops->options, td); 3480} 3481 3482void fio_fill_default_options(struct thread_data *td) 3483{ 3484 fill_default_options(td, fio_options); 3485} 3486 3487int fio_show_option_help(const char *opt) 3488{ 3489 return show_cmd_help(fio_options, opt); 3490} 3491 3492void options_mem_dupe(void *data, struct fio_option *options) 3493{ 3494 struct fio_option *o; 3495 char **ptr; 3496 3497 for (o = &options[0]; o->name; o++) { 3498 if (o->type != FIO_OPT_STR_STORE) 3499 continue; 3500 3501 ptr = td_var(data, o->off1); 3502 if (*ptr) 3503 *ptr = strdup(*ptr); 3504 } 3505} 3506 3507/* 3508 * dupe FIO_OPT_STR_STORE options 3509 */ 3510void fio_options_mem_dupe(struct thread_data *td) 3511{ 3512 options_mem_dupe(&td->o, fio_options); 3513 3514 if (td->eo && td->io_ops) { 3515 void *oldeo = td->eo; 3516 3517 td->eo = malloc(td->io_ops->option_struct_size); 3518 memcpy(td->eo, oldeo, td->io_ops->option_struct_size); 3519 options_mem_dupe(td->eo, td->io_ops->options); 3520 } 3521} 3522 3523unsigned int fio_get_kb_base(void *data) 3524{ 3525 struct thread_options *o = data; 3526 unsigned int kb_base = 0; 3527 3528 if (o) 3529 kb_base = o->kb_base; 3530 if (!kb_base) 3531 kb_base = 1024; 3532 3533 return kb_base; 3534} 3535 3536int add_option(struct fio_option *o) 3537{ 3538 struct fio_option *__o; 3539 int opt_index = 0; 3540 3541 __o = fio_options; 3542 while (__o->name) { 3543 opt_index++; 3544 __o++; 3545 } 3546 3547 memcpy(&fio_options[opt_index], o, sizeof(*o)); 3548 return 0; 3549} 3550 3551void invalidate_profile_options(const char *prof_name) 3552{ 3553 struct fio_option *o; 3554 3555 o = fio_options; 3556 while (o->name) { 3557 if (o->prof_name && !strcmp(o->prof_name, prof_name)) { 3558 o->type = FIO_OPT_INVALID; 3559 o->prof_name = NULL; 3560 } 3561 o++; 3562 } 3563} 3564 3565void add_opt_posval(const char *optname, const char *ival, const char *help) 3566{ 3567 struct fio_option *o; 3568 unsigned int i; 3569 3570 o = find_option(fio_options, optname); 3571 if (!o) 3572 return; 3573 3574 for (i = 0; i < PARSE_MAX_VP; i++) { 3575 if (o->posval[i].ival) 3576 continue; 3577 3578 o->posval[i].ival = ival; 3579 o->posval[i].help = help; 3580 break; 3581 } 3582} 3583 3584void del_opt_posval(const char *optname, const char *ival) 3585{ 3586 struct fio_option *o; 3587 unsigned int i; 3588 3589 o = find_option(fio_options, optname); 3590 if (!o) 3591 return; 3592 3593 for (i = 0; i < PARSE_MAX_VP; i++) { 3594 if (!o->posval[i].ival) 3595 continue; 3596 if (strcmp(o->posval[i].ival, ival)) 3597 continue; 3598 3599 o->posval[i].ival = NULL; 3600 o->posval[i].help = NULL; 3601 } 3602} 3603 3604void fio_options_free(struct thread_data *td) 3605{ 3606 options_free(fio_options, td); 3607 if (td->eo && td->io_ops && td->io_ops->options) { 3608 options_free(td->io_ops->options, td->eo); 3609 free(td->eo); 3610 td->eo = NULL; 3611 } 3612} 3613 3614struct fio_option *fio_option_find(const char *name) 3615{ 3616 return find_option(fio_options, name); 3617} 3618 3619