[dovecot-cvs] dovecot/src/lib-index mail-cache-compress.c, 1.46, 1.47 mail-cache-transaction.c, 1.54, 1.55 mail-hash.c, 1.27, 1.28 mail-index-lock.c, 1.57, 1.58 mail-index-private.h, 1.77, 1.78 mail-index.c, 1.248, 1.249 mail-index.h, 1.163, 1.164

tss at dovecot.org tss at dovecot.org
Sun Dec 17 16:35:34 UTC 2006


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

Modified Files:
	mail-cache-compress.c mail-cache-transaction.c mail-hash.c 
	mail-index-lock.c mail-index-private.h mail-index.c 
	mail-index.h 
Log Message:
Added fsync_disable setting. Also added missing fsync()ing to dbox when
saving mails.



Index: mail-cache-compress.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-cache-compress.c,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- mail-cache-compress.c	6 Dec 2006 15:08:32 -0000	1.46
+++ mail-cache-compress.c	17 Dec 2006 16:35:32 -0000	1.47
@@ -229,10 +229,12 @@
 
 	o_stream_destroy(&output);
 
-	if (fdatasync(fd) < 0) {
-		mail_cache_set_syscall_error(cache, "fdatasync()");
-		(void)mail_index_transaction_rollback(&t);
-		return -1;
+	if (!cache->index->fsync_disable) {
+		if (fdatasync(fd) < 0) {
+			mail_cache_set_syscall_error(cache, "fdatasync()");
+			(void)mail_index_transaction_rollback(&t);
+			return -1;
+		}
 	}
 
 	return mail_index_transaction_commit(&t, &seq, &offset);

Index: mail-cache-transaction.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-cache-transaction.c,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -d -r1.54 -r1.55
--- mail-cache-transaction.c	15 Oct 2006 15:11:34 -0000	1.54
+++ mail-cache-transaction.c	17 Dec 2006 16:35:32 -0000	1.55
@@ -659,7 +659,7 @@
 		ret = -1;
 	else if (mail_cache_write(cache, data, size, offset) < 0)
 		ret = -1;
-	else if (fdatasync(cache->fd) < 0) {
+	else if (!cache->index->fsync_disable && fdatasync(cache->fd) < 0) {
 		mail_cache_set_syscall_error(cache, "fdatasync()");
 		ret = -1;
 	} else if (mail_cache_header_fields_get_next_offset(cache,

Index: mail-hash.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-hash.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- mail-hash.c	15 Dec 2006 16:55:40 -0000	1.27
+++ mail-hash.c	17 Dec 2006 16:35:32 -0000	1.28
@@ -310,9 +310,11 @@
 		}
 	}
 
-	if (fdatasync(hash->fd) < 0) {
-		mail_hash_set_syscall_error(hash, "fdatasync()");
-		return -1;
+	if (!hash->index->fsync_disable) {
+		if (fdatasync(hash->fd) < 0) {
+			mail_hash_set_syscall_error(hash, "fdatasync()");
+			return -1;
+		}
 	}
 
 	/* now that the file is guaranteed to be updated, reset the

Index: mail-index-lock.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-lock.c,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -d -r1.57 -r1.58
--- mail-index-lock.c	10 Dec 2006 12:59:15 -0000	1.57
+++ mail-index-lock.c	17 Dec 2006 16:35:32 -0000	1.58
@@ -272,10 +272,13 @@
 
 static int mail_index_copy_lock_finish(struct mail_index *index)
 {
-	if (fsync(index->fd) < 0) {
-		mail_index_file_set_syscall_error(index, index->copy_lock_path,
-						  "fsync()");
-		return -1;
+	if (!index->fsync_disable) {
+		if (fsync(index->fd) < 0) {
+			mail_index_file_set_syscall_error(index,
+							  index->copy_lock_path,
+							  "fsync()");
+			return -1;
+		}
 	}
 
 	if (rename(index->copy_lock_path, index->filepath) < 0) {

Index: mail-index-private.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index-private.h,v
retrieving revision 1.77
retrieving revision 1.78
diff -u -d -r1.77 -r1.78
--- mail-index-private.h	15 Dec 2006 18:10:55 -0000	1.77
+++ mail-index-private.h	17 Dec 2006 16:35:32 -0000	1.78
@@ -181,6 +181,7 @@
 	unsigned int opened:1;
 	unsigned int log_locked:1;
 	unsigned int mmap_disable:1;
+	unsigned int fsync_disable:1;
 	unsigned int mmap_no_write: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.248
retrieving revision 1.249
diff -u -d -r1.248 -r1.249
--- mail-index.c	15 Dec 2006 18:10:56 -0000	1.248
+++ mail-index.c	17 Dec 2006 16:35:32 -0000	1.249
@@ -1569,6 +1569,8 @@
 			(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->lock_method = lock_method;
 
 		/* don't even bother to handle dotlocking without mmap being

Index: mail-index.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-index/mail-index.h,v
retrieving revision 1.163
retrieving revision 1.164
diff -u -d -r1.163 -r1.164
--- mail-index.h	6 Dec 2006 15:08:32 -0000	1.163
+++ mail-index.h	17 Dec 2006 16:35:32 -0000	1.164
@@ -19,7 +19,9 @@
 	/* 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
+	MAIL_INDEX_OPEN_FLAG_MMAP_NO_WRITE	= 0x08,
+	/* Don't fsync() or fdatasync() */
+	MAIL_INDEX_OPEN_FLAG_FSYNC_DISABLE	= 0x10
 };
 
 enum mail_index_header_compat_flags {



More information about the dovecot-cvs mailing list