All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chandan Babu R <chandanbabu@kernel.org>
To: fstests@vger.kernel.org
Cc: Chandan Babu R <chandanbabu@kernel.org>,
	linux-xfs@vger.kernel.org, djwong@kernel.org, zlang@redhat.com
Subject: [PATCH 3/5] _scratch_xfs_mdrestore: Pass scratch log device when applicable
Date: Tue,  2 Jan 2024 14:13:50 +0530	[thread overview]
Message-ID: <20240102084357.1199843-4-chandanbabu@kernel.org> (raw)
In-Reply-To: <20240102084357.1199843-1-chandanbabu@kernel.org>

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.

Signed-off-by: Chandan Babu R <chandanbabu@kernel.org>
---
 common/xfs | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/common/xfs b/common/xfs
index 558a6bb5..248c8361 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
@@ -695,6 +696,10 @@ _xfs_mdrestore() {
 	fi
 	test -r "$metadump" || return 1
 
+	if [ "$logdev" != "none" ]; then
+		options="$options -l $logdev"
+	fi
+
 	$XFS_MDRESTORE_PROG $options "${metadump}" "${device}"
 }
 
@@ -724,8 +729,18 @@ _scratch_xfs_mdrestore()
 {
 	local metadump=$1
 	shift
+	local logdev=none
+	local options="$@"
 
-	_xfs_mdrestore "$metadump" "$SCRATCH_DEV" "$@"
+	# $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" "$logdev" "$@"
 }
 
 # Do not use xfs_repair (offline fsck) to rebuild the filesystem
-- 
2.43.0


  parent reply	other threads:[~2024-01-02  8:44 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-02  8:43 [PATCH 0/5] Add support for testing XFS metadump v2 Chandan Babu R
2024-01-02  8:43 ` [PATCH 1/5] common/xfs: Do not append -a and -o options to metadump Chandan Babu R
2024-01-02 18:10   ` Darrick J. Wong
2024-01-05  6:54     ` Chandan Babu R
2024-01-06 17:10       ` Darrick J. Wong
2024-01-02  8:43 ` [PATCH 2/5] common/xfs: Add function to detect support for metadump v2 Chandan Babu R
2024-01-02 18:27   ` Darrick J. Wong
2024-01-05  7:03     ` Chandan Babu R
2024-01-02  8:43 ` Chandan Babu R [this message]
2024-01-02 19:11   ` [PATCH 3/5] _scratch_xfs_mdrestore: Pass scratch log device when applicable Darrick J. Wong
2024-01-02  8:43 ` [PATCH 4/5] xfs: Add support for testing metadump v2 Chandan Babu R
2024-01-03  5:57   ` Darrick J. Wong
2024-01-05  7:04     ` Chandan Babu R
2024-01-02  8:43 ` [PATCH 5/5] xfs: Check correctness of metadump/mdrestore's ability to work with dirty log Chandan Babu R
2024-01-03  5:44   ` Darrick J. Wong
2024-01-05 13:36     ` Chandan Babu R

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240102084357.1199843-4-chandanbabu@kernel.org \
    --to=chandanbabu@kernel.org \
    --cc=djwong@kernel.org \
    --cc=fstests@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=zlang@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.