summaryrefslogtreecommitdiff
path: root/test/shell/missing-pv-unused.sh
blob: 22dd77d03338aab0969e52e3cfc637869fb288c1 (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
75
76
77
78
79
80
81
82
83
84
85
86
#!/usr/bin/env bash

# Copyright (C) 2008-2013,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

. lib/inittest

aux prepare_devs 3
get_devs

vgcreate $SHARED $vg "$dev1" "$dev2" "$dev3"

lvcreate -n $lv1 -L8M $vg "$dev2"
lvcreate -n $lv2 -L8M $vg "$dev3"
lvcreate -n $lv3 -L8M $vg "$dev2"
lvcreate -n $lv4 -L8M $vg "$dev3"

vgchange -an $vg

pvs
vgs
lvs -a -o+devices

# Fail device that is not used by any LVs.
aux disable_dev "$dev1"

pvs
vgs
lvs -a -o+devices

# Cannot do normal activation of LVs not using failed PV.
lvchange -ay $vg/$lv1
lvchange -ay $vg/$lv2

vgchange -an $vg

# Check that MISSING flag is not set in ondisk metadata.
vgck --dumpmetadata --sourcedevice "$dev2" $vg > meta
not grep MISSING meta
rm meta

pvs
vgs
lvs -a -o+devices

# lvremove is one of the few commands that is allowed to run
# when PVs are missing.  The vg_write from this command sets
# the MISSING flag on the PV in the ondisk metadata.
# (this could be changed, the MISSING flag wouldn't need
# to be set in the first place since the PV isn't used.)
lvremove $vg/$lv1

# Check that MISSING flag is set in ondisk metadata.
vgck --dumpmetadata --sourcedevice "$dev2" $vg > meta
grep MISSING meta
rm meta

# with MISSING flag in metadata, restrictions apply
not lvcreate -l1 $vg

aux enable_dev "$dev1"

# No LVs are using the PV with MISSING flag, so no restrictions
# are applied, and the vg_write here clears the MISSING flag on disk.
lvcreate -l1 $vg

# Check that MISSING flag is not set in ondisk metadata.
vgck --dumpmetadata --sourcedevice "$dev2" $vg > meta
not grep MISSING meta
rm meta


pvs
vgs
lvs -a -o+devices

vgchange -an $vg
vgremove -ff $vg