From: Darrick J. Wong Date: Tue, 13 Dec 2022 19:45:15 +0000 (-0800) Subject: common/populate: create helpers to handle restoring metadumps X-Git-Tag: v2022.12.18~3 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=538abf799424a769f2f546790b12508932838586;p=xfstests-dev.git common/populate: create helpers to handle restoring metadumps Refactor _scratch_populate_restore_cached so that the actual commands for restoring metadumps are filesystem-specific helpers. Signed-off-by: Darrick J. Wong Reviewed-by: Zorro Lang Signed-off-by: Zorro Lang --- diff --git a/common/ext4 b/common/ext4 index 4a2eaa15..dc2e4e59 100644 --- a/common/ext4 +++ b/common/ext4 @@ -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() diff --git a/common/fuzzy b/common/fuzzy index 2d688fd2..fad79124 100644 --- a/common/fuzzy +++ b/common/fuzzy @@ -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() { diff --git a/common/populate b/common/populate index 8f7f2113..abfd39d3 100644 --- a/common/populate +++ b/common/populate @@ -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 diff --git a/common/xfs b/common/xfs index 65a5b5b2..938c5826 100644 --- a/common/xfs +++ b/common/xfs @@ -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() {