Mercurial > dovecot > original-hg > dovecot-1.2
changeset 6796:587a9d3054c1 HEAD
If mail_nfs_index=yes, we need to call fdatasync() for all written
transactions. Also this fdatasyncing needs to be done after rewriting the
first record's size.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Wed, 14 Nov 2007 23:43:42 +0200 |
parents | 407f75ee2598 |
children | a59deefc552f |
files | src/lib-index/mail-transaction-log-append.c |
diffstat | 1 files changed, 10 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-index/mail-transaction-log-append.c Tue Nov 13 06:23:22 2007 +0200 +++ b/src/lib-index/mail-transaction-log-append.c Wed Nov 14 23:43:42 2007 +0200 @@ -104,14 +104,6 @@ file->sync_offset + ctx->output->used == file->max_tail_offset); - if (want_fsync && !file->log->index->fsync_disable && - fdatasync(file->fd) < 0) { - mail_index_file_set_syscall_error(file->log->index, - file->filepath, - "fdatasync()"); - return log_buffer_move_to_memory(ctx); - } - /* now that the whole transaction has been written, rewrite the first record's size so the transaction becomes visible */ if (pwrite_full(file->fd, &ctx->first_append_size, @@ -122,6 +114,16 @@ return log_buffer_move_to_memory(ctx); } + if ((want_fsync && !file->log->index->fsync_disable) || + file->log->index->nfs_flush) { + if (fdatasync(file->fd) < 0) { + mail_index_file_set_syscall_error(file->log->index, + file->filepath, + "fdatasync()"); + return log_buffer_move_to_memory(ctx); + } + } + /* FIXME: when we're relying on O_APPEND and someone else wrote a transaction, we'll need to wait for it to commit its transaction. if it crashes before doing that, we'll need to overwrite it with