From 5011eb3e04e89d71b7ce2623d2aaff342339b79e Mon Sep 17 00:00:00 2001 From: Chandan Babu R Date: Thu, 11 Jan 2024 17:28:27 +0530 Subject: [PATCH] _scratch_xfs_mdrestore: Pass scratch log device when applicable Metadump v2 supports dumping contents of an external log device. This commit modifies _scratch_xfs_mdrestore() and _xfs_mdrestore() to be able to restore metadump files which contain data from external log devices. The callers of _scratch_xfs_mdrestore() must set the value of $SCRATCH_LOGDEV only when all of the following conditions are met: 1. Metadump is in v2 format. 2. Metadump has contents dumped from an external log device. Reviewed-by: "Darrick J. Wong" Signed-off-by: Chandan Babu R Signed-off-by: Zorro Lang --- common/xfs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/common/xfs b/common/xfs index 49c5df15..11cfd795 100644 --- a/common/xfs +++ b/common/xfs @@ -692,7 +692,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 @@ -705,6 +706,10 @@ _xfs_mdrestore() { fi test -r "$metadump" || return 1 + if [ "$logdev" != "none" ]; then + options="$options -l $logdev" + fi + $XFS_MDRESTORE_PROG $options "${metadump}" "${device}" } @@ -732,8 +737,18 @@ _scratch_xfs_mdrestore() { local metadump=$1 shift + local logdev=none + local options="$@" + + # $SCRATCH_LOGDEV should have a non-zero length value only when all of + # the following conditions are met. + # 1. Metadump is in v2 format. + # 2. Metadump has contents dumped from an external log device. + if [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ]; then + logdev=$SCRATCH_LOGDEV + fi - _xfs_mdrestore "$metadump" "$SCRATCH_DEV" "$@" + _xfs_mdrestore "$metadump" "$SCRATCH_DEV" "$logdev" "$@" } # Do not use xfs_repair (offline fsck) to rebuild the filesystem -- 2.39.5