From: Qu Wenruo <wqu@suse.com>
To: linux-btrfs@vger.kernel.org, fstests@vger.kernel.org
Subject: [PATCH] generic/050: add a workaround for btrfs
Date: Wed, 2 Jul 2025 14:23:12 +0930 [thread overview]
Message-ID: <20250702045312.59995-1-wqu@suse.com> (raw)
[BUG]
With the incoming btrfs shutdown ioctl/remove_bdev callback support,
btrfs can be tested with the shutdown group.
But test case generic/050 still fails on btrfs with shutdown support:
generic/050 1s ... - output mismatch (see /home/adam/xfstests/results//generic/050.out.bad)
--- tests/generic/050.out 2022-05-11 11:25:30.763333331 +0930
+++ /home/adam/xfstests/results//generic/050.out.bad 2025-06-30 10:22:21.752068622 +0930
@@ -13,9 +13,7 @@
setting device read-only
mounting filesystem that needs recovery on a read-only device:
mount: device write-protected, mounting read-only
-mount: cannot mount device read-only
unmounting read-only filesystem
-umount: SCRATCH_DEV: not mounted
mounting filesystem with -o norecovery on a read-only device:
...
(Run 'diff -u /home/adam/xfstests/tests/generic/050.out /home/adam/xfstests/results//generic/050.out.bad' to see the entire diff)
Ran: generic/050
[CAUSE]
The test case generic/050 has several different golden output depending
on the fs features.
For fses which requires data write (e.g. replay the journal) during
mount, mounting a read-only block device should fail.
And that is the default golden output.
However for btrfs, although it has something similar to a journal, aka
log tree, it's not the traditional journal which is used to protect
metadata update.
The log tree of btrfs is mostly for speeding up fsync() without syncing
the full fs.
This means several things are different with btrfs:
- Regular metadata update won't cause dirty log tree
The workload here is just touching several files, which will not cause
the creation of btrfs log tree.
And the metadata consistency is protected by metadata COW, not
journal.
- FLUSHLOG shutdown flag will cause btrfs to commit the current
transaction
And above new files are recorded in the current transaction, meaning
those new files will be fully written by a FLUSHLOG shutdown.
This means, unlike fses using traditional journals, touching files then
shutdown with FLUSHLOG will not cause any dirty log tree.
This makes btrfs acts like it doesn't support metadata journaling, at
least for this particular test case.
[FIX]
Since the workload here will not cause btrfs to generate a log tree,
meaning after the shutdown, the fs can still be mounted RO even the
block device is read-only.
So here we have to make an exception for btrfs, that it has to go
through the "nojournal" feature.
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
tests/generic/050 | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/tests/generic/050 b/tests/generic/050
index affb072d..3bc37175 100755
--- a/tests/generic/050
+++ b/tests/generic/050
@@ -34,6 +34,18 @@ elif [ "$FSTYP" = "xfs" ] && echo "$MOUNT_OPTIONS" | grep -q quota ; then
# Mounting with quota on XFS requires a writable fs, which means
# we expect to fail the ro blockdev test with with EPERM.
features="xfsquota"
+elif [ "$FSTYP" = "btrfs" ]; then
+ # Btrfs' log tree is not the traditional journal to protect metadata
+ # (that is done by metadata COW), the log tree is to speed up fsync()
+ # without syncing the full fs.
+ #
+ # In this particular test case, the workload (touching files without
+ # fsync, and use FLUSHLOG option to shutdown) will not utilize log tree
+ # at all.
+ #
+ # So for this test case, btrfs will not get any dirty log tree thus
+ # it can be treated as "nojournal".
+ features="nojournal"
fi
_link_out_file "$features"
--
2.50.0
next reply other threads:[~2025-07-02 4:53 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-02 4:53 Qu Wenruo [this message]
2025-07-08 14:47 ` [PATCH] generic/050: add a workaround for btrfs 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=20250702045312.59995-1-wqu@suse.com \
--to=wqu@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