aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarrick J. Wong <djwong@kernel.org>2024-02-06 18:19:25 -0800
committerZorro Lang <zlang@kernel.org>2024-02-09 13:27:17 +0800
commite595ffddd23eed59e823b1bc42c0016b401090ad (patch)
tree9089409789dd454b01dceff7b9bf3fa0e639146d
parentb809844c72b97b2ac0a01ffb7b7f114bf6364028 (diff)
downloadxfstests-dev-e595ffddd23eed59e823b1bc42c0016b401090ad.tar.gz
common/xfs: only pass -l in _xfs_mdrestore for v2 metadumps
fstests has a weird history with external log devices -- prior to the introduction of metadump v2, a dump/restore cycle would leave an external log unaltered, and most tests worked just fine. Were those tests ignorant? Or did they pass intentionally? Either way, we don't want to pass -l to xfs_mdrestore just because we have an external log, because that switch is new and causes regressions when testing with xfsprogs from before 6.5. Signed-off-by: "Darrick J. Wong" <djwong@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Zorro Lang <zlang@kernel.org>
-rw-r--r--common/xfs27
1 files changed, 25 insertions, 2 deletions
diff --git a/common/xfs b/common/xfs
index 6a48960a7f..65b509691b 100644
--- a/common/xfs
+++ b/common/xfs
@@ -689,12 +689,25 @@ _xfs_metadump() {
return $res
}
+# What is the version of this metadump file?
+_xfs_metadumpfile_version() {
+ local file="$1"
+ local magic
+
+ magic="$($XFS_IO_PROG -c 'pread -q -v 0 4' "$file")"
+ case "$magic" in
+ "00000000: 58 4d 44 32 XMD2") echo 2;;
+ "00000000: 58 46 53 4d XFSM") echo 1;;
+ esac
+}
+
_xfs_mdrestore() {
local metadump="$1"
local device="$2"
local logdev="$3"
shift; shift; shift
local options="$@"
+ local dumpfile_ver
# If we're configured for compressed dumps and there isn't already an
# uncompressed dump, see if we can use DUMP_COMPRESSOR to decompress
@@ -705,8 +718,18 @@ _xfs_mdrestore() {
done
fi
test -r "$metadump" || return 1
-
- if [ "$logdev" != "none" ]; then
+ dumpfile_ver="$(_xfs_metadumpfile_version "$metadump")"
+
+ if [ "$logdev" != "none" ] && [[ $dumpfile_ver > 1 ]]; then
+ # metadump and mdrestore began capturing and restoring the
+ # contents of external log devices with the addition of the
+ # metadump v2 format. Hence it only makes sense to specify -l
+ # here if the dump file itself is in v2 format.
+ #
+ # With a v1 metadump, the log device is not changed by the dump
+ # and restore process. Historically, fstests either didn't
+ # notice or _notrun themselves when external logs were in use.
+ # Don't break that for people testing with xfsprogs < 6.5.
options="$options -l $logdev"
fi