dovecot: Delayed NFS attribute cache flushing had some bug, so r...

dovecot at dovecot.org dovecot at dovecot.org
Mon Nov 26 12:16:02 EET 2007


details:   http://hg.dovecot.org/dovecot/rev/64e0f45e8dc3
changeset: 6859:64e0f45e8dc3
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Nov 26 12:15:57 2007 +0200
description:
Delayed NFS attribute cache flushing had some bug, so removed it for now.

diffstat:

5 files changed, 16 insertions(+), 60 deletions(-)
src/lib-storage/index/dbox/dbox-sync-rebuild.c  |    2 
src/lib-storage/index/maildir/maildir-copy.c    |    2 
src/lib-storage/index/maildir/maildir-sync.c    |    2 
src/lib-storage/index/maildir/maildir-uidlist.c |   68 ++++-------------------
src/lib-storage/index/maildir/maildir-uidlist.h |    2 

diffs (200 lines):

diff -r 78922561e9ea -r 64e0f45e8dc3 src/lib-storage/index/dbox/dbox-sync-rebuild.c
--- a/src/lib-storage/index/dbox/dbox-sync-rebuild.c	Mon Nov 26 12:09:05 2007 +0200
+++ b/src/lib-storage/index/dbox/dbox-sync-rebuild.c	Mon Nov 26 12:15:57 2007 +0200
@@ -250,7 +250,7 @@ dbox_sync_index_maildir_file(struct dbox
 			maildir_keywords_sync_init(ctx->mk,
 						   ctx->mbox->ibox.index);
 
-		if (maildir_uidlist_refresh(ctx->maildir_uidlist, FALSE) < 0)
+		if (maildir_uidlist_refresh(ctx->maildir_uidlist) < 0)
 			return -1;
 	}
 
