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()
718 data_blocks = slab_size - meta_blocks; in vdo_configure_slab()
730 remaining = slab_journal_blocks - flushing_threshold; in vdo_configure_slab()
736 scrubbing_threshold = slab_journal_blocks - minimal_extra_space; in vdo_configure_slab()
752 * vdo_decode_slab_journal_entry() - Decode a slab journal entry.
762 vdo_unpack_slab_journal_entry(&block->payload.entries[entry_count]); in vdo_decode_slab_journal_entry()
764 if (block->header.has_block_map_increments && in vdo_decode_slab_journal_entry()
765 ((block->payload.full_entries.entry_types[entry_count / 8] & in vdo_decode_slab_journal_entry()
773 * allocate_partition() - Allocate a partition and add it to a layout.
774 * @layout: The layout containing the partition.
775 * @id: The id of the partition.
776 * @offset: The offset into the layout at which the partition begins.
777 * @size: The size of the partition in blocks.
784 struct partition *partition; in allocate_partition() local
787 result = vdo_allocate(1, struct partition, __func__, &partition); in allocate_partition()
791 partition->id = id; in allocate_partition()
792 partition->offset = offset; in allocate_partition()
793 partition->count = size; in allocate_partition()
794 partition->next = layout->head; in allocate_partition()
795 layout->head = partition; in allocate_partition()
801 * make_partition() - Create a new partition from the beginning or end of the unused space in a
804 * @id: The id of the partition to make.
806 * @beginning: True if the partition should start at the beginning of the unused space.
816 block_count_t free_blocks = layout->last_free - layout->first_free; in make_partition()
830 offset = beginning ? layout->first_free : (layout->last_free - size); in make_partition()
836 layout->num_partitions++; in make_partition()
838 layout->first_free += size; in make_partition()
840 layout->last_free = layout->last_free - size; in make_partition()
846 * vdo_initialize_layout() - Lay out the partitions of a vdo.
849 * @block_map_blocks: The size of the block map partition.
850 * @journal_blocks: The size of the journal partition.
851 * @summary_blocks: The size of the slab summary partition.
905 * vdo_uninitialize_layout() - Clean up a layout.
912 while (layout->head != NULL) { in vdo_uninitialize_layout()
913 struct partition *part = layout->head; in vdo_uninitialize_layout()
915 layout->head = part->next; in vdo_uninitialize_layout()
923 * vdo_get_partition() - Get a partition by id.
924 * @layout: The layout from which to get a partition.
925 * @id: The id of the partition.
926 * @partition_ptr: A pointer to hold the partition.
931 struct partition **partition_ptr) in vdo_get_partition()
933 struct partition *partition; in vdo_get_partition() local
935 for (partition = layout->head; partition != NULL; partition = partition->next) { in vdo_get_partition()
936 if (partition->id == id) { in vdo_get_partition()
938 *partition_ptr = partition; in vdo_get_partition()
947 * vdo_get_known_partition() - Get a partition by id from a validated layout.
948 * @layout: The layout from which to get a partition.
949 * @id: The id of the partition.
951 * Return: the partition
953 struct partition *vdo_get_known_partition(struct layout *layout, enum partition_id id) in vdo_get_known_partition()
955 struct partition *partition; in vdo_get_known_partition() local
956 int result = vdo_get_partition(layout, id, &partition); in vdo_get_known_partition()
958 VDO_ASSERT_LOG_ONLY(result == VDO_SUCCESS, "layout has expected partition: %u", id); in vdo_get_known_partition()
960 return partition; in vdo_get_known_partition()
965 const struct partition *partition; in encode_layout() local
970 VDO_ASSERT_LOG_ONLY(layout->num_partitions <= U8_MAX, in encode_layout()
971 "layout partition count must fit in a byte"); in encode_layout()
976 encode_u64_le(buffer, offset, layout->first_free); in encode_layout()
977 encode_u64_le(buffer, offset, layout->last_free); in encode_layout()
978 buffer[(*offset)++] = layout->num_partitions; in encode_layout()
980 VDO_ASSERT_LOG_ONLY(sizeof(struct layout_3_0) == *offset - initial_offset, in encode_layout()
983 for (partition = layout->head; partition != NULL; partition = partition->next) { in encode_layout()
984 buffer[(*offset)++] = partition->id; in encode_layout()
985 encode_u64_le(buffer, offset, partition->offset); in encode_layout()
988 encode_u64_le(buffer, offset, partition->count); in encode_layout()
991 VDO_ASSERT_LOG_ONLY(header.size == *offset - initial_offset, in encode_layout()
1000 struct partition *partition; in decode_layout() local
1023 result = VDO_ASSERT(sizeof(struct layout_3_0) == *offset - initial_offset, in decode_layout()
1028 layout->start = start; in decode_layout()
1029 layout->size = size; in decode_layout()
1030 layout->first_free = layout_header.first_free; in decode_layout()
1031 layout->last_free = layout_header.last_free; in decode_layout()
1032 layout->num_partitions = layout_header.partition_count; in decode_layout()
1034 if (layout->num_partitions > VDO_PARTITION_COUNT) { in decode_layout()
1039 for (i = 0; i < layout->num_partitions; i++) { in decode_layout()
1057 result = vdo_get_partition(layout, REQUIRED_PARTITIONS[i], &partition); in decode_layout()
1061 "layout is missing required partition %u", in decode_layout()
1065 start += partition->count; in decode_layout()
1078 * pack_vdo_config() - Convert a vdo_config to its packed on-disk representation.
1081 * Return: The platform-independent representation of the config.
1095 * pack_vdo_component() - Convert a vdo_component to its packed on-disk representation.
1098 * Return: The platform-independent representation of the component.
1123 * unpack_vdo_config() - Convert a packed_vdo_config to its native in-memory representation.
1126 * Return: The native in-memory representation of the vdo config.
1140 * unpack_vdo_component_41_0() - Convert a packed_vdo_component_41_0 to its native in-memory
1144 * Return: The native in-memory representation of the component.
1158 * decode_vdo_component() - Decode the component data for the vdo itself out of the super block.
1181 * vdo_validate_config() - Validate constraints on a VDO config.
1196 result = VDO_ASSERT(config->slab_size > 0, "slab size unspecified"); in vdo_validate_config()
1200 result = VDO_ASSERT(is_power_of_2(config->slab_size), in vdo_validate_config()
1205 result = VDO_ASSERT(config->slab_size <= (1 << MAX_VDO_SLAB_BITS), in vdo_validate_config()
1211 result = VDO_ASSERT(config->slab_journal_blocks <= config->slab_size, in vdo_validate_config()
1216 result = vdo_configure_slab(config->slab_size, config->slab_journal_blocks, in vdo_validate_config()
1226 result = VDO_ASSERT(config->physical_blocks > 0, "physical blocks unspecified"); in vdo_validate_config()
1230 result = VDO_ASSERT(config->physical_blocks <= MAXIMUM_VDO_PHYSICAL_BLOCKS, in vdo_validate_config()
1232 (unsigned long long) config->physical_blocks, in vdo_validate_config()
1237 if (physical_block_count != config->physical_blocks) { in vdo_validate_config()
1240 (unsigned long long) config->physical_blocks); in vdo_validate_config()
1245 result = VDO_ASSERT((config->logical_blocks > 0), in vdo_validate_config()
1250 if (logical_block_count != config->logical_blocks) { in vdo_validate_config()
1253 (unsigned long long) config->logical_blocks); in vdo_validate_config()
1258 result = VDO_ASSERT(config->logical_blocks <= MAXIMUM_VDO_LOGICAL_BLOCKS, in vdo_validate_config()
1263 result = VDO_ASSERT(config->recovery_journal_size > 0, in vdo_validate_config()
1268 result = VDO_ASSERT(is_power_of_2(config->recovery_journal_size), in vdo_validate_config()
1277 * vdo_destroy_component_states() - Clean up any allocations in a vdo_component_states.
1285 vdo_uninitialize_layout(&states->layout); in vdo_destroy_component_states()
1289 * decode_components() - Decode the components now that we know the component data is a version we
1304 decode_vdo_component(buffer, offset, &states->vdo); in decode_components()
1307 states->vdo.config.physical_blocks, &states->layout); in decode_components()
1312 &states->recovery_journal); in decode_components()
1316 result = decode_slab_depot_state_2_0(buffer, offset, &states->slab_depot); in decode_components()
1320 result = decode_block_map_state_2_0(buffer, offset, &states->block_map); in decode_components()
1330 * vdo_decode_component_states() - Decode the payload of a super block.
1344 decode_u32_le(buffer, &offset, &states->unused); in vdo_decode_component_states()
1347 decode_version_number(buffer, &offset, &states->volume_version); in vdo_decode_component_states()
1348 result = validate_version(VDO_VOLUME_VERSION_67_0, states->volume_version, in vdo_decode_component_states()
1355 vdo_uninitialize_layout(&states->layout); in vdo_decode_component_states()
1361 * vdo_validate_component_states() - Validate the decoded super block configuration.
1374 if (geometry_nonce != states->vdo.nonce) { in vdo_validate_component_states()
1378 (unsigned long long) states->vdo.nonce); in vdo_validate_component_states()
1381 return vdo_validate_config(&states->vdo.config, physical_size, logical_size); in vdo_validate_component_states()
1385 * vdo_encode_component_states() - Encode the state of all vdo components in the super block.
1391 encode_u32_le(buffer, offset, states->unused); in vdo_encode_component_states()
1392 encode_version_number(buffer, offset, states->volume_version); in vdo_encode_component_states()
1393 encode_vdo_component(buffer, offset, states->vdo); in vdo_encode_component_states()
1394 encode_layout(buffer, offset, &states->layout); in vdo_encode_component_states()
1395 encode_recovery_journal_state_7_0(buffer, offset, states->recovery_journal); in vdo_encode_component_states()
1396 encode_slab_depot_state_2_0(buffer, offset, states->slab_depot); in vdo_encode_component_states()
1397 encode_block_map_state_2_0(buffer, offset, states->block_map); in vdo_encode_component_states()
1404 * vdo_encode_super_block() - Encode a super block into its on-disk representation.
1428 * vdo_decode_super_block() - Decode a super block from its on-disk representation.