Skip to contentSkip to conversation

cluster/rgmanager/src clulib/Makefile clulib/a ...

Cluster-devel [email protected] 1 participant 1 message Jul 11, 2006

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/cluster
Module name: cluster
Changes by: lhh at sourceware.org 2006-07-11 23:52:42

Modified files:
rgmanager/src/clulib: Makefile alloc.c lock.c lockspace.c
members.c message.c msgsimple.c rg_strings.c signals.c vft.c
rgmanager/src/daemons: Makefile fo_domain.c groups.c main.c
nodeevent.c reslist.c restree.c rg_forward.c rg_state.c test.c
rgmanager/src/resources: service.sh rgmanager/src/utils: clustat.c clusvcadm.c
Added files:
rgmanager/src/clulib: cman.c locktest.c msg_cluster.c
msg_socket.c msgtest.c
rgmanager/src/daemons: rg_event.c

Log message:
- Make rgmanager actually do things.
- Finish port of rgmanager to CMAN messaging.
- Add feature to wait for nodes to be fenced prior to handling a node-down event.
- Add direct DLM lock support.
- Fix local communication.
- Optimize VF data distribution algorithm to use CMAN/Totem's broadcast mode; this should make rgmanager much more scalable.
- Add multiplexing for CMAN communications so threads can have pseudo private channels over the One CMAN socket.
- Add service->service dependencies based on service events.
- Add node ID display to clustat text-mode output.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/clulib/cman.c.diff?cvsroot=cluster&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/clulib/locktest.c.diff?cvsroot=cluster&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/clulib/msg_cluster.c.diff?cvsroot=cluster&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/clulib/msg_socket.c.diff?cvsroot=cluster&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/clulib/msgtest.c.diff?cvsroot=cluster&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/clulib/Makefile.diff?cvsroot=cluster&r1=1.8&r2=1.9
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/clulib/alloc.c.diff?cvsroot=cluster&r1=1.7&r2=1.8
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/clulib/lock.c.diff?cvsroot=cluster&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/clulib/lockspace.c.diff?cvsroot=cluster&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/clulib/members.c.diff?cvsroot=cluster&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/clulib/message.c.diff?cvsroot=cluster&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/clulib/msgsimple.c.diff?cvsroot=cluster&r1=1.5&r2=1.6
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/clulib/rg_strings.c.diff?cvsroot=cluster&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/clulib/signals.c.diff?cvsroot=cluster&r1=1.1&r2=1.2
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/clulib/vft.c.diff?cvsroot=cluster&r1=1.13&r2=1.14
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/rg_event.c.diff?cvsroot=cluster&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/Makefile.diff?cvsroot=cluster&r1=1.12&r2=1.13
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/fo_domain.c.diff?cvsroot=cluster&r1=1.8&r2=1.9
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/groups.c.diff?cvsroot=cluster&r1=1.18&r2=1.19
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/main.c.diff?cvsroot=cluster&r1=1.25&r2=1.26
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/nodeevent.c.diff?cvsroot=cluster&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/reslist.c.diff?cvsroot=cluster&r1=1.13&r2=1.14
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/restree.c.diff?cvsroot=cluster&r1=1.19&r2=1.20
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/rg_forward.c.diff?cvsroot=cluster&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/rg_state.c.diff?cvsroot=cluster&r1=1.16&r2=1.17
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/daemons/test.c.diff?cvsroot=cluster&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/resources/service.sh.diff?cvsroot=cluster&r1=1.5&r2=1.6
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/utils/clustat.c.diff?cvsroot=cluster&r1=1.17&r2=1.18
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/rgmanager/src/utils/clusvcadm.c.diff?cvsroot=cluster&r1=1.8&r2=1.9

/cvs/cluster/cluster/rgmanager/src/clulib/cman.c,v --> standard output revision 1.1

