Loading fs_mgr/libsnapshot/android/snapshot/snapshot.proto +3 −0 Original line number Diff line number Diff line Loading @@ -140,4 +140,7 @@ message SnapshotMergeReport { // Number of reboots that occurred after issuing and before completeing the // merge of all the snapshot devices. int32 resume_count = 2; // Total size of all the COW images before the update. uint64 cow_file_size = 4; } fs_mgr/libsnapshot/include/libsnapshot/snapshot.h +1 −1 Original line number Diff line number Diff line Loading @@ -148,7 +148,7 @@ class SnapshotManager final { // Initiate a merge on all snapshot devices. This should only be used after an // update has been marked successful after booting. bool InitiateMerge(); bool InitiateMerge(uint64_t* cow_file_size = nullptr); // Perform any necessary post-boot actions. This should be run soon after // /data is mounted. Loading fs_mgr/libsnapshot/include/libsnapshot/snapshot_stats.h +4 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,8 @@ class SnapshotMergeStats { // Called when merge starts or resumes. bool Start(); void set_state(android::snapshot::UpdateState state); virtual void set_cow_file_size(uint64_t cow_file_size); virtual uint64_t cow_file_size(); // Called when merge ends. Properly clean up permanent storage. class Result { Loading @@ -43,6 +45,8 @@ class SnapshotMergeStats { std::unique_ptr<Result> Finish(); private: virtual ~SnapshotMergeStats() {} bool ReadState(); bool WriteState(); bool DeleteState(); Loading fs_mgr/libsnapshot/snapshot.cpp +12 −1 Original line number Diff line number Diff line Loading @@ -555,7 +555,7 @@ bool SnapshotManager::DeleteSnapshot(LockedFile* lock, const std::string& name) return true; } bool SnapshotManager::InitiateMerge() { bool SnapshotManager::InitiateMerge(uint64_t* cow_file_size) { auto lock = LockExclusive(); if (!lock) return false; Loading Loading @@ -618,6 +618,7 @@ bool SnapshotManager::InitiateMerge() { } } uint64_t total_cow_file_size = 0; DmTargetSnapshot::Status initial_target_values = {}; for (const auto& snapshot : snapshots) { DmTargetSnapshot::Status current_status; Loading @@ -627,6 +628,16 @@ bool SnapshotManager::InitiateMerge() { initial_target_values.sectors_allocated += current_status.sectors_allocated; initial_target_values.total_sectors += current_status.total_sectors; initial_target_values.metadata_sectors += current_status.metadata_sectors; SnapshotStatus snapshot_status; if (!ReadSnapshotStatus(lock.get(), snapshot, &snapshot_status)) { return false; } total_cow_file_size += snapshot_status.cow_file_size(); } if (cow_file_size) { *cow_file_size = total_cow_file_size; } SnapshotUpdateStatus initial_status; Loading fs_mgr/libsnapshot/snapshot_stats.cpp +9 −0 Original line number Diff line number Diff line Loading @@ -88,6 +88,15 @@ void SnapshotMergeStats::set_state(android::snapshot::UpdateState state) { report_.set_state(state); } void SnapshotMergeStats::set_cow_file_size(uint64_t cow_file_size) { report_.set_cow_file_size(cow_file_size); WriteState(); } uint64_t SnapshotMergeStats::cow_file_size() { return report_.cow_file_size(); } class SnapshotMergeStatsResultImpl : public SnapshotMergeStats::Result { public: SnapshotMergeStatsResultImpl(const SnapshotMergeReport& report, Loading Loading
fs_mgr/libsnapshot/android/snapshot/snapshot.proto +3 −0 Original line number Diff line number Diff line Loading @@ -140,4 +140,7 @@ message SnapshotMergeReport { // Number of reboots that occurred after issuing and before completeing the // merge of all the snapshot devices. int32 resume_count = 2; // Total size of all the COW images before the update. uint64 cow_file_size = 4; }
fs_mgr/libsnapshot/include/libsnapshot/snapshot.h +1 −1 Original line number Diff line number Diff line Loading @@ -148,7 +148,7 @@ class SnapshotManager final { // Initiate a merge on all snapshot devices. This should only be used after an // update has been marked successful after booting. bool InitiateMerge(); bool InitiateMerge(uint64_t* cow_file_size = nullptr); // Perform any necessary post-boot actions. This should be run soon after // /data is mounted. Loading
fs_mgr/libsnapshot/include/libsnapshot/snapshot_stats.h +4 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,8 @@ class SnapshotMergeStats { // Called when merge starts or resumes. bool Start(); void set_state(android::snapshot::UpdateState state); virtual void set_cow_file_size(uint64_t cow_file_size); virtual uint64_t cow_file_size(); // Called when merge ends. Properly clean up permanent storage. class Result { Loading @@ -43,6 +45,8 @@ class SnapshotMergeStats { std::unique_ptr<Result> Finish(); private: virtual ~SnapshotMergeStats() {} bool ReadState(); bool WriteState(); bool DeleteState(); Loading
fs_mgr/libsnapshot/snapshot.cpp +12 −1 Original line number Diff line number Diff line Loading @@ -555,7 +555,7 @@ bool SnapshotManager::DeleteSnapshot(LockedFile* lock, const std::string& name) return true; } bool SnapshotManager::InitiateMerge() { bool SnapshotManager::InitiateMerge(uint64_t* cow_file_size) { auto lock = LockExclusive(); if (!lock) return false; Loading Loading @@ -618,6 +618,7 @@ bool SnapshotManager::InitiateMerge() { } } uint64_t total_cow_file_size = 0; DmTargetSnapshot::Status initial_target_values = {}; for (const auto& snapshot : snapshots) { DmTargetSnapshot::Status current_status; Loading @@ -627,6 +628,16 @@ bool SnapshotManager::InitiateMerge() { initial_target_values.sectors_allocated += current_status.sectors_allocated; initial_target_values.total_sectors += current_status.total_sectors; initial_target_values.metadata_sectors += current_status.metadata_sectors; SnapshotStatus snapshot_status; if (!ReadSnapshotStatus(lock.get(), snapshot, &snapshot_status)) { return false; } total_cow_file_size += snapshot_status.cow_file_size(); } if (cow_file_size) { *cow_file_size = total_cow_file_size; } SnapshotUpdateStatus initial_status; Loading
fs_mgr/libsnapshot/snapshot_stats.cpp +9 −0 Original line number Diff line number Diff line Loading @@ -88,6 +88,15 @@ void SnapshotMergeStats::set_state(android::snapshot::UpdateState state) { report_.set_state(state); } void SnapshotMergeStats::set_cow_file_size(uint64_t cow_file_size) { report_.set_cow_file_size(cow_file_size); WriteState(); } uint64_t SnapshotMergeStats::cow_file_size() { return report_.cow_file_size(); } class SnapshotMergeStatsResultImpl : public SnapshotMergeStats::Result { public: SnapshotMergeStatsResultImpl(const SnapshotMergeReport& report, Loading