dovecot-2.1: mdbox: When rebuilding storage, fsck the map index ...
dovecot at dovecot.org
dovecot at dovecot.org
Tue Nov 27 10:41:40 EET 2012
details: http://hg.dovecot.org/dovecot-2.1/rev/8770940057b9
changeset: 14819:8770940057b9
user: Timo Sirainen <tss at iki.fi>
date: Tue Nov 27 10:39:26 2012 +0200
description:
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.
diffstat:
src/lib-storage/index/dbox-multi/mdbox-map.c | 12 +++++++-----
src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c | 6 ++++++
2 files changed, 13 insertions(+), 5 deletions(-)
diffs (49 lines):
diff -r fd2d24171afd -r 8770940057b9 src/lib-storage/index/dbox-multi/mdbox-map.c
--- 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
diff -r fd2d24171afd -r 8770940057b9 src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c
--- 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,
More information about the dovecot-cvs
mailing list