Deleted Added
sdiff udiff text old ( 252218 ) new ( 254591 )
full compact
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

--- 59 unchanged lines hidden (view full) ---

68 "ZFS-8000-JQ",
69 "ZFS-8000-K4",
70};
71
72#define NMSGID (sizeof (zfs_msgid_table) / sizeof (zfs_msgid_table[0]))
73
74/* ARGSUSED */
75static int
76vdev_missing(uint64_t state, uint64_t aux, uint64_t errs)
77{
78 return (state == VDEV_STATE_CANT_OPEN &&
79 aux == VDEV_AUX_OPEN_FAILED);
80}
81
82/* ARGSUSED */
83static int
84vdev_faulted(uint64_t state, uint64_t aux, uint64_t errs)
85{
86 return (state == VDEV_STATE_FAULTED);
87}
88
89/* ARGSUSED */
90static int
91vdev_errors(uint64_t state, uint64_t aux, uint64_t errs)
92{
93 return (state == VDEV_STATE_DEGRADED || errs != 0);
94}
95
96/* ARGSUSED */
97static int
98vdev_broken(uint64_t state, uint64_t aux, uint64_t errs)
99{
100 return (state == VDEV_STATE_CANT_OPEN);
101}
102
103/* ARGSUSED */
104static int
105vdev_offlined(uint64_t state, uint64_t aux, uint64_t errs)
106{
107 return (state == VDEV_STATE_OFFLINE);
108}
109
110/* ARGSUSED */
111static int
112vdev_removed(uint64_t state, uint64_t aux, uint64_t errs)
113{
114 return (state == VDEV_STATE_REMOVED);
115}
116
117/*
118 * Detect if any leaf devices that have seen errors or could not be opened.
119 */
120static boolean_t
121find_vdev_problem(nvlist_t *vdev, int (*func)(uint64_t, uint64_t, uint64_t))
122{
123 nvlist_t **child;
124 vdev_stat_t *vs;
125 uint_t c, children;
126 char *type;
127
128 /*
129 * Ignore problems within a 'replacing' vdev, since we're presumably in
130 * the process of repairing any such errors, and don't want to call them
131 * out again. We'll pick up the fact that a resilver is happening
132 * later.
133 */
134 verify(nvlist_lookup_string(vdev, ZPOOL_CONFIG_TYPE, &type) == 0);
135 if (strcmp(type, VDEV_TYPE_REPLACING) == 0)
136 return (B_FALSE);
137
138 if (nvlist_lookup_nvlist_array(vdev, ZPOOL_CONFIG_CHILDREN, &child,
139 &children) == 0) {
140 for (c = 0; c < children; c++)
141 if (find_vdev_problem(child[c], func))
142 return (B_TRUE);
143 } else {
144 verify(nvlist_lookup_uint64_array(vdev, ZPOOL_CONFIG_VDEV_STATS,
145 (uint64_t **)&vs, &c) == 0);
146
147 if (func(vs->vs_state, vs->vs_aux,
148 vs->vs_read_errors +
149 vs->vs_write_errors +
150 vs->vs_checksum_errors))
151 return (B_TRUE);
152 }
153
154 /*
155 * Check any L2 cache devs
156 */
157 if (nvlist_lookup_nvlist_array(vdev, ZPOOL_CONFIG_L2CACHE, &child,
158 &children) == 0) {
159 for (c = 0; c < children; c++)
160 if (find_vdev_problem(child[c], func))
161 return (B_TRUE);
162 }
163
164 return (B_FALSE);
165}
166
167/*
168 * Active pool health status.

--- 96 unchanged lines hidden (view full) ---

265 vs->vs_aux == VDEV_AUX_BAD_LOG) {
266 return (ZPOOL_STATUS_BAD_LOG);
267 }
268
269 /*
270 * Bad devices in non-replicated config.
271 */
272 if (vs->vs_state == VDEV_STATE_CANT_OPEN &&
273 find_vdev_problem(nvroot, vdev_faulted))
274 return (ZPOOL_STATUS_FAULTED_DEV_NR);
275
276 if (vs->vs_state == VDEV_STATE_CANT_OPEN &&
277 find_vdev_problem(nvroot, vdev_missing))
278 return (ZPOOL_STATUS_MISSING_DEV_NR);
279
280 if (vs->vs_state == VDEV_STATE_CANT_OPEN &&
281 find_vdev_problem(nvroot, vdev_broken))
282 return (ZPOOL_STATUS_CORRUPT_LABEL_NR);
283
284 /*
285 * Corrupted pool metadata
286 */
287 if (vs->vs_state == VDEV_STATE_CANT_OPEN &&
288 vs->vs_aux == VDEV_AUX_CORRUPT_DATA)
289 return (ZPOOL_STATUS_CORRUPT_POOL);

--- 5 unchanged lines hidden (view full) ---

295 if (nvlist_lookup_uint64(config, ZPOOL_CONFIG_ERRCOUNT,
296 &nerr) == 0 && nerr != 0)
297 return (ZPOOL_STATUS_CORRUPT_DATA);
298 }
299
300 /*
301 * Missing devices in a replicated config.
302 */
303 if (find_vdev_problem(nvroot, vdev_faulted))
304 return (ZPOOL_STATUS_FAULTED_DEV_R);
305 if (find_vdev_problem(nvroot, vdev_missing))
306 return (ZPOOL_STATUS_MISSING_DEV_R);
307 if (find_vdev_problem(nvroot, vdev_broken))
308 return (ZPOOL_STATUS_CORRUPT_LABEL_R);
309
310 /*
311 * Devices with errors
312 */
313 if (!isimport && find_vdev_problem(nvroot, vdev_errors))
314 return (ZPOOL_STATUS_FAILING_DEV);
315
316 /*
317 * Offlined devices
318 */
319 if (find_vdev_problem(nvroot, vdev_offlined))
320 return (ZPOOL_STATUS_OFFLINE_DEV);
321
322 /*
323 * Removed device
324 */
325 if (find_vdev_problem(nvroot, vdev_removed))
326 return (ZPOOL_STATUS_REMOVED_DEV);
327
328 /*
329 * Outdated, but usable, version
330 */
331 if (SPA_VERSION_IS_SUPPORTED(version) && version != SPA_VERSION)
332 return (ZPOOL_STATUS_VERSION_OLDER);
333
334 /*
335 * Usable pool with disabled features
336 */

--- 114 unchanged lines hidden ---