1#!/bin/sh 2 3# 4# Copyright (c) 2014 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# Parallel mount and umount of file systems 30# "panic: Bad link elm 0xfffff8052a20cc00 prev->next != elm" seen: 31# http://people.freebsd.org/~pho/stress/log/crossmp3.txt 32# Fixed in r269853 33 34# panic: softdep_waitidle: work added after flush: 35# http://people.freebsd.org/~pho/stress/log/crossmp3-2.txt, fixed by r273967. 36 37[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 38 39. ../default.cfg 40 41CONT=/tmp/crossmp3.continue 42if [ $# -eq 0 ]; then 43 N=`sysctl -n hw.ncpu` 44 [ $N -gt 32 ] && N=32 # Arbitrary cap 45 usermem=`sysctl -n hw.usermem` 46 [ `sysctl -n vm.swap_total` -eq 0 ] && usermem=$((usermem / 2)) 47 size=$((usermem / 1024 / 1024 / N)) 48 echo "Using $N memory disks of size $size MB." 49 50 mounts=$N # Number of parallel scripts 51 52 for i in `jot $mounts`; do 53 m=$(( i + mdstart - 1 )) 54 [ ! -d ${mntpoint}$m ] && 55 { mkdir ${mntpoint}$m; chmod 755 ${mntpoint}$m; } 56 mount | grep "${mntpoint}$m " | grep -q md$m && 57 umount ${mntpoint}$m 58 mdconfig -l | grep -q md$m && mdconfig -d -u $m 59 60 mdconfig -a -t swap -s ${size}m -u $m 61 newfs $newfs_flags md${m} > /dev/null 2>&1 62 done 63 64 # start the parallel tests 65 touch $CONT 66 for i in `jot $mounts`; do 67 m=$(( i + mdstart - 1 )) 68 ./$0 $m & 69 ./$0 find & 70 done 71 wait 72 73 for i in `jot $mounts`; do 74 m=$(( i + mdstart - 1 )) 75 while mount | grep -q "on ${mntpoint}$m "; do 76 umount ${mntpoint}$m && break 77 sleep 1 78 done 79 mdconfig -d -u $m 80 done 81 exit 0 82else 83 if [ $1 = find ]; then 84 while [ -f $CONT ]; do 85 find ${mntpoint}* -type f > /dev/null 2>&1 86 done 87 else 88 export runRUNTIME=20s 89 # The test: Parallel mount and unmounts 90 start=`date +%s` 91 for i in `jot 3`; do 92 m=$1 93 mount /dev/md${m} ${mntpoint}$m && 94 chmod 777 ${mntpoint}$m 95 export RUNDIR=${mntpoint}$m/stressX 96 export CTRLDIR=${mntpoint}$m/stressX.control 97 (cd ${mntpoint}$m && find . -delete) 98 su $testuser -c 'cd ..; ./run.sh disk.cfg' > \ 99 /dev/null 2>&1 100 101 while mount | grep -q "on ${mntpoint}$m "; do 102 opt=$([ $((`date '+%s'` % 2)) -eq 0 ] && echo "-f") 103 umount $opt ${mntpoint}$m > /dev/null 2>&1 104 [ -f $CONT ] || break 2 105 done 106 [ $((`date +%s` - start)) -gt 600 ] && 107 { echo "Timed out"; s=1; } 108 done 109 rm -f $CONT 110 fi 111 exit $s 112fi 113