resource-agents: master - resource-agents: Kill correct PIDs during force_unmount

Fabio M. Di Nitto fabbione at fedoraproject.org
Tue Jul 6 03:50:43 UTC 2010


Gitweb:        http://git.fedorahosted.org/git/resource-agents.git?p=resource-agents.git;a=commitdiff;h=3e0c47b36f6f8e7cf3e590490213e907055669c3
Commit:        3e0c47b36f6f8e7cf3e590490213e907055669c3
Parent:        f3a2fe8271161bad2975d355635e14dc3eb17755
Author:        Shane Bradley <sbradley at redhat.com>
AuthorDate:    Mon Feb 15 16:16:55 2010 -0500
Committer:     Fabio M. Di Nitto <fdinitto at redhat.com>
CommitterDate: Tue Jul 6 05:38:08 2010 +0200

resource-agents: Kill correct PIDs during force_unmount

When stopping a service that contains a filesystem resource that is
managed by fs.sh, on a stop operation it can kill a process that is
not located on that mount point.

There was a couple of scenarios that would kill a process that was
not on that mount point when it was stopped:

These processes should not have been killed:
 $ less /tmp/media/demo1/tmp.txt
 $ less /tmp/test\ /media/demo1/tmp.txt

These processes was and should have been killed:
 $ less /media/demo1/tmp.txt

Resolves: rhbz#555901

Signed-off-by: Lon Hohberger <lhh at redhat.com>
---
 rgmanager/src/resources/fs.sh.in |   27 ++++++++++++++-------------
 1 files changed, 14 insertions(+), 13 deletions(-)

diff --git a/rgmanager/src/resources/fs.sh.in b/rgmanager/src/resources/fs.sh.in
index 1454295..b037796 100644
--- a/rgmanager/src/resources/fs.sh.in
+++ b/rgmanager/src/resources/fs.sh.in
@@ -691,6 +691,7 @@ killMountProcesses()
 	typeset have_lsof=""
 	typeset have_fuser=""
 	typeset try
+	typeset command pid user line
 
 	if [ $# -ne 1 ]; then
 		ocf_log err \
@@ -727,30 +728,30 @@ killMountProcesses()
 			#
 			# Use lsof to free up mount point
 			#
-	    		while read command pid user
+			while read line
 			do
-				if [ -z "$pid" ]; then
+				path=$(echo $line | awk '{for (i=9;i<NF+1;i++) {printf "%s ",$i};}')
+				#if [ -z $(echo $path | grep -E "$mp(/| |$)") ]
+				if [ -z $(echo $path | grep -E "^$mp/.*") ]; then
 					continue
 				fi
-
+				command=$(echo $line | awk '{print $1}')
+				pid=$(echo $line | awk '{print $2}')
+				user=$(echo $line | awk '{print $3}')
 				if [ $try -eq 1 ]; then
-					ocf_log warn \
-			 	  "killing process $pid ($user $command $mp)"
+					ocf_log warn "killing process $pid ($user $command $mp)"
 				elif [ $try -eq 3 ]; then
-					ocf_log crit \
-		    		  "Could not clean up mountpoint $mp"
-				ret=$FAIL
+					ocf_log crit "Could not clean up mountpoint $mp"
+					ret=$FAIL
 				fi
-
 				if [ $try -gt 1 ]; then
 					kill -9 $pid
 				else
 					kill -TERM $pid
 				fi
-			done < <(lsof -bn 2>/dev/null | \
-			    grep -E " $mp(/| |$)" | \
-			    awk '{print $1,$2,$3}' | \
-			    sort -u -k 1,3)
+			done< <(lsof -bn 2>/dev/null | \
+				grep -E " $mp(/| |$)" | \
+				sort -u -k 1,3) 
 		elif [ -n "$have_fuser" ]; then
 			#
 			# Use fuser to free up mount point


More information about the cluster-commits mailing list