btrfs: test if show_devname returns sprout device
authorAnand Jain <anand.jain@oracle.com>
Mon, 20 Jul 2020 03:55:54 +0000 (11:55 +0800)
committerEryu Guan <guaneryu@gmail.com>
Sun, 26 Jul 2020 13:40:40 +0000 (21:40 +0800)
Test if the show_devname() returns sprout device instead of seed device.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
tests/btrfs/216 [new file with mode: 0755]
tests/btrfs/216.out [new file with mode: 0644]
tests/btrfs/group

diff --git a/tests/btrfs/216 b/tests/btrfs/216
new file mode 100755 (executable)
index 0000000..76228d3
--- /dev/null
@@ -0,0 +1,63 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2020 Oracle.  All Rights Reserved.
+#
+# FS QA Test 216
+#
+# Test if the show_devname() returns sprout device instead of seed device.
+#
+# Fixed in kernel patch:
+#   btrfs: btrfs_show_devname don't traverse into the seed fsid
+
+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
+_supported_fs btrfs
+_supported_os Linux
+_require_scratch_dev_pool 2
+
+_scratch_dev_pool_get 2
+
+seed=$(echo $SCRATCH_DEV_POOL | awk '{print $1}')
+sprout=$(echo $SCRATCH_DEV_POOL | awk '{print $2}')
+
+_mkfs_dev $seed
+$BTRFS_TUNE_PROG -S 1 $seed
+_mount $seed $SCRATCH_MNT >> $seqres.full 2>&1
+cat /proc/self/mounts | grep $seed >> $seqres.full
+$BTRFS_UTIL_PROG device add -f $sprout $SCRATCH_MNT
+cat /proc/self/mounts | grep $sprout >> $seqres.full
+
+# check if the show_devname() returns the sprout device instead of seed device.
+dev=$(grep $SCRATCH_MNT /proc/self/mounts | $AWK_PROG '{print $1}')
+
+if [ "$sprout" != "$dev" ]; then
+       echo "Unexpected device: $dev, expected $sprout"
+fi
+echo "Silence is golden"
+
+_scratch_dev_pool_put
+
+# success, all done
+status=0
+exit
diff --git a/tests/btrfs/216.out b/tests/btrfs/216.out
new file mode 100644 (file)
index 0000000..83d25fc
--- /dev/null
@@ -0,0 +1,2 @@
+QA output created by 216
+Silence is golden
index dda0763..ca90818 100644 (file)
 213 auto balance dangerous
 214 auto quick send snapshot
 215 auto quick
+216 auto quick seed