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 _begin_fstest auto balance dangerous
12 # Override the default cleanup function.
16 kill $write_pid &> /dev/null
20 # Import common functions.
23 # Modify as appropriate.
26 _require_xfs_io_command pwrite -D
28 _scratch_mkfs >> $seqres.full
33 # Create enough IO so that we need around $runtime seconds to relocate it.
35 # Here we don't want any wrapper, as we want full control of the process.
36 $XFS_IO_PROG -f -c "pwrite -D -b 1M 0 1024T" "$SCRATCH_MNT/file" &> /dev/null &
42 # Now balance should take at least $runtime seconds, we can cancel it at
43 # $runtime/2 to ensure a success cancel.
44 _run_btrfs_balance_start -d --bg "$SCRATCH_MNT"
45 sleep $(($runtime / 2))
46 $BTRFS_UTIL_PROG balance cancel "$SCRATCH_MNT"
48 # Now check if we can finish relocating metadata, which should finish very
50 $BTRFS_UTIL_PROG balance start -m "$SCRATCH_MNT" >> $seqres.full
52 echo "Silence is golden"