Merge "libsnapshot: Don't call RemoveAllSnapshots on normal boot." into main am: 0bb1098965
Original change: https://android-review.googlesource.com/c/platform/system/core/+/3508341
Change-Id: I7dc608bae935fee9c2f39aef389240c8cce3d5fa
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/fs_mgr/libsnapshot/snapshot.cpp b/fs_mgr/libsnapshot/snapshot.cpp
index b614aab..adfb16b 100644
--- a/fs_mgr/libsnapshot/snapshot.cpp
+++ b/fs_mgr/libsnapshot/snapshot.cpp
@@ -351,9 +351,14 @@
LOG(INFO) << "Removing all update state.";
- if (!RemoveAllSnapshots(lock)) {
- LOG(ERROR) << "Could not remove all snapshots";
- return false;
+ if (ReadUpdateState(lock) != UpdateState::None) {
+ // Only call this if we're actually cancelling an update. It's not
+ // expected to yield anything otherwise, and firing up gsid on normal
+ // boot is expensive.
+ if (!RemoveAllSnapshots(lock)) {
+ LOG(ERROR) << "Could not remove all snapshots";
+ return false;
+ }
}
// It's okay if these fail: