5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License (the "License").
7 # You may not use this file except in compliance with the License.
9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 # or http://www.opensolaris.org/os/licensing.
11 # See the License for the specific language governing permissions
12 # and limitations under the License.
14 # When distributing Covered Code, include this CDDL HEADER in each
15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 # If applicable, add the following below this CDDL HEADER, with the
17 # fields enclosed by brackets "[]" replaced with your own identifying
18 # information: Portions Copyright [yyyy] [name of copyright owner]
24 # Copyright 2008 Sun Microsystems, Inc. All rights reserved.
25 # Use is subject to license terms.
29 # Copyright (c) 2013, 2016 by Delphix. All rights reserved.
32 .
$STF_SUITE/include
/libtest.shlib
36 # Verify that the ZFS mdb dcmds and walkers are working as expected.
39 # 1) Given a list of dcmds and walkers
40 # 2) Step through each element of the list
41 # 3) Verify the output by checking for "mdb:" in the output string
49 verify_runnable
"global"
53 log_must zpool scrub
$TESTPOOL
55 typeset spa
=$
(mdb
-ke "::spa" |
awk "/$TESTPOOL/ {print \$1}")
56 typeset off_ub
=$
(mdb
-ke "::offsetof spa_t spa_uberblock | =J")
57 typeset off_rbp
=$
(mdb
-ke "::offsetof uberblock_t ub_rootbp | =J")
58 typeset bp
=$
(mdb
-ke "$spa + $off_ub + $off_rbp =J")
60 # dcmds and walkers skipped due to being DEBUG only or difficult to run:
64 set -A dcmds
"::abuf_find 1 2" \
67 "::arc_compression_stats" \
79 "$spa ::spa_space -b" \
81 "$spa ::print spa_t spa_root_vdev | ::vdev" \
82 "$spa ::print spa_t spa_root_vdev | ::vdev -re" \
83 "$spa ::print -a spa_t spa_dsl_pool->dp_dirty_datasets | ::walk txg_list" \
84 "$spa ::print -a spa_t spa_uberblock.ub_rootbp | ::blkptr" \
85 "$spa ::walk metaslab" \
86 "$spa ::walk metaslab | ::head -1 | ::metaslab_weight" \
87 "$spa ::walk metaslab | ::head -1 | ::metaslab_trace" \
88 "$spa ::walk zio_root | ::zio -c" \
89 "$spa ::walk zio_root | ::zio -r" \
90 "$spa ::walk zms_freelist"
91 "$spa ::zfs_blkstats -v" \
93 "::dbufs -n mos -o mdn -l 0 -b 0" \
96 "dbuf_cache ::walk multilist"
98 # The commands above were supplied by the ZFS development team. The idea is to
99 # do as much checking as possible without the need to hardcode addresses.
102 log_assert
"Verify that the ZFS mdb dcmds and walkers are working as expected."
107 while (( $i < ${#dcmds[*]} )); do
108 log_note
"Verifying: '${dcmds[i]}'"
109 echo "${dcmds[i]}" | mdb
-k > $OUTFILE 2>&1
111 if (( $RET != 0 )); then
112 log_fail
"mdb '${dcmds[i]}' returned error $RET"
116 # mdb prefixes all errors with "mdb: " so we check the output.
118 grep "mdb:" $OUTFILE > /dev
/null
2>&1
120 if (( $RET == 0 )); then
121 echo "mdb '${dcmds[i]}' contained 'mdb:'"
122 # Using tail limits the number of lines in the log
124 log_fail
"mdb walker or dcmd failed"
130 log_pass
"The ZFS mdb dcmds and walkers are working as expected."