]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
mdbox, mbox, virtual: Avoid getting expunged-status in index lookups when not necessary.
authorTimo Sirainen <tss@iki.fi>
Sat, 16 Feb 2013 11:51:05 +0000 (13:51 +0200)
committerTimo Sirainen <tss@iki.fi>
Sat, 16 Feb 2013 11:51:05 +0000 (13:51 +0200)
This especially improves dsync performance with mdbox.

src/lib-storage/index/dbox-multi/mdbox-mail.c
src/lib-storage/index/dbox-multi/mdbox-map.c
src/lib-storage/index/dbox-multi/mdbox-save.c
src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c
src/lib-storage/index/dbox-multi/mdbox-sync.c
src/lib-storage/index/mbox/mbox-mail.c
src/lib-storage/index/mbox/mbox-sync.c
src/plugins/virtual/virtual-mail.c
src/plugins/virtual/virtual-search.c
src/plugins/virtual/virtual-sync.c

index 97b4b1c257b14d91f69bf4509acfab5be0b06675..2d8d71f2961b3e3ad64e27410d450d1709bd2984 100644 (file)
@@ -21,9 +21,8 @@ int mdbox_mail_lookup(struct mdbox_mailbox *mbox, struct mail_index_view *view,
        struct mdbox_index_header hdr;
        const void *data;
        uint32_t uid, cur_map_uid_validity;
-       bool expunged;
 
-       mail_index_lookup_ext(view, seq, mbox->ext_id, &data, &expunged);
+       mail_index_lookup_ext(view, seq, mbox->ext_id, &data, NULL);
        dbox_rec = data;
        if (dbox_rec == NULL || dbox_rec->map_uid == 0) {
                mail_index_lookup_uid(view, seq, &uid);
@@ -156,10 +155,9 @@ static int mdbox_mail_get_save_date(struct mail *mail, time_t *date_r)
                (struct mdbox_mailbox *)mail->transaction->box;
        const struct mdbox_mail_index_record *dbox_rec;
        const void *data;
-       bool expunged;
 
        mail_index_lookup_ext(mail->transaction->view, mail->seq,
-                             mbox->ext_id, &data, &expunged);
+                             mbox->ext_id, &data, NULL);
        dbox_rec = data;
        if (dbox_rec == NULL || dbox_rec->map_uid == 0) {
                /* lost for some reason, use fallback */
index e3c55e2d5ae88c1a649a0a8ebc5983198615ed5a..b7febd5954a21d5ec0ce18285eeb0f59a85eef96 100644 (file)
@@ -266,10 +266,8 @@ mdbox_map_lookup_seq(struct mdbox_map *map, uint32_t seq,
        const struct mdbox_map_mail_index_record *rec;
        const void *data;
        uint32_t uid;
-       bool expunged;
 
-       mail_index_lookup_ext(map->view, seq, map->map_ext_id,
-                             &data, &expunged);
+       mail_index_lookup_ext(map->view, seq, map->map_ext_id, &data, NULL);
        rec = data;
 
        if (rec == NULL || rec->file_id == 0) {
@@ -322,7 +320,6 @@ int mdbox_map_lookup_full(struct mdbox_map *map, uint32_t map_uid,
        const uint16_t *ref16_p;
        const void *data;
        uint32_t seq;
-       bool expunged;
        int ret;
 
        if (mdbox_map_open_or_create(map) < 0)
@@ -335,8 +332,7 @@ int mdbox_map_lookup_full(struct mdbox_map *map, uint32_t map_uid,
                return -1;
        *rec_r = *rec;
 
-       mail_index_lookup_ext(map->view, seq, map->ref_ext_id,
-                             &data, &expunged);
+       mail_index_lookup_ext(map->view, seq, map->ref_ext_id, &data, NULL);
        if (data == NULL) {
                mdbox_map_set_corrupted(map, "missing ref extension");
                return -1;
@@ -352,19 +348,18 @@ int mdbox_map_view_lookup_rec(struct mdbox_map *map,
 {
        const uint16_t *ref16_p;
        const void *data;
-       bool expunged;
 
        memset(rec_r, 0, sizeof(*rec_r));
        mail_index_lookup_uid(view, seq, &rec_r->map_uid);
 
-       mail_index_lookup_ext(view, seq, map->map_ext_id, &data, &expunged);
+       mail_index_lookup_ext(view, seq, map->map_ext_id, &data, NULL);
        if (data == NULL) {
                mdbox_map_set_corrupted(map, "missing map extension");
                return -1;
        }
        memcpy(&rec_r->rec, data, sizeof(rec_r->rec));
 
-       mail_index_lookup_ext(view, seq, map->ref_ext_id, &data, &expunged);
+       mail_index_lookup_ext(view, seq, map->ref_ext_id, &data, NULL);
        if (data == NULL) {
                mdbox_map_set_corrupted(map, "missing ref extension");
                return -1;
@@ -605,7 +600,6 @@ int mdbox_map_update_refcount(struct mdbox_map_transaction_context *ctx,
        struct mdbox_map *map = ctx->atomic->map;
        const void *data;
        uint32_t seq;
-       bool expunged;
        int old_diff, new_diff;
 
        if (unlikely(ctx->trans == NULL))
@@ -624,8 +618,7 @@ int mdbox_map_update_refcount(struct mdbox_map_transaction_context *ctx,
                }
                return -1;
        }
-       mail_index_lookup_ext(map->view, seq, map->ref_ext_id,
-                             &data, &expunged);
+       mail_index_lookup_ext(map->view, seq, map->ref_ext_id, &data, NULL);
        old_diff = data == NULL ? 0 : *((const uint16_t *)data);
        ctx->changed = TRUE;
        new_diff = mail_index_atomic_inc_ext(ctx->trans, seq,
@@ -672,7 +665,6 @@ int mdbox_map_remove_file_id(struct mdbox_map *map, uint32_t file_id)
        const struct mail_index_header *hdr;
        const struct mdbox_map_mail_index_record *rec;
        const void *data;
-       bool expunged;
        uint32_t seq;
        int ret = 0;
 
@@ -686,7 +678,7 @@ int mdbox_map_remove_file_id(struct mdbox_map *map, uint32_t file_id)
        hdr = mail_index_get_header(map->view);
        for (seq = 1; seq <= hdr->messages_count; seq++) {
                mail_index_lookup_ext(map->view, seq, map->map_ext_id,
-                                     &data, &expunged);
+                                     &data, NULL);
                if (data == NULL) {
                        mdbox_map_set_corrupted(map, "missing map extension");
                        ret = -1;
index 2193c8acecdc37c3e256c58ba9a8f39e0e66ede5..06e31e1c92ebcabe8100f151664d4068e11e9249 100644 (file)
@@ -51,11 +51,9 @@ mdbox_copy_file_get_file(struct mailbox_transaction_context *t,
                (struct mdbox_save_context *)t->save_ctx;
        const struct mdbox_mail_index_record *rec;
        const void *data;
-       bool expunged;
        uint32_t file_id;
 
-       mail_index_lookup_ext(t->view, seq, ctx->mbox->ext_id,
-                             &data, &expunged);
+       mail_index_lookup_ext(t->view, seq, ctx->mbox->ext_id, &data, NULL);
        rec = data;
 
        if (mdbox_map_lookup(ctx->mbox->storage->map, rec->map_uid,
@@ -251,7 +249,6 @@ mdbox_save_set_map_uids(struct mdbox_save_context *ctx,
        const struct dbox_save_mail *mails;
        unsigned int i, count;
        const void *data;
-       bool expunged;
        uint32_t next_map_uid = first_map_uid;
 
        mdbox_update_header(mbox, ctx->ctx.trans, NULL);
@@ -261,7 +258,7 @@ mdbox_save_set_map_uids(struct mdbox_save_context *ctx,
        mails = array_get(&ctx->mails, &count);
        for (i = 0; i < count; i++) {
                mail_index_lookup_ext(view, mails[i].seq, mbox->ext_id,
-                                     &data, &expunged);
+                                     &data, NULL);
                old_rec = data;
                if (old_rec != NULL && old_rec->map_uid != 0) {
                        /* message was copied. keep the existing map uid */
@@ -413,7 +410,6 @@ int mdbox_copy(struct mail_save_context *_ctx, struct mail *mail)
        struct mdbox_mail_index_record rec;
        const void *guid_data;
        guid_128_t wanted_guid;
-       bool expunged;
 
        ctx->ctx.finished = TRUE;
 
@@ -431,7 +427,7 @@ int mdbox_copy(struct mail_save_context *_ctx, struct mail *mail)
        }
 
        mail_index_lookup_ext(mail->transaction->view, mail->seq,
-                             src_mbox->guid_ext_id, &guid_data, &expunged);
+                             src_mbox->guid_ext_id, &guid_data, NULL);
        if (guid_data == NULL || guid_128_is_empty(guid_data)) {
                /* missing GUID, something's broken. don't copy using
                   refcounting. */
index df2adefd60070b62cbe28720e0dd657ccb278fa8..33b87c524ce186f53dbaa8ec2c45f1bd25326555 100644 (file)
@@ -400,7 +400,6 @@ rebuild_mailbox_multi(struct mdbox_storage_rebuild_context *ctx,
        struct mdbox_rebuild_msg *rec;
        const void *data;
        const uint8_t *guid_p;
-       bool expunged;
        uint32_t old_seq, new_seq, uid, map_uid;
 
        /* Rebuild the mailbox's index. Note that index is reset at this point,
@@ -409,7 +408,7 @@ rebuild_mailbox_multi(struct mdbox_storage_rebuild_context *ctx,
        hdr = mail_index_get_header(view);
        for (old_seq = 1; old_seq <= hdr->messages_count; old_seq++) {
                mail_index_lookup_ext(view, old_seq, mbox->ext_id,
-                                     &data, &expunged);
+                                     &data, NULL);
                if (data == NULL) {
                        memset(&new_dbox_rec, 0, sizeof(new_dbox_rec));
                        map_uid = 0;
@@ -419,7 +418,7 @@ rebuild_mailbox_multi(struct mdbox_storage_rebuild_context *ctx,
                }
 
                mail_index_lookup_ext(view, old_seq, mbox->guid_ext_id,
-                                     &data, &expunged);
+                                     &data, NULL);
                guid_p = data;
 
                /* see if we can find this message based on
@@ -764,7 +763,6 @@ static void rebuild_update_refcounts(struct mdbox_storage_rebuild_context *ctx)
        const void *data;
        struct mdbox_rebuild_msg **msgs;
        const uint16_t *ref16_p;
-       bool expunged;
        uint32_t seq, map_uid;
        unsigned int i, count;
 
@@ -781,7 +779,7 @@ static void rebuild_update_refcounts(struct mdbox_storage_rebuild_context *ctx)
 
                mail_index_lookup_ext(ctx->atomic->sync_view, seq,
                                      ctx->storage->map->ref_ext_id,
-                                     &data, &expunged);
+                                     &data, NULL);
                ref16_p = data;
                if (ref16_p == NULL || *ref16_p != msgs[i]->refcount) {
                        mail_index_update_ext(ctx->atomic->sync_trans, seq,
index 5a2cfff5ab7d498690e0d1cfd65ac17b937c73c0..f6256a3d8768cbb62dd026398ebc21dbc32aa670 100644 (file)
@@ -30,11 +30,10 @@ dbox_sync_verify_expunge_guid(struct mdbox_sync_context *ctx, uint32_t seq,
 {
        const void *data;
        uint32_t uid;
-       bool expunged;
 
        mail_index_lookup_uid(ctx->sync_view, seq, &uid);
        mail_index_lookup_ext(ctx->sync_view, seq,
-                             ctx->mbox->guid_ext_id, &data, &expunged);
+                             ctx->mbox->guid_ext_id, &data, NULL);
        if (guid_128_is_empty(guid_128) ||
            memcmp(data, guid_128, GUID_128_SIZE) == 0)
                return 0;
@@ -100,7 +99,6 @@ static int dbox_sync_mark_expunges(struct mdbox_sync_context *ctx)
        unsigned int n;
        const void *data;
        uint32_t seq, uid;
-       bool expunged;
 
        /* use a separate transaction here so that we can commit the changes
           during map transaction */
@@ -109,7 +107,7 @@ static int dbox_sync_mark_expunges(struct mdbox_sync_context *ctx)
        while (seq_range_array_iter_nth(&iter, n++, &seq)) {
                mail_index_lookup_uid(ctx->sync_view, seq, &uid);
                mail_index_lookup_ext(ctx->sync_view, seq,
-                                     ctx->mbox->guid_ext_id, &data, &expunged);
+                                     ctx->mbox->guid_ext_id, &data, NULL);
                mail_index_expunge_guid(trans, seq, data);
        }
        if (mail_index_transaction_commit(&trans) < 0)
index 8f50b62ba24220de7443cfd94e39a46ca40e4074..15063d9e536d7cf71b95dbd6b469e4752fd6b707 100644 (file)
@@ -156,7 +156,6 @@ mbox_mail_get_md5_header(struct index_mail *mail, const char **value_r)
                { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
        struct mbox_mailbox *mbox = (struct mbox_mailbox *)mail->mail.mail.box;
        const void *ext_data;
-       bool expunged;
 
        if (mail->data.guid != NULL) {
                *value_r = mail->data.guid;
@@ -165,7 +164,7 @@ mbox_mail_get_md5_header(struct index_mail *mail, const char **value_r)
 
        mail_index_lookup_ext(mail->mail.mail.transaction->view,
                              mail->mail.mail.seq, mbox->md5hdr_ext_idx,
-                             &ext_data, &expunged);
+                             &ext_data, NULL);
        if (ext_data != NULL && memcmp(ext_data, empty_md5, 16) != 0) {
                mail->data.guid = p_strdup(mail->mail.data_pool,
                                           binary_to_hex(ext_data, 16));
index bdfeebbe212d3e45f8e27a0b02da7df43fa1ed11..feb48a79dbd0cf948760c5bf873915fd33ae9b4a 100644 (file)
@@ -244,7 +244,6 @@ static void mbox_sync_find_index_md5(struct mbox_sync_context *sync_ctx,
         const struct mail_index_record *rec = NULL;
        uint32_t messages_count;
        const void *data;
-       bool expunged;
 
        if (sync_ctx->index_reset) {
                *rec_r = NULL;
@@ -258,7 +257,7 @@ static void mbox_sync_find_index_md5(struct mbox_sync_context *sync_ctx,
                mail_index_lookup_ext(sync_ctx->sync_view,
                                      sync_ctx->idx_seq,
                                      sync_ctx->mbox->md5hdr_ext_idx,
-                                     &data, &expunged);
+                                     &data, NULL);
                if (data != NULL && memcmp(data, hdr_md5_sum, 16) == 0)
                        break;
 
@@ -278,13 +277,12 @@ mbox_sync_update_from_offset(struct mbox_sync_context *sync_ctx,
 {
        const void *data;
        uint64_t offset;
-       bool expunged;
 
        if (!nocheck) {
                /* see if from_offset needs updating */
                mail_index_lookup_ext(sync_ctx->sync_view, sync_ctx->idx_seq,
                                      sync_ctx->mbox->mbox_ext_idx,
-                                     &data, &expunged);
+                                     &data, NULL);
                if (data != NULL &&
                    *((const uint64_t *)data) == mail->from_offset)
                        return;
@@ -316,11 +314,9 @@ mbox_sync_update_md5_if_changed(struct mbox_sync_mail_context *mail_ctx)
 {
         struct mbox_sync_context *sync_ctx = mail_ctx->sync_ctx;
        const void *ext_data;
-       bool expunged;
 
        mail_index_lookup_ext(sync_ctx->sync_view, sync_ctx->idx_seq,
-                             sync_ctx->mbox->md5hdr_ext_idx,
-                             &ext_data, &expunged);
+                             sync_ctx->mbox->md5hdr_ext_idx, &ext_data, NULL);
        if (ext_data == NULL ||
            memcmp(mail_ctx->hdr_md5_sum, ext_data, 16) != 0) {
                mail_index_update_ext(sync_ctx->t, sync_ctx->idx_seq,
index 9aca4ca26d807c5118880f22a3d28724d1fc406e..23418e144928722ab7423f9ceacdc6f8d8d2e862 100644 (file)
@@ -117,12 +117,11 @@ static void virtual_mail_set_seq(struct mail *mail, uint32_t seq, bool saving)
        struct virtual_backend_box *bbox;
        const struct virtual_mail_index_record *vrec;
        const void *data;
-       bool expunged;
 
        i_assert(!saving);
 
        mail_index_lookup_ext(mail->transaction->view, seq,
-                             mbox->virtual_ext_id, &data, &expunged);
+                             mbox->virtual_ext_id, &data, NULL);
        vrec = data;
 
        bbox = virtual_backend_box_lookup(mbox, vrec->mailbox_id);
index 0221df26c15f4da5d2ed41da657aa68b424e0508..767a3aed6cd1c99f72fd1ce7ae123c7f3bb19d0c 100644 (file)
@@ -70,7 +70,6 @@ static void virtual_search_get_records(struct mail_search_context *ctx,
        const struct virtual_mail_index_record *vrec;
        struct virtual_search_record srec;
        const void *data;
-       bool expunged;
        int result;
 
        memset(&srec, 0, sizeof(srec));
@@ -84,7 +83,7 @@ static void virtual_search_get_records(struct mail_search_context *ctx,
                        /* possible match, save and check later */
                        mail_index_lookup_ext(mbox->box.view, ctx->seq,
                                              mbox->virtual_ext_id,
-                                             &data, &expunged);
+                                             &data, NULL);
                        vrec = data;
 
                        srec.mailbox_id = vrec->mailbox_id;
index e579f387597f350aee6c8c20ad2fe43442139614..63c6629b49152046937f123bc58f215aa697f602 100644 (file)
@@ -343,7 +343,6 @@ static void virtual_sync_index_rec(struct virtual_sync_context *ctx,
        enum modify_type modify_type;
        const char *kw_names[2];
        uint32_t vseq, seq1, seq2;
-       bool expunged;
 
        switch (sync_rec->type) {
        case MAIL_INDEX_SYNC_TYPE_EXPUNGE:
@@ -361,7 +360,7 @@ static void virtual_sync_index_rec(struct virtual_sync_context *ctx,
 
        for (vseq = seq1; vseq <= seq2; vseq++) {
                mail_index_lookup_ext(ctx->sync_view, vseq, virtual_ext_id,
-                                     &data, &expunged);
+                                     &data, NULL);
                vrec = data;
 
                bbox = virtual_backend_box_lookup(ctx->mbox, vrec->mailbox_id);
@@ -633,7 +632,6 @@ virtual_sync_backend_handle_old_vmsgs(struct virtual_sync_context *ctx,
        struct virtual_backend_uidmap uidmap;
        const void *data;
        uint32_t seq, vseq, vuid, messages;
-       bool expunged;
 
        /* add the currently existing UIDs to uidmap. remember the messages
           that were already expunged */
@@ -644,8 +642,7 @@ virtual_sync_backend_handle_old_vmsgs(struct virtual_sync_context *ctx,
        for (vseq = 1; vseq <= messages; vseq++) {
                mail_index_lookup_uid(ctx->sync_view, vseq, &vuid);
                mail_index_lookup_ext(ctx->sync_view, vseq,
-                                     ctx->mbox->virtual_ext_id,
-                                     &data, &expunged);
+                                     ctx->mbox->virtual_ext_id, &data, NULL);
                vrec = data;
                if (vrec->mailbox_id == bbox->mailbox_id) {
                        uidmap.real_uid = vrec->real_uid;
@@ -1070,7 +1067,6 @@ static void virtual_sync_backend_map_uids(struct virtual_sync_context *ctx)
        struct virtual_add_record add_rec;
        const struct virtual_mail_index_record *vrec;
        const void *data;
-       bool expunged;
        uint32_t i, vseq, vuid, messages;
        unsigned int j = 0, uidmap_count = 0;
 
@@ -1083,7 +1079,7 @@ static void virtual_sync_backend_map_uids(struct virtual_sync_context *ctx)
        vmails = i_new(struct virtual_sync_mail, messages);
        for (vseq = 1; vseq <= messages; vseq++) {
                mail_index_lookup_ext(ctx->sync_view, vseq, virtual_ext_id,
-                                     &data, &expunged);
+                                     &data, NULL);
                vrec = data;
                vmails[vseq-1].vseq = vseq;
                vmails[vseq-1].vrec = *vrec;
@@ -1293,7 +1289,6 @@ virtual_sync_apply_existing_appends(struct virtual_sync_context *ctx)
        const struct virtual_mail_index_record *vrec;
        struct virtual_backend_uidmap uidmap;
        const void *data;
-       bool expunged;
        uint32_t seq, seq2;
 
        if (!ctx->mbox->uids_mapped)
@@ -1313,7 +1308,7 @@ virtual_sync_apply_existing_appends(struct virtual_sync_context *ctx)
        memset(&uidmap, 0, sizeof(uidmap));
        for (; seq <= seq2; seq++) {
                mail_index_lookup_ext(ctx->sync_view, seq, virtual_ext_id,
-                                     &data, &expunged);
+                                     &data, NULL);
                vrec = data;
                uidmap.real_uid = vrec->real_uid;
                mail_index_lookup_uid(ctx->sync_view, seq, &uidmap.virtual_uid);
@@ -1347,7 +1342,6 @@ virtual_sync_apply_existing_expunges(struct virtual_mailbox *mbox,
        struct seq_range_iter iter;
        const struct virtual_mail_index_record *vrec;
        const void *data;
-       bool expunged;
        unsigned int n = 0;
        uint32_t seq;
 
@@ -1357,7 +1351,7 @@ virtual_sync_apply_existing_expunges(struct virtual_mailbox *mbox,
        seq_range_array_iter_init(&iter, isync_ctx->expunges);
        while (seq_range_array_iter_nth(&iter, n++, &seq)) {
                mail_index_lookup_ext(mbox->box.view, seq,
-                                     mbox->virtual_ext_id, &data, &expunged);
+                                     mbox->virtual_ext_id, &data, NULL);
                vrec = data;
 
                if (bbox == NULL || bbox->mailbox_id != vrec->mailbox_id) {