11623Stw21770 %/* 21623Stw21770 % * CDDL HEADER START 31623Stw21770 % * 41623Stw21770 % * The contents of this file are subject to the terms of the 51623Stw21770 % * Common Development and Distribution License (the "License"). 61623Stw21770 % * You may not use this file except in compliance with the License. 71623Stw21770 % * 81623Stw21770 % * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 91623Stw21770 % * or http://www.opensolaris.org/os/licensing. 101623Stw21770 % * See the License for the specific language governing permissions 111623Stw21770 % * and limitations under the License. 121623Stw21770 % * 131623Stw21770 % * When distributing Covered Code, include this CDDL HEADER in each 141623Stw21770 % * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 151623Stw21770 % * If applicable, add the following below this CDDL HEADER, with the 161623Stw21770 % * fields enclosed by brackets "[]" replaced with your own identifying 171623Stw21770 % * information: Portions Copyright [yyyy] [name of copyright owner] 181623Stw21770 % * 191623Stw21770 % * CDDL HEADER END 201623Stw21770 % */ 210Sstevel@tonic-gate % 220Sstevel@tonic-gate %/* 23*8452SJohn.Wren.Kennedy@Sun.COM % * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate % * Use is subject to license terms. 250Sstevel@tonic-gate % */ 260Sstevel@tonic-gate % 270Sstevel@tonic-gate 280Sstevel@tonic-gate %#include <sys/types.h> 290Sstevel@tonic-gate %#include <sys/types32.h> 300Sstevel@tonic-gate %#include <sys/lvm/md_basic.h> 310Sstevel@tonic-gate %#include <sys/lvm/mdio.h> 320Sstevel@tonic-gate %#ifndef _KERNEL 330Sstevel@tonic-gate %#include <mdiox.h> 340Sstevel@tonic-gate %#include <meta_basic.h> 350Sstevel@tonic-gate %extern bool_t xdr_md_set_params_t(XDR *xdrs, md_set_params_t *objp); 360Sstevel@tonic-gate %extern bool_t xdr_mp_unit_t(XDR *xdrs, mp_unit_t *objp); 370Sstevel@tonic-gate %extern bool_t xdr_diskaddr_t(XDR *xdrs, diskaddr_t *objp); 380Sstevel@tonic-gate %extern bool_t xdr_md_dev64_t(XDR *xdrs, md_dev64_t *objp); 390Sstevel@tonic-gate %extern bool_t xdr_daddr_t(XDR *xdrs, daddr_t *objp); 400Sstevel@tonic-gate %extern bool_t xdr_daddr32_t(XDR *xdrs, daddr32_t *objp); 410Sstevel@tonic-gate %#else 420Sstevel@tonic-gate %#include <sys/lvm/md_mdiox.h> 430Sstevel@tonic-gate %#endif /* ! _KERNEL */ 440Sstevel@tonic-gate 450Sstevel@tonic-gate /* every message handler must have these parameters */ 460Sstevel@tonic-gate %#define HANDLER_PARMS md_mn_msg_t *msg, uint_t flag, md_mn_result_t *res 470Sstevel@tonic-gate 480Sstevel@tonic-gate 490Sstevel@tonic-gate /* every submessage generator must have these parameters */ 500Sstevel@tonic-gate %#define SMGEN_PARMS md_mn_msg_t *msg, md_mn_msg_t **msglist 510Sstevel@tonic-gate 520Sstevel@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*/ 530Sstevel@tonic-gate 540Sstevel@tonic-gate enum md_mn_msgtype_t { 550Sstevel@tonic-gate MD_MN_MSG_NULL = 0, /* special message type for internal use only */ 560Sstevel@tonic-gate MD_MN_MSG_TEST1, 570Sstevel@tonic-gate MD_MN_MSG_TEST2, 580Sstevel@tonic-gate MD_MN_MSG_TEST3, 590Sstevel@tonic-gate MD_MN_MSG_TEST4, 600Sstevel@tonic-gate MD_MN_MSG_TEST5, 610Sstevel@tonic-gate MD_MN_MSG_TEST6, 620Sstevel@tonic-gate MD_MN_MSG_BC_CMD, /* Send metacommand */ 630Sstevel@tonic-gate MD_MN_MSG_BC_CMD_RETRY, /* Send metacommand, retry on busy */ 640Sstevel@tonic-gate MD_MN_MSG_CLU_CHECK, 650Sstevel@tonic-gate MD_MN_MSG_CLU_LOCK, 660Sstevel@tonic-gate MD_MN_MSG_CLU_UNLOCK, 670Sstevel@tonic-gate MD_MN_MSG_REQUIRE_OWNER, /* Request to become Mirror owner */ 680Sstevel@tonic-gate MD_MN_MSG_CHOOSE_OWNER, /* Request to allocate a resync owner */ 690Sstevel@tonic-gate MD_MN_MSG_CHANGE_OWNER, /* Change owner to a specific node */ 700Sstevel@tonic-gate MD_MN_MSG_SUSPEND_WRITES, /* Suspend writes to a mirror */ 710Sstevel@tonic-gate MD_MN_MSG_STATE_UPDATE_RESWR, /* Ch state of comp & resume writes */ 720Sstevel@tonic-gate MD_MN_MSG_STATE_UPDATE, /* Susp writes/Change state of comp */ 730Sstevel@tonic-gate MD_MN_MSG_ALLOCATE_HOTSPARE, /* Allocate hotspare for mirror comp */ 740Sstevel@tonic-gate MD_MN_MSG_RESYNC_STARTING, /* Resync thread starting */ 750Sstevel@tonic-gate MD_MN_MSG_RESYNC_NEXT, /* Next resync region */ 760Sstevel@tonic-gate MD_MN_MSG_RESYNC_FINISH, /* Resync thread finished */ 770Sstevel@tonic-gate MD_MN_MSG_RESYNC_PHASE_DONE, /* End of resync phase */ 780Sstevel@tonic-gate MD_MN_MSG_SET_CAP, /* Set capability, eg ABR */ 790Sstevel@tonic-gate MD_MN_MSG_VERBOSITY, /* set various levels of debug */ 800Sstevel@tonic-gate MD_MN_MSG_MDDB_PARSE, /* Slave to reparse portion of mddb */ 810Sstevel@tonic-gate MD_MN_MSG_MDDB_BLOCK, /* Block parse/recs on master/slave */ 820Sstevel@tonic-gate MD_MN_MSG_META_DB_ATTACH, /* Master message to add new mddb */ 830Sstevel@tonic-gate MD_MN_MSG_SM_MDDB_ATTACH, /* Submessage to add new mddb */ 840Sstevel@tonic-gate MD_MN_MSG_META_DB_DETACH, /* Master message to delete mddb */ 850Sstevel@tonic-gate MD_MN_MSG_SM_MDDB_DETACH, /* Submessage to delete mddb */ 860Sstevel@tonic-gate MD_MN_MSG_META_DB_NEWSIDE, /* Node adding mddb side info */ 870Sstevel@tonic-gate MD_MN_MSG_META_DB_DELSIDE, /* Node deleting mddb side info */ 880Sstevel@tonic-gate MD_MN_MSG_META_MD_ADDSIDE, /* Node adding md side info */ 890Sstevel@tonic-gate MD_MN_MSG_META_MD_DELSIDE, /* Node deleting md side info */ 900Sstevel@tonic-gate MD_MN_MSG_MDDB_OPTRECERR, /* Node detects opt rec error */ 910Sstevel@tonic-gate MD_MN_MSG_ABORT, /* Stop sending messages to any node */ 920Sstevel@tonic-gate MD_MN_MSG_STATE_UPDATE_RESWR2, /* UPDATE_RESWR for watermark updates */ 930Sstevel@tonic-gate MD_MN_MSG_STATE_UPDATE2, /* STATE_UPDATE for watermark updates */ 940Sstevel@tonic-gate MD_MN_MSG_ALLOCATE_HOTSPARE2, /* ALLOCATE_HOTSPARE for wm updates */ 950Sstevel@tonic-gate MD_MN_MSG_IOCSET, /* Send IOCSET ioctl */ 960Sstevel@tonic-gate MD_MN_MSG_SP_SETSTAT, /* Update status of softpart */ 970Sstevel@tonic-gate MD_MN_MSG_ADDKEYNAME, /* Add key */ 980Sstevel@tonic-gate MD_MN_MSG_DELKEYNAME, /* Delete key */ 990Sstevel@tonic-gate MD_MN_MSG_GET_TSTATE, /* Get tstate from master */ 1000Sstevel@tonic-gate MD_MN_MSG_GET_MIRROR_STATE, /* Get submirror state from master */ 1010Sstevel@tonic-gate MD_MN_MSG_SP_SETSTAT2, /* Update softpart status on error */ 1020Sstevel@tonic-gate MD_MN_MSG_SETSYNC, /* Set resync status */ 1030Sstevel@tonic-gate MD_MN_MSG_POKE_HOTSPARES, /* Call poke_hotspares */ 1041623Stw21770 MD_MN_MSG_ADDMDNAME, /* Add metadevice name */ 105*8452SJohn.Wren.Kennedy@Sun.COM MD_MN_MSG_RR_DIRTY, /* Mark RR range as dirty */ 106*8452SJohn.Wren.Kennedy@Sun.COM MD_MN_MSG_RR_CLEAN, /* Mark RR range as clean */ 1070Sstevel@tonic-gate MD_MN_NMESSAGES /* insert elements before */ 1080Sstevel@tonic-gate }; 1090Sstevel@tonic-gate 1100Sstevel@tonic-gate /* 1110Sstevel@tonic-gate * A message of class X may trigger only messages of classes higher than X 1120Sstevel@tonic-gate * Feel free to change the order here. As long as you leave MD_MSG_CL_NULL 1130Sstevel@tonic-gate * and NCLASSES, of course 1140Sstevel@tonic-gate */ 1150Sstevel@tonic-gate 1160Sstevel@tonic-gate enum md_mn_msgclass_t { 1170Sstevel@tonic-gate MD_MSG_CLASS0 = 0, /* special message class for internal use only */ 1180Sstevel@tonic-gate MD_MSG_CLASS1, 1190Sstevel@tonic-gate MD_MSG_CLASS2, 1200Sstevel@tonic-gate MD_MSG_CLASS3, 1210Sstevel@tonic-gate MD_MSG_CLASS4, 1220Sstevel@tonic-gate MD_MSG_CLASS5, 1230Sstevel@tonic-gate MD_MSG_CLASS6, 1240Sstevel@tonic-gate MD_MSG_CLASS7, 1250Sstevel@tonic-gate MD_MN_NCLASSES /* insert elements before */ 1260Sstevel@tonic-gate }; 1270Sstevel@tonic-gate 1280Sstevel@tonic-gate %/* 1290Sstevel@tonic-gate % * The following are needed for things like suspend and resume when the 1300Sstevel@tonic-gate % * operation is to be applied to all classes / all sets. 1310Sstevel@tonic-gate % */ 1320Sstevel@tonic-gate %#define MD_COMM_ALL_CLASSES MD_MSG_CLASS0 1330Sstevel@tonic-gate %#define MD_COMM_ALL_SETS 0 1340Sstevel@tonic-gate 1350Sstevel@tonic-gate /* This is for state changes of submirror components */ 1360Sstevel@tonic-gate struct md_mn_msg_stch_t { 1370Sstevel@tonic-gate minor_t msg_stch_mnum; /* minor number of dev */ 1380Sstevel@tonic-gate int msg_stch_sm; /* submirror involved */ 1390Sstevel@tonic-gate int msg_stch_comp; /* component */ 1400Sstevel@tonic-gate int msg_stch_new_state; /* new state for comp */ 1410Sstevel@tonic-gate mddb_recid_t msg_stch_hs_id; /* hs_id at time of call */ 1420Sstevel@tonic-gate }; 1430Sstevel@tonic-gate 1440Sstevel@tonic-gate 1450Sstevel@tonic-gate /* This is for suspending writes to a mirror */ 1460Sstevel@tonic-gate struct md_mn_msg_suspwr_t { 1470Sstevel@tonic-gate minor_t msg_suspwr_mnum; /* minor number of dev */ 1480Sstevel@tonic-gate }; 1490Sstevel@tonic-gate 1500Sstevel@tonic-gate /* Message format for choosing a resync owner */ 1510Sstevel@tonic-gate struct md_mn_msg_chooseid_t { 1520Sstevel@tonic-gate minor_t msg_chooseid_mnum; /* minor num of dev */ 1530Sstevel@tonic-gate int msg_chooseid_rcnt; /* resync count for set */ 1540Sstevel@tonic-gate int msg_chooseid_set_node; /* 1 => use rcnt as nodeid for owner */ 1550Sstevel@tonic-gate }; 1560Sstevel@tonic-gate 1570Sstevel@tonic-gate /* Message format for changing a resync owner */ 1580Sstevel@tonic-gate struct md_mn_msg_chowner_t { 1590Sstevel@tonic-gate minor_t msg_chowner_mnum; /* minor num of dev */ 1600Sstevel@tonic-gate int msg_chowner_nodeid; /* node id of new owner */ 1610Sstevel@tonic-gate }; 1620Sstevel@tonic-gate 1630Sstevel@tonic-gate /* Message format for setting metadevice capability */ 1640Sstevel@tonic-gate struct md_mn_msg_setcap_t { 1650Sstevel@tonic-gate char msg_setcap_driver[MD_DRIVERNAMELEN]; /* Driver name */ 1660Sstevel@tonic-gate minor_t msg_setcap_mnum; /* minor num of dev */ 1670Sstevel@tonic-gate u_int msg_setcap_set; /* new settings */ 1680Sstevel@tonic-gate }; 1690Sstevel@tonic-gate 1700Sstevel@tonic-gate /* This is for setting the verbosity level (MD_MN_MSG_VERBOSITY) */ 1710Sstevel@tonic-gate struct md_mn_verbose_t { 1720Sstevel@tonic-gate set_t mmv_setno; 1730Sstevel@tonic-gate md_mn_msgclass_t mmv_class; 1740Sstevel@tonic-gate u_int mmv_what; 1750Sstevel@tonic-gate }; 1760Sstevel@tonic-gate 1770Sstevel@tonic-gate /* What do we want to debug ? (mmv_what) */ 1780Sstevel@tonic-gate %/* turn off everything */ 1790Sstevel@tonic-gate %#define MD_MMV_NULL 0x00000000 1800Sstevel@tonic-gate %/* initialization of nodes / rpc clients */ 1810Sstevel@tonic-gate %#define MD_MMV_INIT 0x00000001 1820Sstevel@tonic-gate %/* mdmn_send_svc_1 related / early stage */ 1830Sstevel@tonic-gate %#define MD_MMV_SEND 0x00000002 1840Sstevel@tonic-gate %/* mdmn_work_svc_1 stuff on master */ 1850Sstevel@tonic-gate %#define MD_MMV_WORK 0x00000004 1860Sstevel@tonic-gate %/* mdmn_master_process_msg stuff */ 1870Sstevel@tonic-gate %#define MD_MMV_PROC_M 0x00000008 1880Sstevel@tonic-gate %/* mdmn_slave_process_msg stuff */ 1890Sstevel@tonic-gate %#define MD_MMV_PROC_S 0x00000010 1900Sstevel@tonic-gate %/* wakeup_master */ 1910Sstevel@tonic-gate %#define MD_MMV_WAKE_M 0x00000020 1920Sstevel@tonic-gate %/* wakeup_initiator */ 1930Sstevel@tonic-gate %#define MD_MMV_WAKE_I 0x00000040 1940Sstevel@tonic-gate %/* Misc stuff*/ 1950Sstevel@tonic-gate %#define MD_MMV_MISC 0x00000080 1960Sstevel@tonic-gate %/* turn on everything */ 1970Sstevel@tonic-gate %#define MD_MMV_ALL 0x0000ffff 1980Sstevel@tonic-gate %/* write to syslog instead of output file, for critical messages */ 1990Sstevel@tonic-gate %#define MD_MMV_SYSLOG 0x10000000 2000Sstevel@tonic-gate %/* enable timestamps */ 2010Sstevel@tonic-gate %#define MD_MMV_TIMESTAMP 0x20000000 2020Sstevel@tonic-gate 2030Sstevel@tonic-gate 2040Sstevel@tonic-gate /* Message format for allocating hotspares */ 2050Sstevel@tonic-gate struct md_mn_msg_allochsp_t { 2060Sstevel@tonic-gate minor_t msg_allochsp_mnum; /* minor num of dev */ 2070Sstevel@tonic-gate int msg_allochsp_sm; /* submirror index */ 2080Sstevel@tonic-gate int msg_allochsp_comp; /* component index */ 2090Sstevel@tonic-gate mddb_recid_t msg_allochsp_hs_id; /* hotspare id */ 2100Sstevel@tonic-gate }; 2110Sstevel@tonic-gate 2120Sstevel@tonic-gate /* Message format for resync messages */ 2130Sstevel@tonic-gate struct md_mn_msg_resync_t { 2140Sstevel@tonic-gate minor_t msg_resync_mnum; /* minor num of dev */ 2150Sstevel@tonic-gate int msg_resync_type; /* resync type */ 2160Sstevel@tonic-gate diskaddr_t msg_resync_start; /* start of resync region */ 2170Sstevel@tonic-gate diskaddr_t msg_resync_rsize; /* size of resync region */ 2180Sstevel@tonic-gate diskaddr_t msg_resync_done; /* count of resync done */ 2190Sstevel@tonic-gate diskaddr_t msg_resync_2_do; /* total size of resync */ 2200Sstevel@tonic-gate int msg_originator; /* message originator */ 2210Sstevel@tonic-gate int msg_resync_flags; /* resync flags */ 2220Sstevel@tonic-gate sm_state_t msg_sm_state[NMIRROR]; /* submirror state */ 2230Sstevel@tonic-gate sm_flags_t msg_sm_flags[NMIRROR]; /* submirror flags */ 2240Sstevel@tonic-gate }; 2250Sstevel@tonic-gate 2260Sstevel@tonic-gate %#define MD_MSGF_DEFAULT_FLAGS 0x00000000 2270Sstevel@tonic-gate 2280Sstevel@tonic-gate /* Message format for blocking/unblocking MDDB parsing and record changes */ 2290Sstevel@tonic-gate struct md_mn_msg_mddb_block_t { 2300Sstevel@tonic-gate int msg_block_flags; 2310Sstevel@tonic-gate }; 2320Sstevel@tonic-gate 2330Sstevel@tonic-gate /* Message format for MDDB re-parsing */ 2340Sstevel@tonic-gate struct md_mn_msg_mddb_parse_t { 2350Sstevel@tonic-gate int msg_parse_flags; /* flags describe part to reparse */ 2360Sstevel@tonic-gate int msg_lb_flags[50]; 2370Sstevel@tonic-gate }; 2380Sstevel@tonic-gate 2390Sstevel@tonic-gate /* Message format for MDDB attach */ 2400Sstevel@tonic-gate struct md_mn_msg_meta_db_attach_t { 2410Sstevel@tonic-gate md_dev64_t msg_l_dev; 2420Sstevel@tonic-gate int msg_cnt; 2430Sstevel@tonic-gate int msg_dbsize; 2440Sstevel@tonic-gate char msg_dname[16]; 2450Sstevel@tonic-gate md_splitname msg_splitname; 2460Sstevel@tonic-gate u_int msg_options; 2470Sstevel@tonic-gate char msg_devid[1]; /* unused for now, for future */ 2480Sstevel@tonic-gate /* must be last element */ 2490Sstevel@tonic-gate }; 2500Sstevel@tonic-gate 2510Sstevel@tonic-gate /* Message format for MDDB detach */ 2520Sstevel@tonic-gate struct md_mn_msg_meta_db_detach_t { 2530Sstevel@tonic-gate md_splitname msg_splitname; 2540Sstevel@tonic-gate char msg_devid[1]; /* unused for now, for future */ 2550Sstevel@tonic-gate /* must be last element */ 2560Sstevel@tonic-gate }; 2570Sstevel@tonic-gate 2580Sstevel@tonic-gate /* Message format for MDDB newside */ 2590Sstevel@tonic-gate struct md_mn_msg_meta_db_newside_t { 2600Sstevel@tonic-gate md_dev64_t msg_l_dev; 2610Sstevel@tonic-gate daddr_t msg_blkno; 2620Sstevel@tonic-gate side_t msg_sideno; 2630Sstevel@tonic-gate minor_t msg_mnum; 2640Sstevel@tonic-gate char msg_dname[16]; 2650Sstevel@tonic-gate md_splitname msg_splitname; 2660Sstevel@tonic-gate char msg_devid[1]; /* unused for now, for future */ 2670Sstevel@tonic-gate /* must be last element */ 2680Sstevel@tonic-gate }; 2690Sstevel@tonic-gate 2700Sstevel@tonic-gate /* Message format for MDDB delside */ 2710Sstevel@tonic-gate struct md_mn_msg_meta_db_delside_t { 2720Sstevel@tonic-gate md_dev64_t msg_l_dev; 2730Sstevel@tonic-gate daddr_t msg_blkno; 2740Sstevel@tonic-gate side_t msg_sideno; 2750Sstevel@tonic-gate char msg_devid[1]; /* unused for now, for future */ 2760Sstevel@tonic-gate /* must be last element */ 2770Sstevel@tonic-gate }; 2780Sstevel@tonic-gate 2790Sstevel@tonic-gate /* Message format for MD addside */ 2800Sstevel@tonic-gate struct md_mn_msg_meta_md_addside_t { 2810Sstevel@tonic-gate side_t msg_sideno; 2820Sstevel@tonic-gate side_t msg_otherside; 2830Sstevel@tonic-gate }; 2840Sstevel@tonic-gate 2850Sstevel@tonic-gate /* Message format for MDDB delside */ 2860Sstevel@tonic-gate struct md_mn_msg_meta_md_delside_t { 2870Sstevel@tonic-gate side_t msg_sideno; 2880Sstevel@tonic-gate }; 2890Sstevel@tonic-gate 2900Sstevel@tonic-gate /* Message format for optimized record error */ 2910Sstevel@tonic-gate struct md_mn_msg_mddb_optrecerr_t { 2920Sstevel@tonic-gate md_replica_recerr_t msg_recerr[2]; 2930Sstevel@tonic-gate }; 2940Sstevel@tonic-gate 2950Sstevel@tonic-gate /* 2960Sstevel@tonic-gate * Message format for IOCSET message 2970Sstevel@tonic-gate */ 2980Sstevel@tonic-gate 2990Sstevel@tonic-gate struct md_mn_msg_iocset_t { 3000Sstevel@tonic-gate md_set_params_t iocset_params; 3010Sstevel@tonic-gate mp_unit_t unit; 3020Sstevel@tonic-gate }; 3030Sstevel@tonic-gate 3040Sstevel@tonic-gate /* Message format for SP_SETSTAT message */ 3050Sstevel@tonic-gate 3060Sstevel@tonic-gate struct md_mn_msg_sp_setstat_t { 3070Sstevel@tonic-gate minor_t sp_setstat_mnum; 3080Sstevel@tonic-gate int sp_setstat_status; 3090Sstevel@tonic-gate }; 3100Sstevel@tonic-gate 3110Sstevel@tonic-gate /* Message format for ADDKEYNAME message */ 3120Sstevel@tonic-gate 3130Sstevel@tonic-gate struct md_mn_msg_addkeyname_t { 3140Sstevel@tonic-gate set_t addkeyname_setno; 3150Sstevel@tonic-gate char addkeyname_name[1]; /* must be last element */ 3160Sstevel@tonic-gate }; 3170Sstevel@tonic-gate 3181623Stw21770 /* 3191623Stw21770 * Add metadevice name into replica 3201623Stw21770 */ 3211623Stw21770 struct md_mn_msg_addmdname_t { 3221623Stw21770 set_t addmdname_setno; 3231623Stw21770 char addmdname_name[1]; 3241623Stw21770 }; 3251623Stw21770 3260Sstevel@tonic-gate /* Message format for DELKEYNAME message */ 3270Sstevel@tonic-gate 3280Sstevel@tonic-gate struct md_mn_msg_delkeyname_t { 3290Sstevel@tonic-gate md_dev64_t delkeyname_dev; 3300Sstevel@tonic-gate set_t delkeyname_setno; 3310Sstevel@tonic-gate mdkey_t delkeyname_key; 3320Sstevel@tonic-gate }; 3330Sstevel@tonic-gate 3340Sstevel@tonic-gate /* Message format for GET_TSTATE message */ 3350Sstevel@tonic-gate 3360Sstevel@tonic-gate struct md_mn_msg_gettstate_t { 3370Sstevel@tonic-gate md_dev64_t gettstate_dev; 3380Sstevel@tonic-gate }; 3390Sstevel@tonic-gate 3400Sstevel@tonic-gate /* Message format for GET_MIRROR_STATE message */ 3410Sstevel@tonic-gate 3420Sstevel@tonic-gate struct md_mn_msg_mir_state_t { 3430Sstevel@tonic-gate minor_t mir_state_mnum; 3440Sstevel@tonic-gate }; 3450Sstevel@tonic-gate 3460Sstevel@tonic-gate /* Results format for GET_SM_STATE message */ 3470Sstevel@tonic-gate struct md_mn_msg_mir_state_res_t { 3480Sstevel@tonic-gate sm_state_t sm_state[NMIRROR]; 3490Sstevel@tonic-gate sm_flags_t sm_flags[NMIRROR]; 3500Sstevel@tonic-gate u_int mir_tstate; 3510Sstevel@tonic-gate }; 3520Sstevel@tonic-gate 3530Sstevel@tonic-gate /* Message format for MD_MN_MSG_SETSYNC message */ 3540Sstevel@tonic-gate struct md_mn_msg_setsync_t { 3550Sstevel@tonic-gate minor_t setsync_mnum; 3560Sstevel@tonic-gate md_riflags_t setsync_flags; 3570Sstevel@tonic-gate diskaddr_t setsync_copysize; 3580Sstevel@tonic-gate }; 3590Sstevel@tonic-gate 3600Sstevel@tonic-gate /* Message format for MD_MN_MSG_POKE_HOTSPARES message */ 3610Sstevel@tonic-gate struct md_mn_msg_pokehsp_t { 3620Sstevel@tonic-gate minor_t pokehsp_setno; 3630Sstevel@tonic-gate }; 3640Sstevel@tonic-gate 365*8452SJohn.Wren.Kennedy@Sun.COM /* Message format for MD_MN_MSG_RR_DIRTY message */ 366*8452SJohn.Wren.Kennedy@Sun.COM struct md_mn_msg_rr_dirty_t { 367*8452SJohn.Wren.Kennedy@Sun.COM minor_t rr_mnum; 368*8452SJohn.Wren.Kennedy@Sun.COM int rr_nodeid; 369*8452SJohn.Wren.Kennedy@Sun.COM u_int rr_range; /* Start(16bits) | End(16bits) */ 370*8452SJohn.Wren.Kennedy@Sun.COM }; 371*8452SJohn.Wren.Kennedy@Sun.COM 372*8452SJohn.Wren.Kennedy@Sun.COM /* Message format for MD_MN_MSG_RR_CLEAN message */ 373*8452SJohn.Wren.Kennedy@Sun.COM %#define MDMN_MSG_RR_CLEAN_DATA_MAX_BYTES \ 374*8452SJohn.Wren.Kennedy@Sun.COM % ((MDMN_MAX_KMSG_DATA) - \ 375*8452SJohn.Wren.Kennedy@Sun.COM % sizeof (struct md_mn_msg_rr_clean_t)) 376*8452SJohn.Wren.Kennedy@Sun.COM %#define MDMN_MSG_RR_CLEAN_SIZE_DATA(x) \ 377*8452SJohn.Wren.Kennedy@Sun.COM % (sizeof (struct md_mn_msg_rr_clean_t) + (x)) 378*8452SJohn.Wren.Kennedy@Sun.COM %#define MDMN_MSG_RR_CLEAN_MSG_SIZE(x) \ 379*8452SJohn.Wren.Kennedy@Sun.COM % (sizeof (struct md_mn_msg_rr_clean_t) \ 380*8452SJohn.Wren.Kennedy@Sun.COM % + MDMN_MSG_RR_CLEAN_DATA_BYTES(x)) 381*8452SJohn.Wren.Kennedy@Sun.COM %#define MDMN_MSG_RR_CLEAN_DATA(x) \ 382*8452SJohn.Wren.Kennedy@Sun.COM % ((unsigned char *)(x) + \ 383*8452SJohn.Wren.Kennedy@Sun.COM % sizeof (struct md_mn_msg_rr_clean_t)) 384*8452SJohn.Wren.Kennedy@Sun.COM 385*8452SJohn.Wren.Kennedy@Sun.COM /* since we cannot use ushorts, some macros to extract the parts from an int */ 386*8452SJohn.Wren.Kennedy@Sun.COM %#define MDMN_MSG_RR_CLEAN_START_BIT(x) ((x)->rr_start_size >> 16) 387*8452SJohn.Wren.Kennedy@Sun.COM %#define MDMN_MSG_RR_CLEAN_DATA_BYTES(x) ((x)->rr_start_size & 0xffff) 388*8452SJohn.Wren.Kennedy@Sun.COM %#define MDMN_MSG_RR_CLEAN_START_SIZE_SET(x, start, size) \ 389*8452SJohn.Wren.Kennedy@Sun.COM % ((x)->rr_start_size = (start << 16) | size) 390*8452SJohn.Wren.Kennedy@Sun.COM 391*8452SJohn.Wren.Kennedy@Sun.COM struct md_mn_msg_rr_clean_t { 392*8452SJohn.Wren.Kennedy@Sun.COM md_mn_nodeid_t rr_nodeid; 393*8452SJohn.Wren.Kennedy@Sun.COM unsigned int rr_mnum; 394*8452SJohn.Wren.Kennedy@Sun.COM unsigned int rr_start_size; /* start_bit (16b) | data_bytes (16b) */ 395*8452SJohn.Wren.Kennedy@Sun.COM /* actual data goes here */ 396*8452SJohn.Wren.Kennedy@Sun.COM }; 397*8452SJohn.Wren.Kennedy@Sun.COM 3980Sstevel@tonic-gate %#define MD_MSGF_NO_LOG 0x00000001 3990Sstevel@tonic-gate %#define MD_MSGF_NO_BCAST 0x00000002 4000Sstevel@tonic-gate %#define MD_MSGF_STOP_ON_ERROR 0x00000004 4010Sstevel@tonic-gate %#define MD_MSGF_REPLAY_MSG 0x00000008 4020Sstevel@tonic-gate %#define MD_MSGF_OVERRIDE_SUSPEND 0x00000010 4030Sstevel@tonic-gate %#define MD_MSGF_ON_MASTER 0x00000020 4040Sstevel@tonic-gate %#define MD_MSGF_ON_SLAVE 0x00000040 4050Sstevel@tonic-gate %#define MD_MSGF_ON_INITIATOR 0x00000080 4060Sstevel@tonic-gate %#define MD_MSGF_LOCAL_ONLY 0x00000100 4070Sstevel@tonic-gate %#define MD_MSGF_FAIL_ON_SUSPEND 0x00000200 4080Sstevel@tonic-gate %#define MD_MSGF_NO_MCT 0x00000400 4090Sstevel@tonic-gate %#define MD_MSGF_PANIC_WHEN_INCONSISTENT 0x00000800 410*8452SJohn.Wren.Kennedy@Sun.COM %#define MD_MSGF_BLK_SIGNAL 0x00001000 411*8452SJohn.Wren.Kennedy@Sun.COM %#define MD_MSGF_KSEND_NORETRY 0x00002000 412*8452SJohn.Wren.Kennedy@Sun.COM %#define MD_MSGF_DIRECTED 0x00004000 4130Sstevel@tonic-gate %#define MD_MSGF_VERBOSE 0x10000000 4140Sstevel@tonic-gate %#define MD_MSGF_VERBOSE_2 0x20000000 4150Sstevel@tonic-gate 4160Sstevel@tonic-gate %#define MD_MSGF_INHERIT_BITS \ 4170Sstevel@tonic-gate % MD_MSGF_REPLAY_MSG | MD_MSGF_OVERRIDE_SUSPEND 4180Sstevel@tonic-gate 4190Sstevel@tonic-gate 4200Sstevel@tonic-gate 4210Sstevel@tonic-gate %/* maximum number of nodes in cluster (not in diskset) */ 4220Sstevel@tonic-gate %#define NNODES MD_MNMAXSIDES 4230Sstevel@tonic-gate 4240Sstevel@tonic-gate 4250Sstevel@tonic-gate /* if you add elements here, make sure, to add them to MSGID_COPY(), too */ 4260Sstevel@tonic-gate struct md_mn_msgid_t { 4270Sstevel@tonic-gate uint64_t mid_time; /* unique timestamp */ 4280Sstevel@tonic-gate md_mn_nodeid_t mid_nid; /* node that created the message */ 4290Sstevel@tonic-gate md_mn_msgclass_t mid_oclass; /* for submessages original class */ 4300Sstevel@tonic-gate uint8_t mid_smid; /* sub message number */ 4310Sstevel@tonic-gate uint8_t mid_spare[15]; /* Always good to have some spares */ 4320Sstevel@tonic-gate }; 4330Sstevel@tonic-gate 4340Sstevel@tonic-gate %#define MD_NULL_MSGID (md_mn_msgid_t *)NULL 4350Sstevel@tonic-gate % 4360Sstevel@tonic-gate %/* macros to handle msgid's */ 4370Sstevel@tonic-gate %#define MSGID_COPY(from, to) { \ 4380Sstevel@tonic-gate % (to)->mid_nid = (from)->mid_nid; \ 4390Sstevel@tonic-gate % (to)->mid_smid = (from)->mid_smid; \ 4400Sstevel@tonic-gate % (to)->mid_oclass = (from)->mid_oclass; \ 4410Sstevel@tonic-gate % (to)->mid_time = (from)->mid_time; \ 4420Sstevel@tonic-gate % } 4430Sstevel@tonic-gate % 4440Sstevel@tonic-gate %#define MSGID_CMP(a, b) \ 4450Sstevel@tonic-gate % (((a)->mid_nid == (b)->mid_nid) && \ 4460Sstevel@tonic-gate % ((a)->mid_smid == (b)->mid_smid) && \ 4470Sstevel@tonic-gate % ((a)->mid_time == (b)->mid_time)) 4480Sstevel@tonic-gate % 4490Sstevel@tonic-gate %#define MSGID_ELEMS(mid) (mid).mid_nid, (mid).mid_time, (mid).mid_smid 4500Sstevel@tonic-gate 4510Sstevel@tonic-gate /* if you add elements here, make sure, to add them to copy_msg(), too */ 4520Sstevel@tonic-gate struct md_mn_msg_t { 4530Sstevel@tonic-gate md_mn_msgid_t msg_msgid; /* Message id */ 4540Sstevel@tonic-gate md_mn_nodeid_t msg_sender; /* who wants the results? */ 4550Sstevel@tonic-gate u_int msg_flags; /* See MD_MSGF_* above */ 4560Sstevel@tonic-gate set_t msg_setno; /* which set is involved */ 4570Sstevel@tonic-gate md_mn_msgtype_t msg_type; /* what type of message */ 458*8452SJohn.Wren.Kennedy@Sun.COM md_mn_nodeid_t msg_recipient; /* who to send DIRECTED message to */ 459*8452SJohn.Wren.Kennedy@Sun.COM char msg_spare[28]; /* Always good to hav'em */ 4600Sstevel@tonic-gate opaque msg_event<>; /* the actual event wrapped up */ 4610Sstevel@tonic-gate }; 4620Sstevel@tonic-gate %#define msg_event_data msg_event.msg_event_val 4630Sstevel@tonic-gate %#define msg_event_size msg_event.msg_event_len 4640Sstevel@tonic-gate % 4650Sstevel@tonic-gate %#define MD_MN_MSG_LEN(msg) ((msg)->msg_event_size +\ 4660Sstevel@tonic-gate % sizeof (md_mn_msg_t)) 4670Sstevel@tonic-gate %#define MD_MN_MSG_MAXDATALEN 1024 4680Sstevel@tonic-gate 4690Sstevel@tonic-gate /* ondisk version of the message */ 4700Sstevel@tonic-gate struct md_mn_msg_od_t { 4710Sstevel@tonic-gate md_mn_msgid_t msg_msgid; /* Message id */ 4720Sstevel@tonic-gate md_mn_nodeid_t msg_sender; /* who wants the results? */ 4730Sstevel@tonic-gate uint32_t msg_flags; /* See MD_MSGF_* above */ 4740Sstevel@tonic-gate set_t msg_setno; /* which set is involved */ 4750Sstevel@tonic-gate md_mn_msgtype_t msg_type; /* what type of message */ 476*8452SJohn.Wren.Kennedy@Sun.COM md_mn_nodeid_t msg_recipient; /* who to send DIRECTED message to */ 477*8452SJohn.Wren.Kennedy@Sun.COM char msg_spare[28]; /* Always good to hav'em */ 4780Sstevel@tonic-gate uint32_t msg_ev_len; 4790Sstevel@tonic-gate char msg_ev_val[MD_MN_MSG_MAXDATALEN]; 4800Sstevel@tonic-gate }; 4810Sstevel@tonic-gate % 4820Sstevel@tonic-gate %#define msg_od_event_data msg_ev_val 4830Sstevel@tonic-gate %#define msg_od_event_size msg_ev_len 4840Sstevel@tonic-gate %#define MDMN_MAX_KMSG_DATA 256 4850Sstevel@tonic-gate 4860Sstevel@tonic-gate /* needed for mdmn_ksend_message to deliver the data into userland thru doors */ 4870Sstevel@tonic-gate struct md_mn_kmsg_t { 4880Sstevel@tonic-gate md_mn_msgid_t kmsg_msgid; 4890Sstevel@tonic-gate u_int kmsg_flags; 4900Sstevel@tonic-gate set_t kmsg_setno; 4910Sstevel@tonic-gate md_mn_msgtype_t kmsg_type; 492*8452SJohn.Wren.Kennedy@Sun.COM md_mn_nodeid_t kmsg_recipient; /* who to send DIRECTED message to */ 4930Sstevel@tonic-gate int kmsg_size; 4940Sstevel@tonic-gate char kmsg_data[MDMN_MAX_KMSG_DATA]; 4950Sstevel@tonic-gate }; 4960Sstevel@tonic-gate 4970Sstevel@tonic-gate /* if you add elements here, make sure, to add them to copy_result(), too */ 4980Sstevel@tonic-gate struct md_mn_result_t { 4990Sstevel@tonic-gate md_mn_msgid_t mmr_msgid; 5000Sstevel@tonic-gate md_mn_msgtype_t mmr_msgtype; 5010Sstevel@tonic-gate set_t mmr_setno; 5020Sstevel@tonic-gate u_int mmr_flags; 5030Sstevel@tonic-gate md_mn_nodeid_t mmr_sender; /* needed to check for unsolicited msgs */ 5040Sstevel@tonic-gate md_mn_nodeid_t mmr_failing_node; /* trouble maker */ 5050Sstevel@tonic-gate int mmr_comm_state; 5060Sstevel@tonic-gate int mmr_exitval; 5070Sstevel@tonic-gate md_error_t mmr_ep; 5080Sstevel@tonic-gate opaque mmr_output<>; /* msg handler can store output here */ 5090Sstevel@tonic-gate opaque mmr_error<>; /* ... and error output goes here */ 5100Sstevel@tonic-gate }; 5110Sstevel@tonic-gate 5120Sstevel@tonic-gate %#define MDMN_MAX_KRES_DATA 256 5130Sstevel@tonic-gate /* kernel results don't provide something like stderr */ 5140Sstevel@tonic-gate struct md_mn_kresult_t { 5150Sstevel@tonic-gate md_mn_msgtype_t kmmr_msgtype; 5160Sstevel@tonic-gate u_int kmmr_flags; 5170Sstevel@tonic-gate int kmmr_comm_state; 5180Sstevel@tonic-gate md_mn_nodeid_t kmmr_failing_node; /* trouble maker */ 5190Sstevel@tonic-gate int kmmr_exitval; 5200Sstevel@tonic-gate int kmmr_res_size; 5210Sstevel@tonic-gate char kmmr_res_data[MDMN_MAX_KRES_DATA]; 5220Sstevel@tonic-gate }; 5230Sstevel@tonic-gate 5240Sstevel@tonic-gate /* possible return values for the rpc services */ 5250Sstevel@tonic-gate enum md_mn_retval_t { 5260Sstevel@tonic-gate MDMNE_NULL = 0, 5270Sstevel@tonic-gate MDMNE_ACK, /* this is the good one */ 5280Sstevel@tonic-gate MDMNE_CLASS_BUSY, /* try again */ 5290Sstevel@tonic-gate MDMNE_RPC_FAIL, /* some RPC error occurred */ 5300Sstevel@tonic-gate MDMNE_THR_CREATE_FAIL, /* cannot create working thread */ 5310Sstevel@tonic-gate MDMNE_NO_HANDLER, /* this message has no handler */ 5320Sstevel@tonic-gate MDMNE_LOG_FAIL, /* logging failed for some reason */ 5330Sstevel@tonic-gate MDMNE_CANNOT_CONNECT, /* rpc connection not possible */ 5340Sstevel@tonic-gate MDMNE_NO_WAKEUP_ENTRY, /* no entry in wakeup table for msgid */ 5350Sstevel@tonic-gate MDMNE_NOT_JOINED, /* this host hasn't joined yet */ 5360Sstevel@tonic-gate MDMNE_HANDLER_FAILED, /* could not run the handler for this message */ 5370Sstevel@tonic-gate MDMNE_EINVAL, /* bad argument specified for special message */ 5380Sstevel@tonic-gate MDMNE_SUSPENDED, /* commd doesn't accept new messgaes */ 5390Sstevel@tonic-gate MDMNE_CLASS_LOCKED, /* class has been locked (for testing only) */ 5400Sstevel@tonic-gate MDMNE_TIMEOUT, /* processing message took too long */ 5410Sstevel@tonic-gate MDMNE_SET_NOT_DRAINED, /* still outstandang messages for this set */ 5420Sstevel@tonic-gate MDMNE_ABORT, /* Contacted node is in abort state */ 5430Sstevel@tonic-gate MDMNE_IGNORE_NODE /* ignore current node, send msg to next one */ 5440Sstevel@tonic-gate }; 5450Sstevel@tonic-gate 5460Sstevel@tonic-gate % 5470Sstevel@tonic-gate %#define MDMN_KSEND_MSG_OK(rv, kres) \ 5480Sstevel@tonic-gate % (((rv) == 0) && (((kres)->kmmr_exitval == 0) && \ 5490Sstevel@tonic-gate % (((kres)->kmmr_comm_state == MDMNE_ACK) || \ 5500Sstevel@tonic-gate % (!md_mn_is_commd_present() && \ 5510Sstevel@tonic-gate % ((kres)->kmmr_comm_state == MDMNE_RPC_FAIL))))) 5520Sstevel@tonic-gate % 5530Sstevel@tonic-gate 5540Sstevel@tonic-gate % 5550Sstevel@tonic-gate %#define mmr_out mmr_output.mmr_output_val 5560Sstevel@tonic-gate %#define mmr_out_size mmr_output.mmr_output_len 5570Sstevel@tonic-gate %#define mmr_err mmr_error.mmr_error_val 5580Sstevel@tonic-gate %#define mmr_err_size mmr_error.mmr_error_len 5590Sstevel@tonic-gate % 5600Sstevel@tonic-gate % 5610Sstevel@tonic-gate %extern void mdmn_master_process_msg(md_mn_msg_t *); 5620Sstevel@tonic-gate %extern void mdmn_slave_process_msg(md_mn_msg_t *); 5630Sstevel@tonic-gate 5640Sstevel@tonic-gate 5650Sstevel@tonic-gate struct md_mn_set_and_class_t { 5660Sstevel@tonic-gate set_t msc_set; 5670Sstevel@tonic-gate md_mn_msgclass_t msc_class; 5680Sstevel@tonic-gate u_int msc_flags; 5690Sstevel@tonic-gate }; 5700Sstevel@tonic-gate 5710Sstevel@tonic-gate %/* possible values for msc_flags above */ 5720Sstevel@tonic-gate %#define MD_MSCF_NO_FLAGS 0x0000 5730Sstevel@tonic-gate %#define MD_MSCF_DONT_RESUME_CLASS1 0x0001 5740Sstevel@tonic-gate 5750Sstevel@tonic-gate struct md_mn_type_and_lock_t { 5760Sstevel@tonic-gate md_mn_msgtype_t mmtl_type; 5770Sstevel@tonic-gate u_int mmtl_lock; 5780Sstevel@tonic-gate }; 5790Sstevel@tonic-gate 5800Sstevel@tonic-gate %/* possible values for mmtl_flags above */ 5810Sstevel@tonic-gate %#define MMTL_UNLOCK 0x0000 5820Sstevel@tonic-gate %#define MMTL_LOCK 0x0001 5830Sstevel@tonic-gate 5840Sstevel@tonic-gate %/* Currently not used, but thinkable extensions */ 5850Sstevel@tonic-gate %#define MMTL_LOCK_ON_INITIATOR 0x0002 5860Sstevel@tonic-gate %#define MMTL_LOCK_ON_MASTER 0x0004 5870Sstevel@tonic-gate %#define MMTL_LOCK_ON_SLAVE 0x0008 5880Sstevel@tonic-gate %#define MMTL_LOCK_ONE_TIME_ONLY 0x0010 5890Sstevel@tonic-gate 5900Sstevel@tonic-gate 5910Sstevel@tonic-gate program MDMN_COMMD { 592*8452SJohn.Wren.Kennedy@Sun.COM version TWO { 5930Sstevel@tonic-gate md_mn_result_t 5940Sstevel@tonic-gate mdmn_send(md_mn_msg_t) = 1; 5950Sstevel@tonic-gate 5960Sstevel@tonic-gate int 5970Sstevel@tonic-gate mdmn_work(md_mn_msg_t msg) = 2; 5980Sstevel@tonic-gate 5990Sstevel@tonic-gate int 6000Sstevel@tonic-gate mdmn_wakeup_initiator(md_mn_result_t) = 3; 6010Sstevel@tonic-gate 6020Sstevel@tonic-gate int 6030Sstevel@tonic-gate mdmn_wakeup_master(md_mn_result_t) = 4; 6040Sstevel@tonic-gate 6050Sstevel@tonic-gate int 6060Sstevel@tonic-gate mdmn_comm_lock(md_mn_set_and_class_t) = 5; 6070Sstevel@tonic-gate 6080Sstevel@tonic-gate int 6090Sstevel@tonic-gate mdmn_comm_unlock(md_mn_set_and_class_t) = 6; 6100Sstevel@tonic-gate 6110Sstevel@tonic-gate int 6120Sstevel@tonic-gate mdmn_comm_suspend(md_mn_set_and_class_t) = 7; 6130Sstevel@tonic-gate 6140Sstevel@tonic-gate int 6150Sstevel@tonic-gate mdmn_comm_resume(md_mn_set_and_class_t) = 8; 6160Sstevel@tonic-gate 6170Sstevel@tonic-gate int 6180Sstevel@tonic-gate mdmn_comm_reinit_set(set_t) = 9; 6190Sstevel@tonic-gate 6200Sstevel@tonic-gate int 6210Sstevel@tonic-gate mdmn_comm_msglock(md_mn_type_and_lock_t) = 10; 622*8452SJohn.Wren.Kennedy@Sun.COM } = 2; 6230Sstevel@tonic-gate } = 100422; 624