xref: /freebsd/sys/contrib/openzfs/man/man8/zdb.8 (revision 9768746b)
1.\"
2.\" This file and its contents are supplied under the terms of the
3.\" Common Development and Distribution License ("CDDL"), version 1.0.
4.\" You may only use this file in accordance with the terms of version
5.\" 1.0 of the CDDL.
6.\"
7.\" A full copy of the text of the CDDL should have accompanied this
8.\" source.  A copy of the CDDL is also available via the Internet at
9.\" http://www.illumos.org/license/CDDL.
10.\"
11.\" Copyright 2012, Richard Lowe.
12.\" Copyright (c) 2012, 2019 by Delphix. All rights reserved.
13.\" Copyright 2017 Nexenta Systems, Inc.
14.\" Copyright (c) 2017 Lawrence Livermore National Security, LLC.
15.\" Copyright (c) 2017 Intel Corporation.
16.\"
17.Dd October 7, 2020
18.Dt ZDB 8
19.Os
20.
21.Sh NAME
22.Nm zdb
23.Nd display ZFS storage pool debugging and consistency information
24.Sh SYNOPSIS
25.Nm
26.Op Fl AbcdDFGhikLMNPsvXYy
27.Op Fl e Oo Fl V Oc Oo Fl p Ar path Oc Ns …
28.Op Fl I Ar inflight-I/O-ops
29.Oo Fl o Ar var Ns = Ns Ar value Oc Ns …
30.Op Fl t Ar txg
31.Op Fl U Ar cache
32.Op Fl x Ar dumpdir
33.Op Ar poolname Ns Op / Ns Ar dataset Ns | Ns Ar objset-ID
34.Op Ar object Ns | Ns Ar range Ns …
35.Nm
36.Op Fl AdiPv
37.Op Fl e Oo Fl V Oc Oo Fl p Ar path Oc Ns …
38.Op Fl U Ar cache
39.Ar poolname Ns Op Ar / Ns Ar dataset Ns | Ns Ar objset-ID
40.Op Ar object Ns | Ns Ar range Ns …
41.Nm
42.Fl C
43.Op Fl A
44.Op Fl U Ar cache
45.Nm
46.Fl E
47.Op Fl A
48.Ar word0 : Ns Ar word1 Ns :…: Ns Ar word15
49.Nm
50.Fl l
51.Op Fl Aqu
52.Ar device
53.Nm
54.Fl m
55.Op Fl AFLPXY
56.Op Fl e Oo Fl V Oc Oo Fl p Ar path Oc Ns …
57.Op Fl t Ar txg
58.Op Fl U Ar cache
59.Ar poolname Op Ar vdev Oo Ar metaslab Oc Ns …
60.Nm
61.Fl O
62.Ar dataset path
63.Nm
64.Fl r
65.Ar dataset path destination
66.Nm
67.Fl R
68.Op Fl A
69.Op Fl e Oo Fl V Oc Oo Fl p Ar path Oc Ns …
70.Op Fl U Ar cache
71.Ar poolname vdev : Ns Ar offset : Ns Oo Ar lsize Ns / Oc Ns Ar psize Ns Op : Ns Ar flags
72.Nm
73.Fl S
74.Op Fl AP
75.Op Fl e Oo Fl V Oc Oo Fl p Ar path Oc Ns …
76.Op Fl U Ar cache
77.Ar poolname
78.
79.Sh DESCRIPTION
80The
81.Nm
82utility displays information about a ZFS pool useful for debugging and performs
83some amount of consistency checking.
84It is a not a general purpose tool and options
85.Pq and facilities
86may change.
87It is not a
88.Xr fsck 8
89utility.
90.Pp
91The output of this command in general reflects the on-disk structure of a ZFS
92pool, and is inherently unstable.
93The precise output of most invocations is not documented, a knowledge of ZFS
94internals is assumed.
95.Pp
96If the
97.Ar dataset
98argument does not contain any
99.Qq Sy /
100or
101.Qq Sy @
102characters, it is interpreted as a pool name.
103The root dataset can be specified as
104.Qq Ar pool Ns / .
105.Pp
106When operating on an imported and active pool it is possible, though unlikely,
107that zdb may interpret inconsistent pool data and behave erratically.
108.
109.Sh OPTIONS
110Display options:
111.Bl -tag -width Ds
112.It Fl b , -block-stats
113Display statistics regarding the number, size
114.Pq logical, physical and allocated
115and deduplication of blocks.
116.It Fl c , -checksum
117Verify the checksum of all metadata blocks while printing block statistics
118.Po see
119.Fl b
120.Pc .
121.Pp
122If specified multiple times, verify the checksums of all blocks.
123.It Fl C , -config
124Display information about the configuration.
125If specified with no other options, instead display information about the cache
126file
127.Pq Pa /etc/zfs/zpool.cache .
128To specify the cache file to display, see
129.Fl U .
130.Pp
131If specified multiple times, and a pool name is also specified display both the
132cached configuration and the on-disk configuration.
133If specified multiple times with
134.Fl e
135also display the configuration that would be used were the pool to be imported.
136.It Fl d , -datasets
137Display information about datasets.
138Specified once, displays basic dataset information: ID, create transaction,
139size, and object count.
140See
141.Fl N
142for determining if
143.Ar poolname Ns Op / Ns Ar dataset Ns | Ns Ar objset-ID
144is to use the specified
145.Ar dataset Ns | Ns Ar objset-ID
146as a string (dataset name) or a number (objset ID) when
147datasets have numeric names.
148.Pp
149If specified multiple times provides greater and greater verbosity.
150.Pp
151If object IDs or object ID ranges are specified, display information about
152those specific objects or ranges only.
153.Pp
154An object ID range is specified in terms of a colon-separated tuple of
155the form
156.Ao start Ac : Ns Ao end Ac Ns Op : Ns Ao flags Ac .
157The fields
158.Ar start
159and
160.Ar end
161are integer object identifiers that denote the upper and lower bounds
162of the range.
163An
164.Ar end
165value of -1 specifies a range with no upper bound.
166The
167.Ar flags
168field optionally specifies a set of flags, described below, that control
169which object types are dumped.
170By default, all object types are dumped.
171A minus sign
172.Pq -
173negates the effect of the flag that follows it and has no effect unless
174preceded by the
175.Ar A
176flag.
177For example, the range 0:-1:A-d will dump all object types except for
178directories.
179.Pp
180.Bl -tag -compact -width Ds
181.It Sy A
182Dump all objects (this is the default)
183.It Sy d
184Dump ZFS directory objects
185.It Sy f
186Dump ZFS plain file objects
187.It Sy m
188Dump SPA space map objects
189.It Sy z
190Dump ZAP objects
191.It Sy -
192Negate the effect of next flag
193.El
194.It Fl D , -dedup-stats
195Display deduplication statistics, including the deduplication ratio
196.Pq Sy dedup ,
197compression ratio
198.Pq Sy compress ,
199inflation due to the zfs copies property
200.Pq Sy copies ,
201and an overall effective ratio
202.Pq Sy dedup No \(mu Sy compress No / Sy copies .
203.It Fl DD
204Display a histogram of deduplication statistics, showing the allocated
205.Pq physically present on disk
206and referenced
207.Pq logically referenced in the pool
208block counts and sizes by reference count.
209.It Fl DDD
210Display the statistics independently for each deduplication table.
211.It Fl DDDD
212Dump the contents of the deduplication tables describing duplicate blocks.
213.It Fl DDDDD
214Also dump the contents of the deduplication tables describing unique blocks.
215.It Fl E , -embedded-block-pointer Ns = Ns Ar word0 : Ns Ar word1 Ns :…: Ns Ar word15
216Decode and display block from an embedded block pointer specified by the
217.Ar word
218arguments.
219.It Fl h , -history
220Display pool history similar to
221.Nm zpool Cm history ,
222but include internal changes, transaction, and dataset information.
223.It Fl i , -intent-logs
224Display information about intent log
225.Pq ZIL
226entries relating to each dataset.
227If specified multiple times, display counts of each intent log transaction type.
228.It Fl k , -checkpointed-state
229Examine the checkpointed state of the pool.
230Note, the on disk format of the pool is not reverted to the checkpointed state.
231.It Fl l , -label Ns = Ns Ar device
232Read the vdev labels and L2ARC header from the specified device.
233.Nm Fl l
234will return 0 if valid label was found, 1 if error occurred, and 2 if no valid
235labels were found.
236The presence of L2ARC header is indicated by a specific
237sequence (L2ARC_DEV_HDR_MAGIC).
238If there is an accounting error in the size or the number of L2ARC log blocks
239.Nm Fl l
240will return 1.
241Each unique configuration is displayed only once.
242.It Fl ll Ar device
243In addition display label space usage stats.
244If a valid L2ARC header was found
245also display the properties of log blocks used for restoring L2ARC contents
246(persistent L2ARC).
247.It Fl lll Ar device
248Display every configuration, unique or not.
249If a valid L2ARC header was found
250also display the properties of log entries in log blocks used for restoring
251L2ARC contents (persistent L2ARC).
252.Pp
253If the
254.Fl q
255option is also specified, don't print the labels or the L2ARC header.
256.Pp
257If the
258.Fl u
259option is also specified, also display the uberblocks on this device.
260Specify multiple times to increase verbosity.
261.It Fl L , -disable-leak-tracking
262Disable leak detection and the loading of space maps.
263By default,
264.Nm
265verifies that all non-free blocks are referenced, which can be very expensive.
266.It Fl m , -metaslabs
267Display the offset, spacemap, free space of each metaslab, all the log
268spacemaps and their obsolete entry statistics.
269.It Fl mm
270Also display information about the on-disk free space histogram associated with
271each metaslab.
272.It Fl mmm
273Display the maximum contiguous free space, the in-core free space histogram, and
274the percentage of free space in each space map.
275.It Fl mmmm
276Display every spacemap record.
277.It Fl M , -metaslab-groups
278Display all "normal" vdev metaslab group information - per-vdev metaslab count,
279fragmentation,
280and free space histogram, as well as overall pool fragmentation and histogram.
281.It Fl MM
282"Special" vdevs are added to -M's normal output.
283.It Fl O , -object-lookups Ns = Ns Ar dataset path
284Also display information about the maximum contiguous free space and the
285percentage of free space in each space map.
286.It Fl MMM
287Display every spacemap record.
288.It Fl N
289Same as
290.Fl d
291but force zdb to interpret the
292.Op Ar dataset Ns | Ns Ar objset-ID
293in
294.Op Ar poolname Ns Op / Ns Ar dataset Ns | Ns Ar objset-ID
295as a numeric objset ID.
296.It Fl O Ar dataset path
297Look up the specified
298.Ar path
299inside of the
300.Ar dataset
301and display its metadata and indirect blocks.
302Specified
303.Ar path
304must be relative to the root of
305.Ar dataset .
306This option can be combined with
307.Fl v
308for increasing verbosity.
309.It Fl r , -copy-object Ns = Ns Ar dataset path destination
310Copy the specified
311.Ar path
312inside of the
313.Ar dataset
314to the specified destination.
315Specified
316.Ar path
317must be relative to the root of
318.Ar dataset .
319This option can be combined with
320.Fl v
321for increasing verbosity.
322.It Xo
323.Fl R , -read-block Ns = Ns Ar poolname vdev : Ns Ar offset : Ns Oo Ar lsize Ns / Oc Ns Ar psize Ns Op : Ns Ar flags
324.Xc
325Read and display a block from the specified device.
326By default the block is displayed as a hex dump, but see the description of the
327.Sy r
328flag, below.
329.Pp
330The block is specified in terms of a colon-separated tuple
331.Ar vdev
332.Pq an integer vdev identifier
333.Ar offset
334.Pq the offset within the vdev
335.Ar size
336.Pq the physical size, or logical size / physical size
337of the block to read and, optionally,
338.Ar flags
339.Pq a set of flags, described below .
340.Pp
341.Bl -tag -compact -width "b offset"
342.It Sy b Ar offset
343Print block pointer at hex offset
344.It Sy c
345Calculate and display checksums
346.It Sy d
347Decompress the block.
348Set environment variable
349.Nm ZDB_NO_ZLE
350to skip zle when guessing.
351.It Sy e
352Byte swap the block
353.It Sy g
354Dump gang block header
355.It Sy i
356Dump indirect block
357.It Sy r
358Dump raw uninterpreted block data
359.It Sy v
360Verbose output for guessing compression algorithm
361.El
362.It Fl s , -io-stats
363Report statistics on
364.Nm zdb
365I/O.
366Display operation counts, bandwidth, and error counts of I/O to the pool from
367.Nm .
368.It Fl S , -simulate-dedup
369Simulate the effects of deduplication, constructing a DDT and then display
370that DDT as with
371.Fl DD .
372.It Fl u , -uberblock
373Display the current uberblock.
374.El
375.Pp
376Other options:
377.Bl -tag -width Ds
378.It Fl A , -ignore-assertions
379Do not abort should any assertion fail.
380.It Fl AA
381Enable panic recovery, certain errors which would otherwise be fatal are
382demoted to warnings.
383.It Fl AAA
384Do not abort if asserts fail and also enable panic recovery.
385.It Fl e , -exported Ns = Ns Oo Fl p Ar path Oc Ns …
386Operate on an exported pool, not present in
387.Pa /etc/zfs/zpool.cache .
388The
389.Fl p
390flag specifies the path under which devices are to be searched.
391.It Fl x , -dump-blocks Ns = Ns Ar dumpdir
392All blocks accessed will be copied to files in the specified directory.
393The blocks will be placed in sparse files whose name is the same as
394that of the file or device read.
395.Nm
396can be then run on the generated files.
397Note that the
398.Fl bbc
399flags are sufficient to access
400.Pq and thus copy
401all metadata on the pool.
402.It Fl F , -automatic-rewind
403Attempt to make an unreadable pool readable by trying progressively older
404transactions.
405.It Fl G , -dump-debug-msg
406Dump the contents of the zfs_dbgmsg buffer before exiting
407.Nm .
408zfs_dbgmsg is a buffer used by ZFS to dump advanced debug information.
409.It Fl I , -inflight Ns = Ns Ar inflight-I/O-ops
410Limit the number of outstanding checksum I/O operations to the specified value.
411The default value is 200.
412This option affects the performance of the
413.Fl c
414option.
415.It Fl o , -option Ns = Ns Ar var Ns = Ns Ar value Ns …
416Set the given global libzpool variable to the provided value.
417The value must be an unsigned 32-bit integer.
418Currently only little-endian systems are supported to avoid accidentally setting
419the high 32 bits of 64-bit variables.
420.It Fl P , -parseable
421Print numbers in an unscaled form more amenable to parsing, e.g.\&
422.Sy 1000000
423rather than
424.Sy 1M .
425.It Fl t , -txg Ns = Ns Ar transaction
426Specify the highest transaction to use when searching for uberblocks.
427See also the
428.Fl u
429and
430.Fl l
431options for a means to see the available uberblocks and their associated
432transaction numbers.
433.It Fl U , -cachefile Ns = Ns Ar cachefile
434Use a cache file other than
435.Pa /etc/zfs/zpool.cache .
436.It Fl v , -verbose
437Enable verbosity.
438Specify multiple times for increased verbosity.
439.It Fl V , -verbatim
440Attempt verbatim import.
441This mimics the behavior of the kernel when loading a pool from a cachefile.
442Only usable with
443.Fl e .
444.It Fl X , -extreme-rewind
445Attempt
446.Qq extreme
447transaction rewind, that is attempt the same recovery as
448.Fl F
449but read transactions otherwise deemed too old.
450.It Fl Y , -all-reconstruction
451Attempt all possible combinations when reconstructing indirect split blocks.
452This flag disables the individual I/O deadman timer in order to allow as
453much time as required for the attempted reconstruction.
454.It Fl y , -livelist
455Perform validation for livelists that are being deleted.
456Scans through the livelist and metaslabs, checking for duplicate entries
457and compares the two, checking for potential double frees.
458If it encounters issues, warnings will be printed, but the command will not
459necessarily fail.
460.El
461.Pp
462Specifying a display option more than once enables verbosity for only that
463option, with more occurrences enabling more verbosity.
464.Pp
465If no options are specified, all information about the named pool will be
466displayed at default verbosity.
467.
468.Sh EXAMPLES
469.Ss Example 1 : No Display the configuration of imported pool Ar rpool
470.Bd -literal
471.No # Nm zdb Fl C Ar rpool
472MOS Configuration:
473        version: 28
474        name: 'rpool'
475476.Ed
477.
478.Ss Example 2 : No Display basic dataset information about Ar rpool
479.Bd -literal
480.No # Nm zdb Fl d Ar rpool
481Dataset mos [META], ID 0, cr_txg 4, 26.9M, 1051 objects
482Dataset rpool/swap [ZVOL], ID 59, cr_txg 356, 486M, 2 objects
483484.Ed
485.
486.Ss Example 3 : No Display basic information about object 0 in Ar rpool/export/home
487.Bd -literal
488.No # Nm zdb Fl d Ar rpool/export/home 0
489Dataset rpool/export/home [ZPL], ID 137, cr_txg 1546, 32K, 8 objects
490
491    Object  lvl   iblk   dblk  dsize  lsize   %full  type
492         0    7    16K    16K  15.0K    16K   25.00  DMU dnode
493.Ed
494.
495.Ss Example 4 : No Display the predicted effect of enabling deduplication on Ar rpool
496.Bd -literal
497.No # Nm zdb Fl S Ar rpool
498Simulated DDT histogram:
499
500bucket              allocated                       referenced
501______   ______________________________   ______________________________
502refcnt   blocks   LSIZE   PSIZE   DSIZE   blocks   LSIZE   PSIZE   DSIZE
503------   ------   -----   -----   -----   ------   -----   -----   -----
504     1     694K   27.1G   15.0G   15.0G     694K   27.1G   15.0G   15.0G
505     2    35.0K   1.33G    699M    699M    74.7K   2.79G   1.45G   1.45G
506507dedup = 1.11, compress = 1.80, copies = 1.00, dedup * compress / copies = 2.00
508.Ed
509.
510.Sh SEE ALSO
511.Xr zfs 8 ,
512.Xr zpool 8
513