Mercurial > dovecot > core-2.2
changeset 16252:54cdc5b6727c
quota: dsync shouldn't trigger quota warnings
They would probably just be duplicates that were already triggered by the
other replica.
author | Timo Sirainen <tss@iki.fi> |
---|---|
date | Mon, 08 Apr 2013 15:13:39 +0300 |
parents | e41a13ae504d |
children | 1a58d4bcb49c |
files | src/plugins/quota/quota-private.h src/plugins/quota/quota-storage.c src/plugins/quota/quota.c |
diffstat | 3 files changed, 21 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/plugins/quota/quota-private.h Mon Apr 08 14:53:31 2013 +0300 +++ b/src/plugins/quota/quota-private.h Mon Apr 08 15:13:39 2013 +0300 @@ -156,6 +156,7 @@ unsigned int limits_set:1; unsigned int failed:1; unsigned int recalculate:1; + unsigned int sync_transaction:1; }; /* Register storage to all user's quota roots. */
--- a/src/plugins/quota/quota-storage.c Mon Apr 08 14:53:31 2013 +0300 +++ b/src/plugins/quota/quota-storage.c Mon Apr 08 15:13:39 2013 +0300 @@ -32,6 +32,7 @@ ARRAY(uoff_t) expunge_sizes; unsigned int recalculate:1; + unsigned int sync_transaction_expunge:1; }; struct quota_user_module quota_user_module = @@ -61,6 +62,14 @@ } array_append(&qbox->expunge_uids, &_mail->uid, 1); array_append(&qbox->expunge_sizes, &size, 1); + if ((_mail->transaction->flags & MAILBOX_TRANSACTION_FLAG_SYNC) != 0) { + /* we're running dsync. if this brings the quota below + a negative quota warning, don't execute it, because + it probably was already executed by the replica. */ + qbox->sync_transaction_expunge = TRUE; + } else { + qbox->sync_transaction_expunge = FALSE; + } } qmail->super.expunge(_mail); @@ -106,6 +115,7 @@ t = qbox->module_ctx.super.transaction_begin(box, flags); qt = quota_transaction_begin(box); + qt->sync_transaction = (flags & MAILBOX_TRANSACTION_FLAG_SYNC) != 0; MODULE_CONTEXT_SET(t, quota_storage_module, qt); return t; @@ -285,6 +295,7 @@ mail_free(&qbox->expunge_qt->tmp_mail); mailbox_transaction_rollback(&qbox->expunge_trans); } + qbox->sync_transaction_expunge = FALSE; } static void quota_mailbox_sync_commit(struct quota_mailbox *qbox) @@ -330,8 +341,11 @@ } } - if (qbox->expunge_qt == NULL) + if (qbox->expunge_qt == NULL) { qbox->expunge_qt = quota_transaction_begin(box); + qbox->expunge_qt->sync_transaction = + qbox->sync_transaction_expunge; + } if (i != count) { /* we already know the size */
--- a/src/plugins/quota/quota.c Mon Apr 08 14:53:31 2013 +0300 +++ b/src/plugins/quota/quota.c Mon Apr 08 15:13:39 2013 +0300 @@ -1210,12 +1210,15 @@ if (roots[i]->backend.v.update(roots[i], ctx) < 0) ret = -1; - else + else if (!ctx->sync_transaction) array_append(&warn_roots, &roots[i], 1); } /* execute quota warnings after all updates. this makes it work correctly regardless of whether backend.get_resource() - returns updated values before backend.update() or not */ + returns updated values before backend.update() or not. + warnings aren't executed when dsync bring the user over, + because the user probably already got the warning on the + other replica. */ array_foreach(&warn_roots, roots) quota_warnings_execute(ctx, *roots); } T_END;