1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-28 01:58:17 +03:00

add a new control : SETVNNMAP to set the generation id and also the vnn

map on a ctdbd daemon

(This used to be ctdb commit f55707885f7b233ad6ddfc952d08851577063200)
This commit is contained in:
Ronnie Sahlberg 2007-04-27 22:08:12 +10:00
parent d9edf88ae5
commit d4c54a93a0
5 changed files with 86 additions and 1 deletions

View File

@ -813,6 +813,38 @@ int ctdb_getvnnmap(struct ctdb_context *ctdb, uint32_t destnode, struct ctdb_vnn
return 0;
}
/*
set vnn map on a node
*/
int ctdb_setvnnmap(struct ctdb_context *ctdb, uint32_t destnode, struct ctdb_vnn_map *vnnmap)
{
int ret;
TDB_DATA *data, outdata;
int32_t i, res;
data = talloc_zero(ctdb, TDB_DATA);
data->dsize = (vnnmap->size+2)*sizeof(uint32_t);
data->dptr = (unsigned char *)talloc_array(data, uint32_t, vnnmap->size+2);
((uint32_t *)&data->dptr[0])[0] = vnnmap->generation;
((uint32_t *)&data->dptr[0])[1] = vnnmap->size;
for (i=0;i<vnnmap->size;i++) {
((uint32_t *)&data->dptr[0])[i+2] = vnnmap->map[i];
}
ret = ctdb_control(ctdb, destnode, 0,
CTDB_CONTROL_SETVNNMAP, *data,
ctdb, &outdata, &res);
if (ret != 0 || res != 0) {
DEBUG(0,(__location__ " ctdb_control for setvnnmap failed\n"));
return -1;
}
talloc_free(data);
return 0;
}
/*
ping a node
*/

View File

@ -73,6 +73,27 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
return 0;
}
case CTDB_CONTROL_SETVNNMAP: {
uint32_t *ptr, i;
ptr = (uint32_t *)(&indata.dptr[0]);
ctdb->vnn_map->generation = ptr[0];
ctdb->vnn_map->size = ptr[1];
if (ctdb->vnn_map->map) {
talloc_free(ctdb->vnn_map->map);
ctdb->vnn_map->map = NULL;
}
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] = ptr[i+2];
}
return 0;
}
case CTDB_CONTROL_CONFIG: {
outdata->dptr = (uint8_t *)ctdb;
outdata->dsize = sizeof(*ctdb);

View File

@ -217,6 +217,7 @@ int ctdb_status(struct ctdb_context *ctdb, uint32_t destnode, struct ctdb_status
struct ctdb_vnn_map;
int ctdb_getvnnmap(struct ctdb_context *ctdb, uint32_t destnode, struct ctdb_vnn_map *vnnmap);
int ctdb_setvnnmap(struct ctdb_context *ctdb, uint32_t destnode, struct ctdb_vnn_map *vnnmap);
int ctdb_getdbpath(struct ctdb_db_context *ctdb_db, TALLOC_CTX *mem_ctx, const char **path);

View File

@ -244,7 +244,8 @@ enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS,
CTDB_CONTROL_CONFIG,
CTDB_CONTROL_PING,
CTDB_CONTROL_GETDBPATH,
CTDB_CONTROL_GETVNNMAP};
CTDB_CONTROL_GETVNNMAP,
CTDB_CONTROL_SETVNNMAP};
enum call_state {CTDB_CALL_WAIT, CTDB_CALL_DONE, CTDB_CALL_ERROR};

View File

@ -37,6 +37,7 @@ static void usage(void)
printf(" process-exists <vnn:pid>\n");
printf(" status <vnn>\n");
printf(" getvnnmap <vnn>\n");
printf(" setvnnmap <vnn> <generation> <numslots> <lmaster>*\n");
exit(1);
}
@ -142,6 +143,33 @@ static int control_getvnnmap(struct ctdb_context *ctdb, int argc, const char **a
return 0;
}
static int control_setvnnmap(struct ctdb_context *ctdb, int argc, const char **argv)
{
uint32_t vnn;
struct ctdb_vnn_map *vnnmap;
int i, ret;
if (argc < 3) {
usage();
}
vnn = strtoul(argv[0], NULL, 0);
vnnmap = talloc_zero(ctdb, struct ctdb_vnn_map);
vnnmap->generation = strtoul(argv[1], NULL, 0);
vnnmap->size = strtoul(argv[2], NULL, 0);
vnnmap->map = talloc_array(vnnmap, uint32_t, vnnmap->size);
for (i=0;i<vnnmap->size;i++) {
vnnmap->map[i] = strtoul(argv[3+i], NULL, 0);
}
ret = ctdb_setvnnmap(ctdb, vnn, vnnmap);
if (ret != 0) {
printf("Unable to set vnnmap for node %u\n", vnn);
return ret;
}
return 0;
}
static int control_ping(struct ctdb_context *ctdb, int argc, const char **argv)
{
int ret, i;
@ -217,6 +245,8 @@ int main(int argc, const char *argv[])
ret = control_status(ctdb, extra_argc-1, extra_argv+1);
} else if (strcmp(control, "getvnnmap") == 0) {
ret = control_getvnnmap(ctdb, extra_argc-1, extra_argv+1);
} else if (strcmp(control, "setvnnmap") == 0) {
ret = control_setvnnmap(ctdb, extra_argc-1, extra_argv+1);
} else if (strcmp(control, "ping") == 0) {
ret = control_ping(ctdb, extra_argc-1, extra_argv+1);
} else {