From: Anand Jain <anand.jain@oracle.com>
To: linux-btrfs@vger.kernel.org
Cc: dsterba@suse.com
Subject: [PATCH 4/4] btrfs-progs: test btrfstune -m|M ability to fix previous failures
Date: Fri, 15 Sep 2023 12:08:59 +0800 [thread overview]
Message-ID: <db8c6de3dfda46d9e3c0dbebc7f10a898f8be112.1694749532.git.anand.jain@oracle.com> (raw)
In-Reply-To: <cover.1694749532.git.anand.jain@oracle.com>
The misc-test/034-metadata_uuid test case, has four sets of disk images to
simulate failed writes during btrfstune -m|M operations. As of now, this
tests kernel only. Update the test case to verify btrfstune -m|M's
capacity to recover from the same scenarios.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
tests/misc-tests/034-metadata-uuid/test.sh | 70 ++++++++++++++++------
1 file changed, 53 insertions(+), 17 deletions(-)
diff --git a/tests/misc-tests/034-metadata-uuid/test.sh b/tests/misc-tests/034-metadata-uuid/test.sh
index 479c7da7a5b2..0b06f1266f57 100755
--- a/tests/misc-tests/034-metadata-uuid/test.sh
+++ b/tests/misc-tests/034-metadata-uuid/test.sh
@@ -195,13 +195,42 @@ check_multi_fsid_unchanged() {
check_flag_cleared "$1" "$2"
}
-failure_recovery() {
+failure_recovery_progs() {
+ local image1
+ local image2
+ local loop1
+ local loop2
+ local devcount
+
+ image1=$(extract_image "$1")
+ image2=$(extract_image "$2")
+ loop1=$(run_check_stdout $SUDO_HELPER losetup --find --show "$image1")
+ loop2=$(run_check_stdout $SUDO_HELPER losetup --find --show "$image2")
+
+ run_check $SUDO_HELPER udevadm settle
+
+ # Scan to make sure btrfs detects both devices before trying to mount
+ #run_check "$TOP/btrfstune" -m --noscan --device="$loop1" "$loop2"
+ run_check "$TOP/btrfstune" -m "$loop2"
+
+ # perform any specific check
+ "$3" "$loop1" "$loop2"
+
+ # cleanup
+ run_check $SUDO_HELPER losetup -d "$loop1"
+ run_check $SUDO_HELPER losetup -d "$loop2"
+ rm -f -- "$image1" "$image2"
+}
+
+failure_recovery_kernel() {
local image1
local image2
local loop1
local loop2
local devcount
+ reload_btrfs
+
image1=$(extract_image "$1")
image2=$(extract_image "$2")
loop1=$(run_check_stdout $SUDO_HELPER losetup --find --show "$image1")
@@ -226,47 +255,55 @@ failure_recovery() {
rm -f -- "$image1" "$image2"
}
+failure_recovery() {
+ failure_recovery_progs $@
+ failure_recovery_kernel $@
+}
+
reload_btrfs() {
run_check $SUDO_HELPER rmmod btrfs
run_check $SUDO_HELPER modprobe btrfs
}
-# for full coverage we need btrfs to actually be a module
-modinfo btrfs > /dev/null 2>&1 || _not_run "btrfs must be a module"
-run_mayfail $SUDO_HELPER modprobe -r btrfs || _not_run "btrfs must be unloadable"
-run_mayfail $SUDO_HELPER modprobe btrfs || _not_run "loading btrfs module failed"
+test_progs() {
+ run_check_mkfs_test_dev
+ check_btrfstune
+
+ run_check_mkfs_test_dev
+ check_dump_super_output
-run_check_mkfs_test_dev
-check_btrfstune
+ run_check_mkfs_test_dev
+ check_image_restore
+}
+
+check_kernel_reloadable() {
+ # for full coverage we need btrfs to actually be a module
+ modinfo btrfs > /dev/null 2>&1 || _not_run "btrfs must be a module"
+ run_mayfail $SUDO_HELPER modprobe -r btrfs || _not_run "btrfs must be unloadable"
+ run_mayfail $SUDO_HELPER modprobe btrfs || _not_run "loading btrfs module failed"
+}
-run_check_mkfs_test_dev
-check_dump_super_output
+check_kernel_reloadable
-run_check_mkfs_test_dev
-check_image_restore
+test_progs
# disk1 is an image which has no metadata uuid flags set and disk2 is part of
# the same fs but has the in-progress flag set. Test that whicever is scanned
# first will result in consistent filesystem.
failure_recovery "./disk1.raw.xz" "./disk2.raw.xz" check_inprogress_flag
-reload_btrfs
failure_recovery "./disk2.raw.xz" "./disk1.raw.xz" check_inprogress_flag
# disk4 contains an image in with the in-progress flag set and disk 3 is part
# of the same filesystem but has both METADATA_UUID incompat and a new
# metadata uuid set. So disk 3 must always take precedence
-reload_btrfs
failure_recovery "./disk3.raw.xz" "./disk4.raw.xz" check_completed
-reload_btrfs
failure_recovery "./disk4.raw.xz" "./disk3.raw.xz" check_completed
# disk5 contains an image which has undergone a successful fsid change more
# than once, disk6 on the other hand is member of the same filesystem but
# hasn't completed its last change. Thus it has both the FSID_CHANGING flag set
# and METADATA_UUID flag set.
-reload_btrfs
failure_recovery "./disk5.raw.xz" "./disk6.raw.xz" check_multi_fsid_change
-reload_btrfs
failure_recovery "./disk6.raw.xz" "./disk5.raw.xz" check_multi_fsid_change
# disk7 contains an image which has undergone a successful fsid change once to
@@ -275,5 +312,4 @@ failure_recovery "./disk6.raw.xz" "./disk5.raw.xz" check_multi_fsid_change
# during the process change. So disk 7 looks as if it never underwent fsid change
# and disk 8 has FSID_CHANGING_FLAG and METADATA_UUID but is stale.
failure_recovery "./disk7.raw.xz" "./disk8.raw.xz" check_multi_fsid_unchanged
-reload_btrfs
failure_recovery "./disk8.raw.xz" "./disk7.raw.xz" check_multi_fsid_unchanged
--
2.38.1
next prev parent reply other threads:[~2023-09-15 4:14 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-15 4:08 [PATCH 0/4 v4] btrfs-progs: recover from failed metadata_uuid port kernel Anand Jain
2023-09-15 4:08 ` [PATCH 1/4] btrfs-progs: tune use the latest bdev in fs_devices for super_copy Anand Jain
2023-09-15 4:08 ` [PATCH 2/4] btrfs-progs: add support to fix superblock with CHANGING_FSID_V2 flag Anand Jain
2023-09-15 4:08 ` [PATCH 3/4] btrfs-progs: recover from the failed btrfstune -m|M Anand Jain
2023-09-15 4:08 ` Anand Jain [this message]
2023-10-02 17:16 ` [PATCH 4/4] btrfs-progs: test btrfstune -m|M ability to fix previous failures David Sterba
2023-10-02 17:19 ` David Sterba
2023-10-03 8:00 ` Anand Jain
2023-10-03 8:38 ` Anand Jain
2023-10-03 17:36 ` David Sterba
2023-10-02 17:00 ` [PATCH 0/4 v4] btrfs-progs: recover from failed metadata_uuid port kernel David Sterba
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=db8c6de3dfda46d9e3c0dbebc7f10a898f8be112.1694749532.git.anand.jain@oracle.com \
--to=anand.jain@oracle.com \
--cc=dsterba@suse.com \
--cc=linux-btrfs@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).