dovecot-2.2: mdbox, mbox, virtual: Avoid getting expunged-status...

dovecot at dovecot.org dovecot at dovecot.org
Sat Feb 16 13:51:11 EET 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/e3eaa8303987
changeset: 15776:e3eaa8303987
user:      Timo Sirainen <tss at iki.fi>
date:      Sat Feb 16 13:51:05 2013 +0200
description:
mdbox, mbox, virtual: Avoid getting expunged-status in index lookups when not necessary.
This especially improves dsync performance with mdbox.

diffstat:

 src/lib-storage/index/dbox-multi/mdbox-mail.c            |   6 +---
 src/lib-storage/index/dbox-multi/mdbox-map.c             |  20 ++++-----------
 src/lib-storage/index/dbox-multi/mdbox-save.c            |  10 ++-----
 src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c |   8 ++----
 src/lib-storage/index/dbox-multi/mdbox-sync.c            |   6 +---
 src/lib-storage/index/mbox/mbox-mail.c                   |   3 +-
 src/lib-storage/index/mbox/mbox-sync.c                   |  10 ++-----
 src/plugins/virtual/virtual-mail.c                       |   3 +-
 src/plugins/virtual/virtual-search.c                     |   3 +-
 src/plugins/virtual/virtual-sync.c                       |  16 ++++--------
 10 files changed, 27 insertions(+), 58 deletions(-)

diffs (truncated from 439 to 300 lines):

diff -r f9b1aaf844c8 -r e3eaa8303987 src/lib-storage/index/dbox-multi/mdbox-mail.c
--- a/src/lib-storage/index/dbox-multi/mdbox-mail.c	Sat Feb 16 13:38:10 2013 +0200
+++ b/src/lib-storage/index/dbox-multi/mdbox-mail.c	Sat Feb 16 13:51:05 2013 +0200
@@ -21,9 +21,8 @@
 	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 @@
 		(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 */
diff -r f9b1aaf844c8 -r e3eaa8303987 src/lib-storage/index/dbox-multi/mdbox-map.c
--- a/src/lib-storage/index/dbox-multi/mdbox-map.c	Sat Feb 16 13:38:10 2013 +0200
+++ b/src/lib-storage/index/dbox-multi/mdbox-map.c	Sat Feb 16 13:51:05 2013 +0200
@@ -266,10 +266,8 @@
 	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 @@
 	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 @@
 		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 @@
 {
 	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 @@
 	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 @@
 		}
 		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 @@
 	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 @@
 	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;
diff -r f9b1aaf844c8 -r e3eaa8303987 src/lib-storage/index/dbox-multi/mdbox-save.c
--- a/src/lib-storage/index/dbox-multi/mdbox-save.c	Sat Feb 16 13:38:10 2013 +0200
+++ b/src/lib-storage/index/dbox-multi/mdbox-save.c	Sat Feb 16 13:51:05 2013 +0200
@@ -51,11 +51,9 @@
 		(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 @@
 	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 @@
 	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 @@
 	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 @@
 	}
 
 	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. */
diff -r f9b1aaf844c8 -r e3eaa8303987 src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c
--- a/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c	Sat Feb 16 13:38:10 2013 +0200
+++ b/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c	Sat Feb 16 13:51:05 2013 +0200
@@ -400,7 +400,6 @@
 	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 @@
 	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 @@
 		}
 
 		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 @@
 	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 @@
 
 		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,
diff -r f9b1aaf844c8 -r e3eaa8303987 src/lib-storage/index/dbox-multi/mdbox-sync.c
--- a/src/lib-storage/index/dbox-multi/mdbox-sync.c	Sat Feb 16 13:38:10 2013 +0200
+++ b/src/lib-storage/index/dbox-multi/mdbox-sync.c	Sat Feb 16 13:51:05 2013 +0200
@@ -30,11 +30,10 @@
 {
 	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 @@
 	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 @@
 	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)
diff -r f9b1aaf844c8 -r e3eaa8303987 src/lib-storage/index/mbox/mbox-mail.c
--- a/src/lib-storage/index/mbox/mbox-mail.c	Sat Feb 16 13:38:10 2013 +0200
+++ b/src/lib-storage/index/mbox/mbox-mail.c	Sat Feb 16 13:51:05 2013 +0200
@@ -156,7 +156,6 @@
 		{ 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 @@
 
 	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));
diff -r f9b1aaf844c8 -r e3eaa8303987 src/lib-storage/index/mbox/mbox-sync.c
--- a/src/lib-storage/index/mbox/mbox-sync.c	Sat Feb 16 13:38:10 2013 +0200
+++ b/src/lib-storage/index/mbox/mbox-sync.c	Sat Feb 16 13:51:05 2013 +0200
@@ -244,7 +244,6 @@
         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 @@
 		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 @@
 {
 	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;


More information about the dovecot-cvs mailing list