From: Timo Sirainen Date: Thu, 26 Oct 2023 10:06:51 +0000 (+0300) Subject: lib-storage: Replace ITERINDEX with mailbox_list_iter_from_index_dir setting X-Git-Tag: 2.4.1~1250 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3d46701b0fb58843e75ead659edb60dfb8e0da9d;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: Replace ITERINDEX with mailbox_list_iter_from_index_dir setting This removes the check that INDEX must also be set. It's not really necessary, the setting's value just gets ignored then. --- diff --git a/src/lib-storage/index/dbox-common/dbox-storage.c b/src/lib-storage/index/dbox-common/dbox-storage.c index a01ad0423a..757e629c0b 100644 --- a/src/lib-storage/index/dbox-common/dbox-storage.c +++ b/src/lib-storage/index/dbox-common/dbox-storage.c @@ -255,7 +255,8 @@ int dbox_mailbox_check_existence(struct mailbox *box) } if (ret < 0) { ret = stat(box_path, &st); - } else if (ret == 0 && !box->list->set.iter_from_index_dir && + } else if (ret == 0 && + !box->list->mail_set->mailbox_list_iter_from_index_dir && *box->list->set.mailbox_dir_name == '\0') { /* There are index files for this mailbox and no separate mailboxes directory is configured. */ diff --git a/src/lib-storage/index/index-storage.c b/src/lib-storage/index/index-storage.c index b587b76f0c..c88b7566bf 100644 --- a/src/lib-storage/index/index-storage.c +++ b/src/lib-storage/index/index-storage.c @@ -216,7 +216,8 @@ int index_storage_mailbox_exists_full(struct mailbox *box, const char *subdir, return 0; } - ret = (subdir != NULL || !box->list->set.iter_from_index_dir) ? 0 : + ret = (subdir != NULL || + !box->list->mail_set->mailbox_list_iter_from_index_dir) ? 0 : mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_INDEX, &index_path); if (ret > 0 && strcmp(path, index_path) != 0) { /* index directory is different - prefer looking it up first @@ -660,7 +661,7 @@ int index_storage_mailbox_create(struct mailbox *box, bool directory) if ((ret = mailbox_mkdir(box, path, type)) < 0) return -1; - if (box->list->set.iter_from_index_dir) { + if (box->list->mail_set->mailbox_list_iter_from_index_dir) { /* need to also create the directory to index path or iteration won't find it. */ int ret2; @@ -1286,10 +1287,11 @@ int index_mailbox_fix_inconsistent_existence(struct mailbox *box, const char *index_path; struct stat st; - /* Could be a race condition or could be because ITERINDEX is used - and the index directory exists, but the storage directory doesn't. - Handle the existence inconsistency by creating this directory if - the index directory exists (don't bother checking if ITERINDEX is + /* Could be a race condition or could be because + mailbox_list_iter_from_index_dir=yes is used and the index directory + exists, but the storage directory doesn't. Handle the existence + inconsistency by creating this directory if the index directory + exists (don't bother checking if mailbox_list_iter_from_index_dir is set or not - it doesn't matter since either both dirs should exist or not). */ if (mailbox_get_path_to(box, MAILBOX_LIST_PATH_TYPE_INDEX, diff --git a/src/lib-storage/list/mailbox-list-delete.c b/src/lib-storage/list/mailbox-list-delete.c index d62993345a..b092a0ac74 100644 --- a/src/lib-storage/list/mailbox-list-delete.c +++ b/src/lib-storage/list/mailbox-list-delete.c @@ -278,10 +278,11 @@ void mailbox_list_delete_until_root(struct mailbox_list *list, const char *path, const char *root_dir, *p; size_t len; - if (list->set.iter_from_index_dir && + if (list->mail_set->mailbox_list_iter_from_index_dir && !list->mail_set->mailbox_list_drop_noselect && mailbox_list_path_is_index(list, type)) { - /* Don't auto-rmdir parent index directories with ITERINDEX. + /* Don't auto-rmdir parent index directories with + mailbox_list_iter_from_index_dir=yes. Otherwise it'll get us into inconsistent state with a \NoSelect mailbox in the mail directory but not in index directory. */ @@ -360,8 +361,8 @@ static int mailbox_list_try_delete(struct mailbox_list *list, const char *name, strcmp(index_path, path) == 0) { /* CONTROL dir is the same as INDEX dir, which we already deleted. We don't want to continue especially with - iter_from_index_dir=yes, because it could be deleting the - index directory. */ + mailbox_list_iter_from_index_dir=yes, because it could be + deleting the index directory. */ return 0; } diff --git a/src/lib-storage/list/mailbox-list-fs-flags.c b/src/lib-storage/list/mailbox-list-fs-flags.c index ed05f6b2e2..55be72f054 100644 --- a/src/lib-storage/list/mailbox-list-fs-flags.c +++ b/src/lib-storage/list/mailbox-list-fs-flags.c @@ -118,7 +118,8 @@ int fs_list_get_mailbox_flags(struct mailbox_list *list, *flags_r = 0; - if (*list->set.maildir_name != '\0' && !list->set.iter_from_index_dir) { + if (*list->set.maildir_name != '\0' && + !list->mail_set->mailbox_list_iter_from_index_dir) { /* maildir_name is set: This is the simple case that works for all mail storage formats, because the only thing that matters for existence or child checks is whether the @@ -136,7 +137,7 @@ int fs_list_get_mailbox_flags(struct mailbox_list *list, though maildir_name is set, it's not used for index directory. */ - if (!list->set.iter_from_index_dir && + if (!list->mail_set->mailbox_list_iter_from_index_dir && list->v.is_internal_name != NULL && list->v.is_internal_name(list, fname)) { /* skip internal dirs. For example Maildir's cur/new/tmp */ @@ -224,7 +225,8 @@ int fs_list_get_mailbox_flags(struct mailbox_list *list, return 1; } - if (list->v.is_internal_name == NULL || list->set.iter_from_index_dir) { + if (list->v.is_internal_name == NULL || + list->mail_set->mailbox_list_iter_from_index_dir) { /* This mailbox format doesn't use any special directories (e.g. Maildir's cur/new/tmp). In that case we can look at the directory's link count to determine whether there are diff --git a/src/lib-storage/list/mailbox-list-fs-iter.c b/src/lib-storage/list/mailbox-list-fs-iter.c index 8524d7c4ce..c594a042c2 100644 --- a/src/lib-storage/list/mailbox-list-fs-iter.c +++ b/src/lib-storage/list/mailbox-list-fs-iter.c @@ -532,7 +532,8 @@ fs_list_iter_init(struct mailbox_list *_list, const char *const *patterns, ctx->info_pool = pool_alloconly_create("fs list", 1024); ctx->sep = mail_namespace_get_sep(_list->ns); ctx->info.ns = _list->ns; - ctx->ctx.iter_from_index_dir = ctx->ctx.list->set.iter_from_index_dir; + ctx->ctx.iter_from_index_dir = + ctx->ctx.list->mail_set->mailbox_list_iter_from_index_dir; if ((flags & MAILBOX_LIST_ITER_FORCE_RESYNC) != 0) { i_assert(!hash_table_is_created(ctx->ctx.found_mailboxes)); diff --git a/src/lib-storage/list/mailbox-list-fs.c b/src/lib-storage/list/mailbox-list-fs.c index 2e1c0d1eb0..077fe1a2df 100644 --- a/src/lib-storage/list/mailbox-list-fs.c +++ b/src/lib-storage/list/mailbox-list-fs.c @@ -304,7 +304,7 @@ static int fs_list_delete_dir(struct mailbox_list *list, const char *name) &path) <= 0) i_unreached(); ret = fs_list_rmdir(list, name, path); - if (!list->set.iter_from_index_dir) { + if (!list->mail_set->mailbox_list_iter_from_index_dir) { /* it should exist only in the mail directory */ if (ret == 0) return 0; diff --git a/src/lib-storage/list/mailbox-list-maildir-iter.c b/src/lib-storage/list/mailbox-list-maildir-iter.c index c7108c6739..7cafac1f3e 100644 --- a/src/lib-storage/list/mailbox-list-maildir-iter.c +++ b/src/lib-storage/list/mailbox-list-maildir-iter.c @@ -443,7 +443,7 @@ maildir_list_iter_init(struct mailbox_list *_list, const char *const *patterns, ctx->prefix_char = strcmp(_list->name, MAILBOX_LIST_NAME_IMAPDIR) == 0 ? '\0' : list->sep; - if (_list->set.iter_from_index_dir) + if (_list->mail_set->mailbox_list_iter_from_index_dir) ctx->dir = _list->set.index_dir; else ctx->dir = _list->set.root_dir; diff --git a/src/lib-storage/mail-storage-settings.c b/src/lib-storage/mail-storage-settings.c index a04d60f00e..1ade2fe49f 100644 --- a/src/lib-storage/mail-storage-settings.c +++ b/src/lib-storage/mail-storage-settings.c @@ -76,6 +76,7 @@ static const struct setting_define mail_storage_setting_defines[] = { DEF(BOOL, mailbox_list_index), DEF(BOOL, mailbox_list_index_very_dirty_syncs), DEF(BOOL, mailbox_list_index_include_inbox), + DEF(BOOL_HIDDEN, mailbox_list_iter_from_index_dir), DEF(BOOL_HIDDEN, mailbox_list_drop_noselect), DEF(BOOL_HIDDEN, mailbox_list_validate_fs_names), DEF(BOOL_HIDDEN, mail_full_filesystem_access), @@ -138,6 +139,7 @@ const struct mail_storage_settings mail_storage_default_settings = { .mailbox_list_index = TRUE, .mailbox_list_index_very_dirty_syncs = FALSE, .mailbox_list_index_include_inbox = FALSE, + .mailbox_list_iter_from_index_dir = FALSE, .mailbox_list_drop_noselect = TRUE, .mailbox_list_validate_fs_names = TRUE, .mail_full_filesystem_access = FALSE, @@ -925,6 +927,7 @@ bool mail_user_set_get_postmaster_smtp(const struct mail_user_settings *set, #define OFFSET(name) offsetof(struct mail_storage_settings, name) static const size_t mail_storage_2nd_reset_offsets[] = { OFFSET(mail_location), + OFFSET(mailbox_list_iter_from_index_dir), }; static void diff --git a/src/lib-storage/mail-storage-settings.h b/src/lib-storage/mail-storage-settings.h index 7e98f1d856..029a88593d 100644 --- a/src/lib-storage/mail-storage-settings.h +++ b/src/lib-storage/mail-storage-settings.h @@ -55,6 +55,7 @@ struct mail_storage_settings { bool mailbox_list_index; bool mailbox_list_index_very_dirty_syncs; bool mailbox_list_index_include_inbox; + bool mailbox_list_iter_from_index_dir; bool mailbox_list_drop_noselect; bool mailbox_list_validate_fs_names; bool mail_full_filesystem_access; diff --git a/src/lib-storage/mail-storage.c b/src/lib-storage/mail-storage.c index b9169ab98a..dc25ca884b 100644 --- a/src/lib-storage/mail-storage.c +++ b/src/lib-storage/mail-storage.c @@ -280,7 +280,7 @@ mail_storage_create_root(struct mailbox_list *list, const char *root_dir, *type_name, *error; enum mailbox_list_path_type type; - if (list->set.iter_from_index_dir) { + if (list->mail_set->mailbox_list_iter_from_index_dir) { type = MAILBOX_LIST_PATH_TYPE_INDEX; type_name = "index"; } else { diff --git a/src/lib-storage/mailbox-list.c b/src/lib-storage/mailbox-list.c index aecce65aed..d3def28a61 100644 --- a/src/lib-storage/mailbox-list.c +++ b/src/lib-storage/mailbox-list.c @@ -189,7 +189,6 @@ int mailbox_list_create(const char *driver, struct event *event, list->set.volatile_dir = p_strdup(list->pool, set->volatile_dir); list->set.index_control_use_maildir_name = set->index_control_use_maildir_name; - list->set.iter_from_index_dir = set->iter_from_index_dir; if (*set->mailbox_dir_name == '\0') list->set.mailbox_dir_name = ""; @@ -365,9 +364,6 @@ mailbox_list_settings_parse_full(struct mail_user *user, const char *data, } set_r->vname_escape_char = value[0]; continue; - } else if (strcmp(key, "ITERINDEX") == 0) { - set_r->iter_from_index_dir = TRUE; - continue; } else { *error_r = t_strdup_printf("Unknown setting: %s", key); return -1; @@ -380,11 +376,6 @@ mailbox_list_settings_parse_full(struct mail_user *user, const char *data, if (set_r->index_dir != NULL && strcmp(set_r->index_dir, "MEMORY") == 0) set_r->index_dir = ""; - if (set_r->iter_from_index_dir && - (set_r->index_dir == NULL || set_r->index_dir[0] == '\0')) { - *error_r = "ITERINDEX requires INDEX to be explicitly set"; - return -1; - } if (set_r->list_index_fname != NULL && (fname = strrchr(set_r->list_index_fname, '/')) != NULL) { /* non-default LISTINDEX directory */ @@ -1014,7 +1005,7 @@ mailbox_list_get_permissions_internal(struct mailbox_list *list, permissions_r->file_create_gid = (gid_t)-1; permissions_r->file_create_gid_origin = "defaults"; - if (list->set.iter_from_index_dir || + if (list->mail_set->mailbox_list_iter_from_index_dir || (list->flags & MAILBOX_LIST_FLAG_NO_MAIL_FILES) != 0) { /* a) iterating from index dir. Use the index dir's permissions as well, since they might be in a faster storage. @@ -1600,7 +1591,7 @@ int mailbox_list_mailbox(struct mailbox_list *list, const char *name, return mailbox_list_iter_deinit(&iter); } - if (!list->set.iter_from_index_dir) { + if (!list->mail_set->mailbox_list_iter_from_index_dir) { rootdir = mailbox_list_get_root_forced(list, MAILBOX_LIST_PATH_TYPE_MAILBOX); if (mailbox_list_get_path(list, name, MAILBOX_LIST_PATH_TYPE_DIR, &path) <= 0) i_unreached(); diff --git a/src/lib-storage/mailbox-list.h b/src/lib-storage/mailbox-list.h index c1884d2918..689eb4d833 100644 --- a/src/lib-storage/mailbox-list.h +++ b/src/lib-storage/mailbox-list.h @@ -175,11 +175,6 @@ struct mailbox_list_settings { have been the default since the beginning, but for backwards compatibility it had to be made an option. */ bool index_control_use_maildir_name:1; - /* Perform mailbox iteration using the index directory instead of the - mail root directory. This can be helpful if the indexes are on a - faster storage. This could perhaps be made the default at some point, - but for now since it's less tested it's optional. */ - bool iter_from_index_dir:1; }; struct mailbox_permissions {