Rev 198: merge vnn_map code from ronnie in http://samba.org/~tridge/ctdb

tridge at samba.org tridge at samba.org
Fri Apr 27 09:01:04 GMT 2007


------------------------------------------------------------
revno: 198
revision-id: tridge at samba.org-20070427090103-i8wupn3xkdt3f7wy
parent: tridge at samba.org-20070426212926-5pgrco1jswx21t63
parent: sahlberg at ronnie-20070427084352-a68b95ed2ab8e2d6
committer: Andrew Tridgell <tridge at samba.org>
branch nick: tridge
timestamp: Fri 2007-04-27 11:01:03 +0200
message:
  merge vnn_map code from ronnie
modified:
  common/cmdline.c               cmdline.c-20070416041216-w1zvz91bkdsgjckw-1
  common/ctdb_daemon.c           ctdb_daemon.c-20070409200331-3el1kqgdb9m4ib0g-1
  common/ctdb_ltdb.c             ctdb_ltdb.c-20061128065342-to93h6eejj5kon81-2
  include/ctdb_private.h         ctdb_private.h-20061117234101-o3qt14umlg9en8z0-13
    ------------------------------------------------------------
    revno: 197.1.1
    merged: sahlberg at ronnie-20070427084352-a68b95ed2ab8e2d6
    parent: tridge at samba.org-20070426212926-5pgrco1jswx21t63
    committer: Ronnie Sahlberg <sahlberg at ronnie>
    branch nick: ctdb
    timestamp: Fri 2007-04-27 18:43:52 +1000
    message:
      add a mapping table from a hash value to a lmaster vnn number
      
      update ctdb_lmaster() return the lmaster based on this tables contents
      
      
      initialize the vnn table based on number of nodes for now.
      later when recovery is implemented the recovery process will populate 
      this mapping table.
=== modified file 'common/cmdline.c'
--- a/common/cmdline.c	2007-04-26 17:27:07 +0000
+++ b/common/cmdline.c	2007-04-27 08:43:52 +0000
@@ -66,7 +66,7 @@
 struct ctdb_context *ctdb_cmdline_init(struct event_context *ev)
 {
 	struct ctdb_context *ctdb;
-	int ret;
+	int i, ret;
 
 	if (ctdb_cmdline.nlist == NULL || ctdb_cmdline.myaddress == NULL) {
 		printf("You must provide a node list with --nlist and an address with --listen\n");
@@ -120,6 +120,31 @@
 		exit(1);
 	}
 
+	/* initialize the vnn mapping table */
+/*
+XXX we currently initialize it to the maximum number of nodes to 
+XXX make it behave the same way as previously.  
+XXX Once we have recovery working we should initialize this always to 
+XXX generation==0 (==invalid) and let the recovery tool populate this 
+XXX table for the daemons. 
+*/
+	ctdb->vnn_map = talloc_zero(ctdb, struct ctdb_vnn_map);
+	if (ctdb->vnn_map == NULL) {
+		DEBUG(0,(__location__ " Unable to allocate vnn_map structure\n"));
+		exit(1);
+	}
+	ctdb->vnn_map->generation = 1;
+	ctdb->vnn_map->size = 1024;
+	ctdb->vnn_map->map = talloc_array(ctdb->vnn_map, uint32_t, ctdb->vnn_map->size);
+	if (ctdb->vnn_map->map == NULL) {
+		DEBUG(0,(__location__ " Unable to allocate vnn_map->map structure\n"));
+		exit(1);
+	}
+	for(i=0;i<ctdb->vnn_map->size;i++){
+		ctdb->vnn_map->map[i] = i%ctdb->num_nodes;
+	}
+
+
 	return ctdb;
 }
 

=== modified file 'common/ctdb_daemon.c'
--- a/common/ctdb_daemon.c	2007-04-26 21:10:35 +0000
+++ b/common/ctdb_daemon.c	2007-04-27 08:43:52 +0000
@@ -678,6 +678,7 @@
 	
 	close(fd[1]);
 
+
 	ctdb->ev = event_context_init(NULL);
 	fde = event_add_fd(ctdb->ev, ctdb, fd[0], EVENT_FD_READ, ctdb_read_from_parent, &fd[0]);
 	fde = event_add_fd(ctdb->ev, ctdb, ctdb->daemon.sd, EVENT_FD_READ, ctdb_accept_client, ctdb);

=== modified file 'common/ctdb_ltdb.c'
--- a/common/ctdb_ltdb.c	2007-04-26 21:10:35 +0000
+++ b/common/ctdb_ltdb.c	2007-04-27 08:43:52 +0000
@@ -124,7 +124,12 @@
 */
 uint32_t ctdb_lmaster(struct ctdb_context *ctdb, const TDB_DATA *key)
 {
-	return ctdb_hash(key) % ctdb->num_nodes;
+	uint32_t idx, lmaster;
+
+	idx = ctdb_hash(key) % ctdb->vnn_map->size;
+	lmaster = ctdb->vnn_map->map[idx];
+
+	return lmaster;
 }
 
 

=== modified file 'include/ctdb_private.h'
--- a/include/ctdb_private.h	2007-04-26 21:10:35 +0000
+++ b/include/ctdb_private.h	2007-04-27 08:43:52 +0000
@@ -157,6 +157,14 @@
 	double max_lockwait_latency;
 };
 
+/* table that contains the mapping between a hash value and lmaster
+ */
+struct ctdb_vnn_map {
+	uint32_t generation;
+	uint32_t size;
+	uint32_t *map;
+};
+
 /* main state of the ctdb daemon */
 struct ctdb_context {
 	struct event_context *ev;
@@ -181,6 +189,7 @@
 	struct ctdb_message_list *message_list;
 	struct ctdb_daemon_data daemon;
 	struct ctdb_status status;
+	struct ctdb_vnn_map *vnn_map;
 };
 
 struct ctdb_db_context {



More information about the samba-cvs mailing list