xref: /titanic_41/usr/src/cmd/lvm/metassist/layout/layout_slice.h (revision b509e89b2befbaa42939abad9da1d7f5a8c6aaae)
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 _LAYOUT_SLICE_H
28 #define	_LAYOUT_SLICE_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 #include "libdiskmgt.h"
37 #include "volume_devconfig.h"
38 #include "volume_dlist.h"
39 
40 /*
41  * struct to track which slices need to be explicitly "removed" from
42  * the system before applying any metassist updates/changes.
43  */
44 typedef struct {
45 	char		*slice_name;
46 	uint32_t	slice_index;
47 } rmvdslice_t;
48 
49 extern void release_slices_to_remove();
50 extern dlist_t *get_slices_to_remove();
51 extern int add_slice_to_remove(char *name, uint32_t index);
52 
53 /*
54  * struct to track which slices have been explicitly modified
55  * during the layout process...
56  *
57  * src_slice_desc is the dm_descriptor_t of the slice which provided the
58  *	space (this is only relevant to slices that have been created by
59  *	 taking space from some other "source" slice).
60  * slice_devconfig is the devconfig_t struct with the modified slice properties.
61  * times_modified is the number of times the slice has been modified
62  *	(this is only relevant to slices that have been resized to
63  *	 provide space for new slices)
64  * volume_component is used to control when the slice_devcfg is freed.
65  *      if volume_component is B_TRUE, the devconfig is returned as part
66  *      of the result of layout and so cannot be freed by
67  *	release_modified_slices.
68  */
69 typedef struct {
70 	dm_descriptor_t	src_slice_desc;
71 	devconfig_t	*slice_devcfg;
72 	int		times_modified;
73 	boolean_t	volume_component;
74 } modslice_t;
75 
76 extern dlist_t *get_modified_slices();
77 extern int release_modified_slices();
78 
79 extern int make_slicename_for_diskname_and_index(
80 	char	*diskname,
81 	uint16_t index,
82 	char	**slicename);
83 
84 extern int assemble_modified_slice(
85 	dm_descriptor_t src_slice_desc,
86 	char		*mod_name,
87 	uint32_t	mod_index,
88 	uint64_t	mod_stblk,
89 	uint64_t	mod_nblks,
90 	uint64_t	mod_size,
91 	devconfig_t	**mod_slice);
92 
93 extern int choose_slice(
94 	uint64_t  	nbytes,
95 	uint16_t  	npaths,
96 	dlist_t   	*slices,
97 	dlist_t   	*used,
98 	dlist_t		*used_hbas,
99 	dlist_t   	*used_disks,
100 	boolean_t  	unused_disk,
101 	boolean_t  	nbytes_is_min,
102 	boolean_t  	add_extra_cyl,
103 	devconfig_t 	**chosen);
104 
105 extern int create_devconfig_for_slice(
106 	dm_descriptor_t slice,
107 	devconfig_t 	**newslice);
108 
109 extern int destroy_new_slice(
110 	devconfig_t *vol);
111 
112 /*
113  * accessors for the list of used slice names for named diskset.
114  */
115 extern int	is_used_slice(dm_descriptor_t slice, boolean_t *is_used);
116 extern int	add_used_slice_by_name(char *slicename);
117 extern int	remove_used_slice_by_name(char *slicename);
118 extern int	add_used_slice(dm_descriptor_t slice);
119 extern void	release_used_slices();
120 extern int	disk_has_used_slice(dm_descriptor_t disk, boolean_t *inuse);
121 
122 /*
123  * accessors to track slices reserved for use in explicit
124  * volume requests
125  */
126 extern int	add_reserved_slice(dm_descriptor_t slice);
127 extern int	is_reserved_slice(dm_descriptor_t slice, boolean_t *is_rsvd);
128 extern int	get_reserved_slices(dlist_t **list);
129 extern void	release_reserved_slices();
130 
131 #ifdef __cplusplus
132 }
133 #endif
134 
135 #endif /* _LAYOUT_SLICE_H */
136