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
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.
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]
23 * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
31 #include "volume_defaults.h"
32 #include "volume_error.h"
35 * Methods which manipulate a defaults_t struct
38 static int defaults_get_singleton_component(
39 defaults_t
*defaults
, char *disksetname
,
40 component_type_t type
, devconfig_t
**component
, boolean_t create
);
43 * Constructor: Create a defaults_t struct populated with default
44 * values. This defaults_t must be freed.
47 * RETURN: a pointer to a new defaults_t
53 * if an error occurred. Use get_error_string() to
54 * retrieve the associated error message.
58 defaults_t
**defaults
)
63 *defaults
= (defaults_t
*)calloc(1, sizeof (defaults_t
));
64 if (*defaults
== NULL
) {
65 volume_set_error(gettext("new_defaults calloc() failed"));
70 * Create initial "global" (disk set-independent) defaults, as
71 * a devconfig_t of type disk set with NULL name
73 if ((error
= new_devconfig(&diskset
, TYPE_DISKSET
)) != 0) {
74 free_defaults(*defaults
);
78 /* Append global defaults disk set to disksets */
79 defaults_set_disksets(
80 *defaults
, dlist_append(dlist_new_item(diskset
),
81 defaults_get_disksets(*defaults
), AT_TAIL
));
84 if ((error
= defaults_set_mirror_nsubs(
85 *defaults
, NULL
, DEFAULT_MIRROR_NSUBS
)) != 0 ||
87 (error
= defaults_set_mirror_read(
88 *defaults
, NULL
, DEFAULT_MIRROR_READ
)) != 0 ||
90 (error
= defaults_set_mirror_write(
91 *defaults
, NULL
, DEFAULT_MIRROR_WRITE
)) != 0 ||
93 (error
= defaults_set_mirror_pass(
94 *defaults
, NULL
, DEFAULT_MIRROR_PASS
)) != 0 ||
96 (error
= defaults_set_mirror_usehsp(
97 *defaults
, NULL
, DEFAULT_MIRROR_USEHSP
)) != 0 ||
99 (error
= defaults_set_concat_usehsp(
100 *defaults
, NULL
, DEFAULT_CONCAT_USEHSP
)) != 0 ||
102 (error
= defaults_set_stripe_interlace(
103 *defaults
, NULL
, DEFAULT_STRIPE_INTERLACE
)) != 0 ||
105 (error
= defaults_set_stripe_mincomp(
106 *defaults
, NULL
, DEFAULT_STRIPE_MINCOMP
)) != 0 ||
108 (error
= defaults_set_stripe_maxcomp(
109 *defaults
, NULL
, DEFAULT_STRIPE_MAXCOMP
)) != 0 ||
111 (error
= defaults_set_stripe_usehsp(
112 *defaults
, NULL
, DEFAULT_STRIPE_USEHSP
)) != 0 ||
114 (error
= defaults_set_volume_redundancy_level(
115 *defaults
, NULL
, DEFAULT_VOLUME_REDUND_LEVEL
)) != 0 ||
117 (error
= defaults_set_volume_npaths(
118 *defaults
, NULL
, DEFAULT_VOLUME_NPATHS
)) != 0 ||
120 (error
= defaults_set_volume_usehsp(
121 *defaults
, NULL
, DEFAULT_VOLUME_USEHSP
)) != 0) {
123 free_defaults(*defaults
);
131 * Free memory (recursively) allocated to a defaults_t struct
134 * pointer to the defaults_t struct to free
140 defaults_t
*defaults
= (defaults_t
*)arg
;
142 if (defaults
== NULL
) {
146 /* Free the disksets */
147 if (defaults
->disksets
!= NULL
) {
148 dlist_free_items(defaults
->disksets
, free_devconfig
);
151 /* Free the devconfig itself */
156 * Set list of diskset specific defaults
159 * a defaults_t hierarchy representing default settings
160 * for all disk sets and specific disk sets
163 * a dlist_t representing the defaults for specific
167 defaults_set_disksets(
168 defaults_t
*defaults
,
171 defaults
->disksets
= disksets
;
175 * Get list of diskset specific defaults
178 * a defaults_t hierarchy representing default settings
179 * for all disk sets and specific disk sets
181 * @return a dlist_t representing the defaults for specific
185 defaults_get_disksets(
186 defaults_t
*defaults
)
188 return (defaults
->disksets
);
192 * Get a disk set with the given name from the given defaults_t
195 * a defaults_t hierarchy representing default settings
196 * for all disk sets and specific disk sets
199 * the name of the disk set whose defaults to retrieve,
200 * or NULL to get the defaults for all disk sets
203 * RETURN: defaults for the given named disk set, or
204 * defaults for all disk sets if name is NULL
207 * if the named disk set does not exist
210 * if the named disk set exists
213 defaults_get_diskset_by_name(
214 defaults_t
*defaults
,
216 devconfig_t
**diskset
)
221 /* Get list of disk sets */
222 list
= defaults_get_disksets(defaults
);
225 /* For each disk set-specific defaults... */
226 for (; list
!= NULL
; list
= list
->next
) {
229 devconfig_t
*d
= (devconfig_t
*)list
->obj
;
231 /* Get the name if this disk set */
232 devconfig_get_name(d
, &dname
);
234 /* Do the names match? */
236 /* Global defaults disk set */
237 (name
== NULL
&& dname
== NULL
) ||
240 (name
!= NULL
&& dname
!= NULL
&&
241 strcmp(name
, dname
) == 0)) {
249 /* Diskset doesn't exist */
250 if (*diskset
== NULL
) {
258 * Get the first component of the given type from the given disk set.
259 * If not found, create the component if requested.
262 * if the given disk set does not exist, or it exists,
263 * but the requested component does not exist under it
264 * and its creation was not requested
267 * if the requested component exists or was created
270 * if the requested component does not exist and could
274 defaults_get_singleton_component(
275 defaults_t
*defaults
,
277 component_type_t type
,
278 devconfig_t
**component
,
282 devconfig_t
*diskset
;
284 /* Get the disk set referred to */
285 if ((error
= defaults_get_diskset_by_name(
286 defaults
, disksetname
, &diskset
)) != 0) {
289 gettext("could not get defaults for disk set %s"),
290 disksetname
== NULL
? gettext("<NULL>") : disksetname
);
296 * Get the singleton component under this disk set, create if
299 return (devconfig_get_component(diskset
, type
, component
, create
));
303 * Set name of the the default HSP to use
306 * a defaults_t hierarchy representing default settings
307 * for all disk sets and specific disk sets
310 * the name of the disk set to which to apply this
311 * default setting, or NULL to apply default
312 * setting to all disk sets
315 * the name of the default HSP to use
321 * if an error occurred. Use get_error_string() to
322 * retrieve the associated error message.
325 defaults_set_hsp_name(
326 defaults_t
*defaults
,
330 devconfig_t
*hsp
= NULL
;
333 /* Get/create singleton HSP element for this disk set */
334 if ((error
= defaults_get_singleton_component(
335 defaults
, diskset
, TYPE_HSP
, &hsp
, TRUE
)) != 0) {
336 /* volume_set_error already called */
340 /* Set the name attribute */
341 return (devconfig_set_hsp_name(hsp
, name
));
345 * Get the name of the default HSP to use
348 * a defaults_t hierarchy representing default settings
349 * for all disk sets and specific disk sets
352 * the name of the disk set to which to apply this
353 * default setting, or NULL to apply default
354 * setting to all disk sets
357 * RETURN: the name of the default HSP to use
363 * if an error occurred. Use get_error_string() to
364 * retrieve the associated error message.
367 defaults_get_hsp_name(
368 defaults_t
*defaults
,
377 /* Check both the given and global (NULL) disk sets for the value */
378 disksets
[0] = diskset
;
381 /* Get/create singleton HSP element for this disk set */
382 error
= defaults_get_singleton_component(
383 defaults
, disksets
[i
], TYPE_HSP
, &hsp
, FALSE
);
386 /* HSP found for this disk set */
388 /* Get the nsubs attribute */
389 if ((error
= devconfig_get_name(hsp
, name
)) == 0) {
390 /* nsubs attribute found */
396 /* HSP not found for this disk set */
400 /* Invalid disk set, or HSP couldn't be created */
402 /* volume_set_error already called */
406 /* Stop after the global (NULL) disk set has been searched */
407 } while (disksets
[i
++] != NULL
);
413 * Set the default number of submirrors for mirrored volumes
416 * a defaults_t hierarchy representing default settings
417 * for all disk sets and specific disk sets
420 * the name of the disk set to which to apply this
421 * default setting, or NULL to apply default
422 * setting to all disk sets
425 * the value to set as the default number of submirrors
426 * for mirrored volumes
432 * if an error occurred. Use get_error_string() to
433 * retrieve the associated error message.
436 defaults_set_mirror_nsubs(
437 defaults_t
*defaults
,
441 devconfig_t
*mirror
= NULL
;
444 /* Get/create singleton mirror element for this disk set */
445 if ((error
= defaults_get_singleton_component(
446 defaults
, diskset
, TYPE_MIRROR
, &mirror
, TRUE
)) != 0) {
447 /* volume_set_error already called */
451 /* Set the nsubs attribute */
452 return (devconfig_set_mirror_nsubs(mirror
, val
));
456 * Get the default number of submirrors for mirrored volumes
459 * a defaults_t hierarchy representing default settings
460 * for all disk sets and specific disk sets
463 * the name of the disk set to which to apply this
464 * default setting, or NULL to apply default
465 * setting to all disk sets
468 * RETURN: the default number of submirrors for mirrored
475 * if an error occurred. Use get_error_string() to
476 * retrieve the associated error message.
479 defaults_get_mirror_nsubs(
480 defaults_t
*defaults
,
489 /* Check both the given and global (NULL) disk sets for the value */
490 disksets
[0] = diskset
;
493 /* Get/create singleton mirror element for this disk set */
494 error
= defaults_get_singleton_component(
495 defaults
, disksets
[i
], TYPE_MIRROR
, &mirror
, FALSE
);
498 /* mirror found for this disk set */
500 /* Get the nsubs attribute */
501 if ((error
= devconfig_get_mirror_nsubs(
502 mirror
, val
)) == 0) {
503 /* nsubs attribute found */
509 /* mirror not found for this disk set */
513 /* Invalid disk set, or mirror couldn't be created */
515 /* volume_set_error already called */
519 /* Stop after the global (NULL) disk set has been searched */
520 } while (disksets
[i
++] != NULL
);
526 * Set the default read strategy for mirrored volumes
529 * a defaults_t hierarchy representing default settings
530 * for all disk sets and specific disk sets
533 * the name of the disk set to which to apply this
534 * default setting, or NULL to apply default
535 * setting to all disk sets
538 * the value to set as the default read strategy for
545 * if an error occurred. Use get_error_string() to
546 * retrieve the associated error message.
549 defaults_set_mirror_read(
550 defaults_t
*defaults
,
552 mirror_read_strategy_t val
)
554 devconfig_t
*mirror
= NULL
;
557 /* Get/create singleton mirror element for this disk set */
558 if ((error
= defaults_get_singleton_component(
559 defaults
, diskset
, TYPE_MIRROR
, &mirror
, TRUE
)) != 0) {
560 /* volume_set_error already called */
564 /* Set the read attribute */
565 return (devconfig_set_mirror_read(mirror
, val
));
569 * Get the default read strategy for mirrored volumes
572 * a defaults_t hierarchy representing default settings
573 * for all disk sets and specific disk sets
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
581 * RETURN: the default read strategy for mirrored volumes
587 * if an error occurred. Use get_error_string() to
588 * retrieve the associated error message.
591 defaults_get_mirror_read(
592 defaults_t
*defaults
,
594 mirror_read_strategy_t
*val
)
601 /* Check both the given and global (NULL) disk sets for the value */
602 disksets
[0] = diskset
;
605 /* Get/create singleton mirror element for this disk set */
606 error
= defaults_get_singleton_component(
607 defaults
, disksets
[i
], TYPE_MIRROR
, &mirror
, FALSE
);
610 /* mirror found for this disk set */
612 /* Get the read attribute */
613 if ((error
= devconfig_get_mirror_read(mirror
, val
)) == 0) {
614 /* read attribute found */
620 /* mirror not found for this disk set */
624 /* Invalid disk set, or mirror couldn't be created */
626 /* volume_set_error already called */
630 /* Stop after the global (NULL) disk set has been searched */
631 } while (disksets
[i
++] != NULL
);
637 * Set the default write strategy for mirrored volumes
640 * a defaults_t hierarchy representing default settings
641 * for all disk sets and specific disk sets
644 * the name of the disk set to which to apply this
645 * default setting, or NULL to apply default
646 * setting to all disk sets
649 * the value to set as the default write strategy for
656 * if an error occurred. Use get_error_string() to
657 * retrieve the associated error message.
660 defaults_set_mirror_write(
661 defaults_t
*defaults
,
663 mirror_write_strategy_t val
)
665 devconfig_t
*mirror
= NULL
;
668 /* Get/create singleton mirror element for this disk set */
669 if ((error
= defaults_get_singleton_component(
670 defaults
, diskset
, TYPE_MIRROR
, &mirror
, TRUE
)) != 0) {
671 /* volume_set_error already called */
675 /* Set the write attribute */
676 return (devconfig_set_mirror_write(mirror
, val
));
680 * Get the default write strategy for mirrored volumes
683 * a defaults_t hierarchy representing default settings
684 * for all disk sets and specific disk sets
687 * the name of the disk set to which to apply this
688 * default setting, or NULL to apply default
689 * setting to all disk sets
692 * RETURN: the default write strategy for mirrored
699 * if an error occurred. Use get_error_string() to
700 * retrieve the associated error message.
703 defaults_get_mirror_write(
704 defaults_t
*defaults
,
706 mirror_write_strategy_t
*val
)
713 /* Check both the given and global (NULL) disk sets for the value */
714 disksets
[0] = diskset
;
717 /* Get/create singleton mirror element for this disk set */
718 error
= defaults_get_singleton_component(
719 defaults
, disksets
[i
], TYPE_MIRROR
, &mirror
, FALSE
);
722 /* mirror found for this disk set */
724 /* Get the write attribute */
725 if ((error
= devconfig_get_mirror_write(
726 mirror
, val
)) == 0) {
727 /* write attribute found */
733 /* mirror not found for this disk set */
737 /* Invalid disk set, or mirror couldn't be created */
739 /* volume_set_error already called */
743 /* Stop after the global (NULL) disk set has been searched */
744 } while (disksets
[i
++] != NULL
);
750 * Set the default resync pass for mirrored volumes
753 * a defaults_t hierarchy representing default settings
754 * for all disk sets and specific disk sets
757 * the name of the disk set to which to apply this
758 * default setting, or NULL to apply default
759 * setting to all disk sets
762 * the value to set as the default resync pass for
769 * if an error occurred. Use get_error_string() to
770 * retrieve the associated error message.
773 defaults_set_mirror_pass(
774 defaults_t
*defaults
,
778 devconfig_t
*mirror
= NULL
;
781 /* Get/create singleton mirror element for this disk set */
782 if ((error
= defaults_get_singleton_component(
783 defaults
, diskset
, TYPE_MIRROR
, &mirror
, TRUE
)) != 0) {
784 /* volume_set_error already called */
788 /* Set the pass attribute */
789 return (devconfig_set_mirror_pass(mirror
, val
));
793 * Get the default resync pass for mirrored volumes
796 * a defaults_t hierarchy representing default settings
797 * for all disk sets and specific disk sets
800 * the name of the disk set to which to apply this
801 * default setting, or NULL to apply default
802 * setting to all disk sets
805 * RETURN: the default resync pass for mirrored volumes
811 * if an error occurred. Use get_error_string() to
812 * retrieve the associated error message.
815 defaults_get_mirror_pass(
816 defaults_t
*defaults
,
825 /* Check both the given and global (NULL) disk sets for the value */
826 disksets
[0] = diskset
;
829 /* Get/create singleton mirror element for this disk set */
830 error
= defaults_get_singleton_component(
831 defaults
, disksets
[i
], TYPE_MIRROR
, &mirror
, FALSE
);
834 /* mirror found for this disk set */
836 /* Get the pass attribute */
837 if ((error
= devconfig_get_mirror_pass(mirror
, val
)) == 0) {
838 /* pass attribute found */
844 /* mirror not found for this disk set */
848 /* Invalid disk set, or mirror couldn't be created */
850 /* volume_set_error already called */
854 /* Stop after the global (NULL) disk set has been searched */
855 } while (disksets
[i
++] != NULL
);
861 * Set the default HSP creation flag for mirrored volumes
864 * a defaults_t hierarchy representing default settings
865 * for all disk sets and specific disk sets
868 * the name of the disk set to which to apply this
869 * default setting, or NULL to apply default
870 * setting to all disk sets
873 * the value to set as the default HSP creation flag for
880 * if an error occurred. Use get_error_string() to
881 * retrieve the associated error message.
884 defaults_set_mirror_usehsp(
885 defaults_t
*defaults
,
889 devconfig_t
*mirror
= NULL
;
892 /* Get/create singleton mirror element for this disk set */
893 if ((error
= defaults_get_singleton_component(
894 defaults
, diskset
, TYPE_MIRROR
, &mirror
, TRUE
)) != 0) {
895 /* volume_set_error already called */
899 /* Set the usehsp attribute */
900 return (devconfig_set_volume_usehsp(mirror
, val
));
904 * Get the default HSP creation flag for mirrored volumes
907 * a defaults_t hierarchy representing default settings
908 * for all disk sets and specific disk sets
911 * the name of the disk set to which to apply this
912 * default setting, or NULL to apply default
913 * setting to all disk sets
916 * RETURN: the default HSP creation flag for mirrored
923 * if an error occurred. Use get_error_string() to
924 * retrieve the associated error message.
927 defaults_get_mirror_usehsp(
928 defaults_t
*defaults
,
937 /* Check both the given and global (NULL) disk sets for the value */
938 disksets
[0] = diskset
;
941 /* Get/create singleton mirror element for this disk set */
942 error
= defaults_get_singleton_component(
943 defaults
, disksets
[i
], TYPE_MIRROR
, &mirror
, FALSE
);
946 /* mirror found for this disk set */
948 /* Get the usehsp attribute */
949 if ((error
= devconfig_get_volume_usehsp(
950 mirror
, val
)) == 0) {
951 /* usehsp attribute found */
957 /* mirror not found for this disk set */
961 /* Invalid disk set, or mirror couldn't be created */
963 /* volume_set_error already called */
967 /* Stop after the global (NULL) disk set has been searched */
968 } while (disksets
[i
++] != NULL
);
974 * Set the default HSP creation flag for concatenated volumes
977 * a defaults_t hierarchy representing default settings
978 * for all disk sets and specific disk sets
981 * the name of the disk set to which to apply this
982 * default setting, or NULL to apply default
983 * setting to all disk sets
986 * the value to set as the default HSP creation flag for
987 * concatenated volumes
993 * if an error occurred. Use get_error_string() to
994 * retrieve the associated error message.
997 defaults_set_concat_usehsp(
998 defaults_t
*defaults
,
1002 devconfig_t
*concat
= NULL
;
1005 /* Get/create singleton concat element for this disk set */
1006 if ((error
= defaults_get_singleton_component(
1007 defaults
, diskset
, TYPE_CONCAT
, &concat
, TRUE
)) != 0) {
1008 /* volume_set_error already called */
1012 /* Set the usehsp attribute */
1013 return (devconfig_set_volume_usehsp(concat
, val
));
1017 * Get the default HSP creation flag for concatenated volumes
1020 * a defaults_t hierarchy representing default settings
1021 * for all disk sets and specific disk sets
1024 * the name of the disk set to which to apply this
1025 * default setting, or NULL to apply default
1026 * setting to all disk sets
1029 * RETURN: the default HSP creation flag for concatenated
1036 * if an error occurred. Use get_error_string() to
1037 * retrieve the associated error message.
1040 defaults_get_concat_usehsp(
1041 defaults_t
*defaults
,
1046 devconfig_t
*concat
;
1050 /* Check both the given and global (NULL) disk sets for the value */
1051 disksets
[0] = diskset
;
1054 /* Get/create singleton concat element for this disk set */
1055 error
= defaults_get_singleton_component(
1056 defaults
, disksets
[i
], TYPE_CONCAT
, &concat
, FALSE
);
1059 /* concat found for this disk set */
1061 /* Get the usehsp attribute */
1062 if ((error
= devconfig_get_volume_usehsp(
1063 concat
, val
)) == 0) {
1064 /* usehsp attribute found */
1070 /* concat not found for this disk set */
1074 /* Invalid disk set, or concat couldn't be created */
1076 /* volume_set_error already called */
1080 /* Stop after the global (NULL) disk set has been searched */
1081 } while (disksets
[i
++] != NULL
);
1087 * Set the default minimum number of components for striped volumes
1090 * a defaults_t hierarchy representing default settings
1091 * for all disk sets and specific disk sets
1094 * the name of the disk set to which to apply this
1095 * default setting, or NULL to apply default
1096 * setting to all disk sets
1099 * the value to set as the default minimum number of
1100 * components for striped volumes
1106 * if an error occurred. Use get_error_string() to
1107 * retrieve the associated error message.
1110 defaults_set_stripe_mincomp(
1111 defaults_t
*defaults
,
1115 devconfig_t
*stripe
= NULL
;
1118 /* Get/create singleton stripe element for this disk set */
1119 if ((error
= defaults_get_singleton_component(
1120 defaults
, diskset
, TYPE_STRIPE
, &stripe
, TRUE
)) != 0) {
1121 /* volume_set_error already called */
1125 /* Set the mincomp attribute */
1126 return (devconfig_set_stripe_mincomp(stripe
, val
));
1130 * Get the default minimum number of components for striped volumes
1133 * a defaults_t hierarchy representing default settings
1134 * for all disk sets and specific disk sets
1137 * the name of the disk set to which to apply this
1138 * default setting, or NULL to apply default
1139 * setting to all disk sets
1142 * RETURN: the default minimum number of components for
1149 * if an error occurred. Use get_error_string() to
1150 * retrieve the associated error message.
1153 defaults_get_stripe_mincomp(
1154 defaults_t
*defaults
,
1159 devconfig_t
*stripe
;
1163 /* Check both the given and global (NULL) disk sets for the value */
1164 disksets
[0] = diskset
;
1167 /* Get/create singleton stripe element for this disk set */
1168 error
= defaults_get_singleton_component(
1169 defaults
, disksets
[i
], TYPE_STRIPE
, &stripe
, FALSE
);
1172 /* stripe found for this disk set */
1174 /* Get the mincomp attribute */
1175 if ((error
= devconfig_get_stripe_mincomp(
1176 stripe
, val
)) == 0) {
1177 /* mincomp attribute found */
1183 /* stripe not found for this disk set */
1187 /* Invalid disk set, or stripe couldn't be created */
1189 /* volume_set_error already called */
1193 /* Stop after the global (NULL) disk set has been searched */
1194 } while (disksets
[i
++] != NULL
);
1200 * Set the default maximum number of components for striped volumes
1203 * a defaults_t hierarchy representing default settings
1204 * for all disk sets and specific disk sets
1207 * the name of the disk set to which to apply this
1208 * default setting, or NULL to apply default
1209 * setting to all disk sets
1212 * the value to set as the default maximum number of
1213 * components for striped volumes
1219 * if an error occurred. Use get_error_string() to
1220 * retrieve the associated error message.
1223 defaults_set_stripe_maxcomp(
1224 defaults_t
*defaults
,
1228 devconfig_t
*stripe
= NULL
;
1231 /* Get/create singleton stripe element for this disk set */
1232 if ((error
= defaults_get_singleton_component(
1233 defaults
, diskset
, TYPE_STRIPE
, &stripe
, TRUE
)) != 0) {
1234 /* volume_set_error already called */
1238 /* Set the maxcomp attribute */
1239 return (devconfig_set_stripe_maxcomp(stripe
, val
));
1243 * Get the default maximum number of components for striped volumes
1246 * a defaults_t hierarchy representing default settings
1247 * for all disk sets and specific disk sets
1250 * the name of the disk set to which to apply this
1251 * default setting, or NULL to apply default
1252 * setting to all disk sets
1255 * RETURN: the default maximum number of components for
1262 * if an error occurred. Use get_error_string() to
1263 * retrieve the associated error message.
1266 defaults_get_stripe_maxcomp(
1267 defaults_t
*defaults
,
1272 devconfig_t
*stripe
;
1276 /* Check both the given and global (NULL) disk sets for the value */
1277 disksets
[0] = diskset
;
1280 /* Get/create singleton stripe element for this disk set */
1281 error
= defaults_get_singleton_component(
1282 defaults
, disksets
[i
], TYPE_STRIPE
, &stripe
, FALSE
);
1285 /* stripe found for this disk set */
1287 /* Get the maxcomp attribute */
1288 if ((error
= devconfig_get_stripe_maxcomp(
1289 stripe
, val
)) == 0) {
1290 /* maxcomp attribute found */
1296 /* stripe not found for this disk set */
1300 /* Invalid disk set, or stripe couldn't be created */
1302 /* volume_set_error already called */
1306 /* Stop after the global (NULL) disk set has been searched */
1307 } while (disksets
[i
++] != NULL
);
1313 * Set the default interlace for striped volumes
1316 * a defaults_t hierarchy representing default settings
1317 * for all disk sets and specific disk sets
1320 * the name of the disk set to which to apply this
1321 * default setting, or NULL to apply default
1322 * setting to all disk sets
1325 * the value to set as the default interlace for striped
1332 * if an error occurred. Use get_error_string() to
1333 * retrieve the associated error message.
1336 defaults_set_stripe_interlace(
1337 defaults_t
*defaults
,
1341 devconfig_t
*stripe
= NULL
;
1344 /* Get/create singleton stripe element for this disk set */
1345 if ((error
= defaults_get_singleton_component(
1346 defaults
, diskset
, TYPE_STRIPE
, &stripe
, TRUE
)) != 0) {
1347 /* volume_set_error already called */
1351 /* Set the interlace attribute */
1352 return (devconfig_set_stripe_interlace(stripe
, val
));
1356 * Get the default interlace for striped volumes
1359 * a defaults_t hierarchy representing default settings
1360 * for all disk sets and specific disk sets
1363 * the name of the disk set to which to apply this
1364 * default setting, or NULL to apply default
1365 * setting to all disk sets
1368 * RETURN: the default interlace for striped volumes
1374 * if an error occurred. Use get_error_string() to
1375 * retrieve the associated error message.
1378 defaults_get_stripe_interlace(
1379 defaults_t
*defaults
,
1384 devconfig_t
*stripe
;
1388 /* Check both the given and global (NULL) disk sets for the value */
1389 disksets
[0] = diskset
;
1392 /* Get/create singleton stripe element for this disk set */
1393 error
= defaults_get_singleton_component(
1394 defaults
, disksets
[i
], TYPE_STRIPE
, &stripe
, FALSE
);
1397 /* stripe found for this disk set */
1399 /* Get the interlace attribute */
1400 if ((error
= devconfig_get_stripe_interlace(
1401 stripe
, val
)) == 0) {
1402 /* interlace attribute found */
1408 /* stripe not found for this disk set */
1412 /* Invalid disk set, or stripe couldn't be created */
1414 /* volume_set_error already called */
1418 /* Stop after the global (NULL) disk set has been searched */
1419 } while (disksets
[i
++] != NULL
);
1425 * Set the default HSP creation flag for striped volumes
1428 * a defaults_t hierarchy representing default settings
1429 * for all disk sets and specific disk sets
1432 * the name of the disk set to which to apply this
1433 * default setting, or NULL to apply default
1434 * setting to all disk sets
1437 * the value to set as the default HSP creation flag for
1444 * if an error occurred. Use get_error_string() to
1445 * retrieve the associated error message.
1448 defaults_set_stripe_usehsp(
1449 defaults_t
*defaults
,
1453 devconfig_t
*stripe
= NULL
;
1456 /* Get/create singleton stripe element for this disk set */
1457 if ((error
= defaults_get_singleton_component(
1458 defaults
, diskset
, TYPE_STRIPE
, &stripe
, TRUE
)) != 0) {
1459 /* volume_set_error already called */
1463 /* Set the usehsp attribute */
1464 return (devconfig_set_volume_usehsp(stripe
, val
));
1468 * Get the default HSP creation flag for striped volumes
1471 * a defaults_t hierarchy representing default settings
1472 * for all disk sets and specific disk sets
1475 * the name of the disk set to which to apply this
1476 * default setting, or NULL to apply default
1477 * setting to all disk sets
1480 * RETURN: the default HSP creation flag for striped
1487 * if an error occurred. Use get_error_string() to
1488 * retrieve the associated error message.
1491 defaults_get_stripe_usehsp(
1492 defaults_t
*defaults
,
1497 devconfig_t
*stripe
;
1501 /* Check both the given and global (NULL) disk sets for the value */
1502 disksets
[0] = diskset
;
1505 /* Get/create singleton stripe element for this disk set */
1506 error
= defaults_get_singleton_component(
1507 defaults
, disksets
[i
], TYPE_STRIPE
, &stripe
, FALSE
);
1510 /* stripe found for this disk set */
1512 /* Get the usehsp attribute */
1513 if ((error
= devconfig_get_volume_usehsp(
1514 stripe
, val
)) == 0) {
1515 /* usehsp attribute found */
1521 /* stripe not found for this disk set */
1525 /* Invalid disk set, or stripe couldn't be created */
1527 /* volume_set_error already called */
1531 /* Stop after the global (NULL) disk set has been searched */
1532 } while (disksets
[i
++] != NULL
);
1538 * Set the default redundancy level for generic volumes.
1541 * a defaults_t hierarchy representing default settings
1542 * for all disk sets and specific disk sets
1545 * the name of the disk set to which to apply this
1546 * default setting, or NULL to apply default
1547 * setting to all disk sets
1550 * If 0, a stripe will be created by default. If > 0, a
1551 * mirror with this number of submirrors will be created
1558 * if an error occurred. Use get_error_string() to
1559 * retrieve the associated error message.
1562 defaults_set_volume_redundancy_level(
1563 defaults_t
*defaults
,
1567 devconfig_t
*volume
= NULL
;
1570 /* Get/create singleton volume element for this disk set */
1571 if ((error
= defaults_get_singleton_component(
1572 defaults
, diskset
, TYPE_VOLUME
, &volume
, TRUE
)) != 0) {
1573 /* volume_set_error already called */
1577 /* Set the redundancy level */
1578 return (devconfig_set_volume_redundancy_level(volume
, val
));
1582 * Get the default redundancy level for generic volumes.
1585 * a defaults_t hierarchy representing default settings
1586 * for all disk sets and specific disk sets
1589 * the name of the disk set to which to apply this
1590 * default setting, or NULL to apply default
1591 * setting to all disk sets
1594 * RETURN: the default redundancy level for generic
1601 * if an error occurred. Use get_error_string() to
1602 * retrieve the associated error message.
1605 defaults_get_volume_redundancy_level(
1606 defaults_t
*defaults
,
1611 devconfig_t
*volume
;
1615 /* Check both the given and global (NULL) disk sets for the value */
1616 disksets
[0] = diskset
;
1619 /* Get/create singleton volume element for this disk set */
1620 error
= defaults_get_singleton_component(
1621 defaults
, disksets
[i
], TYPE_VOLUME
, &volume
, FALSE
);
1624 /* volume found for this disk set */
1626 /* Get the redundancy level */
1627 if ((error
= devconfig_get_volume_redundancy_level(
1628 volume
, val
)) == 0) {
1629 /* redundancy level found */
1635 /* volume not found for this disk set */
1639 /* Invalid disk set, or volume couldn't be created */
1641 /* volume_set_error already called */
1645 /* Stop after the global (NULL) disk set has been searched */
1646 } while (disksets
[i
++] != NULL
);
1652 * Set the default number of data paths for generic volume
1655 * a defaults_t hierarchy representing default settings
1656 * for all disk sets and specific disk sets
1659 * the name of the disk set to which to apply this
1660 * default setting, or NULL to apply default
1661 * setting to all disk sets
1664 * the value to set as the default number of data paths
1665 * for generic volume
1671 * if an error occurred. Use get_error_string() to
1672 * retrieve the associated error message.
1675 defaults_set_volume_npaths(
1676 defaults_t
*defaults
,
1680 devconfig_t
*volume
= NULL
;
1683 /* Get/create singleton volume element for this disk set */
1684 if ((error
= defaults_get_singleton_component(
1685 defaults
, diskset
, TYPE_VOLUME
, &volume
, TRUE
)) != 0) {
1686 /* volume_set_error already called */
1690 /* Set the npaths attribute */
1691 return (devconfig_set_volume_npaths(volume
, val
));
1695 * Get the default number of data paths for generic volume
1698 * a defaults_t hierarchy representing default settings
1699 * for all disk sets and specific disk sets
1702 * the name of the disk set to which to apply this
1703 * default setting, or NULL to apply default
1704 * setting to all disk sets
1707 * RETURN: the default number of data paths for generic
1714 * if an error occurred. Use get_error_string() to
1715 * retrieve the associated error message.
1718 defaults_get_volume_npaths(
1719 defaults_t
*defaults
,
1724 devconfig_t
*volume
;
1728 /* Check both the given and global (NULL) disk sets for the value */
1729 disksets
[0] = diskset
;
1732 /* Get/create singleton volume element for this disk set */
1733 error
= defaults_get_singleton_component(
1734 defaults
, disksets
[i
], TYPE_VOLUME
, &volume
, FALSE
);
1737 /* volume found for this disk set */
1739 /* Get the npaths attribute */
1740 if ((error
= devconfig_get_volume_npaths(
1741 volume
, val
)) == 0) {
1742 /* npaths attribute found */
1748 /* volume not found for this disk set */
1752 /* Invalid disk set, or volume couldn't be created */
1754 /* volume_set_error already called */
1758 /* Stop after the global (NULL) disk set has been searched */
1759 } while (disksets
[i
++] != NULL
);
1765 * Set the default HSP creation flag for generic volume
1768 * a defaults_t hierarchy representing default settings
1769 * for all disk sets and specific disk sets
1772 * the name of the disk set to which to apply this
1773 * default setting, or NULL to apply default
1774 * setting to all disk sets
1777 * the value to set as the default HSP creation flag for
1784 * if an error occurred. Use get_error_string() to
1785 * retrieve the associated error message.
1788 defaults_set_volume_usehsp(
1789 defaults_t
*defaults
,
1793 devconfig_t
*volume
= NULL
;
1796 /* Get/create singleton volume element for this disk set */
1797 if ((error
= defaults_get_singleton_component(
1798 defaults
, diskset
, TYPE_VOLUME
, &volume
, TRUE
)) != 0) {
1799 /* volume_set_error already called */
1803 /* Set the usehsp attribute */
1804 return (devconfig_set_volume_usehsp(volume
, val
));
1808 * Get the default HSP creation flag for generic volume
1811 * a defaults_t hierarchy representing default settings
1812 * for all disk sets and specific disk sets
1815 * the name of the disk set to which to apply this
1816 * default setting, or NULL to apply default
1817 * setting to all disk sets
1820 * RETURN: the default HSP creation flag for generic
1827 * if an error occurred. Use get_error_string() to
1828 * retrieve the associated error message.
1831 defaults_get_volume_usehsp(
1832 defaults_t
*defaults
,
1837 devconfig_t
*volume
;
1841 /* Check both the given and global (NULL) disk sets for the value */
1842 disksets
[0] = diskset
;
1845 /* Get/create singleton volume element for this disk set */
1846 error
= defaults_get_singleton_component(
1847 defaults
, disksets
[i
], TYPE_VOLUME
, &volume
, FALSE
);
1850 /* volume found for this disk set */
1852 /* Get the usehsp attribute */
1853 if ((error
= devconfig_get_volume_usehsp(
1854 volume
, val
)) == 0) {
1855 /* usehsp attribute found */
1861 /* volume not found for this disk set */
1865 /* Invalid disk set, or volume couldn't be created */
1867 /* volume_set_error already called */
1871 /* Stop after the global (NULL) disk set has been searched */
1872 } while (disksets
[i
++] != NULL
);