1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00
lvm2/test/shell/lvconvert-thin-external.sh
Zdenek Kabelac 6ac4cba276 tests: lvconvert external origin
Add tests for thin external origin support
2013-04-02 15:17:31 +02:00

122 lines
2.7 KiB
Bash

#!/bin/sh
# Copyright (C) 2013 Red Hat, Inc. All rights reserved.
#
# 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,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# Test conversion to thin external origin
. lib/test
which mkfs.ext2 || skip
which fsck || skip
#
# Main
#
aux have_thin 1 5 0 || skip
aux prepare_pvs 2 64
vgcreate $vg -s 64K $(cat DEVICES)
# create thin pool
lvcreate -L8M -T $vg/pool
# create plain LV
lvcreate -L8M -n $lv1 $vg
mkfs.ext2 $DM_DEV_DIR/$vg/$lv1
mkdir mnt
mount $DM_DEV_DIR/$vg/$lv1 mnt
dd if=/dev/zero of=mnt/test1 bs=1M count=1
# convert plain LV into thin external snapshot volume
# during conversion dd above could be still flushed
lvconvert -T --originname extorg --thinpool $vg/pool $vg/$lv1
check active $vg $lv1
check inactive $vg extorg
touch mnt/test
umount mnt
fsck -n $DM_DEV_DIR/$vg/$lv1
lvchange -ay $vg/extorg
lvchange -an $vg/$lv1
check active $vg extorg
check inactive $vg $lv1
# fsck in read-only mode
fsck -n $DM_DEV_DIR/$vg/extorg
#not lvresize -l+8 $vg/extorg
#not lvresize -l-4 $vg/extorg
#not lvchange -p rw $vg/extorg
#lvresize -L+8M $vg/$lv1
#lvresize -L-4M $vg/$lv1
#lvchange -p r $vg/$lv1
#lvchange -p rw $vg/$lv1
lvchange -ay $vg
lvs -a -o+origin_size,seg_size $vg
lvconvert --originname extorg1 --thinpool $vg/pool -T $vg/extorg
check inactive $vg extorg1
lvconvert --originname extorglv1 --thinpool $vg/pool -T $vg/extorg1
lvs -a -o+origin_size,seg_size $vg
lvchange -an $vg/extorg
lvs -a -o+origin_size,seg_size $vg
check inactive $vg extorglv1
lvchange -ay $vg/extorg1
lvs -a -o+origin_size,seg_size $vg
lvcreate -l4 -s $vg/$lv1 -n $lv2
lvcreate -l8 -s $vg/extorg -n $lv3
lvcreate -l12 -s $vg/extorg1 -n $lv4
lvcreate -l16 -s $vg/extorglv1 -n $lv5
lvs -a -o+origin_size,seg_size,segtype $vg
# Converting old-snapshot into external origin is not supported
not lvconvert -T --thinpool $vg/pool --originname lv5origin $vg/$lv4
check lv_field $vg/$lv1 segtype thin
check lv_field $vg/$lv2 segtype linear
check lv_field $vg/$lv3 segtype linear
check lv_field $vg/$lv4 segtype linear
check lv_field $vg/$lv5 segtype linear
check lv_field $vg/extorg segtype thin
check lv_field $vg/extorg1 segtype thin
check lv_field $vg/extorglv1 segtype linear
vgchange -ay $vg
lvs -a -o+origin_size,seg_size $vg
lvchange -an $vg/extorglv1
check inactive $vg extorglv1
# Remove all volumes dependent on external origin
lvremove -f $vg/extorglv1
# Only pool is left
check vg_field $vg lv_count 1
vgremove -ff $vg