@@ -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
@@ -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.
@@ -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."
@@ -585,6 +585,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
@@ -2730,6 +2742,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