1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 2003 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #ifndef _VOLUME_DEFAULTS_H 28 #define _VOLUME_DEFAULTS_H 29 30 #pragma ident "%Z%%M% %I% %E% SMI" 31 32 #ifdef __cplusplus 33 extern "C" { 34 #endif 35 36 #include "volume_devconfig.h" 37 38 #define DEFAULT_MIRROR_NSUBS 2 39 #define DEFAULT_MIRROR_READ MIRROR_READ_ROUNDROBIN 40 #define DEFAULT_MIRROR_WRITE MIRROR_WRITE_PARALLEL 41 #define DEFAULT_MIRROR_PASS 1 42 #define DEFAULT_STRIPE_INTERLACE 1024 * 64 43 #define DEFAULT_STRIPE_MINCOMP 3 44 #define DEFAULT_STRIPE_MAXCOMP 10 45 #define DEFAULT_VOLUME_REDUND_LEVEL 0 46 #define DEFAULT_VOLUME_NPATHS 1 47 48 /* For consistency, these should all have the same value */ 49 #define DEFAULT_MIRROR_USEHSP FALSE 50 #define DEFAULT_CONCAT_USEHSP FALSE 51 #define DEFAULT_STRIPE_USEHSP FALSE 52 #define DEFAULT_VOLUME_USEHSP FALSE 53 54 /* 55 * default_t - struct to hold layout defaults 56 */ 57 typedef struct defaults { 58 /* 59 * List of devconfig_t, each of which represents disk set- 60 * specific defaults. Each disk set has a name, except for 61 * the global set, whose name is NULL. 62 */ 63 dlist_t *disksets; 64 } defaults_t; 65 66 /* 67 * Constructor: Create a defaults_t struct populated with default 68 * values. This defaults_t must be freed. 69 * 70 * @param defaults 71 * RETURN: a pointer to a new defaults_t 72 * 73 * @return 0 74 * if successful 75 * 76 * @return non-zero 77 * if an error occurred. Use get_error_string() to 78 * retrieve the associated error message. 79 */ 80 extern int new_defaults(defaults_t **defaults); 81 82 /* 83 * Free memory (recursively) allocated to a defaults_t struct 84 * 85 * @param arg 86 * pointer to the defaults_t struct to free 87 */ 88 extern void free_defaults(void *arg); 89 90 /* 91 * Set list of diskset specific defaults 92 * 93 * @param defaults 94 * a defaults_t hierarchy representing default settings 95 * for all disk sets and specific disk sets 96 * 97 * @param disksets 98 * a dlist_t representing the defaults for specific 99 * named disk sets 100 */ 101 extern void defaults_set_disksets(defaults_t *defaults, dlist_t *disksets); 102 /* 103 * Get list of diskset specific defaults 104 * 105 * @param defaults 106 * a defaults_t hierarchy representing default settings 107 * for all disk sets and specific disk sets 108 * 109 * @return a dlist_t representing the defaults for specific 110 * named disk sets 111 */ 112 extern dlist_t *defaults_get_disksets(defaults_t *defaults); 113 114 /* 115 * Get a disk set with the given name from the given defaults_t 116 * 117 * @param defaults 118 * a defaults_t hierarchy representing default settings 119 * for all disk sets and specific disk sets 120 * 121 * @param name 122 * the name of the disk set whose defaults to retrieve, 123 * or NULL to get the defaults for all disk sets 124 * 125 * @param diskset 126 * RETURN: defaults for the given named disk set, or 127 * defaults for all disk sets if name is NULL 128 * 129 * @return ENOENT 130 * if the named disk set does not exist 131 * 132 * @return 0 133 * if the named disk set exists 134 */ 135 136 extern int defaults_get_diskset_by_name( 137 defaults_t *defaults, char *name, devconfig_t **diskset); 138 139 /* 140 * Set name of the the default HSP to use 141 * 142 * @param defaults 143 * a defaults_t hierarchy representing default settings 144 * for all disk sets and specific disk sets 145 * 146 * @param diskset 147 * the name of the disk set to which to apply this 148 * default setting, or NULL to apply default 149 * setting to all disk sets 150 * 151 * @param name 152 * the name of the default HSP to use 153 * 154 * @return 0 155 * if successful 156 * 157 * @return non-zero 158 * if an error occurred. Use get_error_string() to 159 * retrieve the associated error message. 160 */ 161 extern int defaults_set_hsp_name( 162 defaults_t *defaults, char *diskset, char *name); 163 /* 164 * Get the name of the default HSP to use 165 * 166 * @param defaults 167 * a defaults_t hierarchy representing default settings 168 * for all disk sets and specific disk sets 169 * 170 * @param diskset 171 * the name of the disk set to which to apply this 172 * default setting, or NULL to apply default 173 * setting to all disk sets 174 * 175 * @param name 176 * RETURN: the name of the default HSP to use 177 * 178 * @return 0 179 * if successful 180 * 181 * @return non-zero 182 * if an error occurred. Use get_error_string() to 183 * retrieve the associated error message. 184 */ 185 extern int defaults_get_hsp_name( 186 defaults_t *defaults, char *diskset, char **name); 187 188 /* 189 * Set the default number of submirrors for mirrored volumes 190 * 191 * @param defaults 192 * a defaults_t hierarchy representing default settings 193 * for all disk sets and specific disk sets 194 * 195 * @param diskset 196 * the name of the disk set to which to apply this 197 * default setting, or NULL to apply default 198 * setting to all disk sets 199 * 200 * @param val 201 * the value to set as the default number of submirrors 202 * for mirrored volumes 203 * 204 * @return 0 205 * if successful 206 * 207 * @return non-zero 208 * if an error occurred. Use get_error_string() to 209 * retrieve the associated error message. 210 */ 211 extern int defaults_set_mirror_nsubs( 212 defaults_t *defaults, char *diskset, uint16_t val); 213 /* 214 * Get the default number of submirrors for mirrored volumes 215 * 216 * @param defaults 217 * a defaults_t hierarchy representing default settings 218 * for all disk sets and specific disk sets 219 * 220 * @param diskset 221 * the name of the disk set to which to apply this 222 * default setting, or NULL to apply default 223 * setting to all disk sets 224 * 225 * @param val 226 * RETURN: the default number of submirrors for mirrored 227 * volumes 228 * 229 * @return 0 230 * if successful 231 * 232 * @return non-zero 233 * if an error occurred. Use get_error_string() to 234 * retrieve the associated error message. 235 */ 236 extern int defaults_get_mirror_nsubs( 237 defaults_t *defaults, char *diskset, uint16_t *val); 238 239 /* 240 * Set the default read strategy for mirrored volumes 241 * 242 * @param defaults 243 * a defaults_t hierarchy representing default settings 244 * for all disk sets and specific disk sets 245 * 246 * @param diskset 247 * the name of the disk set to which to apply this 248 * default setting, or NULL to apply default 249 * setting to all disk sets 250 * 251 * @param val 252 * the value to set as the default read strategy for 253 * mirrored volumes 254 * 255 * @return 0 256 * if successful 257 * 258 * @return non-zero 259 * if an error occurred. Use get_error_string() to 260 * retrieve the associated error message. 261 */ 262 extern int defaults_set_mirror_read( 263 defaults_t *defaults, char *diskset, mirror_read_strategy_t val); 264 /* 265 * Get the default read strategy for mirrored volumes 266 * 267 * @param defaults 268 * a defaults_t hierarchy representing default settings 269 * for all disk sets and specific disk sets 270 * 271 * @param diskset 272 * the name of the disk set to which to apply this 273 * default setting, or NULL to apply default 274 * setting to all disk sets 275 * 276 * @param val 277 * RETURN: the default read strategy for mirrored volumes 278 * 279 * @return 0 280 * if successful 281 * 282 * @return non-zero 283 * if an error occurred. Use get_error_string() to 284 * retrieve the associated error message. 285 */ 286 extern int defaults_get_mirror_read( 287 defaults_t *defaults, char *diskset, mirror_read_strategy_t *val); 288 289 /* 290 * Set the default write strategy for mirrored volumes 291 * 292 * @param defaults 293 * a defaults_t hierarchy representing default settings 294 * for all disk sets and specific disk sets 295 * 296 * @param diskset 297 * the name of the disk set to which to apply this 298 * default setting, or NULL to apply default 299 * setting to all disk sets 300 * 301 * @param val 302 * the value to set as the default write strategy for 303 * mirrored volumes 304 * 305 * @return 0 306 * if successful 307 * 308 * @return non-zero 309 * if an error occurred. Use get_error_string() to 310 * retrieve the associated error message. 311 */ 312 extern int defaults_set_mirror_write( 313 defaults_t *defaults, char *diskset, mirror_write_strategy_t val); 314 /* 315 * Get the default write strategy for mirrored volumes 316 * 317 * @param defaults 318 * a defaults_t hierarchy representing default settings 319 * for all disk sets and specific disk sets 320 * 321 * @param diskset 322 * the name of the disk set to which to apply this 323 * default setting, or NULL to apply default 324 * setting to all disk sets 325 * 326 * @param val 327 * RETURN: the default write strategy for mirrored 328 * volumes 329 * 330 * @return 0 331 * if successful 332 * 333 * @return non-zero 334 * if an error occurred. Use get_error_string() to 335 * retrieve the associated error message. 336 */ 337 extern int defaults_get_mirror_write( 338 defaults_t *defaults, char *diskset, mirror_write_strategy_t *val); 339 340 /* 341 * Set the default resync pass for mirrored volumes 342 * 343 * @param defaults 344 * a defaults_t hierarchy representing default settings 345 * for all disk sets and specific disk sets 346 * 347 * @param diskset 348 * the name of the disk set to which to apply this 349 * default setting, or NULL to apply default 350 * setting to all disk sets 351 * 352 * @param val 353 * the value to set as the default resync pass for 354 * mirrored volumes 355 * 356 * @return 0 357 * if successful 358 * 359 * @return non-zero 360 * if an error occurred. Use get_error_string() to 361 * retrieve the associated error message. 362 */ 363 extern int defaults_set_mirror_pass( 364 defaults_t *defaults, char *diskset, uint16_t val); 365 /* 366 * Get the default resync pass for mirrored volumes 367 * 368 * @param defaults 369 * a defaults_t hierarchy representing default settings 370 * for all disk sets and specific disk sets 371 * 372 * @param diskset 373 * the name of the disk set to which to apply this 374 * default setting, or NULL to apply default 375 * setting to all disk sets 376 * 377 * @param val 378 * RETURN: the default resync pass for mirrored volumes 379 * 380 * @return 0 381 * if successful 382 * 383 * @return non-zero 384 * if an error occurred. Use get_error_string() to 385 * retrieve the associated error message. 386 */ 387 extern int defaults_get_mirror_pass( 388 defaults_t *defaults, char *diskset, uint16_t *val); 389 390 /* 391 * Set the default HSP creation flag for mirrored volumes 392 * 393 * @param defaults 394 * a defaults_t hierarchy representing default settings 395 * for all disk sets and specific disk sets 396 * 397 * @param diskset 398 * the name of the disk set to which to apply this 399 * default setting, or NULL to apply default 400 * setting to all disk sets 401 * 402 * @param val 403 * the value to set as the default HSP creation flag for 404 * mirrored volumes 405 * 406 * @return 0 407 * if successful 408 * 409 * @return non-zero 410 * if an error occurred. Use get_error_string() to 411 * retrieve the associated error message. 412 */ 413 extern int defaults_set_mirror_usehsp( 414 defaults_t *defaults, char *diskset, boolean_t val); 415 /* 416 * Get the default HSP creation flag for mirrored volumes 417 * 418 * @param defaults 419 * a defaults_t hierarchy representing default settings 420 * for all disk sets and specific disk sets 421 * 422 * @param diskset 423 * the name of the disk set to which to apply this 424 * default setting, or NULL to apply default 425 * setting to all disk sets 426 * 427 * @param val 428 * RETURN: the default HSP creation flag for mirrored 429 * volumes 430 * 431 * @return 0 432 * if successful 433 * 434 * @return non-zero 435 * if an error occurred. Use get_error_string() to 436 * retrieve the associated error message. 437 */ 438 extern int defaults_get_mirror_usehsp( 439 defaults_t *defaults, char *diskset, boolean_t *val); 440 441 /* 442 * Set the default HSP creation flag for concatenated volumes 443 * 444 * @param defaults 445 * a defaults_t hierarchy representing default settings 446 * for all disk sets and specific disk sets 447 * 448 * @param diskset 449 * the name of the disk set to which to apply this 450 * default setting, or NULL to apply default 451 * setting to all disk sets 452 * 453 * @param val 454 * the value to set as the default HSP creation flag for 455 * concatenated volumes 456 * 457 * @return 0 458 * if successful 459 * 460 * @return non-zero 461 * if an error occurred. Use get_error_string() to 462 * retrieve the associated error message. 463 */ 464 extern int defaults_set_concat_usehsp( 465 defaults_t *defaults, char *diskset, boolean_t val); 466 /* 467 * Get the default HSP creation flag for concatenated volumes 468 * 469 * @param defaults 470 * a defaults_t hierarchy representing default settings 471 * for all disk sets and specific disk sets 472 * 473 * @param diskset 474 * the name of the disk set to which to apply this 475 * default setting, or NULL to apply default 476 * setting to all disk sets 477 * 478 * @param val 479 * RETURN: the default HSP creation flag for concatenated 480 * volumes 481 * 482 * @return 0 483 * if successful 484 * 485 * @return non-zero 486 * if an error occurred. Use get_error_string() to 487 * retrieve the associated error message. 488 */ 489 extern int defaults_get_concat_usehsp( 490 defaults_t *defaults, char *diskset, boolean_t *val); 491 492 /* 493 * Set the default minimum number of components for striped volumes 494 * 495 * @param defaults 496 * a defaults_t hierarchy representing default settings 497 * for all disk sets and specific disk sets 498 * 499 * @param diskset 500 * the name of the disk set to which to apply this 501 * default setting, or NULL to apply default 502 * setting to all disk sets 503 * 504 * @param val 505 * the value to set as the default minimum number of 506 * components for striped volumes 507 * 508 * @return 0 509 * if successful 510 * 511 * @return non-zero 512 * if an error occurred. Use get_error_string() to 513 * retrieve the associated error message. 514 */ 515 extern int defaults_set_stripe_mincomp( 516 defaults_t *defaults, char *diskset, uint16_t val); 517 /* 518 * Get the default minimum number of components for striped volumes 519 * 520 * @param defaults 521 * a defaults_t hierarchy representing default settings 522 * for all disk sets and specific disk sets 523 * 524 * @param diskset 525 * the name of the disk set to which to apply this 526 * default setting, or NULL to apply default 527 * setting to all disk sets 528 * 529 * @param val 530 * RETURN: the default minimum number of components for 531 * striped volumes 532 * 533 * @return 0 534 * if successful 535 * 536 * @return non-zero 537 * if an error occurred. Use get_error_string() to 538 * retrieve the associated error message. 539 */ 540 extern int defaults_get_stripe_mincomp( 541 defaults_t *defaults, char *diskset, uint16_t *val); 542 543 /* 544 * Set the default maximum number of components for striped volumes 545 * 546 * @param defaults 547 * a defaults_t hierarchy representing default settings 548 * for all disk sets and specific disk sets 549 * 550 * @param diskset 551 * the name of the disk set to which to apply this 552 * default setting, or NULL to apply default 553 * setting to all disk sets 554 * 555 * @param val 556 * the value to set as the default maximum number of 557 * components for striped volumes 558 * 559 * @return 0 560 * if successful 561 * 562 * @return non-zero 563 * if an error occurred. Use get_error_string() to 564 * retrieve the associated error message. 565 */ 566 extern int defaults_set_stripe_maxcomp( 567 defaults_t *defaults, char *diskset, uint16_t val); 568 /* 569 * Get the default maximum number of components for striped volumes 570 * 571 * @param defaults 572 * a defaults_t hierarchy representing default settings 573 * for all disk sets and specific disk sets 574 * 575 * @param diskset 576 * the name of the disk set to which to apply this 577 * default setting, or NULL to apply default 578 * setting to all disk sets 579 * 580 * @param val 581 * RETURN: the default maximum number of components for 582 * striped volumes 583 * 584 * @return 0 585 * if successful 586 * 587 * @return non-zero 588 * if an error occurred. Use get_error_string() to 589 * retrieve the associated error message. 590 */ 591 extern int defaults_get_stripe_maxcomp( 592 defaults_t *defaults, char *diskset, uint16_t *val); 593 594 /* 595 * Set the default interlace for striped volumes 596 * 597 * @param defaults 598 * a defaults_t hierarchy representing default settings 599 * for all disk sets and specific disk sets 600 * 601 * @param diskset 602 * the name of the disk set to which to apply this 603 * default setting, or NULL to apply default 604 * setting to all disk sets 605 * 606 * @param val 607 * the value to set as the default interlace for striped 608 * volumes 609 * 610 * @return 0 611 * if successful 612 * 613 * @return non-zero 614 * if an error occurred. Use get_error_string() to 615 * retrieve the associated error message. 616 */ 617 extern int defaults_set_stripe_interlace( 618 defaults_t *defaults, char *diskset, uint64_t val); 619 /* 620 * Get the default interlace for striped volumes 621 * 622 * @param defaults 623 * a defaults_t hierarchy representing default settings 624 * for all disk sets and specific disk sets 625 * 626 * @param diskset 627 * the name of the disk set to which to apply this 628 * default setting, or NULL to apply default 629 * setting to all disk sets 630 * 631 * @param val 632 * RETURN: the default interlace for striped volumes 633 * 634 * @return 0 635 * if successful 636 * 637 * @return non-zero 638 * if an error occurred. Use get_error_string() to 639 * retrieve the associated error message. 640 */ 641 extern int defaults_get_stripe_interlace( 642 defaults_t *defaults, char *diskset, uint64_t *val); 643 644 /* 645 * Set the default HSP creation flag for striped volumes 646 * 647 * @param defaults 648 * a defaults_t hierarchy representing default settings 649 * for all disk sets and specific disk sets 650 * 651 * @param diskset 652 * the name of the disk set to which to apply this 653 * default setting, or NULL to apply default 654 * setting to all disk sets 655 * 656 * @param val 657 * the value to set as the default HSP creation flag for 658 * striped volumes 659 * 660 * @return 0 661 * if successful 662 * 663 * @return non-zero 664 * if an error occurred. Use get_error_string() to 665 * retrieve the associated error message. 666 */ 667 extern int defaults_set_stripe_usehsp( 668 defaults_t *defaults, char *diskset, boolean_t val); 669 /* 670 * Get the default HSP creation flag for striped volumes 671 * 672 * @param defaults 673 * a defaults_t hierarchy representing default settings 674 * for all disk sets and specific disk sets 675 * 676 * @param diskset 677 * the name of the disk set to which to apply this 678 * default setting, or NULL to apply default 679 * setting to all disk sets 680 * 681 * @param val 682 * RETURN: the default HSP creation flag for striped 683 * volumes 684 * 685 * @return 0 686 * if successful 687 * 688 * @return non-zero 689 * if an error occurred. Use get_error_string() to 690 * retrieve the associated error message. 691 */ 692 extern int defaults_get_stripe_usehsp( 693 defaults_t *defaults, char *diskset, boolean_t *val); 694 695 /* 696 * Set the default redundancy level for generic volumes. 697 * 698 * @param defaults 699 * a defaults_t hierarchy representing default settings 700 * for all disk sets and specific disk sets 701 * 702 * @param diskset 703 * the name of the disk set to which to apply this 704 * default setting, or NULL to apply default 705 * setting to all disk sets 706 * 707 * @param val 708 * If 0, a stripe will be created by default. If > 0, a 709 * mirror with this number of submirrors will be created 710 * by default. 711 * 712 * @return 0 713 * if successful 714 * 715 * @return non-zero 716 * if an error occurred. Use get_error_string() to 717 * retrieve the associated error message. 718 */ 719 extern int defaults_set_volume_redundancy_level( 720 defaults_t *defaults, char *diskset, uint16_t val); 721 /* 722 * Get the default redundancy level for generic volumes. 723 * 724 * @param defaults 725 * a defaults_t hierarchy representing default settings 726 * for all disk sets and specific disk sets 727 * 728 * @param diskset 729 * the name of the disk set to which to apply this 730 * default setting, or NULL to apply default 731 * setting to all disk sets 732 * 733 * @param val 734 * RETURN: the default redundancy level for generic 735 * volumes 736 * 737 * @return 0 738 * if successful 739 * 740 * @return non-zero 741 * if an error occurred. Use get_error_string() to 742 * retrieve the associated error message. 743 */ 744 extern int defaults_get_volume_redundancy_level( 745 defaults_t *defaults, char *diskset, uint16_t *val); 746 747 /* 748 * Set the default number of data paths for generic volume 749 * 750 * @param defaults 751 * a defaults_t hierarchy representing default settings 752 * for all disk sets and specific disk sets 753 * 754 * @param diskset 755 * the name of the disk set to which to apply this 756 * default setting, or NULL to apply default 757 * setting to all disk sets 758 * 759 * @param val 760 * the value to set as the default number of data paths 761 * for generic volume 762 * 763 * @return 0 764 * if successful 765 * 766 * @return non-zero 767 * if an error occurred. Use get_error_string() to 768 * retrieve the associated error message. 769 */ 770 extern int defaults_set_volume_npaths( 771 defaults_t *defaults, char *diskset, uint16_t val); 772 /* 773 * Get the default number of data paths for generic volume 774 * 775 * @param defaults 776 * a defaults_t hierarchy representing default settings 777 * for all disk sets and specific disk sets 778 * 779 * @param diskset 780 * the name of the disk set to which to apply this 781 * default setting, or NULL to apply default 782 * setting to all disk sets 783 * 784 * @param val 785 * RETURN: the default number of data paths for generic 786 * volume 787 * 788 * @return 0 789 * if successful 790 * 791 * @return non-zero 792 * if an error occurred. Use get_error_string() to 793 * retrieve the associated error message. 794 */ 795 extern int defaults_get_volume_npaths( 796 defaults_t *defaults, char *diskset, uint16_t *val); 797 798 /* 799 * Set the default HSP creation flag for generic volume 800 * 801 * @param defaults 802 * a defaults_t hierarchy representing default settings 803 * for all disk sets and specific disk sets 804 * 805 * @param diskset 806 * the name of the disk set to which to apply this 807 * default setting, or NULL to apply default 808 * setting to all disk sets 809 * 810 * @param val 811 * the value to set as the default HSP creation flag for 812 * generic volume 813 * 814 * @return 0 815 * if successful 816 * 817 * @return non-zero 818 * if an error occurred. Use get_error_string() to 819 * retrieve the associated error message. 820 */ 821 extern int defaults_set_volume_usehsp( 822 defaults_t *defaults, char *diskset, boolean_t val); 823 /* 824 * Get the default HSP creation flag for generic volume 825 * 826 * @param defaults 827 * a defaults_t hierarchy representing default settings 828 * for all disk sets and specific disk sets 829 * 830 * @param diskset 831 * the name of the disk set to which to apply this 832 * default setting, or NULL to apply default 833 * setting to all disk sets 834 * 835 * @param val 836 * RETURN: the default HSP creation flag for generic 837 * volume 838 * 839 * @return 0 840 * if successful 841 * 842 * @return non-zero 843 * if an error occurred. Use get_error_string() to 844 * retrieve the associated error message. 845 */ 846 extern int defaults_get_volume_usehsp( 847 defaults_t *defaults, char *diskset, boolean_t *val); 848 849 #ifdef __cplusplus 850 } 851 #endif 852 853 #endif /* _VOLUME_DEFAULTS_H */ 854