[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] [PATCH] rgmanager: Fix CIFS mount handling in netfs.sh



Portions based on a patch by Eduardo Alvarenga.

Resolves: rhbz#640676

Signed-off-by: Lon Hohberger <lhh redhat com>
---
 rgmanager/src/resources/netfs.sh |  135 +++++++++++++++++++++-----------------
 1 files changed, 76 insertions(+), 59 deletions(-)

diff --git a/rgmanager/src/resources/netfs.sh b/rgmanager/src/resources/netfs.sh
index 2cc6863..1a669d3 100755
--- a/rgmanager/src/resources/netfs.sh
+++ b/rgmanager/src/resources/netfs.sh
@@ -196,7 +196,7 @@ verify_mountpoint()
 	[ -d "$OCF_RESKEY_mountpoint" ] && return 0
 
 	ocf_log err "$OCF_RESKEY_mountpoint is not a directory"
-	
+
 	return 1
 }
 
@@ -392,7 +392,14 @@ startNFSFilesystem() {
 	host=${OCF_RESKEY_host}
 	exp=${OCF_RESKEY_export}
 
-	fullpath=$host:$exp
+	case $OCF_RESKEY_fstype in
+	cifs)
+		fullpath="//$host/$exp"
+		;;
+	*)
+		fullpath=$host:$exp
+		;;
+	esac
 
 	#
 	# Ensure we've got a valid directory
@@ -445,12 +452,12 @@ startFilesystem: Creating mount point $mp for $fullpath"
 	ocf_log debug "mount $fstype_option $mount_options $fullpath $mp"
 
         case $OCF_RESKEY_fstype in
-		nfs|nfs4)
-			mount -t $OCF_RESKEY_fstype $mount_options $host:$exp $mp
-			;;
-		cifs)
-			mount -t $OCF_RESKEY_fstype $mount_options //$host/$exp $mp
-			;;
+	cifs)
+		mount -t $OCF_RESKEY_fstype $mount_options //$host/$exp $mp
+		;;
+	*)	# nfs/nfs4
+		mount -t $OCF_RESKEY_fstype $mount_options $host:$exp $mp
+		;;
 	esac
 
 	ret_val=$?
@@ -459,7 +466,7 @@ startFilesystem: Creating mount point $mp for $fullpath"
 'mount $fstype_option $mount_options $fullpath $mp' failed, error=$ret_val"
 		return $FAIL
 	fi
-	
+
 	return $SUCCESS
 }
 
@@ -497,11 +504,19 @@ stopNFSFilesystem() {
 	    	return $FAIL
 	    	;;
 	esac
-	
+
 	#
 	# Get the host/path
 	#
-	fullpath="${OCF_RESKEY_host}:${OCF_RESKEY_export}"
+	case $OCF_RESKEY_fstype in
+	cifs)
+		fullpath="//${OCF_RESKEY_host}/${OCF_RESKEY_export}"
+		;;
+	*)	# nfs / nfs4
+		fullpath="${OCF_RESKEY_host}:${OCF_RESKEY_export}"
+		;;
+	esac
+  
 
 	#
 	# Get the force unmount setting if there is a mount point.
@@ -517,61 +532,54 @@ stopNFSFilesystem() {
 	#
 	# Unmount
 	#
-        while [ ! "$done" ]; do
-	isMounted $fullpath $mp
-	case $? in
-	$NO)
-		ocf_log debug "$fullpath is not mounted"
-		umount_failed=
-		done=$YES
-		;;
-	$FAIL)
-		return $FAIL
-		;;
-	$YES)
-		case ${OCF_RESKEY_no_unmount} in
-                $YES_STR)       no_umount="$YES" ;;
-                1)              no_umount="$YES" ;;
-                *)              no_umount="" ;;
-                esac
-		
-		if [ "$no_umount" ]; then
-				ocf_log info "skipping unmount operation of $mp"
-				return $SUCCESS
-		fi
+	while [ ! "$done" ]; do
+		isMounted $fullpath $mp
+		case $? in
+		$NO)
+			ocf_log debug "$fullpath is not mounted"
+			umount_failed=
+			done=$YES
+			;;
+		$FAIL)
+			return $FAIL
+			;;
+		$YES)
+			case ${OCF_RESKEY_no_unmount} in
+			$YES_STR)       no_umount="$YES" ;;
+			1)              no_umount="$YES" ;;
+			*)              no_umount="" ;;
+			esac
 
-		sync; sync; sync
-                        ocf_log info "unmounting $mp"
+			if [ "$no_umount" ]; then
+					ocf_log info "skipping unmount operation of $mp"
+					return $SUCCESS
+			fi
+
+			sync; sync; sync
+			ocf_log info "unmounting $mp"
 
                         umount $mp
-		if  [ $? -eq 0 ]; then
+			if  [ $? -eq 0 ]; then
                                 umount_failed=
                                 done=$YES
                                 continue
-		fi
+			fi
 
-		umount_failed=yes
+			umount_failed=yes
 
-		if [ "$force_umount" ]; then
-			if [ $try -eq 1 ]; then
-				fuser -TERM -kvm "$mp"
-			else
-				fuser -kvm "$mp"
+			if [ "$force_umount" ]; then
+				if [ $try -eq 1 ]; then
+					fuser -TERM -kvm "$mp"
+				else
+					fuser -kvm "$mp"
+				fi
 			fi
-		fi
-
 
-		if [ $try -ge $max_tries ]; then
-			done=$YES
-		else
-			sleep $sleep_time
-			let try=try+1
-                        fi
-		;;
-	*)
-		return $FAIL
-		;;
-	esac
+			;;
+		*)
+			return $FAIL
+			;;
+		esac
 
                 if [ $try -ge $max_tries ]; then
                         done=$YES
@@ -580,9 +588,9 @@ stopNFSFilesystem() {
                         let try=try+1
                 fi
         done # while
+
 	if [ -n "$umount_failed" ]; then
 		ocf_log err "'umount $fullpath' failed ($mp), error=$ret_val"
-
 		return $FAIL
 	fi
 
@@ -618,9 +626,18 @@ stop)
 	exit $?
 	;;
 status|monitor)
-	isMounted ${OCF_RESKEY_host}:${OCF_RESKEY_export} \
+	case $OCF_RESKEY_fstype in
+	cifs)
+		isMounted //${OCF_RESKEY_host}/${OCF_RESKEY_export} \
 		${OCF_RESKEY_mountpoint}
-	exit $?
+		exit $?
+		;;
+	*)	# nfs/nfs4
+		isMounted ${OCF_RESKEY_host}:${OCF_RESKEY_export} \
+			${OCF_RESKEY_mountpoint}
+		exit $?
+		;;
+	esac
 	;;
 restart)
 	stopNFSFilesystem
-- 
1.7.2.3


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]