From f12e42cccf31d6077f585a562d7e7ed3483291b1 Mon Sep 17 00:00:00 2001 From: Paul Zuchowski <31706010+PaulZ-98@users.noreply.github.com> Date: Thu, 16 Jan 2020 12:22:49 -0500 Subject: zdb -d should accept the numeric objset id As an alternative to the dataset name, zdb now allows the decimal or hexadecimal objset ID to be specified. When permanent errors are reported as 2 hexadecimal numbers (objset ID : object ID) in zpool status; you can now use 'zdb [/objset ID] object' to determine the names of the objset and object which have the error. Reviewed-by: Brian Behlendorf Reviewed-by: Ryan Moeller Signed-off-by: Paul Zuchowski Closes #9733 --- .../tests/functional/cli_root/zdb/Makefile.am | 3 +- .../functional/cli_root/zdb/zdb_objset_id.ksh | 96 ++++++++++++++++++++++ 2 files changed, 98 insertions(+), 1 deletion(-) create mode 100755 tests/zfs-tests/tests/functional/cli_root/zdb/zdb_objset_id.ksh (limited to 'tests/zfs-tests') diff --git a/tests/zfs-tests/tests/functional/cli_root/zdb/Makefile.am b/tests/zfs-tests/tests/functional/cli_root/zdb/Makefile.am index 9f143078f..edbebb020 100644 --- a/tests/zfs-tests/tests/functional/cli_root/zdb/Makefile.am +++ b/tests/zfs-tests/tests/functional/cli_root/zdb/Makefile.am @@ -7,4 +7,5 @@ dist_pkgdata_SCRIPTS = \ zdb_005_pos.ksh \ zdb_006_pos.ksh \ zdb_checksum.ksh \ - zdb_decompress.ksh + zdb_decompress.ksh \ + zdb_objset_id.ksh diff --git a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_objset_id.ksh b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_objset_id.ksh new file mode 100755 index 000000000..f0c1076c9 --- /dev/null +++ b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_objset_id.ksh @@ -0,0 +1,96 @@ +#!/bin/ksh + +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright (c) 2020 by Datto, Inc. All rights reserved. +# + +. $STF_SUITE/include/libtest.shlib + +# +# Description: +# zdb -d pool/ will display the dataset +# +# Strategy: +# 1. Create a pool +# 2. Write some data to a file +# 3. Get the inode number (object number) of the file +# 4. Run zdb -d to get the objset ID of the dataset +# 5. Run zdb -dddddd pool/objsetID objectID (decimal) +# 6. Confirm names +# 7. Run zdb -dddddd pool/objsetID objectID (hex) +# 8. Confirm names +# 9. Obtain objsetID from /proc/spl/kstat/zfs/testpool/obset-0x +# (linux only) +# 10. Run zdb -dddddd pool/objsetID (hex) +# 11. Match name from zdb against proc entry +# + +function cleanup +{ + datasetexists $TESTPOOL && destroy_pool $TESTPOOL +} + +log_assert "Verify zdb -d / generates the correct names." +log_onexit cleanup +init_data=$TESTDIR/file1 +write_count=8 +blksize=131072 +verify_runnable "global" +verify_disk_count "$DISKS" 2 + +default_mirror_setup_noexit $DISKS +file_write -o create -w -f $init_data -b $blksize -c $write_count + +# get object number of file +listing=$(ls -i $init_data) +set -A array $listing +obj=${array[0]} +log_note "file $init_data has object number $obj" + +output=$(zdb -d $TESTPOOL/$TESTFS) +objset_id=$(echo $output | awk '{split($0,array,",")} END{print array[2]}' | + awk '{split($0,array," ")} END{print array[2]}') +objset_hex=$(printf "0x%X" $objset_id) +log_note "objset $TESTPOOL/$TESTFS has objset ID $objset_id ($objset_hex)" + +for id in "$objset_id" "$objset_hex" +do + log_note "zdb -dddddd $TESTPOOL/$id $obj" + output=$(zdb -dddddd $TESTPOOL/$id $obj) + reason="($TESTPOOL/$TESTFS not in zdb output)" + echo $output |grep "$TESTPOOL/$TESTFS" > /dev/null + (( $? != 0 )) && log_fail \ + "zdb -dddddd $TESTPOOL/$id $obj failed $reason" + reason="(file1 not in zdb output)" + echo $output |grep "file1" > /dev/null + (( $? != 0 )) && log_fail \ + "zdb -dddddd $TESTPOOL/$id $obj failed $reason" + obj=$(printf "0x%X" $obj) +done + +if is_linux; then + output=$(ls -1 /proc/spl/kstat/zfs/$TESTPOOL |grep objset- |tail -1) + objset_hex=${output#*-} + name_from_proc=$(cat /proc/spl/kstat/zfs/$TESTPOOL/$output | + grep dataset_name | awk '{split($0,array," ")} END{print array[3]}') + log_note "checking zdb output for $name_from_proc" + reason="(name $name_from_proc from proc not in zdb output)" + log_note "zdb -dddddd $TESTPOOL/$objset_hex" + output=$(zdb -dddddd $TESTPOOL/$objset_hex) + echo $output |grep "$name_from_proc" > /dev/null + (( $? != 0 )) && log_fail \ + "zdb -dddddd $TESTPOOL/$objset_hex failed $reason" +fi + +log_pass "zdb -d / generates the correct names." -- cgit v1.2.3