Re: [Linux-ha-dev] Patch : ocf/resource.d/heartbeat/Filesystem: Use /proc/mounts if available since /etc/mtab might be outdated

2011-03-23 Thread Corvus Corax
Am Wed, 23 Mar 2011 13:47:34 +0100
schrieb Lars Marowsky-Bree l...@novell.com:

 On 2011-03-23T11:50:02, Lars Ellenberg lars.ellenb...@linbit.com wrote:
 
# Take advantage of /etc/mtab if present, use portable mount command
# otherwise. Normalize format to dev mountpoint fstype.
 
 I wonder if we shouldn't just always rely on mount and insist on that
 providing proper data.
 
 Re-implementing mount seems like a bad idea. If more extensive checks
 than a binary mounted xor not are needed, this would be noticed by the
 deeper monitor levels or the application-level monitor, no?
 
 
 Regards,
 Lars
 

I had a weird case in which a filesystem (GFS2) had gotten unmounted
without /etc/mtab being modified.

It is possible to enforce that behavour by calling the umount() system
call directly from any program that has sufficient privileges.
(For example by executing `umount mountpoint -n` )

It can apparently also happen if a hardware (or in this case network)
caused event leads to a unmount by the kernel.

mount without arguments as well as the the filesystem resource agent
both still list the filesystem as mounted, simply because BOTH just
look at /etc/mtab. The application level resource agent of course
noticed the errors, but were unable to recover (the application on
course depends on its filesystem being mounted) pacemaker did not
remount the filesystem because the resource agents monitor() function
did not notice that it wasn't.

I agree, the correct way of doing this would be to use a system tool
that lists all mounted filesystems for us, regardless of the actual
system used. However `mount` is the wrong tool, since `mount` without
parameters only prints out thew contents of /etc/mtab (even if given an
additional -n flag this doesn't change) and as such is not suitable
as a `monitor()` IMHO.

Currently neither /etc/mtab nor `mount` are reliable to monitor the
mount state of a device or mountpoint. /proc/mounts is accurate with
some limitations.

regards

Corvus
___
Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/


[Linux-ha-dev] Patch : ocf/resource.d/heartbeat/Filesystem: Use /proc/mounts if available since /etc/mtab might be outdated

2011-03-22 Thread Corvus Corax


-- 
Eric Price
Linux Solutions / Development

Lightwerk GmbH - www.lightwerk.com
Schulze-Delitzsch-Str. 38, 70565 Stuttgart
E-Mail: e...@lightwerk.com

Geschäftsführender Gesellschafter: Veikko Wünsche
Amtsgericht Stuttgart, HRB 22214
Ust.-ID: DE 813315708

--- Filesystem	2011-03-22 14:49:58.103845191 +0100
+++ Filesystem_lw	2011-03-22 14:49:32.396825985 +0100
@@ -186,7 +186,9 @@
 # Take advantage of /etc/mtab if present, use portable mount command
 # otherwise. Normalize format to dev mountpoint fstype.
 list_mounts() {
-	if [ -f /etc/mtab -a -r /etc/mtab ]; then
+	if [ -f /proc/mounts -a -r /proc/mounts ]; then
+		cut -d' ' -f1,2,3 /proc/mounts
+	elif [ -f /etc/mtab -a -r /etc/mtab ]; then
 		cut -d' ' -f1,2,3 /etc/mtab
 	else
 		$MOUNT | cut -d' ' -f1,3,5
___
Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/


[Linux-ha-dev] Patch to ocf:heartbeat:IPaddr2 to check if link status is up

2011-03-16 Thread Corvus Corax

IPAddr2 puts the interface up on start and down on stop.
But its not able to detect an UP or DOWN change in status or monitor.

Therefore an ifconfig interface down from a thrird program or a
careless administrator would drop the link without pacemaker noticing!

The attached patch tries to fix that

-- 
Eric Price
Linux Solutions / Development

Lightwerk GmbH - www.lightwerk.com
Schulze-Delitzsch-Str. 38, 70565 Stuttgart
E-Mail: e...@lightwerk.com

Geschäftsführender Gesellschafter: Veikko Wünsche
Amtsgericht Stuttgart, HRB 22214
Ust.-ID: DE 813315708

--- IPaddr2	2011-03-16 15:54:46.359554666 +0100
+++ IPaddr2_lw	2011-03-16 16:38:33.728562036 +0100
@@ -364,10 +364,21 @@
 	echo $iface
 	return 0
 }
 
 #
+#	Check interface status (up or down)
+#	The argument is an interface name (e.g. eth0)
+#
+interface_down() {
+	if $IP2UTIL -o -f inet link show $1 | grep state UP /dev/null; then
+		return 1
+	fi
+	return 0
+}
+
+#
 #Delete an interface
 #
 delete_interface () {
 	ipaddr=$1
 	iface=$2
@@ -572,20 +583,31 @@
 return 0
 			fi
 			;;
 		esac
 
+		if interface_down $cur_nic; then
+			echo partial3
+			return 0
+		fi
+
 		echo ok
 		return 0
 	fi
 
 	# Special handling for the CIP:
 	if [ ! -e $IP_CIP_FILE ]; then
 		echo partial2
 		return 0
 	fi
 	if egrep -q (^|,)${IP_INC_NO}(,|$) $IP_CIP_FILE ; then
+
+		if interface_down $cur_nic; then
+			echo partial3
+			return 0
+		fi
+
 		echo ok
 		return 0
 	else
 		echo partial
 		return 0
@@ -620,10 +642,19 @@
 	#
 	#	Do we already service this IP address?
 	#
 	local ip_status=`ip_served`
 
+	# yes, but interface is down, bring it up!
+	if [ $ip_status = partial3 ]; then
+		CMD=$IP2UTIL link set $NIC up
+
+		ocf_log info $CMD
+		$CMD
+		ip_status=`ip_served`
+	fi
+
 	if [ $ip_status = ok ]; then
 		exit $OCF_SUCCESS
 	fi
 	
 	if [ -n $IP_CIP ]  [ $ip_status = no ] || [ $ip_status = partial2 ]; then
___
Linux-HA-Dev: Linux-HA-Dev@lists.linux-ha.org
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/