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

[Cluster-devel] Cluster Project branch, master, updated. gfs-kernel_0_1_22-215-g1307d58



This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Cluster Project".

http://sources.redhat.com/git/gitweb.cgi?p=cluster.git;a=commitdiff;h=1307d58730031a6d9f7401ba7182034e73280b49

The branch, master has been updated
       via  1307d58730031a6d9f7401ba7182034e73280b49 (commit)
      from  5ec7deb8f5677cc33b6b0c3bf3cc3d3d9d8c2dfd (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 1307d58730031a6d9f7401ba7182034e73280b49
Author: David Teigland <teigland redhat com>
Date:   Fri Apr 25 12:48:29 2008 -0500

    fence: using new libs
    
    Filling out various incomplete parts, making use of the new interfaces.
    
    Signed-off-by: David Teigland <teigland redhat com>

-----------------------------------------------------------------------

Summary of changes:
 fence/fence_node/fence_node.c |    2 +
 fence/fence_tool/Makefile     |    3 +-
 fence/fence_tool/fence_tool.c |    5 ++-
 fence/fenced/cpg.c            |   54 ++++++++++++++++++++++++++-
 fence/fenced/fd.h             |    1 +
 fence/fenced/main.c           |   37 +++++++++++++-----
 fence/fenced/member_cman.c    |   84 +++++++++++++++++++++++++++++++++++-----
 fence/libfenced/libfenced.h   |    2 -
 group/dlm_controld/Makefile   |    4 +-
 group/dlm_controld/cpg.c      |   37 +++++++++++-------
 10 files changed, 186 insertions(+), 43 deletions(-)

diff --git a/fence/fence_node/fence_node.c b/fence/fence_node/fence_node.c
index 6662f52..00fe6ea 100644
--- a/fence/fence_node/fence_node.c
+++ b/fence/fence_node/fence_node.c
@@ -108,6 +108,8 @@ int main(int argc, char *argv[])
 	} else {
 		syslog(LOG_NOTICE, "Fence of \"%s\" was successful\n", victim);
 
+		/* Tell fenced what we've done so that it can avoid fencing
+		   this node again if the fence_node() rebooted it. */
 		fenced_external(victim);
 
 		exit(EXIT_SUCCESS);
diff --git a/fence/fence_tool/Makefile b/fence/fence_tool/Makefile
index faf6580..c3b1a22 100644
--- a/fence/fence_tool/Makefile
+++ b/fence/fence_tool/Makefile
@@ -27,11 +27,10 @@ OBJS=fence_tool.o
 
 CFLAGS += -D_FILE_OFFSET_BITS=64
 CFLAGS += -I${ccsincdir} -I${cmanincdir} -I${fencedincdir}
-CFLAGS += -I$(S)/../include -I$(SRCDIR)/group/lib
+CFLAGS += -I$(S)/../include
 CFLAGS += -I${incdir} 
 
 LDFLAGS += -L${ccslibdir} -L${cmanlibdir} -L${fencedlibdir} -lccs -lcman -lfenced
-LDFLAGS += -L../../group/lib -lgroup 
 
 ${TARGET}: ${OBJS}
 	$(CC) -o $@ $^ $(LDFLAGS)
diff --git a/fence/fence_tool/fence_tool.c b/fence/fence_tool/fence_tool.c
index 72c262e..334231c 100644
--- a/fence/fence_tool/fence_tool.c
+++ b/fence/fence_tool/fence_tool.c
@@ -31,7 +31,6 @@
 #include "ccs.h"
 #include "copyright.cf"
 #include "libcman.h"
-#include "libgroup.h"
 #include "libfenced.h"
 
 #define OPTION_STRING			("Vht:wQ")
@@ -142,6 +141,7 @@ static void sigalarm_handler(int sig)
 
 static int we_are_in_fence_domain(void)
 {
+#if 0
 	group_data_t gdata;
 	int rv;
 
@@ -152,6 +152,9 @@ static int we_are_in_fence_domain(void)
 		return 0;
 
 	return gdata.member;
+#endif
+	printf("FIXME: use libfenced:fenced_domain_members()\n");
+	return 1;
 }
 
 /*
diff --git a/fence/fenced/cpg.c b/fence/fenced/cpg.c
index 0ab6a60..9d1a143 100644
--- a/fence/fenced/cpg.c
+++ b/fence/fenced/cpg.c
@@ -1247,19 +1247,71 @@ int fd_leave(struct fd *fd)
 	return 0;
 }
 
-int set_node_info(struct fd *fd, int nodeid, struct fenced_node *node)
+int set_node_info(struct fd *fd, int nodeid, struct fenced_node *nodeinfo)
 {
+	struct node_history *node;
+	struct member *memb;
+
+	nodeinfo->nodeid = nodeid;
+	nodeinfo->victim = is_victim(fd, nodeid);
+
+	if (!fd->started_change)
+		goto history;
+
+	memb = find_memb(fd->started_change, nodeid);
+	if (memb)
+		nodeinfo->member = memb->disallowed ? 0 : 1;
+
+ history:
+	node = get_node_history(fd, nodeid);
+	if (!node)
+		return 0;
+
+	nodeinfo->last_fenced_master = node->fence_master;
+	nodeinfo->last_fenced_how = node->fence_how;
+	nodeinfo->last_fenced_time = node->fence_time;
+
 	return 0;
 }
 
 int set_domain_info(struct fd *fd, struct fenced_domain *domain)
 {
+	struct change *cg = fd->started_change;
+
+	if (cg) {
+		domain->member_count = cg->member_count;
+		domain->state = cg->state;
+	}
+	domain->master_nodeid = fd->master;
+	domain->victim_count = list_count(&fd->victims);
+
 	return 0;
 }
 
 int set_domain_members(struct fd *fd, int *member_count,
 		       struct fenced_node **members)
 {
+	struct change *cg = fd->started_change;
+	struct fenced_node *nodes, *nodep;
+	struct member *memb;
+
+	if (!cg) {
+		*member_count = 0;
+		return 0;
+	}
+
+	nodes = malloc(cg->member_count * sizeof(struct fenced_node));
+	if (!nodes)
+		return -ENOMEM;
+
+	nodep = nodes;
+	list_for_each_entry(memb, &cg->members, list) {
+		set_node_info(fd, memb->nodeid, nodep++);
+	}
+
+	*member_count = cg->member_count;
+	*members = nodes;
+
 	return 0;
 }
 
diff --git a/fence/fenced/fd.h b/fence/fenced/fd.h
index 605cb1b..413d75c 100644
--- a/fence/fenced/fd.h
+++ b/fence/fenced/fd.h
@@ -268,6 +268,7 @@ void process_cman(int ci);
 int setup_cman(void);
 int is_cman_member(int nodeid);
 char *nodeid_to_name(int nodeid);
+int name_to_nodeid(char *name);
 struct node *get_new_node(struct fd *fd, int nodeid);
 
 /* recover.c */
diff --git a/fence/fenced/main.c b/fence/fenced/main.c
index f208378..2e08355 100644
--- a/fence/fenced/main.c
+++ b/fence/fenced/main.c
@@ -244,23 +244,21 @@ static int do_leave(char *name)
 	return rv;
 }
 
