1#!/bin/sh 2 3# 4# SPDX-License-Identifier: BSD-2-Clause 5# 6# Copyright (c) 2023 Peter Holm <pho@FreeBSD.org> 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# Parallel mount and umount test of file mounts, 31# mounting over non-directories 32 33# panic: free: address 0xffffffff80b229b4 ... has not been allocated 34# https://people.freebsd.org/~pho/stress/log/log0454.txt 35 36[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 37. ../default.cfg 38 39cont=/tmp/nullfs30.continue 40mounts=3 # Number of parallel scripts 41 42set -eu 43md1=$mdstart 44md2=$((md1 + 1)) 45mp1=$mntpoint$md1 46mp2=$mntpoint$md2 47mkdir -p $mp1 $mp2 48 49mdconfig -a -t swap -s 256m -u $md1 50newfs $newfs_flags -n md$md1 > /dev/null 51mount /dev/md$md1 $mp1 52mdconfig -a -t swap -s 256m -u $md2 53newfs $newfs_flags -n md$md2 > /dev/null 54mount /dev/md$md2 $mp2 55 56for i in `jot $mounts`; do 57 cp /etc/group $mp1/f$i 58 touch $mp2/m$i 59done 60set +e 61 62mount -t nullfs $mp1/f1 $mp2/m1 || { 63 umount $mp2 64 umount $mp1 65 mdconfig -d -u $md2 66 mdconfig -d -u $md1 67 echo "File mount not implemented" 68 exit 0 69} 70 71(cd ../testcases/swap; ./swap -t 5m -i 20 > /dev/null) & 72 73# Start the parallel tests 74touch $cont 75while [ -f $cont ]; do 76 while mount | grep -q "on $mp2/m1 "; do umount $mp2/m1; done 2> /dev/null 77 mount -t nullfs $mp1/f1 $mp2/m1 78done & 79while [ -f $cont ]; do 80 while mount | grep -q "on $mp2/m2 "; do umount $mp2/m2; done 2> /dev/null 81 mount -t nullfs $mp1/f2 $mp2/m2 82done & 83while [ -f $cont ]; do 84 while mount | grep -q "on $mp2/m3 "; do umount $mp2/m3; done 2> /dev/null 85 mount -t nullfs $mp1/f3 $mp2/m3 86done & 87 88start=`date +%s` 89while [ $((`date +%s` - start)) -lt 300 ]; do 90 cat $mp2/m1 $mp2/m2 $mp2/m3 > /dev/null 91done 92rm -f $cont 93while pgrep -q swap; do pkill swap; done 94wait 95 96for i in 1 2 3; do 97 while mount | grep -q "on $mp2/m$i "; do umount $mp2/m$i; done 2> /dev/null 98done 99 100# Check error handling 101mount -t nullfs $mp1/f1 $mp2/m1 102mount -t nullfs $mp1/f1 $mp2/m1 2>/dev/null && s=1 || s=0 103while mount | grep -q "on $mp2/m1 "; do umount $mp2/m1; done 2> /dev/null 104 105mkdir $mp2/dir 106mount -t nullfs $mp1/f1 $mp2/dir 2>/dev/null && s=2 107 108umount $mp2 109umount $mp1 110mdconfig -d -u $md2 111mdconfig -d -u $md1 112exit $s 113