Index: user/pho/stress2/misc/core.sh =================================================================== --- user/pho/stress2/misc/core.sh (revision 306944) +++ user/pho/stress2/misc/core.sh (revision 306945) @@ -1,79 +1,79 @@ #!/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$ # # Test multiple (parallel) core dumps . ../default.cfg odir=`pwd` cd /tmp rm -f core sed '1,/^EOF/d' < $odir/$0 > core.c mycc -o core -Wall core.c rm -f core.c cd $RUNDIR for i in `jot 2`; do for j in `jot 4`; do /tmp/core & done for j in `jot 4`; do wait done done -rm -f core +rm -f /tmp/core exit EOF #include #include #include #include #include #include #include #define SIZ 10*1024*1024 int main(int argc, char **argv) { char *cp; if ((cp = malloc(SIZ)) == NULL) err(1, "Could not malloc 10Mb!"); memset(cp, 1, SIZ); sleep(120 - (time(NULL) % 120)); raise(SIGSEGV); return (0); } Index: user/pho/stress2/misc/core2.sh =================================================================== --- user/pho/stress2/misc/core2.sh (revision 306944) +++ user/pho/stress2/misc/core2.sh (revision 306945) @@ -1,96 +1,96 @@ #!/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$ # # Test multiple (parallel) core dumps and umount . ../default.cfg odir=`pwd` cd /tmp sed '1,/^EOF/d' < $odir/$0 > core2.c mycc -o core2 -Wall -Wextra -O0 core2.c || exit 1 rm -f core2.c cd $RUNDIR mount | grep "on $mntpoint " | grep -q md$mdstart && umount $mntpoint [ -c /dev/mn$mdstart ] && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart bsdlabel -w md$mdstart auto newfs $newfs_flags md${mdstart}$part > /dev/null mount /dev/md${mdstart}$part $mntpoint touch /tmp/continue for i in `jot 64`; do mkdir -p $mntpoint/d$i (cd $mntpoint; /tmp/core2) & done rm -f /tmp/continue for i in `jot 60`; do umount $mntpoint 2>/dev/null || sleep 1 mount | grep -q "on $mntpoint " || break done wait mount | grep -q "on $mntpoint " && umount -f $mntpoint mdconfig -d -u $mdstart -rm -f core2 +rm -f /tmp/core2 exit EOF #include #include #include #include #include #include #include #include #define SIZ 1L * 128 * 1024 * 1024 void *p; int main(void) { size_t len; len = SIZ; p = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_ANON, -1, 0); while (access("/tmp/continue", R_OK) == 0) usleep(1); raise(SIGSEGV); return (0); } Index: user/pho/stress2/misc/core3.sh =================================================================== --- user/pho/stress2/misc/core3.sh (revision 306944) +++ user/pho/stress2/misc/core3.sh (revision 306945) @@ -1,170 +1,170 @@ #!/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$ # # Test multiple (parallel) core dumps and mount / umount. # mount(8) stuck in "ufs" or "tmpfs". # http://people.freebsd.org/~pho/stress/log/kostik724.txt # Fixed by r272535. # On i386 pgrep(1) loops. Fixed by r272566. # "Sleeping on "pmapdi" with the following non-sleepable locks held:" # https://people.freebsd.org/~pho/stress/log/kostik883.txt . ../default.cfg odir=`pwd` cd /tmp sed '1,/^EOF/d' < $odir/$0 > core3.c mycc -o core3 -Wall -Wextra -O2 core3.c || exit 1 rm -f core3.c cd $odir mount | grep -q "on $mntpoint " && umount $mntpoint [ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart bsdlabel -w md$mdstart auto newfs $newfs_flags md${mdstart}$part > /dev/null mount /dev/md${mdstart}$part $mntpoint mkdir $mntpoint/d chmod 777 $mntpoint/d su $testuser -c "/tmp/core3 $mntpoint/d" & pid=$! sleep 1 while pgrep -q core3; do [ -d $mntpoint/d ] && umount -f $mntpoint done > /dev/null 2>&1 & while pgrep -q core3; do [ -d $mntpoint/d ] || mount /dev/md${mdstart}$part $mntpoint done > /dev/null 2>&1 wait $pid status=$? mount | grep -q "on $mntpoint " && umount -f $mntpoint mdconfig -d -u $mdstart [ $status -ne 0 ] && exit $status # tmpfs mount -o size=1g -t tmpfs tmpfs $mntpoint su $testuser -c "/tmp/core3 $mntpoint/d" & pid=$! sleep 1 while pgrep -q core3; do [ -d $mntpoint/d ] && umount -f $mntpoint done & while pgrep -q core3; do if [ ! -d $mntpoint/d ]; then mount -t tmpfs tmpfs $mntpoint mkdir $mntpoint/d fi done wait $pid status=$? mount | grep -q "on $mntpoint " && umount -f $mntpoint -rm -f core3 +rm -f /tmp/core3 exit $status EOF #include #include #include #include #include #include #include #include #include #define PARALLEL 64 #define SIZ (4 * 1024 * 1024) #define TIMEDOUT 22 void *p; static void hand(int i __unused) { /* handler */ _exit(TIMEDOUT); } void test(char *argv[]) { size_t len; len = SIZ; p = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_ANON, -1, 0); /* * This loop caused mount to wait in "ufs". * Adding a usleep(200) would remove the hang. */ signal(SIGALRM, hand); alarm(600); while (chdir(argv[1]) == -1) ; raise(SIGSEGV); _exit(0); } int main(int argc, char *argv[]) { time_t start; int i, s, status; if (argc != 2) errx(1, "Usage: %s ", argv[0]); status = 0; start = time(NULL); while (time(NULL) - start < 600 && status == 0) { for (i = 0; i < PARALLEL; i++) { if (fork() == 0) test(argv); } for (i = 0; i < PARALLEL; i++) { wait(&s); if (WEXITSTATUS(s) == TIMEDOUT) status = 1; } } return (status); } Index: user/pho/stress2/misc/credleak.sh =================================================================== --- user/pho/stress2/misc/credleak.sh (revision 306944) +++ user/pho/stress2/misc/credleak.sh (revision 306945) @@ -1,162 +1,164 @@ #!/bin/sh # # Copyright (c) 2016 Dell EMC # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ # # Demonstrate that vfs_export() leaks M_CRED when mountd(8) is started: # "M_CRED leaked 160". [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg pgrep -q mountd || echo "Note: mountd(8) must run for this test to fail" here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > credleak.c mycc -o credleak -Wall -Wextra -O2 -g credleak.c || exit 1 rm -f credleak.c mount | grep -q "on $mntpoint " && umount -f $mntpoint mount -t tmpfs tmpfs $mntpoint chmod 777 $mntpoint old=`vmstat -m | grep -w cred | awk '{print $2}'` su $testuser -c "/tmp/credleak $mntpoint" & while kill -0 $! 2>/dev/null; do umount -f $mntpoint && mount -t tmpfs tmpfs $mntpoint chmod 777 $mntpoint sleep .1 done pkill -9 swap wait while pkill -9 swap; do : done > /dev/null 2>&1 while mount | grep $mntpoint | grep -q tmpfs; do umount $mntpoint || sleep 1 done -[ -n "`ls $mntpoint`" ] && find $mntpoint/* -delete +[ -d "$mntpoint" ] && (cd $mntpoint && find . -delete) rm -f /tmp/credleak s=0 leak=$((`vmstat -m | grep -w cred | awk '{print $2}'` - old)) [ $leak -gt 10 ] && { echo "M_CRED leaked $leak"; s=1; } exit $s EOF #include #include #include #include #include #include #include #include #include #include #define LOOPS 160 #define PARALLEL 16 int nbc, nbd; char *dir; void tmkdir(void) { int i, j; char d[MAXPATHLEN + 1], name[MAXPATHLEN + 1]; setproctitle(__func__); i = 0; snprintf(name, sizeof(name), "%s/d1.%05d", dir, getpid()); if (mkdir(name, 0755) == -1) { if (errno != ENAMETOOLONG && errno != ENOENT && errno != EBUSY && errno != EACCES && errno != EPERM) warn("mkdir(%s)", name); _exit(0); } for (;;) { snprintf(d, sizeof(d), "/%d", i++); strncat(name, d, sizeof(name) - 1); if (mkdir(name, 0755) == -1) { if (errno != ENAMETOOLONG && errno != ENOENT && errno != EBUSY && errno != EACCES && errno != EPERM) warn("mkdir(%s)", name); i--; break; } nbc++; } while (i >= 0) { snprintf(name, sizeof(name), "%s/d1.%05d", dir, getpid()); for (j = 0; j < i; j++) { snprintf(d, sizeof(d), "/%d", j); strncat(name, d, sizeof(name) - 1); } if (rmdir(name) == -1) { if (errno != ENOTEMPTY && errno != ENOENT && errno != EBUSY) warn("rmdir(%s)", name); } else nbd++; i--; } #if defined(TEST) if (nbc == 0) fprintf(stderr, "FAIL nbc = %d, nbd = %d\n", nbc, nbd); #endif _exit(0); } int main(int argc, char **argv) { int i, j; - if (argc != 2) - errx(1, "Usage: %s ", argv[0]); + if (argc != 2) { + fprintf(stderr, "Usage: %s ", argv[0]); + exit(1); + } dir = argv[1]; for (j = 0; j < LOOPS; j++) { for (i = 0; i < PARALLEL; i++) { if (fork() == 0) tmkdir(); } for (i = 0; i < PARALLEL; i++) wait(NULL); } return(0); } Index: user/pho/stress2/misc/crossmp6.sh =================================================================== --- user/pho/stress2/misc/crossmp6.sh (revision 306944) +++ user/pho/stress2/misc/crossmp6.sh (revision 306945) @@ -1,97 +1,99 @@ #!/bin/sh # # Copyright (c) 2015 EMC Corp. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ # # Copy of crossmp2.sh: NFS test, with lockf(1) added. # "panic: vinvalbuf: dirty bufs" seen. # https://people.freebsd.org/~pho/stress/log/crossmp6.txt # Fixed by r283968. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg pgrep -q lockd || { echo "lockd not running."; exit 1; } mounts=10 # Number of parallel scripts if [ $# -eq 0 ]; then [ -z "$nfs_export" ] && exit 0 ping -c 2 `echo $nfs_export | sed 's/:.*//'` > /dev/null 2>&1 || exit 0 mount -t nfs -o tcp -o nfsv3 -o retrycnt=1 -o soft,timeout=1 \ -o rw $nfs_export $mntpoint || exit 0 umount $mntpoint for i in `jot $mounts`; do mp=${mntpoint}$i [ ! -d $mp ] && mkdir $mp mount | grep -qw "$mp" && umount $mp done # start the parallel tests for i in `jot $mounts`; do ./$0 $i & ./$0 find $i & done wait mount -t nfs -o tcp -o nfsv3 -o retrycnt=1 -o soft,timeout=1 \ -o rw $nfs_export $mntpoint || exit 0 - rm -f /mnt/$0.* + sleep .5 + rm -f $mntpoint/$0.* umount $mntpoint + rm -f $mntpoint*/$0.* exit 0 else if [ $1 = find ]; then for i in `jot 128`; do find ${mntpoint}* -maxdepth 1 -type f > \ /dev/null 2>&1 (lockf -t 10 ${mntpoint}$2/$0.$$.$i sleep 1 &) > \ /dev/null 2>&1 done wait 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 soft -o rw $nfs_export ${mntpoint}$m sleep .5 opt=`[ $(( m % 2 )) -eq 0 ] && echo -f` n=0 while mount | grep -qw ${mntpoint}$m; do umount $opt ${mntpoint}$m > /dev/null 2>&1 n=$((n + 1)) [ $n -gt 99 ] && umount -f ${mntpoint}$m > \ /dev/null 2>&1 [ $n -gt 100 ] && exit done done fi fi Index: user/pho/stress2/misc/link.sh =================================================================== --- user/pho/stress2/misc/link.sh (revision 306944) +++ user/pho/stress2/misc/link.sh (revision 306945) @@ -1,194 +1,195 @@ #!/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$ # # Deadlock seen for file systems which suspend writes on unmount, such as # UFS and tmpfs. # http://people.freebsd.org/~pho/stress/log/link.txt # Fixed by r272130 [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > link.c mycc -o link -Wall -Wextra -O2 -g link.c || exit 1 rm -f link.c mount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint [ -c /dev/md$mdstart ] && 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 daemon sh -c "(cd $here/../testcases/swap; ./swap -t 5m -i 20 -h -l 100)" \ > /dev/null 2>&1 /tmp/link $mntpoint > /dev/null 2>&1 & for i in `jot 100`; do umount -f $mntpoint && mount /dev/md${mdstart}$part $mntpoint sleep .1 done pkill -9 link wait while mount | grep $mntpoint | grep -q /dev/md; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart # tmpfs mount -t tmpfs tmpfs $mntpoint /tmp/link $mntpoint > /dev/null 2>&1 & for i in `jot 100`; do umount -f $mntpoint && mount -t tmpfs tmpfs $mntpoint sleep .1 done pkill -9 link swap wait while pkill -9 swap; do : done > /dev/null 2>&1 while mount | grep $mntpoint | grep -q tmpfs; do umount $mntpoint || sleep 1 done +[ -d "$mntpoint" ] && (cd $mntpoint && find . -delete) rm -f /tmp/link exit 0 EOF #include #include #include #include #include #include #include #include #include #define PARALLEL 16 #define RUNTIME 300 time_t start; char *dir; void trename(void) { int fd; char name1[MAXPATHLEN + 1]; char name2[MAXPATHLEN + 1]; setproctitle(__func__); snprintf(name1, sizeof(name1), "%s/r1.%05d", dir, getpid()); snprintf(name2, sizeof(name2), "%s/r2.%05d", dir, getpid()); if ((fd = open(name1, O_RDWR | O_CREAT, 0644)) == -1) err(1, "open(%s)", name1); close(fd); while (time(NULL) - start < RUNTIME) { if (rename(name1, name2) == -1) { if (errno == ENOENT) { if ((fd = open(name1, O_RDWR | O_CREAT, 0644)) == -1) err(1, "open(%s)", name1); close(fd); continue; } else warn("link(%s, %s)", name1, name2); } if (rename(name2, name1) == -1) warn("link(%s, %s)", name2, name1); } unlink(name1); unlink(name2); _exit(0); } void tlink(void) { int fd; char name1[MAXPATHLEN + 1]; char name2[MAXPATHLEN + 1]; setproctitle(__func__); snprintf(name1, sizeof(name1), "%s/f1.%05d", dir, getpid()); snprintf(name2, sizeof(name2), "%s/f2.%05d", dir, getpid()); if ((fd = open(name1, O_RDWR | O_CREAT, 0644)) == -1) err(1, "open(%s)", name1); close(fd); while (time(NULL) - start < RUNTIME) { unlink(name2); if (link(name1, name2) == -1) { if (errno == ENOENT) { if ((fd = open(name1, O_RDWR | O_CREAT, 0644)) == -1) err(1, "open(%s)", name1); close(fd); continue; } else warn("link(%s, %s)", name1, name2); } } unlink(name1); unlink(name2); _exit(0); } int main(int argc, char **argv) { int i, type; if (argc != 2) errx(1, "Usage: %s ", argv[0]); dir = argv[1]; type = arc4random() % 2; /* test either link() or rename() */ start = time(NULL); for (i = 0; i < PARALLEL; i++) { if (type == 0 && fork() == 0) tlink(); if (type == 1 && fork() == 0) trename(); } for (i = 0; i < PARALLEL; i++) wait(NULL); return(0); } Index: user/pho/stress2/misc/mmap2.sh =================================================================== --- user/pho/stress2/misc/mmap2.sh (revision 306944) +++ user/pho/stress2/misc/mmap2.sh (revision 306945) @@ -1,179 +1,179 @@ #!/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$ # # Stress mmap by having at most 100 threads mapping random areas within # a 100 Mb range. # Test scenario by kib@ . ../default.cfg odir=`pwd` cd /tmp sed '1,/^EOF/d' < $odir/$0 > mmap2.c mycc -o mmap2 -Wall -g mmap2.c -lpthread rm -f mmap2.c start=`date '+%s'` while [ $((`date '+%s'` - start)) -lt 600 ]; do ./mmap2 done -rm -f ./mmap2 +rm -f ./mmap2* exit EOF #include #include #include #include #include #include #include #include #include #include #include #include #define THREADS 100 #define STARTADDR 0x50000000U #define ADRSPACE 0x06400000U /* 100 Mb */ static void work(int nr) { int fd, m; void *p; size_t left, len; char path[128]; p = (void *)STARTADDR + trunc_page(arc4random() % ADRSPACE); left = ADRSPACE - (size_t)p + STARTADDR; len = trunc_page(arc4random() % left) + PAGE_SIZE; fd = -1; if (arc4random() % 100 < 90) sprintf(path, "/tmp/mmap.%06d.%04d", getpid(), nr); else sprintf(path, "/dev/zero"); if (arc4random() % 2 == 0) { if ((fd = open(path, O_CREAT | O_TRUNC | O_RDWR, 0622)) == -1) err(1,"open()"); if (ftruncate(fd, len) == -1) err(1, "ftruncate"); if (arc4random() % 2 == 0) { if ((p = mmap(p, len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)) == MAP_FAILED) { if (errno == ENOMEM) return; err(1, "mmap()"); } } else { if ((p = mmap(p, len, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0)) == MAP_FAILED) { if (errno == ENOMEM) return; err(1, "mmap()"); } } if (fd > 0 && strcmp(path, "/dev/zero")) if (unlink(path) == -1) err(1, "unlink(%s)", path); } else { if ((p = mmap(p, len, PROT_READ | PROT_WRITE, MAP_ANON, -1, 0)) == MAP_FAILED) { if (errno == ENOMEM) return; err(1, "mmap()"); } strcpy(path, "anon"); } #if 0 printf("nr = %d, %-14s, start = %p, end = %p, len = 0x%08x, (%5d pages)\n", nr, path, p, p + len, len, len>>PAGE_SHIFT); #endif *(int *)p = 1; if (arc4random() % 2 == 0) { m = arc4random() % 10; if (madvise(p, len, m) == -1) warn("madvise(%p, %zd, %d)", p, len, m); } if (arc4random() %2 == 0) if (mprotect(p, trunc_page(arc4random() % len), PROT_READ) == -1 ) err(1, "mprotect failed with error:"); if (arc4random() % 2 == 0) { if (arc4random() %2 == 0) { if (msync(p, 0, MS_SYNC) == -1) err(1, "msync(%p)", p); } else { if (msync(p, 0, MS_INVALIDATE) == -1) err(1, "msync(%p)", p); } } if (munmap(p, len) == -1) err(1, "munmap(%p)", p); close(fd); } void * thr(void *arg) { int i; for (i = 0; i < 512; i++) { work(*(int *)arg); } return (0); } int main(int argc, char **argv) { pthread_t threads[THREADS]; int nr[THREADS]; int i, n, r; // printf("Address start 0x%x, address end 0x%x, pages %d\n", // STARTADDR, STARTADDR + ADRSPACE, ADRSPACE>>PAGE_SHIFT); n = arc4random() % THREADS + 1; for (i = 0; i < n; i++) { nr[i] = i; if ((r = pthread_create(&threads[i], NULL, thr, (void *)&nr[i])) != 0) errc(1, r, "pthread_create()"); } for (i = 0; i < n; i++) { if ((r = pthread_join(threads[i], NULL)) != 0) errc(1, r, "pthread_join(%d)", i); } return (0); } Index: user/pho/stress2/misc/mmap27.sh =================================================================== --- user/pho/stress2/misc/mmap27.sh (revision 306944) +++ user/pho/stress2/misc/mmap27.sh (revision 306945) @@ -1,128 +1,128 @@ #!/bin/sh # # Copyright (c) 2016 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$ # # 'WARNING: A device driver has set "memattr" inconsistently.' seen on # console. # https://people.freebsd.org/~pho/stress/log/mmap27.txt # Fixed by r298891. . ../default.cfg odir=`pwd` cd /tmp sed '1,/^EOF/d' < $odir/$0 > mmap27.c mycc -o mmap27 -Wall -Wextra -g -O0 mmap27.c || exit 1 rm -f mmap27.c cd $odir daemon sh -c '(cd ../testcases/swap; ./swap -t 2m -i 20 -l 100)' > /dev/null 2>&1 sleep 2 /tmp/mmap27 while pgrep -q swap; do pkill -9 swap done -rm -f ./mmap27 /tmp/mmap27.0* +rm -f ./mmap27 /tmp/mmap27.0* /tmp/mmap27 exit 0 EOF #include #include #include #include #include #include #include #include #include #include #include int fd; #define ADRSPACE (256 * 1024 * 1024 ) #define PARALLEL 64 #define RUNTIME 120 #define STARTADDR 0x50000000U static void work(void) { size_t left, len; int i; char *p; volatile char val; if ((fd = open("/dev/mem", O_RDWR)) == -1) err(1,"open()"); p = (void *)STARTADDR + trunc_page(arc4random() % ADRSPACE); left = ADRSPACE - (size_t)p + STARTADDR; len = trunc_page(arc4random() % left) + PAGE_SIZE; if ((p = mmap(p, len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)) == MAP_FAILED) { if (errno == ENOMEM) return; err(1, "mmap()"); } for (i = 0; i < 100; i++) val = p[arc4random() % len]; if (munmap(p, len) == -1) err(1, "munmap(%p)", p); _exit(0); } int main(void) { pid_t pids[PARALLEL]; time_t start; int i, n; start = time(NULL); while (time(NULL) - start < RUNTIME) { n = arc4random() % PARALLEL + 1; for (i = 0; i < n; i++) { if ((pids[i] = fork()) == 0) work(); } for (i = 0; i < n; i++) if (waitpid(pids[i], NULL, 0) != pids[i]) err(1, "waitpid(%d)", pids[i]); } close(fd); return (0); } Index: user/pho/stress2/misc/mmap28.sh =================================================================== --- user/pho/stress2/misc/mmap28.sh (revision 306944) +++ user/pho/stress2/misc/mmap28.sh (revision 306945) @@ -1,131 +1,131 @@ #!/bin/sh # # Copyright (c) 2016 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$ # # 'panic: vnode_pager_generic_getpages: page 0xc3350b0c offset beyond vp # 0xcc187000 size' seen. # https://people.freebsd.org/~pho/stress/log/mmap28.txt # This was introduced by r292373. # # A page fault is seen on a non INVARIANTS kernel w/ r292373, # whereas this test runs as expected on r292372. # https://people.freebsd.org/~pho/stress/log/mmap28-2.txt # https://people.freebsd.org/~pho/stress/log/mmap28-3.txt # Test scenario refinement by kib@ . ../default.cfg odir=`pwd` cd /tmp sed '1,/^EOF/d' < $odir/$0 > mmap28.c mycc -o mmap28 -Wall -Wextra -g -O0 mmap28.c || exit 1 rm -f mmap28.c cd $odir (cd /tmp; ./mmap28) -rm -f /tmp/mmap28 /tmp/mmap28.0* +rm -f /tmp/mmap28 /tmp/mmap28.0* /tmp/mmap28.core exit 0 EOF #include #include #include #include #include #include #include #include #include #include #define ADRSPACE (256 * 1024 * 1024 ) #define STARTADDR 0x50000000U static void work(void) { size_t indx, left, len; int fd, rfd; int i; char *p; char path[128]; volatile char val; if ((rfd = open("/dev/random", O_RDONLY)) == -1) err(1, "open(/dev/random)"); snprintf(path, sizeof(path), "/tmp/mmap28.%06d", 0); if ((fd = open(path, O_RDWR | O_CREAT | O_TRUNC, 0640)) == -1) err(1,"open(%s)", path); p = (void *)STARTADDR + trunc_page(arc4random() % ADRSPACE); left = ADRSPACE - (size_t)p + STARTADDR; len = trunc_page(arc4random() % left) + PAGE_SIZE; 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) return; err(1, "mmap()"); } /* Truncating the mapped file triggers a panic when accessed beyond EOF. */ if (ftruncate(fd, len / 2) == -1) err(1, "ftruncate(%s)", path); for (i = 0; i < 1000; i++) { if (read(rfd, &indx, sizeof(indx)) != sizeof(indx)) err(1, "read(random)"); val = p[indx % len]; } close(rfd); if (munmap(p, len) == -1) err(1, "munmap(%p)", p); close(fd); unlink(path); } int main(void) { work(); return (0); } Index: user/pho/stress2/misc/pfl.sh =================================================================== --- user/pho/stress2/misc/pfl.sh (revision 306944) +++ user/pho/stress2/misc/pfl.sh (revision 306945) @@ -1,184 +1,185 @@ #!/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. . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > pfl.c mycc -o pfl -Wall -Wextra pfl.c || exit 1 rm -f pfl.c cd $here mp1=$mntpoint mp2=${mntpoint}2 [ -d $mp2 ] || mkdir -p $mp2 md1=$mdstart md2=$((mdstart + 1)) usermem=`sysctl -n hw.usermem` [ `swapinfo | wc -l` -eq 1 ] && usermem=$((usermem/100*80)) 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 su ${testuser} -c "cd $mp1; /tmp/pfl" & su ${testuser} -c "cd $mp2; /tmp/pfl" & sleep .5 start=`date '+%s'` while pgrep -q pfl; do if [ $((`date '+%s'`- start)) -gt 600 ]; then echo "$0 timed out." pkill -9 pfl fi sleep 10 done 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 +rm -f /tmp/pfl mdconfig -d -u $md1 exit EOF #include #include #include #include #include #include #include #include #include #include #include #define PARALLEL 10 static int size = 10000; void test(void) { pid_t pid; int fd, i, j; char file[128]; pid = getpid(); sprintf(file,"d%05d", pid); if (mkdir(file, 0740) == -1) err(1, "mkdir(%s)", file); chdir(file); for (j = 0; j < size; j++) { sprintf(file,"p%05d.%05d", pid, j); if ((fd = open(file, O_CREAT | O_TRUNC | O_WRONLY, 0644)) == -1) { if (errno != EINTR) { warn("mkdir(%s). %s:%d", file, __FILE__, __LINE__); unlink("continue"); break; } } if (arc4random() % 100 < 10) if (write(fd, "1", 1) != 1) err(1, "write()"); close(fd); } sleep(3); for (i = --j; i >= 0; i--) { sprintf(file,"p%05d.%05d", pid, i); if (unlink(file) == -1) err(3, "unlink(%s)", file); } chdir(".."); sprintf(file,"d%05d", pid); if (rmdir(file) == -1) err(3, "unlink(%s)", file); } int main(void) { int fd, i, j, k; umask(0); if ((fd = open("continue", O_CREAT, 0644)) == -1) err(1, "open()"); close(fd); for (i = 0; i < 1; i++) { for (j = 0; j < PARALLEL; j++) { if (fork() == 0) { for (k = 0; k < 50; k++) test(); exit(0); } } for (j = 0; j < PARALLEL; j++) wait(NULL); if (access("continue", R_OK) == -1) { fprintf(stderr, "Loop #%d\n", i + 1); fflush(stderr); break; } } unlink("continue"); return (0); } Index: user/pho/stress2/misc/pthread9.sh =================================================================== --- user/pho/stress2/misc/pthread9.sh (revision 306944) +++ user/pho/stress2/misc/pthread9.sh (revision 306945) @@ -1,185 +1,186 @@ #!/bin/sh # # Copyright (c) 2015 EMC Corp. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ # # Thread suspend deadlock seen: # https://people.freebsd.org/~pho/stress/log/pthread9.txt # Test scenario by Conrad Meyer. # Fixed by r283320. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > pthread9.c mycc -o pthread9 -Wall -Wextra -O2 pthread9.c -lpthread || exit 1 rm -f pthread9.c status=0 if ping -c 2 `echo $nfs_export | sed 's/:.*//'` > /dev/null 2>&1; then mount -t nfs -o nfsv3,tcp,nolockd,retrycnt=3,intr $nfs_export \ $mntpoint || exit 1 sleep .5 + echo "Expect core dumps" (cd $mntpoint; /tmp/pthread9) & sleep 200 if pgrep -q pthread9; then echo FAIL procstat -k `pgrep pthread9 | grep -v $!` status=1 fi umount -f $mntpoint wait fi -rm -f /tmp/pthread9 +rm -f /tmp/pthread9 /tmp/pthread9.core exit $status EOF #include #include #include #include #include #include #ifdef __FreeBSD__ #include #define __NP__ #endif #include #include #include #include #include #define LOOPS 50 #define RUNTIME 180 volatile u_int go; int fd; char file[] = "pthread9.file"; static void * t1(void *data __unused) { int i; #ifdef __NP__ pthread_set_name_np(pthread_self(), __func__); #endif while (go == 0) pthread_yield(); atomic_add_int(&go, 1); for (i = 0; i < 100; i++) if (ftruncate(fd, 0) == -1) err(1, "truncate"); return (NULL); } static void * t2(void *data __unused) { int i; #ifdef __NP__ pthread_set_name_np(pthread_self(), __func__); #endif while (go == 0) pthread_yield(); atomic_add_int(&go, 1); for (i = 0; i < 100; i++) if (ftruncate(fd, 0) == -1) err(1, "truncate"); return (NULL); } static void * t3(void *data __unused) { #ifdef __NP__ pthread_set_name_np(pthread_self(), __func__); #endif while (go != 3) pthread_yield(); abort(); return (NULL); } int test(void) { pthread_t tid[3]; int i, rc; go = 0; if ((rc = pthread_create(&tid[0], NULL, t1, NULL)) != 0) errc(1, rc, "pthread_create"); if ((rc = pthread_create(&tid[1], NULL, t2, NULL)) != 0) errc(1, rc, "pthread_create"); if ((rc = pthread_create(&tid[2], NULL, t3, NULL)) != 0) errc(1, rc, "pthread_create"); usleep(200); atomic_add_int(&go, 1); for (i = 0; i < 3; i++) { if ((rc = pthread_join(tid[i], NULL)) != 0) errc(1, rc, "pthread_join"); } _exit(0); } int main(void) { time_t start; if ((fd = open(file, O_RDWR | O_CREAT, 0644)) == -1) err(1, "open(%s)", file); start = time(NULL); while (time(NULL) - start < RUNTIME) { if (fork() == 0) test(); wait(NULL); } close(fd); unlink(file); return (0); } Index: user/pho/stress2/misc/rename10.sh =================================================================== --- user/pho/stress2/misc/rename10.sh (revision 306944) +++ user/pho/stress2/misc/rename10.sh (revision 306945) @@ -1,181 +1,182 @@ #!/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 # Regression test for rename(2) problem with missing reference release of # a busy "to" vnode, resulting in a leak. # Fixed in r253998. . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > rename10.c mycc -o rename10 -Wall -Wextra -g -O2 rename10.c || exit 1 rm -f rename10.c cd $here mount | grep "on $mntpoint " | grep -q /dev/md && umount -f $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 4g -u $mdstart || exit 1 bsdlabel -w md$mdstart auto newfs $newfs_flags md${mdstart}$part > /dev/null mount /dev/md${mdstart}$part $mntpoint avail=`df -k $mntpoint | tail -1 | awk '{print $4}'` (cd $mntpoint; /tmp/rename10) for i in `jot 3`; do sync sleep 2 done if [ `df -k $mntpoint | tail -1 | awk '{print $4}'` -lt $avail ]; then echo FAIL ls -ial $mntpoint df -i $mntpoint fi n=0 while mount | grep "on $mntpoint " | grep -q /dev/md; do umount $mntpoint || sleep 1 n=$((n + 1)) [ $n -gt 5 ] && { umount -f $mntpoint; break; } done checkfs /dev/md${mdstart}$part +rm -f /tmp/rename10 mdconfig -d -u $mdstart exit 0 EOF #include #include #include #include #include #include #include #include #include #include #define PARALLEL 4 #define SIZE (1 * 1024 * 1024) static char *logfile = "logfile"; static char *oldfiles[] = { "logfile.0", "logfile.1", "logfile.2", "logfile.3", "logfile.4" }; void * logger(void) { int fd; char * cp; setproctitle("logger"); cp = calloc(1, SIZE); for(;;) { if ((fd = open(logfile, O_RDWR | O_APPEND)) != -1) { if (write(fd, cp, SIZE) != SIZE) err(1, "write()"); close(fd); } usleep(1); } _exit(0); } void * spin(void) { int fd, i; setproctitle("spin"); for(;;) { for (i = 0; i < 5; i++) { if ((fd = open(oldfiles[i], O_RDWR | O_APPEND)) != -1) close(fd); } usleep(1); } _exit(0); } void renamer() { int fd, i; time_t start; setproctitle("renamer"); start = time(NULL); i = 0; while (time(NULL) - start < 60) { if ((fd = open(logfile, O_RDWR | O_CREAT | O_EXCL, 0644)) == -1) err(1, "creat(%s)", logfile); close(fd); if (rename(logfile, oldfiles[i]) == -1) err(1, "rename(%s, %s)", logfile, oldfiles[i]); i = (i + 1) % 5; } for (i = 0; i < 5; i++) { unlink(oldfiles[i]); } unlink(logfile); } int main() { pid_t pids[PARALLEL], spids[PARALLEL]; int i; for (i = 0; i < PARALLEL; i++) { if ((pids[i] = fork()) == 0) logger(); if ((spids[i] = fork()) == 0) spin(); } renamer(); for (i = 0; i < PARALLEL; i++) { kill(pids[i], SIGINT); kill(spids[i], SIGINT); } for (i = 0; i < PARALLEL * 2; i++) wait(NULL); wait(NULL); return (0); } Index: user/pho/stress2/misc/rename7.sh =================================================================== --- user/pho/stress2/misc/rename7.sh (revision 306944) +++ user/pho/stress2/misc/rename7.sh (revision 306945) @@ -1,152 +1,152 @@ #!/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$ # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 # After a few runs this will happen: # $ umount /mnt # umount: unmount of /mnt failed: Device busy # $ umount -f /mnt # $ . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > rename7.c mycc -o rename7 -Wall -Wextra -O2 rename7.c || exit rm -f rename7.c cd $here mount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 2g -u $mdstart bsdlabel -w md$mdstart auto newfs $newfs_flags md${mdstart}$part > /dev/null mount /dev/md${mdstart}$part $mntpoint chmod 777 $mntpoint su ${testuser} -c "cd $mntpoint; /tmp/rename7 || echo FAIL" for i in `jot 10`; do mount | grep -q md${mdstart}$part && \ umount $mntpoint && mdconfig -d -u $mdstart && break done if mount | grep -q md${mdstart}$part; then echo "Test failed" exit 1 fi -rm -d /tmp/rename7 +rm -f /tmp/rename7 exit 0 EOF #include #include #include #include #include #include #include #include #include #include #include #include #include #include const char *logfile = "test.log"; pid_t wpid, spid; void r1(void) { int i; struct stat sb1, sb2; for (i = 0; i < 800000; i++) { rename(logfile, "r1"); if (stat("r1", &sb1) == 0 && stat("r2", &sb2) == 0 && bcmp(&sb1, &sb2, sizeof(sb1)) == 0) { fprintf(stderr, "r1 and r2 are identical after rename(%s, \"r1\")\n", logfile); system("ls -ail"); _exit(1); } } _exit(0); } void r2(void) { int i; struct stat sb1, sb2; // _exit(0); /* No problems with only r1 running */ for (i = 0; i < 800000; i++) { rename(logfile, "r2"); if (stat("r1", &sb1) == 0 && stat("r2", &sb2) == 0 && bcmp(&sb1, &sb2, sizeof(sb1)) == 0) { usleep(10000); fprintf(stderr, "r1 and r2 are identical after rename(%s, \"r2\")\n", logfile); system("ls -ail"); _exit(1); } } _exit(0); } int main(void) { pid_t wpid, spid; int e, fd, i, status; if ((wpid = fork()) == 0) r1(); if ((spid = fork()) == 0) r2(); setproctitle("main"); e = 0; for (i = 0; i < 800000; i++) { if ((fd = open(logfile, O_RDWR | O_CREAT | O_TRUNC, 0644)) == -1) warn("creat(%s)", logfile); close(fd); } kill(wpid, SIGINT); kill(spid, SIGINT); wait(&status); e += WEXITSTATUS(status); wait(&status); e += WEXITSTATUS(status); return (e); } Index: user/pho/stress2/misc/suj10.sh =================================================================== --- user/pho/stress2/misc/suj10.sh (revision 306944) +++ user/pho/stress2/misc/suj10.sh (revision 306945) @@ -1,184 +1,184 @@ #!/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: projects/stress2/misc/suj.sh 210724 2010-08-01 10:33:03Z pho $ # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 # Page fault in softdep_revert_mkdir+0x4d seen and # fsck updates "clean" FS: # *** /tmp/dumpfs.1 2010-12-24 19:18:44.000000000 +0100 # --- /tmp/dumpfs.2 2010-12-24 19:18:46.000000000 +0100 # *************** # *** 5,11 **** # frag 8 shift 3 fsbtodb 2 # minfree 8% optim time symlinklen 120 # maxbsize 16384 maxbpg 2048 maxcontig 8 contigsumsize 8 # ! nbfree 62794 ndir 2 nifree 141307 nffree 25 # bpg 11761 fpg 94088 ipg 23552 unrefs 0 # nindir 2048 inopb 64 maxfilesize 140806241583103 # sbsize 2048 cgsize 16384 csaddr 3000 cssize 2048 # --- 5,11 ---- # frag 8 shift 3 fsbtodb 2 # minfree 8% optim time symlinklen 120 # maxbsize 16384 maxbpg 2048 maxcontig 8 contigsumsize 8 # ! nbfree 62794 ndir 30 nifree 141307 nffree 25 # bpg 11761 fpg 94088 ipg 23552 unrefs 0 # nindir 2048 inopb 64 maxfilesize 140806241583103 # sbsize 2048 cgsize 16384 csaddr 3000 cssize 2048 . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > suj10.c mycc -o suj10 -Wall -O2 suj10.c rm -f suj10.c cd $here mount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart bsdlabel -w md$mdstart auto newfs -j md${mdstart}$part > /dev/null mount /dev/md${mdstart}$part $mntpoint chmod 777 $mntpoint su ${testuser} -c "cd $mntpoint; /tmp/suj10" while mount | grep "$mntpoint " | grep -q /dev/md; do umount $mntpoint || sleep 1 done dumpfs /dev/md${mdstart}$part | grep -v UFS2 > /tmp/dumpfs.1 sleep 1 fsck -t ufs -y -v /dev/md${mdstart}$part > /tmp/fsck.log 2>&1 dumpfs /dev/md${mdstart}$part | grep -v UFS2 > /tmp/dumpfs.2 diff -c /tmp/dumpfs.1 /tmp/dumpfs.2 || cat /tmp/fsck.log mdconfig -d -u $mdstart -rm -f /tmp/fsck.log /tmp/dumpfs.? +rm -f /tmp/fsck.log /tmp/dumpfs.? /tmp/suj10 exit EOF #include #include #include #include #include #include #include #include #include #include #include #define PARALLEL 10 /* static int size = 14100; Causes: Fatal trap 12: page fault while in kernel mode Stopped at softdep_revert_mkdir+0x4d: movl 0x28(%ebx),%eax */ //static int size = 14000; static int size = 13000; void test(void) { int fd, i, j; pid_t pid; char file[128]; for (;;) { if (access("rendezvous", R_OK) == 0) break; sched_yield(); } pid = getpid(); sprintf(file,"d%05d", pid); if (mkdir(file, 0740) == -1) err(1, "mkdir(%s)", file); chdir(file); for (j = 0; j < size; j++) { sprintf(file,"p%05d.%05d", pid, j); if ((fd = mkdir(file, 0740)) == -1) { if (errno != EINTR) { warn("mkdir(%s). %s:%d", file, __FILE__, __LINE__); unlink("continue"); break; } } } sleep(3); for (i = --j; i >= 0; i--) { sprintf(file,"p%05d.%05d", pid, i); if (rmdir(file) == -1) err(3, "unlink(%s)", file); } chdir(".."); sprintf(file,"d%05d", pid); if (rmdir(file) == -1) err(3, "unlink(%s)", file); } int main(void) { int fd, i, j; umask(0); if ((fd = open("continue", O_CREAT, 0644)) == -1) err(1, "open()"); close(fd); for (i = 0; i < 1; i++) { for (j = 0; j < PARALLEL; j++) { if (fork() == 0) { test(); exit(0); } } if ((fd = open("rendezvous", O_CREAT, 0644)) == -1) err(1, "open()"); close(fd); for (j = 0; j < PARALLEL; j++) wait(NULL); unlink("rendezvous"); if (access("continue", R_OK) == -1) { fprintf(stderr, "Loop #%d\n", i + 1); fflush(stderr); break; } } unlink("continue"); return (0); } Index: user/pho/stress2/misc/symlink.sh =================================================================== --- user/pho/stress2/misc/symlink.sh (revision 306944) +++ user/pho/stress2/misc/symlink.sh (revision 306945) @@ -1,129 +1,130 @@ #!/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$ # # Testing problem with premature disk full problem with symlinks [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg D=$diskimage dede $D 1m 1024 || exit 1 odir=`pwd` dir=$mntpoint cd /tmp sed '1,/^EOF/d' < $odir/$0 > symlink.c mycc -o symlink -Wall symlink.c rm -f symlink.c cd $odir mount | grep "$mntpoint" | grep md${mdstart} > /dev/null && umount $mntpoint mdconfig -l | grep md${mdstart} > /dev/null && mdconfig -d -u ${mdstart} mdconfig -a -t vnode -f $D -u ${mdstart} tst() { cd $dir df -ik $mntpoint i=`df -ik $mntpoint | tail -1 | awk '{printf "%d\n", ($7 - 500)/2}'` [ $i -gt 20000 ] && i=20000 for k in `jot 5`; do for j in `jot 2`; do /tmp/symlink $i & done for j in `jot 2`; do wait done df -ik $mntpoint | tail -1 # sleep 30 # With this enabled, soft update also works done cd $odir } for i in "" "-U"; do echo "newfs $i /dev/md${mdstart}" newfs $i /dev/md${mdstart} > /dev/null 2>&1 mount /dev/md${mdstart} ${mntpoint} tst umount -f ${mntpoint} done +rm -f /tmp/symlink mdconfig -d -u $mdstart exit EOF #include #include #include #include #include #include #include #include #include #include #include int main(int argc, char **argv) { int i, j; int64_t size; pid_t pid; char file[128]; size = atol(argv[1]); // printf("Creating %jd symlinks...\n", size); fflush(stdout); pid = getpid(); for (j = 0; j < size; j++) { sprintf(file,"p%05d.%05d", pid, j); if (symlink("/mnt/not/there", file) == -1) { if (errno != EINTR) { warn("symlink(%s)", file); printf("break out at %d, errno %d\n", j, errno); break; } } } // printf("Deleting %jd files...\n", size); fflush(stdout); for (i = --j; i >= 0; i--) { sprintf(file,"p%05d.%05d", pid, i); if (unlink(file) == -1) err(3, "unlink(%s)", file); } return (0); } Index: user/pho/stress2/misc/symlink2.sh =================================================================== --- user/pho/stress2/misc/symlink2.sh (revision 306944) +++ user/pho/stress2/misc/symlink2.sh (revision 306945) @@ -1,121 +1,122 @@ #!/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$ # # Testing problem with buffer cache inconsistancy [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg D=$diskimage dede $D 1m 10 || exit 1 odir=`pwd` dir=$mntpoint cd /tmp sed '1,/^EOF/d' < $odir/$0 > symlink2.c mycc -o symlink2 -Wall symlink2.c rm -f symlink2.c cd $odir mount | grep "$mntpoint" | grep md${mdstart} > /dev/null && umount $mntpoint mdconfig -l | grep md${mdstart} > /dev/null && mdconfig -d -u ${mdstart} mdconfig -a -t vnode -f $D -u ${mdstart} for i in "" "-U"; do echo "newfs $i /dev/md${mdstart}" newfs $i /dev/md${mdstart} > /dev/null 2>&1 mount /dev/md${mdstart} $mntpoint mkdir ${mntpoint}/dir /tmp/symlink2 ${mntpoint}/dir/link ls -l ${mntpoint}/dir > /dev/null 2>&1 if [ $? -ne 0 ]; then set -x ls -l ${mntpoint}/dir umount $mntpoint mount /dev/md${mdstart} $mntpoint ls -l ${mntpoint}/dir set +x fi umount -f ${mntpoint} done +rm -f /tmp/symlink2 $D mdconfig -d -u $mdstart exit EOF #include #include #include #include #include #include #include static char *path; int main(int argc, char **argv) { int i, n; pid_t p; char buf[128]; path = argv[1]; for (i = 0; i < 100; i++) { if ((p = fork()) == 0) { if ((n = readlink(path, buf, sizeof(buf) -1)) < 0) { for (i = 0; i < 60; i++) { sleep(1); if ((n = readlink(path, buf, sizeof(buf) -1)) > 0) { break; } } } if (n < 0) err(1, "readlink(%s). %s:%d", path, __FILE__, __LINE__); exit(0); } } (void) unlink(path); sleep(2); if (symlink("1234", path) < 0) err(1, "symlink(%s, %s)", path, "1234"); for (i = 0; i < 100; i++) { if (wait(&n) == -1) err(1, "wait(), %s:%d", __FILE__, __LINE__); } return (0); } Index: user/pho/stress2/misc/tmpfs9.sh =================================================================== --- user/pho/stress2/misc/tmpfs9.sh (revision 306944) +++ user/pho/stress2/misc/tmpfs9.sh (revision 306945) @@ -1,113 +1,113 @@ #!/bin/sh # # Copyright (c) 2013 Peter Holm # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 # Regression test: exec returning EIO problem scenario for tmpfs . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > tmpfs9.c mycc -o tmpfs9 -Wall -Wextra -O2 tmpfs9.c rm -f tmpfs9.c cd $here mount | grep $mntpoint | grep -q tmpfs && umount -f $mntpoint mount -t tmpfs tmpfs $mntpoint chmod 777 $mntpoint cp /usr/bin/true $mntpoint su ${testuser} -c "/tmp/tmpfs9 $mntpoint" & while kill -0 $! 2>/dev/null; do ../testcases/swap/swap -t 2m -i 40 -h done wait while mount | grep $mntpoint | grep -q tmpfs; do umount $mntpoint || sleep 1 done -rm -d /tmp/tmpfs9 +rm -f /tmp/tmpfs9 exit EOF #include #include #include #include #include #include #include #include #define N 5000 #define PARALLEL 10 const char path[] = "./true"; void test(void) { pid_t p; int i; for (i = 0; i < N; i++) { if ((p = fork()) == 0) if (execl(path, path, (char *)0) == -1) err(1, "exec(%s)", path); if (p > 0) wait(NULL); } _exit(0); } int main(int argc, char **argv) { int i, status; if (argc != 2) errx(1, "Usage: %s ", argv[0]); if (chdir(argv[1]) == -1) err(1, "chdir(%s)", argv[1]); for (i = 0; i < PARALLEL; i++) { if (fork() == 0) test(); } for (i = 0; i < PARALLEL; i++) { wait(&status); if (status != 0) return (1); } return (0); } Index: user/pho/stress2/misc/truss.sh =================================================================== --- user/pho/stress2/misc/truss.sh (revision 306944) +++ user/pho/stress2/misc/truss.sh (revision 306945) @@ -1,130 +1,130 @@ #!/bin/sh # # Copyright (c) 2015 EMC Corp. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ # # truss(1) of a multithreaded program. # FAIL # 0 90968 90933 0 52 0 6028 0 wait IW+ 1 0:00,00 truss /tmp/ttruss # 0 90970 90968 0 52 0 6436 1560 uwrlck IX+ 1 0:00,00 /tmp/ttruss # $ procstat -k 90970 # PID TID COMM TDNAME KSTACK # 90970 101244 ttruss - mi_switch sleepq_switch # sleepq_catch_signals sleepq_wait_sig _sleep umtxq_sleep # do_rw_wrlock __umtx_op_rw_wrlock syscall Xint0x80_syscall # $ # Only seen during testing of a WiP ptrace(2) patch. . ../default.cfg dir=/tmp odir=`pwd` cd $dir sed '1,/^EOF/d' < $odir/$0 > $dir/ttruss.c mycc -o ttruss -Wall -Wextra -O0 -g ttruss.c -lpthread || exit 1 rm -f ttruss.c # VM pressure is not mandatory, but shortens the time to failure. daemon sh -c \ "(cd $odir/../testcases/swap; ./swap -t 6m -i 20 -k -l 100)" > \ /dev/null sleep .5 for i in `jot 30`; do truss /tmp/ttruss 10 > /dev/null 2>&1 & sleep 11 if ps -l | grep -v grep | grep -q uwrlck; then echo FAIL ps -lH | egrep -v "grep|truss.sh" | grep truss while pkill -9 swap; do : done exit 1 fi wait done while pkill -9 swap; do : done sleep 2 if pgrep -q ttruss; then echo FAIL ps -lH | grep -v grep | grep ttruss - exit 1 + s=1 fi -rm -rf /tmp/ttruss -exit +rm -rf /tmp/ttruss /tmp/ttruss.core +exit $s EOF #include #include #include #include #include #include #include #include #include #define THREADS 16 static void * t1(void *data __unused) { return (NULL); } int main(int argc, char *argv[]) { pthread_t tid[THREADS]; time_t start; int i, rc, runtime; if (argc != 2) errx(1, "Usage: %s ", argv[0]); runtime = atoi(argv[1]); start = time(NULL); while ((time(NULL) - start) < runtime) { for (i = 0; i < THREADS; i++) { if ((rc = pthread_create(&tid[i], NULL, t1, NULL)) != 0) errc(1, rc, "pthread_create"); } for (i = 0; i < THREADS; i++) { if ((rc = pthread_join(tid[i], NULL)) != 0) errc(1, rc, "pthread_join"); } } return (0); }