diff mbox series

[v2] btrfs: add fstrim test case on the sprout device

Message ID 7ff015576992de7e8d6ff554c27c420a9ffa1595.1619800208.git.anand.jain@oracle.com (mailing list archive)
State New, archived
Headers show
Series [v2] btrfs: add fstrim test case on the sprout device | expand

Commit Message

Anand Jain May 1, 2021, 5:17 a.m. UTC
Add fstrim test case on the sprout device, verify seed device
integrity.

 btrfs: fix unmountable seed device after fstrim

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
v2:
  Add _require_fstrim and _require_batched_discard.
  Use FSTRIM_PROG.
  Use _filter_ro_mount to handle the difference in output in different
     mount(8) version.
  Call _scratch_dev_pool_put.
  Add _check_btrfs_filesystem $seed to check the whole seed fs.
  Update in-code comments.

 tests/btrfs/236     | 81 +++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/236.out |  5 +++
 tests/btrfs/group   |  1 +
 3 files changed, 87 insertions(+)
 create mode 100755 tests/btrfs/236
 create mode 100644 tests/btrfs/236.out

Comments

Filipe Manana May 3, 2021, 9:54 a.m. UTC | #1
On Sat, May 1, 2021 at 6:24 AM Anand Jain <anand.jain@oracle.com> wrote:
>
> Add fstrim test case on the sprout device, verify seed device
> integrity.
>
>  btrfs: fix unmountable seed device after fstrim
>
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
> v2:
>   Add _require_fstrim and _require_batched_discard.
>   Use FSTRIM_PROG.
>   Use _filter_ro_mount to handle the difference in output in different
>      mount(8) version.
>   Call _scratch_dev_pool_put.
>   Add _check_btrfs_filesystem $seed to check the whole seed fs.
>   Update in-code comments.
>
>  tests/btrfs/236     | 81 +++++++++++++++++++++++++++++++++++++++++++++
>  tests/btrfs/236.out |  5 +++
>  tests/btrfs/group   |  1 +
>  3 files changed, 87 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..aac27fac06dd
> --- /dev/null
> +++ b/tests/btrfs/236
> @@ -0,0 +1,81 @@
> +#! /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_fstrim
> +_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
> +
> +$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_ro_mount | _filter_scratch
> +md5sum $SCRATCH_MNT/foo | _filter_scratch
> +
> +$BTRFS_UTIL_PROG device add -f $sprout $SCRATCH_MNT
> +_scratch_unmount
> +
> +# Now remount writeable sprout device, create some data and run fstrim
> +_mount $sprout $SCRATCH_MNT
> +_require_batched_discard $SCRATCH_MNT
> +
> +$XFS_IO_PROG -f -c "pwrite -S 0xcd 0 1M" $SCRATCH_MNT/bar > /dev/null

We aren't doing anything with this file ("bar"). Just remove it.

Otherwise it passes now with the filter.

Thanks.

