Lines Matching refs:volume_index

162 static inline bool has_sparse(const struct volume_index *volume_index)  in has_sparse()  argument
164 return volume_index->sparse_sample_rate > 0; in has_sparse()
167 bool uds_is_volume_index_sample(const struct volume_index *volume_index, in uds_is_volume_index_sample() argument
170 if (!has_sparse(volume_index)) in uds_is_volume_index_sample()
173 return (uds_extract_sampling_bytes(name) % volume_index->sparse_sample_rate) == 0; in uds_is_volume_index_sample()
177 get_volume_sub_index(const struct volume_index *volume_index, in get_volume_sub_index() argument
180 return (uds_is_volume_index_sample(volume_index, name) ? in get_volume_sub_index()
181 &volume_index->vi_hook : in get_volume_sub_index()
182 &volume_index->vi_non_hook); in get_volume_sub_index()
191 unsigned int uds_get_volume_index_zone(const struct volume_index *volume_index, in uds_get_volume_index_zone() argument
194 return get_volume_sub_index_zone(get_volume_sub_index(volume_index, name), name); in uds_get_volume_index_zone()
287 void uds_free_volume_index(struct volume_index *volume_index) in uds_free_volume_index() argument
289 if (volume_index == NULL) in uds_free_volume_index()
292 if (volume_index->zones != NULL) in uds_free_volume_index()
293 vdo_free(vdo_forget(volume_index->zones)); in uds_free_volume_index()
295 uninitialize_volume_sub_index(&volume_index->vi_non_hook); in uds_free_volume_index()
296 uninitialize_volume_sub_index(&volume_index->vi_hook); in uds_free_volume_index()
297 vdo_free(volume_index); in uds_free_volume_index()
531 int uds_get_volume_index_record(struct volume_index *volume_index, in uds_get_volume_index_record() argument
537 if (uds_is_volume_index_sample(volume_index, name)) { in uds_get_volume_index_record()
544 get_volume_sub_index_zone(&volume_index->vi_hook, name); in uds_get_volume_index_record()
545 struct mutex *mutex = &volume_index->zones[zone].hook_mutex; in uds_get_volume_index_record()
548 result = get_volume_sub_index_record(&volume_index->vi_hook, name, in uds_get_volume_index_record()
554 result = get_volume_sub_index_record(&volume_index->vi_non_hook, name, in uds_get_volume_index_record()
675 void uds_set_volume_index_zone_open_chapter(struct volume_index *volume_index, in uds_set_volume_index_zone_open_chapter() argument
679 struct mutex *mutex = &volume_index->zones[zone_number].hook_mutex; in uds_set_volume_index_zone_open_chapter()
681 set_volume_sub_index_zone_open_chapter(&volume_index->vi_non_hook, zone_number, in uds_set_volume_index_zone_open_chapter()
688 if (has_sparse(volume_index)) { in uds_set_volume_index_zone_open_chapter()
690 set_volume_sub_index_zone_open_chapter(&volume_index->vi_hook, in uds_set_volume_index_zone_open_chapter()
700 void uds_set_volume_index_open_chapter(struct volume_index *volume_index, in uds_set_volume_index_open_chapter() argument
705 for (zone = 0; zone < volume_index->zone_count; zone++) in uds_set_volume_index_open_chapter()
706 uds_set_volume_index_zone_open_chapter(volume_index, zone, virtual_chapter); in uds_set_volume_index_open_chapter()
776 u64 uds_lookup_volume_index_name(const struct volume_index *volume_index, in uds_lookup_volume_index_name() argument
779 unsigned int zone_number = uds_get_volume_index_zone(volume_index, name); in uds_lookup_volume_index_name()
780 struct mutex *mutex = &volume_index->zones[zone_number].hook_mutex; in uds_lookup_volume_index_name()
783 if (!uds_is_volume_index_sample(volume_index, name)) in uds_lookup_volume_index_name()
787 virtual_chapter = lookup_volume_sub_index_name(&volume_index->vi_hook, name); in uds_lookup_volume_index_name()
798 static void abort_restoring_volume_index(struct volume_index *volume_index) in abort_restoring_volume_index() argument
800 abort_restoring_volume_sub_index(&volume_index->vi_non_hook); in abort_restoring_volume_index()
801 if (has_sparse(volume_index)) in abort_restoring_volume_index()
802 abort_restoring_volume_sub_index(&volume_index->vi_hook); in abort_restoring_volume_index()
899 static int start_restoring_volume_index(struct volume_index *volume_index, in start_restoring_volume_index() argument
906 if (!has_sparse(volume_index)) { in start_restoring_volume_index()
907 return start_restoring_volume_sub_index(&volume_index->vi_non_hook, in start_restoring_volume_index()
938 volume_index->sparse_sample_rate = header.sparse_sample_rate; in start_restoring_volume_index()
939 } else if (volume_index->sparse_sample_rate != header.sparse_sample_rate) { in start_restoring_volume_index()
942 volume_index->sparse_sample_rate, in start_restoring_volume_index()
948 result = start_restoring_volume_sub_index(&volume_index->vi_non_hook, in start_restoring_volume_index()
953 return start_restoring_volume_sub_index(&volume_index->vi_hook, buffered_readers, in start_restoring_volume_index()
965 static int finish_restoring_volume_index(struct volume_index *volume_index, in finish_restoring_volume_index() argument
971 result = finish_restoring_volume_sub_index(&volume_index->vi_non_hook, in finish_restoring_volume_index()
973 if ((result == UDS_SUCCESS) && has_sparse(volume_index)) { in finish_restoring_volume_index()
974 result = finish_restoring_volume_sub_index(&volume_index->vi_hook, in finish_restoring_volume_index()
982 int uds_load_volume_index(struct volume_index *volume_index, in uds_load_volume_index() argument
988 result = start_restoring_volume_index(volume_index, readers, reader_count); in uds_load_volume_index()
992 result = finish_restoring_volume_index(volume_index, readers, reader_count); in uds_load_volume_index()
994 abort_restoring_volume_index(volume_index); in uds_load_volume_index()
1001 abort_restoring_volume_index(volume_index); in uds_load_volume_index()
1053 static int start_saving_volume_index(const struct volume_index *volume_index, in start_saving_volume_index() argument
1061 if (!has_sparse(volume_index)) { in start_saving_volume_index()
1062 return start_saving_volume_sub_index(&volume_index->vi_non_hook, in start_saving_volume_index()
1068 encode_u32_le(buffer, &offset, volume_index->sparse_sample_rate); in start_saving_volume_index()
1081 result = start_saving_volume_sub_index(&volume_index->vi_non_hook, zone_number, in start_saving_volume_index()
1086 return start_saving_volume_sub_index(&volume_index->vi_hook, zone_number, in start_saving_volume_index()
1096 static int finish_saving_volume_index(const struct volume_index *volume_index, in finish_saving_volume_index() argument
1101 result = finish_saving_volume_sub_index(&volume_index->vi_non_hook, zone_number); in finish_saving_volume_index()
1102 if ((result == UDS_SUCCESS) && has_sparse(volume_index)) in finish_saving_volume_index()
1103 result = finish_saving_volume_sub_index(&volume_index->vi_hook, zone_number); in finish_saving_volume_index()
1107 int uds_save_volume_index(struct volume_index *volume_index, in uds_save_volume_index() argument
1114 result = start_saving_volume_index(volume_index, zone, writers[zone]); in uds_save_volume_index()
1118 result = finish_saving_volume_index(volume_index, zone); in uds_save_volume_index()
1153 void uds_get_volume_index_stats(const struct volume_index *volume_index, in uds_get_volume_index_stats() argument
1158 get_volume_sub_index_stats(&volume_index->vi_non_hook, stats); in uds_get_volume_index_stats()
1159 if (!has_sparse(volume_index)) in uds_get_volume_index_stats()
1162 get_volume_sub_index_stats(&volume_index->vi_hook, &sparse_stats); in uds_get_volume_index_stats()
1224 struct volume_index **volume_index_ptr) in uds_make_volume_index()
1228 struct volume_index *volume_index; in uds_make_volume_index() local
1231 result = vdo_allocate(1, struct volume_index, "volume index", &volume_index); in uds_make_volume_index()
1235 volume_index->zone_count = config->zone_count; in uds_make_volume_index()
1239 &volume_index->vi_non_hook); in uds_make_volume_index()
1241 uds_free_volume_index(volume_index); in uds_make_volume_index()
1245 volume_index->memory_size = volume_index->vi_non_hook.memory_size; in uds_make_volume_index()
1246 *volume_index_ptr = volume_index; in uds_make_volume_index()
1250 volume_index->sparse_sample_rate = config->sparse_sample_rate; in uds_make_volume_index()
1253 "volume index zones", &volume_index->zones); in uds_make_volume_index()
1255 uds_free_volume_index(volume_index); in uds_make_volume_index()
1260 mutex_init(&volume_index->zones[zone].hook_mutex); in uds_make_volume_index()
1264 &volume_index->vi_non_hook); in uds_make_volume_index()
1266 uds_free_volume_index(volume_index); in uds_make_volume_index()
1272 &volume_index->vi_hook); in uds_make_volume_index()
1274 uds_free_volume_index(volume_index); in uds_make_volume_index()
1279 volume_index->memory_size = in uds_make_volume_index()
1280 volume_index->vi_non_hook.memory_size + volume_index->vi_hook.memory_size; in uds_make_volume_index()
1281 *volume_index_ptr = volume_index; in uds_make_volume_index()