xfs: Add test for too-small device with stripe geometry
[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 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 tmp=/tmp/$$
15 status=1        # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
17
18 _cleanup()
19 {
20         cd /
21         kill $write_pid &> /dev/null
22         rm -f $tmp.*
23 }
24
25 # get standard environment, filters and checks
26 . ./common/rc
27 . ./common/filter
28
29 # remove previous $seqres.full before test
30 rm -f $seqres.full
31
32 # Modify as appropriate.
33 _supported_fs btrfs
34 _require_scratch
35 _require_xfs_io_command pwrite -D
36
37 _scratch_mkfs >> $seqres.full
38 _scratch_mount
39
40 runtime=4
41
42 # Create enough IO so that we need around $runtime seconds to relocate it.
43 #
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 &
46 write_pid=$!
47 sleep $runtime
48 kill $write_pid
49 wait $write_pid
50
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"
56
57 # Now check if we can finish relocating metadata, which should finish very
58 # quickly.
59 $BTRFS_UTIL_PROG balance start -m "$SCRATCH_MNT" >> $seqres.full
60
61 echo "Silence is golden"
62
63 # success, all done
64 status=0
65 exit