xref: /freebsd/tools/test/stress2/misc/zfs14.sh (revision ba3c1f5972d7b90feb6e6da47905ff2757e0fe57)
1#!/bin/sh
2
3#
4# SPDX-License-Identifier: BSD-2-Clause
5#
6# Copyright (c) 2021 Peter Holm <pho@FreeBSD.org>
7#
8# Redistribution and use in source and binary forms, with or without
9# modification, are permitted provided that the following conditions
10# are met:
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.
16#
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
27# SUCH DAMAGE.
28#
29
30# "userret: returning with the following locks held:" seen:
31# https://people.freebsd.org/~pho/stress/log/log0188.txt
32
33# Test scenario suggestion by: markj@
34
35[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
36kldstat -v | grep -q zfs.ko  || { kldload zfs.ko; loaded=1; } ||
37    exit 0
38
39. ../default.cfg
40
41here=`pwd`
42mp1=/stress2_tank/test
43u1=$mdstart
44u2=$((u1 + 1))
45
46set -e
47mdconfig -l | grep -q md$u1 && mdconfig -d -u $u1
48mdconfig -l | grep -q md$u2 && mdconfig -d -u $u2
49
50mdconfig -s 2g -u $u1
51mdconfig -s 2g -u $u2
52
53zpool list | egrep -q "^stress2_tank" && zpool destroy stress2_tank
54[ -d /stress2_tank ] && rm -rf /stress2_tank
55zpool create stress2_tank md$u1 md$u2
56zfs create stress2_tank/test
57set +e
58
59export RUNDIR=/stress2_tank/test/stressX
60export runRUNTIME=5m
61export LOAD=70
62export TESTPROGS=`cd ..; find testcases/ -perm -1 -type f | \
63    egrep -Ev "/run/|/tcp/|/udp/"`
64
65(cd ..; ./testcases/run/run $TESTPROGS > /dev/null 2>&1) &
66
67sleep 5
68zfs snapshot stress2_tank/test@1
69
70start=`date +%s`
71while [ $((`date +%s` - start)) -lt 300 ]; do
72	if [ `jot -r 1 1 2` -eq 1 ]; then
73		zfs umount -f stress2_tank/test &&
74		   zfs mount stress2_tank/test
75	else
76		zfs rollback stress2_tank/test@1
77	fi
78	sleep 5
79	zfs list | grep -q /stress2_tank/test || break
80done
81wait
82
83zfs umount stress2_tank/test
84zfs destroy -r stress2_tank
85zpool destroy stress2_tank
86
87mdconfig -d -u $u1
88mdconfig -d -u $u2
89[ -n "$loaded" ] && kldunload zfs.ko
90exit 0
91