From patchwork Fri Dec 30 22:20:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13085841 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10360C4167B for ; Sat, 31 Dec 2022 03:08:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236313AbiLaDIs (ORCPT ); Fri, 30 Dec 2022 22:08:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236321AbiLaDIq (ORCPT ); Fri, 30 Dec 2022 22:08:46 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5DDD12A9C; Fri, 30 Dec 2022 19:08:42 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 4C0DF61D43; Sat, 31 Dec 2022 03:08:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A6807C433EF; Sat, 31 Dec 2022 03:08:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1672456121; bh=ZNjCnCZ07gW3ub0N+12jMOAoaMlKgghqJ3lcLjm0/q4=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=G7h3lexHr+I2YhnKCiE375+N+Nf7Zw3Anix7bW44TjSI+oNjgKcY0Scle15oRHdan 3Z4N1+k1qmBTsIqjnacrW0Zn5bdPXDnz4vyOwvSUZcV5J/uORB76yTkqU3MUz8HLW4 JFcbdTKltvh2VjzogeTQ9e6cLkiiWLkzB52Hjy6ypVbuBSszDscelYzyUfjjuk89hz xjy6B5xOiEbqZSDET92l733SdF4ThoHaKIOSZ/4aTd84ZgMLGFouVuoy1IlpSYGdh1 9kUVLRU1kC4fclpMXQUljbF/ViUM+8QgwkeIo/PeKF62wEWPSM3oWZlY2bdkdLOnQ+ V6ayeOVRzqtmQ== Subject: [PATCH 1/4] common/populate: refactor caching of metadumps to a helper From: "Darrick J. Wong" To: zlang@redhat.com, djwong@kernel.org Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org, guan@eryu.me Date: Fri, 30 Dec 2022 14:20:36 -0800 Message-ID: <167243883626.738384.359731015865489369.stgit@magnolia> In-Reply-To: <167243883613.738384.6883268151338937809.stgit@magnolia> References: <167243883613.738384.6883268151338937809.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong Hoist out of _scratch_populate_cached all the code that we use to save a metadump of the populated filesystem. We're going to make this more involved for XFS in the next few patches so that we can take advantage of the new support for external devices in metadump/mdrestore. Signed-off-by: Darrick J. Wong --- common/populate | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/common/populate b/common/populate index 29ea637ecb..8db7acefb6 100644 --- a/common/populate +++ b/common/populate @@ -938,6 +938,31 @@ _scratch_populate_restore_cached() { return 1 } +# Take a metadump of the scratch filesystem and cache it for later. +_scratch_populate_save_metadump() +{ + local metadump_file="$1" + + case "${FSTYP}" in + "xfs") + local logdev=none + [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \ + logdev=$SCRATCH_LOGDEV + + _xfs_metadump "$metadump_file" "$SCRATCH_DEV" "$logdev" \ + compress + res=$? + ;; + "ext2"|"ext3"|"ext4") + _ext4_metadump "${SCRATCH_DEV}" "${metadump_file}" compress + res=$? + ;; + *) + _fail "Don't know how to save a ${FSTYP} filesystem." + esac + return $res +} + # Populate a scratch FS from scratch or from a cached image. _scratch_populate_cached() { local meta_descr="$(_scratch_populate_cache_tag "$@")" @@ -961,26 +986,20 @@ _scratch_populate_cached() { # Oh well, just create one from scratch _scratch_mkfs - echo "${meta_descr}" > "${populate_metadump_descr}" case "${FSTYP}" in "xfs") _scratch_xfs_populate $@ _scratch_xfs_populate_check - - local logdev=none - [ "$USE_EXTERNAL" = yes -a ! -z "$SCRATCH_LOGDEV" ] && \ - logdev=$SCRATCH_LOGDEV - - _xfs_metadump "$POPULATE_METADUMP" "$SCRATCH_DEV" "$logdev" \ - compress ;; "ext2"|"ext3"|"ext4") _scratch_ext4_populate $@ _scratch_ext4_populate_check - _ext4_metadump "${SCRATCH_DEV}" "${POPULATE_METADUMP}" compress ;; *) _fail "Don't know how to populate a ${FSTYP} filesystem." ;; esac + + _scratch_populate_save_metadump "${POPULATE_METADUMP}" && \ + echo "${meta_descr}" > "${populate_metadump_descr}" } From patchwork Fri Dec 30 22:20:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13085842 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 48C10C3DA7C for ; Sat, 31 Dec 2022 03:09:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236321AbiLaDJB (ORCPT ); Fri, 30 Dec 2022 22:09:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236316AbiLaDJA (ORCPT ); Fri, 30 Dec 2022 22:09:00 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C24C010540; Fri, 30 Dec 2022 19:08:59 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 75E33B81E69; Sat, 31 Dec 2022 03:08:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 317DAC433D2; Sat, 31 Dec 2022 03:08:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1672456137; bh=Fap7+eQntY4azp33+7EmMEt/z/LH/Y9zKHAx3JZPLl0=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=hZddP1VRGYfNZhvtvt9CKvOp11K6ClizRoHJQPAianxHSe8hll4UcRl+P7mJEezjE 9XVZhe7YFIBEfUf+uGwA25FHTGVMsFnr3D3S3s/e2wQr8qw/UxkEsn1kUddKdcIl1r BMSs1g4I0lFamq6fGOtnQ1mVS545KiI0vowaLx5V9L9go04igNEgQitssFyoBfW5bp vFPd+mHlVXi4PY65Sq+PCqb+8ekZepcJn8zwD6ZbwZxiFQY+qa95yw50z+3+8wgt79 fr9wdDMXh9B3FrsxojHPm0f2Q5EczNYtW07VSEFqSKWlmxEqGjkzwPLP8Hr+QlTkPh URhseMgII46TQ== Subject: [PATCH 2/4] common/xfs: wipe external logs during mdrestore operations From: "Darrick J. Wong" To: zlang@redhat.com, djwong@kernel.org Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org, guan@eryu.me Date: Fri, 30 Dec 2022 14:20:36 -0800 Message-ID: <167243883638.738384.14861856901709322328.stgit@magnolia> In-Reply-To: <167243883613.738384.6883268151338937809.stgit@magnolia> References: <167243883613.738384.6883268151338937809.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong The XFS metadump file format doesn't support the capture of external log devices, which means that mdrestore ought to wipe the external log and run xfs_repair to rewrite the log device as needed to get the restored filesystem to work again. The common/populate code could already do this, so push it to the common xfs helper. While we're at it, fix the uncareful usage of SCRATCH_LOGDEV in the populate code. Signed-off-by: Darrick J. Wong --- common/fuzzy | 7 ++++++- common/populate | 19 ++++++------------- common/xfs | 21 +++++++++++++++++++-- 3 files changed, 31 insertions(+), 16 deletions(-) diff --git a/common/fuzzy b/common/fuzzy index ef54f2fe2c..7034ff8c42 100644 --- a/common/fuzzy +++ b/common/fuzzy @@ -297,7 +297,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?" } diff --git a/common/populate b/common/populate index 8db7acefb6..08c4bdc151 100644 --- a/common/populate +++ b/common/populate @@ -902,21 +902,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}" diff --git a/common/xfs b/common/xfs index 77af8a6d60..29130fabbc 100644 --- a/common/xfs +++ b/common/xfs @@ -682,7 +682,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 @@ -696,6 +697,18 @@ _xfs_mdrestore() { test -r "$metadump" || return 1 $XFS_MDRESTORE_PROG $options "${metadump}" "${device}" + 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 [ "${logdev}" != "none" ]; then + $WIPEFS_PROG -a "${logdev}" + _scratch_xfs_repair + res=$? + fi + return $res } # Snapshot the metadata on the scratch device @@ -717,7 +730,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" "$@" } # run xfs_check and friends on a FS. From patchwork Fri Dec 30 22:20:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13085843 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2668AC3DA7C for ; Sat, 31 Dec 2022 03:09:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236323AbiLaDJP (ORCPT ); Fri, 30 Dec 2022 22:09:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236316AbiLaDJO (ORCPT ); Fri, 30 Dec 2022 22:09:14 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2AF61054D; Fri, 30 Dec 2022 19:09:13 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6089F61D39; Sat, 31 Dec 2022 03:09:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B975EC433EF; Sat, 31 Dec 2022 03:09:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1672456152; bh=K5+CfoR/yWPJrjuFDFxGWGskGStK+cRvXlhc1OYHuPU=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=K0+6ZrSZa0VtdogAojvGUkvSc/WGsmkeBMPg44kti192PGEnbFkmJ4JP1/OL4VWTY U0LRqYPteIfRh+ss+UjbiK66LbvXMT7T7rnfIRQisMZqtf9gXxhtxr3AdvdubAKJH+ N4qoTNXtWyo/WuxjTnE6SXCyeSWv1+5O04aJ/Fryk2YMf1rmo5ywkKU4XJcrkMVr5Q M9ePkSh2s9DUPQrandnvq8xphNDoKgasMBi2WReCqfzV5siQBSVDlZgkPiKobTV6cb mkke5CBGJp7uoO04SklCVqMzdKmSn6XNJsYsJ5v8yDFrDY5BpyGdHjfTB2B4rMmAiG 2BKpClTHyx9+w== Subject: [PATCH 3/4] common/ext4: reformat external logs during mdrestore operations From: "Darrick J. Wong" To: zlang@redhat.com, djwong@kernel.org Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org, guan@eryu.me Date: Fri, 30 Dec 2022 14:20:36 -0800 Message-ID: <167243883649.738384.9931798542555490230.stgit@magnolia> In-Reply-To: <167243883613.738384.6883268151338937809.stgit@magnolia> References: <167243883613.738384.6883268151338937809.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong The e2image file format doesn't support the capture of external log devices, which means that mdrestore ought to reformat the external log to get the restored filesystem to work again. The common/populate code could already do this, so push it to the common ext4 helper. While we're at it, fix the uncareful usage of SCRATCH_LOGDEV in the populate code. Signed-off-by: Darrick J. Wong --- common/ext4 | 17 ++++++++++++++++- common/populate | 16 ++-------------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/common/ext4 b/common/ext4 index 3dcbfe17c9..5171b8df68 100644 --- a/common/ext4 +++ b/common/ext4 @@ -134,7 +134,8 @@ _ext4_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 @@ -148,6 +149,20 @@ _ext4_mdrestore() test -r "$metadump" || return 1 $E2IMAGE_PROG $options -r "${metadump}" "${SCRATCH_DEV}" + res=$? + test $res -ne 0 && return $res + + # ext4 cannot e2image external logs, so we have to reformat the log + # device to match the restored fs + if [ "${logdev}" != "none" ]; then + local fsuuid="$($DUMPE2FS_PROG -h "${SCRATCH_DEV}" 2>/dev/null | \ + grep 'Journal UUID:' | \ + sed -e 's/Journal UUID:[[:space:]]*//g')" + $MKFS_EXT4_PROG -O journal_dev "${logdev}" \ + -F -U "${fsuuid}" + res=$? + fi + return $res } # this test requires the ext4 kernel support crc feature on scratch device diff --git a/common/populate b/common/populate index 08c4bdc151..095e771d67 100644 --- a/common/populate +++ b/common/populate @@ -912,20 +912,8 @@ _scratch_populate_restore_cached() { return $? ;; "ext2"|"ext3"|"ext4") - _ext4_mdrestore "${metadump}" "${SCRATCH_DEV}" - ret=$? - test $ret -ne 0 && return $ret - - # ext4 cannot e2image external logs, so we have to reformat - # the scratch device to match the restored fs - if [ -n "${SCRATCH_LOGDEV}" ]; then - local fsuuid="$($DUMPE2FS_PROG -h "${SCRATCH_DEV}" 2>/dev/null | \ - grep 'Journal UUID:' | \ - sed -e 's/Journal UUID:[[:space:]]*//g')" - $MKFS_EXT4_PROG -O journal_dev "${SCRATCH_LOGDEV}" \ - -F -U "${fsuuid}" - fi - return 0 + _ext4_mdrestore "${metadump}" "${SCRATCH_DEV}" "${logdev}" + return $? ;; esac return 1 From patchwork Fri Dec 30 22:20:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 13085844 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5030C4332F for ; Sat, 31 Dec 2022 03:09:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236316AbiLaDJm (ORCPT ); Fri, 30 Dec 2022 22:09:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236324AbiLaDJa (ORCPT ); Fri, 30 Dec 2022 22:09:30 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67A0415F1C; Fri, 30 Dec 2022 19:09:29 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id EDEAA61C7A; Sat, 31 Dec 2022 03:09:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 55B22C433EF; Sat, 31 Dec 2022 03:09:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1672456168; bh=64aj6sNU4jmIXiBD/oAd0BMwgzQu21eyPSkp/TpfSsg=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=rQrsvvWVvEWlg5WR6opot1l6W1fb28OHbjt2Z76hYx4unxGX/SZPPrlxxmSMNxluS 3DmW4c/V4BguzqbntkZ71HcKt3lc4DR02F+F+nm98h6pW3JN8XJRWC4xkek1/T1A1V VAKTZph5Taj13sY46mo7KrDc3Sg9wam09O8opNDFKj3kKPH8JMnqK8QQec86SRB/SG RRC4dQJdC7pKgJsye5LkUevgmWZvlRWez6IeBpVuwI73qU8uLuQtOyNCviittOv5WI WYnNqBl8eyrcFCMxn2wgx7u84yajc8/AsnZ9NUmExs+jZPn/YESWw3kIUpRyXEjEZ8 SGxZ0qEs68Fiw== Subject: [PATCH 4/4] common/xfs: capture external logs during metadump/mdrestore From: "Darrick J. Wong" To: zlang@redhat.com, djwong@kernel.org Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org, guan@eryu.me Date: Fri, 30 Dec 2022 14:20:36 -0800 Message-ID: <167243883661.738384.17775898025965694134.stgit@magnolia> In-Reply-To: <167243883613.738384.6883268151338937809.stgit@magnolia> References: <167243883613.738384.6883268151338937809.stgit@magnolia> User-Agent: StGit/0.19 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-xfs@vger.kernel.org From: Darrick J. Wong If xfs_metadump supports the -x switch to capture the contents of external log devices and there is an external log device, add the option to the command line to enable preservation. Similarly, if xfs_mdrestore supports the -l switch and there's an external scratch log, pass the option so that we can restore log contents. Signed-off-by: Darrick J. Wong --- common/xfs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/common/xfs b/common/xfs index 29130fabbc..36e02413db 100644 --- a/common/xfs +++ b/common/xfs @@ -667,9 +667,20 @@ _xfs_metadump() { shift; shift; shift; shift local options="$@" test -z "$options" && options="-a -o" + local metadump_has_dash_x + + # Does metadump support capturing from external devices? + $XFS_METADUMP_PROG --help 2>&1 | grep -q -- '-[a-zA-Z]*[wW]x' && \ + metadump_has_dash_x=1 if [ "$logdev" != "none" ]; then options="$options -l $logdev" + + # Tell metadump to capture the log device + if [ -n "$metadump_has_dash_x" ]; then + options="$options -x" + unset metadump_has_dash_x + fi fi $XFS_METADUMP_PROG $options "$device" "$metadump" @@ -696,6 +707,13 @@ _xfs_mdrestore() { fi test -r "$metadump" || return 1 + # Does mdrestore support restoring to external log devices? If so, + # restore to it, and do not wipe it afterwards. + if [ "$logdev" != "none" ] && $XFS_MDRESTORE_PROG --help 2>&1 | grep -q -- '-l logdev'; then + options="$options -l $logdev" + logdev="none" + fi + $XFS_MDRESTORE_PROG $options "${metadump}" "${device}" res=$? test $res -ne 0 && return $res