xref: /freebsd/tools/test/stress2/misc/graid1_7.sh (revision 43a5ec4eb41567cc92586503212743d89686d78f)
1#!/bin/sh
2
3#
4# Copyright (c) 2017 Dell EMC Isilon
5# All rights reserved.
6#
7# Redistribution and use in source and binary forms, with or without
8# modification, are permitted provided that the following conditions
9# are met:
10# 1. Redistributions of source code must retain the above copyright
11#    notice, this list of conditions and the following disclaimer.
12# 2. Redistributions in binary form must reproduce the above copyright
13#    notice, this list of conditions and the following disclaimer in the
14#    documentation and/or other materials provided with the distribution.
15#
16# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26# SUCH DAMAGE.
27#
28
29# Component looses it's name:
30# g_dev_taste: make_dev_p() failed
31# (gp->name=gptid/7c598e03-19cb-11e7-b62b-001e6756c168, error=17)
32
33# Deadlock seen:
34# https://people.freebsd.org/~pho/stress/log/graid1_7.txt
35
36[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
37
38. ../default.cfg
39
40gmirror load > /dev/null 2>&1 && unload=1
41[ -c /dev/mirror/test ] && { gmirror stop test; gmirror destroy test; }
42old=`sysctl -n kern.geom.mirror.debug`
43sysctl kern.geom.mirror.debug=-1 | grep -q -- -1 ||
44    sysctl kern.geom.mirror.debug=$old > /dev/null
45
46u1=$mdstart
47s=0
48[ -c /dev/md$u1 ] && mdconfig -d -u $u1
49mdconfig -a -t swap -s 1g -u $u1
50
51set -e
52(
53gpart create -s GPT md$u1
54gpart add -t freebsd-ufs -s 341m md$u1
55gpart add -t freebsd-ufs -s 341m md$u1
56gpart add -t freebsd-ufs -s 341m md$u1
57) > /dev/null
58gmirror label test md${u1}p1 md${u1}p2 md${u1}p3
59[ "`sysctl -in kern.geom.mirror.launch_mirror_before_timeout`" = "0" ] &&
60    sleep $((`sysctl -n kern.geom.mirror.timeout` + 1))
61[ -c /dev/mirror/test ] || exit 1
62
63newfs /dev/mirror/test > /dev/null
64mount /dev/mirror/test $mntpoint
65set +e
66chmod 777 $mntpoint
67
68export runRUNTIME=5m
69export RUNDIR=$mntpoint/stressX
70rm -rf /tmp/stressX.control
71
72su $testuser -c 'cd ..; ./run.sh io.cfg' > /dev/null 2>&1 &
73pid=$!
74
75mlog=/tmp/graid1_6.log
76tail -F -n 0 /var/log/messages > $mlog & mpid=$!
77sleep 2
78cont=/tmp/graid1_7.cont
79touch $cont
80for i in `jot 8`; do
81	while [ -f $cont ]; do
82		for u in md${u1}p2 md${u1}p3; do
83			gmirror forget test
84			gmirror remove test $u
85			gmirror insert test $u
86			id=`gmirror status test | grep gptid | awk '{print $1}'`
87			if [ $i -eq 1 -a -n "$id" ]; then
88				echo "FAIL Remove component $id"
89				gmirror remove test $id
90			fi
91		done 2>/dev/null
92	done &
93done
94while kill -0 $pid 2>/dev/null; do sleep 5; done
95rm $cont
96wait $!
97gmirror status test | grep -qw md${u1}p2 || gmirror insert test md${u1}p2
98gmirror status test | grep -qw md${u1}p3 || gmirror insert test md${u1}p3
99i=0
100while ! gmirror status test | grep -q COMPLETE; do
101	sleep 5
102	if [ $((i += 1)) -gt 20 ]; then
103		echo "FAIL to COMPLETE"
104		gmirror status test
105		s=1
106		break
107	fi
108done
109
110while mount | grep $mntpoint | grep -q /mirror/; do
111	umount $mntpoint || sleep 5
112done
113checkfs /dev/mirror/test || s=2
114while gmirror status test | grep -q SYNCHRONIZING; do sleep 10; done
115for i in `jot 10`; do
116	gmirror stop test && break || sleep 30
117done
118[ $i -eq 10 ] && s=3
119gmirror destroy test 2>/dev/null
120[ $unload ] && gmirror unload
121
122mdconfig -d -u $mdstart || s=4
123grep -m 1 "check-hash" $mlog && s=5
124kill $mpid
125wait
126rm -f $mlog
127exit $s
128