From: Zhang Boyang <zhangboyang.id@gmail.com>
To: linux-btrfs@vger.kernel.org
Cc: David Sterba <dsterba@suse.com>, Qu Wenruo <wqu@suse.com>,
Filipe Manana <fdmanana@kernel.org>,
Zhang Boyang <zhangboyang.id@gmail.com>
Subject: [PATCH 2/2] fstests: btrfs/349: test if latest tree-log is choosen at mount time on raid1 profile
Date: Wed, 15 Jul 2026 00:10:44 +0800 [thread overview]
Message-ID: <20260714161044.7330-3-zhangboyang.id@gmail.com> (raw)
In-Reply-To: <20260714161044.7330-1-zhangboyang.id@gmail.com>
This test simulate a scenario that tree-log only exists in secondary
device, and test if latest tree-log is choosen at mount time.
Currently, the tree-log in the device with lowest devid is choosen. So
fsync'ed data may loss if tree-log only exists in secondary device.
Signed-off-by: Zhang Boyang <zhangboyang.id@gmail.com>
---
tests/btrfs/349 | 53 +++++++++++++++++++++++++++++++++++++++++++++
tests/btrfs/349.out | 14 ++++++++++++
2 files changed, 67 insertions(+)
create mode 100755 tests/btrfs/349
create mode 100644 tests/btrfs/349.out
diff --git a/tests/btrfs/349 b/tests/btrfs/349
new file mode 100755
index 00000000..40e966c6
--- /dev/null
+++ b/tests/btrfs/349
@@ -0,0 +1,53 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2026 Zhang Boyang. All Rights Reserved.
+#
+# FS QA Test 349
+#
+# Test if latest tree-log is choosen at mount time on raid1 profile.
+#
+. ./common/preamble
+_begin_fstest auto quick read_repair raid
+
+. ./common/filter
+. ./common/fail_make_request
+
+_require_fail_make_request
+_require_scratch_dev_pool 2
+
+_scratch_dev_pool_get 2
+_check_minimal_fs_size $(( 1024 * 1024 * 1024 ))
+# a strong checksum like sha256 can't protect you
+_scratch_pool_mkfs "-m raid1 -d raid1 -b 1G --csum sha256" >> $seqres.full 2>&1
+dev2=`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $2}'`
+_allow_fail_make_request
+
+echo "Step 1: prepare filesystem"
+_scratch_mount -o treelog
+$XFS_IO_PROG -f -c "pwrite -W -S 0xaa 0 8" $SCRATCH_MNT/foobar | _filter_xfs_io
+_scratch_unmount
+
+echo "Step 2: simulate failure"
+_scratch_mount -o treelog
+# simulate dev1 disappears before writing anything
+_bdev_fail_make_request $SCRATCH_DEV 1
+# this write should success
+$XFS_IO_PROG -f -c "pwrite -W -S 0xbb 0 8" $SCRATCH_MNT/foobar | _filter_xfs_io
+# simulate dev2 disappears after writing TREE_LOG
+_bdev_fail_make_request $dev2 1
+_scratch_unmount
+_bdev_fail_make_request $SCRATCH_DEV 0
+_bdev_fail_make_request $dev2 0
+
+echo "Step 3: simulate recovery"
+# this mount should start tree-log replay
+_scratch_mount -o treelog
+echo "Step 4: verify written data"
+# read data should be 0xbb
+$XFS_IO_PROG -c "pread -v 0 8" $SCRATCH_MNT/foobar | _filter_xfs_io_offset
+_scratch_unmount
+
+_disallow_fail_make_request
+_scratch_dev_pool_put
+# success, all done
+_exit 0
diff --git a/tests/btrfs/349.out b/tests/btrfs/349.out
new file mode 100644
index 00000000..1ebf4dc9
--- /dev/null
+++ b/tests/btrfs/349.out
@@ -0,0 +1,14 @@
+QA output created by 349
+Allow global fail_make_request feature
+Step 1: prepare filesystem
+wrote 8/8 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+Step 2: simulate failure
+wrote 8/8 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+Step 3: simulate recovery
+Step 4: verify written data
+XXXXXXXX: bb bb bb bb bb bb bb bb ........
+read 8/8 bytes
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+Disallow global fail_make_request feature
--
2.53.0
next prev parent reply other threads:[~2026-07-14 16:11 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-14 16:10 [BUG] two raid consistency bugs Zhang Boyang
2026-07-14 16:10 ` [PATCH 1/2] fstests: btrfs/348: test ambiguous generation handling on raid1 profile Zhang Boyang
2026-07-14 16:10 ` Zhang Boyang [this message]
2026-07-14 21:40 ` [BUG] two raid consistency bugs Qu Wenruo
2026-07-15 5:46 ` Zhang Boyang
2026-07-15 6:10 ` Qu Wenruo
2026-07-15 7:38 ` Zhang Boyang
2026-07-15 8:36 ` Qu Wenruo
2026-07-15 9:25 ` Zhang Boyang
2026-07-15 9:44 ` Qu Wenruo
2026-07-15 10:07 ` Zhang Boyang
2026-07-15 10:11 ` Qu Wenruo
2026-07-15 10:41 ` Zhang Boyang
2026-07-15 13:11 ` Alan Huang
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=20260714161044.7330-3-zhangboyang.id@gmail.com \
--to=zhangboyang.id@gmail.com \
--cc=dsterba@suse.com \
--cc=fdmanana@kernel.org \
--cc=linux-btrfs@vger.kernel.org \
--cc=wqu@suse.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox