xref: /freebsd/tools/test/stress2/misc/zfs19.sh (revision 6463b6b59152fb1695bbe0de78f6e2675c5a765a)
1#!/bin/sh
2
3#
4# Copyright (c) 2024 Peter Holm <pho@FreeBSD.org>
5#
6# SPDX-License-Identifier: BSD-2-Clause
7#
8
9# Hunt for "vm_fault: pager read error, pid 99058 (mmap)"
10
11[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
12kldstat -v | grep -q zfs.ko  || { kldload zfs.ko; loaded=1; } ||
13    exit 0
14
15. ../default.cfg
16
17prog=$(basename "$0" .sh)
18here=`pwd`
19log=/tmp/$prog.log
20mp1=/stress2_tank/test
21u1=$mdstart
22u2=$((u1 + 1))
23
24set -e
25mdconfig -l | grep -q md$u1 && mdconfig -d -u $u1
26mdconfig -l | grep -q md$u2 && mdconfig -d -u $u2
27
28mdconfig -s 2g -u $u1
29mdconfig -s 2g -u $u2
30
31zpool list | egrep -q "^stress2_tank" && zpool destroy stress2_tank
32[ -d /stress2_tank ] && rm -rf /stress2_tank
33zpool create stress2_tank md$u1 md$u2
34zfs create stress2_tank/test
35set +e
36
37export RUNDIR=/stress2_tank/test/stressX
38export runRUNTIME=2m
39export LOAD=70
40export mmapLOAD=100
41export TESTPROGS="testcases/mmap/mmap testcases/swap/swap"
42
43(cd ..; ./testcases/run/run $TESTPROGS > /dev/null 2>&1) & rpid=$!
44sleep 5
45
46tail -F -n 0 /var/log/messages > $log & lpid=$!
47
48start=`date +%s`
49while [ $((`date +%s` - start)) -lt 120 ]; do
50	zfs umount -f stress2_tank/test &&
51	    zfs mount stress2_tank/test
52	sleep 5
53	zfs list | grep -q /stress2_tank/test || break
54	pgrep -q mmap || break
55done
56pkill run swap mmap
57while pgrep -q swap; do pkill swap; done
58wait $rpid
59
60zfs umount stress2_tank/test
61zfs destroy -r stress2_tank
62zpool destroy stress2_tank
63
64mdconfig -d -u $u1
65mdconfig -d -u $u2
66[ -n "$loaded" ] && kldunload zfs.ko
67
68kill $lpid && wait $lpid
69grep -m 1 "pager read error" $log && s=1 || s=0
70rm $log
71s=0	# This is an expected behavior for zfs
72exit $s
73