2
# Copyright (C) 2010 Red Hat, Inc. All rights reserved.
4
# This copyrighted material is made available to anyone wishing to use,
5
# modify, copy, or redistribute it subject to the terms and conditions
6
# of the GNU General Public License v.2.
8
# You should have received a copy of the GNU General Public License
9
# along with this program; if not, write to the Free Software Foundation,
10
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
13
which mkfs.ext3 || exit 200
19
echo "$DM_DEV_DIR/$1/$2"
29
local NUM_EXTRA_SNAPS="$3"
30
test -z "$NUM_EXTRA_SNAPS" && NUM_EXTRA_SNAPS=0
31
local BASE_SNAP_LV_NAME=$(snap_lv_name_ $LV_NAME)
33
lvcreate -n $LV_NAME -l 50%FREE $VG_NAME
34
lvcreate -s -n $BASE_SNAP_LV_NAME -l 20%FREE ${VG_NAME}/${LV_NAME}
35
mkfs.ext3 $(lvdev_ $VG_NAME $LV_NAME)
37
if [ $NUM_EXTRA_SNAPS -gt 0 ]; then
38
for i in `seq 1 $NUM_EXTRA_SNAPS`; do
39
lvcreate -s -n ${BASE_SNAP_LV_NAME}_${i} -l 20%FREE ${VG_NAME}/${LV_NAME}
47
# test full merge of a single LV
49
# now that snapshot LV is created: test if snapshot-merge target is available
50
$(dmsetup targets | grep snapshot-merge >/dev/null) || exit 200
52
# make sure lvconvert --merge requires explicit LV listing
53
not lvconvert --merge 2>err
54
lvconvert --merge $vg/$(snap_lv_name_ $lv1)
58
# test that an actively merging snapshot may not be removed
60
lvconvert -i+100 --merge --background $vg/$(snap_lv_name_ $lv1)
61
not lvremove -f $vg/$(snap_lv_name_ $lv1)
65
# "onactivate merge" test
69
mount $(lvdev_ $vg $lv1) test_mnt
70
lvconvert --merge $vg/$(snap_lv_name_ $lv1)
71
# -- refresh LV while FS is still mounted (merge must not start),
72
# verify 'snapshot-origin' target is still being used
73
lvchange --refresh $vg/$lv1
76
dmsetup table ${vg}-${lv1} | grep " snapshot-origin "
78
# -- refresh LV to start merge (now that FS is unmounted),
79
# an active merge uses the 'snapshot-merge' target
80
lvchange --refresh $vg/$lv1
81
dmsetup table ${vg}-${lv1} | grep " snapshot-merge "
82
# -- don't care if merge is still active; lvremove at this point
83
# may test stopping an active merge
87
# "onactivate merge" test
88
# -- deactivate/remove after disallowed merge attempt, tests
89
# to make sure preload of origin's metadata is _not_ performed
93
mount $(lvdev_ $vg $lv1) test_mnt
94
lvconvert --merge $vg/$(snap_lv_name_ $lv1)
95
# -- refresh LV while FS is still mounted (merge must not start),
96
# verify 'snapshot-origin' target is still being used
97
lvchange --refresh $vg/$lv1
100
dmsetup table ${vg}-${lv1} | grep " snapshot-origin " >/dev/null
104
# test multiple snapshot merge; tests copy out that is driven by merge
105
setup_merge $vg $lv1 1
107
lvconvert --merge $vg/$(snap_lv_name_ $lv1)
111
# test merging multiple snapshots that share the same tag
115
lvchange --addtag this_is_a_test $vg/$(snap_lv_name_ $lv1)
116
lvchange --addtag this_is_a_test $vg/$(snap_lv_name_ $lv2)
117
lvconvert --merge @this_is_a_test
118
lvs | not grep $(snap_lv_name_ $lv1)
119
lvs | not grep $(snap_lv_name_ $lv2)
123
# FIXME following tests would need to poll merge progress, via periodic lvs?
124
# Background processes don't lend themselves to lvm testsuite...
126
# test: onactivate merge of a single lv
128
# test: do onactivate, deactivate the origin LV, reactivate the LV, merge should resume
130
# test: multiple onactivate merge