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

Commit 6c31ab7a authored by David Anderson's avatar David Anderson Committed by Gerrit Code Review
Browse files

Merge changes I350c8c88,I1e462fad

* changes:
  libsnapshot: Fix unmapping getting skipped for userspace snapshots.
  libsnapshot: Don't map "b" partitions during testing.
parents 4bf3c13d d2f8d514
Loading
Loading
Loading
Loading
+15 −17
Original line number Diff line number Diff line
@@ -668,10 +668,16 @@ bool SnapshotManager::MapSourceDevice(LockedFile* lock, const std::string& name,
bool SnapshotManager::UnmapSnapshot(LockedFile* lock, const std::string& name) {
    CHECK(lock);

    if (UpdateUsesUserSnapshots(lock)) {
        if (!UnmapUserspaceSnapshotDevice(lock, name)) {
            return false;
        }
    } else {
        if (!DeleteDeviceIfExists(name)) {
            LOG(ERROR) << "Could not delete snapshot device: " << name;
            return false;
        }
    }
    return true;
}

@@ -2429,11 +2435,9 @@ bool SnapshotManager::UnmapPartitionWithSnapshot(LockedFile* lock,
                                                 const std::string& target_partition_name) {
    CHECK(lock);

    if (!UpdateUsesUserSnapshots(lock)) {
    if (!UnmapSnapshot(lock, target_partition_name)) {
        return false;
    }
    }

    if (!UnmapCowDevices(lock, target_partition_name)) {
        return false;
@@ -2530,18 +2534,12 @@ bool SnapshotManager::UnmapCowDevices(LockedFile* lock, const std::string& name)
    CHECK(lock);
    if (!EnsureImageManager()) return false;

    if (UpdateUsesCompression(lock)) {
        if (UpdateUsesUserSnapshots(lock)) {
            if (!UnmapUserspaceSnapshotDevice(lock, name)) {
                return false;
            }
        } else {
    if (UpdateUsesCompression(lock) && !UpdateUsesUserSnapshots(lock)) {
        auto dm_user_name = GetDmUserCowName(name, GetSnapshotDriver(lock));
        if (!UnmapDmUserDevice(dm_user_name)) {
            return false;
        }
    }
    }

    if (!DeleteDeviceIfExists(GetCowName(name), 4000ms)) {
        LOG(ERROR) << "Cannot unmap: " << GetCowName(name);
+2 −2
Original line number Diff line number Diff line
@@ -897,9 +897,9 @@ class SnapshotUpdateTest : public SnapshotTest {
        ASSERT_NE(nullptr, metadata);
        ASSERT_TRUE(UpdatePartitionTable(*opener_, "super", *metadata.get(), 0));

        // Map source partitions. Additionally, map sys_b to simulate system_other after flashing.
        // Map source partitions.
        std::string path;
        for (const auto& name : {"sys_a", "vnd_a", "prd_a", "sys_b"}) {
        for (const auto& name : {"sys_a", "vnd_a", "prd_a"}) {
            ASSERT_TRUE(CreateLogicalPartition(
                    CreateLogicalPartitionParams{
                            .block_device = fake_super,