On Fri, Apr 30, 2021 at 3:40 PM Anand Jain <anand.jain@xxxxxxxxxx> wrote: > > Add fstrim test case on the sprout device, verify seed device > integrity. > > Needs kernel patch [1] to pass the test case. > [1] > btrfs: fix unmountable seed device after fstrim > > Signed-off-by: Anand Jain <anand.jain@xxxxxxxxxx> > --- > tests/btrfs/236 | 72 +++++++++++++++++++++++++++++++++++++++++++++ > tests/btrfs/236.out | 5 ++++ > tests/btrfs/group | 1 + > 3 files changed, 78 insertions(+) > create mode 100755 tests/btrfs/236 > create mode 100644 tests/btrfs/236.out > > diff --git a/tests/btrfs/236 b/tests/btrfs/236 > new file mode 100755 > index 000000000000..599892bebf10 > --- /dev/null > +++ b/tests/btrfs/236 > @@ -0,0 +1,72 @@ > +#! /bin/bash > +# SPDX-License-Identifier: GPL-2.0 > +# Copyright (c) 2021 Oracle. All Rights Reserved. > +# > +# FS QA Test 236 > +# > +# Check seed device integrity after fstrim on the sprout device. > +# > +# Kernel bug is fixed by the commit: > +# btrfs: fix unmountable seed device after fstrim > + > +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.* > +} > + > +# 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 btrfs > +_require_command "$BTRFS_TUNE_PROG" btrfstune > +_require_scratch_dev_pool 2 > +_scratch_dev_pool_get 2 > + > +seed=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $1}') > +sprout=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $2}') > + > +_mkfs_dev $seed > +_mount $seed $SCRATCH_MNT Missing the check for discard/trim support: _require_batched_discard $SCRATCH_MNT > + > +$XFS_IO_PROG -f -c "pwrite -S 0xab 0 1M" $SCRATCH_MNT/foo > /dev/null > +_scratch_unmount > +$BTRFS_TUNE_PROG -S 1 $seed > + > +# Mount the seed device and add the rw device > +_mount $seed $SCRATCH_MNT 2>&1 | _filter_scratch > +md5sum $SCRATCH_MNT/foo | _filter_scratch > + > +$BTRFS_UTIL_PROG device add -f $sprout $SCRATCH_MNT > +_scratch_unmount > + > +# Now remount > +_mount $sprout $SCRATCH_MNT > +$XFS_IO_PROG -f -c "pwrite -S 0xcd 0 1M" $SCRATCH_MNT/bar > /dev/null > + > +fstrim $SCRATCH_MNT Should use $FSTRIM_PROG instead of fstrim. > + > +_scratch_unmount > +_mount $seed $SCRATCH_MNT 2>&1 | _filter_scratch > +md5sum $SCRATCH_MNT/foo | _filter_scratch > +_scratch_unmount Missing a call to _scratch_dev_pool_put > + > +# success, all done > +status=0 > +exit > diff --git a/tests/btrfs/236.out b/tests/btrfs/236.out > new file mode 100644 > index 000000000000..2929d39395a8 > --- /dev/null > +++ b/tests/btrfs/236.out > @@ -0,0 +1,5 @@ > +QA output created by 236 > +mount: SCRATCH_MNT: WARNING: device write-protected, mounted read-only. > +096003817ad2638000a6836e55866697 SCRATCH_MNT/foo > +mount: SCRATCH_MNT: WARNING: device write-protected, mounted read-only. > +096003817ad2638000a6836e55866697 SCRATCH_MNT/foo > diff --git a/tests/btrfs/group b/tests/btrfs/group > index 331dd432fac3..5032259244e0 100644 > --- a/tests/btrfs/group > +++ b/tests/btrfs/group > @@ -238,3 +238,4 @@ > 233 auto quick subvolume > 234 auto quick compress rw > 235 auto quick send > +236 auto quick seed trim Ok, it fails as expected without the btrfs fix. But with the fix applied, it fails differently for me. It looks like different mount versions output different strings maybe: root 16:18:40 /home/fdmanana/git/hub/xfstests (master)> ./check btrfs/237 FSTYP -- btrfs PLATFORM -- Linux/x86_64 debian8 5.12.0-rc8-btrfs-next-86 #1 SMP PREEMPT Fri Apr 23 17:35:49 WEST 2021 MKFS_OPTIONS -- /dev/sdc MOUNT_OPTIONS -- /dev/sdc /home/fdmanana/btrfs-tests/scratch_1 btrfs/237 - output mismatch (see /home/fdmanana/git/hub/xfstests/results//btrfs/237.out.bad) --- tests/btrfs/237.out 2021-04-30 16:09:33.103380077 +0100 +++ /home/fdmanana/git/hub/xfstests/results//btrfs/237.out.bad 2021-04-30 16:19:31.577988213 +0100 @@ -1,5 +1,5 @@ QA output created by 237 -mount: SCRATCH_MNT: WARNING: device write-protected, mounted read-only. +mount: SCRATCH_MNT: WARNING: source write-protected, mounted read-only. 096003817ad2638000a6836e55866697 SCRATCH_MNT/foo -mount: SCRATCH_MNT: WARNING: device write-protected, mounted read-only. +mount: SCRATCH_MNT: WARNING: source write-protected, mounted read-only. 096003817ad2638000a6836e55866697 SCRATCH_MNT/foo ... (Run 'diff -u /home/fdmanana/git/hub/xfstests/tests/btrfs/237.out /home/fdmanana/git/hub/xfstests/results//btrfs/237.out.bad' to see the entire diff) Ran: btrfs/237 Failures: btrfs/237 Failed 1 of 1 tests root 16:19:31 /home/fdmanana/git/hub/xfstests (master)> diff -u /home/fdmanana/git/hub/xfstests/tests/btrfs/237.out /home/fdmanana/git/hub/xfstests/results//btrfs/237.out.bad --- /home/fdmanana/git/hub/xfstests/tests/btrfs/237.out 2021-04-30 16:09:33.103380077 +0100 +++ /home/fdmanana/git/hub/xfstests/results//btrfs/237.out.bad 2021-04-30 16:19:31.577988213 +0100 @@ -1,5 +1,5 @@ QA output created by 237 -mount: SCRATCH_MNT: WARNING: device write-protected, mounted read-only. +mount: SCRATCH_MNT: WARNING: source write-protected, mounted read-only. 096003817ad2638000a6836e55866697 SCRATCH_MNT/foo -mount: SCRATCH_MNT: WARNING: device write-protected, mounted read-only. +mount: SCRATCH_MNT: WARNING: source write-protected, mounted read-only. 096003817ad2638000a6836e55866697 SCRATCH_MNT/foo root 16:20:06 /home/fdmanana/git/hub/xfstests (master)> Thanks. > -- > 2.27.0 > -- Filipe David Manana, “Whether you think you can, or you think you can't — you're right.”