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

[Cluster-devel] Cluster Project branch, master, updated. cluster-2.99.05-57-g2e429a3



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=2e429a3f1a4fa95dfae4365f8d3afd9bd25608f2

The branch, master has been updated
       via  2e429a3f1a4fa95dfae4365f8d3afd9bd25608f2 (commit)
      from  e88a7d8044de44be39369f99d65bdb818e478c97 (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 2e429a3f1a4fa95dfae4365f8d3afd9bd25608f2
Author: David Teigland <teigland redhat com>
Date:   Wed Jul 9 13:44:24 2008 -0500

    gfs_controld: add query code
    
    Also let group_tool query new daemons.
    
    Signed-off-by: David Teigland <teigland redhat com>

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

Summary of changes:
 fence/fenced/fenced.h               |    4 +-
 group/gfs_controld/cpg-new.c        |    1 +
 group/gfs_controld/gfs_daemon.h     |   14 ++-
 group/gfs_controld/group.c          |   21 ++
 group/gfs_controld/main.c           |  129 ++++++++++++
 group/libgfscontrol/libgfscontrol.h |   16 +-
 group/tool/Makefile                 |    7 +-
 group/tool/main.c                   |  392 +++++++++++++++++++++++++----------
 8 files changed, 462 insertions(+), 122 deletions(-)

diff --git a/fence/fenced/fenced.h b/fence/fenced/fenced.h
index cb09e12..fb7d951 100644
--- a/fence/fenced/fenced.h
+++ b/fence/fenced/fenced.h
@@ -7,8 +7,8 @@
 /* should match the same in fd.h */
 #define MAX_NODENAME_LEN		255
 
-#define FENCED_SOCK_PATH		"fenced_socket"
-#define FENCED_QUERY_SOCK_PATH		"fenced_query_socket"
+#define FENCED_SOCK_PATH		"fenced_sock"
+#define FENCED_QUERY_SOCK_PATH		"fenced_query_sock"
 
 #define FENCED_MAGIC			0x0FE11CED
 #define FENCED_VERSION			0x00010001
diff --git a/group/gfs_controld/cpg-new.c b/group/gfs_controld/cpg-new.c
index 95cc007..7070842 100644
--- a/group/gfs_controld/cpg-new.c
+++ b/group/gfs_controld/cpg-new.c
@@ -2593,3 +2593,4 @@ int set_mountgroup_nodes(struct mountgroup *mg, int option, int *node_count,
 	*nodes_out = nodes;
 	return 0;
 }
+
diff --git a/group/gfs_controld/gfs_daemon.h b/group/gfs_controld/gfs_daemon.h
index 58fa69e..7b1983a 100644
--- a/group/gfs_controld/gfs_daemon.h
+++ b/group/gfs_controld/gfs_daemon.h
@@ -208,6 +208,11 @@ void process_mountgroups(void);
 int gfs_join_mountgroup(struct mountgroup *mg);
 void gfs_leave_mountgroup(char *name, int mnterr);
 void gfs_mount_done(struct mountgroup *mg);
+int set_mountgroup_info(struct mountgroup *mg, struct gfsc_mountgroup *out);
+int set_node_info(struct mountgroup *mg, int nodeid, struct gfsc_node *node);
+int set_mountgroups(int *count, struct gfsc_mountgroup **mgs_out);
+int set_mountgroup_nodes(struct mountgroup *mg, int option, int *node_count,
+	struct gfsc_node **nodes_out);
 
 /* cpg-old.c */
 int setup_cpg_old(void);
@@ -216,7 +221,7 @@ int gfs_join_mountgroup_old(struct mountgroup *mg, struct gfsc_mount_args *ma);
 void gfs_leave_mountgroup_old(char *name, int mnterr);
 int send_group_message_old(struct mountgroup *mg, int len, char *buf);
 void save_message_old(struct mountgroup *mg, char *buf, int len, int from,
-		      int type);
+	int type);
 void send_withdraw_old(struct mountgroup *mg);
 int process_recovery_uevent_old(char *table);
 void ping_kernel_mount_old(char *table);
