From patchwork Tue Jan 9 10:20:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13514723 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 27E8936AEE; Tue, 9 Jan 2024 10:21:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="m6xr/70p" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 764E9C433F1; Tue, 9 Jan 2024 10:21:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704795670; bh=X7T7SibnpDblAuAHtg1wbVmEECiEvQrQbOkkajbEF0Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m6xr/70pm7K5AChP3vvJct5Qqj4aLzV26sxkHbKDRQaGAa6HTj5zNseET6bMxO63r Tw8+8TwTQ4K9eMgwvhTJTX5UYYbZ9azJLjDwzDV8KnBiv/wfS9c4Q2km+nEajmv5lz 6flUlZbyupv73Lb0/3AUbWkID14zE2AKzrf2r/gHPOAmi88tSP9ly0tohMQ3z3PUAU 5QCsZRF0r0xgsCsOag6vUQWPkrc1XrR9Y8cuqiUg91657CupqIZygmET/RIuNbXmIb D/Tlv18LMa2k3q/Z3Ue8IKhFITvlUjybi+If/9cvxKsaKtXCj6jcL76wXlrgRRZhle 6J8RCjquOd2PA== From: Chandan Babu R To: fstests@vger.kernel.org Cc: Chandan Babu R , linux-xfs@vger.kernel.org, djwong@kernel.org, zlang@redhat.com Subject: [PATCH V2 1/5] common/xfs: Do not append -a and -o options to metadump Date: Tue, 9 Jan 2024 15:50:43 +0530 Message-ID: <20240109102054.1668192-2-chandanbabu@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240109102054.1668192-1-chandanbabu@kernel.org> References: <20240109102054.1668192-1-chandanbabu@kernel.org> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 xfs/253 requires the metadump to be obfuscated. However _xfs_metadump() would append the '-o' option causing the metadump to be unobfuscated. This commit fixes the bug by modifying _xfs_metadump() to no longer append any metadump options. The direct/indirect callers of this function now pass the required options explicitly. Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- common/populate | 2 +- common/xfs | 7 +++---- tests/xfs/291 | 2 +- tests/xfs/336 | 2 +- tests/xfs/432 | 2 +- tests/xfs/503 | 2 +- 6 files changed, 8 insertions(+), 9 deletions(-) diff --git a/common/populate b/common/populate index 3d233073..cfbfd88a 100644 --- a/common/populate +++ b/common/populate @@ -55,7 +55,7 @@ __populate_fail() { case "$FSTYP" in xfs) _scratch_unmount - _scratch_xfs_metadump "$metadump" + _scratch_xfs_metadump "$metadump" -a -o ;; ext4) _scratch_unmount diff --git a/common/xfs b/common/xfs index f53b33fc..38094828 100644 --- a/common/xfs +++ b/common/xfs @@ -667,7 +667,6 @@ _xfs_metadump() { local compressopt="$4" shift; shift; shift; shift local options="$@" - test -z "$options" && options="-a -o" if [ "$logdev" != "none" ]; then options="$options -l $logdev" @@ -855,7 +854,7 @@ _check_xfs_filesystem() if [ "$ok" -ne 1 ] && [ "$DUMP_CORRUPT_FS" = "1" ]; then local flatdev="$(basename "$device")" _xfs_metadump "$seqres.$flatdev.check.md" "$device" "$logdev" \ - compress >> $seqres.full + compress -a -o >> $seqres.full fi # Optionally test the index rebuilding behavior. @@ -888,7 +887,7 @@ _check_xfs_filesystem() if [ "$rebuild_ok" -ne 1 ] && [ "$DUMP_CORRUPT_FS" = "1" ]; then local flatdev="$(basename "$device")" _xfs_metadump "$seqres.$flatdev.rebuild.md" "$device" \ - "$logdev" compress >> $seqres.full + "$logdev" compress -a -o >> $seqres.full fi fi @@ -972,7 +971,7 @@ _check_xfs_filesystem() if [ "$orebuild_ok" -ne 1 ] && [ "$DUMP_CORRUPT_FS" = "1" ]; then local flatdev="$(basename "$device")" _xfs_metadump "$seqres.$flatdev.orebuild.md" "$device" \ - "$logdev" compress >> $seqres.full + "$logdev" compress -a -o >> $seqres.full fi fi diff --git a/tests/xfs/291 b/tests/xfs/291 index 600dcb2e..54448497 100755 --- a/tests/xfs/291 +++ b/tests/xfs/291 @@ -92,7 +92,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" +_scratch_xfs_metadump $tmp.metadump -a -o || _fail "xfs_metadump 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 d7a074d9..43b3790c 100755 --- a/tests/xfs/336 +++ b/tests/xfs/336 @@ -62,7 +62,7 @@ _scratch_cycle_mount echo "Create metadump file" _scratch_unmount -_scratch_xfs_metadump $metadump_file +_scratch_xfs_metadump $metadump_file -a # Now restore the obfuscated one back and take a look around echo "Restore metadump" diff --git a/tests/xfs/432 b/tests/xfs/432 index 66315b03..dae68fb2 100755 --- a/tests/xfs/432 +++ b/tests/xfs/432 @@ -86,7 +86,7 @@ echo "qualifying extent: $extlen blocks" >> $seqres.full test -n "$extlen" || _notrun "could not create dir extent > 1000 blocks" echo "Try to metadump" -_scratch_xfs_metadump $metadump_file -w +_scratch_xfs_metadump $metadump_file -a -o -w SCRATCH_DEV=$metadump_img _scratch_xfs_mdrestore $metadump_file echo "Check restored metadump image" diff --git a/tests/xfs/503 b/tests/xfs/503 index f5710ece..8805632d 100755 --- a/tests/xfs/503 +++ b/tests/xfs/503 @@ -46,7 +46,7 @@ metadump_file_ag=${metadump_file}.ag copy_file=$testdir/copy.img echo metadump -_scratch_xfs_metadump $metadump_file >> $seqres.full +_scratch_xfs_metadump $metadump_file -a -o >> $seqres.full echo metadump a _scratch_xfs_metadump $metadump_file_a -a >> $seqres.full From patchwork Tue Jan 9 10:20:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13514724 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B11E236AED; Tue, 9 Jan 2024 10:21:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="kl7pbz8g" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A89B2C433C7; Tue, 9 Jan 2024 10:21:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704795673; bh=KrcwIHRNBrvWhmypIQpphTw4zTRmmmsGsm5ScFnFkyc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kl7pbz8ggowixp5kKgBkCUyxefzap8swHixtvYFYsUwFtKbphO01KydBXxJ39oT+x 9mb6boRd4sRhcQc9Ad9QGR4ma8/XyMF1Ap/iefvDQsa4197xXEaxyBu4zgGMDepujI ikGYd4I0wY3GYAWiGBnSnJ8XBNYPJMq+vXNf1SJ299UF9dsnEiupDlIMCe6S6vOkvP hhclPimR2sMZiAadPWSeno7gGSW2FVRTSf2b3xkiXre+Y3VLxfNOyS5EIldLQXPE2M 4F310scKnzu3DrzyFfLnrxGVmVeifIN4009YyojsnzC7A/gqH475eScMbBIFwzK97p oSvksNLI4zrzQ== From: Chandan Babu R To: fstests@vger.kernel.org Cc: Chandan Babu R , linux-xfs@vger.kernel.org, djwong@kernel.org, zlang@redhat.com Subject: [PATCH V2 2/5] common/xfs: Add function to detect support for metadump v2 Date: Tue, 9 Jan 2024 15:50:44 +0530 Message-ID: <20240109102054.1668192-3-chandanbabu@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240109102054.1668192-1-chandanbabu@kernel.org> References: <20240109102054.1668192-1-chandanbabu@kernel.org> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This commit defines a new function to help detect support for metadump v2. Signed-off-by: Chandan Babu R Reviewed-by: Darrick J. Wong --- common/xfs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/common/xfs b/common/xfs index 38094828..fc744489 100644 --- a/common/xfs +++ b/common/xfs @@ -698,6 +698,12 @@ _xfs_mdrestore() { $XFS_MDRESTORE_PROG $options "${metadump}" "${device}" } +_scratch_metadump_v2_supported() +{ + $XFS_DB_PROG -c "help metadump" $SCRATCH_DEV | \ + grep -q "Metadump version to be used" +} + # Snapshot the metadata on the scratch device _scratch_xfs_metadump() { From patchwork Tue Jan 9 10:20:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13514725 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B0A1536AFD; Tue, 9 Jan 2024 10:21:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XcID1vEN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AC119C433A6; Tue, 9 Jan 2024 10:21:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704795676; bh=u4HHZ3AFHL7gMnlhFkwiY14aNOdvq20liB4pGJr3ARw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XcID1vENcH4PU30xKUZSTh28ZGN+UYU3qDmH0EFAtIt222heWLkYfj7tp63bLF3uA uMF2nQetoZquEh4BEBgfds3ag/jJCOabiGSr6mYZNR3663rO5o/V0pVex7h7OyMg3m eDMdXwFE4KadaBEJOgNzPbdvBYk4t9X4Lr1D/QEegLLDneeOIbJjV7zRJdxKXWVpOZ X9inart7nuT6TQWe/UrwaNu+QIV0UaOk5uoamH3lYf7oYubvJJW1JS6xzxrKcniyrQ dlVfkKCfZYsSz9lrVVfV6VvnVqLZuANUF4EyZZTIXlFMDjUToPEUOmUoo7REjEsc7A NCTyP/qND0axw== From: Chandan Babu R To: fstests@vger.kernel.org Cc: Chandan Babu R , linux-xfs@vger.kernel.org, djwong@kernel.org, zlang@redhat.com Subject: [PATCH V2 3/5] _scratch_xfs_mdrestore: Pass scratch log device when applicable Date: Tue, 9 Jan 2024 15:50:45 +0530 Message-ID: <20240109102054.1668192-4-chandanbabu@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240109102054.1668192-1-chandanbabu@kernel.org> References: <20240109102054.1668192-1-chandanbabu@kernel.org> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 --- common/xfs | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/common/xfs b/common/xfs index fc744489..070680d8 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}" } @@ -722,8 +727,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 From patchwork Tue Jan 9 10:20:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13514726 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 17EC136AED; Tue, 9 Jan 2024 10:21:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="egkBk60W" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C0ADDC433C7; Tue, 9 Jan 2024 10:21:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704795679; bh=x7IgayICm6Hex/YlLffkZCic7vju9DGwjBnBDNvTxSo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=egkBk60WOWJBvMWhJUVbuFfNLRGhXEk0zmPta4YQXHOQh5YxTE02UgJUEoAMKHgOI HaAE+CfAtSuzTwIhioUYTbrFbX8xL6n/jDpbn1buVpVZJE95HoDT7OYOsR1u4GhT/o 0biUQnjngV04s2AO4xPmgabh9R6q9FV/sq7PZm/VFAIpsW2GdVaRBRg613rkUgiHeI doygBNkEhCl5DWOyEK13AdSgQ8UdqP8UJcbS13l+zM3iAruahiLL65b1GLdqCiiW54 7GHL7rewEg8FXww20nMKJdPxV5y+S16alofgMFWbAViiqMXR2zGhDsUOTOrKsnu9qx 4n5/sxxdR4Iyw== From: Chandan Babu R To: fstests@vger.kernel.org Cc: Chandan Babu R , linux-xfs@vger.kernel.org, djwong@kernel.org, zlang@redhat.com Subject: [PATCH V2 4/5] xfs: Add support for testing metadump v2 Date: Tue, 9 Jan 2024 15:50:46 +0530 Message-ID: <20240109102054.1668192-5-chandanbabu@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240109102054.1668192-1-chandanbabu@kernel.org> References: <20240109102054.1668192-1-chandanbabu@kernel.org> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This commit adds the ability to test metadump v2 to existing metadump tests. Signed-off-by: Chandan Babu R --- tests/xfs/129 | 97 ++++++++++++++++++++++++++++++++----- tests/xfs/129.out | 4 +- tests/xfs/234 | 97 ++++++++++++++++++++++++++++++++----- tests/xfs/234.out | 4 +- tests/xfs/253 | 118 ++++++++++++++++++++++++++++++++++++++-------- tests/xfs/291 | 25 ++++++++-- tests/xfs/432 | 29 +++++++++--- tests/xfs/432.out | 3 +- tests/xfs/503 | 94 ++++++++++++++++++++++-------------- tests/xfs/503.out | 12 ++--- 10 files changed, 381 insertions(+), 102 deletions(-) diff --git a/tests/xfs/129 b/tests/xfs/129 index 6f2ef564..8a817b41 100755 --- a/tests/xfs/129 +++ b/tests/xfs/129 @@ -16,7 +16,11 @@ _cleanup() { cd / _scratch_unmount > /dev/null 2>&1 - rm -rf $tmp.* $testdir $metadump_file $TEST_DIR/image + [[ -n $logdev && $logdev != "none" && $logdev != $SCRATCH_LOGDEV ]] && \ + _destroy_loop_device $logdev + [[ -n $datadev ]] && _destroy_loop_device $datadev + rm -rf $tmp.* $testdir $metadump_file $TEST_DIR/data-image \ + $TEST_DIR/log-image } # Import common functions. @@ -29,12 +33,86 @@ _require_command "$XFS_MDRESTORE_PROG" "xfs_mdrestore" _require_loop _require_scratch_reflink +metadump_file=$TEST_DIR/${seq}_metadump + +verify_metadump_v1() +{ + local max_version=$1 + local version="" + + if [[ $max_version == 2 ]]; then + version="-v 1" + fi + + _scratch_xfs_metadump $metadump_file $version + + SCRATCH_DEV=$TEST_DIR/data-image SCRATCH_LOGDEV="" \ + _scratch_xfs_mdrestore $metadump_file + + datadev=$(_create_loop_device $TEST_DIR/data-image) + + SCRATCH_DEV=$datadev _scratch_mount + SCRATCH_DEV=$datadev _scratch_unmount + + logdev=$SCRATCH_LOGDEV + [[ -z $logdev ]] && logdev=none + _check_xfs_filesystem $datadev $logdev none + + _destroy_loop_device $datadev + datadev="" + rm -f $TEST_DIR/data-image +} + +verify_metadump_v2() +{ + version="-v 2" + + _scratch_xfs_metadump $metadump_file $version + + # Metadump v2 files can contain contents dumped from an external log + # device. Use a temporary file to hold the log device contents restored + # from such a metadump file. + slogdev="" + if [[ -n $SCRATCH_LOGDEV ]]; then + slogdev=$TEST_DIR/log-image + fi + + SCRATCH_DEV=$TEST_DIR/data-image SCRATCH_LOGDEV=$slogdev \ + _scratch_xfs_mdrestore $metadump_file + + datadev=$(_create_loop_device $TEST_DIR/data-image) + + logdev=${SCRATCH_LOGDEV} + if [[ -s $TEST_DIR/log-image ]]; then + logdev=$(_create_loop_device $TEST_DIR/log-image) + fi + + SCRATCH_DEV=$datadev SCRATCH_LOGDEV=$logdev _scratch_mount + SCRATCH_DEV=$datadev SCRATCH_LOGDEV=$logdev _scratch_unmount + + [[ -z $logdev ]] && logdev=none + _check_xfs_filesystem $datadev $logdev none + + if [[ -s $TEST_DIR/log-image ]]; then + _destroy_loop_device $logdev + logdev="" + rm -f $TEST_DIR/log-image + fi + + _destroy_loop_device $datadev + datadev="" + rm -f $TEST_DIR/data-image +} + _scratch_mkfs >/dev/null 2>&1 + +max_md_version=1 +_scratch_metadump_v2_supported && max_md_version=2 + _scratch_mount testdir=$SCRATCH_MNT/test-$seq mkdir $testdir -metadump_file=$TEST_DIR/${seq}_metadump echo "Create the original file blocks" blksz="$(_get_file_block_size $testdir)" @@ -47,18 +125,15 @@ seq 1 2 $((nr_blks - 1)) | while read nr; do $testdir/file2 $((nr * blksz)) $blksz >> $seqres.full done -echo "Create metadump file" _scratch_unmount -_scratch_xfs_metadump $metadump_file -# Now restore the obfuscated one back and take a look around -echo "Restore metadump" -SCRATCH_DEV=$TEST_DIR/image _scratch_xfs_mdrestore $metadump_file -SCRATCH_DEV=$TEST_DIR/image _scratch_mount -SCRATCH_DEV=$TEST_DIR/image _scratch_unmount +echo "Create metadump file, restore it and check restored fs" -echo "Check restored fs" -_check_generic_filesystem $metadump_file +verify_metadump_v1 $max_md_version + +if [[ $max_md_version == 2 ]]; then + verify_metadump_v2 +fi # success, all done status=0 diff --git a/tests/xfs/129.out b/tests/xfs/129.out index da6f43fd..0f24c431 100644 --- a/tests/xfs/129.out +++ b/tests/xfs/129.out @@ -1,6 +1,4 @@ QA output created by 129 Create the original file blocks Reflink every other block -Create metadump file -Restore metadump -Check restored fs +Create metadump file, restore it and check restored fs diff --git a/tests/xfs/234 b/tests/xfs/234 index 57d447c0..c9bdb674 100755 --- a/tests/xfs/234 +++ b/tests/xfs/234 @@ -16,7 +16,11 @@ _cleanup() { cd / _scratch_unmount > /dev/null 2>&1 - rm -rf $tmp.* $metadump_file $TEST_DIR/image + [[ -n $logdev && $logdev != "none" && $logdev != $SCRATCH_LOGDEV ]] && \ + _destroy_loop_device $logdev + [[ -n $datadev ]] && _destroy_loop_device $datadev + rm -rf $tmp.* $testdir $metadump_file $TEST_DIR/image \ + $TEST_DIR/log-image } # Import common functions. @@ -29,12 +33,86 @@ _require_loop _require_xfs_scratch_rmapbt _require_xfs_io_command "fpunch" +metadump_file=$TEST_DIR/${seq}_metadump + +verify_metadump_v1() +{ + local max_version=$1 + local version="" + + if [[ $max_version == 2 ]]; then + version="-v 1" + fi + + _scratch_xfs_metadump $metadump_file $version + + SCRATCH_DEV=$TEST_DIR/data-image SCRATCH_LOGDEV="" \ + _scratch_xfs_mdrestore $metadump_file + + datadev=$(_create_loop_device $TEST_DIR/data-image) + + SCRATCH_DEV=$datadev _scratch_mount + SCRATCH_DEV=$datadev _scratch_unmount + + logdev=$SCRATCH_LOGDEV + [[ -z $logdev ]] && logdev=none + _check_xfs_filesystem $datadev $logdev none + + _destroy_loop_device $datadev + datadev="" + rm -f $TEST_DIR/data-image +} + +verify_metadump_v2() +{ + version="-v 2" + + _scratch_xfs_metadump $metadump_file $version + + # Metadump v2 files can contain contents dumped from an external log + # device. Use a temporary file to hold the log device contents restored + # from such a metadump file. + slogdev="" + if [[ -n $SCRATCH_LOGDEV ]]; then + slogdev=$TEST_DIR/log-image + fi + + SCRATCH_DEV=$TEST_DIR/data-image SCRATCH_LOGDEV=$slogdev \ + _scratch_xfs_mdrestore $metadump_file + + datadev=$(_create_loop_device $TEST_DIR/data-image) + + logdev=${SCRATCH_LOGDEV} + if [[ -s $TEST_DIR/log-image ]]; then + logdev=$(_create_loop_device $TEST_DIR/log-image) + fi + + SCRATCH_DEV=$datadev SCRATCH_LOGDEV=$logdev _scratch_mount + SCRATCH_DEV=$datadev SCRATCH_LOGDEV=$logdev _scratch_unmount + + [[ -z $logdev ]] && logdev=none + _check_xfs_filesystem $datadev $logdev none + + if [[ -s $TEST_DIR/log-image ]]; then + _destroy_loop_device $logdev + logdev="" + rm -f $TEST_DIR/log-image + fi + + _destroy_loop_device $datadev + datadev="" + rm -f $TEST_DIR/data-image +} + _scratch_mkfs >/dev/null 2>&1 + +max_md_version=1 +_scratch_metadump_v2_supported && max_md_version=2 + _scratch_mount testdir=$SCRATCH_MNT/test-$seq mkdir $testdir -metadump_file=$TEST_DIR/${seq}_metadump echo "Create the original file blocks" blksz="$(_get_block_size $testdir)" @@ -47,18 +125,15 @@ seq 1 2 $((nr_blks - 1)) | while read nr; do $XFS_IO_PROG -c "fpunch $((nr * blksz)) $blksz" $testdir/file1 >> $seqres.full done -echo "Create metadump file" _scratch_unmount -_scratch_xfs_metadump $metadump_file -# Now restore the obfuscated one back and take a look around -echo "Restore metadump" -SCRATCH_DEV=$TEST_DIR/image _scratch_xfs_mdrestore $metadump_file -SCRATCH_DEV=$TEST_DIR/image _scratch_mount -SCRATCH_DEV=$TEST_DIR/image _scratch_unmount +echo "Create metadump file, restore it and check restored fs" -echo "Check restored fs" -_check_generic_filesystem $metadump_file +verify_metadump_v1 $max_md_version + +if [[ $max_md_version == 2 ]]; then + verify_metadump_v2 +fi # success, all done status=0 diff --git a/tests/xfs/234.out b/tests/xfs/234.out index 463d4660..fc2ddd77 100644 --- a/tests/xfs/234.out +++ b/tests/xfs/234.out @@ -1,6 +1,4 @@ QA output created by 234 Create the original file blocks Punch every other block -Create metadump file -Restore metadump -Check restored fs +Create metadump file, restore it and check restored fs diff --git a/tests/xfs/253 b/tests/xfs/253 index ce902477..8e18ddb8 100755 --- a/tests/xfs/253 +++ b/tests/xfs/253 @@ -27,6 +27,9 @@ _cleanup() rm -f $tmp.* rm -rf "${OUTPUT_DIR}" rm -f "${METADUMP_FILE}" + [[ -n $logdev && $logdev != $SCRATCH_LOGDEV ]] && \ + _destroy_loop_device $logdev + [[ -n $datadev ]] && _destroy_loop_device $datadev } # Import common functions. @@ -49,21 +52,101 @@ function create_file() { touch $(printf "$@") } +verify_metadump_v1() +{ + local max_version=$1 + local version="" + + if [[ $max_version == 2 ]]; then + version="-v 1" + fi + + _scratch_xfs_metadump $METADUMP_FILE $version + + SCRATCH_DEV=$TEST_DIR/data-image SCRATCH_LOGDEV="" \ + _scratch_xfs_mdrestore $METADUMP_FILE + + datadev=$(_create_loop_device $TEST_DIR/data-image) + + SCRATCH_DEV=$datadev _scratch_mount + + cd "${SCRATCH_MNT}" + + # Get a listing of all the files after obfuscation + echo "Metadump v1" >> $seqres.full + ls -R >> $seqres.full + ls -R | od -c >> $seqres.full + + cd / + + SCRATCH_DEV=$datadev _scratch_unmount + + _destroy_loop_device $datadev + datadev="" + rm -f $TEST_DIR/data-image +} + +verify_metadump_v2() +{ + version="-v 2" + + _scratch_xfs_metadump $METADUMP_FILE $version + + # Metadump v2 files can contain contents dumped from an external log + # device. Use a temporary file to hold the log device contents restored + # from such a metadump file. + slogdev="" + if [[ -n $SCRATCH_LOGDEV ]]; then + slogdev=$TEST_DIR/log-image + fi + + SCRATCH_DEV=$TEST_DIR/data-image SCRATCH_LOGDEV=$slogdev \ + _scratch_xfs_mdrestore $METADUMP_FILE + + datadev=$(_create_loop_device $TEST_DIR/data-image) + + logdev=${SCRATCH_LOGDEV} + if [[ -s $TEST_DIR/log-image ]]; then + logdev=$(_create_loop_device $TEST_DIR/log-image) + fi + + SCRATCH_DEV=$datadev SCRATCH_LOGDEV=$logdev _scratch_mount + + cd "${SCRATCH_MNT}" + + # Get a listing of all the files after obfuscation + echo "Metadump v2" >> $seqres.full + ls -R >> $seqres.full + ls -R | od -c >> $seqres.full + + cd / + + SCRATCH_DEV=$datadev SCRATCH_LOGDEV=$logdev _scratch_unmount + + if [[ -s $TEST_DIR/log-image ]]; then + _destroy_loop_device $logdev + logdev="" + rm -f $TEST_DIR/log-image + fi + + _destroy_loop_device $datadev + datadev="" + rm -f $TEST_DIR/data-image +} + echo "Disciplyne of silence is goed." _scratch_mkfs >/dev/null 2>&1 _scratch_mount -# Initialize and mount the scratch filesystem, then create a bunch -# of files that exercise the original problem. +# Initialize and mount the scratch filesystem, then create a bunch of +# files that exercise the original problem. # # The problem arose when a file name produced a hash that contained -# either 0x00 (string terminator) or 0x27 ('/' character) in a -# spot used to determine a character in an obfuscated name. This -# occurred in one of 5 spots at the end of the name, at position -# (last-4), (last-3), (last-2), (last-1), or (last). - -rm -f "${METADUMP_FILE}" +# either 0x00 (string terminator) or 0x27 ('/' character) in a spot used +# to determine a character in an obfuscated name. This occurred in one +# of 5 spots at the end of the name, at position (last-4), (last-3), +# (last-2), (last-1), or (last). mkdir -p "${OUTPUT_DIR}" @@ -78,8 +161,8 @@ create_file 'lmno' # hash 0x0d9b776f (4-byte name) create_file 'pqrstu' # hash 0x1e5cf9f2 (6-byte name) create_file 'abcdefghijklmnopqrstuvwxyz' # a most remarkable word (0x55004ae3) -# Create a short directory name; it won't be obfuscated. Populate -# it with some longer named-files. The first part of the obfuscated +# Create a short directory name; it won't be obfuscated. Populate it +# with some longer named-files. The first part of the obfuscated # filenames should use printable characters. mkdir foo create_file 'foo/longer_file_name_1' # hash 0xe83634ec @@ -149,22 +232,19 @@ ls -R | od -c >> $seqres.full cd $here _scratch_unmount -_scratch_xfs_metadump $METADUMP_FILE -# Now restore the obfuscated one back and take a look around -_scratch_xfs_mdrestore "$METADUMP_FILE" +max_md_version=1 +_scratch_metadump_v2_supported && max_md_version=2 -_scratch_mount +verify_metadump_v1 $max_md_version -# Get a listing of all the files after obfuscation -cd ${SCRATCH_MNT} -ls -R >> $seqres.full -ls -R | od -c >> $seqres.full +if [[ $max_md_version == 2 ]]; then + verify_metadump_v2 +fi # Finally, re-make the filesystem since to ensure we don't # leave a directory with duplicate entries lying around. cd / -_scratch_unmount _scratch_mkfs >/dev/null 2>&1 # all done diff --git a/tests/xfs/291 b/tests/xfs/291 index 54448497..33193eb7 100755 --- a/tests/xfs/291 +++ b/tests/xfs/291 @@ -92,10 +92,27 @@ _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 -a -o || _fail "xfs_metadump 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" +max_md_version=1 +_scratch_metadump_v2_supported && max_md_version=2 + +for md_version in $(seq 1 $max_md_version); do + version="" + if [[ $max_md_version == 2 ]]; then + version="-v $md_version" + fi + + _scratch_xfs_metadump $tmp.metadump -a -o $version || \ + _fail "xfs_metadump failed" + + slogdev=$SCRATCH_LOGDEV + if [[ -z $version || $version == "-v 1" ]]; then + slogdev="" + fi + SCRATCH_DEV=$tmp.img SCRATCH_LOGDEV=$slogdev _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" +done # Yes it can; success, all done status=0 diff --git a/tests/xfs/432 b/tests/xfs/432 index dae68fb2..a215d3ce 100755 --- a/tests/xfs/432 +++ b/tests/xfs/432 @@ -50,6 +50,7 @@ echo "Format and mount" # block. 8187 hashes/dablk / 248 dirents/dirblock = ~33 dirblocks per # dablock. 33 dirblocks * 64k mean that we can expand a directory by # 2112k before we have to allocate another da btree block. + _scratch_mkfs -b size=1k -n size=64k > "$seqres.full" 2>&1 _scratch_mount >> "$seqres.full" 2>&1 @@ -85,13 +86,29 @@ extlen="$(check_for_long_extent $dir_inum)" echo "qualifying extent: $extlen blocks" >> $seqres.full test -n "$extlen" || _notrun "could not create dir extent > 1000 blocks" -echo "Try to metadump" -_scratch_xfs_metadump $metadump_file -a -o -w -SCRATCH_DEV=$metadump_img _scratch_xfs_mdrestore $metadump_file +echo "Try to metadump, restore and check restored metadump image" +max_md_version=1 +_scratch_metadump_v2_supported && max_md_version=2 -echo "Check restored metadump image" -SCRATCH_DEV=$metadump_img _scratch_xfs_repair -n &>> $seqres.full || \ - echo "xfs_repair on restored fs returned $?" +for md_version in $(seq 1 $max_md_version); do + version="" + if [[ $max_md_version == 2 ]]; then + version="-v $md_version" + fi + + _scratch_xfs_metadump $metadump_file -a -o -w $version + + slogdev=$SCRATCH_LOGDEV + if [[ -z $version || $version == "-v 1" ]]; then + slogdev="" + fi + + SCRATCH_DEV=$metadump_img SCRATCH_LOGDEV=$slogdev \ + _scratch_xfs_mdrestore $metadump_file + + SCRATCH_DEV=$metadump_img _scratch_xfs_repair -n &>> $seqres.full || \ + echo "xfs_repair on restored fs returned $?" +done # success, all done status=0 diff --git a/tests/xfs/432.out b/tests/xfs/432.out index 1f135d16..37bac902 100644 --- a/tests/xfs/432.out +++ b/tests/xfs/432.out @@ -2,5 +2,4 @@ QA output created by 432 Format and mount Create huge dir Check for > 1000 block extent? -Try to metadump -Check restored metadump image +Try to metadump, restore and check restored metadump image diff --git a/tests/xfs/503 b/tests/xfs/503 index 8805632d..a1479eb6 100755 --- a/tests/xfs/503 +++ b/tests/xfs/503 @@ -29,6 +29,7 @@ testdir=$TEST_DIR/test-$seq _supported_fs xfs _require_command "$XFS_MDRESTORE_PROG" "xfs_mdrestore" +_require_loop _require_xfs_copy _require_scratch_nocheck _require_populate_commands @@ -40,22 +41,69 @@ _scratch_populate_cached nofill > $seqres.full 2>&1 mkdir -p $testdir metadump_file=$testdir/scratch.md -metadump_file_a=${metadump_file}.a -metadump_file_g=${metadump_file}.g -metadump_file_ag=${metadump_file}.ag copy_file=$testdir/copy.img -echo metadump -_scratch_xfs_metadump $metadump_file -a -o >> $seqres.full +check_restored_metadump_image() +{ + local image=$1 -echo metadump a -_scratch_xfs_metadump $metadump_file_a -a >> $seqres.full + loop_dev=$(_create_loop_device $image) + SCRATCH_DEV=$loop_dev _scratch_mount + SCRATCH_DEV=$loop_dev _check_scratch_fs + SCRATCH_DEV=$loop_dev _scratch_unmount + _destroy_loop_device $loop_dev +} -echo metadump g -_scratch_xfs_metadump $metadump_file_g -g >> $seqres.full +max_md_version=1 +_scratch_metadump_v2_supported && max_md_version=2 -echo metadump ag -_scratch_xfs_metadump $metadump_file_ag -a -g >> $seqres.full +echo "metadump and mdrestore" +for md_version in $(seq 1 $max_md_version); do + version="" + if [[ $max_md_version == 2 ]]; then + version="-v $md_version" + fi + + _scratch_xfs_metadump $metadump_file -a -o $version >> $seqres.full + SCRATCH_DEV=$TEST_DIR/image _scratch_xfs_mdrestore $metadump_file + check_restored_metadump_image $TEST_DIR/image +done + +echo "metadump a and mdrestore" +for md_version in $(seq 1 $max_md_version); do + version="" + if [[ $max_md_version == 2 ]]; then + version="-v $md_version" + fi + + _scratch_xfs_metadump $metadump_file -a $version >> $seqres.full + SCRATCH_DEV=$TEST_DIR/image _scratch_xfs_mdrestore $metadump_file + check_restored_metadump_image $TEST_DIR/image +done + +echo "metadump g and mdrestore" +for md_version in $(seq 1 $max_md_version); do + version="" + if [[ $max_md_version == 2 ]]; then + version="-v $md_version" + fi + + _scratch_xfs_metadump $metadump_file -g $version >> $seqres.full + SCRATCH_DEV=$TEST_DIR/image _scratch_xfs_mdrestore $metadump_file + check_restored_metadump_image $TEST_DIR/image +done + +echo "metadump ag and mdrestore" +for md_version in $(seq 1 $max_md_version); do + version="" + if [[ $max_md_version == 2 ]]; then + version="-v $md_version" + fi + + _scratch_xfs_metadump $metadump_file -a -g $version >> $seqres.full + SCRATCH_DEV=$TEST_DIR/image _scratch_xfs_mdrestore $metadump_file + check_restored_metadump_image $TEST_DIR/image +done echo copy $XFS_COPY_PROG $SCRATCH_DEV $copy_file >> $seqres.full @@ -67,30 +115,6 @@ _scratch_mount _check_scratch_fs _scratch_unmount -echo mdrestore -_scratch_xfs_mdrestore $metadump_file -_scratch_mount -_check_scratch_fs -_scratch_unmount - -echo mdrestore a -_scratch_xfs_mdrestore $metadump_file_a -_scratch_mount -_check_scratch_fs -_scratch_unmount - -echo mdrestore g -_scratch_xfs_mdrestore $metadump_file_g -_scratch_mount -_check_scratch_fs -_scratch_unmount - -echo mdrestore ag -_scratch_xfs_mdrestore $metadump_file_ag -_scratch_mount -_check_scratch_fs -_scratch_unmount - # success, all done status=0 exit diff --git a/tests/xfs/503.out b/tests/xfs/503.out index 8ef31dbe..496f2516 100644 --- a/tests/xfs/503.out +++ b/tests/xfs/503.out @@ -1,12 +1,8 @@ QA output created by 503 Format and populate -metadump -metadump a -metadump g -metadump ag +metadump and mdrestore +metadump a and mdrestore +metadump g and mdrestore +metadump ag and mdrestore copy recopy -mdrestore -mdrestore a -mdrestore g -mdrestore ag From patchwork Tue Jan 9 10:20:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chandan Babu R X-Patchwork-Id: 13514727 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B8D0E36B17; Tue, 9 Jan 2024 10:21:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="APhHxEAj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 18638C43394; Tue, 9 Jan 2024 10:21:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704795682; bh=E98CMmPmtp7X7GFuAdrPG/3wB2r8h5HPUMvqagvqccY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=APhHxEAj3Kjeee2XzxeoTEGCKahd+G0X8hWB93zMI6lAEqaRkIa2I7JK98tYCDhgb ayfRlwNaB+ZmWmdQNPPoyqIM7DwoInwn7Z7DLQraeUl8pOiliedOPc1t2sDEm9cXIX /2rpEcxV1M4/i0YUHZE49Vp/GltT3T7j0e6xHYnR6I/X1Fksp4wnUeBYSJ3fwdYy/Q i4gA83Q59t/vJByf8HibBCLMNuI2OuzQnLFTxT/2vSVlz9tyS7u2uN3w/PS391f66r jR2/j+JUmvIdpVDcA4ODQRCo58Jfu1N0YPUN7NRGQ8ivJXN6DYhJVUiqXrXDgsfyZL Nz/ekh5ykUNrQ== From: Chandan Babu R To: fstests@vger.kernel.org Cc: Chandan Babu R , linux-xfs@vger.kernel.org, djwong@kernel.org, zlang@redhat.com Subject: [PATCH V2 5/5] xfs: Check correctness of metadump/mdrestore's ability to work with dirty log Date: Tue, 9 Jan 2024 15:50:47 +0530 Message-ID: <20240109102054.1668192-6-chandanbabu@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240109102054.1668192-1-chandanbabu@kernel.org> References: <20240109102054.1668192-1-chandanbabu@kernel.org> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add a new test to verify if metadump/mdrestore are able to dump and restore the contents of a dirty log. Signed-off-by: Chandan Babu R --- tests/xfs/801 | 178 ++++++++++++++++++++++++++++++++++++++++++++++ tests/xfs/801.out | 14 ++++ 2 files changed, 192 insertions(+) create mode 100755 tests/xfs/801 create mode 100644 tests/xfs/801.out diff --git a/tests/xfs/801 b/tests/xfs/801 new file mode 100755 index 00000000..a7866ce7 --- /dev/null +++ b/tests/xfs/801 @@ -0,0 +1,178 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2024 Oracle, Inc. All Rights Reserved. +# +# FS QA Test 801 +# +# Test metadump/mdrestore's ability to dump a dirty log and restore it +# correctly. +# +. ./common/preamble +_begin_fstest auto quick metadump log logprint punch + +# Override the default cleanup function. +_cleanup() +{ + cd / + rm -r -f $tmp.* + _scratch_unmount > /dev/null 2>&1 + [[ -n $logdev && $logdev != "none" && $logdev != $SCRATCH_LOGDEV ]] && \ + _destroy_loop_device $logdev + [[ -n $datadev ]] && _destroy_loop_device $datadev + rm -r -f $metadump_file $TEST_DIR/data-image \ + $TEST_DIR/log-image +} + +# Import common functions. +. ./common/dmflakey +. ./common/inject + +# real QA test starts here +_supported_fs xfs +_require_scratch +_require_test +_require_loop +_require_xfs_debug +_require_xfs_io_error_injection log_item_pin +_require_dm_target flakey +_require_xfs_io_command "pwrite" +_require_test_program "punch-alternating" + +metadump_file=${TEST_DIR}/${seq}.md +testfile=${SCRATCH_MNT}/testfile + +echo "Format filesystem on scratch device" +_scratch_mkfs >> $seqres.full 2>&1 + +max_md_version=1 +_scratch_metadump_v2_supported && max_md_version=2 + +external_log=0 +if [[ $USE_EXTERNAL = yes && -n "$SCRATCH_LOGDEV" ]]; then + external_log=1 +fi + +if [[ $max_md_version == 1 && $external_log == 1 ]]; then + _notrun "metadump v1 does not support external log device" +fi + +verify_metadump_v1() +{ + local version="" + if [[ $max_md_version == 2 ]]; then + version="-v 1" + fi + + _scratch_xfs_metadump $metadump_file -a -o $version + + SCRATCH_DEV=$TEST_DIR/data-image _scratch_xfs_mdrestore $metadump_file + + datadev=$(_create_loop_device $TEST_DIR/data-image) + + SCRATCH_DEV=$datadev _scratch_mount + SCRATCH_DEV=$datadev _check_scratch_fs + SCRATCH_DEV=$datadev _scratch_unmount + + _destroy_loop_device $datadev + datadev="" + rm -f $TEST_DIR/data-image +} + +verify_metadump_v2() +{ + local version="-v 2" + + _scratch_xfs_metadump $metadump_file -a -o $version + + # Metadump v2 files can contain contents dumped from an external log + # device. Use a temporary file to hold the log device contents restored + # from such a metadump file. + slogdev="" + if [[ -n $SCRATCH_LOGDEV ]]; then + slogdev=$TEST_DIR/log-image + fi + + SCRATCH_DEV=$TEST_DIR/data-image SCRATCH_LOGDEV=$slogdev \ + _scratch_xfs_mdrestore $metadump_file + + datadev=$(_create_loop_device $TEST_DIR/data-image) + + logdev=${SCRATCH_LOGDEV} + if [[ -s $TEST_DIR/log-image ]]; then + logdev=$(_create_loop_device $TEST_DIR/log-image) + fi + + SCRATCH_DEV=$datadev SCRATCH_LOGDEV=$logdev _scratch_mount + SCRATCH_DEV=$datadev SCRATCH_LOGDEV=$logdev _check_scratch_fs + SCRATCH_DEV=$datadev SCRATCH_LOGDEV=$logdev _scratch_unmount + + if [[ -s $TEST_DIR/log-image ]]; then + _destroy_loop_device $logdev + logdev="" + rm -f $TEST_DIR/log-image + fi + + _destroy_loop_device $datadev + datadev="" + rm -f $TEST_DIR/data-image +} + +echo "Initialize and mount filesystem on flakey device" +_init_flakey +_load_flakey_table $FLAKEY_ALLOW_WRITES +_mount_flakey + +echo "Create test file" +$XFS_IO_PROG -s -f -c "pwrite 0 5M" $testfile >> $seqres.full + +echo "Punch alternative blocks of test file" +$here/src/punch-alternating $testfile + +echo "Mount cycle the filesystem on flakey device" +_unmount_flakey +_mount_flakey + +device=$(readlink -f $FLAKEY_DEV) +device=$(_short_dev $device) + +echo "Pin log items in the AIL" +echo 1 > /sys/fs/xfs/${device}/errortag/log_item_pin + +echo "Create two checkpoint transactions on ondisk log" +for ct in $(seq 1 2); do + offset=$($XFS_IO_PROG -c 'fiemap' $testfile | tac | grep -v hole | \ + head -n 1 | awk -F '[\\[.]' '{ print $2 * 512; }') + $XFS_IO_PROG -c "truncate $offset" -c fsync $testfile +done + +echo "Drop writes to filesystem from here onwards" +_load_flakey_table $FLAKEY_DROP_WRITES + +echo "Unpin log items in AIL" +echo 0 > /sys/fs/xfs/${device}/errortag/log_item_pin + +echo "Unmount filesystem on flakey device" +_unmount_flakey + +echo "Clean up flakey device" +_cleanup_flakey + +echo -n "Filesystem has a " +_print_logstate + +echo "Create metadump file, restore it and check restored fs" + +if [[ $external_log == 0 ]]; then + verify_metadump_v1 $max_md_version +fi + +if [[ $max_md_version == 2 ]]; then + verify_metadump_v2 +fi + +# Mount the fs to replay the contents from the dirty log. +_scratch_mount + +# success, all done +status=0 +exit diff --git a/tests/xfs/801.out b/tests/xfs/801.out new file mode 100644 index 00000000..a2f2abca --- /dev/null +++ b/tests/xfs/801.out @@ -0,0 +1,14 @@ +QA output created by 801 +Format filesystem on scratch device +Initialize and mount filesystem on flakey device +Create test file +Punch alternative blocks of test file +Mount cycle the filesystem on flakey device +Pin log items in the AIL +Create two checkpoint transactions on ondisk log +Drop writes to filesystem from here onwards +Unpin log items in AIL +Unmount filesystem on flakey device +Clean up flakey device +Filesystem has a dirty log +Create metadump file, restore it and check restored fs