[dovecot-cvs] dovecot/src/lib-storage/index index-status.c, 1.37, 1.38 index-storage.c, 1.91, 1.92 index-storage.h, 1.106, 1.107 index-sync.c, 1.58, 1.59

tss at dovecot.org tss at dovecot.org
Sat Nov 25 22:17:44 UTC 2006


Update of /var/lib/cvs/dovecot/src/lib-storage/index
In directory talvi:/tmp/cvs-serv28938/lib-storage/index

Modified Files:
	index-status.c index-storage.c index-storage.h index-sync.c 
Log Message:
Mailbox list indexing and related changes. Currently works only with
maildir and mmap_disable=no. This allows doing STATUS to synced mailboxes
without opening their index files at all.



Index: index-status.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-status.c,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- index-status.c	12 Jul 2005 13:40:11 -0000	1.37
+++ index-status.c	25 Nov 2006 22:17:41 -0000	1.38
@@ -40,6 +40,11 @@
 	struct index_mailbox *ibox = (struct index_mailbox *)box;
 	int ret;
 
+	if (!box->opened) {
+		if (index_storage_mailbox_open(ibox) < 0)
+			return -1;
+	}
+
 	ret = index_storage_get_status_locked(ibox, items, status);
 	mail_index_view_unlock(ibox->view);
 	return ret;

Index: index-storage.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-storage.c,v
retrieving revision 1.91
retrieving revision 1.92
diff -u -d -r1.91 -r1.92
--- index-storage.c	16 Nov 2006 00:16:33 -0000	1.91
+++ index-storage.c	25 Nov 2006 22:17:41 -0000	1.92
@@ -314,24 +314,16 @@
 	ibox->last_notify_type = MAILBOX_LOCK_NOTIFY_NONE;
 }
 
-int index_storage_mailbox_init(struct index_mailbox *ibox,
-			       struct mail_index *index, const char *name,
-			       enum mailbox_open_flags flags,
-			       bool move_to_memory)
+int index_storage_mailbox_open(struct index_mailbox *ibox)
 {
 	struct mail_storage *storage = &ibox->storage->storage;
 	enum mail_index_open_flags index_flags;
 	enum mail_index_lock_method lock_method = 0;
 	int ret;
 
-	i_assert(name != NULL);
-
-	ibox->box.storage = storage;
-	ibox->box.name = p_strdup(ibox->box.pool, name);
-	array_create(&ibox->box.module_contexts,
-		     ibox->box.pool, sizeof(void *), 5);
+	i_assert(!ibox->box.opened);
 
-	index_flags = move_to_memory ? 0 : MAIL_INDEX_OPEN_FLAG_CREATE;
+	index_flags = ibox->move_to_memory ? 0 : MAIL_INDEX_OPEN_FLAG_CREATE;
 	if ((storage->flags & MAIL_STORAGE_FLAG_MMAP_DISABLE) != 0)
 		index_flags |= MAIL_INDEX_OPEN_FLAG_MMAP_DISABLE;
 #ifndef MMAP_CONFLICTS_WRITE
@@ -351,23 +343,13 @@
 		break;
 	}
 
