dovecot: Flush cache file's NFS attribute cache only once per sy...
dovecot at dovecot.org
dovecot at dovecot.org
Thu Nov 8 21:55:09 EET 2007
details: http://hg.dovecot.org/dovecot/rev/de67ceff3199
changeset: 6753:de67ceff3199
user: Timo Sirainen <tss at iki.fi>
date: Thu Nov 08 21:55:06 2007 +0200
description:
Flush cache file's NFS attribute cache only once per sync. Don't invalidate
areas that have already been invalidated within this sync.
diffstat:
1 file changed, 36 insertions(+), 12 deletions(-)
src/lib-index/mail-cache-sync-update.c | 48 ++++++++++++++++++++++++--------
diffs (92 lines):
diff -r 75f7163d4379 -r de67ceff3199 src/lib-index/mail-cache-sync-update.c
--- a/src/lib-index/mail-cache-sync-update.c Thu Nov 08 21:37:43 2007 +0200
+++ b/src/lib-index/mail-cache-sync-update.c Thu Nov 08 21:55:06 2007 +0200
@@ -7,8 +7,11 @@
#include "mail-index-sync-private.h"
struct mail_cache_sync_context {
+ uoff_t invalidate_highwater;
+
unsigned int locked:1;
unsigned int lock_failed:1;
+ unsigned int nfs_attr_cache_flushed:1;
};
static void mail_cache_handler_deinit(struct mail_index_sync_map_ctx *sync_ctx,
@@ -22,14 +25,24 @@ static void mail_cache_handler_deinit(st
i_free(ctx);
}
-static int mail_cache_handler_init(struct mail_cache_sync_context **ctx_r,
+static struct mail_cache_sync_context *mail_cache_handler_init(void **context)
+{
+ struct mail_cache_sync_context *ctx;
+
+ if (*context != NULL)
+ ctx = *context;
+ else {
+ *context = i_new(struct mail_cache_sync_context, 1);
+ ctx = *context;
+ ctx->invalidate_highwater = (uoff_t)-1;
+ }
+ return ctx;
+}
+
+static int mail_cache_handler_lock(struct mail_cache_sync_context *ctx,
struct mail_cache *cache)
{
- struct mail_cache_sync_context *ctx = *ctx_r;
int ret;
-
- if (ctx == NULL)
- ctx = *ctx_r = i_new(struct mail_cache_sync_context, 1);
if (ctx->locked)
return 1;
@@ -81,8 +94,8 @@ int mail_cache_expunge_handler(struct ma
if (MAIL_CACHE_IS_UNUSABLE(cache))
return 0;
- ret = mail_cache_handler_init(&ctx, cache);
- *sync_context = ctx;
+ ctx = mail_cache_handler_init(context);
+ ret = mail_cache_handler_lock(ctx, cache);
if (ret <= 0)
return ret;
@@ -118,10 +131,22 @@ int mail_cache_sync_handler(struct mail_
if (MAIL_CACHE_IS_UNUSABLE(cache))
return 1;
+ ctx = mail_cache_handler_init(context);
if (cache->file_cache != NULL) {
- mail_cache_flush_read_cache(cache, FALSE);
- file_cache_invalidate(cache->file_cache, *new_cache_offset,
- (uoff_t)-1);
+ /* flush attribute cache only once per sync */
+ if (!ctx->nfs_attr_cache_flushed && cache->index->nfs_flush) {
+ ctx->nfs_attr_cache_flushed = TRUE;
+ mail_cache_flush_read_cache(cache, FALSE);
+ }
+ /* don't invalidate anything that's already been invalidated
+ within this sync. */
+ if (*new_cache_offset < ctx->invalidate_highwater) {
+ file_cache_invalidate(cache->file_cache,
+ *new_cache_offset,
+ ctx->invalidate_highwater -
+ *new_cache_offset);
+ ctx->invalidate_highwater = *new_cache_offset;
+ }
}
if (*old_cache_offset == 0 || *old_cache_offset == *new_cache_offset ||
@@ -138,8 +163,7 @@ int mail_cache_sync_handler(struct mail_
}
/* we'll need to link the old and new cache records */
- ret = mail_cache_handler_init(&ctx, cache);
- *context = ctx;
+ ret = mail_cache_handler_lock(ctx, cache);
if (ret <= 0)
return ret < 0 ? -1 : 1;
More information about the dovecot-cvs
mailing list