dovecot: Don't flush attribute cache unless we're locked and we ...
dovecot at dovecot.org
dovecot at dovecot.org
Thu Nov 15 00:38:13 EET 2007
details: http://hg.dovecot.org/dovecot/rev/e70686f19f67
changeset: 6798:e70686f19f67
user: Timo Sirainen <tss at iki.fi>
date: Thu Nov 15 00:38:05 2007 +0200
description:
Don't flush attribute cache unless we're locked and we really need to know
the latest changes.
diffstat:
4 files changed, 21 insertions(+), 11 deletions(-)
src/lib-index/mail-transaction-log-file.c | 2 +-
src/lib-index/mail-transaction-log.c | 6 +++++-
src/lib-storage/index/maildir/maildir-keywords.c | 2 +-
src/lib-storage/index/maildir/maildir-uidlist.c | 22 ++++++++++++++--------
diffs (93 lines):
diff -r a59deefc552f -r e70686f19f67 src/lib-index/mail-transaction-log-file.c
--- a/src/lib-index/mail-transaction-log-file.c Wed Nov 14 23:52:33 2007 +0200
+++ b/src/lib-index/mail-transaction-log-file.c Thu Nov 15 00:38:05 2007 +0200
@@ -893,7 +893,7 @@ mail_transaction_log_file_read(struct ma
i_assert(file->mmap_base == NULL);
- if (file->log->index->nfs_flush) {
+ if (file->log->index->nfs_flush && file->locked) {
/* Make sure we know the latest file size */
nfs_flush_attr_cache_fd(file->filepath, file->fd);
}
diff -r a59deefc552f -r e70686f19f67 src/lib-index/mail-transaction-log.c
--- a/src/lib-index/mail-transaction-log.c Wed Nov 14 23:52:33 2007 +0200
+++ b/src/lib-index/mail-transaction-log.c Thu Nov 15 00:38:05 2007 +0200
@@ -278,7 +278,7 @@ static int mail_transaction_log_refresh(
path = t_strconcat(log->index->filepath,
MAIL_TRANSACTION_LOG_SUFFIX, NULL);
- if (log->index->nfs_flush)
+ if (log->index->nfs_flush && log->head->locked)
nfs_flush_attr_cache(path, TRUE);
if (nfs_safe_stat(path, &st) < 0) {
if (errno != ENOENT) {
@@ -300,6 +300,10 @@ static int mail_transaction_log_refresh(
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;
diff -r a59deefc552f -r e70686f19f67 src/lib-storage/index/maildir/maildir-keywords.c
--- a/src/lib-storage/index/maildir/maildir-keywords.c Wed Nov 14 23:52:33 2007 +0200
+++ b/src/lib-storage/index/maildir/maildir-keywords.c Thu Nov 15 00:38:05 2007 +0200
@@ -118,7 +118,7 @@ static int maildir_keywords_sync(struct
errors. */
if ((mk->storage->flags & MAIL_STORAGE_FLAG_NFS_FLUSH_STORAGE) != 0)
- nfs_flush_attr_cache(mk->path, TRUE);
+ nfs_flush_attr_cache(mk->path, FALSE);
if (nfs_safe_stat(mk->path, &st) < 0) {
if (errno == ENOENT) {
diff -r a59deefc552f -r e70686f19f67 src/lib-storage/index/maildir/maildir-uidlist.c
--- a/src/lib-storage/index/maildir/maildir-uidlist.c Wed Nov 14 23:52:33 2007 +0200
+++ b/src/lib-storage/index/maildir/maildir-uidlist.c Thu Nov 15 00:38:05 2007 +0200
@@ -630,7 +630,9 @@ maildir_uidlist_has_changed(struct maild
*recreated_r = FALSE;
- if ((storage->flags & MAIL_STORAGE_FLAG_NFS_FLUSH_STORAGE) != 0)
+ /* don't bother flushing attribute caches unless uidlist is locked */
+ if ((storage->flags & MAIL_STORAGE_FLAG_NFS_FLUSH_STORAGE) != 0 &&
+ UIDLIST_IS_LOCKED(uidlist))
nfs_flush_attr_cache(uidlist->path, TRUE);
if (nfs_safe_stat(uidlist->path, &st) < 0) {
@@ -649,12 +651,15 @@ maildir_uidlist_has_changed(struct maild
return 1;
}
- /* either the file hasn't been changed, or it has already been deleted
- and the inodes just happen to be the same. check if the fd is still
- valid. */
- if (!nfs_flush_attr_cache_fd(uidlist->path, uidlist->fd)) {
- *recreated_r = TRUE;
- return 1;
+ if ((storage->flags & MAIL_STORAGE_FLAG_NFS_FLUSH_STORAGE) != 0 &&
+ UIDLIST_IS_LOCKED(uidlist)) {
+ /* NFS: either the file hasn't been changed, or it has already
+ been deleted and the inodes just happen to be the same.
+ check if the fd is still valid. */
+ if (!nfs_flush_attr_cache_fd(uidlist->path, uidlist->fd)) {
+ *recreated_r = TRUE;
+ return 1;
+ }
}
if (st.st_size != uidlist->fd_size) {
@@ -681,7 +686,8 @@ int maildir_uidlist_refresh(struct maild
if (recreated)
maildir_uidlist_close(uidlist);
} else {
- if ((storage->flags & MAIL_STORAGE_FLAG_NFS_FLUSH_STORAGE) != 0)
+ if (UIDLIST_IS_LOCKED(uidlist) &&
+ (storage->flags & MAIL_STORAGE_FLAG_NFS_FLUSH_STORAGE) != 0)
nfs_flush_attr_cache(uidlist->path, TRUE);
}
More information about the dovecot-cvs
mailing list