if (ENOSPACE(errno)) {
cache->index->nodiskspace = TRUE;
- return;
+ if (!cache->index->never_in_memory)
+ return;
}
mail_index_set_error(cache->index,
unsigned int modseqs_enabled:1;
unsigned int initial_create:1;
unsigned int initial_mapped:1;
+ unsigned int never_in_memory:1;
};
extern struct mail_index_module_register mail_index_module_register;
if (ENOSPACE(errno)) {
strmap->index->nodiskspace = TRUE;
- return;
+ if (!strmap->index->never_in_memory)
+ return;
}
mail_index_set_error(strmap->index,
index->nfs_flush = (flags & MAIL_INDEX_OPEN_FLAG_NFS_FLUSH) != 0;
index->readonly = (flags & MAIL_INDEX_OPEN_FLAG_READONLY) != 0;
index->keep_backups = (flags & MAIL_INDEX_OPEN_FLAG_KEEP_BACKUPS) != 0;
+ index->never_in_memory =
+ (flags & MAIL_INDEX_OPEN_FLAG_NEVER_IN_MEMORY) != 0;
index->lock_method = lock_method;
if (index->nfs_flush && index->fsync_disable)
if (MAIL_INDEX_IS_IN_MEMORY(index))
return index->map == NULL ? -1 : 0;
+ if (index->never_in_memory)
+ return -1;
+
/* set the index as being into memory */
i_free_and_null(index->dir);
if (ENOSPACE(errno)) {
index->nodiskspace = TRUE;
- return -1;
+ if (!index->never_in_memory)
+ return -1;
}
return mail_index_set_error(index, "%s failed with index file %s: %m",
if (ENOSPACE(errno)) {
index->nodiskspace = TRUE;
- return -1;
+ if (!index->never_in_memory)
+ return -1;
}
return mail_index_set_error(index, "%s failed with file %s: %m",
/* Open the index read-only */
MAIL_INDEX_OPEN_FLAG_READONLY = 0x80,
/* Create backups of dovecot.index files once in a while */
- MAIL_INDEX_OPEN_FLAG_KEEP_BACKUPS = 0x100
+ MAIL_INDEX_OPEN_FLAG_KEEP_BACKUPS = 0x100,
+ /* If we run out of disk space, fail modifications instead of moving
+ indexes to memory. */
+ MAIL_INDEX_OPEN_FLAG_NEVER_IN_MEMORY = 0x200
};
enum mail_index_header_compat_flags {
return 0;
}
- open_flags = index_storage_get_index_open_flags(storage);
+ open_flags = MAIL_INDEX_OPEN_FLAG_NEVER_IN_MEMORY |
+ index_storage_get_index_open_flags(storage);
ret = mail_index_open_or_create(map->index, open_flags,
storage->lock_method);
if (ret < 0) {
mbox->ibox.mail_vfuncs = &dbox_mail_vfuncs;
mbox->ibox.index = index;
mbox->ibox.keep_index_backups = TRUE;
+ mbox->ibox.index_never_in_memory = TRUE;
mbox->path = p_strdup(pool, path);
mbox->alt_path = p_strdup(pool, dbox_get_alt_path(storage, path));
mbox->storage = storage;
ibox->fsync_disable = TRUE;
if (ibox->keep_index_backups)
index_flags |= MAIL_INDEX_OPEN_FLAG_KEEP_BACKUPS;
+ if (ibox->index_never_in_memory)
+ index_flags |= MAIL_INDEX_OPEN_FLAG_NEVER_IN_MEMORY;
ret = mail_index_open(ibox->index, index_flags, storage->lock_method);
if (ret <= 0 || ibox->move_to_memory) {
unsigned int move_to_memory:1;
unsigned int fsync_disable:1;
unsigned int keep_index_backups:1;
+ unsigned int index_never_in_memory:1;
};
struct index_transaction_context {