dovecot-2.2: lib-index: Don't bother tracking if header/records ...
dovecot at dovecot.org
dovecot at dovecot.org
Tue Jun 18 12:59:31 EEST 2013
details: http://hg.dovecot.org/dovecot-2.2/rev/37bd40e27b67
changeset: 16532:37bd40e27b67
user: Timo Sirainen <tss at iki.fi>
date: Tue Jun 18 12:59:17 2013 +0300
description:
lib-index: Don't bother tracking if header/records were changed.
They aren't really needed. When mail_index_write() is called, we already
know we want to update the index.
diffstat:
src/lib-index/mail-index-fsck.c | 1 -
src/lib-index/mail-index-map.c | 4 ----
src/lib-index/mail-index-modseq.c | 2 --
src/lib-index/mail-index-private.h | 5 -----
src/lib-index/mail-index-sync-ext.c | 13 +++++--------
src/lib-index/mail-index-sync-keywords.c | 2 --
src/lib-index/mail-index-sync-update.c | 7 +------
src/lib-index/mail-index-write.c | 8 +-------
8 files changed, 7 insertions(+), 35 deletions(-)
diffs (223 lines):
diff -r 3794e6cb0da8 -r 37bd40e27b67 src/lib-index/mail-index-fsck.c
--- a/src/lib-index/mail-index-fsck.c Tue Jun 18 12:56:27 2013 +0300
+++ b/src/lib-index/mail-index-fsck.c Tue Jun 18 12:59:17 2013 +0300
@@ -454,7 +454,6 @@
mail_index_fsck_map(index, map);
} T_END;
- map->header_changed = TRUE;
mail_index_write(index, FALSE);
if (!orig_locked)
diff -r 3794e6cb0da8 -r 37bd40e27b67 src/lib-index/mail-index-map.c
--- a/src/lib-index/mail-index-map.c Tue Jun 18 12:56:27 2013 +0300
+++ b/src/lib-index/mail-index-map.c Tue Jun 18 12:59:17 2013 +0300
@@ -332,8 +332,6 @@
dest->records = buffer_get_modifiable_data(dest->buffer, NULL);
dest->records_count = src->records_count;
-
- dest->records_changed = src->records_changed;
}
static void mail_index_map_copy_header(struct mail_index_map *dest,
@@ -396,8 +394,6 @@
mail_index_map_copy_header(mem_map, map);
- mem_map->header_changed = map->header_changed;
-
/* copy extensions */
if (array_is_created(&map->ext_id_map)) {
count = array_count(&map->ext_id_map);
diff -r 3794e6cb0da8 -r 37bd40e27b67 src/lib-index/mail-index-modseq.c
--- a/src/lib-index/mail-index-modseq.c Tue Jun 18 12:56:27 2013 +0300
+++ b/src/lib-index/mail-index-modseq.c Tue Jun 18 12:59:17 2013 +0300
@@ -470,7 +470,6 @@
} T_END;
}
}
- map->rec_map->records_changed = TRUE;
mail_transaction_log_view_close(&ctx->log_view);
}
@@ -521,7 +520,6 @@
buffer_write(map->hdr_copy_buf, ext->hdr_offset,
&new_modseq_hdr, sizeof(new_modseq_hdr));
map->hdr_base = map->hdr_copy_buf->data;
- map->header_changed = TRUE;
}
}
diff -r 3794e6cb0da8 -r 37bd40e27b67 src/lib-index/mail-index-private.h
--- a/src/lib-index/mail-index-private.h Tue Jun 18 12:56:27 2013 +0300
+++ b/src/lib-index/mail-index-private.h Tue Jun 18 12:59:17 2013 +0300
@@ -127,9 +127,6 @@
struct mail_index_map_modseq *modseq;
uint32_t last_appended_uid;
-
- /* The records have changed since it was read */
- bool records_changed;
};
struct mail_index_map {
@@ -147,8 +144,6 @@
ARRAY(unsigned int) keyword_idx_map; /* file -> index */
struct mail_index_record_map *rec_map;
-
- unsigned int header_changed:1;
};
struct mail_index_module_register {
diff -r 3794e6cb0da8 -r 37bd40e27b67 src/lib-index/mail-index-sync-ext.c
--- a/src/lib-index/mail-index-sync-ext.c Tue Jun 18 12:56:27 2013 +0300
+++ b/src/lib-index/mail-index-sync-ext.c Tue Jun 18 12:59:17 2013 +0300
@@ -317,7 +317,6 @@
i_assert((map->hdr_copy_buf->used % sizeof(uint64_t)) == 0);
map->hdr_base = map->hdr_copy_buf->data;
map->hdr.header_size = map->hdr_copy_buf->used;
- map->header_changed = TRUE;
ext_hdr = get_ext_header(map, ext);
ext_hdr->reset_id = ext->reset_id;
@@ -577,7 +576,6 @@
memset(PTR_OFFSET(rec, ext->record_offset), 0,
ext->record_size);
}
- map->rec_map->records_changed = TRUE;
}
int mail_index_sync_ext_reset(struct mail_index_sync_map_ctx *ctx,
@@ -630,9 +628,14 @@
ext = array_idx(&map->extensions, ctx->cur_ext_map_idx);
if (offset + size > ext->hdr_size) {
+#if 1
mail_index_sync_set_corrupted(ctx,
"Extension header update points outside header size");
return -1;
+#else
+ size = offset > ext->hdr_size ? 0 :
+ ext->hdr_size - offset;
+#endif
}
buffer_write(map->hdr_copy_buf, ext->hdr_offset + offset, data, size);
@@ -640,8 +643,6 @@
if (ext->index_idx == ctx->view->index->modseq_ext_id)
mail_index_modseq_hdr_update(ctx->modseq_ctx);
-
- map->header_changed = TRUE;
return 1;
}
@@ -690,8 +691,6 @@
return ret;
}
- view->map->rec_map->records_changed = TRUE;
-
/* @UNSAFE */
memcpy(old_data, u + 1, ext->record_size);
return 1;
@@ -791,7 +790,5 @@
u->uid, u->diff, (unsigned long long)orig_num);
return -1;
}
-
- view->map->rec_map->records_changed = TRUE;
return 1;
}
diff -r 3794e6cb0da8 -r 37bd40e27b67 src/lib-index/mail-index-sync-keywords.c
--- a/src/lib-index/mail-index-sync-keywords.c Tue Jun 18 12:56:27 2013 +0300
+++ b/src/lib-index/mail-index-sync-keywords.c Tue Jun 18 12:59:17 2013 +0300
@@ -215,7 +215,6 @@
if (!mail_index_lookup_seq_range(view, uid1, uid2, &seq1, &seq2))
return 1;
- view->map->rec_map->records_changed = TRUE;
mail_index_modseq_update_keyword(ctx->modseq_ctx, keyword_idx,
seq1, seq2);
@@ -337,7 +336,6 @@
&seq1, &seq2))
continue;
- map->rec_map->records_changed = TRUE;
mail_index_modseq_reset_keywords(ctx->modseq_ctx, seq1, seq2);
for (seq1--; seq1 < seq2; seq1++) {
rec = MAIL_INDEX_MAP_IDX(map, seq1);
diff -r 3794e6cb0da8 -r 37bd40e27b67 src/lib-index/mail-index-sync-update.c
--- a/src/lib-index/mail-index-sync-update.c Tue Jun 18 12:56:27 2013 +0300
+++ b/src/lib-index/mail-index-sync-update.c Tue Jun 18 12:59:17 2013 +0300
@@ -380,7 +380,6 @@
map->rec_map->last_appended_uid = rec->uid;
new_flags = rec->flags;
- map->rec_map->records_changed = TRUE;
mail_index_modseq_append(ctx->modseq_ctx,
map->rec_map->records_count);
}
@@ -408,7 +407,6 @@
if (!mail_index_lookup_seq_range(view, u->uid1, u->uid2, &seq1, &seq2))
return 1;
- view->map->rec_map->records_changed = TRUE;
if (!MAIL_TRANSACTION_FLAG_UPDATE_IS_INTERNAL(u)) {
mail_index_modseq_update_flags(ctx->modseq_ctx,
u->add_flags | u->remove_flags,
@@ -464,7 +462,6 @@
buffer_write(map->hdr_copy_buf, u->offset, u + 1, u->size);
map->hdr_base = map->hdr_copy_buf->data;
- map->header_changed = TRUE;
/* @UNSAFE */
if ((uint32_t)(u->offset + u->size) <= sizeof(map->hdr)) {
@@ -945,10 +942,8 @@
map->refcount--;
had_dirty = (map->hdr.flags & MAIL_INDEX_HDR_FLAG_HAVE_DIRTY) != 0;
- if (had_dirty) {
+ if (had_dirty)
map->hdr.flags &= ~MAIL_INDEX_HDR_FLAG_HAVE_DIRTY;
- map->header_changed = TRUE;
- }
if (map->hdr_base != map->hdr_copy_buf->data) {
/* if syncing updates the header, it updates hdr_copy_buf
diff -r 3794e6cb0da8 -r 37bd40e27b67 src/lib-index/mail-index-write.c
--- a/src/lib-index/mail-index-write.c Tue Jun 18 12:56:27 2013 +0300
+++ b/src/lib-index/mail-index-write.c Tue Jun 18 12:59:17 2013 +0300
@@ -119,9 +119,6 @@
return ret;
}
-#define mail_index_map_has_changed(map) \
- ((map)->header_changed || (map)->rec_map->records_changed)
-
void mail_index_write(struct mail_index *index, bool want_rotate)
{
struct mail_index_map *map = index->map;
@@ -129,7 +126,7 @@
i_assert(index->log_sync_locked);
- if (!mail_index_map_has_changed(map) || index->readonly)
+ if (index->readonly)
return;
if (!MAIL_INDEX_IS_IN_MEMORY(index)) {
@@ -143,9 +140,6 @@
index->last_read_log_file_head_offset = hdr->log_file_head_offset;
index->last_read_log_file_tail_offset = hdr->log_file_tail_offset;
- map->rec_map->records_changed = FALSE;
- map->header_changed = FALSE;
-
if (want_rotate &&
hdr->log_file_seq == index->log->head->hdr.file_seq &&
hdr->log_file_tail_offset == hdr->log_file_head_offset)
More information about the dovecot-cvs
mailing list