> +
> +$FSTRIM_PROG $SCRATCH_MNT
> +
> +_scratch_unmount
> +
> +# Verify seed device is all ok
> +_mount $seed $SCRATCH_MNT 2>&1 | _filter_ro_mount | _filter_scratch
> +md5sum $SCRATCH_MNT/foo | _filter_scratch
> +_scratch_unmount
> +
> +_check_btrfs_filesystem $seed
> +
> +_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..01699b8fc291
> --- /dev/null
> +++ b/tests/btrfs/236.out
> @@ -0,0 +1,5 @@
> +QA output created by 236
> +mount: device write-protected, mounting read-only
> +096003817ad2638000a6836e55866697  SCRATCH_MNT/foo
> +mount: device write-protected, mounting 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
> --
> 2.27.0
>
Anand Jain May 3, 2021, 10:29 a.m. UTC | #2
On 03/05/2021 17:54, Filipe Manana wrote:
> On Sat, May 1, 2021 at 6:24 AM Anand Jain <anand.jain@oracle.com> wrote:
>>
>> Add fstrim test case on the sprout device, verify seed device
>> integrity.
>>
>>   btrfs: fix unmountable seed device after fstrim
>>
>> Signed-off-by: Anand Jain <anand.jain@oracle.com>
>> ---
>> v2:
>>    Add _require_fstrim and _require_batched_discard.
>>    Use FSTRIM_PROG.
>>    Use _filter_ro_mount to handle the difference in output in different
>>       mount(8) version.
>>    Call _scratch_dev_pool_put.
>>    Add _check_btrfs_filesystem $seed to check the whole seed fs.
>>    Update in-code comments.
>>
>>   tests/btrfs/236     | 81 +++++++++++++++++++++++++++++++++++++++++++++
>>   tests/btrfs/236.out |  5 +++
>>   tests/btrfs/group   |  1 +
>>   3 files changed, 87 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..aac27fac06dd
>> --- /dev/null
>> +++ b/tests/btrfs/236
>> @@ -0,0 +1,81 @@
>> +#! /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_fstrim
>> +_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
>> +
>> +$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_ro_mount | _filter_scratch
>> +md5sum $SCRATCH_MNT/foo | _filter_scratch
>> +
>> +$BTRFS_UTIL_PROG device add -f $sprout $SCRATCH_MNT
>> +_scratch_unmount
>> +
>> +# Now remount writeable sprout device, create some data and run fstrim
>> +_mount $sprout $SCRATCH_MNT
>> +_require_batched_discard $SCRATCH_MNT
>> +
>> +$XFS_IO_PROG -f -c "pwrite -S 0xcd 0 1M" $SCRATCH_MNT/bar > /dev/null
> 
> We aren't doing anything with this file ("bar"). Just remove it.
> 

  Right.  It can go.  I will fix it in v3.
Thanks.


> Otherwise it passes now with the filter.
> 
> Thanks.
> 
>> +
>> +$FSTRIM_PROG $SCRATCH_MNT
>> +
>> +_scratch_unmount
>> +
>> +# Verify seed device is all ok
>> +_mount $seed $SCRATCH_MNT 2>&1 | _filter_ro_mount | _filter_scratch
>> +md5sum $SCRATCH_MNT/foo | _filter_scratch
>> +_scratch_unmount
>> +
>> +_check_btrfs_filesystem $seed
>> +
>> +_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..01699b8fc291
>> --- /dev/null
>> +++ b/tests/btrfs/236.out
>> @@ -0,0 +1,5 @@
>> +QA output created by 236
>> +mount: device write-protected, mounting read-only
>> +096003817ad2638000a6836e55866697  SCRATCH_MNT/foo
>> +mount: device write-protected, mounting 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
>> --
>> 2.27.0
>>
> 
>
diff mbox series

Patch

diff --git a/tests/btrfs/236 b/tests/btrfs/236
new file mode 100755
index 000000000000..aac27fac06dd
--- /dev/null
+++ b/tests/btrfs/236
@@ -0,0 +1,81 @@ 
+#! /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_fstrim
+_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
+
+$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_ro_mount | _filter_scratch
+md5sum $SCRATCH_MNT/foo | _filter_scratch
+
+$BTRFS_UTIL_PROG device add -f $sprout $SCRATCH_MNT
+_scratch_unmount
+
+# Now remount writeable sprout device, create some data and run fstrim
+_mount $sprout $SCRATCH_MNT
+_require_batched_discard $SCRATCH_MNT
+
+$XFS_IO_PROG -f -c "pwrite -S 0xcd 0 1M" $SCRATCH_MNT/bar > /dev/null
+
+$FSTRIM_PROG $SCRATCH_MNT
+
+_scratch_unmount
+
+# Verify seed device is all ok
+_mount $seed $SCRATCH_MNT 2>&1 | _filter_ro_mount | _filter_scratch
+md5sum $SCRATCH_MNT/foo | _filter_scratch
+_scratch_unmount
+
+_check_btrfs_filesystem $seed
+
+_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..01699b8fc291
--- /dev/null
+++ b/tests/btrfs/236.out
@@ -0,0 +1,5 @@ 
+QA output created by 236
+mount: device write-protected, mounting read-only
+096003817ad2638000a6836e55866697  SCRATCH_MNT/foo
+mount: device write-protected, mounting 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