int ret = 0;
if (index_mailbox_want_full_sync(&mbox->box, flags) ||
- mbox->storage->corrupted)
+ mbox->storage->corrupted_reason != NULL)
ret = mdbox_deleted_sync(mbox, mdbox_sync_flags);
return index_mailbox_sync_init(box, flags, ret < 0);
} T_END;
mdbox_purge_free(&ctx);
- if (storage->corrupted) {
+ if (storage->corrupted_reason != NULL) {
/* purging found corrupted files */
(void)mdbox_storage_rebuild(storage, NULL,
MDBOX_REBUILD_REASON_CORRUPTED);
if ((reason & MDBOX_REBUILD_REASON_FORCED) != 0)
*reason_string_r = "Rebuild forced";
- else if ((reason & MDBOX_REBUILD_REASON_CORRUPTED) != 0)
- *reason_string_r = "Storage was marked corrupted";
- else if ((reason & MDBOX_REBUILD_REASON_MAP_FSCKD) != 0)
+ else if ((reason & MDBOX_REBUILD_REASON_CORRUPTED) != 0) {
+ i_assert(ctx->storage->corrupted_reason != NULL);
+ *reason_string_r = t_strdup_printf(
+ "Storage was marked corrupted: %s",
+ ctx->storage->corrupted_reason);
+ } else if ((reason & MDBOX_REBUILD_REASON_MAP_FSCKD) != 0)
*reason_string_r = "dovecot.index.map was fsck'd";
else if ((reason & MDBOX_REBUILD_REASON_MAILBOX_FSCKD) != 0) {
*reason_string_r = t_strdup_printf(
/* get storage rebuild counter after locking */
ctx->rebuild_count = mdbox_map_get_rebuild_count(ctx->storage->map);
if (ctx->rebuild_count != ctx->storage->corrupted_rebuild_count &&
- ctx->storage->corrupted) {
+ ctx->storage->corrupted_reason != NULL) {
/* storage was already rebuilt by someone else */
return 0;
}
mdbox_storage_rebuild_deinit(ctx);
if (ret == 0) {
- storage->corrupted = FALSE;
+ i_free(storage->corrupted_reason);
storage->corrupted_rebuild_count = 0;
}
return ret;
if (array_is_created(&storage->move_to_alt_map_uids))
array_free(&storage->move_to_alt_map_uids);
array_free(&storage->open_files);
+ i_free(storage->corrupted_reason);
dbox_storage_destroy(_storage);
}
{
struct mdbox_storage *mstorage = MDBOX_STORAGE(box->storage);
- if (mstorage->corrupted && !mstorage->rebuilding_storage) {
+ if (mstorage->corrupted_reason != NULL &&
+ !mstorage->rebuilding_storage) {
(void)mdbox_storage_rebuild(mstorage, box,
MDBOX_REBUILD_REASON_CORRUPTED);
}
void mdbox_storage_set_corrupted(struct mdbox_storage *storage)
{
- if (storage->corrupted) {
+ if (storage->corrupted_reason != NULL) {
/* already set it corrupted (possibly recursing back here) */
return;
}
- storage->corrupted = TRUE;
+ storage->corrupted_reason = i_strdup("Storage marked corrupted");
storage->corrupted_rebuild_count = (uint32_t)-1;
if (mdbox_map_open(storage->map) > 0 &&
/* if non-zero, storage should be rebuilt (except if rebuild_count
has changed from this value) */
uint32_t corrupted_rebuild_count;
+ char *corrupted_reason;
- bool corrupted:1;
bool rebuilding_storage:1;
bool preallocate_space:1;
};
mailbox_sync_notify(box, 0, 0);
return ret == 0 ? 1 :
- (ctx->mbox->storage->corrupted ? 0 : -1);
+ (ctx->mbox->storage->corrupted_reason != NULL ? 0 : -1);
}
static int mdbox_sync_try_begin(struct mdbox_sync_context *ctx,
bool corrupted, storage_rebuilt = FALSE;
int ret;
- if (mbox->storage->corrupted)
+ if (mbox->storage->corrupted_reason != NULL)
rebuild_reason |= MDBOX_REBUILD_REASON_CORRUPTED;
if ((hdr->flags & MAIL_INDEX_HDR_FLAG_FSCKD) != 0)
rebuild_reason |= MDBOX_REBUILD_REASON_MAILBOX_FSCKD;
if (mail_index_reset_fscked(box->index))
mdbox_storage_set_corrupted(mbox->storage);
if (index_mailbox_want_full_sync(&mbox->box, flags) ||
- mbox->storage->corrupted) {
+ mbox->storage->corrupted_reason != NULL) {
if ((flags & MAILBOX_SYNC_FLAG_FORCE_RESYNC) != 0)
mdbox_sync_flags |= MDBOX_SYNC_FLAG_FORCE_REBUILD;
ret = mdbox_sync(mbox, mdbox_sync_flags);