Lines Matching +full:buffer +full:- +full:size
1 // SPDX-License-Identifier: GPL-2.0-only
11 #include "memory-alloc.h"
15 #include "status-codes.h"
37 * Note: this size isn't just the payload size following the header, like it is everywhere
40 .size = sizeof(struct geometry_block) + sizeof(struct volume_geometry),
50 * Note: this size isn't just the payload size following the header, like it is everywhere
53 .size = sizeof(struct geometry_block) + sizeof(struct volume_geometry_4_0),
71 .size = sizeof(struct block_map_state_2_0),
80 .size = sizeof(struct recovery_journal_state_7_0),
89 .size = sizeof(struct slab_depot_state_2_0),
98 .size = sizeof(struct layout_3_0) + (sizeof(struct partition_3_0) * VDO_PARTITION_COUNT),
129 /* This is the minimum size, if the super block contains no components. */
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.
165 * @exact_size: If true, the size fields of the two headers must be the same, otherwise it is
166 * required that actual_header.size >= expected_header.size.
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()
196 "%s size mismatch, expected %zu, got %zu", in vdo_validate_header()
197 name, expected_header->size, in vdo_validate_header()
198 actual_header->size); in vdo_validate_header()
204 static void encode_version_number(u8 *buffer, size_t *offset, in encode_version_number() argument
209 memcpy(buffer + *offset, &packed, sizeof(packed)); in encode_version_number()
213 void vdo_encode_header(u8 *buffer, size_t *offset, const struct header *header) in vdo_encode_header() argument
217 memcpy(buffer + *offset, &packed, sizeof(packed)); in vdo_encode_header()
221 static void decode_version_number(u8 *buffer, size_t *offset, in decode_version_number() argument
226 memcpy(&packed, buffer + *offset, sizeof(packed)); in decode_version_number()
231 void vdo_decode_header(u8 *buffer, size_t *offset, struct header *header) in vdo_decode_header() argument
235 memcpy(&packed, buffer + *offset, sizeof(packed)); in vdo_decode_header()
242 * decode_volume_geometry() - Decode the on-disk representation of a volume geometry from a buffer.
243 * @buffer: A buffer to decode from.
244 * @offset: The offset in the buffer at which to decode.
248 static void decode_volume_geometry(u8 *buffer, size_t *offset, in decode_volume_geometry() argument
258 decode_u32_le(buffer, offset, &unused); in decode_volume_geometry()
259 geometry->unused = unused; in decode_volume_geometry()
261 decode_u64_le(buffer, offset, &nonce); 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()
268 decode_u64_le(buffer, offset, &bio_offset); in decode_volume_geometry()
269 geometry->bio_offset = bio_offset; in decode_volume_geometry()
275 decode_u32_le(buffer, offset, &saved_id); in decode_volume_geometry()
276 decode_u64_le(buffer, offset, &start_block); in decode_volume_geometry()
278 geometry->regions[id] = (struct volume_region) { in decode_volume_geometry()
284 decode_u32_le(buffer, offset, &mem); in decode_volume_geometry()
286 sparse = buffer[(*offset)++]; 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.
323 result = VDO_ASSERT(header.size == offset + sizeof(u32), in vdo_parse_geometry_block()
335 struct block_map_page *vdo_format_block_map_page(void *buffer, nonce_t nonce, in vdo_format_block_map_page() argument
339 struct block_map_page *page = buffer; in vdo_format_block_map_page()
341 memset(buffer, 0, VDO_BLOCK_SIZE); in vdo_format_block_map_page()
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()
366 static int decode_block_map_state_2_0(u8 *buffer, size_t *offset, in decode_block_map_state_2_0() argument
375 vdo_decode_header(buffer, offset, &header); in decode_block_map_state_2_0()
382 decode_u64_le(buffer, offset, &flat_page_origin); in decode_block_map_state_2_0()
386 (unsigned long long) state->flat_page_origin); in decode_block_map_state_2_0()
390 decode_u64_le(buffer, offset, &flat_page_count); in decode_block_map_state_2_0()
393 (unsigned long long) state->flat_page_count); in decode_block_map_state_2_0()
397 decode_u64_le(buffer, offset, &root_origin); in decode_block_map_state_2_0()
398 decode_u64_le(buffer, offset, &root_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()
401 "decoded block map component size must match header size"); in decode_block_map_state_2_0()
415 static void encode_block_map_state_2_0(u8 *buffer, size_t *offset, in encode_block_map_state_2_0() argument
420 vdo_encode_header(buffer, offset, &VDO_BLOCK_MAP_HEADER_2_0); in encode_block_map_state_2_0()
423 encode_u64_le(buffer, offset, state.flat_page_origin); in encode_block_map_state_2_0()
424 encode_u64_le(buffer, offset, state.flat_page_count); in encode_block_map_state_2_0()
425 encode_u64_le(buffer, offset, state.root_origin); in encode_block_map_state_2_0()
426 encode_u64_le(buffer, offset, state.root_count); in encode_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()
429 "encoded block map component size must match header size"); 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.
468 static void encode_recovery_journal_state_7_0(u8 *buffer, size_t *offset, in encode_recovery_journal_state_7_0() argument
473 vdo_encode_header(buffer, offset, &VDO_RECOVERY_JOURNAL_HEADER_7_0); in encode_recovery_journal_state_7_0()
476 encode_u64_le(buffer, offset, state.journal_start); in encode_recovery_journal_state_7_0()
477 encode_u64_le(buffer, offset, state.logical_blocks_used); in encode_recovery_journal_state_7_0()
478 encode_u64_le(buffer, offset, state.block_map_data_blocks); in encode_recovery_journal_state_7_0()
480 VDO_ASSERT_LOG_ONLY(VDO_RECOVERY_JOURNAL_HEADER_7_0.size == *offset - initial_offset, in encode_recovery_journal_state_7_0()
481 "encoded recovery journal component size must match header size"); 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.
486 * @buffer: The buffer containing the saved state.
491 static int __must_check decode_recovery_journal_state_7_0(u8 *buffer, size_t *offset, in decode_recovery_journal_state_7_0() argument
500 vdo_decode_header(buffer, offset, &header); in decode_recovery_journal_state_7_0()
507 decode_u64_le(buffer, offset, &journal_start); in decode_recovery_journal_state_7_0()
508 decode_u64_le(buffer, offset, &logical_blocks_used); in decode_recovery_journal_state_7_0()
509 decode_u64_le(buffer, offset, &block_map_data_blocks); in decode_recovery_journal_state_7_0()
511 result = VDO_ASSERT(VDO_RECOVERY_JOURNAL_HEADER_7_0.size == *offset - initial_offset, in decode_recovery_journal_state_7_0()
512 "decoded recovery journal component size must match header size"); 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.
548 static void encode_slab_depot_state_2_0(u8 *buffer, size_t *offset, in encode_slab_depot_state_2_0() argument
553 vdo_encode_header(buffer, offset, &VDO_SLAB_DEPOT_HEADER_2_0); in encode_slab_depot_state_2_0()
556 encode_u64_le(buffer, offset, state.slab_config.slab_blocks); in encode_slab_depot_state_2_0()
557 encode_u64_le(buffer, offset, state.slab_config.data_blocks); in encode_slab_depot_state_2_0()
558 encode_u64_le(buffer, offset, state.slab_config.reference_count_blocks); in encode_slab_depot_state_2_0()
559 encode_u64_le(buffer, offset, state.slab_config.slab_journal_blocks); in encode_slab_depot_state_2_0()
560 encode_u64_le(buffer, offset, state.slab_config.slab_journal_flushing_threshold); in encode_slab_depot_state_2_0()
561 encode_u64_le(buffer, offset, state.slab_config.slab_journal_blocking_threshold); in encode_slab_depot_state_2_0()
562 encode_u64_le(buffer, offset, state.slab_config.slab_journal_scrubbing_threshold); in encode_slab_depot_state_2_0()
563 encode_u64_le(buffer, offset, state.first_block); in encode_slab_depot_state_2_0()
564 encode_u64_le(buffer, offset, state.last_block); in encode_slab_depot_state_2_0()
565 buffer[(*offset)++] = state.zone_count; in encode_slab_depot_state_2_0()
567 VDO_ASSERT_LOG_ONLY(VDO_SLAB_DEPOT_HEADER_2_0.size == *offset - initial_offset, in encode_slab_depot_state_2_0()
568 "encoded block map component size must match header size"); 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.
576 static int decode_slab_depot_state_2_0(u8 *buffer, size_t *offset, in decode_slab_depot_state_2_0() argument
587 vdo_decode_header(buffer, offset, &header); in decode_slab_depot_state_2_0()
594 decode_u64_le(buffer, offset, &count); in decode_slab_depot_state_2_0()
597 decode_u64_le(buffer, offset, &count); in decode_slab_depot_state_2_0()
600 decode_u64_le(buffer, offset, &count); in decode_slab_depot_state_2_0()
603 decode_u64_le(buffer, offset, &count); in decode_slab_depot_state_2_0()
606 decode_u64_le(buffer, offset, &count); in decode_slab_depot_state_2_0()
609 decode_u64_le(buffer, offset, &count); in decode_slab_depot_state_2_0()
612 decode_u64_le(buffer, offset, &count); in decode_slab_depot_state_2_0()
615 decode_u64_le(buffer, offset, &first_block); in decode_slab_depot_state_2_0()
616 decode_u64_le(buffer, offset, &last_block); in decode_slab_depot_state_2_0()
617 zone_count = buffer[(*offset)++]; in decode_slab_depot_state_2_0()
619 result = VDO_ASSERT(VDO_SLAB_DEPOT_HEADER_2_0.size == *offset - initial_offset, in decode_slab_depot_state_2_0()
620 "decoded slab depot component size must match header size"); in decode_slab_depot_state_2_0()
635 * vdo_configure_slab_depot() - Configure the slab depot.
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()
719 * If the slab size is very small, assume this must be a unit test and override the number in vdo_configure_slab()
722 * fall out since they use a power of two for the number of data blocks, the slab size was in vdo_configure_slab()
726 * hack isn't needed without having to edit several unit tests every time the metadata size 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.
790 * @size: The size of the partition in blocks.
795 physical_block_number_t offset, block_count_t size) in allocate_partition() argument
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
818 * @size: The number of blocks to carve out; if 0, all remaining space will be used.
821 * Return: A success or error code, particularly VDO_NO_SPACE if there are fewer than size blocks
825 block_count_t size, bool beginning) in make_partition() argument
829 block_count_t free_blocks = layout->last_free - layout->first_free; in make_partition()
831 if (size == 0) { in make_partition()
834 size = free_blocks; in make_partition()
835 } else if (size > free_blocks) { in make_partition()
843 offset = beginning ? layout->first_free : (layout->last_free - size); in make_partition()
845 result = allocate_partition(layout, id, offset, 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.
860 * @size: The entire size of the 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.
869 int vdo_initialize_layout(block_count_t size, physical_block_number_t offset, in vdo_initialize_layout() argument
877 if (necessary_size > size) in vdo_initialize_layout()
883 .size = size, in vdo_initialize_layout()
885 .last_free = size, in vdo_initialize_layout()
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.
948 for (partition = layout->head; partition != NULL; partition = partition->next) { in vdo_get_partition()
949 if (partition->id == id) { in vdo_get_partition()
960 * vdo_get_known_partition() - Get a partition by id from a validated layout.
976 static void encode_layout(u8 *buffer, size_t *offset, const struct layout *layout) in encode_layout() argument
983 VDO_ASSERT_LOG_ONLY(layout->num_partitions <= U8_MAX, in encode_layout()
986 vdo_encode_header(buffer, offset, &header); 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()
994 "encoded size of a layout header must match structure"); 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()
1000 encode_u64_le(buffer, offset, 0); 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()
1005 "encoded size of a layout must match header size"); in encode_layout()
1008 static int decode_layout(u8 *buffer, size_t *offset, physical_block_number_t start, in decode_layout() argument
1009 block_count_t size, struct layout *layout) in decode_layout() argument
1020 vdo_decode_header(buffer, offset, &header); in decode_layout()
1021 /* Layout is variable size, so only do a minimum size check here. */ in decode_layout()
1027 decode_u64_le(buffer, offset, &first_free); in decode_layout()
1028 decode_u64_le(buffer, offset, &last_free); in decode_layout()
1029 partition_count = buffer[(*offset)++]; in decode_layout()
1036 result = VDO_ASSERT(sizeof(struct layout_3_0) == *offset - initial_offset, in decode_layout()
1037 "decoded size of a layout header must match structure"); 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()
1056 id = buffer[(*offset)++]; in decode_layout()
1057 decode_u64_le(buffer, offset, &partition_offset); in decode_layout()
1059 decode_u64_le(buffer, offset, &count); in decode_layout()
1078 start += partition->count; in decode_layout()
1081 if (start != size) { 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.
1124 static void encode_vdo_component(u8 *buffer, size_t *offset, in encode_vdo_component() argument
1129 encode_version_number(buffer, offset, VDO_COMPONENT_DATA_41_0); in encode_vdo_component()
1131 memcpy(buffer + *offset, &packed, sizeof(packed)); in encode_vdo_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.
1175 static int decode_vdo_component(u8 *buffer, size_t *offset, struct vdo_component *component) in decode_vdo_component() argument
1181 decode_version_number(buffer, offset, &version); in decode_vdo_component()
1187 memcpy(&packed, buffer + *offset, sizeof(packed)); in decode_vdo_component()
1194 * vdo_validate_config() - Validate constraints on a VDO config.
1197 * @logical_block_count: The expected logical size of the VDO, or 0 if the logical size may be
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()
1214 "slab size must be a power of two"); in vdo_validate_config()
1218 result = VDO_ASSERT(config->slab_size <= (1 << MAX_VDO_SLAB_BITS), in vdo_validate_config()
1219 "slab size must be less than or equal to 2^%d", in vdo_validate_config()
1224 result = VDO_ASSERT(config->slab_journal_blocks >= MINIMUM_VDO_SLAB_JOURNAL_BLOCKS, in vdo_validate_config()
1225 "slab journal size meets minimum size"); in vdo_validate_config()
1229 result = VDO_ASSERT(config->slab_journal_blocks <= config->slab_size, in vdo_validate_config()
1230 "slab journal size is within expected bound"); 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()
1256 …vdo_log_error("A physical size of %llu blocks was specified, not the %llu blocks configured in the… 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()
1269 …vdo_log_error("A logical size of %llu blocks was specified, but that differs from the %llu 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()
1282 "recovery journal size unspecified"); in vdo_validate_config()
1286 result = VDO_ASSERT(is_power_of_2(config->recovery_journal_size), in vdo_validate_config()
1287 "recovery journal size must be a power of two"); 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
1309 * @buffer: The buffer being decoded.
1316 static int __must_check decode_components(u8 *buffer, size_t *offset, in decode_components() argument
1322 decode_vdo_component(buffer, offset, &states->vdo); in decode_components()
1324 result = decode_layout(buffer, offset, vdo_get_data_region_start(*geometry) + 1, in decode_components()
1325 states->vdo.config.physical_blocks, &states->layout); in decode_components()
1329 result = decode_recovery_journal_state_7_0(buffer, offset, 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.
1349 * @buffer: The buffer containing the encoded super block contents.
1355 int vdo_decode_component_states(u8 *buffer, struct volume_geometry *geometry, in vdo_decode_component_states() argument
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()
1371 result = decode_components(buffer, &offset, geometry, states); 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.
1383 * @logical_size: The expected logical size of the VDO, or 0 if the logical size may be
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.
1405 static void vdo_encode_component_states(u8 *buffer, size_t *offset, in vdo_encode_component_states() argument
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.
1424 void vdo_encode_super_block(u8 *buffer, struct vdo_component_states *states) in vdo_encode_super_block() argument
1430 header.size += VDO_COMPONENT_DATA_SIZE; in vdo_encode_super_block()
1431 vdo_encode_header(buffer, &offset, &header); in vdo_encode_super_block()
1432 vdo_encode_component_states(buffer, &offset, states); in vdo_encode_super_block()
1434 checksum = vdo_crc32(buffer, offset); in vdo_encode_super_block()
1435 encode_u32_le(buffer, &offset, checksum); in vdo_encode_super_block()
1438 * Even though the buffer is a full block, to avoid the potential corruption from a torn in vdo_encode_super_block()
1446 * vdo_decode_super_block() - Decode a super block from its on-disk representation.
1448 int vdo_decode_super_block(u8 *buffer) in vdo_decode_super_block() argument
1456 vdo_decode_header(buffer, &offset, &header); in vdo_decode_super_block()
1461 if (header.size > VDO_COMPONENT_DATA_SIZE + sizeof(u32)) { in vdo_decode_super_block()
1463 * We can't check release version or checksum until we know the content size, so we in vdo_decode_super_block()
1468 header.size); in vdo_decode_super_block()
1474 checksum = vdo_crc32(buffer, offset); in vdo_decode_super_block()
1475 decode_u32_le(buffer, &offset, &saved_checksum); in vdo_decode_super_block()