zdb: add support for object ranges for zdb -d

Allow a range of object identifiers to dump with -d. This may
be useful when dumping a large dataset and you want to break
it up into multiple phases, or to resume where a previous scan
left off. Object type selection flags are supported to reduce
the performance overhead of verbosely dumping unwanted objects,
and to reduce the amount of post-processing work needed to
filter out unwanted objects from zdb output.

This change extends existing syntax in a backward-compatible
way. That is, the base case of a range is to specify a single
object identifier to dump. Ranges and object identifiers can
be intermixed as command line parameters.

Usage synopsis:

    Object ranges take the form <start>:<end>[:<flags>]
        start    Starting object number
        end      Ending object number, or -1 for no upper bound
        flags    Optional flags to select object types:
         A    All objects (this is the default)
         d    ZFS directories
         f    ZFS files
         m    SPA space maps
         z    ZAPs
         -    Negate effect of next flag

Examples:

 # Dump all file objects
 zdb -dd tank/fish 0:-1:f

 # Dump all file and directory objects
 zdb -dd tank/fish 0:-1:fd

 # Dump all types except file and directory objects
 zdb -dd tank/fish 0:-1:A-f-d

 # Dump object IDs in a specific range
 zdb -dd tank/fish 1000:2000

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Ryan Moeller <ryan@ixsystems.com>
Reviewed-by: Paul Zuchowski <pzuchowski@datto.com>
Signed-off-by: Ned Bass <bass6@llnl.gov>
Closes #9832
This commit is contained in:
Ned Bass
2020-01-24 11:00:46 -08:00
committed by Brian Behlendorf
parent 8e9e90bba3
commit a3403164d7
6 changed files with 555 additions and 50 deletions
+41 -4
View File
@@ -31,12 +31,12 @@
.Op Fl U Ar cache
.Op Fl x Ar dumpdir
.Op Ar poolname[/dataset | objset ID]
.Op Ar object ...
.Op Ar object | range ...
.Nm
.Op Fl AdiPv
.Op Fl e Oo Fl V Oc Op Fl p Ar path ...
.Op Fl U Ar cache
.Ar poolname[/dataset | objset ID] Op Ar object ...
.Ar poolname[/dataset | objset ID] Op Ar object | range ...
.Nm
.Fl C
.Op Fl A
@@ -135,8 +135,45 @@ size, and object count.
.Pp
If specified multiple times provides greater and greater verbosity.
.Pp
If object IDs are specified, display information about those specific objects
only.
If object IDs or object ID ranges are specified, display information about
those specific objects or ranges only.
.Pp
An object ID range is specified in terms of a colon-separated tuple of
the form
.Ao start Ac Ns : Ns Ao end Ac Ns Op Ns : Ns Ao flags Ac Ns .
The fields
.Ar start
and
.Ar end
are integer object identfiers that denote the upper and lower bounds
of the range. An
.Ar end
value of -1 specifies a range with no upper bound. The
.Ar flags
field optionally specifies a set of flags, described below, that control
which object types are dumped. By default, all object types are dumped. A minus
sign
.Pq -
negates the effect of the flag that follows it and has no effect unless
preceded by the
.Ar A
flag. For example, the range 0:-1:A-d will dump all object types except
for directories.
.Pp
.Bl -tag -compact
.It Sy A
Dump all objects (this is the default)
.It Sy d
Dump ZFS directory objects
.It Sy f
Dump ZFS plain file objects
.It Sy m
Dump SPA space map objects
.It Sy z
Dump ZAP objects
.It Sy -
Negate the effect of next flag
.El
.It Fl D
Display deduplication statistics, including the deduplication ratio
.Pq Sy dedup ,