]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
mdbox: Rebuild storage in its own atomic context
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 3 Jul 2023 09:10:41 +0000 (12:10 +0300)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 31 Jan 2024 11:37:41 +0000 (13:37 +0200)
This guarantees that the atomic context is fully committed after rebuild,
instead of rolled back due to sync failing later on.

src/lib-storage/index/dbox-multi/mdbox-sync.c

index 8b2c55f5227e0ab1a6b278b2b44f5bed5c351682..5b16b1a1ecf2f8586f9ee0d5c051b0024f5ce710 100644 (file)
@@ -321,22 +321,18 @@ int mdbox_sync(struct mdbox_mailbox *mbox, enum mdbox_sync_flags flags)
        bool corrupted, storage_rebuilt = FALSE;
        int ret;
 
-       atomic = mdbox_map_atomic_begin(mbox->storage->map);
-
        if (mbox->storage->corrupted ||
            (hdr->flags & MAIL_INDEX_HDR_FLAG_FSCKD) != 0 ||
            mdbox_map_is_fscked(mbox->storage->map) ||
            (flags & MDBOX_SYNC_FLAG_FORCE_REBUILD) != 0) {
-               if (mdbox_storage_rebuild_in_context(mbox->storage, atomic) < 0) {
-                       (void)mdbox_map_atomic_finish(&atomic);
+               if (mdbox_storage_rebuild(mbox->storage) < 0)
                        return -1;
-               }
                mailbox_recent_flags_reset(&mbox->box);
                storage_rebuilt = TRUE;
                flags |= MDBOX_SYNC_FLAG_FORCE;
        }
 
-
+       atomic = mdbox_map_atomic_begin(mbox->storage->map);
        ret = mdbox_sync_begin(mbox, flags, atomic, &sync_ctx, &corrupted);
        if (corrupted) {
                if (storage_rebuilt) {