1#!/bin/ksh -p 2# 3# CDDL HEADER START 4# 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. 8# 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. 13# 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] 19# 20# CDDL HEADER END 21# 22 23# 24# Copyright 2008 Sun Microsystems, Inc. All rights reserved. 25# Use is subject to license terms. 26# 27 28# 29# Copyright (c) 2013, 2017 by Delphix. All rights reserved. 30# Copyright 2020 Joyent, Inc. 31# 32 33. $STF_SUITE/include/libtest.shlib 34 35# 36# DESCRIPTION: 37# Verify that the ZFS mdb dcmds and walkers are working as expected. 38# 39# STRATEGY: 40# 1) Given a list of dcmds and walkers 41# 2) Step through each element of the list 42# 3) Verify the output by checking for "mdb:" in the output string 43# 44 45function cleanup 46{ 47 rm -f $tmpfile 48} 49 50verify_runnable "global" 51log_onexit cleanup 52 53tmpfile=$(mktemp) 54log_must zpool scrub $TESTPOOL 55 56typeset spa=$(mdb -ke "::spa" | awk "/$TESTPOOL/ {print \$1}") 57typeset off_ub=$(mdb -ke "::offsetof spa_t spa_uberblock | =J") 58typeset off_rbp=$(mdb -ke "::offsetof uberblock_t ub_rootbp | =J") 59typeset bp=$(mdb -ke "$spa + $off_ub + $off_rbp =J") 60 61# dcmds and walkers skipped due to being DEBUG only or difficult to run: 62# ::zfs_params 63# ::refcount 64# ::walk zms_freelist 65 66set -A dcmds "::abuf_find 1 2" \ 67 "::arc" \ 68 "::arc -b" \ 69 "::arc_compression_stats" \ 70 "$bp ::blkptr" \ 71 "$bp ::dva" \ 72 "::walk spa" \ 73 "::spa" \ 74 "$spa ::spa " \ 75 "$spa ::spa -c" \ 76 "$spa ::spa -h" \ 77 "$spa ::spa -v" \ 78 "$spa ::spa -Mmh" \ 79 "$spa ::spa_config" \ 80 "$spa ::spa_space" \ 81 "$spa ::spa_space -b" \ 82 "$spa ::spa_vdevs" \ 83 "$spa ::print spa_t spa_root_vdev | ::vdev" \ 84 "$spa ::print spa_t spa_root_vdev | ::vdev -re" \ 85 "$spa ::print -a spa_t spa_dsl_pool->dp_dirty_datasets | ::walk txg_list" \ 86 "$spa ::print -a spa_t spa_uberblock.ub_rootbp | ::blkptr" \ 87 "$spa ::walk metaslab" \ 88 "$spa ::walk metaslab | ::head -1 | ::metaslab_weight" \ 89 "*metaslab_alloc_trace_cache::walk kmem | ::metaslab_trace" \ 90 "$spa ::walk zio_root | ::zio -c" \ 91 "$spa ::walk zio_root | ::zio -r" \ 92 "$spa ::zfs_blkstats -v" \ 93 "::dbufs" \ 94 "::dbufs -n mos -o mdn -l 0 -b 0" \ 95 "::dbufs | ::dbuf" \ 96 "::dbuf_stats" \ 97 "dbuf_caches::print dbuf_cache_t cache | ::walk multilist" 98# 99# The commands above were supplied by the ZFS development team. The idea is to 100# do as much checking as possible without the need to hardcode addresses. 101# 102 103for cmd in ${cmds[@]}; do 104 log_must eval "mdb -ke \"${cmd}\" >$tmpfile 2>&1" 105 106 # mdb prefixes all errors with "mdb: " so we check the output. 107 log_mustnot grep -q "mdb:" $tmpfile 108done 109 110log_pass "The ZFS mdb dcmds and walkers are working as expected." 111