* [PATCH] btrfs/242: test case to fstrim on a degraded filesystem
@ 2021-07-04 11:20 Anand Jain
2021-07-05 0:17 ` Qu Wenruo
` (4 more replies)
0 siblings, 5 replies; 10+ messages in thread
From: Anand Jain @ 2021-07-04 11:20 UTC (permalink / raw)
To: fstests; +Cc: linux-btrfs
Create a degraded btrfs filesystem and run fstrim on it.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
tests/btrfs/242 | 49 +++++++++++++++++++++++++++++++++++++++++++++
tests/btrfs/242.out | 2 ++
2 files changed, 51 insertions(+)
create mode 100755 tests/btrfs/242
create mode 100644 tests/btrfs/242.out
diff --git a/tests/btrfs/242 b/tests/btrfs/242
new file mode 100755
index 000000000000..e946ee6ac7c2
--- /dev/null
+++ b/tests/btrfs/242
@@ -0,0 +1,49 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2021 Oracle. All Rights Reserved.
+#
+# FS QA Test 242
+#
+# Test that fstrim can run on the degraded filesystem
+# Kernel requires fix for the null pointer deref in btrfs_trim_fs()
+# [patch] btrfs: check for missing device in btrfs_trim_fs
+
+
+. ./common/preamble
+_begin_fstest auto quick replace trim
+
+# Import common functions.
+. ./common/filter
+
+# real QA test starts here
+_supported_fs btrfs
+_require_btrfs_forget_or_module_loadable
+_require_scratch_dev_pool 2
+#_require_command "$WIPEFS_PROG" wipefs
+
+_scratch_dev_pool_get 2
+dev1=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{ print $1 }')
+
+_scratch_pool_mkfs "-m raid1 -d raid1"
+_scratch_mount
+_require_batched_discard $SCRATCH_MNT
+
+# Add a test file with some data.
+$XFS_IO_PROG -f -c "pwrite -S 0xab 0 10M" $SCRATCH_MNT/foo > /dev/null
+
+# Unmount the filesystem.
+_scratch_unmount
+
+# Mount the filesystem in degraded mode
+_btrfs_forget_or_module_reload
+_mount -o degraded $dev1 $SCRATCH_MNT
+
+# Run fstrim
+$FSTRIM_PROG $SCRATCH_MNT
+
+_scratch_dev_pool_put
+
+echo Silence is golden
+
+status=0
+exit
diff --git a/tests/btrfs/242.out b/tests/btrfs/242.out
new file mode 100644
index 000000000000..a46d77702f23
--- /dev/null
+++ b/tests/btrfs/242.out
@@ -0,0 +1,2 @@
+QA output created by 242
+Silence is golden
--
2.27.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] btrfs/242: test case to fstrim on a degraded filesystem
2021-07-04 11:20 [PATCH] btrfs/242: test case to fstrim on a degraded filesystem Anand Jain
@ 2021-07-05 0:17 ` Qu Wenruo
2021-07-05 3:41 ` [PATCH v2] " Anand Jain
` (3 subsequent siblings)
4 siblings, 0 replies; 10+ messages in thread
From: Qu Wenruo @ 2021-07-05 0:17 UTC (permalink / raw)
To: Anand Jain, fstests; +Cc: linux-btrfs
On 2021/7/4 下午7:20, Anand Jain wrote:
> Create a degraded btrfs filesystem and run fstrim on it.
>
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
> tests/btrfs/242 | 49 +++++++++++++++++++++++++++++++++++++++++++++
> tests/btrfs/242.out | 2 ++
> 2 files changed, 51 insertions(+)
> create mode 100755 tests/btrfs/242
> create mode 100644 tests/btrfs/242.out
>
> diff --git a/tests/btrfs/242 b/tests/btrfs/242
> new file mode 100755
> index 000000000000..e946ee6ac7c2
> --- /dev/null
> +++ b/tests/btrfs/242
> @@ -0,0 +1,49 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (C) 2021 Oracle. All Rights Reserved.
> +#
> +# FS QA Test 242
> +#
> +# Test that fstrim can run on the degraded filesystem
> +# Kernel requires fix for the null pointer deref in btrfs_trim_fs()
> +# [patch] btrfs: check for missing device in btrfs_trim_fs
> +
> +
> +. ./common/preamble
> +_begin_fstest auto quick replace trim
> +
> +# Import common functions.
> +. ./common/filter
> +
> +# real QA test starts here
> +_supported_fs btrfs
> +_require_btrfs_forget_or_module_loadable
Since you have wipefs requirement commented out, I guess you're also
unsure which is the better way.
Personally speaking, I think wipefs is better.
As it's more generic and needs no kernel support.
Despite that it looks good to me.
Thanks,
Qu
> +_require_scratch_dev_pool 2
> +#_require_command "$WIPEFS_PROG" wipefs
> +
> +_scratch_dev_pool_get 2
> +dev1=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{ print $1 }')
> +
> +_scratch_pool_mkfs "-m raid1 -d raid1"
> +_scratch_mount
> +_require_batched_discard $SCRATCH_MNT
> +
> +# Add a test file with some data.
> +$XFS_IO_PROG -f -c "pwrite -S 0xab 0 10M" $SCRATCH_MNT/foo > /dev/null
> +
> +# Unmount the filesystem.
> +_scratch_unmount
> +
> +# Mount the filesystem in degraded mode
> +_btrfs_forget_or_module_reload
> +_mount -o degraded $dev1 $SCRATCH_MNT
> +
> +# Run fstrim
> +$FSTRIM_PROG $SCRATCH_MNT
> +
> +_scratch_dev_pool_put
> +
> +echo Silence is golden
> +
> +status=0
> +exit
> diff --git a/tests/btrfs/242.out b/tests/btrfs/242.out
> new file mode 100644
> index 000000000000..a46d77702f23
> --- /dev/null
> +++ b/tests/btrfs/242.out
> @@ -0,0 +1,2 @@
> +QA output created by 242
> +Silence is golden
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v2] btrfs/242: test case to fstrim on a degraded filesystem
2021-07-04 11:20 [PATCH] btrfs/242: test case to fstrim on a degraded filesystem Anand Jain
2021-07-05 0:17 ` Qu Wenruo
@ 2021-07-05 3:41 ` Anand Jain
2021-07-05 8:45 ` [PATCH] " Filipe Manana
` (2 subsequent siblings)
4 siblings, 0 replies; 10+ messages in thread
From: Anand Jain @ 2021-07-05 3:41 UTC (permalink / raw)
To: fstests; +Cc: linux-btrfs, quwenruo.btrfs
Create a degraded btrfs filesystem and run fstrim on it.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
v2: Remove the commented #_require_command "$WIPEFS_PROG" wipefs
which I forgot to remove earlier.
tests/btrfs/242 | 48 +++++++++++++++++++++++++++++++++++++++++++++
tests/btrfs/242.out | 2 ++
2 files changed, 50 insertions(+)
create mode 100755 tests/btrfs/242
create mode 100644 tests/btrfs/242.out
diff --git a/tests/btrfs/242 b/tests/btrfs/242
new file mode 100755
index 000000000000..6b632e4abada
--- /dev/null
+++ b/tests/btrfs/242
@@ -0,0 +1,48 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2021 Oracle. All Rights Reserved.
+#
+# FS QA Test 242
+#
+# Test that fstrim can run on the degraded filesystem
+# Kernel requires fix for the null pointer deref in btrfs_trim_fs()
+# [patch] btrfs: check for missing device in btrfs_trim_fs
+
+
+. ./common/preamble
+_begin_fstest auto quick replace trim
+
+# Import common functions.
+. ./common/filter
+
+# real QA test starts here
+_supported_fs btrfs
+_require_btrfs_forget_or_module_loadable
+_require_scratch_dev_pool 2
+
+_scratch_dev_pool_get 2
+dev1=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{ print $1 }')
+
+_scratch_pool_mkfs "-m raid1 -d raid1"
+_scratch_mount
+_require_batched_discard $SCRATCH_MNT
+
+# Add a test file with some data.
+$XFS_IO_PROG -f -c "pwrite -S 0xab 0 10M" $SCRATCH_MNT/foo > /dev/null
+
+# Unmount the filesystem.
+_scratch_unmount
+
+# Mount the filesystem in degraded mode
+_btrfs_forget_or_module_reload
+_mount -o degraded $dev1 $SCRATCH_MNT
+
+# Run fstrim
+$FSTRIM_PROG $SCRATCH_MNT
+
+_scratch_dev_pool_put
+
+echo Silence is golden
+
+status=0
+exit
diff --git a/tests/btrfs/242.out b/tests/btrfs/242.out
new file mode 100644
index 000000000000..a46d77702f23
--- /dev/null
+++ b/tests/btrfs/242.out
@@ -0,0 +1,2 @@
+QA output created by 242
+Silence is golden
--
2.27.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] btrfs/242: test case to fstrim on a degraded filesystem
2021-07-04 11:20 [PATCH] btrfs/242: test case to fstrim on a degraded filesystem Anand Jain
2021-07-05 0:17 ` Qu Wenruo
2021-07-05 3:41 ` [PATCH v2] " Anand Jain
@ 2021-07-05 8:45 ` Filipe Manana
2021-07-05 10:20 ` Anand Jain
2021-07-05 8:50 ` Filipe Manana
2021-07-05 10:43 ` [PATCH v3] " Anand Jain
4 siblings, 1 reply; 10+ messages in thread
From: Filipe Manana @ 2021-07-05 8:45 UTC (permalink / raw)
To: Anand Jain; +Cc: fstests, linux-btrfs
On Sun, Jul 4, 2021 at 12:24 PM Anand Jain <anand.jain@oracle.com> wrote:
>
> Create a degraded btrfs filesystem and run fstrim on it.
>
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
> tests/btrfs/242 | 49 +++++++++++++++++++++++++++++++++++++++++++++
> tests/btrfs/242.out | 2 ++
> 2 files changed, 51 insertions(+)
> create mode 100755 tests/btrfs/242
> create mode 100644 tests/btrfs/242.out
>
> diff --git a/tests/btrfs/242 b/tests/btrfs/242
> new file mode 100755
> index 000000000000..e946ee6ac7c2
> --- /dev/null
> +++ b/tests/btrfs/242
> @@ -0,0 +1,49 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (C) 2021 Oracle. All Rights Reserved.
> +#
> +# FS QA Test 242
> +#
> +# Test that fstrim can run on the degraded filesystem
> +# Kernel requires fix for the null pointer deref in btrfs_trim_fs()
> +# [patch] btrfs: check for missing device in btrfs_trim_fs
> +
> +
> +. ./common/preamble
> +_begin_fstest auto quick replace trim
> +
> +# Import common functions.
> +. ./common/filter
> +
> +# real QA test starts here
> +_supported_fs btrfs
> +_require_btrfs_forget_or_module_loadable
> +_require_scratch_dev_pool 2
> +#_require_command "$WIPEFS_PROG" wipefs
> +
> +_scratch_dev_pool_get 2
> +dev1=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{ print $1 }')
> +
> +_scratch_pool_mkfs "-m raid1 -d raid1"
> +_scratch_mount
> +_require_batched_discard $SCRATCH_MNT
> +
> +# Add a test file with some data.
> +$XFS_IO_PROG -f -c "pwrite -S 0xab 0 10M" $SCRATCH_MNT/foo > /dev/null
What's the point of adding this file (which you copied exactly from
btrfs/223) if it's not needed to trigger the bug and it's not used
anywhere in the test?
Or at the very least, check that reading it after the fstrim returns
the correct data, as it might help prevent some regression in the
future.
Thanks.
> +
> +# Unmount the filesystem.
> +_scratch_unmount
> +
> +# Mount the filesystem in degraded mode
> +_btrfs_forget_or_module_reload
> +_mount -o degraded $dev1 $SCRATCH_MNT
> +
> +# Run fstrim
> +$FSTRIM_PROG $SCRATCH_MNT
> +
> +_scratch_dev_pool_put
> +
> +echo Silence is golden
> +
> +status=0
> +exit
> diff --git a/tests/btrfs/242.out b/tests/btrfs/242.out
> new file mode 100644
> index 000000000000..a46d77702f23
> --- /dev/null
> +++ b/tests/btrfs/242.out
> @@ -0,0 +1,2 @@
> +QA output created by 242
> +Silence is golden
> --
> 2.27.0
>
--
Filipe David Manana,
“Whether you think you can, or you think you can't — you're right.”
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] btrfs/242: test case to fstrim on a degraded filesystem
2021-07-04 11:20 [PATCH] btrfs/242: test case to fstrim on a degraded filesystem Anand Jain
` (2 preceding siblings ...)
2021-07-05 8:45 ` [PATCH] " Filipe Manana
@ 2021-07-05 8:50 ` Filipe Manana
2021-07-05 10:04 ` Anand Jain
2021-07-05 10:43 ` [PATCH v3] " Anand Jain
4 siblings, 1 reply; 10+ messages in thread
From: Filipe Manana @ 2021-07-05 8:50 UTC (permalink / raw)
To: Anand Jain; +Cc: fstests, linux-btrfs
On Sun, Jul 4, 2021 at 12:24 PM Anand Jain <anand.jain@oracle.com> wrote:
>
> Create a degraded btrfs filesystem and run fstrim on it.
>
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
> tests/btrfs/242 | 49 +++++++++++++++++++++++++++++++++++++++++++++
> tests/btrfs/242.out | 2 ++
> 2 files changed, 51 insertions(+)
> create mode 100755 tests/btrfs/242
> create mode 100644 tests/btrfs/242.out
>
> diff --git a/tests/btrfs/242 b/tests/btrfs/242
> new file mode 100755
> index 000000000000..e946ee6ac7c2
> --- /dev/null
> +++ b/tests/btrfs/242
> @@ -0,0 +1,49 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (C) 2021 Oracle. All Rights Reserved.
> +#
> +# FS QA Test 242
> +#
> +# Test that fstrim can run on the degraded filesystem
> +# Kernel requires fix for the null pointer deref in btrfs_trim_fs()
> +# [patch] btrfs: check for missing device in btrfs_trim_fs
> +
> +
> +. ./common/preamble
> +_begin_fstest auto quick replace trim
Also, this does not belong to the 'replace' group (again copied from
btrfs/223 it seems).
Thanks.
> +
> +# Import common functions.
> +. ./common/filter
> +
> +# real QA test starts here
> +_supported_fs btrfs
> +_require_btrfs_forget_or_module_loadable
> +_require_scratch_dev_pool 2
> +#_require_command "$WIPEFS_PROG" wipefs
> +
> +_scratch_dev_pool_get 2
> +dev1=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{ print $1 }')
> +
> +_scratch_pool_mkfs "-m raid1 -d raid1"
> +_scratch_mount
> +_require_batched_discard $SCRATCH_MNT
> +
> +# Add a test file with some data.
> +$XFS_IO_PROG -f -c "pwrite -S 0xab 0 10M" $SCRATCH_MNT/foo > /dev/null
> +
> +# Unmount the filesystem.
> +_scratch_unmount
> +
> +# Mount the filesystem in degraded mode
> +_btrfs_forget_or_module_reload
> +_mount -o degraded $dev1 $SCRATCH_MNT
> +
> +# Run fstrim
> +$FSTRIM_PROG $SCRATCH_MNT
> +
> +_scratch_dev_pool_put
> +
> +echo Silence is golden
> +
> +status=0
> +exit
> diff --git a/tests/btrfs/242.out b/tests/btrfs/242.out
> new file mode 100644
> index 000000000000..a46d77702f23
> --- /dev/null
> +++ b/tests/btrfs/242.out
> @@ -0,0 +1,2 @@
> +QA output created by 242
> +Silence is golden
> --
> 2.27.0
>
--
Filipe David Manana,
“Whether you think you can, or you think you can't — you're right.”
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] btrfs/242: test case to fstrim on a degraded filesystem
2021-07-05 8:50 ` Filipe Manana
@ 2021-07-05 10:04 ` Anand Jain
0 siblings, 0 replies; 10+ messages in thread
From: Anand Jain @ 2021-07-05 10:04 UTC (permalink / raw)
To: fdmanana; +Cc: fstests, linux-btrfs
On 05/07/2021 16:50, Filipe Manana wrote:
> On Sun, Jul 4, 2021 at 12:24 PM Anand Jain <anand.jain@oracle.com> wrote:
>>
>> Create a degraded btrfs filesystem and run fstrim on it.
>>
>> Signed-off-by: Anand Jain <anand.jain@oracle.com>
>> ---
>> tests/btrfs/242 | 49 +++++++++++++++++++++++++++++++++++++++++++++
>> tests/btrfs/242.out | 2 ++
>> 2 files changed, 51 insertions(+)
>> create mode 100755 tests/btrfs/242
>> create mode 100644 tests/btrfs/242.out
>>
>> diff --git a/tests/btrfs/242 b/tests/btrfs/242
>> new file mode 100755
>> index 000000000000..e946ee6ac7c2
>> --- /dev/null
>> +++ b/tests/btrfs/242
>> @@ -0,0 +1,49 @@
>> +#! /bin/bash
>> +# SPDX-License-Identifier: GPL-2.0
>> +# Copyright (C) 2021 Oracle. All Rights Reserved.
>> +#
>> +# FS QA Test 242
>> +#
>> +# Test that fstrim can run on the degraded filesystem
>> +# Kernel requires fix for the null pointer deref in btrfs_trim_fs()
>> +# [patch] btrfs: check for missing device in btrfs_trim_fs
>> +
>> +
>> +. ./common/preamble
>> +_begin_fstest auto quick replace trim
>
> Also, this does not belong to the 'replace' group (again copied from
> btrfs/223 it seems).
Oh no. Will fix it. Thanks.
- Anand
>
> Thanks.
>
>> +
>> +# Import common functions.
>> +. ./common/filter
>> +
>> +# real QA test starts here
>> +_supported_fs btrfs
>> +_require_btrfs_forget_or_module_loadable
>> +_require_scratch_dev_pool 2
>> +#_require_command "$WIPEFS_PROG" wipefs
>> +
>> +_scratch_dev_pool_get 2
>> +dev1=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{ print $1 }')
>> +
>> +_scratch_pool_mkfs "-m raid1 -d raid1"
>> +_scratch_mount
>> +_require_batched_discard $SCRATCH_MNT
>> +
>> +# Add a test file with some data.
>> +$XFS_IO_PROG -f -c "pwrite -S 0xab 0 10M" $SCRATCH_MNT/foo > /dev/null
>> +
>> +# Unmount the filesystem.
>> +_scratch_unmount
>> +
>> +# Mount the filesystem in degraded mode
>> +_btrfs_forget_or_module_reload
>> +_mount -o degraded $dev1 $SCRATCH_MNT
>> +
>> +# Run fstrim
>> +$FSTRIM_PROG $SCRATCH_MNT
>> +
>> +_scratch_dev_pool_put
>> +
>> +echo Silence is golden
>> +
>> +status=0
>> +exit
>> diff --git a/tests/btrfs/242.out b/tests/btrfs/242.out
>> new file mode 100644
>> index 000000000000..a46d77702f23
>> --- /dev/null
>> +++ b/tests/btrfs/242.out
>> @@ -0,0 +1,2 @@
>> +QA output created by 242
>> +Silence is golden
>> --
>> 2.27.0
>>
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] btrfs/242: test case to fstrim on a degraded filesystem
2021-07-05 8:45 ` [PATCH] " Filipe Manana
@ 2021-07-05 10:20 ` Anand Jain
0 siblings, 0 replies; 10+ messages in thread
From: Anand Jain @ 2021-07-05 10:20 UTC (permalink / raw)
To: fdmanana; +Cc: fstests, linux-btrfs
On 05/07/2021 16:45, Filipe Manana wrote:
> On Sun, Jul 4, 2021 at 12:24 PM Anand Jain <anand.jain@oracle.com> wrote:
>>
>> Create a degraded btrfs filesystem and run fstrim on it.
>>
>> Signed-off-by: Anand Jain <anand.jain@oracle.com>
>> ---
>> tests/btrfs/242 | 49 +++++++++++++++++++++++++++++++++++++++++++++
>> tests/btrfs/242.out | 2 ++
>> 2 files changed, 51 insertions(+)
>> create mode 100755 tests/btrfs/242
>> create mode 100644 tests/btrfs/242.out
>>
>> diff --git a/tests/btrfs/242 b/tests/btrfs/242
>> new file mode 100755
>> index 000000000000..e946ee6ac7c2
>> --- /dev/null
>> +++ b/tests/btrfs/242
>> @@ -0,0 +1,49 @@
>> +#! /bin/bash
>> +# SPDX-License-Identifier: GPL-2.0
>> +# Copyright (C) 2021 Oracle. All Rights Reserved.
>> +#
>> +# FS QA Test 242
>> +#
>> +# Test that fstrim can run on the degraded filesystem
>> +# Kernel requires fix for the null pointer deref in btrfs_trim_fs()
>> +# [patch] btrfs: check for missing device in btrfs_trim_fs
>> +
>> +
>> +. ./common/preamble
>> +_begin_fstest auto quick replace trim
>> +
>> +# Import common functions.
>> +. ./common/filter
>> +
>> +# real QA test starts here
>> +_supported_fs btrfs
>> +_require_btrfs_forget_or_module_loadable
>> +_require_scratch_dev_pool 2
>> +#_require_command "$WIPEFS_PROG" wipefs
>> +
>> +_scratch_dev_pool_get 2
>> +dev1=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{ print $1 }')
>> +
>> +_scratch_pool_mkfs "-m raid1 -d raid1"
>> +_scratch_mount
>> +_require_batched_discard $SCRATCH_MNT
>> +
>> +# Add a test file with some data.
>> +$XFS_IO_PROG -f -c "pwrite -S 0xab 0 10M" $SCRATCH_MNT/foo > /dev/null
>
> What's the point of adding this file (which you copied exactly from
> btrfs/223) if it's not needed to trigger the bug and it's not used
> anywhere in the test?
> Or at the very least, check that reading it after the fstrim returns
> the correct data, as it might help prevent some regression in the
> future.
There is no need for data to trigger the bug. I wanted some data as
practically it is. I like the idea to prevent some regression in the
future- I will add code to check if data is correct after fstrim.
Thanks, Anand
>
> Thanks.
>
>> +
>> +# Unmount the filesystem.
>> +_scratch_unmount
>> +
>> +# Mount the filesystem in degraded mode
>> +_btrfs_forget_or_module_reload
>> +_mount -o degraded $dev1 $SCRATCH_MNT
>> +
>> +# Run fstrim
>> +$FSTRIM_PROG $SCRATCH_MNT
>> +
>> +_scratch_dev_pool_put
>> +
>> +echo Silence is golden
>> +
>> +status=0
>> +exit
>> diff --git a/tests/btrfs/242.out b/tests/btrfs/242.out
>> new file mode 100644
>> index 000000000000..a46d77702f23
>> --- /dev/null
>> +++ b/tests/btrfs/242.out
>> @@ -0,0 +1,2 @@
>> +QA output created by 242
>> +Silence is golden
>> --
>> 2.27.0
>>
>
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v3] btrfs/242: test case to fstrim on a degraded filesystem
2021-07-04 11:20 [PATCH] btrfs/242: test case to fstrim on a degraded filesystem Anand Jain
` (3 preceding siblings ...)
2021-07-05 8:50 ` Filipe Manana
@ 2021-07-05 10:43 ` Anand Jain
2021-07-05 11:38 ` Filipe Manana
2021-07-05 11:51 ` Qu Wenruo
4 siblings, 2 replies; 10+ messages in thread
From: Anand Jain @ 2021-07-05 10:43 UTC (permalink / raw)
To: fstests; +Cc: linux-btrfs, quwenruo.btrfs, fdmanana
Create a degraded btrfs filesystem and run fstrim on it.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
v3: Remove from replace-group.
Add to the volume-group.
Check for the data integrity.
v2: Remove the commented #_require_command "$WIPEFS_PROG" wipefs
which I forgot to remove earlier.
tests/btrfs/242 | 49 +++++++++++++++++++++++++++++++++++++++++++++
tests/btrfs/242.out | 7 +++++++
2 files changed, 56 insertions(+)
create mode 100755 tests/btrfs/242
create mode 100644 tests/btrfs/242.out
diff --git a/tests/btrfs/242 b/tests/btrfs/242
new file mode 100755
index 000000000000..da787c1ef91f
--- /dev/null
+++ b/tests/btrfs/242
@@ -0,0 +1,49 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2021 Oracle. All Rights Reserved.
+#
+# FS QA Test 242
+#
+# Test that fstrim can run on the degraded filesystem
+# Kernel requires fix for the null pointer deref in btrfs_trim_fs()
+# [patch] btrfs: check for missing device in btrfs_trim_fs
+
+. ./common/preamble
+_begin_fstest auto quick volume trim
+
+# Import common functions.
+. ./common/filter
+
+# real QA test starts here
+_supported_fs btrfs
+_require_btrfs_forget_or_module_loadable
+_require_scratch_dev_pool 2
+
+_scratch_dev_pool_get 2
+dev1=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{ print $1 }')
+
+_scratch_pool_mkfs "-m raid1 -d raid1"
+_scratch_mount
+_require_batched_discard $SCRATCH_MNT
+
+# Add a test file with some data.
+$XFS_IO_PROG -f -c "pwrite -S 0xab 0 10M" $SCRATCH_MNT/foo | _filter_xfs_io
+
+# Unmount the filesystem.
+_scratch_unmount
+
+# Mount the filesystem in degraded mode
+_btrfs_forget_or_module_reload
+_mount -o degraded $dev1 $SCRATCH_MNT
+
+# Run fstrim, it should skip on the missing device.
+$FSTRIM_PROG $SCRATCH_MNT
+
+# Verify data integrity as in the golden output.
+echo "File foo data:"
+od -A d -t x1 $SCRATCH_MNT/foo
+
+_scratch_dev_pool_put
+
+status=0
+exit
diff --git a/tests/btrfs/242.out b/tests/btrfs/242.out
new file mode 100644
index 000000000000..0f478fc93db7
--- /dev/null
+++ b/tests/btrfs/242.out
@@ -0,0 +1,7 @@
+QA output created by 242
+wrote 10485760/10485760 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+File foo data:
+0000000 ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab
+*
+10485760
--
2.27.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v3] btrfs/242: test case to fstrim on a degraded filesystem
2021-07-05 10:43 ` [PATCH v3] " Anand Jain
@ 2021-07-05 11:38 ` Filipe Manana
2021-07-05 11:51 ` Qu Wenruo
1 sibling, 0 replies; 10+ messages in thread
From: Filipe Manana @ 2021-07-05 11:38 UTC (permalink / raw)
To: Anand Jain; +Cc: fstests, linux-btrfs, Qu Wenruo
On Mon, Jul 5, 2021 at 11:43 AM Anand Jain <anand.jain@oracle.com> wrote:
>
> Create a degraded btrfs filesystem and run fstrim on it.
>
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Thanks.
> ---
> v3: Remove from replace-group.
> Add to the volume-group.
> Check for the data integrity.
> v2: Remove the commented #_require_command "$WIPEFS_PROG" wipefs
> which I forgot to remove earlier.
> tests/btrfs/242 | 49 +++++++++++++++++++++++++++++++++++++++++++++
> tests/btrfs/242.out | 7 +++++++
> 2 files changed, 56 insertions(+)
> create mode 100755 tests/btrfs/242
> create mode 100644 tests/btrfs/242.out
>
> diff --git a/tests/btrfs/242 b/tests/btrfs/242
> new file mode 100755
> index 000000000000..da787c1ef91f
> --- /dev/null
> +++ b/tests/btrfs/242
> @@ -0,0 +1,49 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (C) 2021 Oracle. All Rights Reserved.
> +#
> +# FS QA Test 242
> +#
> +# Test that fstrim can run on the degraded filesystem
> +# Kernel requires fix for the null pointer deref in btrfs_trim_fs()
> +# [patch] btrfs: check for missing device in btrfs_trim_fs
> +
> +. ./common/preamble
> +_begin_fstest auto quick volume trim
> +
> +# Import common functions.
> +. ./common/filter
> +
> +# real QA test starts here
> +_supported_fs btrfs
> +_require_btrfs_forget_or_module_loadable
> +_require_scratch_dev_pool 2
> +
> +_scratch_dev_pool_get 2
> +dev1=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{ print $1 }')
> +
> +_scratch_pool_mkfs "-m raid1 -d raid1"
> +_scratch_mount
> +_require_batched_discard $SCRATCH_MNT
> +
> +# Add a test file with some data.
> +$XFS_IO_PROG -f -c "pwrite -S 0xab 0 10M" $SCRATCH_MNT/foo | _filter_xfs_io
> +
> +# Unmount the filesystem.
> +_scratch_unmount
> +
> +# Mount the filesystem in degraded mode
> +_btrfs_forget_or_module_reload
> +_mount -o degraded $dev1 $SCRATCH_MNT
> +
> +# Run fstrim, it should skip on the missing device.
> +$FSTRIM_PROG $SCRATCH_MNT
> +
> +# Verify data integrity as in the golden output.
> +echo "File foo data:"
> +od -A d -t x1 $SCRATCH_MNT/foo
> +
> +_scratch_dev_pool_put
> +
> +status=0
> +exit
> diff --git a/tests/btrfs/242.out b/tests/btrfs/242.out
> new file mode 100644
> index 000000000000..0f478fc93db7
> --- /dev/null
> +++ b/tests/btrfs/242.out
> @@ -0,0 +1,7 @@
> +QA output created by 242
> +wrote 10485760/10485760 bytes at offset 0
> +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
> +File foo data:
> +0000000 ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab
> +*
> +10485760
> --
> 2.27.0
>
--
Filipe David Manana,
“Whether you think you can, or you think you can't — you're right.”
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v3] btrfs/242: test case to fstrim on a degraded filesystem
2021-07-05 10:43 ` [PATCH v3] " Anand Jain
2021-07-05 11:38 ` Filipe Manana
@ 2021-07-05 11:51 ` Qu Wenruo
1 sibling, 0 replies; 10+ messages in thread
From: Qu Wenruo @ 2021-07-05 11:51 UTC (permalink / raw)
To: Anand Jain, fstests; +Cc: linux-btrfs, fdmanana
On 2021/7/5 下午6:43, Anand Jain wrote:
> Create a degraded btrfs filesystem and run fstrim on it.
>
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Thanks,
Qu
> ---
> v3: Remove from replace-group.
> Add to the volume-group.
> Check for the data integrity.
> v2: Remove the commented #_require_command "$WIPEFS_PROG" wipefs
> which I forgot to remove earlier.
> tests/btrfs/242 | 49 +++++++++++++++++++++++++++++++++++++++++++++
> tests/btrfs/242.out | 7 +++++++
> 2 files changed, 56 insertions(+)
> create mode 100755 tests/btrfs/242
> create mode 100644 tests/btrfs/242.out
>
> diff --git a/tests/btrfs/242 b/tests/btrfs/242
> new file mode 100755
> index 000000000000..da787c1ef91f
> --- /dev/null
> +++ b/tests/btrfs/242
> @@ -0,0 +1,49 @@
> +#! /bin/bash
> +# SPDX-License-Identifier: GPL-2.0
> +# Copyright (C) 2021 Oracle. All Rights Reserved.
> +#
> +# FS QA Test 242
> +#
> +# Test that fstrim can run on the degraded filesystem
> +# Kernel requires fix for the null pointer deref in btrfs_trim_fs()
> +# [patch] btrfs: check for missing device in btrfs_trim_fs
> +
> +. ./common/preamble
> +_begin_fstest auto quick volume trim
> +
> +# Import common functions.
> +. ./common/filter
> +
> +# real QA test starts here
> +_supported_fs btrfs
> +_require_btrfs_forget_or_module_loadable
> +_require_scratch_dev_pool 2
> +
> +_scratch_dev_pool_get 2
> +dev1=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{ print $1 }')
> +
> +_scratch_pool_mkfs "-m raid1 -d raid1"
> +_scratch_mount
> +_require_batched_discard $SCRATCH_MNT
> +
> +# Add a test file with some data.
> +$XFS_IO_PROG -f -c "pwrite -S 0xab 0 10M" $SCRATCH_MNT/foo | _filter_xfs_io
> +
> +# Unmount the filesystem.
> +_scratch_unmount
> +
> +# Mount the filesystem in degraded mode
> +_btrfs_forget_or_module_reload
> +_mount -o degraded $dev1 $SCRATCH_MNT
> +
> +# Run fstrim, it should skip on the missing device.
> +$FSTRIM_PROG $SCRATCH_MNT
> +
> +# Verify data integrity as in the golden output.
> +echo "File foo data:"
> +od -A d -t x1 $SCRATCH_MNT/foo
> +
> +_scratch_dev_pool_put
> +
> +status=0
> +exit
> diff --git a/tests/btrfs/242.out b/tests/btrfs/242.out
> new file mode 100644
> index 000000000000..0f478fc93db7
> --- /dev/null
> +++ b/tests/btrfs/242.out
> @@ -0,0 +1,7 @@
> +QA output created by 242
> +wrote 10485760/10485760 bytes at offset 0
> +XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
> +File foo data:
> +0000000 ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab
> +*
> +10485760
>
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2021-07-05 11:51 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-04 11:20 [PATCH] btrfs/242: test case to fstrim on a degraded filesystem Anand Jain
2021-07-05 0:17 ` Qu Wenruo
2021-07-05 3:41 ` [PATCH v2] " Anand Jain
2021-07-05 8:45 ` [PATCH] " Filipe Manana
2021-07-05 10:20 ` Anand Jain
2021-07-05 8:50 ` Filipe Manana
2021-07-05 10:04 ` Anand Jain
2021-07-05 10:43 ` [PATCH v3] " Anand Jain
2021-07-05 11:38 ` Filipe Manana
2021-07-05 11:51 ` Qu Wenruo
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.