xref: /freebsd/tools/test/stress2/misc/crossmp8.sh (revision e32fecd0c2c3ee37c47ee100f169e7eb0282a873)
1#!/bin/sh
2
3#
4# Copyright (c) 2015 EMC Corp.
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# Variation of crossmp3.sh. fifos and sockets added to load.
30# Not really a cross mount point test, but a test of the old
31# non-directory use of the vnode v_un union.
32# mckusick@ suggested using fifos for this test.
33
34# "panic: mtx_lock() of spin mutex  @ ../kern/vfs_subr.c:512" seen.
35# https://people.freebsd.org/~pho/stress/log/crossmp8.txt
36# Fixed by r291671.
37
38[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
39
40. ../default.cfg
41
42CONT=/tmp/crossmp8.continue
43N=`sysctl -n hw.ncpu`
44usermem=`sysctl -n hw.usermem`
45[ `swapinfo | wc -l` -eq 1 ] && usermem=$((usermem/100*80))
46size=$((usermem / 1024 / 1024 / N))
47
48mounts=$N		# Number of parallel scripts
49
50if [ $# -eq 0 ]; then
51	oldmx=`sysctl -n kern.maxvnodes`
52	trap "sysctl kern.maxvnodes=$oldmx > /dev/null" EXIT SIGINT
53	sysctl kern.maxvnodes=3072 > /dev/null
54
55	for i in `jot $mounts`; do
56		m=$((i + mdstart - 1))
57		[ ! -d ${mntpoint}$m ] &&
58		    { mkdir ${mntpoint}$m;  chmod 755 ${mntpoint}$m; }
59		mount | grep "${mntpoint}$m " | grep -q md$m &&
60		    umount ${mntpoint}$m
61		mdconfig -l | grep -q md$m && mdconfig -d -u $m
62
63		mdconfig -a -t swap -s ${size}m -u $m
64		newfs md${m} > /dev/null 2>&1
65	done
66
67	# start the parallel tests
68	touch $CONT
69	for i in `jot $mounts`; do
70		m=$((i + mdstart - 1))
71		./$0 $m &
72		./$0 find &
73	done
74	sleep 60
75	rm -f $CONT
76	../tools/killall.sh
77	wait
78
79	for i in `jot $mounts`; do
80		m=$((i + mdstart - 1))
81		while mount | grep -q "on ${mntpoint}$m "; do
82		    umount ${mntpoint}$m && break
83		    sleep 1
84		done
85		mdconfig -d -u $m
86	done
87	./cleanup.sh
88	exit 0
89else
90	if [ $1 = find ]; then
91		while [ -f $CONT ]; do
92			find ${mntpoint}* -maxdepth 1 -ls > /dev/null 2>&1
93			sleep .1
94		done
95	else
96		export RUNTIME=15s
97		export runRUNTIME=15s
98		# The test: Parallel mount and unmounts
99		start=`date '+%s'`
100		while [ $((`date '+%s'` - start)) -lt 300 ]; do
101			m=$1
102			mount /dev/md${m} ${mntpoint}$m &&
103			   chmod 777 ${mntpoint}$m
104			export RUNDIR=${mntpoint}$m/stressX
105			export CTRLDIR=${mntpoint}$m/stressX.control
106			export mkfifoLOAD=80
107			export socketLOAD=80
108			export TP="
109			testcases/mkfifo/mkfifo
110			testcases/mkdir/mkdir
111			"
112			(cd ${mntpoint}$m && find . -delete)
113			su $testuser -c 'cd ..; ./testcases/run/run $TP' > \
114			    /dev/null 2>&1
115
116			while mount | grep -q "on ${mntpoint}$m "; do
117				opt=$([ $((`date '+%s'` % 2)) -eq 0 ] && echo "-f")
118				umount $opt ${mntpoint}$m > /dev/null 2>&1
119				[ -f $CONT ] || break 2
120			done
121		done
122		rm -f $CONT
123	fi
124fi
125