4 # SPDX-License-Identifier: BSD-2-Clause
6 # Copyright (c) 2023 Peter Holm <pho@FreeBSD.org>
8 # Redistribution and use in source and binary forms, with or without
9 # modification, are permitted provided that the following conditions
11 # 1. Redistributions of source code must retain the above copyright
12 # notice, this list of conditions and the following disclaimer.
13 # 2. Redistributions in binary form must reproduce the above copyright
14 # notice, this list of conditions and the following disclaimer in the
15 # documentation and/or other materials provided with the distribution.
17 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 # FFS+SU with snapshots and forced unmounts
32 # "panic: flush_pagedep_deps: failed to flush inodedep ..." seen
33 # https://people.freebsd.org/~pho/stress/log/log0427.txt
35 [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
37 prog=$(basename "$0" .sh)
38 diskimage=/tmp/diskimage
45 mount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint
46 mdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart
47 dd if=/dev/zero of=$diskimage bs=1m count=1k status=none
48 mdconfig -a -t vnode -f $diskimage -u $mdstart
51 newfs $flags md$mdstart > /dev/null 2>&1
54 while [ $((`date +%s` - start)) -lt $((5 * 60)) ]; do
55 mount /dev/md$mdstart $mntpoint
56 rm -fr $mntpoint/lost+found
58 jot 10 | xargs -I% mkdir -p $mntpoint/%
62 jot $n | xargs -P0 -I% touch $mntpoint/$j/%
63 jot $n | xargs -P0 -I% rm $mntpoint/$j/%
70 mkdir -p $mntpoint/.snap
72 rm -f $mntpoint/.snap/$i
73 mksnap_ffs $mntpoint $mntpoint/.snap/$i > /dev/null 2>&1 || break
75 [ $((`date +%s` - st)) -ge $t ] && break
78 while mdconfig -l | grep -q md$mdstart; do
79 mdconfig -d -u $mdstart -o force || sleep 1
84 while mount | grep -q "on $mntpoint "; do
85 umount $mntpoint || sleep 1
86 [ $((n += 1)) -gt 300 ] && { echo FAIL; exit 1; }
88 mdconfig -a -t vnode -f $diskimage -u $mdstart
92 echo "$i: fsck_ffs -fy /dev/md$mdstart"
93 fsck_ffs -fy /dev/md$mdstart > $log 2>&1; s=$?
94 grep 'INTERNAL ERROR: GOT TO reply' $log
95 grep -q CLEAN $log && grep -q MODIFIED && c=$((c+=1))
96 grep -Eq "WAS MODIFIED" $log || break
99 { echo "Note: FS marked clean+modified $c times out of $i fsck runs"; s=101; }
100 [ $s -ne 0 ] && break
101 grep -Eq "IS CLEAN|MARKED CLEAN" $log || { s=102; break; }
103 if [ $s -eq 0 ]; then
104 mount /dev/md$mdstart $mntpoint
105 cp -R /usr/include $mntpoint
106 dd if=/dev/zero of=$mntpoint/big bs=1m count=10 status=none
107 find $mntpoint/* -delete
110 mdconfig -d -u $mdstart
111 rm -f $diskimage $log