diff --git a/tools/test/stress2/misc/crossmp.sh b/tools/test/stress2/misc/crossmp.sh index 0bd07cea2aaf..b61506dcc477 100755 --- a/tools/test/stress2/misc/crossmp.sh +++ b/tools/test/stress2/misc/crossmp.sh @@ -1,88 +1,89 @@ #!/bin/sh # # Copyright (c) 2008 Peter Holm # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # Parallel mount and umount of file systems [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg mounts=15 # Number of parallel scripts cont=/tmp/crossmp.continue mdstart=$mdstart # Use md unit numbers from this point D=$diskimage if [ $# -eq 0 ]; then touch $cont for i in `jot $mounts`; do m=$(( i + mdstart - 1 )) [ ! -d ${mntpoint}$m ] && mkdir ${mntpoint}$m mount | grep "on ${mntpoint}$m " | grep -q md$m && umount ${mntpoint}$m mdconfig -l | grep -q md$m && mdconfig -d -u $m dd if=/dev/zero of=$D$m bs=1m count=1 status=none mdconfig -a -t vnode -f $D$m -u $m newfs $newfs_flags md${m} > /dev/null 2>&1 done # start the parallel tests for i in `jot $mounts`; do m=$(( i + mdstart - 1 )) ./$0 $m & ./$0 find & done wait for i in `jot $mounts`; do m=$(( i + mdstart - 1 )) mdconfig -d -u $m rm -f $D$m done exit 0 else if [ $1 = find ]; then while [ -r $cont ]; do find ${mntpoint}* -type f > /dev/null 2>&1 done else # The test: Parallel mount and unmounts - for i in `jot 1024`; do + start=`date +%s` + while [ $((`date +%s`- start)) -lt 300 ]; do m=$1 mount /dev/md${m} ${mntpoint}$m while mount | grep -q "on ${mntpoint}$m "; do opt=$([ $((`date '+%s'` % 2)) -eq 0 ] && echo "-f") umount $opt ${mntpoint}$m > /dev/null 2>&1 done done rm -f $cont fi fi diff --git a/tools/test/stress2/misc/crossmp2.sh b/tools/test/stress2/misc/crossmp2.sh index 03cd04e077c1..1f2f1a921e10 100755 --- a/tools/test/stress2/misc/crossmp2.sh +++ b/tools/test/stress2/misc/crossmp2.sh @@ -1,86 +1,87 @@ #!/bin/sh # # Copyright (c) 2008 Peter Holm # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # NFS test [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg cont=/tmp/crossmp2.continue mounts=10 # Number of parallel scripts if [ $# -eq 0 ]; then [ -z "$nfs_export" ] && exit 0 ping -c 2 `echo $nfs_export | sed 's/:.*//'` > /dev/null 2>&1 || exit 0 touch $cont mount -t nfs -o tcp -o nfsv3 -o retrycnt=1 -o intr,soft,timeout=1 \ -o rw $nfs_export $mntpoint || exit 0 sleep .2 umount $mntpoint for i in `jot $mounts`; do mp=${mntpoint}$i [ ! -d $mp ] && mkdir $mp mount | grep -q "$mp " && umount $mp done # start the parallel tests for i in `jot $mounts`; do ./$0 $i & ./$0 find & done wait exit 0 else if [ $1 = find ]; then while [ -r $cont ]; do find ${mntpoint}* -maxdepth 1 -type f > \ /dev/null 2>&1 done else # The test: Parallel mount and unmounts - for i in `jot 128`; do + start=`date +%s` + while [ $((`date +%s`- start)) -lt 300 ]; do m=$1 mount -t nfs -o tcp -o nfsv3 -o retrycnt=3 \ -o intr,soft -o rw $nfs_export ${mntpoint}$m sleep .5 opt=`[ $(( m % 2 )) -eq 0 ] && echo -f` n=0 while mount | grep -q "${mntpoint}$m "; do umount $opt ${mntpoint}$m > /dev/null 2>&1 [ $((n += 1)) -gt 99 ] && umount -f \ ${mntpoint}$m > /dev/null 2>&1 [ $n -gt 100 ] && exit done done rm -f $cont fi fi diff --git a/tools/test/stress2/misc/crossmp5.sh b/tools/test/stress2/misc/crossmp5.sh index b5a8304f2dcb..038dea7ebe4f 100755 --- a/tools/test/stress2/misc/crossmp5.sh +++ b/tools/test/stress2/misc/crossmp5.sh @@ -1,94 +1,97 @@ #!/bin/sh # # Copyright (c) 2014 EMC Corp. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # Variation of crossmp3.sh [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg N=`sysctl -n hw.ncpu` usermem=`sysctl -n hw.usermem` [ `swapinfo | wc -l` -eq 1 ] && usermem=$((usermem/100*80)) size=$((usermem / 1024 / 1024 / N)) mounts=$N # Number of parallel scripts if [ $# -eq 0 ]; then for i in `jot $mounts`; do m=$(( i + mdstart - 1 )) [ ! -d ${mntpoint}$m ] && mkdir ${mntpoint}$m mount | grep "${mntpoint}$m " | grep -q md$m && umount ${mntpoint}$m mdconfig -l | grep -q md$m && mdconfig -d -u $m mdconfig -a -t swap -s ${size}m -u $m newfs $newfs_flags md${m} > /dev/null 2>&1 done # start the parallel tests for i in `jot $mounts`; do m=$(( i + mdstart - 1 )) ./$0 $m & ./$0 find & done wait for i in `jot $mounts`; do m=$(( i + mdstart - 1 )) mdconfig -d -u $m rm -f $D$m done exit 0 else touch /tmp/crossmp.continue if [ $1 = find ]; then while [ -f /tmp/crossmp.continue ]; do find ${mntpoint}* -type f > /dev/null 2>&1 done else # The test: Parallel mount and unmount + i=0 m=$1 - for i in `jot 200`; do + start=`date +%s` + while [ $((`date +%s`- start)) -lt 300 ]; do mount /dev/md${m} ${mntpoint}$m chmod 777 ${mntpoint}$m l=`jot -r 1 65535` dd if=/dev/zero of=$mntpoint/$i bs=$l count=100 \ status=none rm -f $mntpoint/$i while mount | grep -q "on ${mntpoint}$m "; do opt=$([ $((`date '+%s'` % 2)) -eq 0 ] && echo "-f") umount $opt ${mntpoint}$m > /dev/null 2>&1 done + i=$((i + 1)) done rm -f /tmp/crossmp.continue fi fi diff --git a/tools/test/stress2/misc/crossmp6.sh b/tools/test/stress2/misc/crossmp6.sh index 92ca0abcba27..d5abd27f99f1 100755 --- a/tools/test/stress2/misc/crossmp6.sh +++ b/tools/test/stress2/misc/crossmp6.sh @@ -1,103 +1,104 @@ #!/bin/sh # # Copyright (c) 2015 EMC Corp. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # Copy of crossmp2.sh: NFS test, with lockf(1) added. # "panic: vinvalbuf: dirty bufs" seen. # https://people.freebsd.org/~pho/stress/log/crossmp6.txt # Fixed by r283968. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg [ -z "$nfs_export" ] && exit 0 ping -c 2 `echo $nfs_export | sed 's/:.*//'` > /dev/null 2>&1 || exit 0 pgrep -q lockd || { echo "lockd not running."; exit 0; } CONT=/tmp/crossmp6.continue mounts=10 # Number of parallel scripts if [ $# -eq 0 ]; then [ -z "$nfs_export" ] && exit 0 ping -c 2 `echo $nfs_export | sed 's/:.*//'` > /dev/null 2>&1 || exit 0 mount -t nfs -o tcp -o nfsv3 -o retrycnt=1 -o soft,timeout=1 \ -o rw $nfs_export $mntpoint || exit 0 umount $mntpoint for i in `jot $mounts`; do mp=${mntpoint}$i [ ! -d $mp ] && mkdir $mp mount | grep -qw "$mp" && umount $mp done # start the parallel tests for i in `jot $mounts`; do ./$0 $i & ./$0 find $i & done wait mount -t nfs -o tcp -o nfsv3 -o retrycnt=1 -o soft,timeout=1 \ -o rw $nfs_export $mntpoint || exit 0 sleep .5 rm -f $mntpoint/$0.* umount $mntpoint rm -f $mntpoint*/$0.* exit 0 else if [ $1 = find ]; then - for i in `jot 128`; do + start=`date +%s` + while [ $((`date +%s`- start)) -lt 300 ]; do find ${mntpoint}* -maxdepth 1 -type f > \ /dev/null 2>&1 (lockf -t 10 ${mntpoint}$2/$0.$$.$i sleep 1 &) > \ /dev/null 2>&1 [ -f $CONT ] || break done wait else # The test: Parallel mount and unmounts start=`date '+%s'` while [ $((`date '+%s'` - start)) -lt 300 ]; do m=$1 mount -t nfs -o tcp -o nfsv3 -o retrycnt=3 \ -o soft -o rw $nfs_export ${mntpoint}$m sleep .5 opt=`[ $(( m % 2 )) -eq 0 ] && echo -f` n=0 while mount | grep -qw ${mntpoint}$m; do umount $opt ${mntpoint}$m > /dev/null 2>&1 n=$((n + 1)) [ $n -gt 99 ] && umount -f ${mntpoint}$m > \ /dev/null 2>&1 [ $n -gt 100 ] && exit done done rm -f $CONT fi fi diff --git a/tools/test/stress2/misc/crossmp7.sh b/tools/test/stress2/misc/crossmp7.sh index c2c2752f38e7..f4f12e64c35f 100755 --- a/tools/test/stress2/misc/crossmp7.sh +++ b/tools/test/stress2/misc/crossmp7.sh @@ -1,100 +1,101 @@ #!/bin/sh # # Copyright (c) 2015 EMC Corp. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # Parallel mount and umount of zfs file systems. # Page fault seen: # https://people.freebsd.org/~pho/stress/log/avg002.txt # Fixed by r309090. # Page fault seen: # https://people.freebsd.org/~pho/stress/log/crossmp7.txt # Fixed by r352437. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 [ `uname -m` = "i386" ] && exit 0 [ `sysctl -n kern.kstack_pages` -lt 4 ] && exit 0 . ../default.cfg mounts=15 # Number of parallel scripts if [ $# -eq 0 ]; then kldstat -v | grep -q zfs.ko || { kldload zfs.ko || exit 0; loaded=1; } zpool list | egrep -q "^stress2_tank" && zpool destroy stress2_tank u1=$mdstart u2=$((u1 + 1)) u3=$((u2 + 1)) [ -c /dev/md$u1 ] && mdconfig -d -u $u1 [ -c /dev/md$u2 ] && mdconfig -d -u $u2 [ -c /dev/md$u3 ] && mdconfig -d -u $u3 mdconfig -s 512m -u $u1 mdconfig -s 512m -u $u2 mdconfig -s 512m -u $u3 zpool create stress2_tank raidz md$u1 md$u2 md$u3 for i in `jot $mounts`; do zfs create stress2_tank/test$i zfs umount stress2_tank/test$i done # start the parallel tests touch /tmp/crossmp7.continue for i in `jot $mounts`; do ./$0 $i & ./$0 find & done wait zpool destroy stress2_tank [ -n "$loaded" ] && kldunload zfs.ko mdconfig -d -u $u1 mdconfig -d -u $u2 mdconfig -d -u $u3 exit 0 else if [ $1 = find ]; then while [ -f /tmp/crossmp7.continue ]; do find /stress2_tank -type f > /dev/null 2>&1 done else # The test: Parallel mount and unmounts m=$1 - for i in `jot 1024`; do + start=`date +%s` + while [ $((`date +%s`- start)) -lt 300 ]; do zfs mount stress2_tank/test$m zfs umount -f stress2_tank/test$m done 2>/dev/null rm -f /tmp/crossmp7.continue fi fi diff --git a/tools/test/stress2/misc/flock_open_close.sh b/tools/test/stress2/misc/flock_open_close.sh index 01e376319abe..39b894da8a63 100755 --- a/tools/test/stress2/misc/flock_open_close.sh +++ b/tools/test/stress2/misc/flock_open_close.sh @@ -1,172 +1,175 @@ #!/bin/sh # # Copyright (c) 2012 Peter Holm # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # Demonstrate that close() of an flock'd file is not atomic. # Fails with "flock_open_close: execv(/mnt/test): Text file busy" # Test scenario by: jhb [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg odir=`pwd` cd /tmp sed '1,/^EOF/d' < $odir/$0 > flock_open_close.c rm -f /tmp/flock_open_close mycc -o flock_open_close -Wall -Wextra -O2 -g flock_open_close.c -lpthread || exit 1 rm -f flock_open_close.c mount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart || exit 1 newfs $newfs_flags md$mdstart > /dev/null mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint cp /bin/test $mntpoint chown $testuser $mntpoint/test chmod +w $mntpoint/test su $testuser -c "/tmp/flock_open_close $mntpoint/test" & pid=$! while kill -0 $! 2>/dev/null; do mksnap_ffs $mntpoint $mntpoint/.snap/snap sleep 2 rm -f $mntpoint/.snap/snap sleep 1 done wait $pid s=$? for i in `jot 10`; do mount | grep -q md$mdstart && \ umount $mntpoint && mdconfig -d -u $mdstart && break sleep 2 done if mount | grep -q md$mdstart; then fstat $mntpoint echo "umount $mntpoint failed" exit 1 fi rm -f /tmp/flock_open_close exit $s EOF #include #include #include #include #include #include #include #include +#include #include static void usage(void) { fprintf(stderr, "Usage: flock_close_race [args]\n"); exit(1); } static void child(const char *binary) { int fd; /* Exit as soon as our parent exits. */ while (getppid() != 1) { fd = open(binary, O_RDWR | O_EXLOCK); if (fd < 0) { /* * This may get ETXTBSY since exit() will * close its open fd's (thus releasing the * lock), before it releases the vmspace (and * mapping of the binary). */ if (errno == ETXTBSY) continue; err(2, "can't open %s", binary); } close(fd); } exit(0); } static void exec_child(char **av) { (void)open(av[0], O_RDONLY | O_SHLOCK); execv(av[0], av); /* "flock_open_close: execv(/mnt/test): Text file busy" seen */ err(127, "execv(%s)", av[0]); } int main(int ac, char **av) { struct stat sb; pid_t pid; - int e, i, status; + time_t start; + int e, status; if (ac < 2) usage(); if (stat(av[1], &sb) != 0) err(1, "stat(%s)", av[1]); if (!S_ISREG(sb.st_mode)) errx(1, "%s not an executable", av[1]); pid = fork(); if (pid < 0) err(1, "fork"); if (pid == 0) child(av[1]); e = 0; - for (i = 0; i < 200000; i++) { + start = time(NULL); + while (time(NULL) - start < 150) { pid = fork(); if (pid < 0) err(1, "vfork"); if (pid == 0) exec_child(av + 1); wait(&status); if (WIFEXITED(status) && WEXITSTATUS(status) == 127) { fprintf(stderr, "FAIL\n"); e = 1; break; } if (WIFEXITED(status) && WEXITSTATUS(status) != 1) { /* /bin/test returns 1 */ e = 1; break; } } return (e); } diff --git a/tools/test/stress2/misc/gnop2.sh b/tools/test/stress2/misc/gnop2.sh index d38754d58456..0a6b830ce749 100755 --- a/tools/test/stress2/misc/gnop2.sh +++ b/tools/test/stress2/misc/gnop2.sh @@ -1,80 +1,82 @@ #!/bin/sh # # Copyright (c) 2016 Dell EMC # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 # "panic: vnode_pager_generic_getpages: sector size 8192 too large" seen # with an 8k sector size: # https://people.freebsd.org/~pho/stress/log/gnop2.txt # Fixed by r307626 . ../default.cfg kldstat | grep -q geom_nop || { gnop load 2>/dev/null || exit 0 && notloaded=1; } dir=/tmp odir=`pwd` cd $dir sed '1,/^EOF/d' < $odir/mmap5.sh > $dir/gnop2.c mycc -o gnop2 -Wall -Wextra gnop2.c || exit 1 rm -f gnop2.c cd $odir test() { . ../default.cfg mount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint [ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart set -e mdconfig -a -t swap -s 2g -u $mdstart gnop create -S $1 /dev/md$mdstart newfs $newfs_flags /dev/md$mdstart.nop > /dev/null mount /dev/md$mdstart.nop $mntpoint chmod 777 $mntpoint set +e dd if=/dev/zero of=$mntpoint/file bs=1k count=333 status=none /tmp/gnop2 $mntpoint/file while mount | grep $mntpoint | grep -q /dev/md; do umount $mntpoint || sleep 1 done gnop destroy /dev/md$mdstart.nop mdconfig -d -u $mdstart } gnop status || exit 1 +start=`date +%s` for i in 1k 2k 4k 8k; do test $i + [ $((`date +%s` - start)) -gt 1200 ] && break done [ $notloaded ] && gnop unload rm -f /tmp/gnop2 exit 0 diff --git a/tools/test/stress2/misc/mmap5.sh b/tools/test/stress2/misc/mmap5.sh index e6dee6d551de..c7369118e0e2 100755 --- a/tools/test/stress2/misc/mmap5.sh +++ b/tools/test/stress2/misc/mmap5.sh @@ -1,129 +1,131 @@ #!/bin/sh # # Copyright (c) 2013 EMC Corp. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # Test scenario inspired by alc@ # "panic: vm_page_dirty: page is invalid!" seen. # Fixed in r255396. . ../default.cfg dir=/tmp odir=`pwd` cd $dir sed '1,/^EOF/d' < $odir/$0 > $dir/mmap5.c mycc -o mmap5 -Wall -Wextra mmap5.c || exit 1 rm -f mmap5.c cd $odir cp /tmp/mmap5 /tmp/mmap5.inputfile (cd ../testcases/swap; ./swap -t 1m -i 2) & cp /tmp/mmap5 /tmp/mmap5.inputfile /tmp/mmap5 /tmp/mmap5.inputfile while killall -9 swap; do sleep .1 done > /dev/null 2>&1 wait rm -f /tmp/mmap5 /tmp/mmap5.inputfile exit EOF -#include -#include -#include +#include #include #include -#include #include #include #include +#include +#include +#include +#include #include const char *file; void test2(void) { struct stat st; char *p; size_t len; int error, fd; if ((fd = open(file, O_RDWR)) == -1) err(1, "open %s", file); if ((error = fstat(fd, &st)) == -1) err(1, "stat(%s)", file); len = round_page(st.st_size); if ((p = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)) == MAP_FAILED) err(1, "mmap"); p[arc4random() % len] = 1; if (arc4random() % 100 < 50) if ((error = mlock(p, len)) == -1) err(1, "mlock"); p[arc4random() % len] = 1; if (arc4random() % 100 < 50) if ((error = msync(p, len, MS_SYNC | MS_INVALIDATE)) == -1) if (errno != EBUSY) err(1, "msync"); if (munmap(p, len) == -1) err(1, "unmap()"); close(fd); _exit(0); } void test(void) { int i; for (i = 0; i < 3; i++) if (fork() == 0) test2(); for (i = 0; i < 3; i++) wait(NULL); _exit(0); } int main(int argc, char *argv[]) { - int i; + time_t start; if (argc != 2) errx(1, "Usage: %s ", argv[0]); file = argv[1]; - for (i = 0; i < 30000; i++) { + start = time(NULL); + while (time(NULL) - start < 120) { if (fork() == 0) test(); wait(NULL); } return (0); } diff --git a/tools/test/stress2/misc/procfs.sh b/tools/test/stress2/misc/procfs.sh index 6b445b0d7e48..a59235c6d521 100755 --- a/tools/test/stress2/misc/procfs.sh +++ b/tools/test/stress2/misc/procfs.sh @@ -1,69 +1,70 @@ #!/bin/sh # # Copyright (c) 2008 Peter Holm # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg mounts=15 # Number of parallel scripts mdstart=$mdstart # Use md unit numbers from this point if [ $# -eq 0 ]; then for i in `jot $mounts`; do m=$(( i + mdstart - 1 )) [ ! -d ${mntpoint}$m ] && mkdir ${mntpoint}$m mount | grep "$mntpoint" | grep -q md$m && umount ${mntpoint}$m done # start the parallel tests touch /tmp/$0 for i in `jot $mounts`; do m=$(( i + mdstart - 1 )) ./$0 $m & ./$0 find $m > /dev/null 2>&1 & done wait else if [ $1 = find ]; then while [ -r /tmp/$0 ]; do ls -lR ${mntpoint}* done else # The test: Parallel mount and unmounts - for i in `jot 128`; do + start=`date +%s` + while [ $((`date +%s`- start)) -lt 300 ]; do m=$1 mount -t procfs proc ${mntpoint}$m while mount | grep -qw $mntpoint$m; do opt=$([ $((`date '+%s'` % 2)) -eq 0 ] && echo "-f") umount $opt ${mntpoint}$m > /dev/null 2>&1 done done rm -f /tmp/$0 fi fi diff --git a/tools/test/stress2/misc/rename3.sh b/tools/test/stress2/misc/rename3.sh index c7ce91f0d359..aa4a3754bfab 100755 --- a/tools/test/stress2/misc/rename3.sh +++ b/tools/test/stress2/misc/rename3.sh @@ -1,51 +1,52 @@ #!/bin/sh # # Copyright (c) 2009 Peter Holm # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # Test vulnerability to transient failures when a directory closer # to the root directory is renamed # Deadlocks seen: # https://people.freebsd.org/~pho/stress/log/kostik447.txt # https://people.freebsd.org/~pho/stress/log/kirk058.txt # Test scenario by Tor Egge root=/tmp -for i in `jot 10000`; do +start=`date +%s` +while [ $((`date +%s` - start)) -lt 60 ]; do rm -rf $root/a mkdir -p $root/a/b/c/d/e/f/g mkdir -p $root/a/b/c/d/e/f/z cd $root/a/b/c/d/e/f ( mv $root/a/b/c $root/a/c ) & if ! mv z g/z; then echo "FAILURE at loop $i" break fi wait done rm -rf $root/a diff --git a/tools/test/stress2/misc/rename7.sh b/tools/test/stress2/misc/rename7.sh index 9f6954916411..fdaa8f575117 100755 --- a/tools/test/stress2/misc/rename7.sh +++ b/tools/test/stress2/misc/rename7.sh @@ -1,149 +1,151 @@ #!/bin/sh # # Copyright (c) 2012 Peter Holm # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 # After a few runs this will happen: # $ umount /mnt # umount: unmount of /mnt failed: Device busy # $ umount -f /mnt # $ . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > rename7.c mycc -o rename7 -Wall -Wextra -O2 rename7.c || exit rm -f rename7.c cd $here mount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 2g -u $mdstart newfs $newfs_flags md$mdstart > /dev/null mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint su $testuser -c "cd $mntpoint; /tmp/rename7 || echo FAIL" for i in `jot 10`; do mount | grep -q md$mdstart && \ umount $mntpoint && mdconfig -d -u $mdstart && break done if mount | grep -q md$mdstart; then echo "Test failed" exit 1 fi rm -f /tmp/rename7 exit 0 EOF #include #include #include #include #include #include #include #include #include #include #include #include #include #include const char *logfile = "test.log"; pid_t wpid, spid; void r1(void) { int i; struct stat sb1, sb2; for (i = 0; i < 800000; i++) { rename(logfile, "r1"); if (stat("r1", &sb1) == 0 && stat("r2", &sb2) == 0 && bcmp(&sb1, &sb2, sizeof(sb1)) == 0) { fprintf(stderr, "r1 and r2 are identical after rename(%s, \"r1\")\n", logfile); system("ls -ail"); _exit(1); } } _exit(0); } void r2(void) { int i; struct stat sb1, sb2; // _exit(0); /* No problems with only r1 running */ for (i = 0; i < 800000; i++) { rename(logfile, "r2"); if (stat("r1", &sb1) == 0 && stat("r2", &sb2) == 0 && bcmp(&sb1, &sb2, sizeof(sb1)) == 0) { usleep(10000); fprintf(stderr, "r1 and r2 are identical after rename(%s, \"r2\")\n", logfile); system("ls -ail"); _exit(1); } } _exit(0); } int main(void) { pid_t wpid, spid; - int e, fd, i, status; + time_t start; + int e, fd, status; if ((wpid = fork()) == 0) r1(); if ((spid = fork()) == 0) r2(); setproctitle("main"); e = 0; - for (i = 0; i < 800000; i++) { + start = time(NULL); + while (time(NULL) - start < 60) { if ((fd = open(logfile, O_RDWR | O_CREAT | O_TRUNC, 0644)) == -1) warn("creat(%s)", logfile); close(fd); } kill(wpid, SIGINT); kill(spid, SIGINT); wait(&status); e += WEXITSTATUS(status); wait(&status); e += WEXITSTATUS(status); return (e); } diff --git a/tools/test/stress2/misc/tmpfs2.sh b/tools/test/stress2/misc/tmpfs2.sh index 80885c331e14..09a2cfd68266 100755 --- a/tools/test/stress2/misc/tmpfs2.sh +++ b/tools/test/stress2/misc/tmpfs2.sh @@ -1,64 +1,66 @@ #!/bin/sh # # Copyright (c) 2009 Peter Holm # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # panic: vfs_mount_destroy: nonzero writeopcount, seen. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg mounts=15 # Number of parallel scripts if [ $# -eq 0 ]; then # start the parallel tests for i in `jot $mounts`; do [ -d ${mntpoint}$i ] || mkdir -p ${mntpoint}$i ./$0 $i & ./$0 find & done wait else if [ $1 = find ]; then - for i in `jot 1024`; do + start=`date +%s` + while [ $((`date +%s`- start)) -lt 300 ]; do find ${mntpoint}* -type f > /dev/null 2>&1 done else # The test: Parallel mount and unmounts - for i in `jot 1024`; do + start=`date +%s` + while [ $((`date +%s`- start)) -lt 300 ]; do m=$1 opt=`[ $(( m % 2 )) -eq 0 ] && echo -f` mount -t tmpfs tmpfs ${mntpoint}$m cp -r /usr/include/machine/a* ${mntpoint}$m while mount | grep -qw $mntpoint$m; do umount $opt ${mntpoint}$m > /dev/null 2>&1 done done fi fi diff --git a/tools/test/stress2/misc/umountf4.sh b/tools/test/stress2/misc/umountf4.sh index 4f5ea0fff660..e26555e7c6f3 100755 --- a/tools/test/stress2/misc/umountf4.sh +++ b/tools/test/stress2/misc/umountf4.sh @@ -1,84 +1,86 @@ #!/bin/sh # # Copyright (c) 2008 Peter Holm # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # Found: Fatal trap 12: page fault while in kernel mode [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg mounts=15 # Number of parallel scripts mdstart=$mdstart # Use md unit numbers from this point D=$diskimage if [ $# -eq 0 ]; then for i in `jot $mounts`; do m=$(( i + mdstart - 1 )) [ ! -d ${mntpoint}$m ] && mkdir ${mntpoint}$m mount | grep "$mntpoint" | grep -q md$m && umount ${mntpoint}$m mdconfig -l | grep -q md$m && mdconfig -d -u $m dd if=/dev/zero of=$D$m bs=1m count=10 status=none mdconfig -a -t vnode -f $D$m -u $m || { rm -f $D$m; exit 1; } newfs md${m} > /dev/null 2>&1 done # start the parallel tests for i in `jot $mounts`; do m=$(( i + mdstart - 1 )) ./$0 $m & ./$0 find & done wait for i in `jot $mounts`; do m=$(( i + mdstart - 1 )) mdconfig -d -u $m rm -f $D$m done else if [ $1 = find ]; then - for i in `jot 100`; do + start=`date +%s` + while [ $((`date +%s`- start)) -lt 300 ]; do find ${mntpoint}* -type f > /dev/null 2>&1 done else # The test: Parallel mount and unmounts - for i in `jot 100`; do + start=`date +%s` + while [ $((`date +%s`- start)) -lt 300 ]; do m=$1 opt=`[ $(( m % 2 )) -eq 0 ] && echo -f` mount $opt /dev/md${m} ${mntpoint}$m cp -r /usr/include/machine/a* ${mntpoint}$m while mount | grep -qw $mntpoint$m; do umount -f ${mntpoint}$m > /dev/null 2>&1 done done fi fi diff --git a/tools/test/stress2/misc/umountf6.sh b/tools/test/stress2/misc/umountf6.sh index aeb4454ea69c..628342689b38 100755 --- a/tools/test/stress2/misc/umountf6.sh +++ b/tools/test/stress2/misc/umountf6.sh @@ -1,84 +1,86 @@ #!/bin/sh # # Copyright (c) 2008-2013 Peter Holm # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # Variation of umountf4.sh; FS with "soft updates" [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg mounts=15 # Number of parallel scripts mdstart=$mdstart # Use md unit numbers from this point D=$diskimage if [ $# -eq 0 ]; then for i in `jot $mounts`; do m=$(( i + mdstart - 1 )) [ ! -d ${mntpoint}$m ] && mkdir ${mntpoint}$m mount | grep "$mntpoint" | grep -q md$m && umount ${mntpoint}$m mdconfig -l | grep -q md$m && mdconfig -d -u $m dd if=/dev/zero of=$D$m bs=1m count=10 status=none mdconfig -a -t vnode -f $D$m -u $m || { rm -f $D$m; exit 1; } newfs $newfs_flags md${m} > /dev/null 2>&1 done # start the parallel tests for i in `jot $mounts`; do m=$((i + mdstart - 1)) ./$0 $m & ./$0 find & done wait for i in `jot $mounts`; do m=$((i + mdstart - 1)) mdconfig -d -u $m rm -f $D$m done else if [ $1 = find ]; then - for i in `jot 100`; do + start=`date +%s` + while [ $((`date +%s`- start)) -lt 300 ]; do find ${mntpoint}* -type f > /dev/null 2>&1 done else # The test: Parallel mount and unmounts - for i in `jot 100`; do + start=`date +%s` + while [ $((`date +%s`- start)) -lt 300 ]; do m=$1 opt=`[ $(( m % 2 )) -eq 0 ] && echo -f` mount $opt /dev/md${m} ${mntpoint}$m cp -r /usr/include/machine/a* ${mntpoint}$m while mount | grep -qw $mntpoint$m; do umount -f ${mntpoint}$m > /dev/null 2>&1 done done fi fi diff --git a/tools/test/stress2/misc/vunref.sh b/tools/test/stress2/misc/vunref.sh index f844a0dd3625..f08035a95694 100755 --- a/tools/test/stress2/misc/vunref.sh +++ b/tools/test/stress2/misc/vunref.sh @@ -1,211 +1,212 @@ #!/bin/sh # # Copyright (c) 2010 Peter Holm # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # Vnode reference leak test scenario by kib@. # Will fail with "umount: unmount of /mnt5 failed: Device busy" # vnode leak not seen on HEAD. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg here=`pwd` mounts=2 # Number of parallel scripts D=$diskimage [ -d "$RUNDIR" ] || mkdir $RUNDIR cd $RUNDIR if [ $# -eq 0 ]; then sed '1,/^EOF/d' < $here/$0 > vunref.c mycc -o /tmp/vunref -Wall -Wextra -O2 vunref.c rm -f vunref.c cd $here rm -f $RUNDIR/active.* for i in `jot $mounts`; do m=$(( i + mdstart - 1 )) [ ! -d ${mntpoint}$m ] && mkdir ${mntpoint}$m mount | grep "$mntpoint" | grep -q md$m && umount -f ${mntpoint}$m mdconfig -l | grep -q md$m && mdconfig -d -u $m dd if=/dev/zero of=$D.$m bs=1m count=10 status=none mdconfig -a -t vnode -f $D.$m -u $m newfs md${m} > /dev/null 2>&1 done # start the parallel tests for i in `jot $mounts`; do m=$((i + mdstart - 1)) $0 mmap $m & sleep 0.2 $0 $m & done sleep 2 while [ ! -z "`ls $RUNDIR/active.* 2>/dev/null`" ] ; do ../testcases/swap/swap -t 2m -i 20 done wait for i in `jot $mounts`; do m=$((i + mdstart - 1)) mdconfig -d -u $m rm -f $D$m done rm -f /tmp/vunref $RUNDIR/active.* $diskimage.* ${mntpoint}*/p* else if [ $1 = mmap ]; then touch $RUNDIR/active.$2 - for i in `jot 500`; do + start=`date +%s` + while [ $((`date +%s`- start)) -lt 300 ]; do cd ${mntpoint}$2 /tmp/vunref > /dev/null 2>&1 cd / [ -f $RUNDIR/active.$2 ] || exit sleep 0.1 done rm -f $RUNDIR/active.$2 else # The test: Parallel mount and unmounts m=$1 mount $opt /dev/md${m} ${mntpoint}$m while [ -f $RUNDIR/active.$m ] ; do sleep 0.1 n=0 while mount | grep -qw $mntpoint$m; do umount ${mntpoint}$m > /dev/null 2>&1 && n=0 if [ $((n += 1)) -gt 600 ]; then echo "*** Leak detected ***" fstat $mntpoint$m rm -f $RUNDIR/active.* exit 1 fi sleep 0.1 done mount $opt /dev/md${m} ${mntpoint}$m done mount | grep "$mntpoint" | grep -q md$m && umount ${mntpoint}$m fi fi exit EOF #include #include #include #include #include #include #include #include #include #include #include #include #define INPUTFILE "/bin/date" int test(void) { int i; pid_t pid; char file[128]; int fdin, fdout; char *src, *dst; struct stat statbuf; pid = getpid(); for (i = 0; i < 100; i++) { sprintf(file,"p%05d.%05d", pid, i); if ((fdin = open(INPUTFILE, O_RDONLY)) < 0) err(1, INPUTFILE); if ((fdout = open(file, O_RDWR | O_CREAT | O_TRUNC, 0600)) < 0) err(1, "%s", file); if (fstat(fdin, &statbuf) < 0) err(1, "fstat error"); if (lseek(fdout, statbuf.st_size - 1, SEEK_SET) == -1) err(1, "lseek error"); /* write a dummy byte at the last location */ if (write(fdout, "", 1) != 1) err(1, "write error"); if ((src = mmap(0, statbuf.st_size, PROT_READ, MAP_SHARED, fdin, 0)) == (caddr_t) - 1) err(1, "mmap error for input"); if ((dst = mmap(0, statbuf.st_size, PROT_READ | PROT_WRITE, MAP_SHARED, fdout, 0)) == (caddr_t) - 1) err(1, "mmap error for output"); memcpy(dst, src, statbuf.st_size); if (munmap(src, statbuf.st_size) == -1) err(1, "munmap"); close(fdin); if (munmap(dst, statbuf.st_size) == -1) err(1, "munmap"); close(fdout); if (unlink(file) == -1) err(3, "unlink(%s)", file); } return (0); } int main() { int i; char path[MAXPATHLEN+1]; struct statfs buf; if (getcwd(path, sizeof(path)) == NULL) err(1, "getcwd()"); if (statfs(path, &buf) < 0) err(1, "statfs(%s)", path); if (!strcmp(buf.f_mntonname, "/")) return (1); for (i = 0; i < 2; i++) { if (fork() == 0) test(); } for (i = 0; i < 2; i++) wait(NULL); return (0); }