[dovecot-cvs] dovecot/src/lib-index mail-cache.c, 1.80.2.10, 1.80.2.11 mail-index-private.h, 1.69.2.8, 1.69.2.9 mail-index.c, 1.230.2.30, 1.230.2.31 mail-index.h, 1.158.2.6, 1.158.2.7 mail-transaction-log.c, 1.111.2.19, 1.111.2.20

tss at dovecot.org tss at dovecot.org
Wed May 16 18:22:39 EEST 2007


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

Modified Files:
      Tag: branch_1_0
	mail-cache.c mail-index-private.h mail-index.c mail-index.h 
	mail-transaction-log.c 
Log Message:
Reversed the last change. It wasn't supposed to go to branch_1_0.



Index: mail-cache.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-cache.c,v
retrieving revision 1.80.2.10
retrieving revision 1.80.2.11
diff -u -d -r1.80.2.10 -r1.80.2.11
--- mail-cache.c	16 May 2007 15:14:13 -0000	1.80.2.10
+++ mail-cache.c	16 May 2007 15:22:33 -0000	1.80.2.11
@@ -321,7 +321,7 @@
 	cache->dotlock_settings.stale_timeout = MAIL_CACHE_LOCK_CHANGE_TIMEOUT;
 
 	if (!MAIL_INDEX_IS_IN_MEMORY(index)) {
-		if (index->mmap_disable)
+		if (index->mmap_disable || index->mmap_no_write)
 			cache->file_cache = file_cache_new(-1);
 	}
 

Index: mail-index-private.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-private.h,v
retrieving revision 1.69.2.8
retrieving revision 1.69.2.9
diff -u -d -r1.69.2.8 -r1.69.2.9
--- mail-index-private.h	16 May 2007 15:14:13 -0000	1.69.2.8
+++ mail-index-private.h	16 May 2007 15:22:33 -0000	1.69.2.9
@@ -175,6 +175,7 @@
 	unsigned int log_locked:1;
 	unsigned int mmap_disable:1;
 	unsigned int fsync_disable:1;
+	unsigned int mmap_no_write:1;
 	unsigned int use_excl_dotlocks:1;
 	unsigned int readonly:1;
 	unsigned int fsck:1;

Index: mail-index.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index.c,v
retrieving revision 1.230.2.30
retrieving revision 1.230.2.31
diff -u -d -r1.230.2.30 -r1.230.2.31
--- mail-index.c	16 May 2007 15:14:13 -0000	1.230.2.30
+++ mail-index.c	16 May 2007 15:22:33 -0000	1.230.2.31
@@ -1645,6 +1645,8 @@
 		index->log_locked = FALSE;
 		index->mmap_disable =
 			(flags & MAIL_INDEX_OPEN_FLAG_MMAP_DISABLE) != 0;
+		index->mmap_no_write =
+			(flags & MAIL_INDEX_OPEN_FLAG_MMAP_NO_WRITE) != 0;
 		index->fsync_disable =
 			(flags & MAIL_INDEX_OPEN_FLAG_FSYNC_DISABLE) != 0;
 		index->use_excl_dotlocks =

Index: mail-index.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index.h,v
retrieving revision 1.158.2.6
retrieving revision 1.158.2.7
diff -u -d -r1.158.2.6 -r1.158.2.7
--- mail-index.h	16 May 2007 15:14:13 -0000	1.158.2.6
+++ mail-index.h	16 May 2007 15:22:33 -0000	1.158.2.7
@@ -13,6 +13,10 @@
 	MAIL_INDEX_OPEN_FLAG_CREATE		= 0x01,
 	/* Don't try to mmap() index files */
 	MAIL_INDEX_OPEN_FLAG_MMAP_DISABLE	= 0x04,
+	/* Don't try to write() to mmap()ed index files. Required for the few
+	   OSes that don't have unified buffer cache
+	   (currently OpenBSD <= 3.5) */
+	MAIL_INDEX_OPEN_FLAG_MMAP_NO_WRITE	= 0x08,
 	/* Rely on O_EXCL when creating dotlocks */
 	MAIL_INDEX_OPEN_FLAG_DOTLOCK_USE_EXCL	= 0x10,
 	/* Don't fsync() or fdatasync() */

Index: mail-transaction-log.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-transaction-log.c,v
retrieving revision 1.111.2.19
retrieving revision 1.111.2.20
diff -u -d -r1.111.2.19 -r1.111.2.20
--- mail-transaction-log.c	16 May 2007 15:14:13 -0000	1.111.2.19
+++ mail-transaction-log.c	16 May 2007 15:22:33 -0000	1.111.2.20
@@ -1252,7 +1252,7 @@
 	struct mail_index *index = file->log->index;
 	size_t size;
 	struct stat st;
-	int ret;
+	int ret, use_mmap;
 
 	i_assert(start_offset <= end_offset);
 
@@ -1271,6 +1271,11 @@
 	if (MAIL_TRANSACTION_LOG_FILE_IN_MEMORY(file))
 		return 1;
 
+	/* with mmap_no_write we could alternatively just write to log with
+	   msync() rather than pwrite(). but since there aren't many such OSes
+	   left, it's easier to just use mmap_disable behavior with it */
+	use_mmap = !index->mmap_disable && !index->mmap_no_write;
+
 	if (file->buffer != NULL && file->buffer_offset <= start_offset) {
 		/* see if we already have it */
 		size = buffer_get_used_size(file->buffer);
@@ -1278,7 +1283,7 @@
 			return 1;
 	}
 
-	if (!index->mmap_disable) {
+	if (use_mmap) {
 		if (fstat(file->fd, &st) < 0) {
 			mail_index_file_set_syscall_error(index, file->filepath,
 							  "fstat()");
@@ -1306,7 +1311,7 @@
 	}
 
 	if (file->buffer != NULL &&
-	    (file->mmap_base != NULL || !index->mmap_disable)) {
+	    (file->mmap_base != NULL || use_mmap)) {
 		buffer_free(file->buffer);
 		file->buffer = NULL;
 	}
@@ -1318,7 +1323,7 @@
 		file->mmap_base = NULL;
 	}
 
-	if (index->mmap_disable) {
+	if (!use_mmap) {
 		ret = mail_transaction_log_file_read(file, start_offset);
 		if (ret <= 0) {
 			/* make sure we don't leave ourself in



More information about the dovecot-cvs mailing list