]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
dbwrap: add record flags to struct db_record
authorRalph Boehme <slow@samba.org>
Mon, 4 Nov 2024 06:54:19 +0000 (07:54 +0100)
committerRalph Boehme <slow@samba.org>
Fri, 17 Jul 2026 10:18:35 +0000 (10:18 +0000)
This is needed to implement persistent record deletion in the case that
a record was stored as persistent, then fetched and is then stored
without persistency.

The additional tdb record header uses CTDB_REC_FLAG_PERSISTENT to denote if the
record was stored as persistent. When fetching a record we remember the
persistency property in record.flags.persistent.

When a subsequent store doesn't request persistency and record.flags.persistent
is set, we delete record from the persistent database.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
lib/dbwrap/dbwrap.h
lib/dbwrap/dbwrap_private.h
lib/dbwrap/dbwrap_rbt.c
lib/dbwrap/dbwrap_tdb.c
source3/lib/dbwrap/dbwrap_ctdb.c

index 675690837659145c36b68a2ef3e699cf1c8d82a3..b1127bc612eda428321617fe52e81a5374ab9b3e 100644 (file)
@@ -70,6 +70,10 @@ enum dbwrap_req_state {
        DBWRAP_REQ_ERROR
 };
 
+struct db_record_flags {
+       bool persistent : 1;
+};
+
 /* The following definitions come from lib/dbwrap.c  */
 
 TDB_DATA dbwrap_record_get_key(const struct db_record *rec);
index 3ac5ebf97a10bbeef201010c48b3c9eb838604eb..3dc7bb20e457dcf03a5e623ce7b8e9206da3733b 100644 (file)
@@ -33,6 +33,7 @@ struct db_record {
        NTSTATUS (*storev)(struct db_record *rec, const TDB_DATA *dbufs,
                           int num_dbufs, int flag);
        NTSTATUS (*delete_rec)(struct db_record *rec);
+       struct db_record_flags flags;
        void *private_data;
 };
 
index 89d30bb323293466440e6ce7164504392bc8e335..6cd8d936db6a1a47882fc44af8cc395df1c461ae 100644 (file)
@@ -380,6 +380,7 @@ static struct db_record *db_rbt_fetch_locked(struct db_context *db_ctx,
        rec_priv = (struct db_rbt_rec *)
                ((char *)result + DBWRAP_RBT_ALIGN(sizeof(struct db_record)));
 
+       result->flags = (struct db_record_flags) {};
        result->storev = db_rbt_storev;
        result->delete_rec = db_rbt_delete;
        result->private_data = rec_priv;
index 6cd95fa25ad524559d219b1a765b887565d2b338..582cea6b97fe7e3076b667226aef146827629596 100644 (file)
@@ -95,6 +95,7 @@ static int db_tdb_fetchlock_parse(TDB_DATA key, TDB_DATA data,
        }
        state->result = result;
 
+       result->flags = (struct db_record_flags) {};
        result->key.dsize = key.dsize;
        result->key.dptr = ((uint8_t *)result) + sizeof(struct db_record);
        memcpy(result->key.dptr, key.dptr, key.dsize);
index 807b7f5224860d40028efe1db4a9cce46ea20780..65e710e552d29a01572d4c6f1bee3c4c67fe9030 100644 (file)
@@ -1107,6 +1107,7 @@ static struct db_record *fetch_locked_internal(struct db_ctdb_ctx *ctx,
                return NULL;
        }
 
+       result->flags = (struct db_record_flags) {};
        result->db = ctx->db;
        result->private_data = (void *)crec;
        crec->ctdb_ctx = ctx;