Files
apfstests/common/dmerror
T
Darrick J. Wong 8522cbe656 common/dmerror: add some more dmerror routines
Add functions to the dmerror routine so that we can load both the
error table and the linear table.  This will help us with EIO testing
of copy-on-write.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2016-02-12 09:39:05 -08:00

89 lines
2.3 KiB
Plaintext

##/bin/bash
#
# Copyright (c) 2015 Oracle. All Rights Reserved.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it would be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
#
# common functions for setting up and tearing down a dmerror device
_dmerror_init()
{
local dm_backing_dev=$SCRATCH_DEV
$DMSETUP_PROG remove error-test > /dev/null 2>&1
local blk_dev_size=`blockdev --getsz $dm_backing_dev`
DMERROR_DEV='/dev/mapper/error-test'
DMLINEAR_TABLE="0 $blk_dev_size linear $dm_backing_dev 0"
$DMSETUP_PROG create error-test --table "$DMLINEAR_TABLE" || \
_fatal "failed to create dm linear device"
DMERROR_TABLE="0 $blk_dev_size error $dm_backing_dev 0"
}
_dmerror_mount_options()
{
echo `_common_dev_mount_options $*` $DMERROR_DEV $SCRATCH_MNT
}
_dmerror_mount()
{
_mount -t $FSTYP `_dmerror_mount_options $*`
}
_dmerror_unmount()
{
umount $SCRATCH_MNT
}
_dmerror_cleanup()
{
$UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1
$DMSETUP_PROG remove error-test > /dev/null 2>&1
}
_dmerror_load_error_table()
{
suspend_opt="--nolockfs"
[ $# -gt 1 ] && [ $2 -eq 1 ] && suspend_opt=""
$DMSETUP_PROG suspend $suspend_opt error-test
[ $? -ne 0 ] && _fail "dmsetup suspend failed"
$DMSETUP_PROG load error-test --table "$DMERROR_TABLE"
[ $? -ne 0 ] && _fail "dmsetup failed to load error table"
$DMSETUP_PROG resume error-test
[ $? -ne 0 ] && _fail "dmsetup resume failed"
}
_dmerror_load_working_table()
{
suspend_opt="--nolockfs"
[ $# -gt 1 ] && [ $2 -eq 1 ] && suspend_opt=""
$DMSETUP_PROG suspend $suspend_opt error-test
[ $? -ne 0 ] && _fail "dmsetup suspend failed"
$DMSETUP_PROG load error-test --table "$DMLINEAR_TABLE"
[ $? -ne 0 ] && _fail "dmsetup failed to load error table"
$DMSETUP_PROG resume error-test
[ $? -ne 0 ] && _fail "dmsetup resume failed"
}