ldb: Move where we update the pack format version
authorTim Beale <timbeale@catalyst.net.nz>
Tue, 30 Jul 2019 03:02:25 +0000 (15:02 +1200)
committerGarming Sam <garming@samba.org>
Tue, 20 Aug 2019 03:40:28 +0000 (03:40 +0000)
Store it on the repack context so that we can log a more informative
message "Repacking from format x to format y".

While this is not really a big deal currently, it could be worth
recording for potential future scenarios (i.e. supporting three or more
pack versions), where upgrades could potentially skip an intermediary
pack format version.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14059

Signed-off-by: Tim Beale <timbeale@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
lib/ldb/ldb_key_value/ldb_kv.c
lib/ldb/ldb_key_value/ldb_kv.h
lib/ldb/ldb_key_value/ldb_kv_index.c

index f768fb5e1e44d60c2f1faf5d695b58c265e4fb45..4e7b8a116b320862e9202385a4f43abfade77903 100644 (file)
@@ -315,8 +315,6 @@ static int ldb_kv_maybe_repack(struct ldb_kv_private *ldb_kv) {
            ldb_kv->target_pack_format_version) {
                int r;
                struct ldb_context *ldb = ldb_module_get_ctx(ldb_kv->module);
-               ldb_kv->pack_format_version =
-                       ldb_kv->target_pack_format_version;
                r = ldb_kv_repack(ldb_kv->module);
                if (r != LDB_SUCCESS) {
                        ldb_debug(ldb, LDB_DEBUG_ERROR,
index e627644ba3499663078b1a8ff0ab8a789f3e779e..f9dffae2dcf05bdbf3c7bc91a189cdd2afc03a55 100644 (file)
@@ -175,6 +175,7 @@ struct ldb_kv_repack_context {
        int error;
        uint32_t count;
        bool normal_record_seen;
+       uint32_t old_version;
 };
 
 
index 5de316579d7efd2b6658a8cb6d2b984de2693e9a..eb84a790e004d89f1020ff34e0034de53a9a1764 100644 (file)
@@ -3595,10 +3595,13 @@ int ldb_kv_repack(struct ldb_module *module)
        struct ldb_kv_repack_context ctx;
        int ret;
 
+       ctx.old_version = ldb_kv->pack_format_version;
        ctx.count = 0;
        ctx.error = LDB_SUCCESS;
        ctx.normal_record_seen = false;
 
+       ldb_kv->pack_format_version = ldb_kv->target_pack_format_version;
+
        /* Iterate all database records and repack them in the new format */
        ret = ldb_kv->kv_ops->iterate(ldb_kv, re_pack, &ctx);
        if (ret < 0) {