]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - tools/test/stress2/misc/pfl2.sh
libedit: vendor import snapshot 2020-07-10
[FreeBSD/FreeBSD.git] / tools / test / stress2 / misc / pfl2.sh
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
41 md1=$mdstart
42 md2=$((mdstart + 1))
43 mp1=${mntpoint}$md1
44 mp2=${mntpoint}$md2
45 mkdir -p $mp1 $mp2
46
47 usermem=`sysctl -n hw.usermem`
48 size=$((2 * 1024 * 1024 * 1024))        # Ideal disk size is 2G
49 [ $((size * 2)) -gt $usermem ] && size=$((usermem / 2))
50 size=$((size / 1024 / 1024))
51
52 opt=$([ $((`date '+%s'` % 2)) -eq 0 ] && echo "-j" || echo "-U")
53 [ "$newfs_flags" = "-U" ] || opt=""
54 mount | grep "on $mp1 " | grep -q /dev/md && umount -f $mp1
55 mdconfig -l | grep -q md$md1 &&  mdconfig -d -u $md1
56 mdconfig -a -t swap -s ${size}m -u $md1
57 bsdlabel -w md$md1 auto
58 newfs $opt md${md1}$part > /dev/null
59 mount /dev/md${md1}$part $mp1
60 chmod 777 $mp1
61
62 mount | grep "on $mp2 " | grep -q /dev/md && umount -f $mp2
63 mdconfig -l | grep -q md$md2 &&  mdconfig -d -u $md2
64 mdconfig -a -t swap -s ${size}m -u $md2
65 bsdlabel -w md$md2 auto
66 newfs $opt md${md2}$part > /dev/null
67 mount /dev/md${md2}$part $mp2
68 chmod 777 $mp2
69
70 export runRUNTIME=10m
71 export RUNDIR=$mp1/stressX
72 export CTRLDIR=$mp1/stressX.control
73 export LOAD=80
74 export symlinkLOAD=80
75 export rwLOAD=80
76 export TESTPROGS="
77 testcases/lockf2/lockf2
78 testcases/symlink/symlink
79 testcases/openat/openat
80 testcases/rw/rw
81 testcases/fts/fts
82 testcases/link/link
83 testcases/lockf/lockf
84 testcases/creat/creat
85 testcases/mkdir/mkdir
86 testcases/rename/rename
87 testcases/mkfifo/mkfifo
88 "
89 su $testuser -c 'cd ..; ./testcases/run/run $TESTPROGS' > /dev/null 2>&1 &
90
91 export TESTPROGS="$TESTPROGS testcases/swap/swap"
92 export RUNDIR=$mp2/stressX
93 export CTRLDIR=$mp2/stressX.control
94 su $testuser -c 'cd ..; ./testcases/run/run $TESTPROGS' > /dev/null 2>&1 &
95 wait
96
97 while mount | grep "$mp2 " | grep -q /dev/md; do
98         umount $mp2 || sleep 1
99 done
100 mdconfig -d -u $md2
101 while mount | grep "$mp1 " | grep -q /dev/md; do
102         umount $mp1 || sleep 1
103 done
104 mdconfig -d -u $md1