-static int do_external(char *name, int ci)
+static int do_external(char *name, char *extra, int extra_len)
 {
 	struct fd *fd;
-	int nodeid = 0;
+	int rv = 0;
 
 	fd = find_fd(name);
 	if (!fd)
 		return -EINVAL;
 
 	if (group_mode == GROUP_LIBGROUP)
-		return -EINVAL;
-
-	/* FIXME: do_read(client[ci].fd, buf, MAX_NODENAME_LEN);
-	   which gets the nodename, then translate the nodename to nodeid */
+		rv = -ENOSYS;
+	else
+		send_external(fd, name_to_nodeid(extra));
 
-	send_external(fd, nodeid);
-	return 0;
+	return rv;
 }
 
 /* combines a header and the data and sends it back to the client in
@@ -397,7 +395,8 @@ static void do_domain_members(int ci, int max)
 static void process_connection(int ci)
 {
 	struct fenced_header h;
-	int rv;
+	char *extra = NULL;
+	int rv, extra_len;
 
 	rv = do_read(client[ci].fd, &h, sizeof(h));
 	if (rv < 0) {
@@ -415,6 +414,22 @@ static void process_connection(int ci)
 		goto out;
 	}
 
+	if (h.len > sizeof(h)) {
+		extra_len = h.len - sizeof(h);
+		extra = malloc(extra_len);
+		if (!extra) {
+			log_error("process_connection no mem %d", extra_len);
+			goto out;
+		}
+		memset(extra, 0, extra_len);
+
+		rv = do_read(client[ci].fd, extra, extra_len);
+		if (rv < 0) {
+			log_debug("connection %d extra read error %d", ci, rv);
+			goto out;
+		}
+	}
+
 	switch (h.command) {
 	case FENCED_CMD_JOIN:
 		do_join("default");
@@ -423,7 +438,7 @@ static void process_connection(int ci)
 		do_leave("default");
 		break;
 	case FENCED_CMD_EXTERNAL:
-		do_external("default", ci);
+		do_external("default", extra, extra_len);
 		break;
 	case FENCED_CMD_DUMP_DEBUG:
 		do_dump(ci);
@@ -442,6 +457,8 @@ static void process_connection(int ci)
 			  ci, h.command);
 	}
  out:
+	if (extra)
+		free(extra);
 	client_dead(ci);
 }
 
diff --git a/fence/fenced/member_cman.c b/fence/fenced/member_cman.c
index a2bb318..50afcf3 100644
--- a/fence/fenced/member_cman.c
+++ b/fence/fenced/member_cman.c
@@ -13,10 +13,61 @@
 #include "fd.h"
 #include <libcman.h>
 
+#define BUFLEN		MAX_NODENAME_LEN+1
+
 static cman_handle_t	ch;
 static cman_node_t	cman_nodes[MAX_NODES];
 static int		cman_node_count;
 
+
+static int name_equal(char *name1, char *name2)
+{
+	char name3[BUFLEN], name4[BUFLEN];
+	int i, len1, len2;
+
+	len1 = strlen(name1);
+	len2 = strlen(name2);
+
+	if (len1 == len2 && !strncmp(name1, name2, len1))
+		return 1;
+
+	memset(name3, 0, BUFLEN);
+	memset(name4, 0, BUFLEN);
+
+	for (i = 0; i < BUFLEN && i < len1; i++) {
+		if (name1[i] != '.')
+			name3[i] = name1[i];
+		else
+			break;
+	}
+
+	for (i = 0; i < BUFLEN && i < len2; i++) {
+		if (name2[i] != '.')
+			name4[i] = name2[i];
+		else
+			break;
+	}
+
+	len1 = strlen(name3);
+	len2 = strlen(name4);
+
+	if (len1 == len2 && !strncmp(name3, name4, len1))
+		return 1;
+
+	return 0;
+}
+
+static cman_node_t *find_cman_node_name(char *name)
+{
+	int i;
+
+	for (i = 0; i < cman_node_count; i++) {
+		if (name_equal(cman_nodes[i].cn_name, name))
+			return &cman_nodes[i];
+	}
+	return NULL;
+}
+
 static cman_node_t *find_cman_node(int nodeid)
 {
 	int i;
@@ -28,6 +79,28 @@ static cman_node_t *find_cman_node(int nodeid)
 	return NULL;
 }
 
+char *nodeid_to_name(int nodeid)
+{
+	cman_node_t *cn;
+
+	cn = find_cman_node(nodeid);
+	if (cn)
+		return cn->cn_name;
+
+	return "unknown";
+}
+
+int name_to_nodeid(char *name)
+{
+	cman_node_t *cn;
+
+	cn = find_cman_node_name(name);
+	if (cn)
+		return cn->cn_nodeid;
+
+	return -1;
+}
+
 static void statechange(void)
 {
 	int rv;
@@ -139,17 +212,6 @@ int is_cman_member(int nodeid)
 	return 0;
 }
 
-char *nodeid_to_name(int nodeid)
-{
-	cman_node_t *cn;
-
-	cn = find_cman_node(nodeid);
-	if (cn)
-		return cn->cn_name;
-
-	return "unknown";
-}
-
 struct node *get_new_node(struct fd *fd, int nodeid)
 {
 	cman_node_t cn;
diff --git a/fence/libfenced/libfenced.h b/fence/libfenced/libfenced.h
index b10055b..a79d188 100644
--- a/fence/libfenced/libfenced.h
+++ b/fence/libfenced/libfenced.h
@@ -32,8 +32,6 @@ struct fenced_node {
 	int last_fenced_master;
 	int last_fenced_how;
 	uint64_t last_fenced_time;
-	uint64_t last_joined_time;
-	uint64_t last_remove_time;
 };
 
 struct fenced_domain {
diff --git a/group/dlm_controld/Makefile b/group/dlm_controld/Makefile
index 8098bad..4c6376c 100644
--- a/group/dlm_controld/Makefile
+++ b/group/dlm_controld/Makefile
@@ -33,12 +33,12 @@ OBJS=	action.o \
 	plock.o \
 	group.o
 
-CFLAGS += -I${ccsincdir} -I${cmanincdir} -I${dlmincdir} -I${openaisincdir}
+CFLAGS += -I${ccsincdir} -I${cmanincdir} -I${dlmincdir} -I${openaisincdir} -I${fencedincdir}
 CFLAGS += -I${KERNEL_SRC}/include/
 CFLAGS += -I$(S)/../lib/ -I$(S)/../include/
 CFLAGS += -I${incdir}
 
-LDFLAGS += -L${ccslibdir} -L${cmanlibdir} -L${dlmlibdir} -lccs -lcman -ldlm
+LDFLAGS += -L${ccslibdir} -L${cmanlibdir} -L${dlmlibdir} -L${fencedlibdir} -lccs -lcman -ldlm -lfenced
 LDFLAGS += -L${openaislibdir} -lcpg -lSaCkpt
 LDFLAGS += -L../lib -lgroup
 
diff --git a/group/dlm_controld/cpg.c b/group/dlm_controld/cpg.c
index e531b65..59872d7 100644
--- a/group/dlm_controld/cpg.c
+++ b/group/dlm_controld/cpg.c
@@ -12,6 +12,7 @@
 
 #include "dlm_daemon.h"
 #include "config.h"
+#include "libfenced.h"
 
 uint32_t cpgname_to_crc(const char *data, int len);
 
@@ -36,7 +37,7 @@ struct node {
 	int check_quorum;
 	int check_fs;
 	int fs_notify;
-	struct timeval add_time;
+	uint64_t add_time;
 };
 
 /* One of these change structs is created for every confchg a cpg gets. */
