1*ce7b20e5SPeter Holm#!/bin/sh 2*ce7b20e5SPeter Holm 3*ce7b20e5SPeter Holm# 4*ce7b20e5SPeter Holm# SPDX-License-Identifier: BSD-2-Clause 5*ce7b20e5SPeter Holm# 6*ce7b20e5SPeter Holm# Copyright (c) 2023 Peter Holm <pho@FreeBSD.org> 7*ce7b20e5SPeter Holm# 8*ce7b20e5SPeter Holm# Redistribution and use in source and binary forms, with or without 9*ce7b20e5SPeter Holm# modification, are permitted provided that the following conditions 10*ce7b20e5SPeter Holm# are met: 11*ce7b20e5SPeter Holm# 1. Redistributions of source code must retain the above copyright 12*ce7b20e5SPeter Holm# notice, this list of conditions and the following disclaimer. 13*ce7b20e5SPeter Holm# 2. Redistributions in binary form must reproduce the above copyright 14*ce7b20e5SPeter Holm# notice, this list of conditions and the following disclaimer in the 15*ce7b20e5SPeter Holm# documentation and/or other materials provided with the distribution. 16*ce7b20e5SPeter Holm# 17*ce7b20e5SPeter Holm# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18*ce7b20e5SPeter Holm# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19*ce7b20e5SPeter Holm# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20*ce7b20e5SPeter Holm# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21*ce7b20e5SPeter Holm# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22*ce7b20e5SPeter Holm# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23*ce7b20e5SPeter Holm# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24*ce7b20e5SPeter Holm# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25*ce7b20e5SPeter Holm# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26*ce7b20e5SPeter Holm# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27*ce7b20e5SPeter Holm# SUCH DAMAGE. 28*ce7b20e5SPeter Holm# 29*ce7b20e5SPeter Holm 30*ce7b20e5SPeter Holm# SU+J Snapshot test with a 50G file system 31*ce7b20e5SPeter Holm 32*ce7b20e5SPeter Holm# "panic: handle_jwork: Unknown type jnewblk" seen: 33*ce7b20e5SPeter Holm# https://people.freebsd.org/~pho/stress/log/log0422.txt 34*ce7b20e5SPeter Holm 35*ce7b20e5SPeter Holm# "panic: flush_pagedep_deps: failed to flush inodedep..." seen: 36*ce7b20e5SPeter Holm# https://people.freebsd.org/~pho/stress/log/log0423.txt 37*ce7b20e5SPeter Holm 38*ce7b20e5SPeter Holm# "panic: softdep_deallocate_dependencies: dangling deps" seen: 39*ce7b20e5SPeter Holm# https://people.freebsd.org/~pho/stress/log/log0424.txt 40*ce7b20e5SPeter Holm 41*ce7b20e5SPeter Holm[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 42*ce7b20e5SPeter Holm. ../default.cfg 43*ce7b20e5SPeter Holm 44*ce7b20e5SPeter Holmset -u 45*ce7b20e5SPeter Holmlog=/tmp/force14.sh.log 46*ce7b20e5SPeter Holmmount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint 47*ce7b20e5SPeter Holmmdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart 48*ce7b20e5SPeter Holmtruncate -s 50g $diskimage 49*ce7b20e5SPeter Holmmdconfig -a -t vnode -f $diskimage -u $mdstart 50*ce7b20e5SPeter Holmflags="-j" 51*ce7b20e5SPeter Holm 52*ce7b20e5SPeter Holmnewfs $flags md$mdstart > /dev/null 2>&1 53*ce7b20e5SPeter Holm 54*ce7b20e5SPeter Holm# Exclude rename for now due to log0374.txt 55*ce7b20e5SPeter Holmexport TESTPROGS=`cd ..; find testcases/ -perm -1 -type f | \ 56*ce7b20e5SPeter Holm egrep -Ev "/run/|/badcode/|/pty/|/shm/|/socket/|sysctl|tcp|thr|udp|rename"` 57*ce7b20e5SPeter Holmexport runRUNTIME=3m 58*ce7b20e5SPeter Holmexport RUNDIR=$mntpoint/stressX 59*ce7b20e5SPeter Holmexport CTRLDIR=$mntpoint/stressX.control 60*ce7b20e5SPeter Holmstart=`date +%s` 61*ce7b20e5SPeter Holmwhile [ $((`date +%s` - start)) -lt $((15 * 60)) ]; do 62*ce7b20e5SPeter Holm mount /dev/md$mdstart $mntpoint 63*ce7b20e5SPeter Holm rm -fr $mntpoint/lost+found 64*ce7b20e5SPeter Holm chmod 777 $mntpoint 65*ce7b20e5SPeter Holm 66*ce7b20e5SPeter Holm su $testuser -c 'cd ..; ./testcases/run/run $TESTPROGS' > \ 67*ce7b20e5SPeter Holm /dev/null 2>&1 & 68*ce7b20e5SPeter Holm 69*ce7b20e5SPeter Holm t=`jot -r 1 60 180` 70*ce7b20e5SPeter Holm st=`date +%s` 71*ce7b20e5SPeter Holm mkdir -p $mntpoint/.snap 72*ce7b20e5SPeter Holm for i in `jot 10`; do 73*ce7b20e5SPeter Holm rm -f $mntpoint/.snap/$i 74*ce7b20e5SPeter Holm mksnap_ffs $mntpoint $mntpoint/.snap/$i || 75*ce7b20e5SPeter Holm { ../tools/killall.sh; break; } 76*ce7b20e5SPeter Holm sleep `jot -r 1 1 5` 77*ce7b20e5SPeter Holm [ $((`date +%s` - st)) -ge $t ] && break 78*ce7b20e5SPeter Holm done & 79*ce7b20e5SPeter Holm sleep `jot -r 1 60 180` 80*ce7b20e5SPeter Holm while mdconfig -l | grep -q md$mdstart; do 81*ce7b20e5SPeter Holm mdconfig -d -u $mdstart -o force || sleep 1 82*ce7b20e5SPeter Holm done 83*ce7b20e5SPeter Holm sleep 1 84*ce7b20e5SPeter Holm ../tools/killall.sh 85*ce7b20e5SPeter Holm wait 86*ce7b20e5SPeter Holm n=0 87*ce7b20e5SPeter Holm while mount | grep -q "on $mntpoint "; do 88*ce7b20e5SPeter Holm umount $mntpoint || sleep 1 89*ce7b20e5SPeter Holm [ $((n += 1)) -gt 300 ] && { echo FAIL; exit 1; } 90*ce7b20e5SPeter Holm done 91*ce7b20e5SPeter Holm mdconfig -a -t vnode -f $diskimage -u $mdstart 92*ce7b20e5SPeter Holm c=0 93*ce7b20e5SPeter Holm # Process the journal 94*ce7b20e5SPeter Holm fsck_ffs -fy /dev/md$mdstart > $log 2>&1; s=$? 95*ce7b20e5SPeter Holm grep 'INTERNAL ERROR: GOT TO reply' $log 96*ce7b20e5SPeter Holm for i in `jot 4`; do 97*ce7b20e5SPeter Holm [ $i -ne 1 ] && 98*ce7b20e5SPeter Holm echo "fsck_ffs -fy /dev/md$mdstart" 99*ce7b20e5SPeter Holm fsck_ffs -fy /dev/md$mdstart > $log 2>&1; s=$? 100*ce7b20e5SPeter Holm grep 'INTERNAL ERROR: GOT TO reply' $log 101*ce7b20e5SPeter Holm grep -q CLEAN $log && c=$((c+=1)) 102*ce7b20e5SPeter Holm grep -Eq "WAS MODIFIED" $log || break 103*ce7b20e5SPeter Holm done 104*ce7b20e5SPeter Holm [ $c -gt 1 ] && 105*ce7b20e5SPeter Holm { echo "Note: FS marked clean+modified $c times out of $i fsck runs"; s=101; } 106*ce7b20e5SPeter Holm [ $s -ne 0 ] && break 107*ce7b20e5SPeter Holm grep -Eq "IS CLEAN|MARKED CLEAN" $log || { s=102; break; } 108*ce7b20e5SPeter Holmdone 109*ce7b20e5SPeter Holmif [ $s -eq 0 ]; then 110*ce7b20e5SPeter Holm mount /dev/md$mdstart $mntpoint 111*ce7b20e5SPeter Holm cp -R /usr/include $mntpoint 112*ce7b20e5SPeter Holm dd if=/dev/zero of=$mntpoint/big bs=1m count=10 status=none 113*ce7b20e5SPeter Holm find $mntpoint/* -delete 114*ce7b20e5SPeter Holm 115*ce7b20e5SPeter Holm umount $mntpoint 116*ce7b20e5SPeter Holm mdconfig -d -u $mdstart 117*ce7b20e5SPeter Holm rm -f $diskimage $log 118*ce7b20e5SPeter Holmfi 119*ce7b20e5SPeter Holmexit $s 120