diff options
author | Paul Zuchowski <[email protected]> | 2022-08-03 17:12:23 +0000 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2022-08-08 16:56:38 -0700 |
commit | fcbddc7f7ca7210f5b68580ca20d7c604dd390b3 (patch) | |
tree | 4038ddaeec4a66b66d87e4aa368ed13df75f88d7 /tests | |
parent | b06aff105cd7adb687f1b0ce269f9d661cc3e774 (diff) |
Fix problem with zdb -d
zdb -d <pool>/<objset ID> does not work when
other command line arguments are included i.e.
zdb -U <cachefile> -d <pool>/<objset ID>
This change fixes the command line parsing
to handle this situation. Also fix issue
where zdb -r <dataset> <file> does not handle
the root <dataset> of the pool. Introduce -N
option to force <objset ID> to be interpreted
as a numeric objsetID.
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Rich Ercolani <[email protected]>
Reviewed-by: Tony Nguyen <[email protected]>
Signed-off-by: Paul Zuchowski <[email protected]>
Closes #12845
Closes #12944
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/zfs-tests/tests/functional/cli_root/zdb/zdb_args_neg.ksh | 2 | ||||
-rwxr-xr-x | tests/zfs-tests/tests/functional/cli_root/zdb/zdb_objset_id.ksh | 42 |
2 files changed, 40 insertions, 4 deletions
diff --git a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_args_neg.ksh b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_args_neg.ksh index ae948bb9b..cb88def7c 100755 --- a/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_args_neg.ksh +++ b/tests/zfs-tests/tests/functional/cli_root/zdb/zdb_args_neg.ksh @@ -58,7 +58,7 @@ set -A args "create" "add" "destroy" "import fakepool" \ "setvprop" "blah blah" "-%" "--?" "-*" "-=" \ "-a" "-f" "-g" "-j" "-n" "-o" "-p" "-p /tmp" \ "-t" "-w" "-z" "-E" "-H" "-I" "-J" "-K" \ - "-N" "-Q" "-R" "-T" "-W" + "-Q" "-R" "-T" "-W" log_assert "Execute zdb using invalid parameters." 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 index d23cc43c9..ce0732a6f 100755 --- 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 @@ -30,10 +30,16 @@ # 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> +# 9. Repeat with zdb -NNNNNN pool/objsetID objectID +# 10. 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 +# 11. Run zdb -dddddd pool/objsetID (hex) +# 12. Match name from zdb against proc entry +# 13. Create dataset with hex numeric name +# 14. Create dataset with decimal numeric name +# 15. zdb -d for numeric datasets succeeds +# 16. zdb -N for numeric datasets fails +# 17. zdb -dN for numeric datasets fails # function cleanup @@ -78,6 +84,17 @@ do (( $? != 0 )) && log_fail \ "zdb -dddddd $TESTPOOL/$id $obj failed $reason" obj=$(printf "0x%X" $obj) + + log_note "zdb -NNNNNN $TESTPOOL/$id $obj" + output=$(zdb -NNNNNN $TESTPOOL/$id $obj) + reason="($TESTPOOL/$TESTFS not in zdb output)" + echo $output |grep "$TESTPOOL/$TESTFS" > /dev/null + (( $? != 0 )) && log_fail \ + "zdb -NNNNNN $TESTPOOL/$id $obj failed $reason" + reason="(file1 not in zdb output)" + echo $output |grep "file1" > /dev/null + (( $? != 0 )) && log_fail \ + "zdb -NNNNNN $TESTPOOL/$id $obj failed $reason" done if is_linux; then @@ -94,4 +111,23 @@ if is_linux; then "zdb -dddddd $TESTPOOL/$objset_hex failed $reason" fi +log_must zfs create $TESTPOOL/0x400 +log_must zfs create $TESTPOOL/100 +output=$(zdb -d $TESTPOOL/0x400) +reason="($TESTPOOL/0x400 not in zdb output)" +echo $output |grep "$TESTPOOL/0x400" > /dev/null +(( $? != 0 )) && log_fail \ + "zdb -d $TESTPOOL/0x400 failed $reason" +output=$(zdb -d $TESTPOOL/100) +reason="($TESTPOOL/100 not in zdb output)" +echo $output |grep "$TESTPOOL/100" > /dev/null +(( $? != 0 )) && log_fail \ + "zdb -d $TESTPOOL/100 failed $reason" + +# force numeric interpretation, should fail +log_mustnot zdb -N $TESTPOOL/0x400 +log_mustnot zdb -N $TESTPOOL/100 +log_mustnot zdb -Nd $TESTPOOL/0x400 +log_mustnot zdb -Nd $TESTPOOL/100 + log_pass "zdb -d <pool>/<objset ID> generates the correct names." |