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

[lvm-devel] LVM2 ./WHATS_NEW daemons/clvmd/clvmd-cman.c



CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	ccaulfield sourceware org	2008-05-09 07:20:04

Modified files:
	.              : WHATS_NEW 
	daemons/clvmd  : clvmd-cman.c 

Log message:
	Make clvmd-cman use a hash rather than an array for node updown info.
	This will allow it to cope with very large nodeids such as those
	generated by clusters using cman_tool join -X

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.870&r2=1.871
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd-cman.c.diff?cvsroot=lvm2&r1=1.22&r2=1.23

--- LVM2/WHATS_NEW	2008/05/08 18:35:58	1.870
+++ LVM2/WHATS_NEW	2008/05/09 07:20:04	1.871
@@ -1,5 +1,6 @@
 Version 2.02.38 - 
 =================================
+  Make clvmd-cman use a hash rather than an array for node updown info.
   Check lv_count in vg_validate.
   Add --prefixes to reporting tools for field name prefix output format.
 
--- LVM2/daemons/clvmd/clvmd-cman.c	2008/04/01 15:01:30	1.22
+++ LVM2/daemons/clvmd/clvmd-cman.c	2008/05/09 07:20:04	1.23
@@ -36,6 +36,7 @@
 #include <fcntl.h>
 #include <getopt.h>
 #include <errno.h>
+#include <libdevmapper.h>
 #include <libdlm.h>
 
 #include "clvmd-comms.h"
@@ -46,13 +47,17 @@
 
 #define LOCKSPACE_NAME "clvmd"
 
+struct clvmd_node
+{
+	struct cman_node *node;
+	int clvmd_up;
+};
+
 static int num_nodes;
 static struct cman_node *nodes = NULL;
 static struct cman_node this_node;
 static int count_nodes; /* size of allocated nodes array */
-static int max_updown_nodes = 50;	/* Current size of the allocated array */
-/* Node up/down status, indexed by nodeid */
-static int *node_updown = NULL;
+static struct dm_hash_table *node_updown_hash;
 static dlm_lshandle_t *lockspace;
 static cman_handle_t c_handle;
 
@@ -72,6 +77,8 @@
 
 static int _init_cluster(void)
 {
+	node_updown_hash = dm_hash_create(100);
+
 	/* Open the cluster communication socket */
 	c_handle = cman_init(NULL);
 	if (!c_handle) {
@@ -165,8 +172,10 @@
 
 	for (i = 0; i < _get_num_nodes(); i++) {
 		if (nodes[i].cn_member && nodes[i].cn_nodeid) {
-			callback(client, (char *)&nodes[i].cn_nodeid, node_updown[nodes[i].cn_nodeid]);
-			if (!node_updown[nodes[i].cn_nodeid])
+			int up = (int)(long)dm_hash_lookup_binary(node_updown_hash, (char *)&nodes[i].cn_nodeid, sizeof(int));
+
+			callback(client, (char *)&nodes[i].cn_nodeid, up);
+			if (!up)
 				somedown = -1;
 		}
 	}
@@ -184,7 +193,7 @@
 		log_notice("clvmd on node %s has died\n", namebuf);
 		DEBUGLOG("Got port closed message, removing node %s\n", namebuf);
 
-		node_updown[arg] = 0;
+		dm_hash_insert_binary(node_updown_hash, (char *)&arg, sizeof(int), (void *)0);
 		break;
 
 	case CMAN_REASON_STATECHANGE:
@@ -239,22 +248,7 @@
 	/* It's up ! */
 	int nodeid = nodeid_from_csid(csid);
 
-	if (nodeid >= max_updown_nodes) {
-	        int new_size = nodeid + 10;
-		int *new_updown = realloc(node_updown, sizeof(int) * new_size);
-
-		if (new_updown) {
-			node_updown = new_updown;
-			max_updown_nodes = new_size;
-			DEBUGLOG("realloced more space for nodes. now %d\n",
-				 max_updown_nodes);
-		} else {
-			log_error
-				("Realloc failed. Node status for clvmd will be wrong. quitting\n");
-			exit(999);
-		}
-	}
-	node_updown[nodeid] = 1;
+	dm_hash_insert_binary(node_updown_hash, (char *)&nodeid, sizeof(int), (void *)1);
 	DEBUGLOG("Added new node %d to updown list\n", nodeid);
 }
 
@@ -288,7 +282,12 @@
 	int i;
 
 	for (i = 0; i < num_nodes; i++) {
-		node_updown[nodes[i].cn_nodeid] = is_listening(nodes[i].cn_nodeid);
+		int nodeid = nodes[i].cn_nodeid;
+
+		if (is_listening(nodeid) == 1)
+			dm_hash_insert_binary(node_updown_hash, (void *)&nodeid, sizeof(int), (void*)1);
+		else
+			dm_hash_insert_binary(node_updown_hash, (void *)&nodeid, sizeof(int), (void*)0);
 	}
 }
 
@@ -332,16 +331,6 @@
 		if (nodes[i].cn_nodeid > high_nodeid)
 			high_nodeid = nodes[i].cn_nodeid;
 	}
-
-	if (node_updown == NULL) {
-		size_t buf_len;
-		if (high_nodeid >= max_updown_nodes)
-			max_updown_nodes = high_nodeid + 1;
-		buf_len = sizeof(int) * max_updown_nodes;
-		node_updown = malloc(buf_len);
-		if (node_updown)
-			memset(node_updown, 0, buf_len);
-	}
 }
 
 


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