All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: djwong@kernel.org, zlang@redhat.com
Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org, guan@eryu.me
Subject: [PATCH 2/4] common/xfs: create a helper for restoring metadumps to the scratch devs
Date: Tue, 13 Dec 2022 11:45:20 -0800	[thread overview]
Message-ID: <167096072069.1750373.18446461395763381324.stgit@magnolia> (raw)
In-Reply-To: <167096070957.1750373.5715692265711468248.stgit@magnolia>

From: Darrick J. Wong <djwong@kernel.org>

Refactor the open-coded $XFS_MDRESTORE_PROG calls into a proper
_scratch_xfs_mdrestore helper.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 common/xfs    |    9 +++++++++
 tests/xfs/129 |    2 +-
 tests/xfs/234 |    2 +-
 tests/xfs/253 |    2 +-
 tests/xfs/284 |    2 +-
 tests/xfs/291 |    2 +-
 tests/xfs/336 |    2 +-
 tests/xfs/432 |    2 +-
 tests/xfs/503 |    8 ++++----
 9 files changed, 20 insertions(+), 11 deletions(-)


diff --git a/common/xfs b/common/xfs
index 27d6ac84e3..216dab3bcd 100644
--- a/common/xfs
+++ b/common/xfs
@@ -660,6 +660,15 @@ _scratch_xfs_metadump()
 	_xfs_metadump "$metadump" "$SCRATCH_DEV" "$logdev" nocompress "$@"
 }
 
