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

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

Merge changes I2db0e626,Ic69fc2f5

* changes:
  libsnapshot: Only mount snapshots in MapAllSnapshots().
  libsnapshot: Do not attempt compression features in recovery.
parents 1d9a7adc 5283ae4a
Loading
Loading
Loading
Loading
+41 −9
Original line number Diff line number Diff line
@@ -2130,10 +2130,6 @@ bool SnapshotManager::UnmapCowDevices(LockedFile* lock, const std::string& name)
bool SnapshotManager::UnmapDmUserDevice(const std::string& snapshot_name) {
    auto& dm = DeviceMapper::Instance();

    if (!EnsureSnapuserdConnected()) {
        return false;
    }

    auto dm_user_name = GetDmUserCowName(snapshot_name);
    if (dm.GetState(dm_user_name) == DmDeviceState::INVALID) {
        return true;
@@ -2144,6 +2140,9 @@ bool SnapshotManager::UnmapDmUserDevice(const std::string& snapshot_name) {
        return false;
    }

    if (!EnsureSnapuserdConnected()) {
        return false;
    }
    if (!snapuserd_client_->WaitForDeviceDelete(dm_user_name)) {
        LOG(ERROR) << "Failed to wait for " << dm_user_name << " control device to delete";
        return false;
@@ -2173,12 +2172,44 @@ bool SnapshotManager::MapAllSnapshots(const std::chrono::milliseconds& timeout_m
        return false;
    }

    if (!UnmapAllSnapshots(lock.get())) {
    std::vector<std::string> snapshots;
    if (!ListSnapshots(lock.get(), &snapshots)) {
        return false;
    }

    const auto& opener = device_->GetPartitionOpener();
    auto slot_suffix = device_->GetOtherSlotSuffix();
    auto slot_number = SlotNumberForSlotSuffix(slot_suffix);
    auto super_device = device_->GetSuperDevice(slot_number);
    auto metadata = android::fs_mgr::ReadMetadata(opener, super_device, slot_number);
    if (!metadata) {
        LOG(ERROR) << "MapAllSnapshots could not read dynamic partition metadata for device: "
                   << super_device;
        return false;
    }

    uint32_t slot = SlotNumberForSlotSuffix(device_->GetOtherSlotSuffix());
    return MapAllPartitions(lock.get(), device_->GetSuperDevice(slot), slot, timeout_ms);
    for (const auto& snapshot : snapshots) {
        if (!UnmapPartitionWithSnapshot(lock.get(), snapshot)) {
            LOG(ERROR) << "MapAllSnapshots could not unmap snapshot: " << snapshot;
            return false;
        }

        CreateLogicalPartitionParams params = {
                .block_device = super_device,
                .metadata = metadata.get(),
                .partition_name = snapshot,
                .partition_opener = &opener,
                .timeout_ms = timeout_ms,
        };
        if (!MapPartitionWithSnapshot(lock.get(), std::move(params), SnapshotContext::Mount,
                                      nullptr)) {
            LOG(ERROR) << "MapAllSnapshots failed to map: " << snapshot;
            return false;
        }
    }

    LOG(INFO) << "MapAllSnapshots succeeded.";
    return true;
}

bool SnapshotManager::UnmapAllSnapshots() {
@@ -2585,8 +2616,9 @@ Return SnapshotManager::CreateUpdateSnapshots(const DeltaArchiveManifest& manife
    // these devices.
    AutoDeviceList created_devices;

    bool use_compression =
            IsCompressionEnabled() && manifest.dynamic_partition_metadata().vabc_enabled();
    bool use_compression = IsCompressionEnabled() &&
                           manifest.dynamic_partition_metadata().vabc_enabled() &&
                           !device_->IsRecovery();

    PartitionCowCreator cow_creator{
            .target_metadata = target_metadata.get(),