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

[Cluster-devel] Cluster Project branch, master, updated. cluster-2.99.00-2-g1fece51



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=1fece51155f0df4e1524dc073a14e641392b0b7b

The branch, master has been updated
       via  1fece51155f0df4e1524dc073a14e641392b0b7b (commit)
      from  5d8906cf847772d3dd3bf3bd49b58fd80e1ab696 (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 1fece51155f0df4e1524dc073a14e641392b0b7b
Author: David Teigland <teigland redhat com>
Date:   Mon Apr 28 16:37:58 2008 -0500

    fence: fence_tool list and fenced_domain_nodes()
    
    Let fence_tool query fenced for domain state.
    Change fenced_domain_members() to fenced_domain_nodes()
    to query for nodes other than members.
    
    Signed-off-by: David Teigland <teigland redhat com>

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

Summary of changes:
 fence/fence_tool/fence_tool.c |   79 ++++++++++++++++++++++++++++++++++++++---
 fence/fenced/cpg.c            |   10 +++---
 fence/fenced/fd.h             |    8 ++--
 fence/fenced/fenced.h         |    6 ++-
 fence/fenced/group.c          |    8 ++--
 fence/fenced/main.c           |   37 +++++++++++--------
 fence/libfenced/libfenced.h   |    7 +++-
 fence/libfenced/main.c        |    9 +++--
 8 files changed, 123 insertions(+), 41 deletions(-)

diff --git a/fence/fence_tool/fence_tool.c b/fence/fence_tool/fence_tool.c
index 334231c..0152948 100644
--- a/fence/fence_tool/fence_tool.c
+++ b/fence/fence_tool/fence_tool.c
@@ -33,11 +33,9 @@
 #include "libcman.h"
 #include "libfenced.h"
 
-#define OPTION_STRING			("Vht:wQ")
-
 #define OP_JOIN  			1
 #define OP_LEAVE 			2
-#define OP_WAIT				3
+#define OP_LIST				3
 #define OP_DUMP				4
 
 #define die(fmt, args...) \
@@ -51,6 +49,7 @@ while (0)
 
 char *prog_name;
 int operation;
+int verbose = 0;
 int child_wait = 0;
 int quorum_wait = 1;
 int fenced_start_timeout = 300; /* five minutes */
@@ -275,6 +274,65 @@ static int do_dump(void)
 	return 0;
 }
 
+static int node_compare(const void *va, const void *vb)
+{
+	const struct fenced_node *a = va;
+	const struct fenced_node *b = vb;
+
+	return a->nodeid - b->nodeid;
+}
+
+#define MAX_NODES 128
+
+static int do_list(void)
+{
+	struct fenced_domain d;
+	struct fenced_node *nodes, *np;
+	int node_count = 0;
+	int rv, i;
+
+	rv = fenced_domain_info(&d);
+	if (rv < 0)
+		die("can't communicate with fenced");
+
+	nodes = malloc(MAX_NODES * sizeof(struct fenced_node));
+	if (!nodes)
+		return -ENOMEM;
+
+	rv = fenced_domain_nodes(FENCED_NODES_MEMBERS, MAX_NODES,
+				 &node_count, nodes);
+	if (rv < 0) {
+		fprintf(stderr, "fenced_domain_nodes error %d\n", rv);
+		return rv;
+	}
+
+	printf("default fence domain\n");
+
+	if (verbose > 0)
+		printf("member_count %d victim_count %d master_nodeid %d current_victim %d state %d\n",
+			d.member_count, d.victim_count, d.master_nodeid, d.current_victim, d.state);
+
+	/*
+	qsort(&nodes, node_count, sizeof(struct fenced_node), node_compare);
+	*/
+
+	printf("domain_nodes node_count %d\n", node_count);
+	np = nodes;
+
+	printf("[");
+	for (i = 0; i < node_count; i++) {
+		if (i != 0)
+			printf(" ");
+		printf("%d", np->nodeid);
+		np++;
+	}
+	printf("]\n");
+
+	free(nodes);
+
+	return 0;
+}
+
 static void print_usage(void)
 {
 	printf("Usage:\n");
@@ -295,6 +353,8 @@ static void print_usage(void)
 	printf("\n");
 }
 
+#define OPTION_STRING "vVht:wQ"
+
 static void decode_arguments(int argc, char *argv[])
 {
 	int cont = 1;
@@ -312,6 +372,10 @@ static void decode_arguments(int argc, char *argv[])
 			exit(EXIT_SUCCESS);
 			break;
 
+		case 'v':
+			verbose++;
+			break;
+
 		case 'h':
 			print_usage();
 			exit(EXIT_SUCCESS);
@@ -352,6 +416,10 @@ static void decode_arguments(int argc, char *argv[])
 			operation = OP_LEAVE;
 		} else if (strcmp(argv[optind], "dump") == 0) {
 			operation = OP_DUMP;
+		} else if (strcmp(argv[optind], "list") == 0) {
+			operation = OP_LIST;
+		} else if (strcmp(argv[optind], "ls") == 0) {
+			operation = OP_LIST;
 		} else
 			die("unknown option %s\n", argv[optind]);
 		optind++;
