export LVM_TEST_THIN_REPAIR_CMD=${LVM_TEST_THIN_REPAIR_CMD-/bin/false}
+mntdir="${PREFIX}mnt with space"
+mntusedir="${PREFIX}mntuse"
+
+cleanup_mounted_and_teardown()
+{
+ umount "$mntdir" 2>/dev/null || true
+ umount "$mntusedir" 2>/dev/null || true
+ vgremove -ff $vg
+ aux teardown
+}
+
is_lv_opened_()
{
test $(get lv_field "$1" lv_device_open --binary) = "1"
#
# Main
#
-which mkfs.ext2 || skip
+which mkfs.ext4 || skip
+export MKE2FS_CONFIG="$TESTDIR/lib/mke2fs.conf"
aux have_thin 1 0 0 || skip
aux prepare_vg 2
-mntdir="${PREFIX}mnt with space"
-mntusedir="${PREFIX}mntuse"
lvcreate -L8M -V8M -n $lv1 -T $vg/pool
lvcreate -V8M -n $lv2 -T $vg/pool
-mkfs.ext2 "$DM_DEV_DIR/$vg/$lv1"
-mkfs.ext2 "$DM_DEV_DIR/$vg/$lv2"
+mkfs.ext4 "$DM_DEV_DIR/$vg/$lv1"
+mkfs.ext4 "$DM_DEV_DIR/$vg/$lv2"
lvchange --monitor y $vg/pool
mkdir "$mntdir" "$mntusedir"
+trap 'cleanup_mounted_and_teardown' EXIT
mount "$DM_DEV_DIR/mapper/$vg-$lv1" "$mntdir"
mount "$DM_DEV_DIR/mapper/$vg-$lv2" "$mntusedir"
sleep 60 < "$mntusedir/file$$" &
PID_SLEEP=$!
-# Fill pool above 70%
-dd if=/dev/zero of="$mntdir/file$$" bs=1M count=6 conv=fdatasync
+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
sleep 1
done
+lvs -a $vg
+
is_lv_opened_ "$vg/$lv2" || \
die "$mntusedir is not mounted here (sleep already expired??)"
kill $PID_SLEEP
wait
-is_lv_opened_ "$vg/$lv2" && {
+not is_lv_opened_ "$vg/$lv2" || {
mount
die "$mntusedir should have been unmounted by dmeventd!"
}
-
-vgremove -f $vg
-
aux have_thin 1 0 0 || skip
which mkfs.ext4 || skip
+# Use our mkfs config file to get approximately same results
+# TODO: maybe use it for all test via some 'prepare' function
+export MKE2FS_CONFIG="$TESTDIR/lib/mke2fs.conf"
+
aux prepare_dmeventd
aux prepare_pvs 2 64
vgcreate $vg -s 64K $(cat DEVICES)
# Create named pool only
-lvcreate --errorwhenfull y -L2100K -T $vg/pool
+lvcreate --errorwhenfull y -L2 -T $vg/pool
POOL="$vg-pool"
THIN="${PREFIX}_thin"
dmsetup info -c
mkdir "$MOUNT_DIR"
-# This mkfs fills 2.2MB pool over 95%
+# This mkfs should fill 2MB pool over 95%
# no autoresize is configured
mkfs.ext4 "$DM_DEV_DIR/mapper/$THIN"
test $(percent_) -gt 95
aux lvmconf 'activation/thin_pool_autoextend_percent = 10' \
'activation/thin_pool_autoextend_threshold = 75'
-# Give it some time to left dmeventd do some work
+# Give it some time to left dmeventd do some (failing to resize) work
sleep 20
# And check foreign thin device is still mounted