@@ -231,6 +236,13 @@ int do_withdraw_old(char *table);
 /* group.c */
 int setup_groupd(void);
 void process_groupd(int ci);
+int set_mountgroup_info_group(struct mountgroup *mg,
+	struct gfsc_mountgroup *out);
+int set_node_info_group(struct mountgroup *mg, int nodeid,
+	struct gfsc_node *node);
+int set_mountgroups_group(int *count, struct gfsc_mountgroup **mgs_out);
+int set_mountgroup_nodes_group(struct mountgroup *mg, int option,
+	int *node_count, struct gfsc_node **nodes_out);
 
 /* main.c */
 int do_read(int fd, void *buf, size_t count);
diff --git a/group/gfs_controld/group.c b/group/gfs_controld/group.c
index 0a6f530..6707341 100644
--- a/group/gfs_controld/group.c
+++ b/group/gfs_controld/group.c
@@ -175,3 +175,24 @@ int setup_groupd(void)
 	return rv;
 }
 
+int set_mountgroup_info_group(struct mountgroup *mg, struct gfsc_mountgroup *out)
+{
+	return 0;
+}
+
+int set_node_info_group(struct mountgroup *mg, int nodeid, struct gfsc_node *node)
+{
+	return 0;
+}
+
+int set_mountgroups_group(int *count, struct gfsc_mountgroup **mgs_out)
+{
+	return 0;
+}
+
+int set_mountgroup_nodes_group(struct mountgroup *mg, int option, int *node_count,
+			       struct gfsc_node **nodes_out)
+{
+	return 0;
+}
+
diff --git a/group/gfs_controld/main.c b/group/gfs_controld/main.c
index 60bd9b7..397662b 100644
--- a/group/gfs_controld/main.c
+++ b/group/gfs_controld/main.c
@@ -443,6 +443,122 @@ static void do_reply(int fd, int cmd, char *name, int result, void *buf,
 	free(reply);
 }
 
