diff mbox series

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

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

Commit Message

Anand Jain July 5, 2021, 3:41 a.m. UTC
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 mbox series

Patch

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