1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

ctdb-daemon: Move VNN map initialisation out of node loading

Each node reload unnecessarily and incorrectly resets the VNN map,
causing a potentially unnecessary recovery.  When nodes are reloaded
any newly deleted nodes should already be disconnected and any newly
added nodes should also be disconnected.  This means that reloading
the nodes file should not cause a change in the VNN map.

The current implementation also leaks memory every time the nodes are
reloaded.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
This commit is contained in:
Martin Schwenke 2015-02-17 12:34:41 +11:00 committed by Amitay Isaacs
parent ee073f60b1
commit db6385afe9
2 changed files with 31 additions and 22 deletions

View File

@ -1139,6 +1139,35 @@ static void ctdb_create_pidfile(pid_t pid)
}
}
static void ctdb_initialise_vnn_map(struct ctdb_context *ctdb)
{
int i, j, count;
/* initialize the vnn mapping table, skipping any deleted nodes */
ctdb->vnn_map = talloc(ctdb, struct ctdb_vnn_map);
CTDB_NO_MEMORY_FATAL(ctdb, ctdb->vnn_map);
count = 0;
for (i = 0; i < ctdb->num_nodes; i++) {
if ((ctdb->nodes[i]->flags & NODE_FLAGS_DELETED) == 0) {
count++;
}
}
ctdb->vnn_map->generation = INVALID_GENERATION;
ctdb->vnn_map->size = count;
ctdb->vnn_map->map = talloc_array(ctdb->vnn_map, uint32_t, ctdb->vnn_map->size);
CTDB_NO_MEMORY_FATAL(ctdb, ctdb->vnn_map->map);
for(i=0, j=0; i < ctdb->vnn_map->size; i++) {
if (ctdb->nodes[i]->flags & NODE_FLAGS_DELETED) {
continue;
}
ctdb->vnn_map->map[j] = i;
j++;
}
}
/*
start the protocol going as a daemon
*/
@ -1265,6 +1294,7 @@ int ctdb_start_daemon(struct ctdb_context *ctdb, bool do_fork)
}
}
ctdb_initialise_vnn_map(ctdb);
/* attach to existing databases */
if (ctdb_attach_databases(ctdb) != 0) {

View File

@ -164,7 +164,7 @@ static int ctdb_set_nlist(struct ctdb_context *ctdb, const char *nlist)
{
char **lines;
int nlines;
int i, j, num_present;
int i;
talloc_free(ctdb->nodes);
ctdb->nodes = NULL;
@ -179,7 +179,6 @@ static int ctdb_set_nlist(struct ctdb_context *ctdb, const char *nlist)
nlines--;
}
num_present = 0;
for (i=0; i < nlines; i++) {
char *node;
@ -202,28 +201,8 @@ static int ctdb_set_nlist(struct ctdb_context *ctdb, const char *nlist)
talloc_free(lines);
return -1;
}
num_present++;
}
/* initialize the vnn mapping table now that we have the nodes list,
skipping any deleted nodes
*/
ctdb->vnn_map = talloc(ctdb, struct ctdb_vnn_map);
CTDB_NO_MEMORY(ctdb, ctdb->vnn_map);
ctdb->vnn_map->generation = INVALID_GENERATION;
ctdb->vnn_map->size = num_present;
ctdb->vnn_map->map = talloc_array(ctdb->vnn_map, uint32_t, ctdb->vnn_map->size);
CTDB_NO_MEMORY(ctdb, ctdb->vnn_map->map);
for(i=0, j=0; i < ctdb->vnn_map->size; i++) {
if (ctdb->nodes[i]->flags & NODE_FLAGS_DELETED) {
continue;
}
ctdb->vnn_map->map[j] = i;
j++;
}
talloc_free(lines);
return 0;
}