# HG changeset patch # User Timo Sirainen # Date 1196072157 -7200 # Node ID 64e0f45e8dc31062a0d7eb3f944e11371d10c918 # Parent 78922561e9ea54fc6473730bc6faeb8a3a042c34 Delayed NFS attribute cache flushing had some bug, so removed it for now. 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ } 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 @@ 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 @@ } } -int maildir_uidlist_refresh(struct maildir_uidlist *uidlist, bool nfs_flush) +int maildir_uidlist_refresh(struct maildir_uidlist *uidlist) { - struct mail_storage *storage = uidlist->ibox->box.storage; 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 @@ 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; } @@ -744,14 +730,6 @@ } } - 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--; *idx_r = idx; return NULL; @@ -1131,17 +1109,6 @@ 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 @@ (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; } @@ -1221,17 +1188,6 @@ 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); if (old_rec != NULL) { 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 @@ /* 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 *