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.
35 _require_xfs_io_command pwrite -D
37 _scratch_mkfs >> $seqres.full
42 # Create enough IO so that we need around $runtime seconds to relocate it.
44 # Here we don't want any wrapper, as we want full control of the process.
45 $XFS_IO_PROG -f -c "pwrite -D -b 1M 0 1024T" "$SCRATCH_MNT/file" &> /dev/null &
51 # Now balance should take at least $runtime seconds, we can cancel it at
52 # $runtime/2 to ensure a success cancel.
53 _run_btrfs_balance_start -d --bg "$SCRATCH_MNT"
54 sleep $(($runtime / 2))
55 $BTRFS_UTIL_PROG balance cancel "$SCRATCH_MNT"
57 # Now check if we can finish relocating metadata, which should finish very
59 $BTRFS_UTIL_PROG balance start -m "$SCRATCH_MNT" >> $seqres.full
61 echo "Silence is golden"