dovecot-2.2: quota: dsync shouldn't trigger quota warnings

dovecot at dovecot.org dovecot at dovecot.org
Mon Apr 8 15:14:01 EEST 2013


details:   http://hg.dovecot.org/dovecot-2.2/rev/54cdc5b6727c
changeset: 16252:54cdc5b6727c
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Apr 08 15:13:39 2013 +0300
description:
quota: dsync shouldn't trigger quota warnings
They would probably just be duplicates that were already triggered by the
other replica.

diffstat:

 src/plugins/quota/quota-private.h |   1 +
 src/plugins/quota/quota-storage.c |  16 +++++++++++++++-
 src/plugins/quota/quota.c         |   7 +++++--
 3 files changed, 21 insertions(+), 3 deletions(-)

diffs (87 lines):

diff -r e41a13ae504d -r 54cdc5b6727c src/plugins/quota/quota-private.h
--- 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. */
diff -r e41a13ae504d -r 54cdc5b6727c src/plugins/quota/quota-storage.c
--- 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 */
diff -r e41a13ae504d -r 54cdc5b6727c src/plugins/quota/quota.c
--- 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;


More information about the dovecot-cvs mailing list