- renamed from rgmanager/src/clulib/cman.c +264 -0
@@ -0,0 +1,264 @@
+/*
+  Copyright Red Hat, Inc. 2006
+
+  This program is free software; you can redistribute it and/or modify it
+  under the terms of the GNU General Public License as published by the
+  Free Software Foundation; either version 2, or (at your option) any
+  later version.
+
+  This program is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program; see the file COPYING.  If not, write to the
+  Free Software Foundation, Inc.,  675 Mass Ave, Cambridge, 
+  MA 02139, USA.
+*/
+/**
+  pthread mutex wrapper for a global CMAN handle
+ */
+#include <stdio.h>
+#include <pthread.h>
+#include <libcman.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/types.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <signal.h>
+#include <sys/socket.h>
+#include <fcntl.h>
+
+static cman_handle_t *_chandle = NULL;
+static pthread_mutex_t _chandle_lock = PTHREAD_MUTEX_INITIALIZER;
+static pthread_cond_t _chandle_cond = PTHREAD_COND_INITIALIZER;
+static pthread_t _chandle_holder = 0;
+static int _chandle_preempt = 0;
+static int _wakeup_pipe[2] = { -1, -1 };
+
+static void
+_set_nonblock(int fd)
+{
+	int flags;
+
+	flags = fcntl(fd, F_GETFL, 0);
+	if (fcntl(fd, F_SETFL, flags | O_NONBLOCK) < 0)
+		perror("fcntl");
+}
+
+
+/**
+  Lock / return the global CMAN handle.
+
+  @param block		If nonzero, we wait until the handle is released
+  @param preempt	If nonzero, *try* to wake up the holder who has
+			taken the lock with cman_lock_preemptible.  Will not
+			wake up holders which took it with cman_lock().
+  @return		NULL / errno on failure; the global CMAN handle
+			on success.
+ */
+cman_handle_t *
+cman_lock(int block, int preempt)
+{
+	pthread_t tid;
+	cman_handle_t *ret = NULL;
+
+	pthread_mutex_lock(&_chandle_lock);
+	if (_chandle == NULL) {
+		errno = ENOSYS;
+		goto out_unlock;
+	}
+
+	tid = pthread_self();
+	if (_chandle_holder == tid) {
+		errno = EDEADLK;
+		goto out_unlock;
+	}
+
+	if (_chandle_holder > 0) {
+		if (!block) {
+			errno = EAGAIN;
+			goto out_unlock;
+		}
+
+		/* Try to wake up the holder! */
+		if (preempt)
+			write(_wakeup_pipe[1], "!", 1);
+
+		/* Blocking call; do the cond-thing */
+		pthread_cond_wait(&_chandle_cond, &_chandle_lock);
+	}
+		
+	_chandle_holder = tid;
+	ret = _chandle;
+out_unlock:
+	pthread_mutex_unlock(&_chandle_lock);
+	return ret;
+}
+
+
+/**
+  Lock / return the global CMAN handle.
+
+  @param block		If nonzero, we wait until the handle is released
+  @param preempt_fd	Caller should include this file descriptor in
+			blocking calls to select(2), so that we can wake
+			it up if someone calls with cman_lock(xxx, 1);
+  @return		NULL / errno on failure; the global CMAN handle
+			on success.
+ */
+cman_handle_t *
+cman_lock_preemptible(int block, int *preempt_fd)
+{
+	pthread_t tid;
+	cman_handle_t *ret = NULL;
+
+	if (preempt_fd == NULL) {
+		errno = EINVAL;
+		return NULL;
+	}
+
+	pthread_mutex_lock(&_chandle_lock);
+	if (_chandle == NULL) {
+		errno = ENOSYS;
+		goto out_unlock;
+	}
+
+	tid = pthread_self();
+	if (_chandle_holder == tid) {
+		errno = EDEADLK;
+		goto out_unlock;
+	}
+
+	if (_chandle_holder > 0) {
+		if (!block) {
+			errno = EAGAIN;
+			goto out_unlock;
+		}
+
+		/* Blocking call; do the cond-thing */
+		pthread_cond_wait(&_chandle_cond, &_chandle_lock);
+	}
+
+	*preempt_fd = _wakeup_pipe[0];
+	_chandle_holder = tid;
+	_chandle_preempt = 1;
+	ret = _chandle;
+out_unlock:
+	pthread_mutex_unlock(&_chandle_lock);
+	return ret;
+}
+
+
+/**
+  Release the global CMAN handle
+
+  @param ch		Should match the global handle
+  @return		-1 on failure, 0 on success
+ */
+int
+cman_unlock(cman_handle_t *ch)
+{
+	int ret = -1;
+	char c;
+
+	pthread_mutex_lock(&_chandle_lock);
+	if (_chandle == NULL) {
+		errno = ENOSYS;
+		goto out_unlock;
+	}
+
+	if (_chandle_holder != pthread_self() || !_chandle_holder) {
+		errno = EBUSY;
+		goto out_unlock;
+	}
+
+	if (_chandle != ch) {
+		errno = EINVAL;
+		goto out_unlock;
+	}
+
+	/* Empty wakeup pipe if we took it with the preempt flag */
+	if (_chandle_preempt)
+		read(_wakeup_pipe[0], &c, 1);
+
+	_chandle_preempt = 0;
+	_chandle_holder = 0;
+	ret = 0;
+
+out_unlock:
+	pthread_mutex_unlock(&_chandle_lock);
+	if (ret == 0) 
+		pthread_cond_broadcast(&_chandle_cond);
+	return ret;
+}
+
+
+int
+cman_init_subsys(cman_handle_t *ch)
+{
+	int ret = -1;
+
+	pthread_mutex_lock(&_chandle_lock);
+	if (_chandle) {
+		errno = EAGAIN;
+		goto out_unlock;
+	}
+
+	if (!ch) {
+		errno = EAGAIN;
+		goto out_unlock;
+	}
+
+	if (pipe(_wakeup_pipe) < 0) {
+		goto out_unlock;
+	}
+
+	_set_nonblock(_wakeup_pipe[0]);
+	_chandle = ch;
+	_chandle_holder = 0;
+	ret = 0;
+
+out_unlock:
+	pthread_mutex_unlock(&_chandle_lock);
+	return ret;
+}
+
+
+int
+cman_cleanup_subsys(void)
+{
+	int ret = -1;
+
+	pthread_mutex_lock(&_chandle_lock);
+	if (!_chandle) {
+		errno = EAGAIN;
+		goto out_unlock;
+	}
+
+	if (_chandle_holder > 0) {
+		pthread_cond_wait(&_chandle_cond, &_chandle_lock);
+	}
+
+	ret = 0;
+	_chandle = NULL;
+	_chandle_holder = 0;
+
+	close(_wakeup_pipe[0]);
+	close(_wakeup_pipe[1]);
+	
+out_unlock:
+	pthread_mutex_unlock(&_chandle_lock);
+	return ret;
+}
+
+
+int
+cman_send_data_unlocked(void *buf, int len, int flags,
+			uint8_t port, int nodeid)
+{
+	return cman_send_data(_chandle, buf, len, flags, port, nodeid);
+}

