[dovecot-cvs] dovecot/src/lib-index mail-index-data.c,1.44,1.45 mail-index.c,1.90,1.91 mail-index.h,1.81,1.82 mail-modifylog.c,1.48,1.49 mail-tree.c,1.19,1.20

cras at procontrol.fi cras at procontrol.fi
Tue Jul 15 22:26:45 EEST 2003


Update of /home/cvs/dovecot/src/lib-index
In directory danu:/tmp/cvs-serv10641/src/lib-index

Modified Files:
	mail-index-data.c mail-index.c mail-index.h mail-modifylog.c 
	mail-tree.c 
Log Message:
index_mmap_invalidate = yes now invalidate memory maps before accessing
them. Setting this on should fix some problems with OpenBSD. It should also
make it possible to use index files over NFS as long as lock daemon is used.
It might be such a good idea however.



Index: mail-index-data.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index-data.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- mail-index-data.c	29 May 2003 21:37:53 -0000	1.44
+++ mail-index-data.c	15 Jul 2003 18:26:42 -0000	1.45
@@ -133,6 +133,12 @@
 {
 	struct mail_index_data_header *hdr;
 
+	if (data->index->mmap_invalidate && data->mmap_base != NULL) {
+		if (msync(data->mmap_base, data->mmap_used_length,
+			  MS_SYNC | MS_INVALIDATE) < 0)
+			return index_data_set_syscall_error(data, "msync()");
+	}
+
 	if (data->header != NULL &&
 	    data->header->indexid != data->index->indexid) {
 		if (data->header->indexid != 0) {

Index: mail-index.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index.c,v
retrieving revision 1.90
retrieving revision 1.91
diff -u -d -r1.90 -r1.91
--- mail-index.c	18 May 2003 12:23:03 -0000	1.90
+++ mail-index.c	15 Jul 2003 18:26:42 -0000	1.91
@@ -89,6 +89,15 @@
 	if (index->mmap_base != NULL) {
 		index->header = (struct mail_index_header *) index->mmap_base;
 
+		if (index->mmap_invalidate) {
+			if (msync(index->mmap_base,
+				  index->mmap_used_length,
+				  MS_SYNC | MS_INVALIDATE) < 0) {
+				index_set_syscall_error(index, "msync()");
+				return FALSE;
+			}
+		}
+
 		/* make sure file size hasn't changed */
 		if (index->header->sync_id == index->sync_id) {
 			index->mmap_used_length = index->header->used_file_size;
@@ -99,9 +108,13 @@
 			return TRUE;
 		}
 
-		if (msync(index->mmap_base,
-			  index->mmap_used_length, MS_SYNC) < 0)
-			return index_set_syscall_error(index, "msync()");
+		if (!index->mmap_invalidate) {
+			if (msync(index->mmap_base,
+				  index->mmap_used_length, MS_SYNC) < 0) {
+				index_set_syscall_error(index, "msync()");
+				return FALSE;
+			}
+		}
 
 		if (munmap(index->mmap_base, index->mmap_full_length) < 0)
 			return index_set_syscall_error(index, "munmap()");

Index: mail-index.h
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index.h,v
retrieving revision 1.81
retrieving revision 1.82
diff -u -d -r1.81 -r1.82
--- mail-index.h	15 Jun 2003 03:42:28 -0000	1.81
+++ mail-index.h	15 Jul 2003 18:26:42 -0000	1.82
@@ -16,9 +16,11 @@
 	MAIL_INDEX_OPEN_FLAG_UPDATE_RECENT	= 0x02,
 	/* Compressing and cache updates are not performed */
 	MAIL_INDEX_OPEN_FLAG_FAST		= 0x04,
+	/* Invalidate memory maps before accessing them */
+	MAIL_INDEX_OPEN_FLAG_MMAP_INVALIDATE	= 0x08,
 
 	/* internal: we're creating the index */
-	_MAIL_INDEX_OPEN_FLAG_CREATING		= 0x10
+	_MAIL_INDEX_OPEN_FLAG_CREATING		= 0x100
 };
 
 enum mail_index_header_compat {
@@ -433,6 +435,7 @@
 	enum mail_data_field set_cache_fields;
 
 	unsigned int anon_mmap:1;
+	unsigned int mmap_invalidate:1;
 	unsigned int opened:1;
 	unsigned int rebuilding:1;
 	unsigned int mail_read_mmaped:1;
@@ -460,7 +463,7 @@
 	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
 	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
 	0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \
-	0, 0, 0, 0, 0
+	0, 0, 0, 0, 0, 0
 #endif
 
 /* defaults - same as above but prefixed with mail_index_. */

Index: mail-modifylog.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-modifylog.c,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- mail-modifylog.c	10 Jul 2003 18:10:20 -0000	1.48
+++ mail-modifylog.c	15 Jul 2003 18:26:42 -0000	1.49
@@ -176,6 +176,12 @@
 	struct modify_log_header *hdr;
 	unsigned int extra;
 
+	if (file->log->index->mmap_invalidate && file->mmap_base != NULL) {
+		if (msync(file->mmap_base, file->mmap_used_length,
+			  MS_SYNC | MS_INVALIDATE) < 0)
+			return modifylog_set_syscall_error(file, "msync()");
+	}
+
 	if (!forced && file->header != NULL &&
 	    file->mmap_full_length >= file->header->used_file_size) {
 		file->mmap_used_length = file->header->used_file_size;

Index: mail-tree.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-tree.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- mail-tree.c	23 Apr 2003 17:07:23 -0000	1.19
+++ mail-tree.c	15 Jul 2003 18:26:42 -0000	1.20
@@ -131,6 +131,12 @@
 
 int _mail_tree_mmap_update(struct mail_tree *tree, int forced)
 {
+	if (tree->index->mmap_invalidate && tree->mmap_base != NULL) {
+		if (msync(tree->mmap_base, tree->mmap_used_length,
+			  MS_SYNC | MS_INVALIDATE) < 0)
+			return tree_set_syscall_error(tree, "msync()");
+	}
+
 	debug_mprotect(tree->mmap_base, tree->mmap_full_length,
 		       tree->index);
 



More information about the dovecot-cvs mailing list