summaryrefslogtreecommitdiff
path: root/test/shell/thin-autoumount-dmeventd.sh
blob: 781a27ec0ec00dc3a9e46c6e27d500e6c93500b5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
# Copyright (C) 2012 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,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

# no automatic extensions, just umount

SKIP_WITH_LVMPOLLD=1

export LVM_TEST_THIN_REPAIR_CMD=${LVM_TEST_THIN_REPAIR_CMD-/bin/false}

is_dir_mounted_()
{
	cat /proc/mounts | sed 's:\\040: :g' | grep "$1"
}

. lib/inittest

#
# Main
#
which mkfs.ext2 || skip

aux have_thin 1 0 0 || skip

aux prepare_dmeventd

aux lvmconf "activation/thin_pool_autoextend_percent = 0" \
            "activation/thin_pool_autoextend_threshold = 70"

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"

lvchange --monitor y $vg/pool

mkdir "$mntdir" "$mntusedir"
mount "$DM_DEV_DIR/mapper/$vg-$lv1" "$mntdir"
mount "$DM_DEV_DIR/mapper/$vg-$lv2" "$mntusedir"

is_dir_mounted_ "$mntdir"

# fill above 70%
dd if=/dev/zero of="$mntdir/file$$" bs=1M count=6
touch "$mntusedir/file$$"
tail -f "$mntusedir/file$$" &
PID_TAIL=$!
sync
lvs -a $vg
sleep 12 # dmeventd only checks every 10 seconds :(

lvs -a $vg
# both dirs should be unmounted
not is_dir_mounted "$mntdir"
not is_dir_mounted "$mntusedir"

# running tail keeps the block device still in use
kill $PID_TAIL
lvs -a $vg

vgremove -f $vg