1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

tests: use hold_device_open

This commit is contained in:
Zdenek Kabelac 2016-12-22 23:31:22 +01:00
parent e1943fc07f
commit 62be9c8de4
3 changed files with 5 additions and 20 deletions

View File

@ -29,9 +29,7 @@ snap_and_merge() {
sync
lvs -a $vg
# keep device open to prevent instant merge
sleep 20 < "$DM_DEV_DIR/$vg/$lv1" &
SLEEP_PID=$!
SLEEP_PID=$(aux hold_device_open $vg $lv1 20)
# initiate background merge
lvconvert -b --merge $vg/$lv2

View File

@ -24,16 +24,6 @@ fill() {
die "Snapshot does not fit $1"
}
# Wait until device is opened
wait_for_open_() {
for i in $(seq 1 50) ; do
test $(dmsetup info --noheadings -c -o open $1) -ne 0 && return
sleep 0.1
done
die "$1 expected to be openned, but it's not!"
}
cleanup_tail()
{
test -z "$SLEEP_PID" || kill $SLEEP_PID || true
@ -125,10 +115,7 @@ lvchange -ay $vg1
check lv_field $vg1/$lv1 lv_active "$CHECK_ACTIVE"
# Test removal of opened (but unmounted) snapshot (device busy) for a while
sleep 120 < "$DM_DEV_DIR/$vg1/$lv1" &
SLEEP_PID=$!
wait_for_open_ "$vg1-$lv1"
SLEEP_PID=$(aux hold_device_open $vg1 $lv1 60)
# Opened virtual snapshot device is not removable
# it should retry device removal for a few seconds

View File

@ -72,18 +72,18 @@ touch "$mntusedir/file$$"
sync
# Running 'keeper' process sleep holds the block device still in use
sleep 60 < "$mntusedir/file$$" &
sleep 60 < "$mntusedir/file$$" >/dev/null 2>&1 &
PID_SLEEP=$!
lvs -a $vg
# Fill pool above 95% (to cause 'forced lazy umount)
dd if=/dev/zero of="$mntdir/file$$" bs=256K count=20 conv=fdatasync
sync
lvs -a $vg
# Could loop here for a few secs so dmeventd can do some work
# In the worst case check only happens every 10 seconds :(
# With low water mark it should react way faster
# With low water mark it quickly discovers overflow and umounts $vg/$lv1
for i in $(seq 1 12) ; do
is_lv_opened_ "$vg/$lv1" || break
test $i -lt 12 || die "$mntdir should have been unmounted by dmeventd!"