fstests: move test group info to test files
[xfstests-dev.git] / tests / btrfs / 213
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2020 SUSE Linux Products GmbH. All Rights Reserved.
4 #
5 # FS QA Test 213
6 #
7 # Test if canceling a running balance can lead to dead looping balance
8 #
9 . ./common/preamble
10 _begin_fstest auto balance dangerous
11
12 # Override the default cleanup function.
13 _cleanup()
14 {
15         cd /
16         kill $write_pid &> /dev/null
17         rm -f $tmp.*
18 }
19
20 # Import common functions.
21 . ./common/filter
22
23 # Modify as appropriate.
24 _supported_fs btrfs
25 _require_scratch
26 _require_xfs_io_command pwrite -D
27
28 _scratch_mkfs >> $seqres.full
29 _scratch_mount
30
31 runtime=4
32
33 # Create enough IO so that we need around $runtime seconds to relocate it.
34 #
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 &
37 write_pid=$!
38 sleep $runtime
39 kill $write_pid
40 wait $write_pid
41
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"
47
48 # Now check if we can finish relocating metadata, which should finish very
49 # quickly.
50 $BTRFS_UTIL_PROG balance start -m "$SCRATCH_MNT" >> $seqres.full
51
52 echo "Silence is golden"
53
54 # success, all done
55 status=0
56 exit