Files
apfstests/common/dmerror
T
Jeff Moyer fc7b390389 dax/dm: disable testing on devices that don't support dax
Move the check for dax from the individual target scripts into
_require_dm_target.  This fixes up a couple of missed tests that are
failing due to the lack of dax support (such as tests requiring
dm-snapshot).

Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2020-03-06 15:55:39 +08:00

98 lines
2.0 KiB
Plaintext

##/bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2015 Oracle. All Rights Reserved.
#
# common functions for setting up and tearing down a dmerror device
_dmerror_setup()
{
local dm_backing_dev=$SCRATCH_DEV
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"
DMERROR_TABLE="0 $blk_dev_size error $dm_backing_dev 0"
}
_dmerror_init()
{
_dmerror_setup
_dmsetup_remove error-test
_dmsetup_create error-test --table "$DMLINEAR_TABLE" || \
_fatal "failed to create dm linear device"
}
_dmerror_mount()
{
_scratch_options mount
$MOUNT_PROG -t $FSTYP `_common_dev_mount_options $*` $SCRATCH_OPTIONS \
$DMERROR_DEV $SCRATCH_MNT
}
_dmerror_unmount()
{
umount $SCRATCH_MNT
}
_dmerror_cleanup()
{
$DMSETUP_PROG resume error-test > /dev/null 2>&1
$UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1
_dmsetup_remove error-test
}
_dmerror_load_error_table()
{
local load_res=0
local resume_res=0
suspend_opt="--nolockfs"
if [ "$1" = "lockfs" ]; then
suspend_opt=""
elif [ -n "$*" ]; then
suspend_opt="$*"
fi
$DMSETUP_PROG suspend $suspend_opt error-test
[ $? -ne 0 ] && _fail "dmsetup suspend failed"
$DMSETUP_PROG load error-test --table "$DMERROR_TABLE"
load_res=$?
$DMSETUP_PROG resume error-test
resume_res=$?
[ $load_res -ne 0 ] && _fail "dmsetup failed to load error table"
[ $resume_res -ne 0 ] && _fail "dmsetup resume failed"
}
_dmerror_load_working_table()
{
local load_res=0
local resume_res=0
suspend_opt="--nolockfs"
if [ "$1" = "lockfs" ]; then
suspend_opt=""
elif [ -n "$*" ]; then
suspend_opt="$*"
fi
$DMSETUP_PROG suspend $suspend_opt error-test
[ $? -ne 0 ] && _fail "dmsetup suspend failed"
$DMSETUP_PROG load error-test --table "$DMLINEAR_TABLE"
load_res=$?
$DMSETUP_PROG resume error-test
resume_res=$?
[ $load_res -ne 0 ] && _fail "dmsetup failed to load error table"
[ $resume_res -ne 0 ] && _fail "dmsetup resume failed"
}