DELAY_DEV=/dev/mapper/delay-test
DELAY_TABLE="0 $BLK_DEV_SIZE delay $SCRATCH_DEV 0 0"
DELAY_TABLE_RDELAY="0 $BLK_DEV_SIZE delay $SCRATCH_DEV 0 10000 $SCRATCH_DEV 0 0"
- $DMSETUP_PROG create delay-test --table "$DELAY_TABLE" || \
+ _dmsetup_create delay-test --table "$DELAY_TABLE" || \
_fatal "failed to create delay device"
- $DMSETUP_PROG mknodes > /dev/null 2>&1
}
_mount_delay()
# otherwise the umount will hang
$DMSETUP_PROG resume delay-test > /dev/null 2>&1
$UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1
- # wait for device to be fully settled so that 'dmsetup remove' doesn't
- # fail due to EBUSY
- $UDEV_SETTLE_PROG >/dev/null 2>&1
- $DMSETUP_PROG remove delay-test > /dev/null 2>&1
- $DMSETUP_PROG mknodes > /dev/null 2>&1
+ _dmsetup_remove delay-test
}
# _load_delay_table <table> [lockfs]
_dmerror_init()
{
_dmerror_setup
- $DMSETUP_PROG remove error-test > /dev/null 2>&1
- $DMSETUP_PROG create error-test --table "$DMLINEAR_TABLE" || \
+ _dmsetup_remove error-test
+ _dmsetup_create error-test --table "$DMLINEAR_TABLE" || \
_fatal "failed to create dm linear device"
}
_dmerror_cleanup()
{
$UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1
- # wait for device to be fully settled so that 'dmsetup remove' doesn't
- # fail due to EBUSY
- $UDEV_SETTLE_PROG >/dev/null 2>&1
- $DMSETUP_PROG remove error-test > /dev/null 2>&1
+ _dmsetup_remove error-test
}
_dmerror_load_error_table()
FLAKEY_TABLE="0 $BLK_DEV_SIZE flakey $SCRATCH_DEV 0 180 0"
FLAKEY_TABLE_DROP="0 $BLK_DEV_SIZE flakey $SCRATCH_DEV 0 0 180 1 drop_writes"
FLAKEY_TABLE_ERROR="0 $BLK_DEV_SIZE flakey $SCRATCH_DEV 0 0 180 1 error_writes"
- $DMSETUP_PROG create flakey-test --table "$FLAKEY_TABLE" || \
+ _dmsetup_create flakey-test --table "$FLAKEY_TABLE" || \
_fatal "failed to create flakey device"
- $DMSETUP_PROG mknodes > /dev/null 2>&1
}
_mount_flakey()
# otherwise the umount will hang
$DMSETUP_PROG resume flakey-test > /dev/null 2>&1
$UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1
- # wait for device to be fully settled so that 'dmsetup remove' doesn't
- # fail due to EBUSY
- $UDEV_SETTLE_PROG >/dev/null 2>&1
- $DMSETUP_PROG remove flakey-test > /dev/null 2>&1
- $DMSETUP_PROG mknodes > /dev/null 2>&1
+ _dmsetup_remove flakey-test
}
# _load_flakey_table <table> [lockfs]
SIZE=`blockdev --getsz $SCRATCH_DEV`
TABLE="0 $SIZE flakey $SCRATCH_DEV 0 0 180 1 error_writes"
- $DMSETUP_PROG create $NAME --table "$TABLE" >/dev/null 2>&1
- if [ $? -ne 0 ]; then
+ _dmsetup_create $NAME --table "$TABLE" || \
_notrun "This test requires error_writes feature in dm-flakey"
- fi
- $DMSETUP_PROG mknodes >/dev/null 2>&1
_cleanup_flakey
}
chunk_size=512
fi
- $DMSETUP_PROG remove huge-test > /dev/null 2>&1
- $DMSETUP_PROG remove huge-test-zero > /dev/null 2>&1
+ _dmsetup_remove huge-test
+ _dmsetup_remove huge-test-zero
local blk_dev_size=$1
DMHUGEDISK_ZERO_TABLE="0 $blk_dev_size zero"
DMHUGEDISK_DEV_TABLE="0 $blk_dev_size snapshot $DMHUGEDISK_ZERO $SCRATCH_DEV N $chunk_size"
- $DMSETUP_PROG create huge-test-zero --table "$DMHUGEDISK_ZERO_TABLE" || \
+ _dmsetup_create huge-test-zero --table "$DMHUGEDISK_ZERO_TABLE" || \
_fatal "failed to create dm huge zero device"
- $DMSETUP_PROG create huge-test --table "$DMHUGEDISK_DEV_TABLE" || \
+ _dmsetup_create huge-test --table "$DMHUGEDISK_DEV_TABLE" || \
_fatal "failed to create dm huge device"
}
_dmhugedisk_cleanup()
{
$UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1
- # wait for device to be fully settled so that 'dmsetup remove' doesn't
- # fail due to EBUSY
- $UDEV_SETTLE_PROG >/dev/null 2>&1
- $DMSETUP_PROG remove huge-test > /dev/null 2>&1
- $DMSETUP_PROG remove huge-test-zero > /dev/null 2>&1
+ _dmsetup_remove huge-test
+ _dmsetup_remove huge-test-zero
}
LOGWRITES_NAME=logwrites-test
LOGWRITES_DMDEV=/dev/mapper/$LOGWRITES_NAME
LOGWRITES_TABLE="0 $BLK_DEV_SIZE log-writes $SCRATCH_DEV $LOGWRITES_DEV"
- $DMSETUP_PROG create $LOGWRITES_NAME --table "$LOGWRITES_TABLE" || \
+ _dmsetup_create $LOGWRITES_NAME --table "$LOGWRITES_TABLE" || \
_fail "failed to create log-writes device"
- $DMSETUP_PROG mknodes > /dev/null 2>&1
}
_log_writes_mark()
_log_writes_remove()
{
- $DMSETUP_PROG remove $LOGWRITES_NAME > /dev/null 2>&1
- $DMSETUP_PROG mknodes > /dev/null 2>&1
+ _dmsetup_remove $LOGWRITES_NAME
}
_log_writes_cleanup()
{
$UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1
- # wait for device to be fully settled so that 'dmsetup remove' doesn't
- # fail due to EBUSY
- $UDEV_SETTLE_PROG >/dev/null 2>&1
_log_writes_remove
}
_dmthin_cleanup()
{
$UMOUNT_PROG $SCRATCH_MNT > /dev/null 2>&1
- # wait for device to be fully settled so that 'dmsetup remove' doesn't
- # fail due to EBUSY
- $UDEV_SETTLE_PROG >/dev/null 2>&1
- $DMSETUP_PROG remove $DMTHIN_VOL_NAME> /dev/null 2>&1
- $DMSETUP_PROG remove $DMTHIN_POOL_NAME> /dev/null 2>&1
- $DMSETUP_PROG remove $DMTHIN_META_NAME> /dev/null 2>&1
- $DMSETUP_PROG remove $DMTHIN_DATA_NAME> /dev/null 2>&1
+ _dmsetup_remove $DMTHIN_VOL_NAME
+ _dmsetup_remove $DMTHIN_POOL_NAME
+ _dmsetup_remove $DMTHIN_META_NAME
+ _dmsetup_remove $DMTHIN_DATA_NAME
}
_dmthin_check_fs()
# Metadata device
DMTHIN_META_TABLE="0 $meta_dev_size linear $dm_backing_dev $meta_dev_offset"
- $DMSETUP_PROG create $DMTHIN_META_NAME --table "$DMTHIN_META_TABLE" || \
+ _dmsetup_create $DMTHIN_META_NAME --table "$DMTHIN_META_TABLE" || \
_fatal "failed to create dm thin meta device"
# Data device
local data_dev_offset=$((meta_dev_offset + $meta_dev_size))
DMTHIN_DATA_TABLE="0 $data_dev_size linear $dm_backing_dev $data_dev_offset"
- $DMSETUP_PROG create $DMTHIN_DATA_NAME --table "$DMTHIN_DATA_TABLE" || \
+ _dmsetup_create $DMTHIN_DATA_NAME --table "$DMTHIN_DATA_TABLE" || \
_fatal "failed to create dm thin data device"
# Zap the pool metadata dev
# Thin pool
# "start length thin-pool metadata_dev data_dev data_block_size low_water_mark"
DMTHIN_POOL_TABLE="0 $data_dev_size thin-pool $DMTHIN_META_DEV $DMTHIN_DATA_DEV $cluster_size $low_water"
- $DMSETUP_PROG create $DMTHIN_POOL_NAME --table "$DMTHIN_POOL_TABLE" || \
+ _dmsetup_create $DMTHIN_POOL_NAME --table "$DMTHIN_POOL_TABLE" || \
_fatal "failed to create dm thin pool device"
# Thin volume
# start length thin pool_dev dev_id [external_origin_dev]
DMTHIN_VOL_TABLE="0 $virtual_size thin $DMTHIN_POOL_DEV $pool_id"
- $DMSETUP_PROG create $DMTHIN_VOL_NAME --table "$DMTHIN_VOL_TABLE" || \
+ _dmsetup_create $DMTHIN_VOL_NAME --table "$DMTHIN_VOL_TABLE" || \
_fatal "failed to create dm thin volume device"
}
dummy=$(_label_get_max)
}
+_dmsetup_remove()
+{
+ $UDEV_SETTLE_PROG >/dev/null 2>&1
+ $DMSETUP_PROG remove "$@" >>$seqres.full 2>&1
+ $DMSETUP_PROG mknodes >/dev/null 2>&1
+}
+
+_dmsetup_create()
+{
+ $DMSETUP_PROG create "$@" >>$seqres.full 2>&1 || return 1
+ $DMSETUP_PROG mknodes >/dev/null 2>&1
+ $UDEV_SETTLE_PROG >/dev/null 2>&1
+}
+
init_rc
################################################################################
# in case it's still suspended and/or mounted
$DMSETUP_PROG resume $lvdev >/dev/null 2>&1
$UMOUNT_PROG $lvdev >/dev/null 2>&1
-
- $DMSETUP_PROG remove $node >>$seqres.full 2>&1
- $DMSETUP_PROG mknodes >/dev/null 2>&1
+ _dmsetup_remove $node
}
# get standard environment, filters and checks
setup_dmdev()
{
table="0 $size_in_sector linear $SCRATCH_DEV 0"
- $DMSETUP_PROG create $node --table "$table" >>$seqres.full 2>&1 && \
- $DMSETUP_PROG mknodes >/dev/null 2>&1
- return $?
+ _dmsetup_create $node --table "$table" || \
+ _fail "setup dm device failed"
}
rm -f $seqres.full
node=$seq-test
lvdev=/dev/mapper/$node
-setup_dmdev || _fail "setup dm device failed"
+setup_dmdev
# take use of dmsetup suspend to freeze the fs.
# xfs_freeze/fsfreeze cannot be used in this test, because it can possibly