btrfs: Add a test for dead looping balance after balance cancel
PATCH v2 1/1 btrfs: Add a test for dead looping balance after balance cancel
Test if canceling a running balance can cause later balance to dead loop.
The ifx is titled "btrfs: relocation: Clear the DEAD_RELOC_TREE bit for
orphan roots to prevent runaway balance".
Signed-off-by Qu Wenruo <[email protected]>
---
Changelog:
v2:
- Remove debugging command
--- tests/btrfs/213 | 65 +++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/213.out | 2 ++ tests/btrfs/group | 1 + 3 files changed, 68 insertions(+) create mode 100755 tests/btrfs/213 create mode 100644 tests/btrfs/213.out
tests/btrfs/213 new file +65 -0
@@ -0,0 +1,65 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2020 SUSE Linux Products GmbH. All Rights Reserved. +# +# FS QA Test 213 +# +# Test if canceling a running balance can lead to dead looping balance +# +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 + +# Modify as appropriate. +_supported_fs btrfs +_supported_os Linux +_require_scratch +_require_command "$KILLALL_PROG" killall + +_scratch_mkfs >> $seqres.full +_scratch_mount + +runtime=4 + +# Create enough IO so that we need around $runtime seconds to relocate it +dd if=/dev/zero bs=1M of="$SCRATCH_MNT/file" oflag=sync status=none \ + &> /dev/null & +dd_pid=$! +sleep $runtime +"$KILLALL_PROG" -q dd &> /dev/null +wait $dd_pid + +ps aux >> $seqres.full +# Now balance should take at least $runtime seconds, we can cancel it at +# $runtime/2 to ensure a success cancel. +$BTRFS_UTIL_PROG balance start -d --bg "$SCRATCH_MNT" +sleep $(($runtime / 2)) +$BTRFS_UTIL_PROG balance cancel "$SCRATCH_MNT" + +# Now check if we can finish relocating metadata, which should finish very +# quickly +$BTRFS_UTIL_PROG balance start -m "$SCRATCH_MNT" >> $seqres.full + +echo "Silence is golden" + +# success, all done +status=0 +exit
tests/btrfs/213.out new file +2 -0
@@ -0,0 +1,2 @@ +QA output created by 213 +Silence is golden
tests/btrfs/group +1 -0
@@ -215,3 +215,4 @@ 210 auto quick qgroup snapshot 211 auto quick log prealloc 212 auto balance dangerous +213 auto fast balance dangerous
Signature · 1 line
2.26.2
Quoted 65 lines · Qu Wenruo
Test if canceling a running balance can cause later balance to dead loop.
The ifx is titled "btrfs: relocation: Clear the
DEAD_RELOC_TREEbit for
orphan roots to prevent runaway balance".Signed-off-by Qu Wenruo <[email protected]>---
Changelog:
v2:
- Remove debugging command--- tests/btrfs/213 | 65 +++++++++++++++++++++++++++++++++++++++++++++ tests/btrfs/213.out | 2 ++ tests/btrfs/group | 1 + 3 files changed, 68 insertions(+) create mode 100755 tests/btrfs/213 create mode 100644 tests/btrfs/213.outtests/btrfs/213 new file +40
-0@@ -0,0 +1,65 @@ +#! /bin/bash +# SPDX-License-Identifier: GPL-2.0 +# Copyright (C) 2020 SUSE Linux Products GmbH. All Rights Reserved. +# +# FS QA Test 213 +# +# Test if canceling a running balance can lead to dead looping balance +# +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 + +# Modify as appropriate. +_supported_fs btrfs +_supported_os Linux +_require_scratch +_require_command "$KILLALL_PROG" killall + +_scratch_mkfs >> $seqres.full +_scratch_mount + +runtime=4
tests/btrfs/213 line 50
Quoted 10 lines
tests/btrfs/213 new file +10
-0+ +# Create enough IO so that we need around $runtime seconds to relocate it +dd if=/dev/zero bs=1M of="$SCRATCH_MNT/file" oflag=sync status=none \ + &> /dev/null & +dd_pid=$! +sleep $runtime +"$KILLALL_PROG" -q dd &> /dev/null +wait $dd_pid + +ps aux >> $seqres.full
nit: Do we really need the list of all processes in the log? I don't think so.
Quoted 33 lines
tests/btrfs/213 new file +15
-0+# Now balance should take at least $runtime seconds, we can cancel it at +# $runtime/2 to ensure a success cancel. +$BTRFS_UTIL_PROG balance start -d --bg "$SCRATCH_MNT" +sleep $(($runtime / 2)) +$BTRFS_UTIL_PROG balance cancel "$SCRATCH_MNT" + +# Now check if we can finish relocating metadata, which should finish very +# quickly +$BTRFS_UTIL_PROG balance start -m "$SCRATCH_MNT" >> $seqres.full + +echo "Silence is golden" + +# success, all done +status=0 +exittests/btrfs/213.out new file +2
-0@@ -0,0 +1,2 @@ +QA output created by 213 +Silence is goldentests/btrfs/group +1
-0@@ -215,3 +215,4 @@ 210 auto quick qgroup snapshot 211 auto quick log prealloc 212 auto balance dangerous +213 auto fast balance dangerous