Lines Matching +full:partition +full:-
1 // SPDX-License-Identifier: GPL-2.0-only
11 #include "memory-alloc.h"
15 #include "status-codes.h"
130 .size = VDO_SUPER_BLOCK_FIXED_SIZE - VDO_ENCODED_HEADER_SIZE,
134 * validate_version() - Check whether a version matches an expected version.
162 * vdo_validate_header() - Check whether a header matches expectations.
181 if (expected_header->id != actual_header->id) { in vdo_validate_header()
184 name, expected_header->id, in vdo_validate_header()
185 actual_header->id); in vdo_validate_header()
188 result = validate_version(expected_header->version, actual_header->version, in vdo_validate_header()
193 if ((expected_header->size > actual_header->size) || in vdo_validate_header()
194 (exact_size && (expected_header->size < actual_header->size))) { in vdo_validate_header()
197 name, expected_header->size, in vdo_validate_header()
198 actual_header->size); in vdo_validate_header()
242 * decode_volume_geometry() - Decode the on-disk representation of a volume geometry from a buffer.
259 geometry->unused = unused; in decode_volume_geometry()
262 geometry->nonce = nonce; in decode_volume_geometry()
264 memcpy((unsigned char *) &geometry->uuid, buffer + *offset, sizeof(uuid_t)); in decode_volume_geometry()
269 geometry->bio_offset = bio_offset; in decode_volume_geometry()
278 geometry->regions[id] = (struct volume_region) { in decode_volume_geometry()
288 geometry->index_config = (struct index_config) { in decode_volume_geometry()
295 * vdo_parse_geometry_block() - Decode and validate an encoded geometry block.
342 page->version = vdo_pack_version_number(BLOCK_MAP_4_1); in vdo_format_block_map_page()
343 page->header.nonce = __cpu_to_le64(nonce); in vdo_format_block_map_page()
344 page->header.pbn = __cpu_to_le64(pbn); in vdo_format_block_map_page()
345 page->header.initialized = initialized; in vdo_format_block_map_page()
356 vdo_unpack_version_number(page->version)) || in vdo_validate_block_map_page()
357 !page->header.initialized || (nonce != __le64_to_cpu(page->header.nonce))) in vdo_validate_block_map_page()
386 (unsigned long long) state->flat_page_origin); in decode_block_map_state_2_0()
393 (unsigned long long) state->flat_page_count); in decode_block_map_state_2_0()
400 result = VDO_ASSERT(VDO_BLOCK_MAP_HEADER_2_0.size == *offset - initial_offset, in decode_block_map_state_2_0()
428 VDO_ASSERT_LOG_ONLY(VDO_BLOCK_MAP_HEADER_2_0.size == *offset - initial_offset, in encode_block_map_state_2_0()
433 * vdo_compute_new_forest_pages() - Compute the number of pages which must be allocated at each
437 * Return: The total number of non-leaf pages required.
453 new_sizes->levels[height] = level_size; in vdo_compute_new_forest_pages()
456 new_pages -= old_sizes->levels[height]; in vdo_compute_new_forest_pages()
464 * encode_recovery_journal_state_7_0() - Encode the state of a recovery journal.
480 VDO_ASSERT_LOG_ONLY(VDO_RECOVERY_JOURNAL_HEADER_7_0.size == *offset - initial_offset, in encode_recovery_journal_state_7_0()
485 * decode_recovery_journal_state_7_0() - Decode the state of a recovery journal saved in a buffer.
511 result = VDO_ASSERT(VDO_RECOVERY_JOURNAL_HEADER_7_0.size == *offset - initial_offset, in decode_recovery_journal_state_7_0()
526 * vdo_get_journal_operation_name() - Get the name of a journal operation.
546 * encode_slab_depot_state_2_0() - Encode the state of a slab depot into a buffer.
567 VDO_ASSERT_LOG_ONLY(VDO_SLAB_DEPOT_HEADER_2_0.size == *offset - initial_offset, in encode_slab_depot_state_2_0()
572 * decode_slab_depot_state_2_0() - Decode slab depot component state version 2.0 from a buffer.
619 result = VDO_ASSERT(VDO_SLAB_DEPOT_HEADER_2_0.size == *offset - initial_offset, in decode_slab_depot_state_2_0()
635 * vdo_configure_slab_depot() - Configure the slab depot.
636 * @partition: The slab depot partition
647 int vdo_configure_slab_depot(const struct partition *partition, in vdo_configure_slab_depot() argument
657 __func__, (unsigned long long) partition->count, in vdo_configure_slab_depot()
658 (unsigned long long) partition->offset, in vdo_configure_slab_depot()
662 slab_count = (partition->count / slab_size); in vdo_configure_slab_depot()
671 last_block = partition->offset + total_slab_blocks; in vdo_configure_slab_depot()
675 .first_block = partition->offset, in vdo_configure_slab_depot()
683 (unsigned long long) (partition->count - (last_block - partition->offset))); in vdo_configure_slab_depot()
689 * vdo_configure_slab() - Measure and initialize the configuration to use for each slab.
711 ref_blocks = vdo_get_saved_reference_count_size(slab_size - slab_journal_blocks); in vdo_configure_slab()
729 data_blocks = slab_size - meta_blocks; in vdo_configure_slab()
743 remaining = slab_journal_blocks - flushing_threshold; in vdo_configure_slab()
749 scrubbing_threshold = slab_journal_blocks - minimal_extra_space; in vdo_configure_slab()
765 * vdo_decode_slab_journal_entry() - Decode a slab journal entry.
775 vdo_unpack_slab_journal_entry(&block->payload.entries[entry_count]); in vdo_decode_slab_journal_entry()
777 if (block->header.has_block_map_increments && in vdo_decode_slab_journal_entry()
778 ((block->payload.full_entries.entry_types[entry_count / 8] & in vdo_decode_slab_journal_entry()
786 * allocate_partition() - Allocate a partition and add it to a layout.
787 * @layout: The layout containing the partition.
788 * @id: The id of the partition.
789 * @offset: The offset into the layout at which the partition begins.
790 * @size: The size of the partition in blocks.
797 struct partition *partition; in allocate_partition() local
800 result = vdo_allocate(1, struct partition, __func__, &partition); in allocate_partition()
804 partition->id = id; in allocate_partition()
805 partition->offset = offset; in allocate_partition()
806 partition->count = size; in allocate_partition()
807 partition->next = layout->head; in allocate_partition()
808 layout->head = partition; in allocate_partition()
814 * make_partition() - Create a new partition from the beginning or end of the unused space in a
817 * @id: The id of the partition to make.
819 * @beginning: True if the partition should start at the beginning of the unused space.
829 block_count_t free_blocks = layout->last_free - layout->first_free; in make_partition()
843 offset = beginning ? layout->first_free : (layout->last_free - size); in make_partition()
849 layout->num_partitions++; in make_partition()
851 layout->first_free += size; in make_partition()
853 layout->last_free = layout->last_free - size; in make_partition()
859 * vdo_initialize_layout() - Lay out the partitions of a vdo.
862 * @block_map_blocks: The size of the block map partition.
863 * @journal_blocks: The size of the journal partition.
864 * @summary_blocks: The size of the slab summary partition.
918 * vdo_uninitialize_layout() - Clean up a layout.
925 while (layout->head != NULL) { in vdo_uninitialize_layout()
926 struct partition *part = layout->head; in vdo_uninitialize_layout()
928 layout->head = part->next; in vdo_uninitialize_layout()
936 * vdo_get_partition() - Get a partition by id.
937 * @layout: The layout from which to get a partition.
938 * @id: The id of the partition.
939 * @partition_ptr: A pointer to hold the partition.
944 struct partition **partition_ptr) in vdo_get_partition()
946 struct partition *partition; in vdo_get_partition() local
948 for (partition = layout->head; partition != NULL; partition = partition->next) { in vdo_get_partition()
949 if (partition->id == id) { in vdo_get_partition()
951 *partition_ptr = partition; in vdo_get_partition()
960 * vdo_get_known_partition() - Get a partition by id from a validated layout.
961 * @layout: The layout from which to get a partition.
962 * @id: The id of the partition.
964 * Return: the partition
966 struct partition *vdo_get_known_partition(struct layout *layout, enum partition_id id) in vdo_get_known_partition()
968 struct partition *partition; in vdo_get_known_partition() local
969 int result = vdo_get_partition(layout, id, &partition); in vdo_get_known_partition()
971 VDO_ASSERT_LOG_ONLY(result == VDO_SUCCESS, "layout has expected partition: %u", id); in vdo_get_known_partition()
973 return partition; in vdo_get_known_partition()
978 const struct partition *partition; in encode_layout() local
983 VDO_ASSERT_LOG_ONLY(layout->num_partitions <= U8_MAX, in encode_layout()
984 "layout partition count must fit in a byte"); in encode_layout()
989 encode_u64_le(buffer, offset, layout->first_free); in encode_layout()
990 encode_u64_le(buffer, offset, layout->last_free); in encode_layout()
991 buffer[(*offset)++] = layout->num_partitions; in encode_layout()
993 VDO_ASSERT_LOG_ONLY(sizeof(struct layout_3_0) == *offset - initial_offset, in encode_layout()
996 for (partition = layout->head; partition != NULL; partition = partition->next) { in encode_layout()
997 buffer[(*offset)++] = partition->id; in encode_layout()
998 encode_u64_le(buffer, offset, partition->offset); in encode_layout()
1001 encode_u64_le(buffer, offset, partition->count); in encode_layout()
1004 VDO_ASSERT_LOG_ONLY(header.size == *offset - initial_offset, in encode_layout()
1013 struct partition *partition; in decode_layout() local
1036 result = VDO_ASSERT(sizeof(struct layout_3_0) == *offset - initial_offset, in decode_layout()
1041 layout->start = start; in decode_layout()
1042 layout->size = size; in decode_layout()
1043 layout->first_free = layout_header.first_free; in decode_layout()
1044 layout->last_free = layout_header.last_free; in decode_layout()
1045 layout->num_partitions = layout_header.partition_count; in decode_layout()
1047 if (layout->num_partitions > VDO_PARTITION_COUNT) { in decode_layout()
1052 for (i = 0; i < layout->num_partitions; i++) { in decode_layout()
1070 result = vdo_get_partition(layout, REQUIRED_PARTITIONS[i], &partition); in decode_layout()
1074 "layout is missing required partition %u", in decode_layout()
1078 start += partition->count; in decode_layout()
1091 * pack_vdo_config() - Convert a vdo_config to its packed on-disk representation.
1094 * Return: The platform-independent representation of the config.
1108 * pack_vdo_component() - Convert a vdo_component to its packed on-disk representation.
1111 * Return: The platform-independent representation of the component.
1136 * unpack_vdo_config() - Convert a packed_vdo_config to its native in-memory representation.
1139 * Return: The native in-memory representation of the vdo config.
1153 * unpack_vdo_component_41_0() - Convert a packed_vdo_component_41_0 to its native in-memory
1157 * Return: The native in-memory representation of the component.
1171 * decode_vdo_component() - Decode the component data for the vdo itself out of the super block.
1194 * vdo_validate_config() - Validate constraints on a VDO config.
1209 result = VDO_ASSERT(config->slab_size > 0, "slab size unspecified"); in vdo_validate_config()
1213 result = VDO_ASSERT(is_power_of_2(config->slab_size), in vdo_validate_config()
1218 result = VDO_ASSERT(config->slab_size <= (1 << MAX_VDO_SLAB_BITS), in vdo_validate_config()
1224 result = VDO_ASSERT(config->slab_journal_blocks >= MINIMUM_VDO_SLAB_JOURNAL_BLOCKS, in vdo_validate_config()
1229 result = VDO_ASSERT(config->slab_journal_blocks <= config->slab_size, in vdo_validate_config()
1234 result = vdo_configure_slab(config->slab_size, config->slab_journal_blocks, in vdo_validate_config()
1244 result = VDO_ASSERT(config->physical_blocks > 0, "physical blocks unspecified"); in vdo_validate_config()
1248 result = VDO_ASSERT(config->physical_blocks <= MAXIMUM_VDO_PHYSICAL_BLOCKS, in vdo_validate_config()
1250 (unsigned long long) config->physical_blocks, in vdo_validate_config()
1255 if (physical_block_count != config->physical_blocks) { in vdo_validate_config()
1258 (unsigned long long) config->physical_blocks); in vdo_validate_config()
1263 result = VDO_ASSERT((config->logical_blocks > 0), in vdo_validate_config()
1268 if (logical_block_count != config->logical_blocks) { in vdo_validate_config()
1271 (unsigned long long) config->logical_blocks); in vdo_validate_config()
1276 result = VDO_ASSERT(config->logical_blocks <= MAXIMUM_VDO_LOGICAL_BLOCKS, in vdo_validate_config()
1281 result = VDO_ASSERT(config->recovery_journal_size > 0, in vdo_validate_config()
1286 result = VDO_ASSERT(is_power_of_2(config->recovery_journal_size), in vdo_validate_config()
1295 * vdo_destroy_component_states() - Clean up any allocations in a vdo_component_states.
1303 vdo_uninitialize_layout(&states->layout); in vdo_destroy_component_states()
1307 * decode_components() - Decode the components now that we know the component data is a version we
1322 decode_vdo_component(buffer, offset, &states->vdo); in decode_components()
1325 states->vdo.config.physical_blocks, &states->layout); in decode_components()
1330 &states->recovery_journal); in decode_components()
1334 result = decode_slab_depot_state_2_0(buffer, offset, &states->slab_depot); in decode_components()
1338 result = decode_block_map_state_2_0(buffer, offset, &states->block_map); in decode_components()
1348 * vdo_decode_component_states() - Decode the payload of a super block.
1362 decode_u32_le(buffer, &offset, &states->unused); in vdo_decode_component_states()
1365 decode_version_number(buffer, &offset, &states->volume_version); in vdo_decode_component_states()
1366 result = validate_version(VDO_VOLUME_VERSION_67_0, states->volume_version, in vdo_decode_component_states()
1373 vdo_uninitialize_layout(&states->layout); in vdo_decode_component_states()
1379 * vdo_validate_component_states() - Validate the decoded super block configuration.
1392 if (geometry_nonce != states->vdo.nonce) { in vdo_validate_component_states()
1396 (unsigned long long) states->vdo.nonce); in vdo_validate_component_states()
1399 return vdo_validate_config(&states->vdo.config, physical_size, logical_size); in vdo_validate_component_states()
1403 * vdo_encode_component_states() - Encode the state of all vdo components in the super block.
1409 encode_u32_le(buffer, offset, states->unused); in vdo_encode_component_states()
1410 encode_version_number(buffer, offset, states->volume_version); in vdo_encode_component_states()
1411 encode_vdo_component(buffer, offset, states->vdo); in vdo_encode_component_states()
1412 encode_layout(buffer, offset, &states->layout); in vdo_encode_component_states()
1413 encode_recovery_journal_state_7_0(buffer, offset, states->recovery_journal); in vdo_encode_component_states()
1414 encode_slab_depot_state_2_0(buffer, offset, states->slab_depot); in vdo_encode_component_states()
1415 encode_block_map_state_2_0(buffer, offset, states->block_map); in vdo_encode_component_states()
1422 * vdo_encode_super_block() - Encode a super block into its on-disk representation.
1446 * vdo_decode_super_block() - Decode a super block from its on-disk representation.