2017-07-02 22:38:32 +03:00
#!/usr/bin/env bash
2015-04-02 13:22:59 +03:00
# Copyright (C) 2010-2015 Red Hat, Inc. All rights reserved.
2010-01-19 19:44:57 +03:00
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
# of the GNU General Public License v.2.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
2016-01-21 13:49:46 +03:00
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2010-01-19 19:44:57 +03:00
2018-05-24 17:49:48 +03:00
2015-10-27 17:10:06 +03:00
SKIP_WITH_LVMPOLLD = 1
2010-01-19 19:44:57 +03:00
2015-10-27 17:10:06 +03:00
. lib/inittest
2015-05-09 02:59:18 +03:00
2012-03-16 17:00:05 +04:00
which mkfs.ext3 || skip
lvdev_( ) {
2010-04-07 18:46:26 +04:00
echo " $DM_DEV_DIR / $1 / $2 "
2010-01-19 19:44:57 +03:00
}
2012-03-16 17:00:05 +04:00
test_snapshot_mount( ) {
2013-05-31 23:11:51 +04:00
lvcreate -aey -L4M -n $lv1 $vg " $dev1 "
2018-05-13 00:22:20 +03:00
mkfs.ext3 -b4096 " $( lvdev_ $vg $lv1 ) "
2010-01-19 19:44:57 +03:00
mkdir test_mnt
2012-03-16 17:00:05 +04:00
mount " $( lvdev_ $vg $lv1 ) " test_mnt
2013-05-31 23:11:51 +04:00
lvcreate -L4M -n $lv2 -s $vg /$lv1
2010-01-19 19:44:57 +03:00
umount test_mnt
2015-04-30 14:43:31 +03:00
aux udev_wait
2010-01-19 19:44:57 +03:00
# mount the origin
2012-03-16 17:00:05 +04:00
mount " $( lvdev_ $vg $lv1 ) " test_mnt
2010-01-19 19:44:57 +03:00
umount test_mnt
2015-04-30 14:43:31 +03:00
aux udev_wait
2010-01-19 19:44:57 +03:00
# mount the snapshot
2012-03-16 17:00:05 +04:00
mount " $( lvdev_ $vg $lv2 ) " test_mnt
2010-01-19 19:44:57 +03:00
umount test_mnt
rm -r test_mnt
vgchange -an $vg
lvremove -f $vg /$lv1
}
# FIXME add more topology-specific tests and validation (striped LVs, etc)
NUM_DEVS = 1
2010-08-12 08:11:48 +04:00
PER_DEV_SIZE = 34
2017-07-06 20:27:04 +03:00
DEV_SIZE = $(( NUM_DEVS * PER_DEV_SIZE ))
2010-01-19 19:44:57 +03:00
# ---------------------------------------------
# Create "desktop-class" 4K drive
# (logical_block_size=512, physical_block_size=4096, alignment_offset=0):
LOGICAL_BLOCK_SIZE = 512
2011-01-05 03:16:18 +03:00
aux prepare_scsi_debug_dev $DEV_SIZE \
2010-01-19 19:44:57 +03:00
sector_size = $LOGICAL_BLOCK_SIZE physblk_exp = 3
2015-05-04 11:17:48 +03:00
# Test that kernel supports topology
2017-07-10 11:40:09 +03:00
if [ ! -e " /sys/block/ $( basename " $( < SCSI_DEBUG_DEV) " ) /alignment_offset " ] ; then
2015-05-04 11:17:48 +03:00
aux cleanup_scsi_debug_dev
skip
fi
2017-07-10 11:40:09 +03:00
check sysfs " $( < SCSI_DEBUG_DEV) " queue/logical_block_size " $LOGICAL_BLOCK_SIZE "
2010-05-24 23:27:38 +04:00
aux prepare_pvs $NUM_DEVS $PER_DEV_SIZE
2014-06-30 22:04:24 +04:00
get_devs
2018-05-24 17:49:48 +03:00
vgcreate $SHARED $vg " ${ DEVICES [@] } "
2010-01-19 19:44:57 +03:00
test_snapshot_mount
vgremove $vg
2011-01-05 03:16:18 +03:00
aux cleanup_scsi_debug_dev
2010-01-19 19:44:57 +03:00
# ---------------------------------------------
# Create "desktop-class" 4K drive w/ 63-sector DOS partition compensation
# (logical_block_size=512, physical_block_size=4096, alignment_offset=3584):
LOGICAL_BLOCK_SIZE = 512
2011-01-05 03:16:18 +03:00
aux prepare_scsi_debug_dev $DEV_SIZE \
2010-01-19 19:44:57 +03:00
sector_size = $LOGICAL_BLOCK_SIZE physblk_exp = 3 lowest_aligned = 7
2015-04-24 21:31:22 +03:00
check sysfs " $( < SCSI_DEBUG_DEV) " queue/logical_block_size $LOGICAL_BLOCK_SIZE
2010-01-19 19:44:57 +03:00
2010-05-24 23:27:38 +04:00
aux prepare_pvs $NUM_DEVS $PER_DEV_SIZE
2018-05-24 17:49:48 +03:00
vgcreate $SHARED $vg " ${ DEVICES [@] } "
2010-01-19 19:44:57 +03:00
test_snapshot_mount
vgremove $vg
2011-01-05 03:16:18 +03:00
aux cleanup_scsi_debug_dev
2010-01-19 19:44:57 +03:00
# ---------------------------------------------
# Create "enterprise-class" 4K drive
# (logical_block_size=4096, physical_block_size=4096, alignment_offset=0):
LOGICAL_BLOCK_SIZE = 4096
2011-01-05 03:16:18 +03:00
aux prepare_scsi_debug_dev $DEV_SIZE \
2010-01-19 19:44:57 +03:00
sector_size = $LOGICAL_BLOCK_SIZE
2015-04-24 21:31:22 +03:00
check sysfs " $( < SCSI_DEBUG_DEV) " queue/logical_block_size $LOGICAL_BLOCK_SIZE
2010-01-19 19:44:57 +03:00
2010-05-24 23:27:38 +04:00
aux prepare_pvs $NUM_DEVS $PER_DEV_SIZE
2018-05-24 17:49:48 +03:00
vgcreate $SHARED $vg " ${ DEVICES [@] } "
2010-01-19 19:44:57 +03:00
test_snapshot_mount
vgremove $vg
2013-05-13 23:56:47 +04:00
aux cleanup_scsi_debug_dev
2015-04-07 15:56:16 +03:00
# scsi_debug option opt_blks appeared in Oct 2010
aux kernel_at_least 2 6 37 || exit 0
2013-05-13 23:56:47 +04:00
# ---------------------------------------------
# Create "enterprise-class" 512 drive w/ HW raid stripe_size = 768K
# (logical_block_size=512, physical_block_size=512, alignment_offset=0):
# - tests case where optimal_io_size=768k < default PE alignment=1MB
LOGICAL_BLOCK_SIZE = 512
aux prepare_scsi_debug_dev $DEV_SIZE \
sector_size = $LOGICAL_BLOCK_SIZE opt_blks = 1536
2015-04-02 13:22:59 +03:00
2015-04-24 21:31:22 +03:00
check sysfs " $( < SCSI_DEBUG_DEV) " queue/logical_block_size $LOGICAL_BLOCK_SIZE
check sysfs " $( < SCSI_DEBUG_DEV) " queue/optimal_io_size 786432
2013-05-13 23:56:47 +04:00
aux prepare_pvs 1 $PER_DEV_SIZE
2015-04-02 13:22:59 +03:00
# Kernel (3.19) could provide wrong results - in this case skip
# test with incorrect result - lvm2 can't figure out good values.
2017-07-11 12:18:22 +03:00
SHOULD = ""
2015-04-24 21:31:22 +03:00
check sysfs " $dev1 " queue/optimal_io_size 786432 || SHOULD = should
2015-04-02 13:22:59 +03:00
$SHOULD check pv_field " ${ DEVICES [@] } " pe_start 768.00k
2013-05-13 23:56:47 +04:00
aux cleanup_scsi_debug_dev