Skip to content

Commit 5283ae4

Browse files
committed
libsnapshot: Only mount snapshots in MapAllSnapshots().
By accident, this was mounting partitions as well, which caused conflicts in partial updates where some partitions don't have snapshots. Test: update_device.py with partial OTA Change-Id: I2db0e6269f0a02cbe8164fa2a72b887c352f56d8
1 parent 71ab9db commit 5283ae4

File tree

1 file changed

+35
-3
lines changed

1 file changed

+35
-3
lines changed

fs_mgr/libsnapshot/snapshot.cpp

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2172,12 +2172,44 @@ bool SnapshotManager::MapAllSnapshots(const std::chrono::milliseconds& timeout_m
21722172
return false;
21732173
}
21742174

2175-
if (!UnmapAllSnapshots(lock.get())) {
2175+
std::vector<std::string> snapshots;
2176+
if (!ListSnapshots(lock.get(), &snapshots)) {
2177+
return false;
2178+
}
2179+
2180+
const auto& opener = device_->GetPartitionOpener();
2181+
auto slot_suffix = device_->GetOtherSlotSuffix();
2182+
auto slot_number = SlotNumberForSlotSuffix(slot_suffix);
2183+
auto super_device = device_->GetSuperDevice(slot_number);
2184+
auto metadata = android::fs_mgr::ReadMetadata(opener, super_device, slot_number);
2185+
if (!metadata) {
2186+
LOG(ERROR) << "MapAllSnapshots could not read dynamic partition metadata for device: "
2187+
<< super_device;
21762188
return false;
21772189
}
21782190

2179-
uint32_t slot = SlotNumberForSlotSuffix(device_->GetOtherSlotSuffix());
2180-
return MapAllPartitions(lock.get(), device_->GetSuperDevice(slot), slot, timeout_ms);
2191+
for (const auto& snapshot : snapshots) {
2192+
if (!UnmapPartitionWithSnapshot(lock.get(), snapshot)) {
2193+
LOG(ERROR) << "MapAllSnapshots could not unmap snapshot: " << snapshot;
2194+
return false;
2195+
}
2196+
2197+
CreateLogicalPartitionParams params = {
2198+
.block_device = super_device,
2199+
.metadata = metadata.get(),
2200+
.partition_name = snapshot,
2201+
.partition_opener = &opener,
2202+
.timeout_ms = timeout_ms,
2203+
};
2204+
if (!MapPartitionWithSnapshot(lock.get(), std::move(params), SnapshotContext::Mount,
2205+
nullptr)) {
2206+
LOG(ERROR) << "MapAllSnapshots failed to map: " << snapshot;
2207+
return false;
2208+
}
2209+
}
2210+
2211+
LOG(INFO) << "MapAllSnapshots succeeded.";
2212+
return true;
21812213
}
21822214

21832215
bool SnapshotManager::UnmapAllSnapshots() {

0 commit comments

Comments
 (0)