@@ -2130,10 +2130,6 @@ bool SnapshotManager::UnmapCowDevices(LockedFile* lock, const std::string& name)
2130
2130
bool SnapshotManager::UnmapDmUserDevice (const std::string& snapshot_name) {
2131
2131
auto & dm = DeviceMapper::Instance ();
2132
2132
2133
- if (!EnsureSnapuserdConnected ()) {
2134
- return false ;
2135
- }
2136
-
2137
2133
auto dm_user_name = GetDmUserCowName (snapshot_name);
2138
2134
if (dm.GetState (dm_user_name) == DmDeviceState::INVALID) {
2139
2135
return true ;
@@ -2144,6 +2140,9 @@ bool SnapshotManager::UnmapDmUserDevice(const std::string& snapshot_name) {
2144
2140
return false ;
2145
2141
}
2146
2142
2143
+ if (!EnsureSnapuserdConnected ()) {
2144
+ return false ;
2145
+ }
2147
2146
if (!snapuserd_client_->WaitForDeviceDelete (dm_user_name)) {
2148
2147
LOG (ERROR) << " Failed to wait for " << dm_user_name << " control device to delete" ;
2149
2148
return false ;
@@ -2173,12 +2172,44 @@ bool SnapshotManager::MapAllSnapshots(const std::chrono::milliseconds& timeout_m
2173
2172
return false ;
2174
2173
}
2175
2174
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;
2177
2188
return false ;
2178
2189
}
2179
2190
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 ;
2182
2213
}
2183
2214
2184
2215
bool SnapshotManager::UnmapAllSnapshots () {
@@ -2585,8 +2616,9 @@ Return SnapshotManager::CreateUpdateSnapshots(const DeltaArchiveManifest& manife
2585
2616
// these devices.
2586
2617
AutoDeviceList created_devices;
2587
2618
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 ();
2590
2622
2591
2623
PartitionCowCreator cow_creator{
2592
2624
.target_metadata = target_metadata.get (),
0 commit comments