xref: /freebsd/tools/test/stress2/misc/unionfs8.sh (revision f374ba41)
1#!/bin/sh
2
3#
4# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
5#
6# Copyright (c) 2021 Peter Holm
7#
8# Redistribution and use in source and binary forms, with or without
9# modification, are permitted provided that the following conditions
10# are met:
11# 1. Redistributions of source code must retain the above copyright
12#    notice, this list of conditions and the following disclaimer.
13# 2. Redistributions in binary form must reproduce the above copyright
14#    notice, this list of conditions and the following disclaimer in the
15#    documentation and/or other materials provided with the distribution.
16#
17# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27# SUCH DAMAGE.
28#
29
30# unionfs(8) test with a cd9660 file system
31
32# "panic: unionfs_noderem: vnode 0xfffffe014f9259c8 locked recursively" seen
33# https://people.freebsd.org/~pho/stress/log/log0233.txt
34
35[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
36[ -z "`type mkisofs 2>/dev/null`" ] &&
37    { echo "cdrtools not installed"; exit 0; }
38. ../default.cfg
39
40I=`dirname $diskimage`/unionfs8.iso
41md1=$mdstart
42md2=$((md1 + 1))
43mp1=/mnt$md1
44mp2=/mnt$md2
45mkdir -p $mp1 $mp2
46set -e
47for i in $mp1 $mp2; do
48	mount | grep -q "on $i " && umount -f $i
49done
50for i in $md1 $md2; do
51	mdconfig -l | grep -q md$i && mdconfig -d -u $i
52done
53
54mdconfig -a -t swap -s 5g -u $md1
55mdconfig -a -t swap -s 5g -u $md2
56newfs $newfs_flags -n md$md1 > /dev/null
57newfs $newfs_flags -n md$md2 > /dev/null
58mount /dev/md$md1 $mp1
59cp -r ../../stress2 $mp1
60mkisofs -o $I -r $mp1 > /dev/null 2>&1
61umount $mp1
62mdconfig -d -u $md1
63mdconfig -a -t vnode -f $I -u $md1
64mount -t cd9660 /dev/md$mdstart $mp1
65mount /dev/md$md2 $mp2
66chmod 777 $mp2
67
68mount -t unionfs -o below $mp1 $mp2
69set +e
70mount | grep -E "$mp1|$mp2"
71
72set `df -ik $mp2 | tail -1 | awk '{print $4,$7}'`
73export KBLOCKS=$(($1 / 6))
74export INODES=$(($2 / 6))
75
76export CTRLDIR=$mp2/stressX.control
77export INCARNATIONS=10
78export LOAD=80
79export RUNDIR=$mp2/stressX
80export runRUNTIME=5m
81export rwLOAD=80
82export symlinkLOAD=80
83
84export TESTPROGS="
85testcases/lockf2/lockf2
86testcases/symlink/symlink
87testcases/openat/openat
88testcases/rw/rw
89testcases/fts/fts
90testcases/link/link
91testcases/lockf/lockf
92testcases/creat/creat
93testcases/mkdir/mkdir
94testcases/rename/rename
95testcases/mkfifo/mkfifo
96testcases/dirnprename/dirnprename
97testcases/dirrename/dirrename
98testcases/swap/swap
99"
100
101export TESTPROGS=`echo $TESTPROGS | sed 's/\n/ /g'`
102
103set +e
104su $testuser -c \
105	"(cd $mp2/stress2; ./testcases/run/run $TESTPROGS)"
106
107n=`find $mp2/stressX 2>/dev/null | wc -l`
108[ $n -eq 1 ] && s=0 || { find $mp2/stressX -ls 2>/dev/null | head -12; s=1; }
109
110while mount | grep "on $mp2" | grep -q unionfs; do
111	umount $mp2 && break
112done
113for i in `jot 5`; do
114	umount $mp2 && break
115	sleep .5
116done
117for i in `jot 5`; do
118	umount $mp1 && break
119	sleep .5
120done
121mdconfig -d -u $md2
122mdconfig -d -u $md1
123rm -f $I
124exit $s
125