Mercurial > dovecot > original-hg > dovecot-2.1
changeset 14819:8770940057b9
mdbox: When rebuilding storage, fsck the map index first to make sure it's valid.
This fixes assert-crash when the map index contained records with UIDs in
wrong order.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Tue, 27 Nov 2012 10:39:26 +0200 |
parents | fd2d24171afd |
children | a9e7f9333f57 |
files | src/lib-storage/index/dbox-multi/mdbox-map.c src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c |
diffstat | 2 files changed, 13 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-storage/index/dbox-multi/mdbox-map.c Tue Nov 27 10:02:59 2012 +0200 +++ b/src/lib-storage/index/dbox-multi/mdbox-map.c Tue Nov 27 10:39:26 2012 +0200 @@ -243,7 +243,8 @@ int mdbox_map_refresh(struct mdbox_map *map) { struct mail_index_view_sync_ctx *ctx; - bool delayed_expunges; + bool delayed_expunges, fscked; + int ret = 0; /* some open files may have read partially written mails. now that map syncing makes the new mails visible, we need to make sure the @@ -262,14 +263,15 @@ ctx = mail_index_view_sync_begin(map->view, MAIL_INDEX_VIEW_SYNC_FLAG_FIX_INCONSISTENT); - if (mail_index_reset_fscked(map->view->index)) - mdbox_storage_set_corrupted(map->storage); + fscked = mail_index_reset_fscked(map->view->index); if (mail_index_view_sync_commit(&ctx, &delayed_expunges) < 0) { mail_storage_set_internal_error(MAP_STORAGE(map)); mail_index_reset_error(map->index); - return -1; + ret = -1; } - return 0; + if (fscked) + mdbox_storage_set_corrupted(map->storage); + return ret; } static void
--- a/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Tue Nov 27 10:02:59 2012 +0200 +++ b/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c Tue Nov 27 10:39:26 2012 +0200 @@ -836,6 +836,12 @@ if (mdbox_map_atomic_lock(ctx->atomic) < 0) return -1; + /* fsck the map just in case its UIDs are broken */ + if (mail_index_fsck(ctx->storage->map->index) < 0) { + mail_storage_set_internal_error(&ctx->storage->storage.storage); + return -1; + } + /* get old map header */ mail_index_get_header_ext(ctx->atomic->sync_view, ctx->storage->map->map_ext_id,