diff -r 78922561e9ea -r 64e0f45e8dc3 src/lib-storage/index/maildir/maildir-copy.c
--- a/src/lib-storage/index/maildir/maildir-copy.c	Mon Nov 26 12:09:05 2007 +0200
+++ b/src/lib-storage/index/maildir/maildir-copy.c	Mon Nov 26 12:15:57 2007 +0200
@@ -138,7 +138,7 @@ maildir_copy_hardlink(struct maildir_tra
 		src_fname = maildir_uidlist_lookup(src_mbox->uidlist,
 						   mail->uid, &src_flags);
 		if (src_fname != NULL &&
-		    maildir_uidlist_refresh(dest_mbox->uidlist, FALSE) >= 0 &&
+		    maildir_uidlist_refresh(dest_mbox->uidlist) >= 0 &&
 		    maildir_uidlist_get_full_filename(dest_mbox->uidlist,
 						      src_fname) == NULL)
 			filename = t_strcut(src_fname, ':');
diff -r 78922561e9ea -r 64e0f45e8dc3 src/lib-storage/index/maildir/maildir-sync.c
--- a/src/lib-storage/index/maildir/maildir-sync.c	Mon Nov 26 12:09:05 2007 +0200
+++ b/src/lib-storage/index/maildir/maildir-sync.c	Mon Nov 26 12:15:57 2007 +0200
@@ -660,7 +660,7 @@ static bool move_recent_messages(struct 
 	if (ctx->mbox->ibox.keep_recent)
 		return FALSE;
 
-	(void)maildir_uidlist_refresh(ctx->mbox->uidlist, FALSE);
+	(void)maildir_uidlist_refresh(ctx->mbox->uidlist);
 
 	/* if there are files in new/, we'll need to move them. we'll check
 	   this by checking if we have any recent messages */
diff -r 78922561e9ea -r 64e0f45e8dc3 src/lib-storage/index/maildir/maildir-uidlist.c
--- a/src/lib-storage/index/maildir/maildir-uidlist.c	Mon Nov 26 12:09:05 2007 +0200
+++ b/src/lib-storage/index/maildir/maildir-uidlist.c	Mon Nov 26 12:15:57 2007 +0200
@@ -91,7 +91,6 @@ struct maildir_uidlist {
 	unsigned int recreate:1;
 	unsigned int initial_read:1;
 	unsigned int initial_sync:1;
-	unsigned int nfs_dirty_refresh:1;
 };
 
 struct maildir_uidlist_sync_ctx {
@@ -170,7 +169,7 @@ static int maildir_uidlist_lock_timeout(
 	uidlist->lock_count++;
 
 	/* make sure we have the latest changes before changing anything */
-	if (maildir_uidlist_refresh(uidlist, FALSE) < 0) {
+	if (maildir_uidlist_refresh(uidlist) < 0) {
 		maildir_uidlist_unlock(uidlist);
 		return -1;
 	}
@@ -624,14 +623,17 @@ maildir_uidlist_update_read(struct maild
 }
 
 static int
-maildir_uidlist_has_changed(struct maildir_uidlist *uidlist, bool nfs_flush,
-			    bool *recreated_r)
+maildir_uidlist_has_changed(struct maildir_uidlist *uidlist, bool *recreated_r)
 {
 	struct mail_storage *storage = uidlist->ibox->box.storage;
         struct stat st;
 
 	*recreated_r = FALSE;
 
+	if ((storage->flags & MAIL_STORAGE_FLAG_NFS_FLUSH_STORAGE) != 0) {
+		nfs_flush_file_handle_cache(uidlist->path);
+		nfs_flush_attr_cache_unlocked(uidlist->path);
+	}
 	if (nfs_safe_stat(uidlist->path, &st) < 0) {
 		if (errno != ENOENT) {
 			mail_storage_set_critical(storage,
@@ -648,8 +650,7 @@ maildir_uidlist_has_changed(struct maild
 		return 1;
 	}
 
-	if ((storage->flags & MAIL_STORAGE_FLAG_NFS_FLUSH_STORAGE) != 0 &&
-	    nfs_flush) {
+	if ((storage->flags & MAIL_STORAGE_FLAG_NFS_FLUSH_STORAGE) != 0) {
 		/* 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. */
@@ -673,29 +674,14 @@ maildir_uidlist_has_changed(struct maild
 	}
 }
 
-int maildir_uidlist_refresh(struct maildir_uidlist *uidlist, bool nfs_flush)
-{
-	struct mail_storage *storage = uidlist->ibox->box.storage;
+int maildir_uidlist_refresh(struct maildir_uidlist *uidlist)
+{
         unsigned int i;
         bool retry, recreated;
         int ret;
 
-	if ((storage->flags & MAIL_STORAGE_FLAG_NFS_FLUSH_STORAGE) != 0) {
-		/* delay flushing attribute cache until we find a file that
-		   doesn't exist in the uidlist. only then we really must have
-		   the latest uidlist. */
-		if (!nfs_flush)
-			uidlist->nfs_dirty_refresh = TRUE;
-		else {
-			nfs_flush_file_handle_cache(uidlist->path);
-			nfs_flush_attr_cache_unlocked(uidlist->path);
-			uidlist->nfs_dirty_refresh = FALSE;
-		}
-	}
-
 	if (uidlist->fd != -1) {
-		ret = maildir_uidlist_has_changed(uidlist, nfs_flush,
-						  &recreated);
+		ret = maildir_uidlist_has_changed(uidlist, &recreated);
 		if (ret <= 0)
 			return ret;
 
@@ -725,7 +711,7 @@ maildir_uidlist_lookup_rec(struct maildi
 
 	if (!uidlist->initial_read) {
 		/* first time we need to read uidlist */
-		if (maildir_uidlist_refresh(uidlist, FALSE) < 0)
+		if (maildir_uidlist_refresh(uidlist) < 0)
 			return NULL;
 	}
 
@@ -742,14 +728,6 @@ maildir_uidlist_lookup_rec(struct maildi
 			*idx_r = idx;
 			return recs[idx];
 		}
-	}
-
-	if (uidlist->nfs_dirty_refresh) {
-		/* We haven't flushed NFS attribute cache yet, do that
-		   to make sure the UID really doesn't exist */
-		if (maildir_uidlist_refresh(uidlist, TRUE) < 0)
-			return NULL;
-		return maildir_uidlist_lookup_rec(uidlist, uid, idx_r);
 	}
 
 	if (idx > 0) idx--;
@@ -1131,17 +1109,6 @@ maildir_uidlist_sync_next_partial(struct
 
 	if (rec == NULL) {
 		/* doesn't exist in uidlist */
-		if (uidlist->nfs_dirty_refresh) {
-			/* We haven't flushed NFS attribute cache yet, do that
-			   to make sure the file doesn't exist */
-			if (maildir_uidlist_refresh(uidlist, TRUE) < 0) {
-				ctx->failed = TRUE;
-				return;
-			}
-			i_assert(!uidlist->nfs_dirty_refresh);
-			return maildir_uidlist_sync_next_partial(ctx, filename,
-								 flags);
-		}
 		if (ctx->first_nouid_pos == (unsigned int)-1)
 			ctx->first_nouid_pos = array_count(&uidlist->records);
 		ctx->new_files_count++;
@@ -1176,7 +1143,7 @@ int maildir_uidlist_sync_next_pre(struct
 	    (ctx->partial || hash_lookup(ctx->files, filename) == NULL)) {
 		if (!ctx->uidlist->initial_read) {
 			/* first time reading the uidlist */
-			if (maildir_uidlist_refresh(ctx->uidlist, FALSE) < 0) {
+			if (maildir_uidlist_refresh(ctx->uidlist) < 0) {
 				ctx->failed = TRUE;
 				return -1;
 			}
@@ -1220,17 +1187,6 @@ int maildir_uidlist_sync_next(struct mai
 	} else {
 		old_rec = hash_lookup(uidlist->files, filename);
 		i_assert(old_rec != NULL || UIDLIST_IS_LOCKED(uidlist));
-
-		if (old_rec == NULL && uidlist->nfs_dirty_refresh) {
-			/* We haven't flushed NFS attribute cache yet, do that
-			   to make sure the file doesn't exist */
-			if (maildir_uidlist_refresh(uidlist, TRUE) < 0) {
-				ctx->failed = TRUE;
-				return -1;
-			}
-			i_assert(!uidlist->nfs_dirty_refresh);
-			return maildir_uidlist_sync_next(ctx, filename, flags);
-		}
 
 		rec = p_new(ctx->record_pool, struct maildir_uidlist_rec, 1);
 
diff -r 78922561e9ea -r 64e0f45e8dc3 src/lib-storage/index/maildir/maildir-uidlist.h
--- a/src/lib-storage/index/maildir/maildir-uidlist.h	Mon Nov 26 12:09:05 2007 +0200
+++ b/src/lib-storage/index/maildir/maildir-uidlist.h	Mon Nov 26 12:15:57 2007 +0200
@@ -49,7 +49,7 @@ void maildir_uidlist_deinit(struct maild
 /* Returns -1 if error, 0 if file is broken or lost, 1 if ok. If nfs_flush=TRUE
    and storage has NFS_FLUSH flag set, the NFS attribute cache is flushed to
    make sure that we see the latest uidlist file. */
-int maildir_uidlist_refresh(struct maildir_uidlist *uidlist, bool nfs_flush);
+int maildir_uidlist_refresh(struct maildir_uidlist *uidlist);
 
 /* Returns uidlist record for given filename, or NULL if not found. */
 const char *


More information about the dovecot-cvs mailing list