summaryrefslogtreecommitdiff
path: root/test/shell/thin-many-dmeventd.sh
blob: b93b0c60ef11dcb8cdea3bdf58045fbc6ad1ea2b (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
#!/usr/bin/env bash

# Copyright (C) 2018 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

# test activation of monitoring with more thin-pool

SKIP_WITH_LVMLOCKD=1
SKIP_WITH_LVMPOLLD=1

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

. lib/inittest

#
# Main
#
aux have_thin 1 0 0 || skip

aux prepare_dmeventd
aux prepare_vg 2 64

# Create couple pools to later cause race in dmeventd during activation.
# each pool may add 1sec. extra delay

for i in $(seq 1 5)
do
	lvcreate --errorwhenfull y -Zn -T -L4M -V4M $vg/pool_${i} -n $lv${i}
        # Fill thin-pool to some capacity >50%
	dd if=/dev/zero of="$DM_DEV_DIR/$vg/$lv${i}" bs=256K count=9 oflag=direct
done

lvs -a $vg
vgchange -an $vg


# Try to now activate all existing pool - this will generate in about 10sec later
# storm of intial call of 'lvextend --use-policies'
vgchange -ay $vg

# Every 10sec. ATM there is DM status monitoring made by dmeventd
sleep 9

# Here try to hit the race by creating several new thin-pools in sequence.
# Creation meets with dmeventd running 'lvextend' command and taking
# it's internal lvm2 library lock - this used to make impossible to proceed with
# new thin-pool registration.
for i in $(seq 11 15)
do
	#/usr/bin/time -o TM -f %e lvcreate --errorwhenfull y -Zn -T -L4M -V4M $vg/pool_${i} -n $lv${i}
	#read -r t < TM
	#test ${t%%.*} -lt 8 || die "Creation of thin pool took more then 8 second! ($t seconds)"
	START=$(date +%s)
	lvcreate --errorwhenfull y -Zn -T -L4M -V4M $vg/pool_${i} -n $lv${i}
	END=$(date +%s)
	DIFF=$(( END - START ))
	test "$DIFF" -lt 8 || die "Creation of thin pool took more then 8 second! ($DIFF seconds)"
	# Fill thin-pool to some capacity >50%
	dd if=/dev/zero of="$DM_DEV_DIR/$vg/$lv${i}" bs=256K count=9 oflag=direct
done

vgremove -f $vg