Lines Matching full:layout

786  * allocate_partition() - Allocate a partition and add it to a layout.
787 * @layout: The layout containing the partition.
789 * @offset: The offset into the layout at which the partition begins.
794 static int allocate_partition(struct layout *layout, u8 id, in allocate_partition() argument
807 partition->next = layout->head; in allocate_partition()
808 layout->head = partition; in allocate_partition()
815 * layout.
816 * @layout: The layout.
824 static int __must_check make_partition(struct layout *layout, enum partition_id id, in make_partition() argument
829 block_count_t free_blocks = layout->last_free - layout->first_free; in make_partition()
839 result = vdo_get_partition(layout, id, NULL); 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()
861 * @origin: The start of the layout on the underlying storage in blocks.
865 * @layout: The layout to initialize.
871 block_count_t summary_blocks, struct layout *layout) in vdo_initialize_layout() argument
881 *layout = (struct layout) { in vdo_initialize_layout()
890 result = make_partition(layout, VDO_BLOCK_MAP_PARTITION, block_map_blocks, true); in vdo_initialize_layout()
892 vdo_uninitialize_layout(layout); in vdo_initialize_layout()
896 result = make_partition(layout, VDO_SLAB_SUMMARY_PARTITION, summary_blocks, in vdo_initialize_layout()
899 vdo_uninitialize_layout(layout); in vdo_initialize_layout()
903 result = make_partition(layout, VDO_RECOVERY_JOURNAL_PARTITION, journal_blocks, in vdo_initialize_layout()
906 vdo_uninitialize_layout(layout); in vdo_initialize_layout()
910 result = make_partition(layout, VDO_SLAB_DEPOT_PARTITION, 0, true); in vdo_initialize_layout()
912 vdo_uninitialize_layout(layout); in vdo_initialize_layout()
918 * vdo_uninitialize_layout() - Clean up a layout.
919 * @layout: The layout to clean up.
921 * All partitions created by this layout become invalid pointers.
923 void vdo_uninitialize_layout(struct layout *layout) in vdo_uninitialize_layout() argument
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()
932 memset(layout, 0, sizeof(struct layout)); in vdo_uninitialize_layout()
937 * @layout: The layout from which to get a partition.
943 int vdo_get_partition(struct layout *layout, enum partition_id id, in vdo_get_partition() argument
948 for (partition = layout->head; partition != NULL; partition = partition->next) { 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.
966 struct partition *vdo_get_known_partition(struct layout *layout, enum partition_id id) in vdo_get_known_partition() argument
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()
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()
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()
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()
1005 "encoded size of a layout must match header size"); in encode_layout()
1009 block_count_t size, struct layout *layout) in decode_layout() argument
1021 /* Layout is variable size, so only do a minimum size check here. */ 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()
1049 "layout has extra partitions"); in decode_layout()
1052 for (i = 0; i < layout->num_partitions; i++) { in decode_layout()
1061 result = allocate_partition(layout, id, partition_offset, count); in decode_layout()
1063 vdo_uninitialize_layout(layout); in decode_layout()
1068 /* Validate that the layout has all (and only) the required partitions */ in decode_layout()
1070 result = vdo_get_partition(layout, REQUIRED_PARTITIONS[i], &partition); in decode_layout()
1072 vdo_uninitialize_layout(layout); in decode_layout()
1074 "layout is missing required partition %u", in decode_layout()
1082 vdo_uninitialize_layout(layout); in decode_layout()
1084 "partitions do not cover the layout"); in decode_layout()
1303 vdo_uninitialize_layout(&states->layout); in vdo_destroy_component_states()
1325 states->vdo.config.physical_blocks, &states->layout); in decode_components()
1373 vdo_uninitialize_layout(&states->layout); in vdo_decode_component_states()
1412 encode_layout(buffer, offset, &states->layout); in vdo_encode_component_states()