dovecot-1.2: Fixed FS quota compiling and Maildir++ quota with m...

dovecot at dovecot.org dovecot at dovecot.org
Thu Aug 14 01:08:52 EEST 2008


details:   http://hg.dovecot.org/dovecot-1.2/rev/f35a8a3dc06d
changeset: 8096:f35a8a3dc06d
user:      Timo Sirainen <tss at iki.fi>
date:      Wed Aug 13 18:08:45 2008 -0400
description:
Fixed FS quota compiling and Maildir++ quota with multiple users.

diffstat:

4 files changed, 28 insertions(+), 21 deletions(-)
src/plugins/quota/quota-fs.c      |    4 ++--
src/plugins/quota/quota-maildir.c |   26 +++++++++++++-------------
src/plugins/quota/quota-private.h |    5 +++++
src/plugins/quota/quota.c         |   14 ++++++++------

diffs (162 lines):

diff -r 1f948670f274 -r f35a8a3dc06d src/plugins/quota/quota-fs.c
--- a/src/plugins/quota/quota-fs.c	Wed Aug 13 16:43:29 2008 -0400
+++ b/src/plugins/quota/quota-fs.c	Wed Aug 13 18:08:45 2008 -0400
@@ -661,9 +661,9 @@ fs_quota_get_resource(struct quota_root 
 
 	/* update limit */
 	if (bytes)
-		_root->default_rule.bytes_limit = limit;
+		_root->bytes_limit = limit;
 	else
-		_root->default_rule.count_limit = limit;
+		_root->count_limit = limit;
 	return 1;
 }
 
