From: Marco Bettini Date: Thu, 7 Jul 2022 08:01:09 +0000 (+0000) Subject: lib-storage: index/dbox-multi - Replace i_() with e_() X-Git-Tag: 2.4.0~3711 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c5fa973d1dcf745b4ebdf4793f7d1cdca926340a;p=thirdparty%2Fdovecot%2Fcore.git lib-storage: index/dbox-multi - Replace i_() with e_() --- diff --git a/src/lib-storage/index/dbox-multi/mdbox-file.c b/src/lib-storage/index/dbox-multi/mdbox-file.c index 65138bd421..6411dd4dea 100644 --- a/src/lib-storage/index/dbox-multi/mdbox-file.c +++ b/src/lib-storage/index/dbox-multi/mdbox-file.c @@ -102,6 +102,7 @@ mdbox_file_init_paths(struct mdbox_file *file, const char *fname, bool alt) static int mdbox_file_create(struct mdbox_file *file) { struct dbox_file *_file = &file->file; + struct event *event = _file->storage->storage.event; bool create_parents; int ret; @@ -121,7 +122,7 @@ static int mdbox_file_create(struct mdbox_file *file) /* ignore */ break; default: - i_error("file_preallocate(%s) failed: %m", + e_error(event, "file_preallocate(%s) failed: %m", _file->cur_path); break; } diff --git a/src/lib-storage/index/dbox-multi/mdbox-map-private.h b/src/lib-storage/index/dbox-multi/mdbox-map-private.h index 259d854844..bca38d5af7 100644 --- a/src/lib-storage/index/dbox-multi/mdbox-map-private.h +++ b/src/lib-storage/index/dbox-multi/mdbox-map-private.h @@ -11,6 +11,7 @@ struct dbox_mail_lookup_rec { struct mdbox_map { struct mdbox_storage *storage; + struct event *event; const struct mdbox_settings *set; char *path, *index_path; diff --git a/src/lib-storage/index/dbox-multi/mdbox-map.c b/src/lib-storage/index/dbox-multi/mdbox-map.c index 67d20831a8..978223e64d 100644 --- a/src/lib-storage/index/dbox-multi/mdbox-map.c +++ b/src/lib-storage/index/dbox-multi/mdbox-map.c @@ -71,6 +71,12 @@ mdbox_map_init(struct mdbox_storage *storage, struct mailbox_list *root_list) sizeof(uint32_t)); map->ref_ext_id = mail_index_ext_register(map->index, "ref", 0, sizeof(uint16_t), sizeof(uint16_t)); + + map->event = event_create(storage->storage.storage.event); + event_drop_parent_log_prefixes(map->event, 1); + event_set_append_log_prefix(map->event, t_strdup_printf( + "mdbox(%s): ", map->path)); + return map; } @@ -85,6 +91,7 @@ void mdbox_map_deinit(struct mdbox_map **_map) mail_index_close(map->index); } mail_index_free(&map->index); + event_unref(&map->event); i_free(map->index_path); i_free(map->path); i_free(map); @@ -477,6 +484,7 @@ static void mdbox_map_sync_handle(struct mdbox_map *map, struct mail_index_sync_ctx *sync_ctx) { + struct event *event = map->event; struct mail_index_sync_rec sync_rec; uint32_t seq1, seq2; uoff_t offset1, offset2; @@ -484,9 +492,9 @@ mdbox_map_sync_handle(struct mdbox_map *map, mail_index_sync_get_offsets(sync_ctx, &seq1, &offset1, &seq2, &offset2); if (offset1 != offset2 || seq1 != seq2) { /* something had crashed. need a full resync. */ - i_warning("mdbox %s: Inconsistency in map index " + e_warning(event, "Inconsistency in map index " "(%u,%"PRIuUOFF_T" != %u,%"PRIuUOFF_T")", - map->path, seq1, offset1, seq2, offset2); + seq1, offset1, seq2, offset2); mdbox_storage_set_corrupted(map->storage); } while (mail_index_sync_next(sync_ctx, &sync_rec)) ; @@ -844,6 +852,7 @@ mdbox_map_file_try_append(struct mdbox_map_append_context *ctx, { struct mdbox_map *map = ctx->map; struct mdbox_storage *storage = map->storage; + struct event *event = map->event; struct dbox_file *file; struct dbox_file_append_context *file_append; struct stat st; @@ -867,7 +876,7 @@ mdbox_map_file_try_append(struct mdbox_map_append_context *ctx, *retry_later_r = ret == 0; } else if (stat(file->cur_path, &st) < 0) { if (errno != ENOENT) - i_error("stat(%s) failed: %m", file->cur_path); + e_error(event, "stat(%s) failed: %m", file->cur_path); /* the file was unlinked between opening and locking it. */ } else if (st.st_size != rec->offset + rec->size && /* check if there's any garbage at the end of file. @@ -1187,6 +1196,7 @@ void mdbox_map_append_abort(struct mdbox_map_append_context *ctx) static int mdbox_find_highest_file_id(struct mdbox_map *map, uint32_t *file_id_r) { + struct event *event = map->event; const size_t prefix_len = strlen(MDBOX_MAIL_FILE_PREFIX); DIR *dir; struct dirent *d; @@ -1194,7 +1204,7 @@ mdbox_find_highest_file_id(struct mdbox_map *map, uint32_t *file_id_r) dir = opendir(map->path); if (dir == NULL) { - i_error("opendir(%s) failed: %m", map->path); + e_error(event, "opendir(%s) failed: %m", map->path); return -1; } while ((d = readdir(dir)) != NULL) { diff --git a/src/lib-storage/index/dbox-multi/mdbox-purge.c b/src/lib-storage/index/dbox-multi/mdbox-purge.c index 60508e315a..1eca969677 100644 --- a/src/lib-storage/index/dbox-multi/mdbox-purge.c +++ b/src/lib-storage/index/dbox-multi/mdbox-purge.c @@ -130,6 +130,7 @@ static int mdbox_metadata_get_extrefs(struct dbox_file *file, pool_t ext_refs_pool, ARRAY_TYPE(mail_attachment_extref) *extrefs) { + struct event *event = file->storage->storage.event; struct dbox_metadata_header meta_hdr; const char *line; size_t buf_size; @@ -150,7 +151,7 @@ mdbox_metadata_get_extrefs(struct dbox_file *file, pool_t ext_refs_pool, if (*line == DBOX_METADATA_EXT_REF) T_BEGIN { if (!index_attachment_parse_extrefs(line+1, ext_refs_pool, extrefs)) { - i_warning("%s: Ignoring corrupted extref: %s", + e_warning(event, "%s: Ignoring corrupted extref: %s", file->cur_path, line); } } T_END; diff --git a/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c b/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c index b4ebbdd77b..3db6be2ff7 100644 --- a/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c +++ b/src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c @@ -142,6 +142,7 @@ static void rebuild_scan_metadata(struct mdbox_storage_rebuild_context *ctx, static int rebuild_file_mails(struct mdbox_storage_rebuild_context *ctx, struct dbox_file *file, uint32_t file_id) { + struct event *event = file->storage->storage.event; const char *guid; uint8_t *guid_p; struct mdbox_rebuild_msg *rec, *old_rec; @@ -217,12 +218,12 @@ static int rebuild_file_mails(struct mdbox_storage_rebuild_context *ctx, rec->seen_zero_ref_in_map = TRUE; } else { /* duplicate GUID, but not a duplicate message. */ - i_error("mdbox %s: Duplicate GUID %s in " + e_error(event, "Duplicate GUID %s in " "m.%u:%u (size=%"PRIuUOFF_T") and m.%u:%u " "(size=%"PRIuUOFF_T")", - ctx->storage->storage_dir, guid, - old_rec->file_id, old_rec->offset, old_rec->mail_size, - rec->file_id, rec->offset, rec->mail_size); + guid, old_rec->file_id, old_rec->offset, + old_rec->mail_size, rec->file_id, rec->offset, + rec->mail_size); rec->guid_hash_next = old_rec->guid_hash_next; old_rec->guid_hash_next = rec; } @@ -239,6 +240,7 @@ static int rebuild_rename_file(struct mdbox_storage_rebuild_context *ctx, const char *dir, const char **fname_p, uint32_t *file_id_r) { + struct event *event = ctx->storage->storage.storage.event; const char *old_path, *new_path, *fname = *fname_p; old_path = t_strconcat(dir, "/", fname, NULL); @@ -255,13 +257,14 @@ rebuild_rename_file(struct mdbox_storage_rebuild_context *ctx, } } while (errno == EEXIST); - i_error("link(%s, %s) failed: %m", old_path, new_path); + e_error(event, "link(%s, %s) failed: %m", old_path, new_path); return -1; } static int rebuild_add_file(struct mdbox_storage_rebuild_context *ctx, const char *dir, const char *fname) { + struct event *event = ctx->storage->storage.storage.event; struct dbox_file *file; uint32_t file_id; const char *id_str, *ext; @@ -275,8 +278,8 @@ static int rebuild_add_file(struct mdbox_storage_rebuild_context *ctx, ext = strrchr(id_str, '.'); if (ext == NULL || (strcmp(ext, ".broken") != 0 && strcmp(ext, ".lock") != 0)) { - i_warning("mdbox rebuild: " - "Skipping file with missing ID: %s/%s", + e_warning(event, + "rebuild: Skipping file with missing ID: %s/%s", dir, fname); } return 0; @@ -298,7 +301,7 @@ static int rebuild_add_file(struct mdbox_storage_rebuild_context *ctx, if ((ret = dbox_file_open(file, &deleted)) > 0 && !deleted) ret = rebuild_file_mails(ctx, file, file_id); if (ret == 0) - i_error("mdbox rebuild: Failed to fix file %s/%s", dir, fname); + e_error(event, "rebuild: Failed to fix file %s/%s", dir, fname); dbox_file_unref(&file); return ret < 0 ? -1 : 0; } @@ -563,8 +566,8 @@ rebuild_mailbox(struct mdbox_storage_rebuild_context *ctx, } if (mailbox_open(box) < 0) { error = mailbox_get_last_mail_error(box); - i_error("Couldn't open mailbox '%s': %s", - vname, mailbox_get_last_internal_error(box, NULL)); + e_error(box->event, "Couldn't open mailbox: %s", + mailbox_get_last_internal_error(box, NULL)); mailbox_free(&box); if (error == MAIL_ERROR_TEMP) return -1; @@ -941,7 +944,8 @@ mdbox_storage_rebuild_scan_prepare(struct mdbox_storage_rebuild_context *ctx) static int mdbox_storage_rebuild_scan(struct mdbox_storage_rebuild_context *ctx) { - i_warning("mdbox %s: rebuilding indexes", ctx->storage->storage_dir); + struct event *event = ctx->storage->storage.storage.event; + e_warning(event, "rebuilding indexes"); if (mdbox_storage_rebuild_scan_dir(ctx, ctx->storage->storage_dir, FALSE) < 0) diff --git a/src/lib-storage/index/dbox-multi/mdbox-storage.c b/src/lib-storage/index/dbox-multi/mdbox-storage.c index 02bca0cca5..b7fc6b3c17 100644 --- a/src/lib-storage/index/dbox-multi/mdbox-storage.c +++ b/src/lib-storage/index/dbox-multi/mdbox-storage.c @@ -64,6 +64,10 @@ int mdbox_storage_create(struct mail_storage *_storage, ns->list->set.alt_dir, "/"MDBOX_GLOBAL_DIR_NAME, NULL); } + + event_set_append_log_prefix(_storage->event, t_strdup_printf( + "mdbox(%s): ", storage->storage_dir)); + i_array_init(&storage->open_files, 64); storage->map = mdbox_map_init(storage, ns->list); @@ -89,19 +93,19 @@ void mdbox_storage_destroy(struct mail_storage *_storage) static const char * mdbox_storage_find_root_dir(const struct mail_namespace *ns) { - bool debug = ns->mail_set->mail_debug; + struct event *event = ns->user->event; const char *home, *path; if (ns->owner != NULL && mail_user_get_home(ns->owner, &home) > 0) { path = t_strconcat(home, "/mdbox", NULL); if (access(path, R_OK|W_OK|X_OK) == 0) { - if (debug) - i_debug("mdbox: root exists (%s)", path); + e_debug(event, + "mdbox autodetect: root exists (%s)", path); return path; } - if (debug) - i_debug("mdbox: access(%s, rwx): failed: %m", path); + e_debug(event, + "mdbox autodetect: access(%s, rwx): failed: %m", path); } return NULL; } @@ -109,7 +113,7 @@ mdbox_storage_find_root_dir(const struct mail_namespace *ns) static bool mdbox_storage_autodetect(const struct mail_namespace *ns, struct mailbox_list_settings *set) { - bool debug = ns->mail_set->mail_debug; + struct event *event = ns->user->event; struct stat st; const char *path, *root_dir; @@ -118,22 +122,20 @@ static bool mdbox_storage_autodetect(const struct mail_namespace *ns, else { root_dir = mdbox_storage_find_root_dir(ns); if (root_dir == NULL) { - if (debug) - i_debug("mdbox: couldn't find root dir"); + e_debug(event, + "mdbox autodetect: couldn't find root dir"); return FALSE; } } path = t_strconcat(root_dir, "/"MDBOX_GLOBAL_DIR_NAME, NULL); if (stat(path, &st) < 0) { - if (debug) - i_debug("mdbox autodetect: stat(%s) failed: %m", path); + e_debug(event, "mdbox autodetect: stat(%s) failed: %m", path); return FALSE; } if (!S_ISDIR(st.st_mode)) { - if (debug) - i_debug("mdbox autodetect: %s not a directory", path); + e_debug(event, "mdbox autodetect: %s not a directory", path); return FALSE; }