btrfs: test if device delete ends up with losing raid profile
authorLiu Bo <bo.li.liu@oracle.com>
Mon, 16 Oct 2017 16:51:20 +0000 (10:51 -0600)
committerEryu Guan <eguan@redhat.com>
Sun, 22 Oct 2017 11:16:56 +0000 (19:16 +0800)
Currently running 'btrfs device delete' can end up with losing data
raid profile (if any), this test is to reproduce the problem.

The fix is
     "Btrfs: avoid losing data raid profile when deleting a device"

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
tests/btrfs/151 [new file with mode: 0755]
tests/btrfs/151.out [new file with mode: 0644]
tests/btrfs/group

diff --git a/tests/btrfs/151 b/tests/btrfs/151
new file mode 100755 (executable)
index 0000000..40b248c
--- /dev/null
@@ -0,0 +1,80 @@
+#! /bin/bash
+# FS QA Test 151
+#
+# Test if it's losing data chunk's raid profile after 'btrfs device
+# remove'.
+#
+# The fix is
+#      Btrfs: avoid losing data raid profile when deleting a device
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2017 Oracle.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+#
+
+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
+
+# Modify as appropriate.
+_supported_fs btrfs
+_supported_os Linux
+_require_scratch
+_require_scratch_dev_pool 3
+_require_btrfs_dev_del_by_devid
+
+# We need exactly 3 disks to form a fixed stripe layout for this test.
+_scratch_dev_pool_get 3
+
+# create raid1 for data
+_scratch_pool_mkfs "-d raid1 -b 1G" >> $seqres.full 2>&1
+
+# we need an empty data chunk, so nospace_cache is required.
+_scratch_mount -onospace_cache
+
+# if data chunk is empty, 'btrfs device remove' can change raid1 to
+# single.
+$BTRFS_UTIL_PROG device delete 2 $SCRATCH_MNT >> $seqres.full 2>&1
+
+# save btrfs filesystem df output for debug purpose
+$BTRFS_UTIL_PROG filesystem df $SCRATCH_MNT 2>&1 | \
+    tee -a $seqres.full | $AWK_PROG -F ':' '/Data,/ {print $1}'
+
+_scratch_dev_pool_put
+
+# success, all done
+status=0
+exit
diff --git a/tests/btrfs/151.out b/tests/btrfs/151.out
new file mode 100644 (file)
index 0000000..0a1de06
--- /dev/null
@@ -0,0 +1,2 @@
+QA output created by 151
+Data, RAID1
index e73bb1b3a8fad58f6230b6ad9091d121f4a4ac54..a7ff7b06dcaedb5b03f431d00cd23b4201b2ad4d 100644 (file)
 148 auto quick rw
 149 auto quick send compress
 150 auto quick dangerous
+151 auto quick