From: Darrick J. Wong Date: Tue, 9 Mar 2021 04:39:27 +0000 (-0800) Subject: common: capture qcow2 dumps of corrupt ext* filesystems X-Git-Tag: v2022.05.01~511 X-Git-Url: http://git.apps.os.sepia.ceph.com/?p=xfstests-dev.git;a=commitdiff_plain;h=9fb30a9500c169b0e94353313bff201da2348952 common: capture qcow2 dumps of corrupt ext* filesystems Create a new helper to use e2image to capture a qcow2 image of an ext* filesystem and make _check_generic_filesystem use it to dump corrupt ext images. Refactor the single user of e2image to use the helper. Signed-off-by: Darrick J. Wong --- diff --git a/README b/README index 569b574a..f15363f6 100644 --- a/README +++ b/README @@ -109,7 +109,7 @@ Preparing system for tests: - Set TEST_FS_MODULE_RELOAD=1 to unload the module and reload it between test invocations. This assumes that the name of the module is the same as FSTYP. - - Set DUMP_CORRUPT_FS=1 to record metadata dumps of XFS + - Set DUMP_CORRUPT_FS=1 to record metadata dumps of XFS or ext* filesystems if a filesystem check fails. - Set DUMP_COMPRESSOR to a compression program to compress metadumps of filesystems. This program must accept '-f' and the diff --git a/common/config b/common/config index d4cf8089..a47e462c 100644 --- a/common/config +++ b/common/config @@ -225,6 +225,7 @@ export CC_PROG="$(type -P cc)" export FSVERITY_PROG="$(type -P fsverity)" export OPENSSL_PROG="$(type -P openssl)" export ACCTON_PROG="$(type -P accton)" +export E2IMAGE_PROG="$(type -P e2image)" # use 'udevadm settle' or 'udevsettle' to wait for lv to be settled. # newer systems have udevadm command but older systems like RHEL5 don't. diff --git a/common/populate b/common/populate index b897922c..4135d89d 100644 --- a/common/populate +++ b/common/populate @@ -888,7 +888,7 @@ _scratch_populate_cached() { "ext2"|"ext3"|"ext4") _scratch_ext4_populate $@ _scratch_ext4_populate_check - e2image -Q "${SCRATCH_DEV}" "${POPULATE_METADUMP}" + _ext4_metadump "${SCRATCH_DEV}" "${POPULATE_METADUMP}" compress ;; *) _fail "Don't know how to populate a ${FSTYP} filesystem." diff --git a/common/rc b/common/rc index b0241b0a..6d1757da 100644 --- a/common/rc +++ b/common/rc @@ -584,6 +584,18 @@ _scratch_mkfs_ext4() return $mkfs_status } +_ext4_metadump() +{ + local device="$1" + local dumpfile="$2" + local compressopt="$3" + + test -n "$E2IMAGE_PROG" || _fail "e2image not installed" + $E2IMAGE_PROG -Q "$device" "$dumpfile" + [ "$compressopt" = "compress" ] && [ -n "$DUMP_COMPRESSOR" ] && + $DUMP_COMPRESSOR "$dumpfile" &>> "$seqres.full" +} + _test_mkfs() { case $FSTYP in @@ -2729,6 +2741,15 @@ _check_generic_filesystem() fi rm -f $tmp.fsck + if [ $ok -eq 0 ] && [ -n "$DUMP_CORRUPT_FS" ]; then + case "$FSTYP" in + ext*) + local flatdev="$(basename "$device")" + _ext4_metadump "$seqres.$flatdev.check.qcow2" "$device" compress + ;; + esac + fi + if [ $ok -eq 0 ] then echo "*** mount output ***" >>$seqres.full