Skip to contentSkip to conversation

fstests: Verify that removed device has its superblocks deleted

PATCH Superseded Nikolay Borisov 2 participants 6 messages Mar 25, 2019 – Mar 26, 2019 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fstests: Verify that removed device has its superblocks deleted

When a device is removed from a btrfs filesystem its superblock copies must be deleted. This test ensures this is indeed the case.

---
 tests/btrfs/184     | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/184.out |  2 ++
 tests/btrfs/group   |  1 +
 3 files changed, 60 insertions(+)
 create mode 100755 tests/btrfs/184
 create mode 100644 tests/btrfs/184.out
tests/btrfs/184 new file +57 -0
new file mode 100755
index 000000000000..3bf7d201a145
@@ -0,0 +1,57 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2019 SUSE LLC. All Rights Reserved.
+#
+# FS QA Test 184
+#
+# Verify that when a device is removed from a multi-device
+# filesystem its superblock copies are correctly deleted
+#
+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
+
+rm -f $seqres.full
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+_require_scratch
+_require_scratch_dev_pool 2
+_require_btrfs_command inspect-internal dump-super
+
+_scratch_pool_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed"
+_scratch_mount
+                                                                            
+# pick last dev in the list
+dev_del=`echo ${SCRATCH_DEV_POOL} | awk '{print $NF}'`
+$BTRFS_UTIL_PROG device delete $dev_del $SCRATCH_MNT || _fail "btrfs device delete failed"
+for i in {0..2}; do
+    output=$($BTRFS_UTIL_PROG inspect-internal dump-super -s $i $dev_del 2>&1)
+    $BTRFS_UTIL_PROG inspect-internal dump-super -s $i $dev_del 2>&1 | grep -q "bad magic"
+    ret=$?
+    if [[ "$output" != "" && $ret -eq 1 ]]; then
+        _fail "Deleted dev superblocks not scratched"
+    fi
+done
+_scratch_unmount
+
+# success, all done
+echo "Silence is golden"
+status=0
+exit
tests/btrfs/184.out new file +2 -0
new file mode 100644
index 000000000000..b4ce96cfc047
@@ -0,0 +1,2 @@
+QA output created by 184
+Silence is golden
tests/btrfs/group +1 -0
index f3227c1708d9..c1d215bf5ff8 100644
@@ -186,3 +186,4 @@
 181 auto quick balance
 182 auto quick balance
 183 auto quick clone compress punch
+184 auto quick volume
Signature · 1 line
2.7.4
#1 lore raw
Quoted 52 lines · Nikolay Borisov

When a device is removed from a btrfs filesystem its superblock copies must be deleted. This test ensures this is indeed the case.

---
  tests/btrfs/184     | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++
  tests/btrfs/184.out |  2 ++
  tests/btrfs/group   |  1 +
  3 files changed, 60 insertions(+)

create mode 100755 tests/btrfs/184
create mode 100644 tests/btrfs/184.out

tests/btrfs/184 new file +34 -0
new file mode 100755
index 000000000000..3bf7d201a145
@@ -0,0 +1,57 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2019 SUSE LLC. All Rights Reserved.
+#
+# FS QA Test 184
+#
+# Verify that when a device is removed from a multi-device
+# filesystem its superblock copies are correctly deleted
+#
+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
+
+rm -f $seqres.full
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+_require_scratch

tests/btrfs/184 line 43

Quoted 10 lines
tests/btrfs/184 new file +9 -0
+_require_scratch_dev_pool 2
+_require_btrfs_command inspect-internal dump-super
+
+_scratch_pool_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed"
+_scratch_mount
+
+# pick last dev in the list
+dev_del=`echo ${SCRATCH_DEV_POOL} | awk '{print $NF}'`
 
+$BTRFS_UTIL_PROG device delete $dev_del $SCRATCH_MNT || _fail "btrfs device delete failed"

Device delete will fail with the raid1 mkfs option in the config fail.

Thanks, Anand

Quoted 32 lines
tests/btrfs/184 new file +14 -0
+for i in {0..2}; do
+    output=$($BTRFS_UTIL_PROG inspect-internal dump-super -s $i $dev_del 2>&1)
+    $BTRFS_UTIL_PROG inspect-internal dump-super -s $i $dev_del 2>&1 | grep -q "bad magic"
+    ret=$?
+    if [[ "$output" != "" && $ret -eq 1 ]]; then
+        _fail "Deleted dev superblocks not scratched"
+    fi
+done
+_scratch_unmount
+
+# success, all done
+echo "Silence is golden"
+status=0
+exit
tests/btrfs/184.out new file +2 -0
new file mode 100644
index 000000000000..b4ce96cfc047
@@ -0,0 +1,2 @@
+QA output created by 184
+Silence is golden
tests/btrfs/group +1 -0
index f3227c1708d9..c1d215bf5ff8 100644
@@ -186,3 +186,4 @@
  181 auto quick balance
  182 auto quick balance
  183 auto quick clone compress punch
+184 auto quick volume
#2 lore raw
Quoted 65 lines · Anand Jain
Quoted 61 lines · Nikolay Borisov

When a device is removed from a btrfs filesystem its superblock copies must be deleted. This test ensures this is indeed the case.

---
  tests/btrfs/184     | 57
+++++++++++++++++++++++++++++++++++++++++++++++++++++
  tests/btrfs/184.out |  2 ++
  tests/btrfs/group   |  1 +

  3 files changed, 60 insertions(+)

  create mode 100755 tests/btrfs/184
  create mode 100644 tests/btrfs/184.out

tests/btrfs/184 new file +42 -0
new file mode 100755
index 000000000000..3bf7d201a145
@@ -0,0 +1,57 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2019 SUSE LLC. All Rights Reserved.
+#
+# FS QA Test 184
+#
+# Verify that when a device is removed from a multi-device
+# filesystem its superblock copies are correctly deleted
+#
+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
+
+rm -f $seqres.full
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+_require_scratch
+_require_scratch_dev_pool 2
+_require_btrfs_command inspect-internal dump-super
+
+_scratch_pool_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed"
+_scratch_mount
+
+# pick last dev in the list
+dev_del=`echo ${SCRATCH_DEV_POOL} | awk '{print $NF}'`
Quoted 4 lines
Quoted 2 lines
tests/btrfs/184 new file +1 -0
+$BTRFS_UTIL_PROG device delete $dev_del $SCRATCH_MNT || _fail "btrfs 

device delete failed"

 Device delete will fail with the raid1 mkfs option in the config fail.

Also needs

_scratch_dev_pool_get 2
_scratch_dev_pool_put

Quoted 37 lines

Thanks, Anand

Quoted 34 lines

+for i in {0..2}; do
+    output=$($BTRFS_UTIL_PROG inspect-internal dump-super -s $i $dev_del 2>&1)
+    $BTRFS_UTIL_PROG inspect-internal dump-super -s $i $dev_del 2>&1 | grep -q "bad magic"
+    ret=$?
+    if [[ "$output" != "" && $ret -eq 1 ]]; then
+        _fail "Deleted dev superblocks not scratched"
+    fi

tests/btrfs/184 new file +7 -0
+done
+_scratch_unmount
+
+# success, all done
+echo "Silence is golden"
+status=0
+exit
tests/btrfs/184.out new file +2 -0
new file mode 100644
index 000000000000..b4ce96cfc047
@@ -0,0 +1,2 @@
+QA output created by 184
+Silence is golden
tests/btrfs/group +0 -0
index f3227c1708d9..c1d215bf5ff8 100644
@@ -186,3 +186,4 @@

  181 auto quick balance
  182 auto quick balance
  183 auto quick clone compress punch
+184 auto quick volume

#3 lore raw

PATCH v2 1/1 fstests: Verify that removed device has its superblocks deleted

In reply to Nikolay Borisov

When a device is removed from a btrfs filesystem its superblock copies must be deleted. This test ensures this is indeed the case.

---

Changes since v1:
* Use _scratch_dev_pool_(get|put) to ensure the test uses exactly 2 devices.

* Explicitly use -draid0 -mraid0 mkfs options for the scratch devices to ensure at least one of the device could be removed. Also add a comment about that.

 tests/btrfs/184     | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/btrfs/184.out |  2 ++
 tests/btrfs/group   |  1 +
 3 files changed, 66 insertions(+)
 create mode 100755 tests/btrfs/184
 create mode 100644 tests/btrfs/184.out
