dovecot-2.0: mdbox: Flush/fsync newly saved mail data before loc...

dovecot at dovecot.org dovecot at dovecot.org
Mon Jun 4 14:13:16 EEST 2012


details:   http://hg.dovecot.org/dovecot-2.0/rev/f87c09103e82
changeset: 13097:f87c09103e82
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Jun 04 14:03:47 2012 +0300
description:
mdbox: Flush/fsync newly saved mail data before locking map.
This reduced the amount of time the map needs to be locked.

diffstat:

 src/lib-storage/index/dbox-multi/mdbox-map.c  |  15 +++++++++++++++
 src/lib-storage/index/dbox-multi/mdbox-map.h  |   2 ++
 src/lib-storage/index/dbox-multi/mdbox-save.c |   6 ++++++
 3 files changed, 23 insertions(+), 0 deletions(-)

diffs (53 lines):

diff -r de5b3386a88a -r f87c09103e82 src/lib-storage/index/dbox-multi/mdbox-map.c
--- a/src/lib-storage/index/dbox-multi/mdbox-map.c	Mon Jun 04 13:59:40 2012 +0300
+++ b/src/lib-storage/index/dbox-multi/mdbox-map.c	Mon Jun 04 14:03:47 2012 +0300
@@ -1284,6 +1284,21 @@
 	return 0;
 }
 
+int mdbox_map_append_flush(struct mdbox_map_append_context *ctx)
+{
+	struct dbox_file_append_context **file_appends;
+	unsigned int i, count;
+
+	i_assert(ctx->trans == NULL);
+
+	file_appends = array_get_modifiable(&ctx->file_appends, &count);
+	for (i = 0; i < count; i++) {
+		if (dbox_file_append_flush(file_appends[i]) < 0)
+			return -1;
+	}
+	return 0;
+}
+
 int mdbox_map_append_commit(struct mdbox_map_append_context *ctx)
 {
 	struct dbox_file_append_context **file_appends;
diff -r de5b3386a88a -r f87c09103e82 src/lib-storage/index/dbox-multi/mdbox-map.h
--- a/src/lib-storage/index/dbox-multi/mdbox-map.h	Mon Jun 04 13:59:40 2012 +0300
+++ b/src/lib-storage/index/dbox-multi/mdbox-map.h	Mon Jun 04 14:03:47 2012 +0300
@@ -115,6 +115,8 @@
 int mdbox_map_append_move(struct mdbox_map_append_context *ctx,
 			  const ARRAY_TYPE(uint32_t) *map_uids,
 			  const ARRAY_TYPE(seq_range) *expunge_map_uids);
+/* Flush/fsync appends. */
+int mdbox_map_append_flush(struct mdbox_map_append_context *ctx);
 /* Returns 0 if ok, -1 if error. */
 int mdbox_map_append_commit(struct mdbox_map_append_context *ctx);
 void mdbox_map_append_free(struct mdbox_map_append_context **ctx);
diff -r de5b3386a88a -r f87c09103e82 src/lib-storage/index/dbox-multi/mdbox-save.c
--- a/src/lib-storage/index/dbox-multi/mdbox-save.c	Mon Jun 04 13:59:40 2012 +0300
+++ b/src/lib-storage/index/dbox-multi/mdbox-save.c	Mon Jun 04 14:03:47 2012 +0300
@@ -287,6 +287,12 @@
 
 	i_assert(ctx->ctx.finished);
 
+	/* flush/fsync writes to m.* files before locking the map */
+	if (mdbox_map_append_flush(ctx->append_ctx) < 0) {
+		mdbox_transaction_save_rollback(_ctx);
+		return -1;
+	}
+
 	/* make sure the map gets locked */
 	if (mdbox_map_atomic_lock(ctx->atomic) < 0) {
 		mdbox_transaction_save_rollback(_ctx);


More information about the dovecot-cvs mailing list