Verify file read from disks assembled with different generations. Signed-off-by: Anand Jain <anand.j...@oracle.com> --- tests/btrfs/184 | 132 ++++++++++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/184.out | 9 ++++ tests/btrfs/group | 1 + 3 files changed, 142 insertions(+) create mode 100755 tests/btrfs/184 create mode 100644 tests/btrfs/184.out
diff --git a/tests/btrfs/184 b/tests/btrfs/184 new file mode 100755 index 000000000000..1791fdb079b7 --- /dev/null +++ b/tests/btrfs/184 @@ -0,0 +1,132 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (c) 2019 YOUR NAME HERE. All Rights Reserved. +# +# FS QA Test 184 +# +# Test read on raid1 assembled with disks of different generations. +# Steps: +# . Use btrfs snapshot on the test_dir to create disk images of +# different generations (lets say generation a and generation b). +# . Mount one disk from generation a and another disk from generation +# b, and verify the file md5sum. +# Note: readmirror feature (in the btrfs ml) helps to reproduce the +# problem consistently. +# Fix-by: kernel patch +# [PATCH] btrfs: fix read corrpution on disks of different generation + + +seq=`basename $0` +seqres=$RESULT_DIR/$seq +echo "QA output created by $seq" + +here=`pwd` +tmp=/tmp/$$ +status=1 # failure is the default! +trap "_cleanup; exit \$status" 0 1 2 3 15 + +_cleanup() +{ + cd / + rm -f $tmp.* + _scratch_unmount > /dev/null 2>&1 + _destroy_loop_device $dev1 + _destroy_loop_device $dev2 + btrfs subvolume delete $img_subvol > /dev/null 2>&1 + btrfs subvolume delete $img_subvol_at_gen_a > /dev/null 2>&1 + [[ -z $scratch_dev_pool_saved ]] || \ + SCRATCH_DEV_POOL="$scratch_dev_pool_saved" + _scratch_dev_pool_put +} + +# get standard environment, filters and checks +. ./common/rc +. ./common/filter + +# remove previous $seqres.full before test +rm -f $seqres.full + +# real QA test starts here + +# Modify as appropriate. +_supported_fs generic +_supported_os Linux +_require_test +_require_scratch_dev_pool 2 + +_test_unmount +_require_btrfs_forget_if_not_fs_loadable +_test_mount + +_scratch_dev_pool_get 2 +scratch_dev_pool_saved="" + +img_subvol=$TEST_DIR/img_subvol +img_subvol_at_gen_a=$TEST_DIR/img_subvol_at_gen_a +dev1_img=$img_subvol/d1 +dev2_img=$img_subvol/d2 +dev1_img_at_gen_a=$img_subvol_at_gen_a/d1 +dev2_img_at_gen_a=$img_subvol_at_gen_a/d2 + +$BTRFS_UTIL_PROG subvolume create $img_subvol >> /dev/null 2>&1 || \ + _fail "subvol create failed" + +$XFS_IO_PROG -f -c "pwrite -S 0xdd 0 256m" $dev1_img >> /dev/null 2>&1 +$XFS_IO_PROG -f -c "pwrite -S 0xdd 0 256m" $dev2_img >> /dev/null 2>&1 + +dev1=$(_create_loop_device $dev1_img) +dev2=$(_create_loop_device $dev2_img) + +scratch_dev_pool_saved="$SCRATCH_DEV_POOL" +SCRATCH_DEV_POOL="$dev1 $dev2" +_scratch_pool_mkfs -d raid1 -m raid1 >> $seqres.full 2>&1 || \ + _fail "mkfs failed on $SCRATCH_DEV_POOL" + + +_mount "-o max_inline=0,nodatacow,device=$dev1" $dev2 $SCRATCH_MNT || \ + _fail "mount for gen a failed" + +$XFS_IO_PROG -f -c "pwrite -S 0xaa 0 4K" $SCRATCH_MNT/foobar >> /dev/null 2>&1 + +echo md5sum at generation aa +md5sum $SCRATCH_MNT/foobar | _filter_scratch +echo +_scratch_unmount + +$BTRFS_UTIL_PROG subvolume snapshot $img_subvol $img_subvol_at_gen_a \ + >> /dev/null 2>&1 || _fail "subvol create failed" + +_mount "-o max_inline=0,nodatacow,device=$dev1" $dev2 $SCRATCH_MNT || \ + _fail "mount for gen b failed" + +$XFS_IO_PROG -f -c "pwrite -S 0xbb 0 4K" $SCRATCH_MNT/foobar >> /dev/null 2>&1 + +echo md5sum at generation bb +md5sum $SCRATCH_MNT/foobar | _filter_scratch +echo + +_scratch_unmount + +_destroy_loop_device $dev1 +_destroy_loop_device $dev2 + +_test_unmount +_btrfs_forget_if_not_fs_reload +_test_mount + +dev1=$(_create_loop_device $dev1_img_at_gen_a) +dev2=$(_create_loop_device $dev2_img) + +# mount with readmirror option, if it fails try without but the +# problem may or may not be reproduced without the readmirror option. +_mount "-o ro,device=$dev1,readmirror=devid$dev1_devid" $dev2 $SCRATCH_MNT > \ + /dev/null 2>&1 +[[ $? != 0 ]] && (echo "readmirror option notfound" >> $seqres.full; + _mount "-o ro,device=$dev1" $dev2 $SCRATCH_MNT || \ + _fail "mount at gen ab failed";) +echo md5sum at generation ab +md5sum $SCRATCH_MNT/foobar | _filter_scratch + +# success, all done +status=0 +exit diff --git a/tests/btrfs/184.out b/tests/btrfs/184.out new file mode 100644 index 000000000000..cc71898920ec --- /dev/null +++ b/tests/btrfs/184.out @@ -0,0 +1,9 @@ +QA output created by 184 +md5sum at generation aa +3e4309c7cc81f23d45e260a8f13ca860 SCRATCH_MNT/foobar + +md5sum at generation bb +055a2a7342c0528969e1b6e32aadeee3 SCRATCH_MNT/foobar + +md5sum at generation ab +055a2a7342c0528969e1b6e32aadeee3 SCRATCH_MNT/foobar diff --git a/tests/btrfs/group b/tests/btrfs/group index f3227c1708d9..a4f8fe1eb5ce 100644 --- a/tests/btrfs/group +++ b/tests/btrfs/group @@ -186,3 +186,4 @@ 181 auto quick balance 182 auto quick balance 183 auto quick clone compress punch +184 other -- 1.8.3.1