From 4d205476d286570a6e1f52b59af42858ce051106 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 30 Jul 2008 14:24:56 +1000 Subject: [PATCH] rename the structure we use for marshalling multiple records --- include/ctdb_private.h | 4 ++-- server/ctdb_recover.c | 20 ++++++++++---------- server/ctdb_recoverd.c | 18 +++++++++--------- tools/ctdb_vacuum.c | 18 +++++++++--------- 4 files changed, 30 insertions(+), 30 deletions(-) diff --git a/include/ctdb_private.h b/include/ctdb_private.h index 77d10926..4d547782 100644 --- a/include/ctdb_private.h +++ b/include/ctdb_private.h @@ -1028,8 +1028,8 @@ struct ctdb_control_pulldb { uint32_t lmaster; }; -/* structure used for pulldb control */ -struct ctdb_control_pulldb_reply { +/* structure used for sending lists of records */ +struct ctdb_marshall_buffer { uint32_t db_id; uint32_t count; uint8_t data[1]; diff --git a/server/ctdb_recover.c b/server/ctdb_recover.c index 7b8d28c5..2b748984 100644 --- a/server/ctdb_recover.c +++ b/server/ctdb_recover.c @@ -258,7 +258,7 @@ int32_t ctdb_control_pull_db(struct ctdb_context *ctdb, TDB_DATA indata, TDB_DAT struct ctdb_control_pulldb *pull; struct ctdb_db_context *ctdb_db; struct pulldb_data params; - struct ctdb_control_pulldb_reply *reply; + struct ctdb_marshall_buffer *reply; if (ctdb->freeze_mode != CTDB_FREEZE_FROZEN) { DEBUG(DEBUG_DEBUG,("rejecting ctdb_control_pull_db when not frozen\n")); @@ -273,14 +273,14 @@ int32_t ctdb_control_pull_db(struct ctdb_context *ctdb, TDB_DATA indata, TDB_DAT return -1; } - reply = talloc_zero(outdata, struct ctdb_control_pulldb_reply); + reply = talloc_zero(outdata, struct ctdb_marshall_buffer); CTDB_NO_MEMORY(ctdb, reply); reply->db_id = pull->db_id; params.ctdb = ctdb; params.pulldata = reply; - params.len = offsetof(struct ctdb_control_pulldb_reply, data); + params.len = offsetof(struct ctdb_marshall_buffer, data); params.failed = false; if (ctdb_lock_all_databases_mark(ctdb) != 0) { @@ -308,7 +308,7 @@ int32_t ctdb_control_pull_db(struct ctdb_context *ctdb, TDB_DATA indata, TDB_DAT */ int32_t ctdb_control_push_db(struct ctdb_context *ctdb, TDB_DATA indata) { - struct ctdb_control_pulldb_reply *reply = (struct ctdb_control_pulldb_reply *)indata.dptr; + struct ctdb_marshall_buffer *reply = (struct ctdb_marshall_buffer *)indata.dptr; struct ctdb_db_context *ctdb_db; int i, ret; struct ctdb_rec_data *rec; @@ -318,7 +318,7 @@ int32_t ctdb_control_push_db(struct ctdb_context *ctdb, TDB_DATA indata) return -1; } - if (indata.dsize < offsetof(struct ctdb_control_pulldb_reply, data)) { + if (indata.dsize < offsetof(struct ctdb_marshall_buffer, data)) { DEBUG(DEBUG_ERR,(__location__ " invalid data in pulldb reply\n")); return -1; } @@ -887,13 +887,13 @@ int32_t ctdb_control_get_reclock_file(struct ctdb_context *ctdb, TDB_DATA *outda */ int32_t ctdb_control_try_delete_records(struct ctdb_context *ctdb, TDB_DATA indata, TDB_DATA *outdata) { - struct ctdb_control_pulldb_reply *reply = (struct ctdb_control_pulldb_reply *)indata.dptr; + struct ctdb_marshall_buffer *reply = (struct ctdb_marshall_buffer *)indata.dptr; struct ctdb_db_context *ctdb_db; int i; struct ctdb_rec_data *rec; - struct ctdb_control_pulldb_reply *records; + struct ctdb_marshall_buffer *records; - if (indata.dsize < offsetof(struct ctdb_control_pulldb_reply, data)) { + if (indata.dsize < offsetof(struct ctdb_marshall_buffer, data)) { DEBUG(DEBUG_ERR,(__location__ " invalid data in try_delete_records\n")); return -1; } @@ -910,9 +910,9 @@ int32_t ctdb_control_try_delete_records(struct ctdb_context *ctdb, TDB_DATA inda /* create a blob to send back the records we couldnt delete */ - records = (struct ctdb_control_pulldb_reply *) + records = (struct ctdb_marshall_buffer *) talloc_zero_size(outdata, - offsetof(struct ctdb_control_pulldb_reply, data)); + offsetof(struct ctdb_marshall_buffer, data)); if (records == NULL) { DEBUG(DEBUG_ERR,(__location__ " Out of memory\n")); return -1; diff --git a/server/ctdb_recoverd.c b/server/ctdb_recoverd.c index 64a05a77..2bc24dd7 100644 --- a/server/ctdb_recoverd.c +++ b/server/ctdb_recoverd.c @@ -546,9 +546,9 @@ static int pull_one_remote_database(struct ctdb_context *ctdb, uint32_t srcnode, return -1; } - reply = (struct ctdb_control_pulldb_reply *)outdata.dptr; + reply = (struct ctdb_marshall_buffer *)outdata.dptr; - if (outdata.dsize < offsetof(struct ctdb_control_pulldb_reply, data)) { + if (outdata.dsize < offsetof(struct ctdb_marshall_buffer, data)) { DEBUG(DEBUG_ERR,(__location__ " invalid data in pulldb reply\n")); talloc_free(tmp_ctx); return -1; @@ -764,7 +764,7 @@ struct vacuum_info { struct ctdb_recoverd *rec; uint32_t srcnode; struct ctdb_db_context *ctdb_db; - struct ctdb_control_pulldb_reply *recs; + struct ctdb_marshall_buffer *recs; struct ctdb_rec_data *r; }; @@ -866,7 +866,7 @@ static void vacuum_fetch_handler(struct ctdb_context *ctdb, uint64_t srvid, TDB_DATA data, void *private_data) { struct ctdb_recoverd *rec = talloc_get_type(private_data, struct ctdb_recoverd); - struct ctdb_control_pulldb_reply *recs; + struct ctdb_marshall_buffer *recs; int ret, i; TALLOC_CTX *tmp_ctx = talloc_new(ctdb); const char *name; @@ -877,7 +877,7 @@ static void vacuum_fetch_handler(struct ctdb_context *ctdb, uint64_t srvid, uint32_t srcnode; struct vacuum_info *v; - recs = (struct ctdb_control_pulldb_reply *)data.dptr; + recs = (struct ctdb_marshall_buffer *)data.dptr; r = (struct ctdb_rec_data *)&recs->data[0]; if (recs->count == 0) { @@ -1136,7 +1136,7 @@ static struct tdb_wrap *create_recdb(struct ctdb_context *ctdb, TALLOC_CTX *mem_ */ struct recdb_data { struct ctdb_context *ctdb; - struct ctdb_control_pulldb_reply *recdata; + struct ctdb_marshall_buffer *recdata; uint32_t len; bool failed; }; @@ -1184,7 +1184,7 @@ static int push_recdb_database(struct ctdb_context *ctdb, uint32_t dbid, struct tdb_wrap *recdb, struct ctdb_node_map *nodemap) { struct recdb_data params; - struct ctdb_control_pulldb_reply *recdata; + struct ctdb_marshall_buffer *recdata; TDB_DATA outdata; TALLOC_CTX *tmp_ctx; uint32_t *nodes; @@ -1192,14 +1192,14 @@ static int push_recdb_database(struct ctdb_context *ctdb, uint32_t dbid, tmp_ctx = talloc_new(ctdb); CTDB_NO_MEMORY(ctdb, tmp_ctx); - recdata = talloc_zero(recdb, struct ctdb_control_pulldb_reply); + recdata = talloc_zero(recdb, struct ctdb_marshall_buffer); CTDB_NO_MEMORY(ctdb, recdata); recdata->db_id = dbid; params.ctdb = ctdb; params.recdata = recdata; - params.len = offsetof(struct ctdb_control_pulldb_reply, data); + params.len = offsetof(struct ctdb_marshall_buffer, data); params.failed = false; if (tdb_traverse_read(recdb->tdb, traverse_recdb, ¶ms) == -1) { diff --git a/tools/ctdb_vacuum.c b/tools/ctdb_vacuum.c index 60a0b0a3..f517c6ea 100644 --- a/tools/ctdb_vacuum.c +++ b/tools/ctdb_vacuum.c @@ -39,7 +39,7 @@ struct vacuum_data { struct ctdb_db_context *ctdb_db; trbt_tree_t *delete_tree; uint32_t delete_count; - struct ctdb_control_pulldb_reply **list; + struct ctdb_marshall_buffer **list; bool traverse_error; uint32_t total; }; @@ -153,7 +153,7 @@ static int vacuum_traverse(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, } struct delete_records_list { - struct ctdb_control_pulldb_reply *records; + struct ctdb_marshall_buffer *records; }; /* @@ -269,16 +269,16 @@ static int ctdb_vacuum_db(struct ctdb_context *ctdb, uint32_t db_id, struct ctdb vdata->ctdb_db = ctdb_db; /* the list needs to be of length num_nodes */ - vdata->list = talloc_array(vdata, struct ctdb_control_pulldb_reply *, ctdb->vnn_map->size); + vdata->list = talloc_array(vdata, struct ctdb_marshall_buffer *, ctdb->vnn_map->size); if (vdata->list == NULL) { DEBUG(DEBUG_ERR,(__location__ " Out of memory\n")); talloc_free(vdata); return -1; } for (i=0;ivnn_map->size;i++) { - vdata->list[i] = (struct ctdb_control_pulldb_reply *) + vdata->list[i] = (struct ctdb_marshall_buffer *) talloc_zero_size(vdata->list, - offsetof(struct ctdb_control_pulldb_reply, data)); + offsetof(struct ctdb_marshall_buffer, data)); if (vdata->list[i] == NULL) { DEBUG(DEBUG_ERR,(__location__ " Out of memory\n")); talloc_free(vdata); @@ -332,9 +332,9 @@ static int ctdb_vacuum_db(struct ctdb_context *ctdb, uint32_t db_id, struct ctdb DEBUG(DEBUG_ERR,(__location__ " Out of memory\n")); return -1; } - recs->records = (struct ctdb_control_pulldb_reply *) + recs->records = (struct ctdb_marshall_buffer *) talloc_zero_size(vdata, - offsetof(struct ctdb_control_pulldb_reply, data)); + offsetof(struct ctdb_marshall_buffer, data)); if (recs->records == NULL) { DEBUG(DEBUG_ERR,(__location__ " Out of memory\n")); return -1; @@ -353,7 +353,7 @@ static int ctdb_vacuum_db(struct ctdb_context *ctdb, uint32_t db_id, struct ctdb (if possible) */ for (i=0;ivnn_map->size;i++) { - struct ctdb_control_pulldb_reply *records; + struct ctdb_marshall_buffer *records; struct ctdb_rec_data *rec; if (ctdb->vnn_map->map[i] == ctdb->pnn) { @@ -375,7 +375,7 @@ static int ctdb_vacuum_db(struct ctdb_context *ctdb, uint32_t db_id, struct ctdb /* outdata countains the list of records coming back from the node which the node could not delete */ - records = (struct ctdb_control_pulldb_reply *)outdata.dptr; + records = (struct ctdb_marshall_buffer *)outdata.dptr; rec = (struct ctdb_rec_data *)&records->data[0]; while (records->count-- > 1) { TDB_DATA reckey, recdata; -- 2.34.1