2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2020 SUSE Linux Products GmbH. All Rights Reserved.
7 # Test if canceling a running balance can lead to dead looping balance
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
15 status=1 # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
21 kill $write_pid &> /dev/null
25 # get standard environment, filters and checks
29 # remove previous $seqres.full before test
32 # Modify as appropriate.
36 _require_xfs_io_command pwrite -D
38 _scratch_mkfs >> $seqres.full
43 # Create enough IO so that we need around $runtime seconds to relocate it.
45 # Here we don't want any wrapper, as we want full control of the process.
46 $XFS_IO_PROG -f -c "pwrite -D -b 1M 0 1024T" "$SCRATCH_MNT/file" &> /dev/null &
52 # Now balance should take at least $runtime seconds, we can cancel it at
53 # $runtime/2 to ensure a success cancel.
54 _run_btrfs_balance_start -d --bg "$SCRATCH_MNT"
55 sleep $(($runtime / 2))
56 $BTRFS_UTIL_PROG balance cancel "$SCRATCH_MNT"
58 # Now check if we can finish relocating metadata, which should finish very
60 $BTRFS_UTIL_PROG balance start -m "$SCRATCH_MNT" >> $seqres.full
62 echo "Silence is golden"