From: Martin Schwenke Date: Thu, 6 Aug 2020 11:35:14 +0000 (+1000) Subject: ctdb-daemon: Drop implementation of old-style database pull/push controls X-Git-Tag: talloc-2.3.2~547 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d98f68f9182632aa1a086084d90b745ddeaed3d7;p=thirdparty%2Fsamba.git ctdb-daemon: Drop implementation of old-style database pull/push controls Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs Autobuild-User(master): Amitay Isaacs Autobuild-Date(master): Fri Sep 11 06:29:32 UTC 2020 on sn-devel-184 --- diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h index 9ca87332d61..8eb6686f953 100644 --- a/ctdb/include/ctdb_private.h +++ b/ctdb/include/ctdb_private.h @@ -794,10 +794,6 @@ int ctdb_control_getnodemap(struct ctdb_context *ctdb, uint32_t opcode, int ctdb_control_reload_nodes_file(struct ctdb_context *ctdb, uint32_t opcode); -int32_t ctdb_control_pull_db(struct ctdb_context *ctdb, TDB_DATA indata, - TDB_DATA *outdata); -int32_t ctdb_control_push_db(struct ctdb_context *ctdb, TDB_DATA indata); - int32_t ctdb_control_db_pull(struct ctdb_context *ctdb, struct ctdb_req_control_old *c, TDB_DATA indata, TDB_DATA *outdata); diff --git a/ctdb/protocol/protocol.h b/ctdb/protocol/protocol.h index 35543a67cf9..e4b76c6b986 100644 --- a/ctdb/protocol/protocol.h +++ b/ctdb/protocol/protocol.h @@ -236,8 +236,8 @@ enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS = 0, CTDB_CONTROL_GET_NODEMAPv4 = 10, /* obsolete */ CTDB_CONTROL_SET_DMASTER = 11, /* obsolete */ /* #12 removed */ - CTDB_CONTROL_PULL_DB = 13, - CTDB_CONTROL_PUSH_DB = 14, + CTDB_CONTROL_PULL_DB = 13, /* obsolete */ + CTDB_CONTROL_PUSH_DB = 14, /* obsolete */ CTDB_CONTROL_GET_RECMODE = 15, CTDB_CONTROL_SET_RECMODE = 16, CTDB_CONTROL_STATISTICS_RESET = 17, diff --git a/ctdb/server/ctdb_control.c b/ctdb/server/ctdb_control.c index 95f3b175934..206ea149693 100644 --- a/ctdb/server/ctdb_control.c +++ b/ctdb/server/ctdb_control.c @@ -285,15 +285,14 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb, case CTDB_CONTROL_SETVNNMAP: return ctdb_control_setvnnmap(ctdb, opcode, indata, outdata); - case CTDB_CONTROL_PULL_DB: - CHECK_CONTROL_DATA_SIZE(sizeof(struct ctdb_pulldb)); - return ctdb_control_pull_db(ctdb, indata, outdata); + case CTDB_CONTROL_PULL_DB: + return control_not_implemented("PULL_DB", NULL); case CTDB_CONTROL_SET_DMASTER: return control_not_implemented("SET_DMASTER", NULL); case CTDB_CONTROL_PUSH_DB: - return ctdb_control_push_db(ctdb, indata); + return control_not_implemented("PUSH_DB", NULL); case CTDB_CONTROL_GET_RECMODE: { return ctdb->recovery_mode; diff --git a/ctdb/server/ctdb_recover.c b/ctdb/server/ctdb_recover.c index 1654c6d3978..108d8bb404b 100644 --- a/ctdb/server/ctdb_recover.c +++ b/ctdb/server/ctdb_recover.c @@ -191,128 +191,6 @@ ctdb_control_reload_nodes_file(struct ctdb_context *ctdb, uint32_t opcode) return 0; } -/* - a traverse function for pulling all relevent records from pulldb - */ -struct pulldb_data { - struct ctdb_context *ctdb; - struct ctdb_db_context *ctdb_db; - struct ctdb_marshall_buffer *pulldata; - uint32_t len; - uint32_t allocated_len; - bool failed; -}; - -static int traverse_pulldb(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void *p) -{ - struct pulldb_data *params = (struct pulldb_data *)p; - struct ctdb_rec_data_old *rec; - struct ctdb_context *ctdb = params->ctdb; - struct ctdb_db_context *ctdb_db = params->ctdb_db; - - /* add the record to the blob */ - rec = ctdb_marshall_record(params->pulldata, 0, key, NULL, data); - if (rec == NULL) { - params->failed = true; - return -1; - } - if (params->len + rec->length >= params->allocated_len) { - params->allocated_len = rec->length + params->len + ctdb->tunable.pulldb_preallocation_size; - params->pulldata = talloc_realloc_size(NULL, params->pulldata, params->allocated_len); - } - if (params->pulldata == NULL) { - DEBUG(DEBUG_CRIT,(__location__ " Failed to expand pulldb_data to %u\n", rec->length + params->len)); - ctdb_fatal(params->ctdb, "failed to allocate memory for recovery. shutting down\n"); - } - params->pulldata->count++; - memcpy(params->len+(uint8_t *)params->pulldata, rec, rec->length); - params->len += rec->length; - - if (ctdb->tunable.db_record_size_warn != 0 && rec->length > ctdb->tunable.db_record_size_warn) { - DEBUG(DEBUG_ERR,("Data record in %s is big. Record size is %d bytes\n", ctdb_db->db_name, (int)rec->length)); - } - - talloc_free(rec); - - return 0; -} - -/* - pull a bunch of records from a ltdb, filtering by lmaster - */ -int32_t ctdb_control_pull_db(struct ctdb_context *ctdb, TDB_DATA indata, TDB_DATA *outdata) -{ - struct ctdb_pulldb *pull; - struct ctdb_db_context *ctdb_db; - struct pulldb_data params; - struct ctdb_marshall_buffer *reply; - - pull = (struct ctdb_pulldb *)indata.dptr; - - ctdb_db = find_ctdb_db(ctdb, pull->db_id); - if (!ctdb_db) { - DEBUG(DEBUG_ERR,(__location__ " Unknown db 0x%08x\n", pull->db_id)); - return -1; - } - - if (!ctdb_db_frozen(ctdb_db)) { - DEBUG(DEBUG_ERR, - ("rejecting ctdb_control_pull_db when not frozen\n")); - return -1; - } - - reply = talloc_zero(outdata, struct ctdb_marshall_buffer); - CTDB_NO_MEMORY(ctdb, reply); - - reply->db_id = pull->db_id; - - params.ctdb = ctdb; - params.ctdb_db = ctdb_db; - params.pulldata = reply; - params.len = offsetof(struct ctdb_marshall_buffer, data); - params.allocated_len = params.len; - params.failed = false; - - if (ctdb_db->unhealthy_reason) { - /* this is just a warning, as the tdb should be empty anyway */ - DEBUG(DEBUG_WARNING,("db(%s) unhealty in ctdb_control_pull_db: %s\n", - ctdb_db->db_name, ctdb_db->unhealthy_reason)); - } - - /* If the records are invalid, we are done */ - if (ctdb_db->invalid_records) { - goto done; - } - - if (ctdb_lockdb_mark(ctdb_db) != 0) { - DEBUG(DEBUG_ERR,(__location__ " Failed to get lock on entire db - failing\n")); - return -1; - } - - if (tdb_traverse_read(ctdb_db->ltdb->tdb, traverse_pulldb, ¶ms) == -1) { - DEBUG(DEBUG_ERR,(__location__ " Failed to get traverse db '%s'\n", ctdb_db->db_name)); - ctdb_lockdb_unmark(ctdb_db); - talloc_free(params.pulldata); - return -1; - } - - ctdb_lockdb_unmark(ctdb_db); - -done: - outdata->dptr = (uint8_t *)params.pulldata; - outdata->dsize = params.len; - - if (ctdb->tunable.db_record_count_warn != 0 && params.pulldata->count > ctdb->tunable.db_record_count_warn) { - DEBUG(DEBUG_ERR,("Database %s is big. Contains %d records\n", ctdb_db->db_name, params.pulldata->count)); - } - if (ctdb->tunable.db_size_warn != 0 && outdata->dsize > ctdb->tunable.db_size_warn) { - DEBUG(DEBUG_ERR,("Database %s is big. Contains %d bytes\n", ctdb_db->db_name, (int)outdata->dsize)); - } - - - return 0; -} - struct db_pull_state { struct ctdb_context *ctdb; struct ctdb_db_context *ctdb_db; @@ -446,100 +324,6 @@ done: return 0; } -/* - push a bunch of records into a ltdb, filtering by rsn - */ -int32_t ctdb_control_push_db(struct ctdb_context *ctdb, TDB_DATA indata) -{ - struct ctdb_marshall_buffer *reply = (struct ctdb_marshall_buffer *)indata.dptr; - struct ctdb_db_context *ctdb_db; - unsigned int i; - int ret; - struct ctdb_rec_data_old *rec; - - if (indata.dsize < offsetof(struct ctdb_marshall_buffer, data)) { - DEBUG(DEBUG_ERR,(__location__ " invalid data in pulldb reply\n")); - return -1; - } - - ctdb_db = find_ctdb_db(ctdb, reply->db_id); - if (!ctdb_db) { - DEBUG(DEBUG_ERR,(__location__ " Unknown db 0x%08x\n", reply->db_id)); - return -1; - } - - if (!ctdb_db_frozen(ctdb_db)) { - DEBUG(DEBUG_ERR, - ("rejecting ctdb_control_push_db when not frozen\n")); - return -1; - } - - if (ctdb_lockdb_mark(ctdb_db) != 0) { - DEBUG(DEBUG_ERR,(__location__ " Failed to get lock on entire db - failing\n")); - return -1; - } - - rec = (struct ctdb_rec_data_old *)&reply->data[0]; - - DEBUG(DEBUG_INFO,("starting push of %u records for dbid 0x%x\n", - reply->count, reply->db_id)); - - for (i=0;icount;i++) { - TDB_DATA key, data; - struct ctdb_ltdb_header *hdr; - - key.dptr = &rec->data[0]; - key.dsize = rec->keylen; - data.dptr = &rec->data[key.dsize]; - data.dsize = rec->datalen; - - if (data.dsize < sizeof(struct ctdb_ltdb_header)) { - DEBUG(DEBUG_CRIT,(__location__ " bad ltdb record\n")); - goto failed; - } - hdr = (struct ctdb_ltdb_header *)data.dptr; - /* strip off any read only record flags. All readonly records - are revoked implicitely by a recovery - */ - hdr->flags &= ~CTDB_REC_RO_FLAGS; - - data.dptr += sizeof(*hdr); - data.dsize -= sizeof(*hdr); - - ret = ctdb_ltdb_store(ctdb_db, key, hdr, data); - if (ret != 0) { - DEBUG(DEBUG_CRIT, (__location__ " Unable to store record\n")); - goto failed; - } - - rec = (struct ctdb_rec_data_old *)(rec->length + (uint8_t *)rec); - } - - DEBUG(DEBUG_DEBUG,("finished push of %u records for dbid 0x%x\n", - reply->count, reply->db_id)); - - if (ctdb_db_readonly(ctdb_db)) { - DEBUG(DEBUG_CRIT,("Clearing the tracking database for dbid 0x%x\n", - ctdb_db->db_id)); - if (tdb_wipe_all(ctdb_db->rottdb) != 0) { - DEBUG(DEBUG_ERR,("Failed to wipe tracking database for 0x%x. Dropping read-only delegation support\n", ctdb_db->db_id)); - tdb_close(ctdb_db->rottdb); - ctdb_db->rottdb = NULL; - ctdb_db_reset_readonly(ctdb_db); - } - while (ctdb_db->revokechild_active != NULL) { - talloc_free(ctdb_db->revokechild_active); - } - } - - ctdb_lockdb_unmark(ctdb_db); - return 0; - -failed: - ctdb_lockdb_unmark(ctdb_db); - return -1; -} - struct db_push_state { struct ctdb_context *ctdb; struct ctdb_db_context *ctdb_db;