dovecot-1.1: dbox: fdatasync() when saving.
dovecot at dovecot.org
dovecot at dovecot.org
Sun May 25 02:58:45 EEST 2008
details: http://hg.dovecot.org/dovecot-1.1/rev/8a4ac809d472
changeset: 7543:8a4ac809d472
user: Timo Sirainen <tss at iki.fi>
date: Sun May 25 02:58:42 2008 +0300
description:
dbox: fdatasync() when saving.
diffstat:
1 file changed, 14 insertions(+)
src/lib-storage/index/dbox/dbox-save.c | 14 ++++++++++++++
diffs (38 lines):
diff -r cf924043234d -r 8a4ac809d472 src/lib-storage/index/dbox/dbox-save.c
--- a/src/lib-storage/index/dbox/dbox-save.c Sun May 25 02:52:39 2008 +0300
+++ b/src/lib-storage/index/dbox/dbox-save.c Sun May 25 02:58:42 2008 +0300
@@ -2,6 +2,7 @@
#include "lib.h"
#include "array.h"
+#include "fdatasync-path.h"
#include "hex-dec.h"
#include "str.h"
#include "istream.h"
@@ -232,6 +233,12 @@ static int dbox_save_mail_write_header(s
dbox_file_set_syscall_error(mail->file, "write");
return -1;
}
+ if (!mail->file->mbox->ibox.fsync_disable) {
+ if (fdatasync(mail->file->fd) < 0) {
+ dbox_file_set_syscall_error(mail->file, "fdatasync");
+ return -1;
+ }
+ }
return 0;
}
@@ -452,6 +459,13 @@ void dbox_transaction_save_commit_post(s
ctx->ctx.transaction = NULL; /* transaction is already freed */
(void)dbox_sync_finish(&ctx->sync_ctx, TRUE);
+
+ if (!ctx->mbox->ibox.fsync_disable) {
+ if (fdatasync_path(ctx->mbox->path) < 0) {
+ i_error("fdatasync_path(%s) failed: %m",
+ ctx->mbox->path);
+ }
+ }
dbox_transaction_save_rollback(ctx);
}
More information about the dovecot-cvs
mailing list