+# Restore snapshotted metadata on the scratch device
+_scratch_xfs_mdrestore()
+{
+	local metadump=$1
+	shift
+
+	_xfs_mdrestore "$metadump" "$SCRATCH_DEV" "$@"
+}
+
 # run xfs_check and friends on a FS.
 _check_xfs_filesystem()
 {
diff --git a/tests/xfs/129 b/tests/xfs/129
index 09d40630d0..6f2ef5640d 100755
--- a/tests/xfs/129
+++ b/tests/xfs/129
@@ -53,7 +53,7 @@ _scratch_xfs_metadump $metadump_file
 
 # Now restore the obfuscated one back and take a look around
 echo "Restore metadump"
-$XFS_MDRESTORE_PROG $metadump_file $TEST_DIR/image
+SCRATCH_DEV=$TEST_DIR/image _scratch_xfs_mdrestore $metadump_file
 SCRATCH_DEV=$TEST_DIR/image _scratch_mount
 SCRATCH_DEV=$TEST_DIR/image _scratch_unmount
 
diff --git a/tests/xfs/234 b/tests/xfs/234
index cc1ee9a8ca..57d447c056 100755
--- a/tests/xfs/234
+++ b/tests/xfs/234
@@ -53,7 +53,7 @@ _scratch_xfs_metadump $metadump_file
 
 # Now restore the obfuscated one back and take a look around
 echo "Restore metadump"
-$XFS_MDRESTORE_PROG $metadump_file $TEST_DIR/image
+SCRATCH_DEV=$TEST_DIR/image _scratch_xfs_mdrestore $metadump_file
 SCRATCH_DEV=$TEST_DIR/image _scratch_mount
 SCRATCH_DEV=$TEST_DIR/image _scratch_unmount
 
diff --git a/tests/xfs/253 b/tests/xfs/253
index 1cfc218088..ce90247777 100755
--- a/tests/xfs/253
+++ b/tests/xfs/253
@@ -152,7 +152,7 @@ _scratch_unmount
 _scratch_xfs_metadump $METADUMP_FILE
 
 # Now restore the obfuscated one back and take a look around
-$XFS_MDRESTORE_PROG "${METADUMP_FILE}" "${SCRATCH_DEV}"
+_scratch_xfs_mdrestore "$METADUMP_FILE"
 
 _scratch_mount
 
diff --git a/tests/xfs/284 b/tests/xfs/284
index e2bd05d4c7..58f330035e 100755
--- a/tests/xfs/284
+++ b/tests/xfs/284
@@ -49,7 +49,7 @@ _scratch_unmount
 # xfs_mdrestore should refuse to restore to a mounted device
 _scratch_xfs_metadump $METADUMP_FILE
 _scratch_mount
-$XFS_MDRESTORE_PROG $METADUMP_FILE $SCRATCH_DEV 2>&1 | filter_mounted
+_scratch_xfs_mdrestore $METADUMP_FILE 2>&1 | filter_mounted
 _scratch_unmount
 
 # Test xfs_copy to a mounted device
diff --git a/tests/xfs/291 b/tests/xfs/291
index f5fea7f9a5..600dcb2eba 100755
--- a/tests/xfs/291
+++ b/tests/xfs/291
@@ -93,7 +93,7 @@ _scratch_xfs_check >> $seqres.full 2>&1 || _fail "xfs_check failed"
 # Yes they can!  Now...
 # Can xfs_metadump cope with this monster?
 _scratch_xfs_metadump $tmp.metadump || _fail "xfs_metadump failed"
-$XFS_MDRESTORE_PROG $tmp.metadump $tmp.img || _fail "xfs_mdrestore failed"
+SCRATCH_DEV=$tmp.img _scratch_xfs_mdrestore $tmp.metadump || _fail "xfs_mdrestore failed"
 SCRATCH_DEV=$tmp.img _scratch_xfs_repair -f &>> $seqres.full || \
 	_fail "xfs_repair of metadump failed"
 
diff --git a/tests/xfs/336 b/tests/xfs/336
index ee8ec649cb..5bcac976e4 100755
--- a/tests/xfs/336
+++ b/tests/xfs/336
@@ -65,7 +65,7 @@ _scratch_xfs_metadump $metadump_file
 
 # Now restore the obfuscated one back and take a look around
 echo "Restore metadump"
-$XFS_MDRESTORE_PROG $metadump_file $TEST_DIR/image
+SCRATCH_DEV=$TEST_DIR/image _scratch_xfs_mdrestore $metadump_file
 SCRATCH_DEV=$TEST_DIR/image _scratch_mount
 SCRATCH_DEV=$TEST_DIR/image _scratch_unmount
 
diff --git a/tests/xfs/432 b/tests/xfs/432
index 676be9bd8a..66315b0398 100755
--- a/tests/xfs/432
+++ b/tests/xfs/432
@@ -87,7 +87,7 @@ test -n "$extlen" || _notrun "could not create dir extent > 1000 blocks"
 
 echo "Try to metadump"
 _scratch_xfs_metadump $metadump_file -w
-$XFS_MDRESTORE_PROG $metadump_file $metadump_img
+SCRATCH_DEV=$metadump_img _scratch_xfs_mdrestore $metadump_file
 
 echo "Check restored metadump image"
 SCRATCH_DEV=$metadump_img _scratch_xfs_repair -n &>> $seqres.full || \
diff --git a/tests/xfs/503 b/tests/xfs/503
index 18bd8694c8..c786b04ccd 100755
--- a/tests/xfs/503
+++ b/tests/xfs/503
@@ -66,25 +66,25 @@ _check_scratch_fs
 _scratch_unmount
 
 echo mdrestore
-$XFS_MDRESTORE_PROG $metadump_file $SCRATCH_DEV
+_scratch_xfs_mdrestore $metadump_file
 _scratch_mount
 _check_scratch_fs
 _scratch_unmount
 
 echo mdrestore a
-$XFS_MDRESTORE_PROG $metadump_file_a $SCRATCH_DEV
+_scratch_xfs_mdrestore $metadump_file_a
 _scratch_mount
 _check_scratch_fs
 _scratch_unmount
 
 echo mdrestore g
-$XFS_MDRESTORE_PROG $metadump_file_g $SCRATCH_DEV
+_scratch_xfs_mdrestore $metadump_file_g
 _scratch_mount
 _check_scratch_fs
 _scratch_unmount
 
 echo mdrestore ag
-$XFS_MDRESTORE_PROG $metadump_file_ag $SCRATCH_DEV
+_scratch_xfs_mdrestore $metadump_file_ag
 _scratch_mount
 _check_scratch_fs
 _scratch_unmount


  parent reply	other threads:[~2022-12-13 19:45 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-13 19:45 [PATCHSET 0/4] fstests: fix broken fuzzing xfs_mdrestore calls Darrick J. Wong
2022-12-13 19:45 ` [PATCH 1/4] common/populate: create helpers to handle restoring metadumps Darrick J. Wong
2022-12-17  6:24   ` Zorro Lang
2022-12-13 19:45 ` Darrick J. Wong [this message]
2022-12-17  6:32   ` [PATCH 2/4] common/xfs: create a helper for restoring metadumps to the scratch devs Zorro Lang
2022-12-13 19:45 ` [PATCH 3/4] common/populate: move decompression code to _{xfs,ext4}_mdrestore Darrick J. Wong
2022-12-17  6:50   ` Zorro Lang
2022-12-17  8:11     ` Darrick J. Wong
2022-12-17  8:18   ` [PATCH v1.1 " Darrick J. Wong
2022-12-17  9:50     ` Zorro Lang
2022-12-13 19:45 ` [PATCH 4/4] fuzzy: don't fail on compressed metadumps Darrick J. Wong
2022-12-17  7:03   ` Zorro Lang
2022-12-17 10:33     ` Zorro Lang
2022-12-17 20:06       ` Darrick J. Wong

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=167096072069.1750373.18446461395763381324.stgit@magnolia \
    --to=djwong@kernel.org \
    --cc=fstests@vger.kernel.org \
    --cc=guan@eryu.me \
    --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.