? clumanager-1.2.35.2-1.2.36.patch
? clumanager-1.2.37-ping-dns.patch
? clumanager-1.2.37.2-1.2.38.patch
? clumanager-1.2.38-0.1test.src.rpm
? clumanager-1.2.38.tar.gz
? clumanager.spec
? foo.out
? lock-update.diff
? rpm_build
? librhcm/sizes.h
? src/clulib/cluping
? src/clulib/foo.patch
? src/daemons/clulocktest
? src/daemons/clusvcmgrd.c.new
? src/daemons/cscope.files
? src/daemons/cscope.out
? src/iolib/raw/clurawtest
? src/locklib/clulock-works.c
? src/utils/clunfsops
Index: ChangeLog
===================================================================
RCS file: /cvs/devel/clumanager/ChangeLog,v
retrieving revision 1.160
diff -u -p -r1.160 ChangeLog
--- ChangeLog	14 Aug 2008 21:19:25 -0000	1.160
+++ ChangeLog	27 Jan 2009 23:41:55 -0000
@@ -1,3 +1,9 @@
+2009-01-27 Lon Hohberger <lhh at redhat.com> 1.2.38
+	* src/locklib/clulock.c: Nuke triple-layer locking to improve
+	reliability.
+	* src/daemons/clulocktest.c: (Added) Utility for verifying cluster
+	mutual exclusion using clulock.c
+
 2008-08-14 Lon Hohberger <lhh at redhat.com> 1.2.37.2
 	* include/ping.h: Include new strerror report for ping errors
 	* include/sharedstate.h: Report lock master ID in lock blocks
Index: Makefile.top
===================================================================
RCS file: /cvs/devel/clumanager/Makefile.top,v
retrieving revision 1.118
diff -u -p -r1.118 Makefile.top
--- Makefile.top	14 Aug 2008 21:19:25 -0000	1.118
+++ Makefile.top	27 Jan 2009 23:41:55 -0000
@@ -1,7 +1,7 @@
 #
 # Make rules
 #
-VERSION = 1.2.37.2
+VERSION = 1.2.38
 CC		= gcc
 CFLAGS  = -Wall -Werror -Wstrict-prototypes -Wshadow -ggdb -fpic\
 	-DVERSION="\"$(VERSION)\"" -pthread $(EXTRA_CFLAGS)
Index: src/daemons/Makefile
===================================================================
RCS file: /cvs/devel/clumanager/src/daemons/Makefile,v
retrieving revision 1.17
diff -u -p -r1.17 Makefile
--- src/daemons/Makefile	21 Sep 2004 18:50:39 -0000	1.17
+++ src/daemons/Makefile	27 Jan 2009 23:41:55 -0000
@@ -12,7 +12,7 @@ LIBS=-lxml2 -ldl -L../locklib -lclulock 
 
 TARGETS=cluquorumd clusvcmgrd clulockd clumembd clurmtabd
 
-all: $(TARGETS)
+all: $(TARGETS) clulocktest
 
 clean:
 	rm -f *.a *.o *~ $(TARGETS)
@@ -24,6 +24,9 @@ install:
 clumembd: clumembd.o clumembd_watchdog.o
 	$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
 
+clulocktest: clulocktest.o
+	$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
+
 cluquorumd: cluquorumd.o cluquorumd_disk.o cluquorumd_net.o
 	$(CC) $(CFLAGS) -o $@ $^ $(LIBS)
 
Index: src/daemons/clulocktest.c
===================================================================
RCS file: src/daemons/clulocktest.c
diff -N src/daemons/clulocktest.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/daemons/clulocktest.c	27 Jan 2009 23:41:55 -0000
@@ -0,0 +1,32 @@
+#include <clu_lock.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+
+int
+main(int argc, char **argv)
+{
+	int x, lockid;
+	char buf[80];
+
+	if (argc < 1) {
+		printf("Usage: %s lockid\n", argv[0]);
+		return 1;
+	}
+
+	lockid = atoi(argv[1]);
+	if (lockid < 0)
+		return -1;
+
+	x = clu_lock(lockid);
+	if (x < 0) {
+		perror("clu_lock");
+		return 0;
+	}
+
+	printf("Lock %d held; press <ENTER> to release\n", lockid);
+	fgets(buf, sizeof(buf)-1, stdin);
+	clu_unlock(lockid);
+	
+	return 0;
+}
Index: src/locklib/clulock.c
===================================================================
RCS file: /cvs/devel/clumanager/src/locklib/clulock.c,v
retrieving revision 1.25
diff -u -p -r1.25 clulock.c
--- src/locklib/clulock.c	14 Aug 2008 21:19:25 -0000	1.25
+++ src/locklib/clulock.c	27 Jan 2009 23:41:55 -0000
@@ -68,13 +68,6 @@
 
 #define CLUSTER_LOCKSTR CLULOCKDIR "/lock.%d"
 
