xref: /onnv-gate/usr/src/head/sdssc.h (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  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24*0Sstevel@tonic-gate  * Use is subject to license terms.
25*0Sstevel@tonic-gate  */
26*0Sstevel@tonic-gate 
27*0Sstevel@tonic-gate #ifndef _SDSSC_H
28*0Sstevel@tonic-gate #define	_SDSSC_H
29*0Sstevel@tonic-gate 
30*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*0Sstevel@tonic-gate 
32*0Sstevel@tonic-gate /*
33*0Sstevel@tonic-gate  * This header supports DiskSuite cluster operations and describes the
34*0Sstevel@tonic-gate  * functions that isolate it from cluster implementation.
35*0Sstevel@tonic-gate  */
36*0Sstevel@tonic-gate 
37*0Sstevel@tonic-gate #include <meta.h>
38*0Sstevel@tonic-gate #include <metacl.h>
39*0Sstevel@tonic-gate #include <sys/types.h>
40*0Sstevel@tonic-gate #ifdef CLUSTER_LIBRARY_SOURCE
41*0Sstevel@tonic-gate #include <sys/mhd.h>
42*0Sstevel@tonic-gate #include <scadmin/scconf.h>
43*0Sstevel@tonic-gate #include <scadmin/scswitch.h>
44*0Sstevel@tonic-gate #include <scadmin/scstat.h>
45*0Sstevel@tonic-gate #endif
46*0Sstevel@tonic-gate 
47*0Sstevel@tonic-gate #ifdef __cplusplus
48*0Sstevel@tonic-gate extern "C" {
49*0Sstevel@tonic-gate #endif
50*0Sstevel@tonic-gate 
51*0Sstevel@tonic-gate #define	SDSSC_PROXY_PRIMARY	((char *)1)
52*0Sstevel@tonic-gate #define	SDSSC_CLASS		"sds"	/* Service class name */
53*0Sstevel@tonic-gate #define	SDSSC_MO_CLASS		"multi-owner-svm"
54*0Sstevel@tonic-gate #define	SDSSC_SERVICE_CMD	"sds_ownership"
55*0Sstevel@tonic-gate #define	SDSSC_DEFAULT_PREFERENCE	0
56*0Sstevel@tonic-gate 
57*0Sstevel@tonic-gate 
58*0Sstevel@tonic-gate /*
59*0Sstevel@tonic-gate  * IMPORTANT: Any change to the metaset "-C" option interface shall
60*0Sstevel@tonic-gate  * be reflected in this number. Changes which do not affect shell
61*0Sstevel@tonic-gate  * parsing such as elimination of spaces or substitution of spaces
62*0Sstevel@tonic-gate  * for \n or addition of new non-interfering features may be indicated
63*0Sstevel@tonic-gate  * by incrementing the minor number in the version. Changes in content
64*0Sstevel@tonic-gate  * require the major portion of the version be incremented. All changes
65*0Sstevel@tonic-gate  * shall be discussed with and approved by our current contract partner(s).
66*0Sstevel@tonic-gate  */
67*0Sstevel@tonic-gate #define	METASETIFVERSION	"1.0"
68*0Sstevel@tonic-gate 
69*0Sstevel@tonic-gate /*
70*0Sstevel@tonic-gate  * XXX - This should be in some general purpose header but I can't
71*0Sstevel@tonic-gate  * find it anywhere. - JST
72*0Sstevel@tonic-gate  */
73*0Sstevel@tonic-gate #define	SDSSC_MD_DIR		"/dev/md"
74*0Sstevel@tonic-gate #define	SDSSC_SET_PATH		SDSSC_MD_DIR "/shared"
75*0Sstevel@tonic-gate #define	SDSSC_SETNO_LINK	"shared"
76*0Sstevel@tonic-gate 
77*0Sstevel@tonic-gate /* This is a cluster-specific directory. */
78*0Sstevel@tonic-gate #define	SDSSC_CL_GLOBAL	"/global/.devices/node@"
79*0Sstevel@tonic-gate 
80*0Sstevel@tonic-gate /*
81*0Sstevel@tonic-gate  * Cluster specific directory which contains libdid.so
82*0Sstevel@tonic-gate  */
83*0Sstevel@tonic-gate #define	SDSSC_CL_LIBDIR	"/usr/cluster/lib"
84*0Sstevel@tonic-gate #define	SDSSC_DID_LIB	SDSSC_CL_LIBDIR "/libdid.so"
85*0Sstevel@tonic-gate 
86*0Sstevel@tonic-gate /*
87*0Sstevel@tonic-gate  * This information can't change unless a corresponding change to SC3.0
88*0Sstevel@tonic-gate  * upgrade process is made. When a HA1.3 or SC2.2 system is upgraded
89*0Sstevel@tonic-gate  * to SC3.0, the upgrade process will create our services with the following
90*0Sstevel@tonic-gate  * properties:
91*0Sstevel@tonic-gate  * SDSSC_PROP_INDEX: the current set number on the old HA pair
92*0Sstevel@tonic-gate  * SDSSC_PROP_STATE: SDSSC_STATE_COMMIT
93*0Sstevel@tonic-gate  */
94*0Sstevel@tonic-gate #define	SDSSC_PROP_COUNT	4		/* Number of store props */
95*0Sstevel@tonic-gate #define	SDSSC_PROP_INDEX	"index"		/* One of the properties */
96*0Sstevel@tonic-gate #define	SDSSC_PROP_NODE		"node"		/* ditto */
97*0Sstevel@tonic-gate #define	SDSSC_PROP_INCAR	"incarnation"	/* ditto */
98*0Sstevel@tonic-gate #define	SDSSC_PROP_STATE	"state"		/* ditto */
99*0Sstevel@tonic-gate 
100*0Sstevel@tonic-gate #define	SDSSC_STATE_COMMIT	"commit"	/* state values */
101*0Sstevel@tonic-gate #define	SDSSC_STATE_CREATE	"create"	/* ditto */
102*0Sstevel@tonic-gate #define	SDSSC_STATE_DEL		"delete"	/* ditto */
103*0Sstevel@tonic-gate 
104*0Sstevel@tonic-gate /*
105*0Sstevel@tonic-gate  * When creating services in the DCS the index used is either set
106*0Sstevel@tonic-gate  * by the calling routine or sdssc_create_begin will pick the next
107*0Sstevel@tonic-gate  * available one. To have the next available one picked the following
108*0Sstevel@tonic-gate  * define should be used as the forth argument.
109*0Sstevel@tonic-gate  */
110*0Sstevel@tonic-gate #define	SDSSC_PICK_SETNO	0
111*0Sstevel@tonic-gate 
112*0Sstevel@tonic-gate /*
113*0Sstevel@tonic-gate  * The following number was lifted from the Cluster Project source
114*0Sstevel@tonic-gate  * code. Apparently they don't believe in using #define for constants.
115*0Sstevel@tonic-gate  * For now we'll create one.
116*0Sstevel@tonic-gate  */
117*0Sstevel@tonic-gate #define	SDSSC_NODE_NAME_LEN 64
118*0Sstevel@tonic-gate 
119*0Sstevel@tonic-gate /*
120*0Sstevel@tonic-gate  * We need to malloc a small amount of space for property values.
121*0Sstevel@tonic-gate  * The two values are integer strings with a value of 1 to 64.
122*0Sstevel@tonic-gate  */
123*0Sstevel@tonic-gate #define	SDSSC_NODE_INDEX_LEN	20
124*0Sstevel@tonic-gate 
125*0Sstevel@tonic-gate /*
126*0Sstevel@tonic-gate  * The maximum number of metadevices in a set is currently limited
127*0Sstevel@tonic-gate  * to 8192.
128*0Sstevel@tonic-gate  */
129*0Sstevel@tonic-gate #define	SDSSC_METADDEV_MAX	8192
130*0Sstevel@tonic-gate 
131*0Sstevel@tonic-gate /*
132*0Sstevel@tonic-gate  * To avoid the need for two separate files with definitions for the libraries
133*0Sstevel@tonic-gate  * entry points the following macro is being used. CLUSTER_LIBRARY_SOURCE
134*0Sstevel@tonic-gate  * is only defined in the libsdssc source just as the name implies. The
135*0Sstevel@tonic-gate  * reference below becomes a function prototype. Otherwise a pointer to a
136*0Sstevel@tonic-gate  * function is defined which can be used elsewhere in the commands.
137*0Sstevel@tonic-gate  */
138*0Sstevel@tonic-gate #ifdef CLUSTER_LIBRARY_SOURCE
139*0Sstevel@tonic-gate #define	REF(method, args) _##method args
140*0Sstevel@tonic-gate #else
141*0Sstevel@tonic-gate #define	REF(method, args) (* method) args
142*0Sstevel@tonic-gate #endif
143*0Sstevel@tonic-gate 
144*0Sstevel@tonic-gate struct sdssc_version {
145*0Sstevel@tonic-gate 	int	major;
146*0Sstevel@tonic-gate 	int	minor;
147*0Sstevel@tonic-gate 	int	library_level;
148*0Sstevel@tonic-gate };
149*0Sstevel@tonic-gate 
150*0Sstevel@tonic-gate typedef struct {
151*0Sstevel@tonic-gate 	char	*fname;		/* function name found in library */
152*0Sstevel@tonic-gate 	void	**fptr;		/* pointer to storage for global pointer */
153*0Sstevel@tonic-gate } func_table_t, *func_table_p;
154*0Sstevel@tonic-gate 
155*0Sstevel@tonic-gate enum rval1 {
156*0Sstevel@tonic-gate 	/*
157*0Sstevel@tonic-gate 	 * Function executed without errors. Duh
158*0Sstevel@tonic-gate 	 */
159*0Sstevel@tonic-gate 	SDSSC_OKAY,
160*0Sstevel@tonic-gate 
161*0Sstevel@tonic-gate 	/*
162*0Sstevel@tonic-gate 	 * Some generic error condition occurred
163*0Sstevel@tonic-gate 	 */
164*0Sstevel@tonic-gate 	SDSSC_ERROR,
165*0Sstevel@tonic-gate 
166*0Sstevel@tonic-gate 	/*
167*0Sstevel@tonic-gate 	 * sdssc_cmd_proxy was able to execute the command
168*0Sstevel@tonic-gate 	 * remotely.
169*0Sstevel@tonic-gate 	 */
170*0Sstevel@tonic-gate 	SDSSC_PROXY_DONE,
171*0Sstevel@tonic-gate 
172*0Sstevel@tonic-gate 	/*
173*0Sstevel@tonic-gate 	 * When the libsds_sc.so is not found or the system isn't
174*0Sstevel@tonic-gate 	 * part of a cluster the interface routines will return this
175*0Sstevel@tonic-gate 	 * as indication
176*0Sstevel@tonic-gate 	 */
177*0Sstevel@tonic-gate 	SDSSC_NOT_BOUND,
178*0Sstevel@tonic-gate 
179*0Sstevel@tonic-gate 	/*
180*0Sstevel@tonic-gate 	 * If the service isn't found in the CCR sdssc_get_primary
181*0Sstevel@tonic-gate 	 * will this enumeration.
182*0Sstevel@tonic-gate 	 */
183*0Sstevel@tonic-gate 	SDSSC_NO_SERVICE,
184*0Sstevel@tonic-gate 
185*0Sstevel@tonic-gate 	/*
186*0Sstevel@tonic-gate 	 * When the libsds_sc.so is found, but this specific routine failed
187*0Sstevel@tonic-gate 	 * to bind, then this interface routine will return this error.
188*0Sstevel@tonic-gate 	 * This error indicates that an older version of the libsds_sc.so
189*0Sstevel@tonic-gate 	 * library which does not support this routine.
190*0Sstevel@tonic-gate 	 */
191*0Sstevel@tonic-gate 	SDSSC_NOT_BOUND_ERROR
192*0Sstevel@tonic-gate 
193*0Sstevel@tonic-gate };
194*0Sstevel@tonic-gate enum dcs_state { SDSSC_COMMIT, SDSSC_CLEANUP };
195*0Sstevel@tonic-gate enum sds_boolean { SDSSC_True, SDSSC_False };
196*0Sstevel@tonic-gate enum sdssc_dcs_notify {	Make_Primary, Release_Primary, Shutdown_Services };
197*0Sstevel@tonic-gate 
198*0Sstevel@tonic-gate typedef enum rval1 rval_e;
199*0Sstevel@tonic-gate typedef enum dcs_state dcs_set_state_e;
200*0Sstevel@tonic-gate typedef struct sdssc_version sdssc_version_t;
201*0Sstevel@tonic-gate typedef enum sds_boolean sdssc_boolean_e;
202*0Sstevel@tonic-gate typedef enum sdssc_dcs_notify sdssc_dcs_notify_e;
203*0Sstevel@tonic-gate 
204*0Sstevel@tonic-gate rval_e sdssc_bind_library(void);
205*0Sstevel@tonic-gate rval_e REF(sdssc_version, (sdssc_version_t *));
206*0Sstevel@tonic-gate rval_e REF(sdssc_create_begin, (char *, int, char **, int));
207*0Sstevel@tonic-gate rval_e REF(sdssc_mo_create_begin, (char *, int, char **, int));
208*0Sstevel@tonic-gate rval_e REF(sdssc_create_end, (char *, dcs_set_state_e));
209*0Sstevel@tonic-gate rval_e REF(sdssc_delete_begin, (char *));
210*0Sstevel@tonic-gate rval_e REF(sdssc_delete_end, (char *, dcs_set_state_e));
211*0Sstevel@tonic-gate rval_e REF(sdssc_get_index, (char *, set_t *));
212*0Sstevel@tonic-gate rval_e REF(sdssc_add_hosts, (char *, int, char **));
213*0Sstevel@tonic-gate rval_e REF(sdssc_delete_hosts, (char *, int, char **));
214*0Sstevel@tonic-gate rval_e REF(sdssc_get_primary_host, (char *, char *, int));
215*0Sstevel@tonic-gate rval_e REF(sdssc_cmd_proxy, (int, char **, char *host, int *));
216*0Sstevel@tonic-gate rval_e REF(sdssc_getnodelist, (int **));
217*0Sstevel@tonic-gate void REF(sdssc_freenodelist, (int *));
218*0Sstevel@tonic-gate mdc_errno_t REF(sdssc_binddevs, (void));
219*0Sstevel@tonic-gate rval_e REF(sdssc_gettransportbynode, (int, char **));
220*0Sstevel@tonic-gate rval_e REF(sdssc_bindclusterdevs, (mdc_err_t ***));
221*0Sstevel@tonic-gate void REF(sdssc_free_mdcerr_list, (mdc_err_t **));
222*0Sstevel@tonic-gate rval_e REF(sdssc_clnt_bind_devs, (char *, mdc_err_t *));
223*0Sstevel@tonic-gate rval_e REF(sdssc_property_get, (char *, char *, char **));
224*0Sstevel@tonic-gate rval_e REF(sdssc_property_set, (char *, char *, char *));
225*0Sstevel@tonic-gate rval_e REF(sdssc_get_services, (char ***));
226*0Sstevel@tonic-gate rval_e REF(sdssc_get_services_free, (char **));
227*0Sstevel@tonic-gate rval_e REF(sdssc_suspend, (const char *));
228*0Sstevel@tonic-gate rval_e REF(sdssc_convert_cluster_path, (const char *, char **));
229*0Sstevel@tonic-gate rval_e REF(sdssc_convert_ctd_path, (const char *, char **));
230*0Sstevel@tonic-gate void REF(sdssc_convert_path_free, (char *));
231*0Sstevel@tonic-gate rval_e REF(sdssc_notify_service, (const char *, sdssc_dcs_notify_e));
232*0Sstevel@tonic-gate void REF(sdssc_cm_nm2nid, (char *));
233*0Sstevel@tonic-gate void REF(sdssc_cm_sr_nm2nid, (md_set_record *));
234*0Sstevel@tonic-gate void REF(sdssc_cm_nid2nm, (char *));
235*0Sstevel@tonic-gate void REF(sdssc_cm_sr_nid2nm, (md_set_record *));
236*0Sstevel@tonic-gate rval_e REF(sdssc_get_priv_ipaddr, (char *, struct in_addr *));
237*0Sstevel@tonic-gate rval_e REF(sdssc_clnt_proxy_cmd, (uint_t, char **, uint_t, char **,
238*0Sstevel@tonic-gate     char *, mdc_err_t *));
239*0Sstevel@tonic-gate 
240*0Sstevel@tonic-gate #ifdef CLUSTER_LIBRARY_SOURCE
241*0Sstevel@tonic-gate /*
242*0Sstevel@tonic-gate  * Support routines used with libsds_sc.so and not for public
243*0Sstevel@tonic-gate  * consumption (see mapfile-vers for scoping).
244*0Sstevel@tonic-gate  */
245*0Sstevel@tonic-gate rval_e l_get_property(scconf_cfg_ds_t *, char *, char **);
246*0Sstevel@tonic-gate void *l_get_incarnation(int);
247*0Sstevel@tonic-gate char *l_incarnation_to_prop(int);
248*0Sstevel@tonic-gate void *l_prop_to_incarnation(char *);
249*0Sstevel@tonic-gate sdssc_boolean_e l_compare_incarnation(void *, void *);
250*0Sstevel@tonic-gate rval_e l_build_hostlist(scconf_nodeid_t *, char ***);
251*0Sstevel@tonic-gate #endif
252*0Sstevel@tonic-gate #ifdef __cplusplus
253*0Sstevel@tonic-gate }
254*0Sstevel@tonic-gate #endif
255*0Sstevel@tonic-gate 
256*0Sstevel@tonic-gate #endif /* _SDSSC_H */
257