hdr->operation = operation;
hdr->ctdb_magic = CTDB_MAGIC;
hdr->ctdb_version = CTDB_VERSION;
- hdr->srcnode = ctdb->vnn;
+ hdr->srcnode = ctdb->pnn;
if (ctdb->vnn_map) {
hdr->generation = ctdb->vnn_map->generation;
}
/* we need to force the record to be written out if this was a remote access,
so that the lacount is updated */
- if (c->new_data == NULL && header->laccessor != ctdb->vnn) {
+ if (c->new_data == NULL && header->laccessor != ctdb->pnn) {
c->new_data = &c->record_data;
}
state->call = *call;
state->ctdb_db = ctdb_db;
- ret = ctdb_call_local(ctdb_db, &state->call, header, state, data, ctdb->vnn);
+ ret = ctdb_call_local(ctdb_db, &state->call, header, state, data, ctdb->pnn);
return state;
}
ret = ctdb_ltdb_fetch(ctdb_db, call->key, &header, ctdb_db, &data);
- if (ret == 0 && header.dmaster == ctdb->vnn) {
+ if (ret == 0 && header.dmaster == ctdb->pnn) {
state = ctdb_client_call_local_send(ctdb_db, call, &header, &data);
talloc_free(data.dptr);
ctdb_ltdb_unlock(ctdb_db, call->key);
DEBUG(4,("ctdb_fetch_lock: done local fetch\n"));
- if (ret != 0 || h->header.dmaster != ctdb_db->ctdb->vnn) {
+ if (ret != 0 || h->header.dmaster != ctdb_db->ctdb->pnn) {
ctdb_ltdb_unlock(ctdb_db, key);
ret = ctdb_client_force_migration(ctdb_db, key);
if (ret != 0) {
*/
uint32_t ctdb_get_vnn(struct ctdb_context *ctdb)
{
- return ctdb->vnn;
+ return ctdb->pnn;
}
return NULL;
}
- /* get our vnn */
- ctdb->vnn = ctdb_ctrl_getvnn(ctdb, timeval_current_ofs(3, 0), CTDB_CURRENT_NODE);
- if (ctdb->vnn == (uint32_t)-1) {
- DEBUG(0,(__location__ " Failed to get ctdb vnn\n"));
+ /* get our pnn */
+ ctdb->pnn = ctdb_ctrl_getvnn(ctdb, timeval_current_ofs(3, 0), CTDB_CURRENT_NODE);
+ if (ctdb->pnn == (uint32_t)-1) {
+ DEBUG(0,(__location__ " Failed to get ctdb pnn\n"));
talloc_free(ctdb);
return NULL;
}
char *node_list_file;
char *recovery_lock_file;
int recovery_lock_fd;
- uint32_t vnn; /* our own vnn */
+ uint32_t pnn; /* our own pnn */
uint32_t num_nodes;
uint32_t num_connected;
unsigned flags;
{
uint32_t lmaster = ctdb_lmaster(ctdb, &key);
- if (ctdb->vnn == lmaster) {
+ if (ctdb->pnn == lmaster) {
c->hdr.destnode = header->dmaster;
} else if ((c->hopcount % ctdb->tunable.max_redirect_count) == 0) {
c->hdr.destnode = lmaster;
int ret, len;
TALLOC_CTX *tmp_ctx;
- if (ctdb->vnn != ctdb_lmaster(ctdb, &key)) {
+ if (ctdb->pnn != ctdb_lmaster(ctdb, &key)) {
DEBUG(0,(__location__ " Caller is not lmaster!\n"));
return;
}
int len;
uint32_t lmaster = ctdb_lmaster(ctdb, key);
- if (lmaster == ctdb->vnn) {
+ if (lmaster == ctdb->pnn) {
ctdb_send_dmaster_reply(ctdb_db, header, *key, *data,
c->hdr.srcnode, c->hdr.reqid);
return;
struct ctdb_context *ctdb = ctdb_db->ctdb;
struct ctdb_ltdb_header header;
- DEBUG(2,("vnn %u dmaster response %08x\n", ctdb->vnn, ctdb_hash(&key)));
+ DEBUG(2,("vnn %u dmaster response %08x\n", ctdb->pnn, ctdb_hash(&key)));
ZERO_STRUCT(header);
header.rsn = rsn + 1;
- header.dmaster = ctdb->vnn;
+ header.dmaster = ctdb->pnn;
if (ctdb_ltdb_store(ctdb_db, key, &header, data) != 0) {
ctdb_fatal(ctdb, "ctdb_reply_dmaster store failed\n");
state = ctdb_reqid_find(ctdb, hdr->reqid, struct ctdb_call_state);
if (state == NULL) {
- DEBUG(0,("vnn %u Invalid reqid %u in ctdb_become_dmaster from node %u\n",
- ctdb->vnn, hdr->reqid, hdr->srcnode));
+ DEBUG(0,("pnn %u Invalid reqid %u in ctdb_become_dmaster from node %u\n",
+ ctdb->pnn, hdr->reqid, hdr->srcnode));
ctdb_ltdb_unlock(ctdb_db, key);
return;
}
return;
}
- ctdb_call_local(ctdb_db, &state->call, &header, state, &data, ctdb->vnn);
+ ctdb_call_local(ctdb_db, &state->call, &header, state, &data, ctdb->pnn);
ctdb_ltdb_unlock(ctdb_db, state->call.key);
return;
}
- if (ctdb_lmaster(ctdb, &key) != ctdb->vnn) {
- DEBUG(0,("vnn %u dmaster request to non-lmaster lmaster=%u gen=%u curgen=%u\n",
- ctdb->vnn, ctdb_lmaster(ctdb, &key),
+ if (ctdb_lmaster(ctdb, &key) != ctdb->pnn) {
+ DEBUG(0,("pnn %u dmaster request to non-lmaster lmaster=%u gen=%u curgen=%u\n",
+ ctdb->pnn, ctdb_lmaster(ctdb, &key),
hdr->generation, ctdb->vnn_map->generation));
ctdb_fatal(ctdb, "ctdb_req_dmaster to non-lmaster");
}
- DEBUG(2,("vnn %u dmaster request on %08x for %u from %u\n",
- ctdb->vnn, ctdb_hash(&key), c->dmaster, c->hdr.srcnode));
+ DEBUG(2,("pnn %u dmaster request on %08x for %u from %u\n",
+ ctdb->pnn, ctdb_hash(&key), c->dmaster, c->hdr.srcnode));
/* its a protocol error if the sending node is not the current dmaster */
if (header.dmaster != hdr->srcnode) {
- DEBUG(0,("vnn %u dmaster request non-master %u dmaster=%u key %08x dbid 0x%08x gen=%u curgen=%u\n",
- ctdb->vnn, hdr->srcnode, header.dmaster, ctdb_hash(&key),
+ DEBUG(0,("pnn %u dmaster request non-master %u dmaster=%u key %08x dbid 0x%08x gen=%u curgen=%u\n",
+ ctdb->pnn, hdr->srcnode, header.dmaster, ctdb_hash(&key),
ctdb_db->db_id, hdr->generation, ctdb->vnn_map->generation));
ctdb_fatal(ctdb, "ctdb_req_dmaster from non-master");
return;
/* check if the new dmaster is the lmaster, in which case we
skip the dmaster reply */
- if (c->dmaster == ctdb->vnn) {
+ if (c->dmaster == ctdb->pnn) {
ctdb_become_dmaster(ctdb_db, hdr, key, data, c->rsn);
} else {
ctdb_send_dmaster_reply(ctdb_db, &header, key, data, c->dmaster, hdr->reqid);
/* if we are not the dmaster, then send a redirect to the
requesting node */
- if (header.dmaster != ctdb->vnn) {
+ if (header.dmaster != ctdb->pnn) {
talloc_free(data.dptr);
ctdb_call_send_redirect(ctdb, call.key, c, &header);
ctdb_ltdb_unlock(ctdb_db, call.key);
then give them the record
or if the node requested an immediate migration
*/
- if ( c->hdr.srcnode != ctdb->vnn &&
+ if ( c->hdr.srcnode != ctdb->pnn &&
((header.laccessor == c->hdr.srcnode
&& header.lacount >= ctdb->tunable.max_lacount)
|| (c->flags & CTDB_IMMEDIATE_MIGRATION)) ) {
- DEBUG(2,("vnn %u starting migration of %08x to %u\n",
- ctdb->vnn, ctdb_hash(&call.key), c->hdr.srcnode));
+ DEBUG(2,("pnn %u starting migration of %08x to %u\n",
+ ctdb->pnn, ctdb_hash(&call.key), c->hdr.srcnode));
ctdb_call_send_dmaster(ctdb_db, c, &header, &call.key, &data);
talloc_free(data.dptr);
ctdb_ltdb_unlock(ctdb_db, call.key);
state = ctdb_reqid_find(ctdb, hdr->reqid, struct ctdb_call_state);
if (state == NULL) {
- DEBUG(0,("vnn %u Invalid reqid %u in ctdb_reply_error\n",
- ctdb->vnn, hdr->reqid));
+ DEBUG(0,("pnn %u Invalid reqid %u in ctdb_reply_error\n",
+ ctdb->pnn, hdr->reqid));
return;
}
state->c->hdr.generation = state->generation;
/* send the packet to ourselves, it will be redirected appropriately */
- state->c->hdr.destnode = ctdb->vnn;
+ state->c->hdr.destnode = ctdb->pnn;
ctdb_queue_packet(ctdb, &state->c->hdr);
DEBUG(0,("resent ctdb_call\n"));
state->call = *call;
state->ctdb_db = ctdb_db;
- ret = ctdb_call_local(ctdb_db, &state->call, header, state, data, ctdb->vnn);
+ ret = ctdb_call_local(ctdb_db, &state->call, header, state, data, ctdb->pnn);
event_add_timed(ctdb->ev, state, timeval_zero(), call_local_trigger, state);
return getpid();
case CTDB_CONTROL_GET_VNN:
- return ctdb->vnn;
+ return ctdb->pnn;
case CTDB_CONTROL_PING:
CHECK_CONTROL_DATA_SIZE(0);
state = ctdb_reqid_find(ctdb, hdr->reqid, struct ctdb_control_state);
if (state == NULL) {
DEBUG(0,("vnn %u Invalid reqid %u in ctdb_reply_control\n",
- ctdb->vnn, hdr->reqid));
+ ctdb->pnn, hdr->reqid));
return;
}
DEBUG(2,("Node flags for node %u are now 0x%x\n", c->vnn, ctdb->nodes[c->vnn]->flags));
/* make sure we don't hold any IPs when we shouldn't */
- if (c->vnn == ctdb->vnn &&
+ if (c->vnn == ctdb->pnn &&
(ctdb->nodes[c->vnn]->flags & (NODE_FLAGS_INACTIVE|NODE_FLAGS_BANNED))) {
ctdb_release_all_ips(ctdb);
}
call->call_data.dsize = c->calldatalen;
call->flags = c->flags;
- if (header.dmaster == ctdb->vnn) {
+ if (header.dmaster == ctdb->pnn) {
state = ctdb_call_local_send(ctdb_db, call, &header, &data);
} else {
state = ctdb_daemon_call_send_remote(ctdb_db, call, &header);
hdr->ctdb_magic = CTDB_MAGIC;
hdr->ctdb_version = CTDB_VERSION;
hdr->generation = ctdb->vnn_map->generation;
- hdr->srcnode = ctdb->vnn;
+ hdr->srcnode = ctdb->pnn;
return hdr;
}
TALLOC_CTX *tmp_ctx = talloc_new(client);
if (c->hdr.destnode == CTDB_CURRENT_NODE) {
- c->hdr.destnode = client->ctdb->vnn;
+ c->hdr.destnode = client->ctdb->pnn;
}
state = talloc(client, struct daemon_control_state);
int len;
/* see if this is a message to ourselves */
- if (vnn == ctdb->vnn) {
+ if (vnn == ctdb->pnn) {
return ctdb_local_message(ctdb, srvid, data);
}
{
const char *db_name = (const char *)indata.dptr;
struct ctdb_db_context *ctdb_db, *tmp_db;
- struct ctdb_node *node = ctdb->nodes[ctdb->vnn];
+ struct ctdb_node *node = ctdb->nodes[ctdb->pnn];
int ret;
/* If the node is inactive it is not part of the cluster
/* open the database */
ctdb_db->db_path = talloc_asprintf(ctdb_db, "%s/%s.%u",
ctdb->db_directory,
- db_name, ctdb->vnn);
+ db_name, ctdb->pnn);
ctdb_db->ltdb = tdb_wrap_open(ctdb, ctdb_db->db_path,
ctdb->tunable.database_hash_size,
int32_t ctdb_ltdb_update_seqnum(struct ctdb_context *ctdb, uint32_t db_id, uint32_t srcnode)
{
struct ctdb_db_context *ctdb_db;
- if (srcnode == ctdb->vnn) {
+ if (srcnode == ctdb->pnn) {
/* don't update ourselves! */
return 0;
}
/* send a keepalive to all other nodes, unless */
for (i=0;i<ctdb->num_nodes;i++) {
struct ctdb_node *node = ctdb->nodes[i];
- if (node->pnn == ctdb->vnn) {
+ if (node->pnn == ctdb->pnn) {
continue;
}
*/
static void ctdb_health_callback(struct ctdb_context *ctdb, int status, void *p)
{
- struct ctdb_node *node = ctdb->nodes[ctdb->vnn];
+ struct ctdb_node *node = ctdb->nodes[ctdb->pnn];
TDB_DATA data;
struct ctdb_node_flag_change c;
timeval_current_ofs(ctdb->tunable.monitor_interval, 0),
ctdb_check_health, ctdb);
- c.vnn = ctdb->vnn;
+ c.vnn = ctdb->pnn;
c.old_flags = node->flags;
if (status != 0 && !(node->flags & NODE_FLAGS_UNHEALTHY)) {
node->flags |= NODE_FLAGS_UNHEALTHY;
} else if (status == 0 && (node->flags & NODE_FLAGS_UNHEALTHY)) {
DEBUG(0,("monitor event OK - node re-enabled\n"));
- ctdb->nodes[ctdb->vnn]->flags &= ~NODE_FLAGS_UNHEALTHY;
+ ctdb->nodes[ctdb->pnn]->flags &= ~NODE_FLAGS_UNHEALTHY;
} else {
/* no change */
return;
struct ctdb_node_modflags *m = (struct ctdb_node_modflags *)indata.dptr;
TDB_DATA data;
struct ctdb_node_flag_change c;
- struct ctdb_node *node = ctdb->nodes[ctdb->vnn];
+ struct ctdb_node *node = ctdb->nodes[ctdb->pnn];
uint32_t old_flags = node->flags;
node->flags |= m->set;
return 0;
}
- DEBUG(0, ("Control modflags on node %u - flags now 0x%x\n", ctdb->vnn, node->flags));
+ DEBUG(0, ("Control modflags on node %u - flags now 0x%x\n", ctdb->pnn, node->flags));
/* if we have been banned, go into recovery mode */
- c.vnn = ctdb->vnn;
+ c.vnn = ctdb->pnn;
c.old_flags = old_flags;
c.new_flags = node->flags;
/* The check for dmaster gives priority to the dmaster
if the rsn values are equal */
if (header.rsn < hdr->rsn ||
- (header.dmaster != ctdb->vnn && header.rsn == hdr->rsn)) {
+ (header.dmaster != ctdb->pnn && header.rsn == hdr->rsn)) {
ret = ctdb_ltdb_store(ctdb_db, key, hdr, data);
if (ret != 0) {
DEBUG(0, (__location__ " Unable to store record\n"));
return;
}
- if (vnn == ctdb->vnn) {
+ if (vnn == ctdb->pnn) {
DEBUG(0,("self ban - lowering our election priority\n"));
/* banning ourselves - lower our election priority */
rec->priority_time = timeval_current();
return;
}
- if (recmaster != ctdb->vnn) {
+ if (recmaster != ctdb->pnn) {
DEBUG(0,("We are not the recmaster - ignoring ban request\n"));
talloc_free(mem_ctx);
return;
return;
}
- if (recmaster != ctdb->vnn) {
+ if (recmaster != ctdb->pnn) {
DEBUG(0,("We are not the recmaster - ignoring unban request\n"));
talloc_free(mem_ctx);
return;
ZERO_STRUCTP(em);
- em->vnn = rec->ctdb->vnn;
+ em->vnn = rec->ctdb->pnn;
em->priority_time = rec->priority_time;
ret = ctdb_ctrl_getnodemap(ctdb, CONTROL_TIMEOUT(), CTDB_CURRENT_NODE, rec, &nodemap);
}
/* release the recmaster lock */
- if (em->vnn != ctdb->vnn &&
+ if (em->vnn != ctdb->pnn &&
ctdb->recovery_lock_fd != -1) {
close(ctdb->recovery_lock_fd);
ctdb->recovery_lock_fd = -1;
}
if (ret == 0 &&
- ctdb->recovery_master == ctdb->vnn &&
+ ctdb->recovery_master == ctdb->pnn &&
ctdb->recovery_mode == CTDB_RECOVERY_NORMAL &&
ctdb->vnn_list) {
/* Only do the takeover run if the perm disabled or unhealthy
if (vnnmap->size != num_active) {
DEBUG(0, (__location__ " The vnnmap count is different from the number of active nodes. %u vs %u\n",
vnnmap->size, num_active));
- do_recovery(rec, mem_ctx, vnn, num_active, nodemap, vnnmap, ctdb->vnn);
+ do_recovery(rec, mem_ctx, vnn, num_active, nodemap, vnnmap, ctdb->pnn);
goto again;
}
if (ctdb->address.address &&
ctdb_same_address(&ctdb->address, &node->address)) {
- ctdb->vnn = node->pnn;
+ ctdb->pnn = node->pnn;
node->flags &= ~NODE_FLAGS_DISCONNECTED;
}
case CTDB_REQ_DMASTER:
case CTDB_REPLY_DMASTER:
/* we dont allow these calls when banned */
- if (ctdb->nodes[ctdb->vnn]->flags & NODE_FLAGS_BANNED) {
+ if (ctdb->nodes[ctdb->pnn]->flags & NODE_FLAGS_BANNED) {
DEBUG(0,(__location__ " ctdb operation %u"
" request %u"
" length %u from node %u to %u while node"
node = ctdb->nodes[hdr->destnode];
- if (hdr->destnode == ctdb->vnn) {
+ if (hdr->destnode == ctdb->pnn) {
ctdb_defer_packet(ctdb, hdr);
} else {
node->tx_cnt++;
data.dptr = (uint8_t *)ip;
data.dsize = strlen(ip)+1;
- ctdb_daemon_send_message(ctdb, ctdb->vnn, CTDB_SRVID_RELEASE_IP, data);
+ ctdb_daemon_send_message(ctdb, ctdb->pnn, CTDB_SRVID_RELEASE_IP, data);
/* kill clients that have registered with this IP */
release_kill_clients(ctdb, state->sin->sin_addr);
/* we only send out updates for public addresses that
we have taken over
*/
- if (ctdb->vnn != vnn->pnn) {
+ if (ctdb->pnn != vnn->pnn) {
continue;
}
/* We only send out the updates if we need to */
/* filter out non-authoritative and zero-length records */
hdr = (struct ctdb_ltdb_header *)data.dptr;
if (data.dsize <= sizeof(struct ctdb_ltdb_header) ||
- hdr->dmaster != h->ctdb_db->ctdb->vnn) {
+ hdr->dmaster != h->ctdb_db->ctdb->pnn) {
return 0;
}
r.db_id = ctdb_db->db_id;
r.reqid = state->reqid;
- r.vnn = ctdb->vnn;
+ r.vnn = ctdb->pnn;
data.dptr = (uint8_t *)&r;
data.dsize = sizeof(r);
/* useful default logfile */
if (ctdb->logfile == NULL) {
- char *name = talloc_asprintf(ctdb, "%s/log.ctdb.vnn%u",
- VARDIR, ctdb->vnn);
+ char *name = talloc_asprintf(ctdb, "%s/log.ctdb.pnn%u",
+ VARDIR, ctdb->pnn);
ctdb_set_logfile(ctdb, name);
talloc_free(name);
}
ctdb->name = talloc_asprintf(ctdb, "%s:%u",
ctdb->address.address,
ctdb->address.port);
- ctdb->vnn = ctdb->nodes[i]->pnn;
+ ctdb->pnn = ctdb->nodes[i]->pnn;
ctdb->nodes[i]->flags &= ~NODE_FLAGS_DISCONNECTED;
- DEBUG(1,("ctdb chose network address %s:%u vnn %u\n",
+ DEBUG(1,("ctdb chose network address %s:%u pnn %u\n",
ctdb->address.address,
ctdb->address.port,
- ctdb->vnn));
+ ctdb->pnn));
if (listen(ctcp->listen_fd, 10) == -1) {
goto failed;