xref: /titanic_41/usr/src/cmd/lvm/metassist/common/volume_devconfig.h (revision e4d060fb4c00d44cd578713eb9a921f594b733b8)
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_DEVCONFIG_H
28 #define	_VOLUME_DEVCONFIG_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 #include <libnvpair.h>
37 #include "volume_dlist.h"
38 #include <sys/lvm/md_mdiox.h>
39 
40 /*
41  * String constants for XML element/attribute names.
42  */
43 #define	ELEMENT_AVAILABLE		"available"
44 #define	ELEMENT_COMMENT			"comment"
45 #define	ELEMENT_CONCAT			"concat"
46 #define	ELEMENT_DISK			"disk"
47 #define	ELEMENT_DISKSET			"diskset"
48 #define	ELEMENT_HSP			"hsp"
49 #define	ELEMENT_L10N			"localization"
50 #define	ELEMENT_MESSAGE			"message"
51 #define	ELEMENT_MIRROR			"mirror"
52 #define	ELEMENT_PARAM			"param"
53 #define	ELEMENT_SLICE			"slice"
54 #define	ELEMENT_STRIPE			"stripe"
55 #define	ELEMENT_TEXT			"text"
56 #define	ELEMENT_UNAVAILABLE		"unavailable"
57 #define	ELEMENT_VARIABLE		"variable"
58 #define	ELEMENT_VOLUME			"volume"
59 #define	ELEMENT_VOLUMECONFIG		"volume-config"
60 #define	ELEMENT_VOLUMEDEFAULTS		"volume-defaults"
61 #define	ELEMENT_VOLUMEREQUEST		"volume-request"
62 
63 #define	ATTR_LANG			"xml:lang"
64 #define	ATTR_MESSAGEID			"msgid"
65 #define	ATTR_MIRROR_NSUBMIRRORS		"nsubmirrors"
66 #define	ATTR_MIRROR_PASSNUM		"passnum"
67 #define	ATTR_MIRROR_READ		"read"
68 #define	ATTR_MIRROR_WRITE		"write"
69 #define	ATTR_NAME			"name"
70 #define	ATTR_SELECT			"select"
71 #define	ATTR_SIZEINBLOCKS		"sizeinblocks"
72 #define	ATTR_SIZEINBYTES		"size"
73 #define	ATTR_SLICE_INDEX		"index"
74 #define	ATTR_SLICE_STARTSECTOR		"startsector"
75 #define	ATTR_STRIPE_INTERLACE		"interlace"
76 #define	ATTR_STRIPE_MAXCOMP		"maxcomp"
77 #define	ATTR_STRIPE_MINCOMP		"mincomp"
78 #define	ATTR_TYPE			"type"
79 #define	ATTR_VOLUME_CREATE		"create"
80 #define	ATTR_VOLUME_DATAPATHS		"datapaths"
81 #define	ATTR_VOLUME_FAULTRECOVERY	"faultrecovery"
82 #define	ATTR_VOLUME_REDUNDANCY		"redundancy"
83 #define	ATTR_VOLUME_USEHSP		"usehsp"
84 
85 #define	NAME_L10N_MESSAGE_FILE		"msgfile"
86 #define	NAME_LANG			"lang"
87 
88 /*
89  * Limits for attributes
90  */
91 #define	MIN_NSTRIPE_COMP	1
92 #define	MIN_SIZE		0
93 #define	MIN_SIZE_IN_BLOCKS	0
94 #define	MIN_NDATAPATHS		1
95 #define	MAX_NDATAPATHS		4
96 
97 /* Attribute requested but not set */
98 #define	ERR_ATTR_UNSET	-10001
99 
100 /*
101  * Enumeration defining physical or logical device types
102  */
103 typedef enum {
104 	TYPE_UNKNOWN = 0,
105 	TYPE_CONCAT = 1,
106 	TYPE_CONTROLLER,
107 	TYPE_DISKSET,
108 	TYPE_DRIVE,
109 	TYPE_EXTENT,
110 	TYPE_HOST,
111 	TYPE_HSP,
112 	TYPE_MIRROR,
113 	TYPE_RAID5,
114 	TYPE_SLICE,
115 	TYPE_SOFTPART,
116 	TYPE_STRIPE,
117 	TYPE_TRANS,
118 	TYPE_VOLUME
119 } component_type_t;
120 
121 /*
122  * enumerated constants for SVM Mirror read strategies
123  */
124 typedef enum {
125 	MIRROR_READ_ROUNDROBIN = 0,
126 	MIRROR_READ_GEOMETRIC,
127 	MIRROR_READ_FIRST
128 } mirror_read_strategy_t;
129 
130 /*
131  * enumerated constants for SVM Mirror write strategies
132  */
133 typedef enum {
134 	MIRROR_WRITE_PARALLEL = 0,
135 	MIRROR_WRITE_SERIAL
136 } mirror_write_strategy_t;
137 
138 /*
139  * devconfig_t - struct to hold a device configuration hierarchy
140  */
141 typedef struct devconfig {
142 
143 	/* Attributes of this device */
144 	nvlist_t *attributes;
145 
146 	/*
147 	 * Available devices for use in construction of this device
148 	 * and its subcomponents
149 	 */
150 	char **available;
151 
152 	/*
153 	 * Unavailable devices for use in construction of this device
154 	 * and its subcomponents
155 	 */
156 	char **unavailable;
157 
158 	/*
159 	 * Subcomponents (devconfig_t) of this device
160 	 */
161 	dlist_t *components;
162 } devconfig_t;
163 
164 /*
165  * Function prototypes
166  */
167 
168 /*
169  * Constructor: Create a devconfig_t struct.  This devconfig_t must be
170  * freed with free_devconfig().
171  *
172  * @param       devconfig
173  *              RETURN: a new devconfig_t
174  *
175  * @param       type
176  *              the type of devconfig_t to create
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 new_devconfig(devconfig_t **devconfig, component_type_t type);
186 
187 /*
188  * Free memory (recursively) allocated to a devconfig_t struct
189  *
190  * @param       arg
191  *              pointer to the devconfig_t to be freed
192  */
193 extern void free_devconfig(void *arg);
194 
195 /*
196  * Check the type of the given device.
197  *
198  * @param       device
199  *              the device whose type to check
200  *
201  * @param       type
202  *              the type of the device against which to compare
203  *
204  * @return      B_TRUE if the device is of the given type, B_FALSE
205  *              otherwise
206  */
207 extern boolean_t devconfig_isA(devconfig_t *device, component_type_t type);
208 
209 /*
210  * Get the first component of the given type from the given
211  * devconfig_t.  Create the component if create is B_TRUE.
212  *
213  * @return      ENOENT
214  *              if the requested component does not exist and its
215  *              creation was not requested
216  *
217  * @return      0
218  *              if the requested component exists or was created
219  *
220  * @return      non-zero
221  *              if the requested component did not exist and could not
222  *              be created
223  */
224 extern int devconfig_get_component(devconfig_t *device,
225 	component_type_t type, devconfig_t **component, boolean_t create);
226 
227 /*
228  * Set the available devices for use in creating this device
229  *
230  * @param       device
231  *              a devconfig_t representing the device to modify
232  *
233  * @param       available
234  *              A NULL-terminated array of device names
235  */
236 extern void devconfig_set_available(devconfig_t *device, char **available);
237 
238 /*
239  * Get the available devices for use in creating this device
240  *
241  * @param       device
242  *              a devconfig_t representing the device to examine
243  *
244  * @return      available
245  *              A NULL-terminated array of device names
246  */
247 extern char ** devconfig_get_available(devconfig_t *device);
248 
249 /*
250  * Set the unavailable devices which may not be used in creating this
251  * device
252  *
253  * @param       device
254  *              a devconfig_t representing the device to modify
255  *
256  * @param       available
257  *              A NULL-terminated array of device names
258  */
259 extern void devconfig_set_unavailable(devconfig_t *device, char **unavailable);
260 
261 /*
262  * Get the unavailable devices for use in creating this device
263  *
264  * @param       device
265  *              a devconfig_t representing the device to examine
266  *
267  * @return      unavailable
268  *              A NULL-terminated array of device names
269  */
270 extern char ** devconfig_get_unavailable(devconfig_t *device);
271 
272 /*
273  * Set the subcomponent devices of a given device
274  *
275  * @param       device
276  *              a devconfig_t representing the device to examine
277  *
278  * @param       components
279  *              A dlist_t containing devconfig_t devices
280  */
281 extern void devconfig_set_components(devconfig_t *device, dlist_t *components);
282 
283 /*
284  * Get the subcomponent devices of a given device
285  *
286  * @param       device
287  *              a devconfig_t representing the device to examine
288  *
289  * @return      A dlist_t containing devconfig_t devices
290  */
291 extern dlist_t *devconfig_get_components(devconfig_t *device);
292 
293 /*
294  * Set the device name
295  *
296  * @param       device
297  *              a devconfig_t representing the device to modify
298  *
299  * @param       name
300  *              the value to set as the device name
301  *
302  * @return      0
303  *              if successful
304  *
305  * @return      non-zero
306  *              if an error occurred.  Use get_error_string() to
307  *              retrieve the associated error message.
308  */
309 extern int devconfig_set_name(devconfig_t *device, char *name);
310 
311 /*
312  * Set the disk set name
313  *
314  * @param       diskset
315  *              a devconfig_t representing the diskset to modify
316  *
317  * @param       name
318  *              the value to set as the device name
319  *
320  * @return      0
321  *              if successful
322  *
323  * @return      non-zero
324  *              if an error occurred.  Use get_error_string() to
325  *              retrieve the associated error message.
326  */
327 extern int devconfig_set_diskset_name(devconfig_t *diskset, char *name);
328 
329 /*
330  * Set the device name
331  *
332  * @param       hsp
333  *              a devconfig_t representing the hsp to modify
334  *
335  * @param       name
336  *              the value to set as the device name
337  *
338  * @return      0
339  *              if successful
340  *
341  * @return      non-zero
342  *              if an error occurred.  Use get_error_string() to
343  *              retrieve the associated error message.
344  */
345 extern int devconfig_set_hsp_name(devconfig_t *hsp, char *name);
346 
347 /*
348  * Set the device name
349  *
350  * @param       volume
351  *              a devconfig_t representing the volume to modify
352  *
353  * @param       name
354  *              the value to set as the device name
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 devconfig_set_volume_name(devconfig_t *volume, char *name);
364 
365 /*
366  * Get the device name
367  *
368  * @param       volume
369  *              a devconfig_t representing the volume to examine
370  *
371  * @param       name
372  *              RETURN: the device name
373  *
374  * @return      0
375  *              if successful
376  *
377  * @return      non-zero
378  *              if an error occurred.  Use get_error_string() to
379  *              retrieve the associated error message.
380  */
381 extern int devconfig_get_name(devconfig_t *device, char **name);
382 
383 /*
384  * Set the device type
385  *
386  * @param       device
387  *              a devconfig_t representing the device to modify
388  *
389  * @param       type
390  *              the value to set as the device type
391  *
392  * @return      0
393  *              if successful
394  *
395  * @return      non-zero
396  *              if an error occurred.  Use get_error_string() to
397  *              retrieve the associated error message.
398  */
399 extern int devconfig_set_type(devconfig_t *device, component_type_t type);
400 
401 /*
402  * Get the device type
403  *
404  * @param       device
405  *              a devconfig_t representing the device to examine
406  *
407  * @param       type
408  *              RETURN: the device type
409  *
410  * @return      0
411  *              if successful
412  *
413  * @return      non-zero
414  *              if an error occurred.  Use get_error_string() to
415  *              retrieve the associated error message.
416  */
417 extern int devconfig_get_type(devconfig_t *device, component_type_t *type);
418 
419 /*
420  * Set the device size (for volume, mirror, stripe, concat) in bytes
421  *
422  * Note that size in bytes in a 64-bit field cannot hold the size that
423  * can be accessed in a 16 byte CDB.  Since CDBs operate on blocks,
424  * the max capacity is 2^73 bytes with 512 byte blocks.
425  *
426  * @param       device
427  *              a devconfig_t representing the device to modify
428  *
429  * @param       size_in_bytes
430  *              the value to set as the device size in bytes
431  *
432  * @return      0
433  *              if successful
434  *
435  * @return      non-zero
436  *              if an error occurred.  Use get_error_string() to
437  *              retrieve the associated error message.
438  */
439 extern int devconfig_set_size(devconfig_t *device, uint64_t size_in_bytes);
440 
441 /*
442  * Get the device size (for volume, mirror, stripe, concat) in bytes
443  *
444  * Note that size in bytes in a 64-bit field cannot hold the size that
445  * can be accessed in a 16 byte CDB.  Since CDBs operate on blocks,
446  * the max capacity is 2^73 bytes with 512 byte blocks.
447  *
448  * @param       device
449  *              a devconfig_t representing the device to examine
450  *
451  * @param       size_in_bytes
452  *              RETURN: the device size in bytes
453  *
454  * @return      0
455  *              if successful
456  *
457  * @return      non-zero
458  *              if an error occurred.  Use get_error_string() to
459  *              retrieve the associated error message.
460  */
461 extern int devconfig_get_size(devconfig_t *device, uint64_t *size_in_bytes);
462 
463 /*
464  * Set the device size in blocks
465  *
466  * @param       device
467  *              a devconfig_t representing the device to modify
468  *
469  * @param       type
470  *              the value to set as the device size in blocks
471  *
472  * @return      0
473  *              if successful
474  *
475  * @return      non-zero
476  *              if an error occurred.  Use get_error_string() to
477  *              retrieve the associated error message.
478  */
479 extern int devconfig_set_size_in_blocks(
480 	devconfig_t *device, uint64_t size_in_blocks);
481 
482 /*
483  * Get the device size in blocks
484  *
485  * @param       device
486  *              a devconfig_t representing the device to examine
487  *
488  * @param       size_in_blocks
489  *              RETURN: the device size in blocks
490  *
491  * @return      0
492  *              if successful
493  *
494  * @return      non-zero
495  *              if an error occurred.  Use get_error_string() to
496  *              retrieve the associated error message.
497  */
498 extern int devconfig_get_size_in_blocks(
499 	devconfig_t *device, uint64_t *size_in_blocks);
500 
501 /*
502  * Set the the slice index
503  *
504  * @param       slice
505  *              a devconfig_t representing the slice to modify
506  *
507  * @param       index
508  *              the value to set as the the slice index
509  *
510  * @return      0
511  *              if successful
512  *
513  * @return      non-zero
514  *              if an error occurred.  Use get_error_string() to
515  *              retrieve the associated error message.
516  */
517 extern int devconfig_set_slice_index(devconfig_t *slice, uint16_t index);
518 
519 /*
520  * Get the slice index
521  *
522  * @param       device
523  *              a devconfig_t representing the device to examine
524  *
525  * @param       index
526  *              RETURN: the slice index
527  *
528  * @return      0
529  *              if successful
530  *
531  * @return      non-zero
532  *              if an error occurred.  Use get_error_string() to
533  *              retrieve the associated error message.
534  */
535 extern int devconfig_get_slice_index(devconfig_t *slice, uint16_t *index);
536 
537 /*
538  * Set the the slice start block
539  *
540  * @param       slice
541  *              a devconfig_t representing the slice to modify
542  *
543  * @param       start_block
544  *              the value to set as the the slice start block
545  *
546  * @return      0
547  *              if successful
548  *
549  * @return      non-zero
550  *              if an error occurred.  Use get_error_string() to
551  *              retrieve the associated error message.
552  */
553 extern int devconfig_set_slice_start_block(
554 	devconfig_t *slice, uint64_t start_block);
555 
556 /*
557  * Get the slice start block
558  *
559  * @param       device
560  *              a devconfig_t representing the device to examine
561  *
562  * @param       start_block
563  *              RETURN: the slice start block
564  *
565  * @return      0
566  *              if successful
567  *
568  * @return      non-zero
569  *              if an error occurred.  Use get_error_string() to
570  *              retrieve the associated error message.
571  */
572 extern int devconfig_get_slice_start_block(
573 	devconfig_t *slice, uint64_t *start_block);
574 
575 /*
576  * Set the number of subcomponents in mirror
577  *
578  * @param       mirror
579  *              a devconfig_t representing the mirror to modify
580  *
581  * @param       nsubs
582  *              the value to set as the number of subcomponents in
583  *              mirror
584  *
585  * @return      0
586  *              if successful
587  *
588  * @return      non-zero
589  *              if an error occurred.  Use get_error_string() to
590  *              retrieve the associated error message.
591  */
592 extern int devconfig_set_mirror_nsubs(devconfig_t *mirror, uint16_t nsubs);
593 
594 /*
595  * Get number of subcomponents in mirror
596  *
597  * @param       device
598  *              a devconfig_t representing the device to examine
599  *
600  * @param       nsubs
601  *              RETURN: number of subcomponents in mirror
602  *
603  * @return      0
604  *              if successful
605  *
606  * @return      non-zero
607  *              if an error occurred.  Use get_error_string() to
608  *              retrieve the associated error message.
609  */
610 extern int devconfig_get_mirror_nsubs(devconfig_t *mirror, uint16_t *nsubs);
611 
612 /*
613  * Set the read strategy for mirror
614  *
615  * @param       mirror
616  *              a devconfig_t representing the mirror to modify
617  *
618  * @param       read
619  *              the value to set as the read strategy for mirror
620  *
621  * @return      0
622  *              if successful
623  *
624  * @return      non-zero
625  *              if an error occurred.  Use get_error_string() to
626  *              retrieve the associated error message.
627  */
628 extern int devconfig_set_mirror_read(
629 	devconfig_t *mirror, mirror_read_strategy_t read);
630 
631 /*
632  * Get read strategy for mirror
633  *
634  * @param       device
635  *              a devconfig_t representing the device to examine
636  *
637  * @param       read
638  *              RETURN: read strategy for mirror
639  *
640  * @return      0
641  *              if successful
642  *
643  * @return      non-zero
644  *              if an error occurred.  Use get_error_string() to
645  *              retrieve the associated error message.
646  */
647 extern int devconfig_get_mirror_read(
648 	devconfig_t *mirror, mirror_read_strategy_t *read);
649 
650 /*
651  * Set the write strategy for mirror
652  *
653  * @param       mirror
654  *              a devconfig_t representing the mirror to modify
655  *
656  * @param       write
657  *              the value to set as the write strategy for mirror
658  *
659  * @return      0
660  *              if successful
661  *
662  * @return      non-zero
663  *              if an error occurred.  Use get_error_string() to
664  *              retrieve the associated error message.
665  */
666 extern int devconfig_set_mirror_write(
667 	devconfig_t *mirror, mirror_write_strategy_t write);
668 
669 /*
670  * Get write strategy for mirror
671  *
672  * @param       device
673  *              a devconfig_t representing the device to examine
674  *
675  * @param       write
676  *              RETURN: write strategy for mirror
677  *
678  * @return      0
679  *              if successful
680  *
681  * @return      non-zero
682  *              if an error occurred.  Use get_error_string() to
683  *              retrieve the associated error message.
684  */
685 extern int devconfig_get_mirror_write(
686 	devconfig_t *mirror, mirror_write_strategy_t *write);
687 
688 /*
689  * Set the resync pass for mirror
690  *
691  * @param       mirror
692  *              a devconfig_t representing the mirror to modify
693  *
694  * @param       pass
695  *              the value to set as the resync pass for mirror
696  *
697  * @return      0
698  *              if successful
699  *
700  * @return      non-zero
701  *              if an error occurred.  Use get_error_string() to
702  *              retrieve the associated error message.
703  */
704 extern int devconfig_set_mirror_pass(devconfig_t *mirror, uint16_t pass);
705 
706 /*
707  * Get resync pass for mirror
708  *
709  * @param       device
710  *              a devconfig_t representing the device to examine
711  *
712  * @param       pass
713  *              RETURN: resync pass for mirror
714  *
715  * @return      0
716  *              if successful
717  *
718  * @return      non-zero
719  *              if an error occurred.  Use get_error_string() to
720  *              retrieve the associated error message.
721  */
722 extern int devconfig_get_mirror_pass(devconfig_t *mirror, uint16_t *pass);
723 
724 /*
725  * Set the minimum number of components in stripe
726  *
727  * @param       stripe
728  *              a devconfig_t representing the stripe to modify
729  *
730  * @param       mincomp
731  *              the value to set as the minimum number of components
732  *              in stripe
733  *
734  * @return      0
735  *              if successful
736  *
737  * @return      non-zero
738  *              if an error occurred.  Use get_error_string() to
739  *              retrieve the associated error message.
740  */
741 extern int devconfig_set_stripe_mincomp(devconfig_t *stripe, uint16_t mincomp);
742 
743 /*
744  * Get minimum number of components in stripe
745  *
746  * @param       device
747  *              a devconfig_t representing the device to examine
748  *
749  * @param       mincomp
750  *              RETURN: minimum number of components in stripe
751  *
752  * @return      0
753  *              if successful
754  *
755  * @return      non-zero
756  *              if an error occurred.  Use get_error_string() to
757  *              retrieve the associated error message.
758  */
759 extern int devconfig_get_stripe_mincomp(devconfig_t *stripe, uint16_t *mincomp);
760 
761 /*
762  * Set the maximum number of components in stripe
763  *
764  * @param       stripe
765  *              a devconfig_t representing the stripe to modify
766  *
767  * @param       maxcomp
768  *              the value to set as the maximum number of components
769  *              in stripe
770  *
771  * @return      0
772  *              if successful
773  *
774  * @return      non-zero
775  *              if an error occurred.  Use get_error_string() to
776  *              retrieve the associated error message.
777  */
778 extern int devconfig_set_stripe_maxcomp(devconfig_t *stripe, uint16_t maxcomp);
779 
780 /*
781  * Get maximum number of components in stripe
782  *
783  * @param       device
784  *              a devconfig_t representing the device to examine
785  *
786  * @param       maxcomp
787  *              RETURN: maximum number of components in stripe
788  *
789  * @return      0
790  *              if successful
791  *
792  * @return      non-zero
793  *              if an error occurred.  Use get_error_string() to
794  *              retrieve the associated error message.
795  */
796 extern int devconfig_get_stripe_maxcomp(devconfig_t *stripe, uint16_t *maxcomp);
797 
798 /*
799  * Set the stripe interlace
800  *
801  * @param       stripe
802  *              a devconfig_t representing the stripe to modify
803  *
804  * @param       interlace
805  *              the value to set as the stripe interlace
806  *
807  * @return      0
808  *              if successful
809  *
810  * @return      non-zero
811  *              if an error occurred.  Use get_error_string() to
812  *              retrieve the associated error message.
813  */
814 extern int devconfig_set_stripe_interlace(
815 	devconfig_t *stripe, uint64_t interlace);
816 
817 /*
818  * Get stripe interlace
819  *
820  * @param       device
821  *              a devconfig_t representing the device to examine
822  *
823  * @param       interlace
824  *              RETURN: stripe interlace
825  *
826  * @return      0
827  *              if successful
828  *
829  * @return      non-zero
830  *              if an error occurred.  Use get_error_string() to
831  *              retrieve the associated error message.
832  */
833 extern int devconfig_get_stripe_interlace(
834 	devconfig_t *stripe, uint64_t *interlace);
835 
836 /*
837  * Set the redundancy level for a volume.
838  *
839  * @param       volume
840  *              a devconfig_t representing the volume to modify
841  *
842  * @param       rlevel
843  *              If 0, a stripe will be created.  If > 0, a mirror with
844  *              this number of submirrors will be created.
845  *
846  * @return      0
847  *              if successful
848  *
849  * @return      non-zero
850  *              if an error occurred.  Use get_error_string() to
851  *              retrieve the associated error message.
852  */
853 extern int devconfig_set_volume_redundancy_level(
854 	devconfig_t *volume, uint16_t rlevel);
855 
856 /*
857  * Get the redundancy level for a volume.
858  *
859  * @param       device
860  *              a devconfig_t representing the device to examine
861  *
862  * @param       rlevel
863  *              RETURN: the redundancy level for a volume
864  *
865  * @return      0
866  *              if successful
867  *
868  * @return      non-zero
869  *              if an error occurred.  Use get_error_string() to
870  *              retrieve the associated error message.
871  */
872 extern int devconfig_get_volume_redundancy_level(
873 	devconfig_t *volume, uint16_t *rlevel);
874 
875 /*
876  * Set the number of paths in volume
877  *
878  * @param       volume
879  *              a devconfig_t representing the volume to modify
880  *
881  * @param       npaths
882  *              the value to set as the number of paths in volume
883  *
884  * @return      0
885  *              if successful
886  *
887  * @return      non-zero
888  *              if an error occurred.  Use get_error_string() to
889  *              retrieve the associated error message.
890  */
891 extern int devconfig_set_volume_npaths(devconfig_t *volume, uint16_t npaths);
892 
893 /*
894  * Get number of paths in volume
895  *
896  * @param       device
897  *              a devconfig_t representing the device to examine
898  *
899  * @param       npaths
900  *              RETURN: number of paths in volume
901  *
902  * @return      0
903  *              if successful
904  *
905  * @return      non-zero
906  *              if an error occurred.  Use get_error_string() to
907  *              retrieve the associated error message.
908  */
909 extern int devconfig_get_volume_npaths(devconfig_t *volume, uint16_t *npaths);
910 
911 /*
912  * Set the HSP creation option (for volume, stripe, concat, mirror)
913  *
914  * @param       volume
915  *              a devconfig_t representing the volume to modify
916  *
917  * @param       usehsp
918  *              the value to set as the HSP creation option
919  *
920  * @return      0
921  *              if successful
922  *
923  * @return      non-zero
924  *              if an error occurred.  Use get_error_string() to
925  *              retrieve the associated error message.
926  */
927 extern int devconfig_set_volume_usehsp(devconfig_t *volume, boolean_t usehsp);
928 
929 /*
930  * Get HSP creation option (for volume, stripe, concat, mirror)
931  *
932  * @param       device
933  *              a devconfig_t representing the device to examine
934  *
935  * @param       usehsp
936  *              RETURN: HSP creation option (for volume, stripe,
937  *              concat, mirror)
938  *
939  * @return      0
940  *              if successful
941  *
942  * @return      non-zero
943  *              if an error occurred.  Use get_error_string() to
944  *              retrieve the associated error message.
945  */
946 extern int devconfig_get_volume_usehsp(devconfig_t *volume, boolean_t *usehsp);
947 
948 /*
949  * Get the string representation of the volume's type
950  *
951  * @param       type
952  *              a valid component_type_t
953  *
954  * @return      an internationalized string representing the given
955  *              type
956  */
957 extern char *devconfig_type_to_str(component_type_t type);
958 
959 /*
960  * Get the string representation of the mirror's read strategy
961  *
962  * @param       read
963  *              a valid mirror_read_strategy_t
964  *
965  * @return      an internationalized string representing the given
966  *              read strategy
967  */
968 extern char *devconfig_read_strategy_to_str(mirror_read_strategy_t read);
969 
970 /*
971  * Get the string representation of the mirror's write strategy
972  *
973  * @param       write
974  *              a valid mirror_write_strategy_t
975  *
976  * @return      an internationalized string representing the given
977  *              write strategy
978  */
979 extern char *devconfig_write_strategy_to_str(mirror_write_strategy_t write);
980 
981 #ifdef DEBUG
982 /*
983  * Dump the contents of a devconfig_t struct to stdout.
984  *
985  * @param       device
986  *              the devconfig_t to examine
987  *
988  * @param       prefix
989  *              a prefix string to print before each line
990  */
991 extern void devconfig_dump(devconfig_t *device, char *prefix);
992 #endif /* DEBUG */
993 
994 #ifdef __cplusplus
995 }
996 #endif
997 
998 #endif /* _VOLUME_DEVCONFIG_H */
999