]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ctdb-daemon: Implement CTDB_CONTROL_PUSH_RECORD
authorRalph Boehme <slow@samba.org>
Tue, 3 Dec 2024 11:21:38 +0000 (12:21 +0100)
committerRalph Boehme <slow@samba.org>
Fri, 17 Jul 2026 10:18:35 +0000 (10:18 +0000)
Pair-Programmed-With: Martin Schwenke <martin@meltin.net>
Signed-off-by: Martin Schwenke <martin@meltin.net>
Signed-off-by: Ralph Boehme <slow@samba.org>
ctdb/include/ctdb_private.h
ctdb/server/ctdb_control.c
ctdb/server/ctdb_daemon.c

index a79c466c1778a296388aa15afbbe08e66e7bfb7e..9b32feb008b48de954631fb70ff2fc842814c63d 100644 (file)
@@ -592,6 +592,8 @@ int32_t ctdb_control_register_notify(struct ctdb_context *ctdb,
 int32_t ctdb_control_deregister_notify(struct ctdb_context *ctdb,
                                       uint32_t client_id, TDB_DATA indata);
 
+int32_t ctdb_control_push_record(struct ctdb_context *ctdb, TDB_DATA indata);
+
 struct ctdb_client *ctdb_find_client_by_pid(struct ctdb_context *ctdb,
                                            pid_t pid);
 
index a51795f340a5dd9b24f1fa91afb7599b4c284250..00a907748955e801549fdc77d9aa02e73c037132 100644 (file)
@@ -880,6 +880,9 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
                CHECK_CONTROL_DATA_SIZE(0);
                return ctdb_control_start_ipreallocate(ctdb, c, async_reply);
 
+       case CTDB_CONTROL_PUSH_RECORD:
+               return ctdb_control_push_record(ctdb, indata);
+
        default:
                DEBUG(DEBUG_CRIT,(__location__ " Unknown CTDB control opcode %u\n", opcode));
                return -1;
index bb6d504335a6e2f9351cf3894f224409fd7f89ae..97872eaaa82217f1a364c4480c737e1eb6f05b99 100644 (file)
@@ -2115,6 +2115,60 @@ int32_t ctdb_control_deregister_notify(struct ctdb_context *ctdb, uint32_t clien
        return 0;
 }
 
+int32_t ctdb_control_push_record(struct ctdb_context *ctdb,
+                                 TDB_DATA indata)
+{
+       struct ctdb_push_record_data *data = NULL;
+       struct ctdb_db_context *ctdb_db = NULL;
+       size_t np = 0;
+       int ret = 0;
+
+       ret = ctdb_push_record_data_pull(indata.dptr,
+                                        indata.dsize,
+                                        ctdb,
+                                        &data,
+                                        &np);
+       if (ret != 0) {
+               DBG_ERR("Invalid data\n");
+               return -1;
+       }
+
+       if (ctdb->vnn_map->generation != data->generation) {
+               DBG_INFO("Ignoring outdated push-record\n");
+               return 0;
+       }
+
+       /*
+        * Do not store on the dmaster.  This will have already been
+        * written by smbd.  Storing here would overwrite the already
+        * written record, which has an incremented RSN.
+        */
+       if (data->hdr.dmaster == ctdb->pnn) {
+               return 0;
+       }
+
+
+       ctdb_db = find_ctdb_db(ctdb, data->db_id);
+       if (ctdb_db == NULL) {
+               DBG_ERR(" Unknown db id 0x%08x\n", data->db_id);
+               return -1;
+       }
+
+       data->hdr.flags |= CTDB_REC_FLAG_MIGRATED_WITH_DATA;
+
+       ret = ctdb_ltdb_store(ctdb_db, data->key, &data->hdr, data->value);
+       if (ret != 0) {
+               return -1;
+       }
+
+       ret = ctdb_ltdb_sync(ctdb_db);
+       if (ret != 0) {
+               return -1;
+       }
+
+       return 0;
+}
+
 struct ctdb_client *ctdb_find_client_by_pid(struct ctdb_context *ctdb, pid_t pid)
 {
        struct ctdb_client_pid_list *client_pid;