1#!/bin/sh 2 3# 4# Copyright (c) 2017 Dell EMC Isilon 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# Copy of crossmp3.sh + elements from dfull.sh 30 31# Live lock seen: 32# https://people.freebsd.org/~pho/stress/log/crossmp11.txt 33 34# umount stuck in mnt_ref seen: 35# https://people.freebsd.org/~pho/stress/log/kostik1002.txt 36 37# Fixed by r319518, r319519 and r319539. 38 39[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 40 41. ../default.cfg 42 43g3=$((3 * 1024 * 1024 * 1024)) 44CONT=/tmp/crossmp11.continue 45N=`sysctl -n hw.ncpu` 46[ $N -gt 4 ] && N=4 47usermem=`sysctl -n hw.usermem` 48[ $usermem -gt $g3 ] && usermem=$g3 49[ `sysctl -n vm.swap_total` -eq 0 ] && usermem=$((usermem/100*80)) 50size=$((usermem / 1024 / 1024 / N)) 51 52mounts=$N # Number of parallel scripts 53 54if [ $# -eq 0 ]; then 55 echo "Expect: 56 /mnt6: write failed, filesystem is full 57 /mnt6: create/symlink failed, no inodes free" 58 59 for i in `jot $mounts`; do 60 m=$(( i + mdstart - 1 )) 61 [ ! -d ${mntpoint}$m ] && 62 { mkdir ${mntpoint}$m; chmod 755 ${mntpoint}$m; } 63 mount | grep "${mntpoint}$m " | grep -q md$m && umount ${mntpoint}$m 64 mdconfig -l | grep -q md$m && mdconfig -d -u $m 65 66 mdconfig -a -t swap -s ${size}m -u $m 67 newfs $newfs_flags md${m} > /dev/null 2>&1 68 done 69 70 # start the parallel tests 71 touch $CONT 72 for i in `jot $mounts`; do 73 m=$(( i + mdstart - 1 )) 74 ./$0 $m & 75 ./$0 find & 76 done 77 78 wait 79 80 for i in `jot $mounts`; do 81 m=$(( i + mdstart - 1 )) 82 while mount | grep -q "on ${mntpoint}$m "; do 83 umount ${mntpoint}$m && break 84 sleep 1 85 done 86 mdconfig -d -u $m 87 done 88 exit 0 89else 90 if [ $1 = find ]; then 91 while [ -f $CONT ]; do 92 find ${mntpoint}* -type f > /dev/null 2>&1 93 done 94 else 95 m=$1 96 export runRUNTIME=20s 97 # The test: Parallel mount and unmounts 98 for i in `jot 3`; do 99 mount /dev/md${m} ${mntpoint}$m && 100 chmod 777 ${mntpoint}$m 101 export RUNDIR=${mntpoint}$m/stressX 102 export CTRLDIR=${mntpoint}$m/stressX.control 103 (cd ${mntpoint}$m && find . -delete) 104 if [ -z "$KBLOCKS" ]; then 105 r=`df -ik ${mntpoint}$m | tail -1 | awk '{print $4,$7}'` 106 export KBLOCKS=`echo $r | awk '{print $1 * 10}'` 107 export INODES=`echo $r | awk '{print $2 * 10}'` 108 fi 109 su $testuser -c 'cd ..; ./run.sh disk.cfg' > \ 110 /dev/null 2>&1 111 112 while mount | grep -q "on ${mntpoint}$m "; do 113 opt=$([ $((`date '+%s'` % 2)) -eq 0 ] && echo "-f") 114 umount $opt ${mntpoint}$m > /dev/null 2>&1 115 [ -f $CONT ] || break 2 116 done 117 done 118 rm -f $CONT 119 fi 120fi 121