@@ -302,7 +303,7 @@ static void node_history_init(struct lockspace *ls, int nodeid)
 	memset(node, 0, sizeof(struct node));
 
 	node->nodeid = nodeid;
-	timerclear(&node->add_time);
+	node->add_time = 0;
 	list_add_tail(&node->list, &ls->node_history);
 }
 
@@ -316,7 +317,7 @@ static void node_history_start(struct lockspace *ls, int nodeid)
 		return;
 	}
 
-	gettimeofday(&node->add_time, NULL);
+	node->add_time = time(NULL);
 }
 
 static void node_history_left(struct lockspace *ls, int nodeid)
@@ -329,7 +330,7 @@ static void node_history_left(struct lockspace *ls, int nodeid)
 		return;
 	}
 
-	timerclear(&node->add_time);
+	node->add_time = 0;
 }
 
 static void node_history_fail(struct lockspace *ls, int nodeid)
@@ -342,7 +343,7 @@ static void node_history_fail(struct lockspace *ls, int nodeid)
 		return;
 	}
 
-	if (!timerisset(&node->add_time))
+	if (!node->add_time)
 		node->check_fencing = 1;
 
 	node->check_quorum = 1;
@@ -352,8 +353,10 @@ static void node_history_fail(struct lockspace *ls, int nodeid)
 static int check_fencing_done(struct lockspace *ls)
 {
 	struct node *node;
-	struct timeval last_fenced;
+	struct fenced_node nodeinfo;
+	struct fenced_domain domain;
 	int wait_count = 0;
+	int rv;
 
 	list_for_each_entry(node, &ls->node_history, list) {
 		if (!node->check_fencing)
@@ -362,12 +365,15 @@ static int check_fencing_done(struct lockspace *ls)
 		/* check with fenced to see if the node has been
 		   fenced since node->add_time */
 
-		/* fenced_last_success(node->nodeid, &last_fenced); */
-		gettimeofday(&last_fenced, NULL);
+		memset(&nodeinfo, 0, sizeof(nodeinfo));
+
+		rv = fenced_node_info(node->nodeid, &nodeinfo);
+		if (rv < 0)
+			log_error("fenced_node_info error %d", rv);
 
-		if (timercmp(&last_fenced, &node->add_time, >)) {
+		if (nodeinfo.last_fenced_time > node->add_time) {
 			node->check_fencing = 0;
-			timerclear(&node->add_time);
+			node->add_time = 0;
 		} else {
 			log_group(ls, "check_fencing %d needs fencing",
 				  node->nodeid);
@@ -382,11 +388,14 @@ static int check_fencing_done(struct lockspace *ls)
 	   we may not have seen in any lockspace), and return 0 if there
 	   are any */
 
-	/*
-	fenced_pending_count(&pending);
-	if (pending)
+	rv = fenced_domain_info(&domain);
+	if (rv < 0) {
+		log_error("fenced_domain_info error %d", rv);
+		return 0;
+	}
+
+	if (domain.victim_count)
 		return 0;
-	*/
 	return 1;
 }
 


hooks/post-receive
--
Cluster Project


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