2012-03-16 17:00:05 +04:00
#!/bin/sh
# Copyright (C) 2010-2012 Red Hat, Inc. All rights reserved.
2010-10-15 20:28:14 +04: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,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2014-06-06 19:40:04 +04:00
. lib/inittest
2010-10-15 20:28:14 +04:00
2015-05-09 02:59:18 +03:00
test -e LOCAL_LVMPOLLD && skip
2010-10-15 20:28:14 +04:00
extend( ) {
2012-08-27 16:04:21 +04:00
lvextend --use-policies --config " activation { snapshot_autoextend_threshold = $1 } " $vg /snap
2010-10-15 20:28:14 +04:00
}
2012-03-16 17:00:05 +04:00
write_( ) {
2015-05-02 22:14:45 +03:00
dd if = /dev/zero of = " $DM_DEV_DIR / $vg /snap " bs = 1k count = $2 seek = $1 oflag = direct
2010-10-15 20:28:14 +04:00
}
2012-03-16 17:00:05 +04:00
percent_( ) {
get lv_field $vg /snap snap_percent | cut -d. -f1
2010-10-15 20:28:14 +04:00
}
2012-03-16 17:00:05 +04:00
wait_for_change_( ) {
# dmeventd only checks every 10 seconds :(
2014-10-01 11:52:09 +04:00
for i in $( seq 1 25) ; do
2012-03-16 17:00:05 +04:00
test " $( percent_) " != " $1 " && return
sleep 1
done
2010-10-15 20:28:14 +04:00
2012-03-16 17:00:05 +04:00
return 1 # timeout
}
2010-10-15 20:28:14 +04:00
2012-03-16 17:00:05 +04:00
aux prepare_dmeventd
aux prepare_vg 2
2010-10-15 20:28:14 +04:00
2013-06-15 13:21:03 +04:00
lvcreate -aey -L16M -n base $vg
2012-03-16 17:00:05 +04:00
lvcreate -s -L4M -n snap $vg /base
2010-10-15 20:28:14 +04:00
2012-03-16 17:00:05 +04:00
write_ 0 1000
test 24 -eq $( percent_)
2010-10-15 20:28:14 +04:00
2012-03-16 17:00:05 +04:00
lvchange --monitor y $vg /snap
2011-11-21 16:31:18 +04:00
2012-03-16 17:00:05 +04:00
write_ 1000 1700
pre = $( percent_)
2015-02-19 19:08:33 +03:00
# Normally the usage should be ~66% here, however on slower systems
# dmeventd could be actually 'fast' enough to have COW already resized now
# so mark test skipped if we are bellow 50% by now
test $pre -gt 50 || skip
2012-03-16 17:00:05 +04:00
wait_for_change_ $pre
test $pre -gt $( percent_)
2011-11-21 16:31:18 +04:00
# check that a second extension happens; we used to fail to extend when the
# utilisation ended up between THRESH and (THRESH + 10)... see RHBZ 754198
# (the utilisation after the write should be 57 %)
2012-03-16 17:00:05 +04:00
write_ 2700 2000
pre = $( percent_)
2015-02-19 19:08:33 +03:00
# Mark test as skipped if already resized...
test $pre -gt 70 || skip
2012-03-16 17:00:05 +04:00
wait_for_change_ $pre
test $pre -gt $( percent_)
vgremove -f $vg