dovecot-2.2: Added MAIL_INDEX_TRANSACTION_FLAG_SYNC
dovecot at dovecot.org
dovecot at dovecot.org
Tue May 22 17:05:03 EEST 2012
details: http://hg.dovecot.org/dovecot-2.2/rev/4b1309d171ff
changeset: 14581:4b1309d171ff
user: Timo Sirainen <tss at iki.fi>
date: Thu May 03 21:46:07 2012 +0300
description:
Added MAIL_INDEX_TRANSACTION_FLAG_SYNC
diffstat:
src/doveadm/doveadm-dump-log.c | 4 +++-
src/lib-index/mail-index-transaction.c | 9 +++++++--
src/lib-index/mail-index.h | 5 ++++-
src/lib-index/mail-transaction-log-append.c | 9 +++++----
src/lib-index/mail-transaction-log.h | 13 +++++++++----
src/lib-index/test-mail-transaction-log-append.c | 8 ++++----
6 files changed, 32 insertions(+), 16 deletions(-)
diffs (167 lines):
diff -r 2e7d718609fd -r 4b1309d171ff src/doveadm/doveadm-dump-log.c
--- a/src/doveadm/doveadm-dump-log.c Tue May 22 17:03:20 2012 +0300
+++ b/src/doveadm/doveadm-dump-log.c Thu May 03 21:46:07 2012 +0300
@@ -119,8 +119,10 @@
break;
}
- if (type & MAIL_TRANSACTION_EXTERNAL)
+ if ((type & MAIL_TRANSACTION_EXTERNAL) != 0)
name = t_strconcat(name, " (ext)", NULL);
+ if ((type & MAIL_TRANSACTION_SYNC) != 0)
+ name = t_strconcat(name, " (sync)", NULL);
return name;
}
diff -r 2e7d718609fd -r 4b1309d171ff src/lib-index/mail-index-transaction.c
--- a/src/lib-index/mail-index-transaction.c Tue May 22 17:03:20 2012 +0300
+++ b/src/lib-index/mail-index-transaction.c Thu May 03 21:46:07 2012 +0300
@@ -140,13 +140,18 @@
uoff_t *commit_size_r)
{
struct mail_transaction_log *log = t->view->index->log;
- bool external = (t->flags & MAIL_INDEX_TRANSACTION_FLAG_EXTERNAL) != 0;
struct mail_transaction_log_append_ctx *ctx;
+ enum mail_transaction_type trans_flags = 0;
uint32_t log_seq1, log_seq2;
uoff_t log_offset1, log_offset2;
int ret;
- if (mail_transaction_log_append_begin(log->index, external, &ctx) < 0)
+ if ((t->flags & MAIL_INDEX_TRANSACTION_FLAG_EXTERNAL) != 0)
+ trans_flags |= MAIL_TRANSACTION_EXTERNAL;
+ if ((t->flags & MAIL_INDEX_TRANSACTION_FLAG_SYNC) != 0)
+ trans_flags |= MAIL_TRANSACTION_SYNC;
+
+ if (mail_transaction_log_append_begin(log->index, trans_flags, &ctx) < 0)
return -1;
ret = mail_transaction_log_file_refresh(t, ctx);
if (ret > 0) T_BEGIN {
diff -r 2e7d718609fd -r 4b1309d171ff src/lib-index/mail-index.h
--- a/src/lib-index/mail-index.h Tue May 22 17:03:20 2012 +0300
+++ b/src/lib-index/mail-index.h Thu May 03 21:46:07 2012 +0300
@@ -120,7 +120,10 @@
have already committed a transaction that had changed the flags. */
MAIL_INDEX_TRANSACTION_FLAG_AVOID_FLAG_UPDATES = 0x04,
/* fsync() this transaction (unless fsyncs are disabled) */
- MAIL_INDEX_TRANSACTION_FLAG_FSYNC = 0x08
+ MAIL_INDEX_TRANSACTION_FLAG_FSYNC = 0x08,
+ /* Sync transaction describes changes to mailbox that already happened
+ to another mailbox with whom we're syncing with (dsync) */
+ MAIL_INDEX_TRANSACTION_FLAG_SYNC = 0x10
};
enum mail_index_sync_type {
diff -r 2e7d718609fd -r 4b1309d171ff src/lib-index/mail-transaction-log-append.c
--- a/src/lib-index/mail-transaction-log-append.c Tue May 22 17:03:20 2012 +0300
+++ b/src/lib-index/mail-transaction-log-append.c Thu May 03 21:46:07 2012 +0300
@@ -19,11 +19,11 @@
return;
memset(&hdr, 0, sizeof(hdr));
- hdr.type = type;
+ hdr.type = type | ctx->trans_flags;
if (type == MAIL_TRANSACTION_EXPUNGE ||
type == MAIL_TRANSACTION_EXPUNGE_GUID)
hdr.type |= MAIL_TRANSACTION_EXPUNGE_PROT;
- if (ctx->external || type == MAIL_TRANSACTION_BOUNDARY)
+ if (type == MAIL_TRANSACTION_BOUNDARY)
hdr.type |= MAIL_TRANSACTION_EXTERNAL;
hdr.size = sizeof(hdr) + size;
hdr.size = mail_index_uint32_to_offset(hdr.size);
@@ -208,7 +208,8 @@
return 0;
}
-int mail_transaction_log_append_begin(struct mail_index *index, bool external,
+int mail_transaction_log_append_begin(struct mail_index *index,
+ enum mail_transaction_type flags,
struct mail_transaction_log_append_ctx **ctx_r)
{
struct mail_transaction_log_append_ctx *ctx;
@@ -220,7 +221,7 @@
ctx = i_new(struct mail_transaction_log_append_ctx, 1);
ctx->log = index->log;
ctx->output = buffer_create_dynamic(default_pool, 1024);
- ctx->external = external;
+ ctx->trans_flags = flags;
*ctx_r = ctx;
return 0;
diff -r 2e7d718609fd -r 4b1309d171ff src/lib-index/mail-transaction-log.h
--- a/src/lib-index/mail-transaction-log.h Tue May 22 17:03:20 2012 +0300
+++ b/src/lib-index/mail-transaction-log.h Thu May 03 21:46:07 2012 +0300
@@ -58,8 +58,11 @@
flag. if it's not present, assume corrupted log. */
MAIL_TRANSACTION_EXPUNGE_PROT = 0x0000cd90,
- /* Mailbox synchronization noticed this change. */
- MAIL_TRANSACTION_EXTERNAL = 0x10000000
+ /* Mailbox storage backend synchronization noticed this change. */
+ MAIL_TRANSACTION_EXTERNAL = 0x10000000,
+ /* This change syncs the state with another mailbox (dsync),
+ i.e. the change isn't something that a user requested locally. */
+ MAIL_TRANSACTION_SYNC = 0x20000000
};
struct mail_transaction_header {
@@ -166,8 +169,9 @@
struct mail_transaction_log *log;
buffer_t *output;
+ enum mail_transaction_type trans_flags;
+
uint64_t new_highest_modseq;
- unsigned int external:1;
unsigned int append_sync_offset:1;
unsigned int sync_includes_this:1;
unsigned int want_fsync:1;
@@ -256,7 +260,8 @@
bool
mail_transaction_log_view_is_corrupted(struct mail_transaction_log_view *view);
-int mail_transaction_log_append_begin(struct mail_index *index, bool external,
+int mail_transaction_log_append_begin(struct mail_index *index,
+ enum mail_transaction_type flags,
struct mail_transaction_log_append_ctx **ctx_r);
void mail_transaction_log_append_add(struct mail_transaction_log_append_ctx *ctx,
enum mail_transaction_type type,
diff -r 2e7d718609fd -r 4b1309d171ff src/lib-index/test-mail-transaction-log-append.c
--- a/src/lib-index/test-mail-transaction-log-append.c Tue May 22 17:03:20 2012 +0300
+++ b/src/lib-index/test-mail-transaction-log-append.c Thu May 03 21:46:07 2012 +0300
@@ -46,7 +46,7 @@
const struct mail_transaction_header *hdr;
const unsigned int *bufp;
- test_assert(mail_transaction_log_append_begin(log->index, TRUE, &ctx) == 0);
+ test_assert(mail_transaction_log_append_begin(log->index, MAIL_TRANSACTION_EXTERNAL, &ctx) == 0);
mail_transaction_log_append_add(ctx, MAIL_TRANSACTION_APPEND,
&buf[0], sizeof(buf[0]));
test_assert(ctx->new_highest_modseq == 0);
@@ -89,7 +89,7 @@
const uint32_t *offsetp;
test_begin("transaction log append: append_sync_offset only");
- test_assert(mail_transaction_log_append_begin(log->index, FALSE, &ctx) == 0);
+ test_assert(mail_transaction_log_append_begin(log->index, 0, &ctx) == 0);
ctx->append_sync_offset = TRUE;
file->max_tail_offset = 123;
test_assert(mail_transaction_log_append_commit(&ctx) == 0);
@@ -131,7 +131,7 @@
test_begin("transaction log append: lock failure");
log_lock_failure = TRUE;
- test_assert(mail_transaction_log_append_begin(log->index, FALSE, &ctx) < 0);
+ test_assert(mail_transaction_log_append_begin(log->index, 0, &ctx) < 0);
log_lock_failure = FALSE;
test_end();
@@ -143,7 +143,7 @@
file->buffer_offset = 1;
file->last_size = 3;
file->fd = fd;
- test_assert(mail_transaction_log_append_begin(log->index, FALSE, &ctx) == 0);
+ test_assert(mail_transaction_log_append_begin(log->index, 0, &ctx) == 0);
test_assert(mail_transaction_log_append_commit(&ctx) == 0);
if (fstat(fd, &st) < 0) i_fatal("fstat() failed: %m");
test_assert(st.st_size == 1);
More information about the dovecot-cvs
mailing list