]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
INDEX_KEYWORDS_BYTE_COUNT was counted wrong so index files were larger than
authorTimo Sirainen <tss@iki.fi>
Mon, 3 May 2004 14:22:24 +0000 (17:22 +0300)
committerTimo Sirainen <tss@iki.fi>
Mon, 3 May 2004 14:22:24 +0000 (17:22 +0300)
they needed to be. Added sizeof(keywords_mask_t) to compat_data. Added limit
to growing index file exponentially.

--HG--
branch : HEAD

src/lib-index/mail-index-private.h
src/lib-index/mail-index-sync-update.c
src/lib-index/mail-index.c
src/lib-index/mail-index.h

index fcc9d8a6673e14446313f37482ce462d1cc9f119..3fb7c3f580e93f4cb2c14fa98adb9c9f3d5eb9e5 100644 (file)
@@ -6,23 +6,13 @@
 
 struct mail_transaction_header;
 
-/* number of records to always keep allocated in index file,
-   either used or unused */
-#define INDEX_MIN_RECORDS_COUNT 64
-/* when empty space in index file gets full, grow the file n% larger */
-#define INDEX_GROW_PERCENTAGE 10
-/* ftruncate() the index file when only n% of it is in use */
-#define INDEX_TRUNCATE_PERCENTAGE 30
-/* don't truncate whole file anyway, keep n% of the empty space */
-#define INDEX_TRUNCATE_KEEP_PERCENTAGE 10
-/* Compress the file when deleted space reaches n% of total size */
-#define INDEX_COMPRESS_PERCENTAGE 50
-/* Compress the file when searching deleted records tree has to go this deep */
-#define INDEX_COMPRESS_DEPTH 10
+/* Index file is grown exponentially when we're adding less than this many
+   records. */
+#define MAIL_INDEX_MAX_POWER_GROW (1024*1024 / sizeof(struct mail_index_record))
 /* How many times to retry opening index files if read/fstat returns ESTALE.
    This happens with NFS when the file has been deleted (ie. index file was
    rewritten by another computer than us). */
-#define INDEX_ESTALE_RETRY_COUNT 10
+#define MAIL_INDEX_ESTALE_RETRY_COUNT 10
 
 #define MAIL_INDEX_MAP_IS_IN_MEMORY(map) \
        ((map)->buffer != NULL)
index 1acccd243ef9a9e9ac1679d193a330ac67e0e6c9..9f460acceb3907a216f3086864d35bfecee4c149 100644 (file)
@@ -116,7 +116,8 @@ static int mail_index_grow(struct mail_index *index, unsigned int count)
        /* when we grow fast, do it exponentially */
        if (count < index->last_grow_count)
                count = index->last_grow_count;
-       count = nearest_power(count);
+       if (count < MAIL_INDEX_MAX_POWER_GROW)
+               count = nearest_power(count);
        index->last_grow_count = count;
 
        size = map->hdr->header_size +
index ace197d38e6db86e42ae4277c12bfbcba6f85b14..e012063042c446aba88c6350e62e7910009c6d8f 100644 (file)
@@ -49,6 +49,7 @@ static int mail_index_check_header(struct mail_index *index,
 #endif
        compat_data[1] = sizeof(uoff_t);
        compat_data[2] = sizeof(time_t);
+       compat_data[3] = sizeof(keywords_mask_t);
 
        if (hdr->major_version != MAIL_INDEX_MAJOR_VERSION) {
                /* major version change - handle silently(?) */
@@ -233,7 +234,7 @@ static int mail_index_read_map_with_retry(struct mail_index *index,
 {
        int i, ret;
 
-       for (i = 0; i < INDEX_ESTALE_RETRY_COUNT; i++) {
+       for (i = 0; i < MAIL_INDEX_ESTALE_RETRY_COUNT; i++) {
                ret = mail_index_read_map(index, map);
                if (ret != 0)
                        return ret;
@@ -359,6 +360,7 @@ void mail_index_header_init(struct mail_index_header *hdr)
 #endif
        hdr->compat_data[1] = sizeof(uoff_t);
        hdr->compat_data[2] = sizeof(time_t);
+       hdr->compat_data[3] = sizeof(keywords_mask_t);
 
        hdr->indexid = now;
 
index 24c9aee8d7bf09104b8d5161846b5a4439c55d18..e941835392964b3cbb65ec70c0ac78cf98360bfe 100644 (file)
@@ -10,7 +10,7 @@
 
 /* Number of keywords in mail_index_record. */
 #define INDEX_KEYWORDS_COUNT (3*8)
-#define INDEX_KEYWORDS_BYTE_COUNT ((INDEX_KEYWORDS_COUNT*7)/8)
+#define INDEX_KEYWORDS_BYTE_COUNT ((INDEX_KEYWORDS_COUNT+CHAR_BIT-1) / CHAR_BIT)
 
 enum mail_index_open_flags {
        /* Create index if it doesn't exist */