tests/btrfs/184 new file +63 -0
new file mode 100755
index 000000000000..49fe5c9c27bb
@@ -0,0 +1,63 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2019 SUSE LLC. All Rights Reserved.
+#
+# FS QA Test 184
+#
+# Verify that when a device is removed from a multi-device
+# filesystem its superblock copies are correctly deleted
+#
+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
+
+rm -f $seqres.full
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+_require_scratch
+_require_scratch_dev_pool 2
+_require_btrfs_command inspect-internal dump-super
+
+_scratch_dev_pool_get 2
+
+# Explicitly use raid0 mode to ensure at least one of the devices can be 
+# removed. 
+_scratch_pool_mkfs "-d raid0 -m raid0" >> $seqres.full 2>&1 || _fail "mkfs failed"
+_scratch_mount
+                                                                            
+# pick last dev in the list
+dev_del=`echo ${SCRATCH_DEV_POOL} | awk '{print $NF}'`
+$BTRFS_UTIL_PROG device delete $dev_del $SCRATCH_MNT || _fail "btrfs device delete failed"
+for i in {0..2}; do
+    output=$($BTRFS_UTIL_PROG inspect-internal dump-super -s $i $dev_del 2>&1)
+    $BTRFS_UTIL_PROG inspect-internal dump-super -s $i $dev_del 2>&1 | grep -q "bad magic"
+    ret=$?
+    if [[ "$output" != "" && $ret -eq 1 ]]; then
+        _fail "Deleted dev superblocks not scratched"
+    fi
+done
+_scratch_unmount
+
+_scratch_dev_pool_put
+
+# success, all done
+echo "Silence is golden"
+status=0
+exit
tests/btrfs/184.out new file +2 -0
new file mode 100644
index 000000000000..b4ce96cfc047
@@ -0,0 +1,2 @@
+QA output created by 184
+Silence is golden
tests/btrfs/group +1 -0
index f3227c1708d9..c1d215bf5ff8 100644
@@ -186,3 +186,4 @@
 181 auto quick balance
 182 auto quick balance
 183 auto quick clone compress punch
+184 auto quick volume
Signature · 1 line
2.7.4
Reviewed-by on v2 1/1
#4 lore raw
Quoted 2 lines · Nikolay Borisov

When a device is removed from a btrfs filesystem its superblock copies must be deleted.

AFAIK this bug was fixed a long time back in the kernel. Is there any newer fix in the kernel?

Quoted 3 lines

This test ensures this is indeed the case.

Looks good.

Quoted 103 lines

---

Changes since v1:
* Use _scratch_dev_pool_(get|put) to ensure the test uses exactly 2 devices.

* Explicitly use -draid0 -mraid0 mkfs options for the scratch devices to ensure at least one of the device could be removed. Also add a comment about that.

  tests/btrfs/184     | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++
  tests/btrfs/184.out |  2 ++
  tests/btrfs/group   |  1 +
  3 files changed, 66 insertions(+)

create mode 100755 tests/btrfs/184
create mode 100644 tests/btrfs/184.out

tests/btrfs/184 new file +63 -0
new file mode 100755
index 000000000000..49fe5c9c27bb
@@ -0,0 +1,63 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2019 SUSE LLC. All Rights Reserved.
+#
+# FS QA Test 184
+#
+# Verify that when a device is removed from a multi-device
+# filesystem its superblock copies are correctly deleted
+#
+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
+
+rm -f $seqres.full
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+_require_scratch
+_require_scratch_dev_pool 2
+_require_btrfs_command inspect-internal dump-super
+
+_scratch_dev_pool_get 2
+
+# Explicitly use raid0 mode to ensure at least one of the devices can be
+# removed.
+_scratch_pool_mkfs "-d raid0 -m raid0" >> $seqres.full 2>&1 || _fail "mkfs failed"
+_scratch_mount
+
+# pick last dev in the list
+dev_del=`echo ${SCRATCH_DEV_POOL} | awk '{print $NF}'`
+$BTRFS_UTIL_PROG device delete $dev_del $SCRATCH_MNT || _fail "btrfs device delete failed"
+for i in {0..2}; do
+    output=$($BTRFS_UTIL_PROG inspect-internal dump-super -s $i $dev_del 2>&1)
+    $BTRFS_UTIL_PROG inspect-internal dump-super -s $i $dev_del 2>&1 | grep -q "bad magic"
+    ret=$?
+    if [[ "$output" != "" && $ret -eq 1 ]]; then
+        _fail "Deleted dev superblocks not scratched"
+    fi
+done
+_scratch_unmount
+
+_scratch_dev_pool_put
+
+# success, all done
+echo "Silence is golden"
+status=0
+exit
tests/btrfs/184.out new file +2 -0
new file mode 100644
index 000000000000..b4ce96cfc047
@@ -0,0 +1,2 @@
+QA output created by 184
+Silence is golden
tests/btrfs/group +1 -0
index f3227c1708d9..c1d215bf5ff8 100644
@@ -186,3 +186,4 @@
  181 auto quick balance
  182 auto quick balance
  183 auto quick clone compress punch
