All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: djwong@kernel.org, guaneryu@gmail.com, zlang@redhat.com
Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org, guan@eryu.me
Subject: [PATCH 3/5] populate: reformat external ext[34] journal devices when restoring a cached image
Date: Tue, 11 Oct 2022 18:45:39 -0700	[thread overview]
Message-ID: <166553913911.422450.17214876114235793554.stgit@magnolia> (raw)
In-Reply-To: <166553912229.422450.15473762183660906876.stgit@magnolia>

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

The fs population code has the ability to save cached metadumps of
filesystems to save time when running fstests.  The cached images should
be unmounted cleanly, so we never save the contents of external journal
devices.

Unfortunately, the cache restore code fails to reset the external
journal when restoring a clean image, so we ignore cached images because
the journal doesn't match the filesystem.  This makes test runtimes
longer than they need to be.

Solve this by reformatting the external journal to match the filesystem.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 common/populate |   20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)


diff --git a/common/populate b/common/populate
index 0bd78e0a0a..66c55b682f 100644
--- a/common/populate
+++ b/common/populate
@@ -16,6 +16,9 @@ _require_populate_commands() {
 		_require_command "$XFS_DB_PROG" "xfs_db"
 		_require_command "$WIPEFS_PROG" "wipefs"
 		;;
+	ext*)
+		_require_command "$DUMPE2FS_PROG" "dumpe2fs"
+		;;
 	esac
 }
 
@@ -871,9 +874,20 @@ _scratch_populate_restore_cached() {
 		return $res
 		;;
 	"ext2"|"ext3"|"ext4")
-		# ext4 cannot e2image external logs, so we cannot restore
-		test -n "${SCRATCH_LOGDEV}" && return 1
-		e2image -r "${metadump}" "${SCRATCH_DEV}" && return 0
+		e2image -r "${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
 		;;
 	esac
 	return 1


  parent reply	other threads:[~2022-10-12  1:45 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-12  1:45 [PATCHSET 0/5] fstests: support external logs when caching prepopulated images Darrick J. Wong
2022-10-12  1:45 ` [PATCH 1/5] populate: export the metadump description name Darrick J. Wong
2022-10-13 14:55   ` Zorro Lang
2022-10-13 15:54     ` Darrick J. Wong
2022-10-13 16:28       ` Zorro Lang
2022-10-13 19:12         ` Darrick J. Wong
2022-10-14  1:17           ` Zorro Lang
2022-10-14 18:21   ` [PATCH v1.1 " Darrick J. Wong
2022-10-15  5:01     ` Zorro Lang
2022-10-15  5:10       ` Zorro Lang
2022-10-15  7:28         ` Darrick J. Wong
2022-10-15  8:21           ` Zorro Lang
2022-10-15  7:23       ` Darrick J. Wong
2022-10-12  1:45 ` [PATCH 2/5] populate: wipe external xfs log devices when restoring a cached image Darrick J. Wong
2022-10-13 15:10   ` Zorro Lang
2022-10-12  1:45 ` Darrick J. Wong [this message]
2022-10-13 15:47   ` [PATCH 3/5] populate: reformat external ext[34] journal " Zorro Lang
2022-10-12  1:45 ` [PATCH 4/5] populate: require e2image before populating Darrick J. Wong
2022-10-13 15:48   ` Zorro Lang
2022-10-12  1:45 ` [PATCH 5/5] fstests: refactor xfs_mdrestore calls Darrick J. Wong
2022-10-13 16:06   ` Zorro Lang

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