Make zstreamdump -v more greppable
Currently, the verbose output of zstreamdump includes new line characters within some individual records. Presumably, this was originally done to keep the output from getting too wide to fit on a terminal. However, since new flags and struct members have been added, these rules have not been maintained consistently. In addition, these newlines can make it hard to grep the output in some scenarios. This patch simply removes these newlines, making the output easier to grep and removing the inconsistency. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Matt Ahrens <mahrens@delphix.com> Reviewed by: Allan Jude <allanjude@freebsd.org> Signed-off-by: Tom Caputi <tcaputi@datto.com> Closes #8493
This commit is contained in:
parent
1814242379
commit
5cc9ba5cf0
|
@ -523,8 +523,8 @@ main(int argc, char *argv[])
|
||||||
ZIO_DATA_MAC_LEN);
|
ZIO_DATA_MAC_LEN);
|
||||||
|
|
||||||
(void) printf("WRITE object = %llu type = %u "
|
(void) printf("WRITE object = %llu type = %u "
|
||||||
"checksum type = %u compression type = %u\n"
|
"checksum type = %u compression type = %u "
|
||||||
" flags = %u offset = %llu "
|
"flags = %u offset = %llu "
|
||||||
"logical_size = %llu "
|
"logical_size = %llu "
|
||||||
"compressed_size = %llu "
|
"compressed_size = %llu "
|
||||||
"payload_size = %llu props = %llx "
|
"payload_size = %llu props = %llx "
|
||||||
|
@ -578,10 +578,10 @@ main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
(void) printf("WRITE_BYREF object = %llu "
|
(void) printf("WRITE_BYREF object = %llu "
|
||||||
"checksum type = %u props = %llx\n"
|
"checksum type = %u props = %llx "
|
||||||
" offset = %llu length = %llu\n"
|
"offset = %llu length = %llu "
|
||||||
"toguid = %llx refguid = %llx\n"
|
"toguid = %llx refguid = %llx "
|
||||||
" refobject = %llu refoffset = %llu\n",
|
"refobject = %llu refoffset = %llu\n",
|
||||||
(u_longlong_t)drrwbr->drr_object,
|
(u_longlong_t)drrwbr->drr_object,
|
||||||
drrwbr->drr_checksumtype,
|
drrwbr->drr_checksumtype,
|
||||||
(u_longlong_t)drrwbr->drr_key.ddk_prop,
|
(u_longlong_t)drrwbr->drr_key.ddk_prop,
|
||||||
|
@ -665,8 +665,8 @@ main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
if (verbose) {
|
if (verbose) {
|
||||||
(void) printf("WRITE_EMBEDDED object = %llu "
|
(void) printf("WRITE_EMBEDDED object = %llu "
|
||||||
"offset = %llu length = %llu\n"
|
"offset = %llu length = %llu "
|
||||||
" toguid = %llx comp = %u etype = %u "
|
"toguid = %llx comp = %u etype = %u "
|
||||||
"lsize = %u psize = %u\n",
|
"lsize = %u psize = %u\n",
|
||||||
(u_longlong_t)drrwe->drr_object,
|
(u_longlong_t)drrwe->drr_object,
|
||||||
(u_longlong_t)drrwe->drr_offset,
|
(u_longlong_t)drrwe->drr_offset,
|
||||||
|
|
|
@ -619,27 +619,6 @@ function stream_has_features
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
#
|
|
||||||
# Parse zstreamdump -v output. The output varies for each kind of record:
|
|
||||||
# BEGIN records are simply output as "BEGIN"
|
|
||||||
# END records are output as "END"
|
|
||||||
# OBJECT records become "OBJECT <object num>"
|
|
||||||
# FREEOBJECTS records become "FREEOBJECTS <startobj> <numobjs>"
|
|
||||||
# FREE records become "<record type> <start> <length>"
|
|
||||||
# WRITE records become:
|
|
||||||
# "<record type> <compression type> <start> <logical size> <compressed size>
|
|
||||||
# <data size>"
|
|
||||||
#
|
|
||||||
function parse_dump
|
|
||||||
{
|
|
||||||
sed '/^WRITE/{N;s/\n/ /;}' | grep "^[A-Z]" | awk '{
|
|
||||||
if ($1 == "BEGIN" || $1 == "END") print $1
|
|
||||||
if ($1 == "OBJECT") print $1" "$4
|
|
||||||
if ($1 == "FREEOBJECTS") print $1" "$4" "$7
|
|
||||||
if ($1 == "FREE") print $1" "$7" "$10
|
|
||||||
if ($1 == "WRITE") print $1" "$15" "$21" "$24" "$27" "$30}'
|
|
||||||
}
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Given a send stream, verify that the size of the stream matches what's
|
# Given a send stream, verify that the size of the stream matches what's
|
||||||
# expected based on the source or target dataset. If the stream is an
|
# expected based on the source or target dataset. If the stream is an
|
||||||
|
|
|
@ -42,15 +42,15 @@ log_must zfs snapshot $sendfs@full
|
||||||
|
|
||||||
log_must eval "zfs send -c $sendfs@full >$BACKDIR/full"
|
log_must eval "zfs send -c $sendfs@full >$BACKDIR/full"
|
||||||
log_must stream_has_features $BACKDIR/full lz4 compressed
|
log_must stream_has_features $BACKDIR/full lz4 compressed
|
||||||
cat $BACKDIR/full | zstreamdump -v | parse_dump > $BACKDIR/dump.out
|
cat $BACKDIR/full | zstreamdump -v > $BACKDIR/dump.out
|
||||||
|
|
||||||
lsize=$(awk '/^WRITE [^0]/ {lsize += $4} END {printf("%d", lsize)}' \
|
lsize=$(awk '/^WRITE [^0]/ {lsize += $24} END {printf("%d", lsize)}' \
|
||||||
$BACKDIR/dump.out)
|
$BACKDIR/dump.out)
|
||||||
lsize_prop=$(get_prop logicalused $sendfs)
|
lsize_prop=$(get_prop logicalused $sendfs)
|
||||||
within_percent $lsize $lsize_prop 90 || log_fail \
|
within_percent $lsize $lsize_prop 90 || log_fail \
|
||||||
"$lsize and $lsize_prop differed by too much"
|
"$lsize and $lsize_prop differed by too much"
|
||||||
|
|
||||||
csize=$(awk '/^WRITE [^0]/ {csize += $5} END {printf("%d", csize)}' \
|
csize=$(awk '/^WRITE [^0]/ {csize += $27} END {printf("%d", csize)}' \
|
||||||
$BACKDIR/dump.out)
|
$BACKDIR/dump.out)
|
||||||
csize_prop=$(get_prop used $sendfs)
|
csize_prop=$(get_prop used $sendfs)
|
||||||
within_percent $csize $csize_prop 90 || log_fail \
|
within_percent $csize $csize_prop 90 || log_fail \
|
||||||
|
|
Loading…
Reference in New Issue