mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 18:40:43 +03:00
Refactor zhack label repair and fix -c regression on nonzero TXG
This commit fixes a likely regression introduced by 64db435 where the checksum repair functionality (`-c` or default behavior) will perform checks and access data associated with the newer undetach (`-u`) functionality, resulting in a failure when an uberblock's TXG is not 0 as required by `-u` but not `-c` Additionally, code is refactored for better separation of tasks. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: buzzingwires <buzzingwires@outlook.com> Closes #17732
This commit is contained in:
committed by
Brian Behlendorf
parent
e3eb3ca3dc
commit
5f7253ca11
@@ -33,13 +33,16 @@
|
||||
# Test one:
|
||||
#
|
||||
# 1. Create pool on a loopback device with some test data
|
||||
# 2. Export the pool.
|
||||
# 3. Corrupt all label checksums in the pool
|
||||
# 4. Check that pool cannot be imported
|
||||
# 5. Verify that it cannot be imported after using zhack label repair -u
|
||||
# 2. Checksum repair should work with a valid TXG. Repeatedly write and
|
||||
# sync the pool so there are enough transactions for every uberblock
|
||||
# to have a TXG
|
||||
# 3. Export the pool.
|
||||
# 4. Corrupt all label checksums in the pool
|
||||
# 5. Check that pool cannot be imported
|
||||
# 6. Verify that it cannot be imported after using zhack label repair -u
|
||||
# to ensure that the -u option will quit on corrupted checksums.
|
||||
# 6. Use zhack label repair -c on device
|
||||
# 7. Check that pool can be imported and that data is intact
|
||||
# 7. Use zhack label repair -c on device
|
||||
# 8. Check that pool can be imported and that data is intact
|
||||
#
|
||||
# Test two:
|
||||
#
|
||||
@@ -170,6 +173,17 @@ function setup_dataset
|
||||
check_dataset true
|
||||
}
|
||||
|
||||
function force_transactions
|
||||
{
|
||||
L_TIMES="$1"
|
||||
for ((i=0; i < L_TIMES; i++))
|
||||
do
|
||||
touch "$TESTDIR"/"test" || return $?
|
||||
zpool sync -f "$TESTPOOL" || return $?
|
||||
done
|
||||
return 0
|
||||
}
|
||||
|
||||
function get_practical_size
|
||||
{
|
||||
L_SIZE="$1"
|
||||
@@ -257,6 +271,9 @@ function run_test_one
|
||||
|
||||
setup_dataset
|
||||
|
||||
# Force 256 extra transactions to ensure all uberblocks are assigned a TXG
|
||||
log_must force_transactions 256
|
||||
|
||||
log_must zpool export "$TESTPOOL"
|
||||
|
||||
corrupt_labels "$L_SIZE" "$VIRTUAL_DISK"
|
||||
|
||||
@@ -18,13 +18,16 @@
|
||||
# Strategy:
|
||||
#
|
||||
# 1. Create pool on a loopback device with some test data
|
||||
# 2. Export the pool.
|
||||
# 3. Corrupt all label checksums in the pool
|
||||
# 4. Check that pool cannot be imported
|
||||
# 5. Verify that it cannot be imported after using zhack label repair -u
|
||||
# 2. Checksum repair should work with a valid TXG. Repeatedly write and
|
||||
# sync the pool so there are enough transactions for every uberblock
|
||||
# to have a TXG
|
||||
# 3. Export the pool.
|
||||
# 4. Corrupt all label checksums in the pool
|
||||
# 5. Check that pool cannot be imported
|
||||
# 6. Verify that it cannot be imported after using zhack label repair -u
|
||||
# to ensure that the -u option will quit on corrupted checksums.
|
||||
# 6. Use zhack label repair -c on device
|
||||
# 7. Check that pool can be imported and that data is intact
|
||||
# 7. Use zhack label repair -c on device
|
||||
# 8. Check that pool can be imported and that data is intact
|
||||
|
||||
. "$STF_SUITE"/tests/functional/cli_root/zhack/library.kshlib
|
||||
|
||||
|
||||
Reference in New Issue
Block a user