xref: /freebsd/tools/test/stress2/misc/unionfs19.sh (revision e9ac41698b2f322d55ccf9da50a3596edb2c1800)
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# umount FS with memory mapped file
10# "panic: general protection fault" seen:
11# https://people.freebsd.org/~pho/stress/log/log0519.txt
12
13[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
14
15. ../default.cfg
16
17prog=$(basename "$0" .sh)
18here=`pwd`
19log=/tmp/$prog.log
20md1=$mdstart
21md2=$((md1 + 1))
22mp1=/mnt$md1
23mp2=/mnt$md2
24
25set -e
26mdconfig -l | grep -q md$md && mdconfig -d -u $md1
27mdconfig -l | grep -q md$u2 && mdconfig -d -u $md2
28
29mdconfig -s 2g -u $md1
30newfs $newfs_flags /dev/md$md1 > /dev/null
31mdconfig -s 2g -u $md2
32newfs $newfs_flags /dev/md$md2 > /dev/null
33
34mkdir -p $mp1 $mp2
35mount /dev/md$md1 $mp1
36mount /dev/md$md2 $mp2
37mount -t unionfs -o noatime $mp1 $mp2
38mount | grep -E "$mp1|$mp2"
39set +e
40
41export RUNDIR=$mp2/stressX
42export runRUNTIME=2m
43export LOAD=70
44export mmapLOAD=100
45export TESTPROGS="testcases/mmap/mmap testcases/swap/swap"
46
47(cd ..; ./testcases/run/run $TESTPROGS > /dev/null 2>&1) & rpid=$!
48sleep 5
49
50tail -F -n 0 /var/log/messages > $log & lpid=$!
51
52start=`date +%s`
53while [ $((`date +%s` - start)) -lt 120 ]; do
54	umount -f $mp2 &&
55	    mount -t unionfs -o noatime $mp1 $mp2
56	sleep 5
57	mount | grep -q unionfs || break
58	pgrep -q mmap || break
59done
60pkill run swap mmap
61while pgrep -q swap; do pkill swap; done
62wait $rpid
63
64umount $mp2 # The unionfs mount
65umount $mp2
66umount $mp1
67
68mdconfig -d -u $md1
69mdconfig -d -u $md2
70
71kill $lpid && wait $lpid
72grep -m 1 "pager read error" $log && s=1 || s=0
73rm $log
74exit $s
75