diff options
author | Paul Zuchowski <[email protected]> | 2020-01-16 12:22:49 -0500 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2020-01-16 09:22:49 -0800 |
commit | f12e42cccf31d6077f585a562d7e7ed3483291b1 (patch) | |
tree | ecee7b446e02d14363f1df499d133651f1b50dbf /tests | |
parent | 1b64627e7335e9f38d66424cdd242b3d0889b060 (diff) |
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 <pool>[/objset ID] object' to
determine the names of the objset and object which have the error.
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Ryan Moeller <[email protected]>
Signed-off-by: Paul Zuchowski <[email protected]>
Closes #9733
Diffstat (limited to 'tests')
-rw-r--r-- | tests/runfiles/common.run | 3 | ||||
-rw-r--r-- | tests/zfs-tests/tests/functional/cli_root/zdb/Makefile.am | 3 | ||||
-rwxr-xr-x | tests/zfs-tests/tests/functional/cli_root/zdb/zdb_objset_id.ksh | 96 |
3 files changed, 100 insertions, 2 deletions
diff --git a/tests/runfiles/common.run b/tests/runfiles/common.run index 50330884d..4342662e7 100644 --- a/tests/runfiles/common.run +++ b/tests/runfiles/common.run @@ -100,7 +100,8 @@ tags = ['functional', 'clean_mirror'] [tests/functional/cli_root/zdb] tests = ['zdb_001_neg', 'zdb_002_pos', 'zdb_003_pos', 'zdb_004_pos', - 'zdb_005_pos', 'zdb_006_pos', 'zdb_checksum', 'zdb_decompress'] + 'zdb_005_pos', 'zdb_006_pos', 'zdb_checksum', 'zdb_decompress', + 'zdb_objset_id'] pre = post = tags = ['functional', 'cli_root', 'zdb'] 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/<objset id> 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<ID> +# (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 <pool>/<objset ID> 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 <pool>/<objset ID> generates the correct names." |