Lines Matching refs:map
19 struct mail_index_map *map, bool eol)
45 map->hdr.log_file_seq = prev_seq;
48 if (map->hdr.log_file_seq != prev_seq) {
49 map->hdr.log_file_seq = prev_seq;
50 map->hdr.log_file_tail_offset = 0;
53 map->hdr.log_file_head_offset = prev_offset;
57 struct mail_index_map *map)
61 i_assert(view->map != map);
63 mail_index_sync_update_log_offset(ctx, view->map, FALSE);
64 mail_index_unmap(&view->map);
65 view->map = map;
68 view->index->map = map;
76 struct mail_index_map *map = ctx->view->map;
78 if (map->refcount > 1) {
79 map = mail_index_map_clone(map);
80 mail_index_sync_replace_map(ctx, map);
83 if (!MAIL_INDEX_MAP_IS_IN_MEMORY(ctx->view->map))
84 mail_index_map_move_to_memory(ctx->view->map);
86 return map;
93 mail_index_record_map_move_to_private(ctx->view->map);
95 return ctx->view->map;
153 maps = array_get(&ctx->view->map->rec_map->maps, &count);
172 if (uid >= ctx->view->map->hdr.next_uid) {
174 uid, ctx->view->map->hdr.next_uid);
176 if (mail_index_header_update_counts(&ctx->view->map->hdr,
190 maps = array_get(&ctx->view->map->rec_map->maps, &count);
211 rec = MAIL_INDEX_REC_AT_SEQ(ctx->view->map, seq);
241 struct mail_index_map *map;
250 map = mail_index_sync_get_atomic_map(ctx);
262 orig_rec_count = map->rec_map->records_count;
272 rec = MAIL_INDEX_REC_AT_SEQ(map, seq);
278 final location in the map if necessary */
281 memmove(MAIL_INDEX_REC_AT_SEQ(map, dest_seq1),
282 MAIL_INDEX_REC_AT_SEQ(map, prev_seq2+1),
283 move_count * map->hdr.record_size);
287 map->rec_map->records_count -= seq_count;
288 map->hdr.messages_count -= seq_count;
295 memmove(MAIL_INDEX_REC_AT_SEQ(map, dest_seq1),
296 MAIL_INDEX_REC_AT_SEQ(map, prev_seq2+1),
297 final_move_count * map->hdr.record_size);
301 static void *sync_append_record(struct mail_index_map *map)
306 append_pos = map->rec_map->records_count * map->hdr.record_size;
307 ret = buffer_get_space_unsafe(map->rec_map->buffer, append_pos,
308 map->hdr.record_size);
309 map->rec_map->records =
310 buffer_get_modifiable_data(map->rec_map->buffer, NULL);
378 struct mail_index_map *map = view->map;
383 if (rec->uid < map->hdr.next_uid) {
386 rec->uid, map->hdr.next_uid);
393 map = mail_index_sync_move_to_private_memory(ctx);
395 if (rec->uid <= map->rec_map->last_appended_uid) {
396 i_assert(map->hdr.messages_count < map->rec_map->records_count);
397 /* the flags may have changed since it was added to map.
400 old_rec = MAIL_INDEX_MAP_IDX(map, map->hdr.messages_count);
406 dest = sync_append_record(map);
409 map->hdr.record_size - sizeof(*rec));
410 map->rec_map->records_count++;
411 map->rec_map->last_appended_uid = rec->uid;
415 map->rec_map->records_count);
418 map->hdr.messages_count++;
419 map->hdr.next_uid = rec->uid+1;
423 map->hdr.flags |= MAIL_INDEX_HDR_FLAG_HAVE_DIRTY;
449 view->map->hdr.flags |= MAIL_INDEX_HDR_FLAG_HAVE_DIRTY;
457 rec = MAIL_INDEX_REC_AT_SEQ(view->map, seq);
462 rec = MAIL_INDEX_REC_AT_SEQ(view->map, seq);
483 struct mail_index_map *map = ctx->view->map;
484 uint32_t orig_log_file_tail_offset = map->hdr.log_file_tail_offset;
485 uint32_t orig_next_uid = map->hdr.next_uid;
487 if (u->offset >= map->hdr.base_header_size ||
488 u->offset + u->size > map->hdr.base_header_size) {
491 u->offset, u->size, map->hdr.base_header_size);
495 buffer_write(map->hdr_copy_buf, u->offset, u + 1, u->size);
496 map->hdr_base = map->hdr_copy_buf->data;
497 i_assert(map->hdr_copy_buf->used == map->hdr.header_size);
500 if ((uint32_t)(u->offset + u->size) <= sizeof(map->hdr)) {
501 memcpy(PTR_OFFSET(&map->hdr, u->offset),
503 } else if (u->offset < sizeof(map->hdr)) {
504 memcpy(PTR_OFFSET(&map->hdr, u->offset),
505 u + 1, sizeof(map->hdr) - u->offset);
508 if (map->hdr.next_uid < orig_next_uid) {
512 map->hdr.next_uid = orig_next_uid;
518 map->hdr.log_file_tail_offset = orig_log_file_tail_offset;
848 static void mail_index_sync_update_hdr_dirty_flag(struct mail_index_map *map)
853 if ((map->hdr.flags & MAIL_INDEX_HDR_FLAG_HAVE_DIRTY) != 0 ||
854 (map->index->flags & MAIL_INDEX_OPEN_FLAG_NO_DIRTY) != 0)
858 for (seq = 1; seq <= map->rec_map->records_count; seq++) {
859 rec = MAIL_INDEX_REC_AT_SEQ(map, seq);
861 map->hdr.flags |= MAIL_INDEX_HDR_FLAG_HAVE_DIRTY;
868 void mail_index_map_check(struct mail_index_map *map)
870 const struct mail_index_header *hdr = &map->hdr;
874 i_assert(hdr->messages_count <= map->rec_map->records_count);
878 rec = MAIL_INDEX_REC_AT_SEQ(map, seq);
900 struct mail_index_map *map = *_map;
901 struct mail_index *index = map->index;
912 i_assert(index->map == map || type == MAIL_INDEX_SYNC_HANDLER_VIEW);
920 map->hdr.log_file_tail_offset : map->hdr.log_file_head_offset;
923 syncing the current map from the transaction log.
934 index_size = map->hdr.header_size +
935 map->rec_map->records_count *
936 map->hdr.record_size;
947 view = mail_index_view_open_with_map(index, map);
949 map->hdr.log_file_seq, start_offset,
964 map->hdr.log_file_seq, start_offset, reason,
973 if (prev_seq != map->hdr.log_file_seq ||
974 prev_offset - map->hdr.log_file_tail_offset >
981 /* view referenced the map. avoid unnecessary map cloning by
982 unreferencing the map while view exists. */
983 map->refcount--;
985 had_dirty = (map->hdr.flags & MAIL_INDEX_HDR_FLAG_HAVE_DIRTY) != 0;
987 map->hdr.flags &= ~MAIL_INDEX_HDR_FLAG_HAVE_DIRTY;
989 if (map->hdr_base != map->hdr_copy_buf->data) {
994 buffer_set_used_size(map->hdr_copy_buf, 0);
995 buffer_append(map->hdr_copy_buf, map->hdr_base,
996 map->hdr.header_size);
997 map->hdr_base = map->hdr_copy_buf->data;
1009 map = mail_index_map_alloc(index);
1010 if ((index->map->hdr.flags & MAIL_INDEX_HDR_FLAG_FSCKD) != 0)
1011 map->hdr.flags |= MAIL_INDEX_HDR_FLAG_FSCKD;
1012 map->hdr.log_file_seq = prev_seq;
1013 map->hdr.log_file_tail_offset = 0;
1014 mail_index_sync_replace_map(&sync_map_ctx, map);
1016 map = NULL;
1029 view->map->hdr.log_file_seq,
1030 view->map->hdr.log_file_head_offset)) {
1044 map = view->map;
1047 mail_index_sync_update_hdr_dirty_flag(map);
1050 mail_index_sync_update_log_offset(&sync_map_ctx, view->map, TRUE);
1053 mail_index_map_check(map);
1055 i_assert(map->hdr.indexid == index->indexid || map->hdr.indexid == 0);
1061 i_assert(map->hdr.log_file_seq == index->log->head->hdr.file_seq);
1062 if (map->hdr.log_file_tail_offset < index->log->head->max_tail_offset) {
1063 map->hdr.log_file_tail_offset =
1067 buffer_write(map->hdr_copy_buf, 0, &map->hdr, sizeof(map->hdr));
1068 if (!MAIL_INDEX_MAP_IS_IN_MEMORY(map)) {
1069 memcpy(map->rec_map->mmap_base, map->hdr_copy_buf->data,
1070 map->hdr_copy_buf->used);
1074 if map got cloned, because view closing would otherwise destroy it */
1075 map->refcount++;
1079 i_assert(index->map == map || type == MAIL_INDEX_SYNC_HANDLER_VIEW);
1081 if (mail_index_map_check_header(map, &error) <= 0) {
1086 map = index->map;
1090 map = index->map;
1093 *_map = map;