xref: /titanic_50/usr/src/lib/libdscfg/common/cfg_cluster.h (revision 0ba6f73dcd1c9160a44b2872ed0e0d81b51d168f)
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  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef _CFG_CLUSTER_H
27 #define	_CFG_CLUSTER_H
28 
29 #ifdef	__cplusplus
30 extern "C" {
31 #endif
32 
33 /*
34  * This file is a combination of interfaces culled from scstat.h,
35  * scconf.h and the header files that they include.
36  *
37  * It exposes a subset of the interfaces defined in PSARC/2001/261
38  * for use in NWS software.
39  */
40 
41 #include <sys/errno.h>
42 #include <sys/types.h>
43 
44 /*
45  * From sc_syslog_msg.h
46  */
47 
48 typedef enum sc_state_code_enum {
49 	ONLINE = 1,	/* resource is running */
50 	OFFLINE,	/* resource is stopped due to user action */
51 	FAULTED,	/* resource is stopped due to a failure */
52 	DEGRADED,	/* resource is running but has a minor problem */
53 	WAIT,		/* resource is in transition from a state to another */
54 
55 	/*
56 	 * resource is monitored but state of the resource is
57 	 * not known because either the monitor went down or
58 	 * the monitor cannot report resource state temporarily.
59 	 */
60 	UNKNOWN,
61 
62 	NOT_MONITORED	/* There is no monitor to check state of the resource */
63 } sc_state_code_t;
64 
65 /*
66  * End sc_syslog_msg.h
67  */
68 
69 
70 /*
71  * From scstat.h
72  */
73 
74 #define	SCSTAT_MAX_STRING_LEN	1024
75 
76 /* Error codes returned by scstat functions. */
77 /* This definition is covered by PSARC/2001/261.  DO NOT change it. */
78 typedef enum scstat_errno {
79 	SCSTAT_ENOERR,		/* normal return - no error */
80 	SCSTAT_EUSAGE,		/* syntax error */
81 	SCSTAT_ENOMEM,		/* not enough memory */
82 	SCSTAT_ENOTCLUSTER,	/* not a cluster node */
83 	SCSTAT_ENOTCONFIGURED,	/* not found in CCR */
84 	SCSTAT_ESERVICENAME,	/* dcs: invalid service name */
85 	SCSTAT_EINVAL,		/* scconf: invalid argument */
86 	SCSTAT_EPERM,		/* not root */
87 	SCSTAT_ECLUSTERRECONFIG, /* cluster is reconfiguring */
88 	SCSTAT_ERGRECONFIG,	/* RG is reconfiguring */
89 	SCSTAT_EOBSOLETE,	/* Resource/RG has been updated */
90 	SCSTAT_EUNEXPECTED	/* internal or unexpected error */
91 } scstat_errno_t;
92 
93 /* States a resource can be in */
94 /* This definition is covered by PSARC/2001/261.  DO NOT change it. */
95 typedef enum scstat_state_code {
96 	SCSTAT_ONLINE = ONLINE,		/* resource is running */
97 	SCSTAT_OFFLINE = OFFLINE, /* resource stopped due to user action */
98 	SCSTAT_FAULTED = FAULTED, /* resource stopped due to a failure */
99 	SCSTAT_DEGRADED = DEGRADED, /* resource running with a minor problem */
100 	SCSTAT_WAIT = WAIT,		/* resource is in transition */
101 	SCSTAT_UNKNOWN = UNKNOWN,	/* resource state is unknown */
102 	SCSTAT_NOTMONITORED = NOT_MONITORED	/* resource is not monitored */
103 } scstat_state_code_t;
104 
105 /* States a replica of a resource can be in */
106 /* This definition is covered by PSARC/2001/261.  DO NOT change it. */
107 typedef enum scstat_node_pref {
108 	SCSTAT_PRIMARY,		/* replica is a primary */
109 	SCSTAT_SECONDARY,	/* replica is a secondary */
110 	SCSTAT_SPARE,		/* replica is a spare */
111 	SCSTAT_INACTIVE,	/* replica is inactive */
112 	SCSTAT_TRANSITION,	/* replica is changing state */
113 	SCSTAT_INVALID		/* replica is in an invalid state */
114 } scstat_node_pref_t;
115 
116 /* component name */
117 typedef char *scstat_name_t;
118 typedef scstat_name_t scstat_cluster_name_t;	/* cluster name */
119 typedef scstat_name_t scstat_node_name_t;	/* node name */
120 typedef scstat_name_t scstat_adapter_name_t;	/* adapter name */
121 typedef scstat_name_t scstat_path_name_t;	/* path name */
122 typedef scstat_name_t scstat_ds_name_t;		/* device service name */
123 typedef scstat_name_t scstat_quorumdev_name_t;	/* quorum device name */
124 typedef scstat_name_t scstat_rs_name_t;		/* resource name */
125 typedef scstat_name_t scstat_rg_name_t;		/* rg name */
126 
127 /* status string */
128 typedef char *scstat_statstr_t;
129 typedef scstat_statstr_t scstat_node_statstr_t;		/* node status */
130 typedef scstat_statstr_t scstat_path_statstr_t;		/* path status */
131 typedef scstat_statstr_t scstat_ds_statstr_t;		/* DS status */
132 typedef scstat_statstr_t scstat_node_quorum_statstr_t;	/* node quorum status */
133 typedef scstat_statstr_t scstat_quorumdev_statstr_t; 	/* quorum device stat */
134 
135 /* ha device node status list */
136 /* This definition is covered by PSARC/2001/261.  DO NOT change it. */
137 typedef struct scstat_ds_node_state_struct {
138 	/* node name */
139 	scstat_node_name_t			scstat_node_name;
140 	/* node status */
141 	scstat_node_pref_t			scstat_node_state;
142 	/* next */
143 	struct scstat_ds_node_state_struct	*scstat_node_next;
144 } scstat_ds_node_state_t;
145 
146 /* Cluster node status */
147 /* This definition is covered by PSARC/2001/261.  DO NOT change it. */
148 typedef struct scstat_node_struct {
149 	scstat_node_name_t	scstat_node_name;	/* node name */
150 	scstat_state_code_t	scstat_node_status;	/* cluster membership */
151 	scstat_node_statstr_t	scstat_node_statstr;	/* node status string */
152 	void			*pad;			/* Padding for */
153 							/* PSARC/2001/261. */
154 	struct scstat_node_struct *scstat_node_next;	/* next */
155 } scstat_node_t;
156 
157 /* Cluster ha device status */
158 /* This definition is covered by PSARC/2001/261.  DO NOT change it. */
159 typedef struct scstat_ds_struct {
160 	/* ha device name */
161 	scstat_ds_name_t		scstat_ds_name;
162 	/* ha device status */
163 	scstat_state_code_t		scstat_ds_status;
164 	/* ha device statstr */
165 	scstat_ds_statstr_t		scstat_ds_statstr;
166 	/* node preference list */
167 	scstat_ds_node_state_t		*scstat_node_state_list;
168 	/* next */
169 	struct scstat_ds_struct		*scstat_ds_next;
170 } scstat_ds_t;
171 
172 /*
173  * scstat_strerr
174  *
175  * Map scstat_errno_t to a string.
176  *
177  * The supplied "errbuffer" should be of at least SCSTAT_MAX_STRING_LEN
178  * in length.
179  */
180 /* This definition is covered by PSARC/2001/261.  DO NOT change it. */
181 void scstat_strerr(scstat_errno_t, char *);
182 
183 /*
184  * Upon success, a list of objects of scstat_node_t are returned.
185  * The caller is responsible for freeing the space.
186  *
187  * Possible return values:
188  *
189  *	SCSTAT_NOERR		- success
190  *	SCSTAT_ENOMEM		- not enough memory
191  *	SCSTAT_EPERM            - not root
192  *      SCSTAT_ENOTCLUSTER      - there is no cluster
193  *      SCCONF_EINVAL           - invalid argument
194  *	SCSTAT_EUNEXPECTED	- internal or unexpected error
195  */
196 /* This definition is covered by PSARC/2001/261.  DO NOT change it. */
197 scstat_errno_t scstat_get_nodes(scstat_node_t **pplnodes);
198 
199 /*
200  * Free all memory associated with a scstat_node_t structure.
201  */
202 /* This definition is covered by PSARC/2001/261.  DO NOT change it. */
203 void scstat_free_nodes(scstat_node_t *plnodes);
204 
205 /*
206  * If the device service name passed in is NULL, then this function returns
207  * the status of all device services, otherwise it returns the status of the
208  * device service specified.
209  * The caller is responsible for freeing the space.
210  *
211  * Possible return values:
212  *
213  *	SCSTAT_ENOERR		- success
214  *	SCSTAT_ENOMEM		- not enough memory
215  *	SCSTAT_EPERM            - not root
216  *      SCSTAT_ENOTCLUSTER      - there is no cluster
217  *      SCCONF_EINVAL           - invalid argument
218  *	SCSTAT_ESERVICENAME	- invalid device group name
219  *	SCSTAT_EUNEXPECTED	- internal or unexpected error
220  */
221 /* This definition is covered by PSARC/2001/261.  DO NOT change it. */
222 scstat_errno_t scstat_get_ds_status(scstat_ds_name_t *dsname,
223     scstat_ds_t **dsstatus);
224 
225 /*
226  * Free memory associated with a scstat_ds_t structure.
227  */
228 /* This definition is covered by PSARC/2001/261.  DO NOT change it. */
229 void scstat_free_ds_status(scstat_ds_t *dsstatus);
230 
231 /*
232  * End scstat.h
233  */
234 
235 /*
236  * From scconf.h
237  */
238 
239 /* Maximum message string length */
240 #define	SCCONF_MAXSTRINGLEN	1024
241 
242 /* This definition is covered by PSARC/2001/261.  DO NOT change it. */
243 typedef enum scconf_errno {
244 	SCCONF_NOERR = 0,		/* normal return - no error */
245 	SCCONF_EPERM = 1,		/* permission denied */
246 	SCCONF_EEXIST = 2,		/* object already exists */
247 	SCCONF_ENOEXIST = 3,		/* object does not exist */
248 	SCCONF_ESTALE = 4,		/* object or handle is stale */
249 	SCCONF_EUNKNOWN = 5,		/* unkown type */
250 	SCCONF_ENOCLUSTER = 6,		/* cluster does not exist */
251 	SCCONF_ENODEID = 7,		/* ID used in place of node name */
252 	SCCONF_EINVAL = 8,		/* invalid argument */
253 	SCCONF_EUSAGE = 9,		/* command usage error */
254 	SCCONF_ETIMEDOUT = 10,		/* call timed out */
255 	SCCONF_EINUSE = 11,		/* already in use */
256 	SCCONF_EBUSY = 12,		/* busy, try again later */
257 	SCCONF_EINSTALLMODE = 13,	/* install mode */
258 	SCCONF_ENOMEM = 14,		/* not enough memory */
259 	SCCONF_ESETUP = 15,		/* setup attempt failed */
260 	SCCONF_EUNEXPECTED = 16,	/* internal or unexpected error */
261 	SCCONF_EBADVALUE = 17,		/* bad ccr table value */
262 	SCCONF_EOVERFLOW = 18,		/* message buffer overflow */
263 	SCCONF_EQUORUM = 19,		/* operation would compromise quorum */
264 	SCCONF_TM_EBADOPTS = 20,	/* bad transport TM "options" */
265 	SCCONF_TM_EINVAL = 21,		/* other transport TM error */
266 	SCCONF_DS_ESUSPENDED = 22,	/* Device service in suspended state */
267 	SCCONF_DS_ENODEINVAL = 23,	/* Node specified is not in cluster */
268 	SCCONF_EAUTH = 24,		/* authentication error */
269 	SCCONF_DS_EINVAL = 25,		/* Device service in an invalid state */
270 	SCCONF_EIO = 26			/* IO error */
271 } scconf_errno_t;
272 
273 /* IDs */
274 /* This definition is covered by PSARC/2001/261.  DO NOT change it. */
275 typedef uint_t scconf_id_t;
276 
277 /* This definition is covered by PSARC/2001/261.  DO NOT change it. */
278 typedef scconf_id_t scconf_nodeid_t;		/* node ID */
279 
280 /* Cluster transport handle */
281 /* This definition is covered by PSARC/2001/261.  DO NOT change it. */
282 typedef void *		scconf_cltr_handle_t;
283 
284 /* This definition is covered by PSARC/2001/261.  DO NOT change it. */
285 extern scconf_errno_t scconf_get_nodeid(char *nodename,
286     scconf_nodeid_t *nodeidp);
287 
288 /*
289  * Get the name of a node from its "nodeid".  Upon success,
290  * a pointer to the nodename is left in "nodenamep".
291  *
292  * It is the caller's responsibility to free memory allocated
293  * for "nodename" using free(3C).
294  *
295  * Possible return values:
296  *
297  *	SCCONF_NOERR		- success
298  *	SCCONF_EPERM		- not root
299  *	SCCONF_ENOCLUSTER	- there is no cluster
300  *	SCCONF_ENOMEM		- not enough memory
301  *	SCCONF_EINVAL		- invalid argument
302  *	SCCONF_EUNEXPECTED	- internal or unexpected error
303  */
304 /* This definition is covered by PSARC/2001/261.  DO NOT change it. */
305 extern scconf_errno_t scconf_get_nodename(scconf_nodeid_t nodeid,
306     char **nodenamep);
307 
308 /*
309  * Map scconf_errno_t to a string.
310  *
311  * The supplied "errbuffer" should be of at least SCCONF_MAXSTRINGLEN
312  * in length.
313  */
314 /* This definition is covered by PSARC/2001/261.  DO NOT change it. */
315 extern void scconf_strerr(char *errbuffer, scconf_errno_t err);
316 
317 /*
318  * Given a dev_t value, return the name of device service that contains this
319  * device.
320  *
321  * The caller is responsible for freeing the memory returned in "name".
322  *
323  * Possible return values:
324  *
325  *      SCCONF_NOERR            - success
326  *      SCCONF_EPERM            - not root
327  *      SCCONF_ENOEXIST         - the given device is not configured
328  *      SCCONF_ENOMEM           - not enough memory
329  *      SCCONF_ENOCLUSTER       - cluster config does not exist
330  *      SCCONF_EUNEXPECTED      - internal or unexpected error
331  */
332 /* This definition is covered by PSARC/2001/261.  DO NOT change it. */
333 extern scconf_errno_t scconf_get_ds_by_devt(major_t maj, minor_t min,
334     char **dsname);
335 
336 /*
337  * End scconf.h
338  */
339 
340 #ifdef	__cplusplus
341 }
342 #endif
343 
344 #endif /* _CFG_CLUSTER_H */
345