xref: /onnv-gate/usr/src/uts/common/sys/lvm/mdmn_commd.x (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate %
23*0Sstevel@tonic-gate %/*
24*0Sstevel@tonic-gate % * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
25*0Sstevel@tonic-gate % * Use is subject to license terms.
26*0Sstevel@tonic-gate % */
27*0Sstevel@tonic-gate %
28*0Sstevel@tonic-gate %#pragma ident	"%Z%%M%	%I%	%E% SMI"
29*0Sstevel@tonic-gate 
30*0Sstevel@tonic-gate %#include <sys/types.h>
31*0Sstevel@tonic-gate %#include <sys/types32.h>
32*0Sstevel@tonic-gate %#include <sys/lvm/md_basic.h>
33*0Sstevel@tonic-gate %#include <sys/lvm/mdio.h>
34*0Sstevel@tonic-gate %#ifndef _KERNEL
35*0Sstevel@tonic-gate %#include <mdiox.h>
36*0Sstevel@tonic-gate %#include <meta_basic.h>
37*0Sstevel@tonic-gate %extern  bool_t  xdr_md_set_params_t(XDR *xdrs, md_set_params_t *objp);
38*0Sstevel@tonic-gate %extern  bool_t  xdr_mp_unit_t(XDR *xdrs, mp_unit_t *objp);
39*0Sstevel@tonic-gate %extern  bool_t  xdr_diskaddr_t(XDR *xdrs, diskaddr_t *objp);
40*0Sstevel@tonic-gate %extern  bool_t  xdr_md_dev64_t(XDR *xdrs, md_dev64_t *objp);
41*0Sstevel@tonic-gate %extern  bool_t  xdr_daddr_t(XDR *xdrs, daddr_t *objp);
42*0Sstevel@tonic-gate %extern  bool_t  xdr_daddr32_t(XDR *xdrs, daddr32_t *objp);
43*0Sstevel@tonic-gate %#else
44*0Sstevel@tonic-gate %#include <sys/lvm/md_mdiox.h>
45*0Sstevel@tonic-gate %#endif /* ! _KERNEL */
46*0Sstevel@tonic-gate 
47*0Sstevel@tonic-gate /* every message handler must have these parameters */
48*0Sstevel@tonic-gate %#define	HANDLER_PARMS md_mn_msg_t *msg, uint_t flag, md_mn_result_t *res
49*0Sstevel@tonic-gate 
50*0Sstevel@tonic-gate 
51*0Sstevel@tonic-gate /* every submessage generator must have these parameters */
52*0Sstevel@tonic-gate %#define	SMGEN_PARMS md_mn_msg_t *msg, md_mn_msg_t **msglist
53*0Sstevel@tonic-gate 
54*0Sstevel@tonic-gate /* when ever a new message type is added, an entry for it must be made in the master msg_table (defined in mdmn_commd_server.c*/
55*0Sstevel@tonic-gate 
56*0Sstevel@tonic-gate enum md_mn_msgtype_t {
57*0Sstevel@tonic-gate         MD_MN_MSG_NULL = 0,  /* special message type for internal use only */
58*0Sstevel@tonic-gate 	MD_MN_MSG_TEST1,
59*0Sstevel@tonic-gate 	MD_MN_MSG_TEST2,
60*0Sstevel@tonic-gate 	MD_MN_MSG_TEST3,
61*0Sstevel@tonic-gate 	MD_MN_MSG_TEST4,
62*0Sstevel@tonic-gate 	MD_MN_MSG_TEST5,
63*0Sstevel@tonic-gate 	MD_MN_MSG_TEST6,
64*0Sstevel@tonic-gate 	MD_MN_MSG_BC_CMD,		/* Send metacommand */
65*0Sstevel@tonic-gate 	MD_MN_MSG_BC_CMD_RETRY,		/* Send metacommand, retry on busy */
66*0Sstevel@tonic-gate 	MD_MN_MSG_CLU_CHECK,
67*0Sstevel@tonic-gate 	MD_MN_MSG_CLU_LOCK,
68*0Sstevel@tonic-gate 	MD_MN_MSG_CLU_UNLOCK,
69*0Sstevel@tonic-gate 	MD_MN_MSG_REQUIRE_OWNER,	/* Request to become Mirror owner */
70*0Sstevel@tonic-gate 	MD_MN_MSG_CHOOSE_OWNER,		/* Request to allocate a resync owner */
71*0Sstevel@tonic-gate 	MD_MN_MSG_CHANGE_OWNER,		/* Change owner to a specific node */
72*0Sstevel@tonic-gate 	MD_MN_MSG_SUSPEND_WRITES,	/* Suspend writes to a mirror */
73*0Sstevel@tonic-gate 	MD_MN_MSG_STATE_UPDATE_RESWR,	/* Ch state of comp & resume writes */
74*0Sstevel@tonic-gate 	MD_MN_MSG_STATE_UPDATE,		/* Susp writes/Change state of comp */
75*0Sstevel@tonic-gate 	MD_MN_MSG_ALLOCATE_HOTSPARE,	/* Allocate hotspare for mirror comp */
76*0Sstevel@tonic-gate 	MD_MN_MSG_RESYNC_STARTING,	/* Resync thread starting */
77*0Sstevel@tonic-gate 	MD_MN_MSG_RESYNC_NEXT,		/* Next resync region */
78*0Sstevel@tonic-gate 	MD_MN_MSG_RESYNC_FINISH,	/* Resync thread finished */
79*0Sstevel@tonic-gate 	MD_MN_MSG_RESYNC_PHASE_DONE,	/* End of resync phase */
80*0Sstevel@tonic-gate 	MD_MN_MSG_SET_CAP,		/* Set capability, eg ABR */
81*0Sstevel@tonic-gate 	MD_MN_MSG_VERBOSITY,		/* set various levels of debug */
82*0Sstevel@tonic-gate 	MD_MN_MSG_MDDB_PARSE,		/* Slave to reparse portion of mddb */
83*0Sstevel@tonic-gate 	MD_MN_MSG_MDDB_BLOCK,		/* Block parse/recs on master/slave */
84*0Sstevel@tonic-gate 	MD_MN_MSG_META_DB_ATTACH,	/* Master message to add new mddb */
85*0Sstevel@tonic-gate 	MD_MN_MSG_SM_MDDB_ATTACH,	/* Submessage to add new mddb */
86*0Sstevel@tonic-gate 	MD_MN_MSG_META_DB_DETACH,	/* Master message to delete mddb */
87*0Sstevel@tonic-gate 	MD_MN_MSG_SM_MDDB_DETACH,	/* Submessage to delete mddb */
88*0Sstevel@tonic-gate 	MD_MN_MSG_META_DB_NEWSIDE,	/* Node adding mddb side info */
89*0Sstevel@tonic-gate 	MD_MN_MSG_META_DB_DELSIDE,	/* Node deleting mddb side info */
90*0Sstevel@tonic-gate 	MD_MN_MSG_META_MD_ADDSIDE,	/* Node adding md side info */
91*0Sstevel@tonic-gate 	MD_MN_MSG_META_MD_DELSIDE,	/* Node deleting md side info */
92*0Sstevel@tonic-gate 	MD_MN_MSG_MDDB_OPTRECERR,	/* Node detects opt rec error */
93*0Sstevel@tonic-gate 	MD_MN_MSG_ABORT,		/* Stop sending messages to any node */
94*0Sstevel@tonic-gate 	MD_MN_MSG_STATE_UPDATE_RESWR2,	/* UPDATE_RESWR for watermark updates */
95*0Sstevel@tonic-gate 	MD_MN_MSG_STATE_UPDATE2,	/* STATE_UPDATE for watermark updates */
96*0Sstevel@tonic-gate 	MD_MN_MSG_ALLOCATE_HOTSPARE2,	/* ALLOCATE_HOTSPARE for wm updates */
97*0Sstevel@tonic-gate 	MD_MN_MSG_IOCSET,		/* Send IOCSET ioctl */
98*0Sstevel@tonic-gate 	MD_MN_MSG_SP_SETSTAT,		/* Update status of softpart */
99*0Sstevel@tonic-gate 	MD_MN_MSG_ADDKEYNAME,		/* Add key */
100*0Sstevel@tonic-gate 	MD_MN_MSG_DELKEYNAME,		/* Delete key */
101*0Sstevel@tonic-gate 	MD_MN_MSG_GET_TSTATE,		/* Get tstate from master */
102*0Sstevel@tonic-gate 	MD_MN_MSG_GET_MIRROR_STATE,	/* Get submirror state from master */
103*0Sstevel@tonic-gate 	MD_MN_MSG_SP_SETSTAT2,		/* Update softpart status on error */
104*0Sstevel@tonic-gate 	MD_MN_MSG_SETSYNC,		/* Set resync status */
105*0Sstevel@tonic-gate 	MD_MN_MSG_POKE_HOTSPARES,	/* Call poke_hotspares */
106*0Sstevel@tonic-gate 	MD_MN_NMESSAGES /* insert elements before */
107*0Sstevel@tonic-gate };
108*0Sstevel@tonic-gate 
109*0Sstevel@tonic-gate /*
110*0Sstevel@tonic-gate  * A message of class X may trigger only messages of classes higher than X
111*0Sstevel@tonic-gate  * Feel free to change the order here. As long as you leave MD_MSG_CL_NULL
112*0Sstevel@tonic-gate  * and NCLASSES, of course
113*0Sstevel@tonic-gate  */
114*0Sstevel@tonic-gate 
115*0Sstevel@tonic-gate enum md_mn_msgclass_t {
116*0Sstevel@tonic-gate 	MD_MSG_CLASS0 = 0,  /* special message class for internal use only */
117*0Sstevel@tonic-gate 	MD_MSG_CLASS1,
118*0Sstevel@tonic-gate 	MD_MSG_CLASS2,
119*0Sstevel@tonic-gate 	MD_MSG_CLASS3,
120*0Sstevel@tonic-gate 	MD_MSG_CLASS4,
121*0Sstevel@tonic-gate 	MD_MSG_CLASS5,
122*0Sstevel@tonic-gate 	MD_MSG_CLASS6,
123*0Sstevel@tonic-gate 	MD_MSG_CLASS7,
124*0Sstevel@tonic-gate 	MD_MN_NCLASSES /* insert elements before */
125*0Sstevel@tonic-gate };
126*0Sstevel@tonic-gate 
127*0Sstevel@tonic-gate %/*
128*0Sstevel@tonic-gate % * The following are needed for things like suspend and resume when the
129*0Sstevel@tonic-gate % * operation is to be applied to all classes / all sets.
130*0Sstevel@tonic-gate % */
131*0Sstevel@tonic-gate %#define	MD_COMM_ALL_CLASSES MD_MSG_CLASS0
132*0Sstevel@tonic-gate %#define	MD_COMM_ALL_SETS 0
133*0Sstevel@tonic-gate 
134*0Sstevel@tonic-gate /* This is for state changes of submirror components */
135*0Sstevel@tonic-gate struct md_mn_msg_stch_t {
136*0Sstevel@tonic-gate         minor_t		msg_stch_mnum;		/* minor number of dev */
137*0Sstevel@tonic-gate 	int		msg_stch_sm;		/* submirror involved */
138*0Sstevel@tonic-gate 	int		msg_stch_comp;		/* component */
139*0Sstevel@tonic-gate 	int		msg_stch_new_state;	/* new state for comp */
140*0Sstevel@tonic-gate 	mddb_recid_t	msg_stch_hs_id;		/* hs_id at time of call */
141*0Sstevel@tonic-gate };
142*0Sstevel@tonic-gate 
143*0Sstevel@tonic-gate 
144*0Sstevel@tonic-gate /* This is for suspending writes to a mirror */
145*0Sstevel@tonic-gate struct md_mn_msg_suspwr_t {
146*0Sstevel@tonic-gate         minor_t         msg_suspwr_mnum;        /* minor number of dev */
147*0Sstevel@tonic-gate };
148*0Sstevel@tonic-gate 
149*0Sstevel@tonic-gate /* Message format for choosing a resync owner */
150*0Sstevel@tonic-gate struct md_mn_msg_chooseid_t {
151*0Sstevel@tonic-gate 	minor_t	msg_chooseid_mnum;	/* minor num of dev */
152*0Sstevel@tonic-gate 	int	msg_chooseid_rcnt;	/* resync count for set */
153*0Sstevel@tonic-gate 	int	msg_chooseid_set_node;	/* 1 => use rcnt as nodeid for owner */
154*0Sstevel@tonic-gate };
155*0Sstevel@tonic-gate 
156*0Sstevel@tonic-gate /* Message format for changing a resync owner */
157*0Sstevel@tonic-gate struct md_mn_msg_chowner_t {
158*0Sstevel@tonic-gate 	minor_t	msg_chowner_mnum;	/* minor num of dev */
159*0Sstevel@tonic-gate 	int	msg_chowner_nodeid;	/* node id of new owner */
160*0Sstevel@tonic-gate };
161*0Sstevel@tonic-gate 
162*0Sstevel@tonic-gate /* Message format for setting metadevice capability */
163*0Sstevel@tonic-gate struct md_mn_msg_setcap_t {
164*0Sstevel@tonic-gate 	char msg_setcap_driver[MD_DRIVERNAMELEN];	/* Driver name */
165*0Sstevel@tonic-gate 	minor_t	msg_setcap_mnum;	/* minor num of dev */
166*0Sstevel@tonic-gate 	u_int	msg_setcap_set;		/* new settings */
167*0Sstevel@tonic-gate };
168*0Sstevel@tonic-gate 
169*0Sstevel@tonic-gate /* This is for setting the verbosity level (MD_MN_MSG_VERBOSITY) */
170*0Sstevel@tonic-gate struct md_mn_verbose_t {
171*0Sstevel@tonic-gate 	set_t			mmv_setno;
172*0Sstevel@tonic-gate 	md_mn_msgclass_t	mmv_class;
173*0Sstevel@tonic-gate 	u_int			mmv_what;
174*0Sstevel@tonic-gate };
175*0Sstevel@tonic-gate 
176*0Sstevel@tonic-gate /* What do we want to debug ? (mmv_what) */
177*0Sstevel@tonic-gate %/* turn off everything */
178*0Sstevel@tonic-gate %#define	MD_MMV_NULL 		0x00000000
179*0Sstevel@tonic-gate %/* initialization of nodes / rpc clients */
180*0Sstevel@tonic-gate %#define	MD_MMV_INIT		0x00000001
181*0Sstevel@tonic-gate %/* mdmn_send_svc_1 related / early stage */
182*0Sstevel@tonic-gate %#define	MD_MMV_SEND		0x00000002
183*0Sstevel@tonic-gate %/* mdmn_work_svc_1 stuff on master */
184*0Sstevel@tonic-gate %#define	MD_MMV_WORK		0x00000004
185*0Sstevel@tonic-gate %/* mdmn_master_process_msg stuff */
186*0Sstevel@tonic-gate %#define	MD_MMV_PROC_M		0x00000008
187*0Sstevel@tonic-gate %/* mdmn_slave_process_msg stuff */
188*0Sstevel@tonic-gate %#define	MD_MMV_PROC_S		0x00000010
189*0Sstevel@tonic-gate %/* wakeup_master  */
190*0Sstevel@tonic-gate %#define	MD_MMV_WAKE_M		0x00000020
191*0Sstevel@tonic-gate %/* wakeup_initiator */
192*0Sstevel@tonic-gate %#define	MD_MMV_WAKE_I		0x00000040
193*0Sstevel@tonic-gate %/* Misc stuff*/
194*0Sstevel@tonic-gate %#define	MD_MMV_MISC		0x00000080
195*0Sstevel@tonic-gate %/* turn on everything */
196*0Sstevel@tonic-gate %#define	MD_MMV_ALL		0x0000ffff
197*0Sstevel@tonic-gate %/* write to syslog instead of output file, for critical messages */
198*0Sstevel@tonic-gate %#define	MD_MMV_SYSLOG		0x10000000
199*0Sstevel@tonic-gate %/* enable timestamps */
200*0Sstevel@tonic-gate %#define	MD_MMV_TIMESTAMP	0x20000000
201*0Sstevel@tonic-gate 
202*0Sstevel@tonic-gate 
203*0Sstevel@tonic-gate /* Message format for allocating hotspares */
204*0Sstevel@tonic-gate struct md_mn_msg_allochsp_t {
205*0Sstevel@tonic-gate 	minor_t msg_allochsp_mnum;		/* minor num of dev */
206*0Sstevel@tonic-gate 	int msg_allochsp_sm;			/* submirror index */
207*0Sstevel@tonic-gate 	int msg_allochsp_comp;			/* component index */
208*0Sstevel@tonic-gate 	mddb_recid_t msg_allochsp_hs_id;	/* hotspare id */
209*0Sstevel@tonic-gate };
210*0Sstevel@tonic-gate 
211*0Sstevel@tonic-gate /* Message format for resync messages */
212*0Sstevel@tonic-gate struct md_mn_msg_resync_t {
213*0Sstevel@tonic-gate 	minor_t msg_resync_mnum;		/* minor num of dev */
214*0Sstevel@tonic-gate 	int msg_resync_type;			/* resync type */
215*0Sstevel@tonic-gate 	diskaddr_t msg_resync_start;		/* start of resync region */
216*0Sstevel@tonic-gate 	diskaddr_t msg_resync_rsize;		/* size of resync region */
217*0Sstevel@tonic-gate 	diskaddr_t msg_resync_done;		/* count of resync done */
218*0Sstevel@tonic-gate 	diskaddr_t msg_resync_2_do;		/* total size of resync */
219*0Sstevel@tonic-gate 	int msg_originator;			/* message originator */
220*0Sstevel@tonic-gate 	int	msg_resync_flags;		/* resync flags */
221*0Sstevel@tonic-gate 	sm_state_t	msg_sm_state[NMIRROR];	/* submirror state */
222*0Sstevel@tonic-gate 	sm_flags_t	msg_sm_flags[NMIRROR];	/* submirror flags */
223*0Sstevel@tonic-gate };
224*0Sstevel@tonic-gate 
225*0Sstevel@tonic-gate %#define	MD_MSGF_DEFAULT_FLAGS		0x00000000
226*0Sstevel@tonic-gate 
227*0Sstevel@tonic-gate /* Message format for blocking/unblocking MDDB parsing and record changes  */
228*0Sstevel@tonic-gate struct md_mn_msg_mddb_block_t {
229*0Sstevel@tonic-gate 	int	msg_block_flags;
230*0Sstevel@tonic-gate };
231*0Sstevel@tonic-gate 
232*0Sstevel@tonic-gate /* Message format for MDDB re-parsing */
233*0Sstevel@tonic-gate struct md_mn_msg_mddb_parse_t {
234*0Sstevel@tonic-gate 	int	msg_parse_flags;	/* flags describe part to reparse */
235*0Sstevel@tonic-gate 	int	msg_lb_flags[50];
236*0Sstevel@tonic-gate };
237*0Sstevel@tonic-gate 
238*0Sstevel@tonic-gate /* Message format for MDDB attach */
239*0Sstevel@tonic-gate struct md_mn_msg_meta_db_attach_t {
240*0Sstevel@tonic-gate 	md_dev64_t	msg_l_dev;
241*0Sstevel@tonic-gate 	int		msg_cnt;
242*0Sstevel@tonic-gate 	int		msg_dbsize;
243*0Sstevel@tonic-gate 	char		msg_dname[16];
244*0Sstevel@tonic-gate 	md_splitname	msg_splitname;
245*0Sstevel@tonic-gate 	u_int		msg_options;
246*0Sstevel@tonic-gate 	char		msg_devid[1];	/* unused for now, for future */
247*0Sstevel@tonic-gate 					/* must be last element */
248*0Sstevel@tonic-gate };
249*0Sstevel@tonic-gate 
250*0Sstevel@tonic-gate /* Message format for MDDB detach */
251*0Sstevel@tonic-gate struct md_mn_msg_meta_db_detach_t {
252*0Sstevel@tonic-gate 	md_splitname	msg_splitname;
253*0Sstevel@tonic-gate 	char		msg_devid[1];	/* unused for now, for future */
254*0Sstevel@tonic-gate 					/* must be last element */
255*0Sstevel@tonic-gate };
256*0Sstevel@tonic-gate 
257*0Sstevel@tonic-gate /* Message format for MDDB newside */
258*0Sstevel@tonic-gate struct md_mn_msg_meta_db_newside_t {
259*0Sstevel@tonic-gate 	md_dev64_t	msg_l_dev;
260*0Sstevel@tonic-gate 	daddr_t		msg_blkno;
261*0Sstevel@tonic-gate 	side_t		msg_sideno;
262*0Sstevel@tonic-gate 	minor_t		msg_mnum;
263*0Sstevel@tonic-gate 	char		msg_dname[16];
264*0Sstevel@tonic-gate 	md_splitname	msg_splitname;
265*0Sstevel@tonic-gate 	char		msg_devid[1];	/* unused for now, for future */
266*0Sstevel@tonic-gate 					/* must be last element */
267*0Sstevel@tonic-gate };
268*0Sstevel@tonic-gate 
269*0Sstevel@tonic-gate /* Message format for MDDB delside */
270*0Sstevel@tonic-gate struct md_mn_msg_meta_db_delside_t {
271*0Sstevel@tonic-gate 	md_dev64_t	msg_l_dev;
272*0Sstevel@tonic-gate 	daddr_t		msg_blkno;
273*0Sstevel@tonic-gate 	side_t		msg_sideno;
274*0Sstevel@tonic-gate 	char		msg_devid[1];	/* unused for now, for future */
275*0Sstevel@tonic-gate 					/* must be last element */
276*0Sstevel@tonic-gate };
277*0Sstevel@tonic-gate 
278*0Sstevel@tonic-gate /* Message format for MD addside */
279*0Sstevel@tonic-gate struct md_mn_msg_meta_md_addside_t {
280*0Sstevel@tonic-gate 	side_t		msg_sideno;
281*0Sstevel@tonic-gate 	side_t		msg_otherside;
282*0Sstevel@tonic-gate };
283*0Sstevel@tonic-gate 
284*0Sstevel@tonic-gate /* Message format for MDDB delside */
285*0Sstevel@tonic-gate struct md_mn_msg_meta_md_delside_t {
286*0Sstevel@tonic-gate 	side_t		msg_sideno;
287*0Sstevel@tonic-gate };
288*0Sstevel@tonic-gate 
289*0Sstevel@tonic-gate /* Message format for optimized record error */
290*0Sstevel@tonic-gate struct md_mn_msg_mddb_optrecerr_t {
291*0Sstevel@tonic-gate 	md_replica_recerr_t	msg_recerr[2];
292*0Sstevel@tonic-gate };
293*0Sstevel@tonic-gate 
294*0Sstevel@tonic-gate /*
295*0Sstevel@tonic-gate  * Message format for IOCSET message
296*0Sstevel@tonic-gate  */
297*0Sstevel@tonic-gate 
298*0Sstevel@tonic-gate struct md_mn_msg_iocset_t {
299*0Sstevel@tonic-gate 	md_set_params_t	iocset_params;
300*0Sstevel@tonic-gate 	mp_unit_t		unit;
301*0Sstevel@tonic-gate };
302*0Sstevel@tonic-gate 
303*0Sstevel@tonic-gate /* Message format for SP_SETSTAT message */
304*0Sstevel@tonic-gate 
305*0Sstevel@tonic-gate struct md_mn_msg_sp_setstat_t {
306*0Sstevel@tonic-gate 	minor_t		sp_setstat_mnum;
307*0Sstevel@tonic-gate 	int		sp_setstat_status;
308*0Sstevel@tonic-gate };
309*0Sstevel@tonic-gate 
310*0Sstevel@tonic-gate /* Message format for ADDKEYNAME message */
311*0Sstevel@tonic-gate 
312*0Sstevel@tonic-gate struct md_mn_msg_addkeyname_t {
313*0Sstevel@tonic-gate 	set_t		addkeyname_setno;
314*0Sstevel@tonic-gate 	char		addkeyname_name[1];	/* must be last element */
315*0Sstevel@tonic-gate };
316*0Sstevel@tonic-gate 
317*0Sstevel@tonic-gate /* Message format for DELKEYNAME message */
318*0Sstevel@tonic-gate 
319*0Sstevel@tonic-gate struct md_mn_msg_delkeyname_t {
320*0Sstevel@tonic-gate 	md_dev64_t	delkeyname_dev;
321*0Sstevel@tonic-gate 	set_t		delkeyname_setno;
322*0Sstevel@tonic-gate 	mdkey_t		delkeyname_key;
323*0Sstevel@tonic-gate };
324*0Sstevel@tonic-gate 
325*0Sstevel@tonic-gate /* Message format for GET_TSTATE message */
326*0Sstevel@tonic-gate 
327*0Sstevel@tonic-gate struct md_mn_msg_gettstate_t {
328*0Sstevel@tonic-gate 	md_dev64_t	gettstate_dev;
329*0Sstevel@tonic-gate };
330*0Sstevel@tonic-gate 
331*0Sstevel@tonic-gate /* Message format for GET_MIRROR_STATE message */
332*0Sstevel@tonic-gate 
333*0Sstevel@tonic-gate struct md_mn_msg_mir_state_t {
334*0Sstevel@tonic-gate 	minor_t		mir_state_mnum;
335*0Sstevel@tonic-gate };
336*0Sstevel@tonic-gate 
337*0Sstevel@tonic-gate /* Results format for GET_SM_STATE message */
338*0Sstevel@tonic-gate struct md_mn_msg_mir_state_res_t {
339*0Sstevel@tonic-gate 	sm_state_t	sm_state[NMIRROR];
340*0Sstevel@tonic-gate 	sm_flags_t	sm_flags[NMIRROR];
341*0Sstevel@tonic-gate 	u_int		mir_tstate;
342*0Sstevel@tonic-gate };
343*0Sstevel@tonic-gate 
344*0Sstevel@tonic-gate /* Message format for MD_MN_MSG_SETSYNC message */
345*0Sstevel@tonic-gate struct md_mn_msg_setsync_t {
346*0Sstevel@tonic-gate 	minor_t		setsync_mnum;
347*0Sstevel@tonic-gate 	md_riflags_t	setsync_flags;
348*0Sstevel@tonic-gate 	diskaddr_t	setsync_copysize;
349*0Sstevel@tonic-gate };
350*0Sstevel@tonic-gate 
351*0Sstevel@tonic-gate /* Message format for MD_MN_MSG_POKE_HOTSPARES message */
352*0Sstevel@tonic-gate struct md_mn_msg_pokehsp_t {
353*0Sstevel@tonic-gate 	minor_t		pokehsp_setno;
354*0Sstevel@tonic-gate };
355*0Sstevel@tonic-gate 
356*0Sstevel@tonic-gate %#define	MD_MSGF_NO_LOG			0x00000001
357*0Sstevel@tonic-gate %#define	MD_MSGF_NO_BCAST		0x00000002
358*0Sstevel@tonic-gate %#define	MD_MSGF_STOP_ON_ERROR		0x00000004
359*0Sstevel@tonic-gate %#define	MD_MSGF_REPLAY_MSG		0x00000008
360*0Sstevel@tonic-gate %#define	MD_MSGF_OVERRIDE_SUSPEND	0x00000010
361*0Sstevel@tonic-gate %#define	MD_MSGF_ON_MASTER		0x00000020
362*0Sstevel@tonic-gate %#define	MD_MSGF_ON_SLAVE		0x00000040
363*0Sstevel@tonic-gate %#define	MD_MSGF_ON_INITIATOR		0x00000080
364*0Sstevel@tonic-gate %#define	MD_MSGF_LOCAL_ONLY		0x00000100
365*0Sstevel@tonic-gate %#define	MD_MSGF_FAIL_ON_SUSPEND		0x00000200
366*0Sstevel@tonic-gate %#define	MD_MSGF_NO_MCT			0x00000400
367*0Sstevel@tonic-gate %#define	MD_MSGF_PANIC_WHEN_INCONSISTENT	0x00000800
368*0Sstevel@tonic-gate %#define	MD_MSGF_VERBOSE			0x10000000
369*0Sstevel@tonic-gate %#define	MD_MSGF_VERBOSE_2		0x20000000
370*0Sstevel@tonic-gate 
371*0Sstevel@tonic-gate %#define	MD_MSGF_INHERIT_BITS		\
372*0Sstevel@tonic-gate %			MD_MSGF_REPLAY_MSG | MD_MSGF_OVERRIDE_SUSPEND
373*0Sstevel@tonic-gate 
374*0Sstevel@tonic-gate 
375*0Sstevel@tonic-gate 
376*0Sstevel@tonic-gate %/* maximum number of nodes in cluster (not in diskset) */
377*0Sstevel@tonic-gate %#define	NNODES MD_MNMAXSIDES
378*0Sstevel@tonic-gate 
379*0Sstevel@tonic-gate 
380*0Sstevel@tonic-gate /* if you add elements here, make sure, to add them to MSGID_COPY(), too */
381*0Sstevel@tonic-gate struct md_mn_msgid_t {
382*0Sstevel@tonic-gate 	uint64_t	mid_time;	/* unique timestamp */
383*0Sstevel@tonic-gate 	md_mn_nodeid_t	mid_nid;	/* node that created the message */
384*0Sstevel@tonic-gate 	md_mn_msgclass_t mid_oclass;	/* for submessages original class */
385*0Sstevel@tonic-gate 	uint8_t		mid_smid;	/* sub message number */
386*0Sstevel@tonic-gate 	uint8_t		mid_spare[15];	/* Always good to have some spares */
387*0Sstevel@tonic-gate };
388*0Sstevel@tonic-gate 
389*0Sstevel@tonic-gate %#define MD_NULL_MSGID (md_mn_msgid_t *)NULL
390*0Sstevel@tonic-gate %
391*0Sstevel@tonic-gate %/* macros to handle msgid's */
392*0Sstevel@tonic-gate %#define	MSGID_COPY(from, to) {				\
393*0Sstevel@tonic-gate %			(to)->mid_nid = (from)->mid_nid;	\
394*0Sstevel@tonic-gate %			(to)->mid_smid = (from)->mid_smid;	\
395*0Sstevel@tonic-gate %			(to)->mid_oclass = (from)->mid_oclass;	\
396*0Sstevel@tonic-gate %			(to)->mid_time = (from)->mid_time;	\
397*0Sstevel@tonic-gate %		}
398*0Sstevel@tonic-gate %
399*0Sstevel@tonic-gate %#define	MSGID_CMP(a, b) 				\
400*0Sstevel@tonic-gate %			(((a)->mid_nid == (b)->mid_nid) &&	\
401*0Sstevel@tonic-gate %			((a)->mid_smid == (b)->mid_smid) &&	\
402*0Sstevel@tonic-gate %			((a)->mid_time == (b)->mid_time))
403*0Sstevel@tonic-gate %
404*0Sstevel@tonic-gate %#define	MSGID_ELEMS(mid) (mid).mid_nid, (mid).mid_time, (mid).mid_smid
405*0Sstevel@tonic-gate 
406*0Sstevel@tonic-gate /* if you add elements here, make sure, to add them to copy_msg(), too */
407*0Sstevel@tonic-gate struct md_mn_msg_t {
408*0Sstevel@tonic-gate         md_mn_msgid_t	msg_msgid;	/* Message id */
409*0Sstevel@tonic-gate 	md_mn_nodeid_t	msg_sender;	/* who wants the results? */
410*0Sstevel@tonic-gate 	u_int		msg_flags;	/* See MD_MSGF_* above */
411*0Sstevel@tonic-gate 	set_t		msg_setno;	/* which set is involved */
412*0Sstevel@tonic-gate         md_mn_msgtype_t msg_type;       /* what type of message */
413*0Sstevel@tonic-gate 	char		msg_spare[32];	/* Always good to hav'em */
414*0Sstevel@tonic-gate 	opaque		msg_event<>;	/* the actual event wrapped up */
415*0Sstevel@tonic-gate };
416*0Sstevel@tonic-gate %#define	msg_event_data	msg_event.msg_event_val
417*0Sstevel@tonic-gate %#define	msg_event_size	msg_event.msg_event_len
418*0Sstevel@tonic-gate %
419*0Sstevel@tonic-gate %#define	MD_MN_MSG_LEN(msg)	((msg)->msg_event_size +\
420*0Sstevel@tonic-gate %							sizeof (md_mn_msg_t))
421*0Sstevel@tonic-gate %#define	MD_MN_MSG_MAXDATALEN	1024
422*0Sstevel@tonic-gate 
423*0Sstevel@tonic-gate /* ondisk version of the message */
424*0Sstevel@tonic-gate struct md_mn_msg_od_t {
425*0Sstevel@tonic-gate         md_mn_msgid_t	msg_msgid;	/* Message id */
426*0Sstevel@tonic-gate 	md_mn_nodeid_t	msg_sender;	/* who wants the results? */
427*0Sstevel@tonic-gate 	uint32_t	msg_flags;	/* See MD_MSGF_* above */
428*0Sstevel@tonic-gate 	set_t		msg_setno;	/* which set is involved */
429*0Sstevel@tonic-gate         md_mn_msgtype_t msg_type;       /* what type of message */
430*0Sstevel@tonic-gate 	char		msg_spare[32];	/* Always good to hav'em */
431*0Sstevel@tonic-gate 	uint32_t	msg_ev_len;
432*0Sstevel@tonic-gate 	char		msg_ev_val[MD_MN_MSG_MAXDATALEN];
433*0Sstevel@tonic-gate };
434*0Sstevel@tonic-gate %
435*0Sstevel@tonic-gate %#define	msg_od_event_data	msg_ev_val
436*0Sstevel@tonic-gate %#define	msg_od_event_size	msg_ev_len
437*0Sstevel@tonic-gate %#define	MDMN_MAX_KMSG_DATA	256
438*0Sstevel@tonic-gate 
439*0Sstevel@tonic-gate /* needed for mdmn_ksend_message to deliver the data into userland thru doors */
440*0Sstevel@tonic-gate struct md_mn_kmsg_t {
441*0Sstevel@tonic-gate 	md_mn_msgid_t 	kmsg_msgid;
442*0Sstevel@tonic-gate 	u_int		kmsg_flags;
443*0Sstevel@tonic-gate 	set_t		kmsg_setno;
444*0Sstevel@tonic-gate 	md_mn_msgtype_t	kmsg_type;
445*0Sstevel@tonic-gate 	int		kmsg_size;
446*0Sstevel@tonic-gate 	char		kmsg_data[MDMN_MAX_KMSG_DATA];
447*0Sstevel@tonic-gate };
448*0Sstevel@tonic-gate 
449*0Sstevel@tonic-gate /* if you add elements here, make sure, to add them to copy_result(), too */
450*0Sstevel@tonic-gate struct md_mn_result_t {
451*0Sstevel@tonic-gate 	md_mn_msgid_t	mmr_msgid;
452*0Sstevel@tonic-gate 	md_mn_msgtype_t	mmr_msgtype;
453*0Sstevel@tonic-gate 	set_t		mmr_setno;
454*0Sstevel@tonic-gate 	u_int		mmr_flags;
455*0Sstevel@tonic-gate 	md_mn_nodeid_t	mmr_sender;   /* needed to check for unsolicited msgs */
456*0Sstevel@tonic-gate 	md_mn_nodeid_t	mmr_failing_node; /* trouble maker */
457*0Sstevel@tonic-gate 	int		mmr_comm_state;
458*0Sstevel@tonic-gate 	int		mmr_exitval;
459*0Sstevel@tonic-gate 	md_error_t	mmr_ep;
460*0Sstevel@tonic-gate 	opaque		mmr_output<>; /* msg handler can store output here */
461*0Sstevel@tonic-gate 	opaque		mmr_error<>;  /* ... and error output goes here */
462*0Sstevel@tonic-gate };
463*0Sstevel@tonic-gate 
464*0Sstevel@tonic-gate %#define	MDMN_MAX_KRES_DATA	256
465*0Sstevel@tonic-gate /* kernel results don't provide something like stderr */
466*0Sstevel@tonic-gate struct md_mn_kresult_t {
467*0Sstevel@tonic-gate 	md_mn_msgtype_t	kmmr_msgtype;
468*0Sstevel@tonic-gate 	u_int		kmmr_flags;
469*0Sstevel@tonic-gate 	int		kmmr_comm_state;
470*0Sstevel@tonic-gate 	md_mn_nodeid_t	kmmr_failing_node; /* trouble maker */
471*0Sstevel@tonic-gate 	int		kmmr_exitval;
472*0Sstevel@tonic-gate 	int		kmmr_res_size;
473*0Sstevel@tonic-gate 	char		kmmr_res_data[MDMN_MAX_KRES_DATA];
474*0Sstevel@tonic-gate };
475*0Sstevel@tonic-gate 
476*0Sstevel@tonic-gate /* possible return values for the rpc services */
477*0Sstevel@tonic-gate enum md_mn_retval_t {
478*0Sstevel@tonic-gate 	MDMNE_NULL = 0,
479*0Sstevel@tonic-gate 	MDMNE_ACK,		/* this is the good one */
480*0Sstevel@tonic-gate 	MDMNE_CLASS_BUSY,	/* try again */
481*0Sstevel@tonic-gate 	MDMNE_RPC_FAIL,		/* some RPC error occurred */
482*0Sstevel@tonic-gate 	MDMNE_THR_CREATE_FAIL,  /* cannot create working thread */
483*0Sstevel@tonic-gate 	MDMNE_NO_HANDLER,	/* this message has no handler */
484*0Sstevel@tonic-gate 	MDMNE_LOG_FAIL,		/* logging failed for some reason */
485*0Sstevel@tonic-gate 	MDMNE_CANNOT_CONNECT,	/* rpc connection not possible */
486*0Sstevel@tonic-gate 	MDMNE_NO_WAKEUP_ENTRY,	/* no entry in wakeup table for msgid */
487*0Sstevel@tonic-gate 	MDMNE_NOT_JOINED,	/* this host hasn't joined yet */
488*0Sstevel@tonic-gate 	MDMNE_HANDLER_FAILED,	/* could not run the handler for this message */
489*0Sstevel@tonic-gate 	MDMNE_EINVAL,		/* bad argument specified for special message */
490*0Sstevel@tonic-gate 	MDMNE_SUSPENDED,	/* commd doesn't accept new messgaes */
491*0Sstevel@tonic-gate 	MDMNE_CLASS_LOCKED,	/* class has been locked (for testing only) */
492*0Sstevel@tonic-gate 	MDMNE_TIMEOUT,		/* processing message took too long */
493*0Sstevel@tonic-gate 	MDMNE_SET_NOT_DRAINED,	/* still outstandang messages for this set */
494*0Sstevel@tonic-gate 	MDMNE_ABORT,		/* Contacted node is in abort state */
495*0Sstevel@tonic-gate 	MDMNE_IGNORE_NODE	/* ignore current node, send msg to next one */
496*0Sstevel@tonic-gate };
497*0Sstevel@tonic-gate 
498*0Sstevel@tonic-gate %
499*0Sstevel@tonic-gate %#define	MDMN_KSEND_MSG_OK(rv, kres)		\
500*0Sstevel@tonic-gate %	(((rv) == 0) && (((kres)->kmmr_exitval == 0) && \
501*0Sstevel@tonic-gate %	 (((kres)->kmmr_comm_state == MDMNE_ACK) || \
502*0Sstevel@tonic-gate %	  (!md_mn_is_commd_present() && \
503*0Sstevel@tonic-gate %	   ((kres)->kmmr_comm_state == MDMNE_RPC_FAIL)))))
504*0Sstevel@tonic-gate %
505*0Sstevel@tonic-gate 
506*0Sstevel@tonic-gate %
507*0Sstevel@tonic-gate %#define	mmr_out		mmr_output.mmr_output_val
508*0Sstevel@tonic-gate %#define	mmr_out_size	mmr_output.mmr_output_len
509*0Sstevel@tonic-gate %#define	mmr_err		mmr_error.mmr_error_val
510*0Sstevel@tonic-gate %#define	mmr_err_size	mmr_error.mmr_error_len
511*0Sstevel@tonic-gate %
512*0Sstevel@tonic-gate %
513*0Sstevel@tonic-gate %extern void mdmn_master_process_msg(md_mn_msg_t *);
514*0Sstevel@tonic-gate %extern void mdmn_slave_process_msg(md_mn_msg_t *);
515*0Sstevel@tonic-gate 
516*0Sstevel@tonic-gate 
517*0Sstevel@tonic-gate struct md_mn_set_and_class_t {
518*0Sstevel@tonic-gate 	set_t			msc_set;
519*0Sstevel@tonic-gate 	md_mn_msgclass_t	msc_class;
520*0Sstevel@tonic-gate 	u_int			msc_flags;
521*0Sstevel@tonic-gate };
522*0Sstevel@tonic-gate 
523*0Sstevel@tonic-gate %/* possible values for msc_flags above */
524*0Sstevel@tonic-gate %#define	MD_MSCF_NO_FLAGS		0x0000
525*0Sstevel@tonic-gate %#define	MD_MSCF_DONT_RESUME_CLASS1	0x0001
526*0Sstevel@tonic-gate 
527*0Sstevel@tonic-gate struct md_mn_type_and_lock_t {
528*0Sstevel@tonic-gate 	md_mn_msgtype_t	mmtl_type;
529*0Sstevel@tonic-gate 	u_int		mmtl_lock;
530*0Sstevel@tonic-gate };
531*0Sstevel@tonic-gate 
532*0Sstevel@tonic-gate %/* possible values for mmtl_flags above */
533*0Sstevel@tonic-gate %#define	MMTL_UNLOCK		0x0000
534*0Sstevel@tonic-gate %#define	MMTL_LOCK		0x0001
535*0Sstevel@tonic-gate 
536*0Sstevel@tonic-gate %/* Currently not used, but thinkable extensions */
537*0Sstevel@tonic-gate %#define	MMTL_LOCK_ON_INITIATOR	0x0002
538*0Sstevel@tonic-gate %#define	MMTL_LOCK_ON_MASTER	0x0004
539*0Sstevel@tonic-gate %#define	MMTL_LOCK_ON_SLAVE	0x0008
540*0Sstevel@tonic-gate %#define	MMTL_LOCK_ONE_TIME_ONLY	0x0010
541*0Sstevel@tonic-gate 
542*0Sstevel@tonic-gate 
543*0Sstevel@tonic-gate program MDMN_COMMD {
544*0Sstevel@tonic-gate 	version ONE {
545*0Sstevel@tonic-gate 		md_mn_result_t
546*0Sstevel@tonic-gate 		mdmn_send(md_mn_msg_t) = 1;
547*0Sstevel@tonic-gate 
548*0Sstevel@tonic-gate 		int
549*0Sstevel@tonic-gate 		mdmn_work(md_mn_msg_t msg) = 2;
550*0Sstevel@tonic-gate 
551*0Sstevel@tonic-gate 		int
552*0Sstevel@tonic-gate 		mdmn_wakeup_initiator(md_mn_result_t) = 3;
553*0Sstevel@tonic-gate 
554*0Sstevel@tonic-gate 		int
555*0Sstevel@tonic-gate 		mdmn_wakeup_master(md_mn_result_t) = 4;
556*0Sstevel@tonic-gate 
557*0Sstevel@tonic-gate 		int
558*0Sstevel@tonic-gate 		mdmn_comm_lock(md_mn_set_and_class_t) = 5;
559*0Sstevel@tonic-gate 
560*0Sstevel@tonic-gate 		int
561*0Sstevel@tonic-gate 		mdmn_comm_unlock(md_mn_set_and_class_t) = 6;
562*0Sstevel@tonic-gate 
563*0Sstevel@tonic-gate 		int
564*0Sstevel@tonic-gate 		mdmn_comm_suspend(md_mn_set_and_class_t) = 7;
565*0Sstevel@tonic-gate 
566*0Sstevel@tonic-gate 		int
567*0Sstevel@tonic-gate 		mdmn_comm_resume(md_mn_set_and_class_t) = 8;
568*0Sstevel@tonic-gate 
569*0Sstevel@tonic-gate 		int
570*0Sstevel@tonic-gate 		mdmn_comm_reinit_set(set_t) = 9;
571*0Sstevel@tonic-gate 
572*0Sstevel@tonic-gate 		int
573*0Sstevel@tonic-gate 		mdmn_comm_msglock(md_mn_type_and_lock_t) = 10;
574*0Sstevel@tonic-gate 	} = 1;
575*0Sstevel@tonic-gate } = 100422;
576