xref: /freebsd/tools/test/stress2/misc/pfl2.sh (revision 59c8e88e72633afbc47a4ace0d2170d00d51f7dc)
1#!/bin/sh
2
3#
4# Copyright (c) 2013 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[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
30
31# Test scenario for the change of a global SU lock to a per filesystem lock.
32# "panic: softdep_write_inodeblock: indirect pointer #0 mismatch ..." seen.
33# http://people.freebsd.org/~pho/stress/log/kirk063.txt
34
35# https://people.freebsd.org/~pho/stress/log/kirk080.txt
36
37. ../default.cfg
38
39[ `swapinfo | wc -l` -eq 1 ] && exit 0
40
41md1=$mdstart
42md2=$((mdstart + 1))
43mp1=${mntpoint}$md1
44mp2=${mntpoint}$md2
45mkdir -p $mp1 $mp2
46
47usermem=`sysctl -n hw.usermem`
48size=$((2 * 1024 * 1024 * 1024))	# Ideal disk size is 2G
49[ $((size * 2)) -gt $usermem ] && size=$((usermem / 2))
50size=$((size / 1024 / 1024))
51
52opt=$([ $((`date '+%s'` % 2)) -eq 0 ] && echo "-j" || echo "-U")
53[ "$newfs_flags" = "-U" ] || opt=""
54mount | grep "on $mp1 " | grep -q /dev/md && umount -f $mp1
55mdconfig -l | grep -q md$md1 &&  mdconfig -d -u $md1
56mdconfig -a -t swap -s ${size}m -u $md1
57newfs $opt md${md1} > /dev/null
58mount /dev/md${md1} $mp1
59chmod 777 $mp1
60
61mount | grep "on $mp2 " | grep -q /dev/md && umount -f $mp2
62mdconfig -l | grep -q md$md2 &&  mdconfig -d -u $md2
63mdconfig -a -t swap -s ${size}m -u $md2
64newfs $opt md${md2} > /dev/null
65mount /dev/md${md2} $mp2
66chmod 777 $mp2
67
68export runRUNTIME=10m
69export RUNDIR=$mp1/stressX
70export CTRLDIR=$mp1/stressX.control
71export LOAD=80
72export symlinkLOAD=80
73export rwLOAD=80
74export TESTPROGS="
75testcases/lockf2/lockf2
76testcases/symlink/symlink
77testcases/openat/openat
78testcases/rw/rw
79testcases/fts/fts
80testcases/link/link
81testcases/lockf/lockf
82testcases/creat/creat
83testcases/mkdir/mkdir
84testcases/rename/rename
85testcases/mkfifo/mkfifo
86"
87su $testuser -c 'cd ..; ./testcases/run/run $TESTPROGS' > /dev/null 2>&1 &
88
89export TESTPROGS="$TESTPROGS testcases/swap/swap"
90export RUNDIR=$mp2/stressX
91export CTRLDIR=$mp2/stressX.control
92su $testuser -c 'cd ..; ./testcases/run/run $TESTPROGS' > /dev/null 2>&1 &
93wait
94
95while mount | grep "$mp2 " | grep -q /dev/md; do
96	umount $mp2 || sleep 1
97done
98mdconfig -d -u $md2
99while mount | grep "$mp1 " | grep -q /dev/md; do
100	umount $mp1 || sleep 1
101done
102mdconfig -d -u $md1
103