]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
common/xfs: create a helper for restoring metadumps to the scratch devs
authorDarrick J. Wong <djwong@kernel.org>
Tue, 13 Dec 2022 19:45:20 +0000 (11:45 -0800)
committerZorro Lang <zlang@kernel.org>
Sat, 17 Dec 2022 10:38:19 +0000 (18:38 +0800)
Refactor the open-coded $XFS_MDRESTORE_PROG calls into a proper
_scratch_xfs_mdrestore helper.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
common/xfs
tests/xfs/129
tests/xfs/234
tests/xfs/253
tests/xfs/284
tests/xfs/291
tests/xfs/336
tests/xfs/432
tests/xfs/503

index 938c5826a4295cbd5ff52386a873bd6b3da147b2..14be44068b888b67643ddfa0c1f7527a7aa68037 100644 (file)
@@ -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()
 {
index 09d40630d0a5c00ae5cc3258d600dc0f52e0a110..6f2ef5640d8fc677d7f78e5fd05920964facf2b2 100755 (executable)
@@ -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
 
index cc1ee9a8caf24593d51da7ee9f78ddaf372f284a..57d447c056ffd2207476e26a68ccd5bdebc19c94 100755 (executable)
@@ -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
 
index 1cfc218088a1e1ac4298b4215f810ff9e20b69f4..ce90247777cb2bca6f1277dc43b204436d9c2d81 100755 (executable)
@@ -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
 
index e2bd05d4c7f7dd95fa18766847f4466ffaac2f79..58f330035e0a79c57226e42e59dfa820ce7051e0 100755 (executable)
@@ -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
index f5fea7f9a5c1335a6a227f05576a458fd66974fc..600dcb2eba8d9f70491f77da30be4c16596ff860 100755 (executable)
@@ -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"
 
index 8d50729e4ffcbcffa3ff4b889b0af89574b49e62..d7a074d971d1c748104aa08d062930d34c112811 100755 (executable)
@@ -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
 
index 676be9bd8a009c111a610fac8b2e137a086f3116..66315b03987287ff458066c4aad6f65cd41dae55 100755 (executable)
@@ -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 || \
index 18bd8694c862004c1da208f526fa7f5d911aa091..c786b04ccd1740bf4de951313a4018e85d0e9f2b 100755 (executable)
@@ -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