From: Darrick J. Wong <djwong@xxxxxxxxxx> Refactor the open-coded $XFS_MDRESTORE_PROG calls into a proper _scratch_xfs_mdrestore helper. Signed-off-by: Darrick J. Wong <djwong@xxxxxxxxxx> --- 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 27d6ac84e3..216dab3bcd 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 09d40630d0..6f2ef5640d 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 cc1ee9a8ca..57d447c056 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 1cfc218088..ce90247777 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 e2bd05d4c7..58f330035e 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 f5fea7f9a5..600dcb2eba 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 ee8ec649cb..5bcac976e4 100755 --- a/tests/xfs/336 +++ b/tests/xfs/336 @@ -65,7 +65,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 676be9bd8a..66315b0398 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 18bd8694c8..c786b04ccd 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