Skip to contentSkip to conversation

cluster/rgmanager include/resgroup.h src/cluli ...

Cluster-devel [email protected] 1 participant 1 message Dec 14, 2006

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/cluster
Module name: cluster
Branch: RHEL50
Changes by: lhh at sourceware.org 2006-12-14 22:17:21

Modified files:
rgmanager/include: resgroup.h
rgmanager/src/clulib: rg_strings.c
rgmanager/src/daemons: rg_state.c
rgmanager/src/resources: fs.sh
rgmanager/src/utils: clusvcadm.c

Log message:

	Fix #216774, pass 3

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/include/resgroup.h.diff?cvsroot=cluster&only_with_tag=RHEL50&r1=1.15.4.1&r2=1.15.4.2
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/clulib/rg_strings.c.diff?cvsroot=cluster&only_with_tag=RHEL50&r1=1.5&r2=1.5.4.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/rg_state.c.diff?cvsroot=cluster&only_with_tag=RHEL50&r1=1.24.4.1&r2=1.24.4.2
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/fs.sh.diff?cvsroot=cluster&only_with_tag=RHEL50&r1=1.17&r2=1.17.4.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/utils/clusvcadm.c.diff?cvsroot=cluster&only_with_tag=RHEL50&r1=1.12.4.1&r2=1.12.4.2

rgmanager/include/resgroup.h +1 -0
@@ -161,6 +161,7 @@
 int my_id(void);
 
 /* Return codes */
+#define RG_ERUN		-10		/* Service is already running */
 #define RG_EQUORUM	-9		/* Operation requires quorum */
 #define RG_EINVAL	-8		/* Invalid operation for resource */
 #define RG_EDEPEND 	-7		/* Operation violates dependency */
rgmanager/src/clulib/rg_strings.c +1 -0
@@ -19,6 +19,7 @@
 #include <resgroup.h>
 
 struct { int val; char *str; } rg_error_strings[] = {
+	{ RG_ERUN,      "Service is already running" },
 	{ RG_EQUORUM,	"Operation requires quorum" },
 	{ RG_EINVAL,	"Invalid operation for resource" },
 	{ RG_EDEPEND,	"Operation violates dependency rule" },
rgmanager/src/daemons/rg_state.c +9 -5
@@ -569,6 +569,7 @@
  *			1 = START service - return whatever it returns.
  *			2 = DO NOT start service, return 0
  *			3 = DO NOT start service, return RG_EAGAIN
+ *			4 = DO NOT start service, return RG_ERUN
  */
 int
 svc_advise_start(rg_state_t *svcStatus, char *svcName, int req)
@@ -593,7 +594,7 @@
 			clulog(LOG_DEBUG,
 			       "RG %s is already running locally\n", svcName);
 			 */
-			ret = 2;
+			ret = 4;
 			break;
 		}
 
@@ -605,7 +606,7 @@
 			       svcName,
 			       memb_id_to_name(membership,svcStatus->rs_owner));
 			 */
-			ret = 2;
+			ret = 4;
 			break;
 		}
 
@@ -663,6 +664,7 @@
 		break;
 
 	case RG_STATE_STOPPED:
+	case RG_STATE_ERROR:
 		/* Don't actually enable if the RG is locked! */
 		if (rg_locked()) {
 			ret = 3;
@@ -694,7 +696,6 @@
 		       svcName);
 		break;
 
-	case RG_STATE_ERROR:
 	default:
 		clulog(LOG_ERR,
 		       "#44: Cannot start RG %s: Invalid State %d\n",
@@ -746,6 +747,9 @@
 	case 3:
 		rg_unlock(&lockp);
 		return RG_EAGAIN;
+	case 4:
+		rg_unlock(&lockp);
+		return RG_ERUN;
 	default:
 		break;
 	}
@@ -1491,8 +1495,8 @@
 	/* 
 	   If services are locked, return the error 
 	  */
-	if (ret == RG_EAGAIN)
-		return RG_EAGAIN;
+	if (ret == RG_EAGAIN || ret == RG_ERUN)
+		return ret;
 
 	/*
 	 * If we succeeded, then we're done.
rgmanager/src/resources/fs.sh +14 -0
@@ -496,6 +496,18 @@
 
 
 #
+# trim_trailing_slash path
+#
+# Trim trailing slash from given path.
+#
+trim_trailing_slash() {
+	declare mpath=$1
+
+	echo $mpath | sed -e 's/\/*$//'
+}
+
+
+#
 # isMounted device mount_point
 #
 # Check to see if the device is mounted.  Print a warning if its not
@@ -523,6 +535,8 @@
 	do
 		#echo "spec=$1 dev=$dev  tmp_dev=$tmp_dev"
 		tmp_dev=$(real_device $tmp_dev)
+		tmp_mp=$(trim_trailing_slash $tmp_mp)
+		mp=$(trim_trailing_slash $mp)
 
 		if [ -n "$tmp_dev" -a "$tmp_dev" = "$dev" ]; then
 			#
rgmanager/src/utils/clusvcadm.c +11 -3
@@ -344,13 +344,16 @@
 		clu_local_nodename(RG_SERVICE_GROUP, nodename,
 				   sizeof(nodename));
 				   */
-		strcpy(nodename,"me");
+		//strcpy(nodename,"me");
 	}
 	
 	build_message(&msg, action, svcname, svctarget);
 
 	if (action != RG_RELOCATE && action != RG_MIGRATE) {
-		printf("Member %s %s %s", nodename, actionstr, svcname);
+		if (!node_specified)
+			printf("Local machine %s %s", actionstr, svcname);
+		else
+			printf("Member %s %s %s", nodename, actionstr, svcname);
 		printf("...");
 		fflush(stdout);
 		msg_open(MSG_SOCKET, 0, RG_PORT, &ctx, 5);
@@ -389,13 +392,18 @@
 
 	swab_SmMessageSt(&msg);
 	printf("%s\n", rg_strerror(msg.sm_data.d_ret));
+
+	if (msg.sm_data.d_ret == RG_ERUN)
+		return 0;
+	
 	switch (action) {
 	case RG_MIGRATE:
 	case RG_RELOCATE:
 	case RG_START:
 	case RG_ENABLE:
 		printf("%s%s is now running on %s\n",
-		       msg.sm_data.d_svcOwner==svctarget?"":"Warning: ",
+		       (!node_specified ||
+		       msg.sm_data.d_svcOwner==svctarget)?"":"Warning: ",
 		       svcname, memb_id_to_name(membership,
 		       			        msg.sm_data.d_svcOwner));
 		break;