diff -r 1f948670f274 -r f35a8a3dc06d src/plugins/quota/quota-maildir.c
--- a/src/plugins/quota/quota-maildir.c	Wed Aug 13 16:43:29 2008 -0400
+++ b/src/plugins/quota/quota-maildir.c	Wed Aug 13 18:08:45 2008 -0400
@@ -217,7 +217,7 @@ maildirs_check_have_changed(struct maild
 
 static int maildirsize_write(struct maildir_quota_root *root, const char *path)
 {
-	const struct quota_rule *rule = &root->root.set->default_rule;
+	struct quota_root *_root = &root->root;
 	struct mail_storage *const *storages;
 	unsigned int i, count;
 	struct dotlock *dotlock;
@@ -257,15 +257,15 @@ static int maildirsize_write(struct mail
 	}
 
 	str = t_str_new(128);
-	if (rule->bytes_limit != 0) {
+	if (_root->bytes_limit != 0) {
 		str_printfa(str, "%lluS",
-			    (unsigned long long)rule->bytes_limit);
-	}
-	if (rule->count_limit != 0) {
+			    (unsigned long long)_root->bytes_limit);
+	}
+	if (_root->count_limit != 0) {
 		if (str_len(str) > 0)
 			str_append_c(str, ',');
 		str_printfa(str, "%lluC",
-			    (unsigned long long)rule->count_limit);
+			    (unsigned long long)_root->count_limit);
 	}
 	str_printfa(str, "\n%llu %llu\n",
 		    (unsigned long long)root->total_bytes,
@@ -410,7 +410,7 @@ static int maildirsize_parse(struct mail
 static int maildirsize_parse(struct maildir_quota_root *root,
 			     int fd, const char *const *lines)
 {
-	struct quota_rule *rule = &root->root.set->default_rule;
+	struct quota_root *_root = &root->root;
 	uint64_t message_bytes_limit, message_count_limit;
 	long long bytes_diff, total_bytes;
 	int count_diff, total_count;
@@ -429,8 +429,8 @@ static int maildirsize_parse(struct mail
 	if (message_count_limit >= (1ULL << 63))
 		message_count_limit = (1ULL << 63) - 1;
 
-	if (rule->bytes_limit == (int64_t)message_bytes_limit &&
-	    rule->count_limit == (int64_t)message_count_limit) {
+	if (root->root.bytes_limit == (int64_t)message_bytes_limit &&
+	    root->root.count_limit == (int64_t)message_count_limit) {
 		/* limits haven't changed */
 	} else if (root->root.set->force_default_rule) {
 		/* we know the limits and they've changed.
@@ -438,8 +438,8 @@ static int maildirsize_parse(struct mail
 		return 0;
 	} else {
 		/* we're using limits from the file. */
-		rule->bytes_limit = message_bytes_limit;
-		rule->count_limit = message_count_limit;
+		root->root.bytes_limit = message_bytes_limit;
+		root->root.count_limit = message_count_limit;
 		quota_root_recalculate_relative_rules(root->root.set);
 	}
 
@@ -463,8 +463,8 @@ static int maildirsize_parse(struct mail
 		return -1;
 	}
 
-	if ((total_bytes > rule->bytes_limit && rule->bytes_limit != 0) ||
-	    (total_count > rule->count_limit && rule->count_limit != 0)) {
+	if ((total_bytes > _root->bytes_limit && _root->bytes_limit != 0) ||
+	    (total_count > _root->count_limit && _root->count_limit != 0)) {
 		/* we're over quota. don't trust these values if the file
 		   contains more than the initial summary line, or if the file
 		   is older than 15 minutes. */
diff -r 1f948670f274 -r f35a8a3dc06d src/plugins/quota/quota-private.h
--- a/src/plugins/quota/quota-private.h	Wed Aug 13 16:43:29 2008 -0400
+++ b/src/plugins/quota/quota-private.h	Wed Aug 13 18:08:45 2008 -0400
@@ -96,6 +96,11 @@ struct quota_root {
 	struct quota *quota;
 	struct quota_backend backend;
 
+	/* initially the same as set->default_rule.*_limit, but some backends
+	   may change these by reading the limits elsewhere (e.g. Maildir++,
+	   FS quota) */
+	int64_t bytes_limit, count_limit;
+
 	/* Module-specific contexts. See quota_module_id. */
 	ARRAY_DEFINE(quota_module_contexts, void);
 
diff -r 1f948670f274 -r f35a8a3dc06d src/plugins/quota/quota.c
--- a/src/plugins/quota/quota.c	Wed Aug 13 16:43:29 2008 -0400
+++ b/src/plugins/quota/quota.c	Wed Aug 13 18:08:45 2008 -0400
@@ -143,6 +143,8 @@ quota_root_init(struct quota_root_settin
 	root->set = root_set;
 	root->quota = quota;
 	root->backend = *root_set->backend;
+	root->bytes_limit = root_set->default_rule.bytes_limit;
+	root->count_limit = root_set->default_rule.count_limit;
 
 	array_create(&root->quota_module_contexts, root->pool,
 		     sizeof(void *), 10);
@@ -424,7 +426,7 @@ int quota_root_add_rule(struct quota_roo
 	return ret;
 }
 
-static bool quota_root_get_rule_limits(struct quota_root_settings *root_set,
+static bool quota_root_get_rule_limits(struct quota_root *root,
 				       const char *mailbox_name,
 				       uint64_t *bytes_limit_r,
 				       uint64_t *count_limit_r)
@@ -433,14 +435,14 @@ static bool quota_root_get_rule_limits(s
 	int64_t bytes_limit, count_limit;
 	bool found;
 
-	bytes_limit = root_set->default_rule.bytes_limit;
-	count_limit = root_set->default_rule.count_limit;
+	bytes_limit = root->bytes_limit;
+	count_limit = root->count_limit;
 
 	/* if default rule limits are 0, this rule applies only to specific
 	   mailboxes */
 	found = bytes_limit != 0 || count_limit != 0;
 
-	rule = quota_root_rule_find(root_set, mailbox_name);
+	rule = quota_root_rule_find(root->set, mailbox_name);
 	if (rule != NULL) {
 		if (!rule->ignore) {
 			bytes_limit += rule->bytes_limit;
@@ -685,7 +687,7 @@ int quota_get_resource(struct quota_root
 	if (ret <= 0)
 		return ret;
 
-	(void)quota_root_get_rule_limits(root->set, mailbox_name,
+	(void)quota_root_get_rule_limits(root, mailbox_name,
 					 &bytes_limit, &count_limit);
 	if (strcmp(name, QUOTA_NAME_STORAGE_BYTES) == 0)
 		*limit_r = bytes_limit;
@@ -914,7 +916,7 @@ static int quota_default_test_alloc(stru
 		if (!quota_root_is_visible(roots[i], ctx->box, TRUE))
 			continue;
 
-		if (!quota_root_get_rule_limits(roots[i]->set,
+		if (!quota_root_get_rule_limits(roots[i],
 						mailbox_get_name(ctx->box),
 						&bytes_limit, &count_limit))
 			continue;


More information about the dovecot-cvs mailing list