xref: /freebsd/tools/test/stress2/misc/growfs2.sh (revision f126890ac5386406dadf7c4cfa9566cbb56537c5)
1#!/bin/sh
2
3#
4# SPDX-License-Identifier: BSD-2-Clause
5#
6# Copyright (c) 2023 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# growfs(8) test with output to FS to be grown.
31# A regression test for D37896 ufs/suspend: deny suspension if calling
32# process has file from mp opened for write
33# Before D37896 this would result in growfs(8) hanging.
34
35. ../default.cfg
36[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
37
38log=/tmp/growfs2.sh.log
39s=0
40set -eu
41mount | grep "on $mntpoint " | grep -q /dev/md && umount -f $mntpoint
42[ -c /dev/md$mdstart ] &&  mdconfig -d -u $mdstart
43mdconfig -a -t swap -s 32g -u $mdstart
44/sbin/gpart create -s GPT md$mdstart > /dev/null
45/sbin/gpart add -t freebsd-ufs -s 2g -a 4k md$mdstart > /dev/null
46set +e
47
48newfs $newfs_flags md${mdstart}p1 > /dev/null
49mount /dev/md${mdstart}p1 $mntpoint
50cp -r /usr/include $mntpoint/inc1
51
52gpart resize -i 1 -s 31g -a 4k md$mdstart
53echo "Expect: growfs: UFSSUSPEND: Resource deadlock avoided"
54growfs -y md${mdstart}p1 > $mntpoint/log && s=1 ||  s=0
55
56cp -r /usr/include $mntpoint/inc2
57umount $mntpoint
58fsck -fy /dev/md${mdstart}p1 > $log 2>&1
59grep -q "WAS MODIFIED" $log && s=2
60grep -q CLEAN $log || s=3
61[ $s -ne 0 ] && cat $log
62
63mdconfig -d -u $mdstart
64rm -f $log
65exit $s
66