annotate usr/src/cmd/zdb/zdb.c @ 13765:9410cf539b11

backout 3006: causes 3046 (panics after mounting root)
author Richard Lowe <richlowe@richlowe.net>
date Wed, 01 Aug 2012 16:40:39 -0400
parents 38b4aca480b3
children a9c12c2c1647
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2 * CDDL HEADER START
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
4 * The contents of this file are subject to the terms of the
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1170
diff changeset
5 * Common Development and Distribution License (the "License").
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1170
diff changeset
6 * You may not use this file except in compliance with the License.
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
7 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
9 * or http://www.opensolaris.org/os/licensing.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
10 * See the License for the specific language governing permissions
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
11 * and limitations under the License.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
12 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
13 * When distributing Covered Code, include this CDDL HEADER in each
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
15 * If applicable, add the following below this CDDL HEADER, with the
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
16 * fields enclosed by brackets "[]" replaced with your own identifying
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
17 * information: Portions Copyright [yyyy] [name of copyright owner]
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
18 *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
19 * CDDL HEADER END
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
20 */
13700
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
21
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
22 /*
12050
5879aa161e65 6938757 SMB and NFS referrals not working correctly
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11935
diff changeset
23 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
13700
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
24 * Copyright (c) 2012 by Delphix. All rights reserved.
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
25 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
26
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
27 #include <stdio.h>
1914
8a8c5f225b1b 4916205 libcmd should not use file operation routines from C library
casper
parents: 1807
diff changeset
28 #include <stdio_ext.h>
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
29 #include <stdlib.h>
1775
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
30 #include <ctype.h>
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
31 #include <sys/zfs_context.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
32 #include <sys/spa.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
33 #include <sys/spa_impl.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
34 #include <sys/dmu.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
35 #include <sys/zap.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
36 #include <sys/fs/zfs.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
37 #include <sys/zfs_znode.h>
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
38 #include <sys/zfs_sa.h>
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
39 #include <sys/sa.h>
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
40 #include <sys/sa_impl.h>
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
41 #include <sys/vdev.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
42 #include <sys/vdev_impl.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
43 #include <sys/metaslab_impl.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
44 #include <sys/dmu_objset.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
45 #include <sys/dsl_dir.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
46 #include <sys/dsl_dataset.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
47 #include <sys/dsl_pool.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
48 #include <sys/dbuf.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
49 #include <sys/zil.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
50 #include <sys/zil_impl.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
51 #include <sys/stat.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
52 #include <sys/resource.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
53 #include <sys/dmu_traverse.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
54 #include <sys/zio_checksum.h>
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
55 #include <sys/zio_compress.h>
5959
1e1904b8526d 6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents: 5530
diff changeset
56 #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
57 #include <sys/arc.h>
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
58 #include <sys/ddt.h>
13700
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
59 #include <sys/zfeature.h>
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
60 #include <zfs_comutil.h>
4627
c85631613c19 6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents: 4577
diff changeset
61 #undef ZFS_MAXNAMELEN
c85631613c19 6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents: 4577
diff changeset
62 #undef verify
c85631613c19 6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents: 4577
diff changeset
63 #include <libzfs.h>
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
64
10859
ea699e57196e 6761101 zdb/mdb crashes when printing bp with bad checksum, compress or type
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10858
diff changeset
65 #define ZDB_COMPRESS_NAME(idx) ((idx) < ZIO_COMPRESS_FUNCTIONS ? \
ea699e57196e 6761101 zdb/mdb crashes when printing bp with bad checksum, compress or type
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10858
diff changeset
66 zio_compress_table[(idx)].ci_name : "UNKNOWN")
ea699e57196e 6761101 zdb/mdb crashes when printing bp with bad checksum, compress or type
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10858
diff changeset
67 #define ZDB_CHECKSUM_NAME(idx) ((idx) < ZIO_CHECKSUM_FUNCTIONS ? \
ea699e57196e 6761101 zdb/mdb crashes when printing bp with bad checksum, compress or type
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10858
diff changeset
68 zio_checksum_table[(idx)].ci_name : "UNKNOWN")
ea699e57196e 6761101 zdb/mdb crashes when printing bp with bad checksum, compress or type
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10858
diff changeset
69 #define ZDB_OT_NAME(idx) ((idx) < DMU_OT_NUMTYPES ? \
13700
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
70 dmu_ot[(idx)].ot_name : DMU_OT_IS_VALID(idx) ? \
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
71 dmu_ot_byteswap[DMU_OT_BYTESWAP(idx)].ob_name : "UNKNOWN")
10859
ea699e57196e 6761101 zdb/mdb crashes when printing bp with bad checksum, compress or type
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10858
diff changeset
72 #define ZDB_OT_TYPE(idx) ((idx) < DMU_OT_NUMTYPES ? (idx) : DMU_OT_NUMTYPES)
ea699e57196e 6761101 zdb/mdb crashes when printing bp with bad checksum, compress or type
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10858
diff changeset
73
11726
9686f6127423 6896791 want zdb option to set aok and zfs_recover
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11725
diff changeset
74 #ifndef lint
9686f6127423 6896791 want zdb option to set aok and zfs_recover
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11725
diff changeset
75 extern int zfs_recover;
9686f6127423 6896791 want zdb option to set aok and zfs_recover
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11725
diff changeset
76 #else
9686f6127423 6896791 want zdb option to set aok and zfs_recover
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11725
diff changeset
77 int zfs_recover;
9686f6127423 6896791 want zdb option to set aok and zfs_recover
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11725
diff changeset
78 #endif
9686f6127423 6896791 want zdb option to set aok and zfs_recover
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11725
diff changeset
79
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
80 const char cmdname[] = "zdb";
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
81 uint8_t dump_opt[256];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
82
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
83 typedef void object_viewer_t(objset_t *, uint64_t, void *data, size_t size);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
84
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
85 extern void dump_intent_log(zilog_t *);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
86 uint64_t *zopt_object = NULL;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
87 int zopt_objects = 0;
4627
c85631613c19 6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents: 4577
diff changeset
88 libzfs_handle_t *g_zfs;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
89
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
90 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
91 * These libumem hooks provide a reasonable set of defaults for the allocator's
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
92 * debugging facilities.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
93 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
94 const char *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
95 _umem_debug_init()
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
96 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
97 return ("default,verbose"); /* $UMEM_DEBUG setting */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
98 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
99
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
100 const char *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
101 _umem_logging_init(void)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
102 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
103 return ("fail,contents"); /* $UMEM_LOGGING setting */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
104 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
105
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
106 static void
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
107 usage(void)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
108 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
109 (void) fprintf(stderr,
13618
c6ae14a341e8 2088 zdb could use a reasonable manual page
Richard Lowe <richlowe@richlowe.net>
parents: 12961
diff changeset
110 "Usage: %s [-CumdibcsDvhLXFPA] [-t txg] [-e [-p path...]] "
c6ae14a341e8 2088 zdb could use a reasonable manual page
Richard Lowe <richlowe@richlowe.net>
parents: 12961
diff changeset
111 "poolname [object...]\n"
c6ae14a341e8 2088 zdb could use a reasonable manual page
Richard Lowe <richlowe@richlowe.net>
parents: 12961
diff changeset
112 " %s [-divPA] [-e -p path...] dataset [object...]\n"
c6ae14a341e8 2088 zdb could use a reasonable manual page
Richard Lowe <richlowe@richlowe.net>
parents: 12961
diff changeset
113 " %s -m [-LXFPA] [-t txg] [-e [-p path...]] "
c6ae14a341e8 2088 zdb could use a reasonable manual page
Richard Lowe <richlowe@richlowe.net>
parents: 12961
diff changeset
114 "poolname [vdev [metaslab...]]\n"
c6ae14a341e8 2088 zdb could use a reasonable manual page
Richard Lowe <richlowe@richlowe.net>
parents: 12961
diff changeset
115 " %s -R [-A] [-e [-p path...]] poolname "
c6ae14a341e8 2088 zdb could use a reasonable manual page
Richard Lowe <richlowe@richlowe.net>
parents: 12961
diff changeset
116 "vdev:offset:size[:flags]\n"
c6ae14a341e8 2088 zdb could use a reasonable manual page
Richard Lowe <richlowe@richlowe.net>
parents: 12961
diff changeset
117 " %s -S [-PA] [-e [-p path...]] poolname\n"
c6ae14a341e8 2088 zdb could use a reasonable manual page
Richard Lowe <richlowe@richlowe.net>
parents: 12961
diff changeset
118 " %s -l [-uA] device\n"
c6ae14a341e8 2088 zdb could use a reasonable manual page
Richard Lowe <richlowe@richlowe.net>
parents: 12961
diff changeset
119 " %s -C [-A] [-U config]\n\n",
11125
fca3e6d28599 6899923 vdev_offline/vdev_add deadlock
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10922
diff changeset
120 cmdname, cmdname, cmdname, cmdname, cmdname, cmdname, cmdname);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
121
10858
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
122 (void) fprintf(stderr, " Dataset name must include at least one "
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
123 "separator character '/' or '@'\n");
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
124 (void) fprintf(stderr, " If dataset name is specified, only that "
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
125 "dataset is dumped\n");
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
126 (void) fprintf(stderr, " If object numbers are specified, only "
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
127 "those objects are dumped\n\n");
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
128 (void) fprintf(stderr, " Options to control amount of output:\n");
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
129 (void) fprintf(stderr, " -u uberblock\n");
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
130 (void) fprintf(stderr, " -d dataset(s)\n");
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
131 (void) fprintf(stderr, " -i intent logs\n");
10860
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
132 (void) fprintf(stderr, " -C config (or cachefile if alone)\n");
10685
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
133 (void) fprintf(stderr, " -h pool history\n");
10858
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
134 (void) fprintf(stderr, " -b block statistics\n");
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
135 (void) fprintf(stderr, " -m metaslabs\n");
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
136 (void) fprintf(stderr, " -c checksum all metadata (twice for "
9463
d0bd231c7518 6764124 want zdb to be able to checksum metadata blocks only
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 9425
diff changeset
137 "all data) blocks\n");
10858
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
138 (void) fprintf(stderr, " -s report stats on zdb's I/O\n");
11811
b25d9f1b5d8e 6914746 sprintf_blkptr() causes NULL pointer dereference
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 11728
diff changeset
139 (void) fprintf(stderr, " -D dedup statistics\n");
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
140 (void) fprintf(stderr, " -S simulate dedup to measure effect\n");
10858
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
141 (void) fprintf(stderr, " -v verbose (applies to all others)\n");
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
142 (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
143 (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
144 "load spacemaps)\n");
10858
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
145 (void) fprintf(stderr, " -R read and display block from a "
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
146 "device\n\n");
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
147 (void) fprintf(stderr, " Below options are intended for use "
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
148 "with other options (except -l):\n");
11726
9686f6127423 6896791 want zdb option to set aok and zfs_recover
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11725
diff changeset
149 (void) fprintf(stderr, " -A ignore assertions (-A), enable "
9686f6127423 6896791 want zdb option to set aok and zfs_recover
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11725
diff changeset
150 "panic recovery (-AA) or both (-AAA)\n");
11727
497d03ab2824 6900971 zdb rewind behavior needs to be revisited
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11726
diff changeset
151 (void) fprintf(stderr, " -F attempt automatic rewind within "
497d03ab2824 6900971 zdb rewind behavior needs to be revisited
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11726
diff changeset
152 "safe range of transaction groups\n");
10858
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
153 (void) fprintf(stderr, " -U <cachefile_path> -- use alternate "
5994
bedab011a2e5 6580270 'zdb [-C|-L] <pool'> can't open alternate root pools
ck153898
parents: 5959
diff changeset
154 "cachefile\n");
11727
497d03ab2824 6900971 zdb rewind behavior needs to be revisited
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11726
diff changeset
155 (void) fprintf(stderr, " -X attempt extreme rewind (does not "
497d03ab2824 6900971 zdb rewind behavior needs to be revisited
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11726
diff changeset
156 "work with dataset)\n");
10858
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
157 (void) fprintf(stderr, " -e pool is exported/destroyed/"
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
158 "has altroot/not in a cachefile\n");
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
159 (void) fprintf(stderr, " -p <path> -- use one or more with "
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
160 "-e to specify path to vdev dir\n");
13618
c6ae14a341e8 2088 zdb could use a reasonable manual page
Richard Lowe <richlowe@richlowe.net>
parents: 12961
diff changeset
161 (void) fprintf(stderr, " -P print numbers in parseable form\n");
10858
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
162 (void) fprintf(stderr, " -t <txg> -- highest txg to use when "
8188
fd00c0a81e80 6761100 want zdb option to select older uberblocks
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 8121
diff changeset
163 "searching for uberblocks\n");
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
164 (void) fprintf(stderr, "Specify an option more than once (e.g. -bb) "
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
165 "to make only that option verbose\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
166 (void) fprintf(stderr, "Default is to dump everything non-verbosely\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
167 exit(1);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
168 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
169
8924
5af812f84759 6789318 coredump when issue zdb -uuuu poolname/
Rich Morris <Richard.Morris@Sun.COM>
parents: 8241
diff changeset
170 /*
5af812f84759 6789318 coredump when issue zdb -uuuu poolname/
Rich Morris <Richard.Morris@Sun.COM>
parents: 8241
diff changeset
171 * Called for usage errors that are discovered after a call to spa_open(),
5af812f84759 6789318 coredump when issue zdb -uuuu poolname/
Rich Morris <Richard.Morris@Sun.COM>
parents: 8241
diff changeset
172 * dmu_bonus_hold(), or pool_match(). abort() is called for other errors.
5af812f84759 6789318 coredump when issue zdb -uuuu poolname/
Rich Morris <Richard.Morris@Sun.COM>
parents: 8241
diff changeset
173 */
5af812f84759 6789318 coredump when issue zdb -uuuu poolname/
Rich Morris <Richard.Morris@Sun.COM>
parents: 8241
diff changeset
174
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
175 static void
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
176 fatal(const char *fmt, ...)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
177 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
178 va_list ap;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
179
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
180 va_start(ap, fmt);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
181 (void) fprintf(stderr, "%s: ", cmdname);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
182 (void) vfprintf(stderr, fmt, ap);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
183 va_end(ap);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
184 (void) fprintf(stderr, "\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
185
8924
5af812f84759 6789318 coredump when issue zdb -uuuu poolname/
Rich Morris <Richard.Morris@Sun.COM>
parents: 8241
diff changeset
186 exit(1);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
187 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
188
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
189 /* ARGSUSED */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
190 static void
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
191 dump_packed_nvlist(objset_t *os, uint64_t object, void *data, size_t size)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
192 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
193 nvlist_t *nv;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
194 size_t nvsize = *(uint64_t *)data;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
195 char *packed = umem_alloc(nvsize, UMEM_NOFAIL);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
196
9512
64cafcbcc337 6801810 Commit of aligned streaming rewrites to ZIL device causes unwanted disk reads
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 9480
diff changeset
197 VERIFY(0 == dmu_read(os, object, 0, nvsize, packed, DMU_READ_PREFETCH));
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
198
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
199 VERIFY(nvlist_unpack(packed, nvsize, &nv, 0) == 0);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
200
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
201 umem_free(packed, nvsize);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
202
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
203 dump_nvlist(nv, 8);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
204
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
205 nvlist_free(nv);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
206 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
207
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
208 /* ARGSUSED */
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
209 static void
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
210 dump_history_offsets(objset_t *os, uint64_t object, void *data, size_t size)
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
211 {
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
212 spa_history_phys_t *shp = data;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
213
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
214 if (shp == NULL)
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
215 return;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
216
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
217 (void) printf("\t\tpool_create_len = %llu\n",
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
218 (u_longlong_t)shp->sh_pool_create_len);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
219 (void) printf("\t\tphys_max_off = %llu\n",
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
220 (u_longlong_t)shp->sh_phys_max_off);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
221 (void) printf("\t\tbof = %llu\n",
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
222 (u_longlong_t)shp->sh_bof);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
223 (void) printf("\t\teof = %llu\n",
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
224 (u_longlong_t)shp->sh_eof);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
225 (void) printf("\t\trecords_lost = %llu\n",
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
226 (u_longlong_t)shp->sh_records_lost);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
227 }
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
228
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
229 static void
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
230 zdb_nicenum(uint64_t num, char *buf)
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
231 {
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
232 if (dump_opt['P'])
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
233 (void) sprintf(buf, "%llu", (longlong_t)num);
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
234 else
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
235 nicenum(num, buf);
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
236 }
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
237
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
238 const char dump_zap_stars[] = "****************************************";
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
239 const int dump_zap_width = sizeof (dump_zap_stars) - 1;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
240
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
241 static void
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
242 dump_zap_histogram(uint64_t histo[ZAP_HISTOGRAM_SIZE])
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
243 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
244 int i;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
245 int minidx = ZAP_HISTOGRAM_SIZE - 1;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
246 int maxidx = 0;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
247 uint64_t max = 0;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
248
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
249 for (i = 0; i < ZAP_HISTOGRAM_SIZE; i++) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
250 if (histo[i] > max)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
251 max = histo[i];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
252 if (histo[i] > 0 && i > maxidx)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
253 maxidx = i;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
254 if (histo[i] > 0 && i < minidx)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
255 minidx = i;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
256 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
257
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
258 if (max < dump_zap_width)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
259 max = dump_zap_width;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
260
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
261 for (i = minidx; i <= maxidx; i++)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
262 (void) printf("\t\t\t%u: %6llu %s\n", i, (u_longlong_t)histo[i],
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
263 &dump_zap_stars[(max - histo[i]) * dump_zap_width / max]);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
264 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
265
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
266 static void
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
267 dump_zap_stats(objset_t *os, uint64_t object)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
268 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
269 int error;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
270 zap_stats_t zs;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
271
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
272 error = zap_get_stats(os, object, &zs);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
273 if (error)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
274 return;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
275
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
276 if (zs.zs_ptrtbl_len == 0) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
277 ASSERT(zs.zs_num_blocks == 1);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
278 (void) printf("\tmicrozap: %llu bytes, %llu entries\n",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
279 (u_longlong_t)zs.zs_blocksize,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
280 (u_longlong_t)zs.zs_num_entries);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
281 return;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
282 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
283
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
284 (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
285
7d486ebd46b7 6392291 zdb needs to tell the entire goodness of the fat zap
nd150628
parents: 1578
diff changeset
286 (void) printf("\t\tPointer table:\n");
7d486ebd46b7 6392291 zdb needs to tell the entire goodness of the fat zap
nd150628
parents: 1578
diff changeset
287 (void) printf("\t\t\t%llu elements\n",
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
288 (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
289 (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
290 (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
291 (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
292 (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
293 (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
294 (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
295 (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
296 (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
297 (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
298 (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
299
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
300 (void) printf("\t\tZAP entries: %llu\n",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
301 (u_longlong_t)zs.zs_num_entries);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
302 (void) printf("\t\tLeaf blocks: %llu\n",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
303 (u_longlong_t)zs.zs_num_leafs);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
304 (void) printf("\t\tTotal blocks: %llu\n",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
305 (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
306 (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
307 (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
308 (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
309 (u_longlong_t)zs.zs_magic);
7d486ebd46b7 6392291 zdb needs to tell the entire goodness of the fat zap
nd150628
parents: 1578
diff changeset
310 (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
311 (u_longlong_t)zs.zs_salt);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
312
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
313 (void) printf("\t\tLeafs with 2^n pointers:\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
314 dump_zap_histogram(zs.zs_leafs_with_2n_pointers);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
315
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
316 (void) printf("\t\tBlocks with n*5 entries:\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
317 dump_zap_histogram(zs.zs_blocks_with_n5_entries);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
318
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
319 (void) printf("\t\tBlocks n/10 full:\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
320 dump_zap_histogram(zs.zs_blocks_n_tenths_full);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
321
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
322 (void) printf("\t\tEntries with n chunks:\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
323 dump_zap_histogram(zs.zs_entries_using_n_chunks);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
324
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
325 (void) printf("\t\tBuckets with n entries:\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
326 dump_zap_histogram(zs.zs_buckets_with_n_entries);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
327 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
328
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
329 /*ARGSUSED*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
330 static void
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
331 dump_none(objset_t *os, uint64_t object, void *data, size_t size)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
332 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
333 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
334
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
335 /*ARGSUSED*/
10859
ea699e57196e 6761101 zdb/mdb crashes when printing bp with bad checksum, compress or type
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10858
diff changeset
336 static void
ea699e57196e 6761101 zdb/mdb crashes when printing bp with bad checksum, compress or type
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10858
diff changeset
337 dump_unknown(objset_t *os, uint64_t object, void *data, size_t size)
ea699e57196e 6761101 zdb/mdb crashes when printing bp with bad checksum, compress or type
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10858
diff changeset
338 {
ea699e57196e 6761101 zdb/mdb crashes when printing bp with bad checksum, compress or type
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10858
diff changeset
339 (void) printf("\tUNKNOWN OBJECT TYPE\n");
ea699e57196e 6761101 zdb/mdb crashes when printing bp with bad checksum, compress or type
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10858
diff changeset
340 }
ea699e57196e 6761101 zdb/mdb crashes when printing bp with bad checksum, compress or type
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10858
diff changeset
341
ea699e57196e 6761101 zdb/mdb crashes when printing bp with bad checksum, compress or type
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10858
diff changeset
342 /*ARGSUSED*/
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
343 void
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
344 dump_uint8(objset_t *os, uint64_t object, void *data, size_t size)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
345 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
346 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
347
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
348 /*ARGSUSED*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
349 static void
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
350 dump_uint64(objset_t *os, uint64_t object, void *data, size_t size)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
351 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
352 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
353
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
354 /*ARGSUSED*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
355 static void
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
356 dump_zap(objset_t *os, uint64_t object, void *data, size_t size)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
357 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
358 zap_cursor_t zc;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
359 zap_attribute_t attr;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
360 void *prop;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
361 int i;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
362
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
363 dump_zap_stats(os, object);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
364 (void) printf("\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
365
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
366 for (zap_cursor_init(&zc, os, object);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
367 zap_cursor_retrieve(&zc, &attr) == 0;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
368 zap_cursor_advance(&zc)) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
369 (void) printf("\t\t%s = ", attr.za_name);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
370 if (attr.za_num_integers == 0) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
371 (void) printf("\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
372 continue;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
373 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
374 prop = umem_zalloc(attr.za_num_integers *
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
375 attr.za_integer_length, UMEM_NOFAIL);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
376 (void) zap_lookup(os, object, attr.za_name,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
377 attr.za_integer_length, attr.za_num_integers, prop);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
378 if (attr.za_integer_length == 1) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
379 (void) printf("%s", (char *)prop);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
380 } else {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
381 for (i = 0; i < attr.za_num_integers; i++) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
382 switch (attr.za_integer_length) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
383 case 2:
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
384 (void) printf("%u ",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
385 ((uint16_t *)prop)[i]);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
386 break;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
387 case 4:
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
388 (void) printf("%u ",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
389 ((uint32_t *)prop)[i]);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
390 break;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
391 case 8:
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
392 (void) printf("%lld ",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
393 (u_longlong_t)((int64_t *)prop)[i]);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
394 break;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
395 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
396 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
397 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
398 (void) printf("\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
399 umem_free(prop, attr.za_num_integers * attr.za_integer_length);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
400 }
885
d925b21dba78 6347493 tar of 25K empty directory entries in ZFS takes 30+ seconds ...
ahrens
parents: 789
diff changeset
401 zap_cursor_fini(&zc);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
402 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
403
4577
ed36b0e652bc PSARC/2007/328 zfs upgrade
ahrens
parents: 4543
diff changeset
404 /*ARGSUSED*/
ed36b0e652bc PSARC/2007/328 zfs upgrade
ahrens
parents: 4543
diff changeset
405 static void
11165
68184eb5449e 6903705 dedup=fletcher4,verify doesn't byteswap correctly, has lots of hash collisions
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11149
diff changeset
406 dump_ddt_zap(objset_t *os, uint64_t object, void *data, size_t size)
68184eb5449e 6903705 dedup=fletcher4,verify doesn't byteswap correctly, has lots of hash collisions
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11149
diff changeset
407 {
68184eb5449e 6903705 dedup=fletcher4,verify doesn't byteswap correctly, has lots of hash collisions
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11149
diff changeset
408 dump_zap_stats(os, object);
68184eb5449e 6903705 dedup=fletcher4,verify doesn't byteswap correctly, has lots of hash collisions
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11149
diff changeset
409 /* contents are printed elsewhere, properly decoded */
68184eb5449e 6903705 dedup=fletcher4,verify doesn't byteswap correctly, has lots of hash collisions
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11149
diff changeset
410 }
68184eb5449e 6903705 dedup=fletcher4,verify doesn't byteswap correctly, has lots of hash collisions
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11149
diff changeset
411
68184eb5449e 6903705 dedup=fletcher4,verify doesn't byteswap correctly, has lots of hash collisions
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11149
diff changeset
412 /*ARGSUSED*/
68184eb5449e 6903705 dedup=fletcher4,verify doesn't byteswap correctly, has lots of hash collisions
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11149
diff changeset
413 static void
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
414 dump_sa_attrs(objset_t *os, uint64_t object, void *data, size_t size)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
415 {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
416 zap_cursor_t zc;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
417 zap_attribute_t attr;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
418
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
419 dump_zap_stats(os, object);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
420 (void) printf("\n");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
421
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
422 for (zap_cursor_init(&zc, os, object);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
423 zap_cursor_retrieve(&zc, &attr) == 0;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
424 zap_cursor_advance(&zc)) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
425 (void) printf("\t\t%s = ", attr.za_name);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
426 if (attr.za_num_integers == 0) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
427 (void) printf("\n");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
428 continue;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
429 }
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
430 (void) printf(" %llx : [%d:%d:%d]\n",
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
431 (u_longlong_t)attr.za_first_integer,
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
432 (int)ATTR_LENGTH(attr.za_first_integer),
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
433 (int)ATTR_BSWAP(attr.za_first_integer),
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
434 (int)ATTR_NUM(attr.za_first_integer));
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
435 }
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
436 zap_cursor_fini(&zc);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
437 }
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
438
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
439 /*ARGSUSED*/
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
440 static void
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
441 dump_sa_layouts(objset_t *os, uint64_t object, void *data, size_t size)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
442 {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
443 zap_cursor_t zc;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
444 zap_attribute_t attr;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
445 uint16_t *layout_attrs;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
446 int i;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
447
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
448 dump_zap_stats(os, object);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
449 (void) printf("\n");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
450
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
451 for (zap_cursor_init(&zc, os, object);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
452 zap_cursor_retrieve(&zc, &attr) == 0;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
453 zap_cursor_advance(&zc)) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
454 (void) printf("\t\t%s = [", attr.za_name);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
455 if (attr.za_num_integers == 0) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
456 (void) printf("\n");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
457 continue;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
458 }
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
459
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
460 VERIFY(attr.za_integer_length == 2);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
461 layout_attrs = umem_zalloc(attr.za_num_integers *
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
462 attr.za_integer_length, UMEM_NOFAIL);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
463
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
464 VERIFY(zap_lookup(os, object, attr.za_name,
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
465 attr.za_integer_length,
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
466 attr.za_num_integers, layout_attrs) == 0);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
467
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
468 for (i = 0; i != attr.za_num_integers; i++)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
469 (void) printf(" %d ", (int)layout_attrs[i]);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
470 (void) printf("]\n");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
471 umem_free(layout_attrs,
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
472 attr.za_num_integers * attr.za_integer_length);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
473 }
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
474 zap_cursor_fini(&zc);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
475 }
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
476
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
477 /*ARGSUSED*/
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
478 static void
4577
ed36b0e652bc PSARC/2007/328 zfs upgrade
ahrens
parents: 4543
diff changeset
479 dump_zpldir(objset_t *os, uint64_t object, void *data, size_t size)
ed36b0e652bc PSARC/2007/328 zfs upgrade
ahrens
parents: 4543
diff changeset
480 {
ed36b0e652bc PSARC/2007/328 zfs upgrade
ahrens
parents: 4543
diff changeset
481 zap_cursor_t zc;
ed36b0e652bc PSARC/2007/328 zfs upgrade
ahrens
parents: 4543
diff changeset
482 zap_attribute_t attr;
ed36b0e652bc PSARC/2007/328 zfs upgrade
ahrens
parents: 4543
diff changeset
483 const char *typenames[] = {
ed36b0e652bc PSARC/2007/328 zfs upgrade
ahrens
parents: 4543
diff changeset
484 /* 0 */ "not specified",
ed36b0e652bc PSARC/2007/328 zfs upgrade
ahrens
parents: 4543
diff changeset
485 /* 1 */ "FIFO",
ed36b0e652bc PSARC/2007/328 zfs upgrade
ahrens
parents: 4543
diff changeset
486 /* 2 */ "Character Device",
ed36b0e652bc PSARC/2007/328 zfs upgrade
ahrens
parents: 4543
diff changeset
487 /* 3 */ "3 (invalid)",
ed36b0e652bc PSARC/2007/328 zfs upgrade
ahrens
parents: 4543
diff changeset
488 /* 4 */ "Directory",
ed36b0e652bc PSARC/2007/328 zfs upgrade
ahrens
parents: 4543
diff changeset
489 /* 5 */ "5 (invalid)",
ed36b0e652bc PSARC/2007/328 zfs upgrade
ahrens
parents: 4543
diff changeset
490 /* 6 */ "Block Device",
ed36b0e652bc PSARC/2007/328 zfs upgrade
ahrens
parents: 4543
diff changeset
491 /* 7 */ "7 (invalid)",
ed36b0e652bc PSARC/2007/328 zfs upgrade
ahrens
parents: 4543
diff changeset
492 /* 8 */ "Regular File",
ed36b0e652bc PSARC/2007/328 zfs upgrade
ahrens
parents: 4543
diff changeset
493 /* 9 */ "9 (invalid)",
ed36b0e652bc PSARC/2007/328 zfs upgrade
ahrens
parents: 4543
diff changeset
494 /* 10 */ "Symbolic Link",
ed36b0e652bc PSARC/2007/328 zfs upgrade
ahrens
parents: 4543
diff changeset
495 /* 11 */ "11 (invalid)",
ed36b0e652bc PSARC/2007/328 zfs upgrade
ahrens
parents: 4543
diff changeset
496 /* 12 */ "Socket",
ed36b0e652bc PSARC/2007/328 zfs upgrade
ahrens
parents: 4543
diff changeset
497 /* 13 */ "Door",
ed36b0e652bc PSARC/2007/328 zfs upgrade
ahrens
parents: 4543
diff changeset
498 /* 14 */ "Event Port",
ed36b0e652bc PSARC/2007/328 zfs upgrade
ahrens
parents: 4543
diff changeset
499 /* 15 */ "15 (invalid)",
ed36b0e652bc PSARC/2007/328 zfs upgrade
ahrens
parents: 4543
diff changeset
500 };
ed36b0e652bc PSARC/2007/328 zfs upgrade
ahrens
parents: 4543
diff changeset
501
ed36b0e652bc PSARC/2007/328 zfs upgrade
ahrens
parents: 4543
diff changeset
502 dump_zap_stats(os, object);
ed36b0e652bc PSARC/2007/328 zfs upgrade
ahrens
parents: 4543
diff changeset
503 (void) printf("\n");
ed36b0e652bc PSARC/2007/328 zfs upgrade
ahrens
parents: 4543
diff changeset
504
ed36b0e652bc PSARC/2007/328 zfs upgrade
ahrens
parents: 4543
diff changeset
505 for (zap_cursor_init(&zc, os, object);
ed36b0e652bc PSARC/2007/328 zfs upgrade
ahrens
parents: 4543
diff changeset
506 zap_cursor_retrieve(&zc, &attr) == 0;
ed36b0e652bc PSARC/2007/328 zfs upgrade
ahrens
parents: 4543
diff changeset
507 zap_cursor_advance(&zc)) {
ed36b0e652bc PSARC/2007/328 zfs upgrade
ahrens
parents: 4543
diff changeset
508 (void) printf("\t\t%s = %lld (type: %s)\n",
ed36b0e652bc PSARC/2007/328 zfs upgrade
ahrens
parents: 4543
diff changeset
509 attr.za_name, ZFS_DIRENT_OBJ(attr.za_first_integer),
ed36b0e652bc PSARC/2007/328 zfs upgrade
ahrens
parents: 4543
diff changeset
510 typenames[ZFS_DIRENT_TYPE(attr.za_first_integer)]);
ed36b0e652bc PSARC/2007/328 zfs upgrade
ahrens
parents: 4543
diff changeset
511 }
ed36b0e652bc PSARC/2007/328 zfs upgrade
ahrens
parents: 4543
diff changeset
512 zap_cursor_fini(&zc);
ed36b0e652bc PSARC/2007/328 zfs upgrade
ahrens
parents: 4543
diff changeset
513 }
ed36b0e652bc PSARC/2007/328 zfs upgrade
ahrens
parents: 4543
diff changeset
514
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
515 static void
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
516 dump_spacemap(objset_t *os, space_map_obj_t *smo, space_map_t *sm)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
517 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
518 uint64_t alloc, offset, entry;
1732
9e3ae798af31 6280668 pluggable block allocation policy
bonwick
parents: 1731
diff changeset
519 uint8_t mapshift = sm->sm_shift;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
520 uint64_t mapstart = sm->sm_start;
3361
a3d194896a76 6480230 ::walk spa|::walk zms_freelist cause mdb to core dump
ck153898
parents: 3060
diff changeset
521 char *ddata[] = { "ALLOC", "FREE", "CONDENSE", "INVALID",
a3d194896a76 6480230 ::walk spa|::walk zms_freelist cause mdb to core dump
ck153898
parents: 3060
diff changeset
522 "INVALID", "INVALID", "INVALID", "INVALID" };
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
523
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
524 if (smo->smo_object == 0)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
525 return;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
526
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
527 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
528 * Print out the freelist entries in both encoded and decoded form.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
529 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
530 alloc = 0;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
531 for (offset = 0; offset < smo->smo_objsize; offset += sizeof (entry)) {
13765
9410cf539b11 backout 3006: causes 3046 (panics after mounting root)
Richard Lowe <richlowe@richlowe.net>
parents: 13764
diff changeset
532 VERIFY3U(0, ==, dmu_read(os, smo->smo_object, offset,
9512
64cafcbcc337 6801810 Commit of aligned streaming rewrites to ZIL device causes unwanted disk reads
Neil Perrin <Neil.Perrin@Sun.COM>
parents: 9480
diff changeset
533 sizeof (entry), &entry, DMU_READ_PREFETCH));
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
534 if (SM_DEBUG_DECODE(entry)) {
10861
ae18f8a4df85 6887242 want to be able to dump specific metaslab(s) for specific vdev
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10860
diff changeset
535 (void) printf("\t [%6llu] %s: txg %llu, pass %llu\n",
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
536 (u_longlong_t)(offset / sizeof (entry)),
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
537 ddata[SM_DEBUG_ACTION_DECODE(entry)],
2856
6f4d5ee1906a 6463348 ZFS code could be more portable
nd150628
parents: 2417
diff changeset
538 (u_longlong_t)SM_DEBUG_TXG_DECODE(entry),
6f4d5ee1906a 6463348 ZFS code could be more portable
nd150628
parents: 2417
diff changeset
539 (u_longlong_t)SM_DEBUG_SYNCPASS_DECODE(entry));
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
540 } else {
10861
ae18f8a4df85 6887242 want to be able to dump specific metaslab(s) for specific vdev
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10860
diff changeset
541 (void) printf("\t [%6llu] %c range:"
ae18f8a4df85 6887242 want to be able to dump specific metaslab(s) for specific vdev
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10860
diff changeset
542 " %010llx-%010llx size: %06llx\n",
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
543 (u_longlong_t)(offset / sizeof (entry)),
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
544 SM_TYPE_DECODE(entry) == SM_ALLOC ? 'A' : 'F',
2856
6f4d5ee1906a 6463348 ZFS code could be more portable
nd150628
parents: 2417
diff changeset
545 (u_longlong_t)((SM_OFFSET_DECODE(entry) <<
6f4d5ee1906a 6463348 ZFS code could be more portable
nd150628
parents: 2417
diff changeset
546 mapshift) + mapstart),
6f4d5ee1906a 6463348 ZFS code could be more portable
nd150628
parents: 2417
diff changeset
547 (u_longlong_t)((SM_OFFSET_DECODE(entry) <<
6f4d5ee1906a 6463348 ZFS code could be more portable
nd150628
parents: 2417
diff changeset
548 mapshift) + mapstart + (SM_RUN_DECODE(entry) <<
6f4d5ee1906a 6463348 ZFS code could be more portable
nd150628
parents: 2417
diff changeset
549 mapshift)),
6f4d5ee1906a 6463348 ZFS code could be more portable
nd150628
parents: 2417
diff changeset
550 (u_longlong_t)(SM_RUN_DECODE(entry) << mapshift));
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
551 if (SM_TYPE_DECODE(entry) == SM_ALLOC)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
552 alloc += SM_RUN_DECODE(entry) << mapshift;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
553 else
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
554 alloc -= SM_RUN_DECODE(entry) << mapshift;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
555 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
556 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
557 if (alloc != smo->smo_alloc) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
558 (void) printf("space_map_object alloc (%llu) INCONSISTENT "
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
559 "with space map summary (%llu)\n",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
560 (u_longlong_t)smo->smo_alloc, (u_longlong_t)alloc);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
561 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
562 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
563
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
564 static void
9480
fcff33da767f 6596237 Stop looking and start ganging
George Wilson <George.Wilson@Sun.COM>
parents: 9463
diff changeset
565 dump_metaslab_stats(metaslab_t *msp)
fcff33da767f 6596237 Stop looking and start ganging
George Wilson <George.Wilson@Sun.COM>
parents: 9463
diff changeset
566 {
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
567 char maxbuf[32];
9480
fcff33da767f 6596237 Stop looking and start ganging
George Wilson <George.Wilson@Sun.COM>
parents: 9463
diff changeset
568 space_map_t *sm = &msp->ms_map;
fcff33da767f 6596237 Stop looking and start ganging
George Wilson <George.Wilson@Sun.COM>
parents: 9463
diff changeset
569 avl_tree_t *t = sm->sm_pp_root;
fcff33da767f 6596237 Stop looking and start ganging
George Wilson <George.Wilson@Sun.COM>
parents: 9463
diff changeset
570 int free_pct = sm->sm_space * 100 / sm->sm_size;
fcff33da767f 6596237 Stop looking and start ganging
George Wilson <George.Wilson@Sun.COM>
parents: 9463
diff changeset
571
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
572 zdb_nicenum(space_map_maxsize(sm), maxbuf);
9480
fcff33da767f 6596237 Stop looking and start ganging
George Wilson <George.Wilson@Sun.COM>
parents: 9463
diff changeset
573
10861
ae18f8a4df85 6887242 want to be able to dump specific metaslab(s) for specific vdev
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10860
diff changeset
574 (void) printf("\t %25s %10lu %7s %6s %4s %4d%%\n",
9480
fcff33da767f 6596237 Stop looking and start ganging
George Wilson <George.Wilson@Sun.COM>
parents: 9463
diff changeset
575 "segments", avl_numnodes(t), "maxsize", maxbuf,
fcff33da767f 6596237 Stop looking and start ganging
George Wilson <George.Wilson@Sun.COM>
parents: 9463
diff changeset
576 "freepct", free_pct);
fcff33da767f 6596237 Stop looking and start ganging
George Wilson <George.Wilson@Sun.COM>
parents: 9463
diff changeset
577 }
fcff33da767f 6596237 Stop looking and start ganging
George Wilson <George.Wilson@Sun.COM>
parents: 9463
diff changeset
578
fcff33da767f 6596237 Stop looking and start ganging
George Wilson <George.Wilson@Sun.COM>
parents: 9463
diff changeset
579 static void
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
580 dump_metaslab(metaslab_t *msp)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
581 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
582 vdev_t *vd = msp->ms_group->mg_vd;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
583 spa_t *spa = vd->vdev_spa;
11146
7e58f40bcb1c 6826241 Sync write IOPS drops dramatically during TXG sync
George Wilson <George.Wilson@Sun.COM>
parents: 11125
diff changeset
584 space_map_t *sm = &msp->ms_map;
7e58f40bcb1c 6826241 Sync write IOPS drops dramatically during TXG sync
George Wilson <George.Wilson@Sun.COM>
parents: 11125
diff changeset
585 space_map_obj_t *smo = &msp->ms_smo;
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
586 char freebuf[32];
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
587
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
588 zdb_nicenum(sm->sm_size - smo->smo_alloc, freebuf);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
589
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
590 (void) printf(
10861
ae18f8a4df85 6887242 want to be able to dump specific metaslab(s) for specific vdev
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10860
diff changeset
591 "\tmetaslab %6llu offset %12llx spacemap %6llu free %5s\n",
11146
7e58f40bcb1c 6826241 Sync write IOPS drops dramatically during TXG sync
George Wilson <George.Wilson@Sun.COM>
parents: 11125
diff changeset
592 (u_longlong_t)(sm->sm_start / sm->sm_size),
7e58f40bcb1c 6826241 Sync write IOPS drops dramatically during TXG sync
George Wilson <George.Wilson@Sun.COM>
parents: 11125
diff changeset
593 (u_longlong_t)sm->sm_start, (u_longlong_t)smo->smo_object, freebuf);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
594
10861
ae18f8a4df85 6887242 want to be able to dump specific metaslab(s) for specific vdev
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10860
diff changeset
595 if (dump_opt['m'] > 1 && !dump_opt['L']) {
9480
fcff33da767f 6596237 Stop looking and start ganging
George Wilson <George.Wilson@Sun.COM>
parents: 9463
diff changeset
596 mutex_enter(&msp->ms_lock);
11146
7e58f40bcb1c 6826241 Sync write IOPS drops dramatically during TXG sync
George Wilson <George.Wilson@Sun.COM>
parents: 11125
diff changeset
597 space_map_load_wait(sm);
11728
59fdb3b856f6 6918420 zdb -m has issues printing metaslab statistics
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11727
diff changeset
598 if (!sm->sm_loaded)
11146
7e58f40bcb1c 6826241 Sync write IOPS drops dramatically during TXG sync
George Wilson <George.Wilson@Sun.COM>
parents: 11125
diff changeset
599 VERIFY(space_map_load(sm, zfs_metaslab_ops,
7e58f40bcb1c 6826241 Sync write IOPS drops dramatically during TXG sync
George Wilson <George.Wilson@Sun.COM>
parents: 11125
diff changeset
600 SM_FREE, smo, spa->spa_meta_objset) == 0);
11728
59fdb3b856f6 6918420 zdb -m has issues printing metaslab statistics
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11727
diff changeset
601 dump_metaslab_stats(msp);
59fdb3b856f6 6918420 zdb -m has issues printing metaslab statistics
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11727
diff changeset
602 space_map_unload(sm);
9480
fcff33da767f 6596237 Stop looking and start ganging
George Wilson <George.Wilson@Sun.COM>
parents: 9463
diff changeset
603 mutex_exit(&msp->ms_lock);
fcff33da767f 6596237 Stop looking and start ganging
George Wilson <George.Wilson@Sun.COM>
parents: 9463
diff changeset
604 }
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
605
9480
fcff33da767f 6596237 Stop looking and start ganging
George Wilson <George.Wilson@Sun.COM>
parents: 9463
diff changeset
606 if (dump_opt['d'] > 5 || dump_opt['m'] > 2) {
11146
7e58f40bcb1c 6826241 Sync write IOPS drops dramatically during TXG sync
George Wilson <George.Wilson@Sun.COM>
parents: 11125
diff changeset
607 ASSERT(sm->sm_size == (1ULL << vd->vdev_ms_shift));
9480
fcff33da767f 6596237 Stop looking and start ganging
George Wilson <George.Wilson@Sun.COM>
parents: 9463
diff changeset
608
fcff33da767f 6596237 Stop looking and start ganging
George Wilson <George.Wilson@Sun.COM>
parents: 9463
diff changeset
609 mutex_enter(&msp->ms_lock);
11146
7e58f40bcb1c 6826241 Sync write IOPS drops dramatically during TXG sync
George Wilson <George.Wilson@Sun.COM>
parents: 11125
diff changeset
610 dump_spacemap(spa->spa_meta_objset, smo, sm);
9480
fcff33da767f 6596237 Stop looking and start ganging
George Wilson <George.Wilson@Sun.COM>
parents: 9463
diff changeset
611 mutex_exit(&msp->ms_lock);
fcff33da767f 6596237 Stop looking and start ganging
George Wilson <George.Wilson@Sun.COM>
parents: 9463
diff changeset
612 }
10861
ae18f8a4df85 6887242 want to be able to dump specific metaslab(s) for specific vdev
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10860
diff changeset
613 }
9480
fcff33da767f 6596237 Stop looking and start ganging
George Wilson <George.Wilson@Sun.COM>
parents: 9463
diff changeset
614
10861
ae18f8a4df85 6887242 want to be able to dump specific metaslab(s) for specific vdev
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10860
diff changeset
615 static void
ae18f8a4df85 6887242 want to be able to dump specific metaslab(s) for specific vdev
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10860
diff changeset
616 print_vdev_metaslab_header(vdev_t *vd)
ae18f8a4df85 6887242 want to be able to dump specific metaslab(s) for specific vdev
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10860
diff changeset
617 {
ae18f8a4df85 6887242 want to be able to dump specific metaslab(s) for specific vdev
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10860
diff changeset
618 (void) printf("\tvdev %10llu\n\t%-10s%5llu %-19s %-15s %-10s\n",
ae18f8a4df85 6887242 want to be able to dump specific metaslab(s) for specific vdev
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10860
diff changeset
619 (u_longlong_t)vd->vdev_id,
ae18f8a4df85 6887242 want to be able to dump specific metaslab(s) for specific vdev
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10860
diff changeset
620 "metaslabs", (u_longlong_t)vd->vdev_ms_count,
ae18f8a4df85 6887242 want to be able to dump specific metaslab(s) for specific vdev
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10860
diff changeset
621 "offset", "spacemap", "free");
ae18f8a4df85 6887242 want to be able to dump specific metaslab(s) for specific vdev
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10860
diff changeset
622 (void) printf("\t%15s %19s %15s %10s\n",
ae18f8a4df85 6887242 want to be able to dump specific metaslab(s) for specific vdev
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10860
diff changeset
623 "---------------", "-------------------",
ae18f8a4df85 6887242 want to be able to dump specific metaslab(s) for specific vdev
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10860
diff changeset
624 "---------------", "-------------");
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
625 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
626
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
627 static void
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
628 dump_metaslabs(spa_t *spa)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
629 {
10861
ae18f8a4df85 6887242 want to be able to dump specific metaslab(s) for specific vdev
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10860
diff changeset
630 vdev_t *vd, *rvd = spa->spa_root_vdev;
ae18f8a4df85 6887242 want to be able to dump specific metaslab(s) for specific vdev
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10860
diff changeset
631 uint64_t m, c = 0, children = rvd->vdev_children;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
632
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
633 (void) printf("\nMetaslabs:\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
634
10861
ae18f8a4df85 6887242 want to be able to dump specific metaslab(s) for specific vdev
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10860
diff changeset
635 if (!dump_opt['d'] && zopt_objects > 0) {
ae18f8a4df85 6887242 want to be able to dump specific metaslab(s) for specific vdev
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10860
diff changeset
636 c = zopt_object[0];
ae18f8a4df85 6887242 want to be able to dump specific metaslab(s) for specific vdev
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10860
diff changeset
637
ae18f8a4df85 6887242 want to be able to dump specific metaslab(s) for specific vdev
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10860
diff changeset
638 if (c >= children)
ae18f8a4df85 6887242 want to be able to dump specific metaslab(s) for specific vdev
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10860
diff changeset
639 (void) fatal("bad vdev id: %llu", (u_longlong_t)c);
ae18f8a4df85 6887242 want to be able to dump specific metaslab(s) for specific vdev
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10860
diff changeset
640
ae18f8a4df85 6887242 want to be able to dump specific metaslab(s) for specific vdev
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10860
diff changeset
641 if (zopt_objects > 1) {
ae18f8a4df85 6887242 want to be able to dump specific metaslab(s) for specific vdev
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10860
diff changeset
642 vd = rvd->vdev_child[c];
ae18f8a4df85 6887242 want to be able to dump specific metaslab(s) for specific vdev
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10860
diff changeset
643 print_vdev_metaslab_header(vd);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
644
10861
ae18f8a4df85 6887242 want to be able to dump specific metaslab(s) for specific vdev
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10860
diff changeset
645 for (m = 1; m < zopt_objects; m++) {
ae18f8a4df85 6887242 want to be able to dump specific metaslab(s) for specific vdev
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10860
diff changeset
646 if (zopt_object[m] < vd->vdev_ms_count)
ae18f8a4df85 6887242 want to be able to dump specific metaslab(s) for specific vdev
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10860
diff changeset
647 dump_metaslab(
ae18f8a4df85 6887242 want to be able to dump specific metaslab(s) for specific vdev
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10860
diff changeset
648 vd->vdev_ms[zopt_object[m]]);
ae18f8a4df85 6887242 want to be able to dump specific metaslab(s) for specific vdev
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10860
diff changeset
649 else
ae18f8a4df85 6887242 want to be able to dump specific metaslab(s) for specific vdev
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10860
diff changeset
650 (void) fprintf(stderr, "bad metaslab "
ae18f8a4df85 6887242 want to be able to dump specific metaslab(s) for specific vdev
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10860
diff changeset
651 "number %llu\n",
ae18f8a4df85 6887242 want to be able to dump specific metaslab(s) for specific vdev
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10860
diff changeset
652 (u_longlong_t)zopt_object[m]);
ae18f8a4df85 6887242 want to be able to dump specific metaslab(s) for specific vdev
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10860
diff changeset
653 }
ae18f8a4df85 6887242 want to be able to dump specific metaslab(s) for specific vdev
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10860
diff changeset
654 (void) printf("\n");
ae18f8a4df85 6887242 want to be able to dump specific metaslab(s) for specific vdev
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10860
diff changeset
655 return;
ae18f8a4df85 6887242 want to be able to dump specific metaslab(s) for specific vdev
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10860
diff changeset
656 }
ae18f8a4df85 6887242 want to be able to dump specific metaslab(s) for specific vdev
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10860
diff changeset
657 children = c + 1;
ae18f8a4df85 6887242 want to be able to dump specific metaslab(s) for specific vdev
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10860
diff changeset
658 }
ae18f8a4df85 6887242 want to be able to dump specific metaslab(s) for specific vdev
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10860
diff changeset
659 for (; c < children; c++) {
ae18f8a4df85 6887242 want to be able to dump specific metaslab(s) for specific vdev
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10860
diff changeset
660 vd = rvd->vdev_child[c];
ae18f8a4df85 6887242 want to be able to dump specific metaslab(s) for specific vdev
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10860
diff changeset
661 print_vdev_metaslab_header(vd);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
662
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
663 for (m = 0; m < vd->vdev_ms_count; m++)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
664 dump_metaslab(vd->vdev_ms[m]);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
665 (void) printf("\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
666 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
667 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
668
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
669 static void
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
670 dump_dde(const ddt_t *ddt, const ddt_entry_t *dde, uint64_t index)
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
671 {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
672 const ddt_phys_t *ddp = dde->dde_phys;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
673 const ddt_key_t *ddk = &dde->dde_key;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
674 char *types[4] = { "ditto", "single", "double", "triple" };
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
675 char blkbuf[BP_SPRINTF_LEN];
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
676 blkptr_t blk;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
677
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
678 for (int p = 0; p < DDT_PHYS_TYPES; p++, ddp++) {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
679 if (ddp->ddp_phys_birth == 0)
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
680 continue;
11125
fca3e6d28599 6899923 vdev_offline/vdev_add deadlock
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10922
diff changeset
681 ddt_bp_create(ddt->ddt_checksum, ddk, ddp, &blk);
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
682 sprintf_blkptr(blkbuf, &blk);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
683 (void) printf("index %llx refcnt %llu %s %s\n",
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
684 (u_longlong_t)index, (u_longlong_t)ddp->ddp_refcnt,
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
685 types[p], blkbuf);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
686 }
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
687 }
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
688
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
689 static void
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
690 dump_dedup_ratio(const ddt_stat_t *dds)
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
691 {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
692 double rL, rP, rD, D, dedup, compress, copies;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
693
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
694 if (dds->dds_blocks == 0)
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
695 return;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
696
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
697 rL = (double)dds->dds_ref_lsize;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
698 rP = (double)dds->dds_ref_psize;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
699 rD = (double)dds->dds_ref_dsize;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
700 D = (double)dds->dds_dsize;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
701
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
702 dedup = rD / D;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
703 compress = rL / rP;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
704 copies = rD / rP;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
705
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
706 (void) printf("dedup = %.2f, compress = %.2f, copies = %.2f, "
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
707 "dedup * compress / copies = %.2f\n\n",
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
708 dedup, compress, copies, dedup * compress / copies);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
709 }
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
710
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
711 static void
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
712 dump_ddt(ddt_t *ddt, enum ddt_type type, enum ddt_class class)
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
713 {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
714 char name[DDT_NAMELEN];
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
715 ddt_entry_t dde;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
716 uint64_t walk = 0;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
717 dmu_object_info_t doi;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
718 uint64_t count, dspace, mspace;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
719 int error;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
720
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
721 error = ddt_object_info(ddt, type, class, &doi);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
722
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
723 if (error == ENOENT)
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
724 return;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
725 ASSERT(error == 0);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
726
12671
2fee57289adb 6959651 assertion failed: ddo_total->ddo_dspace == 0, file: ../../common/fs/zfs/ddt.c, line: 460
George Wilson <George.Wilson@Sun.COM>
parents: 12493
diff changeset
727 if ((count = ddt_object_count(ddt, type, class)) == 0)
2fee57289adb 6959651 assertion failed: ddo_total->ddo_dspace == 0, file: ../../common/fs/zfs/ddt.c, line: 460
George Wilson <George.Wilson@Sun.COM>
parents: 12493
diff changeset
728 return;
2fee57289adb 6959651 assertion failed: ddo_total->ddo_dspace == 0, file: ../../common/fs/zfs/ddt.c, line: 460
George Wilson <George.Wilson@Sun.COM>
parents: 12493
diff changeset
729
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
730 dspace = doi.doi_physical_blocks_512 << 9;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
731 mspace = doi.doi_fill_count * doi.doi_data_block_size;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
732
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
733 ddt_object_name(ddt, type, class, name);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
734
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
735 (void) printf("%s: %llu entries, size %llu on disk, %llu in core\n",
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
736 name,
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
737 (u_longlong_t)count,
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
738 (u_longlong_t)(dspace / count),
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
739 (u_longlong_t)(mspace / count));
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
740
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
741 if (dump_opt['D'] < 3)
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
742 return;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
743
11149
8bad7424e2c2 6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents: 11146
diff changeset
744 zpool_dump_ddt(NULL, &ddt->ddt_histogram[type][class]);
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
745
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
746 if (dump_opt['D'] < 4)
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
747 return;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
748
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
749 if (dump_opt['D'] < 5 && class == DDT_CLASS_UNIQUE)
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
750 return;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
751
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
752 (void) printf("%s contents:\n\n", name);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
753
11125
fca3e6d28599 6899923 vdev_offline/vdev_add deadlock
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10922
diff changeset
754 while ((error = ddt_object_walk(ddt, type, class, &walk, &dde)) == 0)
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
755 dump_dde(ddt, &dde, walk);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
756
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
757 ASSERT(error == ENOENT);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
758
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
759 (void) printf("\n");
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
760 }
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
761
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
762 static void
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
763 dump_all_ddts(spa_t *spa)
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
764 {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
765 ddt_histogram_t ddh_total = { 0 };
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
766 ddt_stat_t dds_total = { 0 };
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
767
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
768 for (enum zio_checksum c = 0; c < ZIO_CHECKSUM_FUNCTIONS; c++) {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
769 ddt_t *ddt = spa->spa_ddt[c];
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
770 for (enum ddt_type type = 0; type < DDT_TYPES; type++) {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
771 for (enum ddt_class class = 0; class < DDT_CLASSES;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
772 class++) {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
773 dump_ddt(ddt, type, class);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
774 }
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
775 }
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
776 }
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
777
11149
8bad7424e2c2 6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents: 11146
diff changeset
778 ddt_get_dedup_stats(spa, &dds_total);
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
779
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
780 if (dds_total.dds_blocks == 0) {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
781 (void) printf("All DDTs are empty\n");
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
782 return;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
783 }
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
784
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
785 (void) printf("\n");
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
786
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
787 if (dump_opt['D'] > 1) {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
788 (void) printf("DDT histogram (aggregated over all DDTs):\n");
11149
8bad7424e2c2 6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents: 11146
diff changeset
789 ddt_get_dedup_histogram(spa, &ddh_total);
8bad7424e2c2 6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents: 11146
diff changeset
790 zpool_dump_ddt(&dds_total, &ddh_total);
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
791 }
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
792
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
793 dump_dedup_ratio(&dds_total);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
794 }
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
795
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
796 static void
8241
5a60f16123ba 6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 8188
diff changeset
797 dump_dtl_seg(space_map_t *sm, uint64_t start, uint64_t size)
5a60f16123ba 6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 8188
diff changeset
798 {
5a60f16123ba 6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 8188
diff changeset
799 char *prefix = (void *)sm;
5a60f16123ba 6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 8188
diff changeset
800
5a60f16123ba 6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 8188
diff changeset
801 (void) printf("%s [%llu,%llu) length %llu\n",
5a60f16123ba 6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 8188
diff changeset
802 prefix,
5a60f16123ba 6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 8188
diff changeset
803 (u_longlong_t)start,
5a60f16123ba 6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 8188
diff changeset
804 (u_longlong_t)(start + size),
5a60f16123ba 6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 8188
diff changeset
805 (u_longlong_t)(size));
5a60f16123ba 6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 8188
diff changeset
806 }
5a60f16123ba 6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 8188
diff changeset
807
5a60f16123ba 6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 8188
diff changeset
808 static void
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
809 dump_dtl(vdev_t *vd, int indent)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
810 {
8241
5a60f16123ba 6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 8188
diff changeset
811 spa_t *spa = vd->vdev_spa;
5a60f16123ba 6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 8188
diff changeset
812 boolean_t required;
5a60f16123ba 6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 8188
diff changeset
813 char *name[DTL_TYPES] = { "missing", "partial", "scrub", "outage" };
5a60f16123ba 6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 8188
diff changeset
814 char prefix[256];
5a60f16123ba 6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 8188
diff changeset
815
10685
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
816 spa_vdev_state_enter(spa, SCL_NONE);
8241
5a60f16123ba 6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 8188
diff changeset
817 required = vdev_dtl_required(vd);
5a60f16123ba 6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 8188
diff changeset
818 (void) spa_vdev_state_exit(spa, NULL, 0);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
819
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
820 if (indent == 0)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
821 (void) printf("\nDirty time logs:\n\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
822
8241
5a60f16123ba 6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 8188
diff changeset
823 (void) printf("\t%*s%s [%s]\n", indent, "",
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
824 vd->vdev_path ? vd->vdev_path :
8241
5a60f16123ba 6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 8188
diff changeset
825 vd->vdev_parent ? vd->vdev_ops->vdev_op_type : spa_name(spa),
5a60f16123ba 6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 8188
diff changeset
826 required ? "DTL-required" : "DTL-expendable");
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
827
8241
5a60f16123ba 6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 8188
diff changeset
828 for (int t = 0; t < DTL_TYPES; t++) {
5a60f16123ba 6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 8188
diff changeset
829 space_map_t *sm = &vd->vdev_dtl[t];
5a60f16123ba 6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 8188
diff changeset
830 if (sm->sm_space == 0)
5a60f16123ba 6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 8188
diff changeset
831 continue;
5a60f16123ba 6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 8188
diff changeset
832 (void) snprintf(prefix, sizeof (prefix), "\t%*s%s",
5a60f16123ba 6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 8188
diff changeset
833 indent + 2, "", name[t]);
5a60f16123ba 6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 8188
diff changeset
834 mutex_enter(sm->sm_lock);
5a60f16123ba 6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 8188
diff changeset
835 space_map_walk(sm, dump_dtl_seg, (void *)prefix);
5a60f16123ba 6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 8188
diff changeset
836 mutex_exit(sm->sm_lock);
5a60f16123ba 6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 8188
diff changeset
837 if (dump_opt['d'] > 5 && vd->vdev_children == 0)
5a60f16123ba 6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 8188
diff changeset
838 dump_spacemap(spa->spa_meta_objset,
5a60f16123ba 6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 8188
diff changeset
839 &vd->vdev_dtl_smo, sm);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
840 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
841
8241
5a60f16123ba 6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 8188
diff changeset
842 for (int c = 0; c < vd->vdev_children; c++)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
843 dump_dtl(vd->vdev_child[c], indent + 4);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
844 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
845
10685
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
846 static void
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
847 dump_history(spa_t *spa)
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
848 {
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
849 nvlist_t **events = NULL;
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
850 char buf[SPA_MAXBLOCKSIZE];
10857
2c20a0bd87cd 6892882 zdb -ddddd prints garbage from stack between dataset summary and rootbp
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10685
diff changeset
851 uint64_t resid, len, off = 0;
10685
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
852 uint_t num = 0;
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
853 int error;
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
854 time_t tsec;
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
855 struct tm t;
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
856 char tbuf[30];
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
857 char internalstr[MAXPATHLEN];
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
858
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
859 do {
10857
2c20a0bd87cd 6892882 zdb -ddddd prints garbage from stack between dataset summary and rootbp
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10685
diff changeset
860 len = sizeof (buf);
2c20a0bd87cd 6892882 zdb -ddddd prints garbage from stack between dataset summary and rootbp
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10685
diff changeset
861
10685
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
862 if ((error = spa_history_get(spa, &off, &len, buf)) != 0) {
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
863 (void) fprintf(stderr, "Unable to read history: "
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
864 "error %d\n", error);
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
865 return;
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
866 }
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
867
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
868 if (zpool_history_unpack(buf, len, &resid, &events, &num) != 0)
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
869 break;
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
870
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
871 off -= resid;
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
872 } while (len != 0);
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
873
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
874 (void) printf("\nHistory:\n");
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
875 for (int i = 0; i < num; i++) {
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
876 uint64_t time, txg, ievent;
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
877 char *cmd, *intstr;
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
878 boolean_t printed = B_FALSE;
10685
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
879
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
880 if (nvlist_lookup_uint64(events[i], ZPOOL_HIST_TIME,
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
881 &time) != 0)
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
882 goto next;
10685
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
883 if (nvlist_lookup_string(events[i], ZPOOL_HIST_CMD,
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
884 &cmd) != 0) {
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
885 if (nvlist_lookup_uint64(events[i],
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
886 ZPOOL_HIST_INT_EVENT, &ievent) != 0)
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
887 goto next;
10685
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
888 verify(nvlist_lookup_uint64(events[i],
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
889 ZPOOL_HIST_TXG, &txg) == 0);
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
890 verify(nvlist_lookup_string(events[i],
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
891 ZPOOL_HIST_INT_STR, &intstr) == 0);
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
892 if (ievent >= ZFS_NUM_LEGACY_HISTORY_EVENTS)
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
893 goto next;
10685
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
894
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
895 (void) snprintf(internalstr,
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
896 sizeof (internalstr),
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
897 "[internal %s txg:%lld] %s",
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
898 zfs_history_event_names[ievent], txg,
10685
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
899 intstr);
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
900 cmd = internalstr;
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
901 }
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
902 tsec = time;
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
903 (void) localtime_r(&tsec, &t);
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
904 (void) strftime(tbuf, sizeof (tbuf), "%F.%T", &t);
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
905 (void) printf("%s %s\n", tbuf, cmd);
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
906 printed = B_TRUE;
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
907
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
908 next:
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
909 if (dump_opt['h'] > 1) {
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
910 if (!printed)
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
911 (void) printf("unrecognized record:\n");
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
912 dump_nvlist(events[i], 2);
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
913 }
10685
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
914 }
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
915 }
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
916
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
917 /*ARGSUSED*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
918 static void
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
919 dump_dnode(objset_t *os, uint64_t object, void *data, size_t size)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
920 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
921 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
922
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
923 static uint64_t
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
924 blkid2offset(const dnode_phys_t *dnp, const blkptr_t *bp, const zbookmark_t *zb)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
925 {
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
926 if (dnp == NULL) {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
927 ASSERT(zb->zb_level < 0);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
928 if (zb->zb_object == 0)
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
929 return (zb->zb_blkid);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
930 return (zb->zb_blkid * BP_GET_LSIZE(bp));
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
931 }
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
932
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
933 ASSERT(zb->zb_level >= 0);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
934
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
935 return ((zb->zb_blkid <<
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
936 (zb->zb_level * (dnp->dn_indblkshift - SPA_BLKPTRSHIFT))) *
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
937 dnp->dn_datablkszsec << SPA_MINBLOCKSHIFT);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
938 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
939
1775
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
940 static void
12470
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
941 sprintf_blkptr_compact(char *blkbuf, const blkptr_t *bp)
1775
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
942 {
12470
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
943 const dva_t *dva = bp->blk_dva;
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
944 int ndvas = dump_opt['d'] > 5 ? BP_GET_NDVAS(bp) : 1;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
945
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
946 if (dump_opt['b'] >= 5) {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
947 sprintf_blkptr(blkbuf, bp);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
948 return;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
949 }
1775
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
950
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
951 blkbuf[0] = '\0';
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
952
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
953 for (int i = 0; i < ndvas; i++)
1775
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
954 (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
955 (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
956 (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
957 (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
958
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
959 (void) sprintf(blkbuf + strlen(blkbuf),
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
960 "%llxL/%llxP F=%llu B=%llu/%llu",
1775
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
961 (u_longlong_t)BP_GET_LSIZE(bp),
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
962 (u_longlong_t)BP_GET_PSIZE(bp),
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
963 (u_longlong_t)bp->blk_fill,
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
964 (u_longlong_t)bp->blk_birth,
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
965 (u_longlong_t)BP_PHYSICAL_BIRTH(bp));
1775
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
966 }
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
967
7837
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
968 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
969 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
970 const dnode_phys_t *dnp)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
971 {
7837
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
972 char blkbuf[BP_SPRINTF_LEN];
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
973 int l;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
974
7837
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
975 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
976 ASSERT3U(BP_GET_LEVEL(bp), ==, zb->zb_level);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
977
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
978 (void) printf("%16llx ", (u_longlong_t)blkid2offset(dnp, bp, zb));
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
979
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
980 ASSERT(zb->zb_level >= 0);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
981
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
982 for (l = dnp->dn_nlevels - 1; l >= -1; l--) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
983 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
984 (void) printf("L%llx", (u_longlong_t)zb->zb_level);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
985 } 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
986 (void) printf(" ");
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
987 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
988 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
989
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
990 sprintf_blkptr_compact(blkbuf, bp);
7837
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
991 (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
992 }
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
993
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
994 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
995 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
996 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
997 {
10857
2c20a0bd87cd 6892882 zdb -ddddd prints garbage from stack between dataset summary and rootbp
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10685
diff changeset
998 int err = 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
999
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
1000 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
1001 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
1002
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
1003 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
1004
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
1005 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
1006 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
1007 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
1008 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
1009 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
1010 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
1011 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
1012
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
1013 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
1014 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
1015 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
1016 return (err);
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
1017 ASSERT(buf->b_data);
7837
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
1018
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
1019 /* 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
1020 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
1021 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
1022 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
1023
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
1024 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
1025 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
1026 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
1027 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
1028 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
1029 break;
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
1030 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
1031 }
8241
5a60f16123ba 6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 8188
diff changeset
1032 if (!err)
5a60f16123ba 6328632 zpool offline is a bit too conservative
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 8188
diff changeset
1033 ASSERT3U(fill, ==, bp->blk_fill);
7837
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
1034 (void) arc_buf_remove_ref(buf, &buf);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1035 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1036
7837
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
1037 return (err);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1038 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1039
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1040 /*ARGSUSED*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1041 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
1042 dump_indirect(dnode_t *dn)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1043 {
7837
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
1044 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
1045 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
1046 zbookmark_t czb;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1047
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1048 (void) printf("Indirect blocks:\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1049
10298
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10242
diff changeset
1050 SET_BOOKMARK(&czb, dmu_objset_id(dn->dn_objset),
7837
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
1051 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
1052 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
1053 czb.zb_blkid = j;
10298
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10242
diff changeset
1054 (void) visit_indirect(dmu_objset_spa(dn->dn_objset), dnp,
7837
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
1055 &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
1056 }
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1057
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1058 (void) printf("\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1059 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1060
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1061 /*ARGSUSED*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1062 static void
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1063 dump_dsl_dir(objset_t *os, uint64_t object, void *data, size_t size)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1064 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1065 dsl_dir_phys_t *dd = data;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1066 time_t crtime;
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
1067 char nice[32];
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1068
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1069 if (dd == NULL)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1070 return;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1071
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5094
diff changeset
1072 ASSERT3U(size, >=, sizeof (dsl_dir_phys_t));
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1073
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1074 crtime = dd->dd_creation_time;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1075 (void) printf("\t\tcreation_time = %s", ctime(&crtime));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1076 (void) printf("\t\thead_dataset_obj = %llu\n",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1077 (u_longlong_t)dd->dd_head_dataset_obj);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1078 (void) printf("\t\tparent_dir_obj = %llu\n",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1079 (u_longlong_t)dd->dd_parent_obj);
5367
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
1080 (void) printf("\t\torigin_obj = %llu\n",
c40abbe796be PSARC/2007/574 zfs send -R
ahrens
parents: 5331
diff changeset
1081 (u_longlong_t)dd->dd_origin_obj);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1082 (void) printf("\t\tchild_dir_zapobj = %llu\n",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1083 (u_longlong_t)dd->dd_child_dir_zapobj);
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
1084 zdb_nicenum(dd->dd_used_bytes, nice);
7390
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7265
diff changeset
1085 (void) printf("\t\tused_bytes = %s\n", nice);
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
1086 zdb_nicenum(dd->dd_compressed_bytes, nice);
7390
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7265
diff changeset
1087 (void) printf("\t\tcompressed_bytes = %s\n", nice);
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
1088 zdb_nicenum(dd->dd_uncompressed_bytes, nice);
7390
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7265
diff changeset
1089 (void) printf("\t\tuncompressed_bytes = %s\n", nice);
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
1090 zdb_nicenum(dd->dd_quota, nice);
7390
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7265
diff changeset
1091 (void) printf("\t\tquota = %s\n", nice);
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
1092 zdb_nicenum(dd->dd_reserved, nice);
7390
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7265
diff changeset
1093 (void) printf("\t\treserved = %s\n", nice);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1094 (void) printf("\t\tprops_zapobj = %llu\n",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1095 (u_longlong_t)dd->dd_props_zapobj);
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4527
diff changeset
1096 (void) printf("\t\tdeleg_zapobj = %llu\n",
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4527
diff changeset
1097 (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
1098 (void) printf("\t\tflags = %llx\n",
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7265
diff changeset
1099 (u_longlong_t)dd->dd_flags);
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7265
diff changeset
1100
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7265
diff changeset
1101 #define DO(which) \
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
1102 zdb_nicenum(dd->dd_used_breakdown[DD_USED_ ## which], nice); \
7390
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7265
diff changeset
1103 (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
1104 DO(HEAD);
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7265
diff changeset
1105 DO(SNAP);
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7265
diff changeset
1106 DO(CHILD);
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7265
diff changeset
1107 DO(CHILD_RSRV);
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7265
diff changeset
1108 DO(REFRSRV);
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7265
diff changeset
1109 #undef DO
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1110 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1111
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1112 /*ARGSUSED*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1113 static void
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1114 dump_dsl_dataset(objset_t *os, uint64_t object, void *data, size_t size)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1115 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1116 dsl_dataset_phys_t *ds = data;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1117 time_t crtime;
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
1118 char used[32], compressed[32], uncompressed[32], unique[32];
896
f5270e6bd04d 6348089 panic in dbuf_remove_ref
maybee
parents: 885
diff changeset
1119 char blkbuf[BP_SPRINTF_LEN];
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1120
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1121 if (ds == NULL)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1122 return;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1123
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1124 ASSERT(size == sizeof (*ds));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1125 crtime = ds->ds_creation_time;
13700
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
1126 zdb_nicenum(ds->ds_referenced_bytes, used);
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
1127 zdb_nicenum(ds->ds_compressed_bytes, compressed);
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
1128 zdb_nicenum(ds->ds_uncompressed_bytes, uncompressed);
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
1129 zdb_nicenum(ds->ds_unique_bytes, unique);
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1130 sprintf_blkptr(blkbuf, &ds->ds_bp);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1131
7046
361307ae060d 6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents: 6992
diff changeset
1132 (void) printf("\t\tdir_obj = %llu\n",
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1133 (u_longlong_t)ds->ds_dir_obj);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1134 (void) printf("\t\tprev_snap_obj = %llu\n",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1135 (u_longlong_t)ds->ds_prev_snap_obj);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1136 (void) printf("\t\tprev_snap_txg = %llu\n",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1137 (u_longlong_t)ds->ds_prev_snap_txg);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1138 (void) printf("\t\tnext_snap_obj = %llu\n",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1139 (u_longlong_t)ds->ds_next_snap_obj);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1140 (void) printf("\t\tsnapnames_zapobj = %llu\n",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1141 (u_longlong_t)ds->ds_snapnames_zapobj);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1142 (void) printf("\t\tnum_children = %llu\n",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1143 (u_longlong_t)ds->ds_num_children);
10242
c40d075fbca6 PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents: 9512
diff changeset
1144 (void) printf("\t\tuserrefs_obj = %llu\n",
c40d075fbca6 PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents: 9512
diff changeset
1145 (u_longlong_t)ds->ds_userrefs_obj);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1146 (void) printf("\t\tcreation_time = %s", ctime(&crtime));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1147 (void) printf("\t\tcreation_txg = %llu\n",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1148 (u_longlong_t)ds->ds_creation_txg);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1149 (void) printf("\t\tdeadlist_obj = %llu\n",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1150 (u_longlong_t)ds->ds_deadlist_obj);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1151 (void) printf("\t\tused_bytes = %s\n", used);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1152 (void) printf("\t\tcompressed_bytes = %s\n", compressed);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1153 (void) printf("\t\tuncompressed_bytes = %s\n", uncompressed);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1154 (void) printf("\t\tunique = %s\n", unique);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1155 (void) printf("\t\tfsid_guid = %llu\n",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1156 (u_longlong_t)ds->ds_fsid_guid);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1157 (void) printf("\t\tguid = %llu\n",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1158 (u_longlong_t)ds->ds_guid);
2082
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1914
diff changeset
1159 (void) printf("\t\tflags = %llx\n",
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1914
diff changeset
1160 (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
1161 (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
1162 (u_longlong_t)ds->ds_next_clones_obj);
7265
cc18862247da PSARC/2008/483 ZFS clone -o
ahrens
parents: 7046
diff changeset
1163 (void) printf("\t\tprops_obj = %llu\n",
cc18862247da PSARC/2008/483 ZFS clone -o
ahrens
parents: 7046
diff changeset
1164 (u_longlong_t)ds->ds_props_obj);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1165 (void) printf("\t\tbp = %s\n", blkbuf);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1166 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1167
12470
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1168 /* ARGSUSED */
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1169 static int
13700
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
1170 dump_bptree_cb(void *arg, const blkptr_t *bp, dmu_tx_t *tx)
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
1171 {
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
1172 char blkbuf[BP_SPRINTF_LEN];
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
1173
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
1174 if (bp->blk_birth != 0) {
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
1175 sprintf_blkptr(blkbuf, bp);
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
1176 (void) printf("\t%s\n", blkbuf);
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
1177 }
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
1178 return (0);
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
1179 }
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
1180
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
1181 static void
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
1182 dump_bptree(objset_t *os, uint64_t obj, char *name)
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
1183 {
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
1184 char bytes[32];
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
1185 bptree_phys_t *bt;
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
1186 dmu_buf_t *db;
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
1187
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
1188 if (dump_opt['d'] < 3)
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
1189 return;
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
1190
13765
9410cf539b11 backout 3006: causes 3046 (panics after mounting root)
Richard Lowe <richlowe@richlowe.net>
parents: 13764
diff changeset
1191 VERIFY3U(0, ==, dmu_bonus_hold(os, obj, FTAG, &db));
13700
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
1192 bt = db->db_data;
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
1193 zdb_nicenum(bt->bt_bytes, bytes);
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
1194 (void) printf("\n %s: %llu datasets, %s\n",
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
1195 name, (unsigned long long)(bt->bt_end - bt->bt_begin), bytes);
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
1196 dmu_buf_rele(db, FTAG);
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
1197
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
1198 if (dump_opt['d'] < 5)
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
1199 return;
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
1200
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
1201 (void) printf("\n");
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
1202
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
1203 (void) bptree_iterate(os, obj, B_FALSE, dump_bptree_cb, NULL, NULL);
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
1204 }
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
1205
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
1206 /* ARGSUSED */
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
1207 static int
12470
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1208 dump_bpobj_cb(void *arg, const blkptr_t *bp, dmu_tx_t *tx)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1209 {
12470
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1210 char blkbuf[BP_SPRINTF_LEN];
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1211
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1212 ASSERT(bp->blk_birth != 0);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1213 sprintf_blkptr_compact(blkbuf, bp);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1214 (void) printf("\t%s\n", blkbuf);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1215 return (0);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1216 }
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1217
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1218 static void
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1219 dump_bpobj(bpobj_t *bpo, char *name)
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1220 {
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
1221 char bytes[32];
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
1222 char comp[32];
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
1223 char uncomp[32];
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1224
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1225 if (dump_opt['d'] < 3)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1226 return;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1227
12470
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1228 zdb_nicenum(bpo->bpo_phys->bpo_bytes, bytes);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1229 if (bpo->bpo_havesubobj) {
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1230 zdb_nicenum(bpo->bpo_phys->bpo_comp, comp);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1231 zdb_nicenum(bpo->bpo_phys->bpo_uncomp, uncomp);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1232 (void) printf("\n %s: %llu local blkptrs, %llu subobjs, "
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1233 "%s (%s/%s comp)\n",
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1234 name, (u_longlong_t)bpo->bpo_phys->bpo_num_blkptrs,
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1235 (u_longlong_t)bpo->bpo_phys->bpo_num_subobjs,
2082
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1914
diff changeset
1236 bytes, comp, uncomp);
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1914
diff changeset
1237 } else {
12470
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1238 (void) printf("\n %s: %llu blkptrs, %s\n",
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1239 name, (u_longlong_t)bpo->bpo_phys->bpo_num_blkptrs, bytes);
2082
76b439ec3ac1 PSARC 2006/223 ZFS Hot Spares
eschrock
parents: 1914
diff changeset
1240 }
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1241
12470
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1242 if (dump_opt['d'] < 5)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1243 return;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1244
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1245 (void) printf("\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1246
12470
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1247 (void) bpobj_iterate_nofree(bpo, dump_bpobj_cb, NULL, NULL);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1248 }
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1249
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1250 static void
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1251 dump_deadlist(dsl_deadlist_t *dl)
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1252 {
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1253 dsl_deadlist_entry_t *dle;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1254 char bytes[32];
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1255 char comp[32];
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1256 char uncomp[32];
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1257
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1258 if (dump_opt['d'] < 3)
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1259 return;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1260
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1261 zdb_nicenum(dl->dl_phys->dl_used, bytes);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1262 zdb_nicenum(dl->dl_phys->dl_comp, comp);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1263 zdb_nicenum(dl->dl_phys->dl_uncomp, uncomp);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1264 (void) printf("\n Deadlist: %s (%s/%s comp)\n",
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1265 bytes, comp, uncomp);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1266
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1267 if (dump_opt['d'] < 4)
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1268 return;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1269
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1270 (void) printf("\n");
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1271
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1272 for (dle = avl_first(&dl->dl_tree); dle;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1273 dle = AVL_NEXT(&dl->dl_tree, dle)) {
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1274 (void) printf(" mintxg %llu -> obj %llu\n",
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1275 (longlong_t)dle->dle_mintxg,
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1276 (longlong_t)dle->dle_bpobj.bpo_object);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1277
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1278 if (dump_opt['d'] >= 5)
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1279 dump_bpobj(&dle->dle_bpobj, "");
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1280 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1281 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1282
5959
1e1904b8526d 6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents: 5530
diff changeset
1283 static avl_tree_t idx_tree;
1e1904b8526d 6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents: 5530
diff changeset
1284 static avl_tree_t domain_tree;
1e1904b8526d 6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents: 5530
diff changeset
1285 static boolean_t fuid_table_loaded;
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1286 static boolean_t sa_loaded;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1287 sa_attr_type_t *sa_attr_table;
5959
1e1904b8526d 6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents: 5530
diff changeset
1288
1e1904b8526d 6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents: 5530
diff changeset
1289 static void
1e1904b8526d 6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents: 5530
diff changeset
1290 fuid_table_destroy()
1e1904b8526d 6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents: 5530
diff changeset
1291 {
1e1904b8526d 6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents: 5530
diff changeset
1292 if (fuid_table_loaded) {
1e1904b8526d 6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents: 5530
diff changeset
1293 zfs_fuid_table_destroy(&idx_tree, &domain_tree);
1e1904b8526d 6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents: 5530
diff changeset
1294 fuid_table_loaded = B_FALSE;
1e1904b8526d 6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents: 5530
diff changeset
1295 }
1e1904b8526d 6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents: 5530
diff changeset
1296 }
1e1904b8526d 6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents: 5530
diff changeset
1297
1e1904b8526d 6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents: 5530
diff changeset
1298 /*
1e1904b8526d 6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents: 5530
diff changeset
1299 * print uid or gid information.
1e1904b8526d 6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents: 5530
diff changeset
1300 * 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
1301 * 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
1302 * the doman-rid string.
1e1904b8526d 6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents: 5530
diff changeset
1303 */
1e1904b8526d 6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents: 5530
diff changeset
1304 static void
1e1904b8526d 6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents: 5530
diff changeset
1305 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
1306 {
1e1904b8526d 6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents: 5530
diff changeset
1307 if (FUID_INDEX(id)) {
1e1904b8526d 6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents: 5530
diff changeset
1308 char *domain;
1e1904b8526d 6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents: 5530
diff changeset
1309
1e1904b8526d 6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents: 5530
diff changeset
1310 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
1311 (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
1312 (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
1313 } else {
1e1904b8526d 6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents: 5530
diff changeset
1314 (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
1315 }
1e1904b8526d 6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents: 5530
diff changeset
1316
1e1904b8526d 6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents: 5530
diff changeset
1317 }
1e1904b8526d 6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents: 5530
diff changeset
1318
1e1904b8526d 6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents: 5530
diff changeset
1319 static void
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1320 dump_uidgid(objset_t *os, uint64_t uid, uint64_t gid)
5959
1e1904b8526d 6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents: 5530
diff changeset
1321 {
1e1904b8526d 6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents: 5530
diff changeset
1322 uint32_t uid_idx, gid_idx;
1e1904b8526d 6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents: 5530
diff changeset
1323
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1324 uid_idx = FUID_INDEX(uid);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1325 gid_idx = FUID_INDEX(gid);
5959
1e1904b8526d 6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents: 5530
diff changeset
1326
1e1904b8526d 6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents: 5530
diff changeset
1327 /* Load domain table, if not already loaded */
1e1904b8526d 6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents: 5530
diff changeset
1328 if (!fuid_table_loaded && (uid_idx || gid_idx)) {
1e1904b8526d 6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents: 5530
diff changeset
1329 uint64_t fuid_obj;
1e1904b8526d 6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents: 5530
diff changeset
1330
1e1904b8526d 6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents: 5530
diff changeset
1331 /* 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
1332 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
1333 8, 1, &fuid_obj) == 0);
9179
d8fbd96b79b3 6790064 zfs needs to determine uid and gid earlier in create process
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 8924
diff changeset
1334 zfs_fuid_avl_tree_create(&idx_tree, &domain_tree);
5959
1e1904b8526d 6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents: 5530
diff changeset
1335 (void) zfs_fuid_table_load(os, fuid_obj,
1e1904b8526d 6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents: 5530
diff changeset
1336 &idx_tree, &domain_tree);
1e1904b8526d 6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents: 5530
diff changeset
1337 fuid_table_loaded = B_TRUE;
1e1904b8526d 6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents: 5530
diff changeset
1338 }
1e1904b8526d 6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents: 5530
diff changeset
1339
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1340 print_idstr(uid, "uid");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1341 print_idstr(gid, "gid");
5959
1e1904b8526d 6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents: 5530
diff changeset
1342 }
1e1904b8526d 6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents: 5530
diff changeset
1343
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1344 /*ARGSUSED*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1345 static void
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1346 dump_znode(objset_t *os, uint64_t object, void *data, size_t size)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1347 {
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1348 char path[MAXPATHLEN * 2]; /* allow for xattr and failure prefix */
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1349 sa_handle_t *hdl;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1350 uint64_t xattr, rdev, gen;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1351 uint64_t uid, gid, mode, fsize, parent, links;
12050
5879aa161e65 6938757 SMB and NFS referrals not working correctly
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11935
diff changeset
1352 uint64_t pflags;
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1353 uint64_t acctm[2], modtm[2], chgtm[2], crtm[2];
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1354 time_t z_crtime, z_atime, z_mtime, z_ctime;
12050
5879aa161e65 6938757 SMB and NFS referrals not working correctly
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11935
diff changeset
1355 sa_bulk_attr_t bulk[12];
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1356 int idx = 0;
3444
dc160a70a50d 6410433 'zpool status -v' would be more useful with filenames
ek110237
parents: 3361
diff changeset
1357 int error;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1358
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1359 if (!sa_loaded) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1360 uint64_t sa_attrs = 0;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1361 uint64_t version;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1362
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1363 VERIFY(zap_lookup(os, MASTER_NODE_OBJ, ZPL_VERSION_STR,
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1364 8, 1, &version) == 0);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1365 if (version >= ZPL_VERSION_SA) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1366 VERIFY(zap_lookup(os, MASTER_NODE_OBJ, ZFS_SA_ATTRS,
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1367 8, 1, &sa_attrs) == 0);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1368 }
12493
89ce40422cea 6952177 SA handling of on-disk corruption can be improved
Mark Shellenbaum <Mark.Shellenbaum@Oracle.COM>
parents: 12470
diff changeset
1369 if ((error = sa_setup(os, sa_attrs, zfs_attr_table,
89ce40422cea 6952177 SA handling of on-disk corruption can be improved
Mark Shellenbaum <Mark.Shellenbaum@Oracle.COM>
parents: 12470
diff changeset
1370 ZPL_END, &sa_attr_table)) != 0) {
89ce40422cea 6952177 SA handling of on-disk corruption can be improved
Mark Shellenbaum <Mark.Shellenbaum@Oracle.COM>
parents: 12470
diff changeset
1371 (void) printf("sa_setup failed errno %d, can't "
89ce40422cea 6952177 SA handling of on-disk corruption can be improved
Mark Shellenbaum <Mark.Shellenbaum@Oracle.COM>
parents: 12470
diff changeset
1372 "display znode contents\n", error);
89ce40422cea 6952177 SA handling of on-disk corruption can be improved
Mark Shellenbaum <Mark.Shellenbaum@Oracle.COM>
parents: 12470
diff changeset
1373 return;
89ce40422cea 6952177 SA handling of on-disk corruption can be improved
Mark Shellenbaum <Mark.Shellenbaum@Oracle.COM>
parents: 12470
diff changeset
1374 }
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1375 sa_loaded = B_TRUE;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1376 }
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1377
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1378 if (sa_handle_get(os, object, NULL, SA_HDL_PRIVATE, &hdl)) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1379 (void) printf("Failed to get handle for SA znode\n");
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1380 return;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1381 }
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1382
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1383 SA_ADD_BULK_ATTR(bulk, idx, sa_attr_table[ZPL_UID], NULL, &uid, 8);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1384 SA_ADD_BULK_ATTR(bulk, idx, sa_attr_table[ZPL_GID], NULL, &gid, 8);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1385 SA_ADD_BULK_ATTR(bulk, idx, sa_attr_table[ZPL_LINKS], NULL,
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1386 &links, 8);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1387 SA_ADD_BULK_ATTR(bulk, idx, sa_attr_table[ZPL_GEN], NULL, &gen, 8);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1388 SA_ADD_BULK_ATTR(bulk, idx, sa_attr_table[ZPL_MODE], NULL,
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1389 &mode, 8);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1390 SA_ADD_BULK_ATTR(bulk, idx, sa_attr_table[ZPL_PARENT],
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1391 NULL, &parent, 8);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1392 SA_ADD_BULK_ATTR(bulk, idx, sa_attr_table[ZPL_SIZE], NULL,
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1393 &fsize, 8);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1394 SA_ADD_BULK_ATTR(bulk, idx, sa_attr_table[ZPL_ATIME], NULL,
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1395 acctm, 16);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1396 SA_ADD_BULK_ATTR(bulk, idx, sa_attr_table[ZPL_MTIME], NULL,
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1397 modtm, 16);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1398 SA_ADD_BULK_ATTR(bulk, idx, sa_attr_table[ZPL_CRTIME], NULL,
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1399 crtm, 16);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1400 SA_ADD_BULK_ATTR(bulk, idx, sa_attr_table[ZPL_CTIME], NULL,
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1401 chgtm, 16);
12050
5879aa161e65 6938757 SMB and NFS referrals not working correctly
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11935
diff changeset
1402 SA_ADD_BULK_ATTR(bulk, idx, sa_attr_table[ZPL_FLAGS], NULL,
5879aa161e65 6938757 SMB and NFS referrals not working correctly
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11935
diff changeset
1403 &pflags, 8);
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1404
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1405 if (sa_bulk_lookup(hdl, bulk, idx)) {
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1406 (void) sa_handle_destroy(hdl);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1407 return;
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1408 }
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1409
3444
dc160a70a50d 6410433 'zpool status -v' would be more useful with filenames
ek110237
parents: 3361
diff changeset
1410 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
1411 if (error != 0) {
dc160a70a50d 6410433 'zpool status -v' would be more useful with filenames
ek110237
parents: 3361
diff changeset
1412 (void) snprintf(path, sizeof (path), "\?\?\?<object#%llu>",
dc160a70a50d 6410433 'zpool status -v' would be more useful with filenames
ek110237
parents: 3361
diff changeset
1413 (u_longlong_t)object);
dc160a70a50d 6410433 'zpool status -v' would be more useful with filenames
ek110237
parents: 3361
diff changeset
1414 }
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1415 if (dump_opt['d'] < 3) {
3444
dc160a70a50d 6410433 'zpool status -v' would be more useful with filenames
ek110237
parents: 3361
diff changeset
1416 (void) printf("\t%s\n", path);
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1417 (void) sa_handle_destroy(hdl);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1418 return;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1419 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1420
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1421 z_crtime = (time_t)crtm[0];
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1422 z_atime = (time_t)acctm[0];
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1423 z_mtime = (time_t)modtm[0];
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1424 z_ctime = (time_t)chgtm[0];
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1425
3444
dc160a70a50d 6410433 'zpool status -v' would be more useful with filenames
ek110237
parents: 3361
diff changeset
1426 (void) printf("\tpath %s\n", path);
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1427 dump_uidgid(os, uid, gid);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1428 (void) printf("\tatime %s", ctime(&z_atime));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1429 (void) printf("\tmtime %s", ctime(&z_mtime));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1430 (void) printf("\tctime %s", ctime(&z_ctime));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1431 (void) printf("\tcrtime %s", ctime(&z_crtime));
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1432 (void) printf("\tgen %llu\n", (u_longlong_t)gen);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1433 (void) printf("\tmode %llo\n", (u_longlong_t)mode);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1434 (void) printf("\tsize %llu\n", (u_longlong_t)fsize);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1435 (void) printf("\tparent %llu\n", (u_longlong_t)parent);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1436 (void) printf("\tlinks %llu\n", (u_longlong_t)links);
12050
5879aa161e65 6938757 SMB and NFS referrals not working correctly
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11935
diff changeset
1437 (void) printf("\tpflags %llx\n", (u_longlong_t)pflags);
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1438 if (sa_lookup(hdl, sa_attr_table[ZPL_XATTR], &xattr,
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1439 sizeof (uint64_t)) == 0)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1440 (void) printf("\txattr %llu\n", (u_longlong_t)xattr);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1441 if (sa_lookup(hdl, sa_attr_table[ZPL_RDEV], &rdev,
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1442 sizeof (uint64_t)) == 0)
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1443 (void) printf("\trdev 0x%016llx\n", (u_longlong_t)rdev);
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1444 sa_handle_destroy(hdl);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1445 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1446
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1447 /*ARGSUSED*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1448 static void
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1449 dump_acl(objset_t *os, uint64_t object, void *data, size_t size)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1450 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1451 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1452
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1453 /*ARGSUSED*/
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1454 static void
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1455 dump_dmu_objset(objset_t *os, uint64_t object, void *data, size_t size)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1456 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1457 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1458
10859
ea699e57196e 6761101 zdb/mdb crashes when printing bp with bad checksum, compress or type
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10858
diff changeset
1459 static object_viewer_t *object_viewer[DMU_OT_NUMTYPES + 1] = {
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1460 dump_none, /* unallocated */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1461 dump_zap, /* object directory */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1462 dump_uint64, /* object array */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1463 dump_none, /* packed nvlist */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1464 dump_packed_nvlist, /* packed nvlist size */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1465 dump_none, /* bplist */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1466 dump_none, /* bplist header */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1467 dump_none, /* SPA space map header */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1468 dump_none, /* SPA space map */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1469 dump_none, /* ZIL intent log */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1470 dump_dnode, /* DMU dnode */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1471 dump_dmu_objset, /* DMU objset */
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1170
diff changeset
1472 dump_dsl_dir, /* DSL directory */
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1473 dump_zap, /* DSL directory child map */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1474 dump_zap, /* DSL dataset snap map */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1475 dump_zap, /* DSL props */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1476 dump_dsl_dataset, /* DSL dataset */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1477 dump_znode, /* ZFS znode */
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5094
diff changeset
1478 dump_acl, /* ZFS V0 ACL */
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1479 dump_uint8, /* ZFS plain file */
4577
ed36b0e652bc PSARC/2007/328 zfs upgrade
ahrens
parents: 4543
diff changeset
1480 dump_zpldir, /* ZFS directory */
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1481 dump_zap, /* ZFS master node */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1482 dump_zap, /* ZFS delete queue */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1483 dump_uint8, /* zvol object */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1484 dump_zap, /* zvol prop */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1485 dump_uint8, /* other uint8[] */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1486 dump_uint64, /* other uint64[] */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1487 dump_zap, /* other ZAP */
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1170
diff changeset
1488 dump_zap, /* persistent error log */
2926
acfcfefbc60d PSARC 2006/288 zpool history
ek110237
parents: 2885
diff changeset
1489 dump_uint8, /* SPA history */
13743
95aba6e49b9f 2882 implement libzfs_core
Matthew Ahrens <mahrens@delphix.com>
parents: 13700
diff changeset
1490 dump_history_offsets, /* SPA history offsets */
3912
f6891a60bd72 PSARC 2007/083 ZFS bootable datasets
lling
parents: 3547
diff changeset
1491 dump_zap, /* Pool properties */
4543
12bb2876a62e PSARC/2006/465 ZFS Delegated Administration
marks
parents: 4527
diff changeset
1492 dump_zap, /* DSL permissions */
5331
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5094
diff changeset
1493 dump_acl, /* ZFS ACL */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5094
diff changeset
1494 dump_uint8, /* ZFS SYSACL */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5094
diff changeset
1495 dump_none, /* FUID nvlist */
3047ad28a67b PSARC/2007/218 caller_context_t in all VOPs
amw
parents: 5094
diff changeset
1496 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
1497 dump_zap, /* DSL dataset next clones */
361307ae060d 6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents: 6992
diff changeset
1498 dump_zap, /* DSL scrub queue */
9396
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9179
diff changeset
1499 dump_zap, /* ZFS user/group used */
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9179
diff changeset
1500 dump_zap, /* ZFS user/group quota */
10242
c40d075fbca6 PSARC/2009/297 zfs snapshot holds
Chris Kirby <chris.kirby@sun.com>
parents: 9512
diff changeset
1501 dump_zap, /* snapshot refcount tags */
11165
68184eb5449e 6903705 dedup=fletcher4,verify doesn't byteswap correctly, has lots of hash collisions
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11149
diff changeset
1502 dump_ddt_zap, /* DDT ZAP object */
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1503 dump_zap, /* DDT statistics */
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1504 dump_znode, /* SA object */
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1505 dump_zap, /* SA Master Node */
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1506 dump_sa_attrs, /* SA attribute registration */
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1507 dump_sa_layouts, /* SA attribute layouts */
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
1508 dump_zap, /* DSL scrub translations */
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
1509 dump_none, /* fake dedup BP */
12470
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1510 dump_zap, /* deadlist */
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1511 dump_none, /* deadlist hdr */
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1512 dump_zap, /* dsl clones */
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1513 dump_none, /* bpobj subobjs */
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1514 dump_unknown, /* Unknown type, must be last */
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1515 };
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1516
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1517 static void
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1518 dump_object(objset_t *os, uint64_t object, int verbosity, int *print_header)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1519 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1520 dmu_buf_t *db = NULL;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1521 dmu_object_info_t doi;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1522 dnode_t *dn;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1523 void *bonus = NULL;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1524 size_t bsize = 0;
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
1525 char iblk[32], dblk[32], lsize[32], asize[32], fill[32];
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
1526 char bonus_size[32];
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1527 char aux[50];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1528 int error;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1529
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1530 if (*print_header) {
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1531 (void) printf("\n%10s %3s %5s %5s %5s %5s %6s %s\n",
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1532 "Object", "lvl", "iblk", "dblk", "dsize", "lsize",
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1533 "%full", "type");
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1534 *print_header = 0;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1535 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1536
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1537 if (object == 0) {
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12671
diff changeset
1538 dn = DMU_META_DNODE(os);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1539 } else {
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1170
diff changeset
1540 error = dmu_bonus_hold(os, object, FTAG, &db);
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1170
diff changeset
1541 if (error)
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1170
diff changeset
1542 fatal("dmu_bonus_hold(%llu) failed, errno %u",
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1170
diff changeset
1543 object, error);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1544 bonus = db->db_data;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1545 bsize = db->db_size;
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12671
diff changeset
1546 dn = DB_DNODE((dmu_buf_impl_t *)db);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1547 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1548 dmu_object_info_from_dnode(dn, &doi);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1549
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
1550 zdb_nicenum(doi.doi_metadata_block_size, iblk);
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
1551 zdb_nicenum(doi.doi_data_block_size, dblk);
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
1552 zdb_nicenum(doi.doi_max_offset, lsize);
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
1553 zdb_nicenum(doi.doi_physical_blocks_512 << 9, asize);
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
1554 zdb_nicenum(doi.doi_bonus_size, bonus_size);
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1555 (void) sprintf(fill, "%6.2f", 100.0 * doi.doi_fill_count *
11125
fca3e6d28599 6899923 vdev_offline/vdev_add deadlock
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10922
diff changeset
1556 doi.doi_data_block_size / (object == 0 ? DNODES_PER_BLOCK : 1) /
fca3e6d28599 6899923 vdev_offline/vdev_add deadlock
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10922
diff changeset
1557 doi.doi_max_offset);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1558
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1559 aux[0] = '\0';
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1560
4577
ed36b0e652bc PSARC/2007/328 zfs upgrade
ahrens
parents: 4543
diff changeset
1561 if (doi.doi_checksum != ZIO_CHECKSUM_INHERIT || verbosity >= 6) {
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1562 (void) snprintf(aux + strlen(aux), sizeof (aux), " (K=%s)",
10859
ea699e57196e 6761101 zdb/mdb crashes when printing bp with bad checksum, compress or type
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10858
diff changeset
1563 ZDB_CHECKSUM_NAME(doi.doi_checksum));
4577
ed36b0e652bc PSARC/2007/328 zfs upgrade
ahrens
parents: 4543
diff changeset
1564 }
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1565
4577
ed36b0e652bc PSARC/2007/328 zfs upgrade
ahrens
parents: 4543
diff changeset
1566 if (doi.doi_compress != ZIO_COMPRESS_INHERIT || verbosity >= 6) {
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1567 (void) snprintf(aux + strlen(aux), sizeof (aux), " (Z=%s)",
10859
ea699e57196e 6761101 zdb/mdb crashes when printing bp with bad checksum, compress or type
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10858
diff changeset
1568 ZDB_COMPRESS_NAME(doi.doi_compress));
4577
ed36b0e652bc PSARC/2007/328 zfs upgrade
ahrens
parents: 4543
diff changeset
1569 }
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1570
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1571 (void) printf("%10lld %3u %5s %5s %5s %5s %6s %s%s\n",
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1572 (u_longlong_t)object, doi.doi_indirection, iblk, dblk,
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1573 asize, lsize, fill, ZDB_OT_NAME(doi.doi_type), aux);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1574
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1575 if (doi.doi_bonus_type != DMU_OT_NONE && verbosity > 3) {
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1576 (void) printf("%10s %3s %5s %5s %5s %5s %6s %s\n",
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1577 "", "", "", "", "", bonus_size, "bonus",
10859
ea699e57196e 6761101 zdb/mdb crashes when printing bp with bad checksum, compress or type
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10858
diff changeset
1578 ZDB_OT_NAME(doi.doi_bonus_type));
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1579 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1580
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1581 if (verbosity >= 4) {
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1582 (void) printf("\tdnode flags: %s%s%s\n",
9396
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9179
diff changeset
1583 (dn->dn_phys->dn_flags & DNODE_FLAG_USED_BYTES) ?
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9179
diff changeset
1584 "USED_BYTES " : "",
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9179
diff changeset
1585 (dn->dn_phys->dn_flags & DNODE_FLAG_USERUSED_ACCOUNTED) ?
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1586 "USERUSED_ACCOUNTED " : "",
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1587 (dn->dn_phys->dn_flags & DNODE_FLAG_SPILL_BLKPTR) ?
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1588 "SPILL_BLKPTR" : "");
9396
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9179
diff changeset
1589 (void) printf("\tdnode maxblkid: %llu\n",
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9179
diff changeset
1590 (longlong_t)dn->dn_phys->dn_maxblkid);
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9179
diff changeset
1591
10859
ea699e57196e 6761101 zdb/mdb crashes when printing bp with bad checksum, compress or type
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10858
diff changeset
1592 object_viewer[ZDB_OT_TYPE(doi.doi_bonus_type)](os, object,
ea699e57196e 6761101 zdb/mdb crashes when printing bp with bad checksum, compress or type
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10858
diff changeset
1593 bonus, bsize);
ea699e57196e 6761101 zdb/mdb crashes when printing bp with bad checksum, compress or type
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10858
diff changeset
1594 object_viewer[ZDB_OT_TYPE(doi.doi_type)](os, object, NULL, 0);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1595 *print_header = 1;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1596 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1597
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1598 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
1599 dump_indirect(dn);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1600
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1601 if (verbosity >= 5) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1602 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1603 * Report the list of segments that comprise the object.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1604 */
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1605 uint64_t start = 0;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1606 uint64_t end;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1607 uint64_t blkfill = 1;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1608 int minlvl = 1;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1609
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1610 if (dn->dn_type == DMU_OT_DNODE) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1611 minlvl = 0;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1612 blkfill = DNODES_PER_BLOCK;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1613 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1614
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1615 for (;;) {
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
1616 char segsize[32];
6992
20c04e18c58c 6573681 deleting a very large file can be slow
maybee
parents: 6957
diff changeset
1617 error = dnode_next_offset(dn,
20c04e18c58c 6573681 deleting a very large file can be slow
maybee
parents: 6957
diff changeset
1618 0, &start, minlvl, blkfill, 0);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1619 if (error)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1620 break;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1621 end = start;
6992
20c04e18c58c 6573681 deleting a very large file can be slow
maybee
parents: 6957
diff changeset
1622 error = dnode_next_offset(dn,
20c04e18c58c 6573681 deleting a very large file can be slow
maybee
parents: 6957
diff changeset
1623 DNODE_FIND_HOLE, &end, minlvl, blkfill, 0);
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
1624 zdb_nicenum(end - start, segsize);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1625 (void) printf("\t\tsegment [%016llx, %016llx)"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1626 " size %5s\n", (u_longlong_t)start,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1627 (u_longlong_t)end, segsize);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1628 if (error)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1629 break;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1630 start = end;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1631 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1632 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1633
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1634 if (db != NULL)
1544
938876158511 PSARC 2006/077 zpool clear
eschrock
parents: 1170
diff changeset
1635 dmu_buf_rele(db, FTAG);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1636 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1637
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1638 static char *objset_types[DMU_OST_NUMTYPES] = {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1639 "NONE", "META", "ZPL", "ZVOL", "OTHER", "ANY" };
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1640
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1641 static void
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1642 dump_dir(objset_t *os)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1643 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1644 dmu_objset_stats_t dds;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1645 uint64_t object, object_count;
2885
c0259887ebbc 6460059 zfs destroy <snapshot> leaves behind kruft
ahrens
parents: 2856
diff changeset
1646 uint64_t refdbytes, usedobjs, scratch;
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
1647 char numbuf[32];
9396
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9179
diff changeset
1648 char blkbuf[BP_SPRINTF_LEN + 20];
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1649 char osname[MAXNAMELEN];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1650 char *type = "UNKNOWN";
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1651 int verbosity = dump_opt['d'];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1652 int print_header = 1;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1653 int i, error;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1654
2885
c0259887ebbc 6460059 zfs destroy <snapshot> leaves behind kruft
ahrens
parents: 2856
diff changeset
1655 dmu_objset_fast_stat(os, &dds);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1656
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1657 if (dds.dds_type < DMU_OST_NUMTYPES)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1658 type = objset_types[dds.dds_type];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1659
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1660 if (dds.dds_type == DMU_OST_META) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1661 dds.dds_creation_txg = TXG_INITIAL;
10298
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10242
diff changeset
1662 usedobjs = os->os_rootbp->blk_fill;
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10242
diff changeset
1663 refdbytes = os->os_spa->spa_dsl_pool->
7390
6d408f0a5fbd PSARC/2008/518 ZFS space accounting enhancements
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7265
diff changeset
1664 dp_mos_dir->dd_phys->dd_used_bytes;
2885
c0259887ebbc 6460059 zfs destroy <snapshot> leaves behind kruft
ahrens
parents: 2856
diff changeset
1665 } else {
c0259887ebbc 6460059 zfs destroy <snapshot> leaves behind kruft
ahrens
parents: 2856
diff changeset
1666 dmu_objset_space(os, &refdbytes, &scratch, &usedobjs, &scratch);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1667 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1668
10298
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10242
diff changeset
1669 ASSERT3U(usedobjs, ==, os->os_rootbp->blk_fill);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1670
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
1671 zdb_nicenum(refdbytes, numbuf);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1672
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1673 if (verbosity >= 4) {
10857
2c20a0bd87cd 6892882 zdb -ddddd prints garbage from stack between dataset summary and rootbp
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10685
diff changeset
1674 (void) sprintf(blkbuf, ", rootbp ");
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1675 (void) sprintf_blkptr(blkbuf + strlen(blkbuf), os->os_rootbp);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1676 } else {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1677 blkbuf[0] = '\0';
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1678 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1679
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1680 dmu_objset_name(os, osname);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1681
2885
c0259887ebbc 6460059 zfs destroy <snapshot> leaves behind kruft
ahrens
parents: 2856
diff changeset
1682 (void) printf("Dataset %s [%s], ID %llu, cr_txg %llu, "
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1683 "%s, %llu objects%s\n",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1684 osname, type, (u_longlong_t)dmu_objset_id(os),
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1685 (u_longlong_t)dds.dds_creation_txg,
2885
c0259887ebbc 6460059 zfs destroy <snapshot> leaves behind kruft
ahrens
parents: 2856
diff changeset
1686 numbuf, (u_longlong_t)usedobjs, blkbuf);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1687
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1688 if (zopt_objects != 0) {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1689 for (i = 0; i < zopt_objects; i++)
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1690 dump_object(os, zopt_object[i], verbosity,
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1691 &print_header);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1692 (void) printf("\n");
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1693 return;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1694 }
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1695
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1696 if (dump_opt['i'] != 0 || verbosity >= 2)
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1697 dump_intent_log(dmu_objset_zil(os));
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1698
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1699 if (dmu_objset_ds(os) != NULL)
12470
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1700 dump_deadlist(&dmu_objset_ds(os)->ds_deadlist);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1701
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1702 if (verbosity < 2)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1703 return;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1704
10298
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10242
diff changeset
1705 if (os->os_rootbp->blk_birth == 0)
7046
361307ae060d 6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents: 6992
diff changeset
1706 return;
361307ae060d 6343667 scrub/resilver has to start over when a snapshot is taken
ahrens
parents: 6992
diff changeset
1707
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1708 dump_object(os, 0, verbosity, &print_header);
9396
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9179
diff changeset
1709 object_count = 0;
12684
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12671
diff changeset
1710 if (DMU_USERUSED_DNODE(os) != NULL &&
397e44ebb8a9 6710343 dnode cache should register a dnode_move() callback to limit fragmentation
Tom Erickson <Tom.Erickson@Sun.COM>
parents: 12671
diff changeset
1711 DMU_USERUSED_DNODE(os)->dn_type != 0) {
9396
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9179
diff changeset
1712 dump_object(os, DMU_USERUSED_OBJECT, verbosity, &print_header);
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9179
diff changeset
1713 dump_object(os, DMU_GROUPUSED_OBJECT, verbosity, &print_header);
f41cf682d0d3 PSARC/2009/204 ZFS user/group quotas & space accounting
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 9179
diff changeset
1714 }
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1715
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1716 object = 0;
3025
4e5ee8301d84 6424466 "panic: data after EOF" when unmounting abused pool
ahrens
parents: 2926
diff changeset
1717 while ((error = dmu_object_next(os, &object, B_FALSE, 0)) == 0) {
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1718 dump_object(os, object, verbosity, &print_header);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1719 object_count++;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1720 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1721
2885
c0259887ebbc 6460059 zfs destroy <snapshot> leaves behind kruft
ahrens
parents: 2856
diff changeset
1722 ASSERT3U(object_count, ==, usedobjs);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1723
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1724 (void) printf("\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1725
8924
5af812f84759 6789318 coredump when issue zdb -uuuu poolname/
Rich Morris <Richard.Morris@Sun.COM>
parents: 8241
diff changeset
1726 if (error != ESRCH) {
5af812f84759 6789318 coredump when issue zdb -uuuu poolname/
Rich Morris <Richard.Morris@Sun.COM>
parents: 8241
diff changeset
1727 (void) fprintf(stderr, "dmu_object_next() = %d\n", error);
5af812f84759 6789318 coredump when issue zdb -uuuu poolname/
Rich Morris <Richard.Morris@Sun.COM>
parents: 8241
diff changeset
1728 abort();
5af812f84759 6789318 coredump when issue zdb -uuuu poolname/
Rich Morris <Richard.Morris@Sun.COM>
parents: 8241
diff changeset
1729 }
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1730 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1731
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1732 static void
11725
68a79ddc6b27 6720637 want zdb -l option to dump uberblock arrays as well
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11724
diff changeset
1733 dump_uberblock(uberblock_t *ub, const char *header, const char *footer)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1734 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1735 time_t timestamp = ub->ub_timestamp;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1736
11725
68a79ddc6b27 6720637 want zdb -l option to dump uberblock arrays as well
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11724
diff changeset
1737 (void) printf(header ? header : "");
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1738 (void) printf("\tmagic = %016llx\n", (u_longlong_t)ub->ub_magic);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1739 (void) printf("\tversion = %llu\n", (u_longlong_t)ub->ub_version);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1740 (void) printf("\ttxg = %llu\n", (u_longlong_t)ub->ub_txg);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1741 (void) printf("\tguid_sum = %llu\n", (u_longlong_t)ub->ub_guid_sum);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1742 (void) printf("\ttimestamp = %llu UTC = %s",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1743 (u_longlong_t)ub->ub_timestamp, asctime(localtime(&timestamp)));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1744 if (dump_opt['u'] >= 3) {
896
f5270e6bd04d 6348089 panic in dbuf_remove_ref
maybee
parents: 885
diff changeset
1745 char blkbuf[BP_SPRINTF_LEN];
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1746 sprintf_blkptr(blkbuf, &ub->ub_rootbp);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1747 (void) printf("\trootbp = %s\n", blkbuf);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1748 }
11725
68a79ddc6b27 6720637 want zdb -l option to dump uberblock arrays as well
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11724
diff changeset
1749 (void) printf(footer ? footer : "");
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1750 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1751
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1752 static void
10860
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
1753 dump_config(spa_t *spa)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1754 {
10860
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
1755 dmu_buf_t *db;
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
1756 size_t nvsize = 0;
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
1757 int error = 0;
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
1758
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
1759
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
1760 error = dmu_bonus_hold(spa->spa_meta_objset,
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
1761 spa->spa_config_object, FTAG, &db);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1762
10860
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
1763 if (error == 0) {
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
1764 nvsize = *(uint64_t *)db->db_data;
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
1765 dmu_buf_rele(db, FTAG);
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
1766
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
1767 (void) printf("\nMOS Configuration:\n");
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
1768 dump_packed_nvlist(spa->spa_meta_objset,
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
1769 spa->spa_config_object, (void *)&nvsize, 1);
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
1770 } else {
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
1771 (void) fprintf(stderr, "dmu_bonus_hold(%llu) failed, errno %d",
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
1772 (u_longlong_t)spa->spa_config_object, error);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1773 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1774 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1775
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1776 static void
6643
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6423
diff changeset
1777 dump_cachefile(const char *cachefile)
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6423
diff changeset
1778 {
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6423
diff changeset
1779 int fd;
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6423
diff changeset
1780 struct stat64 statbuf;
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6423
diff changeset
1781 char *buf;
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6423
diff changeset
1782 nvlist_t *config;
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6423
diff changeset
1783
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6423
diff changeset
1784 if ((fd = open64(cachefile, O_RDONLY)) < 0) {
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6423
diff changeset
1785 (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
1786 strerror(errno));
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6423
diff changeset
1787 exit(1);
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6423
diff changeset
1788 }
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6423
diff changeset
1789
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6423
diff changeset
1790 if (fstat64(fd, &statbuf) != 0) {
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6423
diff changeset
1791 (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
1792 strerror(errno));
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6423
diff changeset
1793 exit(1);
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6423
diff changeset
1794 }
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6423
diff changeset
1795
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6423
diff changeset
1796 if ((buf = malloc(statbuf.st_size)) == NULL) {
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6423
diff changeset
1797 (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
1798 (u_longlong_t)statbuf.st_size);
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6423
diff changeset
1799 exit(1);
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6423
diff changeset
1800 }
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6423
diff changeset
1801
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6423
diff changeset
1802 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
1803 (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
1804 (u_longlong_t)statbuf.st_size);
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6423
diff changeset
1805 exit(1);
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6423
diff changeset
1806 }
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6423
diff changeset
1807
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6423
diff changeset
1808 (void) close(fd);
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6423
diff changeset
1809
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6423
diff changeset
1810 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
1811 (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
1812 exit(1);
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6423
diff changeset
1813 }
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6423
diff changeset
1814
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6423
diff changeset
1815 free(buf);
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6423
diff changeset
1816
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6423
diff changeset
1817 dump_nvlist(config, 0);
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6423
diff changeset
1818
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6423
diff changeset
1819 nvlist_free(config);
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6423
diff changeset
1820 }
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6423
diff changeset
1821
11725
68a79ddc6b27 6720637 want zdb -l option to dump uberblock arrays as well
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11724
diff changeset
1822 #define ZDB_MAX_UB_HEADER_SIZE 32
68a79ddc6b27 6720637 want zdb -l option to dump uberblock arrays as well
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11724
diff changeset
1823
68a79ddc6b27 6720637 want zdb -l option to dump uberblock arrays as well
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11724
diff changeset
1824 static void
68a79ddc6b27 6720637 want zdb -l option to dump uberblock arrays as well
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11724
diff changeset
1825 dump_label_uberblocks(vdev_label_t *lbl, uint64_t ashift)
68a79ddc6b27 6720637 want zdb -l option to dump uberblock arrays as well
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11724
diff changeset
1826 {
68a79ddc6b27 6720637 want zdb -l option to dump uberblock arrays as well
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11724
diff changeset
1827 vdev_t vd;
68a79ddc6b27 6720637 want zdb -l option to dump uberblock arrays as well
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11724
diff changeset
1828 vdev_t *vdp = &vd;
68a79ddc6b27 6720637 want zdb -l option to dump uberblock arrays as well
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11724
diff changeset
1829 char header[ZDB_MAX_UB_HEADER_SIZE];
68a79ddc6b27 6720637 want zdb -l option to dump uberblock arrays as well
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11724
diff changeset
1830
68a79ddc6b27 6720637 want zdb -l option to dump uberblock arrays as well
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11724
diff changeset
1831 vd.vdev_ashift = ashift;
68a79ddc6b27 6720637 want zdb -l option to dump uberblock arrays as well
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11724
diff changeset
1832 vdp->vdev_top = vdp;
68a79ddc6b27 6720637 want zdb -l option to dump uberblock arrays as well
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11724
diff changeset
1833
68a79ddc6b27 6720637 want zdb -l option to dump uberblock arrays as well
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11724
diff changeset
1834 for (int i = 0; i < VDEV_UBERBLOCK_COUNT(vdp); i++) {
68a79ddc6b27 6720637 want zdb -l option to dump uberblock arrays as well
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11724
diff changeset
1835 uint64_t uoff = VDEV_UBERBLOCK_OFFSET(vdp, i);
68a79ddc6b27 6720637 want zdb -l option to dump uberblock arrays as well
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11724
diff changeset
1836 uberblock_t *ub = (void *)((char *)lbl + uoff);
68a79ddc6b27 6720637 want zdb -l option to dump uberblock arrays as well
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11724
diff changeset
1837
68a79ddc6b27 6720637 want zdb -l option to dump uberblock arrays as well
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11724
diff changeset
1838 if (uberblock_verify(ub))
68a79ddc6b27 6720637 want zdb -l option to dump uberblock arrays as well
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11724
diff changeset
1839 continue;
68a79ddc6b27 6720637 want zdb -l option to dump uberblock arrays as well
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11724
diff changeset
1840 (void) snprintf(header, ZDB_MAX_UB_HEADER_SIZE,
68a79ddc6b27 6720637 want zdb -l option to dump uberblock arrays as well
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11724
diff changeset
1841 "Uberblock[%d]\n", i);
68a79ddc6b27 6720637 want zdb -l option to dump uberblock arrays as well
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11724
diff changeset
1842 dump_uberblock(ub, header, "");
68a79ddc6b27 6720637 want zdb -l option to dump uberblock arrays as well
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11724
diff changeset
1843 }
68a79ddc6b27 6720637 want zdb -l option to dump uberblock arrays as well
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11724
diff changeset
1844 }
68a79ddc6b27 6720637 want zdb -l option to dump uberblock arrays as well
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11724
diff changeset
1845
6643
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6423
diff changeset
1846 static void
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1847 dump_label(const char *dev)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1848 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1849 int fd;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1850 vdev_label_t label;
11826
f769bc37a3d0 6808244 changing vdev state doesn't update config file
George Wilson <George.Wilson@Sun.COM>
parents: 11811
diff changeset
1851 char *path, *buf = label.vl_vdev_phys.vp_nvlist;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1852 size_t buflen = sizeof (label.vl_vdev_phys.vp_nvlist);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1853 struct stat64 statbuf;
11725
68a79ddc6b27 6720637 want zdb -l option to dump uberblock arrays as well
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11724
diff changeset
1854 uint64_t psize, ashift;
11826
f769bc37a3d0 6808244 changing vdev state doesn't update config file
George Wilson <George.Wilson@Sun.COM>
parents: 11811
diff changeset
1855 int len = strlen(dev) + 1;
f769bc37a3d0 6808244 changing vdev state doesn't update config file
George Wilson <George.Wilson@Sun.COM>
parents: 11811
diff changeset
1856
f769bc37a3d0 6808244 changing vdev state doesn't update config file
George Wilson <George.Wilson@Sun.COM>
parents: 11811
diff changeset
1857 if (strncmp(dev, "/dev/dsk/", 9) == 0) {
f769bc37a3d0 6808244 changing vdev state doesn't update config file
George Wilson <George.Wilson@Sun.COM>
parents: 11811
diff changeset
1858 len++;
f769bc37a3d0 6808244 changing vdev state doesn't update config file
George Wilson <George.Wilson@Sun.COM>
parents: 11811
diff changeset
1859 path = malloc(len);
f769bc37a3d0 6808244 changing vdev state doesn't update config file
George Wilson <George.Wilson@Sun.COM>
parents: 11811
diff changeset
1860 (void) snprintf(path, len, "%s%s", "/dev/rdsk/", dev + 9);
f769bc37a3d0 6808244 changing vdev state doesn't update config file
George Wilson <George.Wilson@Sun.COM>
parents: 11811
diff changeset
1861 } else {
f769bc37a3d0 6808244 changing vdev state doesn't update config file
George Wilson <George.Wilson@Sun.COM>
parents: 11811
diff changeset
1862 path = strdup(dev);
f769bc37a3d0 6808244 changing vdev state doesn't update config file
George Wilson <George.Wilson@Sun.COM>
parents: 11811
diff changeset
1863 }
f769bc37a3d0 6808244 changing vdev state doesn't update config file
George Wilson <George.Wilson@Sun.COM>
parents: 11811
diff changeset
1864
f769bc37a3d0 6808244 changing vdev state doesn't update config file
George Wilson <George.Wilson@Sun.COM>
parents: 11811
diff changeset
1865 if ((fd = open64(path, O_RDONLY)) < 0) {
f769bc37a3d0 6808244 changing vdev state doesn't update config file
George Wilson <George.Wilson@Sun.COM>
parents: 11811
diff changeset
1866 (void) printf("cannot open '%s': %s\n", path, strerror(errno));
f769bc37a3d0 6808244 changing vdev state doesn't update config file
George Wilson <George.Wilson@Sun.COM>
parents: 11811
diff changeset
1867 free(path);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1868 exit(1);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1869 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1870
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1871 if (fstat64(fd, &statbuf) != 0) {
11826
f769bc37a3d0 6808244 changing vdev state doesn't update config file
George Wilson <George.Wilson@Sun.COM>
parents: 11811
diff changeset
1872 (void) printf("failed to stat '%s': %s\n", path,
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1873 strerror(errno));
11826
f769bc37a3d0 6808244 changing vdev state doesn't update config file
George Wilson <George.Wilson@Sun.COM>
parents: 11811
diff changeset
1874 free(path);
f769bc37a3d0 6808244 changing vdev state doesn't update config file
George Wilson <George.Wilson@Sun.COM>
parents: 11811
diff changeset
1875 (void) close(fd);
f769bc37a3d0 6808244 changing vdev state doesn't update config file
George Wilson <George.Wilson@Sun.COM>
parents: 11811
diff changeset
1876 exit(1);
f769bc37a3d0 6808244 changing vdev state doesn't update config file
George Wilson <George.Wilson@Sun.COM>
parents: 11811
diff changeset
1877 }
f769bc37a3d0 6808244 changing vdev state doesn't update config file
George Wilson <George.Wilson@Sun.COM>
parents: 11811
diff changeset
1878
f769bc37a3d0 6808244 changing vdev state doesn't update config file
George Wilson <George.Wilson@Sun.COM>
parents: 11811
diff changeset
1879 if (S_ISBLK(statbuf.st_mode)) {
f769bc37a3d0 6808244 changing vdev state doesn't update config file
George Wilson <George.Wilson@Sun.COM>
parents: 11811
diff changeset
1880 (void) printf("cannot use '%s': character device required\n",
f769bc37a3d0 6808244 changing vdev state doesn't update config file
George Wilson <George.Wilson@Sun.COM>
parents: 11811
diff changeset
1881 path);
f769bc37a3d0 6808244 changing vdev state doesn't update config file
George Wilson <George.Wilson@Sun.COM>
parents: 11811
diff changeset
1882 free(path);
f769bc37a3d0 6808244 changing vdev state doesn't update config file
George Wilson <George.Wilson@Sun.COM>
parents: 11811
diff changeset
1883 (void) close(fd);
f769bc37a3d0 6808244 changing vdev state doesn't update config file
George Wilson <George.Wilson@Sun.COM>
parents: 11811
diff changeset
1884 exit(1);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1885 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1886
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1887 psize = statbuf.st_size;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1888 psize = P2ALIGN(psize, (uint64_t)sizeof (vdev_label_t));
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1889
11725
68a79ddc6b27 6720637 want zdb -l option to dump uberblock arrays as well
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11724
diff changeset
1890 for (int l = 0; l < VDEV_LABELS; l++) {
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1891 nvlist_t *config = NULL;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1892
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1893 (void) printf("--------------------------------------------\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1894 (void) printf("LABEL %d\n", l);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1895 (void) printf("--------------------------------------------\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1896
1170
cbb023fb2c22 6366222 zdb(1M) needs to use largefile primitives when reading label
eschrock
parents: 896
diff changeset
1897 if (pread64(fd, &label, sizeof (label),
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1898 vdev_label_offset(psize, l, 0)) != sizeof (label)) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1899 (void) printf("failed to read label %d\n", l);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1900 continue;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1901 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1902
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1903 if (nvlist_unpack(buf, buflen, &config, 0) != 0) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1904 (void) printf("failed to unpack label %d\n", l);
11725
68a79ddc6b27 6720637 want zdb -l option to dump uberblock arrays as well
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11724
diff changeset
1905 ashift = SPA_MINBLOCKSHIFT;
68a79ddc6b27 6720637 want zdb -l option to dump uberblock arrays as well
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11724
diff changeset
1906 } else {
68a79ddc6b27 6720637 want zdb -l option to dump uberblock arrays as well
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11724
diff changeset
1907 nvlist_t *vdev_tree = NULL;
68a79ddc6b27 6720637 want zdb -l option to dump uberblock arrays as well
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11724
diff changeset
1908
68a79ddc6b27 6720637 want zdb -l option to dump uberblock arrays as well
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11724
diff changeset
1909 dump_nvlist(config, 4);
68a79ddc6b27 6720637 want zdb -l option to dump uberblock arrays as well
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11724
diff changeset
1910 if ((nvlist_lookup_nvlist(config,
68a79ddc6b27 6720637 want zdb -l option to dump uberblock arrays as well
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11724
diff changeset
1911 ZPOOL_CONFIG_VDEV_TREE, &vdev_tree) != 0) ||
68a79ddc6b27 6720637 want zdb -l option to dump uberblock arrays as well
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11724
diff changeset
1912 (nvlist_lookup_uint64(vdev_tree,
68a79ddc6b27 6720637 want zdb -l option to dump uberblock arrays as well
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11724
diff changeset
1913 ZPOOL_CONFIG_ASHIFT, &ashift) != 0))
68a79ddc6b27 6720637 want zdb -l option to dump uberblock arrays as well
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11724
diff changeset
1914 ashift = SPA_MINBLOCKSHIFT;
68a79ddc6b27 6720637 want zdb -l option to dump uberblock arrays as well
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11724
diff changeset
1915 nvlist_free(config);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1916 }
11725
68a79ddc6b27 6720637 want zdb -l option to dump uberblock arrays as well
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11724
diff changeset
1917 if (dump_opt['u'])
68a79ddc6b27 6720637 want zdb -l option to dump uberblock arrays as well
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11724
diff changeset
1918 dump_label_uberblocks(&label, ashift);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1919 }
11826
f769bc37a3d0 6808244 changing vdev state doesn't update config file
George Wilson <George.Wilson@Sun.COM>
parents: 11811
diff changeset
1920
f769bc37a3d0 6808244 changing vdev state doesn't update config file
George Wilson <George.Wilson@Sun.COM>
parents: 11811
diff changeset
1921 free(path);
f769bc37a3d0 6808244 changing vdev state doesn't update config file
George Wilson <George.Wilson@Sun.COM>
parents: 11811
diff changeset
1922 (void) close(fd);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1923 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1924
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1925 /*ARGSUSED*/
2199
712a788c2dfd PSARC 2006/388 snapshot -r
ahrens
parents: 2082
diff changeset
1926 static int
11209
462283cb4096 6905188 panic: kernel heap corruption when doing "zfs rename -r"
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 11165
diff changeset
1927 dump_one_dir(const char *dsname, void *arg)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1928 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1929 int error;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1930 objset_t *os;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1931
10298
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10242
diff changeset
1932 error = dmu_objset_own(dsname, DMU_OST_ANY, B_TRUE, FTAG, &os);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1933 if (error) {
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1934 (void) printf("Could not open %s, error %d\n", dsname, error);
2199
712a788c2dfd PSARC 2006/388 snapshot -r
ahrens
parents: 2082
diff changeset
1935 return (0);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1936 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1937 dump_dir(os);
10298
a0d52501437c 6860996 %temporary clones are not automatically destroyed on error
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 10242
diff changeset
1938 dmu_objset_disown(os, FTAG);
5959
1e1904b8526d 6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents: 5530
diff changeset
1939 fuid_table_destroy();
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
1940 sa_loaded = B_FALSE;
2199
712a788c2dfd PSARC 2006/388 snapshot -r
ahrens
parents: 2082
diff changeset
1941 return (0);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1942 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
1943
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1944 /*
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1945 * Block statistics.
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1946 */
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1947 typedef struct zdb_blkstats {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1948 uint64_t zb_asize;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1949 uint64_t zb_lsize;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1950 uint64_t zb_psize;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1951 uint64_t zb_count;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1952 } zdb_blkstats_t;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1953
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1954 /*
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1955 * Extended object types to report deferred frees and dedup auto-ditto blocks.
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1956 */
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1957 #define ZDB_OT_DEFERRED (DMU_OT_NUMTYPES + 0)
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1958 #define ZDB_OT_DITTO (DMU_OT_NUMTYPES + 1)
13700
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
1959 #define ZDB_OT_OTHER (DMU_OT_NUMTYPES + 2)
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
1960 #define ZDB_OT_TOTAL (DMU_OT_NUMTYPES + 3)
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1961
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1962 static char *zdb_ot_extname[] = {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1963 "deferred free",
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1964 "dedup ditto",
13700
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
1965 "other",
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1966 "Total",
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1967 };
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1968
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1969 #define ZB_TOTAL DN_MAX_LEVELS
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1970
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1971 typedef struct zdb_cb {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1972 zdb_blkstats_t zcb_type[ZB_TOTAL + 1][ZDB_OT_TOTAL + 1];
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1973 uint64_t zcb_dedup_asize;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1974 uint64_t zcb_dedup_blocks;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1975 uint64_t zcb_errors[256];
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1976 int zcb_readfails;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1977 int zcb_haderrors;
12470
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1978 spa_t *zcb_spa;
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1979 } zdb_cb_t;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1980
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1981 static void
12470
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
1982 zdb_count_block(zdb_cb_t *zcb, zilog_t *zilog, const blkptr_t *bp,
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1983 dmu_object_type_t type)
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1984 {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1985 uint64_t refcnt = 0;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1986
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1987 ASSERT(type < ZDB_OT_TOTAL);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1988
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1989 if (zilog && zil_bp_tree_add(zilog, bp) != 0)
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1990 return;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1991
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1992 for (int i = 0; i < 4; i++) {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1993 int l = (i < 2) ? BP_GET_LEVEL(bp) : ZB_TOTAL;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1994 int t = (i & 1) ? type : ZDB_OT_TOTAL;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1995 zdb_blkstats_t *zb = &zcb->zcb_type[l][t];
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1996
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1997 zb->zb_asize += BP_GET_ASIZE(bp);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1998 zb->zb_lsize += BP_GET_LSIZE(bp);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
1999 zb->zb_psize += BP_GET_PSIZE(bp);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2000 zb->zb_count++;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2001 }
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2002
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2003 if (dump_opt['L'])
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2004 return;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2005
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2006 if (BP_GET_DEDUP(bp)) {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2007 ddt_t *ddt;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2008 ddt_entry_t *dde;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2009
12470
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
2010 ddt = ddt_select(zcb->zcb_spa, bp);
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2011 ddt_enter(ddt);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2012 dde = ddt_lookup(ddt, bp, B_FALSE);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2013
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2014 if (dde == NULL) {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2015 refcnt = 0;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2016 } else {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2017 ddt_phys_t *ddp = ddt_phys_select(dde, bp);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2018 ddt_phys_decref(ddp);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2019 refcnt = ddp->ddp_refcnt;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2020 if (ddt_phys_total_refcnt(dde) == 0)
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2021 ddt_remove(ddt, dde);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2022 }
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2023 ddt_exit(ddt);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2024 }
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2025
12470
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
2026 VERIFY3U(zio_wait(zio_claim(NULL, zcb->zcb_spa,
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
2027 refcnt ? 0 : spa_first_txg(zcb->zcb_spa),
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2028 bp, NULL, NULL, ZIO_FLAG_CANFAIL)), ==, 0);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2029 }
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2030
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
2031 /* ARGSUSED */
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2032 static int
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
2033 zdb_blkptr_cb(spa_t *spa, zilog_t *zilog, const blkptr_t *bp, arc_buf_t *pbuf,
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2034 const zbookmark_t *zb, const dnode_phys_t *dnp, void *arg)
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2035 {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2036 zdb_cb_t *zcb = arg;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2037 char blkbuf[BP_SPRINTF_LEN];
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2038 dmu_object_type_t type;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2039 boolean_t is_metadata;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2040
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2041 if (bp == NULL)
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2042 return (0);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2043
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2044 type = BP_GET_TYPE(bp);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2045
13700
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
2046 zdb_count_block(zcb, zilog, bp,
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
2047 (type & DMU_OT_NEWTYPE) ? ZDB_OT_OTHER : type);
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
2048
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
2049 is_metadata = (BP_GET_LEVEL(bp) != 0 || DMU_OT_IS_METADATA(type));
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2050
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2051 if (dump_opt['c'] > 1 || (dump_opt['c'] && is_metadata)) {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2052 int ioerr;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2053 size_t size = BP_GET_PSIZE(bp);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2054 void *data = malloc(size);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2055 int flags = ZIO_FLAG_CANFAIL | ZIO_FLAG_SCRUB | ZIO_FLAG_RAW;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2056
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2057 /* If it's an intent log block, failure is expected. */
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2058 if (zb->zb_level == ZB_ZIL_LEVEL)
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2059 flags |= ZIO_FLAG_SPECULATIVE;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2060
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2061 ioerr = zio_wait(zio_read(NULL, spa, bp, data, size,
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2062 NULL, NULL, ZIO_PRIORITY_ASYNC_READ, flags, zb));
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2063
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2064 free(data);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2065
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2066 if (ioerr && !(flags & ZIO_FLAG_SPECULATIVE)) {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2067 zcb->zcb_haderrors = 1;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2068 zcb->zcb_errors[ioerr]++;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2069
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2070 if (dump_opt['b'] >= 2)
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2071 sprintf_blkptr(blkbuf, bp);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2072 else
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2073 blkbuf[0] = '\0';
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2074
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2075 (void) printf("zdb_blkptr_cb: "
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2076 "Got error %d reading "
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2077 "<%llu, %llu, %lld, %llx> %s -- skipping\n",
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2078 ioerr,
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2079 (u_longlong_t)zb->zb_objset,
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2080 (u_longlong_t)zb->zb_object,
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2081 (u_longlong_t)zb->zb_level,
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2082 (u_longlong_t)zb->zb_blkid,
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2083 blkbuf);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2084 }
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2085 }
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2086
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2087 zcb->zcb_readfails = 0;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2088
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2089 if (dump_opt['b'] >= 4) {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2090 sprintf_blkptr(blkbuf, bp);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2091 (void) printf("objset %llu object %llu "
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2092 "level %lld offset 0x%llx %s\n",
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2093 (u_longlong_t)zb->zb_objset,
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2094 (u_longlong_t)zb->zb_object,
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2095 (longlong_t)zb->zb_level,
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2096 (u_longlong_t)blkid2offset(dnp, bp, zb),
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2097 blkbuf);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2098 }
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2099
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2100 return (0);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2101 }
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2102
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2103 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
2104 zdb_leak(space_map_t *sm, uint64_t start, uint64_t size)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2105 {
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
2106 vdev_t *vd = sm->sm_ppd;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2107
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
2108 (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
2109 (u_longlong_t)vd->vdev_id, (u_longlong_t)start, (u_longlong_t)size);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2110 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2111
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
2112 /* 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
2113 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
2114 zdb_space_map_load(space_map_t *sm)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2115 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2116 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2117
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2118 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
2119 zdb_space_map_unload(space_map_t *sm)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2120 {
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
2121 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
2122 }
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2123
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
2124 /* 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
2125 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
2126 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
2127 {
b80e4842ad54 6754011 SPA 3.0: lock breakup, i/o pipeline refactoring, device failure handling
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 7390
diff changeset
2128 }
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2129
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
2130 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
2131 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
2132 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
2133 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
2134 zdb_space_map_claim,
9480
fcff33da767f 6596237 Stop looking and start ganging
George Wilson <George.Wilson@Sun.COM>
parents: 9463
diff changeset
2135 NULL, /* free */
fcff33da767f 6596237 Stop looking and start ganging
George Wilson <George.Wilson@Sun.COM>
parents: 9463
diff changeset
2136 NULL /* maxsize */
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
2137 };
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2138
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2139 static void
11125
fca3e6d28599 6899923 vdev_offline/vdev_add deadlock
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10922
diff changeset
2140 zdb_ddt_leak_init(spa_t *spa, zdb_cb_t *zcb)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2141 {
11125
fca3e6d28599 6899923 vdev_offline/vdev_add deadlock
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10922
diff changeset
2142 ddt_bookmark_t ddb = { 0 };
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2143 ddt_entry_t dde;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2144 int error;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2145
11125
fca3e6d28599 6899923 vdev_offline/vdev_add deadlock
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10922
diff changeset
2146 while ((error = ddt_walk(spa, &ddb, &dde)) == 0) {
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2147 blkptr_t blk;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2148 ddt_phys_t *ddp = dde.dde_phys;
11125
fca3e6d28599 6899923 vdev_offline/vdev_add deadlock
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10922
diff changeset
2149
fca3e6d28599 6899923 vdev_offline/vdev_add deadlock
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10922
diff changeset
2150 if (ddb.ddb_class == DDT_CLASS_UNIQUE)
fca3e6d28599 6899923 vdev_offline/vdev_add deadlock
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10922
diff changeset
2151 return;
fca3e6d28599 6899923 vdev_offline/vdev_add deadlock
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10922
diff changeset
2152
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2153 ASSERT(ddt_phys_total_refcnt(&dde) > 1);
11125
fca3e6d28599 6899923 vdev_offline/vdev_add deadlock
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10922
diff changeset
2154
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2155 for (int p = 0; p < DDT_PHYS_TYPES; p++, ddp++) {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2156 if (ddp->ddp_phys_birth == 0)
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2157 continue;
11125
fca3e6d28599 6899923 vdev_offline/vdev_add deadlock
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10922
diff changeset
2158 ddt_bp_create(ddb.ddb_checksum,
fca3e6d28599 6899923 vdev_offline/vdev_add deadlock
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10922
diff changeset
2159 &dde.dde_key, ddp, &blk);
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2160 if (p == DDT_PHYS_DITTO) {
12470
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
2161 zdb_count_block(zcb, NULL, &blk, ZDB_OT_DITTO);
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2162 } else {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2163 zcb->zcb_dedup_asize +=
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2164 BP_GET_ASIZE(&blk) * (ddp->ddp_refcnt - 1);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2165 zcb->zcb_dedup_blocks++;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2166 }
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2167 }
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2168 if (!dump_opt['L']) {
11125
fca3e6d28599 6899923 vdev_offline/vdev_add deadlock
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10922
diff changeset
2169 ddt_t *ddt = spa->spa_ddt[ddb.ddb_checksum];
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2170 ddt_enter(ddt);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2171 VERIFY(ddt_lookup(ddt, &blk, B_TRUE) != NULL);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2172 ddt_exit(ddt);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2173 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2174 }
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2175
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2176 ASSERT(error == ENOENT);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2177 }
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2178
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2179 static void
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2180 zdb_leak_init(spa_t *spa, zdb_cb_t *zcb)
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2181 {
12470
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
2182 zcb->zcb_spa = spa;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
2183
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2184 if (!dump_opt['L']) {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2185 vdev_t *rvd = spa->spa_root_vdev;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2186 for (int c = 0; c < rvd->vdev_children; c++) {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2187 vdev_t *vd = rvd->vdev_child[c];
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2188 for (int m = 0; m < vd->vdev_ms_count; m++) {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2189 metaslab_t *msp = vd->vdev_ms[m];
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2190 mutex_enter(&msp->ms_lock);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2191 space_map_unload(&msp->ms_map);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2192 VERIFY(space_map_load(&msp->ms_map,
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2193 &zdb_space_map_ops, SM_ALLOC, &msp->ms_smo,
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2194 spa->spa_meta_objset) == 0);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2195 msp->ms_map.sm_ppd = vd;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2196 mutex_exit(&msp->ms_lock);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2197 }
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2198 }
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2199 }
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2200
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2201 spa_config_enter(spa, SCL_CONFIG, FTAG, RW_READER);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2202
11125
fca3e6d28599 6899923 vdev_offline/vdev_add deadlock
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10922
diff changeset
2203 zdb_ddt_leak_init(spa, zcb);
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2204
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2205 spa_config_exit(spa, SCL_CONFIG, FTAG);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2206 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2207
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2208 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
2209 zdb_leak_fini(spa_t *spa)
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2210 {
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2211 if (!dump_opt['L']) {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2212 vdev_t *rvd = spa->spa_root_vdev;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2213 for (int c = 0; c < rvd->vdev_children; c++) {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2214 vdev_t *vd = rvd->vdev_child[c];
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2215 for (int m = 0; m < vd->vdev_ms_count; m++) {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2216 metaslab_t *msp = vd->vdev_ms[m];
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2217 mutex_enter(&msp->ms_lock);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2218 space_map_unload(&msp->ms_map);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2219 mutex_exit(&msp->ms_lock);
7837
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
2220 }
6217
40ffa8cc1b75 6656655 zdb should be able to display blkptr signatures
ek110237
parents: 5994
diff changeset
2221 }
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2222 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2223 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2224
12470
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
2225 /* ARGSUSED */
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
2226 static int
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
2227 count_block_cb(void *arg, const blkptr_t *bp, dmu_tx_t *tx)
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
2228 {
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
2229 zdb_cb_t *zcb = arg;
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
2230
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
2231 if (dump_opt['b'] >= 4) {
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
2232 char blkbuf[BP_SPRINTF_LEN];
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
2233 sprintf_blkptr(blkbuf, bp);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
2234 (void) printf("[%s] %s\n",
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
2235 "deferred free", blkbuf);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
2236 }
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
2237 zdb_count_block(zcb, NULL, bp, ZDB_OT_DEFERRED);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
2238 return (0);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
2239 }
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
2240
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2241 static int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2242 dump_block_stats(spa_t *spa)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2243 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2244 zdb_cb_t zcb = { 0 };
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2245 zdb_blkstats_t *zb, *tzb;
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2246 uint64_t norm_alloc, norm_space, total_alloc, total_found;
11724
a2728800460e 6848238 zdb -bcsv does not report all corruptions
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11497
diff changeset
2247 int flags = TRAVERSE_PRE | TRAVERSE_PREFETCH_METADATA | TRAVERSE_HARD;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2248 int leaks = 0;
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2249
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2250 (void) printf("\nTraversing all blocks %s%s%s%s%s...\n",
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2251 (dump_opt['c'] || !dump_opt['L']) ? "to verify " : "",
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2252 (dump_opt['c'] == 1) ? "metadata " : "",
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2253 dump_opt['c'] ? "checksums " : "",
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2254 (dump_opt['c'] && !dump_opt['L']) ? "and verify " : "",
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2255 !dump_opt['L'] ? "nothing leaked " : "");
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2256
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2257 /*
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
2258 * 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
2259 * 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
2260 * 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
2261 * 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
2262 * 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
2263 * reference to a freed block, or an unclaimed log block.
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2264 */
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2265 zdb_leak_init(spa, &zcb);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2266
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2267 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2268 * If there's a deferred-free bplist, process that first.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2269 */
12470
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
2270 (void) bpobj_iterate_nofree(&spa->spa_deferred_bpobj,
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
2271 count_block_cb, &zcb, NULL);
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
2272 (void) bpobj_iterate_nofree(&spa->spa_dsl_pool->dp_free_bpobj,
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
2273 count_block_cb, &zcb, NULL);
13700
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
2274 if (spa_feature_is_active(spa,
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
2275 &spa_feature_table[SPA_FEATURE_ASYNC_DESTROY])) {
13765
9410cf539b11 backout 3006: causes 3046 (panics after mounting root)
Richard Lowe <richlowe@richlowe.net>
parents: 13764
diff changeset
2276 VERIFY3U(0, ==, bptree_iterate(spa->spa_meta_objset,
13700
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
2277 spa->spa_dsl_pool->dp_bptree_obj, B_FALSE, count_block_cb,
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
2278 &zcb, NULL));
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
2279 }
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2280
11125
fca3e6d28599 6899923 vdev_offline/vdev_add deadlock
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10922
diff changeset
2281 if (dump_opt['c'] > 1)
fca3e6d28599 6899923 vdev_offline/vdev_add deadlock
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10922
diff changeset
2282 flags |= TRAVERSE_PREFETCH_DATA;
fca3e6d28599 6899923 vdev_offline/vdev_add deadlock
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10922
diff changeset
2283
fca3e6d28599 6899923 vdev_offline/vdev_add deadlock
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10922
diff changeset
2284 zcb.zcb_haderrors |= traverse_pool(spa, 0, flags, zdb_blkptr_cb, &zcb);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2285
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2286 if (zcb.zcb_haderrors) {
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2287 (void) printf("\nError counts:\n\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2288 (void) printf("\t%5s %s\n", "errno", "count");
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2289 for (int e = 0; e < 256; e++) {
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2290 if (zcb.zcb_errors[e] != 0) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2291 (void) printf("\t%5d %llu\n",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2292 e, (u_longlong_t)zcb.zcb_errors[e]);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2293 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2294 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2295 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2296
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2297 /*
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2298 * Report any leaked segments.
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2299 */
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2300 zdb_leak_fini(spa);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2301
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2302 tzb = &zcb.zcb_type[ZB_TOTAL][ZDB_OT_TOTAL];
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2303
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2304 norm_alloc = metaslab_class_get_alloc(spa_normal_class(spa));
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2305 norm_space = metaslab_class_get_space(spa_normal_class(spa));
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2306
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2307 total_alloc = norm_alloc + metaslab_class_get_alloc(spa_log_class(spa));
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2308 total_found = tzb->zb_asize - zcb.zcb_dedup_asize;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2309
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2310 if (total_found == total_alloc) {
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
2311 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
2312 (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
2313 " maps exactly)\n");
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2314 } else {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2315 (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
2316 "(%s %lld)\n",
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2317 (u_longlong_t)total_found,
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2318 (u_longlong_t)total_alloc,
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
2319 (dump_opt['L']) ? "unreachable" : "leaked",
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2320 (longlong_t)(total_alloc - total_found));
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2321 leaks = 1;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2322 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2323
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2324 if (tzb->zb_count == 0)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2325 return (2);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2326
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2327 (void) printf("\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2328 (void) printf("\tbp count: %10llu\n",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2329 (u_longlong_t)tzb->zb_count);
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2330 (void) printf("\tbp logical: %10llu avg: %6llu\n",
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2331 (u_longlong_t)tzb->zb_lsize,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2332 (u_longlong_t)(tzb->zb_lsize / tzb->zb_count));
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2333 (void) printf("\tbp physical: %10llu avg:"
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2334 " %6llu compression: %6.2f\n",
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2335 (u_longlong_t)tzb->zb_psize,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2336 (u_longlong_t)(tzb->zb_psize / tzb->zb_count),
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2337 (double)tzb->zb_lsize / tzb->zb_psize);
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2338 (void) printf("\tbp allocated: %10llu avg:"
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2339 " %6llu compression: %6.2f\n",
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2340 (u_longlong_t)tzb->zb_asize,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2341 (u_longlong_t)(tzb->zb_asize / tzb->zb_count),
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2342 (double)tzb->zb_lsize / tzb->zb_asize);
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2343 (void) printf("\tbp deduped: %10llu ref>1:"
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2344 " %6llu deduplication: %6.2f\n",
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2345 (u_longlong_t)zcb.zcb_dedup_asize,
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2346 (u_longlong_t)zcb.zcb_dedup_blocks,
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2347 (double)zcb.zcb_dedup_asize / tzb->zb_asize + 1.0);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2348 (void) printf("\tSPA allocated: %10llu used: %5.2f%%\n",
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2349 (u_longlong_t)norm_alloc, 100.0 * norm_alloc / norm_space);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2350
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2351 if (dump_opt['b'] >= 2) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2352 int l, t, level;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2353 (void) printf("\nBlocks\tLSIZE\tPSIZE\tASIZE"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2354 "\t avg\t comp\t%%Total\tType\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2355
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2356 for (t = 0; t <= ZDB_OT_TOTAL; t++) {
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
2357 char csize[32], lsize[32], psize[32], asize[32];
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
2358 char avg[32];
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2359 char *typename;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2360
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2361 if (t < DMU_OT_NUMTYPES)
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2362 typename = dmu_ot[t].ot_name;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2363 else
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2364 typename = zdb_ot_extname[t - DMU_OT_NUMTYPES];
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2365
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2366 if (zcb.zcb_type[ZB_TOTAL][t].zb_asize == 0) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2367 (void) printf("%6s\t%5s\t%5s\t%5s"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2368 "\t%5s\t%5s\t%6s\t%s\n",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2369 "-",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2370 "-",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2371 "-",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2372 "-",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2373 "-",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2374 "-",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2375 "-",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2376 typename);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2377 continue;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2378 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2379
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2380 for (l = ZB_TOTAL - 1; l >= -1; l--) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2381 level = (l == -1 ? ZB_TOTAL : l);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2382 zb = &zcb.zcb_type[level][t];
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2383
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2384 if (zb->zb_asize == 0)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2385 continue;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2386
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2387 if (dump_opt['b'] < 3 && level != ZB_TOTAL)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2388 continue;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2389
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2390 if (level == 0 && zb->zb_asize ==
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2391 zcb.zcb_type[ZB_TOTAL][t].zb_asize)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2392 continue;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2393
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
2394 zdb_nicenum(zb->zb_count, csize);
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
2395 zdb_nicenum(zb->zb_lsize, lsize);
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
2396 zdb_nicenum(zb->zb_psize, psize);
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
2397 zdb_nicenum(zb->zb_asize, asize);
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
2398 zdb_nicenum(zb->zb_asize / zb->zb_count, avg);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2399
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2400 (void) printf("%6s\t%5s\t%5s\t%5s\t%5s"
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2401 "\t%5.2f\t%6.2f\t",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2402 csize, lsize, psize, asize, avg,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2403 (double)zb->zb_lsize / zb->zb_psize,
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2404 100.0 * zb->zb_asize / tzb->zb_asize);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2405
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2406 if (level == ZB_TOTAL)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2407 (void) printf("%s\n", typename);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2408 else
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2409 (void) printf(" L%d %s\n",
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2410 level, typename);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2411 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2412 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2413 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2414
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2415 (void) printf("\n");
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2416
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2417 if (leaks)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2418 return (2);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2419
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2420 if (zcb.zcb_haderrors)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2421 return (3);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2422
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2423 return (0);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2424 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2425
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2426 typedef struct zdb_ddt_entry {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2427 ddt_key_t zdde_key;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2428 uint64_t zdde_ref_blocks;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2429 uint64_t zdde_ref_lsize;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2430 uint64_t zdde_ref_psize;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2431 uint64_t zdde_ref_dsize;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2432 avl_node_t zdde_node;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2433 } zdb_ddt_entry_t;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2434
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2435 /* ARGSUSED */
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2436 static int
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2437 zdb_ddt_add_cb(spa_t *spa, zilog_t *zilog, const blkptr_t *bp,
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
2438 arc_buf_t *pbuf, const zbookmark_t *zb, const dnode_phys_t *dnp, void *arg)
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2439 {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2440 avl_tree_t *t = arg;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2441 avl_index_t where;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2442 zdb_ddt_entry_t *zdde, zdde_search;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2443
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2444 if (bp == NULL)
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2445 return (0);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2446
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2447 if (dump_opt['S'] > 1 && zb->zb_level == ZB_ROOT_LEVEL) {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2448 (void) printf("traversing objset %llu, %llu objects, "
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2449 "%lu blocks so far\n",
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2450 (u_longlong_t)zb->zb_objset,
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2451 (u_longlong_t)bp->blk_fill,
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2452 avl_numnodes(t));
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2453 }
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2454
11125
fca3e6d28599 6899923 vdev_offline/vdev_add deadlock
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10922
diff changeset
2455 if (BP_IS_HOLE(bp) || BP_GET_CHECKSUM(bp) == ZIO_CHECKSUM_OFF ||
13700
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
2456 BP_GET_LEVEL(bp) > 0 || DMU_OT_IS_METADATA(BP_GET_TYPE(bp)))
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2457 return (0);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2458
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2459 ddt_key_fill(&zdde_search.zdde_key, bp);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2460
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2461 zdde = avl_find(t, &zdde_search, &where);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2462
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2463 if (zdde == NULL) {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2464 zdde = umem_zalloc(sizeof (*zdde), UMEM_NOFAIL);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2465 zdde->zdde_key = zdde_search.zdde_key;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2466 avl_insert(t, zdde, where);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2467 }
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2468
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2469 zdde->zdde_ref_blocks += 1;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2470 zdde->zdde_ref_lsize += BP_GET_LSIZE(bp);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2471 zdde->zdde_ref_psize += BP_GET_PSIZE(bp);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2472 zdde->zdde_ref_dsize += bp_get_dsize_sync(spa, bp);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2473
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2474 return (0);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2475 }
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2476
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2477 static void
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2478 dump_simulated_ddt(spa_t *spa)
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2479 {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2480 avl_tree_t t;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2481 void *cookie = NULL;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2482 zdb_ddt_entry_t *zdde;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2483 ddt_histogram_t ddh_total = { 0 };
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2484 ddt_stat_t dds_total = { 0 };
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2485
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2486 avl_create(&t, ddt_entry_compare,
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2487 sizeof (zdb_ddt_entry_t), offsetof(zdb_ddt_entry_t, zdde_node));
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2488
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2489 spa_config_enter(spa, SCL_CONFIG, FTAG, RW_READER);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2490
11125
fca3e6d28599 6899923 vdev_offline/vdev_add deadlock
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10922
diff changeset
2491 (void) traverse_pool(spa, 0, TRAVERSE_PRE | TRAVERSE_PREFETCH_METADATA,
fca3e6d28599 6899923 vdev_offline/vdev_add deadlock
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10922
diff changeset
2492 zdb_ddt_add_cb, &t);
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2493
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2494 spa_config_exit(spa, SCL_CONFIG, FTAG);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2495
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2496 while ((zdde = avl_destroy_nodes(&t, &cookie)) != NULL) {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2497 ddt_stat_t dds;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2498 uint64_t refcnt = zdde->zdde_ref_blocks;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2499 ASSERT(refcnt != 0);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2500
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2501 dds.dds_blocks = zdde->zdde_ref_blocks / refcnt;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2502 dds.dds_lsize = zdde->zdde_ref_lsize / refcnt;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2503 dds.dds_psize = zdde->zdde_ref_psize / refcnt;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2504 dds.dds_dsize = zdde->zdde_ref_dsize / refcnt;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2505
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2506 dds.dds_ref_blocks = zdde->zdde_ref_blocks;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2507 dds.dds_ref_lsize = zdde->zdde_ref_lsize;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2508 dds.dds_ref_psize = zdde->zdde_ref_psize;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2509 dds.dds_ref_dsize = zdde->zdde_ref_dsize;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2510
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2511 ddt_stat_add(&ddh_total.ddh_stat[highbit(refcnt) - 1], &dds, 0);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2512
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2513 umem_free(zdde, sizeof (*zdde));
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2514 }
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2515
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2516 avl_destroy(&t);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2517
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2518 ddt_histogram_stat(&dds_total, &ddh_total);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2519
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2520 (void) printf("Simulated DDT histogram:\n");
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2521
11149
8bad7424e2c2 6903731 need userland dedup stats
George Wilson <George.Wilson@Sun.COM>
parents: 11146
diff changeset
2522 zpool_dump_ddt(&dds_total, &ddh_total);
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2523
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2524 dump_dedup_ratio(&dds_total);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2525 }
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2526
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2527 static void
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2528 dump_zpool(spa_t *spa)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2529 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2530 dsl_pool_t *dp = spa_get_dsl(spa);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2531 int rc = 0;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2532
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2533 if (dump_opt['S']) {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2534 dump_simulated_ddt(spa);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2535 return;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2536 }
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2537
10860
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
2538 if (!dump_opt['e'] && dump_opt['C'] > 1) {
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
2539 (void) printf("\nCached configuration:\n");
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
2540 dump_nvlist(spa->spa_config, 8);
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
2541 }
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
2542
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
2543 if (dump_opt['C'])
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
2544 dump_config(spa);
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
2545
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2546 if (dump_opt['u'])
11725
68a79ddc6b27 6720637 want zdb -l option to dump uberblock arrays as well
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11724
diff changeset
2547 dump_uberblock(&spa->spa_uberblock, "\nUberblock:\n", "\n");
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2548
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2549 if (dump_opt['D'])
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2550 dump_all_ddts(spa);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2551
10861
ae18f8a4df85 6887242 want to be able to dump specific metaslab(s) for specific vdev
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10860
diff changeset
2552 if (dump_opt['d'] > 2 || dump_opt['m'])
ae18f8a4df85 6887242 want to be able to dump specific metaslab(s) for specific vdev
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10860
diff changeset
2553 dump_metaslabs(spa);
ae18f8a4df85 6887242 want to be able to dump specific metaslab(s) for specific vdev
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10860
diff changeset
2554
ae18f8a4df85 6887242 want to be able to dump specific metaslab(s) for specific vdev
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10860
diff changeset
2555 if (dump_opt['d'] || dump_opt['i']) {
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2556 dump_dir(dp->dp_meta_objset);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2557 if (dump_opt['d'] >= 3) {
12470
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
2558 dump_bpobj(&spa->spa_deferred_bpobj, "Deferred frees");
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
2559 if (spa_version(spa) >= SPA_VERSION_DEADLISTS) {
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
2560 dump_bpobj(&spa->spa_dsl_pool->dp_free_bpobj,
13700
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
2561 "Pool snapshot frees");
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
2562 }
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
2563
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
2564 if (spa_feature_is_active(spa,
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
2565 &spa_feature_table[SPA_FEATURE_ASYNC_DESTROY])) {
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
2566 dump_bptree(spa->spa_meta_objset,
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
2567 spa->spa_dsl_pool->dp_bptree_obj,
2889e2596bd6 2619 asynchronous destruction of ZFS file systems
Christopher Siden <chris.siden@delphix.com>
parents: 13618
diff changeset
2568 "Pool dataset frees");
12470
54258108784b 6948890 snapshot deletion can induce pathologically long spa_sync() times
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 12296
diff changeset
2569 }
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2570 dump_dtl(spa->spa_root_vdev, 0);
9480
fcff33da767f 6596237 Stop looking and start ganging
George Wilson <George.Wilson@Sun.COM>
parents: 9463
diff changeset
2571 }
10860
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
2572 (void) dmu_objset_find(spa_name(spa), dump_one_dir,
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
2573 NULL, DS_FIND_SNAPSHOTS | DS_FIND_CHILDREN);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2574 }
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2575 if (dump_opt['b'] || dump_opt['c'])
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2576 rc = dump_block_stats(spa);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2577
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2578 if (dump_opt['s'])
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2579 show_pool_stats(spa);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2580
10685
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
2581 if (dump_opt['h'])
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
2582 dump_history(spa);
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
2583
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2584 if (rc != 0)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2585 exit(rc);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2586 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
2587
1775
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2588 #define ZDB_FLAG_CHECKSUM 0x0001
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2589 #define ZDB_FLAG_DECOMPRESS 0x0002
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2590 #define ZDB_FLAG_BSWAP 0x0004
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2591 #define ZDB_FLAG_GBH 0x0008
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2592 #define ZDB_FLAG_INDIRECT 0x0010
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2593 #define ZDB_FLAG_PHYS 0x0020
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2594 #define ZDB_FLAG_RAW 0x0040
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2595 #define ZDB_FLAG_PRINT_BLKPTR 0x0080
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2596
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2597 int flagbits[256];
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2598
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2599 static void
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2600 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
2601 {
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2602 char blkbuf[BP_SPRINTF_LEN];
1775
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2603
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2604 if (flags & ZDB_FLAG_BSWAP)
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2605 byteswap_uint64_array((void *)bp, sizeof (blkptr_t));
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2606
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2607 sprintf_blkptr(blkbuf, bp);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2608 (void) printf("%s\n", blkbuf);
1775
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2609 }
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2610
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2611 static void
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2612 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
2613 {
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2614 int i;
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2615
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2616 for (i = 0; i < nbps; i++)
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2617 zdb_print_blkptr(&bp[i], flags);
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2618 }
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2619
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2620 static void
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2621 zdb_dump_gbh(void *buf, int flags)
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2622 {
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2623 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
2624 }
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2625
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2626 static void
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2627 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
2628 {
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2629 if (flags & ZDB_FLAG_BSWAP)
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2630 byteswap_uint64_array(buf, size);
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2631 (void) write(1, buf, size);
1775
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2632 }
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2633
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2634 static void
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2635 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
2636 {
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2637 uint64_t *d = (uint64_t *)buf;
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2638 int nwords = size / sizeof (uint64_t);
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2639 int do_bswap = !!(flags & ZDB_FLAG_BSWAP);
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2640 int i, j;
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2641 char *hdr, *c;
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2642
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2643
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2644 if (do_bswap)
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2645 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
2646 else
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2647 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
2648
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2649 (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
2650
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2651 for (i = 0; i < nwords; i += 2) {
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2652 (void) printf("%06llx: %016llx %016llx ",
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2653 (u_longlong_t)(i * sizeof (uint64_t)),
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2654 (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
2655 (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
2656
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2657 c = (char *)&d[i];
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2658 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
2659 (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
2660 (void) printf("\n");
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2661 }
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2662 }
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2663
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2664 /*
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2665 * There are two acceptable formats:
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2666 * 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
2667 * child[.child]* - For example: 0.1.1
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2668 *
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2669 * 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
2670 * 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
2671 * 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
2672 */
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2673 static vdev_t *
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2674 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
2675 {
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2676 char *s, *p, *q;
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2677 int i;
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2678
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2679 if (vdev == NULL)
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2680 return (NULL);
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2681
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2682 /* 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
2683 i = (int)strtoul(path, &s, 10);
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2684 if (s == path || (s && *s != '.' && *s != '\0'))
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2685 goto name;
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2686 if (i < 0 || i >= vdev->vdev_children)
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2687 return (NULL);
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2688
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2689 vdev = vdev->vdev_child[i];
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2690 if (*s == '\0')
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2691 return (vdev);
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2692 return (zdb_vdev_lookup(vdev, s+1));
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2693
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2694 name:
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2695 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
2696 vdev_t *vc = vdev->vdev_child[i];
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2697
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2698 if (vc->vdev_path == NULL) {
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2699 vc = zdb_vdev_lookup(vc, path);
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2700 if (vc == NULL)
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2701 continue;
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2702 else
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2703 return (vc);
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2704 }
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2705
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2706 p = strrchr(vc->vdev_path, '/');
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2707 p = p ? p + 1 : vc->vdev_path;
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2708 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
2709
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2710 if (strcmp(vc->vdev_path, path) == 0)
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2711 return (vc);
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2712 if (strcmp(p, path) == 0)
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2713 return (vc);
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2714 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
2715 return (vc);
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2716 }
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2717
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2718 return (NULL);
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2719 }
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2720
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2721 /*
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2722 * 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
2723 * block descriptor is:
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2724 *
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2725 * pool:vdev_specifier:offset:size[:flags]
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2726 *
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2727 * 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
2728 * 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
2729 * offset - offset, in hex, in bytes
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2730 * 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
2731 * flags - A string of characters specifying options
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2732 * 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
2733 * *c: Calculate and display checksums
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2734 * d: Decompress data before dumping
1775
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2735 * e: Byteswap data before dumping
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2736 * g: Display data as a gang block header
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2737 * i: Display as an indirect block
1775
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2738 * p: Do I/O to physical offset
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2739 * r: Dump raw data to stdout
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2740 *
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2741 * * = not yet implemented
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2742 */
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2743 static void
10860
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
2744 zdb_read_block(char *thing, spa_t *spa)
1775
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2745 {
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2746 blkptr_t blk, *bp = &blk;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2747 dva_t *dva = bp->blk_dva;
1775
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2748 int flags = 0;
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2749 uint64_t offset = 0, size = 0, psize = 0, lsize = 0, blkptr_offset = 0;
1775
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2750 zio_t *zio;
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2751 vdev_t *vd;
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2752 void *pbuf, *lbuf, *buf;
10860
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
2753 char *s, *p, *dup, *vdev, *flagstr;
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2754 int i, error;
1775
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2755
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2756 dup = strdup(thing);
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2757 s = strtok(dup, ":");
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2758 vdev = s ? s : "";
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2759 s = strtok(NULL, ":");
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2760 offset = strtoull(s ? s : "", NULL, 16);
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2761 s = strtok(NULL, ":");
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2762 size = strtoull(s ? s : "", NULL, 16);
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2763 s = strtok(NULL, ":");
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2764 flagstr = s ? s : "";
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2765
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2766 s = NULL;
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2767 if (size == 0)
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2768 s = "size must not be zero";
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2769 if (!IS_P2ALIGNED(size, DEV_BSIZE))
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2770 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
2771 if (!IS_P2ALIGNED(offset, DEV_BSIZE))
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2772 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
2773 if (s) {
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2774 (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
2775 free(dup);
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2776 return;
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2777 }
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2778
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2779 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
2780 for (i = 0; flagstr[i]; i++) {
2856
6f4d5ee1906a 6463348 ZFS code could be more portable
nd150628
parents: 2417
diff changeset
2781 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
2782
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2783 if (bit == 0) {
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2784 (void) printf("***Invalid flag: %c\n",
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2785 flagstr[i]);
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2786 continue;
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2787 }
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2788 flags |= bit;
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2789
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2790 /* If it's not something with an argument, keep going */
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2791 if ((bit & (ZDB_FLAG_CHECKSUM |
1775
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2792 ZDB_FLAG_PRINT_BLKPTR)) == 0)
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2793 continue;
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2794
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2795 p = &flagstr[i + 1];
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2796 if (bit == ZDB_FLAG_PRINT_BLKPTR)
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2797 blkptr_offset = strtoull(p, &p, 16);
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2798 if (*p != ':' && *p != '\0') {
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2799 (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
2800 free(dup);
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2801 return;
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2802 }
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2803 }
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2804 }
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2805
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2806 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
2807 if (vd == NULL) {
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2808 (void) printf("***Invalid vdev: %s\n", vdev);
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2809 free(dup);
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2810 return;
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2811 } else {
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2812 if (vd->vdev_path)
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2813 (void) fprintf(stderr, "Found vdev: %s\n",
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2814 vd->vdev_path);
1775
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2815 else
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2816 (void) fprintf(stderr, "Found vdev type: %s\n",
1775
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2817 vd->vdev_ops->vdev_op_type);
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2818 }
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2819
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2820 psize = size;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2821 lsize = size;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2822
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2823 pbuf = umem_alloc(SPA_MAXBLOCKSIZE, UMEM_NOFAIL);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2824 lbuf = umem_alloc(SPA_MAXBLOCKSIZE, UMEM_NOFAIL);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2825
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2826 BP_ZERO(bp);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2827
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2828 DVA_SET_VDEV(&dva[0], vd->vdev_id);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2829 DVA_SET_OFFSET(&dva[0], offset);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2830 DVA_SET_GANG(&dva[0], !!(flags & ZDB_FLAG_GBH));
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2831 DVA_SET_ASIZE(&dva[0], vdev_psize_to_asize(vd, psize));
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2832
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2833 BP_SET_BIRTH(bp, TXG_INITIAL, TXG_INITIAL);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2834
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2835 BP_SET_LSIZE(bp, lsize);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2836 BP_SET_PSIZE(bp, psize);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2837 BP_SET_COMPRESS(bp, ZIO_COMPRESS_OFF);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2838 BP_SET_CHECKSUM(bp, ZIO_CHECKSUM_OFF);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2839 BP_SET_TYPE(bp, DMU_OT_NONE);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2840 BP_SET_LEVEL(bp, 0);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2841 BP_SET_DEDUP(bp, 0);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2842 BP_SET_BYTEORDER(bp, ZFS_HOST_BYTEORDER);
1775
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2843
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
2844 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
2845 zio = zio_root(spa, NULL, NULL, 0);
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2846
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2847 if (vd == vd->vdev_top) {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2848 /*
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2849 * Treat this as a normal block read.
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2850 */
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2851 zio_nowait(zio_read(zio, spa, bp, pbuf, psize, NULL, NULL,
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2852 ZIO_PRIORITY_SYNC_READ,
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2853 ZIO_FLAG_CANFAIL | ZIO_FLAG_RAW, NULL));
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2854 } else {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2855 /*
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2856 * Treat this as a vdev child I/O.
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2857 */
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2858 zio_nowait(zio_vdev_child_io(zio, bp, vd, offset, pbuf, psize,
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2859 ZIO_TYPE_READ, ZIO_PRIORITY_SYNC_READ,
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2860 ZIO_FLAG_DONT_CACHE | ZIO_FLAG_DONT_QUEUE |
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2861 ZIO_FLAG_DONT_PROPAGATE | ZIO_FLAG_DONT_RETRY |
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2862 ZIO_FLAG_CANFAIL | ZIO_FLAG_RAW, NULL, NULL));
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2863 }
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2864
1775
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2865 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
2866 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
2867
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2868 if (error) {
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2869 (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
2870 goto out;
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2871 }
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2872
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2873 if (flags & ZDB_FLAG_DECOMPRESS) {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2874 /*
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2875 * We don't know how the data was compressed, so just try
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2876 * every decompress function at every inflated blocksize.
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2877 */
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2878 enum zio_compress c;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2879 void *pbuf2 = umem_alloc(SPA_MAXBLOCKSIZE, UMEM_NOFAIL);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2880 void *lbuf2 = umem_alloc(SPA_MAXBLOCKSIZE, UMEM_NOFAIL);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2881
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2882 bcopy(pbuf, pbuf2, psize);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2883
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2884 VERIFY(random_get_pseudo_bytes((uint8_t *)pbuf + psize,
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2885 SPA_MAXBLOCKSIZE - psize) == 0);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2886
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2887 VERIFY(random_get_pseudo_bytes((uint8_t *)pbuf2 + psize,
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2888 SPA_MAXBLOCKSIZE - psize) == 0);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2889
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2890 for (lsize = SPA_MAXBLOCKSIZE; lsize > psize;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2891 lsize -= SPA_MINBLOCKSIZE) {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2892 for (c = 0; c < ZIO_COMPRESS_FUNCTIONS; c++) {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2893 if (zio_decompress_data(c, pbuf, lbuf,
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2894 psize, lsize) == 0 &&
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2895 zio_decompress_data(c, pbuf2, lbuf2,
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2896 psize, lsize) == 0 &&
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2897 bcmp(lbuf, lbuf2, lsize) == 0)
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2898 break;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2899 }
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2900 if (c != ZIO_COMPRESS_FUNCTIONS)
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2901 break;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2902 lsize -= SPA_MINBLOCKSIZE;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2903 }
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2904
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2905 umem_free(pbuf2, SPA_MAXBLOCKSIZE);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2906 umem_free(lbuf2, SPA_MAXBLOCKSIZE);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2907
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2908 if (lsize <= psize) {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2909 (void) printf("Decompress of %s failed\n", thing);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2910 goto out;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2911 }
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2912 buf = lbuf;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2913 size = lsize;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2914 } else {
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2915 buf = pbuf;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2916 size = psize;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2917 }
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2918
1775
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2919 if (flags & ZDB_FLAG_PRINT_BLKPTR)
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2920 zdb_print_blkptr((blkptr_t *)(void *)
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2921 ((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
2922 else if (flags & ZDB_FLAG_RAW)
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2923 zdb_dump_block_raw(buf, size, flags);
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2924 else if (flags & ZDB_FLAG_INDIRECT)
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2925 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
2926 flags);
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2927 else if (flags & ZDB_FLAG_GBH)
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2928 zdb_dump_gbh(buf, flags);
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2929 else
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2930 zdb_dump_block(thing, buf, size, flags);
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2931
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2932 out:
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2933 umem_free(pbuf, SPA_MAXBLOCKSIZE);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
2934 umem_free(lbuf, SPA_MAXBLOCKSIZE);
1775
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2935 free(dup);
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2936 }
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
2937
4627
c85631613c19 6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents: 4577
diff changeset
2938 static boolean_t
10858
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
2939 pool_match(nvlist_t *cfg, char *tgt)
4627
c85631613c19 6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents: 4577
diff changeset
2940 {
10858
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
2941 uint64_t v, guid = strtoull(tgt, NULL, 0);
4627
c85631613c19 6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents: 4577
diff changeset
2942 char *s;
c85631613c19 6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents: 4577
diff changeset
2943
10858
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
2944 if (guid != 0) {
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
2945 if (nvlist_lookup_uint64(cfg, ZPOOL_CONFIG_POOL_GUID, &v) == 0)
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
2946 return (v == guid);
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
2947 } else {
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
2948 if (nvlist_lookup_string(cfg, ZPOOL_CONFIG_POOL_NAME, &s) == 0)
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
2949 return (strcmp(s, tgt) == 0);
4627
c85631613c19 6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents: 4577
diff changeset
2950 }
c85631613c19 6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents: 4577
diff changeset
2951 return (B_FALSE);
c85631613c19 6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents: 4577
diff changeset
2952 }
c85631613c19 6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents: 4577
diff changeset
2953
10858
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
2954 static char *
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
2955 find_zpool(char **target, nvlist_t **configp, int dirc, char **dirv)
4627
c85631613c19 6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents: 4577
diff changeset
2956 {
c85631613c19 6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents: 4577
diff changeset
2957 nvlist_t *pools;
c85631613c19 6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents: 4577
diff changeset
2958 nvlist_t *match = NULL;
10858
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
2959 char *name = NULL;
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
2960 char *sepp = NULL;
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
2961 char sep;
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
2962 int count = 0;
11497
69b45e632792 6698011 zfs incorrectly reports file systems as children when attempting a rename
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11209
diff changeset
2963 importargs_t args = { 0 };
69b45e632792 6698011 zfs incorrectly reports file systems as children when attempting a rename
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11209
diff changeset
2964
69b45e632792 6698011 zfs incorrectly reports file systems as children when attempting a rename
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11209
diff changeset
2965 args.paths = dirc;
69b45e632792 6698011 zfs incorrectly reports file systems as children when attempting a rename
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11209
diff changeset
2966 args.path = dirv;
69b45e632792 6698011 zfs incorrectly reports file systems as children when attempting a rename
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11209
diff changeset
2967 args.can_be_active = B_TRUE;
4627
c85631613c19 6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents: 4577
diff changeset
2968
10858
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
2969 if ((sepp = strpbrk(*target, "/@")) != NULL) {
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
2970 sep = *sepp;
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
2971 *sepp = '\0';
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
2972 }
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
2973
11497
69b45e632792 6698011 zfs incorrectly reports file systems as children when attempting a rename
Mark J Musante <Mark.Musante@Sun.COM>
parents: 11209
diff changeset
2974 pools = zpool_search_import(g_zfs, &args);
4627
c85631613c19 6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents: 4577
diff changeset
2975
c85631613c19 6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents: 4577
diff changeset
2976 if (pools != NULL) {
c85631613c19 6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents: 4577
diff changeset
2977 nvpair_t *elem = NULL;
c85631613c19 6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents: 4577
diff changeset
2978 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
2979 verify(nvpair_value_nvlist(elem, configp) == 0);
10858
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
2980 if (pool_match(*configp, *target)) {
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
2981 count++;
4627
c85631613c19 6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents: 4577
diff changeset
2982 if (match != NULL) {
10858
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
2983 /* print previously found config */
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
2984 if (name != NULL) {
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
2985 (void) printf("%s\n", name);
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
2986 dump_nvlist(match, 8);
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
2987 name = NULL;
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
2988 }
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
2989 (void) printf("%s\n",
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
2990 nvpair_name(elem));
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
2991 dump_nvlist(*configp, 8);
4627
c85631613c19 6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents: 4577
diff changeset
2992 } else {
c85631613c19 6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents: 4577
diff changeset
2993 match = *configp;
10858
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
2994 name = nvpair_name(elem);
4627
c85631613c19 6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents: 4577
diff changeset
2995 }
c85631613c19 6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents: 4577
diff changeset
2996 }
c85631613c19 6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents: 4577
diff changeset
2997 }
c85631613c19 6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents: 4577
diff changeset
2998 }
10858
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
2999 if (count > 1)
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
3000 (void) fatal("\tMatched %d pools - use pool GUID "
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
3001 "instead of pool name or \n"
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
3002 "\tpool name part of a dataset name to select pool", count);
4627
c85631613c19 6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents: 4577
diff changeset
3003
10858
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
3004 if (sepp)
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
3005 *sepp = sep;
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
3006 /*
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
3007 * If pool GUID was specified for pool id, replace it with pool name
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
3008 */
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
3009 if (name && (strstr(*target, name) != *target)) {
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
3010 int sz = 1 + strlen(name) + ((sepp) ? strlen(sepp) : 0);
4627
c85631613c19 6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents: 4577
diff changeset
3011
10858
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
3012 *target = umem_alloc(sz, UMEM_NOFAIL);
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
3013 (void) snprintf(*target, sz, "%s%s", name, sepp ? sepp : "");
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
3014 }
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
3015
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
3016 *configp = name ? match : NULL;
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
3017
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
3018 return (name);
4627
c85631613c19 6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents: 4577
diff changeset
3019 }
c85631613c19 6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents: 4577
diff changeset
3020
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3021 int
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3022 main(int argc, char **argv)
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3023 {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3024 int i, c;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3025 struct rlimit rl = { 1024, 1024 };
10858
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
3026 spa_t *spa = NULL;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3027 objset_t *os = NULL;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3028 int dump_all = 1;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3029 int verbose = 0;
11727
497d03ab2824 6900971 zdb rewind behavior needs to be revisited
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11726
diff changeset
3030 int error = 0;
10858
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
3031 char **searchdirs = NULL;
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
3032 int nsearch = 0;
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
3033 char *target;
10921
8aac17999e4d PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents: 10861
diff changeset
3034 nvlist_t *policy = NULL;
8aac17999e4d PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents: 10861
diff changeset
3035 uint64_t max_txg = UINT64_MAX;
11727
497d03ab2824 6900971 zdb rewind behavior needs to be revisited
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11726
diff changeset
3036 int rewind = ZPOOL_NEVER_REWIND;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3037
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3038 (void) setrlimit(RLIMIT_NOFILE, &rl);
1914
8a8c5f225b1b 4916205 libcmd should not use file operation routines from C library
casper
parents: 1807
diff changeset
3039 (void) enable_extended_FILE_stdio(-1, -1);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3040
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3041 dprintf_setup(&argc, argv);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3042
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
3043 while ((c = getopt(argc, argv, "bcdhilmsuCDRSAFLXevp:t:U:P")) != -1) {
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3044 switch (c) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3045 case 'b':
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3046 case 'c':
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
3047 case 'd':
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
3048 case 'h':
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
3049 case 'i':
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
3050 case 'l':
9480
fcff33da767f 6596237 Stop looking and start ganging
George Wilson <George.Wilson@Sun.COM>
parents: 9463
diff changeset
3051 case 'm':
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3052 case 's':
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
3053 case 'u':
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3054 case 'C':
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
3055 case 'D':
1775
e51e26b432c0 6410698 ZFS metadata needs to be more highly replicated (ditto blocks)
billm
parents: 1732
diff changeset
3056 case 'R':
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
3057 case 'S':
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3058 dump_opt[c]++;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3059 dump_all = 0;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3060 break;
11726
9686f6127423 6896791 want zdb option to set aok and zfs_recover
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11725
diff changeset
3061 case 'A':
11727
497d03ab2824 6900971 zdb rewind behavior needs to be revisited
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11726
diff changeset
3062 case 'F':
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
3063 case 'L':
11727
497d03ab2824 6900971 zdb rewind behavior needs to be revisited
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11726
diff changeset
3064 case 'X':
10858
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
3065 case 'e':
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
3066 case 'P':
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
3067 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
3068 break;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3069 case 'v':
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3070 verbose++;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3071 break;
4627
c85631613c19 6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents: 4577
diff changeset
3072 case 'p':
10858
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
3073 if (searchdirs == NULL) {
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
3074 searchdirs = umem_alloc(sizeof (char *),
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
3075 UMEM_NOFAIL);
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
3076 } else {
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
3077 char **tmp = umem_alloc((nsearch + 1) *
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
3078 sizeof (char *), UMEM_NOFAIL);
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
3079 bcopy(searchdirs, tmp, nsearch *
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
3080 sizeof (char *));
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
3081 umem_free(searchdirs,
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
3082 nsearch * sizeof (char *));
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
3083 searchdirs = tmp;
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
3084 }
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
3085 searchdirs[nsearch++] = optarg;
4627
c85631613c19 6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents: 4577
diff changeset
3086 break;
8188
fd00c0a81e80 6761100 want zdb option to select older uberblocks
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 8121
diff changeset
3087 case 't':
10921
8aac17999e4d PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents: 10861
diff changeset
3088 max_txg = strtoull(optarg, NULL, 0);
8aac17999e4d PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents: 10861
diff changeset
3089 if (max_txg < TXG_INITIAL) {
8188
fd00c0a81e80 6761100 want zdb option to select older uberblocks
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 8121
diff changeset
3090 (void) fprintf(stderr, "incorrect txg "
fd00c0a81e80 6761100 want zdb option to select older uberblocks
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 8121
diff changeset
3091 "specified: %s\n", optarg);
fd00c0a81e80 6761100 want zdb option to select older uberblocks
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 8121
diff changeset
3092 usage();
fd00c0a81e80 6761100 want zdb option to select older uberblocks
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 8121
diff changeset
3093 }
fd00c0a81e80 6761100 want zdb option to select older uberblocks
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 8121
diff changeset
3094 break;
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
3095 case 'U':
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
3096 spa_config_path = optarg;
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
3097 break;
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3098 default:
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3099 usage();
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3100 break;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3101 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3102 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3103
10858
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
3104 if (!dump_opt['e'] && searchdirs != NULL) {
7837
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
3105 (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
3106 usage();
001de5627df3 6333409 traversal code should be able to issue multiple reads in parallel
Matthew Ahrens <Matthew.Ahrens@Sun.COM>
parents: 7754
diff changeset
3107 }
4627
c85631613c19 6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents: 4577
diff changeset
3108
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3109 kernel_init(FREAD);
4627
c85631613c19 6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents: 4577
diff changeset
3110 g_zfs = libzfs_init();
4787
602d3f97842c 6393351 unique_* could be improved
ahrens
parents: 4627
diff changeset
3111 ASSERT(g_zfs != NULL);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3112
10922
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
3113 if (dump_all)
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
3114 verbose = MAX(verbose, 1);
e2081f502306 PSARC 2009/571 ZFS Deduplication Properties
Jeff Bonwick <Jeff.Bonwick@Sun.COM>
parents: 10921
diff changeset
3115
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3116 for (c = 0; c < 256; c++) {
12296
7cf402a7f374 6675946 'zpool status' should show the progress of resilvering for individual disk.
Lin Ling <Lin.Ling@Sun.COM>
parents: 12050
diff changeset
3117 if (dump_all && !strchr("elAFLRSXP", c))
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3118 dump_opt[c] = 1;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3119 if (dump_opt[c])
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3120 dump_opt[c] += verbose;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3121 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3122
11726
9686f6127423 6896791 want zdb option to set aok and zfs_recover
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11725
diff changeset
3123 aok = (dump_opt['A'] == 1) || (dump_opt['A'] > 2);
9686f6127423 6896791 want zdb option to set aok and zfs_recover
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11725
diff changeset
3124 zfs_recover = (dump_opt['A'] > 1);
9686f6127423 6896791 want zdb option to set aok and zfs_recover
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11725
diff changeset
3125
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3126 argc -= optind;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3127 argv += optind;
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3128
10860
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
3129 if (argc < 2 && dump_opt['R'])
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
3130 usage();
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3131 if (argc < 1) {
10858
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
3132 if (!dump_opt['e'] && dump_opt['C']) {
6957
ad855bd47277 6689844 ztest fails with "zdb: can't open ztest: No such device or address"
ck153898
parents: 6807
diff changeset
3133 dump_cachefile(spa_config_path);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3134 return (0);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3135 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3136 usage();
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3137 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3138
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3139 if (dump_opt['l']) {
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3140 dump_label(argv[0]);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3141 return (0);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3142 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3143
11727
497d03ab2824 6900971 zdb rewind behavior needs to be revisited
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11726
diff changeset
3144 if (dump_opt['X'] || dump_opt['F'])
497d03ab2824 6900971 zdb rewind behavior needs to be revisited
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11726
diff changeset
3145 rewind = ZPOOL_DO_REWIND |
497d03ab2824 6900971 zdb rewind behavior needs to be revisited
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11726
diff changeset
3146 (dump_opt['X'] ? ZPOOL_EXTREME_REWIND : 0);
497d03ab2824 6900971 zdb rewind behavior needs to be revisited
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11726
diff changeset
3147
497d03ab2824 6900971 zdb rewind behavior needs to be revisited
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11726
diff changeset
3148 if (nvlist_alloc(&policy, NV_UNIQUE_NAME_TYPE, 0) != 0 ||
497d03ab2824 6900971 zdb rewind behavior needs to be revisited
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11726
diff changeset
3149 nvlist_add_uint64(policy, ZPOOL_REWIND_REQUEST_TXG, max_txg) != 0 ||
497d03ab2824 6900971 zdb rewind behavior needs to be revisited
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11726
diff changeset
3150 nvlist_add_uint32(policy, ZPOOL_REWIND_REQUEST, rewind) != 0)
497d03ab2824 6900971 zdb rewind behavior needs to be revisited
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11726
diff changeset
3151 fatal("internal error: %s", strerror(ENOMEM));
497d03ab2824 6900971 zdb rewind behavior needs to be revisited
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11726
diff changeset
3152
6643
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6423
diff changeset
3153 error = 0;
10858
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
3154 target = argv[0];
4627
c85631613c19 6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents: 4577
diff changeset
3155
10858
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
3156 if (dump_opt['e']) {
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
3157 nvlist_t *cfg = NULL;
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
3158 char *name = find_zpool(&target, &cfg, nsearch, searchdirs);
5094
71a3e95fb9e2 PSARC 2007/342 Enhanced ZFS Pool Properties
lling
parents: 4831
diff changeset
3159
10858
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
3160 error = ENOENT;
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
3161 if (name) {
10860
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
3162 if (dump_opt['C'] > 1) {
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
3163 (void) printf("\nConfiguration for import:\n");
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
3164 dump_nvlist(cfg, 8);
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
3165 }
11727
497d03ab2824 6900971 zdb rewind behavior needs to be revisited
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 11726
diff changeset
3166 if (nvlist_add_nvlist(cfg,
10921
8aac17999e4d PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents: 10861
diff changeset
3167 ZPOOL_REWIND_POLICY, policy) != 0) {
8aac17999e4d PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents: 10861
diff changeset
3168 fatal("can't open '%s': %s",
8aac17999e4d PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents: 10861
diff changeset
3169 target, strerror(ENOMEM));
8aac17999e4d PSARC 2009/479 zpool recovery support
Tim Haley <Tim.Haley@Sun.COM>
parents: 10861
diff changeset
3170 }
12961
b521d551715f 6733267 Allow a pool to be imported with a missing slog
George Wilson <George.Wilson@Sun.COM>
parents: 12684
diff changeset
3171 if ((error = spa_import(name, cfg, NULL,
b521d551715f 6733267 Allow a pool to be imported with a missing slog
George Wilson <George.Wilson@Sun.COM>
parents: 12684
diff changeset
3172 ZFS_IMPORT_MISSING_LOG)) != 0) {
b521d551715f 6733267 Allow a pool to be imported with a missing slog
George Wilson <George.Wilson@Sun.COM>
parents: 12684
diff changeset
3173 error = spa_import(name, cfg, NULL,
b521d551715f 6733267 Allow a pool to be imported with a missing slog
George Wilson <George.Wilson@Sun.COM>
parents: 12684
diff changeset
3174 ZFS_IMPORT_VERBATIM);
b521d551715f 6733267 Allow a pool to be imported with a missing slog
George Wilson <George.Wilson@Sun.COM>
parents: 12684
diff changeset
3175 }
4627
c85631613c19 6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents: 4577
diff changeset
3176 }
6643
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6423
diff changeset
3177 }
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6423
diff changeset
3178
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6423
diff changeset
3179 if (error == 0) {
10860
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
3180 if (strpbrk(target, "/@") == NULL || dump_opt['R']) {
11146
7e58f40bcb1c 6826241 Sync write IOPS drops dramatically during TXG sync
George Wilson <George.Wilson@Sun.COM>
parents: 11125
diff changeset
3181 error = spa_open_rewind(target, &spa, FTAG, policy,
7e58f40bcb1c 6826241 Sync write IOPS drops dramatically during TXG sync
George Wilson <George.Wilson@Sun.COM>
parents: 11125
diff changeset
3182 NULL);
10685
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
3183 if (error) {
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
3184 /*
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
3185 * If we're missing the log device then
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
3186 * try opening the pool after clearing the
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
3187 * log state.
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
3188 */
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
3189 mutex_enter(&spa_namespace_lock);
10858
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
3190 if ((spa = spa_lookup(target)) != NULL &&
10685
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
3191 spa->spa_log_state == SPA_LOG_MISSING) {
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
3192 spa->spa_log_state = SPA_LOG_CLEAR;
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
3193 error = 0;
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
3194 }
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
3195 mutex_exit(&spa_namespace_lock);
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
3196
11146
7e58f40bcb1c 6826241 Sync write IOPS drops dramatically during TXG sync
George Wilson <George.Wilson@Sun.COM>
parents: 11125
diff changeset
3197 if (!error) {
7e58f40bcb1c 6826241 Sync write IOPS drops dramatically during TXG sync
George Wilson <George.Wilson@Sun.COM>
parents: 11125
diff changeset
3198 error = spa_open_rewind(target, &spa,
7e58f40bcb1c 6826241 Sync write IOPS drops dramatically during TXG sync
George Wilson <George.Wilson@Sun.COM>
parents: 11125
diff changeset
3199 FTAG, policy, NULL);
7e58f40bcb1c 6826241 Sync write IOPS drops dramatically during TXG sync
George Wilson <George.Wilson@Sun.COM>
parents: 11125
diff changeset
3200 }
10685
931790026ac6 6846163 ZFS continues to use faulted logzilla, bringing system to a crawl
George Wilson <George.Wilson@Sun.COM>
parents: 10594
diff changeset
3201 }
10860
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
3202 } else {
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
3203 error = dmu_objset_own(target, DMU_OST_ANY,
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
3204 B_TRUE, FTAG, &os);
6643
3a34b0dbb107 6625086 changing cachefile doesn't remove old cache on last user
eschrock
parents: 6423
diff changeset
3205 }
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3206 }
11146
7e58f40bcb1c 6826241 Sync write IOPS drops dramatically during TXG sync
George Wilson <George.Wilson@Sun.COM>
parents: 11125
diff changeset
3207 nvlist_free(policy);
7e58f40bcb1c 6826241 Sync write IOPS drops dramatically during TXG sync
George Wilson <George.Wilson@Sun.COM>
parents: 11125
diff changeset
3208
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3209 if (error)
10858
9efff268b959 6709782 issues using zdb with -e option
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10857
diff changeset
3210 fatal("can't open '%s': %s", target, strerror(error));
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3211
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3212 argv++;
10860
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
3213 argc--;
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
3214 if (!dump_opt['R']) {
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
3215 if (argc > 0) {
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
3216 zopt_objects = argc;
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
3217 zopt_object = calloc(zopt_objects, sizeof (uint64_t));
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
3218 for (i = 0; i < zopt_objects; i++) {
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
3219 errno = 0;
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
3220 zopt_object[i] = strtoull(argv[i], NULL, 0);
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
3221 if (zopt_object[i] == 0 && errno != 0)
10861
ae18f8a4df85 6887242 want to be able to dump specific metaslab(s) for specific vdev
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10860
diff changeset
3222 fatal("bad number %s: %s",
10860
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
3223 argv[i], strerror(errno));
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
3224 }
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3225 }
10860
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
3226 (os != NULL) ? dump_dir(os) : dump_zpool(spa);
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
3227 } else {
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
3228 flagbits['b'] = ZDB_FLAG_PRINT_BLKPTR;
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
3229 flagbits['c'] = ZDB_FLAG_CHECKSUM;
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
3230 flagbits['d'] = ZDB_FLAG_DECOMPRESS;
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
3231 flagbits['e'] = ZDB_FLAG_BSWAP;
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
3232 flagbits['g'] = ZDB_FLAG_GBH;
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
3233 flagbits['i'] = ZDB_FLAG_INDIRECT;
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
3234 flagbits['p'] = ZDB_FLAG_PHYS;
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
3235 flagbits['r'] = ZDB_FLAG_RAW;
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
3236
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
3237 for (i = 0; i < argc; i++)
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
3238 zdb_read_block(argv[i], spa);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3239 }
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3240
10860
f850bd358163 6736356 zdb -R/-C needs to work with exported pools
Victor Latushkin <Victor.Latushkin@Sun.COM>
parents: 10859
diff changeset
3241 (os != NULL) ? dmu_objset_disown(os, FTAG) : spa_close(spa, FTAG);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3242
5959
1e1904b8526d 6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents: 5530
diff changeset
3243 fuid_table_destroy();
11935
538c866aaac6 6716117 ZFS needs native system attribute infrastructure
Mark Shellenbaum <Mark.Shellenbaum@Sun.COM>
parents: 11826
diff changeset
3244 sa_loaded = B_FALSE;
5959
1e1904b8526d 6650192 zfs ACL/fuid code could use some minor cleanup
marks
parents: 5530
diff changeset
3245
4627
c85631613c19 6509812 it would be useful if zdb(1M) could run on exported pools
ck153898
parents: 4577
diff changeset
3246 libzfs_fini(g_zfs);
789
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3247 kernel_fini();
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3248
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3249 return (0);
b348f31ed315 PSARC 2002/240 ZFS
ahrens
parents:
diff changeset
3250 }