# HG changeset patch # User Timo Sirainen # Date 1179329128 -10800 # Node ID d1de7c4867634e5c1c82cd677f1a57cfff34d190 # Parent ebf443cae9516c6f906504c3437e580da773313f Removed mmap_no_write setting. The only OS requiring it is OpenBSD, so we're now forcing mmap_disable=yes with it instead. dovecot.index.cache file is the most important file to mmap(), but since this didn't work with mmap_no_write, there's not much point in keeping special code paths for minimal gains. diff -r ebf443cae951 -r d1de7c486763 dovecot-example.conf --- a/dovecot-example.conf Wed May 16 16:57:23 2007 +0300 +++ b/dovecot-example.conf Wed May 16 18:25:28 2007 +0300 @@ -283,10 +283,6 @@ # filesystems (NFS or clustered filesystem). #mmap_disable = no -# Don't write() to mmaped files. This is required for some operating systems -# which use separate caches for them, such as OpenBSD. -#mmap_no_write = no - # Rely on O_EXCL to work when creating dotlock files. The default is to use # hard linking. O_EXCL makes the dotlocking faster, but it doesn't always # work with NFS. diff -r ebf443cae951 -r d1de7c486763 src/lib-index/mail-cache.c --- a/src/lib-index/mail-cache.c Wed May 16 16:57:23 2007 +0300 +++ b/src/lib-index/mail-cache.c Wed May 16 18:25:28 2007 +0300 @@ -327,7 +327,7 @@ cache->dotlock_settings.stale_timeout = MAIL_CACHE_LOCK_CHANGE_TIMEOUT; if (!MAIL_INDEX_IS_IN_MEMORY(index)) { - if (index->mmap_disable || index->mmap_no_write) + if (index->mmap_disable) cache->file_cache = file_cache_new(-1); } diff -r ebf443cae951 -r d1de7c486763 src/lib-index/mail-index-private.h --- a/src/lib-index/mail-index-private.h Wed May 16 16:57:23 2007 +0300 +++ b/src/lib-index/mail-index-private.h Wed May 16 18:25:28 2007 +0300 @@ -191,7 +191,6 @@ unsigned int log_locked:1; unsigned int mmap_disable:1; unsigned int fsync_disable:1; - unsigned int mmap_no_write:1; unsigned int use_excl_dotlocks:1; unsigned int readonly:1; unsigned int fsck:1; diff -r ebf443cae951 -r d1de7c486763 src/lib-index/mail-index.c --- a/src/lib-index/mail-index.c Wed May 16 16:57:23 2007 +0300 +++ b/src/lib-index/mail-index.c Wed May 16 18:25:28 2007 +0300 @@ -1650,8 +1650,6 @@ index->log_locked = FALSE; index->mmap_disable = (flags & MAIL_INDEX_OPEN_FLAG_MMAP_DISABLE) != 0; - index->mmap_no_write = - (flags & MAIL_INDEX_OPEN_FLAG_MMAP_NO_WRITE) != 0; index->use_excl_dotlocks = (flags & MAIL_INDEX_OPEN_FLAG_DOTLOCK_USE_EXCL) != 0; index->fsync_disable = diff -r ebf443cae951 -r d1de7c486763 src/lib-index/mail-index.h --- a/src/lib-index/mail-index.h Wed May 16 16:57:23 2007 +0300 +++ b/src/lib-index/mail-index.h Wed May 16 18:25:28 2007 +0300 @@ -16,10 +16,6 @@ MAIL_INDEX_OPEN_FLAG_CREATE = 0x01, /* Don't try to mmap() index files */ MAIL_INDEX_OPEN_FLAG_MMAP_DISABLE = 0x04, - /* Don't try to write() to mmap()ed index files. Required for the few - OSes that don't have unified buffer cache - (currently OpenBSD <= 3.5) */ - MAIL_INDEX_OPEN_FLAG_MMAP_NO_WRITE = 0x08, /* Rely on O_EXCL when creating dotlocks */ MAIL_INDEX_OPEN_FLAG_DOTLOCK_USE_EXCL = 0x10, /* Don't fsync() or fdatasync() */ diff -r ebf443cae951 -r d1de7c486763 src/lib-index/mail-transaction-log.c --- a/src/lib-index/mail-transaction-log.c Wed May 16 16:57:23 2007 +0300 +++ b/src/lib-index/mail-transaction-log.c Wed May 16 18:25:28 2007 +0300 @@ -1246,7 +1246,7 @@ struct mail_index *index = file->log->index; size_t size; struct stat st; - int ret, use_mmap; + int ret; i_assert(start_offset <= end_offset); @@ -1265,11 +1265,6 @@ if (MAIL_TRANSACTION_LOG_FILE_IN_MEMORY(file)) return 1; - /* with mmap_no_write we could alternatively just write to log with - msync() rather than pwrite(). but since there aren't many such OSes - left, it's easier to just use mmap_disable behavior with it */ - use_mmap = !index->mmap_disable && !index->mmap_no_write; - if (file->buffer != NULL && file->buffer_offset <= start_offset) { /* see if we already have it */ size = buffer_get_used_size(file->buffer); @@ -1277,7 +1272,7 @@ return 1; } - if (use_mmap) { + if (!index->mmap_disable) { if (fstat(file->fd, &st) < 0) { mail_index_file_set_syscall_error(index, file->filepath, "fstat()"); @@ -1305,7 +1300,7 @@ } if (file->buffer != NULL && - (file->mmap_base != NULL || use_mmap)) { + (file->mmap_base != NULL || !index->mmap_disable)) { buffer_free(file->buffer); file->buffer = NULL; } @@ -1317,7 +1312,7 @@ file->mmap_base = NULL; } - if (!use_mmap) { + if (index->mmap_disable) { ret = mail_transaction_log_file_read(file, start_offset); if (ret <= 0) { /* make sure we don't leave ourself in diff -r ebf443cae951 -r d1de7c486763 src/lib-storage/index/index-storage.c --- a/src/lib-storage/index/index-storage.c Wed May 16 16:57:23 2007 +0300 +++ b/src/lib-storage/index/index-storage.c Wed May 16 18:25:28 2007 +0300 @@ -361,12 +361,10 @@ if (!ibox->move_to_memory) index_flags |= MAIL_INDEX_OPEN_FLAG_CREATE; +#ifndef MMAP_CONFLICTS_WRITE if ((storage->flags & MAIL_STORAGE_FLAG_MMAP_DISABLE) != 0) +#endif index_flags |= MAIL_INDEX_OPEN_FLAG_MMAP_DISABLE; -#ifndef MMAP_CONFLICTS_WRITE - if ((storage->flags & MAIL_STORAGE_FLAG_MMAP_NO_WRITE) != 0) -#endif - index_flags |= MAIL_INDEX_OPEN_FLAG_MMAP_NO_WRITE; if ((storage->flags & MAIL_STORAGE_FLAG_DOTLOCK_USE_EXCL) != 0) index_flags |= MAIL_INDEX_OPEN_FLAG_DOTLOCK_USE_EXCL; diff -r ebf443cae951 -r d1de7c486763 src/lib-storage/list/index-mailbox-list.c --- a/src/lib-storage/list/index-mailbox-list.c Wed May 16 16:57:23 2007 +0300 +++ b/src/lib-storage/list/index-mailbox-list.c Wed May 16 18:25:28 2007 +0300 @@ -414,12 +414,10 @@ /* FIXME: a bit ugly way to get the flags, but this will do for now.. */ index_flags = MAIL_INDEX_OPEN_FLAG_CREATE; storage_flags = *list->set.mail_storage_flags; +#ifndef MMAP_CONFLICTS_WRITE if ((storage_flags & MAIL_STORAGE_FLAG_MMAP_DISABLE) != 0) +#endif index_flags |= MAIL_INDEX_OPEN_FLAG_MMAP_DISABLE; -#ifndef MMAP_CONFLICTS_WRITE - if ((storage_flags & MAIL_STORAGE_FLAG_MMAP_NO_WRITE) != 0) -#endif - index_flags |= MAIL_INDEX_OPEN_FLAG_MMAP_NO_WRITE; if (mail_index_open(ilist->mail_index, index_flags, *list->set.lock_method) < 0) { diff -r ebf443cae951 -r d1de7c486763 src/master/mail-process.c --- a/src/master/mail-process.c Wed May 16 16:57:23 2007 +0300 +++ b/src/master/mail-process.c Wed May 16 18:25:28 2007 +0300 @@ -235,8 +235,6 @@ env_put("MAIL_SAVE_CRLF=1"); if (set->mmap_disable) env_put("MMAP_DISABLE=1"); - if (set->mmap_no_write) - env_put("MMAP_NO_WRITE=1"); if (set->dotlock_use_excl) env_put("DOTLOCK_USE_EXCL=1"); if (set->fsync_disable) diff -r ebf443cae951 -r d1de7c486763 src/master/master-settings-defs.c --- a/src/master/master-settings-defs.c Wed May 16 16:57:23 2007 +0300 +++ b/src/master/master-settings-defs.c Wed May 16 18:25:28 2007 +0300 @@ -74,7 +74,6 @@ DEF_INT(mail_max_keyword_length), DEF_BOOL(mail_save_crlf), DEF_BOOL(mmap_disable), - DEF_BOOL(mmap_no_write), DEF_BOOL(dotlock_use_excl), DEF_BOOL(fsync_disable), DEF_BOOL(mailbox_list_index_disable), diff -r ebf443cae951 -r d1de7c486763 src/master/master-settings.c --- a/src/master/master-settings.c Wed May 16 16:57:23 2007 +0300 +++ b/src/master/master-settings.c Wed May 16 18:25:28 2007 +0300 @@ -221,11 +221,10 @@ MEMBER(mail_full_filesystem_access) FALSE, MEMBER(mail_max_keyword_length) 50, MEMBER(mail_save_crlf) FALSE, +#ifdef MMAP_CONFLICTS_WRITE + MEMBER(mmap_disable) TRUE, +#else MEMBER(mmap_disable) FALSE, -#ifdef MMAP_CONFLICTS_WRITE - MEMBER(mmap_no_write) TRUE, -#else - MEMBER(mmap_no_write) FALSE, #endif MEMBER(dotlock_use_excl) FALSE, MEMBER(fsync_disable) FALSE, diff -r ebf443cae951 -r d1de7c486763 src/master/master-settings.h --- a/src/master/master-settings.h Wed May 16 16:57:23 2007 +0300 +++ b/src/master/master-settings.h Wed May 16 18:25:28 2007 +0300 @@ -78,7 +78,6 @@ unsigned int mail_max_keyword_length; bool mail_save_crlf; bool mmap_disable; - bool mmap_no_write; bool dotlock_use_excl; bool fsync_disable; bool mailbox_list_index_disable;