xref: /freebsd/tools/test/stress2/misc/nfs9.sh (revision e32fecd0c2c3ee37c47ee100f169e7eb0282a873)
1#!/bin/sh
2
3#
4# Copyright (c) 2008-2013 Peter Holm <pho@FreeBSD.org>
5# All rights reserved.
6#
7# Redistribution and use in source and binary forms, with or without
8# modification, are permitted provided that the following conditions
9# are met:
10# 1. Redistributions of source code must retain the above copyright
11#    notice, this list of conditions and the following disclaimer.
12# 2. Redistributions in binary form must reproduce the above copyright
13#    notice, this list of conditions and the following disclaimer in the
14#    documentation and/or other materials provided with the distribution.
15#
16# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26# SUCH DAMAGE.
27#
28
29# Copy of nfs4.sh, where it was discovered that a missing killall.sh script
30# turned up quite a few new panics. For example:
31
32# vfs_mount_destroy: nonzero writeopcount
33# Lock nfs not locked @ kern/vfs_default.c:462
34# Assertion x == LK_SHARERS_LOCK(1) failed at kern/kern_lock.c:236
35
36# "panic: SACK scoreboard must not be empty" seen:
37# https://people.freebsd.org/~pho/stress/log/nfs9-2.txt
38
39# Hang seen:
40# $ ps -lp52442
41# UID   PID  PPID CPU PRI NI   VSZ  RSS MWCHAN STAT TT     TIME COMMAND
42#   0 52442 52120   0  20  0 11336 2868 nfsreq S     0  0:01.48 rm -rf /mnt/nfs9.dktfkpuf/stressX
43
44[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
45
46. ../default.cfg
47
48[ -z "$nfs_export" ] && exit 0
49ping -c 2 `echo $nfs_export | sed 's/:.*//'` > /dev/null 2>&1 ||
50    exit 0
51
52[ ! -d $mntpoint ] &&  mkdir $mntpoint
53export RUNDIR=$mntpoint/nfs9.`jot -rc 8 a z | tr -d '\n'`/stressX
54USE_TIMEOUT=1
55s=0
56start=`date +%s`
57for i in `jot 10`; do
58	mount | grep "on $mntpoint " | grep -q nfs && umount $mntpoint
59	mount -t nfs -o tcp -o retrycnt=3 -o intr -o soft \
60		-o rw $nfs_export $mntpoint
61	sleep .5
62
63	rm -rf $RUNDIR 2> /dev/null
64	mkdir -p $RUNDIR || exit 1
65	chmod -R 777 $RUNDIR 2> /dev/null
66	export runRUNTIME=3m
67	rm -rf /tmp/stressX.control/*
68
69	if [ $i -eq 10 -o $((`date +%s` - start)) -ge 600 ]; then
70		../tools/killall.sh
71		su $testuser -c "rm -rf $RUNDIR" 2> /dev/null
72		rm -rf `dirname $RUNDIR` || s=1
73		done=1
74	else
75		su $testuser -c '(cd ..; ./run.sh all.cfg) > /dev/null \
76		    2>&1' &
77		sleep 60
78	fi
79
80	while mount | grep -q $mntpoint; do
81		umount -f $mntpoint > /dev/null 2>&1
82	done
83	../tools/killall.sh || break
84	kill -9 $! 2>/dev/null
85	wait
86	[ $done ] && break
87done
88exit $s
89