[PATCH 2/2] fstests: btrfs/349: test if latest tree-log is choosen at mount time on raid1 profile
Zhang Boyang <[email protected]>
| Newsgroups | org.kernel.vger.linux-btrfs |
|---|---|
| Message-ID | <[email protected]> |
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 <[email protected]> --- 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