+184 auto quick volume
#5 lore raw
Quoted 8 lines · Anand Jain
Quoted 2 lines · Nikolay Borisov

When a device is removed from a btrfs filesystem its superblock copies must be deleted.

AFAIK this bug was fixed a long time back in the kernel. Is there any newer fix in the kernel?

No there isn't but we currently don't have a test that covers that functionality and I have some changes in progress that touch superblock writing code so I'd rather be safe than sorry.

Quoted 120 lines
Quoted 4 lines

This test ensures this is indeed the case.

Looks good.

Quoted 110 lines

---

Changes since v1:
  * Use _scratch_dev_pool_(get|put) to ensure the test uses exactly 2 devices.
    * Explicitly use -draid0 -mraid0 mkfs options for the scratch devices to
  ensure at least one of the device could be removed. Also add a comment about
  that.

  tests/btrfs/184     | 63
+++++++++++++++++++++++++++++++++++++++++++++++++++++
  tests/btrfs/184.out |  2 ++
  tests/btrfs/group   |  1 +

  3 files changed, 66 insertions(+)

  create mode 100755 tests/btrfs/184
  create mode 100644 tests/btrfs/184.out

tests/btrfs/184 new file +42 -0
new file mode 100755
index 000000000000..49fe5c9c27bb
@@ -0,0 +1,63 @@
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2019 SUSE LLC. All Rights Reserved.
+#
+# FS QA Test 184
+#
+# Verify that when a device is removed from a multi-device
+# filesystem its superblock copies are correctly deleted
+#
+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
+
+rm -f $seqres.full
+
+# real QA test starts here
+_supported_fs btrfs
+_supported_os Linux
+_require_scratch
+_require_scratch_dev_pool 2
+_require_btrfs_command inspect-internal dump-super
+
+_scratch_dev_pool_get 2
+
+# Explicitly use raid0 mode to ensure at least one of the devices can be
+# removed.
+_scratch_pool_mkfs "-d raid0 -m raid0" >> $seqres.full 2>&1 || _fail

"mkfs failed"

tests/btrfs/184 new file +5 -0
+_scratch_mount
+
+# pick last dev in the list
+dev_del=`echo ${SCRATCH_DEV_POOL} | awk '{print $NF}'`
+$BTRFS_UTIL_PROG device delete $dev_del $SCRATCH_MNT || _fail "btrfs

device delete failed"
+for i in {0..2}; do
+    output=$($BTRFS_UTIL_PROG inspect-internal dump-super -s $i $dev_del 2>&1)
+    $BTRFS_UTIL_PROG inspect-internal dump-super -s $i $dev_del 2>&1 | grep -q "bad magic"
+    ret=$?
+    if [[ "$output" != "" && $ret -eq 1 ]]; then
+        _fail "Deleted dev superblocks not scratched"
+    fi

tests/btrfs/184 new file +9 -0
+done
+_scratch_unmount
+
+_scratch_dev_pool_put
+
+# success, all done
+echo "Silence is golden"
+status=0
+exit
tests/btrfs/184.out new file +2 -0
new file mode 100644
index 000000000000..b4ce96cfc047
@@ -0,0 +1,2 @@
+QA output created by 184
+Silence is golden
tests/btrfs/group +0 -0
index f3227c1708d9..c1d215bf5ff8 100644
@@ -186,3 +186,4 @@

  181 auto quick balance
  182 auto quick balance
  183 auto quick clone compress punch
+184 auto quick volume