Lines Matching +full:byte +full:- +full:order

1 /* SPDX-License-Identifier: GPL-2.0-only */
20 * An in-memory representation of a version number for versioned structures on disk.
34 * A packed, machine-independent, on-disk representation of a version_number. Both fields are
35 * stored in little-endian byte order.
57 /* A packed, machine-independent, on-disk representation of a component header. */
101 /* The regions in ID order */
115 /* The regions in ID order */
127 * in both the on-disk and in-memory layouts. It consists of the 36 low-order bits of a
128 * physical_block_number_t (addressing 256 terabytes with a 4KB block size) and a 4-bit encoding of
131 * Of the 8 high bits of the 5-byte structure:
133 * Bits 7..4: The four highest bits of the 36-bit physical block number
134 * Bits 3..0: The 4-bit block_mapping_state
136 * The following 4 bytes are the low order bytes of the physical block number, in little-endian
137 * order.
157 /* May be non-zero on disk */
166 /* May be non-zero on disk */
225 /* The packed, on-disk representation of a recovery journal entry. */
228 * In little-endian bit order:
229 * Bits 15..12: The four highest bits of the 36-bit physical block number of the block map
231 * Bits 11..2: The 10-bit block map page slot number
248 * Bits 47..16: The 32 low-order bits of the block map page PBN, in little-endian byte
249 * order
254 * Bits 87..48: The five-byte block map entry encoding the location that will be stored in
260 * Bits 127..88: The five-byte block map entry encoding the location that was stored in the
266 /* The packed, on-disk representation of an old format recovery journal entry. */
269 * In little-endian bit order:
270 * Bits 15..12: The four highest bits of the 36-bit physical block number of the block map
272 * Bits 11..2: The 10-bit block map page slot number
273 * Bits 1..0: The 2-bit journal_operation of the entry
289 * Bits 47..16: The 32 low-order bits of the block map page PBN, in little-endian byte
290 * order
295 * Bits 87..48: The five-byte block map entry encoding the location that was or will be
316 u8 check_byte; /* The protection check byte */
322 * The packed, on-disk representation of a recovery journal block header. All fields are kept in
323 * little-endian byte order.
326 /* Block map head 64-bit sequence number */
329 /* Slab journal head 64-bit sequence number */
332 /* The 64-bit sequence number for this block */
335 /* A given VDO instance's 64-bit nonce */
338 /* 8-bit metadata type (should always be one for the recovery journal) */
341 /* 16-bit count of the entries encoded in the block */
344 /* 64-bit count of the logical blocks used when this block was opened */
347 /* 64-bit count of the block map blocks used when this block was opened */
350 /* The protection check byte */
358 /* The protection check byte */
374 ((VDO_SECTOR_SIZE - sizeof(struct packed_journal_sector)) /
381 ((VDO_SECTOR_SIZE - sizeof(struct packed_journal_sector)) /
397 /* A packed, platform-independent encoding of a struct journal_point. */
400 * The packed representation is the little-endian 64-bit representation of the low-order 48
401 * bits of the sequence number, shifted up 16 bits, or'ed with the 16-bit entry count.
403 * Very long-term, the top 16 bits of the sequence number may not always be zero, as this
404 * encoding assumes--see BZ 1523240.
418 ((VDO_SECTOR_SIZE - sizeof(struct packed_journal_point)) / sizeof(vdo_refcount_t)),
455 /* A single slab journal entry in its on-disk form */
488 * The packed, on-disk representation of a slab journal block header. All fields are kept in
489 * little-endian byte order.
492 /* 64-bit sequence number for head of journal */
494 /* 64-bit sequence number for this block */
498 /* The 64-bit nonce for a given VDO instance */
500 /* 8-bit metadata type (should always be two, for the slab journal) */
504 /* 16-bit count of the entries encoded in the block */
510 VDO_BLOCK_SIZE - sizeof(struct packed_slab_journal_block_header),
513 ((VDO_SLAB_JOURNAL_FULL_ENTRIES_PER_BLOCK - 1) / 8) + 1,
621 * A packed, machine-independent, on-disk representation of the vdo_config in the VDO component
633 * A packed, machine-independent, on-disk representation of version 41.0 of the VDO component data
645 * The version of the on-disk format of a VDO volume. This should be incremented any time the
646 * on-disk representation of any VDO structure changes. Changes which require only online upgrade
665 VDO_MAX_COMPONENT_DATA_SIZE = VDO_SECTOR_SIZE - VDO_SUPER_BLOCK_FIXED_SIZE,
697 * vdo_are_same_version() - Check whether two version numbers are the same.
711 * vdo_is_upgradable_version() - Check whether an actual version is upgradable to an expected
736 * vdo_pack_version_number() - Convert a version_number to its packed on-disk representation.
739 * Return: the platform-independent representation of the version
750 * vdo_unpack_version_number() - Convert a packed_version_number to its native in-memory
754 * Return: The platform-independent representation of the version.
765 * vdo_pack_header() - Convert a component header to its packed on-disk representation.
768 * Return: the platform-independent representation of the header
773 .id = __cpu_to_le32(header->id), in vdo_pack_header()
774 .version = vdo_pack_version_number(header->version), in vdo_pack_header()
775 .size = __cpu_to_le64(header->size), in vdo_pack_header()
780 * vdo_unpack_header() - Convert a packed_header to its native in-memory representation.
783 * Return: The platform-independent representation of the version.
788 .id = __le32_to_cpu(header->id), in vdo_unpack_header()
789 .version = vdo_unpack_version_number(header->version), in vdo_unpack_header()
790 .size = __le64_to_cpu(header->size), in vdo_unpack_header()
795 * vdo_get_index_region_start() - Get the start of the index region from a geometry.
807 * vdo_get_data_region_start() - Get the start of the data region from a geometry.
819 * vdo_get_index_region_size() - Get the size of the index region from a geometry.
827 return vdo_get_data_region_start(geometry) - in vdo_get_index_region_size()
851 physical_block_number_t low32 = __le32_to_cpu(entry->pbn_low_word); in vdo_unpack_block_map_entry()
852 physical_block_number_t high4 = entry->pbn_high_nibble; in vdo_unpack_block_map_entry()
856 .state = entry->mapping_state, in vdo_unpack_block_map_entry()
862 return (location->state != VDO_MAPPING_STATE_UNMAPPED); in vdo_is_mapped_location()
867 if (location->pbn == VDO_ZERO_BLOCK) in vdo_is_valid_location()
868 return !vdo_is_state_compressed(location->state); in vdo_is_valid_location()
876 return __le64_to_cpu(page->header.pbn); in vdo_get_block_map_page_pbn()
898 * vdo_pack_recovery_journal_entry() - Return the packed, on-disk representation of a recovery
908 .operation = entry->operation, in vdo_pack_recovery_journal_entry()
909 .slot_low = entry->slot.slot & 0x3F, in vdo_pack_recovery_journal_entry()
910 .slot_high = (entry->slot.slot >> 6) & 0x0F, in vdo_pack_recovery_journal_entry()
911 .pbn_high_nibble = (entry->slot.pbn >> 32) & 0x0F, in vdo_pack_recovery_journal_entry()
912 .pbn_low_word = __cpu_to_le32(entry->slot.pbn & UINT_MAX), in vdo_pack_recovery_journal_entry()
913 .mapping = vdo_pack_block_map_entry(entry->mapping.pbn, in vdo_pack_recovery_journal_entry()
914 entry->mapping.state), in vdo_pack_recovery_journal_entry()
915 .unmapping = vdo_pack_block_map_entry(entry->unmapping.pbn, in vdo_pack_recovery_journal_entry()
916 entry->unmapping.state), in vdo_pack_recovery_journal_entry()
921 * vdo_unpack_recovery_journal_entry() - Unpack the on-disk representation of a recovery journal
930 physical_block_number_t low32 = __le32_to_cpu(entry->pbn_low_word); in vdo_unpack_recovery_journal_entry()
931 physical_block_number_t high4 = entry->pbn_high_nibble; in vdo_unpack_recovery_journal_entry()
934 .operation = entry->operation, in vdo_unpack_recovery_journal_entry()
937 .slot = (entry->slot_low | (entry->slot_high << 6)), in vdo_unpack_recovery_journal_entry()
939 .mapping = vdo_unpack_block_map_entry(&entry->mapping), in vdo_unpack_recovery_journal_entry()
940 .unmapping = vdo_unpack_block_map_entry(&entry->unmapping), in vdo_unpack_recovery_journal_entry()
947 * vdo_is_valid_recovery_journal_sector() - Determine whether the header of the given sector could
961 if ((header->check_byte != sector->check_byte) || in vdo_is_valid_recovery_journal_sector()
962 (header->recovery_count != sector->recovery_count)) in vdo_is_valid_recovery_journal_sector()
965 if (header->metadata_type == VDO_METADATA_RECOVERY_JOURNAL_2) in vdo_is_valid_recovery_journal_sector()
966 return sector->entry_count <= RECOVERY_JOURNAL_ENTRIES_PER_SECTOR; in vdo_is_valid_recovery_journal_sector()
969 return sector->entry_count <= RECOVERY_JOURNAL_1_ENTRIES_IN_LAST_SECTOR; in vdo_is_valid_recovery_journal_sector()
971 return sector->entry_count <= RECOVERY_JOURNAL_1_ENTRIES_PER_SECTOR; in vdo_is_valid_recovery_journal_sector()
975 * vdo_compute_recovery_journal_block_number() - Compute the physical block number of the recovery
989 * from the low-order bits of the sequence. in vdo_compute_recovery_journal_block_number()
991 return (sequence_number & (journal_size - 1)); in vdo_compute_recovery_journal_block_number()
995 * vdo_get_journal_block_sector() - Find the recovery journal sector from the block header and
998 * @sector_number: The index of the sector (1-based).
1011 * vdo_pack_recovery_block_header() - Generate the packed representation of a recovery block
1020 .block_map_head = __cpu_to_le64(header->block_map_head), in vdo_pack_recovery_block_header()
1021 .slab_journal_head = __cpu_to_le64(header->slab_journal_head), in vdo_pack_recovery_block_header()
1022 .sequence_number = __cpu_to_le64(header->sequence_number), in vdo_pack_recovery_block_header()
1023 .nonce = __cpu_to_le64(header->nonce), in vdo_pack_recovery_block_header()
1024 .logical_blocks_used = __cpu_to_le64(header->logical_blocks_used), in vdo_pack_recovery_block_header()
1025 .block_map_data_blocks = __cpu_to_le64(header->block_map_data_blocks), in vdo_pack_recovery_block_header()
1026 .entry_count = __cpu_to_le16(header->entry_count), in vdo_pack_recovery_block_header()
1027 .check_byte = header->check_byte, in vdo_pack_recovery_block_header()
1028 .recovery_count = header->recovery_count, in vdo_pack_recovery_block_header()
1029 .metadata_type = header->metadata_type, in vdo_pack_recovery_block_header()
1034 * vdo_unpack_recovery_block_header() - Decode the packed representation of a recovery block
1044 .block_map_head = __le64_to_cpu(packed->block_map_head), in vdo_unpack_recovery_block_header()
1045 .slab_journal_head = __le64_to_cpu(packed->slab_journal_head), in vdo_unpack_recovery_block_header()
1046 .sequence_number = __le64_to_cpu(packed->sequence_number), in vdo_unpack_recovery_block_header()
1047 .nonce = __le64_to_cpu(packed->nonce), in vdo_unpack_recovery_block_header()
1048 .logical_blocks_used = __le64_to_cpu(packed->logical_blocks_used), in vdo_unpack_recovery_block_header()
1049 .block_map_data_blocks = __le64_to_cpu(packed->block_map_data_blocks), in vdo_unpack_recovery_block_header()
1050 .entry_count = __le16_to_cpu(packed->entry_count), in vdo_unpack_recovery_block_header()
1051 .check_byte = packed->check_byte, in vdo_unpack_recovery_block_header()
1052 .recovery_count = packed->recovery_count, in vdo_unpack_recovery_block_header()
1053 .metadata_type = packed->metadata_type, in vdo_unpack_recovery_block_header()
1058 * vdo_compute_slab_count() - Compute the number of slabs a depot with given parameters would have.
1069 return (slab_count_t) ((last_block - first_block) >> slab_size_shift); in vdo_compute_slab_count()
1082 * vdo_get_saved_reference_count_size() - Get the number of blocks required to save a reference
1095 * vdo_get_slab_journal_start_block() - Get the physical block number of the start of the slab
1104 return origin + slab_config->data_blocks + slab_config->reference_count_blocks; in vdo_get_slab_journal_start_block()
1108 * vdo_advance_journal_point() - Move the given journal point forward by one entry.
1115 point->entry_count++; in vdo_advance_journal_point()
1116 if (point->entry_count == entries_per_block) { in vdo_advance_journal_point()
1117 point->sequence_number++; in vdo_advance_journal_point()
1118 point->entry_count = 0; in vdo_advance_journal_point()
1123 * vdo_before_journal_point() - Check whether the first point precedes the second point.
1132 return ((first->sequence_number < second->sequence_number) || in vdo_before_journal_point()
1133 ((first->sequence_number == second->sequence_number) && in vdo_before_journal_point()
1134 (first->entry_count < second->entry_count))); in vdo_before_journal_point()
1138 * vdo_pack_journal_point() - Encode the journal location represented by a
1146 packed->encoded_point = in vdo_pack_journal_point()
1147 __cpu_to_le64((unpacked->sequence_number << 16) | unpacked->entry_count); in vdo_pack_journal_point()
1151 * vdo_unpack_journal_point() - Decode the journal location represented by a packed_journal_point
1159 u64 native = __le64_to_cpu(packed->encoded_point); in vdo_unpack_journal_point()
1161 unpacked->sequence_number = (native >> 16); in vdo_unpack_journal_point()
1162 unpacked->entry_count = (native & 0xffff); in vdo_unpack_journal_point()
1166 * vdo_pack_slab_journal_block_header() - Generate the packed representation of a slab block
1175 packed->head = __cpu_to_le64(header->head); in vdo_pack_slab_journal_block_header()
1176 packed->sequence_number = __cpu_to_le64(header->sequence_number); in vdo_pack_slab_journal_block_header()
1177 packed->nonce = __cpu_to_le64(header->nonce); in vdo_pack_slab_journal_block_header()
1178 packed->entry_count = __cpu_to_le16(header->entry_count); in vdo_pack_slab_journal_block_header()
1179 packed->metadata_type = header->metadata_type; in vdo_pack_slab_journal_block_header()
1180 packed->has_block_map_increments = header->has_block_map_increments; in vdo_pack_slab_journal_block_header()
1182 vdo_pack_journal_point(&header->recovery_point, &packed->recovery_point); in vdo_pack_slab_journal_block_header()
1186 * vdo_unpack_slab_journal_block_header() - Decode the packed representation of a slab block
1196 .head = __le64_to_cpu(packed->head), in vdo_unpack_slab_journal_block_header()
1197 .sequence_number = __le64_to_cpu(packed->sequence_number), in vdo_unpack_slab_journal_block_header()
1198 .nonce = __le64_to_cpu(packed->nonce), in vdo_unpack_slab_journal_block_header()
1199 .entry_count = __le16_to_cpu(packed->entry_count), in vdo_unpack_slab_journal_block_header()
1200 .metadata_type = packed->metadata_type, in vdo_unpack_slab_journal_block_header()
1201 .has_block_map_increments = packed->has_block_map_increments, in vdo_unpack_slab_journal_block_header()
1203 vdo_unpack_journal_point(&packed->recovery_point, &header->recovery_point); in vdo_unpack_slab_journal_block_header()
1207 * vdo_pack_slab_journal_entry() - Generate the packed encoding of a slab journal entry.
1215 packed->offset_low8 = (sbn & 0x0000FF); in vdo_pack_slab_journal_entry()
1216 packed->offset_mid8 = (sbn & 0x00FF00) >> 8; in vdo_pack_slab_journal_entry()
1217 packed->offset_high7 = (sbn & 0x7F0000) >> 16; in vdo_pack_slab_journal_entry()
1218 packed->increment = is_increment ? 1 : 0; in vdo_pack_slab_journal_entry()
1222 * vdo_unpack_slab_journal_entry() - Decode the packed representation of a slab journal entry.
1232 entry.sbn = packed->offset_high7; in vdo_unpack_slab_journal_entry()
1234 entry.sbn |= packed->offset_mid8; in vdo_unpack_slab_journal_entry()
1236 entry.sbn |= packed->offset_low8; in vdo_unpack_slab_journal_entry()
1238 entry.increment = packed->increment; in vdo_unpack_slab_journal_entry()
1247 * vdo_get_slab_summary_hint_shift() - Compute the shift for slab summary hints.
1255 (slab_size_shift - VDO_SLAB_SUMMARY_FULLNESS_HINT_BITS) : in vdo_get_slab_summary_hint_shift()