-extern int in_initializePartition;
-
-/*
- * Import functions
- */
-int clu_power_cycle(int node);
-
 /* 
  * Function Prototypes - Exported functions 
  */
@@ -82,21 +75,13 @@ int	clu_lock(int lockid);
 int	clu_try_lock(int lockid);
 int	clu_unlock(int lockid);
 
-int	test_clu_lock_held(int lockid);
-int	clu_lock_repair(int lockid);
-
-
 
 /*
  * Function Prototypes - Private functions
  */
-inline int	_clu_process_lock_depth(int lockid);
-
-int	_clu_process_try_lock(int lockid);
+int	_clu_process_try_lock(void *pc, int lockid);
 void	_clu_process_unlock(int lockid);
-int	_clu_try_lock_node(int lockid);
 void	_clu_unlock_node(int lockid);
-int	_clu_try_lock(void *pc, int lockid);
 int	_clu_try_lock_cluster(void *pc, int lockid);
 int	_clu_unlock(void *pc, int lockid);
 int	_clu_lock_init(int lockid);
@@ -111,12 +96,9 @@ int	_clu_lock_init_if_needed(int lockid)
 int _clu_node_id = -1;
 char _clu_prog_name[MAX_DAEMON_NAME_LEN];
 uint32_t _clu_prog_crc = 0;
-int _clu_lock_fd[MAX_LOCKS];
-int _clu_lock_count[MAX_LOCKS];
 int _locks_initialized = 0;
 int delay_shift = 16;
 pid_t _clu_init_pid = -1;
-int clu_msg_based_shoot = 1;
 int _keeper = -1;
 
 /*
@@ -350,7 +332,7 @@ clu_lock(int lockid)
 
 	pc = __builtin_return_address(0);
 
-	while (((rv = _clu_try_lock(pc, lockid)) == -1) && 
+	while (((rv = _clu_try_lock_cluster(pc, lockid)) == -1) && 
 	       ((errno == EAGAIN) || (errno == EBUSY) || (errno == EACCES))) {
 		wait_cur = random() & ((1<<delay_shift)-1);
 		usleep(wait_cur);
@@ -380,158 +362,16 @@ clu_try_lock(int lockid)
 {
 	void *pc;
 	pc = __builtin_return_address(0);
-	return _clu_try_lock(pc, lockid);
-}
-
-
-int 
-_clu_try_lock(void *pc, int lockid)
-{
-	int depth;
-	int err_sv = 0;
-
-	if (_clu_lock_init_if_needed(lockid) < 0) {
-		return -1;
-	}
-
-	depth = _clu_process_try_lock(lockid);
-	if(!depth) {
-		errno = ENOLCK;
-		return -1;
-	}
-
-	if(depth == 1) {
-		if (_clu_try_lock_node(lockid) == -1) {
-			_clu_process_unlock(lockid);
-			return -1;
-		}
-
-		if (_clu_try_lock_cluster(pc,lockid) == -1) {
-			/* Save errno; fcntl will reset it */
-			err_sv = errno;
-			_clu_unlock_node(lockid);
-			_clu_process_unlock(lockid);
-			errno = err_sv;
-			return -1;
-		}
-	}
-	return 0;
+	return _clu_try_lock_cluster(pc, lockid);
 }
 
 
 int
 clu_unlock(int lockid)
 {
-	void *pc;
-	int rv = 0;
-
-	if (_clu_lock_init_if_needed(lockid) < 0) {
-		return -1;
-	}
-
-	if(_clu_process_lock_depth(lockid) == 1) {
-
-		/* BZ 168665: don't unlock local/node if we fail
-		   to unlock from the server. */
-		rv = _clu_unlock(pc,lockid);
-		if (rv < 0)
-			return rv;
-
-		_clu_unlock_node(lockid);
-	}
+	void *pc = __builtin_return_address(0);
 
-	_clu_process_unlock(lockid);
-
-	return 0;
-}
-
-
-int
-_clu_process_try_lock(int lockid)
-{
-	_clu_lock_count[lockid]++;
-	return _clu_lock_count[lockid];
-}
-
-
-void
-_clu_process_unlock(int lockid)
-{
-	_clu_lock_count[lockid]--;
-	if(_clu_lock_count[lockid] < 0) {
-		clulog(LOG_CRIT, "%s: cluster lock not held\n", __FUNCTION__);
-		FAULT();
-	}
-}
-
-
-int
-test_clu_lock_held(int lockid)
-{
-	if (_clu_lock_init_if_needed(lockid) < 0) {
-		return -1;
-	}
-
-	if(_clu_lock_count[lockid] < 0) {
-		clulog(LOG_CRIT, "%s: invalid lock value\n", __FUNCTION__);
-		FAULT();
-	}
-
-	return !!(_clu_lock_count[lockid]);
-}
-
-
-inline int
-_clu_process_lock_depth(int lockid)
-{
-	return _clu_lock_count[lockid];
-}
-
-
-int
-_clu_try_lock_node(int lockid)
-{
-	char filename[256];
-	struct flock lock;
-	int fd;
-
-	snprintf(filename, sizeof(filename), CLUSTER_LOCKSTR, lockid);
-
-	if (_clu_lock_fd[lockid] == -1) {
-		fd = open(filename, O_RDWR | O_CREAT, S_IRWXU);
-		if(fd == -1) {
-			clulog(LOG_CRIT,"%s: open failure, error: %s file %s\n",
-			       __FUNCTION__, strerror(errno), filename);
-			return -1;
-		}
-		_clu_lock_fd[lockid] = fd;
-	}
-
-	memset(&lock, 0, sizeof(lock));
-	lock.l_type = F_WRLCK;
-	if (fcntl(_clu_lock_fd[lockid], F_SETLK, &lock) == -1)
-		/* clu_lock will check for EAGAIN/EBUSY/EACCES*/
-		return -1;
-	else
-		return 0;
-}
-
-
-void
-_clu_unlock_node(int lockid)
-{
-	struct flock lock;
-
-	memset(&lock, 0, sizeof(lock));
-
-	lock.l_type = F_UNLCK;
-	if(fcntl(_clu_lock_fd[lockid], F_SETLK, &lock)) {
-		clulog(LOG_CRIT,"%s: fcntl: %s\n", __FUNCTION__,
-		       strerror(errno));
-		FAULT();
-	}
-	close(_clu_lock_fd[lockid]);
-	_clu_lock_fd[lockid] = -1;
+	return _clu_unlock(pc, lockid);
 }
 
 
