@@ -304,7 +304,12 @@ __scratch_xfs_fuzz_unmount()
__scratch_xfs_fuzz_mdrestore()
{
__scratch_xfs_fuzz_unmount
- _xfs_mdrestore "${POPULATE_METADUMP}" "${SCRATCH_DEV}" || \
+
+ local logdev=none
+ [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
+ logdev=$SCRATCH_LOGDEV
+
+ _xfs_mdrestore "${POPULATE_METADUMP}" "${SCRATCH_DEV}" "${logdev}" || \
_fail "${POPULATE_METADUMP}: Could not find metadump to restore?"
}
@@ -1011,21 +1011,14 @@ _scratch_populate_cache_tag() {
_scratch_populate_restore_cached() {
local metadump="$1"
+ local logdev=none
+ [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
+ logdev=$SCRATCH_LOGDEV
+
case "${FSTYP}" in
"xfs")
- _xfs_mdrestore "${metadump}" "${SCRATCH_DEV}"
- res=$?
- test $res -ne 0 && return $res
-
- # Cached images should have been unmounted cleanly, so if
- # there's an external log we need to wipe it and run repair to
- # format it to match this filesystem.
- if [ -n "${SCRATCH_LOGDEV}" ]; then
- $WIPEFS_PROG -a "${SCRATCH_LOGDEV}"
- _scratch_xfs_repair
- res=$?
- fi
- return $res
+ _xfs_mdrestore "${metadump}" "${SCRATCH_DEV}" "${logdev}"
+ return $?
;;
"ext2"|"ext3"|"ext4")
_ext4_mdrestore "${metadump}" "${SCRATCH_DEV}"
@@ -683,7 +683,8 @@ _xfs_metadump() {
_xfs_mdrestore() {
local metadump="$1"
local device="$2"
- shift; shift
+ local logdev="$3"
+ shift; shift; shift
local options="$@"
# If we're configured for compressed dumps and there isn't already an
@@ -697,6 +698,18 @@ _xfs_mdrestore() {
test -r "$metadump" || return 1
$XFS_MDRESTORE_PROG $options "${metadump}" "${device}"
+ res=$?
+ test $res -ne 0 && return $res
+
+ # mdrestore does not know how to restore an external log. If there is
+ # one, we need to erase the log header and run xfs_repair to format a
+ # new log header onto the log device.
+ if [ "$logdev" != "none" ]; then
+ $XFS_IO_PROG -d -c 'pwrite -S 0 -q 0 1m' "$logdev"
+ _scratch_xfs_repair >> $seqres.full 2>&1
+ res=$?
+ fi
+ return $res
}
# Snapshot the metadata on the scratch device
@@ -718,7 +731,11 @@ _scratch_xfs_mdrestore()
local metadump=$1
shift
- _xfs_mdrestore "$metadump" "$SCRATCH_DEV" "$@"
+ local logdev=none
+ [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \
+ logdev=$SCRATCH_LOGDEV
+
+ _xfs_mdrestore "$metadump" "$SCRATCH_DEV" "$logdev" "$@"
}
# Do not use xfs_repair (offline fsck) to rebuild the filesystem