xref: /titanic_41/usr/src/uts/common/sys/lvm/md_hotspares.h (revision 657a8c206b913d1ee578fd725f0b25eca5b77253)
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 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _SYS_MD_HOTSPARES_H
28 #define	_SYS_MD_HOTSPARES_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/lvm/mdvar.h>
33 
34 #ifdef	__cplusplus
35 extern "C" {
36 #endif
37 
38 /*
39  * ioctl parameter structures
40  */
41 
42 typedef enum set_hs_command	{
43 	ADD_HOT_SPARE, DELETE_HOT_SPARE, REPLACE_HOT_SPARE, FIX_HOT_SPARE
44 } set_hs_command_t;
45 
46 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
47 #pragma pack(4)
48 #endif
49 typedef struct set_hs_params {
50 	MD_DRIVER
51 	md_error_t		mde;			/* error return */
52 	set_hs_command_t	shs_cmd;		/* ioctl command */
53 	hsp_t			shs_hot_spare_pool;	/* hsp identifier */
54 	md_dev64_t		shs_component_old; /* dev for add, del, repl */
55 	md_dev64_t		shs_component_new;	/* new dev for repl */
56 	mdkey_t			shs_key_old;		/* key */
57 	mdkey_t			shs_key_new;		/* new key for repl */
58 	uint_t			shs_options;		/* see HS_OPT_* below */
59 	diskaddr_t		shs_start_blk;		/* used by add/repl */
60 	int			shs_has_label;		/* used by add/repl */
61 	diskaddr_t		shs_number_blks;	/* used by add/repl */
62 	int			shs_size_option;	/* big or small */
63 } set_hs_params_t;
64 
65 #define	HS_OPT_NONE	0x0000	/* Nothing special */
66 #define	HS_OPT_FORCE	0x0001	/* force flag */
67 #define	HS_OPT_POOL	0x0002	/* work on a hs pool */
68 #define	HS_OPT_DRYRUN	0x0004	/* just check if operation would be possible */
69 
70 typedef struct get_hs_params {
71 	MD_DRIVER
72 	md_error_t		mde;		/* error return */
73 	mdkey_t			ghs_key;	/* hs name key */
74 	md_dev64_t		ghs_devnum;	/* returned hs dev_t */
75 	diskaddr_t		ghs_start_blk;	/* returned start blk */
76 	diskaddr_t		ghs_number_blks; /* returned # of blks */
77 	hotspare_states_t	ghs_state;	/* returned state */
78 	md_timeval32_t		ghs_timestamp;	/* returned timestamp */
79 	uint_t			ghs_revision;	/* returned revision */
80 } get_hs_params_t;
81 
82 typedef struct get_hsp {
83 	hsp_t		ghsp_id;		/* hsp id */
84 	int		ghsp_refcount;		/* # metadevices using hsp */
85 	int		ghsp_nhotspares;	/* # of hs in hsp */
86 	mdkey_t		ghsp_hs_keys[1];	/* array of keys */
87 } get_hsp_t;
88 
89 #define	MD_IOCSET_HS	(MDIOC_MISC|0)
90 #define	MD_IOCGET_HS    (MDIOC_MISC|1)
91 #define	HSP_REC	1
92 #define	HS_REC	2
93 
94 /*
95  * Hot spare and hot spare pool data structures
96  * Note that hot_spare32_od is for old 32 bit format only
97  */
98 typedef struct hot_spare32_od {
99 	uint_t			hs_revision;	/* revision number */
100 	mddb_recid_t		hs_record_id;	/* db record id */
101 	caddr32_t		xx_hs_next;	/* hs list, link */
102 	dev32_t			hs_devnum;	/* hs device number */
103 	mdkey_t			hs_key;		/* namespace key */
104 	daddr32_t		hs_start_blk;	/* hs starting block */
105 	int			hs_has_label;	/* hs has a label */
106 	int			hs_number_blks;	/* hs # of blocks */
107 	hotspare_states_t	hs_state;	/* hs state */
108 	int			hs_refcount;	/* # hsp using the hs */
109 	int			hs_isopen;	/* is open flag */
110 	struct timeval32	hs_timestamp;	/* time of last state change */
111 	/*
112 	 * Incore elements in this old format are not used by 64 bit kernel
113 	 * Comment out here for maintenance history
114 	 *	struct hot_spare	*hs_next;
115 	 */
116 } hot_spare32_od_t;
117 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
118 #pragma pack()
119 #endif
120 
121 /*
122  * The pads are necessary for the hot_spare_t structure to be interpreted
123  * correctly in userland on the amd64 arch.
124  */
125 typedef struct hot_spare {
126 	uint_t			hs_revision;    /* revision number */
127 	mddb_recid_t		hs_record_id;   /* db record id */
128 	md_dev64_t		hs_devnum;	/* hs device number */
129 	mdkey_t			hs_key;		/* namespace key */
130 	int			hs_pad1;
131 	diskaddr_t		hs_start_blk;   /* hs starting block */
132 	int			hs_has_label;   /* hs has a label */
133 	int			hs_pad2;
134 	diskaddr_t		hs_number_blks; /* hs # of blocks */
135 	hotspare_states_t	hs_state;	/* hs state */
136 	int			hs_refcount;    /* # hsp using the hs */
137 	int			hs_isopen;	/* is open flag */
138 	md_timeval32_t		hs_timestamp;	/* time of last state change */
139 	/*
140 	 * Incore elements.
141 	 * they should always be at the end of this data structure.
142 	 */
143 	struct hot_spare	*hs_next;
144 } hot_spare_t;
145 
146 #define	HS_ONDSK_STR_SIZE	offsetof(hot_spare_t, hs_next)
147 
148 
149 /*
150  * Ondisk part of hot_spare_pool
151  */
152 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
153 #pragma pack(4)
154 #endif
155 typedef struct hot_spare_pool_ond {
156 	uint_t			hsp_revision;
157 	hsp_t			hsp_self_id;
158 	mddb_recid_t		hsp_record_id;
159 	uint32_t		spare[4];
160 	int			hsp_refcount;
161 	int			hsp_nhotspares;
162 	mddb_recid_t		hsp_hotspares[1];
163 } hot_spare_pool_ond_t;
164 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
165 #pragma pack()
166 #endif
167 
168 typedef struct hot_spare_pool {
169 	/*
170 	 * incore only elements
171 	 */
172 	struct hot_spare_pool	*hsp_next;	/* hsp list, link */
173 	md_link_t		hsp_link;	/* next hsp (for IOCGET_NEXT) */
174 
175 	/*
176 	 * ondisk and should be the same as hot_spare_pool_ond
177 	 */
178 	uint_t			hsp_revision;	/* revision number */
179 	hsp_t			hsp_self_id;	/* hsp identifier */
180 	mddb_recid_t		hsp_record_id;	/* db record id */
181 	uint32_t		spare[4];
182 	int			hsp_refcount;	/* # metadevices using hsp */
183 	int			hsp_nhotspares;	/* # hs in the pool */
184 	mddb_recid_t		hsp_hotspares[1];	/* array of recid's */
185 } hot_spare_pool_t;
186 
187 #define	HSP_ONDSK_STR_OFF ((off_t)(&((hot_spare_pool_t *)0)->hsp_revision))
188 
189 
190 #ifdef	__cplusplus
191 }
192 #endif
193 
194 #endif	/* _SYS_MD_HOTSPARES_H */
195