1*0Sstevel@tonic-gate %/*
2*0Sstevel@tonic-gate % * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
3*0Sstevel@tonic-gate % * Use is subject to license terms.
4*0Sstevel@tonic-gate % *
5*0Sstevel@tonic-gate % * CDDL HEADER START
6*0Sstevel@tonic-gate % *
7*0Sstevel@tonic-gate % * The contents of this file are subject to the terms of the
8*0Sstevel@tonic-gate % * Common Development and Distribution License, Version 1.0 only
9*0Sstevel@tonic-gate % * (the "License").  You may not use this file except in compliance
10*0Sstevel@tonic-gate % * with the License.
11*0Sstevel@tonic-gate % *
12*0Sstevel@tonic-gate % * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
13*0Sstevel@tonic-gate % * or http://www.opensolaris.org/os/licensing.
14*0Sstevel@tonic-gate % * See the License for the specific language governing permissions
15*0Sstevel@tonic-gate % * and limitations under the License.
16*0Sstevel@tonic-gate % *
17*0Sstevel@tonic-gate % * When distributing Covered Code, include this CDDL HEADER in each
18*0Sstevel@tonic-gate % * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
19*0Sstevel@tonic-gate % * If applicable, add the following below this CDDL HEADER, with the
20*0Sstevel@tonic-gate % * fields enclosed by brackets "[]" replaced with your own identifying
21*0Sstevel@tonic-gate % * information: Portions Copyright [yyyy] [name of copyright owner]
22*0Sstevel@tonic-gate % *
23*0Sstevel@tonic-gate % * CDDL HEADER END
24*0Sstevel@tonic-gate % */
25*0Sstevel@tonic-gate %
26*0Sstevel@tonic-gate %#pragma ident	"%Z%%M%	%I%	%E% SMI"
27*0Sstevel@tonic-gate %
28*0Sstevel@tonic-gate %/*
29*0Sstevel@tonic-gate % *	MDD interface definitions
30*0Sstevel@tonic-gate % */
31*0Sstevel@tonic-gate 
32*0Sstevel@tonic-gate %/* pick up multihost ioctl definitions */
33*0Sstevel@tonic-gate %#include <sys/lvm/md_mhdx.h>
34*0Sstevel@tonic-gate %/* get the basic XDR types */
35*0Sstevel@tonic-gate %#include <sys/lvm/md_basic.h>
36*0Sstevel@tonic-gate %/* pick up device id information */
37*0Sstevel@tonic-gate %#include <sys/dditypes.h>
38*0Sstevel@tonic-gate 
39*0Sstevel@tonic-gate %#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
40*0Sstevel@tonic-gate %/*
41*0Sstevel@tonic-gate % * NOTE: can't change these structures so make sure they are packed
42*0Sstevel@tonic-gate % * in the kernel.
43*0Sstevel@tonic-gate % */
44*0Sstevel@tonic-gate %#pragma pack(4)
45*0Sstevel@tonic-gate %#endif
46*0Sstevel@tonic-gate %
47*0Sstevel@tonic-gate %/*
48*0Sstevel@tonic-gate % * fundamental types
49*0Sstevel@tonic-gate % */
50*0Sstevel@tonic-gate %
51*0Sstevel@tonic-gate %/*
52*0Sstevel@tonic-gate % *
53*0Sstevel@tonic-gate % * NOTE: THESE ARE ON-DISK VALUES DO NOT CHANGE THE ORDER
54*0Sstevel@tonic-gate % */
55*0Sstevel@tonic-gate enum mddb_type_t {
56*0Sstevel@tonic-gate 	MDDB_ALL,
57*0Sstevel@tonic-gate 	MDDB_NM_HDR,
58*0Sstevel@tonic-gate 	MDDB_NM,
59*0Sstevel@tonic-gate 	MDDB_SHR_NM,
60*0Sstevel@tonic-gate 	MDDB_VTOC,
61*0Sstevel@tonic-gate 	MDDB_USER,
62*0Sstevel@tonic-gate 	MDDB_DID_NM_HDR,
63*0Sstevel@tonic-gate 	MDDB_DID_NM,
64*0Sstevel@tonic-gate 	MDDB_DID_SHR_NM,
65*0Sstevel@tonic-gate 	MDDB_EFILABEL,
66*0Sstevel@tonic-gate 	MDDB_FIRST_MODID = 1000
67*0Sstevel@tonic-gate };
68*0Sstevel@tonic-gate 
69*0Sstevel@tonic-gate %
70*0Sstevel@tonic-gate %/*
71*0Sstevel@tonic-gate % * Configuration commands.
72*0Sstevel@tonic-gate % */
73*0Sstevel@tonic-gate enum mddb_cfgcmd_t {
74*0Sstevel@tonic-gate 	MDDB_USEDEV,
75*0Sstevel@tonic-gate 	MDDB_NEWDEV,
76*0Sstevel@tonic-gate 	MDDB_DELDEV,
77*0Sstevel@tonic-gate 	MDDB_GETDEV,
78*0Sstevel@tonic-gate 	MDDB_ENDDEV,
79*0Sstevel@tonic-gate 	MDDB_GETDRVRNAME,
80*0Sstevel@tonic-gate 	MDDB_RELEASESET,
81*0Sstevel@tonic-gate 	MDDB_NEWSIDE,
82*0Sstevel@tonic-gate 	MDDB_DELSIDE,
83*0Sstevel@tonic-gate 	MDDB_SETDID,
84*0Sstevel@tonic-gate 	MDDB_LBINITTIME
85*0Sstevel@tonic-gate };
86*0Sstevel@tonic-gate 
87*0Sstevel@tonic-gate %
88*0Sstevel@tonic-gate %/*
89*0Sstevel@tonic-gate % * Return codes from DB record operations.
90*0Sstevel@tonic-gate % */
91*0Sstevel@tonic-gate enum mddb_recstatus_t {
92*0Sstevel@tonic-gate 	MDDB_NORECORD,
93*0Sstevel@tonic-gate 	MDDB_NODATA,
94*0Sstevel@tonic-gate 	MDDB_OK,
95*0Sstevel@tonic-gate 	MDDB_STALE
96*0Sstevel@tonic-gate };
97*0Sstevel@tonic-gate 
98*0Sstevel@tonic-gate %
99*0Sstevel@tonic-gate %/*
100*0Sstevel@tonic-gate % * Commands for DB accesses from user land.
101*0Sstevel@tonic-gate % */
102*0Sstevel@tonic-gate enum mddb_usercmd_t {
103*0Sstevel@tonic-gate 	MD_DB_GETNEXTREC,
104*0Sstevel@tonic-gate 	MD_DB_COMMIT_ONE,
105*0Sstevel@tonic-gate 	MD_DB_COMMIT_MANY,
106*0Sstevel@tonic-gate 	MD_DB_GETDATA,
107*0Sstevel@tonic-gate 	MD_DB_DELETE,
108*0Sstevel@tonic-gate 	MD_DB_CREATE,
109*0Sstevel@tonic-gate 	MD_DB_GETSTATUS,
110*0Sstevel@tonic-gate 	MD_DB_GETSIZE,
111*0Sstevel@tonic-gate 	MD_DB_SETDATA,
112*0Sstevel@tonic-gate 	MD_DB_MAKEID
113*0Sstevel@tonic-gate };
114*0Sstevel@tonic-gate 
115*0Sstevel@tonic-gate %
116*0Sstevel@tonic-gate %/*
117*0Sstevel@tonic-gate % * MDDB_USER record subtypes, set records and drive records.
118*0Sstevel@tonic-gate % * Node records (NR) used for Multinode Disksets.
119*0Sstevel@tonic-gate % * The MDDB_UR_SR record subtype is associated with the structures
120*0Sstevel@tonic-gate % * md_set_record and md_mnset_record.
121*0Sstevel@tonic-gate % * The MDDB_UR_DR record subtype is associated with the structure
122*0Sstevel@tonic-gate % * md_drive_record.
123*0Sstevel@tonic-gate % * The MDDB_NR_DR record subtype is associated with the structure
124*0Sstevel@tonic-gate % * md_mnnode_record.
125*0Sstevel@tonic-gate % * The MDDB_UR_LR record subtype is associated with the structure
126*0Sstevel@tonic-gate % * md_mn_changelog_record_t
127*0Sstevel@tonic-gate % */
128*0Sstevel@tonic-gate enum mddb_userrec_t {
129*0Sstevel@tonic-gate 	MDDB_UR_ALL,
130*0Sstevel@tonic-gate 	MDDB_UR_SR,
131*0Sstevel@tonic-gate 	MDDB_UR_DR,
132*0Sstevel@tonic-gate 	MDDB_UR_NR,
133*0Sstevel@tonic-gate 	MDDB_UR_LR
134*0Sstevel@tonic-gate };
135*0Sstevel@tonic-gate 
136*0Sstevel@tonic-gate %
137*0Sstevel@tonic-gate %/*
138*0Sstevel@tonic-gate % * MDDB_USER record get commands.
139*0Sstevel@tonic-gate % */
140*0Sstevel@tonic-gate enum md_ur_get_cmd_t {
141*0Sstevel@tonic-gate 	MD_UR_GET_NEXT,
142*0Sstevel@tonic-gate 	MD_UR_GET_WKEY
143*0Sstevel@tonic-gate };
144*0Sstevel@tonic-gate 
145*0Sstevel@tonic-gate %
146*0Sstevel@tonic-gate %/*
147*0Sstevel@tonic-gate % * These are the options for mddb_createrec()
148*0Sstevel@tonic-gate % */
149*0Sstevel@tonic-gate enum md_create_rec_option_t {
150*0Sstevel@tonic-gate 	MD_CRO_NOOPT		= 0x000,
151*0Sstevel@tonic-gate 	MD_CRO_OPTIMIZE		= 0x001,
152*0Sstevel@tonic-gate 	MD_CRO_32BIT		= 0x002,
153*0Sstevel@tonic-gate 	MD_CRO_64BIT		= 0x004,
154*0Sstevel@tonic-gate 	MD_CRO_STRIPE		= 0x008,
155*0Sstevel@tonic-gate 	MD_CRO_MIRROR		= 0x010,
156*0Sstevel@tonic-gate 	MD_CRO_RAID		= 0x020,
157*0Sstevel@tonic-gate 	MD_CRO_SOFTPART		= 0x040,
158*0Sstevel@tonic-gate 	MD_CRO_TRANS_MASTER	= 0x080,
159*0Sstevel@tonic-gate 	MD_CRO_TRANS_LOG	= 0x100,
160*0Sstevel@tonic-gate 	MD_CRO_HOTSPARE		= 0x200,
161*0Sstevel@tonic-gate 	MD_CRO_HOTSPARE_POOL	= 0x400,
162*0Sstevel@tonic-gate 	MD_CRO_CHANGELOG	= 0x800
163*0Sstevel@tonic-gate };
164*0Sstevel@tonic-gate 
165*0Sstevel@tonic-gate %
166*0Sstevel@tonic-gate %/*
167*0Sstevel@tonic-gate % * This SKEW value is used to skew the sideno of
168*0Sstevel@tonic-gate % * the share device names that are put into each
169*0Sstevel@tonic-gate % * local set's namespace.  This will prevent the
170*0Sstevel@tonic-gate % * wrong name to be picked up via a devno, when
171*0Sstevel@tonic-gate % * we really wanted a local device name.
172*0Sstevel@tonic-gate % */
173*0Sstevel@tonic-gate const	SKEW = 1;
174*0Sstevel@tonic-gate 
175*0Sstevel@tonic-gate #ifdef	RPC_XDR
176*0Sstevel@tonic-gate %
177*0Sstevel@tonic-gate %/* Start - Avoid duplicate definitions, but get the xdr calls right */
178*0Sstevel@tonic-gate %#if 0
179*0Sstevel@tonic-gate #include "meta_arr.x"
180*0Sstevel@tonic-gate %#endif	/* 0 */
181*0Sstevel@tonic-gate %/* End   - Avoid duplicate definitions, but get the xdr calls right */
182*0Sstevel@tonic-gate %
183*0Sstevel@tonic-gate #endif	/* RPC_XDR */
184*0Sstevel@tonic-gate 
185*0Sstevel@tonic-gate const	MD_DRIVE_RECORD_REVISION = 0x00010000;
186*0Sstevel@tonic-gate 
187*0Sstevel@tonic-gate #ifdef RPC_HDR
188*0Sstevel@tonic-gate %
189*0Sstevel@tonic-gate %#define	MD_DR_ADD	0x00000001U
190*0Sstevel@tonic-gate %#define	MD_DR_DEL	0x00000002U
191*0Sstevel@tonic-gate %#define	MD_DR_OK	0x80000000U
192*0Sstevel@tonic-gate #endif	/* RPC_HDR */
193*0Sstevel@tonic-gate 
194*0Sstevel@tonic-gate #if !defined(_KERNEL)
195*0Sstevel@tonic-gate struct md_drive_record {
196*0Sstevel@tonic-gate 	u_int			dr_revision;	/* revision level */
197*0Sstevel@tonic-gate 	u_int			dr_flags;	/* state flags */
198*0Sstevel@tonic-gate 	mddb_recid_t		dr_selfid;	/* db record id */
199*0Sstevel@tonic-gate 	md_timeval32_t		dr_ctime;	/* creation timestamp */
200*0Sstevel@tonic-gate 	u_long			dr_genid;	/* generation id */
201*0Sstevel@tonic-gate 	md_drive_record		*dr_next;	/* next ptr (Incore) */
202*0Sstevel@tonic-gate 	mddb_recid_t		dr_nextrec;	/* next record id */
203*0Sstevel@tonic-gate 	int			dr_dbcnt;	/* # of replica's */
204*0Sstevel@tonic-gate 	int			dr_dbsize;	/* replica size */
205*0Sstevel@tonic-gate 	mdkey_t			dr_key;		/* namespace key */
206*0Sstevel@tonic-gate };
207*0Sstevel@tonic-gate #else /* _KERNEL */
208*0Sstevel@tonic-gate struct md_drive_record {
209*0Sstevel@tonic-gate 	u_int			dr_revision;	/* revision level */
210*0Sstevel@tonic-gate 	u_int			dr_flags;	/* state flags */
211*0Sstevel@tonic-gate 	mddb_recid_t		dr_selfid;	/* db record id */
212*0Sstevel@tonic-gate 	md_timeval32_t		dr_ctime;	/* creation timestamp */
213*0Sstevel@tonic-gate 	u_int			dr_genid;	/* generation id */
214*0Sstevel@tonic-gate 	u_int			dr_next;	/* next ptr (Incore) */
215*0Sstevel@tonic-gate 	mddb_recid_t		dr_nextrec;	/* next record id */
216*0Sstevel@tonic-gate 	int			dr_dbcnt;	/* # of replica's */
217*0Sstevel@tonic-gate 	int			dr_dbsize;	/* replica size */
218*0Sstevel@tonic-gate 	mdkey_t			dr_key;		/* namespace key */
219*0Sstevel@tonic-gate };
220*0Sstevel@tonic-gate #endif /* !_KERNEL */
221*0Sstevel@tonic-gate 
222*0Sstevel@tonic-gate #ifdef RPC_HDR
223*0Sstevel@tonic-gate %/*
224*0Sstevel@tonic-gate % * Actions that can be taken on a node record.
225*0Sstevel@tonic-gate % * Used with routine upd_nr_flags.
226*0Sstevel@tonic-gate % */
227*0Sstevel@tonic-gate %
228*0Sstevel@tonic-gate %#define	MD_NR_JOIN	0x00000001U	/* Turn on JOIN flag */
229*0Sstevel@tonic-gate %#define	MD_NR_WITHDRAW	0x00000002U	/* Turn off JOIN flag */
230*0Sstevel@tonic-gate %#define	MD_NR_SET	0x00000004U	/* Set node flags in nodelist */
231*0Sstevel@tonic-gate %#define	MD_NR_DEL	0x00000008U	/* reset OK flag, set DEL */
232*0Sstevel@tonic-gate %#define	MD_NR_OK	0x80000000U	/* set OK flag; reset ADD */
233*0Sstevel@tonic-gate #endif	/* RPC_HDR */
234*0Sstevel@tonic-gate 
235*0Sstevel@tonic-gate struct md_mnnode_record {
236*0Sstevel@tonic-gate 	u_int			nr_revision;	/* revision level */
237*0Sstevel@tonic-gate 	u_int			nr_flags;	/* state flags */
238*0Sstevel@tonic-gate 	mddb_recid_t		nr_selfid;	/* db record id */
239*0Sstevel@tonic-gate 	md_timeval32_t		nr_ctime;	/* creation timestamp */
240*0Sstevel@tonic-gate 	u_long			nr_genid;	/* generation id */
241*0Sstevel@tonic-gate 	md_mnnode_record	*nr_next;	/* next ptr (Incore) */
242*0Sstevel@tonic-gate 	mddb_recid_t		nr_nextrec;	/* next node rec id */
243*0Sstevel@tonic-gate 	u_int			nr_nodeid;	/* node id */
244*0Sstevel@tonic-gate 	md_node_nm_t		nr_nodename;	/* node name */
245*0Sstevel@tonic-gate 
246*0Sstevel@tonic-gate };
247*0Sstevel@tonic-gate 
248*0Sstevel@tonic-gate const	MD_MNNODE_RECORD_REVISION = 0x00000100;
249*0Sstevel@tonic-gate 
250*0Sstevel@tonic-gate const	MD_SET_RECORD_REVISION = 0x00010000;
251*0Sstevel@tonic-gate 
252*0Sstevel@tonic-gate #ifdef RPC_HDR
253*0Sstevel@tonic-gate %
254*0Sstevel@tonic-gate %#define	MD_SR_ADD	0x00000001U
255*0Sstevel@tonic-gate %#define	MD_SR_DEL	0x00000002U
256*0Sstevel@tonic-gate %#define	MD_SR_CHECK	0x00000004U
257*0Sstevel@tonic-gate %#define	MD_SR_CVT	0x00000008U
258*0Sstevel@tonic-gate %#define	MD_SR_LOCAL	0x00000010U
259*0Sstevel@tonic-gate %#define	MD_SR_MB_DEVID	0x10000000U
260*0Sstevel@tonic-gate %#define	MD_SR_AUTO_TAKE	0x20000000U
261*0Sstevel@tonic-gate %#define	MD_SR_MN	0x40000000U
262*0Sstevel@tonic-gate %#define	MD_SR_OK	0x80000000U
263*0Sstevel@tonic-gate %#define	MD_SR_STATE_FLAGS (MD_SR_ADD | \
264*0Sstevel@tonic-gate %				   MD_SR_DEL | \
265*0Sstevel@tonic-gate %				   MD_SR_CHECK | \
266*0Sstevel@tonic-gate %				   MD_SR_CVT | \
267*0Sstevel@tonic-gate %				   MD_SR_OK)
268*0Sstevel@tonic-gate #endif	/* RPC_HDR */
269*0Sstevel@tonic-gate 
270*0Sstevel@tonic-gate #if !defined(_KERNEL)
271*0Sstevel@tonic-gate struct md_set_record {
272*0Sstevel@tonic-gate 	u_int			sr_revision;		/* revision level */
273*0Sstevel@tonic-gate 	u_int			sr_flags;		/* state flags */
274*0Sstevel@tonic-gate 	mddb_recid_t		sr_selfid;		/* db record id */
275*0Sstevel@tonic-gate #ifdef RPC_HDR
276*0Sstevel@tonic-gate 	md_set_record		*sr_next;		/* next ptr (Incore) */
277*0Sstevel@tonic-gate #endif	/* RPC_HDR */
278*0Sstevel@tonic-gate 	set_t			sr_setno;		/* set number */
279*0Sstevel@tonic-gate 	md_set_nm_t		sr_setname;		/* setname */
280*0Sstevel@tonic-gate 	md_timeval32_t		sr_ctime;		/* creation timestamp */
281*0Sstevel@tonic-gate 	u_long			sr_genid;		/* generation id */
282*0Sstevel@tonic-gate 	md_node_nm_arr_t	sr_nodes;		/* array of nodenames */
283*0Sstevel@tonic-gate 	md_drive_record		*sr_drivechain;		/* dr list (Incore) */
284*0Sstevel@tonic-gate 	mddb_recid_t		sr_driverec;		/* first dr record id */
285*0Sstevel@tonic-gate 	mhd_mhiargs_t		sr_mhiargs;		/* MH ioctl timeouts */
286*0Sstevel@tonic-gate 	md_h_arr_t		sr_med;			/* Mediator hosts */
287*0Sstevel@tonic-gate };
288*0Sstevel@tonic-gate #else /* _KERNEL */
289*0Sstevel@tonic-gate struct md_set_record {
290*0Sstevel@tonic-gate 	u_int			sr_revision;		/* revision level */
291*0Sstevel@tonic-gate 	u_int			sr_flags;		/* state flags */
292*0Sstevel@tonic-gate 	mddb_recid_t		sr_selfid;		/* db record id */
293*0Sstevel@tonic-gate #ifdef RPC_HDR
294*0Sstevel@tonic-gate 	u_int			sr_next;		/* next ptr (Incore) */
295*0Sstevel@tonic-gate #endif  /* RPC_HDR */
296*0Sstevel@tonic-gate 	set_t			sr_setno;		/* set number */
297*0Sstevel@tonic-gate 	md_set_nm_t		sr_setname;		/* setname */
298*0Sstevel@tonic-gate 	md_timeval32_t		sr_ctime;		/* creation timestamp */
299*0Sstevel@tonic-gate 	u_int			sr_genid;		/* generation id */
300*0Sstevel@tonic-gate 	md_node_nm_arr_t	sr_nodes;		/* array of nodenames */
301*0Sstevel@tonic-gate 	u_int			sr_drivechain;		/* dr list (Incore) */
302*0Sstevel@tonic-gate 	mddb_recid_t		sr_driverec;		/* first dr record id */
303*0Sstevel@tonic-gate 	mhd_mhiargs_t		sr_mhiargs;		/* MH ioctl timeouts */
304*0Sstevel@tonic-gate 	md_h_arr_t		sr_med;			/* Mediator hosts */
305*0Sstevel@tonic-gate };
306*0Sstevel@tonic-gate #endif /* !_KERNEL */
307*0Sstevel@tonic-gate 
308*0Sstevel@tonic-gate struct md_mnset_record {
309*0Sstevel@tonic-gate 	u_int			sr_revision;		/* revision level */
310*0Sstevel@tonic-gate 	u_int			sr_flags;		/* state flags */
311*0Sstevel@tonic-gate 	mddb_recid_t		sr_selfid;		/* db record id */
312*0Sstevel@tonic-gate #ifdef RPC_HDR
313*0Sstevel@tonic-gate 	md_set_record		*sr_next;		/* next ptr (Incore) */
314*0Sstevel@tonic-gate #endif	/* RPC_HDR */
315*0Sstevel@tonic-gate 	set_t			sr_setno;		/* set number */
316*0Sstevel@tonic-gate 	md_set_nm_t		sr_setname;		/* setname */
317*0Sstevel@tonic-gate 	md_timeval32_t		sr_ctime;		/* creation timestamp */
318*0Sstevel@tonic-gate 	u_long			sr_genid;		/* generation id */
319*0Sstevel@tonic-gate 	md_node_nm_arr_t	sr_nodes_bw_compat;	/* for compat with */
320*0Sstevel@tonic-gate 							/* md_set_record, */
321*0Sstevel@tonic-gate 							/* first node always */
322*0Sstevel@tonic-gate 							/* this node */
323*0Sstevel@tonic-gate 	md_drive_record		*sr_drivechain;		/* dr list (Incore) */
324*0Sstevel@tonic-gate 	mddb_recid_t		sr_driverec;		/* first dr record id */
325*0Sstevel@tonic-gate 	mhd_mhiargs_t		sr_mhiargs;		/* MH ioctl timeouts */
326*0Sstevel@tonic-gate 	md_h_arr_t		sr_med;			/* Mediator hosts */
327*0Sstevel@tonic-gate 	md_mnnode_record	*sr_nodechain;		/* node list (incore) */
328*0Sstevel@tonic-gate 	mddb_recid_t		sr_noderec;		/* first node rec id */
329*0Sstevel@tonic-gate 	md_node_nm_t		sr_master_nodenm;	/* Master nm (incore) */
330*0Sstevel@tonic-gate 	u_int			sr_master_nodeid;	/* Master id (incore) */
331*0Sstevel@tonic-gate 	u_int			sr_mddb_min_size;	/* min size of mddb */
332*0Sstevel@tonic-gate };
333*0Sstevel@tonic-gate 
334*0Sstevel@tonic-gate #ifdef RPC_HDR
335*0Sstevel@tonic-gate %
336*0Sstevel@tonic-gate %#define	MD_SETOWNER_NO		0
337*0Sstevel@tonic-gate %#define	MD_SETOWNER_YES		1
338*0Sstevel@tonic-gate %#define	MD_SETOWNER_NONE	2
339*0Sstevel@tonic-gate #endif	/* RPC_HDR */
340*0Sstevel@tonic-gate 
341*0Sstevel@tonic-gate %
342*0Sstevel@tonic-gate %/* Gate key type */
343*0Sstevel@tonic-gate struct	md_setkey_t {
344*0Sstevel@tonic-gate 	string			sk_host<>;
345*0Sstevel@tonic-gate 	set_t			sk_setno;
346*0Sstevel@tonic-gate 	string			sk_setname<>;
347*0Sstevel@tonic-gate 	md_timeval32_t		sk_key;
348*0Sstevel@tonic-gate #ifdef	RPC_HDR
349*0Sstevel@tonic-gate 	struct md_setkey_t	*sk_next;
350*0Sstevel@tonic-gate #endif	/* RPC_HDR */
351*0Sstevel@tonic-gate };
352*0Sstevel@tonic-gate 
353*0Sstevel@tonic-gate %
354*0Sstevel@tonic-gate %/* metadevice ID */
355*0Sstevel@tonic-gate typedef	minor_t		unit_t;
356*0Sstevel@tonic-gate 
357*0Sstevel@tonic-gate %
358*0Sstevel@tonic-gate %/* component ID */
359*0Sstevel@tonic-gate struct comp_t {
360*0Sstevel@tonic-gate 	minor_t		mnum;		/* associated metadevice */
361*0Sstevel@tonic-gate 	md_dev64_t	dev;
362*0Sstevel@tonic-gate };
363*0Sstevel@tonic-gate 
364*0Sstevel@tonic-gate %
365*0Sstevel@tonic-gate %/* hotspare pool ID */
366*0Sstevel@tonic-gate typedef	u_int		hsp_t;
367*0Sstevel@tonic-gate 
368*0Sstevel@tonic-gate #ifdef RPC_HDR
369*0Sstevel@tonic-gate %
370*0Sstevel@tonic-gate %#define	MD_HSP_NONE	((hsp_t)~0U)
371*0Sstevel@tonic-gate #endif	/* RPC_HDR */
372*0Sstevel@tonic-gate 
373*0Sstevel@tonic-gate %
374*0Sstevel@tonic-gate %/* hotspare ID */
375*0Sstevel@tonic-gate struct hs_t {
376*0Sstevel@tonic-gate 	hsp_t		hsp;		/* associated hotspare pool */
377*0Sstevel@tonic-gate 	md_dev64_t	dev;		/* device ID */
378*0Sstevel@tonic-gate };
379*0Sstevel@tonic-gate 
380*0Sstevel@tonic-gate %
381*0Sstevel@tonic-gate %/* mnum or hsp */
382*0Sstevel@tonic-gate typedef	u_int	minor_or_hsp_t;
383*0Sstevel@tonic-gate 
384*0Sstevel@tonic-gate %
385*0Sstevel@tonic-gate %/*
386*0Sstevel@tonic-gate % * name service stuff
387*0Sstevel@tonic-gate % */
388*0Sstevel@tonic-gate const	MD_MAXPREFIX = 127;
389*0Sstevel@tonic-gate %
390*0Sstevel@tonic-gate %#define	MD_MAX_CTDLEN	64
391*0Sstevel@tonic-gate 
392*0Sstevel@tonic-gate struct md_name_prefix {
393*0Sstevel@tonic-gate 	u_char		pre_len;
394*0Sstevel@tonic-gate 	char		pre_data[MD_MAXPREFIX];
395*0Sstevel@tonic-gate };
396*0Sstevel@tonic-gate 
397*0Sstevel@tonic-gate const	MD_MAXSUFFIX = 40;
398*0Sstevel@tonic-gate %
399*0Sstevel@tonic-gate struct md_name_suffix {
400*0Sstevel@tonic-gate 	u_char		suf_prefix;
401*0Sstevel@tonic-gate 	u_char		suf_len;
402*0Sstevel@tonic-gate 	char		suf_data[MD_MAXSUFFIX];
403*0Sstevel@tonic-gate };
404*0Sstevel@tonic-gate 
405*0Sstevel@tonic-gate struct md_splitname {
406*0Sstevel@tonic-gate 	md_name_prefix	sn_prefix;
407*0Sstevel@tonic-gate 	md_name_suffix	sn_suffix;
408*0Sstevel@tonic-gate };
409*0Sstevel@tonic-gate 
410*0Sstevel@tonic-gate #ifdef RPC_HDR
411*0Sstevel@tonic-gate %
412*0Sstevel@tonic-gate %#define	SPN_PREFIX(spn)	((spn)->sn_prefix)
413*0Sstevel@tonic-gate %#define	SPN_SUFFIX(spn)	((spn)->sn_suffix)
414*0Sstevel@tonic-gate #endif	/* RPC_HDR */
415*0Sstevel@tonic-gate 
416*0Sstevel@tonic-gate %
417*0Sstevel@tonic-gate %/*
418*0Sstevel@tonic-gate % * Number of bits to represent a setno
419*0Sstevel@tonic-gate % * this gives us all info to define masks and shifts ...
420*0Sstevel@tonic-gate % * Also used for minor #, hsp id, recid mask and shifts.
421*0Sstevel@tonic-gate % */
422*0Sstevel@tonic-gate const	MD_BITSSET =	5;
423*0Sstevel@tonic-gate const	MD_DEFAULTSETS =	4;
424*0Sstevel@tonic-gate %
425*0Sstevel@tonic-gate #ifdef RPC_HDR
426*0Sstevel@tonic-gate %
427*0Sstevel@tonic-gate %#define	MD_MAXSETS	(1 << MD_BITSSET)
428*0Sstevel@tonic-gate %#define	MD_SETMASK	(MD_MAXSETS - 1)
429*0Sstevel@tonic-gate #endif	/* RPC_HDR */
430*0Sstevel@tonic-gate 
431*0Sstevel@tonic-gate %
432*0Sstevel@tonic-gate %/*
433*0Sstevel@tonic-gate % * Define a file descriptor for lockfd
434*0Sstevel@tonic-gate % * when the lock is not held.
435*0Sstevel@tonic-gate % */
436*0Sstevel@tonic-gate const	MD_NO_LOCK = -2;
437*0Sstevel@tonic-gate 
438*0Sstevel@tonic-gate %
439*0Sstevel@tonic-gate %/*
440*0Sstevel@tonic-gate % * accumulated setname
441*0Sstevel@tonic-gate % */
442*0Sstevel@tonic-gate struct mdsetname_t {
443*0Sstevel@tonic-gate 	string			setname<>;	/* logical name */
444*0Sstevel@tonic-gate 	set_t			setno;		/* set number */
445*0Sstevel@tonic-gate #ifdef RPC_HDR
446*0Sstevel@tonic-gate 	struct md_set_desc	*setdesc;	/* Cache set/drive desc */
447*0Sstevel@tonic-gate 	int			lockfd;		/* used by meta_lock_* */
448*0Sstevel@tonic-gate #endif /* RPC_HDR */
449*0Sstevel@tonic-gate };
450*0Sstevel@tonic-gate 
451*0Sstevel@tonic-gate struct mdsetnamelist_t {
452*0Sstevel@tonic-gate 	mdsetnamelist_t	*next;
453*0Sstevel@tonic-gate 	mdsetname_t	*sp;
454*0Sstevel@tonic-gate };
455*0Sstevel@tonic-gate 
456*0Sstevel@tonic-gate %
457*0Sstevel@tonic-gate %/*
458*0Sstevel@tonic-gate % * device name
459*0Sstevel@tonic-gate % */
460*0Sstevel@tonic-gate #ifdef RPC_HDR
461*0Sstevel@tonic-gate %#define	MD_FULLNAME_ONLY	0x0
462*0Sstevel@tonic-gate %#define	MD_BASICNAME_OK	0x1
463*0Sstevel@tonic-gate %#define	MD_BYPASS_DAEMON	0x2
464*0Sstevel@tonic-gate %
465*0Sstevel@tonic-gate %#define	MD_SLICE0		0
466*0Sstevel@tonic-gate %#define	MD_SLICE6		6
467*0Sstevel@tonic-gate %#define	MD_SLICE7		7
468*0Sstevel@tonic-gate %
469*0Sstevel@tonic-gate %#define	MD_MAX_PARTS		17
470*0Sstevel@tonic-gate #endif	/* RPC_HDR */
471*0Sstevel@tonic-gate 
472*0Sstevel@tonic-gate struct mdname_t {
473*0Sstevel@tonic-gate #ifdef RPC_HDR
474*0Sstevel@tonic-gate 	struct mddrivename_t *drivenamep; /* back pointer to drive */
475*0Sstevel@tonic-gate #endif /* RPC_HDR */
476*0Sstevel@tonic-gate 	string		cname<>;	/* cannonical name */
477*0Sstevel@tonic-gate 	string		bname<>;	/* block name */
478*0Sstevel@tonic-gate 	string		rname<>;	/* raw name */
479*0Sstevel@tonic-gate 	string		devicesname<>;	/* /devices name (or NULL) */
480*0Sstevel@tonic-gate 	string		minor_name<>;	/* minor name with respect to devid */
481*0Sstevel@tonic-gate 	md_dev64_t	dev;		/* major/minor (or NODEV64) */
482*0Sstevel@tonic-gate #ifdef RPC_HDR
483*0Sstevel@tonic-gate 	mdkey_t		key;		/* namespace key (or MD_KEYBAD) */
484*0Sstevel@tonic-gate #endif /* RPC_HDR */
485*0Sstevel@tonic-gate 	diskaddr_t	end_blk;	/* end of database replicas (or -1) */
486*0Sstevel@tonic-gate 	diskaddr_t	start_blk;	/* usable start block (or -1) */
487*0Sstevel@tonic-gate };
488*0Sstevel@tonic-gate 
489*0Sstevel@tonic-gate %/* name structure (old style) */
490*0Sstevel@tonic-gate struct o_mdname_t {
491*0Sstevel@tonic-gate #ifdef RPC_HDR
492*0Sstevel@tonic-gate 	struct o_mddrivename_t *drivenamep; /* back pointer to drive */
493*0Sstevel@tonic-gate #endif /* RPC_HDR */
494*0Sstevel@tonic-gate 	string		cname<>;	/* cannonical name */
495*0Sstevel@tonic-gate 	string		bname<>;	/* block name */
496*0Sstevel@tonic-gate 	string		rname<>;	/* raw name */
497*0Sstevel@tonic-gate 	string		devicesname<>;	/* /devices name (or NULL) */
498*0Sstevel@tonic-gate 	dev_t		dev;		/* major/minor (or NODEV64) */
499*0Sstevel@tonic-gate #ifdef RPC_HDR
500*0Sstevel@tonic-gate 	mdkey_t		key;		/* namespace key (or MD_KEYBAD) */
501*0Sstevel@tonic-gate #endif /* RPC_HDR */
502*0Sstevel@tonic-gate 	daddr_t		end_blk;	/* end of database replicas (or -1) */
503*0Sstevel@tonic-gate 	daddr_t		start_blk;	/* usable start block (or -1) */
504*0Sstevel@tonic-gate };
505*0Sstevel@tonic-gate 
506*0Sstevel@tonic-gate struct mdnamelist_t {
507*0Sstevel@tonic-gate 	mdnamelist_t	*next;
508*0Sstevel@tonic-gate 	mdname_t	*namep;
509*0Sstevel@tonic-gate };
510*0Sstevel@tonic-gate 
511*0Sstevel@tonic-gate %
512*0Sstevel@tonic-gate %/*
513*0Sstevel@tonic-gate % * drive name
514*0Sstevel@tonic-gate % */
515*0Sstevel@tonic-gate %/* name types */
516*0Sstevel@tonic-gate enum mdnmtype_t {
517*0Sstevel@tonic-gate 	MDT_UNKNOWN = 0,		/* unknown type */
518*0Sstevel@tonic-gate 	MDT_ACCES,			/* could not access device */
519*0Sstevel@tonic-gate 	MDT_META,			/* metadevice name */
520*0Sstevel@tonic-gate 	MDT_COMP,			/* regular device name */
521*0Sstevel@tonic-gate 	MDT_FAST_META,			/* metadevice name (partial) */
522*0Sstevel@tonic-gate 	MDT_FAST_COMP			/* regular device name (partial) */
523*0Sstevel@tonic-gate };
524*0Sstevel@tonic-gate 
525*0Sstevel@tonic-gate %/* metadevice types */
526*0Sstevel@tonic-gate enum md_types_t {
527*0Sstevel@tonic-gate 	MD_UNDEFINED = 0,
528*0Sstevel@tonic-gate 	MD_DEVICE,
529*0Sstevel@tonic-gate 	MD_METAMIRROR,
530*0Sstevel@tonic-gate 	MD_METATRANS,
531*0Sstevel@tonic-gate 	MD_METARAID,
532*0Sstevel@tonic-gate 	MD_METASP
533*0Sstevel@tonic-gate };
534*0Sstevel@tonic-gate 
535*0Sstevel@tonic-gate #ifdef RPC_HDR
536*0Sstevel@tonic-gate %
537*0Sstevel@tonic-gate %/* misc module names */
538*0Sstevel@tonic-gate %#define	MD_STRIPE	"md_stripe"
539*0Sstevel@tonic-gate %#define	MD_MIRROR	"md_mirror"
540*0Sstevel@tonic-gate %#define	MD_TRANS	"md_trans"
541*0Sstevel@tonic-gate %#define	MD_HOTSPARES	"md_hotspares"
542*0Sstevel@tonic-gate %#define	MD_RAID		"md_raid"
543*0Sstevel@tonic-gate %#define	MD_VERIFY	"md_verify"
544*0Sstevel@tonic-gate %#define	MD_SP		"md_sp"
545*0Sstevel@tonic-gate %#define	MD_NOTIFY	"md_notify"
546*0Sstevel@tonic-gate #endif	/* RPC_HDR */
547*0Sstevel@tonic-gate 
548*0Sstevel@tonic-gate %/* generic device info */
549*0Sstevel@tonic-gate struct mdgeom_t {
550*0Sstevel@tonic-gate 	u_int		ncyl;
551*0Sstevel@tonic-gate 	u_int		nhead;
552*0Sstevel@tonic-gate 	u_int		nsect;
553*0Sstevel@tonic-gate 	u_int		rpm;
554*0Sstevel@tonic-gate 	u_int		write_reinstruct;
555*0Sstevel@tonic-gate 	u_int		read_reinstruct;
556*0Sstevel@tonic-gate 	u_int		blk_sz;
557*0Sstevel@tonic-gate };
558*0Sstevel@tonic-gate 
559*0Sstevel@tonic-gate %/* generic device info (old style) */
560*0Sstevel@tonic-gate struct o_mdgeom_t {
561*0Sstevel@tonic-gate 	u_int		ncyl;
562*0Sstevel@tonic-gate 	u_int		nhead;
563*0Sstevel@tonic-gate 	u_int		nsect;
564*0Sstevel@tonic-gate 	u_int		rpm;
565*0Sstevel@tonic-gate 	u_int		write_reinstruct;
566*0Sstevel@tonic-gate 	u_int		read_reinstruct;
567*0Sstevel@tonic-gate };
568*0Sstevel@tonic-gate 
569*0Sstevel@tonic-gate struct mdcinfo_t {
570*0Sstevel@tonic-gate 	char		cname[16];	/* controller driver name */
571*0Sstevel@tonic-gate 	mhd_ctlrtype_t	ctype;		/* controller type */
572*0Sstevel@tonic-gate 	u_int		cnum;		/* controller instance */
573*0Sstevel@tonic-gate 	u_int		tray;		/* SSA100 tray */
574*0Sstevel@tonic-gate 	u_int		bus;		/* SSA100 bus */
575*0Sstevel@tonic-gate 	u_longlong_t	wwn;		/* SSA100 World Wide Name */
576*0Sstevel@tonic-gate 	char		dname[16];	/* disk driver name */
577*0Sstevel@tonic-gate 	u_int		unit;		/* disk instance */
578*0Sstevel@tonic-gate 	u_int		maxtransfer;	/* max I/O size (in blocks) */
579*0Sstevel@tonic-gate };
580*0Sstevel@tonic-gate 
581*0Sstevel@tonic-gate struct mdpart_t {
582*0Sstevel@tonic-gate 	diskaddr_t	start;		/* start block */
583*0Sstevel@tonic-gate 	diskaddr_t	size;		/* size of partition (in blocks) */
584*0Sstevel@tonic-gate 	u_short		tag;		/* ID tag of partition */
585*0Sstevel@tonic-gate 	u_short		flag;		/* permission flags */
586*0Sstevel@tonic-gate 	diskaddr_t	label;		/* size of disk label (or 0) */
587*0Sstevel@tonic-gate };
588*0Sstevel@tonic-gate 
589*0Sstevel@tonic-gate %/* partition information (old style) */
590*0Sstevel@tonic-gate struct o_mdpart_t {
591*0Sstevel@tonic-gate 	daddr_t		start;		/* start block */
592*0Sstevel@tonic-gate 	daddr_t		size;		/* size of partition (in blocks) */
593*0Sstevel@tonic-gate 	u_short		tag;		/* ID tag of partition */
594*0Sstevel@tonic-gate 	u_short		flag;		/* permission flags */
595*0Sstevel@tonic-gate 	daddr_t		label;		/* size of disk label (or 0) */
596*0Sstevel@tonic-gate };
597*0Sstevel@tonic-gate 
598*0Sstevel@tonic-gate struct mdvtoc_t {
599*0Sstevel@tonic-gate 	u_int		nparts;
600*0Sstevel@tonic-gate 	diskaddr_t	first_lba;	/* for efi devices only */
601*0Sstevel@tonic-gate 	diskaddr_t	last_lba;	/* for efi devices only */
602*0Sstevel@tonic-gate 	diskaddr_t	lbasize;	/* for efi devices only */
603*0Sstevel@tonic-gate 	mdpart_t	parts[MD_MAX_PARTS];	/* room for i386 too */
604*0Sstevel@tonic-gate 	char		*typename;	/* disk type (or NULL) */
605*0Sstevel@tonic-gate };
606*0Sstevel@tonic-gate 
607*0Sstevel@tonic-gate %/* vtoc information (old style) */
608*0Sstevel@tonic-gate struct o_mdvtoc_t {
609*0Sstevel@tonic-gate 	char		*typename;	/* disk type (or NULL) */
610*0Sstevel@tonic-gate 	u_int		nparts;
611*0Sstevel@tonic-gate 	o_mdpart_t	parts[16];	/* room for i386 too */
612*0Sstevel@tonic-gate };
613*0Sstevel@tonic-gate %
614*0Sstevel@tonic-gate %/*
615*0Sstevel@tonic-gate % * List of drivename cnames per side,
616*0Sstevel@tonic-gate % * also the driver name, mnum (for slice 7).
617*0Sstevel@tonic-gate % */
618*0Sstevel@tonic-gate struct mdsidenames_t {
619*0Sstevel@tonic-gate 	mdsidenames_t	*next;
620*0Sstevel@tonic-gate 	side_t		sideno;
621*0Sstevel@tonic-gate 	minor_t		mnum;
622*0Sstevel@tonic-gate 	string		dname<>;
623*0Sstevel@tonic-gate 	string		cname<>;
624*0Sstevel@tonic-gate };
625*0Sstevel@tonic-gate 
626*0Sstevel@tonic-gate struct mddrivename_t {
627*0Sstevel@tonic-gate #ifdef RPC_HDR
628*0Sstevel@tonic-gate 	/*
629*0Sstevel@tonic-gate 	 * the following string is not used but is left in place so that
630*0Sstevel@tonic-gate 	 * it is not necessary to version the rpc interface that passes
631*0Sstevel@tonic-gate 	 * this structure.
632*0Sstevel@tonic-gate 	 */
633*0Sstevel@tonic-gate 	string		not_used<>;
634*0Sstevel@tonic-gate #endif	/* RPC_HDR */
635*0Sstevel@tonic-gate 	string		cname<>;	/* canonical drive name */
636*0Sstevel@tonic-gate 	string		rname<>;	/* raw name */
637*0Sstevel@tonic-gate 	mdnmtype_t	type;		/* type of drive */
638*0Sstevel@tonic-gate 	string		devid<>;	/* Device Id of the drive */
639*0Sstevel@tonic-gate 	int		errnum;		/* errno for type == MDT_ACCES */
640*0Sstevel@tonic-gate 	mdgeom_t	geom;		/* disk geometry */
641*0Sstevel@tonic-gate 	mdcinfo_t	cinfo;		/* controller info */
642*0Sstevel@tonic-gate 	mdvtoc_t	vtoc;		/* volume table of contents info */
643*0Sstevel@tonic-gate 	mdname_t	parts<>;	/* partitions in drive */
644*0Sstevel@tonic-gate 	mdsidenames_t	*side_names;	/* list of names per side */
645*0Sstevel@tonic-gate 	mdkey_t		side_names_key;	/* key used to store the side names*/
646*0Sstevel@tonic-gate 
647*0Sstevel@tonic-gate 	string		miscname<>;	/* metadevice misc name */
648*0Sstevel@tonic-gate #ifdef RPC_HDR
649*0Sstevel@tonic-gate 	struct md_common_t *unitp;	/* metadevice unit structure */
650*0Sstevel@tonic-gate #endif	/* RPC_HDR */
651*0Sstevel@tonic-gate };
652*0Sstevel@tonic-gate 
653*0Sstevel@tonic-gate %/*
654*0Sstevel@tonic-gate % * old version of mddrivename_t that contains an old version of mdgeom_t,
655*0Sstevel@tonic-gate % * mdvtoc_t and mdname_t (prefixed _o).
656*0Sstevel@tonic-gate % */
657*0Sstevel@tonic-gate struct o_mddrivename_t {
658*0Sstevel@tonic-gate #ifdef RPC_HDR
659*0Sstevel@tonic-gate 	string		cachenm<>;	/* name used for cache lookups */
660*0Sstevel@tonic-gate #endif	/* RPC_HDR */
661*0Sstevel@tonic-gate 	string		cname<>;	/* canonical drive name */
662*0Sstevel@tonic-gate 	string		rname<>;	/* raw name */
663*0Sstevel@tonic-gate 	mdnmtype_t	type;		/* type of drive */
664*0Sstevel@tonic-gate 	int		errnum;		/* errno for type == MDT_ACCES */
665*0Sstevel@tonic-gate 	o_mdgeom_t	geom;		/* disk geometry (old style) */
666*0Sstevel@tonic-gate 	mdcinfo_t	cinfo;		/* controller info */
667*0Sstevel@tonic-gate 	o_mdvtoc_t	vtoc;		/* vtoc info (old style) */
668*0Sstevel@tonic-gate 	o_mdname_t	parts<>;	/* partitions in drive (old style) */
669*0Sstevel@tonic-gate 	mdsidenames_t	*side_names;	/* list of names per side */
670*0Sstevel@tonic-gate 	mdkey_t		side_names_key;	/* key used to store the side names*/
671*0Sstevel@tonic-gate 
672*0Sstevel@tonic-gate 	string		miscname<>;	/* metadevice misc name */
673*0Sstevel@tonic-gate #ifdef RPC_HDR
674*0Sstevel@tonic-gate 	struct md_common_t *unitp;	/* metadevice unit structure */
675*0Sstevel@tonic-gate #endif	/* RPC_HDR */
676*0Sstevel@tonic-gate };
677*0Sstevel@tonic-gate struct mddrivenamelist_t {
678*0Sstevel@tonic-gate 	mddrivenamelist_t *next;
679*0Sstevel@tonic-gate 	mddrivename_t	*drivenamep;
680*0Sstevel@tonic-gate };
681*0Sstevel@tonic-gate 
682*0Sstevel@tonic-gate %
683*0Sstevel@tonic-gate %/*
684*0Sstevel@tonic-gate % * replica struct
685*0Sstevel@tonic-gate % */
686*0Sstevel@tonic-gate typedef	u_int	replica_flags_t;
687*0Sstevel@tonic-gate #ifdef RPC_HDR
688*0Sstevel@tonic-gate %
689*0Sstevel@tonic-gate %#define	MDDB_F_EREAD	0x00001	/* a read error occurred */
690*0Sstevel@tonic-gate %#define	MDDB_F_TOOSMALL	0x00002	/* replica is too small to hold db */
691*0Sstevel@tonic-gate %#define	MDDB_F_EFMT	0x00004	/* something is wrong with the data */
692*0Sstevel@tonic-gate %#define	MDDB_F_EDATA	0x00008	/* error in data blocks */
693*0Sstevel@tonic-gate %#define	MDDB_F_EMASTER	0x00010	/* error in master block(s) */
694*0Sstevel@tonic-gate %#define	MDDB_F_ACTIVE	0x00020	/* this replica is currently in use */
695*0Sstevel@tonic-gate %#define	MDDB_F_EWRITE	0x00040	/* a write error occurred */
696*0Sstevel@tonic-gate %#define	MDDB_F_MASTER	0x00080	/* the copy which was used as input */
697*0Sstevel@tonic-gate %#define	MDDB_F_SUSPECT	0x00100	/* replica write ability is suspect */
698*0Sstevel@tonic-gate %#define	MDDB_F_PTCHED	0x00400	/* db location was patched in kernel */
699*0Sstevel@tonic-gate %#define	MDDB_F_IOCTL	0x00800	/* db location passed in from ioctl */
700*0Sstevel@tonic-gate %#define	MDDB_F_GOTTEN	0x01000	/* getdev has been done on this dev */
701*0Sstevel@tonic-gate %#define	MDDB_F_LOCACC	0x02000	/* the locator has been accessed */
702*0Sstevel@tonic-gate %#define	MDDB_F_UP2DATE	0x04000	/* this copy of db is up to date */
703*0Sstevel@tonic-gate %#define	MDDB_F_OLDACT	0x08000	/* this copy was active previously */
704*0Sstevel@tonic-gate %#define	MDDB_F_DELETED	0x10000 /* place holder in empty slot */
705*0Sstevel@tonic-gate %#define	MDDB_F_TAGDATA	0x20000 /* Data is tagged */
706*0Sstevel@tonic-gate %#define	MDDB_F_BADTAG	0x40000 /* Data tag was not valid */
707*0Sstevel@tonic-gate %#define	MDDB_F_NODEVID	0x80000 /* No devid associated with replica */
708*0Sstevel@tonic-gate %
709*0Sstevel@tonic-gate %/*
710*0Sstevel@tonic-gate % * These are used in de_flags only
711*0Sstevel@tonic-gate % * Do not change these values, they are stored on-disk
712*0Sstevel@tonic-gate % */
713*0Sstevel@tonic-gate %#define	MDDB_F_STRIPE		0x00001 /* record is a stripe record */
714*0Sstevel@tonic-gate %#define	MDDB_F_MIRROR		0x00002 /* record is a mirror record */
715*0Sstevel@tonic-gate %#define	MDDB_F_RAID		0x00004 /* record is a raid record */
716*0Sstevel@tonic-gate %#define	MDDB_F_SOFTPART		0x00008 /* record is a sp record */
717*0Sstevel@tonic-gate %#define	MDDB_F_TRANS_MASTER	0x00010 /* trans master record */
718*0Sstevel@tonic-gate %#define	MDDB_F_TRANS_LOG	0x00020 /* trans log record */
719*0Sstevel@tonic-gate %#define	MDDB_F_HOTSPARE		0x00040 /* hotspare record */
720*0Sstevel@tonic-gate %#define	MDDB_F_HOTSPARE_POOL	0x00080 /* hotspare record */
721*0Sstevel@tonic-gate %#define	MDDB_F_OPT		0x00200 /* optimization record */
722*0Sstevel@tonic-gate %#define	MDDB_F_CHANGELOG	0x00400 /* change log record */
723*0Sstevel@tonic-gate 
724*0Sstevel@tonic-gate %/* used by metadb(1m) for printing */
725*0Sstevel@tonic-gate %#define	MDDB_FLAGS_STRING	"RSFDMaWm  pc luo tBr"
726*0Sstevel@tonic-gate %#define	MDDB_FLAGS_LEN		(strlen(MDDB_FLAGS_STRING))
727*0Sstevel@tonic-gate %
728*0Sstevel@tonic-gate %/*
729*0Sstevel@tonic-gate % * See meta_prbits() in SUNWmd/lib/libmeta/meta_print.c for a description of
730*0Sstevel@tonic-gate % * the way this is used
731*0Sstevel@tonic-gate % */
732*0Sstevel@tonic-gate %#define	MDDB_F_BITNAMES	"\020\001EREAD\002TOOSMALL\003EFMT\004EDATA" \
733*0Sstevel@tonic-gate %				"\005EMASTER\006ACTIVE\007EWRITE\010MASTER" \
734*0Sstevel@tonic-gate %				"\011SUSPECT\012OPT\013PTCHED\014IOCTL" \
735*0Sstevel@tonic-gate %				"\015GOTTEN\016LOCACC\017UP2DATE\020OLDACT" \
736*0Sstevel@tonic-gate %				"\021DELETED\022TAGDATA\023BADTAG\024NORELOC"
737*0Sstevel@tonic-gate %
738*0Sstevel@tonic-gate #endif	/* RPC_HDR */
739*0Sstevel@tonic-gate 
740*0Sstevel@tonic-gate /*
741*0Sstevel@tonic-gate  * Refering to r_blkno and r_nblk:
742*0Sstevel@tonic-gate  * A replica will always be smaller than 1 Terabyte, so no need to
743*0Sstevel@tonic-gate  * change the ondisk structure to 64 bits.
744*0Sstevel@tonic-gate  */
745*0Sstevel@tonic-gate struct md_replica_t {
746*0Sstevel@tonic-gate 	mdname_t		*r_namep;
747*0Sstevel@tonic-gate 	replica_flags_t		r_flags;
748*0Sstevel@tonic-gate 	daddr_t			r_blkno;
749*0Sstevel@tonic-gate 	daddr_t			r_nblk;
750*0Sstevel@tonic-gate 	ddi_devid_t		r_devid;
751*0Sstevel@tonic-gate 	char			r_driver_name[MD_MAXDRVNM];
752*0Sstevel@tonic-gate 	char			r_minor_name[MDDB_MINOR_NAME_MAX];
753*0Sstevel@tonic-gate };
754*0Sstevel@tonic-gate 
755*0Sstevel@tonic-gate struct md_replica_recerr_t {
756*0Sstevel@tonic-gate 	int			r_li;
757*0Sstevel@tonic-gate 	int			r_flags;
758*0Sstevel@tonic-gate 	daddr32_t		r_blkno;
759*0Sstevel@tonic-gate 	minor_t			r_mnum;
760*0Sstevel@tonic-gate 	char			r_driver_name[MD_MAXDRVNM];
761*0Sstevel@tonic-gate };
762*0Sstevel@tonic-gate 
763*0Sstevel@tonic-gate struct md_replicalist_t {
764*0Sstevel@tonic-gate 	md_replicalist_t	*rl_next;
765*0Sstevel@tonic-gate 	md_replica_t		*rl_repp;
766*0Sstevel@tonic-gate };
767*0Sstevel@tonic-gate 
768*0Sstevel@tonic-gate %
769*0Sstevel@tonic-gate %/*
770*0Sstevel@tonic-gate % * set/drive structs exposed by the library routines
771*0Sstevel@tonic-gate % */
772*0Sstevel@tonic-gate struct md_drive_desc {
773*0Sstevel@tonic-gate 	md_timeval32_t		dd_ctime;		/* creation time */
774*0Sstevel@tonic-gate 	u_long			dd_genid;		/* generation id */
775*0Sstevel@tonic-gate 	u_int			dd_flags;		/* state flags */
776*0Sstevel@tonic-gate 	md_drive_desc		*dd_next;		/* next drive */
777*0Sstevel@tonic-gate 	mddrivename_t		*dd_dnp;		/* drive name ptr */
778*0Sstevel@tonic-gate 	int			dd_dbcnt;		/* # of replicas */
779*0Sstevel@tonic-gate 	int			dd_dbsize;		/* size of replica */
780*0Sstevel@tonic-gate };
781*0Sstevel@tonic-gate 
782*0Sstevel@tonic-gate %
783*0Sstevel@tonic-gate %/*
784*0Sstevel@tonic-gate % * set/drive structs exposed by the library routines (old style)
785*0Sstevel@tonic-gate % */
786*0Sstevel@tonic-gate struct o_md_drive_desc {
787*0Sstevel@tonic-gate 	md_timeval32_t		dd_ctime;		/* creation time */
788*0Sstevel@tonic-gate 	u_long			dd_genid;		/* generation id */
789*0Sstevel@tonic-gate 	u_int			dd_flags;		/* state flags */
790*0Sstevel@tonic-gate 	o_md_drive_desc		*dd_next;		/* next drive */
791*0Sstevel@tonic-gate 	o_mddrivename_t		*dd_dnp;		/* drive name ptr */
792*0Sstevel@tonic-gate 	int			dd_dbcnt;		/* # of replicas */
793*0Sstevel@tonic-gate 	int			dd_dbsize;		/* size of replica */
794*0Sstevel@tonic-gate };
795*0Sstevel@tonic-gate 
796*0Sstevel@tonic-gate struct md_mnnode_desc {
797*0Sstevel@tonic-gate 	md_timeval32_t		nd_ctime;		/* creation time */
798*0Sstevel@tonic-gate 	u_long			nd_genid;		/* generation id */
799*0Sstevel@tonic-gate 	u_int			nd_flags;		/* state flags */
800*0Sstevel@tonic-gate 	md_mnnode_desc		*nd_next;		/* next node */
801*0Sstevel@tonic-gate 	md_mnnode_nm_t		nd_nodename;		/* name of node */
802*0Sstevel@tonic-gate 	u_int			nd_nodeid;		/* id of node */
803*0Sstevel@tonic-gate 	md_mnnode_nm_t		nd_priv_ic;		/* priv interconnect */
804*0Sstevel@tonic-gate 							/* nodename */
805*0Sstevel@tonic-gate };
806*0Sstevel@tonic-gate 
807*0Sstevel@tonic-gate struct md_set_desc {
808*0Sstevel@tonic-gate 	md_timeval32_t		sd_ctime;		/* creation time */
809*0Sstevel@tonic-gate 	u_long			sd_genid;		/* generation id */
810*0Sstevel@tonic-gate 	set_t			sd_setno;		/* set number */
811*0Sstevel@tonic-gate 	u_int			sd_flags;		/* state flags */
812*0Sstevel@tonic-gate 	md_node_nm_arr_t	sd_nodes;		/* array of nodenames */
813*0Sstevel@tonic-gate 							/* for !MN_disksets */
814*0Sstevel@tonic-gate 	int			sd_isown[MD_MAXSIDES];	/* bool for is owner? */
815*0Sstevel@tonic-gate 	md_h_arr_t		sd_med;			/* Mediator hosts */
816*0Sstevel@tonic-gate 	md_drive_desc		*sd_drvs;		/* drive list */
817*0Sstevel@tonic-gate 	u_int			sd_mn_am_i_master;
818*0Sstevel@tonic-gate 	u_int			sd_mn_numnodes;		/* # of nodes in list */
819*0Sstevel@tonic-gate 	md_mnnode_desc		*sd_nodelist;		/* MN node list */
820*0Sstevel@tonic-gate 							/* for MN_disksets */
821*0Sstevel@tonic-gate 	md_node_nm_t		sd_mn_master_nodenm;	/* Master node name */
822*0Sstevel@tonic-gate 	u_int			sd_mn_master_nodeid;	/* Master node id */
823*0Sstevel@tonic-gate 	md_mnnode_desc		*sd_mn_mynode;		/* shortcut to me */
824*0Sstevel@tonic-gate 	md_mnnode_desc		*sd_mn_masternode;	/* shortcut to master */
825*0Sstevel@tonic-gate };
826*0Sstevel@tonic-gate 
827*0Sstevel@tonic-gate %/*
828*0Sstevel@tonic-gate % * Defines to determine if diskset is a Multinode diskset.
829*0Sstevel@tonic-gate % * The sd_flags field in the md_set_desc structure is never manipulated
830*0Sstevel@tonic-gate % * directly but is always a copy of the set record's sr_flags field, so
831*0Sstevel@tonic-gate % * the same define (MD_SR_MN) can be used for both sd_flags and sr_flags.
832*0Sstevel@tonic-gate % * The set record is of the structure type md_set_record if a regular diskset
833*0Sstevel@tonic-gate % * or type md_mnset_record for a Multinode diskset.
834*0Sstevel@tonic-gate %*/
835*0Sstevel@tonic-gate %#define	MD_MNSET_DESC(sd)	(((sd)->sd_flags & MD_SR_MN) ? 1 : 0)
836*0Sstevel@tonic-gate %#define	MD_MNSET_REC(sr)	(((sr)->sr_flags & MD_SR_MN) ? 1 : 0)
837*0Sstevel@tonic-gate %#define	MD_MNDR_REC(dr)		(((dr)->dr_flags & MD_DR_MN) ? 1 : 0)
838*0Sstevel@tonic-gate 
839*0Sstevel@tonic-gate %/*
840*0Sstevel@tonic-gate % * Define to determine if diskset is a Auto-Take diskset.
841*0Sstevel@tonic-gate %*/
842*0Sstevel@tonic-gate %#define	MD_ATSET_DESC(sd) (((sd)->sd_flags & MD_SR_AUTO_TAKE) ? 1 : 0)
843*0Sstevel@tonic-gate 
844*0Sstevel@tonic-gate %/*
845*0Sstevel@tonic-gate % * Define to set the alive flag for a node.  A node is alive if it
846*0Sstevel@tonic-gate % * is in the multi_node membership list.
847*0Sstevel@tonic-gate % */
848*0Sstevel@tonic-gate %#define	MD_MN_NODE_ALIVE	0x0001
849*0Sstevel@tonic-gate 
850*0Sstevel@tonic-gate %/*
851*0Sstevel@tonic-gate % * Define to set the own flag for a node.  A node is an owner of the diskset
852*0Sstevel@tonic-gate % * if that node has snarf'd in the mddb.
853*0Sstevel@tonic-gate % */
854*0Sstevel@tonic-gate %#define	MD_MN_NODE_OWN		0x0002
855*0Sstevel@tonic-gate 
856*0Sstevel@tonic-gate %/*
857*0Sstevel@tonic-gate % * Defines to set the add, delete and ok states of a node.  The add state is
858*0Sstevel@tonic-gate % * set at the beginning of the addition of a node to a diskset.   The
859*0Sstevel@tonic-gate % * delete state is set at the beginning of a deletion of a node from a diskset.
860*0Sstevel@tonic-gate % * The OK state is set (and the add state reset) when that node is
861*0Sstevel@tonic-gate % * functional in the diskset.
862*0Sstevel@tonic-gate % * Rollback join flag is used on an error condition when deleting the last
863*0Sstevel@tonic-gate % * disk from a diskset. rpc.metad should never see this flag.
864*0Sstevel@tonic-gate % * NOSET flag is used on an error condition during a reconfig cycle when
865*0Sstevel@tonic-gate % * the set has been removed from this node.  rpc.metad should just ignore
866*0Sstevel@tonic-gate % * this flag.
867*0Sstevel@tonic-gate % */
868*0Sstevel@tonic-gate %#define	MD_MN_NODE_ADD		0x0004
869*0Sstevel@tonic-gate %#define	MD_MN_NODE_DEL		0x0008
870*0Sstevel@tonic-gate %#define	MD_MN_NODE_OK		0x0010
871*0Sstevel@tonic-gate %#define	MD_MN_NODE_RB_JOIN	0x0020
872*0Sstevel@tonic-gate %#define	MD_MN_NODE_NOSET	0x0040
873*0Sstevel@tonic-gate 
874*0Sstevel@tonic-gate %/*
875*0Sstevel@tonic-gate % * Define for invalid node id.   Used specifically to set mn set record
876*0Sstevel@tonic-gate % * master nodeid to invalid when no master can be determined.
877*0Sstevel@tonic-gate % */
878*0Sstevel@tonic-gate %#define	MD_MN_INVALID_NID	0xfffffffful	/* invalid node id */
879*0Sstevel@tonic-gate 
880*0Sstevel@tonic-gate %
881*0Sstevel@tonic-gate %/*
882*0Sstevel@tonic-gate % * set description (old style)
883*0Sstevel@tonic-gate % */
884*0Sstevel@tonic-gate struct o_md_set_desc {
885*0Sstevel@tonic-gate 	md_timeval32_t		sd_ctime;		/* creation time */
886*0Sstevel@tonic-gate 	u_long			sd_genid;		/* generation id */
887*0Sstevel@tonic-gate 	set_t			sd_setno;		/* set number */
888*0Sstevel@tonic-gate 	u_int			sd_flags;		/* state flags */
889*0Sstevel@tonic-gate 	md_node_nm_arr_t	sd_nodes;		/* array of nodenames */
890*0Sstevel@tonic-gate 	int			sd_isown[MD_MAXSIDES];	/* bool for is owner? */
891*0Sstevel@tonic-gate 	md_h_arr_t		sd_med;			/* Mediator hosts */
892*0Sstevel@tonic-gate 	o_md_drive_desc		*sd_drvs;		/* drive list */
893*0Sstevel@tonic-gate };
894*0Sstevel@tonic-gate 
895*0Sstevel@tonic-gate %
896*0Sstevel@tonic-gate %/*
897*0Sstevel@tonic-gate % * hotspare pool name
898*0Sstevel@tonic-gate % */
899*0Sstevel@tonic-gate struct mdhspname_t {
900*0Sstevel@tonic-gate 	string		hspname<>;	/* hotspare pool name */
901*0Sstevel@tonic-gate 	hsp_t		hsp;		/* number */
902*0Sstevel@tonic-gate 
903*0Sstevel@tonic-gate #ifdef RPC_HDR
904*0Sstevel@tonic-gate 	struct md_hsp_t	*unitp;		/* hotspare pool unit structure */
905*0Sstevel@tonic-gate #endif	/* RPC_HDR */
906*0Sstevel@tonic-gate };
907*0Sstevel@tonic-gate 
908*0Sstevel@tonic-gate struct mdhspnamelist_t {
909*0Sstevel@tonic-gate 	mdhspnamelist_t	*next;
910*0Sstevel@tonic-gate 	mdhspname_t	*hspnamep;
911*0Sstevel@tonic-gate };
912*0Sstevel@tonic-gate 
913*0Sstevel@tonic-gate %
914*0Sstevel@tonic-gate %/*
915*0Sstevel@tonic-gate % *	generic metadevice descriptions for status and init
916*0Sstevel@tonic-gate % */
917*0Sstevel@tonic-gate %
918*0Sstevel@tonic-gate 
919*0Sstevel@tonic-gate %/*
920*0Sstevel@tonic-gate % * following used with un_status
921*0Sstevel@tonic-gate % * bottom 16 bits are global definitions
922*0Sstevel@tonic-gate % * top 16 bits are defined by sub device
923*0Sstevel@tonic-gate % */
924*0Sstevel@tonic-gate typedef	u_int	md_status_t;
925*0Sstevel@tonic-gate #ifdef RPC_HDR
926*0Sstevel@tonic-gate %
927*0Sstevel@tonic-gate %#define	MD_UN_GROW_PENDING	0x0008	/* grow mirror pending */
928*0Sstevel@tonic-gate %#define	MD_UN_BEING_RESET	0x0040	/* reset at snarf time */
929*0Sstevel@tonic-gate #endif	/* RPC_HDR */
930*0Sstevel@tonic-gate %
931*0Sstevel@tonic-gate %/*
932*0Sstevel@tonic-gate % * following are used with un_parent
933*0Sstevel@tonic-gate % *	MD_NO_PARENT	- Not a sub-device.
934*0Sstevel@tonic-gate % *	MD_MULTI_PARENT	- A sub-device with one or more parents, like a log.
935*0Sstevel@tonic-gate % *	other		- A sub-device with only one parent, like a submirror.
936*0Sstevel@tonic-gate % *			  The number is the parent's unit number.
937*0Sstevel@tonic-gate % */
938*0Sstevel@tonic-gate typedef	unit_t	md_parent_t;
939*0Sstevel@tonic-gate #ifdef RPC_HDR
940*0Sstevel@tonic-gate %
941*0Sstevel@tonic-gate %#define	MD_NO_PARENT		0xffffffffu
942*0Sstevel@tonic-gate %#define	MD_MULTI_PARENT		0xfffffffeu
943*0Sstevel@tonic-gate %#define	MD_HAS_PARENT(p)	((p) != MD_NO_PARENT)
944*0Sstevel@tonic-gate #endif	/* RPC_HDR */
945*0Sstevel@tonic-gate 
946*0Sstevel@tonic-gate typedef	u_int	md_stackcap_t;
947*0Sstevel@tonic-gate #ifdef RPC_HDR
948*0Sstevel@tonic-gate %
949*0Sstevel@tonic-gate %#define	MD_CANT_PARENT		0x00	/* cannot have a parent */
950*0Sstevel@tonic-gate %#define	MD_CAN_PARENT		0x01	/* can have a parent */
951*0Sstevel@tonic-gate %#define	MD_CAN_SUB_MIRROR	0x02	/* can be a sub-mirror */
952*0Sstevel@tonic-gate %#define	MD_CAN_META_CHILD	0x04	/* can have metadev. children */
953*0Sstevel@tonic-gate %#define	MD_CAN_SP		0x08	/* can be soft partitioned */
954*0Sstevel@tonic-gate 
955*0Sstevel@tonic-gate #endif	/* RPC_HDR */
956*0Sstevel@tonic-gate 
957*0Sstevel@tonic-gate /* common to all metadevices */
958*0Sstevel@tonic-gate struct md_common_t {
959*0Sstevel@tonic-gate 	mdname_t	*namep;
960*0Sstevel@tonic-gate 	md_types_t	type;
961*0Sstevel@tonic-gate 	md_status_t	state;
962*0Sstevel@tonic-gate 	md_stackcap_t	capabilities;
963*0Sstevel@tonic-gate 	md_parent_t	parent;
964*0Sstevel@tonic-gate 	diskaddr_t	size;
965*0Sstevel@tonic-gate 	u_long		user_flags;
966*0Sstevel@tonic-gate 	u_longlong_t	revision;
967*0Sstevel@tonic-gate };
968*0Sstevel@tonic-gate 
969*0Sstevel@tonic-gate %
970*0Sstevel@tonic-gate %/*
971*0Sstevel@tonic-gate % *	stripe
972*0Sstevel@tonic-gate % */
973*0Sstevel@tonic-gate /*
974*0Sstevel@tonic-gate  * ioctl stuff
975*0Sstevel@tonic-gate  */
976*0Sstevel@tonic-gate struct ms_params_t {
977*0Sstevel@tonic-gate 	int		change_hsp_id;
978*0Sstevel@tonic-gate 	hsp_t		hsp_id;
979*0Sstevel@tonic-gate };
980*0Sstevel@tonic-gate 
981*0Sstevel@tonic-gate /*
982*0Sstevel@tonic-gate  * unit structure
983*0Sstevel@tonic-gate  */
984*0Sstevel@tonic-gate typedef u_int	comp_state_t;
985*0Sstevel@tonic-gate #ifdef RPC_HDR
986*0Sstevel@tonic-gate %
987*0Sstevel@tonic-gate %#define	CS_OKAY		0x0001
988*0Sstevel@tonic-gate %#define	CS_ERRED	0x0002
989*0Sstevel@tonic-gate %#define	CS_RESYNC	0x0004
990*0Sstevel@tonic-gate %#define	CS_LAST_ERRED	0x0008
991*0Sstevel@tonic-gate %
992*0Sstevel@tonic-gate %/* interlace values (in bytes) */
993*0Sstevel@tonic-gate %#define	MININTERLACE	(16 * 512)
994*0Sstevel@tonic-gate %#define	MAXINTERLACE	(100 * 1024 * 1024)
995*0Sstevel@tonic-gate #endif	/* RPC_HDR */
996*0Sstevel@tonic-gate 
997*0Sstevel@tonic-gate struct md_comp_t {
998*0Sstevel@tonic-gate 	mdname_t	*compnamep;
999*0Sstevel@tonic-gate 	mdname_t	*hsnamep;
1000*0Sstevel@tonic-gate 	comp_state_t	state;
1001*0Sstevel@tonic-gate 	u_int		lasterrcnt;
1002*0Sstevel@tonic-gate 	md_timeval32_t	timestamp;
1003*0Sstevel@tonic-gate };
1004*0Sstevel@tonic-gate 
1005*0Sstevel@tonic-gate struct md_row_t {
1006*0Sstevel@tonic-gate 	diskaddr_t	interlace;
1007*0Sstevel@tonic-gate 	diskaddr_t	row_size;
1008*0Sstevel@tonic-gate 	md_comp_t	comps<>;
1009*0Sstevel@tonic-gate };
1010*0Sstevel@tonic-gate 
1011*0Sstevel@tonic-gate struct md_stripe_t {
1012*0Sstevel@tonic-gate 	md_common_t	common;
1013*0Sstevel@tonic-gate 	mdhspname_t	*hspnamep;
1014*0Sstevel@tonic-gate 	md_row_t	rows<>;
1015*0Sstevel@tonic-gate };
1016*0Sstevel@tonic-gate 
1017*0Sstevel@tonic-gate %
1018*0Sstevel@tonic-gate %/*
1019*0Sstevel@tonic-gate % *	soft partition
1020*0Sstevel@tonic-gate % */
1021*0Sstevel@tonic-gate typedef uint64_t	xsp_offset_t;
1022*0Sstevel@tonic-gate typedef uint64_t	xsp_length_t;
1023*0Sstevel@tonic-gate typedef u_int		xsp_status_t;
1024*0Sstevel@tonic-gate %
1025*0Sstevel@tonic-gate %#define	SP_INIT		0x0001
1026*0Sstevel@tonic-gate %#define	SP_OK		0x0002
1027*0Sstevel@tonic-gate %#define	SP_LASTERR	0x0004
1028*0Sstevel@tonic-gate %
1029*0Sstevel@tonic-gate /*
1030*0Sstevel@tonic-gate  * unit structure
1031*0Sstevel@tonic-gate  */
1032*0Sstevel@tonic-gate 
1033*0Sstevel@tonic-gate struct md_sp_ext_t {
1034*0Sstevel@tonic-gate 	xsp_offset_t	voff;
1035*0Sstevel@tonic-gate 	xsp_offset_t	poff;
1036*0Sstevel@tonic-gate 	xsp_length_t	len;
1037*0Sstevel@tonic-gate };
1038*0Sstevel@tonic-gate 
1039*0Sstevel@tonic-gate struct md_sp_t {
1040*0Sstevel@tonic-gate 	md_common_t	common;
1041*0Sstevel@tonic-gate 	mdname_t	*compnamep;	/* name of this component */
1042*0Sstevel@tonic-gate 	xsp_status_t	status;		/* state of this soft partition */
1043*0Sstevel@tonic-gate 	md_sp_ext_t	ext<>;
1044*0Sstevel@tonic-gate };
1045*0Sstevel@tonic-gate 
1046*0Sstevel@tonic-gate %
1047*0Sstevel@tonic-gate %/*
1048*0Sstevel@tonic-gate % *	mirror
1049*0Sstevel@tonic-gate % */
1050*0Sstevel@tonic-gate /*
1051*0Sstevel@tonic-gate  * ioctl stuff
1052*0Sstevel@tonic-gate  */
1053*0Sstevel@tonic-gate enum mm_wr_opt_t {
1054*0Sstevel@tonic-gate 	WR_PARALLEL = 0,	/* write submirrors in parallel */
1055*0Sstevel@tonic-gate 	WR_SERIAL		/* write submirrors one at a time */
1056*0Sstevel@tonic-gate };
1057*0Sstevel@tonic-gate 
1058*0Sstevel@tonic-gate enum mm_rd_opt_t {
1059*0Sstevel@tonic-gate 	RD_LOAD_BAL = 0,	/* read submirrors roundrobin */
1060*0Sstevel@tonic-gate 	RD_GEOMETRY,		/* read submirrors geometrically */
1061*0Sstevel@tonic-gate 	RD_FIRST		/* read first submirror */
1062*0Sstevel@tonic-gate };
1063*0Sstevel@tonic-gate 
1064*0Sstevel@tonic-gate typedef	short	mm_pass_num_t;
1065*0Sstevel@tonic-gate const	MD_PASS_DEFAULT = 1;
1066*0Sstevel@tonic-gate const	MD_PASS_MAX = 9;
1067*0Sstevel@tonic-gate 
1068*0Sstevel@tonic-gate struct mm_params_t {
1069*0Sstevel@tonic-gate 	int		change_read_option;
1070*0Sstevel@tonic-gate 	mm_rd_opt_t	read_option;
1071*0Sstevel@tonic-gate 	int		change_write_option;
1072*0Sstevel@tonic-gate 	mm_wr_opt_t	write_option;
1073*0Sstevel@tonic-gate 	int		change_pass_num;
1074*0Sstevel@tonic-gate 	mm_pass_num_t	pass_num;
1075*0Sstevel@tonic-gate };
1076*0Sstevel@tonic-gate 
1077*0Sstevel@tonic-gate /*
1078*0Sstevel@tonic-gate  * unit structure
1079*0Sstevel@tonic-gate  */
1080*0Sstevel@tonic-gate typedef	u_int	sm_state_t;
1081*0Sstevel@tonic-gate #ifdef RPC_HDR
1082*0Sstevel@tonic-gate %
1083*0Sstevel@tonic-gate %#define	SMS_UNUSED		0x0000
1084*0Sstevel@tonic-gate %#define	SMS_RUNNING		0x0001
1085*0Sstevel@tonic-gate %#define	SMS_COMP_ERRED		0x0002
1086*0Sstevel@tonic-gate %#define	SMS_COMP_RESYNC		0x0004
1087*0Sstevel@tonic-gate %#define	SMS_ATTACHED		0x0008
1088*0Sstevel@tonic-gate %#define	SMS_ATTACHED_RESYNC	0x0010
1089*0Sstevel@tonic-gate %#define	SMS_OFFLINE		0x0020
1090*0Sstevel@tonic-gate %#define	SMS_OFFLINE_RESYNC	0x0040
1091*0Sstevel@tonic-gate %#define	SMS_ALL_ERRED		0x0080
1092*0Sstevel@tonic-gate %#define	SMS_INUSE		(0xffff)
1093*0Sstevel@tonic-gate %#define	SMS_LIMPING		(SMS_COMP_ERRED | SMS_COMP_RESYNC)
1094*0Sstevel@tonic-gate %#define	SMS_IGNORE		0x4000
1095*0Sstevel@tonic-gate #endif	/* RPC_HDR */
1096*0Sstevel@tonic-gate 
1097*0Sstevel@tonic-gate typedef	u_int	sm_flags_t;
1098*0Sstevel@tonic-gate #ifdef RPC_HDR
1099*0Sstevel@tonic-gate %
1100*0Sstevel@tonic-gate %#define	MD_SM_RESYNC_TARGET	0x0001
1101*0Sstevel@tonic-gate %#define	MD_SM_FAILFAST		0x0002
1102*0Sstevel@tonic-gate #endif	/* RPC_HDR */
1103*0Sstevel@tonic-gate 
1104*0Sstevel@tonic-gate struct md_submirror_t {
1105*0Sstevel@tonic-gate 	mdname_t	*submirnamep;
1106*0Sstevel@tonic-gate 	sm_state_t	state;
1107*0Sstevel@tonic-gate 	sm_flags_t	flags;
1108*0Sstevel@tonic-gate 	md_timeval32_t	timestamp;
1109*0Sstevel@tonic-gate };
1110*0Sstevel@tonic-gate 
1111*0Sstevel@tonic-gate #ifdef RPC_HDR
1112*0Sstevel@tonic-gate %
1113*0Sstevel@tonic-gate %#define	MD_UN_RESYNC_ACTIVE	0x00010000
1114*0Sstevel@tonic-gate %#define	MD_UN_WAR		0x00020000
1115*0Sstevel@tonic-gate %#define	MD_UN_OFFLINE_SM	0x00040000
1116*0Sstevel@tonic-gate %#define	MD_UN_OPT_NOT_DONE	0x00080000
1117*0Sstevel@tonic-gate %#define	MD_UN_KEEP_DIRTY	(MD_UN_OFFLINE_SM | MD_UN_OPT_NOT_DONE)
1118*0Sstevel@tonic-gate %#define	MD_UN_RESYNC_CANCEL	0x00100000
1119*0Sstevel@tonic-gate %#define	MD_UN_REPLAYED		0x00200000
1120*0Sstevel@tonic-gate %#define	MD_UN_RENAMING		0x00400000
1121*0Sstevel@tonic-gate %#define	MD_UN_MOD_INPROGRESS	(MD_UN_RESYNC_ACTIVE	|	\
1122*0Sstevel@tonic-gate %					 MD_UN_OPT_NOT_DONE	|	\
1123*0Sstevel@tonic-gate %					 MD_UN_RENAMING)
1124*0Sstevel@tonic-gate #endif	/* RPC_HDR */
1125*0Sstevel@tonic-gate 
1126*0Sstevel@tonic-gate const	NMIRROR = 4;
1127*0Sstevel@tonic-gate struct md_mirror_t {
1128*0Sstevel@tonic-gate 	md_common_t	common;
1129*0Sstevel@tonic-gate 	mm_rd_opt_t	read_option;
1130*0Sstevel@tonic-gate 	mm_wr_opt_t	write_option;
1131*0Sstevel@tonic-gate 	mm_pass_num_t	pass_num;
1132*0Sstevel@tonic-gate 	int		percent_done;
1133*0Sstevel@tonic-gate 	int		percent_dirty;
1134*0Sstevel@tonic-gate 	md_submirror_t	submirrors[NMIRROR];
1135*0Sstevel@tonic-gate };
1136*0Sstevel@tonic-gate 
1137*0Sstevel@tonic-gate 
1138*0Sstevel@tonic-gate %
1139*0Sstevel@tonic-gate %/*
1140*0Sstevel@tonic-gate % *	trans
1141*0Sstevel@tonic-gate % */
1142*0Sstevel@tonic-gate %/*
1143*0Sstevel@tonic-gate % * unit structure
1144*0Sstevel@tonic-gate % */
1145*0Sstevel@tonic-gate typedef	u_int	mt_flags_t;
1146*0Sstevel@tonic-gate #ifdef RPC_HDR
1147*0Sstevel@tonic-gate %
1148*0Sstevel@tonic-gate %#define	TRANS_NEED_OPEN		0x0001	/* subdevs are unopened */
1149*0Sstevel@tonic-gate %#define	TRANS_OPENED		0x0002	/* open at snarf succeeded */
1150*0Sstevel@tonic-gate %#define	TRANS_DETACHING		0x0004	/* detaching the log */
1151*0Sstevel@tonic-gate %#define	TRANS_DETACHED		0x0008	/* log successfully detached */
1152*0Sstevel@tonic-gate %#define	TRANS_DETACH_SKIP	0x0010	/* already processed; skip */
1153*0Sstevel@tonic-gate %#define	TRANS_ATTACHING		0x0020	/* attaching the log */
1154*0Sstevel@tonic-gate %#define	TRANS_ROLL_ON_WRITE	0x0040	/* roll on physio write */
1155*0Sstevel@tonic-gate %#define	TRANS_NEED_SCANROLL	0x0080	/* roll on physio write */
1156*0Sstevel@tonic-gate #endif	/* RPC_HDR */
1157*0Sstevel@tonic-gate 
1158*0Sstevel@tonic-gate typedef	u_int	mt_l_error_t;
1159*0Sstevel@tonic-gate #ifdef RPC_HDR
1160*0Sstevel@tonic-gate %
1161*0Sstevel@tonic-gate %#define	LDL_ERROR	0x0001	/* error state */
1162*0Sstevel@tonic-gate %#define	LDL_HERROR	0x0002	/* hard error state */
1163*0Sstevel@tonic-gate %#define	LDL_ANYERROR	0x0003	/* any error state */
1164*0Sstevel@tonic-gate %#define	LDL_NOERROR	0x0004	/* dont error transition during scan */
1165*0Sstevel@tonic-gate %#define	LDL_SAVERROR	0x0008	/* transition to error after scan */
1166*0Sstevel@tonic-gate #endif	/* RPC_HDR */
1167*0Sstevel@tonic-gate 
1168*0Sstevel@tonic-gate typedef	u_int	mt_debug_t;	/* values in md_trans.h */
1169*0Sstevel@tonic-gate 
1170*0Sstevel@tonic-gate struct md_trans_t {
1171*0Sstevel@tonic-gate 	md_common_t	common;
1172*0Sstevel@tonic-gate 	mdname_t	*masternamep;
1173*0Sstevel@tonic-gate 	mdname_t	*lognamep;
1174*0Sstevel@tonic-gate 	mt_flags_t	flags;
1175*0Sstevel@tonic-gate 	md_timeval32_t	timestamp;
1176*0Sstevel@tonic-gate 	mt_l_error_t	log_error;
1177*0Sstevel@tonic-gate 	md_timeval32_t log_timestamp;
1178*0Sstevel@tonic-gate 	daddr_t		log_size;
1179*0Sstevel@tonic-gate 	mt_debug_t	debug;
1180*0Sstevel@tonic-gate };
1181*0Sstevel@tonic-gate 
1182*0Sstevel@tonic-gate 
1183*0Sstevel@tonic-gate 
1184*0Sstevel@tonic-gate %
1185*0Sstevel@tonic-gate %/*
1186*0Sstevel@tonic-gate % *	RAID
1187*0Sstevel@tonic-gate % */
1188*0Sstevel@tonic-gate /*
1189*0Sstevel@tonic-gate  * ioctl stuff
1190*0Sstevel@tonic-gate  */
1191*0Sstevel@tonic-gate struct mr_params_t {
1192*0Sstevel@tonic-gate 	int		change_hsp_id;
1193*0Sstevel@tonic-gate 	hsp_t		hsp_id;
1194*0Sstevel@tonic-gate };
1195*0Sstevel@tonic-gate 
1196*0Sstevel@tonic-gate /*
1197*0Sstevel@tonic-gate  * unit structure
1198*0Sstevel@tonic-gate  */
1199*0Sstevel@tonic-gate enum rcs_state_t {
1200*0Sstevel@tonic-gate 	RCS_UNUSED = 0x0,
1201*0Sstevel@tonic-gate 	RCS_INIT = 0x1,
1202*0Sstevel@tonic-gate 	RCS_OKAY = 0x2,
1203*0Sstevel@tonic-gate 	RCS_ERRED = 0x4,
1204*0Sstevel@tonic-gate 	RCS_LAST_ERRED = 0x8,
1205*0Sstevel@tonic-gate 	RCS_RESYNC = 0x10,
1206*0Sstevel@tonic-gate 	RCS_INIT_ERRED = 0x20,
1207*0Sstevel@tonic-gate 	RCS_REGEN = 0x40
1208*0Sstevel@tonic-gate };
1209*0Sstevel@tonic-gate 
1210*0Sstevel@tonic-gate typedef	u_int	rcs_flags_t;
1211*0Sstevel@tonic-gate #ifdef RPC_HDR
1212*0Sstevel@tonic-gate %
1213*0Sstevel@tonic-gate %#define	MD_RAID_DEV_ISOPEN	0x00001
1214*0Sstevel@tonic-gate %#define	MD_RAID_ALT_ISOPEN	0x00002
1215*0Sstevel@tonic-gate %#define	MD_RAID_RESYNC		0x00004
1216*0Sstevel@tonic-gate %#define	MD_RAID_RESYNC_ERRED	0x00008
1217*0Sstevel@tonic-gate %#define	MD_RAID_FORCE_REPLACE	0x00010
1218*0Sstevel@tonic-gate %#define	MD_RAID_WRITE_ALT	0x00020
1219*0Sstevel@tonic-gate %#define	MD_RAID_DEV_ERRED	0x00040
1220*0Sstevel@tonic-gate %#define	MD_RAID_COPY_RESYNC	0x00080
1221*0Sstevel@tonic-gate %#define	MD_RAID_REGEN_RESYNC	0x00100
1222*0Sstevel@tonic-gate %#define	MD_RAID_DEV_PROBEOPEN	0x00200
1223*0Sstevel@tonic-gate %#define	MD_RAID_HAS_LABEL	0x40000
1224*0Sstevel@tonic-gate #endif	/* RPC_HDR */
1225*0Sstevel@tonic-gate 
1226*0Sstevel@tonic-gate struct md_raidcol_t {
1227*0Sstevel@tonic-gate 	mdname_t	*colnamep;
1228*0Sstevel@tonic-gate 	mdname_t	*hsnamep;
1229*0Sstevel@tonic-gate 	rcs_state_t	state;
1230*0Sstevel@tonic-gate 	rcs_flags_t	flags;
1231*0Sstevel@tonic-gate 	md_timeval32_t	timestamp;
1232*0Sstevel@tonic-gate };
1233*0Sstevel@tonic-gate 
1234*0Sstevel@tonic-gate enum rus_state_t {
1235*0Sstevel@tonic-gate 	RUS_UNUSED = 0x0,
1236*0Sstevel@tonic-gate 	RUS_INIT = 0x1,
1237*0Sstevel@tonic-gate 	RUS_OKAY = 0x2,
1238*0Sstevel@tonic-gate 	RUS_ERRED = 0x4,
1239*0Sstevel@tonic-gate 	RUS_LAST_ERRED = 0x8,
1240*0Sstevel@tonic-gate 	RUS_DOI = 0x10,
1241*0Sstevel@tonic-gate 	RUS_REGEN = 0x20
1242*0Sstevel@tonic-gate };
1243*0Sstevel@tonic-gate 
1244*0Sstevel@tonic-gate typedef	u_int	md_riflags_t;
1245*0Sstevel@tonic-gate #ifdef RPC_HDR
1246*0Sstevel@tonic-gate %
1247*0Sstevel@tonic-gate %#define	MD_RI_INPROGRESS		0x0001
1248*0Sstevel@tonic-gate %#define	MD_GROW_INPROGRESS		0x0002
1249*0Sstevel@tonic-gate %#define	MD_RI_BLOCK			0x0004
1250*0Sstevel@tonic-gate %#define	MD_RI_UNBLOCK			0x0008
1251*0Sstevel@tonic-gate %#define	MD_RI_KILL			0x0010
1252*0Sstevel@tonic-gate %#define	MD_RI_BLOCK_OWNER		0x0020
1253*0Sstevel@tonic-gate %#define	MD_RI_SHUTDOWN			0x0040
1254*0Sstevel@tonic-gate %#define	MD_RI_NO_WAIT			0x0080
1255*0Sstevel@tonic-gate %#define	MD_RI_RESYNC_FORCE_MNSTART	0x0100
1256*0Sstevel@tonic-gate #endif	/* RPC_HDR */
1257*0Sstevel@tonic-gate 
1258*0Sstevel@tonic-gate const	MD_RAID_MIN = 3;
1259*0Sstevel@tonic-gate struct md_raid_t {
1260*0Sstevel@tonic-gate 	md_common_t	common;
1261*0Sstevel@tonic-gate 	rus_state_t	state;
1262*0Sstevel@tonic-gate 	md_timeval32_t	timestamp;
1263*0Sstevel@tonic-gate 	diskaddr_t	interlace;
1264*0Sstevel@tonic-gate 	diskaddr_t	column_size;
1265*0Sstevel@tonic-gate 	size_t		orig_ncol;
1266*0Sstevel@tonic-gate 	mdhspname_t	*hspnamep;
1267*0Sstevel@tonic-gate 	md_riflags_t	resync_flags;
1268*0Sstevel@tonic-gate 	int		percent_dirty;
1269*0Sstevel@tonic-gate 	int		percent_done;
1270*0Sstevel@tonic-gate 	int		pw_count;
1271*0Sstevel@tonic-gate 	md_raidcol_t	cols<>;
1272*0Sstevel@tonic-gate };
1273*0Sstevel@tonic-gate 
1274*0Sstevel@tonic-gate %
1275*0Sstevel@tonic-gate %/*
1276*0Sstevel@tonic-gate % *	shared
1277*0Sstevel@tonic-gate % */
1278*0Sstevel@tonic-gate /*
1279*0Sstevel@tonic-gate  * unit structure
1280*0Sstevel@tonic-gate  */
1281*0Sstevel@tonic-gate struct md_shared_t {
1282*0Sstevel@tonic-gate 	md_common_t	common;
1283*0Sstevel@tonic-gate };
1284*0Sstevel@tonic-gate 
1285*0Sstevel@tonic-gate %
1286*0Sstevel@tonic-gate %/*
1287*0Sstevel@tonic-gate % *	hotspare
1288*0Sstevel@tonic-gate % */
1289*0Sstevel@tonic-gate /*
1290*0Sstevel@tonic-gate  * ioctl stuff
1291*0Sstevel@tonic-gate  */
1292*0Sstevel@tonic-gate enum hotspare_states_t {
1293*0Sstevel@tonic-gate 	HSS_UNUSED, HSS_AVAILABLE, HSS_RESERVED, HSS_BROKEN
1294*0Sstevel@tonic-gate };
1295*0Sstevel@tonic-gate 
1296*0Sstevel@tonic-gate /*
1297*0Sstevel@tonic-gate  * unit structure
1298*0Sstevel@tonic-gate  */
1299*0Sstevel@tonic-gate struct md_hs_t {
1300*0Sstevel@tonic-gate 	mdname_t	*hsnamep;
1301*0Sstevel@tonic-gate 	hotspare_states_t state;
1302*0Sstevel@tonic-gate 	diskaddr_t	size;
1303*0Sstevel@tonic-gate 	md_timeval32_t	timestamp;
1304*0Sstevel@tonic-gate 	u_longlong_t	revision;
1305*0Sstevel@tonic-gate };
1306*0Sstevel@tonic-gate 
1307*0Sstevel@tonic-gate struct md_hsp_t {
1308*0Sstevel@tonic-gate 	mdhspname_t	*hspnamep;
1309*0Sstevel@tonic-gate 	u_int		refcount;
1310*0Sstevel@tonic-gate 	md_hs_t		hotspares<>;
1311*0Sstevel@tonic-gate };
1312*0Sstevel@tonic-gate 
1313*0Sstevel@tonic-gate %
1314*0Sstevel@tonic-gate %/*
1315*0Sstevel@tonic-gate % * specific error info
1316*0Sstevel@tonic-gate % */
1317*0Sstevel@tonic-gate %
1318*0Sstevel@tonic-gate %/*
1319*0Sstevel@tonic-gate % * simple errors
1320*0Sstevel@tonic-gate % */
1321*0Sstevel@tonic-gate enum md_void_errno_t {
1322*0Sstevel@tonic-gate 	MDE_NONE = 0,
1323*0Sstevel@tonic-gate 	MDE_UNIT_NOT_FOUND,
1324*0Sstevel@tonic-gate 	MDE_DUPDRIVE,
1325*0Sstevel@tonic-gate 	MDE_INVAL_HSOP,
1326*0Sstevel@tonic-gate 	MDE_NO_SET,		/* no such set */
1327*0Sstevel@tonic-gate 	MDE_SET_DIFF,		/* setname changed on command line */
1328*0Sstevel@tonic-gate 	MDE_BAD_RD_OPT,		/* bad mirror read option */
1329*0Sstevel@tonic-gate 	MDE_BAD_WR_OPT,		/* bad mirror write option */
1330*0Sstevel@tonic-gate 	MDE_BAD_PASS_NUM,	/* bad mirror pass number */
1331*0Sstevel@tonic-gate 	MDE_BAD_INTERLACE,	/* bad stripe interlace */
1332*0Sstevel@tonic-gate 	MDE_NO_HSPS,		/* couldn't find any hotspare pools */
1333*0Sstevel@tonic-gate 	MDE_NOTENOUGH_DB,	/* Too few replicas */
1334*0Sstevel@tonic-gate 	MDE_DELDB_NOTALLOWED,	/* last replica in ds cannot be del in metadb */
1335*0Sstevel@tonic-gate 	MDE_DEL_VALIDDB_NOTALLOWED,	/* last valid replica cannot be del */
1336*0Sstevel@tonic-gate 	MDE_SYSTEM_FILE,	/* /etc/system file error */
1337*0Sstevel@tonic-gate 	MDE_MDDB_FILE,		/* /etc/lvm/mddb.cf file error */
1338*0Sstevel@tonic-gate 	MDE_MDDB_CKSUM,		/* /etc/lvm/mddb.cf checksum error */
1339*0Sstevel@tonic-gate 	MDE_VFSTAB_FILE,	/* /etc/vfstab file error */
1340*0Sstevel@tonic-gate 	MDE_NOSLICE,		/* metaslicename() with sliceno to big */
1341*0Sstevel@tonic-gate 	MDE_SYNTAX,		/* metainit syntax error */
1342*0Sstevel@tonic-gate 	MDE_OPTION,		/* metainit options error */
1343*0Sstevel@tonic-gate 	MDE_TAKE_OWN,		/* take ownership failed */
1344*0Sstevel@tonic-gate 	MDE_NOT_DRIVENAME,	/* not in drivename syntax */
1345*0Sstevel@tonic-gate 	MDE_RESERVED,		/* device is reserved by another host */
1346*0Sstevel@tonic-gate 	MDE_DVERSION,		/* driver version out of sync */
1347*0Sstevel@tonic-gate 	MDE_MVERSION,		/* MDDB version out of sync */
1348*0Sstevel@tonic-gate 	MDE_TESTERROR,		/* Test Error Message */
1349*0Sstevel@tonic-gate 	MDE_BAD_ORIG_NCOL,	/* bad RAID original column count */
1350*0Sstevel@tonic-gate 	MDE_RAID_INVALID,	/* attempt to use -k on invalid device */
1351*0Sstevel@tonic-gate 	MDE_MED_ERROR,		/* mediator error */
1352*0Sstevel@tonic-gate 	MDE_TOOMANYMED,		/* Too many mediators specified */
1353*0Sstevel@tonic-gate 	MDE_NOMED,		/* No mediators */
1354*0Sstevel@tonic-gate 	MDE_ONLYNODENAME,	/* Only the nodename is needed */
1355*0Sstevel@tonic-gate 	MDE_RAID_BAD_PW_CNT,	/* bad prewrite count specified */
1356*0Sstevel@tonic-gate 	MDE_DEVID_TOOBIG,	/* Devid size is greater than allowed */
1357*0Sstevel@tonic-gate 	MDE_NOPERM,		/* No permission - not root */
1358*0Sstevel@tonic-gate 	MDE_NODEVID,		/* No device id for given devt */
1359*0Sstevel@tonic-gate 	MDE_NOROOT,		/* No root in /etc/mnttab */
1360*0Sstevel@tonic-gate 	MDE_EOF_TRANS,		/* trans logging eof'd */
1361*0Sstevel@tonic-gate 	MDE_BAD_RESYNC_OPT,	/* bad mirror resync option */
1362*0Sstevel@tonic-gate 	MDE_NOT_MN,		/* option only valid within a multi-node set */
1363*0Sstevel@tonic-gate 	MDE_ABR_SET,		/* invalid operation for ABR mirror */
1364*0Sstevel@tonic-gate 	MDE_INVAL_MNOP,		/* Invalid operation on MN diskset */
1365*0Sstevel@tonic-gate 	MDE_MNSET_NOTRANS,	/* Trans metadevice not supported in MN set */
1366*0Sstevel@tonic-gate 	MDE_MNSET_NORAID,	/* RAID metadevice not supported in MN set */
1367*0Sstevel@tonic-gate 	MDE_FORCE_DEL_ALL_DRV,	/* Must use -f flag to delete all drives */
1368*0Sstevel@tonic-gate 	MDE_STRIPE_TRUNC_SINGLE,	/* single component stripe truncation */
1369*0Sstevel@tonic-gate 	MDE_STRIPE_TRUNC_MULTIPLE,	/* multiple component stripe trun */
1370*0Sstevel@tonic-gate 	MDE_SMF_FAIL,		/* service management facility error */
1371*0Sstevel@tonic-gate 	MDE_SMF_NO_SERVICE	/* service not enabled in SMF */
1372*0Sstevel@tonic-gate };
1373*0Sstevel@tonic-gate 
1374*0Sstevel@tonic-gate struct md_void_error_t {
1375*0Sstevel@tonic-gate 	md_void_errno_t		errnum;
1376*0Sstevel@tonic-gate };
1377*0Sstevel@tonic-gate 
1378*0Sstevel@tonic-gate %
1379*0Sstevel@tonic-gate %/*
1380*0Sstevel@tonic-gate % * system errors
1381*0Sstevel@tonic-gate % */
1382*0Sstevel@tonic-gate struct md_sys_error_t {
1383*0Sstevel@tonic-gate 	int			errnum;
1384*0Sstevel@tonic-gate };
1385*0Sstevel@tonic-gate 
1386*0Sstevel@tonic-gate %
1387*0Sstevel@tonic-gate %/*
1388*0Sstevel@tonic-gate % * RPC errors
1389*0Sstevel@tonic-gate % */
1390*0Sstevel@tonic-gate struct md_rpc_error_t {
1391*0Sstevel@tonic-gate 	enum clnt_stat		errnum;
1392*0Sstevel@tonic-gate };
1393*0Sstevel@tonic-gate 
1394*0Sstevel@tonic-gate %
1395*0Sstevel@tonic-gate %/*
1396*0Sstevel@tonic-gate % * device errors
1397*0Sstevel@tonic-gate % */
1398*0Sstevel@tonic-gate enum md_dev_errno_t {
1399*0Sstevel@tonic-gate 	MDE_INVAL_HS = 1,
1400*0Sstevel@tonic-gate 	MDE_FIX_INVAL_STATE,
1401*0Sstevel@tonic-gate 	MDE_FIX_INVAL_HS_STATE,
1402*0Sstevel@tonic-gate 	MDE_NOT_META,
1403*0Sstevel@tonic-gate 	MDE_IS_META,
1404*0Sstevel@tonic-gate 	MDE_IS_SWAPPED,
1405*0Sstevel@tonic-gate 	MDE_NAME_SPACE,
1406*0Sstevel@tonic-gate 	MDE_IN_SHARED_SET,
1407*0Sstevel@tonic-gate 	MDE_NOT_IN_SET,
1408*0Sstevel@tonic-gate 	MDE_NOT_DISK,
1409*0Sstevel@tonic-gate 	MDE_CANT_CONFIRM,
1410*0Sstevel@tonic-gate 	MDE_INVALID_PART,
1411*0Sstevel@tonic-gate 	MDE_HAS_MDDB,
1412*0Sstevel@tonic-gate 	MDE_NO_DB,		/* Replica not on device given */
1413*0Sstevel@tonic-gate 	MDE_CANTVERIFY_VTOC,
1414*0Sstevel@tonic-gate 	MDE_NOT_LOCAL,
1415*0Sstevel@tonic-gate 	MDE_DEVICES_NAME,
1416*0Sstevel@tonic-gate 	MDE_REPCOMP_INVAL,	/* replica slice not allowed in "set" metadevs */
1417*0Sstevel@tonic-gate 	MDE_REPCOMP_ONLY,	/* only replica slice diskset replicas */
1418*0Sstevel@tonic-gate 	MDE_INV_ROOT,		/* Invalid root device for this operation */
1419*0Sstevel@tonic-gate 	MDE_MULTNM,		/* Multiple entries for device in namespace */
1420*0Sstevel@tonic-gate 	MDE_TOO_MANY_PARTS,	/* dev has more than MD_MAX_PARTS partitions */
1421*0Sstevel@tonic-gate 	MDE_REPART_REPLICA,	/* replica slice would move with repartitioning */
1422*0Sstevel@tonic-gate 	MDE_IS_DUMP		/* device already in use as dump device */
1423*0Sstevel@tonic-gate };
1424*0Sstevel@tonic-gate 
1425*0Sstevel@tonic-gate struct md_dev_error_t {
1426*0Sstevel@tonic-gate 	md_dev_errno_t		errnum;
1427*0Sstevel@tonic-gate 	md_dev64_t		dev;	/* 64 bit fixed size */
1428*0Sstevel@tonic-gate };
1429*0Sstevel@tonic-gate 
1430*0Sstevel@tonic-gate %
1431*0Sstevel@tonic-gate %/*
1432*0Sstevel@tonic-gate % * overlap errors
1433*0Sstevel@tonic-gate % */
1434*0Sstevel@tonic-gate enum md_overlap_errno_t {
1435*0Sstevel@tonic-gate 	MDE_OVERLAP_MOUNTED = 1,
1436*0Sstevel@tonic-gate 	MDE_OVERLAP_SWAP,
1437*0Sstevel@tonic-gate 	MDE_OVERLAP_DUMP
1438*0Sstevel@tonic-gate };
1439*0Sstevel@tonic-gate 
1440*0Sstevel@tonic-gate %
1441*0Sstevel@tonic-gate 
1442*0Sstevel@tonic-gate #if !defined(_KERNEL)
1443*0Sstevel@tonic-gate struct md_overlap_error_t {
1444*0Sstevel@tonic-gate 	md_overlap_errno_t	errnum;
1445*0Sstevel@tonic-gate 	string			where<>;
1446*0Sstevel@tonic-gate 	string			overlap<>;
1447*0Sstevel@tonic-gate };
1448*0Sstevel@tonic-gate #else
1449*0Sstevel@tonic-gate struct md_overlap_error_t {
1450*0Sstevel@tonic-gate 	md_overlap_errno_t	errnum;
1451*0Sstevel@tonic-gate 	u_int			xwhere;
1452*0Sstevel@tonic-gate 	u_int			xoverlap;
1453*0Sstevel@tonic-gate };
1454*0Sstevel@tonic-gate #endif /* !_KERNEL */
1455*0Sstevel@tonic-gate 
1456*0Sstevel@tonic-gate %
1457*0Sstevel@tonic-gate %/*
1458*0Sstevel@tonic-gate % * use errors
1459*0Sstevel@tonic-gate % */
1460*0Sstevel@tonic-gate enum md_use_errno_t {
1461*0Sstevel@tonic-gate 	MDE_IS_MOUNTED = 1,
1462*0Sstevel@tonic-gate 	MDE_ALREADY,
1463*0Sstevel@tonic-gate 	MDE_OVERLAP
1464*0Sstevel@tonic-gate };
1465*0Sstevel@tonic-gate 
1466*0Sstevel@tonic-gate %
1467*0Sstevel@tonic-gate #if !defined(_KERNEL)
1468*0Sstevel@tonic-gate struct md_use_error_t {
1469*0Sstevel@tonic-gate 	md_use_errno_t		errnum;
1470*0Sstevel@tonic-gate 	md_dev64_t		dev;
1471*0Sstevel@tonic-gate 	string			where<>;
1472*0Sstevel@tonic-gate };
1473*0Sstevel@tonic-gate #else
1474*0Sstevel@tonic-gate struct md_use_error_t {
1475*0Sstevel@tonic-gate 	md_use_errno_t		errnum;
1476*0Sstevel@tonic-gate 	md_dev64_t		dev;
1477*0Sstevel@tonic-gate 	u_int			xwhere;
1478*0Sstevel@tonic-gate };
1479*0Sstevel@tonic-gate #endif
1480*0Sstevel@tonic-gate 
1481*0Sstevel@tonic-gate %
1482*0Sstevel@tonic-gate %/*
1483*0Sstevel@tonic-gate % * metadevice errors
1484*0Sstevel@tonic-gate % */
1485*0Sstevel@tonic-gate enum md_md_errno_t {
1486*0Sstevel@tonic-gate 	MDE_INVAL_UNIT = 1,
1487*0Sstevel@tonic-gate 	MDE_UNIT_NOT_SETUP,
1488*0Sstevel@tonic-gate 	MDE_UNIT_ALREADY_SETUP,
1489*0Sstevel@tonic-gate 	MDE_NOT_MM,
1490*0Sstevel@tonic-gate 	MDE_NOT_ENOUGH_DBS,
1491*0Sstevel@tonic-gate 	MDE_IS_SM,
1492*0Sstevel@tonic-gate 	MDE_IS_OPEN,
1493*0Sstevel@tonic-gate 	MDE_C_WITH_INVAL_SM,
1494*0Sstevel@tonic-gate 	MDE_RESYNC_ACTIVE,
1495*0Sstevel@tonic-gate 	MDE_LAST_SM_RE,
1496*0Sstevel@tonic-gate 	MDE_MIRROR_FULL,
1497*0Sstevel@tonic-gate 	MDE_IN_USE,
1498*0Sstevel@tonic-gate 	MDE_SM_TOO_SMALL,
1499*0Sstevel@tonic-gate 	MDE_NO_LABELED_SM,
1500*0Sstevel@tonic-gate 	MDE_SM_OPEN_ERR,
1501*0Sstevel@tonic-gate 	MDE_CANT_FIND_SM,
1502*0Sstevel@tonic-gate 	MDE_LAST_SM,
1503*0Sstevel@tonic-gate 	MDE_NO_READABLE_SM,
1504*0Sstevel@tonic-gate 	MDE_SM_FAILED_COMPS,
1505*0Sstevel@tonic-gate 	MDE_ILLEGAL_SM_STATE,
1506*0Sstevel@tonic-gate 	MDE_RR_ALLOC_ERROR,
1507*0Sstevel@tonic-gate 	MDE_MIRROR_OPEN_FAILURE,
1508*0Sstevel@tonic-gate 	MDE_MIRROR_THREAD_FAILURE,
1509*0Sstevel@tonic-gate 	MDE_GROW_DELAYED,
1510*0Sstevel@tonic-gate 	MDE_NOT_MT,
1511*0Sstevel@tonic-gate 	MDE_HS_IN_USE,
1512*0Sstevel@tonic-gate 	MDE_HAS_LOG,
1513*0Sstevel@tonic-gate 	MDE_UNKNOWN_TYPE,
1514*0Sstevel@tonic-gate 	MDE_NOT_STRIPE,
1515*0Sstevel@tonic-gate 	MDE_NOT_RAID,
1516*0Sstevel@tonic-gate 	MDE_NROWS,
1517*0Sstevel@tonic-gate 	MDE_NCOMPS,
1518*0Sstevel@tonic-gate 	MDE_NSUBMIRS,
1519*0Sstevel@tonic-gate 	MDE_BAD_STRIPE,
1520*0Sstevel@tonic-gate 	MDE_BAD_MIRROR,
1521*0Sstevel@tonic-gate 	MDE_BAD_TRANS,
1522*0Sstevel@tonic-gate 	MDE_BAD_RAID,
1523*0Sstevel@tonic-gate 	MDE_RAID_OPEN_FAILURE,
1524*0Sstevel@tonic-gate 	MDE_RAID_THREAD_FAILURE,
1525*0Sstevel@tonic-gate 	MDE_RAID_NEED_FORCE,
1526*0Sstevel@tonic-gate 	MDE_NO_LOG,
1527*0Sstevel@tonic-gate 	MDE_RAID_DOI,
1528*0Sstevel@tonic-gate 	MDE_RAID_LAST_ERRED,
1529*0Sstevel@tonic-gate 	MDE_RAID_NOT_OKAY,
1530*0Sstevel@tonic-gate 	MDE_RENAME_BUSY,
1531*0Sstevel@tonic-gate 	MDE_RENAME_SOURCE_BAD,
1532*0Sstevel@tonic-gate 	MDE_RENAME_TARGET_BAD,
1533*0Sstevel@tonic-gate 	MDE_RENAME_TARGET_UNRELATED,
1534*0Sstevel@tonic-gate 	MDE_RENAME_CONFIG_ERROR,
1535*0Sstevel@tonic-gate 	MDE_RENAME_ORDER,
1536*0Sstevel@tonic-gate 	MDE_RECOVER_FAILED,
1537*0Sstevel@tonic-gate 	MDE_NOT_SP,
1538*0Sstevel@tonic-gate 	MDE_SP_NOSPACE,
1539*0Sstevel@tonic-gate 	MDE_SP_BADWMREAD,
1540*0Sstevel@tonic-gate 	MDE_SP_BADWMWRITE,
1541*0Sstevel@tonic-gate 	MDE_SP_BADWMMAGIC,
1542*0Sstevel@tonic-gate 	MDE_SP_BADWMCRC,
1543*0Sstevel@tonic-gate 	MDE_SP_OVERLAP,
1544*0Sstevel@tonic-gate 	MDE_SP_BAD_LENGTH,
1545*0Sstevel@tonic-gate 	MDE_UNIT_TOO_LARGE,
1546*0Sstevel@tonic-gate 	MDE_LOG_TOO_LARGE,
1547*0Sstevel@tonic-gate 	MDE_SP_NOSP,
1548*0Sstevel@tonic-gate 	MDE_IN_UNAVAIL_STATE
1549*0Sstevel@tonic-gate };
1550*0Sstevel@tonic-gate 
1551*0Sstevel@tonic-gate struct md_md_error_t {
1552*0Sstevel@tonic-gate 	md_md_errno_t		errnum;
1553*0Sstevel@tonic-gate 	minor_t			mnum;
1554*0Sstevel@tonic-gate };
1555*0Sstevel@tonic-gate 
1556*0Sstevel@tonic-gate %
1557*0Sstevel@tonic-gate %/*
1558*0Sstevel@tonic-gate % * component errors
1559*0Sstevel@tonic-gate % */
1560*0Sstevel@tonic-gate enum md_comp_errno_t {
1561*0Sstevel@tonic-gate 	MDE_CANT_FIND_COMP = 1,
1562*0Sstevel@tonic-gate 	MDE_REPL_INVAL_STATE,
1563*0Sstevel@tonic-gate 	MDE_COMP_TOO_SMALL,
1564*0Sstevel@tonic-gate 	MDE_COMP_OPEN_ERR,
1565*0Sstevel@tonic-gate 	MDE_RAID_COMP_ERRED,
1566*0Sstevel@tonic-gate 	MDE_MAXIO,
1567*0Sstevel@tonic-gate 	MDE_SP_COMP_OPEN_ERR
1568*0Sstevel@tonic-gate };
1569*0Sstevel@tonic-gate 
1570*0Sstevel@tonic-gate struct md_comp_error_t {
1571*0Sstevel@tonic-gate 	md_comp_errno_t		errnum;
1572*0Sstevel@tonic-gate 	comp_t			comp;
1573*0Sstevel@tonic-gate };
1574*0Sstevel@tonic-gate 
1575*0Sstevel@tonic-gate %
1576*0Sstevel@tonic-gate %/*
1577*0Sstevel@tonic-gate % * hotspare pool errors
1578*0Sstevel@tonic-gate % */
1579*0Sstevel@tonic-gate enum md_hsp_errno_t {
1580*0Sstevel@tonic-gate 	MDE_HSP_CREATE_FAILURE = 1,
1581*0Sstevel@tonic-gate 	MDE_HSP_IN_USE,
1582*0Sstevel@tonic-gate 	MDE_INVAL_HSP,
1583*0Sstevel@tonic-gate 	MDE_HSP_BUSY,
1584*0Sstevel@tonic-gate 	MDE_HSP_REF,
1585*0Sstevel@tonic-gate 	MDE_HSP_ALREADY_SETUP,
1586*0Sstevel@tonic-gate 	MDE_BAD_HSP,
1587*0Sstevel@tonic-gate 	MDE_HSP_UNIT_TOO_LARGE
1588*0Sstevel@tonic-gate };
1589*0Sstevel@tonic-gate 
1590*0Sstevel@tonic-gate struct md_hsp_error_t {
1591*0Sstevel@tonic-gate 	md_hsp_errno_t		errnum;
1592*0Sstevel@tonic-gate 	hsp_t			hsp;
1593*0Sstevel@tonic-gate };
1594*0Sstevel@tonic-gate 
1595*0Sstevel@tonic-gate %
1596*0Sstevel@tonic-gate %/*
1597*0Sstevel@tonic-gate % * hotspare errors
1598*0Sstevel@tonic-gate % */
1599*0Sstevel@tonic-gate enum md_hs_errno_t {
1600*0Sstevel@tonic-gate 	MDE_HS_RESVD = 1,
1601*0Sstevel@tonic-gate 	MDE_HS_CREATE_FAILURE,
1602*0Sstevel@tonic-gate 	MDE_HS_INUSE,
1603*0Sstevel@tonic-gate 	MDE_HS_UNIT_TOO_LARGE
1604*0Sstevel@tonic-gate };
1605*0Sstevel@tonic-gate 
1606*0Sstevel@tonic-gate struct md_hs_error_t {
1607*0Sstevel@tonic-gate 	md_hs_errno_t		errnum;
1608*0Sstevel@tonic-gate 	hs_t			hs;
1609*0Sstevel@tonic-gate };
1610*0Sstevel@tonic-gate 
1611*0Sstevel@tonic-gate %
1612*0Sstevel@tonic-gate %/*
1613*0Sstevel@tonic-gate % * MDDB errors
1614*0Sstevel@tonic-gate % */
1615*0Sstevel@tonic-gate enum md_mddb_errno_t {
1616*0Sstevel@tonic-gate 	MDE_TOOMANY_REPLICAS = 1,
1617*0Sstevel@tonic-gate 	MDE_REPLICA_TOOSMALL,
1618*0Sstevel@tonic-gate 	MDE_NOTVERIFIED,
1619*0Sstevel@tonic-gate 	MDE_DB_INVALID,
1620*0Sstevel@tonic-gate 	MDE_DB_EXISTS,
1621*0Sstevel@tonic-gate 	MDE_DB_MASTER,
1622*0Sstevel@tonic-gate 	MDE_DB_TOOSMALL,
1623*0Sstevel@tonic-gate 	MDE_DB_NORECORD,
1624*0Sstevel@tonic-gate 	MDE_DB_NOSPACE,
1625*0Sstevel@tonic-gate 	MDE_DB_NOTNOW,
1626*0Sstevel@tonic-gate 	MDE_DB_NODB,
1627*0Sstevel@tonic-gate 	MDE_DB_NOTOWNER,
1628*0Sstevel@tonic-gate 	MDE_DB_STALE,
1629*0Sstevel@tonic-gate 	MDE_DB_TOOFEW,
1630*0Sstevel@tonic-gate 	MDE_DB_TAGDATA,
1631*0Sstevel@tonic-gate 	MDE_DB_ACCOK,
1632*0Sstevel@tonic-gate 	MDE_DB_NTAGDATA,
1633*0Sstevel@tonic-gate 	MDE_DB_ACCNOTOK,
1634*0Sstevel@tonic-gate 	MDE_DB_NOLOCBLK,
1635*0Sstevel@tonic-gate 	MDE_DB_NOLOCNMS,
1636*0Sstevel@tonic-gate 	MDE_DB_NODIRBLK,
1637*0Sstevel@tonic-gate 	MDE_DB_NOTAGREC,
1638*0Sstevel@tonic-gate 	MDE_DB_NOTAG,
1639*0Sstevel@tonic-gate 	MDE_DB_BLKRANGE
1640*0Sstevel@tonic-gate };
1641*0Sstevel@tonic-gate 
1642*0Sstevel@tonic-gate %
1643*0Sstevel@tonic-gate struct md_mddb_error_t {
1644*0Sstevel@tonic-gate 	md_mddb_errno_t		errnum;
1645*0Sstevel@tonic-gate 	minor_t			mnum;		/* associated metadevice */
1646*0Sstevel@tonic-gate 	set_t			setno;
1647*0Sstevel@tonic-gate 	u_int			size;
1648*0Sstevel@tonic-gate };
1649*0Sstevel@tonic-gate 
1650*0Sstevel@tonic-gate %
1651*0Sstevel@tonic-gate %/*
1652*0Sstevel@tonic-gate % * diskset (ds) errors
1653*0Sstevel@tonic-gate % */
1654*0Sstevel@tonic-gate enum md_ds_errno_t {
1655*0Sstevel@tonic-gate 	MDE_DS_DUPHOST = 1,
1656*0Sstevel@tonic-gate 	MDE_DS_NOTNODENAME,
1657*0Sstevel@tonic-gate 	MDE_DS_SELFNOTIN,
1658*0Sstevel@tonic-gate 	MDE_DS_NODEHASSET,
1659*0Sstevel@tonic-gate 	MDE_DS_NODENOSET,
1660*0Sstevel@tonic-gate 	MDE_DS_NOOWNER,
1661*0Sstevel@tonic-gate 	MDE_DS_NOTOWNER,
1662*0Sstevel@tonic-gate 	MDE_DS_NODEISNOTOWNER,
1663*0Sstevel@tonic-gate 	MDE_DS_NODEINSET,
1664*0Sstevel@tonic-gate 	MDE_DS_NODENOTINSET,
1665*0Sstevel@tonic-gate 	MDE_DS_SETNUMBUSY,
1666*0Sstevel@tonic-gate 	MDE_DS_SETNUMNOTAVAIL,
1667*0Sstevel@tonic-gate 	MDE_DS_SETNAMEBUSY,
1668*0Sstevel@tonic-gate 	MDE_DS_DRIVENOTCOMMON,
1669*0Sstevel@tonic-gate 	MDE_DS_DRIVEINSET,
1670*0Sstevel@tonic-gate 	MDE_DS_DRIVENOTINSET,
1671*0Sstevel@tonic-gate 	MDE_DS_DRIVEINUSE,
1672*0Sstevel@tonic-gate 	MDE_DS_DUPDRIVE,
1673*0Sstevel@tonic-gate 	MDE_DS_INVALIDSETNAME,
1674*0Sstevel@tonic-gate 	MDE_DS_HASDRIVES,
1675*0Sstevel@tonic-gate 	MDE_DS_SIDENUMNOTAVAIL,
1676*0Sstevel@tonic-gate 	MDE_DS_SETNAMETOOLONG,
1677*0Sstevel@tonic-gate 	MDE_DS_NODENAMETOOLONG,
1678*0Sstevel@tonic-gate 	MDE_DS_OHACANTDELSELF,
1679*0Sstevel@tonic-gate 	MDE_DS_HOSTNOSIDE,
1680*0Sstevel@tonic-gate 	MDE_DS_SETLOCKED,
1681*0Sstevel@tonic-gate 	MDE_DS_ULKSBADKEY,
1682*0Sstevel@tonic-gate 	MDE_DS_LKSBADKEY,
1683*0Sstevel@tonic-gate 	MDE_DS_WRITEWITHSULK,
1684*0Sstevel@tonic-gate 	MDE_DS_SETCLEANUP,
1685*0Sstevel@tonic-gate 	MDE_DS_CANTDELSELF,
1686*0Sstevel@tonic-gate 	MDE_DS_HASMED,
1687*0Sstevel@tonic-gate 	MDE_DS_TOOMANYALIAS,
1688*0Sstevel@tonic-gate 	MDE_DS_ISMED,
1689*0Sstevel@tonic-gate 	MDE_DS_ISNOTMED,
1690*0Sstevel@tonic-gate 	MDE_DS_INVALIDMEDNAME,
1691*0Sstevel@tonic-gate 	MDE_DS_ALIASNOMATCH,
1692*0Sstevel@tonic-gate 	MDE_DS_NOMEDONHOST,
1693*0Sstevel@tonic-gate 	MDE_DS_CANTDELMASTER,
1694*0Sstevel@tonic-gate 	MDE_DS_NOTINMEMBERLIST,
1695*0Sstevel@tonic-gate 	MDE_DS_MNCANTDELSELF,
1696*0Sstevel@tonic-gate 	MDE_DS_RPCVERSMISMATCH,
1697*0Sstevel@tonic-gate 	MDE_DS_WITHDRAWMASTER,
1698*0Sstevel@tonic-gate 	MDE_DS_COMMDCTL_SUSPEND_NYD,
1699*0Sstevel@tonic-gate 	MDE_DS_COMMDCTL_SUSPEND_FAIL,
1700*0Sstevel@tonic-gate 	MDE_DS_COMMDCTL_REINIT_FAIL,
1701*0Sstevel@tonic-gate 	MDE_DS_COMMDCTL_RESUME_FAIL,
1702*0Sstevel@tonic-gate 	MDE_DS_NOTNOW_RECONFIG,
1703*0Sstevel@tonic-gate 	MDE_DS_NOTNOW_CMD,
1704*0Sstevel@tonic-gate 	MDE_DS_COMMD_SEND_FAIL,
1705*0Sstevel@tonic-gate 	MDE_DS_MASTER_ONLY,
1706*0Sstevel@tonic-gate 	MDE_DS_DRIVENOTONHOST,
1707*0Sstevel@tonic-gate 	MDE_DS_CANTRESNARF,
1708*0Sstevel@tonic-gate 	MDE_DS_INSUFQUORUM,
1709*0Sstevel@tonic-gate 	MDE_DS_EXTENDEDNM,
1710*0Sstevel@tonic-gate 	MDE_DS_PARTIALSET,
1711*0Sstevel@tonic-gate 	MDE_DS_SINGLEHOST,
1712*0Sstevel@tonic-gate 	MDE_DS_AUTONOTSET,
1713*0Sstevel@tonic-gate 	MDE_DS_INVALIDDEVID,
1714*0Sstevel@tonic-gate 	MDE_DS_SETNOTIMP,
1715*0Sstevel@tonic-gate 	MDE_DS_NOTSELFIDENTIFY
1716*0Sstevel@tonic-gate };
1717*0Sstevel@tonic-gate 
1718*0Sstevel@tonic-gate %
1719*0Sstevel@tonic-gate #if !defined(_KERNEL)
1720*0Sstevel@tonic-gate struct md_ds_error_t {
1721*0Sstevel@tonic-gate 	md_ds_errno_t		errnum;
1722*0Sstevel@tonic-gate 	set_t			setno;
1723*0Sstevel@tonic-gate 	string			node<>;
1724*0Sstevel@tonic-gate 	string			drive<>;
1725*0Sstevel@tonic-gate };
1726*0Sstevel@tonic-gate #else /* _KERNEL */
1727*0Sstevel@tonic-gate struct md_ds_error_t {
1728*0Sstevel@tonic-gate 	md_ds_errno_t		errnum;
1729*0Sstevel@tonic-gate 	set_t			setno;
1730*0Sstevel@tonic-gate 	u_int			xnode;
1731*0Sstevel@tonic-gate 	u_int			xdrive;
1732*0Sstevel@tonic-gate };
1733*0Sstevel@tonic-gate #endif /* !_KERNEL */
1734*0Sstevel@tonic-gate 
1735*0Sstevel@tonic-gate %
1736*0Sstevel@tonic-gate %/*
1737*0Sstevel@tonic-gate % * fundamental error type
1738*0Sstevel@tonic-gate % */
1739*0Sstevel@tonic-gate enum md_errclass_t {
1740*0Sstevel@tonic-gate 	MDEC_VOID = 0,	/* simple error */
1741*0Sstevel@tonic-gate 	MDEC_SYS,	/* system errno */
1742*0Sstevel@tonic-gate 	MDEC_RPC,	/* RPC errno */
1743*0Sstevel@tonic-gate 	MDEC_DEV,	/* device error */
1744*0Sstevel@tonic-gate 	MDEC_USE,	/* use error */
1745*0Sstevel@tonic-gate 	MDEC_MD,	/* metadevice error */
1746*0Sstevel@tonic-gate 	MDEC_COMP,	/* component error */
1747*0Sstevel@tonic-gate 	MDEC_HSP,	/* hotspare pool error */
1748*0Sstevel@tonic-gate 	MDEC_HS,	/* hotspare error */
1749*0Sstevel@tonic-gate 	MDEC_MDDB,	/* metadevice database error */
1750*0Sstevel@tonic-gate 	MDEC_DS,	/* diskset error */
1751*0Sstevel@tonic-gate 	MDEC_OVERLAP	/* overlap error */
1752*0Sstevel@tonic-gate };
1753*0Sstevel@tonic-gate 
1754*0Sstevel@tonic-gate %
1755*0Sstevel@tonic-gate %/*
1756*0Sstevel@tonic-gate % * error info
1757*0Sstevel@tonic-gate % */
1758*0Sstevel@tonic-gate union md_error_info_t
1759*0Sstevel@tonic-gate switch (md_errclass_t	errclass) {
1760*0Sstevel@tonic-gate case MDEC_VOID:
1761*0Sstevel@tonic-gate 	md_void_error_t		void_error;
1762*0Sstevel@tonic-gate case MDEC_SYS:
1763*0Sstevel@tonic-gate 	md_sys_error_t		sys_error;
1764*0Sstevel@tonic-gate case MDEC_RPC:
1765*0Sstevel@tonic-gate 	md_rpc_error_t		rpc_error;
1766*0Sstevel@tonic-gate case MDEC_DEV:
1767*0Sstevel@tonic-gate 	md_dev_error_t		dev_error;
1768*0Sstevel@tonic-gate case MDEC_USE:
1769*0Sstevel@tonic-gate 	md_use_error_t		use_error;
1770*0Sstevel@tonic-gate case MDEC_MD:
1771*0Sstevel@tonic-gate 	md_md_error_t		md_error;
1772*0Sstevel@tonic-gate case MDEC_COMP:
1773*0Sstevel@tonic-gate 	md_comp_error_t		comp_error;
1774*0Sstevel@tonic-gate case MDEC_HSP:
1775*0Sstevel@tonic-gate 	md_hsp_error_t		hsp_error;
1776*0Sstevel@tonic-gate case MDEC_HS:
1777*0Sstevel@tonic-gate 	md_hs_error_t		hs_error;
1778*0Sstevel@tonic-gate case MDEC_MDDB:
1779*0Sstevel@tonic-gate 	md_mddb_error_t		mddb_error;
1780*0Sstevel@tonic-gate case MDEC_DS:
1781*0Sstevel@tonic-gate 	md_ds_error_t		ds_error;
1782*0Sstevel@tonic-gate case MDEC_OVERLAP:
1783*0Sstevel@tonic-gate 	md_overlap_error_t	overlap_error;
1784*0Sstevel@tonic-gate };
1785*0Sstevel@tonic-gate 
1786*0Sstevel@tonic-gate %
1787*0Sstevel@tonic-gate #if !defined(_KERNEL)
1788*0Sstevel@tonic-gate struct md_error_t {
1789*0Sstevel@tonic-gate 	md_error_info_t		info;		/* specific info */
1790*0Sstevel@tonic-gate 	string			host<>;		/* hostname */
1791*0Sstevel@tonic-gate 	string			extra<>;	/* extra context info */
1792*0Sstevel@tonic-gate 	string			name<>;		/* file or device name */
1793*0Sstevel@tonic-gate };
1794*0Sstevel@tonic-gate #else /* _KERNEL */
1795*0Sstevel@tonic-gate struct md_error_t {
1796*0Sstevel@tonic-gate 	md_error_info_t		info;		/* specific info */
1797*0Sstevel@tonic-gate 	u_int			xhost;		/* hostname */
1798*0Sstevel@tonic-gate 	u_int			xextra;	/* extra context info */
1799*0Sstevel@tonic-gate 	u_int			xname;		/* file or device name */
1800*0Sstevel@tonic-gate };
1801*0Sstevel@tonic-gate #endif /* !_KERNEL */
1802*0Sstevel@tonic-gate %#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
1803*0Sstevel@tonic-gate %#pragma pack()
1804*0Sstevel@tonic-gate %#endif
1805*0Sstevel@tonic-gate 
1806*0Sstevel@tonic-gate #ifdef	RPC_HDR
1807*0Sstevel@tonic-gate %
1808*0Sstevel@tonic-gate %/*
1809*0Sstevel@tonic-gate % * Null error constant
1810*0Sstevel@tonic-gate % */
1811*0Sstevel@tonic-gate %#define	MDNULLERROR		{{MDEC_VOID}, NULL, NULL, NULL}
1812*0Sstevel@tonic-gate #endif	/* RPC_HDR */
1813*0Sstevel@tonic-gate 
1814*0Sstevel@tonic-gate #ifdef RPC_XDR
1815*0Sstevel@tonic-gate %/*
1816*0Sstevel@tonic-gate % * Constant null error struct.
1817*0Sstevel@tonic-gate % */
1818*0Sstevel@tonic-gate %const		md_error_t		mdnullerror = MDNULLERROR;
1819*0Sstevel@tonic-gate #endif	/* RPC_XDR */
1820*0Sstevel@tonic-gate 
1821*0Sstevel@tonic-gate #ifdef RPC_HDR
1822*0Sstevel@tonic-gate %
1823*0Sstevel@tonic-gate %/*
1824*0Sstevel@tonic-gate % * External reference to constant null error struct. (declared in mdiox_xdr.c)
1825*0Sstevel@tonic-gate % */
1826*0Sstevel@tonic-gate %extern	const	md_error_t		mdnullerror;
1827*0Sstevel@tonic-gate %
1828*0Sstevel@tonic-gate %/*
1829*0Sstevel@tonic-gate % * External declarations
1830*0Sstevel@tonic-gate % */
1831*0Sstevel@tonic-gate %extern	void	mdclrerror(md_error_t *ep);	/* clear error */
1832*0Sstevel@tonic-gate %extern	int	mdstealerror(md_error_t *to, md_error_t *from);
1833*0Sstevel@tonic-gate %
1834*0Sstevel@tonic-gate %#define	mdiserror(ep, num)	(((ep)->info.errclass == MDEC_VOID) &&\
1835*0Sstevel@tonic-gate %	((ep)->info.md_error_info_t_u.void_error.errnum == (num)))
1836*0Sstevel@tonic-gate %#define	mdisok(ep)	mdiserror(ep, MDE_NONE)
1837*0Sstevel@tonic-gate %
1838*0Sstevel@tonic-gate %#define	mdissyserror(ep, num)	(((ep)->info.errclass == MDEC_SYS) && \
1839*0Sstevel@tonic-gate %	((ep)->info.md_error_info_t_u.sys_error.errnum == (num)))
1840*0Sstevel@tonic-gate %#define	mdisrpcerror(ep, num)	(((ep)->info.errclass == MDEC_RPC) && \
1841*0Sstevel@tonic-gate %	((ep)->info.md_error_info_t_u.rpc_error.errnum == (num)))
1842*0Sstevel@tonic-gate %#define	mdisdeverror(ep, num)	(((ep)->info.errclass == MDEC_DEV) && \
1843*0Sstevel@tonic-gate %	((ep)->info.md_error_info_t_u.dev_error.errnum == (num)))
1844*0Sstevel@tonic-gate %#define	mdisuseerror(ep, num)	(((ep)->info.errclass == MDEC_USE) && \
1845*0Sstevel@tonic-gate %	((ep)->info.md_error_info_t_u.use_error.errnum == (num)))
1846*0Sstevel@tonic-gate %#define	mdismderror(ep, num)	(((ep)->info.errclass == MDEC_MD) && \
1847*0Sstevel@tonic-gate %	((ep)->info.md_error_info_t_u.md_error.errnum == (num)))
1848*0Sstevel@tonic-gate %#define	mdiscomperror(ep, num)	(((ep)->info.errclass == MDEC_COMP) &&\
1849*0Sstevel@tonic-gate %	((ep)->info.md_error_info_t_u.comp_error.errnum == (num)))
1850*0Sstevel@tonic-gate %#define	mdishsperror(ep, num)	(((ep)->info.errclass == MDEC_HSP) && \
1851*0Sstevel@tonic-gate %	((ep)->info.md_error_info_t_u.hsp_error.errnum == (num)))
1852*0Sstevel@tonic-gate %#define	mdishserror(ep, num)	(((ep)->info.errclass == MDEC_HS) && \
1853*0Sstevel@tonic-gate %	((ep)->info.md_error_info_t_u.hs_error.errnum == (num)))
1854*0Sstevel@tonic-gate %#define	mdismddberror(ep, num)	(((ep)->info.errclass == MDEC_MDDB) &&\
1855*0Sstevel@tonic-gate %	((ep)->info.md_error_info_t_u.mddb_error.errnum == (num)))
1856*0Sstevel@tonic-gate %#define	mdisdserror(ep, num)	(((ep)->info.errclass == MDEC_DS) && \
1857*0Sstevel@tonic-gate %	((ep)->info.md_error_info_t_u.ds_error.errnum == (num)))
1858*0Sstevel@tonic-gate %#define	mdisoverlaperror(ep, num) \
1859*0Sstevel@tonic-gate %	(((ep)->info.errclass == MDEC_OVERLAP) && \
1860*0Sstevel@tonic-gate %	((ep)->info.md_error_info_t_u.ds_error.errnum == (num)))
1861*0Sstevel@tonic-gate %
1862*0Sstevel@tonic-gate %#define	mdanysyserror(ep)	((ep)->info.errclass == MDEC_SYS)
1863*0Sstevel@tonic-gate %#define	mdanyrpcerror(ep)	((ep)->info.errclass == MDEC_RPC)
1864*0Sstevel@tonic-gate %#define	mdanydeverror(ep)	((ep)->info.errclass == MDEC_DEV)
1865*0Sstevel@tonic-gate %#define	mdanyuseerror(ep)	((ep)->info.errclass == MDEC_USE)
1866*0Sstevel@tonic-gate %#define	mdanymderror(ep)	((ep)->info.errclass == MDEC_MD)
1867*0Sstevel@tonic-gate %#define	mdanycomperror(ep)	((ep)->info.errclass == MDEC_COMP)
1868*0Sstevel@tonic-gate %#define	mdanyhsperror(ep)	((ep)->info.errclass == MDEC_HSP)
1869*0Sstevel@tonic-gate %#define	mdanyhserror(ep)	((ep)->info.errclass == MDEC_HS)
1870*0Sstevel@tonic-gate %#define	mdanymddberror(ep)	((ep)->info.errclass == MDEC_MDDB)
1871*0Sstevel@tonic-gate %#define	mdanydserror(ep)	((ep)->info.errclass == MDEC_DS)
1872*0Sstevel@tonic-gate %#define	mdanyoverlaperror(ep)	((ep)->info.errclass == MDEC_OVERLAP)
1873*0Sstevel@tonic-gate %
1874*0Sstevel@tonic-gate #ifdef	_KERNEL
1875*0Sstevel@tonic-gate %
1876*0Sstevel@tonic-gate %extern	int	mderror(md_error_t *ep, md_void_errno_t errnum);
1877*0Sstevel@tonic-gate %extern	int	mdsyserror(md_error_t *ep, int errnum);
1878*0Sstevel@tonic-gate %extern	int	mddeverror(md_error_t *ep, md_dev_errno_t errnum,
1879*0Sstevel@tonic-gate %		    md_dev64_t dev);
1880*0Sstevel@tonic-gate %extern	int	mdmderror(md_error_t *ep, md_md_errno_t errnum, minor_t mnum);
1881*0Sstevel@tonic-gate %extern	int	mdcomperror(md_error_t *ep, md_comp_errno_t errnum,
1882*0Sstevel@tonic-gate %		    minor_t mnum, md_dev64_t dev);
1883*0Sstevel@tonic-gate %extern	int	mdhsperror(md_error_t *ep, md_hsp_errno_t errnum, hsp_t hsp);
1884*0Sstevel@tonic-gate %extern	int	mdhserror(md_error_t *ep, md_hs_errno_t errnum,
1885*0Sstevel@tonic-gate %		    hsp_t hsp, md_dev64_t dev);
1886*0Sstevel@tonic-gate %extern	int	mdmddberror(md_error_t *ep, md_mddb_errno_t errnum,
1887*0Sstevel@tonic-gate %		    minor_t mnum, set_t setno);
1888*0Sstevel@tonic-gate %extern	int	mddbstatus2error(md_error_t *ep, int status, minor_t mnum,
1889*0Sstevel@tonic-gate %		    set_t setno);
1890*0Sstevel@tonic-gate %
1891*0Sstevel@tonic-gate #else	/* ! _KERNEL */
1892*0Sstevel@tonic-gate %
1893*0Sstevel@tonic-gate %extern	int	mderror(md_error_t *ep, md_void_errno_t errnum, char *name);
1894*0Sstevel@tonic-gate %extern	int	mdsyserror(md_error_t *ep, int errnum, char *name);
1895*0Sstevel@tonic-gate %extern	int	mdrpcerror(md_error_t *ep, CLIENT *clntp, char *host,
1896*0Sstevel@tonic-gate %		    char *extra);
1897*0Sstevel@tonic-gate %extern	int	mdrpccreateerror(md_error_t *ep, char *host, char *extra);
1898*0Sstevel@tonic-gate %extern	int	mddeverror(md_error_t *ep, md_dev_errno_t errnum,
1899*0Sstevel@tonic-gate %		    md_dev64_t dev, char *name);
1900*0Sstevel@tonic-gate %extern	int	mduseerror(md_error_t *ep, md_use_errno_t errnum,
1901*0Sstevel@tonic-gate %		    md_dev64_t dev, char *where, char *name);
1902*0Sstevel@tonic-gate %extern	int	mdmderror(md_error_t *ep, md_md_errno_t errnum, minor_t mnum,
1903*0Sstevel@tonic-gate %		    char *name);
1904*0Sstevel@tonic-gate %extern	int	mdcomperror(md_error_t *ep, md_comp_errno_t errnum,
1905*0Sstevel@tonic-gate %		    minor_t mnum, md_dev64_t dev, char *name);
1906*0Sstevel@tonic-gate %extern	int	mdhsperror(md_error_t *ep, md_hsp_errno_t errnum, hsp_t hsp,
1907*0Sstevel@tonic-gate %		    char *name);
1908*0Sstevel@tonic-gate %extern	int	mdhserror(md_error_t *ep, md_hs_errno_t errnum,
1909*0Sstevel@tonic-gate %		    hsp_t hsp, md_dev64_t dev, char *name);
1910*0Sstevel@tonic-gate %extern	int	mdmddberror(md_error_t *ep, md_mddb_errno_t errnum,
1911*0Sstevel@tonic-gate %		    minor_t mnum, set_t setno, size_t size, char *name);
1912*0Sstevel@tonic-gate %extern	int	mddserror(md_error_t *ep, md_ds_errno_t errnum, set_t setno,
1913*0Sstevel@tonic-gate %		    char *node, char *drive, char *name);
1914*0Sstevel@tonic-gate %extern	int	mdoverlaperror(md_error_t *ep, md_overlap_errno_t errnum,
1915*0Sstevel@tonic-gate %		    char *overlap, char *where, char *name);
1916*0Sstevel@tonic-gate %
1917*0Sstevel@tonic-gate %extern	void	mderrorextra(md_error_t *ep, char *extra);
1918*0Sstevel@tonic-gate %
1919*0Sstevel@tonic-gate #endif	/* ! _KERNEL */
1920*0Sstevel@tonic-gate #endif	/* RPC_HDR */
1921*0Sstevel@tonic-gate 
1922*0Sstevel@tonic-gate /*
1923*0Sstevel@tonic-gate  * common unit structure
1924*0Sstevel@tonic-gate  */
1925*0Sstevel@tonic-gate struct mdc_unit {
1926*0Sstevel@tonic-gate 	u_longlong_t	un_revision;	/* revision # (keep this a longlong) */
1927*0Sstevel@tonic-gate 	md_types_t	un_type;	/* type of record */
1928*0Sstevel@tonic-gate 	md_status_t	un_status;	/* status flags */
1929*0Sstevel@tonic-gate 	int		un_parent_res; /* parent reserve index */
1930*0Sstevel@tonic-gate 	int		un_child_res;	/* child reserve index */
1931*0Sstevel@tonic-gate 	minor_t		un_self_id;	/* metadevice unit number */
1932*0Sstevel@tonic-gate 	mddb_recid_t	un_record_id;	/* db record id */
1933*0Sstevel@tonic-gate 	uint_t		un_size;	/* db record size for unit structure */
1934*0Sstevel@tonic-gate 	ushort_t	un_flag;	/* configuration info */
1935*0Sstevel@tonic-gate 	diskaddr_t	un_total_blocks; /* external # blocks in metadevice */
1936*0Sstevel@tonic-gate 	diskaddr_t	un_actual_tb;	/* actual # blocks in metadevice */
1937*0Sstevel@tonic-gate 	uint_t		un_nhead;	/* saved value of # heads */
1938*0Sstevel@tonic-gate 	uint_t		un_nsect;	/* saved value of # sectors */
1939*0Sstevel@tonic-gate 	ushort_t	un_rpm;		/* saved value of rpm's */
1940*0Sstevel@tonic-gate 	ushort_t	un_wr_reinstruct; /* worse case write reinstruct */
1941*0Sstevel@tonic-gate 	ushort_t	un_rd_reinstruct; /* worse case read reinstruct */
1942*0Sstevel@tonic-gate 	mddb_recid_t	un_vtoc_id;	/* vtoc db record id */
1943*0Sstevel@tonic-gate 	md_stackcap_t	un_capabilities; /* subdevice capabilities */
1944*0Sstevel@tonic-gate 	md_parent_t	un_parent;	/* -1 none, -2 many, positive unit # */
1945*0Sstevel@tonic-gate 	uint_t		un_user_flags;	/* provided for userland */
1946*0Sstevel@tonic-gate };
1947*0Sstevel@tonic-gate typedef struct mdc_unit mdc_unit_t;
1948*0Sstevel@tonic-gate 
1949*0Sstevel@tonic-gate /*
1950*0Sstevel@tonic-gate  * For old 32 bit format use only
1951*0Sstevel@tonic-gate  */
1952*0Sstevel@tonic-gate %#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
1953*0Sstevel@tonic-gate %#pragma pack(4)
1954*0Sstevel@tonic-gate %#endif
1955*0Sstevel@tonic-gate struct mdc_unit32_od {
1956*0Sstevel@tonic-gate 	u_longlong_t	un_revision;
1957*0Sstevel@tonic-gate 	md_types_t	un_type;
1958*0Sstevel@tonic-gate 	md_status_t	un_status;
1959*0Sstevel@tonic-gate 	int		un_parent_res;
1960*0Sstevel@tonic-gate 	int		un_child_res;
1961*0Sstevel@tonic-gate 	minor_t		un_self_id;
1962*0Sstevel@tonic-gate 	mddb_recid_t	un_record_id;
1963*0Sstevel@tonic-gate 	uint_t		un_size;
1964*0Sstevel@tonic-gate 	ushort_t	un_flag;
1965*0Sstevel@tonic-gate 	daddr32_t	un_total_blocks; /* external # blocks in metadevice */
1966*0Sstevel@tonic-gate 	daddr32_t	un_actual_tb;	/* actual # blocks in metadevice */
1967*0Sstevel@tonic-gate 	ushort_t	un_nhead;
1968*0Sstevel@tonic-gate 	ushort_t	un_nsect;
1969*0Sstevel@tonic-gate 	ushort_t	un_rpm;
1970*0Sstevel@tonic-gate 	ushort_t	un_wr_reinstruct;
1971*0Sstevel@tonic-gate 	ushort_t	un_rd_reinstruct;
1972*0Sstevel@tonic-gate 	mddb_recid_t	un_vtoc_id;
1973*0Sstevel@tonic-gate 	md_stackcap_t	un_capabilities;
1974*0Sstevel@tonic-gate 	md_parent_t	un_parent;
1975*0Sstevel@tonic-gate 	uint_t		un_user_flags;
1976*0Sstevel@tonic-gate };
1977*0Sstevel@tonic-gate typedef struct mdc_unit32_od mdc_unit32_od_t;
1978*0Sstevel@tonic-gate 
1979*0Sstevel@tonic-gate struct md_unit {
1980*0Sstevel@tonic-gate 	mdc_unit_t	c;	/* common stuff */
1981*0Sstevel@tonic-gate };
1982*0Sstevel@tonic-gate typedef struct md_unit md_unit_t;
1983*0Sstevel@tonic-gate 
1984*0Sstevel@tonic-gate enum sp_status_t {
1985*0Sstevel@tonic-gate 	MD_SP_CREATEPEND,	/* soft partition creation in progress */
1986*0Sstevel@tonic-gate 	MD_SP_GROWPEND,		/* attach operation in progress */
1987*0Sstevel@tonic-gate 	MD_SP_DELPEND,		/* delete operation in progress */
1988*0Sstevel@tonic-gate 	MD_SP_OK,		/* soft partition is stable */
1989*0Sstevel@tonic-gate 	MD_SP_ERR,		/* soft partition is errored */
1990*0Sstevel@tonic-gate 	MD_SP_RECOVER,		/* recovery operation in progess */
1991*0Sstevel@tonic-gate 	MD_SP_LAST		/* always the last entry */
1992*0Sstevel@tonic-gate };
1993*0Sstevel@tonic-gate 
1994*0Sstevel@tonic-gate /* soft partition offsets and lengths are specified in sectors */
1995*0Sstevel@tonic-gate typedef u_longlong_t	sp_ext_offset_t;
1996*0Sstevel@tonic-gate typedef u_longlong_t	sp_ext_length_t;
1997*0Sstevel@tonic-gate struct mp_ext {
1998*0Sstevel@tonic-gate 	sp_ext_offset_t un_voff;	/* virtual offset */
1999*0Sstevel@tonic-gate 	sp_ext_offset_t un_poff;	/* physical offset */
2000*0Sstevel@tonic-gate 	sp_ext_length_t un_len;		/* length of extent */
2001*0Sstevel@tonic-gate };
2002*0Sstevel@tonic-gate typedef struct mp_ext mp_ext_t;
2003*0Sstevel@tonic-gate 
2004*0Sstevel@tonic-gate /*
2005*0Sstevel@tonic-gate  * mp_unit32_od is for old 32 bit format only
2006*0Sstevel@tonic-gate  */
2007*0Sstevel@tonic-gate struct mp_unit32_od {
2008*0Sstevel@tonic-gate 	mdc_unit32_od_t	c;		/* common unit structure */
2009*0Sstevel@tonic-gate 	mdkey_t		un_key;		/* namespace key */
2010*0Sstevel@tonic-gate 	dev32_t		un_dev;		/* device number */
2011*0Sstevel@tonic-gate 	sp_ext_offset_t un_start_blk;	/* start block, incl reserved space */
2012*0Sstevel@tonic-gate 	sp_status_t	un_status;	/* sp status */
2013*0Sstevel@tonic-gate 	uint_t		un_numexts;	/* number of extents */
2014*0Sstevel@tonic-gate 	sp_ext_length_t un_length;	/* total length (in sectors) */
2015*0Sstevel@tonic-gate 	/* extent array.  NOTE: sized dynamically! */
2016*0Sstevel@tonic-gate 	mp_ext_t un_ext[1];
2017*0Sstevel@tonic-gate };
2018*0Sstevel@tonic-gate typedef struct mp_unit32_od mp_unit32_od_t;
2019*0Sstevel@tonic-gate 
2020*0Sstevel@tonic-gate /*
2021*0Sstevel@tonic-gate  * softpart unit structure
2022*0Sstevel@tonic-gate  */
2023*0Sstevel@tonic-gate struct mp_unit {
2024*0Sstevel@tonic-gate 	mdc_unit_t	c;		/* common unit structure */
2025*0Sstevel@tonic-gate 	mdkey_t		un_key;		/* namespace key */
2026*0Sstevel@tonic-gate 	md_dev64_t	un_dev;		/* device number, 64 bit */
2027*0Sstevel@tonic-gate 	sp_ext_offset_t	un_start_blk;	/* start block, incl reserved space */
2028*0Sstevel@tonic-gate 	sp_status_t	un_status;	/* sp status */
2029*0Sstevel@tonic-gate 	uint_t		un_numexts;	/* number of extents */
2030*0Sstevel@tonic-gate 	sp_ext_length_t	un_length;	/* total length (in sectors) */
2031*0Sstevel@tonic-gate 	/* extent array.  NOTE: sized dynamically! */
2032*0Sstevel@tonic-gate 	mp_ext_t un_ext[1];
2033*0Sstevel@tonic-gate };
2034*0Sstevel@tonic-gate typedef struct mp_unit mp_unit_t;
2035*0Sstevel@tonic-gate 
2036*0Sstevel@tonic-gate /*
2037*0Sstevel@tonic-gate  * ioctl structures used when passing ioctls via rpc.mdcommd
2038*0Sstevel@tonic-gate  */
2039*0Sstevel@tonic-gate struct md_driver {
2040*0Sstevel@tonic-gate 	char	md_drivername[MD_MAXDRVNM];
2041*0Sstevel@tonic-gate 	set_t	md_setno;
2042*0Sstevel@tonic-gate };
2043*0Sstevel@tonic-gate typedef struct md_driver md_driver_t;
2044*0Sstevel@tonic-gate 
2045*0Sstevel@tonic-gate %#define	MD_DRIVER md_driver_t md_driver;
2046*0Sstevel@tonic-gate #define	MD_DRIVER md_driver_t md_driver;
2047*0Sstevel@tonic-gate 
2048*0Sstevel@tonic-gate struct md_set_params {
2049*0Sstevel@tonic-gate 	MD_DRIVER
2050*0Sstevel@tonic-gate 	md_error_t	mde;
2051*0Sstevel@tonic-gate 	minor_t		mnum;
2052*0Sstevel@tonic-gate 	md_types_t	type;
2053*0Sstevel@tonic-gate 	uint_t		size;
2054*0Sstevel@tonic-gate 	int		options;
2055*0Sstevel@tonic-gate 	uint64_t	mdp;	/* Contains pointer */
2056*0Sstevel@tonic-gate };
2057*0Sstevel@tonic-gate typedef struct md_set_params md_set_params_t;
2058*0Sstevel@tonic-gate %#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
2059*0Sstevel@tonic-gate %#pragma pack()
2060*0Sstevel@tonic-gate %#endif
2061*0Sstevel@tonic-gate 
2062*0Sstevel@tonic-gate 
2063