diff mbox series

[v3] btrfs/242: test case to fstrim on a degraded filesystem

Message ID cae6a7e7836949a0407cf6859d7f9102636bab8f.1625481473.git.anand.jain@oracle.com (mailing list archive)
State New, archived
Headers show
Series [v3] btrfs/242: test case to fstrim on a degraded filesystem | expand

Commit Message

Anand Jain July 5, 2021, 10:43 a.m. UTC
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

Comments

Filipe Manana July 5, 2021, 11:38 a.m. UTC | #1
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
>
Qu Wenruo July 5, 2021, 11:51 a.m. UTC | #2
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
>
diff mbox series

Patch

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