Path: blob/main/tools/test/stress2/misc/backingstore2.sh
39536 views
#!/bin/sh12#3# Copyright (c) 2009 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# Test unmount of a device that is already gone2930# Leaves /mnt6 unmountable and leads to a "panic: 1 vncache entries remaining"31# during shut down.3233[ `id -u ` -ne 0 ] && echo "Must be root!" && exit 13435. ../default.cfg3637D=$diskimage38export here=`pwd`3940m1=$mdstart41m2=$((m1 + 1))42mount | grep "$mntpoint$m2" | grep -q md$m2 && umount $mntpoint$m243mdconfig -l | grep -q md$m2 && mdconfig -d -u $m244mount | grep "$mntpoint$m1" | grep -q md$m1 && umount $mntpoint$m145mdconfig -l | grep -q md$m1 && mdconfig -d -u $m146[ -d $mntpoint$m1 ] || mkdir -p $mntpoint$m147[ -d $mntpoint$m2 ] || mkdir -p $mntpoint$m24849dd if=/dev/zero of=$D$m bs=100m count=1 status=none || exit 15051mdconfig -a -t vnode -f $D$m1 -u $m15253newfs md$m1 > /dev/null 2>&154mount /dev/md$m1 $mntpoint$m15556truncate -s 500M $mntpoint$m1/diskimage57mdconfig -a -t vnode -f $mntpoint$m1/diskimage -u $m25859newfs md$m2 > /dev/null 2>&160mount /dev/md$m2 $mntpoint$m26162# Reversed umount sequence:63umount -f /dev/md$m164umount -f /dev/md$m26566mount | grep "$mntpoint" | grep -q md$m2 && umount $mntpoint$m267mdconfig -l | grep -q md$m2 && mdconfig -d -u $m268mount | grep "$mntpoint" | grep -q md$m1 && umount $mntpoint$m169mdconfig -l | grep -q md$m1 && mdconfig -d -u $m1707172