author | Victor Latushkin <Victor.Latushkin@Sun.COM> |
Fri, 14 Nov 2008 15:07:41 -0800 | |
changeset 8121 | 7fd09d4ebd9c |
parent 7837 | 001de5627df3 |
child 8188 | fd00c0a81e80 |
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 |
*/ |
|
21 |
/* |
|
5959
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
22 |
* Copyright 2008 Sun Microsystems, Inc. All rights reserved. |
789 | 23 |
* Use is subject to license terms. |
24 |
*/ |
|
25 |
||
26 |
#include <stdio.h> |
|
1914
8a8c5f225b1b
4916205 libcmd should not use file operation routines from C library
casper
parents:
1807
diff
changeset
|
27 |
#include <stdio_ext.h> |
789 | 28 |
#include <stdlib.h> |
1775
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
29 |
#include <ctype.h> |
789 | 30 |
#include <sys/zfs_context.h> |
31 |
#include <sys/spa.h> |
|
32 |
#include <sys/spa_impl.h> |
|
33 |
#include <sys/dmu.h> |
|
34 |
#include <sys/zap.h> |
|
35 |
#include <sys/fs/zfs.h> |
|
36 |
#include <sys/zfs_znode.h> |
|
37 |
#include <sys/vdev.h> |
|
38 |
#include <sys/vdev_impl.h> |
|
39 |
#include <sys/metaslab_impl.h> |
|
40 |
#include <sys/dmu_objset.h> |
|
41 |
#include <sys/dsl_dir.h> |
|
42 |
#include <sys/dsl_dataset.h> |
|
43 |
#include <sys/dsl_pool.h> |
|
44 |
#include <sys/dbuf.h> |
|
45 |
#include <sys/zil.h> |
|
46 |
#include <sys/zil_impl.h> |
|
47 |
#include <sys/stat.h> |
|
48 |
#include <sys/resource.h> |
|
49 |
#include <sys/dmu_traverse.h> |
|
50 |
#include <sys/zio_checksum.h> |
|
51 |
#include <sys/zio_compress.h> |
|
5959
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
52 |
#include <sys/zfs_fuid.h> |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
53 |
#include <sys/arc.h> |
4627
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
54 |
#undef ZFS_MAXNAMELEN |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
55 |
#undef verify |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
56 |
#include <libzfs.h> |
789 | 57 |
|
58 |
const char cmdname[] = "zdb"; |
|
59 |
uint8_t dump_opt[256]; |
|
60 |
||
61 |
typedef void object_viewer_t(objset_t *, uint64_t, void *data, size_t size); |
|
62 |
||
63 |
extern void dump_intent_log(zilog_t *); |
|
64 |
uint64_t *zopt_object = NULL; |
|
65 |
int zopt_objects = 0; |
|
4627
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
66 |
libzfs_handle_t *g_zfs; |
6217
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
67 |
boolean_t zdb_sig_user_data = B_TRUE; |
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
68 |
int zdb_sig_cksumalg = ZIO_CHECKSUM_SHA256; |
789 | 69 |
|
70 |
/* |
|
71 |
* These libumem hooks provide a reasonable set of defaults for the allocator's |
|
72 |
* debugging facilities. |
|
73 |
*/ |
|
74 |
const char * |
|
75 |
_umem_debug_init() |
|
76 |
{ |
|
77 |
return ("default,verbose"); /* $UMEM_DEBUG setting */ |
|
78 |
} |
|
79 |
||
80 |
const char * |
|
81 |
_umem_logging_init(void) |
|
82 |
{ |
|
83 |
return ("fail,contents"); /* $UMEM_LOGGING setting */ |
|
84 |
} |
|
85 |
||
86 |
static void |
|
87 |
usage(void) |
|
88 |
{ |
|
89 |
(void) fprintf(stderr, |
|
8121
7fd09d4ebd9c
6757430 want an option for zdb to disable space map loading and leak tracking
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
7837
diff
changeset
|
90 |
"Usage: %s [-udibcsvL] [-U cachefile_path] " |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
91 |
"[-S user:cksumalg] " |
789 | 92 |
"dataset [object...]\n" |
93 |
" %s -C [pool]\n" |
|
1775
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
94 |
" %s -l dev\n" |
6423 | 95 |
" %s -R pool:vdev:offset:size:flags\n" |
5994
bedab011a2e5
6580270 'zdb [-C|-L] <pool'> can't open alternate root pools
ck153898
parents:
5959
diff
changeset
|
96 |
" %s [-p path_to_vdev_dir]\n" |
bedab011a2e5
6580270 'zdb [-C|-L] <pool'> can't open alternate root pools
ck153898
parents:
5959
diff
changeset
|
97 |
" %s -e pool | GUID | devid ...\n", |
bedab011a2e5
6580270 'zdb [-C|-L] <pool'> can't open alternate root pools
ck153898
parents:
5959
diff
changeset
|
98 |
cmdname, cmdname, cmdname, cmdname, cmdname, cmdname); |
789 | 99 |
|
100 |
(void) fprintf(stderr, " -u uberblock\n"); |
|
101 |
(void) fprintf(stderr, " -d datasets\n"); |
|
102 |
(void) fprintf(stderr, " -C cached pool configuration\n"); |
|
103 |
(void) fprintf(stderr, " -i intent logs\n"); |
|
104 |
(void) fprintf(stderr, " -b block statistics\n"); |
|
105 |
(void) fprintf(stderr, " -c checksum all data blocks\n"); |
|
106 |
(void) fprintf(stderr, " -s report stats on zdb's I/O\n"); |
|
6217
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
107 |
(void) fprintf(stderr, " -S <user|all>:<cksum_alg|all> -- " |
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
108 |
"dump blkptr signatures\n"); |
789 | 109 |
(void) fprintf(stderr, " -v verbose (applies to all others)\n"); |
110 |
(void) fprintf(stderr, " -l dump label contents\n"); |
|
8121
7fd09d4ebd9c
6757430 want an option for zdb to disable space map loading and leak tracking
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
7837
diff
changeset
|
111 |
(void) fprintf(stderr, " -L disable leak tracking (do not " |
7fd09d4ebd9c
6757430 want an option for zdb to disable space map loading and leak tracking
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
7837
diff
changeset
|
112 |
"load spacemaps)\n"); |
5994
bedab011a2e5
6580270 'zdb [-C|-L] <pool'> can't open alternate root pools
ck153898
parents:
5959
diff
changeset
|
113 |
(void) fprintf(stderr, " -U cachefile_path -- use alternate " |
bedab011a2e5
6580270 'zdb [-C|-L] <pool'> can't open alternate root pools
ck153898
parents:
5959
diff
changeset
|
114 |
"cachefile\n"); |
6217
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
115 |
(void) fprintf(stderr, " -R read and display block from a " |
1775
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
116 |
"device\n"); |
5994
bedab011a2e5
6580270 'zdb [-C|-L] <pool'> can't open alternate root pools
ck153898
parents:
5959
diff
changeset
|
117 |
(void) fprintf(stderr, " -e Pool is exported/destroyed/" |
bedab011a2e5
6580270 'zdb [-C|-L] <pool'> can't open alternate root pools
ck153898
parents:
5959
diff
changeset
|
118 |
"has altroot\n"); |
4627
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
119 |
(void) fprintf(stderr, " -p <Path to vdev dir> (use with -e)\n"); |
789 | 120 |
(void) fprintf(stderr, "Specify an option more than once (e.g. -bb) " |
121 |
"to make only that option verbose\n"); |
|
122 |
(void) fprintf(stderr, "Default is to dump everything non-verbosely\n"); |
|
123 |
exit(1); |
|
124 |
} |
|
125 |
||
126 |
static void |
|
127 |
fatal(const char *fmt, ...) |
|
128 |
{ |
|
129 |
va_list ap; |
|
130 |
||
131 |
va_start(ap, fmt); |
|
132 |
(void) fprintf(stderr, "%s: ", cmdname); |
|
133 |
(void) vfprintf(stderr, fmt, ap); |
|
134 |
va_end(ap); |
|
135 |
(void) fprintf(stderr, "\n"); |
|
136 |
||
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
137 |
abort(); |
789 | 138 |
} |
139 |
||
140 |
static void |
|
141 |
dump_nvlist(nvlist_t *list, int indent) |
|
142 |
{ |
|
143 |
nvpair_t *elem = NULL; |
|
144 |
||
145 |
while ((elem = nvlist_next_nvpair(list, elem)) != NULL) { |
|
146 |
switch (nvpair_type(elem)) { |
|
147 |
case DATA_TYPE_STRING: |
|
148 |
{ |
|
149 |
char *value; |
|
150 |
||
151 |
VERIFY(nvpair_value_string(elem, &value) == 0); |
|
152 |
(void) printf("%*s%s='%s'\n", indent, "", |
|
153 |
nvpair_name(elem), value); |
|
154 |
} |
|
155 |
break; |
|
156 |
||
157 |
case DATA_TYPE_UINT64: |
|
158 |
{ |
|
159 |
uint64_t value; |
|
160 |
||
161 |
VERIFY(nvpair_value_uint64(elem, &value) == 0); |
|
162 |
(void) printf("%*s%s=%llu\n", indent, "", |
|
163 |
nvpair_name(elem), (u_longlong_t)value); |
|
164 |
} |
|
165 |
break; |
|
166 |
||
167 |
case DATA_TYPE_NVLIST: |
|
168 |
{ |
|
169 |
nvlist_t *value; |
|
170 |
||
171 |
VERIFY(nvpair_value_nvlist(elem, &value) == 0); |
|
172 |
(void) printf("%*s%s\n", indent, "", |
|
173 |
nvpair_name(elem)); |
|
174 |
dump_nvlist(value, indent + 4); |
|
175 |
} |
|
176 |
break; |
|
177 |
||
178 |
case DATA_TYPE_NVLIST_ARRAY: |
|
179 |
{ |
|
180 |
nvlist_t **value; |
|
181 |
uint_t c, count; |
|
182 |
||
183 |
VERIFY(nvpair_value_nvlist_array(elem, &value, |
|
184 |
&count) == 0); |
|
185 |
||
186 |
for (c = 0; c < count; c++) { |
|
187 |
(void) printf("%*s%s[%u]\n", indent, "", |
|
188 |
nvpair_name(elem), c); |
|
189 |
dump_nvlist(value[c], indent + 8); |
|
190 |
} |
|
191 |
} |
|
192 |
break; |
|
193 |
||
194 |
default: |
|
195 |
||
196 |
(void) printf("bad config type %d for %s\n", |
|
197 |
nvpair_type(elem), nvpair_name(elem)); |
|
198 |
} |
|
199 |
} |
|
200 |
} |
|
201 |
||
202 |
/* ARGSUSED */ |
|
203 |
static void |
|
204 |
dump_packed_nvlist(objset_t *os, uint64_t object, void *data, size_t size) |
|
205 |
{ |
|
206 |
nvlist_t *nv; |
|
207 |
size_t nvsize = *(uint64_t *)data; |
|
208 |
char *packed = umem_alloc(nvsize, UMEM_NOFAIL); |
|
209 |
||
1544 | 210 |
VERIFY(0 == dmu_read(os, object, 0, nvsize, packed)); |
789 | 211 |
|
212 |
VERIFY(nvlist_unpack(packed, nvsize, &nv, 0) == 0); |
|
213 |
||
214 |
umem_free(packed, nvsize); |
|
215 |
||
216 |
dump_nvlist(nv, 8); |
|
217 |
||
218 |
nvlist_free(nv); |
|
219 |
} |
|
220 |
||
221 |
const char dump_zap_stars[] = "****************************************"; |
|
222 |
const int dump_zap_width = sizeof (dump_zap_stars) - 1; |
|
223 |
||
224 |
static void |
|
225 |
dump_zap_histogram(uint64_t histo[ZAP_HISTOGRAM_SIZE]) |
|
226 |
{ |
|
227 |
int i; |
|
228 |
int minidx = ZAP_HISTOGRAM_SIZE - 1; |
|
229 |
int maxidx = 0; |
|
230 |
uint64_t max = 0; |
|
231 |
||
232 |
for (i = 0; i < ZAP_HISTOGRAM_SIZE; i++) { |
|
233 |
if (histo[i] > max) |
|
234 |
max = histo[i]; |
|
235 |
if (histo[i] > 0 && i > maxidx) |
|
236 |
maxidx = i; |
|
237 |
if (histo[i] > 0 && i < minidx) |
|
238 |
minidx = i; |
|
239 |
} |
|
240 |
||
241 |
if (max < dump_zap_width) |
|
242 |
max = dump_zap_width; |
|
243 |
||
244 |
for (i = minidx; i <= maxidx; i++) |
|
245 |
(void) printf("\t\t\t%u: %6llu %s\n", i, (u_longlong_t)histo[i], |
|
246 |
&dump_zap_stars[(max - histo[i]) * dump_zap_width / max]); |
|
247 |
} |
|
248 |
||
249 |
static void |
|
250 |
dump_zap_stats(objset_t *os, uint64_t object) |
|
251 |
{ |
|
252 |
int error; |
|
253 |
zap_stats_t zs; |
|
254 |
||
255 |
error = zap_get_stats(os, object, &zs); |
|
256 |
if (error) |
|
257 |
return; |
|
258 |
||
259 |
if (zs.zs_ptrtbl_len == 0) { |
|
260 |
ASSERT(zs.zs_num_blocks == 1); |
|
261 |
(void) printf("\tmicrozap: %llu bytes, %llu entries\n", |
|
262 |
(u_longlong_t)zs.zs_blocksize, |
|
263 |
(u_longlong_t)zs.zs_num_entries); |
|
264 |
return; |
|
265 |
} |
|
266 |
||
267 |
(void) printf("\tFat ZAP stats:\n"); |
|
1632
7d486ebd46b7
6392291 zdb needs to tell the entire goodness of the fat zap
nd150628
parents:
1578
diff
changeset
|
268 |
|
7d486ebd46b7
6392291 zdb needs to tell the entire goodness of the fat zap
nd150628
parents:
1578
diff
changeset
|
269 |
(void) printf("\t\tPointer table:\n"); |
7d486ebd46b7
6392291 zdb needs to tell the entire goodness of the fat zap
nd150628
parents:
1578
diff
changeset
|
270 |
(void) printf("\t\t\t%llu elements\n", |
789 | 271 |
(u_longlong_t)zs.zs_ptrtbl_len); |
1632
7d486ebd46b7
6392291 zdb needs to tell the entire goodness of the fat zap
nd150628
parents:
1578
diff
changeset
|
272 |
(void) printf("\t\t\tzt_blk: %llu\n", |
7d486ebd46b7
6392291 zdb needs to tell the entire goodness of the fat zap
nd150628
parents:
1578
diff
changeset
|
273 |
(u_longlong_t)zs.zs_ptrtbl_zt_blk); |
7d486ebd46b7
6392291 zdb needs to tell the entire goodness of the fat zap
nd150628
parents:
1578
diff
changeset
|
274 |
(void) printf("\t\t\tzt_numblks: %llu\n", |
7d486ebd46b7
6392291 zdb needs to tell the entire goodness of the fat zap
nd150628
parents:
1578
diff
changeset
|
275 |
(u_longlong_t)zs.zs_ptrtbl_zt_numblks); |
7d486ebd46b7
6392291 zdb needs to tell the entire goodness of the fat zap
nd150628
parents:
1578
diff
changeset
|
276 |
(void) printf("\t\t\tzt_shift: %llu\n", |
7d486ebd46b7
6392291 zdb needs to tell the entire goodness of the fat zap
nd150628
parents:
1578
diff
changeset
|
277 |
(u_longlong_t)zs.zs_ptrtbl_zt_shift); |
7d486ebd46b7
6392291 zdb needs to tell the entire goodness of the fat zap
nd150628
parents:
1578
diff
changeset
|
278 |
(void) printf("\t\t\tzt_blks_copied: %llu\n", |
7d486ebd46b7
6392291 zdb needs to tell the entire goodness of the fat zap
nd150628
parents:
1578
diff
changeset
|
279 |
(u_longlong_t)zs.zs_ptrtbl_blks_copied); |
7d486ebd46b7
6392291 zdb needs to tell the entire goodness of the fat zap
nd150628
parents:
1578
diff
changeset
|
280 |
(void) printf("\t\t\tzt_nextblk: %llu\n", |
7d486ebd46b7
6392291 zdb needs to tell the entire goodness of the fat zap
nd150628
parents:
1578
diff
changeset
|
281 |
(u_longlong_t)zs.zs_ptrtbl_nextblk); |
7d486ebd46b7
6392291 zdb needs to tell the entire goodness of the fat zap
nd150628
parents:
1578
diff
changeset
|
282 |
|
789 | 283 |
(void) printf("\t\tZAP entries: %llu\n", |
284 |
(u_longlong_t)zs.zs_num_entries); |
|
285 |
(void) printf("\t\tLeaf blocks: %llu\n", |
|
286 |
(u_longlong_t)zs.zs_num_leafs); |
|
287 |
(void) printf("\t\tTotal blocks: %llu\n", |
|
288 |
(u_longlong_t)zs.zs_num_blocks); |
|
1632
7d486ebd46b7
6392291 zdb needs to tell the entire goodness of the fat zap
nd150628
parents:
1578
diff
changeset
|
289 |
(void) printf("\t\tzap_block_type: 0x%llx\n", |
7d486ebd46b7
6392291 zdb needs to tell the entire goodness of the fat zap
nd150628
parents:
1578
diff
changeset
|
290 |
(u_longlong_t)zs.zs_block_type); |
7d486ebd46b7
6392291 zdb needs to tell the entire goodness of the fat zap
nd150628
parents:
1578
diff
changeset
|
291 |
(void) printf("\t\tzap_magic: 0x%llx\n", |
7d486ebd46b7
6392291 zdb needs to tell the entire goodness of the fat zap
nd150628
parents:
1578
diff
changeset
|
292 |
(u_longlong_t)zs.zs_magic); |
7d486ebd46b7
6392291 zdb needs to tell the entire goodness of the fat zap
nd150628
parents:
1578
diff
changeset
|
293 |
(void) printf("\t\tzap_salt: 0x%llx\n", |
7d486ebd46b7
6392291 zdb needs to tell the entire goodness of the fat zap
nd150628
parents:
1578
diff
changeset
|
294 |
(u_longlong_t)zs.zs_salt); |
789 | 295 |
|
296 |
(void) printf("\t\tLeafs with 2^n pointers:\n"); |
|
297 |
dump_zap_histogram(zs.zs_leafs_with_2n_pointers); |
|
298 |
||
299 |
(void) printf("\t\tBlocks with n*5 entries:\n"); |
|
300 |
dump_zap_histogram(zs.zs_blocks_with_n5_entries); |
|
301 |
||
302 |
(void) printf("\t\tBlocks n/10 full:\n"); |
|
303 |
dump_zap_histogram(zs.zs_blocks_n_tenths_full); |
|
304 |
||
305 |
(void) printf("\t\tEntries with n chunks:\n"); |
|
306 |
dump_zap_histogram(zs.zs_entries_using_n_chunks); |
|
307 |
||
308 |
(void) printf("\t\tBuckets with n entries:\n"); |
|
309 |
dump_zap_histogram(zs.zs_buckets_with_n_entries); |
|
310 |
} |
|
311 |
||
312 |
/*ARGSUSED*/ |
|
313 |
static void |
|
314 |
dump_none(objset_t *os, uint64_t object, void *data, size_t size) |
|
315 |
{ |
|
316 |
} |
|
317 |
||
318 |
/*ARGSUSED*/ |
|
319 |
void |
|
320 |
dump_uint8(objset_t *os, uint64_t object, void *data, size_t size) |
|
321 |
{ |
|
322 |
} |
|
323 |
||
324 |
/*ARGSUSED*/ |
|
325 |
static void |
|
326 |
dump_uint64(objset_t *os, uint64_t object, void *data, size_t size) |
|
327 |
{ |
|
328 |
} |
|
329 |
||
330 |
/*ARGSUSED*/ |
|
331 |
static void |
|
332 |
dump_zap(objset_t *os, uint64_t object, void *data, size_t size) |
|
333 |
{ |
|
334 |
zap_cursor_t zc; |
|
335 |
zap_attribute_t attr; |
|
336 |
void *prop; |
|
337 |
int i; |
|
338 |
||
339 |
dump_zap_stats(os, object); |
|
340 |
(void) printf("\n"); |
|
341 |
||
342 |
for (zap_cursor_init(&zc, os, object); |
|
343 |
zap_cursor_retrieve(&zc, &attr) == 0; |
|
344 |
zap_cursor_advance(&zc)) { |
|
345 |
(void) printf("\t\t%s = ", attr.za_name); |
|
346 |
if (attr.za_num_integers == 0) { |
|
347 |
(void) printf("\n"); |
|
348 |
continue; |
|
349 |
} |
|
350 |
prop = umem_zalloc(attr.za_num_integers * |
|
351 |
attr.za_integer_length, UMEM_NOFAIL); |
|
352 |
(void) zap_lookup(os, object, attr.za_name, |
|
353 |
attr.za_integer_length, attr.za_num_integers, prop); |
|
354 |
if (attr.za_integer_length == 1) { |
|
355 |
(void) printf("%s", (char *)prop); |
|
356 |
} else { |
|
357 |
for (i = 0; i < attr.za_num_integers; i++) { |
|
358 |
switch (attr.za_integer_length) { |
|
359 |
case 2: |
|
360 |
(void) printf("%u ", |
|
361 |
((uint16_t *)prop)[i]); |
|
362 |
break; |
|
363 |
case 4: |
|
364 |
(void) printf("%u ", |
|
365 |
((uint32_t *)prop)[i]); |
|
366 |
break; |
|
367 |
case 8: |
|
368 |
(void) printf("%lld ", |
|
369 |
(u_longlong_t)((int64_t *)prop)[i]); |
|
370 |
break; |
|
371 |
} |
|
372 |
} |
|
373 |
} |
|
374 |
(void) printf("\n"); |
|
375 |
umem_free(prop, attr.za_num_integers * attr.za_integer_length); |
|
376 |
} |
|
885
d925b21dba78
6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents:
789
diff
changeset
|
377 |
zap_cursor_fini(&zc); |
789 | 378 |
} |
379 |
||
4577 | 380 |
/*ARGSUSED*/ |
381 |
static void |
|
382 |
dump_zpldir(objset_t *os, uint64_t object, void *data, size_t size) |
|
383 |
{ |
|
384 |
zap_cursor_t zc; |
|
385 |
zap_attribute_t attr; |
|
386 |
const char *typenames[] = { |
|
387 |
/* 0 */ "not specified", |
|
388 |
/* 1 */ "FIFO", |
|
389 |
/* 2 */ "Character Device", |
|
390 |
/* 3 */ "3 (invalid)", |
|
391 |
/* 4 */ "Directory", |
|
392 |
/* 5 */ "5 (invalid)", |
|
393 |
/* 6 */ "Block Device", |
|
394 |
/* 7 */ "7 (invalid)", |
|
395 |
/* 8 */ "Regular File", |
|
396 |
/* 9 */ "9 (invalid)", |
|
397 |
/* 10 */ "Symbolic Link", |
|
398 |
/* 11 */ "11 (invalid)", |
|
399 |
/* 12 */ "Socket", |
|
400 |
/* 13 */ "Door", |
|
401 |
/* 14 */ "Event Port", |
|
402 |
/* 15 */ "15 (invalid)", |
|
403 |
}; |
|
404 |
||
405 |
dump_zap_stats(os, object); |
|
406 |
(void) printf("\n"); |
|
407 |
||
408 |
for (zap_cursor_init(&zc, os, object); |
|
409 |
zap_cursor_retrieve(&zc, &attr) == 0; |
|
410 |
zap_cursor_advance(&zc)) { |
|
411 |
(void) printf("\t\t%s = %lld (type: %s)\n", |
|
412 |
attr.za_name, ZFS_DIRENT_OBJ(attr.za_first_integer), |
|
413 |
typenames[ZFS_DIRENT_TYPE(attr.za_first_integer)]); |
|
414 |
} |
|
415 |
zap_cursor_fini(&zc); |
|
416 |
} |
|
417 |
||
789 | 418 |
static void |
419 |
dump_spacemap(objset_t *os, space_map_obj_t *smo, space_map_t *sm) |
|
420 |
{ |
|
421 |
uint64_t alloc, offset, entry; |
|
1732 | 422 |
uint8_t mapshift = sm->sm_shift; |
789 | 423 |
uint64_t mapstart = sm->sm_start; |
3361
a3d194896a76
6480230 ::walk spa|::walk zms_freelist cause mdb to core dump
ck153898
parents:
3060
diff
changeset
|
424 |
char *ddata[] = { "ALLOC", "FREE", "CONDENSE", "INVALID", |
a3d194896a76
6480230 ::walk spa|::walk zms_freelist cause mdb to core dump
ck153898
parents:
3060
diff
changeset
|
425 |
"INVALID", "INVALID", "INVALID", "INVALID" }; |
789 | 426 |
|
427 |
if (smo->smo_object == 0) |
|
428 |
return; |
|
429 |
||
430 |
/* |
|
431 |
* Print out the freelist entries in both encoded and decoded form. |
|
432 |
*/ |
|
433 |
alloc = 0; |
|
434 |
for (offset = 0; offset < smo->smo_objsize; offset += sizeof (entry)) { |
|
1544 | 435 |
VERIFY(0 == dmu_read(os, smo->smo_object, offset, |
436 |
sizeof (entry), &entry)); |
|
789 | 437 |
if (SM_DEBUG_DECODE(entry)) { |
438 |
(void) printf("\t\t[%4llu] %s: txg %llu, pass %llu\n", |
|
439 |
(u_longlong_t)(offset / sizeof (entry)), |
|
440 |
ddata[SM_DEBUG_ACTION_DECODE(entry)], |
|
2856 | 441 |
(u_longlong_t)SM_DEBUG_TXG_DECODE(entry), |
442 |
(u_longlong_t)SM_DEBUG_SYNCPASS_DECODE(entry)); |
|
789 | 443 |
} else { |
444 |
(void) printf("\t\t[%4llu] %c range:" |
|
445 |
" %08llx-%08llx size: %06llx\n", |
|
446 |
(u_longlong_t)(offset / sizeof (entry)), |
|
447 |
SM_TYPE_DECODE(entry) == SM_ALLOC ? 'A' : 'F', |
|
2856 | 448 |
(u_longlong_t)((SM_OFFSET_DECODE(entry) << |
449 |
mapshift) + mapstart), |
|
450 |
(u_longlong_t)((SM_OFFSET_DECODE(entry) << |
|
451 |
mapshift) + mapstart + (SM_RUN_DECODE(entry) << |
|
452 |
mapshift)), |
|
453 |
(u_longlong_t)(SM_RUN_DECODE(entry) << mapshift)); |
|
789 | 454 |
if (SM_TYPE_DECODE(entry) == SM_ALLOC) |
455 |
alloc += SM_RUN_DECODE(entry) << mapshift; |
|
456 |
else |
|
457 |
alloc -= SM_RUN_DECODE(entry) << mapshift; |
|
458 |
} |
|
459 |
} |
|
460 |
if (alloc != smo->smo_alloc) { |
|
461 |
(void) printf("space_map_object alloc (%llu) INCONSISTENT " |
|
462 |
"with space map summary (%llu)\n", |
|
463 |
(u_longlong_t)smo->smo_alloc, (u_longlong_t)alloc); |
|
464 |
} |
|
465 |
} |
|
466 |
||
467 |
static void |
|
468 |
dump_metaslab(metaslab_t *msp) |
|
469 |
{ |
|
470 |
char freebuf[5]; |
|
1732 | 471 |
space_map_obj_t *smo = &msp->ms_smo; |
789 | 472 |
vdev_t *vd = msp->ms_group->mg_vd; |
473 |
spa_t *spa = vd->vdev_spa; |
|
474 |
||
475 |
nicenum(msp->ms_map.sm_size - smo->smo_alloc, freebuf); |
|
476 |
||
477 |
if (dump_opt['d'] <= 5) { |
|
478 |
(void) printf("\t%10llx %10llu %5s\n", |
|
479 |
(u_longlong_t)msp->ms_map.sm_start, |
|
480 |
(u_longlong_t)smo->smo_object, |
|
481 |
freebuf); |
|
482 |
return; |
|
483 |
} |
|
484 |
||
485 |
(void) printf( |
|
486 |
"\tvdev %llu offset %08llx spacemap %4llu free %5s\n", |
|
487 |
(u_longlong_t)vd->vdev_id, (u_longlong_t)msp->ms_map.sm_start, |
|
488 |
(u_longlong_t)smo->smo_object, freebuf); |
|
489 |
||
490 |
ASSERT(msp->ms_map.sm_size == (1ULL << vd->vdev_ms_shift)); |
|
491 |
||
492 |
dump_spacemap(spa->spa_meta_objset, smo, &msp->ms_map); |
|
493 |
} |
|
494 |
||
495 |
static void |
|
496 |
dump_metaslabs(spa_t *spa) |
|
497 |
{ |
|
498 |
vdev_t *rvd = spa->spa_root_vdev; |
|
499 |
vdev_t *vd; |
|
500 |
int c, m; |
|
501 |
||
502 |
(void) printf("\nMetaslabs:\n"); |
|
503 |
||
504 |
for (c = 0; c < rvd->vdev_children; c++) { |
|
505 |
vd = rvd->vdev_child[c]; |
|
506 |
||
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
507 |
(void) printf("\n vdev %llu\n\n", (u_longlong_t)vd->vdev_id); |
789 | 508 |
|
509 |
if (dump_opt['d'] <= 5) { |
|
510 |
(void) printf("\t%10s %10s %5s\n", |
|
511 |
"offset", "spacemap", "free"); |
|
512 |
(void) printf("\t%10s %10s %5s\n", |
|
513 |
"------", "--------", "----"); |
|
514 |
} |
|
515 |
for (m = 0; m < vd->vdev_ms_count; m++) |
|
516 |
dump_metaslab(vd->vdev_ms[m]); |
|
517 |
(void) printf("\n"); |
|
518 |
} |
|
519 |
} |
|
520 |
||
521 |
static void |
|
522 |
dump_dtl(vdev_t *vd, int indent) |
|
523 |
{ |
|
524 |
avl_tree_t *t = &vd->vdev_dtl_map.sm_root; |
|
525 |
space_seg_t *ss; |
|
526 |
vdev_t *pvd; |
|
527 |
int c; |
|
528 |
||
529 |
if (indent == 0) |
|
530 |
(void) printf("\nDirty time logs:\n\n"); |
|
531 |
||
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
532 |
(void) printf("\t%*s%s\n", indent, "", |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
533 |
vd->vdev_path ? vd->vdev_path : |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
534 |
vd->vdev_parent ? vd->vdev_ops->vdev_op_type : |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
535 |
spa_name(vd->vdev_spa)); |
789 | 536 |
|
537 |
for (ss = avl_first(t); ss; ss = AVL_NEXT(t, ss)) { |
|
538 |
/* |
|
539 |
* Everything in this DTL must appear in all parent DTL unions. |
|
540 |
*/ |
|
541 |
for (pvd = vd; pvd; pvd = pvd->vdev_parent) |
|
542 |
ASSERT(vdev_dtl_contains(&pvd->vdev_dtl_map, |
|
543 |
ss->ss_start, ss->ss_end - ss->ss_start)); |
|
544 |
(void) printf("\t%*soutage [%llu,%llu] length %llu\n", |
|
545 |
indent, "", |
|
546 |
(u_longlong_t)ss->ss_start, |
|
547 |
(u_longlong_t)ss->ss_end - 1, |
|
2856 | 548 |
(u_longlong_t)(ss->ss_end - ss->ss_start)); |
789 | 549 |
} |
550 |
||
551 |
(void) printf("\n"); |
|
552 |
||
553 |
if (dump_opt['d'] > 5 && vd->vdev_children == 0) { |
|
554 |
dump_spacemap(vd->vdev_spa->spa_meta_objset, &vd->vdev_dtl, |
|
555 |
&vd->vdev_dtl_map); |
|
556 |
(void) printf("\n"); |
|
557 |
} |
|
558 |
||
559 |
for (c = 0; c < vd->vdev_children; c++) |
|
560 |
dump_dtl(vd->vdev_child[c], indent + 4); |
|
561 |
} |
|
562 |
||
563 |
/*ARGSUSED*/ |
|
564 |
static void |
|
565 |
dump_dnode(objset_t *os, uint64_t object, void *data, size_t size) |
|
566 |
{ |
|
567 |
} |
|
568 |
||
569 |
static uint64_t |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
570 |
blkid2offset(const dnode_phys_t *dnp, int level, uint64_t blkid) |
789 | 571 |
{ |
572 |
if (level < 0) |
|
573 |
return (blkid); |
|
574 |
||
575 |
return ((blkid << (level * (dnp->dn_indblkshift - SPA_BLKPTRSHIFT))) * |
|
576 |
dnp->dn_datablkszsec << SPA_MINBLOCKSHIFT); |
|
577 |
} |
|
578 |
||
1775
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
579 |
static void |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
580 |
sprintf_blkptr_compact(char *blkbuf, blkptr_t *bp, int alldvas) |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
581 |
{ |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
582 |
dva_t *dva = bp->blk_dva; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
583 |
int ndvas = alldvas ? BP_GET_NDVAS(bp) : 1; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
584 |
int i; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
585 |
|
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
586 |
blkbuf[0] = '\0'; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
587 |
|
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
588 |
for (i = 0; i < ndvas; i++) |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
589 |
(void) sprintf(blkbuf + strlen(blkbuf), "%llu:%llx:%llx ", |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
590 |
(u_longlong_t)DVA_GET_VDEV(&dva[i]), |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
591 |
(u_longlong_t)DVA_GET_OFFSET(&dva[i]), |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
592 |
(u_longlong_t)DVA_GET_ASIZE(&dva[i])); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
593 |
|
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
594 |
(void) sprintf(blkbuf + strlen(blkbuf), "%llxL/%llxP F=%llu B=%llu", |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
595 |
(u_longlong_t)BP_GET_LSIZE(bp), |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
596 |
(u_longlong_t)BP_GET_PSIZE(bp), |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
597 |
(u_longlong_t)bp->blk_fill, |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
598 |
(u_longlong_t)bp->blk_birth); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
599 |
} |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
600 |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
601 |
static void |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
602 |
print_indirect(blkptr_t *bp, const zbookmark_t *zb, |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
603 |
const dnode_phys_t *dnp) |
789 | 604 |
{ |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
605 |
char blkbuf[BP_SPRINTF_LEN]; |
789 | 606 |
int l; |
607 |
||
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
608 |
ASSERT3U(BP_GET_TYPE(bp), ==, dnp->dn_type); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
609 |
ASSERT3U(BP_GET_LEVEL(bp), ==, zb->zb_level); |
789 | 610 |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
611 |
(void) printf("%16llx ", |
789 | 612 |
(u_longlong_t)blkid2offset(dnp, zb->zb_level, zb->zb_blkid)); |
613 |
||
614 |
ASSERT(zb->zb_level >= 0); |
|
615 |
||
616 |
for (l = dnp->dn_nlevels - 1; l >= -1; l--) { |
|
617 |
if (l == zb->zb_level) { |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
618 |
(void) printf("L%llx", (u_longlong_t)zb->zb_level); |
789 | 619 |
} else { |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
620 |
(void) printf(" "); |
789 | 621 |
} |
622 |
} |
|
623 |
||
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
624 |
sprintf_blkptr_compact(blkbuf, bp, dump_opt['d'] > 5 ? 1 : 0); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
625 |
(void) printf("%s\n", blkbuf); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
626 |
} |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
627 |
|
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
628 |
#define SET_BOOKMARK(zb, objset, object, level, blkid) \ |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
629 |
{ \ |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
630 |
(zb)->zb_objset = objset; \ |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
631 |
(zb)->zb_object = object; \ |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
632 |
(zb)->zb_level = level; \ |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
633 |
(zb)->zb_blkid = blkid; \ |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
634 |
} |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
635 |
|
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
636 |
static int |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
637 |
visit_indirect(spa_t *spa, const dnode_phys_t *dnp, |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
638 |
blkptr_t *bp, const zbookmark_t *zb) |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
639 |
{ |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
640 |
int err; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
641 |
|
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
642 |
if (bp->blk_birth == 0) |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
643 |
return (0); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
644 |
|
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
645 |
print_indirect(bp, zb, dnp); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
646 |
|
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
647 |
if (BP_GET_LEVEL(bp) > 0) { |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
648 |
uint32_t flags = ARC_WAIT; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
649 |
int i; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
650 |
blkptr_t *cbp; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
651 |
int epb = BP_GET_LSIZE(bp) >> SPA_BLKPTRSHIFT; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
652 |
arc_buf_t *buf; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
653 |
uint64_t fill = 0; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
654 |
|
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
655 |
err = arc_read_nolock(NULL, spa, bp, arc_getbuf_func, &buf, |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
656 |
ZIO_PRIORITY_ASYNC_READ, ZIO_FLAG_CANFAIL, &flags, zb); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
657 |
if (err) |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
658 |
return (err); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
659 |
|
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
660 |
/* recursively visit blocks below this */ |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
661 |
cbp = buf->b_data; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
662 |
for (i = 0; i < epb; i++, cbp++) { |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
663 |
zbookmark_t czb; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
664 |
|
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
665 |
SET_BOOKMARK(&czb, zb->zb_objset, zb->zb_object, |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
666 |
zb->zb_level - 1, |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
667 |
zb->zb_blkid * epb + i); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
668 |
err = visit_indirect(spa, dnp, cbp, &czb); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
669 |
if (err) |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
670 |
break; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
671 |
fill += cbp->blk_fill; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
672 |
} |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
673 |
ASSERT3U(fill, ==, bp->blk_fill); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
674 |
(void) arc_buf_remove_ref(buf, &buf); |
789 | 675 |
} |
676 |
||
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
677 |
return (err); |
789 | 678 |
} |
679 |
||
680 |
/*ARGSUSED*/ |
|
681 |
static void |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
682 |
dump_indirect(dnode_t *dn) |
789 | 683 |
{ |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
684 |
dnode_phys_t *dnp = dn->dn_phys; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
685 |
int j; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
686 |
zbookmark_t czb; |
789 | 687 |
|
688 |
(void) printf("Indirect blocks:\n"); |
|
689 |
||
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
690 |
SET_BOOKMARK(&czb, dmu_objset_id(&dn->dn_objset->os), |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
691 |
dn->dn_object, dnp->dn_nlevels - 1, 0); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
692 |
for (j = 0; j < dnp->dn_nblkptr; j++) { |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
693 |
czb.zb_blkid = j; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
694 |
(void) visit_indirect(dmu_objset_spa(&dn->dn_objset->os), dnp, |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
695 |
&dnp->dn_blkptr[j], &czb); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
696 |
} |
789 | 697 |
|
698 |
(void) printf("\n"); |
|
699 |
} |
|
700 |
||
701 |
/*ARGSUSED*/ |
|
702 |
static void |
|
703 |
dump_dsl_dir(objset_t *os, uint64_t object, void *data, size_t size) |
|
704 |
{ |
|
705 |
dsl_dir_phys_t *dd = data; |
|
706 |
time_t crtime; |
|
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7265
diff
changeset
|
707 |
char nice[6]; |
789 | 708 |
|
709 |
if (dd == NULL) |
|
710 |
return; |
|
711 |
||
5331 | 712 |
ASSERT3U(size, >=, sizeof (dsl_dir_phys_t)); |
789 | 713 |
|
714 |
crtime = dd->dd_creation_time; |
|
715 |
(void) printf("\t\tcreation_time = %s", ctime(&crtime)); |
|
716 |
(void) printf("\t\thead_dataset_obj = %llu\n", |
|
717 |
(u_longlong_t)dd->dd_head_dataset_obj); |
|
718 |
(void) printf("\t\tparent_dir_obj = %llu\n", |
|
719 |
(u_longlong_t)dd->dd_parent_obj); |
|
5367 | 720 |
(void) printf("\t\torigin_obj = %llu\n", |
721 |
(u_longlong_t)dd->dd_origin_obj); |
|
789 | 722 |
(void) printf("\t\tchild_dir_zapobj = %llu\n", |
723 |
(u_longlong_t)dd->dd_child_dir_zapobj); |
|
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7265
diff
changeset
|
724 |
nicenum(dd->dd_used_bytes, nice); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7265
diff
changeset
|
725 |
(void) printf("\t\tused_bytes = %s\n", nice); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7265
diff
changeset
|
726 |
nicenum(dd->dd_compressed_bytes, nice); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7265
diff
changeset
|
727 |
(void) printf("\t\tcompressed_bytes = %s\n", nice); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7265
diff
changeset
|
728 |
nicenum(dd->dd_uncompressed_bytes, nice); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7265
diff
changeset
|
729 |
(void) printf("\t\tuncompressed_bytes = %s\n", nice); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7265
diff
changeset
|
730 |
nicenum(dd->dd_quota, nice); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7265
diff
changeset
|
731 |
(void) printf("\t\tquota = %s\n", nice); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7265
diff
changeset
|
732 |
nicenum(dd->dd_reserved, nice); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7265
diff
changeset
|
733 |
(void) printf("\t\treserved = %s\n", nice); |
789 | 734 |
(void) printf("\t\tprops_zapobj = %llu\n", |
735 |
(u_longlong_t)dd->dd_props_zapobj); |
|
4543 | 736 |
(void) printf("\t\tdeleg_zapobj = %llu\n", |
737 |
(u_longlong_t)dd->dd_deleg_zapobj); |
|
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7265
diff
changeset
|
738 |
(void) printf("\t\tflags = %llx\n", |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7265
diff
changeset
|
739 |
(u_longlong_t)dd->dd_flags); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7265
diff
changeset
|
740 |
|
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7265
diff
changeset
|
741 |
#define DO(which) \ |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7265
diff
changeset
|
742 |
nicenum(dd->dd_used_breakdown[DD_USED_ ## which], nice); \ |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7265
diff
changeset
|
743 |
(void) printf("\t\tused_breakdown[" #which "] = %s\n", nice) |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7265
diff
changeset
|
744 |
DO(HEAD); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7265
diff
changeset
|
745 |
DO(SNAP); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7265
diff
changeset
|
746 |
DO(CHILD); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7265
diff
changeset
|
747 |
DO(CHILD_RSRV); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7265
diff
changeset
|
748 |
DO(REFRSRV); |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7265
diff
changeset
|
749 |
#undef DO |
789 | 750 |
} |
751 |
||
752 |
/*ARGSUSED*/ |
|
753 |
static void |
|
754 |
dump_dsl_dataset(objset_t *os, uint64_t object, void *data, size_t size) |
|
755 |
{ |
|
756 |
dsl_dataset_phys_t *ds = data; |
|
757 |
time_t crtime; |
|
896 | 758 |
char used[6], compressed[6], uncompressed[6], unique[6]; |
759 |
char blkbuf[BP_SPRINTF_LEN]; |
|
789 | 760 |
|
761 |
if (ds == NULL) |
|
762 |
return; |
|
763 |
||
764 |
ASSERT(size == sizeof (*ds)); |
|
765 |
crtime = ds->ds_creation_time; |
|
766 |
nicenum(ds->ds_used_bytes, used); |
|
767 |
nicenum(ds->ds_compressed_bytes, compressed); |
|
768 |
nicenum(ds->ds_uncompressed_bytes, uncompressed); |
|
769 |
nicenum(ds->ds_unique_bytes, unique); |
|
896 | 770 |
sprintf_blkptr(blkbuf, BP_SPRINTF_LEN, &ds->ds_bp); |
789 | 771 |
|
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
772 |
(void) printf("\t\tdir_obj = %llu\n", |
789 | 773 |
(u_longlong_t)ds->ds_dir_obj); |
774 |
(void) printf("\t\tprev_snap_obj = %llu\n", |
|
775 |
(u_longlong_t)ds->ds_prev_snap_obj); |
|
776 |
(void) printf("\t\tprev_snap_txg = %llu\n", |
|
777 |
(u_longlong_t)ds->ds_prev_snap_txg); |
|
778 |
(void) printf("\t\tnext_snap_obj = %llu\n", |
|
779 |
(u_longlong_t)ds->ds_next_snap_obj); |
|
780 |
(void) printf("\t\tsnapnames_zapobj = %llu\n", |
|
781 |
(u_longlong_t)ds->ds_snapnames_zapobj); |
|
782 |
(void) printf("\t\tnum_children = %llu\n", |
|
783 |
(u_longlong_t)ds->ds_num_children); |
|
784 |
(void) printf("\t\tcreation_time = %s", ctime(&crtime)); |
|
785 |
(void) printf("\t\tcreation_txg = %llu\n", |
|
786 |
(u_longlong_t)ds->ds_creation_txg); |
|
787 |
(void) printf("\t\tdeadlist_obj = %llu\n", |
|
788 |
(u_longlong_t)ds->ds_deadlist_obj); |
|
789 |
(void) printf("\t\tused_bytes = %s\n", used); |
|
790 |
(void) printf("\t\tcompressed_bytes = %s\n", compressed); |
|
791 |
(void) printf("\t\tuncompressed_bytes = %s\n", uncompressed); |
|
792 |
(void) printf("\t\tunique = %s\n", unique); |
|
793 |
(void) printf("\t\tfsid_guid = %llu\n", |
|
794 |
(u_longlong_t)ds->ds_fsid_guid); |
|
795 |
(void) printf("\t\tguid = %llu\n", |
|
796 |
(u_longlong_t)ds->ds_guid); |
|
2082 | 797 |
(void) printf("\t\tflags = %llx\n", |
798 |
(u_longlong_t)ds->ds_flags); |
|
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
799 |
(void) printf("\t\tnext_clones_obj = %llu\n", |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
800 |
(u_longlong_t)ds->ds_next_clones_obj); |
7265 | 801 |
(void) printf("\t\tprops_obj = %llu\n", |
802 |
(u_longlong_t)ds->ds_props_obj); |
|
789 | 803 |
(void) printf("\t\tbp = %s\n", blkbuf); |
804 |
} |
|
805 |
||
806 |
static void |
|
807 |
dump_bplist(objset_t *mos, uint64_t object, char *name) |
|
808 |
{ |
|
809 |
bplist_t bpl = { 0 }; |
|
810 |
blkptr_t blk, *bp = &blk; |
|
811 |
uint64_t itor = 0; |
|
2082 | 812 |
char bytes[6]; |
813 |
char comp[6]; |
|
814 |
char uncomp[6]; |
|
789 | 815 |
|
816 |
if (dump_opt['d'] < 3) |
|
817 |
return; |
|
818 |
||
4831
41ec732c6d9f
6584470 zdb needs to initialize the bpl_lock mutex
gw25295
parents:
4787
diff
changeset
|
819 |
mutex_init(&bpl.bpl_lock, NULL, MUTEX_DEFAULT, NULL); |
1544 | 820 |
VERIFY(0 == bplist_open(&bpl, mos, object)); |
789 | 821 |
if (bplist_empty(&bpl)) { |
822 |
bplist_close(&bpl); |
|
4831
41ec732c6d9f
6584470 zdb needs to initialize the bpl_lock mutex
gw25295
parents:
4787
diff
changeset
|
823 |
mutex_destroy(&bpl.bpl_lock); |
789 | 824 |
return; |
825 |
} |
|
826 |
||
2082 | 827 |
nicenum(bpl.bpl_phys->bpl_bytes, bytes); |
828 |
if (bpl.bpl_dbuf->db_size == sizeof (bplist_phys_t)) { |
|
829 |
nicenum(bpl.bpl_phys->bpl_comp, comp); |
|
830 |
nicenum(bpl.bpl_phys->bpl_uncomp, uncomp); |
|
831 |
(void) printf("\n %s: %llu entries, %s (%s/%s comp)\n", |
|
832 |
name, (u_longlong_t)bpl.bpl_phys->bpl_entries, |
|
833 |
bytes, comp, uncomp); |
|
834 |
} else { |
|
835 |
(void) printf("\n %s: %llu entries, %s\n", |
|
836 |
name, (u_longlong_t)bpl.bpl_phys->bpl_entries, bytes); |
|
837 |
} |
|
789 | 838 |
|
839 |
if (dump_opt['d'] < 5) { |
|
840 |
bplist_close(&bpl); |
|
4831
41ec732c6d9f
6584470 zdb needs to initialize the bpl_lock mutex
gw25295
parents:
4787
diff
changeset
|
841 |
mutex_destroy(&bpl.bpl_lock); |
789 | 842 |
return; |
843 |
} |
|
844 |
||
845 |
(void) printf("\n"); |
|
846 |
||
847 |
while (bplist_iterate(&bpl, &itor, bp) == 0) { |
|
1775
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
848 |
char blkbuf[BP_SPRINTF_LEN]; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
849 |
|
789 | 850 |
ASSERT(bp->blk_birth != 0); |
1775
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
851 |
sprintf_blkptr_compact(blkbuf, bp, dump_opt['d'] > 5 ? 1 : 0); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
852 |
(void) printf("\tItem %3llu: %s\n", |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
853 |
(u_longlong_t)itor - 1, blkbuf); |
789 | 854 |
} |
855 |
||
856 |
bplist_close(&bpl); |
|
4831
41ec732c6d9f
6584470 zdb needs to initialize the bpl_lock mutex
gw25295
parents:
4787
diff
changeset
|
857 |
mutex_destroy(&bpl.bpl_lock); |
789 | 858 |
} |
859 |
||
5959
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
860 |
static avl_tree_t idx_tree; |
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
861 |
static avl_tree_t domain_tree; |
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
862 |
static boolean_t fuid_table_loaded; |
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
863 |
|
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
864 |
static void |
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
865 |
fuid_table_destroy() |
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
866 |
{ |
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
867 |
if (fuid_table_loaded) { |
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
868 |
zfs_fuid_table_destroy(&idx_tree, &domain_tree); |
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
869 |
fuid_table_loaded = B_FALSE; |
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
870 |
} |
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
871 |
} |
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
872 |
|
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
873 |
/* |
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
874 |
* print uid or gid information. |
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
875 |
* For normal POSIX id just the id is printed in decimal format. |
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
876 |
* For CIFS files with FUID the fuid is printed in hex followed by |
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
877 |
* the doman-rid string. |
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
878 |
*/ |
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
879 |
static void |
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
880 |
print_idstr(uint64_t id, const char *id_type) |
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
881 |
{ |
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
882 |
if (FUID_INDEX(id)) { |
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
883 |
char *domain; |
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
884 |
|
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
885 |
domain = zfs_fuid_idx_domain(&idx_tree, FUID_INDEX(id)); |
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
886 |
(void) printf("\t%s %llx [%s-%d]\n", id_type, |
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
887 |
(u_longlong_t)id, domain, (int)FUID_RID(id)); |
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
888 |
} else { |
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
889 |
(void) printf("\t%s %llu\n", id_type, (u_longlong_t)id); |
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
890 |
} |
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
891 |
|
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
892 |
} |
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
893 |
|
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
894 |
static void |
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
895 |
dump_uidgid(objset_t *os, znode_phys_t *zp) |
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
896 |
{ |
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
897 |
uint32_t uid_idx, gid_idx; |
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
898 |
|
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
899 |
uid_idx = FUID_INDEX(zp->zp_uid); |
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
900 |
gid_idx = FUID_INDEX(zp->zp_gid); |
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
901 |
|
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
902 |
/* Load domain table, if not already loaded */ |
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
903 |
if (!fuid_table_loaded && (uid_idx || gid_idx)) { |
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
904 |
uint64_t fuid_obj; |
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
905 |
|
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
906 |
/* first find the fuid object. It lives in the master node */ |
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
907 |
VERIFY(zap_lookup(os, MASTER_NODE_OBJ, ZFS_FUID_TABLES, |
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
908 |
8, 1, &fuid_obj) == 0); |
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
909 |
(void) zfs_fuid_table_load(os, fuid_obj, |
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
910 |
&idx_tree, &domain_tree); |
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
911 |
fuid_table_loaded = B_TRUE; |
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
912 |
} |
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
913 |
|
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
914 |
print_idstr(zp->zp_uid, "uid"); |
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
915 |
print_idstr(zp->zp_gid, "gid"); |
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
916 |
} |
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
917 |
|
789 | 918 |
/*ARGSUSED*/ |
919 |
static void |
|
920 |
dump_znode(objset_t *os, uint64_t object, void *data, size_t size) |
|
921 |
{ |
|
922 |
znode_phys_t *zp = data; |
|
923 |
time_t z_crtime, z_atime, z_mtime, z_ctime; |
|
924 |
char path[MAXPATHLEN * 2]; /* allow for xattr and failure prefix */ |
|
3444
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3361
diff
changeset
|
925 |
int error; |
789 | 926 |
|
927 |
ASSERT(size >= sizeof (znode_phys_t)); |
|
928 |
||
3444
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3361
diff
changeset
|
929 |
error = zfs_obj_to_path(os, object, path, sizeof (path)); |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3361
diff
changeset
|
930 |
if (error != 0) { |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3361
diff
changeset
|
931 |
(void) snprintf(path, sizeof (path), "\?\?\?<object#%llu>", |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3361
diff
changeset
|
932 |
(u_longlong_t)object); |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3361
diff
changeset
|
933 |
} |
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3361
diff
changeset
|
934 |
|
789 | 935 |
if (dump_opt['d'] < 3) { |
3444
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3361
diff
changeset
|
936 |
(void) printf("\t%s\n", path); |
789 | 937 |
return; |
938 |
} |
|
939 |
||
940 |
z_crtime = (time_t)zp->zp_crtime[0]; |
|
941 |
z_atime = (time_t)zp->zp_atime[0]; |
|
942 |
z_mtime = (time_t)zp->zp_mtime[0]; |
|
943 |
z_ctime = (time_t)zp->zp_ctime[0]; |
|
944 |
||
3444
dc160a70a50d
6410433 'zpool status -v' would be more useful with filenames
ek110237
parents:
3361
diff
changeset
|
945 |
(void) printf("\tpath %s\n", path); |
5959
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
946 |
dump_uidgid(os, zp); |
789 | 947 |
(void) printf("\tatime %s", ctime(&z_atime)); |
948 |
(void) printf("\tmtime %s", ctime(&z_mtime)); |
|
949 |
(void) printf("\tctime %s", ctime(&z_ctime)); |
|
950 |
(void) printf("\tcrtime %s", ctime(&z_crtime)); |
|
951 |
(void) printf("\tgen %llu\n", (u_longlong_t)zp->zp_gen); |
|
952 |
(void) printf("\tmode %llo\n", (u_longlong_t)zp->zp_mode); |
|
953 |
(void) printf("\tsize %llu\n", (u_longlong_t)zp->zp_size); |
|
954 |
(void) printf("\tparent %llu\n", (u_longlong_t)zp->zp_parent); |
|
955 |
(void) printf("\tlinks %llu\n", (u_longlong_t)zp->zp_links); |
|
956 |
(void) printf("\txattr %llu\n", (u_longlong_t)zp->zp_xattr); |
|
957 |
(void) printf("\trdev 0x%016llx\n", (u_longlong_t)zp->zp_rdev); |
|
958 |
} |
|
959 |
||
960 |
/*ARGSUSED*/ |
|
961 |
static void |
|
962 |
dump_acl(objset_t *os, uint64_t object, void *data, size_t size) |
|
963 |
{ |
|
964 |
} |
|
965 |
||
966 |
/*ARGSUSED*/ |
|
967 |
static void |
|
968 |
dump_dmu_objset(objset_t *os, uint64_t object, void *data, size_t size) |
|
969 |
{ |
|
970 |
} |
|
971 |
||
972 |
static object_viewer_t *object_viewer[DMU_OT_NUMTYPES] = { |
|
973 |
dump_none, /* unallocated */ |
|
974 |
dump_zap, /* object directory */ |
|
975 |
dump_uint64, /* object array */ |
|
976 |
dump_none, /* packed nvlist */ |
|
977 |
dump_packed_nvlist, /* packed nvlist size */ |
|
978 |
dump_none, /* bplist */ |
|
979 |
dump_none, /* bplist header */ |
|
980 |
dump_none, /* SPA space map header */ |
|
981 |
dump_none, /* SPA space map */ |
|
982 |
dump_none, /* ZIL intent log */ |
|
983 |
dump_dnode, /* DMU dnode */ |
|
984 |
dump_dmu_objset, /* DMU objset */ |
|
1544 | 985 |
dump_dsl_dir, /* DSL directory */ |
789 | 986 |
dump_zap, /* DSL directory child map */ |
987 |
dump_zap, /* DSL dataset snap map */ |
|
988 |
dump_zap, /* DSL props */ |
|
989 |
dump_dsl_dataset, /* DSL dataset */ |
|
990 |
dump_znode, /* ZFS znode */ |
|
5331 | 991 |
dump_acl, /* ZFS V0 ACL */ |
789 | 992 |
dump_uint8, /* ZFS plain file */ |
4577 | 993 |
dump_zpldir, /* ZFS directory */ |
789 | 994 |
dump_zap, /* ZFS master node */ |
995 |
dump_zap, /* ZFS delete queue */ |
|
996 |
dump_uint8, /* zvol object */ |
|
997 |
dump_zap, /* zvol prop */ |
|
998 |
dump_uint8, /* other uint8[] */ |
|
999 |
dump_uint64, /* other uint64[] */ |
|
1000 |
dump_zap, /* other ZAP */ |
|
1544 | 1001 |
dump_zap, /* persistent error log */ |
2926 | 1002 |
dump_uint8, /* SPA history */ |
1003 |
dump_uint64, /* SPA history offsets */ |
|
3912 | 1004 |
dump_zap, /* Pool properties */ |
4543 | 1005 |
dump_zap, /* DSL permissions */ |
5331 | 1006 |
dump_acl, /* ZFS ACL */ |
1007 |
dump_uint8, /* ZFS SYSACL */ |
|
1008 |
dump_none, /* FUID nvlist */ |
|
1009 |
dump_packed_nvlist, /* FUID nvlist size */ |
|
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1010 |
dump_zap, /* DSL dataset next clones */ |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1011 |
dump_zap, /* DSL scrub queue */ |
789 | 1012 |
}; |
1013 |
||
1014 |
static void |
|
1015 |
dump_object(objset_t *os, uint64_t object, int verbosity, int *print_header) |
|
1016 |
{ |
|
1017 |
dmu_buf_t *db = NULL; |
|
1018 |
dmu_object_info_t doi; |
|
1019 |
dnode_t *dn; |
|
1020 |
void *bonus = NULL; |
|
1021 |
size_t bsize = 0; |
|
1732 | 1022 |
char iblk[6], dblk[6], lsize[6], asize[6], bonus_size[6], segsize[6]; |
789 | 1023 |
char aux[50]; |
1024 |
int error; |
|
1025 |
||
1026 |
if (*print_header) { |
|
1027 |
(void) printf("\n Object lvl iblk dblk lsize" |
|
1732 | 1028 |
" asize type\n"); |
789 | 1029 |
*print_header = 0; |
1030 |
} |
|
1031 |
||
1032 |
if (object == 0) { |
|
1033 |
dn = os->os->os_meta_dnode; |
|
1034 |
} else { |
|
1544 | 1035 |
error = dmu_bonus_hold(os, object, FTAG, &db); |
1036 |
if (error) |
|
1037 |
fatal("dmu_bonus_hold(%llu) failed, errno %u", |
|
1038 |
object, error); |
|
789 | 1039 |
bonus = db->db_data; |
1040 |
bsize = db->db_size; |
|
1041 |
dn = ((dmu_buf_impl_t *)db)->db_dnode; |
|
1042 |
} |
|
1043 |
dmu_object_info_from_dnode(dn, &doi); |
|
1044 |
||
1045 |
nicenum(doi.doi_metadata_block_size, iblk); |
|
1046 |
nicenum(doi.doi_data_block_size, dblk); |
|
1047 |
nicenum(doi.doi_data_block_size * (doi.doi_max_block_offset + 1), |
|
1048 |
lsize); |
|
1732 | 1049 |
nicenum(doi.doi_physical_blks << 9, asize); |
789 | 1050 |
nicenum(doi.doi_bonus_size, bonus_size); |
1051 |
||
1052 |
aux[0] = '\0'; |
|
1053 |
||
4577 | 1054 |
if (doi.doi_checksum != ZIO_CHECKSUM_INHERIT || verbosity >= 6) { |
789 | 1055 |
(void) snprintf(aux + strlen(aux), sizeof (aux), " (K=%s)", |
4527 | 1056 |
zio_checksum_table[doi.doi_checksum].ci_name); |
4577 | 1057 |
} |
789 | 1058 |
|
4577 | 1059 |
if (doi.doi_compress != ZIO_COMPRESS_INHERIT || verbosity >= 6) { |
789 | 1060 |
(void) snprintf(aux + strlen(aux), sizeof (aux), " (Z=%s)", |
4527 | 1061 |
zio_compress_table[doi.doi_compress].ci_name); |
4577 | 1062 |
} |
789 | 1063 |
|
1064 |
(void) printf("%10lld %3u %5s %5s %5s %5s %s%s\n", |
|
1065 |
(u_longlong_t)object, doi.doi_indirection, iblk, dblk, lsize, |
|
1732 | 1066 |
asize, dmu_ot[doi.doi_type].ot_name, aux); |
789 | 1067 |
|
1068 |
if (doi.doi_bonus_type != DMU_OT_NONE && verbosity > 3) { |
|
1069 |
(void) printf("%10s %3s %5s %5s %5s %5s %s\n", |
|
1070 |
"", "", "", "", bonus_size, "bonus", |
|
1071 |
dmu_ot[doi.doi_bonus_type].ot_name); |
|
1072 |
} |
|
1073 |
||
1074 |
if (verbosity >= 4) { |
|
1075 |
object_viewer[doi.doi_bonus_type](os, object, bonus, bsize); |
|
1076 |
object_viewer[doi.doi_type](os, object, NULL, 0); |
|
1077 |
*print_header = 1; |
|
1078 |
} |
|
1079 |
||
1080 |
if (verbosity >= 5) |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1081 |
dump_indirect(dn); |
789 | 1082 |
|
1083 |
if (verbosity >= 5) { |
|
1084 |
/* |
|
1085 |
* Report the list of segments that comprise the object. |
|
1086 |
*/ |
|
1087 |
uint64_t start = 0; |
|
1088 |
uint64_t end; |
|
1089 |
uint64_t blkfill = 1; |
|
1090 |
int minlvl = 1; |
|
1091 |
||
1092 |
if (dn->dn_type == DMU_OT_DNODE) { |
|
1093 |
minlvl = 0; |
|
1094 |
blkfill = DNODES_PER_BLOCK; |
|
1095 |
} |
|
1096 |
||
1097 |
for (;;) { |
|
6992 | 1098 |
error = dnode_next_offset(dn, |
1099 |
0, &start, minlvl, blkfill, 0); |
|
789 | 1100 |
if (error) |
1101 |
break; |
|
1102 |
end = start; |
|
6992 | 1103 |
error = dnode_next_offset(dn, |
1104 |
DNODE_FIND_HOLE, &end, minlvl, blkfill, 0); |
|
789 | 1105 |
nicenum(end - start, segsize); |
1106 |
(void) printf("\t\tsegment [%016llx, %016llx)" |
|
1107 |
" size %5s\n", (u_longlong_t)start, |
|
1108 |
(u_longlong_t)end, segsize); |
|
1109 |
if (error) |
|
1110 |
break; |
|
1111 |
start = end; |
|
1112 |
} |
|
1113 |
} |
|
1114 |
||
1115 |
if (db != NULL) |
|
1544 | 1116 |
dmu_buf_rele(db, FTAG); |
789 | 1117 |
} |
1118 |
||
1119 |
static char *objset_types[DMU_OST_NUMTYPES] = { |
|
1120 |
"NONE", "META", "ZPL", "ZVOL", "OTHER", "ANY" }; |
|
1121 |
||
1122 |
static void |
|
1123 |
dump_dir(objset_t *os) |
|
1124 |
{ |
|
1125 |
dmu_objset_stats_t dds; |
|
1126 |
uint64_t object, object_count; |
|
2885 | 1127 |
uint64_t refdbytes, usedobjs, scratch; |
789 | 1128 |
char numbuf[8]; |
896 | 1129 |
char blkbuf[BP_SPRINTF_LEN]; |
789 | 1130 |
char osname[MAXNAMELEN]; |
1131 |
char *type = "UNKNOWN"; |
|
1132 |
int verbosity = dump_opt['d']; |
|
1133 |
int print_header = 1; |
|
1134 |
int i, error; |
|
1135 |
||
2885 | 1136 |
dmu_objset_fast_stat(os, &dds); |
789 | 1137 |
|
1138 |
if (dds.dds_type < DMU_OST_NUMTYPES) |
|
1139 |
type = objset_types[dds.dds_type]; |
|
1140 |
||
1141 |
if (dds.dds_type == DMU_OST_META) { |
|
1142 |
dds.dds_creation_txg = TXG_INITIAL; |
|
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3444
diff
changeset
|
1143 |
usedobjs = os->os->os_rootbp->blk_fill; |
7390
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7265
diff
changeset
|
1144 |
refdbytes = os->os->os_spa->spa_dsl_pool-> |
6d408f0a5fbd
PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7265
diff
changeset
|
1145 |
dp_mos_dir->dd_phys->dd_used_bytes; |
2885 | 1146 |
} else { |
1147 |
dmu_objset_space(os, &refdbytes, &scratch, &usedobjs, &scratch); |
|
789 | 1148 |
} |
1149 |
||
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3444
diff
changeset
|
1150 |
ASSERT3U(usedobjs, ==, os->os->os_rootbp->blk_fill); |
789 | 1151 |
|
2885 | 1152 |
nicenum(refdbytes, numbuf); |
789 | 1153 |
|
1154 |
if (verbosity >= 4) { |
|
1155 |
(void) strcpy(blkbuf, ", rootbp "); |
|
896 | 1156 |
sprintf_blkptr(blkbuf + strlen(blkbuf), |
3547
e396e0a440b1
6512391 DMU should leverage ZIO dependencies to achieve greater parallelism
maybee
parents:
3444
diff
changeset
|
1157 |
BP_SPRINTF_LEN - strlen(blkbuf), os->os->os_rootbp); |
789 | 1158 |
} else { |
1159 |
blkbuf[0] = '\0'; |
|
1160 |
} |
|
1161 |
||
1162 |
dmu_objset_name(os, osname); |
|
1163 |
||
2885 | 1164 |
(void) printf("Dataset %s [%s], ID %llu, cr_txg %llu, " |
789 | 1165 |
"%s, %llu objects%s\n", |
1166 |
osname, type, (u_longlong_t)dmu_objset_id(os), |
|
1167 |
(u_longlong_t)dds.dds_creation_txg, |
|
2885 | 1168 |
numbuf, (u_longlong_t)usedobjs, blkbuf); |
789 | 1169 |
|
1170 |
dump_intent_log(dmu_objset_zil(os)); |
|
1171 |
||
1172 |
if (dmu_objset_ds(os) != NULL) |
|
1173 |
dump_bplist(dmu_objset_pool(os)->dp_meta_objset, |
|
1174 |
dmu_objset_ds(os)->ds_phys->ds_deadlist_obj, "Deadlist"); |
|
1175 |
||
1176 |
if (verbosity < 2) |
|
1177 |
return; |
|
1178 |
||
7046
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1179 |
if (os->os->os_rootbp->blk_birth == 0) |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1180 |
return; |
361307ae060d
6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents:
6992
diff
changeset
|
1181 |
|
789 | 1182 |
if (zopt_objects != 0) { |
1183 |
for (i = 0; i < zopt_objects; i++) |
|
1184 |
dump_object(os, zopt_object[i], verbosity, |
|
1185 |
&print_header); |
|
1186 |
(void) printf("\n"); |
|
1187 |
return; |
|
1188 |
} |
|
1189 |
||
1190 |
dump_object(os, 0, verbosity, &print_header); |
|
1191 |
object_count = 1; |
|
1192 |
||
1193 |
object = 0; |
|
3025
4e5ee8301d84
6424466 "panic: data after EOF" when unmounting abused pool
ahrens
parents:
2926
diff
changeset
|
1194 |
while ((error = dmu_object_next(os, &object, B_FALSE, 0)) == 0) { |
789 | 1195 |
dump_object(os, object, verbosity, &print_header); |
1196 |
object_count++; |
|
1197 |
} |
|
1198 |
||
2885 | 1199 |
ASSERT3U(object_count, ==, usedobjs); |
789 | 1200 |
|
1201 |
(void) printf("\n"); |
|
1202 |
||
1203 |
if (error != ESRCH) |
|
1204 |
fatal("dmu_object_next() = %d", error); |
|
1205 |
} |
|
1206 |
||
1207 |
static void |
|
1208 |
dump_uberblock(uberblock_t *ub) |
|
1209 |
{ |
|
1210 |
time_t timestamp = ub->ub_timestamp; |
|
1211 |
||
1212 |
(void) printf("Uberblock\n\n"); |
|
1213 |
(void) printf("\tmagic = %016llx\n", (u_longlong_t)ub->ub_magic); |
|
1214 |
(void) printf("\tversion = %llu\n", (u_longlong_t)ub->ub_version); |
|
1215 |
(void) printf("\ttxg = %llu\n", (u_longlong_t)ub->ub_txg); |
|
1216 |
(void) printf("\tguid_sum = %llu\n", (u_longlong_t)ub->ub_guid_sum); |
|
1217 |
(void) printf("\ttimestamp = %llu UTC = %s", |
|
1218 |
(u_longlong_t)ub->ub_timestamp, asctime(localtime(×tamp))); |
|
1219 |
if (dump_opt['u'] >= 3) { |
|
896 | 1220 |
char blkbuf[BP_SPRINTF_LEN]; |
1221 |
sprintf_blkptr(blkbuf, BP_SPRINTF_LEN, &ub->ub_rootbp); |
|
789 | 1222 |
(void) printf("\trootbp = %s\n", blkbuf); |
1223 |
} |
|
1224 |
(void) printf("\n"); |
|
1225 |
} |
|
1226 |
||
1227 |
static void |
|
1228 |
dump_config(const char *pool) |
|
1229 |
{ |
|
1230 |
spa_t *spa = NULL; |
|
1231 |
||
1232 |
mutex_enter(&spa_namespace_lock); |
|
1233 |
while ((spa = spa_next(spa)) != NULL) { |
|
1234 |
if (pool == NULL) |
|
1235 |
(void) printf("%s\n", spa_name(spa)); |
|
1236 |
if (pool == NULL || strcmp(pool, spa_name(spa)) == 0) |
|
1237 |
dump_nvlist(spa->spa_config, 4); |
|
1238 |
} |
|
1239 |
mutex_exit(&spa_namespace_lock); |
|
1240 |
} |
|
1241 |
||
1242 |
static void |
|
6643
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
1243 |
dump_cachefile(const char *cachefile) |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
1244 |
{ |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
1245 |
int fd; |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
1246 |
struct stat64 statbuf; |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
1247 |
char *buf; |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
1248 |
nvlist_t *config; |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
1249 |
|
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
1250 |
if ((fd = open64(cachefile, O_RDONLY)) < 0) { |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
1251 |
(void) printf("cannot open '%s': %s\n", cachefile, |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
1252 |
strerror(errno)); |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
1253 |
exit(1); |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
1254 |
} |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
1255 |
|
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
1256 |
if (fstat64(fd, &statbuf) != 0) { |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
1257 |
(void) printf("failed to stat '%s': %s\n", cachefile, |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
1258 |
strerror(errno)); |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
1259 |
exit(1); |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
1260 |
} |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
1261 |
|
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
1262 |
if ((buf = malloc(statbuf.st_size)) == NULL) { |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
1263 |
(void) fprintf(stderr, "failed to allocate %llu bytes\n", |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
1264 |
(u_longlong_t)statbuf.st_size); |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
1265 |
exit(1); |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
1266 |
} |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
1267 |
|
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
1268 |
if (read(fd, buf, statbuf.st_size) != statbuf.st_size) { |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
1269 |
(void) fprintf(stderr, "failed to read %llu bytes\n", |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
1270 |
(u_longlong_t)statbuf.st_size); |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
1271 |
exit(1); |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
1272 |
} |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
1273 |
|
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
1274 |
(void) close(fd); |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
1275 |
|
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
1276 |
if (nvlist_unpack(buf, statbuf.st_size, &config, 0) != 0) { |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
1277 |
(void) fprintf(stderr, "failed to unpack nvlist\n"); |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
1278 |
exit(1); |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
1279 |
} |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
1280 |
|
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
1281 |
free(buf); |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
1282 |
|
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
1283 |
dump_nvlist(config, 0); |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
1284 |
|
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
1285 |
nvlist_free(config); |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
1286 |
} |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
1287 |
|
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
1288 |
static void |
789 | 1289 |
dump_label(const char *dev) |
1290 |
{ |
|
1291 |
int fd; |
|
1292 |
vdev_label_t label; |
|
1293 |
char *buf = label.vl_vdev_phys.vp_nvlist; |
|
1294 |
size_t buflen = sizeof (label.vl_vdev_phys.vp_nvlist); |
|
1295 |
struct stat64 statbuf; |
|
1296 |
uint64_t psize; |
|
1297 |
int l; |
|
1298 |
||
1170
cbb023fb2c22
6366222 zdb(1M) needs to use largefile primitives when reading label
eschrock
parents:
896
diff
changeset
|
1299 |
if ((fd = open64(dev, O_RDONLY)) < 0) { |
789 | 1300 |
(void) printf("cannot open '%s': %s\n", dev, strerror(errno)); |
1301 |
exit(1); |
|
1302 |
} |
|
1303 |
||
1304 |
if (fstat64(fd, &statbuf) != 0) { |
|
1305 |
(void) printf("failed to stat '%s': %s\n", dev, |
|
1306 |
strerror(errno)); |
|
1307 |
exit(1); |
|
1308 |
} |
|
1309 |
||
1310 |
psize = statbuf.st_size; |
|
1311 |
psize = P2ALIGN(psize, (uint64_t)sizeof (vdev_label_t)); |
|
1312 |
||
1313 |
for (l = 0; l < VDEV_LABELS; l++) { |
|
1314 |
||
1315 |
nvlist_t *config = NULL; |
|
1316 |
||
1317 |
(void) printf("--------------------------------------------\n"); |
|
1318 |
(void) printf("LABEL %d\n", l); |
|
1319 |
(void) printf("--------------------------------------------\n"); |
|
1320 |
||
1170
cbb023fb2c22
6366222 zdb(1M) needs to use largefile primitives when reading label
eschrock
parents:
896
diff
changeset
|
1321 |
if (pread64(fd, &label, sizeof (label), |
789 | 1322 |
vdev_label_offset(psize, l, 0)) != sizeof (label)) { |
1323 |
(void) printf("failed to read label %d\n", l); |
|
1324 |
continue; |
|
1325 |
} |
|
1326 |
||
1327 |
if (nvlist_unpack(buf, buflen, &config, 0) != 0) { |
|
1328 |
(void) printf("failed to unpack label %d\n", l); |
|
1329 |
continue; |
|
1330 |
} |
|
1331 |
dump_nvlist(config, 4); |
|
1332 |
nvlist_free(config); |
|
1333 |
} |
|
1334 |
} |
|
1335 |
||
1336 |
/*ARGSUSED*/ |
|
2199 | 1337 |
static int |
789 | 1338 |
dump_one_dir(char *dsname, void *arg) |
1339 |
{ |
|
1340 |
int error; |
|
1341 |
objset_t *os; |
|
1342 |
||
1343 |
error = dmu_objset_open(dsname, DMU_OST_ANY, |
|
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
1344 |
DS_MODE_USER | DS_MODE_READONLY, &os); |
789 | 1345 |
if (error) { |
1346 |
(void) printf("Could not open %s\n", dsname); |
|
2199 | 1347 |
return (0); |
789 | 1348 |
} |
1349 |
dump_dir(os); |
|
1350 |
dmu_objset_close(os); |
|
5959
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
1351 |
fuid_table_destroy(); |
2199 | 1352 |
return (0); |
789 | 1353 |
} |
1354 |
||
1355 |
static void |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
1356 |
zdb_leak(space_map_t *sm, uint64_t start, uint64_t size) |
789 | 1357 |
{ |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
1358 |
vdev_t *vd = sm->sm_ppd; |
789 | 1359 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
1360 |
(void) printf("leaked space: vdev %llu, offset 0x%llx, size %llu\n", |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
1361 |
(u_longlong_t)vd->vdev_id, (u_longlong_t)start, (u_longlong_t)size); |
789 | 1362 |
} |
1363 |
||
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
1364 |
/* ARGSUSED */ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
1365 |
static void |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
1366 |
zdb_space_map_load(space_map_t *sm) |
789 | 1367 |
{ |
1368 |
} |
|
1369 |
||
1370 |
static void |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
1371 |
zdb_space_map_unload(space_map_t *sm) |
789 | 1372 |
{ |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
1373 |
space_map_vacate(sm, zdb_leak, sm); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
1374 |
} |
789 | 1375 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
1376 |
/* ARGSUSED */ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
1377 |
static void |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
1378 |
zdb_space_map_claim(space_map_t *sm, uint64_t start, uint64_t size) |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
1379 |
{ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
1380 |
} |
789 | 1381 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
1382 |
static space_map_ops_t zdb_space_map_ops = { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
1383 |
zdb_space_map_load, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
1384 |
zdb_space_map_unload, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
1385 |
NULL, /* alloc */ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
1386 |
zdb_space_map_claim, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
1387 |
NULL /* free */ |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
1388 |
}; |
789 | 1389 |
|
1390 |
static void |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
1391 |
zdb_leak_init(spa_t *spa) |
789 | 1392 |
{ |
1393 |
vdev_t *rvd = spa->spa_root_vdev; |
|
1394 |
||
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
1395 |
for (int c = 0; c < rvd->vdev_children; c++) { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
1396 |
vdev_t *vd = rvd->vdev_child[c]; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
1397 |
for (int m = 0; m < vd->vdev_ms_count; m++) { |
789 | 1398 |
metaslab_t *msp = vd->vdev_ms[m]; |
1399 |
mutex_enter(&msp->ms_lock); |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
1400 |
VERIFY(space_map_load(&msp->ms_map, &zdb_space_map_ops, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
1401 |
SM_ALLOC, &msp->ms_smo, spa->spa_meta_objset) == 0); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
1402 |
msp->ms_map.sm_ppd = vd; |
789 | 1403 |
mutex_exit(&msp->ms_lock); |
1404 |
} |
|
1405 |
} |
|
1406 |
} |
|
1407 |
||
1408 |
static void |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
1409 |
zdb_leak_fini(spa_t *spa) |
789 | 1410 |
{ |
1411 |
vdev_t *rvd = spa->spa_root_vdev; |
|
1412 |
||
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
1413 |
for (int c = 0; c < rvd->vdev_children; c++) { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
1414 |
vdev_t *vd = rvd->vdev_child[c]; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
1415 |
for (int m = 0; m < vd->vdev_ms_count; m++) { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
1416 |
metaslab_t *msp = vd->vdev_ms[m]; |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
1417 |
mutex_enter(&msp->ms_lock); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
1418 |
space_map_unload(&msp->ms_map); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
1419 |
mutex_exit(&msp->ms_lock); |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
1420 |
} |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
1421 |
} |
789 | 1422 |
} |
1423 |
||
1424 |
/* |
|
1425 |
* Verify that the sum of the sizes of all blocks in the pool adds up |
|
1426 |
* to the SPA's sa_alloc total. |
|
1427 |
*/ |
|
1428 |
typedef struct zdb_blkstats { |
|
1429 |
uint64_t zb_asize; |
|
1430 |
uint64_t zb_lsize; |
|
1431 |
uint64_t zb_psize; |
|
1432 |
uint64_t zb_count; |
|
1433 |
} zdb_blkstats_t; |
|
1434 |
||
1435 |
#define DMU_OT_DEFERRED DMU_OT_NONE |
|
1436 |
#define DMU_OT_TOTAL DMU_OT_NUMTYPES |
|
1437 |
||
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1438 |
#define ZB_TOTAL DN_MAX_LEVELS |
789 | 1439 |
|
1440 |
typedef struct zdb_cb { |
|
1441 |
zdb_blkstats_t zcb_type[ZB_TOTAL + 1][DMU_OT_TOTAL + 1]; |
|
1442 |
uint64_t zcb_errors[256]; |
|
1443 |
int zcb_readfails; |
|
1444 |
int zcb_haderrors; |
|
1445 |
} zdb_cb_t; |
|
1446 |
||
1447 |
static void |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1448 |
zdb_count_block(spa_t *spa, zdb_cb_t *zcb, blkptr_t *bp, dmu_object_type_t type) |
789 | 1449 |
{ |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
1450 |
for (int i = 0; i < 4; i++) { |
789 | 1451 |
int l = (i < 2) ? BP_GET_LEVEL(bp) : ZB_TOTAL; |
1452 |
int t = (i & 1) ? type : DMU_OT_TOTAL; |
|
1453 |
zdb_blkstats_t *zb = &zcb->zcb_type[l][t]; |
|
1454 |
||
1455 |
zb->zb_asize += BP_GET_ASIZE(bp); |
|
1456 |
zb->zb_lsize += BP_GET_LSIZE(bp); |
|
1457 |
zb->zb_psize += BP_GET_PSIZE(bp); |
|
1458 |
zb->zb_count++; |
|
1459 |
} |
|
1460 |
||
6217
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
1461 |
if (dump_opt['S']) { |
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
1462 |
boolean_t print_sig; |
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
1463 |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1464 |
print_sig = !zdb_sig_user_data || (BP_GET_LEVEL(bp) == 0 && |
6217
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
1465 |
BP_GET_TYPE(bp) == DMU_OT_PLAIN_FILE_CONTENTS); |
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
1466 |
|
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
1467 |
if (BP_GET_CHECKSUM(bp) < zdb_sig_cksumalg) |
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
1468 |
print_sig = B_FALSE; |
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
1469 |
|
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
1470 |
if (print_sig) { |
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
1471 |
(void) printf("%llu\t%lld\t%lld\t%s\t%s\t%s\t" |
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
1472 |
"%llx:%llx:%llx:%llx\n", |
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
1473 |
(u_longlong_t)BP_GET_LEVEL(bp), |
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
1474 |
(longlong_t)BP_GET_PSIZE(bp), |
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
1475 |
(longlong_t)BP_GET_NDVAS(bp), |
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
1476 |
dmu_ot[BP_GET_TYPE(bp)].ot_name, |
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
1477 |
zio_checksum_table[BP_GET_CHECKSUM(bp)].ci_name, |
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
1478 |
zio_compress_table[BP_GET_COMPRESS(bp)].ci_name, |
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
1479 |
(u_longlong_t)bp->blk_cksum.zc_word[0], |
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
1480 |
(u_longlong_t)bp->blk_cksum.zc_word[1], |
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
1481 |
(u_longlong_t)bp->blk_cksum.zc_word[2], |
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
1482 |
(u_longlong_t)bp->blk_cksum.zc_word[3]); |
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
1483 |
} |
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
1484 |
} |
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
1485 |
|
8121
7fd09d4ebd9c
6757430 want an option for zdb to disable space map loading and leak tracking
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
7837
diff
changeset
|
1486 |
if (!dump_opt['L']) |
7fd09d4ebd9c
6757430 want an option for zdb to disable space map loading and leak tracking
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
7837
diff
changeset
|
1487 |
VERIFY(zio_wait(zio_claim(NULL, spa, spa_first_txg(spa), bp, |
7fd09d4ebd9c
6757430 want an option for zdb to disable space map loading and leak tracking
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
7837
diff
changeset
|
1488 |
NULL, NULL, ZIO_FLAG_MUSTSUCCEED)) == 0); |
789 | 1489 |
} |
1490 |
||
1491 |
static int |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1492 |
zdb_blkptr_cb(spa_t *spa, blkptr_t *bp, const zbookmark_t *zb, |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1493 |
const dnode_phys_t *dnp, void *arg) |
789 | 1494 |
{ |
1495 |
zdb_cb_t *zcb = arg; |
|
896 | 1496 |
char blkbuf[BP_SPRINTF_LEN]; |
789 | 1497 |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1498 |
if (bp == NULL) |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1499 |
return (0); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1500 |
|
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1501 |
zdb_count_block(spa, zcb, bp, BP_GET_TYPE(bp)); |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
1502 |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1503 |
if (dump_opt['c'] || dump_opt['S']) { |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1504 |
int ioerr, size; |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1505 |
void *data; |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
1506 |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1507 |
size = BP_GET_LSIZE(bp); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1508 |
data = malloc(size); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1509 |
ioerr = zio_wait(zio_read(NULL, spa, bp, data, size, |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1510 |
NULL, NULL, ZIO_PRIORITY_ASYNC_READ, |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1511 |
ZIO_FLAG_CANFAIL | ZIO_FLAG_SCRUB, zb)); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1512 |
free(data); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1513 |
|
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1514 |
/* We expect io errors on intent log */ |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1515 |
if (ioerr && BP_GET_TYPE(bp) != DMU_OT_INTENT_LOG) { |
789 | 1516 |
zcb->zcb_haderrors = 1; |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1517 |
zcb->zcb_errors[ioerr]++; |
789 | 1518 |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1519 |
if (dump_opt['b'] >= 2) |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1520 |
sprintf_blkptr(blkbuf, BP_SPRINTF_LEN, bp); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1521 |
else |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1522 |
blkbuf[0] = '\0'; |
789 | 1523 |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1524 |
if (!dump_opt['S']) { |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1525 |
(void) printf("zdb_blkptr_cb: " |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1526 |
"Got error %d reading " |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1527 |
"<%llu, %llu, %lld, %llx> %s -- skipping\n", |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1528 |
ioerr, |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1529 |
(u_longlong_t)zb->zb_objset, |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1530 |
(u_longlong_t)zb->zb_object, |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1531 |
(u_longlong_t)zb->zb_level, |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1532 |
(u_longlong_t)zb->zb_blkid, |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1533 |
blkbuf); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1534 |
} |
6217
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
1535 |
} |
789 | 1536 |
} |
1537 |
||
1538 |
zcb->zcb_readfails = 0; |
|
1539 |
||
1540 |
if (dump_opt['b'] >= 4) { |
|
896 | 1541 |
sprintf_blkptr(blkbuf, BP_SPRINTF_LEN, bp); |
789 | 1542 |
(void) printf("objset %llu object %llu offset 0x%llx %s\n", |
1543 |
(u_longlong_t)zb->zb_objset, |
|
1544 |
(u_longlong_t)zb->zb_object, |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1545 |
(u_longlong_t)blkid2offset(dnp, zb->zb_level, zb->zb_blkid), |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1546 |
blkbuf); |
789 | 1547 |
} |
1548 |
||
1549 |
return (0); |
|
1550 |
} |
|
1551 |
||
1552 |
static int |
|
1553 |
dump_block_stats(spa_t *spa) |
|
1554 |
{ |
|
1555 |
zdb_cb_t zcb = { 0 }; |
|
1556 |
zdb_blkstats_t *zb, *tzb; |
|
4527 | 1557 |
uint64_t alloc, space, logalloc; |
1558 |
vdev_t *rvd = spa->spa_root_vdev; |
|
789 | 1559 |
int leaks = 0; |
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1560 |
int c, e; |
789 | 1561 |
|
6217
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
1562 |
if (!dump_opt['S']) { |
8121
7fd09d4ebd9c
6757430 want an option for zdb to disable space map loading and leak tracking
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
7837
diff
changeset
|
1563 |
(void) printf("\nTraversing all blocks %s%s%s%s...\n", |
7fd09d4ebd9c
6757430 want an option for zdb to disable space map loading and leak tracking
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
7837
diff
changeset
|
1564 |
(dump_opt['c'] || !dump_opt['L']) ? "to verify " : "", |
7fd09d4ebd9c
6757430 want an option for zdb to disable space map loading and leak tracking
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
7837
diff
changeset
|
1565 |
dump_opt['c'] ? "checksums " : "", |
7fd09d4ebd9c
6757430 want an option for zdb to disable space map loading and leak tracking
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
7837
diff
changeset
|
1566 |
(dump_opt['c'] && !dump_opt['L']) ? "and verify " : "", |
7fd09d4ebd9c
6757430 want an option for zdb to disable space map loading and leak tracking
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
7837
diff
changeset
|
1567 |
!dump_opt['L'] ? "nothing leaked " : ""); |
6217
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
1568 |
} |
789 | 1569 |
|
1570 |
/* |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
1571 |
* Load all space maps as SM_ALLOC maps, then traverse the pool |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
1572 |
* claiming each block we discover. If the pool is perfectly |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
1573 |
* consistent, the space maps will be empty when we're done. |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
1574 |
* Anything left over is a leak; any block we can't claim (because |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
1575 |
* it's not part of any space map) is a double allocation, |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
1576 |
* reference to a freed block, or an unclaimed log block. |
789 | 1577 |
*/ |
8121
7fd09d4ebd9c
6757430 want an option for zdb to disable space map loading and leak tracking
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
7837
diff
changeset
|
1578 |
if (!dump_opt['L']) |
7fd09d4ebd9c
6757430 want an option for zdb to disable space map loading and leak tracking
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
7837
diff
changeset
|
1579 |
zdb_leak_init(spa); |
789 | 1580 |
|
1581 |
/* |
|
1582 |
* If there's a deferred-free bplist, process that first. |
|
1583 |
*/ |
|
1584 |
if (spa->spa_sync_bplist_obj != 0) { |
|
1585 |
bplist_t *bpl = &spa->spa_sync_bplist; |
|
1586 |
blkptr_t blk; |
|
1587 |
uint64_t itor = 0; |
|
1588 |
||
1544 | 1589 |
VERIFY(0 == bplist_open(bpl, spa->spa_meta_objset, |
1590 |
spa->spa_sync_bplist_obj)); |
|
789 | 1591 |
|
1592 |
while (bplist_iterate(bpl, &itor, &blk) == 0) { |
|
1593 |
if (dump_opt['b'] >= 4) { |
|
896 | 1594 |
char blkbuf[BP_SPRINTF_LEN]; |
1595 |
sprintf_blkptr(blkbuf, BP_SPRINTF_LEN, &blk); |
|
789 | 1596 |
(void) printf("[%s] %s\n", |
1597 |
"deferred free", blkbuf); |
|
1598 |
} |
|
1775
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1599 |
zdb_count_block(spa, &zcb, &blk, DMU_OT_DEFERRED); |
789 | 1600 |
} |
1601 |
||
1602 |
bplist_close(bpl); |
|
1603 |
} |
|
1604 |
||
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
1605 |
zcb.zcb_haderrors |= traverse_pool(spa, zdb_blkptr_cb, &zcb); |
789 | 1606 |
|
6217
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
1607 |
if (zcb.zcb_haderrors && !dump_opt['S']) { |
789 | 1608 |
(void) printf("\nError counts:\n\n"); |
1609 |
(void) printf("\t%5s %s\n", "errno", "count"); |
|
1610 |
for (e = 0; e < 256; e++) { |
|
1611 |
if (zcb.zcb_errors[e] != 0) { |
|
1612 |
(void) printf("\t%5d %llu\n", |
|
1613 |
e, (u_longlong_t)zcb.zcb_errors[e]); |
|
1614 |
} |
|
1615 |
} |
|
1616 |
} |
|
1617 |
||
1618 |
/* |
|
1619 |
* Report any leaked segments. |
|
1620 |
*/ |
|
8121
7fd09d4ebd9c
6757430 want an option for zdb to disable space map loading and leak tracking
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
7837
diff
changeset
|
1621 |
if (!dump_opt['L']) |
7fd09d4ebd9c
6757430 want an option for zdb to disable space map loading and leak tracking
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
7837
diff
changeset
|
1622 |
zdb_leak_fini(spa); |
789 | 1623 |
|
6217
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
1624 |
/* |
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
1625 |
* If we're interested in printing out the blkptr signatures, |
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
1626 |
* return now as we don't print out anything else (including |
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
1627 |
* errors and leaks). |
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
1628 |
*/ |
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
1629 |
if (dump_opt['S']) |
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
1630 |
return (zcb.zcb_haderrors ? 3 : 0); |
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
1631 |
|
789 | 1632 |
alloc = spa_get_alloc(spa); |
1633 |
space = spa_get_space(spa); |
|
1634 |
||
4527 | 1635 |
/* |
1636 |
* Log blocks allocated from a separate log device don't count |
|
1637 |
* as part of the normal pool space; factor them in here. |
|
1638 |
*/ |
|
1639 |
logalloc = 0; |
|
1640 |
||
1641 |
for (c = 0; c < rvd->vdev_children; c++) |
|
1642 |
if (rvd->vdev_child[c]->vdev_islog) |
|
1643 |
logalloc += rvd->vdev_child[c]->vdev_stat.vs_alloc; |
|
1644 |
||
789 | 1645 |
tzb = &zcb.zcb_type[ZB_TOTAL][DMU_OT_TOTAL]; |
1646 |
||
4527 | 1647 |
if (tzb->zb_asize == alloc + logalloc) { |
8121
7fd09d4ebd9c
6757430 want an option for zdb to disable space map loading and leak tracking
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
7837
diff
changeset
|
1648 |
if (!dump_opt['L']) |
7fd09d4ebd9c
6757430 want an option for zdb to disable space map loading and leak tracking
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
7837
diff
changeset
|
1649 |
(void) printf("\n\tNo leaks (block sum matches space" |
7fd09d4ebd9c
6757430 want an option for zdb to disable space map loading and leak tracking
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
7837
diff
changeset
|
1650 |
" maps exactly)\n"); |
789 | 1651 |
} else { |
1652 |
(void) printf("block traversal size %llu != alloc %llu " |
|
8121
7fd09d4ebd9c
6757430 want an option for zdb to disable space map loading and leak tracking
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
7837
diff
changeset
|
1653 |
"(%s %lld)\n", |
789 | 1654 |
(u_longlong_t)tzb->zb_asize, |
4527 | 1655 |
(u_longlong_t)alloc + logalloc, |
8121
7fd09d4ebd9c
6757430 want an option for zdb to disable space map loading and leak tracking
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
7837
diff
changeset
|
1656 |
(dump_opt['L']) ? "unreachable" : "leaked", |
7fd09d4ebd9c
6757430 want an option for zdb to disable space map loading and leak tracking
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
7837
diff
changeset
|
1657 |
(longlong_t)(alloc + logalloc - tzb->zb_asize)); |
789 | 1658 |
leaks = 1; |
1659 |
} |
|
1660 |
||
1661 |
if (tzb->zb_count == 0) |
|
1662 |
return (2); |
|
1663 |
||
1664 |
(void) printf("\n"); |
|
1665 |
(void) printf("\tbp count: %10llu\n", |
|
1666 |
(u_longlong_t)tzb->zb_count); |
|
1667 |
(void) printf("\tbp logical: %10llu\t avg: %6llu\n", |
|
1668 |
(u_longlong_t)tzb->zb_lsize, |
|
1669 |
(u_longlong_t)(tzb->zb_lsize / tzb->zb_count)); |
|
1670 |
(void) printf("\tbp physical: %10llu\t avg:" |
|
1671 |
" %6llu\tcompression: %6.2f\n", |
|
1672 |
(u_longlong_t)tzb->zb_psize, |
|
1673 |
(u_longlong_t)(tzb->zb_psize / tzb->zb_count), |
|
1674 |
(double)tzb->zb_lsize / tzb->zb_psize); |
|
1675 |
(void) printf("\tbp allocated: %10llu\t avg:" |
|
1676 |
" %6llu\tcompression: %6.2f\n", |
|
1677 |
(u_longlong_t)tzb->zb_asize, |
|
1678 |
(u_longlong_t)(tzb->zb_asize / tzb->zb_count), |
|
1679 |
(double)tzb->zb_lsize / tzb->zb_asize); |
|
1680 |
(void) printf("\tSPA allocated: %10llu\tused: %5.2f%%\n", |
|
1681 |
(u_longlong_t)alloc, 100.0 * alloc / space); |
|
1682 |
||
1683 |
if (dump_opt['b'] >= 2) { |
|
1684 |
int l, t, level; |
|
1685 |
(void) printf("\nBlocks\tLSIZE\tPSIZE\tASIZE" |
|
1686 |
"\t avg\t comp\t%%Total\tType\n"); |
|
1687 |
||
1688 |
for (t = 0; t <= DMU_OT_NUMTYPES; t++) { |
|
1689 |
char csize[6], lsize[6], psize[6], asize[6], avg[6]; |
|
1690 |
char *typename; |
|
1691 |
||
1692 |
typename = t == DMU_OT_DEFERRED ? "deferred free" : |
|
1693 |
t == DMU_OT_TOTAL ? "Total" : dmu_ot[t].ot_name; |
|
1694 |
||
1695 |
if (zcb.zcb_type[ZB_TOTAL][t].zb_asize == 0) { |
|
1696 |
(void) printf("%6s\t%5s\t%5s\t%5s" |
|
1697 |
"\t%5s\t%5s\t%6s\t%s\n", |
|
1698 |
"-", |
|
1699 |
"-", |
|
1700 |
"-", |
|
1701 |
"-", |
|
1702 |
"-", |
|
1703 |
"-", |
|
1704 |
"-", |
|
1705 |
typename); |
|
1706 |
continue; |
|
1707 |
} |
|
1708 |
||
1709 |
for (l = ZB_TOTAL - 1; l >= -1; l--) { |
|
1710 |
level = (l == -1 ? ZB_TOTAL : l); |
|
1711 |
zb = &zcb.zcb_type[level][t]; |
|
1712 |
||
1713 |
if (zb->zb_asize == 0) |
|
1714 |
continue; |
|
1715 |
||
1716 |
if (dump_opt['b'] < 3 && level != ZB_TOTAL) |
|
1717 |
continue; |
|
1718 |
||
1719 |
if (level == 0 && zb->zb_asize == |
|
1720 |
zcb.zcb_type[ZB_TOTAL][t].zb_asize) |
|
1721 |
continue; |
|
1722 |
||
1723 |
nicenum(zb->zb_count, csize); |
|
1724 |
nicenum(zb->zb_lsize, lsize); |
|
1725 |
nicenum(zb->zb_psize, psize); |
|
1726 |
nicenum(zb->zb_asize, asize); |
|
1727 |
nicenum(zb->zb_asize / zb->zb_count, avg); |
|
1728 |
||
1729 |
(void) printf("%6s\t%5s\t%5s\t%5s\t%5s" |
|
1730 |
"\t%5.2f\t%6.2f\t", |
|
1731 |
csize, lsize, psize, asize, avg, |
|
1732 |
(double)zb->zb_lsize / zb->zb_psize, |
|
1733 |
100.0 * zb->zb_asize / tzb->zb_asize); |
|
1734 |
||
1735 |
if (level == ZB_TOTAL) |
|
1736 |
(void) printf("%s\n", typename); |
|
1737 |
else |
|
1738 |
(void) printf(" L%d %s\n", |
|
1739 |
level, typename); |
|
1740 |
} |
|
1741 |
} |
|
1742 |
} |
|
1743 |
||
1744 |
(void) printf("\n"); |
|
1745 |
||
1746 |
if (leaks) |
|
1747 |
return (2); |
|
1748 |
||
1749 |
if (zcb.zcb_haderrors) |
|
1750 |
return (3); |
|
1751 |
||
1752 |
return (0); |
|
1753 |
} |
|
1754 |
||
1755 |
static void |
|
1756 |
dump_zpool(spa_t *spa) |
|
1757 |
{ |
|
1758 |
dsl_pool_t *dp = spa_get_dsl(spa); |
|
1759 |
int rc = 0; |
|
1760 |
||
1761 |
if (dump_opt['u']) |
|
1762 |
dump_uberblock(&spa->spa_uberblock); |
|
1763 |
||
1764 |
if (dump_opt['d'] || dump_opt['i']) { |
|
1765 |
dump_dir(dp->dp_meta_objset); |
|
1766 |
if (dump_opt['d'] >= 3) { |
|
1767 |
dump_bplist(dp->dp_meta_objset, |
|
1768 |
spa->spa_sync_bplist_obj, "Deferred frees"); |
|
1769 |
dump_dtl(spa->spa_root_vdev, 0); |
|
1770 |
dump_metaslabs(spa); |
|
1771 |
} |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
1772 |
(void) dmu_objset_find(spa_name(spa), dump_one_dir, NULL, |
2417 | 1773 |
DS_FIND_SNAPSHOTS | DS_FIND_CHILDREN); |
789 | 1774 |
} |
1775 |
||
6217
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
1776 |
if (dump_opt['b'] || dump_opt['c'] || dump_opt['S']) |
789 | 1777 |
rc = dump_block_stats(spa); |
1778 |
||
1779 |
if (dump_opt['s']) |
|
1780 |
show_pool_stats(spa); |
|
1781 |
||
1782 |
if (rc != 0) |
|
1783 |
exit(rc); |
|
1784 |
} |
|
1785 |
||
1775
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1786 |
#define ZDB_FLAG_CHECKSUM 0x0001 |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1787 |
#define ZDB_FLAG_DECOMPRESS 0x0002 |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1788 |
#define ZDB_FLAG_BSWAP 0x0004 |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1789 |
#define ZDB_FLAG_GBH 0x0008 |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1790 |
#define ZDB_FLAG_INDIRECT 0x0010 |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1791 |
#define ZDB_FLAG_PHYS 0x0020 |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1792 |
#define ZDB_FLAG_RAW 0x0040 |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1793 |
#define ZDB_FLAG_PRINT_BLKPTR 0x0080 |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1794 |
|
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1795 |
int flagbits[256]; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1796 |
|
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1797 |
static void |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1798 |
zdb_print_blkptr(blkptr_t *bp, int flags) |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1799 |
{ |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1800 |
dva_t *dva = bp->blk_dva; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1801 |
int d; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1802 |
|
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1803 |
if (flags & ZDB_FLAG_BSWAP) |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1804 |
byteswap_uint64_array((void *)bp, sizeof (blkptr_t)); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1805 |
/* |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1806 |
* Super-ick warning: This code is also duplicated in |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1807 |
* cmd/mdb/common/modules/zfs/zfs.c . Yeah, I hate code |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1808 |
* replication, too. |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1809 |
*/ |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1810 |
for (d = 0; d < BP_GET_NDVAS(bp); d++) { |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1811 |
(void) printf("\tDVA[%d]: vdev_id %lld / %llx\n", d, |
2856 | 1812 |
(longlong_t)DVA_GET_VDEV(&dva[d]), |
1813 |
(longlong_t)DVA_GET_OFFSET(&dva[d])); |
|
1775
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1814 |
(void) printf("\tDVA[%d]: GANG: %-5s GRID: %04llx\t" |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1815 |
"ASIZE: %llx\n", d, |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1816 |
DVA_GET_GANG(&dva[d]) ? "TRUE" : "FALSE", |
2856 | 1817 |
(longlong_t)DVA_GET_GRID(&dva[d]), |
1818 |
(longlong_t)DVA_GET_ASIZE(&dva[d])); |
|
1775
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1819 |
(void) printf("\tDVA[%d]: :%llu:%llx:%llx:%s%s%s%s\n", d, |
2856 | 1820 |
(u_longlong_t)DVA_GET_VDEV(&dva[d]), |
1821 |
(longlong_t)DVA_GET_OFFSET(&dva[d]), |
|
1822 |
(longlong_t)BP_GET_PSIZE(bp), |
|
1775
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1823 |
BP_SHOULD_BYTESWAP(bp) ? "e" : "", |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1824 |
!DVA_GET_GANG(&dva[d]) && BP_GET_LEVEL(bp) != 0 ? |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1825 |
"d" : "", |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1826 |
DVA_GET_GANG(&dva[d]) ? "g" : "", |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1827 |
BP_GET_COMPRESS(bp) != 0 ? "d" : ""); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1828 |
} |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1829 |
(void) printf("\tLSIZE: %-16llx\t\tPSIZE: %llx\n", |
2856 | 1830 |
(longlong_t)BP_GET_LSIZE(bp), (longlong_t)BP_GET_PSIZE(bp)); |
1775
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1831 |
(void) printf("\tENDIAN: %6s\t\t\t\t\tTYPE: %s\n", |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1832 |
BP_GET_BYTEORDER(bp) ? "LITTLE" : "BIG", |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1833 |
dmu_ot[BP_GET_TYPE(bp)].ot_name); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1834 |
(void) printf("\tBIRTH: %-16llx LEVEL: %-2llu\tFILL: %llx\n", |
2856 | 1835 |
(u_longlong_t)bp->blk_birth, (u_longlong_t)BP_GET_LEVEL(bp), |
1775
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1836 |
(u_longlong_t)bp->blk_fill); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1837 |
(void) printf("\tCKFUNC: %-16s\t\tCOMP: %s\n", |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1838 |
zio_checksum_table[BP_GET_CHECKSUM(bp)].ci_name, |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1839 |
zio_compress_table[BP_GET_COMPRESS(bp)].ci_name); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1840 |
(void) printf("\tCKSUM: %llx:%llx:%llx:%llx\n", |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1841 |
(u_longlong_t)bp->blk_cksum.zc_word[0], |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1842 |
(u_longlong_t)bp->blk_cksum.zc_word[1], |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1843 |
(u_longlong_t)bp->blk_cksum.zc_word[2], |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1844 |
(u_longlong_t)bp->blk_cksum.zc_word[3]); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1845 |
} |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1846 |
|
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1847 |
static void |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1848 |
zdb_dump_indirect(blkptr_t *bp, int nbps, int flags) |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1849 |
{ |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1850 |
int i; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1851 |
|
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1852 |
for (i = 0; i < nbps; i++) |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1853 |
zdb_print_blkptr(&bp[i], flags); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1854 |
} |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1855 |
|
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1856 |
static void |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1857 |
zdb_dump_gbh(void *buf, int flags) |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1858 |
{ |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1859 |
zdb_dump_indirect((blkptr_t *)buf, SPA_GBH_NBLKPTRS, flags); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1860 |
} |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1861 |
|
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1862 |
static void |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1863 |
zdb_dump_block_raw(void *buf, uint64_t size, int flags) |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1864 |
{ |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1865 |
if (flags & ZDB_FLAG_BSWAP) |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1866 |
byteswap_uint64_array(buf, size); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1867 |
(void) write(2, buf, size); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1868 |
} |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1869 |
|
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1870 |
static void |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1871 |
zdb_dump_block(char *label, void *buf, uint64_t size, int flags) |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1872 |
{ |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1873 |
uint64_t *d = (uint64_t *)buf; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1874 |
int nwords = size / sizeof (uint64_t); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1875 |
int do_bswap = !!(flags & ZDB_FLAG_BSWAP); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1876 |
int i, j; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1877 |
char *hdr, *c; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1878 |
|
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1879 |
|
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1880 |
if (do_bswap) |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1881 |
hdr = " 7 6 5 4 3 2 1 0 f e d c b a 9 8"; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1882 |
else |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1883 |
hdr = " 0 1 2 3 4 5 6 7 8 9 a b c d e f"; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1884 |
|
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1885 |
(void) printf("\n%s\n%6s %s 0123456789abcdef\n", label, "", hdr); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1886 |
|
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1887 |
for (i = 0; i < nwords; i += 2) { |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1888 |
(void) printf("%06llx: %016llx %016llx ", |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1889 |
(u_longlong_t)(i * sizeof (uint64_t)), |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1890 |
(u_longlong_t)(do_bswap ? BSWAP_64(d[i]) : d[i]), |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1891 |
(u_longlong_t)(do_bswap ? BSWAP_64(d[i + 1]) : d[i + 1])); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1892 |
|
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1893 |
c = (char *)&d[i]; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1894 |
for (j = 0; j < 2 * sizeof (uint64_t); j++) |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1895 |
(void) printf("%c", isprint(c[j]) ? c[j] : '.'); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1896 |
(void) printf("\n"); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1897 |
} |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1898 |
} |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1899 |
|
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1900 |
/* |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1901 |
* There are two acceptable formats: |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1902 |
* leaf_name - For example: c1t0d0 or /tmp/ztest.0a |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1903 |
* child[.child]* - For example: 0.1.1 |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1904 |
* |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1905 |
* The second form can be used to specify arbitrary vdevs anywhere |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1906 |
* in the heirarchy. For example, in a pool with a mirror of |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1907 |
* RAID-Zs, you can specify either RAID-Z vdev with 0.0 or 0.1 . |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1908 |
*/ |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1909 |
static vdev_t * |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1910 |
zdb_vdev_lookup(vdev_t *vdev, char *path) |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1911 |
{ |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1912 |
char *s, *p, *q; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1913 |
int i; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1914 |
|
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1915 |
if (vdev == NULL) |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1916 |
return (NULL); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1917 |
|
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1918 |
/* First, assume the x.x.x.x format */ |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1919 |
i = (int)strtoul(path, &s, 10); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1920 |
if (s == path || (s && *s != '.' && *s != '\0')) |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1921 |
goto name; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1922 |
if (i < 0 || i >= vdev->vdev_children) |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1923 |
return (NULL); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1924 |
|
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1925 |
vdev = vdev->vdev_child[i]; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1926 |
if (*s == '\0') |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1927 |
return (vdev); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1928 |
return (zdb_vdev_lookup(vdev, s+1)); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1929 |
|
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1930 |
name: |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1931 |
for (i = 0; i < vdev->vdev_children; i++) { |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1932 |
vdev_t *vc = vdev->vdev_child[i]; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1933 |
|
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1934 |
if (vc->vdev_path == NULL) { |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1935 |
vc = zdb_vdev_lookup(vc, path); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1936 |
if (vc == NULL) |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1937 |
continue; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1938 |
else |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1939 |
return (vc); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1940 |
} |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1941 |
|
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1942 |
p = strrchr(vc->vdev_path, '/'); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1943 |
p = p ? p + 1 : vc->vdev_path; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1944 |
q = &vc->vdev_path[strlen(vc->vdev_path) - 2]; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1945 |
|
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1946 |
if (strcmp(vc->vdev_path, path) == 0) |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1947 |
return (vc); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1948 |
if (strcmp(p, path) == 0) |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1949 |
return (vc); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1950 |
if (strcmp(q, "s0") == 0 && strncmp(p, path, q - p) == 0) |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1951 |
return (vc); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1952 |
} |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1953 |
|
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1954 |
return (NULL); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1955 |
} |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1956 |
|
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1957 |
/* |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1958 |
* Read a block from a pool and print it out. The syntax of the |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1959 |
* block descriptor is: |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1960 |
* |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1961 |
* pool:vdev_specifier:offset:size[:flags] |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1962 |
* |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1963 |
* pool - The name of the pool you wish to read from |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1964 |
* vdev_specifier - Which vdev (see comment for zdb_vdev_lookup) |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1965 |
* offset - offset, in hex, in bytes |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1966 |
* size - Amount of data to read, in hex, in bytes |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1967 |
* flags - A string of characters specifying options |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1968 |
* b: Decode a blkptr at given offset within block |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1969 |
* *c: Calculate and display checksums |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1970 |
* *d: Decompress data before dumping |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1971 |
* e: Byteswap data before dumping |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1972 |
* *g: Display data as a gang block header |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1973 |
* *i: Display as an indirect block |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1974 |
* p: Do I/O to physical offset |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1975 |
* r: Dump raw data to stdout |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1976 |
* |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1977 |
* * = not yet implemented |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1978 |
*/ |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1979 |
static void |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1980 |
zdb_read_block(char *thing, spa_t **spap) |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1981 |
{ |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1982 |
spa_t *spa = *spap; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1983 |
int flags = 0; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1984 |
uint64_t offset = 0, size = 0, blkptr_offset = 0; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1985 |
zio_t *zio; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1986 |
vdev_t *vd; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1987 |
void *buf; |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
1988 |
char *s, *p, *dup, *pool, *vdev, *flagstr; |
1775
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1989 |
int i, error, zio_flags; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1990 |
|
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1991 |
dup = strdup(thing); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1992 |
s = strtok(dup, ":"); |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
1993 |
pool = s ? s : ""; |
1775
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1994 |
s = strtok(NULL, ":"); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1995 |
vdev = s ? s : ""; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1996 |
s = strtok(NULL, ":"); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1997 |
offset = strtoull(s ? s : "", NULL, 16); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1998 |
s = strtok(NULL, ":"); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
1999 |
size = strtoull(s ? s : "", NULL, 16); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2000 |
s = strtok(NULL, ":"); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2001 |
flagstr = s ? s : ""; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2002 |
|
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2003 |
s = NULL; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2004 |
if (size == 0) |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2005 |
s = "size must not be zero"; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2006 |
if (!IS_P2ALIGNED(size, DEV_BSIZE)) |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2007 |
s = "size must be a multiple of sector size"; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2008 |
if (!IS_P2ALIGNED(offset, DEV_BSIZE)) |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2009 |
s = "offset must be a multiple of sector size"; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2010 |
if (s) { |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2011 |
(void) printf("Invalid block specifier: %s - %s\n", thing, s); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2012 |
free(dup); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2013 |
return; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2014 |
} |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2015 |
|
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2016 |
for (s = strtok(flagstr, ":"); s; s = strtok(NULL, ":")) { |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2017 |
for (i = 0; flagstr[i]; i++) { |
2856 | 2018 |
int bit = flagbits[(uchar_t)flagstr[i]]; |
1775
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2019 |
|
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2020 |
if (bit == 0) { |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2021 |
(void) printf("***Invalid flag: %c\n", |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2022 |
flagstr[i]); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2023 |
continue; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2024 |
} |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2025 |
flags |= bit; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2026 |
|
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2027 |
/* If it's not something with an argument, keep going */ |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2028 |
if ((bit & (ZDB_FLAG_CHECKSUM | ZDB_FLAG_DECOMPRESS | |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2029 |
ZDB_FLAG_PRINT_BLKPTR)) == 0) |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2030 |
continue; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2031 |
|
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2032 |
p = &flagstr[i + 1]; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2033 |
if (bit == ZDB_FLAG_PRINT_BLKPTR) |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2034 |
blkptr_offset = strtoull(p, &p, 16); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2035 |
if (*p != ':' && *p != '\0') { |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2036 |
(void) printf("***Invalid flag arg: '%s'\n", s); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2037 |
free(dup); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2038 |
return; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2039 |
} |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2040 |
} |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2041 |
} |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2042 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
2043 |
if (spa == NULL || strcmp(spa_name(spa), pool) != 0) { |
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
2044 |
if (spa) |
1775
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2045 |
spa_close(spa, (void *)zdb_read_block); |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
2046 |
error = spa_open(pool, spap, (void *)zdb_read_block); |
1775
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2047 |
if (error) |
4070
4390ea390a1e
6386594 zdb message should be clearer when failing for lack of permissions
mc142369
parents:
3912
diff
changeset
|
2048 |
fatal("Failed to open pool '%s': %s", |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
2049 |
pool, strerror(error)); |
1775
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2050 |
spa = *spap; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2051 |
} |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2052 |
|
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2053 |
vd = zdb_vdev_lookup(spa->spa_root_vdev, vdev); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2054 |
if (vd == NULL) { |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2055 |
(void) printf("***Invalid vdev: %s\n", vdev); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2056 |
free(dup); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2057 |
return; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2058 |
} else { |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2059 |
if (vd->vdev_path) |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2060 |
(void) printf("Found vdev: %s\n", vd->vdev_path); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2061 |
else |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2062 |
(void) printf("Found vdev type: %s\n", |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2063 |
vd->vdev_ops->vdev_op_type); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2064 |
} |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2065 |
|
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2066 |
buf = umem_alloc(size, UMEM_NOFAIL); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2067 |
|
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2068 |
zio_flags = ZIO_FLAG_DONT_CACHE | ZIO_FLAG_DONT_QUEUE | |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
2069 |
ZIO_FLAG_DONT_PROPAGATE | ZIO_FLAG_DONT_RETRY; |
1775
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2070 |
|
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
2071 |
spa_config_enter(spa, SCL_STATE, FTAG, RW_READER); |
1775
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2072 |
zio = zio_root(spa, NULL, NULL, 0); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2073 |
/* XXX todo - cons up a BP so RAID-Z will be happy */ |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2074 |
zio_nowait(zio_vdev_child_io(zio, NULL, vd, offset, buf, size, |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2075 |
ZIO_TYPE_READ, ZIO_PRIORITY_SYNC_READ, zio_flags, NULL, NULL)); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2076 |
error = zio_wait(zio); |
7754
b80e4842ad54
6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents:
7390
diff
changeset
|
2077 |
spa_config_exit(spa, SCL_STATE, FTAG); |
1775
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2078 |
|
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2079 |
if (error) { |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2080 |
(void) printf("Read of %s failed, error: %d\n", thing, error); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2081 |
goto out; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2082 |
} |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2083 |
|
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2084 |
if (flags & ZDB_FLAG_PRINT_BLKPTR) |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2085 |
zdb_print_blkptr((blkptr_t *)(void *) |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2086 |
((uintptr_t)buf + (uintptr_t)blkptr_offset), flags); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2087 |
else if (flags & ZDB_FLAG_RAW) |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2088 |
zdb_dump_block_raw(buf, size, flags); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2089 |
else if (flags & ZDB_FLAG_INDIRECT) |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2090 |
zdb_dump_indirect((blkptr_t *)buf, size / sizeof (blkptr_t), |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2091 |
flags); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2092 |
else if (flags & ZDB_FLAG_GBH) |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2093 |
zdb_dump_gbh(buf, flags); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2094 |
else |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2095 |
zdb_dump_block(thing, buf, size, flags); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2096 |
|
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2097 |
out: |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2098 |
umem_free(buf, size); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2099 |
free(dup); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2100 |
} |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2101 |
|
4627
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2102 |
static boolean_t |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2103 |
nvlist_string_match(nvlist_t *config, char *name, char *tgt) |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2104 |
{ |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2105 |
char *s; |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2106 |
|
6643
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
2107 |
if (nvlist_lookup_string(config, name, &s) != 0) |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
2108 |
return (B_FALSE); |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
2109 |
|
4627
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2110 |
return (strcmp(s, tgt) == 0); |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2111 |
} |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2112 |
|
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2113 |
static boolean_t |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2114 |
nvlist_uint64_match(nvlist_t *config, char *name, uint64_t tgt) |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2115 |
{ |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2116 |
uint64_t val; |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2117 |
|
6643
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
2118 |
if (nvlist_lookup_uint64(config, name, &val) != 0) |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
2119 |
return (B_FALSE); |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
2120 |
|
4627
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2121 |
return (val == tgt); |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2122 |
} |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2123 |
|
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2124 |
static boolean_t |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2125 |
vdev_child_guid_match(nvlist_t *vdev, uint64_t guid) |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2126 |
{ |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2127 |
nvlist_t **child; |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2128 |
uint_t c, children; |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2129 |
|
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2130 |
verify(nvlist_lookup_nvlist_array(vdev, ZPOOL_CONFIG_CHILDREN, |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2131 |
&child, &children) == 0); |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2132 |
for (c = 0; c < children; ++c) |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2133 |
if (nvlist_uint64_match(child[c], ZPOOL_CONFIG_GUID, guid)) |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2134 |
return (B_TRUE); |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2135 |
return (B_FALSE); |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2136 |
} |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2137 |
|
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2138 |
static boolean_t |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2139 |
vdev_child_string_match(nvlist_t *vdev, char *tgt) |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2140 |
{ |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2141 |
nvlist_t **child; |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2142 |
uint_t c, children; |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2143 |
|
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2144 |
verify(nvlist_lookup_nvlist_array(vdev, ZPOOL_CONFIG_CHILDREN, |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2145 |
&child, &children) == 0); |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2146 |
for (c = 0; c < children; ++c) { |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2147 |
if (nvlist_string_match(child[c], ZPOOL_CONFIG_PATH, tgt) || |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2148 |
nvlist_string_match(child[c], ZPOOL_CONFIG_DEVID, tgt)) |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2149 |
return (B_TRUE); |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2150 |
} |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2151 |
return (B_FALSE); |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2152 |
} |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2153 |
|
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2154 |
static boolean_t |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2155 |
vdev_guid_match(nvlist_t *config, uint64_t guid) |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2156 |
{ |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2157 |
nvlist_t *nvroot; |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2158 |
|
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2159 |
verify(nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE, |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2160 |
&nvroot) == 0); |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2161 |
|
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2162 |
return (nvlist_uint64_match(nvroot, ZPOOL_CONFIG_GUID, guid) || |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2163 |
vdev_child_guid_match(nvroot, guid)); |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2164 |
} |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2165 |
|
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2166 |
static boolean_t |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2167 |
vdev_string_match(nvlist_t *config, char *tgt) |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2168 |
{ |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2169 |
nvlist_t *nvroot; |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2170 |
|
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2171 |
verify(nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE, |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2172 |
&nvroot) == 0); |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2173 |
|
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2174 |
return (vdev_child_string_match(nvroot, tgt)); |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2175 |
} |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2176 |
|
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2177 |
static boolean_t |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2178 |
pool_match(nvlist_t *config, char *tgt) |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2179 |
{ |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2180 |
uint64_t guid = strtoull(tgt, NULL, 0); |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2181 |
|
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2182 |
if (guid != 0) { |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2183 |
return ( |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2184 |
nvlist_uint64_match(config, ZPOOL_CONFIG_POOL_GUID, guid) || |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2185 |
vdev_guid_match(config, guid)); |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2186 |
} else { |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2187 |
return ( |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2188 |
nvlist_string_match(config, ZPOOL_CONFIG_POOL_NAME, tgt) || |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2189 |
vdev_string_match(config, tgt)); |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2190 |
} |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2191 |
} |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2192 |
|
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2193 |
static int |
6957
ad855bd47277
6689844 ztest fails with "zdb: can't open ztest: No such device or address"
ck153898
parents:
6807
diff
changeset
|
2194 |
find_exported_zpool(char *pool_id, nvlist_t **configp, char *vdev_dir) |
4627
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2195 |
{ |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2196 |
nvlist_t *pools; |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2197 |
int error = ENOENT; |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2198 |
nvlist_t *match = NULL; |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2199 |
|
6957
ad855bd47277
6689844 ztest fails with "zdb: can't open ztest: No such device or address"
ck153898
parents:
6807
diff
changeset
|
2200 |
if (vdev_dir != NULL) |
6807
1564ba2e93f5
6689452 zfs often fails to import a zpool if several zfs import commands are running at the same time.
ck153898
parents:
6689
diff
changeset
|
2201 |
pools = zpool_find_import_activeok(g_zfs, 1, &vdev_dir); |
6957
ad855bd47277
6689844 ztest fails with "zdb: can't open ztest: No such device or address"
ck153898
parents:
6807
diff
changeset
|
2202 |
else |
6807
1564ba2e93f5
6689452 zfs often fails to import a zpool if several zfs import commands are running at the same time.
ck153898
parents:
6689
diff
changeset
|
2203 |
pools = zpool_find_import_activeok(g_zfs, 0, NULL); |
4627
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2204 |
|
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2205 |
if (pools != NULL) { |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2206 |
nvpair_t *elem = NULL; |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2207 |
|
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2208 |
while ((elem = nvlist_next_nvpair(pools, elem)) != NULL) { |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2209 |
verify(nvpair_value_nvlist(elem, configp) == 0); |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2210 |
if (pool_match(*configp, pool_id)) { |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2211 |
if (match != NULL) { |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2212 |
(void) fatal( |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2213 |
"More than one matching pool - " |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2214 |
"specify guid/devid/device path."); |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2215 |
} else { |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2216 |
match = *configp; |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2217 |
error = 0; |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2218 |
} |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2219 |
} |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2220 |
} |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2221 |
} |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2222 |
|
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2223 |
*configp = error ? NULL : match; |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2224 |
|
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2225 |
return (error); |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2226 |
} |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2227 |
|
789 | 2228 |
int |
2229 |
main(int argc, char **argv) |
|
2230 |
{ |
|
2231 |
int i, c; |
|
2232 |
struct rlimit rl = { 1024, 1024 }; |
|
2233 |
spa_t *spa; |
|
2234 |
objset_t *os = NULL; |
|
2235 |
char *endstr; |
|
2236 |
int dump_all = 1; |
|
2237 |
int verbose = 0; |
|
2238 |
int error; |
|
4627
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2239 |
int exported = 0; |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2240 |
char *vdev_dir = NULL; |
789 | 2241 |
|
2242 |
(void) setrlimit(RLIMIT_NOFILE, &rl); |
|
1914
8a8c5f225b1b
4916205 libcmd should not use file operation routines from C library
casper
parents:
1807
diff
changeset
|
2243 |
(void) enable_extended_FILE_stdio(-1, -1); |
789 | 2244 |
|
2245 |
dprintf_setup(&argc, argv); |
|
2246 |
||
8121
7fd09d4ebd9c
6757430 want an option for zdb to disable space map loading and leak tracking
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
7837
diff
changeset
|
2247 |
while ((c = getopt(argc, argv, "udibcsvCLS:U:lRep:")) != -1) { |
789 | 2248 |
switch (c) { |
2249 |
case 'u': |
|
2250 |
case 'd': |
|
2251 |
case 'i': |
|
2252 |
case 'b': |
|
2253 |
case 'c': |
|
2254 |
case 's': |
|
2255 |
case 'C': |
|
2256 |
case 'l': |
|
1775
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2257 |
case 'R': |
789 | 2258 |
dump_opt[c]++; |
2259 |
dump_all = 0; |
|
2260 |
break; |
|
8121
7fd09d4ebd9c
6757430 want an option for zdb to disable space map loading and leak tracking
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
7837
diff
changeset
|
2261 |
case 'L': |
7fd09d4ebd9c
6757430 want an option for zdb to disable space map loading and leak tracking
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
7837
diff
changeset
|
2262 |
dump_opt[c]++; |
7fd09d4ebd9c
6757430 want an option for zdb to disable space map loading and leak tracking
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents:
7837
diff
changeset
|
2263 |
break; |
789 | 2264 |
case 'v': |
2265 |
verbose++; |
|
2266 |
break; |
|
2267 |
case 'U': |
|
6957
ad855bd47277
6689844 ztest fails with "zdb: can't open ztest: No such device or address"
ck153898
parents:
6807
diff
changeset
|
2268 |
spa_config_path = optarg; |
789 | 2269 |
break; |
4627
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2270 |
case 'e': |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2271 |
exported = 1; |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2272 |
break; |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2273 |
case 'p': |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2274 |
vdev_dir = optarg; |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2275 |
break; |
6217
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
2276 |
case 'S': |
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
2277 |
dump_opt[c]++; |
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
2278 |
dump_all = 0; |
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
2279 |
zdb_sig_user_data = (strncmp(optarg, "user:", 5) == 0); |
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
2280 |
if (!zdb_sig_user_data && strncmp(optarg, "all:", 4)) |
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
2281 |
usage(); |
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
2282 |
endstr = strchr(optarg, ':') + 1; |
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
2283 |
if (strcmp(endstr, "fletcher2") == 0) |
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
2284 |
zdb_sig_cksumalg = ZIO_CHECKSUM_FLETCHER_2; |
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
2285 |
else if (strcmp(endstr, "fletcher4") == 0) |
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
2286 |
zdb_sig_cksumalg = ZIO_CHECKSUM_FLETCHER_4; |
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
2287 |
else if (strcmp(endstr, "sha256") == 0) |
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
2288 |
zdb_sig_cksumalg = ZIO_CHECKSUM_SHA256; |
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
2289 |
else if (strcmp(endstr, "all") == 0) |
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
2290 |
zdb_sig_cksumalg = ZIO_CHECKSUM_FLETCHER_2; |
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
2291 |
else |
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
2292 |
usage(); |
40ffa8cc1b75
6656655 zdb should be able to display blkptr signatures
ek110237
parents:
5994
diff
changeset
|
2293 |
break; |
789 | 2294 |
default: |
2295 |
usage(); |
|
2296 |
break; |
|
2297 |
} |
|
2298 |
} |
|
2299 |
||
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
2300 |
if (vdev_dir != NULL && exported == 0) { |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
2301 |
(void) fprintf(stderr, "-p option requires use of -e\n"); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
2302 |
usage(); |
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
2303 |
} |
4627
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2304 |
|
789 | 2305 |
kernel_init(FREAD); |
4627
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2306 |
g_zfs = libzfs_init(); |
4787 | 2307 |
ASSERT(g_zfs != NULL); |
789 | 2308 |
|
2309 |
for (c = 0; c < 256; c++) { |
|
7837
001de5627df3
6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents:
7754
diff
changeset
|
2310 |
if (dump_all && c != 'l' && c != 'R') |
789 | 2311 |
dump_opt[c] = 1; |
2312 |
if (dump_opt[c]) |
|
2313 |
dump_opt[c] += verbose; |
|
2314 |
} |
|
2315 |
||
2316 |
argc -= optind; |
|
2317 |
argv += optind; |
|
2318 |
||
2319 |
if (argc < 1) { |
|
2320 |
if (dump_opt['C']) { |
|
6957
ad855bd47277
6689844 ztest fails with "zdb: can't open ztest: No such device or address"
ck153898
parents:
6807
diff
changeset
|
2321 |
dump_cachefile(spa_config_path); |
789 | 2322 |
return (0); |
2323 |
} |
|
2324 |
usage(); |
|
2325 |
} |
|
2326 |
||
2327 |
if (dump_opt['l']) { |
|
2328 |
dump_label(argv[0]); |
|
2329 |
return (0); |
|
2330 |
} |
|
2331 |
||
1775
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2332 |
if (dump_opt['R']) { |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2333 |
flagbits['b'] = ZDB_FLAG_PRINT_BLKPTR; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2334 |
flagbits['c'] = ZDB_FLAG_CHECKSUM; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2335 |
flagbits['d'] = ZDB_FLAG_DECOMPRESS; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2336 |
flagbits['e'] = ZDB_FLAG_BSWAP; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2337 |
flagbits['g'] = ZDB_FLAG_GBH; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2338 |
flagbits['i'] = ZDB_FLAG_INDIRECT; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2339 |
flagbits['p'] = ZDB_FLAG_PHYS; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2340 |
flagbits['r'] = ZDB_FLAG_RAW; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2341 |
|
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2342 |
spa = NULL; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2343 |
while (argv[0]) { |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2344 |
zdb_read_block(argv[0], &spa); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2345 |
argv++; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2346 |
argc--; |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2347 |
} |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2348 |
if (spa) |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2349 |
spa_close(spa, (void *)zdb_read_block); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2350 |
return (0); |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2351 |
} |
e51e26b432c0
6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents:
1732
diff
changeset
|
2352 |
|
789 | 2353 |
if (dump_opt['C']) |
2354 |
dump_config(argv[0]); |
|
2355 |
||
6643
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
2356 |
error = 0; |
6957
ad855bd47277
6689844 ztest fails with "zdb: can't open ztest: No such device or address"
ck153898
parents:
6807
diff
changeset
|
2357 |
if (exported) { |
4627
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2358 |
/* |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2359 |
* Check to see if the name refers to an exported zpool |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2360 |
*/ |
6643
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
2361 |
char *slash; |
4627
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2362 |
nvlist_t *exported_conf = NULL; |
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2363 |
|
6643
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
2364 |
if ((slash = strchr(argv[0], '/')) != NULL) |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
2365 |
*slash = '\0'; |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
2366 |
|
6957
ad855bd47277
6689844 ztest fails with "zdb: can't open ztest: No such device or address"
ck153898
parents:
6807
diff
changeset
|
2367 |
error = find_exported_zpool(argv[0], &exported_conf, vdev_dir); |
4627
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2368 |
if (error == 0) { |
5094 | 2369 |
nvlist_t *nvl = NULL; |
2370 |
||
2371 |
if (vdev_dir != NULL) { |
|
2372 |
if (nvlist_alloc(&nvl, NV_UNIQUE_NAME, 0) != 0) |
|
2373 |
error = ENOMEM; |
|
2374 |
else if (nvlist_add_string(nvl, |
|
2375 |
zpool_prop_to_name(ZPOOL_PROP_ALTROOT), |
|
2376 |
vdev_dir) != 0) |
|
2377 |
error = ENOMEM; |
|
2378 |
} |
|
2379 |
||
2380 |
if (error == 0) |
|
6643
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
2381 |
error = spa_import_faulted(argv[0], |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
2382 |
exported_conf, nvl); |
5094 | 2383 |
|
2384 |
nvlist_free(nvl); |
|
4627
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2385 |
} |
6643
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
2386 |
|
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
2387 |
if (slash != NULL) |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
2388 |
*slash = '/'; |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
2389 |
} |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
2390 |
|
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
2391 |
if (error == 0) { |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
2392 |
if (strchr(argv[0], '/') != NULL) { |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
2393 |
error = dmu_objset_open(argv[0], DMU_OST_ANY, |
6689
47572a2f5e73
6610506 Eliminate or improve retry logic from callers of dmu_objset_open()
maybee
parents:
6643
diff
changeset
|
2394 |
DS_MODE_USER | DS_MODE_READONLY, &os); |
6643
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
2395 |
} else { |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
2396 |
error = spa_open(argv[0], &spa, FTAG); |
3a34b0dbb107
6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents:
6423
diff
changeset
|
2397 |
} |
789 | 2398 |
} |
2399 |
||
2400 |
if (error) |
|
4070
4390ea390a1e
6386594 zdb message should be clearer when failing for lack of permissions
mc142369
parents:
3912
diff
changeset
|
2401 |
fatal("can't open %s: %s", argv[0], strerror(error)); |
789 | 2402 |
|
2403 |
argv++; |
|
2404 |
if (--argc > 0) { |
|
2405 |
zopt_objects = argc; |
|
2406 |
zopt_object = calloc(zopt_objects, sizeof (uint64_t)); |
|
2407 |
for (i = 0; i < zopt_objects; i++) { |
|
2408 |
errno = 0; |
|
2409 |
zopt_object[i] = strtoull(argv[i], NULL, 0); |
|
2410 |
if (zopt_object[i] == 0 && errno != 0) |
|
2411 |
fatal("bad object number %s: %s", |
|
2412 |
argv[i], strerror(errno)); |
|
2413 |
} |
|
2414 |
} |
|
2415 |
||
2416 |
if (os != NULL) { |
|
2417 |
dump_dir(os); |
|
2418 |
dmu_objset_close(os); |
|
2419 |
} else { |
|
2420 |
dump_zpool(spa); |
|
2421 |
spa_close(spa, FTAG); |
|
2422 |
} |
|
2423 |
||
5959
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
2424 |
fuid_table_destroy(); |
1e1904b8526d
6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents:
5530
diff
changeset
|
2425 |
|
4627
c85631613c19
6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents:
4577
diff
changeset
|
2426 |
libzfs_fini(g_zfs); |
789 | 2427 |
kernel_fini(); |
2428 |
||
2429 |
return (0); |
|
2430 |
} |