]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
global: Add mailbox_set_reason() calls
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Sat, 1 Apr 2017 18:43:16 +0000 (21:43 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 3 Apr 2017 11:00:05 +0000 (14:00 +0300)
Added to the most important places.

39 files changed:
src/doveadm/doveadm-mail-copymove.c
src/doveadm/doveadm-mail-import.c
src/doveadm/doveadm-mail-index.c
src/doveadm/doveadm-mail-iter.c
src/doveadm/doveadm-mail-mailbox-metadata.c
src/doveadm/doveadm-mail-mailbox-status.c
src/doveadm/doveadm-mail-mailbox.c
src/doveadm/doveadm-mail-save.c
src/doveadm/doveadm-mail.c
src/imap/cmd-create.c
src/imap/cmd-delete.c
src/imap/cmd-getmetadata.c
src/imap/cmd-notify.c
src/imap/cmd-rename.c
src/imap/cmd-resetkey.c
src/imap/cmd-select.c
src/imap/cmd-setmetadata.c
src/imap/cmd-subscribe.c
src/imap/imap-commands-util.c
src/imap/imap-notify.c
src/imap/imap-state.c
src/imap/imap-status.c
src/indexer/master-connection.c
src/lib-imap-storage/imap-metadata.c
src/lib-imap-storage/imap-msgpart-url.c
src/lib-imap-urlauth/imap-urlauth-backend.c
src/lib-lda/mail-deliver.c
src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c
src/lib-storage/mail-autoexpunge.c
src/lib-storage/mail-storage.c
src/lmtp/commands.c
src/plugins/lazy-expunge/lazy-expunge-plugin.c
src/plugins/pop3-migration/pop3-migration-plugin.c
src/plugins/quota/quota-count.c
src/plugins/quota/quota-status.c
src/plugins/trash/trash-plugin.c
src/plugins/virtual/virtual-config.c
src/plugins/virtual/virtual-storage.c
src/pop3/pop3-client.c

index 14b3d9d8efd9bb0fc4839b6ae7eeb3786f72917d..8e5b700912c7a26e8966e4455079c01fe839875f 100644 (file)
@@ -108,6 +108,7 @@ cmd_copy_run(struct doveadm_mail_cmd_context *_ctx, struct mail_user *user)
 
        ns = mail_namespace_find(user->namespaces, ctx->destname);
        destbox = mailbox_alloc(ns->list, ctx->destname, MAILBOX_FLAG_SAVEONLY);
+       mailbox_set_reason(destbox, _ctx->cmd->name);
        if (mailbox_open(destbox) < 0) {
                i_error("Can't open mailbox '%s': %s", ctx->destname,
                        mailbox_get_last_internal_error(destbox, NULL));
index cabd369ab4fbac8da812b96bb5cda2a0fb0887be..302401e548a202b3283605e6353032ea5098b487 100644 (file)
@@ -63,6 +63,7 @@ dest_mailbox_open_or_create(struct import_cmd_context *ctx,
        }
 
        box = mailbox_alloc(ns->list, name, MAILBOX_FLAG_SAVEONLY);
+       mailbox_set_reason(*box_r, ctx->ctx.cmd->name);
        if (mailbox_create(box, NULL, FALSE) < 0) {
                errstr = mailbox_get_last_internal_error(box, &error);
                if (error != MAIL_ERROR_EXISTS) {
index 2656dece8c88dca77ac9beede4b0e90ca3b7ecbe..a16622436a3dfcb7b6a60cf28e36033f1b058e83 100644 (file)
@@ -106,6 +106,7 @@ cmd_index_box(struct index_cmd_context *ctx, const struct mailbox_info *info)
 
        box = mailbox_alloc(info->ns->list, info->vname,
                            MAILBOX_FLAG_IGNORE_ACLS);
+       mailbox_set_reason(box, ctx->ctx.cmd->name);
        if (ctx->max_recent_msgs != 0) {
                /* index only if there aren't too many recent messages.
                   don't bother syncing the mailbox, that alone can take a
index 44186aaab03ca7f437308159abab65189f612ad2..a348c285c01e5fc15657618094d4d9bd2b010d47 100644 (file)
@@ -37,6 +37,7 @@ int doveadm_mail_iter_init(struct doveadm_mail_cmd_context *ctx,
        iter->ctx = ctx;
        iter->box = mailbox_alloc(info->ns->list, info->vname,
                                  MAILBOX_FLAG_IGNORE_ACLS | readonly_flag);
+       mailbox_set_reason(iter->box, ctx->cmd->name);
        iter->search_args = search_args;
 
        if (mailbox_sync(iter->box, MAILBOX_SYNC_FLAG_FULL_READ) < 0) {
index c3ed7482a8e397ac85c08afd7307a435aeeeb06d..357adef38166d8ab0b2e60ab1f1940b3fee024ba 100644 (file)
@@ -46,6 +46,7 @@ cmd_mailbox_metadata_open_mailbox(struct metadata_cmd_context *mctx,
                *ns_r = mail_namespace_find(user->namespaces, mctx->mailbox);
                *box_r = mailbox_alloc((*ns_r)->list, mctx->mailbox, 0);
        }
+       mailbox_set_reason(*box_r, mctx->ctx.cmd->name);
 
        if (mailbox_open(*box_r) < 0) {
                i_error("Failed to open mailbox: %s",
index 316bbd47be5b18d2bd611c5c3a3bc371c8cbf33b..eb91542f5ddb6b89639413d448407cf8921e6c0f 100644 (file)
@@ -127,6 +127,7 @@ status_mailbox(struct status_cmd_context *ctx, const struct mailbox_info *info)
        struct mailbox_metadata metadata;
 
        box = doveadm_mailbox_find(ctx->ctx.cur_mail_user, info->vname);
+       mailbox_set_reason(box, ctx->ctx.cmd->name);
        if (mailbox_get_status(box, ctx->status_items, &status) < 0 ||
            mailbox_get_metadata(box, ctx->metadata_items, &metadata) < 0) {
                i_error("Mailbox %s: Failed to lookup mailbox status: %s",
index c4dbca8a592b41955ffc276acdc9b8ea44632ca9..b7b5c52d1142267568de6724cec4881e50deda58 100644 (file)
@@ -242,6 +242,7 @@ cmd_mailbox_create_run(struct doveadm_mail_cmd_context *_ctx,
                }
 
                box = mailbox_alloc(ns->list, name, 0);
+               mailbox_set_reason(box, _ctx->cmd->name);
                if (mailbox_create(box, &ctx->update, directory) < 0) {
                        i_error("Can't create mailbox %s: %s", name,
                                mailbox_get_last_internal_error(box, NULL));
@@ -372,6 +373,7 @@ cmd_mailbox_delete_run(struct doveadm_mail_cmd_context *_ctx,
 
                ns = mail_namespace_find(user->namespaces, name);
                box = mailbox_alloc(ns->list, name, mailbox_flags);
+               mailbox_set_reason(box, _ctx->cmd->name);
                storage = mailbox_get_storage(box);
                ret2 = ctx->require_empty ? mailbox_delete_empty(box) :
                        mailbox_delete(box);
@@ -464,6 +466,8 @@ cmd_mailbox_rename_run(struct doveadm_mail_cmd_context *_ctx,
        newns = mail_namespace_find(user->namespaces, newname);
        oldbox = mailbox_alloc(oldns->list, oldname, 0);
        newbox = mailbox_alloc(newns->list, newname, 0);
+       mailbox_set_reason(oldbox, _ctx->cmd->name);
+       mailbox_set_reason(newbox, _ctx->cmd->name);
        if (mailbox_rename(oldbox, newbox) < 0) {
                i_error("Can't rename mailbox %s to %s: %s", oldname, newname,
                        mailbox_get_last_internal_error(oldbox, NULL));
@@ -528,6 +532,7 @@ cmd_mailbox_subscribe_run(struct doveadm_mail_cmd_context *_ctx,
 
                ns = mail_namespace_find(user->namespaces, name);
                box = mailbox_alloc(ns->list, name, 0);
+               mailbox_set_reason(box, _ctx->cmd->name);
                if (mailbox_set_subscribed(box, ctx->ctx.subscriptions) < 0) {
                        i_error("Can't %s mailbox %s: %s", name,
                                ctx->ctx.subscriptions ? "subscribe to" :
@@ -655,6 +660,7 @@ int cmd_mailbox_update_run(struct doveadm_mail_cmd_context *_ctx,
 
        ns = mail_namespace_find(user->namespaces, ctx->mailbox);
        box = mailbox_alloc(ns->list, ctx->mailbox, 0);
+       mailbox_set_reason(box, _ctx->cmd->name);
 
        if ((ret = mailbox_update(box, &(ctx->update))) != 0) {
                i_error("Cannot update %s: %s",
index 5badfdb7c03320358f1995be1f516f005a3489ab..3481f619a26c86a0c2bd9236201da9d2d8b55bf3 100644 (file)
@@ -90,6 +90,7 @@ cmd_save_run(struct doveadm_mail_cmd_context *_ctx, struct mail_user *user)
 
        ns = mail_namespace_find(user->namespaces, ctx->mailbox);
        box = mailbox_alloc(ns->list, ctx->mailbox, MAILBOX_FLAG_SAVEONLY);
+       mailbox_set_reason(box, _ctx->cmd->name);
        ret = cmd_save_to_mailbox(ctx, box, _ctx->cmd_input);
        mailbox_free(&box);
        return ret;
index 639ca4f7c7ae85f0079274d4b24e4263fa93045d..5549f09c55afe156e29c231b67652be8d249962e 100644 (file)
@@ -285,6 +285,7 @@ static int cmd_force_resync_box(struct doveadm_mail_cmd_context *ctx,
 
        box = mailbox_alloc(info->ns->list, info->vname,
                            MAILBOX_FLAG_IGNORE_ACLS);
+       mailbox_set_reason(box, ctx->cmd->name);
        if (mailbox_open(box) < 0) {
                i_error("Opening mailbox %s failed: %s", info->vname,
                        mailbox_get_last_internal_error(box, NULL));
index 36cfbc6b846ea4a8085134edb117f5e7bd570bc0..f581c304163ba08633ef7437bd0f8909c974552a 100644 (file)
@@ -38,6 +38,7 @@ bool cmd_create(struct client_command_context *cmd)
        }
 
        box = mailbox_alloc(ns->list, mailbox, 0);
+       mailbox_set_reason(box, "CREATE");
        if (mailbox_create(box, NULL, directory) < 0)
                client_send_box_error(cmd, box);
        else
index 17b077851b52051e8af0478ba4bc6852431053ca..4e34c1d0d337406495f456d77e730869dcc1168f 100644 (file)
@@ -21,6 +21,7 @@ bool cmd_delete(struct client_command_context *cmd)
                return TRUE;
 
        box = mailbox_alloc(ns->list, name, 0);
+       mailbox_set_reason(box, "DELETE");
        if (mailbox_is_any_inbox(box)) {
                /* IMAP protocol allows this, but I think it's safer to
                   not allow it. */
index 917979524d65cbb7ad09f1141e2834383dd241ab..9635a6cef4f67fc6469513cf13cafdd2e0d87b77 100644 (file)
@@ -410,6 +410,7 @@ cmd_getmetadata_try_mailbox(struct imap_getmetadata_context *ctx,
                            struct mail_namespace *ns, const char *mailbox)
 {
        ctx->box = mailbox_alloc(ns->list, mailbox, MAILBOX_FLAG_READONLY);
+       mailbox_set_reason(ctx->box, "GETMETADATA");
        if (mailbox_open(ctx->box) < 0)
                return -1;
 
index 3d04873b3e2f80d0b4b8cd9ed7d87da389221b87..4c6aad975a3eee480d6f8e99983fed73810fd18a 100644 (file)
@@ -417,6 +417,7 @@ imap_notify_box_send_status(struct client_command_context *cmd,
                items.status |= STATUS_HIGHESTMODSEQ;
 
        box = mailbox_alloc(info->ns->list, info->vname, MAILBOX_FLAG_READONLY);
+       mailbox_set_reason(box, "NOTIFY send STATUS");
        if (ctx->client->enabled_features != 0)
                (void)mailbox_enable(box, ctx->client->enabled_features);
 
index f9369e8f523b40e6ccaeefcb372faa9dca8d2032..f74561bcc994e48ecf3b43b93bb91a7326880be8 100644 (file)
@@ -37,6 +37,8 @@ bool cmd_rename(struct client_command_context *cmd)
 
        old_box = mailbox_alloc(old_ns->list, oldname, 0);
        new_box = mailbox_alloc(new_ns->list, newname, 0);
+       mailbox_set_reason(old_box, "RENAME from");
+       mailbox_set_reason(new_box, "RENAME to");
        if (mailbox_rename(old_box, new_box) < 0)
                client_send_box_error(cmd, old_box);
        else
index bbac12c1c4f0849719284644f17e964e1b035b49..3ab164e4872339f6531fd0e84d57bbfd7cb017b0 100644 (file)
@@ -49,6 +49,7 @@ cmd_resetkey_mailbox(struct client_command_context *cmd,
 
        /* open mailbox */
        box = mailbox_alloc(ns->list, mailbox, flags);
+       mailbox_set_reason(box, "RESETKEY");
        if (mailbox_open(box) < 0) {
                client_send_box_error(cmd, box);
                mailbox_free(&box);
index bac30fc2e96086e308b1cc4b8e2bd71b39235cf5..73dab9a0e5dac6f4216a1de4584c6449154b4f48 100644 (file)
@@ -291,6 +291,7 @@ select_open(struct imap_select_context *ctx, const char *mailbox, bool readonly)
        else
                flags |= MAILBOX_FLAG_DROP_RECENT;
        ctx->box = mailbox_alloc(ctx->ns->list, mailbox, flags);
+       mailbox_set_reason(ctx->box, readonly ? "EXAMINE" : "SELECT");
        if (mailbox_open(ctx->box) < 0) {
                client_send_box_error(ctx->cmd, ctx->box);
                mailbox_free(&ctx->box);
index a89aab9e5273f80fe5bde4158d470e783a35aef4..6182a8b63fc5c01634e2d6e71aa272ed1c7e327e 100644 (file)
@@ -304,6 +304,7 @@ cmd_setmetadata_mailbox(struct imap_setmetadata_context *ctx,
                ctx->box = client->mailbox;
        else {
                ctx->box = mailbox_alloc(ns->list, mailbox, 0);
+               mailbox_set_reason(ctx->box, "SETMETADATA");
                if (mailbox_open(ctx->box) < 0) {
                        client_send_box_error(cmd, ctx->box);
                        mailbox_free(&ctx->box);
index c8e1c02bcb0ac778668901a15cfa89e04fd4ef95..40b6a2d149575e61c93102972ebfa6301f1972b4 100644 (file)
@@ -49,6 +49,7 @@ bool cmd_subscribe_full(struct client_command_context *cmd, bool subscribe)
                return TRUE;
 
        box = mailbox_alloc(ns->list, mailbox, 0);
+       mailbox_set_reason(box, subscribe ? "SUBSCRIBE" : "UNSUBSCRIBE");
        if (subscribe) {
                if (!subscribe_is_valid_name(cmd, box)) {
                        mailbox_free(&box);
@@ -64,6 +65,7 @@ bool cmd_subscribe_full(struct client_command_context *cmd, bool subscribe)
                /* try to unsubscribe both "box" and "box/" */
                const char *name2 = t_strdup_printf("%s%c", mailbox, sep);
                box2 = mailbox_alloc(ns->list, name2, 0);
+               mailbox_set_reason(box2, "UNSUBSCRIBE");
                if (mailbox_set_subscribed(box2, FALSE) == 0)
                        unsubscribed_mailbox2 = TRUE;
                mailbox_free(&box2);
index 8e8c04d8f141f6d7fc6b441d0e10e015534acfc7..d18361e40d5fc5927047d4b9b3ac03084cadb799 100644 (file)
@@ -109,6 +109,7 @@ int client_open_save_dest_box(struct client_command_context *cmd,
                return 0;
        }
        box = mailbox_alloc(ns->list, name, MAILBOX_FLAG_SAVEONLY);
+       mailbox_set_reason(box, cmd->name);
        if (mailbox_open(box) < 0) {
                error_string = mailbox_get_last_error(box, &error);
                if (error == MAIL_ERROR_NOTFOUND) {
index 4eef79d381358890843430b609f6f6b00f6defb7..c2020166db15cfd7b7e58f5dc695424c76e1071f 100644 (file)
@@ -57,6 +57,7 @@ static int imap_notify_status(struct imap_notify_namespace *notify_ns,
                items.status |= STATUS_HIGHESTMODSEQ;
 
        box = mailbox_alloc(notify_ns->ns->list, rec->vname, 0);
+       mailbox_set_reason(box, "NOTIFY STATUS");
        if ((rec->events & MAILBOX_LIST_NOTIFY_UIDVALIDITY) != 0) {
                items.status |= STATUS_UIDVALIDITY | STATUS_UIDNEXT |
                        STATUS_MESSAGES | STATUS_UNSEEN;
@@ -197,6 +198,7 @@ bool imap_notify_match_mailbox(struct imap_notify_namespace *notify_ns,
        switch (notify_boxes->type) {
        case IMAP_NOTIFY_TYPE_SUBSCRIBED:
                box = mailbox_alloc(notify_ns->ns->list, vname, 0);
+               mailbox_set_reason(box, "NOTIFY is subscribed");
                ret = mailbox_is_subscribed(box);
                mailbox_free(&box);
                return ret;
index 02722aef64ad928c47ca86d6ff13cb01e79a3f61..e8bccb3fc3c9c6d982fb3485b031a5bad66117f8 100644 (file)
@@ -573,6 +573,7 @@ import_state_mailbox_open(struct client *client,
        else
                flags |= MAILBOX_FLAG_DROP_RECENT;
        box = mailbox_alloc(ns->list, state->vname, flags);
+       mailbox_set_reason(box, "unhibernate");
        if (mailbox_open(box) < 0) {
                *error_r = t_strdup_printf("Couldn't open mailbox: %s",
                        mailbox_get_last_internal_error(box, NULL));
index b3ca1faa580c8b7d1e6ed0a7aa99cb2f290b6c3d..13e4512e85872acb95ffae2bbbcae0436192a804 100644 (file)
@@ -74,6 +74,7 @@ int imap_status_get(struct client_command_context *cmd,
        } else {
                /* open the mailbox */
                box = mailbox_alloc(ns->list, mailbox, MAILBOX_FLAG_READONLY);
+               mailbox_set_reason(box, "STATUS");
                if (client->enabled_features != 0)
                        (void)mailbox_enable(box, client->enabled_features);
        }
index 9ca4560501336290d2becfbdeef694c5a84d468c..a1be841f77c7954261398afdb472d9572e39f4d6 100644 (file)
@@ -142,6 +142,7 @@ index_mailbox(struct master_connection *conn, struct mail_user *user,
 
        ns = mail_namespace_find(user->namespaces, mailbox);
        box = mailbox_alloc(ns->list, mailbox, 0);
+       mailbox_set_reason(box, "indexing");
        ret = mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_INDEX, &path);
        if (ret < 0) {
                i_error("Getting path to mailbox %s failed: %s",
index 38fa0e73b3c8a6408852a4a4ceffb8e03faca173..5097add7ddf2062839e12136e0d18b5976b1be35 100644 (file)
@@ -244,6 +244,7 @@ imap_metadata_transaction_begin_server(struct mail_user *user)
 
        ns = mail_namespace_find_inbox(user->namespaces);
        box = mailbox_alloc(ns->list, "INBOX", 0);
+       mailbox_set_reason(box, "Server METADATA");
        imtrans = imap_metadata_transaction_begin(box);
        imtrans->server = TRUE;
        return imtrans;
index afb83b4999d3c018ab1e786dc1cc2aefcf9ad813..319f74559f79fbd98f496777e2100645ecb090fb 100644 (file)
@@ -129,8 +129,10 @@ int imap_msgpart_url_open_mailbox(struct imap_msgpart_url *mpurl,
        if (mpurl->selected_box != NULL &&
            mailbox_equals(mpurl->selected_box, ns, mpurl->mailbox))
                box = mpurl->selected_box;
-       else
+       else {
                box = mailbox_alloc(ns->list, mpurl->mailbox, flags);
+               mailbox_set_reason(box, "Read IMAP URL");
+       }
        if (mailbox_open(box) < 0) {
                *error_r = mail_storage_get_last_error(mailbox_get_storage(box),
                                                       error_code_r);
index 783f9dcfd42032b013a06ee11bee7b4796e8ccaa..49bcc4580f386ee639fdd96e79a7d2b7c7b1b94e 100644 (file)
@@ -132,6 +132,7 @@ int imap_urlauth_backend_reset_all_keys(struct mail_user *user)
                                                 MAILBOX_LIST_ITER_RETURN_NO_FLAGS);
        while ((info = mailbox_list_iter_next(iter)) != NULL) {
                box = mailbox_alloc(info->ns->list, info->vname, 0);
+               mailbox_set_reason(box, "URLAUTH reset all keys");
                if (imap_urlauth_backend_mailbox_reset_key(box) < 0)
                        ret = -1;
                mailbox_free(&box);
index fcca8c6edc3ed5981c56e8b9f873bc17cbfaace1..42822d4f2028049356b68539c106559612d85602 100644 (file)
@@ -230,6 +230,7 @@ int mail_deliver_save_open(struct mail_deliver_save_open_context *ctx,
        }
 
        *box_r = box = mailbox_alloc(ns->list, name, flags);
+       mailbox_set_reason(box, "lib-lda delivery");
        /* flag that this mailbox is used for delivering the mail.
           the context isn't set in pigeonhole testuite. */
        struct mail_deliver_mailbox *mbox = MAIL_DELIVER_STORAGE_CONTEXT(box);
@@ -574,6 +575,7 @@ mail_deliver_cache_update_post_commit(struct mailbox *orig_box, uint32_t uid)
           synced, so it'll contain the newly written mail. this is racy, so
           it's possible another process has already deleted the mail. */
        box = mailbox_alloc(orig_box->list, orig_box->vname, 0);
+       mailbox_set_reason(box, "lib-lda storage-id");
 
        mail = mail_deliver_open_mail(box, uid, MAIL_FETCH_STORAGE_ID, &t);
        if (mail != NULL) {
index 7c7e99b1119fd69f1496316cbf47bf66c9dd35b4..ffdafa2d1a4a54280c15f6db2d09fe8e01197e67 100644 (file)
@@ -551,6 +551,7 @@ rebuild_mailbox(struct mdbox_storage_rebuild_context *ctx,
 
        box = mailbox_alloc(ns->list, vname, MAILBOX_FLAG_READONLY |
                            MAILBOX_FLAG_IGNORE_ACLS);
+       mailbox_set_reason(box, "mdbox rebuild");
        if (box->storage != &ctx->storage->storage.storage) {
                /* the namespace has multiple storages. */
                mailbox_free(&box);
@@ -703,6 +704,7 @@ static int rebuild_restore_msg(struct mdbox_storage_rebuild_context *ctx,
                box = mailbox_alloc(ctx->default_list, mailbox,
                                    MAILBOX_FLAG_READONLY |
                                    MAILBOX_FLAG_IGNORE_ACLS);
+               mailbox_set_reason(box, "mdbox rebuild restore");
                i_assert(box->storage == storage);
                if (mailbox_open(box) == 0)
                        break;
index eec43bb00a4f2e6ba307066773c6973fc4a4cb7b..1c4a626692d29c1e3adf9cd43a8d88ec417610e4 100644 (file)
@@ -156,6 +156,7 @@ mailbox_autoexpunge_set(struct mail_namespace *ns, const char *vname,
           any ACLs the user might normally have against expunging in
           the mailbox. */
        box = mailbox_alloc(ns->list, vname, MAILBOX_FLAG_IGNORE_ACLS);
+       mailbox_set_reason(box, "autoexpunge");
        if (mailbox_autoexpunge(box, autoexpunge, autoexpunge_max_mails,
                                expunged_count) < 0) {
                i_error("Failed to autoexpunge mailbox '%s': %s",
index 03eafb23caab250003d8605bb3892003a8ba4955..782056fb1daf485d8a1ea067d5cf28b12b1bd639 100644 (file)
@@ -1389,6 +1389,7 @@ static void mailbox_copy_cache_decisions_from_inbox(struct mailbox *box)
 
        /* this should be NoSelect but since inbox can never be
           NoSelect we use EXISTENCE_NONE to avoid creating inbox by accident */
+       mailbox_set_reason(inbox, "copy caching decisions");
        if (mailbox_exists(inbox, FALSE, &existence) == 0 &&
            existence != MAILBOX_EXISTENCE_NONE &&
            mailbox_open(inbox) == 0 &&
index f0abf29dc804f88d5105546a35f41773b43aac5e..d0a687304dbdd3904c1e306a0c5d29789e44a97d 100644 (file)
@@ -583,6 +583,7 @@ lmtp_rcpt_to_is_over_quota(struct client *client,
 
        ns = mail_namespace_find_inbox(user->namespaces);
        box = mailbox_alloc(ns->list, "INBOX", 0);
+       mailbox_set_reason(box, "over-quota check");
        ret = mailbox_get_status(box, STATUS_CHECK_OVER_QUOTA, &status);
        if (ret < 0) {
                errstr = mailbox_get_last_error(box, &error);
index b7dd0e297b0958460874e61163dd951c2f257df6..a9ed1d10de5fc4c822057cb4b35b8873a4d0fddf 100644 (file)
@@ -119,6 +119,7 @@ mailbox_open_or_create(struct mailbox_list *list, struct mailbox *src_box,
 
        box = mailbox_alloc(list, name, MAILBOX_FLAG_NO_INDEX_FILES |
                            MAILBOX_FLAG_SAVEONLY | MAILBOX_FLAG_IGNORE_ACLS);
+       mailbox_set_reason(box, "lazy_expunge");
        if (mailbox_open(box) == 0) {
                *error_r = NULL;
                return box;
index 4197afd64b2f0d711eb023a5e125e5c9d23e68c5..80bead91c82a81de816910c83733109937b4ea25 100644 (file)
@@ -311,12 +311,15 @@ static struct mailbox *pop3_mailbox_alloc(struct mail_storage *storage)
        struct pop3_migration_mail_storage *mstorage =
                POP3_MIGRATION_CONTEXT(storage);
        struct mail_namespace *ns;
+       struct mailbox *box;
 
        ns = mail_namespace_find(storage->user->namespaces,
                                 mstorage->pop3_box_vname);
        i_assert(ns != NULL);
-       return mailbox_alloc(ns->list, mstorage->pop3_box_vname,
-                            MAILBOX_FLAG_READONLY | MAILBOX_FLAG_POP3_SESSION);
+       box = mailbox_alloc(ns->list, mstorage->pop3_box_vname,
+                           MAILBOX_FLAG_READONLY | MAILBOX_FLAG_POP3_SESSION);
+       mailbox_set_reason(box, "pop3_migration");
+       return box;
 }
 
 static int pop3_map_read(struct mail_storage *storage, struct mailbox *pop3_box)
index 9410b69099f83a13be2b47b409b2a602fc8b8c01..21c2f08c62d125cf717bd0b8430ba94b09c720a3 100644 (file)
@@ -42,6 +42,7 @@ quota_count_mailbox(struct quota_root *root, struct mail_namespace *ns,
        }
 
        box = mailbox_alloc(ns->list, vname, MAILBOX_FLAG_READONLY);
+       mailbox_set_reason(box, "quota count");
        if ((box->storage->class_flags & MAIL_STORAGE_CLASS_FLAG_NOQUOTA) != 0) {
                /* quota doesn't exist for this mailbox/storage */
                ret = 0;
@@ -295,6 +296,7 @@ static int quota_count_recalculate(struct quota_root *root)
        iter = quota_mailbox_iter_begin(root);
        while ((info = quota_mailbox_iter_next(iter)) != NULL) {
                box = mailbox_alloc(info->ns->list, info->vname, 0);
+               mailbox_set_reason(box, "quota recalculate");
                if (quota_count_recalculate_box(box) < 0)
                        ret = -1;
                mailbox_free(&box);
index b1438ac0a704f35b4ad48b5a4a8ba2b0930c8b8a..762ef34a1551ea729780bb169240d039e3749031 100644 (file)
@@ -61,6 +61,7 @@ quota_check(struct mail_user *user, uoff_t mail_size, const char **error_r)
 
        ns = mail_namespace_find_inbox(user->namespaces);
        box = mailbox_alloc(ns->list, "INBOX", MAILBOX_FLAG_POST_SESSION);
+       mailbox_set_reason(box, "quota status");
 
        ctx = quota_transaction_begin(box);
        ret = quota_test_alloc(ctx, I_MAX(1, mail_size));
index a851be90f2d6f8d631f947877690c97f39e4a0d2..de10b995df219d3e91a96ae220c3f08a9a5cfeb1 100644 (file)
@@ -52,6 +52,7 @@ static int trash_clean_mailbox_open(struct trash_mailbox *trash)
        struct mail_search_args *search_args;
 
        trash->box = mailbox_alloc(trash->ns->list, trash->name, 0);
+       mailbox_set_reason(trash->box, "trash plugin");
        if (mailbox_open(trash->box) < 0) {
                mailbox_free(&trash->box);
                return 0;
index cd5e7a170dffb1dd706343ccd7e79b22933c69df..ed431cef9168af7d4ffa5338887bec0729e9e21b 100644 (file)
@@ -373,6 +373,7 @@ virtual_config_metadata_match(const struct mailbox_info *info,
                return 1;
 
        box = mailbox_alloc(info->ns->list, info->vname, MAILBOX_FLAG_READONLY);
+       mailbox_set_reason(box, "virtual mailbox metadata match");
        for (i = 0; i < count; i++) {
                if ((ret = virtual_config_box_metadata_match(box, boxes[i], error_r)) <= 0)
                        break;
index d8d410af36783a42b7fece11fcbafd476eacde2f..b05fc69dfc2c5f059fc9dcb8d1d6ed323c42d4c6 100644 (file)
@@ -192,6 +192,8 @@ static int virtual_backend_box_alloc(struct virtual_mailbox *mbox,
        ns = mail_namespace_find(user->namespaces, mailbox);
        bbox->box = mailbox_alloc(ns->list, mailbox, flags);
        MODULE_CONTEXT_SET(bbox->box, virtual_storage_module, bbox);
+       mailbox_set_reason(bbox->box, mbox->box.reason == NULL ? "virtual mailbox" :
+               t_strdup_printf("virtual mailbox: %s", mbox->box.reason));
 
        if (mailbox_exists(bbox->box, TRUE, &existence) < 0)
                return virtual_backend_box_open_failed(mbox, bbox);
index c9b5eec247f253a4bf85463aa695f18af04df495..22c9c768fd536b1534a1e198596bcb18a60091cc 100644 (file)
@@ -466,6 +466,7 @@ int client_init_mailbox(struct client *client, const char **error_r)
        if (!client->set->pop3_no_flag_updates)
                flags |= MAILBOX_FLAG_DROP_RECENT;
        client->mailbox = mailbox_alloc(client->inbox_ns->list, "INBOX", flags);
+       mailbox_set_reason(client->mailbox, "POP3 INBOX");
        if (mailbox_open(client->mailbox) < 0) {
                *error_r = t_strdup_printf("Couldn't open INBOX: %s",
                        mailbox_get_last_internal_error(client->mailbox, NULL));