From 9615d021e95eaafb3762289a69aa7245cff7dc7d Mon Sep 17 00:00:00 2001 From: Qu Wenruo Date: Wed, 2 Jul 2025 14:23:12 +0930 Subject: [PATCH] generic/050: add a workaround for btrfs [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 Reviewed-by: Anand Jain Signed-off-by: Zorro Lang --- 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.39.5