From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org, fstests@vger.kernel.org
Cc: Filipe Manana <fdmanana@suse.com>
Subject: [PATCH v2] fstests: btrfs: add a new test case to verify degraded RMW writes
Date: Fri, 2 Oct 2026 18:51:35 +0930 [thread overview]
Message-ID: <20261002092135.61719-1-wqu@suse.com> (raw)
This is a regression test for a recent reported bug.
The test workload is pretty straightforward:
- Create a 4 disks RAID5 or RAID6 btrfs
- Destroy one disk and mount the btrfs degraded
- Use fio to do a workload meeting all the following conditions
* Triggering a RMW write
This is done by using buffered write with 8 4K writes.
The total write will not fulfill a full stripe, thus it will
always go through RMW.
* Some blocks of the full stripe have csum and some do not
This is done by pre-allocating the target file before testing, so
every full stripe does not have any csum by default.
Then after some writes, there will be checksum for those new writes,
resulting blocks with mixed data checksum.
* Detect RMW failure
This is done through fsync.
For unpatched kernels, the fio will always fail pretty early, meanwhile
patched kernels can finish the full 15 seconds runs on both RAID5 and
RAID6 profiles.
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
Changelog:
v2:
- Use fsync= option for the fio workload
The fdatasync= is no different than fsync= on btrfs.
---
tests/btrfs/357 | 65 +++++++++++++++++++++++++++++++++++++++++++++
tests/btrfs/357.out | 2 ++
2 files changed, 67 insertions(+)
create mode 100755 tests/btrfs/357
create mode 100644 tests/btrfs/357.out
diff --git a/tests/btrfs/357 b/tests/btrfs/357
new file mode 100755
index 00000000..b68d03b5
--- /dev/null
+++ b/tests/btrfs/357
@@ -0,0 +1,65 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2026 SUSE S.A. All Rights Reserved.
+#
+# FS QA Test 357
+#
+# Make sure on degraded RAID5/6, RMW writes won't return false errors
+# when some blocks do not have checksums.
+#
+. ./common/preamble
+
+_begin_fstest auto raid volume
+
+_fixed_by_kernel_commit xxxxxxxxxxxx \
+ "btrfs: raid56: do not verify the content if there is no data checksum"
+
+_require_command "$WIPEFS_PROG" wipefs
+_require_scratch_dev_pool 4
+_scratch_dev_pool_get 4
+
+fio_job_file=$tmp.fio
+cat > $fio_job_file << EOF
+[sync_randwrite]
+directory=$SCRATCH_MNT
+rw=randwrite
+filesize=512M
+bs=4K
+fsync=8
+time_based
+fallocate=posix
+runtime=15
+EOF
+
+_require_fio "$fio_job_file"
+
+# The target to remove for degraded mount.
+dev2="${SCRATCH_DEV_NAME[1]}"
+
+workload()
+{
+ local profile=$1
+ _scratch_pool_mkfs "-m raid1 -d $profile" >> $seqres.full 2>&1
+ $WIPEFS_PROG -fa "$dev2" >> $seqres.full 2>&1
+ _scratch_mount -o degraded
+
+ # The fio job will do fsync after 8 4K writes, which is not enough to
+ # fill a full stripe and always trigger RMW.
+ # And the target file is preallocated, after some writes a full stripe
+ # can have blocks with csum and some blocks without csum.
+ #
+ # Unpatched kernels will try to verify the checksum even if there is no
+ # csum and fail the RMW, causing fio to fail.
+ $FIO_PROG $fio_job_file >> $seqres.full 2>&1
+ if [ $? -ne 0 ]; then
+ echo "fio failed on degraded $profile"
+ fi
+ _scratch_unmount
+}
+
+workload raid5
+workload raid6
+
+_scratch_dev_pool_put
+echo "Silence is golden"
+_exit 0
diff --git a/tests/btrfs/357.out b/tests/btrfs/357.out
new file mode 100644
index 00000000..25875c6d
--- /dev/null
+++ b/tests/btrfs/357.out
@@ -0,0 +1,2 @@
+QA output created by 357
+Silence is golden
--
2.51.2
next reply other threads:[~2026-10-02 9:22 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-02 9:21 Qu Wenruo [this message]
2026-10-06 9:52 ` [PATCH v2] fstests: btrfs: add a new test case to verify degraded RMW writes Anand Jain
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=20261002092135.61719-1-wqu@suse.com \
--to=wqu@suse.com \
--cc=fdmanana@suse.com \
--cc=fstests@vger.kernel.org \
--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