Path: blob/main/tools/test/stress2/misc/altbufferflushes.sh
39537 views
#!/bin/sh12#3# Copyright (c) 2008 Peter Holm <[email protected]>4# All rights reserved.5#6# Redistribution and use in source and binary forms, with or without7# modification, are permitted provided that the following conditions8# are met:9# 1. Redistributions of source code must retain the above copyright10# notice, this list of conditions and the following disclaimer.11# 2. Redistributions in binary form must reproduce the above copyright12# notice, this list of conditions and the following disclaimer in the13# documentation and/or other materials provided with the distribution.14#15# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND16# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE17# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE18# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE19# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL20# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS21# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)22# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT23# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY24# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF25# SUCH DAMAGE.26#2728# Regression test. This script caused this panic:2930# panic: lockmgr: locking against myself31# cpuid = 232# KDB: enter: panic33# [thread pid 2526 tid 100070 ]34# Stopped at kdb_enter+0x2b: nop35# db> bt36# Tracing pid 2526 tid 100070 td 0xc46f836037# kdb_enter(c094247f) at kdb_enter+0x2b38# panic(c09402b6,c46f8360,0,12,c06af5d9,...) at panic+0x14b39# _lockmgr(d864a748,202122,c479f788,c46f8360,c094b01c,12d) at _lockmgr+0x41a40# getblk(c479f6b8,5d51940,0,4000,0,...) at getblk+0x13c41# breadn(c479f6b8,5d51940,0,4000,0,...) at breadn+0x2f42# bread(c479f6b8,5d51940,0,4000,0,e6d13544,c4743eac,0,c095a185,56d) at bread+0x2043# ffs_alloccg(c47408c4,104,1754628,0,4000,c4743eac,1,c095a185,4d8) at ffs_alloccg+0x11d44# ffs_hashalloc(c47408c4,104,1754628,0,4000,...) at ffs_hashalloc+0x4545# ffs_alloc(c47408c4,3f2cd,0,1754628,0,4000,c42fd400,e6d13674) at ffs_alloc+0x1a546# ffs_balloc_ufs2(c4735d70,fcb34000,0,4000,c42fd400,...) at ffs_balloc_ufs2+0x161947# ffs_copyonwrite(c479f6b8,d84e3d08) at ffs_copyonwrite+0x3d348# ffs_geom_strategy(c479f7c0,d84e3d08) at ffs_geom_strategy+0xbd49# bufwrite(d84e3d08,4000,d84e3d08,e6d137e4,c070b7a9,...) at bufwrite+0x17a50# ffs_bufwrite(d84e3d08) at ffs_bufwrite+0x28251# vfs_bio_awrite(d84e3d08) at vfs_bio_awrite+0x23552# bdwrite(d864a6e8,c4743eac,0,c095a185,57c,...) at bdwrite+0x23753# ffs_alloccg(c4b54a50,104,1754628,0,4000,c4743eac,1,c095a185,4d8) at ffs_alloccg+0x1f654# ffs_hashalloc(c4b54a50,104,1754628,0,4000,...) at ffs_hashalloc+0x4555# ffs_alloc(c4b54a50,1b00c,0,1754628,0,4000,c4b22a80,e6d139ac) at ffs_alloc+0x1a556# ffs_balloc_ufs2(c4e72158,6c030000,0,4000,c4b22a80,...) at ffs_balloc_ufs2+0x161957# ffs_write(e6d13b98) at ffs_write+0x2ac58# VOP_WRITE_APV(c0a00e80,e6d13b98) at VOP_WRITE_APV+0x13259# vn_write(c46c65a0,e6d13c60,c4b22a80,0,c46f8360) at vn_write+0x1f660# dofilewrite(c46f8360,4,c46c65a0,e6d13c60,ffffffff,...) at dofilewrite+0x7761# kern_writev(c46f8360,4,e6d13c60,8430000,d0000,...) at kern_writev+0x3662# write(c46f8360,e6d13d00) at write+0x4563# syscall(e6d13d38) at syscall+0x2566465[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 16667persist () {68false69while [ $? -ne 0 ]; do70$1 > /dev/null 2>&171sleep 172done73}7475diskfree=`df -k /var/tmp | tail -1 | awk '{print $4}'`76[ $((diskfree / 1024 / 1024)) -lt 5 ] && echo "Not enough disk space" && exit 17778rm -f /var/.snap/stress2 /var/tmp/big.?79trap "rm -f /var/.snap/stress2 /var/tmp/big.?" EXIT INT80persist 'mksnap_ffs /var /var/.snap/stress2'81tresh=`sysctl vfs.dirtybufthresh | awk '{print $NF}'`82sysctl vfs.dirtybufthresh=108384cd /var/tmp85for j in `jot 5`; do86old=`sysctl vfs.altbufferflushes | awk '{print $NF}'`87for i in `jot 4`; do88echo "`date '+%T'` Create big.$i"89dd if=/dev/zero of=big.$i bs=1m count=4k status=none90done91sleep 192rm -rf /var/tmp/big.?93new=`sysctl vfs.altbufferflushes | awk '{print $NF}'`94[ $new -ne $old ] && echo "vfs.altbufferflushes changed from $old to $new."95done96sysctl vfs.dirtybufthresh=$tresh97rm -f /var/.snap/stress29899100