aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnand Jain <anand.jain@oracle.com>2023-09-28 17:01:30 +0800
committerZorro Lang <zlang@kernel.org>2023-10-05 22:36:24 +0800
commit0b70188b651b8d918989d35d162927051b5ff1bb (patch)
tree0552652bb891f1e00ab76d4d6cad4c8fa3afb3ff
parentd213e332a32b5d74034ca718e1add40a2443fde2 (diff)
downloadxfstests-dev-0b70188b651b8d918989d35d162927051b5ff1bb.tar.gz
btrfs: test scan but not register the single device fs
Recently, in the kernel commit 0d9436739af2 ("btrfs: scan but don't register device on single device filesystem"), we adopted an approach where we scan the device to validate it. However, we do not register it in the kernel memory since it is not required to be remembered. However, the seed device should continue to be registered because otherwise, the mount operation for the sprout device will fail. This patch ensures that we honor the mount requirements and do not break anything while making changes in this part of the code. Signed-off-by: Anand Jain <anand.jain@oracle.com> Reviewed-by: Zorro Lang <zlang@redhat.com> Signed-off-by: Zorro Lang <zlang@kernel.org>
-rwxr-xr-xtests/btrfs/29855
-rw-r--r--tests/btrfs/298.out2
2 files changed, 57 insertions, 0 deletions
diff --git a/tests/btrfs/298 b/tests/btrfs/298
new file mode 100755
index 0000000000..d5536cf3ed
--- /dev/null
+++ b/tests/btrfs/298
@@ -0,0 +1,55 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2023 Oracle. All Rights Reserved.
+#
+# FS QA Test 298
+#
+# Check if the device scan registers for a single-device seed and drops
+# it from the kernel if it is eventually marked as non-seed.
+#
+. ./common/preamble
+_begin_fstest auto quick seed
+
+_supported_fs btrfs
+_require_command "$BTRFS_TUNE_PROG" btrfstune
+_require_command "$WIPEFS_PROG" wipefs
+_require_scratch_dev_pool 2
+_scratch_dev_pool_get 1
+_spare_dev_get
+
+$WIPEFS_PROG -a $SCRATCH_DEV
+$WIPEFS_PROG -a $SPARE_DEV
+
+echo "#setup seed sprout device" >> $seqres.full
+_scratch_mkfs "-b 300M" >> $seqres.full 2>&1 || \
+ _fail "Fail to make SCRATCH_DEV with -b 300M"
+$BTRFS_TUNE_PROG -S 1 $SCRATCH_DEV
+_scratch_mount >> $seqres.full 2>&1
+$BTRFS_UTIL_PROG device add $SPARE_DEV $SCRATCH_MNT
+_scratch_unmount
+$BTRFS_UTIL_PROG device scan --forget
+
+echo "#Scan seed device and check using mount" >> $seqres.full
+$BTRFS_UTIL_PROG device scan $SCRATCH_DEV >> $seqres.full
+_mount $SPARE_DEV $SCRATCH_MNT
+umount $SCRATCH_MNT
+
+echo "#check again, ensures seed device still in kernel" >> $seqres.full
+_mount $SPARE_DEV $SCRATCH_MNT
+umount $SCRATCH_MNT
+
+echo "#Now scan of non-seed device makes kernel forget" >> $seqres.full
+$BTRFS_TUNE_PROG -f -S 0 $SCRATCH_DEV >> $seqres.full 2>&1
+$BTRFS_UTIL_PROG device scan $SCRATCH_DEV >> $seqres.full
+
+echo "#Sprout mount must fail for missing seed device" >> $seqres.full
+_mount $SPARE_DEV $SCRATCH_MNT > /dev/null 2>&1
+[[ $? == 32 ]] || _fail "mount failed to fail"
+
+_spare_dev_put
+_scratch_dev_pool_put
+
+# success, all done
+echo Silence is golden
+status=0
+exit
diff --git a/tests/btrfs/298.out b/tests/btrfs/298.out
new file mode 100644
index 0000000000..634342678f
--- /dev/null
+++ b/tests/btrfs/298.out
@@ -0,0 +1,2 @@
+QA output created by 298
+Silence is golden