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

[Cluster-devel] cluster/magma-plugins dumb/dumb.c gulm/gulm-lo ...



CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	STABLE
Changes by:	lhh sourceware org	2006-06-16 20:01:36

Modified files:
	magma-plugins/dumb: dumb.c 
	magma-plugins/gulm: gulm-lock.c gulm.c 
	magma-plugins/sm: services.c sm.c 

Log message:
	Merge from RHEL4 branch - fix #193128, part 1

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/magma-plugins/dumb/dumb.c.diff?cvsroot=cluster&only_with_tag=STABLE&r1=1.2&r2=1.2.8.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/magma-plugins/gulm/gulm-lock.c.diff?cvsroot=cluster&only_with_tag=STABLE&r1=1.5.8.3&r2=1.5.8.4
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/magma-plugins/gulm/gulm.c.diff?cvsroot=cluster&only_with_tag=STABLE&r1=1.6.2.2.6.3&r2=1.6.2.2.6.4
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/magma-plugins/sm/services.c.diff?cvsroot=cluster&only_with_tag=STABLE&r1=1.4.2.1.6.3&r2=1.4.2.1.6.4
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/magma-plugins/sm/sm.c.diff?cvsroot=cluster&only_with_tag=STABLE&r1=1.9.2.3.6.4&r2=1.9.2.3.6.5

--- cluster/magma-plugins/dumb/Attic/dumb.c	2004/06/29 20:25:49	1.2
+++ cluster/magma-plugins/dumb/Attic/dumb.c	2006/06/16 20:01:36	1.2.8.1
@@ -35,7 +35,7 @@
 #include <netinet/in.h>
 #include <assert.h>
 
-#define MODULE_DESCRIPTION "Dumb Plugin v1.1"
+#define MODULE_DESCRIPTION "Dumb Plugin v1.1.1"
 #define MODULE_AUTHOR      "Lon Hohberger"
 #define DUMB_LOCK_PATH	   "/tmp/magma-dumb"
 
@@ -158,6 +158,12 @@
 
 	//printf("DUMB: %s called\n", __FUNCTION__);
 
+	if ((flags & CLK_EX) == 0) {
+		/* NULL lock not supported */
+		errno = EINVAL;
+		return -1;
+	}
+
 	fdp = malloc(sizeof(int));
 	if (!fdp)
 		return -1;
--- cluster/magma-plugins/gulm/Attic/gulm-lock.c	2006/01/27 20:55:02	1.5.8.3
+++ cluster/magma-plugins/gulm/Attic/gulm-lock.c	2006/06/16 20:01:36	1.5.8.4
@@ -269,13 +269,14 @@
 
 	*lockpp = NULL;
 
-	if (flags & CLK_EX) {
+	if ((flags & CLK_EX) == CLK_EX) {
 		state = lg_lock_state_Exclusive;
 	} else if (flags & CLK_READ) {
 		state = lg_lock_state_Shared;
 	} else if (flags & CLK_WRITE) {
 		state = lg_lock_state_Exclusive;
 	} else {
+		/* NULL Locks not supported on GULM */
 		errno = EINVAL;
 		return -1;
 	}
--- cluster/magma-plugins/gulm/Attic/gulm.c	2006/01/24 19:31:12	1.6.2.2.6.3
+++ cluster/magma-plugins/gulm/Attic/gulm.c	2006/06/16 20:01:36	1.6.2.2.6.4
@@ -34,7 +34,7 @@
 #include <sys/types.h>
 #include <linux/unistd.h>
 
-#define MODULE_DESCRIPTION "GuLM Plugin v1.0.4"
+#define MODULE_DESCRIPTION "GuLM Plugin v1.0.5"
 #define MODULE_AUTHOR      "Lon Hohberger"
 
 
--- cluster/magma-plugins/sm/Attic/services.c	2005/12/09 17:00:44	1.4.2.1.6.3
+++ cluster/magma-plugins/sm/Attic/services.c	2006/06/16 20:01:36	1.4.2.1.6.4
@@ -235,8 +235,6 @@
 	} while (ioctl(sockfd, SIOCCLUSTER_GETMEMBERS, &cman_nl) !=
 		 cman_nl.max_members);
 
-	/* Another biggie */
-	foo = malloc(cml_size(cman_nl.max_members));
 	assert(foo != NULL);
 	strncpy(foo->cml_groupname, groupname, sizeof(foo->cml_groupname));
 
--- cluster/magma-plugins/sm/Attic/sm.c	2006/01/20 16:12:05	1.9.2.3.6.4
+++ cluster/magma-plugins/sm/Attic/sm.c	2006/06/16 20:01:36	1.9.2.3.6.5
@@ -35,7 +35,7 @@
 #include <sys/types.h>
 #include <sys/select.h>
 
