Mercurial > dovecot > core-2.2
changeset 14645:61be33b6336c
mdbox: Flush/fsync newly saved mail data before locking map.
This reduced the amount of time the map needs to be locked.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 04 Jun 2012 14:03:47 +0300 |
parents | 99d31c803b7b |
children | fa75bd3245a4 |
files | src/lib-storage/index/dbox-multi/mdbox-map.c src/lib-storage/index/dbox-multi/mdbox-map.h src/lib-storage/index/dbox-multi/mdbox-save.c |
diffstat | 3 files changed, 23 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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 @@ -1369,6 +1369,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;
--- 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);
--- 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);