xref: /freebsd/tools/test/stress2/misc/growfs2.sh (revision 17edacfb6e7cf7b5bf7678968038955d29293aef)
1*17edacfbSPeter Holm#!/bin/sh
2*17edacfbSPeter Holm
3*17edacfbSPeter Holm#
4*17edacfbSPeter Holm# SPDX-License-Identifier: BSD-2-Clause
5*17edacfbSPeter Holm#
6*17edacfbSPeter Holm# Copyright (c) 2023 Peter Holm <pho@FreeBSD.org>
7*17edacfbSPeter Holm#
8*17edacfbSPeter Holm# Redistribution and use in source and binary forms, with or without
9*17edacfbSPeter Holm# modification, are permitted provided that the following conditions
10*17edacfbSPeter Holm# are met:
11*17edacfbSPeter Holm# 1. Redistributions of source code must retain the above copyright
12*17edacfbSPeter Holm#    notice, this list of conditions and the following disclaimer.
13*17edacfbSPeter Holm# 2. Redistributions in binary form must reproduce the above copyright
14*17edacfbSPeter Holm#    notice, this list of conditions and the following disclaimer in the
15*17edacfbSPeter Holm#    documentation and/or other materials provided with the distribution.
16*17edacfbSPeter Holm#
17*17edacfbSPeter Holm# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18*17edacfbSPeter Holm# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19*17edacfbSPeter Holm# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20*17edacfbSPeter Holm# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21*17edacfbSPeter Holm# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22*17edacfbSPeter Holm# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23*17edacfbSPeter Holm# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24*17edacfbSPeter Holm# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25*17edacfbSPeter Holm# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26*17edacfbSPeter Holm# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27*17edacfbSPeter Holm# SUCH DAMAGE.
28*17edacfbSPeter Holm#
29*17edacfbSPeter Holm
30*17edacfbSPeter Holm# growfs(8) test with output to FS to be grown.
31*17edacfbSPeter Holm# A regression test for D37896 ufs/suspend: deny suspension if calling
32*17edacfbSPeter Holm# process has file from mp opened for write
33*17edacfbSPeter Holm# Before D37896 this would result in growfs(8) hanging.
34*17edacfbSPeter Holm
35*17edacfbSPeter Holm. ../default.cfg
36*17edacfbSPeter Holm[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
37*17edacfbSPeter Holm
38*17edacfbSPeter Holmlog=/tmp/growfs2.sh.log
39*17edacfbSPeter Holms=0
40*17edacfbSPeter Holmset -eu
41*17edacfbSPeter Holmmount | grep "on $mntpoint " | grep -q /dev/md && umount -f $mntpoint
42*17edacfbSPeter Holm[ -c /dev/md$mdstart ] &&  mdconfig -d -u $mdstart
43*17edacfbSPeter Holmmdconfig -a -t swap -s 32g -u $mdstart
44*17edacfbSPeter Holm/sbin/gpart create -s GPT md$mdstart > /dev/null
45*17edacfbSPeter Holm/sbin/gpart add -t freebsd-ufs -s 2g -a 4k md$mdstart > /dev/null
46*17edacfbSPeter Holmset +e
47*17edacfbSPeter Holm
48*17edacfbSPeter Holmnewfs $newfs_flags md${mdstart}p1 > /dev/null
49*17edacfbSPeter Holmmount /dev/md${mdstart}p1 $mntpoint
50*17edacfbSPeter Holmcp -r /usr/include $mntpoint/inc1
51*17edacfbSPeter Holm
52*17edacfbSPeter Holmgpart resize -i 1 -s 31g -a 4k md$mdstart
53*17edacfbSPeter Holmecho "Expect: growfs: UFSSUSPEND: Resource deadlock avoided"
54*17edacfbSPeter Holmgrowfs -y md${mdstart}p1 > $mntpoint/log && s=1 ||  s=0
55*17edacfbSPeter Holm
56*17edacfbSPeter Holmcp -r /usr/include $mntpoint/inc2
57*17edacfbSPeter Holmumount $mntpoint
58*17edacfbSPeter Holmfsck -fy /dev/md${mdstart}p1 > $log 2>&1
59*17edacfbSPeter Holmgrep -q "WAS MODIFIED" $log && s=2
60*17edacfbSPeter Holmgrep -q CLEAN $log || s=3
61*17edacfbSPeter Holm[ $s -ne 0 ] && cat $log
62*17edacfbSPeter Holm
63*17edacfbSPeter Holmmdconfig -d -u $mdstart
64*17edacfbSPeter Holmrm -f $log
65*17edacfbSPeter Holmexit $s
66