Lines Matching refs:offset

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()
210 *offset += 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()
218 *offset += 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()
227 *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()
236 *offset += sizeof(packed); in vdo_decode_header()
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()
261 decode_u64_le(buffer, offset, &nonce); in decode_volume_geometry()
264 memcpy((unsigned char *) &geometry->uuid, buffer + *offset, sizeof(uuid_t)); in decode_volume_geometry()
265 *offset += sizeof(uuid_t); in decode_volume_geometry()
268 decode_u64_le(buffer, 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()
284 decode_u32_le(buffer, offset, &mem); in decode_volume_geometry()
285 *offset += sizeof(u32); in decode_volume_geometry()
286 sparse = buffer[(*offset)++]; in decode_volume_geometry()
303 size_t offset = 0; in vdo_parse_geometry_block() local
308 offset += VDO_GEOMETRY_MAGIC_NUMBER_SIZE; in vdo_parse_geometry_block()
310 vdo_decode_header(block, &offset, &header); in vdo_parse_geometry_block()
321 decode_volume_geometry(block, &offset, geometry, header.version.major_version); in vdo_parse_geometry_block()
323 result = VDO_ASSERT(header.size == offset + sizeof(u32), in vdo_parse_geometry_block()
329 checksum = vdo_crc32(block, offset); in vdo_parse_geometry_block()
330 decode_u32_le(block, &offset, &saved_checksum); in vdo_parse_geometry_block()
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()
380 initial_offset = *offset; in decode_block_map_state_2_0()
382 decode_u64_le(buffer, offset, &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()
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()
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()
422 initial_offset = *offset; 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()
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()
475 initial_offset = *offset; 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()
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()
506 initial_offset = *offset; 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()
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()
555 initial_offset = *offset; 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()
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()
593 initial_offset = *offset; 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()
658 (unsigned long long) partition->offset, 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()
795 physical_block_number_t offset, block_count_t size) in allocate_partition() argument
805 partition->offset = offset; in allocate_partition()
828 physical_block_number_t offset; in make_partition() local
843 offset = beginning ? layout->first_free : (layout->last_free - size); in make_partition()
845 result = allocate_partition(layout, id, offset, size); in make_partition()
869 int vdo_initialize_layout(block_count_t size, physical_block_number_t offset, in vdo_initialize_layout() argument
875 (offset + block_map_blocks + journal_blocks + summary_blocks); in vdo_initialize_layout()
882 .start = offset, in vdo_initialize_layout()
884 .first_free = offset, in vdo_initialize_layout()
976 static void encode_layout(u8 *buffer, size_t *offset, const struct layout *layout) in encode_layout() argument
986 vdo_encode_header(buffer, offset, &header); in encode_layout()
988 initial_offset = *offset; 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()
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()
1008 static int decode_layout(u8 *buffer, size_t *offset, physical_block_number_t start, in decode_layout() argument
1020 vdo_decode_header(buffer, offset, &header); in decode_layout()
1026 initial_offset = *offset; 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()
1056 id = buffer[(*offset)++]; in decode_layout()
1057 decode_u64_le(buffer, offset, &partition_offset); in decode_layout()
1058 *offset += sizeof(u64); in decode_layout()
1059 decode_u64_le(buffer, offset, &count); in decode_layout()
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()
1132 *offset += sizeof(packed); in encode_vdo_component()
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()
1188 *offset += sizeof(packed); in decode_vdo_component()
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()
1329 result = decode_recovery_journal_state_7_0(buffer, offset, 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()
1342 VDO_ASSERT_LOG_ONLY(*offset == VDO_COMPONENT_DATA_OFFSET + VDO_COMPONENT_DATA_SIZE, in decode_components()
1359 size_t offset = VDO_COMPONENT_DATA_OFFSET; in vdo_decode_component_states() local
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()
1371 result = decode_components(buffer, &offset, geometry, states); in vdo_decode_component_states()
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()
1417 VDO_ASSERT_LOG_ONLY(*offset == VDO_COMPONENT_DATA_OFFSET + VDO_COMPONENT_DATA_SIZE, in vdo_encode_component_states()
1428 size_t offset = 0; in vdo_encode_super_block() local
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()
1441 VDO_ASSERT_LOG_ONLY(offset <= VDO_SECTOR_SIZE, in vdo_encode_super_block()
1453 size_t offset = 0; in vdo_decode_super_block() local
1456 vdo_decode_header(buffer, &offset, &header); in vdo_decode_super_block()
1472 offset += VDO_COMPONENT_DATA_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()
1477 result = VDO_ASSERT(offset == VDO_SUPER_BLOCK_FIXED_SIZE + VDO_COMPONENT_DATA_SIZE, in vdo_decode_super_block()