Skip to contentSkip to conversation

cluster/rgmanager/src/resources lvm.sh

Cluster-devel [email protected] 1 participant 1 message Jul 2, 2007

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/cluster
Module name: cluster
Changes by: jbrassow at sourceware.org 2007-07-02 21:58:34

Modified files:
rgmanager/src/resources: lvm.sh

Log message:
<Previous check-in>
Require vg_name to be unique. Allowing multiple LVs from the same VG on different machines can lead to races when updating metadata during device failures.
</Previous check-in>

We can do better. This patch puts the validation in lvm.sh so that it can print out a understandable error message.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/lvm.sh.diff?cvsroot=cluster&r1=1.8&r2=1.9

rgmanager/src/resources/lvm.sh +12 -1
@@ -71,7 +71,7 @@
 	    <content type="string"/>
         </parameter>
 
-        <parameter name="vg_name" required="1" unique="1">
+        <parameter name="vg_name" required="1">
             <longdesc lang="en">
                 If you can see this, your GUI is broken.
             </longdesc>
@@ -465,6 +465,17 @@
 		exit 0
 	fi
 
+	if ! lvs $OCF_RESKEY_vg_name >& /dev/null; then
+		lv_count=0
+	else
+		lv_count=`lvs --noheadings -o name $OCF_RESKEY_vg_name | grep -v _mlog | grep -v _mimage | grep -v nconsistent | wc -l`
+	fi
+	if [ $lv_count -gt 1 ]; then
+		ocf_log err "HA LVM requires Only one logical volume per volume group."
+		ocf_log err "There are currently $lv_count logical volumes in $OCF_RESKEY_vg_name"
+		ocf_log err "Failing HA LVM start of $OCF_RESKEY_vg_name/$OCF_RESKEY_lv_name"
+		exit $OCF_ERR_GENERIC
+	fi
 	ha_lvm_proper_setup_check || exit 1
 		
 	if [ -z $OCF_RESKEY_lv_name ]; then