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(vdev_stat_t *vs, uint_t vsc) |
77{ |
78 return (vs->vs_state == VDEV_STATE_CANT_OPEN && 79 vs->vs_aux == VDEV_AUX_OPEN_FAILED); |
80} 81 82/* ARGSUSED */ 83static int |
84vdev_faulted(vdev_stat_t *vs, uint_t vsc) |
85{ |
86 return (vs->vs_state == VDEV_STATE_FAULTED); |
87} 88 89/* ARGSUSED */ 90static int |
91vdev_errors(vdev_stat_t *vs, uint_t vsc) |
92{ |
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); |
96} 97 98/* ARGSUSED */ 99static int |
100vdev_broken(vdev_stat_t *vs, uint_t vsc) |
101{ |
102 return (vs->vs_state == VDEV_STATE_CANT_OPEN); |
103} 104 105/* ARGSUSED */ 106static int |
107vdev_offlined(vdev_stat_t *vs, uint_t vsc) |
108{ |
109 return (vs->vs_state == VDEV_STATE_OFFLINE); |
110} 111 112/* ARGSUSED */ 113static int |
114vdev_removed(vdev_stat_t *vs, uint_t vsc) |
115{ |
116 return (vs->vs_state == VDEV_STATE_REMOVED); |
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 |
126/* 127 * Detect if any leaf devices that have seen errors or could not be opened. 128 */ 129static boolean_t |
130find_vdev_problem(nvlist_t *vdev, int (*func)(vdev_stat_t *, uint_t), 131 boolean_t ignore_replacing) |
132{ 133 nvlist_t **child; 134 vdev_stat_t *vs; |
135 uint_t c, vsc, children; |
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 */ |
143 if (ignore_replacing == B_TRUE) { 144 char *type; |
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 |
152 if (nvlist_lookup_nvlist_array(vdev, ZPOOL_CONFIG_CHILDREN, &child, 153 &children) == 0) { 154 for (c = 0; c < children; c++) |
155 if (find_vdev_problem(child[c], func, ignore_replacing)) |
156 return (B_TRUE); 157 } else { 158 verify(nvlist_lookup_uint64_array(vdev, ZPOOL_CONFIG_VDEV_STATS, |
159 (uint64_t **)&vs, &vsc) == 0); |
160 |
161 if (func(vs, vsc) != 0) |
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++) |
171 if (find_vdev_problem(child[c], func, ignore_replacing)) |
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 && |
284 find_vdev_problem(nvroot, vdev_faulted, B_TRUE)) |
285 return (ZPOOL_STATUS_FAULTED_DEV_NR); 286 287 if (vs->vs_state == VDEV_STATE_CANT_OPEN && |
288 find_vdev_problem(nvroot, vdev_missing, B_TRUE)) |
289 return (ZPOOL_STATUS_MISSING_DEV_NR); 290 291 if (vs->vs_state == VDEV_STATE_CANT_OPEN && |
292 find_vdev_problem(nvroot, vdev_broken, B_TRUE)) |
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 */ |
314 if (find_vdev_problem(nvroot, vdev_faulted, B_TRUE)) |
315 return (ZPOOL_STATUS_FAULTED_DEV_R); |
316 if (find_vdev_problem(nvroot, vdev_missing, B_TRUE)) |
317 return (ZPOOL_STATUS_MISSING_DEV_R); |
318 if (find_vdev_problem(nvroot, vdev_broken, B_TRUE)) |
319 return (ZPOOL_STATUS_CORRUPT_LABEL_R); 320 321 /* 322 * Devices with errors 323 */ |
324 if (!isimport && find_vdev_problem(nvroot, vdev_errors, B_TRUE)) |
325 return (ZPOOL_STATUS_FAILING_DEV); 326 327 /* 328 * Offlined devices 329 */ |
330 if (find_vdev_problem(nvroot, vdev_offlined, B_TRUE)) |
331 return (ZPOOL_STATUS_OFFLINE_DEV); 332 333 /* 334 * Removed device 335 */ |
336 if (find_vdev_problem(nvroot, vdev_removed, B_TRUE)) |
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 /* |
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 --- |