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

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

276 vs->vs_aux == VDEV_AUX_BAD_LOG) {
277 return (ZPOOL_STATUS_BAD_LOG);
278 }
279
280 /*
281 * Bad devices in non-replicated config.
282 */
283 if (vs->vs_state == VDEV_STATE_CANT_OPEN &&
273 find_vdev_problem(nvroot, vdev_faulted))
284 find_vdev_problem(nvroot, vdev_faulted, B_TRUE))
274 return (ZPOOL_STATUS_FAULTED_DEV_NR);
275
276 if (vs->vs_state == VDEV_STATE_CANT_OPEN &&
285 return (ZPOOL_STATUS_FAULTED_DEV_NR);
286
287 if (vs->vs_state == VDEV_STATE_CANT_OPEN &&
277 find_vdev_problem(nvroot, vdev_missing))
288 find_vdev_problem(nvroot, vdev_missing, B_TRUE))
278 return (ZPOOL_STATUS_MISSING_DEV_NR);
279
280 if (vs->vs_state == VDEV_STATE_CANT_OPEN &&
289 return (ZPOOL_STATUS_MISSING_DEV_NR);
290
291 if (vs->vs_state == VDEV_STATE_CANT_OPEN &&
281 find_vdev_problem(nvroot, vdev_broken))
292 find_vdev_problem(nvroot, vdev_broken, B_TRUE))
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 */
293 return (ZPOOL_STATUS_CORRUPT_LABEL_NR);
294
295 /*
296 * Corrupted pool metadata
297 */
298 if (vs->vs_state == VDEV_STATE_CANT_OPEN &&
299 vs->vs_aux == VDEV_AUX_CORRUPT_DATA)
300 return (ZPOOL_STATUS_CORRUPT_POOL);

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

306 if (nvlist_lookup_uint64(config, ZPOOL_CONFIG_ERRCOUNT,
307 &nerr) == 0 && nerr != 0)
308 return (ZPOOL_STATUS_CORRUPT_DATA);
309 }
310
311 /*
312 * Missing devices in a replicated config.
313 */
303 if (find_vdev_problem(nvroot, vdev_faulted))
314 if (find_vdev_problem(nvroot, vdev_faulted, B_TRUE))
304 return (ZPOOL_STATUS_FAULTED_DEV_R);
315 return (ZPOOL_STATUS_FAULTED_DEV_R);
305 if (find_vdev_problem(nvroot, vdev_missing))
316 if (find_vdev_problem(nvroot, vdev_missing, B_TRUE))
306 return (ZPOOL_STATUS_MISSING_DEV_R);
317 return (ZPOOL_STATUS_MISSING_DEV_R);
307 if (find_vdev_problem(nvroot, vdev_broken))
318 if (find_vdev_problem(nvroot, vdev_broken, B_TRUE))
308 return (ZPOOL_STATUS_CORRUPT_LABEL_R);
309
310 /*
311 * Devices with errors
312 */
319 return (ZPOOL_STATUS_CORRUPT_LABEL_R);
320
321 /*
322 * Devices with errors
323 */
313 if (!isimport && find_vdev_problem(nvroot, vdev_errors))
324 if (!isimport && find_vdev_problem(nvroot, vdev_errors, B_TRUE))
314 return (ZPOOL_STATUS_FAILING_DEV);
315
316 /*
317 * Offlined devices
318 */
325 return (ZPOOL_STATUS_FAILING_DEV);
326
327 /*
328 * Offlined devices
329 */
319 if (find_vdev_problem(nvroot, vdev_offlined))
330 if (find_vdev_problem(nvroot, vdev_offlined, B_TRUE))
320 return (ZPOOL_STATUS_OFFLINE_DEV);
321
322 /*
323 * Removed device
324 */
331 return (ZPOOL_STATUS_OFFLINE_DEV);
332
333 /*
334 * Removed device
335 */
325 if (find_vdev_problem(nvroot, vdev_removed))
336 if (find_vdev_problem(nvroot, vdev_removed, B_TRUE))
326 return (ZPOOL_STATUS_REMOVED_DEV);
327
328 /*
337 return (ZPOOL_STATUS_REMOVED_DEV);
338
339 /*
340 * Suboptimal, but usable, ashift configuration.
341 */
342 if (find_vdev_problem(nvroot, vdev_non_native_ashift, B_FALSE))
343 return (ZPOOL_STATUS_NON_NATIVE_ASHIFT);
344
345 /*
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 ---
346 * Outdated, but usable, version
347 */
348 if (SPA_VERSION_IS_SUPPORTED(version) && version != SPA_VERSION)
349 return (ZPOOL_STATUS_VERSION_OLDER);
350
351 /*
352 * Usable pool with disabled features
353 */

--- 114 unchanged lines hidden ---