Lines Matching full:map

6 #include "index-page-map.h"
20 * The index page map is conceptually a two-dimensional array indexed by chapter number and index
39 struct index_page_map *map; in uds_make_index_page_map() local
41 result = vdo_allocate(1, struct index_page_map, "page map", &map); in uds_make_index_page_map()
45 map->geometry = geometry; in uds_make_index_page_map()
46 map->entries_per_chapter = geometry->index_pages_per_chapter - 1; in uds_make_index_page_map()
47 result = vdo_allocate(get_entry_count(geometry), u16, "Index Page Map Entries", in uds_make_index_page_map()
48 &map->entries); in uds_make_index_page_map()
50 uds_free_index_page_map(map); in uds_make_index_page_map()
54 *map_ptr = map; in uds_make_index_page_map()
58 void uds_free_index_page_map(struct index_page_map *map) in uds_free_index_page_map() argument
60 if (map != NULL) { in uds_free_index_page_map()
61 vdo_free(map->entries); in uds_free_index_page_map()
62 vdo_free(map); in uds_free_index_page_map()
66 void uds_update_index_page_map(struct index_page_map *map, u64 virtual_chapter_number, in uds_update_index_page_map() argument
72 map->last_update = virtual_chapter_number; in uds_update_index_page_map()
73 if (index_page_number == map->entries_per_chapter) in uds_update_index_page_map()
76 slot = (chapter_number * map->entries_per_chapter) + index_page_number; in uds_update_index_page_map()
77 map->entries[slot] = delta_list_number; in uds_update_index_page_map()
80 u32 uds_find_index_page_number(const struct index_page_map *map, in uds_find_index_page_number() argument
83 u32 delta_list_number = uds_hash_to_chapter_delta_list(name, map->geometry); in uds_find_index_page_number()
84 u32 slot = chapter_number * map->entries_per_chapter; in uds_find_index_page_number()
87 for (page = 0; page < map->entries_per_chapter; page++) { in uds_find_index_page_number()
88 if (delta_list_number <= map->entries[slot + page]) in uds_find_index_page_number()
95 void uds_get_list_number_bounds(const struct index_page_map *map, u32 chapter_number, in uds_get_list_number_bounds() argument
99 u32 slot = chapter_number * map->entries_per_chapter; in uds_get_list_number_bounds()
102 0 : map->entries[slot + index_page_number - 1] + 1); in uds_get_list_number_bounds()
103 *highest_list = ((index_page_number < map->entries_per_chapter) ? in uds_get_list_number_bounds()
104 map->entries[slot + index_page_number] : in uds_get_list_number_bounds()
105 map->geometry->delta_lists_per_chapter - 1); in uds_get_list_number_bounds()
113 int uds_write_index_page_map(struct index_page_map *map, struct buffered_writer *writer) in uds_write_index_page_map() argument
118 u64 saved_size = uds_compute_index_page_map_save_size(map->geometry); in uds_write_index_page_map()
121 result = vdo_allocate(saved_size, u8, "page map data", &buffer); in uds_write_index_page_map()
127 encode_u64_le(buffer, &offset, map->last_update); in uds_write_index_page_map()
128 for (i = 0; i < get_entry_count(map->geometry); i++) in uds_write_index_page_map()
129 encode_u16_le(buffer, &offset, map->entries[i]); in uds_write_index_page_map()
139 int uds_read_index_page_map(struct index_page_map *map, struct buffered_reader *reader) in uds_read_index_page_map() argument
145 u64 saved_size = uds_compute_index_page_map_save_size(map->geometry); in uds_read_index_page_map()
148 result = vdo_allocate(saved_size, u8, "page map data", &buffer); in uds_read_index_page_map()
165 decode_u64_le(buffer, &offset, &map->last_update); in uds_read_index_page_map()
166 for (i = 0; i < get_entry_count(map->geometry); i++) in uds_read_index_page_map()
167 decode_u16_le(buffer, &offset, &map->entries[i]); in uds_read_index_page_map()
170 vdo_log_debug("read index page map, last update %llu", in uds_read_index_page_map()
171 (unsigned long long) map->last_update); in uds_read_index_page_map()