[Cluster-devel] cluster/rgmanager/src/resources lvm.sh

jbrassow at sourceware.org jbrassow at sourceware.org
Wed May 9 20:50:51 UTC 2007


CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL4
Changes by:	jbrassow at sourceware.org	2007-05-09 20:50:51

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

Log message:
	If misconfigured, HA LVM + mirroring can cause data corruption.  We should
	attempt to catch configuration errors before allowing LVM resources to start.

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

--- cluster/rgmanager/src/resources/lvm.sh	2007/05/09 18:03:28	1.1.2.4
+++ cluster/rgmanager/src/resources/lvm.sh	2007/05/09 20:50:51	1.1.2.5
@@ -432,6 +432,32 @@
 	return $OCF_SUCCESS
 }
 
+ha_lvm_proper_setup_check()
+{
+	# First, let's check that they have setup their lvm.conf correctly
+	if ! lvm dumpconfig activation/volume_list >& /dev/null ||
+	   ! lvm dumpconfig activation/volume_list | grep $(local_node_name); then
+		ocf_log err "lvm.conf improperly configured for HA LVM."
+		return $OCF_ERR_GENERIC
+	fi
+
+	# Next, we need to ensure that their initrd has been updated
+	if [ -e /boot/initrd-`uname -r`.img ]; then
+		if [ "$(find /boot/initrd-`uname -r`.img -newer /etc/lvm/lvm.conf)" == "" ]; then
+			ocf_log err "HA LVM requires the initrd image to be newer than lvm.conf"
+			return $OCF_ERR_GENERIC
+		fi
+	else
+		# Best guess...
+		if [ "$(find /boot/*.img -newer /etc/lvm/lvm.conf)" == "" ]; then
+			ocf_log err "HA LVM requires the initrd image to be newer than lvm.conf"
+			return $OCF_ERR_GENERIC
+		fi
+	fi
+
+	return $OCF_SUCCESS
+}
+
 case $1 in
 start)
 	if [[ $(vgs -o attr --noheadings $OCF_RESKEY_vg_name) =~ .....c ]]; then
@@ -439,6 +465,8 @@
 		exit 0
 	fi
 
+	ha_lvm_proper_setup_check || exit 1
+		
 	if [ -z $OCF_RESKEY_lv_name ]; then
 		vg_activate start || exit 1
 	else
@@ -462,6 +490,10 @@
 		exit 0
 	fi
 
+	if ! ha_lvm_proper_setup_check; then
+		ocf_log err "WARNING: An improper setup can cause data corruption!"
+	fi
+
 	if [ -z $OCF_RESKEY_lv_name ]; then
 		vg_activate stop || exit 1
 	else




More information about the Cluster-devel mailing list