2017-07-02 22:38:32 +03:00
#!/usr/bin/env bash
2015-11-21 00:28:21 +03:00
# Copyright (C) 2015 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
2015-11-21 00:28:21 +03:00
# ensure there is no data loss during thin-pool resize
2018-05-24 17:49:48 +03:00
2017-04-21 13:18:56 +03:00
SKIP_WITH_LVMPOLLD = 1
2016-02-23 01:13:42 +03:00
2015-11-21 00:28:21 +03:00
export LVM_TEST_THIN_REPAIR_CMD = ${ LVM_TEST_THIN_REPAIR_CMD -/bin/false }
. lib/inittest
which md5sum || skip
aux have_thin 1 0 0 || skip
2016-12-12 13:22:41 +03:00
aux prepare_vg 2 20
2015-11-21 00:28:21 +03:00
lvcreate -L1M -V2M -n $lv1 -T $vg /pool
# just ensure we check what we need to check
check lv_field $vg /pool size "1.00m"
check lv_field $vg /$lv1 size "2.00m"
# prepare 2097152 file content
seq 0 315465 > 2M
md5sum 2M | cut -f 1 -d ' ' | tee MD5
2015-12-10 22:47:30 +03:00
dd if = 2M of = " $DM_DEV_DIR /mapper/ $vg - $lv1 " bs = 512K conv = fdatasync >log 2>& 1 &
2015-11-21 00:28:21 +03:00
#dd if=2M of="$DM_DEV_DIR/mapper/$vg-$lv1" bs=2M oflag=direct &
# give it some time to fill thin-volume
# eventually loop to wait for 100% full pool...
sleep .1
lvs -a $vg
# this must not 'block & wait' on suspending flush
# if it waits on thin-pool's target timeout
# it will harm queued data
lvextend -L+512k $vg /pool
lvextend -L+512k $vg /pool
# collect 'dd' result
wait
cat log
lvs -a $vg
dd if = " $DM_DEV_DIR /mapper/ $vg - $lv1 " of = 2M-2 iflag = direct
md5sum 2M-2 | cut -f 1 -d ' ' | tee MD5-2
# these 2 are supposed to match
diff MD5 MD5-2
# Do not want to see Live & Inactive table entry
2017-07-07 22:29:55 +03:00
( dm_info attr,name | not grep " LI-.* ${ PREFIX } " ) || {
2015-11-21 00:28:21 +03:00
dmsetup table --inactive | grep ${ PREFIX }
die "Found device with Inactive table"
}
# Check wrapping active thin-pool linear mapping has matching size
POOLSZ = $( dmsetup table ${ vg } -pool-tpool | cut -d ' ' -f 2)
WRAPSZ = $( dmsetup table ${ vg } -pool | cut -d ' ' -f 2)
#
# FIXME: currently requires to update 2 dependent targets in one 'preload'
# lvm2 cannot handle this and would need one extra --refresh pass.
# Once resolved - enabled this test.
# Maybe other solution without fake linear mapping could be found.
# Eventually strictly map just single sector as it has no real use?
#
#should test "${POOLSZ}" = "${WRAPSZ}" || \
# die "Wrapping pool device size does not match real pool size"
vgremove -f $vg