Index: user/pho/stress2/misc/alternativeFlushPath.sh =================================================================== --- user/pho/stress2/misc/alternativeFlushPath.sh (revision 291421) +++ user/pho/stress2/misc/alternativeFlushPath.sh (revision 291422) @@ -1,129 +1,127 @@ #!/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$ # # Alternate buffer flush path test (Not verified). # Regression test for r169006. # Apply this patch to amplify the problem: # # diff -r1.520 vfs_bio.c # 894c894 # < if (bo->bo_dirty.bv_cnt > dirtybufthresh + 10) { # --- # > if (bo->bo_dirty.bv_cnt > dirtybufthresh /*+ 10*/) { . ../default.cfg odir=`pwd` dir=${RUNDIR}/alternativeFlushPath [ -d $dir ] && find $dir -type f | xargs rm rm -rf $dir mkdir -p $dir cd $dir sed '1,/^EOF/d' < $odir/$0 > $dir/alternativeFlushPath.c mycc -o /tmp/alternativeFlushPath -Wall -Wextra alternativeFlushPath.c rm -f alternativeFlushPath.c for j in `jot 10`; do /tmp/alternativeFlushPath & done -for j in `jot 10`; do - wait -done +wait sysctl vfs.altbufferflushes rm -rf /tmp/alternativeFlushPath $dir exit EOF #include #include #include #include #include #include #include #include #include static volatile sig_atomic_t more; static void handler(int i __unused) { more = 0; } void test(void) { int i, j; char name[80]; pid_t mypid; int *fd; struct rlimit rlp; if (getrlimit(RLIMIT_NOFILE, &rlp) == -1) err(1, "getrlimit(RLIMIT_NOFILE)"); rlp.rlim_cur /= 10; mypid = getpid(); fd = malloc(rlp.rlim_cur * sizeof(int)); for (i = 0, j = 0; i < rlp.rlim_cur && more == 1; i++, j++) { sprintf(name, "f%05d.%05d", mypid, i); if ((fd[i] = open(name, O_CREAT|O_WRONLY, 0666)) == -1) { warn("open(%s)", name); more = 0; break; } } for (i = 0; i < j; i++) { sprintf(name, "f%05d.%05d", mypid, i); if (unlink(name) == -1) warn("unlink(%s)", name); } for (i = 0; i < j; i++) { if (close(fd[i]) == -1) warn("close(%d)", i); } free(fd); } int main() { more = 1; signal(SIGALRM, handler); alarm(20 * 60); while (more == 1) test(); return(0); } Index: user/pho/stress2/misc/devfs.sh =================================================================== --- user/pho/stress2/misc/devfs.sh (revision 291421) +++ user/pho/stress2/misc/devfs.sh (revision 291422) @@ -1,73 +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. # # $FreeBSD$ # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg mounts=15 # Number of parallel scripts cont=/tmp/devfs.continue if [ $# -eq 0 ]; then touch $cont for i in `jot $mounts`; do [ ! -d ${mntpoint}$i ] && mkdir ${mntpoint}$i mount | grep -q "on ${mntpoint}$i " && umount ${mntpoint}$i 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 while [ -r $cont ]; do find ${mntpoint}* -maxdepth 1 -type f > /dev/null 2>&1 done else # The test: Parallel mount and unmounts start=`date '+%s'` while [ `date '+%s'` -lt $((start + 300)) ]; do m=$1 mount -t devfs none ${mntpoint}$m opt=`[ $(( m % 2 )) -eq 0 ] && echo -f` while mount | grep -q " ${mntpoint}$m "; do umount $opt ${mntpoint}$m > /dev/null 2>&1 done done rm -f $cont fi fi Index: user/pho/stress2/misc/fdescfs.sh =================================================================== --- user/pho/stress2/misc/fdescfs.sh (revision 291421) +++ user/pho/stress2/misc/fdescfs.sh (revision 291422) @@ -1,75 +1,72 @@ #!/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 seen in fdesc_allocvp+0x8f: # http://people.freebsd.org/~pho/stress/log/fdescfs-2.txt # Fixed by r279401 [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg mounts=15 # Number of parallel scripts cont=/tmp/fdescfs.continue if [ $# -eq 0 ]; then touch $cont # start the parallel tests for i in `jot $mounts`; do [ -d ${mntpoint}$i ] || mkdir -p ${mntpoint}$i ./$0 $i & ./$0 find & done - - for i in `jot $mounts`; do - wait; wait - done + wait else if [ $1 = find ]; then exec 6< /dev/zero exec 7< /dev/zero exec 8< /dev/zero exec 9< /dev/zero while [ -r $cont ]; do ls -l ${mntpoint}* > /dev/null 2>&1 done else # The test: Parallel mount and unmounts start=`date '+%s'` while [ `date '+%s'` -lt $((start + 300)) ]; do mount -t fdescfs null ${mntpoint}$1 while mount | grep -wq ${mntpoint}$1; do umount -f ${mntpoint}$1 > /dev/null 2>&1 done done rm -f $cont fi fi Index: user/pho/stress2/misc/fuse2.sh =================================================================== --- user/pho/stress2/misc/fuse2.sh (revision 291421) +++ user/pho/stress2/misc/fuse2.sh (revision 291422) @@ -1,94 +1,91 @@ #!/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$ # # Parallel mount and umount test # livelock seen [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 [ -z "`type mkntfs 2>/dev/null`" ] && exit 0 [ -c /dev/fuse ] || kldload fuse.ko . ../default.cfg [ -c /dev/fuse ] || kldload fuse.ko MOUNT=/usr/local/bin/ntfs-3g 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 mdconfig -l | grep -q md$m && mdconfig -d -u $m mdconfig -a -t swap -s 1g -u $m mkntfs -Ff /dev/md$m > /dev/null 2>&1 || exit 1 done # start the parallel tests for i in `jot $mounts`; do m=$(( i + mdstart - 1 )) ./$0 $m & ./$0 find & done - - for i in `jot $mounts`; do - wait; wait - done + wait for i in `jot $mounts`; do m=$(( i + mdstart - 1 )) mdconfig -d -u $m done else if [ $1 = find ]; then while mount | grep -q fusefs; do find ${mntpoint}* -type f > /dev/null 2>&1 sleep 1 done else # The test: Parallel mount and unmounts for i in `jot 100`; do m=$1 $MOUNT /dev/md$m ${mntpoint}$m || continue cp -r /usr/include/sys ${mntpoint}$m/file.$m 2>/dev/null sleep .5 while mount | grep -q ${mntpoint}$m; do umount ${mntpoint}$m > /dev/null 2>&1 || sleep 1 done done fi fi Index: user/pho/stress2/misc/isofs.sh =================================================================== --- user/pho/stress2/misc/isofs.sh (revision 291421) +++ user/pho/stress2/misc/isofs.sh (revision 291422) @@ -1,64 +1,62 @@ #!/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$ # [ `id -u ` -ne 0 ] && echo "Must not be root!" && exit 1 [ -z "`type mkisofs 2>/dev/null`" ] && echo "mkisofs not found" && exit 1 . ../default.cfg D=`dirname $diskimage`/dir I=`dirname $diskimage`/dir.iso export here=`pwd` cd /tmp mycc -o fstool $here/../tools/fstool.c rm -rf $D $I mkdir $D (cd $D; /tmp/fstool -n 10 -l -f 512) mkisofs -o $I -r $D > /dev/null 2>&1 mdconfig -a -t vnode -f $I -u ${mdstart} mount -t cd9660 /dev/md${mdstart} $mntpoint for i in `jot 64`; do find /$mntpoint -type f > /dev/null 2>&1 & done -for i in `jot 64`; do - wait -done +wait umount ${mntpoint} mdconfig -d -u ${mdstart} rm -rf $D $I fstool Index: user/pho/stress2/misc/pfl2.sh =================================================================== --- user/pho/stress2/misc/pfl2.sh (revision 291421) +++ user/pho/stress2/misc/pfl2.sh (revision 291422) @@ -1,104 +1,104 @@ #!/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$ # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 # Test scenario for the change of a global SU lock to a per filesystem lock. # "panic: softdep_write_inodeblock: indirect pointer #0 mismatch ..." seen. # http://people.freebsd.org/~pho/stress/log/kirk063.txt . ../default.cfg [ `swapinfo | wc -l` -eq 1 ] && exit 0 mp1=$mntpoint mp2=${mntpoint}2 [ -d $mp2 ] || mkdir -p $mp2 md1=$mdstart md2=$((mdstart + 1)) usermem=`sysctl -n hw.usermem` size=$((2 * 1024 * 1024 * 1024)) # Ideal disk size is 2G [ $((size * 2)) -gt $usermem ] && size=$((usermem / 2)) size=$((size / 1024 / 1024)) opt=$([ $((`date '+%s'` % 2)) -eq 0 ] && echo "-j" || echo "-U") [ "$newfs_flags" = "-U" ] || opt="" mount | grep "on $mp1 " | grep -q /dev/md && umount -f $mp1 mdconfig -l | grep -q md$md1 && mdconfig -d -u $md1 mdconfig -a -t swap -s ${size}m -u $md1 bsdlabel -w md$md1 auto newfs $opt md${md1}$part > /dev/null mount /dev/md${md1}$part $mp1 chmod 777 $mp1 mount | grep "on $mp2 " | grep -q /dev/md && umount -f $mp2 mdconfig -l | grep -q md$md2 && mdconfig -d -u $md2 mdconfig -a -t swap -s ${size}m -u $md2 bsdlabel -w md$md2 auto newfs $opt md${md2}$part > /dev/null mount /dev/md${md2}$part $mp2 chmod 777 $mp2 export runRUNTIME=10m export RUNDIR=$mp1/stressX export CTRLDIR=$mp1/stressX.control export LOAD=80 export symlinkLOAD=80 export rwLOAD=80 export TESTPROGS=" testcases/lockf2/lockf2 testcases/symlink/symlink testcases/openat/openat testcases/rw/rw testcases/fts/fts testcases/link/link testcases/lockf/lockf testcases/creat/creat testcases/mkdir/mkdir testcases/rename/rename testcases/mkfifo/mkfifo " su $testuser -c 'cd ..; ./testcases/run/run $TESTPROGS' > /dev/null 2>&1 & export TESTPROGS="$TESTPROGS testcases/swap/swap" export RUNDIR=$mp2/stressX export CTRLDIR=$mp2/stressX.control su $testuser -c 'cd ..; ./testcases/run/run $TESTPROGS' > /dev/null 2>&1 & -wait; wait +wait while mount | grep "$mp2 " | grep -q /dev/md; do umount $mp2 || sleep 1 done mdconfig -d -u $md2 while mount | grep "$mp1 " | grep -q /dev/md; do umount $mp1 || sleep 1 done mdconfig -d -u $md1 Index: user/pho/stress2/misc/procfs.sh =================================================================== --- user/pho/stress2/misc/procfs.sh (revision 291421) +++ user/pho/stress2/misc/procfs.sh (revision 291422) @@ -1,74 +1,71 @@ #!/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$ # [ `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 - - for i in `jot $mounts`; do - wait; wait - 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 1024`; 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 Index: user/pho/stress2/misc/pthread3.sh =================================================================== --- user/pho/stress2/misc/pthread3.sh (revision 291421) +++ user/pho/stress2/misc/pthread3.sh (revision 291422) @@ -1,301 +1,299 @@ #!/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$ # # _exit(2) test scenario with focus on shared channel tear down. . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > pthread3.c mycc -o pthread3 -Wall -Wextra -O2 -g -gdwarf-2 pthread3.c -lpthread || exit 1 rm -f pthread3.c for i in `jot 8`; do /tmp/pthread3 & done -for i in `jot 8`; do - wait -done +wait rm -f /tmp/pthread3 exit 0 EOF /* * Threaded producer-consumer test. * Loosly based on work by * Andrey Zonov (c) 2012 */ #include #include #include #include #include #include #include #include #ifdef __FreeBSD__ #include #define __NP__ #endif #include #include #include #include #include #include #include #include #define LOCK(x) plock(&x.mtx) #define UNLOCK(x) punlock(&x.mtx) #define SIGNAL(x) psig(&x.wait) #define WAIT(x) pwait(&x.wait, &x.mtx) long ncreate, nrename, nunlink; int max; char *dirname1; char *dirname2; struct file { char *name; STAILQ_ENTRY(file) next; }; struct files { pthread_mutex_t mtx; pthread_cond_t wait; STAILQ_HEAD(, file) list; }; static struct files newfiles; static struct files renamedfiles; static void hand(int i __unused) { /* handler */ fprintf(stderr, "max = %d, ncreate = %ld, nrename = %ld, nunlink = %ld\n", max, ncreate, nrename, nunlink); } static void ahand(int i __unused) { /* handler */ fprintf(stderr, "FAIL\n"); hand(0); _exit(0); } void plock(pthread_mutex_t *l) { int rc; if ((rc = pthread_mutex_lock(l)) != 0) errc(1, rc, "pthread_mutex_lock"); } void punlock(pthread_mutex_t *l) { int rc; if ((rc = pthread_mutex_unlock(l)) != 0) errc(1, rc, "pthread_mutex_unlock"); } void psig(pthread_cond_t *c) { int rc; if ((rc = pthread_cond_signal(c)) != 0) errc(1, rc, "pthread_cond_signal"); } void pwait(pthread_cond_t *c, pthread_mutex_t *l) { int rc; if ((rc = pthread_cond_wait(c, l)) != 0) errc(1, rc, "pthread_cond_wait"); } void * loop_create(void *arg __unused) { int i, j; struct file *file; #ifdef __NP__ pthread_set_name_np(pthread_self(), __func__); #endif for (i = 0; i < max; i++) { file = malloc(sizeof(*file)); asprintf(&file->name, "%s/filename_too-long:%d", dirname1, i); LOCK(newfiles); STAILQ_INSERT_TAIL(&newfiles.list, file, next); ncreate++; UNLOCK(newfiles); SIGNAL(newfiles); if ((i > 0) && (i % 100000 == 0)) for (j = 0; j < 10 && ncreate != nrename; j++) usleep(400); } return (NULL); } void * loop_rename(void *arg __unused) { char *filename, *newname; struct file *file; #ifdef __NP__ pthread_set_name_np(pthread_self(), __func__); #endif while (nrename < max) { LOCK(newfiles); while (STAILQ_EMPTY(&newfiles.list)) { WAIT(newfiles); } file = STAILQ_FIRST(&newfiles.list); STAILQ_REMOVE_HEAD(&newfiles.list, next); UNLOCK(newfiles); filename = strrchr(file->name, '/'); asprintf(&newname, "%s/%s", dirname2, filename); nrename++; free(file->name); file->name = newname; LOCK(renamedfiles); STAILQ_INSERT_TAIL(&renamedfiles.list, file, next); UNLOCK(renamedfiles); SIGNAL(renamedfiles); } return (NULL); } void * loop_unlink(void *arg __unused) { struct file *file; #ifdef __NP__ pthread_set_name_np(pthread_self(), __func__); #endif while (nunlink < max) { LOCK(renamedfiles); while (STAILQ_EMPTY(&renamedfiles.list)) { WAIT(renamedfiles); } file = STAILQ_FIRST(&renamedfiles.list); STAILQ_REMOVE_HEAD(&renamedfiles.list, next); nunlink++; UNLOCK(renamedfiles); free(file->name); free(file); if (arc4random() % 100 == 1) if (arc4random() % 100 == 1) if (arc4random() % 100 < 10) _exit(0); } return (NULL); } void test(void) { int i; int rc; pthread_t tid[3]; asprintf(&dirname1, "%s.1", "f1"); asprintf(&dirname2, "%s.2", "f2"); max = 15000000; STAILQ_INIT(&newfiles.list); STAILQ_INIT(&renamedfiles.list); if ((rc = pthread_mutex_init(&newfiles.mtx, NULL)) != 0) errc(1, rc, "pthread_mutex_init()"); if ((rc = pthread_cond_init(&newfiles.wait, NULL)) != 0) errc(1, rc, "pthread_cond_init()"); if ((rc = pthread_mutex_init(&renamedfiles.mtx, NULL)) != 0) errc(1, rc, "pthread_mutex_init()"); if ((rc = pthread_cond_init(&renamedfiles.wait, NULL)) != 0) errc(1, rc, "pthread_cond_init()"); signal(SIGINFO, hand); signal(SIGALRM, ahand); alarm(300); if ((rc = pthread_create(&tid[0], NULL, loop_create, NULL)) != 0) errc(1, rc, "pthread_create()"); if ((rc = pthread_create(&tid[1], NULL, loop_rename, NULL)) != 0) errc(1, rc, "pthread_create()"); if ((rc = pthread_create(&tid[2], NULL, loop_unlink, NULL)) != 0) errc(1, rc, "pthread_create()"); for (i = 0; i < 3; i++) { if ((rc = pthread_join(tid[i], NULL)) != 0) errc(1, rc, "pthread_join(%d)", i); } if ((rc = pthread_mutex_destroy(&newfiles.mtx)) != 0) errc(1, rc, "pthread_mutex_destroy(newfiles)"); if ((rc = pthread_cond_destroy(&newfiles.wait)) != 0) errc(1, rc, "pthread_cond_destroy(newfiles)"); if ((rc = pthread_mutex_destroy(&renamedfiles.mtx)) != 0) errc(1, rc, "pthread_mutex_destroy(renamedfiles)"); if ((rc = pthread_cond_destroy(&renamedfiles.wait)) != 0) errc(1, rc, "pthread_cond_destroy(renamedfiles)"); free(dirname1); free(dirname2); _exit(0); } int main(void) { int i; for (i = 0; i < 1000; i++) { if (fork() == 0) test(); wait(NULL); } return (0); } Index: user/pho/stress2/misc/pthread4.sh =================================================================== --- user/pho/stress2/misc/pthread4.sh (revision 291421) +++ user/pho/stress2/misc/pthread4.sh (revision 291422) @@ -1,301 +1,299 @@ #!/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$ # # PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP version of pthread2.sh . ../default.cfg export LANG=C here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > pthread4.c mycc -o pthread4 -Wall -Wextra -O2 -g -gdwarf-2 pthread4.c -lpthread || exit 1 rm -f pthread4.c /tmp/pthread4.core log=/tmp/pthread4.`date '+%Y%m%d-%H%M'` for i in `jot 5`; do [ $i -eq 1 ] && echo "# `uname -v`" time sh -c ' for i in `jot 8`; do /tmp/pthread4 & done - for i in `jot 8`; do - wait - done + wait ' done > $log 2>&1 rm -f /tmp/pthread4 if [ -n "$bench" ]; then pair=`ls /tmp/pthread4* | egrep "pthread4\.[0-9]{8}-" | sort | tail -2 | tr '\n' ' '` ministat -w 72 $pair else rm -f $log fi exit 0 EOF /* * Threaded producer-consumer test. * Loosly based on work by * Andrey Zonov (c) 2012 */ #include #include #include #include #include #include #include #include #ifdef __FreeBSD__ #include #define __NP__ #endif #include #include #include #include #include #include #include #define LOCK(x) plock(&x.mtx) #define UNLOCK(x) punlock(&x.mtx) #define SIGNAL(x) psig(&x.wait) #define WAIT(x) pwait(&x.wait, &x.mtx) long ncreate, nrename, nunlink; int bench, max; char *dirname1; char *dirname2; struct file { char *name; STAILQ_ENTRY(file) next; }; struct files { pthread_mutex_t mtx; pthread_cond_t wait; STAILQ_HEAD(, file) list; }; static struct files newfiles; static struct files renamedfiles; static void hand(int i __unused) { /* handler */ fprintf(stderr, "max = %d, ncreate = %ld, nrename = %ld, nunlink = %ld\n", max, ncreate, nrename, nunlink); } static void ahand(int i __unused) { /* handler */ fprintf(stderr, "FAIL\n"); hand(0); _exit(0); } void plock(pthread_mutex_t *l) { int rc; if ((rc = pthread_mutex_lock(l)) != 0) errc(1, rc, "pthread_mutex_lock"); } void punlock(pthread_mutex_t *l) { int rc; if ((rc = pthread_mutex_unlock(l)) != 0) errc(1, rc, "pthread_mutex_unlock"); } void psig(pthread_cond_t *c) { int rc; if ((rc = pthread_cond_signal(c)) != 0) errc(1, rc, "pthread_cond_signal"); } void pwait(pthread_cond_t *c, pthread_mutex_t *l) { int rc; if ((rc = pthread_cond_wait(c, l)) != 0) errc(1, rc, "pthread_cond_wait"); } void * loop_create(void *arg __unused) { int i, j; struct file *file; #ifdef __NP__ pthread_set_name_np(pthread_self(), __func__); #endif for (i = 0; i < max; i++) { file = malloc(sizeof(*file)); asprintf(&file->name, "%s/filename_too-long:%d", dirname1, i); LOCK(newfiles); STAILQ_INSERT_TAIL(&newfiles.list, file, next); ncreate++; UNLOCK(newfiles); SIGNAL(newfiles); if ((bench == 0) && (i > 0) && (i % 100000 == 0)) for (j = 0; j < 10 && ncreate != nrename; j++) usleep(400); } return (NULL); } void * loop_rename(void *arg __unused) { char *filename, *newname; struct file *file; #ifdef __NP__ pthread_set_name_np(pthread_self(), __func__); #endif while (nrename < max) { LOCK(newfiles); while (STAILQ_EMPTY(&newfiles.list)) { WAIT(newfiles); } file = STAILQ_FIRST(&newfiles.list); STAILQ_REMOVE_HEAD(&newfiles.list, next); UNLOCK(newfiles); filename = strrchr(file->name, '/'); asprintf(&newname, "%s/%s", dirname2, filename); nrename++; free(file->name); file->name = newname; LOCK(renamedfiles); STAILQ_INSERT_TAIL(&renamedfiles.list, file, next); UNLOCK(renamedfiles); SIGNAL(renamedfiles); } return (NULL); } void * loop_unlink(void *arg __unused) { struct file *file; #ifdef __NP__ pthread_set_name_np(pthread_self(), __func__); #endif while (nunlink < max) { LOCK(renamedfiles); while (STAILQ_EMPTY(&renamedfiles.list)) { WAIT(renamedfiles); } file = STAILQ_FIRST(&renamedfiles.list); STAILQ_REMOVE_HEAD(&renamedfiles.list, next); nunlink++; UNLOCK(renamedfiles); free(file->name); free(file); } return (NULL); } int main(void) { int i; int rc; pthread_t tid[3]; pthread_mutexattr_t attr, *pattr = NULL; bench = getenv("bench") != NULL; asprintf(&dirname1, "%s.1", "f1"); asprintf(&dirname2, "%s.2", "f2"); max = 15000000; STAILQ_INIT(&newfiles.list); STAILQ_INIT(&renamedfiles.list); pthread_mutexattr_init (&attr); pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ADAPTIVE_NP); pattr = &attr; if ((rc = pthread_mutex_init(&newfiles.mtx, pattr)) != 0) errc(1, rc, "pthread_mutex_init()"); if ((rc = pthread_cond_init(&newfiles.wait, NULL)) != 0) errc(1, rc, "pthread_cond_init()"); if ((rc = pthread_mutex_init(&renamedfiles.mtx, NULL)) != 0) errc(1, rc, "pthread_mutex_init()"); if ((rc = pthread_cond_init(&renamedfiles.wait, NULL)) != 0) errc(1, rc, "pthread_cond_init()"); signal(SIGINFO, hand); signal(SIGALRM, ahand); alarm(300); if ((rc = pthread_create(&tid[0], NULL, loop_create, NULL)) != 0) errc(1, rc, "pthread_create()"); if ((rc = pthread_create(&tid[1], NULL, loop_rename, NULL)) != 0) errc(1, rc, "pthread_create()"); if ((rc = pthread_create(&tid[2], NULL, loop_unlink, NULL)) != 0) errc(1, rc, "pthread_create()"); for (i = 0; i < 3; i++) { if ((rc = pthread_join(tid[i], NULL)) != 0) errc(1, rc, "pthread_join(%d)", i); } if ((rc = pthread_mutex_destroy(&newfiles.mtx)) != 0) errc(1, rc, "pthread_mutex_destroy(newfiles)"); if ((rc = pthread_cond_destroy(&newfiles.wait)) != 0) errc(1, rc, "pthread_cond_destroy(newfiles)"); if ((rc = pthread_mutex_destroy(&renamedfiles.mtx)) != 0) errc(1, rc, "pthread_mutex_destroy(renamedfiles)"); if ((rc = pthread_cond_destroy(&renamedfiles.wait)) != 0) errc(1, rc, "pthread_cond_destroy(renamedfiles)"); free(dirname1); free(dirname2); return (0); } Index: user/pho/stress2/misc/quota10.sh =================================================================== --- user/pho/stress2/misc/quota10.sh (revision 291421) +++ user/pho/stress2/misc/quota10.sh (revision 291422) @@ -1,101 +1,98 @@ #!/bin/sh # # Copyright (c) 2008, 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$ # # Hunt for deadlock that could occur running umount and quota at the same time [ `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 export PATH_FSTAB=/tmp/fstab if [ $# -eq 0 ]; then rm -f $PATH_FSTAB 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 dede $D$m 1m 1 mdconfig -a -t vnode -f $D$m -u $m bsdlabel -w md$m auto newfs md${m}${part} > /dev/null 2>&1 echo "/dev/md${m}${part} ${mntpoint}$m ufs rw,userquota 2 2" >> $PATH_FSTAB mount ${mntpoint}$m edquota -u -f ${mntpoint}$m -e ${mntpoint}$m:100000:110000:15000:16000 root umount ${mntpoint}$m done sync;sync;sync # start the parallel tests touch /tmp/$0 for i in `jot $mounts`; do m=$(( i + mdstart - 1 )) ./$0 $m & ./$0 find $m & done + wait for i in `jot $mounts`; do - wait; wait - done - - for i in `jot $mounts`; do m=$(( i + mdstart - 1 )) mdconfig -d -u $m rm -f $D$m done rm -f $PATH_FSTAB else if [ $1 = find ]; then while [ -r /tmp/$0 ]; do ( quotaon ${mntpoint}$2 quotaoff ${mntpoint}$2 ) 2>&1 | egrep -v "No such file or directory" done else # The test: Parallel mount and unmounts - for i in `jot 1000`; do + for i in `jot 200`; do m=$1 opt=`[ $(( m % 2 )) -eq 0 ] && echo -f` mount $opt /dev/md${m}${part} ${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 Index: user/pho/stress2/misc/recursiveflushes.sh =================================================================== --- user/pho/stress2/misc/recursiveflushes.sh (revision 291421) +++ user/pho/stress2/misc/recursiveflushes.sh (revision 291422) @@ -1,79 +1,77 @@ # $FreeBSD$ # # 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$ # # test recursive flushes in bdwrite(). [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg snap() { for i in `jot 5`; do mksnap_ffs $1 $2 [ $? -eq 0 ] && break done } 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 4g -u $mdstart || exit 1 bsdlabel -w md$mdstart auto newfs $newfs_flags md${mdstart}$part > /dev/null mount /dev/md${mdstart}$part $mntpoint old=`sysctl vfs.recursiveflushes | awk '{print $NF}'` cd $mntpoint rm -f $mntpoint/.snap/stress2.* snap $mntpoint $mntpoint/.snap/stress2.1 snap $mntpoint $mntpoint/.snap/stress2.2 snap $mntpoint $mntpoint/.snap/stress2.3 snap $mntpoint $mntpoint/.snap/stress2.4 snap $mntpoint $mntpoint/.snap/stress2.5 for i in `jot 32`; do # Create 32 Mb files dd if=/dev/zero of=big.$i bs=16k count=2048 2>&1 | egrep -v "records|transferred"& done -for i in `jot 32`; do - wait -done +wait for i in `jot 32`; do rm -f big.$i done rm -f $mntpoint/.snap/stress2.* new=`sysctl vfs.recursiveflushes | awk '{print $NF}'` [ $old != $new ] && echo "vfs.recursiveflushes changed from $old to $new" cd / while mount | grep $mntpoint | grep -q /dev/md; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart Index: user/pho/stress2/misc/revoke.sh =================================================================== --- user/pho/stress2/misc/revoke.sh (revision 291421) +++ user/pho/stress2/misc/revoke.sh (revision 291422) @@ -1,120 +1,118 @@ #!/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$ # # Regression test. Causes panic on 6.1 . ../default.cfg odir=`pwd` dir=/tmp cd $dir sed '1,/^EOF/d' < $odir/$0 > $dir/revoke.c mycc -o revoke -Wall revoke.c || exit 1 rm -f revoke.c n=100 # Number of times to test for i in `jot $n`; do ./revoke /dev/ttyv9 > /dev/null 2>&1 & ./revoke /dev/ttyva > /dev/null 2>&1 & ./revoke /dev/ttyvb > /dev/null 2>&1 & ./revoke /dev/ttyvc > /dev/null 2>&1 & - for j in `jot 4`; do - wait - done + wait done rm -f revoke exit EOF /* By Martin Blapp, */ #include #include #include #include #include #include #include #include /*#define TTY "/dev/ttyv9"*/ /* should be totally unused */ #define CTTY "/dev/tty" int main(int argc, char **argv) { int ttyfd; pid_t pid; if (argc != 2) { fprintf(stderr, "Usage: %s /dev/ttyv?\n", argv[0]); return 1; } /* Get rid of my ctty. */ printf("Parent starting: pid %d\n", getpid()); pid = fork(); if (pid < 0) { err(1, "fork"); exit(1); } else if (pid > 0) { int status; /* parent */ waitpid(pid, &status, 0); exit(0); } /* child */ printf("Child: pid %d\n", getpid()); if (setsid() < 0) { err(1, "setsid"); exit(1); } ttyfd = open(argv[1], O_RDWR); if (ttyfd < 0) { err(1, "open(%s)", argv[1]); exit(1); } if (ioctl(ttyfd, TIOCSCTTY) < 0) { err(1, "ioctl(TIOCSCTTY)"); exit(1); } if (revoke(argv[1]) < 0) { err(1, "revoke(%s)", argv[1]); exit(1); } if (open(CTTY, O_RDWR) < 0) { err(1, "open(%s)", CTTY); exit(1); } return 0; } Index: user/pho/stress2/misc/suj30.sh =================================================================== --- user/pho/stress2/misc/suj30.sh (revision 291421) +++ user/pho/stress2/misc/suj30.sh (revision 291422) @@ -1,282 +1,280 @@ #!/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$ # # SUJ rename test scenario by Andrey Zonov # "panic: flush_pagedep_deps: MKDIR_PARENT" seen: # http://people.freebsd.org/~pho/stress/log/suj30.txt [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > suj30.c mycc -o suj30 -Wall -Wextra -O2 suj30.c -lpthread rm -f suj30.c mount | grep "on $mntpoint " | grep -q md$mdstart && umount $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 4g -u ${mdstart} bsdlabel -w md$mdstart auto newfs -j md${mdstart}$part > /dev/null mount /dev/md${mdstart}$part $mntpoint chmod 777 $mntpoint for i in `jot 10`; do /tmp/suj30 $mntpoint/test-$i 100000 & done -for i in `jot 10`; do - wait -done +wait while mount | grep -q $mntpoint; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart rm -f /tmp/suj30 exit 0 EOF /* * Andrey Zonov (c) 2012 * * compile as `cc -o rename rename.c -lpthread' */ #include #include #include #include #include #include #include #include #ifdef __FreeBSD__ #include #define __NP__ #endif #include #include #include #include #include #include #define LOCK(x) pthread_mutex_lock(&x.mtx) #define UNLOCK(x) pthread_mutex_unlock(&x.mtx) #define SIGNAL(x) pthread_cond_signal(&x.wait) #define WAIT(x) pthread_cond_wait(&x.wait, &x.mtx) int max; int exited; char *dirname1; char *dirname2; struct file { char *name; STAILQ_ENTRY(file) next; }; struct files { pthread_mutex_t mtx; pthread_cond_t wait; STAILQ_HEAD(, file) list; }; static struct files newfiles; static struct files renamedfiles; void *loop_create(void *arg __unused); void *loop_rename(void *arg __unused); void *loop_unlink(void *arg __unused); int main(int argc, char **argv) { int i; int rc; pthread_t tid[3]; if (argc != 3) errx(1, "usage: pthread_count "); asprintf(&dirname1, "%s.1", argv[1]); asprintf(&dirname2, "%s.2", argv[1]); if (mkdir(dirname1, 0755) == -1) err(1, "mkdir(%s)", dirname1); if (mkdir(dirname2, 0755) == -1) err(1, "mkdir(%s)", dirname2); max = atoi(argv[2]); STAILQ_INIT(&newfiles.list); STAILQ_INIT(&renamedfiles.list); rc = pthread_mutex_init(&newfiles.mtx, NULL); if (rc != 0) errc(1, rc, "pthread_mutex_init()"); rc = pthread_cond_init(&newfiles.wait, NULL); if (rc != 0) errc(1, rc, "pthread_cond_init()"); rc = pthread_mutex_init(&renamedfiles.mtx, NULL); if (rc != 0) errc(1, rc, "pthread_mutex_init()"); rc = pthread_cond_init(&renamedfiles.wait, NULL); if (rc != 0) errc(1, rc, "pthread_cond_init()"); rc = pthread_create(&tid[0], NULL, loop_create, NULL); if (rc != 0) errc(1, rc, "pthread_create()"); rc = pthread_create(&tid[1], NULL, loop_rename, NULL); if (rc != 0) errc(1, rc, "pthread_create()"); rc = pthread_create(&tid[2], NULL, loop_unlink, NULL); if (rc != 0) errc(1, rc, "pthread_create()"); for (i = 0; i < 3; i++) { rc = pthread_join(tid[i], NULL); if (rc != 0) errc(1, rc, "pthread_join(%d)", i); } rc = pthread_mutex_destroy(&newfiles.mtx); if (rc != 0) errc(1, rc, "pthread_mutex_destroy(newfiles)"); rc = pthread_cond_destroy(&newfiles.wait); if (rc != 0) errc(1, rc, "pthread_cond_destroy(newfiles)"); rc = pthread_mutex_destroy(&renamedfiles.mtx); if (rc != 0) errc(1, rc, "pthread_mutex_destroy(renamedfiles)"); rc = pthread_cond_destroy(&renamedfiles.wait); if (rc != 0) errc(1, rc, "pthread_cond_destroy(renamedfiles)"); rmdir(dirname1); rmdir(dirname2); free(dirname1); free(dirname2); exit(0); } void * loop_create(void *arg __unused) { int i; struct file *file; #ifdef __NP__ pthread_set_name_np(pthread_self(), __func__); #endif for (i = 0; i < max; i++) { file = malloc(sizeof(*file)); asprintf(&file->name, "%s/filename_too-long:%d", dirname1, i); if (mkdir(file->name, 0666) == -1) { warn("mkdir(%s)", file->name); free(file->name); free(file); break; } LOCK(newfiles); STAILQ_INSERT_TAIL(&newfiles.list, file, next); UNLOCK(newfiles); SIGNAL(newfiles); } exited = 1; SIGNAL(newfiles); pthread_exit(NULL); } void * loop_rename(void *arg __unused) { char *filename, *newname; struct file *file; #ifdef __NP__ pthread_set_name_np(pthread_self(), __func__); #endif for ( ;; ) { LOCK(newfiles); while (STAILQ_EMPTY(&newfiles.list) && exited < 1) WAIT(newfiles); if (STAILQ_EMPTY(&newfiles.list) && exited == 1) { UNLOCK(newfiles); break; } file = STAILQ_FIRST(&newfiles.list); STAILQ_REMOVE_HEAD(&newfiles.list, next); UNLOCK(newfiles); filename = strrchr(file->name, '/'); asprintf(&newname, "%s/%s", dirname2, filename); if (rename(file->name, newname) == -1) err(1, "rename(%s, %s)", file->name, newname); free(file->name); file->name = newname; LOCK(renamedfiles); STAILQ_INSERT_TAIL(&renamedfiles.list, file, next); UNLOCK(renamedfiles); SIGNAL(renamedfiles); } exited = 2; SIGNAL(renamedfiles); pthread_exit(NULL); } void * loop_unlink(void *arg __unused) { struct file *file; #ifdef __NP__ pthread_set_name_np(pthread_self(), __func__); #endif for ( ;; ) { LOCK(renamedfiles); while (STAILQ_EMPTY(&renamedfiles.list) && exited < 2) WAIT(renamedfiles); if (STAILQ_EMPTY(&renamedfiles.list) && exited == 2) { UNLOCK(renamedfiles); break; } file = STAILQ_FIRST(&renamedfiles.list); STAILQ_REMOVE_HEAD(&renamedfiles.list, next); UNLOCK(renamedfiles); rmdir(file->name); free(file->name); free(file); } pthread_exit(NULL); } Index: user/pho/stress2/misc/tmpfs2.sh =================================================================== --- user/pho/stress2/misc/tmpfs2.sh (revision 291421) +++ user/pho/stress2/misc/tmpfs2.sh (revision 291422) @@ -1,69 +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. # # $FreeBSD$ # # 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 - - for i in `jot $mounts`; do - wait; wait - done + wait else if [ $1 = find ]; then for i in `jot 1024`; do find ${mntpoint}* -type f > /dev/null 2>&1 done else # The test: Parallel mount and unmounts for i in `jot 1024`; 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 Index: user/pho/stress2/misc/umountf4.sh =================================================================== --- user/pho/stress2/misc/umountf4.sh (revision 291421) +++ user/pho/stress2/misc/umountf4.sh (revision 291422) @@ -1,89 +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. # # $FreeBSD$ # # 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 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 $m & ./$0 find & done - - for i in `jot $mounts`; do - wait; wait - 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 find ${mntpoint}* -type f > /dev/null 2>&1 done else # The test: Parallel mount and unmounts for i in `jot 100`; do m=$1 opt=`[ $(( m % 2 )) -eq 0 ] && echo -f` mount $opt /dev/md${m}${part} ${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 Index: user/pho/stress2/misc/umountf6.sh =================================================================== --- user/pho/stress2/misc/umountf6.sh (revision 291421) +++ user/pho/stress2/misc/umountf6.sh (revision 291422) @@ -1,91 +1,88 @@ #!/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$ # # 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 dede $D$m 1m 10 dd if=/dev/zero of=$D$m bs=1m count=10 2>&1 | egrep -v "records|transferred" mdconfig -a -t vnode -f $D$m -u $m bsdlabel -w md$m auto newfs $newfs_flags md${m}$part > /dev/null 2>&1 done # start the parallel tests for i in `jot $mounts`; do m=$((i + mdstart - 1)) ./$0 $m & ./$0 find & done - - for i in `jot $mounts`; do - wait; wait - 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 find ${mntpoint}* -type f > /dev/null 2>&1 done else # The test: Parallel mount and unmounts for i in `jot 100`; do m=$1 opt=`[ $(( m % 2 )) -eq 0 ] && echo -f` mount $opt /dev/md${m}$part ${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 Index: user/pho/stress2/misc/vunref.sh =================================================================== --- user/pho/stress2/misc/vunref.sh (revision 291421) +++ user/pho/stress2/misc/vunref.sh (revision 291422) @@ -1,225 +1,222 @@ #!/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 - - for i in `jot $mounts`; do - wait; wait - 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 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); }