summaryrefslogtreecommitdiffstats
path: root/tests/24raid456deadlock
blob: 80e6e97ec0c0a5d32308209cf676605cda241032 (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
devs="$dev0 $dev1 $dev2 $dev3 $dev4 $dev5"
runtime=120
pid=""
old=`cat /proc/sys/vm/dirty_background_ratio`

test_write_action()
{
	while true; do
		echo check > /sys/block/md0/md/sync_action &> /dev/null
		sleep 0.1
		echo idle > /sys/block/md0/md/sync_action &> /dev/null
	done
}

test_write_back()
{
	fio -filename=$md0 -bs=4k -rw=write -numjobs=1 -name=test \
		-time_based -runtime=$runtime &> /dev/null
}

set_up_test()
{
	fio -h &> /dev/null || die "fio not found"

	# create a simple raid6
	mdadm -Cv -R -n 6 -l6 $md0 $devs --assume-clean || die "create raid6 failed"

	# trigger dirty pages write back
	echo 0 > /proc/sys/vm/dirty_background_ratio
}

clean_up_test()
{
	echo $old > /proc/sys/vm/dirty_background_ratio

	pkill -9 fio
	kill -9 $pid

	sleep 1

	if ps $pid | tail -1 | awk '{print $3}' | grep D; then
		die "thread that is writing sysfs is stuck in D state, deadlock is triggered"
	fi
	mdadm -S $md0
}

trap 'clean_up_test' EXIT

set_up_test || die "set up test failed"

test_write_back &

test_write_action &
pid="$!"

sleep $runtime

exit 0