+static void query_mountgroup_info(int fd, char *name)
+{
+	struct mountgroup *mg;
+	struct gfsc_mountgroup mountgroup;
+	int rv;
+
+	mg = find_mg(name);
+	if (!mg) {
+		rv = -ENOENT;
+		goto out;
+	}
+
+	if (group_mode == GROUP_LIBGROUP)
+		rv = set_mountgroup_info_group(mg, &mountgroup);
+	else
+		rv = set_mountgroup_info(mg, &mountgroup);
+ out:
+	do_reply(fd, GFSC_CMD_MOUNTGROUP_INFO, name, rv,
+		 (char *)&mountgroup, sizeof(mountgroup));
+}
+
+static void query_node_info(int fd, char *name, int nodeid)
+{
+	struct mountgroup *mg;
+	struct gfsc_node node;
+	int rv;
+
+	mg = find_mg(name);
+	if (!mg) {
+		rv = -ENOENT;
+		goto out;
+	}
+
+	if (group_mode == GROUP_LIBGROUP)
+		rv = set_node_info_group(mg, nodeid, &node);
+	else
+		rv = set_node_info(mg, nodeid, &node);
+ out:
+	do_reply(fd, GFSC_CMD_NODE_INFO, name, rv,
+		 (char *)&node, sizeof(node));
+}
+
+static void query_mountgroups(int fd, int max)
+{
+	int mg_count = 0;
+	struct gfsc_mountgroup *mgs = NULL;
+	int rv, result;
+
+	if (group_mode == GROUP_LIBGROUP)
+		rv = set_mountgroups_group(&mg_count, &mgs);
+	else
+		rv = set_mountgroups(&mg_count, &mgs);
+
+	if (rv < 0) {
+		result = rv;
+		mg_count = 0;
+		goto out;
+	}
+
+	if (mg_count > max) {
+		result = -E2BIG;
+		mg_count = max;
+	} else {
+		result = mg_count;
+	}
+ out:
+	do_reply(fd, GFSC_CMD_MOUNTGROUPS, NULL, result,
+		 (char *)mgs, mg_count * sizeof(struct gfsc_mountgroup));
+
+	if (mgs)
+		free(mgs);
+}
+
+static void query_mountgroup_nodes(int fd, char *name, int option, int max)
+{
+	struct mountgroup *mg;
+	int node_count = 0;
+	struct gfsc_node *nodes = NULL;
+	int rv, result;
+
+	mg = find_mg(name);
+	if (!mg) {
+		result = -ENOENT;
+		node_count = 0;
+		goto out;
+	}
+
+	if (group_mode == GROUP_LIBGROUP)
+		rv = set_mountgroup_nodes_group(mg, option, &node_count, &nodes);
+	else
+		rv = set_mountgroup_nodes(mg, option, &node_count, &nodes);
+
+	if (rv < 0) {
+		result = rv;
+		node_count = 0;
+		goto out;
+	}
+
+	/* 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) {
+		result = -E2BIG;
+		node_count = max;
+	} else {
+		result = node_count;
+	}
+ out:
+	do_reply(fd, GFSC_CMD_MOUNTGROUP_NODES, name, result,
+		 (char *)nodes, node_count * sizeof(struct gfsc_node));
+
+	if (nodes)
+		free(nodes);
+}
+
 void client_reply_remount(struct mountgroup *mg, int result)
 {
 	struct gfsc_mount_args *ma = &mg->mount_args;
@@ -726,6 +842,7 @@ void process_connection(int ci)
 		if (group_mode == GROUP_LIBGROUP)
 			remount_mountgroup_old(ci, ma);
 #if 0
+		/* FIXME */
 		else
 			remount_mountgroup(ci, ma);
 #endif
@@ -838,6 +955,18 @@ static void *process_queries(void *arg)
 		case GFSC_CMD_DUMP_PLOCKS:
 			query_dump_plocks(f, h.name);
 			break;
+		case GFSC_CMD_MOUNTGROUP_INFO:
+			query_mountgroup_info(f, h.name);
+			break;
+		case GFSC_CMD_NODE_INFO:
+			query_node_info(f, h.name, h.data);
+			break;
+		case GFSC_CMD_MOUNTGROUPS:
+			query_mountgroups(f, h.data);
+			break;
+		case GFSC_CMD_MOUNTGROUP_NODES:
+			query_mountgroup_nodes(f, h.name, h.option, h.data);
+			break;
 		default:
 			break;
 		}
diff --git a/group/libgfscontrol/libgfscontrol.h b/group/libgfscontrol/libgfscontrol.h
index 90578e5..28b20e5 100644
--- a/group/libgfscontrol/libgfscontrol.h
+++ b/group/libgfscontrol/libgfscontrol.h
@@ -15,9 +15,9 @@
 #define GFSC_NF_DISALLOWED		0x00000004 /* node disallowed in cg */
 #define GFSC_NF_KERNEL_MOUNT_DONE	0x00000008
 #define GFSC_NF_KERNEL_MOUNT_ERROR	0x00000010
