Index: user/pho/stress2/misc/graid1_4.sh =================================================================== --- user/pho/stress2/misc/graid1_4.sh (revision 318232) +++ user/pho/stress2/misc/graid1_4.sh (revision 318233) @@ -1,98 +1,98 @@ #!/bin/sh # # Copyright (c) 2017 Dell EMC Isilon # 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. # # $FreeBSD$ # # Non UFS SU gmirror stop -f test. # Page fault seen: # https://people.freebsd.org/~pho/stress/log/graid1_4.txt # Fixed in r316867 [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg -rm -f ${diskimage}* +rm -f $diskimage* need=1024 # MB [ `df -k $(dirname $diskimage) | tail -1 | awk '{print int($4 / 1024)'}` -lt \ $need ] && printf "Need %d MB on %s.\n" $need `dirname $diskimage` && exit gmirror load > /dev/null 2>&1 && unload=1 [ -c /dev/mirror/test ] && { gmirror stop test; gmirror destroy test; } old=`sysctl -n kern.geom.mirror.debug` sysctl kern.geom.mirror.debug=-1 | grep -q -- -1 || sysctl kern.geom.mirror.debug=$old > /dev/null md1=$mdstart md2=$((mdstart + 1)) s=0 for u in $md1 $md2; do disk="$diskimage.$u" dd if=/dev/zero of=$disk bs=1m count=512 2>&1 | \ egrep -v "records|transferred" [ -c /dev/md$u ] && mdconfig -d -u $u mdconfig -a -t vnode -f $disk -u $u done gmirror label -v -b split -s 2048 test /dev/md$md1 /dev/md$md2 \ > /dev/null || exit 1 [ -c /dev/mirror/test ] || exit 1 # Soft Updates issues with removal of backing media newfs /dev/mirror/test > /dev/null mount /dev/mirror/test $mntpoint chmod 777 $mntpoint export runRUNTIME=10m export RUNDIR=$mntpoint/stressX su $testuser -c 'cd ..; ./run.sh marcus.cfg' & while kill -0 $! > /dev/null 2>&1; do sleep `jot -r 1 1 5` gmirror remove test md$md2 sleep `jot -r 1 1 5` gmirror insert test md$md2 done wait gmirror stop -f test # Note the stop *before* umount while mount | grep $mntpoint | grep -q /mirror/; do umount $mntpoint || sleep 1 done gmirror stop test || s=1 gmirror destroy test 2>/dev/null [ $unload ] && gmirror unload for u in $md3 $md2 $md1; do mdconfig -d -u $u || s=3 done rm -f $diskimage* exit $s Index: user/pho/stress2/misc/graid1_6.sh =================================================================== --- user/pho/stress2/misc/graid1_6.sh (revision 318232) +++ user/pho/stress2/misc/graid1_6.sh (revision 318233) @@ -1,91 +1,91 @@ #!/bin/sh # # Copyright (c) 2017 Dell EMC Isilon # 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. # # $FreeBSD$ # # Variation of graid1_4.sh [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg -rm -f ${diskimage}* +rm -f $diskimage* need=1024 # MB [ `df -k $(dirname $diskimage) | tail -1 | awk '{print int($4 / 1024)'}` -lt \ $need ] && printf "Need %d MB on %s.\n" $need `dirname $diskimage` && exit gmirror load > /dev/null 2>&1 && unload=1 [ -c /dev/mirror/test ] && { gmirror stop test; gmirror destroy test; } old=`sysctl -n kern.geom.mirror.debug` sysctl kern.geom.mirror.debug=-1 | grep -q -- -1 || sysctl kern.geom.mirror.debug=$old > /dev/null md1=$mdstart md2=$((mdstart + 1)) s=0 for u in $md1 $md2; do disk="$diskimage.$u" dd if=/dev/zero of=$disk bs=1m count=512 2>&1 | \ egrep -v "records|transferred" [ -c /dev/md$u ] && mdconfig -d -u $u mdconfig -a -t vnode -f $disk -u $u done gmirror label -v -b split -s 2048 test /dev/md$md1 /dev/md$md2 \ > /dev/null || exit 1 [ -c /dev/mirror/test ] || exit 1 newfs $newfs_flags /dev/mirror/test > /dev/null mount /dev/mirror/test $mntpoint chmod 777 $mntpoint export runRUNTIME=4m export RUNDIR=$mntpoint/stressX su $testuser -c 'cd ..; ./run.sh marcus.cfg' & while kill -0 $! > /dev/null 2>&1; do sleep `jot -r 1 1 5` gmirror remove test md$md2 sleep `jot -r 1 1 5` gmirror insert test md$md2 done wait while mount | grep $mntpoint | grep -q /mirror/; do umount $mntpoint || sleep 1 done gmirror stop -f test ||s=1 gmirror destroy test 2>/dev/null [ $unload ] && gmirror unload for u in $md3 $md2 $md1; do mdconfig -d -u $u || s=3 done rm -f $diskimage* exit $s Index: user/pho/stress2/misc/nanosleep.sh =================================================================== --- user/pho/stress2/misc/nanosleep.sh (revision 318232) +++ user/pho/stress2/misc/nanosleep.sh (revision 318233) @@ -1,98 +1,98 @@ #!/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. # # $FreeBSD$ # # A simplistic regression test for r200510: -[ `sysctl kern.hz | sed 's/.* //'` -ne 1000 ] && exit 1 +[ `sysctl -n kern.hz` -lt 1000 ] && exit 0 . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > nanosleep.c mycc -o nanosleep -Wall -Wextra nanosleep.c || exit 1 rm -f nanosleep.c /tmp/nanosleep || exit rm -f /tmp/nanosleep exit 0 EOF #include #include #include #include #include #include #define timespecsub(vvp, uvp) \ do { \ (vvp)->tv_sec -= (uvp)->tv_sec; \ (vvp)->tv_nsec -= (uvp)->tv_nsec; \ if ((vvp)->tv_nsec < 0) { \ (vvp)->tv_sec--; \ (vvp)->tv_nsec += 1000000000; \ } \ } while (0) #define N 20000 int main(void) { struct timespec rqt, rmt; struct timespec start, finish; long m; int i; m = LONG_MAX; for (i = 0; i < 100; i++) { rqt.tv_sec = 0; rqt.tv_nsec = N; clock_gettime(CLOCK_REALTIME_PRECISE, &start); if (nanosleep(&rqt, &rmt) == -1) err(1, "nanosleep"); clock_gettime(CLOCK_REALTIME_PRECISE, &finish); timespecsub(&finish, &start); if (finish.tv_nsec < N) errx(1, "Short sleep: %ld", finish.tv_nsec); // fprintf(stderr, "asked for %f, got %f\n", (double)N / 1e9, // (double)finish.tv_nsec / 1e9); if (m > finish.tv_nsec) m = finish.tv_nsec; } if (m > 2 * N) { fprintf(stderr, "nanosleep(%fs). Best value is %fs.\n", (double)N / 1e9, (double)m / 1e9); errx(1, "FAIL"); } return (0); } Index: user/pho/stress2/misc/nfs11.sh =================================================================== --- user/pho/stress2/misc/nfs11.sh (revision 318232) +++ user/pho/stress2/misc/nfs11.sh (revision 318233) @@ -1,68 +1,69 @@ #!/bin/sh # # Copyright (c) 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. # # $FreeBSD$ # # nfsv4 test scenario [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg grep -q $mntpoint /etc/exports || { echo "$mntpoint missing from /etc/exports"; exit 0; } m2=${mntpoint}2 [ -d $m2 ] || mkdir $m2 mount | grep "on $m2 " | grep -q nfs && umount $m2 mount | grep "on $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 || exit 1 bsdlabel -w md$mdstart auto newfs $newfs_flags md${mdstart}$part > /dev/null mount /dev/md${mdstart}$part $mntpoint chmod 777 $mntpoint mount -t nfs -o nfsv4 -o rw,retrycnt=3 127.0.0.1:$mntpoint $m2 export RUNDIR=$m2/stressX export runRUNTIME=10m # Run tests for 10 minutes su $testuser -c "(cd ..; ./run.sh marcus.cfg)" while mount | grep "on $m2 " | grep -q nfs; do umount $m2 done while mount | grep "on $mntpoint " | grep -q /dev/md; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart +exit 0 Index: user/pho/stress2/misc/nullfs15.sh =================================================================== --- user/pho/stress2/misc/nullfs15.sh (revision 318232) +++ user/pho/stress2/misc/nullfs15.sh (revision 318233) @@ -1,67 +1,67 @@ #!/bin/sh # # Copyright (c) 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. # # $FreeBSD$ # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg # panic: lockmgr still held. Fixed in r250852. # Test scenario by antoine@ nullfsmp=${mntpoint}2 mount | grep -q "$nullfsmp " && umount $nullfsmp [ -d $nullfsmp ] || mkdir $nullfsmp 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 bsdlabel -w md$mdstart auto newfs $newfs_flags md${mdstart}$part > /dev/null mount /dev/md${mdstart}$part $mntpoint mount -t nullfs $mntpoint $nullfsmp -mkdir ${mntpoint}/.new_packages ${nullfsmp}/new_packages -mount -t nullfs ${mntpoint}/.new_packages ${nullfsmp}/new_packages -dd if=/dev/zero of=${nullfsmp}/new_packages/bar count=20000 2>&1 | +mkdir $mntpoint/.new_packages $nullfsmp/new_packages +mount -t nullfs $mntpoint/.new_packages $nullfsmp/new_packages +dd if=/dev/zero of=$nullfsmp/new_packages/bar count=20000 2>&1 | egrep -v "records|transferred" -mv ${mntpoint}/.new_packages/bar /tmp/ -rm -rf ${mntpoint}/.new_packages -umount -f ${nullfsmp}/new_packages +mv $mntpoint/.new_packages/bar /tmp/ +rm -rf $mntpoint/.new_packages +umount -f $nullfsmp/new_packages while mount | grep -q "$nullfsmp "; do umount $nullfsmp || sleep 1 done while mount | grep -q "$mntpoint "; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart rm -f /tmp/bar exit 0 Index: user/pho/stress2/misc/spin.sh =================================================================== --- user/pho/stress2/misc/spin.sh (revision 318232) +++ user/pho/stress2/misc/spin.sh (revision 318233) @@ -1,129 +1,128 @@ #!/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. # # $FreeBSD$ # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 # Demonstrate starvation: Thread stuck in "ufs" for minutes. # Only seen with >= 16 CPUs. # Not a problem with 4BSD. # http://people.freebsd.org/~pho/stress/log/spin.txt # Fixed by r273966. mntpoint=/mnt mdstart=5 part=a timeout=1200 [ -r ../default.cfg ] && . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > spin.c mycc -o spin -Wall -Wextra -O0 spin.c || exit 1 rm -f spin.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 1g -u $mdstart || exit 1 bsdlabel -w md$mdstart auto newfs $newfs_flags -n md${mdstart}$part > /dev/null mount /dev/md${mdstart}$part $mntpoint cpus=`sysctl hw.ncpu | sed 's/.*: //'` (cd $mntpoint; /tmp/spin $((cpus + 1))) & error=0 n=0 while kill -0 $! 2>/dev/null; do sleep 1 - n=$((n + 1)) - if [ $n -gt $timeout ]; then + if [ $((n += 1)) -gt $timeout ]; then echo FAIL ps -l | grep -v sed | sed -n '1p;/ufs/p' pkill spin error=1 fi done wait while mount | grep $mntpoint | grep -q /dev/md; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart rm -f /tmp/spin exit $error EOF #include #include #include #include #include #include #include void work(void) { while (access("rendezvous", R_OK) != 0) ; _exit(0); } int main(int argc, char **argv) { int fd, i, parallel; if (argc == 2) parallel = atoi(argv[1]); else errx(1, "Usage: %s ", argv[0]); for (i = 0; i < parallel; i++) { if (fork() == 0) work(); } /* open(2) blocked on "ufs" for minutes */ if ((fd = open("rendezvous", O_CREAT, 0644)) == -1) err(1, "open()"); close(fd); for (i = 0; i < parallel; i++) wait(NULL); if (unlink("rendezvous") == -1) err(1, "unlink()"); return (0); } Index: user/pho/stress2/misc/vunref.sh =================================================================== --- user/pho/stress2/misc/vunref.sh (revision 318232) +++ user/pho/stress2/misc/vunref.sh (revision 318233) @@ -1,222 +1,221 @@ #!/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. # # $FreeBSD: projects/stress2/misc/umountf4.sh 197027 2009-09-09 10:13:56Z pho $ # # 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 dede $D.$m 1m 10 mdconfig -a -t vnode -f $D.$m -u $m bsdlabel -w md$m auto newfs md${m}$part > /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 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}$part ${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 - n=$((n + 1)) - if [ $n -gt 600 ]; then + 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}$part ${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 #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); }