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

Commit d967d01f authored by Akilesh Kailash's avatar Akilesh Kailash
Browse files

libsnapshot: Retrieve COW version from update engine manifest



update_metadata.proto will have the COW version. Retrieve
that from the manifest and compare it with the COW library.
If the versioning doesn't match, disable VABC.

The primary use case of this is during downgrade tests
in pre-submit. Whenever we have a COW format changes,
we may have to disable VABC for that specific transition
build. At a high level, the flow of version check will be:

1: Create a initial COW version of 1 in manifest (update_metadata.proto)
2: The latest COW version of libsnapshot is 2
3: libsnapshot will return VABC disabled
4: Check-in the CL and changes to manifest
5: Once the CL is baked in and the build is green, bump up the COW version to 2 in the manifest
6: Next set of tests, since both versions match, libsnapshot will enable VABC
7: Downgrade should be done to the build which was checked in at (5)

Bug: 183863613
Test: Apply OTA and verify if VABC is disabled if the versions don't
match
Signed-off-by: default avatarAkilesh Kailash <akailash@google.com>
Change-Id: Id55f33a90bb31b417e72f4fbe370daf05a68f05a
parent 771b17f5
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -106,6 +106,8 @@ class CowWriter : public ICowWriter {

    uint64_t GetCowSize() override;

    uint32_t GetCowVersion() { return header_.major_version; }

  protected:
    virtual bool EmitCopy(uint64_t new_block, uint64_t old_block) override;
    virtual bool EmitRawBlocks(uint64_t new_block_start, const void* data, size_t size) override;
+12 −2
Original line number Diff line number Diff line
@@ -2673,8 +2673,18 @@ Return SnapshotManager::CreateUpdateSnapshots(const DeltaArchiveManifest& manife
    AutoDeviceList created_devices;

    const auto& dap_metadata = manifest.dynamic_partition_metadata();
    bool use_compression =
            IsCompressionEnabled() && dap_metadata.vabc_enabled() && !device_->IsRecovery();
    CowOptions options;
    CowWriter writer(options);
    bool cow_format_support = true;
    if (dap_metadata.cow_version() < writer.GetCowVersion()) {
        cow_format_support = false;
    }

    LOG(INFO) << " dap_metadata.cow_version(): " << dap_metadata.cow_version()
              << " writer.GetCowVersion(): " << writer.GetCowVersion();

    bool use_compression = IsCompressionEnabled() && dap_metadata.vabc_enabled() &&
                           !device_->IsRecovery() && cow_format_support;

    std::string compression_algorithm;
    if (use_compression) {
+1 −0
Original line number Diff line number Diff line
@@ -75,6 +75,7 @@ message DynamicPartitionMetadata {
    repeated DynamicPartitionGroup groups = 1;
    optional bool vabc_enabled = 3;
    optional string vabc_compression_param = 4;
    optional uint32 cow_version = 5;
}

message DeltaArchiveManifest {