1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
|
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
* Copyright 2016 Nexenta Systems, Inc. All rights reserved.
*/
#ifndef _DISKMOND_CONF_H
#define _DISKMOND_CONF_H
/*
* Configuration File data
*/
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/types.h>
#include <pthread.h>
#include <libnvpair.h>
#include <fm/fmd_api.h>
#include "dm_types.h"
#include "util.h"
#ifndef MIN
#define MIN(x, y) ((x) < (y) ? (x) : (y))
#endif
#ifndef MAX
#define MAX(x, y) ((x) > (y) ? (x) : (y))
#endif
#define DEVICES_PREFIX "/devices"
#define GLOBAL_PROP_LOG_LEVEL "log-level"
/* Property names (and values) for the disk configuration file entity */
#define DISK_PROP_DEVPATH "dev-path"
#define DISK_PROP_LOGNAME "logical-path"
#define DISK_PROP_FRUACTION "fru-update-action"
#define DISK_PROP_OTEMPACTION "overtemp-action"
#define DISK_PROP_STFAILACTION "selftest-fail-action"
#define DISK_PROP_SSMWEAROUTACTION "ssm-wearout-action"
/* Properties for the "ap" subentity */
#define DISK_AP_PROP_APID "path"
#define DEVPATH_MINOR_SEPARATOR ':'
#define DEFAULT_FAULT_POLLING_INTERVAL 3600 /* seconds */
#define INDICATOR_FAULT_IDENTIFIER "FAULT"
typedef enum conf_err_e {
E_NO_ERROR = 0,
E_MULTIPLE_IND_LISTS_DEFINED,
E_MULTIPLE_INDRULE_LISTS_DEFINED,
E_INVALID_STATE_CHANGE,
E_IND_MULTIPLY_DEFINED,
E_IND_ACTION_REDUNDANT,
E_IND_ACTION_CONFLICT,
E_IND_MISSING_FAULT_ON,
E_IND_MISSING_FAULT_OFF,
E_INDRULE_REFERENCES_NONEXISTENT_IND_ACTION,
E_DUPLICATE_STATE_TRANSITION
} conf_err_t;
typedef enum {
INDICATOR_UNKNOWN,
INDICATOR_ON,
INDICATOR_OFF
} ind_state_t;
typedef enum {
TS_NOT_RUNNING,
TS_RUNNING,
TS_EXIT_REQUESTED,
TS_EXITED
} thread_state_t;
typedef struct ind_action {
ind_state_t ind_state;
char *ind_name;
struct ind_action *next;
} ind_action_t;
typedef struct state_transition {
hotplug_state_t begin;
hotplug_state_t end;
} state_transition_t;
typedef struct indrule {
state_transition_t strans;
ind_action_t *action_list;
struct indrule *next;
} indrule_t;
typedef struct indicator {
ind_state_t ind_state;
char *ind_name;
char *ind_instr_spec;
struct indicator *next;
} indicator_t;
typedef struct diskmon {
/*
* Static configuration data
*/
nvlist_t *props;
char *location; /* descriptive location */
nvlist_t *app_props;
indicator_t *ind_list;
indrule_t *indrule_list;
/*
* Dynamic data
*/
hotplug_state_t state;
/*
* Only one manager can be manipulating the
* state in the diskmon at one time (either the
* state-change manager or the fault-polling manager)
*/
pthread_mutex_t manager_mutex;
/*
* Set to true only during initialization, and
* cleared the next time a fru update needs to
* occur, this flag enabled an optimization of
* NOT calling libtopo for a configuration update
* when the DE starts up. This allows a HUGE
* savings (since only a single snapshot-- the
* initial snapshot) is used as the source of
* the FRU information.
*/
boolean_t initial_configuration;
/* For the state-change manager: */
/*
* Current state of the fault indicator.
*/
pthread_mutex_t fault_indicator_mutex;
ind_state_t fault_indicator_state;
/*
* Set to TRUE when a disk transitions to the CONFIGURED state
* and remains TRUE until the disk is physically removed.
*/
boolean_t configured_yet;
/*
* The number of disk hotplug state transitions since the disk
* was inserted.
*/
uint_t state_change_count;
/* Disk FRU (model, manufacturer, etc) information */
pthread_mutex_t fru_mutex;
dm_fru_t *frup;
struct diskmon *next;
} diskmon_t;
typedef struct cfgdata {
nvlist_t *props;
diskmon_t *disk_list;
} cfgdata_t;
typedef struct namevalpr {
char *name;
char *value;
} namevalpr_t;
extern indicator_t *new_indicator(ind_state_t lstate, char *namep,
char *actionp);
extern void link_indicator(indicator_t **first,
indicator_t *to_add);
extern void ind_free(indicator_t *indp);
extern ind_action_t *new_indaction(ind_state_t state, char *namep);
extern void link_indaction(ind_action_t **first,
ind_action_t *to_add);
extern void indaction_free(ind_action_t *lap);
extern indrule_t *new_indrule(state_transition_t *st,
ind_action_t *actionp);
extern void link_indrule(indrule_t **first, indrule_t *to_add);
extern void indrule_free(indrule_t *lrp);
extern diskmon_t *new_diskmon(nvlist_t *app_props, indicator_t *indp,
indrule_t *indrp, nvlist_t *nvlp);
extern void diskmon_free(diskmon_t *dmp);
extern dm_fru_t *new_dmfru(char *manu, char *modl, char *firmrev,
char *serno, uint64_t capa);
extern void dmfru_free(dm_fru_t *frup);
extern nvlist_t *namevalpr_to_nvlist(namevalpr_t *nvprp);
extern conf_err_t check_state_transition(hotplug_state_t s1,
hotplug_state_t s2);
extern conf_err_t check_inds(indicator_t *indp);
extern conf_err_t check_indactions(ind_action_t *indap);
extern conf_err_t check_indrules(indrule_t *indrp,
state_transition_t **offender);
extern conf_err_t check_consistent_ind_indrules(indicator_t *indp,
indrule_t *indrp, ind_action_t **offender);
extern void cfgdata_add_diskmon(cfgdata_t *cfgp, diskmon_t *dmp);
extern void conf_error_msg(conf_err_t err, char *buf, int buflen,
void *arg);
extern const char *dm_prop_lookup(nvlist_t *props, const char *prop_name);
extern int dm_prop_lookup_int(nvlist_t *props,
const char *prop_name, int *value);
extern int config_init(void);
extern int config_get(fmd_hdl_t *hdl, const fmd_prop_t *fmd_props);
extern void config_fini(void);
extern const char *hotplug_state_string(hotplug_state_t state);
extern nvlist_t *dm_global_proplist(void);
#ifdef __cplusplus
}
#endif
#endif /* _DISKMOND_CONF_H */
|