author | Christopher Siden <chris.siden@delphix.com> |
Mon, 21 May 2012 12:11:39 -0700 | |
changeset 13700 | 2889e2596bd6 |
parent 12296 | 7cf402a7f374 |
child 13753 | 2aba784c276b |
permissions | -rw-r--r-- |
789 | 1 |
/* |
2 |
* CDDL HEADER START |
|
3 |
* |
|
4 |
* The contents of this file are subject to the terms of the |
|
1544 | 5 |
* Common Development and Distribution License (the "License"). |
6 |
* You may not use this file except in compliance with the License. |
|
789 | 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 |
*/ |
|
13700
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
12296
diff
changeset
|
21 |
|
789 | 22 |
/* |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11149
diff
changeset
|
23 |
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. |
13700
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
12296
diff
changeset
|
24 |
* Copyright (c) 2012 by Delphix. All rights reserved. |
789 | 25 |
*/ |
26 |
||
27 |
/* |
|
28 |
* This file contains the functions which analyze the status of a pool. This |
|
29 |
* include both the status of an active pool, as well as the status exported |
|
30 |
* pools. Returns one of the ZPOOL_STATUS_* defines describing the status of |
|
31 |
* the pool. This status is independent (to a certain degree) from the state of |
|
4451 | 32 |
* the pool. A pool's state describes only whether or not it is capable of |
789 | 33 |
* providing the necessary fault tolerance for data. The status describes the |
34 |
* overall status of devices. A pool that is online can still have a device |
|
35 |
* that is experiencing errors. |
|
36 |
* |
|
37 |
* Only a subset of the possible faults can be detected using 'zpool status', |
|
38 |
* and not all possible errors correspond to a FMA message ID. The explanation |
|
39 |
* is left up to the caller, depending on whether it is a live pool or an |
|
40 |
* import. |
|
41 |
*/ |
|
42 |
||
43 |
#include <libzfs.h> |
|
44 |
#include <string.h> |
|
3975
6674f5d79069
6282725 hostname/hostid should be stored in the label
ek110237
parents:
2082
diff
changeset
|
45 |
#include <unistd.h> |
789 | 46 |
#include "libzfs_impl.h" |
47 |
||
48 |
/* |
|
4451 | 49 |
* Message ID table. This must be kept in sync with the ZPOOL_STATUS_* defines |
789 | 50 |
* in libzfs.h. Note that there are some status results which go past the end |
51 |
* of this table, and hence have no associated message ID. |
|
52 |
*/ |
|
3975
6674f5d79069
6282725 hostname/hostid should be stored in the label
ek110237
parents:
2082
diff
changeset
|
53 |
static char *zfs_msgid_table[] = { |
789 | 54 |
"ZFS-8000-14", |
55 |
"ZFS-8000-2Q", |
|
56 |
"ZFS-8000-3C", |
|
57 |
"ZFS-8000-4J", |
|
58 |
"ZFS-8000-5E", |
|
59 |
"ZFS-8000-6X", |
|
60 |
"ZFS-8000-72", |
|
61 |
"ZFS-8000-8A", |
|
62 |
"ZFS-8000-9P", |
|
3975
6674f5d79069
6282725 hostname/hostid should be stored in the label
ek110237
parents:
2082
diff
changeset
|
63 |
"ZFS-8000-A5", |
6523
c1d2a7f04573
6616739 panic message ZFS: I/O failure (write on <unknown> is not very helpful
ek110237
parents:
4577
diff
changeset
|
64 |
"ZFS-8000-EY", |
c1d2a7f04573
6616739 panic message ZFS: I/O failure (write on <unknown> is not very helpful
ek110237
parents:
4577
diff
changeset
|
65 |
"ZFS-8000-HC", |
7294 | 66 |
"ZFS-8000-JQ", |
67 |
"ZFS-8000-K4", |
|
789 | 68 |
}; |
69 |
||
3975
6674f5d79069
6282725 hostname/hostid should be stored in the label
ek110237
parents:
2082
diff
changeset
|
70 |
#define NMSGID (sizeof (zfs_msgid_table) / sizeof (zfs_msgid_table[0])) |
789 | 71 |
|
72 |
/* ARGSUSED */ |
|
73 |
static int |
|
74 |
vdev_missing(uint64_t state, uint64_t aux, uint64_t errs) |
|
75 |
{ |
|
76 |
return (state == VDEV_STATE_CANT_OPEN && |
|
77 |
aux == VDEV_AUX_OPEN_FAILED); |
|
78 |
} |
|
79 |
||
80 |
/* ARGSUSED */ |
|
81 |
static int |
|
4451 | 82 |
vdev_faulted(uint64_t state, uint64_t aux, uint64_t errs) |
83 |
{ |
|
84 |
return (state == VDEV_STATE_FAULTED); |
|
85 |
} |
|
86 |
||
87 |
/* ARGSUSED */ |
|
88 |
static int |
|
789 | 89 |
vdev_errors(uint64_t state, uint64_t aux, uint64_t errs) |
90 |
{ |
|
4451 | 91 |
return (state == VDEV_STATE_DEGRADED || errs != 0); |
789 | 92 |
} |
93 |
||
94 |
/* ARGSUSED */ |
|
95 |
static int |
|
96 |
vdev_broken(uint64_t state, uint64_t aux, uint64_t errs) |
|
97 |
{ |
|
98 |
return (state == VDEV_STATE_CANT_OPEN); |
|
99 |
} |
|
100 |
||
101 |
/* ARGSUSED */ |
|
102 |
static int |
|
103 |
vdev_offlined(uint64_t state, uint64_t aux, uint64_t errs) |
|
104 |
{ |
|
105 |
return (state == VDEV_STATE_OFFLINE); |
|
106 |
} |
|
107 |
||
10151
3e86bccfd4da
6793967 zpool status -x sometimes incorrect.
George Wilson <George.Wilson@Sun.COM>
parents:
7754
diff
changeset
|
108 |
/* ARGSUSED */ |
3e86bccfd4da
6793967 zpool status -x sometimes incorrect.
George Wilson <George.Wilson@Sun.COM>
parents:
7754
diff
changeset
|
109 |
static int |
3e86bccfd4da
6793967 zpool status -x sometimes incorrect.
George Wilson <George.Wilson@Sun.COM>
parents:
7754
diff
changeset
|
110 |
vdev_removed(uint64_t state, uint64_t aux, uint64_t errs) |
3e86bccfd4da
6793967 zpool status -x sometimes incorrect.
George Wilson <George.Wilson@Sun.COM>
parents:
7754
diff
changeset
|
111 |
{ |
3e86bccfd4da
6793967 zpool status -x sometimes incorrect.
George Wilson <George.Wilson@Sun.COM>
parents:
7754
diff
changeset
|
112 |
return (state == VDEV_STATE_REMOVED); |
3e86bccfd4da
6793967 zpool status -x sometimes incorrect.
George Wilson <George.Wilson@Sun.COM>
parents:
7754
diff
changeset
|
113 |
} |
3e86bccfd4da
6793967 zpool status -x sometimes incorrect.
George Wilson <George.Wilson@Sun.COM>
parents:
7754
diff
changeset
|
114 |
|
789 | 115 |
/* |
116 |
* Detect if any leaf devices that have seen errors or could not be opened. |
|
117 |
*/ |
|
2082 | 118 |
static boolean_t |
789 | 119 |
find_vdev_problem(nvlist_t *vdev, int (*func)(uint64_t, uint64_t, uint64_t)) |
120 |
{ |
|
121 |
nvlist_t **child; |
|
122 |
vdev_stat_t *vs; |
|
123 |
uint_t c, children; |
|
124 |
char *type; |
|
125 |
||
126 |
/* |
|
127 |
* Ignore problems within a 'replacing' vdev, since we're presumably in |
|
128 |
* the process of repairing any such errors, and don't want to call them |
|
129 |
* out again. We'll pick up the fact that a resilver is happening |
|
130 |
* later. |
|
131 |
*/ |
|
132 |
verify(nvlist_lookup_string(vdev, ZPOOL_CONFIG_TYPE, &type) == 0); |
|
133 |
if (strcmp(type, VDEV_TYPE_REPLACING) == 0) |
|
2082 | 134 |
return (B_FALSE); |
789 | 135 |
|
136 |
if (nvlist_lookup_nvlist_array(vdev, ZPOOL_CONFIG_CHILDREN, &child, |
|
137 |
&children) == 0) { |
|
138 |
for (c = 0; c < children; c++) |
|
139 |
if (find_vdev_problem(child[c], func)) |
|
2082 | 140 |
return (B_TRUE); |
789 | 141 |
} else { |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11149
diff
changeset
|
142 |
verify(nvlist_lookup_uint64_array(vdev, ZPOOL_CONFIG_VDEV_STATS, |
789 | 143 |
(uint64_t **)&vs, &c) == 0); |
144 |
||
145 |
if (func(vs->vs_state, vs->vs_aux, |
|
146 |
vs->vs_read_errors + |
|
147 |
vs->vs_write_errors + |
|
148 |
vs->vs_checksum_errors)) |
|
2082 | 149 |
return (B_TRUE); |
789 | 150 |
} |
151 |
||
2082 | 152 |
return (B_FALSE); |
789 | 153 |
} |
154 |
||
155 |
/* |
|
156 |
* Active pool health status. |
|
157 |
* |
|
158 |
* To determine the status for a pool, we make several passes over the config, |
|
159 |
* picking the most egregious error we find. In order of importance, we do the |
|
160 |
* following: |
|
161 |
* |
|
162 |
* - Check for a complete and valid configuration |
|
4451 | 163 |
* - Look for any faulted or missing devices in a non-replicated config |
1544 | 164 |
* - Check for any data errors |
4451 | 165 |
* - Check for any faulted or missing devices in a replicated config |
789 | 166 |
* - Look for any devices showing errors |
167 |
* - Check for any resilvering devices |
|
168 |
* |
|
169 |
* There can obviously be multiple errors within a single pool, so this routine |
|
170 |
* only picks the most damaging of all the current errors to report. |
|
171 |
*/ |
|
172 |
static zpool_status_t |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7294
diff
changeset
|
173 |
check_status(nvlist_t *config, boolean_t isimport) |
789 | 174 |
{ |
175 |
nvlist_t *nvroot; |
|
176 |
vdev_stat_t *vs; |
|
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11149
diff
changeset
|
177 |
pool_scan_stat_t *ps = NULL; |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11149
diff
changeset
|
178 |
uint_t vsc, psc; |
1544 | 179 |
uint64_t nerr; |
1760 | 180 |
uint64_t version; |
3975
6674f5d79069
6282725 hostname/hostid should be stored in the label
ek110237
parents:
2082
diff
changeset
|
181 |
uint64_t stateval; |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7294
diff
changeset
|
182 |
uint64_t suspended; |
3975
6674f5d79069
6282725 hostname/hostid should be stored in the label
ek110237
parents:
2082
diff
changeset
|
183 |
uint64_t hostid = 0; |
789 | 184 |
|
1760 | 185 |
verify(nvlist_lookup_uint64(config, ZPOOL_CONFIG_VERSION, |
186 |
&version) == 0); |
|
789 | 187 |
verify(nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE, |
188 |
&nvroot) == 0); |
|
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11149
diff
changeset
|
189 |
verify(nvlist_lookup_uint64_array(nvroot, ZPOOL_CONFIG_VDEV_STATS, |
789 | 190 |
(uint64_t **)&vs, &vsc) == 0); |
3975
6674f5d79069
6282725 hostname/hostid should be stored in the label
ek110237
parents:
2082
diff
changeset
|
191 |
verify(nvlist_lookup_uint64(config, ZPOOL_CONFIG_POOL_STATE, |
6674f5d79069
6282725 hostname/hostid should be stored in the label
ek110237
parents:
2082
diff
changeset
|
192 |
&stateval) == 0); |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11149
diff
changeset
|
193 |
|
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11149
diff
changeset
|
194 |
/* |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11149
diff
changeset
|
195 |
* Currently resilvering a vdev |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11149
diff
changeset
|
196 |
*/ |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11149
diff
changeset
|
197 |
(void) nvlist_lookup_uint64_array(nvroot, ZPOOL_CONFIG_SCAN_STATS, |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11149
diff
changeset
|
198 |
(uint64_t **)&ps, &psc); |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11149
diff
changeset
|
199 |
if (ps && ps->pss_func == POOL_SCAN_RESILVER && |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11149
diff
changeset
|
200 |
ps->pss_state == DSS_SCANNING) |
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11149
diff
changeset
|
201 |
return (ZPOOL_STATUS_RESILVERING); |
3975
6674f5d79069
6282725 hostname/hostid should be stored in the label
ek110237
parents:
2082
diff
changeset
|
202 |
|
6674f5d79069
6282725 hostname/hostid should be stored in the label
ek110237
parents:
2082
diff
changeset
|
203 |
/* |
6674f5d79069
6282725 hostname/hostid should be stored in the label
ek110237
parents:
2082
diff
changeset
|
204 |
* Pool last accessed by another system. |
6674f5d79069
6282725 hostname/hostid should be stored in the label
ek110237
parents:
2082
diff
changeset
|
205 |
*/ |
12296
7cf402a7f374
6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents:
11149
diff
changeset
|
206 |
(void) nvlist_lookup_uint64(config, ZPOOL_CONFIG_HOSTID, &hostid); |
3975
6674f5d79069
6282725 hostname/hostid should be stored in the label
ek110237
parents:
2082
diff
changeset
|
207 |
if (hostid != 0 && (unsigned long)hostid != gethostid() && |
6674f5d79069
6282725 hostname/hostid should be stored in the label
ek110237
parents:
2082
diff
changeset
|
208 |
stateval == POOL_STATE_ACTIVE) |
6674f5d79069
6282725 hostname/hostid should be stored in the label
ek110237
parents:
2082
diff
changeset
|
209 |
return (ZPOOL_STATUS_HOSTID_MISMATCH); |
789 | 210 |
|
211 |
/* |
|
1760 | 212 |
* Newer on-disk version. |
213 |
*/ |
|
214 |
if (vs->vs_state == VDEV_STATE_CANT_OPEN && |
|
215 |
vs->vs_aux == VDEV_AUX_VERSION_NEWER) |
|
216 |
return (ZPOOL_STATUS_VERSION_NEWER); |
|
217 |
||
218 |
/* |
|
13700
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
12296
diff
changeset
|
219 |
* Unsupported feature(s). |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
12296
diff
changeset
|
220 |
*/ |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
12296
diff
changeset
|
221 |
if (vs->vs_state == VDEV_STATE_CANT_OPEN && |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
12296
diff
changeset
|
222 |
vs->vs_aux == VDEV_AUX_UNSUP_FEAT) { |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
12296
diff
changeset
|
223 |
nvlist_t *nvinfo; |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
12296
diff
changeset
|
224 |
|
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
12296
diff
changeset
|
225 |
verify(nvlist_lookup_nvlist(config, ZPOOL_CONFIG_LOAD_INFO, |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
12296
diff
changeset
|
226 |
&nvinfo) == 0); |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
12296
diff
changeset
|
227 |
if (nvlist_exists(nvinfo, ZPOOL_CONFIG_CAN_RDONLY)) |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
12296
diff
changeset
|
228 |
return (ZPOOL_STATUS_UNSUP_FEAT_WRITE); |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
12296
diff
changeset
|
229 |
return (ZPOOL_STATUS_UNSUP_FEAT_READ); |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
12296
diff
changeset
|
230 |
} |
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
12296
diff
changeset
|
231 |
|
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
12296
diff
changeset
|
232 |
/* |
789 | 233 |
* Check that the config is complete. |
234 |
*/ |
|
235 |
if (vs->vs_state == VDEV_STATE_CANT_OPEN && |
|
1544 | 236 |
vs->vs_aux == VDEV_AUX_BAD_GUID_SUM) |
789 | 237 |
return (ZPOOL_STATUS_BAD_GUID_SUM); |
1544 | 238 |
|
239 |
/* |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7294
diff
changeset
|
240 |
* Check whether the pool has suspended due to failed I/O. |
6523
c1d2a7f04573
6616739 panic message ZFS: I/O failure (write on <unknown> is not very helpful
ek110237
parents:
4577
diff
changeset
|
241 |
*/ |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7294
diff
changeset
|
242 |
if (nvlist_lookup_uint64(config, ZPOOL_CONFIG_SUSPENDED, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7294
diff
changeset
|
243 |
&suspended) == 0) { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7294
diff
changeset
|
244 |
if (suspended == ZIO_FAILURE_MODE_CONTINUE) |
6523
c1d2a7f04573
6616739 panic message ZFS: I/O failure (write on <unknown> is not very helpful
ek110237
parents:
4577
diff
changeset
|
245 |
return (ZPOOL_STATUS_IO_FAILURE_CONTINUE); |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7294
diff
changeset
|
246 |
return (ZPOOL_STATUS_IO_FAILURE_WAIT); |
6523
c1d2a7f04573
6616739 panic message ZFS: I/O failure (write on <unknown> is not very helpful
ek110237
parents:
4577
diff
changeset
|
247 |
} |
c1d2a7f04573
6616739 panic message ZFS: I/O failure (write on <unknown> is not very helpful
ek110237
parents:
4577
diff
changeset
|
248 |
|
c1d2a7f04573
6616739 panic message ZFS: I/O failure (write on <unknown> is not very helpful
ek110237
parents:
4577
diff
changeset
|
249 |
/* |
7294 | 250 |
* Could not read a log. |
251 |
*/ |
|
252 |
if (vs->vs_state == VDEV_STATE_CANT_OPEN && |
|
253 |
vs->vs_aux == VDEV_AUX_BAD_LOG) { |
|
254 |
return (ZPOOL_STATUS_BAD_LOG); |
|
255 |
} |
|
256 |
||
257 |
/* |
|
4451 | 258 |
* Bad devices in non-replicated config. |
1544 | 259 |
*/ |
260 |
if (vs->vs_state == VDEV_STATE_CANT_OPEN && |
|
4451 | 261 |
find_vdev_problem(nvroot, vdev_faulted)) |
262 |
return (ZPOOL_STATUS_FAULTED_DEV_NR); |
|
263 |
||
264 |
if (vs->vs_state == VDEV_STATE_CANT_OPEN && |
|
1544 | 265 |
find_vdev_problem(nvroot, vdev_missing)) |
266 |
return (ZPOOL_STATUS_MISSING_DEV_NR); |
|
267 |
||
268 |
if (vs->vs_state == VDEV_STATE_CANT_OPEN && |
|
269 |
find_vdev_problem(nvroot, vdev_broken)) |
|
270 |
return (ZPOOL_STATUS_CORRUPT_LABEL_NR); |
|
271 |
||
272 |
/* |
|
273 |
* Corrupted pool metadata |
|
274 |
*/ |
|
275 |
if (vs->vs_state == VDEV_STATE_CANT_OPEN && |
|
276 |
vs->vs_aux == VDEV_AUX_CORRUPT_DATA) |
|
277 |
return (ZPOOL_STATUS_CORRUPT_POOL); |
|
278 |
||
279 |
/* |
|
280 |
* Persistent data errors. |
|
281 |
*/ |
|
282 |
if (!isimport) { |
|
283 |
if (nvlist_lookup_uint64(config, ZPOOL_CONFIG_ERRCOUNT, |
|
284 |
&nerr) == 0 && nerr != 0) |
|
285 |
return (ZPOOL_STATUS_CORRUPT_DATA); |
|
789 | 286 |
} |
287 |
||
288 |
/* |
|
1544 | 289 |
* Missing devices in a replicated config. |
789 | 290 |
*/ |
4451 | 291 |
if (find_vdev_problem(nvroot, vdev_faulted)) |
292 |
return (ZPOOL_STATUS_FAULTED_DEV_R); |
|
1544 | 293 |
if (find_vdev_problem(nvroot, vdev_missing)) |
294 |
return (ZPOOL_STATUS_MISSING_DEV_R); |
|
295 |
if (find_vdev_problem(nvroot, vdev_broken)) |
|
296 |
return (ZPOOL_STATUS_CORRUPT_LABEL_R); |
|
789 | 297 |
|
298 |
/* |
|
299 |
* Devices with errors |
|
300 |
*/ |
|
301 |
if (!isimport && find_vdev_problem(nvroot, vdev_errors)) |
|
302 |
return (ZPOOL_STATUS_FAILING_DEV); |
|
303 |
||
304 |
/* |
|
305 |
* Offlined devices |
|
306 |
*/ |
|
307 |
if (find_vdev_problem(nvroot, vdev_offlined)) |
|
308 |
return (ZPOOL_STATUS_OFFLINE_DEV); |
|
309 |
||
310 |
/* |
|
10151
3e86bccfd4da
6793967 zpool status -x sometimes incorrect.
George Wilson <George.Wilson@Sun.COM>
parents:
7754
diff
changeset
|
311 |
* Removed device |
3e86bccfd4da
6793967 zpool status -x sometimes incorrect.
George Wilson <George.Wilson@Sun.COM>
parents:
7754
diff
changeset
|
312 |
*/ |
3e86bccfd4da
6793967 zpool status -x sometimes incorrect.
George Wilson <George.Wilson@Sun.COM>
parents:
7754
diff
changeset
|
313 |
if (find_vdev_problem(nvroot, vdev_removed)) |
3e86bccfd4da
6793967 zpool status -x sometimes incorrect.
George Wilson <George.Wilson@Sun.COM>
parents:
7754
diff
changeset
|
314 |
return (ZPOOL_STATUS_REMOVED_DEV); |
3e86bccfd4da
6793967 zpool status -x sometimes incorrect.
George Wilson <George.Wilson@Sun.COM>
parents:
7754
diff
changeset
|
315 |
|
3e86bccfd4da
6793967 zpool status -x sometimes incorrect.
George Wilson <George.Wilson@Sun.COM>
parents:
7754
diff
changeset
|
316 |
/* |
1760 | 317 |
* Outdated, but usable, version |
789 | 318 |
*/ |
13700
2889e2596bd6
2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents:
12296
diff
changeset
|
319 |
if (SPA_VERSION_IS_SUPPORTED(version) && version != SPA_VERSION) |
1760 | 320 |
return (ZPOOL_STATUS_VERSION_OLDER); |
789 | 321 |
|
322 |
return (ZPOOL_STATUS_OK); |
|
323 |
} |
|
324 |
||
325 |
zpool_status_t |
|
326 |
zpool_get_status(zpool_handle_t *zhp, char **msgid) |
|
327 |
{ |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7294
diff
changeset
|
328 |
zpool_status_t ret = check_status(zhp->zpool_config, B_FALSE); |
789 | 329 |
|
330 |
if (ret >= NMSGID) |
|
331 |
*msgid = NULL; |
|
332 |
else |
|
4451 | 333 |
*msgid = zfs_msgid_table[ret]; |
789 | 334 |
|
335 |
return (ret); |
|
336 |
} |
|
337 |
||
338 |
zpool_status_t |
|
339 |
zpool_import_status(nvlist_t *config, char **msgid) |
|
340 |
{ |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7294
diff
changeset
|
341 |
zpool_status_t ret = check_status(config, B_TRUE); |
789 | 342 |
|
343 |
if (ret >= NMSGID) |
|
344 |
*msgid = NULL; |
|
345 |
else |
|
3975
6674f5d79069
6282725 hostname/hostid should be stored in the label
ek110237
parents:
2082
diff
changeset
|
346 |
*msgid = zfs_msgid_table[ret]; |
789 | 347 |
|
348 |
return (ret); |
|
349 |
} |
|
11149
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
350 |
|
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
351 |
static void |
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
352 |
dump_ddt_stat(const ddt_stat_t *dds, int h) |
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
353 |
{ |
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
354 |
char refcnt[6]; |
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
355 |
char blocks[6], lsize[6], psize[6], dsize[6]; |
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
356 |
char ref_blocks[6], ref_lsize[6], ref_psize[6], ref_dsize[6]; |
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
357 |
|
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
358 |
if (dds == NULL || dds->dds_blocks == 0) |
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
359 |
return; |
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
360 |
|
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
361 |
if (h == -1) |
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
362 |
(void) strcpy(refcnt, "Total"); |
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
363 |
else |
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
364 |
zfs_nicenum(1ULL << h, refcnt, sizeof (refcnt)); |
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
365 |
|
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
366 |
zfs_nicenum(dds->dds_blocks, blocks, sizeof (blocks)); |
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
367 |
zfs_nicenum(dds->dds_lsize, lsize, sizeof (lsize)); |
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
368 |
zfs_nicenum(dds->dds_psize, psize, sizeof (psize)); |
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
369 |
zfs_nicenum(dds->dds_dsize, dsize, sizeof (dsize)); |
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
370 |
zfs_nicenum(dds->dds_ref_blocks, ref_blocks, sizeof (ref_blocks)); |
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
371 |
zfs_nicenum(dds->dds_ref_lsize, ref_lsize, sizeof (ref_lsize)); |
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
372 |
zfs_nicenum(dds->dds_ref_psize, ref_psize, sizeof (ref_psize)); |
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
373 |
zfs_nicenum(dds->dds_ref_dsize, ref_dsize, sizeof (ref_dsize)); |
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
374 |
|
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
375 |
(void) printf("%6s %6s %5s %5s %5s %6s %5s %5s %5s\n", |
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
376 |
refcnt, |
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
377 |
blocks, lsize, psize, dsize, |
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
378 |
ref_blocks, ref_lsize, ref_psize, ref_dsize); |
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
379 |
} |
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
380 |
|
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
381 |
/* |
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
382 |
* Print the DDT histogram and the column totals. |
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
383 |
*/ |
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
384 |
void |
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
385 |
zpool_dump_ddt(const ddt_stat_t *dds_total, const ddt_histogram_t *ddh) |
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
386 |
{ |
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
387 |
int h; |
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
388 |
|
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
389 |
(void) printf("\n"); |
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
390 |
|
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
391 |
(void) printf("bucket " |
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
392 |
" allocated " |
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
393 |
" referenced \n"); |
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
394 |
(void) printf("______ " |
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
395 |
"______________________________ " |
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
396 |
"______________________________\n"); |
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
397 |
|
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
398 |
(void) printf("%6s %6s %5s %5s %5s %6s %5s %5s %5s\n", |
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
399 |
"refcnt", |
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
400 |
"blocks", "LSIZE", "PSIZE", "DSIZE", |
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
401 |
"blocks", "LSIZE", "PSIZE", "DSIZE"); |
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
402 |
|
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
403 |
(void) printf("%6s %6s %5s %5s %5s %6s %5s %5s %5s\n", |
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
404 |
"------", |
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
405 |
"------", "-----", "-----", "-----", |
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
406 |
"------", "-----", "-----", "-----"); |
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
407 |
|
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
408 |
for (h = 0; h < 64; h++) |
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
409 |
dump_ddt_stat(&ddh->ddh_stat[h], h); |
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
410 |
|
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
411 |
dump_ddt_stat(dds_total, -1); |
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
412 |
|
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
413 |
(void) printf("\n"); |
8bad7424e2c2
6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents:
10151
diff
changeset
|
414 |
} |