changeset 3845:18a786df5815 HEAD

Added dbox_rotate_min_size and fixed rotation checks.
author Timo Sirainen <tss@iki.fi>
date Wed, 11 Jan 2006 21:26:05 +0200
parents 93959452e17e
children 223ceff28fc3
files dovecot-example.conf src/lib-storage/index/dbox/dbox-storage.c src/lib-storage/index/dbox/dbox-storage.h src/lib-storage/index/dbox/dbox-uidlist.c src/master/master-settings.c src/master/master-settings.h
diffstat 6 files changed, 25 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/dovecot-example.conf	Mon Jan 09 10:05:24 2006 +0200
+++ b/dovecot-example.conf	Wed Jan 11 21:26:05 2006 +0200
@@ -380,6 +380,10 @@
 # Maximum dbox file size in kilobytes until it's rotated.
 #dbox_rotate_size = 2048
 
+# Minimum dbox file size in kilobytes before it's rotated
+# (overrides dbox_rotate_days)
+#dbox_rotate_min_size = 16
+
 # Maximum dbox file age in days until it's rotated. Day always begins from
 # midnight, so 1 = today, 2 = yesterday, etc. 0 = check disabled.
 #dbox_rotate_days = 0
--- a/src/lib-storage/index/dbox/dbox-storage.c	Mon Jan 09 10:05:24 2006 +0200
+++ b/src/lib-storage/index/dbox/dbox-storage.c	Wed Jan 11 21:26:05 2006 +0200
@@ -306,6 +306,11 @@
 		mbox->rotate_size = (uoff_t)strtoul(value, NULL, 10) * 1024;
 	else
 		mbox->rotate_size = DBOX_DEFAULT_ROTATE_SIZE;
+	value = getenv("DBOX_ROTATE_MIN_SIZE");
+	if (value != NULL)
+		mbox->rotate_min_size = (uoff_t)strtoul(value, NULL, 10) * 1024;
+	else
+		mbox->rotate_min_size = DBOX_DEFAULT_ROTATE_MIN_SIZE;
 	value = getenv("DBOX_ROTATE_DAYS");
 	if (value != NULL)
 		mbox->rotate_days = (unsigned int)strtoul(value, NULL, 10);
--- a/src/lib-storage/index/dbox/dbox-storage.h	Mon Jan 09 10:05:24 2006 +0200
+++ b/src/lib-storage/index/dbox/dbox-storage.h	Wed Jan 11 21:26:05 2006 +0200
@@ -15,6 +15,7 @@
 
 /* Default rotation settings */
 #define DBOX_DEFAULT_ROTATE_SIZE (2*1024*1024)
+#define DBOX_DEFAULT_ROTATE_MIN_SIZE (1024*16)
 #define DBOX_DEFAULT_ROTATE_DAYS 0
 
 struct dbox_uidlist;
@@ -80,7 +81,7 @@
 	uint32_t dbox_file_ext_idx;
 	uint32_t dbox_offset_ext_idx;
 
-	uoff_t rotate_size;
+	uoff_t rotate_size, rotate_min_size;
 	unsigned int rotate_days;
 };
 
--- a/src/lib-storage/index/dbox/dbox-uidlist.c	Mon Jan 09 10:05:24 2006 +0200
+++ b/src/lib-storage/index/dbox/dbox-uidlist.c	Wed Jan 11 21:26:05 2006 +0200
@@ -847,6 +847,11 @@
 	return stamp - (3600*24 * (days-1));
 }
 
+#define DBOX_CAN_APPEND(mbox, create_time, file_size, min_usable_timestamp) \
+	(((create_time) >= (min_usable_timestamp) && \
+	  (file_size) < (mbox)->rotate_size) || \
+	 (file_size) < (mbox)->rotate_min_size)
+
 int dbox_uidlist_append_locked(struct dbox_uidlist_append_ctx *ctx,
 			       struct dbox_file **file_r)
 {
@@ -867,8 +872,9 @@
 	/* check first from already opened files */
 	files = array_get(&ctx->files, &count);
 	for (i = 0; i < count; i++) {
-		if (files[i]->file->create_time >= min_usable_timestamp ||
-		    files[i]->append_offset < mbox->rotate_size) {
+		if (DBOX_CAN_APPEND(mbox, files[i]->file->create_time,
+				    files[i]->append_offset,
+				    min_usable_timestamp)) {
 			if (dbox_reopen_file(ctx, files[i]) < 0)
 				return -1;
 
@@ -885,8 +891,9 @@
 	for (i = 0;; i++) {
                 file_seq = 0; 
 		for (; i < count; i++) {
-			if ((entries[i]->create_time >= min_usable_timestamp ||
-			     entries[i]->file_size < mbox->rotate_size) &&
+			if (DBOX_CAN_APPEND(mbox, entries[i]->create_time,
+					    entries[i]->file_size,
+					    min_usable_timestamp) &&
 			    !dbox_uidlist_files_lookup(ctx,
 						       entries[i]->file_seq)) {
 				file_seq = entries[i]->file_seq;
--- a/src/master/master-settings.c	Mon Jan 09 10:05:24 2006 +0200
+++ b/src/master/master-settings.c	Wed Jan 11 21:26:05 2006 +0200
@@ -117,6 +117,7 @@
 	DEF(SET_BOOL, mbox_very_dirty_syncs),
 	DEF(SET_BOOL, mbox_lazy_writes),
 	DEF(SET_INT, dbox_rotate_size),
+	DEF(SET_INT, dbox_rotate_min_size),
 	DEF(SET_INT, dbox_rotate_days),
 	DEF(SET_INT, umask),
 	DEF(SET_BOOL, mail_drop_priv_before_exec),
@@ -316,6 +317,7 @@
 	MEMBER(mbox_very_dirty_syncs) FALSE,
 	MEMBER(mbox_lazy_writes) TRUE,
 	MEMBER(dbox_rotate_size) 2048,
+	MEMBER(dbox_rotate_min_size) 16,
 	MEMBER(dbox_rotate_days) 1,
 	MEMBER(umask) 0077,
 	MEMBER(mail_drop_priv_before_exec) FALSE,
--- a/src/master/master-settings.h	Mon Jan 09 10:05:24 2006 +0200
+++ b/src/master/master-settings.h	Wed Jan 11 21:26:05 2006 +0200
@@ -86,6 +86,7 @@
 	int mbox_very_dirty_syncs;
 	int mbox_lazy_writes;
 	unsigned int dbox_rotate_size;
+	unsigned int dbox_rotate_min_size;
 	unsigned int dbox_rotate_days;
 	unsigned int umask;
 	int mail_drop_priv_before_exec;