Skip to content

Commit ea1f0fa

Browse files
dvandercorpGerrit Code Review
authored andcommitted
Merge changes I2db0e626,Ic69fc2f5
* changes: libsnapshot: Only mount snapshots in MapAllSnapshots(). libsnapshot: Do not attempt compression features in recovery.
2 parents 1d9a7ad + 5283ae4 commit ea1f0fa

File tree

1 file changed

+41
-9
lines changed

1 file changed

+41
-9
lines changed

fs_mgr/libsnapshot/snapshot.cpp

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2130,10 +2130,6 @@ bool SnapshotManager::UnmapCowDevices(LockedFile* lock, const std::string& name)
21302130
bool SnapshotManager::UnmapDmUserDevice(const std::string& snapshot_name) {
21312131
auto& dm = DeviceMapper::Instance();
21322132

2133-
if (!EnsureSnapuserdConnected()) {
2134-
return false;
2135-
}
2136-
21372133
auto dm_user_name = GetDmUserCowName(snapshot_name);
21382134
if (dm.GetState(dm_user_name) == DmDeviceState::INVALID) {
21392135
return true;
@@ -2144,6 +2140,9 @@ bool SnapshotManager::UnmapDmUserDevice(const std::string& snapshot_name) {
21442140
return false;
21452141
}
21462142

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

2176-
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;
21772188
return false;
21782189
}
21792190

2180-
uint32_t slot = SlotNumberForSlotSuffix(device_->GetOtherSlotSuffix());
2181-
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;
21822213
}
21832214

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

2588-
bool use_compression =
2589-
IsCompressionEnabled() && manifest.dynamic_partition_metadata().vabc_enabled();
2619+
bool use_compression = IsCompressionEnabled() &&
2620+
manifest.dynamic_partition_metadata().vabc_enabled() &&
2621+
!device_->IsRecovery();
25902622

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

0 commit comments

Comments
 (0)