All of lore.kernel.org
 help / color / mirror / Atom feed
From: ccaulfield@sourceware.org <ccaulfield@sourceware.org>
To: lvm-devel@redhat.com
Subject: LVM2 ./WHATS_NEW daemons/clvmd/clvmd-cman.c
Date: 9 May 2008 07:20:04 -0000	[thread overview]
Message-ID: <20080509072004.6399.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	ccaulfield at 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);
-	}
 }
 
 



             reply	other threads:[~2008-05-09  7:20 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-09  7:20 ccaulfield [this message]
  -- strict thread matches above, loose matches on Subject: below --
2008-04-01 15:01 LVM2 ./WHATS_NEW daemons/clvmd/clvmd-cman.c ccaulfield
2008-03-25 10:42 ccaulfield
2007-05-02  8:23 pcaulfield
2007-04-23 14:55 pcaulfield

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080509072004.6399.qmail@sourceware.org \
    --to=ccaulfield@sourceware.org \
    --cc=lvm-devel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.