/cvs/cluster/cluster/rgmanager/src/clulib/locktest.c,v --> standard output revision 1.1

- renamed from rgmanager/src/clulib/locktest.c +85 -0

85 lines not on this page · raw message

/cvs/cluster/cluster/rgmanager/src/clulib/msg_cluster.c,v --> standard output revision 1.1

- renamed from rgmanager/src/clulib/msg_cluster.c +1104 -0

1,104 lines not on this page · raw message

/cvs/cluster/cluster/rgmanager/src/clulib/msg_socket.c,v --> standard output revision 1.1

- renamed from rgmanager/src/clulib/msg_socket.c +432 -0

432 lines not on this page · raw message

/cvs/cluster/cluster/rgmanager/src/clulib/msgtest.c,v --> standard output revision 1.1

- renamed from rgmanager/src/clulib/msgtest.c +286 -0

286 lines not on this page · raw message

rgmanager/src/clulib/Makefile +6 -3
@@ -21,7 +21,7 @@
 CFLAGS+= -g -Wstrict-prototypes -Wshadow -fPIC -D_GNU_SOURCE
 
 
-TARGETS=libclulib.a liblalloc.a
+TARGETS=libclulib.a liblalloc.a msgtest 
 
 all: ${TARGETS}
 
@@ -29,9 +29,12 @@
 
 uninstall:
 
