]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-daemon: Drop implementation of old-style database pull/push controls
authorMartin Schwenke <martin@meltin.net>
Thu, 6 Aug 2020 11:35:14 +0000 (21:35 +1000)
committerAmitay Isaacs <amitay@samba.org>
Fri, 11 Sep 2020 06:29:32 +0000 (06:29 +0000)
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Autobuild-User(master): Amitay Isaacs <amitay@samba.org>
Autobuild-Date(master): Fri Sep 11 06:29:32 UTC 2020 on sn-devel-184

ctdb/include/ctdb_private.h
ctdb/protocol/protocol.h
ctdb/server/ctdb_control.c
ctdb/server/ctdb_recover.c

index 9ca87332d6102b7dc01fbbc4900f315fdaad6c60..8eb6686f953a3ac2fe9b8adfe46a6f84484d17d4 100644 (file)
@@ -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);
index 35543a67cf95e01020e5fc6c2d4e3ae2126bdd83..e4b76c6b9864524cd523550755ab5e535c6efb77 100644 (file)
@@ -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,
index 95f3b175934a871b7df8a1be845a441d6881519a..206ea14969324d2cf2db55e52defdadb6d751f24 100644 (file)
@@ -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;
index 1654c6d3978c1c97b976d20edc4e269e7941750b..108d8bb404b1cf5d6a2f1c60f1a3cf382d397313 100644 (file)
@@ -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, &params) == -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;i<reply->count;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;