xref: /freebsd/tools/test/stress2/misc/zfs11.sh (revision 43a5ec4eb41567cc92586503212743d89686d78f)
1#!/bin/sh
2
3#
4# SPDX-License-Identifier: BSD-2-Clause-FreeBSD
5#
6# Copyright (c) 2020 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# zfs deadlock on r360452 relating to busy vm page
31#  0  5804  5803   0  52  0 13048  2740 prev->lr DC+   0     0:00.00 tail -F blah
32#  0  5805  5802   0  52  0 12976  2636 pgnslp   DC+   0     0:00.00 dd if=/dev/zero of=blah
33
34# Test scenario by Bryan Drewery <bdrewery@FreeBSD.org>
35
36[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
37[ `uname -m` = "i386" ] && exit 0
38[ `sysctl -n kern.kstack_pages` -lt 4 ] && exit 0
39
40. ../default.cfg
41
42kldstat -v | grep -q zfs.ko  || { kldload zfs.ko ||
43    exit 0; loaded=1; }
44
45u1=$mdstart
46u2=$((u1 + 1))
47
48set -e
49mdconfig -l | grep -q md$u1 && mdconfig -d -u $u1
50mdconfig -l | grep -q md$u2 && mdconfig -d -u $u2
51
52mdconfig -s 2g -u $u1
53mdconfig -s 2g -u $u2
54
55zpool list | egrep -q "^stress2_tank" && zpool destroy stress2_tank
56[ -d /stress2_tank ] && rm -rf /stress2_tank
57zpool create stress2_tank raidz md$u1 md$u2
58zfs create stress2_tank/test
59set +e
60
61cd /stress2_tank/test
62timeout 10s sh -c '\
63	dd if=/dev/zero of=blah status=none & tail -F blah > /dev/null' &
64sleep 5
65ps -l | grep -v grep | grep -q pgnslp && { s=1; echo FAIL; }
66ps -l | grep -v grep | grep blah
67wait
68cd /
69
70zfs umount stress2_tank/test
71zfs destroy -r stress2_tank
72zpool destroy stress2_tank
73
74mdconfig -d -u $u1
75mdconfig -d -u $u2
76[ $loaded ] && kldunload zfs.ko
77exit $s
78