Send Linux-ha-cvs mailing list submissions to linux-ha-cvs@lists.linux-ha.org
To subscribe or unsubscribe via the World Wide Web, visit http://lists.community.tummy.com/mailman/listinfo/linux-ha-cvs or, via email, send a message with subject or body 'help' to [EMAIL PROTECTED] You can reach the person managing the list at [EMAIL PROTECTED] When replying, please edit your Subject line so it is more specific than "Re: Contents of Linux-ha-cvs digest..." Today's Topics: 1. Linux-HA CVS: resources by lars from (linux-ha-cvs@lists.linux-ha.org) 2. Linux-HA CVS: resources by lars from (linux-ha-cvs@lists.linux-ha.org) ---------------------------------------------------------------------- Message: 1 Date: Wed, 21 Jun 2006 13:04:04 -0600 (MDT) From: linux-ha-cvs@lists.linux-ha.org Subject: [Linux-ha-cvs] Linux-HA CVS: resources by lars from To: [EMAIL PROTECTED] Message-ID: <[EMAIL PROTECTED]> linux-ha CVS committal Author : lars Host : Project : linux-ha Module : resources Dir : linux-ha/resources/OCF Modified Files: Filesystem.in Log Message: Large overhaul of Filesystem_stop. Checkpoint commit. Addresses: - Filesystem_status was using /proc/mounts, which is unportable. Encapsulate into list_mounts() function which takes advantage of this if present, and calls mount otherwise. - Unify handling of nested mounts with the handling of the mount itself. - Never call fuser if the attempt to umount succeeded, but return success directly. - If it didn't, send signals, sleep a bit, retry. - Use umount -f for network filesystems. - No need to call umount or fuser differently for block device mounts or others; using the mountpoint always works. - Reindent Filesystem_stop() be at least consistent with _some_ other parts of the script. ;-) - Split out OCFS2 specific handling in stop code path. =================================================================== RCS file: /home/cvs/linux-ha/linux-ha/resources/OCF/Filesystem.in,v retrieving revision 1.28 retrieving revision 1.29 diff -u -3 -r1.28 -r1.29 --- Filesystem.in 14 Jun 2006 13:48:20 -0000 1.28 +++ Filesystem.in 21 Jun 2006 19:04:03 -0000 1.29 @@ -1,6 +1,6 @@ #!/bin/sh # -# $Id: Filesystem.in,v 1.28 2006/06/14 13:48:20 lars Exp $ +# $Id: Filesystem.in,v 1.29 2006/06/21 19:04:03 lars Exp $ # # Support: [EMAIL PROTECTED] # License: GNU General Public License (GPL) @@ -95,7 +95,7 @@ usage() { cat <<-EOT usage: $0 {start|stop|status|monitor|validate-all|meta-data} - $Id: Filesystem.in,v 1.28 2006/06/14 13:48:20 lars Exp $ + $Id: Filesystem.in,v 1.29 2006/06/21 19:04:03 lars Exp $ EOT } @@ -196,6 +196,22 @@ return 0 } +# Take advantage of /proc/mounts if present, use portabel mount command +# otherwise. Normalize format to "dev mountpoint fstype". +list_mounts() { + if [ -f "/proc/mounts" -a -r "/proc/mounts" ]; then + cut -d' ' -f1,2,3 </proc/mounts + else + $MOUNT | cut -d' ' -f1,3,5 + fi +} + +# Lists all filesystems potentially mounted under a given path, +# excluding the path itself. +list_submounts() { + list_mounts | grep " $1/" | cut -d' ' -f2 | sort -r +} + # # START: Start up the filesystem # @@ -432,62 +448,7 @@ done } -# -# STOP: Unmount the filesystem -# -Filesystem_stop() -{ - # See if the device is currently mounted - Filesystem_status >/dev/null 2>&1 - if [ $? -ne $OCF_NOT_RUNNING ]; then - # Umount all sub-filesystems mounted under $MOUNTPOINT/ - # (e.g. /proc in chroots) - for SUB in `$MOUNT | grep "on $MOUNTPOINT/" | cut -d' ' -f3 | tac` ; do - $FUSER -m -k $SUB - $UMOUNT $SUB - done - - # By sending both signals twice, we eliminate the need - # for `sleep` after them. - for sig in SIGTERM SIGTERM SIGKILL SIGKILL; do - if [ $blockdevice = "yes" ]; then - $FUSER -$sig -m -k $DEVICE - else - $FUSER -$sig -m -k $MOUNTPOINT - fi - # fuser returns a non-zero return code if none of the - # specified files is accessed or in case of a fatal - # error, in either case we stop sending signal. If at - # least one access has been found, fuser returns zero, - # then we should try it again. - if [ $? -ne 0 ]; then - break - fi - done - - rc=$OCF_SUCCESS - if [ $blockdevice = "yes" ]; then - $UMOUNT $DEVICE - DEV=$DEVICE - else - # Get the current real device name... - # (specified devname could be -L or -U...) - - DEV=`$MOUNT | grep "on $MOUNTPOINT " | cut -d' ' -f1` - # Unmount the filesystem - $UMOUNT $MOUNTPOINT - fi - - if [ $? -ne 0 ] ; then - ocf_log err "Couldn't unmount $MOUNTPOINT" - rc=$OCF_ERR_GENERIC - fi - flushbufs $DEV - else - # $MOUNTPOINT Not mounted. No problema! - rc=$OCF_SUCCESS - fi - +ocfs2_cleanup() { # We'll never see the post-stop notification. We're gone now, # have unmounted, and thus should remove the membership. # @@ -495,16 +456,87 @@ # because the admin might have manually unmounted but not # cleared up the membership directory. Bad admin, no cookie.) # - if [ "$FSTYPE" = "ocfs2" ]; then - if [ ! -d "$OCFS2_FS_ROOT" ]; then - ocf_log info "$OCFS2_FS_ROOT: Filesystem membership already gone." - else - ocf_log info "$OCFS2_FS_ROOT: Removing membership directory." - rm -rf $OCFS2_FS_ROOT/ - fi + if [ ! -d "$OCFS2_FS_ROOT" ]; then + ocf_log info "$OCFS2_FS_ROOT: Filesystem membership already gone." + else + ocf_log info "$OCFS2_FS_ROOT: Removing membership directory." + rm -rf $OCFS2_FS_ROOT/ fi - - return $rc +} + +determine_blockdevice() { + if [ $blockdevice == "yes" ]; then + return + fi + + # Get the current real device name, if possible. + # (specified devname could be -L or -U...) + case "$FSTYPE" in + nfs|smbfs|cifs) ;; + *) DEVICE=`list_mounts | grep " $MOUNTPOINT " | cut -d' ' -f1` + if [ -b "$DEVICE" ]; then + blockdevice=yes + fi + ;; + esac +} + +# +# STOP: Unmount the filesystem +# +Filesystem_stop() +{ + # See if the device is currently mounted + Filesystem_status >/dev/null 2>&1 + if [ $? -ne $OCF_NOT_RUNNING ]; then + # Determine the real blockdevice this is mounted on (if + # possible) prior to unmounting. + determine_blockdevice + + # For networked filesystems, there's merit in trying -f: + case "$FSTYPE" in + nfs|cifs|smbfs) umount_force="-f" ;; + esac + + # Umount all sub-filesystems mounted under $MOUNTPOINT/ too. + for SUB in `list_submounts $MOUNTPOINT` $MOUNTPOINT; do + ocf_log info "Trying to unmount $MOUNTPOINT" + for sig in SIGTERM SIGTERM SIGTERM SIGKILL SIGKILL SIGKILL; do + if $UMOUNT $umount_force $SUB ; then + rc=$OCF_SUCCESS + ocf_log info "unmounted $SUB successfully" + break + else + rc=$OCF_ERR_GENERIC + ocf_log err "Couldn't unmount $SUB; trying cleanup with $sig" + # fuser returns a non-zero return code if none of the + # specified files is accessed or in case of a fatal + # error. + if $FUSER -$sig -m -k $SUB ; then + ocf_log info "Some processes on $SUB were signalled" + else + ocf_log info "No processes on $SUB were signalled" + fi + sleep 1 + fi + done + + if [ $rc -ne $OCF_SUCCESS ]; then + ocf_log err "Couldn't unmount $SUB, giving up!" + fi + done + else + # Already unmounted, wonderful. + rc=$OCF_SUCCESS + fi + + flushbufs $DEVICE + + if [ "$FSTYPE" = "ocfs2" ]; then + ocfs2_cleanup + fi + + return $rc } # end of Filesystem_stop @@ -514,14 +546,7 @@ Filesystem_status() { if - [ $blockdevice = "yes" ] - then - greppat="^$DEVICE $MOUNTPOINT " - else - greppat=" $MOUNTPOINT " - fi - if - grep -q -e "${greppat}" /proc/mounts >/dev/null 2>&1 + list_mounts | grep -q " $MOUNTPOINT " >/dev/null 2>&1 then rc=$OCF_SUCCESS msg="$MOUNTPOINT is mounted (running)" @@ -554,6 +579,7 @@ # Check if the $FSTYPE is workable # NOTE: Without inserting the $FSTYPE module, this step may be imprecise +# TODO: This is Linux specific crap. if [ ! -z $FSTYPE ]; then cut -f2 /proc/filesystems |grep -q ^$FSTYPE$ if [ $? -ne 0 ]; then ------------------------------ Message: 2 Date: Wed, 21 Jun 2006 14:43:01 -0600 (MDT) From: linux-ha-cvs@lists.linux-ha.org Subject: [Linux-ha-cvs] Linux-HA CVS: resources by lars from To: [EMAIL PROTECTED] Message-ID: <[EMAIL PROTECTED]> linux-ha CVS committal Author : lars Host : Project : linux-ha Module : resources Dir : linux-ha/resources/OCF Modified Files: Filesystem.in Log Message: Logging changes, less noisy on monitor ops now for OCFS2. =================================================================== RCS file: /home/cvs/linux-ha/linux-ha/resources/OCF/Filesystem.in,v retrieving revision 1.29 retrieving revision 1.30 diff -u -3 -r1.29 -r1.30 --- Filesystem.in 21 Jun 2006 19:04:03 -0000 1.29 +++ Filesystem.in 21 Jun 2006 20:43:00 -0000 1.30 @@ -1,6 +1,6 @@ #!/bin/sh # -# $Id: Filesystem.in,v 1.29 2006/06/21 19:04:03 lars Exp $ +# $Id: Filesystem.in,v 1.30 2006/06/21 20:43:00 lars Exp $ # # Support: [EMAIL PROTECTED] # License: GNU General Public License (GPL) @@ -95,7 +95,7 @@ usage() { cat <<-EOT usage: $0 {start|stop|status|monitor|validate-all|meta-data} - $Id: Filesystem.in,v 1.29 2006/06/21 19:04:03 lars Exp $ + $Id: Filesystem.in,v 1.30 2006/06/21 20:43:00 lars Exp $ EOT } @@ -222,6 +222,7 @@ # we're being started means we didn't get the # pre-notification, because we weren't running, so # process the information now first. + ocf_log info "$OCFS2_UUID: Faking pre-notification on start." OCF_RESKEY_CRM_meta_notify_type="pre" OCF_RESKEY_CRM_meta_notify_operation="start" Filesystem_notify @@ -346,17 +347,17 @@ local n_stop="$OCF_RESKEY_CRM_meta_notify_stop_uname" local n_start="$OCF_RESKEY_CRM_meta_notify_start_uname" - ocf_log debug "$OCFS2_UUID - notify: $n_type for $n_op" - ocf_log debug "$OCFS2_UUID - notify active: $n_active" - ocf_log debug "$OCFS2_UUID - notify stop: $n_stop" - ocf_log debug "$OCFS2_UUID - notify start: $n_start" + ocf_log info "$OCFS2_UUID: notify: $n_type for $n_op" + ocf_log info "$OCFS2_UUID: notify active: $n_active" + ocf_log info "$OCFS2_UUID: notify stop: $n_stop" + ocf_log info "$OCFS2_UUID: notify start: $n_start" case "$n_type" in pre) case "$n_op" in stop) - ocf_log debug "$OCFS2_UUID: ignoring pre-notify for stop." - return $OCF_SUCCESS + ocf_log info "$OCFS2_UUID: ignoring pre-notify for stop." + return $infoUCCESS ;; start) # These are about to become active; prepare to @@ -376,7 +377,7 @@ ;; start) if [ "$n_op" = "start" ]; then - ocf_log debug "$OCFS2_UUID: ignoring post-notify for start." + ocf_log info "$OCFS2_UUID: ignoring post-notify for start." return $OCF_SUCCESS fi ;; @@ -384,10 +385,10 @@ ;; esac - ocf_log debug "$OCFS2_UUID - post-processed active: $n_active" + ocf_log info "$OCFS2_UUID: post-processed active: $n_active" local n_myself=${HA_CURHOST:-$(uname -n | tr A-Z a-z)} - ocf_log debug "$OCFS2_UUID: I am node $n_myself." + ocf_log info "$OCFS2_UUID: I am node $n_myself." case " $n_active " in *" $n_myself "*) ;; @@ -400,13 +401,13 @@ entry_prefix=$OCFS2_FS_ROOT/ for entry in $OCFS2_FS_ROOT/* ; do n_fs="${entry##$entry_prefix}" -# ocf_log debug "$OCFS2_UUID: Found current node $n_fs" +# ocf_log info "$OCFS2_UUID: Found current node $n_fs" case " $n_active " in *" $n_fs "*) # Construct a list of nodes which are present # already in the membership. n_exists="$n_exists $n_fs" - ocf_log debug "$OCFS2_UUID: Keeping node: $n_fs" + ocf_log info "$OCFS2_UUID: Keeping node: $n_fs" ;; *) # Node is in the membership currently, but not on our @@ -426,21 +427,21 @@ mkdir -p $OCFS2_FS_ROOT fi - ocf_log debug "$OCFS2_UUID: Existing node list: $n_exists" + ocf_log info "$OCFS2_UUID: Existing node list: $n_exists" # (2) for entry in $n_active ; do -# ocf_log debug "$OCFS2_UUID: Expected active node: $entry" +# ocf_log info "$OCFS2_UUID: Expected active node: $entry" case " $n_exists " in *" $entry "*) - ocf_log debug "$OCFS2_UUID: Already active: $entry" + ocf_log info "$OCFS2_UUID: Already active: $entry" ;; *) if [ "$n_op" = "stop" ]; then ocf_log warn "$OCFS2_UUID: Adding nodes on stop" fi ocf_log info "$OCFS2_UUID: Activating node: $entry" - if ! ln -s $OCFS2_CLUSTER_ROOT/node/$entry $OCFS2_FS_ROOT/$entry ; then + if ! ln -s $OCFS2_CLUSTER_ROOT/node/$entry $OCFS2_FS_ROOT/$entry ; then ocf_log err "$OCFS2_CLUSTER_ROOT/node/$entry: failed to link" fi ;; @@ -614,7 +615,6 @@ for f in "$OCF_RESKEY_ocfs2_configfs" /sys/kernel/config/cluster /configfs/cluster ; do if [ -n "$f" -a -d "$f" ]; then OCFS2_CONFIGFS="$f" - ocf_log debug "$OCFS2_CONFIGFS: used as configfs root." break fi done @@ -644,7 +644,6 @@ exit $OCF_ERR_GENERIC fi fi - ocf_log debug "$DEVICE: using cluster $OCFS2_CLUSTER" OCFS2_CLUSTER_ROOT="$OCFS2_CONFIGFS/$OCFS2_CLUSTER" if [ ! -d "$OCFS2_CLUSTER_ROOT" ]; then @@ -739,6 +738,10 @@ check_util $MOUNT check_util $UMOUNT +if [ "$OP" != "monitor" ]; then + ocf_log info "Running $OP for $DEVICE on $MOUNTPOINT" +fi + case $OP in start) Filesystem_start ;; ------------------------------ _______________________________________________ Linux-ha-cvs mailing list Linux-ha-cvs@lists.linux-ha.org http://lists.community.tummy.com/mailman/listinfo/linux-ha-cvs End of Linux-ha-cvs Digest, Vol 31, Issue 77 ********************************************