From 830b45aa636f1816e161f05177a41c1ec3625665 Mon Sep 17 00:00:00 2001 From: "Darrick J. Wong" Date: Tue, 13 Dec 2022 11:45:20 -0800 Subject: [PATCH] common/xfs: create a helper for restoring metadumps to the scratch devs Refactor the open-coded $XFS_MDRESTORE_PROG calls into a proper _scratch_xfs_mdrestore helper. Signed-off-by: Darrick J. Wong Reviewed-by: Zorro Lang Signed-off-by: Zorro Lang --- common/xfs | 9 +++++++++ tests/xfs/129 | 2 +- tests/xfs/234 | 2 +- tests/xfs/253 | 2 +- tests/xfs/284 | 2 +- tests/xfs/291 | 2 +- tests/xfs/336 | 2 +- tests/xfs/432 | 2 +- tests/xfs/503 | 8 ++++---- 9 files changed, 20 insertions(+), 11 deletions(-) diff --git a/common/xfs b/common/xfs index 938c5826..14be4406 100644 --- a/common/xfs +++ b/common/xfs @@ -660,6 +660,15 @@ _scratch_xfs_metadump() _xfs_metadump "$metadump" "$SCRATCH_DEV" "$logdev" nocompress "$@" } +# Restore snapshotted metadata on the scratch device +_scratch_xfs_mdrestore() +{ + local metadump=$1 + shift + + _xfs_mdrestore "$metadump" "$SCRATCH_DEV" "$@" +} + # run xfs_check and friends on a FS. _check_xfs_filesystem() { diff --git a/tests/xfs/129 b/tests/xfs/129 index 09d40630..6f2ef564 100755 --- a/tests/xfs/129 +++ b/tests/xfs/129 @@ -53,7 +53,7 @@ _scratch_xfs_metadump $metadump_file # Now restore the obfuscated one back and take a look around echo "Restore metadump" -$XFS_MDRESTORE_PROG $metadump_file $TEST_DIR/image +SCRATCH_DEV=$TEST_DIR/image _scratch_xfs_mdrestore $metadump_file SCRATCH_DEV=$TEST_DIR/image _scratch_mount SCRATCH_DEV=$TEST_DIR/image _scratch_unmount diff --git a/tests/xfs/234 b/tests/xfs/234 index cc1ee9a8..57d447c0 100755 --- a/tests/xfs/234 +++ b/tests/xfs/234 @@ -53,7 +53,7 @@ _scratch_xfs_metadump $metadump_file # Now restore the obfuscated one back and take a look around echo "Restore metadump" -$XFS_MDRESTORE_PROG $metadump_file $TEST_DIR/image +SCRATCH_DEV=$TEST_DIR/image _scratch_xfs_mdrestore $metadump_file SCRATCH_DEV=$TEST_DIR/image _scratch_mount SCRATCH_DEV=$TEST_DIR/image _scratch_unmount diff --git a/tests/xfs/253 b/tests/xfs/253 index 1cfc2180..ce902477 100755 --- a/tests/xfs/253 +++ b/tests/xfs/253 @@ -152,7 +152,7 @@ _scratch_unmount _scratch_xfs_metadump $METADUMP_FILE # Now restore the obfuscated one back and take a look around -$XFS_MDRESTORE_PROG "${METADUMP_FILE}" "${SCRATCH_DEV}" +_scratch_xfs_mdrestore "$METADUMP_FILE" _scratch_mount diff --git a/tests/xfs/284 b/tests/xfs/284 index e2bd05d4..58f33003 100755 --- a/tests/xfs/284 +++ b/tests/xfs/284 @@ -49,7 +49,7 @@ _scratch_unmount # xfs_mdrestore should refuse to restore to a mounted device _scratch_xfs_metadump $METADUMP_FILE _scratch_mount -$XFS_MDRESTORE_PROG $METADUMP_FILE $SCRATCH_DEV 2>&1 | filter_mounted +_scratch_xfs_mdrestore $METADUMP_FILE 2>&1 | filter_mounted _scratch_unmount # Test xfs_copy to a mounted device diff --git a/tests/xfs/291 b/tests/xfs/291 index f5fea7f9..600dcb2e 100755 --- a/tests/xfs/291 +++ b/tests/xfs/291 @@ -93,7 +93,7 @@ _scratch_xfs_check >> $seqres.full 2>&1 || _fail "xfs_check failed" # Yes they can! Now... # Can xfs_metadump cope with this monster? _scratch_xfs_metadump $tmp.metadump || _fail "xfs_metadump failed" -$XFS_MDRESTORE_PROG $tmp.metadump $tmp.img || _fail "xfs_mdrestore failed" +SCRATCH_DEV=$tmp.img _scratch_xfs_mdrestore $tmp.metadump || _fail "xfs_mdrestore failed" SCRATCH_DEV=$tmp.img _scratch_xfs_repair -f &>> $seqres.full || \ _fail "xfs_repair of metadump failed" diff --git a/tests/xfs/336 b/tests/xfs/336 index 8d50729e..d7a074d9 100755 --- a/tests/xfs/336 +++ b/tests/xfs/336 @@ -66,7 +66,7 @@ _scratch_xfs_metadump $metadump_file # Now restore the obfuscated one back and take a look around echo "Restore metadump" -$XFS_MDRESTORE_PROG $metadump_file $TEST_DIR/image +SCRATCH_DEV=$TEST_DIR/image _scratch_xfs_mdrestore $metadump_file SCRATCH_DEV=$TEST_DIR/image _scratch_mount SCRATCH_DEV=$TEST_DIR/image _scratch_unmount diff --git a/tests/xfs/432 b/tests/xfs/432 index 676be9bd..66315b03 100755 --- a/tests/xfs/432 +++ b/tests/xfs/432 @@ -87,7 +87,7 @@ test -n "$extlen" || _notrun "could not create dir extent > 1000 blocks" echo "Try to metadump" _scratch_xfs_metadump $metadump_file -w -$XFS_MDRESTORE_PROG $metadump_file $metadump_img +SCRATCH_DEV=$metadump_img _scratch_xfs_mdrestore $metadump_file echo "Check restored metadump image" SCRATCH_DEV=$metadump_img _scratch_xfs_repair -n &>> $seqres.full || \ diff --git a/tests/xfs/503 b/tests/xfs/503 index 18bd8694..c786b04c 100755 --- a/tests/xfs/503 +++ b/tests/xfs/503 @@ -66,25 +66,25 @@ _check_scratch_fs _scratch_unmount echo mdrestore -$XFS_MDRESTORE_PROG $metadump_file $SCRATCH_DEV +_scratch_xfs_mdrestore $metadump_file _scratch_mount _check_scratch_fs _scratch_unmount echo mdrestore a -$XFS_MDRESTORE_PROG $metadump_file_a $SCRATCH_DEV +_scratch_xfs_mdrestore $metadump_file_a _scratch_mount _check_scratch_fs _scratch_unmount echo mdrestore g -$XFS_MDRESTORE_PROG $metadump_file_g $SCRATCH_DEV +_scratch_xfs_mdrestore $metadump_file_g _scratch_mount _check_scratch_fs _scratch_unmount echo mdrestore ag -$XFS_MDRESTORE_PROG $metadump_file_ag $SCRATCH_DEV +_scratch_xfs_mdrestore $metadump_file_ag _scratch_mount _check_scratch_fs _scratch_unmount -- 2.39.5