+msgtest: msgtest.o libclulib.a
+	gcc -o msgtest msgtest.o -lcman -L. -lclulib -llalloc -lpthread
+
 libclulib.a: clulog.o daemon_init.o signals.o msgsimple.o \
-		gettid.o rg_strings.o message.o members.o fdops.o
-		# lock.o lockspace.o 
+		gettid.o rg_strings.o message.o members.o fdops.o \
+		lock.o cman.o vft.o msg_cluster.o msg_socket.o
 	${AR} cru $@ $^
 	ranlib $@
 
rgmanager/src/clulib/alloc.c +2 -1
@@ -129,8 +129,9 @@
 #undef  AGGR_RECLAIM		/* consolidate_all on free (*slow*) */
 
 #undef  STACKSIZE	/*4	   backtrace to store if DEBUG is set */
+//#define STACKSIZE 4
 
-#undef  GDB_HOOK		/* Dump program addresses in malloc_table
+#undef	GDB_HOOK		/* Dump program addresses in malloc_table
 				   using a fork/exec of gdb (SLOW but fun)
 				   building this defeats the purpose of
 				   a bounded memory allocator, and is only
rgmanager/src/clulib/lock.c +162 -10

221 lines not on this page · raw message

rgmanager/src/clulib/lockspace.c +18 -0
@@ -1,3 +1,21 @@
+/*
+  Copyright Red Hat, Inc. 2006
+
+  This program is free software; you can redistribute it and/or modify it
+  under the terms of the GNU General Public License as published by the
+  Free Software Foundation; either version 2, or (at your option) any
+  later version.
+
+  This program is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program; see the file COPYING.  If not, write to the
+  Free Software Foundation, Inc.,  675 Mass Ave, Cambridge, 
+  MA 02139, USA.
+*/
 #include <stdlib.h>
 #include <unistd.h>
 #include <string.h>
rgmanager/src/clulib/members.c +96 -23

261 lines not on this page · raw message

rgmanager/src/clulib/message.c +102 -1162

294 lines not on this page · raw message

rgmanager/src/clulib/msgsimple.c +6 -5

Lines of this file are not shown. View the raw message.

rgmanager/src/clulib/rg_strings.c +18 -0

Lines of this file are not shown. View the raw message.

rgmanager/src/clulib/signals.c +18 -0

Lines of this file are not shown. View the raw message.

rgmanager/src/clulib/vft.c +252 -350

602 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

/cvs/cluster/cluster/rgmanager/src/daemons/rg_event.c,v --> standard output revision 1.1

- renamed from rgmanager/src/daemons/rg_event.c +103 -0

103 lines not on this page · raw message

rgmanager/src/daemons/Makefile +2 -2

Lines of this file are not shown. View the raw message.

rgmanager/src/daemons/fo_domain.c +3 -3

Lines of this file are not shown. View the raw message.

rgmanager/src/daemons/groups.c +217 -94

311 lines not on this page · raw message

rgmanager/src/daemons/main.c +269 -205

474 lines not on this page · raw message

rgmanager/src/daemons/nodeevent.c +128 -5

133 lines not on this page · raw message

rgmanager/src/daemons/reslist.c +25 -5

Lines of this file are not shown. View the raw message.

rgmanager/src/daemons/restree.c +1 -1

Lines of this file are not shown. View the raw message.

rgmanager/src/daemons/rg_forward.c +9 -4

Lines of this file are not shown. View the raw message.

rgmanager/src/daemons/rg_state.c +93 -144

237 lines not on this page · raw message

rgmanager/src/daemons/test.c +18 -0

Lines of this file are not shown. View the raw message.

rgmanager/src/resources/service.sh +11 -0

Lines of this file are not shown. View the raw message.

rgmanager/src/utils/clustat.c +45 -23

68 lines not on this page · raw message

rgmanager/src/utils/clusvcadm.c +17 -6

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Part of the diff is not shown here. View the raw message.