]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
quota: Drop support for percentage based quota_grace
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Thu, 15 Aug 2024 10:02:21 +0000 (13:02 +0300)
committerAki Tuomi <aki.tuomi@open-xchange.com>
Wed, 12 Feb 2025 10:34:13 +0000 (12:34 +0200)
Also change the default from 10% to 10 MB. It's likely not necessary to
support both, and having a fixed size makes usually more sense than a
percentage that can be rather huge. If we wanted to support both, the
settings redesign would require two separate grace settings, which seems
a bit excessive.

src/plugins/quota/quota-private.h
src/plugins/quota/quota-util.c
src/plugins/quota/quota.c

index 388af5445084243824866a66803b2015e9f4fbf7..e0a43755ae124530c39dabfd51070fb0304f1690 100644 (file)
@@ -97,8 +97,7 @@ struct quota_root_settings {
 
        /* If user is under quota before saving a mail, allow the last mail to
           bring the user over quota by this many bytes. */
-       uint64_t last_mail_max_extra_bytes;
-       struct quota_rule grace_rule;
+       uint64_t quota_storage_grace;
 
        /* TRUE if any of the warning_rules have reverse==TRUE */
        bool have_reverse_warnings:1;
@@ -157,7 +156,7 @@ struct quota_transaction_context {
        /* how many bytes/mails can be saved until limit is reached.
           (set once, not updated by bytes_used/count_used).
 
-          if last_mail_max_extra_bytes>0, the bytes_ceil is initially
+          if quota_storage_grace>0, the bytes_ceil is initially
           increased by that much, while bytes_ceil2 contains the real ceiling.
           after the first allocation is done, bytes_ceil is set to
           bytes_ceil2. */
index 583726609afced40f20ced9cfe4fa63df419c9ae..4290aafaf1bafad582a15aab8e4f62270ee95ac1 100644 (file)
@@ -1,12 +1,13 @@
 /* Copyright (c) 2005-2018 Dovecot authors, see the included COPYING file */
 
 #include "lib.h"
+#include "str-parse.h"
 #include "wildcard-match.h"
 #include "quota-private.h"
 
 #include <ctype.h>
 
-#define QUOTA_DEFAULT_GRACE "10%"
+#define QUOTA_DEFAULT_GRACE "10M"
 
 #define RULE_NAME_DEFAULT_FORCE "*"
 
@@ -126,15 +127,11 @@ void quota_root_recalculate_relative_rules(struct event *event,
                quota_rule_recalculate_relative_rules(&warning_rule->rule,
                                                      bytes_limit, count_limit);
        }
-       quota_rule_recalculate_relative_rules(&root_set->grace_rule,
-                                             bytes_limit, 0);
-       root_set->last_mail_max_extra_bytes = root_set->grace_rule.bytes_limit;
 
        e_debug(event,
                "Quota root %s: Recalculated relative rules with "
-               "bytes=%lld count=%lld. Now grace=%"PRIu64, root_set->name,
-               (long long)bytes_limit, (long long)count_limit,
-               root_set->last_mail_max_extra_bytes);
+               "bytes=%lld count=%lld.", root_set->name,
+               (long long)bytes_limit, (long long)count_limit);
 }
 
 static int
@@ -344,25 +341,16 @@ int quota_root_parse_grace(struct event *event,
                           struct quota_root_settings *root_set,
                           const char *value, const char **error_r)
 {
-       const char *p;
-
        if (value == NULL) {
                /* default */
                value = QUOTA_DEFAULT_GRACE;
        }
 
-       if (str_parse_int64(value, &root_set->grace_rule.bytes_limit, &p) < 0)
-               return -1;
-       if (quota_limit_parse(root_set, &root_set->grace_rule, p, 1,
-                             &root_set->grace_rule.bytes_limit, error_r) < 0)
+       if (str_parse_get_size(value, &root_set->quota_storage_grace,
+                              error_r) < 0)
                return -1;
-       quota_rule_recalculate_relative_rules(&root_set->grace_rule,
-               root_set->default_rule.bytes_limit, 0);
-       root_set->last_mail_max_extra_bytes = root_set->grace_rule.bytes_limit;
-       e_debug(event, "Quota grace: root=%s bytes=%lld%s",
-               root_set->name, (long long)root_set->grace_rule.bytes_limit,
-               root_set->grace_rule.bytes_percent == 0 ? "" :
-               t_strdup_printf(" (%u%%)", root_set->grace_rule.bytes_percent));
+       e_debug(event, "Quota grace: root=%s bytes=%"PRIu64,
+               root_set->name, root_set->quota_storage_grace);
        return 0;
 }
 
index 52519268078d4d9d41eff97c92e0039cdedcce35..68ffcb32b802f6191f9b4a2e2feee824cf33d1dc 100644 (file)
@@ -870,7 +870,7 @@ int quota_transaction_set_limits(struct quota_transaction_context *ctx,
                                        if (ctx->bytes_ceil2 > diff)
                                                ctx->bytes_ceil2 = diff;
                                        diff += !use_grace ? 0 :
-                                               roots[i]->set->last_mail_max_extra_bytes;
+                                               roots[i]->set->quota_storage_grace;
                                        if (ctx->bytes_ceil > diff)
                                                ctx->bytes_ceil = diff;
                                }