]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
mdbox: Added mdbox_purge_preserve_alt setting to keep the file within alt storage...
authorTimo Sirainen <tss@iki.fi>
Mon, 10 Mar 2014 22:39:27 +0000 (00:39 +0200)
committerTimo Sirainen <tss@iki.fi>
Mon, 10 Mar 2014 22:39:27 +0000 (00:39 +0200)
Perhaps it would be better for this setting to be the default in v2.3 and
maybe be removed entirely? Not a good idea to change during v2.2.x anyway,
so for now this is a setting.

src/lib-storage/index/dbox-multi/mdbox-purge.c
src/lib-storage/index/dbox-multi/mdbox-settings.c
src/lib-storage/index/dbox-multi/mdbox-settings.h

index 7c02b3f2476faaad27b21c4ab14f732232247ea0..cee06d92ba013cfd17a7824d0fb6195fe6fbb9ec 100644 (file)
@@ -165,11 +165,16 @@ mdbox_metadata_get_extrefs(struct dbox_file *file, pool_t ext_refs_pool,
 }
 
 static bool
-mdbox_purge_want_altpath(struct mdbox_purge_context *ctx, uint32_t map_uid)
+mdbox_purge_want_altpath(struct mdbox_purge_context *ctx,
+                        struct dbox_file *file, uint32_t map_uid)
 {
        enum mdbox_msg_action action;
        void *value;
 
+       if (dbox_file_is_in_alt(file) &&
+           ctx->storage->set->mdbox_purge_preserve_alt)
+               return TRUE;
+
        if (!ctx->have_altmoves)
                return FALSE;
 
@@ -193,7 +198,7 @@ mdbox_purge_save_msg(struct mdbox_purge_context *ctx, struct dbox_file *file,
        if (ctx->append_ctx == NULL)
                ctx->append_ctx = mdbox_map_append_begin(ctx->atomic);
 
-       append_flags = !mdbox_purge_want_altpath(ctx, msg->map_uid) ? 0 :
+       append_flags = !mdbox_purge_want_altpath(ctx, file, msg->map_uid) ? 0 :
                DBOX_MAP_APPEND_FLAG_ALT;
        msg_size = file->msg_header_size + file->cur_physical_size;
        if (mdbox_map_append_next(ctx->append_ctx, file->cur_physical_size,
index ffafcca70ed77530d1a5cfe7037630d424b2aa11..947018a2f45e1186f2d451ffaf31b89ff473dcf4 100644 (file)
@@ -13,6 +13,7 @@
 
 static const struct setting_define mdbox_setting_defines[] = {
        DEF(SET_BOOL, mdbox_preallocate_space),
+       DEF(SET_BOOL, mdbox_purge_preserve_alt),
        DEF(SET_SIZE, mdbox_rotate_size),
        DEF(SET_TIME, mdbox_rotate_interval),
 
@@ -21,6 +22,7 @@ static const struct setting_define mdbox_setting_defines[] = {
 
 static const struct mdbox_settings mdbox_default_settings = {
        .mdbox_preallocate_space = FALSE,
+       .mdbox_purge_preserve_alt = FALSE,
        .mdbox_rotate_size = 2*1024*1024,
        .mdbox_rotate_interval = 0
 };
index 353da69618643c7f5200e1a3a88b8bd5e0f89bb5..80aefa2e282677d2220a81e2ef27d8c3b7610e71 100644 (file)
@@ -3,6 +3,7 @@
 
 struct mdbox_settings {
        bool mdbox_preallocate_space;
+       bool mdbox_purge_preserve_alt;
        uoff_t mdbox_rotate_size;
        unsigned int mdbox_rotate_interval;
 };