4 # SPDX-License-Identifier: BSD-2-Clause-FreeBSD
6 # Copyright (c) 2018 Dell EMC Isilon
8 # Redistribution and use in source and binary forms, with or without
9 # modification, are permitted provided that the following conditions
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.
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
30 # Buildworld / quota test scenario.
32 # "panic: chkdquot: missing dquot" seen
33 # https://people.freebsd.org/~pho/stress/log/kostik1113.txt
34 # Fixed in r338798 + r338799
38 [ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1
40 [ "`sysctl -in kern.features.ufs_quota`" != "1" ] && exit 0
41 [ -d /usr/src/sys ] || exit 0
42 mount | grep -q "on $mntpoint " && umount $mntpoint
43 mdconfig -a -t swap -s 2g -u $mdstart
44 bsdlabel -w md$mdstart auto
45 newfs $newfs_flags md${mdstart}$part > /dev/null
47 export PATH_FSTAB=/tmp/fstab
48 trap "rm -f $PATH_FSTAB" EXIT INT
49 echo "/dev/md${mdstart}$part $mntpoint ufs rw,userquota 2 2" > $PATH_FSTAB
51 set `df -ik $mntpoint | tail -1 | awk '{print $4,$7}'`
54 edquota -u -f $mntpoint -e \
55 ${mntpoint}:$((QK - 50)):$QK:$((QI - 50 )):$QI $testuser
57 mount | grep $mntpoint
60 export MAKEOBJDIRPREFIX=$mntpoint/obj
61 export TMPDIR=$mntpoint/tmp
62 mkdir $TMPDIR $MAKEOBJDIRPREFIX
63 chmod 0777 $TMPDIR $MAKEOBJDIRPREFIX
65 p=$((`sysctl -n hw.ncpu`+ 1))
67 "make -i -j $p buildworld DESTDIR=$mntpoint TARGET=amd64 \
68 TARGET_ARCH=amd64 > /dev/null" &
71 while [ $((`date +%s` - start)) -lt 1200 ]; do
72 kill -0 $! > /dev/null 2>&1 || break
75 kill $! > /dev/null 2>&1
76 # Let make run 50% of the time so quotaoff runs on an active FS
77 [ `jot -r 1 0 1` -eq 1 ] &&
78 pkill -U$testuser make
81 while ! quotaoff $mntpoint; do
85 pgrep -q -U$testuser make && pkill -U$testuser make
86 export tmp=/tmp/$(basename $0).$$
87 quotacheck -v $mntpoint > $tmp 2>&1
88 grep -q failed $tmp && { cat $tmp; s=1; }
89 while mount | grep -q "on $mntpoint "; do
90 umount $mntpoint || sleep 1
92 checkfs /dev/md$mdstart || s=$?
93 mdconfig -d -u $mdstart