@@ -374,9 +442,10 @@ int main(int argc, char *argv[])
 		return do_leave();
 	case OP_DUMP:
 		return do_dump();
-	case OP_WAIT:
-		return -1;
+	case OP_LIST:
+		return do_list();
 	}
 
 	return EXIT_FAILURE;
 }
+
diff --git a/fence/fenced/cpg.c b/fence/fenced/cpg.c
index 430c21e..5f84220 100644
--- a/fence/fenced/cpg.c
+++ b/fence/fenced/cpg.c
@@ -1277,15 +1277,15 @@ int set_domain_info(struct fd *fd, struct fenced_domain *domain)
 	return 0;
 }
 
-int set_domain_members(struct fd *fd, int *member_count,
-		       struct fenced_node **members)
+int set_domain_nodes(struct fd *fd, int option, int *node_count,
+		     struct fenced_node **nodes_out)
 {
 	struct change *cg = fd->started_change;
 	struct fenced_node *nodes, *nodep;
 	struct member *memb;
 
 	if (!cg) {
-		*member_count = 0;
+		*node_count = 0;
 		return 0;
 	}
 
@@ -1298,8 +1298,8 @@ int set_domain_members(struct fd *fd, int *member_count,
 		set_node_info(fd, memb->nodeid, nodep++);
 	}
 
-	*member_count = cg->member_count;
-	*members = nodes;
+	*node_count = cg->member_count;
+	*nodes_out = nodes;
 	return 0;
 }
 
diff --git a/fence/fenced/fd.h b/fence/fenced/fd.h
index b111736..7b823d1 100644
--- a/fence/fenced/fd.h
+++ b/fence/fenced/fd.h
@@ -241,8 +241,8 @@ int fd_join(struct fd *fd);
 int fd_leave(struct fd *fd);
 int set_node_info(struct fd *fd, int nodeid, struct fenced_node *node);
 int set_domain_info(struct fd *fd, struct fenced_domain *domain);
-int set_domain_members(struct fd *fd, int *member_count,
-	struct fenced_node **members);
+int set_domain_nodes(struct fd *fd, int option, int *node_count,
+		     struct fenced_node **nodes);
 
 /* group.c */
 
@@ -252,8 +252,8 @@ int fd_join_group(struct fd *fd);
 int fd_leave_group(struct fd *fd);
 int set_node_info_group(struct fd *fd, int nodeid, struct fenced_node *node);
 int set_domain_info_group(struct fd *fd, struct fenced_domain *domain);
-int set_domain_members_group(struct fd *fd, int *member_count,
-	struct fenced_node **members);
+int set_domain_nodes_group(struct fd *fd, int option, int *node_count,
+			   struct fenced_node **nodes);
 
 /* main.c */
 
diff --git a/fence/fenced/fenced.h b/fence/fenced/fenced.h
index 140ecd2..fc75255 100644
--- a/fence/fenced/fenced.h
+++ b/fence/fenced/fenced.h
@@ -31,15 +31,17 @@
 #define FENCED_CMD_EXTERNAL		4
 #define FENCED_CMD_NODE_INFO		5
 #define FENCED_CMD_DOMAIN_INFO		6
-#define FENCED_CMD_DOMAIN_MEMBERS	7
+#define FENCED_CMD_DOMAIN_NODES		7
 
 struct fenced_header {
 	unsigned int magic;
 	unsigned int version;
 	unsigned int command;
-	unsigned int pad;
+	unsigned int option;
 	unsigned int len;
 	int data;	/* embedded command-specific data, for convenience */
+	int unused1;
+	int unsued2;
 };
 
 #endif
diff --git a/fence/fenced/group.c b/fence/fenced/group.c
index 22b6bd0..54bbb9b 100644
--- a/fence/fenced/group.c
+++ b/fence/fenced/group.c
@@ -431,8 +431,8 @@ int set_domain_info_group(struct fd *fd, struct fenced_domain *domain)
 	return 0;
 }
 
-int set_domain_members_group(struct fd *fd, int *member_count,
-			     struct fenced_node **members)
+int set_domain_nodes_group(struct fd *fd, int option, int *node_count,
+			   struct fenced_node **nodes_out)
 {
 	struct fenced_node *nodes = NULL, *nodep;
 	int i;
@@ -449,8 +449,8 @@ int set_domain_members_group(struct fd *fd, int *member_count,
 		set_node_info(fd, cb_members[i], nodep++);
 	}
  out:
-	*member_count = cb_member_count;
-	*members = nodes;
+	*node_count = cb_member_count;
+	*nodes_out = nodes;
 	return 0;
 }
 
diff --git a/fence/fenced/main.c b/fence/fenced/main.c
index 1cc46ef..bdd0f8b 100644
--- a/fence/fenced/main.c
+++ b/fence/fenced/main.c
@@ -358,11 +358,11 @@ static void query_domain_info(int f)
 	do_reply(f, FENCED_CMD_DOMAIN_INFO, rv, (char *)&domain, sizeof(domain));
 }
 
