get a list of databases off a remote node
*/
int ctdb_ctrl_getdbmap(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode,
- TALLOC_CTX *mem_ctx, struct ctdb_dbid_map **dbmap)
+ TALLOC_CTX *mem_ctx, struct ctdb_dbid_map_old **dbmap)
{
int ret;
TDB_DATA outdata;
return -1;
}
- *dbmap = (struct ctdb_dbid_map *)talloc_memdup(mem_ctx, outdata.dptr, outdata.dsize);
+ *dbmap = (struct ctdb_dbid_map_old *)talloc_memdup(mem_ctx, outdata.dptr, outdata.dsize);
talloc_free(outdata.dptr);
return 0;
int ctdb_ctrl_getdbmap(struct ctdb_context *ctdb, struct timeval timeout,
uint32_t destnode, TALLOC_CTX *mem_ctx,
- struct ctdb_dbid_map **dbmap);
+ struct ctdb_dbid_map_old **dbmap);
int ctdb_ctrl_getnodemap(struct ctdb_context *ctdb, struct timeval timeout,
uint32_t destnode, TALLOC_CTX *mem_ctx,
/* table that contains a list of all dbids on a node
*/
-struct ctdb_dbid_map {
- uint32_t num;
- struct ctdb_dbid {
- uint32_t dbid;
+
+struct ctdb_dbid {
+ uint32_t db_id;
#define CTDB_DB_FLAGS_PERSISTENT 0x01
#define CTDB_DB_FLAGS_READONLY 0x02
#define CTDB_DB_FLAGS_STICKY 0x04
- uint8_t flags;
- } dbs[1];
+ uint8_t flags;
+};
+
+struct ctdb_dbid_map_old {
+ uint32_t num;
+ struct ctdb_dbid dbs[1];
};
#define CTDB_RECOVERY_NORMAL 0
{
uint32_t i, len;
struct ctdb_db_context *ctdb_db;
- struct ctdb_dbid_map *dbid_map;
+ struct ctdb_dbid_map_old *dbid_map;
CHECK_CONTROL_DATA_SIZE(0);
}
- outdata->dsize = offsetof(struct ctdb_dbid_map, dbs) + sizeof(dbid_map->dbs[0])*len;
+ outdata->dsize = offsetof(struct ctdb_dbid_map_old, dbs) + sizeof(dbid_map->dbs[0])*len;
outdata->dptr = (unsigned char *)talloc_zero_size(outdata, outdata->dsize);
if (!outdata->dptr) {
DEBUG(DEBUG_ALERT, (__location__ " Failed to allocate dbmap array\n"));
exit(1);
}
- dbid_map = (struct ctdb_dbid_map *)outdata->dptr;
+ dbid_map = (struct ctdb_dbid_map_old *)outdata->dptr;
dbid_map->num = len;
for (i=0,ctdb_db=ctdb->db_list;ctdb_db;i++,ctdb_db=ctdb_db->next){
- dbid_map->dbs[i].dbid = ctdb_db->db_id;
+ dbid_map->dbs[i].db_id = ctdb_db->db_id;
if (ctdb_db->persistent != 0) {
dbid_map->dbs[i].flags |= CTDB_DB_FLAGS_PERSISTENT;
}
*/
static int update_db_priority_on_remote_nodes(struct ctdb_context *ctdb,
struct ctdb_node_map_old *nodemap,
- uint32_t pnn, struct ctdb_dbid_map *dbmap, TALLOC_CTX *mem_ctx)
+ uint32_t pnn, struct ctdb_dbid_map_old *dbmap, TALLOC_CTX *mem_ctx)
{
int db;
struct ctdb_db_priority db_prio;
int ret;
- db_prio.db_id = dbmap->dbs[db].dbid;
- ret = ctdb_ctrl_get_db_priority(ctdb, CONTROL_TIMEOUT(), CTDB_CURRENT_NODE, dbmap->dbs[db].dbid, &db_prio.priority);
+ db_prio.db_id = dbmap->dbs[db].db_id;
+ ret = ctdb_ctrl_get_db_priority(ctdb, CONTROL_TIMEOUT(), CTDB_CURRENT_NODE, dbmap->dbs[db].db_id, &db_prio.priority);
if (ret != 0) {
- DEBUG(DEBUG_ERR,(__location__ " Failed to read database priority from local node for db 0x%08x\n", dbmap->dbs[db].dbid));
+ DEBUG(DEBUG_ERR,(__location__ " Failed to read database priority from local node for db 0x%08x\n", dbmap->dbs[db].db_id));
continue;
}
- DEBUG(DEBUG_INFO,("Update DB priority for db 0x%08x to %u\n", dbmap->dbs[db].dbid, db_prio.priority));
+ DEBUG(DEBUG_INFO,("Update DB priority for db 0x%08x to %u\n", dbmap->dbs[db].db_id, db_prio.priority));
ret = ctdb_ctrl_set_db_priority(ctdb, CONTROL_TIMEOUT(),
CTDB_CURRENT_NODE, &db_prio);
ensure all other nodes have attached to any databases that we have
*/
static int create_missing_remote_databases(struct ctdb_context *ctdb, struct ctdb_node_map_old *nodemap,
- uint32_t pnn, struct ctdb_dbid_map *dbmap, TALLOC_CTX *mem_ctx)
+ uint32_t pnn, struct ctdb_dbid_map_old *dbmap, TALLOC_CTX *mem_ctx)
{
int i, j, db, ret;
- struct ctdb_dbid_map *remote_dbmap;
+ struct ctdb_dbid_map_old *remote_dbmap;
/* verify that all other nodes have all our databases */
for (j=0; j<nodemap->num; j++) {
for (i=0;i<remote_dbmap->num;i++) {
- if (dbmap->dbs[db].dbid == remote_dbmap->dbs[i].dbid) {
+ if (dbmap->dbs[db].db_id == remote_dbmap->dbs[i].db_id) {
break;
}
}
}
/* ok so we need to create this database */
ret = ctdb_ctrl_getdbname(ctdb, CONTROL_TIMEOUT(), pnn,
- dbmap->dbs[db].dbid, mem_ctx,
+ dbmap->dbs[db].db_id, mem_ctx,
&name);
if (ret != 0) {
DEBUG(DEBUG_ERR, (__location__ " Unable to get dbname from node %u\n", pnn));
ensure we are attached to any databases that anyone else is attached to
*/
static int create_missing_local_databases(struct ctdb_context *ctdb, struct ctdb_node_map_old *nodemap,
- uint32_t pnn, struct ctdb_dbid_map **dbmap, TALLOC_CTX *mem_ctx)
+ uint32_t pnn, struct ctdb_dbid_map_old **dbmap, TALLOC_CTX *mem_ctx)
{
int i, j, db, ret;
- struct ctdb_dbid_map *remote_dbmap;
+ struct ctdb_dbid_map_old *remote_dbmap;
/* verify that we have all database any other node has */
for (j=0; j<nodemap->num; j++) {
const char *name;
for (i=0;i<(*dbmap)->num;i++) {
- if (remote_dbmap->dbs[db].dbid == (*dbmap)->dbs[i].dbid) {
+ if (remote_dbmap->dbs[db].db_id == (*dbmap)->dbs[i].db_id) {
break;
}
}
rebuild dbmap
*/
ctdb_ctrl_getdbname(ctdb, CONTROL_TIMEOUT(), nodemap->nodes[j].pnn,
- remote_dbmap->dbs[db].dbid, mem_ctx, &name);
+ remote_dbmap->dbs[db].db_id, mem_ctx, &name);
if (ret != 0) {
DEBUG(DEBUG_ERR, (__location__ " Unable to get dbname from node %u\n",
nodemap->nodes[j].pnn));
int ret, i;
TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
const char *name;
- struct ctdb_dbid_map *dbmap=NULL;
+ struct ctdb_dbid_map_old *dbmap=NULL;
bool persistent = false;
struct ctdb_db_context *ctdb_db;
struct ctdb_rec_data_old *r;
}
for (i=0;i<dbmap->num;i++) {
- if (dbmap->dbs[i].dbid == recs->db_id) {
+ if (dbmap->dbs[i].db_id == recs->db_id) {
persistent = dbmap->dbs[i].flags & CTDB_DB_FLAGS_PERSISTENT;
break;
}
static int db_recovery_serial(struct ctdb_recoverd *rec, TALLOC_CTX *mem_ctx,
uint32_t pnn, struct ctdb_node_map_old *nodemap,
struct ctdb_vnn_map *vnnmap,
- struct ctdb_dbid_map *dbmap)
+ struct ctdb_dbid_map_old *dbmap)
{
struct ctdb_context *ctdb = rec->ctdb;
uint32_t generation;
for (i=0;i<dbmap->num;i++) {
ret = recover_database(rec, mem_ctx,
- dbmap->dbs[i].dbid,
+ dbmap->dbs[i].db_id,
dbmap->dbs[i].flags & CTDB_DB_FLAGS_PERSISTENT,
pnn, nodemap, generation);
if (ret != 0) {
- DEBUG(DEBUG_ERR, (__location__ " Failed to recover database 0x%x\n", dbmap->dbs[i].dbid));
+ DEBUG(DEBUG_ERR, (__location__ " Failed to recover database 0x%x\n", dbmap->dbs[i].db_id));
return -1;
}
}
{
struct ctdb_context *ctdb = rec->ctdb;
int i, ret;
- struct ctdb_dbid_map *dbmap;
+ struct ctdb_dbid_map_old *dbmap;
struct timeval start_time;
uint32_t culprit = (uint32_t)-1;
bool self_ban;
uint32_t *dbid, const char **dbname, uint8_t *flags)
{
int i, ret;
- struct ctdb_dbid_map *dbmap=NULL;
+ struct ctdb_dbid_map_old *dbmap=NULL;
bool dbid_given = false, found = false;
uint32_t id;
TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
for(i=0; i<dbmap->num; i++) {
if (dbid_given) {
- if (id == dbmap->dbs[i].dbid) {
+ if (id == dbmap->dbs[i].db_id) {
found = true;
break;
}
} else {
- ret = ctdb_ctrl_getdbname(ctdb, TIMELIMIT(), options.pnn, dbmap->dbs[i].dbid, tmp_ctx, &name);
+ ret = ctdb_ctrl_getdbname(ctdb, TIMELIMIT(), options.pnn, dbmap->dbs[i].db_id, tmp_ctx, &name);
if (ret != 0) {
- DEBUG(DEBUG_ERR, ("Unable to get dbname from dbid %u\n", dbmap->dbs[i].dbid));
+ DEBUG(DEBUG_ERR, ("Unable to get dbname from dbid %u\n", dbmap->dbs[i].db_id));
goto fail;
}
if (strcmp(name, dbarg) == 0) {
- id = dbmap->dbs[i].dbid;
+ id = dbmap->dbs[i].db_id;
found = true;
break;
}
}
if (found && dbid_given && dbname != NULL) {
- ret = ctdb_ctrl_getdbname(ctdb, TIMELIMIT(), options.pnn, dbmap->dbs[i].dbid, tmp_ctx, &name);
+ ret = ctdb_ctrl_getdbname(ctdb, TIMELIMIT(), options.pnn, dbmap->dbs[i].db_id, tmp_ctx, &name);
if (ret != 0) {
- DEBUG(DEBUG_ERR, ("Unable to get dbname from dbid %u\n", dbmap->dbs[i].dbid));
+ DEBUG(DEBUG_ERR, ("Unable to get dbname from dbid %u\n", dbmap->dbs[i].db_id));
found = false;
goto fail;
}
static int control_getdbmap(struct ctdb_context *ctdb, int argc, const char **argv)
{
int i, ret;
- struct ctdb_dbid_map *dbmap=NULL;
+ struct ctdb_dbid_map_old *dbmap=NULL;
ret = ctdb_ctrl_getdbmap(ctdb, TIMELIMIT(), options.pnn, ctdb, &dbmap);
if (ret != 0) {
bool sticky;
ctdb_ctrl_getdbpath(ctdb, TIMELIMIT(), options.pnn,
- dbmap->dbs[i].dbid, ctdb, &path);
+ dbmap->dbs[i].db_id, ctdb, &path);
ctdb_ctrl_getdbname(ctdb, TIMELIMIT(), options.pnn,
- dbmap->dbs[i].dbid, ctdb, &name);
+ dbmap->dbs[i].db_id, ctdb, &name);
ctdb_ctrl_getdbhealth(ctdb, TIMELIMIT(), options.pnn,
- dbmap->dbs[i].dbid, ctdb, &health);
+ dbmap->dbs[i].db_id, ctdb, &health);
persistent = dbmap->dbs[i].flags & CTDB_DB_FLAGS_PERSISTENT;
readonly = dbmap->dbs[i].flags & CTDB_DB_FLAGS_READONLY;
sticky = dbmap->dbs[i].flags & CTDB_DB_FLAGS_STICKY;
printm(":0x%08X:%s:%s:%d:%d:%d:%d:\n",
- dbmap->dbs[i].dbid, name, path,
+ dbmap->dbs[i].db_id, name, path,
!!(persistent), !!(sticky),
!!(health), !!(readonly));
}
bool readonly;
bool sticky;
- ctdb_ctrl_getdbpath(ctdb, TIMELIMIT(), options.pnn, dbmap->dbs[i].dbid, ctdb, &path);
- ctdb_ctrl_getdbname(ctdb, TIMELIMIT(), options.pnn, dbmap->dbs[i].dbid, ctdb, &name);
- ctdb_ctrl_getdbhealth(ctdb, TIMELIMIT(), options.pnn, dbmap->dbs[i].dbid, ctdb, &health);
+ ctdb_ctrl_getdbpath(ctdb, TIMELIMIT(), options.pnn, dbmap->dbs[i].db_id, ctdb, &path);
+ ctdb_ctrl_getdbname(ctdb, TIMELIMIT(), options.pnn, dbmap->dbs[i].db_id, ctdb, &name);
+ ctdb_ctrl_getdbhealth(ctdb, TIMELIMIT(), options.pnn, dbmap->dbs[i].db_id, ctdb, &health);
persistent = dbmap->dbs[i].flags & CTDB_DB_FLAGS_PERSISTENT;
readonly = dbmap->dbs[i].flags & CTDB_DB_FLAGS_READONLY;
sticky = dbmap->dbs[i].flags & CTDB_DB_FLAGS_STICKY;
printf("dbid:0x%08x name:%s path:%s%s%s%s%s\n",
- dbmap->dbs[i].dbid, name, path,
+ dbmap->dbs[i].db_id, name, path,
persistent?" PERSISTENT":"",
sticky?" STICKY":"",
readonly?" READONLY":"",