-	ibox->open_flags = flags;
-	ibox->readonly = (flags & MAILBOX_OPEN_READONLY) != 0;
-	ibox->keep_recent = (flags & MAILBOX_OPEN_KEEP_RECENT) != 0;
-	ibox->keep_locked = (flags & MAILBOX_OPEN_KEEP_LOCKED) != 0;
-	ibox->index = index;
-
-	ibox->next_lock_notify = time(NULL) + LOCK_NOTIFY_INTERVAL;
-	ibox->commit_log_file_seq = 0;
-	ibox->mail_read_mmaped = (storage->flags &
-				  MAIL_STORAGE_FLAG_MMAP_MAILS) != 0;
-
-	ret = mail_index_open(index, index_flags, lock_method);
-	if (ret <= 0 || move_to_memory) {
-		if (mail_index_move_to_memory(index) < 0) {
+	ret = mail_index_open(ibox->index, index_flags, lock_method);
+	if (ret <= 0 || ibox->move_to_memory) {
+		if (mail_index_move_to_memory(ibox->index) < 0) {
 			/* try opening once more. it should be created
 			   directly into memory now. */
-			ret = mail_index_open(index, index_flags, lock_method);
+			ret = mail_index_open(ibox->index, index_flags,
+					      lock_method);
 			if (ret <= 0) {
 				mail_storage_set_index_error(ibox);
 				index_storage_mailbox_free(&ibox->box);
@@ -376,17 +358,49 @@
 		}
 	}
 
+	ibox->cache = mail_index_get_cache(ibox->index);
+	index_cache_register_defaults(ibox);
+	ibox->view = mail_index_view_open(ibox->index);
+	ibox->keyword_names = mail_index_get_keywords(ibox->index);
+
+	ibox->box.opened = TRUE;
+	return 0;
+}
+
+int index_storage_mailbox_init(struct index_mailbox *ibox,
+			       struct mail_index *index, const char *name,
+			       enum mailbox_open_flags flags,
+			       bool move_to_memory)
+{
+	struct mail_storage *storage = &ibox->storage->storage;
+
+	i_assert(name != NULL);
+
+	ibox->box.storage = storage;
+	ibox->box.name = p_strdup(ibox->box.pool, name);
+	array_create(&ibox->box.module_contexts,
+		     ibox->box.pool, sizeof(void *), 5);
+
+	ibox->open_flags = flags;
+	ibox->readonly = (flags & MAILBOX_OPEN_READONLY) != 0;
+	ibox->keep_recent = (flags & MAILBOX_OPEN_KEEP_RECENT) != 0;
+	ibox->keep_locked = (flags & MAILBOX_OPEN_KEEP_LOCKED) != 0;
+	ibox->move_to_memory = move_to_memory;
+	ibox->index = index;
+
+	ibox->next_lock_notify = time(NULL) + LOCK_NOTIFY_INTERVAL;
+	ibox->commit_log_file_seq = 0;
+	ibox->mail_read_mmaped =
+		(storage->flags & MAIL_STORAGE_FLAG_MMAP_MAILS) != 0;
+
 	ibox->md5hdr_ext_idx =
 		mail_index_ext_register(index, "header-md5", 0, 16, 1);
 
-	ibox->cache = mail_index_get_cache(index);
-	index_cache_register_defaults(ibox);
-	ibox->view = mail_index_view_open(index);
-	ibox->keyword_names = mail_index_get_keywords(index);
-
 	array_idx_set(&index->mail_index_module_contexts,
 		      mail_storage_mail_index_module_id, &ibox);
-	return 0;
+
+	return (flags & MAILBOX_OPEN_FAST) != 0 ? 0 :
+		index_storage_mailbox_open(ibox);
 }
 
 void index_storage_mailbox_free(struct mailbox *box)

Index: index-storage.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-storage.h,v
retrieving revision 1.106
retrieving revision 1.107
diff -u -d -r1.106 -r1.107
--- index-storage.h	16 Nov 2006 00:16:33 -0000	1.106
+++ index-storage.h	25 Nov 2006 22:17:41 -0000	1.107
@@ -76,6 +76,7 @@
 	unsigned int sent_readonly_flags_warning:1;
 	unsigned int notify_pending:1;
 	unsigned int mail_read_mmaped:1;
+	unsigned int move_to_memory:1;
 };
 
 struct index_transaction_context {
@@ -117,6 +118,7 @@
 			       struct mail_index *index, const char *name,
 			       enum mailbox_open_flags flags,
 			       bool move_to_memory);
+int index_storage_mailbox_open(struct index_mailbox *ibox);
 void index_storage_mailbox_free(struct mailbox *box);
 
 bool index_storage_is_readonly(struct mailbox *box);
@@ -144,6 +146,7 @@
 int index_mailbox_sync_next(struct mailbox_sync_context *ctx,
 			    struct mailbox_sync_rec *sync_rec_r);
 int index_mailbox_sync_deinit(struct mailbox_sync_context *ctx,
+			      enum mailbox_status_items status_items,
 			      struct mailbox_status *status_r);
 
 int index_storage_sync(struct mailbox *box, enum mailbox_sync_flags flags);

Index: index-sync.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/index-sync.c,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -d -r1.58 -r1.59
--- index-sync.c	15 Oct 2006 17:56:10 -0000	1.58
+++ index-sync.c	25 Nov 2006 22:17:41 -0000	1.59
@@ -294,11 +294,8 @@
 	return ret;
 }
 
-#define SYNC_STATUS_FLAGS \
-	(STATUS_MESSAGES | STATUS_RECENT | STATUS_UIDNEXT | \
-	 STATUS_UIDVALIDITY | STATUS_UNSEEN | STATUS_KEYWORDS)
-
 int index_mailbox_sync_deinit(struct mailbox_sync_context *_ctx,
+			      enum mailbox_status_items status_items,
 			      struct mailbox_status *status_r)
 {
 	struct index_mailbox_sync_context *ctx =
@@ -319,9 +316,9 @@
 		}
 		ibox->synced_recent_count = ibox->recent_flags_count;
 
-		ret = index_storage_get_status_locked(ctx->ibox,
-						      SYNC_STATUS_FLAGS,
-						      status_r);
+		ret = status_items == 0 ? 0 :
+			index_storage_get_status_locked(ctx->ibox, status_items,
+							status_r);
 	}
 
 	mail_index_view_unlock(ctx->ibox->view);



More information about the dovecot-cvs mailing list