-#define MODULE_DESCRIPTION "CMAN/SM Plugin v1.1.5"
+#define MODULE_DESCRIPTION "CMAN/SM Plugin v1.1.7.1"
 #define MODULE_AUTHOR      "Lon Hohberger"
 
 #define DLM_LS_NAME	   "Magma"
@@ -47,6 +47,7 @@
 
 /* Internal */
 static inline int _dlm_release_lockspace(sm_priv_t *p);
+static inline int _dlm_unlock(sm_priv_t *p, struct dlm_lksb *lksb);
 
 
 /*
@@ -560,24 +561,13 @@
 {
         int ret;
 
-        /*
-         * per pjc: create/open lockspace when first lock is taken
-         */
-        ret = dlm_ls_lock(p->ls, mode, lksb, options, resource,
-                          strlen(resource), 0, ast_function, lksb,
-                          NULL, NULL);
-
-        if (ret < 0) {
-#if 0
-                if (errno == ENOENT) {
-                        /* This should not happen if we have a lock
-                           ref open in the LS ! */A
-                        assert(0);
-                }
-#endif
+	/* Ok, we have the NL lock.  Now convert it. */
+        ret = dlm_ls_lock(p->ls, mode, lksb, options,
+			  resource, strlen(resource), 0, ast_function,
+			  lksb, NULL, NULL);
 
+        if (ret < 0)
                 return -1;
-        }
 
         if ((ret = (wait_for_dlm_event(p->ls) < 0))) {
                 fprintf(stderr, "wait_for_dlm_event: %d / %d\n",
@@ -585,6 +575,7 @@
                 return -1;
         }
 
+	/* Got the lock ! */
         return 0;
 }
 
@@ -760,42 +751,64 @@
 
 	p = (sm_priv_t *)self->cp_private.p_data;
 	assert(p);
-	*lockpp = NULL;
-	if (flags & CLK_EX) {
+
+	if ((flags & CLK_EX) == CLK_EX) {
 		mode = LKM_EXMODE;
 	} else if (flags & CLK_READ) {
 		mode = LKM_PRMODE;
 	} else if (flags & CLK_WRITE) {
 		mode = LKM_PWMODE;
-	} else {
-		errno = EINVAL;
-		return -1;
+	} else if ((flags & CLK_EX) == 0){
+		mode = LKM_NLMODE;
 	}
 
 	if (flags & CLK_NOWAIT)
 		options = LKF_NOQUEUE;
+	if (flags & CLK_CONVERT)
+		flags &= ~CLK_HOLDER; /* CLK_HOLDER mutually exclusive with
+					 CLK_CONVERT */
 
 	/* Allocate our lock structure. */
 	sz = (sizeof(*lksb) > sizeof(uint64_t) ? sizeof(*lksb) :
 	      sizeof(uint64_t));
 
-	lksb = malloc(sz);
-	assert(lksb);
-	memset(lksb, 0, sz);
-
-	while(!p->ls) {
+	while(!p->ls)
 		_dlm_acquire_lockspace(p, DLM_LS_NAME);
-	}
 	assert(p->ls);
 
+	/* If we've got a non-zero pointer and we're being called with
+	   the CLK_CONVERT flag, then assume it's a previous lksb with
+	   a held lock. */
+	if ((flags & CLK_CONVERT) && *lockpp) {
+		lksb = (struct lksb *)*lockpp;
+		options |= LKF_CONVERT;
+	} else {
+		lksb = malloc(sz);
+		assert(lksb);
+		memset(lksb, 0, sz);
+	}
+
+	/* Take the real lock, or at least, try to. */
 	ret = _dlm_lock(p, mode, lksb, options, resource);
 
-	switch(lksb->sb_status) {
-	case 0:
-		*lockpp = (void *)lksb;
-		return 0;
+	/* Got the lock? */
+	if (ret == 0) {
+		if (lksb->sb_status == 0) {
+			*lockpp = (void *)lksb;
+			return 0;
+		}
+
+		/* Flip errno so we only have one switch statement */
+		errno = lksb->sb_status;
+	}
+
+	switch(errno) {
 	case EAGAIN:
-		if ((flags & CLK_HOLDER) &&
+		if (flags & CLK_CONVERT) {
+			*lockpp = (void *)lksb;
+			/* Nothing special here */
+			/* Lock is busy */
+		} else if ((flags & CLK_HOLDER) &&
 		    (_get_holder(resource, p, mode, &holder) == 0)) {
 			memset(lksb, 0, sz);
 			*((uint64_t *)lksb) = holder;
@@ -806,7 +819,7 @@
 		errno = EAGAIN;
 		return -1;
 	default:
-		fprintf(stderr, "_dlm_lock: %d / %d\n", ret, lksb->sb_status);
+		fprintf(stderr, "_dlm_lock: %d / %d\n", ret, errno);
 		ret = lksb->sb_status;
 		free(lksb);
 		errno = ret;


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