diff --git a/tools/test/stress2/default.cfg b/tools/test/stress2/default.cfg index 43b89dc7e160..f7748b55fa04 100644 --- a/tools/test/stress2/default.cfg +++ b/tools/test/stress2/default.cfg @@ -1,122 +1,121 @@ # Stress Test Suite Configuration. # Changes should be added to a `hostname` file in this directory. # As a minimum you must updated "testuser". export SHELL=/bin/sh : ${allconfig:=/tmp/stress2.d/`hostname`} [ -f "$allconfig" ] && . $allconfig # Source in local configuration # Default values export RUNDIR=${RUNDIR:-/tmp/stressX} export RUNTIME=${RUNTIME:-2m} export VERBOSE=${VERBOSE:-1} export LOAD=${LOAD:-20} # The INCARNATIONS variable may be set to match the number of CPUs and # the amount of RAM in the test box. export INCARNATIONS=${INCARNATIONS:-20} export BLASTHOST=${BLASTHOST:-192.168.1.1} # host with udp discard enabled in inetd.conf #export nfs_export=somehost:mount # Used by the NFS tests # Run all test cases: export runRUNTIME=${runRUNTIME:-3d} # Run tests for three days export runINCARNATIONS=1 export runLOAD=100 export swapINCARNATIONS=${swapINCARNATIONS:-$((2 * INCARNATIONS))} export swapLOAD=${swapLOAD:-80} export syscallKILL=1 export swapKILL=1 # May takes a long time to stop export rwLOAD=${rwLOAD:-70} export mkdirLOAD=${mkdirLOAD:-80} export creatLOAD=${creatLOAD:-80} export symlinkLOAD=${symlinkLOAD:-20} export tcpKILL=1 export shmINCARNATIONS=${shmINCARNATIONS:-5} [ -z "$TESTPROGS" ] && export TESTPROGS=" testcases/rw/rw testcases/swap/swap testcases/creat/creat testcases/mkdir/mkdir testcases/thr1/thr1 testcases/udp/udp testcases/tcp/tcp " # # Defaults for ./misc tests # export diskimage=${diskimage:-/tmp/diskimage} # Location of 1G disk image export mntpoint=${mntpoint:-/mnt} # Disk image mount point export testuser=${testuser:-TBD} # Name of non root test user export mdstart=${mdstart:-10} # Start of free md units -export part=${part:-a} # Partition to use on a md FS export newfs_flags=${newfs_flags:-"-U"} # Default file system flags export stress2origin=${stress2origin:-`pwd`} export stress2tools=`dirname $stress2origin`/tools # fsck wrapper checkfs () { local s fsck -t ufs -fy $1 > /tmp/fsck.log 2>&1 if grep -v "IS CLEAN" /tmp/fsck.log | \ LANG=C egrep -q "[A-Z][A-Z]"; then echo "fsck -t ufs -fy $1" cat /tmp/fsck.log s=1 else rm -f /tmp/fsck.log s=0 fi return $s } # Support for pre-build binaries for stress2/misc tests # Build modes: # 1 Build and copy binary to $STRESS2BIN # 2 Do not compile; use binary from $STRESS2BIN # Examples: # BMODE=1 ./all.sh -on `grep -lw mycc *.sh` # BMODE=2 STRESS2BIN=/home/pho/stress2/bin.i386.r276368 ./all.sh CC=${CC:-cc} top=`dirname $(pwd)` # cwd for the all.sh script STRESS2BIN=${STRESS2BIN:-$top/bin} mycc () { # "-o" must be first argument local file [ "$1" = "-o" ] && file=`basename $2` if [ "$BMODE" = "1" ]; then $CC $@ || return [ -z "$file" ] && return # "-c" [ -d $STRESS2BIN ] || mkdir $STRESS2BIN [ -x $STRESS2BIN/$file ] && echo "Overwriting $STRESS2BIN/$file" echo "cp $2 $STRESS2BIN" cp $2 $STRESS2BIN exit 0 # Build but do not run the test elif [ "$BMODE" = "2" ]; then [ -z "$file" ] && return if [ ! -x $STRESS2BIN/$file ]; then echo "$STRESS2BIN/$file not found" exit 1 fi echo "Using binary $STRESS2BIN/$file" cp $STRESS2BIN/$file /tmp else $CC $@ # default "build and run" mode fi } id $testuser > /dev/null 2>&1 || { echo "Non-root \$testuser \"$testuser\" not found."; exit 1; } diff --git a/tools/test/stress2/misc/advlock.sh b/tools/test/stress2/misc/advlock.sh index 16b67c3f3340..9e7144856310 100755 --- a/tools/test/stress2/misc/advlock.sh +++ b/tools/test/stress2/misc/advlock.sh @@ -1,245 +1,244 @@ #!/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. # # From r238952's commit log: # The first change closes a race where an open() that will block with O_SHLOCK # or O_EXLOCK can increase the write count while it waits. If the process # holding the current lock on the file then tries to call exec() on the file # it has locked, it can fail with ETXTBUSY even though the advisory lock is # preventing other threads from successfully completing a writable open(). # # The second change closes a race where a read-only open() with O_SHLOCK or # O_EXLOCK may return successfully while the write count is non-zero due to # another descriptor that had the advisory lock and was blocking the open() # still being in the process of closing. If the process that completed the # open() then attempts to call exec() on the file it locked, it can fail with # ETXTBUSY even though the other process that held a write lock has closed # the file and released the lock. # https://people.freebsd.org/~pho/stress/log/kostik859.txt # https://people.freebsd.org/~pho/stress/log/kostik860.txt # Fixed by r294204. . ../default.cfg [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 dir=/tmp odir=`pwd` cd $dir sed '1,/^EOF/d' < $odir/$0 > $dir/advlock.c mycc -o advlock -Wall -Wextra -O0 -g advlock.c || exit 1 rm -f advlock.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 512m -u $mdstart || exit 1 -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint cp /usr/bin/true $mntpoint cd $mntpoint /tmp/advlock r=$? cd $odir while mount | grep "on $mntpoint " | grep -q /dev/md; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart rm -f /tmp/advlock exit $r EOF #include #include #include #include #include #include #include #include #include #include #include #include #include volatile u_int *share; char *cmdline[] = { "./true", NULL }; const char *tp; #define SYNC 0 #define PARALLEL 2 #define RUNTIME (1 * 60) void handler(int i __unused) { fprintf(stderr, "ALARM from %s.\n", tp); _exit(1); } void slock(void) { int fd; setproctitle("%s", __func__); atomic_add_int(&share[SYNC], 1); while (share[SYNC] != PARALLEL) ; tp = __func__; alarm(2); if ((fd = open(cmdline[0], O_RDONLY | O_SHLOCK)) == -1) err(1, "open(%s). %d", cmdline[0], __LINE__); usleep(500); close(fd); _exit(0); } void elock(void) { int fd; setproctitle("%s", __func__); atomic_add_int(&share[SYNC], 1); while (share[SYNC] != PARALLEL) ; tp = __func__; alarm(2); if ((fd = open(cmdline[0], O_WRONLY | O_EXLOCK)) == -1) { if (errno != ETXTBSY) err(1, "open(%s). %d", cmdline[0], __LINE__); } else { usleep(500); close(fd); } _exit(0); } void stest(void) { int fd; setproctitle("%s", __func__); atomic_add_int(&share[SYNC], 1); while (share[SYNC] != PARALLEL) ; tp = __func__; alarm(2); if ((fd = open(cmdline[0], O_RDONLY | O_SHLOCK)) == -1) err(1, "open(%s). %d", cmdline[0], __LINE__); if (execve(cmdline[0], cmdline, NULL) == -1) err(1, "execve(%s) @ %d", cmdline[0], __LINE__); _exit(0); } void etest(void) { int fd; setproctitle("%s", __func__); atomic_add_int(&share[SYNC], 1); while (share[SYNC] != PARALLEL) ; tp = __func__; alarm(2); if ((fd = open(cmdline[0], O_RDONLY | O_EXLOCK)) == -1) err(1, "open(%s). %d", cmdline[0], __LINE__); if (execve(cmdline[0], cmdline, NULL) == -1) err(1, "execve(%s) @ %d", cmdline[0], __LINE__); _exit(0); } int main(void) { size_t len; time_t start; int i, n, r, s; len = PAGE_SIZE; if ((share = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED, -1, 0)) == MAP_FAILED) err(1, "mmap"); signal(SIGALRM, handler); n = r = 0; start = time(NULL); while ((time(NULL) - start) < RUNTIME) { n++; share[SYNC] = 0; if (fork() == 0) slock(); if (fork() == 0) stest(); for (i = 0; i < PARALLEL; i++) { wait(&s); r += s == 0 ? 0 : 1; } if (r != 0) break; share[SYNC] = 0; if (fork() == 0) elock(); if (fork() == 0) etest(); for (i = 0; i < PARALLEL; i++) { wait(&s); r += s == 0 ? 0 : 1; } if (r != 0) break; } if (r != 0) fprintf(stderr, "FAIL @ %d\n", n); return (r); } diff --git a/tools/test/stress2/misc/audit2.sh b/tools/test/stress2/misc/audit2.sh index 1435b13d9768..36a6339b8852 100755 --- a/tools/test/stress2/misc/audit2.sh +++ b/tools/test/stress2/misc/audit2.sh @@ -1,59 +1,58 @@ #!/bin/sh # # Copyright (c) 2018 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. # # No problems seen. . ../default.cfg [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 [ -f /usr/sbin/auditd -a -f /etc/rc.d/auditd ] || exit 0 pgrep -q auditd && exit 0 || service auditd onestart mount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint export runRUNTIME=5m export RUNDIR=$mntpoint/stressX su $testuser -c 'cd ..; ./run.sh marcus.cfg' n=0 while mount | grep $mntpoint | grep -q /dev/md; do umount $mntpoint || sleep 1 [ $((n += 1)) -gt 300 ] && { echo FAIL; exit 1; } done -checkfs /dev/md${mdstart}$part; s=$? +checkfs /dev/md$mdstart; s=$? mdconfig -d -u $mdstart service auditd onestop exit 0 diff --git a/tools/test/stress2/misc/backingstore.sh b/tools/test/stress2/misc/backingstore.sh index b16ff852acd9..5c8a1ac83577 100755 --- a/tools/test/stress2/misc/backingstore.sh +++ b/tools/test/stress2/misc/backingstore.sh @@ -1,81 +1,79 @@ #!/bin/sh # # Copyright (c) 2008 Peter Holm # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # 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 dd if=/dev/zero of=$D$m bs=100m count=1 status=none || exit 1 mdconfig -a -t vnode -f $D$m -u $m -bsdlabel -w md$m auto -newfs md${m}$part > /dev/null 2>&1 -[ -d ${mntpoint}$m ] || mkdir -p ${mntpoint}$m -mount $opt /dev/md${m}$part ${mntpoint}$m +newfs md${m} > /dev/null 2>&1 +[ -d $mntpoint$m ] || mkdir -p $mntpoint$m +mount $opt /dev/md$m $mntpoint$m n=$m m=$((m + 1)) -mount | grep "$mntpoint" | grep -q md$m && umount ${mntpoint}$m +mount | grep "$mntpoint$m" | 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 +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 -[ -d ${mntpoint}$m ] || mkdir -p ${mntpoint}$m -mount $opt /dev/md${m}$part ${mntpoint}$m +newfs md${m} > /dev/null 2>&1 +[ -d $mntpoint$m ] || mkdir -p $mntpoint$m +mount $opt /dev/md$m $mntpoint$m -export RUNDIR=${mntpoint}$m/stressX +export RUNDIR=$mntpoint$m/stressX ../testcases/rw/rw -t 5m -i 200 -h -n -while mount | grep -q ${mntpoint}$m; do +while mount | grep -q $mntpoint$m; do flag=$([ $((`date '+%s'` % 2)) -eq 0 ] && echo "-f" || echo "") - umount $flag ${mntpoint}$m > /dev/null 2>&1 + 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 +while mount | grep -q $mntpoint$m; do umount $([ $((`date '+%s'` % 2)) -eq 0 ] && \ - echo "-f" || echo "") ${mntpoint}$m > /dev/null 2>&1 + echo "-f" || echo "") $mntpoint$m > /dev/null 2>&1 done mdconfig -l | grep -q md$m && mdconfig -d -u $m rm -f $D diff --git a/tools/test/stress2/misc/backingstore2.sh b/tools/test/stress2/misc/backingstore2.sh index 48dc6109f719..91b8cb7acb68 100755 --- a/tools/test/stress2/misc/backingstore2.sh +++ b/tools/test/stress2/misc/backingstore2.sh @@ -1,72 +1,70 @@ #!/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. # # 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$m2" | 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$m1" | 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 +[ -d $mntpoint$m1 ] || mkdir -p $mntpoint$m1 +[ -d $mntpoint$m2 ] || mkdir -p $mntpoint$m2 dd if=/dev/zero of=$D$m bs=100m count=1 status=none || 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 > /dev/null 2>&1 +mount /dev/md$m1 $mntpoint$m1 -truncate -s 500M ${mntpoint}$m1/diskimage -mdconfig -a -t vnode -f ${mntpoint}$m1/diskimage -u $m2 +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 > /dev/null 2>&1 +mount /dev/md$m2 $mntpoint$m2 # Reversed umount sequence: -umount -f /dev/md${m1}$part -umount -f /dev/md${m2}$part +umount -f /dev/md$m1 +umount -f /dev/md$m2 -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 diff --git a/tools/test/stress2/misc/backingstore3.sh b/tools/test/stress2/misc/backingstore3.sh index 2610983da92e..1cea69c46477 100755 --- a/tools/test/stress2/misc/backingstore3.sh +++ b/tools/test/stress2/misc/backingstore3.sh @@ -1,73 +1,71 @@ #!/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. # # 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 +[ -d $mntpoint$m1 ] || mkdir -p $mntpoint$m1 +[ -d $mntpoint$m2 ] || mkdir -p $mntpoint$m2 dd if=/dev=zero of=$D$m bs=25m count=1 status=none || 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 > /dev/null 2>&1 +mount /dev/md$m1 $mntpoint$m1 -truncate -s 500M ${mntpoint}$m1/diskimage -mdconfig -a -t vnode -f ${mntpoint}$m1/diskimage -u $m2 +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 > /dev/null 2>&1 +mount /dev/md$m2 $mntpoint$m2 -dd if=/dev/zero of=${mntpoint}$m2/file bs=1m > /dev/null 2>&1 +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 +umount -f /dev/md$m2 -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 diff --git a/tools/test/stress2/misc/badcode.sh b/tools/test/stress2/misc/badcode.sh index c869c3a8c13e..caa9b1b6d461 100755 --- a/tools/test/stress2/misc/badcode.sh +++ b/tools/test/stress2/misc/badcode.sh @@ -1,65 +1,64 @@ #!/bin/sh # # Copyright (c) 2016 Dell EMC # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 # Run tests on a 2g swap backed MD with UFS SU fs. # "panic: SACK scoreboard must not be empty" seen: # https://people.freebsd.org/~pho/stress/log/full.txt # Fixed by r310547. . ../default.cfg kldstat -v | grep -q pty || kldload pty # ignore any load failure mount | grep "on $mntpoint " | grep -q /dev/md && umount -f $mntpoint [ -c /dev/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 +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint export LOAD=80 export rwLOAD=80 export runRUNTIME=10m export RUNDIR=$mntpoint/stressX export TESTPROGS=" testcases/badcode/badcode testcases/swap/swap testcases/sysctl/sysctl " su $testuser -c 'cd ..; ./testcases/run/run $TESTPROGS' ../tools/killall.sh while mount | grep "on $mntpoint " | grep -q /dev/md; do umount $mntpoint || sleep 1 done -checkfs /dev/md${mdstart}$part +checkfs /dev/md$mdstart mdconfig -d -u $mdstart diff --git a/tools/test/stress2/misc/bench.sh b/tools/test/stress2/misc/bench.sh index 965c9a3d9b99..33b6eb653879 100755 --- a/tools/test/stress2/misc/bench.sh +++ b/tools/test/stress2/misc/bench.sh @@ -1,300 +1,299 @@ #!/bin/sh # # Copyright (c) 2017 Dell EMC Isilon # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # "benchmark" for file system use, using no physical disk. . ../default.cfg [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 export LANG=C dir=/tmp odir=`pwd` cd $dir sed '1,/^EOF/d' < $odir/$0 > $dir/bench.c mycc -o bench -Wall -Wextra -O0 -g bench.c || exit 1 rm -f bench.c cd $odir mount | grep "on $mntpoint " | grep -q /dev/md && umount -f $mntpoint [ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart || exit 1 -bsdlabel -w md$mdstart auto log=/tmp/stress2.d/bench.sh.log [ -f $log ] && old=`tail -1 $log | awk '{print $2}'` tmp=/tmp/bench.sh.tmp s=0 for j in `jot 5`; do - newfs -n -b 4096 -f 512 -i 1024 md${mdstart}$part > \ + newfs -n -b 4096 -f 512 -i 1024 md$mdstart > \ /dev/null - mount -o async /dev/md${mdstart}$part $mntpoint + mount -o async /dev/md$mdstart $mntpoint /usr/bin/time sh -c "(cd $mntpoint; /tmp/bench)" 2>&1 | \ awk '{print $1}' [ $? -ne 0 ] && s=1 umount $mntpoint done | ministat -n | tail -1 | awk '{printf "%.3f %.3f\n",$6,$7}' > $tmp r=`cat $tmp` echo "`date +%Y%m%d%H%M` $r `uname -a`" >> $log tail -5 $log | cut -c 1-92 rm $tmp if [ $old ]; then awk -v old=$old -v new=$(echo $r | awk '{print $1}') \ 'BEGIN {if ((new - old) * 100 / old > 5) exit 1; else exit 0}' s=$? fi for i in `jot 6`; do mount | grep -q "on $mntpoint " || break umount $mntpoint && break || sleep 10 done [ $i -eq 6 ] && exit 1 mdconfig -d -u $mdstart rm -rf /tmp/bench exit 0 EOF #include #include #include #include #include #include #include #include #include #include #include #include #define LOOPS 50000 #define TESTS 6 #define TIMEOUT 600 static void (*functions[TESTS])(); static void t1(void) { int fd, i; char file[128]; alarm(TIMEOUT); for (i = 0; i < LOOPS; i++) { if (i % 1000 == 0) setproctitle("%s @ %d", __func__, i); snprintf(file, sizeof(file), "t1.%06d.%03d", getpid(), i); if ((fd = open(file, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE)) == -1) err(1, "open(%s)", file); close(fd); if (unlink(file) == -1) err(1, "unlink(%s)", file); usleep(100); } _exit(0); } static void t2(void) { int fd, i; char file[128]; alarm(TIMEOUT); for (i = 0; i < LOOPS; i++) { if (i % 1000 == 0) setproctitle("%s @ %d", __func__, i); snprintf(file, sizeof(file), "t2.%06d.%03d", getpid(), i); if ((fd = open(file, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE)) == -1) err(1, "open(%s)", file); close(fd); usleep(100); } for (i = 0; i < LOOPS; i++) { snprintf(file, sizeof(file), "t2.%06d.%03d", getpid(), i); if (unlink(file) == -1) err(1, "unlink(%s)", file); } _exit(0); } static void t3(void) { int fd, i; char dir[128], file[128]; alarm(TIMEOUT); snprintf(dir, sizeof(dir), "t3.%06d.dir", getpid()); if (mkdir(dir, 700) == -1) err(1, "mkdir(%s)", dir); for (i = 0; i < LOOPS; i++) { if (i % 1000 == 0) setproctitle("%s @ %d", __func__, i); snprintf(file, sizeof(file), "%s/t3.%06d.%03d", dir, getpid(), i); if ((fd = open(file, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE)) == -1) err(1, "open(%s)", file); close(fd); if (unlink(file) == -1) err(1, "unlink(%s)", file); usleep(100); } if (rmdir(dir) == -1) err(1, "rmdir(%s)", dir); _exit(0); } static void t4(void) { int fd, i; char file[128], new[128]; alarm(TIMEOUT); for (i = 0; i < LOOPS / 2; i++) { if (i % 1000 == 0) setproctitle("%s @ %d", __func__, i); snprintf(file, sizeof(file), "t4.%06d.%03d", getpid(), i); if ((fd = open(file, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE)) == -1) err(1, "open(%s)", file); close(fd); snprintf(new, sizeof(new), "t4.%06d.%03d.new", getpid(), i); if (rename(file, new) == -1) err(1, "rename(%s, %s)", file, new); if (unlink(new) == -1) err(1, "unlink(%s)", new); usleep(100); } _exit(0); } static void t5(void) { int fd, i; char buf[512], file[128]; alarm(TIMEOUT); memset(buf, 0, sizeof(buf)); for (i = 0; i < LOOPS; i++) { if (i % 1000 == 0) setproctitle("%s @ %d", __func__, i); snprintf(file, sizeof(file), "t5.%06d.%03d", getpid(), i); if ((fd = open(file, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE)) == -1) err(1, "open(%s)", file); if (write(fd, buf, sizeof(buf)) != sizeof(buf)) err(1, "write(%s)", file); close(fd); if (unlink(file) == -1) err(1, "unlink(%s)", file); usleep(100); } _exit(0); } static void t6(void) { int fd, i; char buf[512], file[128]; alarm(TIMEOUT); memset(buf, 0, sizeof(buf)); for (i = 0; i < LOOPS / 2; i++) { if (i % 1000 == 0) setproctitle("%s/write @ %d", __func__, i); snprintf(file, sizeof(file), "t6.%06d.%03d", getpid(), i); if ((fd = open(file, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE)) == -1) err(1, "open(%s)", file); if (write(fd, buf, sizeof(buf)) != sizeof(buf)) err(1, "write(%s)", file); close(fd); } for (i = 0; i < LOOPS / 2; i++) { if (i % 1000 == 0) setproctitle("%s/read @ %d", __func__, i); snprintf(file, sizeof(file), "t6.%06d.%03d", getpid(), i); if ((fd = open(file, O_RDONLY)) == -1) err(1, "open(%s)", file); if (read(fd, buf, sizeof(buf)) != sizeof(buf)) err(1, "write(%s)", file); close(fd); usleep(100); } for (i = 0; i < LOOPS / 2; i++) { snprintf(file, sizeof(file), "t6.%06d.%03d", getpid(), i); if (unlink(file) == -1) err(1, "unlink(%s)", file); } _exit(0); } static int test(void) { pid_t pids[TESTS]; int e, i, status; e = 0; for (i = 0; i < TESTS; i++) if ((pids[i] = fork()) == 0) functions[i](); for (i = 0; i < TESTS; i++) { if (waitpid(pids[i], &status, 0) != pids[i]) err(1, "waitpid(%d)", pids[i]); e += status != 0; } return (e); } int main(void) { int e; functions[0] = &t1; functions[1] = &t2; functions[2] = &t3; functions[3] = &t4; functions[4] = &t5; functions[5] = &t6; e = test(); return (e); } diff --git a/tools/test/stress2/misc/beneath2.sh b/tools/test/stress2/misc/beneath2.sh index a89cd8deb1e1..ad1f5c538258 100755 --- a/tools/test/stress2/misc/beneath2.sh +++ b/tools/test/stress2/misc/beneath2.sh @@ -1,101 +1,100 @@ #!/bin/sh # # SPDX-License-Identifier: BSD-2-Clause-FreeBSD # # Copyright (c) 2018 Dell EMC Isilon # # 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. # # O_RESOLVE_BENEATH test with a relative path, which is a symbolic link pointing # to an absolute path. # "panic: Assertion (ndp->ni_lcf & NI_LCF_LATCH) != 0 failed at # ../../../kern/vfs_lookup.c:182" seen. Fixed by r340343. # Based on scenario by Vladimir Kondratyev . ../default.cfg [ `id -u` -ne 0 ] && echo "Must be root!" && exit 1 dir=/tmp odir=`pwd` cd $dir sed '1,/^EOF/d' < $odir/$0 > $dir/beneath2.c mycc -o beneath2 -Wall -Wextra -O0 -g beneath2.c || exit 1 rm -f beneath2.c cd $odir set -e mount | grep "on $mntpoint " | grep -q /dev/md && umount -f $mntpoint [ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint set +e cd $mntpoint ln -s /tmp/justalongname symlink $dir/beneath2 symlink s=$? [ -f beneath2.core -a $s -eq 0 ] && { ls -l beneath2.core; mv beneath2.core $dir; s=1; } cd $odir for i in `jot 6`; do mount | grep -q "on $mntpoint " || break umount $mntpoint && break || sleep 10 [ $i -eq 6 ] && { echo FATAL; fstat -mf $mntpoint; exit 1; } done mdconfig -d -u $mdstart rm -rf $dir/beneath2 exit $s EOF #include #include #include #include #include #include int main(int argc, char *argv[]) { int fd; char *file; if (argc != 2) { fprintf(stderr, "Usage: %s ", argv[0]); exit(1); } file = argv[1]; if ((fd = open(file, O_RDONLY | O_RESOLVE_BENEATH)) != 0 && errno != ENOTCAPABLE) err(1, "open(%s)", file); return (0); } diff --git a/tools/test/stress2/misc/beneath3.sh b/tools/test/stress2/misc/beneath3.sh index 46f370899ee8..9e7493a2322c 100755 --- a/tools/test/stress2/misc/beneath3.sh +++ b/tools/test/stress2/misc/beneath3.sh @@ -1,92 +1,91 @@ #!/bin/sh # # SPDX-License-Identifier: BSD-2-Clause-FreeBSD # # Copyright (c) 2019 Dell EMC Isilon # # 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. # # vput: 0xfffff808d79c0278 is not locked but should be # KDB: enter: lock violation # Test scenario suggestions by kib@ and markj@ # Fixed by r348052. . ../default.cfg [ `id -u` -ne 0 ] && echo "Must be root!" && exit 1 dir=/tmp odir=`pwd` cd $dir sed '1,/^EOF/d' < $odir/$0 > $dir/beneath3.c mycc -o beneath3 -Wall -Wextra -O0 -g beneath3.c || exit 1 rm -f beneath3.c cd $odir set -e mount | grep "on $mntpoint " | grep -q /dev/md && umount -f $mntpoint [ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint set +e cd $mntpoint (cd /usr; $dir/beneath3) s=$? [ -f beneath3.core -a $s -eq 0 ] && { ls -l beneath3.core; mv beneath3.core $dir; s=1; } cd $odir for i in `jot 6`; do mount | grep -q "on $mntpoint " || break umount $mntpoint && break || sleep 10 [ $i -eq 6 ] && { echo FATAL; fstat -mf $mntpoint; exit 1; } done mdconfig -d -u $mdstart rm -rf $dir/beneath3 exit $s EOF #include #include #include #include int main(void) { int fd; char file[] = "/.."; errno = 0; fd = open(file, O_CREAT | O_RDONLY | O_RESOLVE_BENEATH); if (fd != -1 || errno != ENOTCAPABLE) err(1, "open(%s) returns %d", file, fd); return (0); } diff --git a/tools/test/stress2/misc/bio.sh b/tools/test/stress2/misc/bio.sh index d344fdb281c3..69bdc773b3ce 100755 --- a/tools/test/stress2/misc/bio.sh +++ b/tools/test/stress2/misc/bio.sh @@ -1,225 +1,224 @@ #!/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. # # mmap() & read()/write() on same file. # Test scenario suggestion by: jeff@ # Out of VM deadlock seen: # https://people.freebsd.org/~pho/stress/log/jeff114.txt # panic: deadlkres: possible deadlock detected: # https://people.freebsd.org/~pho/stress/log/jeff115.txt . ../default.cfg [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 dir=/tmp odir=`pwd` cd $dir ps=`sysctl -n hw.pagesize` sed "1,/^EOF/d;s/\$ps/$ps/" < $odir/$0 > $dir/bio.c mycc -o bio -Wall -Wextra -O0 -g bio.c || exit 1 rm -f bio.c cd $odir mount | grep "on $mntpoint " | grep -q /dev/md && umount -f $mntpoint [ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart mdconfig -a -t swap -s 2g -u $mdstart || exit 1 -bsdlabel -w md$mdstart auto -newfs -n md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs -n md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint (cd $mntpoint; /tmp/bio) & pid1=$! sleep 5 (cd ../testcases/swap; ./swap -t 5m -i 20 -k -l 100 -h) & pid2=$! while pgrep -q bio; do sleep 2 done while pgrep -q swap; do pkill -9 swap done wait $pid2 wait $pid1 s=$? while mount | grep "on $mntpoint " | grep -q /dev/md; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart rm -rf /tmp/bio exit $s EOF #include #include #include #include #include #include #include #include #include #include #include #include #define PS $ps /* From hw.pagesize */ #define SYN1 0 #define SYN2 1 #define INDX 2 #define PAGES (512 * 1024 * 1024 / PS) /* 512MB file size */ #define PARALLEL 3 #define RUNTIME (5 * 60) #define TIMEOUT (30 * 60) char buf[PS]; void test(int inx) { pid_t pid; size_t i, len, slen; time_t start; volatile u_int *share; int fd, r; u_int *ip, val; char file[80]; slen = PS; if ((share = mmap(NULL, slen, PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED, -1, 0)) == MAP_FAILED) err(1, "mmap"); snprintf(file, sizeof(file), "file.%06d", inx); if ((fd = open(file, O_RDWR | O_CREAT | O_TRUNC, 0640)) < 0) err(1, "%s", file); for (i = 0; i < PAGES; i++) { if (write(fd, buf, sizeof(buf)) != sizeof(buf)) err(1, "write error"); } len = PS * PAGES * sizeof(u_int); if ((ip = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)) == MAP_FAILED) err(1, "mmap"); start = time(NULL); if ((pid = fork()) == 0) { alarm(2 * RUNTIME); /* mmap read / write access */ for (i = 0; i < (size_t)(PAGES * PS); i += PS) { while (share[SYN1] == 0) sched_yield(); atomic_add_int(&share[SYN1], -1); if (ip[share[INDX] / sizeof(u_int)] != share[INDX]) warn("child expected %d, but got %d\n", ip[share[INDX] / sizeof(u_int)], share[INDX]); share[INDX] += PS; ip[share[INDX] / sizeof(u_int)] = share[INDX]; atomic_add_int(&share[SYN2], 1); /* signal parent */ if (i % 1000 == 0 && time(NULL) - start > TIMEOUT) errx(1, "Timed out");; } _exit(0); } if (pid == -1) err(1, "fork()"); share[INDX] = 0; atomic_add_int(&share[SYN2], 1); alarm(2 * RUNTIME); for (i = 0; i < (size_t)(PAGES * PS); i += PS) { while (share[SYN2] == 0) sched_yield(); atomic_add_int(&share[SYN2], -1); if (lseek(fd, share[INDX], SEEK_SET) == -1) err(1, "lseek error"); if ((r = read(fd, &val, sizeof(val))) != sizeof(val)) err(1, "parent read read %d bytes", r); if (val != share[INDX]) warn("parent expected %d, but got %d\n", share[INDX], val); val += PS; if (lseek(fd, val, SEEK_SET) == -1) err(1, "lseek error"); if (write(fd, &val, sizeof(val)) != sizeof(val)) err(1, "write"); atomic_add_int(&share[SYN1], 1); /* signal child */ if (i % 1000 == 0 && time(NULL) - start > TIMEOUT) errx(1, "Timed out");; } atomic_add_int(&share[SYN2], -1); if (waitpid(pid, NULL, 0) != pid) err(1, "wait"); if (munmap(ip, len) == -1) err(1, "unmap()"); if (munmap((void *)share, slen) == -1) err(1, "unmap()"); close(fd); if (unlink(file) == -1) err(1, "unlink(%s)", file); _exit(0); } int main(void) { pid_t pids[PARALLEL]; time_t start; int i, s, status; start = time(NULL); s = 0; while ((time(NULL) - start) < RUNTIME && s == 0) { for (i = 0; i < PARALLEL; i++) { if ((pids[i] = fork()) == 0) test(i); } for (i = 0; i < PARALLEL; i++) { if (waitpid(pids[i], &status, 0) == -1) err(1, "waitpid(%d)", pids[i]); if (status != 0) fprintf(stderr, "Child exit status = %d\n", status); s += status == 0 ? 0 : 1; } } return (s); } diff --git a/tools/test/stress2/misc/buildworld.sh b/tools/test/stress2/misc/buildworld.sh index ef4927d8dd1b..595b387c90ae 100755 --- a/tools/test/stress2/misc/buildworld.sh +++ b/tools/test/stress2/misc/buildworld.sh @@ -1,67 +1,66 @@ #!/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. # # "panic: Invalid page 0xfffff8007f227cf0 on inact queue" seen. # https://people.freebsd.org/~pho/stress/log/buildworld.txt # Fixed by r289377 . ../default.cfg [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 [ -d /usr/src/sys ] || exit 0 [ `sysctl -n hw.physmem` -gt $(( 2 * 1024 * 1024 * 1024)) ] && { echo "RAM must be clamped to 2GB or less for this test."; exit 0; } rm -f $diskimage [ `df -k $(dirname $diskimage) | tail -1 | awk '{print $4}'` -lt \ $((3 * 1024 * 1024)) ] && { echo "Need 3GB on `dirname $diskimage`"; \ exit 0; } mount | grep -q "on $mntpoint " && umount $mntpoint dd if=/dev/zero of=$diskimage bs=1m count=3k status=none trap "rm -f $diskimage" EXIT INT mdconfig -a -t vnode -f $diskimage -u $mdstart -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null -mount -o async /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags md$mdstart > /dev/null +mount -o async /dev/md$mdstart $mntpoint cd /usr/src export MAKEOBJDIRPREFIX=$mntpoint/obj export TMPDIR=$mntpoint/tmp mkdir $TMPDIR chmod 0777 $TMPDIR p=$((`sysctl -n hw.ncpu`+ 1)) timeout 20m make -i -j $p buildworld DESTDIR=$mntpoint TARGET=amd64 \ TARGET_ARCH=amd64 > /dev/null while mount | grep -q "on $mntpoint "; do umount $mntpoint || sleep 1 done checkfs /dev/md$mdstart || s=$? mdconfig -d -u $mdstart exit $s diff --git a/tools/test/stress2/misc/buildworld3.sh b/tools/test/stress2/misc/buildworld3.sh index 518c16151bcd..a5dc642ce876 100755 --- a/tools/test/stress2/misc/buildworld3.sh +++ b/tools/test/stress2/misc/buildworld3.sh @@ -1,95 +1,94 @@ #!/bin/sh # # SPDX-License-Identifier: BSD-2-Clause-FreeBSD # # Copyright (c) 2018 Dell EMC Isilon # # 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. # # Buildworld / quota test scenario. # "panic: chkdquot: missing dquot" seen # https://people.freebsd.org/~pho/stress/log/kostik1113.txt # Fixed in r338798 + r338799 . ../default.cfg [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 [ "`sysctl -in kern.features.ufs_quota`" != "1" ] && exit 0 [ -d /usr/src/sys ] || exit 0 mount | grep -q "on $mntpoint " && umount $mntpoint mdconfig -a -t swap -s 2g -u $mdstart -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null +newfs $newfs_flags md$mdstart > /dev/null export PATH_FSTAB=/tmp/fstab trap "rm -f $PATH_FSTAB" EXIT INT -echo "/dev/md${mdstart}$part $mntpoint ufs rw,userquota 2 2" > $PATH_FSTAB +echo "/dev/md$mdstart $mntpoint ufs rw,userquota 2 2" > $PATH_FSTAB mount $mntpoint set `df -ik $mntpoint | tail -1 | awk '{print $4,$7}'` export QK=$(($1 / 2)) export QI=$(($2 / 2)) edquota -u -f $mntpoint -e \ ${mntpoint}:$((QK - 50)):$QK:$((QI - 50 )):$QI $testuser quotaon $mntpoint mount | grep $mntpoint cd /usr/src export MAKEOBJDIRPREFIX=$mntpoint/obj export TMPDIR=$mntpoint/tmp mkdir $TMPDIR $MAKEOBJDIRPREFIX chmod 0777 $TMPDIR $MAKEOBJDIRPREFIX p=$((`sysctl -n hw.ncpu`+ 1)) su $testuser -c \ "make -i -j $p buildworld DESTDIR=$mntpoint TARGET=amd64 \ TARGET_ARCH=amd64 > /dev/null" & sleep 2 start=`date +%s` while [ $((`date +%s` - start)) -lt 1200 ]; do kill -0 $! > /dev/null 2>&1 || break sleep 2 done kill $! > /dev/null 2>&1 # Let make run 50% of the time so quotaoff runs on an active FS [ `jot -r 1 0 1` -eq 1 ] && pkill -U$testuser make wait while ! quotaoff $mntpoint; do sync sleep 5 done pgrep -q -U$testuser make && pkill -U$testuser make export tmp=/tmp/$(basename $0).$$ quotacheck -v $mntpoint > $tmp 2>&1 grep -q failed $tmp && { cat $tmp; s=1; } while mount | grep -q "on $mntpoint "; do umount $mntpoint || sleep 1 done checkfs /dev/md$mdstart || s=$? mdconfig -d -u $mdstart rm -f $PATH_FSTAB exit $s diff --git a/tools/test/stress2/misc/buildworld4.sh b/tools/test/stress2/misc/buildworld4.sh index fae22b9a17b9..98d4904ec4bd 100755 --- a/tools/test/stress2/misc/buildworld4.sh +++ b/tools/test/stress2/misc/buildworld4.sh @@ -1,74 +1,73 @@ #!/bin/sh # # SPDX-License-Identifier: BSD-2-Clause-FreeBSD # # Copyright (c) 2018 Dell EMC Isilon # # 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. # # Buildworld test with SUJ # "fsync: giving up on dirty (error = 35): tag devfs, type VCHR" seen. . ../default.cfg [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 [ -d /usr/src/sys ] || exit 0 rm -f $diskimage mount | grep -q "on $mntpoint " && umount $mntpoint mdconfig -a -t swap -s 5g -u $mdstart -bsdlabel -w md$mdstart auto [ "$newfs_flags" = "-U" ] && newfs_flags="-j" -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint mount | grep $mntpoint cd /usr/src export MAKEOBJDIRPREFIX=$mntpoint/obj export TMPDIR=$mntpoint/tmp mkdir $TMPDIR chmod 0777 $TMPDIR p=$((`sysctl -n hw.ncpu`+ 1)) [ `sysctl -n vm.swap_total` -gt 0 ] && p=$((p * 4)) p=`jot -r 1 1 $p` echo "make -i -j $p buildworld DESTDIR=$mntpoint TARGET=amd64 "\ "TARGET_ARCH=amd64" make -i -j $p buildworld DESTDIR=$mntpoint TARGET=amd64 TARGET_ARCH=amd64 \ > /dev/null & sleep 1 start=`date +%s` while [ $((`date +%s` - start)) -lt 600 ]; do kill -0 $! > /dev/null 2>&1 || break sleep 30 done kill $! > /dev/null 2>&1 wait while mount | grep -q "on $mntpoint "; do umount $mntpoint || sleep 1 done checkfs /dev/md$mdstart; s=$? mdconfig -d -u $mdstart exit $s diff --git a/tools/test/stress2/misc/burnin.sh b/tools/test/stress2/misc/burnin.sh index 0b6c206cd69b..352cc55426e3 100755 --- a/tools/test/stress2/misc/burnin.sh +++ b/tools/test/stress2/misc/burnin.sh @@ -1,210 +1,209 @@ #!/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. # # Time creating and deleting a number of files once a minute. . ../default.cfg [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 export LANG=C dir=/tmp runtime=1200 # default [ $# -eq 1 ] && runtime=$1 odir=`pwd` cd $dir sed '1,/^EOF/d' < $odir/$0 > $dir/burnin.c mycc -o burnin -Wall -Wextra -O0 -g burnin.c || exit 1 rm -f burnin.c cd $odir 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 1g -u $mdstart || exit 1 -bsdlabel -w md$mdstart auto -newfs -n md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs -n md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint d=`date '+%Y%m%dT%H%M%S'` log=/tmp/burnin.$d.log mode=`pgrep -q cron && echo "Multi-user" || echo "Single-user"` echo "# `uname -a` $mode mode `hostname`" > $log /tmp/burnin -r 10 -d $mntpoint > /dev/null 2>&1 /tmp/burnin -r $runtime -d $mntpoint >> $log ministat -A -C 2 -w 72 $log | tail -1 | awk '{if ($NF > .1) exit(1)}' s=$? [ $s -ne 0 ] && ministat -C 2 -w 72 $log while mount | grep "on $mntpoint " | grep -q /dev/md; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart rm -rf /tmp/burnin $log exit 0 EOF #include #include #include #include #include #include #include #include #include #include #include #include #define DELAY 60 #define SYNC 0 volatile u_int *share; int bufsize, files, parallel, runtime; char *buf, *dir; void usage(void) { fprintf(stderr, "Usage: %s [-b buf size] [-d directory] [-p parallel] " "[-r runtime]\n", getprogname()); _exit(1); } void test(void) { pid_t pid; int fd, i; char path[MAXPATHLEN + 1]; atomic_add_int(&share[SYNC], 1); while (share[SYNC] != (volatile u_int)parallel) ; pid =getpid(); for (i = 0; i < files; i++) { snprintf(path, sizeof(path), "%s/f%06d.%06d", dir, pid, i); if ((fd = open(path, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE)) == -1) err(1, "open(%s)", path); if (write(fd, buf, bufsize) != bufsize) err(1, "write()"); if (close(fd) == -1) err(1, "close(%d)", fd); if (unlink(path) == -1) err(1, "unlink(%s)", path); } _exit(0); } int main(int argc, char *argv[]) { struct timeval t1, t2, diff; struct tm *tp; size_t len; time_t start, now; int ch, e, i, *pids, status; char help[80]; bufsize = 8 * 1024; dir = "/tmp"; files = 5000; parallel = 4; runtime = 1 * 60 * 60 * 24; while ((ch = getopt(argc, argv, "b:d:f:r:")) != -1) switch(ch) { case 'b': /* bufsize */ if (sscanf(optarg, "%d", &bufsize) != 1) usage(); break; case 'd': /* dir */ dir = optarg; break; case 'f': /* files */ if (sscanf(optarg, "%d", &files) != 1) usage(); break; case 'p': /* parallel */ if (sscanf(optarg, "%d", ¶llel) != 1) usage(); break; case 'r': /* runtime */ if (sscanf(optarg, "%d", &runtime) != 1) usage(); break; default: usage(); } argc -= optind; argv += optind; printf("# Options used: dir=%s, bufsize=%d, files=%d, parallel=%d, " "runtime=%d\n", dir, bufsize, files, parallel, runtime); if ((buf = malloc(bufsize)) == NULL) err(1, "malloc(%d)", bufsize); if ((pids = malloc(sizeof(pid_t) * parallel)) == NULL) err(1, "malloc(%d)", (int)(sizeof(pid_t) * parallel)); e = 0; len = PAGE_SIZE; if ((share = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED, -1, 0)) == MAP_FAILED) err(1, "mmap"); start = time(NULL); while ((time(NULL) - start) < runtime && e == 0) { share[SYNC] = 0; gettimeofday(&t1, NULL); for (i = 0; i < parallel; i++) { if ((pids[i] = fork()) == 0) test(); } for (i = 0; i < parallel; i++) { waitpid(pids[i], &status, 0); e += status == 0 ? 0 : 1; } gettimeofday(&t2, NULL); timersub(&t2, &t1, &diff); now = time(NULL); tp = localtime(&now); strftime(help, sizeof(help), "%Y%m%d%H%M%S", tp); printf("%s %ld.%06ld\n", help, (long)diff.tv_sec, diff.tv_usec); fflush(stdout); if (runtime > DELAY) sleep(DELAY); } return (e); } diff --git a/tools/test/stress2/misc/cmp.sh b/tools/test/stress2/misc/cmp.sh index bd492c8493ca..91adf5ea5ab0 100755 --- a/tools/test/stress2/misc/cmp.sh +++ b/tools/test/stress2/misc/cmp.sh @@ -1,187 +1,186 @@ #!/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. # # Cross mount test of mkdir(2). # Page fault seen: # http://people.freebsd.org/~pho/stress/log/cmp.txt # Fixed by r275347 [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > cmp.c mycc -o cmp -Wall -Wextra -O2 -g cmp.c || exit 1 rm -f cmp.c mount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint [ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart mdconfig -a -t swap -s 2g -u $mdstart || exit 1 -bsdlabel -w md$mdstart auto # Don't use SU due to bogus "out of inodes" messages. -newfs md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint daemon sh -c "(cd $here/../testcases/swap; ./swap -t 5m -i 20 -h -l 100)" \ > /dev/null 2>&1 sleep 1 su $testuser -c "/tmp/cmp $mntpoint" & while kill -0 $! 2>/dev/null; do umount -f $mntpoint && - mount /dev/md${mdstart}$part $mntpoint + mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint sleep .1 done wait while mount | grep $mntpoint | grep -q /dev/md; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart [ -d "$mntpoint" ] && (cd $mntpoint && find . -delete) # tmpfs mount -t tmpfs tmpfs $mntpoint chmod 777 $mntpoint su $testuser -c "/tmp/cmp $mntpoint" & while kill -0 $! 2>/dev/null; do umount -f $mntpoint && mount -t tmpfs tmpfs $mntpoint chmod 777 $mntpoint sleep .1 done pkill -9 swap wait while pkill -9 swap; do : done > /dev/null 2>&1 while mount | grep $mntpoint | grep -q tmpfs; do umount $mntpoint || sleep 1 done [ -d "$mntpoint" ] && (cd $mntpoint && find . -delete) rm -f /tmp/cmp exit 0 EOF #include #include #include #include #include #include #include #include #include #include #define LOOPS 160 #define PARALLEL 16 int nbc, nbd; char *dir; void tmkdir(void) { int i, j; char d[MAXPATHLEN + 1], name[MAXPATHLEN + 1]; setproctitle(__func__); i = 0; snprintf(name, sizeof(name), "%s/d1.%05d", dir, getpid()); if (mkdir(name, 0755) == -1) { if (errno != ENAMETOOLONG && errno != ENOENT && errno != EBUSY && errno != EACCES && errno != EPERM) warn("mkdir(%s)", name); _exit(0); } for (;;) { snprintf(d, sizeof(d), "/%d", i++); strncat(name, d, sizeof(name) - 1); if (mkdir(name, 0755) == -1) { if (errno != ENAMETOOLONG && errno != ENOENT && errno != EBUSY && errno != EACCES && errno != EPERM) warn("mkdir(%s)", name); i--; break; } nbc++; } while (i >= 0) { snprintf(name, sizeof(name), "%s/d1.%05d", dir, getpid()); for (j = 0; j < i; j++) { snprintf(d, sizeof(d), "/%d", j); strncat(name, d, sizeof(name) - 1); } if (rmdir(name) == -1) { if (errno != ENOTEMPTY && errno != ENOENT && errno != EBUSY) warn("rmdir(%s)", name); } else nbd++; i--; } #if defined(TEST) if (nbc == 0) fprintf(stderr, "FAIL nbc = %d, nbd = %d\n", nbc, nbd); #endif _exit(0); } int main(int argc, char **argv) { int i, j; if (argc != 2) { fprintf(stderr, "Usage: %s ", argv[0]); exit(1); } dir = argv[1]; for (j = 0; j < LOOPS; j++) { for (i = 0; i < PARALLEL; i++) { if (fork() == 0) tmkdir(); } for (i = 0; i < PARALLEL; i++) wait(NULL); } return(0); } diff --git a/tools/test/stress2/misc/core2.sh b/tools/test/stress2/misc/core2.sh index 4f0e0472af95..2e8396858982 100755 --- a/tools/test/stress2/misc/core2.sh +++ b/tools/test/stress2/misc/core2.sh @@ -1,95 +1,94 @@ #!/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. # # Test multiple (parallel) core dumps and umount [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg odir=`pwd` cd /tmp sed '1,/^EOF/d' < $odir/$0 > core2.c mycc -o core2 -Wall -Wextra -O0 core2.c || exit 1 rm -f core2.c cd $RUNDIR mount | grep "on $mntpoint " | grep -q md$mdstart && umount $mntpoint [ -c /dev/mn$mdstart ] && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint touch /tmp/continue for i in `jot 64`; do mkdir -p $mntpoint/d$i (cd $mntpoint; /tmp/core2) & done rm -f /tmp/continue for i in `jot 60`; do umount $mntpoint 2>/dev/null || sleep 1 mount | grep -q "on $mntpoint " || break done wait mount | grep -q "on $mntpoint " && umount -f $mntpoint mdconfig -d -u $mdstart rm -f /tmp/core2 exit EOF #include #include #include #include #include #include #include #include #define SIZ 1L * 128 * 1024 * 1024 void *p; int main(void) { size_t len; len = SIZ; p = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_ANON, -1, 0); while (access("/tmp/continue", R_OK) == 0) usleep(1); raise(SIGSEGV); return (0); } diff --git a/tools/test/stress2/misc/core3.sh b/tools/test/stress2/misc/core3.sh index 68d55468c087..5d0d0c258651 100755 --- a/tools/test/stress2/misc/core3.sh +++ b/tools/test/stress2/misc/core3.sh @@ -1,171 +1,170 @@ #!/bin/sh # # Copyright (c) 2014 EMC Corp. # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # Test multiple (parallel) core dumps and mount / umount. # mount(8) stuck in "ufs" or "tmpfs". # http://people.freebsd.org/~pho/stress/log/kostik724.txt # Fixed by r272535. # On i386 pgrep(1) loops. Fixed by r272566. # "Sleeping on "pmapdi" with the following non-sleepable locks held:" # https://people.freebsd.org/~pho/stress/log/kostik883.txt [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg odir=`pwd` cd /tmp sed '1,/^EOF/d' < $odir/$0 > core3.c mycc -o core3 -Wall -Wextra -O2 core3.c || exit 1 rm -f core3.c cd $odir mount | grep -q "on $mntpoint " && umount $mntpoint [ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint mkdir $mntpoint/d chmod 777 $mntpoint/d su $testuser -c "/tmp/core3 $mntpoint/d" & pid=$! sleep 1 while pgrep -q core3; do [ -d $mntpoint/d ] && umount -f $mntpoint done > /dev/null 2>&1 & while pgrep -q core3; do [ -d $mntpoint/d ] || - mount /dev/md${mdstart}$part $mntpoint + mount /dev/md$mdstart $mntpoint done > /dev/null 2>&1 wait $pid status=$? mount | grep -q "on $mntpoint " && umount -f $mntpoint mdconfig -d -u $mdstart [ $status -ne 0 ] && exit $status # tmpfs mount -o size=1g -t tmpfs tmpfs $mntpoint su $testuser -c "/tmp/core3 $mntpoint/d" & pid=$! sleep 1 while pgrep -q core3; do [ -d $mntpoint/d ] && umount -f $mntpoint done > /dev/null & while pgrep -q core3; do if [ ! -d $mntpoint/d ]; then mount -t tmpfs tmpfs $mntpoint mkdir $mntpoint/d fi done wait $pid status=$? for i in `jot 5` ; do mount | grep -q "on $mntpoint " || break umount -f $mntpoint sleep 1 done rm -f /tmp/core3 exit $status EOF #include #include #include #include #include #include #include #include #include #define PARALLEL 64 #define SIZ (4 * 1024 * 1024) #define TIMEDOUT 22 void *p; static void hand(int i __unused) { /* handler */ _exit(TIMEDOUT); } void test(char *argv[]) { size_t len; len = SIZ; p = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_ANON, -1, 0); /* * This loop caused mount to wait in "ufs". * Adding a usleep(200) would remove the hang. */ signal(SIGALRM, hand); alarm(600); while (chdir(argv[1]) == -1) ; raise(SIGSEGV); _exit(0); } int main(int argc, char *argv[]) { time_t start; int i, s, status; if (argc != 2) errx(1, "Usage: %s ", argv[0]); status = 0; start = time(NULL); while (time(NULL) - start < 600 && status == 0) { for (i = 0; i < PARALLEL; i++) { if (fork() == 0) test(argv); } for (i = 0; i < PARALLEL; i++) { wait(&s); if (WEXITSTATUS(s) == TIMEDOUT) status = 1; } } return (status); } diff --git a/tools/test/stress2/misc/core4.sh b/tools/test/stress2/misc/core4.sh index e77b5176c261..0f0096e7052b 100755 --- a/tools/test/stress2/misc/core4.sh +++ b/tools/test/stress2/misc/core4.sh @@ -1,87 +1,86 @@ #!/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. # # 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 . ../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 -newfs $newfs_flags md${mdstart}$part > /dev/null +newfs $newfs_flags md$mdstart > /dev/null for i in `jot 20`; do - mount /dev/md${mdstart}$part $mntpoint + mount /dev/md$mdstart $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)mmap(NULL, SIZ, PROT_READ | PROT_WRITE, MAP_ANON, -1, 0); usleep(1000); raise(SIGSEGV); return (0); } diff --git a/tools/test/stress2/misc/core5.sh b/tools/test/stress2/misc/core5.sh index 6dc6ba96b742..856b01608f2e 100755 --- a/tools/test/stress2/misc/core5.sh +++ b/tools/test/stress2/misc/core5.sh @@ -1,199 +1,198 @@ #!/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. # # 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 used to resolve this. # For now change MAXVNODES from 1.000 to 4.000. [ `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 -newfs -b 4096 -f 512 -i 2048 md${mdstart}$part > /dev/null -mount -o async /dev/md${mdstart}$part $mntpoint || exit 1 +newfs -b 4096 -f 512 -i 2048 md$mdstart > /dev/null +mount -o async /dev/md$mdstart $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 4000 #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; unsigned long nv, maxvnodes; int j; 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); } diff --git a/tools/test/stress2/misc/crossmp.sh b/tools/test/stress2/misc/crossmp.sh index 7d1ccbe3a469..0bd07cea2aaf 100755 --- a/tools/test/stress2/misc/crossmp.sh +++ b/tools/test/stress2/misc/crossmp.sh @@ -1,89 +1,88 @@ #!/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. # # 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/crossmp.continue mdstart=$mdstart # Use md unit numbers from this point D=$diskimage if [ $# -eq 0 ]; then touch $cont for i in `jot $mounts`; do m=$(( i + mdstart - 1 )) [ ! -d ${mntpoint}$m ] && mkdir ${mntpoint}$m mount | grep "on ${mntpoint}$m " | 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 status=none mdconfig -a -t vnode -f $D$m -u $m - bsdlabel -w md$m auto - newfs $newfs_flags md${m}$part > /dev/null 2>&1 + newfs $newfs_flags md${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 rm -f $D$m done exit 0 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 for i in `jot 1024`; do m=$1 - mount /dev/md${m}$part ${mntpoint}$m + mount /dev/md${m} ${mntpoint}$m 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 $cont fi fi diff --git a/tools/test/stress2/misc/crossmp10.sh b/tools/test/stress2/misc/crossmp10.sh index 30e64a064dac..7833aec176cb 100755 --- a/tools/test/stress2/misc/crossmp10.sh +++ b/tools/test/stress2/misc/crossmp10.sh @@ -1,104 +1,103 @@ #!/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. # # ext2fs parallel mount & umount test scenario # "panic: vm_fault_hold: fault on nofault entry" seen. # https://people.freebsd.org/~pho/stress/log/crossmp10.txt [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 [ -z "`which mke2fs`" ] && echo "mke2fs not found" && exit 0 . ../default.cfg CONT=/tmp/crossmp10.continue mounts=4 # Number of parallel scripts size=512 # Disk size in MB 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 - mke2fs -m 0 /dev/md${m}$part > /dev/null 2>&1 + mke2fs -m 0 /dev/md${m} > /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 )) while mount | grep -q "on ${mntpoint}$m "; do umount ${mntpoint}$m && break sleep 1 done mdconfig -d -u $m done exit 0 else if [ $1 = find ]; then while [ -f $CONT ]; do find ${mntpoint}* -ls > /dev/null 2>&1 sleep .1 done else export runRUNTIME=30s # The test: Parallel mount and unmounts start=`date '+%s'` while [ $((`date '+%s'` - start)) -lt 300 ]; do m=$1 - mount -t ext2fs /dev/md${m}$part ${mntpoint}$m && + mount -t ext2fs /dev/md${m} ${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 & sleep 2 while mount | grep -q "on ${mntpoint}$m "; do opt=$([ `jot -r 1 0 1` -eq 0 ] && echo "-f") umount $opt ${mntpoint}$m > /dev/null 2>&1 [ -f $CONT ] || break 2 done wait $! done rm -f $CONT ../tools/killall.sh fi fi diff --git a/tools/test/stress2/misc/crossmp11.sh b/tools/test/stress2/misc/crossmp11.sh index 8bc008f6f504..8332b1592675 100755 --- a/tools/test/stress2/misc/crossmp11.sh +++ b/tools/test/stress2/misc/crossmp11.sh @@ -1,121 +1,120 @@ #!/bin/sh # # Copyright (c) 2017 Dell EMC Isilon # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # Copy of crossmp3.sh + elements from dfull.sh # Live lock seen: # https://people.freebsd.org/~pho/stress/log/crossmp11.txt # umount stuck in mnt_ref seen: # https://people.freebsd.org/~pho/stress/log/kostik1002.txt # Fixed by r319518, r319519 and r319539. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg g3=$((3 * 1024 * 1024 * 1024)) CONT=/tmp/crossmp11.continue N=`sysctl -n hw.ncpu` [ $N -gt 4 ] && N=4 usermem=`sysctl -n hw.usermem` [ $usermem -gt $g3 ] && usermem=$g3 [ `sysctl -n vm.swap_total` -eq 0 ] && usermem=$((usermem/100*80)) size=$((usermem / 1024 / 1024 / N)) mounts=$N # Number of parallel scripts if [ $# -eq 0 ]; then echo "Expect: /mnt6: write failed, filesystem is full /mnt6: create/symlink failed, no inodes free" 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 + newfs $newfs_flags md${m} > /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 )) while mount | grep -q "on ${mntpoint}$m "; do umount ${mntpoint}$m && break sleep 1 done mdconfig -d -u $m done exit 0 else if [ $1 = find ]; then while [ -f $CONT ]; do find ${mntpoint}* -type f > /dev/null 2>&1 done else m=$1 export runRUNTIME=20s # The test: Parallel mount and unmounts for i in `jot 3`; do - mount /dev/md${m}$part ${mntpoint}$m && + mount /dev/md${m} ${mntpoint}$m && chmod 777 ${mntpoint}$m export RUNDIR=${mntpoint}$m/stressX export CTRLDIR=${mntpoint}$m/stressX.control (cd ${mntpoint}$m && find . -delete) if [ -z "$KBLOCKS" ]; then r=`df -ik ${mntpoint}$m | tail -1 | awk '{print $4,$7}'` export KBLOCKS=`echo $r | awk '{print $1 * 10}'` export INODES=`echo $r | awk '{print $2 * 10}'` fi 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 diff --git a/tools/test/stress2/misc/crossmp3.sh b/tools/test/stress2/misc/crossmp3.sh index 30c9f86840f1..0f7c01af5569 100755 --- a/tools/test/stress2/misc/crossmp3.sh +++ b/tools/test/stress2/misc/crossmp3.sh @@ -1,108 +1,107 @@ #!/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. # # 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 if [ $# -eq 0 ]; then N=`sysctl -n hw.ncpu` usermem=`sysctl -n hw.usermem` [ `sysctl -n vm.swap_total` -eq 0 ] && usermem=$((usermem / 2)) size=$((usermem / 1024 / 1024 / N)) echo "Using $N memory disks of size $size MB." mounts=$N # Number of parallel scripts 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 + newfs $newfs_flags md${m} > /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 )) while mount | grep -q "on ${mntpoint}$m "; do umount ${mntpoint}$m && break sleep 1 done mdconfig -d -u $m done exit 0 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} ${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 diff --git a/tools/test/stress2/misc/crossmp4.sh b/tools/test/stress2/misc/crossmp4.sh index 7f24097475f3..e22f969b72bb 100755 --- a/tools/test/stress2/misc/crossmp4.sh +++ b/tools/test/stress2/misc/crossmp4.sh @@ -1,107 +1,106 @@ #!/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. # # 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 - 2)) CONT=/tmp/crossmp4.continue mounts=$N # Number of parallel scripts if [ $# -eq 0 ]; then 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 + newfs $newfs_flags md$mdstart > /dev/null 2>&1 + mount /dev/md$mdstart $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 exit 0 else touch $CONT if [ $1 = find ]; then while [ -f $CONT ]; 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 $CONT fi fi diff --git a/tools/test/stress2/misc/crossmp5.sh b/tools/test/stress2/misc/crossmp5.sh index 9a636c9aae45..b5a8304f2dcb 100755 --- a/tools/test/stress2/misc/crossmp5.sh +++ b/tools/test/stress2/misc/crossmp5.sh @@ -1,95 +1,94 @@ #!/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. # # 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 + newfs $newfs_flags md${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 rm -f $D$m done exit 0 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} ${mntpoint}$m chmod 777 ${mntpoint}$m l=`jot -r 1 65535` dd if=/dev/zero of=$mntpoint/$i bs=$l count=100 \ status=none 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 diff --git a/tools/test/stress2/misc/crossmp8.sh b/tools/test/stress2/misc/crossmp8.sh index f8d06d6a4a30..e877dfaf6d1c 100755 --- a/tools/test/stress2/misc/crossmp8.sh +++ b/tools/test/stress2/misc/crossmp8.sh @@ -1,125 +1,124 @@ #!/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. # # 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=3072 > /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 + newfs md${m} > /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)) while mount | grep -q "on ${mntpoint}$m "; do umount ${mntpoint}$m && break sleep 1 done mdconfig -d -u $m done ./cleanup.sh exit 0 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} ${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 diff --git a/tools/test/stress2/misc/crossmp9.sh b/tools/test/stress2/misc/crossmp9.sh index e55f16b5ede4..b049f65aded9 100755 --- a/tools/test/stress2/misc/crossmp9.sh +++ b/tools/test/stress2/misc/crossmp9.sh @@ -1,90 +1,89 @@ #!/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. # # 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}$m " | 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 + newfs $newfs_flags md${m} > /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 exit 0 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} ${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 diff --git a/tools/test/stress2/misc/dangling.sh b/tools/test/stress2/misc/dangling.sh index 5f3db6db00ec..cd807a382375 100755 --- a/tools/test/stress2/misc/dangling.sh +++ b/tools/test/stress2/misc/dangling.sh @@ -1,87 +1,86 @@ #!/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. # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 # "panic: softdep_deallocate_dependencies: dangling deps" seen. # "panic: softdep_write_inodeblock: indirect pointer #0 mismatch" seen. # http://people.freebsd.org/~pho/stress/log/dangling.txt # http://people.freebsd.org/~pho/stress/log/dangling2.txt # https://people.freebsd.org/~pho/stress/log/kostik1101.txt # Test scenario seems optimized for 4 CPUs. . ../default.cfg mount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 4g -u $mdstart || exit 1 -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint || exit 1 +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint || exit 1 chmod 777 $mntpoint export runRUNTIME=4m export RUNDIR=$mntpoint/stressX set `df -ik $mntpoint | tail -1 | awk '{print $4,$7}'` export KBLOCKS=$(($1 / 4)) export INODES=$(($2 / 4)) export symlinkHOG=1 export rwHOG=1 export mkdirHOG=1 export LOAD=100 export symlinkLOAD=100 export rwLOAD=100 export mkdirLOAD=100 export TESTPROGS=" testcases/symlink/symlink testcases/fts/fts testcases/mkdir/mkdir testcases/rw/rw " for i in `jot 10`; do su $testuser -c 'cd ..; ./testcases/run/run $TESTPROGS' > \ /dev/null 2>&1 & sleep 60 kill $! ../tools/killall.sh > /dev/null 2>&1 ../tools/killall.sh > /dev/null 2>&1 wait done s=0 for i in `jot 6`; do umount $mntpoint && break || sleep 10 done [ $i -eq 6 ] && s=1 mdconfig -d -u $mdstart exit $s diff --git a/tools/test/stress2/misc/datamove5.sh b/tools/test/stress2/misc/datamove5.sh index 5f4a868f03b1..49e97570100d 100755 --- a/tools/test/stress2/misc/datamove5.sh +++ b/tools/test/stress2/misc/datamove5.sh @@ -1,262 +1,261 @@ #!/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. # # Variation of the datamove2.sh, using NULLFS # No problems seen. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > datamove5.c mycc -o datamove5 -Wall -Wextra -O2 -g datamove5.c rm -f datamove5.c mp1=$mntpoint mp2=${mntpoint}2 [ -d $mp2 ] || mkdir $mp2 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 -mount /dev/md${mdstart}$part $mp1 +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mp1 mount -t nullfs $opt $mp1 $mp2 chmod 777 $mp2 for i in `jot 5`; do su $testuser -c "cd $mp2; /tmp/datamove5" 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 rm -rf /tmp/datamove5 exit 0 EOF /*- * Copyright (c) 2006, Stephan Uphoff * 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 unmodified, 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 ``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 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. */ #include #include #include #include #include #include #include #include #include int prepareFile(char *filename, int *fdp); int mapBuffer (char **bufferp, int fd1, int fd2); int startIO (int fd, char *buffer); int pagesize; #define FILESIZE (32*1024) char wbuffer [FILESIZE]; /* Create a FILESIZE sized file - then remove file data from the cache */ int prepareFile(char *filename, int *fdp) { int fd; int len; int status; void *addr; fd = open(filename, O_CREAT | O_TRUNC | O_RDWR, S_IRWXU); if (fd == -1) { perror(filename); return fd; } len = write(fd, wbuffer, FILESIZE); if (len < 0) { perror("Write failed"); return 1; } status = fsync(fd); if (status != 0) { perror("fsync failed"); return 1; } addr = mmap(NULL, FILESIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); if (addr == MAP_FAILED) { perror("Mmap failed"); return 1; } status = msync(addr, FILESIZE, MS_INVALIDATE | MS_SYNC); if (status != 0) { perror("Msync failed"); return 1; } if (munmap(addr, FILESIZE) == -1) { perror("munmap failed"); return 1; } *fdp = fd; return 0; } /* mmap a 2 page buffer - first page is from fd1, second page from fd2 */ int mapBuffer(char **bufferp, int fd1, int fd2) { void *addr; char *buffer; addr = mmap(NULL, pagesize * 2, PROT_READ | PROT_WRITE, MAP_SHARED, fd1, 0); if (addr == MAP_FAILED) { perror("Mmap failed"); return 1; } buffer = addr; addr = mmap(buffer + pagesize, pagesize, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_SHARED, fd2, 0); if (addr == MAP_FAILED) { perror("Mmap2 failed"); return 1; } *bufferp = buffer; return 0; } void unmapBuffer(char *bufferp) { if (munmap(bufferp, pagesize * 2) == -1) err(1, "unmap 1. buffer"); /* The following unmaps something random, which could trigger: Program received signal SIGSEGV, Segmentation fault. free (cp=0x28070000) at /usr/src/libexec/rtld-elf/malloc.c:311 */ #if 0 if (munmap(bufferp + pagesize * 2, pagesize * 2) == -1) err(1, "unmap 2. buffer"); #endif } int startIO(int fd, char *buffer) { ssize_t len; len = write(fd, buffer, 2 * pagesize); if (len == -1) { perror("write failed"); return 1; } return 0; } int main() { int fdA, fdB, fdDelayA, fdDelayB; int status; int i; char *bufferA, *bufferB; pid_t pid; pagesize = getpagesize(); for (i = 0; i < 1000; i++) { if ((prepareFile("A", &fdA)) || (prepareFile("B", &fdB)) || (prepareFile("DelayA", &fdDelayA)) || (prepareFile("DelayB", &fdDelayB)) || (mapBuffer(&bufferA, fdDelayA, fdB)) || (mapBuffer(&bufferB, fdDelayB, fdA))) exit(1); pid = fork(); if (pid == 0) { status = startIO(fdA, bufferA); exit(status); } if (pid == -1) { perror("fork"); exit(1); } status = startIO(fdB, bufferB); if (wait(&status) == -1) err(1, "wait"); close(fdA); close(fdB); close(fdDelayA); close(fdDelayB); unmapBuffer(bufferA); unmapBuffer(bufferB); unlink("A"); unlink("B"); unlink("DelayA"); unlink("DelayB"); } exit(status); } diff --git a/tools/test/stress2/misc/devfd.sh b/tools/test/stress2/misc/devfd.sh index 1f5eecece0ca..a1ff329cda1c 100755 --- a/tools/test/stress2/misc/devfd.sh +++ b/tools/test/stress2/misc/devfd.sh @@ -1,130 +1,129 @@ #!/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. # # "panic: vn_lock 0xc65b5828: zero hold count" seen. # Originally found by the iknowthis test suite # by Tavis Ormandy # Fixed by r227952 [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg odir=`pwd` cd /tmp sed '1,/^EOF/d' < $odir/$0 > devfd.c rm -f /tmp/devfd mycc -o devfd -Wall -Wextra -O2 -g devfd.c -lpthread || exit 1 rm -f devfd.c mount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart || exit 1 -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint su $testuser -c "(cd $mntpoint; /tmp/devfd)" while mount | grep $mntpoint | grep -q /dev/md; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart rm -f /tmp/devfd exit EOF #include #include #include #include #include #include #include #include #include int fd[3], fd2[3]; void * thr1(void *arg __unused) { int i, j; char path[80]; for (i = 0; i < 100000; i++) { for (j = 0; j < 3; j++) { if (fd[j] != -1) close(fd[j]); sprintf(path, "fx%d", j); fd[j] = open(path, O_RDWR | O_CREAT, 0640); } } return (0); } void * thr2(void *arg __unused) { int i, j; char path[80]; for (i = 0; i < 100000; i++) { for (j = 0; j < 3; j++) { if (fd2[j] != -1) close(fd2[j]); sprintf(path, "/dev/fd/%d", j); if ((fd2[j] = open(path, O_RDONLY)) != -1) fchflags(fd2[j], UF_NODUMP); } } return (0); } int main(void) { pthread_t p1, p2; int r; close(0); close(1); close(2); if ((r = pthread_create(&p1, NULL, thr1, NULL)) != 0) errc(1, r, "pthread_create"); if ((r = pthread_create(&p2, NULL, thr2, NULL)) != 0) errc(1, r, "pthread_create"); pthread_join(p1, NULL); pthread_join(p2, NULL); return (0); } diff --git a/tools/test/stress2/misc/dfull.sh b/tools/test/stress2/misc/dfull.sh index 100784047dbc..5ee40698a96d 100755 --- a/tools/test/stress2/misc/dfull.sh +++ b/tools/test/stress2/misc/dfull.sh @@ -1,56 +1,55 @@ #!/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. # # 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 +mount | grep "$mntpoint" | grep md$mdstart > /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 +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint export RUNDIR=$mntpoint/stressX set `df -ik $mntpoint | tail -1 | awk '{print $4,$7}'` export KBLOCKS=$(($1 * 10)) export INODES=$(($2 * 10)) export runRUNTIME=20m 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 diff --git a/tools/test/stress2/misc/dtrace.sh b/tools/test/stress2/misc/dtrace.sh index 3521ef3099e5..dc11e67edec5 100755 --- a/tools/test/stress2/misc/dtrace.sh +++ b/tools/test/stress2/misc/dtrace.sh @@ -1,68 +1,67 @@ #!/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. # # Simple dtrace(1) test scenario. # https://people.freebsd.org/~pho/stress/log/dtrace.txt [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg dtrace -n 'dtrace:::BEGIN { exit(0); }' > /dev/null 2>&1 || exit 0 mount | grep "on $mntpoint " | grep -q /dev/md && umount -f $mntpoint [ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart mdconfig -a -t swap -s 2g -u $mdstart -bsdlabel -w md$mdstart auto -newfs md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint export runRUNTIME=5m export RUNDIR=$mntpoint/stressX log=/tmp/dtrace.$$ trap "rm -f $log" EXIT INT dtrace -w -n 'syscall::*read:entry,syscall::*write:entry {\ @rw[execname,probefunc] = count(); }' > $log 2>&1 & pid=$! sleep 1 su $testuser -c 'cd ..; ./run.sh marcus.cfg' > /dev/null 2>&1 kill -INT $pid > /dev/null 2>&1 while pgrep -q dtrace; do pkill dtrace sleep 2 done wait tail -5 $log while mount | grep "on $mntpoint " | grep -q /dev/md; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart kldstat | grep -q dtraceall && kldunload dtraceall.ko exit 0 diff --git a/tools/test/stress2/misc/execpath.sh b/tools/test/stress2/misc/execpath.sh index 4323e3b7d505..22613a948e6b 100755 --- a/tools/test/stress2/misc/execpath.sh +++ b/tools/test/stress2/misc/execpath.sh @@ -1,105 +1,104 @@ #!/bin/sh # # SPDX-License-Identifier: BSD-2-Clause-FreeBSD # # Copyright (c) 2021 Peter Holm # # 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. # # Bug 248184 - readlink("/proc/curproc/file") returns arbitrary correct name for programs with more than one link (name) # Test scenario for D32611 "exec: provide right hardlink name in AT_EXECPATH" . ../default.cfg [ `id -u` -ne 0 ] && echo "Must be root!" && exit 1 dir=/tmp odir=`pwd` cd $dir sed '1,/^EOF/d' < $odir/$0 > $dir/execpath.c mycc -o execpath -Wall -Wextra -O0 -g execpath.c || exit 1 rm -f execpath.c cd $odir set -e mount | grep "on $mntpoint " | grep -q /dev/md && umount -f $mntpoint [ -c /dev/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 +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint set +e cd $mntpoint mkdir d1 d2 cp /bin/sleep . ln sleep d1/sleep ln sleep d2/sleep s=0 for p in $mntpoint/sleep $mntpoint/d1/sleep $mntpoint/d2/sleep; do (cd `dirname $p`; ./`basename $p` 10) & /bin/sleep .2 path=`procstat binary $! | awk "/$!/ {print \\$NF}"` kill $! wait [ "$path" != "$p" ] && { s=1; echo "fail path=$path : prog=$p"; } done mv /tmp/execpath d1 ln d1/execpath d2/execpath r=`./d1/execpath` echo $r | grep -q "/d1/" || { s=1; echo "fail: $r. Expected d1 @ 1"; } r=`./d2/execpath` echo $r | grep -q "/d2/" || { s=1; echo "fail: $r. Expected d2 @ 2"; } r=`(cd d1; ./execpath)` echo $r | grep -q "/d1/" || { s=1; echo "fail: $r. Expected d1 @ 3"; } r=`(cd d2; ./execpath)` echo $r | grep -q "/d2/" || { s=1; echo "fail: $r. Expected d2 @ 4"; } cd $odir for i in `jot 6`; do mount | grep -q "on $mntpoint " || break umount $mntpoint && break || sleep 10 [ $i -eq 6 ] && { echo FATAL; fstat -mf $mntpoint; exit 1; } done mdconfig -d -u $mdstart exit $s EOF /* Test scenario by Tobias Kortkamp */ #include #include #include int main(void) { char pathname[PATH_MAX]; elf_aux_info(AT_EXECPATH, pathname, PATH_MAX); puts(pathname); return 0; } diff --git a/tools/test/stress2/misc/exlock.sh b/tools/test/stress2/misc/exlock.sh index 6e88f9437177..7369f6fe3834 100755 --- a/tools/test/stress2/misc/exlock.sh +++ b/tools/test/stress2/misc/exlock.sh @@ -1,122 +1,121 @@ #!/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. # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 # Simple O_EXLOCK test scenario. . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > exlock.c mycc -o exlock -Wall -Wextra exlock.c || exit 1 rm -f exlock.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 || exit 1 -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint su $testuser -c "cd $mntpoint; /tmp/exlock" while mount | grep $mntpoint | grep -q /dev/md; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart rm -f /tmp/exlock exit EOF #include #include #include #include #include #include char buf[128]; #define PARALLEL 3 static void tst(char *file, int n) { int fd, i; for (i = 0; i < (int)sizeof(buf); i++) buf[i] = '0' + n; for (i = 0; i < 1024 * 1024; i++) { if ((fd = open(file, O_RDWR | O_CREAT | O_APPEND | O_EXLOCK, 0644)) == -1) err(1, "open(%s)", file); if (write(fd, buf, sizeof(buf)) != sizeof(buf)) err(1, "write"); close(fd); } _exit(0); } static void test(void) { int i; char file[80]; snprintf(file, sizeof(file), "f06%d", getpid()); for (i = 0; i < 3; i++) if (fork() == 0) tst(file, i); for (i = 0; i < 3; i++) wait(NULL); unlink(file); _exit(0); } int main(void) { int i; for (i = 0; i < PARALLEL; i++) if (fork() == 0) test(); for (i = 0; i < PARALLEL; i++) wait(NULL); return (0); } diff --git a/tools/test/stress2/misc/ext2fs2.sh b/tools/test/stress2/misc/ext2fs2.sh index a576c582cc7e..748e45a33ffa 100755 --- a/tools/test/stress2/misc/ext2fs2.sh +++ b/tools/test/stress2/misc/ext2fs2.sh @@ -1,55 +1,56 @@ #!/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. # [ `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 mdconfig -a -t swap -s 1g -u $mdstart -bsdlabel -w md$mdstart auto +gpart create -s bsd md$mdstart > /dev/null +gpart add -t freebsd-ufs md$mdstart > /dev/null 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 +# tune2fs -O ^dir_index /dev/md$mdstart +mount -t ext2fs /dev/md${mdstart}a $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 diff --git a/tools/test/stress2/misc/extattr.sh b/tools/test/stress2/misc/extattr.sh index 31027eec696b..bd37c092bda8 100755 --- a/tools/test/stress2/misc/extattr.sh +++ b/tools/test/stress2/misc/extattr.sh @@ -1,95 +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. # # 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 [ -z "`which setfacl`" ] && exit 0 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 && 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 > /dev/null +mount /dev/md$mdstart $mntpoint 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 $mntpoint -tunefs -a enable /dev/md${mdstart}$part -mount /dev/md${mdstart}$part $mntpoint -mount | grep md${mdstart}$part +tunefs -a enable /dev/md$mdstart +mount /dev/md$mdstart $mntpoint +mount | grep md$mdstart 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); } diff --git a/tools/test/stress2/misc/extattr2.sh b/tools/test/stress2/misc/extattr2.sh index 313d4ea26447..3ce10dfbc894 100755 --- a/tools/test/stress2/misc/extattr2.sh +++ b/tools/test/stress2/misc/extattr2.sh @@ -1,94 +1,93 @@ #!/bin/sh # # SPDX-License-Identifier: BSD-2-Clause-FreeBSD # # Copyright (c) 2018 Dell EMC Isilon # # 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. # # [Bug 230962] Kernel panic when writing extended attributes with soft updates # enabled. # "panic: softdep_deallocate_dependencies: dangling deps" seen: # https://people.freebsd.org/~pho/stress/log/kostik1121.txt # Fixed in r343536. # "panic: ffs_truncate3" seen: # https://people.freebsd.org/~pho/stress/log/extattr2.txt [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg [ -z "`which setfacl`" ] && exit 0 here=`pwd` -mount | grep "$mntpoint" | grep -q md${mdstart}$part && umount $mntpoint +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 -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint 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 $mntpoint -tunefs -a enable /dev/md${mdstart}$part -mount /dev/md${mdstart}$part $mntpoint -mount | grep md${mdstart}$part +tunefs -a enable /dev/md$mdstart +mount /dev/md$mdstart $mntpoint +mount | grep md$mdstart export runRUNTIME=10m export RUNDIR=$mntpoint/stressX if [ `jot -r 1 0 1` -eq 1 ]; then set `df -ik $mntpoint | tail -1 | awk '{print $4,$7}'` export KBLOCKS=$(($1 / 2)) export INODES=$(($2 / 2)) fi mkdir -p $RUNDIR chmod 0777 $RUNDIR setfacl -b $RUNDIR setfacl -m user:$testuser:rwx,group:$testuser:rwx $RUNDIR su $testuser -c "cd $here/..; ./run.sh marcus.cfg" & sleep 5 while pgrep -U$testuser -q -f run.sh; do find $RUNDIR | \ xargs -P0 -J% setfacl -m user:$testuser:rwx,group:$testuser:rwx % done > /dev/null 2>&1 wait s=0 for i in `jot 6`; do mount | grep -q "on $mntpoint " || break umount $mntpoint && break || sleep 10 [ $i -eq 6 ] && { echo FAIL; fstat -mf $mntpoint; exit 1; } done -checkfs /dev/md${mdstart}$part || s=1 +checkfs /dev/md$mdstart || s=1 mdconfig -d -u $mdstart || s=2 exit $s diff --git a/tools/test/stress2/misc/extattr_set_fd.sh b/tools/test/stress2/misc/extattr_set_fd.sh index 22bfa52f4813..3982318fe9e0 100755 --- a/tools/test/stress2/misc/extattr_set_fd.sh +++ b/tools/test/stress2/misc/extattr_set_fd.sh @@ -1,79 +1,78 @@ #!/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. # # "panic: kmem_malloc(2069012480): kmem_map too small" seen. # Fixed in r237366. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg [ -z "`which setfacl`" ] && exit 0 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 +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $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); } diff --git a/tools/test/stress2/misc/extattrctl.sh b/tools/test/stress2/misc/extattrctl.sh index dad79023a2fc..14cb44ab72b4 100755 --- a/tools/test/stress2/misc/extattrctl.sh +++ b/tools/test/stress2/misc/extattrctl.sh @@ -1,73 +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. # # Regression test of extattrctl and ACLs on UFS1 FS # Kernel must be compiled with options UFS_EXTATTR and UFS_EXTATTR_AUTOSTART # Scenario by rwatson@ from: # # Newsgroups: lucky.freebsd.current # Subject: Re: setfacl requirements? # Date: Thu, 5 Dec 2002 15:50:02 +0000 (UTC) [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg [ "`sysctl -in kern.features.ufs_extattr`" != "1" ] && { echo "Kernel not build with UFS_EXTATTR"; exit 0; } [ -z "`which setfacl`" ] && exit 0 -mount | grep "$mntpoint" | grep -q md${mdstart}$part && umount $mntpoint +mount | grep "$mntpoint" | grep -q md$mdstart && 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 1 md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs -O 1 md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint 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 $mntpoint -tunefs -a enable /dev/md${mdstart}$part -mount /dev/md${mdstart}$part $mntpoint -mount | grep md${mdstart}$part +tunefs -a enable /dev/md$mdstart +mount /dev/md$mdstart $mntpoint +mount | grep md$mdstart touch $mntpoint/acl-test setfacl -b $mntpoint/acl-test setfacl -m user:nobody:rw-,group:wheel:rw- $mntpoint/acl-test getfacl $mntpoint/acl-test ls -l $mntpoint/acl-test umount $mntpoint mdconfig -d -u $mdstart diff --git a/tools/test/stress2/misc/ffs_blkfree.sh b/tools/test/stress2/misc/ffs_blkfree.sh index 5ea4828429c3..a71a979857ed 100755 --- a/tools/test/stress2/misc/ffs_blkfree.sh +++ b/tools/test/stress2/misc/ffs_blkfree.sh @@ -1,76 +1,75 @@ #!/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. # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg D=$diskimage DUMP=$RUNDIR/dump trap "rm -f $D" EXIT INT dd if=/dev/zero of=$D bs=1m count=1024 status=none || exit 1 -mount | grep "$mntpoint" | grep md${mdstart}$part > /dev/null && +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 -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint mount for i in `jot 10`; do mkdir $mntpoint/d$i for j in `jot 100`; do touch $mntpoint/d$i/f$j done done -dump -L0a -f $DUMP /dev/md${mdstart}$part +dump -L0a -f $DUMP /dev/md$mdstart ls -lf $DUMP while mount | grep -q $mntpoint; do umount $([ $((`date '+%s'` % 2)) -eq 0 ] && echo "-f" || echo "") $mntpoint > /dev/null 2>&1 done for i in `jot 10`; do - newfs $newfs_flags -n md${mdstart}$part > /dev/null - mount /dev/md${mdstart}$part $mntpoint + newfs $newfs_flags -n md$mdstart > /dev/null + mount /dev/md$mdstart $mntpoint (cd $mntpoint; restore -rf $DUMP) rm -rf $mntpoint/* while mount | grep -q $mntpoint; do umount $([ $((`date '+%s'` % 2)) -eq 0 ] && echo "-f" || echo "") $mntpoint > /dev/null 2>&1 done done mdconfig -d -u $mdstart rm -f $D $DUMP diff --git a/tools/test/stress2/misc/ffs_sync.sh b/tools/test/stress2/misc/ffs_sync.sh index aa970839c7b3..c2f4bc962d11 100755 --- a/tools/test/stress2/misc/ffs_sync.sh +++ b/tools/test/stress2/misc/ffs_sync.sh @@ -1,254 +1,253 @@ #!/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. # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 # "ffs_fsync: dirty" seen: # http://people.freebsd.org/~pho/stress/log/ffs_sync.txt . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > ffs_sync.c mycc -o ffs_sync -Wall -Wextra ffs_sync.c || exit 1 rm -f ffs_sync.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 4g -u $mdstart || exit 1 -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint for i in `jot 3`; do su $testuser -c "cd $mntpoint; /tmp/ffs_sync" & sleep 60 killall -q ffs_sync killall -q ffs_sync done while mount | grep $mntpoint | grep -q /dev/md; do umount $mntpoint || sleep 1 done rm -f /tmp/ffs_sync mdconfig -d -u $mdstart exit EOF #include #include #include #include #include #include #include #include #include #include #include #include #include #define PARALLEL 12 #define NRW 1000 #define NFTS 10000 #define NMKDIR 6000 #define NSYMLINK 20000 void slinktest(void) { int i, j; pid_t pid; char file[128]; setproctitle("slink"); pid = getpid(); for (j = 0; j < NSYMLINK; j++) { sprintf(file,"p%05d.%05d", pid, j); if (symlink("/tmp/not/there", file) == -1) { if (errno != EINTR) warn("symlink(%s). %s.%d", file, __FILE__, __LINE__); } } for (i = --j; i >= 0; i--) { sprintf(file,"p%05d.%05d", pid, i); if (unlink(file) == -1) err(3, "unlink(%s)", file); } _exit(0); } void mktest(void) { int i; char path[80]; setproctitle("mkdir"); sprintf(path, "d%06d", getpid()); if (mkdir(path, 0770) == -1) err(1, "mkdir(%s)", path); chdir(path); sprintf(path, "d"); for (i = 0; i < NMKDIR; i++) { if (mkdir(path, 0770) == -1) { warn("mkdir(%s), %s:%d", path, __FILE__, __LINE__); } else chdir(path); } for (i = 0; i < NMKDIR; i++) { chdir(".."); rmdir(path); } chdir(".."); _exit(0); } void rwtest(void) { int fd, i, j; char buf[80], file[80]; setproctitle("rw"); for (i = 0; i < NRW; i++) { sprintf(file, "f%06d.%06d", getpid(), i); if ((fd = open(file, O_CREAT | O_EXCL, 0644)) == -1) err(1, "open(%s)", file); for (j = 0; j < 1024; j++) write(fd, buf, sizeof(buf)); lseek(fd, 0, SEEK_SET); for (j = 0; j < 1024; j++) read(fd, buf, sizeof(buf)); close(fd); } for (i = 0; i < NRW; i++) { sprintf(file, "f%06d.%06d", getpid(), i); if (unlink(file) == -1) warn("unlink(%s)", file); } _exit(0); } void slink(void) { int i; for (i = 0; i < PARALLEL; i++) if (fork() == 0) slinktest(); } void mk(void) { int i; for (i = 0; i < PARALLEL; i++) if (fork() == 0) mktest(); } void rw(void) { int i; for (i = 0; i < PARALLEL; i++) if (fork() == 0) rwtest(); } void ftstest(void) { FTS *fts; FTSENT *p; int ftsoptions, i; char *args[2]; setproctitle("fts"); ftsoptions = FTS_PHYSICAL; args[0] = "."; args[1] = 0; for (i = 0; i < NFTS; i++) { if ((fts = fts_open(args, ftsoptions, NULL)) == NULL) err(1, "fts_open"); while ((p = fts_read(fts)) != NULL) ; if (errno != 0 && errno != ENOENT) err(1, "fts_read"); if (fts_close(fts) == -1) err(1, "fts_close()"); } _exit(0); } void fts(void) { int i; for (i = 0; i < PARALLEL; i++) if (fork() == 0) ftstest(); } int main(void) { int i; slink(); mk(); rw(); fts(); for (i = 0; i < PARALLEL; i++) { wait(NULL); wait(NULL); wait(NULL); wait(NULL); } return (0); } diff --git a/tools/test/stress2/misc/ffs_syncvnode.sh b/tools/test/stress2/misc/ffs_syncvnode.sh index faa9856a8bca..96991ca7904c 100755 --- a/tools/test/stress2/misc/ffs_syncvnode.sh +++ b/tools/test/stress2/misc/ffs_syncvnode.sh @@ -1,59 +1,58 @@ #!/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. # # "panic: flush_newblk_deps: Bad newblk 0xc8d2ac00" seen. # "panic: softdep_deallocate_dependencies: dangling deps" seen with # /mnt: out of inodes. 20130627. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg 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 || exit 1 -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null +newfs $newfs_flags md$mdstart > /dev/null -mount /dev/md${mdstart}$part $mntpoint +mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint export runRUNTIME=20m export RUNDIR=$mntpoint/stressX find -x / -type f > /dev/null 2>&1 & su $testuser -c 'cd ..; ./run.sh disk.cfg' wait while mount | grep $mntpoint | grep -q /dev/md; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart diff --git a/tools/test/stress2/misc/ffs_syncvnode2.sh b/tools/test/stress2/misc/ffs_syncvnode2.sh index 5fd9e4cfe843..a3356183a15d 100755 --- a/tools/test/stress2/misc/ffs_syncvnode2.sh +++ b/tools/test/stress2/misc/ffs_syncvnode2.sh @@ -1,63 +1,62 @@ #!/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. # # Lock seen with: # 1001 61985 61981 0 52 0 9624 1028 ufs D+ 0 0:22,89 mkdir # 1001 61986 61981 0 52 0 9624 1028 ufs D+ 0 0:21,63 mkdir # 1001 61987 61981 0 52 0 9624 1028 ufs D+ 0 0:23,39 mkdir # Fixed in rxxxxxx. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg 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 || exit 1 -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null +newfs $newfs_flags md$mdstart > /dev/null -mount /dev/md${mdstart}$part $mntpoint +mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint export runRUNTIME=20m export RUNDIR=$mntpoint/stressX set `df -ik $mntpoint | tail -1 | awk '{print $4,$7}'` export KBLOCKS=$(($1 * 4)) export INODES=$(($2 * 4)) su $testuser -c '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 diff --git a/tools/test/stress2/misc/fifo.sh b/tools/test/stress2/misc/fifo.sh index 662f09d5d2dc..773ceaedd938 100755 --- a/tools/test/stress2/misc/fifo.sh +++ b/tools/test/stress2/misc/fifo.sh @@ -1,86 +1,85 @@ #!/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. # # Page fault seen. # http://people.freebsd.org/~pho/stress/log/kostik652.txt # Fixed by r259522. # https://people.freebsd.org/~pho/stress/log/kostik863.txt [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg odir=`pwd` cd /tmp sed '1,/^EOF/d' < $odir/$0 > fifo.c rm -f /tmp/fifo mycc -o fifo -Wall -Wextra -O2 -g fifo.c || exit 1 rm -f fifo.c 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 || exit 1 -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint (cd $mntpoint; /tmp/fifo) for i in `jot 10`; do - mount | grep -q md${mdstart}$part && \ + mount | grep -q md$mdstart && \ umount $mntpoint && mdconfig -d -u $mdstart && break sleep 10 done rm -f /tmp/fifo exit EOF #include #include #include #include #include #include #include #include #include int main(void) { if (mkfifo("fifo", 0644) == -1) err(1, "mkfifo"); (void)open("fifo", O_RDWR | O_SHLOCK | O_EXLOCK); (void)open("fifo", 0x60e9f2, 0xc74c65b1db4be370, 0xb64a34df72368759); return (0); } diff --git a/tools/test/stress2/misc/fifo2.sh b/tools/test/stress2/misc/fifo2.sh index 7d32ce063908..9e4a7e632e9d 100755 --- a/tools/test/stress2/misc/fifo2.sh +++ b/tools/test/stress2/misc/fifo2.sh @@ -1,205 +1,204 @@ #!/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. # # Page fault seen # http://people.freebsd.org/~pho/stress/log/kostik654.txt # Fixed by r259521. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg odir=`pwd` cd /tmp sed '1,/^EOF/d' < $odir/$0 > fifo2.c rm -f /tmp/fifo2 mycc -o fifo2 -Wall -Wextra -O2 -g fifo2.c -lpthread || exit 1 rm -f fifo2.c mount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart || exit 1 -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint mkfifo $mntpoint/f chmod 777 $mntpoint/f sleeptime=12 st=`date '+%s'` while [ $((`date '+%s'` - st)) -lt $((10 * sleeptime)) ]; do (cd $mntpoint; /tmp/fifo2) & start=`date '+%s'` while [ $((`date '+%s'` - start)) -lt $sleeptime ]; do pgrep -q fifo2 || break sleep .5 done while pkill -9 fifo2; do :; done wait done for i in `jot 10`; do - mount | grep -q md${mdstart}$part && \ + mount | grep -q md$mdstart && \ umount $mntpoint > /dev/null 2>&1 && mdconfig -d -u $mdstart && break sleep 10 done s=0 -mount | grep -q md${mdstart}$part && +mount | grep -q md$mdstart && { echo "umount $mntpoint failed"; s=1; } rm -f /tmp/fifo2 exit $s 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)) u_int32_t r[N]; static void hand(int i __unused) { /* handler */ _exit(1); } static unsigned long makearg(void) { unsigned int i; unsigned long val; val = arc4random(); i = arc4random() % 100; if (i < 20) val = val & 0xff; if (i >= 20 && i < 40) val = val & 0xffff; if (i >= 40 && i < 60) val = (unsigned long)(r) | (val & 0xffff); #if defined(__LP64__) if (i >= 60) { val = (val << 32) | arc4random(); if (i > 80) val = val & 0x00007fffffffffffUL; } #endif return(val); } static void * calls(void *arg __unused) { unsigned long arg1, arg2, arg3, arg4, arg5, arg6, arg7; int i; for (i = 0;; i++) { arg1 = (unsigned long)(void *)"f"; arg2 = makearg(); arg3 = makearg(); arg4 = makearg(); arg5 = makearg(); arg6 = makearg(); arg7 = makearg(); #if 0 fprintf(stderr, "%2d : syscall(%3d, %lx, %lx, %lx, %lx, %lx, %lx, %lx)\n", i, SYS_open, arg1, arg2, arg3, arg4, arg5, arg6, arg7); usleep(100000); #endif alarm(1); syscall(SYS_open, arg1, arg2, arg3, arg4, arg5, arg6, arg7); } return (0); } int main(void) { struct passwd *pw; struct rlimit limit; pthread_t cp[50]; time_t start; int e, j; if ((pw = getpwnam("nobody")) == NULL) err(1, "no such user: nobody"); if (setgroups(1, &pw->pw_gid) || setegid(pw->pw_gid) || setgid(pw->pw_gid) || seteuid(pw->pw_uid) || setuid(pw->pw_uid)) err(1, "Can't drop privileges to \"nobody\""); endpwent(); limit.rlim_cur = limit.rlim_max = 1000; if (setrlimit(RLIMIT_NPTS, &limit) < 0) err(1, "setrlimit"); signal(SIGALRM, hand); signal(SIGILL, hand); signal(SIGFPE, hand); signal(SIGSEGV, hand); signal(SIGBUS, hand); signal(SIGURG, hand); signal(SIGSYS, hand); signal(SIGTRAP, hand); start = time(NULL); while ((time(NULL) - start) < 120) { if (fork() == 0) { for (j = 0; j < 1; j++) if ((e = pthread_create(&cp[j], NULL, calls, NULL)) != 0) errc(1, e,"pthread_create"); for (j = 0; j < 1; j++) pthread_join(cp[j], NULL); _exit(0); } wait(NULL); } return (0); } diff --git a/tools/test/stress2/misc/fifo3.sh b/tools/test/stress2/misc/fifo3.sh index 04fca483eabf..4ffd34e2f424 100755 --- a/tools/test/stress2/misc/fifo3.sh +++ b/tools/test/stress2/misc/fifo3.sh @@ -1,209 +1,208 @@ #!/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. # # Demonstrate that fts_read(3) will open a fifo for read. # Not seen on a pristine FreeBSD. # $ while ./fifo.sh; do date; done # Wed Oct 1 14:07:41 CEST 2014 # Wed Oct 1 14:09:58 CEST 2014 # FAIL # $ ps -l19547 # UID PID PPID CPU PRI NI VSZ RSS MWCHAN STAT TT TIME COMMAND # 0 19547 19544 0 25 0 12176 3996 fifoor I 0 0:08.19 /tmp/fifo # $ gdb /tmp/fifo 19547 # GNU gdb 6.1.1 [FreeBSD] # Copyright 2004 Free Software Foundation, Inc. # GDB is free software, covered by the GNU General Public License, and you are # welcome to change it and/or distribute copies of it under certain conditions. # Type "show copying" to see the conditions. # There is absolutely no warranty for GDB. Type "show warranty" for details. # This GDB was configured as "amd64-marcel-freebsd"... # Attaching to program: /tmp/fifo, process 19547 # Reading symbols from /lib/libc.so.7...done. # Loaded symbols for /lib/libc.so.7 # Reading symbols from /libexec/ld-elf.so.1...done. # Loaded symbols for /libexec/ld-elf.so.1 # 0x00000008008a9ab8 in enc_openat () from /lib/libc.so.7 # (gdb) bt # #0 0x00000008008a9ab8 in enc_openat () from /lib/libc.so.7 # #1 0x00000008008a581b in fts_read () from /lib/libc.so.7 # #2 0x00000008008a4f24 in fts_read () from /lib/libc.so.7 # #3 0x0000000000400ee9 in test () at /tmp/fifo.c:86 # #4 0x0000000000400fd8 in main () at /tmp/fifo.c:108 # (gdb) f 3 # #3 0x0000000000400ee9 in test () at /tmp/fifo.c:86 # 86 while ((p = fts_read(fts)) != NULL) { # Current language: auto; currently minimal # (gdb) # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg cat > /tmp/fifo3.c < #include #include #include #include #include #include #include #include #include #define LOOPS 50 #define PARALLEL 4 void tmkfifo(void) { pid_t pid; int i, j; char name[80]; setproctitle(__func__); pid = getpid(); for (j = 0; j < LOOPS; j++) { for (i = 0; i < 1000; i++) { snprintf(name, sizeof(name), "fifo.%d.%06d", pid, i); if (mkfifo(name, 0644) == -1) err(1, "mkfifo(%s)", name); } for (i = 0; i < 1000; i++) { snprintf(name, sizeof(name), "fifo.%d.%06d", pid, i); if (unlink(name) == -1) err(1, "unlink(%s)", name); } } _exit(0); } void tmkdir(void) { pid_t pid; int i, j; char name[80]; setproctitle(__func__); pid = getpid(); for (j = 0; j < LOOPS; j++) { for (i = 0; i < 1000; i++) { snprintf(name, sizeof(name), "dir.%d.%06d", pid, i); if (mkdir(name, 0644) == -1) err(1, "mkdir(%s)", name); } for (i = 0; i < 1000; i++) { snprintf(name, sizeof(name), "dir.%d.%06d", pid, i); if (rmdir(name) == -1) err(1, "unlink(%s)", name); } } _exit(0); } void test(void) { FTS *fts; FTSENT *p; int ftsoptions, i; char *args[2]; if (fork() == 0) tmkfifo(); if (fork() == 0) tmkdir(); ftsoptions = FTS_PHYSICAL; args[0] = "."; args[1] = 0; for (i = 0; i < LOOPS; i++) { if ((fts = fts_open(args, ftsoptions, NULL)) == NULL) err(1, "fts_open"); while ((p = fts_read(fts)) != NULL) { #if defined(TEST) fprintf(stdout, "%s\n", p->fts_path); #endif } if (errno != 0 && errno != ENOENT) err(1, "fts_read"); if (fts_close(fts) == -1) err(1, "fts_close()"); } wait(NULL); wait(NULL); _exit(0); } int main(void) { int i; for (i = 0; i < PARALLEL; i++) if (fork() == 0) test(); for (i = 0; i < PARALLEL; i++) wait(NULL); return (0); } EOF mycc -o /tmp/fifo3 -Wall -Wextra -O0 -g /tmp/fifo3.c || exit 1 mount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint [ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart || exit 1 -bsdlabel -w md$mdstart auto -newfs md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint (cd $mntpoint; /tmp/fifo3 ) & while pgrep -q fifo3; do ps -lx | grep -v grep | grep -q fifoor && { echo FAIL; exit 1; } sleep 2 done wait while mount | grep $mntpoint | grep -q /dev/md; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart rm /tmp/fifo3 /tmp/fifo3.c diff --git a/tools/test/stress2/misc/flock.sh b/tools/test/stress2/misc/flock.sh index 451fec4b518a..cbb07e14085d 100755 --- a/tools/test/stress2/misc/flock.sh +++ b/tools/test/stress2/misc/flock.sh @@ -1,191 +1,190 @@ #!/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. # # flock(2) read (shared) lock test. # FAIL: Unfair scheduling? # share[1] = 359171 # share[2] = 394437 # share[3] = 359488 # share[4] = 394429 # share[5] = 359441 # share[6] = 394281 # share[7] = 359314 # share[8] = 394615 . ../default.cfg [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 dir=/tmp odir=`pwd` cd $dir sed '1,/^EOF/d' < $odir/$0 > $dir/flock.c mycc -o flock -Wall -Wextra -O0 -g flock.c || exit 1 rm -f flock.c cd $odir 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 1g -u $mdstart || exit 1 -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint (cd $mntpoint; /tmp/flock) e=$? while mount | grep "on $mntpoint " | grep -q /dev/md; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart rm -rf /tmp/flock exit $e EOF #include #include #include #include #include #include #include #include #include #include #include #include #include volatile u_int *share; int fd; #define RENDEZVOUS 0 #define CHILDREN 8 #define LOOPS 8000 #define PARALLEL 1 #define RUNTIME (1 * 60) void chld(int id) { while (share[RENDEZVOUS] == 0) ; while (share[RENDEZVOUS] == 1) { if (flock(fd, LOCK_SH) == -1) err(1, "fcntl @ %d", __LINE__); atomic_add_int(&share[id + 1], 1); if (flock(fd, LOCK_UN) == -1) err(1, "fcntl @ %d", __LINE__); usleep(100); } _exit(0); } void test(void) { int i; char file[80]; snprintf(file, sizeof(file), "file.%05d", getpid()); if ((fd = open(file, O_RDWR | O_CREAT, 0640)) == -1) err(1, "open(%s)", file); if (flock(fd, LOCK_EX) == -1) err(1, "fcntl @ %d", __LINE__); for (i = 0; i < CHILDREN; i++) { if (fork() == 0) chld(i); } usleep(200); atomic_add_int(&share[RENDEZVOUS], 1); /* start chld */ for (i = 0; i < LOOPS; i++) { if (flock(fd, LOCK_UN) == -1) err(1, "fcntl @ %d", __LINE__); if (flock(fd, LOCK_EX) == -1) err(1, "fcntl @ %d", __LINE__); } atomic_add_int(&share[RENDEZVOUS], 1); /* stop chld */ for (i = 0; i < CHILDREN; i++) wait(NULL); close(fd); unlink(file); _exit(0); } int main(void) { size_t len; time_t start; int i, n, pct; len = getpagesize(); if ((share = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED, -1, 0)) == MAP_FAILED) err(1, "mmap"); start = time(NULL); while ((time(NULL) - start) < RUNTIME) { share[RENDEZVOUS] = 0; for (i = 0; i < PARALLEL; i++) { if (fork() == 0) test(); } for (i = 0; i < PARALLEL; i++) wait(NULL); } n = 0; for (i = 0; i < CHILDREN; i++) n += share[i + 1]; n /= CHILDREN; for (i = 0; i < CHILDREN; i++) { pct = abs((int)share[i + 1] - n) * 100 / n; if (pct > 1) { fprintf(stderr, "Unfair scheduling?\n"); for (i = 0; i < CHILDREN; i++) { pct = abs((int)share[i + 1] - n) * 100 / n; fprintf(stderr, "share[%d] = %d\n", i+1, share[i+1]); } break; } } return (0); } diff --git a/tools/test/stress2/misc/flock_open_close.sh b/tools/test/stress2/misc/flock_open_close.sh index 2b70d41aa4f8..01e376319abe 100755 --- a/tools/test/stress2/misc/flock_open_close.sh +++ b/tools/test/stress2/misc/flock_open_close.sh @@ -1,173 +1,172 @@ #!/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. # # Demonstrate that close() of an flock'd file is not atomic. # Fails with "flock_open_close: execv(/mnt/test): Text file busy" # Test scenario by: jhb [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg odir=`pwd` cd /tmp sed '1,/^EOF/d' < $odir/$0 > flock_open_close.c rm -f /tmp/flock_open_close mycc -o flock_open_close -Wall -Wextra -O2 -g flock_open_close.c -lpthread || exit 1 rm -f flock_open_close.c mount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart || exit 1 -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint cp /bin/test $mntpoint chown $testuser $mntpoint/test chmod +w $mntpoint/test su $testuser -c "/tmp/flock_open_close $mntpoint/test" & pid=$! while kill -0 $! 2>/dev/null; do mksnap_ffs $mntpoint $mntpoint/.snap/snap sleep 2 rm -f $mntpoint/.snap/snap sleep 1 done wait $pid s=$? for i in `jot 10`; do - mount | grep -q md${mdstart}$part && \ + mount | grep -q md$mdstart && \ umount $mntpoint && mdconfig -d -u $mdstart && break sleep 2 done -if mount | grep -q md${mdstart}$part; then +if mount | grep -q md$mdstart; then fstat $mntpoint echo "umount $mntpoint failed" exit 1 fi rm -f /tmp/flock_open_close exit $s EOF #include #include #include #include #include #include #include #include #include static void usage(void) { fprintf(stderr, "Usage: flock_close_race [args]\n"); exit(1); } static void child(const char *binary) { int fd; /* Exit as soon as our parent exits. */ while (getppid() != 1) { fd = open(binary, O_RDWR | O_EXLOCK); if (fd < 0) { /* * This may get ETXTBSY since exit() will * close its open fd's (thus releasing the * lock), before it releases the vmspace (and * mapping of the binary). */ if (errno == ETXTBSY) continue; err(2, "can't open %s", binary); } close(fd); } exit(0); } static void exec_child(char **av) { (void)open(av[0], O_RDONLY | O_SHLOCK); execv(av[0], av); /* "flock_open_close: execv(/mnt/test): Text file busy" seen */ err(127, "execv(%s)", av[0]); } int main(int ac, char **av) { struct stat sb; pid_t pid; int e, i, status; if (ac < 2) usage(); if (stat(av[1], &sb) != 0) err(1, "stat(%s)", av[1]); if (!S_ISREG(sb.st_mode)) errx(1, "%s not an executable", av[1]); pid = fork(); if (pid < 0) err(1, "fork"); if (pid == 0) child(av[1]); e = 0; for (i = 0; i < 200000; i++) { pid = fork(); if (pid < 0) err(1, "vfork"); if (pid == 0) exec_child(av + 1); wait(&status); if (WIFEXITED(status) && WEXITSTATUS(status) == 127) { fprintf(stderr, "FAIL\n"); e = 1; break; } if (WIFEXITED(status) && WEXITSTATUS(status) != 1) { /* /bin/test returns 1 */ e = 1; break; } } return (e); } diff --git a/tools/test/stress2/misc/forkbomb.sh b/tools/test/stress2/misc/forkbomb.sh index 9638fe796fee..73a3c5f37fe2 100755 --- a/tools/test/stress2/misc/forkbomb.sh +++ b/tools/test/stress2/misc/forkbomb.sh @@ -1,148 +1,147 @@ #!/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. # # Fork bomb memory leak test scenario. # https://en.wikipedia.org/wiki/Fork_bomb # OO memory seen: # https://people.freebsd.org/~pho/stress/log/forkbomb.txt # Fixed by r289026. . ../default.cfg [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 dir=/tmp odir=`pwd` cd $dir sed '1,/^EOF/d' < $odir/$0 > $dir/forkbomb.c mycc -o forkbomb -Wall -Wextra -O0 -g forkbomb.c || exit 1 rm -f forkbomb.c cd $odir 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 512m -u $mdstart || exit 1 -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint su $testuser -c /tmp/forkbomb while mount | grep "on $mntpoint " | grep -q /dev/md; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart rm -rf /tmp/forkbomb exit 0 EOF #include #include #include #include #include #include #include #include #include #include volatile u_int *share; #define R1 1 /* sync start */ #define R2 2 /* forks */ #define R3 3 /* exits */ #define R4 4 /* fork failed */ //#define DEBUG #define MXFAIL 100 #define MAXPROC 40000 /* Arbitrary cap */ #define PARALLEL 200 void test(void) { int r; alarm(1200); atomic_add_int(&share[R1], 1); while (share[R1] != PARALLEL) ; atomic_add_int(&share[R2], 1); for (;;) { if (share[R2] >= MAXPROC || share[R4] > MXFAIL) break; atomic_add_int(&share[R2], 1); if ((r = fork()) == -1) { atomic_add_int(&share[R4], 1); atomic_add_int(&share[R2], -1); break; } } atomic_add_int(&share[R3], 1); _exit(0); } int main(void) { struct sigaction sa; size_t len; int i; alarm(1200); len = PAGE_SIZE; if ((share = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED, -1, 0)) == MAP_FAILED) err(1, "mmap"); sa.sa_handler = SIG_IGN; sigemptyset(&sa.sa_mask); sa.sa_flags = 0; if (sigaction(SIGCHLD, &sa, 0) == -1) err(1, "sigaction"); for (i = 0; i < PARALLEL; i++) { if (fork() == 0) test(); } while (share[R2] == 0 || share[R3] < share[R2]) sleep(1); #if defined(DEBUG) fprintf(stderr, "MAXPROC: %d. forks: %u / exits: %u / fails: %u\n", MAXPROC, share[R2], share[R3], share[R4]); #endif return (0); } diff --git a/tools/test/stress2/misc/fragments.sh b/tools/test/stress2/misc/fragments.sh index ea1d095081c6..56d95d9cf8d9 100755 --- a/tools/test/stress2/misc/fragments.sh +++ b/tools/test/stress2/misc/fragments.sh @@ -1,275 +1,274 @@ #!/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. # # 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 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 +newfs $newfs_flags -m 0 md$mdstart > /dev/null 2>&1 +mount /dev/md$mdstart $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 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); } diff --git a/tools/test/stress2/misc/fs.sh b/tools/test/stress2/misc/fs.sh index dde3f39ed3ef..40cd8bd0917a 100755 --- a/tools/test/stress2/misc/fs.sh +++ b/tools/test/stress2/misc/fs.sh @@ -1,91 +1,90 @@ #!/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. # # 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 flag=/tmp/fs.sh.flag ftest () { # option, disk full local args="$@" [ $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 + newfs $1 md$mdstart > /dev/null + mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint export RUNDIR=$mntpoint/stressX export runRUNTIME=1m 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 & sleep 60 ../tools/killall.sh wait done for i in `jot 6`; do mount | grep -q "on $mntpoint " || break umount $mntpoint && break || sleep 10 if [ $i -eq 6 ]; then touch $flag echo "Test \"$args\" FAIL" fstat -mf $mntpoint umount -f $mntpoint fi done - checkfs /dev/md${mdstart}$part || touch $flag + checkfs /dev/md$mdstart || touch $flag } -mount | grep "on $mntpoint " | grep -q md${mdstart}$part && umount $mntpoint +mount | grep "on $mntpoint " | grep -q md$mdstart && umount $mntpoint [ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart 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 [ -f $flag ] && s=1 || s=0 rm -f $flag exit $s diff --git a/tools/test/stress2/misc/ftruncate2.sh b/tools/test/stress2/misc/ftruncate2.sh index c8c89e7ea5bd..35db3a4c5f8d 100755 --- a/tools/test/stress2/misc/ftruncate2.sh +++ b/tools/test/stress2/misc/ftruncate2.sh @@ -1,205 +1,204 @@ #!/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. # # 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 -newfs md${mdstart}$part > /dev/null # Non SU panics -mount /dev/md${mdstart}$part $mntpoint +newfs md$mdstart > /dev/null # Non SU panics +mount /dev/md$mdstart $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 #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(); 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); } diff --git a/tools/test/stress2/misc/fts.sh b/tools/test/stress2/misc/fts.sh index b823517f7c3c..84d89ddc9e9e 100755 --- a/tools/test/stress2/misc/fts.sh +++ b/tools/test/stress2/misc/fts.sh @@ -1,144 +1,143 @@ #!/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. # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 # Run with marcus.cfg on a 1g swap backed MD # "panic: vm_radix_remove: invalid key found" seen. . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > fts1.c mycc -o fts1 -Wall -Wextra fts1.c || exit 1 rm -f fts1.c cd $here mount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart || exit 1 -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null +newfs $newfs_flags md$mdstart > /dev/null -mount /dev/md${mdstart}$part $mntpoint +mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint export runRUNTIME=20m export RUNDIR=$mntpoint/stressX su $testuser -c 'cd ..; ./run.sh marcus.cfg' > /dev/null & pid=$! while kill -0 $pid 2> /dev/null; do /tmp/fts1 $mntpoint sleep 1 done wait s=0 for i in `jot 6`; do umount $mntpoint && break || sleep 10 done [ $i -eq 6 ] && s=1 mdconfig -d -u $mdstart rm -f /tmp/fts1 exit $s EOF #include #include #include #include #include #include #include #include #include #include int test(char *path) { FTS *fts; FTSENT *p; int ftsoptions; char *args[2]; ftsoptions = FTS_PHYSICAL; args[0] = path; args[1] = 0; if ((fts = fts_open(args, ftsoptions, NULL)) == NULL) err(1, "fts_open"); while ((p = fts_read(fts)) != NULL) { switch (p->fts_info) { case FTS_F: /* Ignore. */ break; case FTS_D: /* Ignore. */ break; case FTS_DP: break; case FTS_DC: /* Ignore. */ break; case FTS_SL: /* Ignore. */ break; case FTS_DNR: /* Warn, continue. */ case FTS_ERR: case FTS_NS: case FTS_DEFAULT: break; default: printf("%s: default, %d\n", getprogname(), p->fts_info); break; } } if (errno != 0 && errno != ENOENT) err(1, "fts_read"); if (fts_close(fts) == -1) err(1, "fts_close()"); return (0); } int main(int argc, char **argv) { int i; if (argc != 2) errx(1, "Usage: %s ", argv[0]); alarm(600); for (i = 0; i < 100; i++) test(argv[1]); return (0); } diff --git a/tools/test/stress2/misc/fts2.sh b/tools/test/stress2/misc/fts2.sh index d155393e66ba..b19ae1c68e7c 100755 --- a/tools/test/stress2/misc/fts2.sh +++ b/tools/test/stress2/misc/fts2.sh @@ -1,285 +1,284 @@ #!/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. # # Show invalid fts_info value: # FAULT # -rw------- 1 root wheel - 4 13 jan 09:25 ./lockf.0.3676 # fts_path: ./lockf.0.3676 # fts_info: 13 FTS_SLNONE # fts_errno: 0 No error: 0 [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg cat > /tmp/fts2.c < #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define LOOPS 1 #define PARALLEL 7 pid_t pid; time_t start; int fd; char file[128]; char *txt[] = { "NULL", "FTS_D", "FTS_DC", "FTS_DEFAULT", "FTS_DNR", "FTS_DOT", "FTS_DP", "FTS_ERR", "FTS_F", "FTS_INIT", "FTS_NS", "FTS_NSOK", "FTS_SL", "FTS_SLNONE", "FTS_W", "15", "16", "17", }; int get(void) { int sem; if (lockf(fd, F_LOCK, 0) == -1) err(1, "lockf(%s, F_LOCK)", file); if (read(fd, &sem, sizeof(sem)) != sizeof(sem)) err(1, "get: read(%d)", fd); if (lseek(fd, 0, SEEK_SET) == -1) err(1, "lseek"); if (lockf(fd, F_ULOCK, 0) == -1) err(1, "lockf(%s, F_ULOCK)", file); return (sem); } void incr(void) { int sem; if (lockf(fd, F_LOCK, 0) == -1) err(1, "lockf(%s, F_LOCK)", file); if (read(fd, &sem, sizeof(sem)) != sizeof(sem)) err(1, "incr: read(%d)", fd); if (lseek(fd, 0, SEEK_SET) == -1) err(1, "lseek"); sem++; if (write(fd, &sem, sizeof(sem)) != sizeof(sem)) err(1, "incr: read"); if (lseek(fd, 0, SEEK_SET) == -1) err(1, "lseek"); if (lockf(fd, F_ULOCK, 0) == -1) err(1, "lockf(%s, F_ULOCK)", file); } void tlockf(void) { int i; int sem = 0; usleep(arc4random() % 10000); sprintf(file, "lockf.0.%d", getpid()); if ((fd = open(file,O_CREAT | O_TRUNC | O_RDWR, 0600)) == -1) err(1, "creat(%s)", file); if (write(fd, &sem, sizeof(sem)) != sizeof(sem)) err(1, "write"); if (lseek(fd, 0, SEEK_SET) == -1) err(1, "lseek"); pid = fork(); if (pid == -1) { perror("fork"); exit(2); } if (pid == 0) { /* child */ for (i = 0; i < 100; i++) { while ((get() & 1) == 0) ; incr(); } exit(0); } else { /* parent */ for (i = 0; i < 100; i++) { while ((get() & 1) == 1) ; incr(); } } close(fd); waitpid(pid, &i, 0); unlink(file); } void tmkdir(void) { pid_t pid; int i, j; char name[80]; setproctitle(__func__); usleep(arc4random() % 10000); pid = getpid(); for (j = 0; j < LOOPS; j++) { for (i = 0; i < 1000; i++) { snprintf(name, sizeof(name), "dir.%d.%06d", pid, i); if (mkdir(name, 0644) == -1) err(1, "mkdir(%s)", name); } for (i = 0; i < 1000; i++) { snprintf(name, sizeof(name), "dir.%d.%06d", pid, i); if (rmdir(name) == -1) err(1, "unlink(%s)", name); } } } void tfts(void) { FTS *fts; FTSENT *p; int ftsoptions, i; char *args[2]; char help[80]; usleep(arc4random() % 10000); ftsoptions = FTS_LOGICAL; args[0] = "."; args[1] = 0; for (i = 0; i < 10; i++) { if ((fts = fts_open(args, ftsoptions, NULL)) == NULL) err(1, "fts_open"); while ((p = fts_read(fts)) != NULL) { if (p->fts_info == FTS_D || /* preorder directory */ p->fts_info == FTS_DNR || /* unreadable directory */ p->fts_info == FTS_DOT || /* dot or dot-dot */ p->fts_info == FTS_DP || /* postorder directory */ p->fts_info == FTS_F || /* regular file */ p->fts_info == FTS_NS) /* stat(2) failed */ continue; fprintf(stderr, "FAULT\n"); sprintf(help, "ls -lo %s", p->fts_path); system(help); fprintf(stderr, "fts_path: %s\n", p->fts_path); fprintf(stderr, "fts_info: %d %s\n", p->fts_info, txt[p->fts_info]); fprintf(stderr, "fts_errno: %d %s\n", p->fts_errno, strerror(p->fts_errno)); } if (errno != 0 && errno != ENOENT) err(1, "fts_read"); if (fts_close(fts) == -1) err(1, "fts_close()"); } } void test(void) { start = time(NULL); if (fork() == 0) { while (time(NULL) - start < 60) tmkdir(); _exit(0); } if (fork() == 0) { while (time(NULL) - start < 60) tlockf(); _exit(0); } if (fork() == 0) { while (time(NULL) - start < 60) tfts(); _exit(0); } wait(NULL); wait(NULL); wait(NULL); _exit(0); } int main(void) { int i; for (i = 0; i < PARALLEL; i++) if (fork() == 0) test(); for (i = 0; i < PARALLEL; i++) wait(NULL); return (0); } EOF mycc -o /tmp/fts2 -Wall -Wextra -O0 -g /tmp/fts2.c || exit 1 mount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint [ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart || exit 1 -bsdlabel -w md$mdstart auto -newfs md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint (cd $mntpoint; /tmp/fts2) while mount | grep $mntpoint | grep -q /dev/md; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart rm /tmp/fts2 /tmp/fts2.c diff --git a/tools/test/stress2/misc/fts3.sh b/tools/test/stress2/misc/fts3.sh index 4cb75d8bf6e6..ed15fa451347 100755 --- a/tools/test/stress2/misc/fts3.sh +++ b/tools/test/stress2/misc/fts3.sh @@ -1,133 +1,132 @@ #!/bin/sh # # Copyright (c) 2017 Dell EMC Isilon # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 # No problems seen. . ../default.cfg [ -d /usr/include ] || exit 0 here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > fts3.c mycc -o fts3 -Wall -Wextra fts3.c || exit 1 rm -f fts3.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 3g -u $mdstart || exit 1 -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint start=`date '+%s'` while [ $((`date '+%s'` - start)) -lt 120 ]; do pids= for i in `jot 20`; do cp -r /usr/include $mntpoint/$i & pids="$pids $!" done for p in $pids; do wait $p done (cd $mntpoint && rm -rf *) done & pid=$! s=0 while kill -0 $pid 2> /dev/null; do /tmp/fts3 $mntpoint || { s=1; break; } done kill $pid > /dev/null 2>&1 wait $pid for i in `jot 6`; do umount $mntpoint && break || sleep 10 done [ $i -eq 6 ] && s=2 mdconfig -d -u $mdstart rm -f /tmp/fts3 exit $s EOF #include #include #include #include #include #include #include #include #include #include int test(char *path) { FTS *fts; FTSENT *p; int ftsoptions; char *args[2]; ftsoptions = FTS_PHYSICAL; args[0] = path; args[1] = 0; if ((fts = fts_open(args, ftsoptions, NULL)) == NULL) err(1, "fts_open"); while ((p = fts_read(fts)) != NULL) ; if (errno != 0 && errno != ENOENT) err(1, "fts_read"); if (fts_close(fts) == -1) err(1, "fts_close()"); return (0); } int main(int argc, char **argv) { int i; if (argc != 2) { fprintf(stderr, "Usage: %s \n", argv[0]); exit(1); } alarm(120); for (i = 0; i < 100; i++) test(argv[1]); return (0); } diff --git a/tools/test/stress2/misc/full.sh b/tools/test/stress2/misc/full.sh index ec99ff88138a..cc6085d77e4e 100755 --- a/tools/test/stress2/misc/full.sh +++ b/tools/test/stress2/misc/full.sh @@ -1,67 +1,66 @@ #!/bin/sh # # Copyright (c) 2016 Dell EMC # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 # Run all tests from testcases on a 2g swap backed MD with UFS SU fs. # "panic: SACK scoreboard must not be empty" seen: # https://people.freebsd.org/~pho/stress/log/full.txt # Fixed by r310547. . ../default.cfg kldstat -v | grep -q pty || kldload pty # ignore any load failure mount | grep "on $mntpoint " | grep -q /dev/md && umount -f $mntpoint [ -c /dev/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 +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint export LOAD=80 export rwLOAD=80 export runRUNTIME=10m export RUNDIR=$mntpoint/stressX export MAXSWAPPCT=80 export TESTPROGS=`cd ..; find testcases/ -perm -1 -type f | \ egrep -v "/run/"` su $testuser -c 'cd ..; ./testcases/run/run $TESTPROGS' ../tools/killall.sh for i in `jot 6`; do mount | grep -q "on $mntpoint " || break umount $mntpoint && break || sleep 10 [ $i -eq 6 ] && { echo FATAL; fstat -mf $mntpoint; exit 1; } done -checkfs /dev/md${mdstart}$part; s=$? +checkfs /dev/md$mdstart; s=$? mdconfig -d -u $mdstart exit $s diff --git a/tools/test/stress2/misc/fuzz.sh b/tools/test/stress2/misc/fuzz.sh index bfe783752280..189cdbfebd01 100755 --- a/tools/test/stress2/misc/fuzz.sh +++ b/tools/test/stress2/misc/fuzz.sh @@ -1,180 +1,179 @@ #!/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. # # 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 + newfs -b 8192 -f 1024 $newfs_flags /dev/md$mdstart > /dev/null 2>&1 + mount /dev/md$mdstart $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 + if fsck -f -y /dev/md$mdstart 2>&1 | egrep "^[A-Z]" > /dev/null; then + if fsck -f -y /dev/md$mdstart 2>&1 | egrep "^[A-Z]" > /dev/null; then + if fsck -f -y /dev/md$mdstart 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 + if mount /dev/md$mdstart $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 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 static void usage(void) { fprintf(stderr, "%s {-n \n", getprogname()); exit(1); } static long random_long(long mi, long ma) { return (arc4random() % (ma - mi + 1) + mi); } int main(int argc, char **argv) { long pos; int ch, fd, i, times = 1, verbose = 0; 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); } diff --git a/tools/test/stress2/misc/getrandom.sh b/tools/test/stress2/misc/getrandom.sh index fe30a688decb..3b2de3ec2a7a 100755 --- a/tools/test/stress2/misc/getrandom.sh +++ b/tools/test/stress2/misc/getrandom.sh @@ -1,142 +1,141 @@ #!/bin/sh # # SPDX-License-Identifier: BSD-2-Clause-FreeBSD # # Copyright (c) 2019 Dell EMC Isilon # # 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. # # getrandom() non threaded test # Reset seen on i386 . ../default.cfg [ `id -u` -ne 0 ] && echo "Must be root!" && exit 1 [ `uname -m` = "i386" ] || exit 0 dir=/tmp odir=`pwd` cd $dir sed '1,/^EOF/d' < $odir/$0 > $dir/getrandom.c mycc -o getrandom -Wall -Wextra -O0 -g getrandom.c || exit 1 rm -f getrandom.c cd $odir set -e mount | grep "on $mntpoint " | grep -q /dev/md && umount -f $mntpoint [ -c /dev/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 +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint set +e (cd $odir/../testcases/swap; ./swap -t 5m -i 40 -l 100) & cd $mntpoint timeout 5m limits -c 0 $dir/getrandom s=0 while pgrep -q swap; do pkill swap; done cd $odir for i in `jot 6`; do mount | grep -q "on $mntpoint " || break umount $mntpoint && break || sleep 10 [ $i -eq 6 ] && { echo FATAL; fstat -mf $mntpoint; exit 1; } done mdconfig -d -u $mdstart rm -rf $dir/getrandom exit $s EOF #include #include #include #include #include #include #include #include #include #include #include #include #include static volatile u_int *share; #define PARALLEL 50 #define RUNTIME (5 * 60) #define SYNC 0 static void test(void) { time_t start; atomic_add_int(&share[SYNC], 1); while (share[SYNC] != PARALLEL) ; alarm(65); start = time(NULL); while ((time(NULL) - start) < 60) getrandom((void *)arc4random(), arc4random(), arc4random() & 3); _exit(0); } int main(void) { pid_t pids[PARALLEL]; size_t len; time_t start; int e, i, status; e = 0; len = PAGE_SIZE; if ((share = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED, -1, 0)) == MAP_FAILED) err(1, "mmap"); start = time(NULL); while ((time(NULL) - start) < RUNTIME) { share[SYNC] = 0; for (i = 0; i < PARALLEL; i++) { if ((pids[i] = fork()) == 0) test(); if (pids[i] == -1) err(1, "fork()"); } for (i = 0; i < PARALLEL; i++) { if (waitpid(pids[i], &status, 0) == -1) err(1, "waitpid(%d)", pids[i]); e += status == 0 ? 0 : 1; } } return (e); } diff --git a/tools/test/stress2/misc/gjournal.sh b/tools/test/stress2/misc/gjournal.sh index 7ccc7a70760e..69d449104661 100755 --- a/tools/test/stress2/misc/gjournal.sh +++ b/tools/test/stress2/misc/gjournal.sh @@ -1,76 +1,75 @@ #!/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. # # Deadlock scenario based on kern/154228, fixed in r217880. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg size="2g" [ `swapinfo | wc -l` -eq 1 ] && exit 0 [ `swapinfo -k | tail -1 | awk '{print int($4/1024/1024)}'` -lt \ ${size%g} ] && exit 0 m=$((mdstart + 1)) mp2=${mntpoint}$m mount | grep $mp2 | grep -q /dev/md && umount -f $mp2 mount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint [ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart [ -c /dev/md$m ] && mdconfig -d -u $m mkdir -p $mp2 mdconfig -a -t swap -s $size -u $mdstart || exit 1 gjournal load gjournal label -s 512m md$mdstart sleep .5 newfs -J /dev/md$mdstart.journal > /dev/null mount -o async /dev/md$mdstart.journal $mntpoint here=`pwd` cd $mntpoint dd if=/dev/zero of=image bs=1m count=1k status=none mdconfig -a -t vnode -f image -u $m -bsdlabel -w md$m auto -newfs md${m}$part > /dev/null -mount /dev/md${m}$part $mp2 +newfs md${m} > /dev/null +mount /dev/md${m} $mp2 # dd will suspend in wdrain echo "Expect \"$mp2: write failed, filesystem is full\"" dd if=/dev/zero of=$mp2/zero bs=1M > /dev/null 2>&1 while mount | grep $mp2 | grep -q /dev/md; do umount $mp2 || sleep 1 done mdconfig -d -u $m cd $here gjournal sync while mount | grep $mntpoint | grep -q /dev/md; do umount $mntpoint || sleep 1 done gjournal stop md$mdstart gjournal unload mdconfig -d -u $mdstart diff --git a/tools/test/stress2/misc/holdcnt0.sh b/tools/test/stress2/misc/holdcnt0.sh index 7a35eb1dbf5f..2833915a8f27 100755 --- a/tools/test/stress2/misc/holdcnt0.sh +++ b/tools/test/stress2/misc/holdcnt0.sh @@ -1,261 +1,260 @@ #!/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. # # "panic: cluster_wbuild: page 0xc2eebc10 failed shared busing" seen. # "panic: vdrop: holdcnt 0" seen. # "panic: cleaned vnode isn't" seen. # OoVM seen with r285808: # https://people.freebsd.org/~pho/stress/log/holdcnt0.txt # Test scenario suggestion by alc@ [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 [ `swapinfo | wc -l` -eq 1 ] && exit 0 [ `sysctl -n hw.physmem` -lt $((32 * 1024 * 1024 * 1024)) ] && exit 0 . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > holdcnt0.c mycc -o holdcnt0 -Wall -Wextra -g holdcnt0.c || exit 1 rm -f holdcnt0.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 5g -u $mdstart -bsdlabel -w md$mdstart auto -newfs md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint (cd $mntpoint; /tmp/holdcnt0) & pid=$! sleep 5 while kill -0 $! 2> /dev/null; do (cd ../testcases/swap; ./swap -t 1m -i 1) > /dev/null 2>&1 done wait $pid; s=$? -while mount | grep -q md${mdstart}$part; do +while mount | grep -q md$mdstart; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart rm -f /tmp/holdcnt0 exit $s EOF /* A test that causes the page daemon to generate cached pages within a bunch of files and has some consumer that is trying to allocate new pages to the same files. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #define BUFSIZE (1024 * 1024) #define FILES 200 #define RPARALLEL 8 #define WPARALLEL 2 static jmp_buf jbuf; static off_t maxsize; static int ps; static char *buf; static volatile char val; static void hand(int i __unused) { /* handler */ #if defined(DEBUG) fprintf(stderr, "%d ", i); #endif longjmp(jbuf, 1); } static void cleanup(void) { int i; char file[80]; for (i = 0; i < FILES; i++) { snprintf(file, sizeof(file), "f%06d", i); unlink(file); } } static void init(void) { int fd, i; char file[80]; for (i = 0; i < FILES; i++) { snprintf(file, sizeof(file), "f%06d", i); if ((fd = open(file, O_RDWR | O_CREAT | O_TRUNC, 0644)) == -1) err(1, "open(%s)", file); if (write(fd, buf, BUFSIZE) != BUFSIZE) err(1, "write"); close(fd); } } static void writer(void) { struct stat statbuf; time_t start; int fd, i; char file[80]; setproctitle("writer"); start = time(NULL); while (time(NULL) - start < 600) { for (i = 0; i < FILES; i++) { snprintf(file, sizeof(file), "f%06d", i); if ((fd = open(file, O_RDWR | O_APPEND)) == -1) { if (errno != ENOENT) err(1, "open(%s) append", file); goto err; } if (fstat(fd, &statbuf) < 0) err(1, "fstat error"); if (statbuf.st_size < maxsize) { if (write(fd, buf, ps) != ps) { warn("writer"); goto err; } } close(fd); } } err: cleanup(); _exit(0); } static void reader(void) { struct stat statbuf; void *p; size_t len; int fd, i, j, n; char file[80]; setproctitle("reader"); signal(SIGSEGV, hand); signal(SIGBUS, hand); fd = 0; for (;;) { (void)setjmp(jbuf); for (i = 0; i < FILES; i++) { snprintf(file, sizeof(file), "f%06d", i); if (fd > 0) close(fd); if ((fd = open(file, O_RDWR)) == -1) { if (errno != ENOENT) warn("reader(%s)", file); _exit(0); } if (fstat(fd, &statbuf) < 0) err(1, "fstat error"); if (statbuf.st_size >= maxsize) { if (ftruncate(fd, ps) == -1) err(1, "ftruncate"); continue; } len = statbuf.st_size; if ((p = mmap(p, len, PROT_READ, MAP_SHARED, fd, 0)) == MAP_FAILED) err(1, "mmap()"); close(fd); n = statbuf.st_size / ps; for (j = 0; j < n; j++) { val = *(char *)p; p = p + ps; } #if 0 if (munmap(p, len) == -1) perror("munmap"); #endif } } _exit(0); } int main(void) { pid_t rpid[RPARALLEL], wpid[WPARALLEL]; int e, i, s; maxsize = 2LL * 1024 * 1024 * 1024 / FILES; buf = malloc(BUFSIZE); ps = getpagesize(); init(); e = 0; for (i = 0; i < WPARALLEL; i++) { if ((wpid[i] = fork()) == 0) writer(); } for (i = 0; i < RPARALLEL; i++) { if ((rpid[i] = fork()) == 0) reader(); } for (i = 0; i < WPARALLEL; i++) { waitpid(wpid[i], &s, 0); if (e == 0) e = s; } for (i = 0; i < RPARALLEL; i++) { waitpid(rpid[i], &s, 0); if (e == 0) e = s; } free(buf); return (e); } diff --git a/tools/test/stress2/misc/holdcnt04.sh b/tools/test/stress2/misc/holdcnt04.sh index 52aff0e3816d..871df7ccb08a 100755 --- a/tools/test/stress2/misc/holdcnt04.sh +++ b/tools/test/stress2/misc/holdcnt04.sh @@ -1,248 +1,247 @@ #!/bin/sh # # Copyright (c) 2017 Dell EMC Isilon # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # Lite version of holdcnt0.sh [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 [ `sysctl -n vm.swap_total` -ne 0 ] && exit 0 [ `sysctl -n hw.physmem` -lt 5250000000 ] && exit 0 . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > holdcnt04.c mycc -o holdcnt04 -Wall -Wextra -g holdcnt04.c || exit 1 rm -f holdcnt04.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 md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint (cd $mntpoint; /tmp/holdcnt04) & pid=$! sleep 5 while kill -0 $! 2> /dev/null; do (cd ../testcases/swap; ./swap -t 1m -i 1) > /dev/null 2>&1 done wait $pid; s=$? -while mount | grep -q md${mdstart}$part; do +while mount | grep -q md$mdstart; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart rm -f /tmp/holdcnt04 exit $s EOF /* A test that causes the page daemon to generate cached pages within a bunch of files and has some consumer that is trying to allocate new pages to the same files. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #define BUFSIZE (1024 * 1024) #define FILES 20 #define RPARALLEL 8 #define WPARALLEL 2 static jmp_buf jbuf; static off_t maxsize; static int ps; static char *buf; static volatile char val; static void hand(int i __unused) { /* handler */ longjmp(jbuf, 1); } static void cleanup(void) { int i; char file[80]; for (i = 0; i < FILES; i++) { snprintf(file, sizeof(file), "f%06d", i); unlink(file); } } static void init(void) { int fd, i; char file[80]; for (i = 0; i < FILES; i++) { snprintf(file, sizeof(file), "f%06d", i); if ((fd = open(file, O_RDWR | O_CREAT | O_TRUNC, 0644)) == -1) err(1, "open(%s)", file); if (write(fd, buf, BUFSIZE) != BUFSIZE) err(1, "write"); close(fd); } } static void writer(void) { struct stat statbuf; time_t start; int fd, i; char file[80]; setproctitle("writer"); start = time(NULL); while (time(NULL) - start < 600) { for (i = 0; i < FILES; i++) { snprintf(file, sizeof(file), "f%06d", i); if ((fd = open(file, O_RDWR | O_APPEND)) == -1) { if (errno != ENOENT) err(1, "open(%s) append", file); goto err; } if (fstat(fd, &statbuf) < 0) err(1, "fstat error"); if (statbuf.st_size < maxsize) { if (write(fd, buf, ps) != ps) { warn("writer"); goto err; } } close(fd); } } err: cleanup(); _exit(0); } static void reader(void) { struct stat statbuf; void *p; size_t len; int fd, i, j, n; char file[80]; setproctitle("reader"); signal(SIGSEGV, hand); signal(SIGBUS, hand); fd = 0; for (;;) { (void)setjmp(jbuf); for (i = 0; i < FILES; i++) { snprintf(file, sizeof(file), "f%06d", i); if (fd > 0) close(fd); if ((fd = open(file, O_RDWR)) == -1) { if (errno != ENOENT) warn("reader(%s)", file); _exit(0); } if (fstat(fd, &statbuf) < 0) err(1, "fstat error"); if (statbuf.st_size >= maxsize) { if (ftruncate(fd, ps) == -1) err(1, "ftruncate"); continue; } len = statbuf.st_size; if ((p = mmap(p, len, PROT_READ, MAP_SHARED, fd, 0)) == MAP_FAILED) err(1, "mmap()"); close(fd); n = statbuf.st_size / ps; for (j = 0; j < n; j++) { val = *(char *)p; p = p + ps; } #if 0 if (munmap(p, len) == -1) perror("munmap"); #endif } } _exit(0); } int main(void) { pid_t rpid[RPARALLEL], wpid[WPARALLEL]; int e, i, s; maxsize = 1LL * 1024 * 1024 * 1024 / FILES; buf = malloc(BUFSIZE); ps = getpagesize(); init(); e = 0; for (i = 0; i < WPARALLEL; i++) { if ((wpid[i] = fork()) == 0) writer(); } for (i = 0; i < RPARALLEL; i++) { if ((rpid[i] = fork()) == 0) reader(); } for (i = 0; i < WPARALLEL; i++) waitpid(wpid[i], &s, 0); e += s == 0 ? 0 : 1; for (i = 0; i < RPARALLEL; i++) waitpid(rpid[i], &s, 0); e += s == 0 ? 0 : 1; free(buf); return (e); } diff --git a/tools/test/stress2/misc/isofs3.sh b/tools/test/stress2/misc/isofs3.sh index 476c729568ac..c3ba14335a26 100755 --- a/tools/test/stress2/misc/isofs3.sh +++ b/tools/test/stress2/misc/isofs3.sh @@ -1,66 +1,65 @@ #!/bin/sh # # Copyright (c) 2016 Dell EMC # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # Simple isofs / union test scenario [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 [ -z "`which mkisofs`" ] && echo "mkisofs not found" && exit 0 . ../default.cfg D=`dirname $diskimage`/dir I=`dirname $diskimage`/dir.iso rm -rf $D $I mkdir -p $D cp -r ../../stress2 $D 2>/dev/null mkisofs -o $I -r $D > /dev/null 2>&1 -mount | grep -q /dev/md${mdstart}$part && umount -f /dev/md${mdstart}$part +mount | grep -q /dev/md$mdstart && umount -f /dev/md${mdstart} [ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart mdconfig -a -t vnode -f $I -u $mdstart || exit 1 mount -t cd9660 /dev/md$mdstart $mntpoint || exit 1 m2=$((mdstart + 1)) mdconfig -s 1g -u $m2 -bsdlabel -w md$m2 auto -newfs $newfs_flags md${m2}$part > /dev/null +newfs $newfs_flags md${m2} > /dev/null -mount -o union /dev/md${m2}$part $mntpoint || exit 1 +mount -o union /dev/md${m2} $mntpoint || exit 1 export RUNDIR=$mntpoint/stressX export runRUNTIME=5m (cd $mntpoint/stress2; ./run.sh marcus.cfg) > /dev/null umount $mntpoint mdconfig -d -u $m2 umount $mntpoint mdconfig -d -u $mdstart rm -rf $D $I exit 0 diff --git a/tools/test/stress2/misc/kevent11.sh b/tools/test/stress2/misc/kevent11.sh index f3a319f2ecff..a973dfc4fae8 100755 --- a/tools/test/stress2/misc/kevent11.sh +++ b/tools/test/stress2/misc/kevent11.sh @@ -1,178 +1,177 @@ #!/bin/sh # # Copyright (c) 2017 Dell EMC Isilon # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # Variation of kevent5.sh # OOM seen: https://people.freebsd.org/~pho/stress/log/mark018.txt . ../default.cfg [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 dir=/tmp odir=`pwd` cd $dir sed '1,/^EOF/d' < $odir/$0 > $dir/kevent11.c mycc -o kevent11 -Wall -Wextra -O0 -g kevent11.c || exit 1 rm -f kevent11.c cd $odir set -e mount | grep "on $mntpoint " | grep -q /dev/md && umount -f $mntpoint [ -c /dev/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 +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint set +e (cd $odir/../testcases/swap; ./swap -t 5m -i 20 -h -l 100 > /dev/null) & cd $mntpoint $dir/kevent11 s=$? [ -f kevent11.core -a $s -eq 0 ] && { ls -l kevent11.core; mv kevent11.core /tmp; s=1; } cd $odir while pkill -9 swap; do :; done wait for i in `jot 6`; do mount | grep -q "on $mntpoint " || break umount $mntpoint && break || sleep 10 done [ $i -eq 6 ] && exit 1 mdconfig -d -u $mdstart rm -rf $dir/kevent11 exit $s EOF #include #include #include #include #include #include #include #include #include #include #include #include #include #include static volatile u_int *share; static char *file = "file"; #define PARALLEL 256 #define RUNTIME (3 * 60) #define SYNC 0 static void test(void) { struct kevent ev[2]; struct timespec ts; int kq, fd, n; if ((fd = open(file, O_RDONLY, 0)) == -1) err(1, "open(%s). %s:%d", file, __func__, __LINE__); if ((kq = kqueue()) < 0) err(1, "kqueue()"); n = 0; EV_SET(&ev[n], fd, EVFILT_VNODE, EV_ADD | EV_ENABLE | EV_CLEAR, NOTE_DELETE, 0, 0); n++; if (kevent(kq, ev, n, NULL, 0, NULL) < 0) err(1, "kevent()"); setproctitle("presync"); atomic_add_int(&share[SYNC], 1); while (share[SYNC] != PARALLEL) usleep(10000); setproctitle("postsync"); memset(&ev, 0, sizeof(ev)); n = kevent(kq, NULL, 0, ev, 1, &ts); close(fd); close(kq); _exit(0); } int main(void) { pid_t pids[PARALLEL]; size_t len; time_t start; int e, fd, i, status; e = 0; len = PAGE_SIZE; if ((share = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED, -1, 0)) == MAP_FAILED) err(1, "mmap"); start = time(NULL); while ((time(NULL) - start) < RUNTIME && e == 0) { if ((fd = open(file, O_CREAT | O_TRUNC | O_RDWR, 0660)) == -1) err(1, "open(%s)", file); close(fd); share[SYNC] = 0; for (i = 0; i < PARALLEL; i++) { if ((pids[i] = fork()) == 0) test(); if (pids[i] == -1) err(1, "fork()"); } while (share[SYNC] != PARALLEL) usleep(10000); if (unlink(file) == -1) err(1, "unlink(%s). %s:%d\n", file, __FILE__, __LINE__); for (i = 0; i < PARALLEL; i++) { if (waitpid(pids[i], &status, 0) == -1) err(1, "waitpid(%d)", pids[i]); if (status != 0) { if (WIFSIGNALED(status)) fprintf(stderr, "pid %d exit signal %d\n", pids[i], WTERMSIG(status)); } e += status == 0 ? 0 : 1; } } return (e); } diff --git a/tools/test/stress2/misc/kevent6.sh b/tools/test/stress2/misc/kevent6.sh index 528bde5e78a1..41396c5be9a2 100755 --- a/tools/test/stress2/misc/kevent6.sh +++ b/tools/test/stress2/misc/kevent6.sh @@ -1,168 +1,167 @@ #!/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. # # "Sleeping thread (tid 101094, pid 13104) owns a non-sleepable lock" seen. # Fixed in r255798. # panic: Memory modified after free: # https://people.freebsd.org/~pho/stress/log/alan011.txt # https://people.freebsd.org/~pho/stress/log/kevent6.txt # Fixed by: r286921 [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg odir=`pwd` cd /tmp sed '1,/^EOF/d' < $odir/$0 > kevent6.c mycc -o kevent6 -Wall -Wextra -O2 -g kevent6.c -lpthread || exit 1 rm -f kevent6.c cd $odir mount | grep "on $mntpoint " | grep -q md$mdstart && umount -f $mntpoint mdconfig -l | grep -q $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 +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint su $testuser -c "(cd $mntpoint; /tmp/kevent6)" while mount | grep -q $mntpoint; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart mount -o size=1g -t tmpfs tmpfs $mntpoint chmod 777 $mntpoint su $testuser -c "(cd $mntpoint; /tmp/kevent6)" while mount | grep -q $mntpoint; do umount $mntpoint || sleep 1 done rm -f /tmp/kevent6 exit EOF #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define LOOPS 500000 #define PARALLEL 8 static int fd; static char path[80]; static void * spin(void *arg __unused) { int i; for (i= 0;; i++) { snprintf(path, sizeof(path), "file.%06d.%d", getpid(), i); if ((fd = open(path, O_CREAT | O_TRUNC | O_RDWR, 0622)) == -1) err(1, "creat()"); close(fd); usleep(10000); fd = 0; unlink(path); } return (NULL); } static void * test(void *arg __unused) { int kq; int i, n; struct kevent ev; struct timespec ts; for (i = 0; i < LOOPS; i++) { if ((kq = kqueue()) < 0) err(1, "kqueue()"); n = 0; memset(&ev, 0, sizeof(ev)); EV_SET(&ev, fd, EVFILT_VNODE, EV_ADD | EV_ENABLE | EV_CLEAR, NOTE_DELETE|NOTE_RENAME|NOTE_EXTEND, 0, 0); n++; if (kevent(kq, &ev, n, NULL, 0, NULL) < 0) { close(kq); continue; } memset(&ev, 0, sizeof(ev)); ts.tv_sec = 0; ts.tv_nsec = 1000000; if ((n = kevent(kq, NULL, 0, &ev, 1, &ts)) == -1) err(1, "kevent()"); close(kq); } return (NULL); } int main(void) { pthread_t cp[PARALLEL], sp; int e, i; if ((e = pthread_create(&sp, NULL, spin, NULL)) != 0) errc(1, e, "pthread_create"); for (i = 0; i < PARALLEL; i++) { if ((e = pthread_create(&cp[i], NULL, test, NULL)) != 0) errc(1, e, "pthread_create"); } for (i = 0; i < PARALLEL; i++) pthread_join(cp[i], NULL); close(fd); return (0); } diff --git a/tools/test/stress2/misc/kevent7.sh b/tools/test/stress2/misc/kevent7.sh index 9383918ea134..8b58c35551f7 100755 --- a/tools/test/stress2/misc/kevent7.sh +++ b/tools/test/stress2/misc/kevent7.sh @@ -1,281 +1,280 @@ #!/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. # # Threaded syscall(2) fuzz test inspired by the iknowthis test suite # by Tavis Ormandy # kevent(2) with random arguments. # Spinning threads seen. # Fixed in r255877. # "panic: softclock_call_cc: act 0xfffff801219a0840 0" seen: # https://people.freebsd.org/~pho/stress/log/kevent7.txt # Fixed by r315289 [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg ulimit -t 200 odir=`pwd` cd /tmp sed '1,/^EOF/d' < $odir/$0 > kevent7.c rm -f /tmp/kevent7 mycc -o kevent7 -Wall -Wextra -O2 -g kevent7.c -lpthread || exit 1 rm -f kevent7.c 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 || exit 1 -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint for i in `jot 5`; do (cd $mntpoint; /tmp/kevent7 $* < /dev/null) & sleep 60 while pgrep -q kevent7; do pkill -9 kevent7 sleep 1 done done for i in `jot 5`; do - mount | grep -q md${mdstart}$part && \ + mount | grep -q md$mdstart && \ umount $mntpoint && mdconfig -d -u $mdstart && break sleep 10 done -if mount | grep -q md${mdstart}$part; then +if mount | grep -q md$mdstart; then fstat $mntpoint echo "umount $mntpoint failed" exit 1 fi rm -f /tmp/kevent7 exit 0 EOF #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define THREADS 50 int fd[900], fds[2], socketpr[2]; #define N (128 * 1024 / (int)sizeof(u_int32_t)) static u_int32_t r[N]; static int syscallno; static void hand(int i __unused) { /* handler */ _exit(1); } static unsigned long makearg(void) { unsigned int i; unsigned long val; val = arc4random(); i = arc4random() % 100; if (i < 20) val = val & 0xff; if (i >= 20 && i < 40) val = val & 0xffff; if (i >= 40 && i < 60) val = (unsigned long)(r) | (val & 0xffff); #if defined(__LP64__) if (i >= 60) { val = (val << 32) | arc4random(); if (i > 80) val = val & 0x00007fffffffffffUL; } #endif return(val); } static void * test(void *arg __unused) { FTS *fts; FTSENT *p; int ftsoptions; int i; char *args[5]; ftsoptions = FTS_PHYSICAL; args[0] = "/dev"; args[1] = "/proc"; args[2] = "/usr/compat/linux/proc"; args[3] = "."; args[4] = 0; for (;;) { for (i = 0; i < N; i++) r[i] = arc4random(); if ((fts = fts_open(args, ftsoptions, NULL)) == NULL) err(1, "fts_open"); i = 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) if ((fd[i] = open(p->fts_path, O_RDONLY)) == -1) continue; i++; i = i % nitems(fd); } if (fts_close(fts) == -1) if (errno != ENOTDIR) warn("fts_close()"); if (pipe(fds) == -1) err(1, "pipe()"); if (socketpair(PF_UNIX, SOCK_SEQPACKET, 0, socketpr) == -1) err(1, "socketpair()"); sleep(1); close(socketpr[0]); close(socketpr[1]); close(fds[0]); close(fds[1]); } return(0); } static void * calls(void *arg __unused) { unsigned long arg1, arg2, arg3, arg4, arg5, arg6, arg7; int i, kq, num; if ((kq = kqueue()) < 0) err(1, "kqueue()"); for (i = 0; i < 1000; i++) { if (i == 0) usleep(1000); num = syscallno; arg1 = makearg(); arg2 = makearg(); arg3 = makearg(); arg4 = makearg(); arg5 = makearg(); arg6 = makearg(); arg7 = makearg(); #if 0 fprintf(stderr, "%2d : syscall(%3d, %lx, %lx, %lx, %lx, %lx," " %lx, %lx)\n", i, num, arg1, arg2, arg3, arg4, arg5, arg6, arg7); #endif alarm(1); syscall(num, arg1, arg2, arg3, arg4, arg5, arg6, arg7); num = 0; } close(kq); return (0); } int main(void) { struct passwd *pw; time_t start; pthread_t rp, cp[THREADS]; int e, j, n; if ((pw = getpwnam("nobody")) == NULL) err(1, "no such user: nobody"); if (setgroups(1, &pw->pw_gid) || setegid(pw->pw_gid) || setgid(pw->pw_gid) || seteuid(pw->pw_uid) || setuid(pw->pw_uid)) err(1, "Can't drop privileges to \"nobody\""); endpwent(); signal(SIGALRM, hand); signal(SIGILL, hand); signal(SIGFPE, hand); signal(SIGSEGV, hand); signal(SIGBUS, hand); signal(SIGURG, hand); signal(SIGSYS, hand); signal(SIGTRAP, hand); syscallno = SYS_kevent; n = 0; start = time(NULL); while (time(NULL) - start < 120) { if (fork() == 0) { if ((e = pthread_create(&rp, NULL, test, NULL)) != 0) errc(1, e, "pthread_create"); usleep(1000); for (j = 0; j < THREADS; j++) { if ((e = pthread_create(&cp[j], NULL, calls, NULL)) != 0) errc(1, e, "pthread_create"); } for (j = 0; j < THREADS; j++) pthread_join(cp[j], NULL); if ((e = pthread_kill(rp, SIGINT)) != 0) errc(1, e, "pthread_kill"); _exit(0); } wait(NULL); if (n++ > 5000) break; } return (0); } diff --git a/tools/test/stress2/misc/kevent8.sh b/tools/test/stress2/misc/kevent8.sh index 66007eb5a2b1..3b9b4899076c 100755 --- a/tools/test/stress2/misc/kevent8.sh +++ b/tools/test/stress2/misc/kevent8.sh @@ -1,163 +1,162 @@ #!/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. # # Out of VM seen due to missing close of kqueue handle. # Fixed in 256849 . ../default.cfg [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 ulimit -k 5000 || { echo FAIL; exit 1; } odir=`pwd` cd /tmp sed '1,/^EOF/d' < $odir/$0 > kevent8.c mycc -o kevent8 -Wall -Wextra -O2 -g kevent8.c -lpthread || exit 1 rm -f kevent8.c cd $odir mount | grep "on $mntpoint " | grep -q md$mdstart && umount -f $mntpoint mdconfig -l | grep -q $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 +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint su $testuser -c "(cd $mntpoint; /tmp/kevent8)" & for i in `jot 99`; do sleep 1 kill -0 $! 2>/dev/null || break done umount -f $mntpoint pkill kevent8 wait while mount | grep -q $mntpoint; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart rm -f /tmp/kevent8 exit EOF #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define PARALLEL 64 static int fd; static char path[80]; static void * spin(void *arg __unused) { int i; setproctitle("spin"); for (i= 0;; i++) { snprintf(path, sizeof(path), "file.%06d.%d", getpid(), i); if ((fd = open(path, O_CREAT | O_TRUNC | O_RDWR, 0622)) == -1) err(1, "creat()"); close(fd); fd = 0; unlink(path); } return (NULL); } static void * test(void *arg __unused) { int kq; int i, n; struct kevent ev; struct timespec ts; for (i = 0; i < 500000; i++) { if ((kq = kqueue()) < 0) if (errno != ENOMEM) err(1, "kqueue()"); n = 0; memset(&ev, 0, sizeof(ev)); EV_SET(&ev, fd, EVFILT_VNODE, EV_ADD | EV_ENABLE | EV_CLEAR, NOTE_DELETE|NOTE_RENAME|NOTE_EXTEND, 0, 0); n++; if (kevent(kq, &ev, n, NULL, 0, NULL) < 0) continue; /* Note: missing close(kq)! */ memset(&ev, 0, sizeof(ev)); ts.tv_sec = 0; ts.tv_nsec = 1000000; if ((n = kevent(kq, NULL, 0, &ev, 1, &ts)) == -1) err(1, "kevent()"); close(kq); } return (NULL); } int main(void) { pthread_t cp[PARALLEL], sp; int e, i; if ((e = pthread_create(&sp, NULL, spin, NULL)) != 0) errc(1, e, "pthread_create"); for (i = 0; i < PARALLEL; i++) { if ((e = pthread_create(&cp[i], NULL, test, NULL)) != 0) errc(1, e, "pthread_create"); } for (i = 0; i < PARALLEL; i++) pthread_join(cp[i], NULL); close(fd); return (0); } diff --git a/tools/test/stress2/misc/laundry.sh b/tools/test/stress2/misc/laundry.sh index 5d368432ac3c..cd94e4f38972 100755 --- a/tools/test/stress2/misc/laundry.sh +++ b/tools/test/stress2/misc/laundry.sh @@ -1,177 +1,176 @@ #!/bin/sh # # Copyright (c) 2017 Dell EMC Isilon # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # vm.stats.vm.v_laundry_count test. WiP. No problems seen. . ../default.cfg [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 dir=/tmp odir=`pwd` cd $dir sed '1,/^EOF/d' < $odir/$0 > $dir/laundry.c mycc -o laundry -Wall -Wextra -O0 -g laundry.c || exit 1 rm -f laundry.c cd $odir size=`sysctl -n hw.usermem` swaptotal=`sysctl -n vm.swap_total` [ $swaptotal -eq 0 ] && exit 0 [ $size -gt $swaptotal ] && size=$swaptotal size=$((size / 10 * 8)) set -e mount | grep "on $mntpoint " | grep -q /dev/md && umount -f $mntpoint [ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint set +e cd $mntpoint $dir/laundry $size s=$? [ -f laundry.core -a $s -eq 0 ] && { ls -l laundry.core; s=1; } cd $odir for i in `jot 6`; do mount | grep -q "on $mntpoint " || break umount $mntpoint && break || sleep 10 done [ $i -eq 6 ] && exit 1 mdconfig -d -u $mdstart rm -rf $dir/laundry exit $s EOF #include #include #include #include #include #include #include #include #include #include #include #include static volatile u_int *share; size_t size; #define PARALLEL 4 #define RUNTIME (5 * 60) #define SYNC 0 static void test(void) { size_t i, sz; time_t start; int n; char *cp; atomic_add_int(&share[SYNC], 1); while (share[SYNC] != PARALLEL) ; sz = size; if ((cp = mmap(0, sz, PROT_READ|PROT_WRITE, MAP_ANON, -1, 0)) == (caddr_t) - 1) err(1, "mmap size %zd", sz); n = 0; start = time(NULL); while ((time(NULL) - start) < RUNTIME) { n++; n = n & 0xff; for (i = 0; i < sz; i += PAGE_SIZE) cp[i] = n; usleep(100); } munmap(cp, sz); _exit(0); } int main(int argc __unused, char *argv[]) { pid_t pids[PARALLEL]; size_t len; time_t start; int e, status; u_int i; sscanf(argv[1], "%zd", &size); size /= PARALLEL; e = 0; len = PAGE_SIZE; if ((share = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED, -1, 0)) == MAP_FAILED) err(1, "mmap"); start = time(NULL); while ((time(NULL) - start) < RUNTIME && e == 0) { share[SYNC] = 0; for (i = 0; i < PARALLEL; i++) { if ((pids[i] = fork()) == 0) test(); if (pids[i] == -1) err(1, "fork()"); } for (i = 0; i < PARALLEL; i++) { if (waitpid(pids[i], &status, 0) == -1) err(1, "waitpid(%d)", pids[i]); if (status != 0) { if (WIFEXITED(status)) { printf("exited, status=%d\n", WEXITSTATUS(status)); } else if (WIFSIGNALED(status)) { printf("killed by signal %d\n", WTERMSIG(status)); } else if (WIFSTOPPED(status)) { printf("stopped by signal %d\n", WSTOPSIG(status)); } else if (WIFCONTINUED(status)) { printf("continued\n"); } fprintf(stderr, "pid %d exit code %d\n", pids[i], status); } e += status == 0 ? 0 : 1; } } return (e); } diff --git a/tools/test/stress2/misc/linger.sh b/tools/test/stress2/misc/linger.sh index fee2524ffd3b..3d1dd1e3268e 100755 --- a/tools/test/stress2/misc/linger.sh +++ b/tools/test/stress2/misc/linger.sh @@ -1,168 +1,167 @@ #!/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. # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 # Demonstrate premature "out of inodes" problem with SU . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > linger.c mycc -o linger -Wall -O2 linger.c rm -f linger.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 -echo "newfs $opt md${mdstart}$part" -newfs $opt md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +echo "newfs $opt md$mdstart" +newfs $opt md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint if ! su $testuser -c "cd $mntpoint; /tmp/linger $size"; then min=2 [ -r $mntpoint/.sujournal ] && min=3 r=`df -hi $mntpoint | head -1` echo " $r" for i in `jot 10`; do r=`df -hi $mntpoint | tail -1` echo "`date '+%T'` $r" [ `echo $r | awk '{print $6}'` = $min ] && break sleep 10 done ls -lR $mntpoint fi while mount | grep "$mntpoint " | grep -q /dev/md; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart rm -f /tmp/linger exit EOF #include #include #include #include #include #include #include #include #include #include #include #include #define PARALLEL 10 #define TIMEOUT 1200 static int size = 6552; /* 10 free inodes */ static int test(void) { int fd, i, j; pid_t pid; char file[128]; for (;;) { if (access("rendezvous", R_OK) == 0) break; sched_yield(); } pid = getpid(); 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"); break; } } if (fd != -1 && close(fd) == -1) err(2, "close(%d)", j); } sleep(3); for (i = --j; i >= 0; i--) { sprintf(file,"p%05d.%05d", pid, i); if (unlink(file) == -1) warn("unlink(%s)", file); } return (0); } int main(void) { time_t start; int error = 0, fd, i, j, status; umask(0); if ((fd = open("continue", O_CREAT, 0644)) == -1) err(1, "open()"); close(fd); start = time(NULL); for (i = 0; i < 100; 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(&status); error += status; } unlink("rendezvous"); if (access("continue", R_OK) == -1) break; if (time(NULL) - start > TIMEOUT) { fprintf(stderr, "FAIL Timeout\n"); break; } } unlink("continue"); return (error != 0); } diff --git a/tools/test/stress2/misc/linger2.sh b/tools/test/stress2/misc/linger2.sh index e5dad8d7e21d..7ffde78089d8 100755 --- a/tools/test/stress2/misc/linger2.sh +++ b/tools/test/stress2/misc/linger2.sh @@ -1,172 +1,171 @@ #!/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. # [ `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 +newfs $opt -n md$mdstart > /dev/null +mount /dev/md$mdstart $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 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); } diff --git a/tools/test/stress2/misc/linger3.sh b/tools/test/stress2/misc/linger3.sh index c888d992138a..b3512041775c 100755 --- a/tools/test/stress2/misc/linger3.sh +++ b/tools/test/stress2/misc/linger3.sh @@ -1,134 +1,133 @@ #!/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. # # 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 +echo "newfs $opt md$mdstart" +newfs $opt md$mdstart > /dev/null +mount /dev/md$mdstart $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 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); } diff --git a/tools/test/stress2/misc/linger4.sh b/tools/test/stress2/misc/linger4.sh index 1578575fa387..aade4a4ab006 100755 --- a/tools/test/stress2/misc/linger4.sh +++ b/tools/test/stress2/misc/linger4.sh @@ -1,155 +1,154 @@ #!/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. # # 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 +echo "newfs $opt md$mdstart" +newfs $opt md$mdstart > /dev/null +mount /dev/md$mdstart $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 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); } diff --git a/tools/test/stress2/misc/link.sh b/tools/test/stress2/misc/link.sh index 64f76ca5f3b0..5be9c1cba293 100755 --- a/tools/test/stress2/misc/link.sh +++ b/tools/test/stress2/misc/link.sh @@ -1,193 +1,192 @@ #!/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. # # Deadlock seen for file systems which suspend writes on unmount, such as # UFS and tmpfs. # http://people.freebsd.org/~pho/stress/log/link.txt # Fixed by r272130 [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > link.c mycc -o link -Wall -Wextra -O2 -g link.c || exit 1 rm -f link.c mount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint [ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart || exit 1 -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint daemon sh -c "(cd $here/../testcases/swap; ./swap -t 5m -i 20 -h -l 100)" \ > /dev/null 2>&1 /tmp/link $mntpoint > /dev/null 2>&1 & for i in `jot 100`; do umount -f $mntpoint && - mount /dev/md${mdstart}$part $mntpoint + mount /dev/md$mdstart $mntpoint sleep .1 done pkill -9 link wait while mount | grep $mntpoint | grep -q /dev/md; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart # tmpfs mount -t tmpfs tmpfs $mntpoint /tmp/link $mntpoint > /dev/null 2>&1 & for i in `jot 100`; do umount -f $mntpoint && mount -t tmpfs tmpfs $mntpoint sleep .1 done pkill -9 link swap wait while pkill -9 swap; do : done > /dev/null 2>&1 while mount | grep $mntpoint | grep -q tmpfs; do umount $mntpoint || sleep 1 done [ -d "$mntpoint" ] && (cd $mntpoint && find . -delete) rm -f /tmp/link exit 0 EOF #include #include #include #include #include #include #include #include #include #define PARALLEL 16 #define RUNTIME 300 time_t start; char *dir; void trename(void) { int fd; char name1[MAXPATHLEN + 1]; char name2[MAXPATHLEN + 1]; setproctitle(__func__); snprintf(name1, sizeof(name1), "%s/r1.%05d", dir, getpid()); snprintf(name2, sizeof(name2), "%s/r2.%05d", dir, getpid()); if ((fd = open(name1, O_RDWR | O_CREAT, 0644)) == -1) err(1, "open(%s)", name1); close(fd); while (time(NULL) - start < RUNTIME) { if (rename(name1, name2) == -1) { if (errno == ENOENT) { if ((fd = open(name1, O_RDWR | O_CREAT, 0644)) == -1) err(1, "open(%s)", name1); close(fd); continue; } else warn("link(%s, %s)", name1, name2); } if (rename(name2, name1) == -1) warn("link(%s, %s)", name2, name1); } unlink(name1); unlink(name2); _exit(0); } void tlink(void) { int fd; char name1[MAXPATHLEN + 1]; char name2[MAXPATHLEN + 1]; setproctitle(__func__); snprintf(name1, sizeof(name1), "%s/f1.%05d", dir, getpid()); snprintf(name2, sizeof(name2), "%s/f2.%05d", dir, getpid()); if ((fd = open(name1, O_RDWR | O_CREAT, 0644)) == -1) err(1, "open(%s)", name1); close(fd); while (time(NULL) - start < RUNTIME) { unlink(name2); if (link(name1, name2) == -1) { if (errno == ENOENT) { if ((fd = open(name1, O_RDWR | O_CREAT, 0644)) == -1) err(1, "open(%s)", name1); close(fd); continue; } else warn("link(%s, %s)", name1, name2); } } unlink(name1); unlink(name2); _exit(0); } int main(int argc, char **argv) { int i, type; if (argc != 2) errx(1, "Usage: %s ", argv[0]); dir = argv[1]; type = arc4random() % 2; /* test either link() or rename() */ start = time(NULL); for (i = 0; i < PARALLEL; i++) { if (type == 0 && fork() == 0) tlink(); if (type == 1 && fork() == 0) trename(); } for (i = 0; i < PARALLEL; i++) wait(NULL); return(0); } diff --git a/tools/test/stress2/misc/link2.sh b/tools/test/stress2/misc/link2.sh index 94116c0dc081..650509c55814 100755 --- a/tools/test/stress2/misc/link2.sh +++ b/tools/test/stress2/misc/link2.sh @@ -1,78 +1,77 @@ #!/bin/sh # # Copyright (c) 2017 Dell EMC Isilon # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # Copy of link.sh with leak detection added [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/link.sh > link.c mycc -o link -Wall -Wextra -O2 -g link.c || exit 1 rm -f link.c mount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint [ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart || exit 1 -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint daemon sh -c "(cd $here/../testcases/swap; ./swap -t 5m -i 20 -h -l 100)" \ > /dev/null 2>&1 /tmp/link $mntpoint > /dev/null 2>&1 & m1=`vmstat -m | awk '/ mount/ {print $2}'` for i in `jot 100`; do umount -f $mntpoint && - mount /dev/md${mdstart}$part $mntpoint + mount /dev/md$mdstart $mntpoint sleep .1 done m2=`vmstat -m | awk '/ mount/ {print $2}'` pkill -9 link while pgrep -q swap; do pkill -9 swap done wait while mount | grep $mntpoint | grep -q /dev/md; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart [ -d "$mntpoint" ] && (cd $mntpoint && find . -delete) rm -f /tmp/link leak=$((m2 - m1)) [ $leak -gt 2 ] && { echo "Leaked $leak InUse \"mount\""; s=1; vmstat -m | \ sed -n '1p;/ mount/p'; } || s=0 exit $s diff --git a/tools/test/stress2/misc/lockf3.sh b/tools/test/stress2/misc/lockf3.sh index 4493fa214a33..02dc86b7884f 100755 --- a/tools/test/stress2/misc/lockf3.sh +++ b/tools/test/stress2/misc/lockf3.sh @@ -1,163 +1,162 @@ #!/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. # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > lockf3.c mycc -o lockf3 -Wall -Wextra -O2 lockf3.c || exit 1 rm -f lockf3.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 -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint cd $mntpoint for i in `jot 3`; do $here/../testcases/swap/swap -t 10m -i 200 > /dev/null & /tmp/lockf3 || break pkill swap wait done while pgrep -q swap; do pkill swap done pkill lockf3 wait cd $here while mount | grep -q "on $mntpoint "; do umount $mntpoint || sleep 1 done rm -rf /tmp/lockf3 exit 0 EOF #include #include #include #include #include #include #include #include #include #include #define LOOPS 10000 #define PIDS 100 void handler(int s __unused) { } void int_handler(int s __unused) { _exit(0); } void ahandler(int s __unused) { fprintf(stderr, "FAIL timed out\n"); _exit(1); } int main(void) { int fd, i, j; char name[128]; pid_t pid[PIDS]; struct sigaction sa; int status; signal(SIGALRM, ahandler); alarm(15 * 60); for (i = 0; i < PIDS; i++) { sprintf(name, "lock.%06d", getpid()); if ((fd = open(name, O_CREAT | O_TRUNC | O_RDWR, 0640)) == -1) err(1, "open(%s)", name); if (lockf(fd, F_LOCK, 0) == -1) err(1, "flock 1"); if ((pid[i] = fork()) == -1) err(1, "fork"); if (pid[i] == 0) { memset(&sa, 0, sizeof(sa)); sa.sa_handler = handler; if (sigaction(SIGHUP, &sa, NULL) == -1) err(1, "signal"); sa.sa_handler = int_handler; if (sigaction(SIGINT, &sa, NULL) == -1) err(1, "signal"); for (;;) { if (lockf(fd, F_LOCK, 0) == -1) if (errno != EINTR) warn("lockf"); } _exit(0); } unlink(name); } usleep(10000); for (i = 0; i < LOOPS; i++) { for (j = 0; j < PIDS; j++) { if (kill(pid[j], SIGHUP) == -1) { warn("kill(%d), i = %d, j = %d", pid[j], i, j); pid[j] = 0; } } } for (j = 0; j < PIDS; j++) { if (kill(pid[j], SIGINT) == -1) { warn("kill(%d), i = %d, j = %d", pid[j], i, j); pid[j] = 0; } } for (j = 0; j < PIDS; j++) { if (waitpid(pid[j], &status, 0) == -1) err(1, "waitpid(%d)", pid[j]); } return (0); } diff --git a/tools/test/stress2/misc/lockf4.sh b/tools/test/stress2/misc/lockf4.sh index 690bad033cf4..6427a8a02ff9 100755 --- a/tools/test/stress2/misc/lockf4.sh +++ b/tools/test/stress2/misc/lockf4.sh @@ -1,183 +1,182 @@ #!/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. # # lockf(3) test scenario. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg odir=`pwd` cd /tmp sed '1,/^EOF/d' < $odir/$0 > lockf4.c rm -f /tmp/lockf4 mycc -o lockf4 -Wall -Wextra -g -O2 lockf4.c || exit 1 rm -f lockf4.c cd $odir [ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart || exit 1 -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint su $testuser -c "(cd $mntpoint; /tmp/lockf4)" & su $testuser -c "(cd $mntpoint; /tmp/lockf4)" & su $testuser -c "(cd $mntpoint; /tmp/lockf4)" & wait while mount | grep "on $mntpoint " | grep -q /dev/md; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart rm -f /tmp/lockf4 exit 0 EOF #include #include #include #include #include #include #include #define N (5 * 1024 * 1024) /* 40 MB */ int fd; int idx[N]; char file[] = "lockf4.file"; #define TIMEOUT 600 int64_t add(int ix, int val) { int64_t v; off_t offset; time_t start; int r; offset = ix * sizeof(v); if (lseek(fd, offset, SEEK_SET) == -1) err(1, "lseek"); start = time(NULL); while (lockf(fd, F_LOCK, sizeof(v)) == -1) { if (errno != EDEADLK) err(1, "lockf(%s, F_LOCK)", file); if (time(NULL) - start > TIMEOUT) errx(1, "lockf timedout"); } v = 0; r = read(fd, &v, sizeof(v)); if (r == 0) v = 0; else if (r == -1) err(1, "read"); v += val; if (lseek(fd, offset, SEEK_SET) == -1) err(1, "lseek"); if (write(fd, &v, sizeof(v)) < 0) err(1, "write"); if (lseek(fd, offset, SEEK_SET) == -1) err(1, "lseek"); if (lockf(fd, F_ULOCK, sizeof(v)) == -1) err(1, "lockf(%s, F_ULOCK)", file); return (v); } int check(void) { int64_t v; int i; setproctitle("check"); if (lseek(fd, 0, SEEK_SET) == -1) err(1, "lseek"); for (i = 1; i < N; i++) { if (read(fd, &v, sizeof(v)) < 0) err(1, "read"); if (v != 0) return (1); } return (0); } int main(void) { int64_t r; int e, i, j, t; char help[80]; for (i = 1; i < N; i++) idx[i] = i; for (i = 1; i < N; i++) { j = arc4random() % (N - 1) + 1; t = idx[i]; idx[i] = idx[j]; idx[j] = t; } if ((fd = open(file, O_RDWR | O_CREAT, 0644)) == -1) err(1, "open(%s)", file); add(0, 1); for (i = 1; i < N; i++) { if (i % 500 == 0) { snprintf(help, sizeof(help), "add %d%%", i * 100 / N); setproctitle("%s", help); } add(idx[i], 1); } for (i = 1; i < N; i++) { if (i % 500 == 0) { snprintf(help, sizeof(help), "sub %d%%", i * 100 / N); setproctitle("%s", help); } add(idx[i], -1); } e = 0; if ((r = add(0, -1)) == 0) { e = check(); if (e == 0) unlink(file); else fprintf(stderr, "FAIL\n"); } close(fd); return (e); } diff --git a/tools/test/stress2/misc/lstat.sh b/tools/test/stress2/misc/lstat.sh index a82692979cbe..b380fee35904 100755 --- a/tools/test/stress2/misc/lstat.sh +++ b/tools/test/stress2/misc/lstat.sh @@ -1,234 +1,233 @@ #!/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. # # Hunt for; # Bug 204764 - Filesystem deadlock, process in vodead state # https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=204764 # No problem seen. . ../default.cfg dir=/tmp odir=`pwd` cd $dir sed '1,/^EOF/d' < $odir/$0 > $dir/lstat.c mycc -o lstat -Wall -Wextra -O0 -g lstat.c || exit 1 rm -f lstat.c cd $odir 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 1g -u $mdstart || exit 1 -bsdlabel -w md$mdstart auto -newfs -n -b 4096 -f 512 -i 1024 md${mdstart}$part > /dev/null -mount -o async /dev/md${mdstart}$part $mntpoint || exit 1 +newfs -n -b 4096 -f 512 -i 1024 md$mdstart > /dev/null +mount -o async /dev/md$mdstart $mntpoint || exit 1 path=$mntpoint/a/b/c mkdir -p $path $dir/lstat $path while mount | grep "on $mntpoint " | grep -q /dev/md; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart rm -rf $dir/lstat $wdir/lstat.tmp.* exit EOF #include #include #include #include #include #include #include #include #include #include #include #include #include #include static volatile u_int *dirs, *share; static char *arg; #define R1 0 #define R2 1 #define MXDIRS 3000 #define PARALLEL 2 #define RUNTIME 600 #define SLPTIME 400 static void tfts(int idx) { FTS *fts; FTSENT *p; struct stat sb; int ftsoptions; char *args[2]; if (idx != 0) _exit(0); ftsoptions = FTS_PHYSICAL; args[0] = arg, args[1] = 0; setproctitle("fts"); while (share[R2] == 0) { if ((fts = fts_open(args, ftsoptions, NULL)) == NULL) err(1, "fts_open"); while ((p = fts_read(fts)) != NULL) { lstat(fts->fts_path, &sb); if (share[R2] == 1) break; } if (fts_close(fts) == -1) err(1, "fts_close()"); } _exit(0); } static int test(int idx) { struct stat sb; pid_t fpid, pd, pid; size_t len; int i, r; char dir[128], path[128]; atomic_add_int(&share[R1], 1); while (share[R1] != PARALLEL) ; len = PAGE_SIZE; if ((dirs = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED, -1, 0)) == MAP_FAILED) err(1, "mmap"); if ((fpid = fork()) == 0) tfts(idx); pid = getpid(); snprintf(dir, sizeof(dir), "%s/dir.%d", arg, pid); if (mkdir(dir, 0777) == -1) err(1, "mkdir(%s)", dir); if (chdir(dir) == -1) err(1, "chdir(%s)", dir); if ((pd = fork()) == 0) { setproctitle("mkdir"); i = 0; while (share[R2] == 0) { snprintf(path, sizeof(path), "%s/d.%d.%d", arg, pid, i); while (dirs[0] > MXDIRS && share[R2] == 0) usleep(SLPTIME); while ((r = mkdir(path, 0777)) == -1) { if (errno != EMLINK) err(1, "mkdir(%s) @ %d", path, __LINE__); usleep(SLPTIME); if (share[2] == 1) break; } if (r == 0) { atomic_add_int(&dirs[0], 1); i++; } } _exit(0); } i = 0; setproctitle("rmdir"); while (dirs[0] > 0 || share[R2] == 0) { if (dirs[0] < MXDIRS / 2) usleep(SLPTIME); snprintf(path, sizeof(path), "%s/d.%d.%d", arg, pid, i); while (lstat(path, &sb) == -1 && share[R2] == 0) { usleep(SLPTIME); } if (rmdir(path) == -1) { if (errno != ENOENT) err(1, "rmdir(%s)", path); } else { atomic_add_int(&dirs[0], -1); i++; } } waitpid(pd, NULL, 0); waitpid(fpid, NULL, 0); chdir(".."); if ((rmdir(dir)) == -1) err(1, "unlink(%s)", dir); _exit(0); } int main(int argc, char *argv[]) { size_t len; int e, i, pids[PARALLEL], status; if (argc != 2) errx(1, "Usage: %s ", argv[0]); arg = argv[1]; e = 0; len = PAGE_SIZE; if ((share = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED, -1, 0)) == MAP_FAILED) err(1, "mmap"); share[R1] = 0; for (i = 0; i < PARALLEL; i++) { if ((pids[i] = fork()) == 0) test(i); } sleep(RUNTIME); share[R2] = 1; for (i = 0; i < PARALLEL; i++) { waitpid(pids[i], &status, 0); e += status == 0 ? 0 : 1; } return (e); } diff --git a/tools/test/stress2/misc/mac_chkexec.sh b/tools/test/stress2/misc/mac_chkexec.sh index d3e961b02200..e1cb6f37169d 100755 --- a/tools/test/stress2/misc/mac_chkexec.sh +++ b/tools/test/stress2/misc/mac_chkexec.sh @@ -1,57 +1,56 @@ #!/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. # # Regression test for panic in second ls exit 0 # Not part of the kernel [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg sysctl -a | ! grep -q security.mac.chkexec && echo "chkexec.ko must be loaded" && exit 1 -mount | grep "$mntpoint" | grep -q md${mdstart}$part && umount $mntpoint +mount | grep "$mntpoint" | grep -q md$mdstart && umount $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 md${mdstart}$part > /dev/null -tunefs -l enable /dev/md${mdstart}$part -mount /dev/md${mdstart}$part $mntpoint +newfs md$mdstart > /dev/null +tunefs -l enable /dev/md$mdstart +mount /dev/md$mdstart $mntpoint cp /bin/ls $mntpoint setfmac chkexec/md5:`md5 -q $mntpoint/ls` $mntpoint/ls sysctl security.mac.chkexec.enforce=1 $mntpoint/ls $mntpoint/ls setfmac chkexec/none $mntpoint/ls $mntpoint/ls $mntpoint/ls sysctl security.mac.chkexec.enforce=0 umount $mntpoint mdconfig -d -u $mdstart diff --git a/tools/test/stress2/misc/marcus.sh b/tools/test/stress2/misc/marcus.sh index 727b1ad56c17..87fc2664d48a 100755 --- a/tools/test/stress2/misc/marcus.sh +++ b/tools/test/stress2/misc/marcus.sh @@ -1,55 +1,54 @@ #!/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. # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 # Run with marcus.cfg on a 1g swap backed MD with UFS SU fs. . ../default.cfg mount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint export runRUNTIME=20m export RUNDIR=$mntpoint/stressX su $testuser -c 'cd ..; ./run.sh marcus.cfg' n=0 while mount | grep $mntpoint | grep -q /dev/md; do umount $mntpoint || sleep 1 [ $((n += 1)) -gt 300 ] && { echo FAIL; exit 1; } done -checkfs /dev/md${mdstart}$part; s=$? +checkfs /dev/md$mdstart; s=$? mdconfig -d -u $mdstart exit $s diff --git a/tools/test/stress2/misc/marcus2.sh b/tools/test/stress2/misc/marcus2.sh index 1e58c52ddfde..ddd358453a2d 100755 --- a/tools/test/stress2/misc/marcus2.sh +++ b/tools/test/stress2/misc/marcus2.sh @@ -1,73 +1,72 @@ #!/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. # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 # Run with marcus.cfg on a 2g swap backed MD with UFS SU fs. # Copy of marcus.sh, but with maximum load. # "panic: vm_radix_remove: invalid key found" seen. # watchdog fired: https://people.freebsd.org/~pho/stress/log/marcus2.txt . ../default.cfg 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 +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint export runRUNTIME=20m export RUNDIR=$mntpoint/stressX n=`find ../testcases -perm -1 -type f | wc -l` m=`su $testuser -c "limits | awk '/maxprocesses/ {print \\$NF}'"` export INCARNATIONS=$((m / n)) export swapINCARNATIONS=$INCARNATIONS su $testuser -c 'cd ..; ./run.sh marcus.cfg' & sleep 10 start=`date '+%s'` while pgrep -q run; do [ $((`date '+%s'` - start)) -gt 1500 ] && ../tools/killall.sh sleep 10 done wait n=0 while mount | grep $mntpoint | grep -q /dev/md; do umount $mntpoint || sleep 1 [ $((n += 1)) -gt 300 ] && { echo FAIL; exit 1; } done -checkfs /dev/md${mdstart}$part; s=$? +checkfs /dev/md$mdstart; s=$? mdconfig -d -u $mdstart exit $s diff --git a/tools/test/stress2/misc/marcus5.sh b/tools/test/stress2/misc/marcus5.sh index 97c2465ba49c..f95887a20d56 100755 --- a/tools/test/stress2/misc/marcus5.sh +++ b/tools/test/stress2/misc/marcus5.sh @@ -1,85 +1,84 @@ #!/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. # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 [ `swapinfo | wc -l` -eq 1 ] && exit 0 # Copy of marcus4.sh, but with a md(4) disk. # "panic: userret: Returning with SU cleanup request not handled" seen: # https://people.freebsd.org/~pho/stress/log/marcus5.txt # Fixed by r292541. . ../default.cfg 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 5g -u $mdstart -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint size=$((`sysctl -n hw.physmem` / 1024 / 1024)) [ $size -gt $((4 * 1024)) ] && echo "RAM should be capped to 4GB for this test." [ "`sysctl -n debug.deadlkres.sleepfreq 2>/dev/null`" = "3" ] && { echo "deadlkres must be disabled for this test."; exit 0; } n=`find ../testcases -perm -1 -type f | wc -l` m=`su $testuser -c "limits | awk '/maxprocesses/ {print \\$NF}'"` export RUNDIR=$mntpoint/stressX export INCARNATIONS=$((m / n)) export runRUNTIME=15m export LOAD=80 export symlinkLOAD=80 export rwLOAD=80 export TESTPROGS=" testcases/lockf2/lockf2 testcases/symlink/symlink testcases/openat/openat testcases/rw/rw testcases/fts/fts testcases/link/link testcases/lockf/lockf testcases/creat/creat testcases/mkdir/mkdir testcases/rename/rename testcases/mkfifo/mkfifo " timeout 20m su $testuser -c 'cd ..; ./testcases/run/run $TESTPROGS' n=0 while mount | grep $mntpoint | grep -q /dev/md; do umount $mntpoint || sleep 1 [ $((n += 1)) -gt 300 ] && { echo FAIL; exit 1; } done -checkfs /dev/md${mdstart}$part; s=$! +checkfs /dev/md$mdstart; s=$! mdconfig -d -u $mdstart exit $s diff --git a/tools/test/stress2/misc/marcus6.sh b/tools/test/stress2/misc/marcus6.sh index 076a51e1e4a4..1a209b2256ee 100755 --- a/tools/test/stress2/misc/marcus6.sh +++ b/tools/test/stress2/misc/marcus6.sh @@ -1,83 +1,82 @@ #!/bin/sh # # SPDX-License-Identifier: BSD-2-Clause-FreeBSD # # Copyright (c) 2020 Peter Holm # # 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. # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 [ `swapinfo | wc -l` -eq 1 ] && exit 0 # Variation of marcus5.sh # "panic: Assertion pgrp->pg_jobc > 0 failed at kern_proc.c:740" seen. . ../default.cfg 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 5g -u $mdstart -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint size=$((`sysctl -n hw.physmem` / 1024 / 1024)) [ "`sysctl -n debug.deadlkres.sleepfreq 2>/dev/null`" = "3" ] && { echo "deadlkres must be disabled for this test."; exit 0; } m=`su $testuser -c "limits | awk '/maxprocesses/ {print \\$NF}'"` [ $m -gt 100000 ] && m=100000 rm -rf /tmp/stressX.control export RUNDIR=$mntpoint/stressX export INCARNATIONS=$((m / 11)) export runRUNTIME=3m export LOAD=80 export symlinkLOAD=80 export rwLOAD=80 export TESTPROGS=" testcases/lockf2/lockf2 testcases/symlink/symlink testcases/openat/openat testcases/rw/rw testcases/fts/fts testcases/link/link testcases/lockf/lockf testcases/creat/creat testcases/mkdir/mkdir testcases/rename/rename testcases/mkfifo/mkfifo " timeout -s SIGINT -k 2m 1m su $testuser -c 'cd ..; ./testcases/run/run $TESTPROGS' n=0 while mount | grep $mntpoint | grep -q /dev/md; do umount $mntpoint || sleep 1 [ $((n += 1)) -gt 60 ] && { echo "Timed out"; exit 1; } done -checkfs /dev/md${mdstart}$part; s=$! +checkfs /dev/md$mdstart; s=$! mdconfig -d -u $mdstart exit $s diff --git a/tools/test/stress2/misc/marcus7.sh b/tools/test/stress2/misc/marcus7.sh index 94800c5c5f60..e196a1e60269 100755 --- a/tools/test/stress2/misc/marcus7.sh +++ b/tools/test/stress2/misc/marcus7.sh @@ -1,90 +1,89 @@ #!/bin/sh # # SPDX-License-Identifier: BSD-2-Clause-FreeBSD # # Copyright (c) 2021 Peter Holm # # 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. # # Variation of marcus5.sh with more rename tests. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 [ `swapinfo | wc -l` -eq 1 ] && exit 0 # Copy of marcus4.sh, but with a md(4) disk. # "panic: userret: Returning with SU cleanup request not handled" seen: # https://people.freebsd.org/~pho/stress/log/marcus5.txt # Fixed by r292541. . ../default.cfg 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 5g -u $mdstart -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint size=$((`sysctl -n hw.physmem` / 1024 / 1024)) [ $size -gt $((4 * 1024)) ] && echo "RAM should be capped to 4GB for this test." [ "`sysctl -n debug.deadlkres.sleepfreq 2>/dev/null`" = "3" ] && { echo "deadlkres must be disabled for this test."; exit 0; } n=`find ../testcases -perm -1 -type f | wc -l` m=`su $testuser -c "limits | awk '/maxprocesses/ {print \\$NF}'"` export RUNDIR=$mntpoint/stressX export INCARNATIONS=$((m / n)) export runRUNTIME=10m export LOAD=80 export symlinkLOAD=80 export rwLOAD=80 export TESTPROGS=" testcases/lockf2/lockf2 testcases/symlink/symlink testcases/openat/openat testcases/rw/rw testcases/fts/fts testcases/link/link testcases/lockf/lockf testcases/creat/creat testcases/mkdir/mkdir testcases/rename/rename testcases/mkfifo/mkfifo testcases/dirnprename/dirnprename testcases/dirrename/dirrename " timeout 12m su $testuser -c 'cd ..; ./testcases/run/run $TESTPROGS' n=0 while mount | grep $mntpoint | grep -q /dev/md; do umount $mntpoint || sleep 1 [ $((n += 1)) -gt 300 ] && { echo FAIL; exit 1; } done -checkfs /dev/md${mdstart}$part; s=$! +checkfs /dev/md$mdstart; s=$! mdconfig -d -u $mdstart exit $s diff --git a/tools/test/stress2/misc/md.sh b/tools/test/stress2/misc/md.sh index 47e491e2b841..ae0b090a86cc 100755 --- a/tools/test/stress2/misc/md.sh +++ b/tools/test/stress2/misc/md.sh @@ -1,58 +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. # # 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 > /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 -mount /dev/md${mdstart}$part $mntpoint +newfs md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint 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 diff --git a/tools/test/stress2/misc/md3.sh b/tools/test/stress2/misc/md3.sh index 626d578e54ae..24354c19c4a7 100755 --- a/tools/test/stress2/misc/md3.sh +++ b/tools/test/stress2/misc/md3.sh @@ -1,56 +1,55 @@ #!/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. # # 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 -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint # Stop FS "out of inodes" problem by only using 70% set `df -ik $mntpoint | 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 diff --git a/tools/test/stress2/misc/md4.sh b/tools/test/stress2/misc/md4.sh index 484e531e3f6c..0d760b99b058 100755 --- a/tools/test/stress2/misc/md4.sh +++ b/tools/test/stress2/misc/md4.sh @@ -1,43 +1,44 @@ #!/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. # # Demonstrate data corruption on the swap-backed md. # Test scenario by Nigel Williams . # Fixed in r250966. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 +[ -z "`which bsdlabel`" ] && exit 0 status=0 MD_DEV=`mdconfig -an -t swap -s 1m -x 63 -y 16` fdisk -I md$MD_DEV > /dev/null 2>&1 bsdlabel -w -B md${MD_DEV}s1 || exit 1 dd if=/dev/md$MD_DEV of=/dev/null bs=64k status=none bsdlabel md${MD_DEV}s1 > /dev/null || { echo FAIL; status=1; } mdconfig -d -u $MD_DEV exit $status diff --git a/tools/test/stress2/misc/md9.sh b/tools/test/stress2/misc/md9.sh index a232ade6963f..ab5024404b36 100755 --- a/tools/test/stress2/misc/md9.sh +++ b/tools/test/stress2/misc/md9.sh @@ -1,59 +1,58 @@ #!/bin/sh # # Copyright (c) 2018 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. # # memory disk with vnode on a tmpfs file system triggers: # "g_handleattr(GEOM::ident): md10 bio_length 24 len 31 -> EFAULT" . ../default.cfg [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 set -e mp2=${mntpoint}2 mkdir -p $mp2 mount | grep "on $mp2 " | grep -q /dev/md && umount -f $mp2 mount -t tmpfs tmpfs $mp2 mount | grep "on $mntpoint " | grep -q /dev/md && umount -f $mntpoint [ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart diskimage=$mp2/diskimage dd if=/dev/zero of=$diskimage bs=1m count=2k status=none mdconfig -a -t vnode -f $diskimage -u $mdstart -bsdlabel -w md$mdstart auto -newfs -U /dev/md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs -U /dev/md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint for i in `jot 10`; do umount $mntpoint && break sleep .5 done mount | grep "on $mntpoint " && { echo FATAL; exit 1; } mdconfig -d -u $mdstart umount $mp2 tail -5 /var/log/messages | grep g_handleattr && s=1 || s=0 exit $s diff --git a/tools/test/stress2/misc/mdconfig4.sh b/tools/test/stress2/misc/mdconfig4.sh index fb7bdd869b2a..c8e0530741c0 100755 --- a/tools/test/stress2/misc/mdconfig4.sh +++ b/tools/test/stress2/misc/mdconfig4.sh @@ -1,57 +1,56 @@ #!/bin/sh # # SPDX-License-Identifier: BSD-2-Clause-FreeBSD # # Copyright (c) 2021 Peter Holm # # 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. # # Test scenario from Bug 255119 by nvass@gmx.com # Fatal trap 12: page fault while in kernel mode # Fixed by 54f98c4dbf9b . ../default.cfg 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 512m -u $mdstart || exit 1 -bsdlabel -w md$mdstart auto newfs $newfs_flags md$mdstart > /dev/null mount /dev/md$mdstart $mntpoint md2=$((mdstart + 1)) cp /bin/sleep $mntpoint $mntpoint/sleep 60 & sleep .2 mdconfig -f $mntpoint/sleep -u $md2 2>&1 | grep -v 'Text file busy' kill $! mdconfig -l | grep -q md$md2 && mdconfig -d -u $md2 wait umount $mntpoint mdconfig -d -u $mdstart exit 0 diff --git a/tools/test/stress2/misc/memguard.sh b/tools/test/stress2/misc/memguard.sh index 9b2a3a964d1b..2f80631ee308 100755 --- a/tools/test/stress2/misc/memguard.sh +++ b/tools/test/stress2/misc/memguard.sh @@ -1,65 +1,64 @@ #!/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. # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 # MEMGUARD(9) test scenario: Page fault seen in softdep_setup_inomapdep(). . ../default.cfg sysctl vm | grep -q memguard || { echo "MEMGUARD(9) not enabled"; exit 0; } 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 20m -u $mdstart || exit 1 -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null +newfs $newfs_flags md$mdstart > /dev/null -mount /dev/md${mdstart}$part $mntpoint +mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint export runRUNTIME=5m export RUNDIR=$mntpoint/stressX set `df -ik $mntpoint | tail -1 | awk '{print $4,$7}'` export KBLOCKS=$(($1 * 2)) export INODES=$(($2 * 2)) sysctl vm.memguard.options=3 > /dev/null sysctl vm.memguard.desc=inodedep su $testuser -c 'cd ..; ./run.sh disk.cfg' > /dev/null sysctl vm.memguard.desc="" > /dev/null sysctl vm.memguard.options=1 > /dev/null while mount | grep $mntpoint | grep -q /dev/md; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart diff --git a/tools/test/stress2/misc/memguard2.sh b/tools/test/stress2/misc/memguard2.sh index 4c4619ef89e3..60d6f00357b8 100755 --- a/tools/test/stress2/misc/memguard2.sh +++ b/tools/test/stress2/misc/memguard2.sh @@ -1,68 +1,67 @@ #!/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. # # MEMGUARD(9) test scenario # http://people.freebsd.org/~pho/stress/log/memguard4.txt [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg sysctl vm | grep -q memguard || { echo "MEMGUARD(9) not enabled"; exit 1; } mount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart || exit 1 -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null +newfs $newfs_flags md$mdstart > /dev/null -mount /dev/md${mdstart}$part $mntpoint +mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint export runRUNTIME=30s export RUNDIR=$mntpoint/stressX [ -d $RUNDIR ] || mkdir $RUNDIR chmod 777 $RUNDIR sysctl vm.memguard.options=3 > /dev/null { vmstat -m; echo dummy; } | sed '1d;s/ [0-9].*//;s/^ *//' | \ sed 's/ *$//' | tr '\n' ' ' | ../tools/shuffle | \ tr ' ' '\n' | head -10 | while read type; do sysctl vm.memguard.desc="$type" su $testuser -c 'cd ..; ./run.sh disk.cfg' > /dev/null find /tmp/stressX.control/* $mntpoint/stressX/* -delete 2>/dev/null done sysctl vm.memguard.desc="" > /dev/null sysctl vm.memguard.options=1 > /dev/null while mount | grep $mntpoint | grep -q /dev/md; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart diff --git a/tools/test/stress2/misc/memguard3.sh b/tools/test/stress2/misc/memguard3.sh index 8a7705c71537..d54c8f8e06b8 100755 --- a/tools/test/stress2/misc/memguard3.sh +++ b/tools/test/stress2/misc/memguard3.sh @@ -1,63 +1,62 @@ #!/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. # # MEMGUARD(9) test scenario using "frequency". # "panic: __rw_wlock_hard: recursing but non-recursive rw kmem vm object" # seen. http://people.freebsd.org/~pho/stress/log/memguard5.txt [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg sysctl vm | grep -q memguard || { echo "MEMGUARD(9) not enabled"; exit 1; } sysctl vm.memguard.options=3 sysctl vm.memguard.frequency=1000 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 5g -u $mdstart -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint export runRUNTIME=5m export RUNDIR=$mntpoint/stressX su $testuser -c 'cd ..; ./run.sh marcus.cfg' while mount | grep $mntpoint | grep -q /dev/md; do umount $mntpoint || sleep 1 done -checkfs /dev/md${mdstart}$part; s=$? +checkfs /dev/md$mdstart; s=$? mdconfig -d -u $mdstart sysctl vm.memguard.frequency=0 > /dev/null sysctl vm.memguard.options=1 > /dev/null exit $s diff --git a/tools/test/stress2/misc/memguard4.sh b/tools/test/stress2/misc/memguard4.sh index 323183caf96d..691deec627ca 100755 --- a/tools/test/stress2/misc/memguard4.sh +++ b/tools/test/stress2/misc/memguard4.sh @@ -1,61 +1,60 @@ #!/bin/sh # # Copyright (c) 2017 Dell EMC Isilon # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 # Test without using memguard.options . ../default.cfg sysctl vm | grep -q memguard || { echo "MEMGUARD(9) not enabled"; exit 0; } mount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart || exit 1 -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null +newfs $newfs_flags md$mdstart > /dev/null -mount /dev/md${mdstart}$part $mntpoint +mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint export runRUNTIME=5m export RUNDIR=$mntpoint/stressX sysctl vm.memguard.desc=inodedep su $testuser -c 'cd ..; ./run.sh marcus.cfg' > /dev/null 2>&1 sysctl vm.memguard.desc="" > /dev/null while mount | grep $mntpoint | grep -q /dev/md; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart exit 0 diff --git a/tools/test/stress2/misc/mkfifo.sh b/tools/test/stress2/misc/mkfifo.sh index a0f012da5baa..1ea7dca8472f 100755 --- a/tools/test/stress2/misc/mkfifo.sh +++ b/tools/test/stress2/misc/mkfifo.sh @@ -1,86 +1,85 @@ #!/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. # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 # Hunt for "panic: ufsdirhash_newblk: bad offset" # but page fault seen in scheduler() due to a _thread_lock_flags() call on # an inactive td. # Fault seen in "softdep_disk_io_initiation+0x41": # https://people.freebsd.org/~pho/stress/log/mkfifo.txt # Run with mkfifo.cfg on a 2g swap backed MD . ../default.cfg 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 || exit 1 -bsdlabel -w md$mdstart auto [ "$newfs_flags" = "-U" ] && opt="-j" -newfs $opt md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $opt md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint export runRUNTIME=20m export RUNDIR=$mntpoint/stressX export TESTPROGS=" testcases/creat/creat testcases/fts/fts testcases/link/link testcases/lockf/lockf testcases/mkdir/mkdir testcases/mkfifo/mkfifo testcases/openat/openat testcases/rename/rename testcases/rw/rw testcases/swap/swap " export creatLOAD=100 export ftsLOAD=100 export linkLOAD=100 export lockfLOAD=100 export mkdirLOAD=100 export mkfifoLOAD=100 export openatLOAD=100 export renameLOAD=100 export rwLOAD=100 export swapLOAD=100 su $testuser -c 'cd ..; ./testcases/run/run $TESTPROGS' while mount | grep $mntpoint | grep -q /dev/md; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart exit 0 diff --git a/tools/test/stress2/misc/mkfifo2c.sh b/tools/test/stress2/misc/mkfifo2c.sh index 6d83a5aca4a2..92a69b37d5fa 100755 --- a/tools/test/stress2/misc/mkfifo2c.sh +++ b/tools/test/stress2/misc/mkfifo2c.sh @@ -1,89 +1,88 @@ #!/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. # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 # "bad offset" panic after up 10:57 on leopard3 # Run with mkfifo.cfg on a 2g swap backed MD # Problem seen with and without +j # "panic: ufsdirhash_newblk: bad offset" seen: # https://people.freebsd.org/~pho/stress/log/mkfifo2c.txt # https://people.freebsd.org/~pho/stress/log/mkfifo2c-2.txt # https://people.freebsd.org/~pho/stress/log/kostik932.txt # Fixed by r305601. . ../default.cfg 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 || exit 1 -bsdlabel -w md$mdstart auto [ $# -eq 1 ] && opt="$1" [ $# -eq 0 ] && opt="-j" -newfs $opt md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $opt md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint export runRUNTIME=20m export RUNDIR=$mntpoint/stressX export TESTPROGS=" testcases/fts/fts testcases/link/link testcases/mkfifo/mkfifo testcases/mkdir/mkdir testcases/rename/rename testcases/swap/swap " export ftsLOAD=100 export linkLOAD=100 export mkdirLOAD=100 export mkfifoLOAD=100 export renameLOAD=100 export swapLOAD=100 export renameINCARNATIONS=4 export swapINCARNATIONS=4 export linkINCARNATIONS=12 export mkdirINCARNATIONS=20 export mkfifoINCARNATIONS=22 export ftsINCARNATIONS=2 export HOG=1 su $testuser -c 'cd ..; timeout 15m ./testcases/run/run $TESTPROGS' while mount | grep $mntpoint | grep -q /dev/md; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart diff --git a/tools/test/stress2/misc/mkfifo2d.sh b/tools/test/stress2/misc/mkfifo2d.sh index 74d5875d090f..e5f2b257470a 100755 --- a/tools/test/stress2/misc/mkfifo2d.sh +++ b/tools/test/stress2/misc/mkfifo2d.sh @@ -1,81 +1,80 @@ #!/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. # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 # Copy of mkfifo2c.sh, but with a SU file system and async mount # "panic: ufsdirhash_newblk: bad offset" seen from openat() # https://people.freebsd.org/~pho/stress/log/mkfifo2d.txt # Fixed by r305601. . ../default.cfg 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 || exit 1 -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null -mount -o async /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags md$mdstart > /dev/null +mount -o async /dev/md$mdstart $mntpoint chmod 777 $mntpoint export runRUNTIME=5m export RUNDIR=$mntpoint/stressX export TESTPROGS=" testcases/fts/fts testcases/link/link testcases/mkfifo/mkfifo testcases/mkdir/mkdir testcases/rename/rename testcases/swap/swap " export ftsLOAD=100 export linkLOAD=100 export mkdirLOAD=100 export mkfifoLOAD=100 export renameLOAD=100 export swapLOAD=100 export renameINCARNATIONS=4 export swapINCARNATIONS=4 export linkINCARNATIONS=12 export mkdirINCARNATIONS=20 export mkfifoINCARNATIONS=22 export ftsINCARNATIONS=2 export HOG=1 su $testuser -c 'cd ..; ./testcases/run/run $TESTPROGS' while mount | grep $mntpoint | grep -q /dev/md; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart diff --git a/tools/test/stress2/misc/mknod.sh b/tools/test/stress2/misc/mknod.sh index d2b9aa617577..4a5a826654fa 100755 --- a/tools/test/stress2/misc/mknod.sh +++ b/tools/test/stress2/misc/mknod.sh @@ -1,163 +1,162 @@ #!/bin/sh # # Copyright (c) 2017 Dell EMC Isilon # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # mknod(2) regression test # "panic: ffs_write: type 0xca2b02d0 8 (0,3)" seen. # Reported by: Dmitry Vyukov # Fixed by r324853 . ../default.cfg [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 dir=/tmp odir=`pwd` cd $dir sed '1,/^EOF/d' < $odir/$0 > $dir/mknod.c mycc -o mknod -Wall -Wextra -O0 -g mknod.c || exit 1 rm -f mknod.c cd $odir set -e mount | grep "on $mntpoint " | grep -q /dev/md && umount -f $mntpoint [ -c /dev/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 +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint set +e cd $mntpoint $dir/mknod $mntpoint s=$? [ -f mknod.core -a $s -eq 0 ] && { ls -l mknod.core; mv mknod.core /tmp; s=1; } cd $odir for i in `jot 6`; do mount | grep -q "on $mntpoint " || break umount $mntpoint && break || sleep 10 done [ $i -eq 6 ] && exit 1 mdconfig -d -u $mdstart rm -rf $dir/mknod exit $s EOF #include #include #include #include #include #include #include #include #include #include #include #include static volatile u_int *share; static char *mp; #define PARALLEL 4 #define RUNTIME (1 * 60) #define SYNC 0 static void test(void) { dev_t dev; mode_t mode; time_t start; int fd, n, r; char path[128]; atomic_add_int(&share[SYNC], 1); while (share[SYNC] != PARALLEL) ; n = 0; snprintf(path, sizeof(path), "%s/node.%06d.%d", mp, getpid(), n); start = time(NULL); while ((time(NULL) - start) < RUNTIME) { dev = makedev(arc4random(), arc4random()); mode = arc4random() % 0x10000; r = mknod(path, mode, dev); if (r == 0) { if ((fd = open(path, O_RDWR)) != -1) { write(fd, "x", 1); close(fd); } unlink(path); n++; snprintf(path, sizeof(path), "%s/node.%06d.%d", mp, getpid(), n); } } _exit(0); } int main(int argc, char *argv[]) { pid_t pids[PARALLEL]; size_t len; int e, i, status; if (argc != 2) return (1); mp = argv[1]; e = 0; len = PAGE_SIZE; if ((share = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED, -1, 0)) == MAP_FAILED) err(1, "mmap"); share[SYNC] = 0; for (i = 0; i < PARALLEL; i++) { if ((pids[i] = fork()) == 0) test(); if (pids[i] == -1) err(1, "fork()"); } for (i = 0; i < PARALLEL; i++) { if (waitpid(pids[i], &status, 0) == -1) err(1, "waitpid(%d)", pids[i]); if (status != 0) { if (WIFSIGNALED(status)) fprintf(stderr, "pid %d exit signal %d\n", pids[i], WTERMSIG(status)); } e += status == 0 ? 0 : 1; } return (e); } diff --git a/tools/test/stress2/misc/mlockall5.sh b/tools/test/stress2/misc/mlockall5.sh index 847909b478c2..18f568ac7024 100755 --- a/tools/test/stress2/misc/mlockall5.sh +++ b/tools/test/stress2/misc/mlockall5.sh @@ -1,162 +1,161 @@ #!/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. # # Regression test for r287591: # From the commit log: # Remove a check which caused spurious SIGSEGV on usermode access to the # mapped address without valid pte installed, when parallel wiring of # the entry happen. The entry must be copy on write. If entry is COW # but was already copied, and parallel wiring set # MAP_ENTRY_IN_TRANSITION, vm_fault() would sleep waiting for the # MAP_ENTRY_IN_TRANSITION flag to clear. After that, the fault handler # is restarted and vm_map_lookup() or vm_map_lookup_locked() trip over # the check. Note that this is race, if the address is accessed after # the wiring is done, the entry does not fault at all. # Test scenario by kib@. . ../default.cfg [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 dir=/tmp odir=`pwd` cd $dir sed '1,/^EOF/d' < $odir/$0 > $dir/mlockall5.c mycc -o mlockall5 -Wall -Wextra -O0 -g mlockall5.c -lpthread || exit 1 rm -f mlockall5.c cd $odir mount | grep "on $mntpoint " | grep -q /dev/md && umount -f $mntpoint [ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart mdconfig -a -t swap -s 512m -u $mdstart || exit 1 -bsdlabel -w md$mdstart auto -newfs $newfs_flags -n md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint || exit 1 +newfs $newfs_flags -n md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint || exit 1 (cd $mntpoint; /tmp/mlockall5 || echo FAIL) n=0 while mount | grep "on $mntpoint " | grep -q /dev/md; do umount $mntpoint || sleep 1 n=$((n + 1)) [ $n -gt 10 ] && { echo FAIL; exit 1; } done mdconfig -d -u $mdstart rm -rf /tmp/mlockall5 exit EOF #include #include #include #include #include #include #include #include #include #include #include size_t clen; volatile u_int share; int ps; char *c; void * touch(void *arg __unused) { int i; while (share == 0) ; for (i = 0; i < (int)clen; i += ps) c[i] = 1; return (NULL); } void * ml(void *arg __unused) { while (share == 0) ; if (mlockall(MCL_CURRENT | MCL_FUTURE) == -1) err(1, "mlock"); return (NULL); } int test(void) { pthread_t tid[2]; int i, rc, status; if (fork() == 0) { alarm(60); rc = pthread_create(&tid[0], NULL, touch, NULL); if (rc != 0) errc(1, rc, "pthread_create()"); rc = pthread_create(&tid[1], NULL, ml, NULL); if (rc != 0) errc(1, rc, "pthread_create()"); share = 1; for (i = 0; i < (int)nitems(tid); i++) { rc = pthread_join(tid[i], NULL); if (rc != 0) errc(1, rc, "pthread_join(%d)", i); } _exit(0); } if (wait(&status) == -1) err(1, "wait"); return (WTERMSIG(status)); } int main(void) { int s; ps = getpagesize(); clen = 32 * 1024; if ((c = mmap(NULL, clen, PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED, -1, 0)) == MAP_FAILED) err(1, "mmap"); s = test(); return (s); } diff --git a/tools/test/stress2/misc/mlockall6.sh b/tools/test/stress2/misc/mlockall6.sh index a755350f673d..b83e033736fc 100755 --- a/tools/test/stress2/misc/mlockall6.sh +++ b/tools/test/stress2/misc/mlockall6.sh @@ -1,203 +1,202 @@ #!/bin/sh # # SPDX-License-Identifier: BSD-2-Clause-FreeBSD # # Copyright (c) 2019 Dell EMC Isilon # # 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. # # "panic: Lock (rw) vm object not locked @ vm/vm_page.c:1013" seen: # https://people.freebsd.org/~pho/stress/log/mlockall6-2.txt . ../default.cfg [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 [ `swapinfo | wc -l` -eq 1 ] && exit 0 dir=/tmp odir=`pwd` cd $dir sed '1,/^EOF/d' < $odir/$0 > $dir/mlockall6.c mycc -o mlockall6 -Wall -Wextra -O0 -g mlockall6.c || exit 1 rm -f mlockall6.c cd $odir 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 512m -u $mdstart || exit 1 -bsdlabel -w md$mdstart auto -newfs $newfs_flags -n md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint || exit 1 +newfs $newfs_flags -n md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint || exit 1 daemon sh -c "(cd $odir/../testcases/swap; ./swap -t 20m -i 20 -l 100)" \ > /dev/null 2>&1 sleep 2 (cd $mntpoint; /tmp/mlockall6 || echo FAIL) while pgrep -q swap; do pkill -9 swap done n=0 while mount | grep "on $mntpoint " | grep -q /dev/md; do umount $mntpoint || sleep 1 n=$((n + 1)) [ $n -gt 10 ] && { echo FAIL; exit 1; } done mdconfig -d -u $mdstart rm -rf /tmp/mlockall6 exit 0 EOF #include #include #include #include #include #include #include #include #include #include #include #include #define LOOPS 2 #define PARALLEL 8 #define R0 0 #define R1 1 #define R2 2 #define RUNTIME (10 * 60) static volatile u_int *share; static int ps; static char c[32 * 1024 * 1024]; static void touch(void) { int i; for (i = 0; i < (int)sizeof(c); i += ps) c[i] = 1; } static void test2(void) { pid_t pid; volatile u_int *share2; size_t len; int i, status; len = ps; if ((share2 = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED, -1, 0)) == MAP_FAILED) err(1, "mmap"); touch(); usleep(arc4random() % 100000); alarm(600); if ((pid = fork()) == 0) { alarm(600); while (share2[R1] == 0) /* Wait for parent */ ; atomic_add_int(&share2[R1], 1); if (arc4random() % 100 < 50) usleep(arc4random() % 1000); if (mlockall(MCL_CURRENT | MCL_FUTURE) == -1) err(1, "mlock"); touch(); atomic_add_int(&share2[R2], 1); _exit(0); } atomic_add_int(&share2[R1], 1); while (share2[R1] != 2) /* Wait for child */ ; for (i = 0; i < 100000 && share2[R2] == 0; i++) touch(); /* while child is running */ if (waitpid(pid, &status, 0) == -1) err(1, "wait"); if (status != 0) fprintf(stderr, "Got signal %d\n", WTERMSIG(status)); _exit(WTERMSIG(status)); } static void test(void) { pid_t pid; int i, s, status; while (share[R0] == 0) ; s = 0; for (i = 0; i < LOOPS; i++) { if ((pid = fork()) == 0) test2(); waitpid(pid, &status, 0); s = (s == 0) ? status : s; } _exit(s); } int main(void) { pid_t pid; size_t len; time_t start; int i, s, status; ps = getpagesize(); len = ps; if ((share = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED, -1, 0)) == MAP_FAILED) err(1, "mmap"); start = time(NULL); s = 0; while (s == 0 && (time(NULL) - start) < RUNTIME) { for (i = 0; i < PARALLEL; i++) { if ((pid = fork()) == 0) test(); } atomic_add_int(&share[R0], 1); /* Start test() runs */ for (i = 0; i < PARALLEL; i++) { waitpid(pid, &status, 0); if (status != 0) { fprintf(stderr, "FAIL: status = %d\n", status); } s = (s == 0) ? status : s; } atomic_add_int(&share[R0], -1); } return (s); } diff --git a/tools/test/stress2/misc/mmap24.sh b/tools/test/stress2/misc/mmap24.sh index 4a25a0e3520f..867c42f0ed9b 100755 --- a/tools/test/stress2/misc/mmap24.sh +++ b/tools/test/stress2/misc/mmap24.sh @@ -1,99 +1,98 @@ #!/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. # # "panic: vm_page_unwire: page 0xc36cafbc's wire count is zero" seen. # https://people.freebsd.org/~pho/stress/log/mmap24.txt # Test scenario by trasz@. # Fixed by r285878. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg dir=/tmp odir=`pwd` cd $dir sed '1,/^EOF/d' < $odir/$0 > $dir/mmap24.c mycc -o mmap24 -Wall -Wextra mmap24.c || exit 1 rm -f mmap24.c cd $odir [ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart || exit 1 -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint cp /tmp/mmap24 $mntpoint (cd $mntpoint; ./mmap24) & sleep .2 umount -f $mntpoint kill $! wait while mount | grep "on $mntpoint " | grep -q /dev/md; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart rm -f /tmp/mmap24 exit EOF #include #include #include #include #include #include #include #include #include #include #include #include #include #include int main(void) { int error; error = mlockall(MCL_CURRENT | MCL_FUTURE); if (error != 0) err(1, "mlockall"); for (;;) { sleep(1); } } diff --git a/tools/test/stress2/misc/mmap29.sh b/tools/test/stress2/misc/mmap29.sh index e6aacc15e48e..207bdb137b99 100755 --- a/tools/test/stress2/misc/mmap29.sh +++ b/tools/test/stress2/misc/mmap29.sh @@ -1,71 +1,70 @@ #!/bin/sh # Test scenario by: David Cross # "panic: softdep_deallocate_dependencies: dangling deps" seen. # https://people.freebsd.org/~pho/stress/log/mmap29.txt # Fixed by: r302567. . ../default.cfg [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 [ -z "`which timeout`" ] && exit 0 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 -U md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs -U md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint mkdir $mntpoint/mmap29 cd /tmp cat > mmap29.c < #include #include #include #include #include #include #include int main(int argc, char **argv) { int fd; unsigned char *memrange; if (argc != 2) { fprintf(stderr, "Usage: %s \n", argv[0]); exit(1); } unlink(argv[1]); if ((fd = open(argv[1], O_RDWR | O_CREAT, DEFFILEMODE)) == -1) err(1, "open(%s)", argv[1]); lseek(fd, 0xbfff, SEEK_SET); write(fd, "\0", 1); if ((memrange = mmap(0, 0x2b6000, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_HASSEMAPHORE | MAP_NOSYNC, fd, 0)) == MAP_FAILED) err(1, "mmap"); memrange[0] = 5; munmap(memrange, 0x2b6000); close(fd); return (0); } EOFHERE cc -o mmap29 -Wall -Wextra -O0 -g mmap29.c || exit 1 rm mmap29.c ./mmap29 $mntpoint/mmap29/mmap291 old=`sysctl -n kern.maxvnodes` trap "sysctl kern.maxvnodes=$old" EXIT INT sysctl kern.maxvnodes=2000 timeout 60 find / -xdev -print >/dev/null while mount | grep "on $mntpoint " | grep -q /dev/md; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart rm mmap29 exit 0 diff --git a/tools/test/stress2/misc/mmap33.sh b/tools/test/stress2/misc/mmap33.sh index 70ac054a9934..de7262c1bf1f 100755 --- a/tools/test/stress2/misc/mmap33.sh +++ b/tools/test/stress2/misc/mmap33.sh @@ -1,121 +1,120 @@ #!/bin/sh # # SPDX-License-Identifier: BSD-2-Clause-FreeBSD # # Copyright (c) 2021 Peter Holm # # 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. # # ftruncate+mmap+fsync fails for small maps # https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=225586 # Original test scenario by tris_vern@hotmail.com # Fixed in r328773: # On pageout, in vnode generic pager, for partially dirty page, only # clear dirty bits for completely invalid blocks. . ../default.cfg cat > /tmp/mmap33.c < #include #include #include #include #include #include int main (int argc, char *argv[]) { size_t i, size1, size2; int fd; char *data; char *filename; char pattern = 0x01; if (argc != 4) { fprintf(stderr, "Usage: %s filename size1 size2\n", argv[0]); exit(1); } filename = argv[1]; size1 = atoi(argv[2]); size2 = atoi(argv[3]); fd = open(filename, O_RDWR | O_TRUNC | O_CREAT, 0644); for (i = 0; i < size1; i++) write(fd, &pattern, 1); close(fd); fd = open(filename, O_RDWR, 0644); if (fd == -1) err(1, "open(%s)", filename); if (ftruncate(fd, size2) == -1) err(1, "ftruncate()"); data = mmap(NULL, size2, PROT_READ|PROT_WRITE,MAP_SHARED, fd, 0); if (data == MAP_FAILED) err(1, "mmap()"); memset(data, 0xFF, size2); if (munmap(data, size2) == -1) err(1, "munmap"); close(fd); return (0); } EOF cc -o /tmp/mmap33 -Wall -Wextra -O2 -g /tmp/mmap33.c || exit 1 rm /tmp/mmap33.c set -e mount | grep "on $mntpoint " | grep -q /dev/md && umount -f $mntpoint [ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart mdconfig -a -t swap -s 2g -u $mdstart -bsdlabel -w md$mdstart auto -newfs $newfs_flags -n md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags -n md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint set +e file=file odir=`pwd` cd $mntpoint /tmp/mmap33 $file 1024 511 s=$? sum1=`md5 < $mntpoint/$file` [ -f mmap33.core -a $s -eq 0 ] && { ls -l mmap33.core; mv mmap33.core /tmp; s=1; } cd $odir umount $mntpoint -mount /dev/md${mdstart}$part $mntpoint +mount /dev/md$mdstart $mntpoint # This fails for truncate size < 512 sum2=`md5 < $mntpoint/$file` [ $sum1 = $sum2 ] || { s=2; echo "md5 fingerprint differs."; } umount $mntpoint mdconfig -d -u $mdstart rm /tmp/mmap33 exit $s diff --git a/tools/test/stress2/misc/mmap4.sh b/tools/test/stress2/misc/mmap4.sh index 8c84401fb960..5303a4fbaeba 100755 --- a/tools/test/stress2/misc/mmap4.sh +++ b/tools/test/stress2/misc/mmap4.sh @@ -1,116 +1,115 @@ #!/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. # # 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 -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $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; volatile char *c; char *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); } diff --git a/tools/test/stress2/misc/mount.sh b/tools/test/stress2/misc/mount.sh index 4b020ca919bd..79639c90ed24 100755 --- a/tools/test/stress2/misc/mount.sh +++ b/tools/test/stress2/misc/mount.sh @@ -1,82 +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. # # Mount regression test # panic: vm_fault: fault on nofault entry, addr: deadc000 # cpuid = 1 # KDB: enter: panic # [thread pid 69453 tid 100388 ] # Stopped at kdb_enter+0x2b: nop # db> where # Tracing pid 69453 tid 100388 td 0xc4b5c1b0 # kdb_enter(c091d9db) at kdb_enter+0x2b # panic(c0938fa0,deadc000,e6b44834,c06c650e,c0a57d20,...) at panic+0x14b # vm_fault(c1869000,deadc000,1,0) at vm_fault+0x1e0 # trap_pfault(e6b4499c,0,deadc112) at trap_pfault+0x137 # trap(8,c0910028,28,deadc0de,deadc0de,...) at trap+0x3f5 # calltrap() at calltrap+0x5 # --- trap 0xc, eip = 0xc0667def, esp = 0xe6b449dc, ebp = 0xe6b44a00 --- # g_io_request(c66d6bdc,c4a1d840,d7c99940,d7c99940,e6b44a34,...) at g_io_request+0x5f # g_vfs_strategy(c40624c4,d7c99940,d7c99940,0,c4e16dec,...) at g_vfs_strategy+0x49 # ffs_geom_strategy(c40624c4,d7c99940,4ba0,0,c09dad00,...) at ffs_geom_strategy+0x141 # ufs_strategy(e6b44a7c) at ufs_strategy+0xb5 # VOP_STRATEGY_APV(c09da7c0,e6b44a7c) at VOP_STRATEGY_APV+0x95 # bufstrategy(c50d2be0,d7c99940) at bufstrategy+0x55 # breadn(c50d2b2c,0,0,1000,0,...) at breadn+0xf7 # bread(c50d2b2c,0,0,1000,0,...) at bread+0x20 # ffs_read(e6b44bb0) at ffs_read+0x23f # VOP_READ_APV(c09da7c0,e6b44bb0) at VOP_READ_APV+0x7e # ufs_readdir(e6b44c38) at ufs_readdir+0xd1 # VOP_READDIR_APV(c09da7c0,e6b44c38) at VOP_READDIR_APV+0x7e # getdirentries(c4b5c1b0,e6b44d04) at getdirentries+0x13f # syscall(3b,3b,3b,8240160,1,...) at syscall+0x256 [ `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 -newfs $newfs_flags md${mdstart}$part > /dev/null +newfs $newfs_flags md$mdstart > /dev/null # The test: echo "Expect: mount: /dev/md5a: Device busy" -mount -r /dev/md${mdstart}$part $mntpoint -mount -r /dev/md${mdstart}$part $mntpoint +mount -r /dev/md$mdstart $mntpoint +mount -r /dev/md$mdstart $mntpoint umount $mntpoint ls -lR $mntpoint > /dev/null # panic # End of test mount | grep -q "$mntpoint" && umount $mntpoint mdconfig -l | grep -q $mdstart && mdconfig -d -u $mdstart diff --git a/tools/test/stress2/misc/mount2.sh b/tools/test/stress2/misc/mount2.sh index d4b30bafe711..cfb3b81e47fb 100755 --- a/tools/test/stress2/misc/mount2.sh +++ b/tools/test/stress2/misc/mount2.sh @@ -1,73 +1,72 @@ #!/bin/sh # # Copyright (c) 2008 Peter Holm # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # Stress test by performing parallel calls to mount and umount. Alternate # between forced and non-forced unmounts. # "kernel: g_dev_taste: make_dev_p() failed (gp->name=md10, error=17)" seen. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg mounts=15 # Number of parallel scripts D=$diskimage 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 dd if=/dev/zero of=$D$m bs=1m count=1 status=none 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 + newfs md${m} > /dev/null done # start the parallel tests for i in `jot $mounts`; do m=$(( i + mdstart - 1 )) start=`date +%s` while [ $((`date +%s` - start)) -lt 300 ]; do opt=`[ $(( m % 2 )) -eq 0 ] && echo -f` - mount /dev/md${m}$part ${mntpoint}$m + mount /dev/md${m} ${mntpoint}$m while mount | grep -q ${mntpoint}$m; do umount $opt ${mntpoint}$m > /dev/null 2>&1 done done & done wait for i in `jot $mounts`; do m=$((i + mdstart - 1)) mdconfig -d -u $m rm -f $D$m done exit 0 diff --git a/tools/test/stress2/misc/mountro.sh b/tools/test/stress2/misc/mountro.sh index 38f6c6e5bd10..74fddb10b751 100755 --- a/tools/test/stress2/misc/mountro.sh +++ b/tools/test/stress2/misc/mountro.sh @@ -1,67 +1,66 @@ #!/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. # # Page fault seen: https://people.freebsd.org/~pho/stress/log/mountro.txt # Fixed by r346031 . ../default.cfg [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 D=$diskimage dd if=/dev/zero of=$D bs=1m count=128 status=none || exit 1 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 +newfs $newfs_flags md$mdstart > /dev/null 2>&1 +mount /dev/md$mdstart $mntpoint mkdir $mntpoint/stressX chmod 777 $mntpoint/stressX export RUNDIR=$mntpoint/stressX export runRUNTIME=4m (cd ..; ./run.sh disk.cfg > /dev/null 2>&1) & sleep 10 for i in `jot 10`; do mount -u -o ro $mntpoint sleep 3 mount -u -o rw $mntpoint sleep 3 done > /dev/null 2>&1 umount -f $mntpoint mdconfig -d -u $mdstart rm -f $D pkill run.sh wait diff --git a/tools/test/stress2/misc/mountro2.sh b/tools/test/stress2/misc/mountro2.sh index a57c6776fb03..33ccb9694dae 100755 --- a/tools/test/stress2/misc/mountro2.sh +++ b/tools/test/stress2/misc/mountro2.sh @@ -1,54 +1,53 @@ #!/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. # # Test scenario by Matthew D. Fuller . ../default.cfg [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 D=$diskimage dd if=/dev/zero of=$D bs=1m count=20 status=none || exit 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 +newfs $newfs_flags md$mdstart > /dev/null 2>&1 +mount /dev/md$mdstart $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 diff --git a/tools/test/stress2/misc/mountro3.sh b/tools/test/stress2/misc/mountro3.sh index e1749dfdc391..fd2959f59de6 100755 --- a/tools/test/stress2/misc/mountro3.sh +++ b/tools/test/stress2/misc/mountro3.sh @@ -1,56 +1,55 @@ #!/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. # # Test scenario by barbara # kern/121809: unable to umount [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg D=$diskimage dd if=/dev/zero of=$D bs=1m count=64 status=none || exit 1 -mount | grep "$mntpoint" | grep md${mdstart}$part > /dev/null && umount $mntpoint +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 || { rm -f $D; exit 1; } -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null 2>&1 +newfs $newfs_flags md$mdstart > /dev/null 2>&1 -mount /dev/md${mdstart}$part $mntpoint +mount /dev/md$mdstart $mntpoint touch $mntpoint/file umount $mntpoint -mount /dev/md${mdstart}$part $mntpoint +mount /dev/md$mdstart $mntpoint rm $mntpoint/file mount -u -o ro $mntpoint # Should fail with "Device busy" umount $mntpoint mdconfig -d -u $mdstart rm -f $D diff --git a/tools/test/stress2/misc/mountro4.sh b/tools/test/stress2/misc/mountro4.sh index b6ff922d5ff9..eddc345c85af 100755 --- a/tools/test/stress2/misc/mountro4.sh +++ b/tools/test/stress2/misc/mountro4.sh @@ -1,100 +1,102 @@ #!/bin/sh # # SPDX-License-Identifier: BSD-2-Clause-FreeBSD # # Copyright (c) 2019 Dell EMC Isilon # # 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. # # Check that the time stamps are not updated for a RO mount. . ../default.cfg f1=$mntpoint/f1 f2=$mntpoint/f2 s=0 # ufs mount | grep -q "on $mntpoint " && umount $mntpoint [ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart newfs $newfs_flags /dev/md$mdstart > /dev/null mount /dev/md$mdstart $mntpoint || exit 1 touch $f1 mount -u -o ro $mntpoint touch $f2 2>/dev/null && { echo "ufs: ro failed"; s=1; } d1=`stat -f '%a %m %c' $f1` sleep 1 cat $f1 > /dev/null d2=`stat -f '%a %m %c' $f1` if [ "$d1" != "$d2" ]; then echo "ufs: Access time was updated. $d1 != $d2" s=1 fi mount -u -o rw $mntpoint touch $f2 2>/dev/null || { echo "ufs: rw failed"; s=1; } umount $mntpoint mdconfig -d -u $mdstart # tmpfs mount -o size=100m -t tmpfs null $mntpoint || exit 1 touch $f1 mount -u -o ro $mntpoint touch $f2 2>/dev/null && { echo "tmpfs: ro failed"; s=1; } d1=`stat -f '%a %m %c' $f1` sleep 1 cat $f1 > /dev/null d2=`stat -f '%a %m %c' $f1` if [ "$d1" != "$d2" ]; then echo "tmpfs: Access time was updated. $d1 != $d2" s=1 fi mount -u -o rw $mntpoint touch $f2 2>/dev/null || { echo "tmpfs: rw failed"; s=1; } umount $mntpoint # msdosfs [ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart -bsdlabel -w md$mdstart auto +gpart create -s bsd md$mdstart > /dev/null +gpart add -t freebsd-ufs md$mdstart > /dev/null +part=a newfs_msdos /dev/md${mdstart}$part > /dev/null mount -t msdosfs /dev/md${mdstart}$part $mntpoint || exit 1 touch $f1 mount -u -o ro $mntpoint touch $f2 2>/dev/null && { echo "msdosfs: ro failed"; s=1; } d1=`stat -f '%a %m %c' $f1` sleep 1 cat $f1 > /dev/null d2=`stat -f '%a %m %c' $f1` if [ "$d1" != "$d2" ]; then echo "msdosfs: Access time was updated. $d1 != $d2" s=1 fi mount -u -o rw $mntpoint touch $f2 2>/dev/null || { echo "msdosfs: rw failed"; s=1; } umount $mntpoint mdconfig -d -u $mdstart exit $s diff --git a/tools/test/stress2/misc/mountu.sh b/tools/test/stress2/misc/mountu.sh index 1c1b619463cd..838850ef3e96 100755 --- a/tools/test/stress2/misc/mountu.sh +++ b/tools/test/stress2/misc/mountu.sh @@ -1,284 +1,288 @@ #!/bin/sh # # SPDX-License-Identifier: BSD-2-Clause-FreeBSD # # Copyright (c) 2012 Peter Holm # Copyright (c) 2019 Dell EMC Isilon # # 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. # # Change mount point from rw to ro with a file mapped rw # Currently fails for NFS # Page fault seen: # https://people.freebsd.org/~pho/stress/log/mountu.txt # Fixed by: r285039. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > mountu.c mycc -o mountu -Wall -Wextra -O2 mountu.c || exit 1 rm -f mountu.c pstat() { local pid pid=`ps ax | grep -v grep | grep /tmp/mountu | awk '{print $1}'` [ -n "$pid" ] && procstat -v $pid } ck() { if mount | grep $mntpoint | grep -q "read-only"; then if pstat $!| awk "\$2 == \"$map\"" | grep -q " rw-"; then echo echo "$1 difference" mount | grep $mntpoint printf "RW mount mapping and RO mount mapping:\n%s\n" "$r" pstat $! | awk "\$2 == \"$map\"" status=$((status + 1)) fi else echo "$1 mount point RO did not succeed" mount | grep $mntpoint status=$((status + 1)) fi } status=0 file=$mntpoint/mountu.sh.file mapfile=/tmp/mountu.sh.map mount | grep -q "$mntpoint " && umount $mntpoint mdconfig -l | grep -q $mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 100m -u $mdstart -bsdlabel -w md$mdstart auto +gpart create -s bsd md$mdstart > /dev/null +gpart add -t freebsd-ufs md$mdstart > /dev/null +part=a newfs $newfs_flags md${mdstart}$part > /dev/null mount /dev/md${mdstart}$part $mntpoint chmod 777 $mntpoint # ufs exec 5>$mapfile /tmp/mountu UFS $file & pid=$! sleep 1 map=`cat $mapfile`; rm $mapfile; exec 5>&- r=`pstat $! | awk "\\$2 == \"$map\""` mount -u -o ro $mntpoint 2>/dev/null || mount -fu -o ro $mntpoint ck UFS mount -u -o rw $mntpoint rm -f $file wait $pid s=$? [ $s -ne 139 ] && { echo "UFS exit status is $s"; status=1; } while mount | grep -q "$mntpoint "; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart # nfs if ping -c 2 `echo $nfs_export | sed 's/:.*//'` > /dev/null 2>&1; then mount -t nfs -o tcp -o retrycnt=3 -o intr,soft -o rw $nfs_export \ $mntpoint sleep .2 rm -f $file /tmp/mountu NFS $file & pid=$! sleep 1 r=`pstat $! | awk "\\$2 == \"$map\""` mount -u -o ro $mntpoint 2>/dev/null || mount -fu -o ro $mntpoint 2>/dev/null ck NFS wait $pid s=$? [ $s -ne 139 ] && { echo "NFS exit status is $s"; status=1; } mount -u -o rw $mntpoint 2>/dev/null sleep .2 [ -f $file ] && rm -f $file umount $mntpoint || umount $mntpoint fi # msdos if [ -x /sbin/mount_msdosfs ]; then mdconfig -a -t swap -s 100m -u $mdstart - bsdlabel -w md$mdstart auto + gpart create -s bsd md$mdstart > /dev/null + gpart add -t freebsd-ufs md$mdstart > /dev/null + part=a newfs_msdos -F 16 -b 8192 /dev/md${mdstart}$part > /dev/null 2>&1 mount_msdosfs -m 777 /dev/md${mdstart}$part $mntpoint /tmp/mountu MSDOS $file & pid=$! sleep 1 r=`pstat $! | awk "\\$2 == \"$map\""` mount -u -o ro $mntpoint 2>/dev/null || mount -fu -o ro $mntpoint ck MSDOS wait $pid s=$? [ $s -ne 139 ] && { echo "MSDOS exit status is $s"; status=1; } mount -u -o rw $mntpoint rm -f $file while mount | grep -q "$mntpoint "; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart fi # tmpfs mount -t tmpfs null $mntpoint chmod 777 $mntpoint /tmp/mountu TMPFS $file & pid=$! sleep 1 r=`pstat $! | awk "\\$2 == \"$map\""` mount -u -o ro $mntpoint 2>/dev/null || mount -fu -o ro $mntpoint ck TMPFS sleep 1 mount -u -o rw $mntpoint rm -f $file wait $pid s=$? [ $s -ne 139 ] && { echo "TMPFS exit status is $s"; status=1; } while mount | grep -q "$mntpoint "; do umount $mntpoint || sleep 1 done rm -f /tmp/mountu exit 0 EOF /* kib@ noted: UFS/NFS/msdosfs reclaim vnode on rw->ro forced remount, and change the type of the underying object to OBJT_DEAD, but leave the pages on the object queue and installed in the page tables. Applications can read/write already mapped pages, but cannot page in new pages, cannot observe possible further modifications to already mapped pages (if ro->rw remount happen later), and their updates to pages are not flushed to file. It is impossible to mimic this behaviour for tmpfs. */ #include #include #include #include #include #include #include #include #include #include #include #include #define STARTADDR 0x0U #define ADRSPACE 0x0640000U static void sighandler(int signo, siginfo_t *si, void *uc1) { ucontext_t *uc; uc = uc1; printf("SIG%s at %p, addr %p\n", sys_signame[signo], si->si_addr, #if defined(__i386__) (void *)uc->uc_mcontext.mc_eip); #else (void *)uc->uc_mcontext.mc_rip); #endif exit(1); } int main(int argc __unused, char **argv) { struct passwd *pw; struct sigaction sa; void *p; size_t len; int fd; char *name, *path; volatile char *c; memset(&sa, 0, sizeof(sa)); sa.sa_sigaction = sighandler; sa.sa_flags = SA_SIGINFO; if (sigaction(SIGSEGV, &sa, NULL) == -1) err(1, "sigaction(SIGSEGV)"); if (sigaction(SIGBUS, &sa, NULL) == -1) err(1, "sigaction(SIGBUS)"); if ((pw = getpwnam("nobody")) == NULL) err(1, "no such user: nobody"); if (setgroups(1, &pw->pw_gid) || setegid(pw->pw_gid) || setgid(pw->pw_gid) || seteuid(pw->pw_uid) || setuid(pw->pw_uid)) err(1, "Can't drop privileges to \"nobody\""); endpwent(); p = (void *)STARTADDR; len = ADRSPACE; name = argv[1]; path = argv[2]; if ((fd = open(path, O_CREAT | O_TRUNC | O_RDWR, 0622)) == -1) err(1,"open(%s)", path); if (ftruncate(fd, len) == -1) err(1, "ftruncate"); if ((p = mmap(p, len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)) == MAP_FAILED) { if (errno == ENOMEM) { warn("mmap()"); return (1); } err(1, "mmap(1)"); } dprintf(5, "%p\n", p); for (c = p; (void *)c < p + len; c += PAGE_SIZE) { *c = 1; } close(fd); sleep(5); fprintf(stderr, "%s: Late read start.\n", name); for (c = p; (void *)c < p + len; c += PAGE_SIZE) { *c; } fprintf(stderr, "%s: Late read complete.\n", name); fprintf(stderr, "%s: Late write start.\n", name); for (c = p; (void *)c < p + len; c += PAGE_SIZE) { *c = 1; } fprintf(stderr, "%s: Late write complete.\n", name); return (0); } diff --git a/tools/test/stress2/misc/msdos.sh b/tools/test/stress2/misc/msdos.sh index 2324404bfd16..c0f38ba3011b 100755 --- a/tools/test/stress2/misc/msdos.sh +++ b/tools/test/stress2/misc/msdos.sh @@ -1,60 +1,62 @@ #!/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. # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 # LOR seen. Fixed by r204467. . ../default.cfg [ -x /sbin/mount_msdosfs ] || exit log=/tmp/msdos.sh.log 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 +gpart create -s bsd md$mdstart > /dev/null +gpart add -t freebsd-ufs md$mdstart > /dev/null +part=a 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 > $log 2>&1 s=0 if egrep -q "BAD|INCONSISTENCY|MODIFIED" $log; then cat $log rm $log s=1 fi mdconfig -d -u $mdstart exit $s diff --git a/tools/test/stress2/misc/msdos10.sh b/tools/test/stress2/misc/msdos10.sh index 09613a859082..b581a71d3519 100755 --- a/tools/test/stress2/misc/msdos10.sh +++ b/tools/test/stress2/misc/msdos10.sh @@ -1,89 +1,91 @@ #!/bin/sh # # Copyright (c) 2017 Dell EMC Isilon # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # fsx test of with msdosfs and a 1k block size # "panic: Assertion ma[i]->dirty == VM_PAGE_BITS_ALL failed" seen. # Fixed by r324794 # Original test scenario by fsu@freebsd.org . ../default.cfg [ `id -u` -ne 0 ] && echo "Must be root!" && exit 1 [ -r /usr/src/tools/regression/fsx/fsx.c ] || exit 0 [ -x /sbin/mount_msdosfs ] || exit 0 dir=/tmp odir=`pwd` cd $dir cc -o fsx -Wall -Wextra -O2 -g /usr/src/tools/regression/fsx/fsx.c || exit 1 rm -f fsx.c cd $odir log=/tmp/fsx.sh.log mount | grep "$mntpoint" | grep -q md$mdstart && umount -f $mntpoint mdconfig -l | grep -q $mdstart && mdconfig -d -u $mdstart set -e mdconfig -a -t swap -s 4g -u $mdstart -bsdlabel -w md$mdstart auto +gpart create -s bsd md$mdstart > /dev/null +gpart add -t freebsd-ufs md$mdstart > /dev/null +part=a newfs_msdos -b 1024 /dev/md${mdstart}$part > /dev/null mount -t msdosfs /dev/md${mdstart}$part $mntpoint set +e cp /tmp/fsx $mntpoint cd $mntpoint NUM_OPS=2000 SEED=2016 ( ./fsx -S ${SEED} -N ${NUM_OPS} ./TEST_FILE0 & ./fsx -S ${SEED} -l 5234123 -o 5156343 -N ${NUM_OPS} ./TEST_FILE1 & ./fsx -S ${SEED} -l 2311244 -o 2311200 -N ${NUM_OPS} ./TEST_FILE2 & ./fsx -S ${SEED} -l 8773121 -o 863672 -N ${NUM_OPS} ./TEST_FILE3 & ./fsx -S ${SEED} -l 234521 -o 234521 -N ${NUM_OPS} ./TEST_FILE4 & ./fsx -S ${SEED} -l 454321 -o 33 -N ${NUM_OPS} ./TEST_FILE5 & ./fsx -S ${SEED} -l 7234125 -o 7876728 -N ${NUM_OPS} ./TEST_FILE6 & wait ) > /dev/null cd / while mount | grep "$mntpoint" | grep -q md$mdstart; do umount $mntpoint || sleep 1 done fsck -t msdosfs -y /dev/md${mdstart}$part > $log 2>&1 if egrep -q "BAD|INCONSISTENCY|MODIFIED" $log; then cat $log s=1 mount -t msdosfs /dev/md${mdstart}$part $mntpoint || exit 1 ls -lR $mntpoint umount $mntpoint fi mdconfig -d -u $mdstart rm /tmp/fsx $log exit $s diff --git a/tools/test/stress2/misc/msdos11.sh b/tools/test/stress2/misc/msdos11.sh index af0958686118..c14ef55f1f7c 100755 --- a/tools/test/stress2/misc/msdos11.sh +++ b/tools/test/stress2/misc/msdos11.sh @@ -1,80 +1,82 @@ #!/bin/sh # # SPDX-License-Identifier: BSD-2-Clause-FreeBSD # # Copyright (c) 2021 Peter Holm # # 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. # # https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=257522 # https://people.freebsd.org/~pho/stress/log/log0158.txt # Original test scenario by trasz@FreeBSD.org . ../default.cfg [ `id -u` -ne 0 ] && echo "Must be root!" && exit 1 [ -x /sbin/mount_msdosfs ] || exit 0 log=/tmp/msdos11.log dir=/tmp odir=`pwd` cd $dir cd $odir mount | grep "$mntpoint" | grep -q md$mdstart && umount -f $mntpoint mdconfig -l | grep -q $mdstart && mdconfig -d -u $mdstart set -e mdconfig -a -t swap -s 4g -u $mdstart -bsdlabel -w md$mdstart auto +gpart create -s bsd md$mdstart > /dev/null +gpart add -t freebsd-ufs md$mdstart > /dev/null +part=a newfs_msdos -b 1024 /dev/md${mdstart}$part > /dev/null mount -t msdosfs /dev/md${mdstart}$part $mntpoint set +e (cd $odir/../testcases/swap; ./swap -t 2m -i 20 -l 100) > /dev/null & sleep 2 cd $mntpoint for i in `jot 2`; do for i in `jot 10000`; do mkdir a mv a b rmdir b done > /dev/null 2>&1 & done wait cd $odir while mount | grep "$mntpoint" | grep -q md$mdstart; do umount $mntpoint || sleep 1 done fsck -t msdosfs -y /dev/md${mdstart}$part > $log 2>&1 if egrep -q "BAD|INCONSISTENCY|MODIFIED" $log; then cat $log s=1 mount -t msdosfs /dev/md${mdstart}$part $mntpoint || exit 1 ls -lR $mntpoint umount $mntpoint fi mdconfig -d -u $mdstart rm $log exit $s diff --git a/tools/test/stress2/misc/msdos12.sh b/tools/test/stress2/misc/msdos12.sh index 0c1c518575e8..da5c8104c3a6 100755 --- a/tools/test/stress2/misc/msdos12.sh +++ b/tools/test/stress2/misc/msdos12.sh @@ -1,89 +1,91 @@ #!/bin/sh # # SPDX-License-Identifier: BSD-2-Clause-FreeBSD # # Copyright (c) 2021 Peter Holm # # 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. # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 # Copy of rename15.sh, modified for msdosfs. . ../default.cfg [ -x /sbin/mount_msdosfs ] || exit 0 log=/tmp/msdos12.log set -e mount | grep "on $mntpoint " | grep -q /dev/md && umount -f $mntpoint [ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart mdconfig -a -t swap -s 2g -u $mdstart -bsdlabel -w md$mdstart auto +gpart create -s bsd md$mdstart > /dev/null +gpart add -t freebsd-ufs md$mdstart > /dev/null +part=a newfs_msdos -F 32 -b 8192 /dev/md$mdstart$part > /dev/null mount -t msdosfs /dev/md$mdstart$part $mntpoint mkdir $mntpoint/stressX chmod 0777 $mntpoint/stressX set +e export LOAD=80 export MAXSWAPPCT=80 export RUNDIR=$mntpoint/stressX export dirnprenameLOAD=100 export dirrenameLOAD=100 export renameLOAD=100 export runRUNTIME=5m export rwLOAD=80 export TESTPROGS=' testcases/rename/rename testcases/swap/swap ' su $testuser -c 'cd ..; ./testcases/run/run $TESTPROGS' ../tools/killall.sh leftover=`find $mntpoint -type f | wc -l` if [ $leftover -gt 0 ]; then s=1 find $mntpoint -type f | head -5 fi for i in `jot 6`; do mount | grep -q "on $mntpoint " || break umount $mntpoint && break || sleep 10 [ $i -eq 6 ] && { echo FATAL; fstat -mf $mntpoint; exit 1; } done fsck -t msdosfs -y /dev/md$mdstart$part > $log 2>&1 if egrep -q "BAD|INCONSISTENCY|MODIFIED" $log; then echo "fsck problems:" cat $log s=2 mount -t msdosfs /dev/md$mdstart$part $mntpoint || exit 1 ls -lR $mntpoint | head -5 umount $mntpoint fi mdconfig -d -u $mdstart rm -f $log exit $s diff --git a/tools/test/stress2/misc/msdos13.sh b/tools/test/stress2/misc/msdos13.sh index 1e6ee205e4f6..52c3d9ece686 100755 --- a/tools/test/stress2/misc/msdos13.sh +++ b/tools/test/stress2/misc/msdos13.sh @@ -1,97 +1,99 @@ #!/bin/sh # # SPDX-License-Identifier: BSD-2-Clause-FreeBSD # # Copyright (c) 2021 Peter Holm # # 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. # # Simple msdosfs rename example [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg [ -x /sbin/mount_msdosfs ] || exit 0 log=/tmp/msdos13.log set -e mount | grep "on $mntpoint " | grep -q /dev/md && umount -f $mntpoint [ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart mdconfig -a -t swap -s 2g -u $mdstart -bsdlabel -w md$mdstart auto +gpart create -s bsd md$mdstart > /dev/null +gpart add -t freebsd-ufs md$mdstart > /dev/null +part=a newfs_msdos -F 32 -b 8192 /dev/md$mdstart$part > /dev/null mount -t msdosfs /dev/md$mdstart$part $mntpoint mkdir $mntpoint/stressX chmod 0777 $mntpoint/stressX set +e here=`pwd` cd $mntpoint/stressX N=4000 s=0 sort /dev/zero & pid=$! sleep 2 for j in `jot $N`; do touch f$i-$j done for j in `jot $N`; do mv f$i-$j g$i-$j [ -f f$i-$j ] && s=1 done for j in `jot $N`; do mv g$i-$j f$i-$j done for j in `jot $N`; do rm f$i-$j done kill $pid wait leftover=`find . -type f | wc -l` if [ $leftover -gt 0 ]; then echo "Unexpected leftover files:" s=2 find . -type f | head -5 fi cd $here for i in `jot 6`; do mount | grep -q "on $mntpoint " || break umount $mntpoint && break || sleep 10 [ $i -eq 6 ] && { echo FATAL; fstat -mf $mntpoint; exit 1; } done fsck -t msdosfs -y /dev/md$mdstart$part > $log 2>&1 if egrep -q "BAD|INCONSISTENCY|MODIFIED" $log; then echo "fsck problems:" cat $log s=3 mount -t msdosfs /dev/md$mdstart$part $mntpoint || exit 1 ls -lR $mntpoint | head -5 umount $mntpoint fi mdconfig -d -u $mdstart rm -f $log exit $s diff --git a/tools/test/stress2/misc/msdos14.sh b/tools/test/stress2/misc/msdos14.sh index 1a39d60f0781..0f5b5b9ab736 100755 --- a/tools/test/stress2/misc/msdos14.sh +++ b/tools/test/stress2/misc/msdos14.sh @@ -1,119 +1,121 @@ #!/bin/sh # # SPDX-License-Identifier: BSD-2-Clause-FreeBSD # # Copyright (c) 2021 Peter Holm # # 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. # # Rename(2) test with msdosfs(5) # Test scenario by kib@ . ../default.cfg [ `id -u` -ne 0 ] && echo "Must be root!" && exit 1 [ -x /sbin/mount_msdosfs ] || exit 0 dir=/tmp odir=`pwd` cd $dir cat > /tmp/msdos14.c < #include #include #include #include #include #include int main(void) { struct stat sb; uint64_t x; int error, fd; char from[64], to[64]; for (x = 0;; x++) { snprintf(from, sizeof(from), "x.%" PRIu64 ".from", x); snprintf(to, sizeof(to), "x.%" PRIu64 ".to", x); fd = open(from, O_CREAT | O_TRUNC | O_EXCL, 0666); if (fd == -1) err(1, "open %s", from); close(fd); error = rename(from, to); if (error == -1) err(1, "rename %s %s", from, to); error = stat(to, &sb); if (error == -1) err(1, "stat %s", to); error = unlink(to); if (error == -1) err(1, "unlink %s", to); } } EOF cc -o msdos14 -Wall -Wextra -O2 msdos14.c || exit 1 rm -f msdos14.c cd $odir log=/tmp/msdos14sh..log mount | grep "$mntpoint" | grep -q md$mdstart && umount -f $mntpoint mdconfig -l | grep -q $mdstart && mdconfig -d -u $mdstart set -e mdconfig -a -t swap -s 4g -u $mdstart -bsdlabel -w md$mdstart auto +gpart create -s bsd md$mdstart > /dev/null +gpart add -t freebsd-ufs md$mdstart > /dev/null +part=a newfs_msdos -b 1024 /dev/md${mdstart}$part > /dev/null mount -t msdosfs /dev/md${mdstart}$part $mntpoint set +e cp /tmp/msdos14 $mntpoint cd $mntpoint (cd $odir/../testcases/swap; ./swap -t 5m -i 20 -l 100) > /dev/null & sleep 2 timeout 5m ./msdos14 while pkill swap; do :; done wait cd $odir while mount | grep "$mntpoint" | grep -q md$mdstart; do umount $mntpoint || sleep 1 done fsck -t msdosfs -y /dev/md${mdstart}$part > $log 2>&1 if egrep -q "BAD|INCONSISTENCY|MODIFIED" $log; then echo "fsck issues:" cat $log s=1 mount -t msdosfs /dev/md${mdstart}$part $mntpoint || exit 1 ls -lR $mntpoint umount $mntpoint fi mdconfig -d -u $mdstart rm /tmp/msdos14 $log exit $s diff --git a/tools/test/stress2/misc/msdos2.sh b/tools/test/stress2/misc/msdos2.sh index 838585595ec3..192ea7905d3b 100755 --- a/tools/test/stress2/misc/msdos2.sh +++ b/tools/test/stress2/misc/msdos2.sh @@ -1,58 +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. # # 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 +gpart create -s bsd md$mdstart > /dev/null +gpart add -t freebsd-ufs md$mdstart > /dev/null +part=a 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 +gpart create -s bsd md$u > /dev/null +gpart add -t freebsd-ufs md$u > /dev/null 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 diff --git a/tools/test/stress2/misc/msdos3.sh b/tools/test/stress2/misc/msdos3.sh index e251f7bf7ee7..38344e37d5d8 100755 --- a/tools/test/stress2/misc/msdos3.sh +++ b/tools/test/stress2/misc/msdos3.sh @@ -1,52 +1,54 @@ #!/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. # # 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 +gpart create -s bsd md$mdstart > /dev/null +gpart add -t freebsd-ufs md$mdstart > /dev/null +part=a 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 diff --git a/tools/test/stress2/misc/msdos4.sh b/tools/test/stress2/misc/msdos4.sh index 807c3b5206eb..b90f7d8229ea 100755 --- a/tools/test/stress2/misc/msdos4.sh +++ b/tools/test/stress2/misc/msdos4.sh @@ -1,76 +1,78 @@ #!/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. # [ `id -u` -ne 0 ] && echo "Must be root!" && exit 1 # "panic: leaf should be empty" seen # "panic: Assertion sq->sq_wchan != NULL" seen: # https://people.freebsd.org/~pho/stress/log/msdos4.txt . ../default.cfg [ -x /sbin/mount_msdosfs ] || exit log=/tmp/msdos4.sh.log 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 +gpart create -s bsd md$mdstart > /dev/null +gpart add -t freebsd-ufs md$mdstart > /dev/null +part=a newfs_msdos /dev/md${mdstart}$part > /dev/null mount -t msdosfs /dev/md${mdstart}$part $mntpoint || exit 1 export RUNDIR=$mntpoint/stressX export runRUNTIME=10m export TESTPROGS=' testcases/lockf2/lockf2 testcases/openat/openat testcases/rw/rw testcases/fts/fts testcases/lockf/lockf testcases/creat/creat testcases/mkdir/mkdir testcases/rename/rename testcases/swap/swap ' (cd ..; ./testcases/run/run $TESTPROGS) while mount | grep "$mntpoint" | grep -q md$mdstart; do umount $mntpoint || sleep 1 done fsck -t msdosfs -y /dev/md${mdstart}$part > $log 2>&1 s=0 if egrep -q "BAD|INCONSISTENCY|MODIFIED" $log; then cat $log rm $log s=1 fi mdconfig -d -u $mdstart s=0 # Ignore for now exit $s diff --git a/tools/test/stress2/misc/msdos5.sh b/tools/test/stress2/misc/msdos5.sh index 815eeca6fd4c..4b7b961a622b 100755 --- a/tools/test/stress2/misc/msdos5.sh +++ b/tools/test/stress2/misc/msdos5.sh @@ -1,59 +1,61 @@ #!/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. # # "panic: Freeing unused sector 79510 22 ff800000" seen. # http://people.freebsd.org/~pho/stress/log/msdos5.txt # FS corruption seen: http://people.freebsd.org/~pho/stress/log/msdos5-2.txt # Fixed by r333693. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 [ -x /sbin/mount_msdosfs ] || exit . ../default.cfg mycc -o /tmp/fstool -Wall -Wextra -O2 ../tools/fstool.c || exit 1 cd /tmp 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 3g -u $mdstart -bsdlabel -w md$mdstart auto +gpart create -s bsd md$mdstart > /dev/null +gpart add -t freebsd-ufs md$mdstart > /dev/null +part=a newfs_msdos -F 32 -b 8192 /dev/md${mdstart}$part > /dev/null 2>&1 mount_msdosfs -m 777 /dev/md${mdstart}$part $mntpoint for i in `jot 5`; do (mkdir $mntpoint/test$i; cd $mntpoint/test$i; /tmp/fstool -l -f 400 -n 200 -s ${i}k) done sleep 1 rm -rf $mntpoint/* || echo FAIL while mount | grep -q "$mntpoint "; do umount $mntpoint || sleep 1 done rm -f /tmp/fstool diff --git a/tools/test/stress2/misc/msdos6.sh b/tools/test/stress2/misc/msdos6.sh index 475989b3fa1c..e99874e78aa1 100755 --- a/tools/test/stress2/misc/msdos6.sh +++ b/tools/test/stress2/misc/msdos6.sh @@ -1,93 +1,95 @@ #!/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. # # Parallel mount and umount of file systems # "panic: userret: Returning with 1 locks held" seen: # https://people.freebsd.org/~pho/stress/log/mark165.txt [ `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 +part=a 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 + gpart create -s bsd md$m > /dev/null + gpart add -t freebsd-ufs md$m > /dev/null newfs_msdos -F 32 -b 8192 /dev/md${m}$part > /dev/null 2>&1 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 diff --git a/tools/test/stress2/misc/msdos7.sh b/tools/test/stress2/misc/msdos7.sh index 7bebe3703848..ff309de0ace8 100755 --- a/tools/test/stress2/misc/msdos7.sh +++ b/tools/test/stress2/misc/msdos7.sh @@ -1,57 +1,59 @@ #!/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. # # 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 +gpart create -s bsd md$mdstart > /dev/null +gpart add -t freebsd-ufs md$mdstart > /dev/null +part=a newfs_msdos -F 32 -b 8192 /dev/md${mdstart}$part > /dev/null || exit 1 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 rm -f /tmp/msdos7 exit 0 diff --git a/tools/test/stress2/misc/msdos8.sh b/tools/test/stress2/misc/msdos8.sh index 58f0390e195d..84192ee6895e 100755 --- a/tools/test/stress2/misc/msdos8.sh +++ b/tools/test/stress2/misc/msdos8.sh @@ -1,157 +1,159 @@ #!/bin/sh # # Copyright (c) 2017 Dell EMC Isilon # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # msdosfs rename scenario # "Invalid long filename entry" seen from fsck . ../default.cfg [ `id -u` -ne 0 ] && echo "Must be root!" && exit 1 [ -x /sbin/mount_msdosfs ] || exit 0 dir=/tmp odir=`pwd` cd $dir sed '1,/^EOF/d' < $odir/$0 > $dir/msdos8.c cc -o msdos8 -Wall -Wextra -O0 -g msdos8.c || exit 1 rm -f msdos8.c cd $odir log=/tmp/msdos8.sh.log 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 +gpart create -s bsd md$mdstart > /dev/null +gpart add -t freebsd-ufs md$mdstart > /dev/null +part=a newfs_msdos /dev/md${mdstart}$part #> /dev/null mount -t msdosfs /dev/md${mdstart}$part $mntpoint || exit 1 (cd $mntpoint; /tmp/msdos8) s=$? while mount | grep "$mntpoint" | grep -q md$mdstart; do umount $mntpoint || sleep 1 done fsck -t msdosfs -y /dev/md${mdstart}$part > $log 2>&1 if egrep -q "BAD|INCONSISTENCY|MODIFIED" $log; then cat $log s=1 mount -t msdosfs /dev/md${mdstart}$part $mntpoint || exit 1 ls -lR $mntpoint umount $mntpoint fi mdconfig -d -u $mdstart rm /tmp/msdos8 $log s=0 # Ignore for now exit $s EOF #include #include #include #include #include #include #include #include #include #include # define PARALLEL 10 static unsigned long size; static void test(void) { pid_t pid; int fd, i, j; char file1[128], file2[128]; pid = getpid(); for (i = 0; i < (int)size; i++) { sprintf(file1,"p%05d.%05d", pid, i); if ((fd = open(file1, O_RDONLY|O_CREAT, 0660)) == -1) err(1, "openat(%s), %s:%d", file1, __FILE__, __LINE__); close(fd); } for (j = 0; j < 100; j++) { for (i = 0; i < (int)size; i++) { sprintf(file1,"p%05d.%05d", pid, i); sprintf(file2,"p%05d.%05d.togo", pid, i); if (rename(file1, file2) == -1) err(1, "rename(%s, %s). %s:%d", file1, file2, __FILE__, __LINE__); } for (i = 0; i < (int)size; i++) { sprintf(file1,"p%05d.%05d", pid, i); sprintf(file2,"p%05d.%05d.togo", pid, i); if (rename(file2, file1) == -1) err(1, "rename(%s, %s). %s:%d", file2, file1, __FILE__, __LINE__); } } for (i = 0; i < (int)size; i++) { sprintf(file1,"p%05d.%05d", pid, i); if (unlink(file1) == -1) err(1, "unlink(%s), %s:%d", file1, __FILE__, __LINE__); } _exit(0); } int main(void) { pid_t pids[PARALLEL]; time_t start; int e, i, status; e = 0; size = 5; start = time(NULL); while ((time(NULL) - start) < 60 && e == 0) { for (i = 0; i < PARALLEL; i++) { if ((pids[i] = fork()) == 0) test(); if (pids[i] == -1) err(1, "fork()"); } for (i = 0; i < PARALLEL; i++) { if (waitpid(pids[i], &status, 0) == -1) err(1, "waitpid(%d)", pids[i]); if (WIFSIGNALED(status)) fprintf(stderr, "pid %d exit signal %d\n", pids[i], WTERMSIG(status)); e += status == 0 ? 0 : 1; } } return (e); } diff --git a/tools/test/stress2/misc/msdos9.sh b/tools/test/stress2/misc/msdos9.sh index cafabc546aa9..d325d4300067 100755 --- a/tools/test/stress2/misc/msdos9.sh +++ b/tools/test/stress2/misc/msdos9.sh @@ -1,77 +1,79 @@ #!/bin/sh # # Copyright (c) 2017 Dell EMC Isilon # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # fsx test of with msdosfs and a 1k block size # "panic: Assertion ma[i]->dirty == VM_PAGE_BITS_ALL failed" seen. # Fixed by r324794 # Original test scenario by fsu@freebsd.org . ../default.cfg [ `id -u` -ne 0 ] && echo "Must be root!" && exit 1 [ -r /usr/src/tools/regression/fsx/fsx.c ] || exit 0 [ -x /sbin/mount_msdosfs ] || exit 0 dir=/tmp odir=`pwd` cd $dir cc -o fsx -Wall -Wextra -O2 -g /usr/src/tools/regression/fsx/fsx.c || exit 1 rm -f fsx.c cd $odir log=/tmp/fsx.sh.log mount | grep "$mntpoint" | grep -q md$mdstart && umount -f $mntpoint mdconfig -l | grep -q $mdstart && mdconfig -d -u $mdstart set -e mdconfig -a -t swap -s 4g -u $mdstart -bsdlabel -w md$mdstart auto +gpart create -s bsd md$mdstart > /dev/null +gpart add -t freebsd-ufs md$mdstart > /dev/null +part=a newfs_msdos -b 1024 /dev/md${mdstart}$part > /dev/null mount -t msdosfs /dev/md${mdstart}$part $mntpoint set +e cp /tmp/fsx $mntpoint cd $mntpoint ./fsx -S 2016 -N 2000 ./TEST_FILE > /dev/null cd / while mount | grep "$mntpoint" | grep -q md$mdstart; do umount $mntpoint || sleep 1 done fsck -t msdosfs -y /dev/md${mdstart}$part > $log 2>&1 if egrep -q "BAD|INCONSISTENCY|MODIFIED" $log; then cat $log s=1 mount -t msdosfs /dev/md${mdstart}$part $mntpoint || exit 1 ls -lR $mntpoint umount $mntpoint fi mdconfig -d -u $mdstart rm /tmp/fsx $log exit $s diff --git a/tools/test/stress2/misc/namecache2.sh b/tools/test/stress2/misc/namecache2.sh index a5dd4319fc66..9fcfe5e0226c 100755 --- a/tools/test/stress2/misc/namecache2.sh +++ b/tools/test/stress2/misc/namecache2.sh @@ -1,192 +1,191 @@ #!/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. # # UFS cache inconsistancy for rename(2) demonstrated # Fails with: # ls -ali /mnt # ls: tfa1022: No such file or directory # Fixed by r248422 # Test scenario obtained from Rick Miller [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 # This threaded test is designed for MP. [ `sysctl hw.ncpu | sed 's/.* //'` -eq 1 ] && exit 0 . ../default.cfg odir=`pwd` cd /tmp sed '1,/^EOF/d' < $odir/$0 > namecache2.c rm -f /tmp/namecache2 mycc -o namecache2 -Wall -Wextra -g -O2 namecache2.c -lpthread || exit 1 rm -f namecache2.c cd $odir mount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint (cd $mntpoint; /tmp/namecache2) f=`(cd $mntpoint; echo *)` if [ "$f" != '*' ]; then echo FAIL echo "echo $mntpoint/*" echo $mntpoint/* echo "" echo "ls -ali $mntpoint" ls -ali $mntpoint echo "" - echo "fsdb -r /dev/md${mdstart}$part" - fsdb -r /dev/md${mdstart}$part <<-EF + echo "fsdb -r /dev/md$mdstart" + fsdb -r /dev/md$mdstart <<-EF ls quit EF fi while mount | grep $mntpoint | grep -q /dev/md; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart rm -f /tmp/namecache2 exit 0 EOF /* * NOTE: This must be run with the current working directory on a local UFS * disk partition, to demonstrate a FreeBSD namecache bug. I have never seen * this bug happen with an NFS partition. */ #include #include #include #include #include #include #include #include #include #include #include int stopping = false; char *pFilename = 0; static void * statThread(void *arg __unused) { struct stat statData; int rc; for (;;) { while (pFilename == 0) { if (stopping) return 0; } rc = stat(pFilename, &statData); if (rc < 0 && errno != ENOENT) { printf(" statThread stat() on %s failed with errno %d\n", pFilename, errno); return 0; } } return 0; } int main(void) { char filename1 [20], filename2[20], filename3[20]; pthread_t threadId; struct stat statData; int result, fd; unsigned int number; struct timespec period; time_t start; sprintf(filename1, "tfa0"); fd = open(filename1, O_CREAT, S_IRWXU); if (fd < 0) { printf("open(O_CREAT) on %s failed with errno %d\n", filename1, errno); return 0; } if (close(fd) < 0) { printf("close() on %s failed with errno %d\n", filename1, errno); return 0; } result = pthread_create(&threadId, NULL, statThread, NULL); if (result < 0) errc(1, result, "pthread_create()"); start = time(NULL); for (number = 0; number < 0x001FFFFF; number += 2) { sprintf(filename1, "tfa%u", number); sprintf(filename2, "tfa%u", number + 1); sprintf(filename3, "tfa%u", number + 2); if (rename(filename1, filename2) < 0) { printf(" rename1() from %s to %s failed with errno %d\n", filename1, filename2, errno); return 0; } pFilename = filename3; if (rename(filename2, filename3) < 0) { printf(" rename2() from %s to %s failed with errno %d\n", filename2, filename3, errno); return 0; } pFilename = 0; period.tv_sec = 0; period.tv_nsec = 500; nanosleep(&period, 0); if (stat(filename3, &statData) < 0) { printf("stat(%s) failed with errno %d\n", filename3, errno); stopping = true; period.tv_sec = 0; period.tv_nsec = 500; nanosleep(&period, 0); return 0; } if (time(NULL) - start > 1200) { fprintf(stderr, "Test timed out.\n"); break; } } unlink(filename3); return 0; } diff --git a/tools/test/stress2/misc/nbufkv.sh b/tools/test/stress2/misc/nbufkv.sh index db2c45feb496..1f9434d2cf75 100755 --- a/tools/test/stress2/misc/nbufkv.sh +++ b/tools/test/stress2/misc/nbufkv.sh @@ -1,156 +1,154 @@ #!/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. # # Test scenario with a 20G files on two UFS2 FSs with 64k/64k # Test program will hang (deadlock) in "nbufkv" # Test scenario by John-Mark Gurney [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg dir=`dirname $diskimage` d1=$dir/diskimage1 d2=$dir/diskimage2 rm -f $d1 $d2 size=20 # G avail=$((`sysctl -n hw.physmem` / 1024 / 1024 / 1024)) [ $((size * 2)) -gt $avail ] && size=$((avail / 2)) [ `df -k $dir | tail -1 | awk '{print $4}'` -lt \ $((size * 2 * 1024 * 1024)) ] && echo "Not enough disk space on $dir." && exit 0 odir=`pwd` USE_TIMEOUT=1 cd /tmp sed '1,/^EOF/d' < $odir/$0 > nbufkv.c mycc -o nbufkv -Wall nbufkv.c rm -f nbufkv.c cd $odir u1=$mdstart u2=$((u1 + 1)) mp1=$mntpoint mp2=${mntpoint}2 [ -d $mp1 ] || mkdir $mp1 [ -d $mp2 ] || mkdir $mp2 dd if=/dev/zero of=$d1 bs=1m count=${size}k status=none || exit 1 cp $d1 $d2 || exit 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 +mount | grep -q /dev/md$u2 && umount -f /dev/md$u2 +mount | grep -q /dev/md$u1 && umount -f /dev/md$u1 [ -c /dev/md$u2 ] && mdconfig -d -u $u2 [ -c /dev/md$u1 ] && mdconfig -d -u $u1 mdconfig -a -t vnode -f $d1 -u $u1 || exit 1 -bsdlabel -w md$u1 auto -newfs -b 65536 -f 65536 -O2 md${u1}$part > /dev/null +newfs -b 65536 -f 65536 -O2 md$u1 > /dev/null mdconfig -a -t vnode -f $d2 -u $u2 || exit 1 -bsdlabel -w md$u2 auto -newfs -b 65536 -f 65536 -O2 md${u2}$part > /dev/null +newfs -b 65536 -f 65536 -O2 md$u2 > /dev/null -mount /dev/md${u1}$part $mp1 -mount /dev/md${u2}$part $mp2 +mount /dev/md$u1 $mp1 +mount /dev/md$u2 $mp2 /tmp/nbufkv $mp1 & /tmp/nbufkv $mp2 & wait -umount /dev/md${u2}$part -umount /dev/md${u1}$part +umount /dev/md$u2 +umount /dev/md$u1 -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 +mount | grep -q /dev/md$u2 && umount -f /dev/md$u2 +mount | grep -q /dev/md$u1 && umount -f /dev/md$u1 mdconfig -d -u $u2 mdconfig -d -u $u1 rm -rf $d1 $d2 /tmp/nbufkv exit EOF #include #include #include #include #include #include #include void handler(int i) { fprintf(stderr, "FAIL. Timerout.\n"); _exit(0); } void work(int fd, size_t n) { int i; for (i = 0; i < 128 * 1024; i++) { n = n - PAGE_SIZE; if (lseek(fd, n , SEEK_SET) == -1) err(1, "lseek()"); if (write(fd, "1", 1) != 1) err(1, "write()"); } } int main(int argc, char **argv) { int fd; off_t len; char path[128]; len = 20; len = len * 1024 * 1024 * 1024; sprintf(path, "%s/nbufkv.%06d", argv[1], getpid()); if ((fd = open(path, O_CREAT | O_TRUNC | O_RDWR, 0640)) == -1) err(1,"open(%s)", path); if (ftruncate(fd, len) == -1) err(1, "ftruncate"); signal(SIGALRM, handler); alarm(1200); work(fd, len); close(fd); if (unlink(path) == -1) err(1, "unlink(%s)", path); return (0); } diff --git a/tools/test/stress2/misc/newfs.sh b/tools/test/stress2/misc/newfs.sh index 8ef7b9eae31e..d953cc669bb9 100755 --- a/tools/test/stress2/misc/newfs.sh +++ b/tools/test/stress2/misc/newfs.sh @@ -1,94 +1,93 @@ #!/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. # # A few UFS1 newfs combinations are known to cause fsck(8) to fail. # Ignore these for now. Will be fixed: # newfs -O1 -b 65536 -f 8192 # newfs -O1 -b 65536 -f 16384 # newfs -O1 -b 65536 -f 32768 # newfs -O1 -b 65536 -f 65536 [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg -mount | grep "$mntpoint" | grep md${mdstart}$part > /dev/null && +mount | grep "$mntpoint" | grep md$mdstart > /dev/null && umount $mntpoint mdconfig -l | grep md$mdstart > /dev/null && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart -bsdlabel -w md$mdstart auto echo "Expect warnings from SU and SU+J." log=/tmp/newfs.sh.log s=0 export RUNDIR=$mntpoint/stressX export runRUNTIME=10s export RUNTIME=$runRUNTIME export CTRLDIR=$mntpoint/stressX.control start=`date '+%s'` for opt in -O1 -O2 -U -j; do echo "Testing newfs with option $opt." blocksize=4096 while [ $blocksize -le 65536 ]; do for i in 8 4 2 1; do fragsize=$((blocksize / i)) newfs $opt -b $blocksize -f $fragsize \ - md${mdstart}$part > /dev/null 2>&1 || continue - mount /dev/md${mdstart}$part $mntpoint + md$mdstart > /dev/null 2>&1 || continue + mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint rm -rf /tmp/stressX.control su $testuser -c \ "(cd ..; ./run.sh disk.cfg > /dev/null 2>&1)" & sleep 10 ../tools/killall.sh wait while mount | grep "$mntpoint" | \ - grep -q md${mdstart}$part; do + grep -q md$mdstart; do umount $mntpoint > /dev/null 2>&1 || sleep 1 done - checkfs /dev/md${mdstart}$part > $log 2>&1 || { + checkfs /dev/md$mdstart > $log 2>&1 || { cmd="newfs $opt -b $blocksize -f $fragsize" # if ! grep -q -- "$cmd" $0; then s=1 echo "$cmd" cat $log # fi } done blocksize=$((blocksize * 2)) done if [ $((`date '+%s'` - start)) -gt 1200 ]; then echo "Timed out" s=1 break fi done mdconfig -d -u $mdstart rm -f $log exit $s diff --git a/tools/test/stress2/misc/newfs2.sh b/tools/test/stress2/misc/newfs2.sh index ac891e7926fb..0706b30e40b8 100755 --- a/tools/test/stress2/misc/newfs2.sh +++ b/tools/test/stress2/misc/newfs2.sh @@ -1,69 +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. # # phk has seen freezes with this newfs option: "-b 32768 -f 4096 -O2" [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg size=$((32 * 1024 * 1024)) -mount | grep "$mntpoint" | grep -q md${mdstart}$part && umount $mntpoint +mount | grep "$mntpoint" | grep -q md$mdstart && umount $mntpoint [ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart s=0 start=`date '+%s'` while [ $size -le $((900 * 1024 * 1024)) ]; do mb=$((size / 1024 / 1024)) rm -f $diskimage dd if=/dev/zero of=$diskimage bs=1m count=$mb status=none mdconfig -a -t vnode -f $diskimage -u $mdstart || { rm $diskimage; exit 1; } - bsdlabel -w md$mdstart auto - newfs -b 32768 -f 4096 -O2 md${mdstart}$part > /dev/null 2>&1 - mount /dev/md${mdstart}$part $mntpoint + newfs -b 32768 -f 4096 -O2 md$mdstart > /dev/null 2>&1 + mount /dev/md$mdstart $mntpoint export RUNDIR=$mntpoint/stressX export runRUNTIME=30s 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 + while mount | grep "$mntpoint" | grep -q md$mdstart; do umount $mntpoint > /dev/null 2>&1 done - checkfs md${mdstart}$part || s=1 + checkfs md$mdstart || s=1 mdconfig -d -u $mdstart size=$((size + 32 * 1024 * 1024)) if [ $((`date '+%s'` - start)) -gt 1200 ]; then echo "Timed out" s=1 break fi done rm -f $diskimage exit $s diff --git a/tools/test/stress2/misc/newfs3.sh b/tools/test/stress2/misc/newfs3.sh index f6dd84e801bc..8bb8125db8aa 100755 --- a/tools/test/stress2/misc/newfs3.sh +++ b/tools/test/stress2/misc/newfs3.sh @@ -1,81 +1,80 @@ #!/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. # # 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 +mount | grep "$mntpoint" | grep -q md$mdstart && umount $mntpoint [ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart s=0 while [ $size -le $((128 * 1024 * 1024)) ]; do mb=$((size / 1024 / 1024)) rm -f $diskimage dd if=/dev/zero of=$diskimage bs=1m count=$mb status=none 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 > \ + newfs -b $blocksize -f $fragsize $opt md$mdstart > \ /dev/null 2>&1 - mount /dev/md${mdstart}$part $mntpoint + mount /dev/md$mdstart $mntpoint export RUNDIR=$mntpoint/stressX export runRUNTIME=15s export RUNTIME=$runRUNTIME export CTRLDIR=$mntpoint/stressX.control (cd ..; ./run.sh disk.cfg) > /dev/null 2>&1 & sleep 15 ../tools/killall.sh wait while mount | grep "$mntpoint" | \ - grep -q md${mdstart}$part; do + grep -q md$mdstart; do umount $mntpoint > /dev/null 2>&1 done - checkfs /dev/md${mdstart}$part || s=1 + checkfs /dev/md$mdstart || s=1 done blocksize=$((blocksize * 2)) done mdconfig -d -u $mdstart size=$((size + 32 * 1024 * 1024)) done rm -f $diskimage exit $s diff --git a/tools/test/stress2/misc/newfs4.sh b/tools/test/stress2/misc/newfs4.sh index 46d563a49460..55ac3aaae3da 100755 --- a/tools/test/stress2/misc/newfs4.sh +++ b/tools/test/stress2/misc/newfs4.sh @@ -1,128 +1,127 @@ #!/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. # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg # Deadlock problems. Test scenario by Lev Serebryakov # newfs -O2 -U -b 65536 # The io programs will get stuck in nbufkv wait state. # Threads stuck in newbuf: # https://people.freebsd.org/~pho/stress/log/newfs4-2.txt odir=`pwd` cd /tmp sed '1,/^EOF/d' < $odir/$0 > newfs4.c mycc -o newfs4 -Wall -Wextra newfs4.c || exit 1 rm -f newfs4.c cd $odir -mount | grep "$mntpoint" | grep -q md${mdstart}$part && umount $mntpoint +mount | grep "$mntpoint" | grep -q md$mdstart && umount $mntpoint mdconfig -l | grep md$mdstart > /dev/null && mdconfig -d -u $mdstart size=9 # Gb [ `df -k $(dirname $diskimage) | tail -1 | \ awk '{print $4}'` -lt $((size * 1024 * 1024)) ] && \ echo "Not enough disk space on `dirname $diskimage`." && exit 1 trap "rm -f $diskimage" EXIT INT dd if=/dev/zero of=$diskimage bs=1m count=$((size * 1024)) status=none || exit 1 blocksize="-b 65536" opt="-O2 -U" mdconfig -a -t vnode -f $diskimage -u $mdstart -bsdlabel -w md$mdstart auto -newfs $blocksize $opt md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $blocksize $opt md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint cd $mntpoint truncate -s 2g f1 truncate -s 2g f2 truncate -s 2g f3 truncate -s 2g f4 /tmp/newfs4 f1 & /tmp/newfs4 f2 & /tmp/newfs4 f3 & /tmp/newfs4 f4 & wait -while mount | grep "$mntpoint" | grep -q md${mdstart}$part; do +while mount | grep "$mntpoint" | grep -q md$mdstart; do umount -f $mntpoint || sleep 1 done -checkfs /dev/md${mdstart}$part; s=$? +checkfs /dev/md$mdstart; s=$? mdconfig -d -u $mdstart rm -f /tmp/newfs4 exit $s EOF #include #include #include #include #include #include #include /* Perform random IO operations on a file */ int main(int argc, char **argv) { struct stat sb; off_t bp, maxb; long i; int fd; char buf[256]; if (argc != 2) { fprintf(stderr, "Usage %s: file\n", argv[0]); return (1); } if ((fd = open(argv[1], O_RDWR)) == -1) err(1, "open(%s)", argv[1]); if (fstat(fd, &sb) == -1) err(1, "fstatf(stdin)"); maxb = sb.st_size - sizeof(buf); for (i = 0; i < 10000; i++) { bp = arc4random(); bp = (bp << 31 | arc4random()) % maxb; if (lseek(fd, bp, 0) == -1) err(1, "lseek()"); if (write(fd, buf, sizeof(buf)) != sizeof(buf)) err(1, "write()"); } close(fd); return (0); } diff --git a/tools/test/stress2/misc/newfs5.sh b/tools/test/stress2/misc/newfs5.sh index f41da12e28dd..29c7e1a84b09 100755 --- a/tools/test/stress2/misc/newfs5.sh +++ b/tools/test/stress2/misc/newfs5.sh @@ -1,116 +1,115 @@ #!/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. # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg # Variation of newfs4.sh, using a swap backed MD disk odir=`pwd` cd /tmp sed '1,/^EOF/d' < $odir/$0 > newfs5.c mycc -o newfs5 -Wall -Wextra newfs5.c rm -f newfs5.c cd $odir -mount | grep "$mntpoint" | grep md${mdstart}$part > /dev/null && umount $mntpoint +mount | grep "$mntpoint" | grep md$mdstart > /dev/null && umount $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart blocksize="-b 65536" opt="-O2 -U" size=9 # Gb mdconfig -a -t swap -s ${size}g -u $mdstart -bsdlabel -w md$mdstart auto -newfs $blocksize $opt md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $blocksize $opt md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint cd $mntpoint truncate -s 2g f1 truncate -s 2g f2 truncate -s 2g f3 truncate -s 2g f4 /tmp/newfs5 f1 & /tmp/newfs5 f2 & /tmp/newfs5 f3 & /tmp/newfs5 f4 & wait -while mount | grep "$mntpoint" | grep -q md${mdstart}$part; do +while mount | grep "$mntpoint" | grep -q md$mdstart; do umount -f $mntpoint || sleep 1 done -checkfs /dev/md${mdstart}$part; s=$? +checkfs /dev/md$mdstart; s=$? mdconfig -d -u $mdstart rm -f $diskimage rm -f /tmp/newfs5 exit $s EOF #include #include #include #include #include #include #include /* Perform random IO operations on a file */ int main(int argc, char **argv) { struct stat sb; char buf[256]; off_t bp, maxb; int fd; long i; if (argc != 2) { fprintf(stderr, "Usage %s: file\n", argv[0]); return (1); } if ((fd = open(argv[1], O_RDWR)) == -1) err(1, "open(%s)", argv[1]); if (fstat(fd, &sb) == -1) err(1, "fstatf(stdin)"); maxb = sb.st_size - sizeof(buf); for (i = 0; i < 10000; i++) { bp = arc4random(); bp = (bp << 31 | arc4random()) % maxb; if (lseek(fd, bp, 0) == -1) err(1, "lseek()"); if (write(fd, buf, sizeof(buf)) != sizeof(buf)) err(1, "write()"); } close(fd); return (0); } diff --git a/tools/test/stress2/misc/nfs10.sh b/tools/test/stress2/misc/nfs10.sh index 15f449548f45..f8c6e3c76c56 100755 --- a/tools/test/stress2/misc/nfs10.sh +++ b/tools/test/stress2/misc/nfs10.sh @@ -1,73 +1,72 @@ #!/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. # # nfsv4 test scenario # Deadlock seen: http://people.freebsd.org/~pho/stress/log/nfs10.txt # Lock violation: http://people.freebsd.org/~pho/stress/log/nfs10-2.txt # Double fault: http://people.freebsd.org/~pho/stress/log/nfs10-3.txt [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg grep -q $mntpoint /etc/exports || { echo "$mntpoint missing from /etc/exports"; exit 0; } m2=${mntpoint}2 [ -d $m2 ] || mkdir $m2 mount | grep "on $m2 " | grep -q nfs && umount $m2 mount | grep "on $mntpoint " | grep -q /dev/md && umount -f $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 2g -u $mdstart || exit 1 -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null +newfs $newfs_flags md$mdstart > /dev/null -mount /dev/md${mdstart}$part $mntpoint +mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint mount -t nfs -o nfsv4 -o rw,retrycnt=3 127.0.0.1:$mntpoint $m2 export RUNDIR=$m2/stressX export runRUNTIME=10m # Run tests for 10 minutes su $testuser -c "(cd ..; ./run.sh marcus.cfg)" & sleep 300 umount $m2 2>/dev/null # Test umount of active FS while here wait while mount | grep "on $m2 " | grep -q nfs; do umount $m2 done while mount | grep "on $mntpoint " | grep -q /dev/md; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart exit 0 diff --git a/tools/test/stress2/misc/nfs11.sh b/tools/test/stress2/misc/nfs11.sh index e132ad9f894e..1ba0124f939e 100755 --- a/tools/test/stress2/misc/nfs11.sh +++ b/tools/test/stress2/misc/nfs11.sh @@ -1,67 +1,66 @@ #!/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. # # nfsv4 test scenario [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg grep -q $mntpoint /etc/exports || { echo "$mntpoint missing from /etc/exports"; exit 0; } m2=${mntpoint}2 [ -d $m2 ] || mkdir $m2 mount | grep "on $m2 " | grep -q nfs && umount $m2 mount | grep "on $mntpoint " | grep -q /dev/md && umount -f $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 2g -u $mdstart || exit 1 -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null +newfs $newfs_flags md$mdstart > /dev/null -mount /dev/md${mdstart}$part $mntpoint +mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint mount -t nfs -o nfsv4 -o rw,retrycnt=3 127.0.0.1:$mntpoint $m2 export RUNDIR=$m2/stressX export runRUNTIME=10m # Run tests for 10 minutes su $testuser -c "(cd ..; ./run.sh marcus.cfg)" while mount | grep "on $m2 " | grep -q nfs; do umount $m2 done while mount | grep "on $mntpoint " | grep -q /dev/md; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart exit 0 diff --git a/tools/test/stress2/misc/nfs18.sh b/tools/test/stress2/misc/nfs18.sh index bf9e0fc8010e..46330a0290a1 100755 --- a/tools/test/stress2/misc/nfs18.sh +++ b/tools/test/stress2/misc/nfs18.sh @@ -1,90 +1,92 @@ #!/bin/sh # # SPDX-License-Identifier: BSD-2-Clause-FreeBSD # # Copyright (c) 2021 Peter Holm # # 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. # # msdosfs rename test over nfs loopback mount # 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 mp1=$mntpoint mp2=$mntpoint$((mdstart + 1)) grep -q $mp1 /etc/exports || { echo "$mp1 missing from /etc/exports"; exit 0; } [ -x /sbin/mount_msdosfs ] || exit mount | grep "$mp2 " | grep nfs > /dev/null && umount -f $mp2 mount | grep "$mp1 " | grep /md > /dev/null && umount -f $mp1 mdconfig -l | grep -q $mdstart && mdconfig -d -u $mdstart kill -HUP `pgrep mountd` # loopback workaround mdconfig -a -t swap -s 1g -u $mdstart set -e -bsdlabel -w md$mdstart auto +gpart create -s bsd md$mdstart +gpart add -t freebsd-ufs md$mdstart +part=a newfs_msdos -F 32 -b 8192 /dev/md${mdstart}$part > /dev/null mkdir -p $mp1; chmod 777 $mp1 mount -t msdosfs -o rw /dev/md${mdstart}$part $mp1 set +e mkdir $mp1/stressX chmod 777 $mp1/stressX mkdir -p $mp2 chmod 777 $mp2 mount -t nfs -o tcp -o retrycnt=3 -o rw \ 127.0.0.1:$mp1 $mp2; s=$? export LOAD=80 export renameLOAD=100 export TESTPROGS=" testcases/rename/rename testcases/swap/swap " export INODES=9999 # No inodes on a msdos fs export RUNDIR=$mp2/stressX export runRUNTIME=2m if [ $s -eq 0 ]; then su $testuser -c 'cd ..; ./testcases/run/run $TESTPROGS' for i in `jot 10`; do umount $mp2 && break sleep 2 done fi sleep .5 for i in `jot 10`; do umount $mp1 && break sleep 2 done mount | grep -q "on $mp1 " && umount -f $mp1 mdconfig -d -u $mdstart exit 0 diff --git a/tools/test/stress2/misc/nfs2.sh b/tools/test/stress2/misc/nfs2.sh index 9d470c18e8f0..16912e59a16e 100755 --- a/tools/test/stress2/misc/nfs2.sh +++ b/tools/test/stress2/misc/nfs2.sh @@ -1,69 +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. # # 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 dd if=/dev/zero of=$D bs=1m count=128 status=none || 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 mdconfig -a -t vnode -f $D -u $mdstart -bsdlabel -w md$mdstart auto +gpart create -s bsd md$mdstart +gpart add -t freebsd-ufs md$mdstart +part=a 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 [ ! -d ${mntpoint}2 ] && mkdir ${mntpoint}2 chmod 777 ${mntpoint}2 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 diff --git a/tools/test/stress2/misc/nfs5.sh b/tools/test/stress2/misc/nfs5.sh index 1f311ef47baf..893c4b7f7e8f 100755 --- a/tools/test/stress2/misc/nfs5.sh +++ b/tools/test/stress2/misc/nfs5.sh @@ -1,68 +1,67 @@ #!/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. # . ../default.cfg [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 D=$diskimage dd if=dev=zero of=$D bs=1m count=128 status=none || 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 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 +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint 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,soft -o rw 127.0.0.1:$mntpoint \ ${mntpoint}2 export RUNDIR=${mntpoint}2/stressX export runRUNTIME=4m su $testuser -c "(cd ..; ./run.sh disk.cfg > /dev/null 2>&1)" & sleep 60 umount -f $mntpoint > /dev/null 2>&1 umount -f ${mntpoint}2 > /dev/null 2>&1 mdconfig -d -u $mdstart rm -f $D kill $! ../tools/killall.sh wait exit 0 diff --git a/tools/test/stress2/misc/nfs6.sh b/tools/test/stress2/misc/nfs6.sh index 98b2a9d40945..0a70893e20ae 100755 --- a/tools/test/stress2/misc/nfs6.sh +++ b/tools/test/stress2/misc/nfs6.sh @@ -1,81 +1,80 @@ #!/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. # # panic: vn_finished_write: neg cnt # http://people.freebsd.org/~pho/stress/log/kostik500.txt # http://people.freebsd.org/~pho/stress/log/nfs6.txt . ../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; } D=$diskimage dd if=/dev/zero of=$D bs=1m count=128 status=none || 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 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 +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint 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,soft -o rw 127.0.0.1:$mntpoint \ ${mntpoint}2 export RUNDIR=${mntpoint}2/stressX export runRUNTIME=4m su $testuser -c "(cd ..; ./run.sh disk.cfg > /dev/null 2>&1)" & sleep 60 for i in `jot 10`; do umount -f $mntpoint > /dev/null 2>&1 sleep 1 - mount /dev/md${mdstart}$part $mntpoint + mount /dev/md$mdstart $mntpoint sleep 1 done umount -f $mntpoint > /dev/null 2>&1 umount -f ${mntpoint}2 > /dev/null 2>&1 mdconfig -d -u $mdstart rm -f $D kill $! ../tools/killall.sh wait exit 0 diff --git a/tools/test/stress2/misc/nullfs10.sh b/tools/test/stress2/misc/nullfs10.sh index 4444bcca2913..c0574be42e5a 100755 --- a/tools/test/stress2/misc/nullfs10.sh +++ b/tools/test/stress2/misc/nullfs10.sh @@ -1,71 +1,70 @@ #!/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. # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 # Regression test: # There is an issue, namely, when the lower file is already # opened r/w, but its nullfs alias is executed. This situation obviously # shall result in ETXTBUSY, but it currently does not. # Test scenario by kib@ . ../default.cfg mnt2=${mntpoint}2 mount | grep -q $mnt2 && umount $mnt2 [ -d $mnt2 ] || mkdir $mnt2 mount | grep $mnt2 | grep -q /dev/md && umount -f $mnt2 mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint mount -t nullfs $mntpoint $mnt2 cp /bin/ls $mntpoint chmod +w $mntpoint/ls sleep 2 >> $mntpoint/ls & sleep .5 # This line should cause a "/mnt2/ls: Text file busy" $mnt2/ls -l /bin/ls $mntpoint $mnt2 && echo FAIL || echo OK kill $! wait while mount | grep -q "$mnt2 "; do umount $mnt2 || sleep 1 done while mount | grep -q "$mntpoint "; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart diff --git a/tools/test/stress2/misc/nullfs11.sh b/tools/test/stress2/misc/nullfs11.sh index 9d02abd3b3ca..7685f607a3ea 100755 --- a/tools/test/stress2/misc/nullfs11.sh +++ b/tools/test/stress2/misc/nullfs11.sh @@ -1,89 +1,88 @@ #!/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. # # nullfs cache / nocache benchmark [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg 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 - mount /dev/md${mdstart}$part $mp1 + newfs $newfs_flags md$mdstart > /dev/null + mount /dev/md$mdstart $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 diff --git a/tools/test/stress2/misc/nullfs12.sh b/tools/test/stress2/misc/nullfs12.sh index 12671bb695c1..daec7c0ba04e 100755 --- a/tools/test/stress2/misc/nullfs12.sh +++ b/tools/test/stress2/misc/nullfs12.sh @@ -1,64 +1,63 @@ #!/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. # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 # "umount -f" test with files open for writing # "panic: vputx: missed vn_close" seen. # Scenario by kib@. Fixed in r245262. . ../default.cfg mnt2=${mntpoint}2 mount | grep -q $mnt2 && umount $mnt2 [ -d $mnt2 ] || mkdir $mnt2 mount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint mount -t nullfs $mntpoint $mnt2 (sleep 5 > $mnt2/log) & sleep 1 umount -f $mnt2 kill $! wait while mount | grep -q "$mnt2 "; do umount $mnt2 || sleep 1 done while mount | grep -q "$mntpoint "; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart diff --git a/tools/test/stress2/misc/nullfs13.sh b/tools/test/stress2/misc/nullfs13.sh index 5c51621a8c94..0ef9b0f597fd 100755 --- a/tools/test/stress2/misc/nullfs13.sh +++ b/tools/test/stress2/misc/nullfs13.sh @@ -1,77 +1,76 @@ #!/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. # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 # kern/178238 "nullfs don't release i-nodes on unlink" # See also nullfs16.sh # Fixed by: r292961. . ../default.cfg nullfsmp=${mntpoint}2 mount | grep -q "$nullfsmp " && umount $nullfsmp [ -d $nullfsmp ] || mkdir $nullfsmp mount | grep "$mntpoint " | grep -q /dev/md && umount -f $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint mount -t nullfs $mntpoint $nullfsmp (cd $nullfsmp; jot 20 | xargs touch) rm $nullfsmp/* (cd $nullfsmp; jot 20 | xargs touch) rm $mntpoint/* (cd $mntpoint; jot 20 | xargs touch) rm $mntpoint/* (cd $mntpoint; jot 20 | xargs touch) rm $nullfsmp/* ino=`df -i $nullfsmp | tail -1 | awk '{print $6}'` if [ $ino -ne 2 ]; then echo FAIL df -i $mntpoint $nullfsmp echo "ls -la $mntpoint $nullfsmp" ls -la $mntpoint $nullfsmp fi while mount | grep -q "$nullfsmp "; do umount $nullfsmp || sleep 1 done while mount | grep -q "$mntpoint "; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart diff --git a/tools/test/stress2/misc/nullfs14.sh b/tools/test/stress2/misc/nullfs14.sh index 96bcb470dc40..4c38bef54896 100755 --- a/tools/test/stress2/misc/nullfs14.sh +++ b/tools/test/stress2/misc/nullfs14.sh @@ -1,58 +1,57 @@ #!/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. # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 # Page fault seen in fifo_close() . ../default.cfg nullfsmp=${mntpoint}2 mount | grep -q "$nullfsmp " && umount $nullfsmp [ -d $nullfsmp ] || mkdir $nullfsmp mount | grep "$mntpoint " | grep -q /dev/md && umount -f $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint #chmod 777 $mntpoint mount -t nullfs $mntpoint $nullfsmp mkfifo $nullfsmp/fifo rm $mntpoint/fifo # Triggers page fault while mount | grep -q "$nullfsmp "; do umount $nullfsmp || sleep 1 done while mount | grep -q "$mntpoint "; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart diff --git a/tools/test/stress2/misc/nullfs15.sh b/tools/test/stress2/misc/nullfs15.sh index fcaca4af8cb9..0cd589173456 100755 --- a/tools/test/stress2/misc/nullfs15.sh +++ b/tools/test/stress2/misc/nullfs15.sh @@ -1,64 +1,63 @@ #!/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. # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg # panic: lockmgr still held. Fixed in r250852. # Test scenario by antoine@ nullfsmp=${mntpoint}2 mount | grep -q "$nullfsmp " && umount $nullfsmp [ -d $nullfsmp ] || mkdir $nullfsmp mount | grep "$mntpoint " | grep -q /dev/md && umount -f $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint mount -t nullfs $mntpoint $nullfsmp mkdir $mntpoint/.new_packages $nullfsmp/new_packages mount -t nullfs $mntpoint/.new_packages $nullfsmp/new_packages dd if=/dev/zero of=$nullfsmp/new_packages/bar count=20000 status=none mv $mntpoint/.new_packages/bar /tmp/ rm -rf $mntpoint/.new_packages umount -f $nullfsmp/new_packages while mount | grep -q "$nullfsmp "; do umount $nullfsmp || sleep 1 done while mount | grep -q "$mntpoint "; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart rm -f /tmp/bar exit 0 diff --git a/tools/test/stress2/misc/nullfs18.sh b/tools/test/stress2/misc/nullfs18.sh index 1f3320bff1e6..0ee0a1c2ef6b 100755 --- a/tools/test/stress2/misc/nullfs18.sh +++ b/tools/test/stress2/misc/nullfs18.sh @@ -1,133 +1,132 @@ #!/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. # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 # Demonstate nullfs(5) inode leak. # Fixed by r295717. . ../default.cfg N=3 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 || exit 1 -bsdlabel -w md$mdstart auto -newfs -n md${mdstart}$part > /dev/null +newfs -n md$mdstart > /dev/null -mount /dev/md${mdstart}$part $mntpoint +mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint set `df -ik $mntpoint | tail -1 | awk '{print $4,$7}'` export KBLOCKS=$(($1 / N)) export INODES=$(($2 / N)) export runRUNTIME=2m export LOAD=80 export symlinkLOAD=80 export rwLOAD=80 export TESTPROGS=" testcases/rw/rw testcases/creat/creat testcases/mkdir/mkdir " for i in `jot $N 1`; do eval mp$i=${mntpoint}$i done for i in `jot $N 1`; do eval mp=\$mp$i [ -d $mp ] || mkdir -p $mp mount | grep $mp | grep -q nullfs && umount -f $mp msrc=$mntpoint/d$i mkdir -p $msrc chmod 777 $msrc mount -t nullfs $msrc $mp chmod 777 $mp export RUNDIR=$mp/stressX export CTRLDIR=$mp/stressX.control mkdir $RUNDIR $CTRLDIR chmod 777 $RUNDIR $CTRLDIR su $testuser -c 'cd ..; ./testcases/run/run $TESTPROGS' > \ /dev/null 2>&1 & mps="$mps $mp" done (cd ../testcases/swap; ./swap -t 10m -i 20 > /dev/null 2>&1) & sleep 1 while pgrep -q run; do find $mps -ls > /dev/null 2>&1 done while pgrep -q swap; do pkill -9 swap done wait (cd $mntpoint; find . -delete) sync; sleep 1; sync; sleep 1; sync inodes=`df -i $mntpoint | tail -1 | awk '{print $6}'` if [ $inodes -ne 4 ]; then echo "FAIL 1" e=1 mount | sed -n "1p;/${mntpoint#/}/p" echo df -ik | sed -n "1p;/${mntpoint#/}/p" printf "\nfind ${mntpoint}* -ls\n" find ${mntpoint}* -ls for i in `jot $N 1`; do eval mp=\$mp$i echo "umount $mp" mount | grep $mp | grep -q nullfs && umount $mp done echo df -ik | sed -n "1p;/${mntpoint#/}/p" else for i in `jot $N 1`; do eval mp=\$mp$i mount | grep $mp | grep -q nullfs && umount $mp done inodes=`df -i $mntpoint | tail -1 | awk '{print $6}'` if [ $inodes -ne 1 ]; then echo "FAIL 2" e=2 mount | sed -n "1p;/${mntpoint#/}/p" echo df -ik | sed -n "1p;/${mntpoint#/}/p" fi fi while mount | grep $mntpoint | grep -q /dev/md; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart exit $e diff --git a/tools/test/stress2/misc/nullfs19.sh b/tools/test/stress2/misc/nullfs19.sh index fd5f16f4b780..6ad70077b7b3 100755 --- a/tools/test/stress2/misc/nullfs19.sh +++ b/tools/test/stress2/misc/nullfs19.sh @@ -1,90 +1,89 @@ #!/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. # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 # Simplified version of nullfs18.sh . ../default.cfg N=3 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 || exit 1 -bsdlabel -w md$mdstart auto -newfs -n $newfs_flags md${mdstart}$part > /dev/null +newfs -n $newfs_flags md$mdstart > /dev/null -mount /dev/md${mdstart}$part $mntpoint +mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint set `df -ik $mntpoint | tail -1 | awk '{print $4,$7}'` export KBLOCKS=$(($1 / N)) export INODES=$(($2 / N)) export runRUNTIME=2m export LOAD=80 export TESTPROGS=" testcases/creat/creat testcases/link/link testcases/mkdir/mkdir testcases/fts/fts " for i in `jot $N 1`; do eval mp$i=${mntpoint}$i done for i in `jot $N 1`; do eval mp=\$mp$i [ -d $mp ] || mkdir -p $mp mount | grep $mp | grep -q nullfs && umount -f $mp msrc=$mntpoint/d$i mkdir -p $msrc chmod 777 $msrc mount -t nullfs $msrc $mp chmod 777 $mp export RUNDIR=$mp/stressX export CTRLDIR=$mp/stressX.control mkdir $RUNDIR $CTRLDIR chmod 777 $RUNDIR $CTRLDIR su $testuser -c 'cd ..; ./testcases/run/run $TESTPROGS' > \ /dev/null 2>&1 & done wait for i in `jot $N 1`; do eval mp=\$mp$i mount | grep $mp | grep -q nullfs && umount $mp done while mount | grep $mntpoint | grep -q /dev/md; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart diff --git a/tools/test/stress2/misc/nullfs20.sh b/tools/test/stress2/misc/nullfs20.sh index 78c5295bae32..9e22770b139b 100755 --- a/tools/test/stress2/misc/nullfs20.sh +++ b/tools/test/stress2/misc/nullfs20.sh @@ -1,74 +1,73 @@ #!/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. # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 # VOP_LOOKUP: 0xfffff8014d6fe000 is not locked but should be # https://people.freebsd.org/~pho/stress/log/nullfs20.txt . ../default.cfg mount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart || exit 1 -bsdlabel -w md$mdstart auto -newfs -n -b 4096 -f 512 -i 1024 md${mdstart}$part > /dev/null +newfs -n -b 4096 -f 512 -i 1024 md$mdstart > /dev/null -mount /dev/md${mdstart}$part $mntpoint +mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint mp2=$mntpoint$((mdstart + 1)) [ -d $mp2 ] || mkdir -p $mp2 mount | grep -wq $mp2 && umount $mp2 mount -t nullfs $mntpoint $mp2 export runRUNTIME=10m export RUNDIR=$mp2/stressX export LOAD=100 export ftsLOAD=100 export TESTPROGS=" testcases/fts/fts testcases/swap/swap testcases/link/link " su $testuser -c 'cd ..; ./testcases/run/run $TESTPROGS' while mount | grep $mp2 | grep -q nullfs; do umount $mp2 || sleep 1 done n=0 while mount | grep $mntpoint | grep -q /dev/md; do umount $mntpoint || sleep 1 n=$((n + 1)) [ $n -gt 30 ] && { echo FAIL; exit 1; } done mdconfig -d -u $mdstart diff --git a/tools/test/stress2/misc/nullfs21.sh b/tools/test/stress2/misc/nullfs21.sh index 209ed65d1d3f..9184cbdaa088 100755 --- a/tools/test/stress2/misc/nullfs21.sh +++ b/tools/test/stress2/misc/nullfs21.sh @@ -1,71 +1,70 @@ #!/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. # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 # mv removes the file. This is OK on FreeBSD. # This is handled on Linux with "mount --bind". . ../default.cfg 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 512m -u $mdstart || exit 1 -bsdlabel -w md$mdstart auto -newfs -n -b 4096 -f 512 -i 1024 md${mdstart}$part > /dev/null +newfs -n -b 4096 -f 512 -i 1024 md$mdstart > /dev/null -mount /dev/md${mdstart}$part $mntpoint +mount /dev/md$mdstart $mntpoint mp2=${mntpoint}2 [ -d $mp2 ] || mkdir -p $mp2 mount | grep -wq $mp2 && umount $mp2 mount -t nullfs $mntpoint $mp2 touch $mntpoint/file # mv's rename(2) fails as this is a "cross mount" -> # rm dst; cp src dst; rm src mv $mp2/file $mountpoint/file [ -f $mntpoint/file ] || { ls -ali $mntpoint $mp2; status=0; } # { echo FAIL; ls -ali $mntpoint $mp2; status=1; } while mount | grep $mp2 | grep -q nullfs; do umount $mp2 || sleep 1 done n=0 while mount | grep $mntpoint | grep -q /dev/md; do umount $mntpoint || sleep 1 n=$((n + 1)) [ $n -gt 30 ] && { echo FAIL; status=2; } done mdconfig -d -u $mdstart exit $status diff --git a/tools/test/stress2/misc/nullfs22.sh b/tools/test/stress2/misc/nullfs22.sh index 12d1c16cd9a3..f5fadd7ed9d0 100755 --- a/tools/test/stress2/misc/nullfs22.sh +++ b/tools/test/stress2/misc/nullfs22.sh @@ -1,247 +1,246 @@ #!/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. # # fcntl(2) locking scenario, using UFS and a nullfs mount. # No problems seen. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > nullfs22.c mycc -o nullfs22 -Wall -Wextra -O0 -g nullfs22.c || exit 1 rm -f nullfs22.c mp2=${mntpoint}2 [ -d $mp2 ] || mkdir -p $mp2 mount | grep -q "on $mp2 " && umount $mp2 mount | grep "on $mntpoint " | grep -q /dev/md && umount -f $mntpoint [ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart mdconfig -a -t swap -s 512m -u $mdstart || exit 1 -bsdlabel -w md$mdstart auto -newfs -n md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs -n md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint mount -t nullfs $mntpoint $mp2 /tmp/nullfs22 $mntpoint $mp2 status=$? while mount | grep -q "on $mp2 "; do umount $mp2 done while mount | grep "on $mntpoint " | grep -q /dev/md; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart rm -f /tmp/nullfs22 exit $status EOF #include #include #include #include #include #include #include #include #include #include #include #include #define LOOPS 1024 #define N (512) #define PARALLEL 4 #define DONE 1 #define SYNC 0 int fd; volatile u_int *share; char name1[80], name2[80]; static void ahandler(int s __unused) { fprintf(stderr, "In alarm handler\n"); unlink(name1); _exit(1); } void add(int n, int increment) { struct flock fl; off_t pos; long val, oval __unused; int r; pos = n * sizeof(val); memset(&fl, 0, sizeof(fl)); fl.l_start = pos; fl.l_len = sizeof(val); fl.l_type = F_WRLCK; fl.l_whence = SEEK_SET; while (fcntl(fd, F_SETLKW, &fl) < 0) { if (errno != EAGAIN) err(1, "F_SETLKW (child)"); usleep(100); } if (lseek(fd, pos, SEEK_SET) == -1) err(1, "lseek"); oval = 999999; while ((r = read(fd, &val, sizeof(val)) != sizeof(val))) { if (r == -1 && errno != EAGAIN) err(1, "read"); if (lseek(fd, pos, SEEK_SET) == -1) err(1, "lseek"); } oval = val; val = val + increment; #if defined(DEBUG) fprintf(stderr, "add(%d, %d) @ pos %ld: %ld = %ld + %d\n", n, increment, (long)pos, val, oval, increment); #endif if (lseek(fd, pos, SEEK_SET) == -1) err(1, "lseek"); while ((r = write(fd, &val, sizeof(val)) != sizeof(val))) { if (r == -1 && errno != EAGAIN) err(1, "write"); if (lseek(fd, pos, SEEK_SET) == -1) err(1, "lseek"); } fl.l_type = F_UNLCK; if (fcntl(fd, F_SETLK, &fl) < 0) err(1, "F_UNLCK"); } void count(int val) { int i, j; char help[80], *name; if (val == 1) name = name1; else name = name2; snprintf(help, sizeof(help), "%s %d %s", __func__, val, name); setproctitle("%s", help); atomic_add_int(&share[SYNC], 1); while (share[SYNC] != 2 * PARALLEL) ; /* Need to re-open after a fork() */ close(fd); if ((fd = open(name, O_RDWR)) == -1) err(1, "open(%s)", name); for (i = 0; i < LOOPS; i++) { for (j = 0; j < N; j++) add(j, val); } atomic_add_int(&share[DONE], 1); _exit(0); } int main(int argc, char *argv[]) { off_t len; size_t mlen; long val, sum; int i, s, stat; if (argc != 3) { fprintf(stderr, "Usage: %s \n", argv[0]); exit(1); } mlen = PAGE_SIZE; if ((share = mmap(NULL, mlen, PROT_READ | PROT_WRITE, MAP_ANON | MAP_SHARED, -1, 0)) == MAP_FAILED) err(1, "mmap"); snprintf(name1, sizeof(name1), "%s/work", argv[1]); snprintf(name2, sizeof(name2), "%s/work", argv[2]); signal(SIGALRM, ahandler); alarm(300); if ((fd = open(name1, O_RDWR | O_CREAT | O_TRUNC, 0640)) == -1) err(1, "open(%s)", name1); len = N * sizeof(val); if (ftruncate(fd, len) == -1) err(1, "ftruncate"); for (i = 0; i < PARALLEL; i++) { if (fork() == 0) count(1); } for (i = 0; i < PARALLEL; i++) { if (fork() == 0) count(-1); } while (share[DONE] != 2 * PARALLEL) usleep(10000); if (lseek(fd, 0, SEEK_SET) == -1) err(1, "lseek"); sum = 0; for (i = 0; i < N; i++) { if (read(fd, &val, sizeof(val)) != sizeof(val)) err(1, "Final read"); if (val != 0) fprintf(stderr, "index %d: %ld\n", i, val); sum += val; } if (sum != 0) fprintf(stderr, "FAIL\n"); unlink(name1); s = 0; for (i = 0; i < PARALLEL; i++) { wait(&stat); s += WEXITSTATUS(stat); wait(&stat); s += WEXITSTATUS(stat); } close(fd); return (sum != 0 || s != 0); } diff --git a/tools/test/stress2/misc/nullfs25.sh b/tools/test/stress2/misc/nullfs25.sh index 5588567ead22..57f63c6d2330 100755 --- a/tools/test/stress2/misc/nullfs25.sh +++ b/tools/test/stress2/misc/nullfs25.sh @@ -1,90 +1,89 @@ #!/bin/sh # # SPDX-License-Identifier: BSD-2-Clause-FreeBSD # # Copyright (c) 2018 Dell EMC Isilon # # 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. # # Variation of nullfs17.sh WiP [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg mounts=4 # Number of parallel scripts : ${nullfs_srcdir:=$mntpoint} : ${nullfs_dstdir:=$mntpoint} CONT=/tmp/nullfs25.continue mount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint (cd $mntpoint; jot 500 | xargs touch) (cd ../testcases/swap; ./swap -t 5m -i 20 > /dev/null) & for i in `jot $mounts $mdstart`; do [ ! -d ${nullfs_dstdir}$i ] && mkdir ${nullfs_dstdir}$i mount | grep -q " ${nullfs_dstdir}$i " && umount ${nullfs_dstdir}$i done # Start the parallel tests touch $CONT for i in `jot $mounts $mdstart`; do while [ -f $CONT ]; do find ${nullfs_dstdir}$i -type f -maxdepth 2 -ls > \ /dev/null 2>&1 done & # The test: Parallel mount and unmounts start=`date +%s` ( while [ $((`date +%s` - start)) -lt 300 ]; do mount_nullfs $nullfs_srcdir ${nullfs_dstdir}$i > \ /dev/null 2>&1 opt=$([ `jot -r 1 0 1` -eq 0 ] && echo "-f") while mount | grep -q ${nullfs_dstdir}$i; do umount $opt ${nullfs_dstdir}$i > \ /dev/null 2>&1 done done rm -f $CONT ) & done while [ -f $CONT ] ; do sleep 1; done while pgrep -q swap; do pkill swap; done wait for i in `jot $mounts`; do umount ${nullfs_dstdir}$i > /dev/null 2>&1 done while mount | grep $mntpoint | grep -q /dev/md; do umount $mntpoint || sleep 1 [ $((n += 1)) -gt 300 ] && { echo FAIL; exit 1; } done mdconfig -d -u $mdstart exit 0 diff --git a/tools/test/stress2/misc/nullfs27.sh b/tools/test/stress2/misc/nullfs27.sh index 02894fba5efb..907e9de14253 100755 --- a/tools/test/stress2/misc/nullfs27.sh +++ b/tools/test/stress2/misc/nullfs27.sh @@ -1,91 +1,90 @@ #!/bin/sh # # SPDX-License-Identifier: BSD-2-Clause-FreeBSD # # Copyright (c) 2019 Dell EMC Isilon # # 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. # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 # Run all the rename(2) test scenarios with nullfs. # Used in connection with WiP work on nullfs. . ../default.cfg set -e 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 || exit 1 -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint mp2=${mntpoint}2 [ -d $mp2 ] || mkdir -p $mp2 mount | grep -wq $mp2 && umount $mp2 mount -t nullfs $mntpoint $mp2 chmod 777 $mp2 set +e export LOAD=80 export MAXSWAPPCT=80 export RUNDIR=$mp2/stressX export runRUNTIME=10m export rwLOAD=80 export TESTPROGS=' testcases/lockf2/lockf2 testcases/symlink/symlink testcases/openat/openat testcases/socket/socket testcases/rw/rw testcases/mmap/mmap testcases/fts/fts testcases/link/link testcases/lockf/lockf testcases/creat/creat testcases/mkdir/mkdir testcases/rename/rename testcases/swap/swap testcases/mkfifo/mkfifo testcases/dirnprename/dirnprename testcases/dirrename/dirrename ' su $testuser -c 'cd ..; ./testcases/run/run $TESTPROGS' while mount | grep $mp2 | grep -q nullfs; do umount $mp2 || sleep 1 done n=0 while mount | grep $mntpoint | grep -q /dev/md; do umount $mntpoint || sleep 1 n=$((n + 1)) [ $n -gt 30 ] && { echo FAIL; status=2; } done mdconfig -d -u $mdstart exit $status diff --git a/tools/test/stress2/misc/nullfs7.sh b/tools/test/stress2/misc/nullfs7.sh index 329258f5af4d..d790f7ef05b0 100755 --- a/tools/test/stress2/misc/nullfs7.sh +++ b/tools/test/stress2/misc/nullfs7.sh @@ -1,63 +1,62 @@ #!/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. # # "panic: Lock ufs not locked @ ../../../kern/vfs_default.c:508" seen. # Based on scenario by Subbsd # Fixed in r226681 [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg # NULLFS(5) and SUJ has known issues. mount | grep "on `df $RUNDIR | sed '1d;s/.* //'` " | \ grep -q "journaled soft-updates" && { echo "Skipping test due to SUJ."; exit 0; } mount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart || exit 1 -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint [ -d $RUNDIR ] || mkdir -p $RUNDIR for i in `jot 50`; do DST="$mntpoint/$i" [ -d "$DST" ] || mkdir $DST mount -oro -t nullfs $RUNDIR $DST mount -orw -t nullfs /bin $DST done mount | grep nullfs | awk '{print $3}' | xargs umount while mount | grep $mntpoint | grep -q /dev/md; do umount $mntpoint || sleep 1 [ $((n += 1)) -gt 100 ] && exit 1 done mdconfig -d -u $mdstart diff --git a/tools/test/stress2/misc/nullfs9.sh b/tools/test/stress2/misc/nullfs9.sh index e74cde947924..7e7403af3138 100755 --- a/tools/test/stress2/misc/nullfs9.sh +++ b/tools/test/stress2/misc/nullfs9.sh @@ -1,82 +1,81 @@ #!/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. # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 # nullfs + tmpfs regression test: # ETXTBSY problem of executable # Fails with "./nullfs9.sh: cannot create /mnt2/mp/true: Text file busy" . ../default.cfg mnt2=${mntpoint}2 mount | grep -q $mnt2/mp && umount $mnt2/mp [ -d $mnt2 ] || mkdir $mnt2 mount | grep $mnt2 | grep -q /dev/md && umount -f $mnt2 mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mnt2 +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mnt2 chmod 777 $mnt2 mount | grep $mntpoint | grep -q tmpfs && umount -f $mntpoint mount -t tmpfs tmpfs $mntpoint chmod 777 $mntpoint mkdir $mnt2/mp mount -t nullfs $mntpoint $mnt2/mp # OK cp /usr/bin/true $mnt2/mp/true $mntpoint/true if ! > $mntpoint/true ; then echo FAIL 1 mount | egrep "tmpfs|nullfs|$mntpoint |$mnt2 " fi rm -f $mntpoint/true # Fails cp /usr/bin/true $mnt2/mp/true $mnt2/mp/true if ! > $mnt2/mp/true; then echo FAIL 2 mount | egrep "tmpfs|nullfs|$mntpoint |$mnt2 " fi rm -f $mnt2/mp/true umount $mnt2/mp while mount | grep -q "$mnt2 "; do umount $mnt2 || sleep 1 done mdconfig -d -u $mdstart while mount | grep -q "$mntpoint "; do umount $mntpoint || sleep 1 done diff --git a/tools/test/stress2/misc/overcommit.sh b/tools/test/stress2/misc/overcommit.sh index 40f60a32f4af..319cd1ee2192 100755 --- a/tools/test/stress2/misc/overcommit.sh +++ b/tools/test/stress2/misc/overcommit.sh @@ -1,62 +1,61 @@ #!/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. # # Test vm.overcommit # Setting bit 0 of the vm.overcommit sysctl causes the virtual memory # system to return failure to the process when allocation of memory # causes vm.swap_reserved to exceed vm.swap_total. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 old=`sysctl -n vm.overcommit` [ $old -eq 1 ] && exit sysctl vm.overcommit=1 . ../default.cfg 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 +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint export runRUNTIME=10m export RUNDIR=$mntpoint/stressX su $testuser -c 'cd ..; ./run.sh marcus.cfg' while mount | grep "on $mntpoint " | grep -q /dev/md; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart sysctl vm.overcommit=$old diff --git a/tools/test/stress2/misc/overcommit2.sh b/tools/test/stress2/misc/overcommit2.sh index aed26689b933..962fc01e8e50 100755 --- a/tools/test/stress2/misc/overcommit2.sh +++ b/tools/test/stress2/misc/overcommit2.sh @@ -1,65 +1,64 @@ #!/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. # # Test vm.overcommit. Variation of overcommit.sh # Use a swap backed MD disk with the size of 1.2 * hw.usermem. # Deadlock seen: https://people.freebsd.org/~pho/stress/log/alan007.txt [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 [ `swapinfo | wc -l` -eq 1 ] && exit 0 . ../default.cfg old=`sysctl -n vm.overcommit` [ $old -eq 1 ] && exit size=$((`sysctl -n hw.usermem` / 1024 / 1024)) # in MB size=$((size + size / 100 * 20)) # 120% of hw.usermem sysctl vm.overcommit=1 trap "sysctl vm.overcommit=$old" EXIT INT 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 ${size}m -u $mdstart -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint echo "Expect: /mnt: write failed, filesystem is full dd: /mnt/big.1: No space left on device" for i in `jot 10`; do dd if=/dev/zero of=$mntpoint/big.$i bs=1m status=none done wait while mount | grep "on $mntpoint " | grep -q /dev/md; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart diff --git a/tools/test/stress2/misc/overlap.sh b/tools/test/stress2/misc/overlap.sh index f7ac00116559..e1de3e914491 100755 --- a/tools/test/stress2/misc/overlap.sh +++ b/tools/test/stress2/misc/overlap.sh @@ -1,160 +1,159 @@ #!/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. # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 # Test that fails on various non FreeBSD file systems. # 3.13.0-74-generic #118-Ubuntu SMP: Mismatch @ count 214, 0 != 123 # OK on OS X (Darwin Kernel Version 15.5.0) # Scanario by: Michael Ubell ubell mindspring com. . ../default.cfg mount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart sed '1,/^EOF/d' < $0 > /tmp/overlap.c mycc -o /tmp/overlap -Wall -Wextra -O2 /tmp/overlap.c -lpthread || exit 1 rm -f /tmp/overlap.c size="1g" mdconfig -a -t swap -s $size -u $mdstart || exit 1 -bsdlabel -w md$mdstart auto -newfs -U md${mdstart}$part > /dev/null +newfs -U md$mdstart > /dev/null -mount /dev/md${mdstart}$part $mntpoint +mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint (cd $mntpoint; /tmp/overlap) s=$? while mount | grep $mntpoint | grep -q /dev/md; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart rm -f /tmp/overlap exit $s EOF #include #include #include #include #include #include #include #include #include char file[128]; int bsiz, siz; void handler(int s __unused) { _exit(0); } void * writer(void *arg __unused) { int fdes, count; ssize_t nwrite; int *buf; if ((fdes = open(file, O_RDWR|O_CREAT, 0664)) == -1) err(1, "open(%s)", file); count = 0; buf = malloc(bsiz * sizeof(int)); buf[0] = buf[bsiz - 1] = 0; while ((nwrite = pwrite(fdes, buf, siz, 0)) != -1) { if (nwrite < siz) err(1, "pwrite @ count %d, nwrite %zd", count, nwrite); buf[0] = ++buf[bsiz - 1]; count++; } err(1, "pwrite()"); } void * reader(void *arg __unused) { int fdes, count; ssize_t nread; int *buf; if ((fdes = open(file, O_RDWR|O_CREAT, 0664)) == -1) err(1, "open(%s)", file); count = 0; buf = malloc(bsiz * sizeof(int)); while ((nread = pread(fdes, buf, siz, 0)) == 0) continue; do { if (nread < siz) err(1, "pread @ count %d, nread %zd", count, nread); if (buf[0] != buf[bsiz - 1]) { printf("Mismatch @ count %d, %d != %d\n", count, buf[0], buf[bsiz - 1]); abort(); } count++; } while ((nread = pread(fdes, buf, siz, 0)) != -1); err(1, "pread()"); } int main(int argc, char **argv) { pthread_t rp, wp; int ret; void *exitstatus; snprintf(file, sizeof(file), "test.%0d5", getpid()); siz = 65536; if (argc == 2) siz = atoi(argv[1]); bsiz = siz / sizeof(int); signal(SIGALRM, handler); alarm(300); if ((ret = pthread_create(&wp, NULL, writer, NULL)) != 0) errc(1, ret, "pthread_create"); if ((ret = pthread_create(&rp, NULL, reader, NULL)) != 0) errc(1, ret, "pthread_create"); pthread_join(rp, &exitstatus); pthread_join(wp, &exitstatus); unlink(file); return (0); } diff --git a/tools/test/stress2/misc/pageout.sh b/tools/test/stress2/misc/pageout.sh index 5497a1135ff4..eafeb22d3417 100755 --- a/tools/test/stress2/misc/pageout.sh +++ b/tools/test/stress2/misc/pageout.sh @@ -1,144 +1,143 @@ #!/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. # # Trigger the two EDEADLK in vm/vm_pageout.c # OOVM deadlock seen # https://people.freebsd.org/~pho/stress/log/pageout.txt # "panic: handle_written_filepage: not started" seen: # https://people.freebsd.org/~pho/stress/log/pageout-2.txt [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg dir=/tmp odir=`pwd` cd $dir sed '1,/^EOF/d' < $odir/$0 > $dir/pageout.c mycc -o pageout -Wall -Wextra -g pageout.c || exit 1 rm -f pageout.c cd $odir 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 || exit 1 -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null +newfs $newfs_flags md$mdstart > /dev/null -mount /dev/md${mdstart}$part $mntpoint +mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint f1=$mntpoint/f1 dd if=/dev/zero of=$f1 bs=1m count=1k status=none daemon sh -c "(cd ../testcases/swap; ./swap -t 5m -i 20 -l 100 -h)" > /dev/null (cd /tmp; /tmp/pageout $f1) & sleep .2 while kill -0 $! 2> /dev/null; do mksnap_ffs $mntpoint $mntpoint/.snap/stress2 && rm -f $mntpoint/.snap/stress2 done while pgrep -q swap; do pkill swap done wait while mount | grep $mntpoint | grep -q /dev/md; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart rm -f /tmp/pageout /tmp/pageout.core exit EOF #include #include #include #include #include #include #include #include #include #include const char *file; #define RUNTIME 600 void test(void) { struct stat st; size_t i, len; time_t start; int error, fd, ps; char *p; ps = getpagesize(); if ((fd = open(file, O_RDWR)) == -1) err(1, "open(%s)", file); if ((error = fstat(fd, &st)) == -1) err(1, "stat(%s)", file); len = round_page(st.st_size); do { if ((p = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)) == MAP_FAILED) { if (errno == ENOMEM) len -= ps; else err(1, "mmap"); } } while (p == MAP_FAILED); start = time(NULL); /* Touch all pages of the file. */ for (i = 0; i < len; i += ps) p[i] = 1; while (time(NULL) - start < RUNTIME) p[arc4random() % len] = 1; if (munmap(p, len) == -1) err(1, "unmap()"); close(fd); } int main(int argc, char *argv[]) { if (argc != 2) errx(1, "Usage: %s ", argv[0]); file = argv[1]; test(); return (0); } diff --git a/tools/test/stress2/misc/parallelmount.sh b/tools/test/stress2/misc/parallelmount.sh index 5292efbed97a..6d6a5c458328 100755 --- a/tools/test/stress2/misc/parallelmount.sh +++ b/tools/test/stress2/misc/parallelmount.sh @@ -1,68 +1,67 @@ #!/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. # # Parallel mount and unmount of the same mount point # http://people.freebsd.org/~pho/stress/log/parallelumount3.txt [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg parallel=40 if [ $# -eq 0 ]; then [ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart mdconfig -a -t swap -s 10m -u $mdstart || exit 1 - bsdlabel -w md$mdstart auto - newfs $newfs_flags md${mdstart}$part > /dev/null + newfs $newfs_flags md$mdstart > /dev/null # start the parallel tests for i in `jot $parallel`; do ./$0 $i & done while kill -0 $! 2> /dev/null; do for i in `jot 100`; do find $mntpoint > /dev/null 2>&1 done done wait while mount | grep $mntpoint | grep -q /dev/md; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart exit 0 else start=`date '+%s'` while [ $((`date '+%s'` - start)) -lt 600 ]; do - mount /dev/md${mdstart}$part $mntpoint + mount /dev/md$mdstart $mntpoint umount $mntpoint mount done > /dev/null 2>&1 fi diff --git a/tools/test/stress2/misc/parallelmount2.sh b/tools/test/stress2/misc/parallelmount2.sh index 454a7b4b01ed..a90ae65aa8fd 100755 --- a/tools/test/stress2/misc/parallelmount2.sh +++ b/tools/test/stress2/misc/parallelmount2.sh @@ -1,84 +1,83 @@ #!/bin/sh # # Copyright (c) 2016 Dell EMC # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # Quota version of parallelmount.sh # "umount busy seen: # https://people.freebsd.org/~pho/stress/log/parallelmount2.txt [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 [ -z "$DEBUG" ] && exit 0 # Waiting for fix [ "`sysctl -in kern.features.ufs_quota`" != "1" ] && exit 0 . ../default.cfg parallel=40 if [ $# -eq 0 ]; then [ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart mdconfig -a -t swap -s 10m -u $mdstart || exit 1 - bsdlabel -w md$mdstart auto - newfs $newfs_flags md${mdstart}$part > /dev/null + newfs $newfs_flags md$mdstart > /dev/null export PATH_FSTAB=/var/tmp/fstab.$$ - echo "/dev/md${mdstart}$part $mntpoint ufs rw,userquota 2 2" > $PATH_FSTAB - mount /dev/md${mdstart}$part $mntpoint + echo "/dev/md$mdstart $mntpoint ufs rw,userquota 2 2" > $PATH_FSTAB + mount /dev/md$mdstart $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 umount $mntpoint # start the parallel tests for i in `jot $parallel`; do ./$0 $i & done while kill -0 $! 2> /dev/null; do for i in `jot 100`; do find $mntpoint > /dev/null 2>&1 done done wait rm -f $PATH_FSTAB for i in `jot 6`; do mount | grep -q "on $mntpoint " || break umount $mntpoint && break || sleep 10 done [ $i -eq 6 ] && exit 1 mdconfig -d -u $mdstart exit 0 else start=`date '+%s'` while [ $((`date '+%s'` - start)) -lt 600 ]; do - mount /dev/md${mdstart}$part $mntpoint + mount /dev/md$mdstart $mntpoint quotaon $mntpoint umount $mntpoint mount done > /dev/null 2>&1 fi diff --git a/tools/test/stress2/misc/pcatch.sh b/tools/test/stress2/misc/pcatch.sh index f1db7de253f2..6a4ebc34e00a 100755 --- a/tools/test/stress2/misc/pcatch.sh +++ b/tools/test/stress2/misc/pcatch.sh @@ -1,154 +1,153 @@ #!/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. # # The issue makes it possible for applications to get wrong EINTR # or ERESTART (the later is not directly visible) when doing write # to the file on suspended UFS volume. I.e. the thread is sleeping # when fs is suspended, and process is signaled. # Test scenario mostly by kib. # Fixed in r275744. # Deadlock seen: # https://people.freebsd.org/~pho/stress/log/pcatch.txt [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 [ -z "$DEBUG" ] && exit 0 # Waiting for fix . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > pcatch.c mycc -o pcatch -Wall -Wextra -O0 -g pcatch.c || exit 1 rm -f pcatch.c cd $here 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 +newfs $newfs_flags md$mdstart > /dev/null -mount /dev/md${mdstart}$part $mntpoint +mount /dev/md$mdstart $mntpoint start=`date '+%s'` while [ $((`date '+%s'` - start)) -lt 120 ]; do /tmp/pcatch $mntpoint done while mount | grep -q "on $mntpoint "; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart rm -f /tmp/pcatch exit 0 EOF #include #include #include #include #include #include #include #include #include #include #include #include #include static void hand_sigaction(int signo __unused, siginfo_t *si __unused, void *c __unused) { } static void suspend(char *path) { struct statfs s; int fd, error; if (fork() == 0) { if ((error = statfs(path, &s)) != 0) err(1, "statfs %s", path); fd = open("/dev/ufssuspend", O_RDWR); if ((error = ioctl(fd, UFSSUSPEND, &s.f_fsid)) != 0) err(1, "UFSSUSPEND"); sleep(1); if ((error = ioctl(fd, UFSRESUME, &s.f_fsid)) != 0) err(1, "UFSRESUME"); _exit(0); } } static void test(char *mp) { pid_t pid; struct sigaction sa; int fd; char buf[80], file[80]; memset(&sa, 0, sizeof(sa)); sa.sa_sigaction = hand_sigaction; if (sigaction(SIGUSR1, &sa, NULL) == -1) err(1, "sigaction"); snprintf(file, sizeof(file), "%s/file", mp); if ((fd = open(file, O_RDWR | O_CREAT | O_TRUNC, 0640)) == -1) err(1, "open(%s). %s:%d", file, __FILE__, __LINE__); suspend(mp); if ((pid = fork()) == 0) { if (write(fd, buf, sizeof(buf)) == -1) warn("FAIL: write"); _exit(0); } usleep(10000); if (kill(pid, SIGUSR1) == -1) err(1, "kill"); wait(NULL); wait(NULL); close(fd); } int main(int argc, char *argv[]) { if (argc != 2) errx(1, "Usage: %s ", argv[0]); test(argv[1]); return (0); } diff --git a/tools/test/stress2/misc/pfl.sh b/tools/test/stress2/misc/pfl.sh index 6d590b5cf225..d4f435c5f34c 100755 --- a/tools/test/stress2/misc/pfl.sh +++ b/tools/test/stress2/misc/pfl.sh @@ -1,188 +1,186 @@ #!/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. # [ `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 md1=$mdstart md2=$((mdstart + 1)) mp1=${mntpoint}$md1 mp2=${mntpoint}$md2 mkdir -p $mp1 $mp2 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 [ -c /dev/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 +newfs $opt md${md1} > /dev/null +mount /dev/md${md1} $mp1 chmod 777 $mp1 mount | grep "on $mp2 " | grep -q /dev/md && umount -f $mp2 [ -c /dev/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 +newfs $opt md${md2} > /dev/null +mount /dev/md${md2} $mp2 chmod 777 $mp2 su $testuser -c "cd $mp1; /tmp/pfl" & pids=$! su $testuser -c "cd $mp2; /tmp/pfl" & pids="$pids $!" sleep .5 s=0 start=`date '+%s'` while pgrep -q pfl; do if [ $((`date '+%s'`- start)) -gt 900 ]; then s=1 echo "$0 timed out." pkill -9 pfl fi sleep 10 done for p in $pids; do wait $p [ $? -ne 0 ] && s=2 done 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 $s EOF #include #include #include #include #include #include #include #include #include #include #include #define PARALLEL 10 static 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 < 10000; 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) { pid_t pids[PARALLEL]; int e, fd, j, k, s; umask(0); if ((fd = open("continue", O_CREAT, 0644)) == -1) err(1, "open()"); close(fd); e = 0; for (j = 0; j < PARALLEL; j++) { if ((pids[j] = fork()) == 0) { for (k = 0; k < 40; k++) test(); _exit(0); } } for (j = 0; j < PARALLEL; j++) { if (waitpid(pids[j], &s, 0) == -1) err(1, "waitpid(%d)", pids[j]); e += s == 0 ? 0 : 1; } return (e); } diff --git a/tools/test/stress2/misc/pfl2.sh b/tools/test/stress2/misc/pfl2.sh index 9b6497294242..458962b65f2b 100755 --- a/tools/test/stress2/misc/pfl2.sh +++ b/tools/test/stress2/misc/pfl2.sh @@ -1,104 +1,102 @@ #!/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. # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 # Test scenario for the change of a global SU lock to a per filesystem lock. # "panic: softdep_write_inodeblock: indirect pointer #0 mismatch ..." seen. # http://people.freebsd.org/~pho/stress/log/kirk063.txt # https://people.freebsd.org/~pho/stress/log/kirk080.txt . ../default.cfg [ `swapinfo | wc -l` -eq 1 ] && exit 0 md1=$mdstart md2=$((mdstart + 1)) mp1=${mntpoint}$md1 mp2=${mntpoint}$md2 mkdir -p $mp1 $mp2 usermem=`sysctl -n hw.usermem` size=$((2 * 1024 * 1024 * 1024)) # Ideal disk size is 2G [ $((size * 2)) -gt $usermem ] && size=$((usermem / 2)) size=$((size / 1024 / 1024)) opt=$([ $((`date '+%s'` % 2)) -eq 0 ] && echo "-j" || echo "-U") [ "$newfs_flags" = "-U" ] || opt="" mount | grep "on $mp1 " | grep -q /dev/md && umount -f $mp1 mdconfig -l | grep -q md$md1 && mdconfig -d -u $md1 mdconfig -a -t swap -s ${size}m -u $md1 -bsdlabel -w md$md1 auto -newfs $opt md${md1}$part > /dev/null -mount /dev/md${md1}$part $mp1 +newfs $opt md${md1} > /dev/null +mount /dev/md${md1} $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 +newfs $opt md${md2} > /dev/null +mount /dev/md${md2} $mp2 chmod 777 $mp2 export runRUNTIME=10m export RUNDIR=$mp1/stressX export CTRLDIR=$mp1/stressX.control export LOAD=80 export symlinkLOAD=80 export rwLOAD=80 export TESTPROGS=" testcases/lockf2/lockf2 testcases/symlink/symlink testcases/openat/openat testcases/rw/rw testcases/fts/fts testcases/link/link testcases/lockf/lockf testcases/creat/creat testcases/mkdir/mkdir testcases/rename/rename testcases/mkfifo/mkfifo " su $testuser -c 'cd ..; ./testcases/run/run $TESTPROGS' > /dev/null 2>&1 & export TESTPROGS="$TESTPROGS testcases/swap/swap" export RUNDIR=$mp2/stressX export CTRLDIR=$mp2/stressX.control su $testuser -c 'cd ..; ./testcases/run/run $TESTPROGS' > /dev/null 2>&1 & wait while mount | grep "$mp2 " | grep -q /dev/md; do umount $mp2 || sleep 1 done mdconfig -d -u $md2 while mount | grep "$mp1 " | grep -q /dev/md; do umount $mp1 || sleep 1 done mdconfig -d -u $md1 diff --git a/tools/test/stress2/misc/pfl4.sh b/tools/test/stress2/misc/pfl4.sh index 38520a983d33..3459923f5795 100755 --- a/tools/test/stress2/misc/pfl4.sh +++ b/tools/test/stress2/misc/pfl4.sh @@ -1,96 +1,95 @@ #!/bin/sh # # Copyright (c) 2017 Dell EMC Isilon # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # "panic: invalid queue 255" seen: # https://people.freebsd.org/~pho/stress/log/pfl4.txt . ../default.cfg [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 [ $((`sysctl -n hw.usermem` / 1024 / 1024 / 1024)) -le 8 ] && exit 0 mounts=4 newfs_flags="" export runRUNTIME=10m export LOAD=80 export symlinkLOAD=80 export rwLOAD=80 export TESTPROGS=" testcases/lockf2/lockf2 testcases/symlink/symlink testcases/openat/openat testcases/rw/rw testcases/fts/fts testcases/link/link testcases/lockf/lockf testcases/creat/creat testcases/mkdir/mkdir testcases/rename/rename testcases/mkfifo/mkfifo " prefix=$mntpoint start=$mdstart for i in `jot $mounts $start`; do mdstart=$i mntpoint=${prefix}$i [ -d $mntpoint ] || mkdir -p $mntpoint mount | grep "on $mntpoint " | grep -q /dev/md && umount -f $mntpoint 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 + newfs $newfs_flags md$mdstart > /dev/null + mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint export RUNDIR=$mntpoint/stressX export CTRLDIR=$mntpoint/stressX.control set `df -ik $mntpoint | tail -1 | awk '{print $4,$7}'` export KBLOCKS=$(($1 / 1)) export INODES=$(($2 / 1)) su $testuser -c 'sleep 2; cd ..; ./testcases/run/run $TESTPROGS' > \ /dev/null 2>&1 & done su $testuser -c "sleep 2; cd ..; ./testcases/swap/swap -t 10m -i 20" & wait s=0 for i in `jot $mounts $start`; do mdstart=$i mntpoint=${prefix}$i n=0 while mount | grep -q "on $mntpoint "; do umount $mntpoint || sleep 1 n=$((n += 1)) [ $n -gt 60 ] && exit 1 done - checkfs /dev/md${mdstart}$part || s=$? + checkfs /dev/md$mdstart || s=$? mdconfig -d -u $mdstart done exit $s diff --git a/tools/test/stress2/misc/pread.sh b/tools/test/stress2/misc/pread.sh index fecdc18675c9..1bf3b874e6af 100755 --- a/tools/test/stress2/misc/pread.sh +++ b/tools/test/stress2/misc/pread.sh @@ -1,190 +1,189 @@ #!/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. # # pread(2) fuzzing inspired by the iknowthis test suite # by Tavis Ormandy # Fixed in r227527. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > pread.c mycc -o pread -Wall -Wextra pread.c rm -f pread.c mount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mount -t tmpfs tmpfs $mntpoint cp -a /usr/include $mntpoint echo "Testing tmpfs(5)" /tmp/pread $mntpoint while mount | grep -q "on $mntpoint "; do umount $mntpoint || sleep 1 done echo "Testing fdescfs(5)" mount -t fdescfs null /dev/fd for i in `jot 100`; do /tmp/pread /dev/fd done while mount | grep -q "on /dev/fd "; do umount /dev/fd || sleep 1 done echo "Testing procfs(5)" mount -t procfs procfs $mntpoint /tmp/pread $mntpoint while mount | grep -q "on $mntpoint "; do umount $mntpoint || sleep 1 done mdconfig -a -t swap -s 1g -u $mdstart || exit 1 -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint cp -a /usr/include $mntpoint echo "Testing FFS" /tmp/pread $mntpoint while mount | grep -q "on $mntpoint "; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart mount -t nullfs /bin $mntpoint echo "Testing nullfs(5)" /tmp/pread $mntpoint while mount | grep -q "on $mntpoint "; do umount $mntpoint || sleep 1 done echo "Testing procfs(5)" mount -t procfs procfs $mntpoint /tmp/pread $mntpoint while mount | grep -q "on $mntpoint "; do umount $mntpoint || sleep 1 done echo "Testing devfs(8)" mount -t devfs devfs $mntpoint /tmp/pread $mntpoint while mount | grep -q "on $mntpoint "; do umount $mntpoint || sleep 1 done rm -f /tmp/pread exit 0 EOF #include #include #include #include #include #include #include #include #include #include #include #include #include #include static void hand(int i __unused) { /* handler */ _exit(1); } int test(char *path) { FTS *fts; FTSENT *p; int ftsoptions; char *args[2]; int buf[64], fd; signal(SIGSEGV, hand); signal(SIGABRT, hand); ftsoptions = FTS_PHYSICAL; args[0] = path; args[1] = 0; if ((fts = fts_open(args, ftsoptions, NULL)) == NULL) err(1, "fts_open"); while ((p = fts_read(fts)) != NULL) { if ((fd = open(p->fts_path, O_RDONLY)) == -1) { if (errno != EACCES && errno != ENXIO) warn("open(%s)", p->fts_path); continue; } alarm(1); pread(fd, (void *)0xdeadc0de, 0x7ffffff, 0xffffffff); pread(fd, buf, 0x7ffffff, 0xffffffff); pread(fd, buf, sizeof(buf), 0xffffffff); pread(fd, buf, sizeof(buf), 0); close(fd); } fts_close(fts); exit(0); } int main(int argc __unused, char **argv) { int i; struct passwd *pw; if ((pw = getpwnam("nobody")) == NULL) err(1, "no such user: nobody"); if (setgroups(1, &pw->pw_gid) || setegid(pw->pw_gid) || setgid(pw->pw_gid) || seteuid(pw->pw_uid) || setuid(pw->pw_uid)) err(1, "Can't drop privileges to \"nobody\""); endpwent(); if (daemon(0, 0) == -1) err(1, "daemon()"); for (i = 0; i < 10; i++) { if (fork() == 0) test(argv[1]); wait(NULL); } return (0); } diff --git a/tools/test/stress2/misc/quota1.sh b/tools/test/stress2/misc/quota1.sh index 38e0fcd9c351..2bdb16c2a624 100755 --- a/tools/test/stress2/misc/quota1.sh +++ b/tools/test/stress2/misc/quota1.sh @@ -1,57 +1,56 @@ #!/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. # [ `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 dd if=/dev/zero of=$D bs=1m count=128 status=none || exit 1 -mount | grep "$mntpoint" | grep md${mdstart}$part > /dev/null && +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 -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint 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 diff --git a/tools/test/stress2/misc/quota10.sh b/tools/test/stress2/misc/quota10.sh index 1452f68538cf..44d417ab3d33 100755 --- a/tools/test/stress2/misc/quota10.sh +++ b/tools/test/stress2/misc/quota10.sh @@ -1,105 +1,104 @@ #!/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. # # 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 dd if=/dev/zero of=$D$m bs=1m count=1 status=none mdconfig -a -t vnode -f $D$m -u $m - bsdlabel -w md$m auto - newfs md${m}$part > /dev/null 2>&1 - echo "/dev/md${m}$part ${mntpoint}$m ufs rw,userquota 2 2" \ + newfs md${m} > /dev/null 2>&1 + echo "/dev/md${m} ${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 start=`date '+%s'` while [ $((`date '+%s'` - start)) -lt 1200 ]; do m=$1 opt=`[ $(( m % 2 )) -eq 0 ] && echo -f` - mount $opt /dev/md${m}$part ${mntpoint}$m + mount $opt /dev/md${m} ${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 diff --git a/tools/test/stress2/misc/quota11.sh b/tools/test/stress2/misc/quota11.sh index bf08f9e15db4..62fcbe7f0922 100755 --- a/tools/test/stress2/misc/quota11.sh +++ b/tools/test/stress2/misc/quota11.sh @@ -1,67 +1,66 @@ #!/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. # # "panic: share->excl" seen. # http://people.freebsd.org/~pho/stress/log/kostik715.txt # Fixed in r270795 and r270797 # Test scenario by Hiroki Sato [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 [ "`sysctl -in kern.features.ufs_quota`" != "1" ] && exit 0 . ../default.cfg -mount | grep "on $mntpoint " | grep -q md${mdstart}$part && umount $mntpoint +mount | grep "on $mntpoint " | grep -q md$mdstart && umount $mntpoint [ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart || exit 1 -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null +newfs $newfs_flags md$mdstart > /dev/null export PATH_FSTAB=/tmp/fstab trap "rm -f $PATH_FSTAB" 0 -echo "/dev/md${mdstart}$part $mntpoint ufs rw,userquota 2 2" > $PATH_FSTAB +echo "/dev/md$mdstart $mntpoint ufs rw,userquota 2 2" > $PATH_FSTAB mount $mntpoint edquota -u -f $mntpoint -e $mntpoint:1000:2000:100:200 root quotaon $mntpoint while true; do repquota -av > /dev/null; done & dd if=/dev/random of=$mntpoint/foo.data bs=512 count=1024x1024 2>&1 | egrep -v "trans|record" kill $! wait n=0 while mount | grep "on $mntpoint " | grep -q /dev/md; do umount $mntpoint || sleep 1 n=$((n + 1)) [ $n -gt 60 ] && exit 1 done mdconfig -d -u $mdstart exit 0 diff --git a/tools/test/stress2/misc/quota12.sh b/tools/test/stress2/misc/quota12.sh index 78a5e0c0cd81..2b2094f22460 100755 --- a/tools/test/stress2/misc/quota12.sh +++ b/tools/test/stress2/misc/quota12.sh @@ -1,80 +1,79 @@ #!/bin/sh # # SPDX-License-Identifier: BSD-2-Clause-FreeBSD # # Copyright (c) 2018 Dell EMC Isilon # # 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. # # Run marcus.cfg on a quota enabled FS # "Inability to allocate buffers" seen with WiP kernel code: # https://people.freebsd.org/~pho/stress/log/kostik1218.txt [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 [ "`sysctl -in kern.features.ufs_quota`" != "1" ] && exit 0 . ../default.cfg -mount | grep "on $mntpoint " | grep -q md${mdstart}$part && umount $mntpoint +mount | grep "on $mntpoint " | grep -q md$mdstart && umount $mntpoint [ -c /dev/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 > /dev/null export PATH_FSTAB=/tmp/fstab trap "rm -f $PATH_FSTAB" 0 -echo "/dev/md${mdstart}$part $mntpoint ufs rw,userquota 2 2" > $PATH_FSTAB +echo "/dev/md$mdstart $mntpoint ufs rw,userquota 2 2" > $PATH_FSTAB mount $mntpoint set `df -ik $mntpoint | tail -1 | awk '{print $4,$7}'` export KBLOCKS=$1 export INODES=$2 s=0 export QK=$((KBLOCKS / 1)) export QI=$((INODES / 1)) edquota -u -f $mntpoint -e \ ${mntpoint}:$((QK - 50)):$QK:$((QI - 50 )):$QI $testuser > \ /dev/null 2>&1 quotaon $mntpoint chmod 777 $mntpoint export runRUNTIME=15m export RUNDIR=$mntpoint/stressX su $testuser -c 'cd ..; ./run.sh marcus.cfg > /dev/null 2>&1' while ! quotaoff $mntpoint; do sync sleep 1 done quotacheck $mntpoint n=0 while mount | grep "on $mntpoint " | grep -q /dev/md; do umount $mntpoint || sleep 1 n=$((n + 1)) [ $n -gt 60 ] && exit 1 done mdconfig -d -u $mdstart exit 0 diff --git a/tools/test/stress2/misc/quota2.sh b/tools/test/stress2/misc/quota2.sh index 9deb97726d60..3b346ef969d2 100755 --- a/tools/test/stress2/misc/quota2.sh +++ b/tools/test/stress2/misc/quota2.sh @@ -1,57 +1,56 @@ #!/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. # [ `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 dd if=/dev/zero of=$D bs=1m count=128 status=none || exit 1 -mount | grep "$mntpoint" | grep md${mdstart}$part > /dev/null && umount $mntpoint +mount | grep "$mntpoint" | grep md$mdstart > /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 +newfs $newfs_flags md$mdstart > /dev/null +echo "/dev/md$mdstart $mntpoint ufs rw,userquota 2 2" > $PATH_FSTAB mount $mntpoint edquota -u -f $mntpoint -e $mntpoint:100000:110000:15000:16000 root quotacheck $mntpoint quotaon $mntpoint 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 diff --git a/tools/test/stress2/misc/quota3.sh b/tools/test/stress2/misc/quota3.sh index de4c60ec2810..9260178b39fa 100755 --- a/tools/test/stress2/misc/quota3.sh +++ b/tools/test/stress2/misc/quota3.sh @@ -1,57 +1,56 @@ #!/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. # [ `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 dd if=/dev/zero of=$D bs=1m count=1k status=none || exit 1 -mount | grep "$mntpoint" | grep -q md${mdstart}$part && umount $mntpoint +mount | grep "$mntpoint" | grep -q md$mdstart && 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 +newfs $newfs_flags md$mdstart > /dev/null +echo "/dev/md$mdstart $mntpoint ufs rw,userquota 2 2" > $PATH_FSTAB 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 diff --git a/tools/test/stress2/misc/quota4.sh b/tools/test/stress2/misc/quota4.sh index 3eeae263cac2..8acac9958f1b 100755 --- a/tools/test/stress2/misc/quota4.sh +++ b/tools/test/stress2/misc/quota4.sh @@ -1,65 +1,64 @@ #!/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. # [ `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 dd if=/dev/zero of=$D bs=1m count=1k status=none || exit 1 -mount | grep "$mntpoint" | grep md${mdstart}$part > /dev/null && umount \ +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 -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null -echo "/dev/md${mdstart}$part $mntpoint ufs rw,userquota 2 2" >> \ +newfs $newfs_flags md$mdstart > /dev/null +echo "/dev/md$mdstart $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 +sed -i -e "/md$mdstart/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 rm -f $D exit 0 diff --git a/tools/test/stress2/misc/quota6.sh b/tools/test/stress2/misc/quota6.sh index 9cb3f5187f65..05a839adb395 100755 --- a/tools/test/stress2/misc/quota6.sh +++ b/tools/test/stress2/misc/quota6.sh @@ -1,69 +1,68 @@ #!/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. # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 [ "`sysctl -in kern.features.ufs_quota`" != "1" ] && exit 0 . ../default.cfg # Deadlock in umount(1) while out of disk space D=$diskimage truncate -s 250M $D -mount | grep $mntpoint | grep -q md${mdstart}$part && umount $mntpoint +mount | grep $mntpoint | grep -q md$mdstart && 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 +newfs $newfs_flags md$mdstart > /dev/null export PATH_FSTAB=/tmp/fstab -echo "/dev/md${mdstart}$part $mntpoint ufs rw,userquota 2 2" > \ +echo "/dev/md$mdstart $mntpoint ufs rw,userquota 2 2" > \ $PATH_FSTAB mount $mntpoint edquota -u -f $mntpoint -e $mntpoint:850000:900000:130000:140000 root > \ /dev/null 2>&1 quotaon $mntpoint export RUNDIR=$mntpoint/stressX timeout 12m ../testcases/rw/rw -t 10m -i 200 -h -n & pid=$! for i in `jot 5`; do echo "`date '+%T'` mksnap_ffs $mntpoint $mntpoint/.snap/snap$i" mksnap_ffs $mntpoint $mntpoint/.snap/snap$i done for i in `jot 5`; do rm -f $mntpoint/.snap/snap1 done kill $pid wait while mount | grep -q $mntpoint; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart rm -f $D $PATH_FSTAB exit 0 diff --git a/tools/test/stress2/misc/quota7.sh b/tools/test/stress2/misc/quota7.sh index f098fceb0939..2e2fe6b7a52d 100755 --- a/tools/test/stress2/misc/quota7.sh +++ b/tools/test/stress2/misc/quota7.sh @@ -1,79 +1,78 @@ #!/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. # # 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 status=none 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 +newfs $newfs_flags md$mdstart > /dev/null export PATH_FSTAB=/tmp/fstab -echo "/dev/md${mdstart}$part $mntpoint ufs rw,userquota 2 2" > $PATH_FSTAB +echo "/dev/md$mdstart $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=20m ./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 diff --git a/tools/test/stress2/misc/quota8.sh b/tools/test/stress2/misc/quota8.sh index a11418aba5d9..148c2d19ce65 100755 --- a/tools/test/stress2/misc/quota8.sh +++ b/tools/test/stress2/misc/quota8.sh @@ -1,89 +1,88 @@ #!/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. # # 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 dd if=/dev/zero of=$D bs=1m count=1k status=none || 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" >> \ +newfs $newfs_flags md$mdstart > /dev/null +echo "/dev/md$mdstart $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 +sed -i -e "/md$mdstart/d" /etc/fstab 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 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 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 diff --git a/tools/test/stress2/misc/quota9.sh b/tools/test/stress2/misc/quota9.sh index 01681bce8a01..1baf4b7b0267 100755 --- a/tools/test/stress2/misc/quota9.sh +++ b/tools/test/stress2/misc/quota9.sh @@ -1,93 +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. # # Test if quotacheck reports actual usage. . ../default.cfg export tmp=/tmp/$(basename $0).$$ export D=$diskimage qc() { local s umount $1 s=0 quotacheck -v $1 > $tmp 2>&1 grep -q fixed $tmp && { cat $tmp; s=1; } mount $1 return $s } 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 dd if=/dev/zero of=$D bs=1m count=50 status=none || 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 +newfs $newfs_flags md$mdstart > /dev/null export PATH_FSTAB=/tmp/fstab -echo "/dev/md${mdstart}$part $mntpoint ufs rw,userquota 2 2" \ +echo "/dev/md$mdstart $mntpoint ufs rw,userquota 2 2" \ > $PATH_FSTAB mount $mntpoint 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 -c ' for i in `jot 20`; do dd if=/dev/zero of=$mntpoint/stressX/d$i bs=1m count=1 \ status=none done ' qc $mntpoint; s=$? 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 $PATH_FSTAB exit $s diff --git a/tools/test/stress2/misc/readdir.sh b/tools/test/stress2/misc/readdir.sh index 16523982d859..8616a8a40206 100755 --- a/tools/test/stress2/misc/readdir.sh +++ b/tools/test/stress2/misc/readdir.sh @@ -1,179 +1,177 @@ #!/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. # # readdir(3) fuzzing inspired by the iknowthis test suite # by Tavis Ormandy # "panic: kmem_malloc(1328054272): kmem_map too small" seen [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > readdir.c mycc -o readdir -Wall -Wextra readdir.c || exit 1 rm -f readdir.c mount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mount -t tmpfs tmpfs $mntpoint echo "Testing tmpfs(5)" cp -a /usr/include $mntpoint /tmp/readdir $mntpoint umount $mntpoint echo "Testing fdescfs(5)" kldstat -v | grep -q fdescfs || { kldload fdescfs.ko; loaded=1; } mount -t fdescfs null /dev/fd /tmp/readdir /dev/fd umount /dev/fd [ $unload ] && kldunload fdescfs.ko echo "Testing procfs(5)" mount -t procfs procfs $mntpoint /tmp/readdir $mntpoint umount $mntpoint if ping -c 2 `echo $nfs_export | sed 's/:.*//'` > /dev/null 2>&1; then echo "Testing nfs" mount -t nfs -o nfsv3,tcp,nolockd,retrycnt=3,soft,timeout=1 \ $nfs_export $mntpoint /tmp/readdir $mntpoint umount $mntpoint fi mdconfig -a -t swap -s 1g -u $mdstart || exit 1 -bsdlabel -w md$mdstart auto -newfs md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint cp -a /usr/include $mntpoint echo "Testing UFS" /tmp/readdir $mntpoint umount $mntpoint mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart || exit 1 -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint cp -a /usr/include $mntpoint echo "Testing FFS" /tmp/readdir $mntpoint umount $mntpoint mdconfig -d -u $mdstart mount -t nullfs /bin $mntpoint echo "Testing nullfs(5)" /tmp/readdir $mntpoint umount $mntpoint rm -f /tmp/readdir exit 0 EOF #include #include #include #include #include #include #include #include #include #include #include #include #define RUNTIME 120 /* copy from /usr/src/lib/libc/gen/gen-private.h */ struct _telldir; /* see telldir.h */ struct pthread_mutex; /* * Structure describing an open directory. * * NOTE. Change structure layout with care, at least dd_fd field has to * remain unchanged to guarantee backward compatibility. */ struct _dirdesc { int dd_fd; /* file descriptor associated with directory */ long dd_loc; /* offset in current buffer */ long dd_size; /* amount of data returned by getdirentries */ char *dd_buf; /* data buffer */ int dd_len; /* size of data buffer */ long dd_seek; /* magic cookie returned by getdirentries */ long dd_rewind; /* magic cookie for rewinding */ int dd_flags; /* flags for readdir */ struct pthread_mutex *dd_lock; /* lock */ struct _telldir *dd_td; /* telldir position recording */ }; /* End copy */ static void hand(int i __unused) { /* handler */ _exit(1); } static void test(char *path) { DIR *dirp, fuzz; int i; signal(SIGSEGV, hand); alarm(300); for (i = 0; i < 2000; i++) { if ((dirp = opendir(path)) == NULL) break; bcopy(dirp, &fuzz, sizeof(fuzz)); fuzz.dd_len = arc4random(); readdir(&fuzz); closedir(dirp); } _exit(0); } int main(int argc __unused, char **argv) { time_t start; start = time(NULL); while (time(NULL) - start < RUNTIME) { if (fork() == 0) test(argv[1]); wait(NULL); } return (0); } diff --git a/tools/test/stress2/misc/recursiveflushes.sh b/tools/test/stress2/misc/recursiveflushes.sh index 1da843a2f1d1..7e6e8a7236a6 100755 --- a/tools/test/stress2/misc/recursiveflushes.sh +++ b/tools/test/stress2/misc/recursiveflushes.sh @@ -1,75 +1,74 @@ #!/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. # # Test recursive flushes in bdwrite(). [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg snap() { for i in `jot 5`; do mksnap_ffs $1 $2 [ $? -eq 0 ] && break done } mount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 4g -u $mdstart || exit 1 -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint old=`sysctl vfs.recursiveflushes | awk '{print $NF}'` cd $mntpoint rm -f $mntpoint/.snap/stress2.* snap $mntpoint $mntpoint/.snap/stress2.1 snap $mntpoint $mntpoint/.snap/stress2.2 snap $mntpoint $mntpoint/.snap/stress2.3 snap $mntpoint $mntpoint/.snap/stress2.4 snap $mntpoint $mntpoint/.snap/stress2.5 for i in `jot 32`; do # Create 32 Mb files dd if=/dev/zero of=big.$i bs=16k count=2048 status=none done wait for i in `jot 32`; do rm -f big.$i done rm -f $mntpoint/.snap/stress2.* new=`sysctl vfs.recursiveflushes | awk '{print $NF}'` [ $old != $new ] && echo "vfs.recursiveflushes changed from $old to $new" cd / while mount | grep $mntpoint | grep -q /dev/md; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart diff --git a/tools/test/stress2/misc/rename10.sh b/tools/test/stress2/misc/rename10.sh index 5cbf39f3d3d2..8a76ba4ed05b 100755 --- a/tools/test/stress2/misc/rename10.sh +++ b/tools/test/stress2/misc/rename10.sh @@ -1,184 +1,183 @@ #!/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. # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 # Regression test for rename(2) problem with missing reference release of # a busy "to" vnode, resulting in a leak. # Fixed in r253998. . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > rename10.c mycc -o rename10 -Wall -Wextra -g -O2 rename10.c || exit 1 rm -f rename10.c cd $here mount | grep "on $mntpoint " | grep -q /dev/md && umount -f $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 4g -u $mdstart || exit 1 -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint avail=`df -k $mntpoint | tail -1 | awk '{print $4}'` cd $mntpoint /tmp/rename10; s=$? cd $here for i in `jot 3`; do sync sleep 2 done if [ `df -k $mntpoint | tail -1 | awk '{print $4}'` -lt $avail ]; then echo FAIL ls -ial $mntpoint df -i $mntpoint fi n=0 while mount | grep "on $mntpoint " | grep -q /dev/md; do umount $mntpoint || sleep 1 n=$((n + 1)) [ $n -gt 5 ] && { umount -f $mntpoint; break; } done -checkfs /dev/md${mdstart}$part || s=$? +checkfs /dev/md$mdstart || s=$? rm -f /tmp/rename10 mdconfig -d -u $mdstart exit $s EOF #include #include #include #include #include #include #include #include #include #include #define PARALLEL 4 #define SIZE (1 * 1024 * 1024) static char *logfile = "logfile"; static char *oldfiles[] = { "logfile.0", "logfile.1", "logfile.2", "logfile.3", "logfile.4" }; void * logger(void) { int fd; char * cp; setproctitle("logger"); cp = calloc(1, SIZE); for(;;) { if ((fd = open(logfile, O_RDWR | O_APPEND)) != -1) { if (write(fd, cp, SIZE) != SIZE) err(1, "write()"); close(fd); } usleep(1); } _exit(0); } void * spin(void) { int fd, i; setproctitle("spin"); for(;;) { for (i = 0; i < 5; i++) { if ((fd = open(oldfiles[i], O_RDWR | O_APPEND)) != -1) close(fd); } usleep(1); } _exit(0); } void renamer() { int fd, i; time_t start; setproctitle("renamer"); start = time(NULL); i = 0; while (time(NULL) - start < 60) { if ((fd = open(logfile, O_RDWR | O_CREAT | O_EXCL, 0644)) == -1) err(1, "creat(%s)", logfile); close(fd); if (rename(logfile, oldfiles[i]) == -1) err(1, "rename(%s, %s)", logfile, oldfiles[i]); i = (i + 1) % 5; } for (i = 0; i < 5; i++) { unlink(oldfiles[i]); } unlink(logfile); } int main() { pid_t pids[PARALLEL], spids[PARALLEL]; int i; for (i = 0; i < PARALLEL; i++) { if ((pids[i] = fork()) == 0) logger(); if ((spids[i] = fork()) == 0) spin(); } renamer(); for (i = 0; i < PARALLEL; i++) { if (kill(pids[i], SIGINT) == -1) err(1, "kill(%d)", pids[i]); if (kill(spids[i], SIGINT) == -1) err(1, "kill(%d)", spids[i]); } for (i = 0; i < PARALLEL * 2; i++) wait(NULL); wait(NULL); return (0); } diff --git a/tools/test/stress2/misc/rename11.sh b/tools/test/stress2/misc/rename11.sh index 19aaa16f92ea..bae0c31c376f 100755 --- a/tools/test/stress2/misc/rename11.sh +++ b/tools/test/stress2/misc/rename11.sh @@ -1,139 +1,138 @@ #!/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. # # 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 [ $# -eq 1 ] && newfs_flags=$1 # Problem only seen with SU -echo newfs $newfs_flags md${mdstart}$part -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +echo newfs $newfs_flags md$mdstart +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint mkdir $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; s=$? +checkfs /dev/md$mdstart; s=$? mdconfig -d -u $mdstart rm -rf /tmp/rename11 exit $s EOF #include #include #include #include #include #include #include #include #include #include #define LOOPS 10 #define PARALLEL 3 #define ND 5000 static void check(char *name) { struct stat sb; if (stat(name, &sb) == -1) warn("stat(%s)", name); else warnx("stat(%s) succeeded!", name); } static 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); } diff --git a/tools/test/stress2/misc/rename12.sh b/tools/test/stress2/misc/rename12.sh index 3000e59b70d3..0f15c7e543d3 100755 --- a/tools/test/stress2/misc/rename12.sh +++ b/tools/test/stress2/misc/rename12.sh @@ -1,192 +1,191 @@ #!/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. # # No problems seen with SU. Panics with SU+J, just like suj30.sh # Triggers "known LOR in SU code" when crossmp8.sh is run first: # https://people.freebsd.org/~pho/stress/log/rename12.txt. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > rename12.c mycc -o rename12 -Wall -Wextra rename12.c || exit 1 rm -f rename12.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 4g -u $mdstart || exit 1 -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint inodes=`df -i $mntpoint | tail -1 | awk '{print $7}'` loops=4 parallel=12 timeout=1200 start=`date '+%s'` for i in `jot $loops`; do for j in `jot $parallel`; do mkdir -p $mntpoint/d$j/dir1 mkdir -p $mntpoint/d$j/dir2 (cd $mntpoint/d$j; /tmp/rename12 $((inodes/parallel)) ) & done wait for j in `jot $parallel`; do rmdir $mntpoint/d$j/dir1 rmdir $mntpoint/d$j/dir2 done [ $((`date '+%s'` - start)) -lt $timeout ] && break done while mount | grep "on $mntpoint " | grep -q /dev/md; do umount $mntpoint || sleep 1 done -checkfs /dev/md${mdstart}$part; s=$? +checkfs /dev/md$mdstart; s=$? mdconfig -d -u $mdstart rm -rf /tmp/rename12 exit $s EOF #include #include #include #include #include #include #include #include #include #include #include pid_t crpid; long n; int mvpipe[2], rmpipe[2]; void cr(void) { pid_t pid; int i; char name[80]; setproctitle("cr"); pid = getpid(); usleep(arc4random() & 1000); for (i = 0; i < n; i++) { snprintf(name, sizeof(name), "dir1/d.%06d.%06d", pid, i); if (mkdir(name, 0700) == -1) err(1, "mkdir(%s). %s:%d", name, __FILE__, __LINE__); if (write(mvpipe[1], &i, sizeof(i)) != sizeof(i)) err(1, "write mvpipe"); } _exit(0); } void mv(void) { pid_t pid; int i; char name[80], to[80]; setproctitle("mv"); pid = crpid; i = 0; while (i != n - 1 && read(mvpipe[0], &i, sizeof(i)) == sizeof(i)) { snprintf(name, sizeof(name), "dir1/d.%06d.%06d", pid, i); snprintf(to , sizeof(to ), "dir2/d.%06d.%06d", pid, i); if (rename(name, to) == -1) warn("rename(%s, %s)", name, to); if (write(rmpipe[1], &i, sizeof(i)) != sizeof(i)) err(1, "write rmpipe"); } _exit(0); } void rm(void) { pid_t pid; int i; char to[80]; setproctitle("rm"); pid = crpid; i = 0; while (i != n - 1 && read(rmpipe[0], &i, sizeof(i)) == sizeof(i)) { snprintf(to, sizeof(to ), "dir2/d.%06d.%06d", pid, i); if (rmdir(to) == -1) warn("rmdir(%s)", to); } _exit(0); } int main(int argc, char **argv) { int r, s; if (argc != 2) errx(1, "Usage %s ", argv[0]); n = atol(argv[1]); if (n > 32765) { n = 32765 - 1; } if (pipe(mvpipe) == -1) err(1, "pipe()"); if (pipe(rmpipe) == -1) err(1, "pipe()"); r = 0; if ((crpid = fork()) == 0) cr(); if (fork() == 0) mv(); if (fork() == 0) rm(); wait(&s); r += WEXITSTATUS(s); wait(&s); r += WEXITSTATUS(s); wait(&s); r += WEXITSTATUS(s); return (r); } diff --git a/tools/test/stress2/misc/rename13.sh b/tools/test/stress2/misc/rename13.sh index 9234d4454751..7184c82cbf78 100755 --- a/tools/test/stress2/misc/rename13.sh +++ b/tools/test/stress2/misc/rename13.sh @@ -1,60 +1,59 @@ #!/bin/sh # # Copyright (c) 2017 Dell EMC Isilon # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # Regression test for crossmp scenario: # Bug 216380 - mv /[dir == mountpoint] causes kernel panic # "panic: No vop_rename(0xfffff80033049000, 0xfffffe104d1e48a8)" seen. # Fixed by r312645. # Test scenario by: fnacl@protonmail.com [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg mount | grep -q "on $mntpoint " && umount -f $mntpoint [ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart mdconfig -a -t swap -s 512m -u $mdstart || exit 1 -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint s=0 to=/tmp/rename13.dir mkdir $to mv $mntpoint $to 2>/dev/null && s=1 for i in `jot 10`; do mount | grep -q "on $mntpoint " || break umount $mntpoint || sleep 1 done mount | grep -q "on $mntpoint " && { s=2; umount -f $mntpoint; } mdconfig -d -u $mdstart rm -rf $to exit $s diff --git a/tools/test/stress2/misc/rename5.sh b/tools/test/stress2/misc/rename5.sh index 89779b79ec32..9a83bf85e2c0 100755 --- a/tools/test/stress2/misc/rename5.sh +++ b/tools/test/stress2/misc/rename5.sh @@ -1,137 +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. # # 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 -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $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 +while mount | grep -q md$mdstart; do umount $mntpoint || sleep 1 done -checkfs /dev/md${mdstart}$part; s=$? +checkfs /dev/md$mdstart; s=$? mdconfig -d -u $mdstart exit $s 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); } diff --git a/tools/test/stress2/misc/rename6.sh b/tools/test/stress2/misc/rename6.sh index 6c27c5601d2a..b08a0851266e 100755 --- a/tools/test/stress2/misc/rename6.sh +++ b/tools/test/stress2/misc/rename6.sh @@ -1,149 +1,148 @@ #!/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. # [ `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 +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint su $testuser -c "cd $mntpoint; /tmp/rename6" -while mount | grep -q md${mdstart}$part; do +while mount | grep -q md$mdstart; 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() { if (kill(spid, SIGINT) == -1 && errno != ESRCH) err(1, "kill(%d)", spid); } 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); } diff --git a/tools/test/stress2/misc/rename7.sh b/tools/test/stress2/misc/rename7.sh index 89edcd17e827..9f6954916411 100755 --- a/tools/test/stress2/misc/rename7.sh +++ b/tools/test/stress2/misc/rename7.sh @@ -1,150 +1,149 @@ #!/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. # [ `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 +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint su $testuser -c "cd $mntpoint; /tmp/rename7 || echo FAIL" for i in `jot 10`; do - mount | grep -q md${mdstart}$part && \ + mount | grep -q md$mdstart && \ umount $mntpoint && mdconfig -d -u $mdstart && break done -if mount | grep -q md${mdstart}$part; then +if mount | grep -q md$mdstart; 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); } diff --git a/tools/test/stress2/misc/rename8.sh b/tools/test/stress2/misc/rename8.sh index e0019cb353fa..990b8e96c941 100755 --- a/tools/test/stress2/misc/rename8.sh +++ b/tools/test/stress2/misc/rename8.sh @@ -1,173 +1,172 @@ #!/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. # [ `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 +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint 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 && \ + mount | grep -q md$mdstart && \ umount $mntpoint && mdconfig -d -u $mdstart && break sleep 1 done -if mount | grep -q md${mdstart}$part; then +if mount | grep -q md$mdstart; 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); } diff --git a/tools/test/stress2/misc/rename9.sh b/tools/test/stress2/misc/rename9.sh index e169c64af5ea..67f5de37b70f 100755 --- a/tools/test/stress2/misc/rename9.sh +++ b/tools/test/stress2/misc/rename9.sh @@ -1,169 +1,168 @@ #!/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. # [ `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 +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $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" kill $! > /dev/null 2>&1 wait ls -ilR $mntpoint | egrep -v "^total " -while mount | grep -q md${mdstart}$part; do +while mount | grep -q md$mdstart; 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); } diff --git a/tools/test/stress2/misc/rot.sh b/tools/test/stress2/misc/rot.sh index b658f35aad1b..3254562fad13 100755 --- a/tools/test/stress2/misc/rot.sh +++ b/tools/test/stress2/misc/rot.sh @@ -1,142 +1,141 @@ #!/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. # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 # Unmapped I/O test scenario: # http://people.freebsd.org/~pho/stress/log/kostik515.txt . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > rot.c mycc -o rot -Wall -Wextra -O2 -g rot.c || exit 1 rm -f rot.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 || exit 1 -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null +newfs $newfs_flags md$mdstart > /dev/null -mount /dev/md${mdstart}$part $mntpoint +mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint (cd $mntpoint; /tmp/rot) (cd `dirname $diskimage`; /tmp/rot) while mount | grep $mntpoint | grep -q /dev/md; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart rm -f /tmp/rot exit 0 EOF #include #include #include #include #include #include #include #include #define N 10240 /* 40 Mb */ #define PARALLEL 20 #define RUNTIME (60 * 15) int test(void) { int fd, i, j, s; unsigned char *buf; char path[128]; s = getpagesize(); sprintf(path,"%s.%05d", getprogname(), getpid()); if ((fd = open(path, O_RDWR | O_CREAT | O_TRUNC, 0600)) < 0) err(1, "open(%s)", path); if (lseek(fd, s * N - 1, SEEK_SET) == -1) err(1, "lseek error"); /* write a dummy byte at the last location */ if (write(fd, "", 1) != 1) err(1, "write error"); for (i = 0; i < N; i++) { if ((buf = mmap(0, s, PROT_READ | PROT_WRITE, MAP_SHARED, fd, i * s)) == MAP_FAILED) err(1, "write map"); for (j = 0; j < s; j++) buf[j] = i % 256; } if (munmap(buf, s) == -1) err(1, "unmap (write)"); close(fd); if ((fd = open(path, O_RDONLY)) < 0) err(1, "open(%s)", path); for (i = 0; i < N; i++) { if ((buf = mmap(0, s, PROT_READ, MAP_SHARED, fd, i * s)) == MAP_FAILED) err(1, "write map"); for (j = 0; j < s; j++) if (buf[j] != i % 256) fprintf(stderr, "read %d, expected %d at %d\n", buf[j], i % 256, i); } if (munmap(buf, s) == -1) err(1, "unmap (read)"); close(fd); unlink(path); _exit(0); } int main(void) { time_t start; int i; start = time(NULL); while (time(NULL) - start < RUNTIME) { for (i = 0; i < PARALLEL; i++) if (fork() == 0) test(); for (i = 0; i < PARALLEL; i++) wait(NULL); } return(0); } diff --git a/tools/test/stress2/misc/routetbl.sh b/tools/test/stress2/misc/routetbl.sh index 0a2b936f15e4..df4fd64409eb 100755 --- a/tools/test/stress2/misc/routetbl.sh +++ b/tools/test/stress2/misc/routetbl.sh @@ -1,61 +1,60 @@ #!/bin/sh # # Copyright (c) 2017 Dell EMC Isilon # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # Demonstrate memory leak of routetbl allegedly caused by use free() in # vfs_free_addrlist_af(), instead of rn_detachhead(). # "routetbl grew 3868" seen on amd64. . ../default.cfg [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 pgrep -q mountd || exit 0 mount | grep "on $mntpoint " | grep -q /dev/md && umount -f $mntpoint [ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart mdconfig -a -t swap -s 128m -u $mdstart || exit 1 -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null +newfs $newfs_flags md$mdstart > /dev/null routetbl=`vmstat -m | grep routetbl | awk '{print $2}'` s=0 start=`date +%s` while [ $((`date +%s` - start)) -lt 60 ]; do - mount /dev/md${mdstart}$part $mntpoint && + mount /dev/md$mdstart $mntpoint && umount $mntpoint done routetbl=$((`vmstat -m | grep routetbl | awk '{print $2}'` - routetbl)) [ $routetbl -gt 0 ] && { echo "routetbl grew $routetbl"; s=1; } for i in `jot 6`; do mount | grep -q "on $mntpoint " || break umount $mntpoint && break || sleep 10 done [ $i -eq 6 ] && exit 1 mdconfig -d -u $mdstart rm -rf /tmp/template exit $s diff --git a/tools/test/stress2/misc/rw.sh b/tools/test/stress2/misc/rw.sh index 2cba9587c925..3f7f83df49db 100755 --- a/tools/test/stress2/misc/rw.sh +++ b/tools/test/stress2/misc/rw.sh @@ -1,65 +1,64 @@ #!/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. # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 # Simple read / write test scenario with VM pressure. # Out of VM seen: # 100135 D vmwait 0xffffffff81d1a348 [CAM taskq] # https://people.freebsd.org/~pho/stress/log/rw.txt . ../default.cfg mount | grep "on $mntpoint " | grep -q /dev/md && umount -f $mntpoint [ -c /dev/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 > /dev/null -mount /dev/md${mdstart}$part $mntpoint +mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint export runRUNTIME=10m export RUNDIR=$mntpoint/stressX export rwLOAD=100 export swapLOAD=100 export TESTPROGS=" testcases/rw/rw testcases/swap/swap " su $testuser -c 'cd ..; ./testcases/run/run $TESTPROGS' while mount | grep "on $mntpoint " | grep -q /dev/md; do umount $mntpoint || sleep 1 done mdconfig -d -u $mdstart diff --git a/tools/test/stress2/misc/sched.sh b/tools/test/stress2/misc/sched.sh index f91055b3c289..1a1db70eb38a 100755 --- a/tools/test/stress2/misc/sched.sh +++ b/tools/test/stress2/misc/sched.sh @@ -1,161 +1,160 @@ #!/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. # [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 # Show scheduler fairness for ULE vs. 4BSD. . ../default.cfg here=`pwd` cd /tmp sed '1,/^EOF/d' < $here/$0 > sched.c mycc -o sched -Wall -Wextra -O0 sched.c || exit 1 rm -f sched.c cd $here mount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart || exit 1 -bsdlabel -w md$mdstart auto -newfs $newfs_flags md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint chmod 777 $mntpoint cpus=`sysctl hw.ncpu | sed 's/.*: //'` uname -v (cd $mntpoint; /tmp/sched $((cpus + 1))) > /dev/null 2>&1 & sleep 30 export LANG=C top -U nobody -d 1 | grep nobody | awk '{print $11}' | sed 's/%//' | ministat -A -w 73 | tail -1 | awk '{if ($NF > 1.0) exit 1}' || { echo Broken; top -U nobody -d 1 | grep nobody; } killall sched wait for i in `jot 3`; do echo "run #$i" (cd $mntpoint; /tmp/sched $((cpus + 1))) done while mount | grep $mntpoint | grep -q /dev/md; do umount $mntpoint || sleep 1 done rm -f /tmp/sched mdconfig -d -u $mdstart exit EOF #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define N 100 * 1024 * 1024 double r; int parallel; void work(void) { struct passwd *pw; struct timespec start, finish; double d1, d2; int i, j; volatile char *cp; while (access("rendezvous", R_OK) != 0) usleep(1); if ((pw = getpwnam("nobody")) == NULL) err(1, "no such user: nobody"); if (setgroups(1, &pw->pw_gid) || setegid(pw->pw_gid) || setgid(pw->pw_gid) || seteuid(pw->pw_uid) || setuid(pw->pw_uid)) err(1, "Can't drop privileges to \"nobody\""); endpwent(); d1 = d2 = 0; cp = malloc(N); clock_gettime(CLOCK_REALTIME_PRECISE, &start); for (i = 0; i < 1; i++) { for (j = 0; j < INT_MAX; j++) { d1 = d1 + 1.0 / j; d2 = d1 + 0.8 / j; if (j % 1000 == 0) { cp[arc4random() % N] = j % 255; } } } r = d1 + d2; clock_gettime(CLOCK_REALTIME_PRECISE, &finish); timespecsub(&finish, &start, &finish); #if defined(DEBUG) fprintf(stderr, "Elapsed time for pid %d: %.4f\n", getpid(), finish.tv_sec + (double)finish.tv_nsec / 1e9); #endif _exit(0); } int main(int argc, char **argv) { int fd, i; if (argc == 2) parallel = atoi(argv[1]); else errx(1, "Usage: %s ", argv[0]); for (i = 0; i < parallel; i++) { if (fork() == 0) work(); } if ((fd = open("rendezvous", O_CREAT, 0644)) == -1) err(1, "open()"); close(fd); for (i = 0; i < parallel; i++) wait(NULL); return (0); } diff --git a/tools/test/stress2/misc/sendfile10.sh b/tools/test/stress2/misc/sendfile10.sh index df94c0f78ace..2e7c142b6bdf 100755 --- a/tools/test/stress2/misc/sendfile10.sh +++ b/tools/test/stress2/misc/sendfile10.sh @@ -1,313 +1,312 @@ #!/bin/sh # # Copyright (c) 2017 Dell EMC Isilon # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # Copy of sendfile8.sh with size validation added. # No problems seen (after r315910). . ../default.cfg [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 dir=/tmp odir=`pwd` cd $dir sed '1,/^EOF/d' < $odir/$0 > $dir/sendfile10.c mycc -o sendfile10 -Wall -Wextra -O0 -g sendfile10.c || exit 1 rm -f sendfile10.c cd $odir mount | grep "on $mntpoint " | grep -q /dev/md && umount -f $mntpoint [ -c /dev/md$mdstart ] && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart || exit 1 -bsdlabel -w md$mdstart auto -newfs $newfs_flags -n md${mdstart}$part > /dev/null -mount /dev/md${mdstart}$part $mntpoint +newfs $newfs_flags -n md$mdstart > /dev/null +mount /dev/md$mdstart $mntpoint cd $mntpoint dd if=/dev/random of=template bs=1m count=50 status=none /tmp/sendfile10 template in out 76543 s=$? cd $odir for i in `jot 6`; do mount | grep -q "on $mntpoint " || break umount $mntpoint && break || sleep 10 done [ $i -eq 6 ] && exit 1 mdconfig -d -u $mdstart rm -rf /tmp/sendfile10 exit $s EOF #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include static volatile off_t *share; static int port; static char *input, *output; #define BUFSIZE 4096 #define MX (100 * 1024 * 1024) #define OSZ 1 #define PARALLEL 1 #define RUNTIME (2 * 60) #define SZ 0 static void mess(void) { off_t length; int fd; if ((fd = open(input, O_RDWR)) == -1) err(1, "open(%s)", input); length = arc4random() % MX; if (ftruncate(fd, length) == -1) err(1, "truncate(%jd)", length); share[SZ] = length; close(fd); } static void reader(void) { off_t t __unused; int tcpsock, msgsock; int on; socklen_t len; struct sockaddr_in inetaddr, inetpeer; int n, *buf, fd; on = 1; if ((tcpsock = socket(AF_INET, SOCK_STREAM, 0)) < 0) err(1, "socket(), %s:%d", __FILE__, __LINE__); if (setsockopt(tcpsock, SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on)) < 0) err(1, "setsockopt(), %s:%d", __FILE__, __LINE__); inetaddr.sin_family = AF_INET; inetaddr.sin_addr.s_addr = INADDR_ANY; inetaddr.sin_port = htons(port); inetaddr.sin_len = sizeof(inetaddr); if (bind(tcpsock, (struct sockaddr *)&inetaddr, sizeof (inetaddr)) < 0) err(1, "bind(), %s:%d", __FILE__, __LINE__); if (listen(tcpsock, 5) < 0) err(1, "listen(), %s:%d", __FILE__, __LINE__); len = sizeof(inetpeer); alarm(10); if ((msgsock = accept(tcpsock, (struct sockaddr *)&inetpeer, &len)) < 0) err(1, "accept(), %s:%d", __FILE__, __LINE__); alarm(0); t = 0; if ((buf = malloc(BUFSIZE)) == NULL) err(1, "malloc(%d), %s:%d", BUFSIZE, __FILE__, __LINE__); if ((fd = open(output, O_RDWR | O_CREAT | O_TRUNC, 0640)) == -1) err(1, "open(%s)", output); for (;;) { if ((n = read(msgsock, buf, BUFSIZE)) < 0) err(1, "read(), %s:%d", __FILE__, __LINE__); t += n; if (n == 0) break; if ((write(fd, buf, n)) != n) err(1, "write"); } close(msgsock); close(fd); #if 0 if (t != share[SZ] && t != share[OSZ]) { fprintf(stderr, "1) Send size %lu, original size %lu, " "receive size %lu\n", (unsigned long)share[SZ], (unsigned long)share[OSZ], (unsigned long)t); exit(1); } #endif return; } static void writer(void) { struct sockaddr_in inetaddr; struct hostent *hostent; struct stat statb; off_t off = 0; size_t size; int i, r, fd; int tcpsock, on; on = 1; for (i = 1; i < 5; i++) { if ((tcpsock = socket(AF_INET, SOCK_STREAM, 0)) < 0) err(1, "socket(), %s:%d", __FILE__, __LINE__); if (setsockopt(tcpsock, SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on)) < 0) err(1, "setsockopt(), %s:%d", __FILE__, __LINE__); size = getpagesize() -4; if (setsockopt(tcpsock, SOL_SOCKET, SO_SNDBUF, (void *)&size, sizeof(size)) < 0) err(1, "setsockopt(SO_SNDBUF), %s:%d", __FILE__, __LINE__); hostent = gethostbyname ("localhost"); memcpy (&inetaddr.sin_addr.s_addr, hostent->h_addr, sizeof (struct in_addr)); inetaddr.sin_family = AF_INET; inetaddr.sin_port = htons(port); inetaddr.sin_len = sizeof(inetaddr); r = connect(tcpsock, (struct sockaddr *) &inetaddr, sizeof(inetaddr)); if (r == 0) break; sleep(1); close(tcpsock); } if (r < 0) err(1, "connect(), %s:%d", __FILE__, __LINE__); if ((fd = open(input, O_RDONLY)) == -1) err(1, "open(%s)", input); if (fstat(fd, &statb) != 0) err(1, "stat(%s)", input); share[SZ] = statb.st_size; if (sendfile(fd, tcpsock, 0, statb.st_size, NULL, &off, 0) == -1) err(1, "sendfile"); close(fd); close(tcpsock); return; } static void test(void) { pid_t pid; if ((pid = fork()) == 0) { writer(); _exit(0); } reader(); kill(pid, SIGINT); if (waitpid(pid, NULL, 0) != pid) err(1, "waitpid(%d)", pid); _exit(0); } int main(int argc, char *argv[]) { struct stat statin, statorig, statout; size_t len; time_t start; int e, i, pids[PARALLEL], status; char help[80], *template; if (argc != 5) { fprintf(stderr, "Usage: %s