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