Sync usage with man page.
[netbsd-mini2440.git] / external / gpl2 / lvm2 / dist / test / t-mirror-lvconvert-usage.sh
blobd27c1b30ab1541fec12bef04e7af0bbaf06d1216
1 # Copyright (C) 2008 Red Hat, Inc. All rights reserved.
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.
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
11 . ./test-utils.sh
13 dmsetup_has_dm_devdir_support_ || exit 200
15 aux prepare_vg 5
18 lv_is_on_() {
19 local lv=$1 #allready vg/lv
20 shift 1
21 lvs -a -odevices --noheadings $lv | sed 's/,/\n/g' > out
22 #is on all specified devs
23 for d in $*; do grep "$d(" out; done
24 #isn't on any other dev (we are set -e remember)
25 for d in $*; do ! grep -v "$d(" out; done
26 return 0
29 mimages_are_on_ ()
31 local lv=$1
32 shift
33 local pvs="$*"
34 local mimages
35 local i
37 echo "Check if mirror images of $lv are on PVs $pvs"
38 rm -f out1 out2
39 echo $pvs | sed 's/ /\n/g' | sort | uniq > out1
41 mimages=$(lvs --noheadings -a -o lv_name $vg | grep "${lv}_mimage_" | \
42 sed 's/\[//g; s/\]//g')
43 for i in $mimages; do
44 echo "Checking $vg/$i"
45 lvs -a -odevices --noheadings $vg/$i | \
46 sed 's/([^)]*)//g; s/ //g; s/,/ /g' | sort | uniq >> out2
47 done
49 diff --ignore-blank-lines out1 out2
52 # ---------------------------------------------------------------------
53 # Common environment setup/cleanup for each sub testcases
55 prepare_lvs_()
57 lvremove -ff $vg
58 if dmsetup table|grep $vg; then
59 echo "ERROR: lvremove did leave some some mappings in DM behind!"
60 return 1
65 check_and_cleanup_lvs_()
67 lvs -a -o+devices $vg
68 lvremove -ff $vg
69 if dmsetup table|grep $vg; then
70 echo "ERROR: lvremove did leave some some mappings in DM behind!"
71 return 1
75 prepare_lvs_
76 check_and_cleanup_lvs_
79 #COMM "convert from 2-way mirror to linear -- specify leg to remove (bz453643)"
80 prepare_lvs_
81 lvcreate -l2 -m1 -n $lv1 $vg $dev1 $dev2 $dev3:0-1
82 lvconvert -m0 $vg/$lv1 $dev2
83 lv_is_on_ $vg/$lv1 $dev1
84 check_and_cleanup_lvs_
86 prepare_lvs_
87 lvcreate -l2 -m2 -n $lv1 $vg $dev1 $dev2 $dev4 $dev3:0-1
88 lvconvert -m-1 $vg/$lv1 $dev1
89 lvs -a -o+devices
90 mimages_are_on_ $lv1 $dev2 $dev4
91 lvconvert -m-1 $vg/$lv1 $dev2
92 lvs -a -o+devices
93 lv_is_on_ $vg/$lv1 $dev4
94 check_and_cleanup_lvs_