Index: user/pho/stress2/default.cfg =================================================================== --- user/pho/stress2/default.cfg (revision 276739) +++ user/pho/stress2/default.cfg (revision 276740) @@ -1,92 +1,92 @@ # $FreeBSD$ # Stress Test Suite Configuration # Default values export RUNDIR=${RUNDIR:-/tmp/stressX} export RUNTIME=${RUNTIME:-2m} export VERBOSE=${VERBOSE:-1} export LOAD=20 # The INCARNATIONS variable should be set to match the number of CPUs and # the amount of RAM in the test box. # 10 for a 1,8 GHz Celeron with 256 Mb of RAM # 100 for a dual Xeon 1,8 GHz with 1024 Gb of RAM export INCARNATIONS=${INCARNATIONS:-20} # Change hostname! #export BLASTHOST=192.168.1.2 # host with udp discard enabled in inetd.conf export BLASTHOST=192.168.1.3 # host with udp discard enabled in inetd.conf +#export nfs_export=somehost:mount # Used by nfs tests - # Run all test cases: export runRUNTIME=${runRUNTIME:-3d} # Run tests for three days export runINCARNATIONS=1 export runLOAD=100 export swapINCARNATIONS=${swapINCARNATIONS:-$((2 * INCARNATIONS))} export swapLOAD=80 export syscallKILL=1 export swapKILL=1 # May takes a long time to stop export rwLOAD=70 export mkdirLOAD=80 export creatLOAD=80 export symlinkLOAD=20 export tcpKILL=1 #export shmKILL=1 export shmINCARNATIONS=5 export TESTPROGS=" testcases/rw/rw testcases/swap/swap testcases/creat/creat testcases/mkdir/mkdir testcases/thr1/thr1 testcases/udp/udp testcases/tcp/tcp " -# +# # Defaults for ./misc tests # diskimage=/var/tmp/diskimage # Location of 1G disk image mntpoint=/mnt # Disk image mount point testuser=pho # Name of non root test user mdstart=5 # Start of free md units part=a # partition to use on a md FS newfs_flags="-U" # default file system flags # Wrapper for dd dede () { # file, blocksize, count local log=/tmp/$0.$$ dd if=/dev/zero of=$1 bs=$2 count=$3 > $log 2>&1 local status=$? egrep -v "records in|records out|bytes transferred" $log rm -f $log - return $status + return $status } # fsck and dumpfs comparison checkfs () { dumpfs $1 | sed '/UFS2/s/..:..:../xx:xx:xx/' > /tmp/dumpfs.1 sleep 1 fsck -t ufs -y $1 > /tmp/fsck.log 2>&1 dumpfs $1 | sed '/UFS2/s/..:..:../xx:xx:xx/' > /tmp/dumpfs.2 if egrep -q "INCONSISTENCY|MODIFIED" /tmp/fsck.log || ! cmp -s /tmp/dumpfs.1 /tmp/dumpfs.2; then diff -c /tmp/dumpfs.1 /tmp/dumpfs.2 echo "fsck -t ufs -y $1" cat /tmp/fsck.log else rm -f /tmp/fsck.log /tmp/dumpfs.[12] fi } [ -f "./`hostname`" ] && . "./`hostname`" # source in local configuration [ -f "../`hostname`" ] && . "../`hostname`" # source in local configuration Index: user/pho/stress2/misc/crossmp2.sh =================================================================== --- user/pho/stress2/misc/crossmp2.sh (revision 276739) +++ user/pho/stress2/misc/crossmp2.sh (revision 276740) @@ -1,77 +1,81 @@ #!/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. # # $FreeBSD$ # -# Panic in getdirentries+0x21a -# Run with stress: disk.cfg +# NFS test [ `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 + mounts=10 # Number of parallel scripts if [ $# -eq 0 ]; then for i in `jot $mounts`; do - [ ! -d ${mntpoint}$i ] && mkdir ${mntpoint}$i - mount | grep -qw "${mntpoint}$i" && umount ${mntpoint}$i + 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 & done - - for i in `jot $mounts`; do - wait; wait - done + wait else if [ $1 = find ]; then for i in `jot 128`; do - find ${mntpoint}* -maxdepth 1 -type f > /dev/null 2>&1 + find ${mntpoint}* -maxdepth 1 -type f > \ + /dev/null 2>&1 done else # The test: Parallel mount and unmounts for i in `jot 128`; do m=$1 - mount -t nfs -o tcp -o nfsv3 -o retrycnt=3 -o intr -o soft -o rw 127.0.0.1:/tmp ${mntpoint}$m + mount -t nfs -o tcp -o nfsv3 -o retrycnt=3 -o intr \ + -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 99 ] && umount -f ${mntpoint}$m > \ + /dev/null 2>&1 [ $n -gt 100 ] && exit done done fi fi Index: user/pho/stress2/misc/lockf.sh =================================================================== --- user/pho/stress2/misc/lockf.sh (revision 276739) +++ user/pho/stress2/misc/lockf.sh (revision 276740) @@ -1,54 +1,59 @@ #!/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. # # $FreeBSD$ # -# Page fault in nfs_advlock +# Page fault seen: +# http://people.freebsd.org/~pho/stress/log/lockf.txt [ `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; } + trap "rm -f /tmp/$0.$$.*" 0 mount | grep "$mntpoint" | grep nfs > /dev/null && umount $mntpoint for i in `jot 100`; do - mount -t nfs -o tcp -o retrycnt=3 -o intr -o soft -o rw 127.0.0.1:/tmp $mntpoint + mount -t nfs -o tcp -o retrycnt=3 -o intr -o soft -o rw $nfs_export $mntpoint + sleep 1 for j in `jot 50`; do -# sh -c "lockf -t 10 $mntpoint/$0.$$.$j sleep 3" & lockf -t 10 $mntpoint/$0.$$.$j sleep 3 & done while mount | grep -q ${mntpoint}; do umount -f $mntpoint > /dev/null 2>&1 done - for j in `jot 50`; do - wait - done + wait done Index: user/pho/stress2/misc/mountu.sh =================================================================== --- user/pho/stress2/misc/mountu.sh (revision 276739) +++ user/pho/stress2/misc/mountu.sh (revision 276740) @@ -1,164 +1,166 @@ #!/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. # # $FreeBSD$ # # Change mount point from rw to ro with a file mapped rw # Currently fails for NFS [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > mountu.c cc -o mountu -Wall -Wextra -O2 mountu.c rm -f mountu.c pstat() { pid=`ps a | grep -v grep | grep /tmp/mountu | awk '{print $1}'` [ -n "$pid" ] && procstat -v $pid } mount | grep -q "$mntpoint " && umount $mntpoint mdconfig -l | grep -q $mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 100m -u $mdstart bsdlabel -w md${mdstart} auto newfs $newfs_flags md${mdstart}${part} > /dev/null mount /dev/md${mdstart}${part} $mntpoint chmod 777 $mntpoint /tmp/mountu $mntpoint/file & sleep 1 if ! mount -u -o ro $mntpoint 2>&1 | grep -q "Device busy"; then echo "UFS FAILED" pstat fi wait while mount | grep -q "$mntpoint "; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart -mount -t nfs -o tcp -o retrycnt=3 -o intr -o soft -o rw 127.0.0.1:/tmp $mntpoint -rm -f /tmp/file -/tmp/mountu $mntpoint/file & -sleep 1 +if ping -c 2 `echo $nfs_export | sed 's/:.*//'` > /dev/null 2>&1; then + mount -t nfs -o tcp -o retrycnt=3 -o intr -o soft -o rw $nfs_export \ + $mntpoint + rm -f /tmp/file + /tmp/mountu $mntpoint/file & + sleep 1 -if ! mount -u -o ro $mntpoint 2>&1 | grep -q "Device busy"; then - echo "NFS FAILED" + if ! mount -u -o ro $mntpoint 2>&1 | grep -q "Device busy"; then + echo "NFS FAILED" + fi + wait + umount $mntpoint fi -wait -umount $mntpoint if [ -x /sbin/mount_msdosfs ]; then mdconfig -a -t swap -s 100m -u $mdstart bsdlabel -w md${mdstart} auto - newfs_msdos -F 16 -b 8192 /dev/md${mdstart}a > /dev/null 2>&1 - mount_msdosfs -m 777 /dev/md${mdstart}a $mntpoint + newfs_msdos -F 16 -b 8192 /dev/md${mdstart}$part > /dev/null 2>&1 + mount_msdosfs -m 777 /dev/md${mdstart}$part $mntpoint /tmp/mountu $mntpoint/file & sleep 1 if ! mount -u -o ro $mntpoint 2>&1 | grep -q "Device busy"; then echo "MSDOS FAILED" fi wait while mount | grep -q "$mntpoint "; do umount $mntpoint || sleep 1 done fi rm -f /tmp/mountu /tmp/file exit 0 EOF #include #include #include #include #include #include #include #include #include #include #include #include #define STARTADDR 0x0U #define ADRSPACE 0x0640000U int main(int argc __unused, char **argv) { int fd, ps; void *p; size_t len; struct passwd *pw; char *c, *path; if ((pw = getpwnam("nobody")) == NULL) err(1, "no such user: nobody"); if (setgroups(1, &pw->pw_gid) || setegid(pw->pw_gid) || setgid(pw->pw_gid) || seteuid(pw->pw_uid) || setuid(pw->pw_uid)) err(1, "Can't drop privileges to \"nobody\""); endpwent(); p = (void *)STARTADDR; len = ADRSPACE; path = argv[1]; if ((fd = open(path, O_CREAT | O_TRUNC | O_RDWR, 0622)) == -1) err(1,"open(%s)", path); if (ftruncate(fd, len) == -1) err(1, "ftruncate"); if ((p = mmap(p, len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)) == MAP_FAILED) { if (errno == ENOMEM) { warn("mmap()"); return (1); } err(1, "mmap(1)"); } -// fprintf(stderr, "%s mapped to %p\n", path, p); c = p; ps = getpagesize(); for (c = p; (void *)c < p + len; c += ps) { *c = 1; } close(fd); sleep(5); return (0); } Index: user/pho/stress2/misc/nfs.sh =================================================================== --- user/pho/stress2/misc/nfs.sh (revision 276739) +++ user/pho/stress2/misc/nfs.sh (revision 276740) @@ -1,48 +1,52 @@ #!/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. # # $FreeBSD$ # # No problems seen with this test [ `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 + mount | grep "$mntpoint" | grep -q nfs && umount $mntpoint -mount -t nfs -o tcp -o retrycnt=3 -o intr -o soft -o rw 127.0.0.1:/tmp $mntpoint +mount -t nfs -o tcp -o retrycnt=3 -o intr -o soft -o rw $nfs_export $mntpoint export RUNDIR=$mntpoint/stressX export runRUNTIME=10m # Run tests for 10 minutes su $testuser -c "(cd ..; ./run.sh disk.cfg)" umount $mntpoint while mount | grep "$mntpoint " | grep -q nfs; do umount -f $mntpoint done Index: user/pho/stress2/misc/nfs12.sh =================================================================== --- user/pho/stress2/misc/nfs12.sh (revision 276739) +++ user/pho/stress2/misc/nfs12.sh (revision 276740) @@ -1,156 +1,159 @@ #!/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$ # # "umount -f" test scenario (distill of nfs4.sh) # "panic: vputx: missed vn_close" seen. # Fixed in r248815 [ `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; } +[ -z "$nfs_export" ] && exit 0 +ping -c 2 `echo $nfs_export | sed 's/:.*//'` > /dev/null 2>&1 || + exit 0 here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > nfs12.c cc -o nfs12 -Wall -Wextra -O2 -g nfs12.c rm -f nfs12.c cd $here mount | grep "on $mntpoint " | grep nfs > /dev/null && umount $mntpoint version="-o nfsv3" # The default [ $# -eq 1 ] && [ "$1" -eq 4 ] && version="-o nfsv4" for i in `jot 10`; do - mount -t nfs $version -o tcp -o retrycnt=3 -o intr -o soft -o rw 127.0.0.1:/tmp $mntpoint + mount -t nfs $version -o tcp -o retrycnt=3 -o intr -o soft -o rw \ + $nfs_export $mntpoint sleep 2 (cd $mntpoint; /tmp/nfs12 > /dev/null 2>&1) & sleep 2 while mount | grep "on $mntpoint " | grep -q nfs; do umount -f $mntpoint done kill -9 $! > /dev/null 2>/dev/null && kill $! wait done rm -f /tmp/nfs12 exit EOF #include #include #include #include #include #include #include #include #include #include #include #define INPUTFILE "/bin/date" #define PARALLEL 5 int tmmap(void) { int i; pid_t pid; char file[128]; int fdin, fdout; char *src, *dst; struct stat statbuf; pid = getpid(); setproctitle("mmap"); for (i = 0; i < 50000; 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); } _exit(0); } int main(void) { int i; for (i = 0; i < PARALLEL; i++) { - if (fork() == 0) + if (fork() == 0) tmmap(); } for (i = 0; i < PARALLEL; i++) { wait(NULL); } return (0); } Index: user/pho/stress2/misc/nfs3.sh =================================================================== --- user/pho/stress2/misc/nfs3.sh (revision 276739) +++ user/pho/stress2/misc/nfs3.sh (revision 276740) @@ -1,55 +1,60 @@ #!/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. # # $FreeBSD$ # # panic: neg mount point vnode list size [ `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 + [ ! -d $mntpoint ] && mkdir $mntpoint mount | grep "$mntpoint" | grep nfs > /dev/null && umount $mntpoint -mount -t nfs -o tcp -o retrycnt=3 -o intr -o soft -o rw 127.0.0.1:/tmp $mntpoint +mount -t nfs -o tcp -o retrycnt=3 -o intr -o soft -o rw $nfs_export $mntpoint +sleep 1 rm -rf $mntpoint/stressX/* rm -rf /tmp/stressX.control export RUNDIR=$mntpoint/nfs/stressX [ ! -d $RUNDIR ] && mkdir -p $RUNDIR export runRUNTIME=1m rm -rf /tmp/stressX.control/* -su $testuser -c "(cd ..; ./run.sh -a > /dev/null 2>&1)" & +su $testuser -c "(cd ..; ./run.sh io.cfg > /dev/null 2>&1)" & sleep 50 -while mount | grep -q $mntpoint; do - umount -f $mntpoint > /dev/null 2>&1 +while mount | grep -q "on $mntpoint "; do + umount -f $mntpoint || sleep 1 done kill -9 $! ../tools/killall.sh Index: user/pho/stress2/misc/nfs4.sh =================================================================== --- user/pho/stress2/misc/nfs4.sh (revision 276739) +++ user/pho/stress2/misc/nfs4.sh (revision 276740) @@ -1,55 +1,59 @@ #!/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. # # $FreeBSD$ # # panic: vm_fault: fault on nofault entry, from vfs_stdcheckexp+0x74 [ `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 + [ ! -d $mntpoint ] && mkdir $mntpoint mount | grep "$mntpoint" | grep nfs > /dev/null && umount $mntpoint -mount -t nfs -o tcp -o retrycnt=3 -o intr -o soft -o rw 127.0.0.1:/tmp $mntpoint +mount -t nfs -o tcp -o retrycnt=3 -o intr -o soft -o rw $nfs_export $mntpoint rm -rf $mntpoint/stressX/* rm -rf /tmp/stressX.control export RUNDIR=$mntpoint/nfs/stressX [ ! -d $RUNDIR ] && mkdir -p $RUNDIR export runRUNTIME=3m rm -rf /tmp/stressX.control/* su $testuser -c '(cd ..; ./run.sh all.cfg)' & sleep 60 while mount | grep -q $mntpoint; do umount -f $mntpoint > /dev/null 2>&1 done kill -9 $! ../tools/killall.sh Index: user/pho/stress2/misc/nfs7.sh =================================================================== --- user/pho/stress2/misc/nfs7.sh (revision 276739) +++ user/pho/stress2/misc/nfs7.sh (revision 276740) @@ -1,54 +1,58 @@ #!/bin/sh # # Copyright (c) 2009-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$ # # NFS test excluding lockd [ `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 + [ ! -d $mntpoint ] && mkdir $mntpoint mount | grep "$mntpoint" | grep nfs > /dev/null && umount $mntpoint -mount -t nfs -o nfsv3,tcp,nolockd -o retrycnt=3 -o intr -o soft -o rw 127.0.0.1:/tmp $mntpoint +mount -t nfs -o nfsv3,tcp,nolockd -o retrycnt=3 -o intr -o soft -o rw $nfs_export $mntpoint rm -rf /tmp/stressX.control export RUNDIR=$mntpoint/nfs/stressX rm -rf $RUNDIR mkdir -p $RUNDIR chmod 777 $RUNDIR export runRUNTIME=10m rm -rf /tmp/stressX.control/* su $testuser -c "(cd ..; ./run.sh marcus.cfg)" umount $mntpoint while mount | grep -q $mntpoint; do umount -f $mntpoint > /dev/null 2>&1 done Index: user/pho/stress2/misc/nfs8.sh =================================================================== --- user/pho/stress2/misc/nfs8.sh (revision 276739) +++ user/pho/stress2/misc/nfs8.sh (revision 276740) @@ -1,58 +1,62 @@ #!/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. # # $FreeBSD$ # # Test scenario for a lock cascade problem with sending SIGSTOP to processes # accessing a NFS intr mount. [ `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 + [ ! -d $mntpoint ] && mkdir $mntpoint mount | grep "$mntpoint" | grep nfs > /dev/null && umount $mntpoint -mount -t nfs -o nfsv3,tcp,nolockd -o retrycnt=3 -o intr -o soft -o rw 127.0.0.1:/tmp $mntpoint +mount -t nfs -o nfsv3,tcp,nolockd -o retrycnt=3 -o intr -o soft -o rw $nfs_export $mntpoint pids="" for i in `jot 10`; do find $mntpoint > /dev/null 2>&1 & sleep 0.1 kill -s STOP $! pids="$pids $!" done umount $mntpoint 2>&1 | grep -v "Device busy" while mount | grep -q $mntpoint; do umount -f $mntpoint > /dev/null 2>&1 done kill -s CONT $pids for i in `jot 10`; do wait done Index: user/pho/stress2/misc/nfs9.sh =================================================================== --- user/pho/stress2/misc/nfs9.sh (revision 276739) +++ user/pho/stress2/misc/nfs9.sh (revision 276740) @@ -1,65 +1,69 @@ #!/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. # # $FreeBSD$ # # Copy of nfs4.sh, where it was discovered that a missing killall.sh script # turned up quite a few new panics. For example: # vfs_mount_destroy: nonzero writeopcount # Lock nfs not locked @ kern/vfs_default.c:462 # Assertion x == LK_SHARERS_LOCK(1) failed at kern/kern_lock.c:236 [ `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 + [ ! -d $mntpoint ] && mkdir $mntpoint for i in `jot 10`; do mount | grep "on $mntpoint " | grep -q nfs && umount $mntpoint mount -t nfs -o tcp -o retrycnt=3 -o intr -o soft \ - -o rw 127.0.0.1:/tmp $mntpoint + -o rw $nfs_export $mntpoint sleep .5 export RUNDIR=$mntpoint/nfs9/stressX rm -rf $RUNDIR mkdir -p $RUNDIR chmod 777 $RUNDIR export runRUNTIME=3m rm -rf /tmp/stressX.control/* su $testuser -c '(cd ..; ./run.sh all.cfg) > /dev/null 2>&1' & sleep 60 while mount | grep -q $mntpoint; do umount -f $mntpoint > /dev/null 2>&1 done kill -9 $! done ../tools/killall.sh rm -rf /tmp/nfs9 Index: user/pho/stress2/misc/nfsrename.sh =================================================================== --- user/pho/stress2/misc/nfsrename.sh (revision 276739) +++ user/pho/stress2/misc/nfsrename.sh (revision 276740) @@ -1,210 +1,214 @@ #!/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. # # $FreeBSD$ # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg # Test scenario by jhb@ +[ -z "$nfs_export" ] && exit 0 +ping -c 2 `echo $nfs_export | sed 's/:.*//'` > /dev/null 2>&1 || + exit 0 + odir=`pwd` cd /tmp sed '1,/^EOF/d' < $odir/$0 > nfsrename.c cc -o nfsrename -Wall nfsrename.c rm -f nfsrename.c cd $odir mount | grep "$mntpoint" | grep nfs > /dev/null && umount $mntpoint -mount -t nfs -o tcp -o retrycnt=3 -o intr -o soft -o rw 127.0.0.1:/tmp $mntpoint +mount -t nfs -o tcp -o retrycnt=3 -o intr -o soft -o rw $nfs_export $mntpoint for i in `jot 10`; do /tmp/nfsrename $mntpoint/nfsrename.$i & done for i in `jot 10`; do wait done killall nfsrename rm -f $mntpoint/nfsrename.* umount $mntpoint > /dev/null 2>&1 while mount | grep "$mntpoint" | grep -q nfs; do umount -f $mntpoint > /dev/null 2>&1 done rm -f /tmp/nfsrename exit EOF /* * Try to expose races with doing renames over NFS that require silly * renames. This results in 2 different RENAME RPCs leaving a race * window where the file may not exist. It also appears that FreeBSD * with shared lookups in NFS can get confused and possibly reference * the sillyrenamed file in lookup but the file is deleted by the time * open gets to it. */ #include #include #include #include #include #include const char *filename; const char *dir; static void usage(void) { fprintf(stderr, "nfsrename: [-n children] file\n"); exit(1); } static void read_file(void) { FILE *fp; char buffer[4096]; fp = fopen(filename, "r"); if (fp == NULL) { warn("fopen"); return; } while (!feof(fp)) { if (fread(buffer, sizeof(buffer), 1, fp) < sizeof(buffer)) break; } if (ferror(fp)) warnx("fread encountered an error"); fclose(fp); } static void write_file(void) { FILE *fp; char path[1024]; int fd; snprintf(path, sizeof(path), "%s/nfsrename.XXXXXX", dir); fd = mkstemp(path); if (fd < 0) { warn("mkstemp"); return; } fp = fdopen(fd, "w"); if (fp == NULL) { warn("fopen:writer"); close(fd); unlink(path); } fprintf(fp, "blah blah blah garbage %ld\n", random()); fclose(fp); if (rename(path, filename) < 0) { warn("rename"); unlink(path); } } static void random_sleep(int base, int slop) { long val; val = random() % slop; usleep(base + val); } static void child(void) { for (;;) { random_sleep(500, 50); read_file(); } exit(0); } int main(int ac, char **av) { long i, nchild; char *cp; int ch; nchild = 1; while ((ch = getopt(ac, av, "n:")) != -1) { switch (ch) { case 'n': nchild = strtol(optarg, &cp, 0); if (*cp != '\0') errx(1, "Invalid count %s", optarg); break; case '?': default: usage(); } } ac -= optind; av += optind; if (ac == 0) errx(1, "Missing filename"); else if (ac > 1) errx(1, "Extra arguments"); filename = av[0]; dir = dirname(filename); srandomdev(); write_file(); for (i = 0; i < nchild; i++) { switch (fork()) { case 0: child(); case -1: err(1, "fork"); } } for (i = 0; i < 10000; i++) { random_sleep(1500, 1000); write_file(); } return (0); } Index: user/pho/stress2/misc/readdir.sh =================================================================== --- user/pho/stress2/misc/readdir.sh (revision 276739) +++ user/pho/stress2/misc/readdir.sh (revision 276740) @@ -1,173 +1,175 @@ #!/bin/sh # # Copyright (c) 2011 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$ # # readdir(3) fuzzing inspired by the iknowthis test suite # by Tavis Ormandy # "panic: kmem_malloc(1328054272): kmem_map too small" seen [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > readdir.c cc -o readdir -Wall -Wextra readdir.c rm -f readdir.c mount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mount -t tmpfs tmpfs $mntpoint echo "Testing tmpfs(5)" cp -a /usr/include $mntpoint /tmp/readdir $mntpoint umount $mntpoint echo "Testing fdescfs(5)" mount -t fdescfs null /dev/fd /tmp/readdir /dev/fd umount /dev/fd echo "Testing procfs(5)" mount -t procfs procfs $mntpoint /tmp/readdir $mntpoint umount $mntpoint -echo "Testing nfs" -mount -t nfs -o nfsv3,tcp,nolockd 127.0.0.1:/tmp $mntpoint -/tmp/readdir $mntpoint -umount $mntpoint +if ping -c 2 `echo $nfs_export | sed 's/:.*//'` > /dev/null 2>&1; then + echo "Testing nfs" + mount -t nfs -o nfsv3,tcp,nolockd $nfs_export $mntpoint + /tmp/readdir $mntpoint + umount $mntpoint +fi mdconfig -a -t swap -s 1g -u $mdstart || exit 1 bsdlabel -w md$mdstart auto newfs md${mdstart}$part > /dev/null mount /dev/md${mdstart}$part $mntpoint cp -a /usr/include $mntpoint echo "Testing UFS" /tmp/readdir $mntpoint umount $mntpoint mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart || exit 1 bsdlabel -w md$mdstart auto newfs $newfs_flags md${mdstart}$part > /dev/null mount /dev/md${mdstart}$part $mntpoint cp -a /usr/include $mntpoint echo "Testing FFS" /tmp/readdir $mntpoint umount $mntpoint mdconfig -d -u $mdstart mount -t nullfs /bin $mntpoint echo "Testing nullfs(5)" /tmp/readdir $mntpoint umount $mntpoint rm -f /tmp/readdir exit 0 EOF #include #include #include #include #include #include #include #include #include #include #include /* copy from /usr/src/lib/libc/gen/gen-private.h */ struct _telldir; /* see telldir.h */ struct pthread_mutex; /* * Structure describing an open directory. * * NOTE. Change structure layout with care, at least dd_fd field has to * remain unchanged to guarantee backward compatibility. */ struct _dirdesc { int dd_fd; /* file descriptor associated with directory */ long dd_loc; /* offset in current buffer */ long dd_size; /* amount of data returned by getdirentries */ char *dd_buf; /* data buffer */ int dd_len; /* size of data buffer */ long dd_seek; /* magic cookie returned by getdirentries */ long dd_rewind; /* magic cookie for rewinding */ int dd_flags; /* flags for readdir */ struct pthread_mutex *dd_lock; /* lock */ struct _telldir *dd_td; /* telldir position recording */ }; /* End copy */ static void hand(int i __unused) { /* handler */ _exit(1); } int test(char *path) { DIR *dirp, fuzz; int i; signal(SIGSEGV, hand); for (i = 0; i < 2000; i++) { if ((dirp = opendir(path)) == NULL) break; bcopy(dirp, &fuzz, sizeof(fuzz)); fuzz.dd_len = arc4random(); readdir(&fuzz); closedir(dirp); } exit(0); } int main(int argc __unused, char **argv) { int i; for (i = 0; i < 1000; i++) { if (fork() == 0) test(argv[1]); wait(NULL); } return (0); }