Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ef9740c6 authored by David Anderson's avatar David Anderson
Browse files

liblp: Allow the super partition to span multiple block devices.

This patch allows the block device table in LpMetadataHeader to contain
additional partitions. MetadataBuilder can now resize partitions such
that are allocated across block devices as needed, however, it attempts
to minimize this by grouping free regions by device.

Bug: 116802789
Test: liblp_test gtests
      device with super partition flashes and boots

Change-Id: I9cf74c8925faf154703eeba2a26546a152efcaa2
parent 7a6c511a
Loading
Loading
Loading
Loading
+2 −7
Original line number Diff line number Diff line
@@ -75,14 +75,9 @@ static bool CreateDmTable(const LpMetadata& metadata, const LpMetadataPartition&
                target = std::make_unique<DmTargetZero>(sector, extent.num_sectors);
                break;
            case LP_TARGET_TYPE_LINEAR: {
                auto block_device = GetMetadataSuperBlockDevice(metadata);
                if (!block_device) {
                    LOG(ERROR) << "Could not identify the super block device";
                    return false;
                }

                const auto& block_device = metadata.block_devices[extent.target_source];
                std::string path;
                if (!GetPhysicalPartitionDevicePath(*block_device, &path)) {
                if (!GetPhysicalPartitionDevicePath(block_device, &path)) {
                    LOG(ERROR) << "Unable to complete device-mapper table, unknown block device";
                    return false;
                }
+207 −89

File changed.

Preview size limit exceeded, changes collapsed.

+72 −20

File changed.

Preview size limit exceeded, changes collapsed.

+39 −21

File changed.

Preview size limit exceeded, changes collapsed.

+11 −3
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@ extern "C" {
#define LP_METADATA_HEADER_MAGIC 0x414C5030

/* Current metadata version. */
#define LP_METADATA_MAJOR_VERSION 7
#define LP_METADATA_MAJOR_VERSION 8
#define LP_METADATA_MINOR_VERSION 0

/* Attributes for the LpMetadataPartition::attributes field.
@@ -240,6 +240,13 @@ typedef struct LpMetadataExtent {
     * ZERO: This field must be 0.
     */
    uint64_t target_data;

    /* 20: Contents depends on target_type.
     *
     * LINEAR: Must be an index into the block devices table.
     * ZERO: This field must be 0.
     */
    uint32_t target_source;
} __attribute__((packed)) LpMetadataExtent;

/* This struct defines an entry in the groups table. Each group has a maximum
@@ -255,8 +262,9 @@ typedef struct LpMetadataPartitionGroup {
    uint64_t maximum_size;
} LpMetadataPartitionGroup;

/* This struct defines an entry in the block_devices table. There must be
 * exactly one device, corresponding to the super partition.
/* This struct defines an entry in the block_devices table. There must be at
 * least one device, and the first device must represent the partition holding
 * the super metadata.
 */
typedef struct LpMetadataBlockDevice {
    /* 0: First usable sector for allocating logical partitions. this will be
Loading