diff --git a/tools/test/stress2/misc/creat.sh b/tools/test/stress2/misc/creat.sh index 45f6b0f87301..1abab774ed7f 100755 --- a/tools/test/stress2/misc/creat.sh +++ b/tools/test/stress2/misc/creat.sh @@ -1,83 +1,84 @@ #!/bin/sh # # SPDX-License-Identifier: BSD-2-Clause # # Copyright (c) 2023 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. # # Demonstrate incorrect "out of inodes" message with SU enabled. # No issue seen with SU+J [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg set -eu prog=$(basename "$0" .sh) log=/tmp/$prog.log s=0 mount | grep -q "on $mntpoint " && umount $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 100m -u $mdstart [ $# -eq 1 ] && flags="$@" || flags="-Un" echo "newfs $flags /dev/md$mdstart" newfs $flags /dev/md$mdstart > /dev/null +[ "$flags" = "" ] && tunefs -n disable md$mdstart mount /dev/md$mdstart $mntpoint set +e ifree1=`df -i $mntpoint | tail -1 | awk '{print $7}'` before=`df -i $mntpoint` n=$(((ifree1 - 5) / 10)) jot 10 | xargs -I% mkdir $mntpoint/% start=`date +%s` while [ $((`date +%s` - start)) -lt 60 ]; do for j in `jot 10`; do ( jot $n | xargs -P0 -I% touch $mntpoint/$j/% jot $n | xargs -P0 -I% rm $mntpoint/$j/% ) & done wait done 2>&1 | tee $log | head -5 [ -s $log ] && s=3 jot 10 | xargs -I% rmdir $mntpoint/% umount $mntpoint; mount /dev/md$mdstart $mntpoint ifree2=`df -i $mntpoint | tail -1 | awk '{print $7}'` after=`df -i $mntpoint | tail -1` if [ $ifree1 -ne $ifree2 ]; then echo "$before" echo "$after" s=1 ls -alsrt $mntpoint | head -20 fi umount $mntpoint fsck -fy /dev/md$mdstart > $log 2>&1 grep -Eq "WAS MODIFIED" $log && { s=2; cat $log; } mdconfig -d -u $mdstart rm -f $log exit $s diff --git a/tools/test/stress2/misc/fsck10.sh b/tools/test/stress2/misc/fsck10.sh index 30479e0dfebb..33ad35f65f11 100755 --- a/tools/test/stress2/misc/fsck10.sh +++ b/tools/test/stress2/misc/fsck10.sh @@ -1,171 +1,172 @@ #!/bin/sh # # SPDX-License-Identifier: BSD-2-Clause # # Copyright (c) 2023 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 fsck9.sh with smaller disk size and newfs options '', 'U' and 'O1' # fsck_ffs core dump seen . ../default.cfg [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 cc -o /tmp/flip -Wall -Wextra -O2 ../tools/flip.c || exit 1 set -e prog=$(basename "$0" .sh) u1=$mdstart u2=$((mdstart + 1)) mp1=${mntpoint}$u1 mp2=${mntpoint}$u2 mkdir -p $mp1 $mp2 log=$mp1/$prog.sh.log diskimage=$mp1/$prog.sh.diskimage backup=/tmp/$prog.sh.diskimage.`date +%Y%m%dT%H%M%S`.gz cleans=0 reruns=0 # Pick a random newfs flag newfs_flags=$(echo "" "-U" "-O1" | awk -v N=`jot -r 1 1 3` '{print $N}') [ $# -eq 1 ] && newfs_flags="$1" # or use script argument max=$((512 * 1024)) mount | grep "on $mp1 " | grep -q /dev/md && umount -f $mp1 [ -c /dev/md$u1 ] && mdconfig -d -u $u1 mdconfig -a -t swap -s 1g -u $u1 newfs $newfs_flags -n /dev/md$u1 > /dev/null mount /dev/md$u1 $mp1 [ -c /dev/md$u2 ] && mdconfig -d -u $u2 dd if=/dev/zero of=$diskimage bs=$max count=1 status=none mdconfig -a -t vnode -f $diskimage -u $u2 backups=`newfs -N $newfs_flags md$u2 | grep -A1 "super-block backups" | \ tail -1 | sed 's/,//g'` echo "newfs $newfs_flags -n md$u2" newfs $newfs_flags -n md$u2 > /dev/null +[ "$newfs_flags" = "" ] && tunefs -n disable md$u2 set +e chk() { local i clean=0 rerun=0 fsck_ffs -fy $1 > $log 2>&1 r=$? if grep -qiE "super-?block.*failed" $log; then for b in $backups; do echo "fsck_ffs -b $b -fy $1" fsck_ffs -b $b -fy $1 > $log 2>&1 r=$? grep -qiE "super-?block.*failed" $log || break echo "Checking next SB" done usedasb=1 else usedasb=0 fi LANG=C egrep -q "[A-Z][A-Z]" $log && clean=0 grep -Eq "IS CLEAN|MARKED CLEAN" $log && clean=1 grep -q RERUN $log && rerun=1 [ $r -ne 0 -a $clean -eq 1 ] && echo "Exit code $r w/ clean == 1" } cd $mp1 clean=0 errors=0 s=0 start=`date +%s` while [ $((`date +%s` - start)) -lt 300 ]; do mount /dev/md$u2 $mp2 || break if ! ls -lR $mp2 > /dev/null; then s=102 echo "ls failed"; grep "core dumped" /var/log/messages | tail -1 break fi rm -f $mp2/???????? touch $mp2/`jot -rc 8 a z | tr -d '\n'` mkdir -p $mp2/dir/dir/dir/dir echo "abc" > $mp2/dir/dir/dir/dir/f while mount | grep -q "on $mp2 "; do umount $mp2; done echo * | grep -q core && break mdconfig -d -u $u2 # Introduce 5 random single bit errors to the file system image /tmp/flip -n 5 $diskimage sync; sleep .1 if [ `stat -f%z $diskimage` -gt $max ]; then ls -lh $diskimage truncate -s $max $diskimage else gzip < $diskimage > $backup fi fsync $backup sync; sleep .1 for i in `jot 5`; do [ $i -gt 2 ] && echo "fsck run #$i" chk $diskimage [ $rerun -eq 1 ] && { reruns=$((reruns + 1)); continue; } [ $clean -eq 1 ] && { cleans=$((cleans + 1)); break; } if [ -f fsck_ffs.core ]; then tstamp=`date +%Y%m%dT%H%M%S` gzip < $backup > /tmp/fsck_ffs.core.diskimage.$tstamp gzip < fsck_ffs.core > /tmp/fsck_ffs.core.$tstamp break 2 fi done if [ $clean -eq 1 ]; then fsck_ffs -fy $diskimage > $log 2>&1 if grep -q MODIFIED $log; then echo "*** fsck of \"clean\" FS found more issues:" cat $log errors=$((errors + 1)) s=1 break fi fi [ $clean -ne 1 ] && break mdconfig -a -t vnode -f $diskimage -u $u2 done for i in `jot 5`; do mount | grep -q "on $mp2 " || break umount $mp2 && break sleep 2 done mdconfig -l | grep -q $u2 && mdconfig -d -u $u2 [ $s -eq 0 ] && rm -f $backup || echo "Preserved $backup due to status code $s" cd /tmp for i in `jot 5`; do umount $mp1 && break sleep 2 done mdconfig -d -u $u1 rm -f /tmp/flip exit $s diff --git a/tools/test/stress2/misc/fsck11.sh b/tools/test/stress2/misc/fsck11.sh index 8019cc1f2656..de4cf2536dad 100755 --- a/tools/test/stress2/misc/fsck11.sh +++ b/tools/test/stress2/misc/fsck11.sh @@ -1,170 +1,171 @@ #!/bin/sh # # SPDX-License-Identifier: BSD-2-Clause # # Copyright (c) 2023 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. # # Demonstrate how the "CLEAN" message and the exit code can be misleading # "panic: softdep_update_inodeblock inconsistent ip ..." seen: # https://people.freebsd.org/~pho/stress/log/log0421.txt # https://people.freebsd.org/~pho/fsck11.sh.diskimage.20230228T064402.gz . ../default.cfg [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 cc -o /tmp/flip -Wall -Wextra -O2 ../tools/flip.c || exit 1 set -e prog=$(basename "$0" .sh) u1=$mdstart u2=$((mdstart + 1)) mp1=${mntpoint}$u1 mp2=${mntpoint}$u2 mkdir -p $mp1 $mp2 log=$mp1/$prog.sh.log diskimage=$mp1/$prog.sh.diskimage backup=/tmp/$prog.sh.diskimage.`date +%Y%m%dT%H%M%S`.gz cleans=0 reruns=0 # Pick a random newfs flag newfs_flags=$(echo "" "-U" "-O1" | awk -v N=`jot -r 1 1 3` '{print $N}') [ $# -eq 1 ] && newfs_flags="$1" # or use script argument max=$((2 * 1024 * 1024)) [ "$newfs_flags" = "-j" ] && max=$((20 * 1024 * 1024)) # Make room for the journal file mount | grep "on $mp1 " | grep -q /dev/md && umount -f $mp1 [ -c /dev/md$u1 ] && mdconfig -d -u $u1 mdconfig -a -t swap -s 1g -u $u1 newfs $newfs_flags -n /dev/md$u1 > /dev/null mount /dev/md$u1 $mp1 [ -c /dev/md$u2 ] && mdconfig -d -u $u2 dd if=/dev/zero of=$diskimage bs=$max count=1 status=none mdconfig -a -t vnode -f $diskimage -u $u2 backups=`newfs -N $newfs_flags md$u2 | grep -A1 "super-block backups" | \ tail -1 | sed 's/,//g'` echo "newfs $newfs_flags -n md$u2" newfs $newfs_flags -n md$u2 > /dev/null +[ "$newfs_flags" = "" ] && tunefs -n disable md$u2 set +e chk() { local i clean=0 rerun=0 fsck_ffs -fy $1 > $log 2>&1 r=$? if grep -qiE "super-?block.*failed" $log; then for b in $backups; do echo "fsck_ffs -b $b -fy $1" fsck_ffs -b $b -fy $1 > $log 2>&1 r=$? grep -qiE "super-?block.*failed" $log || break echo "Checking next SB" done usedasb=1 else usedasb=0 fi LANG=C egrep -q "[A-Z][A-Z]" $log && clean=0 grep -Eq "IS CLEAN|MARKED CLEAN" $log && clean=1 grep -q RERUN $log && rerun=1 [ $r -ne 0 -a $clean -eq 1 ] && echo "Exit code $r w/ clean == 1" } cd $mp1 clean=0 errors=0 s=0 start=`date +%s` while [ $((`date +%s` - start)) -lt 300 ]; do mount /dev/md$u2 $mp2 || break if ! ls -lR $mp2 > /dev/null; then s=102 echo "ls failed"; grep "core dumped" /var/log/messages | tail -1 break fi find $mp2 -type f | xargs cat > /dev/null for j in `jot 9`; do rm -rf $mp2/$j mkdir $mp2/$j jot 10 | xargs -P0 -I% cp /etc/group $mp2/$j/% done 2>/dev/null while mount | grep -q "on $mp2 "; do umount $mp2; done echo * | grep -q core && break mdconfig -d -u $u2 # Introduce 5 random single bit errors to the file system image /tmp/flip -n 5 $diskimage if [ `stat -f%z $diskimage` -gt $max ]; then ls -lh $diskimage truncate -s $max $diskimage else gzip < $diskimage > $backup fi fsync $backup sync; sleep 1 [ "$newfs_flags" = "-j" ] && fsck -fy $diskimage > $log 2>&1 # process the journal file for i in `jot 5`; do [ $i -gt 2 ] && echo "fsck run #$i" chk $diskimage [ $rerun -eq 1 ] && { reruns=$((reruns + 1)); continue; } [ $clean -eq 1 ] && { cleans=$((cleans + 1)); break; } if [ -f fsck_ffs.core ]; then tstamp=`date +%Y%m%dT%H%M%S` gzip < $backup > /tmp/fsck_ffs.core.diskimage.$tstamp gzip < fsck_ffs.core > /tmp/fsck_ffs.core.$tstamp break 2 fi done [ $clean -ne 1 ] && { s=99; break; } # broken image? mdconfig -a -t vnode -f $diskimage -u $u2 done for i in `jot 5`; do mount | grep -q "on $mp2 " || break umount $mp2 && break sleep 2 done mdconfig -l | grep -q $u2 && mdconfig -d -u $u2 [ $s -eq 0 ] && rm -f $backup || echo "Preserved $backup due to status code $s" cd /tmp for i in `jot 5`; do umount $mp1 && break sleep 2 done mdconfig -d -u $u1 rm -f /tmp/flip exit $s diff --git a/tools/test/stress2/misc/fsck13.sh b/tools/test/stress2/misc/fsck13.sh index f279e0bae066..3b8dc64d12b9 100755 --- a/tools/test/stress2/misc/fsck13.sh +++ b/tools/test/stress2/misc/fsck13.sh @@ -1,152 +1,153 @@ #!/bin/sh # # SPDX-License-Identifier: BSD-2-Clause # # Copyright (c) 2023 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. # # fsck_ffs(8) disk image fuzz test. # Test without mount(8) and umount(8) . ../default.cfg [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 cc -o /tmp/flip -Wall -Wextra -O2 ../tools/flip.c || exit 1 # Disable the calls to sync(2) in fsck_ffs(8) to speed up the test echo 'int sync(void) { return (0); }' > /tmp/fsck_preload.c mycc -o /tmp/fsck_preload.so -shared -fpic /tmp/fsck_preload.c || exit 1 rm /tmp/fsck_preload.c set -eu u1=$mdstart u2=$((mdstart + 1)) mp1=${mntpoint}$u1 prog=$(basename "$0" .sh) mkdir -p $mp1 max=$((2 * 1024 * 1024)) # Two alternate super blocks @ 192 and 2240 i=`jot -r 1 1 3` [ $i -eq 1 ] && flags="-O2" [ $i -eq 2 ] && flags="-U" [ $i -eq 3 ] && { flags="-j"; max=$((8 * 1024 * 1024)); } backup=$mp1/$prog.diskimage.$flags.`date +%Y%m%dT%H%M%S` core=/tmp/$prog.core.`date +%Y%m%dT%H%M%S` diskimage=$mp1/$prog.diskimage log=$mp1/$prog.log asbs=0 cleans=0 reruns=0 waccess=0 set +e mount | grep "on $mp1 " | grep -q /dev/md && umount -f $mp1 [ -c /dev/md$u1 ] && mdconfig -d -u $u1 mdconfig -a -t swap -s 10g -u $u1 newfs $newfs_flags /dev/md$u1 > /dev/null mount /dev/md$u1 $mp1 [ -c /dev/md$u2 ] && mdconfig -d -u $u2 dd if=/dev/zero of=$diskimage bs=$max count=1 status=none mdconfig -a -t vnode -f $diskimage -u $u2 backups=`newfs -N $flags md$u2 | grep -A1 "super-block backups" | \ tail -1 | sed 's/,//g'` echo "newfs $flags /dev/md$u2" newfs $flags md$u2 > /dev/null +[ "$newfs_flags" = "" ] && tunefs -n disable md$u2 mdconfig -d -u $u2 chk() { local i clean=0 rerun=0 waccess=0 LD_PRELOAD=/tmp/fsck_preload.so \ timeout 2m fsck_ffs -fy $1 > $log 2>&1 r=$? if grep -qiE "super-?block.*failed" $log; then for b in $backups; do asbs=$((asbs + 1)) LD_PRELOAD=/tmp/fsck_preload.so \ timeout 2m fsck_ffs -b $b -fy $1 > $log 2>&1 r=$? grep -qiE "super-?block.*failed" $log || break done usedasb=1 else usedasb=0 fi LANG=C egrep -q "[A-Z][A-Z]" $log && clean=0 grep -Eq "IS CLEAN|MARKED CLEAN" $log && clean=1 # For now regard a "was modified" as a cause for a rerun, # disregarding "clean" claim. grep -Eq "WAS MODIFIED" $log && rerun=1 grep -q RERUN $log && rerun=1 grep -q "NO WRITE ACCESS" $log && waccess=1 [ $r -ne 0 -a $clean -eq 1 ] && echo "Exit code $r w/ clean == 1" } cd $mp1 s=0 start=`date +%s` while [ $((`date +%s` - start)) -lt 60 ]; do /tmp/flip -n 50 $diskimage cp $diskimage $backup for i in `jot 10`; do chk $diskimage [ $i -eq 1 -a "$flags" = "-j" ] && continue # First run processes the journal [ $rerun -eq 1 ] && { reruns=$((reruns + 1)); continue; } [ $clean -eq 1 ] && { cleans=$((cleans + 1)); break; } [ -f fsck_ffs.core ] && { s=1; break 2; } [ $r -eq 124 ] && { s=2; break 2; } # timeout done [ $clean -ne 1 ] && break [ $r -ne 0 -a $clean -eq 1 ] && { echo "CLEAN && non zero exit code"; break; } [ $clean -eq 1 ] && continue [ $usedasb -eq 1 ] && { echo "Alt. SB failed"; s=104; } [ $waccess -eq 1 ] && { echo "No write access"; s=105; } break done echo "$cleans cleans, $reruns reruns, $asbs alternate SBs." if [ $clean -ne 1 ]; then echo "FS still not clean. Last fsck_ffs exit code was $r." [ $s -eq 0 ] && s=106 fi grep -q "Superblock check-hash failed" $log && s=0 # Ignore for now grep -q "is not a file system superblock" $log && s=0 # Ignore for now [ $s -ne 0 ] && { gzip $backup; cp -v $backup.gz /tmp; } cd /tmp umount $mp1 mdconfig -d -u $u1 rm -f /tmp/flip /tmp/fsck_preload.so exit $s diff --git a/tools/test/stress2/misc/mkdir.sh b/tools/test/stress2/misc/mkdir.sh index 39cc828f0303..734b8994ad4e 100755 --- a/tools/test/stress2/misc/mkdir.sh +++ b/tools/test/stress2/misc/mkdir.sh @@ -1,80 +1,81 @@ #!/bin/sh # # SPDX-License-Identifier: BSD-2-Clause # # Copyright (c) 2023 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. # # Demonstrate incorrect "out of inodes" message with SU enabled. # No issue seen with SU+J [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg set -eu prog=$(basename "$0" .sh) log=/tmp/$prog.log s=0 mount | grep -q "on $mntpoint " && umount $mntpoint mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart mdconfig -a -t swap -s 100m -u $mdstart [ $# -eq 1 ] && flags="$@" || flags="-Un" echo "newfs $flags /dev/md$mdstart" newfs $flags /dev/md$mdstart > /dev/null +[ "$flags" = "" ] && tunefs -n disable md$mdstart mount /dev/md$mdstart $mntpoint set +e ifree1=`df -i $mntpoint | tail -1 | awk '{print $7}'` before=`df -i $mntpoint` n=$(((ifree1 - 5) / 10)) jot 10 | xargs -I% mkdir $mntpoint/% start=`date +%s` while [ $((`date +%s` - start)) -lt 180 ]; do for j in `jot 10`; do jot $n | xargs -P0 -I% mkdir $mntpoint/$j/% jot $n | xargs -P0 -I% rmdir $mntpoint/$j/% done done 2>&1 | tee $log | head -5 [ -s $log ] && s=3 jot 10 | xargs -I% rmdir $mntpoint/% umount $mntpoint; mount /dev/md$mdstart $mntpoint ifree2=`df -i $mntpoint | tail -1 | awk '{print $7}'` after=`df -i $mntpoint | tail -1` if [ $ifree1 -ne $ifree2 ]; then echo "$before" echo "$after" s=1 ls -alsrt $mntpoint | head -20 fi umount $mntpoint fsck -fy /dev/md$mdstart > $log 2>&1 grep -Eq "WAS MODIFIED" $log && { s=2; cat $log; } mdconfig -d -u $mdstart rm -f $log exit $s diff --git a/tools/test/stress2/misc/nullfs18.sh b/tools/test/stress2/misc/nullfs18.sh index b4414cbc3e3e..3936ea64c6a3 100755 --- a/tools/test/stress2/misc/nullfs18.sh +++ b/tools/test/stress2/misc/nullfs18.sh @@ -1,132 +1,133 @@ #!/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(4) 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 newfs -n md$mdstart > /dev/null +tunefs -n disable md$mdstart 2>/dev/null 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/perf.sh b/tools/test/stress2/misc/perf.sh index 58f5bd67b756..de6c20028c59 100755 --- a/tools/test/stress2/misc/perf.sh +++ b/tools/test/stress2/misc/perf.sh @@ -1,151 +1,152 @@ #!/bin/sh # # SPDX-License-Identifier: BSD-2-Clause # # 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. # # O_CREAT / unlink() timing test with different FFS options. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 [ `uname -m` = "i386" ] && exit 0 # very long runtime . ../default.cfg [ $# -eq 0 ] && half=1 # SU and SUJ workaround first=1 export LANG=en_US.ISO8859-1 odir=`pwd` dir=$mntpoint cd /tmp sed '1,/^EOF/d' < $odir/$0 > perf.c mycc -o perf -Wall -Wextra perf.c || exit 1 rm -f perf.c cd $odir mount | grep -q "on $mntpoint " && umount $mntpoint mdconfig -l | grep md$mdstart > /dev/null && mdconfig -d -u $mdstart mdconfig -a -t swap -s 2g -u $mdstart tst() { local i j k s s=0 cd $dir inodes=`df -ik $mntpoint | tail -1 | \ awk '{printf "%d\n", $7}'` # SU and SUJ tests fail with ENOSPC [ $half ] && i=$((inodes / 4)) || i=$(((inodes - 500) / 2)) [ $first -eq 1 ] && printf "Using %'\''d inodes out of a total of %'\''d.\n" \ $((i * 2)) $inodes first=0 for k in `jot 3`; do pids="" for j in `jot 2`; do /tmp/perf $i & pids="$pids $!" done for pid in $pids; do wait $pid; r=$? [ $r -ne 0 ] && s=$r done done cd $odir return $s } s=0 for i in "" "-U" "-j"; do newfs $i /dev/md$mdstart > /dev/null 2>&1 + [ "$i" = "" ] && tunefs -n disable md$mdstart mount /dev/md$mdstart $mntpoint t1=`date +%s` tst; r=$? t2=$((`date +%s` - t1)) umount -f $mntpoint t2=$((`date +%s` - t1)) [ $t2 -eq 0 ] && t2=1 [ -z "$base" ] && base=$t2 pct=$(((t2 - base) * 100 / base)) printf '%3d seconds elapsed for newfs option "%2s" (%+4d%%)\n' \ $t2 "$i" $pct [ $pct -gt 10 ] && s=111 [ $s -eq 0 -a $r -ne 0 ] && s=$r done rm -f /tmp/perf mdconfig -d -u $mdstart exit $s EOF #include #include #include #include #include #include #include #include int main(int argc __unused, char **argv) { pid_t pid; int64_t size; int e, fd, i, j; char file[128]; size = atol(argv[1]); e = 0; pid = getpid(); for (j = 0; j < size; j++) { sprintf(file,"p%05d.%05d", pid, j); if ((fd = open(file, O_RDWR | O_CREAT | O_TRUNC, DEFFILEMODE)) == -1) { e = errno; if (errno != EINTR) { warn("open(%s)", file); printf("break out at %d, errno %d\n", j, errno); break; } } close(fd); } for (i = --j; i >= 0; i--) { sprintf(file,"p%05d.%05d", pid, i); if (unlink(file) == -1) err(3, "unlink(%s)", file); } return (e); } diff --git a/tools/test/stress2/misc/softupdate.sh b/tools/test/stress2/misc/softupdate.sh index ecf7c5d04e9c..37f819579f83 100755 --- a/tools/test/stress2/misc/softupdate.sh +++ b/tools/test/stress2/misc/softupdate.sh @@ -1,58 +1,59 @@ #!/bin/sh # # Copyright (c) 2008 Peter Holm # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # Like the symlink.sh test, this test shows the problem with Soft Update and # incorrect statfs(2). [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg RUNTIME=2m runRUNTIME=2m RUNDIR=$mntpoint/stressX D=$diskimage dd if=/dev/zero of=$D bs=1m count=512 status=none || exit 1 mount | grep "$mntpoint" | grep md$mdstart > /dev/null && umount $mntpoint mdconfig -l | grep md$mdstart > /dev/null && mdconfig -d -u $mdstart mdconfig -a -t vnode -f $D -u $mdstart for mode in "" "-U"; do printf "newfs -O2 $mode /dev/md${mdstart}\n\n" newfs -O2 $mode /dev/md$mdstart > /dev/null 2>&1 + [ "$mode" = "" ] && tunefs -n disable md$mdstart mount /dev/md$mdstart $mntpoint for i in `jot 5`; do (cd ..;./run.sh disk.cfg) done umount -f $mntpoint done mdconfig -d -u $mdstart diff --git a/tools/test/stress2/misc/symlink.sh b/tools/test/stress2/misc/symlink.sh index 47257aa92a24..1d30636d6b25 100755 --- a/tools/test/stress2/misc/symlink.sh +++ b/tools/test/stress2/misc/symlink.sh @@ -1,128 +1,129 @@ #!/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. # # Testing problem with premature disk full problem with symlinks. # Not seen as of 20210117. [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg dbt=`sysctl -n vfs.dirtybufthresh` [ $dbt -lt 1000 ] && echo "Note: vfs.dirtybufthresh = $dbt" D=$diskimage dd if=/dev/zero of=$D bs=1m count=128 status=none || exit 1 odir=`pwd` dir=$mntpoint cd /tmp sed '1,/^EOF/d' < $odir/$0 > symlink.c mycc -o symlink -Wall -Wextra symlink.c || exit 1 rm -f symlink.c cd $odir mount | grep -q "on $mntpoint " && umount $mntpoint mdconfig -l | grep md$mdstart > /dev/null && mdconfig -d -u $mdstart mdconfig -a -t vnode -f $D -u $mdstart tst() { local i j k cd $dir i=`df -ik $mntpoint | tail -1 | awk '{printf "%d\n", ($7 - 500)/2}'` [ $i -gt 20000 ] && i=20000 for k in `jot 3`; do for j in `jot 2`; do /tmp/symlink $i & done wait done cd $odir } s=0 for i in "" "-U" "-j"; do newfs $i /dev/md$mdstart > /dev/null 2>&1 + [ "$i" = "" ] && tunefs -n disable md$mdstart mount /dev/md$mdstart $mntpoint t1=`date +%s` tst; s=$? t2=$((`date +%s` - t1)) umount -f $mntpoint t2=$((`date +%s` - t1)) echo "$t2 seconds elapsed for newfs option \"$i\"" [ $t2 -gt 1000 ] && s=111 done rm -f /tmp/symlink $D mdconfig -d -u $mdstart exit $s EOF #include #include #include #include #include #include #include int main(int argc __unused, char **argv) { pid_t pid; int64_t size; int i, j; char file[128]; size = atol(argv[1]); pid = getpid(); for (j = 0; j < size; j++) { sprintf(file,"p%05d.%05d", pid, j); if (symlink("/mnt/not/there", file) == -1) { if (errno != EINTR) { warn("symlink(%s)", file); printf("break out at %d, errno %d\n", j, errno); break; } } } for (i = --j; i >= 0; i--) { sprintf(file,"p%05d.%05d", pid, i); if (unlink(file) == -1) err(3, "unlink(%s)", file); } return (0); } diff --git a/tools/test/stress2/misc/symlink2.sh b/tools/test/stress2/misc/symlink2.sh index f13065badb4a..210702defe4a 100755 --- a/tools/test/stress2/misc/symlink2.sh +++ b/tools/test/stress2/misc/symlink2.sh @@ -1,121 +1,122 @@ #!/bin/sh # # Copyright (c) 2008 Peter Holm # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # Testing problem with buffer cache inconsistency [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg D=$diskimage dd if=/dev/zero of=$D bs=1m count=10 status=none || exit 1 odir=`pwd` dir=$mntpoint cd /tmp sed '1,/^EOF/d' < $odir/$0 > symlink2.c mycc -o symlink2 -Wall symlink2.c rm -f symlink2.c cd $odir mount | grep "$mntpoint" | grep md$mdstart > /dev/null && umount $mntpoint mdconfig -l | grep md$mdstart > /dev/null && mdconfig -d -u $mdstart mdconfig -a -t vnode -f $D -u $mdstart for i in "" "-U"; do [ "$i" = "-U" -a "$newfs_flags" != "-U" ] && continue echo "newfs $i /dev/md$mdstart" newfs $i /dev/md$mdstart > /dev/null 2>&1 + [ "$i" = "" ] && tunefs -n disable md$mdstart mount /dev/md$mdstart $mntpoint mkdir $mntpoint/dir /tmp/symlink2 $mntpoint/dir/link ls -l $mntpoint/dir > /dev/null 2>&1 if [ $? -ne 0 ]; then set -x ls -l $mntpoint/dir umount $mntpoint mount /dev/md$mdstart $mntpoint ls -l $mntpoint/dir set +x fi umount -f $mntpoint done rm -f /tmp/symlink2 $D mdconfig -d -u $mdstart exit EOF #include #include #include #include #include #include #include static char *path; int main(int argc, char **argv) { int i, n; pid_t p; char buf[128]; path = argv[1]; for (i = 0; i < 100; i++) { if ((p = fork()) == 0) { if ((n = readlink(path, buf, sizeof(buf) -1)) < 0) { for (i = 0; i < 60; i++) { sleep(1); if ((n = readlink(path, buf, sizeof(buf) -1)) > 0) { break; } } } if (n < 0) err(1, "readlink(%s). %s:%d", path, __FILE__, __LINE__); exit(0); } } (void) unlink(path); sleep(2); if (symlink("1234", path) < 0) err(1, "symlink(%s, %s)", path, "1234"); for (i = 0; i < 100; i++) { if (wait(&n) == -1) err(1, "wait(), %s:%d", __FILE__, __LINE__); } return (0); } diff --git a/tools/test/stress2/misc/symlink5.sh b/tools/test/stress2/misc/symlink5.sh index 55f71e209791..9332f906a3e0 100755 --- a/tools/test/stress2/misc/symlink5.sh +++ b/tools/test/stress2/misc/symlink5.sh @@ -1,137 +1,138 @@ #!/bin/sh # # SPDX-License-Identifier: BSD-2-Clause # # 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 symlink.sh using a larger swap backed FS. # "panic: refcount 0xfffff8093d7ed268 wraparound" seen in WiP kernel code. # https://people.freebsd.org/~pho/stress/log/log0024.txt [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 . ../default.cfg dbt=`sysctl -n vfs.dirtybufthresh` [ $dbt -lt 1000 ] && echo "Note: vfs.dirtybufthresh = $dbt" D=$diskimage odir=`pwd` dir=$mntpoint cd /tmp sed '1,/^EOF/d' < $odir/$0 > symlink.c mycc -o symlink -Wall -Wextra symlink.c || exit 1 rm -f symlink.c cd $odir mount | grep -q "on $mntpoint " && umount $mntpoint mdconfig -l | grep md$mdstart > /dev/null && mdconfig -d -u $mdstart mdconfig -a -t swap -s 1g -u $mdstart tst() { local i j k cd $dir df -ik $mntpoint i=`df -ik $mntpoint | tail -1 | awk '{printf "%d\n", ($7 - 500)/2}'` [ $i -gt 20000 ] && i=20000 for k in `jot 3`; do for j in `jot 2`; do /tmp/symlink $i & done for j in `jot 2`; do wait done done df -ik $mntpoint | tail -1 cd $odir } s=0 for i in "" "-U"; do t1=`date +%s` echo "newfs $i /dev/md$mdstart" newfs $i /dev/md$mdstart > /dev/null 2>&1 + [ "$i" = "" ] && tunefs -n disable md$mdstart mount /dev/md$mdstart $mntpoint tst; s=$? umount -f $mntpoint t2=$((`date +%s` - t1)) echo "$t2 seconds elapsed for newfs option \"$i\"" [ $t2 -gt 1000 ] && s=111 done rm -f /tmp/symlink mdconfig -d -u $mdstart exit $s EOF #include #include #include #include #include #include #include #include #include #include int main(int argc __unused, char **argv) { pid_t pid; int64_t size; int i, j; char file[128]; size = atol(argv[1]); pid = getpid(); for (j = 0; j < size; j++) { sprintf(file,"p%05d.%05d", pid, j); if (symlink("/mnt/not/there", file) == -1) { if (errno != EINTR) { warn("symlink(%s)", file); printf("break out at %d, errno %d\n", j, errno); break; } } } for (i = --j; i >= 0; i--) { sprintf(file,"p%05d.%05d", pid, i); if (unlink(file) == -1) err(3, "unlink(%s)", file); } return (0); }