1#!/bin/sh 2 3# 4# SPDX-License-Identifier: BSD-2-Clause 5# 6# Copyright (c) 2018 Dell EMC Isilon 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# Buildworld / quota test scenario. 31 32# "panic: chkdquot: missing dquot" seen 33# https://people.freebsd.org/~pho/stress/log/kostik1113.txt 34# Fixed in r338798 + r338799 35 36. ../default.cfg 37 38[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 1 39 40[ "`sysctl -in kern.features.ufs_quota`" != "1" ] && exit 0 41[ -d /usr/src/sys ] || exit 0 42mount | grep -q "on $mntpoint " && umount $mntpoint 43mdconfig -a -t swap -s 2g -u $mdstart 44newfs $newfs_flags md$mdstart > /dev/null 45 46export PATH_FSTAB=/tmp/fstab 47trap "rm -f $PATH_FSTAB" EXIT INT 48echo "/dev/md$mdstart $mntpoint ufs rw,userquota 2 2" > $PATH_FSTAB 49mount $mntpoint 50set `df -ik $mntpoint | tail -1 | awk '{print $4,$7}'` 51export QK=$(($1 / 2)) 52export QI=$(($2 / 2)) 53edquota -u -f $mntpoint -e \ 54 ${mntpoint}:$((QK - 50)):$QK:$((QI - 50 )):$QI $testuser 55quotaon $mntpoint 56mount | grep $mntpoint 57 58cd /usr/src 59export MAKEOBJDIRPREFIX=$mntpoint/obj 60export TMPDIR=$mntpoint/tmp 61mkdir $TMPDIR $MAKEOBJDIRPREFIX 62chmod 0777 $TMPDIR $MAKEOBJDIRPREFIX 63 64p=$((`sysctl -n hw.ncpu`+ 1)) 65[ $p -gt 32 ] && p=32 # Arbitrary cap 66su $testuser -c \ 67 "make -i -j $p buildworld DESTDIR=$mntpoint TARGET=amd64 \ 68 TARGET_ARCH=amd64 > /dev/null" & 69sleep 2 70start=`date +%s` 71while [ $((`date +%s` - start)) -lt 1200 ]; do 72 kill -0 $! > /dev/null 2>&1 || break 73 sleep 2 74done 75kill $! > /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 79wait 80 81while ! quotaoff $mntpoint; do 82 sync 83 sleep 5 84done 85pgrep -q -U$testuser make && pkill -U$testuser make 86export tmp=/tmp/$(basename $0).$$ 87quotacheck -v $mntpoint > $tmp 2>&1 88grep -q failed $tmp && { cat $tmp; s=1; } 89while mount | grep -q "on $mntpoint "; do 90 umount $mntpoint || sleep 1 91done 92checkfs /dev/md$mdstart || s=$? 93mdconfig -d -u $mdstart 94rm -f $PATH_FSTAB 95exit $s 96