dovecot: Don't flush attribute cache twice after locking transac...

dovecot at dovecot.org dovecot at dovecot.org
Thu Nov 15 14:18:12 EET 2007


details:   http://hg.dovecot.org/dovecot/rev/937faba78a68
changeset: 6808:937faba78a68
user:      Timo Sirainen <tss at iki.fi>
date:      Thu Nov 15 14:18:03 2007 +0200
description:
Don't flush attribute cache twice after locking transaction log.

diffstat:

2 files changed, 14 insertions(+), 17 deletions(-)
src/lib-index/mail-transaction-log-file.c |   10 ++++++----
src/lib-index/mail-transaction-log.c      |   21 ++++++++-------------

diffs (52 lines):

diff -r 5382964fc01d -r 937faba78a68 src/lib-index/mail-transaction-log-file.c
--- a/src/lib-index/mail-transaction-log-file.c	Thu Nov 15 13:32:10 2007 +0200
+++ b/src/lib-index/mail-transaction-log-file.c	Thu Nov 15 14:18:03 2007 +0200
@@ -914,11 +914,13 @@ mail_transaction_log_file_read(struct ma
 
 	i_assert(file->mmap_base == NULL);
 
-	if (file->log->index->nfs_flush && (file->locked || nfs_flush)) {
-		/* Make sure we know the latest file size */
+	/* NFS: if file isn't locked, we're optimistic that we can read enough
+	   data without flushing attribute cache. if after reading we notice
+	   that we really should have read more, flush the cache and try again.
+	   if file is locked, the attribute cache was already flushed when
+	   refreshing the log. */
+	if (file->log->index->nfs_flush && nfs_flush)
 		nfs_flush_attr_cache_fd(file->filepath, file->fd);
-		nfs_flush = TRUE;
-	}
 
 	if (file->buffer != NULL && file->buffer_offset > start_offset) {
 		/* we have to insert missing data to beginning of buffer */
diff -r 5382964fc01d -r 937faba78a68 src/lib-index/mail-transaction-log.c
--- a/src/lib-index/mail-transaction-log.c	Thu Nov 15 13:32:10 2007 +0200
+++ b/src/lib-index/mail-transaction-log.c	Thu Nov 15 14:18:03 2007 +0200
@@ -297,19 +297,14 @@ mail_transaction_log_refresh(struct mail
 		file->refcount--;
 		log->index->need_recreate = TRUE;
 		return 0;
-	} else {
-		if (log->head->st_ino == st.st_ino &&
-		    CMP_DEV_T(log->head->st_dev, st.st_dev)) {
-			/* same file? */
-			if (!log->head->locked) {
-				/* we don't care that much, it most likely is */
-				return 0;
-			}
-			if (nfs_flush_attr_cache_fd(log->head->filepath,
-						    log->head->fd))
-				return 0;
-			/* nope */
-		}
+	} else if (log->head->st_ino == st.st_ino &&
+		   CMP_DEV_T(log->head->st_dev, st.st_dev)) {
+		/* NFS: log files get rotated to .log.2 files instead
+		   of being unlinked, so we don't bother checking if
+		   the existing file has already been unlinked here
+		   (in which case inodes could match but point to
+		   different files) */
+		return 0;
 	}
 
 	file = mail_transaction_log_file_alloc(log, path);


More information about the dovecot-cvs mailing list