]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
common/populate: create helpers to handle restoring metadumps
authorDarrick J. Wong <djwong@kernel.org>
Tue, 13 Dec 2022 19:45:15 +0000 (11:45 -0800)
committerZorro Lang <zlang@kernel.org>
Sat, 17 Dec 2022 10:38:09 +0000 (18:38 +0800)
Refactor _scratch_populate_restore_cached so that the actual commands
for restoring metadumps are filesystem-specific helpers.

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/ext4
common/fuzzy
common/populate
common/xfs

index 4a2eaa157fda71a1d9efae52365a9a551bbc82d0..dc2e4e59cc697c7318be9862b3e80566efed6eca 100644 (file)
@@ -125,6 +125,16 @@ _ext4_metadump()
                $DUMP_COMPRESSOR -f "$dumpfile" &>> "$seqres.full"
 }
 
+_ext4_mdrestore()
+{
+       local metadump="$1"
+       local device="$2"
+       shift; shift
+       local options="$@"
+
+       $E2IMAGE_PROG $options -r "${metadump}" "${SCRATCH_DEV}"
+}
+
 # this test requires the ext4 kernel support crc feature on scratch device
 #
 _require_scratch_ext4_crc()
index 2d688fd27bc68af6393bbec006f8b324aa7e9e8e..fad79124e5e9cad08a2648dd271eedba25cf2399 100644 (file)
@@ -159,7 +159,7 @@ __scratch_xfs_fuzz_mdrestore()
        test -e "${POPULATE_METADUMP}" || _fail "Need to set POPULATE_METADUMP"
 
        __scratch_xfs_fuzz_unmount
-       $XFS_MDRESTORE_PROG "${POPULATE_METADUMP}" "${SCRATCH_DEV}"
+       _xfs_mdrestore "${POPULATE_METADUMP}" "${SCRATCH_DEV}"
 }
 
 __fuzz_notify() {
index 8f7f21135668b1fbdbe92c6e47a141b0f4fcc8a2..abfd39d3337102926d8dd7860ab0b48f01269082 100644 (file)
@@ -893,7 +893,7 @@ _scratch_populate_restore_cached() {
 
        case "${FSTYP}" in
        "xfs")
-               $XFS_MDRESTORE_PROG "${metadump}" "${SCRATCH_DEV}"
+               _xfs_mdrestore "${metadump}" "${SCRATCH_DEV}"
                res=$?
                test $res -ne 0 && return $res
 
@@ -908,7 +908,7 @@ _scratch_populate_restore_cached() {
                return $res
                ;;
        "ext2"|"ext3"|"ext4")
-               $E2IMAGE_PROG -r "${metadump}" "${SCRATCH_DEV}"
+               _ext4_mdrestore "${metadump}" "${SCRATCH_DEV}"
                ret=$?
                test $ret -ne 0 && return $ret
 
index 65a5b5b29efe07bed0d5d0079677084141694fbc..938c5826a4295cbd5ff52386a873bd6b3da147b2 100644 (file)
@@ -638,6 +638,15 @@ _xfs_metadump() {
        return $res
 }
 
+_xfs_mdrestore() {
+       local metadump="$1"
+       local device="$2"
+       shift; shift
+       local options="$@"
+
+       $XFS_MDRESTORE_PROG $options "${metadump}" "${device}"
+}
+
 # Snapshot the metadata on the scratch device
 _scratch_xfs_metadump()
 {