2017-07-02 22:38:32 +03:00
#!/usr/bin/env bash
2012-10-09 18:32:11 +04:00
# Copyright (C) 2012 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,
2016-01-21 13:49:46 +03:00
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
2012-10-09 18:32:11 +04:00
2018-05-24 17:49:48 +03:00
2015-10-27 17:10:06 +03:00
SKIP_WITH_LVMPOLLD = 1
2015-05-17 18:22:18 +03:00
export LVM_TEST_THIN_REPAIR_CMD = ${ LVM_TEST_THIN_REPAIR_CMD -/bin/false }
2014-06-06 19:40:04 +04:00
. lib/inittest
2012-10-09 18:32:11 +04:00
check_lv_field_modules_( )
{
mod = $1
shift
2017-07-10 11:40:09 +03:00
for d in " $@ " ; do
check lv_field " $vg / $d " modules " $mod "
2012-10-09 18:32:11 +04:00
done
}
#
# Main
#
2012-10-10 02:20:22 +04:00
aux have_thin 1 0 0 || skip
2014-02-27 02:25:30 +04:00
which mkfs.ext4 || skip
2012-10-09 18:32:11 +04:00
aux prepare_pvs 2 64
2017-07-06 20:41:25 +03:00
get_devs
2012-10-09 18:32:11 +04:00
2018-05-24 17:49:48 +03:00
vgcreate $SHARED -s 64K " $vg " " ${ DEVICES [@] } "
2012-10-09 18:32:11 +04:00
lvcreate -L10M -V10M -T $vg /pool --name $lv1
2014-02-23 02:08:55 +04:00
mkfs.ext4 " $DM_DEV_DIR / $vg / $lv1 "
2014-02-27 02:25:30 +04:00
# create read-only thin snapshot of thin LV
lvcreate -K -s $vg /$lv1 -pr --name snap
2012-10-09 18:32:11 +04:00
# check snapshot filesystem was properly frozen before snapping
2014-02-23 02:08:55 +04:00
fsck -n " $DM_DEV_DIR / $vg /snap "
2013-07-12 15:54:53 +04:00
lvcreate -K -s $vg /$lv1 --name $lv2
lvcreate -K -s $vg /$lv1 --name $vg /$lv3
2014-10-20 16:56:55 +04:00
# old-snapshot without known size is invalid
invalid lvcreate --type snapshot $vg /$lv1
invalid lvcreate --type snapshot $vg /$lv1 --name $lv4
invalid lvcreate --type snapshot $vg /$lv1 --name $vg /$lv5
# some other ways how to take a thin snapshot
lvcreate -T $vg /$lv1
lvcreate --thin $vg /$lv1 --name $lv4
lvcreate --type thin $vg /$lv1 --name $vg /$lv5
# virtual size needs thin pool
fail lvcreate --type thin $vg /$lv1 -V20
2012-10-09 18:32:11 +04:00
# create old-style snapshot
lvcreate -s -L10M --name oldsnap1 $vg /$lv2
lvcreate -s -L10M --name oldsnap2 $vg /$lv2
# thin snap of snap of snap...
2013-07-12 15:54:53 +04:00
lvcreate -K -s --name sn1 $vg /$lv2
lvcreate -K -s --name sn2 $vg /sn1
lvcreate -K -s --name sn3 $vg /sn2
lvcreate -K -s --name sn4 $vg /sn3
2012-10-09 18:32:11 +04:00
2013-07-24 03:11:15 +04:00
lvremove -ff $vg
lvcreate -L10M --zero n -T $vg /pool -V10M --name $lv1
2014-02-23 02:08:55 +04:00
mkfs.ext4 " $DM_DEV_DIR / $vg / $lv1 "
2013-07-24 03:11:15 +04:00
lvcreate -K -s $vg /$lv1 --name snap
2014-02-23 02:08:55 +04:00
fsck -n " $DM_DEV_DIR / $vg /snap "
2023-06-20 23:41:24 +03:00
vgchange -an $vg
lvremove -y $vg
# One thin pool and one thin LV
lvcreate --type thin-pool -L 10M -n tp $vg
lvcreate --type thin -n thin1 -V 20M --thinpool tp $vg
# Different syntaxes for creating a thin snapshot
lvcreate --type thin -n snap1 $vg /thin1
lvcreate --type thin --snapshot -n snap2 $vg /thin1
lvcreate --type thin --thin -n snap3 $vg /thin1
lvcreate --type thin --snapshot --thin -n snap4 $vg /thin1
lvcreate --snapshot -n snap5 $vg /thin1
lvcreate --thin -n snap6 $vg /thin1
# The command defs allow --snapshot --thin, but the internal
# lvcreate option checks disallow it. It doesn't seem to make
# sense to disallow this from a syntax point of view, but it's
# possible that the lvcreate implementation would do the wrong
# thing (that should probably be fixed.)
not lvcreate --thin --snapshot -n snap7 $vg /thin1
vgchange -an $vg
2013-07-24 03:11:15 +04:00
2012-10-09 18:32:11 +04:00
vgremove -ff $vg