-static void query_domain_members(int f, int max)
+static void query_domain_nodes(int f, int option, int max)
 {
 	struct fd *fd;
-	int member_count = 0;
-	struct fenced_node *members = NULL;
+	int node_count = 0;
+	struct fenced_node *nodes = NULL;
 	int rv;
 
 	fd = find_fd("default");
@@ -372,26 +372,31 @@ static void query_domain_members(int f, int max)
 	}
 
 	if (group_mode == GROUP_LIBGROUP)
-		rv = set_domain_members(fd, &member_count, &members);
+		rv = set_domain_nodes(fd, option, &node_count, &nodes);
 	else
-		rv = set_domain_members(fd, &member_count, &members);
+		rv = set_domain_nodes(fd, option, &node_count, &nodes);
 
 	if (rv < 0) {
-		member_count = 0;
+		node_count = 0;
 		goto out;
 	}
-	if (member_count > max) {
+
+	/* node_count is the number of structs copied/returned; the caller's
+	   max may be less than that, in which case we copy as many as they
+	   asked for and return -E2BIG */
+
+	if (node_count > max) {
 		rv = -E2BIG;
-		member_count = max;
+		node_count = max;
 	} else {
-		rv = member_count;
+		rv = node_count;
 	}
  out:
-	do_reply(f, FENCED_CMD_DOMAIN_MEMBERS, rv,
-	         (char *)members, member_count * sizeof(struct fenced_node));
+	do_reply(f, FENCED_CMD_DOMAIN_NODES, rv,
+	         (char *)nodes, node_count * sizeof(struct fenced_node));
 
-	if (members)
-		free(members);
+	if (nodes)
+		free(nodes);
 }
 
 static void process_connection(int ci)
@@ -445,7 +450,7 @@ static void process_connection(int ci)
 	case FENCED_CMD_DUMP_DEBUG:
 	case FENCED_CMD_NODE_INFO:
 	case FENCED_CMD_DOMAIN_INFO:
-	case FENCED_CMD_DOMAIN_MEMBERS:
+	case FENCED_CMD_DOMAIN_NODES:
 		log_error("process_connection query on wrong socket");
 		break;
 	default:
@@ -556,8 +561,8 @@ static void *process_queries(void *arg)
 		case FENCED_CMD_DOMAIN_INFO:
 			query_domain_info(f);
 			break;
-		case FENCED_CMD_DOMAIN_MEMBERS:
-			query_domain_members(f, h.data);
+		case FENCED_CMD_DOMAIN_NODES:
+			query_domain_nodes(f, h.option, h.data);
 			break;
 		default:
 			break;
diff --git a/fence/libfenced/libfenced.h b/fence/libfenced/libfenced.h
index a79d188..69ecb6e 100644
--- a/fence/libfenced/libfenced.h
+++ b/fence/libfenced/libfenced.h
@@ -42,12 +42,17 @@ struct fenced_domain {
 	int state;
 };
 
+/* fenced_domain_nodes() types */
+#define FENCED_NODES_ALL	1
+#define FENCED_NODES_MEMBERS	2
+#define FENCED_NODES_VICTIMS	3
+
 int fenced_join(void);
 int fenced_leave(void);
 int fenced_dump_debug(char *buf);
 int fenced_external(char *name);
 int fenced_node_info(int nodeid, struct fenced_node *node);
 int fenced_domain_info(struct fenced_domain *domain);
-int fenced_domain_members(int max, int *count, struct fenced_node *members);
+int fenced_domain_nodes(int type, int max, int *count, struct fenced_node *nodes);
 
 #endif
diff --git a/fence/libfenced/main.c b/fence/libfenced/main.c
index 4bd928f..17dd37e 100644
--- a/fence/libfenced/main.c
+++ b/fence/libfenced/main.c
@@ -276,14 +276,15 @@ int fenced_domain_info(struct fenced_domain *domain)
 	return rv;
 }
 
-int fenced_domain_members(int max, int *count, struct fenced_node *members)
+int fenced_domain_nodes(int type, int max, int *count, struct fenced_node *nodes)
 {
 	struct fenced_header h, *rh;
 	char *reply;
 	int reply_len;
 	int fd, rv;
 
-	init_header(&h, FENCED_CMD_DOMAIN_MEMBERS, sizeof(h));
+	init_header(&h, FENCED_CMD_DOMAIN_NODES, sizeof(h));
+	h.option = type;
 	h.data = max;
 
 	reply_len = sizeof(struct fenced_header) + (max * sizeof(struct fenced_node));
@@ -315,9 +316,9 @@ int fenced_domain_members(int max, int *count, struct fenced_node *members)
 	if (rv == -E2BIG)
 		*count = max;
 	else
-		*count = rh->data;
+		*count = rv;
 
-	memcpy(members, (char *)reply + sizeof(struct fenced_header),
+	memcpy(nodes, (char *)reply + sizeof(struct fenced_header),
 	       *count * sizeof(struct fenced_node));
  out_close:
 	close(fd);


hooks/post-receive
--
Cluster Project


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