new_path = t_strdup_printf("%s/%s", new_dir, new_fname);
if (stat(new_path, &st) == 0) {
- mail_storage_set_critical(&file->file.storage->storage,
- "mdbox: %s already exists, rebuilding index", new_path);
- mdbox_storage_set_corrupted(file->storage);
+ mdbox_storage_set_corrupted(file->storage,
+ "%s already exists, rebuilding index", new_path);
return -1;
}
if (rename(old_path, new_path) < 0) {
va_list args;
va_start(args, format);
- mail_storage_set_critical(MAP_STORAGE(map),
- "mdbox map %s corrupted: %s",
- map->index->filepath,
- t_strdup_vprintf(format, args));
+ mdbox_storage_set_corrupted(map->storage, "map %s corrupted: %s",
+ map->index->filepath,
+ t_strdup_vprintf(format, args));
va_end(args);
-
- mdbox_storage_set_corrupted(map->storage);
}
struct mdbox_map *
mail_storage_set_index_error(MAP_STORAGE(map), map->index);
ret = -1;
}
- if (fscked)
- mdbox_storage_set_corrupted(map->storage);
+ if (fscked) {
+ mdbox_storage_set_corrupted(map->storage,
+ "dovecot.index.map was fsck'd (refresh)");
+ }
return ret;
}
mail_index_sync_get_offsets(sync_ctx, &seq1, &offset1, &seq2, &offset2);
if (offset1 != offset2 || seq1 != seq2) {
/* something had crashed. need a full resync. */
- i_warning("mdbox %s: Inconsistency in map index "
- "(%u,%"PRIuUOFF_T" != %u,%"PRIuUOFF_T")",
- map->path, seq1, offset1, seq2, offset2);
- mdbox_storage_set_corrupted(map->storage);
+ mdbox_storage_set_corrupted(map->storage,
+ "Inconsistency in map index "
+ "(%u,%"PRIuUOFF_T" != %u,%"PRIuUOFF_T")",
+ seq1, offset1, seq2, offset2);
}
while (mail_index_sync_next(sync_ctx, &sync_rec)) ;
}
ret = mail_index_sync_begin(atomic->map->index, &atomic->sync_ctx,
&atomic->sync_view, &atomic->sync_trans,
MAIL_INDEX_SYNC_FLAG_UPDATE_TAIL_OFFSET);
- if (mail_index_reset_fscked(atomic->map->index))
- mdbox_storage_set_corrupted(atomic->map->storage);
+ if (mail_index_reset_fscked(atomic->map->index)) {
+ mdbox_storage_set_corrupted(atomic->map->storage,
+ "dovecot.index.map was fsck'd (atomic lock)");
+ }
if (ret <= 0) {
i_assert(ret != 0);
mail_storage_set_index_error(MAP_STORAGE(atomic->map),
return ret;
}
-void mdbox_storage_set_corrupted(struct mdbox_storage *storage)
+void mdbox_storage_set_corrupted(struct mdbox_storage *storage,
+ const char *reason, ...)
{
+ const char *reason_str;
+ va_list args;
+
+ va_start(args, reason);
+ reason_str = t_strdup_vprintf(reason, args);
+ va_end(args);
+
+ mail_storage_set_critical(&storage->storage.storage, "%s", reason_str);
if (storage->corrupted_reason != NULL) {
/* already set it corrupted (possibly recursing back here) */
return;
}
- storage->corrupted_reason = i_strdup("Storage marked corrupted");
+ storage->corrupted_reason = i_strdup(reason_str);
storage->corrupted_rebuild_count = (uint32_t)-1;
if (mdbox_map_open(storage->map) > 0 &&
{
struct mdbox_storage *mstorage = MDBOX_STORAGE(box->storage);
- mailbox_set_critical(box, "%s", reason);
- mdbox_storage_set_corrupted(mstorage);
+ mdbox_storage_set_corrupted(mstorage, "Mailbox %s: %s",
+ box->vname, reason);
}
void mdbox_set_file_corrupted(struct dbox_file *file, const char *reason)
{
struct mdbox_storage *mstorage = MDBOX_DBOX_STORAGE(file->storage);
- mail_storage_set_critical(&mstorage->storage.storage, "%s", reason);
- mdbox_storage_set_corrupted(mstorage);
+ mdbox_storage_set_corrupted(mstorage, "%s", reason);
}
static int
void mdbox_storage_destroy(struct mail_storage *_storage);
int mdbox_mailbox_open(struct mailbox *box);
-void mdbox_storage_set_corrupted(struct mdbox_storage *storage);
+void mdbox_storage_set_corrupted(struct mdbox_storage *storage,
+ const char *reason, ...) ATTR_FORMAT(2, 3);
void mdbox_set_mailbox_corrupted(struct mailbox *box, const char *reason);
void mdbox_set_file_corrupted(struct dbox_file *file, const char *reason);