Lines Matching refs:quota

14 #include "quota-private.h"
15 #include "quota-fs.h"
24 #define QUOTA_LIMIT_SET_PATH DICT_PATH_PRIVATE"quota/limit/"
32 struct quota *quota;
204 /* <backend>[:<quota root name>[:<backend args>]] */
216 *error_r = t_strdup_printf("Unknown quota backend: %s",
287 return "Blocked by an ongoing background quota calculation";
289 return "Internal quota calculation error";
295 return qt->quota->set->quota_exceeded_msg;
310 pool = pool_alloconly_create("quota settings", 2048);
334 if (i_strocpy(root_name, "quota", sizeof(root_name)) < 0)
343 *error_r = t_strdup_printf("Invalid quota root %s: %s",
348 if (i_snprintf(root_name, sizeof(root_name), "quota%d", i) < 0)
395 quota_root_init(struct quota_root_settings *root_set, struct quota *quota,
401 root->pool = pool_alloconly_create("quota root", 512);
403 root->quota = quota;
413 *error_r = t_strdup_printf("%s quota init failed: %s",
432 struct quota **quota_r, const char **error_r)
434 struct quota *quota;
441 quota = i_new(struct quota, 1);
442 quota->user = user;
443 quota->set = quota_set;
444 i_array_init(&quota->roots, 8);
447 i_array_init(&quota->namespaces, count);
449 ret = quota_root_init(root_sets[i], quota, &root, &error);
453 quota_deinit(&quota);
457 array_append(&quota->roots, &root, 1);
459 *quota_r = quota;
463 void quota_deinit(struct quota **_quota)
465 struct quota *quota = *_quota;
469 roots = array_get(&quota->roots, &count);
473 /* deinit quota roots before setting quser->quota=NULL */
476 array_free(&quota->roots);
477 array_free(&quota->namespaces);
478 i_free(quota);
499 "Initializing limits failed for quota backend: %s",
509 /* if default rule limits are 0, user has unlimited quota.
510 ignore any specific quota rules */
512 (void)mail_namespace_find_unalias(root->quota->user->namespaces,
538 quota_is_duplicate_namespace(struct quota *quota, struct mail_namespace *ns)
548 namespaces = array_get(&quota->namespaces, &count);
552 explicitly added as the wanted quota namespace. */
567 include the INBOX also in quota calculations, so we
576 i_assert(quota->unwanted_ns == NULL);
577 quota->unwanted_ns = namespaces[i];
584 void quota_add_user_namespace(struct quota *quota, struct mail_namespace *ns)
592 if (quota_is_duplicate_namespace(quota, ns))
595 array_append(&quota->namespaces, &ns, 1);
597 roots = array_get(&quota->roots, &count);
611 backends[i]->v.namespace_added(quota, ns);
617 struct quota *quota;
621 quota = ns->owner != NULL ?
624 if (quota == NULL) {
625 /* no quota for this namespace */
629 namespaces = array_get(&quota->namespaces, &count);
632 array_delete(&quota->namespaces, i, 1);
644 iter->quota = box->list->ns->owner != NULL ?
661 if (root->quota->unwanted_ns == ns)
679 /* we don't want to include this root in quota enforcing */
684 if (array_count(&root->quota->roots) == 1) {
685 /* a single quota root: don't bother checking further */
697 if (iter->quota == NULL)
700 roots = array_get(&iter->quota->roots, &count);
726 struct quota *quota;
730 quota = quota_get_mail_user_quota(user);
731 if (quota == NULL)
733 roots = array_get(&quota->roots, &count);
776 /* Get the value first. This call may also update quota limits if
785 "quota-%s: %s", root->set->backend->name, error);
793 "Failed to get quota root rule limits for mailbox %s: %s",
837 set.username = root->quota->user->username;
838 set.base_dir = root->quota->user->set->base_dir;
839 if (mail_user_get_home(root->quota->user, &set.home_dir) <= 0)
851 *error_r = "Internal quota limit update error";
865 ctx->quota = box->list->ns->owner != NULL ?
868 i_assert(ctx->quota != NULL);
880 array_foreach(&ctx->quota->roots, rootp) {
886 /* This mailbox isn't included in quota. This means
894 (An alternative could be to get the current quota usage
903 /* ignore quota for dsync */
928 /* find the lowest quota limits from all roots and use them */
929 roots = array_get(&ctx->quota->roots, &count);
940 "Failed to get quota root rule limits for %s: %s",
953 /* over quota */
972 "Failed to get quota resource "
985 /* over quota */
999 "Failed to get quota resource "
1021 if (root->quota->set->debug)
1022 i_debug("quota: Executing warning: %s (because %s)", cmd, reason);
1045 t_strconcat(root->quota->user->set->base_dir,
1079 i_error("Failed to get quota resource "QUOTA_NAME_STORAGE_BYTES
1085 i_error("Failed to get quota resource "QUOTA_NAME_MESSAGES
1132 roots = array_get(&ctx->quota->roots, &count);
1141 /* mailbox not included in quota */
1147 i_error("Failed to update quota for %s: %s",
1154 /* execute quota warnings after all updates. this makes it
1179 *quota_over_script_r = mail_user_plugin_getenv(root->quota->user, name);
1181 if (root->quota->set->debug) {
1182 i_debug("quota: quota_over_flag check: "
1190 flag_mask = mail_user_plugin_getenv(root->quota->user, name);
1192 if (root->quota->set->debug) {
1193 i_debug("quota: quota_over_flag check: "
1202 *quota_over_flag_r = mail_user_plugin_getenv(root->quota->user, name);
1220 if (root->quota->user->session_create_time +
1223 if (root->quota->set->debug) {
1224 i_debug("quota: quota_over_flag check: "
1229 if (root->quota->user->session_restored) {
1233 if (root->quota->set->debug) {
1234 i_debug("quota: quota_over_flag check: "
1250 i_error("quota: Quota %s lookup failed - can't verify quota_over_flag: %s",
1254 if (root->quota->set->debug) {
1255 i_debug("quota: quota_over_flag check: %s ret=%d value=%"PRIu64" limit=%"PRIu64,
1261 if (root->quota->set->debug) {
1262 i_debug("quota: quota_over_flag=%d(%s) vs currently overquota=%d",
1273 void quota_over_flag_check_startup(struct quota *quota)
1279 roots = array_get(&quota->roots, &count);
1282 if (!mail_user_plugin_getenv_bool(roots[i]->quota->user, name))
1298 if (ctx->quota->set->vsizes)
1326 so just return success for the quota allocated. */
1363 uoff_t max_size = ctx->quota->set->max_mail_size;
1374 which may automatically delete mails to stay under quota. */
1375 return ctx->quota->set->test_alloc(ctx, size, error_r);
1391 roots = array_get(&ctx->quota->roots, &count);
1405 "Failed to get quota root rule limits: %s",
1414 "Allocating %"PRIuUOFF_T" bytes would exceed quota limit",
1420 "Allocating %"PRIuUOFF_T" bytes would exceed quota", size);