summaryrefslogtreecommitdiff
path: root/tests/btrfs/212
blob: 71337722b5bf92c4659f5193e4774d052f7aa930 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2020 SUSE Linux Products GmbH. All Rights Reserved.
#
# FS QA Test 212
#
# Test if unmounting a fs with balance canceled can lead to crash.
# This needs CONFIG_BTRFS_DEBUG compiled, which adds extra unmount time self-test
#
. ./common/preamble
_begin_fstest auto balance dangerous

# Override the default cleanup function.
_cleanup()
{
	cd /
	rm -f $tmp.*
	kill $balance_pid &> /dev/null
	kill $cancel_pid &> /dev/null
	"$KILLALL_PROG" -q $FSSTRESS_PROG &> /dev/null
	$BTRFS_UTIL_PROG balance cancel $SCRATCH_MNT &> /dev/null
	wait
}

. ./common/filter

_supported_fs btrfs
_require_scratch
_require_command "$KILLALL_PROG" killall

_scratch_mkfs >> $seqres.full
_scratch_mount

runtime=15

balance_workload()
{
	trap "wait; exit" SIGTERM
	while true; do
		_run_btrfs_balance_start &> /dev/null
	done
}

cancel_workload()
{
	trap "wait; exit" SIGTERM
	while true; do
		$BTRFS_UTIL_PROG balance cancel $SCRATCH_MNT &> /dev/null
		sleep 2
	done
}

$FSSTRESS_PROG -d $SCRATCH_MNT -w -n 100000  >> $seqres.full 2>/dev/null &
balance_workload &
balance_pid=$!

cancel_workload &
cancel_pid=$!

sleep $runtime

kill $balance_pid
kill $cancel_pid
"$KILLALL_PROG" -q $FSSTRESS_PROG &> /dev/null
$BTRFS_UTIL_PROG balance cancel $SCRATCH_MNT &> /dev/null
wait

echo "Silence is golden"
# success, all done
status=0
exit