Loading fs_mgr/README.overlayfs.md +0 −6 Original line number Diff line number Diff line Loading @@ -96,12 +96,6 @@ Caveats may fail because of the scratch partition. If this happens, clear the scratch storage by running either either _fastboot flashall_ or _adb enable-verity_. Then reinstate the overrides and continue. - For implementation simplicity on retrofit dynamic partition devices, take the whole alternate super (eg: if "*a*" slot, then the whole of "*system_b*"). Since landing a filesystem on the alternate super physical device without differentiating if it is setup to support logical or physical, the alternate slot metadata and previous content will be lost. - There are other subtle caveats requiring complex logic to solve. Have evaluated them as too complex or not worth the trouble, please File a bug if a use case needs to be covered. Loading fs_mgr/libfs_avb/tests/fs_avb_device_test.cpp +2 −6 Original line number Diff line number Diff line Loading @@ -59,9 +59,7 @@ TEST(FsAvbUtilTest, GetHashtreeDescriptor_SystemOther) { if (fs_mgr_get_slot_suffix() == "") return; // Skip running this test if system_other is a logical partition. // Note that system_other is still a physical partition on "retrofit" devices. if (android::base::GetBoolProperty("ro.boot.dynamic_partitions", false) && !android::base::GetBoolProperty("ro.boot.dynamic_partitions_retrofit", false)) { if (android::base::GetBoolProperty("ro.boot.dynamic_partitions", false)) { return; } Loading Loading @@ -98,9 +96,7 @@ TEST(AvbHandleTest, LoadAndVerifyVbmeta_SystemOther) { if (fs_mgr_get_slot_suffix() == "") return; // Skip running this test if system_other is a logical partition. // Note that system_other is still a physical partition on "retrofit" devices. if (android::base::GetBoolProperty("ro.boot.dynamic_partitions", false) && !android::base::GetBoolProperty("ro.boot.dynamic_partitions_retrofit", false)) { if (android::base::GetBoolProperty("ro.boot.dynamic_partitions", false)) { return; } Loading fs_mgr/liblp/builder.cpp +1 −63 Original line number Diff line number Diff line Loading @@ -224,18 +224,6 @@ std::unique_ptr<MetadataBuilder> MetadataBuilder::NewForUpdate(const IPartitionO return nullptr; } // On retrofit DAP devices, modify the metadata so that it is suitable for being written // to the target slot later. We detect retrofit DAP devices by checking the super partition // name and system properties. // See comments for UpdateMetadataForOtherSuper. auto super_device = GetMetadataSuperBlockDevice(*metadata.get()); if (android::fs_mgr::GetBlockDevicePartitionName(*super_device) != "super" && IsRetrofitDynamicPartitionsDevice()) { if (!UpdateMetadataForOtherSuper(metadata.get(), source_slot_number, target_slot_number)) { return nullptr; } } if (IPropertyFetcher::GetInstance()->GetBoolProperty("ro.virtual_ab.enabled", false)) { if (always_keep_source_slot) { // always_keep_source_slot implies the target build does not support snapshots. Loading @@ -254,49 +242,6 @@ std::unique_ptr<MetadataBuilder> MetadataBuilder::NewForUpdate(const IPartitionO return New(*metadata.get(), &opener); } // For retrofit DAP devices, there are (conceptually) two super partitions. We'll need to translate // block device and group names to update their slot suffixes. // (On the other hand, On non-retrofit DAP devices there is only one location for metadata: the // super partition. update_engine will remove and resize partitions as needed.) bool MetadataBuilder::UpdateMetadataForOtherSuper(LpMetadata* metadata, uint32_t source_slot_number, uint32_t target_slot_number) { // Clear partitions and extents, since they have no meaning on the target // slot. We also clear groups since they are re-added during OTA. metadata->partitions.clear(); metadata->extents.clear(); metadata->groups.clear(); std::string source_slot_suffix = SlotSuffixForSlotNumber(source_slot_number); std::string target_slot_suffix = SlotSuffixForSlotNumber(target_slot_number); // Translate block devices. auto source_block_devices = std::move(metadata->block_devices); for (const auto& source_block_device : source_block_devices) { std::string partition_name = android::fs_mgr::GetBlockDevicePartitionName(source_block_device); std::string slot_suffix = GetPartitionSlotSuffix(partition_name); if (slot_suffix.empty() || slot_suffix != source_slot_suffix) { // This should never happen. It means that the source metadata // refers to a target or unknown block device. LERROR << "Invalid block device for slot " << source_slot_suffix << ": " << partition_name; return false; } std::string new_name = partition_name.substr(0, partition_name.size() - slot_suffix.size()) + target_slot_suffix; auto new_device = source_block_device; if (!UpdateBlockDevicePartitionName(&new_device, new_name)) { LERROR << "Partition name too long: " << new_name; return false; } metadata->block_devices.emplace_back(new_device); } return true; } MetadataBuilder::MetadataBuilder() : auto_slot_suffixing_(false) { memset(&geometry_, 0, sizeof(geometry_)); geometry_.magic = LP_METADATA_GEOMETRY_MAGIC; Loading Loading @@ -789,9 +734,7 @@ std::vector<Interval> MetadataBuilder::PrioritizeSecondHalfOfSuper( std::vector<Interval> first_half; std::vector<Interval> second_half; for (const auto& region : free_list) { // Note: deprioritze if not the main super partition. Even though we // don't call this for retrofit devices, we will allow adding additional // block devices on non-retrofit devices. // Note: deprioritze if not the main super partition. if (region.device_index != 0 || region.end <= midpoint) { first_half.emplace_back(region); continue; Loading Loading @@ -1224,11 +1167,6 @@ bool MetadataBuilder::IsABDevice() { return !IPropertyFetcher::GetInstance()->GetProperty("ro.boot.slot_suffix", "").empty(); } bool MetadataBuilder::IsRetrofitDynamicPartitionsDevice() { return IPropertyFetcher::GetInstance()->GetBoolProperty("ro.boot.dynamic_partitions_retrofit", false); } bool MetadataBuilder::ShouldHalveSuper() const { return GetBlockDevicePartitionName(0) == LP_METADATA_DEFAULT_PARTITION_NAME && !IPropertyFetcher::GetInstance()->GetBoolProperty("ro.virtual_ab.enabled", false); Loading fs_mgr/liblp/device_test.cpp +0 −17 Original line number Diff line number Diff line Loading @@ -60,20 +60,3 @@ TEST_F(DeviceTest, ReadSuperPartitionCurrentSlot) { auto metadata = ReadMetadata(super_name, slot_number); EXPECT_NE(metadata, nullptr); } TEST_F(DeviceTest, ReadSuperPartitionOtherSlot) { auto other_slot_suffix = fs_mgr_get_other_slot_suffix(); if (other_slot_suffix.empty()) { GTEST_SKIP() << "No other slot, skipping"; } if (IPropertyFetcher::GetInstance()->GetBoolProperty("ro.boot.dynamic_partitions_retrofit", false)) { GTEST_SKIP() << "Device with retrofit dynamic partition may not have metadata at other " << "slot, skipping"; } auto other_slot_number = SlotNumberForSlotSuffix(other_slot_suffix); auto other_super_name = fs_mgr_get_super_partition_name(other_slot_number); auto other_metadata = ReadMetadata(other_super_name, other_slot_number); EXPECT_NE(other_metadata, nullptr); } fs_mgr/liblp/images.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -223,7 +223,7 @@ bool ImageBuilder::Export(const std::string& file) { return false; } if (device_images_.size() > 1) { LERROR << "Cannot export to a single image on retrofit builds."; LERROR << "Cannot export to a single image on multi-super configurations."; return false; } // No gzip compression; no checksum. Loading Loading
fs_mgr/README.overlayfs.md +0 −6 Original line number Diff line number Diff line Loading @@ -96,12 +96,6 @@ Caveats may fail because of the scratch partition. If this happens, clear the scratch storage by running either either _fastboot flashall_ or _adb enable-verity_. Then reinstate the overrides and continue. - For implementation simplicity on retrofit dynamic partition devices, take the whole alternate super (eg: if "*a*" slot, then the whole of "*system_b*"). Since landing a filesystem on the alternate super physical device without differentiating if it is setup to support logical or physical, the alternate slot metadata and previous content will be lost. - There are other subtle caveats requiring complex logic to solve. Have evaluated them as too complex or not worth the trouble, please File a bug if a use case needs to be covered. Loading
fs_mgr/libfs_avb/tests/fs_avb_device_test.cpp +2 −6 Original line number Diff line number Diff line Loading @@ -59,9 +59,7 @@ TEST(FsAvbUtilTest, GetHashtreeDescriptor_SystemOther) { if (fs_mgr_get_slot_suffix() == "") return; // Skip running this test if system_other is a logical partition. // Note that system_other is still a physical partition on "retrofit" devices. if (android::base::GetBoolProperty("ro.boot.dynamic_partitions", false) && !android::base::GetBoolProperty("ro.boot.dynamic_partitions_retrofit", false)) { if (android::base::GetBoolProperty("ro.boot.dynamic_partitions", false)) { return; } Loading Loading @@ -98,9 +96,7 @@ TEST(AvbHandleTest, LoadAndVerifyVbmeta_SystemOther) { if (fs_mgr_get_slot_suffix() == "") return; // Skip running this test if system_other is a logical partition. // Note that system_other is still a physical partition on "retrofit" devices. if (android::base::GetBoolProperty("ro.boot.dynamic_partitions", false) && !android::base::GetBoolProperty("ro.boot.dynamic_partitions_retrofit", false)) { if (android::base::GetBoolProperty("ro.boot.dynamic_partitions", false)) { return; } Loading
fs_mgr/liblp/builder.cpp +1 −63 Original line number Diff line number Diff line Loading @@ -224,18 +224,6 @@ std::unique_ptr<MetadataBuilder> MetadataBuilder::NewForUpdate(const IPartitionO return nullptr; } // On retrofit DAP devices, modify the metadata so that it is suitable for being written // to the target slot later. We detect retrofit DAP devices by checking the super partition // name and system properties. // See comments for UpdateMetadataForOtherSuper. auto super_device = GetMetadataSuperBlockDevice(*metadata.get()); if (android::fs_mgr::GetBlockDevicePartitionName(*super_device) != "super" && IsRetrofitDynamicPartitionsDevice()) { if (!UpdateMetadataForOtherSuper(metadata.get(), source_slot_number, target_slot_number)) { return nullptr; } } if (IPropertyFetcher::GetInstance()->GetBoolProperty("ro.virtual_ab.enabled", false)) { if (always_keep_source_slot) { // always_keep_source_slot implies the target build does not support snapshots. Loading @@ -254,49 +242,6 @@ std::unique_ptr<MetadataBuilder> MetadataBuilder::NewForUpdate(const IPartitionO return New(*metadata.get(), &opener); } // For retrofit DAP devices, there are (conceptually) two super partitions. We'll need to translate // block device and group names to update their slot suffixes. // (On the other hand, On non-retrofit DAP devices there is only one location for metadata: the // super partition. update_engine will remove and resize partitions as needed.) bool MetadataBuilder::UpdateMetadataForOtherSuper(LpMetadata* metadata, uint32_t source_slot_number, uint32_t target_slot_number) { // Clear partitions and extents, since they have no meaning on the target // slot. We also clear groups since they are re-added during OTA. metadata->partitions.clear(); metadata->extents.clear(); metadata->groups.clear(); std::string source_slot_suffix = SlotSuffixForSlotNumber(source_slot_number); std::string target_slot_suffix = SlotSuffixForSlotNumber(target_slot_number); // Translate block devices. auto source_block_devices = std::move(metadata->block_devices); for (const auto& source_block_device : source_block_devices) { std::string partition_name = android::fs_mgr::GetBlockDevicePartitionName(source_block_device); std::string slot_suffix = GetPartitionSlotSuffix(partition_name); if (slot_suffix.empty() || slot_suffix != source_slot_suffix) { // This should never happen. It means that the source metadata // refers to a target or unknown block device. LERROR << "Invalid block device for slot " << source_slot_suffix << ": " << partition_name; return false; } std::string new_name = partition_name.substr(0, partition_name.size() - slot_suffix.size()) + target_slot_suffix; auto new_device = source_block_device; if (!UpdateBlockDevicePartitionName(&new_device, new_name)) { LERROR << "Partition name too long: " << new_name; return false; } metadata->block_devices.emplace_back(new_device); } return true; } MetadataBuilder::MetadataBuilder() : auto_slot_suffixing_(false) { memset(&geometry_, 0, sizeof(geometry_)); geometry_.magic = LP_METADATA_GEOMETRY_MAGIC; Loading Loading @@ -789,9 +734,7 @@ std::vector<Interval> MetadataBuilder::PrioritizeSecondHalfOfSuper( std::vector<Interval> first_half; std::vector<Interval> second_half; for (const auto& region : free_list) { // Note: deprioritze if not the main super partition. Even though we // don't call this for retrofit devices, we will allow adding additional // block devices on non-retrofit devices. // Note: deprioritze if not the main super partition. if (region.device_index != 0 || region.end <= midpoint) { first_half.emplace_back(region); continue; Loading Loading @@ -1224,11 +1167,6 @@ bool MetadataBuilder::IsABDevice() { return !IPropertyFetcher::GetInstance()->GetProperty("ro.boot.slot_suffix", "").empty(); } bool MetadataBuilder::IsRetrofitDynamicPartitionsDevice() { return IPropertyFetcher::GetInstance()->GetBoolProperty("ro.boot.dynamic_partitions_retrofit", false); } bool MetadataBuilder::ShouldHalveSuper() const { return GetBlockDevicePartitionName(0) == LP_METADATA_DEFAULT_PARTITION_NAME && !IPropertyFetcher::GetInstance()->GetBoolProperty("ro.virtual_ab.enabled", false); Loading
fs_mgr/liblp/device_test.cpp +0 −17 Original line number Diff line number Diff line Loading @@ -60,20 +60,3 @@ TEST_F(DeviceTest, ReadSuperPartitionCurrentSlot) { auto metadata = ReadMetadata(super_name, slot_number); EXPECT_NE(metadata, nullptr); } TEST_F(DeviceTest, ReadSuperPartitionOtherSlot) { auto other_slot_suffix = fs_mgr_get_other_slot_suffix(); if (other_slot_suffix.empty()) { GTEST_SKIP() << "No other slot, skipping"; } if (IPropertyFetcher::GetInstance()->GetBoolProperty("ro.boot.dynamic_partitions_retrofit", false)) { GTEST_SKIP() << "Device with retrofit dynamic partition may not have metadata at other " << "slot, skipping"; } auto other_slot_number = SlotNumberForSlotSuffix(other_slot_suffix); auto other_super_name = fs_mgr_get_super_partition_name(other_slot_number); auto other_metadata = ReadMetadata(other_super_name, other_slot_number); EXPECT_NE(other_metadata, nullptr); }
fs_mgr/liblp/images.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -223,7 +223,7 @@ bool ImageBuilder::Export(const std::string& file) { return false; } if (device_images_.size() > 1) { LERROR << "Cannot export to a single image on retrofit builds."; LERROR << "Cannot export to a single image on multi-super configurations."; return false; } // No gzip compression; no checksum. Loading