~ubuntu-branches/ubuntu/saucy/lvm2/saucy

« back to all changes in this revision

Viewing changes to test/shell/metadata-balance.sh

  • Committer: Package Import Robot
  • Author(s): Dmitrijs Ledkovs
  • Date: 2012-08-14 14:35:57 UTC
  • mfrom: (3.1.25 sid)
  • Revision ID: package-import@ubuntu.com-20120814143557-93aill2tp3kf3o30
Tags: 2.02.95-4ubuntu1
* Merge from Debian unstable, remaining changes:
  - debian/patches/avoid-dev-block.patch: Prefer any other device name over
    names in /dev/block/ since lvm.conf won't handle this.
  - debian/rules:
    - copy .po file to .pot file for Rosetta (Ubuntu specific).
  - debian/{dmsetup,lvm2}-udeb.install:
    - install initramfs and udev hooks in udebs (Debian bug 504341).
  - auto-start VGs as their PVs are discovered (Ubuntu specific):
    - add debian/tree/lvm2/lib/udev/rules.d/85-lvm2.rules: use watershed plus
      the sledgehammer of vgscan/vgchange to turn on VGs as they come online.
    - debian/tree/lvm2/usr/share/initramfs-tools/scripts/hooks/lvm2:
      - add 85-lvm2.rules to the list of udev rules to copy.
      - depend on udev.
    - debian/control:
      - add versioned Depend on watershed in lvm2 for udev rules.
      - add Depends on watershed-udeb in lvm2-udeb for udev rules.
      - add versioned Depend/Breaks on udev in dmsetup for udev rules.
      - add Depend on initramfs-tools in dmsetup so system is not potentially
        rendered unbootable by out-of-order dpkg configuration.
    - debian/rules:
      - do not install local-top scripts since Ubuntu mounts root using udev.
      - do not install init scripts for lvm2, since udev starts LVM.
    - debian/lvm2.postinst: handle missing lvm2 init script.
    - debian/tree/dmsetup/lib/udev/rules.d/60-persistent-storage-dm.rules:
      watch dm devices for changes with inotify
  - add mountroot failure hooks to help fix bad boots (Debian bug 468115):
    - debian/tree/lvm2/usr/share/initramfs-tools/scripts/init-premount/lvm2
  - remaining changes to upstream event manager packages (Debian bug 514706):
    - debian/rules:
      - enable dmeventd during configure.
    - debian/dmeventd.{8,manpages}: install dmeventd files.
  - rename debian/clvm.defaults to debian/clvm.default so it is installed
    correctly.
  - debian/control: add dmsetup-udeb to libdevmapper1.02.1-udeb recommends.
  - debian/rules: make sure dmsetup and lvm2 initramfs-tools scripts are
    executable.  When the Ubuntu-specific ones are added with a patch,
    they may lose their executable bit.
  - Add and install clvmd resource agent
  - Add dependency on libudev-dev to libdevmapper-dev so that the .pc file
    works.
  - debian/{clvmd.ra,clvm.init}:
    - create /run/lvm if it doesn't exist.
  - debian/clvm.init:
    - exit 3 if not running on status action.
  - Call dh_installman so that our dmeventd manpage actually gets installed
  - Install the missing fsadm manpage.

 * libdevmapper-dev:
  - move .so symlinks and pkgconfig files to multiarched locations.
  - mark libdevmapper-dev M-A: same

 * libdevmapper-event1.02.1:
  - Add Breaks: dmeventd (<< 2.02.95-4ubuntu1) due to debian symbol rename

 * debian/lvm2.{preinst,postinst,postrm}:
  - Implement removal of obsolete /etc/init.d/lvm2 conffile, which
    should not have been re-introduced in Quantal.

 * Dropped Changes, included in Debian:
  - Mostly included packages for upstream event manager (Debian bug 514706).
  - debian/patches/rules-subdir.patch: removed as reordering will cause
    build failure with dmeventd.
  - debian/patches/libdm-event-static.patch: removed as other static libs
    aren't being built anymore either.
  - Update symbols for libdevmapper-event.
  - Update libdevmapper-event, dmeventd descriptions to match Debian
    boilerplate.

 * Disappeared Changes:
  - Don't install documentation in udebs. No diff found, but no docs are
    installed into udebs either.

 * Resurected Changes:
  - corrected dropping the wrong init script. Now clvm.init is shipped
    and lvm2.init is dropped in favor of udev rules as per original
    intention (LP: #1037033).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2008 Red Hat, Inc. All rights reserved.
 
2
#
 
3
# This copyrighted material is made available to anyone wishing to use,
 
4
# modify, copy, or redistribute it subject to the terms and conditions
 
5
# of the GNU General Public License v.2.
 
6
#
 
7
# You should have received a copy of the GNU General Public License
 
8
# along with this program; if not, write to the Free Software Foundation,
 
9
# Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
10
 
 
11
. lib/test
 
12
 
 
13
aux prepare_devs 6
 
14
 
 
15
echo Make sure we can ignore / un-ignore mdas on a per-PV basis
 
16
for pv_in_vg in 1 0; do
 
17
for mdacp in 1 2; do
 
18
        pvcreate --metadatacopies $mdacp $dev1 $dev2
 
19
        pvcreate --metadatacopies 0 $dev3
 
20
        if [ $pv_in_vg = 1 ]; then
 
21
                vgcreate -c n "$vg" $dev1 $dev2 $dev3
 
22
        fi
 
23
        pvchange --metadataignore y $dev1
 
24
        check pv_field $dev1 pv_mda_count $mdacp
 
25
        check pv_field $dev1 pv_mda_used_count 0
 
26
        check pv_field $dev2 pv_mda_count $mdacp
 
27
        check pv_field $dev2 pv_mda_used_count $mdacp
 
28
        if [ $pv_in_vg = 1 ]; then
 
29
                check vg_field $vg vg_mda_count $(($mdacp * 2))
 
30
                check vg_field $vg vg_mda_used_count $mdacp
 
31
                check vg_field $vg vg_mda_copies unmanaged
 
32
        fi
 
33
        pvchange --metadataignore n $dev1
 
34
        check pv_field $dev1 pv_mda_count $mdacp
 
35
        check pv_field $dev1 pv_mda_used_count $mdacp
 
36
        if [ $pv_in_vg = 1 ]; then
 
37
                check vg_field $vg vg_mda_count $(($mdacp * 2))
 
38
                check vg_field $vg vg_mda_used_count $(($mdacp * 2))
 
39
                check vg_field $vg vg_mda_copies unmanaged
 
40
                vgremove -f $vg
 
41
        fi
 
42
done
 
43
done
 
44
 
 
45
# Check if a PV has unignored (used) mdas, and if so, ignore
 
46
pvignore_ () {
 
47
        pv_mda_used_count=$(get pv_field "$1" pv_mda_used_count)
 
48
        if [ $pv_mda_used_count -ne 0 ]; then
 
49
            pvchange --metadataignore y $1
 
50
        fi
 
51
}
 
52
 
 
53
# Check if a PV has ignored mdas, and if so, unignore (make used)
 
54
pvunignore_ () {
 
55
        pv_mda_count=$(get pv_field "$1" pv_mda_count)
 
56
        pv_mda_used_count=$(get pv_field "$1" pv_mda_used_count)
 
57
        if [ $pv_mda_count -gt $pv_mda_used_count ]; then
 
58
            pvchange --metadataignore n $1
 
59
        fi
 
60
}
 
61
 
 
62
echo Test of vgmetadatacopies with vgcreate and vgchange
 
63
for mdacp in 1 2; do
 
64
        pvcreate --metadatacopies $mdacp $dev1 $dev2 $dev4 $dev5
 
65
        check pv_field $dev1 pv_mda_used_count $mdacp
 
66
        check pv_field $dev2 pv_mda_used_count $mdacp
 
67
        check pv_field $dev4 pv_mda_used_count $mdacp
 
68
        check pv_field $dev5 pv_mda_used_count $mdacp
 
69
        pvcreate --metadatacopies 0 $dev3
 
70
        vgcreate -c n "$vg" $dev1 $dev2 $dev3
 
71
        check vg_field $vg vg_mda_copies unmanaged
 
72
        echo ensure both --vgmetadatacopies and --metadatacopies accepted
 
73
        vgchange --metadatacopies $(($mdacp * 1)) $vg
 
74
        echo --vgmetadatacopies is persistent on disk
 
75
        echo --vgmetadatacopies affects underlying pv mda ignore
 
76
        check vg_field $vg vg_mda_copies $(($mdacp * 1))
 
77
        check vg_field $vg vg_mda_used_count $(($mdacp * 1))
 
78
        vgchange --vgmetadatacopies $(($mdacp * 2)) $vg
 
79
        check vg_field $vg vg_mda_copies $(($mdacp * 2))
 
80
        check vg_field $vg vg_mda_used_count $(($mdacp * 2))
 
81
        echo allow setting metadatacopies larger than number of PVs
 
82
        vgchange --vgmetadatacopies $(($mdacp * 5)) $vg
 
83
        check vg_field $vg vg_mda_copies $(($mdacp * 5))
 
84
        check vg_field $vg vg_mda_used_count $(($mdacp * 2))
 
85
        echo setting to 0 disables automatic balancing
 
86
        vgchange --vgmetadatacopies unmanaged $vg
 
87
        check vg_field $vg vg_mda_copies unmanaged
 
88
        vgremove -f $vg
 
89
        echo vgcreate succeeds even when creating a VG w/all ignored mdas
 
90
        pvchange --metadataignore y $dev1 $dev2
 
91
        check pv_field $dev1 pv_mda_count $mdacp
 
92
        check pv_field $dev2 pv_mda_used_count 0
 
93
        vgcreate -c n "$vg" $dev1 $dev2
 
94
        check vg_field $vg vg_mda_copies unmanaged
 
95
        vgremove -f $vg
 
96
        echo vgcreate succeeds with a specific number of metadata copies
 
97
        vgcreate -c n --vgmetadatacopies $(($mdacp * 2)) "$vg" $dev1 $dev2
 
98
        check vg_field $vg vg_mda_copies $(($mdacp * 2))
 
99
        vgremove -f $vg
 
100
        vgcreate -c n --vgmetadatacopies $(($mdacp * 1)) "$vg" $dev1 $dev2
 
101
        check vg_field $vg vg_mda_copies $(($mdacp * 1))
 
102
        vgremove -f $vg
 
103
        echo vgcreate succeeds with a larger value than total metadatacopies
 
104
        vgcreate -c n --vgmetadatacopies $(($mdacp * 5)) "$vg" $dev1 $dev2
 
105
        check vg_field $vg vg_mda_copies $(($mdacp * 5))
 
106
        vgremove -f $vg
 
107
        echo vgcreate succeeds with --vgmetadatacopies unmanaged
 
108
        vgcreate -c n --vgmetadatacopies unmanaged "$vg" $dev1 $dev2
 
109
        check vg_field $vg vg_mda_copies unmanaged
 
110
        vgremove -f $vg
 
111
        pvunignore_ $dev1
 
112
        pvunignore_ $dev2
 
113
        pvunignore_ $dev4
 
114
        pvunignore_ $dev5
 
115
        echo vgcreate succeds with small value of --metadatacopies, ignores mdas
 
116
        vgcreate -c n --vgmetadatacopies 1 "$vg" $dev1 $dev2 $dev4 $dev5
 
117
        check vg_field $vg vg_mda_copies 1
 
118
        check vg_field $vg vg_mda_count $(($mdacp * 4))
 
119
        check vg_field $vg vg_mda_used_count 1
 
120
        echo Setting a larger value should trigger non-ignore of mdas
 
121
        vgchange --metadatacopies 3 $vg
 
122
        check vg_field $vg vg_mda_copies 3
 
123
        check vg_field $vg vg_mda_used_count 3
 
124
        echo Setting all should trigger unignore of all mdas
 
125
        vgchange --vgmetadatacopies all $vg
 
126
        check vg_field $vg vg_mda_count $(($mdacp * 4))
 
127
        check vg_field $vg vg_mda_copies unmanaged
 
128
        check vg_field $vg vg_mda_used_count $(($mdacp * 4))
 
129
        echo --vgmetadatacopies 0 should be unmanaged for vgchange and vgcreate
 
130
        vgchange --vgmetadatacopies 0 $vg
 
131
        check vg_field $vg vg_mda_copies unmanaged
 
132
        vgremove -f $vg
 
133
        vgcreate -c n --vgmetadatacopies 0 "$vg" $dev1 $dev2 $dev4 $dev5
 
134
        check vg_field $vg vg_mda_copies unmanaged
 
135
        vgremove -f $vg
 
136
done
 
137
 
 
138
echo Test vgextend / vgreduce with vgmetadatacopies
 
139
for mdacp in 1 2; do
 
140
        pvcreate --metadatacopies $mdacp $dev1 $dev2 $dev4 $dev5
 
141
        pvcreate --metadatacopies 0 $dev3
 
142
        echo Set a large value of vgmetadatacopies
 
143
        vgcreate -c n --vgmetadatacopies $(($mdacp * 5)) "$vg" $dev1 $dev2 $dev3
 
144
        check vg_field $vg vg_mda_copies $(($mdacp * 5))
 
145
        echo Ignore mdas on devices to be used for vgextend
 
146
        echo Large value of vgetadatacopies should automatically un-ignore mdas
 
147
        pvchange --metadataignore y $dev4 $dev5
 
148
        check pv_field $dev4 pv_mda_used_count 0
 
149
        vgextend $vg $dev4 $dev5
 
150
        check pv_field $dev4 pv_mda_used_count $mdacp
 
151
        check pv_field $dev5 pv_mda_used_count $mdacp
 
152
        vgremove -f $vg
 
153
        echo Set a small value of vgmetadatacopies
 
154
        vgcreate -c n --vgmetadatacopies $(($mdacp * 1)) "$vg" $dev1 $dev2 $dev3
 
155
        check vg_field $vg vg_mda_copies $(($mdacp * 1))
 
156
        echo Ignore mdas on devices to be used for vgextend
 
157
        echo Small value of vgetadatacopies should leave mdas as ignored
 
158
        pvchange --metadataignore y $dev4 $dev5
 
159
        check pv_field $dev4 pv_mda_used_count 0
 
160
        vgextend $vg $dev4 $dev5
 
161
        check pv_field $dev4 pv_mda_used_count 0
 
162
        check pv_field $dev5 pv_mda_used_count 0
 
163
        echo vgreduce of ignored pv w/mda should not trigger any change to ignore bits
 
164
        vgreduce $vg $dev4
 
165
        check pv_field $dev4 pv_mda_used_count 0
 
166
        check pv_field $dev5 pv_mda_used_count 0
 
167
        echo vgreduce of un-ignored pv w/mda should trigger un-ignore on an mda
 
168
        vgreduce $vg $dev1 $dev2 $dev3
 
169
        check pv_field $dev5 pv_mda_used_count $mdacp
 
170
        check vg_field $vg vg_mda_copies $(($mdacp * 1))
 
171
        pvunignore_ $dev1
 
172
        pvunignore_ $dev2
 
173
        echo setting vgmetadatacopies to unmanaged should allow vgextend to add w/out balancing
 
174
        vgchange --vgmetadatacopies unmanaged $vg
 
175
        vgextend $vg $dev1 $dev2
 
176
        check vg_field $vg vg_mda_copies unmanaged
 
177
        check vg_field $vg vg_mda_count $(($mdacp * 3))
 
178
        check vg_field $vg vg_mda_used_count $((mdacp * 3))
 
179
        check pv_field $dev1 pv_mda_used_count $mdacp
 
180
        check pv_field $dev2 pv_mda_used_count $mdacp
 
181
        vgremove -f $vg
 
182
done
 
183
 
 
184
echo Test special situations, vgsplit, vgmerge, etc
 
185
for mdacp in 1 2; do
 
186
        pvcreate --metadatacopies $mdacp $dev1 $dev2 $dev3 $dev4 $dev5
 
187
        vgcreate -c n --vgmetadatacopies 2 $vg1 $dev1 $dev2 $dev3
 
188
        vgcreate -c n --vgmetadatacopies $(($mdacp * 1)) $vg2 $dev4 $dev5
 
189
        echo vgsplit/vgmerge preserves value of metadata copies
 
190
        check vg_field $vg1 vg_mda_copies 2
 
191
        check vg_field $vg2 vg_mda_copies $(($mdacp * 1))
 
192
        vgsplit $vg1 $vg2 $dev1
 
193
        check vg_field $vg2 vg_mda_copies $(($mdacp * 1))
 
194
        vgmerge $vg1 $vg2
 
195
        check vg_field $vg1 vg_mda_copies 2
 
196
        check vg_field $vg1 vg_mda_count $(($mdacp * 5))
 
197
        echo vgsplit into new vg sets proper value of vgmetadatacopies
 
198
        vgsplit --vgmetadatacopies $(($mdacp * 2)) $vg1 $vg2 $dev1 $dev2
 
199
        check vg_field $vg2 vg_mda_copies $(($mdacp * 2))
 
200
        echo vgchange fails if given both vgmetadatacopies and metadatacopies
 
201
        not vgchange --vgmetadatacopies 5 --metadatacopies 7 $vg2
 
202
        vgremove -f $vg1
 
203
        vgremove -f $vg2
 
204
done
 
205
 
 
206
echo Test combination of --vgmetadatacopies and pvchange --metadataignore
 
207
for mdacp in 1 2; do
 
208
        pvcreate --metadatacopies $mdacp $dev1 $dev2 $dev3 $dev4 $dev5
 
209
        vgcreate -c n --vgmetadatacopies $(($mdacp * 1)) $vg1 $dev1 $dev2
 
210
        check vg_field $vg1 vg_mda_copies $(($mdacp * 1))
 
211
        check vg_field $vg1 vg_mda_used_count $(($mdacp * 1))
 
212
        pvignore_ $dev3
 
213
        echo Ensure vgextend of PVs with ignored MDAs does not add to vg_mda_used_count
 
214
        vgextend $vg1 $dev3
 
215
        check vg_field $vg1 vg_mda_used_count $(($mdacp * 1))
 
216
        echo Using pvchange to unignore should update vg_mda_used_count
 
217
        pvchange -f --metadataignore n $dev3
 
218
        check pv_field $dev3 pv_mda_used_count $mdacp
 
219
        check vg_field $vg1 vg_mda_used_count $(($mdacp * 2))
 
220
        echo Set unmanaged on the vg should keep ignore bits the same during vgextend
 
221
        vgchange --vgmetadatacopies unmanaged $vg1
 
222
        check vg_field $vg1 vg_mda_used_count $(($mdacp * 2))
 
223
        pvunignore_ $dev4
 
224
        vgextend $vg1 $dev4
 
225
        check pv_field $dev4 pv_mda_used_count $mdacp
 
226
        check vg_field $vg1 vg_mda_used_count $(($mdacp * 3))
 
227
        echo Using pvchange to ignore should update vg_mda_used_count
 
228
        pvchange -f --metadataignore y $dev4
 
229
        check pv_field $dev4 pv_mda_used_count 0
 
230
        check vg_field $vg1 vg_mda_used_count $(($mdacp * 2))
 
231
        vgremove -f $vg1
 
232
done