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

Commit 4d05c3e3 authored by David Anderson's avatar David Anderson Committed by Automerger Merge Worker
Browse files

Merge "libsnapshot: Add a compression bit to SnapshotUpdateStatus." am: 3fc65555

Original change: https://android-review.googlesource.com/c/platform/system/core/+/1507550

Change-Id: If58bc9faae1531c4050241e4b141b2886ea0e942
parents 9378395e 3fc65555
Loading
Loading
Loading
Loading
+4 −1
Original line number Original line Diff line number Diff line
@@ -118,7 +118,7 @@ enum UpdateState {
    Cancelled = 7;
    Cancelled = 7;
};
};


// Next: 5
// Next: 6
message SnapshotUpdateStatus {
message SnapshotUpdateStatus {
    UpdateState state = 1;
    UpdateState state = 1;


@@ -133,6 +133,9 @@ message SnapshotUpdateStatus {


    // Sectors allocated for metadata in all the snapshot devices.
    // Sectors allocated for metadata in all the snapshot devices.
    uint64 metadata_sectors = 4;
    uint64 metadata_sectors = 4;

    // Whether compression/dm-user was used for any snapshots.
    bool compression_enabled = 5;
}
}


// Next: 4
// Next: 4
+4 −0
Original line number Original line Diff line number Diff line
@@ -353,6 +353,10 @@ class SnapshotManager final : public ISnapshotManager {
        uevent_regen_callback_ = callback;
        uevent_regen_callback_ = callback;
    }
    }


    // If true, compression is enabled for this update. This is used by
    // first-stage to decide whether to launch snapuserd.
    bool IsSnapuserdRequired();

  private:
  private:
    FRIEND_TEST(SnapshotTest, CleanFirstStageMount);
    FRIEND_TEST(SnapshotTest, CleanFirstStageMount);
    FRIEND_TEST(SnapshotTest, CreateSnapshot);
    FRIEND_TEST(SnapshotTest, CreateSnapshot);
+10 −1
Original line number Original line Diff line number Diff line
@@ -2283,6 +2283,7 @@ SnapshotUpdateStatus SnapshotManager::ReadSnapshotUpdateStatus(LockedFile* lock)
bool SnapshotManager::WriteUpdateState(LockedFile* lock, UpdateState state) {
bool SnapshotManager::WriteUpdateState(LockedFile* lock, UpdateState state) {
    SnapshotUpdateStatus status = {};
    SnapshotUpdateStatus status = {};
    status.set_state(state);
    status.set_state(state);
    status.set_compression_enabled(IsCompressionEnabled());
    return WriteSnapshotUpdateStatus(lock, status);
    return WriteSnapshotUpdateStatus(lock, status);
}
}


@@ -2855,7 +2856,7 @@ std::unique_ptr<ISnapshotWriter> SnapshotManager::OpenSnapshotWriter(
        return nullptr;
        return nullptr;
    }
    }


    if (IsCompressionEnabled()) {
    if (status.compression_enabled()) {
        return OpenCompressedSnapshotWriter(lock.get(), source_device, params.GetPartitionName(),
        return OpenCompressedSnapshotWriter(lock.get(), source_device, params.GetPartitionName(),
                                            status, paths);
                                            status, paths);
    }
    }
@@ -3346,5 +3347,13 @@ bool SnapshotManager::WaitForDevice(const std::string& device,
    return true;
    return true;
}
}


bool SnapshotManager::IsSnapuserdRequired() {
    auto lock = LockExclusive();
    if (!lock) return false;

    auto status = ReadSnapshotUpdateStatus(lock.get());
    return status.state() != UpdateState::None && status.compression_enabled();
}

}  // namespace snapshot
}  // namespace snapshot
}  // namespace android
}  // namespace android