Index: user/pho/stress2/misc/alternativeFlushPath.sh =================================================================== --- user/pho/stress2/misc/alternativeFlushPath.sh (revision 317637) +++ user/pho/stress2/misc/alternativeFlushPath.sh (revision 317638) @@ -1,132 +1,133 @@ #!/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 +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 || exit 1 rm -f alternativeFlushPath.c for j in `jot 10`; do /tmp/alternativeFlushPath & done wait sysctl vfs.altbufferflushes +cd $odir rm -rf /tmp/alternativeFlushPath $dir exit EOF #include #include #include #include #include #include #include #include #include #define MAXNOFILE 500000 /* To limit runtime */ 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)"); if (rlp.rlim_cur > MAXNOFILE) rlp.rlim_cur = MAXNOFILE; 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/backingstore.sh =================================================================== --- user/pho/stress2/misc/backingstore.sh (revision 317637) +++ user/pho/stress2/misc/backingstore.sh (revision 317638) @@ -1,83 +1,83 @@ #!/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 sparse backing store [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg D=$diskimage export here=`pwd` m=$mdstart -mount | grep "${mntpoint}" | grep -q md$m && umount ${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 100m 1 || exit 1 mdconfig -a -t vnode -f $D$m -u $m bsdlabel -w md$m auto -newfs md${m}${part} > /dev/null 2>&1 +newfs md${m}$part > /dev/null 2>&1 [ -d ${mntpoint}$m ] || mkdir -p ${mntpoint}$m -mount $opt /dev/md${m}${part} ${mntpoint}$m +mount $opt /dev/md${m}$part ${mntpoint}$m n=$m m=$((m + 1)) -mount | grep "${mntpoint}" | grep -q md$m && umount ${mntpoint}$m +mount | grep "$mntpoint" | grep -q md$m && umount ${mntpoint}$m mdconfig -l | grep -q md$m && mdconfig -d -u $m truncate -s 500M ${mntpoint}$n/diskimage mdconfig -a -t vnode -f ${mntpoint}$n/diskimage -u $m bsdlabel -w md$m auto -newfs md${m}${part} > /dev/null 2>&1 +newfs md${m}$part > /dev/null 2>&1 [ -d ${mntpoint}$m ] || mkdir -p ${mntpoint}$m -mount $opt /dev/md${m}${part} ${mntpoint}$m +mount $opt /dev/md${m}$part ${mntpoint}$m export RUNDIR=${mntpoint}$m/stressX ../testcases/rw/rw -t 5m -i 200 -h -n while mount | grep -q ${mntpoint}$m; do flag=$([ $((`date '+%s'` % 2)) -eq 0 ] && echo "-f" || echo "") umount $flag ${mntpoint}$m > /dev/null 2>&1 done mdconfig -l | grep -q md$m && mdconfig -d -u $m m=$((m - 1)) while mount | grep -q ${mntpoint}$m; do umount $([ $((`date '+%s'` % 2)) -eq 0 ] && \ echo "-f" || echo "") ${mntpoint}$m > /dev/null 2>&1 done mdconfig -l | grep -q md$m && mdconfig -d -u $m rm -f $D Index: user/pho/stress2/misc/backingstore2.sh =================================================================== --- user/pho/stress2/misc/backingstore2.sh (revision 317637) +++ user/pho/stress2/misc/backingstore2.sh (revision 317638) @@ -1,75 +1,75 @@ #!/bin/sh # # Copyright (c) 2009 Peter Holm # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ # # Test unmount of a device that is already gone # Leaves /mnt6 unmountable and leads to a "panic: 1 vncache entries remaining" # during shut down. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg D=$diskimage export here=`pwd` m1=$mdstart m2=$((m1 + 1)) -mount | grep "${mntpoint}" | grep -q md$m2 && umount ${mntpoint}$m2 +mount | grep "$mntpoint" | grep -q md$m2 && umount ${mntpoint}$m2 mdconfig -l | grep -q md$m2 && mdconfig -d -u $m2 -mount | grep "${mntpoint}" | grep -q md$m1 && umount ${mntpoint}$m1 +mount | grep "$mntpoint" | grep -q md$m1 && umount ${mntpoint}$m1 mdconfig -l | grep -q md$m1 && mdconfig -d -u $m1 [ -d ${mntpoint}$m1 ] || mkdir -p ${mntpoint}$m1 [ -d ${mntpoint}$m2 ] || mkdir -p ${mntpoint}$m2 dede $D$m1 100m 1 || exit 1 mdconfig -a -t vnode -f $D$m1 -u $m1 bsdlabel -w md$m1 auto -newfs md${m1}${part} > /dev/null 2>&1 -mount /dev/md${m1}${part} ${mntpoint}$m1 +newfs md${m1}$part > /dev/null 2>&1 +mount /dev/md${m1}$part ${mntpoint}$m1 truncate -s 500M ${mntpoint}$m1/diskimage mdconfig -a -t vnode -f ${mntpoint}$m1/diskimage -u $m2 bsdlabel -w md$m2 auto -newfs md${m2}${part} > /dev/null 2>&1 -mount /dev/md${m2}${part} ${mntpoint}$m2 +newfs md${m2}$part > /dev/null 2>&1 +mount /dev/md${m2}$part ${mntpoint}$m2 # Reversed umount sequence: -umount -f /dev/md${m1}${part} -umount -f /dev/md${m2}${part} +umount -f /dev/md${m1}$part +umount -f /dev/md${m2}$part -mount | grep "${mntpoint}" | grep -q md$m2 && umount ${mntpoint}$m2 +mount | grep "$mntpoint" | grep -q md$m2 && umount ${mntpoint}$m2 mdconfig -l | grep -q md$m2 && mdconfig -d -u $m2 -mount | grep "${mntpoint}" | grep -q md$m1 && umount ${mntpoint}$m1 +mount | grep "$mntpoint" | grep -q md$m1 && umount ${mntpoint}$m1 mdconfig -l | grep -q md$m1 && mdconfig -d -u $m1 Index: user/pho/stress2/misc/backingstore3.sh =================================================================== --- user/pho/stress2/misc/backingstore3.sh (revision 317637) +++ user/pho/stress2/misc/backingstore3.sh (revision 317638) @@ -1,76 +1,76 @@ #!/bin/sh # # Copyright (c) 2009 Peter Holm # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ # # Test unmount of a device that is already gone # Caused "panic: bundirty: buffer 0xdafaf2c4 still on queue 1" [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg D=$diskimage export here=`pwd` m1=$mdstart m2=$((m1 + 1)) -mount | grep "${mntpoint}" | grep -q md$m2 && umount ${mntpoint}$m2 +mount | grep "$mntpoint" | grep -q md$m2 && umount ${mntpoint}$m2 mdconfig -l | grep -q md$m2 && mdconfig -d -u $m2 -mount | grep "${mntpoint}" | grep -q md$m1 && umount ${mntpoint}$m1 +mount | grep "$mntpoint" | grep -q md$m1 && umount ${mntpoint}$m1 mdconfig -l | grep -q md$m1 && mdconfig -d -u $m1 [ -d ${mntpoint}$m1 ] || mkdir -p ${mntpoint}$m1 [ -d ${mntpoint}$m2 ] || mkdir -p ${mntpoint}$m2 dede $D$m1 25m 1 || exit 1 mdconfig -a -t vnode -f $D$m1 -u $m1 bsdlabel -w md$m1 auto -newfs md${m1}${part} > /dev/null 2>&1 -mount /dev/md${m1}${part} ${mntpoint}$m1 +newfs md${m1}$part > /dev/null 2>&1 +mount /dev/md${m1}$part ${mntpoint}$m1 truncate -s 500M ${mntpoint}$m1/diskimage mdconfig -a -t vnode -f ${mntpoint}$m1/diskimage -u $m2 bsdlabel -w md$m2 auto -newfs md${m2}${part} > /dev/null 2>&1 -mount /dev/md${m2}${part} ${mntpoint}$m2 +newfs md${m2}$part > /dev/null 2>&1 +mount /dev/md${m2}$part ${mntpoint}$m2 dd if=/dev/zero of=${mntpoint}$m2/file bs=1m > /dev/null 2>&1 # Reversed umount sequence: -umount -f /dev/md${m1}${part} -umount -f /dev/md${m2}${part} +umount -f /dev/md${m1}$part +umount -f /dev/md${m2}$part -mount | grep "${mntpoint}" | grep -q md$m2 && umount ${mntpoint}$m2 +mount | grep "$mntpoint" | grep -q md$m2 && umount ${mntpoint}$m2 mdconfig -l | grep -q md$m2 && mdconfig -d -u $m2 -mount | grep "${mntpoint}" | grep -q md$m1 && umount ${mntpoint}$m1 +mount | grep "$mntpoint" | grep -q md$m1 && umount ${mntpoint}$m1 mdconfig -l | grep -q md$m1 && mdconfig -d -u $m1 Index: user/pho/stress2/misc/core4.sh =================================================================== --- user/pho/stress2/misc/core4.sh (revision 317637) +++ user/pho/stress2/misc/core4.sh (revision 317638) @@ -1,97 +1,97 @@ #!/bin/sh # # Copyright (c) 2014 EMC Corp. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ # # Test multiple (parallel) core dumps and umount -f # "panic: vn_finished_write: neg cnt" seen. # http://people.freebsd.org/~pho/core4.sh # Fixed in r274501 [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 mntpoint=/mnt mdstart=5 part=a newfs_flags="-U" testuser=stress [ -r ../default.cfg ] && . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > core4.c mycc -o core4 -Wall -Wextra -O0 -g core4.c || exit 1 rm -f core4.c mount | grep -q "$mntpoint" && umount $mntpoint mdconfig -l | grep -q $mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 2g -u $mdstart -bsdlabel -w md${mdstart} auto +bsdlabel -w md$mdstart auto newfs $newfs_flags md${mdstart}$part > /dev/null for i in `jot 20`; do mount /dev/md${mdstart}$part $mntpoint chmod 777 $mntpoint su $testuser -c "(cd $mntpoint; /tmp/core4)" & su $testuser -c "(cd $mntpoint; /tmp/core4)" & su $testuser -c "(cd $mntpoint; /tmp/core4)" & sleep .5 sleep .`jot -r 1 1 9` umount -f $mntpoint wait done 2>/dev/null while mount | grep -q "on $mntpoint "; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart rm -f /tmp/core4 exit 0 EOF #include #include #include #include #include #define SIZ (1024L * 1024 * 1024) int main(void) { void *p; p = mmap(NULL, SIZ, PROT_READ | PROT_WRITE, MAP_ANON, -1, 0); usleep(1000); raise(SIGSEGV); return (0); } Index: user/pho/stress2/misc/core5.sh =================================================================== --- user/pho/stress2/misc/core5.sh (revision 317637) +++ user/pho/stress2/misc/core5.sh (revision 317638) @@ -1,201 +1,201 @@ #!/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$ # # The core file vnode is unreferenced before notification is sent. # Problem reported by sbruno@ # http://people.freebsd.org/~pho/stress/log/core5.txt # Fixed by r279237. # 20150714 Slowdown seen with core5 waiting in vlruwk. # sysctl vfs.vlru_allow_cache_src=1 resolves this. # For now change MAXVNODES from 1.000 to 1.500. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > core5.c mycc -o core5 -Wall -Wextra -O0 -g core5.c || exit 1 rm -f core5.c cat > core5-dumper.c << EOT #include #include #include #include #include #include #include int main(int argc __unused, char *argv[]) { time_t start; char core[80]; snprintf(core, sizeof(core), "%s.core", argv[0]); if (unlink(core) == -1) if (errno != ENOENT) warn("unlink(%s)", core); start = time(NULL); while (time(NULL) - start < 600) { if (fork() == 0) raise(SIGSEGV); wait(NULL); } if (unlink(core) == -1) if (errno != ENOENT) warn("unlink(%s)", core); return (0); } EOT mycc -o core5-dumper -Wall -Wextra -O0 -g core5-dumper.c || exit 1 rm -f core5-dumper.c for i in `jot 10`; do cp core5-dumper core5-dumper$i done rm -f core5-dumper mount | grep -q "on $mntpoint " && umount $mntpoint [ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart mdconfig -a -t malloc -s 1g -u $mdstart -bsdlabel -w md${mdstart} auto +bsdlabel -w md$mdstart auto newfs -b 4096 -f 512 -i 2048 md${mdstart}$part > /dev/null mount -o async /dev/md${mdstart}$part $mntpoint || exit 1 cp /tmp/core5 $mntpoint mkdir $mntpoint/dir cd $mntpoint mp2=${mntpoint}2 [ -d $mp2 ] || mkdir $mp2 mount | grep -q "on $mp2 " && umount $mp2 mount -o size=2g -t tmpfs tmpfs $mp2 || exit 1 for i in `jot 10`; do (cd $mp2; /tmp/core5-dumper$i ) & done maxvnodes=`sysctl -n kern.maxvnodes` trap "sysctl kern.maxvnodes=$maxvnodes > /dev/null" EXIT INT $mntpoint/core5 $mntpoint/dir wait umount $mp2 cd $here while mount | grep -q "on $mntpoint "; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart rm -f /tmp/core5 /tmp/core5-dumper* /tmp/core5-dumper*.core exit 0 EOF #include #include #include #include #include #include #include #include #include #define MAXVNODES 1500 #define NBFILES 10000 #define PARALLEL 4 #define RTIME (10 * 60) char *path; void test(int n) { int fd, i; char file[80]; usleep(arc4random() % 1000); for (i = 0; i < NBFILES; i++) { snprintf(file, sizeof(file), "%s/f%d.%06d", path, n, i); if ((fd = open(file, O_CREAT, 0644)) == -1) { warn("open(%s)", file); break; } close(fd); } for (i = 0; i < NBFILES; i++) { snprintf(file, sizeof(file), "%s/f%d.%06d", path, n, i); if (unlink(file) == -1) err(1, "unlink(%s)", file); } _exit(0); } int main(int argc, char *argv[]) { size_t len; time_t start; int j, maxvnodes, nv; if (argc != 2) errx(1, "Usage: %s ", argv[0]); path = argv[1]; nv = MAXVNODES; len = sizeof(maxvnodes); if (sysctlbyname("kern.maxvnodes", &maxvnodes, &len, &nv, sizeof(nv)) != 0) err(1, "sysctl kern.maxvnodes 1"); start = time(NULL); while (time(NULL) - start < RTIME) { for (j = 0; j < PARALLEL; j++) if (fork() == 0) test(j); for (j = 0; j < PARALLEL; j++) wait(NULL); } if (sysctlbyname("kern.maxvnodes", NULL, NULL, &maxvnodes, sizeof(maxvnodes)) != 0) err(1, "sysctl kern.maxvnodes 2"); return (0); } Index: user/pho/stress2/misc/crossmp3.sh =================================================================== --- user/pho/stress2/misc/crossmp3.sh (revision 317637) +++ user/pho/stress2/misc/crossmp3.sh (revision 317638) @@ -1,105 +1,105 @@ #!/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$ # # Parallel mount and umount of file systems # "panic: Bad link elm 0xfffff8052a20cc00 prev->next != elm" seen: # http://people.freebsd.org/~pho/stress/log/crossmp3.txt # Fixed in r269853 # panic: softdep_waitidle: work added after flush: # http://people.freebsd.org/~pho/stress/log/crossmp3-2.txt, fixed by r273967. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg CONT=/tmp/crossmp3.continue N=`sysctl -n hw.ncpu` usermem=`sysctl -n hw.usermem` [ `swapinfo | wc -l` -eq 1 ] && usermem=$((usermem/100*80)) size=$((usermem / 1024 / 1024 / N)) mounts=$N # Number of parallel scripts if [ $# -eq 0 ]; then for i in `jot $mounts`; do m=$(( i + mdstart - 1 )) [ ! -d ${mntpoint}$m ] && { mkdir ${mntpoint}$m; chmod 755 ${mntpoint}$m; } mount | grep "${mntpoint}$m" | grep -q md$m && umount ${mntpoint}$m mdconfig -l | grep -q md$m && mdconfig -d -u $m mdconfig -a -t swap -s ${size}m -u $m bsdlabel -w md$m auto newfs $newfs_flags md${m}$part > /dev/null 2>&1 done # start the parallel tests touch $CONT for i in `jot $mounts`; do m=$(( i + mdstart - 1 )) ./$0 $m & ./$0 find & done wait for i in `jot $mounts`; do m=$(( i + mdstart - 1 )) mdconfig -d -u $m done else if [ $1 = find ]; then while [ -f $CONT ]; do find ${mntpoint}* -type f > /dev/null 2>&1 done else export runRUNTIME=20s # The test: Parallel mount and unmounts for i in `jot 3`; do m=$1 - mount /dev/md${m}${part} ${mntpoint}$m && + mount /dev/md${m}$part ${mntpoint}$m && chmod 777 ${mntpoint}$m export RUNDIR=${mntpoint}$m/stressX export CTRLDIR=${mntpoint}$m/stressX.control (cd ${mntpoint}$m && find . -delete) su $testuser -c 'cd ..; ./run.sh disk.cfg' > \ /dev/null 2>&1 while mount | grep -q "on ${mntpoint}$m "; do opt=$([ $((`date '+%s'` % 2)) -eq 0 ] && echo "-f") umount $opt ${mntpoint}$m > /dev/null 2>&1 [ -f $CONT ] || break 2 done done rm -f $CONT fi fi Index: user/pho/stress2/misc/crossmp4.sh =================================================================== --- user/pho/stress2/misc/crossmp4.sh (revision 317637) +++ user/pho/stress2/misc/crossmp4.sh (revision 317638) @@ -1,108 +1,108 @@ #!/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$ # # Parallel mount and umount of file systems. Nullfs version. # "panic: Lock (lockmgr) null not locked @ kern/vfs_default.c:523." seen. # http://people.freebsd.org/~pho/stress/log/kostik698.txt # Fixed by r269708. # Not fixed: https://people.freebsd.org/~pho/stress/log/kostik798.txt # https://people.freebsd.org/~pho/stress/log/kostik856.txt [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg N=`sysctl -n hw.ncpu` usermem=`sysctl -n hw.usermem` [ `swapinfo | wc -l` -eq 1 ] && usermem=$((usermem/100*80)) size=$((usermem / 1024 / 1024)) mounts=$N # Number of parallel scripts if [ $# -eq 0 ]; then - mount | grep "$mntpoint" | grep -q md && umount ${mntpoint} + mount | grep "$mntpoint" | grep -q md && umount $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s ${size}m -u $mdstart bsdlabel -w md$mdstart auto newfs $newfs_flags md${mdstart}$part > /dev/null 2>&1 mount /dev/md${mdstart}$part $mntpoint # start the parallel tests for i in `jot $mounts`; do m=$(( i + mdstart - 1 )) ./$0 $m & ./$0 find & done wait while mount | grep -q "on $mntpoint "; do umount $mntpoint > /dev/null 2>&1 || sleep 1 done mdconfig -d -u $mdstart else touch /tmp/crossmp.continue if [ $1 = find ]; then while [ -f /tmp/crossmp.continue ]; do find ${mntpoint}* -type f > /dev/null 2>&1 done else m=$1 set `df -ik $mntpoint | tail -1 | awk '{print $4,$7}'` export KBLOCKS=$(($1 / N)) export INODES=$(($2 / N)) export runRUNTIME=1m export INCARNATIONS=4 # The test: Parallel mount and unmounts for i in `jot 4`; do [ ! -d ${mntpoint}$m ] && mkdir ${mntpoint}$m mount -t nullfs $mntpoint ${mntpoint}$m mkdir -p ${mntpoint}$m/$m chmod 777 ${mntpoint}$m/$m export RUNDIR=${mntpoint}$m/$m/stressX export CTRLDIR=${mntpoint}$m/$m/stressX.control (cd ${mntpoint}$m/$m && find . -delete) su $testuser -c 'cd ..; ./run.sh disk.cfg' > \ /dev/null 2>&1 & sleep 30 while mount | grep -q "on ${mntpoint}$m "; do opt=$([ $((`date '+%s'` % 2)) -eq 0 ] && echo "-f") umount $opt ${mntpoint}$m > /dev/null 2>&1 done wait done rm -f /tmp/crossmp.continue fi fi Index: user/pho/stress2/misc/crossmp5.sh =================================================================== --- user/pho/stress2/misc/crossmp5.sh (revision 317637) +++ user/pho/stress2/misc/crossmp5.sh (revision 317638) @@ -1,97 +1,97 @@ #!/bin/sh # # Copyright (c) 2014 EMC Corp. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ # # Variation of crossmp3.sh [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg N=`sysctl -n hw.ncpu` usermem=`sysctl -n hw.usermem` [ `swapinfo | wc -l` -eq 1 ] && usermem=$((usermem/100*80)) size=$((usermem / 1024 / 1024 / N)) mounts=$N # Number of parallel scripts if [ $# -eq 0 ]; then for i in `jot $mounts`; do m=$(( i + mdstart - 1 )) [ ! -d ${mntpoint}$m ] && mkdir ${mntpoint}$m mount | grep "${mntpoint}$m" | grep -q md$m && umount ${mntpoint}$m mdconfig -l | grep -q md$m && mdconfig -d -u $m mdconfig -a -t swap -s ${size}m -u $m 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 wait for i in `jot $mounts`; do m=$(( i + mdstart - 1 )) mdconfig -d -u $m rm -f $D$m done else touch /tmp/crossmp.continue if [ $1 = find ]; then while [ -f /tmp/crossmp.continue ]; do find ${mntpoint}* -type f > /dev/null 2>&1 done else # The test: Parallel mount and unmount m=$1 for i in `jot 200`; do - mount /dev/md${m}${part} ${mntpoint}$m + mount /dev/md${m}$part ${mntpoint}$m chmod 777 ${mntpoint}$m l=`jot -r 1 65535` dd if=/dev/zero of=$mntpoint/$i bs=$l count=100 \ 2>&1 | egrep -v 'records|transferred' rm -f $mntpoint/$i while mount | grep -q "on ${mntpoint}$m "; do opt=$([ $((`date '+%s'` % 2)) -eq 0 ] && echo "-f") umount $opt ${mntpoint}$m > /dev/null 2>&1 done done rm -f /tmp/crossmp.continue fi fi Index: user/pho/stress2/misc/crossmp8.sh =================================================================== --- user/pho/stress2/misc/crossmp8.sh (revision 317637) +++ user/pho/stress2/misc/crossmp8.sh (revision 317638) @@ -1,122 +1,122 @@ #!/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$ # # Variation of crossmp3.sh. fifos and sockets added to load. # Not really a cross mount point test, but a test of the old # non-directory use of the vnode v_un union. # mckusick@ suggested using fifos for this test. # "panic: mtx_lock() of spin mutex @ ../kern/vfs_subr.c:512" seen. # https://people.freebsd.org/~pho/stress/log/crossmp8.txt # Fixed by r291671. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg CONT=/tmp/crossmp8.continue N=`sysctl -n hw.ncpu` usermem=`sysctl -n hw.usermem` [ `swapinfo | wc -l` -eq 1 ] && usermem=$((usermem/100*80)) size=$((usermem / 1024 / 1024 / N)) mounts=$N # Number of parallel scripts if [ $# -eq 0 ]; then oldmx=`sysctl -n kern.maxvnodes` trap "sysctl kern.maxvnodes=$oldmx > /dev/null" EXIT SIGINT sysctl kern.maxvnodes=2048 > /dev/null for i in `jot $mounts`; do m=$((i + mdstart - 1)) [ ! -d ${mntpoint}$m ] && { mkdir ${mntpoint}$m; chmod 755 ${mntpoint}$m; } mount | grep "${mntpoint}$m" | grep -q md$m && umount ${mntpoint}$m mdconfig -l | grep -q md$m && mdconfig -d -u $m mdconfig -a -t swap -s ${size}m -u $m bsdlabel -w md$m auto newfs md${m}$part > /dev/null 2>&1 done # start the parallel tests touch $CONT for i in `jot $mounts`; do m=$((i + mdstart - 1)) ./$0 $m & ./$0 find & done sleep 60 rm -f $CONT ../tools/killall.sh wait for i in `jot $mounts`; do m=$((i + mdstart - 1)) mdconfig -d -u $m done ./cleanup.sh else if [ $1 = find ]; then while [ -f $CONT ]; do find ${mntpoint}* -maxdepth 1 -ls > /dev/null 2>&1 sleep .1 done else export RUNTIME=15s export runRUNTIME=15s # The test: Parallel mount and unmounts start=`date '+%s'` while [ $((`date '+%s'` - start)) -lt 300 ]; do m=$1 - mount /dev/md${m}${part} ${mntpoint}$m && + mount /dev/md${m}$part ${mntpoint}$m && chmod 777 ${mntpoint}$m export RUNDIR=${mntpoint}$m/stressX export CTRLDIR=${mntpoint}$m/stressX.control export mkfifoLOAD=80 export socketLOAD=80 export TP=" testcases/mkfifo/mkfifo testcases/mkdir/mkdir " (cd ${mntpoint}$m && find . -delete) su $testuser -c 'cd ..; ./testcases/run/run $TP' > \ /dev/null 2>&1 while mount | grep -q "on ${mntpoint}$m "; do opt=$([ $((`date '+%s'` % 2)) -eq 0 ] && echo "-f") umount $opt ${mntpoint}$m > /dev/null 2>&1 [ -f $CONT ] || break 2 done done rm -f $CONT fi fi Index: user/pho/stress2/misc/crossmp9.sh =================================================================== --- user/pho/stress2/misc/crossmp9.sh (revision 317637) +++ user/pho/stress2/misc/crossmp9.sh (revision 317638) @@ -1,91 +1,91 @@ #!/bin/sh # # Copyright (c) 2016 Dell EMC Isilon # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ # # Parallel mount and umount of file systems, while using getfsstat(2) via # mount(8). [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg mounts=15 # Number of parallel scripts cont=/tmp/crossmp.continue mdstart=$mdstart # Use md unit numbers from this point if [ $# -eq 0 ]; then touch $cont 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 512m -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 $m & 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 m=$2 while [ -r $cont ]; do df ${mntpoint}$m mount done > /dev/null 2>&1 else # The test: Parallel mount and unmounts start=`date '+%s'` while [ $((`date '+%s'` - start)) -lt 300 ] ; do m=$1 - mount /dev/md${m}${part} ${mntpoint}$m + mount /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 $cont fi fi Index: user/pho/stress2/misc/dfull.sh =================================================================== --- user/pho/stress2/misc/dfull.sh (revision 317637) +++ user/pho/stress2/misc/dfull.sh (revision 317638) @@ -1,58 +1,58 @@ #!/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$ # # Processes stuck in "ufs" seen. # Looping softdep_request_cleanup() seen [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg mount | grep "$mntpoint" | grep md${mdstart}$part > /dev/null && umount $mntpoint mdconfig -l | grep md$mdstart > /dev/null && mdconfig -d -u $mdstart mdconfig -a -t swap -s 512m -u $mdstart bsdlabel -w md$mdstart auto newfs $newfs_flags md${mdstart}$part > /dev/null mount /dev/md${mdstart}$part $mntpoint -export RUNDIR=${mntpoint}/stressX +export RUNDIR=$mntpoint/stressX set `df -ik $mntpoint | tail -1 | awk '{print $4,$7}'` export KBLOCKS=$(($1 * 10)) export INODES=$(($2 * 10)) export runRUNTIME=30m export RUNTIME=1m (cd ..; ./run.sh disk.cfg > /dev/null 2>&1) while mount | grep $mntpoint | grep -q /dev/md; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart Index: user/pho/stress2/misc/ext2fs2.sh =================================================================== --- user/pho/stress2/misc/ext2fs2.sh (revision 317637) +++ user/pho/stress2/misc/ext2fs2.sh (revision 317638) @@ -1,57 +1,57 @@ #!/bin/sh # # Copyright (c) 2014 EMC Corp. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 # "panic: ext2_dirbad: /mnt: bad dir ino ...: mangled entry" seen. # https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=191895 . ../default.cfg # Uses mke2fs from sysutils/e2fsprogs [ -x /usr/local/sbin/mke2fs ] || exit 0 -mount | grep "$mntpoint" | grep -q md$mdstart && umount -f ${mntpoint} -mdconfig -l | grep -q ${mdstart} && mdconfig -d -u $mdstart +mount | grep "$mntpoint" | grep -q md$mdstart && umount -f $mntpoint +mdconfig -l | grep -q $mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart -bsdlabel -w md${mdstart} auto +bsdlabel -w md$mdstart auto mke2fs /dev/md${mdstart}a # No panic seen when disabling hashed b-tree lookup for large directories # tune2fs -O ^dir_index /dev/md${mdstart}$part mount -t ext2fs /dev/md${mdstart}$part $mntpoint export RUNDIR=$mntpoint/stressX export runRUNTIME=10m # Run tests for 10 minutes (cd ..; ./run.sh disk.cfg) while mount | grep "$mntpoint " | grep -q md$mdstart; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart Index: user/pho/stress2/misc/extattr.sh =================================================================== --- user/pho/stress2/misc/extattr.sh (revision 317637) +++ user/pho/stress2/misc/extattr.sh (revision 317638) @@ -1,96 +1,96 @@ #!/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$ # # Regression test of extattr on a UFS2 FS using ACLs # Caused a "Duplicate free" panic. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg odir=`pwd` cd /tmp sed '1,/^EOF/d' < $odir/$0 > extattr.c mycc -o extattr -Wall extattr.c rm -f extattr.c cd $odir -mount | grep "${mntpoint}" | grep -q md${mdstart}${part} && umount $mntpoint +mount | grep "$mntpoint" | grep -q md${mdstart}$part && umount $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 20m -u $mdstart bsdlabel -w md$mdstart auto -newfs -O 2 md${mdstart}${part} > /dev/null -mount /dev/md${mdstart}${part} $mntpoint +newfs -O 2 md${mdstart}$part > /dev/null +mount /dev/md${mdstart}$part $mntpoint -mkdir -p ${mntpoint}/.attribute/system -cd ${mntpoint}/.attribute/system +mkdir -p $mntpoint/.attribute/system +cd $mntpoint/.attribute/system extattrctl initattr -p . 388 posix1e.acl_access extattrctl initattr -p . 388 posix1e.acl_default cd / umount /mnt -tunefs -a enable /dev/md${mdstart}${part} -mount /dev/md${mdstart}${part} $mntpoint -mount | grep md${mdstart}${part} +tunefs -a enable /dev/md${mdstart}$part +mount /dev/md${mdstart}$part $mntpoint +mount | grep md${mdstart}$part touch $mntpoint/acl-test setfacl -b $mntpoint/acl-test setfacl -m user:nobody:rw-,group:wheel:rw- $mntpoint/acl-test for i in `jot 5`; do /tmp/extattr $mntpoint/acl-test & done for i in `jot 5`; do wait done umount $mntpoint mdconfig -d -u $mdstart rm -f /tmp/extattr exit EOF #include #include #include int main(int argc, char **argv) { int i; struct stat sb; for (i = 0; i < 100000; i++) if (lstat(argv[1], &sb) == -1) err(1, "lstat(%s)", argv[1]); return (0); } Index: user/pho/stress2/misc/extattr_set_fd.sh =================================================================== --- user/pho/stress2/misc/extattr_set_fd.sh (revision 317637) +++ user/pho/stress2/misc/extattr_set_fd.sh (revision 317638) @@ -1,80 +1,80 @@ #!/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$ # # "panic: kmem_malloc(2069012480): kmem_map too small" seen. # Fixed in r237366. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > extattr_set_fd.c mycc -o extattr_set_fd -Wall -Wextra -O2 extattr_set_fd.c rm -f extattr_set_fd.c mount | grep -q "$mntpoint" && umount $mntpoint mdconfig -l | grep -q $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 +bsdlabel -w md$mdstart auto +newfs $newfs_flags md${mdstart}$part > /dev/null +mount /dev/md${mdstart}$part $mntpoint chmod 777 $mntpoint (cd $mntpoint; /tmp/extattr_set_fd) while mount | grep -q $mntpoint; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart rm -f /tmp/extattr_set_fd exit 0 EOF #include #include #include #include #include char buf[4096]; int main(void) { int fd; if ((fd = open("theFile", O_RDWR | O_CREAT, 0622)) == -1) err(1, "open(%s)", "theFile"); (void) extattr_set_fd(fd, 1, "test", buf, 0x7b5294a6); return (0); } Index: user/pho/stress2/misc/fdgrowtable.sh =================================================================== --- user/pho/stress2/misc/fdgrowtable.sh (revision 317637) +++ user/pho/stress2/misc/fdgrowtable.sh (revision 317638) @@ -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$ # # Regression test for r236822. # http://people.freebsd.org/~pho/stress/log/fdgrowtable.txt # Fixed in r256210. . ../default.cfg max=`ulimit -n` here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > fdgrowtable.c mycc -o fdgrowtable -Wall -Wextra -O2 fdgrowtable.c || exit 1 rm -f fdgrowtable.c cd $here -su ${testuser} -c "/tmp/fdgrowtable $max" & +su $testuser -c "/tmp/fdgrowtable $max" & while kill -0 $! 2>/dev/null; do ../testcases/swap/swap -t 2m -i 40 -h done wait rm -f /tmp/fdgrowtable exit EOF #include #include #include #include #include #include #include #include #include #define PARALLEL 3 int max; void test(void) { int i; for (i = 0; i < max; i++) { if (dup2(1, i + 3) == -1) err(1, "dup2(%d)", i + 3); } _exit(0); } int main(int argc, char **argv) { int i, j; if (argc == 2) max = atoi(argv[1]); else err(1, "Usage: %s ", argv[0]); max = (max - 3) / PARALLEL; for (j = 0; j < 300; j++) { for (i = 0; i < PARALLEL; i++) { if (fork() == 0) test(); } for (i = 0; i < PARALLEL; i++) wait(NULL); } return (0); } Index: user/pho/stress2/misc/fragments.sh =================================================================== --- user/pho/stress2/misc/fragments.sh (revision 317637) +++ user/pho/stress2/misc/fragments.sh (revision 317638) @@ -1,280 +1,280 @@ #!/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$ # # Scenario that causes "panic: brelse: free buffer onto another queue???" # Idea for scenario by kib@. Fixed in r203818 # When UFS partition is full, then some high load causes # panic: brelse: free buffer onto another queue??? [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > fragments.c rm -f /tmp/fragments mycc -o fragments -Wall -Wextra -O2 -g fragments.c rm -f fragments.c cd $here -mount | grep "$mntpoint" | grep -q md$mdstart && umount -f ${mntpoint} +mount | grep "$mntpoint" | grep -q md$mdstart && umount -f $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart bsdlabel -w md$mdstart auto newfs $newfs_flags -m 0 md${mdstart}$part > /dev/null 2>&1 mount /dev/md${mdstart}$part $mntpoint chmod 777 $mntpoint cd $mntpoint su $testuser -c "/tmp/fragments" cd $here umount $mntpoint mount | grep "$mntpoint" | grep -q md$mdstart && umount -f $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart rm -f /tmp/fragments exit EOF #include #include #include #include #include #include #include #include #include #include #include #include //#define LOOPS 50000 #define LOOPS 600 #define PARALLEL 8 static pid_t pid; static char *buf; static volatile sig_atomic_t stop; void handler(int i __unused) { stop = 1; } void cleanup(int n) { int i, j, start; int nb = 0; char file[128]; struct statfs sbuf; struct stat sb; if (n == -1) { for (i = 0; i < LOOPS; i++) { sprintf(file,"t%05d", i); unlink(file); } return; } start = arc4random() % n; for (i = 0; i < LOOPS; i++) { j = (start + i) % LOOPS; sprintf(file,"t%05d", j); if (stat(file, &sb) != 0) continue; if (sb.st_size == 0) { unlink(file); continue; } if (truncate(file, 0) == 0) { nb++; continue; } if (nb > 10) break; } for (i = 0; i < 10; i++) { if (statfs(".", &sbuf) < 0) err(1, "statfs(%s)", "."); if (sbuf.f_bfree > 8) return; } for (i = 0; i < LOOPS; i++) { j = (start + i) % LOOPS; sprintf(file,"t%05d", j); if (unlink(file) == 0) { return; } } } void fragments(void) { int i, len; char file[128]; int fd; for (i = 0;; i++) { sprintf(file,"d%d/f%05d.%05d", i/1000, pid, i); if ((fd = open(file, O_RDWR | O_CREAT | O_TRUNC, 0600)) < 0) { if (errno != ENOSPC) warn("open(%s)", file); break; } len = 2 * 1024; if (write(fd, buf, len) != len) { } close(fd); } } void blocks(void) { int i, len; char file[128]; int fd; for (i = 0;; i++) { sprintf(file,"d%d/b%05d.%05d", i/1000, pid, i); if ((fd = open(file, O_RDWR | O_CREAT | O_TRUNC, 0600)) < 0) { if (errno != ENOSPC) warn("open(%s)", file); break; } len = 16 * 1024; if (write(fd, buf, len) != len) { } close(fd); } } void setup(void) { int i; char file[128]; for (i = 0; i < 300; i++) { sprintf(file,"d%d", i); if (mkdir(file, 0700) == -1) warn("mkdir(%s)", file); } blocks(); fragments(); for (i = 0;i < 8; i++) { sprintf(file,"d%d/b%05d.%05d", i/1000, pid, i); unlink(file); } for (i = 0;i < 1; i++) { sprintf(file,"d%d/f%05d.%05d", i/1000, pid, i); unlink(file); } } int test(void) { int i, len, n; char file[128]; int fd; for (i = 0; i < LOOPS; i++) { sprintf(file,"t%05d", i); if ((fd = open(file, O_RDWR | O_CREAT | O_EXCL, 0600)) < 0) { continue; } // n = arc4random() % (12 + 1); n = 0; len = (arc4random() % (16 * 1024) + 1) + n * 16; while (len > 0) { if (write(fd, buf, len) == len) break; len = len / 2; usleep(1000); } close(fd); if (len == 0) { cleanup(i); } } exit(0); return (0); } int main() { int i, j, status; pid = getpid(); if ((buf = malloc(12 * 16 * 1024)) == NULL) err(1, "malloc()"); setup(); signal(SIGALRM, handler); alarm(30 * 60); for (j = 0; j < 50 && stop == 0; j++) { for (i = 0; i < PARALLEL; i++) { if (fork() == 0) test(); } for (i = 0; i < PARALLEL; i++) wait(&status); cleanup(-1); } return (0); } Index: user/pho/stress2/misc/fs.sh =================================================================== --- user/pho/stress2/misc/fs.sh (revision 317637) +++ user/pho/stress2/misc/fs.sh (revision 317638) @@ -1,77 +1,77 @@ #!/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$ # # Run a simple test on different FS variations, with and without disk full. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg ftest () { # option, disk full [ $2 -eq 1 ] && df=", disk full" || df="" echo "`date '+%T'` newfs $1 md${mdstart}${part}$df" newfs $1 md${mdstart}$part > /dev/null mount /dev/md${mdstart}$part $mntpoint chmod 777 $mntpoint - export RUNDIR=${mntpoint}/stressX + export RUNDIR=$mntpoint/stressX export runRUNTIME=2m disk=$(($2 + 1)) # 1 or 2 set `df -ik $mntpoint | tail -1 | awk '{print $4,$7}'` export KBLOCKS=$(($1 * disk)) export INODES=$(($2 * disk)) for i in `jot 2`; do rm -rf /tmp/stressX.control $RUNDIR su $testuser -c "(cd ..; ./run.sh disk.cfg)" > /dev/null 2>&1 done while mount | grep $mntpoint | grep -q /dev/md; do umount $mntpoint || sleep 1 done } -mount | grep "${mntpoint}" | grep md${mdstart}${part} > /dev/null && umount ${mntpoint} -mdconfig -l | grep md${mdstart} > /dev/null && mdconfig -d -u ${mdstart} +mount | grep "$mntpoint" | grep md${mdstart}$part > /dev/null && umount $mntpoint +mdconfig -l | grep md$mdstart > /dev/null && mdconfig -d -u $mdstart -mdconfig -a -t swap -s 20m -u ${mdstart} -bsdlabel -w md${mdstart} auto +mdconfig -a -t swap -s 20m -u $mdstart +bsdlabel -w md$mdstart auto ftest "-O 1" 0 # ufs1 ftest "-O 1" 1 # ufs1, disk full ftest "-O 2" 0 # ufs2 ftest "-O 2" 1 # ufs2, disk full ftest "-U" 0 # ufs2 + soft update ftest "-U" 1 # ufs2 + soft update, disk full ftest "-j" 0 # ufs2 + SU+J ftest "-j" 1 # ufs2 + SU+J, disk full -mdconfig -d -u ${mdstart} +mdconfig -d -u $mdstart Index: user/pho/stress2/misc/ftruncate2.sh =================================================================== --- user/pho/stress2/misc/ftruncate2.sh (revision 317637) +++ user/pho/stress2/misc/ftruncate2.sh (revision 317638) @@ -1,212 +1,212 @@ #!/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$ # -# A fuzz test. Most likely a disk full / FFS issue. +# A fuzz test triggered a failed block allocation unwinding problem. # "panic: ffs_blkfree_cg: freeing free block" seen: # https://people.freebsd.org/~pho/stress/log/kostik923.txt # Fixed by r304232. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg odir=`pwd` cd /tmp sed '1,/^EOF/d' < $odir/$0 > ftruncate2.c rm -f /tmp/ftruncate2 mycc -o ftruncate2 -Wall -Wextra -O2 -g ftruncate2.c -lpthread || exit 1 rm -f ftruncate2.c echo "Expect: \"/mnt: write failed, filesystem is full\"" mount | grep $mntpoint | grep -q "on $mntpoint " && umount -f $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart || exit 1 -bsdlabel -w md${mdstart} auto +bsdlabel -w md$mdstart auto newfs md${mdstart}$part > /dev/null # Non SU panics mount /dev/md${mdstart}$part $mntpoint dir=$mntpoint chmod 777 $dir cd $dir jot 500 | xargs touch jot 500 | xargs chmod 666 cd $odir (cd /tmp; /tmp/ftruncate2 $dir) e=$? rm -rf $dir/* while mount | grep -q "on $mntpoint "; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart rm -f /tmp/ftruncate2 exit $e EOF #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define N (128 * 1024 / (int)sizeof(u_int32_t)) #define RUNTIME 180 #define THREADS 2 static int fd[900]; static u_int32_t r[N]; static char *args[2]; static unsigned long makearg(void) { unsigned long val; val = arc4random(); #if defined(__LP64__) val = (val << 32) | arc4random(); val = val & 0x00007fffffffffffUL; #endif return(val); } static void * test(void *arg __unused) { FTS *fts; FTSENT *p; int ftsoptions, i, n; ftsoptions = FTS_PHYSICAL; for (;;) { for (i = 0; i < N; i++) r[i] = arc4random(); if ((fts = fts_open(args, ftsoptions, NULL)) == NULL) err(1, "fts_open"); i = n = 0; while ((p = fts_read(fts)) != NULL) { if (fd[i] > 0) close(fd[i]); if ((fd[i] = open(p->fts_path, O_RDWR)) == -1) if ((fd[i] = open(p->fts_path, O_WRONLY)) == -1) continue; if (ftruncate(fd[i], 0) != 0) err(1, "ftruncate"); i++; i = i % nitems(fd); } if (fts_close(fts) == -1) err(1, "fts_close()"); sleep(1); } return(0); } static void * calls(void *arg __unused) { off_t offset; time_t start; int fd2; start = time(NULL); while ((time(NULL) - start) < RUNTIME) { fd2 = makearg() % nitems(fd) + 3; offset = makearg(); if (lseek(fd2, offset - 1, SEEK_SET) != -1) { if (write(fd2, "x", 1) != 1) if (errno != EBADF && errno != ENOSPC && errno != E2BIG && errno != ESTALE && errno != EFBIG) warn("write"); } else if (errno != EBADF) warn("lseek"); if (fsync(fd2) == -1) if (errno != EBADF) warn("x"); } return (0); } int main(int argc, char **argv) { struct passwd *pw; pthread_t rp, cp[THREADS]; int e, i; if (argc != 2) { fprintf(stderr, "Usage: %s \n", argv[0]); exit(1); } args[0] = argv[1]; args[1] = 0; if ((pw = getpwnam("nobody")) == NULL) err(1, "failed to resolve nobody"); if (setgroups(1, &pw->pw_gid) || setegid(pw->pw_gid) || setgid(pw->pw_gid) || seteuid(pw->pw_uid) || setuid(pw->pw_uid)) err(1, "Can't drop privileges to \"nobody\""); endpwent(); arc4random_stir(); if ((e = pthread_create(&rp, NULL, test, NULL)) != 0) errc(1, e, "pthread_create"); usleep(1000); for (i = 0; i < THREADS; i++) if ((e = pthread_create(&cp[i], NULL, calls, NULL)) != 0) errc(1, e, "pthread_create"); for (i = 0; i < THREADS; i++) pthread_join(cp[i], NULL); return (0); } Index: user/pho/stress2/misc/fuse.sh =================================================================== --- user/pho/stress2/misc/fuse.sh (revision 317637) +++ user/pho/stress2/misc/fuse.sh (revision 317638) @@ -1,59 +1,59 @@ #!/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$ # # General Fuse test scenario [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg [ -z "`type mkntfs 2>/dev/null`" ] && exit 0 [ -c /dev/fuse ] || kldload fuse.ko MOUNT=/usr/local/bin/ntfs-3g mount | grep -q "$mntpoint" && umount $mntpoint mdconfig -l | grep -q $mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart -mkntfs -Ff /dev/md${mdstart} > /dev/null 2>&1 || exit 1 +mkntfs -Ff /dev/md$mdstart > /dev/null 2>&1 || exit 1 -$MOUNT /dev/md${mdstart} $mntpoint || exit 1 +$MOUNT /dev/md$mdstart $mntpoint || exit 1 export RUNDIR=$mntpoint/stressX export runRUNTIME=20m (cd ..; ./run.sh marcus.cfg) rm -rf $RUNDIR for i in `jot 10`; do umount $mntpoint || sleep 2 mount | grep -q $mntpoint || break done mdconfig -d -u $mdstart Index: user/pho/stress2/misc/fuzz.sh =================================================================== --- user/pho/stress2/misc/fuzz.sh (revision 317637) +++ user/pho/stress2/misc/fuzz.sh (revision 317638) @@ -1,180 +1,180 @@ #!/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$ # # Stress test UFS2 file systems by introducing single bit errors in the FS # fsck should fix the FS no matter how damaged, but e.g. this panic has been seen: # # panic(c0912b65,dfe96000,0,c09e4060,ef48c778,...) at panic+0x14b # vm_fault(c1868000,dfe96000,1,0) at vm_fault+0x1e0 # trap_pfault(ef48c894,0,dfe96000) at trap_pfault+0x137 # trap(dfe90008,ef480028,c0690028,d0560000,dfe96000,...) at trap+0x341 # calltrap() at calltrap+0x5 # --- trap 0xc, eip = 0xc08785a6, esp = 0xef48c8d4, ebp = 0xef48c958 --- # generic_bcopy(c81cd570,d0508000,c5ead600,c87b81c0,0,...) at generic_bcopy+0x1a # ffs_mount(d0508000,c5ead600,0,c09b0860,c5ecfc3c,...) at ffs_mount+0xa14 # vfs_domount(c5ead600,cd8c7280,ccb75080,0,...) at vfs_domount+0x687 # vfs_donmount(c5ead600,0,ef48cc04) at vfs_donmount+0x2ef # kernel_mount(c5660960,0,bfbfec86,0,fffffffe,...) at kernel_mount+0x6d # ffs_cmount(c5660960,bfbfde50,0,c5ead600,c09b0860,...) at ffs_cmount+0x5d # mount(c5ead600,ef48cd04) at mount+0x156 # syscall(3b,3b,3b,804abcf,bfbfe8e4,...) at syscall+0x22f [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg D=$diskimage tst() { rm -f $D truncate -s 2M $D mdconfig -a -t vnode -f $D -u $mdstart bsdlabel -w md$mdstart auto newfs -b 8192 -f 1024 $newfs_flags /dev/md${mdstart}$part > /dev/null 2>&1 mount /dev/md${mdstart}$part $mntpoint cp /etc/passwd /etc/group /etc/hosts $mntpoint cp -r /usr/include/ufs $mntpoint umount $mntpoint for i in `jot 50`; do ./fuzz -n 50 $D if fsck -f -y /dev/md${mdstart}$part 2>&1 | egrep "^[A-Z]" > /dev/null; then if fsck -f -y /dev/md${mdstart}$part 2>&1 | egrep "^[A-Z]" > /dev/null; then if fsck -f -y /dev/md${mdstart}$part 2>&1 | egrep "^[A-Z]" > /dev/null; then echo "fsck is giving up in loop $i!" break fi fi fi sync;sync;sync if mount /dev/md${mdstart}$part $mntpoint; then ls -l $mntpoint > /dev/null find $mntpoint -exec dd if={} of=/dev/null bs=1m count=3 \; > /dev/null 2>&1 umount $mntpoint else echo "Giving up at loop $i" break fi done - mdconfig -d -u ${mdstart} + mdconfig -d -u $mdstart rm -f $D } odir=`pwd` dir=/tmp cd $dir sed '1,/^EOF/d' < $odir/$0 > $dir/fuzz.c mycc -o fuzz -Wall fuzz.c rm -f fuzz.c for j in `jot 10`; do date '+%T' tst done rm -f fuzz exit EOF #include #include #include #include #include #include void usage(void) { fprintf(stderr, "%s {-n \n", getprogname()); exit(1); } long random_long(long mi, long ma) { return (arc4random() % (ma - mi + 1) + mi); } int main(int argc, char **argv) { int ch, fd, i, times = 1, verbose = 0; long pos; unsigned char bit, buf, mask, old; struct stat sb; while ((ch = getopt(argc, argv, "n:v")) != -1) switch(ch) { case 'n': /* Bits to alter */ if (sscanf(optarg, "%d", ×) != 1) usage(); break; case 'v': /* verbose flag */ verbose += 1; break; default: usage(); } argc -= optind; argv += optind; if (argc == 0) usage(); if ((fd = open(argv[0], O_RDWR)) == -1) err(1, "open(%s)", argv[0]); if (fstat(fd, &sb) == -1) err(1, "stat(%s)", argv[0]); for (i = 0; i < times; i++) { pos = random_long(0, sb.st_size - 1); if (lseek(fd, pos, SEEK_SET) == -1) err(1, "fseek(%d, %ld)", fd, pos); if (read(fd, &buf, 1) != 1) err(1, "read(%d)", fd); bit = random_long(0,7); mask = ~(1 << bit); old = buf; buf = (buf & mask) | (~buf & ~mask); if (verbose > 0) printf("Change %2x to %2x at %4ld by flipping bit %d\n", old, buf, pos, bit); if (lseek(fd, pos, SEEK_SET) == -1) err(1, "fseek(%d, %ld)", fd, pos); if (write(fd, &buf, 1) != 1) err(1, "write(%d)", fd); } close(fd); return (0); } Index: user/pho/stress2/misc/linger2.sh =================================================================== --- user/pho/stress2/misc/linger2.sh (revision 317637) +++ user/pho/stress2/misc/linger2.sh (revision 317638) @@ -1,174 +1,174 @@ #!/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$ # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 # Variation of linger.sh, with emphasis on blocks. . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > linger2.c mycc -o linger2 -Wall -O2 linger2.c rm -f linger2.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 [ $# -eq 1 ] && opt="$1" [ $# -eq 0 ] && opt=$newfs_flags # No argument == default flag newfs $opt -n md${mdstart}$part > /dev/null mount /dev/md${mdstart}$part $mntpoint chmod 777 $mntpoint set `df -i $mntpoint | tail -1 | awk '{print $3, $6}'` min=24 [ -r $mntpoint/.sujournal ] && { size=88; min=8232; } -if ! su ${testuser} -c "cd $mntpoint; /tmp/linger2 $size 2>/dev/null"; then +if ! su $testuser -c "cd $mntpoint; /tmp/linger2 $size 2>/dev/null"; then r=`df -i $mntpoint | head -1` echo " $r" for i in `jot 12`; do r=`df -ik $mntpoint | tail -1` [ "$r" != "$old" ] && echo "`date '+%T'` $r" old=$r [ `echo $r | awk '{print $3}'` -le $min ] && break sleep 10 done fi while mount | grep "$mntpoint " | grep -q /dev/md; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart rm -f /tmp/linger2 exit EOF #include #include #include #include #include #include #include #include #include #include #include #define PARALLEL 10 static int size = 89; int test(void) { int error = 0, fd, i, j; pid_t pid; char file[128]; char *buf; for (;;) { if (access("rendezvous", R_OK) == 0) break; sched_yield(); } pid = getpid(); buf = malloc(1024 * 1024); for (j = 0; j < size; j++) { sprintf(file,"p%05d.%05d", pid, j); if ((fd = creat(file, 0660)) == -1) { if (errno != EINTR) { warn("creat(%s). %s:%d", file, __FILE__, __LINE__); unlink("continue"); error = 1; break; } } if (write(fd, buf, 1024 * 1024) != 1024 * 1024) { warn("write()"); unlink("continue"); error = 1; break; } if (fd != -1 && close(fd) == -1) err(2, "close(%d)", j); } sleep(3); if (error == 0) j--; for (i = j; i >= 0; i--) { sprintf(file,"p%05d.%05d", pid, i); if (unlink(file) == -1) warn("unlink(%s)", file); } return (error); } int main(int argc, char **argv) { int error = 0, fd, i, j, status; if (argc == 2) size = atoi(argv[1]); umask(0); if ((fd = open("continue", O_CREAT, 0644)) == -1) err(1, "open()"); close(fd); for (i = 0; i < 200; i++) { for (j = 0; j < PARALLEL; j++) { if (fork() == 0) exit(test()); } if ((fd = open("rendezvous", O_CREAT, 0644)) == -1) err(1, "open()"); close(fd); for (j = 0; j < PARALLEL; j++) { wait(&status); error += status; } unlink("rendezvous"); if (access("continue", R_OK) == -1) { break; } } unlink("continue"); return (error != 0); } Index: user/pho/stress2/misc/linger3.sh =================================================================== --- user/pho/stress2/misc/linger3.sh (revision 317637) +++ user/pho/stress2/misc/linger3.sh (revision 317638) @@ -1,136 +1,136 @@ #!/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$ # # Test for SU problem with false EMLINK [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > linger3.c mycc -o linger3 -Wall -Wextra -O2 linger3.c rm -f linger3.c mount | grep "$mntpoint" | grep -q md$mdstart && umount $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 2g -u $mdstart bsdlabel -w md$mdstart auto [ $# -eq 1 ] && opt="$1" [ $# -eq 0 ] && opt=$newfs_flags # No argument == default flag echo "newfs $opt md${mdstart}$part" newfs $opt md${mdstart}$part > /dev/null mount /dev/md${mdstart}$part $mntpoint cd $mntpoint chmod 777 $mntpoint su $testuser -c "/tmp/linger3" cd $here while mount | grep -q $mntpoint; do - umount ${mntpoint} 2> /dev/null || sleep 1 + umount $mntpoint 2> /dev/null || sleep 1 done mdconfig -d -u $mdstart rm -f /tmp/linger3 exit 0 EOF #include #include #include #include #include #include #include #include #include #include #define PARALLEL 4 #define ND ((32767 / PARALLEL) - 2) static pid_t p; void setup(int loop) { int d; char name[128]; for (d = 0; d < ND; d++) { snprintf(name, sizeof(name), "d%06d.%03d", p, d); if (mkdir(name, 00700) == -1) err(1, "mkdir(%s) @ loop #%d", name, loop); } } void prune(int loop) { int d; char name[128]; for (d = 0; d < ND; d++) { snprintf(name, sizeof(name), "d%06d.%03d", p, d); if (rmdir(name) == -1) err(1, "rmdir(%s) @ loop #%d", name, loop); } } int main() { int i, j; int linger = 0; if (getenv("LINGER")) linger = atoi(getenv("LINGER")); for (i = 0; i < PARALLEL; i++) { if (fork() == 0) { p = getpid(); for (j = 0; j < 10; j++) { setup(j); prune(j); if (linger != 0) sleep(linger); } _exit(0); } } for (i = 0; i < PARALLEL; i++) wait(NULL); return (0); } Index: user/pho/stress2/misc/linger4.sh =================================================================== --- user/pho/stress2/misc/linger4.sh (revision 317637) +++ user/pho/stress2/misc/linger4.sh (revision 317638) @@ -1,157 +1,157 @@ #!/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$ # # Test for SU problem with "out of inodes" for CREAT [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > linger4.c mycc -o linger4 -Wall -Wextra -O2 linger4.c rm -f linger4.c mount | grep "$mntpoint" | grep -q md$mdstart && umount $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 2g -u $mdstart bsdlabel -w md$mdstart auto [ $# -eq 1 ] && opt="$1" [ $# -eq 0 ] && opt="$newfs_flags -n" # No argument == default flag echo "newfs $opt md${mdstart}$part" newfs $opt md${mdstart}$part > /dev/null mount /dev/md${mdstart}$part $mntpoint cd $mntpoint chmod 777 $mntpoint su $testuser -c "/tmp/linger4" || { ls -la $mntpoint; df -i $mntpoint; } cd $here while mount | grep -q $mntpoint; do - umount ${mntpoint} 2> /dev/null || sleep 1 + umount $mntpoint 2> /dev/null || sleep 1 done mdconfig -d -u $mdstart rm -f /tmp/linger4 exit 0 EOF #include #include #include #include #include #include #include #include #include #include #define LOOPS 300 #define NUMBER 80000 / PARALLEL /* Number of files to use. Max is 131068 */ #define PARALLEL 4 #define TIMEOUT (20 * 60) void Creat(int loopno) { int e, fd, i, j; char file[128]; char path[128]; pid_t pid; e = 0; pid = getpid(); sprintf(path, "f%06d", pid); if (mkdir(path, 0770) == -1) warn("mkdir(%s), %s:%d, loop #%d", path, __FILE__, __LINE__, loopno); chdir(path); for (j = 0; j < NUMBER; j++) { sprintf(file,"p%05d.%05d", pid, j); if ((fd = creat(file, 0660)) == -1) { if (errno != EINTR) { warn("creat(%s). %s:%d, loop #%d", file, __FILE__, __LINE__, loopno); e = 1; break; } } if (fd != -1 && close(fd) == -1) err(2, "close(%d)", j); } for (i = --j; i >= 0; i--) { sprintf(file,"p%05d.%05d", pid, i); if (unlink(file) == -1) err(3, "unlink(%s)", file); } chdir (".."); if (rmdir(path) == -1) err(1, "rmdir(%s), %s:%d, loop #%d", path, __FILE__, __LINE__, loopno); _exit(e); } int main() { time_t start; int e, i, j, status; e = 0; start = time(NULL); for (j = 0; j < LOOPS; j++) { for (i = 0; i < PARALLEL; i++) { if (fork() == 0) Creat(j); } for (i = 0; i < PARALLEL; i++) { wait(&status); e += WEXITSTATUS(status); } if (e != 0) break; // sleep(60); /* No problems if this is included */ if (time(NULL) - start > TIMEOUT) { fprintf(stderr, "Timeout.\n"); e++; break; } } return (e); } Index: user/pho/stress2/misc/md.sh =================================================================== --- user/pho/stress2/misc/md.sh (revision 317637) +++ user/pho/stress2/misc/md.sh (revision 317638) @@ -1,60 +1,60 @@ #!/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$ # # Caused panic: ffs_truncate3 # The problem is caused by a full FS with Soft-updates disabled. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg -mount | grep "$mntpoint" | grep md${mdstart}${part} > /dev/null && umount $mntpoint +mount | grep "$mntpoint" | grep md${mdstart}$part > /dev/null && umount $mntpoint [ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart mdconfig -a -t swap -s 2m -u $mdstart -bsdlabel -w md${mdstart} auto -newfs md${mdstart}${part} > /dev/null +bsdlabel -w md$mdstart auto +newfs md${mdstart}$part > /dev/null mount /dev/md${mdstart}$part $mntpoint -export RUNDIR=${mntpoint}/stressX +export RUNDIR=$mntpoint/stressX export KBLOCKS=30000 # Exaggerate disk capacity export INODES=8000 for i in `jot 20`; do (cd ../testcases/rw;./rw -t 2m -i 20 > /dev/null 2>&1) done while mount | grep -q $mntpoint; do umount $([ $((`date '+%s'` % 2)) -eq 0 ] && echo "-f" || echo "") $mntpoint > /dev/null 2>&1 done mdconfig -d -u $mdstart exit 0 Index: user/pho/stress2/misc/md3.sh =================================================================== --- user/pho/stress2/misc/md3.sh (revision 317637) +++ user/pho/stress2/misc/md3.sh (revision 317638) @@ -1,58 +1,58 @@ #!/bin/sh # # Copyright (c) 2009-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$ # # Test scenario for deadlock fixed in r200447 [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg mount | grep -q "$mntpoint" && umount $mntpoint mdconfig -l | grep -q $mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1400m -u $mdstart -bsdlabel -w md${mdstart} auto +bsdlabel -w md$mdstart auto -newfs $newfs_flags md5${part} > /dev/null -mount /dev/md5${part} $mntpoint +newfs $newfs_flags md5$part > /dev/null +mount /dev/md5$part $mntpoint # Stop FS "out of inodes" problem by only using 70% set `df -ik /mnt | tail -1 | awk '{print $4,$7}'` export KBLOCKS=$(($1 / 10 * 7)) export INODES=$(($2 / 10 * 7)) export RUNDIR=$mntpoint/stressX export runRUNTIME=10m (cd ..; ./run.sh marcus.cfg) umount $mntpoint mount | grep -q "$mntpoint" && umount -f $mntpoint mdconfig -d -u $mdstart Index: user/pho/stress2/misc/mmap4.sh =================================================================== --- user/pho/stress2/misc/mmap4.sh (revision 317637) +++ user/pho/stress2/misc/mmap4.sh (revision 317638) @@ -1,117 +1,117 @@ #!/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$ # # Test overcommit of the file system capacity # Causes panic: 1 vncache entries remaining # Fixed in r202529 # Scenario by kib@ [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > mmap4.c mycc -o mmap4 -Wall -O2 mmap4.c rm -f mmap4.c mount | grep -q "$mntpoint" && umount $mntpoint mdconfig -l | grep -q $mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 40m -u $mdstart -bsdlabel -w md${mdstart} auto +bsdlabel -w md$mdstart auto newfs $newfs_flags md${mdstart}$part > /dev/null mount /dev/md${mdstart}$part $mntpoint /tmp/mmap4 /$mntpoint/file cd $here rm -f /tmp/mmap4 while mount | grep -q $mntpoint; do sync;sync;sync sleep 1 umount $mntpoint done mdconfig -d -u $mdstart exit 0 EOF #include #include #include #include #include #include #include #include #include #include #include #define STARTADDR 0x0U #define ADRSPACE 0x06400000U /* 100 Mb */ int main(int argc, char **argv) { int fd, ps; void *p; size_t len; char *c, *path; p = (void *)STARTADDR; len = ADRSPACE; path = argv[1]; if ((fd = open(path, O_CREAT | O_TRUNC | O_RDWR, 0622)) == -1) err(1,"open()"); 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 (1); err(1, "mmap(1)"); } c = p; ps = getpagesize(); for (c = p; (void *)c < p + len; c += ps) { *c = 1; } close(fd); return (0); } Index: user/pho/stress2/misc/mount2.sh =================================================================== --- user/pho/stress2/misc/mount2.sh (revision 317637) +++ user/pho/stress2/misc/mount2.sh (revision 317638) @@ -1,82 +1,82 @@ #!/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$ # # Stress test by performing parallel calls to mount and umount. Alternate # between forced and non-forced unmounts [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg mounts=15 # Number of parallel scripts 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 && + mount | grep "$mntpoint" | grep -q md$m && umount ${mntpoint}$m mdconfig -l | grep -q md$m && mdconfig -d -u $m dd if=/dev/zero of=$D$m bs=1m count=1 > /dev/null 2>&1 mdconfig -a -t vnode -f $D$m -u $m || { rm -f $D$m; exit 1; } bsdlabel -w md$m auto - newfs md${m}${part} > /dev/null 2>&1 + 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 & done for i in `jot $mounts`; do wait done for i in `jot $mounts`; do m=$(( i + mdstart - 1 )) mdconfig -d -u $m rm -f $D$m done else # The test: Parallel mount and unmounts for i in `jot 1024`; do m=$1 opt=`[ $(( m % 2 )) -eq 0 ] && echo -f` - mount /dev/md${m}${part} ${mntpoint}$m + mount /dev/md${m}$part ${mntpoint}$m while mount | grep -q ${mntpoint}$m; do umount $opt ${mntpoint}$m > /dev/null 2>&1 done done fi Index: user/pho/stress2/misc/mountro.sh =================================================================== --- user/pho/stress2/misc/mountro.sh (revision 317637) +++ user/pho/stress2/misc/mountro.sh (revision 317638) @@ -1,68 +1,68 @@ #!/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$ # . ../default.cfg [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 D=$diskimage dede $D 1m 128 || exit -mount | grep "$mntpoint" | grep -q /md && umount -f ${mntpoint} -mdconfig -l | grep -q ${mdstart} && mdconfig -d -u $mdstart +mount | grep "$mntpoint" | grep -q /md && umount -f $mntpoint +mdconfig -l | grep -q $mdstart && mdconfig -d -u $mdstart mdconfig -a -t vnode -f $D -u $mdstart || { rm -f $D; exit 1; } -bsdlabel -w md${mdstart} auto -newfs $newfs_flags md${mdstart}${part} > /dev/null 2>&1 -mount /dev/md${mdstart}${part} $mntpoint +bsdlabel -w md$mdstart auto +newfs $newfs_flags md${mdstart}$part > /dev/null 2>&1 +mount /dev/md${mdstart}$part $mntpoint -mkdir ${mntpoint}/stressX -chmod 777 ${mntpoint}/stressX +mkdir $mntpoint/stressX +chmod 777 $mntpoint/stressX -export RUNDIR=${mntpoint}/stressX +export RUNDIR=$mntpoint/stressX export runRUNTIME=4m (cd ..; ./run.sh disk.cfg > /dev/null 2>&1) & sleep 30 for i in `jot 10`; do mount $mntpoint -u -o ro > /dev/null 2>&1 sleep 3 mount $mntpoint -u -o rw > /dev/null 2>&1 sleep 3 done df -i $mntpoint umount -f $mntpoint > /dev/null 2>&1 mdconfig -d -u $mdstart rm -f $D kill `ps -x | grep run.sh | grep -v grep | awk '{print $1}'` wait Index: user/pho/stress2/misc/mountro2.sh =================================================================== --- user/pho/stress2/misc/mountro2.sh (revision 317637) +++ user/pho/stress2/misc/mountro2.sh (revision 317638) @@ -1,57 +1,57 @@ #!/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 scenario by Matthew D. Fuller . ../default.cfg [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 D=$diskimage dede $D 1m 20 || exit -mount | grep "$mntpoint" | grep -q /md && umount -f ${mntpoint} -mdconfig -l | grep -q ${mdstart} && mdconfig -d -u $mdstart +mount | grep "$mntpoint" | grep -q /md && umount -f $mntpoint +mdconfig -l | grep -q $mdstart && mdconfig -d -u $mdstart mdconfig -a -t vnode -f $D -u $mdstart || { rm -f $D; exit 1; } -bsdlabel -w md${mdstart} auto -newfs $newfs_flags md${mdstart}${part} > /dev/null 2>&1 -mount /dev/md${mdstart}${part} $mntpoint +bsdlabel -w md$mdstart auto +newfs $newfs_flags md${mdstart}$part > /dev/null 2>&1 +mount /dev/md${mdstart}$part $mntpoint mtree -deU -f /etc/mtree/BSD.usr.dist -p $mntpoint/ >> /dev/null sync ; sync ; sync rm -rf $mntpoint/* mount -u -o ro $mntpoint umount -f $mntpoint > /dev/null 2>&1 mdconfig -d -u $mdstart Index: user/pho/stress2/misc/mountro3.sh =================================================================== --- user/pho/stress2/misc/mountro3.sh (revision 317637) +++ user/pho/stress2/misc/mountro3.sh (revision 317638) @@ -1,58 +1,58 @@ #!/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 scenario by barbara # kern/121809: unable to umount [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg D=$diskimage dede $D 1m 64 || exit 1 -mount | grep "$mntpoint" | grep md${mdstart}${part} > /dev/null && umount $mntpoint -mdconfig -l | grep md${mdstart} > /dev/null && mdconfig -d -u ${mdstart} +mount | grep "$mntpoint" | grep md${mdstart}$part > /dev/null && umount $mntpoint +mdconfig -l | grep md$mdstart > /dev/null && mdconfig -d -u $mdstart -mdconfig -a -t vnode -f $D -u ${mdstart} || { rm -f $D; exit 1; } -bsdlabel -w md${mdstart} auto -newfs $newfs_flags md${mdstart}${part} > /dev/null 2>&1 +mdconfig -a -t vnode -f $D -u $mdstart || { rm -f $D; exit 1; } +bsdlabel -w md$mdstart auto +newfs $newfs_flags md${mdstart}$part > /dev/null 2>&1 -mount /dev/md${mdstart}${part} $mntpoint +mount /dev/md${mdstart}$part $mntpoint touch $mntpoint/file umount $mntpoint -mount /dev/md${mdstart}${part} $mntpoint +mount /dev/md${mdstart}$part $mntpoint rm $mntpoint/file mount -u -o ro $mntpoint # Should fail with "Device busy" umount $mntpoint -mdconfig -d -u ${mdstart} +mdconfig -d -u $mdstart rm -f $D Index: user/pho/stress2/misc/msdos.sh =================================================================== --- user/pho/stress2/misc/msdos.sh (revision 317637) +++ user/pho/stress2/misc/msdos.sh (revision 317638) @@ -1,54 +1,54 @@ #!/bin/sh # # Copyright (c) 2008-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$ # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 # LOR seen. Fixed by r204467. . ../default.cfg [ -x /sbin/mount_msdosfs ] || exit -mount | grep "$mntpoint" | grep -q md$mdstart && umount -f ${mntpoint} -mdconfig -l | grep -q ${mdstart} && mdconfig -d -u $mdstart +mount | grep "$mntpoint" | grep -q md$mdstart && umount -f $mntpoint +mdconfig -l | grep -q $mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart -bsdlabel -w md${mdstart} auto +bsdlabel -w md$mdstart auto newfs_msdos /dev/md${mdstart}$part > /dev/null mount -t msdosfs /dev/md${mdstart}$part $mntpoint export RUNDIR=$mntpoint/stressX export runRUNTIME=10m # Run tests for 10 minutes (cd ..; ./run.sh disk.cfg) while mount | grep "$mntpoint" | grep -q md$mdstart; do umount $mntpoint || sleep 1 done fsck -t msdosfs -y /dev/md${mdstart}$part mdconfig -d -u $mdstart Index: user/pho/stress2/misc/msdos2.sh =================================================================== --- user/pho/stress2/misc/msdos2.sh (revision 317637) +++ user/pho/stress2/misc/msdos2.sh (revision 317638) @@ -1,61 +1,61 @@ #!/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$ # # panic: __lockmgr_args: recursing on non recursive lockmgr devfs @ ../../../kern/vfs_subr.c:2204 # Scenario by kib@ [ `id -u` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg [ -x /sbin/mount_msdosfs ] || exit mount | grep "$mntpoint" | grep -q md$mdstart && umount -f $mntpoint mdconfig -l | grep -q $mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart -bsdlabel -w md${mdstart} auto +bsdlabel -w md$mdstart auto newfs_msdos /dev/md${mdstart}$part > /dev/null mount -t msdosfs /dev/md${mdstart}$part $mntpoint u=$((mdstart + 1)) mdconfig -l | grep -q $u && mdconfig -d -u $u mdconfig -a -t swap -s 1g -u $u -bsdlabel -w md${u} auto +bsdlabel -w md$u auto newfs_msdos /dev/md${u}$part > /dev/null mount -u /dev/md${u}$part $mntpoint > /dev/null 2>&1 # panic ls $mntpoint > /dev/null while mount | grep "$mntpoint" | grep -q md$mdstart; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart mdconfig -d -u $u Index: user/pho/stress2/misc/msdos3.sh =================================================================== --- user/pho/stress2/misc/msdos3.sh (revision 317637) +++ user/pho/stress2/misc/msdos3.sh (revision 317638) @@ -1,55 +1,55 @@ #!/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$ # # Page fault seen # Scenario by kib@ [ `id -u` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg [ -x /sbin/mount_msdosfs ] || exit mount | grep "$mntpoint" | grep -q md$mdstart && umount -f $mntpoint mdconfig -l | grep -q $mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart -bsdlabel -w md${mdstart} auto +bsdlabel -w md$mdstart auto newfs_msdos /dev/md${mdstart}$part > /dev/null mount -t msdosfs /dev/md${mdstart}$part $mntpoint mount -t msdosfs /dev/md${mdstart}$part $mntpoint || echo OK ls $mntpoint > /dev/null while mount | grep "$mntpoint" | grep -q md$mdstart; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart Index: user/pho/stress2/misc/msdos6.sh =================================================================== --- user/pho/stress2/misc/msdos6.sh (revision 317637) +++ user/pho/stress2/misc/msdos6.sh (revision 317638) @@ -1,92 +1,92 @@ #!/bin/sh # # Copyright (c) 2016 Dell EMC Isilon # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ # # Parallel mount and umount of file systems [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg mounts=15 # Number of parallel scripts cont=/tmp/msdos6.continue mdstart=$mdstart # Use md unit numbers from this point if [ $# -eq 0 ]; then touch $cont mycc -o /tmp/fstool -Wall -Wextra -O2 ../tools/fstool.c || exit 1 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 bsdlabel -w md$m auto newfs_msdos -F 32 -b 8192 /dev/md${m}$part > /dev/null 2>&1 - mount -t msdosfs /dev/md${m}${part} ${mntpoint}$m + mount -t msdosfs /dev/md${m}$part ${mntpoint}$m (mkdir ${mntpoint}$m/test$i; cd ${mntpoint}$m/test$i; /tmp/fstool -l -f 100 -n 100 -s ${i}k) umount ${mntpoint}$m > /dev/null 2>&1 done # start the parallel tests for i in `jot $mounts`; do m=$(( i + mdstart - 1 )) ./$0 $m & ./$0 find & done wait for i in `jot $mounts`; do m=$(( i + mdstart - 1 )) mdconfig -d -u $m done rm -f /tmp/fstool else if [ $1 = find ]; then while [ -r $cont ]; do find ${mntpoint}* -type f > /dev/null 2>&1 done else # The test: Parallel mount and unmounts start=`date '+%s'` while [ $((`date '+%s'` - start)) -lt 300 ]; do m=$1 mount -t msdosfs /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 $cont fi fi Index: user/pho/stress2/misc/msdos7.sh =================================================================== --- user/pho/stress2/misc/msdos7.sh (revision 317637) +++ user/pho/stress2/misc/msdos7.sh (revision 317638) @@ -1,58 +1,58 @@ #!/bin/sh # # Copyright (c) 2016 Dell EMC Isilon # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ # # Run misc/datamove.sh on a msdos fs. # Thread waiting on "msdosfs". # https://people.freebsd.org/~pho/stress/log/kostik958.txt # Fixed by r308025. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg 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_msdos -F 32 -b 8192 /dev/md${mdstart}$part > /dev/null || exit 1 -mount -t msdosfs /dev/md${mdstart}${part} $mntpoint +mount -t msdosfs /dev/md${mdstart}$part $mntpoint here=`pwd` cd /tmp sed "1,/^EOF/d" < $here/datamove.sh > msdos7.c mycc -o msdos7 -Wall msdos7.c rm -f msdos7.c (cd $mntpoint; /tmp/msdos7) umount $mntpoint mdconfig -d -u $mdstart exit 0 Index: user/pho/stress2/misc/newfs3.sh =================================================================== --- user/pho/stress2/misc/newfs3.sh (revision 317637) +++ user/pho/stress2/misc/newfs3.sh (revision 317638) @@ -1,79 +1,79 @@ #!/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$ # # phk has seen freezes with this newfs option: "-b 32768 -f 4096 -O2" # # Deadlocks seen with this test and: # newfs -b 4096 -f 4096 -O2 md0c on a 128 Mb FS # newfs -b 4096 -f 1024 -O2 md0c on a 64 Mb FS # 20070505 newfs -b 4096 -f 4096 -O2 md0c on a 32 Mb FS: panic: lockmgr: locking against myself [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg size=$((32 * 1024 * 1024)) opt="-O2" # newfs option. Eg. -U mount | grep "$mntpoint" | grep -q md${mdstart}$part && umount $mntpoint [ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart while [ $size -le $((128 * 1024 * 1024)) ]; do mb=$((size / 1024 / 1024)) rm -f $diskimage dd if=/dev/zero of=$diskimage bs=1m count=$mb 2>&1 | egrep -v "records|transferred" mdconfig -a -t vnode -f $diskimage -u $mdstart || { rm -f $diskimage; exit 1; } bsdlabel -w md$mdstart auto blocksize=4096 while [ $blocksize -le 65536 ]; do for i in 1 2 4 8; do fragsize=$((blocksize / i)) newfs -b $blocksize -f $fragsize $opt md${mdstart}$part > \ /dev/null 2>&1 mount /dev/md${mdstart}$part $mntpoint export RUNDIR=$mntpoint/stressX export runRUNTIME=15s export RUNTIME=$runRUNTIME export CTRLDIR=$mntpoint/stressX.control (cd ..; ./run.sh disk.cfg) > /dev/null while mount | grep "$mntpoint" | \ grep -q md${mdstart}$part; do umount $mntpoint > /dev/null 2>&1 done done blocksize=$((blocksize * 2)) done - mdconfig -d -u ${mdstart} + mdconfig -d -u $mdstart size=$((size + 32 * 1024 * 1024)) done rm -f $diskimage Index: user/pho/stress2/misc/nfs2.sh =================================================================== --- user/pho/stress2/misc/nfs2.sh (revision 317637) +++ user/pho/stress2/misc/nfs2.sh (revision 317638) @@ -1,71 +1,71 @@ #!/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$ # # Test msdos over nfs. "panic: wrong diroffset" seen. # This needs to be in /etc/exports: /mnt -maproot=root 127.0.0.1 . ../default.cfg [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 grep -q $mntpoint /etc/exports || { echo "$mntpoint missing from /etc/exports"; exit 0; } [ -x /sbin/mount_msdosfs ] || exit D=$diskimage dede $D 1m 128 || exit mount | grep "${mntpoint}2" | grep nfs > /dev/null && umount -f ${mntpoint}2 -mount | grep "$mntpoint" | grep /md > /dev/null && umount -f ${mntpoint} -mdconfig -l | grep -q ${mdstart} && mdconfig -d -u $mdstart +mount | grep "$mntpoint" | grep /md > /dev/null && umount -f $mntpoint +mdconfig -l | grep -q $mdstart && mdconfig -d -u $mdstart mdconfig -a -t vnode -f $D -u $mdstart -bsdlabel -w md${mdstart} auto +bsdlabel -w md$mdstart auto newfs_msdos -F 16 -b 8192 /dev/md${mdstart}$part > /dev/null mount -t msdosfs -o rw /dev/md${mdstart}$part $mntpoint -mkdir ${mntpoint}/stressX -chmod 777 ${mntpoint}/stressX +mkdir $mntpoint/stressX +chmod 777 $mntpoint/stressX [ ! -d ${mntpoint}2 ] && mkdir ${mntpoint}2 chmod 777 ${mntpoint}2 -mount -t nfs -o tcp -o retrycnt=3 -o intr -o soft -o rw \ +mount -t nfs -o tcp -o retrycnt=3 -o intr,soft -o rw \ 127.0.0.1:$mntpoint ${mntpoint}2 export INODES=9999 # No inodes on a msdos fs export RUNDIR=${mntpoint}2/stressX export runRUNTIME=10m # Run tests for 10 minutes (cd ..; ./run.sh disk.cfg) umount -f ${mntpoint}2 > /dev/null 2>&1 umount -f $mntpoint > /dev/null 2>&1 mdconfig -d -u $mdstart rm -f $D Index: user/pho/stress2/misc/nullfs11.sh =================================================================== --- user/pho/stress2/misc/nullfs11.sh (revision 317637) +++ user/pho/stress2/misc/nullfs11.sh (revision 317638) @@ -1,97 +1,97 @@ #!/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$ # # nullfs cache / nocache benchmark [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 if [ -r ../default.cfg ]; then . ../default.cfg else mntpoint=/mnt mdstart=5 part=a fi export LANG=C CACHE=nullfs11-cache.log NOCACHE=nullfs11-nocache.log mp1=$mntpoint mp2=${mntpoint}2 [ -d $mp2 ] || mkdir $mp2 rm -f $CACHE $NOCACHE mycc -o /tmp/fstool ../tools/fstool.c test() { opt=$1 mount | grep -wq $mp2 && umount $mp2 mount | grep -wq $mp1 && umount $mp1 mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 2g -u $mdstart || exit 1 bsdlabel -w md$mdstart auto - newfs $newfs_flags md${mdstart}${part} > /dev/null + newfs $newfs_flags md${mdstart}$part > /dev/null mount /dev/md${mdstart}$part $mp1 mount -t nullfs $opt $mp1 $mp2 i=1 (mkdir $mp2/test$i; cd $mp2/test$i; /tmp/fstool -l -f 50 -n 500 -s 4k) rm -rf $mp2/test$i sync sleep 5 parallel=4 for j in `jot 5`; do s=`date '+%s'` for i in `jot $parallel`; do (mkdir $mp2/test$i; cd $mp2/test$i; \ /tmp/fstool -l -f 50 -n 500 -s $((i * 4))k) & done for i in `jot $parallel`; do wait done rm -rf $mp2/* echo $((`date '+%s'` - $s)) done while mount | grep -wq $mp2; do umount $mp2 || sleep 1 done while mount | grep $mp1 | grep -q /dev/md; do umount $mp1 || sleep 1 done mdconfig -d -u $mdstart } test "-o nocache" > $NOCACHE test "-o cache" > $CACHE ministat -s -w 60 $NOCACHE $CACHE rm -f /tmp/fstool $CACHE $NOCACHE Index: user/pho/stress2/misc/pfl.sh =================================================================== --- user/pho/stress2/misc/pfl.sh (revision 317637) +++ user/pho/stress2/misc/pfl.sh (revision 317638) @@ -1,185 +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" & +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/quota1.sh =================================================================== --- user/pho/stress2/misc/quota1.sh (revision 317637) +++ user/pho/stress2/misc/quota1.sh (revision 317638) @@ -1,59 +1,59 @@ #!/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$ # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 # Causes this: panic: mutex Giant not owned at ../../../kern/vfs_subr.c:1968 # with a kernel compiled with "options QUOTA". # This is not really a quota test. . ../default.cfg D=$diskimage trap "rm -f $D" 0 dede $D 1m 128 || exit 1 mount | grep "$mntpoint" | grep md${mdstart}$part > /dev/null && umount $mntpoint mdconfig -l | grep md$mdstart > /dev/null && mdconfig -d -u $mdstart mdconfig -a -t vnode -f $D -u $mdstart bsdlabel -w md$mdstart auto newfs $newfs_flags md${mdstart}$part > /dev/null mount /dev/md${mdstart}$part $mntpoint -export RUNDIR=${mntpoint}/stressX +export RUNDIR=$mntpoint/stressX export runRUNTIME=10m # Run tests for 10 minutes (cd ..; ./run.sh disk.cfg) while mount | grep -q $mntpoint; do umount $mntpoint > /dev/null 2>&1 || sleep 1 done mdconfig -d -u $mdstart rm -f $D exit 0 Index: user/pho/stress2/misc/quota10.sh =================================================================== --- user/pho/stress2/misc/quota10.sh (revision 317637) +++ user/pho/stress2/misc/quota10.sh (revision 317638) @@ -1,106 +1,106 @@ #!/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 # "panic: dqsync: file" seen: # https://people.freebsd.org/~pho/stress/log/quota10.txt [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 [ "`sysctl -in kern.features.ufs_quota`" != "1" ] && exit 0 . ../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 [ -c /dev/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 + 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 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 200`; do m=$1 opt=`[ $(( m % 2 )) -eq 0 ] && echo -f` - mount $opt /dev/md${m}${part} ${mntpoint}$m + 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 exit 0 Index: user/pho/stress2/misc/quota2.sh =================================================================== --- user/pho/stress2/misc/quota2.sh (revision 317637) +++ user/pho/stress2/misc/quota2.sh (revision 317638) @@ -1,59 +1,59 @@ #!/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$ # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 [ "`sysctl -in kern.features.ufs_quota`" != "1" ] && exit 0 . ../default.cfg D=$diskimage export PATH_FSTAB=/tmp/fstab trap "rm -f $D $PATH_FSTAB" 0 dede $D 1m 128 || exit 1 mount | grep "$mntpoint" | grep md${mdstart}$part > /dev/null && umount $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mdconfig -a -t vnode -f $D -u $mdstart bsdlabel -w md$mdstart auto newfs $newfs_flags md${mdstart}$part > /dev/null echo "/dev/md${mdstart}$part $mntpoint ufs rw,userquota 2 2" > $PATH_FSTAB -mount ${mntpoint} +mount $mntpoint edquota -u -f $mntpoint -e $mntpoint:100000:110000:15000:16000 root quotacheck $mntpoint quotaon $mntpoint -export RUNDIR=${mntpoint}/stressX +export RUNDIR=$mntpoint/stressX export runRUNTIME=10m # Run tests for 10 minutes (cd ..; ./run.sh disk.cfg) 2>/dev/null while mount | grep $mntpoint | grep -q /dev/md; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart exit 0 Index: user/pho/stress2/misc/quota3.sh =================================================================== --- user/pho/stress2/misc/quota3.sh (revision 317637) +++ user/pho/stress2/misc/quota3.sh (revision 317638) @@ -1,59 +1,59 @@ #!/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$ # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 [ "`sysctl -in kern.features.ufs_quota`" != "1" ] && exit 0 . ../default.cfg D=$diskimage export PATH_FSTAB=/tmp/fstab trap "rm -f $D $PATH_FSTAB" 0 dede $D 1m 1k || exit 1 -mount | grep "${mntpoint}" | grep -q md${mdstart}$part && umount ${mntpoint} +mount | grep "$mntpoint" | grep -q md${mdstart}$part && umount $mntpoint mdconfig -l | grep md$mdstart > /dev/null && mdconfig -d -u $mdstart mdconfig -a -t vnode -f $D -u $mdstart bsdlabel -w md$mdstart auto newfs $newfs_flags md${mdstart}$part > /dev/null echo "/dev/md${mdstart}$part $mntpoint ufs rw,userquota 2 2" > $PATH_FSTAB -mount ${mntpoint} +mount $mntpoint edquota -u -f $mntpoint -e $mntpoint:850000:900000:130000:140000 root quotacheck $mntpoint quotaon $mntpoint mksnap_ffs $mntpoint $mntpoint/.snap/stress2 export RUNDIR=$mntpoint/stressX export runRUNTIME=10m # Run tests for 10 minutes (cd ..; ./run.sh disk.cfg) while mount | grep $mntpoint | grep -q /dev/md; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart Index: user/pho/stress2/misc/quota4.sh =================================================================== --- user/pho/stress2/misc/quota4.sh (revision 317637) +++ user/pho/stress2/misc/quota4.sh (revision 317638) @@ -1,67 +1,67 @@ #!/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 [ "`sysctl -in kern.features.ufs_quota`" != "1" ] && exit 0 # Has shown a deadlock after 7 hours of testing # https://people.freebsd.org/~pho/stress/log/quota4.txt . ../default.cfg D=$diskimage trap "rm -f $D" 0 dede $D 1m 1k || exit 1 mount | grep "$mntpoint" | grep md${mdstart}$part > /dev/null && umount \ $mntpoint -mdconfig -l | grep md${mdstart} > /dev/null && mdconfig -d -u ${mdstart} +mdconfig -l | grep md$mdstart > /dev/null && mdconfig -d -u $mdstart -mdconfig -a -t vnode -f $D -u ${mdstart} -bsdlabel -w md${mdstart} auto +mdconfig -a -t vnode -f $D -u $mdstart +bsdlabel -w md$mdstart auto newfs $newfs_flags md${mdstart}$part > /dev/null echo "/dev/md${mdstart}$part $mntpoint ufs rw,userquota 2 2" >> \ /etc/fstab mount $mntpoint edquota -u -f $mntpoint -e ${mntpoint}:850000:900000:130000:140000 root \ > /dev/null 2>&1 quotaon $mntpoint -sed -i -e "/md${mdstart}${part}/d" /etc/fstab # clean up before any panics -export RUNDIR=${mntpoint}/stressX +sed -i -e "/md${mdstart}$part/d" /etc/fstab # clean up before any panics +export RUNDIR=$mntpoint/stressX ../testcases/rw/rw -t 2m -i 200 -h -n 2>/dev/null & sleep 60 false while mount | grep -q $mntpoint; do umount $([ $((`date '+%s'` % 2)) -eq 0 ] && echo "-f" || echo "") \ $mntpoint > /dev/null 2>&1 done -mdconfig -d -u ${mdstart} +mdconfig -d -u $mdstart rm -f $D exit 0 Index: user/pho/stress2/misc/quota7.sh =================================================================== --- user/pho/stress2/misc/quota7.sh (revision 317637) +++ user/pho/stress2/misc/quota7.sh (revision 317638) @@ -1,81 +1,81 @@ #!/bin/sh # # Copyright (c) 2008 Peter Holm # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ # # Quota / snapshot test scenario by Kris@ # Causes spin in ffs_sync or panic in panic: vfs_allocate_syncvnode: insmntque failed [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 [ "`sysctl -in kern.features.ufs_quota`" != "1" ] && exit 0 . ../default.cfg D=$diskimage trap "rm -f $D" 0 dd if=/dev/zero of=$D bs=1m count=1k 2>&1 | egrep -v "records|transferred" mount | grep $mntpoint | grep -q md$mdstart && umount -f $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mdconfig -a -t vnode -f $D -u $mdstart bsdlabel -w md$mdstart auto newfs $newfs_flags md${mdstart}$part > /dev/null export PATH_FSTAB=/tmp/fstab -echo "/dev/md${mdstart}${part} $mntpoint ufs rw,userquota 2 2" > $PATH_FSTAB +echo "/dev/md${mdstart}$part $mntpoint ufs rw,userquota 2 2" > $PATH_FSTAB mount $mntpoint set `df -ik $mntpoint | tail -1 | awk '{print $4,$7}'` export KBLOCKS=$(($1 / 21)) export INODES=$(($2 / 21)) export HOG=1 export INCARNATIONS=40 export QK=$((KBLOCKS / 2)) export QI=$((INODES / 2)) edquota -u -f $mntpoint -e $mntpoint:$((QK - 50)):$QK:$((QI - 50 )):$QI $testuser quotaon $mntpoint export RUNDIR=$mntpoint/stressX mkdir $mntpoint/stressX chmod 777 $mntpoint/stressX rm -rf /tmp/stressX.control/* su $testuser -c "(cd ..;runRUNTIME=30m ./run.sh disk.cfg)"& # panic: vfs_allocate_syncvnode: insmntque failed for i in `jot 20`; do echo "`date '+%T'` mksnap_ffs $mntpoint $mntpoint/.snap/snap$i" mksnap_ffs $mntpoint $mntpoint/.snap/snap$i sleep 1 done i=$(($(date '+%S') % 20 + 1)) echo "rm -f $mntpoint/.snap/snap$i" rm -f $mntpoint/.snap/snap$i wait while mount | grep -q $mntpoint; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart rm -f $D $PATH_FSTAB Index: user/pho/stress2/misc/quota8.sh =================================================================== --- user/pho/stress2/misc/quota8.sh (revision 317637) +++ user/pho/stress2/misc/quota8.sh (revision 317638) @@ -1,91 +1,91 @@ #!/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$ # # Quota / snapshot test scenario by Kris@ # Causes spin in ffs_sync or panic in panic: vfs_allocate_syncvnode: # insmntque failed # "Fatal double fault" seen when compiling selected files # with "-O0" on i386: # https://people.freebsd.org/~pho/stress/log/quota8.txt [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 [ "`sysctl -in kern.features.ufs_quota`" != "1" ] && exit 0 . ../default.cfg D=$diskimage trap "rm -f $D" 0 dede $D 1m 1k || exit 1 mount | grep "$mntpoint" | grep -q md$mdstart && umount -f $mntpoint [ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart mdconfig -a -t vnode -f $D -u $mdstart bsdlabel -w md$mdstart auto newfs $newfs_flags md${mdstart}$part > /dev/null echo "/dev/md${mdstart}$part $mntpoint ufs rw,userquota 2 2" >> \ /etc/fstab mount $mntpoint set `df -ik $mntpoint | tail -1 | awk '{print $4,$7}'` export KBLOCKS=$(($1 / 21)) export INODES=$(($2 / 21)) export HOG=1 export INCARNATIONS=40 export QK=$((KBLOCKS / 2)) export QI=$((INODES / 2)) edquota -u -f $mntpoint -e ${mntpoint}:$((QK - 50)):$QK:$((QI - 50 )):$QI \ $testuser quotaon $mntpoint sed -i -e "/md${mdstart}$part/d" /etc/fstab -export RUNDIR=${mntpoint}/stressX -mkdir ${mntpoint}/stressX -chmod 777 ${mntpoint}/stressX +export RUNDIR=$mntpoint/stressX +mkdir $mntpoint/stressX +chmod 777 $mntpoint/stressX su $testuser -c 'sh -c "(cd ..;runRUNTIME=20m ./run.sh disk.cfg > \ /dev/null 2>&1)"&' for i in `jot 20`; do - echo "`date '+%T'` mksnap_ffs $mntpoint ${mntpoint}/.snap/snap$i" - mksnap_ffs $mntpoint ${mntpoint}/.snap/snap$i + echo "`date '+%T'` mksnap_ffs $mntpoint $mntpoint/.snap/snap$i" + mksnap_ffs $mntpoint $mntpoint/.snap/snap$i sleep 1 done # Remove random snapshot file i=$((`date +%S` % 20 + 1)) -echo "rm -f ${mntpoint}/.snap/snap$i" -rm -f ${mntpoint}/.snap/snap$i +echo "rm -f $mntpoint/.snap/snap$i" +rm -f $mntpoint/.snap/snap$i wait su $testuser -c 'sh -c "../tools/killall.sh"' while mount | grep -q $mntpoint; do umount $([ $((`date '+%s'` % 2)) -eq 0 ] && echo "-f" || echo "") \ $mntpoint > /dev/null 2>&1 done mdconfig -d -u $mdstart exit 0 Index: user/pho/stress2/misc/quota9.sh =================================================================== --- user/pho/stress2/misc/quota9.sh (revision 317637) +++ user/pho/stress2/misc/quota9.sh (revision 317638) @@ -1,92 +1,92 @@ #!/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 if quotacheck reports actual usage . ../default.cfg export tmp=/tmp/$(basename $0).$$ export D=$diskimage qc() { quotacheck -v $1 > $tmp 2>&1 grep -q fixed $tmp && cat $tmp } if [ $# -eq 0 ]; then trap "rm -f $D $tmp" 0 [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 [ "`sysctl -in kern.features.ufs_quota`" != "1" ] && exit 0 dede $D 1m 50 || exit 1 mount | grep "$mntpoint" | grep -q md$mdstart && umount -f $mntpoint [ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart mdconfig -a -t vnode -f $D -u $mdstart bsdlabel -w md$mdstart auto newfs $newfs_flags md${mdstart}$part > /dev/null echo "/dev/md${mdstart}$part $mntpoint ufs rw,userquota 2 2" \ >> /etc/fstab mount $mntpoint - mkdir ${mntpoint}/stressX - chown $testuser ${mntpoint}/stressX + mkdir $mntpoint/stressX + chown $testuser $mntpoint/stressX set `df -ik $mntpoint | tail -1 | awk '{print $4,$7}'` export KBLOCKS=$1 export INODES=$2 export QK=$((KBLOCKS / 2)) export QI=$((INODES / 2)) edquota -u -f $mntpoint -e \ ${mntpoint}:$((QK - 50)):$QK:$((QI - 50 )):$QI $testuser > \ /dev/null 2>&1 quotaon $mntpoint qc $mntpoint - su ${testuser} $0 xxx + su $testuser $0 xxx du -k /mnt/stressX qc $mntpoint - sed -i -e "/md${mdstart}${part}/d" /etc/fstab + sed -i -e "/md${mdstart}$part/d" /etc/fstab while mount | grep -q $mntpoint; do umount $([ $((`date '+%s'` % 2)) -eq 0 ] && echo "-f" || echo "") $mntpoint > /dev/null 2>&1 done mdconfig -d -u $mdstart rm -f $D else for i in `jot 20`; do dede $mntpoint/stressX/d$i 1m 1 done fi exit 0 Index: user/pho/stress2/misc/rename11.sh =================================================================== --- user/pho/stress2/misc/rename11.sh (revision 317637) +++ user/pho/stress2/misc/rename11.sh (revision 317638) @@ -1,139 +1,139 @@ #!/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$ # # SU problem with "mkdir(d.008740.000987): Too many links" seen. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > rename11.c mycc -o rename11 -Wall -Wextra rename11.c || exit 1 rm -f rename11.c mount | grep "on $mntpoint " | grep -q /dev/md && umount -f $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 2g -u $mdstart || exit 1 bsdlabel -w md$mdstart auto #newfs md${mdstart}$part > /dev/null # No problems seen without SU newfs $newfs_flags md${mdstart}$part > /dev/null mount /dev/md${mdstart}$part $mntpoint -mkdir ${mntpoint}/dir +mkdir $mntpoint/dir ( - cd ${mntpoint}/dir + cd $mntpoint/dir /tmp/rename11 || echo FAIL ) while mount | grep "on $mntpoint " | grep -q /dev/md; do umount $mntpoint || sleep 1 done checkfs /dev/md${mdstart}$part mdconfig -d -u $mdstart rm -rf /tmp/rename11 exit 0 EOF #include #include #include #include #include #include #include #include #include #include #define LOOPS 10 #define PARALLEL 3 #define ND 5000 void check(char *name) { struct stat sb; if (stat(name, &sb) == -1) warn("stat(%s)", name); else warnx("stat(%s) succeeded!", name); } void dirs(void) { pid_t pid; int i, j; char name[80], to[80]; pid = getpid(); for (j = 0; j < LOOPS; j++) { for (i = 0; i < ND; i++) { snprintf(name, sizeof(name), "d.%06d.%06d", pid, i); if (mkdir(name, 0700) == -1) err(1, "mkdir(%s)", name); snprintf(to , sizeof(to ), "d2.%06d.%06d", pid, i); if (rename(name, to) == -1) warn("rename(%s, %s)", name, to); if (rename(to, name) == -1) warn("rename(%s, %s)", to, name); if (rmdir(name) == -1) { check(name); err(1, "rmdir(%s)", name); } } } _exit(0); } int main(void) { int i, r, s; r = 0; for (i = 0; i < PARALLEL; i++) { if (fork() == 0) dirs(); } for (i = 0; i < PARALLEL; i++) { wait(&s); r += WEXITSTATUS(s); } return (r); } Index: user/pho/stress2/misc/rename3.sh =================================================================== --- user/pho/stress2/misc/rename3.sh (revision 317637) +++ user/pho/stress2/misc/rename3.sh (revision 317638) @@ -1,53 +1,53 @@ #!/bin/sh # # Copyright (c) 2009 Peter Holm # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ # # Test vulnerability to transient failures when a directory closer # to the root directory is renamed # Deadlocks seen: # https://people.freebsd.org/~pho/stress/log/kostik447.txt # https://people.freebsd.org/~pho/stress/log/kirk058.txt # Test scenario by Tor Egge root=/tmp for i in `jot 10000`; do - rm -rf ${root}/a - mkdir -p ${root}/a/b/c/d/e/f/g - mkdir -p ${root}/a/b/c/d/e/f/z - cd ${root}/a/b/c/d/e/f - ( mv ${root}/a/b/c ${root}/a/c ) & + rm -rf $root/a + mkdir -p $root/a/b/c/d/e/f/g + mkdir -p $root/a/b/c/d/e/f/z + cd $root/a/b/c/d/e/f + ( mv $root/a/b/c $root/a/c ) & if ! mv z g/z; then echo "FAILURE at loop $i" break fi wait done -rm -rf ${root}/a +rm -rf $root/a Index: user/pho/stress2/misc/rename5.sh =================================================================== --- user/pho/stress2/misc/rename5.sh (revision 317637) +++ user/pho/stress2/misc/rename5.sh (revision 317638) @@ -1,140 +1,140 @@ #!/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$ # # Rename scenario from kern/156545 by Konstantin, # konstantin malov kaspersky com # On 8.2-STABLE fsck reports # "xxx IS AN EXTRANEOUS HARD LINK TO DIRECTORY yyy" # Fixed by r220986 [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg mount | grep -q "$mntpoint" && umount $mntpoint mdconfig -l | grep -q $mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart -bsdlabel -w md${mdstart} auto +bsdlabel -w md$mdstart auto newfs $newfs_flags md${mdstart}$part > /dev/null mount /dev/md${mdstart}$part $mntpoint here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > rename5.c mycc -o rename5 -Wall -Wextra -O2 rename5.c rm -f rename5.c cd $mntpoint /tmp/rename5 cd $here rm -f /tmp/rename5 while mount | grep -q md${mdstart}$part; do umount $mntpoint || sleep 1 done checkfs /dev/md${mdstart}$part mdconfig -d -u $mdstart exit 0 EOF #include #include #include #include #include #include #include #include #define N 1000 #define RUNTIME (5 * 60) void test(void) { pid_t pid; int i; char from[128], to[128]; pid = getpid(); for (i = 0; i < N; i++) { snprintf(from, sizeof(from), "src/dir.%06d", i); snprintf(to , sizeof(to), "src/dir.%06d.%06d", i, pid); (void)rename(from, to); } _exit(0); } int main() { time_t start; int fd, i; char dir[128], file[128]; start = time(NULL); while (time(NULL) - start < RUNTIME) { if (mkdir("src", 0700) == -1) err(1, "mkdir(src)"); for (i = 0; i < N; i++) { snprintf(dir, sizeof(dir), "src/dir.%06d", i); if (mkdir(dir, 0700) == -1) err(1, "mkdir(%s)", dir); snprintf(file, sizeof(file), "%s/meta", dir); if ((fd = open(file, O_RDWR | O_CREAT, 0600)) < 0) err(1, "open(%s)", file); close(fd); snprintf(file, sizeof(file), "%s/data", dir); if ((fd = open(file, O_RDWR | O_CREAT, 0600)) < 0) err(1, "open(%s)", file); close(fd); } for (i = 0; i < 2; i++) { if (fork() == 0) test(); } for (i = 0; i < 2; i++) wait(NULL); system("rm -rf src > /dev/null 2>&1"); } return (0); } Index: user/pho/stress2/misc/rename6.sh =================================================================== --- user/pho/stress2/misc/rename6.sh (revision 317637) +++ user/pho/stress2/misc/rename6.sh (revision 317638) @@ -1,150 +1,150 @@ #!/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$ # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 # Demonstrate rename(2) cache problem, where the original name lingers in the VFS cache. # Original test scenario by Anton Yuzhaninov . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > rename6.c mycc -o rename6 -Wall -Wextra -O2 rename6.c rm -f rename6.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/rename6" +su $testuser -c "cd $mntpoint; /tmp/rename6" while mount | grep -q md${mdstart}$part; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart rm -f /tmp/rename6 exit EOF #include #include #include #include #include #include #include #include #include #include #include #include #include #include pid_t spid; const char *logfile = "test.log"; void cleanup() { kill(spid, SIGINT); } static void Stat() { struct stat sb; int i; setproctitle("Stat"); for (;;) { for (i = 0; i < 1000; i++) { stat(logfile, &sb); } usleep(1000); } } int main(void) { struct stat sb1, sb2; int fd, i; char new[128]; if ((spid = fork()) == 0) Stat(); setproctitle("main"); atexit(cleanup); for (i = 0; i < 20000; i++) { sprintf(new, "test.log.%05d", i); if ((fd = open(logfile, O_RDWR | O_CREAT | O_TRUNC, 0644)) == -1) err(1, "creat(%s)", logfile); close(fd); #if 1 if (rename(logfile, new) == -1) warn("rename(%s, %s)", logfile, new); #else /* No cache problem is seen */ if (link(logfile, new) == -1) err(1, "link(%s, %s)", logfile, new); if (unlink(logfile) == -1) err(1, "unlink(%s)", logfile); #endif /* * stat() for logfile and new will be identical sometimes, * but only when Stat() is running. */ if (stat(logfile, &sb1) == 0 && stat(new, &sb2) == 0 && bcmp(&sb1, &sb2, sizeof(sb1)) == 0) { fprintf(stderr, "At loop #%d\n", i); fprintf(stderr, "%-15s: ino = %ju, nlink = %ju," " size = %jd\n", logfile, (uintmax_t)sb1.st_ino, (uintmax_t)sb1.st_nlink, sb1.st_blocks); fprintf(stderr, "%-15s: ino = %ju, nlink = %ju, " "size = %jd\n", new , (uintmax_t)sb2.st_ino, (uintmax_t)sb2.st_nlink, sb2.st_blocks); } unlink(new); } kill(spid, SIGINT); wait(NULL); return (0); } Index: user/pho/stress2/misc/rename7.sh =================================================================== --- user/pho/stress2/misc/rename7.sh (revision 317637) +++ user/pho/stress2/misc/rename7.sh (revision 317638) @@ -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" +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 -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/rename8.sh =================================================================== --- user/pho/stress2/misc/rename8.sh (revision 317637) +++ user/pho/stress2/misc/rename8.sh (revision 317638) @@ -1,175 +1,175 @@ #!/bin/sh # # Copyright (c) 2011 Peter Holm # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $FreeBSD$ # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 # Cache inconsistency seen on "to" file for rename(2). # Scenario by jhb@ . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > rename8.c mycc -o rename8 -Wall -Wextra -O2 rename8.c rm -f rename8.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; mkdir r; /tmp/rename8 r" +su $testuser -c "cd $mntpoint; mkdir r; /tmp/rename8 r" ls -li $mntpoint/r | egrep -v "^total" for i in `jot 10`; do mount | grep -q md${mdstart}$part && \ umount $mntpoint && mdconfig -d -u $mdstart && break sleep 1 done if mount | grep -q md${mdstart}$part; then fuser $mntpoint echo "umount $mntpoint failed" exit 1 fi mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart rm -f /tmp/rename8 exit EOF #include #include #include #include #include #include #include #include #include #include static char *always, *file1, *file2; static ino_t always_ino; static void usage(void) { fprintf(stderr, "Usage: rename_race \n"); exit(1); } static void child(void) { struct stat sb; /* Exit as soon as our parent exits. */ while (getppid() != 1) { stat(file1, &sb); } exit(0); } static void create_file(const char *path) { int fd; fd = open(path, O_CREAT, 0666); if (fd < 0) err(1, "open(%s)", path); close(fd); } int main(int ac, char **av) { struct stat sb, sb2; pid_t pid; int i, r; if (ac != 2) usage(); if (stat(av[1], &sb) != 0) err(1, "stat(%s)", av[1]); if (!S_ISDIR(sb.st_mode)) errx(1, "%s not a directory", av[1]); asprintf(&always, "%s/file.always", av[1]); asprintf(&file1, "%s/file1", av[1]); asprintf(&file2, "%s/file2", av[1]); create_file(always); if (stat(always, &sb) != 0) err(1, "stat(%s)", always); always_ino = sb.st_ino; pid = fork(); if (pid < 0) err(1, "fork"); if (pid == 0) child(); r = 0; for (i = 0; i < 100000; i++) { if (unlink(file1) < 0 && errno != ENOENT) err(1, "unlink(%s)", file1); if (link(always, file1) < 0) err(1, "link(%s, %s)", always, file1); create_file(file2); if (stat(file2, &sb2) < 0) err(1, "stat(%s)", file2); if (rename(file2, file1) < 0) err(1, "rename(%s, %s)", file2, file1); if (stat(file1, &sb) < 0) err(1, "stat(%s)", file1); if (sb.st_ino != sb2.st_ino || sb.st_ino == always_ino) { printf("FAIL. Bad stat: always: %ju file1: %ju (should be %ju)\n", (uintmax_t)always_ino, (uintmax_t)sb.st_ino, (uintmax_t)sb2.st_ino); r = EXIT_FAILURE; break; } } kill(pid, SIGINT); wait(NULL); if (r == 0) { unlink(always); unlink(file1); unlink(file2); } return (r); } Index: user/pho/stress2/misc/rename9.sh =================================================================== --- user/pho/stress2/misc/rename9.sh (revision 317637) +++ user/pho/stress2/misc/rename9.sh (revision 317638) @@ -1,171 +1,171 @@ #!/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 # Variation of rename6.sh. Cache problem of "to" file name seen. . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > rename9.c mycc -o rename9 -Wall -Wextra -O2 rename9.c rm -f rename9.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 rm -rf $mntpoint/.snap chmod 777 $mntpoint (while true; do ls -lRi $mntpoint > /dev/null 2>&1; done) & -su ${testuser} -c "cd $mntpoint; /tmp/rename9" +su $testuser -c "cd $mntpoint; /tmp/rename9" kill $! > /dev/null 2>&1 wait ls -ilR $mntpoint | egrep -v "^total " while mount | grep -q md${mdstart}$part; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart rm -f /tmp/rename9 exit EOF #include #include #include #include #include #include #include #include #include #include #include #include #include #include pid_t spid; char *fromFile = "fromFile.log"; char toFile[128]; void cleanup() { kill(spid, SIGINT); } static void statFrom() { struct stat sb; setproctitle("Stat"); for (;;) { stat(fromFile, &sb); } } int main(void) { struct stat fb, tb, fa, ta; int fd, i; if ((spid = fork()) == 0) statFrom(); setproctitle("main"); atexit(cleanup); for (i = 0;i < 100000; i++) { bzero(&fb, sizeof(fb)); bzero(&tb, sizeof(tb)); bzero(&fa, sizeof(fa)); bzero(&ta, sizeof(ta)); if ((fd = open(fromFile, O_RDWR | O_CREAT | O_TRUNC, 0644)) == -1) err(1, "creat(%s)", fromFile); close(fd); sprintf(toFile, "toFile.log.%05d", i); if ((fd = open(toFile, O_RDWR | O_CREAT | O_TRUNC, 0644)) == -1) err(1, "creat(%s)", toFile); write(fd, "xxx", 3); close(fd); stat(fromFile, &fb); stat(toFile, &tb); if (rename(fromFile, toFile) == -1) warn("rename(%s, %s)", fromFile, toFile); stat(fromFile, &fa); if (stat(toFile, &ta) == -1) err(1, "stat(%s)", toFile); if (tb.st_ino == ta.st_ino) { fprintf(stderr, "FAIL: old and new \"To\" inode " "number is identical\n"); fprintf(stderr, "stat() before the rename():\n"); fprintf(stderr, "%-16s: ino = %4ju, nlink = %ju, size = %jd\n", fromFile, (uintmax_t)fb.st_ino, (uintmax_t)fb.st_nlink, fb.st_blocks); fprintf(stderr, "%-16s: ino = %4ju, nlink = %ju, size = %jd\n", toFile, (uintmax_t)tb.st_ino, (uintmax_t)tb.st_nlink, tb.st_blocks); fprintf(stderr, "\nstat() after the rename():\n"); if (fa.st_ino != 0) fprintf(stderr, "%-16s: ino = %4ju, nlink = %ju, size = " "%jd\n", fromFile, (uintmax_t)fa.st_ino, (uintmax_t)fa.st_nlink, fa.st_blocks); fprintf(stderr, "%-16s: ino = %4ju, nlink = %ju, size = %jd\n", toFile, (uintmax_t)ta.st_ino, (uintmax_t)ta.st_nlink, ta.st_blocks); kill(spid, SIGINT); exit(1); } unlink(toFile); } kill(spid, SIGINT); wait(NULL); return (0); } Index: user/pho/stress2/misc/snap2.sh =================================================================== --- user/pho/stress2/misc/snap2.sh (revision 317637) +++ user/pho/stress2/misc/snap2.sh (revision 317638) @@ -1,62 +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 be root!" && exit 1 # Regression test: Delete an active md device # # panic(c088cd33,deadc000,c0943aa0,0,c08753e1) at panic+0x14b # vm_fault(c1060000,deadc000,1,0,c54de480) at vm_fault+0x1e0 # trap_pfault(e76728b8,0,deadc112) at trap_pfault+0x137 # trap(8,c0870028,28,deadc0de,deadc0de) at trap+0x355 # calltrap() at calltrap+0x5 # --- trap 0xc, eip = 0xc060bcfb, esp = 0xe76728f8, ebp = 0xe767291c --- # g_io_request(c53ff7bc,c5051d40,d8c72408,c54ca110,e7672950) at g_io_request+0x5f . ../default.cfg mount | grep -q "on /tmp (ufs," || exit 0 rm -f /tmp/.snap/stress2 trap "rm -f /tmp/.snap/stress2" 0 -mount | grep "${mntpoint}" | grep -q md${mdstart} && umount -f ${mntpoint} -mdconfig -l | grep -q md${mdstart} && mdconfig -d -u ${mdstart} +mount | grep "$mntpoint" | grep -q md$mdstart && umount -f $mntpoint +mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mksnap_ffs /tmp /tmp/.snap/stress2 mdconfig -a -t vnode -f /tmp/.snap/stress2 -u $mdstart -o readonly -mount -r /dev/md${mdstart} ${mntpoint} +mount -r /dev/md$mdstart $mntpoint ls -lR > /dev/null 2>&1 & mdconfig -d -u $mdstart > /dev/null 2>&1 -umount ${mntpoint} > /dev/null 2>&1 -umount -f ${mntpoint} > /dev/null 2>&1 +umount $mntpoint > /dev/null 2>&1 +umount -f $mntpoint > /dev/null 2>&1 mdconfig -d -u $mdstart rm -f /tmp/.snap/stress2 wait Index: user/pho/stress2/misc/snap8.sh =================================================================== --- user/pho/stress2/misc/snap8.sh (revision 317637) +++ user/pho/stress2/misc/snap8.sh (revision 317638) @@ -1,94 +1,94 @@ #!/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$ # # Deadlock seen when deleting the snapshots during an "ls" of the FS # Based on test scenario by John Kozubik # kern/94769: [ufs] Multiple file deletions on multi-snapshotted filesystems # causes hang [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg mount | grep -q /dev/md${mdstart}$part && umount -f /dev/md${mdstart}$part -mdconfig -l | grep -q md${mdstart} && mdconfig -d -u $mdstart +mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart parallel=20 size=25 # Gb [ `df -k $(dirname $diskimage) | tail -1 | awk '{print $4'}` -lt $((size * 1024 * 1024)) ] && \ echo "Not enough disk space." && exit 1 truncate -s ${size}G $diskimage mdconfig -a -t vnode -f $diskimage -u $mdstart bsdlabel -w md$mdstart auto -newfs -O2 $newfs_flags md${mdstart}${part} > /dev/null -mount /dev/md${mdstart}${part} $mntpoint +newfs -O2 $newfs_flags md${mdstart}$part > /dev/null +mount /dev/md${mdstart}$part $mntpoint mycc -o /tmp/fstool -Wall ../tools/fstool.c for i in `jot $parallel`; do (mkdir $mntpoint/test$i; cd $mntpoint/test$i; /tmp/fstool -l -f 50 -n 500 -s 8k) & done for i in `jot $parallel`; do wait done rm -f /tmp/fstool mksnap_ffs $mntpoint $mntpoint/.snap/snap1 mksnap_ffs $mntpoint $mntpoint/.snap/snap2 mksnap_ffs $mntpoint $mntpoint/.snap/snap3 mksnap_ffs $mntpoint $mntpoint/.snap/snap4 mksnap_ffs $mntpoint $mntpoint/.snap/snap5 mksnap_ffs $mntpoint $mntpoint/.snap/snap6 mksnap_ffs $mntpoint $mntpoint/.snap/snap7 mksnap_ffs $mntpoint $mntpoint/.snap/snap8 mksnap_ffs $mntpoint $mntpoint/.snap/snap9 for i in `jot $parallel`; do rm -rf $mntpoint/test$i & done for i in `jot $parallel`; do wait done rm -rf $mntpoint/.snap/snap? & for i in `jot 10`; do ls -lsrt $mntpoint > /dev/null 2>&1 sleep 2 done wait umount /dev/md${mdstart}$part mount | grep -q /dev/md${mdstart}$part && umount -f /dev/md${mdstart}$part -mdconfig -l | grep -q md${mdstart} && mdconfig -d -u $mdstart +mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart rm -f $diskimage Index: user/pho/stress2/misc/softupdate.sh =================================================================== --- user/pho/stress2/misc/softupdate.sh (revision 317637) +++ user/pho/stress2/misc/softupdate.sh (revision 317638) @@ -1,60 +1,60 @@ #!/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$ # # Like the symlink.sh test, this test shows the problem with Soft Update and # incorrect statfs(2). [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg RUNTIME=2m runRUNTIME=2m -RUNDIR=${mntpoint}/stressX +RUNDIR=$mntpoint/stressX D=$diskimage dede $D 1m 512 || exit 1 -mount | grep "$mntpoint" | grep md${mdstart} > /dev/null && umount $mntpoint -mdconfig -l | grep md${mdstart} > /dev/null && mdconfig -d -u ${mdstart} +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} +mdconfig -a -t vnode -f $D -u $mdstart for mode in "" "-U"; do printf "newfs -O2 $mode /dev/md${mdstart}\n\n" - newfs -O2 $mode /dev/md${mdstart} > /dev/null 2>&1 - mount /dev/md${mdstart} ${mntpoint} + newfs -O2 $mode /dev/md$mdstart > /dev/null 2>&1 + mount /dev/md$mdstart $mntpoint for i in `jot 5`; do (cd ..;./run.sh disk.cfg) done - umount -f ${mntpoint} + umount -f $mntpoint done mdconfig -d -u $mdstart Index: user/pho/stress2/misc/suj10.sh =================================================================== --- user/pho/stress2/misc/suj10.sh (revision 317637) +++ user/pho/stress2/misc/suj10.sh (revision 317638) @@ -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" +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.? /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/suj18.sh =================================================================== --- user/pho/stress2/misc/suj18.sh (revision 317637) +++ user/pho/stress2/misc/suj18.sh (revision 317638) @@ -1,70 +1,70 @@ #!/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$ # # SUJ and quota test scenario. # "panic: check_inode_unwritten: busy inode" seen. # Deadlock seen: # https://people.freebsd.org/~pho/stress/log/suj18.txt # Fixed by r305594. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 [ "`sysctl -in kern.features.ufs_quota`" != "1" ] && exit 0 . ../default.cfg mount | grep "$mntpoint" | grep -q md$mdstart && umount $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart -mdconfig -a -t swap -s 1g -u ${mdstart} +mdconfig -a -t swap -s 1g -u $mdstart bsdlabel -w md$mdstart auto newfs -j md${mdstart}$part > /dev/null export PATH_FSTAB=/tmp/fstab echo "/dev/md${mdstart}$part $mntpoint ufs rw,userquota 2 2" > \ $PATH_FSTAB mount $mntpoint set `df -ik $mntpoint | tail -1 | awk '{print $4,$7}'` export QK=$(($1 / 10 * 8)) export QI=$(($2 / 10 * 8)) edquota -u -f $mntpoint -e ${mntpoint}:$((QK - 50)):$QK:$((QI - 50 )):$QI \ $testuser quotaon $mntpoint -export RUNDIR=${mntpoint}/stressX +export RUNDIR=$mntpoint/stressX chmod 777 $mntpoint su $testuser -c 'sh -c "(cd ..;runRUNTIME=20m ./run.sh disk.cfg > \ /dev/null 2>&1)"' rm -f $PATH_FSTAB for i in `jot 6`; do umount $mntpoint && break || sleep 10 done [ $i -eq 6 ] && exit 1 mdconfig -d -u $mdstart exit 0 Index: user/pho/stress2/misc/suj19.sh =================================================================== --- user/pho/stress2/misc/suj19.sh (revision 317637) +++ user/pho/stress2/misc/suj19.sh (revision 317638) @@ -1,79 +1,79 @@ #!/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$ # # SUJ, quota and snapshots test scenario [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 [ "`sysctl -in kern.features.ufs_quota`" != "1" ] && exit 0 . ../default.cfg snap () { for i in `jot 5`; do mksnap_ffs $1 $2 2>&1 | grep -v "Resource temporarily unavailable" [ ! -s $2 ] && rm -f $2 || return 0 sleep 1 done return 1 } -mount | grep "${mntpoint}" | grep -q md${mdstart} && umount ${mntpoint} -mdconfig -l | grep -q md${mdstart} && mdconfig -d -u ${mdstart} +mount | grep "$mntpoint" | grep -q md$mdstart && umount $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 +mdconfig -a -t swap -s 1g -u $mdstart +bsdlabel -w md$mdstart auto +newfs -j md${mdstart}$part > /dev/null export PATH_FSTAB=/tmp/fstab -echo "/dev/md${mdstart}${part} ${mntpoint} ufs rw,userquota 2 2" > $PATH_FSTAB -mount ${mntpoint} -set `df -ik ${mntpoint} | tail -1 | awk '{print $4,$7}'` +echo "/dev/md${mdstart}$part $mntpoint ufs rw,userquota 2 2" > $PATH_FSTAB +mount $mntpoint +set `df -ik $mntpoint | tail -1 | awk '{print $4,$7}'` export QK=$(($1 / 4)) export QI=$(($2 / 4)) -edquota -u -f ${mntpoint} -e ${mntpoint}:$((QK - 50)):$QK:$((QI - 50 )):$QI ${testuser} -quotaon ${mntpoint} -export RUNDIR=${mntpoint}/stressX -chmod 777 ${mntpoint} -su ${testuser} -c 'sh -c "(cd ..;runRUNTIME=20m ./run.sh disk.cfg > /dev/null 2>&1)"' & +edquota -u -f $mntpoint -e ${mntpoint}:$((QK - 50)):$QK:$((QI - 50 )):$QI $testuser +quotaon $mntpoint +export RUNDIR=$mntpoint/stressX +chmod 777 $mntpoint +su $testuser -c 'sh -c "(cd ..;runRUNTIME=20m ./run.sh disk.cfg > /dev/null 2>&1)"' & for i in `jot 20`; do - echo "`date '+%T'` mksnap_ffs ${mntpoint} ${mntpoint}/.snap/snap$i" - snap ${mntpoint} ${mntpoint}/.snap/snap$i || break + echo "`date '+%T'` mksnap_ffs $mntpoint $mntpoint/.snap/snap$i" + snap $mntpoint $mntpoint/.snap/snap$i || break sleep 1 done i=$(($(date '+%S') % 20 + 1)) -echo "rm -f ${mntpoint}/.snap/snap$i" -rm -f ${mntpoint}/.snap/snap$i +echo "rm -f $mntpoint/.snap/snap$i" +rm -f $mntpoint/.snap/snap$i wait -while mount | grep -q ${mntpoint}; do - umount ${mntpoint} || sleep 1 +while mount | grep -q $mntpoint; do + umount $mntpoint || sleep 1 done -mdconfig -d -u ${mdstart} +mdconfig -d -u $mdstart rm -f $PATH_FSTAB Index: user/pho/stress2/misc/suj20.sh =================================================================== --- user/pho/stress2/misc/suj20.sh (revision 317637) +++ user/pho/stress2/misc/suj20.sh (revision 317638) @@ -1,179 +1,179 @@ #!/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$ # # Looping mksnap_ffs seen. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg # Scenario by mckusick@ # # create a bunch of files/directories # create a snapshot # remove many (but not all) of those files/directories # create some new files/directories in what remains of those # original files/directories. # create another snapshot # repeat { # remove many (somewhat different) of those files/directories # create some new files/directories in what remains of those # remaining files/directories. # create a new snapshot # remove oldest snapshot # } snap () { for i in `jot 5`; do mksnap_ffs $1 $2 2>&1 | grep -v "Resource temporarily unavailable" [ ! -s $2 ] && rm -f $2 || return 0 sleep 1 done return 1 } here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > suj20.c mycc -o suj20 -Wall -Wextra -g -O2 suj20.c rm -f suj20.c -mount | grep "${mntpoint}" | grep -q md${mdstart} && umount ${mntpoint} -mdconfig -l | grep -q md${mdstart} && mdconfig -d -u ${mdstart} +mount | grep "$mntpoint" | grep -q md$mdstart && umount $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 +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 cd $mntpoint chmod 777 $mntpoint /tmp/suj20 -snap $mntpoint ${mntpoint}/.snap/snap1 +snap $mntpoint $mntpoint/.snap/snap1 /tmp/suj20 prune -snap $mntpoint ${mntpoint}/.snap/snap2 +snap $mntpoint $mntpoint/.snap/snap2 /tmp/suj20 for i in `jot 10`; do /tmp/suj20 prune /tmp/suj20 - snap $mntpoint ${mntpoint}/.snap/snap$((i + 2)) - sn=`ls -tU ${mntpoint}/.snap | tail -1` - rm -f ${mntpoint}/.snap/$sn + snap $mntpoint $mntpoint/.snap/snap$((i + 2)) + sn=`ls -tU $mntpoint/.snap | tail -1` + rm -f $mntpoint/.snap/$sn done cd $here -while mount | grep -q ${mntpoint}; do - umount ${mntpoint} || sleep 1 +while mount | grep -q $mntpoint; do + umount $mntpoint || sleep 1 done -mdconfig -d -u ${mdstart} +mdconfig -d -u $mdstart rm -f /tmp/suj20 exit 0 EOF #include #include #include #include #include #include #include #include static char buf[4096]; #define ND 100 #define NF 100 void setup(void) { int d, f, fd, i, n; char name[128]; for (d = 0; d < ND; d++) { snprintf(name, sizeof(name), "d%03d", d); if (mkdir(name, 00700) == -1 && errno != EEXIST) err(1, "mkdir(%s)", name); if (chdir(name) == -1) err(1, "chdir(%s)", name); for (f = 0; f < NF; f++) { if (arc4random() % 100 < 33) continue; snprintf(name, sizeof(name), "f%03d", f); if ((fd = open(name, O_RDWR | O_CREAT | O_TRUNC, 0640)) == -1) err(1, "open(%s)", name); n = arc4random() % 10; for (i = 0; i < n; i++) { if (write(fd, buf, sizeof(buf)) != sizeof(buf)) err(1, "write()"); } close(fd); } if (chdir("..") == -1) err(1, "chdir(%s)", ".."); } } void prune(void) { int d, f; char name[128]; for (d = 0; d < ND; d++) { snprintf(name, sizeof(name), "d%03d", d); if (chdir(name) == -1) err(1, "chdir(%s)", name); for (f = 0; f < NF; f++) { if (arc4random() % 100 < 33) continue; snprintf(name, sizeof(name), "f%03d", f); if (unlink(name) == -1 && errno != ENOENT) err(1, "unlink(%s)", name); } if (chdir("..") == -1) err(1, "chdir(%s)", ".."); } for (d = 0; d < ND; d++) { if (arc4random() % 100 > 10) continue; snprintf(name, sizeof(name), "rm -rf d%03d", d); system(name); } } int main(int argc, char **argv __unused) { if (argc == 1) setup(); if (argc == 2) prune(); return (0); } Index: user/pho/stress2/misc/suj21.sh =================================================================== --- user/pho/stress2/misc/suj21.sh (revision 317637) +++ user/pho/stress2/misc/suj21.sh (revision 317638) @@ -1,180 +1,180 @@ #!/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$ # # Copy of suj20.sh, but with test user as non root. # "panic: handle_disk_write_complete: Unknown type freedep" seen. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg # Scenario by mckusick@ # # create a bunch of files/directories # create a snapshot # remove many (but not all) of those files/directories # create some new files/directories in what remains of those # original files/directories. # create another snapshot # repeat { # remove many (somewhat different) of those files/directories # create some new files/directories in what remains of those # remaining files/directories. # create a new snapshot # remove oldest snapshot # } snap () { for i in `jot 5`; do mksnap_ffs $1 $2 2>&1 | grep -v "Resource temporarily unavailable" [ ! -s $2 ] && rm -f $2 || return 0 sleep 1 done return 1 } here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > suj21.c mycc -o suj21 -Wall -Wextra -g -O2 suj21.c rm -f suj21.c -mount | grep "${mntpoint}" | grep -q md${mdstart} && umount ${mntpoint} -mdconfig -l | grep -q md${mdstart} && mdconfig -d -u ${mdstart} +mount | grep "$mntpoint" | grep -q md$mdstart && umount $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 +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 cd $mntpoint chmod 777 $mntpoint su $testuser -c '/tmp/suj21' -snap $mntpoint ${mntpoint}/.snap/snap1 +snap $mntpoint $mntpoint/.snap/snap1 su $testuser -c '/tmp/suj21 prune' -snap $mntpoint ${mntpoint}/.snap/snap2 +snap $mntpoint $mntpoint/.snap/snap2 su $testuser -c '/tmp/suj21' for i in `jot 10`; do su $testuser -c '/tmp/suj21 prune' su $testuser -c '/tmp/suj21' - snap $mntpoint ${mntpoint}/.snap/snap$((i + 2)) - sn=`ls -tU ${mntpoint}/.snap | tail -1` - rm -f ${mntpoint}/.snap/$sn + snap $mntpoint $mntpoint/.snap/snap$((i + 2)) + sn=`ls -tU $mntpoint/.snap | tail -1` + rm -f $mntpoint/.snap/$sn done cd $here -while mount | grep -q ${mntpoint}; do - umount ${mntpoint} || sleep 1 +while mount | grep -q $mntpoint; do + umount $mntpoint || sleep 1 done -mdconfig -d -u ${mdstart} +mdconfig -d -u $mdstart rm -f /tmp/suj21 exit 0 EOF #include #include #include #include #include #include #include #include static char buf[4096]; #define ND 100 #define NF 100 void setup(void) { int d, f, fd, i, n; char name[128]; for (d = 0; d < ND; d++) { snprintf(name, sizeof(name), "d%03d", d); if (mkdir(name, 00700) == -1 && errno != EEXIST) err(1, "mkdir(%s)", name); if (chdir(name) == -1) err(1, "chdir(%s)", name); for (f = 0; f < NF; f++) { if (arc4random() % 100 < 33) continue; snprintf(name, sizeof(name), "f%03d", f); if ((fd = open(name, O_RDWR | O_CREAT | O_TRUNC, 0640)) == -1) err(1, "open(%s)", name); n = arc4random() % 10; for (i = 0; i < n; i++) { if (write(fd, buf, sizeof(buf)) != sizeof(buf)) err(1, "write()"); } close(fd); } if (chdir("..") == -1) err(1, "chdir(%s)", ".."); } } void prune(void) { int d, f; char name[128]; for (d = 0; d < ND; d++) { snprintf(name, sizeof(name), "d%03d", d); if (chdir(name) == -1) err(1, "chdir(%s)", name); for (f = 0; f < NF; f++) { if (arc4random() % 100 < 33) continue; snprintf(name, sizeof(name), "f%03d", f); if (unlink(name) == -1 && errno != ENOENT) err(1, "unlink(%s)", name); } if (chdir("..") == -1) err(1, "chdir(%s)", ".."); } for (d = 0; d < ND; d++) { if (arc4random() % 100 > 10) continue; snprintf(name, sizeof(name), "rm -rf d%03d", d); system(name); } } int main(int argc, char **argv __unused) { if (argc == 1) setup(); if (argc == 2) prune(); return (0); } Index: user/pho/stress2/misc/suj22.sh =================================================================== --- user/pho/stress2/misc/suj22.sh (revision 317637) +++ user/pho/stress2/misc/suj22.sh (revision 317638) @@ -1,197 +1,197 @@ #!/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$ # # Variation of suj20.sh, with focus on the FS state after a panic / power # cycle. # Demonstrate "multiple references to blocks" in FS after reboot from a # looping mksnap_ffs(8). [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg # Scenario by mckusick@ # # create a bunch of files/directories # create a snapshot # remove many (but not all) of those files/directories # create some new files/directories in what remains of those # original files/directories. # create another snapshot # repeat { # remove many (somewhat different) of those files/directories # create some new files/directories in what remains of those # remaining files/directories. # create a new snapshot # remove oldest snapshot # } snap () { for i in `jot 5`; do mksnap_ffs $1 $2 2>&1 | grep -v "Resource temporarily unavailable" [ ! -s $2 ] && rm -f $2 || return 0 sleep 1 done return 1 } D=$diskimage if [ -n "`find $D -mtime -1h 2>/dev/null`" ]; then # FS left by previous crash - mdconfig -a -t vnode -f $D -u ${mdstart} - fsck -t ufs -y md${mdstart}${part} - fsck -t ufs -y md${mdstart}${part} + mdconfig -a -t vnode -f $D -u $mdstart + fsck -t ufs -y md${mdstart}$part + fsck -t ufs -y md${mdstart}$part rm -f $D exit 0 fi here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > suj22.c mycc -o suj22 -Wall -Wextra -O2 suj22.c rm -f suj22.c -mount | grep "${mntpoint}" | grep -q md${mdstart} && umount ${mntpoint} -mdconfig -l | grep -q md${mdstart} && mdconfig -d -u ${mdstart} +mount | grep "$mntpoint" | grep -q md$mdstart && umount $mntpoint +mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart dede $D 1m 1k || exit 1 -mdconfig -a -t vnode -f $D -u ${mdstart} -bsdlabel -w md${mdstart} auto -newfs -j md${mdstart}${part} > /dev/null +mdconfig -a -t vnode -f $D -u $mdstart +bsdlabel -w md$mdstart auto +newfs -j md${mdstart}$part > /dev/null mount /dev/md${mdstart}$part $mntpoint cd $mntpoint chmod 777 $mntpoint /tmp/suj22 -snap $mntpoint ${mntpoint}/.snap/snap1 +snap $mntpoint $mntpoint/.snap/snap1 /tmp/suj22 prune -snap $mntpoint ${mntpoint}/.snap/snap2 +snap $mntpoint $mntpoint/.snap/snap2 /tmp/suj22 for i in `jot 10`; do /tmp/suj22 prune /tmp/suj22 - snap $mntpoint ${mntpoint}/.snap/snap$((i + 2)) || break - sn=`ls -tU ${mntpoint}/.snap | tail -1` - rm -f ${mntpoint}/.snap/$sn + snap $mntpoint $mntpoint/.snap/snap$((i + 2)) || break + sn=`ls -tU $mntpoint/.snap | tail -1` + rm -f $mntpoint/.snap/$sn done cd $here -while mount | grep -q ${mntpoint}; do - umount ${mntpoint} || sleep 1 +while mount | grep -q $mntpoint; do + umount $mntpoint || sleep 1 done -fsck -t ufs -y md${mdstart}${part} -fsck -t ufs -y md${mdstart}${part} -mdconfig -d -u ${mdstart} +fsck -t ufs -y md${mdstart}$part +fsck -t ufs -y md${mdstart}$part +mdconfig -d -u $mdstart rm -f /tmp/suj22 $D exit 0 EOF #include #include #include #include #include #include #include #include static char buf[4096]; #define ND 100 #define NF 100 void setup(void) { int d, f, fd, i, n; char name[128]; for (d = 0; d < ND; d++) { snprintf(name, sizeof(name), "d%03d", d); if (mkdir(name, 00700) == -1 && errno != EEXIST) err(1, "mkdir(%s)", name); if (chdir(name) == -1) err(1, "chdir(%s)", name); for (f = 0; f < NF; f++) { if (arc4random() % 100 < 33) continue; snprintf(name, sizeof(name), "f%03d", f); if ((fd = open(name, O_RDWR | O_CREAT | O_TRUNC, 0640)) == -1) err(1, "open(%s)", name); n = arc4random() % 10; for (i = 0; i < n; i++) { if (write(fd, buf, sizeof(buf)) != sizeof(buf)) err(1, "write()"); } close(fd); } if (chdir("..") == -1) err(1, "chdir(%s)", ".."); } } void prune(void) { int d, f; char name[128]; for (d = 0; d < ND; d++) { snprintf(name, sizeof(name), "d%03d", d); if (chdir(name) == -1) err(1, "chdir(%s)", name); for (f = 0; f < NF; f++) { if (arc4random() % 100 < 33) continue; snprintf(name, sizeof(name), "f%03d", f); if (unlink(name) == -1 && errno != ENOENT) err(1, "unlink(%s)", name); } if (chdir("..") == -1) err(1, "chdir(%s)", ".."); } for (d = 0; d < ND; d++) { if (arc4random() % 100 > 10) continue; snprintf(name, sizeof(name), "rm -rf d%03d", d); system(name); } } int main(int argc, char **argv __unused) { if (argc == 1) setup(); if (argc == 2) prune(); return (0); } Index: user/pho/stress2/misc/suj24.sh =================================================================== --- user/pho/stress2/misc/suj24.sh (revision 317637) +++ user/pho/stress2/misc/suj24.sh (revision 317638) @@ -1,54 +1,54 @@ #!/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$ # # Scenario from kern/160662 # Scenario by Hans Ottevanger # Fixed in r225806 [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg here=`pwd` -mount | grep "${mntpoint}" | grep -q md${mdstart} && umount ${mntpoint} -mdconfig -l | grep -q md${mdstart} && mdconfig -d -u ${mdstart} +mount | grep "$mntpoint" | grep -q md$mdstart && umount $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 +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 (cd $mntpoint; mksnap_ffs $mntpoint/.snap/snapshot) -while mount | grep -q ${mntpoint}; do - umount ${mntpoint} || sleep 1 +while mount | grep -q $mntpoint; do + umount $mntpoint || sleep 1 done -mdconfig -d -u ${mdstart} +mdconfig -d -u $mdstart Index: user/pho/stress2/misc/suj30.sh =================================================================== --- user/pho/stress2/misc/suj30.sh (revision 317637) +++ user/pho/stress2/misc/suj30.sh (revision 317638) @@ -1,280 +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} +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 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/suj32.sh =================================================================== --- user/pho/stress2/misc/suj32.sh (revision 317637) +++ user/pho/stress2/misc/suj32.sh (revision 317638) @@ -1,95 +1,95 @@ #!/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$ # # tunefs -j enable is not aware of the indirect blocks. # Problem fixed in r247399. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > suj32.c mycc -o suj32 -Wall -Wextra -O2 suj32.c || exit 1 rm -f suj32.c cd $here -mount | grep "${mntpoint}" | grep -q md${mdstart} && umount ${mntpoint} -mdconfig -l | grep -q md${mdstart} && mdconfig -d -u ${mdstart} +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 5g -u ${mdstart} -bsdlabel -w md${mdstart} auto -newfs -U md${mdstart}${part} > /dev/null -mount /dev/md${mdstart}$part $mntpoint +mdconfig -a -t swap -s 5g -u $mdstart +bsdlabel -w md$mdstart auto +newfs -U md${mdstart}$part > /dev/null +mount /dev/md${mdstart}$part $mntpoint || exit 1 # fill the root directory to become larger than NIDIR * blksize (cd $mntpoint; /tmp/suj32) -while mount | grep -q ${mntpoint}; do - umount ${mntpoint} || sleep 1 +while mount | grep -q $mntpoint; do + umount $mntpoint || sleep 1 done tunefs -j enable /dev/md${mdstart}$part if ! mount /dev/md${mdstart}$part $mntpoint; then echo FAIL fsck_ffs -y /dev/md${mdstart}$part else umount $mntpoint fi -mdconfig -d -u ${mdstart} +mdconfig -d -u $mdstart rm -f /tmp/suj32 exit 0 EOF #include #include #include int main(void) { int i; char name[800]; char *filler = "fillerfillerfillerfillerfillerfillerfillerfillerfiller" "fillerfillerfillerfillerfillerfillerfillerfillerfiller" "fillerfillerfillerfillerfillerfillerfillerfillerfiller" "fillerfillerfillerfillerfillerfillerfillerfillerfiller"; for (i = 0; i < 2000; i++) { snprintf(name, sizeof(name), "%s.%d", filler, i); if (mkdir(name, 00700) == -1) err(1, "mkdir(%s)", name); } return (0); } Index: user/pho/stress2/misc/suj34.sh =================================================================== --- user/pho/stress2/misc/suj34.sh (revision 317637) +++ user/pho/stress2/misc/suj34.sh (revision 317638) @@ -1,63 +1,63 @@ #!/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$ # # Simple suj / nullfs test scenario. # http://people.freebsd.org/~pho/stress/log/suj34.txt # More debug info: https://people.freebsd.org/~pho/stress/log/kostik831.txt [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg mount | grep -q "$mntpoint" && umount $mntpoint mdconfig -l | grep -q $mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 4g -u $mdstart -bsdlabel -w md${mdstart} auto +bsdlabel -w md$mdstart auto newfs -j md${mdstart}$part > /dev/null mount /dev/md${mdstart}$part $mntpoint mkdir $mntpoint/null mnt2=${mntpoint}2 [ -d $mnt2 ] || mkdir -p $mnt2 mount | grep -q "on $mnt2 " && umount -f $mnt2 mount -t nullfs $mntpoint/null $mnt2 export RUNDIR=$mnt2/stressX export runRUNTIME=10m (cd ..; ./run.sh marcus.cfg) while mount | grep -q "on $mnt2 "; do umount $mnt2 || sleep 1 done while mount | grep -q "on $mntpoint "; do umount $mntpoint || sleep 1 done Index: user/pho/stress2/misc/symlink.sh =================================================================== --- user/pho/stress2/misc/symlink.sh (revision 317637) +++ user/pho/stress2/misc/symlink.sh (revision 317638) @@ -1,130 +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} +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} +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} + echo "newfs $i /dev/md$mdstart" + newfs $i /dev/md$mdstart > /dev/null 2>&1 + mount /dev/md$mdstart $mntpoint tst - umount -f ${mntpoint} + 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 317637) +++ user/pho/stress2/misc/symlink2.sh (revision 317638) @@ -1,122 +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 +# Testing problem with buffer cache inconsistency [ `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} +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} +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 + 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 + /tmp/symlink2 $mntpoint/dir/link - ls -l ${mntpoint}/dir > /dev/null 2>&1 + ls -l $mntpoint/dir > /dev/null 2>&1 if [ $? -ne 0 ]; then set -x - ls -l ${mntpoint}/dir + ls -l $mntpoint/dir umount $mntpoint - mount /dev/md${mdstart} $mntpoint - ls -l ${mntpoint}/dir + mount /dev/md$mdstart $mntpoint + ls -l $mntpoint/dir set +x fi - umount -f ${mntpoint} + 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/tmpfs4.sh =================================================================== --- user/pho/stress2/misc/tmpfs4.sh (revision 317637) +++ user/pho/stress2/misc/tmpfs4.sh (revision 317638) @@ -1,49 +1,49 @@ #!/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$ # # Regression test from kern/122038 by gprspb mail ru [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg mount | grep "$mntpoint" | grep -q tmpfs && umount $mntpoint mount -t tmpfs tmpfs $mntpoint for i in `jot 100`; do - mkdir -p ${mntpoint}/1/2 - cd ${mntpoint}/1/2 - rm -rf ${mntpoint}/1 + mkdir -p $mntpoint/1/2 + cd $mntpoint/1/2 + rm -rf $mntpoint/1 cd .. 2>&1 | grep -v "cd: \.\.: No such file or directory" done umount $mntpoint 2>&1 | grep -v busy mount | grep "$mntpoint" | grep -q tmpfs && umount -f $mntpoint Index: user/pho/stress2/misc/tmpfs8.sh =================================================================== --- user/pho/stress2/misc/tmpfs8.sh (revision 317637) +++ user/pho/stress2/misc/tmpfs8.sh (revision 317638) @@ -1,180 +1,180 @@ #!/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$ # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 # Demonstrate rename(2) cache problem for tmpfs(5). Fixed in r226987. # Variation of rename6.sh . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > tmpfs8.c mycc -o tmpfs8 -Wall -Wextra -O2 tmpfs8.c rm -f tmpfs8.c cd $here mount | grep $mntpoint | grep -q tmpfs && umount -f $mntpoint mount -t tmpfs tmpfs $mntpoint chmod 777 $mntpoint -su ${testuser} -c "cd $mntpoint; /tmp/tmpfs8" +su $testuser -c "cd $mntpoint; /tmp/tmpfs8" while mount | grep $mntpoint | grep -q tmpfs; do umount $mntpoint || sleep 1 done rm -f /tmp/tmpfs8 exit EOF #include #include #include #include #include #include #include #include #include #include #include #include #include #include pid_t spid; const char *logfile = "test.log"; char new[128]; void cleanup() { kill(spid, SIGINT); } static void Stat() { struct stat sb; int i; setproctitle("Stat"); for (;;) { for (i = 0; i < 1000; i++) { stat(logfile, &sb); stat(new, &sb); } // usleep(1000); usleep(100); } } int main(void) { struct stat sb1, sb2, sb3; int fd, i, r1, r2, r3; if ((spid = fork()) == 0) Stat(); setproctitle("main"); atexit(cleanup); for (i = 0; i < 200000; i++) { bzero(&sb1, sizeof(sb1)); bzero(&sb2, sizeof(sb2)); if ((fd = open(logfile, O_RDWR | O_CREAT | O_TRUNC, 0644)) == -1) err(1, "creat(%s)", logfile); close(fd); sprintf(new, "test.log.%05d", i); if ((fd = open(new, O_RDWR | O_CREAT | O_TRUNC, 0644)) == -1) err(1, "creat(%s)", new); write(fd, "xxx", 3); close(fd); if ((r3 = stat(new, &sb3)) == -1) err(1, "stat(%s)", new); #if 1 if (rename(logfile, new) == -1) warn("rename(%s, %s)", logfile, new); #else /* No cache problem is seen */ if (link(logfile, new) == -1) err(1, "link(%s, %s)", logfile, new); if (unlink(logfile) == -1) err(1, "unlink(%s)", logfile); #endif /* * stat() for logfile and new will be identical sometimes, * but only when Stat() is running. */ r1 = stat(logfile, &sb1); r2 = stat(new, &sb2); if (r1 == 0 && r2 == 0 && bcmp(&sb1, &sb2, sizeof(sb1)) == 0) { fprintf(stderr, "FAIL 1\n"); fprintf(stderr, "%-15s: ino = %4ju, nlink = %ju, " "size = %jd\n", logfile, (uintmax_t)sb1.st_ino, (uintmax_t)sb1.st_nlink, sb1.st_blocks); fprintf(stderr, "%-15s: ino = %4ju, nlink = %ju, " "size = %jd\n", new , (uintmax_t)sb2.st_ino, (uintmax_t)sb2.st_nlink, sb2.st_blocks); } if (bcmp(&sb2, &sb3, sizeof(sb2)) == 0) { fprintf(stderr, "Old to file is lingering\n"); } if (sb2.st_ino == sb3.st_ino) { fprintf(stderr, "FAIL 2\n"); if (r1 == 0) fprintf(stderr, "sb1: %-15s: ino = %4ju, nlink = %ju, " "size = %jd\n", logfile, (uintmax_t)sb1.st_ino, (uintmax_t)sb1.st_nlink, sb1.st_blocks); if (r2 == 0) fprintf(stderr, "sb2: %-15s: ino = %4ju, nlink = %ju, " "size = %jd\n", new, (uintmax_t)sb2.st_ino, (uintmax_t)sb2.st_nlink, sb2.st_blocks); if (r3 == 0) fprintf(stderr, "sb3: %-15s: ino = %4ju, nlink = %ju, " "size = %jd\n", new, (uintmax_t)sb3.st_ino, (uintmax_t)sb3.st_nlink, sb3.st_blocks); exit(1); } unlink(new); } kill(spid, SIGINT); wait(NULL); return (0); } Index: user/pho/stress2/misc/tmpfs9.sh =================================================================== --- user/pho/stress2/misc/tmpfs9.sh (revision 317637) +++ user/pho/stress2/misc/tmpfs9.sh (revision 317638) @@ -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" & +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 -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/truncate3.sh =================================================================== --- user/pho/stress2/misc/truncate3.sh (revision 317637) +++ user/pho/stress2/misc/truncate3.sh (revision 317638) @@ -1,124 +1,124 @@ #!/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/rename.sh 191485 2009-04-25 10:19:36Z pho $ # # Variation of truncate2.sh with FS check added. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg mount | grep -q "$mntpoint" && umount $mntpoint mdconfig -l | grep -q $mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 400m -u $mdstart -bsdlabel -w md${mdstart} auto +bsdlabel -w md$mdstart auto newfs $newfs_flags md${mdstart}$part > /dev/null mount /dev/md${mdstart}$part $mntpoint export RUNDIR=$mntpoint/stressX here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > truncate3.c mycc -o truncate3 -Wall -O2 truncate3.c rm -f truncate3.c [ -d $RUNDIR ] || mkdir -p $RUNDIR cd $RUNDIR /tmp/truncate3 cd $here rm -f /tmp/truncate3 sync;sync;sync while mount | grep -q $mntpoint; do sync;sync;sync sleep 1 umount $mntpoint done if fsck -n -t ufs /dev/md${mdstart}$part | egrep -q "BAD|WRONG"; then fsck -n -t ufs /dev/md${mdstart}$part fi mdconfig -d -u $mdstart exit 0 EOF #include #include #include #include #include #include #define SIZ 512 char buf[SIZ]; void test(void) { int fd[10], i, j; char name[128]; off_t len; for (j = 0; j < 10; j++) { sprintf(name, "%05d.%05d", getpid(), j); fd[j] = open(name, O_WRONLY | O_CREAT | O_APPEND, 0666); if (fd[j] == -1) err(1, "open(%s)", name); unlink(name); } for (i = 0; i < 100; i++) { for (j = 0; j < 10; j++) { if (write(fd[j], buf, 2) != 2) err(1, "write"); len = arc4random() % 1024 * 1024; if (ftruncate(fd[j], len) == -1) err(1, "ftruncate"); } } exit(0); } int main(int argc, char **argv) { int i, status; for (i = 0; i < 20; i++) { if (fork() == 0) test(); } for (i = 0; i < 20; i++) wait(&status); return (0); } Index: user/pho/stress2/misc/truncate5.sh =================================================================== --- user/pho/stress2/misc/truncate5.sh (revision 317637) +++ user/pho/stress2/misc/truncate5.sh (revision 317638) @@ -1,110 +1,110 @@ #!/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/rename.sh 191485 2009-04-25 10:19:36Z pho $ # # "panic: handle_workitem_freeblocks: inode 447489 block count 336" seen. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg mount | grep -q "$mntpoint" && umount $mntpoint mdconfig -l | grep -q $mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart -bsdlabel -w md${mdstart} auto +bsdlabel -w md$mdstart auto newfs $newfs_flags md${mdstart}$part > /dev/null mount /dev/md${mdstart}$part $mntpoint here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > truncate5.c mycc -o truncate5 -Wall -Wextra -O2 truncate5.c rm -f truncate5.c export RUNDIR=$mntpoint/stressX [ -d $RUNDIR ] || mkdir -p $RUNDIR cd $RUNDIR /tmp/truncate5 cd $here rm -f /tmp/truncate5 while mount | grep -q md${mdstart}$part; do umount $mntpoint || sleep 1 done if fsck -n -t ufs /dev/md${mdstart}$part | egrep -q "BAD|WRONG"; then fsck -n -t ufs /dev/md${mdstart}$part fi mdconfig -d -u $mdstart exit 0 EOF #include #include #include #include #include #include #define SIZ 4096 char buf[SIZ]; int main() { int fd, i, j; char name[128]; off_t len = 21474837416LL; off_t pos; srand48(getpid()); sprintf(name, "%05d.%05d", getpid(), 0); fd = open(name, O_WRONLY | O_CREAT, 0666); if (ftruncate(fd, len) == -1) err(1, "ftruncate"); unlink(name); sleep(1); for (i = 0; i < 100; i++) { for (j = 0; j < 100; j++) { pos = lrand48() % (len - sizeof(buf)); if (lseek(fd, pos, SEEK_SET) == -1) err(1, "lseek"); if (write(fd, buf, sizeof(buf)) != sizeof(buf)) err(1, "write"); } } close(fd); return (0); } Index: user/pho/stress2/misc/umount.sh =================================================================== --- user/pho/stress2/misc/umount.sh (revision 317637) +++ user/pho/stress2/misc/umount.sh (revision 317638) @@ -1,52 +1,52 @@ #!/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$ # # Test "umount" [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg D=$diskimage dede $D 1m 110 || exit 1 -mount | grep "$mntpoint" | grep md${mdstart}${part} > /dev/null && umount $mntpoint -mdconfig -l | grep md${mdstart} > /dev/null && mdconfig -d -u ${mdstart} +mount | grep "$mntpoint" | grep md${mdstart}$part > /dev/null && umount $mntpoint +mdconfig -l | grep md$mdstart > /dev/null && mdconfig -d -u $mdstart -mdconfig -a -t vnode -f $D -u ${mdstart} -bsdlabel -w md${mdstart} auto -newfs md${mdstart}${part} > /dev/null -mount /dev/md${mdstart}${part} $mntpoint +mdconfig -a -t vnode -f $D -u $mdstart +bsdlabel -w md$mdstart auto +newfs md${mdstart}$part > /dev/null +mount /dev/md${mdstart}$part $mntpoint export RUNDIR=$mntpoint/stressX export runRUNTIME=3m # Run tests for three minutes (cd ..; ./run.sh vfs.cfg) umount $mntpoint -mdconfig -d -u ${mdstart} +mdconfig -d -u $mdstart rm -f $D Index: user/pho/stress2/misc/umountf.sh =================================================================== --- user/pho/stress2/misc/umountf.sh (revision 317637) +++ user/pho/stress2/misc/umountf.sh (revision 317638) @@ -1,71 +1,71 @@ #!/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$ # # Test problems with "umount -f" [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg D=$diskimage dede $D 1m 110 || exit 1 -mount | grep "$mntpoint" | grep md${mdstart}${part} > /dev/null && +mount | grep "$mntpoint" | grep md${mdstart}$part > /dev/null && umount $mntpoint mdconfig -l | grep md$mdstart > /dev/null && mdconfig -d -u $mdstart mdconfig -a -t vnode -f $D -u $mdstart || { rm $diskimage; exit 1; } bsdlabel -w md$mdstart auto newfs md${mdstart}$part > /dev/null mount /dev/md${mdstart}$part $mntpoint export RUNDIR=$mntpoint/stressX export runRUNTIME=2m cd ..; ./run.sh vfs.cfg > /dev/null 2>&1 & sleep 30 umount -f $mntpoint mdconfig -d -u $mdstart rm -f $D s=0 n=0 while pkill -f "swap|mkdir|creat"; do sleep 1 n=$((n + 1)) if [ $n -gt 60 ]; then pgrep "swap|mkdir|creat" s=1 break fi done wait exit $s Index: user/pho/stress2/misc/umountf2.sh =================================================================== --- user/pho/stress2/misc/umountf2.sh (revision 317637) +++ user/pho/stress2/misc/umountf2.sh (revision 317638) @@ -1,1303 +1,1303 @@ #!/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 scenario by kris@freebsd.org # Test problems with "umount -f and fsx. Results in a "KDB: enter: watchdog timeout" # http://people.freebsd.org/~pho/stress/log/kostik745.txt # Fixed by r275743 [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg sed '1,/^EOF/d' < $0 > /tmp/fsx.c mycc -o /tmp/fsx -O2 /tmp/fsx.c || exit 1 rm -f /tmp/fsx.c D=$diskimage dede $D 1m 1k || exit 1 mount | grep "$mntpoint" | grep md${mdstart}$part > /dev/null && umount $mntpoint mdconfig -l | grep md$mdstart > /dev/null && mdconfig -d -u $mdstart mdconfig -a -t vnode -f $D -u $mdstart bsdlabel -w md$mdstart auto newfs md${mdstart}$part > /dev/null 2>&1 mount /dev/md${mdstart}$part $mntpoint sleep 5 for i in `jot 100`; do - /tmp/fsx -S $i -q ${mntpoint}/xxx$i > /dev/null & + /tmp/fsx -S $i -q $mntpoint/xxx$i > /dev/null & done sleep 30 umount -f $mntpoint & for i in `jot 30`; do sleep 30 pgrep -q fsx || break done if pgrep -q fsx; then echo FAIL ps -l $! pkill fsx fi sleep 5 wait mdconfig -d -u $mdstart rm -f $D /tmp/fsx exit 0 EOF /* * Copyright (c) 1998-2001 Apple Computer, Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * * The contents of this file constitute Original Code as defined in and * are subject to the Apple Public Source License Version 2.0 (the * "License"). You may not use this file except in compliance with the * License. Please obtain a copy of the License at * http://www.opensource.apple.com/apsl/ and read it before using this file. * * This Original Code and all software distributed under the License are * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the * License for the specific language governing rights and limitations * under the License. * * @APPLE_LICENSE_HEADER_END@ * * File: fsx.c * Author: Avadis Tevanian, Jr. * * File system exerciser. * * Rewrite and enhancements 1998-2001 Conrad Minshall -- conrad@mac.com * * Various features from Joe Sokol, Pat Dirks, and Clark Warner. * * Small changes to work under Linux -- davej@suse.de * * Sundry porting patches from Guy Harris 12/2001 * * Checks for mmap last-page zero fill. * * Updated license to APSL 2.0, 2004/7/27 - Jordan Hubbard * * $FreeBSD$ * */ #include #include #ifdef _UWIN # include # include # include # include #endif #include #include #ifndef MAP_FILE # define MAP_FILE 0 #endif #include #include #include #include #include #include #include #include #define NUMPRINTCOLUMNS 32 /* # columns of data to print on each line */ /* * A log entry is an operation and a bunch of arguments. */ struct log_entry { int operation; int args[3]; }; #define LOGSIZE 1000 struct log_entry oplog[LOGSIZE]; /* the log */ int logptr = 0; /* current position in log */ int logcount = 0; /* total ops */ /* * Define operations */ #define OP_READ 1 #define OP_WRITE 2 #define OP_TRUNCATE 3 #define OP_CLOSEOPEN 4 #define OP_MAPREAD 5 #define OP_MAPWRITE 6 #define OP_SKIPPED 7 #define OP_INVALIDATE 8 int page_size; int page_mask; char *original_buf; /* a pointer to the original data */ char *good_buf; /* a pointer to the correct data */ char *temp_buf; /* a pointer to the current data */ char *fname; /* name of our test file */ int fd; /* fd for our test file */ off_t file_size = 0; off_t biggest = 0; char state[256]; unsigned long testcalls = 0; /* calls to function "test" */ unsigned long simulatedopcount = 0; /* -b flag */ int closeprob = 0; /* -c flag */ int invlprob = 0; /* -i flag */ int debug = 0; /* -d flag */ unsigned long debugstart = 0; /* -D flag */ unsigned long maxfilelen = 256 * 1024; /* -l flag */ int sizechecks = 1; /* -n flag disables them */ int maxoplen = 64 * 1024; /* -o flag */ int quiet = 0; /* -q flag */ unsigned long progressinterval = 0; /* -p flag */ int readbdy = 1; /* -r flag */ int style = 0; /* -s flag */ int truncbdy = 1; /* -t flag */ int writebdy = 1; /* -w flag */ long monitorstart = -1; /* -m flag */ long monitorend = -1; /* -m flag */ int lite = 0; /* -L flag */ long numops = -1; /* -N flag */ int randomoplen = 1; /* -O flag disables it */ int seed = 1; /* -S flag */ int mapped_writes = 1; /* -W flag disables */ int mapped_reads = 1; /* -R flag disables it */ int mapped_msync = 1; /* -U flag disables */ int fsxgoodfd = 0; FILE * fsxlogf = NULL; int badoff = -1; int closeopen = 0; int invl = 0; void vwarnc(code, fmt, ap) int code; const char *fmt; va_list ap; { fprintf(stderr, "fsx: "); if (fmt != NULL) { vfprintf(stderr, fmt, ap); fprintf(stderr, ": "); } fprintf(stderr, "%s\n", strerror(code)); } void warn(const char * fmt, ...) { va_list ap; va_start(ap, fmt); vwarnc(errno, fmt, ap); va_end(ap); } void prt(char *fmt, ...) { va_list args; va_start(args, fmt); vfprintf(stdout, fmt, args); va_end(args); if (fsxlogf) { va_start(args, fmt); vfprintf(fsxlogf, fmt, args); va_end(args); } } void prterr(char *prefix) { prt("%s%s%s\n", prefix, prefix ? ": " : "", strerror(errno)); } void do_log4(int operation, int arg0, int arg1, int arg2) { struct log_entry *le; le = &oplog[logptr]; le->operation = operation; le->args[0] = arg0; le->args[1] = arg1; le->args[2] = arg2; logptr++; logcount++; if (logptr >= LOGSIZE) logptr = 0; } void log4(int operation, int arg0, int arg1, int arg2) { do_log4(operation, arg0, arg1, arg2); if (closeopen) do_log4(OP_CLOSEOPEN, 0, 0, 0); if (invl) do_log4(OP_INVALIDATE, 0, 0, 0); } void logdump(void) { struct log_entry *lp; int i, count, down, opnum; prt("LOG DUMP (%d total operations):\n", logcount); if (logcount < LOGSIZE) { i = 0; count = logcount; } else { i = logptr; count = LOGSIZE; } opnum = i + 1 + (logcount/LOGSIZE)*LOGSIZE; for ( ; count > 0; count--) { lp = &oplog[i]; if (lp->operation == OP_CLOSEOPEN || lp->operation == OP_INVALIDATE) { switch (lp->operation) { case OP_CLOSEOPEN: prt("\t\tCLOSE/OPEN\n"); break; case OP_INVALIDATE: prt("\t\tMS_INVALIDATE\n"); break; } i++; if (i == LOGSIZE) i = 0; continue; } prt("%d(%d mod 256): ", opnum, opnum%256); switch (lp->operation) { case OP_MAPREAD: prt("MAPREAD\t0x%x thru 0x%x\t(0x%x bytes)", lp->args[0], lp->args[0] + lp->args[1] - 1, lp->args[1]); if (badoff >= lp->args[0] && badoff < lp->args[0] + lp->args[1]) prt("\t***RRRR***"); break; case OP_MAPWRITE: prt("MAPWRITE 0x%x thru 0x%x\t(0x%x bytes)", lp->args[0], lp->args[0] + lp->args[1] - 1, lp->args[1]); if (badoff >= lp->args[0] && badoff < lp->args[0] + lp->args[1]) prt("\t******WWWW"); break; case OP_READ: prt("READ\t0x%x thru 0x%x\t(0x%x bytes)", lp->args[0], lp->args[0] + lp->args[1] - 1, lp->args[1]); if (badoff >= lp->args[0] && badoff < lp->args[0] + lp->args[1]) prt("\t***RRRR***"); break; case OP_WRITE: prt("WRITE\t0x%x thru 0x%x\t(0x%x bytes)", lp->args[0], lp->args[0] + lp->args[1] - 1, lp->args[1]); if (lp->args[0] > lp->args[2]) prt(" HOLE"); else if (lp->args[0] + lp->args[1] > lp->args[2]) prt(" EXTEND"); if ((badoff >= lp->args[0] || badoff >=lp->args[2]) && badoff < lp->args[0] + lp->args[1]) prt("\t***WWWW"); break; case OP_TRUNCATE: down = lp->args[0] < lp->args[1]; prt("TRUNCATE %s\tfrom 0x%x to 0x%x", down ? "DOWN" : "UP", lp->args[1], lp->args[0]); if (badoff >= lp->args[!down] && badoff < lp->args[!!down]) prt("\t******WWWW"); break; case OP_SKIPPED: prt("SKIPPED (no operation)"); break; default: prt("BOGUS LOG ENTRY (operation code = %d)!", lp->operation); } prt("\n"); opnum++; i++; if (i == LOGSIZE) i = 0; } } void save_buffer(char *buffer, off_t bufferlength, int fd) { off_t ret; ssize_t byteswritten; if (fd <= 0 || bufferlength == 0) return; if (bufferlength > SSIZE_MAX) { prt("fsx flaw: overflow in save_buffer\n"); exit(67); } if (lite) { off_t size_by_seek = lseek(fd, (off_t)0, SEEK_END); if (size_by_seek == (off_t)-1) prterr("save_buffer: lseek eof"); else if (bufferlength > size_by_seek) { warn("save_buffer: .fsxgood file too short... will save 0x%llx bytes instead of 0x%llx\n", (unsigned long long)size_by_seek, (unsigned long long)bufferlength); bufferlength = size_by_seek; } } ret = lseek(fd, (off_t)0, SEEK_SET); if (ret == (off_t)-1) prterr("save_buffer: lseek 0"); byteswritten = write(fd, buffer, (size_t)bufferlength); if (byteswritten != bufferlength) { if (byteswritten == -1) prterr("save_buffer write"); else warn("save_buffer: short write, 0x%x bytes instead of 0x%llx\n", (unsigned)byteswritten, (unsigned long long)bufferlength); } } void report_failure(int status) { logdump(); if (fsxgoodfd) { if (good_buf) { save_buffer(good_buf, file_size, fsxgoodfd); prt("Correct content saved for comparison\n"); prt("(maybe hexdump \"%s\" vs \"%s.fsxgood\")\n", fname, fname); } close(fsxgoodfd); } exit(status); } #define short_at(cp) ((unsigned short)((*((unsigned char *)(cp)) << 8) | \ *(((unsigned char *)(cp)) + 1))) void check_buffers(unsigned offset, unsigned size) { unsigned char c, t; unsigned i = 0; unsigned n = 0; unsigned op = 0; unsigned bad = 0; if (memcmp(good_buf + offset, temp_buf, size) != 0) { prt("READ BAD DATA: offset = 0x%x, size = 0x%x\n", offset, size); prt("OFFSET\tGOOD\tBAD\tRANGE\n"); while (size > 0) { c = good_buf[offset]; t = temp_buf[i]; if (c != t) { if (n == 0) { bad = short_at(&temp_buf[i]); prt("0x%5x\t0x%04x\t0x%04x", offset, short_at(&good_buf[offset]), bad); op = temp_buf[offset & 1 ? i+1 : i]; } n++; badoff = offset; } offset++; i++; size--; } if (n) { prt("\t0x%5x\n", n); if (bad) prt("operation# (mod 256) for the bad data may be %u\n", ((unsigned)op & 0xff)); else prt("operation# (mod 256) for the bad data unknown, check HOLE and EXTEND ops\n"); } else prt("????????????????\n"); report_failure(110); } } void check_size(void) { struct stat statbuf; off_t size_by_seek; if (fstat(fd, &statbuf)) { prterr("check_size: fstat"); statbuf.st_size = -1; } size_by_seek = lseek(fd, (off_t)0, SEEK_END); if (file_size != statbuf.st_size || file_size != size_by_seek) { prt("Size error: expected 0x%llx stat 0x%llx seek 0x%llx\n", (unsigned long long)file_size, (unsigned long long)statbuf.st_size, (unsigned long long)size_by_seek); report_failure(120); } } void check_trunc_hack(void) { struct stat statbuf; ftruncate(fd, (off_t)0); ftruncate(fd, (off_t)100000); fstat(fd, &statbuf); if (statbuf.st_size != (off_t)100000) { prt("no extend on truncate! not posix!\n"); exit(130); } ftruncate(fd, (off_t)0); } void doread(unsigned offset, unsigned size) { off_t ret; unsigned iret; offset -= offset % readbdy; if (size == 0) { if (!quiet && testcalls > simulatedopcount) prt("skipping zero size read\n"); log4(OP_SKIPPED, OP_READ, offset, size); return; } if (size + offset > file_size) { if (!quiet && testcalls > simulatedopcount) prt("skipping seek/read past end of file\n"); log4(OP_SKIPPED, OP_READ, offset, size); return; } log4(OP_READ, offset, size, 0); if (testcalls <= simulatedopcount) return; if (!quiet && ((progressinterval && testcalls % progressinterval == 0) || (debug && (monitorstart == -1 || (offset + size > monitorstart && (monitorend == -1 || offset <= monitorend)))))) prt("%lu read\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls, offset, offset + size - 1, size); ret = lseek(fd, (off_t)offset, SEEK_SET); if (ret == (off_t)-1) { prterr("doread: lseek"); report_failure(140); } iret = read(fd, temp_buf, size); if (iret != size) { if (iret == -1) prterr("doread: read"); else prt("short read: 0x%x bytes instead of 0x%x\n", iret, size); report_failure(141); } check_buffers(offset, size); } void check_eofpage(char *s, unsigned offset, char *p, int size) { uintptr_t last_page, should_be_zero; if (offset + size <= (file_size & ~page_mask)) return; /* * we landed in the last page of the file * test to make sure the VM system provided 0's * beyond the true end of the file mapping * (as required by mmap def in 1996 posix 1003.1) */ last_page = ((uintptr_t)p + (offset & page_mask) + size) & ~page_mask; for (should_be_zero = last_page + (file_size & page_mask); should_be_zero < last_page + page_size; should_be_zero++) if (*(char *)should_be_zero) { prt("Mapped %s: non-zero data past EOF (0x%llx) page offset 0x%x is 0x%04x\n", s, file_size - 1, should_be_zero & page_mask, short_at(should_be_zero)); report_failure(205); } } void domapread(unsigned offset, unsigned size) { unsigned pg_offset; unsigned map_size; char *p; offset -= offset % readbdy; if (size == 0) { if (!quiet && testcalls > simulatedopcount) prt("skipping zero size read\n"); log4(OP_SKIPPED, OP_MAPREAD, offset, size); return; } if (size + offset > file_size) { if (!quiet && testcalls > simulatedopcount) prt("skipping seek/read past end of file\n"); log4(OP_SKIPPED, OP_MAPREAD, offset, size); return; } log4(OP_MAPREAD, offset, size, 0); if (testcalls <= simulatedopcount) return; if (!quiet && ((progressinterval && testcalls % progressinterval == 0) || (debug && (monitorstart == -1 || (offset + size > monitorstart && (monitorend == -1 || offset <= monitorend)))))) prt("%lu mapread\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls, offset, offset + size - 1, size); pg_offset = offset & page_mask; map_size = pg_offset + size; if ((p = (char *)mmap(0, map_size, PROT_READ, MAP_FILE | MAP_SHARED, fd, (off_t)(offset - pg_offset))) == (char *)-1) { prterr("domapread: mmap"); report_failure(190); } memcpy(temp_buf, p + pg_offset, size); check_eofpage("Read", offset, p, size); if (munmap(p, map_size) != 0) { prterr("domapread: munmap"); report_failure(191); } check_buffers(offset, size); } void gendata(char *original_buf, char *good_buf, unsigned offset, unsigned size) { while (size--) { good_buf[offset] = testcalls % 256; if (offset % 2) good_buf[offset] += original_buf[offset]; offset++; } } void dowrite(unsigned offset, unsigned size) { off_t ret; unsigned iret; offset -= offset % writebdy; if (size == 0) { if (!quiet && testcalls > simulatedopcount) prt("skipping zero size write\n"); log4(OP_SKIPPED, OP_WRITE, offset, size); return; } log4(OP_WRITE, offset, size, file_size); gendata(original_buf, good_buf, offset, size); if (file_size < offset + size) { if (file_size < offset) memset(good_buf + file_size, '\0', offset - file_size); file_size = offset + size; if (lite) { warn("Lite file size bug in fsx!"); report_failure(149); } } if (testcalls <= simulatedopcount) return; if (!quiet && ((progressinterval && testcalls % progressinterval == 0) || (debug && (monitorstart == -1 || (offset + size > monitorstart && (monitorend == -1 || offset <= monitorend)))))) prt("%lu write\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls, offset, offset + size - 1, size); ret = lseek(fd, (off_t)offset, SEEK_SET); if (ret == (off_t)-1) { prterr("dowrite: lseek"); report_failure(150); } iret = write(fd, good_buf + offset, size); if (iret != size) { if (iret == -1) prterr("dowrite: write"); else prt("short write: 0x%x bytes instead of 0x%x\n", iret, size); report_failure(151); } } void domapwrite(unsigned offset, unsigned size) { unsigned pg_offset; unsigned map_size; off_t cur_filesize; char *p; offset -= offset % writebdy; if (size == 0) { if (!quiet && testcalls > simulatedopcount) prt("skipping zero size write\n"); log4(OP_SKIPPED, OP_MAPWRITE, offset, size); return; } cur_filesize = file_size; log4(OP_MAPWRITE, offset, size, 0); gendata(original_buf, good_buf, offset, size); if (file_size < offset + size) { if (file_size < offset) memset(good_buf + file_size, '\0', offset - file_size); file_size = offset + size; if (lite) { warn("Lite file size bug in fsx!"); report_failure(200); } } if (testcalls <= simulatedopcount) return; if (!quiet && ((progressinterval && testcalls % progressinterval == 0) || (debug && (monitorstart == -1 || (offset + size > monitorstart && (monitorend == -1 || offset <= monitorend)))))) prt("%lu mapwrite\t0x%x thru\t0x%x\t(0x%x bytes)\n", testcalls, offset, offset + size - 1, size); if (file_size > cur_filesize) { if (ftruncate(fd, file_size) == -1) { prterr("domapwrite: ftruncate"); exit(201); } } pg_offset = offset & page_mask; map_size = pg_offset + size; if ((p = (char *)mmap(0, map_size, PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, fd, (off_t)(offset - pg_offset))) == MAP_FAILED) { prterr("domapwrite: mmap"); report_failure(202); } memcpy(p + pg_offset, good_buf + offset, size); if (mapped_msync && msync(p, map_size, MS_SYNC) != 0) { prterr("domapwrite: msync"); report_failure(203); } check_eofpage("Write", offset, p, size); if (munmap(p, map_size) != 0) { prterr("domapwrite: munmap"); report_failure(204); } } void dotruncate(unsigned size) { int oldsize = file_size; size -= size % truncbdy; if (size > biggest) { biggest = size; if (!quiet && testcalls > simulatedopcount) prt("truncating to largest ever: 0x%x\n", size); } log4(OP_TRUNCATE, size, (unsigned)file_size, 0); if (size > file_size) memset(good_buf + file_size, '\0', size - file_size); file_size = size; if (testcalls <= simulatedopcount) return; if ((progressinterval && testcalls % progressinterval == 0) || (debug && (monitorstart == -1 || monitorend == -1 || size <= monitorend))) prt("%lu trunc\tfrom 0x%x to 0x%x\n", testcalls, oldsize, size); if (ftruncate(fd, (off_t)size) == -1) { prt("ftruncate1: %x\n", size); prterr("dotruncate: ftruncate"); report_failure(160); } } void writefileimage() { ssize_t iret; if (lseek(fd, (off_t)0, SEEK_SET) == (off_t)-1) { prterr("writefileimage: lseek"); report_failure(171); } iret = write(fd, good_buf, file_size); if ((off_t)iret != file_size) { if (iret == -1) prterr("writefileimage: write"); else prt("short write: 0x%x bytes instead of 0x%llx\n", iret, (unsigned long long)file_size); report_failure(172); } if (lite ? 0 : ftruncate(fd, file_size) == -1) { prt("ftruncate2: %llx\n", (unsigned long long)file_size); prterr("writefileimage: ftruncate"); report_failure(173); } } void docloseopen(void) { if (testcalls <= simulatedopcount) return; if (debug) prt("%lu close/open\n", testcalls); if (close(fd)) { prterr("docloseopen: close"); report_failure(180); } fd = open(fname, O_RDWR, 0); if (fd < 0) { prterr("docloseopen: open"); report_failure(181); } } void doinvl(void) { char *p; if (file_size == 0) return; if (testcalls <= simulatedopcount) return; if (debug) prt("%lu msync(MS_INVALIDATE)\n", testcalls); if ((p = (char *)mmap(0, file_size, PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, fd, 0)) == MAP_FAILED) { prterr("doinvl: mmap"); report_failure(205); } if (msync(p, 0, MS_SYNC | MS_INVALIDATE) != 0) { prterr("doinvl: msync"); report_failure(206); } if (munmap(p, file_size) != 0) { prterr("doinvl: munmap"); report_failure(207); } } void test(void) { unsigned long offset; unsigned long size = maxoplen; unsigned long rv = random(); unsigned long op = rv % (3 + !lite + mapped_writes); /* turn off the map read if necessary */ if (op == 2 && !mapped_reads) op = 0; if (simulatedopcount > 0 && testcalls == simulatedopcount) writefileimage(); testcalls++; if (closeprob) closeopen = (rv >> 3) < (1 << 28) / closeprob; if (invlprob) invl = (rv >> 3) < (1 << 28) / invlprob; if (debugstart > 0 && testcalls >= debugstart) debug = 1; if (!quiet && testcalls < simulatedopcount && testcalls % 100000 == 0) prt("%lu...\n", testcalls); /* * READ: op = 0 * WRITE: op = 1 * MAPREAD: op = 2 * TRUNCATE: op = 3 * MAPWRITE: op = 3 or 4 */ if (lite ? 0 : op == 3 && style == 0) /* vanilla truncate? */ dotruncate(random() % maxfilelen); else { if (randomoplen) size = random() % (maxoplen+1); if (lite ? 0 : op == 3) dotruncate(size); else { offset = random(); if (op == 1 || op == (lite ? 3 : 4)) { offset %= maxfilelen; if (offset + size > maxfilelen) size = maxfilelen - offset; if (op != 1) domapwrite(offset, size); else dowrite(offset, size); } else { if (file_size) offset %= file_size; else offset = 0; if (offset + size > file_size) size = file_size - offset; if (op != 0) domapread(offset, size); else doread(offset, size); } } } if (sizechecks && testcalls > simulatedopcount) check_size(); if (invl) doinvl(); if (closeopen) docloseopen(); } void cleanup(sig) int sig; { if (sig) prt("signal %d\n", sig); prt("testcalls = %lu\n", testcalls); exit(sig); } void usage(void) { fprintf(stdout, "usage: %s", "fsx [-dnqLOW] [-b opnum] [-c Prob] [-l flen] [-m start:end] [-o oplen] [-p progressinterval] [-r readbdy] [-s style] [-t truncbdy] [-w writebdy] [-D startingop] [-N numops] [-P dirpath] [-S seed] fname\n\ -b opnum: beginning operation number (default 1)\n\ -c P: 1 in P chance of file close+open at each op (default infinity)\n\ -d: debug output for all operations\n\ -i P: 1 in P chance of calling msync(MS_INVALIDATE) (default infinity)\n\ -l flen: the upper bound on file size (default 262144)\n\ -m startop:endop: monitor (print debug output) specified byte range (default 0:infinity)\n\ -n: no verifications of file size\n\ -o oplen: the upper bound on operation size (default 65536)\n\ -p progressinterval: debug output at specified operation interval\n\ -q: quieter operation\n\ -r readbdy: 4096 would make reads page aligned (default 1)\n\ -s style: 1 gives smaller truncates (default 0)\n\ -t truncbdy: 4096 would make truncates page aligned (default 1)\n\ -w writebdy: 4096 would make writes page aligned (default 1)\n\ -D startingop: debug output starting at specified operation\n\ -L: fsxLite - no file creations & no file size changes\n\ -N numops: total # operations to do (default infinity)\n\ -O: use oplen (see -o flag) for every op (default random)\n\ -P dirpath: save .fsxlog and .fsxgood files in dirpath (default ./)\n\ -S seed: for random # generator (default 1) 0 gets timestamp\n\ -W: mapped write operations DISabled\n\ -R: mapped read operations DISabled)\n\ -U: msync after mapped write operations DISabled\n\ fname: this filename is REQUIRED (no default)\n"); exit(90); } int getnum(char *s, char **e) { int ret = -1; *e = (char *) 0; ret = strtol(s, e, 0); if (*e) switch (**e) { case 'b': case 'B': ret *= 512; *e = *e + 1; break; case 'k': case 'K': ret *= 1024; *e = *e + 1; break; case 'm': case 'M': ret *= 1024*1024; *e = *e + 1; break; case 'w': case 'W': ret *= 4; *e = *e + 1; break; } return (ret); } int main(int argc, char **argv) { int i, ch; char *endp; char goodfile[1024]; char logfile[1024]; goodfile[0] = 0; logfile[0] = 0; page_size = getpagesize(); page_mask = page_size - 1; setvbuf(stdout, (char *)0, _IOLBF, 0); /* line buffered stdout */ while ((ch = getopt(argc, argv, "b:c:di:l:m:no:p:qr:s:t:w:D:LN:OP:RS:UW")) != -1) switch (ch) { case 'b': simulatedopcount = getnum(optarg, &endp); if (!quiet) fprintf(stdout, "Will begin at operation %ld\n", simulatedopcount); if (simulatedopcount == 0) usage(); simulatedopcount -= 1; break; case 'c': closeprob = getnum(optarg, &endp); if (!quiet) fprintf(stdout, "Chance of close/open is 1 in %d\n", closeprob); if (closeprob <= 0) usage(); break; case 'd': debug = 1; break; case 'i': invlprob = getnum(optarg, &endp); if (!quiet) fprintf(stdout, "Chance of MS_INVALIDATE is 1 in %d\n", invlprob); if (invlprob <= 0) usage(); break; case 'l': maxfilelen = getnum(optarg, &endp); if (maxfilelen <= 0) usage(); break; case 'm': monitorstart = getnum(optarg, &endp); if (monitorstart < 0) usage(); if (!endp || *endp++ != ':') usage(); monitorend = getnum(endp, &endp); if (monitorend < 0) usage(); if (monitorend == 0) monitorend = -1; /* aka infinity */ debug = 1; case 'n': sizechecks = 0; break; case 'o': maxoplen = getnum(optarg, &endp); if (maxoplen <= 0) usage(); break; case 'p': progressinterval = getnum(optarg, &endp); // if (progressinterval < 0) // usage(); break; case 'q': quiet = 1; break; case 'r': readbdy = getnum(optarg, &endp); if (readbdy <= 0) usage(); break; case 's': style = getnum(optarg, &endp); if (style < 0 || style > 1) usage(); break; case 't': truncbdy = getnum(optarg, &endp); if (truncbdy <= 0) usage(); break; case 'w': writebdy = getnum(optarg, &endp); if (writebdy <= 0) usage(); break; case 'D': debugstart = getnum(optarg, &endp); if (debugstart < 1) usage(); break; case 'L': lite = 1; break; case 'N': numops = getnum(optarg, &endp); if (numops < 0) usage(); break; case 'O': randomoplen = 0; break; case 'P': strncpy(goodfile, optarg, sizeof(goodfile)); strcat(goodfile, "/"); strncpy(logfile, optarg, sizeof(logfile)); strcat(logfile, "/"); break; case 'R': mapped_reads = 0; break; case 'S': seed = getnum(optarg, &endp); if (seed == 0) seed = time(0) % 10000; if (!quiet) fprintf(stdout, "Seed set to %d\n", seed); if (seed < 0) usage(); break; case 'W': mapped_writes = 0; if (!quiet) fprintf(stdout, "mapped writes DISABLED\n"); break; case 'U': mapped_msync = 0; if (!quiet) fprintf(stdout, "mapped msync DISABLED\n"); break; default: usage(); /* NOTREACHED */ } argc -= optind; argv += optind; if (argc != 1) usage(); fname = argv[0]; signal(SIGHUP, cleanup); signal(SIGINT, cleanup); signal(SIGPIPE, cleanup); signal(SIGALRM, cleanup); signal(SIGTERM, cleanup); signal(SIGXCPU, cleanup); signal(SIGXFSZ, cleanup); signal(SIGVTALRM, cleanup); signal(SIGUSR1, cleanup); signal(SIGUSR2, cleanup); initstate(seed, state, 256); setstate(state); fd = open(fname, O_RDWR|(lite ? 0 : O_CREAT|O_TRUNC), 0666); if (fd < 0) { prterr(fname); exit(91); } strncat(goodfile, fname, 256); strcat (goodfile, ".fsxgood"); fsxgoodfd = open(goodfile, O_RDWR|O_CREAT|O_TRUNC, 0666); if (fsxgoodfd < 0) { prterr(goodfile); exit(92); } strncat(logfile, fname, 256); strcat (logfile, ".fsxlog"); fsxlogf = fopen(logfile, "w"); if (fsxlogf == NULL) { prterr(logfile); exit(93); } if (lite) { off_t ret; file_size = maxfilelen = lseek(fd, (off_t)0, SEEK_END); if (file_size == (off_t)-1) { prterr(fname); warn("main: lseek eof"); exit(94); } ret = lseek(fd, (off_t)0, SEEK_SET); if (ret == (off_t)-1) { prterr(fname); warn("main: lseek 0"); exit(95); } } original_buf = (char *) malloc(maxfilelen); for (i = 0; i < maxfilelen; i++) original_buf[i] = random() % 256; good_buf = (char *) malloc(maxfilelen); memset(good_buf, '\0', maxfilelen); temp_buf = (char *) malloc(maxoplen); memset(temp_buf, '\0', maxoplen); if (lite) { /* zero entire existing file */ ssize_t written; written = write(fd, good_buf, (size_t)maxfilelen); if (written != maxfilelen) { if (written == -1) { prterr(fname); warn("main: error on write"); } else warn("main: short write, 0x%x bytes instead of 0x%x\n", (unsigned)written, maxfilelen); exit(98); } } else check_trunc_hack(); while (numops == -1 || numops--) test(); if (close(fd)) { prterr("close"); report_failure(99); } prt("All operations completed A-OK!\n"); exit(0); return 0; } Index: user/pho/stress2/misc/umountf4.sh =================================================================== --- user/pho/stress2/misc/umountf4.sh (revision 317637) +++ user/pho/stress2/misc/umountf4.sh (revision 317638) @@ -1,87 +1,87 @@ #!/bin/sh # # Copyright (c) 2008 Peter Holm # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # $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 || { rm -f $D$m; exit 1; } bsdlabel -w md$m auto - newfs md${m}${part} > /dev/null 2>&1 + 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 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 + 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/umountf5.sh =================================================================== --- user/pho/stress2/misc/umountf5.sh (revision 317637) +++ user/pho/stress2/misc/umountf5.sh (revision 317638) @@ -1,72 +1,72 @@ #!/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$ # # Test with "umount -f" and SU [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg D=$diskimage dd if=/dev/zero of=$D$m bs=1m count=10 2>&1 | egrep -v "records|transferred" mount | grep "$mntpoint" | grep md${mdstart}$part > /dev/null && umount $mntpoint mdconfig -l | grep md$mdstart > /dev/null && mdconfig -d -u $mdstart mdconfig -a -t vnode -f $D -u $mdstart || { rm -f $diskimage; exit 1; } -bsdlabel -w md${mdstart} auto +bsdlabel -w md$mdstart auto newfs $newfs_flags md${mdstart}$part > /dev/null 2>&1 mount /dev/md${mdstart}$part $mntpoint export RUNDIR=$mntpoint/stressX export runRUNTIME=2m cd ..; ./run.sh vfs.cfg > /dev/null 2>&1 & sleep 30 umount -f $mntpoint mdconfig -d -u $mdstart rm -f $D s=0 n=0 while pkill -f "swap|mkdir|creat"; do sleep 1 n=$((n + 1)) if [ $n -gt 60 ]; then pgrep "swap|mkdir|creat" s=1 break fi done wait exit $s Index: user/pho/stress2/misc/union.sh =================================================================== --- user/pho/stress2/misc/union.sh (revision 317637) +++ user/pho/stress2/misc/union.sh (revision 317638) @@ -1,67 +1,67 @@ #!/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$ # # Simple union test scenario [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg u1=$mdstart u2=$((u1 + 1)) mount | grep -q /dev/md${u2}$part && umount -f /dev/md${u2}$part mount | grep -q /dev/md${u1}$part && umount -f /dev/md${u1}$part -mdconfig -l | grep -q md${u2} && mdconfig -d -u $u2 -mdconfig -l | grep -q md${u1} && mdconfig -d -u $u1 +mdconfig -l | grep -q md$u2 && mdconfig -d -u $u2 +mdconfig -l | grep -q md$u1 && mdconfig -d -u $u1 mdconfig -s 256m -u $u1 bsdlabel -w md$u1 auto -newfs md${u1}${part} > /dev/null +newfs md${u1}$part > /dev/null mdconfig -s 256m -u $u2 bsdlabel -w md$u2 auto -newfs md${u2}${part} > /dev/null +newfs md${u2}$part > /dev/null mount -o ro /dev/md${u1}$part $mntpoint mount -o union /dev/md${u2}$part $mntpoint export RUNDIR=$mntpoint/stressX export runRUNTIME=10m (cd ..; ./run.sh marcus.cfg) > /dev/null umount /dev/md${u2}$part umount /dev/md${u1}$part mount | grep -q /dev/md${u2}$part && umount -f /dev/md${u2}$part mount | grep -q /dev/md${u1}$part && umount -f /dev/md${u1}$part mdconfig -d -u $u2 mdconfig -d -u $u1 Index: user/pho/stress2/misc/vunref2.sh =================================================================== --- user/pho/stress2/misc/vunref2.sh (revision 317637) +++ user/pho/stress2/misc/vunref2.sh (revision 317638) @@ -1,74 +1,74 @@ #!/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. # 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 -mount | grep "${mntpoint}" | grep -q md${mdstart}${part} && umount -f $mntpoint +mount | grep "$mntpoint" | grep -q md${mdstart}$part && umount -f $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 12m -u $mdstart bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}${part} > /dev/null -mount /dev/md${mdstart}${part} $mntpoint -chmod 777 ${mntpoint} +newfs $newfs_flags md${mdstart}$part > /dev/null +mount /dev/md${mdstart}$part $mntpoint +chmod 777 $mntpoint export runRUNTIME=5m export LOAD=100 export swapLOAD=100 -export RUNDIR=${mntpoint}/stressX +export RUNDIR=$mntpoint/stressX for i in `jot 10`; do su $testuser -c "\ cd ..; testcases/run/run testcases/mmap/mmap testcases/swap/swap " sync;sync;sync sleep 5 n=0 while mount | grep -qw $mntpoint; do - umount ${mntpoint} > /dev/null 2>&1 || sleep 0.1 + umount $mntpoint > /dev/null 2>&1 || sleep 0.1 n=$((n + 1)) if [ $n -gt 25 ]; then echo "*** Leak detected ***" fstat $mntpoint exit 1 fi done - mount /dev/md${mdstart}${part} $mntpoint + mount /dev/md${mdstart}$part $mntpoint done umount $mntpoint mdconfig -d -u $mdstart Index: user/pho/stress2/misc/zfs.sh =================================================================== --- user/pho/stress2/misc/zfs.sh (revision 317637) +++ user/pho/stress2/misc/zfs.sh (revision 317638) @@ -1,69 +1,69 @@ #!/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$ # # Simple zfs raidz test scenario [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 [ `sysctl -n kern.kstack_pages` -lt 4 ] && exit 0 . ../default.cfg kldstat -v | grep -q zfs.ko || { kldload zfs.ko || exit 0; loaded=1; } u1=$mdstart u2=$((u1 + 1)) u3=$((u2 + 1)) -mdconfig -l | grep -q md${u1} && mdconfig -d -u $u1 -mdconfig -l | grep -q md${u2} && mdconfig -d -u $u2 -mdconfig -l | grep -q md${u3} && mdconfig -d -u $u3 +mdconfig -l | grep -q md$u1 && mdconfig -d -u $u1 +mdconfig -l | grep -q md$u2 && mdconfig -d -u $u2 +mdconfig -l | grep -q md$u3 && mdconfig -d -u $u3 mdconfig -s 512m -u $u1 mdconfig -s 512m -u $u2 mdconfig -s 512m -u $u3 zpool list | egrep -q "^tank" && zpool destroy tank [ -d /tank ] && rm -rf /tank zpool create tank raidz md$u1 md$u2 md$u3 zfs create tank/test export RUNDIR=/tank/test/stressX export runRUNTIME=20m (cd ..; ./run.sh marcus.cfg) zfs destroy -r tank zpool destroy tank mdconfig -d -u $u1 mdconfig -d -u $u2 mdconfig -d -u $u3 [ -n "$loaded" ] && kldunload zfs.ko exit 0 Index: user/pho/stress2/misc/zfs2.sh =================================================================== --- user/pho/stress2/misc/zfs2.sh (revision 317637) +++ user/pho/stress2/misc/zfs2.sh (revision 317638) @@ -1,72 +1,72 @@ #!/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$ # # Simple zfs mirror test scenario [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 [ `sysctl -n kern.kstack_pages` -lt 4 ] && exit 0 . ../default.cfg kldstat -v | grep -q zfs.ko || { kldload zfs.ko || exit 0; loaded=1; } d1=${diskimage}.1 d2=${diskimage}.2 dd if=/dev/zero of=$d1 bs=1m count=1k 2>&1 | egrep -v "records|transferred" dd if=/dev/zero of=$d2 bs=1m count=1k 2>&1 | egrep -v "records|transferred" u1=$mdstart u2=$((u1 + 1)) -mdconfig -l | grep -q md${u1} && mdconfig -d -u $u1 -mdconfig -l | grep -q md${u2} && mdconfig -d -u $u2 +mdconfig -l | grep -q md$u1 && mdconfig -d -u $u1 +mdconfig -l | grep -q md$u2 && mdconfig -d -u $u2 mdconfig -a -t vnode -f $d1 -u $u1 mdconfig -a -t vnode -f $d2 -u $u2 zpool list | egrep -q "^tank" && zpool destroy tank [ -d /tank ] && rm -rf /tank zpool create tank mirror md$u1 md$u2 export RUNDIR=/tank/stressX export runRUNTIME=10m (cd ..; ./run.sh marcus.cfg) zfs destroy -r tank zpool destroy tank mdconfig -d -u $u1 mdconfig -d -u $u2 rm -rf $d1 $d2 [ -n "$loaded" ] && kldunload zfs.ko exit 0 Index: user/pho/stress2/misc/zfs3.sh =================================================================== --- user/pho/stress2/misc/zfs3.sh (revision 317637) +++ user/pho/stress2/misc/zfs3.sh (revision 317638) @@ -1,84 +1,84 @@ #!/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$ # # Simple zfs snapshot test scenario # page fault from fs/zfs/dbuf.c:1807 # Page fault seen: # https://people.freebsd.org/~pho/stress/log/zfs3-2.txt # Fixed in r308887. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 [ `sysctl -n kern.kstack_pages` -lt 4 ] && exit 0 . ../default.cfg kldstat -v | grep -q zfs.ko || { kldload zfs.ko || exit 0; loaded=1; } d1=${diskimage}.1 d2=${diskimage}.2 dd if=/dev/zero of=$d1 bs=1m count=1k 2>&1 | egrep -v "records|transferred" dd if=/dev/zero of=$d2 bs=1m count=1k 2>&1 | egrep -v "records|transferred" u1=$mdstart u2=$((u1 + 1)) -mdconfig -l | grep -q md${u1} && mdconfig -d -u $u1 -mdconfig -l | grep -q md${u2} && mdconfig -d -u $u2 +mdconfig -l | grep -q md$u1 && mdconfig -d -u $u1 +mdconfig -l | grep -q md$u2 && mdconfig -d -u $u2 mdconfig -a -t vnode -f $d1 -u $u1 mdconfig -a -t vnode -f $d2 -u $u2 zpool list | egrep -q "^tank" && zpool destroy tank [ -d /tank ] && rm -rf /tank zpool create tank md$u1 md$u2 zfs create tank/test zfs set quota=800m tank/test zfs snapshot tank/test@snap1 export RUNDIR=/tank/test/stressX export runRUNTIME=10m (cd ..; ./run.sh marcus.cfg) zfs rollback tank/test@snap1 zfs destroy tank/test@snap1 zfs destroy -r tank zpool destroy tank mdconfig -d -u $u1 mdconfig -d -u $u2 rm -rf $d1 $d2 [ -n "$loaded" ] && kldunload zfs.ko exit 0 Index: user/pho/stress2/misc/zfs4.sh =================================================================== --- user/pho/stress2/misc/zfs4.sh (revision 317637) +++ user/pho/stress2/misc/zfs4.sh (revision 317638) @@ -1,83 +1,83 @@ #!/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$ # # Simple zfs snapshot test scenario [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 [ `sysctl -n kern.kstack_pages` -lt 4 ] && exit 0 . ../default.cfg kldstat -v | grep -q zfs.ko || { kldload zfs.ko || exit 0; loaded=1; } d1=${diskimage}.1 d2=${diskimage}.2 dd if=/dev/zero of=$d1 bs=1m count=1k 2>&1 | egrep -v "records|transferred" dd if=/dev/zero of=$d2 bs=1m count=1k 2>&1 | egrep -v "records|transferred" u1=$mdstart u2=$((u1 + 1)) -mdconfig -l | grep -q md${u1} && mdconfig -d -u $u1 -mdconfig -l | grep -q md${u2} && mdconfig -d -u $u2 +mdconfig -l | grep -q md$u1 && mdconfig -d -u $u1 +mdconfig -l | grep -q md$u2 && mdconfig -d -u $u2 mdconfig -a -t vnode -f $d1 -u $u1 mdconfig -a -t vnode -f $d2 -u $u2 zpool list | egrep -q "^tank" && zpool destroy tank [ -d /tank ] && rm -rf /tank zpool create tank md$u1 md$u2 zfs create tank/test zfs set quota=100m tank/test zfs set snapdir=visible tank/test export RUNDIR=/tank/test/stressX export runRUNTIME=10m (cd ..; ./run.sh marcus.cfg) & for i in `jot 20`; do zfs snapshot tank/test@snap$i done for i in `jot 20`; do zfs destroy tank/test@snap$i done wait zfs destroy -r tank zpool destroy tank mdconfig -d -u $u1 mdconfig -d -u $u2 rm -rf $d1 $d2 [ -n "$loaded" ] && kldunload zfs.ko exit 0 Index: user/pho/stress2/misc/zfs6.sh =================================================================== --- user/pho/stress2/misc/zfs6.sh (revision 317637) +++ user/pho/stress2/misc/zfs6.sh (revision 317638) @@ -1,80 +1,80 @@ #!/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$ # # Parallel mount / umount and snapshots. zpool hang seen: # https://people.freebsd.org/~pho/stress/log/zfs6.txt [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 [ `sysctl -n kern.kstack_pages` -lt 4 ] && exit 0 . ../default.cfg kldstat -v | grep -q zfs.ko || { kldload zfs.ko || exit 0; loaded=1; } u1=$mdstart u2=$((u1 + 1)) u3=$((u2 + 1)) -mdconfig -l | grep -q md${u1} && mdconfig -d -u $u1 -mdconfig -l | grep -q md${u2} && mdconfig -d -u $u2 -mdconfig -l | grep -q md${u3} && mdconfig -d -u $u3 +mdconfig -l | grep -q md$u1 && mdconfig -d -u $u1 +mdconfig -l | grep -q md$u2 && mdconfig -d -u $u2 +mdconfig -l | grep -q md$u3 && mdconfig -d -u $u3 mdconfig -s 512m -u $u1 mdconfig -s 512m -u $u2 mdconfig -s 512m -u $u3 zpool list | egrep -q "^tank" && zpool destroy tank [ -d /tank ] && rm -rf /tank zpool create tank raidz md$u1 md$u2 md$u3 || exit 1 zfs create tank/test || exit 1 while true; do zfs umount tank/test zfs mount tank/test done & for i in `jot 5000`; do touch /tank/test/f$i zfs snapshot tank/test@$i if [ $i -gt 5 ]; then zfs destroy tank/test@$((i - 5)) fi done kill $! wait zfs destroy -r tank zpool destroy tank mdconfig -d -u $u1 mdconfig -d -u $u2 mdconfig -d -u $u3 [ -n "$loaded" ] && kldunload zfs.ko exit 0