-#define GFSC_NF_READONLY		0x00000010
-#define GFSC_NF_SPECTATOR		0x00000010
-#define GFSC_NF_CHECK_DLM		0x00000010
+#define GFSC_NF_READONLY		0x00000020
+#define GFSC_NF_SPECTATOR		0x00000040
+#define GFSC_NF_CHECK_DLM		0x00000080
 
 struct gfsc_node {
 	int nodeid;
@@ -42,11 +42,11 @@ struct gfsc_change {
 #define GFSC_MF_JOINING			0x00000001
 #define GFSC_MF_LEAVING			0x00000002
 #define GFSC_MF_KERNEL_STOPPED		0x00000004
-#define GFSC_MF_KERNEL_MOUNT_DONE	0x00000004
-#define GFSC_MF_KERNEL_MOUNT_ERROR	0x00000004
-#define GFSC_MF_FIRST_RECOVERY_NEEDED	0x00000008
-#define GFSC_MF_FIRST_RECOVERY_MSG	0x00000010
-#define GFSC_MF_LOCAL_RECOVERY_BUSY	0x00000020
+#define GFSC_MF_KERNEL_MOUNT_DONE	0x00000008
+#define GFSC_MF_KERNEL_MOUNT_ERROR	0x00000010
+#define GFSC_MF_FIRST_RECOVERY_NEEDED	0x00000020
+#define GFSC_MF_FIRST_RECOVERY_MSG	0x00000040
+#define GFSC_MF_LOCAL_RECOVERY_BUSY	0x00000080
 
 struct gfsc_mountgroup {
 	struct gfsc_change cg_prev;	/* completed change (started_change) */
diff --git a/group/tool/Makefile b/group/tool/Makefile
index 30ba011..e7cbd58 100644
--- a/group/tool/Makefile
+++ b/group/tool/Makefile
@@ -13,10 +13,15 @@ include $(OBJDIR)/make/uninstall.mk
 OBJS=	main.o
 
 CFLAGS += -I$(S) -I$(S)/../daemon/ -I$(S)/../lib/
+CFLAGS += -I${dlmcontrolincdir}
+CFLAGS += -I$(S)/../../fence/libfenced
+CFLAGS += -I$(S)/../libgfscontrol
 CFLAGS += -I${incdir}
 
 LDFLAGS += -L../lib -lgroup
-
+LDFLAGS += -L${dlmcontrollibdir} -ldlmcontrol
+LDFLAGS += -L../../fence/libfenced -lfenced
+LDFLAGS += -L../libgfscontrol -lgfscontrol
 
 ${TARGET}: ${OBJS}
 	$(CC) -o $@ $^ $(LDFLAGS)
diff --git a/group/tool/main.c b/group/tool/main.c
index 0980444..e3e1ee5 100644
--- a/group/tool/main.c
+++ b/group/tool/main.c
@@ -10,28 +10,22 @@
 #include <string.h>
 #include <errno.h>
 #include <netinet/in.h>
+#include <linux/dlmconstants.h>
 
 #include "libgroup.h"
 #include "groupd.h"
+#include "libfenced.h"
+#include "libdlmcontrol.h"
+#include "libgfscontrol.h"
 
-#define MAX_GROUPS			64
-#define OPTION_STRING			"hVv"
+#define MAX_NODES			128
+#define MAX_LS				128
+#define MAX_MG				128
+#define MAX_GROUPS			128
 
-/* copied from cluster/group/gfs_controld/lock_dlm.h */
-#define LOCK_DLM_SOCK_PATH		"gfs_controld_sock"
+#define GROUPD_DUMP_SIZE		(1024 * 1024)
 
-/* copied from cluster/fence/fenced/fd.h */
-#define FENCED_SOCK_PATH		"fenced_socket"
-
-/* needs to match the same in cluster/group/daemon/gd_internal.h and
-   cluster/group/gfs_controld/lock_dlm.h and cluster/fence/fenced/fd.h */
-#define DUMP_SIZE			(1024 * 1024)
-
-/* needs to match the same in cluster/group/gfs_controld/lock_dlm.h,
-   it's the message size that gfs_controld takes */
-#define MAXLINE				256
-
-#define OP_LS				1
+#define OP_LIST				1
 #define OP_DUMP				2
 #define OP_LOG				3
 
@@ -39,6 +33,8 @@ static char *prog_name;
 static int operation;
 static int opt_ind;
 static int verbose;
+static int all_daemons;
+
 
 static int do_write(int fd, void *buf, size_t count)
 {
@@ -101,6 +97,8 @@ static void print_usage(void)
 	printf("\n");
 }
 
+#define OPTION_STRING "ahVv"
+
 static void decode_arguments(int argc, char **argv)
 {
 	int cont = 1;
@@ -110,6 +108,10 @@ static void decode_arguments(int argc, char **argv)
 		optchar = getopt(argc, argv, OPTION_STRING);
 
 		switch (optchar) {
+		case 'a':
+			all_daemons = 1;
+			break;
+
 		case 'v':
 			verbose = 1;
 			break;
@@ -150,7 +152,7 @@ static void decode_arguments(int argc, char **argv)
 			break;
 		} else if (strcmp(argv[optind], "ls") == 0 ||
 		           strcmp(argv[optind], "list") == 0) {
-			operation = OP_LS;
+			operation = OP_LIST;
 			opt_ind = optind + 1;
 			break;
 		} else if (strcmp(argv[optind], "log") == 0) {
@@ -162,7 +164,7 @@ static void decode_arguments(int argc, char **argv)
 	}
 
 	if (!operation)
-		operation = OP_LS;
+		operation = OP_LIST;
 }
 
 /* copied from grouip/daemon/gd_internal.h, must keep in sync */
@@ -255,7 +257,7 @@ static int member_compare(const void *va, const void *vb)
 	return *a - *b;
 }
 
-int do_ls(int argc, char **argv)
+static int groupd_list(int argc, char **argv, int *total)
 {
 	group_data_t data[MAX_GROUPS];
 	int i, j, rv, count = 0, level;
@@ -278,10 +280,14 @@ int do_ls(int argc, char **argv)
 	} else
 		rv = group_get_groups(MAX_GROUPS, &count, data);
 
-	if (rv < 0) {
-		fprintf(stderr,"Unable to connect to groupd.  Is it running?\n");
+	if (rv < 0)
 		return rv;
-	}
+
+	if (!count)
+		return 0;
+
+	*total = count;
+
 	for (i = 0; i < count; i++) {
 		len = strlen(data[i].name);
 		if (len > max_name)
@@ -326,116 +332,226 @@ int do_ls(int argc, char **argv)
 	return 0;
 }
 
-static int connect_daemon(char *path)
+static int fenced_node_compare(const void *va, const void *vb)
 {
-	struct sockaddr_un sun;
-	socklen_t addrlen;
-	int rv, fd;
+	const struct fenced_node *a = va;
+	const struct fenced_node *b = vb;
 
-	fd = socket(PF_UNIX, SOCK_STREAM, 0);
-	if (fd < 0)
-		goto out;
+	return a->nodeid - b->nodeid;
+}
 
-	memset(&sun, 0, sizeof(sun));
-	sun.sun_family = AF_UNIX;
-	strcpy(&sun.sun_path[1], path);
-	addrlen = sizeof(sa_family_t) + strlen(sun.sun_path+1) + 1;
+static void fenced_list(void)
+{
+	struct fenced_domain d;
+	struct fenced_node nodes[MAX_NODES];
+	struct fenced_node *np;
+	int node_count;
+	int rv, j;
 
-	rv = connect(fd, (struct sockaddr *) &sun, addrlen);
-	if (rv < 0) {
-		close(fd);
-		fd = rv;
+	rv = fenced_domain_info(&d);
+	if (rv < 0)
+		return;
+
+	printf("fence        0     %-*s %08x %d\n",
+	       16, "default", 0, d.state);
+
+	node_count = 0;
+	memset(&nodes, 0, sizeof(nodes));
+
+	rv = fenced_domain_nodes(FENCED_NODES_MEMBERS, MAX_NODES,
+				 &node_count, nodes);
+	if (rv < 0 || !node_count)
+		goto do_nodeids;
+
+	qsort(&nodes, node_count, sizeof(struct fenced_node),
+	      fenced_node_compare);
+
+ do_nodeids:
+	printf("[");
+	np = nodes;
+	for (j = 0; j < node_count; j++) {
+		if (j)
+			printf(" ");
+		printf("%d", np->nodeid);
+		np++;
 	}
- out:
-	return fd;
+	printf("]\n");
 }
 
-int do_dump(int argc, char **argv, int fd)
+static int dlmc_node_compare(const void *va, const void *vb)
 {
-	char inbuf[DUMP_SIZE];
-	char outbuf[GROUPD_MSGLEN];
+	const struct dlmc_node *a = va;
+	const struct dlmc_node *b = vb;
+
+	return a->nodeid - b->nodeid;
+}
+
+static void dlm_controld_list(void)
+{
+	struct dlmc_lockspace lss[MAX_LS];
+	struct dlmc_node nodes[MAX_NODES];
+	struct dlmc_node *np;
+	struct dlmc_lockspace *ls;
+	char *name = NULL;
+	int node_count;
+	int ls_count;
 	int rv;
+	int i, j;
+
+	memset(lss, 0, sizeof(lss));
+
+	if (name) {
+		rv = dlmc_lockspace_info(name, lss);
+		if (rv < 0)
+			return;
+		ls_count = 1;
+	} else {
+		rv = dlmc_lockspaces(MAX_LS, &ls_count, lss);
+		if (rv < 0)
+			return;
+	}
 
-	memset(inbuf, 0, sizeof(inbuf));
-	memset(outbuf, 0, sizeof(outbuf));
+	for (i = 0; i < ls_count; i++) {
+		ls = &lss[i];
 
-	sprintf(outbuf, "dump");
+		printf("dlm          1     %-*s %08x %x\n",
+			16, ls->name, ls->global_id, ls->flags);
 
-	rv = do_write(fd, outbuf, sizeof(outbuf));
-	if (rv < 0) {
-		printf("dump write error %d errno %d\n", rv, errno);
-		return -1;
+		node_count = 0;
+		memset(&nodes, 0, sizeof(nodes));
+
+		rv = dlmc_lockspace_nodes(ls->name, DLMC_NODES_MEMBERS,
+					  MAX_NODES, &node_count, nodes);
+		if (rv < 0 || !node_count)
+			goto do_nodeids;
+
+		qsort(nodes, node_count, sizeof(struct dlmc_node),
+		      dlmc_node_compare);
+
+ do_nodeids:
+		printf("[");
+		np = nodes;
+		for (j = 0; j < node_count; j++) {
+			if (j)
+				printf(" ");
+			printf("%d", np->nodeid);
+			np++;
+		}
+		printf("]\n");
 	}
+}
 
-	do_read(fd, inbuf, sizeof(inbuf));
-	do_write(STDOUT_FILENO, inbuf, strlen(inbuf));
+static int gfsc_node_compare(const void *va, const void *vb)
+{
+	const struct gfsc_node *a = va;
+	const struct gfsc_node *b = vb;
 
-	close(fd);
-	return 0;
+	return a->nodeid - b->nodeid;
 }
 
-int do_maxline_dump(int argc, char **argv, int fd)
+static void gfs_controld_list(void)
 {
-	char inbuf[DUMP_SIZE];
-	char outbuf[MAXLINE];
+	struct gfsc_mountgroup mgs[MAX_MG];
+	struct gfsc_node nodes[MAX_NODES];
+	struct gfsc_node *np;
+	struct gfsc_mountgroup *mg;
+	char *name = NULL;
+	int node_count;
+	int mg_count;
 	int rv;
+	int i, j;
+
+	memset(mgs, 0, sizeof(mgs));
+
+	if (name) {
+		rv = gfsc_mountgroup_info(name, mgs);
+		if (rv < 0)
+			return;
+		mg_count = 1;
+	} else {
+		rv = gfsc_mountgroups(MAX_MG, &mg_count, mgs);
+		if (rv < 0)
+			return;
+	}
 
-	memset(inbuf, 0, sizeof(inbuf));
-	memset(outbuf, 0, sizeof(outbuf));
+	for (i = 0; i < mg_count; i++) {
+		mg = &mgs[i];
 
-	sprintf(outbuf, "dump");
+		printf("gfs          2     %-*s %08x %x\n",
+			16, mg->name, mg->global_id, mg->flags);
 
-	rv = do_write(fd, outbuf, sizeof(outbuf));
-	if (rv < 0) {
-		printf("dump write error %d errno %d\n", rv, errno);
-		return -1;
-	}
+		node_count = 0;
+		memset(&nodes, 0, sizeof(nodes));
 
-	do_read(fd, inbuf, sizeof(inbuf));
-	do_write(STDOUT_FILENO, inbuf, sizeof(inbuf));
+		rv = gfsc_mountgroup_nodes(mg->name, GFSC_NODES_MEMBERS,
+					   MAX_NODES, &node_count, nodes);
+		if (rv < 0 || !node_count)
+			goto do_nodeids;
 
-	close(fd);
-	return 0;
+		qsort(nodes, node_count, sizeof(struct dlmc_node),
+		      gfsc_node_compare);
+
+ do_nodeids:
+		printf("[");
+		np = nodes;
+		for (j = 0; j < node_count; j++) {
+			if (j)
+				printf(" ");
+			printf("%d", np->nodeid);
+			np++;
+		}
+		printf("]\n");
+	}
 }
 
-int do_plock_dump(int argc, char **argv, int fd)
+static int connect_daemon(char *path)
 {
-	char inbuf[MAXLINE];
-	char outbuf[MAXLINE];
-	int rv;
+	struct sockaddr_un sun;
+	socklen_t addrlen;
+	int rv, fd;
 
-	memset(outbuf, 0, sizeof(outbuf));
+	fd = socket(PF_UNIX, SOCK_STREAM, 0);
+	if (fd < 0)
+		goto out;
+
+	memset(&sun, 0, sizeof(sun));
+	sun.sun_family = AF_UNIX;
+	strcpy(&sun.sun_path[1], path);
+	addrlen = sizeof(sa_family_t) + strlen(sun.sun_path+1) + 1;
 
-	if (opt_ind + 1 >= argc) {
-		printf("plocks option requires a group name\n");
-		return -1;
+	rv = connect(fd, (struct sockaddr *) &sun, addrlen);
+	if (rv < 0) {
+		close(fd);
+		fd = rv;
 	}
+ out:
+	return fd;
+}
 
-	sprintf(outbuf, "plocks %s", argv[opt_ind + 1]);
+static void groupd_dump_debug(int argc, char **argv, char *inbuf)
+{
+	char outbuf[GROUPD_MSGLEN];
+	int rv, fd;
+
+	fd = connect_daemon(GROUPD_SOCK_PATH);
+	if (fd < 0)
+		return;
+
+	memset(outbuf, 0, sizeof(outbuf));
+	sprintf(outbuf, "dump");
 
 	rv = do_write(fd, outbuf, sizeof(outbuf));
 	if (rv < 0) {
 		printf("dump write error %d errno %d\n", rv, errno);
-		return -1;
+		return;
 	}
 
-	while (1) {
-		memset(&inbuf, 0, sizeof(inbuf));
-		rv = read(fd, inbuf, sizeof(inbuf));
-		if (rv <= 0)
-			break;
-		rv = write(STDOUT_FILENO, inbuf, rv);
-		if (rv < 0) {
-			printf("dump write error %d errno %d\n", rv, errno);
-			return  -1;
-		}
-	}
+	do_read(fd, inbuf, sizeof(inbuf));
 
 	close(fd);
-	return 0;
 }
 
-int do_log(char *comment)
+static int do_log(char *comment)
 {
 	char buf[GROUPD_MSGLEN];
 	int fd, rv;
@@ -452,43 +568,99 @@ int do_log(char *comment)
 
 int main(int argc, char **argv)
 {
-	int fd;
+	int total = 0;
 
 	prog_name = argv[0];
 	decode_arguments(argc, argv);
 
 	switch (operation) {
-	case OP_LS:
-		return do_ls(argc, argv);
+	case OP_LIST:
+		if (all_daemons) {
+			if (verbose) {
+				system("fence_tool ls -v");
+				system("dlm_tool ls -v");
+				system("gfs_control ls -v");
+			} else {
+				system("fence_tool ls");
+				system("dlm_tool ls");
+				system("gfs_control ls");
+			}
+			break;
+		}
+
+		/* If no groupd or no groups found in groupd, then try
+		   the querying the daemons.  Print any data from the
+		   new daemons in a format similar to the old format. */
+
+		groupd_list(argc, argv, &total);
+		if (total)
+			break;
+
+		printf("type         level name             id       state\n");
+		fenced_list();
+		dlm_controld_list();
+		gfs_controld_list();
+		break;
 
 	case OP_DUMP:
 		if (opt_ind && opt_ind < argc) {
 			if (!strncmp(argv[opt_ind], "gfs", 3)) {
-				fd = connect_daemon(LOCK_DLM_SOCK_PATH);
-				if (fd < 0)
-					return -1;
-				return do_maxline_dump(argc, argv, fd);
+				char gbuf[GFSC_DUMP_SIZE];
+
+				memset(gbuf, 0, sizeof(gbuf));
+
+				printf("dump gfs\n");
+				gfsc_dump_debug(gbuf);
+
+				do_write(STDOUT_FILENO, gbuf, strlen(gbuf));
+			}
+
+			if (!strncmp(argv[opt_ind], "dlm", 3)) {
+				char dbuf[DLMC_DUMP_SIZE];
+
+				memset(dbuf, 0, sizeof(dbuf));
+
+				printf("dump dlm\n");
+				dlmc_dump_debug(dbuf);
+
+				do_write(STDOUT_FILENO, dbuf, strlen(dbuf));
 			}
 
 			if (!strncmp(argv[opt_ind], "fence", 5)) {
-				fd = connect_daemon(FENCED_SOCK_PATH);
-				if (fd < 0)
-					return -1;
-				return do_maxline_dump(argc, argv, fd);
+				char fbuf[FENCED_DUMP_SIZE];
+
+				memset(fbuf, 0, sizeof(fbuf));
+
+				fenced_dump_debug(fbuf);
+
+				do_write(STDOUT_FILENO, fbuf, strlen(fbuf));
 			}
 
-			if (!strncmp(argv[opt_ind], "plocks", 5)) {
-				fd = connect_daemon(LOCK_DLM_SOCK_PATH);
-				if (fd < 0)
+			if (!strncmp(argv[opt_ind], "plocks", 6)) {
+				char pbuf[DLMC_DUMP_SIZE];
+
+				if (opt_ind + 1 >= argc) {
+					printf("plock dump requires name\n");
 					return -1;
-				return do_plock_dump(argc, argv, fd);
+				}
+
+				memset(pbuf, 0, sizeof(pbuf));
+
+				dlmc_dump_plocks(argv[opt_ind + 1], pbuf);
+
+				do_write(STDOUT_FILENO, pbuf, strlen(pbuf));
 			}
+		} else {
+			char rbuf[GROUPD_DUMP_SIZE];
+
+			memset(rbuf, 0, sizeof(rbuf));
+
+			groupd_dump_debug(argc, argv, rbuf);
+
+			do_write(STDOUT_FILENO, rbuf, strlen(rbuf));
 		}
 
-		fd = connect_daemon(GROUPD_SOCK_PATH);
-		if (fd < 0)
-			break;
-		return do_dump(argc, argv, fd);
+		break;
 
 	case OP_LOG:
 		if (opt_ind && opt_ind < argc) {


hooks/post-receive
--
Cluster Project


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