Files
apfstests/common/dmhugedisk
T
Dave Chinner 98a3b42b42 common: convert to SPDX license tags
These have been scripted conversions then cleaned up by hand as
there was no consistency to the formatting of the license headers in
the common/ directory. Author information was also removed (it's in
the git history) and so now the header format is consistently:

##/bin/bash
# SPDX-License-Identifier: GPL-2.0(+)
# Copyright (c) <date> <owner>. All Rights Reserved.
#
# <file description>

Signed-off-by: Dave Chinner <dchinner@redhat.com>
2018-06-09 11:34:49 +10:00

49 lines
1.3 KiB
Plaintext

##/bin/bash
# SPDX-License-Identifier: GPL-2.0+
# Copyright (c) 2016 Oracle. All Rights Reserved.
#
# Routines for creating huge (fake) disks
_require_dmhugedisk()
{
_require_dm_target zero
_require_dm_target snapshot
}
_dmhugedisk_init()
{
test -z "$1" && _fatal "must specify sector count to _dmhugedisk_init"
local dm_backing_dev=$SCRATCH_DEV
local chunk_size="$2"
if [ -z "$chunk_size" ]; then
chunk_size=512
fi
$DMSETUP_PROG remove huge-test > /dev/null 2>&1
$DMSETUP_PROG remove huge-test-zero > /dev/null 2>&1
local blk_dev_size=$1
DMHUGEDISK_ZERO='/dev/mapper/huge-test-zero'
DMHUGEDISK_DEV='/dev/mapper/huge-test'
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" || \
_fatal "failed to create dm huge zero device"
$DMSETUP_PROG 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
}