xfs: Add test for too-small device with stripe geometry
[xfstests-dev.git] / tests / btrfs / 212
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 212
6 #
7 # Test if unmounting a fs with balance canceled can lead to crash.
8 # This needs CONFIG_BTRFS_DEBUG compiled, which adds extra unmount time self-test
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16 status=1        # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
18
19 _cleanup()
20 {
21         cd /
22         rm -f $tmp.*
23         kill $balance_pid &> /dev/null
24         kill $cancel_pid &> /dev/null
25         "$KILLALL_PROG" -q $FSSTRESS_PROG &> /dev/null
26         $BTRFS_UTIL_PROG balance cancel $SCRATCH_MNT &> /dev/null
27         wait
28 }
29
30 # get standard environment, filters and checks
31 . ./common/rc
32 . ./common/filter
33
34 # remove previous $seqres.full before test
35 rm -f $seqres.full
36
37 # real QA test starts here
38
39 # Modify as appropriate.
40 _supported_fs btrfs
41 _require_scratch
42 _require_command "$KILLALL_PROG" killall
43
44 _scratch_mkfs >> $seqres.full
45 _scratch_mount
46
47 runtime=15
48
49 balance_workload()
50 {
51         trap "wait; exit" SIGTERM
52         while true; do
53                 _run_btrfs_balance_start &> /dev/null
54         done
55 }
56
57 cancel_workload()
58 {
59         trap "wait; exit" SIGTERM
60         while true; do
61                 $BTRFS_UTIL_PROG balance cancel $SCRATCH_MNT &> /dev/null
62                 sleep 2
63         done
64 }
65
66 $FSSTRESS_PROG -d $SCRATCH_MNT -w -n 100000  >> $seqres.full 2>/dev/null &
67 balance_workload &
68 balance_pid=$!
69
70 cancel_workload &
71 cancel_pid=$!
72
73 sleep $runtime
74
75 kill $balance_pid
76 kill $cancel_pid
77 "$KILLALL_PROG" -q $FSSTRESS_PROG &> /dev/null
78 $BTRFS_UTIL_PROG balance cancel $SCRATCH_MNT &> /dev/null
79 wait
80
81 echo "Silence is golden"
82 # success, all done
83 status=0
84 exit