@@ -562,14 +402,6 @@ _clu_unlock(void *pc, int lockid)
 }
 
 
-/* repairs corruption for locks of downed nodes */
-int
-clu_lock_repair(int __attribute__ ((unused))lockid)
-{
-	return 0;
-}
-
-
 /*
  * [re]configure the lock timeout interval; generally called from a daemon's
  * sighup handler 
@@ -650,8 +482,8 @@ _clu_lock_init(int lockid)
 	if (_clu_node_id == -1) {
 		_clu_node_id = memb_local_id();
 		if(_clu_node_id < 0) {
-			clulog(LOG_CRIT, "%s: unable to get local member ID\n",
-			       __FUNCTION__);
+			clulog(LOG_DEBUG, "%s: unable to get local member "
+			       "ID; cluster not running?\n", __FUNCTION__);
 			return -1;
 		}		
 
@@ -666,32 +498,27 @@ _clu_lock_init(int lockid)
 int
 _clu_lock_init_if_needed(int lockid)
 {
-	pid_t pid, fd;
+	pid_t pid;
 
 	/*
 	 * full init - XXX pthreads?
 	 */
 	if (!_locks_initialized) {
 		clu_lock_hup();
-		for (fd=0; fd < MAX_LOCKS; fd++) {
-			_clu_lock_count[fd] = 0; 
-			_clu_lock_fd[fd] = -1;
-		}
-		_locks_initialized = 1;
 		read_my_data();	
 	}
 
-	if (((_clu_lock_fd[lockid] == -1) || (!_locks_initialized)) &&
-	    (_clu_lock_init(lockid) < 0))
+	if (_clu_lock_init(lockid) < 0)
 		return -1;
 
 	pid = getpid();
 	/* lock is stripped in the child */
 	if (pid != _clu_init_pid) {
-		_clu_lock_count[lockid] = 0;
 		_clu_init_pid = pid;
 	}
 
+	_locks_initialized = 1;
+
 	return 0;
 }
 
Index: src/stonithlib/Makefile
===================================================================
RCS file: /cvs/devel/clumanager/src/stonithlib/Makefile,v
retrieving revision 1.14
diff -u -p -r1.14 Makefile
--- src/stonithlib/Makefile	14 Aug 2008 22:28:45 -0000	1.14
+++ src/stonithlib/Makefile	27 Jan 2009 23:41:55 -0000
@@ -8,7 +8,7 @@ TARGETS  = wti_nps.so servertech.so bayt
 # Hack to make clumanager build without GFS-devel installed; i.e. on
 # machines which do not have gulm.
 #
-TARGETS += $(shell if locate libgulm.h; then echo gulm-bridge.so; fi)
+TARGETS += $(shell if locate libgulm.h >/dev/null; then echo gulm-bridge.so; fi)
 
 all: $(TARGETS)
 
