# HG changeset patch # User Timo Sirainen # Date 1192973948 -10800 # Node ID b6631550cf84d4971ee383084c39efa497c4844a # Parent f74e84fd11fcc7ff17227abaf56a2758d022eab6 dotlocks: Flush NFS attribute cache only if nfs_flush setting is TRUE. diff -r f74e84fd11fc -r b6631550cf84 src/deliver/duplicate.c --- a/src/deliver/duplicate.c Sun Oct 21 16:28:12 2007 +0300 +++ b/src/deliver/duplicate.c Sun Oct 21 16:39:08 2007 +0300 @@ -308,6 +308,8 @@ { duplicate_dotlock_set.use_excl_lock = getenv("DOTLOCK_USE_EXCL") != NULL; + duplicate_dotlock_set.nfs_flush = + getenv("MAIL_NFS_STORAGE") != NULL; } void duplicate_deinit(void) diff -r f74e84fd11fc -r b6631550cf84 src/lib-index/mail-cache.c --- a/src/lib-index/mail-cache.c Sun Oct 21 16:28:12 2007 +0300 +++ b/src/lib-index/mail-cache.c Sun Oct 21 16:39:08 2007 +0300 @@ -328,6 +328,7 @@ strcase_hash, (hash_cmp_callback_t *)strcasecmp); cache->dotlock_settings.use_excl_lock = index->use_excl_dotlocks; + cache->dotlock_settings.nfs_flush = index->nfs_flush; cache->dotlock_settings.timeout = MAIL_CACHE_LOCK_TIMEOUT; cache->dotlock_settings.stale_timeout = MAIL_CACHE_LOCK_CHANGE_TIMEOUT; diff -r f74e84fd11fc -r b6631550cf84 src/lib-index/mail-hash.c --- a/src/lib-index/mail-hash.c Sun Oct 21 16:28:12 2007 +0300 +++ b/src/lib-index/mail-hash.c Sun Oct 21 16:39:08 2007 +0300 @@ -78,12 +78,7 @@ MEMBER(lock_suffix) NULL, MEMBER(timeout) 10, - MEMBER(stale_timeout) 30, - - MEMBER(callback) NULL, - MEMBER(context) NULL, - - MEMBER(use_excl_lock) FALSE + MEMBER(stale_timeout) 30 }; static void mail_hash_set_syscall_error(struct mail_hash *hash, @@ -570,6 +565,7 @@ hash->fd = -1; hash->dotlock_settings = default_dotlock_settings; hash->dotlock_settings.use_excl_lock = index->use_excl_dotlocks; + hash->dotlock_settings.nfs_flush = index->nfs_flush; hash->key_hash_cb = key_hash_cb; hash->rec_hash_cb = rec_hash_cb; diff -r f74e84fd11fc -r b6631550cf84 src/lib-index/mail-transaction-log.c --- a/src/lib-index/mail-transaction-log.c Sun Oct 21 16:28:12 2007 +0300 +++ b/src/lib-index/mail-transaction-log.c Sun Oct 21 16:39:08 2007 +0300 @@ -39,6 +39,7 @@ log->index = index; log->dotlock_settings.use_excl_lock = index->use_excl_dotlocks; + log->dotlock_settings.nfs_flush = index->nfs_flush; log->dotlock_settings.timeout = MAIL_TRANSCATION_LOG_LOCK_TIMEOUT; log->dotlock_settings.stale_timeout = MAIL_TRANSCATION_LOG_LOCK_CHANGE_TIMEOUT; diff -r f74e84fd11fc -r b6631550cf84 src/lib-index/mailbox-list-index.c --- a/src/lib-index/mailbox-list-index.c Sun Oct 21 16:28:12 2007 +0300 +++ b/src/lib-index/mailbox-list-index.c Sun Oct 21 16:39:08 2007 +0300 @@ -46,12 +46,7 @@ MEMBER(lock_suffix) NULL, MEMBER(timeout) 60, - MEMBER(stale_timeout) 30, - - MEMBER(callback) NULL, - MEMBER(context) NULL, - - MEMBER(use_excl_lock) FALSE + MEMBER(stale_timeout) 30 }; int mailbox_list_index_set_syscall_error(struct mailbox_list_index *index, @@ -363,6 +358,7 @@ index->mmap_disable = mail_index->mmap_disable; index->dotlock_set = default_dotlock_set; index->dotlock_set.use_excl_lock = mail_index->use_excl_dotlocks; + index->dotlock_set.nfs_flush = mail_index->nfs_flush; return index; } diff -r f74e84fd11fc -r b6631550cf84 src/lib-storage/index/maildir/maildir-keywords.c --- a/src/lib-storage/index/maildir/maildir-keywords.c Sun Oct 21 16:28:12 2007 +0300 +++ b/src/lib-storage/index/maildir/maildir-keywords.c Sun Oct 21 16:39:08 2007 +0300 @@ -76,6 +76,9 @@ mk->dotlock_settings.use_excl_lock = (box->storage->flags & MAIL_STORAGE_FLAG_DOTLOCK_USE_EXCL) != 0; + mk->dotlock_settings.nfs_flush = + (box->storage->flags & + MAIL_STORAGE_FLAG_NFS_FLUSH_STORAGE) != 0; mk->dotlock_settings.timeout = KEYWORDS_LOCK_STALE_TIMEOUT + 2; mk->dotlock_settings.stale_timeout = KEYWORDS_LOCK_STALE_TIMEOUT; mk->dotlock_settings.temp_prefix = diff -r f74e84fd11fc -r b6631550cf84 src/lib-storage/index/maildir/maildir-uidlist.c --- a/src/lib-storage/index/maildir/maildir-uidlist.c Sun Oct 21 16:28:12 2007 +0300 +++ b/src/lib-storage/index/maildir/maildir-uidlist.c Sun Oct 21 16:39:08 2007 +0300 @@ -212,6 +212,9 @@ uidlist->dotlock_settings.use_excl_lock = (mbox->storage->storage.flags & MAIL_STORAGE_FLAG_DOTLOCK_USE_EXCL) != 0; + uidlist->dotlock_settings.nfs_flush = + (mbox->storage->storage.flags & + MAIL_STORAGE_FLAG_NFS_FLUSH_STORAGE) != 0; uidlist->dotlock_settings.timeout = UIDLIST_LOCK_STALE_TIMEOUT + 2; uidlist->dotlock_settings.stale_timeout = UIDLIST_LOCK_STALE_TIMEOUT; uidlist->dotlock_settings.temp_prefix = mbox->storage->temp_prefix; diff -r f74e84fd11fc -r b6631550cf84 src/lib-storage/index/mbox/mbox-lock.c --- a/src/lib-storage/index/mbox/mbox-lock.c Sun Oct 21 16:28:12 2007 +0300 +++ b/src/lib-storage/index/mbox/mbox-lock.c Sun Oct 21 16:39:08 2007 +0300 @@ -260,6 +260,8 @@ memset(&set, 0, sizeof(set)); set.use_excl_lock = (mbox->storage->storage.flags & MAIL_STORAGE_FLAG_DOTLOCK_USE_EXCL) != 0; + set.nfs_flush = (mbox->storage->storage.flags & + MAIL_STORAGE_FLAG_NFS_FLUSH_STORAGE) != 0; set.timeout = lock_timeout; set.stale_timeout = dotlock_change_timeout; set.callback = dotlock_callback; diff -r f74e84fd11fc -r b6631550cf84 src/lib-storage/list/subscription-file.c --- a/src/lib-storage/list/subscription-file.c Sun Oct 21 16:28:12 2007 +0300 +++ b/src/lib-storage/list/subscription-file.c Sun Oct 21 16:39:08 2007 +0300 @@ -89,6 +89,8 @@ memset(&dotlock_set, 0, sizeof(dotlock_set)); dotlock_set.use_excl_lock = (list->flags & MAILBOX_LIST_FLAG_DOTLOCK_USE_EXCL) != 0; + dotlock_set.nfs_flush = + (list->flags & MAILBOX_LIST_FLAG_NFS_FLUSH) != 0; dotlock_set.temp_prefix = temp_prefix; dotlock_set.timeout = SUBSCRIPTION_FILE_LOCK_TIMEOUT; dotlock_set.stale_timeout = SUBSCRIPTION_FILE_CHANGE_TIMEOUT; diff -r f74e84fd11fc -r b6631550cf84 src/lib-storage/mail-storage.c --- a/src/lib-storage/mail-storage.c Sun Oct 21 16:28:12 2007 +0300 +++ b/src/lib-storage/mail-storage.c Sun Oct 21 16:39:08 2007 +0300 @@ -421,6 +421,8 @@ list_flags |= MAILBOX_LIST_FLAG_FULL_FS_ACCESS; if ((storage_flags & MAIL_STORAGE_FLAG_DOTLOCK_USE_EXCL) != 0) list_flags |= MAILBOX_LIST_FLAG_DOTLOCK_USE_EXCL; + if ((storage_flags & MAIL_STORAGE_FLAG_NFS_FLUSH_STORAGE) != 0) + list_flags |= MAILBOX_LIST_FLAG_NFS_FLUSH; return list_flags; } diff -r f74e84fd11fc -r b6631550cf84 src/lib-storage/mailbox-list.h --- a/src/lib-storage/mailbox-list.h Sun Oct 21 16:28:12 2007 +0300 +++ b/src/lib-storage/mailbox-list.h Sun Oct 21 16:39:08 2007 +0300 @@ -15,7 +15,9 @@ /* Rely on O_EXCL when creating dotlocks */ MAILBOX_LIST_FLAG_DOTLOCK_USE_EXCL = 0x08, /* Mailboxes are files, not directories. */ - MAILBOX_LIST_FLAG_MAILBOX_FILES = 0x10 + MAILBOX_LIST_FLAG_MAILBOX_FILES = 0x10, + /* Flush NFS attribute cache when needed */ + MAILBOX_LIST_FLAG_NFS_FLUSH = 0x20 }; enum mailbox_info_flags { diff -r f74e84fd11fc -r b6631550cf84 src/lib/file-dotlock.c --- a/src/lib/file-dotlock.c Sun Oct 21 16:28:12 2007 +0300 +++ b/src/lib/file-dotlock.c Sun Oct 21 16:39:08 2007 +0300 @@ -147,7 +147,8 @@ { struct stat st; - nfs_flush_attr_cache(lock_info->lock_path); + if (lock_info->set->nfs_flush) + nfs_flush_attr_cache(lock_info->lock_path); if (nfs_safe_lstat(lock_info->lock_path, &st) < 0) { if (errno != ENOENT) { i_error("lstat(%s) failed: %m", lock_info->lock_path); @@ -232,7 +233,8 @@ /* possibly stale lock file. check also the timestamp of the file we're protecting. */ - nfs_flush_attr_cache(lock_info->path); + if (lock_info->set->nfs_flush) + nfs_flush_attr_cache(lock_info->path); if (nfs_safe_stat(lock_info->path, &st) < 0) { if (errno == ENOENT) { /* file doesn't exist. treat it as if diff -r f74e84fd11fc -r b6631550cf84 src/lib/file-dotlock.h --- a/src/lib/file-dotlock.h Sun Oct 21 16:28:12 2007 +0300 +++ b/src/lib/file-dotlock.h Sun Oct 21 16:39:08 2007 +0300 @@ -30,6 +30,8 @@ /* Rely on O_EXCL locking to work instead of using hardlinks. It's faster, but doesn't work with all NFS implementations. */ unsigned int use_excl_lock:1; + /* Flush NFS attribute cache before stating files. */ + unsigned int nfs_flush:1; /* Use io_add_notify() to speed up finding out when an existing dotlock is deleted */ unsigned int use_io_notify:1; diff -r f74e84fd11fc -r b6631550cf84 src/plugins/convert/convert-storage.c --- a/src/plugins/convert/convert-storage.c Sun Oct 21 16:28:12 2007 +0300 +++ b/src/plugins/convert/convert-storage.c Sun Oct 21 16:39:08 2007 +0300 @@ -17,12 +17,7 @@ MEMBER(lock_suffix) NULL, MEMBER(timeout) 60*5, - MEMBER(stale_timeout) 60*5, - - MEMBER(callback) NULL, - MEMBER(context) NULL, - - MEMBER(use_excl_lock) FALSE + MEMBER(stale_timeout) 60*5 }; static int mailbox_copy_mails(struct mailbox *srcbox, struct mailbox *destbox, @@ -287,6 +282,9 @@ dotlock_settings.use_excl_lock = (source_ns->storage->flags & MAIL_STORAGE_FLAG_DOTLOCK_USE_EXCL) != 0; + dotlock_settings.nfs_flush = + (source_ns->storage->flags & + MAIL_STORAGE_FLAG_NFS_FLUSH_STORAGE) != 0; ret = file_dotlock_create(&dotlock_settings, path, 0, &dotlock); if (ret <= 0) { if (ret == 0) diff -r f74e84fd11fc -r b6631550cf84 src/plugins/quota/quota-maildir.c --- a/src/plugins/quota/quota-maildir.c Sun Oct 21 16:28:12 2007 +0300 +++ b/src/plugins/quota/quota-maildir.c Sun Oct 21 16:39:08 2007 +0300 @@ -52,12 +52,7 @@ MEMBER(lock_suffix) NULL, MEMBER(timeout) 0, - MEMBER(stale_timeout) 30, - - MEMBER(callback) NULL, - MEMBER(context) NULL, - - MEMBER(use_excl_lock) FALSE + MEMBER(stale_timeout) 30 }; static int maildir_sum_dir(const char *dir, uint64_t *total_bytes, @@ -217,6 +212,7 @@ i_assert(root->fd == -1); dotlock_settings.use_excl_lock = getenv("DOTLOCK_USE_EXCL") != NULL; + dotlock_settings.nfs_flush = getenv("MAIL_NFS_STORAGE") != NULL; fd = file_dotlock_open(&dotlock_settings, path, DOTLOCK_CREATE_FLAG_NONBLOCK, &dotlock); if (fd == -1) {