xref: /freebsd/tools/test/stress2/misc/force12.sh (revision 7c455ce26fbfa372378c13681daa2e3d209ac285)
1*7c455ce2SPeter Holm#!/bin/sh
2*7c455ce2SPeter Holm
3*7c455ce2SPeter Holm#
4*7c455ce2SPeter Holm# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
5*7c455ce2SPeter Holm#
6*7c455ce2SPeter Holm# Copyright (c) 2022 Peter Holm <pho@FreeBSD.org>
7*7c455ce2SPeter Holm#
8*7c455ce2SPeter Holm# Redistribution and use in source and binary forms, with or without
9*7c455ce2SPeter Holm# modification, are permitted provided that the following conditions
10*7c455ce2SPeter Holm# are met:
11*7c455ce2SPeter Holm# 1. Redistributions of source code must retain the above copyright
12*7c455ce2SPeter Holm#    notice, this list of conditions and the following disclaimer.
13*7c455ce2SPeter Holm# 2. Redistributions in binary form must reproduce the above copyright
14*7c455ce2SPeter Holm#    notice, this list of conditions and the following disclaimer in the
15*7c455ce2SPeter Holm#    documentation and/or other materials provided with the distribution.
16*7c455ce2SPeter Holm#
17*7c455ce2SPeter Holm# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18*7c455ce2SPeter Holm# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19*7c455ce2SPeter Holm# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20*7c455ce2SPeter Holm# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21*7c455ce2SPeter Holm# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22*7c455ce2SPeter Holm# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23*7c455ce2SPeter Holm# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24*7c455ce2SPeter Holm# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25*7c455ce2SPeter Holm# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26*7c455ce2SPeter Holm# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27*7c455ce2SPeter Holm# SUCH DAMAGE.
28*7c455ce2SPeter Holm#
29*7c455ce2SPeter Holm
30*7c455ce2SPeter Holm# rename() livelock seen with a forced unmount of a FS
31*7c455ce2SPeter Holm# https://people.freebsd.org/~pho/stress/log/log0375.txt
32*7c455ce2SPeter Holm
33*7c455ce2SPeter Holm[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
34*7c455ce2SPeter Holm. ../default.cfg
35*7c455ce2SPeter Holmecho "Known issue. Skipping ..."; exit 0
36*7c455ce2SPeter Holm
37*7c455ce2SPeter Holmset -u
38*7c455ce2SPeter Holmlog=/tmp/force12.sh.log
39*7c455ce2SPeter Holmmount | grep $mntpoint | grep -q /dev/md && umount -f $mntpoint
40*7c455ce2SPeter Holmmdconfig -l | grep -q md$mdstart && mdconfig -d -u $mdstart
41*7c455ce2SPeter Holmmdconfig -a -t swap -s 4g -u $mdstart
42*7c455ce2SPeter Holmflags=$newfs_flags
43*7c455ce2SPeter Holm[ `jot -r 1 0 1` -eq 1 ] && flags="-j"
44*7c455ce2SPeter Holmecho "newfs $flags md$mdstart"
45*7c455ce2SPeter Holmnewfs $flags md$mdstart > /dev/null 2>&1
46*7c455ce2SPeter Holm
47*7c455ce2SPeter Holmexport TESTPROGS='
48*7c455ce2SPeter Holmtestcases/dirnprename/dirnprename
49*7c455ce2SPeter Holmtestcases/dirrename/dirrename
50*7c455ce2SPeter Holmtestcases/fts/fts
51*7c455ce2SPeter Holmtestcases/mkdir/mkdir
52*7c455ce2SPeter Holmtestcases/rename/rename
53*7c455ce2SPeter Holmtestcases/rw/rw
54*7c455ce2SPeter Holmtestcases/swap/swap
55*7c455ce2SPeter Holm'
56*7c455ce2SPeter Holm
57*7c455ce2SPeter Holmexport runRUNTIME=3m
58*7c455ce2SPeter Holmexport RUNDIR=$mntpoint/stressX
59*7c455ce2SPeter Holmexport CTRLDIR=$mntpoint/stressX.control
60*7c455ce2SPeter Holm
61*7c455ce2SPeter Holmmount /dev/md$mdstart $mntpoint
62*7c455ce2SPeter Holmchmod 777 $mntpoint
63*7c455ce2SPeter Holmexport dirnprenameLOAD=100
64*7c455ce2SPeter Holmexport dirrenameLOAD=100
65*7c455ce2SPeter Holm
66*7c455ce2SPeter Holmsu $testuser -c 'cd ..; ./testcases/run/run $TESTPROGS' > \
67*7c455ce2SPeter Holm    /dev/null 2>&1 &
68*7c455ce2SPeter Holm
69*7c455ce2SPeter Holmsleep `jot -r 1 60 180`
70*7c455ce2SPeter Holmwhile mdconfig -l | grep -q md$mdstart; do
71*7c455ce2SPeter Holm	mdconfig -d -u $mdstart -o force || sleep 1
72*7c455ce2SPeter Holmdone
73*7c455ce2SPeter Holmsleep 1
74*7c455ce2SPeter Holm../tools/killall.sh
75*7c455ce2SPeter Holmwait
76*7c455ce2SPeter Holmn=0
77*7c455ce2SPeter Holmwhile mount | grep $mntpoint | grep -q /dev/md; do
78*7c455ce2SPeter Holm	umount $mntpoint || sleep 1
79*7c455ce2SPeter Holm	[ $((n += 1)) -gt 30 ] && { echo FAIL; exit 1; }
80*7c455ce2SPeter Holmdone
81*7c455ce2SPeter Holmmdconfig -d -u $mdstart > /dev/null 2>&1
82*7c455ce2SPeter Holmrm -f $log
83*7c455ce2SPeter Holmexit 0
84